@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.53
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 +160 -1
- package/README.md +306 -36
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +14 -4
- package/dist/agent-delete.js +30 -58
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agents-store.d.ts +28 -18
- package/dist/agents-store.js +48 -34
- package/dist/api-only.d.ts +30 -8
- package/dist/api-only.js +40 -16
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +70 -7
- package/dist/composio-preset.d.ts +2 -1
- package/dist/composio-preset.js +4 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +9 -0
- package/dist/computer-setting.js +19 -1
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-BFgyZzF_.js +734 -0
- package/dist/console/assets/index-DbilxljH.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +3 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.d.ts +76 -0
- package/dist/fal-price.js +365 -0
- package/dist/handed-secret.d.ts +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +19 -1
- package/dist/learn/commit.js +160 -2
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +46 -15
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +16 -0
- package/dist/learn/folder.js +30 -4
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +29 -4
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning-words.d.ts +5 -0
- package/dist/learning-words.js +5 -0
- package/dist/learning.d.ts +15 -10
- package/dist/learning.js +14 -8
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +56 -12
- package/dist/mcp-pin-first.js +1 -1
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +7 -2
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +17 -12
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +211 -47
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +29 -5
- package/dist/run-launch.js +44 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +18 -1
- package/dist/run-view.js +28 -8
- package/dist/runner/adapter-loop.d.ts +14 -4
- package/dist/runner/adapter-loop.js +150 -31
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +35 -22
- package/dist/runner/audit.d.ts +10 -3
- package/dist/runner/audit.js +30 -7
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +31 -4
- package/dist/runner/claim-secrets.js +43 -7
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +32 -20
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +16 -3
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +9 -3
- package/dist/runner/learning-end.js +66 -29
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +7 -2
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +14 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +51 -24
- package/dist/runner/promotion.js +206 -78
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +174 -42
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.js +5 -2
- package/dist/runner/runner.js +41 -12
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +3 -3
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +4 -4
- package/dist/runs-over-store.d.ts +39 -8
- package/dist/runs-over-store.js +147 -32
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +185 -78
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +68 -32
- package/dist/server.js +678 -124
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +8 -0
- package/dist/store/agent-body.js +20 -6
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/schema.d.ts +15 -1
- package/dist/store/schema.js +43 -4
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +14 -0
- package/dist/store/sqlite/run-launch.js +58 -7
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.js +319 -153
- package/dist/store/store-schema.js +2 -2
- package/dist/store/store.d.ts +173 -33
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- package/dist/template-eval.js +4 -4
- package/dist/template-import.d.ts +10 -2
- package/dist/template-import.js +116 -13
- package/dist/templates.d.ts +29 -5
- package/dist/templates.js +68 -14
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/tools.js +1 -1
- package/dist/trigger-launch-hook.d.ts +47 -0
- package/dist/trigger-launch-hook.js +90 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +2 -1
- package/dist/uploads.d.ts +0 -3
- package/dist/uploads.js +2 -11
- package/dist/validate.js +4 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +5 -2
- package/dist/console/assets/index-Bt1B51b7.js +0 -733
- package/dist/console/assets/index-sVftE9Ht.css +0 -1
|
@@ -14,7 +14,7 @@ import { dirname, join } from "node:path";
|
|
|
14
14
|
import { stopRunWith } from "../paid-calls.js";
|
|
15
15
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
16
16
|
import { defineExtension, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
17
|
-
import { checkRaise, followUpOf,
|
|
17
|
+
import { checkRaise, followUpOf, freeRequestLimitOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
|
|
18
18
|
import { inspectWorkflow } from "@parcha/agentrun-dsl";
|
|
19
19
|
import { factsOf } from "../harness-table.js";
|
|
20
20
|
import { decisionProvidersIn } from "../decisions.js";
|
|
@@ -24,7 +24,6 @@ import { llmTiers, nodeTiers, thinkingLevel, TIERS, tierModelOf, workflowNodes }
|
|
|
24
24
|
import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
|
|
25
25
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
26
26
|
import { isWebHostTool } from "../tool-list.js";
|
|
27
|
-
import { ASKED_BECAUSE } from "../refusal-words.js";
|
|
28
27
|
import { deniedText, noApproverText, runGate } from "../tool-gate.js";
|
|
29
28
|
import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
30
29
|
import { readApprovers } from "../server-approvers.js";
|
|
@@ -50,7 +49,7 @@ import { filesToCopy, placeRunInputs } from "../uploads.js";
|
|
|
50
49
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
51
50
|
import { UNREADABLE_SIGN_IN } from "../run-view.js";
|
|
52
51
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
53
|
-
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
52
|
+
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
54
53
|
import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
|
|
55
54
|
import { agreeOnOf } from "../learning-setting.js";
|
|
56
55
|
import { catalogSessionNames, mcpWhereHeld } from "./mcp-run.js";
|
|
@@ -84,6 +83,9 @@ import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
|
84
83
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
85
84
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
86
85
|
import { monidForClaim, withMonid } from "./monid-run.js";
|
|
86
|
+
import { verifyPlacedProject, movedSkillFiles } from "../source-sync/claim.js";
|
|
87
|
+
import { projectCheckpointForRun } from "./project-checkpoint.js";
|
|
88
|
+
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
87
89
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
88
90
|
export const PI_WIRES = Object.freeze(["anthropic-messages", "openai-responses"]);
|
|
89
91
|
/** The browser's catalog name (tools.ts TOOLS.browser). */
|
|
@@ -132,13 +134,14 @@ const isSubagentRoute = (key) => key.startsWith(SUBAGENT_ROUTE);
|
|
|
132
134
|
* holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone. A run with its
|
|
133
135
|
* own model key carries that key, and no saved key is read. Undefined when there is no fast model, the revision names
|
|
134
136
|
* agree_on, or no route can be made (logged: the pair is then compared whole). */
|
|
135
|
-
export async function graderRouteOf(body, keyed, runKey, claimed, cut, log, deps, holds = [cut]) {
|
|
137
|
+
export async function graderRouteOf(body, keyed, runKey, claimed, cut, log, deps, holds = [cut], claim) {
|
|
136
138
|
if (agreeOnOf(body.learning)?.length)
|
|
137
139
|
return undefined;
|
|
138
140
|
const savedKeys = keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env });
|
|
139
141
|
for (const redact of new Set(holds))
|
|
140
142
|
holdClaimed(redact, savedKeys);
|
|
141
|
-
|
|
143
|
+
// The claim's run, turn and attempt on its grader's requests too (request-metadata.ts): they spend on the run's cap.
|
|
144
|
+
const env = claimModelEnv(deps.env, { ...savedKeys, ...claimed }, runKey, claim);
|
|
142
145
|
if (body.modelTiers?.fast === undefined && tierModelOf(env, "fast") === undefined)
|
|
143
146
|
return undefined;
|
|
144
147
|
try {
|
|
@@ -204,7 +207,7 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
|
|
|
204
207
|
const asksOf = decision === "allow" && host && options.ran ? toolOf(call.tool)?.asks : undefined;
|
|
205
208
|
const because = asksOf ? await askedOne(call, asksOf, host, options.ran) : undefined;
|
|
206
209
|
if (because !== undefined)
|
|
207
|
-
return approvers ? { ask: {
|
|
210
|
+
return approvers ? { ask: {}, because } : { deny: noApproverText(gate.askedAs(call.tool, call.args), options.replayed ? "unknown" : "no", because) };
|
|
208
211
|
// A learned workflow's MCP nodes are the run's own MCP calls, held to the same settings: one set to deny refuses the
|
|
209
212
|
// whole call in the gate's words before any node runs, nothing sent; the actions set to ask are put to a person on the
|
|
210
213
|
// call's one card, up front, each with its arguments' shape (learnedAskShown), and the person's allow passes the
|
|
@@ -279,6 +282,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
279
282
|
if (!revisionRow)
|
|
280
283
|
throw new Error(`run ${claim.runId}: its revision ${runRow.revisionId} is gone from the store`);
|
|
281
284
|
const body = (revisionRow.body ?? {});
|
|
285
|
+
const movedProject = await verifyPlacedProject(deps.store, runRow, revisionRow, launch, { data: deps.data, sealKey: deps.sealKey, env: deps.env, ...(run.signal ? { signal: run.signal } : {}), control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
282
286
|
const revision = { kind: revisionRow.kind, body };
|
|
283
287
|
const granted = body.tools ?? [];
|
|
284
288
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
@@ -329,14 +333,17 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
329
333
|
// on the one store the claim does), from the revision row's texts (the body keeps only each file's SHA-256): each
|
|
330
334
|
// folder not there yet, never over an earlier claim's. A desktop or a phone (the revision's computer
|
|
331
335
|
// setting, the one computerForClaim starts) brings its kind's skill, named in the prompt beside the revision's own.
|
|
332
|
-
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
336
|
+
const kindSkills = movedProject ? [] : await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
337
|
+
const currentSkills = movedProject ? await movedSkillFiles(ws.workspace, body.skills ?? {}, settingOfDefinition(body)?.computer.kind) : [...Object.keys(body.skills ?? {}), ...kindSkills];
|
|
333
338
|
// A learning run's seed, read once from its learning folder where the run's place keeps it (runner/learning-seed.ts):
|
|
334
339
|
// its learned workflows, cut of the server's secrets, the ones its learned_workflow tool runs. Read before the run's
|
|
335
|
-
// tools are bound. A learning fault, or a seed that failed (seedFailed), gives none.
|
|
340
|
+
// tools are bound. A learning fault, or a seed that failed (seedFailed), gives none. None a purged run wrote, by the
|
|
341
|
+
// store's runs; a run's own process (no seal key) reads no other run, and its runner reads the seed again
|
|
342
|
+
// (learned-first.ts learnedFirstWhereHeld).
|
|
336
343
|
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
337
344
|
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
338
345
|
const seedLaid = start && !seedFailed(start)
|
|
339
|
-
? await layLearningSeed({ seed: start.seed, folder: learningFolder, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
|
|
346
|
+
? await layLearningSeed({ seed: start.seed, folder: learningFolder, store: deps.sealKey ? deps.store : null, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
|
|
340
347
|
: undefined;
|
|
341
348
|
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
342
349
|
// credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
|
|
@@ -344,7 +351,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
344
351
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
345
352
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
346
353
|
const hold = (values) => cut.hold(values);
|
|
347
|
-
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => 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 } : {}), ...reach });
|
|
354
|
+
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => 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 } : {}), ...reach, capped: launch.maxCostUsd !== undefined, media: { env: deps.env, web: deps.evalFakes?.(runRow.agentId)?.web, slots: deps.saveSlots } });
|
|
348
355
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
349
356
|
holds.hold({ passed: mcp });
|
|
350
357
|
// The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
|
|
@@ -374,7 +381,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
374
381
|
// as `tools.<name>`, each a nested call, gated and recorded as the model's own call is. A computer that replaced an
|
|
375
382
|
// earlier claim's holds its acts to what it showed.
|
|
376
383
|
const tools = await runTools(ws.workspace, computer.computer, { mode, context, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
|
|
377
|
-
|
|
384
|
+
let remoteProjectCapture = false;
|
|
385
|
+
holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
|
|
378
386
|
// The run's model route: its model through routeOf (NEVER re-resolved — the launch's model, pinned at start), the catalog
|
|
379
387
|
// price with tiers for the cap, and the proxy's price (pi-ai calculateCost, tiered).
|
|
380
388
|
// pi speaks both of main's wires: an OpenAI-family model's route is OpenAI's Responses itself.
|
|
@@ -383,7 +391,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
383
391
|
// The run's secrets for this claim, read from the one store (never this process's environment or a pipe): the keys its
|
|
384
392
|
// tools unlock and its model needs, scoped to the run as the old per-run environment was, so one run's keys never reach
|
|
385
393
|
// another's on this runner (claim-secrets.ts). MCP credentials are the other per-claim secret and come through mcp-claim.
|
|
386
|
-
const toolEnv = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, revisionRow, launch);
|
|
394
|
+
const toolEnv = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env, redact: run.redact }, revisionRow, launch, claim.runId);
|
|
387
395
|
// The run's own model key, when its caller handed one (model_key, sealed in its launch): opened at every claim, a reclaim
|
|
388
396
|
// after a crash among them, and held by the run's one redactor. Its model routes read it alone; its tools never do.
|
|
389
397
|
// 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.
|
|
@@ -397,7 +405,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
397
405
|
holdClaimed(cut, toolEnv);
|
|
398
406
|
// The route reads its model's key from the runner's environment, else the one the claim opened from the store: a key
|
|
399
407
|
// saved in Settings → Model keys runs the next run with no restart (withModelKeys). A run with its own key: that key.
|
|
400
|
-
const modelEnv = claimModelEnv(deps.env, toolEnv, runKey);
|
|
408
|
+
const modelEnv = claimModelEnv(deps.env, toolEnv, runKey, claim);
|
|
401
409
|
const route = await deps.routeOf(modelAskOf(launch.model, body.model), modelEnv, "default", PI_WIRES, undefined, cut);
|
|
402
410
|
await planBeforeRun(modelEnv, route.provider.plan ? { provider: PLAN_PROVIDER } : undefined);
|
|
403
411
|
// The run's models of other tiers, for its learned workflows' nodes of a tier (learnedTierRoutes, filled once the seed's
|
|
@@ -429,7 +437,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
429
437
|
// A run with its own model key: its subagents' models carry that key too, and no saved key is read.
|
|
430
438
|
const savedKeys = keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env });
|
|
431
439
|
holdClaimed(cut, savedKeys);
|
|
432
|
-
const tierEnv = claimModelEnv(deps.env, { ...savedKeys, ...toolEnv }, runKey);
|
|
440
|
+
const tierEnv = claimModelEnv(deps.env, { ...savedKeys, ...toolEnv }, runKey, claim);
|
|
433
441
|
for (const tier of SUBAGENT_TIERS) {
|
|
434
442
|
if (body.modelTiers?.[tier] === undefined && tierModelOf(tierEnv, tier) === undefined)
|
|
435
443
|
continue;
|
|
@@ -498,8 +506,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
498
506
|
},
|
|
499
507
|
// What its audit's shadow took beside it, read by every gate with its own sessions (none: it starts none).
|
|
500
508
|
...(besideOf ? { beside: besideOf } : {}),
|
|
501
|
-
// The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
|
|
502
|
-
freeRequests:
|
|
509
|
+
// The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS, or the agent's lower max_requests).
|
|
510
|
+
freeRequests: freeRequestLimitOf(deps.env, body.maxRequests),
|
|
503
511
|
};
|
|
504
512
|
// The run's cap figure and what a refusal does to it (parkOf, with the kernel's raise rule): present only when the run
|
|
505
513
|
// has a cap. A park names the cap the loop holds the run to then (a raise's, else this one).
|
|
@@ -533,10 +541,11 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
533
541
|
// Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit and a replay check
|
|
534
542
|
// are skipped, in words, where the run brought its own key or the server holds none.
|
|
535
543
|
const spendOff = await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey);
|
|
536
|
-
const
|
|
544
|
+
const admitAuxiliary = runnerSeam() ? undefined : sourceAuxiliaryAdmitter(deps.store, { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
545
|
+
const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff, admitAuxiliary };
|
|
537
546
|
// Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
|
|
538
547
|
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself.
|
|
539
|
-
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 ?? []);
|
|
548
|
+
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, admitAuxiliary }, seedLaid?.workflows ?? []);
|
|
540
549
|
const firstChoice = learned.choice;
|
|
541
550
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
542
551
|
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
@@ -554,7 +563,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
554
563
|
// A run with its own model key: its learned nodes' tiers carry that key too, and no saved key is read.
|
|
555
564
|
const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
|
|
556
565
|
holdClaimed(cut, tierKeys);
|
|
557
|
-
const tierEnv = claimModelEnv(deps.env, { ...toolEnv, ...tierKeys }, runKey);
|
|
566
|
+
const tierEnv = claimModelEnv(deps.env, { ...toolEnv, ...tierKeys }, runKey, claim);
|
|
558
567
|
for (const [tier, routed] of await learnedTierRoutes(workflows, tierEnv, (tier) => deps.routeOf(undefined, tierEnv, tier, PI_WIRES, undefined, cut))) {
|
|
559
568
|
if ("why" in routed)
|
|
560
569
|
tierUnreachable.set(tier, routed.why);
|
|
@@ -563,11 +572,11 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
563
572
|
}
|
|
564
573
|
const learnedKeys = await learnedDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, workflows, (provider) => gate.permissions.policy(provider) !== "deny");
|
|
565
574
|
holdClaimed(cut, learnedKeys);
|
|
566
|
-
|
|
575
|
+
underClaimed(toolEnv, learnedKeys);
|
|
567
576
|
}
|
|
568
577
|
// A replay run's or a shadow's grader (runner/compare-end.ts), on a route of its own beside the session's, on the
|
|
569
578
|
// session's booking under the run's one cap. None: the pair is compared whole, in words saying so.
|
|
570
|
-
const graderRoute = launch.replay || launch.audit ? await graderRouteOf(body, keyed, runKey, toolEnv, cut, log, deps) : undefined;
|
|
579
|
+
const graderRoute = launch.replay || launch.audit ? await graderRouteOf(body, keyed, runKey, toolEnv, cut, log, deps, [cut], claim) : undefined;
|
|
571
580
|
if (graderRoute)
|
|
572
581
|
tierRoutes.set(GRADER, graderRoute);
|
|
573
582
|
// The tool host's install lifecycle: what a binding registers to run in each conversation's creating commit, once the
|
|
@@ -610,7 +619,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
610
619
|
// The one path for every harness.
|
|
611
620
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
612
621
|
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
613
|
-
const instructions = await promptOf(laid,
|
|
622
|
+
const instructions = await promptOf(laid, currentSkills, ws.workspace, { onDemand: movedProject || readsFiles(granted) });
|
|
614
623
|
const guidance = effortGuidance(launch.effort);
|
|
615
624
|
// The run's clock: a template eval case's (EvalFakes.now), else the real one.
|
|
616
625
|
const now = fakes?.now;
|
|
@@ -766,6 +775,10 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
766
775
|
// credential with it, and the run's timeline is told so.
|
|
767
776
|
...(computer.keeps ? { keptWords: computerKeptWords(computer.keeps) } : {}),
|
|
768
777
|
release: (how) => holds.release(how),
|
|
778
|
+
...(movedProject ? { projectCheckpoint: projectCheckpointForRun({ store: deps.store, agentId: runRow.agentId, claim, launch, tools, computer,
|
|
779
|
+
workspace: { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } },
|
|
780
|
+
secrets: async () => runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)),
|
|
781
|
+
}, () => { remoteProjectCapture = true; }) } : {}),
|
|
769
782
|
endCheckout: () => holds.endCheckout(),
|
|
770
783
|
};
|
|
771
784
|
}
|
package/dist/runner/audit.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { AuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
2
3
|
import { type AuditLoop } from "../learning-setting.js";
|
|
3
4
|
import { type RunLaunch } from "../run-launch.js";
|
|
4
5
|
import { type RunRow, type Store } from "../store/store.js";
|
|
@@ -19,6 +20,7 @@ export type AuditDeps = {
|
|
|
19
20
|
readonly shown: () => Promise<Pick<Shown, "text">>;
|
|
20
21
|
readonly log: (line: string) => void;
|
|
21
22
|
readonly sealKey?: Buffer;
|
|
23
|
+
readonly admitAuxiliary?: AuxiliaryAdmitter;
|
|
22
24
|
readonly now?: () => number;
|
|
23
25
|
/** Why model spend beside the claimed run is skipped (claim-secrets.ts claimSpendOff): a shadow is a run the runner
|
|
24
26
|
* starts with no caller's key. Absent: it runs. */
|
|
@@ -37,7 +39,7 @@ export declare function agreeOnOfRevision(store: Pick<Store, "agents">, revision
|
|
|
37
39
|
export declare function auditedAnswerOf(deps: Pick<AuditDeps, "store" | "context" | "folder">, shadowRun: string): Promise<string | null>;
|
|
38
40
|
/** How many of the newest stop_window runs `workflow` at `digest` served were not auditable (auditableLaunch: a trigger
|
|
39
41
|
* started them): what the promotions read counts beside the audit line. */
|
|
40
|
-
export declare function notAuditableOf(store: Pick<Store, "runs">, agentId: string, workflow: string, digest: string, loop: Pick<AuditLoop, "stop_window">): Promise<number>;
|
|
42
|
+
export declare function notAuditableOf(store: Pick<Store, "runs" | "settings">, agentId: string, workflow: string, digest: string, loop: Pick<AuditLoop, "stop_window">): Promise<number>;
|
|
41
43
|
/** The words a shadow run ends failed with where it would wait on a person (AdapterRunSpec.neverWaits: an approval, a
|
|
42
44
|
* raise of its cap, which is what its served run's cap left, a question), what it would wait on after them: its row is
|
|
43
45
|
* `parked`, with no verdict. */
|
|
@@ -58,7 +60,9 @@ export declare function withAudit(step: EndOfRunTurn | undefined, deps: AuditDep
|
|
|
58
60
|
* spend past the served run's cap; with less than a run's smallest cap left (or a spend not known), no shadow is started
|
|
59
61
|
* and its row says `skipped: "no allowance"`. Its started line is appended first: a shadow is created only once the
|
|
60
62
|
* ledger names it (settlement finds it there, never in a window of runs), and one whose line could not be written is
|
|
61
|
-
* never created. Idempotent: one line and one shadow per run.
|
|
63
|
+
* never created. Idempotent: one line and one shadow per run. A run the agent's learning reads no more starts none, as
|
|
64
|
+
* it adds no grade row (gradeRow): one before its learning's reset (sinceReset), ended again after it by a follow-up,
|
|
65
|
+
* or one on a named disk (learn/learning-of.ts). */
|
|
62
66
|
export declare function startAudit(deps: AuditDeps & {
|
|
63
67
|
readonly runId: string;
|
|
64
68
|
readonly launch: RunLaunch;
|
|
@@ -71,5 +75,8 @@ export declare function startAudit(deps: AuditDeps & {
|
|
|
71
75
|
export declare function settleAudits(deps: AuditDeps): Promise<void>;
|
|
72
76
|
/** The row an owner's grade of served run `run` writes (source grade, agreed = the grade, counted for the digest's
|
|
73
77
|
* promotion now), then the hold rule: only for a run the workflow answered alone (its answer is the workflow's).
|
|
74
|
-
* Nothing else: no round, no compile by itself.
|
|
78
|
+
* Nothing else: no round, no compile by itself. A run before the agent's learning reset (sinceReset) adds no row: its
|
|
79
|
+
* grade is kept, but a promotion of the same digest after the reset is never held by what came before it. A run on a
|
|
80
|
+
* named disk adds none either (learn/learning-of.ts): the hold rule would copy its answers into the promotion's
|
|
81
|
+
* disagreements, and the agent's compile reads those. */
|
|
75
82
|
export declare function gradeRow(deps: AuditDeps, run: RunRow, correct: boolean): Promise<void>;
|
package/dist/runner/audit.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
// Every number is the agent definition's (learning-setting.ts auditLoopOf). Nothing here fails a claim: a failure is logged.
|
|
27
27
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
28
28
|
import { overCapMessage } from "@parcha/agentrun-kernel/kernel/cap";
|
|
29
|
+
import { sourceSyncOf } from "../source-sync/types.js";
|
|
29
30
|
import { agreeOnOf, auditLoopOf } from "../learning-setting.js";
|
|
30
31
|
import { launchBody, readLaunchBody } from "../run-launch.js";
|
|
31
32
|
import { runEntries } from "../store-reads/journal.js";
|
|
@@ -34,7 +35,7 @@ import { FINAL_STATES, StoreConstraint } from "../store/store.js";
|
|
|
34
35
|
import { openRunMcpAuth, sealRunMcpAuth } from "../store/seal.js";
|
|
35
36
|
import { isObject } from "../validate.js";
|
|
36
37
|
import { auditableLaunch, auditChange, auditEveryOf, auditDrawn, auditsOffWords, auditWriterOf, holdOf, ledgerOf, lineKey, openAudits, rowsOf, shadowRunId } from "../learn/audit.js";
|
|
37
|
-
import { lastRunsOf } from "../learn/compile.js";
|
|
38
|
+
import { lastRunsOf, sinceReset } from "../learn/compile.js";
|
|
38
39
|
import { readLearning, writeLearning } from "../learn/folder.js";
|
|
39
40
|
import { CHECK_TEXT_MAX, compareAnswers, comparedOf, promotionOf, promotionsOf, promotionStartOf, recordPromotion, servingOf } from "../learn/promote.js";
|
|
40
41
|
import { excerptShown } from "../learn/secrets.js";
|
|
@@ -79,9 +80,13 @@ export async function auditedAnswerOf(deps, shadowRun) {
|
|
|
79
80
|
const open = openAudits(await readLedger(deps)).find((line) => line.shadow_run === shadowRun);
|
|
80
81
|
return open ? auditedAnswer(deps, open) : null;
|
|
81
82
|
}
|
|
82
|
-
/** The served runs of `workflow` (at `digest` when given) that `keep` keeps too, the
|
|
83
|
-
* shadows and the agent's own runs among them never push one out
|
|
84
|
-
|
|
83
|
+
/** The served runs of `workflow` (at `digest` when given) that `keep` keeps too, since the agent's learning's reset
|
|
84
|
+
* (sinceReset), the newest `n` of them (lastRunsOf: the shadows and the agent's own runs among them never push one out
|
|
85
|
+
* of the read). */
|
|
86
|
+
const servedRuns = async (store, agentId, n, workflow, digest, keep = () => true) => {
|
|
87
|
+
const since = await sinceReset(store, agentId);
|
|
88
|
+
return lastRunsOf(store, agentId, n, (row) => served(row) && metricsOf(row).workflow === workflow && (digest === undefined || metricsOf(row).workflow_digest === digest) && keep(row) && since(row));
|
|
89
|
+
};
|
|
85
90
|
/** How many of the newest stop_window runs `workflow` at `digest` served were not auditable (auditableLaunch: a trigger
|
|
86
91
|
* started them): what the promotions read counts beside the audit line. */
|
|
87
92
|
export async function notAuditableOf(store, agentId, workflow, digest, loop) {
|
|
@@ -134,7 +139,9 @@ async function auditAtEnd(deps, runId) {
|
|
|
134
139
|
* spend past the served run's cap; with less than a run's smallest cap left (or a spend not known), no shadow is started
|
|
135
140
|
* and its row says `skipped: "no allowance"`. Its started line is appended first: a shadow is created only once the
|
|
136
141
|
* ledger names it (settlement finds it there, never in a window of runs), and one whose line could not be written is
|
|
137
|
-
* never created. Idempotent: one line and one shadow per run.
|
|
142
|
+
* never created. Idempotent: one line and one shadow per run. A run the agent's learning reads no more starts none, as
|
|
143
|
+
* it adds no grade row (gradeRow): one before its learning's reset (sinceReset), ended again after it by a follow-up,
|
|
144
|
+
* or one on a named disk (learn/learning-of.ts). */
|
|
138
145
|
export async function startAudit(deps, serve) {
|
|
139
146
|
const { store, agentId, runId, launch, log } = deps;
|
|
140
147
|
if (!serve || serve.replay || launch.replay || launch.audit || !launch.learning || !auditableLaunch(launch))
|
|
@@ -145,9 +152,17 @@ export async function startAudit(deps, serve) {
|
|
|
145
152
|
if (off)
|
|
146
153
|
return void log(`workflow-first: ${off}`);
|
|
147
154
|
try {
|
|
155
|
+
// The run is there at its end (its end commits after this step).
|
|
156
|
+
const row = await store.runs.get(runId);
|
|
157
|
+
if (row && ((row.disk ?? null) !== null || !(await sinceReset(store, agentId))(row)))
|
|
158
|
+
return;
|
|
148
159
|
// Read after the claim pinned the revision's MCP tools (mcp-claim.ts pinFirst): the pin a revision saved without one
|
|
149
160
|
// takes at its first run is what its tools are classed by.
|
|
150
161
|
const revision = await store.agents.revision(deps.revisionId);
|
|
162
|
+
if ((launch.sourceProject || sourceSyncOf(revision?.body)) && !deps.admitAuxiliary) {
|
|
163
|
+
log("workflow-first: an auxiliary audit requires its own project placement for this moved agent; no audit was started. Start a normal run to use the saved project.");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
151
166
|
const writer = auditWriterOf(revision);
|
|
152
167
|
if (writer !== undefined) {
|
|
153
168
|
log(`workflow-first: ${serve.name} at ${serve.digest} serves this run, never audited: ${auditsOffWords(writer)}`);
|
|
@@ -199,7 +214,10 @@ export async function startAudit(deps, serve) {
|
|
|
199
214
|
await addLines(deps, [started]);
|
|
200
215
|
const sealed = await handedTo(deps, runId, id);
|
|
201
216
|
try {
|
|
202
|
-
|
|
217
|
+
if (sourceSyncOf(revision?.body))
|
|
218
|
+
await deps.admitAuxiliary({ runId: id, agentId, revisionId: deps.revisionId, launch: shadow, ...(sealed ? { sealed } : {}) });
|
|
219
|
+
else
|
|
220
|
+
await store.runs.create({ id, agentId, revisionId: deps.revisionId }, { body: launchBody(shadow), ...(sealed ? { sealed } : {}) });
|
|
203
221
|
}
|
|
204
222
|
catch (error) {
|
|
205
223
|
if (error instanceof StoreConstraint && (await store.runs.get(id)))
|
|
@@ -268,11 +286,16 @@ export async function settleAudits(deps) {
|
|
|
268
286
|
}
|
|
269
287
|
/** The row an owner's grade of served run `run` writes (source grade, agreed = the grade, counted for the digest's
|
|
270
288
|
* promotion now), then the hold rule: only for a run the workflow answered alone (its answer is the workflow's).
|
|
271
|
-
* Nothing else: no round, no compile by itself.
|
|
289
|
+
* Nothing else: no round, no compile by itself. A run before the agent's learning reset (sinceReset) adds no row: its
|
|
290
|
+
* grade is kept, but a promotion of the same digest after the reset is never held by what came before it. A run on a
|
|
291
|
+
* named disk adds none either (learn/learning-of.ts): the hold rule would copy its answers into the promotion's
|
|
292
|
+
* disagreements, and the agent's compile reads those. */
|
|
272
293
|
export async function gradeRow(deps, run, correct) {
|
|
273
294
|
const m = metricsOf(run);
|
|
274
295
|
if (m.path !== "workflow" || typeof m.workflow !== "string" || typeof m.workflow_digest !== "string")
|
|
275
296
|
return;
|
|
297
|
+
if ((run.disk ?? null) !== null || !(await sinceReset(deps.store, deps.agentId))(run))
|
|
298
|
+
return;
|
|
276
299
|
const promoted = promotionStartOf(await promotionsOf(deps.store.settings, deps.agentId), m.workflow, m.workflow_digest);
|
|
277
300
|
// The answer graded: the run's newest now, kept by its row's id (as a shadow's audit keeps its turn).
|
|
278
301
|
const turn = turnOf((await answerRowOf(deps.store, run.id, deps.context))?.id);
|
package/dist/runner/beside.js
CHANGED
|
@@ -118,7 +118,8 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
|
|
|
118
118
|
};
|
|
119
119
|
// A run's end lets go of what its earlier claims' computers left, with the same computers (run-end-computers.ts).
|
|
120
120
|
const { runEndComputers } = await import("../workspace/run-end-computers.js");
|
|
121
|
-
const
|
|
121
|
+
const { projectRunEnded } = await import("../source-sync/checkpoints.js");
|
|
122
|
+
const runEnded = projectRunEnded(store, runEndComputers({ store, computers: computers.computerDeps, log: (line) => console.error(`agentrun-serve runner: ${line}`) }));
|
|
122
123
|
const runner = startRunner({ store, name, createLoop, memory: runnerMemory(store, undefined, runs, isolation ? RUN_PROCESS_MIB : 0), onEvent: said, runEnded, ...(held !== undefined ? { loops: held } : {}), ...(drainMs !== undefined ? { drainMs } : {}) });
|
|
123
124
|
// The computer janitor over the same computers, when the start asks for it: never under --faux. Its lines are the
|
|
124
125
|
// runner's, on stderr (a stderr whose reader closed loses them, never the process: cli.ts).
|
|
@@ -5,23 +5,43 @@ import type { SealedKeys } from "../store/store.js";
|
|
|
5
5
|
import type { Revision } from "../agent-rows.js";
|
|
6
6
|
import type { HeldRedact } from "./redact.js";
|
|
7
7
|
import { type HeldModelKey } from "../run-model-key.js";
|
|
8
|
-
import { type RunModelKey } from "../store/seal.js";
|
|
8
|
+
import { type RunModelKey, type RunToolKeys } from "../store/seal.js";
|
|
9
|
+
import { type Claim } from "../store/store.js";
|
|
9
10
|
/** What claimSecrets reads the keys from: the one store (its sealed keys) and the runner's seal key, and the runner's base
|
|
10
11
|
* environment (its own, with no server secret in it: those are the store's). */
|
|
11
12
|
export interface ClaimSecretsDeps {
|
|
12
13
|
/** `put`, `replaceIf`, `removeIf` and `clock` for the ChatGPT sign-in alone, which a run renews and seals again under a
|
|
13
|
-
* lease on the store's clock (chatgpt-plan.ts).
|
|
14
|
+
* lease on the store's clock (chatgpt-plan.ts). `runs.launch` for a claim given its run's id: its launch's sealed
|
|
15
|
+
* column, which holds the run's own tool keys. */
|
|
14
16
|
readonly store: {
|
|
15
17
|
readonly sealedKeys: Pick<SealedKeys, "get" | "put" | "replaceIf" | "removeIf" | "clock">;
|
|
18
|
+
readonly runs?: RunLaunchReader;
|
|
16
19
|
};
|
|
17
20
|
/** The runner's seal key: with none, no saved key is opened, and only the environment's values are read. */
|
|
18
21
|
readonly sealKey: Buffer | undefined;
|
|
19
22
|
readonly env?: NodeJS.ProcessEnv;
|
|
23
|
+
/** The runner's one redactor (redact.ts), for a claim given its run's id: the run's own tool keys it lays are carried
|
|
24
|
+
* there first, cut from the run's journal as it is written, since no one holds them after the turn. A claim with run
|
|
25
|
+
* keys to lay and no redactor lays none, and throws. */
|
|
26
|
+
readonly redact?: HeldRedact;
|
|
20
27
|
}
|
|
28
|
+
/** What reads a run's launch sealed column. */
|
|
29
|
+
type RunLaunchReader = {
|
|
30
|
+
launch(runId: string): Promise<{
|
|
31
|
+
readonly sealed: Uint8Array | null;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
21
34
|
/** The environment a claimed run's tools run under: the runner's base (its secrets stripped), with the keys the run's
|
|
22
35
|
* revision needs read from the store on top — the tool keys its tools unlock, the model keys its model needs, and its
|
|
23
|
-
* decision provider keys
|
|
36
|
+
* decision provider keys — and, for claim `runId`, the run's own tool keys its revision declares (run-keys.ts) over the
|
|
37
|
+
* server's by the same name. A fresh object per claim, so no run's keys reach another's. */
|
|
38
|
+
export declare function claimSecrets(deps: ClaimSecretsDeps & {
|
|
39
|
+
readonly redact: HeldRedact | undefined;
|
|
40
|
+
}, revision: Revision, launch: Pick<RunLaunch, "plane" | "model">, runId: string): Promise<NodeJS.ProcessEnv>;
|
|
24
41
|
export declare function claimSecrets(deps: ClaimSecretsDeps, revision: Revision, launch: Pick<RunLaunch, "plane" | "model">): Promise<NodeJS.ProcessEnv>;
|
|
42
|
+
/** `keys` (learnedDecisionKeys') laid onto `env`, a claim's environment, where it holds no value of that name: what the
|
|
43
|
+
* claim laid stays, a run's own tool key over the server's above all. A name both read holds the same server key. */
|
|
44
|
+
export declare function underClaimed(env: NodeJS.ProcessEnv, keys: Readonly<Record<string, string>>): void;
|
|
25
45
|
/** The decision keys a run's learned workflows need, beside those claimSecrets scoped to its revision (whose own nodes
|
|
26
46
|
* are all needsOf reads, so an agentic run gets none there): the keys of the providers the chosen workflows' typed
|
|
27
47
|
* questions name (decisions.ts providersNamed, Jev for a node that names none), but any provider `allowed` refuses (the
|
|
@@ -73,6 +93,12 @@ export declare function openRunModelKey(deps: {
|
|
|
73
93
|
};
|
|
74
94
|
readonly sealKey: Buffer | undefined;
|
|
75
95
|
}, runId: string): Promise<RunModelKey | undefined>;
|
|
96
|
+
/** Run `runId`'s own tool keys as its launch's sealed column holds them (run-keys.ts), opened under `deps.sealKey`: none
|
|
97
|
+
* for a launch that holds none (or no launch row). Throws, in words, where the launch does not open. */
|
|
98
|
+
export declare function openRunKeys(deps: {
|
|
99
|
+
readonly runs: RunLaunchReader;
|
|
100
|
+
readonly sealKey: Buffer;
|
|
101
|
+
}, runId: string): Promise<RunToolKeys | undefined>;
|
|
76
102
|
/**
|
|
77
103
|
* The run's own model key for claim `runId`, opened from its launch's sealed column under the runner's seal key (the
|
|
78
104
|
* server sealed it there with mcp_auth, store/seal.ts). Undefined only where the server has no gateway and the run holds
|
|
@@ -109,8 +135,9 @@ export declare function claimSpendOff(deps: ClaimSecretsDeps, runKey: ClaimModel
|
|
|
109
135
|
/** The env a claimed run's model routes read: the run's own key alone where the claim opened one (withRunModelKey); else
|
|
110
136
|
* the runner's environment with the keys `opened` for it (withModelKeys), whose gateway variables read the run's key
|
|
111
137
|
* once a message hands it one (withRunModelKeyLater). */
|
|
112
|
-
export declare function claimModelEnv(env: NodeJS.ProcessEnv, opened: NodeJS.ProcessEnv, runKey: ClaimModelKey | undefined): NodeJS.ProcessEnv;
|
|
138
|
+
export declare function claimModelEnv(env: NodeJS.ProcessEnv, opened: NodeJS.ProcessEnv, runKey: ClaimModelKey | undefined, claim?: Pick<Claim, "runId" | "turn" | "attempt">): NodeJS.ProcessEnv;
|
|
113
139
|
/** `toolEnv` with no model key in it, for a run that holds its own: a tool's environment never carries a model key the
|
|
114
140
|
* run's model routes do not send. The decision providers' keys stay (DECISION_KEY_NAMES): a keyed workflow's judge,
|
|
115
141
|
* pick, sift, route and ask nodes run on them as any run's do. */
|
|
116
142
|
export declare function withoutModelKeys(toolEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
143
|
+
export {};
|
|
@@ -17,14 +17,13 @@ import { held, held as runnerSeam } from "./held.js";
|
|
|
17
17
|
import { savedGatewayIn } from "../model-gateway.js";
|
|
18
18
|
import { noServerKeyWords, runKeyEndedFor, runModelOrigin, withRunModelKey, withRunModelKeyLater } from "../run-model-key.js";
|
|
19
19
|
import { openRunLaunch } from "../store/seal.js";
|
|
20
|
+
import { declaredFrom } from "../run-keys.js";
|
|
20
21
|
import { StoreLaunchMissing } from "../store/store.js";
|
|
22
|
+
import { withRequestMetadata } from "../request-metadata.js";
|
|
21
23
|
/** Every server secret a run might be handed (runs.ts RUN_SECRETS is the tool and model keys; the decision keys go beside
|
|
22
24
|
* them). Read from the store into a working environment, then scoped to the run below. */
|
|
23
25
|
const CANDIDATES = [...new Set([...RUN_SECRETS, ...DECISION_KEYS])];
|
|
24
|
-
|
|
25
|
-
* revision needs read from the store on top — the tool keys its tools unlock, the model keys its model needs, and its
|
|
26
|
-
* decision provider keys. A fresh object per claim, so no run's keys reach another's. */
|
|
27
|
-
export async function claimSecrets(deps, revision, launch) {
|
|
26
|
+
export async function claimSecrets(deps, revision, launch, runId) {
|
|
28
27
|
const base = withoutSecrets(deps.env ?? {});
|
|
29
28
|
const working = await workingEnv(deps);
|
|
30
29
|
const needs = await needsOf(revision);
|
|
@@ -42,6 +41,20 @@ export async function claimSecrets(deps, revision, launch) {
|
|
|
42
41
|
const decision = decisionKeysFor(working, { providers: needs.decisionProviders, parallelWeb: launch.plane ? handsParallel(launch.plane) : false });
|
|
43
42
|
for (const [name, value] of Object.entries(decision))
|
|
44
43
|
env[name] = value;
|
|
44
|
+
// The run's own tool keys, sealed with its launch: each one its revision declares, over the server's by the same name.
|
|
45
|
+
// Opened by a runner, which holds the seal key; a run's own process is handed them with the rest of its claim's keys.
|
|
46
|
+
if (runId !== undefined && deps.sealKey && deps.store.runs) {
|
|
47
|
+
const carried = await openRunKeys({ runs: deps.store.runs, sealKey: deps.sealKey }, runId);
|
|
48
|
+
const declared = carried ? declaredFrom(needs, revision) : [];
|
|
49
|
+
const laid = Object.entries(carried ?? {}).filter(([name]) => declared.includes(name));
|
|
50
|
+
if (laid.length) {
|
|
51
|
+
if (!deps.redact)
|
|
52
|
+
throw new Error(`Run ${runId} carries its own tool keys (${laid.map(([name]) => name).join(", ")}), and this claim has no redactor to cut them from what the run writes: none is laid.`);
|
|
53
|
+
deps.redact.carry(runId, laid.map(([, value]) => value));
|
|
54
|
+
}
|
|
55
|
+
for (const [name, value] of laid)
|
|
56
|
+
env[name] = value;
|
|
57
|
+
}
|
|
45
58
|
// The server's ChatGPT sign-in, read from the store for this claim: its token is asked at each request the run's model
|
|
46
59
|
// proxy sends (chatgpt-plan.ts), never put on the environment its tools run under (a symbol no spawn copies). Only for
|
|
47
60
|
// a run that can reach a plan model: one pinned to a key's model (and its tiers on keys) never holds the sign-in, which
|
|
@@ -76,6 +89,13 @@ async function workingEnv(deps) {
|
|
|
76
89
|
}
|
|
77
90
|
return working;
|
|
78
91
|
}
|
|
92
|
+
/** `keys` (learnedDecisionKeys') laid onto `env`, a claim's environment, where it holds no value of that name: what the
|
|
93
|
+
* claim laid stays, a run's own tool key over the server's above all. A name both read holds the same server key. */
|
|
94
|
+
export function underClaimed(env, keys) {
|
|
95
|
+
for (const [name, value] of Object.entries(keys))
|
|
96
|
+
if (!env[name])
|
|
97
|
+
env[name] = value;
|
|
98
|
+
}
|
|
79
99
|
/** The decision keys a run's learned workflows need, beside those claimSecrets scoped to its revision (whose own nodes
|
|
80
100
|
* are all needsOf reads, so an agentic run gets none there): the keys of the providers the chosen workflows' typed
|
|
81
101
|
* questions name (decisions.ts providersNamed, Jev for a node that names none), but any provider `allowed` refuses (the
|
|
@@ -203,6 +223,21 @@ export async function openRunModelKey(deps, runId) {
|
|
|
203
223
|
throw new Error("This run's launch secrets do not open with this runner's seal key: its model key is not sent.");
|
|
204
224
|
return opened.model;
|
|
205
225
|
}
|
|
226
|
+
/** Run `runId`'s own tool keys as its launch's sealed column holds them (run-keys.ts), opened under `deps.sealKey`: none
|
|
227
|
+
* for a launch that holds none (or no launch row). Throws, in words, where the launch does not open. */
|
|
228
|
+
export async function openRunKeys(deps, runId) {
|
|
229
|
+
const sealed = await deps.runs.launch(runId).then((launch) => launch.sealed, (error) => {
|
|
230
|
+
if (error instanceof StoreLaunchMissing)
|
|
231
|
+
return null;
|
|
232
|
+
throw error;
|
|
233
|
+
});
|
|
234
|
+
if (sealed === null)
|
|
235
|
+
return undefined;
|
|
236
|
+
const opened = openRunLaunch(deps.sealKey, runId, sealed);
|
|
237
|
+
if (!opened)
|
|
238
|
+
throw new Error("This run's launch secrets do not open with this runner's seal key: its keys are not sent.");
|
|
239
|
+
return opened.keys;
|
|
240
|
+
}
|
|
206
241
|
/**
|
|
207
242
|
* The run's own model key for claim `runId`, opened from its launch's sealed column under the runner's seal key (the
|
|
208
243
|
* server sealed it there with mcp_auth, store/seal.ts). Undefined only where the server has no gateway and the run holds
|
|
@@ -285,10 +320,11 @@ export async function claimSpendOff(deps, runKey) {
|
|
|
285
320
|
/** The env a claimed run's model routes read: the run's own key alone where the claim opened one (withRunModelKey); else
|
|
286
321
|
* the runner's environment with the keys `opened` for it (withModelKeys), whose gateway variables read the run's key
|
|
287
322
|
* once a message hands it one (withRunModelKeyLater). */
|
|
288
|
-
export function claimModelEnv(env, opened, runKey) {
|
|
323
|
+
export function claimModelEnv(env, opened, runKey, claim) {
|
|
324
|
+
// The claim's run, turn and attempt, which each request on serve's gateway names (request-metadata.ts).
|
|
289
325
|
if (!runKey)
|
|
290
|
-
return withModelKeys(env, opened);
|
|
291
|
-
return keyedAtClaim(runKey) ? withRunModelKey(env, runKey) : withRunModelKeyLater(withModelKeys(env, opened), runKey);
|
|
326
|
+
return withRequestMetadata(withModelKeys(env, opened), claim);
|
|
327
|
+
return withRequestMetadata(keyedAtClaim(runKey) ? withRunModelKey(env, runKey) : withRunModelKeyLater(withModelKeys(env, opened), runKey), claim);
|
|
292
328
|
}
|
|
293
329
|
/** The decision providers' own keys (decisions.ts: Jev's TypeSafe key, OpenRouter's, Parallel's): some are also pi-ai
|
|
294
330
|
* provider names, but a run's model key never replaces them, so withoutModelKeys keeps them. */
|
|
@@ -51,7 +51,7 @@ export declare function cliCapModel(entry: HarnessEntry & {
|
|
|
51
51
|
* run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
|
|
52
52
|
* own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
|
|
53
53
|
* (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
|
|
54
|
-
export declare function cliRunEnv(env: NodeJS.ProcessEnv | undefined, data: string, claimed?: NodeJS.ProcessEnv, plane?: RunLaunch["plane"], runKey?: ClaimModelKey): NodeJS.ProcessEnv;
|
|
54
|
+
export declare function cliRunEnv(env: NodeJS.ProcessEnv | undefined, data: string, claimed?: NodeJS.ProcessEnv, plane?: RunLaunch["plane"], runKey?: ClaimModelKey, claim?: Pick<Claim, "runId" | "turn" | "attempt">): NodeJS.ProcessEnv;
|
|
55
55
|
/** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
|
|
56
56
|
* name), as main listed a CLI run's tools to its harness: each granted tool where its grant is, and a tool the grant
|
|
57
57
|
* does not name (one a granted tool or the run's computer brings beside it) right after the tool listed before it. Ties
|