@parcha/agentrun-serve 0.1.0-beta.52 → 0.1.0-beta.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +122 -1
- package/README.md +213 -24
- package/dist/agent-delete.d.ts +5 -6
- package/dist/agent-delete.js +30 -67
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agents-store.d.ts +26 -20
- package/dist/agents-store.js +41 -33
- package/dist/api-only.d.ts +26 -6
- package/dist/api-only.js +35 -13
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +70 -7
- package/dist/composio-preset.d.ts +2 -1
- package/dist/composio-preset.js +4 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +8 -1
- package/dist/console/assets/index-BFgyZzF_.js +734 -0
- package/dist/console/assets/index-DbilxljH.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +3 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.js +10 -13
- package/dist/handed-secret.d.ts +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +14 -1
- package/dist/learn/commit.js +156 -1
- package/dist/learn/compile.js +22 -8
- package/dist/learn/folder.d.ts +5 -0
- package/dist/learn/folder.js +10 -1
- package/dist/learn/learning.sh +15 -3
- package/dist/learn/promote.d.ts +2 -2
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning.d.ts +9 -6
- package/dist/learning.js +9 -4
- package/dist/mcp-gateway.js +15 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +7 -2
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +16 -12
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +167 -36
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +16 -1
- package/dist/run-launch.js +30 -1
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-view.d.ts +17 -0
- package/dist/run-view.js +25 -1
- package/dist/runner/adapter-loop.d.ts +11 -3
- package/dist/runner/adapter-loop.js +138 -22
- package/dist/runner/adapter-run-spec.js +25 -12
- package/dist/runner/audit.d.ts +2 -0
- package/dist/runner/audit.js +9 -1
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +29 -3
- package/dist/runner/claim-secrets.js +38 -4
- package/dist/runner/cli-run-spec.js +23 -12
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +11 -1
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +2 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +7 -2
- package/dist/runner/learning-end.js +22 -10
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +6 -1
- package/dist/runner/mcp-run.d.ts +10 -7
- package/dist/runner/mcp-run.js +3 -5
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +14 -6
- package/dist/runner/promotion.js +98 -41
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +171 -41
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.js +5 -2
- package/dist/runner/runner.js +26 -9
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.d.ts +34 -6
- package/dist/runs-over-store.js +133 -25
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +117 -26
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +68 -32
- package/dist/server.js +600 -110
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +4 -0
- package/dist/store/agent-body.js +16 -5
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +2 -1
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +4 -12
- package/dist/store/sqlite/run-launch.js +5 -19
- package/dist/store/sqlite/store.js +224 -170
- package/dist/store/store.d.ts +116 -39
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +2 -2
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- package/dist/template-import.d.ts +10 -2
- package/dist/template-import.js +116 -13
- package/dist/templates.d.ts +26 -5
- package/dist/templates.js +62 -10
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/trigger-launch-hook.d.ts +47 -0
- package/dist/trigger-launch-hook.js +90 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +1 -1
- package/dist/uploads.js +1 -1
- package/dist/validate.js +1 -2
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +5 -2
- package/dist/console/assets/index-B-D0EM3j.js +0 -733
- package/dist/console/assets/index-DlQepP2J.css +0 -1
package/dist/runner/promotion.js
CHANGED
|
@@ -1,8 +1,53 @@
|
|
|
1
|
+
// Promotion, at a run's claim (champion/challenger, shadow deployment): the learned workflow that fits the run's input
|
|
2
|
+
// serves first only when its digest is promoted (learn/promote.ts). Promote once: a digest with no record yet, the learning
|
|
3
|
+
// folder's newest revision, is checked once (startCheck): a replay run of it (RunLaunch.replay, at workflow cost) on the
|
|
4
|
+
// input of each of the agent's last compile_after completed runs of its own (its definition's `learning`,
|
|
5
|
+
// learning-setting.ts), the agent taking the runs meanwhile. A later claim that finds every check run ended scores each
|
|
6
|
+
// against the agent's own recorded answer (learn/promote.ts sameAnswer; no grade is read) and promotes the digest when,
|
|
7
|
+
// of the inputs it ran on, it answered at least alone_min alone and at least agree_min of those said what the agent said
|
|
8
|
+
// (checkPasses); else it is held, its record keeping the inputs it disagreed on, which the agent's next run's compile
|
|
9
|
+
// turn reads to write its one recompile (learn/compile.ts); that revision is checked the same way, once, and a hold of
|
|
10
|
+
// it stops (nothing compiles again). A check-promoted digest is never checked again: no grade, no refit, no queue, no
|
|
11
|
+
// second replay. Every reserved input counts: one whose replay run was never created, or never ended, by the check's
|
|
12
|
+
// deadline is a failed input. With nothing to check it on (no input of the agent's it takes, or every input skipped at a
|
|
13
|
+
// write) it is never promoted: it stops, its record naming why (stopUnchecked), and asks no recompile.
|
|
14
|
+
//
|
|
15
|
+
// The champion keeps serving meanwhile: while the folder's revision (the challenger) is checked, or once it is held, the
|
|
16
|
+
// digest promoted last (learn/promote.ts championOf) serves the run, read from the learning commit its record names. Only
|
|
17
|
+
// the money rule (workflow-first.ts) stops it. Who serves is the champion alone, read at every run's claim, a queued run's
|
|
18
|
+
// included (servingNow): a digest's own promote record never serves it once another digest was promoted after it. A run
|
|
19
|
+
// already executing (an earlier claim of it served a workflow first) keeps that revision (keptFor). A serving revision
|
|
20
|
+
// this release's workflow DSL refuses (a key an older release took, say) is held at the claim that finds it, once per
|
|
21
|
+
// digest, its reason the DSL's (holdRefused): the run hands back as before, and the hold asks the one recompile.
|
|
22
|
+
// One check at a time: a check at work finishes (a revision newer than it waits, and decides it first: settleAhead). The
|
|
23
|
+
// check is reserved before any of its replay runs starts: its replaying record, naming the runs it will start, is kept
|
|
24
|
+
// only while no other revision of the workflow replays (the rival check in the same guarded write), so two claims of two
|
|
25
|
+
// revisions at once start one check. A reserved run not created yet is pending, never ended: a claim between the
|
|
26
|
+
// reservation and the creates decides nothing, and a launch interrupted there (a crash, a failed create) is finished by a
|
|
27
|
+
// claim REPLAY_LAUNCH_GRACE_MS on, each run under its reserved id on the input its record names (relaunch), with the
|
|
28
|
+
// launch its record chose when it was reserved (PromotionRecord.launch: model, revision, credentials), never the finishing
|
|
29
|
+
// claim's. Every decision is acted on (replay runs started, runs cancelled) only by the claim whose write kept it
|
|
30
|
+
// (learn/promote.ts Recorded.won). A check decided with runs still at work (its deadline passed) cancels them. A replay
|
|
31
|
+
// run's claim refuses it unless its revision still replays (replayClaimed), so a cancel lost to a crash or a failed write
|
|
32
|
+
// never leaves one running.
|
|
33
|
+
// A replay never repeats a side effect and runs with what a served run of the agent has (learn/replay-calls.ts, SPEC B4):
|
|
34
|
+
// each call node's tool is a read or a write; a read runs live through a cache seeded from the agent's recorded calls, a
|
|
35
|
+
// write is answered only from that recording (same tool, same canonical arguments) and is never sent, and an input whose
|
|
36
|
+
// workflow needs a write the recording does not have is skipped (counted in the record's check.outcomes, never scored); a
|
|
37
|
+
// check whose every input was skipped holds the revision in those words, or, when the tool that stopped them is an MCP
|
|
38
|
+
// tool its server listed with no readOnlyHint, naming it (check.skipped_tools). Its credentials resolve at its claim as
|
|
39
|
+
// any run's of the agent do: saved ones from the server's store, and the per_run MCP credentials the run whose claim
|
|
40
|
+
// reserved it was handed (its record's launch.handed_from), sealed anew for the replay run alone (startReplay), never
|
|
41
|
+
// opened outside the claim.
|
|
42
|
+
// Its owner may start one too (askReplay, POST .../revisions/{digest}/replays): a held revision re-checked, or an edited
|
|
43
|
+
// one, on the inputs it was last checked on or the agent's newest, decided by the same settleCheck, at a claim that lays
|
|
44
|
+
// it or at its read (replayView), so its records are a claim-started check's.
|
|
45
|
+
import { sourceSyncOf } from "../source-sync/types.js";
|
|
1
46
|
import { LEARNING_LABEL } from "../learning.js";
|
|
2
47
|
import { loopOf } from "../learning-setting.js";
|
|
3
48
|
import { LEARNED_WORKFLOW_TOOL } from "../learned-workflow.js";
|
|
4
49
|
import { launchBody, readLaunchBody } from "../run-launch.js";
|
|
5
|
-
import { uuidv7 } from "../
|
|
50
|
+
import { uuidv7 } from "../ids.js";
|
|
6
51
|
import { FINAL_STATES, RunFinal, RunPurged, StoreConstraint } from "../store/store.js";
|
|
7
52
|
import { openRunMcpAuth, sealRunMcpAuth } from "../store/seal.js";
|
|
8
53
|
import { isCliRecord, piShaped, runEntries, runTimeline } from "../store-reads/journal.js";
|
|
@@ -32,7 +77,7 @@ export function claimPromotion(deps) {
|
|
|
32
77
|
return {
|
|
33
78
|
...deps,
|
|
34
79
|
kept: async () => (deps.runId ? servedOf(await runEntries(deps.store, deps.runId, deps.context).catch(() => [])) : undefined),
|
|
35
|
-
champion: async (name, commit) => (await workflowsAt({ folder: deps.folder, shown: deps.shown }, commit)).find((one) => one.name === name),
|
|
80
|
+
champion: async (name, commit) => (await workflowsAt({ folder: deps.folder, store: deps.store, shown: deps.shown }, commit)).find((one) => one.name === name),
|
|
36
81
|
newest: async (name) => {
|
|
37
82
|
const folder = deps.folder();
|
|
38
83
|
let main;
|
|
@@ -42,7 +87,7 @@ export function claimPromotion(deps) {
|
|
|
42
87
|
finally {
|
|
43
88
|
await folder.end().catch(() => undefined);
|
|
44
89
|
}
|
|
45
|
-
const text = main ? (await workflowsAt({ folder: deps.folder, shown: deps.shown }, main)).find((one) => one.name === name) : undefined;
|
|
90
|
+
const text = main ? (await workflowsAt({ folder: deps.folder, store: deps.store, shown: deps.shown }, main)).find((one) => one.name === name) : undefined;
|
|
46
91
|
return text ? workflowDigest(text) : undefined;
|
|
47
92
|
},
|
|
48
93
|
};
|
|
@@ -337,6 +382,10 @@ async function checkInputs(deps, workflow, pick, audited = []) {
|
|
|
337
382
|
* it fits), it is decided at once: never promoted, it stops with nothing checked (stopUnchecked). */
|
|
338
383
|
async function startCheck(deps, workflow, digest) {
|
|
339
384
|
const { store, agentId, log } = deps;
|
|
385
|
+
if ((deps.launch.sourceProject || sourceSyncOf((await store.agents.revision(deps.revisionId))?.body)) && !deps.admitAuxiliary) {
|
|
386
|
+
log(`workflow-first: ${PROJECT_REPLAY_REFUSED}`);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
340
389
|
// Its replay runs are runs the runner starts, on no caller's key: skipped where the claimed run brought its own key or
|
|
341
390
|
// the server holds none (claimSpendOff).
|
|
342
391
|
const off = deps.spendOff?.("A learned workflow's replay check");
|
|
@@ -386,18 +435,22 @@ export const NOTHING_TO_CHECK = "nothing to check it on";
|
|
|
386
435
|
export const NEVER_WORD_FOR_WORD = "its answers never matched the agent's word for word, and no fast model compared their decisions (a learning agent with no agree_on wants one: AGENT_MODEL_FAST, or its model_tiers.fast); name the fields that carry the decision (learning.agree_on)";
|
|
387
436
|
/** What a held check the grader compared says of the inputs it disagreed on: k of n, with one of the decisions. */
|
|
388
437
|
export const differentDecisionWords = (k, n, example) => `its answers reached a different decision from the agent's on ${k} of ${n}${example ? ` (for example: ${example})` : ""}`;
|
|
438
|
+
/** The one writer of a hold with nothing checked (n 0): `name` at `digest` held for `reason`, never promoted, its check
|
|
439
|
+
* the bar it was held at (`check`: what else the record keeps of it), `stopped` when nothing compiles again until a hold
|
|
440
|
+
* or its owner acts, and `extra` on the record (a connected agent's check: what its reservation carries). Kept only while
|
|
441
|
+
* `still` holds of the digest's record (the one write), and logged. */
|
|
442
|
+
async function holdUnchecked(deps, name, digest, bar, reason, still, { stopped = false, check = {}, extra = {} } = {}) {
|
|
443
|
+
const decided = await recordPromotion(deps.store.settings, deps.agentId, { workflow: name, digest, at: iso((deps.now ?? Date.now)()), decided: "hold", reason, check: { ...bar, n: 0, agreed: 0, alone: 0, of: [], ...check, ...(stopped ? { stopped: true } : {}) }, ...seedOf(deps), ...extra }, still);
|
|
444
|
+
if (decided.won)
|
|
445
|
+
deps.log(`workflow-first: ${name} at ${digest} ${stopped ? "stopped" : "held"}: ${reason}`);
|
|
446
|
+
return decided;
|
|
447
|
+
}
|
|
389
448
|
/** Stops a draft its check had nothing to run on (`why`: no input of the agent's it takes, or every input skipped at a
|
|
390
449
|
* write): held, never promoted unchecked, its record `stopped` (nothing compiles again until a hold or its owner acts)
|
|
391
450
|
* and naming the cause, which the compile's draft errors show (store-reads/loop.ts). It asks no recompile: a revision
|
|
392
451
|
* would have nothing to be checked on either, and a stop with nothing checked never counts as a compile's first check
|
|
393
|
-
* (attemptOf).
|
|
394
|
-
|
|
395
|
-
const reason = `${NOTHING_TO_CHECK}: ${why}. It is not promoted, and it stops: nothing compiles again until a hold or its owner acts`;
|
|
396
|
-
const decided = await recordPromotion(deps.store.settings, deps.agentId, { workflow: name, digest, at: iso((deps.now ?? Date.now)()), decided: "hold", reason, check: { ...bar, n: 0, agreed: 0, alone: 0, of: [], ...check, stopped: true }, ...seedOf(deps), ...extra }, still);
|
|
397
|
-
if (decided.won)
|
|
398
|
-
deps.log(`workflow-first: ${name} at ${digest} stopped: ${reason}`);
|
|
399
|
-
return decided;
|
|
400
|
-
}
|
|
452
|
+
* (attemptOf). */
|
|
453
|
+
const stopUnchecked = (deps, name, digest, bar, why, still, check = {}, extra = {}) => holdUnchecked(deps, name, digest, bar, `${NOTHING_TO_CHECK}: ${why}. It is not promoted, and it stops: nothing compiles again until a hold or its owner acts`, still, { stopped: true, check, extra });
|
|
401
454
|
/** Decides `ahead`, the check at work for a revision older than the laid (newest) one, as a claim laying it would
|
|
402
455
|
* (relaunch, then settleCheck) once its runs ended: its text read at its record's commit, its verdict standing (promote
|
|
403
456
|
* or hold) though a newer revision waits. Left replaying while a run of it is at work, or when its text cannot be read
|
|
@@ -573,12 +626,14 @@ async function reserve(deps, workflow, digest, inputs, reason, still, check) {
|
|
|
573
626
|
}
|
|
574
627
|
/** How many of a connected agent's reserved native turns its check gives back in a row (failed, a learned workflow or
|
|
575
628
|
* nested call in it, redacted evidence, no shadow report, or a shadow that did not answer; never a cancel, and a turn
|
|
576
|
-
* that lands starts the count again) before it holds the draft, never promoted and never stopped for good, for the
|
|
577
|
-
*
|
|
629
|
+
* that lands starts the count again) before it holds the draft, never promoted and never stopped for good, for the
|
|
630
|
+
* agent's next compile after compile_after more of its runs (runner/learning-end.ts compileAskOf) to revise and check
|
|
631
|
+
* afresh: five in a row say the integration cannot give a baseline now, not that it never will. The one list of the
|
|
632
|
+
* causes a give-back has: every other mention points here. */
|
|
578
633
|
export const SDK_CHECK_RELEASES = 5;
|
|
579
634
|
/** Whether a hold's check is a connected agent's held on SDK_CHECK_RELEASES give-backs in a row (releaseSdkCheck): only
|
|
580
635
|
* a connected agent's check counts give-backs. */
|
|
581
|
-
const heldOnGiveBacks = (check) => (check?.released ?? 0) >= SDK_CHECK_RELEASES;
|
|
636
|
+
export const heldOnGiveBacks = (check) => (check?.released ?? 0) >= SDK_CHECK_RELEASES;
|
|
582
637
|
/** Which attempt a revision compile of `held` is when its draft fails its checks (runner/learning-end.ts
|
|
583
638
|
* recordDraftFailed): 2, the recompile, for any hold but a connected agent's on give-backs, which spends none: its
|
|
584
639
|
* check's own attempt, until a revise of it has failed once already (the workflow's newest record that failed draft). */
|
|
@@ -676,15 +731,20 @@ export async function sdkCheckTurn(deps, record, row, still, read = {}) {
|
|
|
676
731
|
const fresh = (before?.fresh_reads ?? 0) + (read.fresh_reads ?? 0);
|
|
677
732
|
const turns = { ...score, of: [row.of, ...(before?.of ?? [])], outcomes: outcomesAdded(outcomes, before?.outcomes), ...(disagreements.length ? { disagreements } : {}), ...(fresh ? { fresh_reads: fresh } : {}) };
|
|
678
733
|
const check = { ...bar, turns };
|
|
679
|
-
const
|
|
680
|
-
const kept = await recordPromotion(deps.store.settings, deps.agentId, {
|
|
681
|
-
...rest, at: iso((deps.now ?? Date.now)()), check,
|
|
682
|
-
reason: `Waiting for the next native turn of the connected agent that it takes: ${sdkTurnsWords(check)}. Nothing was promoted.`,
|
|
683
|
-
}, (was, current) => turnStill(was, current) && !overtaken(current, was));
|
|
734
|
+
const kept = await waitAgain(deps, record, check, `Waiting for the next native turn of the connected agent that it takes: ${sdkTurnsWords(check)}. Nothing was promoted.`, still);
|
|
684
735
|
if (kept.won)
|
|
685
736
|
deps.log(`workflow-first: ${record.workflow} at ${record.digest}: ${sdkTurnsWords(check)}`);
|
|
686
737
|
return kept;
|
|
687
738
|
}
|
|
739
|
+
/** Puts a connected agent's check back as waiting for the next native turn it takes, nothing decided or promoted: its
|
|
740
|
+
* reserved turn taken off (runs, inputs), its `check` and `reason` kept. The turn lands once: kept only while `still`
|
|
741
|
+
* holds and the record still reserves that turn (sameReplay, heldTurn), so a second writer that read the same
|
|
742
|
+
* reservation finds it gone, and never over a newer revision's record (overtaken). The one writer of a check put back
|
|
743
|
+
* as waiting: a turn's row (sdkCheckTurn) and a give-back (releaseSdkCheck). */
|
|
744
|
+
function waitAgain(deps, record, check, reason, still = () => true) {
|
|
745
|
+
const { runs: _runs, inputs: _inputs, ...rest } = record;
|
|
746
|
+
return recordPromotion(deps.store.settings, deps.agentId, { ...rest, at: iso((deps.now ?? Date.now)()), check, reason }, (was, current) => still(was, current) && sameReplay(was, record) && heldTurn(was, record) && !overtaken(current, was));
|
|
747
|
+
}
|
|
688
748
|
/** A connected agent's check whose native turn did not settle it by REPLAY_DEADLINE_MS (the backend never completed the
|
|
689
749
|
* turn, or the server stopped before the run's end): one failed row of its turns (sdkCheckTurn), as a managed check's
|
|
690
750
|
* replay run not ended by its deadline is a failed input. The hold the turns end in asks the one recompile, and a
|
|
@@ -700,7 +760,8 @@ export async function sdkCheckDeadline(deps, pending) {
|
|
|
700
760
|
/** Gives back a connected agent's reserved native turn that cannot be its check's baseline (`cause`): the check waits for
|
|
701
761
|
* the next turn the draft takes, nothing decided or promoted, the turns it checked kept on the record. A `counted` turn
|
|
702
762
|
* (not a cancel, not a start that was never admitted) counts toward SDK_CHECK_RELEASES in a row, whose last holds the
|
|
703
|
-
* draft for
|
|
763
|
+
* draft for a compile after compile_after more runs, whose revision is checked afresh. Kept only while the record is
|
|
764
|
+
* still this reservation. */
|
|
704
765
|
export async function releaseSdkCheck(deps, record, cause, counted = true) {
|
|
705
766
|
if (!record.check)
|
|
706
767
|
return;
|
|
@@ -713,20 +774,11 @@ export async function releaseSdkCheck(deps, record, cause, counted = true) {
|
|
|
713
774
|
// Overtaken is read again inside the write: a newer revision's record can land while the cause is being cut.
|
|
714
775
|
const still = (was, current) => sameReplay(was, record) && heldTurn(was, record) && !overtaken(current, was);
|
|
715
776
|
const bar = { ...record.check, ...(released ? { released } : {}) };
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (held.won)
|
|
722
|
-
deps.log(`workflow-first: ${record.workflow} at ${record.digest} held: ${reason}`);
|
|
723
|
-
return held;
|
|
724
|
-
}
|
|
725
|
-
const { runs: _runs, inputs: _inputs, ...rest } = record;
|
|
726
|
-
const kept = await recordPromotion(deps.store.settings, deps.agentId, {
|
|
727
|
-
...rest, at, check: bar,
|
|
728
|
-
reason: `Waiting for a native turn of the connected agent that it takes: ${why}, so that turn was given back${counted ? ` (${released} of ${SDK_CHECK_RELEASES} in a row before it is held for a recompile)` : ""}. Nothing was promoted.`,
|
|
729
|
-
}, still);
|
|
777
|
+
// A hold, never `stopped`: it asks a compile for a revision (learn/compile.ts heldNamesOf) after compile_after more runs
|
|
778
|
+
// (runner/learning-end.ts compileAskOf), checked afresh.
|
|
779
|
+
if (released >= SDK_CHECK_RELEASES)
|
|
780
|
+
return holdUnchecked(deps, record.workflow, record.digest, bar, `the connected agent gave back ${plural(released, "reserved native turn")} in a row with no answer to check it against (the last: ${why}). It is not promoted; the agent's next compile after ${plural(bar.compile_after, "more run")} revises it, and the revision is checked afresh`, still, { check: bar.turns?.disagreements?.length ? { disagreements: bar.turns.disagreements } : {}, extra: sdkExtra(record) });
|
|
781
|
+
const kept = await waitAgain(deps, record, bar, `Waiting for a native turn of the connected agent that it takes: ${why}, so that turn was given back${counted ? ` (${released} of ${SDK_CHECK_RELEASES} in a row before it is held for a recompile)` : ""}. Nothing was promoted.`);
|
|
730
782
|
if (kept.won)
|
|
731
783
|
deps.log(`workflow-first: ${record.workflow} at ${record.digest} waits for another native turn: ${why}`);
|
|
732
784
|
return kept;
|
|
@@ -735,13 +787,10 @@ export async function releaseSdkCheck(deps, record, cause, counted = true) {
|
|
|
735
787
|
* with nothing decided, never promoted (the turns it checked kept on the record), and `stopped` as any stop with
|
|
736
788
|
* nothing checked, so it spends no recompile (attemptOf): the newer revision is the one checked next. */
|
|
737
789
|
async function setAside(deps, pending) {
|
|
738
|
-
|
|
790
|
+
const { workflow, digest, at: _at, decided: _decided, reason: _reason, check, ...extra } = pending;
|
|
791
|
+
if (!check)
|
|
739
792
|
return;
|
|
740
|
-
await
|
|
741
|
-
...pending, at: iso((deps.now ?? Date.now)()), decided: "hold",
|
|
742
|
-
reason: `${NOTHING_TO_CHECK}: a newer revision of it landed before the connected agent's native turns finished checking it. It is not promoted; the newer revision is checked instead`,
|
|
743
|
-
check: { ...pending.check, n: 0, agreed: 0, alone: 0, of: [], stopped: true },
|
|
744
|
-
}, (was, current) => waitingSdk(was) && was.replay_id === pending.replay_id && !overtaken(current, was));
|
|
793
|
+
await holdUnchecked(deps, workflow, digest, check, `${NOTHING_TO_CHECK}: a newer revision of it landed before the connected agent's native turns finished checking it. It is not promoted; the newer revision is checked instead`, (was, current) => waitingSdk(was) && was.replay_id === pending.replay_id && !overtaken(current, was), { stopped: true, extra });
|
|
745
794
|
}
|
|
746
795
|
/** The launch a replay's runs all run with (PromotionRecord.launch), chosen once by the claim or person reserving it:
|
|
747
796
|
* `deps.launch` as a replay run takes it (a claim's claimed run's; a person's ask makes one now), the revision it runs,
|
|
@@ -824,9 +873,14 @@ async function startReplay(deps, workflow, digest, of, from, id, launch) {
|
|
|
824
873
|
const base = readLaunchBody(launch.body);
|
|
825
874
|
if (!base)
|
|
826
875
|
throw new Error(`the launch of ${workflow.name} at ${digest}'s replay could not be read`);
|
|
876
|
+
const source = sourceSyncOf((await store.agents.revision(launch.revision))?.body);
|
|
877
|
+
if (base.sourceProject || source && !deps.admitAuxiliary)
|
|
878
|
+
throw new ReplayRefused("conflict", PROJECT_REPLAY_REFUSED);
|
|
827
879
|
const replay = { ...base, input: from.input, title: `Replay of ${workflow.name}: ${from.title}`.slice(0, 200), replay: { of, workflow: workflow.name, digest } };
|
|
828
880
|
const sealed = await handedTo(deps, launch, id);
|
|
829
881
|
try {
|
|
882
|
+
if (source)
|
|
883
|
+
return (await deps.admitAuxiliary({ runId: id, agentId, revisionId: launch.revision, launch: replay, ...(sealed ? { sealed } : {}) })).created;
|
|
830
884
|
await store.runs.create({ id, agentId, revisionId: launch.revision }, { body: launchBody(replay), ...(sealed ? { sealed } : {}) });
|
|
831
885
|
return true;
|
|
832
886
|
}
|
|
@@ -926,6 +980,7 @@ function skipWordsOf(tools, skipped) {
|
|
|
926
980
|
}
|
|
927
981
|
/** Why a replay a person asked for (askReplay) or read (replayView) was refused: `missing`, no such workflow, revision or
|
|
928
982
|
* replay of the agent (404); `conflict`, the revision cannot replay now (409), in words that say why. */
|
|
983
|
+
const PROJECT_REPLAY_REFUSED = "An auxiliary replay requires its own project placement for this moved agent; nothing was started. Start a normal run to use the saved project.";
|
|
929
984
|
export class ReplayRefused extends Error {
|
|
930
985
|
kind;
|
|
931
986
|
constructor(kind, message) {
|
|
@@ -993,9 +1048,11 @@ export async function askReplay(ask, name, digest, inputs) {
|
|
|
993
1048
|
if (!picked.length)
|
|
994
1049
|
throw new ReplayRefused("conflict", `${name} at ${digest} has no input to replay on: none of ${typeof inputs === "number" ? `the agent's newest ${plural(inputs, "completed run")}` : last ? "the runs it was last checked on" : "the agent's last completed runs"} has an input it fits. Nothing was started.`);
|
|
995
1050
|
const { launch, revisionId } = await ask.launchOf(picked[0].launch.input);
|
|
1051
|
+
if (launch.sourceProject || sourceSyncOf((await ask.store.agents.revision(revisionId))?.body) && !ask.admitAuxiliary)
|
|
1052
|
+
throw new ReplayRefused("conflict", PROJECT_REPLAY_REFUSED);
|
|
996
1053
|
if (!launch.learning || launch.learning.noWorkflows)
|
|
997
1054
|
throw new ReplayRefused("conflict", `A replay runs ${name} as a run of the agent that learns does, and the agent's runs do not take learned workflows here (its learning is off, it takes no workflows, or this server's is off).`);
|
|
998
|
-
const deps = { store: ask.store, agentId: ask.agentId, revisionId, launch: { ...launch, learning: { ...launch.learning, seed: found.commit } }, context: ask.context, log: ask.log, shown: ask.shown, ...(ask.now ? { now: ask.now } : {}) };
|
|
1055
|
+
const deps = { store: ask.store, agentId: ask.agentId, revisionId, launch: { ...launch, learning: { ...launch.learning, seed: found.commit } }, context: ask.context, log: ask.log, shown: ask.shown, ...(ask.admitAuxiliary ? { admitAuxiliary: ask.admitAuxiliary } : {}), ...(ask.now ? { now: ask.now } : {}) };
|
|
999
1056
|
const bar = { ...loop, attempt: attemptOf(records, name, digest) };
|
|
1000
1057
|
const said = `checking it on ${plural(picked.length, "input")} of the agent's own runs, as its owner asked`;
|
|
1001
1058
|
// Kept only while the revision's newest record is still the one read here: each record write stamps a new `at`.
|
package/dist/runner/redact.d.ts
CHANGED
|
@@ -24,9 +24,22 @@ export declare const processSecretRedactor: () => Redact;
|
|
|
24
24
|
export interface HeldRedact extends Redact {
|
|
25
25
|
/** Cut `values` too from here on, each in every form; one shorter than MIN_SECRET, whitespace aside, is left out. */
|
|
26
26
|
hold(values: readonly string[]): void;
|
|
27
|
+
/** Hold `values`, and cut them from run `runId`'s journal as it is written too (runner.ts): the run's own tool keys
|
|
28
|
+
* (run-keys.ts), erased at its turn's end, so no read after it could cut them. */
|
|
29
|
+
carry(runId: string, values: readonly string[]): void;
|
|
30
|
+
/** The cut of what run `runId` carried (`carry`), or undefined while it carried none. */
|
|
31
|
+
carried(runId: string): Redact | undefined;
|
|
32
|
+
/** Forget what run `runId` carried, once the runner lets its claim go: a later run's writes are never cut of it. The
|
|
33
|
+
* values stay held (`hold`). */
|
|
34
|
+
dropCarried(runId: string): void;
|
|
27
35
|
}
|
|
28
36
|
/** `base`, then every value held since (`hold`). One that holds already is itself: wrapped once, the one instance. */
|
|
29
37
|
export declare function heldRedactor(base: Redact): HeldRedact;
|
|
38
|
+
/** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
|
|
39
|
+
* loop of its own (rule three: no secret the runner holds is written). `names`: each object's and map's names too (a
|
|
40
|
+
* model may write a value as a JSON name); two names cut to one are both kept, the later ones numbered. A number that
|
|
41
|
+
* shows a value `cut` holds (a key of digits alone, quoted as a JSON number: key-refusal.ts heldNumber) is "[redacted]". */
|
|
42
|
+
export declare function cutDeep<T>(value: T, cut: Redact, names?: boolean): T;
|
|
30
43
|
/** The secrets a claim opened from the store (`env`, claimSecrets' environment for the run) held by `redact`, the run's
|
|
31
44
|
* one redactor, so a host tool's or a provider's error that echoes one is cut in the run's record, its end and its logs. */
|
|
32
45
|
export declare function holdClaimed(redact: HeldRedact, env: NodeJS.ProcessEnv): void;
|
package/dist/runner/redact.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// loop's failed end), the runner's events, and the model route's error text that pi records. Each passes through the one
|
|
4
4
|
// function made here, which puts "[redacted]" in place of every secret value the runner holds, in every form a value
|
|
5
5
|
// can take in text (key-refusal.ts redactedAnswer: as written, JSON-escaped, base64, hex and percent-encoded).
|
|
6
|
-
import { redactedAnswer } from "../key-refusal.js";
|
|
6
|
+
import { heldNumber, redactedAnswer } from "../key-refusal.js";
|
|
7
7
|
import { MIN_SECRET } from "../learn/secrets.js";
|
|
8
8
|
import { hostSecrets, SECRET_NAMES } from "../secrets.js";
|
|
9
9
|
import { planOf } from "../chatgpt-plan.js";
|
|
@@ -39,6 +39,8 @@ export function heldRedactor(base) {
|
|
|
39
39
|
if (isHeld(base))
|
|
40
40
|
return base;
|
|
41
41
|
const held = new Set();
|
|
42
|
+
/** Each run's carried values and their cut, made at its first use after a carry. */
|
|
43
|
+
const carried = new Map();
|
|
42
44
|
const cut = ((text) => {
|
|
43
45
|
const once = base(text);
|
|
44
46
|
return once && held.size ? redactedAnswer(once, [...held]) : once;
|
|
@@ -48,12 +50,76 @@ export function heldRedactor(base) {
|
|
|
48
50
|
if (value.replace(/\s+/g, "").length >= MIN_SECRET)
|
|
49
51
|
held.add(value);
|
|
50
52
|
};
|
|
53
|
+
cut.carry = (runId, values) => {
|
|
54
|
+
cut.hold(values);
|
|
55
|
+
const kept = values.filter((value) => held.has(value));
|
|
56
|
+
if (!kept.length)
|
|
57
|
+
return;
|
|
58
|
+
const run = new Set([...(carried.get(runId)?.values ?? []), ...kept]);
|
|
59
|
+
carried.set(runId, { values: run });
|
|
60
|
+
};
|
|
61
|
+
cut.carried = (runId) => {
|
|
62
|
+
const run = carried.get(runId);
|
|
63
|
+
if (!run)
|
|
64
|
+
return undefined;
|
|
65
|
+
return (run.cut ??= secretRedactor([...run.values]));
|
|
66
|
+
};
|
|
67
|
+
cut.dropCarried = (runId) => void carried.delete(runId);
|
|
51
68
|
// Its values are the base's and every one held since; a base that does not know its own leaves them unknown.
|
|
52
69
|
const known = base.heldValues;
|
|
53
70
|
if (known)
|
|
54
71
|
withHeldValues(cut, () => [...new Set([...known(), ...held])]);
|
|
55
72
|
return cut;
|
|
56
73
|
}
|
|
74
|
+
/** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
|
|
75
|
+
* loop of its own (rule three: no secret the runner holds is written). `names`: each object's and map's names too (a
|
|
76
|
+
* model may write a value as a JSON name); two names cut to one are both kept, the later ones numbered. A number that
|
|
77
|
+
* shows a value `cut` holds (a key of digits alone, quoted as a JSON number: key-refusal.ts heldNumber) is "[redacted]". */
|
|
78
|
+
export function cutDeep(value, cut, names = false) {
|
|
79
|
+
// The values `cut` holds, read once for the whole of `value` at its first number.
|
|
80
|
+
let held;
|
|
81
|
+
const shows = (number) => {
|
|
82
|
+
const text = String(number);
|
|
83
|
+
if (held === undefined)
|
|
84
|
+
held = cut.heldValues?.() ?? null;
|
|
85
|
+
if (!held)
|
|
86
|
+
return cut(text) !== text;
|
|
87
|
+
// Digits shorter than any held value can't hold one, in any form; only the same number written otherwise can.
|
|
88
|
+
if (text.length < MIN_SECRET)
|
|
89
|
+
return held.some((secret) => secret.trim() !== "" && Number(secret) === Number(number));
|
|
90
|
+
return heldNumber(number, held);
|
|
91
|
+
};
|
|
92
|
+
const named = (taken, key) => {
|
|
93
|
+
const once = names ? cut(key) : key;
|
|
94
|
+
let name = once;
|
|
95
|
+
for (let n = 2; taken(name); n++)
|
|
96
|
+
name = `${once} (${n})`;
|
|
97
|
+
return name;
|
|
98
|
+
};
|
|
99
|
+
const walk = (one) => {
|
|
100
|
+
if (typeof one === "string")
|
|
101
|
+
return cut(one);
|
|
102
|
+
if (typeof one === "number" || typeof one === "bigint")
|
|
103
|
+
return shows(one) ? "[redacted]" : one;
|
|
104
|
+
if (one === null || typeof one !== "object")
|
|
105
|
+
return one;
|
|
106
|
+
if (ArrayBuffer.isView(one) || one instanceof Date || one instanceof RegExp || one instanceof ArrayBuffer)
|
|
107
|
+
return one;
|
|
108
|
+
if (Array.isArray(one))
|
|
109
|
+
return one.map(walk);
|
|
110
|
+
if (one instanceof Map) {
|
|
111
|
+
const out = new Map();
|
|
112
|
+
for (const [k, v] of one)
|
|
113
|
+
out.set(typeof k === "string" ? named((name) => out.has(name), k) : k, walk(v));
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
const out = {};
|
|
117
|
+
for (const key of Object.keys(one))
|
|
118
|
+
Object.defineProperty(out, named((name) => Object.hasOwn(out, name), key), { value: walk(one[key]), enumerable: true, writable: true, configurable: true });
|
|
119
|
+
return out;
|
|
120
|
+
};
|
|
121
|
+
return walk(value);
|
|
122
|
+
}
|
|
57
123
|
/** The secrets a claim opened from the store (`env`, claimSecrets' environment for the run) held by `redact`, the run's
|
|
58
124
|
* one redactor, so a host tool's or a provider's error that echoes one is cut in the run's record, its end and its logs. */
|
|
59
125
|
export function holdClaimed(redact, env) {
|
|
@@ -9,6 +9,15 @@ export declare class ChannelClosed extends Error {
|
|
|
9
9
|
export declare class ChannelRefused extends Error {
|
|
10
10
|
name: string;
|
|
11
11
|
}
|
|
12
|
+
/** A call or an answer past the channel's cap: it fails alone, and the channel goes on. Its bytes and the cap cross with
|
|
13
|
+
* it (registered on both sides), so a runner can tell a run whose records no longer fit from one that may go on. */
|
|
14
|
+
export declare class FrameTooLarge extends RangeError {
|
|
15
|
+
name: string;
|
|
16
|
+
readonly bytes: number;
|
|
17
|
+
readonly limit: number;
|
|
18
|
+
/** `what`: "an answer", or "a call of <method>". */
|
|
19
|
+
constructor(what: string, bytes: number, limit: number);
|
|
20
|
+
}
|
|
12
21
|
export declare function registerErrors(classes: Record<string, abstract new (...args: never[]) => Error>): void;
|
|
13
22
|
/** What a target exposed by name does with a call: its method and arguments, as decoded. */
|
|
14
23
|
export type Dispatch = (method: string, args: unknown[]) => unknown;
|
|
@@ -24,6 +24,19 @@ export class ChannelClosed extends Error {
|
|
|
24
24
|
export class ChannelRefused extends Error {
|
|
25
25
|
name = "ChannelRefused";
|
|
26
26
|
}
|
|
27
|
+
/** A call or an answer past the channel's cap: it fails alone, and the channel goes on. Its bytes and the cap cross with
|
|
28
|
+
* it (registered on both sides), so a runner can tell a run whose records no longer fit from one that may go on. */
|
|
29
|
+
export class FrameTooLarge extends RangeError {
|
|
30
|
+
name = "FrameTooLarge";
|
|
31
|
+
bytes;
|
|
32
|
+
limit;
|
|
33
|
+
/** `what`: "an answer", or "a call of <method>". */
|
|
34
|
+
constructor(what, bytes, limit) {
|
|
35
|
+
super(what === "an answer" ? `an answer of ${bytes} bytes is past the channel's ${limit}` : `${what} is ${bytes} bytes, past the channel's ${limit}`);
|
|
36
|
+
this.bytes = bytes;
|
|
37
|
+
this.limit = limit;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
27
40
|
/** The error classes made again by name on the receiving side, so instanceof holds across the channel. Each side
|
|
28
41
|
* registers the ones it may receive (registerErrors). */
|
|
29
42
|
const ERRORS = new Map();
|
|
@@ -189,11 +202,11 @@ export class Channel {
|
|
|
189
202
|
if (message.t === "call") {
|
|
190
203
|
const pending = this.#pending.get(message.id);
|
|
191
204
|
this.#pending.delete(message.id);
|
|
192
|
-
pending?.reject(new
|
|
205
|
+
pending?.reject(new FrameTooLarge(`a call of ${String(message.m)}`, body.length, this.#maxFrame));
|
|
193
206
|
return;
|
|
194
207
|
}
|
|
195
208
|
if (message.t === "ok")
|
|
196
|
-
return this.#send({ t: "err", id: message.id, e: this.#encode(new
|
|
209
|
+
return this.#send({ t: "err", id: message.id, e: this.#encode(new FrameTooLarge("an answer", body.length, this.#maxFrame)) });
|
|
197
210
|
return;
|
|
198
211
|
}
|
|
199
212
|
const head = Buffer.alloc(4);
|
|
@@ -32,6 +32,9 @@ export declare const runIsolationName: (isolation: RunIsolation) => "uid" | "pro
|
|
|
32
32
|
export declare class RunIsolationRefused extends Error {
|
|
33
33
|
name: string;
|
|
34
34
|
}
|
|
35
|
+
/** Whether runIsolationOf gives `env` on this host `process` (every run as the runner's own user), told before it is
|
|
36
|
+
* asked: `same`, or no helper and not `slot`. A helper that is there but cannot switch refuses the runner instead. */
|
|
37
|
+
export declare const runsAsOwnUser: (env: NodeJS.ProcessEnv, helper?: string) => boolean;
|
|
35
38
|
/** This host's isolation for `loops` runs at once, by `env` and the helper: the helper's own check that it can switch
|
|
36
39
|
* (its effective set holds what it needs) decides `uid`; none installed (a local install), `process`; `same`, `process`
|
|
37
40
|
* said in the log. A helper that cannot switch is refused in words naming the setting, never a quiet fall back. `loops`
|
|
@@ -89,9 +92,6 @@ export declare function reapSlot(isolation: Extract<RunIsolation, {
|
|
|
89
92
|
/** `value` as data: every function, symbol and class's method left out, so nothing the runner holds is handed by
|
|
90
93
|
* reference to the run's process unless a target hands it on purpose. */
|
|
91
94
|
export declare function dataOnly(value: unknown, seen?: Set<object>): unknown;
|
|
92
|
-
/** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
|
|
93
|
-
* loop of its own (rule three: no secret the runner holds is written). */
|
|
94
|
-
export declare function cutDeep<T>(value: T, cut: (text: string) => string): T;
|
|
95
95
|
/** What the store target knows of the claim: its run and the run's agent and revision. */
|
|
96
96
|
export interface Bound {
|
|
97
97
|
readonly claim: Claim;
|
|
@@ -116,6 +116,7 @@ interface ClaimReads {
|
|
|
116
116
|
readonly body: Record<string, unknown>;
|
|
117
117
|
};
|
|
118
118
|
readonly claimed: NodeJS.ProcessEnv;
|
|
119
|
+
readonly signal?: AbortSignal;
|
|
119
120
|
}
|
|
120
121
|
/** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
|
|
121
122
|
* runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
|
|
@@ -126,6 +127,7 @@ export declare function heldFor(deps: AdapterSpecDeps & {
|
|
|
126
127
|
held: Held;
|
|
127
128
|
inputs(): Promise<void>;
|
|
128
129
|
release(): Promise<void>;
|
|
130
|
+
projectEnd?(): Promise<void>;
|
|
129
131
|
};
|
|
130
132
|
/** A call of the learning folder a run's process asks (Held.learning), on the runner's own Workspace of the claim's
|
|
131
133
|
* agent's folder: reads pass, and the learning script runs its reads, with the script's own environment (the script
|
|
@@ -156,6 +158,9 @@ export declare const childArgv: () => string[];
|
|
|
156
158
|
export declare const runsInRunner: (harness: string, launch: Pick<RunLaunch, "sdk" | "native" | "cli_learning">) => boolean;
|
|
157
159
|
/** The words a run on Claude Code's login on this machine is refused in where each run is a user of its own. */
|
|
158
160
|
export declare const LOGIN_NEEDS_SERVER_USER = "A run on Claude Code's login on this machine needs runs under the server's own user, and this runner runs each run as a user of its own: set AGENTRUN_RUN_USER=same, or give the run a model_key.";
|
|
161
|
+
/** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
|
|
162
|
+
export declare const RECIPE_NEEDS_SERVER_USER = "A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set AGENTRUN_RUN_USER=same on this runner.";
|
|
163
|
+
export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
|
|
159
164
|
/** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
|
|
160
165
|
* directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
|
|
161
166
|
* user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
|
|
@@ -176,4 +181,3 @@ export declare function runChannel(socket: Duplex, onClose: (why: Error) => void
|
|
|
176
181
|
readonly bigs?: RunBigWrites;
|
|
177
182
|
readonly maxFrame?: number;
|
|
178
183
|
}): Channel;
|
|
179
|
-
export {};
|