feat(agent): improve investigation contracts and runtime readiness
This commit is contained in:
@@ -6,6 +6,7 @@ function runtime(state: "missing" | "enqueued" | "delivered", active = false) {
|
||||
const adapter = Object.assign(Object.create(OpencodeRuntimeAdapter.prototype), {
|
||||
ensureClient: async () => ({ session: { active: async () => active ? { s: {} } : {}, interrupt: async (input: unknown) => { calls.push(input); } } }),
|
||||
agentMessageState: async () => state,
|
||||
ensureSessionToolsReady: async () => undefined,
|
||||
prompt: async (...args: unknown[]) => { calls.push(args); },
|
||||
}) as OpencodeRuntimeAdapter;
|
||||
return { adapter, calls };
|
||||
@@ -13,7 +14,7 @@ function runtime(state: "missing" | "enqueued" | "delivered", active = false) {
|
||||
test("host reply continuation injects fixed ID only when absent; queued and consumed IDs never reinject", async () => {
|
||||
const missing = runtime("missing");
|
||||
expect(await missing.adapter.continueInteraction("s", "msg_fixed", "answer")).toBe("started");
|
||||
expect(missing.calls).toEqual([["s", "answer", undefined, "msg_fixed"]]);
|
||||
expect(missing.calls).toEqual([["s", "answer", undefined, "msg_fixed", undefined]]);
|
||||
const busy = runtime("missing", true);
|
||||
await expect(busy.adapter.continueInteraction("s", "msg_fixed", "answer")).rejects.toThrow("still active");
|
||||
expect(busy.calls).toEqual([]);
|
||||
|
||||
Reference in New Issue
Block a user