@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.34
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 +233 -0
- package/README.md +266 -201
- package/dist/adapters.d.ts +0 -4
- package/dist/adapters.js +11 -15
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +92 -50
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/cap.d.ts +8 -5
- package/dist/cap.js +12 -5
- package/dist/cli.js +39 -13
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +30 -2
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +32 -1
- package/dist/learned-workflow.js +100 -9
- package/dist/learning-routes.d.ts +8 -4
- package/dist/learning-routes.js +23 -9
- package/dist/learning-run.d.ts +9 -26
- package/dist/learning-run.js +22 -32
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -49
- package/dist/mcp-gateway.js +44 -135
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +121 -47
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +25 -60
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +10 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +15 -4
- package/dist/run-view.d.ts +7 -8
- package/dist/run-view.js +26 -7
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +6 -1
- package/dist/runner/adapter-loop.js +423 -53
- package/dist/runner/adapter-run-spec.d.ts +21 -8
- package/dist/runner/adapter-run-spec.js +90 -32
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +12 -2
- package/dist/runner/adapters/pi.js +16 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +36 -5
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +48 -14
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +45 -16
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/main.d.ts +56 -9
- package/dist/runner/main.js +127 -18
- package/dist/runner/mcp-claim.js +1 -2
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +133 -9
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +63 -17
- package/dist/runs-over-store.d.ts +7 -2
- package/dist/runs-over-store.js +60 -14
- package/dist/seal-key.js +5 -43
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +16 -38
- package/dist/server.js +145 -106
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +93 -17
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +53 -18
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +30 -18
- package/dist/tools.js +97 -107
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +24 -6
- package/dist/workspace/computer-deps.js +108 -20
- package/dist/workspace/computer-for-claim.d.ts +12 -11
- package/dist/workspace/computer-for-claim.js +76 -15
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.js +3 -3
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -14
- package/dist/workspace.js +3 -96
- package/package.json +13 -13
- package/templates/README.md +9 -3
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/run-cut.d.ts
CHANGED
|
@@ -13,12 +13,6 @@ export declare function runCutValues(deps: {
|
|
|
13
13
|
}): Promise<{
|
|
14
14
|
values: string[];
|
|
15
15
|
} | "unreadable">;
|
|
16
|
-
/** Run `runId`'s cut as a function of a text: the one rule its served words are shown by (run-view.ts shownOf: no value
|
|
17
|
-
* of the cut set, in any spelling, and no loopback address), or `unreadable` when the run is withheld. */
|
|
18
|
-
export declare function runCutOf(deps: {
|
|
19
|
-
serverSecrets: () => string[];
|
|
20
|
-
signIns?: SignInReader;
|
|
21
|
-
}, store: Pick<Store, "runs">, runId: string): Promise<((text: string) => string) | "unreadable">;
|
|
22
16
|
/** Run `runId`'s error words: how its error text reads wherever it is served (its view's error, its Timeline's error
|
|
23
17
|
* rows), main's errorWords: a refused key in plain words (key-refusal.ts keyRefusal, the key its harness's route sends
|
|
24
18
|
* by this server's settings and keys), else the text by the one rule (shownOf); `unreadable` when the run is withheld.
|
package/dist/run-cut.js
CHANGED
|
@@ -18,12 +18,6 @@ export async function runCutValues(deps, store, runId, known) {
|
|
|
18
18
|
return "unreadable";
|
|
19
19
|
return { values: [...deps.serverSecrets(), ...handed.refs.filter((ref) => ref.length >= MIN_SECRET)] };
|
|
20
20
|
}
|
|
21
|
-
/** Run `runId`'s cut as a function of a text: the one rule its served words are shown by (run-view.ts shownOf: no value
|
|
22
|
-
* of the cut set, in any spelling, and no loopback address), or `unreadable` when the run is withheld. */
|
|
23
|
-
export async function runCutOf(deps, store, runId) {
|
|
24
|
-
const cut = await runCutValues(deps, store, runId);
|
|
25
|
-
return cut === "unreadable" ? "unreadable" : shownOf(cut.values);
|
|
26
|
-
}
|
|
27
21
|
/** Run `runId`'s error words: how its error text reads wherever it is served (its view's error, its Timeline's error
|
|
28
22
|
* rows), main's errorWords: a refused key in plain words (key-refusal.ts keyRefusal, the key its harness's route sends
|
|
29
23
|
* by this server's settings and keys), else the text by the one rule (shownOf); `unreadable` when the run is withheld.
|
package/dist/run-db.d.ts
CHANGED
|
@@ -3,17 +3,16 @@ import { DatabaseSync } from "node:sqlite";
|
|
|
3
3
|
/** `dropped`: a read of the file alone whose file changed during it, made again (readRunDbSync). */
|
|
4
4
|
export type RunDbOpen = {
|
|
5
5
|
file: string;
|
|
6
|
-
mode: "read" | "
|
|
6
|
+
mode: "read" | "dropped";
|
|
7
7
|
held: boolean;
|
|
8
8
|
};
|
|
9
9
|
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
10
10
|
export declare function observeRunDbOpens(observer: (open: RunDbOpen) => void): () => void;
|
|
11
11
|
/** Tests' seams: `afterPlan`, called between a read's choice of how to open the file and its open; `madeReads`, called
|
|
12
|
-
* with each MonotonicReads made
|
|
12
|
+
* with each MonotonicReads made. */
|
|
13
13
|
export declare const runDbTestHooks: {
|
|
14
14
|
afterPlan?: (file: string) => void;
|
|
15
15
|
madeReads?: (reads: MonotonicReads) => void;
|
|
16
|
-
beforeCheckpoint?: (db: DatabaseSync) => void;
|
|
17
16
|
};
|
|
18
17
|
/** A read of a run's database file alone whose file changed during it (a run's process wrote and a take-back checkpointed
|
|
19
18
|
* meanwhile), every try: none of them is shown. */
|
|
@@ -52,11 +51,3 @@ export declare class MonotonicReads {
|
|
|
52
51
|
/** Forgets run `runId`'s reads: a run that is gone, or whose store was replaced. */
|
|
53
52
|
forget(runId: string): void;
|
|
54
53
|
}
|
|
55
|
-
/** A read-write open of a run's database while a process holds the run: refused, never made. */
|
|
56
|
-
export declare class HeldRunDbError extends Error {
|
|
57
|
-
constructor(file: string);
|
|
58
|
-
}
|
|
59
|
-
/** Checkpoints the run database at `file` into its database file and removes its WAL, once no process holds the run
|
|
60
|
-
* (`held` false; true throws HeldRunDbError before any open). A database with no WAL left is untouched but for the
|
|
61
|
-
* open. The one read-write open the server makes of a run's database. */
|
|
62
|
-
export declare function checkpointRunDb(file: string, held: boolean, platform?: NodeJS.Platform): Promise<void>;
|
package/dist/run-db.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
// guard). The one read-write open is the checkpoint when the server takes the run back (runs.ts), with no process left.
|
|
8
8
|
import { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
9
9
|
import { DatabaseSync } from "node:sqlite";
|
|
10
|
-
import {
|
|
11
|
-
import { profilePragmas } from "@parcha/pi-durable-disk/internals";
|
|
10
|
+
import { walHasCommit } from "@parcha/agentrun-pi/durable";
|
|
12
11
|
const observers = new Set();
|
|
13
12
|
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
14
13
|
export function observeRunDbOpens(observer) {
|
|
@@ -33,7 +32,7 @@ function fileMark(file) {
|
|
|
33
32
|
return `${at.ino}:${at.size}:${at.mtimeNs}:${header.toString("hex")}`;
|
|
34
33
|
}
|
|
35
34
|
/** Tests' seams: `afterPlan`, called between a read's choice of how to open the file and its open; `madeReads`, called
|
|
36
|
-
* with each MonotonicReads made
|
|
35
|
+
* with each MonotonicReads made. */
|
|
37
36
|
export const runDbTestHooks = {};
|
|
38
37
|
/** A read of a run's database file alone whose file changed during it (a run's process wrote and a take-back checkpointed
|
|
39
38
|
* meanwhile), every try: none of them is shown. */
|
|
@@ -115,37 +114,3 @@ export class MonotonicReads {
|
|
|
115
114
|
this.#seen.delete(runId);
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
|
-
/** A read-write open of a run's database while a process holds the run: refused, never made. */
|
|
119
|
-
export class HeldRunDbError extends Error {
|
|
120
|
-
constructor(file) {
|
|
121
|
-
super(`the server never opens a run's database read-write while a process holds the run (${file})`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** Checkpoints the run database at `file` into its database file and removes its WAL, once no process holds the run
|
|
125
|
-
* (`held` false; true throws HeldRunDbError before any open). A database with no WAL left is untouched but for the
|
|
126
|
-
* open. The one read-write open the server makes of a run's database. */
|
|
127
|
-
export async function checkpointRunDb(file, held, platform = process.platform) {
|
|
128
|
-
for (const observer of observers)
|
|
129
|
-
observer({ file, mode: "checkpoint", held });
|
|
130
|
-
if (held)
|
|
131
|
-
throw new HeldRunDbError(file);
|
|
132
|
-
const db = new DatabaseSync(file, { timeout: 0 });
|
|
133
|
-
try {
|
|
134
|
-
// As its writer opened it (pi-durable-disk's exclusive profile): the WAL index in heap, so no -shm is made; and on
|
|
135
|
-
// macOS F_FULLFSYNC (`fullfsync`, `checkpoint_fullfsync`), as fsync there leaves the drive's cache unflushed. And
|
|
136
|
-
// synchronous FULL whatever level the run's journal runs at, so the checkpoint's copy is synced into the database file
|
|
137
|
-
// before the WAL that held it is removed (pi-durable-disk barriers.ts lists this store as FULL).
|
|
138
|
-
for (const [pragma, value] of Object.entries(profilePragmas("exclusive", platform, "FULL")))
|
|
139
|
-
db.exec(`PRAGMA ${pragma} = ${value}`);
|
|
140
|
-
db.prepare("SELECT count(*) FROM sqlite_schema").get();
|
|
141
|
-
runDbTestHooks.beforeCheckpoint?.(db);
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
// The close checkpoints: it copies into the database file only pages the WAL holds too, so a lock-free reader still
|
|
145
|
-
// reading the WAL reads the same bytes either way; then it removes the WAL, which a reader that holds it open goes on
|
|
146
|
-
// reading. Never wal_checkpoint(TRUNCATE): that cuts the WAL under such a reader, whose read then fails.
|
|
147
|
-
db.close();
|
|
148
|
-
// The WAL is gone, and with it what was kept of its walk (walHasCommit).
|
|
149
|
-
forgetWalWalk(`${file}-wal`);
|
|
150
|
-
}
|
|
151
|
-
}
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MessageOrigin } from "
|
|
1
|
+
import { type MessageOrigin } from "./timeline/index.js";
|
|
2
2
|
import type { Plane } from "./tool-plane.js";
|
|
3
3
|
import type { RunTrigger } from "./triggers.js";
|
|
4
4
|
import { type Json } from "./validate.js";
|
|
@@ -32,6 +32,9 @@ export interface RunLaunch {
|
|
|
32
32
|
readonly documents?: string;
|
|
33
33
|
/** What a run's box may reach, as the server resolved it: the list, or "none". */
|
|
34
34
|
readonly boxAllow?: readonly string[] | "none";
|
|
35
|
+
/** The operator set AGENTRUN_BOX_ALLOW (box-settings.ts boxAllowSetIn): `boxAllow` is theirs, not the default. A
|
|
36
|
+
* browser is held to an operator's list and runs open under the default. Absent: the default. */
|
|
37
|
+
readonly boxAllowSet?: true;
|
|
35
38
|
/** The uploaded file ids the run was started with, in order (the create body's file_ids, already checked ready): the
|
|
36
39
|
* runner copies them into the run's work/inputs/ at its claim, as the old start copied them before the process ran. */
|
|
37
40
|
readonly files?: readonly string[];
|
|
@@ -40,7 +43,11 @@ export interface RunLaunch {
|
|
|
40
43
|
* shows them); `seed`, the learning commit's sha (or null when the seed could not be read); and `section`, the exact
|
|
41
44
|
* # Learned text to lay into the prompt for those notes (what the old layLearned laid), within the learning budget; and
|
|
42
45
|
* `seedNotes`, the count of all notes in the seed before the budget picked `given` (present with a read seed; absent when
|
|
43
|
-
* the seed could not be read)
|
|
46
|
+
* the seed could not be read); `skills`, the names of the learned skills the seed offers the run (each active one that
|
|
47
|
+
* fits a run's skill budget at all; its claim lays them), absent when none; `gradeModel`, the model the server names
|
|
48
|
+
* to grade what the run proposes (learning.ts gradeModelOf: --grade-model, else AGENTRUN_SERVE_GRADE_MODEL, else
|
|
49
|
+
* AGENT_MODEL_STRONG), absent when it names none and the agent's own grades it; and `seedFailed`, why it starts with
|
|
50
|
+
* nothing learned when it does (SeedFailed). Absent when the run does not learn. */
|
|
44
51
|
readonly learning?: {
|
|
45
52
|
readonly given: readonly {
|
|
46
53
|
readonly file: string;
|
|
@@ -49,6 +56,9 @@ export interface RunLaunch {
|
|
|
49
56
|
readonly seed: string | null;
|
|
50
57
|
readonly section: string;
|
|
51
58
|
readonly seedNotes?: number;
|
|
59
|
+
readonly skills?: readonly string[];
|
|
60
|
+
readonly gradeModel?: string;
|
|
61
|
+
readonly seedFailed?: SeedFailed;
|
|
52
62
|
};
|
|
53
63
|
/** The trigger and firing that started the run, or none for a person's run. */
|
|
54
64
|
readonly trigger?: RunTrigger;
|
|
@@ -70,3 +80,10 @@ export declare function readLaunchBody(stored: unknown): RunLaunch | undefined;
|
|
|
70
80
|
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
71
81
|
* routes and the runner; undefined when the run does not learn. */
|
|
72
82
|
export declare const learningStartOf: (launch: RunLaunch) => RunLaunch["learning"];
|
|
83
|
+
/** Why a learning run starts with nothing learned, as main says it: its agent's learning folder could not be read
|
|
84
|
+
* (`unreadable`, STOPPED.unreadable), or what was read could not be made into its start (`not_copied`,
|
|
85
|
+
* STOPPED.notCopied). */
|
|
86
|
+
export type SeedFailed = "unreadable" | "not_copied";
|
|
87
|
+
/** A learning start with no seed (no commit of main, runs-over-store.ts learningStartFor): the run learns nothing, is
|
|
88
|
+
* never asked what to keep, and so is never told it learns. Why is its `seedFailed`, when its start records one. */
|
|
89
|
+
export declare const seedFailed: (start: NonNullable<RunLaunch["learning"]>) => boolean;
|
package/dist/run-launch.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// The input's origin keeps its fail-safe on read (#1856): a run started by a trigger keeps an origin only when it names
|
|
7
7
|
// the run's own trigger with owner === (the source is a schedule, whose words its owner wrote when they set it up), else
|
|
8
8
|
// that trigger's own with owner false, so a forged or lost origin never reads as the person's or the owner's.
|
|
9
|
-
import { originOf } from "
|
|
9
|
+
import { originOf } from "./timeline/index.js";
|
|
10
10
|
import { isObject } from "./validate.js";
|
|
11
11
|
/** The trigger a launch body names, as read back: `{ id, firing_key }`, or null (triggerOf of the old serve.json). */
|
|
12
12
|
function readTrigger(value) {
|
|
@@ -54,22 +54,25 @@ export function launchBody(launch) {
|
|
|
54
54
|
...(launch.approvers !== undefined ? { approvers: launch.approvers } : {}),
|
|
55
55
|
...(launch.documents !== undefined ? { documents: launch.documents } : {}),
|
|
56
56
|
...(launch.boxAllow !== undefined ? { box_allow: launch.boxAllow } : {}),
|
|
57
|
+
...(launch.boxAllowSet ? { box_allow_set: true } : {}),
|
|
57
58
|
...(launch.files?.length ? { files: launch.files } : {}),
|
|
58
|
-
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}) } } : {}),
|
|
59
|
+
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}) } } : {}),
|
|
59
60
|
...(launch.trigger ? { trigger: launch.trigger } : {}),
|
|
60
61
|
...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
|
|
61
62
|
...(launch.followUp ? { follow_up: true } : {}),
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
/** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha
|
|
65
|
-
* section text,
|
|
65
|
+
/** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha, its # Learned
|
|
66
|
+
* section text, the learned skills it was offered, its grade model and why its seed failed, or undefined when the body
|
|
67
|
+
* names none (a run that does not learn). */
|
|
66
68
|
function readLearning(value) {
|
|
67
69
|
if (!isObject(value))
|
|
68
70
|
return undefined;
|
|
69
71
|
const given = Array.isArray(value.given) ? value.given.flatMap((note) => (isObject(note) && typeof note.file === "string" && typeof note.name === "string" ? [{ file: note.file, name: note.name }] : [])) : [];
|
|
70
72
|
const seed = typeof value.seed === "string" ? value.seed : null;
|
|
71
73
|
const section = typeof value.section === "string" ? value.section : "";
|
|
72
|
-
|
|
74
|
+
const skills = Array.isArray(value.skills) ? value.skills.filter((name) => typeof name === "string") : [];
|
|
75
|
+
return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}), ...(skills.length ? { skills } : {}), ...(typeof value.gradeModel === "string" && value.gradeModel !== "" ? { gradeModel: value.gradeModel } : {}), ...(typeof value.seedFailed === "string" && SEED_FAILURES.includes(value.seedFailed) ? { seedFailed: value.seedFailed } : {}) };
|
|
73
76
|
}
|
|
74
77
|
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
75
78
|
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
@@ -96,6 +99,7 @@ export function readLaunchBody(stored) {
|
|
|
96
99
|
...(typeof stored.approvers === "boolean" ? { approvers: stored.approvers } : {}),
|
|
97
100
|
...(typeof stored.documents === "string" ? { documents: stored.documents } : {}),
|
|
98
101
|
...(boxAllow !== undefined ? { boxAllow } : {}),
|
|
102
|
+
...(stored.box_allow_set === true ? { boxAllowSet: true } : {}),
|
|
99
103
|
...(Array.isArray(stored.files) && stored.files.every((id) => typeof id === "string") ? { files: stored.files } : {}),
|
|
100
104
|
...(stored.learning !== undefined ? { learning: readLearning(stored.learning) ?? { given: [], seed: null, section: "" } } : {}),
|
|
101
105
|
...(trigger ? { trigger } : {}),
|
|
@@ -106,3 +110,7 @@ export function readLaunchBody(stored) {
|
|
|
106
110
|
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
107
111
|
* routes and the runner; undefined when the run does not learn. */
|
|
108
112
|
export const learningStartOf = (launch) => launch.learning;
|
|
113
|
+
const SEED_FAILURES = ["unreadable", "not_copied"];
|
|
114
|
+
/** A learning start with no seed (no commit of main, runs-over-store.ts learningStartFor): the run learns nothing, is
|
|
115
|
+
* never asked what to keep, and so is never told it learns. Why is its `seedFailed`, when its start records one. */
|
|
116
|
+
export const seedFailed = (start) => start.seed === null;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type ItemStatus } from "./learning.js";
|
|
1
2
|
import { type SignInReader } from "./run-view.js";
|
|
2
3
|
import type { Store } from "./store/store.js";
|
|
3
4
|
/** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
|
|
4
5
|
export declare function servedRunLearning(deps: {
|
|
5
6
|
serverSecrets: () => string[];
|
|
6
7
|
signIns?: SignInReader;
|
|
8
|
+
statuses?: (agentId: string) => Promise<ReadonlyMap<string, ItemStatus> | undefined>;
|
|
7
9
|
}, store: Store, runId: string): Promise<{
|
|
8
10
|
seed: string | null;
|
|
9
11
|
merged: string | null;
|
|
@@ -23,7 +25,11 @@ export declare function servedRunLearning(deps: {
|
|
|
23
25
|
keep: boolean;
|
|
24
26
|
}[];
|
|
25
27
|
} | null;
|
|
26
|
-
problems:
|
|
28
|
+
problems: {
|
|
29
|
+
detail: string;
|
|
30
|
+
path?: string | undefined;
|
|
31
|
+
rule: import("./learn/check.js").Rule;
|
|
32
|
+
}[];
|
|
27
33
|
cost_usd: {
|
|
28
34
|
grade: number | null;
|
|
29
35
|
};
|
|
@@ -37,12 +43,12 @@ export declare function servedRunLearning(deps: {
|
|
|
37
43
|
workflows?: import("./learning.js").LearnedFile[];
|
|
38
44
|
run: string;
|
|
39
45
|
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
40
|
-
reason: "empty" | "
|
|
46
|
+
reason: "empty" | "cancelled" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
41
47
|
detail: string | null;
|
|
42
48
|
at: string;
|
|
43
49
|
} | null>;
|
|
44
|
-
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut
|
|
45
|
-
*
|
|
50
|
+
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut as its
|
|
51
|
+
* learning is, or ApiError forbidden for a withheld run. */
|
|
46
52
|
export declare function servedRunDiff(deps: {
|
|
47
53
|
serverSecrets: () => string[];
|
|
48
54
|
signIns?: SignInReader;
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
// GET /runs/{id}/learning over the store: the run's learning view (store-reads/learning.ts
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// GET /runs/{id}/learning and GET /runs/{id}/learning/diff over the store: the run's learning view (store-reads/learning.ts
|
|
2
|
+
// runLearningOverStore) and its learning diff (learning-routes.ts runDiffOverStore), each cut by the run's one cut
|
|
3
|
+
// (run-cut.ts) as its words are: every secret this server keeps and every sign-in pointer the run was handed, and every
|
|
4
|
+
// pointer of its agent's own sign-ins, live and forgotten (agentPointers), as the agent's learning routes cut them, so a
|
|
5
|
+
// note's name, a patch or a proposal's words holding one shows none of it. A run whose hand can't be read back here is
|
|
6
|
+
// refused (403, in the view's words), as its graph and its files are; so is one whose agent's sign-in can't be.
|
|
5
7
|
import { ApiError } from "./errors.js";
|
|
8
|
+
import { agentPointers, WITHHELD_LEARNING } from "./handed-values.js";
|
|
6
9
|
import { secretsShown } from "./learning.js";
|
|
7
10
|
import { runCutValues } from "./run-cut.js";
|
|
8
11
|
import { WITHHELD_SIGN_IN } from "./run-view.js";
|
|
9
12
|
import { runLearningOverStore } from "./store-reads/learning.js";
|
|
10
13
|
import { runDiffOverStore } from "./learning-routes.js";
|
|
11
|
-
/**
|
|
12
|
-
|
|
14
|
+
/** What run `runId`'s learning reads are cut of: the run's one cut and its agent's own sign-in pointers. ApiError forbidden
|
|
15
|
+
* for a withheld run, and for one whose agent has a pointer that can't be read here (its learning may hold it). */
|
|
16
|
+
async function learningCutOf(deps, store, runId) {
|
|
13
17
|
const cut = await runCutValues(deps, store, runId);
|
|
14
18
|
if (cut === "unreadable")
|
|
15
19
|
throw new ApiError("forbidden", WITHHELD_SIGN_IN);
|
|
16
|
-
|
|
20
|
+
const agentId = (await store.runs.get(runId))?.agentId;
|
|
21
|
+
const pointers = agentId ? await agentPointers(deps.signIns, agentId) : [];
|
|
22
|
+
if (pointers === "unreadable")
|
|
23
|
+
throw new ApiError("forbidden", WITHHELD_LEARNING);
|
|
24
|
+
return [...cut.values, ...pointers];
|
|
25
|
+
}
|
|
26
|
+
/** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
|
|
27
|
+
export async function servedRunLearning(deps, store, runId) {
|
|
28
|
+
const values = await learningCutOf(deps, store, runId);
|
|
29
|
+
return runLearningOverStore(store, runId, secretsShown(values), values, deps.statuses);
|
|
17
30
|
}
|
|
18
|
-
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut
|
|
19
|
-
*
|
|
31
|
+
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut as its
|
|
32
|
+
* learning is, or ApiError forbidden for a withheld run. */
|
|
20
33
|
export async function servedRunDiff(deps, store, data, runId) {
|
|
21
|
-
|
|
22
|
-
if (cut === "unreadable")
|
|
23
|
-
throw new ApiError("forbidden", WITHHELD_SIGN_IN);
|
|
24
|
-
return runDiffOverStore(data, store, runId, secretsShown(cut.values));
|
|
34
|
+
return runDiffOverStore(data, store, runId, secretsShown(await learningCutOf(deps, store, runId)));
|
|
25
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import type { TimelineEvent } from "
|
|
2
|
+
import type { TimelineEvent } from "./timeline/index.js";
|
|
3
3
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
4
4
|
import { type Page } from "./rows.js";
|
|
5
5
|
import { type FileView } from "./run-files.js";
|
|
@@ -6,7 +6,8 @@ import { costOf, WITHHELD_SIGN_IN } from "./run-view.js";
|
|
|
6
6
|
import { ChangeClock, RowLog } from "./rows.js";
|
|
7
7
|
import { listFiles, sendFile } from "./run-files.js";
|
|
8
8
|
import { readLaunchBody } from "./run-launch.js";
|
|
9
|
-
import {
|
|
9
|
+
import { costIsBooked } from "./runner/metrics.js";
|
|
10
|
+
import { runEntries, runTimeline } from "./store-reads/journal.js";
|
|
10
11
|
import { StoreLaunchMissing } from "./store/index.js";
|
|
11
12
|
import { isUnavailable, recheckPlane, whyUnavailable } from "./tool-plane.js";
|
|
12
13
|
/** The most files a list answers with (server.ts FILE_LIST_CAP). */
|
|
@@ -79,8 +80,12 @@ export async function runGraphView(store, runId, deps) {
|
|
|
79
80
|
const status = String(view.status);
|
|
80
81
|
const ended = view.ended_at !== null;
|
|
81
82
|
const launch = await store.runs.launch(runId).then((row) => readLaunchBody(row.body), (error) => (error instanceof StoreLaunchMissing ? undefined : Promise.reject(error)));
|
|
82
|
-
// The run's model-node cost from its rows once it ended (0 before), as the old graph read it from run.rows
|
|
83
|
+
// The run's model-node cost from its rows once it ended (0 before), as the old graph read it from run.rows: a workflow's
|
|
84
|
+
// usage row is its booking's (store-reads/journal.ts bookedUsage), its model nodes', its `llm` calls' and its paid
|
|
85
|
+
// tools', never its decisions', which the graph sums from their receipts. Its `llm` calls' answers are then all in it
|
|
86
|
+
// (llmRead), never counted again from the node log.
|
|
83
87
|
const rows = ended ? await runTimeline(store, runId, deps.context) : [];
|
|
88
|
+
const booked = ended && costIsBooked(await runEntries(store, runId, deps.context), false);
|
|
84
89
|
// Every field it serves is cut by the run's one cut (graph-served.ts servedGraphView): its nodes, decisions and calls by
|
|
85
90
|
// servedPart, and every other field (its workflow, its structure, any added later) whole.
|
|
86
91
|
const cut = await deps.cutValues(store, runId);
|
|
@@ -90,12 +95,11 @@ export async function runGraphView(store, runId, deps) {
|
|
|
90
95
|
run: { id: runId, agent: String(view.agent_id), revision: String(view.revision), status, paused: status === "paused", startedAt: String(view.created_at), endedAt: view.ended_at },
|
|
91
96
|
ended,
|
|
92
97
|
workflow,
|
|
93
|
-
// No
|
|
94
|
-
storeFile: "",
|
|
98
|
+
// No run directory now: the store and a context carry the journal the graph reads.
|
|
95
99
|
root: "",
|
|
96
100
|
input: launch?.input ?? {},
|
|
97
101
|
modelCost: ended ? costOf(rows) : 0,
|
|
98
|
-
llmRead: 0,
|
|
102
|
+
llmRead: booked ? Number.MAX_SAFE_INTEGER : 0,
|
|
99
103
|
store,
|
|
100
104
|
context: deps.context,
|
|
101
105
|
}), cut.values, graphParts);
|
|
@@ -120,9 +124,14 @@ export function runTimelines(deps) {
|
|
|
120
124
|
};
|
|
121
125
|
const pollMs = deps.pollMs ?? 1_000;
|
|
122
126
|
async function once(store, runId, after, limit) {
|
|
123
|
-
|
|
127
|
+
// The view first, then the rows, never both at once: the journal only grows, so the rows read after the view hold
|
|
128
|
+
// every entry its status was read from. Read together, a message committed between the two reads gave a page that
|
|
129
|
+
// said working before the message row it works on (#2307), or a waiting status with its parked call's row still
|
|
130
|
+
// missing. The rows may run ahead of the status, never behind it.
|
|
131
|
+
const view = await deps.runView(store, runId);
|
|
124
132
|
if (!view)
|
|
125
133
|
throw new ApiError("not_found", `There is no run ${runId}.`);
|
|
134
|
+
const rows = await deps.timelineRows(store, runId, deps.context);
|
|
126
135
|
const status = String(view.status);
|
|
127
136
|
const state = String(view.state);
|
|
128
137
|
const log = logOf(runId);
|
package/dist/run-secrets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Revision } from "
|
|
1
|
+
import type { Revision } from "./agent-rows.js";
|
|
2
2
|
import { type Tier } from "./model.js";
|
|
3
3
|
/** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
|
|
4
4
|
export declare const RUN_SECRETS: string[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import { type TimelineEvent } from "
|
|
2
|
+
import { type TimelineEvent } from "./timeline/index.js";
|
|
3
|
+
import { type ItemStatus } from "./learning.js";
|
|
3
4
|
import { type SignInReader } from "./run-view.js";
|
|
4
5
|
import { type Store } from "./store/store.js";
|
|
5
6
|
export type ServedTimelineDeps = {
|
|
@@ -7,6 +8,9 @@ export type ServedTimelineDeps = {
|
|
|
7
8
|
readonly signIns?: SignInReader;
|
|
8
9
|
/** The environment a run's model key is read from, with the keys a person saved (withSecrets, as main's plainKey). */
|
|
9
10
|
readonly keyEnv: () => NodeJS.ProcessEnv;
|
|
11
|
+
/** Each learned item's status on an agent's learning folder's main (learning-routes.ts statusesOf): what a run held for
|
|
12
|
+
* its owner's OK reads as it stands there. None: as the merge wrote it. */
|
|
13
|
+
readonly statuses?: (agentId: string) => Promise<ReadonlyMap<string, ItemStatus> | undefined>;
|
|
10
14
|
};
|
|
11
15
|
/** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
|
|
12
16
|
* run's error's words; none for a run withheld. */
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { TRIGGER_LABELS } from "
|
|
1
|
+
import { TRIGGER_LABELS } from "./timeline/index.js";
|
|
2
2
|
import { withDecisions } from "./decision-rows.js";
|
|
3
|
+
import { currentLearning, holdsForOk, secretsShown } from "./learning.js";
|
|
4
|
+
import { withLearning } from "./learning-run.js";
|
|
5
|
+
import { runLearningEnd } from "./store-reads/learning.js";
|
|
3
6
|
import { redacted } from "./key-refusal.js";
|
|
4
7
|
import { runCutValues, runErrorWordsOf } from "./run-cut.js";
|
|
5
8
|
import { answersOf, asksOf, shownOf, withApprovalRows, withAsks } from "./run-view.js";
|
|
@@ -28,7 +31,9 @@ export async function servedTimelineRows(deps, store, runId, context) {
|
|
|
28
31
|
// the run's view carries it and main's served Timeline did, so the console's "The agent asks" box reads that question,
|
|
29
32
|
// never an earlier wait's words.
|
|
30
33
|
// Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
|
|
31
|
-
|
|
34
|
+
// A run that ended is read settled, as its view reads it: nothing of it is in flight, so a request it left unanswered
|
|
35
|
+
// is a cost unknown, never one still running.
|
|
36
|
+
const options = { redact, settled: ended };
|
|
32
37
|
const timeline = await wholeAnswers(store, runId, context, await runTimeline(store, runId, context, options), options, wholeAnswerFor(values));
|
|
33
38
|
const rows = withApprovalRows(withAsks(timeline), asksOf(records.entries), answersOf(records.entries, { final }), redact);
|
|
34
39
|
// A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
|
|
@@ -42,14 +47,20 @@ export async function servedTimelineRows(deps, store, runId, context) {
|
|
|
42
47
|
const words = await runErrorWordsOf(deps, store, runId, { workflow });
|
|
43
48
|
if (words === "unreadable")
|
|
44
49
|
return [];
|
|
50
|
+
// The run's learning row, once its learning was proposed, merged or dropped (learning-run.ts withLearning, main's row):
|
|
51
|
+
// its end from the store (runLearningEnd), what it held for the owner's OK read as the run's view reads it (on its agent's
|
|
52
|
+
// folder's main), its words cut by the same set.
|
|
53
|
+
const end = await runLearningEnd(store, runId);
|
|
54
|
+
const learning = end ? (holdsForOk(end) && run && deps.statuses ? currentLearning(end, await deps.statuses(run.agentId)) : end) : undefined;
|
|
55
|
+
const learned = withLearning(own, learning, secretsShown(values));
|
|
45
56
|
// Each trigger the rows name, read once for this read: its name now, or none for one gone.
|
|
46
57
|
const names = new Map();
|
|
47
|
-
for (const row of
|
|
58
|
+
for (const row of learned)
|
|
48
59
|
if (row.trigger && !names.has(row.trigger.id))
|
|
49
60
|
names.set(row.trigger.id, (await store.triggers.get(row.trigger.id))?.name);
|
|
50
61
|
// A refused key's plain words are its summary and its text alike; any other error keeps each in the one rule.
|
|
51
62
|
const shown = shownOf(values);
|
|
52
|
-
return
|
|
63
|
+
return learned.map((row) => {
|
|
53
64
|
if (row.trigger)
|
|
54
65
|
return named(row, names.get(row.trigger.id), redact);
|
|
55
66
|
if (row.kind !== "error")
|
package/dist/run-view.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { type TimelineEvent } from "
|
|
2
|
-
import type { RevisionKind } from "
|
|
1
|
+
import { type TimelineEvent } from "./timeline/index.js";
|
|
2
|
+
import type { RevisionKind } from "./agent-rows.js";
|
|
3
3
|
import { type RefusalFigures } from "./cap.js";
|
|
4
4
|
import type { Turns } from "./turns.js";
|
|
5
5
|
import type { PendingAsk } from "./browser-person.js";
|
|
6
6
|
import { type PendingApproval } from "./tool-gate.js";
|
|
7
|
-
import { type
|
|
7
|
+
import { type signInReads } from "./sign-ins-store.js";
|
|
8
8
|
/** The sign-in read surface a run's served view needs: a run's handed-pointer cut reads only `peek` (the agent's saved
|
|
9
|
-
* pointer) and `forgotten` (its tombstoned ones)
|
|
10
|
-
|
|
11
|
-
export type SignInReader = Pick<SignIns, "peek" | "forgotten">;
|
|
9
|
+
* pointer) and `forgotten` (its tombstoned ones), over the store (sign-ins-store.ts signInReads). */
|
|
10
|
+
export type SignInReader = ReturnType<typeof signInReads>;
|
|
12
11
|
/** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
|
|
13
12
|
export declare const costOf: (rows: readonly TimelineEvent[]) => number | null;
|
|
14
13
|
/** What a run's paid tools charged (`tool`'s alone, when given; every other tool's with `others`), from the same rows its
|
|
@@ -184,7 +183,7 @@ export interface RunFacts {
|
|
|
184
183
|
budgetWaiting(): boolean;
|
|
185
184
|
/** A workflow run paused in its process (pausedIn(run.dir)). */
|
|
186
185
|
paused(): boolean;
|
|
187
|
-
/** The ask its agent made for the person in its browser the run waits on (
|
|
186
|
+
/** The ask its agent made for the person in its browser the run waits on (browser-commands.ts browserAsk, over its journal). */
|
|
188
187
|
browserAsk(): PendingAsk | undefined;
|
|
189
188
|
/** The ask its agent made for the person on its desktop or phone the run waits on (computer-commands.ts computerAsk). */
|
|
190
189
|
computerAsk?(): ComputerAsk | undefined;
|
|
@@ -378,7 +377,7 @@ export declare const servedRunErrorWith: <E extends {
|
|
|
378
377
|
export declare const servedReviewWith: <R extends {
|
|
379
378
|
reason: string;
|
|
380
379
|
}>(shown: (text: string) => string, unshown: boolean | undefined, review: R | null) => R | null;
|
|
381
|
-
/** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its `sign_in_handed`: none
|
|
380
|
+
/** The pointers a run was handed, read back to cut them (sign-ins-store.ts peek and forgotten), by its `sign_in_handed`: none
|
|
382
381
|
* for a run with no mark (it was never handed one); else, for each hash it names, the live or forgotten pointer whose
|
|
383
382
|
* SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED mark, no vendor browser kept
|
|
384
383
|
* beside the mark, the sign-ins file can't be read, or any of its hashes matches no pointer that opens (one under another
|
package/dist/run-view.js
CHANGED
|
@@ -6,16 +6,17 @@
|
|
|
6
6
|
// The pieces here so far: the cost reads (a run's cost, its paid tools' charges, the cost a view shows, what it has cost so
|
|
7
7
|
// far when the total is unknown) and the served row transforms a view applies to the timeline (the over-cap row, the
|
|
8
8
|
// paused run's waiting row). All read the same rows the timeline renders.
|
|
9
|
-
import { chargedTool, isMessageRow, registerLabel, registerTurnEnding, scrubUrls } from "
|
|
9
|
+
import { chargedTool, isMessageRow, registerLabel, registerTurnEnding, scrubUrls } from "./timeline/index.js";
|
|
10
10
|
import { CAP_TOLERANCE, FIT_TOLERANCE, money, roomRefusal } from "./cap.js";
|
|
11
11
|
import { APPROVAL_ROW, previewOf } from "./tool-gate.js";
|
|
12
12
|
import { ASK_TOOL } from "./tools.js";
|
|
13
13
|
import { LEARNING_LABEL } from "./learning.js";
|
|
14
14
|
import { builtinHarness } from "./harness-table.js";
|
|
15
15
|
import { cutStrings, redacted, withoutLoopback } from "./key-refusal.js";
|
|
16
|
-
import { pointerHash } from "./sign-ins.js";
|
|
16
|
+
import { pointerHash } from "./sign-ins-store.js";
|
|
17
17
|
import { MIN_SECRET } from "./learn/secrets.js";
|
|
18
18
|
import { KINDS } from "./runner/journal-kinds.js";
|
|
19
|
+
import { ENDED_WHILE_WAITING, STOPPED_WHILE_WAITING } from "./refusal-words.js";
|
|
19
20
|
/** The run's newest usage row, which carries its cost. */
|
|
20
21
|
const usageOf = (rows) => rows.findLast((r) => r.kind === "usage");
|
|
21
22
|
/** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
|
|
@@ -168,7 +169,7 @@ export function answersOf(entries, { final } = {}) {
|
|
|
168
169
|
if (decision === undefined)
|
|
169
170
|
continue;
|
|
170
171
|
const given = out[d.callId];
|
|
171
|
-
if (given && !(decision === "withdrawn" && d.superseded))
|
|
172
|
+
if (given && !((decision === "withdrawn" || decision === "canceled") && d.superseded))
|
|
172
173
|
continue;
|
|
173
174
|
const superseded = given ? { superseded: { decision: given.decision, answered_at: given.answered_at, ...(given.note !== undefined ? { note: given.note } : {}), ...(given.by ? { by: given.by } : {}) } } : {};
|
|
174
175
|
// A deny a person's message gave keeps that it was (`by`): its row reads "Declined by your message".
|
|
@@ -477,7 +478,7 @@ export const servedRunErrorWith = (shown, error) => ({ ...error, message: shown(
|
|
|
477
478
|
/** A run's review as its view serves it: its reason (an escalation's own words) in `shown`'s terms, or withheld as its
|
|
478
479
|
* other words are while the run is hidden (`unshown`), as a list row read from disk withholds it. */
|
|
479
480
|
export const servedReviewWith = (shown, unshown, review) => (review && { ...review, reason: unshown ? WITHHELD_SIGN_IN : shown(review.reason) });
|
|
480
|
-
/** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its `sign_in_handed`: none
|
|
481
|
+
/** The pointers a run was handed, read back to cut them (sign-ins-store.ts peek and forgotten), by its `sign_in_handed`: none
|
|
481
482
|
* for a run with no mark (it was never handed one); else, for each hash it names, the live or forgotten pointer whose
|
|
482
483
|
* SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED mark, no vendor browser kept
|
|
483
484
|
* beside the mark, the sign-ins file can't be read, or any of its hashes matches no pointer that opens (one under another
|
|
@@ -556,7 +557,7 @@ function callSays(answer) {
|
|
|
556
557
|
if (answer.decision === "canceled")
|
|
557
558
|
return "Not run: the run was cancelled while it waited";
|
|
558
559
|
if (answer.decision === "withdrawn")
|
|
559
|
-
return answer.ended ?
|
|
560
|
+
return answer.ended ? ENDED_WHILE_WAITING : STOPPED_WHILE_WAITING;
|
|
560
561
|
return "Allowed: it runs now";
|
|
561
562
|
}
|
|
562
563
|
/** A synthesized row's id: the approval's own, so a pass over rows this function gave drops and remakes it. */
|
|
@@ -578,7 +579,13 @@ export function withApprovalRows(rows, asks, answers, redact) {
|
|
|
578
579
|
for (const row of given)
|
|
579
580
|
if (owns(row))
|
|
580
581
|
lastOf.set(row.tool_use_id, row.id);
|
|
582
|
+
// The result rows of the calls that waited: a Saved row read from such a call's write (pi's `<result>:saved:<n>`) says
|
|
583
|
+
// a file was written that the park never wrote; an allowed call's file is its outcome row's to say, as on main.
|
|
584
|
+
const waitedResults = new Set(given.filter((row) => row.kind === "tool_result" && owns(row)).map((row) => row.id));
|
|
581
585
|
return given.flatMap((row) => {
|
|
586
|
+
const savedBy = row.kind === "phase" ? /^(.*):saved:\d+$/.exec(row.id)?.[1] : undefined;
|
|
587
|
+
if (savedBy !== undefined && waitedResults.has(savedBy))
|
|
588
|
+
return [];
|
|
582
589
|
if (!owns(row))
|
|
583
590
|
return [row];
|
|
584
591
|
const approval = byCall.get(row.tool_use_id);
|
|
@@ -590,13 +597,25 @@ export function withApprovalRows(rows, asks, answers, redact) {
|
|
|
590
597
|
if (lastOf.get(approval.call_id) !== row.id)
|
|
591
598
|
return [own];
|
|
592
599
|
const args = shownArgs(approval, redact);
|
|
600
|
+
// A served row keeps the place it was first served at (rows.ts). The call's result comes in after the answer (the park
|
|
601
|
+
// writes none), so the approval and outcome rows take a new id once it is there: served anew below the result, the
|
|
602
|
+
// call's own rows, then its approval, then what came of it, as a person reads it.
|
|
603
|
+
const at = result ? `${approvalRowId(approval.call_id)}:after` : approvalRowId(approval.call_id);
|
|
593
604
|
const head = !answer ? "Waiting for your approval" : answer.decision === "canceled" ? "Withdrawn when the run was cancelled" : answer.decision === "withdrawn" ? (answer.ended ? "Withdrawn when the run ended" : "Withdrawn when the run was stopped") : answer.by === "message" ? "Declined by your message" : "Asked your approval";
|
|
594
|
-
const asked = { ...row, id:
|
|
605
|
+
const asked = { ...row, id: at, kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
|
|
595
606
|
if (!outcome)
|
|
596
607
|
return [own, asked];
|
|
597
608
|
const failed = answer.decision === "allow" && result?.tool_status === "failed";
|
|
598
609
|
// The result's words: a tool_result row keeps them as its preview (the renderer's, redacted and cut), its text empty.
|
|
599
|
-
const told = { ...(result ?? row), id: `${
|
|
610
|
+
const told = { ...(result ?? row), id: `${at}:outcome`, kind: "phase", origin: "server", summary: outcomeSays(approval.tool, answer, failed, redact), text: outcomeShows(approval.tool, answer, redact(result?.text || result?.tool_result_preview || ""), failed), tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
|
|
611
|
+
// A person's message that declined the call (runs-over-store.ts message: a deny carrying their words) is theirs as any
|
|
612
|
+
// message is: its own row, between the approval and what came of it, as main's declineBy kept it.
|
|
613
|
+
if (answer.decision === "deny" && answer.by === "message" && answer.note) {
|
|
614
|
+
const words = redact(answer.note);
|
|
615
|
+
const { origin: _origin, ...base } = result ?? row;
|
|
616
|
+
const theirs = { ...base, id: `${at}:message`, kind: "user_message", summary: clip(`You: ${words.split("\n", 1)[0]}`, 500), text: words, tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
|
|
617
|
+
return [own, asked, theirs, told];
|
|
618
|
+
}
|
|
600
619
|
return [own, asked, told];
|
|
601
620
|
});
|
|
602
621
|
}
|