Skip to content

Commit fc0210c

Browse files
authored
fix(acp): rename setSessionModel to unstable_setSessionModel (anomalyco#9940)
1 parent f1df6f2 commit fc0210c

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

packages/opencode/src/acp/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ export namespace ACP {
10841084
}
10851085
}
10861086

1087-
async setSessionModel(params: SetSessionModelRequest) {
1087+
async unstable_setSessionModel(params: SetSessionModelRequest) {
10881088
const session = this.sessionManager.get(params.sessionId)
10891089

10901090
const model = Provider.parseModel(params.modelId)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { describe, expect, test } from "bun:test"
2+
import { ACP } from "../../src/acp/agent"
3+
import type { Agent as ACPAgent } from "@agentclientprotocol/sdk"
4+
5+
/**
6+
* Type-level test: This line will fail to compile if ACP.Agent
7+
* doesn't properly implement the ACPAgent interface.
8+
*
9+
* The SDK checks for methods like `agent.unstable_setSessionModel` at runtime
10+
* and throws "Method not found" if they're missing. TypeScript allows optional
11+
* interface methods to be omitted, but the SDK still expects them.
12+
*
13+
* @see https://github.com/agentclientprotocol/typescript-sdk/commit/7072d3f
14+
*/
15+
type _AssertAgentImplementsACPAgent = ACP.Agent extends ACPAgent ? true : never
16+
const _typeCheck: _AssertAgentImplementsACPAgent = true
17+
18+
/**
19+
* Runtime verification that optional methods the SDK expects are actually implemented.
20+
* The SDK's router checks `if (!agent.methodName)` and throws MethodNotFound if missing.
21+
*/
22+
describe("acp.agent interface compliance", () => {
23+
// Extract method names from the ACPAgent interface type
24+
type ACPAgentMethods = keyof ACPAgent
25+
26+
// Methods that the SDK's router explicitly checks for at runtime
27+
const sdkCheckedMethods: ACPAgentMethods[] = [
28+
// Required
29+
"initialize",
30+
"newSession",
31+
"prompt",
32+
"cancel",
33+
// Optional but checked by SDK router
34+
"loadSession",
35+
"setSessionMode",
36+
"authenticate",
37+
// Unstable - SDK checks these with unstable_ prefix
38+
"unstable_listSessions",
39+
"unstable_forkSession",
40+
"unstable_resumeSession",
41+
"unstable_setSessionModel",
42+
]
43+
44+
test("Agent implements all SDK-checked methods", () => {
45+
for (const method of sdkCheckedMethods) {
46+
expect(typeof ACP.Agent.prototype[method as keyof typeof ACP.Agent.prototype], `Missing method: ${method}`).toBe(
47+
"function",
48+
)
49+
}
50+
})
51+
})

0 commit comments

Comments
 (0)