@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/harness-keys.d.ts
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
|
+
import { HARNESS_KEY_REENTER } from "./server-keys.js";
|
|
1
2
|
import type { PlanRecipe } from "./harness-table.js";
|
|
2
3
|
import { type SecretMeta } from "./secret-writes.js";
|
|
3
|
-
import { type SealedKeys } from "./store/index.js";
|
|
4
|
+
import { type SealedKeys, type Settings } from "./store/index.js";
|
|
4
5
|
/** The console's page for these keys (Settings → Harness keys). */
|
|
5
6
|
export declare const HARNESS_KEYS_PAGE = "/#/settings/harness-keys";
|
|
6
7
|
/** The plane of a harness key's name (its row's, and its view's: harness:<harness>:<KEY>). */
|
|
7
8
|
export declare const HARNESS_KEY_PLANE = "harness";
|
|
8
9
|
/** How many replaced or removed values of one key stay sealed for the cut: the oldest beyond it leaves. */
|
|
9
10
|
export declare const RETIRED_KEPT = 8;
|
|
11
|
+
/** The settings row each current key row's binding is kept in: { v: 1, rows: { <row>: { seal, recipe, sealed } } }, `seal`
|
|
12
|
+
* the fingerprint of the seal key it was sealed under (server-keys.ts sealFingerprint), `recipe` the sha256 of the recipe
|
|
13
|
+
* file it was saved for (PlanRecipe.digest), `sealed` the sha256 of the sealed bytes written with it (sealedDigest). */
|
|
14
|
+
export declare const HARNESS_KEY_BINDS = "harness-keys";
|
|
10
15
|
/** The row (and view) name of `key` saved for `harness`. */
|
|
11
16
|
export declare const harnessKeyRow: (harness: string, key: string) => string;
|
|
17
|
+
export { HARNESS_KEY_REENTER };
|
|
18
|
+
export type HarnessKeyWhy = (typeof HARNESS_KEY_REENTER)[number];
|
|
12
19
|
type HarnessKeysStore = {
|
|
13
20
|
readonly sealedKeys: Pick<SealedKeys, "all" | "get" | "put" | "remove">;
|
|
21
|
+
readonly settings: Pick<Settings, "get" | "put">;
|
|
14
22
|
flush(): Promise<void>;
|
|
15
23
|
};
|
|
16
|
-
/** The keys
|
|
17
|
-
|
|
24
|
+
/** The recipe a claim's keys are opened for: its id, the keys it runs on, and its file's digest they must be bound to. */
|
|
25
|
+
type RecipeBound = Pick<PlanRecipe, "id" | "keys" | "digest">;
|
|
26
|
+
/** The keys `recipe` runs on that are saved for it (bound to its digest) and open under `sealKey`, by name. One saved for
|
|
27
|
+
* another recipe file of its id, or that does not open (another seal key, or damaged), reads as not saved, never a clear
|
|
28
|
+
* fallback. For a runner's claim, whose run is on that recipe. */
|
|
18
29
|
export declare function openHarnessKeys(store: {
|
|
19
|
-
sealedKeys: Pick<SealedKeys, "get">;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
readonly sealedKeys: Pick<SealedKeys, "get">;
|
|
31
|
+
readonly settings: Pick<Settings, "get">;
|
|
32
|
+
}, sealKey: Buffer, recipe: RecipeBound): Promise<Record<string, string>>;
|
|
33
|
+
/** Whether every key `recipe` runs on has a row saved for it, bound to its digest (its bytes never opened): a trigger's
|
|
34
|
+
* check, and a runner's claim before it opens them. */
|
|
23
35
|
export declare function harnessKeysSaved(store: {
|
|
24
|
-
sealedKeys: Pick<SealedKeys, "all">;
|
|
25
|
-
|
|
36
|
+
readonly sealedKeys: Pick<SealedKeys, "all">;
|
|
37
|
+
readonly settings: Pick<Settings, "get">;
|
|
38
|
+
}, recipe: RecipeBound): Promise<boolean>;
|
|
26
39
|
/** Whether a claim laid every key of `names` on `env` (layHarnessKeys: own, never enumerable, not empty), which is when
|
|
27
40
|
* a start takes the keys route (harness-recipe-entry.ts serverRoute). A variable of the same name the environment
|
|
28
41
|
* carries enumerable (one the operator's shell set) is never one: a run takes the keys saved for its harness alone. */
|
|
@@ -40,13 +53,28 @@ export declare const RECIPE_TURN_PERSON_ONLY = "This run started on its owner's
|
|
|
40
53
|
/** Lays `keys` on `env` where only a direct read finds them: never enumerable, so no spread, copy or child environment
|
|
41
54
|
* built from `env` carries them (claim-secrets.ts withModelKeys). */
|
|
42
55
|
export declare function layHarnessKeys(env: NodeJS.ProcessEnv, keys: Readonly<Record<string, string>>): void;
|
|
43
|
-
/** What one
|
|
44
|
-
*
|
|
56
|
+
/** What one harness's keys look like in Settings → Harness keys, never a value. `named`: a plan-billed recipe this
|
|
57
|
+
* server is started with; else an id whose recipe it no longer names, its keys kept until removed. `keys`: each key its
|
|
58
|
+
* recipe runs on (none when not named), set once saved for this recipe file. `kept`: each key saved for this id that its
|
|
59
|
+
* recipe runs on no more (or no recipe does): no run gets it, and DELETE removes it. `ready`: every one of `keys` saved,
|
|
60
|
+
* which is when its runs take the keys route. `reenter`: each of `keys` saved but not one its runs get, and why. */
|
|
45
61
|
export type HarnessKeysView = {
|
|
46
62
|
readonly id: string;
|
|
47
63
|
readonly label: string;
|
|
64
|
+
readonly named: boolean;
|
|
48
65
|
readonly keys: SecretMeta[];
|
|
66
|
+
readonly kept: SecretMeta[];
|
|
49
67
|
readonly ready: boolean;
|
|
68
|
+
readonly reenter: {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly why: HarnessKeyWhy;
|
|
71
|
+
}[];
|
|
72
|
+
};
|
|
73
|
+
/** What a DELETE may remove: a named recipe's keys and those kept for it, or the kept keys of an id no recipe names. */
|
|
74
|
+
export type HarnessKeysHeld = {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly label: string;
|
|
77
|
+
readonly keys: readonly string[];
|
|
50
78
|
};
|
|
51
79
|
/** The saved harness keys over the one store, for the server (the one writer of these rows): a snapshot loaded once at
|
|
52
80
|
* start (load()) and kept in step with every write, so a read answers without a round trip. */
|
|
@@ -57,37 +85,56 @@ export declare class HarnessKeysOverStore {
|
|
|
57
85
|
private readonly data;
|
|
58
86
|
private current;
|
|
59
87
|
private retired;
|
|
88
|
+
private binds;
|
|
89
|
+
private readonly seal;
|
|
60
90
|
/** The last write in flight (save, remove): each waits for the one before it, so two that overlap never read the same
|
|
61
|
-
* value as the one they replace,
|
|
91
|
+
* value as the one they replace, every value a claim may have opened is retired, and the binding row is written whole
|
|
92
|
+
* by one at a time. */
|
|
62
93
|
private writing;
|
|
63
|
-
/** `work` once every write before it has settled, its failure its own.
|
|
94
|
+
/** `work` once every write before it has settled, its failure its own. A write that fails partway (a value put and its
|
|
95
|
+
* binding not) reads the store again before the next one, so the snapshot, and the cut it gives (values()), holds
|
|
96
|
+
* every value the store does. */
|
|
64
97
|
private serial;
|
|
65
98
|
/** `recipes`: the plan-billed recipes this server is started with (harness-table.ts planRecipesOf), the only harnesses
|
|
66
|
-
* whose keys it saves
|
|
99
|
+
* whose keys it saves. `data`: its data directory, which its registry (harnessKeysSavedHere) is kept under. */
|
|
67
100
|
constructor(store: HarnessKeysStore, sealKey: Buffer, recipes: readonly PlanRecipe[], data: string);
|
|
68
101
|
/** This server's registry (harnessKeysSavedHere) set from the snapshot: each recipe whose every key is saved. */
|
|
69
102
|
private mark;
|
|
70
|
-
/** Reads every harness key row once: each current one opened, each retired one opened
|
|
71
|
-
*
|
|
103
|
+
/** Reads every harness key row once, and their bindings: each current one opened (or why not), each retired one opened
|
|
104
|
+
* for the cut. */
|
|
72
105
|
load(): Promise<void>;
|
|
106
|
+
/** `key`'s row for `recipe` when its runs get it: it opens, and is bound to this recipe file. */
|
|
107
|
+
private bound;
|
|
73
108
|
/** Whether every key `recipe` runs on is saved for it. */
|
|
74
|
-
saved(recipe: Pick<PlanRecipe, "id" | "keys">): boolean;
|
|
75
|
-
/** Every value to cut: each saved key's, and each retired one's
|
|
109
|
+
saved(recipe: Pick<PlanRecipe, "id" | "keys" | "digest">): boolean;
|
|
110
|
+
/** Every value to cut: each saved key's that opens, whatever recipe it is bound to (or none), and each retired one's
|
|
111
|
+
* still kept. */
|
|
76
112
|
values(): string[];
|
|
77
|
-
/**
|
|
113
|
+
/** The keys saved for `id` that `named` does not hold, each as its view says it. */
|
|
114
|
+
private kept;
|
|
115
|
+
/** GET: `recipe`'s keys, each by name, whether saved for it and when it changed, and those to enter again: never a value. */
|
|
78
116
|
view(recipe: PlanRecipe): HarnessKeysView;
|
|
79
|
-
/**
|
|
117
|
+
/** Each id with keys saved whose recipe this server does not name, sorted: capabilities' harness_keys.kept, so the
|
|
118
|
+
* console offers the page that removes them. */
|
|
119
|
+
unnamed(): string[];
|
|
120
|
+
/** GET /settings/harness-keys: every plan-billed recipe this server is started with, its keys by name; then each id
|
|
121
|
+
* with keys saved whose recipe it no longer names (unnamed), its keys kept. */
|
|
80
122
|
list(): {
|
|
81
123
|
harnesses: HarnessKeysView[];
|
|
82
124
|
};
|
|
83
|
-
/** The plan-billed recipe `id` names on this server, else 404. */
|
|
125
|
+
/** The plan-billed recipe `id` names on this server, else 404: what a PUT saves for. */
|
|
84
126
|
recipe(id: string): PlanRecipe;
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
127
|
+
/** What a DELETE of `id`'s keys may remove: a named recipe's keys and those kept for it, or the keys kept for an id no
|
|
128
|
+
* recipe on this server names; else 404. */
|
|
129
|
+
held(id: string): HarnessKeysHeld;
|
|
130
|
+
/** PUT: `value` sealed as `key` for `recipe`'s harness alone, bound to its file; a value it replaces kept as a retired
|
|
131
|
+
* row. Durable before it resolves, so a 204 never outruns the store. */
|
|
87
132
|
save(recipe: PlanRecipe, key: string, body: unknown): Promise<void>;
|
|
88
|
-
/** DELETE: `key`'s value for `
|
|
89
|
-
*
|
|
90
|
-
remove(
|
|
133
|
+
/** DELETE: `key`'s value for `held`'s harness gone from its runs, kept as a retired row for the cut. A row that does not
|
|
134
|
+
* open under this server's seal key is removed too, so no claim counts it saved. */
|
|
135
|
+
remove(held: HarnessKeysHeld, key: string): Promise<void>;
|
|
136
|
+
/** The bindings written back as one settings row. */
|
|
137
|
+
private writeBinds;
|
|
91
138
|
/** `value`, which `key` held, sealed as a retired row of its own; the oldest beyond RETIRED_KEPT leaves. */
|
|
92
139
|
private retire;
|
|
93
140
|
}
|
|
@@ -95,4 +142,3 @@ export declare class HarnessKeysOverStore {
|
|
|
95
142
|
export declare function planRecipeOr404(recipes: readonly PlanRecipe[], id: string): PlanRecipe;
|
|
96
143
|
/** The bytes a value would be sealed as, for a test that checks a key is sealed at rest. */
|
|
97
144
|
export declare const sealedHarnessKeyBytes: (key: Buffer, harness: string, name: string, value: string) => Uint8Array;
|
|
98
|
-
export {};
|
package/dist/harness-keys.js
CHANGED
|
@@ -5,13 +5,25 @@
|
|
|
5
5
|
// cut (the server's secretStores, and a runner's storeSecrets, which reads every sealed_keys row) still holds it, and a
|
|
6
6
|
// timeline written while it was live stays cut after it changes.
|
|
7
7
|
//
|
|
8
|
+
// Each current row is bound to the recipe it was saved for and the seal key it was sealed under, in one settings row
|
|
9
|
+
// beside them (HARNESS_KEY_BINDS: the recipe file's sha256, the seal key's fingerprint, the sha256 of the sealed bytes it
|
|
10
|
+
// was written with, none a secret). A row opens for a run only on the recipe it was saved for: a later recipe file of the
|
|
11
|
+
// same id (another agent, another vendor) never takes it, and a row whose seal key changed says so. The binding is kept
|
|
12
|
+
// outside the sealed value and its AAD, since the cut opens every row as a bare key; the digest of the sealed bytes ties
|
|
13
|
+
// the two reads together, so a claim that reads one value's binding and then, after a save, another value's bytes never
|
|
14
|
+
// opens them. A recipe the server no longer names keeps its keys (still sealed, still cut, run by
|
|
15
|
+
// nothing): listed by its id, and removed by DELETE.
|
|
16
|
+
//
|
|
8
17
|
// The server reads and writes them through HarnessKeysOverStore (its Settings → Harness keys routes, owner only). A
|
|
9
|
-
// runner opens a claim's own at its claim (openHarnessKeys), for that run's
|
|
18
|
+
// runner opens a claim's own at its claim (openHarnessKeys), for that run's recipe alone, and lays them on its adapter's
|
|
10
19
|
// environment where only the agent's start reads them (runner/cli-run-spec.ts): never on its tools, never another run's.
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
11
21
|
import { ApiError, invalid } from "./errors.js";
|
|
12
|
-
import {
|
|
22
|
+
import { HARNESS_KEY_REENTER, openSealed, putSealedKey, removeSealedKey, sealFingerprint } from "./server-keys.js";
|
|
13
23
|
import { registerSecretPage, registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
14
|
-
|
|
24
|
+
// isObject from the store, never validate.ts: this module loads while model.ts does (harness-table.ts →
|
|
25
|
+
// harness-recipe-entry.ts), and validate.ts reaches key-words.ts, which reads model.ts's MODEL_KEYS before it is set.
|
|
26
|
+
import { isObject, sealColumn, sealedAt } from "./store/index.js";
|
|
15
27
|
// Every value saved here is a secret: saving one or removing it takes the owner's session (secret-writes.ts), never the
|
|
16
28
|
// token, and the token's refusal names the console's page.
|
|
17
29
|
registerSecretWrite("saveHarnessKey", () => true);
|
|
@@ -24,31 +36,77 @@ export const HARNESS_KEY_PLANE = "harness";
|
|
|
24
36
|
const RETIRED_PLANE = "harness-retired";
|
|
25
37
|
/** How many replaced or removed values of one key stay sealed for the cut: the oldest beyond it leaves. */
|
|
26
38
|
export const RETIRED_KEPT = 8;
|
|
39
|
+
/** The settings row each current key row's binding is kept in: { v: 1, rows: { <row>: { seal, recipe, sealed } } }, `seal`
|
|
40
|
+
* the fingerprint of the seal key it was sealed under (server-keys.ts sealFingerprint), `recipe` the sha256 of the recipe
|
|
41
|
+
* file it was saved for (PlanRecipe.digest), `sealed` the sha256 of the sealed bytes written with it (sealedDigest). */
|
|
42
|
+
export const HARNESS_KEY_BINDS = "harness-keys";
|
|
27
43
|
/** A value's bounds: under 8 characters or holding whitespace, no cut could hold it whole (server-secrets.ts' floor). */
|
|
28
44
|
const MIN_VALUE = 8;
|
|
29
45
|
const MAX_VALUE_BYTES = 1024;
|
|
30
|
-
const UNFIT = /[\s\
|
|
46
|
+
const UNFIT = /[\s\x00-\x1f\x7f-\x9f]/;
|
|
31
47
|
/** The row (and view) name of `key` saved for `harness`. */
|
|
32
48
|
export const harnessKeyRow = (harness, key) => secretName(HARNESS_KEY_PLANE, harness, key);
|
|
33
49
|
const retiredPrefix = (harness, key) => `${secretName(RETIRED_PLANE, harness, key)}:`;
|
|
34
|
-
/** The
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
/** The harness and key a current row's name holds, else undefined (a retired row, or another layer's). */
|
|
51
|
+
const rowParts = (name) => {
|
|
52
|
+
if (!name.startsWith(`${HARNESS_KEY_PLANE}:`))
|
|
53
|
+
return undefined;
|
|
54
|
+
const rest = name.slice(HARNESS_KEY_PLANE.length + 1);
|
|
55
|
+
const at = rest.lastIndexOf(":");
|
|
56
|
+
return at > 0 && at < rest.length - 1 ? { harness: rest.slice(0, at), key: rest.slice(at + 1) } : undefined;
|
|
57
|
+
};
|
|
58
|
+
export { HARNESS_KEY_REENTER };
|
|
59
|
+
/** The sha256 of a row's sealed bytes (base64url): a binding holds the one its value was written with, so bytes read
|
|
60
|
+
* apart from it open only when they are those bytes. Of ciphertext, never of a value. */
|
|
61
|
+
const sealedDigest = (sealed) => createHash("sha256").update(sealed).digest("base64url");
|
|
62
|
+
/** The recipe `bind` binds `sealed` to: none when there is no binding, or it was written with other bytes (a save landed
|
|
63
|
+
* between the reads of one and the other, or the row was put by hand). */
|
|
64
|
+
const boundRecipe = (bind, sealed) => (bind !== undefined && bind.sealed === sealedDigest(sealed) ? bind.recipe : undefined);
|
|
65
|
+
/** The bindings the settings row holds, failing closed: an unreadable row, or a binding with no digest of its bytes,
|
|
66
|
+
* reads as none, so no key opens until saved again. */
|
|
67
|
+
function bindsOf(read) {
|
|
68
|
+
const binds = new Map();
|
|
69
|
+
if (isObject(read) && read.v === 1 && isObject(read.rows)) {
|
|
70
|
+
for (const [row, bind] of Object.entries(read.rows)) {
|
|
71
|
+
if (isObject(bind) && typeof bind.seal === "string" && typeof bind.recipe === "string" && typeof bind.sealed === "string")
|
|
72
|
+
binds.set(row, { seal: bind.seal, recipe: bind.recipe, sealed: bind.sealed });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return binds;
|
|
76
|
+
}
|
|
77
|
+
const readBinds = async (store) => bindsOf(await store.settings.get(HARNESS_KEY_BINDS));
|
|
78
|
+
/** The keys `recipe` runs on that are saved for it (bound to its digest) and open under `sealKey`, by name. One saved for
|
|
79
|
+
* another recipe file of its id, or that does not open (another seal key, or damaged), reads as not saved, never a clear
|
|
80
|
+
* fallback. For a runner's claim, whose run is on that recipe. */
|
|
81
|
+
export async function openHarnessKeys(store, sealKey, recipe) {
|
|
82
|
+
const binds = await readBinds(store);
|
|
37
83
|
const opened = {};
|
|
38
|
-
for (const name of
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
84
|
+
for (const name of recipe.keys) {
|
|
85
|
+
const row = harnessKeyRow(recipe.id, name);
|
|
86
|
+
const bind = binds.get(row);
|
|
87
|
+
if (bind?.recipe !== recipe.digest)
|
|
88
|
+
continue;
|
|
89
|
+
const sealed = await store.sealedKeys.get(row);
|
|
90
|
+
// The bytes read after the binding are the ones it was written with, or a save came between: never another value.
|
|
91
|
+
if (sealed === undefined || boundRecipe(bind, sealed) !== recipe.digest)
|
|
92
|
+
continue;
|
|
93
|
+
const open = openSealed(sealKey, row, sealed, bind.seal);
|
|
94
|
+
if ("value" in open)
|
|
95
|
+
opened[name] = open.value;
|
|
42
96
|
}
|
|
43
97
|
return opened;
|
|
44
98
|
}
|
|
45
|
-
/** Whether every key
|
|
46
|
-
* claim before it opens them. */
|
|
47
|
-
export async function harnessKeysSaved(store,
|
|
48
|
-
if (!
|
|
99
|
+
/** Whether every key `recipe` runs on has a row saved for it, bound to its digest (its bytes never opened): a trigger's
|
|
100
|
+
* check, and a runner's claim before it opens them. */
|
|
101
|
+
export async function harnessKeysSaved(store, recipe) {
|
|
102
|
+
if (!recipe.keys.length)
|
|
49
103
|
return false;
|
|
50
104
|
const rows = new Set((await store.sealedKeys.all()).map((row) => row.name));
|
|
51
|
-
|
|
105
|
+
const binds = await readBinds(store);
|
|
106
|
+
return recipe.keys.every((name) => {
|
|
107
|
+
const row = harnessKeyRow(recipe.id, name);
|
|
108
|
+
return rows.has(row) && binds.get(row)?.recipe === recipe.digest;
|
|
109
|
+
});
|
|
52
110
|
}
|
|
53
111
|
/** Whether a claim laid every key of `names` on `env` (layHarnessKeys: own, never enumerable, not empty), which is when
|
|
54
112
|
* a start takes the keys route (harness-recipe-entry.ts serverRoute). A variable of the same name the environment
|
|
@@ -91,113 +149,188 @@ export class HarnessKeysOverStore {
|
|
|
91
149
|
data;
|
|
92
150
|
current = new Map();
|
|
93
151
|
retired = new Map();
|
|
152
|
+
binds = new Map();
|
|
153
|
+
seal;
|
|
94
154
|
/** The last write in flight (save, remove): each waits for the one before it, so two that overlap never read the same
|
|
95
|
-
* value as the one they replace,
|
|
155
|
+
* value as the one they replace, every value a claim may have opened is retired, and the binding row is written whole
|
|
156
|
+
* by one at a time. */
|
|
96
157
|
writing = Promise.resolve();
|
|
97
|
-
/** `work` once every write before it has settled, its failure its own.
|
|
158
|
+
/** `work` once every write before it has settled, its failure its own. A write that fails partway (a value put and its
|
|
159
|
+
* binding not) reads the store again before the next one, so the snapshot, and the cut it gives (values()), holds
|
|
160
|
+
* every value the store does. */
|
|
98
161
|
serial(work) {
|
|
99
|
-
const next = this.writing.then(
|
|
162
|
+
const next = this.writing.then(async () => {
|
|
163
|
+
try {
|
|
164
|
+
await work();
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
await this.load().catch(() => undefined);
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
100
171
|
this.writing = next.catch(() => undefined);
|
|
101
172
|
return next;
|
|
102
173
|
}
|
|
103
174
|
/** `recipes`: the plan-billed recipes this server is started with (harness-table.ts planRecipesOf), the only harnesses
|
|
104
|
-
* whose keys it saves
|
|
175
|
+
* whose keys it saves. `data`: its data directory, which its registry (harnessKeysSavedHere) is kept under. */
|
|
105
176
|
constructor(store, sealKey, recipes, data) {
|
|
106
177
|
this.store = store;
|
|
107
178
|
this.sealKey = sealKey;
|
|
108
179
|
this.recipes = recipes;
|
|
109
180
|
this.data = data;
|
|
181
|
+
this.seal = sealFingerprint(sealKey);
|
|
110
182
|
}
|
|
111
183
|
/** This server's registry (harnessKeysSavedHere) set from the snapshot: each recipe whose every key is saved. */
|
|
112
184
|
mark() {
|
|
113
185
|
savedHere.set(this.data, new Set(this.recipes.filter((recipe) => this.saved(recipe)).map((recipe) => recipe.id)));
|
|
114
186
|
}
|
|
115
|
-
/** Reads every harness key row once: each current one opened, each retired one opened
|
|
116
|
-
*
|
|
187
|
+
/** Reads every harness key row once, and their bindings: each current one opened (or why not), each retired one opened
|
|
188
|
+
* for the cut. */
|
|
117
189
|
async load() {
|
|
190
|
+
const binds = await readBinds(this.store);
|
|
118
191
|
const current = new Map();
|
|
119
192
|
const retired = new Map();
|
|
120
193
|
for (const row of await this.store.sealedKeys.all()) {
|
|
121
|
-
|
|
122
|
-
|
|
194
|
+
if (rowParts(row.name)) {
|
|
195
|
+
const bind = binds.get(row.name);
|
|
196
|
+
current.set(row.name, { opened: openSealed(this.sealKey, row.name, row.sealed, bind?.seal), recipe: boundRecipe(bind, row.sealed), changedAt: row.updatedAt });
|
|
123
197
|
continue;
|
|
124
|
-
let value;
|
|
125
|
-
try {
|
|
126
|
-
value = unsealColumn(this.sealKey, sealedAt.sealedKey(row.name), row.sealed).toString("utf8");
|
|
127
198
|
}
|
|
128
|
-
|
|
199
|
+
if (!row.name.startsWith(`${RETIRED_PLANE}:`))
|
|
129
200
|
continue;
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
retired.set(of, [...(retired.get(of) ?? []), { row: row.name, value, at: row.updatedAt }]);
|
|
136
|
-
}
|
|
201
|
+
const opened = openSealed(this.sealKey, row.name, row.sealed, undefined);
|
|
202
|
+
if (!("value" in opened))
|
|
203
|
+
continue;
|
|
204
|
+
const of = row.name.slice(0, row.name.lastIndexOf(":") + 1);
|
|
205
|
+
retired.set(of, [...(retired.get(of) ?? []), { row: row.name, value: opened.value, at: row.updatedAt }]);
|
|
137
206
|
}
|
|
138
207
|
for (const list of retired.values())
|
|
139
208
|
list.sort((a, b) => a.at - b.at);
|
|
209
|
+
this.binds = binds;
|
|
140
210
|
this.current = current;
|
|
141
211
|
this.retired = retired;
|
|
142
212
|
this.mark();
|
|
143
213
|
}
|
|
214
|
+
/** `key`'s row for `recipe` when its runs get it: it opens, and is bound to this recipe file. */
|
|
215
|
+
bound(recipe, key) {
|
|
216
|
+
const entry = this.current.get(harnessKeyRow(recipe.id, key));
|
|
217
|
+
return entry && "value" in entry.opened && entry.recipe === recipe.digest ? entry : undefined;
|
|
218
|
+
}
|
|
144
219
|
/** Whether every key `recipe` runs on is saved for it. */
|
|
145
220
|
saved(recipe) {
|
|
146
|
-
return recipe.keys.length > 0 && recipe.keys.every((name) => this.
|
|
221
|
+
return recipe.keys.length > 0 && recipe.keys.every((name) => this.bound(recipe, name) !== undefined);
|
|
147
222
|
}
|
|
148
|
-
/** Every value to cut: each saved key's, and each retired one's
|
|
223
|
+
/** Every value to cut: each saved key's that opens, whatever recipe it is bound to (or none), and each retired one's
|
|
224
|
+
* still kept. */
|
|
149
225
|
values() {
|
|
150
|
-
return [
|
|
226
|
+
return [
|
|
227
|
+
...[...this.current.values()].flatMap((entry) => ("value" in entry.opened ? [entry.opened.value] : [])),
|
|
228
|
+
...[...this.retired.values()].flat().map((entry) => entry.value),
|
|
229
|
+
];
|
|
151
230
|
}
|
|
152
|
-
/**
|
|
231
|
+
/** The keys saved for `id` that `named` does not hold, each as its view says it. */
|
|
232
|
+
kept(id, named) {
|
|
233
|
+
return [...this.current].flatMap(([row, entry]) => {
|
|
234
|
+
const parts = rowParts(row);
|
|
235
|
+
if (parts?.harness !== id || named.includes(parts.key))
|
|
236
|
+
return [];
|
|
237
|
+
return [secretMeta(row, "value" in entry.opened ? { set: true, source: "console", changedAt: new Date(entry.changedAt) } : { set: false })];
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/** GET: `recipe`'s keys, each by name, whether saved for it and when it changed, and those to enter again: never a value. */
|
|
153
241
|
view(recipe) {
|
|
154
242
|
const keys = recipe.keys.map((name) => {
|
|
243
|
+
const saved = this.bound(recipe, name);
|
|
244
|
+
return secretMeta(harnessKeyRow(recipe.id, name), saved ? { set: true, source: "console", changedAt: new Date(saved.changedAt) } : { set: false });
|
|
245
|
+
});
|
|
246
|
+
const reenter = recipe.keys.flatMap((name) => {
|
|
155
247
|
const row = harnessKeyRow(recipe.id, name);
|
|
156
|
-
const
|
|
157
|
-
|
|
248
|
+
const entry = this.current.get(row);
|
|
249
|
+
if (!entry || this.bound(recipe, name))
|
|
250
|
+
return [];
|
|
251
|
+
const why = "unreadable" in entry.opened ? entry.opened.unreadable : "recipe_changed";
|
|
252
|
+
return [{ name: row, why }];
|
|
158
253
|
});
|
|
159
|
-
return { id: recipe.id, label: recipe.label, keys, ready: this.saved(recipe) };
|
|
254
|
+
return { id: recipe.id, label: recipe.label, named: true, keys, kept: this.kept(recipe.id, recipe.keys), ready: this.saved(recipe), reenter };
|
|
160
255
|
}
|
|
161
|
-
/**
|
|
256
|
+
/** Each id with keys saved whose recipe this server does not name, sorted: capabilities' harness_keys.kept, so the
|
|
257
|
+
* console offers the page that removes them. */
|
|
258
|
+
unnamed() {
|
|
259
|
+
const named = new Set(this.recipes.map((recipe) => recipe.id));
|
|
260
|
+
return [...new Set([...this.current.keys()].flatMap((row) => rowParts(row)?.harness ?? []))].filter((id) => !named.has(id)).sort();
|
|
261
|
+
}
|
|
262
|
+
/** GET /settings/harness-keys: every plan-billed recipe this server is started with, its keys by name; then each id
|
|
263
|
+
* with keys saved whose recipe it no longer names (unnamed), its keys kept. */
|
|
162
264
|
list() {
|
|
163
|
-
return {
|
|
265
|
+
return {
|
|
266
|
+
harnesses: [
|
|
267
|
+
...this.recipes.map((recipe) => this.view(recipe)),
|
|
268
|
+
...this.unnamed().map((id) => ({ id, label: id, named: false, keys: [], kept: this.kept(id, []), ready: false, reenter: [] })),
|
|
269
|
+
],
|
|
270
|
+
};
|
|
164
271
|
}
|
|
165
|
-
/** The plan-billed recipe `id` names on this server, else 404. */
|
|
272
|
+
/** The plan-billed recipe `id` names on this server, else 404: what a PUT saves for. */
|
|
166
273
|
recipe(id) {
|
|
167
274
|
return planRecipeOr404(this.recipes, id);
|
|
168
275
|
}
|
|
169
|
-
/**
|
|
170
|
-
*
|
|
276
|
+
/** What a DELETE of `id`'s keys may remove: a named recipe's keys and those kept for it, or the keys kept for an id no
|
|
277
|
+
* recipe on this server names; else 404. */
|
|
278
|
+
held(id) {
|
|
279
|
+
const recipe = this.recipes.find((entry) => entry.id === id);
|
|
280
|
+
const kept = [...this.current.keys()].flatMap((row) => {
|
|
281
|
+
const parts = rowParts(row);
|
|
282
|
+
return parts?.harness === id && !recipe?.keys.includes(parts.key) ? [parts.key] : [];
|
|
283
|
+
});
|
|
284
|
+
if (!recipe && !kept.length)
|
|
285
|
+
return planRecipeOr404(this.recipes, id);
|
|
286
|
+
return { id, label: recipe?.label ?? id, keys: [...(recipe?.keys ?? []), ...kept] };
|
|
287
|
+
}
|
|
288
|
+
/** PUT: `value` sealed as `key` for `recipe`'s harness alone, bound to its file; a value it replaces kept as a retired
|
|
289
|
+
* row. Durable before it resolves, so a 204 never outruns the store. */
|
|
171
290
|
async save(recipe, key, body) {
|
|
172
291
|
const value = admit(recipe, key, body);
|
|
173
292
|
const row = harnessKeyRow(recipe.id, key);
|
|
174
293
|
await this.serial(async () => {
|
|
175
294
|
const was = this.current.get(row);
|
|
176
|
-
|
|
295
|
+
const wasValue = was && "value" in was.opened ? was.opened.value : undefined;
|
|
296
|
+
if (wasValue === value && was?.recipe === recipe.digest && this.binds.get(row)?.seal === this.seal)
|
|
177
297
|
return;
|
|
178
|
-
if (
|
|
179
|
-
await this.retire(recipe.id, key,
|
|
180
|
-
|
|
181
|
-
|
|
298
|
+
if (wasValue !== undefined && wasValue !== value)
|
|
299
|
+
await this.retire(recipe.id, key, wasValue);
|
|
300
|
+
// Unbound before the new value is written, bound after: a write cut short leaves a row bound to no recipe (opened by
|
|
301
|
+
// none), never a value bound to a recipe it was not saved for.
|
|
302
|
+
if (this.binds.delete(row))
|
|
303
|
+
await this.writeBinds();
|
|
304
|
+
const sealed = sealColumn(this.sealKey, sealedAt.sealedKey(row), value);
|
|
305
|
+
await this.store.sealedKeys.put(row, sealed);
|
|
306
|
+
this.binds.set(row, { seal: this.seal, recipe: recipe.digest, sealed: sealedDigest(sealed) });
|
|
307
|
+
await this.writeBinds();
|
|
308
|
+
this.current.set(row, { opened: { value }, recipe: recipe.digest, changedAt: Date.now() });
|
|
182
309
|
this.mark();
|
|
183
310
|
await this.store.flush();
|
|
184
311
|
});
|
|
185
312
|
}
|
|
186
|
-
/** DELETE: `key`'s value for `
|
|
187
|
-
*
|
|
188
|
-
async remove(
|
|
189
|
-
known(
|
|
190
|
-
const row = harnessKeyRow(
|
|
313
|
+
/** DELETE: `key`'s value for `held`'s harness gone from its runs, kept as a retired row for the cut. A row that does not
|
|
314
|
+
* open under this server's seal key is removed too, so no claim counts it saved. */
|
|
315
|
+
async remove(held, key) {
|
|
316
|
+
known(held, key);
|
|
317
|
+
const row = harnessKeyRow(held.id, key);
|
|
191
318
|
await this.serial(async () => {
|
|
192
319
|
const was = this.current.get(row);
|
|
193
|
-
if (was)
|
|
194
|
-
await this.retire(
|
|
320
|
+
if (was && "value" in was.opened)
|
|
321
|
+
await this.retire(held.id, key, was.opened.value);
|
|
195
322
|
await removeSealedKey(this.store, row);
|
|
323
|
+
if (this.binds.delete(row))
|
|
324
|
+
await this.writeBinds();
|
|
196
325
|
this.current.delete(row);
|
|
197
326
|
this.mark();
|
|
198
327
|
await this.store.flush();
|
|
199
328
|
});
|
|
200
329
|
}
|
|
330
|
+
/** The bindings written back as one settings row. */
|
|
331
|
+
async writeBinds() {
|
|
332
|
+
await this.store.settings.put(HARNESS_KEY_BINDS, { v: 1, rows: Object.fromEntries(this.binds) });
|
|
333
|
+
}
|
|
201
334
|
/** `value`, which `key` held, sealed as a retired row of its own; the oldest beyond RETIRED_KEPT leaves. */
|
|
202
335
|
async retire(harness, key, value) {
|
|
203
336
|
const of = retiredPrefix(harness, key);
|
|
@@ -211,7 +344,7 @@ export class HarnessKeysOverStore {
|
|
|
211
344
|
this.retired.set(of, list);
|
|
212
345
|
}
|
|
213
346
|
}
|
|
214
|
-
/** 422 unless `key` is one `recipe` runs on (
|
|
347
|
+
/** 422 unless `key` is one `recipe` runs on (or, for a DELETE, one kept for it): a key no recipe names is never saved. */
|
|
215
348
|
function known(recipe, key) {
|
|
216
349
|
if (!recipe.keys.includes(key))
|
|
217
350
|
throw invalid([{ field: "key", reason: "not_an_option", message: `${recipe.label} runs on ${recipe.keys.join(", ")}.` }]);
|
|
@@ -240,7 +373,7 @@ function admit(recipe, key, body) {
|
|
|
240
373
|
export function planRecipeOr404(recipes, id) {
|
|
241
374
|
const recipe = recipes.find((entry) => entry.id === id);
|
|
242
375
|
if (!recipe)
|
|
243
|
-
throw new ApiError("not_found", `No harness recipe billed to its vendor's plan is named ${id} on this server: its keys are saved for a recipe the server is started with (--harness-recipe).`);
|
|
376
|
+
throw new ApiError("not_found", `No harness recipe billed to its vendor's plan is named ${id} on this server, and no key is kept for it: its keys are saved for a recipe the server is started with (--harness-recipe).`);
|
|
244
377
|
return recipe;
|
|
245
378
|
}
|
|
246
379
|
/** The bytes a value would be sealed as, for a test that checks a key is sealed at rest. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AcpRecipe } from "@parcha/agentrun-harness-acp";
|
|
2
|
-
import { type Recipe, type RecipeArchive } from "./harness-recipe.js";
|
|
2
|
+
import { loadRecipe, type Recipe, type RecipeArchive } from "./harness-recipe.js";
|
|
3
3
|
import { type AcpEntryHost, type HarnessEntry } from "./harness-table.js";
|
|
4
4
|
/** A recipe with a sign-in on a server started with --harness-sign-in, whose owner has not signed its agent in on this
|
|
5
5
|
* data directory. */
|
|
@@ -65,12 +65,13 @@ export interface RecipeEntryOptions extends AcpEntryHost {
|
|
|
65
65
|
* session's model proxy (the one on Anthropic's Messages there is, Goose's policy, its address under the variable the
|
|
66
66
|
* recipe names). Billed to its plan: as Cursor's, on the model the recipe names or its vendor's own default. */
|
|
67
67
|
export declare function recipeEntryOf(options: RecipeEntryOptions): HarnessEntry;
|
|
68
|
-
/** The entry of the recipe
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
68
|
+
/** The entry of the recipe `loaded` (loadRecipe: read once, so the entry and the digest its keys are bound to are of the
|
|
69
|
+
* same bytes) on a server whose data directory is `data` (harness-table.ts HARNESS_RECIPES_ENV), loaded under its five
|
|
70
|
+
* rules when the table is (a refused one refuses the start, in words). It runs only on the
|
|
71
|
+
* install its owner made and checked: hidden, and each run refused, with the command that fixes it, until a harness-check
|
|
72
|
+
* passed for this very recipe and this install's tree, the binary among it (HARNESS_NOT_CHECKED). Each start of its
|
|
73
|
+
* agent digests the tree again and holds it to its pin (harness-recipe.ts installHolds). It runs on
|
|
73
74
|
* the route serverRoute gives, its owner's sign-in only where `signIn` (--harness-sign-in). */
|
|
74
|
-
export declare function recipeServerEntry(
|
|
75
|
+
export declare function recipeServerEntry(loaded: ReturnType<typeof loadRecipe>, data: string, { signIn }?: {
|
|
75
76
|
signIn?: boolean;
|
|
76
77
|
}): HarnessEntry;
|