@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +231 -0
- package/README.md +580 -320
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +10 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +26 -89
- package/dist/learn/check.js +58 -336
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +30 -2
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +58 -9
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +119 -83
- package/dist/server.js +1121 -419
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +41 -21
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -9
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -33
- package/dist/learning-evals.js +0 -98
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/dist/model.js
CHANGED
|
@@ -8,22 +8,25 @@
|
|
|
8
8
|
import { isRouter, withLocalModels } from "./local-models.js";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
import { DEFAULT_HARNESS, PLAN_HARNESSES } from "./harness.js";
|
|
11
|
-
import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
|
|
12
|
-
import { gatewayBase } from "./provider.js";
|
|
11
|
+
import { builtinHarness, HARNESS_MODULES_ENV, HARNESS_TABLE_ENV, harnessIds, harnessOf } from "./harness-table.js";
|
|
12
|
+
import { gatewayBase, modelGatewayBase } from "./provider.js";
|
|
13
13
|
import { modelFormWhy } from "./model-form.js";
|
|
14
14
|
// Leaves, which the key rows below read as this module loads, in any import order (wires.ts, adapter-facts.ts).
|
|
15
|
-
import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
15
|
+
import { ADAPTER_FACTS, adapterFactsOf } from "./adapter-facts.js";
|
|
16
16
|
import { WIRES } from "./wires.js";
|
|
17
17
|
import { authContextOf } from "./secrets.js";
|
|
18
18
|
import { EXPIRED, PLAN_DEFAULT_MODEL, PLAN_ORIGIN, PLAN_PROVIDER, planOf, signedIn, SIGNED_OUT } from "./chatgpt-plan.js";
|
|
19
|
+
import { LOGIN_DEFAULT_MODEL, onClaudeLogin } from "./claude-login.js";
|
|
19
20
|
/** The child's environment names the faux module by absolute path. */
|
|
20
21
|
export const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
|
|
21
22
|
/** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
|
|
22
|
-
* (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name
|
|
23
|
+
* (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
|
|
24
|
+
* (HARNESS_MODULES_ENV). */
|
|
23
25
|
export const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
|
|
24
|
-
/** `env` without a test hook's name: serve sets those from startServe's options
|
|
25
|
-
* environment holds (an operator's export, a leftover) never gives its runs fake
|
|
26
|
-
|
|
26
|
+
/** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
|
|
27
|
+
* alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
|
|
28
|
+
* answers or loads a module. */
|
|
29
|
+
export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV && name !== HARNESS_MODULES_ENV));
|
|
27
30
|
/** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
|
|
28
31
|
* tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
|
|
29
32
|
* request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
|
|
@@ -57,16 +60,28 @@ export const MODEL_NODES = ["agent", "decide", "extract", "report"];
|
|
|
57
60
|
export const MODEL_KEYS = Object.freeze([
|
|
58
61
|
{ id: "anthropic", label: "Anthropic", field: "ANTHROPIC_API_KEY", model: "anthropic/claude-sonnet-5-5", harnesses: onVendor("anthropic") },
|
|
59
62
|
{ id: "openai", label: "OpenAI", field: "OPENAI_API_KEY", model: "openai/gpt-6.1-sol", harnesses: onVendor("openai") },
|
|
63
|
+
// Particle's direct API is Chat Completions; the adapter harnesses need Messages or HTTP Responses.
|
|
64
|
+
{ id: "particle", label: "Particle", field: "PARTICLE_API_KEY", model: "particle/particle-1", harnesses: [DEFAULT_HARNESS] },
|
|
60
65
|
// OpenRouter serves both wires: every harness runs on its key, an adapter harness on its wire's vendor's model there.
|
|
61
66
|
{ id: "openrouter", label: "OpenRouter", field: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-6.1-sol", harnesses: [DEFAULT_HARNESS, ...ADAPTER_FACTS.map((facts) => facts.id)], byVendor: { anthropic: "anthropic/claude-sonnet-5.5", openai: "openai/gpt-6.1-sol" } },
|
|
62
67
|
]);
|
|
63
|
-
/** pi, and the adapter harnesses whose wire (their facts') runs `vendor`'s models: those that talk to its own API. */
|
|
68
|
+
/** pi, and the built-in adapter harnesses whose wire (their facts') runs `vendor`'s models: those that talk to its own API. */
|
|
64
69
|
function onVendor(vendor) {
|
|
65
70
|
return [DEFAULT_HARNESS, ...ADAPTER_FACTS.filter((facts) => WIRES[facts.wire].vendor === vendor).map((facts) => facts.id)];
|
|
66
71
|
}
|
|
72
|
+
/** The harnesses `row`'s key runs on `env`'s server: its own (`harnesses`), then each harness this server lists only once its
|
|
73
|
+
* owner installs it (Goose: harness-table.ts hidden, listed by harnessIds) whose wire runs the row's vendor's models, or
|
|
74
|
+
* any, on OpenRouter's. One not installed here is never named. */
|
|
75
|
+
export function keyHarnesses(row, env) {
|
|
76
|
+
const installed = harnessIds(env).filter((id) => !row.harnesses.includes(id) && builtinHarness(id)?.hidden !== undefined);
|
|
77
|
+
return [...row.harnesses, ...installed.filter((id) => {
|
|
78
|
+
const facts = adapterFactsOf(id);
|
|
79
|
+
return facts !== undefined && (row.id === "openrouter" || WIRES[facts.wire].vendor === row.id);
|
|
80
|
+
})];
|
|
81
|
+
}
|
|
67
82
|
/** `row`'s default for `harness`: the one for its wire's vendor (`byVendor`, OpenRouter's), else the row's. */
|
|
68
83
|
const rowModel = (row, harness) => {
|
|
69
|
-
const facts =
|
|
84
|
+
const facts = adapterFactsOf(harness);
|
|
70
85
|
return (facts && row.byVendor?.[WIRES[facts.wire].vendor]) ?? row.model;
|
|
71
86
|
};
|
|
72
87
|
/** What a person does when no model runs here: add a model provider's key in the console, or set one where AgentRun
|
|
@@ -110,7 +125,10 @@ export function hostModel(env, tier = "default", harness = DEFAULT_HARNESS) {
|
|
|
110
125
|
// Signed in to a ChatGPT plan, codex and pi run on it by default: a key's model is then named (`openai/<id>`).
|
|
111
126
|
if (PLAN_HARNESSES.includes(harness) && signedIn(env) && !env.AGENT_MODEL_BASE_URL)
|
|
112
127
|
return `${PLAN_PROVIDER}/${planModel(env)}`;
|
|
113
|
-
|
|
128
|
+
// On Claude Code's login on this machine, claude-agent runs Anthropic's model on it by default (provider.ts).
|
|
129
|
+
if (onClaudeLogin(env, harness))
|
|
130
|
+
return LOGIN_DEFAULT_MODEL;
|
|
131
|
+
const row = MODEL_KEYS.find((row) => env[row.field] && (row.harnesses.includes(harness) || keyHarnesses(row, env).includes(harness)));
|
|
114
132
|
return row ? rowModel(row, harness) : env[DEFAULT_MODEL_ENV] || undefined;
|
|
115
133
|
}
|
|
116
134
|
/** The plan's model a run that names none takes: GPT-6.1 Sol where the plan lists it, else the plan's first. */
|
|
@@ -194,7 +212,7 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
|
|
|
194
212
|
// A gateway its key may not go to (the one base rule, gatewayBase) runs no model, in its words: capabilities read it
|
|
195
213
|
// not ready, a save warns, and a run is refused before its process starts, so the key is never handed to one.
|
|
196
214
|
try {
|
|
197
|
-
|
|
215
|
+
modelGatewayBase(env.AGENT_MODEL_BASE_URL);
|
|
198
216
|
}
|
|
199
217
|
catch (error) {
|
|
200
218
|
return { why: error.message, host: true, needs: "key" };
|
|
@@ -255,7 +273,7 @@ async function pinnedChoice(env, { pinned, ref }, tier, harness) {
|
|
|
255
273
|
return { why: "This run started on the model gateway, and AGENT_MODEL_BASE_URL names none here.", host: true, needs: "key" };
|
|
256
274
|
// The one base rule (gatewayBase) holds for a pinned run as for any: its key never goes to a gateway it may not.
|
|
257
275
|
try {
|
|
258
|
-
|
|
276
|
+
modelGatewayBase(env.AGENT_MODEL_BASE_URL);
|
|
259
277
|
}
|
|
260
278
|
catch (error) {
|
|
261
279
|
return { why: error.message, host: true, needs: "key" };
|
|
@@ -299,6 +317,7 @@ export const PROVIDER_KEYS = {
|
|
|
299
317
|
opencode: ["OPENCODE_API_KEY"],
|
|
300
318
|
"opencode-go": ["OPENCODE_API_KEY"],
|
|
301
319
|
openrouter: ["OPENROUTER_API_KEY"],
|
|
320
|
+
particle: ["PARTICLE_API_KEY"],
|
|
302
321
|
"qwen-token-plan": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
303
322
|
"qwen-token-plan-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
|
|
304
323
|
"qwen-token-plan-individual": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
@@ -435,7 +454,7 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
435
454
|
// One base rule for every harness (provider.ts' gatewayBase): one trailing /v1 off, then the API under <base>/v1, so
|
|
436
455
|
// <gw>/api and <gw>/api/v1 both reach <gw>/api/v1/responses and <gw>/api/v1/messages, as OpenRouter serves them. pi-ai's
|
|
437
456
|
// Responses client takes the base with its /v1, its Messages client adds /v1/messages itself.
|
|
438
|
-
const base =
|
|
457
|
+
const base = modelGatewayBase(env.AGENT_MODEL_BASE_URL);
|
|
439
458
|
const baseUrl = `${base}/v1`;
|
|
440
459
|
const [{ openAIResponsesApi }, { anthropicMessagesApi }] = await Promise.all([import("@earendil-works/pi-ai/api/openai-responses.lazy"), import("@earendil-works/pi-ai/api/anthropic-messages.lazy")]);
|
|
441
460
|
const catalog = await catalogPrices();
|
|
@@ -454,7 +473,8 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
454
473
|
// the provider's client per wire, which pi-ai picks by the model's `api`.
|
|
455
474
|
const gatewayModels = ids.map((id) => {
|
|
456
475
|
const cost = priceOf(id);
|
|
457
|
-
// The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none
|
|
476
|
+
// The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none,
|
|
477
|
+
// and so does a model the catalog does not list.
|
|
458
478
|
const thinking = catalogThinking(catalog, id, namedOf.get(id));
|
|
459
479
|
const shared = { id, name: id, provider: MODEL_PROVIDER, reasoning: true, input: ["text", "image"], cost, contextWindow: 128_000, maxTokens: 32_000, ...(thinking ? { thinkingLevelMap: thinking } : {}) };
|
|
460
480
|
return wireOf(id) === "anthropic-messages" ? { ...shared, api: "anthropic-messages", baseUrl: base } : { ...shared, api: "openai-responses", baseUrl, compat: { supportsDeveloperRole: false } };
|
|
@@ -712,12 +732,17 @@ export async function catalogPrices() {
|
|
|
712
732
|
* version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
|
|
713
733
|
* agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
|
|
714
734
|
* pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
|
|
715
|
-
* effort, as its catalog entries say (off: null), not the "none" it refuses.
|
|
735
|
+
* effort, as its catalog entries say (off: null), not the "none" it refuses. A model the catalog does not list (a local
|
|
736
|
+
* model, a gateway's own alias) is never asked to stop reasoning either (off: null): pi then thinks at its lowest level,
|
|
737
|
+
* so a model that reasons anyway has its reasoning split out of the answer, never written into it. */
|
|
716
738
|
export function catalogThinking(catalog, id, named) {
|
|
717
739
|
const segments = id.split("/");
|
|
718
740
|
const own = segments.at(-1);
|
|
719
741
|
const vendor = segments.length > 1 ? segments.at(-2) : named;
|
|
720
|
-
const
|
|
742
|
+
const listed = [own, ...flippedForms(own)].flatMap((form) => catalog.get(form) ?? []);
|
|
743
|
+
if (!listed.length)
|
|
744
|
+
return { off: null };
|
|
745
|
+
const saying = listed.flatMap((entry) => (entry.thinkingLevelMap ? [{ provider: entry.provider, map: entry.thinkingLevelMap }] : []));
|
|
721
746
|
const vendors = saying.find((entry) => entry.provider === vendor);
|
|
722
747
|
if (vendors)
|
|
723
748
|
return vendors.map;
|
package/dist/native/binding.js
CHANGED
|
@@ -49,7 +49,7 @@ export function nativeBindingOf(value) {
|
|
|
49
49
|
if (!b || typeof b !== 'object' || !['claude-code', 'codex'].includes(b.runtime) || typeof b.project !== 'string' || !isAbsolute(b.project) || b.project.includes('\0') || typeof b.machine_id !== 'string' || !b.machine_id || !b.selector || !['project', 'agent', 'profile'].includes(b.selector.kind) || (b.selector.kind !== 'project' && (typeof b.selector.name !== 'string' || !/^[\w.@+-]{1,160}$/.test(b.selector.name))) || typeof b.connected !== 'boolean' || typeof b.fingerprint !== 'string' || !Array.isArray(b.configuration) || !Array.isArray(b.skills) || !Array.isArray(b.mcp_servers) || !Array.isArray(b.issues) || !b.capabilities)
|
|
50
50
|
throw new Error('Invalid native connection: connect the source project using /native/connect.');
|
|
51
51
|
// Keep the defined metadata only. Never persist arbitrary configuration, environment or credentials.
|
|
52
|
-
return { runtime: b.runtime, project: b.project, selector: { kind: b.selector.kind, ...(b.selector.name ? { name: b.selector.name } : {}) }, machine_id: b.machine_id, version: typeof b.version === 'string' ? b.version : null, model: typeof b.model === 'string' ? b.model : null, fingerprint: b.fingerprint, configuration: b.configuration.map(c => ({ path: c.path, sha256: c.sha256 })), skills: b.skills.filter(x => typeof x === 'string'), mcp_servers: b.mcp_servers.filter(x => typeof x === 'string'), state: b.state, issues: b.issues.filter(x => typeof x === 'string'), capabilities: { launch: !!b.capabilities.launch,
|
|
52
|
+
return { runtime: b.runtime, project: b.project, selector: { kind: b.selector.kind, ...(b.selector.name ? { name: b.selector.name } : {}) }, machine_id: b.machine_id, version: typeof b.version === 'string' ? b.version : null, model: typeof b.model === 'string' ? b.model : null, fingerprint: b.fingerprint, configuration: b.configuration.map(c => ({ path: c.path, sha256: c.sha256 })), skills: b.skills.filter(x => typeof x === 'string'), mcp_servers: b.mcp_servers.filter(x => typeof x === 'string'), state: b.state, issues: b.issues.filter(x => typeof x === 'string'), capabilities: { launch: !!b.capabilities.launch, learning: !!b.capabilities.learning, workflows: false, approval: b.capabilities.approval === 'native' ? 'native' : 'unavailable', usage: !!b.capabilities.usage }, connected: b.connected, ...(typeof b.verified_at === 'string' ? { verified_at: b.verified_at } : {}), ...(b.remote ? { remote: { connector_id: b.remote.connector_id, target_id: b.remote.target_id } } : {}) };
|
|
53
53
|
}
|
|
54
54
|
export function nativeOf(body) {
|
|
55
55
|
const value = body?.native;
|
|
@@ -73,7 +73,7 @@ export async function verifyConnection(store, entry, env = nativeEnvironment())
|
|
|
73
73
|
if (native.state === 'ready') {
|
|
74
74
|
const snapshot = await snapshotNativeInstructions(native);
|
|
75
75
|
if (snapshot.incomplete || snapshot.truncated) {
|
|
76
|
-
native.capabilities = { ...native.capabilities,
|
|
76
|
+
native.capabilities = { ...native.capabilities, learning: false };
|
|
77
77
|
native.issues.push(`Self-improvement is unavailable: ${snapshot.incomplete ?? 'the declared native instruction files exceed the 64 KiB grading evidence limit.'} Native jobs remain available; no incomplete policy is automatically graded.`);
|
|
78
78
|
}
|
|
79
79
|
}
|
package/dist/native/discovery.js
CHANGED
|
@@ -371,7 +371,7 @@ export async function discoverNative(options) {
|
|
|
371
371
|
const config = (NATIVE_RUNTIME_FACTS[runtime].protocol === "claude-json" ? [...configuration] : [...configuration].sort(([a], [b]) => a.localeCompare(b))).map(([path, sha256]) => ({ path, sha256 }));
|
|
372
372
|
for (const selected of selectors) {
|
|
373
373
|
const ownModel = policyUnresolved ? null : selected.model === "inherit" ? model : selected.model ?? model;
|
|
374
|
-
const target = { runtime, project, selector: selected.selector, machine_id, version, model: ownModel, fingerprint: hash(JSON.stringify([runtime, version, selected.selector, config, ...(policyUnresolved ? [NATIVE_CLAUDE_POLICY_UNRESOLVED] : []), ...(additionalPolicyUnresolved ? [NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED] : [])])), configuration: config, skills: [...skills].sort(), mcp_servers: [...mcp].sort(), state: needsAttention ? "needs_attention" : "needs_verification", issues: [...issues], capabilities: { launch: supported,
|
|
374
|
+
const target = { runtime, project, selector: selected.selector, machine_id, version, model: ownModel, fingerprint: hash(JSON.stringify([runtime, version, selected.selector, config, ...(policyUnresolved ? [NATIVE_CLAUDE_POLICY_UNRESOLVED] : []), ...(additionalPolicyUnresolved ? [NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED] : [])])), configuration: config, skills: [...skills].sort(), mcp_servers: [...mcp].sort(), state: needsAttention ? "needs_attention" : "needs_verification", issues: [...issues], capabilities: { launch: supported, learning: supported && !policyUnresolved && !additionalPolicyUnresolved, workflows: false, approval: "unavailable", usage: supported } };
|
|
375
375
|
targets.push(target);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { NativeBinding, NativeTarget } from "./types.js";
|
|
2
|
+
/** The most bytes (UTF-8) of a native or SDK run's standing instructions kept as its learning's evidence: a source policy
|
|
3
|
+
* past it is cut, and learning is skipped for the run. */
|
|
4
|
+
export declare const INSTRUCTION_EVIDENCE_BYTES = 65536;
|
|
2
5
|
export type NativeInstructionSnapshot = {
|
|
3
6
|
text: string;
|
|
4
7
|
files: {
|
|
@@ -2,8 +2,10 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { basename, dirname, sep } from "node:path";
|
|
4
4
|
import { parse as parseToml } from "smol-toml";
|
|
5
|
-
import { NATIVE_GRADE_INSTRUCTION_BYTES } from "../learn/grade.js";
|
|
6
5
|
import { NATIVE_RUNTIME_FACTS, NATIVE_CLAUDE_POLICY_UNRESOLVED, NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED } from './runtimes.js';
|
|
6
|
+
/** The most bytes (UTF-8) of a native or SDK run's standing instructions kept as its learning's evidence: a source policy
|
|
7
|
+
* past it is cut, and learning is skipped for the run. */
|
|
8
|
+
export const INSTRUCTION_EVIDENCE_BYTES = 65_536;
|
|
7
9
|
const depth = (path) => path.split(sep).length;
|
|
8
10
|
const scopeOf = (path) => basename(dirname(path)) === ".claude" ? dirname(dirname(path)) : dirname(path);
|
|
9
11
|
/** Read-only, bounded policy evidence for grading. This text is never installed as grader runtime instructions. */
|
|
@@ -107,10 +109,10 @@ export function withSavedNativeInstructions(snapshot, instructions, redact) {
|
|
|
107
109
|
}
|
|
108
110
|
function boundedSnapshot(text, files, truncated, incomplete) {
|
|
109
111
|
const bytes = Buffer.from(text, "utf8");
|
|
110
|
-
if (bytes.length <=
|
|
112
|
+
if (bytes.length <= INSTRUCTION_EVIDENCE_BYTES)
|
|
111
113
|
return { text, files, truncated, ...(incomplete ? { incomplete } : {}) };
|
|
112
114
|
const marker = "\n\n[Native instruction snapshot truncated: additional standing policy was omitted. Do not assume the excerpt is complete.]";
|
|
113
|
-
let end =
|
|
115
|
+
let end = INSTRUCTION_EVIDENCE_BYTES - Buffer.byteLength(marker, "utf8"), prefix = "";
|
|
114
116
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
115
117
|
// A prefix must end on a whole UTF8 codepoint, including when a policy uses non-ASCII text.
|
|
116
118
|
for (let trim = 0; trim < 4; trim++) {
|
|
@@ -5,13 +5,11 @@ import { createHash } from 'node:crypto';
|
|
|
5
5
|
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
6
6
|
import { tmpdir } from 'node:os';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import {
|
|
9
|
-
import { promisify, types } from 'node:util';
|
|
8
|
+
import { types } from 'node:util';
|
|
10
9
|
import { discoverNative, nativeIdentity, verifyNative } from './discovery.js';
|
|
11
10
|
import { nativeEnvironment } from './environment.js';
|
|
12
11
|
import { openNativeSession } from './runtime.js';
|
|
13
12
|
import { snapshotNativeInstructions } from './instructions.js';
|
|
14
|
-
import { nativeSkillContext } from './context.js';
|
|
15
13
|
import { exportRemoteHistory } from '../import.js';
|
|
16
14
|
import { runnerSecrets, secretRedactor } from '../runner/redact.js';
|
|
17
15
|
import { redactedOutput } from '../key-refusal.js';
|
|
@@ -156,19 +154,19 @@ export async function runRemoteWorkerBridge(options = {}) {
|
|
|
156
154
|
expireIdle(sessionKey);
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
|
-
if (type !== 'open'
|
|
157
|
+
if (type !== 'open')
|
|
160
158
|
throw new Error('Unsupported remote operation.');
|
|
161
159
|
const approved = await current(message.target), identity = nativeIdentity(approved);
|
|
162
|
-
const sessionKey =
|
|
160
|
+
const sessionKey = key(message.session_key);
|
|
163
161
|
if (sessions.has(sessionKey) || sessions.size >= 8)
|
|
164
162
|
throw new Error('The native session already exists or the source session limit was reached.');
|
|
165
163
|
signal.throwIfAborted();
|
|
166
|
-
if (
|
|
164
|
+
if ((typeof payload.expected_fingerprint !== 'string' || payload.expected_fingerprint !== approved.fingerprint))
|
|
167
165
|
throw new Error('The source configuration changed after preparation. Start a new run after reviewing it.');
|
|
168
166
|
const root = await mkdtemp(join(tmpdir(), 'agentrun-remote-'));
|
|
169
167
|
const locks = join(tmpdir(), `agentrun-native-locks-${process.getuid?.() ?? 'user'}`);
|
|
170
168
|
await mkdir(locks, { mode: 0o700, recursive: true });
|
|
171
|
-
const lock = join(locks, createHash('sha256').update(
|
|
169
|
+
const lock = join(locks, createHash('sha256').update(approved.project).digest('hex'));
|
|
172
170
|
try {
|
|
173
171
|
await mkdir(lock, { mode: 0o700 });
|
|
174
172
|
}
|
|
@@ -178,45 +176,13 @@ export async function runRemoteWorkerBridge(options = {}) {
|
|
|
178
176
|
}
|
|
179
177
|
let opened;
|
|
180
178
|
try {
|
|
181
|
-
|
|
182
|
-
if (type === 'grade') {
|
|
183
|
-
await promisify(execFile)('git', ['init', '--quiet', root], { timeout: 10_000 });
|
|
184
|
-
const report = await discoverNative({ project: root, runtime: approved.runtime, env });
|
|
185
|
-
target = { ...report.targets.find(item => item.selector.kind === 'project'), connected: true };
|
|
186
|
-
if (!target.runtime)
|
|
187
|
-
throw new Error('The native grading runtime is unavailable.');
|
|
188
|
-
context = '';
|
|
189
|
-
}
|
|
190
|
-
else if (payload.skills !== undefined) {
|
|
191
|
-
if (!Array.isArray(payload.skills) || payload.skills.length > 64)
|
|
192
|
-
throw new Error('Invalid learned skills.');
|
|
193
|
-
const skills = payload.skills.map(value => {
|
|
194
|
-
const skill = object(value), files = object(skill.files);
|
|
195
|
-
if (Object.keys(files).length > 128)
|
|
196
|
-
throw new Error('Too many learned skill resources.');
|
|
197
|
-
const read = {};
|
|
198
|
-
for (const [path, value] of Object.entries(files))
|
|
199
|
-
read[path] = text(value);
|
|
200
|
-
return { name: text(skill.name, 128), files: read };
|
|
201
|
-
});
|
|
202
|
-
if (Buffer.byteLength(JSON.stringify(skills)) > 2_000_000)
|
|
203
|
-
throw new Error('Learned skills exceed the source limit.');
|
|
204
|
-
context = [context, await nativeSkillContext(join(root, 'skills'), skills)].filter(Boolean).join('\n\n');
|
|
205
|
-
}
|
|
179
|
+
const context = payload.context === undefined ? '' : text(payload.context);
|
|
206
180
|
signal.throwIfAborted();
|
|
207
|
-
const session = opened = await openNativeSession({ target, context, env, signal, onEvent: event => { output({ event, session_key: sessionKey }); } });
|
|
181
|
+
const session = opened = await openNativeSession({ target: approved, context, env, signal, onEvent: event => { output({ event, session_key: sessionKey }); } });
|
|
208
182
|
signal.throwIfAborted();
|
|
209
183
|
sessions.set(sessionKey, { session, root, lock, identity });
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return {};
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
return await session.send(text(payload.prompt), { signal, reflection: true, timeoutMs: timeout(payload.timeout_ms) });
|
|
216
|
-
}
|
|
217
|
-
finally {
|
|
218
|
-
await close(sessionKey);
|
|
219
|
-
}
|
|
184
|
+
expireIdle(sessionKey);
|
|
185
|
+
return {};
|
|
220
186
|
}
|
|
221
187
|
catch (error) {
|
|
222
188
|
try {
|
package/dist/native/remote.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Store } from '../store/store.js';
|
|
|
3
3
|
import type { NativeBinding, NativeEvent, NativeResult, NativeSession } from './types.js';
|
|
4
4
|
import type { NativeInstructionSnapshot } from './instructions.js';
|
|
5
5
|
export declare const REMOTE_COMPLETION_BODY_BYTES = 4000000;
|
|
6
|
-
export type RemoteCommandType = 'prepare' | 'open' | 'send' | 'close'
|
|
6
|
+
export type RemoteCommandType = 'prepare' | 'open' | 'send' | 'close';
|
|
7
7
|
export declare class RemoteConnectors {
|
|
8
8
|
readonly store: Store;
|
|
9
9
|
readonly now: () => number;
|
|
@@ -31,12 +31,11 @@ export declare class RemoteConnectors {
|
|
|
31
31
|
history_only: boolean;
|
|
32
32
|
runtime: "codex" | "claude-code";
|
|
33
33
|
machine_id: string;
|
|
34
|
-
state: "
|
|
34
|
+
state: "ready" | "needs_verification" | "needs_attention";
|
|
35
35
|
issues: string[];
|
|
36
36
|
capabilities: {
|
|
37
37
|
launch: boolean;
|
|
38
|
-
|
|
39
|
-
skills: boolean;
|
|
38
|
+
learning: boolean;
|
|
40
39
|
workflows: false;
|
|
41
40
|
approval: "native" | "unavailable";
|
|
42
41
|
usage: boolean;
|
|
@@ -69,12 +68,11 @@ export declare class RemoteConnectors {
|
|
|
69
68
|
history_only: boolean;
|
|
70
69
|
runtime: "codex" | "claude-code";
|
|
71
70
|
machine_id: string;
|
|
72
|
-
state: "
|
|
71
|
+
state: "ready" | "needs_verification" | "needs_attention";
|
|
73
72
|
issues: string[];
|
|
74
73
|
capabilities: {
|
|
75
74
|
launch: boolean;
|
|
76
|
-
|
|
77
|
-
skills: boolean;
|
|
75
|
+
learning: boolean;
|
|
78
76
|
workflows: false;
|
|
79
77
|
approval: "native" | "unavailable";
|
|
80
78
|
usage: boolean;
|
|
@@ -105,12 +103,11 @@ export declare class RemoteConnectors {
|
|
|
105
103
|
history_only: boolean;
|
|
106
104
|
runtime: "codex" | "claude-code";
|
|
107
105
|
machine_id: string;
|
|
108
|
-
state: "
|
|
106
|
+
state: "ready" | "needs_verification" | "needs_attention";
|
|
109
107
|
issues: string[];
|
|
110
108
|
capabilities: {
|
|
111
109
|
launch: boolean;
|
|
112
|
-
|
|
113
|
-
skills: boolean;
|
|
110
|
+
learning: boolean;
|
|
114
111
|
workflows: false;
|
|
115
112
|
approval: "native" | "unavailable";
|
|
116
113
|
usage: boolean;
|
|
@@ -174,14 +171,10 @@ export declare function checkedPrepared(before: NativeBinding, result: unknown):
|
|
|
174
171
|
};
|
|
175
172
|
export declare function remoteResult(value: unknown): NativeResult;
|
|
176
173
|
export declare function verifyRemote(store: Store, entry: AgentEntry): Promise<AgentEntry>;
|
|
177
|
-
/** A session transport only. Task
|
|
174
|
+
/** A session transport only. Task and end-of-run policy remains in the native loop and source runtime. */
|
|
178
175
|
export declare function openRemoteSession(broker: RemoteConnectors, target: NativeBinding, options: {
|
|
179
176
|
signal?: AbortSignal;
|
|
180
177
|
context?: string;
|
|
181
|
-
skills?: readonly {
|
|
182
|
-
name: string;
|
|
183
|
-
files?: Record<string, string>;
|
|
184
|
-
}[];
|
|
185
178
|
runId: string;
|
|
186
179
|
onEvent?: (event: NativeEvent) => Promise<void> | void;
|
|
187
180
|
}): Promise<NativeSession>;
|
package/dist/native/remote.js
CHANGED
|
@@ -444,7 +444,7 @@ export function checkedPrepared(before, result) {
|
|
|
444
444
|
if (unchecked && !instructions.incomplete)
|
|
445
445
|
instructions = { ...instructions, incomplete: unchecked };
|
|
446
446
|
if (instructions.incomplete || instructions.truncated)
|
|
447
|
-
target = { ...target, capabilities: { ...target.capabilities,
|
|
447
|
+
target = { ...target, capabilities: { ...target.capabilities, learning: false }, issues: [...target.issues, `Self-improvement is unavailable: ${instructions.incomplete ?? 'the source instruction snapshot exceeds the grading evidence limit.'} Native jobs remain available; no incomplete policy is automatically graded.`] };
|
|
448
448
|
return { target, instructions };
|
|
449
449
|
}
|
|
450
450
|
function validUsage(value) {
|
|
@@ -478,10 +478,10 @@ export async function verifyRemote(store, entry) {
|
|
|
478
478
|
const prepared = checkedPrepared(binding, await new RemoteConnectors(store).request(binding, 'prepare', {}, { timeoutMs: 30_000 }));
|
|
479
479
|
return updateNative(store, entry, { ...prepared.target, connected: binding.connected });
|
|
480
480
|
}
|
|
481
|
-
/** A session transport only. Task
|
|
481
|
+
/** A session transport only. Task and end-of-run policy remains in the native loop and source runtime. */
|
|
482
482
|
export async function openRemoteSession(broker, target, options) {
|
|
483
483
|
const sessionKey = opaque('session');
|
|
484
|
-
await broker.request(target, 'open', { context: options.context ?? '',
|
|
484
|
+
await broker.request(target, 'open', { context: options.context ?? '', run_id: options.runId, expected_fingerprint: target.fingerprint }, { signal: options.signal, sessionKey, timeoutMs: 30_000 });
|
|
485
485
|
return {
|
|
486
486
|
send: async (prompt, sendOptions = {}) => remoteResult(await broker.request(target, 'send', { prompt, reflection: sendOptions.reflection ?? false, timeout_ms: sendOptions.timeoutMs ?? 180_000 }, { signal: sendOptions.signal ?? options.signal, sessionKey, timeoutMs: (sendOptions.timeoutMs ?? 180_000) + 5000, onEvent: options.onEvent })),
|
|
487
487
|
close: async () => { try {
|
package/dist/native/schema.js
CHANGED
|
@@ -4,7 +4,7 @@ const strings = { type: 'array', items: text };
|
|
|
4
4
|
const object = (properties, required = Object.keys(properties)) => ({ type: 'object', additionalProperties: false, properties, required });
|
|
5
5
|
export const NATIVE_SELECTOR = object({ kind: { enum: ['project', 'agent', 'profile'] }, name: text }, ['kind']);
|
|
6
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' },
|
|
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' }, learning: { type: 'boolean' }, workflows: { const: false }, approval: { enum: ['native', 'unavailable'] }, usage: { type: 'boolean' } }) });
|
|
8
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
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
10
|
const response = (schema) => ({ description: 'Native connection on the source machine.', content: { 'application/json': { schema } } });
|
package/dist/native/types.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ export type NativeTarget = {
|
|
|
23
23
|
issues: string[];
|
|
24
24
|
capabilities: {
|
|
25
25
|
launch: boolean;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
/** Whether its runs may learn: its owner's corrections reach it and its runs compile (no unresolved policy). */
|
|
27
|
+
learning: boolean;
|
|
28
28
|
workflows: false;
|
|
29
29
|
approval: "native" | "unavailable";
|
|
30
30
|
usage: boolean;
|