@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45
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 +231 -0
- package/README.md +580 -320
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +10 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +26 -89
- package/dist/learn/check.js +58 -336
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +30 -2
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +58 -9
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +119 -83
- package/dist/server.js +1121 -419
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +41 -21
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -9
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -33
- package/dist/learning-evals.js +0 -98
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
// hands on them (runTools), the gate from the store's tool settings, the system prompt (environment line, instructions
|
|
15
15
|
// with what the agent learned and its skills, effort guidance), the first message, the end's metrics and the release.
|
|
16
16
|
import { mkdir, readdir, rm, rmdir } from "node:fs/promises";
|
|
17
|
+
import { stopRunWith } from "../paid-calls.js";
|
|
17
18
|
import { dirname, join } from "node:path";
|
|
18
19
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
19
20
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
20
21
|
import { checkRaise, followUpOf, freeModelRequestsOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
|
|
21
22
|
import { PLAN_LIMIT_WORDS } from "@parcha/agentrun-kernel";
|
|
22
23
|
import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.js";
|
|
23
|
-
import { claimSettled, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
24
|
+
import { claimSettled, claudeCliIn, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
24
25
|
import { HarnessUnavailable } from "../provider.js";
|
|
25
26
|
import { effortGuidance } from "../effort-guidance.js";
|
|
26
27
|
import { outputContract } from "../answer-json.js";
|
|
@@ -41,21 +42,22 @@ import { recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.j
|
|
|
41
42
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
42
43
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
43
44
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
44
|
-
import {
|
|
45
|
+
import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
45
46
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
46
47
|
import { settingOfDefinition } from "../computer-setting.js";
|
|
47
48
|
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
48
49
|
import { hadComputer } from "./computer-journal.js";
|
|
49
50
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
50
|
-
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
51
|
+
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, claimLiveAt, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
51
52
|
import { openTierProxies } from "./adapters/pi.js";
|
|
52
53
|
import { signInReads } from "../sign-ins-store.js";
|
|
53
54
|
import { isWebHostTool } from "../tool-list.js";
|
|
54
55
|
import { hostToolOf } from "../host-tools.js";
|
|
55
56
|
import { ASK_TOOL, askPerson } from "../tools.js";
|
|
56
57
|
import { fakedPlane } from "../web-fake.js";
|
|
57
|
-
import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, tierModelKeys,
|
|
58
|
-
import {
|
|
58
|
+
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
59
|
+
import { mcpWhereHeld } from "./mcp-run.js";
|
|
60
|
+
import { held as runnerSeam, heldSignInReads } from "./held.js";
|
|
59
61
|
import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
60
62
|
import { decisionProvidersIn } from "../decisions.js";
|
|
61
63
|
import { resolveHarness } from "./adapters/index.js";
|
|
@@ -63,13 +65,15 @@ import { entriesOf } from "./loop.js";
|
|
|
63
65
|
import { bookedSpend, cliModelWorked, cliRunMetrics, endCostOf, runCostOf } from "./metrics.js";
|
|
64
66
|
import { journalEntries } from "./journal-reader.js";
|
|
65
67
|
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
68
|
+
import { replayCallsOver } from "./promotion.js";
|
|
69
|
+
import { learnedFirstWhereHeld } from "./learned-first.js";
|
|
70
|
+
import { pathMetrics } from "./workflow-first.js";
|
|
71
|
+
import { AUDIT_PARKED, withAudit } from "./audit.js";
|
|
72
|
+
import { runPathOverStore } from "../store-reads/learning.js";
|
|
70
73
|
import { specBuilt } from "./spec-holds.js";
|
|
71
74
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
72
75
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
76
|
+
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
73
77
|
import { heldSpecOf } from "./held-run.js";
|
|
74
78
|
import { loopComputerOf } from "./computer-channel.js";
|
|
75
79
|
import { githubAppAccess } from "./github-app.js";
|
|
@@ -120,7 +124,7 @@ export function capModelOf(id, wire, listed, unpriced, plan = false) {
|
|
|
120
124
|
function chosenCapModel(entry, env, chosen, wire) {
|
|
121
125
|
const priced = entry.priceModel(env, chosen.model);
|
|
122
126
|
const listed = chosen.models.getModel(priced.provider, priced.modelId);
|
|
123
|
-
return capModelOf(priced.modelId, wire, listed, chosen.unpriced.has(priced.modelId) || listed === undefined, priced.provider === PLAN_PROVIDER);
|
|
127
|
+
return capModelOf(priced.modelId, wire, listed, chosen.unpriced.has(priced.modelId) || listed === undefined, priced.provider === PLAN_PROVIDER || priced.provider === CLAUDE_LOGIN_PROVIDER);
|
|
124
128
|
}
|
|
125
129
|
/** The model a run of the CLI harness `entry` on `ref` (a revision's model; none, this host's default for it) is capped
|
|
126
130
|
* at here, as its run's spec prices it (modelsOf, chosenCapModel), before any run: a save's cap warning (cap-short.ts)
|
|
@@ -139,8 +143,9 @@ export async function cliCapModel(entry, env, ref) {
|
|
|
139
143
|
* run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
|
|
140
144
|
* own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
|
|
141
145
|
* (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
|
|
142
|
-
export function cliRunEnv(env, data, claimed = {}, plane) {
|
|
143
|
-
|
|
146
|
+
export function cliRunEnv(env, data, claimed = {}, plane, runKey) {
|
|
147
|
+
// A run with its own model key: that key alone, in the variables its route sends (claimModelEnv, never enumerable).
|
|
148
|
+
const out = claimModelEnv(env ?? {}, claimed, runKey);
|
|
144
149
|
Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
|
|
145
150
|
delete out[TOOL_PLANE_ENV];
|
|
146
151
|
if (plane && Object.keys(plane).length)
|
|
@@ -207,6 +212,11 @@ async function rmEmptyParents(parents) {
|
|
|
207
212
|
const code = error.code;
|
|
208
213
|
if (code === "ENOTEMPTY" || code === "EEXIST")
|
|
209
214
|
return;
|
|
215
|
+
// A folder this process may not remove ends the climb: a run's own process on a slot (run-child-host.ts) removes
|
|
216
|
+
// its harness folder, and the run's scratch folder and its agent's are its runner's, which sweeps them after the
|
|
217
|
+
// slot's reap.
|
|
218
|
+
if (code === "EACCES" || code === "EPERM")
|
|
219
|
+
return;
|
|
210
220
|
// Already gone (a sweep cut off after it, or never made): the folder above it may still be left empty.
|
|
211
221
|
if (code !== "ENOENT")
|
|
212
222
|
throw error;
|
|
@@ -270,7 +280,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
270
280
|
// test runner; anywhere else it is the built-ins), and the runner's record mode for it.
|
|
271
281
|
const name = launch.harness ?? body.harness;
|
|
272
282
|
const entry = harnessOf(deps.env, name);
|
|
273
|
-
const runner = name === undefined ? undefined : resolveHarness(name);
|
|
283
|
+
const runner = name === undefined ? undefined : resolveHarness(name, deps.env);
|
|
274
284
|
if (!name || !entry?.facts || !entry.adapter || !runner)
|
|
275
285
|
throw new Error(`run ${claim.runId}: ${JSON.stringify(name)} is not a CLI harness this runner runs`);
|
|
276
286
|
const facts = entry.facts;
|
|
@@ -317,7 +327,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
317
327
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
318
328
|
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
319
329
|
redact.hold(values); };
|
|
320
|
-
const mcp = await
|
|
330
|
+
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...reach });
|
|
321
331
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
322
332
|
holds.hold({ passed: mcp });
|
|
323
333
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
@@ -332,7 +342,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
332
342
|
// fake) is spread into the mount, so no test reaches the real control plane. TODO(k2 lazy mint): the mint moves into
|
|
333
343
|
// computerForClaim (a mounting computer only), with the ttl the run's lifetime bound (not this fixed figure). As pi does.
|
|
334
344
|
// The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one.
|
|
335
|
-
: await
|
|
345
|
+
: await archilWhereHeld({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
|
|
336
346
|
// Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go. The claim's Archil keys go
|
|
337
347
|
// from memory last, once nothing more reads the disk.
|
|
338
348
|
holds.hold({ archil, keys: archil });
|
|
@@ -345,7 +355,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
345
355
|
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
346
356
|
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
347
357
|
holds.hold({ checkout });
|
|
348
|
-
|
|
358
|
+
// A run's own process copies nothing: its runner placed them before the process started (run-child-host.ts).
|
|
359
|
+
if (!(deps.sealKey === undefined && runnerSeam()))
|
|
360
|
+
await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
|
|
349
361
|
// The run's skills and its learning seed laid before its computer exists, as the pi spec lays them (adapter-run-spec.ts):
|
|
350
362
|
// on Archil the computer's mount takes the disk's write delegation, and a lay over the disk's file API after it is
|
|
351
363
|
// refused (409) while the mount holds it.
|
|
@@ -354,21 +366,12 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
354
366
|
// The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts), with the kind's
|
|
355
367
|
// skill of a desktop or a phone (the revision's computer setting), in the harness's skill list beside the revision's.
|
|
356
368
|
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
357
|
-
// A learning run's seed
|
|
358
|
-
//
|
|
369
|
+
// A learning run's seed read as the pi spec reads it (runner/learning-seed.ts): its learned workflows, the ones
|
|
370
|
+
// learned_workflow runs.
|
|
359
371
|
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
360
372
|
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
361
373
|
const seedLaid = start && !seedFailed(start)
|
|
362
|
-
? await layLearningSeed({
|
|
363
|
-
work: ws.workspace,
|
|
364
|
-
seed: start.seed,
|
|
365
|
-
folder: learningFolder,
|
|
366
|
-
own: Object.keys(revisionRow.skills ?? {}),
|
|
367
|
-
shown,
|
|
368
|
-
log,
|
|
369
|
-
...(start.notesOnly ? { workflows: false } : {}),
|
|
370
|
-
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
371
|
-
})
|
|
374
|
+
? await layLearningSeed({ seed: start.seed, folder: learningFolder, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
|
|
372
375
|
: undefined;
|
|
373
376
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
374
377
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
@@ -383,7 +386,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
383
386
|
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer), as the pi
|
|
384
387
|
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount). Its
|
|
385
388
|
// screen's recording (computer.record) goes in the run's recordings folder, as the pi spec's does.
|
|
386
|
-
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
389
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
387
390
|
holds.hold({ computer });
|
|
388
391
|
const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
|
|
389
392
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
@@ -417,9 +420,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
417
420
|
// those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
|
|
418
421
|
// pi spec gives it), then the effort guidance.
|
|
419
422
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
420
|
-
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section
|
|
423
|
+
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
421
424
|
const check = await entry.skillCheck?.();
|
|
422
|
-
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills
|
|
425
|
+
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills], ws.workspace, check, { onDemand: readsFiles(granted) });
|
|
423
426
|
const guidance = effortGuidance(launch.effort);
|
|
424
427
|
// The run's model (the launch's, pinned at start, else the revision's) and its adapter, as main builds them, on the
|
|
425
428
|
// environment main's server gives its runs: the server's data directory named (DATA_ENV), so the CLI's install is
|
|
@@ -429,11 +432,29 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
429
432
|
// to the model choice and the adapter's provider (withModelKeys, never enumerable), so a key saved in
|
|
430
433
|
// Settings → Model keys runs the next run with no restart, as one set where AgentRun starts does.
|
|
431
434
|
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, revisionRow, launch);
|
|
432
|
-
|
|
435
|
+
// The run's own model key, when its caller handed one (model_key): opened at every claim, held by the redactors, read by
|
|
436
|
+
// its model route alone; the CLI's process and its tools never carry it, nor any other model key then.
|
|
437
|
+
// A run that starts on the server's key holds the claim's key holder too: a message's first key reaches its next request.
|
|
438
|
+
const runKey = await claimModelKey({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, claim.runId);
|
|
439
|
+
const keyed = keyedAtClaim(runKey);
|
|
440
|
+
if (keyed)
|
|
441
|
+
withoutModelKeys(claimed);
|
|
442
|
+
for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut]) {
|
|
433
443
|
holdClaimed(redact, claimed);
|
|
434
|
-
|
|
444
|
+
if (runKey)
|
|
445
|
+
holdRunKey(redact, runKey);
|
|
446
|
+
}
|
|
447
|
+
// Claude Code's login on this machine, where the owner turned it on for claude-agent here (claude-login.ts): the run
|
|
448
|
+
// carries only where it is, and its CLI says it is signed in before the run starts. A run that brought its own key
|
|
449
|
+
// runs on that key, and a run in a sandbox place on the model keys.
|
|
450
|
+
const login = keyed ? undefined : await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place);
|
|
451
|
+
const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey), login);
|
|
435
452
|
const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
436
453
|
await planBeforeRun(env, chosen.model);
|
|
454
|
+
if (login && entry.priceModel(env, chosen.model).provider === CLAUDE_LOGIN_PROVIDER) {
|
|
455
|
+
const claude = await import("@parcha/agentrun-harness-claude");
|
|
456
|
+
await loginBeforeRun(login, loginCli(claudeCliIn(installDirOf(deps.data, name), claude.claudeAgentPlatform()), env), (cli, at) => claude.claudeLoginStatus(cli, at, env.PATH ? { path: env.PATH } : {}));
|
|
457
|
+
}
|
|
437
458
|
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
438
459
|
// (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
|
|
439
460
|
// or a command it runs reaches grants nothing; none on macOS. Where setpriv is not usable the run is refused, in pi's words.
|
|
@@ -441,7 +462,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
441
462
|
// The run's clock: a template eval case's (EvalFakes.now), else the real one. Its environment line and the harness's own
|
|
442
463
|
// turn date (claude-agent's dateLine) read it.
|
|
443
464
|
const now = fakes?.now;
|
|
444
|
-
|
|
465
|
+
// A run's own process reads no trigger's row: its runner answers the zone (held.ts runZone).
|
|
466
|
+
const seam = deps.sealKey ? undefined : runnerSeam();
|
|
467
|
+
const zone = seam ? await seam.runZone() : await runZone(deps.store, launch.inputOrigin);
|
|
445
468
|
const built = await entry.adapter(env, { zone, model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(confine ? { confine } : {}), ...(native.length ? { skills: native } : {}), ...(now ? { now: () => now } : {}) });
|
|
446
469
|
// The harness's own session options, its private directory and its working directory (SessionIO's dir and cwd, which
|
|
447
470
|
// every CLI adapter reads), set on its open here, so the loop lends the session nothing of its own. A turn that ends on
|
|
@@ -504,8 +527,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
504
527
|
const tierRoute = tierRoutes.get(by);
|
|
505
528
|
return tierRoute && tierRoute.model === id ? capModelOfRoute(tierRoute) : undefined;
|
|
506
529
|
},
|
|
507
|
-
// What its
|
|
508
|
-
// (none: it queues none).
|
|
530
|
+
// What its audit's shadow took beside it, read by every gate with its own sessions (none: it starts none).
|
|
509
531
|
...(besideOf ? { beside: besideOf } : {}),
|
|
510
532
|
// The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
|
|
511
533
|
freeRequests: freeModelRequestsOf(deps.env),
|
|
@@ -549,29 +571,26 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
549
571
|
// The keys the claim hands the run (its web tools and its learned workflow's call nodes run on them): never learned
|
|
550
572
|
// (learningEndOfRun).
|
|
551
573
|
let handedKeys = [];
|
|
552
|
-
// A replay run lays only the workflow it replays (runner/promotion.ts replayLaid).
|
|
553
|
-
const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
|
|
554
574
|
// The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
|
|
555
575
|
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
556
576
|
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
557
577
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
558
578
|
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
559
579
|
// The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
|
|
580
|
+
// Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit and a replay check
|
|
581
|
+
// are skipped, in words, where the run brought its own key or the server holds none.
|
|
582
|
+
const spendOff = await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey);
|
|
583
|
+
const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff };
|
|
584
|
+
// Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
|
|
585
|
+
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself.
|
|
586
|
+
const learned = await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, folder: learningFolder, shown, spendOff }, seedLaid?.workflows ?? []);
|
|
587
|
+
const firstChoice = learned.choice;
|
|
569
588
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
570
|
-
// answered from that recording (runner/promotion.ts
|
|
571
|
-
const replay = await
|
|
589
|
+
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
590
|
+
const replay = learned.recorded ? await replayCallsOver(deps.store, claim.runId, new Map(learned.recorded)) : undefined;
|
|
572
591
|
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
573
592
|
// The tool runs what serves, never a revision not promoted (runner/promotion.ts toolFlowsFor).
|
|
574
|
-
const workflows =
|
|
593
|
+
const workflows = learned.workflows;
|
|
575
594
|
const learns = learnsWorkflows(revision.kind, workflows);
|
|
576
595
|
if (webNames.length || learns) {
|
|
577
596
|
// The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below.
|
|
@@ -592,7 +611,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
592
611
|
toolEnv[TOOL_PLANE_ENV] = JSON.stringify(launch.plane);
|
|
593
612
|
if (webNames.length) {
|
|
594
613
|
life = hostLifecycle();
|
|
595
|
-
const
|
|
614
|
+
const liveAt = await claimLiveAt(deps, claim.runId);
|
|
615
|
+
const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach, ...(liveAt ? { liveAt } : {}) });
|
|
596
616
|
gate.askedOn(host);
|
|
597
617
|
webTools = await webHostTools(host, granted, ctx);
|
|
598
618
|
}
|
|
@@ -601,10 +621,11 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
601
621
|
// keys, pi's wires, since pi-ai's client sends these, never the CLI); one refused fails its node in its words.
|
|
602
622
|
// Their models' keys (tierModelKeys: a saved one too, which claimSecrets opened only for the run's own model), held by
|
|
603
623
|
// the redactors, on the tiers' route env alone (withModelKeys, never enumerable), never on the tools' (toolEnv).
|
|
604
|
-
|
|
624
|
+
// A run with its own model key: these tiers carry that key too, and no saved key is read.
|
|
625
|
+
const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
|
|
605
626
|
for (const redact of new Set([held, cut]))
|
|
606
627
|
holdClaimed(redact, tierKeys);
|
|
607
|
-
const modelEnv =
|
|
628
|
+
const modelEnv = claimModelEnv(deps.env, { ...claimed, ...tierKeys }, runKey);
|
|
608
629
|
const tiers = new Map();
|
|
609
630
|
for (const [tier, routed] of await learnedTierRoutes(workflows, modelEnv, (tier) => deps.routeOf(undefined, modelEnv, tier, PI_WIRES, undefined, cut))) {
|
|
610
631
|
if ("why" in routed)
|
|
@@ -636,11 +657,11 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
636
657
|
};
|
|
637
658
|
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
638
659
|
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
639
|
-
// The run's end-of-run step, when it learns, the same as the pi spec's: the
|
|
640
|
-
// store, its learning folder where the run's place keeps it — Mode 1 under the data directory, Mode 2 on this
|
|
641
|
-
// Archil disk — so the
|
|
660
|
+
// The run's end-of-run step, when it learns, the same as the pi spec's: the compile turn and the owner's correction over
|
|
661
|
+
// the run's store, its learning folder where the run's place keeps it — Mode 1 under the data directory, Mode 2 on this
|
|
662
|
+
// claim's Archil disk — so the draft is checked against the seed in the run's own Workspace, never this machine's local path.
|
|
642
663
|
// A replay run or an audit's shadow run asks nothing at its end: it is the promotion's, never the agent's to learn from.
|
|
643
|
-
// A run the promoted workflow
|
|
664
|
+
// A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
|
|
644
665
|
// withAudit): at its end, so the shadow's cap is what the run's own left.
|
|
645
666
|
const endOfRun = launch.replay || launch.audit ? undefined : withAudit(learningEndOfRun(launch, {
|
|
646
667
|
store: deps.store,
|
|
@@ -649,7 +670,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
649
670
|
// What the run must never learn beside the runner's secrets: the keys its claim handed it, every secret the server
|
|
650
671
|
// keeps sealed (storeSecrets: the run's redactor holds the same list), and its sign-in's pointers, read back from the
|
|
651
672
|
// store's sign-ins under the seal key (learning-run.ts refused, on the runner).
|
|
652
|
-
signIns: signInReads(deps.store, deps.sealKey),
|
|
673
|
+
signIns: deps.sealKey ? signInReads(deps.store, deps.sealKey) : heldSignInReads(),
|
|
653
674
|
handed: handedKeys,
|
|
654
675
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
655
676
|
log,
|
|
@@ -658,7 +679,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
658
679
|
learningFolder: archil === undefined
|
|
659
680
|
? (agentId) => learningFolderOf(deps.data, agentId)
|
|
660
681
|
: (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
|
|
661
|
-
}), { ...audits, launch });
|
|
682
|
+
}), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
|
|
662
683
|
return {
|
|
663
684
|
adapter,
|
|
664
685
|
session,
|
|
@@ -674,6 +695,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
674
695
|
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
675
696
|
// the catalog tools the session mounts; absent when none.
|
|
676
697
|
...(catalog ? { mcp: catalog } : {}),
|
|
698
|
+
// The run's own model key: a command row opens it again before the next model request (a message's new key).
|
|
699
|
+
...(runKey ? { modelKey: runKey } : {}),
|
|
677
700
|
// The run's end-of-run step, when it learns (the spec's, preferred over the loop's deps': adapter-loop.ts stepOf).
|
|
678
701
|
...(endOfRun ? { endOfRun } : {}),
|
|
679
702
|
...(start ? { learningLaid: laidOf(seedLaid) } : {}),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Command } from "./loop-contract.js";
|
|
2
|
+
import type { LaunchSealedWrite } from "../store/store.js";
|
|
2
3
|
/** stop and cancel both end the run, stopped: a cancel's end says it was cancelled, as main's cancel ends a run for good.
|
|
3
4
|
* browser_hand_back is a person's answer to the agent's browser hand-over (runner/hand-back.ts). computer_take_over and
|
|
4
5
|
* computer_hand_back are a person's turn with the run's desktop or phone (computer-commands.ts, runner/computer-journal.ts).
|
|
@@ -15,15 +16,11 @@ export interface CommandSink {
|
|
|
15
16
|
command(runId: string, command: {
|
|
16
17
|
kind: string;
|
|
17
18
|
body: Record<string, unknown>;
|
|
18
|
-
}, options?:
|
|
19
|
-
launchSealed?: Uint8Array;
|
|
20
|
-
}): Promise<Command>;
|
|
19
|
+
}, options?: LaunchSealedWrite): Promise<Command>;
|
|
21
20
|
}
|
|
22
21
|
/** Inserts a command row for a run, after checking its kind and body. Rejects RunFinal (from the store) when the run is
|
|
23
22
|
* final, and a TypeError for a kind or body no runner would take. */
|
|
24
|
-
export declare function sendCommand(store: CommandSink, runId: string, input: CommandInput, options?:
|
|
25
|
-
launchSealed?: Uint8Array;
|
|
26
|
-
}): Promise<Command>;
|
|
23
|
+
export declare function sendCommand(store: CommandSink, runId: string, input: CommandInput, options?: LaunchSealedWrite): Promise<Command>;
|
|
27
24
|
/** The reason a command still untaken when its run ended is refused with: the store's own words (the write that makes a
|
|
28
25
|
* run final refuses such rows itself). */
|
|
29
26
|
export { endedReason } from "../store/store.js";
|
|
@@ -57,6 +57,12 @@ export type Seen = {
|
|
|
57
57
|
epoch: number;
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
+
/** What the process wrote after it said it stops at the point, in its file's order (each line is appended synchronously),
|
|
61
|
+
* or everything when it never said so. One millisecond of the clock can hold the loop's last write before the stop and
|
|
62
|
+
* the case's going on both, so the order, not the time, says which side of the stop a write is on. */
|
|
63
|
+
export declare function afterStop<T extends {
|
|
64
|
+
type?: string;
|
|
65
|
+
}>(events: readonly T[]): readonly T[];
|
|
60
66
|
/**
|
|
61
67
|
* The claim's fence, as the stalled process's own events show it: once it went on (`continuedAt`, its lease run out and no
|
|
62
68
|
* one holding the run yet), its old loop's writes under the claim it was held under are each refused by the fence, by name (ClaimLost
|
|
@@ -384,6 +384,13 @@ async function world(subject, t, timing = STEADY) {
|
|
|
384
384
|
};
|
|
385
385
|
return { dir, storeUrl: url, storeEnv, clockFile, runOut, runOutUnknown, claimsSettled, server, start, run, read, ended, began, commandRow, askedCall, events, handedOver: (id) => handed.has(id), answered: (id) => answered.has(id), liveRows, servedRows };
|
|
386
386
|
}
|
|
387
|
+
/** What the process wrote after it said it stops at the point, in its file's order (each line is appended synchronously),
|
|
388
|
+
* or everything when it never said so. One millisecond of the clock can hold the loop's last write before the stop and
|
|
389
|
+
* the case's going on both, so the order, not the time, says which side of the stop a write is on. */
|
|
390
|
+
export function afterStop(events) {
|
|
391
|
+
const stop = events.findIndex((event) => event.type === "stopping");
|
|
392
|
+
return stop < 0 ? events : events.slice(stop + 1);
|
|
393
|
+
}
|
|
387
394
|
/**
|
|
388
395
|
* The claim's fence, as the stalled process's own events show it: once it went on (`continuedAt`, its lease run out and no
|
|
389
396
|
* one holding the run yet), its old loop's writes under the claim it was held under are each refused by the fence, by name (ClaimLost
|
|
@@ -396,8 +403,10 @@ export function fenceHeld(events, continuedAt) {
|
|
|
396
403
|
// process's first claim before the point and take the run again, so the held loop's epoch need not be its first.
|
|
397
404
|
const heldFrom = events.find((event) => event.type === "stopping")?.at ?? continuedAt;
|
|
398
405
|
const first = events.filter((event) => event.type === "claimed" && (event.at ?? 0) <= heldFrom).at(-1)?.claim?.epoch;
|
|
399
|
-
const
|
|
406
|
+
const after = afterStop(events);
|
|
407
|
+
const old = after.filter((event) => (event.at ?? 0) >= continuedAt && event.epoch === first && (event.type === "commit-landed" || event.type === "commit-refused"));
|
|
400
408
|
const lost = events.find((event) => event.type === "claim-lost" && event.epoch === first);
|
|
409
|
+
const lostOnceOn = after.find((event) => event.type === "claim-lost" && event.epoch === first && (event.at ?? 0) >= continuedAt);
|
|
401
410
|
for (const landed of old.filter((event) => event.type === "commit-landed")) {
|
|
402
411
|
const when = lost?.at !== undefined ? `${landed.at - lost.at} ms after its claim was lost` : `${landed.at - continuedAt} ms after it went on, its lease run out`;
|
|
403
412
|
assert.fail(`an epoch-${first} commit landed ${when}: ${history}`);
|
|
@@ -406,7 +415,7 @@ export function fenceHeld(events, continuedAt) {
|
|
|
406
415
|
// before any write (a loaded box), or the loop's write is tried and refused. The store's refusal of a write past the
|
|
407
416
|
// lease is held on its own, deterministically (store-claim-lease).
|
|
408
417
|
if (old.length === 0) {
|
|
409
|
-
assert.ok(
|
|
418
|
+
assert.ok(lostOnceOn !== undefined, `the old loop neither tried a write nor was stopped by its claim lost once it went on: ${history}`);
|
|
410
419
|
return;
|
|
411
420
|
}
|
|
412
421
|
assert.ok(old.every((event) => event.name === "ClaimLost" || event.name === "Fenced"), `each was refused by the claim's fence, by name: ${history}`);
|
|
@@ -552,8 +561,9 @@ async function processCrashThenResume(subject, t, tool, point, { stall = false }
|
|
|
552
561
|
child.kill("SIGCONT");
|
|
553
562
|
// The fence first, before anything waits on the process's death: its old loop's first write once it went on (landed or
|
|
554
563
|
// refused), or the process's end, bounded. The old loop's epoch is the claim it was held under.
|
|
564
|
+
// A write after the stop (afterStop): one that landed before it, in the millisecond the case went on, is not one.
|
|
555
565
|
const outcome = (event) => (event.at ?? 0) >= continuedAt && (event.type === "commit-landed" || event.type === "commit-refused");
|
|
556
|
-
await until(() => child.exitCode !== null || child.signalCode !== null || childEvents(eventsFile).some(
|
|
566
|
+
await until(() => child.exitCode !== null || child.signalCode !== null || afterStop(childEvents(eventsFile)).some(outcome), "the old loop writes once it goes on, or the process ends", 15_000);
|
|
557
567
|
fenceHeld(childEvents(eventsFile), continuedAt);
|
|
558
568
|
}
|
|
559
569
|
// The process's unanswered first claim (its events file) is run out while the case waits for its death.
|
|
@@ -701,8 +711,9 @@ const CASES = [
|
|
|
701
711
|
await w.start("runner-a", { script: [{ call: "slow" }, { sayLastSteer: true }], tools, hooks: quiet });
|
|
702
712
|
await w.began(slowStarted, "the slow tool to start");
|
|
703
713
|
const steer = await sendCommand(w.server, RUN, { kind: "steer", body: { text: "check the totals" } });
|
|
704
|
-
//
|
|
705
|
-
|
|
714
|
+
// The tool goes on once the loop has answered the steer: the turn in flight has it, never a timer (as in
|
|
715
|
+
// message-mid-turn-kept). A steer that reaches a CLI only after the tool's end is the next turn by its facts.
|
|
716
|
+
await until(() => w.answered(steer.id), "the steer placed by the loop mid-turn");
|
|
706
717
|
letSlowGo();
|
|
707
718
|
await w.ended("ended");
|
|
708
719
|
const { calls, messages } = await w.read();
|
|
@@ -9,8 +9,8 @@ export interface DispatchDeps {
|
|
|
9
9
|
}>;
|
|
10
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
|
-
* this runner does not run it (the run fails in words). pi is the adapter loop with adapterRunSpecFromLaunch;
|
|
13
|
-
*
|
|
12
|
+
* this runner does not run it (the run fails in words). pi is the adapter loop with adapterRunSpecFromLaunch; the CLI
|
|
13
|
+
* harnesses name their own. May be async (the revision read). */
|
|
14
14
|
resolve(harness: string, launch: RunLaunch, runId: string): LoopFactory | undefined | Promise<LoopFactory | undefined>;
|
|
15
15
|
}
|
|
16
16
|
/** A launch naming a harness this runner does not run. */
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
export declare const REFLECT_PREFIX = "learn-reflect-";
|
|
3
3
|
/** The label a reader puts on the end-of-run turn's rows and messages: the server's (learning.ts LEARNING_LABEL). */
|
|
4
4
|
export declare const REFLECT_LABEL = "learning";
|
|
5
|
-
/** The end-of-run turn's request id, one per round of a run, and one per `step` of a round (
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
/** The end-of-run turn's request id, one per round of a run, and one per `step` of a round (the compile turn's attempts,
|
|
6
|
+
* `compile-<n>`): pi answers a repeat of it from its submission, so a turn asked again on a later claim is never asked of
|
|
7
|
+
* the model twice. A run's first end is round 1; an end after a follow-up opened the run again is the next round, whose
|
|
8
|
+
* turn is asked of the model anew under an id of its own. The server's own prefix, so the run's readers tell the turn's
|
|
9
|
+
* rows apart by it (reflectRanges). */
|
|
10
10
|
export declare const reflectRequestId: (runId: string, again?: boolean, round?: number, step?: string) => string;
|
|
11
11
|
/** The suffix of the end-of-run turn's re-ask's request id (EndOfRunTurn ask's `again`): one per round too, so a repeat
|
|
12
12
|
* is answered from its submission, never asked of the model twice. */
|
|
13
13
|
export declare const REFLECT_AGAIN = ":again";
|
|
14
|
-
/** The round shared by its
|
|
14
|
+
/** The round shared by its re-ask and compile attempts, for range and durable accounting reads. */
|
|
15
15
|
export declare const reflectRoundId: (requestId: string) => string;
|
|
16
16
|
/** One round of a run's end-of-run turn in its journal: `from`, the entry its input placed (the turn's first); `until`, the
|
|
17
17
|
* run's end entry that closed it, once written. Every entry between is the turn's. */
|
|
@@ -36,14 +36,6 @@ export declare function reflectRanges(submissions: readonly {
|
|
|
36
36
|
}[]): ReflectRange[];
|
|
37
37
|
/** Whether entry `entry` (a number) is one of `ranges`' end-of-run turns. */
|
|
38
38
|
export declare const inReflect: (ranges: readonly ReflectRange[], entry: number) => boolean;
|
|
39
|
-
/** 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
|
|
40
|
-
* the adapter loop's refusal and the gate's are the same words. */
|
|
41
|
-
export { NOTE_ONLY_TEXT as REFLECT_NOTE_ONLY } from "../tool-gate.js";
|
|
42
|
-
/** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then lexically),
|
|
43
|
-
* names work/.learning/ or a path under it: by the run's `work` (when the loop knows it), or the box's. */
|
|
44
|
-
export declare function underLearning(work: string | undefined, args: unknown): boolean;
|
|
45
|
-
/** The tools whose write the end-of-run turn is refused under work/.learning/. */
|
|
46
|
-
export declare const WRITES: Set<string>;
|
|
47
39
|
/** The text an answer entry gave (pi's assistant entry): the text parts of the messages it adds to the model's context,
|
|
48
40
|
* joined. */
|
|
49
41
|
export declare function answerText(entry: {
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
// The runner's half of the end-of-run turn (the learning lane's
|
|
2
|
-
//
|
|
3
|
-
// answer's note blocks, never from a file it writes there. The words and the rule are the tool gate's own
|
|
4
|
-
// (tool-gate.ts NOTE_ONLY_TEXT, underLearning), kept equal by a test.
|
|
5
|
-
import { posix, resolve, sep, join } from "node:path";
|
|
1
|
+
// The runner's half of the end-of-run turn (the learning lane's compile turn): its request id, and where its rounds are
|
|
2
|
+
// in a run's journal.
|
|
6
3
|
import { KINDS } from "./journal-kinds.js";
|
|
7
4
|
/** The prefix of the end-of-run turn's request id: the server's own (turns.ts REFLECT_REQUEST). */
|
|
8
5
|
export const REFLECT_PREFIX = "learn-reflect-";
|
|
9
6
|
/** The label a reader puts on the end-of-run turn's rows and messages: the server's (learning.ts LEARNING_LABEL). */
|
|
10
7
|
export const REFLECT_LABEL = "learning";
|
|
11
|
-
/** The end-of-run turn's request id, one per round of a run, and one per `step` of a round (
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
/** The end-of-run turn's request id, one per round of a run, and one per `step` of a round (the compile turn's attempts,
|
|
9
|
+
* `compile-<n>`): pi answers a repeat of it from its submission, so a turn asked again on a later claim is never asked of
|
|
10
|
+
* the model twice. A run's first end is round 1; an end after a follow-up opened the run again is the next round, whose
|
|
11
|
+
* turn is asked of the model anew under an id of its own. The server's own prefix, so the run's readers tell the turn's
|
|
12
|
+
* rows apart by it (reflectRanges). */
|
|
16
13
|
export const reflectRequestId = (runId, again = false, round = 1, step) => `${REFLECT_PREFIX}${runId}${round > 1 ? `${REFLECT_ROUND}${round}` : ""}${step !== undefined ? `:${step}` : again ? REFLECT_AGAIN : ""}`;
|
|
17
14
|
/** The suffix of the end-of-run turn's re-ask's request id (EndOfRunTurn ask's `again`): one per round too, so a repeat
|
|
18
15
|
* is answered from its submission, never asked of the model twice. */
|
|
@@ -21,7 +18,7 @@ export const REFLECT_AGAIN = ":again";
|
|
|
21
18
|
const REFLECT_ROUND = ":round-";
|
|
22
19
|
/** What a round's re-ask or step adds to its request id (reflectRequestId): the round is the id without it. */
|
|
23
20
|
const REFLECT_STEP = /:(?:again|compile-\d+)$/;
|
|
24
|
-
/** The round shared by its
|
|
21
|
+
/** The round shared by its re-ask and compile attempts, for range and durable accounting reads. */
|
|
25
22
|
export const reflectRoundId = (requestId) => requestId.replace(REFLECT_STEP, "");
|
|
26
23
|
/** Each round of the end-of-run turn in a run's journal, oldest first: each begins at the entry its input placed, from the
|
|
27
24
|
* input submissions under its request ids (its re-ask's within it); else, on a CLI harness, at the turn's prompt the CLI
|
|
@@ -54,28 +51,6 @@ export function reflectRanges(submissions, entries = []) {
|
|
|
54
51
|
}
|
|
55
52
|
/** Whether entry `entry` (a number) is one of `ranges`' end-of-run turns. */
|
|
56
53
|
export const inReflect = (ranges, entry) => ranges.some(({ from, until }) => entry >= from && (until === undefined || entry <= until));
|
|
57
|
-
/** 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
|
|
58
|
-
* the adapter loop's refusal and the gate's are the same words. */
|
|
59
|
-
export { NOTE_ONLY_TEXT as REFLECT_NOTE_ONLY } from "../tool-gate.js";
|
|
60
|
-
/** The folder of a run's copy of what its agent learned, relative to its work. */
|
|
61
|
-
const LEARNED_DIR = ".learning";
|
|
62
|
-
/** A computer's work folder, as a box names it. */
|
|
63
|
-
const BOX_WORK = "/workspace";
|
|
64
|
-
/** The work a relative path resolves against when the run's own work folder is not known to the loop. */
|
|
65
|
-
const NO_WORK = "/.agentrun-run-work";
|
|
66
|
-
/** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then lexically),
|
|
67
|
-
* names work/.learning/ or a path under it: by the run's `work` (when the loop knows it), or the box's. */
|
|
68
|
-
export function underLearning(work, args) {
|
|
69
|
-
const path = args?.path;
|
|
70
|
-
if (typeof path !== "string")
|
|
71
|
-
return false;
|
|
72
|
-
const plain = path.replace(/[ - ]/g, " ").replace(/^@/, "");
|
|
73
|
-
const under = (base, at) => at === join(base, LEARNED_DIR) || at.startsWith(`${join(base, LEARNED_DIR)}${sep}`);
|
|
74
|
-
const root = work ?? NO_WORK;
|
|
75
|
-
return under(resolve(root), resolve(root, plain)) || under(BOX_WORK, posix.resolve(BOX_WORK, plain));
|
|
76
|
-
}
|
|
77
|
-
/** The tools whose write the end-of-run turn is refused under work/.learning/. */
|
|
78
|
-
export const WRITES = new Set(["write", "edit"]);
|
|
79
54
|
/** The text an answer entry gave (pi's assistant entry): the text parts of the messages it adds to the model's context,
|
|
80
55
|
* joined. */
|
|
81
56
|
export function answerText(entry) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Grade } from "../learn/promote.js";
|
|
2
2
|
import type { RunPath } from "../learning-cost.js";
|
|
3
|
+
import { type RunLaunch } from "../run-launch.js";
|
|
3
4
|
import { type Command, type Store } from "../store/store.js";
|
|
4
|
-
export declare const FEEDBACK_ROUNDS: readonly ["
|
|
5
|
+
export declare const FEEDBACK_ROUNDS: readonly ["correction"];
|
|
5
6
|
export type FeedbackRound = (typeof FEEDBACK_ROUNDS)[number];
|
|
6
7
|
/** A feedback round, as its steer's body carries it (`feedback`) and its FEEDBACK entry keeps it: the round, whether the
|
|
7
8
|
* grade said right, and the grade's words (`text`). */
|
|
@@ -10,7 +11,7 @@ export interface FeedbackData {
|
|
|
10
11
|
readonly correct: boolean;
|
|
11
12
|
readonly text: string;
|
|
12
13
|
}
|
|
13
|
-
/** What a grade asks for: `
|
|
14
|
+
/** What a grade asks for: `correction` for a graded run the agent finished when the grade has words, else none
|
|
14
15
|
* (undefined): a run its learned workflow answered alone opens none, right or wrong (its grade is kept). A replay run
|
|
15
16
|
* is never graded. */
|
|
16
17
|
export declare function feedbackRoundOf(grade: {
|
|
@@ -55,9 +56,9 @@ export interface OpenedRound {
|
|
|
55
56
|
* agent (closed history: a grade of it starts no paid work), and one the store opens again (an agentic run that answered
|
|
56
57
|
* or that a person stopped). Null when the grade asks for nothing more, or the run can't be opened again (the grade is
|
|
57
58
|
* kept either way). */
|
|
58
|
-
export declare function openFeedbackRound(store: Pick<Store, "runs" | "agents">, grade: Grade, label: string | undefined): Promise<OpenedRound | null>;
|
|
59
|
+
export declare function openFeedbackRound(store: Pick<Store, "runs" | "agents">, grade: Grade, label: string | undefined, canTurn?: (launch: RunLaunch) => boolean): Promise<OpenedRound | null>;
|
|
59
60
|
/** A grade's write (PUT /runs/{id}/grade): keeps `grade` for agent `agentId` naming no round, opens its run again on the
|
|
60
61
|
* round it asks for (openFeedbackRound), and only then marks the kept grade with that round and its steer. The grade is
|
|
61
62
|
* kept first, so the round's end reads it; the round is named last, so a reopen that fails (thrown, or a run that can't
|
|
62
63
|
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
63
|
-
export declare function keepGrade(store: Pick<Store, "runs" | "agents" | "settings">, agentId: string, grade: Grade, label: string | undefined): Promise<Grade>;
|
|
64
|
+
export declare function keepGrade(store: Pick<Store, "runs" | "agents" | "settings">, agentId: string, grade: Grade, label: string | undefined, canTurn?: (launch: RunLaunch) => boolean): Promise<Grade>;
|