@parcha/agentrun-serve 0.1.0-beta.32 → 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 +270 -0
- package/README.md +343 -246
- package/dist/adapters.d.ts +0 -7
- package/dist/adapters.js +11 -22
- 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 +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +26 -0
- package/dist/box-settings.js +63 -0
- package/dist/boxes.d.ts +21 -1
- 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 +94 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -53
- package/dist/browser-person.js +94 -279
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +8 -12
- package/dist/cap.js +12 -27
- package/dist/cli.js +61 -20
- 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 +31 -3
- 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/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- 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/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -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 -11
- package/dist/files.js +2 -21
- package/dist/github-connection.d.ts +2 -2
- package/dist/github-connection.js +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 +22 -5
- package/dist/harness-install.js +98 -20
- 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/harness.d.ts +4 -3
- package/dist/harness.js +16 -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 +62 -24
- 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 +8 -1
- package/dist/learn/secrets.js +95 -15
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +37 -5
- package/dist/learned-workflow.js +106 -12
- package/dist/learning-routes.d.ts +16 -49
- package/dist/learning-routes.js +46 -36
- package/dist/learning-run.d.ts +6 -250
- package/dist/learning-run.js +11 -665
- 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 +13 -3
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -52
- package/dist/mcp-gateway.js +44 -148
- 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 +13 -15
- 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 +124 -50
- package/dist/page.d.ts +1 -3
- package/dist/page.js +9 -19
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +28 -62
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- 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 -13
- package/dist/run-db.js +2 -41
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +46 -2
- package/dist/run-learning-served.js +26 -7
- 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 +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +19 -5
- package/dist/run-view.d.ts +12 -17
- package/dist/run-view.js +29 -28
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +14 -3
- package/dist/runner/adapter-loop.js +464 -62
- package/dist/runner/adapter-run-spec.d.ts +29 -8
- package/dist/runner/adapter-run-spec.js +96 -37
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +15 -1
- package/dist/runner/adapters/pi.js +19 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +54 -12
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +49 -15
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +60 -17
- 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 +30 -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/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +64 -10
- package/dist/runner/main.js +165 -27
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +2 -3
- 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 +154 -11
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- 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 +68 -26
- package/dist/runs-over-store.d.ts +8 -3
- package/dist/runs-over-store.js +76 -19
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +232 -82
- 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/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- 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 +10 -32
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -33
- package/dist/server.d.ts +26 -44
- package/dist/server.js +229 -142
- 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 +3 -3
- package/dist/store/index.js +3 -3
- package/dist/store/open.d.ts +18 -5
- package/dist/store/open.js +23 -3
- 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 +27 -3
- 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 +64 -20
- package/dist/store/store.d.ts +38 -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 +25 -6
- package/dist/store-reads/journal.js +173 -21
- 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 +91 -23
- 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 +9 -104
- package/dist/tool-keys.js +15 -271
- 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 +31 -19
- package/dist/tools.js +101 -108
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- 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 +52 -5
- package/dist/workspace/computer-deps.js +154 -19
- package/dist/workspace/computer-for-claim.d.ts +19 -14
- package/dist/workspace/computer-for-claim.js +77 -16
- 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/computer-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +4 -3
- package/dist/workspace/index.js +4 -4
- 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 -17
- package/dist/workspace.js +3 -99
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/README.md +9 -3
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- 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-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- 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/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -178
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
- 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
|
@@ -19,8 +19,8 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
|
19
19
|
import { dropPostgresSchema, openPostgresStore, openStore, RunFinal, StoreConstraint, storeTarget } from "../../store/index.js";
|
|
20
20
|
import { sendCommand } from "../commands.js";
|
|
21
21
|
import { callsOf, journalRecords, messagesOf } from "../journal-reader.js";
|
|
22
|
-
import { KINDS } from "../journal-kinds.js";
|
|
23
|
-
import { timelineReducer } from "
|
|
22
|
+
import { KINDS, MESSAGE_SENT_AGAIN } from "../journal-kinds.js";
|
|
23
|
+
import { timelineReducer } from "../../timeline/index.js";
|
|
24
24
|
import { emptyState, translate } from "../../live/translate.js";
|
|
25
25
|
/** The one row a person's stop gives on the live timeline (live/translate.ts STOPPED_BY_YOU), the same on every harness. */
|
|
26
26
|
const STOPPED_BY_YOU = "Stopped by you";
|
|
@@ -119,15 +119,15 @@ function crashAt(point, holder) {
|
|
|
119
119
|
return {
|
|
120
120
|
beforeIntent: async () => (point === "beforeIntent" ? crash() : undefined),
|
|
121
121
|
beforeResult: async () => (point === "beforeResult" ? crash() : undefined),
|
|
122
|
+
afterMessageSent: async () => (point === "afterMessageSent" ? crash() : undefined),
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
/** The Postgres store each registered subject's worlds open (registerHarnessConformance's `storeUrl`), by the subject
|
|
125
126
|
* object the suite's cases are handed: none for the data directory's SQLite store. */
|
|
126
127
|
const STORE_URLS = new WeakMap();
|
|
127
|
-
/** Cases a Postgres store can't pass yet, each with what it waits on: they run on SQLite and are skipped on Postgres.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
128
|
+
/** Cases a Postgres store can't pass yet, each with what it waits on: they run on SQLite and are skipped on Postgres. None
|
|
129
|
+
* today. */
|
|
130
|
+
const POSTGRES_PENDING = {};
|
|
131
131
|
/** A store in a data directory of its own, one queued run, and runners started on it (each its own connection). */
|
|
132
132
|
/** The suite's short lease, for the crash cases: a crashed runner's claim must run out for the second runner to take
|
|
133
133
|
* the run over. */
|
|
@@ -630,6 +630,88 @@ const CASES = [
|
|
|
630
630
|
assert.ok((await w.commandRow(steer.id)).takenAt !== null, "the steer row is taken");
|
|
631
631
|
},
|
|
632
632
|
},
|
|
633
|
+
{
|
|
634
|
+
id: "message-mid-turn-kept",
|
|
635
|
+
title: "messages sent mid-turn are never dropped: each is taken, in order, and the model answers each",
|
|
636
|
+
async body(subject, t) {
|
|
637
|
+
const w = await world(subject, t);
|
|
638
|
+
const { tools, letSlowGo, slowStarted } = suiteTools();
|
|
639
|
+
// A harness that steers places a message in the turn in flight (steer-mid-turn); one that does not (a CLI's: its
|
|
640
|
+
// adapter's facts say steer false) sends each as a turn of its own once the turn ends, in the order they came. Either
|
|
641
|
+
// way the model reads it, and its row is taken, never refused after the API accepted it (#2174).
|
|
642
|
+
const steers = subject.facts?.steer !== false;
|
|
643
|
+
const texts = steers ? ["check the totals"] : ["check the totals", "and the dates"];
|
|
644
|
+
// The model's steps: the call, then what it says after it (the steer it read, when it steers), then, for each message
|
|
645
|
+
// sent as a turn of its own, that message (the last the person sent).
|
|
646
|
+
const script = [{ call: "slow" }, { sayLastSteer: true }, ...(steers ? [] : texts.map(() => ({ sayLastSteer: true })))];
|
|
647
|
+
await w.start("runner-a", { script, tools, hooks: quiet });
|
|
648
|
+
await slowStarted;
|
|
649
|
+
const rows = [];
|
|
650
|
+
for (const text of texts)
|
|
651
|
+
rows.push(await sendCommand(w.server, RUN, { kind: "steer", body: { text } }));
|
|
652
|
+
// The tool goes on once every message is with the loop: the turn in flight has them, never a timer.
|
|
653
|
+
await until(() => rows.every((row) => w.handedOver(row.id)), "the messages handed to the loop mid-turn");
|
|
654
|
+
letSlowGo();
|
|
655
|
+
await w.ended("ended");
|
|
656
|
+
const { calls, messages } = await w.read();
|
|
657
|
+
const slow = calls.find((call) => call.tool === "slow");
|
|
658
|
+
assert.ok(slow?.endEntry !== undefined && slow.status === "done", `slow ran to its end: ${JSON.stringify(calls)}`);
|
|
659
|
+
const sent = texts.map((text) => messages.find((message) => message.role !== "model" && message.text === text));
|
|
660
|
+
assert.ok(sent.every((message) => message !== undefined), `each message is in the journal: ${JSON.stringify(messages)}`);
|
|
661
|
+
for (const [i, message] of sent.entries()) {
|
|
662
|
+
assert.ok(message.entry > slow.endEntry, `"${texts[i]}" comes after the call it was sent during: ${JSON.stringify(messages)}`);
|
|
663
|
+
if (i > 0)
|
|
664
|
+
assert.ok(message.entry > sent[i - 1].entry, `in the order they came: ${JSON.stringify(messages)}`);
|
|
665
|
+
const answered = messages.find((one) => one.role === "model" && one.entry > message.entry && one.text.includes(texts[i]));
|
|
666
|
+
assert.ok(answered, `the model answered "${texts[i]}": ${JSON.stringify(messages)}`);
|
|
667
|
+
}
|
|
668
|
+
for (const row of rows) {
|
|
669
|
+
const taken = await w.commandRow(row.id);
|
|
670
|
+
assert.ok(taken.takenAt !== null && taken.refused === null, `its row is taken, not refused: ${JSON.stringify(taken)}`);
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
id: "message-resent-after-crash",
|
|
676
|
+
title: "a message sent as its own turn by a runner lost before its row was taken is sent again by the next, and the timeline says so",
|
|
677
|
+
async body(subject, t) {
|
|
678
|
+
const w = await world(subject, t);
|
|
679
|
+
const { tools, letSlowGo, slowStarted } = suiteTools();
|
|
680
|
+
const text = "check the totals";
|
|
681
|
+
// The call, then the turn's words, then the message's turn (sent once by runner-a, again by runner-b), each saying
|
|
682
|
+
// the message it was given.
|
|
683
|
+
const script = [{ call: "slow" }, { sayLastSteer: true }, { sayLastSteer: true }, { sayLastSteer: true }];
|
|
684
|
+
const holder = {};
|
|
685
|
+
await w.start("runner-a", { script, tools, hooks: crashAt("afterMessageSent", holder) }, holder);
|
|
686
|
+
await slowStarted;
|
|
687
|
+
const row = await sendCommand(w.server, RUN, { kind: "steer", body: { text } });
|
|
688
|
+
await until(() => w.handedOver(row.id), "the message handed to the loop mid-turn");
|
|
689
|
+
letSlowGo();
|
|
690
|
+
// runner-a dies once the session holds the message, before the commit that records it and takes its row.
|
|
691
|
+
await until(() => holder.crashed, "the crash after the message was sent", EVENT_WAIT_MS);
|
|
692
|
+
assert.equal((await w.commandRow(row.id)).takenAt, null, "the row is untaken when runner-a is lost");
|
|
693
|
+
await w.claimsSettled("runner-a");
|
|
694
|
+
w.runOut();
|
|
695
|
+
await w.start("runner-b", { script, tools, hooks: quiet });
|
|
696
|
+
await w.ended("ended", EVENT_WAIT_MS);
|
|
697
|
+
const { messages } = await w.read();
|
|
698
|
+
const sent = messages.filter((message) => message.role !== "model" && message.text === text);
|
|
699
|
+
assert.ok(sent.length >= 1, `the message is on the record: ${JSON.stringify(messages)}`);
|
|
700
|
+
assert.ok(messages.some((message) => message.role === "model" && message.text.includes(text) && message.entry > sent[0].entry), `the model answered it: ${JSON.stringify(messages)}`);
|
|
701
|
+
const taken = await w.commandRow(row.id);
|
|
702
|
+
assert.ok(taken.takenAt !== null && taken.refused === null, `its row is taken once runner-b sent it: ${JSON.stringify(taken)}`);
|
|
703
|
+
// Never silent: the timeline says the message went again, once, before it.
|
|
704
|
+
const rows = await w.liveRows();
|
|
705
|
+
const again = rows.filter((one) => one.summary === MESSAGE_SENT_AGAIN);
|
|
706
|
+
const shown = JSON.stringify(rows.map((one) => [one.kind, one.summary]));
|
|
707
|
+
assert.deepEqual(again.map((one) => one.kind), ["phase"], `one row says it was sent again: ${shown}`);
|
|
708
|
+
// Just before the message it was said of: the person's row of it is the next message row.
|
|
709
|
+
const at = rows.indexOf(again[0]);
|
|
710
|
+
const message = rows.findIndex((one, i) => i > at && one.kind === "user_message");
|
|
711
|
+
assert.ok(message > at && rows[message].text === text, `the notice comes right before the message it was sent again: ${shown}`);
|
|
712
|
+
assert.ok(!rows.slice(0, at).some((one) => one.kind === "user_message" && one.text === text), `no row of the message before the notice: ${shown}`);
|
|
713
|
+
},
|
|
714
|
+
},
|
|
633
715
|
{
|
|
634
716
|
id: "stop-ends-turn",
|
|
635
717
|
title: "stop ends the turn; the run says why",
|
|
@@ -798,6 +880,31 @@ const CASES = [
|
|
|
798
880
|
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["asked", "done"]]);
|
|
799
881
|
},
|
|
800
882
|
},
|
|
883
|
+
{
|
|
884
|
+
id: "approval-race",
|
|
885
|
+
title: "an approve and a deny sent at once write one answer: the store refuses the other (one answer per approval), and the run acts on the one written",
|
|
886
|
+
async body(subject, t) {
|
|
887
|
+
const w = await world(subject, t);
|
|
888
|
+
const { tools, ran } = suiteTools();
|
|
889
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { say: "done" }], tools, hooks: quiet });
|
|
890
|
+
await w.ended("parked");
|
|
891
|
+
const callId = await w.askedCall();
|
|
892
|
+
// Both sent before either is awaited (on Postgres, each on its own pooled connection). Whichever is written first, the
|
|
893
|
+
// store's one-answer index refuses the other: no order is imposed, so the case holds for either winner.
|
|
894
|
+
const settled = await Promise.allSettled([
|
|
895
|
+
sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } }),
|
|
896
|
+
sendCommand(w.server, RUN, { kind: "deny", body: { approval: callId } }),
|
|
897
|
+
]);
|
|
898
|
+
const won = settled.filter((r) => r.status === "fulfilled");
|
|
899
|
+
const lost = settled.filter((r) => r.status === "rejected");
|
|
900
|
+
assert.equal(won.length, 1, `one answer is written, not both: ${JSON.stringify(settled.map((r) => r.status))}`);
|
|
901
|
+
assert.ok(lost[0]?.reason instanceof StoreConstraint, `the other is refused by the store: ${String(lost[0]?.reason)}`);
|
|
902
|
+
await w.ended("ended");
|
|
903
|
+
const winner = won[0].value;
|
|
904
|
+
assert.equal(ran.asked, winner.kind === "approve" ? 1 : 0, "the run acted on the answer written, never the other");
|
|
905
|
+
assert.equal((await w.commandRow(winner.id)).refused, null, "the answer written stands");
|
|
906
|
+
},
|
|
907
|
+
},
|
|
801
908
|
{
|
|
802
909
|
id: "message-never-answers",
|
|
803
910
|
title: "a message that answers nothing (a trigger's, answers: false) never answers a waiting call, whatever its words",
|
|
@@ -879,12 +986,13 @@ const CASES = [
|
|
|
879
986
|
},
|
|
880
987
|
},
|
|
881
988
|
];
|
|
989
|
+
const STEERS_IN_TURN = "it places a message sent mid-turn in the turn in flight, its row taken in its submission's commit, so it never sends one as a turn of its own (message-resent-after-crash)";
|
|
882
990
|
const CLI_NEVER_RERUNS = "a CLI never reruns a call that started; only the model calls again (its adapter's facts: rerunsStarted false)";
|
|
883
991
|
/** The cases a harness's declared facts rule out, each with why: what it does by design, not what it cannot model yet. */
|
|
884
992
|
export function factsRuleOut(facts) {
|
|
885
993
|
if (!facts)
|
|
886
994
|
return {};
|
|
887
|
-
const noSteer = `${facts.id} takes no message mid-turn (its adapter's facts: steer false), so
|
|
995
|
+
const noSteer = `${facts.id} takes no message mid-turn (its adapter's facts: steer false), so a message sent while it works is never placed in the turn in flight: it is the run's next turn (message-mid-turn-kept)`;
|
|
888
996
|
return {
|
|
889
997
|
// steer-origin steers the turn in flight too: its message is taken mid-turn, or never.
|
|
890
998
|
...(facts.steer ? {} : { "steer-mid-turn": noSteer, "steer-origin": noSteer }),
|
|
@@ -918,7 +1026,9 @@ export function registerHarnessConformance(given, { test, storeUrl }) {
|
|
|
918
1026
|
const ruledOut = factsRuleOut(subject.facts);
|
|
919
1027
|
for (const entry of CASES) {
|
|
920
1028
|
const processCase = entry.id.endsWith("-process");
|
|
921
|
-
|
|
1029
|
+
// A harness that steers (any whose facts do not say steer false, as message-mid-turn-kept reads them) places a message
|
|
1030
|
+
// in the turn in flight, its row taken in the commit of its submission: it never sends one as a turn of its own.
|
|
1031
|
+
const byFacts = ruledOut[entry.id] ?? (entry.id === "message-resent-after-crash" && subject.facts?.steer !== false ? STEERS_IN_TURN : undefined);
|
|
922
1032
|
const notYet = subject.unsupported?.[entry.id] ?? (processCase && !subject.process ? "it names no module a runner process can load (subject.process)" : undefined);
|
|
923
1033
|
const onPostgres = storeUrl ? POSTGRES_PENDING[entry.id] : undefined;
|
|
924
1034
|
const skip = byFacts ? `${subject.name} does not do this by design: ${byFacts}` : notYet ? `${subject.name} cannot model this yet: ${notYet}` : onPostgres ? `on Postgres, ${onPostgres}` : undefined;
|
|
@@ -46,6 +46,9 @@ export interface KernelHooks {
|
|
|
46
46
|
beforeBooking?(): Promise<void>;
|
|
47
47
|
/** The adapter loop waits for its session's paid requests to be booked (bookingsSettled, with one still unbooked). */
|
|
48
48
|
awaitingBookings?(): void;
|
|
49
|
+
/** A message taken mid-turn was sent as a turn of its own (the adapter loop's sendAfterTurn): the session holds it, and
|
|
50
|
+
* the commit that records it and takes its row has not run yet. */
|
|
51
|
+
afterMessageSent?(): Promise<void>;
|
|
49
52
|
}
|
|
50
53
|
export interface ConformanceSetup {
|
|
51
54
|
readonly script: readonly ScriptStep[];
|
|
@@ -54,7 +57,7 @@ export interface ConformanceSetup {
|
|
|
54
57
|
/** The run's agent, for the subject's spec to name (AdapterRunSpec.agentId): the end-of-run step is asked with it. */
|
|
55
58
|
readonly agentId?: string;
|
|
56
59
|
}
|
|
57
|
-
export type ConformanceCase = "crash-before-intent" | "crash-after-intent" | "crash-before-intent-process" | "crash-after-intent-process" | "stalled-past-lease-process" | "replay-safe-rerun" | "steer-mid-turn" | "cancel-ends-for-good" | "cancel-parked" | "deny-note" | "steer-origin" | "stop-ends-turn" | "park-on-ask" | "approval-names-its-call" | "approval-double-click" | "message-never-answers" | "end-of-run-answer" | "fault-effects-once" | "fault-restarts-bounded" | "length-ends-failed" | "length-mid-run";
|
|
60
|
+
export type ConformanceCase = "crash-before-intent" | "crash-after-intent" | "crash-before-intent-process" | "crash-after-intent-process" | "stalled-past-lease-process" | "replay-safe-rerun" | "steer-mid-turn" | "message-mid-turn-kept" | "message-resent-after-crash" | "cancel-ends-for-good" | "cancel-parked" | "deny-note" | "steer-origin" | "stop-ends-turn" | "park-on-ask" | "approval-names-its-call" | "approval-double-click" | "approval-race" | "message-never-answers" | "end-of-run-answer" | "fault-effects-once" | "fault-restarts-bounded" | "length-ends-failed" | "length-mid-run";
|
|
58
61
|
export interface ConformanceSubject {
|
|
59
62
|
/** The harness's name, as the suite's tests are titled. */
|
|
60
63
|
readonly name: string;
|
|
@@ -7,7 +7,7 @@ export interface DispatchDeps {
|
|
|
7
7
|
launchOf(runId: string): Promise<{
|
|
8
8
|
readonly body: unknown;
|
|
9
9
|
}>;
|
|
10
|
-
/** The loop factory for a run launched with `harness`, built from its `launch` record and its run id (so the
|
|
10
|
+
/** The loop factory for a run launched with `harness`, built from its `launch` record and its run id (so the resolver may
|
|
11
11
|
* read the run's revision — a workflow revision runs on the workflow loop whatever its harness name), or undefined when
|
|
12
12
|
* this runner does not run it (the run fails in words). pi is the adapter loop with adapterRunSpecFromLaunch; a built-in
|
|
13
13
|
* learning run names "learning"; the CLI harnesses name their own. May be async (the revision read). */
|
|
@@ -24,6 +24,13 @@ export declare class LaunchUnreadable extends Error {
|
|
|
24
24
|
name: string;
|
|
25
25
|
constructor(runId: string);
|
|
26
26
|
}
|
|
27
|
+
/** The first wait before a buffered row whose delivery threw is tried again, and the most any later wait (doubling)
|
|
28
|
+
* grows to. */
|
|
29
|
+
export declare const REPLAY_RETRY_FIRST_MS = 250;
|
|
30
|
+
export declare const REPLAY_RETRY_MAX_MS = 5000;
|
|
31
|
+
/** How many times in all a buffered row's delivery is tried before the dispatch stops trying it on this claim: a row that
|
|
32
|
+
* fails for a lasting reason is said once and left untaken for the run's next claim, never tried for the whole run. */
|
|
33
|
+
export declare const REPLAY_TRIES = 5;
|
|
27
34
|
/** The loop factory the runner holds for every run: `createDispatchLoop(deps)` picks each run's harness loop at its
|
|
28
35
|
* claim. The inner loop gets the same LoopDeps the dispatch does, so the runner's fence, flush, live and end-of-run
|
|
29
36
|
* channels reach it unchanged. */
|
package/dist/runner/dispatch.js
CHANGED
|
@@ -25,6 +25,13 @@ export class LaunchUnreadable extends Error {
|
|
|
25
25
|
super(`run ${runId}: its launch record could not be read as a launch (it names no place, or is not an object).`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
/** The first wait before a buffered row whose delivery threw is tried again, and the most any later wait (doubling)
|
|
29
|
+
* grows to. */
|
|
30
|
+
export const REPLAY_RETRY_FIRST_MS = 250;
|
|
31
|
+
export const REPLAY_RETRY_MAX_MS = 5_000;
|
|
32
|
+
/** How many times in all a buffered row's delivery is tried before the dispatch stops trying it on this claim: a row that
|
|
33
|
+
* fails for a lasting reason is said once and left untaken for the run's next claim, never tried for the whole run. */
|
|
34
|
+
export const REPLAY_TRIES = 5;
|
|
28
35
|
/** The loop factory the runner holds for every run: `createDispatchLoop(deps)` picks each run's harness loop at its
|
|
29
36
|
* claim. The inner loop gets the same LoopDeps the dispatch does, so the runner's fence, flush, live and end-of-run
|
|
30
37
|
* channels reach it unchanged. */
|
|
@@ -62,16 +69,83 @@ function dispatchLoop(deps, loopDeps) {
|
|
|
62
69
|
// buffered row and no buffered stop is lost between choosing the loop and replaying what was buffered.
|
|
63
70
|
inner = factory(innerDeps);
|
|
64
71
|
const end = inner.start(claim);
|
|
65
|
-
// Replay the buffered commands through the inner loop in order, each awaited, then let its `delivered` resolve.
|
|
72
|
+
// Replay the buffered commands through the inner loop in order, each awaited, then let its `delivered` resolve. A
|
|
73
|
+
// command whose delivery throws is never thrown out of here, where nothing would catch it and the runner's process
|
|
74
|
+
// would go down. The runner already moved past its row (the dispatch said it holds it), so the dispatch tries it again
|
|
75
|
+
// itself while the inner loop runs, as the runner tries again a row whose delivery threw (a store that failed for a
|
|
76
|
+
// moment), up to REPLAY_TRIES times. Once the inner loop has ended, or the tries are spent, a row still not delivered
|
|
77
|
+
// stays untaken (the store's take is the inner loop's own commit), so the run's next claim delivers it again and
|
|
78
|
+
// nobody's words are lost.
|
|
66
79
|
const buffered = early.splice(0);
|
|
67
|
-
void (
|
|
80
|
+
void replay(claim.runId, inner, buffered, end);
|
|
81
|
+
// The buffered stop, not awaited here (start() returns the inner loop's end): an inner stop that throws is said in
|
|
82
|
+
// the log, never an unhandled rejection, which would end the runner process and every run it holds.
|
|
83
|
+
if (earlyStop) {
|
|
84
|
+
inner.stop(earlyStop).catch((error) => {
|
|
85
|
+
const text = error?.message ?? String(error);
|
|
86
|
+
console.warn(`[runner] run ${claim.runId}: its stop failed: ${loopDeps.redact ? loopDeps.redact(text) : text}`);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return end;
|
|
90
|
+
}
|
|
91
|
+
/** Hands each of `buffered` to `loop` once, in order, then lets the loop's `delivered` resolve; the ones whose delivery
|
|
92
|
+
* threw are tried again, in order, until each goes through, the loop has ended, or a row has been tried REPLAY_TRIES
|
|
93
|
+
* times (said once; it and the failed rows after it are left untaken for the run's next claim). Never rejects. */
|
|
94
|
+
async function replay(runId, loop, buffered, end, tries = REPLAY_TRIES) {
|
|
95
|
+
let ended = false;
|
|
96
|
+
const loopEnded = end.then(() => undefined, () => undefined).then(() => void (ended = true));
|
|
97
|
+
let lastError;
|
|
98
|
+
const delivers = async (command) => {
|
|
99
|
+
try {
|
|
100
|
+
await loop.command(command);
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
lastError = error;
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
// What went wrong, cut of the values the run holds (LoopDeps.redact), as the log may not show them.
|
|
109
|
+
const why = () => {
|
|
110
|
+
const text = lastError?.message ?? String(lastError);
|
|
111
|
+
return loopDeps.redact ? loopDeps.redact(text) : text;
|
|
112
|
+
};
|
|
113
|
+
const failed = [];
|
|
114
|
+
try {
|
|
115
|
+
// Every row is tried once before the inner loop's `delivered` resolves, a later one even when an earlier one threw:
|
|
116
|
+
// a loop that waits on `delivered` (a run reopened by a follow-up) never goes on with a row still held here.
|
|
68
117
|
for (const command of buffered)
|
|
69
|
-
await
|
|
118
|
+
if (!(await delivers(command)))
|
|
119
|
+
failed.push(command);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
70
122
|
replayed();
|
|
71
|
-
}
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
123
|
+
}
|
|
124
|
+
if (failed.length === 0)
|
|
125
|
+
return;
|
|
126
|
+
console.warn(`[runner] ${runId}: a ${failed[0].kind} row held before its loop was chosen was not delivered (${why()}); it is tried again while the loop runs, up to ${tries} times in all`);
|
|
127
|
+
// How many times the first row still to deliver has been tried: once, in the pass above.
|
|
128
|
+
let tried = 1;
|
|
129
|
+
for (let wait = REPLAY_RETRY_FIRST_MS; failed.length > 0 && !ended; wait = Math.min(wait * 2, REPLAY_RETRY_MAX_MS)) {
|
|
130
|
+
if (tried >= tries) {
|
|
131
|
+
console.warn(`[runner] ${runId}: a ${failed[0].kind} row held before its loop was chosen was tried ${tried} times and not delivered (${why()}); it and the ${failed.length - 1} after it are left untaken, for the run's next claim`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let timer;
|
|
135
|
+
await Promise.race([loopEnded, new Promise((resolve) => (timer = setTimeout(resolve, wait)))]);
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
if (ended)
|
|
138
|
+
break;
|
|
139
|
+
// The first row again; once it goes through, the rows after it at once, in order, until one throws.
|
|
140
|
+
while (failed.length > 0 && !ended) {
|
|
141
|
+
tried += 1;
|
|
142
|
+
if (!(await delivers(failed[0])))
|
|
143
|
+
break;
|
|
144
|
+
failed.shift();
|
|
145
|
+
// Every row left was tried once in the first pass.
|
|
146
|
+
tried = 1;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
75
149
|
}
|
|
76
150
|
return {
|
|
77
151
|
start(claim) {
|
|
@@ -10,12 +10,18 @@ export declare const reflectRequestId: (runId: string, again?: boolean) => strin
|
|
|
10
10
|
* is answered from its submission, never asked of the model twice. */
|
|
11
11
|
export declare const REFLECT_AGAIN = ":again";
|
|
12
12
|
/** Where the end-of-run turn began in a run's journal: the entry its input placed, from the input submission under the
|
|
13
|
-
* turn's request id;
|
|
14
|
-
*
|
|
13
|
+
* turn's request id; else, on a CLI harness, the turn's prompt the CLI record wrote as it asked the turn (`entries`:
|
|
14
|
+
* adapter-loop.ts asking, an end-of-run-turn entry of the person's, written before the turn's submission, which only
|
|
15
|
+
* its answer writes). Undefined before either, or for a run that asked none. Every entry from it on, until the run's
|
|
16
|
+
* end, is the turn's (the server's labelled: after the entry before it). */
|
|
15
17
|
export declare function reflectFrom(submissions: readonly {
|
|
16
18
|
readonly type?: string;
|
|
17
19
|
readonly requestId?: string;
|
|
18
20
|
readonly entry?: unknown;
|
|
21
|
+
}[], entries?: readonly {
|
|
22
|
+
readonly kind?: string;
|
|
23
|
+
readonly id?: unknown;
|
|
24
|
+
readonly data?: unknown;
|
|
19
25
|
}[]): number | undefined;
|
|
20
26
|
/** The refusal of the end-of-run turn's write or edit under work/.learning/: the tool gate's one text (NOTE_ONLY_TEXT), so
|
|
21
27
|
* the adapter loop's refusal and the gate's are the same words. */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// answer's note blocks, never from a file it writes there. The words and the rule are the tool gate's own
|
|
4
4
|
// (tool-gate.ts NOTE_ONLY_TEXT, underLearning), kept equal by a test.
|
|
5
5
|
import { posix, resolve, sep, join } from "node:path";
|
|
6
|
+
import { KINDS } from "./journal-kinds.js";
|
|
6
7
|
/** The prefix of the end-of-run turn's request id: the server's own (turns.ts REFLECT_REQUEST). */
|
|
7
8
|
export const REFLECT_PREFIX = "learn-reflect-";
|
|
8
9
|
/** The label a reader puts on the end-of-run turn's rows and messages: the server's (learning.ts LEARNING_LABEL). */
|
|
@@ -15,11 +16,16 @@ export const reflectRequestId = (runId, again = false) => `${REFLECT_PREFIX}${ru
|
|
|
15
16
|
* is answered from its submission, never asked of the model twice. */
|
|
16
17
|
export const REFLECT_AGAIN = ":again";
|
|
17
18
|
/** Where the end-of-run turn began in a run's journal: the entry its input placed, from the input submission under the
|
|
18
|
-
* turn's request id;
|
|
19
|
-
*
|
|
20
|
-
|
|
19
|
+
* turn's request id; else, on a CLI harness, the turn's prompt the CLI record wrote as it asked the turn (`entries`:
|
|
20
|
+
* adapter-loop.ts asking, an end-of-run-turn entry of the person's, written before the turn's submission, which only
|
|
21
|
+
* its answer writes). Undefined before either, or for a run that asked none. Every entry from it on, until the run's
|
|
22
|
+
* end, is the turn's (the server's labelled: after the entry before it). */
|
|
23
|
+
export function reflectFrom(submissions, entries = []) {
|
|
21
24
|
const placed = submissions.filter((record) => record.type === "input" && typeof record.requestId === "string" && record.requestId.startsWith(REFLECT_PREFIX) && record.entry !== undefined);
|
|
22
|
-
|
|
25
|
+
if (placed.length)
|
|
26
|
+
return Math.min(...placed.map((record) => Number(record.entry)));
|
|
27
|
+
const asked = entries.find((entry) => entry.kind === KINDS.endOfRunTurn && entry.data?.role === "person");
|
|
28
|
+
return asked === undefined ? undefined : Number(asked.id);
|
|
23
29
|
}
|
|
24
30
|
/** The refusal of the end-of-run turn's write or edit under work/.learning/: the tool gate's one text (NOTE_ONLY_TEXT), so
|
|
25
31
|
* the adapter loop's refusal and the gate's are the same words. */
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// sealed-settings-store.ts writes them), opened here with the runner's seal key and held only in the bound mint's closure.
|
|
5
5
|
// No App (never connected, disconnected, or rows that do not open under this key): no access, and such a server's calls
|
|
6
6
|
// are refused in words (GITHUB_UNUSABLE.noAccess).
|
|
7
|
-
import { unseal } from "
|
|
7
|
+
import { unseal } from "../sealing.js";
|
|
8
8
|
import { GITHUB_API, GITHUB_FIELDS, GITHUB_SCOPE, githubTargetOf, mintInstallationToken } from "../github.js";
|
|
9
9
|
import { isObject } from "../validate.js";
|
|
10
10
|
const ADAPTER = "github";
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { RunLaunch } from "../run-launch.js";
|
|
2
2
|
import { type AdapterSpecDeps } from "./adapter-run-spec.js";
|
|
3
|
+
import { type GradeRouteAsk } from "./learning-dispatch.js";
|
|
4
|
+
import type { GraderRoute } from "./learning-ask.js";
|
|
3
5
|
import type { LoopFactory } from "./loop-contract.js";
|
|
4
6
|
/** The dispatch's `resolve`, built from the runner's deps: it reads the run's revision (for a workflow revision) and
|
|
5
7
|
* returns the loop the run runs on, or undefined when this runner does not run it (the dispatch fails it in words). */
|
|
6
8
|
export declare function resolveRunnerLoop(deps: AdapterSpecDeps): (harness: string, launch: RunLaunch, runId: string) => Promise<LoopFactory | undefined>;
|
|
9
|
+
/** The route a grade asks for (gradeModelFor: the grade model the server named, else the agent's own), from the runner's
|
|
10
|
+
* one route (`routeOf`), through gradeRouteOf. A grade model the server named (--grade-model, else AGENT_MODEL_STRONG)
|
|
11
|
+
* is the strong tier's: it goes with that tier's settings, sent whole as AGENT_MODEL_STRONG is (never cut to its bare id
|
|
12
|
+
* by AGENT_MODEL_GATEWAY_IDS) and priced at AGENT_MODEL_STRONG_PRICE. The agent's own model goes as its runs' does, on
|
|
13
|
+
* the default tier. */
|
|
14
|
+
export declare function gradeRouteFor(grade: GradeRouteAsk, env: NodeJS.ProcessEnv, routeOf: AdapterSpecDeps["routeOf"]): Promise<GraderRoute>;
|
|
7
15
|
/** The loop factory the runner holds for every run (its createLoop), built from the runner's deps over the one store: the
|
|
8
|
-
* dispatch (dispatch.ts) reads each run's launch and asks
|
|
16
|
+
* dispatch (dispatch.ts) reads each run's launch and asks resolveRunnerLoop for its harness loop. The server
|
|
9
17
|
* start and the test server pass this to startRunner. */
|
|
10
18
|
export declare function dispatchRunner(deps: AdapterSpecDeps): LoopFactory;
|
|
@@ -38,9 +38,10 @@ export function resolveRunnerLoop(deps) {
|
|
|
38
38
|
routeOf: async (grade) => {
|
|
39
39
|
const base = deps.env ?? process.env;
|
|
40
40
|
const env = withModelKeys(base, await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: base }));
|
|
41
|
-
return
|
|
41
|
+
return gradeRouteFor(grade, env, deps.routeOf);
|
|
42
42
|
},
|
|
43
43
|
...(deps.log ? { log: deps.log } : {}),
|
|
44
|
+
...(deps.gradeBound ? { gradeBound: deps.gradeBound } : {}),
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
// The harness's own entry decides which spec builds the run, by the entry's facts and never the harness's name: an entry
|
|
@@ -59,8 +60,20 @@ export function resolveRunnerLoop(deps) {
|
|
|
59
60
|
return undefined;
|
|
60
61
|
};
|
|
61
62
|
}
|
|
63
|
+
/** The route a grade asks for (gradeModelFor: the grade model the server named, else the agent's own), from the runner's
|
|
64
|
+
* one route (`routeOf`), through gradeRouteOf. A grade model the server named (--grade-model, else AGENT_MODEL_STRONG)
|
|
65
|
+
* is the strong tier's: it goes with that tier's settings, sent whole as AGENT_MODEL_STRONG is (never cut to its bare id
|
|
66
|
+
* by AGENT_MODEL_GATEWAY_IDS) and priced at AGENT_MODEL_STRONG_PRICE. The agent's own model goes as its runs' does, on
|
|
67
|
+
* the default tier. */
|
|
68
|
+
export function gradeRouteFor(grade, env, routeOf) {
|
|
69
|
+
return gradeRouteOf(gradeModelFor(grade), env, (model) => (grade.model !== undefined && model === grade.model
|
|
70
|
+
// The runner's environment under the grader as its strong model: every key it holds read through it, a non-enumerable
|
|
71
|
+
// one (a launcher-held or Settings key) too, which a copy would drop.
|
|
72
|
+
? routeOf(undefined, Object.create(env, { AGENT_MODEL_STRONG: { value: model, enumerable: true } }), "strong", PI_WIRES)
|
|
73
|
+
: routeOf(model, env, "default", PI_WIRES)));
|
|
74
|
+
}
|
|
62
75
|
/** The loop factory the runner holds for every run (its createLoop), built from the runner's deps over the one store: the
|
|
63
|
-
* dispatch (dispatch.ts) reads each run's launch and asks
|
|
76
|
+
* dispatch (dispatch.ts) reads each run's launch and asks resolveRunnerLoop for its harness loop. The server
|
|
64
77
|
* start and the test server pass this to startRunner. */
|
|
65
78
|
export function dispatchRunner(deps) {
|
|
66
79
|
return createDispatchLoop({
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import type { MessageOrigin } from "
|
|
1
|
+
import type { MessageOrigin } from "../timeline/index.js";
|
|
2
|
+
/** The phase row before a message a CLI run sends again (adapter-loop.ts CliRecord.sending): its runner was lost after
|
|
3
|
+
* sending it, before the message was recorded, so the model may read it twice, and the turn it starts is paid like any
|
|
4
|
+
* other. */
|
|
5
|
+
export declare const MESSAGE_SENT_AGAIN = "Your message was sent again after the runner restarted: it may have reached the model before, and this turn is paid again.";
|
|
2
6
|
export declare const KINDS: {
|
|
3
7
|
/** A tool call about to run: written before it runs (and before the flush that precedes a side effect). */
|
|
4
8
|
readonly callStart: "agentrun.call.start";
|
|
9
|
+
/** A call whose start was written at its park (CallStartData.parked) is about to be sent: committed and flushed before
|
|
10
|
+
* the send, once. Only a parked call with this mark may have been sent; one without it never left. */
|
|
11
|
+
readonly callSent: "agentrun.call.sent";
|
|
5
12
|
/** How it ended: written after it ran, or by recovery for a start with no end (replay-safe reruns and ends done;
|
|
6
13
|
* any other ends interrupted, and the model is told). */
|
|
7
14
|
readonly callEnd: "agentrun.call.end";
|
|
8
15
|
/** A message: the person's, a steer, or the model's. */
|
|
9
16
|
readonly message: "agentrun.message";
|
|
17
|
+
/** A message a CLI run took mid-turn is about to be sent as a turn of its own (adapter-loop.ts sendAfterTurn): its
|
|
18
|
+
* command row's id, committed and flushed before the send. Its row is taken only after the send, so a runner lost in
|
|
19
|
+
* between leaves this mark with the row untaken: the next claim sends it again and says so (MESSAGE_SENT_AGAIN). Neither
|
|
20
|
+
* a call nor a message, so the reader passes over it. */
|
|
21
|
+
readonly messageSending: "agentrun.message.sending";
|
|
10
22
|
/** A pi input the person did not type (a trigger's message): pi's user entry under the host's kind, its `data.origin`
|
|
11
23
|
* the Timeline's attribution (pi-durable-agent's originMatcher reads a host's user entry's own origin). The model
|
|
12
24
|
* reads it as any message. */
|
|
@@ -118,12 +130,19 @@ export interface CallStartData {
|
|
|
118
130
|
readonly input: unknown;
|
|
119
131
|
/** May run again after a crash (it changes nothing outside the run): the tool registry's own flag. */
|
|
120
132
|
readonly replaySafe: boolean;
|
|
133
|
+
/** Written as the call reached its gate through a CLI's own MCP client, before any answer: nothing is sent until its
|
|
134
|
+
* agentrun.call.sent mark (KINDS.callSent). */
|
|
135
|
+
readonly parked?: true;
|
|
136
|
+
/** When it was written (ms, the loop's clock): the Timeline dates the call's row by it. */
|
|
137
|
+
readonly at?: number;
|
|
121
138
|
}
|
|
122
139
|
export type CallStatus = "done" | "failed" | "refused" | "interrupted";
|
|
123
140
|
export interface CallEndData {
|
|
124
141
|
readonly callId: string;
|
|
125
142
|
readonly status: CallStatus;
|
|
126
143
|
readonly output?: unknown;
|
|
144
|
+
/** When it was written (ms, the loop's clock): the Timeline dates the result's row by it. */
|
|
145
|
+
readonly at?: number;
|
|
127
146
|
}
|
|
128
147
|
/** What a call that already ended answers when it is asked for again (a parked call's resume, a CLI's re-issue of its id):
|
|
129
148
|
* its recorded output; for one a crash cut with none, the kernel's words for an outcome not known (INTERRUPTED_TEXT);
|
|
@@ -145,6 +164,8 @@ export interface MessageData {
|
|
|
145
164
|
* answer's output tokens when known. The loop reads it as pi's stopReason (loop.ts cutLast). */
|
|
146
165
|
readonly stopReason?: "length";
|
|
147
166
|
readonly outputTokens?: number;
|
|
167
|
+
/** When it was written (ms, the loop's clock): the Timeline dates the message's row by it. */
|
|
168
|
+
readonly at?: number;
|
|
148
169
|
}
|
|
149
170
|
/** What an approval costs, as main's card shows it (tool-gate.ts ApprovalPrice): dollars, or "not metered". */
|
|
150
171
|
export type ApprovalPrice = number | "not metered";
|
|
@@ -160,12 +181,12 @@ export interface AskData {
|
|
|
160
181
|
/** Its approval price (the spec's approvalPrice); null when it has none. */
|
|
161
182
|
readonly price?: ApprovalPrice | null;
|
|
162
183
|
}
|
|
163
|
-
/** How an ask was answered: approved, denied,
|
|
164
|
-
export type AnswerDecision = "allow" | "deny" | "withdrawn";
|
|
184
|
+
/** How an ask was answered: approved, denied, withdrawn (a stop while the call waited) or canceled (a cancel). */
|
|
185
|
+
export type AnswerDecision = "allow" | "deny" | "withdrawn" | "canceled";
|
|
165
186
|
export interface AnswerData {
|
|
166
187
|
readonly callId: string;
|
|
167
188
|
readonly approved: boolean;
|
|
168
|
-
/** allow, deny, or
|
|
189
|
+
/** allow, deny, withdrawn or canceled: main's resolved entry. Optional for an answer written before it. */
|
|
169
190
|
readonly decision?: AnswerDecision;
|
|
170
191
|
/** When it was answered (ISO), from the loop's clock (or the runner's, for an end it writes itself). */
|
|
171
192
|
readonly answeredAt?: string;
|
|
@@ -185,12 +206,13 @@ export interface AnswerData {
|
|
|
185
206
|
/** The withdrawn answers a stopped end writes in `entries`: for every call still waiting (an ask with no answer), and
|
|
186
207
|
* for every approved call that had not finished (no result, or one its abort wrote), which the stop overrides, keeping
|
|
187
208
|
* the allow it was given (main's supersede: an answer the run had not acted on to the end is withdrawn by the stop). A
|
|
188
|
-
* call that finished before the stop keeps its allow and its result.
|
|
209
|
+
* call that finished before the stop keeps its allow and its result. `decision`: "canceled" for a cancel's end, whose
|
|
210
|
+
* calls read cancelled with their run; "withdrawn" for a stop's. */
|
|
189
211
|
export declare function withdrawnAnswers(entries: readonly {
|
|
190
212
|
readonly kind: string;
|
|
191
213
|
readonly data?: unknown;
|
|
192
214
|
readonly model?: unknown;
|
|
193
|
-
}[], answeredAt: string): AnswerData[];
|
|
215
|
+
}[], answeredAt: string, decision?: "withdrawn" | "canceled"): AnswerData[];
|
|
194
216
|
export interface EndData {
|
|
195
217
|
readonly state: "ended" | "stopped" | "failed";
|
|
196
218
|
readonly summary?: string;
|
|
@@ -209,3 +231,5 @@ export interface SessionKeyData {
|
|
|
209
231
|
/** The conversation whose entries are this session's resume log. */
|
|
210
232
|
readonly conversation: number;
|
|
211
233
|
}
|
|
234
|
+
/** The session a workflow's model requests are booked under, in its run's journal. */
|
|
235
|
+
export declare const WORKFLOW_SESSION = "workflow";
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { INTERRUPTED_TEXT } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
/** The phase row before a message a CLI run sends again (adapter-loop.ts CliRecord.sending): its runner was lost after
|
|
3
|
+
* sending it, before the message was recorded, so the model may read it twice, and the turn it starts is paid like any
|
|
4
|
+
* other. */
|
|
5
|
+
export const MESSAGE_SENT_AGAIN = "Your message was sent again after the runner restarted: it may have reached the model before, and this turn is paid again.";
|
|
2
6
|
export const KINDS = {
|
|
3
7
|
/** A tool call about to run: written before it runs (and before the flush that precedes a side effect). */
|
|
4
8
|
callStart: "agentrun.call.start",
|
|
9
|
+
/** A call whose start was written at its park (CallStartData.parked) is about to be sent: committed and flushed before
|
|
10
|
+
* the send, once. Only a parked call with this mark may have been sent; one without it never left. */
|
|
11
|
+
callSent: "agentrun.call.sent",
|
|
5
12
|
/** How it ended: written after it ran, or by recovery for a start with no end (replay-safe reruns and ends done;
|
|
6
13
|
* any other ends interrupted, and the model is told). */
|
|
7
14
|
callEnd: "agentrun.call.end",
|
|
8
15
|
/** A message: the person's, a steer, or the model's. */
|
|
9
16
|
message: "agentrun.message",
|
|
17
|
+
/** A message a CLI run took mid-turn is about to be sent as a turn of its own (adapter-loop.ts sendAfterTurn): its
|
|
18
|
+
* command row's id, committed and flushed before the send. Its row is taken only after the send, so a runner lost in
|
|
19
|
+
* between leaves this mark with the row untaken: the next claim sends it again and says so (MESSAGE_SENT_AGAIN). Neither
|
|
20
|
+
* a call nor a message, so the reader passes over it. */
|
|
21
|
+
messageSending: "agentrun.message.sending",
|
|
10
22
|
/** A pi input the person did not type (a trigger's message): pi's user entry under the host's kind, its `data.origin`
|
|
11
23
|
* the Timeline's attribution (pi-durable-agent's originMatcher reads a host's user entry's own origin). The model
|
|
12
24
|
* reads it as any message. */
|
|
@@ -90,8 +102,9 @@ function finished(entries, callId) {
|
|
|
90
102
|
/** The withdrawn answers a stopped end writes in `entries`: for every call still waiting (an ask with no answer), and
|
|
91
103
|
* for every approved call that had not finished (no result, or one its abort wrote), which the stop overrides, keeping
|
|
92
104
|
* the allow it was given (main's supersede: an answer the run had not acted on to the end is withdrawn by the stop). A
|
|
93
|
-
* call that finished before the stop keeps its allow and its result.
|
|
94
|
-
|
|
105
|
+
* call that finished before the stop keeps its allow and its result. `decision`: "canceled" for a cancel's end, whose
|
|
106
|
+
* calls read cancelled with their run; "withdrawn" for a stop's. */
|
|
107
|
+
export function withdrawnAnswers(entries, answeredAt, decision = "withdrawn") {
|
|
95
108
|
const answers = new Map();
|
|
96
109
|
for (const entry of entries)
|
|
97
110
|
if (entry.kind === KINDS.answer)
|
|
@@ -107,10 +120,12 @@ export function withdrawnAnswers(entries, answeredAt) {
|
|
|
107
120
|
seen.add(callId);
|
|
108
121
|
const given = answers.get(callId);
|
|
109
122
|
if (!given)
|
|
110
|
-
out.push({ callId, approved: false, decision
|
|
111
|
-
else if (given.approved && given.decision !== "withdrawn" && !finished(entries, callId)) {
|
|
112
|
-
out.push({ callId, approved: false, decision
|
|
123
|
+
out.push({ callId, approved: false, decision, answeredAt });
|
|
124
|
+
else if (given.approved && given.decision !== "withdrawn" && given.decision !== "canceled" && !finished(entries, callId)) {
|
|
125
|
+
out.push({ callId, approved: false, decision, answeredAt, superseded: { decision: "allow", ...(given.answeredAt ? { answeredAt: given.answeredAt } : {}) } });
|
|
113
126
|
}
|
|
114
127
|
}
|
|
115
128
|
return out;
|
|
116
129
|
}
|
|
130
|
+
/** The session a workflow's model requests are booked under, in its run's journal. */
|
|
131
|
+
export const WORKFLOW_SESSION = "workflow";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import { type MessageOrigin } from "
|
|
2
|
+
import { type MessageOrigin } from "../timeline/index.js";
|
|
3
3
|
import type { EntryRecord, SubmissionRecord, TaskRecord } from "@earendil-works/pi-durable";
|
|
4
4
|
import { type CallEndData, type MessageRole } from "./journal-kinds.js";
|
|
5
5
|
import type { JournalReads } from "../store/store.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { originOf } from "
|
|
1
|
+
import { originOf } from "../timeline/index.js";
|
|
2
2
|
import { reflectFrom } from "./end-of-run.js";
|
|
3
3
|
import { KINDS } from "./journal-kinds.js";
|
|
4
4
|
const PAGE = 500;
|
|
@@ -97,7 +97,7 @@ export function messagesOf(from) {
|
|
|
97
97
|
const out = [];
|
|
98
98
|
const records = asRecords(from);
|
|
99
99
|
// The end-of-run turn's, from the entry its input placed on (the reader's tag, as the server's labelled() reads it).
|
|
100
|
-
const from_ = reflectFrom(records.submissions ?? []);
|
|
100
|
+
const from_ = reflectFrom(records.submissions ?? [], records.entries);
|
|
101
101
|
const turn = (entry) => (from_ !== undefined && entry >= from_ ? { learning: true } : {});
|
|
102
102
|
for (const entry of recordOf(records.entries)) {
|
|
103
103
|
const at = entryNumber(entry);
|