mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
* feat(server): let clients create internal agents The daemon's own branch-name and commit-message generators run as internal agents: never persisted, listed, flagged, announced, or seen by plugin lifecycle hooks. Nothing outside the daemon could ask for one, because the wire config schema strips `internal` and the agent.create transform re-pins it. A plugin that runs a one-turn helper per event therefore left an archived session in History every time. Add an optional `internal` flag to `create_agent_request` (inherited by `agent.create.request`), copy it onto the config in the session's create path, and skip provider session persistence for it like the generators do. The client SDK forwards the flag on both creation paths and gates it once on `server_info.features.internalAgents`. Two daemon paths assumed every agent is public and had to follow: `resolveAgentIdentifier` now accepts a live agent by exact id, since the id set it matched against came from listings that exclude internal agents and left `wait_for_finish` answering "Agent not found"; and archiving an internal agent now closes it without writing the record that `registry.applySnapshot` used to leave behind, so `autoArchive` does not accumulate hidden files on disk. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(server): keep internal agents whole through failure, archive, and wait Review follow-ups for internal agents: - A create that fails after the runtime is registered now closes the internal agent before rethrowing, so a hidden runtime cannot outlive the failed request. Public agents keep today's behaviour. - Archiving an internal agent cascades to attached children like any parent. cascadeArchiveChildren takes the parent record instead of reading it back from storage, where an internal agent never is. - The archived snapshot and last message of an internal agent stay readable by exact id for ten minutes, so create-then-waitForFinish returns the finished turn whether the wait lands before or after an auto-archive. Storage plays that role for public agents. - The internal-agent e2e scenarios live in the existing create_agent_request lifecycle suite rather than a new file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(server): cascade to live internal children and keep a failed internal create's worktree until it closes Internal children never reach storage, so the parent archive cascade scans live agents for them as well. A failed internal create now clears the created id only after the runtime is archived, so worktree cleanup cannot delete the directory under a runtime that would not close. Stored agent payloads carry lastError, so a retained failed helper reports its error through wait_for_finish instead of the generic message. * feat(cli,mcp): expose internal agents and document --no-wait paseo run gains --internal and create_agent gains internal, both forwarded to the create request. --no-wait becomes the documented spelling for returning immediately, matching paseo send; --background and --detach stay as hidden aliases under COMPAT tags. * test: follow the --no-wait rename and stub getRetiredInternalAgent * feat: list internal agents on request and add internal workspaces Internal agents stay hidden by default, but a caller can now ask for them: `fetch_agents_request` takes `filter.includeInternal`, snapshots carry `internal: true`, and `paseo ls --internal` shows them in an INTERNAL column. The app never passes the flag. Workspaces get the same flag. `workspace.create.request` with `internal: true` persists a hidden workspace: listings, update subscriptions, sync reads, empty-project counting, open-by-path, MCP `list_workspaces`, and plugin workspace hooks all skip it unless the caller opts in with `filter.includeInternal`. Every agent created inside an internal workspace is internal and unpersisted; AgentManager applies that from the workspace id before the plugin hook so creators cannot opt out. Archive and shutdown enumerate internal agents so nothing inside an internal workspace outlives it. Surfaces: `paseo workspace create --internal`, `paseo workspace ls --internal`, `paseo run --internal --new-workspace`, MCP `create_workspace({ internal })`, SDK `workspaces.create({ internal })` and `list({ filter: { includeInternal } })`. Clients gate on `features.internalWorkspaces`. Co-Authored-By: Claude <noreply@anthropic.com> * feat(workspaces): add background visibility with inherited creation defaults * fix(cli): resolve workspace callers on the selected daemon * test(workspaces): keep caller integration coverage in server suite * test(cli): exercise workspace callers through CLI integration harness * test(mcp): remove obsolete execution flags from browser fixtures --------- Co-authored-by: marvin-ambrozio <marvin@gustavo.eng.br> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
282 lines
12 KiB
TypeScript
282 lines
12 KiB
TypeScript
#!/usr/bin/env npx tsx
|
|
|
|
/**
|
|
* Phase 4: Run Command Tests
|
|
*
|
|
* Tests the run command - creating and running agents with tasks (top-level command).
|
|
* Since daemon may not be running, we test both:
|
|
* - Help and argument parsing
|
|
* - Graceful error handling when daemon not running
|
|
* - All flags are accepted
|
|
*
|
|
* Tests:
|
|
* - run --help shows options
|
|
* - run requires prompt argument
|
|
* - run handles daemon not running
|
|
* - run -d flag is accepted
|
|
* - run --name flag is accepted
|
|
* - run --provider flag is accepted
|
|
* - run --mode flag is accepted
|
|
* - run --cwd flag is accepted
|
|
*/
|
|
|
|
import assert from "node:assert";
|
|
import { getAvailablePort } from "./helpers/network.ts";
|
|
import { $ } from "zx";
|
|
import { mkdtemp, rm, writeFile } from "fs/promises";
|
|
import { tmpdir } from "os";
|
|
import { join } from "path";
|
|
|
|
$.verbose = false;
|
|
|
|
console.log("=== Run Command Tests ===\n");
|
|
|
|
// Allocate an unused endpoint for connection-error and argument-validation checks.
|
|
const port = await getAvailablePort();
|
|
const paseoHome = await mkdtemp(join(tmpdir(), "paseo-test-home-"));
|
|
const schemaPath = join(paseoHome, "run-output-schema.json");
|
|
await writeFile(
|
|
schemaPath,
|
|
JSON.stringify({
|
|
type: "object",
|
|
properties: {
|
|
status: { type: "string" },
|
|
},
|
|
required: ["status"],
|
|
additionalProperties: false,
|
|
}),
|
|
);
|
|
|
|
try {
|
|
// Test 1: run --help shows options
|
|
{
|
|
console.log("Test 1: run --help shows options");
|
|
const result = await $`npx paseo run --help`.nothrow();
|
|
assert.strictEqual(result.exitCode, 0, "run --help should exit 0");
|
|
assert(result.stdout.includes("--no-wait"), "help should mention --no-wait flag");
|
|
assert(
|
|
!result.stdout.includes("--internal"),
|
|
"help should not mention removed --internal flag",
|
|
);
|
|
assert(!result.stdout.includes("--background"), "help should hide legacy --background syntax");
|
|
assert(!result.stdout.includes("--detach"), "help should hide legacy --detach syntax");
|
|
assert(result.stdout.includes("--title"), "help should mention --title option");
|
|
assert(result.stdout.includes("--provider"), "help should mention --provider option");
|
|
assert(result.stdout.includes("--mode"), "help should mention --mode option");
|
|
assert(result.stdout.includes("--new-workspace"), "help should mention --new-workspace option");
|
|
assert(!result.stdout.includes("--isolation"), "help should not mention --isolation");
|
|
assert(result.stdout.includes("--cwd"), "help should mention --cwd option");
|
|
assert(result.stdout.includes("--output-schema"), "help should mention --output-schema option");
|
|
assert(result.stdout.includes("--host"), "help should mention --host option");
|
|
assert(result.stdout.includes("<prompt>"), "help should mention prompt argument");
|
|
assert(!result.stdout.includes("--ui"), "help should not mention removed --ui option");
|
|
console.log("✓ run --help shows options\n");
|
|
}
|
|
|
|
// Test 2: run requires prompt argument
|
|
{
|
|
console.log("Test 2: run requires prompt argument");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run`.nothrow();
|
|
assert.notStrictEqual(result.exitCode, 0, "should fail without prompt");
|
|
const output = result.stdout + result.stderr;
|
|
// Commander should complain about missing argument
|
|
const hasMissingArg =
|
|
output.toLowerCase().includes("missing") ||
|
|
output.toLowerCase().includes("required") ||
|
|
output.toLowerCase().includes("argument");
|
|
assert(hasMissingArg, "error should mention missing argument");
|
|
console.log("✓ run requires prompt argument\n");
|
|
}
|
|
|
|
// Test 3: run handles daemon not running
|
|
{
|
|
console.log("Test 3: run handles daemon not running");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --provider claude "test prompt"`.nothrow();
|
|
// Should fail because daemon not running
|
|
assert.notStrictEqual(result.exitCode, 0, "should fail when daemon not running");
|
|
const output = result.stdout + result.stderr;
|
|
const hasError =
|
|
output.toLowerCase().includes("daemon") ||
|
|
output.toLowerCase().includes("connect") ||
|
|
output.toLowerCase().includes("cannot");
|
|
assert(hasError, "error message should mention connection issue");
|
|
console.log("✓ run handles daemon not running\n");
|
|
}
|
|
|
|
// Test 4: run -d flag is accepted
|
|
{
|
|
console.log("Test 4: run -d flag is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run -d "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept -d flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run -d flag is accepted\n");
|
|
}
|
|
|
|
// Test 5: run --name flag is accepted
|
|
{
|
|
console.log("Test 5: run --name flag is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --name "test-agent" "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept --name flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --name flag is accepted\n");
|
|
}
|
|
|
|
// Test 6: run --provider flag is accepted
|
|
{
|
|
console.log("Test 6: run --provider flag is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --provider codex "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept --provider flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --provider flag is accepted\n");
|
|
}
|
|
|
|
// Test 6b: run --provider provider/model syntax is accepted
|
|
{
|
|
console.log("Test 6b: run --provider provider/model syntax is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --provider codex/gpt-5.4 "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept provider/model syntax");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --provider provider/model syntax is accepted\n");
|
|
}
|
|
|
|
// Test 7: run --mode flag is accepted
|
|
{
|
|
console.log("Test 7: run --mode flag is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --mode bypass "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept --mode flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --mode flag is accepted\n");
|
|
}
|
|
|
|
// Test 8: run --cwd flag is accepted
|
|
{
|
|
console.log("Test 8: run --cwd flag is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --cwd /tmp "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept --cwd flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --cwd flag is accepted\n");
|
|
}
|
|
|
|
// Test 9: run --output-schema flag is accepted
|
|
{
|
|
console.log("Test 9: run --output-schema flag is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --output-schema ${schemaPath} "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept --output-schema flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --output-schema flag is accepted\n");
|
|
}
|
|
|
|
// Test 10: run --output-schema cannot be used with --no-wait
|
|
{
|
|
console.log("Test 10: run --output-schema cannot be used with --no-wait");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --no-wait --output-schema ${schemaPath} "test prompt"`.nothrow();
|
|
assert.notStrictEqual(result.exitCode, 0, "should fail with --no-wait and --output-schema");
|
|
const output = result.stdout + result.stderr;
|
|
assert(
|
|
output.includes("--output-schema cannot be used with --no-wait"),
|
|
"error should explain background incompatibility",
|
|
);
|
|
console.log("✓ run --output-schema cannot be used with --no-wait\n");
|
|
}
|
|
|
|
// Test 11: -q (quiet) flag is accepted with run
|
|
{
|
|
console.log("Test 11: -q (quiet) flag is accepted with run");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} -q run -d "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept -q flag");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ -q (quiet) flag is accepted with run\n");
|
|
}
|
|
|
|
// Test 12: Combined flags work together
|
|
{
|
|
console.log("Test 12: Combined flags work together");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} -q run -d --name "test-fixer" --provider claude --mode bypass --cwd /tmp "Fix the tests"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept all combined flags");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ Combined flags work together\n");
|
|
}
|
|
|
|
// Test 12b: conflicting provider/model syntax is rejected before connect
|
|
{
|
|
console.log("Test 12b: conflicting provider/model syntax is rejected");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --provider codex/gpt-5.4 --model gpt-5.5 "test prompt"`.nothrow();
|
|
assert.notStrictEqual(result.exitCode, 0, "should fail for conflicting model inputs");
|
|
const output = result.stdout + result.stderr;
|
|
assert(
|
|
output.includes("Conflicting model values provided"),
|
|
"should explain conflicting model inputs",
|
|
);
|
|
console.log("✓ conflicting provider/model syntax is rejected\n");
|
|
}
|
|
|
|
// Test 13: paseo --help shows run command
|
|
{
|
|
console.log("Test 13: paseo --help shows run command");
|
|
const result = await $`npx paseo --help`.nothrow();
|
|
assert.strictEqual(result.exitCode, 0, "paseo --help should exit 0");
|
|
assert(result.stdout.includes("run"), "help should mention run command");
|
|
console.log("✓ paseo --help shows run command\n");
|
|
}
|
|
|
|
// Test 14: run --ui is rejected (flag removed)
|
|
{
|
|
console.log("Test 14: run --ui is rejected");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --ui "test prompt"`.nothrow();
|
|
assert.notStrictEqual(result.exitCode, 0, "should fail for removed --ui flag");
|
|
const output = result.stdout + result.stderr;
|
|
assert(output.includes("unknown option"), "should report unknown option for --ui");
|
|
console.log("✓ run --ui is rejected\n");
|
|
}
|
|
|
|
// Test 15: run --new-workspace is accepted
|
|
{
|
|
console.log("Test 15: run --new-workspace is accepted");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --new-workspace local "test prompt"`.nothrow();
|
|
const output = result.stdout + result.stderr;
|
|
assert(!output.includes("unknown option"), "should accept --new-workspace");
|
|
assert(!output.includes("error: option"), "should not have option parsing error");
|
|
console.log("✓ run --new-workspace is accepted\n");
|
|
}
|
|
|
|
// Test 16: run --isolation is rejected (unreleased flag removed)
|
|
{
|
|
console.log("Test 16: run --isolation is rejected");
|
|
const result =
|
|
await $`PASEO_HOME=${paseoHome} npx paseo --host localhost:${port} run --isolation local "test prompt"`.nothrow();
|
|
assert.notStrictEqual(result.exitCode, 0, "should fail for removed --isolation flag");
|
|
const output = result.stdout + result.stderr;
|
|
assert(output.includes("unknown option"), "should report unknown option for --isolation");
|
|
console.log("✓ run --isolation is rejected\n");
|
|
}
|
|
} finally {
|
|
// Clean up temp directory
|
|
await rm(paseoHome, { recursive: true, force: true });
|
|
}
|
|
|
|
console.log("=== All run tests passed ===");
|