@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.34
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 +270 -0
- package/README.md +343 -246
- package/dist/adapters.d.ts +0 -7
- package/dist/adapters.js +11 -22
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +26 -0
- package/dist/box-settings.js +63 -0
- package/dist/boxes.d.ts +21 -1
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +94 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -53
- package/dist/browser-person.js +94 -279
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +8 -12
- package/dist/cap.js +12 -27
- package/dist/cli.js +61 -20
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +31 -3
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -11
- package/dist/files.js +2 -21
- package/dist/github-connection.d.ts +2 -2
- package/dist/github-connection.js +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +22 -5
- package/dist/harness-install.js +98 -20
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/harness.d.ts +4 -3
- package/dist/harness.js +16 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +62 -24
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +8 -1
- package/dist/learn/secrets.js +95 -15
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +37 -5
- package/dist/learned-workflow.js +106 -12
- package/dist/learning-routes.d.ts +16 -49
- package/dist/learning-routes.js +46 -36
- package/dist/learning-run.d.ts +6 -250
- package/dist/learning-run.js +11 -665
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +13 -3
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -52
- package/dist/mcp-gateway.js +44 -148
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +13 -15
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +124 -50
- package/dist/page.d.ts +1 -3
- package/dist/page.js +9 -19
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +28 -62
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -13
- package/dist/run-db.js +2 -41
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +46 -2
- package/dist/run-learning-served.js +26 -7
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +19 -5
- package/dist/run-view.d.ts +12 -17
- package/dist/run-view.js +29 -28
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +14 -3
- package/dist/runner/adapter-loop.js +464 -62
- package/dist/runner/adapter-run-spec.d.ts +29 -8
- package/dist/runner/adapter-run-spec.js +96 -37
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +15 -1
- package/dist/runner/adapters/pi.js +19 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +54 -12
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +49 -15
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +60 -17
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +30 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +64 -10
- package/dist/runner/main.js +165 -27
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +2 -3
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +154 -11
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +68 -26
- package/dist/runs-over-store.d.ts +8 -3
- package/dist/runs-over-store.js +76 -19
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +232 -82
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +10 -32
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -33
- package/dist/server.d.ts +26 -44
- package/dist/server.js +229 -142
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +3 -3
- package/dist/store/open.d.ts +18 -5
- package/dist/store/open.js +23 -3
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +27 -3
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +64 -20
- package/dist/store/store.d.ts +38 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +25 -6
- package/dist/store-reads/journal.js +173 -21
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +91 -23
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +9 -104
- package/dist/tool-keys.js +15 -271
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +31 -19
- package/dist/tools.js +101 -108
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +52 -5
- package/dist/workspace/computer-deps.js +154 -19
- package/dist/workspace/computer-for-claim.d.ts +19 -14
- package/dist/workspace/computer-for-claim.js +77 -16
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +4 -3
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +3 -99
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/README.md +9 -3
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -178
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/adapters.d.ts
CHANGED
|
@@ -81,9 +81,6 @@ export type AdapterNeeds = {
|
|
|
81
81
|
skills?: readonly SkillFiles[];
|
|
82
82
|
unpriced?: ReadonlySet<string>;
|
|
83
83
|
};
|
|
84
|
-
/** The ConfineChild that starts a child under `prefix` (the argv pi's commands start under, ending in "--"); none when
|
|
85
|
-
* the run confines nothing, since an adapter refuses a confinement that adds nothing. */
|
|
86
|
-
export declare function confineOf(prefix: readonly string[]): ConfineChild | undefined;
|
|
87
84
|
/** The model key a run on `harness` (one on an adapter, by its wire's route) of `model` (the revision's; none, the host's default for the
|
|
88
85
|
* harness) takes: the one its requests carry on the route its provider below takes, as key-refusal.ts' runKeyOf names
|
|
89
86
|
* it. codex: the gateway's when AGENT_MODEL_BASE_URL is set, else OpenAI's, or OpenRouter's on OpenRouter's route;
|
|
@@ -98,8 +95,6 @@ export declare function priceOf(needs: AdapterNeeds): (_model: string, usage: {
|
|
|
98
95
|
cacheRead?: number;
|
|
99
96
|
cacheWrite?: number;
|
|
100
97
|
}) => number | null;
|
|
101
|
-
/** The SDK version claude-agent pins: the one constant, the package's own (CLAUDE_AGENT_SDK_VERSION). */
|
|
102
|
-
export declare function claudeSdkVersion(load?: () => Promise<unknown>): Promise<string>;
|
|
103
98
|
/** What claude-agent's install needs (harness-install.ts HarnessPins): the pinned SDK version, and this platform's CLI package. */
|
|
104
99
|
export declare function claudePins(load?: () => Promise<unknown>): Promise<HarnessPins>;
|
|
105
100
|
/** What codex's install needs: the pinned Codex version (its adapter's one constant, CODEX_VERSION), and this platform's
|
|
@@ -137,8 +132,6 @@ export declare function codexOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds, loa
|
|
|
137
132
|
* its wire's do (providerFor): serve's gateway (AGENT_MODEL_BASE_URL), OpenAI or OpenRouter, on the Responses API,
|
|
138
133
|
* through the adapter's proxy. */
|
|
139
134
|
export declare function opencodeOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds, load?: () => Promise<typeof import("./harness-opencode/index.js")>, npx?: boolean): Promise<AgentAdapter>;
|
|
140
|
-
/** `harness`'s adapter for a run, as its entry in the harness table builds it (harness-table.ts). */
|
|
141
|
-
export declare function adapterFor(harness: string, env: NodeJS.ProcessEnv, needs: AdapterNeeds): Promise<AgentAdapter>;
|
|
142
135
|
/** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
|
|
143
136
|
* the adapter's own check of the model `given` names (with none, a model of its wire's vendor: whether it runs here at
|
|
144
137
|
* all). `atStart`: asked by the start's probe, whose offers hold until a restart, so a reason installing fixes ends
|
package/dist/adapters.js
CHANGED
|
@@ -15,7 +15,7 @@ import { DATA_ENV, defaultData } from "./files.js";
|
|
|
15
15
|
import { harnessOf, onAdapter } from "./harness-table.js";
|
|
16
16
|
import { HarnessUnavailable, providerFor } from "./provider.js";
|
|
17
17
|
import { keyShaped } from "./secret-cut.js";
|
|
18
|
-
import {
|
|
18
|
+
import { servedSkills } from "./learn/skills.js";
|
|
19
19
|
import { runKeyOf } from "./key-refusal.js";
|
|
20
20
|
import { planeOf } from "./tool-plane.js";
|
|
21
21
|
import { NATIVE_SEARCH_ALLOWANCE_TOKENS } from "./cap.js";
|
|
@@ -159,13 +159,6 @@ function unavailable(facts, error, npx, env) {
|
|
|
159
159
|
const hinted = installHint(said, facts.install.npmLine, facts.install.spec, npx, env);
|
|
160
160
|
return new HarnessUnavailable(hinted, hinted === said ? fixOf(facts, error) : undefined);
|
|
161
161
|
}
|
|
162
|
-
/** The ConfineChild that starts a child under `prefix` (the argv pi's commands start under, ending in "--"); none when
|
|
163
|
-
* the run confines nothing, since an adapter refuses a confinement that adds nothing. */
|
|
164
|
-
export function confineOf(prefix) {
|
|
165
|
-
if (!prefix.length)
|
|
166
|
-
return undefined;
|
|
167
|
-
return (child) => ({ command: prefix[0], args: [...prefix.slice(1), child.command, ...child.args] });
|
|
168
|
-
}
|
|
169
162
|
/** The model key a run on `harness` (one on an adapter, by its wire's route) of `model` (the revision's; none, the host's default for the
|
|
170
163
|
* harness) takes: the one its requests carry on the route its provider below takes, as key-refusal.ts' runKeyOf names
|
|
171
164
|
* it. codex: the gateway's when AGENT_MODEL_BASE_URL is set, else OpenAI's, or OpenRouter's on OpenRouter's route;
|
|
@@ -196,10 +189,6 @@ const CLAUDE_PACKAGE = "@parcha/agentrun-harness-claude";
|
|
|
196
189
|
const loadClaude = () => import(CLAUDE_PACKAGE);
|
|
197
190
|
/** This server's data, as `env` names it (the server sets it for itself and its runs). */
|
|
198
191
|
const dataOf = (env) => env[DATA_ENV] || defaultData(env);
|
|
199
|
-
/** The SDK version claude-agent pins: the one constant, the package's own (CLAUDE_AGENT_SDK_VERSION). */
|
|
200
|
-
export async function claudeSdkVersion(load = loadClaude) {
|
|
201
|
-
return (await load()).CLAUDE_AGENT_SDK_VERSION;
|
|
202
|
-
}
|
|
203
192
|
/** What claude-agent's install needs (harness-install.ts HarnessPins): the pinned SDK version, and this platform's CLI package. */
|
|
204
193
|
export async function claudePins(load = loadClaude) {
|
|
205
194
|
const claude = (await load());
|
|
@@ -265,6 +254,10 @@ export async function claudeOf(env, needs, load = loadClaude, sdkOf = (version,
|
|
|
265
254
|
// whoever bills it (its priceModel).
|
|
266
255
|
const endpoint = provider ? { origin: provider.origin, credential: provider.credential, auth: provider.auth } : { origin: "", credential: () => "" };
|
|
267
256
|
const priced = provider ? { ...needs, model: provider.priceModel } : native;
|
|
257
|
+
// Its CLI checked off the event loop first (hashed and run as a child), so the server goes on answering: a pass is
|
|
258
|
+
// kept, and the adapter's own check answers from it. A CLI that fails its pins is the adapter's to report, in its
|
|
259
|
+
// order (the SDK before the CLI).
|
|
260
|
+
await claude.verifyClaudeAgentCliAsync(sdk.cliPath);
|
|
268
261
|
// The skills only when there are some: with none, the adapter keeps its Skill tool off.
|
|
269
262
|
adapter = claude.claudeAgentAdapter({ model: { default: provider?.modelId ?? native.model.modelId }, provider: endpoint, price: priceOf(priced), log: harnessLog(claudeFacts.id, env), sdk: sdk.sdk, sdkVersion: sdk.sdkVersion, cliPath: sdk.cliPath, mcp: sdk.mcp, ...(needs.confine ? { confine: needs.confine } : {}), ...(needs.skills?.length ? { skills: needs.skills } : {}), ...nativeOptions(claudeFacts, env) });
|
|
270
263
|
}
|
|
@@ -296,7 +289,9 @@ export async function codexOf(env, needs, load = () => import("@parcha/agentrun-
|
|
|
296
289
|
throw new HarnessUnavailable(new HarnessNotInstalled(entry, dir, pins.version, existsSync(dir) ? `Codex in ${dir} is not whole: it lacks ${missing}` : undefined).message, "install");
|
|
297
290
|
binary = codexBinaryIn(dir, pins);
|
|
298
291
|
try {
|
|
299
|
-
|
|
292
|
+
// Off the event loop (the binary hashed and run as a child), so the server goes on answering; the adapter's own
|
|
293
|
+
// check then answers from what this kept.
|
|
294
|
+
await codex.verifyCodexAsync(binary);
|
|
300
295
|
}
|
|
301
296
|
catch (error) {
|
|
302
297
|
const line = installLine(dir, entry.lock);
|
|
@@ -318,7 +313,8 @@ export async function opencodeOf(env, needs, load = () => import("./harness-open
|
|
|
318
313
|
const standIn = env[OPENCODE_STANDIN_ENV] ? JSON.parse(env[OPENCODE_STANDIN_ENV]) : undefined;
|
|
319
314
|
if (!standIn) {
|
|
320
315
|
try {
|
|
321
|
-
|
|
316
|
+
// Off the event loop, as codexOf checks its binary; the adapter's own check then answers from what this kept.
|
|
317
|
+
await opencode.verifyOpenCodeAsync();
|
|
322
318
|
}
|
|
323
319
|
catch (error) {
|
|
324
320
|
// serve's own line, which installs the adapter with its pinned CLI, in place of the adapter's (the CLI alone).
|
|
@@ -333,16 +329,9 @@ export async function opencodeOf(env, needs, load = () => import("./harness-open
|
|
|
333
329
|
// Its instructions list each skill by the description its SKILL.md's front matter gives on one LF line, which is all the
|
|
334
330
|
// adapter reads: each SKILL.md goes as servedSkill writes it (its name and description, as a prompt reads them, on one
|
|
335
331
|
// line each), as a learned skill already does, so a CRLF file or a folded description is listed by its own words.
|
|
336
|
-
const skills = needs.skills
|
|
332
|
+
const skills = needs.skills && servedSkills(needs.skills);
|
|
337
333
|
return opencode.openCodeAdapter({ model: provider.modelId, provider: { origin: provider.origin, credential: provider.credential }, price: priceOf({ ...needs, model: provider.priceModel }), log: harnessLog(openCodeFacts.id, env), ...(needs.confine ? { confine: needs.confine } : {}), ...(skills?.length ? { skills } : {}), ...(standIn ? { standIn } : {}) });
|
|
338
334
|
}
|
|
339
|
-
/** `harness`'s adapter for a run, as its entry in the harness table builds it (harness-table.ts). */
|
|
340
|
-
export async function adapterFor(harness, env, needs) {
|
|
341
|
-
const make = harnessOf(env, harness)?.adapter;
|
|
342
|
-
if (!make)
|
|
343
|
-
throw new HarnessUnavailable(`This server does not run ${harness} yet.`);
|
|
344
|
-
return make(env, needs);
|
|
345
|
-
}
|
|
346
335
|
/** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
|
|
347
336
|
* the adapter's own check of the model `given` names (with none, a model of its wire's vendor: whether it runs here at
|
|
348
337
|
* all). `atStart`: asked by the start's probe, whose offers hold until a restart, so a reason installing fixes ends
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Workflow } from "@parcha/agentrun-dsl";
|
|
2
|
+
import type { ImportSource } from "./store-reads/analytics.js";
|
|
3
|
+
export type RevisionKind = "agentic" | "workflow";
|
|
4
|
+
/** Where a revision's runs execute: a mode and the box it uses, ids its host knows. */
|
|
5
|
+
export type RevisionPlace = {
|
|
6
|
+
mode: string;
|
|
7
|
+
box?: string;
|
|
8
|
+
};
|
|
9
|
+
/** The computer a revision's runs are given: a kind and the provider that serves it, ids its host knows. */
|
|
10
|
+
export type RevisionComputer = {
|
|
11
|
+
kind: string;
|
|
12
|
+
provider?: string;
|
|
13
|
+
};
|
|
14
|
+
/** An overlay's selection rule: the id of the `question` row it answers, the `option` this variant needs, and the least
|
|
15
|
+
* probability (`threshold`, 0 to 1) for that option. */
|
|
16
|
+
export type PromptRule = {
|
|
17
|
+
question: string;
|
|
18
|
+
option: string;
|
|
19
|
+
threshold: number;
|
|
20
|
+
};
|
|
21
|
+
/** A prompt variant, keyed by id: one `base`, one `generic`, any number of `overlay`s, and at most one `question`. */
|
|
22
|
+
export type PromptVariant = {
|
|
23
|
+
role: "base" | "overlay" | "generic" | "question";
|
|
24
|
+
label: string;
|
|
25
|
+
text: string;
|
|
26
|
+
when?: PromptRule;
|
|
27
|
+
criteria?: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
export type AgenticBody = {
|
|
30
|
+
instructions: string;
|
|
31
|
+
skills: Record<string, string>;
|
|
32
|
+
tools: string[];
|
|
33
|
+
model?: string;
|
|
34
|
+
thinking?: string;
|
|
35
|
+
prompts?: Record<string, PromptVariant>;
|
|
36
|
+
harness?: string;
|
|
37
|
+
place?: RevisionPlace;
|
|
38
|
+
computer?: RevisionComputer;
|
|
39
|
+
learning?: boolean;
|
|
40
|
+
toolSettings?: Record<string, Record<string, string>>;
|
|
41
|
+
approvals?: "never";
|
|
42
|
+
maxCostUsd?: number;
|
|
43
|
+
capMode?: string;
|
|
44
|
+
outputSchema?: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
export type WorkflowBody = {
|
|
47
|
+
workflow: Workflow;
|
|
48
|
+
skills: Record<string, string>;
|
|
49
|
+
tools: string[];
|
|
50
|
+
harness?: string;
|
|
51
|
+
place?: RevisionPlace;
|
|
52
|
+
computer?: RevisionComputer;
|
|
53
|
+
toolSettings?: Record<string, Record<string, string>>;
|
|
54
|
+
approvals?: "never";
|
|
55
|
+
maxCostUsd?: number;
|
|
56
|
+
capMode?: string;
|
|
57
|
+
};
|
|
58
|
+
/** A revision, written once: `body.skills` maps a skill path to the SHA-256 of its text. */
|
|
59
|
+
export type Revision = {
|
|
60
|
+
id: string;
|
|
61
|
+
agent: string;
|
|
62
|
+
parent: string | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
note?: string;
|
|
65
|
+
} & ({
|
|
66
|
+
kind: "agentic";
|
|
67
|
+
body: AgenticBody;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "workflow";
|
|
70
|
+
body: WorkflowBody;
|
|
71
|
+
});
|
|
72
|
+
export type RunState = "running" | "completed" | "failed" | "stopped" | "escalated";
|
|
73
|
+
/** Where an imported run came from: the harness that ran it on this machine, and its own session id. */
|
|
74
|
+
export type ImportedFrom = {
|
|
75
|
+
source: ImportSource;
|
|
76
|
+
session: string;
|
|
77
|
+
};
|
|
78
|
+
/** A run as a list reads it. `archivedAt`: when the run (or its agent) was archived; `importedFrom`: set on a run imported
|
|
79
|
+
* from another harness's session. */
|
|
80
|
+
export type RunRow = {
|
|
81
|
+
id: string;
|
|
82
|
+
agent: string;
|
|
83
|
+
revision: string;
|
|
84
|
+
kind: RevisionKind;
|
|
85
|
+
state: RunState;
|
|
86
|
+
startedAt: string;
|
|
87
|
+
endedAt?: string;
|
|
88
|
+
costUsd?: number;
|
|
89
|
+
summary?: string;
|
|
90
|
+
archivedAt?: string;
|
|
91
|
+
importedFrom?: ImportedFrom;
|
|
92
|
+
};
|
|
93
|
+
/** What starts a run: `key`, the caller's name for it (1 to 256 characters), and `fingerprint`, what was asked, kept to
|
|
94
|
+
* tell a retry from another request under the same key. */
|
|
95
|
+
export type RunOrigin = {
|
|
96
|
+
key: string;
|
|
97
|
+
fingerprint?: string;
|
|
98
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/agents-store.d.ts
CHANGED
|
@@ -62,8 +62,12 @@ export declare function makeRevision(definition: Json, files: Record<string, str
|
|
|
62
62
|
/** An edit: a new revision of the agent, made current. Without `skills` the current revision's skill files carry over. An
|
|
63
63
|
* edit that is the current revision writes nothing, so a PUT sent twice makes one revision. The agent keeps its id, name
|
|
64
64
|
* and description from its creation. `ifCurrent` (from If-Match) is the current revision the caller read, null for none;
|
|
65
|
-
* it is checked against the agent's current revision
|
|
66
|
-
*
|
|
65
|
+
* it is checked against the agent's current revision when the edit is read, and the write is conditional on the revision
|
|
66
|
+
* the edit was built on still being current, compared in the store's own transaction (addRevision's ifCurrent), so it
|
|
67
|
+
* holds across every server on the store. `check` may refuse the revision before a write; it runs outside the write, so
|
|
68
|
+
* another request may move the current revision meanwhile: an edit with If-Match is then precondition_failed, and one
|
|
69
|
+
* without is built and checked again on the new current revision, so what it leaves out (skill files, harness, place, learning, cap) is never carried over from a
|
|
70
|
+
* revision it does not follow. `contract`: an edit that always makes a new revision, even one equal to the current. */
|
|
67
71
|
export declare function commitAgent(store: AgentsStore, read: AgentEntry, { definition, skills, note }: DefinitionBody, { ifCurrent, check, contract }?: {
|
|
68
72
|
ifCurrent?: string | null;
|
|
69
73
|
check?: (revision: NewRevision) => Promise<void>;
|
package/dist/agents-store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The agents this server holds, over the one store (
|
|
2
|
-
//
|
|
1
|
+
// The agents this server holds, over the one store (store.agents); pi-durable-agent's agent-store.ts bodyOf and revisionOf
|
|
2
|
+
// are folded into store/agent-body.ts. An agent is a
|
|
3
3
|
// row with revisions written once; a definition is one revision; an edit commits the next and makes it current. A
|
|
4
4
|
// revision's body is checked by store/agent-body.ts before anything is written; its skill texts ride on the revision's row.
|
|
5
5
|
// The one server per store (the owner lock) is the sole writer of agents and revisions, so a read-then-write here is not
|
|
@@ -12,7 +12,7 @@ import { approvalsOf } from "./approvals.js";
|
|
|
12
12
|
import { ApiError, invalid } from "./errors.js";
|
|
13
13
|
import { harnessOfBody } from "./harness.js";
|
|
14
14
|
import { storedHarness } from "./harness-table.js";
|
|
15
|
-
import { AgentBodyInvalid, bodyOf, canonical, isObject, StoreConstraint, } from "./store/index.js";
|
|
15
|
+
import { AgentBodyInvalid, RevisionMoved, bodyOf, canonical, isObject, StoreConstraint, } from "./store/index.js";
|
|
16
16
|
import { canonicalToolSettings, settingsIssues } from "./tool-plane.js";
|
|
17
17
|
import { computerOfPlace, settingOfDefinition } from "./computer-setting.js";
|
|
18
18
|
import { skillIssues, skillNames } from "./validate.js";
|
|
@@ -70,7 +70,7 @@ export function externalOf(agent, revision) {
|
|
|
70
70
|
/** A definition's tool settings as a revision body keeps them, through the one copy: checked by tool-plane's settingsIssues
|
|
71
71
|
* (a refusal is an input error) and made canonical by canonicalToolSettings (sorted keys, empty tools dropped, a pin's
|
|
72
72
|
* arguments sorted). `{ toolSettings }` when any survive, `{}` when none. Whether an agent may set its own pin is the
|
|
73
|
-
* request layer's gate (validate.ts
|
|
73
|
+
* request layer's gate (validate.ts); here a pin that reaches this is kept canonical. */
|
|
74
74
|
function toolSettingsOf(given) {
|
|
75
75
|
if (!isObject(given))
|
|
76
76
|
return {};
|
|
@@ -82,7 +82,7 @@ function toolSettingsOf(given) {
|
|
|
82
82
|
return Object.keys(canonical).length ? { toolSettings: canonical } : {};
|
|
83
83
|
}
|
|
84
84
|
/** The revision a checked definition makes, in the store's shape (store/agent-body.ts's input), ready for bodyOf. `files`
|
|
85
|
-
* are the skill files by path.
|
|
85
|
+
* are the skill files by path. */
|
|
86
86
|
function revisionInputOf(definition, files) {
|
|
87
87
|
const issues = skillIssues(definition.skills, Object.keys(files));
|
|
88
88
|
if (issues.length)
|
|
@@ -113,6 +113,7 @@ function revisionInputOf(definition, files) {
|
|
|
113
113
|
...(typeof definition.model === "string" ? { model: definition.model } : {}),
|
|
114
114
|
...(typeof definition.thinking === "string" ? { thinking: definition.thinking } : {}),
|
|
115
115
|
...(definition.approvals === "ask" || definition.approvals === "never" ? { approvals: definition.approvals } : {}),
|
|
116
|
+
...(isObject(definition.output_schema) ? { outputSchema: definition.output_schema } : {}),
|
|
116
117
|
...common,
|
|
117
118
|
...learning,
|
|
118
119
|
...capped,
|
|
@@ -208,17 +209,27 @@ export function makeRevision(definition, files, note) {
|
|
|
208
209
|
}
|
|
209
210
|
return note !== undefined ? { ...revision, note } : revision;
|
|
210
211
|
}
|
|
212
|
+
/** How many times an edit with no If-Match is built again on a current revision that moved while it was checked. */
|
|
213
|
+
const EDIT_TRIES = 5;
|
|
211
214
|
/** An edit: a new revision of the agent, made current. Without `skills` the current revision's skill files carry over. An
|
|
212
215
|
* edit that is the current revision writes nothing, so a PUT sent twice makes one revision. The agent keeps its id, name
|
|
213
216
|
* and description from its creation. `ifCurrent` (from If-Match) is the current revision the caller read, null for none;
|
|
214
|
-
* it is checked against the agent's current revision
|
|
215
|
-
*
|
|
217
|
+
* it is checked against the agent's current revision when the edit is read, and the write is conditional on the revision
|
|
218
|
+
* the edit was built on still being current, compared in the store's own transaction (addRevision's ifCurrent), so it
|
|
219
|
+
* holds across every server on the store. `check` may refuse the revision before a write; it runs outside the write, so
|
|
220
|
+
* another request may move the current revision meanwhile: an edit with If-Match is then precondition_failed, and one
|
|
221
|
+
* without is built and checked again on the new current revision, so what it leaves out (skill files, harness, place, learning, cap) is never carried over from a
|
|
222
|
+
* revision it does not follow. `contract`: an edit that always makes a new revision, even one equal to the current. */
|
|
216
223
|
export async function commitAgent(store, read, { definition, skills, note }, { ifCurrent, check, contract = false } = {}) {
|
|
217
|
-
const
|
|
224
|
+
const stale = () => new ApiError("precondition_failed", "the agent's current revision moved since the If-Match it was read at: read the agent again");
|
|
225
|
+
const held = (entry) => {
|
|
226
|
+
if (ifCurrent !== undefined && (entry.revision?.id ?? null) !== ifCurrent)
|
|
227
|
+
throw stale();
|
|
228
|
+
return entry;
|
|
229
|
+
};
|
|
230
|
+
let entry = (await getAgent(store, read.agent.id)) ?? read;
|
|
218
231
|
refuseExternal(entry.agent);
|
|
219
|
-
|
|
220
|
-
throw new ApiError("precondition_failed", "the agent's current revision moved since the If-Match it was read at: read the agent again");
|
|
221
|
-
}
|
|
232
|
+
held(entry);
|
|
222
233
|
const { agent } = entry;
|
|
223
234
|
const kept = [
|
|
224
235
|
...(definition.id !== undefined && definition.id !== agent.id ? [{ field: "definition.id", reason: "not_an_option", message: `definition.id is ${agent.id}, the agent's id` }] : []),
|
|
@@ -228,8 +239,38 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
228
239
|
];
|
|
229
240
|
if (kept.length)
|
|
230
241
|
throw invalid(kept);
|
|
231
|
-
|
|
232
|
-
|
|
242
|
+
for (let tries = 1;; tries++) {
|
|
243
|
+
if (tries > 1)
|
|
244
|
+
entry = held((await getAgent(store, agent.id)) ?? entry);
|
|
245
|
+
const revision = editOn(entry, definition, skills, note);
|
|
246
|
+
await check?.(revision);
|
|
247
|
+
const base = entry.revision?.id ?? null;
|
|
248
|
+
const now = held((await getAgent(store, agent.id)) ?? entry);
|
|
249
|
+
if ((now.revision?.id ?? null) === base) {
|
|
250
|
+
if (!contract && now.revision && sameRevision(now.revision, revision)) {
|
|
251
|
+
checkVersion(definition, now.version);
|
|
252
|
+
return now;
|
|
253
|
+
}
|
|
254
|
+
checkVersion(definition, now.revisions + 1);
|
|
255
|
+
try {
|
|
256
|
+
await store.agents.addRevision({ agentId: agent.id, ifCurrent: base, ...revision });
|
|
257
|
+
return (await getAgent(store, agent.id));
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (!(error instanceof RevisionMoved))
|
|
261
|
+
storeError(error);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// Moved while it was checked or written: with If-Match that is stale; without, built and checked again on it.
|
|
265
|
+
if (ifCurrent !== undefined)
|
|
266
|
+
throw stale();
|
|
267
|
+
if (tries >= EDIT_TRIES)
|
|
268
|
+
throw new ApiError("precondition_failed", "the agent's current revision kept moving while this edit was checked: read the agent again");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** The revision an edit makes on `entry`'s current one: what the edit leaves out keeps the current revision's, its skill
|
|
272
|
+
* files, harness, place, learning switch and default cap. Absent here is unchanged, not the default. */
|
|
273
|
+
function editOn(entry, definition, skills, note) {
|
|
233
274
|
const current = entry.revision;
|
|
234
275
|
const currentBody = (current?.body ?? {});
|
|
235
276
|
let files = skills;
|
|
@@ -241,21 +282,15 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
241
282
|
// The computer and its place go together: an edit naming neither keeps both (the computer, else the place).
|
|
242
283
|
...(definition.place === undefined && definition.computer === undefined ? (currentBody.computer ? { computer: currentBody.computer } : currentBody.place ? { place: currentBody.place } : {}) : {}),
|
|
243
284
|
...(definition.learning === undefined && current.kind === "agentic" && !isObject(definition.workflow) && currentBody.learning !== undefined ? { learning: currentBody.learning } : {}),
|
|
244
|
-
// No approvals here: an edit that leaves them out asks (openapi.ts DefinitionInput.approvals
|
|
285
|
+
// No approvals here: an edit that leaves them out asks (openapi.ts DefinitionInput.approvals),
|
|
245
286
|
// so no edit makes an agent unattended by saying nothing. The console's edit sends back the approvals it read.
|
|
246
287
|
...(definition.max_cost_usd === undefined && currentBody.maxCostUsd !== undefined ? { max_cost_usd: currentBody.maxCostUsd } : {}),
|
|
247
288
|
...(definition.cap_mode === undefined && currentBody.capMode !== undefined ? { cap_mode: currentBody.capMode } : {}),
|
|
289
|
+
// The structured answer's schema is the agent's contract with its callers: an edit that leaves it out keeps it.
|
|
290
|
+
...(definition.output_schema === undefined && current.kind === "agentic" && !isObject(definition.workflow) && currentBody.outputSchema !== undefined ? { output_schema: currentBody.outputSchema } : {}),
|
|
248
291
|
}
|
|
249
292
|
: {};
|
|
250
|
-
|
|
251
|
-
await check?.(revision);
|
|
252
|
-
if (!contract && current && sameRevision(current, revision)) {
|
|
253
|
-
checkVersion(definition, entry.version);
|
|
254
|
-
return entry;
|
|
255
|
-
}
|
|
256
|
-
checkVersion(definition, entry.revisions + 1);
|
|
257
|
-
await store.agents.addRevision({ agentId: agent.id, ...revision }).catch(storeError);
|
|
258
|
-
return (await getAgent(store, agent.id));
|
|
293
|
+
return makeRevision({ ...definition, ...carried }, files, note);
|
|
259
294
|
}
|
|
260
295
|
/** Makes `revisionId`, one of the agent's own, its current one (POST /agents/{id}/current). */
|
|
261
296
|
export async function setCurrentRevision(store, entry, revisionId) {
|
|
@@ -296,7 +331,7 @@ export function definitionOf(agent, revision, version) {
|
|
|
296
331
|
...(body.capMode !== undefined ? { cap_mode: body.capMode } : {}),
|
|
297
332
|
};
|
|
298
333
|
const kindBody = revision.kind === "agentic"
|
|
299
|
-
? { instructions: body.instructions, ...(body.model ? { model: body.model } : {}), ...(body.thinking ? { thinking: body.thinking } : {}), ...(body.learning !== undefined ? { learning: body.learning } : {}), ...common }
|
|
334
|
+
? { instructions: body.instructions, ...(body.model ? { model: body.model } : {}), ...(body.thinking ? { thinking: body.thinking } : {}), ...(body.learning !== undefined ? { learning: body.learning } : {}), ...(body.outputSchema !== undefined ? { output_schema: body.outputSchema } : {}), ...common }
|
|
300
335
|
: { workflow: body.workflow, ...common };
|
|
301
336
|
return {
|
|
302
337
|
id: agent.id,
|
|
@@ -304,7 +339,7 @@ export function definitionOf(agent, revision, version) {
|
|
|
304
339
|
name: agent.name,
|
|
305
340
|
...(agent.description !== null && agent.description !== undefined ? { description: agent.description } : {}),
|
|
306
341
|
...kindBody,
|
|
307
|
-
// Its approvals, of either kind: "ask" where none is set, as
|
|
342
|
+
// Its approvals, of either kind: "ask" where none is set, as the definition read says it (definitionOf).
|
|
308
343
|
approvals: approvalsOf(body.approvals),
|
|
309
344
|
harness: harnessOfBody(body),
|
|
310
345
|
...(body.place ? { place: body.place } : {}),
|
package/dist/agents.d.ts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import { type Agent, type AgentStore, type NewRevision, type Revision, type RevisionPlace, type RevisionRow } from "@parcha/pi-durable-agent";
|
|
2
1
|
import { ApiError } from "./errors.js";
|
|
3
|
-
import { type DefinitionBody, type Json } from "./validate.js";
|
|
4
|
-
import type { SignInView } from "./sign-ins.js";
|
|
5
|
-
/** One agent as the routes show it: its row, its current revision and that revision's number (the oldest is 1). */
|
|
6
|
-
export type AgentEntry = {
|
|
7
|
-
agent: Agent;
|
|
8
|
-
revision: Revision | null;
|
|
9
|
-
version: number;
|
|
10
|
-
revisions: number;
|
|
11
|
-
runs: {
|
|
12
|
-
count: number;
|
|
13
|
-
live: number;
|
|
14
|
-
};
|
|
15
|
-
sizes: Map<string, number>;
|
|
16
|
-
};
|
|
17
2
|
/** SQLITE_BUSY or SQLITE_LOCKED: another connection holds the database. */
|
|
18
3
|
export declare const sqliteBusy: (error: unknown) => boolean;
|
|
19
4
|
/** How long a request waits for a busy agent store, step by step: short first, so a reader's overlap costs
|
|
@@ -22,116 +7,15 @@ export declare const REQUEST_BUSY_MS: readonly number[];
|
|
|
22
7
|
/** `act` again while another connection holds the store: after busy `attempt`, `onBusy` hears of it and the next of
|
|
23
8
|
* `delaysMs` is waited out without blocking the event loop. Past the last, the busy error is thrown. */
|
|
24
9
|
export declare function whenFree<T>(act: () => T | Promise<T>, delaysMs: readonly number[], onBusy?: (attempt: number, delayMs: number | undefined) => void): Promise<T>;
|
|
25
|
-
/** A store another writer holds: SQLite's busy or locked,
|
|
26
|
-
* store
|
|
10
|
+
/** A store another writer holds: SQLite's busy or locked, the one store's lock held past its busy wait (StoreBusy), or a
|
|
11
|
+
* transaction of the one store rolled back at its deadline (StoreDeadline). Nothing of the request's write was kept, so
|
|
12
|
+
* it may be sent again: every answer of the server maps it the same way, home_busy (answerOf). */
|
|
27
13
|
export declare const storeBusy: (error: unknown) => boolean;
|
|
28
14
|
/** The answer to a request the agent store stayed busy for. */
|
|
29
15
|
export declare const homeBusy: () => ApiError;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
export declare
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** Read-only, for the store's skill texts, which its reads do not return. */
|
|
37
|
-
private readonly skills;
|
|
38
|
-
constructor(dir: string);
|
|
39
|
-
/** A read or write of the store for a request: a busy store is waited for about 2 s (REQUEST_BUSY_MS). */
|
|
40
|
-
request<T>(act: () => T | Promise<T>): Promise<T>;
|
|
41
|
-
private closed;
|
|
42
|
-
close(): void;
|
|
43
|
-
/** Skill texts by their SHA-256. */
|
|
44
|
-
private texts;
|
|
45
|
-
/** The revision a checked definition makes; `files` are its skill files by path. */
|
|
46
|
-
private revisionOf;
|
|
47
|
-
/** `definition.version`, when given, is the number of the revision the request leaves current. */
|
|
48
|
-
private checkVersion;
|
|
49
|
-
/** A workflow revision is checked before anything is written, so a refusal makes no agent. */
|
|
50
|
-
private checked;
|
|
51
|
-
/** A new agent and its first revision, current. A definition id already here is `409 agent_exists`. `check` sees the
|
|
52
|
-
* revision before anything is written, and may refuse it. */
|
|
53
|
-
/** `fresh`: the place a new agent that names none is saved with, and the tools it gets when it names none (place.ts
|
|
54
|
-
* newAgentPlace); an agentic definition alone takes them, and only where it leaves them out. */
|
|
55
|
-
create({ definition, skills, note }: DefinitionBody, check?: (revision: NewRevision) => Promise<void>, fresh?: {
|
|
56
|
-
place: RevisionPlace;
|
|
57
|
-
tools: readonly string[];
|
|
58
|
-
}): Promise<AgentEntry>;
|
|
59
|
-
/** An edit: a new revision of the agent, its parent the current one, made current. Without `skills` the current
|
|
60
|
-
* revision's skill files carry over. An edit that is the current revision writes nothing, so a PUT sent twice makes
|
|
61
|
-
* one revision. The store keeps an agent's id, name and description from its creation. `ifCurrent` (from If-Match)
|
|
62
|
-
* is the current revision the caller read, null for none: the store compares it in the commit's own transaction.
|
|
63
|
-
* `check` sees the revision, the current one's included, before anything is written, and may refuse it. */
|
|
64
|
-
/** `contract`: the contract's edit, whose version the caller has checked is past the current one. It always makes a new
|
|
65
|
-
* revision, the same definition included, numbered as this store numbers them (the next), whatever version it named. */
|
|
66
|
-
commit(read: AgentEntry, { definition, skills, note }: DefinitionBody, { ifCurrent, check, contract }?: {
|
|
67
|
-
ifCurrent?: string | null;
|
|
68
|
-
check?: (revision: NewRevision) => Promise<void>;
|
|
69
|
-
contract?: boolean;
|
|
70
|
-
}): Promise<AgentEntry>;
|
|
71
|
-
/** Makes `revision`, one of the agent's own, its current one. */
|
|
72
|
-
setCurrent(entry: AgentEntry, revision: string): Promise<AgentEntry>;
|
|
73
|
-
/** Archives or unarchives an agent or a run. */
|
|
74
|
-
setArchived(kind: "agent" | "run", id: string, archived: boolean): Promise<void>;
|
|
75
|
-
/** The agent's revisions, newest first, each with its number. */
|
|
76
|
-
revisions(id: string): Promise<Array<RevisionRow & {
|
|
77
|
-
version: number;
|
|
78
|
-
}>>;
|
|
79
|
-
/** Revision `id` and its number, or null when it is not one of `agent`'s. */
|
|
80
|
-
revision(agent: string, id: string): Promise<{
|
|
81
|
-
revision: Revision;
|
|
82
|
-
version: number;
|
|
83
|
-
} | null>;
|
|
84
|
-
/** The agent `id`, or null. `runs` saves a read when the caller holds every run already. */
|
|
85
|
-
get(id: string): Promise<AgentEntry | null>;
|
|
86
|
-
private entry;
|
|
87
|
-
/** Every agent here, newest first. */
|
|
88
|
-
list(): Promise<AgentEntry[]>;
|
|
89
|
-
}
|
|
90
|
-
/** The agent's ETag: its current revision, which only an edit or `POST .../current` moves. */
|
|
91
|
-
export declare const etagOf: (entry: AgentEntry) => string;
|
|
92
|
-
/** A revision as a definition, as `POST /agents` takes one, numbered. */
|
|
93
|
-
export declare function definitionOf(agent: Agent, revision: Revision, version: number): Json;
|
|
94
|
-
/** `Agent` as the contract shows it, with its current revision and its saved sign-ins (sign-ins.ts view: never a ref).
|
|
95
|
-
* `origin`: where its console page is (console-links.ts). */
|
|
96
|
-
export declare function agentView(entry: AgentEntry, origin: string, signIns?: readonly SignInView[], learning?: {
|
|
97
|
-
pending: number;
|
|
98
|
-
}): {
|
|
99
|
-
created_at: string;
|
|
100
|
-
updated_at: string;
|
|
101
|
-
learning?: {
|
|
102
|
-
pending: number;
|
|
103
|
-
} | undefined;
|
|
104
|
-
agent_id: string;
|
|
105
|
-
definition: Json | null;
|
|
106
|
-
kind: "agentic" | "workflow" | null;
|
|
107
|
-
revision: string | null;
|
|
108
|
-
revisions: number;
|
|
109
|
-
source: null;
|
|
110
|
-
skills: {
|
|
111
|
-
path: string;
|
|
112
|
-
sha256: string;
|
|
113
|
-
size_bytes: number | null;
|
|
114
|
-
}[];
|
|
115
|
-
sign_ins: readonly SignInView[];
|
|
116
|
-
runs: {
|
|
117
|
-
count: number;
|
|
118
|
-
live: number;
|
|
119
|
-
};
|
|
120
|
-
region: string;
|
|
121
|
-
home_etag: string;
|
|
122
|
-
archived_at: string | null;
|
|
123
|
-
console_url: string;
|
|
124
|
-
};
|
|
125
|
-
/** One revision as `GET .../revisions` lists it. */
|
|
126
|
-
export declare function revisionView(agent: Agent, row: RevisionRow & {
|
|
127
|
-
version: number;
|
|
128
|
-
}, revision: Revision): {
|
|
129
|
-
revision: string;
|
|
130
|
-
version: number;
|
|
131
|
-
parent: string | null;
|
|
132
|
-
kind: import("@parcha/pi-durable-agent").RevisionKind;
|
|
133
|
-
current: boolean;
|
|
134
|
-
note: string | null;
|
|
135
|
-
created_at: string;
|
|
136
|
-
definition: Json;
|
|
137
|
-
};
|
|
16
|
+
/** What a request's error answers, over HTTP and through an MCP tool alike (server.ts, mcp.ts dispatch): an ApiError as
|
|
17
|
+
* it is; a busy store home_busy (409, retryable), never 500; anything else internal, its message kept. */
|
|
18
|
+
export declare const answerOf: (error: unknown) => ApiError;
|
|
19
|
+
/** Whether a request's error goes to the server's log: every fault the server did not answer on purpose. A busy wait
|
|
20
|
+
* is not one; a transaction past its deadline is (something held the store that long). */
|
|
21
|
+
export declare const logged: (error: unknown) => boolean;
|