The open source coding agent.
TypeScript
fix(acp): rename setSessionModel to unstable_setSessionModel (#9940)
Alex Sadleirfc0210c2fdd3
diff --git a/packages/opencode/src/acp/agent.ts b/packages/opencode/src/acp/agent.tsindex e165509b9dc..d4d556485da 100644--- a/packages/opencode/src/acp/agent.ts+++ b/packages/opencode/src/acp/agent.ts@@ -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)diff --git a/packages/opencode/test/acp/agent-interface.test.ts b/packages/opencode/test/acp/agent-interface.test.tsnew file mode 100644index 00000000000..a915d30ebe6--- /dev/null+++ b/packages/opencode/test/acp/agent-interface.test.ts@@ -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",+ )+ }+ })+})