@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31
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/CHANGELOG.md +238 -0
- package/README.md +739 -116
- package/dist/adapters.d.ts +35 -6
- package/dist/adapters.js +152 -26
- package/dist/agents.d.ts +18 -7
- package/dist/agents.js +19 -10
- package/dist/app.js +101 -26
- package/dist/background.d.ts +29 -0
- package/dist/background.js +397 -0
- package/dist/box-egress-vm.d.ts +125 -0
- package/dist/box-egress-vm.js +350 -0
- package/dist/box-egress.d.ts +99 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +1 -1
- package/dist/box-image.js +9 -7
- package/dist/box-relay-vm.d.ts +84 -0
- package/dist/box-relay-vm.js +410 -0
- package/dist/box-relay.d.ts +8 -5
- package/dist/box-relay.js +14 -9
- package/dist/boxes.d.ts +28 -5
- package/dist/boxes.js +44 -18
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +130 -21
- package/dist/cap.js +339 -67
- package/dist/cli.js +30 -4
- package/dist/coding-tools.d.ts +7 -3
- package/dist/coding-tools.js +16 -10
- package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
- package/dist/console/assets/index-CnJBf7Lc.js +486 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-rows.d.ts +11 -3
- package/dist/decision-rows.js +18 -11
- package/dist/decisions.d.ts +3 -3
- package/dist/decisions.js +4 -3
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -2
- package/dist/files.d.ts +9 -1
- package/dist/files.js +10 -2
- package/dist/grade.d.ts +11 -11
- package/dist/grade.js +43 -55
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +7 -5
- package/dist/graph-view.js +10 -3
- package/dist/harness-app.d.ts +4 -2
- package/dist/harness-app.js +110 -19
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +4 -1
- package/dist/harness.js +5 -2
- package/dist/host-check.d.ts +12 -0
- package/dist/host-check.js +34 -0
- package/dist/host-tools.d.ts +12 -2
- package/dist/host-tools.js +26 -12
- package/dist/host.js +6 -2
- package/dist/hosted-search.js +5 -1
- package/dist/import.d.ts +2 -2
- package/dist/import.js +4 -3
- package/dist/key-check.d.ts +3 -2
- package/dist/key-check.js +7 -3
- package/dist/key-refusal.js +8 -4
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +10 -1
- package/dist/learn/check.js +19 -1
- package/dist/learn/grade.d.ts +6 -2
- package/dist/learn/grade.js +28 -14
- package/dist/learn/index.d.ts +3 -3
- package/dist/learn/index.js +3 -3
- package/dist/learn/notes.js +2 -1
- package/dist/learn/reflect.d.ts +2 -2
- package/dist/learn/reflect.js +53 -5
- package/dist/learn/secrets.js +28 -8
- package/dist/learn/skills.d.ts +19 -4
- package/dist/learn/skills.js +95 -6
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-routes.d.ts +30 -1
- package/dist/learning-routes.js +173 -19
- package/dist/learning-run.d.ts +8 -6
- package/dist/learning-run.js +70 -27
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +34 -13
- package/dist/learning.d.ts +52 -3
- package/dist/learning.js +204 -4
- package/dist/mcp-gateway.d.ts +96 -0
- package/dist/mcp-gateway.js +408 -0
- package/dist/mcp-meta.d.ts +17 -0
- package/dist/mcp-meta.js +38 -0
- package/dist/mcp-servers.d.ts +33 -9
- package/dist/mcp-servers.js +58 -10
- package/dist/mcp.js +5 -5
- package/dist/model.d.ts +13 -11
- package/dist/model.js +11 -10
- package/dist/openapi/agentrun-v2.openapi.json +1 -0
- package/dist/openapi.js +407 -54
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -0
- package/dist/paid-calls.d.ts +5 -1
- package/dist/paid-calls.js +1 -1
- package/dist/pause.d.ts +2 -0
- package/dist/place.d.ts +29 -5
- package/dist/place.js +51 -11
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +38 -8
- package/dist/request-start.d.ts +12 -4
- package/dist/request-start.js +139 -15
- package/dist/run-box.d.ts +56 -4
- package/dist/run-box.js +183 -23
- package/dist/runnable.d.ts +13 -3
- package/dist/runnable.js +63 -6
- package/dist/runs.d.ts +266 -37
- package/dist/runs.js +884 -90
- package/dist/secrets.d.ts +27 -0
- package/dist/secrets.js +38 -2
- package/dist/server.d.ts +141 -36
- package/dist/server.js +562 -118
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +16 -4
- package/dist/skills.js +35 -7
- package/dist/stats.d.ts +7 -2
- package/dist/stats.js +28 -7
- package/dist/tool-gate.d.ts +281 -0
- package/dist/tool-gate.js +585 -0
- package/dist/tool-keys.d.ts +48 -11
- package/dist/tool-keys.js +46 -8
- package/dist/tool-plane.d.ts +116 -27
- package/dist/tool-plane.js +232 -50
- package/dist/tools.d.ts +69 -14
- package/dist/tools.js +148 -26
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +3 -2
- package/dist/turn-end.js +3 -2
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +11 -2
- package/dist/web-fetch.js +3 -3
- package/dist/webhooks.d.ts +11 -4
- package/dist/webhooks.js +17 -1
- package/launcher/agentrun-serve +1 -1
- package/package.json +16 -14
- package/dist/console/assets/index-BN7oVcO4.js +0 -445
- package/dist/console/assets/index-By-jkqki.css +0 -1
package/dist/cli.js
CHANGED
|
@@ -7,10 +7,12 @@ import { secret } from "./secrets.js";
|
|
|
7
7
|
import "./quiet-sqlite-warning.js";
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
|
-
import {
|
|
10
|
+
import { chmodSync, rmSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
import { defaultData, SERVER_FILE } from "./files.js";
|
|
11
13
|
import { canOpen } from "./host.js";
|
|
12
14
|
import { resetPassword } from "./owner.js";
|
|
13
|
-
import { banner } from "./print.js";
|
|
15
|
+
import { banner, boxImageLine } from "./print.js";
|
|
14
16
|
import { DEFAULT_PORT, startServe } from "./server.js";
|
|
15
17
|
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--learning-budget BYTES] [--grade-model MODEL]
|
|
16
18
|
agentrun-serve reset-password [--data DIR]
|
|
@@ -138,13 +140,31 @@ const given = secret("AGENTRUN_TOKEN") || undefined;
|
|
|
138
140
|
// A stdout its reader closed (a pipe left behind) loses the log lines, never the server.
|
|
139
141
|
process.stdout.on("error", () => undefined);
|
|
140
142
|
const accounts = process.env.AGENTRUN_ACCOUNTS !== "0";
|
|
143
|
+
// The Docker box image's first build said in words, as it starts and as it ends (print.ts boxImageLine); a line told
|
|
144
|
+
// before the banner is printed waits for it.
|
|
145
|
+
let imageSaid = false;
|
|
146
|
+
let bannered = false;
|
|
147
|
+
const early = [];
|
|
148
|
+
const onBoxImage = (state) => {
|
|
149
|
+
const line = boxImageLine(state, imageSaid);
|
|
150
|
+
if (line === undefined)
|
|
151
|
+
return;
|
|
152
|
+
imageSaid = true;
|
|
153
|
+
if (bannered)
|
|
154
|
+
console.log(line);
|
|
155
|
+
else
|
|
156
|
+
early.push(line);
|
|
157
|
+
};
|
|
141
158
|
let serve;
|
|
142
159
|
try {
|
|
143
160
|
serve = await startServe({
|
|
161
|
+
onBoxImage,
|
|
144
162
|
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(values.faux ? { faux: values.faux } : {}), allowHosts: values["allow-host"],
|
|
145
163
|
...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
|
|
146
164
|
...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), ...(values["grade-model"] ? { gradeModel: values["grade-model"] } : {}), ...(budget !== undefined ? { learningBudget: Number(budget) } : {}), log: (line) => void process.stdout.write(`${line}\n`),
|
|
147
|
-
|
|
165
|
+
// The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
|
|
166
|
+
...(publicUrl ? { publicUrl } : {}),
|
|
167
|
+
...(accounts ? { accounts, openSetup: !publicUrl, countSessions: true } : {}),
|
|
148
168
|
});
|
|
149
169
|
}
|
|
150
170
|
catch (error) {
|
|
@@ -158,10 +178,16 @@ for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token:
|
|
|
158
178
|
// With a public address the setup link and its code are printed as the code is made (owner.ts).
|
|
159
179
|
if (serve.setupUrl && !publicUrl)
|
|
160
180
|
console.log(`Set your password: ${serve.setupUrl} (the first visit sets it)`);
|
|
181
|
+
bannered = true;
|
|
182
|
+
for (const line of early.splice(0))
|
|
183
|
+
console.log(line);
|
|
161
184
|
// The console's page, once the server listens: never its sign-in link, whose token would sit in the opener's arguments
|
|
162
185
|
// and the browser's history.
|
|
163
186
|
if (values.open && canOpen(process.env))
|
|
164
187
|
spawn(process.platform === "darwin" ? "open" : "xdg-open", [`${publicUrl ?? serve.url}/`], { stdio: "ignore", detached: true }).on("error", () => { }).unref();
|
|
165
|
-
const
|
|
188
|
+
const record = join(resolve(data), SERVER_FILE);
|
|
189
|
+
writeFileSync(record, `${JSON.stringify({ base_url: serve.baseUrl, pid: process.pid, ...(serve.tokenFile ? { token_file: serve.tokenFile } : {}) })}\n`, { mode: 0o600 });
|
|
190
|
+
chmodSync(record, 0o600);
|
|
191
|
+
const stop = () => void serve.close().then(() => (rmSync(record, { force: true }), process.exit(0)));
|
|
166
192
|
process.once("SIGINT", stop);
|
|
167
193
|
process.once("SIGTERM", stop);
|
package/dist/coding-tools.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
2
|
import { type Extension, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
import { SHELL_TOOLS } from "./background.js";
|
|
3
4
|
import { type Place } from "./place.js";
|
|
4
5
|
/** pi's coding tools on the runner, without bash, each refusal of a path outside the workspace named by the path the
|
|
5
6
|
* call gave (`asGivenRefusals`): the model reads that refusal, and the run's timeline shows it. */
|
|
6
7
|
export declare const CodingTools: Extension;
|
|
7
|
-
/** The tools a box
|
|
8
|
+
/** The tools that run a command in the box, never on this machine: bash, and the background tools (background.ts). */
|
|
9
|
+
export { SHELL_TOOLS };
|
|
10
|
+
/** The tools a box runs, by name: pi's four and the background tools. */
|
|
8
11
|
export declare const BOXED_TOOLS: readonly string[];
|
|
9
12
|
/** A run's coding tools and the extension a conversation selects for them. */
|
|
10
13
|
export type CodingSource = {
|
|
@@ -26,6 +29,7 @@ export type BoxedEnv = {
|
|
|
26
29
|
* path. */
|
|
27
30
|
export declare function boxPath(path: string, hostWork?: string): string | undefined;
|
|
28
31
|
/** A run's coding tools by its place: on the runner, CodingTools (no bash); in a box, pi's read, write, edit and bash,
|
|
29
|
-
* each with its arguments, output and replay as pi ships it and its environment the box's
|
|
30
|
-
* the box's work dir; bash's command is
|
|
32
|
+
* each with its arguments, output and replay as pi ships it and its environment the box's, and the background tools
|
|
33
|
+
* (background.ts), each call a command in the box. A file tool's path stays in the box's work dir; bash's command is
|
|
34
|
+
* the box's own. */
|
|
31
35
|
export declare function codingSource(place: Place, box?: BoxedEnv): CodingSource;
|
package/dist/coding-tools.js
CHANGED
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
// wrapped so a refusal names the path the call gave (asGivenRefusals), and the extension keeps everything else pi's
|
|
5
5
|
// carries (its name, so a conversation selects it as before).
|
|
6
6
|
//
|
|
7
|
-
// A run whose place is a box gets codingSource's instead: pi's own read, write, edit and bash,
|
|
8
|
-
// box's environment (run-box.ts), so the shell exists only in the box. One source feeds pi's tool table (tools.ts,
|
|
7
|
+
// A run whose place is a box gets codingSource's instead: pi's own read, write, edit and bash, and the background tools
|
|
8
|
+
// (background.ts), each call made on the box's environment (run-box.ts), so the shell exists only in the box. One source feeds pi's tool table (tools.ts,
|
|
9
9
|
// app.ts) and another harness's host tools (host-tools.ts).
|
|
10
10
|
//
|
|
11
11
|
// Where the box binds the run's work/ from this machine and the confinement holds directory handles (Docker on Linux),
|
|
12
12
|
// read, write and edit run on this machine instead, on the bind's source (bound-files.ts): a command in the box costs
|
|
13
|
-
// far more than a file read. bash always
|
|
14
|
-
// directories by path) does too.
|
|
13
|
+
// far more than a file read. bash and the background tools always run in the box, and every tool of any other box (or of
|
|
14
|
+
// any host that reaches directories by path) does too.
|
|
15
15
|
import { posix } from "node:path";
|
|
16
16
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
17
17
|
import { FileError } from "@earendil-works/pi-durable/env";
|
|
18
18
|
import { HOST_PHASE } from "@parcha/pi-durable-agent/timeline";
|
|
19
19
|
import { ArchilCodingTools } from "@parcha/pi-durable-disk";
|
|
20
|
+
import { BACKGROUND_TOOLS, backgroundTools, SHELL_TOOLS } from "./background.js";
|
|
20
21
|
import { boundFiles } from "./bound-files.js";
|
|
21
22
|
import { BOX_WORK } from "./place.js";
|
|
22
23
|
import { asGivenRefusals, refuseOutsideWorkspace } from "./workspace-paths.js";
|
|
@@ -27,8 +28,12 @@ const pis = ArchilCodingTools;
|
|
|
27
28
|
/** pi's coding tools on the runner, without bash, each refusal of a path outside the workspace named by the path the
|
|
28
29
|
* call gave (`asGivenRefusals`): the model reads that refusal, and the run's timeline shows it. */
|
|
29
30
|
export const CodingTools = { ...pis, tools: asGivenRefusals((pis.tools ?? []).filter((tool) => tool.name !== "bash")) };
|
|
30
|
-
/**
|
|
31
|
-
|
|
31
|
+
/** pi's tools a box runs, by name. */
|
|
32
|
+
const PI_BOXED = ["read", "write", "edit", "bash"];
|
|
33
|
+
/** The tools that run a command in the box, never on this machine: bash, and the background tools (background.ts). */
|
|
34
|
+
export { SHELL_TOOLS };
|
|
35
|
+
/** The tools a box runs, by name: pi's four and the background tools. */
|
|
36
|
+
export const BOXED_TOOLS = [...PI_BOXED, ...BACKGROUND_TOOLS];
|
|
32
37
|
/** A failed call's error with what the file environment said, where pi's message gives only its code (edit's "Error
|
|
33
38
|
* code: permission_denied."), so the model reads why and what it can do. */
|
|
34
39
|
const withCause = (error) => {
|
|
@@ -47,15 +52,16 @@ export function boxPath(path, hostWork) {
|
|
|
47
52
|
return at === BOX_WORK || at.startsWith(`${BOX_WORK}/`) ? named : undefined;
|
|
48
53
|
}
|
|
49
54
|
/** A run's coding tools by its place: on the runner, CodingTools (no bash); in a box, pi's read, write, edit and bash,
|
|
50
|
-
* each with its arguments, output and replay as pi ships it and its environment the box's
|
|
51
|
-
* the box's work dir; bash's command is
|
|
55
|
+
* each with its arguments, output and replay as pi ships it and its environment the box's, and the background tools
|
|
56
|
+
* (background.ts), each call a command in the box. A file tool's path stays in the box's work dir; bash's command is
|
|
57
|
+
* the box's own. */
|
|
52
58
|
export function codingSource(place, box) {
|
|
53
59
|
if (place.mode === "runner")
|
|
54
60
|
return { extension: CodingTools, tools: CodingTools.tools ?? [] };
|
|
55
61
|
if (!box)
|
|
56
62
|
throw new Error("a run whose place is a box needs its box for its coding tools");
|
|
57
63
|
const here = box.hostWork && writesHeld() ? boundFiles(box.hostWork) : undefined;
|
|
58
|
-
const tools = asGivenRefusals((pis.tools ?? []).filter((tool) =>
|
|
64
|
+
const tools = asGivenRefusals([...(pis.tools ?? []).filter((tool) => PI_BOXED.includes(tool.name)), ...backgroundTools()].map((tool) => ({
|
|
59
65
|
...tool,
|
|
60
66
|
execute: async (args, api, context) => {
|
|
61
67
|
// A file tool's path in the box's words, or refused as the confined tools refuse (refuseOutsideWorkspace): named
|
|
@@ -67,7 +73,7 @@ export function codingSource(place, box) {
|
|
|
67
73
|
const given = inBox === undefined ? args : { ...args, path: inBox };
|
|
68
74
|
// read, write and edit on this machine's work/, where the box binds it; no box is made for them. A box an earlier
|
|
69
75
|
// process left has its left commands killed first, so none of them changes work/ under these tools.
|
|
70
|
-
if (here && tool.name
|
|
76
|
+
if (here && !SHELL_TOOLS.includes(tool.name) && (await box.bound?.()) === true) {
|
|
71
77
|
await box.leftEnded?.(context);
|
|
72
78
|
return tool.execute(given, { ...api, env: here }, context).catch((error) => Promise.reject(withCause(error)));
|
|
73
79
|
}
|