@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45
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 +231 -0
- package/README.md +580 -320
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +10 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +26 -89
- package/dist/learn/check.js +58 -336
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +30 -2
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +58 -9
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +119 -83
- package/dist/server.js +1121 -419
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +41 -21
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -9
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -33
- package/dist/learning-evals.js +0 -98
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
|
@@ -14,8 +14,8 @@ import type { ScriptComputer } from "../workspace/run-tools.js";
|
|
|
14
14
|
import { type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
|
|
15
15
|
import { type PortModels } from "../port-models.js";
|
|
16
16
|
/** The run's cap's config, as its spec gives it: the kernel runCap's options but its sessions (the loop's own), and
|
|
17
|
-
* `beside`, what was spent beside the run's sessions on its behalf (
|
|
18
|
-
*
|
|
17
|
+
* `beside`, what was spent beside the run's sessions on its behalf (learning-end.ts shadowBesideOf: its audit's shadow
|
|
18
|
+
* run), which every gate of the run reads with its sessions' spend (runBooking's sessions.beside, overCap, the
|
|
19
19
|
* wrap-ups). None: nothing is. */
|
|
20
20
|
export type RunCapConfig = Omit<RunCapOptions, "sessions"> & {
|
|
21
21
|
beside?(): Promise<number | null>;
|
|
@@ -98,6 +98,9 @@ export interface AdapterRunSpec {
|
|
|
98
98
|
* run, its model requests, its paid tool calls and its decisions, is admitted and booked through it. An uncapped run
|
|
99
99
|
* gives capUsd: () => undefined. */
|
|
100
100
|
readonly runCap: RunCapConfig;
|
|
101
|
+
/** This claim's model-request retry policy over the loop's defaults. A provider whose failed request may already be
|
|
102
|
+
* billed can disable automatic retries for every conversation in the claim, including its subagents. */
|
|
103
|
+
readonly retry?: Partial<ConversationRetryPolicy>;
|
|
101
104
|
/** The run's cap, when it has one (filled from the run's launch): its figure, and what a refusal does to the run (the
|
|
102
105
|
* kernel cap's parkOf: parked with a pending budget for a refusal a raise could fix, else failed in its words), at the
|
|
103
106
|
* cap the run is held to when it parks (`capUsd`: the newest raise's, else the launch's), which its pending budget
|
|
@@ -144,11 +147,10 @@ export interface AdapterRunSpec {
|
|
|
144
147
|
* them): it wins over LoopDeps.endOfRun and is asked where that one is, in the end turn while the claim is held, before
|
|
145
148
|
* a tool host's beforeRelease and the run's release, its rows in the end's commit. */
|
|
146
149
|
readonly endOfRun?: EndOfRunTurn;
|
|
147
|
-
/** What the claim laid of the run's learning seed (runner/learning-seed.ts): the learned
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
+
/** What the claim laid of the run's learning seed (runner/learning-seed.ts): the learned workflows it was given, by
|
|
151
|
+
* name. The loop writes it on the root (KINDS.learningLaid) as this claim opens. Absent for a run that does not
|
|
152
|
+
* learn. */
|
|
150
153
|
readonly learningLaid?: {
|
|
151
|
-
readonly skills: readonly string[];
|
|
152
154
|
readonly workflows: readonly string[];
|
|
153
155
|
};
|
|
154
156
|
/** The run's work folder, as its file tools resolve a path: what the end-of-run turn's refusal under work/.learning/
|
|
@@ -220,6 +222,12 @@ export interface AdapterRunSpec {
|
|
|
220
222
|
* the session through the loop's gate, a command row makes them fresh again, and the pass's end lets them go. Absent:
|
|
221
223
|
* the run grants no MCP tool. */
|
|
222
224
|
readonly mcp?: ClaimMcp;
|
|
225
|
+
/** The run's model key holder (claim-secrets.ts claimModelKey), which its model routes read at each request: a command
|
|
226
|
+
* row opens it from the run's launch again before the command reaches the session, so a message's key (a replacement,
|
|
227
|
+
* or a run's first) is the one its next request carries. Absent: no gateway here, and the routes read the server's keys. */
|
|
228
|
+
readonly modelKey?: {
|
|
229
|
+
fresh(): Promise<void>;
|
|
230
|
+
};
|
|
223
231
|
/** The JSON Schema the run's final answer's last json block meets (its revision's definition.output_schema). An answer
|
|
224
232
|
* that misses it is asked again once, in the same session under the same cap (the output contract's retry); absent:
|
|
225
233
|
* the run's answer is never checked here. */
|
|
@@ -29,7 +29,7 @@ const outputRetried = (entries) => {
|
|
|
29
29
|
import { ClaimRefused, deniedText, noteOf, stopEnd } from "./loop-contract.js";
|
|
30
30
|
import { ASKED_BECAUSE, deniedText as setToDenyText, ENDED_WHILE_WAITING, refusedText, STOPPED_WHILE_WAITING } from "../refusal-words.js";
|
|
31
31
|
import { ADAPTER_API } from "../turn-end.js";
|
|
32
|
-
import { answerText,
|
|
32
|
+
import { answerText, REFLECT_PREFIX, reflectRequestId } from "./end-of-run.js";
|
|
33
33
|
import { agentEntriesOf, approvalOf, BOOKING_WRITE_MS, CLOSE_MS, CUT_STEP_MS, END_PATCH_MS, END_PATCH_UNKNOWN, PARK_SIBLINGS_MS, readAgain, STOP_SETTLE_MS, commandRequest, cutLast, DEFAULT_RESTART_LIMIT, entriesOf, findData, Gate, heldReporter, INPUT_REQUEST, Interrupted, KernelFault, lastAnswerText, Parked, quiet, restartLimited, writesEntry, writesSubmission } from "./loop.js";
|
|
34
34
|
import { outputMiss, outputRetryWords } from "../answer-json.js";
|
|
35
35
|
import { answerOnce, HAND_BACK, handBackOf } from "./hand-back.js";
|
|
@@ -53,6 +53,7 @@ import { Fenced } from "../store/index.js";
|
|
|
53
53
|
import { answerAsServed } from "../answer-json.js";
|
|
54
54
|
import { reserveFor, stepAndAnswerFor, wrappingUp, wrapUpText } from "../wrap-up.js";
|
|
55
55
|
import { LEARNED_CARD_FIELDS, LEARNED_CLIP, LEARNED_WORKFLOW_TOOL, learnedApprovedTools } from "../learned-workflow.js";
|
|
56
|
+
import { warnHoldShort } from "../print.js";
|
|
56
57
|
import { feedbackAsk, feedbackOf, pendingFeedbackOf } from "./feedback-round.js";
|
|
57
58
|
import { handbackText, servedAnswerOf, servedAnswerText, WORKFLOW_FIRST, WORKFLOW_FIRST_CALL } from "./workflow-first.js";
|
|
58
59
|
/** The end of a harness's own call (Claude Code's WebSearch) the gate held and then let run: the host ran nothing of it,
|
|
@@ -350,7 +351,7 @@ async function openCliRecord(harness, journal, context, now, cwd, endsItsCalls =
|
|
|
350
351
|
flushedAtRequest = atRequest;
|
|
351
352
|
if (joined)
|
|
352
353
|
return;
|
|
353
|
-
const length = cut?.stopReason === "length" ? { stopReason: "length", ...(cut.outputTokens === undefined ? {} : { outputTokens: cut.outputTokens }) } : {};
|
|
354
|
+
const length = cut?.stopReason === "length" ? { stopReason: "length", ...(cut.outputTokens === undefined ? {} : { outputTokens: cut.outputTokens }), ...(cut.capCut === undefined ? {} : { capCut: { capUsd: cut.capCut.capUsd, raiseToUsd: cut.capCut.raiseToUsd } }) } : {};
|
|
354
355
|
await append(KINDS.message, { role: "model", text: said, ...length });
|
|
355
356
|
});
|
|
356
357
|
};
|
|
@@ -634,8 +635,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
634
635
|
/** The current pass ended in a park that keeps its computer (keepAtPark), for this cause, until its release reads it. */
|
|
635
636
|
let parkedNow;
|
|
636
637
|
/** From the end-of-run step's start (or a claim that found its turn open: lookingBackOpen, from its session's open)
|
|
637
|
-
* until the claim ends: a steer is left for the end,
|
|
638
|
-
* (REFLECT_NOTE_ONLY), and every request is learning's, never the job's: the cap's wrap-up note is never told to it,
|
|
638
|
+
* until the claim ends: a steer is left for the end, and every request is learning's, never the job's: the cap's wrap-up note is never told to it,
|
|
639
639
|
* and a refusal of one never parks the run (learningRefused). Held between the step's asks too: a turn a takeover
|
|
640
640
|
* resumed may send its next request while the step still reads an earlier answer. */
|
|
641
641
|
let reflecting = false;
|
|
@@ -1321,7 +1321,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1321
1321
|
/** The root a phase is making, awaited before the owed writes are read. */
|
|
1322
1322
|
let rootMaking;
|
|
1323
1323
|
harness = await Harness.open(gate.journal, {
|
|
1324
|
-
models: () => models, registry, settings: { restartLimit, retry, stream }, onReport: () => { },
|
|
1324
|
+
models: () => models, registry, settings: () => ({ restartLimit, retry: { ...retry, ...specNow?.retry }, stream }), onReport: () => { },
|
|
1325
1325
|
// A tool host's onConversation, in each agent conversation's creating commit (the spec's, once it is known: the
|
|
1326
1326
|
// root is created when the session opens, after the spec).
|
|
1327
1327
|
conversationCreated: async (tx, record) => {
|
|
@@ -1659,7 +1659,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1659
1659
|
// earlier session's, a grade's), summed as overCap sums them; null while any is unknown. Read at the claim and again
|
|
1660
1660
|
// after each request is admitted (the note is placed before its own request's admission, so it reads the last).
|
|
1661
1661
|
const restOf = async () => {
|
|
1662
|
-
// And what was spent beside the run on its behalf (its
|
|
1662
|
+
// And what was spent beside the run on its behalf (its audit's shadow run).
|
|
1663
1663
|
const beside = await besideNow();
|
|
1664
1664
|
if (beside === null)
|
|
1665
1665
|
return null;
|
|
@@ -1849,6 +1849,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1849
1849
|
// at their hold or cut, comes before `capNote.live` and is never one.)
|
|
1850
1850
|
if (capNote.live && event.type === "request_end" && event.host === undefined && !notOwn.has(event.turn) && typeof event.usage.usd === "number" && event.usage.usd > 0 && !event.usage.cut && !event.usage.givenBack)
|
|
1851
1851
|
capNote.costs.push(event.usage.usd);
|
|
1852
|
+
// A request that billed more input than the bound its hold was priced on (the booking's holdShort): one warn
|
|
1853
|
+
// line, ids and figures only (print.ts warnHoldShort). Its booking, the hold and the cap are as they were.
|
|
1854
|
+
warnHoldShort(claim.runId, spec.adapter.id, event);
|
|
1852
1855
|
if (event.type === "request_start") {
|
|
1853
1856
|
// A new request means the model's last message is over: what it said so far is on the record before the request,
|
|
1854
1857
|
// so an answer shows while the turn goes on (a CLI that answers, then makes another request).
|
|
@@ -2317,15 +2320,19 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2317
2320
|
// (a new claim's, or a restart's after a fault: closeSession let the last one go) is not the one an open hold held,
|
|
2318
2321
|
// nor has what the owner set up on it: the run ends in those words.
|
|
2319
2322
|
heldNow = undefined;
|
|
2323
|
+
// This pass's hold began waiting for the start: an owner's row may move it on (start, release) as soon as the pass
|
|
2324
|
+
// opens, before the wait below begins, so a release there still ends the run before its agent runs.
|
|
2325
|
+
let heldBeforeStart = false;
|
|
2320
2326
|
if (spec.held) {
|
|
2321
2327
|
const [journalOf, rootOf] = [harness, root];
|
|
2322
2328
|
heldNow = journalHeld(spec.held, (entries) => journalOf.commit(async (tx) => {
|
|
2323
2329
|
for (const entry of entries)
|
|
2324
2330
|
await tx.appendEntry(rootOf.id, { kind: entry.kind, data: entry.data });
|
|
2325
2331
|
}, context), now);
|
|
2326
|
-
|
|
2332
|
+
const up = await heldNow.up(await entriesOf(gate.journal, root.id, context));
|
|
2333
|
+
if (up === "lost")
|
|
2327
2334
|
return await writeEnd(harness, root, gate, { state: "failed", summary: heldWords.lost }, []);
|
|
2328
|
-
|
|
2335
|
+
heldBeforeStart = up === "held";
|
|
2329
2336
|
}
|
|
2330
2337
|
// The cap a raise left the run at, before any request of this claim, through the one reader the run view and its
|
|
2331
2338
|
// budget card read too (capNowOf: the newest raise entry, else the launch's cap): a claim that takes over a raised
|
|
@@ -2350,7 +2357,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2350
2357
|
// What this claim laid of the run's learning seed, once per claim: the newest is what the run was given.
|
|
2351
2358
|
if (restarts === 0 && spec.learningLaid) {
|
|
2352
2359
|
const [journalOf, rootOf, laid] = [harness, root, spec.learningLaid];
|
|
2353
|
-
await journalOf.commit((tx) => tx.appendEntry(rootOf.id, { kind: KINDS.learningLaid, data: {
|
|
2360
|
+
await journalOf.commit((tx) => tx.appendEntry(rootOf.id, { kind: KINDS.learningLaid, data: { workflows: [...laid.workflows] } }), context);
|
|
2354
2361
|
}
|
|
2355
2362
|
// Reopened by a person's follow-up (runs.reopen, or the end's own reopen): a fresh reopen is a claim whose journal's
|
|
2356
2363
|
// root ends on an end entry, with no input of the root in flight. Then any turn its session still reads open is one
|
|
@@ -2402,7 +2409,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2402
2409
|
// A held computer waits for its owner's start before the agent's first input; the owner's calls set the task up
|
|
2403
2410
|
// meanwhile. A release, or no call for the hold's minutes, ends the run before its agent ever ran. A stop ends it
|
|
2404
2411
|
// stopped, and a lost claim leaves it for the next claim.
|
|
2405
|
-
if (heldNow
|
|
2412
|
+
if (heldNow && (heldNow.state() === "waiting" || (heldBeforeStart && heldNow.state() === "released"))) {
|
|
2406
2413
|
const aborted = new Promise((resolve) => (deps.signal.aborted ? resolve() : deps.signal.addEventListener("abort", () => resolve(), { once: true })));
|
|
2407
2414
|
const waited = await heldNow.untilStarted(Promise.race([stopping, aborted, harness.closed]));
|
|
2408
2415
|
// Set by stop() during the wait: read past the narrowing TypeScript did before it.
|
|
@@ -2992,9 +2999,6 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2992
2999
|
// An MCP tool is asked about by its catalog name (`mcp:<server>/<tool>`), as its settings and its card name it.
|
|
2993
3000
|
const tool = mcp?.catalogOf(call.tool) ?? call.tool;
|
|
2994
3001
|
const kernelCall = { callId: call.callId, tool: tool, args: call.args };
|
|
2995
|
-
// The end-of-run turn's notes are kept only from its answer: a write there is refused before its intent.
|
|
2996
|
-
if (reflecting && WRITES.has(call.tool) && underLearning(spec.workRoot, call.args))
|
|
2997
|
-
return { deny: REFLECT_NOTE_ONLY };
|
|
2998
3002
|
await hooks.beforeIntent(kernelCall);
|
|
2999
3003
|
// The cap's wrap-up, the same way: once the run has taken its share of the cap, every call the model makes is refused
|
|
3000
3004
|
// in its fixed words, and the model answers from what it has. A call a running tool makes is that tool's, let through.
|
|
@@ -3948,8 +3952,15 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3948
3952
|
async command(command) {
|
|
3949
3953
|
// A command row resumes a loop that may have sat past a token's life: its MCP credentials are made fresh again
|
|
3950
3954
|
// before its next model request.
|
|
3951
|
-
if (command.kind === "steer" || command.kind === "approve" || command.kind === "deny" || command.kind === "raise")
|
|
3955
|
+
if (command.kind === "steer" || command.kind === "approve" || command.kind === "deny" || command.kind === "raise") {
|
|
3952
3956
|
mcpStale = true;
|
|
3957
|
+
// The run's own model key, read again from its launch before the command reaches the session: the message's key
|
|
3958
|
+
// was written with its command row, so the next request's credential (which the model proxy reads before its
|
|
3959
|
+
// beforeRequest hook) is the message's, a first key or a replacement. Fail-closed: a read that keeps failing
|
|
3960
|
+
// throws here, before the command is taken, so the runner delivers it again at its next poll and the session
|
|
3961
|
+
// never runs the message on the key held before it.
|
|
3962
|
+
await specNow?.modelKey?.fresh();
|
|
3963
|
+
}
|
|
3953
3964
|
if (command.kind === "steer")
|
|
3954
3965
|
return steer(command);
|
|
3955
3966
|
if (command.kind === "approve" || command.kind === "deny") {
|
|
@@ -4,6 +4,7 @@ import type { HostTool, Wire } from "@parcha/agentrun-kernel";
|
|
|
4
4
|
import type { Approvals } from "../approvals.js";
|
|
5
5
|
import type { installForClaim, installSettled } from "../harness-install.js";
|
|
6
6
|
import type { LiveHandover, LiveViewerStore } from "../browser-live.js";
|
|
7
|
+
import { type RunnerLive } from "../live-reach.js";
|
|
7
8
|
import { type PinnedModel, type Tier } from "../model.js";
|
|
8
9
|
import { type RunLaunch } from "../run-launch.js";
|
|
9
10
|
import type { Store } from "../store/store.js";
|
|
@@ -16,6 +17,7 @@ import { type LearnedWorkflow } from "../learning.js";
|
|
|
16
17
|
import { type ToolResults } from "../workspace/run-tools.js";
|
|
17
18
|
import { type ClaimMcp } from "./mcp-run.js";
|
|
18
19
|
import { type AdapterLoopOptions, type AdapterRun, type AdapterRunSpec, hostLifecycle } from "./adapter-loop.js";
|
|
20
|
+
import { type RunnerHarness } from "./adapters/index.js";
|
|
19
21
|
import { type Claim, type Journal } from "./loop-contract.js";
|
|
20
22
|
import type { ReplayCalls } from "../learn/replay-calls.js";
|
|
21
23
|
import type { ModelRoute } from "./model-route.js";
|
|
@@ -87,8 +89,9 @@ export interface AdapterSpecDeps {
|
|
|
87
89
|
readonly journal: (claim: Claim) => Journal;
|
|
88
90
|
/** The one store: `runs` and `agents` for the run's revision, and the live-viewer seam for the browser tool. */
|
|
89
91
|
readonly store: Store & LiveViewerStore;
|
|
90
|
-
/** The key the store's
|
|
91
|
-
|
|
92
|
+
/** The key the store's sealed values are opened under (store/seal.ts): the runner's. Undefined in a run's own process
|
|
93
|
+
* (run-child.ts), which never holds it: what a claim opens with it is asked of the runner there (held.ts). */
|
|
94
|
+
readonly sealKey: Buffer | undefined;
|
|
92
95
|
/** The run's model route (model-route.ts routeOf), the one route the pi adapter and the cap read, on a wire of `wires`
|
|
93
96
|
* (the caller's; pi speaks both of main's, PI_WIRES). */
|
|
94
97
|
readonly routeOf: (model: string | PinnedModel | undefined, env: NodeJS.ProcessEnv, tier?: Tier, wires?: readonly Wire[], upstream?: typeof fetch, redact?: (text: string) => string) => Promise<ModelRoute>;
|
|
@@ -166,6 +169,9 @@ export type EvalFakes = {
|
|
|
166
169
|
* model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
|
|
167
170
|
* overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
|
|
168
171
|
export declare function capModelOf(route: ModelRoute): CapModel;
|
|
172
|
+
/** Particle requests are never automatically replayed after an uncertain failure. Retry is a harness-wide setting,
|
|
173
|
+
* so a claim with any Particle route disables it for all its conversations, including subagents on other tiers. */
|
|
174
|
+
export declare function modelRetryOf(routes: Iterable<Pick<ModelRoute, "like">>): Pick<AdapterRunSpec, "retry">;
|
|
169
175
|
/** What the runner routes a claimed run on: the launch's model as its start pinned it, sent as pinned, with the
|
|
170
176
|
* revision's own ref beside it (main prices a gateway's id by the provider that ref names); the revision's ref alone
|
|
171
177
|
* when the start pinned none. Never the pin's provider and id joined into a ref: a gateway refuses the joined id, and
|
|
@@ -221,9 +227,11 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
221
227
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
222
228
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|
|
223
229
|
export declare function storeSettings(store: Pick<Store, "settings">): Promise<Awaited<ReturnType<typeof loadToolSettings>>>;
|
|
224
|
-
/** pi's spec for a claimed run
|
|
225
|
-
*
|
|
226
|
-
|
|
230
|
+
/** pi's spec for a claimed run, on `runner`'s adapter (pi's when none is given; a harness module's runner for a harness it
|
|
231
|
+
* adds with no adapter facts), its visible record kept as that runner says (RunnerHarness.record). What it makes for the
|
|
232
|
+
* run (its Archil mount credential, its Workspace, its computer, its tools) is held until the spec's release; a build
|
|
233
|
+
* that throws part-way lets go what it made by then (spec-holds.ts). */
|
|
234
|
+
export declare function adapterRunSpecFromLaunch(launch: RunLaunch, run: AdapterRun, deps: AdapterSpecDeps, claim: Claim, runner?: RunnerHarness): Promise<AdapterRunSpec>;
|
|
227
235
|
/** The host-tool ctx a non-hand tool is wrapped with (host-tools.ts hostToolOf): the run's own Harness (its commit,
|
|
228
236
|
* snapshot and task reads), the results map, and the run's folder as the api env's cwd (a tool reads no
|
|
229
237
|
* file environment, so an error names a path relative to it). Shared by the pi spec's bindNonHandTools and the CLI spec's
|
|
@@ -290,7 +298,7 @@ export declare function learnedWorkflowHostTool(opts: {
|
|
|
290
298
|
* each a named todo, added as their seams land. */
|
|
291
299
|
/** The run's live-viewer writers over the store (browser-live.ts): a session's hand-over written sealed, and gone. Its
|
|
292
300
|
* viewer token, minted in the run, is held by `cut`, the run's one redactor, as it is handed over, before it is written. */
|
|
293
|
-
export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer, claim: Claim, cut: HeldRedact): {
|
|
301
|
+
export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer | undefined, claim: Claim, cut: HeldRedact): {
|
|
294
302
|
put(handover: LiveHandover): Promise<boolean>;
|
|
295
303
|
drop(tag?: string): Promise<void>;
|
|
296
304
|
};
|
|
@@ -311,7 +319,8 @@ export declare function buildToolHost(opts: {
|
|
|
311
319
|
readonly env: NodeJS.ProcessEnv;
|
|
312
320
|
readonly run: AdapterRun;
|
|
313
321
|
readonly store: Store & LiveViewerStore;
|
|
314
|
-
|
|
322
|
+
/** The runner's seal key; none in a run's own process, whose sealed reads its runner makes (held.ts). */
|
|
323
|
+
readonly sealKey: Buffer | undefined;
|
|
315
324
|
readonly life: ReturnType<typeof hostLifecycle>;
|
|
316
325
|
readonly redact: HeldRedact;
|
|
317
326
|
/** The run's launch (its trigger and origin) and its agent's own tool settings, as the email tools read them. */
|
|
@@ -323,7 +332,13 @@ export declare function buildToolHost(opts: {
|
|
|
323
332
|
readonly loopback?: boolean;
|
|
324
333
|
/** That server's own addresses (AdapterSpecDeps.mcpOwn): never the ports calendar_events reads on loopback. */
|
|
325
334
|
readonly own?: readonly string[];
|
|
335
|
+
/** A runner on another host than its server: where the run's viewers answer, under its run's key (claimLiveAt). */
|
|
336
|
+
readonly liveAt?: RunnerLive;
|
|
326
337
|
}): ToolHost;
|
|
338
|
+
/** Where the claim's viewers answer on a runner on another host than its server (live-reach.ts runnerLiveOf), under the
|
|
339
|
+
* claim's run's own proof key (liveForRun); none on the server's machine. In a run's own process its runner's
|
|
340
|
+
* (held.ts liveAt): the process holds its run's key, never the runners' shared one. */
|
|
341
|
+
export declare function claimLiveAt(deps: Pick<AdapterSpecDeps, "env" | "sealKey">, runId: string): Promise<RunnerLive | undefined>;
|
|
327
342
|
/** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
|
|
328
343
|
* catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
|
|
329
344
|
* CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its
|