When a client steers a live tool turn, agy-cli now waits for agy to commit the MCP responses (a tool_call_update, the next generation, or the prompt ending; AGY_BRIDGE_MCP_COMMIT_WAIT_MS, default 5s) before sending session/cancel. Before, the cancel could beat the response, and agy recorded "Tool execution was canceled". A clean steer keeps SQLite step usage trusted, and an unpolled LONGTOOL result stays in the steered prompt. A steer in progress is not evicted or reclaimed, and a second steer gets 503. Reviewed at 01de2cc. Run on a separate test Mac (Bun 1.4.2, temp HOME): bun scripts/check.mjs agy-cli ok; bun test ./packages/agy-cli 17 pass. Broken by hand: with no commit wait, the smoke steer case, six steer-in-session groups and usage-settlement go red. Not tried by the reviewer: a real agy (the author's live run on agy 1.5.6 is in the PR). Co-authored-by: tungloong <tungloong@users.noreply.github.com>
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
// Runs the suites in test/ (brought over from gitxm/yce-magpie-agy, MIT), each
|
|
// in a bun process of its own: they mock node:child_process, move the clock and
|
|
// set the bridge's environment, and smoke.mjs ends with process.exit.
|
|
import { expect, test } from "bun:test"
|
|
import path from "node:path"
|
|
|
|
const dir = path.join(import.meta.dir, "test")
|
|
const hook = path.join(dir, "cp-hook.mjs")
|
|
|
|
function run(args, timeout) {
|
|
const result = Bun.spawnSync({ cmd: [process.execPath, ...args], cwd: dir, env: { ...process.env }, stdout: "pipe", stderr: "pipe", timeout })
|
|
const output = result.stdout.toString() + result.stderr.toString()
|
|
if (result.exitCode !== 0) console.error(output)
|
|
return { code: result.exitCode, output }
|
|
}
|
|
|
|
for (const [name, mocks] of [
|
|
["platform.mjs", true],
|
|
["compat.mjs", true],
|
|
["prefill.mjs", false],
|
|
["usage.mjs", true],
|
|
["catalog.mjs", false],
|
|
["step-usage.mjs", false],
|
|
["tool-schema.mjs", false],
|
|
["usage-settlement.mjs", false],
|
|
["steer-in-session.mjs", false],
|
|
["repeat-batch.mjs", false],
|
|
["conversation-key.mjs", false],
|
|
["windows-nc.mjs", false],
|
|
]) {
|
|
test(`test/${name}`, () => {
|
|
// bun's 5s default per test is a fixed wait these process-spawning tests
|
|
// overrun on a loaded machine; the 240s run bounds a real hang.
|
|
const { code, output } = run(["test", "--timeout", "120000", ...(mocks ? ["--preload", hook] : []), `./${name}`], 240_000)
|
|
expect(output).toMatch(/\b[1-9]\d* pass\b/)
|
|
expect(code).toBe(0)
|
|
}, 250_000)
|
|
}
|
|
|
|
|
|
test("test/re2-pattern-unit.mjs", () => {
|
|
const { code, output } = run([path.join(dir, "re2-pattern-unit.mjs")], 60_000)
|
|
expect(output).toMatch(/ALL OK/)
|
|
expect(code).toBe(0)
|
|
}, 70_000)
|
|
|
|
test("test/smoke.mjs against a fake agy", () => {
|
|
const { code, output } = run([path.join(dir, "smoke.mjs")], 240_000)
|
|
expect(output).toMatch(/ALL OK \(\d+ checks\)/)
|
|
expect(code).toBe(0)
|
|
}, 250_000)
|
|
|
|
test("test/array-items-unit.mjs", () => {
|
|
const { code, output } = run([path.join(dir, "array-items-unit.mjs")], 60_000)
|
|
expect(output).toMatch(/ALL OK/)
|
|
expect(code).toBe(0)
|
|
}, 70_000)
|