@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.53
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 +160 -1
- package/README.md +306 -36
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +14 -4
- package/dist/agent-delete.js +30 -58
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agents-store.d.ts +28 -18
- package/dist/agents-store.js +48 -34
- package/dist/api-only.d.ts +30 -8
- package/dist/api-only.js +40 -16
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +70 -7
- package/dist/composio-preset.d.ts +2 -1
- package/dist/composio-preset.js +4 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +9 -0
- package/dist/computer-setting.js +19 -1
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-BFgyZzF_.js +734 -0
- package/dist/console/assets/index-DbilxljH.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +3 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.d.ts +76 -0
- package/dist/fal-price.js +365 -0
- package/dist/handed-secret.d.ts +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +19 -1
- package/dist/learn/commit.js +160 -2
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +46 -15
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +16 -0
- package/dist/learn/folder.js +30 -4
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +29 -4
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning-words.d.ts +5 -0
- package/dist/learning-words.js +5 -0
- package/dist/learning.d.ts +15 -10
- package/dist/learning.js +14 -8
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +56 -12
- package/dist/mcp-pin-first.js +1 -1
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +7 -2
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +17 -12
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +211 -47
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +29 -5
- package/dist/run-launch.js +44 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +18 -1
- package/dist/run-view.js +28 -8
- package/dist/runner/adapter-loop.d.ts +14 -4
- package/dist/runner/adapter-loop.js +150 -31
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +35 -22
- package/dist/runner/audit.d.ts +10 -3
- package/dist/runner/audit.js +30 -7
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +31 -4
- package/dist/runner/claim-secrets.js +43 -7
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +32 -20
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +16 -3
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +9 -3
- package/dist/runner/learning-end.js +66 -29
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +7 -2
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +14 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +51 -24
- package/dist/runner/promotion.js +206 -78
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +174 -42
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.js +5 -2
- package/dist/runner/runner.js +41 -12
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +3 -3
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +4 -4
- package/dist/runs-over-store.d.ts +39 -8
- package/dist/runs-over-store.js +147 -32
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +185 -78
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +68 -32
- package/dist/server.js +678 -124
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +8 -0
- package/dist/store/agent-body.js +20 -6
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/schema.d.ts +15 -1
- package/dist/store/schema.js +43 -4
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +14 -0
- package/dist/store/sqlite/run-launch.js +58 -7
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.js +319 -153
- package/dist/store/store-schema.js +2 -2
- package/dist/store/store.d.ts +173 -33
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- package/dist/template-eval.js +4 -4
- package/dist/template-import.d.ts +10 -2
- package/dist/template-import.js +116 -13
- package/dist/templates.d.ts +29 -5
- package/dist/templates.js +68 -14
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/tools.js +1 -1
- package/dist/trigger-launch-hook.d.ts +47 -0
- package/dist/trigger-launch-hook.js +90 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +2 -1
- package/dist/uploads.d.ts +0 -3
- package/dist/uploads.js +2 -11
- package/dist/validate.js +4 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +5 -2
- package/dist/console/assets/index-Bt1B51b7.js +0 -733
- package/dist/console/assets/index-sVftE9Ht.css +0 -1
package/dist/harness-recipe.d.ts
CHANGED
|
@@ -15,9 +15,24 @@ export declare const RECIPE_CODES: Readonly<{
|
|
|
15
15
|
readonly env: "RECIPE_ENV_NOT_ALLOWLIST";
|
|
16
16
|
}>;
|
|
17
17
|
export type RecipeCode = (typeof RECIPE_CODES)[keyof typeof RECIPE_CODES];
|
|
18
|
-
/** One platform's release of the agent,
|
|
18
|
+
/** One platform's release of the agent, as its vendor ships it (an ACP registry entry's `distribution.binary.<platform>`,
|
|
19
|
+
* or a release manifest's, Google's agy CLI's), pinned by its archive's sha256 or sha512, with that platform's own `args`
|
|
20
|
+
* where it lists them: they start the agent there in place of the recipe's `args`. */
|
|
19
21
|
export type RecipeArchive = ArchiveRelease & {
|
|
20
22
|
readonly format: ArchiveFormat;
|
|
23
|
+
readonly args?: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
/** How an agent that runs on its owner's own account signs in, with its own sign-in (Google's agy CLI: `agy acp --login
|
|
26
|
+
* --gemini-dir DIR`), as T3 Code runs it. `args`: the flags that start that sign-in (`--login`), after the release's
|
|
27
|
+
* args. `homeArg`: the flag the agent takes the folder it keeps its sign-in in by (`--gemini-dir`), given the owner's
|
|
28
|
+
* folder (signInHomeOf) on the sign-in and on every run on it. AgentRun never reads, refreshes or sends the sign-in:
|
|
29
|
+
* the agent alone writes and reads what is in that folder (HARNESS.md#sign-in). Plan billing alone, beside its keys: a
|
|
30
|
+
* proxy-billed agent runs on the server's key. `terms`: the vendor's terms for it, named in the warning each sign-in
|
|
31
|
+
* prints. */
|
|
32
|
+
export type RecipeSignIn = {
|
|
33
|
+
readonly args: readonly string[];
|
|
34
|
+
readonly homeArg: string;
|
|
35
|
+
readonly terms?: string;
|
|
21
36
|
};
|
|
22
37
|
/** The variables a proxy-billed agent may read the proxy's address from: Goose's, and the Anthropic SDKs'. */
|
|
23
38
|
export declare const PROXY_HOST_ENVS: readonly string[];
|
|
@@ -28,8 +43,9 @@ export declare const PROXY_HOST_ENVS: readonly string[];
|
|
|
28
43
|
export declare const AGENT_VARS: Readonly<Record<"inherited" | "reserved" | "proxy", readonly string[]>>;
|
|
29
44
|
/** How the agent's model is billed. `proxy`: it speaks Anthropic's Messages API to the address in `hostEnv` (default
|
|
30
45
|
* ANTHROPIC_HOST) with ANTHROPIC_API_KEY, both the session's model proxy's (the run's cap and books hold), and reads the
|
|
31
|
-
* run's model from `env`. `plan`: the vendor bills the owner's plan on the recipe's own keys
|
|
32
|
-
* at these limits
|
|
46
|
+
* run's model from `env`. `plan`: the vendor bills the owner's plan on the recipe's own keys or its sign-in; the adapter
|
|
47
|
+
* stops the run at these limits, and `id` is the model chosen among those the agent lists (session/set_model), its own
|
|
48
|
+
* default when absent. */
|
|
33
49
|
export type RecipeModel = {
|
|
34
50
|
readonly billing: "proxy";
|
|
35
51
|
readonly wire: "anthropic-messages";
|
|
@@ -40,18 +56,28 @@ export type RecipeModel = {
|
|
|
40
56
|
readonly maxTurns: number;
|
|
41
57
|
readonly maxToolCalls: number;
|
|
42
58
|
readonly hosts?: readonly string[];
|
|
59
|
+
readonly id?: string;
|
|
43
60
|
};
|
|
44
61
|
/** A recipe file, as the loader passes it. */
|
|
45
62
|
export interface Recipe {
|
|
46
63
|
readonly id: string;
|
|
47
64
|
readonly label: string;
|
|
65
|
+
/** `registry`: the agent's id in the ACP registry, for a release copied from there (the agy CLI is not). */
|
|
48
66
|
readonly release: {
|
|
49
|
-
readonly registry
|
|
67
|
+
readonly registry?: string;
|
|
50
68
|
readonly version: string;
|
|
51
69
|
readonly archives: Readonly<Record<string, RecipeArchive>>;
|
|
52
70
|
};
|
|
53
71
|
readonly args: readonly string[];
|
|
72
|
+
/** The keys the agent runs on, by the names they are saved under for this harness alone. */
|
|
54
73
|
readonly keys: readonly string[];
|
|
74
|
+
/** The variable each key reaches the agent as, by its saved name, where it differs (a key entry's `env`): Antigravity's
|
|
75
|
+
* AI Studio key, saved as ANTIGRAVITY_GEMINI_API_KEY, reaches its runs alone as GEMINI_API_KEY, and the server's own
|
|
76
|
+
* GEMINI_API_KEY never does. */
|
|
77
|
+
readonly keyEnv: Readonly<Record<string, string>>;
|
|
78
|
+
/** The sign-in method the adapter sends with ACP `authenticate` on a run on the keys (Antigravity's `gemini-api-key`):
|
|
79
|
+
* none, the agent reads its keys unasked. */
|
|
80
|
+
readonly keyMethod?: string;
|
|
55
81
|
readonly env: Readonly<Record<string, string>>;
|
|
56
82
|
readonly model: RecipeModel;
|
|
57
83
|
readonly files: Readonly<Record<string, string>>;
|
|
@@ -63,6 +89,7 @@ export interface Recipe {
|
|
|
63
89
|
readonly quirks: {
|
|
64
90
|
readonly mcpCall?: "match" | "mint";
|
|
65
91
|
};
|
|
92
|
+
readonly signIn?: RecipeSignIn;
|
|
66
93
|
}
|
|
67
94
|
/** A recipe the loader refused: `code` is the first problem's, and the message says every one. */
|
|
68
95
|
export declare class RecipeRefused extends Error {
|
|
@@ -108,20 +135,60 @@ export declare function firstSeenRecord(file: string): {
|
|
|
108
135
|
read(): string | undefined;
|
|
109
136
|
write(sha256: string): void;
|
|
110
137
|
};
|
|
138
|
+
/** Where the first digest of every file the archive unpacked to (acp's treeDigest) is kept, for a recipe that pins no
|
|
139
|
+
* treeSha256: beside the binary's (firstSeenOf), so a second executable beside the binary (Antigravity's sidecar) is held
|
|
140
|
+
* to its first install as the binary is. */
|
|
141
|
+
export declare const firstSeenTreeOf: (data: string, recipe: Recipe, platform: string) => string;
|
|
111
142
|
/** The sha256 the installed binary must have: the recipe's pin, else the first one its install recorded; undefined when it
|
|
112
143
|
* pins none and none was recorded (never installed by the owner's command). */
|
|
113
144
|
export declare function pinnedDigest(data: string, recipe: Recipe, release: RecipeArchive, platform: string): {
|
|
114
145
|
sha256: string;
|
|
115
146
|
by: "recipe" | "first-seen";
|
|
116
147
|
} | undefined;
|
|
148
|
+
/** The digest every file of the install must have together (treeDigest): the recipe's treeSha256, else the first one its
|
|
149
|
+
* install recorded; undefined when neither is there (an install from before trees were recorded, or none at all). */
|
|
150
|
+
export declare function pinnedTree(data: string, recipe: Recipe, release: RecipeArchive, platform: string): {
|
|
151
|
+
sha256: string;
|
|
152
|
+
by: "recipe" | "first-seen";
|
|
153
|
+
} | undefined;
|
|
154
|
+
/** The folder the agent keeps its owner's sign-in in (given by signIn.homeArg on `agentrun harness sign-in` and on every
|
|
155
|
+
* run on that sign-in): `<data>/harnesses/<id>.sign-in`, 0700, beside the install and never inside it (a reinstall keeps
|
|
156
|
+
* the sign-in). The agent alone writes and reads what is in it: AgentRun hands it the path, and never lists, opens,
|
|
157
|
+
* copies or sends anything in it. */
|
|
158
|
+
export declare const signInHomeOf: (data: string, id: string) => string;
|
|
159
|
+
/** AgentRun's own note that the agent's sign-in ended well (its exit status 0), beside the folder and never in it:
|
|
160
|
+
* `<data>/harnesses/<id>.signed-in`, holding when and on which version. It holds nothing of the sign-in. */
|
|
161
|
+
export declare const signedInNoteOf: (data: string, id: string) => string;
|
|
162
|
+
/** The owner's command that signs the recipe at `file` in, on `data`. */
|
|
163
|
+
export declare const recipeSignInLine: (file: string, data: string, env?: NodeJS.ProcessEnv) => string;
|
|
164
|
+
/** Whether the agent's own sign-in ended well on `data` (signedInNoteOf): nothing in its folder is read to say so.
|
|
165
|
+
* Whether the sign-in still holds is the agent's to say when it runs (an ACP -32000, Authentication required). */
|
|
166
|
+
export declare const signedIn: (data: string, recipe: Recipe) => boolean;
|
|
167
|
+
/** What a passing harness-check proved, by digest: the recipe file, the binary and every file beside it, on `platform`. A
|
|
168
|
+
* server runs the recipe only while all three are still these (harness-recipe-entry.ts). */
|
|
169
|
+
export type RecipeChecked = {
|
|
170
|
+
readonly recipe: string;
|
|
171
|
+
readonly binary: string;
|
|
172
|
+
readonly tree: string;
|
|
173
|
+
readonly version: string;
|
|
174
|
+
readonly platform: string;
|
|
175
|
+
};
|
|
176
|
+
/** AgentRun's own note of the last harness-check that passed for the recipe `id` on `data`: `<data>/harnesses/<id>.checked`,
|
|
177
|
+
* beside the install and never in it. */
|
|
178
|
+
export declare const checkedNoteOf: (data: string, id: string) => string;
|
|
179
|
+
/** Writes the note of a passing check (checkedNoteOf), over the one before it: open to its owner alone. */
|
|
180
|
+
export declare function writeChecked(data: string, id: string, checked: RecipeChecked): void;
|
|
181
|
+
/** The note of the last check that passed for `id` on `data`, or undefined where there is none or it is not one. */
|
|
182
|
+
export declare function checkedOf(data: string, id: string): RecipeChecked | undefined;
|
|
117
183
|
/** Installs the recipe's release into `<data>/harnesses/<id>` (the owner's command, rule 4): its archive downloaded and
|
|
118
184
|
* checked against the recipe's sha256, unpacked, and its binary checked against the recipe's pin, or recorded as the
|
|
119
|
-
* first one seen where the recipe pins none (a later one that differs is refused).
|
|
185
|
+
* first one seen where the recipe pins none (a later one that differs is refused). Every file beside it the same way: the
|
|
186
|
+
* recipe's treeSha256, else the first tree digest recorded, so nothing in the archive runs unpinned. */
|
|
120
187
|
export declare function installRecipe(recipe: Recipe, file: string, data: string, options?: ArchiveInstallOptions, env?: NodeJS.ProcessEnv): Promise<{
|
|
121
188
|
installed: "already" | "now";
|
|
122
189
|
binary: string;
|
|
123
190
|
version: string;
|
|
124
|
-
pinnedBy: "
|
|
191
|
+
pinnedBy: "recorded" | "recipe" | "first-seen";
|
|
125
192
|
}>;
|
|
126
193
|
/** The owner's command that checks the recipe at `file`, installed into `data`. */
|
|
127
194
|
export declare const recipeCheckLine: (file: string, data: string, env?: NodeJS.ProcessEnv) => string;
|
package/dist/harness-recipe.js
CHANGED
|
@@ -7,7 +7,9 @@ import { ARCHIVE_FORMATS, archivePlatform, installArchive } from "./harness-arch
|
|
|
7
7
|
import { BUILTIN_HARNESS_IDS } from "./harness-table.js";
|
|
8
8
|
import { commandData } from "./harness-owned.js";
|
|
9
9
|
import { harnessesOf, installDirOf, shellWord } from "./harness-install.js";
|
|
10
|
-
import {
|
|
10
|
+
import { ENV_NAME, KEY_NAME, launchEnv } from "@parcha/agentrun-kernel";
|
|
11
|
+
import { acpPackage } from "./acp-package.js";
|
|
12
|
+
import { keyShaped, SECRET_SEGMENTS } from "./secret-name.js";
|
|
11
13
|
import { SECRET_NAMES } from "./secrets.js";
|
|
12
14
|
/** The codes a refused recipe carries, one per rule, and one for a file that is not a recipe at all. */
|
|
13
15
|
export const RECIPE_CODES = Object.freeze({
|
|
@@ -35,6 +37,12 @@ export const AGENT_VARS = Object.freeze({
|
|
|
35
37
|
reserved: Object.freeze(["HOME", "TMPDIR", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME", "XDG_STATE_HOME", "GIT_CEILING_DIRECTORIES"]),
|
|
36
38
|
proxy: Object.freeze([...PROXY_HOST_ENVS, "ANTHROPIC_API_KEY"]),
|
|
37
39
|
});
|
|
40
|
+
/** A sign-in method's id as an agent lists it (keyMethod's `gemini-api-key`). */
|
|
41
|
+
const SIGN_IN_METHOD = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
42
|
+
/** A long flag as signIn.homeArg names one (`--gemini-dir`): its value is the next argument, never after an `=`. */
|
|
43
|
+
const LONG_FLAG = /^--[a-z0-9][a-z0-9-]{0,63}$/;
|
|
44
|
+
/** `items` in a sentence: `a`, `a and b`, `a, b and c`. */
|
|
45
|
+
const listed = (items) => (items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`);
|
|
38
46
|
/** A host a plan-billed agent's vendor is on, as model.hosts names it: a lowercase host name, with an optional port. */
|
|
39
47
|
const VENDOR_HOST = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*(?::([1-9][0-9]{0,4}))?$/;
|
|
40
48
|
const vendorHost = (host) => {
|
|
@@ -53,7 +61,7 @@ export class RecipeRefused extends Error {
|
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
/** The fields a recipe has. */
|
|
56
|
-
const FIELDS = new Set(["id", "label", "release", "args", "keys", "env", "model", "files", "state", "declares", "quirks", "description", "$schema"]);
|
|
64
|
+
const FIELDS = new Set(["id", "label", "release", "args", "keys", "keyMethod", "env", "model", "files", "state", "declares", "quirks", "signIn", "description", "$schema"]);
|
|
57
65
|
/** Fields that would run something of the recipe's own at install or start (rule 4). */
|
|
58
66
|
const INSTALL_FIELDS = new Set(["install", "installCommand", "postinstall", "preinstall", "setup", "script", "scripts", "run", "hooks", "update"]);
|
|
59
67
|
/** Fields that would name a binary other than the release's archive (rule 2). */
|
|
@@ -62,9 +70,9 @@ const BINARY_FIELDS = new Set(["command", "binary", "path", "bin", "executable",
|
|
|
62
70
|
const ENV_FIELDS = new Set(["inheritEnv", "passEnv", "envFrom", "inherit", "envPassthrough", "passthroughEnv"]);
|
|
63
71
|
/** Every variable of AGENT_VARS. */
|
|
64
72
|
const SET_BY_ADAPTER = new Set(Object.values(AGENT_VARS).flat());
|
|
65
|
-
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
66
73
|
const SHA256 = /^[0-9a-f]{64}$/;
|
|
67
|
-
const
|
|
74
|
+
const SHA512 = /^[0-9a-f]{128}$/;
|
|
75
|
+
const ARCHIVE_FIELDS = new Set(["url", "format", "sha256", "sha512", "cmd", "binarySha256", "treeSha256", "args"]);
|
|
68
76
|
/** A value the host would fill in from its own environment: `$NAME` or `${NAME}`. */
|
|
69
77
|
const EXPANDS = /\$(?:\{[^}]*\}|[A-Za-z_])/;
|
|
70
78
|
/** Whether `name` is a key the server holds for anything but this harness: the launcher's secrets (model providers, the
|
|
@@ -82,6 +90,24 @@ export function insideHome(path) {
|
|
|
82
90
|
}
|
|
83
91
|
const isPlain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
84
92
|
const strings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
93
|
+
/** A recipe's keys as entries: each a saved name, handed as `env` (its own name, unless an entry `{ name, env }` says
|
|
94
|
+
* another); undefined when `keys` is not a list of those. */
|
|
95
|
+
function keyEntries(keys) {
|
|
96
|
+
if (keys === undefined)
|
|
97
|
+
return [];
|
|
98
|
+
if (!Array.isArray(keys))
|
|
99
|
+
return undefined;
|
|
100
|
+
const entries = [];
|
|
101
|
+
for (const key of keys) {
|
|
102
|
+
if (typeof key === "string")
|
|
103
|
+
entries.push({ name: key, env: key });
|
|
104
|
+
else if (isPlain(key) && typeof key.name === "string" && typeof key.env === "string" && Object.keys(key).every((field) => field === "name" || field === "env"))
|
|
105
|
+
entries.push({ name: key.name, env: key.env });
|
|
106
|
+
else
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return entries;
|
|
110
|
+
}
|
|
85
111
|
/** Every problem with `parsed` as a recipe, by its rule's code. */
|
|
86
112
|
export function recipeProblems(parsed) {
|
|
87
113
|
const problems = [];
|
|
@@ -106,20 +132,21 @@ export function recipeProblems(parsed) {
|
|
|
106
132
|
say(RECIPE_CODES.invalid, `id must match ${HARNESS_ID_PATTERN}`);
|
|
107
133
|
else if (BUILTIN_HARNESS_IDS.includes(r.id) || RESERVED_HARNESS_IDS.includes(r.id))
|
|
108
134
|
say(RECIPE_CODES.invalid, `id ${r.id} is a harness AgentRun already has, or a name its runs carry; give yours its own`);
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
// Printed in sentences on a terminal (the sign-in's warning among them), so no control character reaches one.
|
|
136
|
+
if (typeof r.label !== "string" || !r.label.trim() || r.label.length > 80 || /\p{Cc}/u.test(r.label))
|
|
137
|
+
say(RECIPE_CODES.invalid, "label is the harness's name in a sentence, 1 to 80 characters, none a control character");
|
|
111
138
|
// Rule 2: the release.
|
|
112
139
|
const release = r.release;
|
|
113
140
|
if (!isPlain(release))
|
|
114
|
-
say(RECIPE_CODES.binary, "release names the agent's
|
|
141
|
+
say(RECIPE_CODES.binary, "release names the agent's version and an archive per platform with its sha256 or sha512 (and its ACP registry id, where it is listed there)");
|
|
115
142
|
else {
|
|
116
143
|
for (const field of Object.keys(release))
|
|
117
144
|
if (!["registry", "version", "archives"].includes(field))
|
|
118
145
|
say(BINARY_FIELDS.has(field) ? RECIPE_CODES.binary : INSTALL_FIELDS.has(field) ? RECIPE_CODES.install : RECIPE_CODES.invalid, `release.${field} is not a release field`);
|
|
119
|
-
if (typeof release.registry !== "string" || !/^[a-z0-9][a-z0-9._-]{0,63}$/.test(release.registry))
|
|
120
|
-
say(RECIPE_CODES.invalid, "release.registry is the agent's id in the ACP registry");
|
|
146
|
+
if (release.registry !== undefined && (typeof release.registry !== "string" || !/^[a-z0-9][a-z0-9._-]{0,63}$/.test(release.registry)))
|
|
147
|
+
say(RECIPE_CODES.invalid, "release.registry, when given, is the agent's id in the ACP registry");
|
|
121
148
|
if (typeof release.version !== "string" || !/^[0-9A-Za-z][0-9A-Za-z.+_-]{0,63}$/.test(release.version))
|
|
122
|
-
say(RECIPE_CODES.invalid, "release.version is the
|
|
149
|
+
say(RECIPE_CODES.invalid, "release.version is the release's version string");
|
|
123
150
|
if (!isPlain(release.archives) || !Object.keys(release.archives).length)
|
|
124
151
|
say(RECIPE_CODES.binary, "release.archives names at least one platform's archive (linux-x86_64, darwin-aarch64, ...)");
|
|
125
152
|
else {
|
|
@@ -128,7 +155,7 @@ export function recipeProblems(parsed) {
|
|
|
128
155
|
if (!/^(darwin|linux|windows)-(aarch64|x86_64)$/.test(platform))
|
|
129
156
|
say(RECIPE_CODES.invalid, `${at}: a platform is named as the registry names it (linux-x86_64)`);
|
|
130
157
|
if (!isPlain(archive)) {
|
|
131
|
-
say(RECIPE_CODES.binary, `${at} is { url, format, sha256, cmd }`);
|
|
158
|
+
say(RECIPE_CODES.binary, `${at} is { url, format, sha256 or sha512, cmd }`);
|
|
132
159
|
continue;
|
|
133
160
|
}
|
|
134
161
|
for (const field of Object.keys(archive))
|
|
@@ -142,13 +169,22 @@ export function recipeProblems(parsed) {
|
|
|
142
169
|
url = undefined;
|
|
143
170
|
}
|
|
144
171
|
if (!url || url.protocol !== "https:" || url.username || url.password)
|
|
145
|
-
say(RECIPE_CODES.binary, `${at}.url must be the
|
|
146
|
-
|
|
147
|
-
|
|
172
|
+
say(RECIPE_CODES.binary, `${at}.url must be the vendor's https URL of the archive`);
|
|
173
|
+
// The archive's one digest, as its vendor lists it: the registry's sha256, or a release manifest's sha512.
|
|
174
|
+
if ((archive.sha256 === undefined) === (archive.sha512 === undefined))
|
|
175
|
+
say(RECIPE_CODES.binary, `${at} pins its archive by one digest: sha256 (64 lowercase hex digits) or sha512 (128), as its vendor lists it`);
|
|
176
|
+
else if (archive.sha256 !== undefined && (typeof archive.sha256 !== "string" || !SHA256.test(archive.sha256)))
|
|
177
|
+
say(RECIPE_CODES.binary, `${at}.sha256 must be the archive's sha256 as its vendor lists it, 64 lowercase hex digits`);
|
|
178
|
+
else if (archive.sha512 !== undefined && (typeof archive.sha512 !== "string" || !SHA512.test(archive.sha512)))
|
|
179
|
+
say(RECIPE_CODES.binary, `${at}.sha512 must be the archive's sha512 as its vendor lists it, 128 lowercase hex digits`);
|
|
148
180
|
if (archive.binarySha256 !== undefined && (typeof archive.binarySha256 !== "string" || !SHA256.test(archive.binarySha256)))
|
|
149
181
|
say(RECIPE_CODES.binary, `${at}.binarySha256, when given, is the unpacked binary's sha256, 64 lowercase hex digits`);
|
|
182
|
+
if (archive.treeSha256 !== undefined && (typeof archive.treeSha256 !== "string" || !SHA256.test(archive.treeSha256)))
|
|
183
|
+
say(RECIPE_CODES.binary, `${at}.treeSha256, when given, is the digest of every file the archive unpacks to (HARNESS.md), 64 lowercase hex digits`);
|
|
184
|
+
if (archive.args !== undefined && !strings(archive.args))
|
|
185
|
+
say(RECIPE_CODES.invalid, `${at}.args, when given, is a list of strings: the release's args for that platform`);
|
|
150
186
|
if (!ARCHIVE_FORMATS.includes(archive.format))
|
|
151
|
-
say(RECIPE_CODES.binary, `${at}.format: the installer unpacks ${ARCHIVE_FORMATS
|
|
187
|
+
say(RECIPE_CODES.binary, `${at}.format: the installer unpacks ${listed(ARCHIVE_FORMATS)} archives alone`);
|
|
152
188
|
if (typeof archive.cmd !== "string" || !archive.cmd || isAbsolute(archive.cmd) || !insideHome(archive.cmd))
|
|
153
189
|
say(RECIPE_CODES.paths, `${at}.cmd is the binary's path inside the archive (./agent), never one outside it`);
|
|
154
190
|
}
|
|
@@ -156,20 +192,48 @@ export function recipeProblems(parsed) {
|
|
|
156
192
|
}
|
|
157
193
|
if (r.args !== undefined && !strings(r.args))
|
|
158
194
|
say(RECIPE_CODES.invalid, "args is a list of strings");
|
|
159
|
-
// Rule 1: keys.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
195
|
+
// Rule 1: keys, each saved under a name of this harness's own, and handed under that name or the one its entry names.
|
|
196
|
+
const entries = keyEntries(r.keys);
|
|
197
|
+
if (!entries)
|
|
198
|
+
say(RECIPE_CODES.keys, 'keys is a list of the key names saved for this harness alone, each a name or { "name": its saved name, "env": the variable the agent reads it from }');
|
|
199
|
+
else {
|
|
200
|
+
const handed = new Set();
|
|
201
|
+
const saved = new Set();
|
|
202
|
+
for (const { name, env } of entries) {
|
|
203
|
+
// One saved key reaches the agent under one name: the adapter maps each saved name to a single variable.
|
|
204
|
+
if (saved.has(name))
|
|
205
|
+
say(RECIPE_CODES.keys, `the key ${name} is named twice: a saved key is handed under one name`);
|
|
206
|
+
saved.add(name);
|
|
207
|
+
if (!KEY_NAME.test(name))
|
|
208
|
+
say(RECIPE_CODES.keys, `the key ${JSON.stringify(name)} is not a key's name (capitals, digits and _, at most 64)`);
|
|
166
209
|
else if (serverKey(name))
|
|
167
|
-
say(RECIPE_CODES.keys, `${name} is a key this server holds for something else; a recipe names only keys saved for its own harness`);
|
|
210
|
+
say(RECIPE_CODES.keys, `${name} is a key this server holds for something else; a recipe names only keys saved for its own harness (save it under a name of its own, and hand it as ${name} with { "name", "env" })`);
|
|
168
211
|
else if (SET_BY_ADAPTER.has(name))
|
|
169
212
|
say(RECIPE_CODES.env, `${name} is set by the adapter or the proxy, never by a key`);
|
|
213
|
+
// Shaped as a key's name (a KEY, TOKEN, SECRET... segment), so the one cut every child's environment takes
|
|
214
|
+
// (secrets.ts withoutSecrets) keeps it out of every run's tools and every other child, wherever it is set.
|
|
215
|
+
else if (!keyShaped(name))
|
|
216
|
+
say(RECIPE_CODES.keys, `the key ${name} is not named as a key: its name needs one of the segments ${SECRET_SEGMENTS.join(", ")} (${name}_KEY, say), so no child of the server is ever handed it by its name`);
|
|
217
|
+
// The variable it reaches the agent as may be a provider's name the server holds a key under (GEMINI_API_KEY): the
|
|
218
|
+
// value is this harness's own, read by its saved name, so the server's never reaches the agent. Never the
|
|
219
|
+
// adapter's, the proxy's, or the server's own (AGENTRUN_, AGENT_MODEL_).
|
|
220
|
+
if (!KEY_NAME.test(env))
|
|
221
|
+
say(RECIPE_CODES.keys, `the key ${name}'s env ${JSON.stringify(env)} is not a key's name (capitals, digits and _, at most 64)`);
|
|
222
|
+
else if (SET_BY_ADAPTER.has(env) || env.startsWith("AGENTRUN_") || env.startsWith("AGENT_MODEL_"))
|
|
223
|
+
say(RECIPE_CODES.env, `the key ${name} is handed as ${env}, which the adapter, the proxy or the server sets`);
|
|
224
|
+
else if (launchEnv(env))
|
|
225
|
+
say(RECIPE_CODES.env, `the key ${name} is handed as ${env}, which changes what the agent's process loads or runs`);
|
|
226
|
+
if (handed.has(env))
|
|
227
|
+
say(RECIPE_CODES.keys, `two keys are handed as ${env}`);
|
|
228
|
+
handed.add(env);
|
|
170
229
|
}
|
|
171
|
-
|
|
172
|
-
|
|
230
|
+
}
|
|
231
|
+
if (r.keyMethod !== undefined && (typeof r.keyMethod !== "string" || !SIGN_IN_METHOD.test(r.keyMethod)))
|
|
232
|
+
say(RECIPE_CODES.invalid, "keyMethod, when given, is the sign-in method's id the agent's initialize lists for its key (gemini-api-key)");
|
|
233
|
+
else if (r.keyMethod !== undefined && !entries?.length)
|
|
234
|
+
say(RECIPE_CODES.invalid, "keyMethod is the method the agent signs in with on its keys: name them in keys");
|
|
235
|
+
// Rule 5: env, with rule 1 for a key named in it (by its saved name or the one it is handed as).
|
|
236
|
+
const keys = new Set((entries ?? []).flatMap(({ name, env }) => [name, env]));
|
|
173
237
|
if (r.env !== undefined && !isPlain(r.env))
|
|
174
238
|
say(RECIPE_CODES.env, "env is an object of variable names and their literal values");
|
|
175
239
|
else
|
|
@@ -180,6 +244,8 @@ export function recipeProblems(parsed) {
|
|
|
180
244
|
say(RECIPE_CODES.keys, `env names ${name}, a key: a key is never written in a recipe; name it in keys, and only a key of this harness's own`);
|
|
181
245
|
else if (SET_BY_ADAPTER.has(name))
|
|
182
246
|
say(RECIPE_CODES.env, `env names ${name}, which the adapter or the proxy sets`);
|
|
247
|
+
else if (launchEnv(name))
|
|
248
|
+
say(RECIPE_CODES.env, `env names ${name}, which changes what the agent's process loads or runs`);
|
|
183
249
|
if (typeof value !== "string")
|
|
184
250
|
say(RECIPE_CODES.env, `env.${name} must be a string`);
|
|
185
251
|
else if (EXPANDS.test(value))
|
|
@@ -196,6 +262,8 @@ export function recipeProblems(parsed) {
|
|
|
196
262
|
say(RECIPE_CODES.invalid, "model.env names the variable the agent reads its model from");
|
|
197
263
|
else if (SET_BY_ADAPTER.has(model.env) || serverKey(model.env) || keyShaped(model.env))
|
|
198
264
|
say(RECIPE_CODES.env, `model.env names ${model.env}, which is the adapter's, the proxy's or a key`);
|
|
265
|
+
else if (launchEnv(model.env))
|
|
266
|
+
say(RECIPE_CODES.env, `model.env names ${model.env}, which changes what the agent's process loads or runs`);
|
|
199
267
|
else if (isPlain(r.env) && model.env in r.env)
|
|
200
268
|
say(RECIPE_CODES.env, `env names ${model.env}, which the run's model sets`);
|
|
201
269
|
if (model.hostEnv !== undefined && !PROXY_HOST_ENVS.includes(model.hostEnv))
|
|
@@ -209,16 +277,51 @@ export function recipeProblems(parsed) {
|
|
|
209
277
|
say(RECIPE_CODES.invalid, "plan billing needs maxTurns, a whole number of turns of at least 1");
|
|
210
278
|
if (!Number.isInteger(model.maxToolCalls) || model.maxToolCalls < 0)
|
|
211
279
|
say(RECIPE_CODES.invalid, "plan billing needs maxToolCalls, a whole number of calls");
|
|
212
|
-
if (!
|
|
213
|
-
say(RECIPE_CODES.
|
|
280
|
+
if (!entries?.length)
|
|
281
|
+
say(RECIPE_CODES.invalid, "a plan-billed agent runs on its vendor's key, the one route its check, a schedule and a shared server take: name the key in keys (a signIn is its owner's own sign-in beside it, on their own machine alone)");
|
|
214
282
|
if (model.hosts !== undefined && (!strings(model.hosts) || model.hosts.length > 16 || !model.hosts.every(vendorHost)))
|
|
215
283
|
say(RECIPE_CODES.invalid, "model.hosts lists at most 16 hosts the vendor's model is on, each a host name with an optional :port from 1 to 65535 (default 443)");
|
|
284
|
+
// A model id as an agent lists one (`gpt-5.4-nano[reasoning=medium]`): the ACP package's MODEL_ID, the one definition.
|
|
285
|
+
// Without that package no recipe runs (harness-table.ts refuses it by name), so its form goes unchecked here.
|
|
286
|
+
const listedId = acpPackage()?.MODEL_ID;
|
|
287
|
+
if (model.id !== undefined && (typeof model.id !== "string" || (listedId !== undefined && !listedId.test(model.id))))
|
|
288
|
+
say(RECIPE_CODES.invalid, "model.id, when given, is the model's id as the agent lists it (session/new's availableModels): one word, no spaces");
|
|
216
289
|
for (const field of Object.keys(model))
|
|
217
|
-
if (!["billing", "maxTurns", "maxToolCalls", "hosts"].includes(field))
|
|
290
|
+
if (!["billing", "maxTurns", "maxToolCalls", "hosts", "id"].includes(field))
|
|
218
291
|
say(RECIPE_CODES.invalid, `model.${field} is not a field of plan billing`);
|
|
219
292
|
}
|
|
220
293
|
else
|
|
221
294
|
say(RECIPE_CODES.invalid, 'model.billing is "proxy" or "plan"');
|
|
295
|
+
// The sign-in: plan billing alone, the agent's own sign-in flags, and the one flag that names its folder, which AgentRun
|
|
296
|
+
// alone gives a value (the owner's folder), so no other argument names it.
|
|
297
|
+
const signIn = r.signIn;
|
|
298
|
+
if (signIn !== undefined) {
|
|
299
|
+
if (!isPlain(signIn))
|
|
300
|
+
say(RECIPE_CODES.invalid, 'signIn is { "args": the flags that start the agent\'s own sign-in (["--login"]), "homeArg": the flag it takes its sign-in folder by ("--gemini-dir") }');
|
|
301
|
+
else {
|
|
302
|
+
for (const field of Object.keys(signIn))
|
|
303
|
+
if (!["args", "homeArg", "terms"].includes(field))
|
|
304
|
+
say(RECIPE_CODES.invalid, `signIn.${field} is not a sign-in field`);
|
|
305
|
+
// Printed as given in the sign-in's warning: printable ASCII with no space, at most 200 characters.
|
|
306
|
+
if (signIn.terms !== undefined && (typeof signIn.terms !== "string" || !/^https:\/\/[\x21-\x7e]{1,192}$/.test(signIn.terms) || URL.parse(signIn.terms)?.protocol !== "https:"))
|
|
307
|
+
say(RECIPE_CODES.invalid, "signIn.terms, when given, is the https address of the vendor's terms for a person's own sign-in, said at each sign-in: printable ASCII with no space, at most 200 characters");
|
|
308
|
+
if (!strings(signIn.args) || !signIn.args.length)
|
|
309
|
+
say(RECIPE_CODES.invalid, 'signIn.args is a list of at least one string: the flags that start the agent\'s own sign-in (["--login"])');
|
|
310
|
+
else if (signIn.args.some((arg) => EXPANDS.test(arg)))
|
|
311
|
+
say(RECIPE_CODES.env, "signIn.args reads the host's environment ($NAME); write each argument out");
|
|
312
|
+
if (typeof signIn.homeArg !== "string" || !LONG_FLAG.test(signIn.homeArg))
|
|
313
|
+
say(RECIPE_CODES.invalid, 'signIn.homeArg is the long flag the agent takes the folder it keeps its sign-in in by ("--gemini-dir"), its value given by AgentRun');
|
|
314
|
+
else {
|
|
315
|
+
const archives = isPlain(release) && isPlain(release.archives) ? Object.values(release.archives) : [];
|
|
316
|
+
const elsewhere = [strings(signIn.args) ? signIn.args : [], strings(r.args) ? r.args : [], ...archives.map((archive) => (isPlain(archive) && strings(archive.args) ? archive.args : []))];
|
|
317
|
+
const flag = signIn.homeArg;
|
|
318
|
+
if (elsewhere.some((args) => args.some((arg) => arg === flag || arg.startsWith(`${flag}=`))))
|
|
319
|
+
say(RECIPE_CODES.invalid, `signIn.homeArg ${flag} is in args too: AgentRun alone gives it its value, the owner's sign-in folder`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (isPlain(model) && model.billing !== "plan")
|
|
323
|
+
say(RECIPE_CODES.invalid, "signIn is for a plan-billed agent: a proxy-billed one runs on the server's key, through its proxy");
|
|
324
|
+
}
|
|
222
325
|
// Rule 3: files and state.
|
|
223
326
|
if (r.files !== undefined && !isPlain(r.files))
|
|
224
327
|
say(RECIPE_CODES.paths, "files is an object of paths in the private HOME and their contents");
|
|
@@ -257,18 +360,22 @@ export function parseRecipe(text) {
|
|
|
257
360
|
if (problems.length)
|
|
258
361
|
throw new RecipeRefused(problems[0].code, problems);
|
|
259
362
|
const r = parsed;
|
|
363
|
+
const entries = keyEntries(r.keys);
|
|
260
364
|
return Object.freeze({
|
|
261
365
|
id: r.id,
|
|
262
366
|
label: r.label,
|
|
263
367
|
release: r.release,
|
|
264
368
|
args: r.args ?? [],
|
|
265
|
-
keys:
|
|
369
|
+
keys: entries.map(({ name }) => name),
|
|
370
|
+
keyEnv: Object.fromEntries(entries.filter(({ name, env }) => name !== env).map(({ name, env }) => [name, env])),
|
|
371
|
+
...(r.keyMethod ? { keyMethod: r.keyMethod } : {}),
|
|
266
372
|
env: r.env ?? {},
|
|
267
373
|
model: r.model,
|
|
268
374
|
files: Object.fromEntries(Object.entries(r.files ?? {}).map(([path, content]) => [insideHome(path), content])),
|
|
269
375
|
state: (r.state ?? []).map((path) => insideHome(path)),
|
|
270
376
|
declares: r.declares,
|
|
271
377
|
quirks: r.quirks ?? {},
|
|
378
|
+
...(r.signIn ? { signIn: Object.freeze({ args: Object.freeze([...r.signIn.args]), homeArg: r.signIn.homeArg, ...(r.signIn.terms ? { terms: r.signIn.terms } : {}) }) } : {}),
|
|
272
379
|
});
|
|
273
380
|
}
|
|
274
381
|
/** The recipe file at `path`, read and loaded. */
|
|
@@ -309,6 +416,10 @@ export function firstSeenRecord(file) {
|
|
|
309
416
|
},
|
|
310
417
|
};
|
|
311
418
|
}
|
|
419
|
+
/** Where the first digest of every file the archive unpacked to (acp's treeDigest) is kept, for a recipe that pins no
|
|
420
|
+
* treeSha256: beside the binary's (firstSeenOf), so a second executable beside the binary (Antigravity's sidecar) is held
|
|
421
|
+
* to its first install as the binary is. */
|
|
422
|
+
export const firstSeenTreeOf = (data, recipe, platform) => join(harnessesOf(data), ".first-seen", `${recipe.id}@${recipe.release.version}-${platform}.tree.sha256`);
|
|
312
423
|
/** The sha256 the installed binary must have: the recipe's pin, else the first one its install recorded; undefined when it
|
|
313
424
|
* pins none and none was recorded (never installed by the owner's command). */
|
|
314
425
|
export function pinnedDigest(data, recipe, release, platform) {
|
|
@@ -317,16 +428,59 @@ export function pinnedDigest(data, recipe, release, platform) {
|
|
|
317
428
|
const recorded = firstSeenRecord(firstSeenOf(data, recipe, platform)).read();
|
|
318
429
|
return recorded ? { sha256: recorded, by: "first-seen" } : undefined;
|
|
319
430
|
}
|
|
431
|
+
/** The digest every file of the install must have together (treeDigest): the recipe's treeSha256, else the first one its
|
|
432
|
+
* install recorded; undefined when neither is there (an install from before trees were recorded, or none at all). */
|
|
433
|
+
export function pinnedTree(data, recipe, release, platform) {
|
|
434
|
+
if (release.treeSha256)
|
|
435
|
+
return { sha256: release.treeSha256, by: "recipe" };
|
|
436
|
+
const recorded = firstSeenRecord(firstSeenTreeOf(data, recipe, platform)).read();
|
|
437
|
+
return recorded ? { sha256: recorded, by: "first-seen" } : undefined;
|
|
438
|
+
}
|
|
439
|
+
/** The folder the agent keeps its owner's sign-in in (given by signIn.homeArg on `agentrun harness sign-in` and on every
|
|
440
|
+
* run on that sign-in): `<data>/harnesses/<id>.sign-in`, 0700, beside the install and never inside it (a reinstall keeps
|
|
441
|
+
* the sign-in). The agent alone writes and reads what is in it: AgentRun hands it the path, and never lists, opens,
|
|
442
|
+
* copies or sends anything in it. */
|
|
443
|
+
export const signInHomeOf = (data, id) => join(harnessesOf(data), `${id}.sign-in`);
|
|
444
|
+
/** AgentRun's own note that the agent's sign-in ended well (its exit status 0), beside the folder and never in it:
|
|
445
|
+
* `<data>/harnesses/<id>.signed-in`, holding when and on which version. It holds nothing of the sign-in. */
|
|
446
|
+
export const signedInNoteOf = (data, id) => join(harnessesOf(data), `${id}.signed-in`);
|
|
447
|
+
/** The owner's command that signs the recipe at `file` in, on `data`. */
|
|
448
|
+
export const recipeSignInLine = (file, data, env = process.env) => `agentrun harness sign-in --recipe ${shellWord(file)}${resolve(data) === commandData(env) ? "" : ` --data ${shellWord(data)}`}`;
|
|
449
|
+
/** Whether the agent's own sign-in ended well on `data` (signedInNoteOf): nothing in its folder is read to say so.
|
|
450
|
+
* Whether the sign-in still holds is the agent's to say when it runs (an ACP -32000, Authentication required). */
|
|
451
|
+
export const signedIn = (data, recipe) => recipe.signIn !== undefined && existsSync(signedInNoteOf(data, recipe.id));
|
|
452
|
+
/** AgentRun's own note of the last harness-check that passed for the recipe `id` on `data`: `<data>/harnesses/<id>.checked`,
|
|
453
|
+
* beside the install and never in it. */
|
|
454
|
+
export const checkedNoteOf = (data, id) => join(harnessesOf(data), `${id}.checked`);
|
|
455
|
+
/** Writes the note of a passing check (checkedNoteOf), over the one before it: open to its owner alone. */
|
|
456
|
+
export function writeChecked(data, id, checked) {
|
|
457
|
+
mkdirSync(harnessesOf(data), { recursive: true, mode: 0o700 });
|
|
458
|
+
writeFileSync(checkedNoteOf(data, id), `${JSON.stringify({ ...checked, at: new Date().toISOString() })}\n`, { mode: 0o600 });
|
|
459
|
+
}
|
|
460
|
+
/** The note of the last check that passed for `id` on `data`, or undefined where there is none or it is not one. */
|
|
461
|
+
export function checkedOf(data, id) {
|
|
462
|
+
try {
|
|
463
|
+
const note = JSON.parse(readFileSync(checkedNoteOf(data, id), "utf8"));
|
|
464
|
+
const fields = ["recipe", "binary", "tree", "version", "platform"];
|
|
465
|
+
return fields.every((field) => typeof note[field] === "string") ? Object.fromEntries(fields.map((field) => [field, note[field]])) : undefined;
|
|
466
|
+
}
|
|
467
|
+
catch {
|
|
468
|
+
return undefined;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
320
471
|
/** Installs the recipe's release into `<data>/harnesses/<id>` (the owner's command, rule 4): its archive downloaded and
|
|
321
472
|
* checked against the recipe's sha256, unpacked, and its binary checked against the recipe's pin, or recorded as the
|
|
322
|
-
* first one seen where the recipe pins none (a later one that differs is refused).
|
|
473
|
+
* first one seen where the recipe pins none (a later one that differs is refused). Every file beside it the same way: the
|
|
474
|
+
* recipe's treeSha256, else the first tree digest recorded, so nothing in the archive runs unpinned. */
|
|
323
475
|
export async function installRecipe(recipe, file, data, options = {}, env = process.env) {
|
|
324
476
|
const platform = options.platform ?? archivePlatform();
|
|
325
477
|
const release = releaseFor(recipe, platform);
|
|
326
478
|
const record = platform ? firstSeenRecord(firstSeenOf(data, recipe, platform)) : undefined;
|
|
327
479
|
const binary = release && !release.binarySha256 && record ? { binaryRecord: record } : {};
|
|
480
|
+
const acp = acpPackage();
|
|
481
|
+
const trees = release && !release.treeSha256 && platform && acp ? { treeRecord: firstSeenRecord(firstSeenTreeOf(data, recipe, platform)) } : {};
|
|
328
482
|
const before = release && !release.binarySha256 ? record?.read() : undefined;
|
|
329
|
-
const done = await installArchive({ id: recipe.id, label: recipe.label, retry: recipeInstallLine(file, data, env), pin: { version: recipe.release.version, archives: recipe.release.archives } }, installDirOf(data, recipe.id), { ...options, ...binary });
|
|
483
|
+
const done = await installArchive({ id: recipe.id, label: recipe.label, retry: recipeInstallLine(file, data, env), pin: { version: recipe.release.version, archives: recipe.release.archives }, ...(acp ? { tree: (root) => acp.treeDigest(root) } : {}) }, installDirOf(data, recipe.id), { ...options, ...binary, ...trees });
|
|
330
484
|
// What the binary was held to: the recipe's pin, the first digest an earlier install recorded, or this one's, recorded now.
|
|
331
485
|
const pinnedBy = release?.binarySha256 ? "recipe" : before ? "first-seen" : "recorded";
|
|
332
486
|
return { version: recipe.release.version, pinnedBy, ...done };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** A recipe with no signIn: it runs on its keys alone, and has nothing to sign in. */
|
|
2
|
+
export declare const HARNESS_NO_SIGN_IN = "HARNESS_NO_SIGN_IN";
|
|
3
|
+
/** The agent's own sign-in did not end well: its exit status, a signal, or the time ran out. */
|
|
4
|
+
export declare const HARNESS_SIGN_IN_FAILED = "HARNESS_SIGN_IN_FAILED";
|
|
5
|
+
/** How long the person has to sign in. */
|
|
6
|
+
export declare const SIGN_IN_MS: number;
|
|
7
|
+
/** The one line each sign-in says first: a person's own sign-in used through AgentRun may be outside what its vendor's
|
|
8
|
+
* terms (the recipe's signIn.terms) cover, and the choice is theirs. A warning, never a refusal. */
|
|
9
|
+
export declare const signInWarning: (label: string, terms: string | undefined) => string;
|
|
10
|
+
export interface SignInHarnessOptions {
|
|
11
|
+
recipe: string;
|
|
12
|
+
data: string;
|
|
13
|
+
/** The environment the agent's allowlist (PATH, LANG, TZ) is read from; nothing else of it reaches the agent. */
|
|
14
|
+
env: NodeJS.ProcessEnv;
|
|
15
|
+
platform?: string;
|
|
16
|
+
/** Hears what this command says to the person (never anything the agent printed). */
|
|
17
|
+
say?: (line: string) => void;
|
|
18
|
+
/** For tests: how long the person has. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Signs the recipe's agent in: `{ ok: true, home }`, or `{ ok: false, code, message }` with the command's own words. */
|
|
22
|
+
export declare function signInHarness(options: SignInHarnessOptions): Promise<{
|
|
23
|
+
ok: true;
|
|
24
|
+
home: string;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
code: string;
|
|
28
|
+
message: string;
|
|
29
|
+
}>;
|