@parcha/agentrun-serve 0.1.0-beta.55 → 0.1.0-beta.57
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 +261 -0
- package/README.md +228 -45
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +18 -5
- package/dist/adapters.js +23 -9
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/answer-json.d.ts +6 -2
- package/dist/answer-json.js +22 -4
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +17 -5
- package/dist/api-only.js +36 -8
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/calendar/tools.js +3 -2
- package/dist/chatgpt-plan.d.ts +28 -3
- package/dist/chatgpt-plan.js +182 -21
- package/dist/claude-login.d.ts +101 -14
- package/dist/claude-login.js +232 -49
- package/dist/claude-sign-in.d.ts +46 -0
- package/dist/claude-sign-in.js +93 -0
- package/dist/cli.js +63 -6
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/console/assets/{backend-D5EmB4N3.js → backend-DVhHzJX2.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-okP-y8PK.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +10 -0
- package/dist/env-switch.js +33 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +58 -20
- package/dist/fal-price.js +341 -82
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/host-check.d.ts +4 -0
- package/dist/host-check.js +4 -0
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +26 -5
- package/dist/key-refusal.js +313 -37
- package/dist/learn/secrets.d.ts +31 -11
- package/dist/learn/secrets.js +152 -191
- package/dist/learning-cost.d.ts +6 -3
- package/dist/learning-cost.js +4 -2
- package/dist/link-check.js +1 -1
- package/dist/llms.txt +2 -2
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +30 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +5 -2
- package/dist/model.js +9 -5
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.d.ts +3 -3
- package/dist/openapi.js +245 -42
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +14 -6
- package/dist/place-offers.js +26 -13
- package/dist/provider.d.ts +9 -0
- package/dist/provider.js +50 -3
- package/dist/redact/match.d.ts +101 -0
- package/dist/redact/match.js +1152 -0
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +2 -0
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +3 -1
- package/dist/run-timeline-served.js +4 -4
- package/dist/run-usage.d.ts +1 -0
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +14 -0
- package/dist/runner/adapter-loop.js +56 -11
- package/dist/runner/adapter-run-spec.d.ts +45 -8
- package/dist/runner/adapter-run-spec.js +154 -29
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.js +11 -6
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +18 -3
- package/dist/runner/claim-secrets.js +35 -6
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +85 -36
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +11 -5
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.js +15 -6
- package/dist/runner/mcp-claim.js +30 -3
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +12 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +4 -3
- package/dist/runner/presence.js +4 -2
- package/dist/runner/run-child-host.d.ts +5 -0
- package/dist/runner/run-child-host.js +71 -30
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +18 -3
- package/dist/runner/runner.js +162 -36
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.js +4 -40
- package/dist/runner/workflow-first.d.ts +11 -4
- package/dist/runner/workflow-first.js +14 -8
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +57 -13
- package/dist/server.js +371 -113
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- 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/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/dialect.js +3 -0
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/schema.d.ts +6 -0
- package/dist/store/schema.js +11 -1
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +1 -1
- package/dist/store/sqlite/run-patch.js +13 -4
- package/dist/store/sqlite/store.js +76 -16
- package/dist/store/store.d.ts +53 -3
- package/dist/store/store.js +27 -0
- package/dist/store-reads/learning.d.ts +6 -3
- package/dist/store-reads/learning.js +22 -7
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +4 -4
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +22 -11
- package/dist/template-eval.js +124 -41
- package/dist/template-import.d.ts +10 -0
- package/dist/template-import.js +16 -7
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +17 -7
- package/dist/timeline/timeline.js +28 -14
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +26 -9
- package/dist/timeline/web-calls.js +124 -37
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +69 -6
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/validate.js +1 -1
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +6 -4
- package/dist/web-save.js +9 -12
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/computer-deps.d.ts +3 -1
- package/dist/workspace/computer-deps.js +12 -4
- package/dist/workspace/computer-for-claim.d.ts +19 -2
- package/dist/workspace/computer-for-claim.js +101 -13
- package/dist/workspace/computer-janitor.d.ts +15 -7
- package/dist/workspace/computer-janitor.js +33 -8
- package/dist/workspace/computer-kept.d.ts +55 -4
- package/dist/workspace/computer-kept.js +129 -8
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/run-end-computers.d.ts +5 -1
- package/dist/workspace/run-end-computers.js +27 -1
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +65 -0
- package/dist/wrapped.js +77 -0
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +38 -15
- package/dist/console/assets/index-DUYLaqiR.js +0 -746
- package/dist/console/assets/index-DYhU4adm.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
package/dist/handed-values.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Handed, type SignInReader } from "./run-view.js";
|
|
2
2
|
import { type RunLaunch } from "./run-launch.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RunRow, type Store } from "./store/store.js";
|
|
4
4
|
/** The run's launch body read back, or undefined when it has none (an old run, or one not started with one). */
|
|
5
5
|
export declare function launchOf(store: Pick<Store, "runs">, runId: string): Promise<RunLaunch | undefined>;
|
|
6
6
|
/** The pointers a run was handed, as its row kept them (never the pointers, their SHA-256), read by the one rule a
|
|
@@ -21,9 +21,51 @@ export declare function handedValuesOf(deps: {
|
|
|
21
21
|
}): Promise<{
|
|
22
22
|
refs: string[];
|
|
23
23
|
} | "unreadable">;
|
|
24
|
+
/** Run `runId`'s launch row as a cut reads it: its body, its sealed part (null when it holds none) and its census (null when
|
|
25
|
+
* no end erased a sealed part). A run with no launch row (one started before launch rows) holds neither; a read that fails
|
|
26
|
+
* is `unreadable`, so the run is withheld, never cut of a shorter set. */
|
|
27
|
+
export declare function launchRowOf(store: Pick<Store, "runs">, runId: string): Promise<{
|
|
28
|
+
readonly body: RunLaunch | undefined;
|
|
29
|
+
readonly sealed: Uint8Array | null;
|
|
30
|
+
readonly census: string | null;
|
|
31
|
+
} | "unreadable">;
|
|
32
|
+
/** What run `runId`'s launch holds sealed now (`sealed`: its caller's MCP credentials, its own model key and tool keys),
|
|
33
|
+
* opened with this server's `sealKey`: each value as the runner's own cut lists it (runner/store-secrets.ts
|
|
34
|
+
* launchSecrets), in every spelling the server's list has (ServerSecrets), each at least MIN_SECRET long. None when it
|
|
35
|
+
* holds none (none handed, or its end erased them); `unreadable` when its bytes don't open here (no seal key, another
|
|
36
|
+
* key, damaged): what the run was handed can't be known, so it is withheld. */
|
|
37
|
+
export declare function launchValuesOf(sealKey: Buffer | undefined, runId: string, sealed: Uint8Array | null): string[] | "unreadable";
|
|
38
|
+
/** Every value a launch's sealed JSON `plain` holds, as a cut lists them: each as the runner's own cut lists it
|
|
39
|
+
* (runner/store-secrets.ts launchSecrets), in every spelling the server's list has (ServerSecrets), each at least
|
|
40
|
+
* MIN_SECRET long. */
|
|
41
|
+
export declare function launchValuesIn(plain: string): string[];
|
|
42
|
+
/** Each value the launch secrets `before` hold (their `retired` too) that `after` no longer hold, as the runner's cut
|
|
43
|
+
* lists them (launchSecrets): what a message's seal keeps as `retired` (store/seal.ts RunLaunchSecrets), so a value it
|
|
44
|
+
* replaced mid-turn is still cut, live and in the end's census. */
|
|
45
|
+
export declare function retiredValues(before: object, after: object): string[];
|
|
46
|
+
/** The most values a launch keeps as `retired` in one turn. A message past it seals none and marks the launch `lost`
|
|
47
|
+
* instead (store/seal.ts RunLaunchSecrets), so the run is withheld until its end, never cut of fewer values than it held. */
|
|
48
|
+
export declare const RETIRED_MAX = 256;
|
|
49
|
+
/** The values a start or a message hands (`mcp_auth`, `model_key`, `keys`: server.ts Handed), as launchValuesIn lists
|
|
50
|
+
* them from the launch they are sealed in. None when it hands none. */
|
|
51
|
+
export declare function handedSecretValues(handed: {
|
|
52
|
+
readonly mcp?: unknown;
|
|
53
|
+
readonly model?: string;
|
|
54
|
+
readonly keys?: Readonly<Record<string, string>>;
|
|
55
|
+
}): string[];
|
|
56
|
+
/** `value` with every string in it cut of `values` alone (each in every form redactSecrets finds it, learn/secrets.ts
|
|
57
|
+
* heldSpans; a string where one still shows in another form is "[redacted]" whole), and nothing else changed: no secret
|
|
58
|
+
* shape is cut, no length blanks it. What the server writes of a start or a message (its input, which a run's title is
|
|
59
|
+
* read from, its text) is cut so of what that start or message hands, so no read after the run's end erased those
|
|
60
|
+
* values (when no cut holds them) shows them. Its names are left as they are. */
|
|
61
|
+
export declare function cutHanded<T>(value: T, values: readonly string[]): T;
|
|
24
62
|
/** Why what an agent learned is withheld (403): a pointer of its sign-in can't be read here, so the cut would be shorter
|
|
25
63
|
* than what a note may hold. */
|
|
26
64
|
export declare const WITHHELD_LEARNING = "This server can't read the agent's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so what it learned is not shown.";
|
|
65
|
+
/** Why a message to a run whose launch's sealed part doesn't open here is refused (409 not_continuable, reason withheld;
|
|
66
|
+
* a trigger's firing skips with these words): it can't be cut of what the run was handed, and once the run's end
|
|
67
|
+
* erases those values, written uncut it would show them. */
|
|
68
|
+
export declare const WITHHELD_MESSAGE = "This server can't read back what this run was handed (its seal key changed or is missing, or what was sealed is damaged), so a message to it can't be cut of those values and was not written. Start a new run of the agent.";
|
|
27
69
|
/** Every sign-in pointer agent `agentId` ever held, live and forgotten (the store keeps every forgotten one, never only
|
|
28
70
|
* the newest), at each vendor that keeps one (each at least MIN_SECRET long, as every cut takes them): what the learning
|
|
29
71
|
* routes cut beside the server's secrets, so a note, a skill or a run's learning that wrote one never shows it. `unreadable` when one does not open under this server's key, or a read
|
package/dist/handed-values.js
CHANGED
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
// mark (the SHA-256 of each pointer, never the pointer), the browser vendor its launch's plane kept, and the agent's
|
|
3
3
|
// sign-ins (live and forgotten) opened to find each pointer the mark names (run-view.ts handedPointers). One read for
|
|
4
4
|
// every place that must cut a run of what it was handed: the store-backed run view (store-view.ts) and the runner's
|
|
5
|
-
// learning end (runner/learning-end.ts), which refuses to learn it.
|
|
6
|
-
|
|
5
|
+
// learning end (runner/learning-end.ts), which refuses to learn it. Beside them, what the run's caller handed it at its
|
|
6
|
+
// launch or with a message (its MCP credentials, its own model key and tool keys: store/seal.ts RunLaunchSecrets), opened
|
|
7
|
+
// from the launch's sealed part while the run holds it (launchValuesOf), and once its end erased that, where in its files
|
|
8
|
+
// they sat (the launch's census, run-census.ts).
|
|
9
|
+
import { heldSpans, MIN_SECRET } from "./learn/secrets.js";
|
|
10
|
+
import { launchSecrets } from "./runner/store-secrets.js";
|
|
11
|
+
import { ServerSecrets } from "./server-secrets.js";
|
|
12
|
+
import { sealedAt, unsealColumn } from "./store/seal.js";
|
|
7
13
|
import { handedMark, handedPointers } from "./run-view.js";
|
|
8
14
|
import { readLaunchBody } from "./run-launch.js";
|
|
15
|
+
import { StoreLaunchMissing } from "./store/store.js";
|
|
9
16
|
import { keptVendor } from "./tool-plane.js";
|
|
10
17
|
/** The run's launch body read back, or undefined when it has none (an old run, or one not started with one). */
|
|
11
18
|
export async function launchOf(store, runId) {
|
|
@@ -35,11 +42,121 @@ export async function handedValuesOf(deps, store, runId, known) {
|
|
|
35
42
|
const browser = launch?.plane ? keptVendor(launch.plane).browser : undefined;
|
|
36
43
|
return handedPointers(deps.signIns, runRow.agentId, browser, handedOf(runRow));
|
|
37
44
|
}
|
|
45
|
+
/** Run `runId`'s launch row as a cut reads it: its body, its sealed part (null when it holds none) and its census (null when
|
|
46
|
+
* no end erased a sealed part). A run with no launch row (one started before launch rows) holds neither; a read that fails
|
|
47
|
+
* is `unreadable`, so the run is withheld, never cut of a shorter set. */
|
|
48
|
+
export async function launchRowOf(store, runId) {
|
|
49
|
+
try {
|
|
50
|
+
const row = await store.runs.launch(runId);
|
|
51
|
+
let body;
|
|
52
|
+
try {
|
|
53
|
+
body = readLaunchBody(row.body);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
body = undefined;
|
|
57
|
+
}
|
|
58
|
+
return { body, sealed: row.sealed, census: row.census };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return error instanceof StoreLaunchMissing ? { body: undefined, sealed: null, census: null } : "unreadable";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** What run `runId`'s launch holds sealed now (`sealed`: its caller's MCP credentials, its own model key and tool keys),
|
|
65
|
+
* opened with this server's `sealKey`: each value as the runner's own cut lists it (runner/store-secrets.ts
|
|
66
|
+
* launchSecrets), in every spelling the server's list has (ServerSecrets), each at least MIN_SECRET long. None when it
|
|
67
|
+
* holds none (none handed, or its end erased them); `unreadable` when its bytes don't open here (no seal key, another
|
|
68
|
+
* key, damaged): what the run was handed can't be known, so it is withheld. */
|
|
69
|
+
export function launchValuesOf(sealKey, runId, sealed) {
|
|
70
|
+
if (sealed === null)
|
|
71
|
+
return [];
|
|
72
|
+
if (!sealKey)
|
|
73
|
+
return "unreadable";
|
|
74
|
+
let plain;
|
|
75
|
+
try {
|
|
76
|
+
plain = unsealColumn(sealKey, sealedAt.runLaunch(runId), sealed).toString("utf8");
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return "unreadable";
|
|
80
|
+
}
|
|
81
|
+
// A message sealed over bytes that did not open here (store/seal.ts RunLaunchSecrets.lost): what they held is unknown.
|
|
82
|
+
if (lostIn(plain))
|
|
83
|
+
return "unreadable";
|
|
84
|
+
return launchValuesIn(plain);
|
|
85
|
+
}
|
|
86
|
+
/** Whether a launch's sealed JSON `plain` says a message sealed over bytes that did not open (RunLaunchSecrets.lost). */
|
|
87
|
+
function lostIn(plain) {
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(plain)?.lost === true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Every value a launch's sealed JSON `plain` holds, as a cut lists them: each as the runner's own cut lists it
|
|
96
|
+
* (runner/store-secrets.ts launchSecrets), in every spelling the server's list has (ServerSecrets), each at least
|
|
97
|
+
* MIN_SECRET long. */
|
|
98
|
+
export function launchValuesIn(plain) {
|
|
99
|
+
const list = new ServerSecrets();
|
|
100
|
+
list.add("handed", () => (plain.trimStart().startsWith("{") ? launchSecrets(plain) : [plain]));
|
|
101
|
+
return list.values().filter((value) => value.length >= MIN_SECRET);
|
|
102
|
+
}
|
|
103
|
+
/** Each value the launch secrets `before` hold (their `retired` too) that `after` no longer hold, as the runner's cut
|
|
104
|
+
* lists them (launchSecrets): what a message's seal keeps as `retired` (store/seal.ts RunLaunchSecrets), so a value it
|
|
105
|
+
* replaced mid-turn is still cut, live and in the end's census. */
|
|
106
|
+
export function retiredValues(before, after) {
|
|
107
|
+
const kept = new Set(launchSecrets(JSON.stringify(after)));
|
|
108
|
+
return [...new Set(launchSecrets(JSON.stringify(before)).filter((value) => !kept.has(value)))];
|
|
109
|
+
}
|
|
110
|
+
/** The most values a launch keeps as `retired` in one turn. A message past it seals none and marks the launch `lost`
|
|
111
|
+
* instead (store/seal.ts RunLaunchSecrets), so the run is withheld until its end, never cut of fewer values than it held. */
|
|
112
|
+
export const RETIRED_MAX = 256;
|
|
113
|
+
/** The values a start or a message hands (`mcp_auth`, `model_key`, `keys`: server.ts Handed), as launchValuesIn lists
|
|
114
|
+
* them from the launch they are sealed in. None when it hands none. */
|
|
115
|
+
export function handedSecretValues(handed) {
|
|
116
|
+
if (handed.mcp === undefined && handed.model === undefined && handed.keys === undefined)
|
|
117
|
+
return [];
|
|
118
|
+
return launchValuesIn(JSON.stringify({ ...(handed.mcp !== undefined ? { mcp: handed.mcp } : {}), ...(handed.model !== undefined ? { model: { key: handed.model } } : {}), ...(handed.keys !== undefined ? { keys: handed.keys } : {}) }));
|
|
119
|
+
}
|
|
120
|
+
/** `value` with every string in it cut of `values` alone (each in every form redactSecrets finds it, learn/secrets.ts
|
|
121
|
+
* heldSpans; a string where one still shows in another form is "[redacted]" whole), and nothing else changed: no secret
|
|
122
|
+
* shape is cut, no length blanks it. What the server writes of a start or a message (its input, which a run's title is
|
|
123
|
+
* read from, its text) is cut so of what that start or message hands, so no read after the run's end erased those
|
|
124
|
+
* values (when no cut holds them) shows them. Its names are left as they are. */
|
|
125
|
+
export function cutHanded(value, values) {
|
|
126
|
+
if (!values.length)
|
|
127
|
+
return value;
|
|
128
|
+
const cutText = (text) => {
|
|
129
|
+
const spans = heldSpans(text, values);
|
|
130
|
+
if (spans === "whole")
|
|
131
|
+
return "[redacted]";
|
|
132
|
+
let out = "";
|
|
133
|
+
let from = 0;
|
|
134
|
+
for (const [start, end] of spans) {
|
|
135
|
+
out += `${text.slice(from, start)}[redacted]`;
|
|
136
|
+
from = end;
|
|
137
|
+
}
|
|
138
|
+
return out + text.slice(from);
|
|
139
|
+
};
|
|
140
|
+
const walk = (one) => {
|
|
141
|
+
if (typeof one === "string")
|
|
142
|
+
return cutText(one);
|
|
143
|
+
if (Array.isArray(one))
|
|
144
|
+
return one.map(walk);
|
|
145
|
+
if (one !== null && typeof one === "object")
|
|
146
|
+
return Object.fromEntries(Object.entries(one).map(([name, inner]) => [name, walk(inner)]));
|
|
147
|
+
return one;
|
|
148
|
+
};
|
|
149
|
+
return walk(value);
|
|
150
|
+
}
|
|
38
151
|
/** The browser vendors that keep a sign-in (sign-ins-store.ts vendorOf). */
|
|
39
152
|
const SIGN_IN_VENDORS = ["browserbase", "kernel"];
|
|
40
153
|
/** Why what an agent learned is withheld (403): a pointer of its sign-in can't be read here, so the cut would be shorter
|
|
41
154
|
* than what a note may hold. */
|
|
42
155
|
export const WITHHELD_LEARNING = "This server can't read the agent's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so what it learned is not shown.";
|
|
156
|
+
/** Why a message to a run whose launch's sealed part doesn't open here is refused (409 not_continuable, reason withheld;
|
|
157
|
+
* a trigger's firing skips with these words): it can't be cut of what the run was handed, and once the run's end
|
|
158
|
+
* erases those values, written uncut it would show them. */
|
|
159
|
+
export const WITHHELD_MESSAGE = "This server can't read back what this run was handed (its seal key changed or is missing, or what was sealed is damaged), so a message to it can't be cut of those values and was not written. Start a new run of the agent.";
|
|
43
160
|
/** Every sign-in pointer agent `agentId` ever held, live and forgotten (the store keeps every forgotten one, never only
|
|
44
161
|
* the newest), at each vendor that keeps one (each at least MIN_SECRET long, as every cut takes them): what the learning
|
|
45
162
|
* routes cut beside the server's secrets, so a note, a skill or a run's learning that wrote one never shows it. `unreadable` when one does not open under this server's key, or a read
|
|
@@ -56,6 +56,14 @@ export declare const ARCHIVE_TIMEOUT_MS: number;
|
|
|
56
56
|
export declare function archivePlatform(platform?: string, arch?: string): string | undefined;
|
|
57
57
|
/** The sha256 of the file at `path`, read a chunk at a time. */
|
|
58
58
|
export declare function digestOf(path: string): Promise<string>;
|
|
59
|
+
/** The first link under `root` (its path from `root`) that leads outside `root`, or to nothing; undefined when none does.
|
|
60
|
+
* The tree digest holds a link by its words, never the bytes it leads to, so a file reached through one (the binary
|
|
61
|
+
* behind a linked folder, code a launcher loads from `lib` linked elsewhere) would be checked by nothing. Each link is
|
|
62
|
+
* resolved by the filesystem (realpath), as opening it would be, never by its words alone: in a chain such as
|
|
63
|
+
* `sub/up -> ..` and `sub/code -> up/../outside`, the `..` is taken after the link before it is followed, so the words
|
|
64
|
+
* read inside while the path leads out. A link that leads to nothing is refused too, since what its last step names
|
|
65
|
+
* could be made outside later. */
|
|
66
|
+
export declare function linkOutOf(root: string): Promise<string | undefined>;
|
|
59
67
|
export interface ArchiveInstallOptions {
|
|
60
68
|
/** The platform, as the registry names it. Default this host's (archivePlatform). */
|
|
61
69
|
platform?: string;
|
|
@@ -69,16 +77,11 @@ export interface ArchiveInstallOptions {
|
|
|
69
77
|
maxBytes?: number;
|
|
70
78
|
/** Hears each step once it holds: `downloaded` (and its digest checked), `unpacked`, `verified` (the binary's digest). */
|
|
71
79
|
onStep?: (step: "downloaded" | "unpacked" | "verified") => void | Promise<void>;
|
|
72
|
-
/** For a release
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
write(sha256: string): void;
|
|
78
|
-
};
|
|
79
|
-
/** For a release with no tree digest pinned (a recipe's): the record of the first tree (every file beside the binary,
|
|
80
|
-
* harness.tree's digest) unpacked from its verified archive, kept as binaryRecord keeps the binary's, so a sidecar
|
|
81
|
-
* that differs is refused (HARNESS_BINARY_MISMATCH) as the binary is. Needs harness.tree. */
|
|
80
|
+
/** For a release with no tree digest pinned (a recipe's, where the registry lists only the archive's): the record of the
|
|
81
|
+
* first tree (every file it unpacks to, the binary among them: harness.tree's digest) unpacked from its verified
|
|
82
|
+
* archive. With none recorded, this install records its tree's; with one, a tree that differs (a binary or a sidecar)
|
|
83
|
+
* is refused (HARNESS_BINARY_MISMATCH). Needs harness.tree. A release that pins neither its binary nor its tree, with
|
|
84
|
+
* no record, is refused. */
|
|
82
85
|
treeRecord?: {
|
|
83
86
|
read(): string | undefined;
|
|
84
87
|
write(sha256: string): void;
|
package/dist/harness-archive.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// repository carries none. A zip (Google Antigravity's) is unpacked by node itself (harness-zip.ts), no tool needed;
|
|
11
11
|
// - the binary's sha256 is checked there against the pin, and where the pin holds one the digest of every file beside
|
|
12
12
|
// it (Cursor's launcher runs its own node on a hundred files of code; Antigravity's server runs a sidecar), and only
|
|
13
|
-
// then is the folder renamed into place and made read-only. A recipe's release
|
|
14
|
-
//
|
|
13
|
+
// then is the folder renamed into place and made read-only. A recipe's release may pin neither: the first tree
|
|
14
|
+
// unpacked from its verified archive (the binary among it) is recorded, and a later install that differs is refused. What was there
|
|
15
15
|
// before goes aside first, then away;
|
|
16
16
|
// - a crash part way leaves that fresh folder (its name the sweep's) and never a half install: the next install removes it.
|
|
17
17
|
// One install at a time on a data directory, under the hold first-use installs take (takeHold). The installer is handed no
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
20
20
|
import { execFile } from "node:child_process";
|
|
21
21
|
import { createReadStream, createWriteStream, existsSync } from "node:fs";
|
|
22
|
-
import { lstat, mkdir, mkdtemp, rename } from "node:fs/promises";
|
|
23
|
-
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
22
|
+
import { lstat, mkdir, mkdtemp, readdir, realpath, rename } from "node:fs/promises";
|
|
23
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
24
24
|
import { Readable, Transform } from "node:stream";
|
|
25
25
|
import { pipeline } from "node:stream/promises";
|
|
26
26
|
import { leftoverPrefix, releaseHold, removeLeftover, sweepLeftovers, takeHold, writable } from "./harness-install.js";
|
|
@@ -76,6 +76,35 @@ function binaryUnder(root, cmd) {
|
|
|
76
76
|
const inside = relative(root, path);
|
|
77
77
|
return inside && inside !== ".." && !inside.startsWith(`..${sep}`) ? path : undefined;
|
|
78
78
|
}
|
|
79
|
+
/** The first link under `root` (its path from `root`) that leads outside `root`, or to nothing; undefined when none does.
|
|
80
|
+
* The tree digest holds a link by its words, never the bytes it leads to, so a file reached through one (the binary
|
|
81
|
+
* behind a linked folder, code a launcher loads from `lib` linked elsewhere) would be checked by nothing. Each link is
|
|
82
|
+
* resolved by the filesystem (realpath), as opening it would be, never by its words alone: in a chain such as
|
|
83
|
+
* `sub/up -> ..` and `sub/code -> up/../outside`, the `..` is taken after the link before it is followed, so the words
|
|
84
|
+
* read inside while the path leads out. A link that leads to nothing is refused too, since what its last step names
|
|
85
|
+
* could be made outside later. */
|
|
86
|
+
export async function linkOutOf(root) {
|
|
87
|
+
const base = await realpath(resolve(root));
|
|
88
|
+
const within = (path) => path === base || path.startsWith(`${base}${sep}`);
|
|
89
|
+
const walk = async (dir) => {
|
|
90
|
+
for (const name of await readdir(dir)) {
|
|
91
|
+
const path = join(dir, name);
|
|
92
|
+
const entry = await lstat(path);
|
|
93
|
+
if (entry.isSymbolicLink()) {
|
|
94
|
+
const target = await realpath(path).catch(() => undefined);
|
|
95
|
+
if (target === undefined || !within(target))
|
|
96
|
+
return relative(base, path);
|
|
97
|
+
}
|
|
98
|
+
else if (entry.isDirectory()) {
|
|
99
|
+
const found = await walk(path);
|
|
100
|
+
if (found !== undefined)
|
|
101
|
+
return found;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
};
|
|
106
|
+
return walk(base);
|
|
107
|
+
}
|
|
79
108
|
/** Installs `harness` into `dir` (`<data>/harnesses/<id>`) from its pin's archive for this platform: downloaded, checked,
|
|
80
109
|
* unpacked beside `dir`, its binary checked, then renamed into place and made read-only. `already` when the pinned binary
|
|
81
110
|
* is in place (nothing is downloaded); `now` once this install put it there. Rejects with ArchiveInstallFailed, `dir` as it
|
|
@@ -92,27 +121,29 @@ export async function installArchive(harness, dir, options = {}) {
|
|
|
92
121
|
const want = release.sha256 ?? release.sha512;
|
|
93
122
|
if (!want)
|
|
94
123
|
throw fail(ARCHIVE_CODES.platform, `${named}'s archive on ${platform} has no sha256 or sha512 pinned, so it cannot be checked`);
|
|
95
|
-
if (!release.binarySha256 && !options.binaryRecord)
|
|
96
|
-
throw fail(ARCHIVE_CODES.platform, `${named}'s binary on ${platform} has no sha256 pinned, so what its archive unpacks to cannot be checked`);
|
|
97
124
|
const flag = UNPACK[release.format];
|
|
98
125
|
if (!flag || !Object.hasOwn(UNPACK, release.format))
|
|
99
126
|
throw fail(ARCHIVE_CODES.platform, `${named}'s archive on ${platform} is ${release.format}, and this installer unpacks ${ARCHIVE_FORMATS.slice(0, -1).join(", ")} and ${ARCHIVE_FORMATS.at(-1)} alone`);
|
|
100
127
|
const treeRecord = release.treeSha256 ? undefined : options.treeRecord;
|
|
128
|
+
if (!release.binarySha256 && !release.treeSha256 && !treeRecord)
|
|
129
|
+
throw fail(ARCHIVE_CODES.platform, `${named}'s binary on ${platform} has no sha256 pinned, so what its archive unpacks to cannot be checked`);
|
|
101
130
|
if ((release.treeSha256 || treeRecord) && !harness.tree)
|
|
102
131
|
throw fail(ARCHIVE_CODES.platform, `${named}'s files on ${platform} are ${release.treeSha256 ? "pinned" : "recorded"} by a tree digest, and this install was given no way to take one`);
|
|
103
132
|
const binary = binaryUnder(dir, release.cmd);
|
|
104
133
|
if (!binary)
|
|
105
134
|
throw fail(ARCHIVE_CODES.platform, `${named}'s pinned path ${release.cmd} is not inside its folder`);
|
|
106
|
-
// The pin's digests, else the first
|
|
107
|
-
const pinned = release.binarySha256
|
|
135
|
+
// The pin's digests, else the first tree recorded (none before the first install).
|
|
136
|
+
const pinned = release.binarySha256;
|
|
108
137
|
const pinnedTree = release.treeSha256 ?? treeRecord?.read();
|
|
109
|
-
/** Whether the pinned
|
|
110
|
-
* one recorded) where it pins or records one.
|
|
111
|
-
* installed again, and its tree recorded. */
|
|
112
|
-
const inPlace = async () =>
|
|
113
|
-
(!treeRecord || pinnedTree !== undefined) &&
|
|
138
|
+
/** Whether the pinned install is in place: a binary there, its sha256 the pin's where it pins one, in a folder whose
|
|
139
|
+
* tree is the pin's (or the one recorded) where it pins or records one. One whose tree is to be recorded and is not
|
|
140
|
+
* yet (a recipe's install from before trees were recorded) is installed again, and its tree recorded. */
|
|
141
|
+
const inPlace = async () => (!treeRecord || pinnedTree !== undefined) &&
|
|
114
142
|
(await lstat(binary).catch(() => undefined)) !== undefined &&
|
|
115
|
-
|
|
143
|
+
// One placed before links out were refused is installed again, where the unpack's own check says why, never
|
|
144
|
+
// "already" (which every start would then refuse).
|
|
145
|
+
(await linkOutOf(dir).catch(() => "unreadable")) === undefined &&
|
|
146
|
+
(pinned === undefined || (await digestOf(binary).catch(() => undefined)) === pinned) &&
|
|
116
147
|
(pinnedTree === undefined || (await harness.tree(dir).catch(() => undefined)) === pinnedTree);
|
|
117
148
|
if (await inPlace())
|
|
118
149
|
return { installed: "already", binary };
|
|
@@ -163,8 +194,10 @@ export async function installArchive(harness, dir, options = {}) {
|
|
|
163
194
|
if (got !== want)
|
|
164
195
|
throw fail(ARCHIVE_CODES.archive, `${named}'s archive from ${release.url} has ${algorithm} ${got}, and the pin is ${want}; it was not unpacked`);
|
|
165
196
|
await options.onStep?.("downloaded");
|
|
166
|
-
// Unpacked, verified archive only, into a folder of its own inside the fresh one: a zip by node, a tarball by tar.
|
|
167
|
-
|
|
197
|
+
// Unpacked, verified archive only, into a folder of its own inside the fresh one: a zip by node, a tarball by tar. It
|
|
198
|
+
// takes the name the install's folder has, so a link is read (linkOutOf) where it leads once renamed into place: a
|
|
199
|
+
// link `a -> ../tree/b` would lead inside a folder named tree and outside the installed one.
|
|
200
|
+
const tree = join(work, basename(dir));
|
|
168
201
|
await mkdir(tree);
|
|
169
202
|
if (release.format === "zip") {
|
|
170
203
|
try {
|
|
@@ -191,25 +224,18 @@ export async function installArchive(harness, dir, options = {}) {
|
|
|
191
224
|
const found = await lstat(unpacked).catch(() => undefined);
|
|
192
225
|
if (!found?.isFile())
|
|
193
226
|
throw fail(ARCHIVE_CODES.unpack, `${named}'s archive holds no file at ${release.cmd}`);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (error?.code !== "EEXIST")
|
|
203
|
-
throw error;
|
|
204
|
-
const first = options.binaryRecord.read();
|
|
205
|
-
if (first !== binarySha)
|
|
206
|
-
throw fail(ARCHIVE_CODES.binary, `${named}'s binary from its archive has sha256 ${binarySha}, and the first one recorded is ${first}; it was not put in place`);
|
|
207
|
-
}
|
|
227
|
+
// A link out of the tree anywhere in it (on the binary's path, or to code the binary loads): refused (linkOutOf).
|
|
228
|
+
const outward = await linkOutOf(tree);
|
|
229
|
+
if (outward !== undefined)
|
|
230
|
+
throw fail(ARCHIVE_CODES.unpack, `${named}'s archive holds a link out of its files (${outward}), so what it leads to would be checked by nothing; it was not put in place`);
|
|
231
|
+
if (pinned !== undefined) {
|
|
232
|
+
const binarySha = await digestOf(unpacked);
|
|
233
|
+
if (binarySha !== pinned)
|
|
234
|
+
throw fail(ARCHIVE_CODES.binary, `${named}'s binary from its archive has sha256 ${binarySha}, and the pin is ${pinned}; it was not put in place`);
|
|
208
235
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
//
|
|
212
|
-
// sidecar, is as much the harness as the binary.
|
|
236
|
+
// Every file it unpacked to, where the pin holds their digest or a record keeps the first (a record another install
|
|
237
|
+
// wrote first holds): a launcher's code, or a server's sidecar, is as much the harness as the binary, which is among
|
|
238
|
+
// them.
|
|
213
239
|
if (release.treeSha256 || treeRecord) {
|
|
214
240
|
const treeSha = await harness.tree(tree);
|
|
215
241
|
let first = pinnedTree;
|
package/dist/harness-check.d.ts
CHANGED
|
@@ -38,9 +38,11 @@ export interface HarnessCheckReport {
|
|
|
38
38
|
};
|
|
39
39
|
platform?: string;
|
|
40
40
|
model?: string;
|
|
41
|
+
/** The installed binary, and the tree digest it and every file beside it were held to: the recipe's or the first one
|
|
42
|
+
* its install recorded. */
|
|
41
43
|
binary?: {
|
|
42
44
|
path: string;
|
|
43
|
-
|
|
45
|
+
tree: string;
|
|
44
46
|
pinnedBy: "recipe" | "first-seen";
|
|
45
47
|
};
|
|
46
48
|
stage2?: Record<string, Check>;
|
package/dist/harness-check.js
CHANGED
|
@@ -15,17 +15,15 @@
|
|
|
15
15
|
// The check spends: four short turns on the run's model, under a cap (default $0.25).
|
|
16
16
|
import { spawnSync } from "node:child_process";
|
|
17
17
|
import { randomBytes } from "node:crypto";
|
|
18
|
-
import {
|
|
18
|
+
import { readFileSync } from "node:fs";
|
|
19
19
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
20
20
|
import { tmpdir } from "node:os";
|
|
21
21
|
import { join } from "node:path";
|
|
22
22
|
import { modelPortFor, SessionFenced } from "@parcha/agentrun-kernel";
|
|
23
23
|
import { beforeRequestOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
24
|
-
import {
|
|
25
|
-
import { ARCHIVE_CODES, archivePlatform, digestOf } from "./harness-archive.js";
|
|
24
|
+
import { archivePlatform } from "./harness-archive.js";
|
|
26
25
|
import { egressProxy, egressVars } from "./harness-egress.js";
|
|
27
|
-
import {
|
|
28
|
-
import { AGENT_VARS, loadRecipe, pinnedDigest, pinnedTree, recipeBinaryOf, recipeInstallLine, RecipeRefused, releaseFor, writeChecked } from "./harness-recipe.js";
|
|
26
|
+
import { AGENT_VARS, installHolds, loadRecipe, recipeInstall, RecipeRefused, writeChecked } from "./harness-recipe.js";
|
|
29
27
|
import { recipeEntryOf } from "./harness-recipe-entry.js";
|
|
30
28
|
import { providerModels } from "./model.js";
|
|
31
29
|
import { capModelOf } from "./runner/cli-run-spec.js";
|
|
@@ -160,34 +158,17 @@ async function checkRun(options, held) {
|
|
|
160
158
|
// A check never runs on its owner's own sign-in, which a schedule, a check and a shared server never take
|
|
161
159
|
// (HARNESS.md#sign-in): a plan-billed recipe whose key is not set here is refused before its agent starts.
|
|
162
160
|
const route = { on: "keys" };
|
|
163
|
-
// Stage 2's pins:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
return refuse(
|
|
173
|
-
|
|
174
|
-
if (found !== pin.sha256)
|
|
175
|
-
return refuse(ARCHIVE_CODES.binary, `${binary} has sha256 ${found ?? "(unreadable)"}, and ${pin.by === "recipe" ? "the recipe pins" : "its first install recorded"} ${pin.sha256}. Install it again with: ${line}`);
|
|
176
|
-
say(`${recipe.label}: the binary is the pinned one (${pin.by === "recipe" ? "the recipe's sha256" : "the first sha256 its install recorded"})`);
|
|
177
|
-
const acp = acpPackage();
|
|
178
|
-
if (!acp)
|
|
179
|
-
return refuse("HARNESS_NOT_INSTALLED", `the ACP adapter (${ACP_PACKAGE}) is not installed beside this server`);
|
|
180
|
-
// Every file beside the binary (a launcher's code, a server's sidecar): the recipe's treeSha256, else the tree its
|
|
181
|
-
// install recorded. One installed before trees were recorded is installed again, so nothing in it runs unpinned.
|
|
182
|
-
const installed = installDirOf(options.data, recipe.id);
|
|
183
|
-
const treePin = pinnedTree(options.data, recipe, release, platform);
|
|
184
|
-
if (!treePin)
|
|
185
|
-
return refuse("HARNESS_NOT_INSTALLED", `${recipe.label} ${recipe.release.version}'s files beside its binary were never recorded by its install, so they cannot be checked. Install it again with: ${line}`);
|
|
186
|
-
const treeNow = async () => acp.treeDigest(installed).catch(() => undefined);
|
|
187
|
-
const treeFound = await treeNow();
|
|
188
|
-
if (treeFound !== treePin.sha256)
|
|
189
|
-
return refuse(ARCHIVE_CODES.binary, `${installed} has the tree sha256 ${treeFound ?? "(unreadable)"}, and ${treePin.by === "recipe" ? "the recipe pins" : "its first install recorded"} ${treePin.sha256}. Install it again with: ${line}`);
|
|
190
|
-
say(`${recipe.label}: every file beside the binary is the pinned tree (${treePin.by === "recipe" ? "the recipe's treeSha256" : "the tree its install recorded"})`);
|
|
161
|
+
// Stage 2's pins: every file the owner's install put there, the binary among them, the recipe's treeSha256 or the tree
|
|
162
|
+
// its install recorded (recipeInstall). Nothing is downloaded here; one installed before trees were recorded is
|
|
163
|
+
// installed again, so nothing in it runs unpinned.
|
|
164
|
+
const install = recipeInstall(options.data, recipe, loaded.file, options.env, options.platform ?? archivePlatform());
|
|
165
|
+
if ("code" in install)
|
|
166
|
+
return refuse(install.code, install.message);
|
|
167
|
+
const { platform, release, binary } = install;
|
|
168
|
+
const off = await installHolds(install);
|
|
169
|
+
if (off)
|
|
170
|
+
return refuse(off.code, off.message);
|
|
171
|
+
say(`${recipe.label}: the binary and every file beside it are the pinned tree (${install.tree.by === "recipe" ? "the recipe's treeSha256" : "the tree its install recorded"})`);
|
|
191
172
|
// The run's model, for a recipe billed through the proxy: named here; its key, the login refusal and its price are its
|
|
192
173
|
// entry's (below), as a server's are.
|
|
193
174
|
const env = options.env;
|
|
@@ -248,16 +229,14 @@ async function checkRun(options, held) {
|
|
|
248
229
|
const modelVar = recipe.model.billing === "proxy" ? recipe.model.env : undefined;
|
|
249
230
|
// The plan's model, where the recipe names one: chosen among those the agent lists (session/set_model).
|
|
250
231
|
const planModel = recipe.model.billing === "plan" ? recipe.model.id : undefined;
|
|
251
|
-
|
|
252
|
-
//
|
|
232
|
+
// Each start of the agent's process checks the pin again (installHolds): a binary or a file beside it swapped after the
|
|
233
|
+
// check began never runs. `starts`: the starts that held.
|
|
234
|
+
let starts = 0;
|
|
253
235
|
const beforeStart = async (command) => {
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const tree = await treeNow();
|
|
259
|
-
if (tree !== treePin.sha256)
|
|
260
|
-
throw new Error(`${ARCHIVE_CODES.binary}: the files beside ${command} changed after the check began (tree sha256 ${tree ?? "(unreadable)"})`);
|
|
236
|
+
const off = await installHolds(install);
|
|
237
|
+
if (off)
|
|
238
|
+
throw new Error(`${off.code}: ${command} or a file beside it changed after the check began: ${off.message}`);
|
|
239
|
+
starts += 1;
|
|
261
240
|
};
|
|
262
241
|
// The recipe's entry as a server builds it (harness-recipe-entry.ts), on this check's route, log, variables (its egress
|
|
263
242
|
// proxy) and recording fetch.
|
|
@@ -390,7 +369,7 @@ async function checkRun(options, held) {
|
|
|
390
369
|
stage2.limits = { ok: true, billing: "plan", maxTurns: recipe.model.maxTurns, maxToolCalls: recipe.model.maxToolCalls, why: "the adapter stops the run at these; the vendor bills the owner's plan" };
|
|
391
370
|
await other.session.close();
|
|
392
371
|
// Stage 2: the pin held at every start; no side request.
|
|
393
|
-
stage2.pins = { ok: starts
|
|
372
|
+
stage2.pins = { ok: starts > 0, binary, tree: install.tree.sha256, pinnedBy: install.tree.by, archiveSha256: release.sha256, starts };
|
|
394
373
|
if (recipe.model.billing === "proxy") {
|
|
395
374
|
const paths = [...new Set(forwarded.map((r) => `${r.method} ${r.path}`))];
|
|
396
375
|
// What the agent asked the proxy for beyond the Messages route: refused there, never sent on.
|
|
@@ -420,15 +399,15 @@ async function checkRun(options, held) {
|
|
|
420
399
|
if (!(name in stage3) && !failures.some((f) => f.startsWith("the check stopped")))
|
|
421
400
|
failures.push(`stage3.${name} did not run`);
|
|
422
401
|
// A pass is noted on the data directory, by digest, for a server that names the recipe (harness-recipe-entry.ts
|
|
423
|
-
// recipeServerEntry): it runs this recipe
|
|
402
|
+
// recipeServerEntry): it runs this recipe and this install's tree, and no other.
|
|
424
403
|
if (failures.length === 0)
|
|
425
|
-
writeChecked(options.data, recipe.id, { recipe: loaded.sha256,
|
|
404
|
+
writeChecked(options.data, recipe.id, { recipe: loaded.sha256, tree: install.tree.sha256, platform });
|
|
426
405
|
return {
|
|
427
406
|
ok: failures.length === 0,
|
|
428
407
|
...head,
|
|
429
408
|
platform,
|
|
430
409
|
...(options.model ? { model: options.model } : {}),
|
|
431
|
-
binary: { path: binary,
|
|
410
|
+
binary: { path: binary, tree: install.tree.sha256, pinnedBy: install.tree.by },
|
|
432
411
|
stage2,
|
|
433
412
|
stage3,
|
|
434
413
|
facts: { resume: resumeFact, tool_gate: asked().length > 0 ? "permission" : "config", billing: recipe.model.billing },
|