@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.36
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 +128 -0
- package/README.md +260 -168
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +13 -41
- package/dist/cap.js +24 -73
- package/dist/cli.js +4 -22
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +48 -7
- package/dist/computers.js +100 -23
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +7 -1
- package/dist/learn/check.js +123 -5
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +5 -0
- package/dist/learn/folder.js +33 -0
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +86 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +43 -29
- package/dist/learn/skills.d.ts +4 -0
- package/dist/learn/skills.js +7 -0
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +19 -9
- package/dist/learned-workflow.js +62 -34
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +8 -3
- package/dist/learning-routes.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -6
- package/dist/learning.js +4 -2
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +5 -5
- package/dist/model.js +6 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +204 -47
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +1 -0
- package/dist/propose.js +25 -10
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +14 -1
- package/dist/run-launch.js +7 -2
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +5 -2
- package/dist/run-view.js +4 -3
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +16 -1
- package/dist/runner/adapter-loop.js +131 -30
- package/dist/runner/adapter-run-spec.d.ts +25 -4
- package/dist/runner/adapter-run-spec.js +103 -24
- package/dist/runner/adapters/pi.d.ts +11 -3
- package/dist/runner/adapters/pi.js +35 -12
- package/dist/runner/beside.js +6 -2
- package/dist/runner/cli-run-spec.d.ts +7 -0
- package/dist/runner/cli-run-spec.js +92 -38
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +8 -5
- package/dist/runner/github-app.js +2 -2
- package/dist/runner/harness-loops.js +1 -1
- package/dist/runner/journal-kinds.d.ts +15 -5
- package/dist/runner/journal-kinds.js +6 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +26 -5
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +73 -1
- package/dist/runner/learning-loop.js +203 -18
- package/dist/runner/learning-seed.d.ts +2 -0
- package/dist/runner/learning-seed.js +1 -1
- package/dist/runner/loop-contract.d.ts +8 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.js +12 -2
- package/dist/runner/mcp-claim.d.ts +4 -0
- package/dist/runner/mcp-claim.js +29 -1
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +0 -7
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +1 -0
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -0
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +47 -12
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +18 -2
- package/dist/runner/workflow-host.js +23 -3
- package/dist/runner/workflow-loop.d.ts +5 -2
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +26 -14
- package/dist/runner/workflow-spec.js +97 -30
- package/dist/runs-over-store.d.ts +11 -6
- package/dist/runs-over-store.js +111 -24
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server.d.ts +32 -49
- package/dist/server.js +249 -199
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/deadline.js +9 -5
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +45 -12
- package/dist/store-reads/learning.d.ts +15 -1
- package/dist/store-reads/learning.js +68 -10
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.js +45 -19
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +3 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +8 -0
- package/dist/tool-budget.js +7 -1
- package/dist/tool-gate.d.ts +7 -1
- package/dist/tool-gate.js +7 -2
- package/dist/tool-plane.d.ts +33 -19
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +18 -34
- package/dist/tools.js +104 -70
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +30 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +76 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +411 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/computer-deps.d.ts +16 -8
- package/dist/workspace/computer-deps.js +18 -7
- package/dist/workspace/computer-for-claim.d.ts +42 -6
- package/dist/workspace/computer-for-claim.js +209 -9
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +7 -0
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.js +1 -0
- package/dist/workspace/resolve-computer.d.ts +42 -11
- package/dist/workspace/resolve-computer.js +65 -13
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +4 -4
- package/dist/workspace/run-tools.js +8 -6
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +10 -15
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/propose.d.ts
CHANGED
package/dist/propose.js
CHANGED
|
@@ -2,15 +2,16 @@ import { join } from "node:path";
|
|
|
2
2
|
import { checkProposal, draftDryRun, draftFiles, NOTE_BLOCK, unstorable, parseReflection, redactSecrets, shortMessage, SKILL_BLOCK, SKILLS_DIR, WORKFLOW_BLOCK, WORKFLOWS_DIR } from "./learn/index.js";
|
|
3
3
|
import { folderAt, readLearning, readSnapshot } from "./learn/folder.js";
|
|
4
4
|
import { baseOf } from "./learn/seed-check.js";
|
|
5
|
+
import { parseNoteFile, ruleOf } from "./learn/notes.js";
|
|
5
6
|
import { writeDurable } from "./files.js";
|
|
6
7
|
import { PROPOSAL } from "./learning.js";
|
|
7
8
|
/** The rules that refuse a proposal whole, whatever item they name: a path outside what a run may write, a deletion,
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* text whole first. */
|
|
13
|
-
const WHOLE = new Set(["outside", "deleted", "
|
|
9
|
+
* anything that must never be stored (a secret, a character a reader does not see), which says the run's answer is
|
|
10
|
+
* not to be trusted for any item, and text that is not UTF-8, which cannot be read for one. Every other problem is its
|
|
11
|
+
* item's alone: a count cap names the items past it (learn/check.ts), a size cap the item over it, the index's lines
|
|
12
|
+
* the notes that add lines from the answer's end, and they are left out and the rest kept; unstorable reads every
|
|
13
|
+
* item's text whole first. */
|
|
14
|
+
const WHOLE = new Set(["outside", "deleted", "secret_value", "secret_shape", "invisible_unicode", "encoding"]);
|
|
14
15
|
/** The item a changed file belongs to: a draft's two files are one item (its folder), every other file is itself. */
|
|
15
16
|
const itemOf = (path) => (path.startsWith(`${WORKFLOWS_DIR}/`) ? path.split("/").slice(0, 2).join("/") : path);
|
|
16
17
|
const utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
@@ -91,10 +92,20 @@ export const proposeRun = async (input) => {
|
|
|
91
92
|
}
|
|
92
93
|
const given = [...fileGroups.values()];
|
|
93
94
|
// The seed is read whatever the answer: a seed the folder does not hold fails the check.
|
|
94
|
-
|
|
95
|
+
// The seed's active notes are read too: a new note of the same rule as one (notes.ts ruleOf) is a duplicate.
|
|
96
|
+
const activeOf = (seedSnapshot) => seedSnapshot.notes.filter((note) => note.status === "active").map((note) => note.file);
|
|
97
|
+
// And the skill of each draft's name, as the folder holds it: what the draft keeps as a workflow, for the grader.
|
|
98
|
+
const skillOf = (draft) => `${SKILLS_DIR}/${draft.split("/")[1]}/SKILL.md`;
|
|
99
|
+
const draftSkills = given.flat().filter(({ file }) => file.endsWith("/workflow.json")).map(({ file }) => skillOf(file));
|
|
100
|
+
const { snapshot, texts } = await seedAt(input.folder, input.seed, (seedSnapshot) => (parsed.ok ? [...parsed.notes.map(({ file }) => file), ...given.flat().map(({ file }) => file), ...draftSkills, ...activeOf(seedSnapshot)] : []));
|
|
95
101
|
if (!parsed.ok)
|
|
96
102
|
return parsed.reason === "empty" ? { state: "dropped", reason: "empty" } : { state: "dropped", reason: "unparsed", detail: parsed.detail };
|
|
97
|
-
const { base, kept } = baseOf(snapshot);
|
|
103
|
+
const { base: seedBase, kept } = baseOf(snapshot);
|
|
104
|
+
const rules = new Map(activeOf(snapshot).flatMap((file) => {
|
|
105
|
+
const note = texts.has(file) ? parseNoteFile(file, texts.get(file)) : undefined;
|
|
106
|
+
return note && !Array.isArray(note) ? [[ruleOf(note.body), file]] : [];
|
|
107
|
+
}));
|
|
108
|
+
const base = { ...seedBase, rules };
|
|
98
109
|
const held = new Set(base.files);
|
|
99
110
|
const files = given.filter((group) => group.some(({ file, text }) => texts.get(file) !== text)).flat();
|
|
100
111
|
const changeOf = ({ file, text }) => ({ path: file, status: held.has(file) ? "modified" : "added", mode: "100644", bytes: Buffer.from(text) });
|
|
@@ -120,7 +131,7 @@ export const proposeRun = async (input) => {
|
|
|
120
131
|
return { state: "dropped", reason: "checker", problems: leaky };
|
|
121
132
|
// A skill or a draft whose seed text has a status is a person's call (retired, or waiting for their OK): never changed.
|
|
122
133
|
const dryRuns = {};
|
|
123
|
-
const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.ask ? { ask: input.ask } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
|
|
134
|
+
const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.ask ? { ask: input.ask } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
|
|
124
135
|
// The static checks first, every one (validateWorkflow with executeCode: false, draftProblems' refusal of code nodes,
|
|
125
136
|
// caps, secrets): a draft they refuse is never dry-run, nor is any when they refuse the answer whole. Then each draft
|
|
126
137
|
// left is dry-run on its example, else on a synthesized input (learn/skills.ts draftDryRun): every model and tool
|
|
@@ -173,7 +184,11 @@ export const proposeRun = async (input) => {
|
|
|
173
184
|
const triggered = (input.turn.triggered ?? []).map(({ source, text }) => ({ source, text: shortMessage(redactSecrets(text, input.refuse, Number.POSITIVE_INFINITY)) }));
|
|
174
185
|
// How each kept draft's dry run went, for the grader: passed, or not run and why.
|
|
175
186
|
const ran = Object.fromEntries(passing.filter(({ file }) => dryRuns[file]).map(({ file }) => [file, dryRuns[file]]));
|
|
176
|
-
|
|
187
|
+
// Each kept draft's skill as the folder holds it at the seed, unless the proposal gives that skill itself (the grader
|
|
188
|
+
// reads it there): the format the draft's answer keeps (#2412). Cut of the host's secrets, as what was said is.
|
|
189
|
+
const proposing = new Set(passing.map(({ file }) => file));
|
|
190
|
+
const drafted = passing.filter(({ file }) => file.endsWith("/workflow.json")).map(({ file }) => skillOf(file)).filter((file) => !proposing.has(file) && texts.has(file)).map((file) => ({ file, text: redactSecrets(texts.get(file), input.refuse, Number.POSITIVE_INFINITY) }));
|
|
191
|
+
const proposal = { seed: input.seed, notes: checked.notes.map(({ file, text }) => ({ file, text })), ...(passing.length ? { files: passing } : {}), ...(Object.keys(ran).length ? { dryRuns: ran } : {}), ...(drafted.length ? { drafted } : {}), asked, ...(triggered.length ? { triggered } : {}) };
|
|
177
192
|
await writeDurable(join(input.runDir, PROPOSAL), `${JSON.stringify(proposal)}\n`);
|
|
178
193
|
const count = (suffix) => passing.filter(({ file }) => file.endsWith(suffix)).length;
|
|
179
194
|
return { state: "proposed", notes: proposal.notes.length, skills: count("/SKILL.md"), workflows: count("/workflow.json"), ...(left.length ? { left } : {}) };
|
package/dist/run-cut.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export declare function runCutValues(deps: {
|
|
|
13
13
|
}): Promise<{
|
|
14
14
|
values: string[];
|
|
15
15
|
} | "unreadable">;
|
|
16
|
+
/** `build` against run `runId`'s cut, and the cut read again once it is built: `build` is made again, under the cut as it then
|
|
17
|
+
* stood, until the cut it ran under is the cut after it. The cut only grows (a value saved stays held), so a cut that is the
|
|
18
|
+
* same after a build holds every value saved before that build's reads, and what `build` rendered under it is cut of all
|
|
19
|
+
* of them. A cut that keeps growing past CUT_TRIES builds fails closed: `build` is made under `unreadable`, the run withheld. */
|
|
20
|
+
export declare function underCut<T>(read: () => Promise<Awaited<ReturnType<typeof runCutValues>>>, build: (cut: Awaited<ReturnType<typeof runCutValues>>) => Promise<T>): Promise<T>;
|
|
16
21
|
/** Run `runId`'s error words: how its error text reads wherever it is served (its view's error, its Timeline's error
|
|
17
22
|
* rows), main's errorWords: a refused key in plain words (key-refusal.ts keyRefusal, the key its harness's route sends
|
|
18
23
|
* by this server's settings and keys), else the text by the one rule (shownOf); `unreadable` when the run is withheld.
|
package/dist/run-cut.js
CHANGED
|
@@ -18,6 +18,25 @@ export async function runCutValues(deps, store, runId, known) {
|
|
|
18
18
|
return "unreadable";
|
|
19
19
|
return { values: [...deps.serverSecrets(), ...handed.refs.filter((ref) => ref.length >= MIN_SECRET)] };
|
|
20
20
|
}
|
|
21
|
+
/** How many times `underCut` builds again against a cut that grew while it built, before it gives up and withholds. */
|
|
22
|
+
const CUT_TRIES = 5;
|
|
23
|
+
/** `build` against run `runId`'s cut, and the cut read again once it is built: `build` is made again, under the cut as it then
|
|
24
|
+
* stood, until the cut it ran under is the cut after it. The cut only grows (a value saved stays held), so a cut that is the
|
|
25
|
+
* same after a build holds every value saved before that build's reads, and what `build` rendered under it is cut of all
|
|
26
|
+
* of them. A cut that keeps growing past CUT_TRIES builds fails closed: `build` is made under `unreadable`, the run withheld. */
|
|
27
|
+
export async function underCut(read, build) {
|
|
28
|
+
const same = (a, b) => a === "unreadable" || b === "unreadable" ? a === b : new Set(a.values).size === new Set([...a.values, ...b.values]).size && new Set(b.values).size === new Set(a.values).size;
|
|
29
|
+
let cut = await read();
|
|
30
|
+
for (let tries = 1;; tries++) {
|
|
31
|
+
const built = await build(cut);
|
|
32
|
+
const now = await read();
|
|
33
|
+
if (same(cut, now))
|
|
34
|
+
return built;
|
|
35
|
+
if (tries >= CUT_TRIES)
|
|
36
|
+
return build("unreadable");
|
|
37
|
+
cut = now;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
21
40
|
/** Run `runId`'s error words: how its error text reads wherever it is served (its view's error, its Timeline's error
|
|
22
41
|
* rows), main's errorWords: a refused key in plain words (key-refusal.ts keyRefusal, the key its harness's route sends
|
|
23
42
|
* by this server's settings and keys), else the text by the one rule (shownOf); `unreadable` when the run is withheld.
|
package/dist/run-db.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// How the server opens a run's database, run.sqlite, which the run's own process writes: in WAL, under an exclusive lock,
|
|
2
|
-
// with no automatic checkpoint, and ended by process.exit with no close
|
|
2
|
+
// with no automatic checkpoint, and ended by process.exit with no close,
|
|
3
3
|
// so its WAL stays until whoever takes the run back checkpoints it. The server never opens it read-write while a
|
|
4
4
|
// process holds the run: every read is a fresh read-only open with no locking (`vfs=unix-none`) and an exclusive
|
|
5
5
|
// locking mode (the WAL index in heap, no -shm), kept for that read alone, since a connection kept open falls behind
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// guard). The one read-write open is the checkpoint when the server takes the run back (runs.ts), with no process left.
|
|
8
8
|
import { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
9
9
|
import { DatabaseSync } from "node:sqlite";
|
|
10
|
-
import { walHasCommit } from "
|
|
10
|
+
import { walHasCommit } from "./workflow/wal.js";
|
|
11
11
|
const observers = new Set();
|
|
12
12
|
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
13
13
|
export function observeRunDbOpens(observer) {
|
|
@@ -60,7 +60,7 @@ export function readRunDbSync(file, held, read) {
|
|
|
60
60
|
for (let attempt = 1;; attempt++) {
|
|
61
61
|
for (const observer of observers)
|
|
62
62
|
observer({ file, mode: "read", held });
|
|
63
|
-
// A WAL is opened only once it holds a commit SQLite's recovery takes (
|
|
63
|
+
// A WAL is opened only once it holds a commit SQLite's recovery takes (workflow/wal.ts walHasCommit).
|
|
64
64
|
const immutable = !walHasCommit(`${file}-wal`);
|
|
65
65
|
const before = immutable ? fileMark(file) : undefined;
|
|
66
66
|
runDbTestHooks.afterPlan?.(file);
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -45,7 +45,9 @@ export interface RunLaunch {
|
|
|
45
45
|
* `seedNotes`, the count of all notes in the seed before the budget picked `given` (present with a read seed; absent when
|
|
46
46
|
* the seed could not be read); `skills`, the names of the learned skills the seed offers the run (each active one that
|
|
47
47
|
* fits a run's skill budget at all; its claim lays them), absent when none; `workflows`, the names of the learned
|
|
48
|
-
* workflows the seed offers its learned_workflow tool (chooseWorkflows), absent when none; `
|
|
48
|
+
* workflows the seed offers its learned_workflow tool (chooseWorkflows), absent when none; `notesOnly`, a run of a
|
|
49
|
+
* revision that says `learning: "notes"`: given its notes and skills but never a learned workflow, and asked for no
|
|
50
|
+
* workflow draft at its end; `gradeModel`, the model the
|
|
49
51
|
* server names to grade what the run proposes (learning.ts gradeModelOf: --grade-model, else AGENTRUN_SERVE_GRADE_MODEL,
|
|
50
52
|
* else AGENT_MODEL_STRONG), absent when it names none and the agent's own grades it; and `seedFailed`, why it starts with
|
|
51
53
|
* nothing learned when it does (SeedFailed). Absent when the run does not learn. */
|
|
@@ -59,6 +61,7 @@ export interface RunLaunch {
|
|
|
59
61
|
readonly seedNotes?: number;
|
|
60
62
|
readonly skills?: readonly string[];
|
|
61
63
|
readonly workflows?: readonly string[];
|
|
64
|
+
readonly notesOnly?: true;
|
|
62
65
|
readonly gradeModel?: string;
|
|
63
66
|
readonly seedFailed?: SeedFailed;
|
|
64
67
|
};
|
|
@@ -68,6 +71,16 @@ export interface RunLaunch {
|
|
|
68
71
|
readonly inputOrigin?: MessageOrigin;
|
|
69
72
|
/** A run that re-asks its agent after it ends (a trigger's follow-up). */
|
|
70
73
|
readonly followUp?: boolean;
|
|
74
|
+
/** The Archil disk the run keeps its folder on (Archil mode), chosen at its start: the one its launch named (`launch`, a
|
|
75
|
+
* customer's disk agentrun never makes or removes), or its agent's when the agent had one then (`agent`). Absent, the
|
|
76
|
+
* run uses its agent's disk, made at its claim when the agent has none (workspace/run-disk.ts). Kept here so every
|
|
77
|
+
* claim, revoke and reclaim of the run, after a restart too, acts on that one disk. */
|
|
78
|
+
readonly archilDisk?: LaunchDisk;
|
|
79
|
+
}
|
|
80
|
+
/** The disk a launch record names, and whose it is. */
|
|
81
|
+
export interface LaunchDisk {
|
|
82
|
+
readonly diskId: string;
|
|
83
|
+
readonly kind: "launch" | "agent";
|
|
71
84
|
}
|
|
72
85
|
/** The input's origin kept through the fail-safe (#1856): the stored one only if it names `trigger` with
|
|
73
86
|
* owner === (its source is a schedule), else that trigger's own with owner false (its source a best-effort label: the
|
package/dist/run-launch.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
// that trigger's own with owner false, so a forged or lost origin never reads as the person's or the owner's.
|
|
9
9
|
import { originOf } from "./timeline/index.js";
|
|
10
10
|
import { isObject } from "./validate.js";
|
|
11
|
+
/** The disk a launch body names, as read back, or undefined. */
|
|
12
|
+
const readDisk = (value) => isObject(value) && typeof value.disk_id === "string" && (value.kind === "launch" || value.kind === "agent") ? { diskId: value.disk_id, kind: value.kind } : undefined;
|
|
11
13
|
/** The trigger a launch body names, as read back: `{ id, firing_key }`, or null (triggerOf of the old serve.json). */
|
|
12
14
|
function readTrigger(value) {
|
|
13
15
|
return isObject(value) && typeof value.id === "string" && typeof value.firing_key === "string" ? { id: value.id, firing_key: value.firing_key } : null;
|
|
@@ -56,10 +58,11 @@ export function launchBody(launch) {
|
|
|
56
58
|
...(launch.boxAllow !== undefined ? { box_allow: launch.boxAllow } : {}),
|
|
57
59
|
...(launch.boxAllowSet ? { box_allow_set: true } : {}),
|
|
58
60
|
...(launch.files?.length ? { files: launch.files } : {}),
|
|
59
|
-
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}) } } : {}),
|
|
61
|
+
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.notesOnly ? { notesOnly: true } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}) } } : {}),
|
|
60
62
|
...(launch.trigger ? { trigger: launch.trigger } : {}),
|
|
61
63
|
...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
|
|
62
64
|
...(launch.followUp ? { follow_up: true } : {}),
|
|
65
|
+
...(launch.archilDisk ? { archil_disk: { disk_id: launch.archilDisk.diskId, kind: launch.archilDisk.kind } } : {}),
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
/** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha, its # Learned
|
|
@@ -73,7 +76,7 @@ function readLearning(value) {
|
|
|
73
76
|
const section = typeof value.section === "string" ? value.section : "";
|
|
74
77
|
const names = (list) => (Array.isArray(list) ? list.filter((name) => typeof name === "string") : []);
|
|
75
78
|
const [skills, workflows] = [names(value.skills), names(value.workflows)];
|
|
76
|
-
return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}), ...(typeof value.gradeModel === "string" && value.gradeModel !== "" ? { gradeModel: value.gradeModel } : {}), ...(typeof value.seedFailed === "string" && SEED_FAILURES.includes(value.seedFailed) ? { seedFailed: value.seedFailed } : {}) };
|
|
79
|
+
return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}), ...(value.notesOnly === true ? { notesOnly: true } : {}), ...(typeof value.gradeModel === "string" && value.gradeModel !== "" ? { gradeModel: value.gradeModel } : {}), ...(typeof value.seedFailed === "string" && SEED_FAILURES.includes(value.seedFailed) ? { seedFailed: value.seedFailed } : {}) };
|
|
77
80
|
}
|
|
78
81
|
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
79
82
|
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
@@ -87,6 +90,7 @@ export function readLaunchBody(stored) {
|
|
|
87
90
|
const inputOrigin = keepInputOrigin(stored.input_origin, trigger);
|
|
88
91
|
const model = readModel(stored.model);
|
|
89
92
|
const boxAllow = readBoxAllow(stored.box_allow);
|
|
93
|
+
const archilDisk = readDisk(stored.archil_disk);
|
|
90
94
|
return {
|
|
91
95
|
input: stored.input,
|
|
92
96
|
title: typeof stored.title === "string" ? stored.title : "",
|
|
@@ -106,6 +110,7 @@ export function readLaunchBody(stored) {
|
|
|
106
110
|
...(trigger ? { trigger } : {}),
|
|
107
111
|
...(inputOrigin ? { inputOrigin } : {}),
|
|
108
112
|
...(stored.follow_up === true ? { followUp: true } : {}),
|
|
113
|
+
...(archilDisk ? { archilDisk } : {}),
|
|
109
114
|
};
|
|
110
115
|
}
|
|
111
116
|
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
@@ -54,7 +54,7 @@ export declare function servedRunLearning(deps: {
|
|
|
54
54
|
workflows?: import("./learning.js").LearnedFile[];
|
|
55
55
|
run: string;
|
|
56
56
|
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
57
|
-
reason: "
|
|
57
|
+
reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
58
58
|
detail: string | null;
|
|
59
59
|
at: string;
|
|
60
60
|
} | null>;
|
package/dist/run-manifest.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Workspace } from "./workspace/index.js";
|
|
2
2
|
/** The most files the line names; the rest are counted. */
|
|
3
3
|
export declare const MANIFEST_ENTRIES = 20;
|
|
4
|
-
/** The most the first message may take, as the JSON string the run's door is sent:
|
|
5
|
-
* at most 1 MiB
|
|
4
|
+
/** The most the first message may take, as the JSON string the run's door is sent: a door takes a body of
|
|
5
|
+
* at most 1 MiB, and this leaves room for the request's other fields. */
|
|
6
6
|
export declare const FIRST_MESSAGE_BYTES: number;
|
|
7
7
|
/** `bytes` as a person reads a size: `32 B`, `1.5 KB`, `2.0 MB`. */
|
|
8
8
|
export declare const sizeOf: (bytes: number) => string;
|
package/dist/run-manifest.js
CHANGED
|
@@ -7,8 +7,8 @@ import { INPUTS_DIR } from "./uploads.js";
|
|
|
7
7
|
import { workspaceAt } from "./workspace/index.js";
|
|
8
8
|
/** The most files the line names; the rest are counted. */
|
|
9
9
|
export const MANIFEST_ENTRIES = 20;
|
|
10
|
-
/** The most the first message may take, as the JSON string the run's door is sent:
|
|
11
|
-
* at most 1 MiB
|
|
10
|
+
/** The most the first message may take, as the JSON string the run's door is sent: a door takes a body of
|
|
11
|
+
* at most 1 MiB, and this leaves room for the request's other fields. */
|
|
12
12
|
export const FIRST_MESSAGE_BYTES = (1 << 20) - 4096;
|
|
13
13
|
/** `bytes` as a person reads a size: `32 B`, `1.5 KB`, `2.0 MB`. */
|
|
14
14
|
export const sizeOf = (bytes) => bytes < 1024 ? `${bytes} B` : bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
package/dist/run-secrets.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { harnessModelKeys } from "./adapters.js";
|
|
2
|
-
import { BOX_KEYS } from "./
|
|
2
|
+
import { BOX_KEYS } from "./place-offers.js";
|
|
3
3
|
import { providersNamed } from "./decisions.js";
|
|
4
4
|
import { harnessOfBody } from "./harness.js";
|
|
5
5
|
import { harnessOf } from "./harness-table.js";
|
|
@@ -8,8 +8,8 @@ import { DECISION_KEYS, SECRET_NAMES } from "./secrets.js";
|
|
|
8
8
|
import { TOOL_KEYS } from "./tool-keys.js";
|
|
9
9
|
import { workflowTools } from "./tools.js";
|
|
10
10
|
/** The server's own secrets, which a run never gets: the API token, by name or by value, the seal key the tool keys are
|
|
11
|
-
* kept under (tool-keys.ts), the store's URL (it may hold the database's password), and the boxes' keys
|
|
12
|
-
* which only the server's
|
|
11
|
+
* kept under (tool-keys.ts), the store's URL (it may hold the database's password), and the remote boxes' keys
|
|
12
|
+
* (place-offers.ts BOX_KEYS), which only the server's computer providers use. */
|
|
13
13
|
const SERVER_ONLY = new Set(["AGENTRUN_TOKEN", "AGENTRUN_API_KEY", "AGENTRUN_SEAL_KEY", "AGENTRUN_STORE_URL", ...BOX_KEYS]);
|
|
14
14
|
/** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
|
|
15
15
|
export const RUN_SECRETS = SECRET_NAMES.filter((name) => !SERVER_ONLY.has(name) && !DECISION_KEYS.includes(name));
|
|
@@ -4,7 +4,7 @@ import { currentLearning, holdsForOk, secretsShown } from "./learning.js";
|
|
|
4
4
|
import { withLearning } from "./learning-run.js";
|
|
5
5
|
import { runLearningEnd } from "./store-reads/learning.js";
|
|
6
6
|
import { redacted } from "./key-refusal.js";
|
|
7
|
-
import { runCutValues, runErrorWordsOf } from "./run-cut.js";
|
|
7
|
+
import { runCutValues, runErrorWordsOf, underCut } from "./run-cut.js";
|
|
8
8
|
import { answersOf, asksOf, shownOf, withApprovalRows, withAsks, withBudgetRows, withOverCap } from "./run-view.js";
|
|
9
9
|
import { launchOf } from "./handed-values.js";
|
|
10
10
|
import { capNowOf } from "./runner/journal-kinds.js";
|
|
@@ -17,57 +17,69 @@ import { FINAL_STATES } from "./store/store.js";
|
|
|
17
17
|
/** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
|
|
18
18
|
* run's error's words; none for a run withheld. */
|
|
19
19
|
export async function servedTimelineRows(deps, store, runId, context) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// The run's rows, its decisions, its learning end and the triggers' names, all read in one snapshot of the store (one
|
|
21
|
+
// moment, whatever the run's runner writes meanwhile): a row from before an answer never sits beside one from after it.
|
|
22
|
+
// They are rendered under the run's cut, which is read before the snapshot and again after it (underCut): the cut only
|
|
23
|
+
// grows, so a cut that is the same after holds every value saved before the rows were read.
|
|
24
|
+
const read = await underCut(() => runCutValues(deps, store, runId), async (cut) => {
|
|
25
|
+
if (cut === "unreadable")
|
|
26
|
+
return undefined;
|
|
27
|
+
const { values } = cut;
|
|
28
|
+
const redact = (text) => redacted(text, values);
|
|
29
|
+
return { values, redact, ...(await store.snapshot(async (snapshot) => {
|
|
30
|
+
// The rows a person reads: each call that waited for approval in order (held, your approval, what came of it), its
|
|
31
|
+
// arguments and the person's notes through the cut (run-view.ts withApprovalRows), as main's served Timeline read them.
|
|
32
|
+
// A call asked before an end in the journal reads withdrawn in that end's words; a stopped or failed run's (states no
|
|
33
|
+
// reopen leaves) whose journal holds no end, by its row (answersOf `final`).
|
|
34
|
+
const run = await snapshot.runs.get(runId);
|
|
35
|
+
const ended = run ? FINAL_STATES.includes(run.state) : false;
|
|
36
|
+
const records = await journalRecords(snapshot.readJournal(runId), context);
|
|
37
|
+
const final = run?.state === "stopped" || run?.state === "failed" ? run.state : undefined;
|
|
38
|
+
// A question the agent asked (ask_person) and waits on: its waiting row after the call's result (run-view.ts withAsks), as
|
|
39
|
+
// the run's view carries it and main's served Timeline did, so the console's "The agent asks" box reads that question,
|
|
40
|
+
// never an earlier wait's words.
|
|
41
|
+
// Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
|
|
42
|
+
// A run that ended is read settled, as its view reads it: nothing of it is in flight, so a request it left unanswered
|
|
43
|
+
// is a cost unknown, never one still running.
|
|
44
|
+
const options = { redact, settled: ended };
|
|
45
|
+
const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values));
|
|
46
|
+
// A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
|
|
47
|
+
// served Timeline did): at the cap as it stands (a raise taken counts, capNowOf), a cache miss within the bound of the
|
|
48
|
+
// requests since its spend last fit said as one (overCapBound).
|
|
49
|
+
const capNow = capNowOf((await launchOf(snapshot, runId))?.maxCostUsd, records.entries);
|
|
50
|
+
const overCap = capNow === undefined ? timeline : withOverCap(timeline, capNow, overCapBound(records.entries, capNow));
|
|
51
|
+
// Each pause at its cap shown as the server's row, and the one it stands at now as its waiting row (withBudgetRows).
|
|
52
|
+
const capped = withBudgetRows(overCap, records.entries, { ended });
|
|
53
|
+
const rows = withApprovalRows(withAsks(capped), asksOf(records.entries), answersOf(records.entries, { final }), redact);
|
|
54
|
+
// A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
|
|
55
|
+
// characters held back from a text stored cut as a held value takes in its widest form (main's decisionShown).
|
|
56
|
+
const receipts = await decisionsOverStore(snapshot, runId, context).catch(() => null);
|
|
57
|
+
const decisionShown = { redact: (text) => redacted(text, values), hold: 6 * values.reduce((most, value) => Math.max(most, value.length), 0) + 16 };
|
|
58
|
+
const own = receipts === null || receipts.length ? withDecisions(rows, receipts, decisionShown, { ended }) : rows;
|
|
59
|
+
// The run's learning end, once its learning was proposed, merged or dropped (runLearningEnd).
|
|
60
|
+
const end = await runLearningEnd(snapshot, runId);
|
|
61
|
+
// Each trigger the rows name, read once for this read: its name now, or none for one gone.
|
|
62
|
+
const names = new Map();
|
|
63
|
+
for (const row of own)
|
|
64
|
+
if (row.trigger && !names.has(row.trigger.id))
|
|
65
|
+
names.set(row.trigger.id, (await snapshot.triggers.get(row.trigger.id))?.name);
|
|
66
|
+
return { run, own, end, names };
|
|
67
|
+
})) };
|
|
68
|
+
});
|
|
69
|
+
if (!read)
|
|
22
70
|
return [];
|
|
23
|
-
const { values } =
|
|
24
|
-
const redact = (text) => redacted(text, values);
|
|
25
|
-
// The rows a person reads: each call that waited for approval in order (held, your approval, what came of it), its
|
|
26
|
-
// arguments and the person's notes through the cut (run-view.ts withApprovalRows), as main's served Timeline read them.
|
|
27
|
-
// A call asked before an end in the journal reads withdrawn in that end's words; a stopped or failed run's (states no
|
|
28
|
-
// reopen leaves) whose journal holds no end, by its row (answersOf `final`).
|
|
29
|
-
const run = await store.runs.get(runId);
|
|
30
|
-
const ended = run ? FINAL_STATES.includes(run.state) : false;
|
|
31
|
-
const records = await journalRecords(store.readJournal(runId), context);
|
|
32
|
-
const final = run?.state === "stopped" || run?.state === "failed" ? run.state : undefined;
|
|
33
|
-
// A question the agent asked (ask_person) and waits on: its waiting row after the call's result (run-view.ts withAsks), as
|
|
34
|
-
// the run's view carries it and main's served Timeline did, so the console's "The agent asks" box reads that question,
|
|
35
|
-
// never an earlier wait's words.
|
|
36
|
-
// Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
|
|
37
|
-
// A run that ended is read settled, as its view reads it: nothing of it is in flight, so a request it left unanswered
|
|
38
|
-
// is a cost unknown, never one still running.
|
|
39
|
-
const options = { redact, settled: ended };
|
|
40
|
-
const timeline = await wholeAnswers(store, runId, context, await runTimeline(store, runId, context, options), options, wholeAnswerFor(values));
|
|
41
|
-
// A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
|
|
42
|
-
// served Timeline did): at the cap as it stands (a raise taken counts, capNowOf), a cache miss within the bound of the
|
|
43
|
-
// requests since its spend last fit said as one (overCapBound).
|
|
44
|
-
const capNow = capNowOf((await launchOf(store, runId))?.maxCostUsd, records.entries);
|
|
45
|
-
const overCap = capNow === undefined ? timeline : withOverCap(timeline, capNow, overCapBound(records.entries, capNow));
|
|
46
|
-
// Each pause at its cap shown as the server's row, and the one it stands at now as its waiting row (withBudgetRows).
|
|
47
|
-
const capped = withBudgetRows(overCap, records.entries, { ended });
|
|
48
|
-
const rows = withApprovalRows(withAsks(capped), asksOf(records.entries), answersOf(records.entries, { final }), redact);
|
|
49
|
-
// A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
|
|
50
|
-
// characters held back from a text stored cut as a held value takes in its widest form (main's decisionShown).
|
|
51
|
-
const receipts = await decisionsOverStore(store, runId, context).catch(() => null);
|
|
52
|
-
const decisionShown = { redact: (text) => redacted(text, values), hold: 6 * values.reduce((most, value) => Math.max(most, value.length), 0) + 16 };
|
|
53
|
-
const own = receipts === null || receipts.length ? withDecisions(rows, receipts, decisionShown, { ended }) : rows;
|
|
71
|
+
const { values, redact, run, own, end, names } = read;
|
|
54
72
|
// An error row reads as the run's error does (run-cut.ts runErrorWordsOf, main's errorWords): a refused key in plain
|
|
55
|
-
// words, else no held value and no loopback address.
|
|
73
|
+
// words, else no held value and no loopback address. Read after the snapshot, through the server's own handles (the
|
|
74
|
+
// agent's sign-ins), which the snapshot's connection would hold up.
|
|
56
75
|
const workflow = (await readRun(store, runId, context))?.kind === "workflow";
|
|
57
76
|
const words = await runErrorWordsOf(deps, store, runId, { workflow });
|
|
58
77
|
if (words === "unreadable")
|
|
59
78
|
return [];
|
|
60
|
-
// The run's learning row
|
|
61
|
-
//
|
|
62
|
-
// folder's main), its words cut by the same set.
|
|
63
|
-
const end = await runLearningEnd(store, runId);
|
|
79
|
+
// The run's learning row (learning-run.ts withLearning, main's row): what the end held for the owner's OK read as the run's
|
|
80
|
+
// view reads it (on its agent's folder's main), its words cut by the same set.
|
|
64
81
|
const learning = end ? (holdsForOk(end) && run && deps.statuses ? currentLearning(end, await deps.statuses(run.agentId)) : end) : undefined;
|
|
65
82
|
const learned = withLearning(own, learning, secretsShown(values));
|
|
66
|
-
// Each trigger the rows name, read once for this read: its name now, or none for one gone.
|
|
67
|
-
const names = new Map();
|
|
68
|
-
for (const row of learned)
|
|
69
|
-
if (row.trigger && !names.has(row.trigger.id))
|
|
70
|
-
names.set(row.trigger.id, (await store.triggers.get(row.trigger.id))?.name);
|
|
71
83
|
// A refused key's plain words are its summary and its text alike; any other error keeps each in the one rule.
|
|
72
84
|
const shown = shownOf(values);
|
|
73
85
|
return learned.map((row) => {
|
package/dist/run-view.d.ts
CHANGED
|
@@ -349,6 +349,9 @@ export interface RunMoment {
|
|
|
349
349
|
readonly waitingApprovalId?: string;
|
|
350
350
|
/** The tool calls this run has or had waiting for approval, by id (for the not-found refusal). */
|
|
351
351
|
readonly approvalIds?: ReadonlySet<string>;
|
|
352
|
+
/** What is archived of it, when anything is: its agent, else the run itself. Archiving closes a run: it takes no message
|
|
353
|
+
* (runs-over-store.ts message). Absent when neither is. */
|
|
354
|
+
readonly archived?: "run" | "agent";
|
|
352
355
|
/** The approvals already answered, by call id, as the run view folds them (for the first-wins refusal and its words). */
|
|
353
356
|
readonly answeredApprovals?: Readonly<Record<string, {
|
|
354
357
|
readonly decision: ApprovalDecision;
|
|
@@ -373,7 +376,7 @@ export declare const WITHHELD_TITLE = "Withheld: a sign-in this run used can't b
|
|
|
373
376
|
* hidden or withheld, never served uncut, and forget waits for it while it goes. */
|
|
374
377
|
export declare const MALFORMED = "malformed";
|
|
375
378
|
export type Handed = string[] | typeof MALFORMED;
|
|
376
|
-
/** A run's `sign_in_handed` as read from its
|
|
379
|
+
/** A run's `sign_in_handed` as read from its stored row: undefined when absent (never handed one); the hashes it names;
|
|
377
380
|
* MALFORMED for any other value. */
|
|
378
381
|
export declare function handedMark(value: unknown): Handed | undefined;
|
|
379
382
|
/** A run's redactor (decision-rows.ts, tool previews): redacted over its refused values. */
|
|
@@ -403,7 +406,7 @@ export declare const servedReviewWith: <R extends {
|
|
|
403
406
|
export declare function handedPointers(signIns: SignInReader | undefined, agentId: string, browser: string | undefined, handed: Handed | undefined): Promise<{
|
|
404
407
|
refs: string[];
|
|
405
408
|
} | "unreadable">;
|
|
406
|
-
/** shown() for a run this server holds no Run for (an ended one a list reads from its row and
|
|
409
|
+
/** shown() for a run this server holds no Run for (an ended one a list reads from its row and journal alone): cut of
|
|
407
410
|
* every secret this server never shows (serverSecrets) and of what the run was handed of its agent's sign-in
|
|
408
411
|
* (handedPointers); `withheld` when that can't be read back here, as a load would hide the run. `browser` and `handed`
|
|
409
412
|
* come from the run's record (its plane's vendor browser and its `sign_in_handed` mark); `damaged` when the record was
|
package/dist/run-view.js
CHANGED
|
@@ -263,7 +263,8 @@ export function budgetOf(entries, run) {
|
|
|
263
263
|
const figures = p.spent_usd !== undefined && p.needs_usd !== undefined
|
|
264
264
|
? { spent_usd: micro(p.spent_usd), needs_usd: micro(p.needs_usd), ...(p.least_cap_usd !== undefined ? { least_cap_usd: p.least_cap_usd } : {}), suggested_cap_usd: suggestedCap(cap, p.spent_usd, p.needs_usd), overshoot_bound_usd: microUp(0) }
|
|
265
265
|
: {};
|
|
266
|
-
|
|
266
|
+
// A workflow's pause names the node whose step waits (null when not known); an agentic run's names none.
|
|
267
|
+
return { kind: "budget", cap_usd: cap, ...figures, said: mark.words, at: meaningful(run.rows)?.timestamp ?? run.updatedAt, ...(mark.node !== undefined ? { node: mark.node } : {}) };
|
|
267
268
|
}
|
|
268
269
|
/** Read only on a run's `rows`, which hold no QUIET row (take). */
|
|
269
270
|
const shows = (r) => r.kind !== "usage" && r.kind !== "phase";
|
|
@@ -480,7 +481,7 @@ export const WITHHELD_TITLE = "Withheld: a sign-in this run used can't be read";
|
|
|
480
481
|
* hash an older build wrote, or a damaged value) reads as: some pointer was handed, which one is not known, so the run is
|
|
481
482
|
* hidden or withheld, never served uncut, and forget waits for it while it goes. */
|
|
482
483
|
export const MALFORMED = "malformed";
|
|
483
|
-
/** A run's `sign_in_handed` as read from its
|
|
484
|
+
/** A run's `sign_in_handed` as read from its stored row: undefined when absent (never handed one); the hashes it names;
|
|
484
485
|
* MALFORMED for any other value. */
|
|
485
486
|
export function handedMark(value) {
|
|
486
487
|
if (value === undefined)
|
|
@@ -526,7 +527,7 @@ export async function handedPointers(signIns, agentId, browser, handed) {
|
|
|
526
527
|
const refs = handed.map((hash) => kept.find((ref) => pointerHash(ref) === hash));
|
|
527
528
|
return refs.every((ref) => ref !== undefined) ? { refs: refs } : "unreadable";
|
|
528
529
|
}
|
|
529
|
-
/** shown() for a run this server holds no Run for (an ended one a list reads from its row and
|
|
530
|
+
/** shown() for a run this server holds no Run for (an ended one a list reads from its row and journal alone): cut of
|
|
530
531
|
* every secret this server never shows (serverSecrets) and of what the run was handed of its agent's sign-in
|
|
531
532
|
* (handedPointers); `withheld` when that can't be read back here, as a load would hide the run. `browser` and `handed`
|
|
532
533
|
* come from the run's record (its plane's vendor browser and its `sign_in_handed` mark); `damaged` when the record was
|
package/dist/runnable.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type InputIssue } from "./errors.js";
|
|
2
2
|
import { type HarnessCapability } from "./harness.js";
|
|
3
3
|
import { type ModelRef } from "./model.js";
|
|
4
|
-
import type { BoxOffer } from "./
|
|
4
|
+
import type { BoxOffer } from "./place-offers.js";
|
|
5
5
|
import { type ToolSettingsMap } from "./tool-plane.js";
|
|
6
6
|
import type { McpTool } from "@parcha/agentrun-kernel";
|
|
7
7
|
import type { ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -99,7 +99,7 @@ export declare const NOT_SET_UP = "not_set_up_here";
|
|
|
99
99
|
* `new Function` transform, which is no sandbox. Off by default. */
|
|
100
100
|
export declare const CODE_NODES_ENV = "AGENTRUN_SERVE_CODE_NODES";
|
|
101
101
|
/** What keeps `revision` from running in `env` under the server's tool `settings` (tool-plane.ts). `boxes`: what this
|
|
102
|
-
* server
|
|
102
|
+
* server found at its start (place-offers.ts); none, every box is unavailable. `offers`: the harnesses' offers
|
|
103
103
|
* the server already holds (its reading); none given, they are probed here. `computerReady`: whether an agent's computer
|
|
104
104
|
* setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check.
|
|
105
105
|
* `shellOf`: where a run of an agent with that computer setting has its shell here now (resolve-computer.ts
|
package/dist/runnable.js
CHANGED
|
@@ -54,7 +54,7 @@ const PRICE_FIX = "Set AGENT_MODEL_PRICE (USD per million input,output,cacheRead
|
|
|
54
54
|
* `new Function` transform, which is no sandbox. Off by default. */
|
|
55
55
|
export const CODE_NODES_ENV = "AGENTRUN_SERVE_CODE_NODES";
|
|
56
56
|
/** What keeps `revision` from running in `env` under the server's tool `settings` (tool-plane.ts). `boxes`: what this
|
|
57
|
-
* server
|
|
57
|
+
* server found at its start (place-offers.ts); none, every box is unavailable. `offers`: the harnesses' offers
|
|
58
58
|
* the server already holds (its reading); none given, they are probed here. `computerReady`: whether an agent's computer
|
|
59
59
|
* setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check.
|
|
60
60
|
* `shellOf`: where a run of an agent with that computer setting has its shell here now (resolve-computer.ts
|
|
@@ -160,6 +160,7 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
160
160
|
return undefined;
|
|
161
161
|
};
|
|
162
162
|
if (revision.kind === "agentic") {
|
|
163
|
+
const browserComputer = revision.computer?.kind === "browser";
|
|
163
164
|
if (!revision.instructions.trim())
|
|
164
165
|
out.push({ field: "definition.instructions", reason: "too_short", message: "definition.instructions is empty: an agentic revision needs instructions.", host: false });
|
|
165
166
|
(revision.tools ?? []).forEach((tool, index) => {
|
|
@@ -184,7 +185,10 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
184
185
|
out.push({ field: `definition.tools[${index}]`, reason: NOT_SET_UP, message: `${tool} runs on pi here; on ${harness} it is not bound yet.`, host: true, tool });
|
|
185
186
|
else {
|
|
186
187
|
unset(`definition.tools[${index}]`, tool);
|
|
187
|
-
|
|
188
|
+
// The browser of an agent whose computer is a browser is that computer (tools.ts browserComputer), on the keys
|
|
189
|
+
// saved for it in Settings → Computers and checked as its readiness above: the tool plane's vendor is not asked.
|
|
190
|
+
if (!(tool === "browser" && browserComputer))
|
|
191
|
+
unavailable(`definition.tools[${index}]`, revision.tools ?? [], tool);
|
|
188
192
|
}
|
|
189
193
|
});
|
|
190
194
|
// The tool-call budget is counted from pi's own journal (tool-budget.ts): on another harness it would hold nothing, so
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConversationId, Harness, type Tx } from "@earendil-works/pi-durable";
|
|
1
|
+
import { type ConversationId, type ConversationRetryPolicy, type ConversationStreamOptions, Harness, type Tx } from "@earendil-works/pi-durable";
|
|
2
2
|
import { type AgentAdapter, type Refusal, type SessionRecord, type SessionSpec } from "@parcha/agentrun-kernel";
|
|
3
3
|
import type { KernelHooks, ToolCall } from "./conformance/subject.js";
|
|
4
4
|
import { type ApprovalPrice, type BudgetData, type EndData } from "./journal-kinds.js";
|
|
@@ -175,6 +175,8 @@ export interface HostLifecycle {
|
|
|
175
175
|
* hold can no longer stand (the cap refused more of the person's time, or what it kept is gone), and the run parks. */
|
|
176
176
|
export interface PersonWait {
|
|
177
177
|
readonly lapsed: Promise<string>;
|
|
178
|
+
/** The run parked on this hold's lapse (not a lapse the answer's placement overrode): the host records why it let go. */
|
|
179
|
+
confirmed?(): void;
|
|
178
180
|
drop(): void;
|
|
179
181
|
}
|
|
180
182
|
/** A HostLifecycle and the ToolHost members that fill it: what a spec's ToolHost takes, and hands the loop. */
|
|
@@ -239,10 +241,23 @@ export interface RunLedger {
|
|
|
239
241
|
* must be on disk before the call's next step leaves the box (a browser session's open, before its vendor is asked). */
|
|
240
242
|
flush(): Promise<void>;
|
|
241
243
|
}
|
|
244
|
+
/** pi's retry of a model request that failed in a way it retries (a provider's 429, overload or 5xx, a dropped connection,
|
|
245
|
+
* a stream cut mid-answer): up to 8 more attempts, 2s doubling to at most 30s apart (about two and a half minutes in all),
|
|
246
|
+
* so a provider's capacity outage of a minute or two is waited out, not the run's end. Each wait is the harness's own
|
|
247
|
+
* durable sleep; a subagent's conversation runs on the same settings. */
|
|
248
|
+
export declare const MODEL_RETRY: ConversationRetryPolicy;
|
|
249
|
+
/** pi-ai's retries inside one attempt, of a request the provider refused before any output (a 429 or a 5xx, through the
|
|
250
|
+
* session's proxy, which passes on its retry-after): after the wait the provider asked for, up to 30s, else its own short
|
|
251
|
+
* backoff. Each is a new request through the proxy, judged by the cap and booked as any other: a refusal books nothing. */
|
|
252
|
+
export declare const MODEL_STREAM: ConversationStreamOptions;
|
|
242
253
|
export interface AdapterLoopOptions {
|
|
243
254
|
/** How many times pi restarts a call's task cut off without progress before it ends it (restart_limit); finite.
|
|
244
255
|
* Default DEFAULT_RESTART_LIMIT. */
|
|
245
256
|
readonly restartLimit?: number;
|
|
257
|
+
/** pi's retry of a model request that failed retryably. Default MODEL_RETRY. */
|
|
258
|
+
readonly retry?: ConversationRetryPolicy;
|
|
259
|
+
/** pi-ai's retries inside one attempt. Default MODEL_STREAM. */
|
|
260
|
+
readonly stream?: ConversationStreamOptions;
|
|
246
261
|
/** The gate's clock (epoch ms): when an ask was asked and answered, and when a wait in the claim on the person's answer
|
|
247
262
|
* started. Default Date.now. */
|
|
248
263
|
readonly now?: () => number;
|