@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.57
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 +229 -0
- package/README.md +201 -52
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +15 -3
- package/dist/adapters.js +17 -6
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +17 -5
- package/dist/api-only.js +34 -8
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/chatgpt-plan.d.ts +18 -8
- package/dist/chatgpt-plan.js +91 -34
- package/dist/claude-login.d.ts +74 -16
- package/dist/claude-login.js +215 -56
- package/dist/claude-sign-in.d.ts +17 -6
- package/dist/claude-sign-in.js +42 -39
- package/dist/cli.js +63 -6
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/console/assets/{backend-Boh7tC4i.js → backend-DVhHzJX2.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-okP-y8PK.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +10 -0
- package/dist/env-switch.js +33 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +58 -20
- package/dist/fal-price.js +341 -82
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +9 -4
- package/dist/key-refusal.js +107 -25
- package/dist/learn/secrets.d.ts +13 -3
- package/dist/learn/secrets.js +118 -17
- package/dist/learning-cost.d.ts +6 -3
- package/dist/learning-cost.js +4 -2
- package/dist/link-check.js +1 -1
- package/dist/llms.txt +1 -1
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +30 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +5 -2
- package/dist/model.js +9 -5
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.js +178 -27
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/provider.d.ts +9 -0
- package/dist/provider.js +50 -3
- package/dist/redact/match.d.ts +30 -3
- package/dist/redact/match.js +422 -41
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +2 -0
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +2 -0
- package/dist/run-timeline-served.js +2 -2
- package/dist/run-usage.d.ts +1 -0
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +11 -0
- package/dist/runner/adapter-loop.js +55 -10
- package/dist/runner/adapter-run-spec.d.ts +45 -8
- package/dist/runner/adapter-run-spec.js +150 -28
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.js +4 -3
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +18 -3
- package/dist/runner/claim-secrets.js +35 -6
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +82 -35
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +11 -5
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/main.js +7 -2
- package/dist/runner/mcp-claim.js +30 -3
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +12 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/run-child-host.d.ts +3 -0
- package/dist/runner/run-child-host.js +69 -28
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +14 -3
- package/dist/runner/runner.js +129 -33
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.js +4 -40
- package/dist/runner/workflow-first.d.ts +11 -4
- package/dist/runner/workflow-first.js +14 -8
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +52 -11
- package/dist/server.js +345 -118
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/schema.d.ts +6 -0
- package/dist/store/schema.js +11 -1
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +1 -1
- package/dist/store/sqlite/run-patch.js +13 -4
- package/dist/store/sqlite/store.js +34 -4
- package/dist/store/store.d.ts +43 -2
- package/dist/store/store.js +20 -0
- package/dist/store-reads/learning.d.ts +6 -3
- package/dist/store-reads/learning.js +22 -7
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +3 -3
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +20 -9
- package/dist/template-eval.js +115 -33
- package/dist/template-import.d.ts +10 -0
- package/dist/template-import.js +16 -7
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +14 -8
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +26 -9
- package/dist/timeline/web-calls.js +124 -37
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +66 -5
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +6 -4
- package/dist/web-save.js +9 -12
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/computer-deps.d.ts +2 -1
- package/dist/workspace/computer-deps.js +9 -2
- package/dist/workspace/computer-for-claim.d.ts +12 -1
- package/dist/workspace/computer-for-claim.js +77 -8
- package/dist/workspace/computer-kept.d.ts +3 -0
- package/dist/workspace/computer-kept.js +11 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +13 -5
- package/dist/wrapped.js +52 -26
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +30 -8
- package/dist/console/assets/index-CQ3cJRzI.js +0 -746
- package/dist/console/assets/index-DKkaS3a0.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
|
@@ -21,6 +21,7 @@ import { decisionProvidersIn } from "../decisions.js";
|
|
|
21
21
|
import { dropLiveViewer, putLiveViewer } from "../browser-live.js";
|
|
22
22
|
import { liveForRun, runnerLiveOf } from "../live-reach.js";
|
|
23
23
|
import { llmTiers, nodeTiers, thinkingLevel, TIERS, tierModelOf, workflowNodes } from "../model.js";
|
|
24
|
+
import { heldRefusedProvider } from "../provider.js";
|
|
24
25
|
import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
|
|
25
26
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
26
27
|
import { isWebHostTool } from "../tool-list.js";
|
|
@@ -31,6 +32,7 @@ import { ASK_TOOL, askPerson, toolOf } from "../tools.js";
|
|
|
31
32
|
import { hostToolOf } from "../host-tools.js";
|
|
32
33
|
import { WEB_SEARCH_TOOL } from "../web-search.js";
|
|
33
34
|
import { webCut } from "../timeline/web-calls.js";
|
|
35
|
+
import { withheldWhole } from "../key-refusal.js";
|
|
34
36
|
import { environmentLine, runZone } from "../environment.js";
|
|
35
37
|
import { effortGuidance } from "../effort-guidance.js";
|
|
36
38
|
import { outputContract } from "../answer-json.js";
|
|
@@ -42,6 +44,7 @@ import { learnedAskShown, LEARNED_WORKFLOW_TOOL, learnedMcpCalls, learnedWorkflo
|
|
|
42
44
|
import { PORT_PROVIDER, tieredModels, tierProvider } from "../port-models.js";
|
|
43
45
|
import { promptOf, readsFiles } from "../skills.js";
|
|
44
46
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
47
|
+
import { withoutKindSkill } from "../workspace/kind-skills.js";
|
|
45
48
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
46
49
|
import { COMPUTER_ROOT, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
47
50
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
@@ -49,10 +52,10 @@ import { filesToCopy, placeRunInputs } from "../uploads.js";
|
|
|
49
52
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
50
53
|
import { UNREADABLE_SIGN_IN } from "../run-view.js";
|
|
51
54
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
52
|
-
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
55
|
+
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, keysOver, learnedDecisionKeys, savedModelKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
53
56
|
import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
|
|
54
57
|
import { agreeOnOf } from "../learning-setting.js";
|
|
55
|
-
import { catalogSessionNames, mcpWhereHeld } from "./mcp-run.js";
|
|
58
|
+
import { catalogSessionNames, claimMetering, mcpWhereHeld } from "./mcp-run.js";
|
|
56
59
|
import { held as runnerSeam, heldOrThrow, heldSignInReads } from "./held.js";
|
|
57
60
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
58
61
|
import { RUNNER_HARNESSES } from "./adapters/index.js";
|
|
@@ -73,7 +76,7 @@ import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
|
73
76
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
74
77
|
import { settingOfDefinition } from "../computer-setting.js";
|
|
75
78
|
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
76
|
-
import { hadComputer } from "./computer-journal.js";
|
|
79
|
+
import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
|
|
77
80
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
78
81
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
79
82
|
import { heldSpecOf } from "./held-run.js";
|
|
@@ -86,6 +89,7 @@ import { monidForClaim, withMonid } from "./monid-run.js";
|
|
|
86
89
|
import { verifyPlacedProject, movedSkillFiles } from "../source-sync/claim.js";
|
|
87
90
|
import { projectCheckpointForRun } from "./project-checkpoint.js";
|
|
88
91
|
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
92
|
+
import { routeTrace } from "../otel/genai.js";
|
|
89
93
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
90
94
|
export const PI_WIRES = Object.freeze(["anthropic-messages", "openai-responses"]);
|
|
91
95
|
/** The browser's catalog name (tools.ts TOOLS.browser). */
|
|
@@ -97,6 +101,22 @@ export const BROWSER_ON_RUNNER = true;
|
|
|
97
101
|
* (host.browserComputer), fail closed: only on the native route (BROWSER_ON_RUNNER), and only with the run's ledger
|
|
98
102
|
* booking on its ToolHost (host.ledger.paid), so no browser call is held on this process's own spend. */
|
|
99
103
|
export const browserListed = (host, granted) => BROWSER_ON_RUNNER && host.ledger?.paid !== undefined && (granted.includes(BROWSER_TOOL) || host.browserComputer !== undefined);
|
|
104
|
+
/** A template eval case's files (EvalFakes.files) written into the run's work folder at its claim, after its inputs and
|
|
105
|
+
* before its computer and its first turn, so they reach a computer's /workspace as its uploads do. Each one the folder
|
|
106
|
+
* does not hold yet: a claim that resumes the run keeps what the run made of it. A write that fails ends the run failed,
|
|
107
|
+
* saying which file. */
|
|
108
|
+
export async function seedEvalFiles(workspace, files) {
|
|
109
|
+
for (const [path, text] of Object.entries(files ?? {})) {
|
|
110
|
+
if (await workspace.stat(path))
|
|
111
|
+
continue;
|
|
112
|
+
try {
|
|
113
|
+
await workspace.write(path, text);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw new Error(`The eval case's file ${path} could not be written in the run's work folder: ${error.message}`, { cause: error });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
100
120
|
/** A model as the cap prices it, from the route's catalog cost: its price WITH TIERS (the money rule — a request past a
|
|
101
121
|
* model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
|
|
102
122
|
* overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
|
|
@@ -118,6 +138,21 @@ export function capModelOf(route) {
|
|
|
118
138
|
// The cap reads a request's provider overhead by the route's own wire (providerInputOverhead).
|
|
119
139
|
return { id: route.model, api: route.provider.api, price, outputCeiling: route.outputCeiling ?? null, ...(route.local ? { local: true } : {}) };
|
|
120
140
|
}
|
|
141
|
+
/** The model of a held run its model kept from running at its create (run-launch.ts hold.refused): as its revision names
|
|
142
|
+
* it (`provider/model-id`). Its launch pins none (runs-over-store.ts skips modelOf for it). Nothing chooses it and
|
|
143
|
+
* nothing prices it. */
|
|
144
|
+
export function heldModelOf(ref) {
|
|
145
|
+
const at = ref?.indexOf("/") ?? -1;
|
|
146
|
+
return ref && at > 0 ? { provider: ref.slice(0, at), modelId: ref.slice(at + 1) } : { provider: "none", modelId: ref ?? "none" };
|
|
147
|
+
}
|
|
148
|
+
/** The route of a held run its model kept from running at its create (run-launch.ts hold.refused): its provider is the
|
|
149
|
+
* stand-in (provider.ts heldRefusedProvider), so a host with no key for its model still opens its claim and holds its
|
|
150
|
+
* computer. Its agent never starts (its start and every message are refused in `why`, its create's words:
|
|
151
|
+
* computer-held.ts), and a request that reached its proxy anyway is refused in them too, and never sent. */
|
|
152
|
+
export function heldRefusedRoute(model, why) {
|
|
153
|
+
const { origin, credential } = heldRefusedProvider(model, why);
|
|
154
|
+
return { model: model.modelId, named: `${model.provider}/${model.modelId}`, provider: { api: "anthropic-messages", origin, credential }, price: () => null, unpriced: true, outputCeiling: null };
|
|
155
|
+
}
|
|
121
156
|
/** Particle requests are never automatically replayed after an uncertain failure. Retry is a harness-wide setting,
|
|
122
157
|
* so a claim with any Particle route disables it for all its conversations, including subagents on other tiers. */
|
|
123
158
|
export function modelRetryOf(routes) {
|
|
@@ -128,12 +163,27 @@ export function modelRetryOf(routes) {
|
|
|
128
163
|
const SUBAGENT_ROUTE = "subagent-";
|
|
129
164
|
const subagentRoute = (tier) => `${SUBAGENT_ROUTE}${tier}`;
|
|
130
165
|
const isSubagentRoute = (key) => key.startsWith(SUBAGENT_ROUTE);
|
|
166
|
+
/** A model route as the run's GenAI trace names it: its provider, the host its requests go to, its model. A route that
|
|
167
|
+
* translates its model's requests (its own `fetch`) is named by its upstream's host (ModelRoute.upstreamOrigin), never
|
|
168
|
+
* its proxy's placeholder origin; one whose upstream is unknown names no host. */
|
|
169
|
+
export const traceOfRoute = (route) => {
|
|
170
|
+
const origin = route.fetch ? route.upstreamOrigin : route.provider.origin;
|
|
171
|
+
return routeTrace({ ...(route.named ? { named: route.named } : {}), ...(origin ? { origin } : {}), model: route.model });
|
|
172
|
+
};
|
|
173
|
+
/** The model a replay run's or an audit shadow's grader runs on (graderRouteOf): the revision's modelTiers.fast, else
|
|
174
|
+
* `env`'s fast tier (AGENT_MODEL_FAST); undefined when there is neither, or the revision names agree_on (no grader). */
|
|
175
|
+
export function graderModelOf(body, env) {
|
|
176
|
+
if (agreeOnOf(body.learning)?.length)
|
|
177
|
+
return undefined;
|
|
178
|
+
return body.modelTiers?.fast ?? tierModelOf(env, "fast");
|
|
179
|
+
}
|
|
131
180
|
/** A replay run's or an audit shadow's grader route (runner/compare-end.ts): its fast model (the revision's
|
|
132
181
|
* modelTiers.fast, else AGENT_MODEL_FAST) when its revision names no agree_on, on pi's wires. A fast model may be another
|
|
133
182
|
* provider's than the run's own, whose key claimSecrets never opened: so its route reads every model key the server
|
|
134
|
-
* holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone
|
|
135
|
-
*
|
|
136
|
-
*
|
|
183
|
+
* holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone; in a run's own
|
|
184
|
+
* process its runner hands it the fast model's provider's keys alone (run-child-host.ts savedModelKeys, graderModelOf). A
|
|
185
|
+
* run with its own model key carries that key, and no saved key is read. Undefined when there is no fast model, the
|
|
186
|
+
* revision names agree_on, or no route can be made (logged: the pair is then compared whole). */
|
|
137
187
|
export async function graderRouteOf(body, keyed, runKey, claimed, cut, log, deps, holds = [cut], claim) {
|
|
138
188
|
if (agreeOnOf(body.learning)?.length)
|
|
139
189
|
return undefined;
|
|
@@ -141,8 +191,9 @@ export async function graderRouteOf(body, keyed, runKey, claimed, cut, log, deps
|
|
|
141
191
|
for (const redact of new Set(holds))
|
|
142
192
|
holdClaimed(redact, savedKeys);
|
|
143
193
|
// The claim's run, turn and attempt on its grader's requests too (request-metadata.ts): they spend on the run's cap.
|
|
144
|
-
|
|
145
|
-
|
|
194
|
+
// keysOver, never a spread: the claim's model keys are not enumerable (claimSecrets).
|
|
195
|
+
const env = claimModelEnv(deps.env, keysOver(savedKeys, claimed), runKey, claim);
|
|
196
|
+
if (graderModelOf(body, env) === undefined)
|
|
146
197
|
return undefined;
|
|
147
198
|
try {
|
|
148
199
|
return await deps.routeOf(body.modelTiers?.fast, env, "fast", PI_WIRES, undefined, cut);
|
|
@@ -169,6 +220,11 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
|
|
|
169
220
|
// An MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf): what "allow reads" lifts an ask by.
|
|
170
221
|
const where = { root: folder, work: folder, ...(options.effectOf ? { effectOf: options.effectOf } : {}), ...(options.argumentsOf ? { argumentsOf: options.argumentsOf } : {}), facts: options.facts };
|
|
171
222
|
const gate = runGate({ ...where, ...(shell === undefined ? {} : { computer: shell === "computer" }) }, claim.runId, revision, () => current, approvers);
|
|
223
|
+
if (options.turnedOff)
|
|
224
|
+
gate.turnOff();
|
|
225
|
+
// Whether the run's journal has the computer off already (an earlier claim's, or this claim's first deny's): written once.
|
|
226
|
+
let offSaid = options.turnedOff === true;
|
|
227
|
+
const { onComputerOff } = options;
|
|
172
228
|
// The run's learned workflows, once its spec has read them (learn): a learned_workflow call is asked about its MCP nodes.
|
|
173
229
|
let learned = [];
|
|
174
230
|
// The host the run's tools bind through, once the spec has made it (askedOn): a tool's own ask reads it.
|
|
@@ -198,9 +254,29 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
|
|
|
198
254
|
asking.set(call.tool, turn.catch(() => undefined));
|
|
199
255
|
return turn;
|
|
200
256
|
};
|
|
257
|
+
// The computer off, written to the run's journal once. A write that fails (a fenced claim, a journal error) never fails
|
|
258
|
+
// the call, whose refusal stands: the claim's next refusal of the computer's tools writes it again.
|
|
259
|
+
const sayOff = async () => {
|
|
260
|
+
const turnedOff = offSaid ? undefined : gate.computerOff;
|
|
261
|
+
if (!turnedOff)
|
|
262
|
+
return;
|
|
263
|
+
offSaid = true;
|
|
264
|
+
try {
|
|
265
|
+
await onComputerOff?.(turnedOff);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
offSaid = false;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
201
271
|
const decide = async (call, options = {}) => {
|
|
272
|
+
const off = gate.offRefusal(call.tool, options);
|
|
273
|
+
if (off) {
|
|
274
|
+
await sayOff();
|
|
275
|
+
return off;
|
|
276
|
+
}
|
|
202
277
|
current = await storeSettings(store);
|
|
203
278
|
const decision = await gate.decide(call.tool, call.args, options);
|
|
279
|
+
await sayOff();
|
|
204
280
|
// A call its setting allows that its tool asks about itself (ToolEntry.asks: email_send past its cap, or to someone
|
|
205
281
|
// outside the run's thread): put to a person with the tool's reason on its card, whatever the setting; where no one
|
|
206
282
|
// can approve, refused in those words. No tool's name is read here: the reason is the tool's.
|
|
@@ -316,6 +392,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
316
392
|
// the process started (run-child-host.ts), as the server's held uploads are never the run's to read.
|
|
317
393
|
if (!(deps.sealKey === undefined && runnerSeam()))
|
|
318
394
|
await placeRunInputs(deps.data, claim.runId, ws.workspace, filesToCopy(launch), messageText(launch.input));
|
|
395
|
+
await seedEvalFiles(ws.workspace, deps.evalFakes?.(runRow.agentId)?.files);
|
|
319
396
|
// The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
|
|
320
397
|
// turn, with the GitHub App's read-only token for that one repository (or none); the run is told what it holds, or why
|
|
321
398
|
// there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
|
|
@@ -351,13 +428,16 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
351
428
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
352
429
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
353
430
|
const hold = (values) => cut.hold(values);
|
|
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 } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach,
|
|
431
|
+
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 } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, runRow.agentId, launch) });
|
|
355
432
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
356
433
|
holds.hold({ passed: mcp });
|
|
357
434
|
// The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
|
|
358
435
|
// Docker container for a sandbox, under the claim's epoch (the one fence). It throws computer_unavailable (nothing made)
|
|
359
436
|
// when the computer cannot be had: the run fails in its words.
|
|
360
437
|
const claimSignal = run.stopped ?? run.signal;
|
|
438
|
+
// An earlier claim's deny turned the run's computer off for the run (computerTurnedOff): this claim starts none, and
|
|
439
|
+
// ends the one a park kept, its mount with it, before the run's tools touch its folder (turnedOff).
|
|
440
|
+
const offAlready = await computerTurnedOff(deps.journal(claim), context);
|
|
361
441
|
const computer = await deps.computerForClaim(
|
|
362
442
|
// The runner holding the claim (its name, its presence incarnation): a computer a park keeps that only it can reach
|
|
363
443
|
// again is pinned to it.
|
|
@@ -370,7 +450,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
370
450
|
// claim's is a new one whatever ended the earlier claim (a lost runner, a server's stop, a park past its keep). The
|
|
371
451
|
// computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted. A
|
|
372
452
|
// recording of its screen (computer.record) goes in the run's recordings folder, beside its folder, said on its timeline.
|
|
373
|
-
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, 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() } : {}), ...(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) } : {}) });
|
|
453
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, ...(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() } : {}), ...(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) } : {}) });
|
|
374
454
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
375
455
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
376
456
|
// A desktop's or a phone's hold (the person's take-over) wraps its ports: a call made while the person holds it waits,
|
|
@@ -409,7 +489,12 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
409
489
|
// The route reads its model's key from the runner's environment, else the one the claim opened from the store: a key
|
|
410
490
|
// saved in Settings → Model keys runs the next run with no restart (withModelKeys). A run with its own key: that key.
|
|
411
491
|
const modelEnv = claimModelEnv(deps.env, toolEnv, runKey, claim);
|
|
412
|
-
|
|
492
|
+
// A held run its model kept from running at its create is never routed (heldRefusedRoute): its model's route chooses no
|
|
493
|
+
// model and reads no key, so a key saved since runs a new run, never this one. Its claim lays only the keys any claim
|
|
494
|
+
// of the run lays (its tools', a key handed with it: claimSecrets lays it no model key), routes no subagent tier and
|
|
495
|
+
// takes no learning step (below).
|
|
496
|
+
const heldRefusal = launch.hold?.refused?.message;
|
|
497
|
+
const route = heldRefusal !== undefined ? heldRefusedRoute(heldModelOf(body.model), heldRefusal) : await deps.routeOf(modelAskOf(launch.model, body.model), modelEnv, "default", PI_WIRES, undefined, cut);
|
|
413
498
|
await planBeforeRun(modelEnv, route.provider.plan ? { provider: PLAN_PROVIDER } : undefined);
|
|
414
499
|
// The run's models of other tiers, for its learned workflows' nodes of a tier (learnedTierRoutes, filled once the seed's
|
|
415
500
|
// lay chose the workflows, below): read when the session opens (pi.ts options.tiers), each on a proxy of its own.
|
|
@@ -434,13 +519,14 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
434
519
|
// credential, never the run's tools (toolEnv).
|
|
435
520
|
// Each is in tierRoutes under its own key (subagentRoute: never a learned workflow's tier, whose nodes keep their own
|
|
436
521
|
// routes and fallback), on a proxy of its own that names that key on each request, so the cap prices a child's
|
|
437
|
-
// requests as that route books them.
|
|
522
|
+
// requests as that route books them. A held run its model kept from running routes none: its subagent's calls run on
|
|
523
|
+
// the stand-in, refused in its create's words.
|
|
438
524
|
const tierWhy = new Map();
|
|
439
|
-
if (revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL)) {
|
|
525
|
+
if (revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL) && heldRefusal === undefined) {
|
|
440
526
|
// A run with its own model key: its subagents' models carry that key too, and no saved key is read.
|
|
441
527
|
const savedKeys = keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env });
|
|
442
528
|
holdClaimed(cut, savedKeys);
|
|
443
|
-
const tierEnv = claimModelEnv(deps.env,
|
|
529
|
+
const tierEnv = claimModelEnv(deps.env, keysOver(savedKeys, toolEnv), runKey, claim);
|
|
444
530
|
for (const tier of SUBAGENT_TIERS) {
|
|
445
531
|
if (body.modelTiers?.[tier] === undefined && tierModelOf(tierEnv, tier) === undefined)
|
|
446
532
|
continue;
|
|
@@ -489,7 +575,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
489
575
|
// A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf). The harness's facts
|
|
490
576
|
// are its entry's on the owner's table (factsOf): none for pi, nor for a module's harness on a runner of its own.
|
|
491
577
|
const facts = factsOf(deps.env, revision.body.harness);
|
|
492
|
-
|
|
578
|
+
// The run's computer off for the run (its first deny's, this claim's or an earlier one's) is on the run's journal.
|
|
579
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, { ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}), facts, turnedOff: offAlready !== undefined, onComputerOff: (kind) => recordComputerOff(run.harness, kind) });
|
|
493
580
|
// The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
|
|
494
581
|
// uncapped — every paid request still books through the one cap), the run's model priced WITH tiers, strict where the
|
|
495
582
|
// launch says. The loop builds the kernel runCap from these over the run's own sessions (its model requests, its paid
|
|
@@ -543,14 +630,14 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
543
630
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
544
631
|
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
545
632
|
// The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
|
|
546
|
-
// Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit and a replay check
|
|
547
|
-
// are skipped, in words, where the run brought its own key or the server holds none.
|
|
548
|
-
const spendOff = await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey);
|
|
549
633
|
const admitAuxiliary = runnerSeam() ? undefined : sourceAuxiliaryAdmitter(deps.store, { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
550
|
-
|
|
634
|
+
// None for a held run, so its claim reads no saved key for spend beside it (claimSpendOff).
|
|
635
|
+
const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff: await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey), admitAuxiliary } : undefined;
|
|
551
636
|
// Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
|
|
552
|
-
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself.
|
|
553
|
-
|
|
637
|
+
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself. A held run its model kept from
|
|
638
|
+
// running takes none of them: it settles no audit and starts no replay run, starts on no workflow, and its tool runs
|
|
639
|
+
// none (so no learned tier is routed, below).
|
|
640
|
+
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: [] };
|
|
554
641
|
const firstChoice = learned.choice;
|
|
555
642
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
556
643
|
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
@@ -568,7 +655,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
568
655
|
// A run with its own model key: its learned nodes' tiers carry that key too, and no saved key is read.
|
|
569
656
|
const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
|
|
570
657
|
holdClaimed(cut, tierKeys);
|
|
571
|
-
const tierEnv = claimModelEnv(deps.env,
|
|
658
|
+
const tierEnv = claimModelEnv(deps.env, keysOver(toolEnv, tierKeys), runKey, claim);
|
|
572
659
|
for (const [tier, routed] of await learnedTierRoutes(workflows, tierEnv, (tier) => deps.routeOf(undefined, tierEnv, tier, PI_WIRES, undefined, cut))) {
|
|
573
660
|
if ("why" in routed)
|
|
574
661
|
tierUnreachable.set(tier, routed.why);
|
|
@@ -580,8 +667,9 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
580
667
|
underClaimed(toolEnv, learnedKeys);
|
|
581
668
|
}
|
|
582
669
|
// 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
|
|
583
|
-
// session's booking under the run's one cap. None: the pair is compared whole, in words saying so.
|
|
584
|
-
|
|
670
|
+
// session's booking under the run's one cap. None: the pair is compared whole, in words saying so. None for a held run
|
|
671
|
+
// its model kept from running, whose model runs nowhere.
|
|
672
|
+
const graderRoute = (launch.replay || launch.audit) && heldRefusal === undefined ? await graderRouteOf(body, keyed, runKey, toolEnv, cut, log, deps, [cut], claim) : undefined;
|
|
585
673
|
if (graderRoute)
|
|
586
674
|
tierRoutes.set(GRADER, graderRoute);
|
|
587
675
|
// The tool host's install lifecycle: what a binding registers to run in each conversation's creating commit, once the
|
|
@@ -624,7 +712,9 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
624
712
|
// The one path for every harness.
|
|
625
713
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
626
714
|
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
627
|
-
|
|
715
|
+
// A computer the claim did not start (every tool of it set to deny: ClaimComputer.off) has its kind's skill named to no one.
|
|
716
|
+
const skills = computer.off ? withoutKindSkill(currentSkills, body.skills ?? {}, settingOfDefinition(body)?.computer.kind) : currentSkills;
|
|
717
|
+
const instructions = await promptOf(laid, skills, ws.workspace, { onDemand: movedProject || readsFiles(granted) });
|
|
628
718
|
const guidance = effortGuidance(launch.effort);
|
|
629
719
|
// The run's clock: a template eval case's (EvalFakes.now), else the real one.
|
|
630
720
|
const now = fakes?.now;
|
|
@@ -681,7 +771,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
681
771
|
// from. With a grader it compares its answer with the other one (runner/compare-end.ts), on its own cap.
|
|
682
772
|
// A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
|
|
683
773
|
// withAudit): at its end, so the shadow's cap is what the run's own left.
|
|
684
|
-
|
|
774
|
+
// A held run (no audits) takes none, and its runner refuses one too (run-child-host.ts heldFor).
|
|
775
|
+
const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, folder: learningFolder, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
|
|
685
776
|
store: deps.store,
|
|
686
777
|
data: deps.data,
|
|
687
778
|
...(deps.env ? { env: deps.env } : {}),
|
|
@@ -715,6 +806,11 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
715
806
|
// The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry).
|
|
716
807
|
...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
|
|
717
808
|
...(cap ? { cap } : {}),
|
|
809
|
+
// Its routes, as its GenAI trace names them (otel/genai.ts): the session's, and each tier's by its name.
|
|
810
|
+
trace: {
|
|
811
|
+
...traceOfRoute(route),
|
|
812
|
+
routes: new Map([...tierRoutes].map(([tier, routed]) => [tier, traceOfRoute(routed)])),
|
|
813
|
+
},
|
|
718
814
|
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
719
815
|
// the catalog tools the session mounts; absent when none.
|
|
720
816
|
...(catalog ? { mcp: catalog } : {}),
|
|
@@ -926,14 +1022,28 @@ export function liveViewersOf(store, sealKey, claim, cut) {
|
|
|
926
1022
|
}
|
|
927
1023
|
/** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
|
|
928
1024
|
* string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
|
|
929
|
-
* its links whole for a grader's link check
|
|
1025
|
+
* its links whole for a grader's link check; one whose strings, read joined, hold a held value no cut in place takes (a
|
|
1026
|
+
* value split across two of them) is "[redacted]" (webHeld). The join is read against the values `cut` holds
|
|
1027
|
+
* (key-refusal.ts withheldWhole), or through `cut` itself when it does not know them (joinCut). Each string is cut once
|
|
1028
|
+
* in a call, for the join's read and the answer both. */
|
|
930
1029
|
export function answersCut(tool, cut) {
|
|
931
1030
|
return {
|
|
932
1031
|
...tool,
|
|
933
1032
|
call: async (args, context) => {
|
|
934
1033
|
try {
|
|
935
1034
|
const answer = await tool.call(args, context);
|
|
936
|
-
|
|
1035
|
+
const seen = new Map();
|
|
1036
|
+
const once = (text) => {
|
|
1037
|
+
let out = seen.get(text);
|
|
1038
|
+
if (out === undefined)
|
|
1039
|
+
seen.set(text, (out = cut(text)));
|
|
1040
|
+
return out;
|
|
1041
|
+
};
|
|
1042
|
+
const holds = (joined, parts) => {
|
|
1043
|
+
const values = cut.heldValues?.();
|
|
1044
|
+
return values ? withheldWhole(joined, values) : joinCut(joined, parts, once);
|
|
1045
|
+
};
|
|
1046
|
+
return { ...answer, text: webCut(tool.name, answer.text, once, holds) ?? cut(answer.text) };
|
|
937
1047
|
}
|
|
938
1048
|
catch (error) {
|
|
939
1049
|
if (error instanceof Error) {
|
|
@@ -947,6 +1057,18 @@ export function answersCut(tool, cut) {
|
|
|
947
1057
|
},
|
|
948
1058
|
};
|
|
949
1059
|
}
|
|
1060
|
+
/** Whether `cut`, a redactor that does not know its values, takes from `joined` (`parts` joined by line breaks) what it
|
|
1061
|
+
* does not take from the parts each read alone: a held value split across two parts. Its cut of the join whole being
|
|
1062
|
+
* "[redacted]" is not enough: it reads a text longer than a piece in pieces of 8,192 characters (key-refusal.ts
|
|
1063
|
+
* redactedAnswer), and a value split inside one piece withholds only that piece, the rest of the join served. So the
|
|
1064
|
+
* join's cut is set beside the parts' cuts joined: no value split across parts is in any part to cut, so the two differ
|
|
1065
|
+
* wherever the join holds one, in one piece or across two. Where nothing spans two parts they are the same: every piece
|
|
1066
|
+
* ends at whitespace or inside a run of more than a piece (the same run in a part as in the join, cut at the same
|
|
1067
|
+
* places), and a line break ends each part. */
|
|
1068
|
+
function joinCut(joined, parts, cut) {
|
|
1069
|
+
const whole = cut(joined);
|
|
1070
|
+
return whole === "[redacted]" || whole !== parts.map(cut).join("\n");
|
|
1071
|
+
}
|
|
950
1072
|
/** The ToolHost a run's non-hand tools bind through, the one both the pi spec and the CLI spec build: the run's folder and
|
|
951
1073
|
* the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
|
|
952
1074
|
* extension a binding installs, the install lifecycle (`life`, run by the adapter loop from the spec's `lifecycle`), the
|
|
@@ -28,6 +28,28 @@ function recordingExtension(extension, keep) {
|
|
|
28
28
|
})),
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
/** A pi-native tool (options.tools, an extension's: ask_person, subagent, the browser's) whose calls the session reports
|
|
32
|
+
* as piTool reports a host tool's: its start before it runs, its end (an error when it says so or throws) after, with no
|
|
33
|
+
* result text. A host tool is never one of these (piTool reports its own), so no call is reported twice. */
|
|
34
|
+
function announcing(tool, io) {
|
|
35
|
+
return {
|
|
36
|
+
...tool,
|
|
37
|
+
execute: async (args, api, context) => {
|
|
38
|
+
io.onEvent({ type: "tool_start", callId: api.callId, name: tool.name, args });
|
|
39
|
+
let failed = true;
|
|
40
|
+
try {
|
|
41
|
+
const result = await tool.execute(args, api, context);
|
|
42
|
+
failed = Boolean(result?.isError);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
io.onEvent({ type: "tool_end", callId: api.callId, name: tool.name, isError: failed });
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** `extension` with each of its tools announcing (announcing). */
|
|
52
|
+
const announcingExtension = (extension, io) => extension.tools?.length ? { ...extension, tools: extension.tools.map((tool) => announcing(tool, io)) } : extension;
|
|
31
53
|
const PROVIDER = "agentrun-session";
|
|
32
54
|
/** The input tokens pi (the @earendil-works/pi-* 1.5.2 packages serve pins) sends in a run's first model request before
|
|
33
55
|
* the agent's own prompt: pi writes no system prompt of its own, so it is serve's (the environment line and the wrapper
|
|
@@ -269,7 +291,7 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
269
291
|
const touched = new Set();
|
|
270
292
|
// A refused nested call's words, by its id (pi's nested result keeps none of a refused call's output).
|
|
271
293
|
const nestedRefusals = new Map();
|
|
272
|
-
const tools = [...spec.tools.filter((tool) => !owned.has(tool.name)).map((tool) => piTool(tool, io, (callId) => (io.gate ? (passed.has(callId) ? 0 : 1) : undefined), touched, nestedRefusals)), ...(options.tools ?? [])];
|
|
294
|
+
const tools = [...spec.tools.filter((tool) => !owned.has(tool.name)).map((tool) => piTool(tool, io, (callId) => (io.gate ? (passed.has(callId) ? 0 : 1) : undefined), touched, nestedRefusals)), ...(options.tools ?? []).map((tool) => announcing(tool, io))];
|
|
273
295
|
// A refused call's words (the gate's deny, main's), by call: its result is those words alone, as main gives them.
|
|
274
296
|
const refusals = refusalWords();
|
|
275
297
|
const extension = defineExtension({
|
|
@@ -327,8 +349,8 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
327
349
|
});
|
|
328
350
|
run.registry.install(extension);
|
|
329
351
|
// The run's pi-native extensions (options.extensions), in the claim's registry beside the session's: each tool's computer
|
|
330
|
-
// calls recorded on its row (io.keepCalls), as the loop records its host tools'.
|
|
331
|
-
const native = (options.extensions ?? []).map((each) => (io.keepCalls ? recordingExtension(each, io.keepCalls) : each));
|
|
352
|
+
// calls recorded on its row (io.keepCalls), as the loop records its host tools', and each call's start and end reported.
|
|
353
|
+
const native = (options.extensions ?? []).map((each) => announcingExtension(io.keepCalls ? recordingExtension(each, io.keepCalls) : each, io));
|
|
332
354
|
for (const each of native)
|
|
333
355
|
run.registry.install(each);
|
|
334
356
|
// The root conversation may exist already (the loop's session records live beside it, under it): its agent is set here,
|
package/dist/runner/beside.js
CHANGED
|
@@ -71,8 +71,8 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
|
|
|
71
71
|
// `mcpLoopback`: the server beside it is a local install (Serve.localInstall), so its runs may reach an MCP server on
|
|
72
72
|
// loopback; a runner in its own process does only as its own environment says (main.ts runnerLoopback). `mcpOwn`: that server's own addresses (Serve.own), whose ports a run's
|
|
73
73
|
// loopback read never goes to. A run's log lines (a sweep that failed) go to
|
|
74
|
-
// stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid
|
|
75
|
-
// email), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
|
|
74
|
+
// stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid,
|
|
75
|
+
// email and files), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
|
|
76
76
|
// claim's first-use install installs with (the eval's sharedInstaller, which the server beside it takes too).
|
|
77
77
|
const { installForClaim } = await import("../harness-install.js");
|
|
78
78
|
const deps = { env: runs, data: dataDir, journal: (claim) => store.journal(claim), store, sealKey: seal.key, routeOf, computerForClaim: computers.computerForClaim, computerDeps: computers.computerDeps, ...(mcpLoopback ? { mcpLoopback: true } : {}), ...(mcpOwn ? { mcpOwn } : {}), ...(evalFakes ? { evalFakes } : {}), ...(harnessInstall ? { installForClaim: ((entry, dir, pins, given) => installForClaim(entry, dir, pins, { ...given, install: harnessInstall })) } : {}), log: (line) => console.error(`agentrun-serve runner: ${line}`) };
|
|
@@ -124,9 +124,10 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
|
|
|
124
124
|
// the runner beside it (read at each end, once it has started): a computer kept pinned to another runner is that one's.
|
|
125
125
|
const { runEndComputers } = await import("../workspace/run-end-computers.js");
|
|
126
126
|
const { projectRunEnded } = await import("../source-sync/checkpoints.js");
|
|
127
|
+
const { runCensus } = await import("../run-census.js");
|
|
127
128
|
const self = () => (runner.incarnation ? { runner: name, incarnation: runner.incarnation } : undefined);
|
|
128
129
|
const runEnded = projectRunEnded(store, runEndComputers({ store, computers: computers.computerDeps, log: (line) => console.error(`agentrun-serve runner: ${line}`), self }));
|
|
129
|
-
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 } : {}) });
|
|
130
|
+
const runner = startRunner({ store, name, createLoop, census: runCensus(store, { data: dataDir, sealKey: seal.key, env: runs }), memory: runnerMemory(store, undefined, runs, isolation ? RUN_PROCESS_MIB : 0), onEvent: said, runEnded, ...(held !== undefined ? { loops: held } : {}), ...(drainMs !== undefined ? { drainMs } : {}) });
|
|
130
131
|
// The computer janitor over the same computers, when the start asks for it: never under --faux. Its lines are the
|
|
131
132
|
// runner's, on stderr (a stderr whose reader closed loses them, never the process: cli.ts).
|
|
132
133
|
const { startJanitor } = await import("../workspace/computer-janitor.js");
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// runner only copies bytes and calls the Workspace: it reads nothing of them and dials nothing.
|
|
15
15
|
import { ClaimRefused } from "./loop-contract.js";
|
|
16
16
|
import { ChannelClosed } from "./run-channel.js";
|
|
17
|
+
import { until } from "../until.js";
|
|
17
18
|
import { saveSlots, SAVE_MAX_BYTES } from "../web-save.js";
|
|
18
19
|
import { WorkspaceError } from "../workspace/workspace.js";
|
|
19
20
|
export { piecedWorkspace } from "../workspace/pieced.js";
|
|
@@ -31,16 +32,6 @@ export const BIG_WRITES = 4;
|
|
|
31
32
|
export const BIG_WRITES_PER_RUN = 8;
|
|
32
33
|
/** The runner's one gate for pieced writes. */
|
|
33
34
|
export const BIG_WRITE_SLOTS = saveSlots(BIG_WRITES);
|
|
34
|
-
/** `work`'s answer, or `signal`'s reason as soon as it aborts. */
|
|
35
|
-
function until(work, signal) {
|
|
36
|
-
if (signal.aborted)
|
|
37
|
-
return Promise.reject(signal.reason);
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
const abort = () => reject(signal.reason);
|
|
40
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
41
|
-
work.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
35
|
export function runBigWrites(options = {}) {
|
|
45
36
|
const gate = options.gate ?? BIG_WRITE_SLOTS;
|
|
46
37
|
const piece = options.piece ?? PIECE_BYTES;
|
|
@@ -30,12 +30,19 @@ type RunLaunchReader = {
|
|
|
30
30
|
/** The environment a claimed run's tools run under: the runner's base (its secrets stripped), with the keys the run's
|
|
31
31
|
* revision needs read from the store on top — the tool keys its tools unlock, the model keys its model needs, and its
|
|
32
32
|
* decision provider keys — and, for claim `runId`, the run's own tool keys its revision declares (run-keys.ts) over the
|
|
33
|
-
* server's by the same name.
|
|
33
|
+
* server's by the same name. Its model keys are readable by name and never enumerable (MODEL_KEY_NAMES): its model
|
|
34
|
+
* routes read them by name (claimModelEnv), and a spread or a spawn of the tools' environment carries none. A fresh
|
|
35
|
+
* object per claim, so no run's keys reach another's. `redact`: the runner's one
|
|
34
36
|
* redactor, which the run's own tool keys are carried into before they are laid, so its journal is cut of them as it is
|
|
35
|
-
* written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws.
|
|
37
|
+
* written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. A held run
|
|
38
|
+
* its model kept from running at its create (hold.refused) is laid no model key and no plan sign-in: its model runs
|
|
39
|
+
* nowhere. Its tools' keys, its decision keys and its own tool keys are laid as any run's. The one tool key row that names
|
|
40
|
+
* a model key's name, TypeSafe's (key-words.ts; model.ts PROVIDER_KEYS typesafe), is a decision key (secrets.ts
|
|
41
|
+
* DECISION_KEYS): keysFor never names one, so the model key filter below never sees it, and decisionKeysFor lays it
|
|
42
|
+
* apart, as it lays OpenRouter's for a decision node that runs on it. */
|
|
36
43
|
export declare function claimSecrets(deps: ClaimSecretsDeps & {
|
|
37
44
|
readonly redact: HeldRedact;
|
|
38
|
-
}, revision: Revision, launch: Pick<RunLaunch, "plane" | "model">, runId?: string): Promise<NodeJS.ProcessEnv>;
|
|
45
|
+
}, revision: Revision, launch: Pick<RunLaunch, "plane" | "model" | "hold">, runId?: string): Promise<NodeJS.ProcessEnv>;
|
|
39
46
|
/** `keys` (learnedDecisionKeys') laid onto `env`, a claim's environment, where it holds no value of that name: what the
|
|
40
47
|
* claim laid stays, a run's own tool key over the server's above all. A name both read holds the same server key. */
|
|
41
48
|
export declare function underClaimed(env: NodeJS.ProcessEnv, keys: Readonly<Record<string, string>>): void;
|
|
@@ -69,6 +76,11 @@ export declare function withModelKeys(env: NodeJS.ProcessEnv, opened: NodeJS.Pro
|
|
|
69
76
|
/** Every model key the server holds, for a model route with no revision to scope it by (an SDK run's compile turn): each
|
|
70
77
|
* by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
|
|
71
78
|
export declare function savedModelKeys(deps: ClaimSecretsDeps): Promise<NodeJS.ProcessEnv>;
|
|
79
|
+
/** Of `saved` (savedModelKeys'), the keys a route to `model` (`provider/model-id`) reads and no other: its provider's
|
|
80
|
+
* (PROVIDER_KEYS), or through a gateway (`env`'s AGENT_MODEL_BASE_URL, as modelKeys reads it) the gateway's key alone.
|
|
81
|
+
* None for no model, or one whose provider names no key. What a runner hands a run's process for one route of its
|
|
82
|
+
* (run-child-host.ts savedModelKeys): never every key the server holds. */
|
|
83
|
+
export declare function routeModelKeys(saved: NodeJS.ProcessEnv, env: NodeJS.ProcessEnv, model: string | undefined): NodeJS.ProcessEnv;
|
|
72
84
|
/** A run's own model key, held by its claim (run-model-key.ts): `fresh()` opens it from the run's launch again (a message's
|
|
73
85
|
* new key replaces it, or a run that started on the server's key takes its first); `everHeld()`, whether the claim ever
|
|
74
86
|
* held one, so spend after the turn never falls to the server's key for a run that brought its own. */
|
|
@@ -137,4 +149,7 @@ export declare function claimModelEnv(env: NodeJS.ProcessEnv, opened: NodeJS.Pro
|
|
|
137
149
|
* run's model routes do not send. The decision providers' keys stay (DECISION_KEY_NAMES): a keyed workflow's judge,
|
|
138
150
|
* pick, sift, route and ask nodes run on them as any run's do. */
|
|
139
151
|
export declare function withoutModelKeys(toolEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
152
|
+
/** `under` and `over` as one set of opened keys for claimModelEnv, `over`'s value winning by name: every property as it
|
|
153
|
+
* is, so a claim's model keys (claimSecrets: never enumerable), which a spread would drop, reach the route. */
|
|
154
|
+
export declare function keysOver(under: NodeJS.ProcessEnv, over: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
140
155
|
export {};
|