@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.59
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 +376 -0
- package/README.md +393 -118
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +7 -5
- package/dist/box-paths.js +12 -8
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +121 -0
- package/dist/claude-login-token.js +797 -0
- package/dist/claude-login.d.ts +119 -34
- package/dist/claude-login.js +551 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +325 -328
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +40 -19
- package/dist/computer-attach.js +326 -62
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +12 -11
- package/dist/computers.js +11 -8
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +139 -5
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +13 -5
- package/dist/env-switch.js +24 -6
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +12 -4
- package/dist/fal-price.js +110 -26
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.js +9 -6
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +8 -0
- package/dist/harness-table.js +17 -6
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +173 -0
- package/dist/learn/ledger.js +225 -0
- package/dist/learn/promote.d.ts +82 -39
- package/dist/learn/promote.js +61 -66
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +40 -21
- package/dist/learning-cost.js +30 -21
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +9 -0
- package/dist/live-reach.js +9 -0
- package/dist/mcp-api-only-origins.d.ts +23 -3
- package/dist/mcp-api-only-origins.js +57 -17
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +234 -61
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +59 -34
- package/dist/place-offers.js +100 -58
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +5 -4
- package/dist/provider.js +26 -13
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.js +3 -1
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +97 -63
- package/dist/runner/adapter-run-spec.d.ts +34 -14
- package/dist/runner/adapter-run-spec.js +120 -75
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +29 -13
- package/dist/runner/claim-secrets.d.ts +27 -18
- package/dist/runner/claim-secrets.js +61 -47
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +93 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +19 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +24 -18
- package/dist/runner/mcp-claim.js +24 -7
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +10 -8
- package/dist/runner/presence.d.ts +11 -4
- package/dist/runner/presence.js +11 -6
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +38 -12
- package/dist/runner/run-child-host.js +231 -83
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +5 -3
- package/dist/runner/runner.js +14 -10
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +138 -37
- package/dist/runner/workflow-first.js +230 -99
- package/dist/runner/workflow-spec.js +2 -2
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +33 -10
- package/dist/server.js +454 -136
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +44 -4
- package/dist/store/schema.js +111 -11
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +19 -2
- package/dist/store/sqlite/run-patch.js +67 -2
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +177 -32
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +74 -25
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +102 -136
- package/dist/store-reads/learning.js +251 -302
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +91 -9
- package/dist/template-eval.js +448 -105
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +14 -14
- package/dist/timeline/web-calls.js +18 -30
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +50 -11
- package/dist/tool-plane.js +94 -30
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +27 -55
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +38 -11
- package/dist/workspace/attached-computers.js +81 -16
- package/dist/workspace/computer-deps.d.ts +29 -7
- package/dist/workspace/computer-deps.js +36 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +166 -57
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +152 -0
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +6 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +25 -9
- package/dist/console/assets/backend-DVhHzJX2.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -49,7 +49,7 @@ import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
|
49
49
|
import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
50
50
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
51
51
|
import { settingOfDefinition } from "../computer-setting.js";
|
|
52
|
-
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
52
|
+
import { computerFilesNote, computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
53
53
|
import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
|
|
54
54
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
55
55
|
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, claimLiveAt, graderRouteOf, heldModelOf, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, seedEvalFiles, webHostTools } from "./adapter-run-spec.js";
|
|
@@ -59,7 +59,7 @@ import { isWebHostTool } from "../tool-list.js";
|
|
|
59
59
|
import { hostToolOf } from "../host-tools.js";
|
|
60
60
|
import { ASK_TOOL, askPerson } from "../tools.js";
|
|
61
61
|
import { fakedPlane } from "../web-fake.js";
|
|
62
|
-
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys,
|
|
62
|
+
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
63
63
|
import { claimMetering, mcpWhereHeld } from "./mcp-run.js";
|
|
64
64
|
import { held as runnerSeam, heldSignInReads } from "./held.js";
|
|
65
65
|
import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
@@ -72,14 +72,14 @@ import { journalEntries } from "./journal-reader.js";
|
|
|
72
72
|
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
73
73
|
import { replayCallsOver } from "./promotion.js";
|
|
74
74
|
import { learnedFirstWhereHeld } from "./learned-first.js";
|
|
75
|
-
import { pathMetrics } from "./workflow-first.js";
|
|
76
75
|
import { AUDIT_PARKED, withAudit } from "./audit.js";
|
|
77
76
|
import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
|
|
78
|
-
import {
|
|
77
|
+
import { runPathMetricsOverStore } from "../store-reads/learning.js";
|
|
79
78
|
import { specBuilt } from "./spec-holds.js";
|
|
80
79
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
81
80
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
82
|
-
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
81
|
+
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginByToken, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
82
|
+
import { heldTokenLogin } from "../claude-login-token.js";
|
|
83
83
|
import { heldSpecOf } from "./held-run.js";
|
|
84
84
|
import { loopComputerOf } from "./computer-channel.js";
|
|
85
85
|
import { githubAppAccess } from "./github-app.js";
|
|
@@ -90,7 +90,7 @@ import { monidForClaim, withMonid } from "./monid-run.js";
|
|
|
90
90
|
import { verifyPlacedProject, movedSkillFiles } from "../source-sync/claim.js";
|
|
91
91
|
import { projectCheckpointForRun } from "./project-checkpoint.js";
|
|
92
92
|
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
93
|
-
import { routeTrace } from "../otel/genai.js";
|
|
93
|
+
import { agentOfRun, routeTrace } from "../otel/genai.js";
|
|
94
94
|
/** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
|
|
95
95
|
export const cliRefusesKind = (kind) => kind === "browser" ? "This agent's computer is a browser, which only the pi harness drives here: pick pi for this agent, or another kind of computer in Settings → Computers." : undefined;
|
|
96
96
|
/** The run's model and the catalog that prices it, as main chooses a CLI run's (app.ts wireModels and runModels): on the
|
|
@@ -176,7 +176,7 @@ export async function cliCapModel(entry, env, ref) {
|
|
|
176
176
|
export function cliRunEnv(env, data, claimed = {}, plane, runKey, claim) {
|
|
177
177
|
// A run with its own model key: that key alone, in the variables its route sends (claimModelEnv, never enumerable), and
|
|
178
178
|
// the claim's request metadata beside it (request-metadata.ts, never enumerable either).
|
|
179
|
-
const out = claimModelEnv(env ?? {}, claimed, runKey, claim);
|
|
179
|
+
const out = claimModelEnv(env ?? {}, [claimed], runKey, claim);
|
|
180
180
|
Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
|
|
181
181
|
delete out[TOOL_PLANE_ENV];
|
|
182
182
|
if (plane && Object.keys(plane).length)
|
|
@@ -254,6 +254,28 @@ async function rmEmptyParents(parents) {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
+
/** The login a run starts on: Claude Code's login on this machine, where the owner turned it on for claude-agent here
|
|
258
|
+
* (claude-login.ts), the run carrying only where it is, its CLI saying it is signed in before the run starts. A run that
|
|
259
|
+
* brought its own key (`keyed`) runs on that key, and a run in a sandbox place on the model keys. A run's own process (no
|
|
260
|
+
* seal key: a user of its own, which cannot open the login's folder) goes on its runner's reader of the login's access
|
|
261
|
+
* token alone (held.ts claudeLogin), each token it hands held by `hold` (the redactors) and this process's own; its CLI
|
|
262
|
+
* then never gets a refresh token. Such a process never reads the login's setting itself: whether its run is on the
|
|
263
|
+
* login is its runner's to say. Its claim read the setting (run-child-host.ts staysInRunner), so a turn-on after the
|
|
264
|
+
* claim never moves it onto a login the claim did not check (a user of its own, a process runner on the same folder);
|
|
265
|
+
* a claim that read it on has the runner read it again at the start, which refuses the start in fixed words when that
|
|
266
|
+
* read names none or another folder. Nor could the process read it: the setting names the machine by the id in the
|
|
267
|
+
* server's data folder (claude-login.ts machineId), which the run's user can neither read nor make there. The runner's
|
|
268
|
+
* answer is the one decision (none: not on the login). A
|
|
269
|
+
* claim on a login other than AgentRun's own folder never gets this far: the claim itself is refused (staysInRunner,
|
|
270
|
+
* in LOGIN_MACHINE_NEEDS_SERVER_USER's words). A run in the runner itself (a seal key) reads the setting here. */
|
|
271
|
+
export async function runLoginOf(deps, keyed, name, place, hold) {
|
|
272
|
+
if (keyed)
|
|
273
|
+
return undefined;
|
|
274
|
+
if (deps.sealKey)
|
|
275
|
+
return loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, place);
|
|
276
|
+
const handed = await runnerSeam()?.claudeLogin();
|
|
277
|
+
return handed && heldTokenLogin(handed, hold);
|
|
278
|
+
}
|
|
257
279
|
/**
|
|
258
280
|
* One claimed CLI run's AdapterRunSpec, built from its launch record and its revision.
|
|
259
281
|
*
|
|
@@ -353,15 +375,6 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
353
375
|
});
|
|
354
376
|
}
|
|
355
377
|
}
|
|
356
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
357
|
-
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
358
|
-
// Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
|
|
359
|
-
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
360
|
-
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
361
|
-
redact.hold(values); };
|
|
362
|
-
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 } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, runRow.agentId, launch) });
|
|
363
|
-
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
364
|
-
holds.hold({ passed: mcp });
|
|
365
378
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
366
379
|
// on the claim's Archil disk (archil-claim.ts: its keys from the store's sealed rows, under the runner's seal key, in
|
|
367
380
|
// this claim's memory only, dropped at the release); else Mode 1, the run's local folder.
|
|
@@ -385,6 +398,25 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
385
398
|
? await openRunWorkspace({ mode: 1, agentId: runRow.agentId, runId: claim.runId, data: deps.data, log })
|
|
386
399
|
: await openRunWorkspace({ mode: 2, agentId: runRow.agentId, runId: claim.runId, archil, log });
|
|
387
400
|
holds.hold({ ws });
|
|
401
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
402
|
+
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
403
|
+
// Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
|
|
404
|
+
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
405
|
+
// A held run its model kept from running at its create (hold.refused) opens none: nothing can call one.
|
|
406
|
+
const heldRefusal = launch.hold?.refused?.message;
|
|
407
|
+
// What its gateway files (a long answer, a server's results) goes in the run's own files. In Mode 1 that is the run's
|
|
408
|
+
// folder on this machine (ws.workspace below, the folder a box bind-mounts). In Mode 2 it is the run's Archil disk:
|
|
409
|
+
// through the run's computer once it mounts the folder (filedIn, set at runTools), since the mount holds the disk's
|
|
410
|
+
// write delegation and a write over the disk's file API is refused (409) while it does; over that file API (ws.workspace)
|
|
411
|
+
// when no computer mounts it. The gateway reads work() only when a call is answered (mcp-gateway.ts textOf, fileResults),
|
|
412
|
+
// and a call reaches it only through the session this spec returns, after `tools` is made. After the run's Workspace,
|
|
413
|
+
// as the pi spec makes it: a refusal lets the Workspace and the Archil claim go (holds above).
|
|
414
|
+
let filedIn;
|
|
415
|
+
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
416
|
+
redact.hold(values); };
|
|
417
|
+
const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), 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 } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
|
|
418
|
+
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
419
|
+
holds.hold({ passed: mcp });
|
|
388
420
|
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
389
421
|
const checkout = body.checkout ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part }), body.checkout) : undefined;
|
|
390
422
|
holds.hold({ checkout });
|
|
@@ -424,9 +456,10 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
424
456
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
425
457
|
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
426
458
|
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer), as the pi
|
|
427
|
-
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount)
|
|
428
|
-
// screen's recording (computer.record) goes in the run's
|
|
429
|
-
|
|
459
|
+
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount); a park's
|
|
460
|
+
// row names the disk that credential is on (mountDisk). Its screen's recording (computer.record) goes in the run's
|
|
461
|
+
// recordings folder, as the pi spec's does.
|
|
462
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(offAlready ? { turnedOff: offAlready } : {}), 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)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit(), mountDisk: () => archil.disk.id } : {}), ...(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) } : {}) });
|
|
430
463
|
holds.hold({ computer });
|
|
431
464
|
const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
|
|
432
465
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
@@ -452,6 +485,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
452
485
|
const bashPolicy = bashPolicyOf(body.toolSettings);
|
|
453
486
|
// A computer that replaced an earlier claim's holds its acts to what it showed, as the pi spec's does.
|
|
454
487
|
const tools = await runTools(ws.workspace, computer.computer, { mode, context, aliases: [scratch], ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
|
|
488
|
+
filedIn = tools.workspace;
|
|
455
489
|
let remoteProjectCapture = false;
|
|
456
490
|
holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
|
|
457
491
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
@@ -487,10 +521,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
487
521
|
if (runKey)
|
|
488
522
|
holdRunKey(redact, runKey);
|
|
489
523
|
}
|
|
490
|
-
|
|
491
|
-
// carries only where it is, and its CLI says it is signed in before the run starts. A run that brought its own key
|
|
492
|
-
// runs on that key, and a run in a sandbox place on the model keys.
|
|
493
|
-
const login = keyed ? undefined : await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place);
|
|
524
|
+
const login = await runLoginOf(deps, keyed, name, launch.place, hold);
|
|
494
525
|
const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey, claim), login);
|
|
495
526
|
// A plan-billed recipe's keys saved for its harness alone (harness-keys.ts), opened at each claim for this run's harness
|
|
496
527
|
// and no other (a run's own process asks its runner, which opens its claim's own: held.ts harnessKeys), held by the
|
|
@@ -504,34 +535,42 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
504
535
|
// is chosen, so it never falls to its owner's sign-in (a row counted at its claim may be gone, or not open, by now).
|
|
505
536
|
// A person's claim that laid none keeps its session on the sign-in (or on nothing) for good: a trigger's message the
|
|
506
537
|
// claim takes later is refused in it (personOnly), keys saved since or not, as no new claim opens them.
|
|
538
|
+
// A held run its model kept from running (hold.refused, above) opens none: its agent never starts.
|
|
507
539
|
const recipe = name === undefined ? undefined : planRecipeOf(deps.env ?? {}, name);
|
|
508
540
|
const recipeKeys = recipe?.keys;
|
|
509
541
|
let personOnly;
|
|
510
542
|
if (recipe !== undefined && recipeKeys?.length) {
|
|
511
543
|
for (const key of recipeKeys)
|
|
512
544
|
delete env[key];
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
545
|
+
if (heldRefusal === undefined) {
|
|
546
|
+
const opened = deps.sealKey ? await openHarnessKeys(deps.store, deps.sealKey, recipe) : ((await runnerSeam()?.harnessKeys(recipe.digest)) ?? {});
|
|
547
|
+
hold(Object.values(opened));
|
|
548
|
+
if (recipeKeys.every((key) => typeof opened[key] === "string" && opened[key] !== ""))
|
|
549
|
+
layHarnessKeys(env, opened);
|
|
550
|
+
else if (!personStarted(launch))
|
|
551
|
+
throw new ClaimRefused(RECIPE_SIGN_IN_PERSON_ONLY);
|
|
552
|
+
else
|
|
553
|
+
personOnly = RECIPE_TURN_PERSON_ONLY;
|
|
554
|
+
}
|
|
521
555
|
}
|
|
522
556
|
// A held run its model kept from running at its create (hold.refused) chooses no model here, and no plan or login is
|
|
523
557
|
// asked before it: its model's route chooses no model and reads no key, its adapter's provider being the stand-in that
|
|
524
|
-
// refuses every request in the create's words (adapters.ts providerOf), never a key or the Claude login
|
|
525
|
-
//
|
|
526
|
-
//
|
|
527
|
-
//
|
|
528
|
-
|
|
558
|
+
// refuses every request in the create's words (adapters.ts providerOf), never a key or the Claude login; a plan-billed
|
|
559
|
+
// agent's adapter is built on no key and refuses its start in those words (harness-table.ts acpPlanEntryOf). Its claim
|
|
560
|
+
// lays only the keys any claim of the run lays (its tools', a key handed with it: claimSecrets lays it no model key, and
|
|
561
|
+
// no key saved for its harness, above) and takes no learning step (below), so it holds the computer on a host with no
|
|
562
|
+
// key for its model, and a key saved since runs a new run, never this one.
|
|
529
563
|
const chosen = heldRefusal !== undefined ? heldChoice(body.model) : await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
530
564
|
if (heldRefusal === undefined) {
|
|
531
565
|
await planBeforeRun(env, chosen.model);
|
|
532
566
|
if (login && entry.priceModel(env, chosen.model).provider === CLAUDE_LOGIN_PROVIDER) {
|
|
533
|
-
|
|
534
|
-
|
|
567
|
+
// On a token: one read before the run, refused in its words (signed out, near its end) as the CLI's own check is.
|
|
568
|
+
if (loginByToken(login))
|
|
569
|
+
await login.token();
|
|
570
|
+
else {
|
|
571
|
+
const claude = await import("@parcha/agentrun-harness-claude");
|
|
572
|
+
await loginBeforeRun(login, loginCli(claudeCliIn(installDirOf(deps.data, name), claude.claudeAgentPlatform()), env), (cli, at) => claude.claudeLoginStatus(cli, at, env.PATH ? { path: env.PATH } : {}), { data: deps.data });
|
|
573
|
+
}
|
|
535
574
|
}
|
|
536
575
|
}
|
|
537
576
|
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
@@ -629,6 +668,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
629
668
|
// native tools are named by its facts on the owner's table (factsOf: a module's harness's too).
|
|
630
669
|
const ownerFacts = factsOf(deps.env, name);
|
|
631
670
|
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, { ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}), facts: ownerFacts, turnedOff: offAlready !== undefined, onComputerOff: (kind) => recordComputerOff(run.harness, kind) });
|
|
671
|
+
// A park lets a computer the gate turned off go rather than keep it (SpecHolds Held.computerOff).
|
|
672
|
+
holds.hold({ computerOff: gate.computerOff });
|
|
632
673
|
// The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
|
|
633
674
|
// (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
|
|
634
675
|
// (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
|
|
@@ -683,7 +724,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
683
724
|
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself. A held run its model kept from
|
|
684
725
|
// running takes none of them, as on pi: it settles no audit and starts no replay run, starts on no workflow, and its
|
|
685
726
|
// tool runs none (so no learned tier is routed, below).
|
|
686
|
-
const learned = audits ? 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: audits.spendOff, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: {}, workflows: [] };
|
|
727
|
+
const learned = audits ? 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: audits.spendOff, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: { reason: "held" }, workflows: [] };
|
|
687
728
|
const firstChoice = learned.choice;
|
|
688
729
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
689
730
|
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
@@ -727,7 +768,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
727
768
|
const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
|
|
728
769
|
for (const redact of new Set([held, cut]))
|
|
729
770
|
holdClaimed(redact, tierKeys);
|
|
730
|
-
const modelEnv = claimModelEnv(deps.env,
|
|
771
|
+
const modelEnv = claimModelEnv(deps.env, [tierKeys, claimed], runKey, claim);
|
|
731
772
|
const tiers = new Map();
|
|
732
773
|
for (const [tier, routed] of await learnedTierRoutes(workflows, modelEnv, (tier) => deps.routeOf(undefined, modelEnv, tier, PI_WIRES, undefined, cut))) {
|
|
733
774
|
if ("why" in routed)
|
|
@@ -753,7 +794,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
753
794
|
system: [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line)),
|
|
754
795
|
// The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
|
|
755
796
|
// redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
|
|
756
|
-
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
797
|
+
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), { results, writes: gate.writes() }), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
757
798
|
context: "fresh",
|
|
758
799
|
...(thinking ? { thinking } : {}),
|
|
759
800
|
};
|
|
@@ -797,8 +838,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
797
838
|
// The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry), as on pi.
|
|
798
839
|
...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
|
|
799
840
|
...(cap ? { cap } : {}),
|
|
800
|
-
// Its model, as its GenAI trace names it (otel/genai.ts); its requests' host is its CLI's own to choose.
|
|
801
|
-
|
|
841
|
+
// Its model, as its GenAI trace names it (otel/genai.ts); its requests' host is its CLI's own to choose. And the agent
|
|
842
|
+
// the run is of (its id and name; the loop cuts them).
|
|
843
|
+
trace: { ...routeTrace({ named: `${chosen.model.provider}/${chosen.model.modelId}`, model: chosen.model.modelId }), agent: await agentOfRun(deps.store.agents, runRow.agentId) },
|
|
802
844
|
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
803
845
|
// the catalog tools the session mounts; absent when none.
|
|
804
846
|
...(catalog ? { mcp: catalog } : {}),
|
|
@@ -822,6 +864,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
822
864
|
...(tools.computer ? { scriptComputer: tools.computer } : {}),
|
|
823
865
|
// A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
|
|
824
866
|
...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
|
|
867
|
+
// A desktop or a phone that holds none of the run's files: the model is told once in the run where they are, or, where
|
|
868
|
+
// the gate would refuse a save (RunGate.writeBar), that a screenshot can't be saved to them.
|
|
869
|
+
...(tools.apart ? { computerFilesNote: computerFilesNote({ ...tools.apart, writes: gate.writes(), outlives: computer.outlives === true }) } : {}),
|
|
825
870
|
workRoot: root,
|
|
826
871
|
// Where the CLI works (its working directory, the run's folder to its file tools): what its absolute paths are read
|
|
827
872
|
// against on the run's rows.
|
|
@@ -849,14 +894,16 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
849
894
|
const metrics = cliRunMetrics(piShaped(entries), booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}`, catalog: await hashedMcpOf(deps.store, claim.runId) });
|
|
850
895
|
// Its cost is endCost's, read apart (an unknown one written as null, never left out: a follow-up's end clears the
|
|
851
896
|
// cost an earlier end stored).
|
|
852
|
-
return { metrics: { ...metrics, ...
|
|
897
|
+
return { metrics: { ...metrics, ...(await runPathMetricsOverStore(deps.store, claim.runId, launch, { ...(run.redact ? { redact: run.redact } : {}), choice: firstChoice.reason })), costBasis: costBasisOf(booked) } };
|
|
853
898
|
},
|
|
854
899
|
// A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
|
|
855
900
|
...(heldComputer ? { held: heldComputer } : {}),
|
|
856
901
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (idempotent with
|
|
857
902
|
// the computer's release). A run that minted none revokes nothing. At a park, a desktop or a phone is kept for the
|
|
858
|
-
// resume instead, its mount credential with it, as the pi spec's
|
|
859
|
-
|
|
903
|
+
// resume instead, its mount credential with it, as the pi spec's, said once its row is written; one the gate turned
|
|
904
|
+
// off is not, nor said to be.
|
|
905
|
+
keptWords: () => (computer.keeps === undefined || gate.computerOff() ? undefined : computerKeptWords(computer.keeps)),
|
|
906
|
+
...(computer.keeps && computer.keepRow ? { keep: () => computer.keepRow() } : {}),
|
|
860
907
|
release: (how) => holds.release(how),
|
|
861
908
|
...(movedProject ? { projectCheckpoint: projectCheckpointForRun({ store: deps.store, agentId: runRow.agentId, claim, launch, tools, computer,
|
|
862
909
|
workspace: { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } },
|
|
@@ -15,7 +15,8 @@ export type CompareEndDeps = {
|
|
|
15
15
|
};
|
|
16
16
|
/** The end-of-run step of a replay run or an audit's shadow (its callers pass no other run): its comparison (above),
|
|
17
17
|
* asked only when the run completed, was not cut, has a grader (its route exists only for a revision that names no
|
|
18
|
-
* agree_on, graderRouteOf), and the two answers are not already the same
|
|
18
|
+
* agree_on, graderRouteOf), and the two answers are not already the same (then a replay keeps only the grade it was judged
|
|
19
|
+
* with, `same` and no model asked). In a run's own process the step is its runner's (held.ts endOfRun): it reads other runs and the
|
|
19
20
|
* learning ledger, which no run's process may. A comparison that fails keeps no verdict: the pair then differs, compared
|
|
20
21
|
* whole (compareAnswers), in the log's words. */
|
|
21
22
|
export declare function compareEndOfRun(launch: RunLaunch, deps: CompareEndDeps): EndOfRunTurn | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
2
|
-
import { gradeAnswers, sameAnswer } from "../learn/promote.js";
|
|
2
|
+
import { answersPair, comparedGrade, gradeAnswers, gradesOf, knownAnswerText, sameAnswer } from "../learn/promote.js";
|
|
3
3
|
import { runPathOverStore } from "../store-reads/learning.js";
|
|
4
4
|
import { auditedAnswerOf } from "./audit.js";
|
|
5
5
|
import { held, heldEndOfRun } from "./held.js";
|
|
@@ -11,17 +11,22 @@ export const GRADER = "grader";
|
|
|
11
11
|
const GRADER_MAX_TOKENS = 1_000;
|
|
12
12
|
/** The job input as the grader reads it: the launch's text, or its typed input as JSON. */
|
|
13
13
|
const inputText = (input) => (typeof input === "string" ? input : JSON.stringify(input ?? null));
|
|
14
|
-
/** The two answers a replay run or a shadow compares at its end: the
|
|
15
|
-
* answer is its own, when the workflow it replays answered it;
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
/** The two answers a replay run or a shadow compares at its end: the known one and the workflow's. A replay's workflow
|
|
15
|
+
* answer is its own, when the workflow it replays answered it; its known answer is its source run's newest grade's
|
|
16
|
+
* expected answer written over that run's own answer (knownAnswerText, which the check reads too), else that run's
|
|
17
|
+
* own answer, with that grade (`graded`, null for none), which its verdict keeps. A shadow's agent answer is its own;
|
|
18
|
+
* the workflow's is the served run's answer it audits (its open ledger line's turn). Null: nothing to compare. */
|
|
18
19
|
async function pairOf(launch, deps, runId) {
|
|
19
20
|
if (launch.replay) {
|
|
20
21
|
const path = await runPathOverStore(deps.store, runId, launch.learning, deps.redact);
|
|
21
22
|
if (path.path !== "workflow" || path.workflow !== launch.replay.workflow)
|
|
22
23
|
return null;
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const workflow = await answerOf(deps.store, runId, BACKGROUND_CONTEXT);
|
|
25
|
+
const said = await answerOf(deps.store, launch.replay.of, BACKGROUND_CONTEXT);
|
|
26
|
+
// The grade read once: the verdict keeps it, so the check judges this input on the grade its grader was asked against.
|
|
27
|
+
const graded = await gradeOf(deps.store, launch.replay.of);
|
|
28
|
+
const agent = graded?.expected ? knownAnswerText(said, graded.expected) : said;
|
|
29
|
+
return workflow === null || agent === null ? null : { agent, workflow, graded };
|
|
25
30
|
}
|
|
26
31
|
if (launch.audit) {
|
|
27
32
|
const [agent, workflow] = [await answerOf(deps.store, runId, BACKGROUND_CONTEXT), await auditedAnswerOf({ store: deps.store, context: BACKGROUND_CONTEXT, folder: deps.folder }, runId)];
|
|
@@ -29,9 +34,15 @@ async function pairOf(launch, deps, runId) {
|
|
|
29
34
|
}
|
|
30
35
|
return null;
|
|
31
36
|
}
|
|
37
|
+
/** Run `of`'s newest grade as the check judges it (comparedGrade), null when it has none. */
|
|
38
|
+
async function gradeOf(store, of) {
|
|
39
|
+
const source = await store.runs.get(of);
|
|
40
|
+
return comparedGrade(source ? (await gradesOf(store.settings, source.agentId)).findLast((one) => one.run === of) : undefined);
|
|
41
|
+
}
|
|
32
42
|
/** The end-of-run step of a replay run or an audit's shadow (its callers pass no other run): its comparison (above),
|
|
33
43
|
* asked only when the run completed, was not cut, has a grader (its route exists only for a revision that names no
|
|
34
|
-
* agree_on, graderRouteOf), and the two answers are not already the same
|
|
44
|
+
* agree_on, graderRouteOf), and the two answers are not already the same (then a replay keeps only the grade it was judged
|
|
45
|
+
* with, `same` and no model asked). In a run's own process the step is its runner's (held.ts endOfRun): it reads other runs and the
|
|
35
46
|
* learning ledger, which no run's process may. A comparison that fails keeps no verdict: the pair then differs, compared
|
|
36
47
|
* whole (compareAnswers), in the log's words. */
|
|
37
48
|
export function compareEndOfRun(launch, deps) {
|
|
@@ -42,10 +53,14 @@ export function compareEndOfRun(launch, deps) {
|
|
|
42
53
|
return undefined;
|
|
43
54
|
try {
|
|
44
55
|
const pair = await pairOf(launch, deps, input.runId);
|
|
45
|
-
if (!pair
|
|
56
|
+
if (!pair)
|
|
46
57
|
return undefined;
|
|
58
|
+
// Equal answers ask no model; a replay's record still keeps the grade it was judged with (Compared.graded).
|
|
59
|
+
if (sameAnswer(pair.agent, pair.workflow))
|
|
60
|
+
return pair.graded === undefined ? undefined : { also: [], compared: { same: true, pair: answersPair(pair.agent, pair.workflow), graded: pair.graded } };
|
|
47
61
|
const grade = input.grade;
|
|
48
|
-
const
|
|
62
|
+
const verdict = await gradeAnswers(inputText(launch.input), pair.agent, pair.workflow, { model: input.grader, ask: (request) => grade(request) });
|
|
63
|
+
const compared = pair.graded !== undefined ? { ...verdict, graded: pair.graded } : verdict;
|
|
49
64
|
return { also: [], compared };
|
|
50
65
|
}
|
|
51
66
|
catch (error) {
|
|
@@ -256,7 +256,7 @@ async function world(subject, t, timing = STEADY) {
|
|
|
256
256
|
* it (Claim.lost names that same runner), gives it back as a run it still holds, and the runner that then takes it over
|
|
257
257
|
* claims a released run, not a lost one: the timeline never says the run went on after the crashed runner was lost. */
|
|
258
258
|
const claimsSettled = async (name) => void (await Promise.allSettled([...(claiming.get(name) ?? [])]));
|
|
259
|
-
const start = async (name, setup, holder
|
|
259
|
+
const start = async (name, setup, holder) => {
|
|
260
260
|
const store = await openCaseStore({ dataDir: dir, role: "runner", url, env, clockFile });
|
|
261
261
|
stores.push(store);
|
|
262
262
|
// Each journal commit's outcome, by the claim's epoch (as child.ts records its process's): what a loop wrote, and
|
|
@@ -265,7 +265,6 @@ async function world(subject, t, timing = STEADY) {
|
|
|
265
265
|
const observedLoop = (deps) => {
|
|
266
266
|
const loop = factory({
|
|
267
267
|
...deps,
|
|
268
|
-
...more,
|
|
269
268
|
journal: (claim) => new Proxy(deps.journal(claim), {
|
|
270
269
|
get(target, property) {
|
|
271
270
|
const value = Reflect.get(target, property, target);
|
|
@@ -1116,7 +1115,7 @@ const CASES = [
|
|
|
1116
1115
|
answers.push(await input.ask(prompt, { origin: "reflect", deadlineMs: 10_000 }));
|
|
1117
1116
|
return undefined;
|
|
1118
1117
|
};
|
|
1119
|
-
await w.start("runner-a", { script: [{ say: "the job's answer" }, { say: "a note" }], tools, hooks: quiet, agentId: "agent-1"
|
|
1118
|
+
await w.start("runner-a", { script: [{ say: "the job's answer" }, { say: "a note" }], tools, hooks: quiet, agentId: "agent-1", endOfRun });
|
|
1120
1119
|
await w.ended("ended");
|
|
1121
1120
|
assert.equal(answers.length, 1, "asked once");
|
|
1122
1121
|
const answer = answers[0];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { CallRecord } from "../journal-reader.js";
|
|
3
|
-
import type { Journal, LoopFactory } from "../loop-contract.js";
|
|
3
|
+
import type { EndOfRunTurn, Journal, LoopFactory } from "../loop-contract.js";
|
|
4
4
|
/** One step of the model's script: call a tool, say a text, or say the text of the last steer it was given. */
|
|
5
5
|
export type ScriptStep = {
|
|
6
6
|
readonly call: ToolName | MetaToolName;
|
|
@@ -61,6 +61,9 @@ export interface ConformanceSetup {
|
|
|
61
61
|
readonly hooks: KernelHooks;
|
|
62
62
|
/** The run's agent, for the subject's spec to name (AdapterRunSpec.agentId): the end-of-run step is asked with it. */
|
|
63
63
|
readonly agentId?: string;
|
|
64
|
+
/** The run's end-of-run step, for the subject's spec to carry (AdapterRunSpec.endOfRun), where every run's step comes
|
|
65
|
+
* from: a loop's deps carry none. */
|
|
66
|
+
readonly endOfRun?: EndOfRunTurn;
|
|
64
67
|
/** Called with each message the subject's model is handed, when the subject can see it (a stand-in's fake reports what
|
|
65
68
|
* it consumed and at what priority): for a case's failure message to name, never asserted on. */
|
|
66
69
|
readonly received?: (message: {
|
|
@@ -130,11 +130,11 @@ async function loopOn(deps, harness, launch, runId) {
|
|
|
130
130
|
const entry = harnessOf(env, harness);
|
|
131
131
|
// A run that learns supplies its own end-of-run step (reflect + proposal over its store) from its spec builder now,
|
|
132
132
|
// where the run's Archil claim is: a Mode 2 run's learning folder is on its claim's disk, not this machine's local
|
|
133
|
-
// path (adapter-run-spec.ts / cli-run-spec.ts endOfRun). The
|
|
134
|
-
//
|
|
133
|
+
// path (adapter-run-spec.ts / cli-run-spec.ts endOfRun). The spec is the loop's only source of a step; a run that does
|
|
134
|
+
// not learn supplies none. The same for the pi and the CLI spec.
|
|
135
135
|
return createAdapterLoop((claim, adapterRun) => entry?.facts && entry.adapter
|
|
136
136
|
? cliRunSpecFromLaunch(launch, adapterRun, deps, claim)
|
|
137
|
-
: adapterRunSpecFromLaunch(launch, adapterRun, deps, claim, runner), deps.modelRetry
|
|
137
|
+
: adapterRunSpecFromLaunch(launch, adapterRun, deps, claim, runner), { ...deps.modelRetry, ...(deps.tracing ? { tracing: deps.tracing } : {}) });
|
|
138
138
|
}
|
|
139
139
|
return undefined;
|
|
140
140
|
}
|
package/dist/runner/held.d.ts
CHANGED
|
@@ -62,6 +62,20 @@ export interface Held {
|
|
|
62
62
|
projectCheckpoint(signal?: AbortSignal): Promise<ProjectCheckpoint>;
|
|
63
63
|
/** The ChatGPT sign-in's reader (chatgpt-plan.ts planReaderOf), for a run whose models reach the plan; else none. */
|
|
64
64
|
plan(): Promise<PlanReader | undefined>;
|
|
65
|
+
/** Claude Code's login on this machine, for a claim of a run that goes on it (claude-login.ts loginForRun, the
|
|
66
|
+
* claim's own harness and place, and no model key of its own): its access token alone, read by the runner at each ask
|
|
67
|
+
* and renewed by it when near its end (claude-login-token.ts LoginTokens), which throws in words where there is none
|
|
68
|
+
* to hand; `refused(sent)` tells the runner Anthropic refused `sent` (the CLI's 401), so the next ask renews it. Else
|
|
69
|
+
* none, and the claim does not go on the login: the one answer to that, since the process can read neither the
|
|
70
|
+
* setting's machine id nor the login's folder. A claim that read the login on has the runner read the setting again
|
|
71
|
+
* here, at the start, and is refused in fixed words (claude-login-token.ts LOGIN_CHANGED_SINCE_CLAIM, no folder in
|
|
72
|
+
* them) when that read names none or another folder, never left to a model key. A claim on a login other than
|
|
73
|
+
* AgentRun's own folder is refused at the claim (run-child-host.ts staysInRunner, LOGIN_MACHINE_NEEDS_SERVER_USER),
|
|
74
|
+
* before this is asked. */
|
|
75
|
+
claudeLogin(): Promise<{
|
|
76
|
+
token(): Promise<string>;
|
|
77
|
+
refused(sent: string): Promise<void>;
|
|
78
|
+
} | undefined>;
|
|
65
79
|
/** Whether a browser sign-in handed to the run reads back here (sign-ins-store.ts handedSignInReadsBack). */
|
|
66
80
|
signInReadsBack(): Promise<boolean>;
|
|
67
81
|
/** The run's browser sign-in for vendor `resolution` (sign-ins-store.ts runSignIn). */
|
|
@@ -74,10 +88,11 @@ export interface Held {
|
|
|
74
88
|
* out and its launch's payload names the pull request. Its mint makes a token of that repository alone, contents
|
|
75
89
|
* read, whatever the process names; its MCP mints on the runner (mcp). */
|
|
76
90
|
githubAppAccess(): Promise<GithubAppAccessAt | undefined>;
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
/** The saved model keys of the models of the claim's subagent tiers (claim-secrets.ts subagentTierKeys asks): an agentic
|
|
92
|
+
* run granted the subagent tool gets its routed tiers' keys; a replay's or an audit's grader, its fast tier's key alone
|
|
93
|
+
* (none when its revision names agree_on or routes no fast tier). None to any other run, to one that holds a model key
|
|
94
|
+
* of its own, or to a held run its model kept from running. */
|
|
95
|
+
subagentTierKeys(): Promise<Record<string, string>>;
|
|
81
96
|
/** The model keys the host's models of `tiers` need (claim-secrets.ts tierModelKeys), the plan's reader with them: of
|
|
82
97
|
* the tiers the claim's learned workflows name, as the runner chose them (learnedFirst), alone. */
|
|
83
98
|
tierModelKeys(tiers: readonly Tier[]): Promise<{
|
|
@@ -298,11 +298,14 @@ export interface AnswerData {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
/** The calls of a tool a run's journal shows (toolCalls): `ran`, the ids run to a good end, and `unnamed`, those pi
|
|
301
|
-
* recorded with no id; `ended`, every id with a result of any kind (done, an error, a refusal or a deny)
|
|
301
|
+
* recorded with no id; `ended`, every id with a result of any kind (done, an error, a refusal or a deny); `args`, each
|
|
302
|
+
* call's arguments by its id, for the calls run to a good end: those its start (a CLI's) or its model's tool call (pi's)
|
|
303
|
+
* wrote last before that end, never a later one reusing the id. */
|
|
302
304
|
export type ToolCalls = {
|
|
303
305
|
readonly ran: ReadonlySet<string>;
|
|
304
306
|
readonly unnamed: number;
|
|
305
307
|
readonly ended: ReadonlySet<string>;
|
|
308
|
+
readonly args: ReadonlyMap<string, unknown>;
|
|
306
309
|
};
|
|
307
310
|
/** The calls of `tool` `entries` show: a CLI's (agentrun.call.start and its end) and pi's (a pi.tool-result of it), each
|
|
308
311
|
* call id once, however many records say it. Run to a good end: a CLI's end done, a pi result that is no error. */
|
|
@@ -153,14 +153,32 @@ export function toolCalls(entries, tool) {
|
|
|
153
153
|
const started = new Set();
|
|
154
154
|
const ran = new Set();
|
|
155
155
|
const ended = new Set();
|
|
156
|
+
const args = new Map();
|
|
157
|
+
// Each id's latest arguments not yet run: those a good end then fixes as the call's own. A call reusing an id that
|
|
158
|
+
// already ran changes nothing, and one whose id a refused or denied call had reads its own.
|
|
159
|
+
const asked = new Map();
|
|
160
|
+
const done = (id) => {
|
|
161
|
+
ran.add(id);
|
|
162
|
+
if (!args.has(id) && asked.has(id))
|
|
163
|
+
args.set(id, asked.get(id));
|
|
164
|
+
};
|
|
156
165
|
let unnamed = 0;
|
|
157
166
|
for (const entry of entries) {
|
|
158
|
-
if (entry.kind === KINDS.callStart && entry.data.tool === tool)
|
|
167
|
+
if (entry.kind === KINDS.callStart && entry.data.tool === tool) {
|
|
159
168
|
started.add(entry.data.callId);
|
|
169
|
+
asked.set(entry.data.callId, entry.data.input);
|
|
170
|
+
}
|
|
171
|
+
else if (entry.kind === "pi.assistant") {
|
|
172
|
+
const content = entry.model?.[0]?.content;
|
|
173
|
+
for (const block of Array.isArray(content) ? content : []) {
|
|
174
|
+
if (block?.type === "toolCall" && block.name === tool && typeof block.id === "string" && block.id)
|
|
175
|
+
asked.set(block.id, block.arguments);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
160
178
|
else if (entry.kind === KINDS.callEnd && started.has(entry.data.callId)) {
|
|
161
179
|
ended.add(entry.data.callId);
|
|
162
180
|
if (entry.data.status === "done")
|
|
163
|
-
|
|
181
|
+
done(entry.data.callId);
|
|
164
182
|
}
|
|
165
183
|
else if (entry.kind === "pi.tool-result") {
|
|
166
184
|
const result = entry.model?.[0];
|
|
@@ -172,12 +190,12 @@ export function toolCalls(entries, tool) {
|
|
|
172
190
|
if (result.isError === true)
|
|
173
191
|
continue;
|
|
174
192
|
if (id)
|
|
175
|
-
|
|
193
|
+
done(id);
|
|
176
194
|
else
|
|
177
195
|
unnamed++;
|
|
178
196
|
}
|
|
179
197
|
}
|
|
180
|
-
return { ran, unnamed, ended };
|
|
198
|
+
return { ran, unnamed, ended, args };
|
|
181
199
|
}
|
|
182
200
|
/** How many calls of `tool` `entries` show run to a good end (toolCalls): a call refused, denied, failed or not ended is
|
|
183
201
|
* not counted. What a tool's own ask counts (tools.ts AskContext.ran), with the calls its gate let through and that
|
|
@@ -3,7 +3,7 @@ import { learnsWorkflows } from "./adapter-run-spec.js";
|
|
|
3
3
|
import { settleAudits } from "./audit.js";
|
|
4
4
|
import { held } from "./held.js";
|
|
5
5
|
import { claimPromotion, promotionGate, replayClaimed, replayLaid, replayRecordedFor, toolFlowsFor } from "./promotion.js";
|
|
6
|
-
import { workflowFirstOf } from "./workflow-first.js";
|
|
6
|
+
import { toolStopsOf, workflowFirstOf } from "./workflow-first.js";
|
|
7
7
|
/** The claim's learned first choice over `laid`, the workflows its seed lay laid (see the file's head). A replay run's
|
|
8
8
|
* claim that is refused throws ClaimRefused, as replayClaimed does. */
|
|
9
9
|
export async function learnedFirst(deps, laid) {
|
|
@@ -14,12 +14,28 @@ export async function learnedFirst(deps, laid) {
|
|
|
14
14
|
if (launch.learning && !launch.replay && !launch.audit)
|
|
15
15
|
await settleAudits({ store, agentId, revisionId, context, log, folder, shown, ...own });
|
|
16
16
|
const promotion = claimPromotion({ store, agentId, runId, revisionId, launch, context, log, folder, shown, ...own });
|
|
17
|
-
const
|
|
17
|
+
const learns = learnsWorkflows(deps.kind, laidFlows);
|
|
18
|
+
// The agent's past runs, read once for both sides of the money rule: the platform's first choice and the agent's tool.
|
|
19
|
+
let read;
|
|
20
|
+
const past = () => (read ??= pastRunsOverStore(store, agentId));
|
|
21
|
+
let choice = learns ? await workflowFirstOf(deps.kind, laidFlows, launch, log, past, promotionGate(promotion), deps.outputSchema) : { reason: "none_laid" };
|
|
18
22
|
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
19
23
|
await replayClaimed(store, agentId, runId, launch, choice);
|
|
20
24
|
const recorded = await replayRecordedFor(store, launch, context);
|
|
21
|
-
// The tool runs what serves, never a revision not promoted (promotion.ts toolFlowsFor)
|
|
22
|
-
|
|
25
|
+
// The tool runs what serves, never a revision not promoted (promotion.ts toolFlowsFor), nor one the money rule stops,
|
|
26
|
+
// whoever made its calls (workflow-first.ts toolStopsOf): a learning run's, not a replay's (it runs its revision, read
|
|
27
|
+
// past or not). A shadow has no learning start (runner/audit.ts): it lays no workflow and reads no past.
|
|
28
|
+
let workflows = await toolFlowsFor(promotion, launch, laidFlows, choice);
|
|
29
|
+
if (learns && launch.learning && !launch.replay && workflows.length) {
|
|
30
|
+
const money = toolStopsOf(await past().catch((error) => ({ unread: error instanceof Error ? error.message : String(error) })), workflows);
|
|
31
|
+
for (const line of money.said)
|
|
32
|
+
log(line);
|
|
33
|
+
workflows = money.flows;
|
|
34
|
+
// A stop asks for its revision on a run nothing else serves or stops first (the run's one WORKFLOW_FIRST entry).
|
|
35
|
+
const stop = money.stops[0];
|
|
36
|
+
if (stop && !choice.serve && !choice.revise)
|
|
37
|
+
choice = { ...choice, reason: "cost_stop", revise: { ...stop, revision: launch.learning.seed, ...(deps.outputSchema !== undefined ? { outputSchema: deps.outputSchema } : {}) } };
|
|
38
|
+
}
|
|
23
39
|
return { choice, workflows, ...(recorded ? { recorded: [...recorded] } : {}) };
|
|
24
40
|
}
|
|
25
41
|
/** learnedFirst where the claim is held: a runner's own (its seal key), else, in a run's own process, its runner's
|