@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.59
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 +376 -0
- package/README.md +393 -118
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +7 -5
- package/dist/box-paths.js +12 -8
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +121 -0
- package/dist/claude-login-token.js +797 -0
- package/dist/claude-login.d.ts +119 -34
- package/dist/claude-login.js +551 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +325 -328
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +40 -19
- package/dist/computer-attach.js +326 -62
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +12 -11
- package/dist/computers.js +11 -8
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +139 -5
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +13 -5
- package/dist/env-switch.js +24 -6
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +12 -4
- package/dist/fal-price.js +110 -26
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.js +9 -6
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +8 -0
- package/dist/harness-table.js +17 -6
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +173 -0
- package/dist/learn/ledger.js +225 -0
- package/dist/learn/promote.d.ts +82 -39
- package/dist/learn/promote.js +61 -66
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +40 -21
- package/dist/learning-cost.js +30 -21
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +9 -0
- package/dist/live-reach.js +9 -0
- package/dist/mcp-api-only-origins.d.ts +23 -3
- package/dist/mcp-api-only-origins.js +57 -17
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +234 -61
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +59 -34
- package/dist/place-offers.js +100 -58
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +5 -4
- package/dist/provider.js +26 -13
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.js +3 -1
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +97 -63
- package/dist/runner/adapter-run-spec.d.ts +34 -14
- package/dist/runner/adapter-run-spec.js +120 -75
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +29 -13
- package/dist/runner/claim-secrets.d.ts +27 -18
- package/dist/runner/claim-secrets.js +61 -47
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +93 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +19 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +24 -18
- package/dist/runner/mcp-claim.js +24 -7
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +10 -8
- package/dist/runner/presence.d.ts +11 -4
- package/dist/runner/presence.js +11 -6
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +38 -12
- package/dist/runner/run-child-host.js +231 -83
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +5 -3
- package/dist/runner/runner.js +14 -10
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +138 -37
- package/dist/runner/workflow-first.js +230 -99
- package/dist/runner/workflow-spec.js +2 -2
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +33 -10
- package/dist/server.js +454 -136
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +44 -4
- package/dist/store/schema.js +111 -11
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +19 -2
- package/dist/store/sqlite/run-patch.js +67 -2
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +177 -32
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +74 -25
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +102 -136
- package/dist/store-reads/learning.js +251 -302
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +91 -9
- package/dist/template-eval.js +448 -105
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +14 -14
- package/dist/timeline/web-calls.js +18 -30
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +50 -11
- package/dist/tool-plane.js +94 -30
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +27 -55
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +38 -11
- package/dist/workspace/attached-computers.js +81 -16
- package/dist/workspace/computer-deps.d.ts +29 -7
- package/dist/workspace/computer-deps.js +36 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +166 -57
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +152 -0
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +6 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +25 -9
- package/dist/console/assets/backend-DVhHzJX2.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -100,12 +100,6 @@ export declare function onlyLearnedWorkflows(rows: readonly TimelineEvent[]): bo
|
|
|
100
100
|
* onlyLearnedWorkflows asks of a run with nothing new, `handed_back` when it called a learned workflow otherwise,
|
|
101
101
|
* `agent` when it called none. */
|
|
102
102
|
export declare function runPathOf(rows: readonly TimelineEvent[]): RunPath;
|
|
103
|
-
/** The learned workflow a run's job called last by its call's `name` (callArgsOf's arguments, in the job's order: `calls`),
|
|
104
|
-
* or null when it called none by a name. */
|
|
105
|
-
export declare function workflowNameOf(calls: readonly {
|
|
106
|
-
tool: string;
|
|
107
|
-
args: Record<string, unknown>;
|
|
108
|
-
}[]): string | null;
|
|
109
103
|
/**
|
|
110
104
|
* One compile draft through the checks (the compile turn's `check`): its two files as the folder would hold them
|
|
111
105
|
* (workflow-draft.ts draftFiles: its workflow.json, and the README.md the host writes from its front matter), against
|
|
@@ -160,8 +154,8 @@ export declare function traceFrom(timeline: readonly TimelineEvent[], refuse: re
|
|
|
160
154
|
/** The compile turn's facts for run `runId` of agent `agentId` (learn/compile.ts): a revision of the learned workflow
|
|
161
155
|
* that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its one check on the
|
|
162
156
|
* agent's own runs fell under the bar; its champion served the run, or the agent did by hand), its text as main holds
|
|
163
|
-
* it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold
|
|
164
|
-
*
|
|
157
|
+
* it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold was asked
|
|
158
|
+
* its revise, read from the agent's kept learning; a stopped check's none; a connected agent's hold on give-backs only once it
|
|
165
159
|
* is due, as a first compile is, on its runs since the hold); else, when the job is due (compileDue: the run
|
|
166
160
|
* completed, the agent has no learned workflow active or waiting, and it has its definition's compile_after completed
|
|
167
161
|
* agent runs), a new one, compiled once: one more after a first compile whose drafts all failed their checks, and none
|
|
@@ -301,16 +301,6 @@ export function runPathOf(rows) {
|
|
|
301
301
|
return "agent";
|
|
302
302
|
return onlyLearnedWorkflows(rows) ? "workflow" : "handed_back";
|
|
303
303
|
}
|
|
304
|
-
/** The learned workflow a run's job called last by its call's `name` (callArgsOf's arguments, in the job's order: `calls`),
|
|
305
|
-
* or null when it called none by a name. */
|
|
306
|
-
export function workflowNameOf(calls) {
|
|
307
|
-
for (let i = calls.length - 1; i >= 0; i--) {
|
|
308
|
-
const call = calls[i];
|
|
309
|
-
if (LEARNED_NAMES.has(call.tool) && typeof call.args.name === "string")
|
|
310
|
-
return call.args.name;
|
|
311
|
-
}
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
304
|
/** Whether a draft's workflow.json (`json`) waits for its owner's OK whatever its checks say: a step of it calls an MCP
|
|
315
305
|
* tool with no declared price (workflow-draft.ts unpricedCalls), from the prices each server's row keeps (mcp-probe.ts
|
|
316
306
|
* McpPrices), or an SDK run's manifest gives. A server the store can't read gives no price: held. */
|
|
@@ -498,7 +488,7 @@ export async function recordDraftFailed(deps, input) {
|
|
|
498
488
|
const digest = draftFailedDigest(input.runId);
|
|
499
489
|
const failed = input.errors.join("; ").slice(0, CHECK_TEXT_MAX) || "no draft passed";
|
|
500
490
|
const reason = `${DRAFT_FAILED}: ${failed}. ${attempt === 2 ? "It was the recompile, so it stops: nothing compiles again until its owner acts" : "It is not promoted; the next due run compiles it once more"}`;
|
|
501
|
-
const check = { compile_after, agree_min, alone_min, attempt, n: 0, agreed: 0, alone: 0, of: [], ...(attempt === 2 ? { stopped: true } : {}) };
|
|
491
|
+
const check = { compile_after, agree_min, alone_min, attempt, n: 0, agreed: 0, alone: 0, agent_agreed: 0, of: [], ...(attempt === 2 ? { stopped: true } : {}) };
|
|
502
492
|
const kept = await recordPromotion(deps.store.settings, input.agentId, { workflow, digest, at: new Date().toISOString(), decided: "hold", reason, check }, (was) => was === undefined, refusedIn(() => deps.learningFolder(input.agentId), deps.store, deps.log));
|
|
503
493
|
if (kept.won)
|
|
504
494
|
deps.log?.(`learning: run ${input.runId}: the compile of ${workflow} failed its checks (attempt ${attempt}${attempt === 2 ? ", stopped" : ""})`);
|
|
@@ -535,8 +525,8 @@ export function traceFrom(timeline, refuse) {
|
|
|
535
525
|
/** The compile turn's facts for run `runId` of agent `agentId` (learn/compile.ts): a revision of the learned workflow
|
|
536
526
|
* that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its one check on the
|
|
537
527
|
* agent's own runs fell under the bar; its champion served the run, or the agent did by hand), its text as main holds
|
|
538
|
-
* it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold
|
|
539
|
-
*
|
|
528
|
+
* it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold was asked
|
|
529
|
+
* its revise, read from the agent's kept learning; a stopped check's none; a connected agent's hold on give-backs only once it
|
|
540
530
|
* is due, as a first compile is, on its runs since the hold); else, when the job is due (compileDue: the run
|
|
541
531
|
* completed, the agent has no learned workflow active or waiting, and it has its definition's compile_after completed
|
|
542
532
|
* agent runs), a new one, compiled once: one more after a first compile whose drafts all failed their checks, and none
|
|
@@ -653,15 +643,17 @@ export async function compileAskOf(deps, input) {
|
|
|
653
643
|
const sinceHold = own.filter(after).length + (after(listed[at]) ? ending : 0);
|
|
654
644
|
if (heldOnGiveBacks(read.held.check) && !(ending === 1 && sinceHold >= compileAfter))
|
|
655
645
|
return sayLeftOut(), undefined;
|
|
656
|
-
// Once per hold: a run since it that
|
|
657
|
-
// way to a replay, or its draft failed its checks), however many
|
|
658
|
-
//
|
|
659
|
-
//
|
|
660
|
-
//
|
|
646
|
+
// Once per hold: a run since it that was asked this hold's revise (its compile record names the held digest) asked
|
|
647
|
+
// already, whatever came of it (its revision is on its way to a replay, or its draft failed its checks), however many
|
|
648
|
+
// runs ago. A new compile asked before the hold (in flight as it was decided) that drafted the same workflow and ended
|
|
649
|
+
// after it is no revise. Read from the agent's kept learning since the hold, never a window of its last runs; one that
|
|
650
|
+
// can't be read asks nothing. A draft that failed since, not stopped (only a revise of a connected agent's hold on
|
|
651
|
+
// give-backs: reviseAttemptOf), asks once more: counted from it, its own run's kept learning (written after its record,
|
|
652
|
+
// at the run's end) not counted.
|
|
661
653
|
const failed = records.findLast((one) => one.workflow === read.held.workflow && draftFailedOf(one) && !one.check?.stopped && !(one.at < read.held.at));
|
|
662
654
|
const since = Date.parse(failed?.at ?? read.held.at);
|
|
663
655
|
const kept = await deps.store.learning.proposals(agentId, { limit: HELD_ASKED_READ }).catch(() => undefined);
|
|
664
|
-
const asked = (one) => !(one.createdAt < since) && compiledOf(one)?.workflow === read.held.workflow && draftFailedDigest(one.runId) !== failed?.digest;
|
|
656
|
+
const asked = (one) => !(one.createdAt < since) && compiledOf(one)?.workflow === read.held.workflow && compiledOf(one)?.held === read.held.digest && draftFailedDigest(one.runId) !== failed?.digest;
|
|
665
657
|
if (!kept || kept.some(asked))
|
|
666
658
|
return sayLeftOut(), undefined;
|
|
667
659
|
const { workflow, digest, reason, check, audit } = read.held;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { redactedAnswer, redactedLive,
|
|
1
|
+
import { redactedAnswer, redactedLive, redactedOutputWhole } from "../key-refusal.js";
|
|
2
2
|
/** A run's held state as the live view keeps it, under `values`, every secret value the run's one redactor holds. A
|
|
3
|
-
* running tool's id and name are cut whole (redactedAnswer). Its args by a workflow output's rule (
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* running tool's id and name are cut whole (redactedAnswer). Its args by a workflow output's rule (redactedOutputWhole):
|
|
4
|
+
* read whole first, so a held value split across two of its fields withholds them as "[redacted]", as a call's arguments
|
|
5
|
+
* are in its Timeline; else every string, property names included; a number whose digits hold a held value or that
|
|
6
|
+
* equals one, withheld; an object two of whose names come out the same once cut, withheld whole, never one value
|
|
7
|
+
* dropped over the other. What is still
|
|
6
8
|
* streaming (the tool's output, the partial answer) by redactedLive: a tail as long as a held value's widest form is held
|
|
7
9
|
* back, so a secret half streamed at a tick shows none of itself; the settled record replaces it whole once it ends. */
|
|
8
10
|
function cutHeld(state, values) {
|
|
@@ -11,7 +13,7 @@ function cutHeld(state, values) {
|
|
|
11
13
|
const tools = state.tools.map((tool) => ({
|
|
12
14
|
callId: redactedAnswer(tool.callId, values),
|
|
13
15
|
name: redactedAnswer(tool.name, values),
|
|
14
|
-
...(tool.args !== undefined ? { args:
|
|
16
|
+
...(tool.args !== undefined ? { args: redactedOutputWhole(tool.args, values) } : {}),
|
|
15
17
|
...(tool.output !== undefined ? { output: redactedLive(tool.output, values) } : {}),
|
|
16
18
|
}));
|
|
17
19
|
return { tools, ...(state.partial ? { partial: { text: redactedLive(state.partial.text, values) } } : {}) };
|
|
@@ -171,8 +171,6 @@ export interface LoopDeps {
|
|
|
171
171
|
flush(): Promise<void>;
|
|
172
172
|
/** Aborted on claim loss, self-stop or shutdown: in-flight model and tool calls are cut at once. */
|
|
173
173
|
signal: AbortSignal;
|
|
174
|
-
/** The end-of-run step (EndOfRunTurn): asked once before a run that answered or failed writes its end. Absent: none. */
|
|
175
|
-
endOfRun?: EndOfRunTurn;
|
|
176
174
|
/** Resolves once the claim's first delivery has handed every untaken row it read to command() (each call returned),
|
|
177
175
|
* or at once when there were none: a resumed ask with no answer row waits for it before it parks again, so an
|
|
178
176
|
* approve already on its way is never raced. Never rejects. */
|
package/dist/runner/loop.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export declare const END_PATCH_UNKNOWN: {
|
|
|
31
31
|
readonly costUsd: null;
|
|
32
32
|
readonly metrics: null;
|
|
33
33
|
};
|
|
34
|
+
/** What a loop's bound is armed on: the timer half of the runner's clock (RunnerOptions.clock). Every runner arms the real
|
|
35
|
+
* one (REAL_TIMER); a test's fires when its case says, so a stalled read is let go on an event, never after a real wait. */
|
|
36
|
+
export interface BoundTimer {
|
|
37
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
38
|
+
clearTimeout(handle: unknown): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const REAL_TIMER: BoundTimer;
|
|
34
41
|
/** How many times an end reads its cost before it is written unknown, and the pause between reads: all within the end's
|
|
35
42
|
* bound (END_PATCH_MS), so a store that refused one read never leaves the cost null. The stored cost is every reader's
|
|
36
43
|
* answer for an ended run (the list, the view, usage, learning), so a null there stays only when no read could be made. */
|
package/dist/runner/loop.js
CHANGED
|
@@ -30,6 +30,7 @@ export const END_PATCH_MS = 30_000;
|
|
|
30
30
|
/** What an end whose patch was late or failed writes: its cost and metrics unknown (null), never left as an earlier end
|
|
31
31
|
* of the run stored them, never read as a run that cost $0 by the agent's own path. */
|
|
32
32
|
export const END_PATCH_UNKNOWN = { costUsd: null, metrics: null };
|
|
33
|
+
export const REAL_TIMER = { setTimeout: (fn, ms) => setTimeout(fn, ms), clearTimeout: (handle) => clearTimeout(handle) };
|
|
33
34
|
/** How many times an end reads its cost before it is written unknown, and the pause between reads: all within the end's
|
|
34
35
|
* bound (END_PATCH_MS), so a store that refused one read never leaves the cost null. The stored cost is every reader's
|
|
35
36
|
* answer for an ended run (the list, the view, usage, learning), so a null there stays only when no read could be made. */
|
package/dist/runner/main.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HostedDial } from "@parcha/agentrun-computer";
|
|
2
|
+
import type { PairedRelay } from "../workspace/attached-computers.js";
|
|
2
3
|
import { type Store } from "../store/index.js";
|
|
3
4
|
import { type KeyEnv } from "../key-meta.js";
|
|
4
5
|
import { type ComputerDeps, type ComputerDepsOptions } from "../workspace/computer-deps.js";
|
|
@@ -22,8 +23,9 @@ export interface RunnerProcessOptions {
|
|
|
22
23
|
/** This runner's name in the runs it claims, its lines and its heartbeat. Default runner.ts runnerName(). */
|
|
23
24
|
name?: string;
|
|
24
25
|
/** Each claimed run's loop; default the runner's dispatch over the store (runnerLoop), with the computers it composed.
|
|
25
|
-
* A factory of the store is given the runner's dial too, where it has a relay
|
|
26
|
-
|
|
26
|
+
* A factory of the store is given the runner's dial and its paired computers' relay too, where it has a relay
|
|
27
|
+
* (dial-relay.ts). */
|
|
28
|
+
createLoop?: LoopFactory | StoreFactory;
|
|
27
29
|
/** Run the computer janitor (workspace/computer-janitor.ts) over the computers createLoop composed: at the start, then
|
|
28
30
|
* on its interval. Only the runner subcommand asks for it; a test that does not ask runs none. */
|
|
29
31
|
janitor?: boolean;
|
|
@@ -81,7 +83,7 @@ export declare function runEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
|
81
83
|
* provider loader in place of the computer package's. Under --faux (the runs' environment names the faux model, as a
|
|
82
84
|
* --faux server's and a `runner --faux` give it), --faux's computers are beside them, as the server's start check
|
|
83
85
|
* reads them (server.ts computerReady): a run on the faux desktop is claimed, and its live view opened, the real way. */
|
|
84
|
-
export declare const runnerComputers: (store: Store, env: KeyEnv, sealKey: Buffer, own?: Pick<ComputerDepsOptions, "kinds" | "load" | "dockerPaths" | "hostAddresses" | "hostWhy" | "hub" | "dial">) => {
|
|
86
|
+
export declare const runnerComputers: (store: Store, env: KeyEnv, sealKey: Buffer, own?: Pick<ComputerDepsOptions, "kinds" | "load" | "dockerPaths" | "hostAddresses" | "hostWhy" | "hub" | "dial" | "pairedRelay">) => {
|
|
85
87
|
computerForClaim: typeof import("../workspace/computer-deps.js").claimComputer;
|
|
86
88
|
computerDeps: ComputerDeps;
|
|
87
89
|
factories: import("../computer-keys.js").ProviderFactories;
|
|
@@ -96,7 +98,7 @@ export declare function besideRunEnv(env: NodeJS.ProcessEnv, switches: NodeJS.Pr
|
|
|
96
98
|
* its launch (harness-loops.ts resolveRunnerLoop), with the data directory, the run environment (runEnv), the store's
|
|
97
99
|
* journal, the seal key and the model route. `booted`: the seal key startRunnerProcess booted against the store (else
|
|
98
100
|
* this process's, as it was handed or booted). Refused in words with no seal key. */
|
|
99
|
-
export declare function runnerLoop(store: Store, dataDir: string, env?: NodeJS.ProcessEnv, booted?: Buffer, isolation?: RunIsolation, dial?: HostedDial): RunnerParts;
|
|
101
|
+
export declare function runnerLoop(store: Store, dataDir: string, env?: NodeJS.ProcessEnv, booted?: Buffer, isolation?: RunIsolation, dial?: HostedDial, paired?: PairedRelay): RunnerParts;
|
|
100
102
|
/** What a runner in its own process may reach on loopback, from its own environment alone, as a server takes its opt-in
|
|
101
103
|
* (cli.ts mcpLoopback): with AGENTRUN_MCP_ALLOW_LOOPBACK=1, an MCP server on this machine's loopback (the machine this
|
|
102
104
|
* process runs on, its container's in a container), never at `own`: the port a server listens on unless --port says
|
|
@@ -129,8 +131,11 @@ export declare function checkRunner(options: {
|
|
|
129
131
|
};
|
|
130
132
|
/** Opens the store as a runner and starts claiming runs. */
|
|
131
133
|
export declare function startRunnerProcess(options: RunnerProcessOptions): Promise<RunnerProcess>;
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
+
/** A function of the store: startRunnerProcess gives it the store it opens, and its relay's dial and paired computers'
|
|
135
|
+
* relay where it has a relay. */
|
|
136
|
+
type StoreFactory = (store: Store, sealKey: Buffer, dial?: HostedDial, paired?: PairedRelay) => LoopFactory | RunnerParts;
|
|
137
|
+
/** Marks `make` as a function of the store (StoreFactory). */
|
|
138
|
+
export declare function ofStore<Made extends LoopFactory | RunnerParts>(make: (store: Store, sealKey: Buffer, dial?: HostedDial, paired?: PairedRelay) => Made): (store: Store, sealKey: Buffer, dial?: HostedDial, paired?: PairedRelay) => Made;
|
|
134
139
|
/** How long a runner process lets each busy run finish its turn on SIGTERM, unless --drain-timeout or
|
|
135
140
|
* AGENTRUN_DRAIN_TIMEOUT says: the image's server drain (its CMD's --drain-timeout 6s), so a runner beside a --no-runner
|
|
136
141
|
* server drains as the server's own runner would.
|
package/dist/runner/main.js
CHANGED
|
@@ -35,7 +35,7 @@ import { bootSealKey } from "../seal-key.js";
|
|
|
35
35
|
import { handedSecret, SECRET_NAMES, secret } from "../secrets.js";
|
|
36
36
|
import { migrationsIn, openStore, RunnerBelowFloor, SchemaVersionUnknown, StoreAwaitsServer, storePlace, storeTarget } from "../store/index.js";
|
|
37
37
|
import { SCHEMA_VERSION } from "../store/schema.js";
|
|
38
|
-
import { SEAL_KEY_ENV,
|
|
38
|
+
import { SEAL_KEY_ENV, sealKeyIn } from "../tool-keys.js";
|
|
39
39
|
import { LAUNCH_HOOK_SECRET_ENV } from "../trigger-launch-hook.js";
|
|
40
40
|
import { FAUX_BROWSER_ENV } from "../tools.js";
|
|
41
41
|
import { claimViewOpener } from "../computer-live.js";
|
|
@@ -50,6 +50,7 @@ import { computerDepsFrom } from "../workspace/computer-deps.js";
|
|
|
50
50
|
import { startJanitor } from "../workspace/computer-janitor.js";
|
|
51
51
|
import { projectRunEnded } from "../source-sync/checkpoints.js";
|
|
52
52
|
import { runEndComputers } from "../workspace/run-end-computers.js";
|
|
53
|
+
import { sayLoginRunner } from "../claude-login-token.js";
|
|
53
54
|
import { createDispatchLoop } from "./dispatch.js";
|
|
54
55
|
import { resolveRunnerLoop } from "./harness-loops.js";
|
|
55
56
|
import { routeOf } from "./model-route.js";
|
|
@@ -98,8 +99,9 @@ export async function openRunnerStore(dataDir, env, warn, url) {
|
|
|
98
99
|
* tokens (the token and the token list) and API key, the seal key (the runner holds it as its sealKey), the store's connection (its URL holds a
|
|
99
100
|
* database password), the launch hook's signing secret (the server's alone), and the Composio account key, which the
|
|
100
101
|
* runner's claim alone reads (composio-made.ts composioEnvKey) and sends only as a granted Composio server's MCP header.
|
|
101
|
-
* And every OpenTelemetry setting (OTEL_*: OTEL_EXPORTER_OTLP_HEADERS holds a backend's key): a run's process is
|
|
102
|
-
* them on its pipe
|
|
102
|
+
* And every OpenTelemetry setting (OTEL_*: OTEL_EXPORTER_OTLP_HEADERS holds a backend's key): a run's process is never
|
|
103
|
+
* handed them, in an environment or on its pipe. It posts its trace over its channel and the runner exports it
|
|
104
|
+
* (otel/tracer.ts postedTracing, tracePosts), so no harness, tool or computer of a run has them. */
|
|
103
105
|
const RUNNER_ONLY = (name) => name === "AGENTRUN_TOKEN" || name === "AGENTRUN_TOKENS" || name === "AGENTRUN_API_KEY" || name === SEAL_KEY_ENV || name === LAUNCH_HOOK_SECRET_ENV || name === COMPOSIO_KEY_ENV || name.startsWith("AGENTRUN_STORE_") || name.startsWith("OTEL_");
|
|
104
106
|
/** A run's environment as the runner hands its loops (AdapterSpecDeps.env): this process's, less the runner's own
|
|
105
107
|
* secrets, with every other secret the launcher's pipe handed it (a model key, a tool key, a box key) readable by name
|
|
@@ -144,17 +146,16 @@ export function besideRunEnv(env, switches) {
|
|
|
144
146
|
* its launch (harness-loops.ts resolveRunnerLoop), with the data directory, the run environment (runEnv), the store's
|
|
145
147
|
* journal, the seal key and the model route. `booted`: the seal key startRunnerProcess booted against the store (else
|
|
146
148
|
* this process's, as it was handed or booted). Refused in words with no seal key. */
|
|
147
|
-
export function runnerLoop(store, dataDir, env = process.env, booted, isolation, dial) {
|
|
148
|
-
const sealKey = booted ??
|
|
149
|
-
if (!sealKey)
|
|
150
|
-
throw new RunnerRefused(`A runner needs the server's seal key (${SEAL_KEY_ENV}): start it through the server's launcher, which hands it over.`);
|
|
149
|
+
export function runnerLoop(store, dataDir, env = process.env, booted, isolation, dial, paired) {
|
|
150
|
+
const sealKey = booted ?? sealKeyIn(secret(SEAL_KEY_ENV) ?? env[SEAL_KEY_ENV], "a runner's secrets", { Refused: RunnerRefused, none: "start the runner through the server's launcher, which hands it over" });
|
|
151
151
|
const runs = runEnv(env);
|
|
152
152
|
// The run's computer at its claim, composed once (runnerComputers): none for the runner's place, a box's computer by the
|
|
153
153
|
// agent's setting, its keys read from the run environment first, then the store's sealed rows; a Docker computer's
|
|
154
154
|
// mounts by where this process's Docker has the data directory (box-paths.ts), read once; a desktop's or a phone's live
|
|
155
155
|
// view opened with it. A machine that dials goes to this runner's own hub, through the server's relay (`dial`, its
|
|
156
|
-
// relay's: dial-relay.ts); with none, its provider refuses.
|
|
157
|
-
|
|
156
|
+
// relay's: dial-relay.ts); with none, its provider refuses. A paired computer is brought onto that same hub for the run
|
|
157
|
+
// (`paired`, the relay's); with none, it is refused in words.
|
|
158
|
+
const computers = runnerComputers(store, runs, sealKey, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(dial ? { dial } : {}), ...(paired ? { pairedRelay: paired } : {}) });
|
|
158
159
|
const loopback = runnerLoopback(env);
|
|
159
160
|
// The operator's bound on owner-allowed private hosts (mcp-private-hosts.ts), read by every dial this runner and its
|
|
160
161
|
// runs' processes make (they inherit it, runEnv): said at the start when it narrows the owner's list.
|
|
@@ -265,21 +266,23 @@ export async function startRunnerProcess(options) {
|
|
|
265
266
|
// Its relay (dial-relay.ts), where its environment names the server's public address: a machine that dials the
|
|
266
267
|
// server lands in this runner's hub, through the server. Its log lines are the runner's warnings.
|
|
267
268
|
relay = await startRunnerRelay({ store, sealKey: seal.key, runner: name, presence, env, log: warn });
|
|
268
|
-
const made = options.createLoop ?? ofStore((opened, sealKey, dial) => runnerLoop(opened, options.dataDir, undefined, sealKey, undefined, dial));
|
|
269
|
+
const made = options.createLoop ?? ofStore((opened, sealKey, dial, paired) => runnerLoop(opened, options.dataDir, undefined, sealKey, undefined, dial, paired));
|
|
269
270
|
// A factory of the store (marked by ofStore) is given the store; a loop factory is used as is.
|
|
270
|
-
const parts = isStoreFactory(made) ? made(store, seal.key, relay?.dial) : made;
|
|
271
|
+
const parts = isStoreFactory(made) ? made(store, seal.key, relay?.dial, relay?.paired) : made;
|
|
271
272
|
const createLoop = typeof parts === "function" ? parts : parts.createLoop;
|
|
272
273
|
// The janitor sweeps with the computers the loop composed, never a second composition. Its lines are the runner's
|
|
273
274
|
// warnings, said where the runner says its others (warn: stderr unless a test gives its own).
|
|
274
275
|
// It sweeps as this runner (its name and its presence's incarnation): a computer kept at a park pinned to another
|
|
275
|
-
// runner still there is that runner's to end (computer-kept.ts sweepKept).
|
|
276
|
+
// runner still there is that runner's to end (computer-kept.ts sweepKept). The seal key is the claims' too: it opens
|
|
277
|
+
// the Archil key a kept computer's mount credential is removed with.
|
|
276
278
|
if (options.janitor && typeof parts !== "function")
|
|
277
|
-
janitor = startJanitor({ store, computers: parts.computers, env: parts.env, log: warn, self: { runner: name, incarnation } });
|
|
279
|
+
janitor = startJanitor({ store, computers: parts.computers, env: parts.env, sealKey: seal.key, log: warn, self: { runner: name, incarnation } });
|
|
278
280
|
// Before it claims: the scratch folders of runs that ended after their runner died (scratch-sweep.ts), said as warnings.
|
|
279
281
|
await sweepEndedScratch(store, options.dataDir, { log: warn });
|
|
280
|
-
// A run's end lets go of what its earlier claims' computers left, with the same computers (run-end-computers.ts),
|
|
281
|
-
//
|
|
282
|
-
|
|
282
|
+
// A run's end lets go of what its earlier claims' computers left, with the same computers (run-end-computers.ts),
|
|
283
|
+
// and with the janitor's environment and seal key, so a machine kept on Archil it deletes has its mount credential
|
|
284
|
+
// removed.
|
|
285
|
+
const runEnded = projectRunEnded(store, typeof parts !== "function" ? runEndComputers({ store, computers: parts.computers, log: warn, env: parts.env, sealKey: seal.key }) : undefined);
|
|
283
286
|
runner = startRunner({
|
|
284
287
|
store,
|
|
285
288
|
createLoop,
|
|
@@ -376,7 +379,7 @@ function watchFloor(store, known, everyMs) {
|
|
|
376
379
|
};
|
|
377
380
|
}
|
|
378
381
|
const storeFactories = new WeakSet();
|
|
379
|
-
/** Marks `make` as a function of the store (
|
|
382
|
+
/** Marks `make` as a function of the store (StoreFactory). */
|
|
380
383
|
export function ofStore(make) {
|
|
381
384
|
storeFactories.add(make);
|
|
382
385
|
return make;
|
|
@@ -635,6 +638,9 @@ export async function runnerMain(argv, given = process.env, hooks = {}) {
|
|
|
635
638
|
holds = { ...holds, loops: isolationLoops(isolation, holds.loops) };
|
|
636
639
|
let started;
|
|
637
640
|
const runnerOf = name ?? runnerName();
|
|
641
|
+
// Said on the data folder before it claims: whether its runs on Claude Code's login stay in this process, its CLI on
|
|
642
|
+
// the login's folder (claude-login-token.ts sayLoginRunner), for a runner whose runs are users of their own to read.
|
|
643
|
+
sayLoginRunner(args.dataDir, runnerOf, isolation.kind === "uid" ? "uid" : "process");
|
|
638
644
|
// The last resort, in this process only (never the library, the server's CLI or the runner beside a server): an error
|
|
639
645
|
// nothing handled is said with its stack, and the process exits 1 at once (lastResort: crashing is the safe failure).
|
|
640
646
|
const fatal = lastResort(runnerOf);
|
|
@@ -661,7 +667,7 @@ export async function runnerMain(argv, given = process.env, hooks = {}) {
|
|
|
661
667
|
drainMs: holds.drainMs,
|
|
662
668
|
// Each run a process of its own (`isolation`); its computer, with this runner's relay's dial, held here in the
|
|
663
669
|
// runner, which the run's process asks for it over its channel (run-child-host.ts, held.ts computer).
|
|
664
|
-
createLoop: ofStore((store, sealKey, dial) => runnerLoop(store, args.dataDir, env, sealKey, isolation, dial)),
|
|
670
|
+
createLoop: ofStore((store, sealKey, dial, paired) => runnerLoop(store, args.dataDir, env, sealKey, isolation, dial, paired)),
|
|
665
671
|
// Each run's own process weighed beside its harness's run (memory-claim.ts RUN_PROCESS_MIB).
|
|
666
672
|
processMib: RUN_PROCESS_MIB,
|
|
667
673
|
// The runner subcommand ends what a crashed runner of this server left (never under --faux).
|
package/dist/runner/mcp-claim.js
CHANGED
|
@@ -26,7 +26,10 @@
|
|
|
26
26
|
// refused unsent (UNUSABLE.perRunMissing).
|
|
27
27
|
//
|
|
28
28
|
// A per-run Composio server (composio-made.ts composioPerRun) is bound by each run's caller ({composio_user_id,
|
|
29
|
-
// connected_account_id?} in mcp_auth, sealed in its launch): its entry carries them as `query` (mcp-gateway.ts).
|
|
29
|
+
// connected_account_id?} in mcp_auth, sealed in its launch): its entry carries them as `query` (mcp-gateway.ts). Each
|
|
30
|
+
// open reads the owner's Composio users again (composio-owners.ts): a binding of one that the owner's session didn't hand
|
|
31
|
+
// (the token's, or one sealed before the seal marked who handed it) is refused unsent (UNUSABLE.composioOwnersUser); on
|
|
32
|
+
// an API-only store, any binding of one is (COMPOSIO_OWNERS_USER_WORDS).
|
|
30
33
|
// A Composio server saved with api_key_env (composio-made.ts key_env) seals no key: each open reads the variable's value
|
|
31
34
|
// as the runner was handed it at its start (secrets.ts secret, never its environment), for an address on Composio's origin
|
|
32
35
|
// alone (composioEnvKey), and only for a server the run is granted: the run's process never holds it. Unset, or a row at
|
|
@@ -55,13 +58,14 @@
|
|
|
55
58
|
// the next call sends the new one (or is refused for the move); and an OAuth access token within REFRESH_MARGIN_MS of its
|
|
56
59
|
// end is refreshed through open's lease path: behind the call while the token is still valid (the call goes at once on
|
|
57
60
|
// it), waited on only when it has run out. Concurrent calls to one server share one such open.
|
|
58
|
-
import { heldApiOnlyMcpOrigins, offApiOnlyMcpOrigins } from "../mcp-api-only-origins.js";
|
|
61
|
+
import { composioOutsideNamespace, heldApiOnlyMcpOrigins, offApiOnlyMcpOrigins } from "../mcp-api-only-origins.js";
|
|
62
|
+
import { bindingRuns, ownersComposioUsers, ownersUser } from "../composio-owners.js";
|
|
59
63
|
import { randomUUID } from "node:crypto";
|
|
60
64
|
import { EndpointRefused, REFRESH_REQUEST_MS, refreshed, refused, RequestUnsent, systemNetwork } from "../mcp-oauth.js";
|
|
61
65
|
import { pinFirst } from "../mcp-pin-first.js";
|
|
62
66
|
import { mcpNameOf } from "../tool-names.js";
|
|
63
67
|
import { composioEnvKey, composioMadeKey, composioPerRun, recordedMade } from "../composio-made.js";
|
|
64
|
-
import { composioRunQuery } from "../composio-preset.js";
|
|
68
|
+
import { COMPOSIO_OWNERS_USER_WORDS, composioRunQuery } from "../composio-preset.js";
|
|
65
69
|
import { META_REASON, metaToolOf } from "../mcp-meta.js";
|
|
66
70
|
import { resourceToolProblem } from "../mcp-resources.js";
|
|
67
71
|
import { credentialInQuery, credentialInQueryWords, shownUrl } from "../mcp-probe.js";
|
|
@@ -237,6 +241,10 @@ export async function mcpClaim(options) {
|
|
|
237
241
|
const account = row.auth === "headers" ? await composioAccount(name, row) : undefined;
|
|
238
242
|
if (account && "unopened" in account)
|
|
239
243
|
return entry({ unopened: account.unopened }), { awaited: false };
|
|
244
|
+
// One the API token saved calling as a user outside its namespace (saved before it): refused unsent, as said at start.
|
|
245
|
+
const outside = account ? undefined : await composioOutsideNamespace(store, name, row);
|
|
246
|
+
if (outside)
|
|
247
|
+
return entry({ unopened: outside }), { awaited: false };
|
|
240
248
|
const query = account?.query;
|
|
241
249
|
// Its key named by api_key_env: the value the runner was handed at its start, for an address on Composio's origin
|
|
242
250
|
// alone; else its calls refused unsent, naming why (composioEnvKey).
|
|
@@ -406,12 +414,20 @@ export async function mcpClaim(options) {
|
|
|
406
414
|
};
|
|
407
415
|
/** A per-run Composio server's account for this run, as the query its requests add (composio-preset.ts
|
|
408
416
|
* composioRunQuery); or why there is none. Undefined: `row` is no per-run Composio server (its own record says so:
|
|
409
|
-
* composioPerRun).
|
|
417
|
+
* composioPerRun). A binding of a user the owner calls as (composio-owners.ts ownersComposioUsers, the start's own
|
|
418
|
+
* check, read again: one sealed before the check, or before the owner's server was saved) is refused unsent: on an
|
|
419
|
+
* API-only store whoever handed it, on a full one unless the owner's session did (bindingRuns). */
|
|
410
420
|
const composioAccount = async (name, row) => {
|
|
411
421
|
if (!composioPerRun(row, await store.settings.get(composioMadeKey(name))))
|
|
412
422
|
return undefined;
|
|
413
423
|
const given = await handed(name, row.url, "composio");
|
|
414
|
-
|
|
424
|
+
if ("unopened" in given)
|
|
425
|
+
return given;
|
|
426
|
+
const owners = await ownersComposioUsers(store);
|
|
427
|
+
const apiOnly = (await heldApiOnlyMcpOrigins(store)) !== undefined;
|
|
428
|
+
if (apiOnly ? ownersUser(owners, given.composio.user_id) : !bindingRuns(given.composio, owners))
|
|
429
|
+
return { unopened: apiOnly ? COMPOSIO_OWNERS_USER_WORDS : UNUSABLE.composioOwnersUser };
|
|
430
|
+
return { query: composioRunQuery(given.composio) };
|
|
415
431
|
};
|
|
416
432
|
const fresh = async () => {
|
|
417
433
|
if (!pin || released)
|
|
@@ -443,8 +459,9 @@ export async function mcpClaim(options) {
|
|
|
443
459
|
// The list is read first: with none held (a full server's store) the row is not read, and nothing is refused.
|
|
444
460
|
let listMoved = false;
|
|
445
461
|
if (stamp.auth === "per_run") {
|
|
446
|
-
const
|
|
447
|
-
|
|
462
|
+
const held = await heldApiOnlyMcpOrigins(store);
|
|
463
|
+
const row = held ? await getMcpServer(store, name) : undefined;
|
|
464
|
+
listMoved = (row !== undefined && (await offApiOnlyMcpOrigins(store, name, row, held)) !== undefined) !== offList.has(name);
|
|
448
465
|
if (released)
|
|
449
466
|
return;
|
|
450
467
|
}
|
package/dist/runner/mcp-run.d.ts
CHANGED
|
@@ -75,15 +75,12 @@ export interface McpForClaimOptions {
|
|
|
75
75
|
readonly hold?: (values: string[]) => void;
|
|
76
76
|
}
|
|
77
77
|
/** What a spec builder gives a claim's MCP for its metered jobs (`capped` and `media`), the same for every builder:
|
|
78
|
-
* whether its launch has a cap, and where a job's input media are read from: the
|
|
79
|
-
* builder's `env`, in web_save's slots. */
|
|
78
|
+
* whether its launch has a cap, and where a job's input media are read from: the run's eval web fake (`web`, as its
|
|
79
|
+
* builder read the run's fakes, once), else the builder's `env`, in web_save's slots. */
|
|
80
80
|
export declare function claimMetering(deps: {
|
|
81
81
|
readonly env: NodeJS.ProcessEnv;
|
|
82
|
-
readonly evalFakes?: (agentId: string) => {
|
|
83
|
-
readonly web?: WebFake;
|
|
84
|
-
} | undefined;
|
|
85
82
|
readonly saveSlots?: SaveSlots;
|
|
86
|
-
},
|
|
83
|
+
}, web: WebFake | undefined, launch: {
|
|
87
84
|
readonly maxCostUsd?: number | undefined;
|
|
88
85
|
}): Pick<McpForClaimOptions, "capped" | "media">;
|
|
89
86
|
/** A claim's MCP (AdapterRunSpec.mcp): what the loop reaches the gateway by, and the claim step's own hooks. */
|
package/dist/runner/mcp-run.js
CHANGED
|
@@ -14,10 +14,9 @@ import { registryListing } from "../mcp-pin-first.js";
|
|
|
14
14
|
import { heldOrThrow } from "./held.js";
|
|
15
15
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
16
16
|
/** What a spec builder gives a claim's MCP for its metered jobs (`capped` and `media`), the same for every builder:
|
|
17
|
-
* whether its launch has a cap, and where a job's input media are read from: the
|
|
18
|
-
* builder's `env`, in web_save's slots. */
|
|
19
|
-
export function claimMetering(deps,
|
|
20
|
-
const web = deps.evalFakes?.(agentId)?.web;
|
|
17
|
+
* whether its launch has a cap, and where a job's input media are read from: the run's eval web fake (`web`, as its
|
|
18
|
+
* builder read the run's fakes, once), else the builder's `env`, in web_save's slots. */
|
|
19
|
+
export function claimMetering(deps, web, launch) {
|
|
21
20
|
return { capped: launch.maxCostUsd !== undefined, media: { env: deps.env, ...(web ? { web } : {}), ...(deps.saveSlots ? { slots: deps.saveSlots } : {}) } };
|
|
22
21
|
}
|
|
23
22
|
/** The wire names a subagent's `grant` gives of the run's MCP and monid tools, by the gate's keys; else the grant's own. */
|
|
@@ -69,7 +69,7 @@ export function refusedName(caller, name, tools, hostName = (given) => given) {
|
|
|
69
69
|
}
|
|
70
70
|
const NO_NESTED = (caller) => `${caller} can't run here: this harness gives it no way to call the run's tools. Nothing was run.`;
|
|
71
71
|
/** A nested answer as a tool's answer. */
|
|
72
|
-
const answered = (result) => ({ text: result.text, ...(result.isError ? { isError: true } : {}), ...(result.images?.length ? { images: result.images } : {}), ...(result.structured !== undefined ? { structured: result.structured } : {}) });
|
|
72
|
+
const answered = (result) => ({ text: result.text, ...(result.isError ? { isError: true } : {}), ...(result.images?.length ? { images: result.images } : {}), ...(result.structured !== undefined ? { structured: result.structured } : {}), ...(result.refused ? { refused: true } : {}) });
|
|
73
73
|
/** A script's `computer` (the computer package's bindComputer, over its card) as one expression of the script's isolate
|
|
74
74
|
* over its `tools`: an observe, an act or a screenshot calls its own step tool, every other op computer_op, so each is a
|
|
75
75
|
* nested call of the run's tool, asked about and recorded as that tool's. On an agent whose exec is off, reaching for
|
|
@@ -337,8 +337,9 @@ function scriptValue(result) {
|
|
|
337
337
|
* rerun, after a person's answer or a crash) that call's outcome, with every call before it as recorded. */
|
|
338
338
|
function endedWith(told, last, ranNow) {
|
|
339
339
|
const lines = told.map(({ name, result }, i) => lineOf(i + 1, name, result));
|
|
340
|
+
// Marked refused: the script's own row reads Refused, as the call it stopped at does, never a red Error.
|
|
340
341
|
if (last.refused)
|
|
341
|
-
return { text: `${last.text}\nThe script stopped at this refused call, and nothing after it ran. Its calls, in order:\n${lines.join("\n")}`, isError: true };
|
|
342
|
+
return { text: `${last.text}\nThe script stopped at this refused call, and nothing after it ran. Its calls, in order:\n${lines.join("\n")}`, isError: true, refused: true };
|
|
342
343
|
if (!ranNow)
|
|
343
344
|
return { text: `The script stopped at a call cut off before it reported a result, and nothing after it ran. Its calls, in order:\n${lines.join("\n")}`, isError: true };
|
|
344
345
|
const head = `The script was stopped (it waited for a person's answer, or the session stopped), and run again only as far as its next call, which ran once: ${last.isError ? "it failed" : "its outcome is below"}. The rest of the script did not run; run what is still needed again.`;
|
package/dist/runner/metrics.d.ts
CHANGED
|
@@ -74,6 +74,13 @@ export declare function bookedSpend(entries: readonly EntryLike[], which: "model
|
|
|
74
74
|
* every other decision left out: the ones a vendor charged as a paid call (store-reads/decisions.ts
|
|
75
75
|
* parallelChargedDecisions), which the run's tools figures count beside its paid tool calls. */
|
|
76
76
|
export declare function bookedDecisionsOf(entries: readonly EntryLike[], ids: ReadonlySet<string>): BookedSpend;
|
|
77
|
+
/** What one call of a tool booked, over `entries` (every conversation of the run's journal, in log order), by the run's
|
|
78
|
+
* one rule (runCostOf): each request whose record names the call or one nested in it (`call`: `callId`, or
|
|
79
|
+
* `callId/...`), and each request of host work (a side or host call, a paid tool call, a decision) admitted after the
|
|
80
|
+
* call's start (`from`, an index in `entries`) and at or before its end (`to`). The caller holds the window to the one
|
|
81
|
+
* call (runner/workflow-calls.ts). $0 for none; null once one has no known cost, or one a crash cut is counted at its
|
|
82
|
+
* hold (`atMost`: the most it can cost, never what it cost). */
|
|
83
|
+
export declare function callCostOf(entries: readonly EntryLike[], callId: string, from: number, to: number): number | null;
|
|
77
84
|
/** A cost of charges as a usage row or a run's cost block says it (costsofar/1, cutathold/1), by the kernel's one rule
|
|
78
85
|
* (costOfParts) over `parts`, its float noise rounded off (floatNoiseOff): `usd` their sum, `upper_bound` when it counts
|
|
79
86
|
* a cut request at its hold, with `so_far_usd` the charges' own figures alone and `unpriced` how many it counts at their
|
package/dist/runner/metrics.js
CHANGED
|
@@ -169,6 +169,25 @@ export function bookedDecisionsOf(entries, ids) {
|
|
|
169
169
|
const kept = new Set(entries.filter((e) => e.kind === RUNNER_RECORDS.request && typeof named(e) === "string" && named(e).startsWith("decision:") && ids.has(named(e).slice("decision:".length))).map(turnOf));
|
|
170
170
|
return bookedSpend(entries.filter((e) => !(e.kind === RUNNER_RECORDS.request || e.kind === RUNNER_RECORDS.turn) || kept.has(turnOf(e))), "decisions");
|
|
171
171
|
}
|
|
172
|
+
/** What one call of a tool booked, over `entries` (every conversation of the run's journal, in log order), by the run's
|
|
173
|
+
* one rule (runCostOf): each request whose record names the call or one nested in it (`call`: `callId`, or
|
|
174
|
+
* `callId/...`), and each request of host work (a side or host call, a paid tool call, a decision) admitted after the
|
|
175
|
+
* call's start (`from`, an index in `entries`) and at or before its end (`to`). The caller holds the window to the one
|
|
176
|
+
* call (runner/workflow-calls.ts). $0 for none; null once one has no known cost, or one a crash cut is counted at its
|
|
177
|
+
* hold (`atMost`: the most it can cost, never what it cost). */
|
|
178
|
+
export function callCostOf(entries, callId, from, to) {
|
|
179
|
+
const keyed = sessionConversations(entries);
|
|
180
|
+
const hosted = new Set([keyed.get(TOOL_SESSION), keyed.get(DECISION_SESSION)].filter((one) => one !== undefined));
|
|
181
|
+
const ours = (e, at) => {
|
|
182
|
+
const d = (e.data ?? {});
|
|
183
|
+
if (typeof d.call === "string" && (d.call === callId || d.call.startsWith(`${callId}/`)))
|
|
184
|
+
return true;
|
|
185
|
+
return at > from && at <= to && (typeof d.host === "string" || d.side === true || hosted.has(Number(e.conversationId)));
|
|
186
|
+
};
|
|
187
|
+
const kept = new Set(entries.flatMap((e, at) => (e.kind === RUNNER_RECORDS.request && ours(e, at) ? [turnOf(e)] : [])));
|
|
188
|
+
const cost = runCostOf(entries.filter((e) => !(e.kind === RUNNER_RECORDS.request || e.kind === RUNNER_RECORDS.turn) || kept.has(turnOf(e))));
|
|
189
|
+
return cost.atMost > 0 ? null : cost.usd;
|
|
190
|
+
}
|
|
172
191
|
/** A sum of charges with its float noise rounded off, nothing more (as the decisions row rounds, decision-rows.ts): a
|
|
173
192
|
* decision costs millionths of a dollar, so a sum rounded to the millionth would lose it. */
|
|
174
193
|
const floatNoiseOff = (usd) => Math.round(usd * 1e12) / 1e12;
|
|
@@ -146,16 +146,19 @@ export declare function routeOf(model: string | PinnedModel | undefined, env?: N
|
|
|
146
146
|
* as one the model proxy sends there does; a request to any other provider carries none. */
|
|
147
147
|
export declare function messagesFetch(models: PiModels, target: PiModel, redact?: Redact, upstream?: typeof fetch, env?: NodeJS.ProcessEnv): typeof fetch;
|
|
148
148
|
/** `route` (a translated route's fetch, which streams every answer, as pi-ai asks) for any Messages client on the wire it
|
|
149
|
-
* translates onto, which asks
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
149
|
+
* translates onto, which asks things pi-ai never does. It takes POST /v1/messages and POST /v1/messages/count_tokens
|
|
150
|
+
* alone; anything else is a 404, never run as a chat. Its token count (free, asked beside its turns) is answered here
|
|
151
|
+
* and never run on the model, which has no count of its own: the body's bytes over four (COUNT_BYTES_PER_TOKEN), a
|
|
152
|
+
* bound for its context, not a price. A request with no `stream: true` (a side request) gets its answer whole, one JSON
|
|
153
|
+
* message as Messages writes it, joined from the stream (wholeOf). Its output schema (output_config.format) is the
|
|
154
|
+
* model's format (outputSchema). What the model here cannot keep is refused with a 400 before it is asked: a tool_choice
|
|
155
|
+
* that forces a call (forcedChoice), an output schema beside tools. */
|
|
154
156
|
export declare function forMessagesClients(route: typeof fetch): typeof fetch;
|
|
155
157
|
/** The route's translation onto each wire it translates a model onto (wires.ts TRANSLATED), by wire: what a harness's
|
|
156
158
|
* proxy on that wire forwards with for `model` (`provider/model-id`), made on `env`. Anthropic's Messages: the route's
|
|
157
|
-
* own Messages fetch (messagesFetch), as a Messages client asks it (forMessagesClients).
|
|
158
|
-
* it; a wire with no entry has no
|
|
159
|
+
* own Messages fetch (messagesFetch), as a Messages client asks it (forMessagesClients). OpenAI's Responses: that same
|
|
160
|
+
* fetch under a Responses edge (responsesFetch). provider.ts routedProvider reads it; a wire with no entry has no
|
|
161
|
+
* translation, whatever TRANSLATED says. */
|
|
159
162
|
export declare const TRANSLATORS: Readonly<Partial<Record<Wire, (model: string, env: NodeJS.ProcessEnv) => Promise<typeof fetch>>>>;
|
|
160
163
|
/** A text-tools re-ask's output limit: the most tokens it may answer with when what is left of the request's hold is
|
|
161
164
|
* `leftUsd` (its first try's input as it was billed and its output limit `outputHeld`, less every try so far) and its
|