Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/agent/opencode-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ export function createOpencodeV2Setup(options: OpencodeV2SetupOptions = {}): (ct
const base = state.proxyBase ?? proxyBaseFromEnv();
if (!base) return { content: "bili: no proxy detected (launch opencode through `bili opencode`, or point the provider baseURL at the bili proxy)" };
try {
// Panel-first for acp_status: the proxy's status
// endpoint renders the same rich panel the /acp
// command shows; the forwarded kernel tool returns
// the legacy flat report. acp_status is read-only,
// so reading the panel changes no state. Fall back
// to the tool call when no panel comes back (older
// proxy, unknown conversation).
if (t.name === "acp_status") {
const status = await fetchStatus(base, tctx.sessionID);
const panel = status?.["panel"];
if (typeof panel === "string" && panel.length > 0) return { content: panel };
}
const result = await forwardTool(base, tctx.sessionID, t.name, args);
return { content: result };
} catch (err) {
Expand Down
9 changes: 8 additions & 1 deletion tests/opencode-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,15 @@ test("v2 setup: activates from /bili/ baseURL on round 1, stamps headers, forwar
assert.equal(proxy.toolCalls.at(-1)?.conversationId, "ses_v2_1");
assert.equal(proxy.toolCalls.at(-1)?.tool, "compress");

const statusOut = await fake.addedTools.find((t) => t.name === "acp_status")!.execute({}, { sessionID: "ses_other" });
// Panel-first: acp_status returns the status panel when the
// proxy serves one for this conversation (ses_other gets the
// generic "ACP-PANEL-OK"), and falls back to the forwarded
// kernel tool when the status endpoint 404s (ses_acp_idle).
const panelOut = await fake.addedTools.find((t) => t.name === "acp_status")!.execute({}, { sessionID: "ses_other" });
assert.equal(panelOut.content, "ACP-PANEL-OK");
const statusOut = await fake.addedTools.find((t) => t.name === "acp_status")!.execute({}, { sessionID: "ses_acp_idle" });
assert.equal(statusOut.content, "STATUS-RESULT");
assert.equal(proxy.toolCalls.at(-1)?.tool, "acp_status");
} finally {
cleanup();
}
Expand Down
Loading