@parcha/agentrun 0.4.22 → 0.4.23
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 +10 -9
- package/install.sh +11 -2
- package/lib/cli.mjs +30 -30
- package/lib/commands.generated.mjs +53 -4
- package/lib/deploy.mjs +149 -149
- package/lib/device.mjs +10 -15
- package/lib/doctor.mjs +3 -3
- package/lib/export.mjs +1 -0
- package/lib/harness.mjs +30 -0
- package/lib/local.mjs +13 -0
- package/lib/login.mjs +8 -22
- package/lib/own.mjs +10 -0
- package/lib/service.mjs +5 -2
- package/lib/start.mjs +39 -34
- package/lib/target.mjs +13 -4
- package/lib/template.mjs +25 -17
- package/package.json +2 -2
- package/skills/agentrun-cli/SKILL.md +3 -2
- package/skills/agentrun-cli/references/commands.md +35 -11
package/lib/doctor.mjs
CHANGED
|
@@ -11,9 +11,9 @@ import { spawnSync } from "node:child_process";
|
|
|
11
11
|
import { existsSync, readFileSync } from "node:fs";
|
|
12
12
|
import { homedir, userInfo } from "node:os";
|
|
13
13
|
import { join, resolve } from "node:path";
|
|
14
|
+
import { OWN_NODE, OWN_VERSION } from "./own.mjs";
|
|
14
15
|
import { INSTALL_COMMAND, managerOf } from "./service.mjs";
|
|
15
16
|
|
|
16
|
-
const OWN = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
17
17
|
const REPO = "https://github.com/Parcha-ai/agentrun/blob/main/packages";
|
|
18
18
|
export const DOCS = {
|
|
19
19
|
launcher: `${REPO}/agentrun/README.md`,
|
|
@@ -87,7 +87,7 @@ export async function doctorOf({
|
|
|
87
87
|
exec = (command, args) => spawnSync(command, args, { encoding: "utf8", timeout: 10_000, env }),
|
|
88
88
|
get = fetch,
|
|
89
89
|
nodeVersion = process.versions.node,
|
|
90
|
-
engines =
|
|
90
|
+
engines = OWN_NODE,
|
|
91
91
|
readRecord = plainText,
|
|
92
92
|
alive = isAlive,
|
|
93
93
|
readToken = () => undefined,
|
|
@@ -342,7 +342,7 @@ export async function doctorOf({
|
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
const exit = refused !== undefined ? 1 : !answering ? 3 : checks.some((c) => c.status === "fail") ? 1 : 0;
|
|
345
|
-
return { data, launcher:
|
|
345
|
+
return { data, launcher: OWN_VERSION, server: answering ? { url: health.url, version: version ?? null } : null, exit, checks };
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
/** The checks as a person reads them: one line each, then its fix and docs when it is not ok. */
|
package/lib/export.mjs
CHANGED
|
@@ -12,6 +12,7 @@ export const EXPORT = {
|
|
|
12
12
|
command: ["export"],
|
|
13
13
|
pathParams: ["agent"],
|
|
14
14
|
summary: "Write an agent's current revision as a template package folder, and say what the target sets up again",
|
|
15
|
+
route: "GET /agents/{agent_id}/package",
|
|
15
16
|
help: [
|
|
16
17
|
["AGENT", "the agent's id"],
|
|
17
18
|
["--out DIR", "the folder to write: a new one, or an empty one"],
|
package/lib/harness.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// (agentrun-serve check-harness, named as install-harness is, so this command's own word stays the CLI's): a JSON
|
|
12
12
|
// report, and the three facts printed. It spends, on the model's key.
|
|
13
13
|
import { spawnSync } from "node:child_process";
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
14
15
|
import { homedir } from "node:os";
|
|
15
16
|
import { join, resolve } from "node:path";
|
|
16
17
|
|
|
@@ -74,6 +75,35 @@ export const HARNESS_SIGN_IN = {
|
|
|
74
75
|
},
|
|
75
76
|
};
|
|
76
77
|
|
|
78
|
+
/** The console's page for a plan-billed recipe's keys (serve's harness-keys.ts HARNESS_KEYS_PAGE). */
|
|
79
|
+
const HARNESS_KEYS_PAGE = "/#/settings/harness-keys";
|
|
80
|
+
|
|
81
|
+
export const HARNESS_KEYS = {
|
|
82
|
+
command: ["harness", "keys"],
|
|
83
|
+
pathParams: [],
|
|
84
|
+
summary: "Print the link to Settings → Harness keys, where the owner saves the keys a plan-billed recipe runs on, for that harness alone (exit 1 when no AgentRun has started on DATA)",
|
|
85
|
+
help: [["--data DIR", "the data directory of the AgentRun the keys are for (default ~/.agentrun)"]],
|
|
86
|
+
options: {},
|
|
87
|
+
// Never a key on this terminal: a key is a secret write, the owner's signed-in session's alone, so it is pasted in the
|
|
88
|
+
// console, which keeps it sealed for that harness alone.
|
|
89
|
+
run({ values, env, io }) {
|
|
90
|
+
const data = dataOf(values, env);
|
|
91
|
+
let origin;
|
|
92
|
+
try {
|
|
93
|
+
const record = JSON.parse(readFileSync(join(data, ".server.json"), "utf8"));
|
|
94
|
+
origin = typeof record?.base_url === "string" && URL.canParse(record.base_url) ? new URL(record.base_url).origin : undefined;
|
|
95
|
+
} catch {
|
|
96
|
+
origin = undefined;
|
|
97
|
+
}
|
|
98
|
+
if (origin === undefined) {
|
|
99
|
+
io.stderr.write(`No AgentRun has started on ${data}: start it (agentrun), then save the keys in Settings → Harness keys (${HARNESS_KEYS_PAGE}).\n`);
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
102
|
+
io.stdout.write(`${origin}${HARNESS_KEYS_PAGE}\n`);
|
|
103
|
+
return 0;
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
77
107
|
export const HARNESS_CHECK = {
|
|
78
108
|
command: ["harness-check"],
|
|
79
109
|
pathParams: [],
|
package/lib/local.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The CLI's hand-written commands, which run as they are given beside the generated table's: cli.mjs runs them, and the
|
|
2
|
+
// table's generator (scripts/generate-clients.mjs) reads them so no generated command takes one of their names and the
|
|
3
|
+
// skill lists them. A command that calls the API names its routes (`route`), which the skill prints.
|
|
4
|
+
import { DEPLOY, DEPLOY_DELETE, DEPLOY_ROLLBACK } from "./deploy.mjs";
|
|
5
|
+
import { DOCTOR } from "./doctor.mjs";
|
|
6
|
+
import { EXPORT } from "./export.mjs";
|
|
7
|
+
import { HARNESS_CHECK, HARNESS_INSTALL, HARNESS_KEYS, HARNESS_SIGN_IN } from "./harness.mjs";
|
|
8
|
+
import { SECRETS } from "./login.mjs";
|
|
9
|
+
import { OPEN, SERVICE, STOP } from "./service.mjs";
|
|
10
|
+
import { SKILL_INSTALL } from "./skill.mjs";
|
|
11
|
+
import { TEMPLATE_EVAL, TEMPLATE_INSTALL, TEMPLATE_VALIDATE } from "./template.mjs";
|
|
12
|
+
|
|
13
|
+
export const LOCAL = [...SECRETS, SKILL_INSTALL, TEMPLATE_VALIDATE, TEMPLATE_EVAL, TEMPLATE_INSTALL, EXPORT, HARNESS_INSTALL, HARNESS_SIGN_IN, HARNESS_KEYS, HARNESS_CHECK, ...SERVICE, STOP, OPEN, DOCTOR, DEPLOY, DEPLOY_ROLLBACK, DEPLOY_DELETE];
|
package/lib/login.mjs
CHANGED
|
@@ -169,8 +169,8 @@ export const LOGIN = {
|
|
|
169
169
|
summary: "Sign in to a server, with a device code when it offers one, else a token read from stdin, and keep the token with the server's address in the config file",
|
|
170
170
|
route: "GET /capabilities, then its device sign-in; else GET /agents?limit=1, to check a token from stdin",
|
|
171
171
|
help: [
|
|
172
|
-
["--to URL|cloud", `the server, /v2 added when its address
|
|
173
|
-
["--base-url URL", "the server
|
|
172
|
+
["--to URL|cloud", `the server, /v2 added when its address's path holds none; cloud is AgentRun cloud (AGENTRUN_CLOUD_URL, else ${CLOUD_URL}). When its capabilities offer a device sign-in, prints an address and a code to approve there, else reads the token from stdin`],
|
|
173
|
+
["--base-url URL", "the server, /v2 added as for --to (default AGENTRUN_BASE_URL); the token from stdin, or on a terminal a device sign-in when the server offers one"],
|
|
174
174
|
["(stdin)", "the token: agentrun login --base-url URL < FILE"],
|
|
175
175
|
],
|
|
176
176
|
options: { to: { type: "string" } },
|
|
@@ -179,30 +179,16 @@ export const LOGIN = {
|
|
|
179
179
|
const named = values.to !== undefined;
|
|
180
180
|
const flagged = values["base-url"] !== undefined;
|
|
181
181
|
const given = named ? toUrl(values.to, env) : flagged ? values["base-url"] : env.AGENTRUN_BASE_URL;
|
|
182
|
-
if (given === undefined) throw cli.fail(2, "agentrun login needs the server: --to URL, --base-url URL
|
|
182
|
+
if (given === undefined) throw cli.fail(2, "agentrun login needs the server: --to URL, --base-url URL or AGENTRUN_BASE_URL.");
|
|
183
183
|
const base = cli.baseOf(given, named ? "--to" : flagged ? "--base-url" : "AGENTRUN_BASE_URL");
|
|
184
|
-
// The device sign-in
|
|
185
|
-
// terminal, which can hold no token (off one, stdin holds the token, as a script gives it). A SignInError's words
|
|
186
|
-
// are this CLI's own and say nothing was written. The token it ends with is the server's own answer from its own
|
|
187
|
-
// origin, so it is kept as it is.
|
|
184
|
+
// The device sign-in for --to, or when stdin is a terminal, which can hold no token.
|
|
188
185
|
if (named || io.stdin.isTTY) {
|
|
189
|
-
let offer;
|
|
190
186
|
try {
|
|
191
|
-
offer = deviceOffer(await capabilitiesOf(base), base);
|
|
187
|
+
const offer = deviceOffer(await capabilitiesOf(base), base);
|
|
188
|
+
if (offer) return keep(base, await deviceSignIn(base, offer, io), env, io, cli);
|
|
192
189
|
} catch (error) {
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
// A server named otherwise that offers a sign-in this CLI does not take, or is not reached: why, then the
|
|
196
|
-
// refusal below of a token typed on a terminal, exit 2 as for a server that offers none.
|
|
197
|
-
io.stderr.write(`${error.message}\n`);
|
|
198
|
-
}
|
|
199
|
-
if (offer) {
|
|
200
|
-
try {
|
|
201
|
-
return keep(base, await deviceSignIn(base, offer, io), env, io, cli);
|
|
202
|
-
} catch (error) {
|
|
203
|
-
if (error instanceof SignInError) throw cli.fail(error.code, error.message);
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
190
|
+
if (error instanceof SignInError) throw cli.fail(error.code, error.message);
|
|
191
|
+
throw error;
|
|
206
192
|
}
|
|
207
193
|
}
|
|
208
194
|
const token = (await readSecret(io, cli.fail, "The token", "agentrun login --base-url URL < FILE")).trim();
|
package/lib/own.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This package's own version and the Node.js it needs, read once from its package.json. A module of its own that imports
|
|
2
|
+
// nothing of this package, so any module may import it (start.mjs imports cli.mjs, which imports the rest).
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
const own = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
6
|
+
|
|
7
|
+
/** This package's version. */
|
|
8
|
+
export const OWN_VERSION = own.version;
|
|
9
|
+
/** The Node.js versions it runs on: package.json's engines.node. */
|
|
10
|
+
export const OWN_NODE = own.engines.node;
|
package/lib/service.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// unit on Linux; never a system service, never sudo. The service runs the installer's command (~/.agentrun/bin/agentrun,
|
|
4
4
|
// install.sh), which brings its own Node, with --no-open and the interactive launcher's rules for the data directory and
|
|
5
5
|
// port, and writes to ~/.agentrun/logs/agentrun.log. With --tailscale it is also served on the person's tailnet
|
|
6
|
-
// (tailscale.mjs); with --env, on a local model or with a start-time switch on (SERVICE_ENV). `agentrun stop` stops the AgentRun the installer starts in the
|
|
6
|
+
// (tailscale.mjs); with --env, on a local model, 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
9
|
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -116,6 +116,8 @@ export const unitEnv = (text) =>
|
|
|
116
116
|
* are sealed in the console.
|
|
117
117
|
* - A local model's (AGENT_MODEL_BASE_URL in front of a gateway such as Ollama's), and its key at `none`: a server that
|
|
118
118
|
* holds no key for its gateway refuses each run that brings none (run-model-key.ts, model_key_required).
|
|
119
|
+
* - Where Ollama listens (OLLAMA_HOST, read as the ollama CLI reads it), for an Ollama off its default address: the
|
|
120
|
+
* server lists its models itself (serve's ollama-provider.ts).
|
|
119
121
|
* - The start-time switches (the server's start-switches.ts), on at `1` alone, for a machine its owner alone uses. A
|
|
120
122
|
* server reads them at its start, so the service restarts.
|
|
121
123
|
* - The usage counts' switches (docs/telemetry.md). A service never sees the shell that installed it, so install writes
|
|
@@ -126,6 +128,7 @@ export const SERVICE_ENV = {
|
|
|
126
128
|
AGENT_MODEL: null,
|
|
127
129
|
AGENT_MODEL_PRICE: null,
|
|
128
130
|
AGENT_MODEL_API_KEY: ["none"],
|
|
131
|
+
OLLAMA_HOST: null,
|
|
129
132
|
AGENTRUN_MCP_ALLOW_LOOPBACK: ["1"],
|
|
130
133
|
AGENTRUN_WEBHOOK_PRIVATE_TARGETS: ["1"],
|
|
131
134
|
AGENTRUN_TELEMETRY: null,
|
|
@@ -636,7 +639,7 @@ export function serviceOf({ platform = process.platform, home = homedir(), uid =
|
|
|
636
639
|
}
|
|
637
640
|
|
|
638
641
|
const VERBS = [
|
|
639
|
-
["install", "Install AgentRun as a service of this user and start it: it keeps running after the terminal closes and starts again at login", [["--port N", "the port to listen on (default: the first free from 7340; 7340 with --tailscale)"], ["--data DIR", "the data directory (default ~/.agentrun)"], ["--tailscale", "also serve it over HTTPS on your own tailnet only (tailscale serve, never Funnel); --no-tailscale takes it off"], ["--env KEY=VALUE", `a local model's variable for the server, a start-time switch or the usage counts' switch: ${Object.entries(SERVICE_ENV).map(([name, takes]) => (takes ? `${name} (${takes.join(" or ")})` : name)).join(", ")}; kept until KEY= removes it; repeatable`], ["--public-url URL", "the https address people open it at, through a proxy you run in front of it (your own tailscale serve, a reverse proxy); kept for every restart"]], { port: { type: "string" }, tailscale: { type: "boolean" }, env: { type: "string", multiple: true }, "public-url": { type: "string" } }],
|
|
642
|
+
["install", "Install AgentRun as a service of this user and start it: it keeps running after the terminal closes and starts again at login", [["--port N", "the port to listen on (default: the first free from 7340; 7340 with --tailscale)"], ["--data DIR", "the data directory (default ~/.agentrun)"], ["--tailscale", "also serve it over HTTPS on your own tailnet only (tailscale serve, never Funnel); --no-tailscale takes it off"], ["--env KEY=VALUE", `a local model's variable for the server or where Ollama listens, a start-time switch or the usage counts' switch: ${Object.entries(SERVICE_ENV).map(([name, takes]) => (takes ? `${name} (${takes.join(" or ")})` : name)).join(", ")}; kept until KEY= removes it; repeatable`], ["--public-url URL", "the https address people open it at, through a proxy you run in front of it (your own tailscale serve, a reverse proxy); kept for every restart"]], { port: { type: "string" }, tailscale: { type: "boolean" }, env: { type: "string", multiple: true }, "public-url": { type: "string" } }],
|
|
640
643
|
["status", "Say whether the service is installed and running, the console's address and its health (exit 0 healthy, 1 not, 3 not installed)", [], {}],
|
|
641
644
|
["start", "Start the service and wait until it answers", [], {}],
|
|
642
645
|
["stop", "Stop the service (it starts again at the next login)", [], {}],
|
package/lib/start.mjs
CHANGED
|
@@ -8,13 +8,14 @@ import { homedir } from "node:os";
|
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
9
|
import { StringDecoder } from "node:string_decoder";
|
|
10
10
|
import { main as cli, NOUNS, words } from "./cli.mjs";
|
|
11
|
+
import { OWN_VERSION } from "./own.mjs";
|
|
11
12
|
import { chosenPublicUrl } from "./public-url.mjs";
|
|
12
13
|
import { tailnetHint, tailnetNameOf } from "./tailscale.mjs";
|
|
13
14
|
|
|
14
15
|
export const SERVE_PACKAGE = "@parcha/agentrun-serve";
|
|
15
16
|
/** This command's package at its version, handed to the server it starts (AGENTRUN_NPX_PACKAGE), so the server's hints
|
|
16
17
|
* name this command. */
|
|
17
|
-
export const OWN_SPEC = `@parcha/agentrun@${
|
|
18
|
+
export const OWN_SPEC = `@parcha/agentrun@${OWN_VERSION}`;
|
|
18
19
|
/** Where the server listens and the console is opened: this machine only. */
|
|
19
20
|
export const HOST = "127.0.0.1"; // key-gate: loopback-rule the server this starts listens on this machine only
|
|
20
21
|
|
|
@@ -313,6 +314,42 @@ export function tellerOf() {
|
|
|
313
314
|
};
|
|
314
315
|
}
|
|
315
316
|
|
|
317
|
+
/** Runs one of the server's commands (`argv[0]`; an eval among them, which spends while it runs) to its end and answers
|
|
318
|
+
* its exit code. A stop sent to this command alone (a job runner's SIGTERM, a SIGHUP) is passed on, and this waits for
|
|
319
|
+
* the command to clean up and end: 130, 143 or 129 when a stop ended it. A hangup is passed on as a SIGTERM, which every
|
|
320
|
+
* server command stops on. Its output comes to this terminal as it is; a command that could not be started, or that a
|
|
321
|
+
* signal this command did not pass on ended, is said here (failureText). `agentrun template eval` runs its eval here
|
|
322
|
+
* too. */
|
|
323
|
+
export function runServerCommand(launcher, argv, env) {
|
|
324
|
+
const child = spawn(launcher, argv, { stdio: "inherit", env });
|
|
325
|
+
const codes = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
|
|
326
|
+
const sent = [];
|
|
327
|
+
const pass = Object.fromEntries(Object.keys(codes).map((signal) => [signal, () => {
|
|
328
|
+
const passed = signal === "SIGHUP" ? "SIGTERM" : signal;
|
|
329
|
+
sent.push(passed);
|
|
330
|
+
child.kill(passed);
|
|
331
|
+
}]));
|
|
332
|
+
for (const [signal, on] of Object.entries(pass)) process.on(signal, on);
|
|
333
|
+
const step = `run the server's ${argv[0]} command (${launcher})`;
|
|
334
|
+
return new Promise((resolve) => {
|
|
335
|
+
let over = false;
|
|
336
|
+
const done = (code) => {
|
|
337
|
+
if (over) return;
|
|
338
|
+
over = true;
|
|
339
|
+
for (const [signal, on] of Object.entries(pass)) process.off(signal, on);
|
|
340
|
+
resolve(code);
|
|
341
|
+
};
|
|
342
|
+
child.on("error", (error) => {
|
|
343
|
+
if (child.pid === undefined && !over) console.error(failureText({ command: argv[0], step, error }));
|
|
344
|
+
done(1);
|
|
345
|
+
});
|
|
346
|
+
child.on("exit", (code, signal) => {
|
|
347
|
+
if (signal !== null && !sent.includes(signal)) console.error(failureText({ command: argv[0], step, code, signal, sent }));
|
|
348
|
+
done(code ?? codes[signal] ?? 1);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
316
353
|
export async function main(argv, env = process.env) {
|
|
317
354
|
// The first argument, past --data and its value: a word there names a command (the server's own, or else the CLI's),
|
|
318
355
|
// and a flag starts the server, whose flags with values (--listen ADDR) follow.
|
|
@@ -363,39 +400,7 @@ export async function main(argv, env = process.env) {
|
|
|
363
400
|
const dataDir = dir ?? join(homedir(), ".agentrun");
|
|
364
401
|
// A name that starts with a dash keeps the equals form: the server's parser reads "--data -x" as a missing value.
|
|
365
402
|
const data = dataDir.startsWith("-") ? [`--data=${dataDir}`] : ["--data", dataDir];
|
|
366
|
-
if (rest[0] && !rest[0].startsWith("-"))
|
|
367
|
-
// A server command (an eval among them, which spends while it runs): a stop sent to this command alone (a job
|
|
368
|
-
// runner's SIGTERM, a SIGHUP) is passed on, and this waits for the command to clean up and end. A hangup is passed
|
|
369
|
-
// on as a SIGTERM, which every server command stops on. Its output comes to this terminal as it is; a command that
|
|
370
|
-
// could not be started, or that a signal this command did not pass on ended, is said here (failureText).
|
|
371
|
-
const child = spawn(launcher, [rest[0], ...data, ...rest.slice(1)], { stdio: "inherit", env: childEnv });
|
|
372
|
-
const codes = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
|
|
373
|
-
const sent = [];
|
|
374
|
-
const pass = Object.fromEntries(Object.keys(codes).map((signal) => [signal, () => {
|
|
375
|
-
const passed = signal === "SIGHUP" ? "SIGTERM" : signal;
|
|
376
|
-
sent.push(passed);
|
|
377
|
-
child.kill(passed);
|
|
378
|
-
}]));
|
|
379
|
-
for (const [signal, on] of Object.entries(pass)) process.on(signal, on);
|
|
380
|
-
const step = `run the server's ${rest[0]} command (${launcher})`;
|
|
381
|
-
return new Promise((resolve) => {
|
|
382
|
-
let over = false;
|
|
383
|
-
const done = (code) => {
|
|
384
|
-
if (over) return;
|
|
385
|
-
over = true;
|
|
386
|
-
for (const [signal, on] of Object.entries(pass)) process.off(signal, on);
|
|
387
|
-
resolve(code);
|
|
388
|
-
};
|
|
389
|
-
child.on("error", (error) => {
|
|
390
|
-
if (child.pid === undefined && !over) console.error(failureText({ command: rest[0], step, error }));
|
|
391
|
-
done(1);
|
|
392
|
-
});
|
|
393
|
-
child.on("exit", (code, signal) => {
|
|
394
|
-
if (signal !== null && !sent.includes(signal)) console.error(failureText({ command: rest[0], step, code, signal, sent }));
|
|
395
|
-
done(code ?? codes[signal] ?? 1);
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
}
|
|
403
|
+
if (rest[0] && !rest[0].startsWith("-")) return runServerCommand(launcher, [rest[0], ...data, ...rest.slice(1)], childEnv);
|
|
399
404
|
// The server's banner and request lines stay out of this terminal: one line here says where to go, the URL of the
|
|
400
405
|
// server's own "Open " line; the lines SAID names go to stderr after it, for the person, so stdout stays that one line.
|
|
401
406
|
// What it prints on stderr comes through as it is, as it prints it, at the pace this command's stderr is read (forward).
|
package/lib/target.mjs
CHANGED
|
@@ -6,10 +6,19 @@ export const CLOUD_URL = "https://api.agentrun.ai";
|
|
|
6
6
|
/** AgentRun cloud's console, where cloud's device sign-in page is. */
|
|
7
7
|
export const CLOUD_CONSOLE = "https://console.agentrun.ai";
|
|
8
8
|
|
|
9
|
-
/** The API base a
|
|
10
|
-
*
|
|
9
|
+
/** The API base of a server's address, the one rule every command takes it by: the address without its trailing
|
|
10
|
+
* slashes, with /v2 added when its path holds no v2 segment, so `https://host/prefix` is `https://host/prefix/v2` and
|
|
11
|
+
* `https://host/v2/` is `https://host/v2`. Only the path's end changes: the string is never re-serialized, so the
|
|
12
|
+
* origin is the given one, byte for byte. The caller checks the address first (cli.mjs baseOf). */
|
|
13
|
+
export function apiBase(given) {
|
|
14
|
+
const url = given.replace(/\/+$/, "");
|
|
15
|
+
const path = URL.canParse(url) ? new URL(url).pathname : "";
|
|
16
|
+
return path.split("/").includes("v2") ? url : `${url}/v2`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The API base a `--to` names: `cloud` is AGENTRUN_CLOUD_URL, else CLOUD_URL; any other address is taken as every
|
|
20
|
+
* command takes one (apiBase). The caller checks the result as every base URL is checked (cli.mjs baseOf), so a query,
|
|
11
21
|
* fragment, user or password is refused there. */
|
|
12
22
|
export function toUrl(given, env) {
|
|
13
|
-
|
|
14
|
-
return /\/v2$/.test(url) ? url : `${url}/v2`;
|
|
23
|
+
return apiBase(given === "cloud" ? env.AGENTRUN_CLOUD_URL || CLOUD_URL : given);
|
|
15
24
|
}
|
package/lib/template.mjs
CHANGED
|
@@ -2,8 +2,24 @@
|
|
|
2
2
|
// the one a server runs on the packages it ships at its start. The server installed with this command checks it
|
|
3
3
|
// (agentrun-serve validate-template), as it runs import and reset-password: this command reaches the server through its
|
|
4
4
|
// launcher and its API alone. Nothing in the package runs.
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { readdirSync, statSync } from "node:fs";
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
|
|
9
|
+
/** The refusal of the cases `names` lists that the package in `dir` does not have (a case is a folder in its evals/), in
|
|
10
|
+
* the words the server uses (template-eval.ts readCases), or undefined: every one is there, or `dir` is no folder, which
|
|
11
|
+
* the server refuses in its own words. The server still checks each case it runs whole. */
|
|
12
|
+
function missingCases(dir, names) {
|
|
13
|
+
if (!names.length || !statSync(dir, { throwIfNoEntry: false })?.isDirectory()) return undefined;
|
|
14
|
+
let cases = [];
|
|
15
|
+
try {
|
|
16
|
+
cases = readdirSync(join(dir, "evals"), { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
17
|
+
} catch {
|
|
18
|
+
// No evals/ folder: the package has no case.
|
|
19
|
+
}
|
|
20
|
+
const missing = names.filter((name) => !cases.includes(name));
|
|
21
|
+
return missing.length ? `${dir}: its eval cases do not check:\n${missing.map((name) => `- evals/${name}: no such case (the package's are ${cases.join(", ") || "none"})`).join("\n")}` : undefined;
|
|
22
|
+
}
|
|
7
23
|
|
|
8
24
|
export const TEMPLATE_VALIDATE = {
|
|
9
25
|
command: ["template", "validate"],
|
|
@@ -83,7 +99,10 @@ export const TEMPLATE_EVAL = {
|
|
|
83
99
|
],
|
|
84
100
|
options: { case: { type: "string", multiple: true }, runs: { type: "string" }, server: { type: "string" }, "grader-model": { type: "string" }, report: { type: "string" }, faux: { type: "string" } },
|
|
85
101
|
async run({ values, args, env, cli }) {
|
|
86
|
-
|
|
102
|
+
// A case the package does not have is refused here, at once, in the server's words, before its launcher starts.
|
|
103
|
+
const missing = missingCases(resolve(args[0]), values.case ?? []);
|
|
104
|
+
if (missing) throw cli.fail(2, missing);
|
|
105
|
+
const { installedServer, runServerCommand } = await import("./start.mjs");
|
|
87
106
|
const launcher = installedServer();
|
|
88
107
|
if (launcher === undefined) throw cli.fail(2, "AgentRun's server is not installed beside this command, and it is the server that runs an eval.");
|
|
89
108
|
const argv = ["eval-template", resolve(args[0])];
|
|
@@ -99,19 +118,8 @@ export const TEMPLATE_EVAL = {
|
|
|
99
118
|
childEnv = { ...env, AGENTRUN_API_KEY: token };
|
|
100
119
|
}
|
|
101
120
|
// A stop sent to this command alone (a job runner's SIGTERM, a SIGHUP) is passed on to the eval, which cancels its
|
|
102
|
-
// run and cleans up before it exits, as it does on the Ctrl-C a terminal sends both: this command waits for that
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// The eval stops on SIGINT and SIGTERM; a hangup is passed on as a SIGTERM, which it cleans up after.
|
|
106
|
-
const pass = Object.fromEntries(Object.keys(signals).map((signal) => [signal, () => child.kill(signal === "SIGHUP" ? "SIGTERM" : signal)]));
|
|
107
|
-
for (const [signal, on] of Object.entries(pass)) process.on(signal, on);
|
|
108
|
-
try {
|
|
109
|
-
return await new Promise((done) => {
|
|
110
|
-
child.on("error", () => done(1));
|
|
111
|
-
child.on("exit", (code, signal) => done(code ?? signals[signal] ?? 1));
|
|
112
|
-
});
|
|
113
|
-
} finally {
|
|
114
|
-
for (const [signal, on] of Object.entries(pass)) process.off(signal, on);
|
|
115
|
-
}
|
|
121
|
+
// run and cleans up before it exits, as it does on the Ctrl-C a terminal sends both: this command waits for that, as
|
|
122
|
+
// for every server command.
|
|
123
|
+
return runServerCommand(launcher, argv, childEnv);
|
|
116
124
|
},
|
|
117
125
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.23",
|
|
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.55"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node --test 'test/*.test.mjs'"
|
|
@@ -139,11 +139,12 @@ Two clients call the same API from code, with the same server and token. `@parch
|
|
|
139
139
|
- `agentrun doctor`: Check how this AgentRun is set up (Node, the server, its service, address, password, models, switches, Docker) and print what to change; read-only (exit 0 ok or warnings, 1 a check failed, 3 no server answering)
|
|
140
140
|
- `agentrun export AGENT`: Write an agent's current revision as a template package folder, and say what the target sets up again
|
|
141
141
|
- `agentrun files`: create, delete, get, list, upload
|
|
142
|
-
- `agentrun harness`: install, sign-in
|
|
142
|
+
- `agentrun harness`: install, keys, sign-in
|
|
143
143
|
- `agentrun harness-check`: 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
|
|
144
|
+
- `agentrun harness-keys`: list
|
|
144
145
|
- `agentrun home`: delete, list, read, write
|
|
145
146
|
- `agentrun learning`: corrections, cost, get, log, read, replay, reset, retire, workflow-revisions, write-corrections
|
|
146
|
-
- `agentrun local`: create-pairing, create-suggested-agent, delete-composio-subscription, delete-computer, delete-workspace-archil, discard-suggestion, disconnect-git-hub, get-git-hub-connection, get-model-gateway, get-suggestion, get-workspace-archil, list-composio-events, list-composio-triggers, list-computer-choices, list-computers, list-git-hub-repositories, list-mcp-server-names, list-suggestions, receive-hook-composio, restore-suggestion, rotate-composio-secret, scan-for-suggestions, test-computer, test-workspace-archil
|
|
147
|
+
- `agentrun local`: create-pairing, create-suggested-agent, delete-composio-subscription, delete-computer, delete-workspace-archil, discard-suggestion, disconnect-git-hub, get-git-hub-connection, get-model-gateway, get-suggestion, get-workspace-archil, list-composio-events, list-composio-triggers, list-computer-choices, list-computers, list-git-hub-repositories, list-mcp-server-names, list-running-computers, list-suggestions, receive-hook-composio, restore-suggestion, rotate-composio-secret, scan-for-suggestions, test-computer, test-workspace-archil
|
|
147
148
|
- `agentrun login`: Sign in to a server, with a device code when it offers one, else a token read from stdin, and keep the token with the server's address in the config file
|
|
148
149
|
- `agentrun logout`: Remove the config file login wrote, its address and token
|
|
149
150
|
- `agentrun mcp-servers`: delete, get, list, oauth-client, private-hosts, refresh
|
|
@@ -427,19 +427,20 @@ Route: `POST /connectors/{connector_id}/targets/{target_id}/sync/status`.
|
|
|
427
427
|
|
|
428
428
|
Deploy an agent's package to another AgentRun: upload, plan, apply, lock (deploy rollback, deploy delete).
|
|
429
429
|
|
|
430
|
-
Route:
|
|
430
|
+
Route: `POST /templates/import`, `POST /templates/{template}/apply`.
|
|
431
431
|
|
|
432
432
|
- `--to URL` (string, this CLI's own): where: cloud (the hosted AgentRun; AGENTRUN_CLOUD_URL overrides its address), or an AgentRun's address; left out after the first deploy, the lock's target (a folder's, only where this CLI deployed it, or cloud)
|
|
433
433
|
- `--yes` (boolean, this CLI's own): apply without asking (needed off a terminal)
|
|
434
434
|
- `--force` (boolean, this CLI's own): replace an agent edited on the target since the last deploy
|
|
435
435
|
- `--params FILE` (string, this CLI's own): the package's parameters, a JSON object
|
|
436
436
|
- `--pause-source` (boolean, this CLI's own): an install agent: turn its schedules off on this install once deployed (else they fire in both places)
|
|
437
|
+
- `--agent ID|new` (string, this CLI's own): with no lock for the target: deploy onto its agent ID, or make another agent (new), where it has one this package made with these parameters; with a lock, only the lock's agent
|
|
437
438
|
|
|
438
439
|
### `agentrun deploy delete SOURCE`
|
|
439
440
|
|
|
440
441
|
Delete the deployed agent from its target (archived first), and the lock here.
|
|
441
442
|
|
|
442
|
-
Route:
|
|
443
|
+
Route: `POST /agents/{agent_id}/archive`, `DELETE /agents/{agent_id}`.
|
|
443
444
|
|
|
444
445
|
- `--to URL` (string, this CLI's own): the target, in place of the lock's
|
|
445
446
|
- `--yes` (boolean, this CLI's own): delete without asking (needed off a terminal)
|
|
@@ -448,7 +449,7 @@ Route: none, it runs on this machine.
|
|
|
448
449
|
|
|
449
450
|
Make the deployed agent's previous revision current on its target, and the lock follow.
|
|
450
451
|
|
|
451
|
-
Route:
|
|
452
|
+
Route: `GET /agents/{agent_id}/revisions`, `POST /agents/{agent_id}/current`.
|
|
452
453
|
|
|
453
454
|
- `--to URL` (string, this CLI's own): the target, in place of the lock's
|
|
454
455
|
|
|
@@ -469,7 +470,7 @@ Route: none, it runs on this machine.
|
|
|
469
470
|
|
|
470
471
|
Write an agent's current revision as a template package folder, and say what the target sets up again.
|
|
471
472
|
|
|
472
|
-
Route:
|
|
473
|
+
Route: `GET /agents/{agent_id}/package`.
|
|
473
474
|
|
|
474
475
|
- `--out DIR` (string, this CLI's own): the folder to write: a new one, or an empty one
|
|
475
476
|
|
|
@@ -531,6 +532,14 @@ Route: none, it runs on this machine.
|
|
|
531
532
|
- `--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
|
|
532
533
|
- `--data DIR` (string, this CLI's own): the data directory of the AgentRun it is for (default ~/.agentrun, where npx @parcha/agentrun keeps it)
|
|
533
534
|
|
|
535
|
+
### `agentrun harness keys`
|
|
536
|
+
|
|
537
|
+
Print the link to Settings → Harness keys, where the owner saves the keys a plan-billed recipe runs on, for that harness alone (exit 1 when no AgentRun has started on DATA).
|
|
538
|
+
|
|
539
|
+
Route: none, it runs on this machine.
|
|
540
|
+
|
|
541
|
+
- `--data DIR` (string, this CLI's own): the data directory of the AgentRun the keys are for (default ~/.agentrun)
|
|
542
|
+
|
|
534
543
|
### `agentrun harness sign-in`
|
|
535
544
|
|
|
536
545
|
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.
|
|
@@ -554,6 +563,14 @@ Route: none, it runs on this machine.
|
|
|
554
563
|
- `--cap USD` (string, this CLI's own): the most the check may spend (default 0.25)
|
|
555
564
|
- `--data DIR` (string, this CLI's own): the data directory the recipe's agent was installed into (default ~/.agentrun)
|
|
556
565
|
|
|
566
|
+
## harness-keys
|
|
567
|
+
|
|
568
|
+
### `agentrun harness-keys list`
|
|
569
|
+
|
|
570
|
+
The keys each plan-billed harness recipe runs on, and which are saved: names only, never a value.
|
|
571
|
+
|
|
572
|
+
Route: `GET /settings/harness-keys`.
|
|
573
|
+
|
|
557
574
|
## home
|
|
558
575
|
|
|
559
576
|
### `agentrun home delete AGENT_ID PATH`
|
|
@@ -773,6 +790,12 @@ The names of the MCP servers saved here, and nothing else of them.
|
|
|
773
790
|
|
|
774
791
|
Route: `GET /settings/mcp-server-names`.
|
|
775
792
|
|
|
793
|
+
### `agentrun local list-running-computers`
|
|
794
|
+
|
|
795
|
+
Every run still going that has a computer.
|
|
796
|
+
|
|
797
|
+
Route: `GET /computers/running`.
|
|
798
|
+
|
|
776
799
|
### `agentrun local list-suggestions`
|
|
777
800
|
|
|
778
801
|
Suggested agents: each repository's scan and the agents it suggests.
|
|
@@ -833,8 +856,8 @@ Sign in to a server, with a device code when it offers one, else a token read fr
|
|
|
833
856
|
|
|
834
857
|
Route: `GET /capabilities, then its device sign-in; else GET /agents?limit=1, to check a token from stdin`.
|
|
835
858
|
|
|
836
|
-
- `--to URL|cloud` (string, this CLI's own): the server, /v2 added when its address
|
|
837
|
-
- `--base-url URL` (string, this CLI's own): the server
|
|
859
|
+
- `--to URL|cloud` (string, this CLI's own): the server, /v2 added when its address's path holds none; cloud is AgentRun cloud (AGENTRUN_CLOUD_URL, else https://api.agentrun.ai). When its capabilities offer a device sign-in, prints an address and a code to approve there, else reads the token from stdin
|
|
860
|
+
- `--base-url URL` (string, this CLI's own): the server, /v2 added as for --to (default AGENTRUN_BASE_URL); the token from stdin, or on a terminal a device sign-in when the server offers one
|
|
838
861
|
|
|
839
862
|
## logout
|
|
840
863
|
|
|
@@ -970,7 +993,7 @@ Route: `POST /runs`.
|
|
|
970
993
|
- `--effort low|medium|high` (string, one of these): How hard a run works. It sets the model's thinking level, and adds a short note on how to work right after the agent's instructions, on every harness: low answers directly, medium plans briefly and checks once, high plans each part, fills the gaps and reviews. A run started with none thinks at its agent revision's own thinking level, else the host's default, and gets no note.
|
|
971
994
|
- `--max-cost-usd NUMBER` (number): This run's cap, for every turn of it. Default the definition's `max_cost_usd`, else the effort default.
|
|
972
995
|
- `--quote-id STRING` (string): Run at a quote's terms. A different `effort` or `max_cost_usd` than the quote's is `409 quote_invalid`.
|
|
973
|
-
- `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn
|
|
996
|
+
- `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn; never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 `invalid` at `model_key` for a key under 8 characters (no cut could hold it) or one with a character that is not visible ASCII (a space, a control character, anything past ASCII); 422 at `model_key` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 `model_key_required`, never a failure at its first model call.
|
|
974
997
|
- `--workflow-first` (boolean): Whether a run of an agent that learns may start on one of its learned workflows. On (absent or true), a run whose input fits exactly one active learned workflow (its input schema has a required field, and the run's input passes it) runs that workflow first, with no turn of the agent's model: its answer is the run's answer, and if it hands the job back (it escalates, a step fails), the same run goes on with the agent, given what the workflow found. The run keeps which path it took: `workflow`, `handed_back` or `agent`. false: the agent takes the run from its first turn.
|
|
975
998
|
- `--learning use` (string, one of these): `use`: the run starts from what its agent learned (its corrections and learned workflows, as a run that learns is given them), whatever its agent's `learning` says, and keeps nothing: no compile turn, no correction and no merge, at its end or after a follow-up. Its `learning` reads `seeded` while it runs, then `dropped` with reason `use`. So many runs of one agent read one learned state, frozen (a held-out evaluation). On a server whose learning is off it is given nothing, as every run there. Absent: the agent's own (`learning: true` learns). 422 not_an_option for anything else.
|
|
976
999
|
- `--repo STRING` (string): The GitHub repository (`owner/name`) this run reaches: the one its GitHub App token is made for, so its github MCP calls are scoped to it. It must be one the agent is bound to (a repository its GitHub triggers' `accept` names on `/repository/full_name`); another is 422 at `repo` in words naming the repositories it is bound to. Absent: the agent's repository when it is bound to exactly one and the first message names none; otherwise the repository a `https://github.com/<owner>/<repo>` URL in the first message names. A run a trigger starts takes its repository from its event, and `repo` there is 422.
|
|
@@ -1069,7 +1092,7 @@ Route: `POST /runs/{run_id}/messages`.
|
|
|
1069
1092
|
|
|
1070
1093
|
- `--idempotency-key STRING` (string): Makes a create safe to retry. The same key and body within `limits.idempotency_ttl_s` replays the first answer with `Idempotent-Replayed: true`; another body is `409 idempotency_mismatch`; a retry while the first is in flight is `409 idempotency_in_progress`. Keys are scoped to the credential's account and the route.
|
|
1071
1094
|
- `--content STRING` (string, required): At most `limits.max_message_chars`. Not only whitespace.
|
|
1072
|
-
- `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn
|
|
1095
|
+
- `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn; never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 `invalid` at `model_key` for a key under 8 characters (no cut could hold it) or one with a character that is not visible ASCII (a space, a control character, anything past ASCII); 422 at `model_key` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 `model_key_required`, never a failure at its first model call. On a message it replaces the run's key from the run's next model request on, a turn still going included, and it is the first key of a run that started on the server's (mint one per turn); a message without one keeps the key the run holds, which is none once its last turn ended: then, where the server holds no key for the run's model, the message is 422 `model_key_required` and nothing is written.
|
|
1073
1096
|
- `--body JSON|@FILE|-` (application/json, required): The whole body: inline, from a file or from stdin. The flags above win over a JSON body's fields.
|
|
1074
1097
|
- `--body-type TYPE` (string): The body's type, one of application/json; any other than JSON is sent as given.
|
|
1075
1098
|
|
|
@@ -1096,6 +1119,7 @@ One file's raw bytes.
|
|
|
1096
1119
|
Route: `GET /runs/{run_id}/files/{path}`. It prints the answer's bytes as they are. PATH keeps its slashes.
|
|
1097
1120
|
|
|
1098
1121
|
- `--download INTEGER` (integer): `1` forces a download.
|
|
1122
|
+
- `--cut run` (string, one of these): `run`: the file's text cut of every value the run's own cut holds (the server's keys, the keys a person saved, its secret stores' values, the sign-in refs the run was handed), each one and each secret shape replaced by `[redacted]` in place, as the run's timeline cuts its calls; the text is `[redacted]` whole when a value still shows in a form not cut in place. The cut holds this server's values, not every secret: a value handed to the run alone at its launch (a key of its own, an MCP server's headers) is not in it, and a secret of no known shape passes as written. Answered `text/plain; charset=utf-8` with `x-agentrun-cut: run` (a server that doesn't know `cut` answers the raw bytes, without it), the whole file (`Range` is not read). A file whose type is not text (text/*, JSON, NDJSON, or an extension the server doesn't type), or whose bytes are not UTF-8 or hold a NUL, is `415 unsupported_media_type`; one over 262144 bytes is `413 payload_too_large`; a run whose cut can't be read (the sign-in it was handed doesn't open) is `403 forbidden`. Without `cut`, the file's bytes as written.
|
|
1099
1123
|
- `--range STRING` (string): One byte range, `bytes=<start>-<end>`.
|
|
1100
1124
|
|
|
1101
1125
|
### `agentrun runs resume RUN_ID`
|
|
@@ -1114,7 +1138,7 @@ Route: `POST /agents/{agent_id}/runs`.
|
|
|
1114
1138
|
- `--effort low|medium|high` (string, one of these): How hard a run works. It sets the model's thinking level, and adds a short note on how to work right after the agent's instructions, on every harness: low answers directly, medium plans briefly and checks once, high plans each part, fills the gaps and reviews. A run started with none thinks at its agent revision's own thinking level, else the host's default, and gets no note.
|
|
1115
1139
|
- `--max-cost-usd NUMBER` (number): This run's cap, for every turn of it. Default the definition's `max_cost_usd`, else the effort default.
|
|
1116
1140
|
- `--quote-id STRING` (string): Run at a quote's terms. A different `effort` or `max_cost_usd` than the quote's is `409 quote_invalid`.
|
|
1117
|
-
- `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn
|
|
1141
|
+
- `--model-key STRING` (string): The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn; never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 `invalid` at `model_key` for a key under 8 characters (no cut could hold it) or one with a character that is not visible ASCII (a space, a control character, anything past ASCII); 422 at `model_key` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 `model_key_required`, never a failure at its first model call.
|
|
1118
1142
|
- `--workflow-first` (boolean): Whether a run of an agent that learns may start on one of its learned workflows. On (absent or true), a run whose input fits exactly one active learned workflow (its input schema has a required field, and the run's input passes it) runs that workflow first, with no turn of the agent's model: its answer is the run's answer, and if it hands the job back (it escalates, a step fails), the same run goes on with the agent, given what the workflow found. The run keeps which path it took: `workflow`, `handed_back` or `agent`. false: the agent takes the run from its first turn.
|
|
1119
1143
|
- `--learning use` (string, one of these): `use`: the run starts from what its agent learned (its corrections and learned workflows, as a run that learns is given them), whatever its agent's `learning` says, and keeps nothing: no compile turn, no correction and no merge, at its end or after a follow-up. Its `learning` reads `seeded` while it runs, then `dropped` with reason `use`. So many runs of one agent read one learned state, frozen (a held-out evaluation). On a server whose learning is off it is given nothing, as every run there. Absent: the agent's own (`learning: true` learns). 422 not_an_option for anything else.
|
|
1120
1144
|
- `--repo STRING` (string): The GitHub repository (`owner/name`) this run reaches: the one its GitHub App token is made for, so its github MCP calls are scoped to it. It must be one the agent is bound to (a repository its GitHub triggers' `accept` names on `/repository/full_name`); another is 422 at `repo` in words naming the repositories it is bound to. Absent: the agent's repository when it is bound to exactly one and the first message names none; otherwise the repository a `https://github.com/<owner>/<repo>` URL in the first message names. A run a trigger starts takes its repository from its event, and `repo` there is 422.
|
|
@@ -1283,7 +1307,7 @@ Route: none, it runs on this machine.
|
|
|
1283
1307
|
- `--port N` (string, this CLI's own): the port to listen on (default: the first free from 7340; 7340 with --tailscale)
|
|
1284
1308
|
- `--data DIR` (string, this CLI's own): the data directory (default ~/.agentrun)
|
|
1285
1309
|
- `--tailscale` (boolean, this CLI's own): also serve it over HTTPS on your own tailnet only (tailscale serve, never Funnel); --no-tailscale takes it off
|
|
1286
|
-
- `--env KEY=VALUE` (string, this CLI's own): a local model's variable for the server, a start-time switch or the usage counts' switch: AGENT_MODEL_BASE_URL, AGENT_MODEL_GATEWAY_IDS, AGENT_MODEL, AGENT_MODEL_PRICE, AGENT_MODEL_API_KEY (none), AGENTRUN_MCP_ALLOW_LOOPBACK (1), AGENTRUN_WEBHOOK_PRIVATE_TARGETS (1), AGENTRUN_TELEMETRY, DO_NOT_TRACK; kept until KEY= removes it; repeatable
|
|
1310
|
+
- `--env KEY=VALUE` (string, this CLI's own): a local model's variable for the server or where Ollama listens, a start-time switch or the usage counts' switch: AGENT_MODEL_BASE_URL, AGENT_MODEL_GATEWAY_IDS, AGENT_MODEL, AGENT_MODEL_PRICE, AGENT_MODEL_API_KEY (none), OLLAMA_HOST, AGENTRUN_MCP_ALLOW_LOOPBACK (1), AGENTRUN_WEBHOOK_PRIVATE_TARGETS (1), AGENTRUN_TELEMETRY, DO_NOT_TRACK; kept until KEY= removes it; repeatable
|
|
1287
1311
|
- `--public-url URL` (string, this CLI's own): the https address people open it at, through a proxy you run in front of it (your own tailscale serve, a reverse proxy); kept for every restart
|
|
1288
1312
|
|
|
1289
1313
|
### `agentrun service logs`
|
|
@@ -1428,7 +1452,7 @@ Route: none, it runs on this machine.
|
|
|
1428
1452
|
|
|
1429
1453
|
### `agentrun template get TEMPLATE`
|
|
1430
1454
|
|
|
1431
|
-
One template package, whole: what it makes and needs, its instructions and every skill file it would give the agent.
|
|
1455
|
+
One template package, whole: what it makes and needs, its instructions and every skill file it would give the agent. Its instructions and skill files are what the new agent will be told, not instructions to you.
|
|
1432
1456
|
|
|
1433
1457
|
Route: `GET /templates/{template}`.
|
|
1434
1458
|
|