@parcha/agentrun-serve 0.1.0-beta.38 → 0.1.0-beta.39
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 +418 -0
- package/README.md +325 -124
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +0 -2
- package/dist/agents-store.d.ts +5 -5
- package/dist/agents-store.js +14 -14
- package/dist/bash-read-only.js +2 -1
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -10
- package/dist/cap.js +2 -5
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +1 -5
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +8 -0
- package/dist/composio-preset.js +8 -7
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.js +2 -2
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +7 -2
- package/dist/computer-live.js +9 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +3 -3
- package/dist/computer-setting.js +5 -5
- package/dist/computer-view.d.ts +15 -0
- package/dist/computer-view.js +16 -2
- package/dist/computer-viewer.js +14 -1
- package/dist/computers.d.ts +5 -2
- package/dist/computers.js +9 -5
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.js +3 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -26
- package/dist/harness-opencode/facts.js +5 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -0
- package/dist/harness-opencode/host/policy.js +10 -5
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.js +8 -5
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/hosted-search.d.ts +3 -1
- package/dist/hosted-search.js +51 -11
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/learn/check.d.ts +18 -3
- package/dist/learn/check.js +328 -3
- package/dist/learn/compile.d.ts +9 -2
- package/dist/learn/compile.js +52 -16
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +106 -51
- package/dist/learn/promote.js +82 -189
- package/dist/learn/refit.d.ts +21 -12
- package/dist/learn/refit.js +51 -23
- package/dist/learn/replay-calls.js +1 -1
- package/dist/learn/skills.d.ts +2 -7
- package/dist/learn/skills.js +28 -14
- package/dist/learned-nodes.d.ts +15 -7
- package/dist/learned-nodes.js +29 -5
- package/dist/learned-workflow.d.ts +41 -31
- package/dist/learned-workflow.js +122 -63
- package/dist/learning-batch.js +3 -3
- package/dist/learning-cost.d.ts +26 -8
- package/dist/learning-cost.js +17 -7
- package/dist/learning-routes.d.ts +2 -4
- package/dist/learning-routes.js +20 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +4 -1
- package/dist/learning.d.ts +5 -5
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-pin-first.js +6 -0
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +25 -16
- package/dist/mcp-servers-store.js +23 -3
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +26 -6
- package/dist/model.js +126 -18
- package/dist/monid.d.ts +26 -31
- package/dist/monid.js +84 -79
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +394 -85
- package/dist/paid-calls.d.ts +8 -3
- package/dist/paid-calls.js +6 -2
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +1 -2
- package/dist/propose.js +10 -1
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +8 -0
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/run-launch.d.ts +10 -1
- package/dist/run-launch.js +11 -4
- package/dist/run-learning-served.d.ts +75 -2
- package/dist/run-manifest.d.ts +3 -0
- package/dist/run-manifest.js +13 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +8 -9
- package/dist/run-view.d.ts +42 -35
- package/dist/run-view.js +79 -44
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +42 -11
- package/dist/runner/adapter-loop.js +651 -247
- package/dist/runner/adapter-run-spec.d.ts +37 -12
- package/dist/runner/adapter-run-spec.js +139 -106
- package/dist/runner/adapters/pi.d.ts +24 -0
- package/dist/runner/adapters/pi.js +59 -9
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +94 -50
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +3 -2
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.js +6 -3
- package/dist/runner/end-of-run.d.ts +2 -0
- package/dist/runner/end-of-run.js +3 -1
- package/dist/runner/feedback-round.d.ts +40 -13
- package/dist/runner/feedback-round.js +64 -16
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +37 -13
- package/dist/runner/journal-kinds.js +9 -5
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +4 -0
- package/dist/runner/learning-end.js +64 -36
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +19 -4
- package/dist/runner/loop.d.ts +18 -0
- package/dist/runner/loop.js +34 -0
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-run.d.ts +4 -1
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/meta-tools.d.ts +10 -3
- package/dist/runner/meta-tools.js +112 -36
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +114 -39
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +139 -18
- package/dist/runner/monid-run.d.ts +8 -6
- package/dist/runner/monid-run.js +117 -43
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +74 -8
- package/dist/runner/promotion.js +365 -124
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.js +9 -0
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +8 -4
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/workflow-first.d.ts +30 -20
- package/dist/runner/workflow-first.js +22 -32
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +18 -12
- package/dist/runner/workflow-spec.d.ts +4 -1
- package/dist/runner/workflow-spec.js +56 -45
- package/dist/runs-over-store.d.ts +30 -2
- package/dist/runs-over-store.js +46 -14
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +48 -32
- package/dist/server.js +554 -130
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +12 -8
- package/dist/store/agent-body.js +9 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.js +20 -1
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +14 -3
- package/dist/store/sqlite/store.js +133 -18
- package/dist/store/store.d.ts +52 -7
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +5 -0
- package/dist/store-reads/journal.js +85 -41
- package/dist/store-reads/learning.d.ts +85 -5
- package/dist/store-reads/learning.js +45 -17
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +75 -21
- package/dist/template-eval.d.ts +73 -11
- package/dist/template-eval.js +535 -75
- package/dist/templates.d.ts +70 -20
- package/dist/templates.js +191 -34
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/index.d.ts +3 -2
- package/dist/timeline/index.js +3 -2
- package/dist/timeline/labels.d.ts +5 -2
- package/dist/timeline/labels.js +29 -6
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +66 -4
- package/dist/timeline/timeline.js +160 -30
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +42 -42
- package/dist/tool-gate.js +97 -91
- package/dist/tool-list.d.ts +4 -1
- package/dist/tool-list.js +8 -1
- package/dist/tool-names.d.ts +18 -13
- package/dist/tool-names.js +19 -17
- package/dist/tool-plane.d.ts +17 -13
- package/dist/tool-plane.js +12 -5
- package/dist/tools.d.ts +44 -16
- package/dist/tools.js +28 -28
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.js +1 -7
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +5 -1
- package/dist/web-fetch.js +8 -31
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +22 -9
- package/dist/workspace/computer-deps.js +78 -37
- package/dist/workspace/computer-for-claim.d.ts +54 -4
- package/dist/workspace/computer-for-claim.js +179 -39
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
- package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
- package/dist/workspace/resolve-computer.d.ts +15 -3
- package/dist/workspace/resolve-computer.js +10 -7
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +28 -29
- package/dist/workspace/run-tools.js +29 -30
- package/dist/wrap-up.d.ts +19 -5
- package/dist/wrap-up.js +31 -4
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +117 -23
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +18 -4
- package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +1 -1
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/skills/review/DEEP.md +2 -2
- package/templates/code-review/skills/review/REVIEWER.md +2 -2
- package/templates/code-review/skills/review/SKILL.md +7 -3
- package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
- package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
- package/templates/release-notes/evals/other-repo/case.yaml +1 -1
- package/dist/console/assets/index-CjqQirbo.css +0 -1
- package/dist/console/assets/index-b6-XY5A9.js +0 -576
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -9
- package/dist/runner/adapters/pi-computer.js +0 -51
- package/dist/workspace/computer-script.d.ts +0 -53
- package/dist/workspace/computer-script.js +0 -172
package/dist/paid-calls.d.ts
CHANGED
|
@@ -42,7 +42,8 @@ export type LedgerRefusal = Refusal;
|
|
|
42
42
|
/** The kernel cap's booking of a run's paid calls (RunTools), as a paid request uses it. */
|
|
43
43
|
export type PaidBooking = {
|
|
44
44
|
/** `chargedBy`: who charges for it (the charge's `charged_by` on main's records: parallel, monid, an MCP server, a
|
|
45
|
-
* browser vendor), named on its runner.request.
|
|
45
|
+
* browser vendor), named on its runner.request. `under`: the model session whose tool call it runs in (RunTools.admit),
|
|
46
|
+
* whose requests in flight it is judged beside and never waits on. */
|
|
46
47
|
admit(request: {
|
|
47
48
|
id: string;
|
|
48
49
|
name: string;
|
|
@@ -55,6 +56,7 @@ export type PaidBooking = {
|
|
|
55
56
|
owed?: true;
|
|
56
57
|
hold?: true;
|
|
57
58
|
ref?: string;
|
|
59
|
+
under?: string;
|
|
58
60
|
}): Promise<unknown>;
|
|
59
61
|
/** `givenBack`: the hold let go unused, nothing sent (RunTools.settle). */
|
|
60
62
|
settle(id: string, usd: number | null, options?: {
|
|
@@ -78,6 +80,8 @@ export declare const bookedIn: <T>(ledger: Ledger | undefined, work: () => Promi
|
|
|
78
80
|
* less. It throws PaidRefused, in the cap's words, when the cap does not hold its price, when its hold could not be kept,
|
|
79
81
|
* or when the call has no run's ledger, and then nothing is sent. A request that throws throws, settled at its price. */
|
|
80
82
|
export declare function paidRequest(fee: Fee, send: () => Promise<Response>): Promise<Response>;
|
|
83
|
+
/** paidStep's chargeOf for a step that charged nothing and is given back: its mark settled with no charge row. */
|
|
84
|
+
export declare const GIVEN_BACK = "given back";
|
|
81
85
|
/** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
|
|
82
86
|
export declare const paidLedger: () => PaidBooking | undefined;
|
|
83
87
|
/** Stops the run the current call books in, in `words`: handed to its pause (Ledger.pause) as a cap refusal no raise
|
|
@@ -86,7 +90,8 @@ export declare const paidLedger: () => PaidBooking | undefined;
|
|
|
86
90
|
* request reads as the cap's refusal (no model error row of its own). */
|
|
87
91
|
export declare const stopRun: (words: string) => Promise<void>;
|
|
88
92
|
/** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
|
|
89
|
-
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold
|
|
93
|
+
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold; GIVEN_BACK:
|
|
94
|
+
* given back, nothing charged, as a hold-only step's: a request its provider refused unrun leaves no charge row). One refused
|
|
90
95
|
* for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
|
|
91
96
|
* paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
|
|
92
97
|
export declare function paidStep<T>(paid: PaidBooking, call: string | undefined, fee: {
|
|
@@ -103,7 +108,7 @@ export declare function paidStep<T>(paid: PaidBooking, call: string | undefined,
|
|
|
103
108
|
result: T;
|
|
104
109
|
} | {
|
|
105
110
|
thrown: unknown;
|
|
106
|
-
}) => number | null, pause?: Ledger["pause"]): Promise<{
|
|
111
|
+
}) => number | null | typeof GIVEN_BACK, pause?: Ledger["pause"]): Promise<{
|
|
107
112
|
refused: string;
|
|
108
113
|
} | {
|
|
109
114
|
result: T;
|
package/dist/paid-calls.js
CHANGED
|
@@ -97,6 +97,8 @@ export async function paidRequest(fee, send) {
|
|
|
97
97
|
throw new PaidRefused(stepped.refused);
|
|
98
98
|
return stepped.result;
|
|
99
99
|
}
|
|
100
|
+
/** paidStep's chargeOf for a step that charged nothing and is given back: its mark settled with no charge row. */
|
|
101
|
+
export const GIVEN_BACK = "given back";
|
|
100
102
|
/** Each paid request of this process on the run's one ledger, numbered within its call (one call may make several). */
|
|
101
103
|
let paidSeq = 0;
|
|
102
104
|
/** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
|
|
@@ -109,7 +111,8 @@ export const stopRun = async (words) => {
|
|
|
109
111
|
await ledgers.getStore()?.pause?.({ refuse: words, code: SPEND_CAP_REACHED, forGood: true });
|
|
110
112
|
};
|
|
111
113
|
/** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
|
|
112
|
-
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold
|
|
114
|
+
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold; GIVEN_BACK:
|
|
115
|
+
* given back, nothing charged, as a hold-only step's: a request its provider refused unrun leaves no charge row). One refused
|
|
113
116
|
* for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
|
|
114
117
|
* paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
|
|
115
118
|
export async function paidStep(paid, call, fee, run, chargeOf, pause) {
|
|
@@ -133,7 +136,8 @@ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
|
|
|
133
136
|
outcome = { thrown };
|
|
134
137
|
}
|
|
135
138
|
// A hold-only step (`hold`) is given back, never a charge: its money is booked by its own charges' steps.
|
|
136
|
-
|
|
139
|
+
const charge = fee.hold ? GIVEN_BACK : chargeOf(outcome);
|
|
140
|
+
await (charge === GIVEN_BACK ? paid.settle(id, 0, { givenBack: true }) : paid.settle(id, charge)).catch(() => undefined);
|
|
137
141
|
if ("thrown" in outcome)
|
|
138
142
|
throw outcome.thrown;
|
|
139
143
|
return outcome;
|
package/dist/place-offers.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
/** Why a remote box (Daytona's, Modal's) has no network, said in capabilities whenever the server's host list is set:
|
|
2
|
-
* its computer is made with no network (Daytona) or no network or an open one (Modal), never with a host list, so a
|
|
3
|
-
* list is narrowed to none (workspace/computer-deps.ts networkOf). */
|
|
4
|
-
export declare const remoteNoList: (id: "daytona" | "modal") => string;
|
|
5
1
|
/** Every box a place may name, in the order capabilities lists them. */
|
|
6
2
|
export declare const BOX_IDS: readonly ["docker", "modal", "daytona"];
|
|
7
3
|
export type BoxId = (typeof BOX_IDS)[number];
|
|
8
4
|
/** A box as capabilities show it: whether this server has it, and why when not (or how it was checked); `state`, which
|
|
9
5
|
* capabilities derive from it (place.ts stated). `network`: what an available box reaches (BOX_NETWORKS), with
|
|
10
|
-
* `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere
|
|
11
|
-
* computer is never made with a host list). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
|
|
6
|
+
* `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
|
|
12
7
|
* its computers' egress proxy refuses as the host's (docker-host-addresses.ts: the read through the socket and
|
|
13
8
|
* AGENTRUN_DOCKER_HOST_ADDRESSES). */
|
|
14
9
|
export type BoxOffer = {
|
|
@@ -87,8 +82,9 @@ export declare function placeOffers(env: NodeJS.ProcessEnv, options?: PlaceOffer
|
|
|
87
82
|
/** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
|
|
88
83
|
* computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
|
|
89
84
|
* runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
|
|
90
|
-
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's
|
|
91
|
-
*
|
|
85
|
+
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's through the
|
|
86
|
+
* egress proxy their computer's init starts (an allowlist too: @parcha/agentrun-computer's hosted/network.ts). With
|
|
87
|
+
* `allow` none, none has a network. */
|
|
92
88
|
export declare function withNetworks(offers: readonly BoxOffer[], allow: readonly string[] | "none", docker?: {
|
|
93
89
|
refused?: string;
|
|
94
90
|
hostAddresses?: readonly string[];
|
package/dist/place-offers.js
CHANGED
|
@@ -14,10 +14,6 @@ import { readFile } from "node:fs/promises";
|
|
|
14
14
|
import { userInfo } from "node:os";
|
|
15
15
|
import { PROVIDERS } from "@parcha/agentrun-computer";
|
|
16
16
|
import { withoutSecrets } from "./secrets.js";
|
|
17
|
-
/** Why a remote box (Daytona's, Modal's) has no network, said in capabilities whenever the server's host list is set:
|
|
18
|
-
* its computer is made with no network (Daytona) or no network or an open one (Modal), never with a host list, so a
|
|
19
|
-
* list is narrowed to none (workspace/computer-deps.ts networkOf). */
|
|
20
|
-
export const remoteNoList = (id) => `a ${id === "daytona" ? "Daytona" : "Modal"} computer is never made with a host list, so a ${id} box has no network`;
|
|
21
17
|
/** Every box a place may name, in the order capabilities lists them. */
|
|
22
18
|
export const BOX_IDS = ["docker", "modal", "daytona"];
|
|
23
19
|
/** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
|
|
@@ -180,8 +176,9 @@ export async function placeOffers(env, options = {}) {
|
|
|
180
176
|
/** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
|
|
181
177
|
* computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
|
|
182
178
|
* runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
|
|
183
|
-
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's
|
|
184
|
-
*
|
|
179
|
+
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's through the
|
|
180
|
+
* egress proxy their computer's init starts (an allowlist too: @parcha/agentrun-computer's hosted/network.ts). With
|
|
181
|
+
* `allow` none, none has a network. */
|
|
185
182
|
export function withNetworks(offers, allow, docker = {}) {
|
|
186
183
|
return offers.map((offer) => {
|
|
187
184
|
if (!offer.available)
|
|
@@ -195,8 +192,6 @@ export function withNetworks(offers, allow, docker = {}) {
|
|
|
195
192
|
return { ...offer, network: "none", network_reason: "AGENTRUN_BOX_ALLOW is none" };
|
|
196
193
|
return { ...offer, network: "allowlist", ...(docker.hostAddresses?.length ? { host_addresses: [...docker.hostAddresses] } : {}) };
|
|
197
194
|
}
|
|
198
|
-
|
|
199
|
-
return { ...offer, network: "none" };
|
|
200
|
-
return { ...offer, network: "none", network_reason: remoteNoList(offer.id) };
|
|
195
|
+
return { ...offer, network: allow === "none" ? "none" : "allowlist" };
|
|
201
196
|
});
|
|
202
197
|
}
|
package/dist/port-models.d.ts
CHANGED
|
@@ -10,11 +10,16 @@ export declare const tierProvider: (tier: string) => string;
|
|
|
10
10
|
* base; OpenAI's adds /responses to a base that holds /v1. The one rule for the port's models and pi's own (runner
|
|
11
11
|
* adapters/pi.ts). */
|
|
12
12
|
export declare const sessionBaseUrl: (api: SessionPort["api"], url: string) => string;
|
|
13
|
+
/** The effort a model asks for at each thinking level, as pi-ai's catalog says (null: no effort sent). */
|
|
14
|
+
export type ThinkingLevelMap = NonNullable<Model<Api>["thinkingLevelMap"]>;
|
|
13
15
|
/** The catalog's entry for a session's model, as its route carries it (model-route.ts `like`): its reasoning, price,
|
|
14
|
-
* window and ceiling, and what it takes as input with its input limits. */
|
|
15
|
-
|
|
16
|
+
* window and ceiling, the effort each thinking level asks for, and what it takes as input with its input limits. */
|
|
17
|
+
/** `developerRole`: on Responses, the instructions go as a developer message, not a system one (a ChatGPT plan's route,
|
|
18
|
+
* which takes no system message). */
|
|
19
|
+
export type SessionLike = Partial<Pick<Model<Api>, "reasoning" | "cost" | "contextWindow" | "maxTokens" | "thinkingLevelMap">> & {
|
|
16
20
|
readonly input?: readonly string[];
|
|
17
21
|
readonly inputLimits?: unknown;
|
|
22
|
+
readonly developerRole?: boolean;
|
|
18
23
|
};
|
|
19
24
|
/** The one model of a session's route as pi-ai lists it, for the port's requests and for pi's own (runner adapters/pi.ts):
|
|
20
25
|
* `model` in `api` at the proxy `url` (sessionBaseUrl), under `provider`, with `headers` (the session key as the proxy
|
package/dist/port-models.js
CHANGED
|
@@ -24,11 +24,14 @@ export function sessionModel(api, url, model, options) {
|
|
|
24
24
|
// What the model takes as input and its input limits, as the catalog says (the route's `like`): a model that takes no
|
|
25
25
|
// images is sent pi-ai's placeholder in place of one, and pi's read holds an image to its limits. Unsaid, text and
|
|
26
26
|
// images within pi's defaults.
|
|
27
|
-
|
|
27
|
+
// The effort each thinking level asks for, as the catalog says: a level it maps to null sends none, so pi's thinking
|
|
28
|
+
// off sends no "none" to a model that refuses it (gpt-6.1-sol). Unsaid, pi-ai's defaults.
|
|
29
|
+
reasoning: like?.reasoning ?? options.reasoning, ...(like?.thinkingLevelMap ? { thinkingLevelMap: like.thinkingLevelMap } : {}),
|
|
30
|
+
input: like?.input ? [...like.input] : ["text", "image"],
|
|
28
31
|
...(like?.inputLimits ? { inputLimits: like.inputLimits } : {}),
|
|
29
32
|
cost: like?.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
30
33
|
contextWindow: like?.contextWindow ?? 200_000, maxTokens: like?.maxTokens ?? 32_000,
|
|
31
|
-
...(api === "openai-responses" ? { compat: { supportsDeveloperRole:
|
|
34
|
+
...(api === "openai-responses" ? { compat: { supportsDeveloperRole: like?.developerRole === true } } : {}),
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
/** pi-ai's provider for the one model of a session's proxy on its wire: pi-ai's client of `api` (Anthropic's Messages or
|
package/dist/print.d.ts
CHANGED
|
@@ -21,8 +21,9 @@ export declare function banner(o: {
|
|
|
21
21
|
/** One log line. */
|
|
22
22
|
export declare const logLine: (event: string, fields?: Record<string, string | number>) => string;
|
|
23
23
|
/** The log line of a runner's start or end event (runner.ts RunnerEvent): `run_started` (run, agent, kind) once a run's
|
|
24
|
-
* first claim, `run_ended` (run, agent, status, cost_usd) once it is final
|
|
25
|
-
*
|
|
24
|
+
* first claim, `run_ended` (run, agent, status, cost_usd) once it is final: `cost_usd` the exact cost or "unknown", and
|
|
25
|
+
* beside an unknown one `cost_usd_at_most` when the run's stored cost is the most it can have cost. Any other event has
|
|
26
|
+
* none. Ids and numbers only: no token or secret reaches a line. */
|
|
26
27
|
export declare function runLine(event: {
|
|
27
28
|
type: string;
|
|
28
29
|
runId?: string;
|
|
@@ -30,6 +31,7 @@ export declare function runLine(event: {
|
|
|
30
31
|
kind?: string;
|
|
31
32
|
status?: string;
|
|
32
33
|
costUsd?: number | null;
|
|
34
|
+
costAtMostUsd?: number;
|
|
33
35
|
}): string | undefined;
|
|
34
36
|
/** A duration as --drain-timeout takes it ("8s", "500ms", "1m"), in milliseconds; undefined when it is not one. */
|
|
35
37
|
export declare function durationMs(text: string): number | undefined;
|
package/dist/print.js
CHANGED
|
@@ -26,13 +26,14 @@ const value = (v) => {
|
|
|
26
26
|
/** One log line. */
|
|
27
27
|
export const logLine = (event, fields = {}) => [`at=${new Date().toISOString()}`, `event=${event}`, ...Object.entries(fields).map(([k, v]) => `${k}=${value(v)}`)].join(" ");
|
|
28
28
|
/** The log line of a runner's start or end event (runner.ts RunnerEvent): `run_started` (run, agent, kind) once a run's
|
|
29
|
-
* first claim, `run_ended` (run, agent, status, cost_usd) once it is final
|
|
30
|
-
*
|
|
29
|
+
* first claim, `run_ended` (run, agent, status, cost_usd) once it is final: `cost_usd` the exact cost or "unknown", and
|
|
30
|
+
* beside an unknown one `cost_usd_at_most` when the run's stored cost is the most it can have cost. Any other event has
|
|
31
|
+
* none. Ids and numbers only: no token or secret reaches a line. */
|
|
31
32
|
export function runLine(event) {
|
|
32
33
|
if (event.type === "started")
|
|
33
34
|
return logLine("run_started", { run: event.runId, agent: event.agent, kind: event.kind });
|
|
34
35
|
if (event.type === "ended")
|
|
35
|
-
return logLine("run_ended", { run: event.runId, agent: event.agent, status: event.status === "ended" ? "completed" : event.status, cost_usd: event.costUsd ?? "unknown" });
|
|
36
|
+
return logLine("run_ended", { run: event.runId, agent: event.agent, status: event.status === "ended" ? "completed" : event.status, cost_usd: event.costUsd ?? "unknown", ...(event.costAtMostUsd !== undefined ? { cost_usd_at_most: event.costAtMostUsd } : {}) });
|
|
36
37
|
return undefined;
|
|
37
38
|
}
|
|
38
39
|
/** A duration as --drain-timeout takes it ("8s", "500ms", "1m"), in milliseconds; undefined when it is not one. */
|
package/dist/propose.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DraftAsk } from "./learn/skills.js";
|
|
2
1
|
import { type Problem } from "./learn/index.js";
|
|
3
2
|
import type { DraftDecisions } from "./learn/skills.js";
|
|
4
3
|
import { type Turn } from "./learning.js";
|
|
@@ -46,8 +45,8 @@ export declare const proposeRun: (input: {
|
|
|
46
45
|
tools?: readonly string[];
|
|
47
46
|
gated?: Readonly<Record<string, string>>;
|
|
48
47
|
deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
|
|
49
|
-
ask?: DraftAsk;
|
|
50
48
|
decisions?: DraftDecisions;
|
|
49
|
+
workflowAdapters?: readonly ("runNode" | "runJudge")[];
|
|
51
50
|
workflows?: false;
|
|
52
51
|
outputSchema?: unknown;
|
|
53
52
|
}) => Promise<Proposed>;
|
package/dist/propose.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Learning, after a run: the notes its end-of-run turn answered with, and a skill or a workflow draft beside them, are read
|
|
2
|
+
// by the host (learn/reflect.ts parseReflection), checked against the commit the run started from (learn/check.ts
|
|
3
|
+
// checkProposal), and kept as its proposal (`learning-proposal.json`, in the directory the caller gives), or dropped. The
|
|
4
|
+
// answer is what the runner's end-of-run turn read from the run's store (runner/learning-end.ts), never the run's work;
|
|
5
|
+
// and no file the run wrote is read at all, in `.learning/` or anywhere. The seed is
|
|
6
|
+
// read from the agent's learning folder through its Workspace, as the reflect hook's check reads it (learn/seed-check.ts):
|
|
7
|
+
// the snapshot and its bodies when main is the seed (no exec), else one read-only exec of the learning script at that
|
|
8
|
+
// commit. Nothing is written to git here, and nothing is written at all before the checks pass: what they refuse (a
|
|
9
|
+
// note holding a secret among them) is never kept anywhere.
|
|
1
10
|
import { join } from "node:path";
|
|
2
11
|
import { checkProposal, draftDryRun, draftFiles, NOTE_BLOCK, unstorable, parseReflection, redactSecrets, shortMessage, SKILL_BLOCK, SKILLS_DIR, WORKFLOW_BLOCK, WORKFLOWS_DIR } from "./learn/index.js";
|
|
3
12
|
import { folderAt, readLearning, readSnapshot } from "./learn/folder.js";
|
|
@@ -150,7 +159,7 @@ export const proposeRun = async (input) => {
|
|
|
150
159
|
return { state: "dropped", reason: "checker", problems: leaky };
|
|
151
160
|
// A skill or a draft whose seed text has a status is a person's call (retired, or waiting for their OK): never changed.
|
|
152
161
|
const dryRuns = {};
|
|
153
|
-
const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.
|
|
162
|
+
const check = (some) => checkProposal({ workflowAdapters: input.workflowAdapters, base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.decisions ? { decisions: input.decisions } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
|
|
154
163
|
// The static checks first, every one (validateWorkflow with executeCode: false, draftProblems' refusal of code nodes,
|
|
155
164
|
// caps, secrets): a draft they refuse is never dry-run, nor is any when they refuse the answer whole. Then each draft
|
|
156
165
|
// left is dry-run on its example, else on a synthesized input (learn/skills.ts draftDryRun): every model and tool
|
package/dist/provider.d.ts
CHANGED
|
@@ -51,12 +51,16 @@ export declare function anthropicModelId(model: ModelRef): string;
|
|
|
51
51
|
* path), its key, read per request, how the endpoint takes it, the model id sent, and the catalog entry that prices it.
|
|
52
52
|
* `who`: the harness, for a refusal's words. Throws a HarnessUnavailable where the run cannot go: a model of another
|
|
53
53
|
* vendor, a key that is not set (its `keys` name the ones that would fix it), or an endpoint a key may not go to. */
|
|
54
|
+
/** `billing: "plan"`: a ChatGPT plan's route (chatgpt-plan.ts), billed to the plan, never priced here; its credential is
|
|
55
|
+
* the plan's token, asked at each request, and `refused` tells the plan OpenAI answered 401 to one it sent. */
|
|
54
56
|
export type Provider = {
|
|
55
57
|
origin: string;
|
|
56
|
-
credential: () => string
|
|
58
|
+
credential: () => string | Promise<string>;
|
|
57
59
|
auth: "bearer" | "x-api-key";
|
|
58
60
|
modelId: string;
|
|
59
61
|
priceModel: ModelRef;
|
|
62
|
+
billing?: "plan";
|
|
63
|
+
refused?: (credential: string) => Promise<void>;
|
|
60
64
|
};
|
|
61
65
|
export declare function providerFor(wire: Wire, env: NodeJS.ProcessEnv, model: ModelRef, who: string): Provider;
|
|
62
66
|
/** The catalog entry a run on `wire` of `model` is capped and priced by: providerFor's, or the model's own (normalized)
|
package/dist/provider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { chooseModel, FAUX_ENV, hostModel, MODEL_PROVIDER } from "./model.js";
|
|
2
2
|
import { WIRES } from "./wires.js";
|
|
3
3
|
import { modelFormWhy } from "./model-form.js";
|
|
4
|
+
import { EXPIRED, PLAN_ORIGIN, PLAN_PROVIDER, planOf, SIGNED_OUT } from "./chatgpt-plan.js";
|
|
4
5
|
// Each wire's own settings live in a leaf module (wires.ts), which the harness table reads as it loads.
|
|
5
6
|
export { WIRES };
|
|
6
7
|
/** Why this server cannot run a harness here, in words a person can act on; `fix`, when installing is the fix; `keys`,
|
|
@@ -117,6 +118,13 @@ export function providerFor(wire, env, model, who) {
|
|
|
117
118
|
throw env.ANTHROPIC_BASE_URL ? new HarnessUnavailable(`${who} needs ANTHROPIC_API_KEY.`, undefined, ["ANTHROPIC_API_KEY"]) : new HarnessUnavailable(`${who} needs ANTHROPIC_API_KEY or OPENROUTER_API_KEY.`, undefined, ["ANTHROPIC_API_KEY", "OPENROUTER_API_KEY"]);
|
|
118
119
|
return { origin, credential: () => env.ANTHROPIC_API_KEY ?? "", auth: "x-api-key", modelId: own, priceModel: { provider: "anthropic", modelId: own } };
|
|
119
120
|
}
|
|
121
|
+
// A ChatGPT plan's model: OpenAI's Responses API on the plan's token, whatever else is set.
|
|
122
|
+
if (model.provider === PLAN_PROVIDER) {
|
|
123
|
+
const plan = planOf(env);
|
|
124
|
+
if (plan?.state !== "signed_in")
|
|
125
|
+
throw new HarnessUnavailable(plan?.state === "expired" ? EXPIRED : SIGNED_OUT);
|
|
126
|
+
return { origin: PLAN_ORIGIN, credential: () => plan.token(), auth: "bearer", modelId: model.modelId, priceModel: model, billing: "plan", refused: (sent) => plan.refused(sent) };
|
|
127
|
+
}
|
|
120
128
|
if (env.AGENT_MODEL_BASE_URL)
|
|
121
129
|
return gatewayProvider(env, model);
|
|
122
130
|
if (model.provider === "openrouter" && model.modelId.startsWith("openai/"))
|
package/dist/push-handler.d.ts
CHANGED
|
@@ -48,5 +48,6 @@ export type PushAnswer = {
|
|
|
48
48
|
body: unknown;
|
|
49
49
|
headers?: Record<string, string>;
|
|
50
50
|
};
|
|
51
|
-
/** The request to /v2/hooks/{segment}
|
|
52
|
-
|
|
51
|
+
/** The request to /v2/hooks/{segment}, or /v2/hooks/{segment}/{sub} for a source that keeps its key per scope
|
|
52
|
+
* (Push.scoped): its answer, or the one 401 (thrown). */
|
|
53
|
+
export declare function receivePush(deps: PushDeps, req: IncomingMessage, segment: string, sub?: string): Promise<PushAnswer>;
|
package/dist/push-handler.js
CHANGED
|
@@ -49,21 +49,31 @@ export function readCapped(req, max, ms = HOOK_BODY_MS) {
|
|
|
49
49
|
}
|
|
50
50
|
/** The one answer to every refused request. */
|
|
51
51
|
const REFUSED = "this route needs a request signed by the webhook trigger's secret";
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
/** A scope a source's own path names (/v2/hooks/{source}/{scope}): an id this server made. */
|
|
53
|
+
const SCOPE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
54
|
+
/** The request to /v2/hooks/{segment}, or /v2/hooks/{segment}/{sub} for a source that keeps its key per scope
|
|
55
|
+
* (Push.scoped): its answer, or the one 401 (thrown). */
|
|
56
|
+
export async function receivePush(deps, req, segment, sub) {
|
|
57
|
+
const route = `/v2/hooks/${segment}${sub === undefined ? "" : `/${sub}`}`;
|
|
55
58
|
const refuse = (reason) => (deps.refused(route, reason), new ApiError("unauthenticated", REFUSED));
|
|
56
59
|
let name;
|
|
60
|
+
let scoped;
|
|
57
61
|
try {
|
|
58
62
|
name = decodeURIComponent(segment);
|
|
63
|
+
scoped = sub === undefined ? undefined : decodeURIComponent(sub);
|
|
59
64
|
}
|
|
60
65
|
catch {
|
|
61
66
|
throw refuse("malformed_path");
|
|
62
67
|
}
|
|
68
|
+
if (scoped !== undefined && !SCOPE.test(scoped))
|
|
69
|
+
throw refuse("malformed_path");
|
|
63
70
|
// A source's own path (its settings are the server's), else a trigger's, checked by that trigger's own source (its
|
|
64
71
|
// settings are a trigger's). A path that names no such trigger is checked as the first such source's, against the
|
|
65
72
|
// decoy: the same work and the same 401, so no id is learned by asking.
|
|
66
73
|
const own = deps.adapters.find((a) => a.id === name && a.push && a.settings?.scope === "server");
|
|
74
|
+
// Only a source that keeps its key per scope has paths under its own: any other path with a second segment names no hook.
|
|
75
|
+
if (scoped !== undefined && !own?.push?.scoped)
|
|
76
|
+
throw refuse("no_hook");
|
|
67
77
|
const named = own || !ID.test(name) ? undefined : await deps.hooked(name);
|
|
68
78
|
const trigger = named && deps.adapters.find((a) => a.id === named.kind && a.push && a.settings?.scope === "trigger");
|
|
69
79
|
const adapter = own ?? trigger ?? deps.adapters.find((a) => a.push && a.settings?.scope === "trigger");
|
|
@@ -77,12 +87,14 @@ export async function receivePush(deps, req, segment) {
|
|
|
77
87
|
const body = await readCapped(req, push.maxBodyBytes, deps.bodyMs);
|
|
78
88
|
const source = trigger ? named : undefined;
|
|
79
89
|
const pathTrigger = source ? name : undefined;
|
|
80
|
-
|
|
90
|
+
// A source that keeps its key per scope is checked with its path's scope's (none on its bare path: the decoy's 401).
|
|
91
|
+
const ownScope = own ? (push.scoped ? scoped : "server") : undefined;
|
|
92
|
+
const key = own ? ownScope && deps.setting(adapter.id, ownScope, push.key) : pathTrigger && deps.setting(adapter.id, pathTrigger, push.key);
|
|
81
93
|
// Checked against the clock now the body has arrived: a timestamp at the tolerance's edge never passes by a slow body.
|
|
82
94
|
const refusal = push.verify(key ?? DECOY, req.headers, body, Date.now(), key ? source : undefined);
|
|
83
95
|
if (!key || refusal)
|
|
84
96
|
throw refuse(key ? refusal : own ? "no_key" : "no_webhook_trigger");
|
|
85
|
-
const scope = own ?
|
|
97
|
+
const scope = own ? ownScope : pathTrigger;
|
|
86
98
|
const ctx = {
|
|
87
99
|
setting: (field) => deps.setting(adapter.id, scope, field),
|
|
88
100
|
notice: async (event, doc) => deps.notice?.(adapter.id, event, doc),
|
|
@@ -91,7 +103,9 @@ export async function receivePush(deps, req, segment) {
|
|
|
91
103
|
const handshake = await push.handshake?.(req.headers, body, ctx);
|
|
92
104
|
if (handshake)
|
|
93
105
|
return handshake;
|
|
94
|
-
const
|
|
106
|
+
const parsed = push.parse(req.headers, body, source);
|
|
107
|
+
// A scoped source's events happened in its path's scope: its takes matches each trigger's to it.
|
|
108
|
+
const events = Array.isArray(parsed) && own && push.scoped ? parsed.map((event) => ({ ...event, scope })) : parsed;
|
|
95
109
|
// Verified, and not an event its trigger takes: answered, so the sender does not send it again, and said once.
|
|
96
110
|
if (!Array.isArray(events)) {
|
|
97
111
|
deps.say({ condition: "hook_ignored", source: adapter.id, route, ...(pathTrigger ? { trigger: pathTrigger } : {}), reason: events.ignored, ...(events.event ? { event: events.event } : {}) });
|
package/dist/refusal-words.d.ts
CHANGED
|
@@ -7,6 +7,17 @@ export declare const RAN_UNKNOWN = "It had started before the deny, and whether
|
|
|
7
7
|
export declare const STOPPED_WHILE_WAITING = "Not run: the run was stopped while it waited";
|
|
8
8
|
/** A call that waited when its run ended (completed or failed) without anyone stopping it: never sent. */
|
|
9
9
|
export declare const ENDED_WHILE_WAITING = "Not run: the run ended while it waited";
|
|
10
|
+
/** How a refusal of a setting's deny, or of an ask no one can approve, opens (deniedText, noApproverText). */
|
|
11
|
+
export declare const DENIED_OPENING = "Permission denied: ";
|
|
12
|
+
/** How a person's deny opens (refusedText). */
|
|
13
|
+
export declare const USER_DENIED_OPENING = "The user denied this ";
|
|
14
|
+
/** What a read-only bash policy's refusal says after the tool's name (bash-read-only.ts readOnlyText). */
|
|
15
|
+
export declare const READ_ONLY_REFUSED = " is read-only for this agent, so this call was refused: ";
|
|
16
|
+
/** What a refusal of a tool no call of which can pass says after its name (a bash policy or a pin that does not read). */
|
|
17
|
+
export declare const CANT_BE_CALLED = " can't be called: ";
|
|
18
|
+
/** The words a refused call's answer opens with (or, past the tool's name, says first): what a script that reads its
|
|
19
|
+
* calls' answers as text (Codex's code mode) checks for, as the desktop and phone kind skills name them. */
|
|
20
|
+
export declare const REFUSAL_OPENINGS: readonly string[];
|
|
10
21
|
/** Where a permission was set (permissionFrom's `from`): the agent's own tool settings, the server's, or the default; or
|
|
11
22
|
* "unattended": an ask the agent's approvals "never" allowed. */
|
|
12
23
|
export type SettingFrom = "agent" | "server" | "default" | "unattended";
|
package/dist/refusal-words.js
CHANGED
|
@@ -9,6 +9,17 @@ export const RAN_UNKNOWN = "It had started before the deny, and whether it took
|
|
|
9
9
|
export const STOPPED_WHILE_WAITING = "Not run: the run was stopped while it waited";
|
|
10
10
|
/** A call that waited when its run ended (completed or failed) without anyone stopping it: never sent. */
|
|
11
11
|
export const ENDED_WHILE_WAITING = "Not run: the run ended while it waited";
|
|
12
|
+
/** How a refusal of a setting's deny, or of an ask no one can approve, opens (deniedText, noApproverText). */
|
|
13
|
+
export const DENIED_OPENING = "Permission denied: ";
|
|
14
|
+
/** How a person's deny opens (refusedText). */
|
|
15
|
+
export const USER_DENIED_OPENING = "The user denied this ";
|
|
16
|
+
/** What a read-only bash policy's refusal says after the tool's name (bash-read-only.ts readOnlyText). */
|
|
17
|
+
export const READ_ONLY_REFUSED = " is read-only for this agent, so this call was refused: ";
|
|
18
|
+
/** What a refusal of a tool no call of which can pass says after its name (a bash policy or a pin that does not read). */
|
|
19
|
+
export const CANT_BE_CALLED = " can't be called: ";
|
|
20
|
+
/** The words a refused call's answer opens with (or, past the tool's name, says first): what a script that reads its
|
|
21
|
+
* calls' answers as text (Codex's code mode) checks for, as the desktop and phone kind skills name them. */
|
|
22
|
+
export const REFUSAL_OPENINGS = [DENIED_OPENING, USER_DENIED_OPENING, READ_ONLY_REFUSED, CANT_BE_CALLED];
|
|
12
23
|
/** Where a deny was set, in words: the place a person changes it. */
|
|
13
24
|
export const denyPlace = (from = "server") => (from === "agent" ? "for this agent" : from === "default" ? "by default" : "on this server");
|
|
14
25
|
/** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
|
|
@@ -17,7 +28,7 @@ export const deniedText = (tool, heldTo, from = "server", ran = "no") => {
|
|
|
17
28
|
// `ran`: "unknown" for a call an earlier attempt of which may have been sent (an approved call cut mid-flight, or a
|
|
18
29
|
// replay-safe call run again after a crash): the words never claim it wasn't.
|
|
19
30
|
const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
|
|
20
|
-
return heldTo && heldTo !== tool ?
|
|
31
|
+
return heldTo && heldTo !== tool ? `${DENIED_OPENING}${tool} follows ${heldTo}'s setting, which is deny ${denyPlace(from)}. ${what} Don't retry it.` : `${DENIED_OPENING}${tool} is set to deny ${denyPlace(from)}. ${what} Don't retry it.`;
|
|
21
32
|
};
|
|
22
33
|
/** A workflow model node's tool set to ask: a model node cannot wait for a person's approval (the gate parks no workflow
|
|
23
34
|
* call), so the call is refused unrun and the model reads why (tool-gate.ts RunGate, on main and on the runner). */
|
|
@@ -26,4 +37,4 @@ export const modelNodeAskText = (tool, ran = "no") => `This ${tool} call needs a
|
|
|
26
37
|
* (main's per-run process and the runner's workflow spec, the same words). */
|
|
27
38
|
export const callNodeAskText = (tool) => `This ${tool} call needs a person's approval, which a workflow's call node cannot wait for; it was not run.`;
|
|
28
39
|
/** A call a person denied, with their reason when they gave one. */
|
|
29
|
-
export const refusedText = (tool, note, ran = "no") =>
|
|
40
|
+
export const refusedText = (tool, note, ran = "no") => `${USER_DENIED_OPENING}${tool} call. ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}${note ? ` Reason: ${note}` : ""}`;
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SdkWorkflowTool, SdkWorkflowAdapter } from "./sdk/workflows.js";
|
|
2
|
+
import type { NativeBinding } from "./native/types.js";
|
|
1
3
|
import { type MessageOrigin } from "./timeline/index.js";
|
|
2
4
|
import type { Plane } from "./tool-plane.js";
|
|
3
5
|
import type { RunTrigger } from "./triggers.js";
|
|
@@ -10,6 +12,14 @@ import type { Place } from "./workspace/place.js";
|
|
|
10
12
|
* names (a learning run's `{ runId }`). `model`, `plane`, `approvers`, `documents` and `boxAllow` are the per-run choices
|
|
11
13
|
* the old path recomputed; here they are pinned at start, and optional (a built-in run may name none). */
|
|
12
14
|
export interface RunLaunch {
|
|
15
|
+
readonly sdk?: {
|
|
16
|
+
runtime: "claude-agent-sdk" | "codex-sdk";
|
|
17
|
+
instructions: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
workflow_tools?: SdkWorkflowTool[];
|
|
20
|
+
workflow_adapters?: SdkWorkflowAdapter[];
|
|
21
|
+
};
|
|
22
|
+
readonly native?: NativeBinding;
|
|
13
23
|
/** The start request's body, as the person or trigger gave it, or an object a built-in run names. */
|
|
14
24
|
readonly input: unknown;
|
|
15
25
|
readonly title: string;
|
|
@@ -26,7 +36,6 @@ export interface RunLaunch {
|
|
|
26
36
|
};
|
|
27
37
|
readonly effort?: string;
|
|
28
38
|
readonly maxCostUsd?: number;
|
|
29
|
-
readonly capMode?: string;
|
|
30
39
|
/** The tool plane as the server resolved it at start (tool-plane.ts). */
|
|
31
40
|
readonly plane?: Plane;
|
|
32
41
|
/** Whether a person can answer a tool call's approval for this run. */
|
package/dist/run-launch.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nativeOf } from "./native/binding.js";
|
|
1
2
|
// A run's launch record: the one JSON body the server writes when it starts a run (start = INSERT run, design 2.1), and
|
|
2
3
|
// the runner reads at its claim to build the run's spec. It replaces the per-run `serve.json` the old per-run process read
|
|
3
4
|
// (app.ts meta.input, place, effort, cap): no process, no door, no marker file, one body written once. What a person sees
|
|
@@ -12,9 +13,13 @@ import { isObject } from "./validate.js";
|
|
|
12
13
|
const readDisk = (value) => isObject(value) && typeof value.disk_id === "string" && (value.kind === "launch" || value.kind === "agent") ? { diskId: value.disk_id, kind: value.kind } : undefined;
|
|
13
14
|
/** The replay a launch body names, as read back, or undefined. */
|
|
14
15
|
const readReplay = (value) => isObject(value) && typeof value.of === "string" && typeof value.workflow === "string" && typeof value.digest === "string" ? { of: value.of, workflow: value.workflow, digest: value.digest } : undefined;
|
|
15
|
-
/** The trigger a launch body names, as read back: `{ id, firing_key }
|
|
16
|
+
/** The trigger a launch body names, as read back: `{ id, firing_key }` and its firing's `attrs` (each a string) when it
|
|
17
|
+
* kept them, or null (triggerOf of the old serve.json). */
|
|
16
18
|
function readTrigger(value) {
|
|
17
|
-
|
|
19
|
+
if (!(isObject(value) && typeof value.id === "string" && typeof value.firing_key === "string"))
|
|
20
|
+
return null;
|
|
21
|
+
const attrs = isObject(value.attrs) ? Object.fromEntries(Object.entries(value.attrs).filter((entry) => typeof entry[1] === "string")) : {};
|
|
22
|
+
return { id: value.id, firing_key: value.firing_key, ...(Object.keys(attrs).length ? { attrs } : {}) };
|
|
18
23
|
}
|
|
19
24
|
/** Where a run runs, as read back from a launch body, or undefined when it names none. */
|
|
20
25
|
function readPlace(value) {
|
|
@@ -47,6 +52,8 @@ export function keepInputOrigin(stored, trigger) {
|
|
|
47
52
|
export function launchBody(launch) {
|
|
48
53
|
return {
|
|
49
54
|
input: launch.input,
|
|
55
|
+
...(launch.sdk ? { sdk: launch.sdk } : {}),
|
|
56
|
+
...(launch.native ? { native: launch.native } : {}),
|
|
50
57
|
title: launch.title,
|
|
51
58
|
...(launch.repo !== undefined ? { repo: launch.repo } : {}),
|
|
52
59
|
place: launch.place,
|
|
@@ -54,7 +61,6 @@ export function launchBody(launch) {
|
|
|
54
61
|
...(launch.model ? { model: launch.model } : {}),
|
|
55
62
|
...(launch.effort !== undefined ? { effort: launch.effort } : {}),
|
|
56
63
|
...(launch.maxCostUsd !== undefined ? { max_cost_usd: launch.maxCostUsd } : {}),
|
|
57
|
-
...(launch.capMode !== undefined ? { cap_mode: launch.capMode } : {}),
|
|
58
64
|
...(launch.plane ? { plane: launch.plane } : {}),
|
|
59
65
|
...(launch.approvers !== undefined ? { approvers: launch.approvers } : {}),
|
|
60
66
|
...(launch.documents !== undefined ? { documents: launch.documents } : {}),
|
|
@@ -100,6 +106,8 @@ export function readLaunchBody(stored) {
|
|
|
100
106
|
const archilDisk = readDisk(stored.archil_disk);
|
|
101
107
|
return {
|
|
102
108
|
input: stored.input,
|
|
109
|
+
...(isObject(stored.sdk) && (stored.sdk.runtime === "claude-agent-sdk" || stored.sdk.runtime === "codex-sdk") && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
|
|
110
|
+
...(nativeOf(stored) ? { native: nativeOf(stored) } : {}),
|
|
103
111
|
title: typeof stored.title === "string" ? stored.title : "",
|
|
104
112
|
...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
|
|
105
113
|
place,
|
|
@@ -107,7 +115,6 @@ export function readLaunchBody(stored) {
|
|
|
107
115
|
...(model ? { model } : {}),
|
|
108
116
|
...(typeof stored.effort === "string" ? { effort: stored.effort } : {}),
|
|
109
117
|
...(typeof stored.max_cost_usd === "number" ? { maxCostUsd: stored.max_cost_usd } : {}),
|
|
110
|
-
...(typeof stored.cap_mode === "string" ? { capMode: stored.cap_mode } : {}),
|
|
111
118
|
...(isObject(stored.plane) ? { plane: stored.plane } : {}),
|
|
112
119
|
...(typeof stored.approvers === "boolean" ? { approvers: stored.approvers } : {}),
|
|
113
120
|
...(typeof stored.documents === "string" ? { documents: stored.documents } : {}),
|
|
@@ -64,8 +64,81 @@ export declare function servedRunLearning(deps: {
|
|
|
64
64
|
skills?: import("./learning.js").LearnedFile[];
|
|
65
65
|
workflows?: import("./learning.js").LearnedFile[];
|
|
66
66
|
run: string;
|
|
67
|
-
state: "
|
|
68
|
-
reason: "cancelled" | "
|
|
67
|
+
state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
|
|
68
|
+
reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
69
|
+
detail: string | null;
|
|
70
|
+
at: string;
|
|
71
|
+
} | {
|
|
72
|
+
graded: {
|
|
73
|
+
workflow: string | null;
|
|
74
|
+
feedback_status: "running" | "ended" | "not_run" | null;
|
|
75
|
+
source: "feedback" | "eval";
|
|
76
|
+
graded_at: string;
|
|
77
|
+
path: "agent" | "workflow" | "handed_back" | "replay";
|
|
78
|
+
workflow_digest: string | null;
|
|
79
|
+
feedback: "revise" | "look_back" | null;
|
|
80
|
+
run_id: string;
|
|
81
|
+
correct: boolean;
|
|
82
|
+
};
|
|
83
|
+
seed: string | null;
|
|
84
|
+
merged: string | null;
|
|
85
|
+
pending: {
|
|
86
|
+
file: string;
|
|
87
|
+
name: string;
|
|
88
|
+
}[];
|
|
89
|
+
verdict: {
|
|
90
|
+
merge: boolean;
|
|
91
|
+
reason: string;
|
|
92
|
+
items: {
|
|
93
|
+
why: string;
|
|
94
|
+
question?: string | undefined;
|
|
95
|
+
origin?: "run" | "you" | undefined;
|
|
96
|
+
pending?: boolean | undefined;
|
|
97
|
+
file: string;
|
|
98
|
+
keep: boolean;
|
|
99
|
+
}[];
|
|
100
|
+
} | null;
|
|
101
|
+
problems: {
|
|
102
|
+
detail: string;
|
|
103
|
+
path?: string | undefined;
|
|
104
|
+
rule: import("./learn/check.js").Rule;
|
|
105
|
+
}[];
|
|
106
|
+
compiled: {
|
|
107
|
+
workflow: string;
|
|
108
|
+
from_notes: string[];
|
|
109
|
+
attempts: {
|
|
110
|
+
ok: boolean;
|
|
111
|
+
errors: string[];
|
|
112
|
+
}[];
|
|
113
|
+
digest: string | null;
|
|
114
|
+
promoted: boolean | null;
|
|
115
|
+
} | null;
|
|
116
|
+
draft_errors: string[];
|
|
117
|
+
cost_usd: {
|
|
118
|
+
grade: number | null;
|
|
119
|
+
};
|
|
120
|
+
tokens: {
|
|
121
|
+
grade: import("./learning.js").Tokens | null;
|
|
122
|
+
};
|
|
123
|
+
used: {
|
|
124
|
+
skills: {
|
|
125
|
+
name: string;
|
|
126
|
+
read: boolean;
|
|
127
|
+
}[];
|
|
128
|
+
workflows: {
|
|
129
|
+
name: string;
|
|
130
|
+
calls: number;
|
|
131
|
+
failed: number;
|
|
132
|
+
}[];
|
|
133
|
+
};
|
|
134
|
+
given?: import("./learning.js").NoteUsed[];
|
|
135
|
+
read?: import("./learning.js").NoteUsed[];
|
|
136
|
+
learned?: import("./learning.js").NoteLearned[];
|
|
137
|
+
skills?: import("./learning.js").LearnedFile[];
|
|
138
|
+
workflows?: import("./learning.js").LearnedFile[];
|
|
139
|
+
run: string;
|
|
140
|
+
state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
|
|
141
|
+
reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
69
142
|
detail: string | null;
|
|
70
143
|
at: string;
|
|
71
144
|
} | null>;
|
package/dist/run-manifest.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type Workspace } from "./workspace/index.js";
|
|
2
|
+
/** The run's opening message as its inputs/message.md holds it: the start's `content` when it is a string, as sent; ""
|
|
3
|
+
* (no file) for any other input. */
|
|
4
|
+
export declare function messageText(input: unknown): string;
|
|
2
5
|
/** The most files the line names; the rest are counted. */
|
|
3
6
|
export declare const MANIFEST_ENTRIES = 20;
|
|
4
7
|
/** The most the first message may take, as the JSON string the run's door is sent: a door takes a body of
|