@parcha/agentrun-serve 0.1.0-beta.37 → 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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- 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 +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- 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.d.ts +2 -0
- package/dist/console-links.js +6 -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/decisions.js +4 -0
- 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/faux-computers.js +4 -2
- 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 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- 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.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- 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/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- 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 +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- 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 +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- 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 +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- 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 +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- 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 +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -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/connection.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -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 +16 -0
- package/dist/store/schema.js +47 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- 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 +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- 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 +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- 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.d.ts +15 -7
- package/dist/validate.js +91 -50
- 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 +6 -8
- package/dist/web-fetch.js +10 -53
- 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 +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- 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 +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- 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 +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- 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/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3
|
+
import { NATIVE_RUNTIME_FACTS } from "./runtimes.js";
|
|
4
|
+
import { nativeExecutable, nativeMetadata } from "./discovery.js";
|
|
5
|
+
const unknownUsage = () => ({ input_tokens: null, output_tokens: null, cache_read_tokens: null, cache_write_tokens: null, cost_usd: null });
|
|
6
|
+
const count = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
7
|
+
/** A stop kills the source immediately, then gives its already reported events this long to finish recording. */
|
|
8
|
+
export const NATIVE_EVENT_DRAIN_MS = 5_000;
|
|
9
|
+
const usageOf = (raw, claude, cost) => ({
|
|
10
|
+
input_tokens: count(raw?.input_tokens), output_tokens: count(raw?.output_tokens),
|
|
11
|
+
cache_read_tokens: count(claude ? raw?.cache_read_input_tokens : raw?.cached_input_tokens),
|
|
12
|
+
cache_write_tokens: count(claude ? raw?.cache_creation_input_tokens : raw?.cache_write_input_tokens), cost_usd: count(cost),
|
|
13
|
+
});
|
|
14
|
+
export class NativeRuntimeError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
sessionId;
|
|
17
|
+
constructor(message, code, sessionId) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.sessionId = sessionId;
|
|
21
|
+
this.name = code === "aborted" ? "AbortError" : "NativeRuntimeError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** CLI JSON mode preserves normal native resolution. An unavailable approval is denied, never upgraded. */
|
|
25
|
+
export async function openNativeSession(options) {
|
|
26
|
+
const { target } = options, env = options.env ?? process.env;
|
|
27
|
+
if (options.signal?.aborted)
|
|
28
|
+
throw new NativeRuntimeError("Native launch was cancelled.", "aborted");
|
|
29
|
+
if (target.selector.kind !== "project" && target.selector.kind !== NATIVE_RUNTIME_FACTS[target.runtime].namedSelector)
|
|
30
|
+
throw new NativeRuntimeError("This native runtime does not support the selected agent/profile selector. Discover this project again.", "unavailable");
|
|
31
|
+
if (target.selector.kind !== "project" && (!target.selector.name || !/^[\w.@+-]{1,160}$/.test(target.selector.name)))
|
|
32
|
+
throw new NativeRuntimeError("The native selector is invalid. Discover this project again.", "unavailable");
|
|
33
|
+
const binary = await nativeExecutable(target.runtime, env);
|
|
34
|
+
if (!binary)
|
|
35
|
+
throw new NativeRuntimeError("The installed native CLI is unavailable on this machine. Verify the connection and PATH.", "unavailable");
|
|
36
|
+
let sessionId = options.sessionId, active, closed = false, busy = false, failed = false;
|
|
37
|
+
// Claude's total_cost_usd includes previous resumed invocations; token counters do not.
|
|
38
|
+
let claudeCumulativeCost = options.sessionId ? null : 0;
|
|
39
|
+
let codexCumulativeUsage = options.sessionId ? unknownUsage() : { input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_write_tokens: 0, cost_usd: null };
|
|
40
|
+
let stopActive;
|
|
41
|
+
const kill = () => { if (!active?.pid)
|
|
42
|
+
return; try {
|
|
43
|
+
process.kill(process.platform === "win32" ? active.pid : -active.pid, "SIGKILL");
|
|
44
|
+
}
|
|
45
|
+
catch { /* process already exited */ } };
|
|
46
|
+
const session = {
|
|
47
|
+
async send(prompt, sendOptions = {}) {
|
|
48
|
+
if (closed || failed)
|
|
49
|
+
throw new NativeRuntimeError("This native session is closed. Inspect its recorded outcome before starting another run.", "unavailable", sessionId);
|
|
50
|
+
if (busy)
|
|
51
|
+
throw new NativeRuntimeError("A turn is already running in this native session.", "unavailable", sessionId);
|
|
52
|
+
if (sendOptions.signal?.aborted || options.signal?.aborted)
|
|
53
|
+
throw new NativeRuntimeError("Native turn was cancelled before dispatch.", "aborted", sessionId);
|
|
54
|
+
busy = true;
|
|
55
|
+
try {
|
|
56
|
+
const claude = NATIVE_RUNTIME_FACTS[target.runtime].protocol === "claude-json", args = [];
|
|
57
|
+
if (claude) {
|
|
58
|
+
args.push("--print", "--output-format", "stream-json", "--verbose", "--permission-prompts", "none");
|
|
59
|
+
if (target.selector.kind === "agent")
|
|
60
|
+
args.push("--agent", target.selector.name);
|
|
61
|
+
if (sessionId)
|
|
62
|
+
args.push("--resume", sessionId);
|
|
63
|
+
if (options.context && !sessionId)
|
|
64
|
+
args.push("--append-system-prompt", options.context);
|
|
65
|
+
if (sendOptions.reflection)
|
|
66
|
+
args.push("--tools", "", "--disallowedTools", "*");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (target.selector.kind === "profile")
|
|
70
|
+
args.push("--profile", target.selector.name);
|
|
71
|
+
if (sendOptions.reflection) {
|
|
72
|
+
// Restrict only this reflection process. The user's files and task settings remain native.
|
|
73
|
+
// Resolve with the installed CLI rather than guessing TOML layouts or profile/plugin precedence.
|
|
74
|
+
const metadata = await nativeMetadata(binary, [...(target.selector.kind === "profile" ? ["--profile", target.selector.name] : []), "mcp", "list", "--json"], target.project, env);
|
|
75
|
+
let servers;
|
|
76
|
+
try {
|
|
77
|
+
const list = JSON.parse(metadata.stdout);
|
|
78
|
+
if (metadata.code !== 0 || !Array.isArray(list) || list.some(server => !server || typeof server.name !== "string" || !/^[\w-]+$/.test(server.name) || !["stdio", "streamable_http"].includes(server.transport?.type)))
|
|
79
|
+
throw new Error();
|
|
80
|
+
servers = list.map(server => ({ name: server.name, type: server.transport.type }));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new NativeRuntimeError("Native MCP configuration could not be safely disabled for reflection. Check codex mcp list --json and use MCP server names containing only letters, numbers, hyphens or underscores.", "unavailable", sessionId);
|
|
84
|
+
}
|
|
85
|
+
if (closed || options.signal?.aborted || sendOptions.signal?.aborted)
|
|
86
|
+
throw new NativeRuntimeError("Native reflection was cancelled before dispatch.", "aborted", sessionId);
|
|
87
|
+
args.push("--sandbox", "read-only");
|
|
88
|
+
for (const feature of ["shell_tool", "unified_exec", "apps", "plugins", "multi_agent", "multi_agent_v2", "in_app_browser", "browser_use", "computer_use"])
|
|
89
|
+
args.push("--disable", feature);
|
|
90
|
+
for (const server of servers) {
|
|
91
|
+
args.push("--config", `mcp_servers.${server.name}.enabled=false`);
|
|
92
|
+
// Inherited native entries can lack a base TOML transport. Supply an inert disabled transport,
|
|
93
|
+
// never credentials or the original command/URL, so native validation still succeeds.
|
|
94
|
+
args.push("--config", server.type === "stdio" ? `mcp_servers.${server.name}.command="agentrun-reflection-disabled"` : `mcp_servers.${server.name}.url="http://127.0.0.1:1"`);
|
|
95
|
+
}
|
|
96
|
+
const disabled = await nativeMetadata(binary, [...args, "mcp", "list", "--json"], target.project, env);
|
|
97
|
+
try {
|
|
98
|
+
const list = JSON.parse(disabled.stdout);
|
|
99
|
+
if (disabled.code !== 0 || !Array.isArray(list) || list.some(server => server?.enabled !== false) || servers.some(server => !list.some(disabledServer => disabledServer?.name === server.name)))
|
|
100
|
+
throw new Error();
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
throw new NativeRuntimeError("Native MCP servers could not be confirmed disabled. Reflection was not dispatched; verify the native CLI configuration before enabling learning.", "unavailable", sessionId);
|
|
104
|
+
}
|
|
105
|
+
if (closed || options.signal?.aborted || sendOptions.signal?.aborted)
|
|
106
|
+
throw new NativeRuntimeError("Native reflection was cancelled before dispatch.", "aborted", sessionId);
|
|
107
|
+
}
|
|
108
|
+
args.push("exec");
|
|
109
|
+
if (sessionId)
|
|
110
|
+
args.push("resume", "--json", sessionId, "-");
|
|
111
|
+
else
|
|
112
|
+
args.push("--json", "--color", "never", "-");
|
|
113
|
+
}
|
|
114
|
+
const input = !claude && options.context && !sessionId ? `<agentrun_context>\n${options.context}\n</agentrun_context>\n\n${prompt}` : prompt;
|
|
115
|
+
return await new Promise((resolveResult, reject) => {
|
|
116
|
+
let buffer = "", bytes = 0, answer = "", usage = unknownUsage(), model, completed = false, stopped = false, terminalReceived = false, protocolError;
|
|
117
|
+
const decoder = new StringDecoder("utf8");
|
|
118
|
+
const denials = [], toolNames = new Map();
|
|
119
|
+
const seenEvents = new Set();
|
|
120
|
+
let eventQueue = Promise.resolve(), eventsClosed = false;
|
|
121
|
+
const child = spawn(binary, args, { cwd: target.project, env, detached: process.platform !== "win32", stdio: ["pipe", "pipe", "pipe"] });
|
|
122
|
+
active = child;
|
|
123
|
+
const emit = (event) => { eventQueue = eventQueue.then(() => eventsClosed ? undefined : options.onEvent?.(event)).then(() => { }); eventQueue.catch(error => stop(error instanceof Error ? error : new Error("Native event recording failed."))); };
|
|
124
|
+
const abort = () => stop(new NativeRuntimeError("Native turn was cancelled; its outcome may be incomplete. Inspect the recorded session before retrying.", "aborted", sessionId));
|
|
125
|
+
const timer = setTimeout(() => stop(new NativeRuntimeError("Native turn timed out; its outcome may be incomplete. Inspect the recorded session before retrying.", "timeout", sessionId)), Math.min(Math.max(sendOptions.timeoutMs ?? 180_000, 1), 600_000));
|
|
126
|
+
const cleanup = () => { clearTimeout(timer); options.signal?.removeEventListener("abort", abort); sendOptions.signal?.removeEventListener("abort", abort); if (active === child)
|
|
127
|
+
active = undefined; stopActive = undefined; };
|
|
128
|
+
const stop = (error) => {
|
|
129
|
+
if (stopped)
|
|
130
|
+
return;
|
|
131
|
+
stopped = true;
|
|
132
|
+
failed = true;
|
|
133
|
+
kill();
|
|
134
|
+
cleanup();
|
|
135
|
+
// The caller may end/release its claim as soon as send rejects. Drain the events already received first,
|
|
136
|
+
// keeping the original stop even if recording fails. A stuck callback cannot be cancelled; after the bound
|
|
137
|
+
// no further queued callback starts, and that in-flight write still relies on its own claim fence.
|
|
138
|
+
let deadline;
|
|
139
|
+
const bound = new Promise(resolve => { deadline = setTimeout(resolve, NATIVE_EVENT_DRAIN_MS); });
|
|
140
|
+
void Promise.race([eventQueue.then(() => { }, () => { }), bound]).then(() => { eventsClosed = true; clearTimeout(deadline); reject(error); });
|
|
141
|
+
};
|
|
142
|
+
stopActive = abort;
|
|
143
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
144
|
+
sendOptions.signal?.addEventListener("abort", abort, { once: true });
|
|
145
|
+
const setSession = (id) => {
|
|
146
|
+
if (typeof id !== "string" || !id)
|
|
147
|
+
return;
|
|
148
|
+
if (sessionId && id !== sessionId)
|
|
149
|
+
throw new NativeRuntimeError("The native CLI resumed a different session; this turn was stopped.", "protocol", sessionId);
|
|
150
|
+
if (!sessionId) {
|
|
151
|
+
sessionId = id;
|
|
152
|
+
emit({ type: "session", sessionId: id });
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const onLine = (line) => {
|
|
156
|
+
if (!line.trim())
|
|
157
|
+
return;
|
|
158
|
+
let event;
|
|
159
|
+
try {
|
|
160
|
+
event = JSON.parse(line);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
throw new NativeRuntimeError("The native CLI returned invalid JSON. Check its installed version and configuration.", "protocol", sessionId);
|
|
164
|
+
}
|
|
165
|
+
const eventKey = !claude && event.item?.id && ["item.started", "item.completed"].includes(event.type) ? `${event.type}:${event.item.id}` : JSON.stringify(event);
|
|
166
|
+
if (seenEvents.has(eventKey))
|
|
167
|
+
return;
|
|
168
|
+
seenEvents.add(eventKey);
|
|
169
|
+
if (claude) {
|
|
170
|
+
setSession(event.session_id);
|
|
171
|
+
if (event.type === "system" && event.subtype === "init")
|
|
172
|
+
model = typeof event.model === "string" ? event.model : undefined;
|
|
173
|
+
if (event.type === "assistant")
|
|
174
|
+
for (const block of event.message?.content ?? []) {
|
|
175
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
176
|
+
answer += block.text;
|
|
177
|
+
emit({ type: "text", text: block.text });
|
|
178
|
+
}
|
|
179
|
+
if (block.type === "tool_use") {
|
|
180
|
+
toolNames.set(block.id, block.name);
|
|
181
|
+
emit({ type: "tool", id: block.id, name: block.name, input: block.input, status: "started" });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (event.type === "user")
|
|
185
|
+
for (const block of event.message?.content ?? [])
|
|
186
|
+
if (block.type === "tool_result")
|
|
187
|
+
emit({ type: "tool", id: block.tool_use_id, name: toolNames.get(block.tool_use_id) ?? "native_tool", output: block.content, status: block.is_error ? "failed" : "completed" });
|
|
188
|
+
if (event.type === "result") {
|
|
189
|
+
if (terminalReceived)
|
|
190
|
+
return;
|
|
191
|
+
terminalReceived = true;
|
|
192
|
+
completed = event.subtype === "success" && !event.is_error;
|
|
193
|
+
if (typeof event.result === "string")
|
|
194
|
+
answer = event.result;
|
|
195
|
+
const cumulative = count(event.total_cost_usd);
|
|
196
|
+
const incremental = cumulative !== null && claudeCumulativeCost !== null && cumulative >= claudeCumulativeCost ? cumulative - claudeCumulativeCost : null;
|
|
197
|
+
claudeCumulativeCost = cumulative;
|
|
198
|
+
usage = usageOf(event.usage, true, incremental);
|
|
199
|
+
emit({ type: "usage", usage });
|
|
200
|
+
for (const denial of event.permission_denials ?? []) {
|
|
201
|
+
const tool = typeof denial.tool_name === "string" ? denial.tool_name : "native_tool";
|
|
202
|
+
denials.push(tool);
|
|
203
|
+
emit({ type: "approval", id: String(denial.tool_use_id ?? denials.length), tool, input: denial.tool_input });
|
|
204
|
+
}
|
|
205
|
+
if (!completed)
|
|
206
|
+
protocolError = new NativeRuntimeError("Claude Code did not complete the turn. Inspect its native session and authentication before retrying.", "failed", sessionId);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
if (event.type === "thread.started")
|
|
211
|
+
setSession(event.thread_id);
|
|
212
|
+
const item = event.item;
|
|
213
|
+
if ((event.type === "item.started" || event.type === "item.completed" || event.type === "item.updated") && item) {
|
|
214
|
+
// Completed messages also carry progress; only the latest is the turn's final answer.
|
|
215
|
+
if (item.type === "agent_message" && event.type === "item.completed" && typeof item.text === "string") {
|
|
216
|
+
answer = item.text;
|
|
217
|
+
emit({ type: "text", text: item.text });
|
|
218
|
+
}
|
|
219
|
+
if (["command_execution", "mcp_tool_call", "file_change", "web_search", "dynamic_tool_call"].includes(item.type)) {
|
|
220
|
+
const tool = item.type === "mcp_tool_call" ? `mcp__${item.server}__${item.tool}` : item.type;
|
|
221
|
+
emit({ type: "tool", id: String(item.id), name: tool, input: item.arguments ?? item.command ?? item.changes, output: item.result ?? item.aggregated_output ?? item.error, status: event.type === "item.started" ? "started" : ["failed", "declined"].includes(item.status) ? "failed" : "completed" });
|
|
222
|
+
if (item.status === "declined" || item.status === "denied") {
|
|
223
|
+
denials.push(tool);
|
|
224
|
+
emit({ type: "approval", id: String(item.id), tool, input: item.arguments ?? item.command });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (event.type === "turn.completed") {
|
|
229
|
+
if (terminalReceived)
|
|
230
|
+
return;
|
|
231
|
+
terminalReceived = true;
|
|
232
|
+
completed = true;
|
|
233
|
+
const cumulative = usageOf(event.usage, false), incremental = unknownUsage();
|
|
234
|
+
for (const key of ["input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens"]) {
|
|
235
|
+
const total = cumulative[key], previous = codexCumulativeUsage[key];
|
|
236
|
+
incremental[key] = total !== null && previous !== null && total >= previous ? total - previous : null;
|
|
237
|
+
}
|
|
238
|
+
codexCumulativeUsage = cumulative;
|
|
239
|
+
usage = incremental;
|
|
240
|
+
emit({ type: "usage", usage });
|
|
241
|
+
}
|
|
242
|
+
if (event.type === "turn.failed" || event.type === "error") {
|
|
243
|
+
terminalReceived = true;
|
|
244
|
+
protocolError = new NativeRuntimeError("Codex did not complete the turn. Inspect its native session, configuration and authentication before retrying.", "failed", sessionId);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
child.stdout.on("data", (chunk) => {
|
|
249
|
+
if (stopped)
|
|
250
|
+
return;
|
|
251
|
+
bytes += chunk.length;
|
|
252
|
+
if (bytes > 16_777_216) {
|
|
253
|
+
stop(new NativeRuntimeError("Native output exceeded the transport limit; inspect the native session.", "protocol", sessionId));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
buffer += decoder.write(chunk);
|
|
257
|
+
let index;
|
|
258
|
+
while ((index = buffer.indexOf("\n")) >= 0) {
|
|
259
|
+
const line = buffer.slice(0, index);
|
|
260
|
+
buffer = buffer.slice(index + 1);
|
|
261
|
+
try {
|
|
262
|
+
onLine(line);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
stop(error instanceof Error ? error : new Error("Native event failed."));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
// Drain diagnostic output without storing credentials or unbounded stderr in the run record.
|
|
271
|
+
child.stderr.on("data", () => { });
|
|
272
|
+
child.stdin.on("error", () => { });
|
|
273
|
+
child.once("error", () => stop(new NativeRuntimeError("The native CLI could not start. Verify its executable and original project directory.", "unavailable", sessionId)));
|
|
274
|
+
child.once("close", (code) => {
|
|
275
|
+
if (stopped)
|
|
276
|
+
return;
|
|
277
|
+
buffer += decoder.end();
|
|
278
|
+
if (buffer.trim()) {
|
|
279
|
+
try {
|
|
280
|
+
onLine(buffer);
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
stop(error instanceof Error ? error : new Error("Native event failed."));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
eventQueue.then(() => {
|
|
288
|
+
if (stopped)
|
|
289
|
+
return;
|
|
290
|
+
if (protocolError || code !== 0 || !completed || !sessionId) {
|
|
291
|
+
stop(protocolError ?? new NativeRuntimeError(`The native CLI exited without a completed turn (exit ${code ?? "unknown"}). Inspect its native session before retrying.`, "failed", sessionId));
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (denials.length) {
|
|
295
|
+
stop(new NativeRuntimeError(`Native approval is required for ${[...new Set(denials)].join(", ")}. This bridge denied the request; continue in the native CLI.`, "approval_required", sessionId));
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
stopped = true;
|
|
299
|
+
cleanup();
|
|
300
|
+
resolveResult({ sessionId, answer, model, usage, ...denials.length ? { permission_denials: denials } : {} });
|
|
301
|
+
}).catch(stop);
|
|
302
|
+
});
|
|
303
|
+
child.stdin.end(input);
|
|
304
|
+
if (options.signal?.aborted || sendOptions.signal?.aborted)
|
|
305
|
+
abort();
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
busy = false;
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
async close() { if (closed)
|
|
313
|
+
return; closed = true; stopActive?.(); kill(); },
|
|
314
|
+
};
|
|
315
|
+
return session;
|
|
316
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Installed native CLIs are source-owned execution protocols, separate from the managed harness registry.
|
|
2
|
+
* Their public connection identifiers stay stable; this table owns executable, selector and observation facts. */
|
|
3
|
+
type ObservationProtocol = {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly activityEvents: Readonly<Record<string, "working" | "unknown">>;
|
|
6
|
+
readonly usageEvents: readonly string[];
|
|
7
|
+
readonly requireCacheUsage: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const NATIVE_RUNTIME_FACTS: Readonly<{
|
|
10
|
+
"claude-code": Readonly<{
|
|
11
|
+
readonly binary: "claude";
|
|
12
|
+
readonly label: "Claude Code CLI";
|
|
13
|
+
readonly minimumVersion: "2.1.322";
|
|
14
|
+
readonly namedSelector: "agent";
|
|
15
|
+
readonly protocol: "claude-json";
|
|
16
|
+
readonly authStatus: readonly string[];
|
|
17
|
+
readonly authStatusJson: true;
|
|
18
|
+
readonly loginCommand: "claude auth login";
|
|
19
|
+
readonly observation: Readonly<{
|
|
20
|
+
readonly id: "claude";
|
|
21
|
+
readonly activityEvents: Readonly<{
|
|
22
|
+
user_prompt: "working";
|
|
23
|
+
api_request: "working";
|
|
24
|
+
tool_result: "working";
|
|
25
|
+
"claude_code.user_prompt": "working";
|
|
26
|
+
"claude_code.api_request": "working";
|
|
27
|
+
"claude_code.tool_result": "working";
|
|
28
|
+
}>;
|
|
29
|
+
readonly usageEvents: readonly string[];
|
|
30
|
+
readonly requireCacheUsage: true;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
codex: Readonly<{
|
|
34
|
+
readonly binary: "codex";
|
|
35
|
+
readonly label: "Codex CLI";
|
|
36
|
+
readonly minimumVersion: "0.167.2";
|
|
37
|
+
readonly namedSelector: "profile";
|
|
38
|
+
readonly protocol: "codex-json";
|
|
39
|
+
readonly authStatus: readonly string[];
|
|
40
|
+
readonly authStatusJson: false;
|
|
41
|
+
readonly loginCommand: "codex login";
|
|
42
|
+
readonly observation: Readonly<{
|
|
43
|
+
readonly id: "codex";
|
|
44
|
+
readonly activityEvents: Readonly<{
|
|
45
|
+
"codex.user_prompt": "working";
|
|
46
|
+
"codex.api_request": "working";
|
|
47
|
+
"codex.tool_result": "working";
|
|
48
|
+
"codex.response_usage": "working";
|
|
49
|
+
"codex.conversation_starts": "unknown";
|
|
50
|
+
}>;
|
|
51
|
+
readonly usageEvents: readonly string[];
|
|
52
|
+
readonly requireCacheUsage: false;
|
|
53
|
+
}>;
|
|
54
|
+
}>;
|
|
55
|
+
}>;
|
|
56
|
+
export type NativeRuntime = keyof typeof NATIVE_RUNTIME_FACTS;
|
|
57
|
+
export declare const NATIVE_CLAUDE_POLICY_UNRESOLVED = "Claude policy sources include settings or agent definitions whose effective selection could not be fully captured. Native tasks remain available; automatic learning is unavailable.";
|
|
58
|
+
export declare const NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED = "Claude policy sources may include additional instruction files or selection settings whose effective policy was not captured. Native tasks remain available; automatic learning is unavailable.";
|
|
59
|
+
export declare const NATIVE_RUNTIMES: readonly ("codex" | "claude-code")[];
|
|
60
|
+
export declare const NATIVE_MINIMUM_VERSION: Readonly<Record<NativeRuntime, string>>;
|
|
61
|
+
export declare const isNativeRuntime: (value: unknown) => value is NativeRuntime;
|
|
62
|
+
/** Native telemetry names are wire identifiers, independent of the managed harness that would execute a run. */
|
|
63
|
+
export type NativeObservationHarness = (typeof NATIVE_RUNTIME_FACTS)[NativeRuntime]["observation"]["id"];
|
|
64
|
+
export declare const NATIVE_OBSERVATION_HARNESSES: readonly ("codex" | "claude")[];
|
|
65
|
+
export declare const nativeObservationProtocol: (value: unknown) => ObservationProtocol | undefined;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const NATIVE_RUNTIME_FACTS = Object.freeze({
|
|
2
|
+
"claude-code": Object.freeze({
|
|
3
|
+
binary: "claude", label: "Claude Code CLI", minimumVersion: "2.1.322", namedSelector: "agent",
|
|
4
|
+
protocol: "claude-json", authStatus: Object.freeze(["auth", "status", "--json"]),
|
|
5
|
+
authStatusJson: true, loginCommand: "claude auth login",
|
|
6
|
+
observation: Object.freeze({
|
|
7
|
+
id: "claude",
|
|
8
|
+
activityEvents: Object.freeze({
|
|
9
|
+
user_prompt: "working", api_request: "working", tool_result: "working",
|
|
10
|
+
"claude_code.user_prompt": "working", "claude_code.api_request": "working", "claude_code.tool_result": "working",
|
|
11
|
+
}),
|
|
12
|
+
usageEvents: Object.freeze(["api_request", "claude_code.api_request"]),
|
|
13
|
+
requireCacheUsage: true,
|
|
14
|
+
}),
|
|
15
|
+
}),
|
|
16
|
+
codex: Object.freeze({
|
|
17
|
+
binary: "codex", label: "Codex CLI", minimumVersion: "0.167.2", namedSelector: "profile",
|
|
18
|
+
protocol: "codex-json", authStatus: Object.freeze(["login", "status"]),
|
|
19
|
+
authStatusJson: false, loginCommand: "codex login",
|
|
20
|
+
observation: Object.freeze({
|
|
21
|
+
id: "codex",
|
|
22
|
+
activityEvents: Object.freeze({
|
|
23
|
+
"codex.user_prompt": "working", "codex.api_request": "working", "codex.tool_result": "working",
|
|
24
|
+
"codex.response_usage": "working", "codex.conversation_starts": "unknown",
|
|
25
|
+
}),
|
|
26
|
+
usageEvents: Object.freeze(["codex.response_usage"]),
|
|
27
|
+
requireCacheUsage: false,
|
|
28
|
+
}),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
export const NATIVE_CLAUDE_POLICY_UNRESOLVED = "Claude policy sources include settings or agent definitions whose effective selection could not be fully captured. Native tasks remain available; automatic learning is unavailable.";
|
|
32
|
+
export const NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED = "Claude policy sources may include additional instruction files or selection settings whose effective policy was not captured. Native tasks remain available; automatic learning is unavailable.";
|
|
33
|
+
export const NATIVE_RUNTIMES = Object.freeze(Object.keys(NATIVE_RUNTIME_FACTS));
|
|
34
|
+
export const NATIVE_MINIMUM_VERSION = Object.freeze(Object.fromEntries(NATIVE_RUNTIMES.map(runtime => [runtime, NATIVE_RUNTIME_FACTS[runtime].minimumVersion])));
|
|
35
|
+
export const isNativeRuntime = (value) => typeof value === "string" && Object.hasOwn(NATIVE_RUNTIME_FACTS, value);
|
|
36
|
+
export const NATIVE_OBSERVATION_HARNESSES = Object.freeze(NATIVE_RUNTIMES.map(runtime => NATIVE_RUNTIME_FACTS[runtime].observation.id));
|
|
37
|
+
const OBSERVATION_PROTOCOLS = Object.freeze(Object.fromEntries(NATIVE_RUNTIMES.map(runtime => {
|
|
38
|
+
const protocol = NATIVE_RUNTIME_FACTS[runtime].observation;
|
|
39
|
+
return [protocol.id, protocol];
|
|
40
|
+
})));
|
|
41
|
+
export const nativeObservationProtocol = (value) => typeof value === "string" && Object.hasOwn(OBSERVATION_PROTOCOLS, value) ? OBSERVATION_PROTOCOLS[value] : undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const NATIVE_SELECTOR: {
|
|
2
|
+
type: string;
|
|
3
|
+
additionalProperties: boolean;
|
|
4
|
+
properties: Record<string, unknown>;
|
|
5
|
+
required: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const NATIVE_USAGE: {
|
|
8
|
+
type: string;
|
|
9
|
+
additionalProperties: boolean;
|
|
10
|
+
properties: Record<string, unknown>;
|
|
11
|
+
required: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare const NATIVE_TARGET: {
|
|
14
|
+
type: string;
|
|
15
|
+
additionalProperties: boolean;
|
|
16
|
+
properties: Record<string, unknown>;
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare const NATIVE_BINDING: {
|
|
20
|
+
properties: {
|
|
21
|
+
connected: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
verified_at: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
remote: {
|
|
28
|
+
type: string;
|
|
29
|
+
additionalProperties: boolean;
|
|
30
|
+
properties: Record<string, unknown>;
|
|
31
|
+
required: string[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
'x-agentrun-serve': string;
|
|
36
|
+
type: string;
|
|
37
|
+
additionalProperties: boolean;
|
|
38
|
+
};
|
|
39
|
+
export declare const NATIVE_RUN: {
|
|
40
|
+
'x-agentrun-serve': string;
|
|
41
|
+
type: string;
|
|
42
|
+
additionalProperties: boolean;
|
|
43
|
+
properties: Record<string, unknown>;
|
|
44
|
+
required: string[];
|
|
45
|
+
};
|
|
46
|
+
export declare const NATIVE_PATHS: Record<string, Record<string, unknown>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const text = { type: 'string' };
|
|
2
|
+
const nullableText = { type: ['string', 'null'] };
|
|
3
|
+
const strings = { type: 'array', items: text };
|
|
4
|
+
const object = (properties, required = Object.keys(properties)) => ({ type: 'object', additionalProperties: false, properties, required });
|
|
5
|
+
export const NATIVE_SELECTOR = object({ kind: { enum: ['project', 'agent', 'profile'] }, name: text }, ['kind']);
|
|
6
|
+
export const NATIVE_USAGE = object({ input_tokens: { type: ['integer', 'null'] }, output_tokens: { type: ['integer', 'null'] }, cache_read_tokens: { type: ['integer', 'null'] }, cache_write_tokens: { type: ['integer', 'null'] }, cost_usd: { type: ['number', 'null'] } });
|
|
7
|
+
export const NATIVE_TARGET = object({ runtime: { enum: ['claude-code', 'codex'] }, project: text, selector: NATIVE_SELECTOR, machine_id: text, version: nullableText, model: nullableText, fingerprint: text, configuration: { type: 'array', items: object({ path: text, sha256: text }) }, skills: strings, mcp_servers: strings, state: { enum: ['needs_verification', 'needs_attention', 'ready'] }, issues: strings, capabilities: object({ launch: { type: 'boolean' }, notes: { type: 'boolean' }, skills: { type: 'boolean' }, workflows: { const: false }, approval: { enum: ['native', 'unavailable'] }, usage: { type: 'boolean' } }) });
|
|
8
|
+
export const NATIVE_BINDING = { ...NATIVE_TARGET, properties: { ...NATIVE_TARGET.properties, connected: { type: 'boolean' }, verified_at: text, remote: object({ connector_id: text, target_id: text }) }, required: [...NATIVE_TARGET.required, 'connected'], 'x-agentrun-serve': 'native/1' };
|
|
9
|
+
export const NATIVE_RUN = { ...object({ runtime: text, project: text, selector: NATIVE_SELECTOR, machine_id: text, fingerprint: text, session_id: nullableText, model: nullableText, learning_revision: nullableText, usage: object({ task: { oneOf: [NATIVE_USAGE, { type: 'null' }] }, reflection: { type: 'array', items: NATIVE_USAGE } }), model_requests: { type: 'null' } }), 'x-agentrun-serve': 'native/1' };
|
|
10
|
+
const response = (schema) => ({ description: 'Native connection on the source machine.', content: { 'application/json': { schema } } });
|
|
11
|
+
const body = (schema) => ({ required: true, content: { 'application/json': { schema } } });
|
|
12
|
+
const mark = { 'x-agentrun-serve': 'native/1', security: [{ bearer: [] }, { ownerSession: [] }], tags: ['agents'] };
|
|
13
|
+
const id = { $ref: '#/components/parameters/AgentId' };
|
|
14
|
+
export const NATIVE_PATHS = {
|
|
15
|
+
'/native/discover': { post: { ...mark, operationId: 'discoverNative', summary: 'Discover existing native projects on this source machine without running a model', requestBody: body(object({ project: text, runtime: { enum: ['claude-code', 'codex'] } }, ['project'])), responses: { '200': response(object({ machine_id: text, targets: { type: 'array', items: NATIVE_TARGET } })) } } },
|
|
16
|
+
'/native/connect': { post: { ...mark, operationId: 'connectNative', summary: 'Connect a native project using ordinary agent and revision storage', requestBody: body(object({ project: text, runtime: { enum: ['claude-code', 'codex'] }, selector: NATIVE_SELECTOR }, ['project', 'runtime'])), responses: { '200': response(object({ agent: { $ref: '#/components/schemas/Agent' }, native: NATIVE_BINDING })) } } },
|
|
17
|
+
'/agents/{agent_id}/native': { get: { ...mark, operationId: 'getNative', summary: 'Read a native connection', parameters: [id], responses: { '200': response(object({ native: { oneOf: [NATIVE_BINDING, { type: 'null' }] } })) } } },
|
|
18
|
+
'/agents/{agent_id}/native/verify': { post: { ...mark, operationId: 'verifyNative', summary: 'Check native CLI and sign-in without a paid model call', parameters: [id], responses: { '200': response(object({ native: NATIVE_BINDING })) } } },
|
|
19
|
+
'/agents/{agent_id}/native/disconnect': { post: { ...mark, operationId: 'disconnectNative', summary: 'Disconnect future native jobs while retaining source configuration and history', parameters: [id], responses: { '200': response(object({ native: NATIVE_BINDING })) } } },
|
|
20
|
+
};
|
|
21
|
+
const targetId = { name: 'target_id', in: 'path', required: true, schema: text };
|
|
22
|
+
const scopes = object({ native_execution: { type: 'boolean' }, history_import: { type: 'boolean' } }, []);
|
|
23
|
+
const connectorId = { name: 'connector_id', in: 'path', required: true, schema: text };
|
|
24
|
+
const commandId = { name: 'command_id', in: 'path', required: true, schema: text };
|
|
25
|
+
const opaqueObject = { type: 'object', additionalProperties: true };
|
|
26
|
+
const connector = object({ id: text, connector_id: text, label: text, created_at: text, last_seen_at: nullableText, status: { enum: ['online', 'offline', 'revoked'] }, capabilities: object({ observe: { const: true }, native_execution: { type: 'boolean' }, history_import: { type: 'boolean' } }), targets: { type: 'array', items: opaqueObject } });
|
|
27
|
+
const remoteMark = { ...mark, tags: ['connectors'], 'x-agentrun-serve': 'connectors/1' };
|
|
28
|
+
const workerMark = { ...remoteMark, security: [{ bearer: [] }] };
|
|
29
|
+
Object.assign(NATIVE_PATHS, {
|
|
30
|
+
'/connectors': {
|
|
31
|
+
get: { ...remoteMark, operationId: 'listRemoteConnectors', summary: 'List remote source machines and imported agent targets', responses: { '200': response(object({ connectors: { type: 'array', items: connector } })) } },
|
|
32
|
+
post: { ...workerMark, operationId: 'registerRemoteConnector', summary: 'Exchange a one-use enrollment code for a connector-scoped credential', requestBody: body(object({ installation_id: text, operation_id: text, label: text, capabilities: object({ native_execution: { type: 'boolean' }, history_import: { type: 'boolean' } }, ['native_execution']) }, ['installation_id', 'operation_id', 'capabilities'])), responses: { '200': response(object({ connector, credential: text, credential_expires_at: text })) } }
|
|
33
|
+
},
|
|
34
|
+
'/connectors/enrollment': { post: { ...remoteMark, operationId: 'enrollRemoteConnector', summary: 'Create a ten-minute one-use connection code', requestBody: body(object({ label: text, capabilities: scopes }, [])), responses: { '200': response(object({ enrollment_token: text, expires_at: text, workspace_id: { const: 'local' } })) } } },
|
|
35
|
+
'/connectors/{connector_id}': { delete: { ...remoteMark, operationId: 'revokeRemoteConnector', summary: 'Revoke a source connector and stop its outstanding commands', parameters: [connectorId], responses: { '200': response(object({ connector })) } } },
|
|
36
|
+
'/connectors/{connector_id}/import': { post: { ...workerMark, operationId: 'importRemoteTarget', summary: 'Import an explicitly selected source-native agent reference', parameters: [connectorId], requestBody: body(object({ target_id: text, name: text, target: NATIVE_BINDING, history_only: { type: 'boolean' } }, ['target_id', 'target'])), responses: { '200': response(object({ agent_id: text, native: NATIVE_BINDING })) } } },
|
|
37
|
+
'/connectors/{connector_id}/targets/{target_id}/history': { post: { ...workerMark, operationId: 'importRemoteHistory', summary: 'Import explicitly selected, redacted past sessions without running or learning from them', parameters: [connectorId, targetId], requestBody: body(object({ sessions: { type: 'array', minItems: 1, maxItems: 20, items: opaqueObject } })), responses: { '200': response(object({ agent_id: text, runs: { type: 'array', items: object({ session_id: text, run_id: text, already: { type: 'boolean' } }) }, imported: { type: 'integer' }, already: { type: 'integer' } })) } } },
|
|
38
|
+
'/connectors/{connector_id}/poll': { post: { ...workerMark, operationId: 'pollRemoteConnector', summary: 'Renew active source leases and claim one command without replay', parameters: [connectorId], requestBody: body(object({ worker_id: text, active: { type: 'array', items: object({ command_id: text, lease_token: text }) } }, ['worker_id'])), responses: { '200': response(object({ commands: { type: 'array', items: opaqueObject }, cancelled: strings, server_time: { type: 'number' }, lease_ttl_ms: { type: 'number' } })) } } },
|
|
39
|
+
'/connectors/{connector_id}/commands/{command_id}/events': { post: { ...workerMark, operationId: 'remoteCommandEvents', summary: 'Append an ordered idempotent native event batch for a valid command lease', parameters: [connectorId, commandId], requestBody: body(object({ lease_token: text, sequence: { type: 'integer', minimum: 0 }, events: { type: 'array', items: opaqueObject } })), responses: { '200': response(object({ accepted: { const: true } })) } } },
|
|
40
|
+
'/connectors/{connector_id}/commands/{command_id}/complete': { post: { ...workerMark, operationId: 'completeRemoteCommand', summary: 'Complete a source command once under its valid lease', parameters: [connectorId, commandId], requestBody: body(object({ lease_token: text, result: {}, error: text }, ['lease_token'])), responses: { '200': response(object({ accepted: { const: true } })) } } }
|
|
41
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Native connections refer to the user's installed runtime; no configuration or credential is copied. */
|
|
2
|
+
import type { NativeRuntime } from "./runtimes.js";
|
|
3
|
+
export type { NativeRuntime } from "./runtimes.js";
|
|
4
|
+
export type NativeSelector = {
|
|
5
|
+
kind: "project" | "agent" | "profile";
|
|
6
|
+
name?: string;
|
|
7
|
+
};
|
|
8
|
+
export type NativeTarget = {
|
|
9
|
+
runtime: NativeRuntime;
|
|
10
|
+
project: string;
|
|
11
|
+
selector: NativeSelector;
|
|
12
|
+
machine_id: string;
|
|
13
|
+
version: string | null;
|
|
14
|
+
model: string | null;
|
|
15
|
+
fingerprint: string;
|
|
16
|
+
configuration: {
|
|
17
|
+
path: string;
|
|
18
|
+
sha256: string;
|
|
19
|
+
}[];
|
|
20
|
+
skills: string[];
|
|
21
|
+
mcp_servers: string[];
|
|
22
|
+
state: "needs_verification" | "needs_attention";
|
|
23
|
+
issues: string[];
|
|
24
|
+
capabilities: {
|
|
25
|
+
launch: boolean;
|
|
26
|
+
notes: boolean;
|
|
27
|
+
skills: boolean;
|
|
28
|
+
workflows: false;
|
|
29
|
+
approval: "native" | "unavailable";
|
|
30
|
+
usage: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type NativeBinding = Omit<NativeTarget, "state"> & {
|
|
34
|
+
state: NativeTarget["state"] | "ready";
|
|
35
|
+
connected: boolean;
|
|
36
|
+
verified_at?: string;
|
|
37
|
+
/** A source-approved target on an outbound-only connector, never a server-selected remote path. */
|
|
38
|
+
remote?: {
|
|
39
|
+
connector_id: string;
|
|
40
|
+
target_id: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type NativeUsage = {
|
|
44
|
+
input_tokens: number | null;
|
|
45
|
+
output_tokens: number | null;
|
|
46
|
+
cache_read_tokens: number | null;
|
|
47
|
+
cache_write_tokens: number | null;
|
|
48
|
+
cost_usd: number | null;
|
|
49
|
+
};
|
|
50
|
+
export type NativeEvent = {
|
|
51
|
+
type: "session";
|
|
52
|
+
sessionId: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: "text";
|
|
55
|
+
text: string;
|
|
56
|
+
} | {
|
|
57
|
+
type: "tool";
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
input?: unknown;
|
|
61
|
+
output?: unknown;
|
|
62
|
+
status: "started" | "completed" | "failed";
|
|
63
|
+
} | {
|
|
64
|
+
type: "approval";
|
|
65
|
+
id: string;
|
|
66
|
+
tool: string;
|
|
67
|
+
input?: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
type: "usage";
|
|
70
|
+
usage: NativeUsage;
|
|
71
|
+
};
|
|
72
|
+
export type NativeResult = {
|
|
73
|
+
sessionId: string;
|
|
74
|
+
answer: string;
|
|
75
|
+
model?: string;
|
|
76
|
+
usage: NativeUsage;
|
|
77
|
+
permission_denials?: string[];
|
|
78
|
+
};
|
|
79
|
+
export type NativeSendOptions = {
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
reflection?: boolean;
|
|
82
|
+
timeoutMs?: number;
|
|
83
|
+
};
|
|
84
|
+
export type NativeSession = {
|
|
85
|
+
send(prompt: string, options?: NativeSendOptions): Promise<NativeResult>;
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { Observations } from "./observer.js";
|
|
3
|
+
export declare function isObservationRoute(path: string): boolean;
|
|
4
|
+
export declare function observationHttp(req: IncomingMessage, res: ServerResponse, url: URL, observer: Observations, ownerToken: string): Promise<void>;
|