@parcha/agentrun-serve 0.1.0-beta.59 → 0.1.0-beta.61
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 +135 -0
- package/README.md +230 -120
- package/dist/acp-package.d.ts +4 -0
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/api-only.d.ts +21 -3
- package/dist/api-only.js +41 -6
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +4 -2
- package/dist/chatgpt-plan.js +13 -3
- package/dist/claude-login-token.d.ts +5 -0
- package/dist/claude-login-token.js +8 -0
- package/dist/claude-login.d.ts +49 -3
- package/dist/claude-login.js +140 -10
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +42 -10
- package/dist/console/assets/{backend-BztxEAvb.js → backend-C9ffXUR5.js} +1 -1
- package/dist/console/assets/index-BnZV3lvW.js +639 -0
- package/dist/console/assets/{share-L84tlUDW.js → share-B1o5mJ56.js} +2 -2
- package/dist/console/assets/{styles-CaRKlHke.js → styles-D_znYrHR.js} +31 -31
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +1 -2
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +9 -3
- package/dist/harness-table.js +11 -5
- package/dist/harness.js +6 -2
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +9 -0
- package/dist/import.js +11 -1
- package/dist/key-refusal.d.ts +5 -0
- package/dist/key-refusal.js +30 -18
- package/dist/learn/audit.d.ts +20 -22
- package/dist/learn/audit.js +72 -55
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +4 -4
- package/dist/learn/compile.js +6 -7
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +40 -66
- package/dist/learn/promote.js +69 -207
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +36 -0
- package/dist/learned-nodes.js +23 -0
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +44 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +35 -0
- package/dist/ollama-provider.js +108 -2
- package/dist/openapi.js +147 -35
- package/dist/place-offers.d.ts +3 -0
- package/dist/place-offers.js +3 -0
- package/dist/place.d.ts +35 -12
- package/dist/place.js +67 -29
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +36 -8
- package/dist/redact/match.js +179 -44
- package/dist/run-export.js +4 -2
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +6 -5
- package/dist/run-usage.js +3 -2
- package/dist/runnable.js +25 -8
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +100 -20
- package/dist/runner/adapter-run-spec.d.ts +3 -5
- package/dist/runner/adapter-run-spec.js +35 -61
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +3 -5
- package/dist/runner/audit.js +28 -51
- package/dist/runner/cli-run-spec.js +19 -22
- package/dist/runner/compare-end.d.ts +1 -3
- package/dist/runner/compare-end.js +6 -2
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/dispatch.js +2 -2
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.d.ts +9 -0
- package/dist/runner/harness-loops.js +49 -7
- package/dist/runner/held.d.ts +4 -11
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +1 -1
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +3 -3
- package/dist/runner/learning-end.d.ts +12 -16
- package/dist/runner/learning-end.js +41 -75
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +3 -4
- package/dist/runner/main.js +1 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +23 -4
- package/dist/runner/mcp-run.js +31 -2
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -3
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -4
- package/dist/runner/promotion.d.ts +19 -28
- package/dist/runner/promotion.js +50 -69
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/run-child-host.d.ts +1 -9
- package/dist/runner/run-child-host.js +12 -68
- package/dist/runner/runner.d.ts +1 -1
- package/dist/runner/sdk-loop.js +7 -7
- package/dist/runner/workflow-calls.d.ts +4 -1
- package/dist/runner/workflow-calls.js +35 -18
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +20 -7
- package/dist/sdk/runs.js +105 -68
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.js +97 -83
- package/dist/secrets.d.ts +4 -0
- package/dist/secrets.js +44 -10
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +6 -0
- package/dist/server-keys.js +12 -0
- package/dist/server.d.ts +22 -15
- package/dist/server.js +311 -198
- package/dist/slack.js +2 -1
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/schema.d.ts +28 -2
- package/dist/store/schema.js +81 -5
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/store.d.ts +7 -1
- package/dist/store/sqlite/store.js +84 -18
- package/dist/store/store.d.ts +219 -6
- package/dist/store/store.js +13 -0
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +23 -26
- package/dist/store-reads/learning.js +42 -30
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +40 -11
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/tool-plane.d.ts +27 -3
- package/dist/tool-plane.js +79 -4
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/web-holds.d.ts +2 -0
- package/dist/web-holds.js +5 -2
- package/dist/web-run.js +2 -1
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-deps.js +5 -3
- package/dist/workspace/computer-providers.d.ts +11 -1
- package/dist/workspace/computer-providers.js +29 -2
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/workspace.d.ts +1 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -13
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/index-LwNL4L9q.js +0 -619
- package/dist/console/assets/styles-DQo8rzY-.css +0 -1
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
|
@@ -30,9 +30,8 @@ import { wireName } from "../catalog.js";
|
|
|
30
30
|
import { environmentLine, runZone } from "../environment.js";
|
|
31
31
|
import { factsOf, harnessOf, planRecipeOf } from "../harness-table.js";
|
|
32
32
|
import { layHarnessKeys, openHarnessKeys, RECIPE_SIGN_IN_PERSON_ONLY, RECIPE_TURN_PERSON_ONLY } from "../harness-keys.js";
|
|
33
|
-
import { laidLearned,
|
|
33
|
+
import { laidLearned, secretsShown } from "../learning.js";
|
|
34
34
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
35
|
-
import { learningWorkspace } from "../learn/folder.js";
|
|
36
35
|
import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
|
|
37
36
|
import { ollamaTagsOf, providerModels, runModels } from "../model.js";
|
|
38
37
|
import { OLLAMA_PROVIDER } from "../ollama-provider.js";
|
|
@@ -76,7 +75,7 @@ import { AUDIT_PARKED, withAudit } from "./audit.js";
|
|
|
76
75
|
import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
|
|
77
76
|
import { runPathMetricsOverStore } from "../store-reads/learning.js";
|
|
78
77
|
import { specBuilt } from "./spec-holds.js";
|
|
79
|
-
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
78
|
+
import { heldRedactor, holdClaimed, mustHold, runnerSecrets, secretRedactor } from "./redact.js";
|
|
80
79
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
81
80
|
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginByToken, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
82
81
|
import { heldTokenLogin } from "../claude-login-token.js";
|
|
@@ -289,6 +288,7 @@ export function cliRunSpecFromLaunch(launch, run, deps, claim) {
|
|
|
289
288
|
return specBuilt((holds) => cliSpec(launch, run, deps, claim, holds));
|
|
290
289
|
}
|
|
291
290
|
async function cliSpec(launch, run, deps, claim, holds) {
|
|
291
|
+
mustHold(run.redact, "A CLI run's spec");
|
|
292
292
|
const context = BACKGROUND_CONTEXT;
|
|
293
293
|
// What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
|
|
294
294
|
const reach = await mcpReachOf(deps);
|
|
@@ -320,7 +320,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
320
320
|
holds.hold({ scratch: { sweep: () => sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
|
|
321
321
|
// Every secret the server keeps sealed (store-secrets.ts) held by the runner's one redactor (the loop's) and this spec's
|
|
322
322
|
// log cut, before any of the run's text is written: a run's text may quote one it was never handed.
|
|
323
|
-
for (const redact of [
|
|
323
|
+
for (const redact of [run.redact, cut])
|
|
324
324
|
await holdStored(redact, deps.store, deps.sealKey, deps.data);
|
|
325
325
|
const revisionRow = await deps.store.agents.revision(runRow.revisionId);
|
|
326
326
|
if (!revisionRow)
|
|
@@ -401,7 +401,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
401
401
|
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
402
402
|
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
403
403
|
// Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
|
|
404
|
-
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
404
|
+
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors. A
|
|
405
|
+
// per_run server the run was handed no credential for is left out of its tools, and its timeline says so; not on a
|
|
406
|
+
// harness whose tools are fixed at its thread's start (AdapterFacts.toolsFixedAtStart), where it would never come back.
|
|
405
407
|
// A held run its model kept from running at its create (hold.refused) opens none: nothing can call one.
|
|
406
408
|
const heldRefusal = launch.hold?.refused?.message;
|
|
407
409
|
// What its gateway files (a long answer, a server's results) goes in the run's own files. In Mode 1 that is the run's
|
|
@@ -412,9 +414,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
412
414
|
// and a call reaches it only through the session this spec returns, after `tools` is made. After the run's Workspace,
|
|
413
415
|
// as the pi spec makes it: a refusal lets the Workspace and the Archil claim go (holds above).
|
|
414
416
|
let filedIn;
|
|
415
|
-
const hold = (values) => { for (const redact of [
|
|
417
|
+
const hold = (values) => { for (const redact of [run.redact, cut])
|
|
416
418
|
redact.hold(values); };
|
|
417
|
-
const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
|
|
419
|
+
const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, say: (words) => run.phase?.(words), ...(facts.toolsFixedAtStart ? { toolsFixedAtStart: true } : {}), ...claimMetering(deps, web, launch) });
|
|
418
420
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
419
421
|
holds.hold({ passed: mcp });
|
|
420
422
|
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
@@ -436,9 +438,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
436
438
|
// A learning run's seed read as the pi spec reads it (runner/learning-seed.ts): its learned workflows, the ones
|
|
437
439
|
// learned_workflow runs.
|
|
438
440
|
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
439
|
-
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
440
441
|
const seedLaid = start && !seedFailed(start)
|
|
441
|
-
? await layLearningSeed({ seed: start.seed,
|
|
442
|
+
? await layLearningSeed({ seed: start.seed, store: deps.store, agentId: runRow.agentId, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
|
|
442
443
|
: undefined;
|
|
443
444
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
444
445
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
@@ -490,7 +491,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
490
491
|
holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
|
|
491
492
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
492
493
|
// The system prompt, as main's harness branch builds it: the environment line, the instructions with what the agent
|
|
493
|
-
// learned laid in (learning.ts laidLearned, from the launch's learning start, so the runner reads no learning
|
|
494
|
+
// learned laid in (learning.ts laidLearned, from the launch's learning start, so the runner reads no learning rows), its
|
|
494
495
|
// own skills through systemOf with the harness's own check (a harness that loads skills itself keeps in the prompt only
|
|
495
496
|
// those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
|
|
496
497
|
// pi spec gives it), then the effort guidance.
|
|
@@ -516,7 +517,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
516
517
|
const keyed = keyedAtClaim(runKey);
|
|
517
518
|
if (keyed)
|
|
518
519
|
withoutModelKeys(claimed);
|
|
519
|
-
for (const redact of [
|
|
520
|
+
for (const redact of [run.redact, cut]) {
|
|
520
521
|
holdClaimed(redact, claimed);
|
|
521
522
|
if (runKey)
|
|
522
523
|
holdRunKey(redact, runKey);
|
|
@@ -683,7 +684,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
683
684
|
const ctx = hostToolCtxOf(run, context, results, root);
|
|
684
685
|
// The runner's one redactor (the loop's), else this spec's log cut: the claim's keys join it, and the answers of the tools
|
|
685
686
|
// that run on them pass it.
|
|
686
|
-
const held = run.redact
|
|
687
|
+
const held = run.redact;
|
|
687
688
|
// The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
|
|
688
689
|
// its MCP tools in the loop's one catalog seam; their answers pass the redactors as the web tools' do.
|
|
689
690
|
const monid = monidForClaim(revisionRow.monidPin ?? undefined, { ...claimed }, () => ws.workspace, claim.runId, () => launch.maxCostUsd !== undefined, fakes?.monid);
|
|
@@ -713,7 +714,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
713
714
|
// The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
|
|
714
715
|
const admitAuxiliary = runnerSeam() ? undefined : sourceAuxiliaryAdmitter(deps.store, { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
715
716
|
// None for a held run, so its claim reads no saved key for spend beside it (claimSpendOff).
|
|
716
|
-
const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log,
|
|
717
|
+
const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, shown, sealKey: deps.sealKey, spendOff: await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey), admitAuxiliary } : undefined;
|
|
717
718
|
// A replay run's or a shadow's grader (runner/compare-end.ts), on a proxy of its own beside the CLI session's, as pi's
|
|
718
719
|
// is (adapter-run-spec.ts graderRouteOf), reached through the session's port while it is up. None: compared whole.
|
|
719
720
|
// None for a held run its model kept from running, whose model runs nowhere.
|
|
@@ -724,7 +725,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
724
725
|
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself. A held run its model kept from
|
|
725
726
|
// running takes none of them, as on pi: it settles no audit and starts no replay run, starts on no workflow, and its
|
|
726
727
|
// tool runs none (so no learned tier is routed, below).
|
|
727
|
-
const learned = audits ? await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log,
|
|
728
|
+
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, shown, spendOff: audits.spendOff, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: { reason: "held" }, workflows: [] };
|
|
728
729
|
const firstChoice = learned.choice;
|
|
729
730
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
730
731
|
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
@@ -801,14 +802,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
801
802
|
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
802
803
|
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
803
804
|
// The run's end-of-run step, when it learns, the same as the pi spec's: the compile turn and the owner's correction over
|
|
804
|
-
// the run's store, its
|
|
805
|
-
// claim's Archil disk — so the draft is checked against the seed in the run's own Workspace, never this machine's local path.
|
|
805
|
+
// the run's store, its draft checked against the seed in the agent's learning rows.
|
|
806
806
|
// A replay run or an audit's shadow run learns nothing at its end: it is the promotion's, never the agent's to learn
|
|
807
807
|
// from. With a grader it compares its answer with the other one (runner/compare-end.ts), on its own cap.
|
|
808
808
|
// A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
|
|
809
809
|
// withAudit): at its end, so the shadow's cap is what the run's own left.
|
|
810
810
|
// A held run (no audits) takes none, as on pi.
|
|
811
|
-
const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store,
|
|
811
|
+
const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, redact: run.redact }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
|
|
812
812
|
store: deps.store,
|
|
813
813
|
data: deps.data,
|
|
814
814
|
...(deps.env ? { env: deps.env } : {}),
|
|
@@ -821,10 +821,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
821
821
|
log,
|
|
822
822
|
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
823
823
|
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
824
|
-
|
|
825
|
-
? (agentId) => learningFolderOf(deps.data, agentId)
|
|
826
|
-
: (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
|
|
827
|
-
}), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
|
|
824
|
+
}), { ...audits, launch, redact: run.redact });
|
|
828
825
|
return {
|
|
829
826
|
adapter,
|
|
830
827
|
facts: factsOn(ownerFacts, chosen.model),
|
|
@@ -894,7 +891,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
894
891
|
const metrics = cliRunMetrics(piShaped(entries), booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}`, catalog: await hashedMcpOf(deps.store, claim.runId) });
|
|
895
892
|
// Its cost is endCost's, read apart (an unknown one written as null, never left out: a follow-up's end clears the
|
|
896
893
|
// cost an earlier end stored).
|
|
897
|
-
return { metrics: { ...metrics, ...(await runPathMetricsOverStore(deps.store, claim.runId, launch, {
|
|
894
|
+
return { metrics: { ...metrics, ...(await runPathMetricsOverStore(deps.store, claim.runId, launch, { redact: run.redact, choice: firstChoice.reason })), costBasis: costBasisOf(booked) } };
|
|
898
895
|
},
|
|
899
896
|
// A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
|
|
900
897
|
...(heldComputer ? { held: heldComputer } : {}),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { LearningFolder } from "../learn/folder.js";
|
|
2
1
|
import { type GraderReply } from "../learn/promote.js";
|
|
3
2
|
import type { PortModels } from "../port-models.js";
|
|
4
3
|
import type { RunLaunch } from "../run-launch.js";
|
|
@@ -9,9 +8,8 @@ import type { EndOfRunTurn } from "./loop-contract.js";
|
|
|
9
8
|
export declare const GRADER = "grader";
|
|
10
9
|
export type CompareEndDeps = {
|
|
11
10
|
readonly store: Store;
|
|
12
|
-
readonly folder: () => LearningFolder;
|
|
13
11
|
readonly log: (line: string) => void;
|
|
14
|
-
readonly redact
|
|
12
|
+
readonly redact: (text: string) => string;
|
|
15
13
|
};
|
|
16
14
|
/** The end-of-run step of a replay run or an audit's shadow (its callers pass no other run): its comparison (above),
|
|
17
15
|
* asked only when the run completed, was not cut, has a grader (its route exists only for a revision that names no
|
|
@@ -29,7 +29,11 @@ async function pairOf(launch, deps, runId) {
|
|
|
29
29
|
return workflow === null || agent === null ? null : { agent, workflow, graded };
|
|
30
30
|
}
|
|
31
31
|
if (launch.audit) {
|
|
32
|
-
|
|
32
|
+
// The shadow's agent's audit ledger: the shadow run is its agent's, as the served run it audits is.
|
|
33
|
+
const agentId = (await deps.store.runs.get(runId))?.agentId;
|
|
34
|
+
if (agentId === undefined)
|
|
35
|
+
return null;
|
|
36
|
+
const [agent, workflow] = [await answerOf(deps.store, runId, BACKGROUND_CONTEXT), await auditedAnswerOf({ store: deps.store, agentId, context: BACKGROUND_CONTEXT }, runId)];
|
|
33
37
|
return workflow === null || agent === null ? null : { agent, workflow };
|
|
34
38
|
}
|
|
35
39
|
return null;
|
|
@@ -37,7 +41,7 @@ async function pairOf(launch, deps, runId) {
|
|
|
37
41
|
/** Run `of`'s newest grade as the check judges it (comparedGrade), null when it has none. */
|
|
38
42
|
async function gradeOf(store, of) {
|
|
39
43
|
const source = await store.runs.get(of);
|
|
40
|
-
return comparedGrade(source ? (await gradesOf(store.
|
|
44
|
+
return comparedGrade(source ? (await gradesOf(store.learning, source.agentId)).findLast((one) => one.run === of) : undefined);
|
|
41
45
|
}
|
|
42
46
|
/** The end-of-run step of a replay run or an audit's shadow (its callers pass no other run): its comparison (above),
|
|
43
47
|
* asked only when the run completed, was not cut, has a grader (its route exists only for a revision that names no
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type KeyEnv } from "../key-meta.js";
|
|
2
2
|
import type { Settings } from "../store/store.js";
|
|
3
3
|
/** The file in the server's data root that holds its id (made once, kept across starts). */
|
|
4
4
|
export declare const DATA_ROOT_FILE = "data-root.id";
|
|
@@ -19,7 +19,8 @@ export declare function sharesServerDisk(store: {
|
|
|
19
19
|
}, dataDir: string): Promise<boolean | undefined>;
|
|
20
20
|
/** Whether the server is in Mode 2, by what the server holds, never by this runner's environment: the Archil settings
|
|
21
21
|
* saved in the store, or set in the server's own environment, whose names (never values) it says at each start
|
|
22
|
-
* (runner-check.ts RUN_ENV_KEY).
|
|
22
|
+
* (runner-check.ts RUN_ENV_KEY). The region is the one name a server in Mode 2 by its environment always has: its S3
|
|
23
|
+
* URL is the region's when it sets none, and a server whose settings there are not whole does not start. */
|
|
23
24
|
export declare function serverInArchilMode(store: {
|
|
24
25
|
settings: Pick<Settings, "get">;
|
|
25
26
|
}): Promise<boolean>;
|
|
@@ -35,10 +36,20 @@ export declare function diskFreeRefusal(store: {
|
|
|
35
36
|
export declare const DISK_FREE_MODE_1 = "this runner's data directory is not the server's, and the server keeps each run's folder on its own disk (Mode 1: the server holds no Archil settings, saved or in its environment), which this runner can't reach. Save the Archil settings so runs' folders are on Archil (Mode 2), or start the runner on the server's data directory.";
|
|
36
37
|
/** A disk-free runner's words while the server is in Mode 2 by its own environment and this runner holds no Archil settings. */
|
|
37
38
|
export declare const DISK_FREE_NO_ARCHIL: string;
|
|
39
|
+
/** Why a runner given a region without an S3 URL can't claim now, or undefined while it can. Such a runner reaches Archil
|
|
40
|
+
* at the region's S3 URL (archil-settings.ts ARCHIL_S3_URLS), and the server's may be another: the server is started with
|
|
41
|
+
* AGENTRUN_ARCHIL_S3_URL (its run-facing names say so, never the value, so one that is the region's own is refused too),
|
|
42
|
+
* or it is in Mode 2 by saved settings whose s3Url is not the runner's. Any runner, on the server's disk or not, on either
|
|
43
|
+
* store: a run's folder on Archil is reached by the runner and the server at one endpoint, or not claimed. */
|
|
44
|
+
export declare function archilS3Refusal(store: {
|
|
45
|
+
settings: Pick<Settings, "get">;
|
|
46
|
+
}, env: KeyEnv): Promise<string | undefined>;
|
|
47
|
+
/** A runner's words while it is given a region without an S3 URL and the server's S3 URL may be another (archilS3Refusal). */
|
|
48
|
+
export declare const ARCHIL_S3_URL_NOT_HELD: string;
|
|
38
49
|
/** How long a gate's answer is kept between polls (diskFreeGate): a change of mode reaches a runner within this. */
|
|
39
50
|
export declare const DISK_FREE_GATE_MS = 5000;
|
|
40
|
-
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: diskFreeRefusal, its
|
|
41
|
-
* DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
51
|
+
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: archilS3Refusal, else diskFreeRefusal, its
|
|
52
|
+
* answer kept for DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
42
53
|
export declare function diskFreeGate(store: {
|
|
43
54
|
settings: Pick<Settings, "get">;
|
|
44
55
|
}, dataDir: string, env: KeyEnv, storeKind: string, now?: () => number): (fresh: boolean) => Promise<string | undefined>;
|
package/dist/runner/disk-free.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
13
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
14
14
|
import { join } from "node:path";
|
|
15
|
-
import { ARCHIL_SETTINGS_ENV, loadArchilSettings } from "../archil-settings.js";
|
|
15
|
+
import { ARCHIL_SETTINGS_ENV, archilSettingsFromEnv, loadArchilSettings } from "../archil-settings.js";
|
|
16
|
+
import { envValue } from "../key-meta.js";
|
|
16
17
|
import { serverRunEnv } from "./runner-check.js";
|
|
17
18
|
/** The file in the server's data root that holds its id (made once, kept across starts). */
|
|
18
19
|
export const DATA_ROOT_FILE = "data-root.id";
|
|
@@ -52,12 +53,13 @@ export async function sharesServerDisk(store, dataDir) {
|
|
|
52
53
|
}
|
|
53
54
|
/** Whether the server is in Mode 2, by what the server holds, never by this runner's environment: the Archil settings
|
|
54
55
|
* saved in the store, or set in the server's own environment, whose names (never values) it says at each start
|
|
55
|
-
* (runner-check.ts RUN_ENV_KEY).
|
|
56
|
+
* (runner-check.ts RUN_ENV_KEY). The region is the one name a server in Mode 2 by its environment always has: its S3
|
|
57
|
+
* URL is the region's when it sets none, and a server whose settings there are not whole does not start. */
|
|
56
58
|
export async function serverInArchilMode(store) {
|
|
57
59
|
if ((await loadArchilSettings(store)) !== undefined)
|
|
58
60
|
return true;
|
|
59
61
|
const names = await serverRunEnv(store);
|
|
60
|
-
return names !== undefined &&
|
|
62
|
+
return names !== undefined && names.includes(ARCHIL_SETTINGS_ENV.region);
|
|
61
63
|
}
|
|
62
64
|
/** Why a runner on `dataDir` can't serve the runs its store holds now, or undefined while it can. On Postgres, a runner
|
|
63
65
|
* whose `dataDir` is not the server's disk can't while the server keeps runs' folders on that disk (Mode 1: the server
|
|
@@ -78,18 +80,34 @@ export async function diskFreeRefusal(store, dataDir, env, storeKind) {
|
|
|
78
80
|
/** A disk-free runner's words while the server is in Mode 1: what the runner can't do, why, and the two ways out. */
|
|
79
81
|
export const DISK_FREE_MODE_1 = "this runner's data directory is not the server's, and the server keeps each run's folder on its own disk (Mode 1: the server holds no Archil settings, saved or in its environment), which this runner can't reach. Save the Archil settings so runs' folders are on Archil (Mode 2), or start the runner on the server's data directory.";
|
|
80
82
|
/** A disk-free runner's words while the server is in Mode 2 by its own environment and this runner holds no Archil settings. */
|
|
81
|
-
export const DISK_FREE_NO_ARCHIL = `this runner's data directory is not the server's, and the server keeps each run's folder on Archil (Mode 2) by the Archil settings in its environment, which this runner does not hold. Hand this runner the server's ${ARCHIL_SETTINGS_ENV.region} and ${ARCHIL_SETTINGS_ENV.s3Url}
|
|
83
|
+
export const DISK_FREE_NO_ARCHIL = `this runner's data directory is not the server's, and the server keeps each run's folder on Archil (Mode 2) by the Archil settings in its environment, which this runner does not hold. Hand this runner the server's ${ARCHIL_SETTINGS_ENV.region} (and ${ARCHIL_SETTINGS_ENV.s3Url} and ${ARCHIL_SETTINGS_ENV.image} when the server has them), or save the Archil settings in the store.`;
|
|
84
|
+
/** Why a runner given a region without an S3 URL can't claim now, or undefined while it can. Such a runner reaches Archil
|
|
85
|
+
* at the region's S3 URL (archil-settings.ts ARCHIL_S3_URLS), and the server's may be another: the server is started with
|
|
86
|
+
* AGENTRUN_ARCHIL_S3_URL (its run-facing names say so, never the value, so one that is the region's own is refused too),
|
|
87
|
+
* or it is in Mode 2 by saved settings whose s3Url is not the runner's. Any runner, on the server's disk or not, on either
|
|
88
|
+
* store: a run's folder on Archil is reached by the runner and the server at one endpoint, or not claimed. */
|
|
89
|
+
export async function archilS3Refusal(store, env) {
|
|
90
|
+
if (envValue(env, ARCHIL_SETTINGS_ENV.region) === undefined || envValue(env, ARCHIL_SETTINGS_ENV.s3Url) !== undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
const names = await serverRunEnv(store);
|
|
93
|
+
if (names?.includes(ARCHIL_SETTINGS_ENV.region))
|
|
94
|
+
return names.includes(ARCHIL_SETTINGS_ENV.s3Url) ? ARCHIL_S3_URL_NOT_HELD : undefined;
|
|
95
|
+
const saved = await loadArchilSettings(store);
|
|
96
|
+
return saved !== undefined && saved.s3Url !== archilSettingsFromEnv(env)?.s3Url ? ARCHIL_S3_URL_NOT_HELD : undefined;
|
|
97
|
+
}
|
|
98
|
+
/** A runner's words while it is given a region without an S3 URL and the server's S3 URL may be another (archilS3Refusal). */
|
|
99
|
+
export const ARCHIL_S3_URL_NOT_HELD = `this runner is given ${ARCHIL_SETTINGS_ENV.region} without ${ARCHIL_SETTINGS_ENV.s3Url}, so it would reach Archil at its region's S3 URL, and the server's may be another (the server is started with ${ARCHIL_SETTINGS_ENV.s3Url}, or its saved Archil settings hold another s3Url): a run's folder is reached at the server's or not at all. Hand this runner the server's S3 URL as ${ARCHIL_SETTINGS_ENV.s3Url}.`;
|
|
82
100
|
/** How long a gate's answer is kept between polls (diskFreeGate): a change of mode reaches a runner within this. */
|
|
83
101
|
export const DISK_FREE_GATE_MS = 5_000;
|
|
84
|
-
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: diskFreeRefusal, its
|
|
85
|
-
* DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
102
|
+
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: archilS3Refusal, else diskFreeRefusal, its
|
|
103
|
+
* answer kept for DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
86
104
|
export function diskFreeGate(store, dataDir, env, storeKind, now = Date.now) {
|
|
87
105
|
let kept;
|
|
88
106
|
return async (fresh) => {
|
|
89
107
|
const at = now();
|
|
90
108
|
if (!fresh && kept && at - kept.at < DISK_FREE_GATE_MS)
|
|
91
109
|
return kept.words;
|
|
92
|
-
const words = await diskFreeRefusal(store, dataDir, env, storeKind);
|
|
110
|
+
const words = (await archilS3Refusal(store, env)) ?? (await diskFreeRefusal(store, dataDir, env, storeKind));
|
|
93
111
|
kept = { at, words };
|
|
94
112
|
return words;
|
|
95
113
|
};
|
package/dist/runner/dispatch.js
CHANGED
|
@@ -85,7 +85,7 @@ function dispatchLoop(deps, loopDeps) {
|
|
|
85
85
|
if (earlyStop) {
|
|
86
86
|
inner.stop(earlyStop).catch((error) => {
|
|
87
87
|
const text = error?.message ?? String(error);
|
|
88
|
-
console.warn(`[runner] run ${claim.runId}: its stop failed: ${loopDeps.redact
|
|
88
|
+
console.warn(`[runner] run ${claim.runId}: its stop failed: ${loopDeps.redact(text)}`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
return end;
|
|
@@ -110,7 +110,7 @@ function dispatchLoop(deps, loopDeps) {
|
|
|
110
110
|
// What went wrong, cut of the values the run holds (LoopDeps.redact), as the log may not show them.
|
|
111
111
|
const why = () => {
|
|
112
112
|
const text = lastError?.message ?? String(lastError);
|
|
113
|
-
return loopDeps.redact
|
|
113
|
+
return loopDeps.redact(text);
|
|
114
114
|
};
|
|
115
115
|
const failed = [];
|
|
116
116
|
try {
|
|
@@ -93,4 +93,4 @@ export declare function openFeedbackRound(store: Pick<Store, "runs" | "agents">,
|
|
|
93
93
|
* round it asks for (openFeedbackRound), and only then marks the kept grade with that round and its steer. The grade is
|
|
94
94
|
* kept first, so the round's end reads it; the round is named last, so a reopen that fails (thrown, or a run that can't
|
|
95
95
|
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
96
|
-
export declare function keepGrade(store: Pick<Store, "runs" | "agents" | "
|
|
96
|
+
export declare function keepGrade(store: Pick<Store, "runs" | "agents" | "learning">, agentId: string, grade: Grade, label: string | undefined, canTurn?: (launch: RunLaunch) => boolean): Promise<Grade>;
|
|
@@ -144,7 +144,7 @@ export async function openFeedbackRound(store, grade, label, canTurn = () => tru
|
|
|
144
144
|
* kept first, so the round's end reads it; the round is named last, so a reopen that fails (thrown, or a run that can't
|
|
145
145
|
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
146
146
|
export async function keepGrade(store, agentId, grade, label, canTurn) {
|
|
147
|
-
const kept = await putGrade(store.
|
|
147
|
+
const kept = await putGrade(store.learning, agentId, { ...grade, feedback: null });
|
|
148
148
|
const opened = await openFeedbackRound(store, kept, label, canTurn);
|
|
149
|
-
return opened ? markGradeRound(store.
|
|
149
|
+
return opened ? markGradeRound(store.learning, agentId, kept, opened) : kept;
|
|
150
150
|
}
|
|
@@ -3,6 +3,7 @@ import type { SealedKeys, Settings } from "../store/index.js";
|
|
|
3
3
|
import { type RunLaunch } from "../run-launch.js";
|
|
4
4
|
import { type AdapterSpecDeps } from "./adapter-run-spec.js";
|
|
5
5
|
import { ClaimRefused, type LoopFactory } from "./loop-contract.js";
|
|
6
|
+
import type { Revision } from "../agent-rows.js";
|
|
6
7
|
/** A claimed run whose harness this host's memory never holds: its message is the host's words (neverFits). A claim
|
|
7
8
|
* refused for good, so a parked run it wakes fails too, never retried as a resume (runner.ts finish). */
|
|
8
9
|
export declare class NeverFits extends ClaimRefused {
|
|
@@ -29,6 +30,14 @@ export declare function refuseRecipeTriggerRun(deps: {
|
|
|
29
30
|
export declare function resolveRunnerLoop(given: AdapterSpecDeps, options?: {
|
|
30
31
|
readonly keysCounted?: boolean;
|
|
31
32
|
}): (harness: string, launch: RunLaunch, runId: string) => Promise<LoopFactory | undefined>;
|
|
33
|
+
/** `launch` as this claim runs it: its plane, resolved at the run's start, under the server's tool settings now
|
|
34
|
+
* (tool-plane.ts claimPlane), so a resume, a follow-up or a reclaim after the server set web_fetch to kernel, or
|
|
35
|
+
* web_search to native or off, sends nothing past that setting, whatever its agent picked. Settings that could not be
|
|
36
|
+
* read fail closed: a capability kept on a keyless third party or on Parallel runs nothing (SETTINGS_NOT_READ), and
|
|
37
|
+
* the gate refuses every tool besides (storeSettings). It resolves on the run's pinned model (the launch's, chosen at
|
|
38
|
+
* its start), never the host's default in this environment, which holds no key saved on the server (claim-secrets.ts
|
|
39
|
+
* opens those later), and with the saved keys' names (savedNamesOver) for the route its model requests take. */
|
|
40
|
+
export declare function underServerCeilings(deps: AdapterSpecDeps, launch: RunLaunch, revision: Revision): Promise<RunLaunch>;
|
|
32
41
|
/** The loop factory the runner holds for every run (its createLoop), built from the runner's deps over the one store: the
|
|
33
42
|
* dispatch (dispatch.ts) reads each run's launch and asks resolveRunnerLoop for its harness loop. The server
|
|
34
43
|
* start and the test server pass this to startRunner. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { envGatewayInForce, readSavedGateway, savedGatewayIn, savedGatewayMarked, SAVED_GATEWAY_ENV, withSavedGateway } from "../model-gateway.js";
|
|
2
2
|
import { GATEWAY_KEY_ENV } from "../model.js";
|
|
3
|
-
import {
|
|
3
|
+
import { mustHold } from "./redact.js";
|
|
4
4
|
import { envValue } from "../key-meta.js";
|
|
5
5
|
import { createSdkLoop } from "./sdk-loop.js";
|
|
6
6
|
import { createNativeLoop } from "./native-loop.js";
|
|
@@ -29,6 +29,11 @@ import { askRouteOf } from "./sdk-ask.js";
|
|
|
29
29
|
import { ClaimRefused } from "./loop-contract.js";
|
|
30
30
|
import { createWorkflowLoop, isWorkflowRevision } from "./workflow-loop.js";
|
|
31
31
|
import { workflowSpecOf } from "./workflow-spec.js";
|
|
32
|
+
import { storeSettings } from "./adapter-run-spec.js";
|
|
33
|
+
import { claimPlane, overCeilings } from "../tool-plane.js";
|
|
34
|
+
import { SECRET_NAMES } from "../secrets.js";
|
|
35
|
+
import { sealedKeyNames } from "../server-keys.js";
|
|
36
|
+
import { toolingOf } from "../tools.js";
|
|
32
37
|
/** A claimed run whose harness this host's memory never holds: its message is the host's words (neverFits). A claim
|
|
33
38
|
* refused for good, so a parked run it wakes fails too, never retried as a resume (runner.ts finish). */
|
|
34
39
|
export class NeverFits extends ClaimRefused {
|
|
@@ -73,23 +78,61 @@ function holdingGatewayKey(made, env) {
|
|
|
73
78
|
if (!key)
|
|
74
79
|
return made;
|
|
75
80
|
return (loopDeps) => {
|
|
76
|
-
|
|
77
|
-
heldRedactor(loopDeps.redact).hold([key]);
|
|
81
|
+
mustHold(loopDeps.redact, "A loop over the saved gateway").hold([key]);
|
|
78
82
|
return made(loopDeps);
|
|
79
83
|
};
|
|
80
84
|
}
|
|
85
|
+
/** `launch` as this claim runs it: its plane, resolved at the run's start, under the server's tool settings now
|
|
86
|
+
* (tool-plane.ts claimPlane), so a resume, a follow-up or a reclaim after the server set web_fetch to kernel, or
|
|
87
|
+
* web_search to native or off, sends nothing past that setting, whatever its agent picked. Settings that could not be
|
|
88
|
+
* read fail closed: a capability kept on a keyless third party or on Parallel runs nothing (SETTINGS_NOT_READ), and
|
|
89
|
+
* the gate refuses every tool besides (storeSettings). It resolves on the run's pinned model (the launch's, chosen at
|
|
90
|
+
* its start), never the host's default in this environment, which holds no key saved on the server (claim-secrets.ts
|
|
91
|
+
* opens those later), and with the saved keys' names (savedNamesOver) for the route its model requests take. */
|
|
92
|
+
export async function underServerCeilings(deps, launch, revision) {
|
|
93
|
+
if (!launch.plane)
|
|
94
|
+
return launch;
|
|
95
|
+
const { settings, unreadable } = await storeSettings(deps.store);
|
|
96
|
+
const unread = unreadable === true;
|
|
97
|
+
const tooling = await toolingOf(revision);
|
|
98
|
+
if (!overCeilings(launch.plane, tooling, settings, { unread }))
|
|
99
|
+
return launch;
|
|
100
|
+
const model = launch.model ? `${launch.model.provider}/${launch.model.modelId}` : undefined;
|
|
101
|
+
const plane = claimPlane(launch.plane, unread ? deps.env ?? process.env : await savedNamesOver(deps), tooling, settings, { capped: launch.maxCostUsd !== undefined, unread, ...(model ? { model } : {}) });
|
|
102
|
+
return { ...launch, plane };
|
|
103
|
+
}
|
|
104
|
+
/** `deps.env` where a key saved on the server, not set in it, is present by name: its row read, never opened (its value
|
|
105
|
+
* a stand-in only a resolution's presence checks read), for a plane resolved in it alone, never handed on. A runner
|
|
106
|
+
* holds the seal key and reads the store's rows; a run's own process (no seal key) was handed its claim's keys, which
|
|
107
|
+
* its environment already holds. */
|
|
108
|
+
async function savedNamesOver(deps) {
|
|
109
|
+
const env = deps.env ?? process.env;
|
|
110
|
+
if (!deps.sealKey)
|
|
111
|
+
return env;
|
|
112
|
+
const names = (await sealedKeyNames(deps.store)).filter((name) => SECRET_NAMES.includes(name) && !env[name]);
|
|
113
|
+
if (!names.length)
|
|
114
|
+
return env;
|
|
115
|
+
// Over `env` (its prototype), so its own secrets and marks (non-enumerable, or symbols) still read.
|
|
116
|
+
const out = Object.create(env);
|
|
117
|
+
for (const name of names)
|
|
118
|
+
Object.defineProperty(out, name, { value: "saved", enumerable: false });
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
81
121
|
/** The loop a claimed run runs on, over `deps` (the saved gateway laid over its environment). */
|
|
82
122
|
async function loopOn(deps, harness, launch, runId) {
|
|
83
123
|
// A workflow revision runs on the workflow loop whatever the harness its body names (its default is pi): read the
|
|
84
124
|
// revision to tell it apart from an agentic pi run.
|
|
85
125
|
const run = await deps.store.runs.get(runId);
|
|
86
126
|
const revision = run ? await deps.store.agents.revision(run.revisionId) : undefined;
|
|
127
|
+
// The plane this claim hands every reader (the secrets, the tools, the run's process), read once here, before any binds.
|
|
128
|
+
if (revision)
|
|
129
|
+
launch = await underServerCeilings(deps, launch, revision);
|
|
87
130
|
if (revision && isWorkflowRevision(revision)) {
|
|
88
131
|
// A workflow run on the workflow loop: its claim-time spec (workflow-spec.ts) resolves each tier's model the one way
|
|
89
132
|
// the runner resolves any (routeProviderOf over the route, the default when no providerOf is given).
|
|
90
133
|
// The runner's seal key and data directory go with it: a claim's sealed secrets are read with them (claim-secrets.ts,
|
|
91
134
|
// store-secrets.ts), and every one the server keeps is held by the run's one redactor.
|
|
92
|
-
return createWorkflowLoop(workflowSpecOf({ store: deps.store, sealKey: deps.sealKey, data: deps.data, ...(deps.env ? { env: deps.env } : {}) }));
|
|
135
|
+
return createWorkflowLoop(workflowSpecOf({ store: deps.store, sealKey: deps.sealKey, data: deps.data, ...(deps.env ? { env: deps.env } : {}), ...(launch.plane ? { plane: launch.plane } : {}) }));
|
|
93
136
|
}
|
|
94
137
|
// A backend SDK run's compile turn is asked on the runner's one model route, on the agent's own model (its learning
|
|
95
138
|
// start's), its key from the runner's environment, else the one saved in Settings → Model keys, read at each ask.
|
|
@@ -129,9 +172,8 @@ async function loopOn(deps, harness, launch, runId) {
|
|
|
129
172
|
throw new NeverFits(tooBig);
|
|
130
173
|
const entry = harnessOf(env, harness);
|
|
131
174
|
// A run that learns supplies its own end-of-run step (reflect + proposal over its store) from its spec builder now,
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
// not learn supplies none. The same for the pi and the CLI spec.
|
|
175
|
+
// (adapter-run-spec.ts / cli-run-spec.ts endOfRun). The spec is the loop's only source of a step; a run that
|
|
176
|
+
// does not learn supplies none. The same for the pi and the CLI spec.
|
|
135
177
|
return createAdapterLoop((claim, adapterRun) => entry?.facts && entry.adapter
|
|
136
178
|
? cliRunSpecFromLaunch(launch, adapterRun, deps, claim)
|
|
137
179
|
: adapterRunSpecFromLaunch(launch, adapterRun, deps, claim, runner), { ...deps.modelRetry, ...(deps.tracing ? { tracing: deps.tracing } : {}) });
|
package/dist/runner/held.d.ts
CHANGED
|
@@ -34,7 +34,10 @@ export interface HeldMcpTool {
|
|
|
34
34
|
/** The claim's MCP as the runner holds it: its tools, and its credentials' refresh and release. */
|
|
35
35
|
export interface HeldMcp {
|
|
36
36
|
readonly tools: readonly HeldMcpTool[];
|
|
37
|
-
|
|
37
|
+
/** The servers left out of `tools` for want of the run's credential (mcp-run.ts ClaimMcp.unconnected). */
|
|
38
|
+
readonly unconnected?: readonly string[];
|
|
39
|
+
/** ClaimMcp.fresh: the servers still handed no credential. */
|
|
40
|
+
fresh(): Promise<readonly string[]>;
|
|
38
41
|
release(): Promise<void>;
|
|
39
42
|
}
|
|
40
43
|
/** What the run's process gives mcpForClaim on the runner: its grants and harness are its revision's, which the runner
|
|
@@ -133,9 +136,6 @@ export interface Held {
|
|
|
133
136
|
emailAccount(): Promise<OpenedAccount | undefined>;
|
|
134
137
|
/** The server's calendar, opened, for a run whose revision grants calendar_events; else none. */
|
|
135
138
|
calendar(): Promise<SavedCalendar | undefined>;
|
|
136
|
-
/** A call of the run's agent's learning folder (learn/folder.ts), the runner's own Workspace of it, held to what a
|
|
137
|
-
* run's learning does there (run-child-host.ts learningCall). */
|
|
138
|
-
learning(method: string, args: readonly unknown[]): Promise<unknown>;
|
|
139
139
|
/** The harness `name`'s install for the claim (harness-install.ts installForClaim), run by the runner. */
|
|
140
140
|
install(name: string, signal?: AbortSignal): Promise<void>;
|
|
141
141
|
/** The claim's computer (workspace/computer-for-claim.ts), made and held by the runner. */
|
|
@@ -185,13 +185,6 @@ export declare function heldSignInReads(): {
|
|
|
185
185
|
peek(agentId: string, resolution: string): Promise<never>;
|
|
186
186
|
forgotten(agentId: string, resolution: string): Promise<never>;
|
|
187
187
|
};
|
|
188
|
-
/** The agent's learning folder in a run's own process (learn/folder.ts learningWorkspace): each call made by its runner on
|
|
189
|
-
* the folder of the claim's agent (Held.learning), whatever place this process names. No background program, mount or
|
|
190
|
-
* attach: a learning folder has none. */
|
|
191
|
-
export declare function heldLearningFolder(): {
|
|
192
|
-
readonly workspace: Workspace;
|
|
193
|
-
end(): Promise<void>;
|
|
194
|
-
};
|
|
195
188
|
/** A learning run's end-of-run step in a run's own process (learning-end.ts learningEndOfRun): its runner's
|
|
196
189
|
* (Held.endOfRun), whatever deps the process would have built it with. */
|
|
197
190
|
export declare function heldEndOfRun(): EndOfRunTurn;
|
package/dist/runner/held.js
CHANGED
|
@@ -22,31 +22,6 @@ export function heldSignInReads() {
|
|
|
22
22
|
forgotten: (_agentId, resolution) => at.signInForgotten(resolution),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
/** The agent's learning folder in a run's own process (learn/folder.ts learningWorkspace): each call made by its runner on
|
|
26
|
-
* the folder of the claim's agent (Held.learning), whatever place this process names. No background program, mount or
|
|
27
|
-
* attach: a learning folder has none. */
|
|
28
|
-
export function heldLearningFolder() {
|
|
29
|
-
const at = heldOrThrow("a run's learning folder");
|
|
30
|
-
const call = (method) => (...args) => at.learning(method, args);
|
|
31
|
-
const none = (what) => async () => {
|
|
32
|
-
throw new Error(`a learning folder has no ${what} in a run's own process`);
|
|
33
|
-
};
|
|
34
|
-
const workspace = {
|
|
35
|
-
read: call("read"),
|
|
36
|
-
write: call("write"),
|
|
37
|
-
append: call("append"),
|
|
38
|
-
stat: call("stat"),
|
|
39
|
-
list: call("list"),
|
|
40
|
-
mkdir: call("mkdir"),
|
|
41
|
-
grep: call("grep"),
|
|
42
|
-
remove: call("remove"),
|
|
43
|
-
exec: call("exec"),
|
|
44
|
-
process: { start: none("background program"), list: none("background program"), output: none("background program"), signal: none("background program"), wait: none("background program") },
|
|
45
|
-
mountSpec: none("mount"),
|
|
46
|
-
attach: none("attach"),
|
|
47
|
-
};
|
|
48
|
-
return { workspace, end: async () => { } };
|
|
49
|
-
}
|
|
50
25
|
/** A learning run's end-of-run step in a run's own process (learning-end.ts learningEndOfRun): its runner's
|
|
51
26
|
* (Held.endOfRun), whatever deps the process would have built it with. */
|
|
52
27
|
export function heldEndOfRun() {
|
|
@@ -110,7 +110,7 @@ export declare const KINDS: {
|
|
|
110
110
|
readonly learningMerged: "agentrun.learning.merged";
|
|
111
111
|
/** Why a learning run merged nothing, with the run's end. */
|
|
112
112
|
readonly learningDropped: "agentrun.learning.dropped";
|
|
113
|
-
/** The learning
|
|
113
|
+
/** The learning could not be reached: the run parks and tries again after a backoff. */
|
|
114
114
|
readonly learningUnavailable: "agentrun.learning.unavailable";
|
|
115
115
|
/** A browser hand-over (pi-browser's browser_request_handoff), on the root. The run's browser host commits the ask, the
|
|
116
116
|
* whole of it (HandoverAsked); its answer is an entry too (HandoverAnswered): the person's (a browser_hand_back row
|
|
@@ -191,6 +191,9 @@ export interface CallStartData {
|
|
|
191
191
|
readonly parentCallId?: string;
|
|
192
192
|
readonly tool: string;
|
|
193
193
|
readonly input: unknown;
|
|
194
|
+
/** An SDK learned_workflow start whose input is stored withheld: the workflow it names, one the run was given, as the
|
|
195
|
+
* server kept it apart from the input (sdk/runs.ts SdkInbox.workflow_calls). Never the caller's text otherwise. */
|
|
196
|
+
readonly workflow?: string;
|
|
194
197
|
/** May run again after a crash (it changes nothing outside the run): the tool registry's own flag. */
|
|
195
198
|
readonly replaySafe: boolean;
|
|
196
199
|
/** Written as its CLI's tool bridge's gate asked about it (adapter-loop.ts bridgeGate), before any answer: nothing is sent
|
|
@@ -110,7 +110,7 @@ export const KINDS = {
|
|
|
110
110
|
learningMerged: "agentrun.learning.merged",
|
|
111
111
|
/** Why a learning run merged nothing, with the run's end. */
|
|
112
112
|
learningDropped: "agentrun.learning.dropped",
|
|
113
|
-
/** The learning
|
|
113
|
+
/** The learning could not be reached: the run parks and tries again after a backoff. */
|
|
114
114
|
learningUnavailable: "agentrun.learning.unavailable",
|
|
115
115
|
/** A browser hand-over (pi-browser's browser_request_handoff), on the root. The run's browser host commits the ask, the
|
|
116
116
|
* whole of it (HandoverAsked); its answer is an entry too (HandoverAnswered): the person's (a browser_hand_back row
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { LearnedWorkflow, Shown } from "../learning.js";
|
|
3
|
-
import type { LearningFolder } from "../learn/folder.js";
|
|
4
3
|
import type { Recorded } from "../learn/replay-calls.js";
|
|
5
4
|
import type { RunLaunch } from "../run-launch.js";
|
|
6
5
|
import type { Store } from "../store/store.js";
|
|
@@ -20,7 +19,6 @@ export interface LearnedFirstDeps {
|
|
|
20
19
|
readonly launch: RunLaunch;
|
|
21
20
|
readonly context: Context;
|
|
22
21
|
readonly log: (line: string) => void;
|
|
23
|
-
readonly folder: () => LearningFolder;
|
|
24
22
|
readonly shown: () => Promise<Shown>;
|
|
25
23
|
readonly spendOff?: (what: string) => string | undefined;
|
|
26
24
|
}
|
|
@@ -7,13 +7,13 @@ import { toolStopsOf, workflowFirstOf } from "./workflow-first.js";
|
|
|
7
7
|
/** The claim's learned first choice over `laid`, the workflows its seed lay laid (see the file's head). A replay run's
|
|
8
8
|
* claim that is refused throws ClaimRefused, as replayClaimed does. */
|
|
9
9
|
export async function learnedFirst(deps, laid) {
|
|
10
|
-
const { store, agentId, runId, revisionId, launch, context, log,
|
|
10
|
+
const { store, agentId, runId, revisionId, launch, context, log, shown } = deps;
|
|
11
11
|
const own = { ...(deps.sealKey ? { sealKey: deps.sealKey } : {}), ...(deps.spendOff ? { spendOff: deps.spendOff } : {}), ...(deps.admitAuxiliary ? { admitAuxiliary: deps.admitAuxiliary } : {}) };
|
|
12
12
|
// A replay run lays only the workflow it replays (promotion.ts replayLaid).
|
|
13
13
|
const laidFlows = replayLaid(launch, laid);
|
|
14
14
|
if (launch.learning && !launch.replay && !launch.audit)
|
|
15
|
-
await settleAudits({ store, agentId, revisionId, context, log,
|
|
16
|
-
const promotion = claimPromotion({ store, agentId, runId, revisionId, launch, context, log,
|
|
15
|
+
await settleAudits({ store, agentId, revisionId, context, log, shown, ...own });
|
|
16
|
+
const promotion = claimPromotion({ store, agentId, runId, revisionId, launch, context, log, shown, ...own });
|
|
17
17
|
const learns = learnsWorkflows(deps.kind, laidFlows);
|
|
18
18
|
// The agent's past runs, read once for both sides of the money rule: the platform's first choice and the agent's tool.
|
|
19
19
|
let read;
|