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
8 changes: 8 additions & 0 deletions src/agent/opencode-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ export function createOpencodeV2Setup(options: OpencodeV2SetupOptions = {}): (ct
text = version !== undefined
? `billion-context@${version} — proxy connected, no ACP session yet. Send a model request, then run /acp again.`
: "bili: no ACP session yet (send a model request first, then run /acp)";
} else if (!status) {
// fetchStatus soft-fails to undefined both when the proxy 404s an absent or
// never-seen conversation and when the proxy is unreachable. Probe the
// manifest to claim "connected" only when it answers.
const version = await fetchProxyVersion(base).catch(() => undefined);
text = version !== undefined
? `billion-context@${version} — proxy connected, no ACP session yet. Send a model request, then run /acp again.`
: "bili: cannot reach the bili proxy (run `bili start`, then run /acp again)";
} else {
const errText = status?.error;
text = typeof errText === "string" && errText.length > 0
Expand Down
33 changes: 33 additions & 0 deletions tests/opencode-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ function startFakeProxyV2(): Promise<{ origin: string; toolCalls: Array<{ conver
return;
}
if ((req.url ?? "").startsWith("/__bili/plugin/status")) {
if ((req.url ?? "").includes("ses_acp_idle")) {
res.writeHead(404, { "content-type": "application/json" });
res.end(JSON.stringify({ ok: false, error: "unknown plugin conversation" }));
return;
}
res.writeHead(200, { "content-type": "application/json" });
const panel = (req.url ?? "").includes("ses_acp_long") ? "X".repeat(1500) : "ACP-PANEL-OK";
res.end(JSON.stringify({ ok: true, panel }));
return;
}
if ((req.url ?? "") === "/__bili/plugin/manifest") {
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ version: "9.9.9-test" }));
return;
}
res.writeHead(404);
res.end("{}");
});
Expand Down Expand Up @@ -385,6 +395,29 @@ test("v2 setup: /acp reports no proxy detected via synthetic when no proxy", asy
});
});

test("v2 setup: first /acp before any model request shows the idle notice (proxy 404s the conversation)", async () => {
const proxy = await startFakeProxyV2();
const fake = makeFakeCtx();
try {
await withEnv({ BILLION_CONTEXT_PROXY: proxy.origin, BILLION_CONTEXT_PLUGIN: undefined }, async () => {
const cleanup = await biliOpencodePlugin.setup(fake.ctx as never);
try {
const acp = fake.addedCommands.find((c) => c.name === "acp")!;
await acp.execute({ sessionID: "ses_acp_idle" });
await until(() => fake.syntheticCalls.length === 1);
assert.match(fake.syntheticCalls[0].description!, /billion-context@9\.9\.9-test \u2014 proxy connected, no ACP session yet/);
assert.match(fake.syntheticCalls[0].text, /not an instruction/);
assert.equal(fake.syntheticCalls[0].resume, false);
} finally {
cleanup();
}
});
} finally {
await proxy.close();
}
});


test("v2 setup: /acp truncates long panels to the TUI notice cap", async () => {
const proxy = await startFakeProxyV2();
const fake = makeFakeCtx();
Expand Down
Loading