@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
package/dist/harness.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
// capabilities, and a revision naming one it does not run saves with a warning and is refused at run time.
|
|
5
5
|
export const HARNESSES = ["pi", "claude-agent", "codex", "opencode"];
|
|
6
6
|
export const DEFAULT_HARNESS = "pi";
|
|
7
|
+
/** The harnesses that run on a person's ChatGPT plan (chatgpt-plan.ts): those whose requests go to OpenAI's Responses
|
|
8
|
+
* API as the plan takes them. The others need a model key. */
|
|
9
|
+
export const PLAN_HARNESSES = Object.freeze(["pi", "codex"]);
|
|
7
10
|
const offered = new WeakMap();
|
|
8
11
|
/** `env` with every model key taken out (each provider's, model.ts PROVIDER_KEYS, and the gateway's), its other
|
|
9
12
|
* properties kept as they are: what a harness would ask for with no model key. */
|
|
@@ -53,7 +56,8 @@ export function harnessOffers(env) {
|
|
|
53
56
|
// Each harness's model when a definition names none, as a save and a run resolve it (runnable.ts): none for a
|
|
54
57
|
// harness that does not run here, or that no model here would run on.
|
|
55
58
|
const { harnessModel } = await import("./runnable.js");
|
|
56
|
-
const { pickerCandidates } = await import("./model-form.js");
|
|
59
|
+
const { pickerCandidates, freeCandidates } = await import("./model-form.js");
|
|
60
|
+
const { planWouldRun, withPlanWords } = await import("./model.js");
|
|
57
61
|
return Promise.all(base.map(async (offer) => {
|
|
58
62
|
const resolved = offer.available ? await harnessModel(env, offer.id, undefined, true) : undefined;
|
|
59
63
|
// The models a person may pick for it (model-form.ts), each in the form it takes: those its entry's own choice
|
|
@@ -61,6 +65,8 @@ export function harnessOffers(env) {
|
|
|
61
65
|
// so the picker never offers one a save would refuse. None for a harness that does not run here.
|
|
62
66
|
const entry = harnessOf(env, offer.id);
|
|
63
67
|
const models = [];
|
|
68
|
+
// Its free models (model-form.ts freeCandidates) are offered after the others, by the same checks.
|
|
69
|
+
const free = offer.available ? await freeCandidates(env, offer.id) : [];
|
|
64
70
|
if (offer.available) {
|
|
65
71
|
// Each choice passes what a save and a run ask, by construction: the save's own shape check (MODEL_REF), the
|
|
66
72
|
// harness's own choice of it, and, on an adapter's wire, providerFor, the function a run starts with. A model
|
|
@@ -71,7 +77,7 @@ export function harnessOffers(env) {
|
|
|
71
77
|
const { ADAPTER_FACTS } = await import("./adapter-facts.js");
|
|
72
78
|
const { FAUX_ENV } = await import("./model.js");
|
|
73
79
|
const facts = ADAPTER_FACTS.find((f) => f.id === offer.id);
|
|
74
|
-
for (const id of pickerCandidates(env, offer.id)) {
|
|
80
|
+
for (const id of new Set([...pickerCandidates(env, offer.id), ...free.map((m) => m.id)])) {
|
|
75
81
|
if (!MODEL_REF.test(id))
|
|
76
82
|
continue;
|
|
77
83
|
const chosen = await entry.model(env, id, true);
|
|
@@ -89,7 +95,13 @@ export function harnessOffers(env) {
|
|
|
89
95
|
models.push(id);
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
|
-
|
|
98
|
+
// One that runs nothing here for want of a key (unavailable with `keys`, or available with no default model for
|
|
99
|
+
// want of one: pi's) says what would give it a model: a key, and for codex and pi the ChatGPT sign-in where this
|
|
100
|
+
// server signs in (planWouldRun), in its reason and in `needs`.
|
|
101
|
+
const wantsKey = offer.available ? resolved !== undefined && "why" in resolved && resolved.needs === "key" : Boolean(offer.keys?.length);
|
|
102
|
+
const sayWhy = !wantsKey ? {} : offer.available ? { reason: resolved.why } : offer.reason ? { reason: withPlanWords(env, offer.id, offer.reason) } : {};
|
|
103
|
+
const needs = wantsKey ? ["key", ...(planWouldRun(env, offer.id) ? ["chatgpt"] : [])] : [];
|
|
104
|
+
return { ...offer, ...sayWhy, default_model: resolved && "model" in resolved ? `${resolved.model.provider}/${resolved.model.modelId}` : null, models, free_models: free.filter((m) => models.includes(m.id)), run_memory_mib: entry.runMib, ...(needs.length ? { needs } : {}) };
|
|
93
105
|
}));
|
|
94
106
|
})();
|
|
95
107
|
offered.set(env, offers);
|
package/dist/host-tools.d.ts
CHANGED
|
@@ -2,10 +2,6 @@ import type { Context } from "@earendil-works/chord/context";
|
|
|
2
2
|
import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { HostTool } from "@parcha/agentrun-kernel";
|
|
4
4
|
export { workspaceRelative } from "./workspace-paths.js";
|
|
5
|
-
/** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again.
|
|
6
|
-
* `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL, named here as a string so the modules do not import
|
|
7
|
-
* each other) is never run again. */
|
|
8
|
-
export declare const REPLAY: Record<string, "safe" | "never">;
|
|
9
5
|
export { cutUtf8, MAX_BYTES, MAX_LINES } from "./workspace/executors.js";
|
|
10
6
|
/** One call's result, kept by its call id for the run's timeline (an adapter's tool_end carries none). */
|
|
11
7
|
export type ToolResults = Map<string, {
|
|
@@ -51,5 +47,5 @@ export interface HostToolCtx {
|
|
|
51
47
|
/** One pi ToolRegistration `tool` (named `name` by its catalog name) as the kernel's HostTool an adapter session takes:
|
|
52
48
|
* the paid-call seam, then the tool on the run's environment and harness, its answer the text a
|
|
53
49
|
* model reads (the output or the failure, a write's or an error's path named relative to the run's folder). Undefined when
|
|
54
|
-
* `name` is not one a host runs (
|
|
50
|
+
* `name` is not one a host runs (tool-list.ts `replay`). */
|
|
55
51
|
export declare function hostToolOf(name: string, tool: ToolRegistration, ctx: HostToolCtx): HostTool | undefined;
|
package/dist/host-tools.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { withAbortSignal } from "@earendil-works/chord/context";
|
|
2
2
|
import { createModels } from "@earendil-works/pi-ai/models";
|
|
3
3
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
4
|
-
import {
|
|
5
|
-
import { WEB_SEARCH_TOOL } from "./web-search.js";
|
|
4
|
+
import { replayOf } from "./tool-list.js";
|
|
6
5
|
import { realOf, workspaceRelative } from "./workspace-paths.js";
|
|
7
6
|
import { bounded, imagesOf, textOf } from "./workspace/executors.js";
|
|
8
7
|
export { workspaceRelative } from "./workspace-paths.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* each other) is never run again. */
|
|
12
|
-
export const REPLAY = { read: "safe", write: "never", edit: "never", bash: "never", [WEB_FETCH_TOOL]: "safe", [WEB_SEARCH_TOOL]: "safe", "monid.discover": "safe", "monid.inspect": "safe", "monid.run": "never", bash_background: "never", bash_output: "safe", bash_input: "never", bash_signal: "never", bash_list: "safe", learned_workflow: "never" };
|
|
8
|
+
// Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again, is its
|
|
9
|
+
// row's `replay` (tool-list.ts). `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL) is never run again.
|
|
13
10
|
// pi's limits on a tool's output, and how a call's output is held within them, are the executors' (workspace/executors.ts).
|
|
14
11
|
export { cutUtf8, MAX_BYTES, MAX_LINES } from "./workspace/executors.js";
|
|
15
12
|
/** The members of pi's ToolExecutionApi a host tool's api gives. They are typed against pi's own type (`HostApi`), so a
|
|
@@ -38,9 +35,9 @@ const SAYS_PATH = new Set(["write", "edit"]);
|
|
|
38
35
|
/** One pi ToolRegistration `tool` (named `name` by its catalog name) as the kernel's HostTool an adapter session takes:
|
|
39
36
|
* the paid-call seam, then the tool on the run's environment and harness, its answer the text a
|
|
40
37
|
* model reads (the output or the failure, a write's or an error's path named relative to the run's folder). Undefined when
|
|
41
|
-
* `name` is not one a host runs (
|
|
38
|
+
* `name` is not one a host runs (tool-list.ts `replay`). */
|
|
42
39
|
export function hostToolOf(name, tool, ctx) {
|
|
43
|
-
const replay =
|
|
40
|
+
const replay = replayOf(name);
|
|
44
41
|
if (!replay)
|
|
45
42
|
return undefined;
|
|
46
43
|
return {
|
|
@@ -59,7 +56,7 @@ export function hostToolOf(name, tool, ctx) {
|
|
|
59
56
|
const out = bounded(tool.outputLimits);
|
|
60
57
|
const notes = [];
|
|
61
58
|
const env = await ctx.env();
|
|
62
|
-
// The call's id and the run's store, as pi's: a paid call marks and books its charge there
|
|
59
|
+
// The call's id and the run's store, as pi's: a paid call marks and books its charge there.
|
|
63
60
|
const api = hostApi({
|
|
64
61
|
env, callId,
|
|
65
62
|
commit: ctx.commit,
|
|
@@ -71,7 +68,7 @@ export function hostToolOf(name, tool, ctx) {
|
|
|
71
68
|
snapshot: ctx.snapshot, waitForTask: ctx.waitForTask,
|
|
72
69
|
});
|
|
73
70
|
// A tool that throws (bash on a non-zero exit or a timeout) still answers with its output, as pi's harness does;
|
|
74
|
-
//
|
|
71
|
+
// one that answers a failure as an error result is kept as it is.
|
|
75
72
|
const result = await tool.execute(args, api, withAbortSignal(signal, ctx.context)).catch((error) => ({ failed: error.message, isError: true }));
|
|
76
73
|
// pi names a result's blocks `output`; its bash answers its exit as a result's diagnostic.
|
|
77
74
|
const given = result;
|
package/dist/hosted-search.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Models } from "@earendil-works/pi-ai";
|
|
2
|
-
import { type Search } from "./web-search.js";
|
|
2
|
+
import { type Search, type Searched } from "./web-search.js";
|
|
3
3
|
export declare const HOSTED_MAX_USES = 5;
|
|
4
4
|
/** One search's results billed as input: about 25,000 tokens, a working estimate. */
|
|
5
5
|
export declare const SEARCH_INPUT_TOKENS = 25000;
|
|
@@ -21,11 +21,11 @@ export declare const OPENAI_SEARCH_TOOL: Readonly<{
|
|
|
21
21
|
export declare const OPENAI_SEARCH_LIMIT: Readonly<{
|
|
22
22
|
max_tool_calls: 5;
|
|
23
23
|
}>;
|
|
24
|
-
/** $10 per 1,000 searches (Anthropic) or calls (OpenAI). */
|
|
25
|
-
export declare const SEARCH_USD = 0.01;
|
|
26
24
|
/** What a hosted search asks: the run's models a search request goes through (on the runner, the session's port: its
|
|
27
25
|
* proxy, policy, key, price and cap), handed to each search by its run, never kept per process. */
|
|
28
26
|
export type SearchModels = Pick<Models, "getModel" | "completeSimple">;
|
|
29
27
|
/** `query` searched by `ref`'s provider (`provider/model-id`, the model the server resolved web_search on) through the
|
|
30
28
|
* run's models (`models`: its own, handed by the run; none, no model to search on), at most `n` results: a Search. */
|
|
31
29
|
export declare function hostedSearch(query: string, n: number, ref: string | undefined, signal: AbortSignal | undefined, models: SearchModels | undefined): Promise<Search>;
|
|
30
|
+
/** hostedSearch, and the limit the provider answered for the run's key, if any (QUOTA, RATE). */
|
|
31
|
+
export declare function hostedSearched(query: string, n: number, ref: string | undefined, signal: AbortSignal | undefined, models: SearchModels | undefined): Promise<Searched>;
|
package/dist/hosted-search.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { clip, TITLE_CAP } from "./web-fetch-direct.js";
|
|
2
|
-
import { sideRequests } from "./cap.js";
|
|
3
2
|
import { ANSWER_MAX, snippetOf } from "./web-search.js";
|
|
4
3
|
export const HOSTED_MAX_USES = 5;
|
|
5
4
|
/** One search's results billed as input: about 25,000 tokens, a working estimate. */
|
|
@@ -13,14 +12,27 @@ export const OPENAI_SEARCH_TOOL = Object.freeze({ type: "web_search", external_w
|
|
|
13
12
|
/** OpenAI's hosted search has no per-tool limit: the Responses API's `max_tool_calls` caps the built-in tool calls of the
|
|
14
13
|
* request at the HOSTED_MAX_USES its fee is reserved for, as Anthropic's tool's `max_uses` does. */
|
|
15
14
|
export const OPENAI_SEARCH_LIMIT = Object.freeze({ max_tool_calls: HOSTED_MAX_USES });
|
|
16
|
-
/** $10 per 1,000 searches (Anthropic) or calls (OpenAI). */
|
|
17
|
-
export const SEARCH_USD = 0.01;
|
|
18
|
-
/** OpenAI's models that bill each call's search content as a fixed block of 8,000 input tokens apart from the response's
|
|
19
|
-
* usage: the block is added to the fee at the model's input price. */
|
|
20
|
-
const BLOCK_BILLED = /^gpt-(?:4o|4\.1)-mini(?:-|$)/;
|
|
21
15
|
const ANSWER_TOKENS = 2_048;
|
|
22
16
|
/** As Exa's and Parallel's searches stop. */
|
|
23
17
|
const TIMEOUT_MS = 60_000;
|
|
18
|
+
/** A provider's answer that the run's key is out of quota, by the status or the error code it names: a 402, Anthropic's
|
|
19
|
+
* billing_error, OpenAI's insufficient_quota (which OpenAI answers as a 429, so it is read first). */
|
|
20
|
+
const QUOTA = /(?<![\w.])402(?![\w.])|\b(?:billing_error|insufficient_quota)\b/;
|
|
21
|
+
/** A provider's answer that the run's key is rate-limited: a 429, Anthropic's rate_limit_error, OpenAI's
|
|
22
|
+
* rate_limit_exceeded, Anthropic's hosted search's own too_many_requests. Never its other failures (an overload, a 5xx),
|
|
23
|
+
* which pass. */
|
|
24
|
+
const RATE = /(?<![\w.])429(?![\w.])|\b(?:rate_limit_error|rate_limit_exceeded|too_many_requests)\b/;
|
|
25
|
+
/** The limit `said` names, with the Retry-After `error` carries when the provider's client kept its headers (none: the
|
|
26
|
+
* breaker's 60 s). */
|
|
27
|
+
function limitOf(said, error) {
|
|
28
|
+
if (QUOTA.test(said))
|
|
29
|
+
return { kind: "quota" };
|
|
30
|
+
if (!RATE.test(said))
|
|
31
|
+
return undefined;
|
|
32
|
+
const headers = error?.headers;
|
|
33
|
+
const header = headers instanceof Headers ? headers.get("retry-after") : headers && typeof headers === "object" ? headers["retry-after"] : undefined;
|
|
34
|
+
return { kind: "rate", ...(typeof header === "string" && header ? { retryAfter: header } : {}) };
|
|
35
|
+
}
|
|
24
36
|
const list = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === "object" && item !== null) : []);
|
|
25
37
|
const text = (value) => (typeof value === "string" ? value : undefined);
|
|
26
38
|
/** What a provider's events say of the search: its results by URL, first seen first, and how many searches it ran. */
|
|
@@ -32,16 +44,19 @@ function reader(anthropic) {
|
|
|
32
44
|
const hit = hits.get(url) ?? {};
|
|
33
45
|
hits.set(url, { ...found, ...Object.fromEntries(Object.entries(hit).filter(([, value]) => value)) });
|
|
34
46
|
};
|
|
35
|
-
let reported;
|
|
36
|
-
let calls = 0;
|
|
37
47
|
let failed;
|
|
48
|
+
// Every search's error code, kept whether or not another search found results: a later search rate-limited after an
|
|
49
|
+
// early one's hits still says the run's key is limited.
|
|
50
|
+
const codes = [];
|
|
38
51
|
const anthropicEvent = (event) => {
|
|
39
52
|
const block = event.content_block;
|
|
40
|
-
if (event.type === "content_block_start" && block?.type === "server_tool_use" && block.name === "web_search")
|
|
41
|
-
calls += 1;
|
|
42
53
|
if (event.type === "content_block_start" && block?.type === "web_search_tool_result") {
|
|
43
|
-
if (!Array.isArray(block.content))
|
|
44
|
-
|
|
54
|
+
if (!Array.isArray(block.content)) {
|
|
55
|
+
const code = text(block.content?.error_code);
|
|
56
|
+
if (code)
|
|
57
|
+
codes.push(code);
|
|
58
|
+
failed = code ?? "the search failed";
|
|
59
|
+
}
|
|
45
60
|
for (const result of list(block.content))
|
|
46
61
|
if (result.type === "web_search_result")
|
|
47
62
|
add(result.url, { title: text(result.title), published: text(result.page_age) });
|
|
@@ -49,14 +64,10 @@ function reader(anthropic) {
|
|
|
49
64
|
const citation = event.delta?.type === "citations_delta" ? event.delta.citation : undefined;
|
|
50
65
|
if (citation)
|
|
51
66
|
add(citation.url, { title: text(citation.title), snippet: text(citation.cited_text) });
|
|
52
|
-
const used = event.usage?.server_tool_use?.web_search_requests;
|
|
53
|
-
if (event.type === "message_delta" && typeof used === "number")
|
|
54
|
-
reported = used;
|
|
55
67
|
};
|
|
56
68
|
const openaiEvent = (event) => {
|
|
57
69
|
const item = event.item;
|
|
58
70
|
if (event.type === "response.output_item.done" && item?.type === "web_search_call") {
|
|
59
|
-
calls += 1;
|
|
60
71
|
for (const source of list(item.action?.sources))
|
|
61
72
|
add(source.url, {});
|
|
62
73
|
}
|
|
@@ -72,21 +83,25 @@ function reader(anthropic) {
|
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
}
|
|
75
|
-
const used = (event.response?.tool_usage?.web_search)?.num_requests;
|
|
76
|
-
if ((event.type === "response.completed" || event.type === "response.incomplete") && typeof used === "number")
|
|
77
|
-
reported = used;
|
|
78
86
|
};
|
|
79
87
|
return {
|
|
80
88
|
event: (event) => (anthropic ? anthropicEvent : openaiEvent)((event ?? {})),
|
|
81
|
-
/** The searches the provider reported, else the search calls its answer held. */
|
|
82
|
-
searches: () => reported ?? calls,
|
|
83
89
|
failed: () => (hits.size ? undefined : failed),
|
|
90
|
+
codes: () => codes,
|
|
84
91
|
hits: () => [...hits].map(([url, hit]) => ({ url, title: clip(hit.title ?? "", TITLE_CAP), snippet: snippetOf(hit.snippet ?? ""), ...(hit.published ? { published: hit.published } : {}) })),
|
|
85
92
|
};
|
|
86
93
|
}
|
|
87
94
|
/** `query` searched by `ref`'s provider (`provider/model-id`, the model the server resolved web_search on) through the
|
|
88
95
|
* run's models (`models`: its own, handed by the run; none, no model to search on), at most `n` results: a Search. */
|
|
89
96
|
export async function hostedSearch(query, n, ref, signal, models) {
|
|
97
|
+
return (await hostedSearched(query, n, ref, signal, models)).answer;
|
|
98
|
+
}
|
|
99
|
+
/** hostedSearch, and the limit the provider answered for the run's key, if any (QUOTA, RATE). */
|
|
100
|
+
export async function hostedSearched(query, n, ref, signal, models) {
|
|
101
|
+
const failed = (error, said = "", thrown) => {
|
|
102
|
+
const limit = limitOf(said, thrown);
|
|
103
|
+
return { answer: { error }, ...(limit ? { limit } : {}) };
|
|
104
|
+
};
|
|
90
105
|
const slash = ref?.indexOf("/") ?? -1;
|
|
91
106
|
const provider = ref && slash > 0 ? ref.slice(0, slash) : undefined;
|
|
92
107
|
const id = ref && slash > 0 ? ref.slice(slash + 1) : undefined;
|
|
@@ -94,14 +109,12 @@ export async function hostedSearch(query, n, ref, signal, models) {
|
|
|
94
109
|
// provider.ts anthropicModelId), the one the run's models hold.
|
|
95
110
|
const model = models && provider && id ? (models.getModel(provider, id) ?? (provider === "anthropic" ? models.getModel(provider, id.replaceAll(".", "-")) : undefined)) : undefined;
|
|
96
111
|
if (!models || !model)
|
|
97
|
-
return
|
|
112
|
+
return failed(`web_search has no model to search on in this run${ref ? ` (${ref})` : ""}`);
|
|
98
113
|
const anthropic = model.api === "anthropic-messages";
|
|
99
114
|
if (!anthropic && model.api !== "openai-responses")
|
|
100
|
-
return
|
|
115
|
+
return failed(`web_search: ${ref} has no hosted web search here`);
|
|
101
116
|
const read = reader(anthropic);
|
|
102
117
|
const context = { messages: [{ role: "user", content: [{ type: "text", text: `Search the web for: ${query}\n\nAnswer briefly from what the search finds, and name each source by its URL.` }], timestamp: Date.now() }] };
|
|
103
|
-
const block = BLOCK_BILLED.test(model.id) ? (8_000 * (model.cost?.input ?? 0)) / 1e6 : 0;
|
|
104
|
-
sideRequests.set(context, { label: "web_search", extraInputTokens: HOSTED_SEARCH_ALLOWANCE_TOKENS, maxFeeUsd: HOSTED_MAX_USES * (SEARCH_USD + block), feeUsd: () => read.searches() * (SEARCH_USD + block) });
|
|
105
118
|
let answer;
|
|
106
119
|
try {
|
|
107
120
|
answer = await models.completeSimple(model, context, {
|
|
@@ -118,13 +131,19 @@ export async function hostedSearch(query, n, ref, signal, models) {
|
|
|
118
131
|
});
|
|
119
132
|
}
|
|
120
133
|
catch (error) {
|
|
121
|
-
|
|
134
|
+
const said = String(error?.message ?? error);
|
|
135
|
+
return failed(`the provider's search failed: ${said.slice(0, 300)}`, `${error?.status ?? ""} ${said}`, error);
|
|
122
136
|
}
|
|
123
|
-
if (answer.stopReason === "
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
if (answer.stopReason === "aborted")
|
|
138
|
+
return failed("the search was stopped");
|
|
139
|
+
if (answer.stopReason === "error")
|
|
140
|
+
return failed(`the provider's search failed: ${(answer.errorMessage ?? "no detail").slice(0, 300)}`, answer.errorMessage);
|
|
141
|
+
const refused = read.failed();
|
|
142
|
+
if (refused)
|
|
143
|
+
return failed(`the provider's search failed: ${refused}`, refused);
|
|
128
144
|
const said = answer.content.flatMap((part) => (part.type === "text" ? [part.text] : [])).join("").trim();
|
|
129
|
-
|
|
145
|
+
// Results found, and a later search of the same request failing all the same (too_many_requests after hits): the run
|
|
146
|
+
// gets the results, and the breaker the limit its codes name (no Retry-After reaches here: 60 s).
|
|
147
|
+
const limit = limitOf(read.codes().join(" "));
|
|
148
|
+
return { answer: { provider: "native", query, results: read.hits().slice(0, n), ...(said ? { text: clip(said, ANSWER_MAX) } : {}) }, ...(limit ? { limit } : {}) };
|
|
130
149
|
}
|
package/dist/import-sources.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export type Session = {
|
|
|
90
90
|
effort?: string;
|
|
91
91
|
};
|
|
92
92
|
/** The session files of `source` under `home`, never through a link. */
|
|
93
|
-
export declare function sessionFiles(home: string, source: Source): Promise<string[]>;
|
|
93
|
+
export declare function sessionFiles(home: string, source: Source, configRoot?: string): Promise<string[]>;
|
|
94
94
|
/** Claude Code's subagents' session files under `home`, in <session id>/subagents/ (a workflow's a folder deeper), each
|
|
95
95
|
* with the session file it ran under (`of`): the one beside the folder it sits in. A session moved to another project
|
|
96
96
|
* folder keeps its id there, with copies of its subagents' files: each folder's are its own file's. Never through a
|
package/dist/import-sources.js
CHANGED
|
@@ -19,11 +19,11 @@ export const HARNESS_OF = {
|
|
|
19
19
|
* open and counts nothing. Claude Code's Bash tool runs a call for up to 10 minutes with nothing written. */
|
|
20
20
|
export const ACTIVE_GAP_MS = 15 * 60_000;
|
|
21
21
|
/** The session files of `source` under `home`, never through a link. */
|
|
22
|
-
export async function sessionFiles(home, source) {
|
|
22
|
+
export async function sessionFiles(home, source, configRoot) {
|
|
23
23
|
const entries = async (dir) => readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
24
24
|
const out = [];
|
|
25
25
|
if (source === "claude-code") {
|
|
26
|
-
const root = join(home, ".claude", "projects");
|
|
26
|
+
const root = join(configRoot ?? join(home, ".claude"), "projects");
|
|
27
27
|
for (const project of await entries(root)) {
|
|
28
28
|
if (!project.isDirectory())
|
|
29
29
|
continue;
|
|
@@ -41,7 +41,7 @@ export async function sessionFiles(home, source) {
|
|
|
41
41
|
out.push(join(dir, entry.name));
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
await walk(join(home, ".codex", "sessions"), 0);
|
|
44
|
+
await walk(join(configRoot ?? join(home, ".codex"), "sessions"), 0);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
const root = join(home, ".pi", "agent", "sessions");
|
package/dist/import.d.ts
CHANGED
|
@@ -12,6 +12,27 @@ export type ImportStore = {
|
|
|
12
12
|
importRun: Store["importRun"];
|
|
13
13
|
readJournal: Store["readJournal"];
|
|
14
14
|
};
|
|
15
|
+
/** Read only the explicitly selected project's historical sessions for an outbound connector. Metadata enumeration
|
|
16
|
+
* locates project sessions; unrelated transcripts are never exported or scanned for keys. No model is called and no
|
|
17
|
+
* source file is changed. Each page is independently redacted, bounded and safe to retry at the destination. */
|
|
18
|
+
export declare function exportRemoteHistory(target: Pick<import('./native/types.js').NativeTarget, 'runtime' | 'project' | 'selector'>, options?: {
|
|
19
|
+
home?: string;
|
|
20
|
+
env?: NodeJS.ProcessEnv;
|
|
21
|
+
own?: readonly string[];
|
|
22
|
+
now?: number;
|
|
23
|
+
cursor?: number;
|
|
24
|
+
inventory?: string;
|
|
25
|
+
preview?: boolean;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
sessions: import('./native/history.js').RemoteHistorySession[];
|
|
28
|
+
skipped: {
|
|
29
|
+
reason: string;
|
|
30
|
+
count: number;
|
|
31
|
+
}[];
|
|
32
|
+
next_cursor: number | null;
|
|
33
|
+
total: number;
|
|
34
|
+
inventory: string;
|
|
35
|
+
}>;
|
|
15
36
|
/** In the data directory while an import the owner asked for at setup has not ended: the server's next start goes on with it. */
|
|
16
37
|
export declare const IMPORT_ASKED = ".import-at-setup";
|
|
17
38
|
/** A session file written to this recently may still be running: it is left for a later import. */
|
package/dist/import.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// the owner's only. Read again, it imports only the sessions it has not.
|
|
7
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
|
-
import { lstat, realpath, stat } from "node:fs/promises";
|
|
9
|
+
import { lstat, open, realpath, stat } from "node:fs/promises";
|
|
10
10
|
import { homedir, tmpdir } from "node:os";
|
|
11
11
|
import { basename, dirname, join, sep } from "node:path";
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
@@ -32,6 +32,189 @@ import { journalEntries } from "./runner/journal-reader.js";
|
|
|
32
32
|
import { bodyOf, openStore, SchemaVersionUnknown, StoreFromEarlierVersion, StoreOwned, storeTarget } from "./store/index.js";
|
|
33
33
|
import { STORE_FILE } from "./store/sqlite/store.js";
|
|
34
34
|
import { foundOverStore } from "./store-reads/import-summary.js";
|
|
35
|
+
/** Read only the explicitly selected project's historical sessions for an outbound connector. Metadata enumeration
|
|
36
|
+
* locates project sessions; unrelated transcripts are never exported or scanned for keys. No model is called and no
|
|
37
|
+
* source file is changed. Each page is independently redacted, bounded and safe to retry at the destination. */
|
|
38
|
+
export async function exportRemoteHistory(target, options = {}) {
|
|
39
|
+
if (target.selector.kind !== 'project')
|
|
40
|
+
throw new Error('Session logs do not reliably identify named agents or profiles. Select the project to import its history.');
|
|
41
|
+
const now = options.now ?? Date.now(), cursor = options.cursor ?? 0;
|
|
42
|
+
if (!Number.isSafeInteger(cursor) || cursor < 0)
|
|
43
|
+
throw new Error('Invalid history cursor.');
|
|
44
|
+
const project = await realpath(target.project), selected = [], skipped = new Map(), stamps = new Map();
|
|
45
|
+
const sourceEnv = options.env ?? process.env, configRoot = target.runtime === 'claude-code' ? sourceEnv.CLAUDE_CONFIG_DIR : sourceEnv.CODEX_HOME;
|
|
46
|
+
const skip = (reason) => skipped.set(reason, (skipped.get(reason) ?? 0) + 1);
|
|
47
|
+
for (const { file, stats } of await inOrder(await sessionFiles(options.home ?? homedir(), target.runtime, configRoot), target.runtime)) {
|
|
48
|
+
if (stats.size > MAX_SESSION_BYTES) {
|
|
49
|
+
skip('Source session project could not be checked: file exceeds the metadata limit.');
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Stop once a complete metadata record names its project. An opening prompt may itself be over 128 KiB;
|
|
53
|
+
// the probe is bounded by the same byte limit as a remotely importable session, without scanning its secrets.
|
|
54
|
+
const header = await remoteHistoryMetadata(file, target.runtime).catch(() => undefined);
|
|
55
|
+
if (!header) {
|
|
56
|
+
skip('Source session project could not be checked: unreadable metadata or metadata size limit exceeded.');
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if ((await realpath(header.cwd).catch(() => header.cwd)) !== project)
|
|
60
|
+
continue;
|
|
61
|
+
// Metadata identifies the project without parsing a transcript that cannot fit in any export page.
|
|
62
|
+
if (stats.size > REMOTE_HISTORY_SOURCE_BYTES) {
|
|
63
|
+
skip('Source session file exceeds the remote import size limit.');
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (header.child) {
|
|
67
|
+
skip('Subagent history is not a separate session.');
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (now - stats.mtimeMs < LIVE_MS) {
|
|
71
|
+
skip('Still being written or modified within ten minutes.');
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
selected.push({ source: target.runtime, id: header.id, file });
|
|
75
|
+
stamps.set(file, remoteHistoryStamp(stats));
|
|
76
|
+
}
|
|
77
|
+
const groups = byRun(selected).sort((a, b) => a[0].id.localeCompare(b[0].id));
|
|
78
|
+
const inventory = hash(JSON.stringify({ project, runtime: target.runtime, groups: groups.map(files => ({ id: files[0].id, files: files.map(file => ({ path: file.file, stamp: stamps.get(file.file) })).sort((a, b) => a.path.localeCompare(b.path)) })) }));
|
|
79
|
+
if ((cursor > 0 && options.inventory === undefined) || (options.inventory !== undefined && options.inventory !== inventory))
|
|
80
|
+
throw new Error('The selected history inventory changed or is missing. Restart the import from its preview; previously imported sessions are safe to retry.');
|
|
81
|
+
const report = () => [...skipped].map(([reason, count]) => ({ reason, count }));
|
|
82
|
+
if (options.preview)
|
|
83
|
+
return { sessions: [], skipped: report(), next_cursor: null, total: groups.length, inventory };
|
|
84
|
+
if (cursor > 0)
|
|
85
|
+
skipped.clear(); // enumeration skips are reported once; each page still reports its own skips
|
|
86
|
+
const sessions = [], cut = secretCut([process.env, options.env ?? {}], SECRET_NAMES);
|
|
87
|
+
cut.add(options.own ?? []);
|
|
88
|
+
let bytes = 0, index = cursor;
|
|
89
|
+
for (; index < groups.length && sessions.length < 20; index++) {
|
|
90
|
+
const parts = [], seen = new Set();
|
|
91
|
+
let changed = false, child = false;
|
|
92
|
+
for (const listed of groups[index]) {
|
|
93
|
+
const before = await stat(listed.file).catch(() => undefined);
|
|
94
|
+
const approvedStamp = stamps.get(listed.file);
|
|
95
|
+
if (!before || remoteHistoryStamp(before) !== approvedStamp || now - before.mtimeMs < LIVE_MS || before.size > REMOTE_HISTORY_SOURCE_BYTES) {
|
|
96
|
+
changed = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
const part = await readSession(listed.file, target.runtime, { seen }).catch(() => undefined), after = await stat(listed.file).catch(() => undefined);
|
|
100
|
+
if (!part || !after || remoteHistoryStamp(after) !== approvedStamp || !part.cwd || (await realpath(part.cwd).catch(() => part.cwd)) !== project || part.id !== listed.id) {
|
|
101
|
+
changed = true;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
// Opening metadata is only a candidate: a later record can identify a child session.
|
|
105
|
+
// The full parser remains authoritative before any transcript can leave the machine.
|
|
106
|
+
if (part.child) {
|
|
107
|
+
child = true;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
parts.push(part);
|
|
111
|
+
}
|
|
112
|
+
if (child) {
|
|
113
|
+
skip('Subagent history is not a separate session.');
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (changed || !parts.length) {
|
|
117
|
+
skip('Source session changed during export or became unreadable.');
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const session = merged(parts);
|
|
121
|
+
if (!session.startedAt || !session.endedAt || Date.parse(session.endedAt) > now - LIVE_MS) {
|
|
122
|
+
skip('Session has no stable historical completion time.');
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (session.turns.length > 2000) {
|
|
126
|
+
skip('Session exceeds 2000 turns; it was not truncated.');
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
cut.add(await keysInSessions(parts));
|
|
130
|
+
// Include current and older connector/enrollment credentials, even when no longer present in the environment.
|
|
131
|
+
cut.add(JSON.stringify(parts).match(/ar_(?:connector|enroll|local)_[A-Za-z0-9_-]{20,}/g) ?? []);
|
|
132
|
+
const packet = JSON.parse(JSON.stringify(cut.json({ source: session.source, id: session.id, startedAt: session.startedAt, endedAt: session.endedAt, state: session.state, model: session.model, costUsd: session.costUsd, firstPrompt: session.firstPrompt, activeMs: session.activeMs, turns: session.turns })));
|
|
133
|
+
if (packet.id !== session.id)
|
|
134
|
+
packet.id = redactedId(session.id);
|
|
135
|
+
const size = Buffer.byteLength(JSON.stringify(packet));
|
|
136
|
+
if (size > 1_000_000) {
|
|
137
|
+
skip('Session exceeds 1 MB after redaction; it was not truncated.');
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
(await import('./native/history.js')).remoteHistorySessions({ sessions: [packet] }, target.runtime, now);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
skip('Session contains unsupported or excessive fields; it was not truncated.');
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (bytes + size > 1_800_000)
|
|
148
|
+
break;
|
|
149
|
+
sessions.push(packet);
|
|
150
|
+
bytes += size;
|
|
151
|
+
}
|
|
152
|
+
return { sessions, skipped: report(), next_cursor: index < groups.length ? index : null, total: groups.length, inventory };
|
|
153
|
+
}
|
|
154
|
+
const REMOTE_HISTORY_SOURCE_BYTES = 8_000_000;
|
|
155
|
+
/** Candidate identity only, matching readSession's source metadata fields. Stop once both id and project are known;
|
|
156
|
+
* do not parse every transcript on every page. The requested page still fully parses and checks each candidate's
|
|
157
|
+
* id, project and child status under its approved file stamp. Preview counts candidates, not guaranteed exports.
|
|
158
|
+
* Keep at most one bounded JSONL record and never read past the remote source limit, even if a file grows. */
|
|
159
|
+
async function remoteHistoryMetadata(file, source) {
|
|
160
|
+
const handle = await open(file, 'r');
|
|
161
|
+
let id, cwd, child = false;
|
|
162
|
+
const str = (value) => typeof value === 'string' && value !== '' ? value : undefined;
|
|
163
|
+
const metadataOf = (parts) => {
|
|
164
|
+
try {
|
|
165
|
+
const row = JSON.parse(Buffer.concat(parts).toString('utf8'));
|
|
166
|
+
if (!row || typeof row !== 'object' || Array.isArray(row))
|
|
167
|
+
return;
|
|
168
|
+
if (source === 'claude-code') {
|
|
169
|
+
id ??= str(row.sessionId);
|
|
170
|
+
cwd ??= str(row.cwd);
|
|
171
|
+
child ||= row.isSidechain === true;
|
|
172
|
+
}
|
|
173
|
+
else if (row.type === 'session_meta') {
|
|
174
|
+
const payload = row.payload;
|
|
175
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload))
|
|
176
|
+
return;
|
|
177
|
+
id = str(payload.id) ?? id;
|
|
178
|
+
cwd = str(payload.cwd) ?? cwd;
|
|
179
|
+
child ||= !!str(payload.parent_thread_id) || !!(payload.source && typeof payload.source === 'object' && payload.source.subagent && typeof payload.source.subagent === 'object');
|
|
180
|
+
}
|
|
181
|
+
else if (row.type === 'turn_context')
|
|
182
|
+
cwd ??= str(row.payload?.cwd);
|
|
183
|
+
}
|
|
184
|
+
catch { /* An unreadable record supplies no identity, as in readSession. */ }
|
|
185
|
+
};
|
|
186
|
+
const metadata = () => id && cwd ? { id, cwd, child } : undefined;
|
|
187
|
+
let position = 0, parts = [];
|
|
188
|
+
try {
|
|
189
|
+
while (position < REMOTE_HISTORY_SOURCE_BYTES) {
|
|
190
|
+
const bytes = Buffer.alloc(Math.min(64 * 1024, REMOTE_HISTORY_SOURCE_BYTES - position));
|
|
191
|
+
const { bytesRead } = await handle.read(bytes, 0, bytes.length, position);
|
|
192
|
+
if (!bytesRead) {
|
|
193
|
+
metadataOf(parts);
|
|
194
|
+
// readSession uses the file name only when no source record supplied an id. That is known only at EOF.
|
|
195
|
+
id ??= basename(file, '.jsonl');
|
|
196
|
+
return metadata();
|
|
197
|
+
}
|
|
198
|
+
position += bytesRead;
|
|
199
|
+
let start = 0;
|
|
200
|
+
for (let end = bytes.indexOf(10); end >= 0 && end < bytesRead; end = bytes.indexOf(10, start)) {
|
|
201
|
+
parts.push(bytes.subarray(start, end));
|
|
202
|
+
metadataOf(parts);
|
|
203
|
+
const found = metadata();
|
|
204
|
+
if (found)
|
|
205
|
+
return found;
|
|
206
|
+
parts = [];
|
|
207
|
+
start = end + 1;
|
|
208
|
+
}
|
|
209
|
+
if (start < bytesRead)
|
|
210
|
+
parts.push(bytes.subarray(start, bytesRead));
|
|
211
|
+
}
|
|
212
|
+
return undefined; // Do not parse a record cut short by the byte limit.
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
await handle.close();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
35
218
|
/** In the data directory while an import the owner asked for at setup has not ended: the server's next start goes on with it. */
|
|
36
219
|
export const IMPORT_ASKED = ".import-at-setup";
|
|
37
220
|
/** A session file written to this recently may still be running: it is left for a later import. */
|
|
@@ -56,6 +239,8 @@ const hash = (text) => createHash("sha256").update(text).digest("hex");
|
|
|
56
239
|
const redactedId = (id) => `redacted-${hash(id).slice(0, 16)}`;
|
|
57
240
|
/** A file's size and time, as an import read it: the same after means the same content was read. */
|
|
58
241
|
const stampOf = (stats) => `${stats.size}:${stats.mtimeMs}`;
|
|
242
|
+
/** Bind remote consent to the enumerated source, including archive replacements that preserve size and mtime. */
|
|
243
|
+
const remoteHistoryStamp = (stats) => `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeMs}:${stats.ctimeMs}`;
|
|
59
244
|
const keptId = (envs, own = []) => {
|
|
60
245
|
const { text, add } = secretCut(envs, SECRET_NAMES);
|
|
61
246
|
add(own);
|
package/dist/key-check.d.ts
CHANGED
|
@@ -17,9 +17,7 @@ export type CheckOutcome = KeyCheck | {
|
|
|
17
17
|
};
|
|
18
18
|
type Call = {
|
|
19
19
|
url: string;
|
|
20
|
-
method?: "POST";
|
|
21
20
|
headers: Record<string, string>;
|
|
22
|
-
body?: string;
|
|
23
21
|
};
|
|
24
22
|
/** Each provider's check, by key id (tool-keys.ts' TOOL_KEYS, and a model provider's key where the server keeps one),
|
|
25
23
|
* made with the key and the server's environment, at the base this server sends that provider's calls to. */
|
package/dist/key-check.js
CHANGED
|
@@ -19,10 +19,9 @@ const base = (set, fallback) => (set?.trim() || fallback).replace(/\/+$/, "");
|
|
|
19
19
|
/** Each provider's check, by key id (tool-keys.ts' TOOL_KEYS, and a model provider's key where the server keeps one),
|
|
20
20
|
* made with the key and the server's environment, at the base this server sends that provider's calls to. */
|
|
21
21
|
export const KEY_CHECKS = {
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
monid: (key) => ({ url: `${MONID_API}/v1/discover`, method: "POST", headers: { authorization: `Bearer ${key}`, "content-type": "application/json" }, body: JSON.stringify({ query: "company data", limit: 1 }) }),
|
|
22
|
+
// One endpoint of monid's listing, the read a save pins grants from (monid.ts pinMonid): monid prices running an
|
|
23
|
+
// endpoint, never its listing (https://docs.monid.ai/guide/pricing.html).
|
|
24
|
+
monid: (key) => ({ url: `${MONID_API}/v1/endpoints?limit=1`, headers: { authorization: `Bearer ${key}` } }),
|
|
26
25
|
// A list of the key's monitors: Parallel prices searches, extracts, decisions, task runs and a monitor's executions,
|
|
27
26
|
// never a list (https://docs.parallel.ai/api-reference/monitor/list-monitors, https://docs.parallel.ai/getting-started/pricing).
|
|
28
27
|
parallel: (key) => ({ url: "https://api.parallel.ai/v1/monitors?limit=1", headers: { "x-api-key": key } }),
|
package/dist/key-refusal.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export declare function runKeyOf(env: NodeJS.ProcessEnv, harness?: string, ref?:
|
|
|
15
15
|
* Only the head serve can show is read: SHOWN characters, plus room for the longest held value in its widest encoded
|
|
16
16
|
* form (6 times it, for JSON's \uXXXX; percent is 3, hex 2, base64 4/3) and 16 more. A key whose start the cut can show
|
|
17
17
|
* starts before SHOWN, so it ends inside that head and is found whole; one that starts later is never shown. So a long
|
|
18
|
-
* error costs no more to redact than a short one, whatever it holds.
|
|
19
|
-
|
|
18
|
+
* error costs no more to redact than a short one, whatever it holds. `shown`: a head of another length, for a reader
|
|
19
|
+
* that is shown more (a template eval's grader reads a call's result to CALL_RESULT_CHARS). */
|
|
20
|
+
export declare function redacted(text: string, secrets: readonly string[], shown?: number): string;
|
|
20
21
|
/** How many texts redactedAnswer has read in this process: a test reads it to see a run's view served from what an
|
|
21
22
|
* earlier view redacted (runs.ts servedOnce). */
|
|
22
23
|
export declare const answerPasses: {
|
|
@@ -30,6 +31,11 @@ export declare const answerPasses: {
|
|
|
30
31
|
* by whitespace across a cut, or a form only found across pieces, still shows to one valueMatcher pass over the joined
|
|
31
32
|
* output, and then the whole answer is "[redacted]", as redactSecrets does with a text that still holds a value. */
|
|
32
33
|
export declare function redactedAnswer(text: string, secrets: readonly string[]): string;
|
|
34
|
+
/** Whether a number shows a held value. A held value can be all digits (a gateway's key), and a record or a call's
|
|
35
|
+
* arguments can quote it as a number: one whose digits hold a held value, by the same rule as a string's, is held. A
|
|
36
|
+
* number can also EQUAL a held value whose text differs from its own (a leading zero, 1e21, a long key read lossy). A
|
|
37
|
+
* boolean's text is shorter than any held value. */
|
|
38
|
+
export declare function heldNumber(value: number | bigint, secrets: readonly string[]): boolean;
|
|
33
39
|
/** `value`, a run's workflow output, with redactedAnswer applied to each string and number in it, property NAMES
|
|
34
40
|
* included (a dictionary field can be keyed by anything a run wrote), its shape kept. Two names of one object that come
|
|
35
41
|
* out the same would merge one value over the other: that object is withheld whole, as "[redacted]". */
|