agy-cli forwards a run_command tool that declares toolSummary when agy adds its own. agy adds a required toolSummary to the MCP tools it loads. When the client's own run_command already lists toolSummary as required, the duplicate makes the schema invalid and the toolbox fails to start. The bridge now drops toolSummary from run_command's required list when it lists the tool. On the way back it fills in "Run command" when agy kept the summary to itself and the client's schema declares the property. A summary the model sent is kept, and a schema without the property is left alone. Run at 52b77b78 on mote: packages/agy-cli `bun test` 25/25. Broken by hand: with main's index.mjs, the new tool-summary test goes red. The author checked a live agy client: run_command is the only tool that requires toolSummary, and an agy-to-magpie-to-agy session ran `pwd`. Not tried here: a live agy session, since the local agy account is disabled. Co-authored-by: andrew-zyf <andrew-zyf@users.noreply.github.com>
60 lines
2.1 KiB
JavaScript
60 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, AGY_BRIDGE_STORED_SIGNIN: "skip" }, 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],
|
|
["signin.mjs", false],
|
|
["catalog.mjs", false],
|
|
["step-usage.mjs", false],
|
|
["tool-schema.mjs", false],
|
|
["tool-summary.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)
|