@parcha/agentrun-serve 0.1.0-beta.40 → 0.1.0-beta.42
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 +130 -0
- package/NOTICE +2 -0
- package/README.md +149 -21
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- package/dist/api-only.d.ts +3 -1
- package/dist/api-only.js +4 -2
- package/dist/api-token.d.ts +30 -0
- package/dist/api-token.js +89 -0
- package/dist/calendar/address.d.ts +49 -0
- package/dist/calendar/address.js +153 -0
- package/dist/calendar/fetch.d.ts +24 -0
- package/dist/calendar/fetch.js +146 -0
- package/dist/calendar/ics-faux.d.ts +39 -0
- package/dist/calendar/ics-faux.js +236 -0
- package/dist/calendar/labels.d.ts +3 -0
- package/dist/calendar/labels.js +61 -0
- package/dist/calendar/names.d.ts +52 -0
- package/dist/calendar/names.js +54 -0
- package/dist/calendar/parse.d.ts +108 -0
- package/dist/calendar/parse.js +625 -0
- package/dist/calendar/routes.d.ts +17 -0
- package/dist/calendar/routes.js +81 -0
- package/dist/calendar/tools.d.ts +23 -0
- package/dist/calendar/tools.js +124 -0
- package/dist/cli.js +22 -6
- package/dist/composio-made.d.ts +54 -0
- package/dist/composio-made.js +83 -0
- package/dist/composio-preset.d.ts +16 -8
- package/dist/composio-preset.js +106 -43
- package/dist/composio-triggers.d.ts +7 -2
- package/dist/composio-triggers.js +13 -7
- package/dist/computer-attach.d.ts +29 -11
- package/dist/computer-attach.js +141 -47
- package/dist/computer-keys.d.ts +4 -0
- package/dist/computer-keys.js +5 -0
- package/dist/computer-record.d.ts +55 -0
- package/dist/computer-record.js +315 -0
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +15 -2
- package/dist/computers.d.ts +11 -1
- package/dist/computers.js +23 -26
- package/dist/console/assets/{index-B8Zn1Iqn.css → index-C3gNPz58.css} +1 -1
- package/dist/console/assets/index-DYJ_wj27.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +9 -2
- package/dist/eval-feed.d.ts +26 -0
- package/dist/eval-feed.js +72 -0
- package/dist/eval-mailbox.d.ts +4 -1
- package/dist/eval-mailbox.js +11 -3
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/feed/feed-faux.d.ts +62 -0
- package/dist/feed/feed-faux.js +123 -0
- package/dist/feed/fetch.d.ts +41 -0
- package/dist/feed/fetch.js +128 -0
- package/dist/feed/parse.d.ts +42 -0
- package/dist/feed/parse.js +291 -0
- package/dist/feed/pointer.d.ts +2 -0
- package/dist/feed/pointer.js +17 -0
- package/dist/file-types.js +1 -0
- package/dist/host-command.d.ts +3 -0
- package/dist/host-command.js +18 -0
- package/dist/host.d.ts +3 -0
- package/dist/host.js +3 -0
- package/dist/learn/check.d.ts +17 -1
- package/dist/learn/check.js +240 -5
- package/dist/learn/compile.d.ts +48 -27
- package/dist/learn/compile.js +134 -101
- package/dist/learn/promote.d.ts +61 -5
- package/dist/learn/promote.js +12 -2
- package/dist/learned-nodes.d.ts +21 -4
- package/dist/learned-nodes.js +21 -8
- package/dist/learned-workflow.d.ts +3 -3
- package/dist/learned-workflow.js +14 -5
- package/dist/learning-setting.d.ts +23 -0
- package/dist/learning-setting.js +51 -0
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +3 -0
- package/dist/learning.d.ts +3 -2
- package/dist/learning.js +5 -3
- package/dist/mcp-oauth.d.ts +23 -1
- package/dist/mcp-oauth.js +46 -5
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +4 -3
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/mcp-servers-store.d.ts +58 -5
- package/dist/mcp-servers-store.js +136 -17
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/observation/http.d.ts +4 -1
- package/dist/observation/http.js +5 -4
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +151 -21
- package/dist/print.d.ts +6 -3
- package/dist/print.js +4 -2
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- package/dist/run-labels.d.ts +23 -0
- package/dist/run-labels.js +79 -0
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-reads-over-store.d.ts +5 -1
- package/dist/run-reads-over-store.js +8 -4
- package/dist/run-recordings.d.ts +20 -0
- package/dist/run-recordings.js +133 -0
- package/dist/run-secrets.js +12 -4
- package/dist/runner/adapter-loop.d.ts +1 -1
- package/dist/runner/adapter-loop.js +94 -16
- package/dist/runner/adapter-run-spec.d.ts +19 -0
- package/dist/runner/adapter-run-spec.js +57 -36
- package/dist/runner/beside.d.ts +6 -3
- package/dist/runner/beside.js +9 -7
- package/dist/runner/cli-run-spec.js +41 -32
- package/dist/runner/conformance/harness.js +69 -14
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/feedback-round.d.ts +9 -25
- package/dist/runner/feedback-round.js +22 -40
- package/dist/runner/learning-end.d.ts +17 -7
- package/dist/runner/learning-end.js +79 -53
- package/dist/runner/main.d.ts +12 -1
- package/dist/runner/main.js +31 -4
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +6 -2
- package/dist/runner/mcp-run.js +5 -3
- package/dist/runner/model-route.d.ts +4 -2
- package/dist/runner/model-route.js +8 -8
- package/dist/runner/promotion.d.ts +44 -4
- package/dist/runner/promotion.js +323 -21
- package/dist/runner/reflect-hook.d.ts +5 -0
- package/dist/runner/reflect-hook.js +22 -14
- package/dist/runner/store-secrets.js +3 -1
- package/dist/runner/workflow-first.d.ts +6 -11
- package/dist/runner/workflow-first.js +16 -20
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/runs-over-store.js +5 -2
- package/dist/sdk/runs.d.ts +7 -1
- package/dist/sdk/runs.js +21 -7
- package/dist/secret-cut.js +3 -1
- package/dist/secrets.js +5 -3
- package/dist/server.d.ts +31 -5
- package/dist/server.js +240 -61
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
- package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +26 -2
- package/dist/store/sqlite/connection.js +11 -3
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +3 -2
- package/dist/store/sqlite/store.js +64 -10
- package/dist/store/store.d.ts +38 -1
- package/dist/store-reads/journal.js +2 -1
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +6 -1
- package/dist/store-reads/loop.d.ts +1 -0
- package/dist/store-reads/loop.js +14 -4
- package/dist/store-reads/runs.d.ts +4 -3
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +8 -2
- package/dist/template-eval.d.ts +11 -0
- package/dist/template-eval.js +177 -52
- package/dist/templates.d.ts +13 -1
- package/dist/templates.js +89 -18
- package/dist/timeline/computer.js +2 -1
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-adapter.d.ts +9 -4
- package/dist/trigger-adapters.js +2 -1
- package/dist/trigger-feed.d.ts +12 -0
- package/dist/trigger-feed.js +420 -0
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +23 -5
- package/dist/validate.js +7 -2
- package/dist/webhooks.js +9 -5
- package/dist/workspace/computer-deps.d.ts +5 -1
- package/dist/workspace/computer-deps.js +2 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.js +2 -0
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +35 -4
- package/dist/workspace/resolve-computer.js +47 -9
- package/launcher/agentrun-serve +34 -22
- package/package.json +11 -9
- package/templates/README.md +38 -4
- package/dist/console/assets/index-Jbxjcmdp.js +0 -705
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// for this run under this claim (labels agentrun.run and agentrun.epoch, the run's folder mounted only where the provider
|
|
4
4
|
// mounts it), with a hold and its live view when it is a desktop or a phone, and released once at the run's end. The hold
|
|
5
5
|
// goes back to the spec (`held`), whose adapter loop journals it and applies the owner's take-over and hand-back rows to it
|
|
6
|
-
// (runner/computer-journal.ts); the live view (computer-live.ts openClaimView) drives the same hold.
|
|
6
|
+
// (runner/computer-journal.ts); the live view (computer-live.ts openClaimView) drives the same hold. Where the setting
|
|
7
|
+
// asks for it (computer.record), the screen is recorded too (computer-record.ts), until the release or a park. A computer that cannot
|
|
7
8
|
// be had is refused in words with code computer_unavailable; kind none, or no setting where the server's default is none,
|
|
8
9
|
// is no computer.
|
|
9
10
|
//
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
// deleted, at the run's end. A run that finds it held by another run still going is refused, naming that run.
|
|
32
33
|
import { randomUUID } from "node:crypto";
|
|
33
34
|
import { isBrowserProvider, ownerFilter, releaseOlder, RUN_LABEL, runLabels } from "@parcha/agentrun-computer";
|
|
35
|
+
import { startRecording } from "../computer-record.js";
|
|
34
36
|
import { computerOfPlace } from "../computer-setting.js";
|
|
35
37
|
import { KEY_TABLE, providerOptions } from "../computer-keys.js";
|
|
36
38
|
import { getSealedKey } from "../server-keys.js";
|
|
@@ -558,7 +560,8 @@ store, deps) {
|
|
|
558
560
|
return launched;
|
|
559
561
|
},
|
|
560
562
|
};
|
|
561
|
-
const
|
|
563
|
+
const setting = await settingOf(launch, store);
|
|
564
|
+
const resolved = await resolveComputer(setting, deps.mode, kinds, side);
|
|
562
565
|
if ("refused" in resolved)
|
|
563
566
|
throw unavailable(resolved.refused);
|
|
564
567
|
if (resolved.kind === "none")
|
|
@@ -589,6 +592,7 @@ store, deps) {
|
|
|
589
592
|
let hold;
|
|
590
593
|
let held;
|
|
591
594
|
let view;
|
|
595
|
+
let recording;
|
|
592
596
|
if (computer && (computer.kind === "desktop" || computer.kind === "phone")) {
|
|
593
597
|
const theHold = computerHold();
|
|
594
598
|
if (deps.openComputerView && made?.watch) {
|
|
@@ -604,6 +608,9 @@ store, deps) {
|
|
|
604
608
|
}
|
|
605
609
|
view = opened.view;
|
|
606
610
|
}
|
|
611
|
+
// The agent asks for a video of the screen (computer.record): a watch of the recorder's own, while this claim holds it.
|
|
612
|
+
if (deps.recordings && made?.watch && setting?.record === true)
|
|
613
|
+
recording = startRecording({ ...deps.recordings, watch: made.watch, tag: made.id, kind: computer.kind });
|
|
607
614
|
// The run's end closes the hold (workspace/computer-hold.ts close()): a take in force ends `released` (the computer
|
|
608
615
|
// goes; the composer's `ended` ViewEnd maps onto it), the agent's open ask is let go at once, and nothing is taken after.
|
|
609
616
|
endHold = () => theHold.close();
|
|
@@ -612,6 +619,7 @@ store, deps) {
|
|
|
612
619
|
}
|
|
613
620
|
let released;
|
|
614
621
|
const release = (why = "released") => (released ??= (async () => {
|
|
622
|
+
await recording?.stop(typeof why === "object" ? "parked" : why);
|
|
615
623
|
await Promise.resolve(view?.close(why)).catch(() => undefined);
|
|
616
624
|
endHold();
|
|
617
625
|
try {
|
|
@@ -651,6 +659,8 @@ store, deps) {
|
|
|
651
659
|
// The live view ends (its frames and any take-over), saying what the run waits for and until when the computer is
|
|
652
660
|
// kept, never that it ended; the hold with it; the machine and its mount stay.
|
|
653
661
|
released = (async () => {
|
|
662
|
+
// The recording pauses: the claim that resumes the run goes on in a new file.
|
|
663
|
+
await recording?.stop("parked");
|
|
654
664
|
await Promise.resolve(view?.close({ parked: cause, until: row.until })).catch(() => undefined);
|
|
655
665
|
endHold();
|
|
656
666
|
await keeps.computer.close();
|
|
@@ -15,6 +15,7 @@ export { type LearningPlace, type LearningWorkspace, learningWorkspace, type Lea
|
|
|
15
15
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
16
16
|
export { type AgentComputer, type RunComputer, type RunHold, runTools, type RunTools, type ScriptComputer, withKindTools } from "./run-tools.js";
|
|
17
17
|
export { NO_PROGRAMS_WORDS, portOf } from "./computer-ports.js";
|
|
18
|
+
export { registryHere } from "./resolve-computer.js";
|
|
18
19
|
export { COMPUTER_MCP_NAME, computerMcp, type ComputerMcpAnswer, mcpAnswerOf } from "./computer-mcp.js";
|
|
19
20
|
export { type ClaimSide, computerReadiness, type ComputerSetting, type KindRegistry, type LaunchedComputer, type Port, resolveComputer, type ResolvedComputer, runShellOf, type ShellPlace, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
|
|
20
21
|
export { computerProviderFactories, computerProviderMakers, type ProviderLoad } from "./computer-providers.js";
|
package/dist/workspace/index.js
CHANGED
|
@@ -16,6 +16,8 @@ export { learningWorkspace } from "./learning-workspace.js";
|
|
|
16
16
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
17
17
|
export { runTools, withKindTools } from "./run-tools.js";
|
|
18
18
|
export { NO_PROGRAMS_WORDS, portOf } from "./computer-ports.js";
|
|
19
|
+
// Each provider as this server has it (the mounts its keys turn on), on a line of its own.
|
|
20
|
+
export { registryHere } from "./resolve-computer.js";
|
|
19
21
|
export { COMPUTER_MCP_NAME, computerMcp, mcpAnswerOf } from "./computer-mcp.js";
|
|
20
22
|
export { computerReadiness, resolveComputer, runShellOf, shellPlaceOf, } from "./resolve-computer.js";
|
|
21
23
|
export { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
|
|
@@ -10,6 +10,10 @@ export declare const runKey: (agentId: string, runId: string) => string;
|
|
|
10
10
|
export declare const learningKey: (agentId: string) => string;
|
|
11
11
|
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
12
12
|
export declare const runFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
13
|
+
/** The recordings folder's name: beside a run's folder on this machine, and the run files route's path to it. */
|
|
14
|
+
export declare const RECORDINGS = "recordings";
|
|
15
|
+
/** Run `runId`'s recordings on this machine, beside its folder: `<data>/disk/agents/<agent>/runs/<run>/recordings`. */
|
|
16
|
+
export declare const recordingsFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
13
17
|
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
14
18
|
export declare const agentLearningFolder: (dataDir: string, agentId: string) => string;
|
|
15
19
|
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
package/dist/workspace/paths.js
CHANGED
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
// no Workspace: a harness's working directory, and its private files
|
|
12
12
|
// in harness/<claim's epoch>, swept at that claim's end
|
|
13
13
|
// (runner/cli-run-spec.ts)
|
|
14
|
+
// <data>/disk/agents/<agent>/runs/<run>/recordings
|
|
15
|
+
// a run's screen recordings (recordingsFolder): beside work/, never in
|
|
16
|
+
// its Workspace, so the agent neither reads nor changes them; on this
|
|
17
|
+
// machine in either mode, as the runner records them
|
|
18
|
+
// (computer-record.ts)
|
|
14
19
|
// <agent> is the id in lower case, a dash, and 16 hex digits of the id's SHA-256, so ids that differ only in case never
|
|
15
20
|
// share a folder on a disk that folds case.
|
|
16
21
|
//
|
|
@@ -40,6 +45,10 @@ export const runKey = (agentId, runId) => `agents/${agentDirName(agentId)}/runs/
|
|
|
40
45
|
export const learningKey = (agentId) => `agents/${agentDirName(agentId)}/learning`;
|
|
41
46
|
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
42
47
|
export const runFolder = (dataDir, agentId, runId) => join(dataDir, DISK_DIR, runKey(agentId, runId));
|
|
48
|
+
/** The recordings folder's name: beside a run's folder on this machine, and the run files route's path to it. */
|
|
49
|
+
export const RECORDINGS = "recordings";
|
|
50
|
+
/** Run `runId`'s recordings on this machine, beside its folder: `<data>/disk/agents/<agent>/runs/<run>/recordings`. */
|
|
51
|
+
export const recordingsFolder = (dataDir, agentId, runId) => join(dirname(runFolder(dataDir, agentId, runId)), RECORDINGS);
|
|
43
52
|
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
44
53
|
export const agentLearningFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, learningKey(agentId));
|
|
45
54
|
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
|
@@ -10,7 +10,8 @@ export type { ComputerSettingKind, KindCapabilities, ProviderEntry, ShellPlace }
|
|
|
10
10
|
/** An agent's computer setting. `image`: the one of the provider's configurations it selects; absent, the default. A
|
|
11
11
|
* sandbox's may ask for GPUs. `persistent`: the agent keeps its own computer between runs (agent-computer.ts). A
|
|
12
12
|
* desktop's or a phone's `surface` and `exec` go to the run's tools on the RunComputer (run-tools.ts); `exec: false`
|
|
13
|
-
* also mounts no folder in it and gives the run no shell.
|
|
13
|
+
* also mounts no folder in it and gives the run no shell. A desktop's or a phone's `record`: the claim records its
|
|
14
|
+
* screen (computer-for-claim.ts, computer-record.ts). */
|
|
14
15
|
export type ComputerSetting = {
|
|
15
16
|
readonly kind: string;
|
|
16
17
|
readonly provider?: string | null;
|
|
@@ -19,6 +20,7 @@ export type ComputerSetting = {
|
|
|
19
20
|
readonly persistent?: boolean;
|
|
20
21
|
readonly surface?: "code" | "tools";
|
|
21
22
|
readonly exec?: boolean;
|
|
23
|
+
readonly record?: boolean;
|
|
22
24
|
};
|
|
23
25
|
/** Whether a computer (or its setting) takes its agent's programs away: `exec: false`. Only a desktop or a phone takes
|
|
24
26
|
* `exec` (computer-setting.ts refuses it on any other kind at save), so a computer without programs is one of those. */
|
|
@@ -121,6 +123,33 @@ export type Port = "files" | "exec" | "processes" | "screen" | "input" | "phone"
|
|
|
121
123
|
/** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
|
|
122
124
|
* key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
|
|
123
125
|
export declare const providerKeys: (registry: Pick<KindRegistry, "PROVIDERS">, keyOf: (name: string) => Promise<string | undefined>) => ClaimSide["keysOf"];
|
|
126
|
+
/** What a provider is on this server beside its descriptor: the mounts the operator's keys turn on, and whether the
|
|
127
|
+
* operator names its image here. */
|
|
128
|
+
type HereFields = {
|
|
129
|
+
readonly mounts: readonly string[];
|
|
130
|
+
readonly unmounted?: Readonly<Partial<Record<string, string>>>;
|
|
131
|
+
readonly mountsWith?: Readonly<Partial<Record<string, string>>>;
|
|
132
|
+
readonly imageEnv?: string;
|
|
133
|
+
readonly prepareImage?: boolean;
|
|
134
|
+
/** Its descriptor's imageEnv has a value here: the operator names the image every computer of it starts from. */
|
|
135
|
+
readonly imageNamed?: true;
|
|
136
|
+
};
|
|
137
|
+
/** `entry` as this server has it, by `set` (whether a key, or a setting of this server, has a value here): with the
|
|
138
|
+
* mounts the operator's keys turn on (its descriptor's mountsWith, by the computer package's mountsOf: Daytona's Archil
|
|
139
|
+
* mount where DAYTONA_ARCHIL_EGRESS names a self-hosted target's Archil egress relay), and imageNamed where its
|
|
140
|
+
* descriptor's imageEnv names its image here (Daytona's AGENTRUN_DAYTONA_SNAPSHOT). Any other entry as it is. Every
|
|
141
|
+
* reader of an entry's mounts (Settings → Computers, the claim, a run's start, its shell) reads this, so the
|
|
142
|
+
* provider made with those keys and the server agree on what it mounts. */
|
|
143
|
+
export declare function entryHere<Entry extends HereFields>(entry: Entry, set: (name: string) => boolean): Entry;
|
|
144
|
+
/** `registry` with each provider as this server has it (entryHere), reading only the names an entry's mountsWith or
|
|
145
|
+
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key). A value of
|
|
146
|
+
* whitespace alone is none. */
|
|
147
|
+
export declare function registryHere<Registry extends {
|
|
148
|
+
readonly PROVIDERS: readonly ProviderEntry[];
|
|
149
|
+
}>(registry: Registry, valueOf: (name: string) => Promise<string | undefined>): Promise<Registry>;
|
|
150
|
+
/** Whether a computer of `entry` that mounts the owner's Archil disk has Archil's image in the owner's vendor account:
|
|
151
|
+
* its provider prepares it (prepareImage), or the operator names it here (imageNamed, entryHere). */
|
|
152
|
+
export declare const archilImageHere: (entry: HereFields) => boolean;
|
|
124
153
|
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
125
154
|
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
126
155
|
export declare const vendorNetworkOnly: (network: readonly string[] | undefined) => boolean;
|
|
@@ -133,8 +162,10 @@ export declare const aLabel: (label: string, start?: boolean) => string;
|
|
|
133
162
|
/** Why a sandbox or a desktop that would mount the owner's Archil disk can't start in Mode 2: the mount needs Archil's
|
|
134
163
|
* image in the owner's own vendor account, and this server can't put it there yet. A provider that prepares its image
|
|
135
164
|
* (prepareImage: Agent37 registers the box image in the owner's workspace, Modal pulls it, E2B starts its public
|
|
136
|
-
* template) is never refused so
|
|
137
|
-
|
|
165
|
+
* template) is never refused so, nor one whose image the operator names here (archilImageHere: Daytona's
|
|
166
|
+
* AGENTRUN_DAYTONA_SNAPSHOT). For such a one, `imageEnv` says where to name it. Settings (computers.ts modeRefusal)
|
|
167
|
+
* and a run's start (computerReadiness) say it. */
|
|
168
|
+
export declare const mode2ArchilWhy: (label: string, kind: "sandbox" | "desktop", imageEnv?: string) => string;
|
|
138
169
|
/** Why a computer that needs a network is refused where this server's AGENTRUN_BOX_ALLOW is none, in words that name the
|
|
139
170
|
* fix: the operator said no network at all, and the computer can't run without one. */
|
|
140
171
|
export declare const noNetworkRefusal: (label: string, kind: string) => string;
|
|
@@ -153,7 +184,7 @@ export declare const noNetworkRefusal: (label: string, kind: string) => string;
|
|
|
153
184
|
*
|
|
154
185
|
* `hostWhy`: why this machine cannot run a provider's computers, in words that say how to fix it (computers.ts
|
|
155
186
|
* hostCommandRefusals, read at the server's start: the phone's adb not on PATH), or undefined. Absent: not asked. */
|
|
156
|
-
export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2,
|
|
187
|
+
export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2, given: KindRegistry, keyOf: (name: string) => Promise<string | undefined>, answers?: (provider: string) => DockerDaemon | Promise<DockerDaemon>, boxAllow?: readonly string[] | "none", hostWhy?: (provider: string) => string | undefined): Promise<{
|
|
157
188
|
readonly ok: true;
|
|
158
189
|
} | {
|
|
159
190
|
readonly refused: string;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// command there would run on the server itself. runShellOf reads it off a setting before anything starts (the tool
|
|
20
20
|
// plane shows bash unavailable by it), and the claim's runTools takes the same rule over the computer it started.
|
|
21
21
|
import { hostToolDefs } from "@parcha/agentrun-kernel/kernel";
|
|
22
|
-
import { configurationOf, imagesOf } from "@parcha/agentrun-computer";
|
|
22
|
+
import { configurationOf, imagesOf, mountsOf } from "@parcha/agentrun-computer";
|
|
23
23
|
import { noDockerWords } from "../docker-daemon.js";
|
|
24
24
|
import { gpuRefused } from "../gpu-words.js";
|
|
25
25
|
import { recordedClient } from "../computer-calls.js";
|
|
@@ -37,6 +37,34 @@ export const providerKeys = (registry, keyOf) => async (provider) => {
|
|
|
37
37
|
}
|
|
38
38
|
return keys;
|
|
39
39
|
};
|
|
40
|
+
/** `entry` as this server has it, by `set` (whether a key, or a setting of this server, has a value here): with the
|
|
41
|
+
* mounts the operator's keys turn on (its descriptor's mountsWith, by the computer package's mountsOf: Daytona's Archil
|
|
42
|
+
* mount where DAYTONA_ARCHIL_EGRESS names a self-hosted target's Archil egress relay), and imageNamed where its
|
|
43
|
+
* descriptor's imageEnv names its image here (Daytona's AGENTRUN_DAYTONA_SNAPSHOT). Any other entry as it is. Every
|
|
44
|
+
* reader of an entry's mounts (Settings → Computers, the claim, a run's start, its shell) reads this, so the
|
|
45
|
+
* provider made with those keys and the server agree on what it mounts. */
|
|
46
|
+
export function entryHere(entry, set) {
|
|
47
|
+
const keyed = entry.mountsWith === undefined ? undefined : mountsOf(entry, set);
|
|
48
|
+
const named = entry.imageEnv !== undefined && set(entry.imageEnv);
|
|
49
|
+
if (keyed === undefined && !named)
|
|
50
|
+
return entry;
|
|
51
|
+
return { ...entry, ...keyed, ...(named ? { imageNamed: true } : {}) };
|
|
52
|
+
}
|
|
53
|
+
/** The names entryHere reads of `entry`: the keys of its mountsWith, and its imageEnv. */
|
|
54
|
+
const hereNames = (entry) => [...Object.values(entry.mountsWith ?? {}).filter((name) => typeof name === "string"), ...(entry.imageEnv === undefined ? [] : [entry.imageEnv])];
|
|
55
|
+
/** `registry` with each provider as this server has it (entryHere), reading only the names an entry's mountsWith or
|
|
56
|
+
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key). A value of
|
|
57
|
+
* whitespace alone is none. */
|
|
58
|
+
export async function registryHere(registry, valueOf) {
|
|
59
|
+
const names = [...new Set(registry.PROVIDERS.flatMap(hereNames))];
|
|
60
|
+
if (names.length === 0)
|
|
61
|
+
return registry;
|
|
62
|
+
const set = new Set((await Promise.all(names.map(async (name) => ((await valueOf(name))?.trim() ? name : "")))).filter((name) => name !== ""));
|
|
63
|
+
return { ...registry, PROVIDERS: registry.PROVIDERS.map((entry) => entryHere(entry, (name) => set.has(name))) };
|
|
64
|
+
}
|
|
65
|
+
/** Whether a computer of `entry` that mounts the owner's Archil disk has Archil's image in the owner's vendor account:
|
|
66
|
+
* its provider prepares it (prepareImage), or the operator names it here (imageNamed, entryHere). */
|
|
67
|
+
export const archilImageHere = (entry) => entry.prepareImage === true || entry.imageNamed === true;
|
|
40
68
|
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
41
69
|
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
42
70
|
export const vendorNetworkOnly = (network) => network !== undefined && network.length > 0 && network.every((one) => one === "open");
|
|
@@ -49,8 +77,12 @@ export const aLabel = (label, start = false) => `${start ? "A" : "a"}${/^[AEIOU]
|
|
|
49
77
|
/** Why a sandbox or a desktop that would mount the owner's Archil disk can't start in Mode 2: the mount needs Archil's
|
|
50
78
|
* image in the owner's own vendor account, and this server can't put it there yet. A provider that prepares its image
|
|
51
79
|
* (prepareImage: Agent37 registers the box image in the owner's workspace, Modal pulls it, E2B starts its public
|
|
52
|
-
* template) is never refused so
|
|
53
|
-
|
|
80
|
+
* template) is never refused so, nor one whose image the operator names here (archilImageHere: Daytona's
|
|
81
|
+
* AGENTRUN_DAYTONA_SNAPSHOT). For such a one, `imageEnv` says where to name it. Settings (computers.ts modeRefusal)
|
|
82
|
+
* and a run's start (computerReadiness) say it. */
|
|
83
|
+
export const mode2ArchilWhy = (label, kind, imageEnv) => imageEnv === undefined
|
|
84
|
+
? `${aLabel(label, true)} ${kind} can't start in Mode 2 yet: it needs Archil's image in your ${label} account, and this server can't put it there yet. Set this agent's computer to none (${SETTINGS})`
|
|
85
|
+
: `${aLabel(label, true)} ${kind} can't start in Mode 2 until this server names Archil's image in your ${label} account: build one from the computer package's box/Dockerfile and name it in ${imageEnv}, or set this agent's computer to none (${SETTINGS})`;
|
|
54
86
|
/** Why a computer that needs a network is refused where this server's AGENTRUN_BOX_ALLOW is none, in words that name the
|
|
55
87
|
* fix: the operator said no network at all, and the computer can't run without one. */
|
|
56
88
|
export const noNetworkRefusal = (label, kind) => `This agent's computer is ${aLabel(label)} ${kind}, which needs a network (the vendor's own, or public addresses from this machine), and this server's AGENTRUN_BOX_ALLOW is none (no network): pick a computer that runs with no network in ${SETTINGS}, or set AGENTRUN_BOX_ALLOW to a host list.`;
|
|
@@ -69,7 +101,9 @@ export const noNetworkRefusal = (label, kind) => `This agent's computer is ${aLa
|
|
|
69
101
|
*
|
|
70
102
|
* `hostWhy`: why this machine cannot run a provider's computers, in words that say how to fix it (computers.ts
|
|
71
103
|
* hostCommandRefusals, read at the server's start: the phone's adb not on PATH), or undefined. Absent: not asked. */
|
|
72
|
-
export async function computerReadiness(setting, mode,
|
|
104
|
+
export async function computerReadiness(setting, mode, given, keyOf, answers, boxAllow, hostWhy) {
|
|
105
|
+
// Each provider as this server has it: the mounts its keys turn on, and whether the operator names its image.
|
|
106
|
+
const registry = await registryHere(given, keyOf);
|
|
73
107
|
const resolved = await resolveComputer(setting, mode, registry, {
|
|
74
108
|
keysOf: providerKeys(registry, keyOf),
|
|
75
109
|
// A setting is given, so the Mode 1 default (the only asker) is never read; and nothing is launched.
|
|
@@ -79,8 +113,8 @@ export async function computerReadiness(setting, mode, registry, keyOf, answers,
|
|
|
79
113
|
if ("refused" in resolved)
|
|
80
114
|
return { refused: resolved.refused };
|
|
81
115
|
const entry = registry.PROVIDERS.find((one) => one.id === resolved.provider);
|
|
82
|
-
if (mode === 2 && (resolved.kind === "sandbox" || resolved.kind === "desktop") && resolved.mounts && entry && !entry
|
|
83
|
-
return { refused: `${mode2ArchilWhy(entry.label, resolved.kind)}.` };
|
|
116
|
+
if (mode === 2 && (resolved.kind === "sandbox" || resolved.kind === "desktop") && resolved.mounts && entry && !archilImageHere(entry))
|
|
117
|
+
return { refused: `${mode2ArchilWhy(entry.label, resolved.kind, entry.imageEnv)}.` };
|
|
84
118
|
if (entry && entry.mounts.includes("bind") && answers) {
|
|
85
119
|
const said = await answers(entry.id);
|
|
86
120
|
// It names the box whose probe said no (a refusal's details.box), as the box check did.
|
|
@@ -202,9 +236,13 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
202
236
|
return { refused: `No provider gives a ${kind} computer on this server: pick another kind for this agent's computer in ${SETTINGS}.` };
|
|
203
237
|
if (!setting.provider)
|
|
204
238
|
return { refused: `A ${kind} computer needs a provider: pick ${pick}` };
|
|
205
|
-
const
|
|
206
|
-
if (!
|
|
239
|
+
const listed = registry.PROVIDERS.find((one) => one.id === setting.provider);
|
|
240
|
+
if (!listed)
|
|
207
241
|
return { refused: `${JSON.stringify(setting.provider)} is no computer provider this server knows: pick ${pick}` };
|
|
242
|
+
// The mounts its keys turn on (entryHere: Daytona's Archil mount with an Archil egress), read from the keys the claim
|
|
243
|
+
// gives it, so the folder it mounts is the one its provider, made with those keys, declares.
|
|
244
|
+
const keyed = listed.mountsWith === undefined ? undefined : await side.keysOf(listed.id);
|
|
245
|
+
const entry = keyed === undefined ? listed : entryHere(listed, (name) => Boolean(keyed[name]?.trim()));
|
|
208
246
|
// The configurations of the provider that serve the kind; none, and the registry says why, by its closest one.
|
|
209
247
|
const serving = servingOf(registry, entry, kind);
|
|
210
248
|
if (serving.length === 0) {
|
|
@@ -256,7 +294,7 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
256
294
|
if (persistent && mounts)
|
|
257
295
|
return { refused: `${aLabel(entry.label, true)} ${kind} mounts each run's folder, so it can't be kept between runs: turn persistent off for this agent's computer in ${SETTINGS}.` };
|
|
258
296
|
// Its keys: every required one saved, before anything starts; only declared names go to the provider.
|
|
259
|
-
const saved = await side.keysOf(entry.id);
|
|
297
|
+
const saved = keyed ?? (await side.keysOf(entry.id));
|
|
260
298
|
const has = (name) => typeof saved[name] === "string" && saved[name] !== "";
|
|
261
299
|
const missing = entry.keys.filter((key) => key.required && !has(key.name)).map((key) => key.name);
|
|
262
300
|
if (missing.length > 0) {
|
package/launcher/agentrun-serve
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
# Each secret named below that is set goes into one pipe as NAME=VALUE and a NUL, AGENTRUN_SECRETS_LEN bytes in all,
|
|
9
9
|
# on fd AGENTRUN_SECRETS_FD; the server reads exactly that many bytes first thing and closes the pipe. First, each
|
|
10
10
|
# secret moves out of the environment into this shell's own memory, so no process it starts (mktemp, mkfifo, rm, env)
|
|
11
|
-
# inherits one; only this launcher's own initial environment,
|
|
12
|
-
# pipe is a FIFO whose name is gone before any secret is written, and only this shell writes it, with its
|
|
13
|
-
# printf
|
|
14
|
-
#
|
|
11
|
+
# inherits one; only this launcher's own initial environment ever held them, and its writer's, a fork of it (below). The
|
|
12
|
+
# pipe is a FIFO whose name is gone before any secret is written, and only that fork of this shell writes it, with its
|
|
13
|
+
# builtin printf, as the server reads, so the secrets may come to any length; it is gone once the last byte is in the
|
|
14
|
+
# pipe, or at its next write once the server has exited without reading. `env -u` drops every name from what COMMAND
|
|
15
|
+
# inherits too. The condition:
|
|
16
|
+
# this runs before any run's process exists. A process of the same user started earlier could open the FIFO while it is
|
|
17
|
+
# named.
|
|
15
18
|
#
|
|
16
19
|
# AGENTRUN_SEAL_KEY, the key the server keeps every secret under (src/seal-key.ts), is one of them. Not set, the
|
|
17
20
|
# server keeps its own in seal/seal.key in its data directory, beside the store, made at its first start: this launcher
|
|
@@ -23,13 +26,17 @@
|
|
|
23
26
|
# BROWSERBASE_PROJECT_ID is no secret, but a tool key's field: every field a person may save is on this list, so a
|
|
24
27
|
# saved one is read by the same name and reaches a run's process over its pipe, as the launcher's does.
|
|
25
28
|
#
|
|
29
|
+
# ARCHIL_API_KEY, the Archil account key, and every computer provider's key from E2B_API_KEY to MODAL_TOKEN_SECRET
|
|
30
|
+
# (src/computer-keys.ts COMPUTER_KEY_NAMES): only the server's and the runner's own code reads one (the Archil claim,
|
|
31
|
+
# a computer's create), and no run is handed one.
|
|
32
|
+
#
|
|
26
33
|
# After MODAL_TOKEN_SECRET, the keys of pi-ai's other providers, which a pi run's model may need (GEMINI_API_KEY,
|
|
27
34
|
# DEEPSEEK_API_KEY, Bedrock's AWS keys, ...): the server holds each, and a run's process gets one over its pipe only when
|
|
28
35
|
# its model is that provider's (../src/model.ts' PROVIDER_KEYS). The custody test checks every key pi-ai's table names is
|
|
29
36
|
# here. Any other variable named like a key (a KEY, TOKEN, SECRET, PASSWORD, PASSWD, PASS, PAT, CREDENTIAL, CREDENTIALS or
|
|
30
37
|
# DSN segment, or a last PWD after another) stays in the server's environment, as this list does not take it, and in no
|
|
31
38
|
# run's: name it here to keep it from the server's too.
|
|
32
|
-
SECRETS='AGENTRUN_TOKEN AGENTRUN_API_KEY AGENTRUN_STORE_URL AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY AGENTRUN_SEAL_KEY DAYTONA_API_KEY MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
|
|
39
|
+
SECRETS='AGENTRUN_TOKEN AGENTRUN_TOKENS AGENTRUN_API_KEY AGENTRUN_STORE_URL AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY AGENTRUN_SEAL_KEY ARCHIL_API_KEY E2B_API_KEY ORGO_API_KEY PHONE_HARNESS_API_KEY AGENT37_API_KEY AGENT37_SSH_KEY DAYTONA_API_KEY BOXD_API_KEY MORPH_API_KEY CLOUDFLARE_RELAY_TOKEN FLY_API_TOKEN MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
|
|
33
40
|
set -eu
|
|
34
41
|
# Each secret out of the environment and into an unexported variable of this shell (agentrun_secret_<NAME>).
|
|
35
42
|
for name in $SECRETS; do
|
|
@@ -48,14 +55,18 @@ locale=${LC_ALL-}
|
|
|
48
55
|
locale_set=${LC_ALL+x}
|
|
49
56
|
LC_ALL=C
|
|
50
57
|
|
|
51
|
-
# Every other
|
|
58
|
+
# Every other program this launcher runs, it runs here, before it writes a secret.
|
|
52
59
|
dir=$(mktemp -d "${TMPDIR:-/tmp}/agentrun-serve.XXXXXX")
|
|
53
60
|
mkfifo -m 600 "$dir/secrets"
|
|
54
|
-
|
|
61
|
+
# The server's end read-only on 3, the writer's write-only on 4: once the server is gone, no read end is left, and the
|
|
62
|
+
# writer's next write fails (EPIPE) rather than wait. Opened read-write first, so neither one-way open waits for the other.
|
|
63
|
+
exec 4<>"$dir/secrets"
|
|
64
|
+
exec 3<"$dir/secrets"
|
|
65
|
+
exec 4>"$dir/secrets"
|
|
55
66
|
rm -f "$dir/secrets"
|
|
56
67
|
rmdir "$dir"
|
|
57
68
|
|
|
58
|
-
# From here to the exec: this shell's builtins only.
|
|
69
|
+
# From here to the exec: this shell's builtins and forks of it only.
|
|
59
70
|
total=0
|
|
60
71
|
for name in $SECRETS; do
|
|
61
72
|
eval "given=\${agentrun_secret_$name+x}"
|
|
@@ -63,20 +74,21 @@ for name in $SECRETS; do
|
|
|
63
74
|
eval "value=\${agentrun_secret_$name}"
|
|
64
75
|
total=$((total + ${#name} + ${#value} + 2))
|
|
65
76
|
done
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
for name in $SECRETS; do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
# The writer: a fork of this shell, so still its builtin printf, with the launcher's command line, which holds no secret.
|
|
78
|
+
# It writes beside the server rather than before it, so a pipe of any size is enough. It holds no read end of the pipe and none of the caller's stdio (a
|
|
79
|
+
# caller waiting for its output to end waits for the server alone). Forked twice, it belongs to init (in the image, tini)
|
|
80
|
+
# and is reaped there, never left a zombie under a server that reaps only its own children.
|
|
81
|
+
(
|
|
82
|
+
(
|
|
83
|
+
for name in $SECRETS; do
|
|
84
|
+
eval "given=\${agentrun_secret_$name+x}"
|
|
85
|
+
[ -n "$given" ] || continue
|
|
86
|
+
eval "value=\${agentrun_secret_$name}"
|
|
87
|
+
printf '%s=%s\000' "$name" "$value" >&4 || exit 1
|
|
88
|
+
done
|
|
89
|
+
) &
|
|
90
|
+
) 3<&- </dev/null >/dev/null 2>&1
|
|
91
|
+
exec 4>&-
|
|
80
92
|
if [ -n "$locale_set" ]; then LC_ALL=$locale; else unset LC_ALL; fi
|
|
81
93
|
|
|
82
94
|
if [ "${1-}" = "--" ]; then
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-serve",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.42",
|
|
4
4
|
"description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -54,19 +54,21 @@
|
|
|
54
54
|
"@earendil-works/pi-coding-agent": "1.5.2",
|
|
55
55
|
"@modelcontextprotocol/client": "2.4.0",
|
|
56
56
|
"@modelcontextprotocol/server": "2.4.0",
|
|
57
|
-
"@parcha/agentrun-computer": "0.1.0-beta.
|
|
58
|
-
"@parcha/agentrun-decisions": "0.1.0-beta.
|
|
59
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
60
|
-
"@parcha/agentrun-harness-claude": "0.1.0-beta.
|
|
61
|
-
"@parcha/agentrun-harness-codex": "0.1.0-beta.
|
|
62
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
63
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
64
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
57
|
+
"@parcha/agentrun-computer": "0.1.0-beta.42",
|
|
58
|
+
"@parcha/agentrun-decisions": "0.1.0-beta.42",
|
|
59
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.42",
|
|
60
|
+
"@parcha/agentrun-harness-claude": "0.1.0-beta.42",
|
|
61
|
+
"@parcha/agentrun-harness-codex": "0.1.0-beta.42",
|
|
62
|
+
"@parcha/agentrun-jev": "0.1.0-beta.42",
|
|
63
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.42",
|
|
64
|
+
"@parcha/pi-browser": "0.1.0-beta.42",
|
|
65
65
|
"@secretlint/core": "13.1.0",
|
|
66
66
|
"@secretlint/profiler": "13.1.0",
|
|
67
67
|
"@secretlint/secretlint-rule-preset-recommend": "13.1.0",
|
|
68
68
|
"croner": "11.0.0",
|
|
69
69
|
"disk": "1.12.0",
|
|
70
|
+
"fast-xml-parser": "4.5.7",
|
|
71
|
+
"ical.js": "2.2.1",
|
|
70
72
|
"imapflow": "2.11.0",
|
|
71
73
|
"ipaddr.js": "2.5.0",
|
|
72
74
|
"mailparser": "3.14.3",
|
package/templates/README.md
CHANGED
|
@@ -103,7 +103,7 @@ Each `evals/<case>/` is one test of the package's agent. No eval runs on the ser
|
|
|
103
103
|
list), `mcp` (an `mcp` need's toolkit to a fixture file in the case that fakes it), `learning` (a folder of notes in the case
|
|
104
104
|
the agent starts with: `MEMORY.md` and its notes), `web` (fakes `web_search` and `web_fetch` for the case's runs),
|
|
105
105
|
`monid` (fakes the package's monid endpoints for the case's runs), `now` (the case's clock), `email` (a fake mailbox
|
|
106
|
-
for the case's runs).
|
|
106
|
+
for the case's runs), `calendar` (a fake calendar for the case's runs).
|
|
107
107
|
- `web: unavailable`: every `web_search` answers with the words a rate-limited free search answers with, and every
|
|
108
108
|
`web_fetch` fails as a page that never answers does; no call reaches the network. `web:` a fixture file in the case
|
|
109
109
|
answers from that file instead:
|
|
@@ -165,6 +165,40 @@ Each `evals/<case>/` is one test of the package's agent. No eval runs on the ser
|
|
|
165
165
|
in_reply_to and text), the ones it moved or labelled (`message_id`, before and after, labels), and those it sent
|
|
166
166
|
(SMTP). The package's `tools` must name an email tool; only the eval's own server honours `email`, so a case with
|
|
167
167
|
it refuses `--server`.
|
|
168
|
+
- `calendar: fixtures/work.ics`, an iCalendar file in the case: a fake calendar server on this machine's loopback serves
|
|
169
|
+
it (with an ETag, as a provider does), and its address is saved as the server's calendar (Settings → Calendar) for
|
|
170
|
+
the case's runs and removed after them, so no run reads a real calendar. `calendar_events` reads it as it reads a
|
|
171
|
+
real one: repeating events expanded in the window (RRULE, RDATE, EXDATE), a moved or cancelled instance as the file
|
|
172
|
+
says, each event in its own time zone. The window's clock is the case's `now`, so a case that asks for "this week"
|
|
173
|
+
sets `now:`; without it, the real clock. Its graders see each `calendar_events` call with its arguments and its
|
|
174
|
+
answer (the events), as any call. The package's `tools` must name `calendar_events`; only the eval's own server
|
|
175
|
+
honours `calendar`, so a case with it refuses `--server`, and `--on-data` is refused while DIR's server keeps a
|
|
176
|
+
calendar, which the fake would replace.
|
|
177
|
+
- `feed: fixtures/feed.json`, a fixture file in the case: each run gets fake feeds of its own on this machine's
|
|
178
|
+
loopback, so no run reads a real feed. The first URL the package's feed trigger names (filled from the case's
|
|
179
|
+
`parameters`, as the apply fills it) is read from a fake serving the fixture's items; each other URL it names reads an
|
|
180
|
+
empty feed of the same format. The fixture:
|
|
181
|
+
```json
|
|
182
|
+
{ "description": "An open incident on GitHub's status page gets a status post.",
|
|
183
|
+
"format": "atom", "title": "GitHub Status - Incident History",
|
|
184
|
+
"items": [ { "id": "tag:status.example,2005:Incident/3", "link": "https://status.example/incidents/3",
|
|
185
|
+
"title": "Degraded Actions", "published": "2026-11-14T08:00:00Z", "updated": "2026-11-14T08:00:00Z",
|
|
186
|
+
"content": "<p><strong>Investigating</strong> - We are looking into it.</p>" } ],
|
|
187
|
+
"item": { "id": "tag:status.example,2005:Incident/3", "link": "https://status.example/incidents/3",
|
|
188
|
+
"title": "Degraded Actions", "published": "2026-11-14T08:00:00Z", "updated": "2026-11-14T09:30:00Z",
|
|
189
|
+
"content": "<p><strong>Resolved</strong> - This incident has been resolved.</p>" },
|
|
190
|
+
"trigger": "New item" }
|
|
191
|
+
```
|
|
192
|
+
`format` is `rss`, `atom` (served as a Statuspage history is), `json-feed` or `json-list` (an API's array of
|
|
193
|
+
objects, GitHub's pulls; served under the trigger's `items` pointer); `items` are the feed before the run, newest
|
|
194
|
+
first (an RSS, Atom or JSON Feed item's fields: `id`, `link`, `title`, `published`, `updated`, `author`, `summary`,
|
|
195
|
+
`content`, `categories`; a JSON list's are its raw objects). A run starts as its trigger would: the package is applied
|
|
196
|
+
(the trigger's first poll takes its start on `items`), `item` is added to the feed (or put in place of the item with
|
|
197
|
+
its `id`, an incident updated), and the trigger's next poll fires on it, `update: true` for an item it had seen with
|
|
198
|
+
an older `updated`. `trigger` names the trigger when the package has more than one feed trigger. The case's
|
|
199
|
+
`prompt.md` holds `description` and `runs` alone: the run's input and cap are the trigger's, and its graders' task is
|
|
200
|
+
that input, the item's payload in its tag. Only the eval's own server honours `feed`, so a case with it refuses
|
|
201
|
+
`--server`.
|
|
168
202
|
- A fake MCP server's fixture, one shape for every package:
|
|
169
203
|
```json
|
|
170
204
|
{ "server": "github", "description": "what the fake holds",
|
|
@@ -208,7 +242,7 @@ case's `max_cost_usd`, and each `llm` grade is a run of its own, capped at $0.50
|
|
|
208
242
|
| `--case NAME` | A case to run; repeat it. Without one, every case. |
|
|
209
243
|
| `--runs N` | Runs of each case, in place of each case's `runs`. |
|
|
210
244
|
| `--server URL` | Run on that server instead, with its token as the CLI finds one (`AGENTRUN_API_KEY`, the CLI's config, or the data directory's for the server on this machine). The token goes to the runner over the launcher's pipe and is never printed. |
|
|
211
|
-
| `--on-data DIR` | Run the eval's own server on DIR, a stopped server's data folder, in place of a temp one: the runs use what that server keeps (its ChatGPT sign-in, so a package is measured on the owner's plan), and every case's fakes still bind (`now`, `email`, `web`, `monid`). The agents the eval made are archived there, and the folder stays, its tool settings as they were (the agent's own pin holds a pinned write, as on `--server`). Refused with `--server`, while another server holds DIR, when DIR's server has work of its own (an enabled trigger, a run not ended) that the eval's server and runner would take up,
|
|
245
|
+
| `--on-data DIR` | Run the eval's own server on DIR, a stopped server's data folder, in place of a temp one: the runs use what that server keeps (its ChatGPT sign-in, so a package is measured on the owner's plan), and every case's fakes still bind (`now`, `email`, `calendar`, `web`, `monid`). The agents the eval made are archived there, and the folder stays, its tool settings as they were (the agent's own pin holds a pinned write, as on `--server`). Refused with `--server`, while another server holds DIR, when DIR's server has work of its own (an enabled trigger, a run not ended) that the eval's server and runner would take up, for an email case when DIR's server keeps an email account, which the case's fake mailbox would replace, and for a calendar case when DIR's server keeps a calendar. A case that fakes an MCP server DIR's server keeps by the same name fails, as on `--server`. |
|
|
212
246
|
| `--grader-model PROVIDER/MODEL` | The `llm` graders' model. Absent: the server's default. |
|
|
213
247
|
| `--report FILE` | The whole report as JSON: per case, per run and per grader, its pass, its reason and its cost. A summary goes to stdout either way, progress to stderr. |
|
|
214
248
|
| `--faux MODULE` | Answer every model request from the module, as the server's `--faux` does: no key, no network. |
|
|
@@ -309,13 +343,13 @@ package}`, and a line in the markdown).
|
|
|
309
343
|
| `tool_policy` | `{bash: read-only}`: a policy on the agent's bash, the one tool that takes one. Apply writes it as `policy` on bash in the agent's `tool_settings` (`definition.tool_settings.bash.policy`), whatever bash's permission, and the tool gate reads each shell call's command before it runs or anyone is asked. Under `read-only` it refuses, in words the model reads, any command that could write, run code or read outside the run's folder: a program outside the read list (git's read subcommands `diff`, `show`, `log`, `blame`, `grep`, `ls-files`, `ls-tree`, `rev-parse`, `cat-file`, `merge-base`, `status`, `shortlog`, `rev-list`, `diff-tree`, `name-rev`, `describe`; `grep`, `egrep`, `fgrep`, `rg`, `sed -n 'N,Mp'`, `cat`, `head`, `tail`, `wc`, `nl`, `ls`, `find` without `-exec` or `-delete`, `sort`, `uniq`, `cut`, `tr`, `diff`, `basename`, `dirname`, `echo`, `true`), a redirection other than `2>/dev/null` and `2>&1`, `$` and backticks, a subshell, `\|\|` or a lone `&`, a pipe into anything but a filter (`head`, `tail`, `sed -n`, `grep`, `wc`, `sort`, `uniq`, `cut`, `tr`, `nl`), an unquoted glob (a glob is quoted, and only in a grep pattern, an `--include=` value or a `find -name` value), a path outside the run's folder, or one on the never-open list (`.env*`, `.ssh/`, `id_rsa*`, `*.pem`, `*.key`, `.npmrc`, `.netrc`, `.git-credentials`, `credentials`), which refuses a command that names such a file but is no fence around the folder: a recursive search reads all it holds, the run's own files and never a key of the server's. `git -C <dir>` is allowed to a directory inside the folder. A line with a `cd` joins its commands with `&&` only. `bash_background` and `bash_input` are refused under it. The check reads the command, never the folder, so a symbolic link in the folder reaches what the computer lets it; and it holds bash alone, so a read-only agent's tools are `read` and `bash` (one that may write can change what git obeys). Approvals `never` lifts none of it. A package with `tools` grants `bash` among them. |
|
|
310
344
|
| `computer` | `default` (or absent): the agent runs where this server puts a new one. Or a preference list, `[shell, none]`, read like `harness`: apply takes the first entry this server meets now and saves it as the agent's `computer`. `shell` is a computer that gives the agent a shell here: Archil's serverless exec on the runner when Archil is on (Settings → Workspace; `bash` alone, so `bash_background` and the other background tools are not granted), else the Docker sandbox where Docker answers. `none` is no shell, and is always met: the shell tools in `tools` (`bash` and the background tools) are not granted, and neither is `tool_policy`'s bash. A package with no `tools` is given the chosen shell's tools, as a new agent in a box is given the box's. A fallback, or a tool not granted, is said in a `computer` warning on the apply. A list with `shell` alone, where there is none, refuses the apply (`409`, nothing made). A list without `shell` grants no shell tool, so one in `tools` is refused, and so is an entry after `none`, which would never be picked. The choice is made at apply: a server that gains a shell later gives it to an agent applied again. `GET /v2/templates` shows the list as `computer`, and as `computer_here` what an apply here would pick now: the entry, the agent's `computer`, the shell in words, the tools it would not grant, and the warning or refusal. |
|
|
311
345
|
| `checkout` | `pull_request` only: apply sets the agent definition's `checkout`, and the server checks out the pull request each run's GitHub event names before its first turn, in `repo/` of the run's folder, detached at the head, with its base and their merge base (refs `pr/head`, `pr/base`, `pr/merge-base`: `git diff pr/merge-base pr/head` reads the change). The server fetches it with its GitHub App's token, narrowed to that one repository and `contents: read` and revoked after the fetch, or anonymously with no App; the agent never holds a token, and nothing of it is left in the folder or the checkout's git config. The run's system prompt says what was checked out, or why nothing was, so the package's instructions can fall back to the GitHub MCP. It is removed when the run's claim ends. With `tool_policy: {bash: read-only}` the agent reads it with git's read subcommands and never fetches itself. |
|
|
312
|
-
| `parameters` | The setup an owner fills once, at apply. Written exactly as `inputs` are (the same keys, the same rule: required unless `required: false`, a `default` only on one that is not) and compiled by the same code; `GET /v2/templates` shows them as a JSON Schema like `input_schema`, and the console's Apply form is the run form. The one difference is where they are filled: apply takes them in `parameters` (a blank one takes its `default`; they are checked as a run's input is, with the same `422` words under `parameters.<name>`), and puts them where the package writes `${parameters.<name>}`: `display_name`, the body, a trigger's `target.input`, a schedule's `cron` and `timezone`, the `in` values of a github, webhook or
|
|
346
|
+
| `parameters` | The setup an owner fills once, at apply. Written exactly as `inputs` are (the same keys, the same rule: required unless `required: false`, a `default` only on one that is not) and compiled by the same code; `GET /v2/templates` shows them as a JSON Schema like `input_schema`, and the console's Apply form is the run form. The one difference is where they are filled: apply takes them in `parameters` (a blank one takes its `default`; they are checked as a run's input is, with the same `422` words under `parameters.<name>`), and puts them where the package writes `${parameters.<name>}`: `display_name`, the body, a trigger's `target.input`, a schedule's `cron` and `timezone`, the `in` values of a github, webhook, composio or feed trigger's `accept` where conditions, a composio trigger's `config` values, a feed trigger's `urls`, a trigger's `enabled`, and an `mcp` entry's `pin` values, nowhere else. Text takes the value as text (a list as its items joined by `, `). A `target.input` value, a composio trigger's `config` value or a pin value that is one placeholder alone takes the value with its type (a list pinned is a one-of); in `target.input` one given no value is dropped, so the input schema sees the field absent. A trigger's `enabled` takes only one placeholder alone, naming a boolean parameter with a default: the trigger is made on or off by its value. A feed trigger's `urls` that are one placeholder alone take an array-of-strings parameter whole. A parameter a where, a composio `config` or a feed's `urls` take is required or has a default, so none fills empty; one a schedule uses has a default, which the package's own schedule is checked with, and apply checks every trigger with the values given before it makes anything (`422` under `triggers.<i>`). |
|
|
313
347
|
| `inputs` | By name: each run's typed input, which apply compiles into the agent's `input_schema` (a closed JSON Schema object). Each is `{type: string \| number \| integer \| boolean \| array, required?, title?, description?, examples?, default?, enum?, pattern? and format? (strings), minLength?/maxLength? (strings), minimum?/maximum? (numbers), items? (an array's scalar, with that scalar's keys)}`, nothing else; an input is required unless it says `required: false`, and a `default` is for one that is not. `format` is `uri`, `email`, `hostname`, `date`, `date-time` or `uuid`, which the server checks, or `cron` or `timezone`, which a form reads. A default and each example are checked against their own input. `content` is the run's message: named, it is a string. Every path that starts a run (the API, the CLI, a trigger, the console) checks the input against it and refuses one that does not meet it with `422 input_invalid`, a path per field (`input.country`). The model is sent the input's `content`, then the other fields as one fenced `json` block under the line `Input:`, so the instructions read each field by its name. `GET /v2/templates` shows it as `input_schema`, and the console's run form is drawn from it. A trigger's `target.input` and an eval case's `input` are checked against it too. Absent: a run takes `{content}`, as before. |
|
|
314
348
|
| `secrets` | Variable names (never values) the server must hold: a model or tool key Settings saves (`OPENROUTER_API_KEY`, `PARALLEL_API_KEY`, ...), set where it starts or saved there. Any other name is refused: the server could neither save it nor hand it to a run. Apply refuses with `409 agent_not_runnable`, making nothing, when one is missing. |
|
|
315
349
|
| `budget` | `{per_run_usd}`: each run's cap (the agent's `max_cost_usd`), required when the package has triggers. A call count belongs in the instructions ("about 30 calls"); the cap is the hard stop. |
|
|
316
350
|
| `learning` | `true` or `false`: whether the agent's runs learn. |
|
|
317
351
|
| `approvals` | `ask` (the default: the agent asks its person before a tool runs) or `never` (it runs unattended). The package's recommendation, shown as `approvals_default` for the apply screen; a template whose job runs on triggers says `never`. `never` only skips asking for the tools the agent was granted: an MCP tool the owner left unticked at apply is not one. Under `ask`, a ticked tool is granted but not allowed: it follows this server's tool settings, so a write asks unless the owner allowed it in Settings → Tools, and a read runs unasked only where the owner turned on Allow reads for its server. Deny settings and pins hold either way. |
|
|
318
|
-
| `triggers` | `POST /v2/triggers` bodies with no `agent_id` (the target is a `start_run`), each with a `name`, unique in the package: the key an upgrade will match triggers by. `enabled` is `true` (the default), `false`, or `"${parameters.<name>}"`, one placeholder alone naming a boolean parameter that has a default (validate refuses any other text there, a parameter of another type, or one with no default): apply makes the trigger enabled or disabled by the owner's answer, the default when it is left out, so a second schedule can be one the owner opts into (`weekly`, default `false`, turning on a `monday-brief` at `0 8 * * 1`). A trigger made off is off as any trigger is: the owner switches it on or off later with `PATCH /v2/triggers/{id}` or the console. A `composio` trigger's `source.server` is the toolkit of one of the package's `mcp` needs, one with `source: composio` and `required: true` (`server: github` for `{source: composio, toolkit: github}`), never a saved server's name: apply makes the trigger on the saved Composio server that need maps to, the one candidate or the owner's pick under `servers`. Its `config` values and its `accept` where `in` values may hold `${parameters.<name>}`, a parameter that is required or has a default (`config: {owner: "${parameters.owner}", repo: "${parameters.repo}"}`); its `server` and `event` can't. It can't carry `instance_id`, `hook` or `move_subscription`, which this server sets when it makes the trigger on Composio. A composio trigger this server can't set up yet (no public URL, the saved server's user with no connected account or several, the project's subscription at another address) is skipped with a `triggers.<i>` warning in the refusal's words, as a github one is with GitHub not connected: the agent stands, and the owner makes the trigger from Triggers → New app trigger once that's fixed. Any other refusal undoes the apply. |
|
|
352
|
+
| `triggers` | `POST /v2/triggers` bodies with no `agent_id` (the target is a `start_run`), each with a `name`, unique in the package: the key an upgrade will match triggers by. `enabled` is `true` (the default), `false`, or `"${parameters.<name>}"`, one placeholder alone naming a boolean parameter that has a default (validate refuses any other text there, a parameter of another type, or one with no default): apply makes the trigger enabled or disabled by the owner's answer, the default when it is left out, so a second schedule can be one the owner opts into (`weekly`, default `false`, turning on a `monday-brief` at `0 8 * * 1`). A trigger made off is off as any trigger is: the owner switches it on or off later with `PATCH /v2/triggers/{id}` or the console. A `composio` trigger's `source.server` is the toolkit of one of the package's `mcp` needs, one with `source: composio` and `required: true` (`server: github` for `{source: composio, toolkit: github}`), never a saved server's name: apply makes the trigger on the saved Composio server that need maps to, the one candidate or the owner's pick under `servers`. Its `config` values and its `accept` where `in` values may hold `${parameters.<name>}`, a parameter that is required or has a default (`config: {owner: "${parameters.owner}", repo: "${parameters.repo}"}`); its `server` and `event` can't. It can't carry `instance_id`, `hook` or `move_subscription`, which this server sets when it makes the trigger on Composio. A composio trigger this server can't set up yet (no public URL, the saved server's user with no connected account or several, the project's subscription at another address) is skipped with a `triggers.<i>` warning in the refusal's words, as a github one is with GitHub not connected: the agent stands, and the owner makes the trigger from Triggers → New app trigger once that's fixed. Any other refusal undoes the apply. A `feed` trigger's `urls` is a list of URLs, each of which may hold `${parameters.<name>}` (pr-alert's `https://api.github.com/repos/${parameters.owner}/${parameters.repo}/pulls?state=open&sort=created&direction=desc`), or one placeholder alone naming an array-of-strings parameter (vendor-outage-watch's `"${parameters.status_feeds}"`), filled whole; each parameter required or with a default, and each filled value an http(s) URL, which apply checks (`422` under `triggers.<i>.source.urls[<j>]`). An array parameter given empty (`[]`) reads no feed: apply skips that trigger with a `triggers.<i>` warning naming the parameter, as it skips a github one with GitHub not connected, and the agent stands. Its `every_s`, `items` and `id` take no placeholder, its `accept` where `in` values may, and it has no `key` in a package. |
|
|
319
353
|
| `output` | `{schema: <file>}`: the JSON Schema of the agent's answer, a file in the package. It becomes the agent's `output_schema`: the runner puts it in the instructions on every harness and asks once more when an answer misses it. A string property with `contentMediaType: "text/markdown"` is a report the console renders as Markdown. A skill that reads the schema itself keeps the file in its own folder. |
|
|
320
354
|
|
|
321
355
|
The check is whole: the package is compiled with a sample of each parameter, and the agent body and each trigger body are
|