@parcha/agentrun 0.4.27 → 0.4.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/lib/commands.generated.mjs +20 -0
- package/lib/deploy.mjs +64 -9
- package/lib/doctor.mjs +11 -2
- package/lib/harness.mjs +12 -12
- package/lib/service.mjs +31 -2
- package/package.json +2 -2
- package/skills/agentrun-cli/references/commands.md +6 -4
package/README.md
CHANGED
|
@@ -141,10 +141,17 @@ any address, and stopped; `AGENTRUN_START_TIMEOUT_MS` sets that wait, in millise
|
|
|
141
141
|
overwrites that log; it is private to you, as the server's first lines name its API token. A log the disk could not hold
|
|
142
142
|
all of is named with the error that cut it short.
|
|
143
143
|
|
|
144
|
-
Where
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
Where a new agent that names no place goes, by mode:
|
|
145
|
+
|
|
146
|
+
- Where Docker answers on this machine, it runs in a Docker box of its own with a shell, and a line on stderr, after the
|
|
147
|
+
address, says so: `Boxes: docker (on by default; set AGENTRUN_BOXES to change).`
|
|
148
|
+
- Where it does not, and the runner has no shell (Mode 1), its create is refused, `name a box`: it names a box, or the
|
|
149
|
+
runner (`"place": {"mode": "runner"}`) to run without a shell. That line says why, and `capabilities.places.default_place`
|
|
150
|
+
is `null`. So is `agentrun deploy` of a package that names no `tools` and no `computer` list, at its preview: name its tools
|
|
151
|
+
(`tools: []` keeps the runner) or its computer list.
|
|
152
|
+
- In Mode 2, where the runner's shell is Archil's serverless exec, it is not refused: it runs on the runner, as before.
|
|
153
|
+
|
|
154
|
+
A Docker box's image is built on its first run, which shows that on its timeline. `AGENTRUN_BOXES=none` turns boxes off.
|
|
148
155
|
|
|
149
156
|
pi runs every agent out of the box. The Claude Code and Codex harnesses need their own packages beside the server; when
|
|
150
157
|
one is missing, AgentRun says so with the one command to paste: `npx` with this package, the server and that harness's
|
|
@@ -613,6 +613,16 @@ export const COMMANDS = [
|
|
|
613
613
|
"required": false,
|
|
614
614
|
"description": "Only runs with this status."
|
|
615
615
|
},
|
|
616
|
+
{
|
|
617
|
+
"name": "scope",
|
|
618
|
+
"type": "string",
|
|
619
|
+
"enum": [
|
|
620
|
+
"active",
|
|
621
|
+
"review"
|
|
622
|
+
],
|
|
623
|
+
"required": false,
|
|
624
|
+
"description": "Factory active executions (including archived) or unarchived terminal escalations and failures for this agent, excluding imports. Uses keyset cursors bound to filters; incompatible with status and archived. Default scoped page size 50, maximum 100."
|
|
625
|
+
},
|
|
616
626
|
{
|
|
617
627
|
"name": "label",
|
|
618
628
|
"type": "string",
|
|
@@ -3480,6 +3490,16 @@ export const COMMANDS = [
|
|
|
3480
3490
|
"required": false,
|
|
3481
3491
|
"description": "Only runs with this status."
|
|
3482
3492
|
},
|
|
3493
|
+
{
|
|
3494
|
+
"name": "scope",
|
|
3495
|
+
"type": "string",
|
|
3496
|
+
"enum": [
|
|
3497
|
+
"active",
|
|
3498
|
+
"review"
|
|
3499
|
+
],
|
|
3500
|
+
"required": false,
|
|
3501
|
+
"description": "Factory scope: active includes every nonterminal execution and continuable stopped turn, including archived runs; review selects unarchived terminal escalations and failures separately. Both exclude imported history and use keyset cursors bound to scope, agent and revision. Cannot combine with status or archived. Page limit defaults to 50 (maximum 100). No scope preserves the ordinary history listing."
|
|
3502
|
+
},
|
|
3483
3503
|
{
|
|
3484
3504
|
"name": "archived",
|
|
3485
3505
|
"type": "boolean",
|
package/lib/deploy.mjs
CHANGED
|
@@ -371,16 +371,43 @@ async function confirmed(io, values, question, offTerminal) {
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
/**
|
|
375
|
-
|
|
374
|
+
/** What a deploy target that sets up triggers itself (a backend in front of an install that does not make them, as an
|
|
375
|
+
* API-only install does not make a Composio trigger) says it did with each, by name: `triggers_set_up` on its apply's
|
|
376
|
+
* answer, and on its plan's (beside `plan` or in it), each `{name, made, enabled?, reason?, message?}`. Its word stands
|
|
377
|
+
* over the install's: a trigger it made is never said skipped, whatever the install's plan or warning says, and one it
|
|
378
|
+
* did not make is said skipped in its words. A trigger it says nothing of keeps the install's word. */
|
|
379
|
+
function setUpBy(answer) {
|
|
380
|
+
const listed = Array.isArray(answer?.triggers_set_up) ? answer.triggers_set_up : Array.isArray(answer?.plan?.triggers_set_up) ? answer.plan.triggers_set_up : [];
|
|
381
|
+
const said = new Map();
|
|
382
|
+
for (const one of listed) {
|
|
383
|
+
if (one === null || typeof one !== "object" || typeof one.name !== "string" || typeof one.made !== "boolean") continue;
|
|
384
|
+
const name = one.name.trim();
|
|
385
|
+
if (name && !said.has(name)) said.set(name, one);
|
|
386
|
+
}
|
|
387
|
+
return said;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const textOf = (value) => (typeof value === "string" && value.trim() ? value.trim() : undefined);
|
|
391
|
+
|
|
392
|
+
/** Why the target says it did not make `trigger` (setUpBy): its message, else its reason in a sentence of the CLI's. */
|
|
393
|
+
const unmadeWhy = (base, trigger, said) => textOf(said.message) ?? `${base} did not set up the trigger ${trigger.name} (${trigger.kind})${textOf(said.reason) ? `: ${textOf(said.reason)}` : ""}.`;
|
|
394
|
+
|
|
395
|
+
/** The plan's lines, as the deploy prints them before it applies anything. A trigger the target says it sets up
|
|
396
|
+
* (setUpBy) is planned made where the install's plan skips it; one it says it does not is skipped in its words. */
|
|
397
|
+
function planLines(base, template, sha, plan, grants, setUp = new Map()) {
|
|
376
398
|
const rows = [];
|
|
377
399
|
rows.push([plan.action === "revise" ? "~" : "+", "agent", template.name, plan.action === "revise" ? `revise ${plan.agent_id}` : "new"]);
|
|
378
400
|
for (const name of plan.missing_secrets) rows.push(["!", "key", name, "missing: add it on the target"]);
|
|
379
401
|
for (const need of plan.unmatched_mcp) rows.push([need.required ? "!" : "?", "tools", `${need.toolkit} (${need.source})`, need.required ? "missing: save a server of it on the target" : "missing: the agent runs without them"]);
|
|
380
402
|
for (const tool of grants) rows.push(["+", "grant", tool, "allowed"]);
|
|
381
403
|
for (const trigger of plan.triggers) {
|
|
382
|
-
const
|
|
383
|
-
rows.push([
|
|
404
|
+
const said = trigger.action === "remove" ? undefined : setUp.get(trigger.name);
|
|
405
|
+
if (said?.made === false) rows.push(["!", "trigger", trigger.name, `${trigger.kind} skipped: ${unmadeWhy(base, trigger, said)}`]);
|
|
406
|
+
else if (said?.made && trigger.action === "skip") rows.push(["+", "trigger", trigger.name, `${trigger.kind} (the target sets it up)`]);
|
|
407
|
+
else {
|
|
408
|
+
const mark = { create: "+", update: "~", remove: "-", skip: "!" }[trigger.action] ?? "?";
|
|
409
|
+
rows.push([mark, "trigger", trigger.name, `${trigger.kind}${trigger.action === "skip" ? ` skipped: ${trigger.reason ?? ""}` : trigger.reason ? ` (${trigger.reason})` : ""}`]);
|
|
410
|
+
}
|
|
384
411
|
}
|
|
385
412
|
if (plan.computer) rows.push([" ", "computer", plan.computer.kind, plan.computer.provider ?? ""]);
|
|
386
413
|
const width = Math.max(...rows.map(([, , name]) => name.length));
|
|
@@ -534,7 +561,7 @@ async function deploy(ctx) {
|
|
|
534
561
|
const body = { grants, sha: template.sha, ...(parameters ? { parameters } : {}), ...(onto ?? {}) };
|
|
535
562
|
const { value: planned } = await to.call("POST", `/templates/${enc(template.id)}/apply`, { ...body, dry_run: true });
|
|
536
563
|
const plan = planned.plan;
|
|
537
|
-
for (const line of planLines(to.base, template, sha, plan, grants)) say(io, line);
|
|
564
|
+
for (const line of planLines(to.base, template, sha, plan, grants, setUpBy(planned))) say(io, line);
|
|
538
565
|
// An agent this package already made there with these parameters (the plan's twins), which no lock here names (it is
|
|
539
566
|
// gone, or this CLI never wrote it): another would run beside it, its schedules firing twice. --agent says which.
|
|
540
567
|
const twins = !onto && picked !== "new" && Array.isArray(plan.twins) ? plan.twins : [];
|
|
@@ -556,16 +583,44 @@ async function deploy(ctx) {
|
|
|
556
583
|
// A trigger the apply could not make yet (a connection or a feed the target lacks; a warning says which) is not in its
|
|
557
584
|
// answer. The lock then names no package, so the next deploy of the same files applies again and makes it once it can.
|
|
558
585
|
// One the target never makes (its plan's skip code not_an_option: a webhook on an API-only install) is no reason to:
|
|
559
|
-
// the plan above said it is skipped, and the same files stay up to date.
|
|
586
|
+
// the plan above said it is skipped, and the same files stay up to date. Where the target says what it set up itself
|
|
587
|
+
// (setUpBy), its word is the one taken: a trigger it made is made, one it did not make is not made yet unless its reason
|
|
588
|
+
// is not_an_option.
|
|
560
589
|
const there = new Set((applied.triggers ?? []).map((one) => one.name));
|
|
561
|
-
const
|
|
590
|
+
const setUp = setUpBy(applied);
|
|
591
|
+
const unmade = plan.triggers
|
|
592
|
+
.filter((one) => {
|
|
593
|
+
if (one.action === "remove") return false;
|
|
594
|
+
const said = setUp.get(one.name);
|
|
595
|
+
if (said) return !said.made && said.reason !== "not_an_option";
|
|
596
|
+
return one.code !== "not_an_option" && !there.has(one.name);
|
|
597
|
+
})
|
|
598
|
+
.map((one) => one.name);
|
|
562
599
|
const written = { target: to.base, agent_id: applied.agent_id, revision_id: applied.revision_id, package_sha256: unmade.length ? null : sha, deployed_at: new Date().toISOString() };
|
|
563
600
|
from.lock.write(written);
|
|
564
|
-
|
|
601
|
+
// The install's warning on a trigger (triggers.<i>, the package's i-th: the plan's triggers in order, its removals
|
|
602
|
+
// after them) gives way to the target's word on it: none for one the target made that the install did not, the
|
|
603
|
+
// target's own warning for one it did not make.
|
|
604
|
+
const order = plan.triggers.filter((one) => one.action !== "remove");
|
|
605
|
+
const kindOf = new Map(order.map((one) => [one.name, one.kind]));
|
|
606
|
+
const replaced = (name) => {
|
|
607
|
+
const said = name === undefined ? undefined : setUp.get(name);
|
|
608
|
+
return said !== undefined && (!said.made || !there.has(name));
|
|
609
|
+
};
|
|
610
|
+
const warnings = (applied.warnings ?? []).filter((warning) => {
|
|
611
|
+
const index = /^triggers\.(\d+)(?:\.|$)/.exec(String(warning.field))?.[1];
|
|
612
|
+
return !replaced(index === undefined ? undefined : order[Number(index)]?.name);
|
|
613
|
+
});
|
|
614
|
+
for (const [i, one] of order.entries()) {
|
|
615
|
+
const said = setUp.get(one.name);
|
|
616
|
+
if (said?.made === false) warnings.push({ field: `triggers.${i}`, ...(textOf(said.reason) ? { reason: textOf(said.reason) } : {}), message: unmadeWhy(to.base, one, said) });
|
|
617
|
+
}
|
|
618
|
+
for (const warning of warnings) say(io, `Warning (${warning.field}): ${warning.message}`);
|
|
619
|
+
for (const [name, said] of setUp) if (said.made && !there.has(name) && kindOf.has(name)) say(io, `Trigger ${name} (${kindOf.get(name)}) set up by ${to.base}${said.enabled === false ? ", off" : ""}.`);
|
|
565
620
|
if (unmade.length) say(io, `Not made on ${to.base} yet: ${unmade.join(", ")}. Until they are, the lock names no package, so the next deploy applies again (keeping the revision when nothing else changed).`);
|
|
566
621
|
say(io, `Deployed ${template.name} to ${to.base}: the agent ${applied.agent_id}, revision ${applied.revision_version} (${applied.agent_change}). Lock: ${from.lock.file}.`);
|
|
567
622
|
const code = from.kind === "agent" ? await sourceSchedules(io, from, values) : 0;
|
|
568
|
-
io.stdout.write(`${JSON.stringify({ status: "deployed", ...written, revision_version: applied.revision_version, agent_change: applied.agent_change, template: template.id, warnings
|
|
623
|
+
io.stdout.write(`${JSON.stringify({ status: "deployed", ...written, revision_version: applied.revision_version, agent_change: applied.agent_change, template: template.id, warnings, ...(setUp.size ? { triggers_set_up: [...setUp.values()] } : {}) })}\n`);
|
|
569
624
|
return code;
|
|
570
625
|
}
|
|
571
626
|
|
package/lib/doctor.mjs
CHANGED
|
@@ -331,8 +331,17 @@ export async function doctorOf({
|
|
|
331
331
|
// Another box that is ready (Daytona, Modal, ...) runs an agent's computer without Docker: then Docker's absence is a fact.
|
|
332
332
|
const others = boxes.filter((b) => b.id !== "docker" && b.available === true).map((b) => b.id);
|
|
333
333
|
if (box?.available) add("docker", "Docker", "ok", "Docker boxes are ready: an agent with a computer runs its tools in one.");
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
// Where a new agent with no place goes is the server's places.default_place: null where it has no default (no Docker,
|
|
335
|
+
// and a runner with no shell: Mode 1), so it names its place, never another box that is ready; else as before.
|
|
336
|
+
else if (box && others.length) {
|
|
337
|
+
const ready = others.join(" or ");
|
|
338
|
+
const goes = caps?.places?.default_place === null ? `A new agent must name its place: a box (${ready}), or the runner` : `An agent that needs a computer runs in ${ready} instead`;
|
|
339
|
+
add("docker", "Docker", "info", `No Docker box: ${box.reason ?? "unavailable"}. ${goes}.`, { details: { ready: others } });
|
|
340
|
+
}
|
|
341
|
+
else if (box) {
|
|
342
|
+
const goes = caps?.places?.default_place === null ? "a new agent must name its place: a box, or the runner" : "new agents run on the runner";
|
|
343
|
+
add("docker", "Docker", "warn", `No Docker box: ${box.reason ?? "unavailable"}. An agent that needs a computer (bash, files) fails to start, and ${goes}.`, { fix: dockerFix(box.reason ?? ""), docs: DOCS.docker });
|
|
344
|
+
}
|
|
336
345
|
else {
|
|
337
346
|
const info = exec("docker", ["info", "--format", "{{.ServerVersion}}"]);
|
|
338
347
|
const said = `${info.stderr ?? ""}`.trim().split("\n")[0];
|
package/lib/harness.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// `agentrun harness install goose|cursor` and `agentrun harness install --recipe FILE`: the harness its owner
|
|
2
|
-
// never a run (Goose; Cursor, on the owner's own Cursor API key;
|
|
3
|
-
// HARNESS.md#a-recipe). The server installed with this command does it (agentrun-serve install-harness), as it runs
|
|
1
|
+
// `agentrun harness install goose|cursor|antigravity` and `agentrun harness install --recipe FILE`: the harness its owner
|
|
2
|
+
// installs, never a run (Goose; Cursor, on the owner's own Cursor API key; Google Antigravity, by the recipe AgentRun
|
|
3
|
+
// ships; or an ACP agent a recipe file names: HARNESS.md#a-recipe). The server installed with this command does it (agentrun-serve install-harness), as it runs
|
|
4
4
|
// validate-template: the pinned archive downloaded, its sha256 checked, unpacked into DATA/harnesses/<id>, the binary's
|
|
5
5
|
// sha256 checked (for Cursor, every file's too; for a recipe that pins none, the first one recorded), then put in place
|
|
6
6
|
// read-only. DATA is this command's (~/.agentrun unless --data names one), the store `npx @parcha/agentrun` starts the
|
|
@@ -15,8 +15,8 @@ import { readFileSync } from "node:fs";
|
|
|
15
15
|
import { homedir } from "node:os";
|
|
16
16
|
import { join, resolve } from "node:path";
|
|
17
17
|
|
|
18
|
-
/** The harnesses this command installs by name. */
|
|
19
|
-
const INSTALLABLE = ["goose", "cursor"];
|
|
18
|
+
/** The harnesses this command installs by name: antigravity by the recipe AgentRun ships (the ACP package's). */
|
|
19
|
+
const INSTALLABLE = ["goose", "cursor", "antigravity"];
|
|
20
20
|
|
|
21
21
|
/** A variable named like a credential (a KEY, TOKEN, SECRET, PASSWORD or CREDENTIAL(S) segment). */
|
|
22
22
|
const KEY_NAMED = /(?:^|_)(?:KEY|TOKEN|TOKENS|SECRET|PASSWORD|CREDENTIALS?)(?:_|$)/i;
|
|
@@ -37,10 +37,10 @@ export const HARNESS_INSTALL = {
|
|
|
37
37
|
command: ["harness", "install"],
|
|
38
38
|
pathParams: ["harness"],
|
|
39
39
|
argsOptional: true,
|
|
40
|
-
summary: "Install a harness AgentRun runs only once its owner installs it (goose, cursor, or a recipe file's), then restart AgentRun",
|
|
40
|
+
summary: "Install a harness AgentRun runs only once its owner installs it (goose, cursor, antigravity, or a recipe file's), then restart AgentRun",
|
|
41
41
|
help: [
|
|
42
42
|
["HARNESS", `the harness: ${INSTALLABLE.join(", ")}. Its pinned release is downloaded and checked by sha256 into DATA/harnesses/HARNESS; run again, it downloads nothing`],
|
|
43
|
-
["--recipe FILE", "in place of HARNESS: a recipe file (HARNESS.md#a-recipe), checked against its five rules before anything is downloaded"],
|
|
43
|
+
["--recipe FILE", "in place of HARNESS: a recipe file (HARNESS.md#a-recipe), checked against its five rules before anything is downloaded; a recipe AgentRun ships by its name (antigravity), unless a file of that name is here (./NAME names it)"],
|
|
44
44
|
["--data DIR", "the data directory of the AgentRun it is for (default ~/.agentrun, where npx @parcha/agentrun keeps it)"],
|
|
45
45
|
],
|
|
46
46
|
options: { recipe: { type: "string" } },
|
|
@@ -51,7 +51,7 @@ export const HARNESS_INSTALL = {
|
|
|
51
51
|
const launcher = await launcherOf(cli, "installs a harness");
|
|
52
52
|
// No key reaches the install: every variable named like one is left out of its environment.
|
|
53
53
|
const keyless = Object.fromEntries(Object.entries(env).filter(([key]) => !KEY_NAMED.test(key)));
|
|
54
|
-
const which = values.recipe === undefined ? [name] : ["--recipe",
|
|
54
|
+
const which = values.recipe === undefined ? [name] : ["--recipe", values.recipe];
|
|
55
55
|
return spawnSync(launcher, ["install-harness", ...which, "--data", dataOf(values, env)], { stdio: "inherit", env: keyless }).status ?? 1;
|
|
56
56
|
},
|
|
57
57
|
};
|
|
@@ -61,7 +61,7 @@ export const HARNESS_SIGN_IN = {
|
|
|
61
61
|
pathParams: [],
|
|
62
62
|
summary: "Sign a recipe's agent in to your own account with the agent's own sign-in, in this terminal (Antigravity's agy acp --login); a server you start with --harness-sign-in on your own machine then runs your own runs on it",
|
|
63
63
|
help: [
|
|
64
|
-
["--recipe FILE", "the recipe file, whose signIn names the agent's own sign-in flags; its agent installed first with agentrun harness install
|
|
64
|
+
["--recipe FILE", "the recipe file, whose signIn names the agent's own sign-in flags, or a recipe AgentRun ships by its name (antigravity); its agent installed first with agentrun harness install"],
|
|
65
65
|
["--data DIR", "the data directory the recipe's agent was installed into (default ~/.agentrun)"],
|
|
66
66
|
],
|
|
67
67
|
options: { recipe: { type: "string" } },
|
|
@@ -71,7 +71,7 @@ export const HARNESS_SIGN_IN = {
|
|
|
71
71
|
// The agent prints where to sign in on this terminal itself, and keeps its sign-in in its own folder: no key is
|
|
72
72
|
// needed, so none reaches it.
|
|
73
73
|
const keyless = Object.fromEntries(Object.entries(env).filter(([key]) => !KEY_NAMED.test(key)));
|
|
74
|
-
return spawnSync(launcher, ["sign-in-harness", "--recipe",
|
|
74
|
+
return spawnSync(launcher, ["sign-in-harness", "--recipe", values.recipe, "--data", dataOf(values, env)], { stdio: "inherit", env: keyless }).status ?? 1;
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -109,7 +109,7 @@ export const HARNESS_CHECK = {
|
|
|
109
109
|
pathParams: [],
|
|
110
110
|
summary: "Run a recipe's installed agent for real and check it (tools off, env allowlist, pins, limits, no side requests, resume, a denied call, an MCP tool): a JSON report and three facts. Real models cost money",
|
|
111
111
|
help: [
|
|
112
|
-
["--recipe FILE", "the recipe file (HARNESS.md#a-recipe); its agent installed first with agentrun harness install
|
|
112
|
+
["--recipe FILE", "the recipe file (HARNESS.md#a-recipe), or a recipe AgentRun ships by its name (antigravity); its agent installed first with agentrun harness install"],
|
|
113
113
|
["--model PROVIDER/MODEL", "the run's model, for a recipe billed through the proxy (openrouter/anthropic/claude-haiku-4.5, anthropic/claude-haiku-4-5)"],
|
|
114
114
|
["--report FILE", "where the JSON report goes (default ./harness-check-ID.json)"],
|
|
115
115
|
["--cap USD", "the most the check may spend (default 0.25)"],
|
|
@@ -119,7 +119,7 @@ export const HARNESS_CHECK = {
|
|
|
119
119
|
async run({ values, env, cli }) {
|
|
120
120
|
if (values.recipe === undefined) throw cli.fail(2, "agentrun harness-check needs --recipe FILE.");
|
|
121
121
|
const launcher = await launcherOf(cli, "checks a harness");
|
|
122
|
-
const flags = ["--recipe",
|
|
122
|
+
const flags = ["--recipe", values.recipe, "--data", dataOf(values, env)];
|
|
123
123
|
if (values.model !== undefined) flags.push("--model", values.model);
|
|
124
124
|
if (values.report !== undefined) flags.push("--report", resolve(values.report));
|
|
125
125
|
if (values.cap !== undefined) flags.push("--cap", values.cap);
|
package/lib/service.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// (tailscale.mjs); with --env, on a model gateway, an Ollama off its default address or with a start-time switch on (SERVICE_ENV). `agentrun stop` stops the AgentRun the installer starts in the
|
|
7
7
|
// background where there is no service manager (a container): its pid is in ~/.agentrun/agentrun.pid.
|
|
8
8
|
import { spawn, spawnSync } from "node:child_process";
|
|
9
|
-
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { homedir, userInfo } from "node:os";
|
|
11
11
|
import { join, resolve } from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
@@ -174,6 +174,32 @@ const keyMove = (url, { shared = false, ollamaHost } = {}) => {
|
|
|
174
174
|
/** The usage counts' two switches in SERVICE_ENV, which install also copies from its own shell. */
|
|
175
175
|
const TELEMETRY_NAMES = ["AGENTRUN_TELEMETRY", "DO_NOT_TRACK"];
|
|
176
176
|
|
|
177
|
+
/** Whether the gateway address `value` carries a user name or password, read as a URL parser reads it (an
|
|
178
|
+
* `https:/user@host` with one slash too), or as an address with no scheme: an `@` before its first `/`, `?` or `#`. */
|
|
179
|
+
function hasUserinfo(value) {
|
|
180
|
+
if (/^\s*(?:[a-z][a-z0-9+.-]*:\/\/)?[^/?#\s]*@/i.test(value)) return true;
|
|
181
|
+
try {
|
|
182
|
+
const url = new URL(value.trim());
|
|
183
|
+
return url.username !== "" || url.password !== "";
|
|
184
|
+
} catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Writes the service file `file` whole or not at all, readable by its owner alone (0600): a temporary file beside it,
|
|
190
|
+
* made new with that mode, renamed over it. A crash mid-write leaves the service as it was, never half a file. */
|
|
191
|
+
function writeService(file, text) {
|
|
192
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
193
|
+
rmSync(temp, { force: true });
|
|
194
|
+
try {
|
|
195
|
+
writeFileSync(temp, text, { mode: 0o600, flag: "wx" });
|
|
196
|
+
renameSync(temp, file);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
rmSync(temp, { force: true });
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
177
203
|
const sleep = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
178
204
|
|
|
179
205
|
/** The service manager of this platform, driven through `exec` (spawnSync's shape). */
|
|
@@ -495,6 +521,9 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
|
|
|
495
521
|
}
|
|
496
522
|
if (!Object.hasOwn(SERVICE_ENV, key)) throw fail(2, `--env takes ${SERVICE_NAMES.slice(0, -1).join(", ")} or ${SERVICE_NAMES.at(-1)}, not ${key}: a key goes in the console (Settings → Model keys), never in a service file.`);
|
|
497
523
|
if (/[\0-\x1f]/.test(pair)) throw fail(2, `${key}'s value has a line break or another control character.`);
|
|
524
|
+
// A user or password in the gateway's address is a key in a service file: refused, and never echoed.
|
|
525
|
+
// Read past leading space and with or without a scheme, as an address before its first /, ? or #.
|
|
526
|
+
if (key === "AGENT_MODEL_BASE_URL" && hasUserinfo(pair.slice(at + 1))) throw fail(2, "AGENT_MODEL_BASE_URL takes the gateway's address with no user name or password in it: a key goes in the console (Settings → Model keys), never in a service file.");
|
|
498
527
|
const takes = SERVICE_ENV[key];
|
|
499
528
|
// The value is never echoed: it may be a key.
|
|
500
529
|
if (takes && pair.slice(at + 1) !== "" && !takes.includes(pair.slice(at + 1))) throw fail(2, `${key} takes ${takes.join(" or ")} alone, or nothing to remove it: a model key goes in the console (Settings → Model keys), never in a service file.`);
|
|
@@ -545,7 +574,7 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
|
|
|
545
574
|
const vars = { ...model, ...(at ? { AGENTRUN_PUBLIC_URL: at.url, AGENTRUN_TRUSTED_PROXIES: "loopback" } : {}) };
|
|
546
575
|
mkdirSync(join(root, "logs"), { recursive: true, mode: 0o700 });
|
|
547
576
|
mkdirSync(join(manager.file, ".."), { recursive: true });
|
|
548
|
-
|
|
577
|
+
writeService(manager.file, manager.text({ program, args, path: env.PATH ?? "/usr/bin:/bin", log, env: vars }));
|
|
549
578
|
// A service from before keeps every variable it may hold but AGENT_MODEL_API_KEY, which is said in one line once
|
|
550
579
|
// the file is written without it (a refused install says nothing of it).
|
|
551
580
|
if (Object.hasOwn(was, "AGENT_MODEL_API_KEY")) say(`This re-install drops AGENT_MODEL_API_KEY from the service. ${keyMove(model.AGENT_MODEL_BASE_URL, { shared: share || publicUrl !== undefined, ollamaHost: model.OLLAMA_HOST })}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
4
4
|
"description": "AgentRun, the open-source platform that supercharges your agents (self-improvement, durable execution and a control plane on top of your favorite agent harness), on this machine with one command: npx @parcha/agentrun",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"NOTICE"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@parcha/agentrun-serve": "0.1.0-beta.
|
|
20
|
+
"@parcha/agentrun-serve": "0.1.0-beta.61"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node --test 'test/*.test.mjs'"
|
|
@@ -177,6 +177,7 @@ Route: `GET /agents/{agent_id}/runs`.
|
|
|
177
177
|
- `--limit INTEGER` (integer)
|
|
178
178
|
- `--cursor STRING` (string): `next_cursor` from the previous page.
|
|
179
179
|
- `--status queued|working|paused|input_required|completed|failed|cancelled` (string, one of these): Only runs with this status.
|
|
180
|
+
- `--scope active|review` (string, one of these): Factory active executions (including archived) or unarchived terminal escalations and failures for this agent, excluding imports. Uses keyset cursors bound to filters; incompatible with status and archived. Default scoped page size 50, maximum 100.
|
|
180
181
|
- `--label STRING` (string): Only runs holding this label: `<key>:<value>`, split at the first `:` (a key holds none). Once per request; a second `label`, or one that does not read as a label, is 400.
|
|
181
182
|
- `--all` (boolean, this CLI's own): every page: follows next_cursor and prints one list, its next_cursor null; stops past 1000 pages, exit 1
|
|
182
183
|
|
|
@@ -533,11 +534,11 @@ Route: `PUT /files/{file_id}`.
|
|
|
533
534
|
|
|
534
535
|
### `agentrun harness install HARNESS`
|
|
535
536
|
|
|
536
|
-
Install a harness AgentRun runs only once its owner installs it (goose, cursor, or a recipe file's), then restart AgentRun.
|
|
537
|
+
Install a harness AgentRun runs only once its owner installs it (goose, cursor, antigravity, or a recipe file's), then restart AgentRun.
|
|
537
538
|
|
|
538
539
|
Route: none, it runs on this machine.
|
|
539
540
|
|
|
540
|
-
- `--recipe FILE` (string, this CLI's own): in place of HARNESS: a recipe file (HARNESS.md#a-recipe), checked against its five rules before anything is downloaded
|
|
541
|
+
- `--recipe FILE` (string, this CLI's own): in place of HARNESS: a recipe file (HARNESS.md#a-recipe), checked against its five rules before anything is downloaded; a recipe AgentRun ships by its name (antigravity), unless a file of that name is here (./NAME names it)
|
|
541
542
|
- `--data DIR` (string, this CLI's own): the data directory of the AgentRun it is for (default ~/.agentrun, where npx @parcha/agentrun keeps it)
|
|
542
543
|
|
|
543
544
|
### `agentrun harness keys`
|
|
@@ -554,7 +555,7 @@ Sign a recipe's agent in to your own account with the agent's own sign-in, in th
|
|
|
554
555
|
|
|
555
556
|
Route: none, it runs on this machine.
|
|
556
557
|
|
|
557
|
-
- `--recipe FILE` (string, this CLI's own): the recipe file, whose signIn names the agent's own sign-in flags; its agent installed first with agentrun harness install
|
|
558
|
+
- `--recipe FILE` (string, this CLI's own): the recipe file, whose signIn names the agent's own sign-in flags, or a recipe AgentRun ships by its name (antigravity); its agent installed first with agentrun harness install
|
|
558
559
|
- `--data DIR` (string, this CLI's own): the data directory the recipe's agent was installed into (default ~/.agentrun)
|
|
559
560
|
|
|
560
561
|
## harness-check
|
|
@@ -565,7 +566,7 @@ Run a recipe's installed agent for real and check it (tools off, env allowlist,
|
|
|
565
566
|
|
|
566
567
|
Route: none, it runs on this machine.
|
|
567
568
|
|
|
568
|
-
- `--recipe FILE` (string, this CLI's own): the recipe file (HARNESS.md#a-recipe); its agent installed first with agentrun harness install
|
|
569
|
+
- `--recipe FILE` (string, this CLI's own): the recipe file (HARNESS.md#a-recipe), or a recipe AgentRun ships by its name (antigravity); its agent installed first with agentrun harness install
|
|
569
570
|
- `--model PROVIDER/MODEL` (string, this CLI's own): the run's model, for a recipe billed through the proxy (openrouter/anthropic/claude-haiku-4.5, anthropic/claude-haiku-4-5)
|
|
570
571
|
- `--report FILE` (string, this CLI's own): where the JSON report goes (default ./harness-check-ID.json)
|
|
571
572
|
- `--cap USD` (string, this CLI's own): the most the check may spend (default 0.25)
|
|
@@ -1110,6 +1111,7 @@ Route: `GET /runs`.
|
|
|
1110
1111
|
- `--agent STRING` (string): Only this agent's runs.
|
|
1111
1112
|
- `--revision STRING` (string): Only runs of this revision.
|
|
1112
1113
|
- `--status queued|working|paused|input_required|completed|failed|cancelled` (string, one of these): Only runs with this status.
|
|
1114
|
+
- `--scope active|review` (string, one of these): Factory scope: active includes every nonterminal execution and continuable stopped turn, including archived runs; review selects unarchived terminal escalations and failures separately. Both exclude imported history and use keyset cursors bound to scope, agent and revision. Cannot combine with status or archived. Page limit defaults to 50 (maximum 100). No scope preserves the ordinary history listing.
|
|
1113
1115
|
- `--archived` (boolean): true lists only archived runs; false, the default, the others.
|
|
1114
1116
|
- `--label STRING` (string): Only runs holding this label: `<key>:<value>`, split at the first `:` (a key holds none). Once per request; a second `label`, or one that does not read as a label, is 400.
|
|
1115
1117
|
- `--source STRING` (string): Only runs imported from this source, a source's name as the run's `imported_from.source` holds it (`claude-code`, `codex`, ...), or `live` for the runs made here, not imported. A name no run holds lists none. Once per request; a second `source`, or one that does not read as a name, is 400.
|