fix(acp): rename setSessionModel to unstable_setSessionModel (#9940)

This commit is contained in:
Alex Sadleir
2026-01-22 15:11:09 +11:00
committed by GitHub
parent f1df6f2d18
commit fc0210c2fd
2 changed files with 52 additions and 1 deletions

View File

@@ -1084,7 +1084,7 @@ export namespace ACP {
}
}
async setSessionModel(params: SetSessionModelRequest) {
async unstable_setSessionModel(params: SetSessionModelRequest) {
const session = this.sessionManager.get(params.sessionId)
const model = Provider.parseModel(params.modelId)

View File

@@ -0,0 +1,51 @@
import { describe, expect, test } from "bun:test"
import { ACP } from "../../src/acp/agent"
import type { Agent as ACPAgent } from "@agentclientprotocol/sdk"
/**
* Type-level test: This line will fail to compile if ACP.Agent
* doesn't properly implement the ACPAgent interface.
*
* The SDK checks for methods like `agent.unstable_setSessionModel` at runtime
* and throws "Method not found" if they're missing. TypeScript allows optional
* interface methods to be omitted, but the SDK still expects them.
*
* @see https://github.com/agentclientprotocol/typescript-sdk/commit/7072d3f
*/
type _AssertAgentImplementsACPAgent = ACP.Agent extends ACPAgent ? true : never
const _typeCheck: _AssertAgentImplementsACPAgent = true
/**
* Runtime verification that optional methods the SDK expects are actually implemented.
* The SDK's router checks `if (!agent.methodName)` and throws MethodNotFound if missing.
*/
describe("acp.agent interface compliance", () => {
// Extract method names from the ACPAgent interface type
type ACPAgentMethods = keyof ACPAgent
// Methods that the SDK's router explicitly checks for at runtime
const sdkCheckedMethods: ACPAgentMethods[] = [
// Required
"initialize",
"newSession",
"prompt",
"cancel",
// Optional but checked by SDK router
"loadSession",
"setSessionMode",
"authenticate",
// Unstable - SDK checks these with unstable_ prefix
"unstable_listSessions",
"unstable_forkSession",
"unstable_resumeSession",
"unstable_setSessionModel",
]
test("Agent implements all SDK-checked methods", () => {
for (const method of sdkCheckedMethods) {
expect(typeof ACP.Agent.prototype[method as keyof typeof ACP.Agent.prototype], `Missing method: ${method}`).toBe(
"function",
)
}
})
})