@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type IncomingMessage, type Server, type ServerResponse } from "node:http";
|
|
2
|
+
import type { Duplex } from "node:stream";
|
|
3
|
+
/** The port a server takes when none is named: the first free one from here (cli.ts). */
|
|
4
|
+
export declare const DEFAULT_PORT = 7340;
|
|
5
|
+
/** The address a server listens on when none is named: this machine only. */
|
|
6
|
+
export declare const DEFAULT_HOST = "127.0.0.1";
|
|
7
|
+
/** The free disk under the data directory below which GET /v2/health fails, in MiB, unless AGENTRUN_MIN_FREE_MB says. */
|
|
8
|
+
export declare const MIN_FREE_MIB = 64;
|
|
9
|
+
/** How long a warming answer asks its caller to wait before it asks again (Retry-After), and the page's reload. */
|
|
10
|
+
export declare const WARMING_RETRY_S = 2;
|
|
11
|
+
/** AGENTRUN_MIN_FREE_MB as MiB (MIN_FREE_MIB when unset), or undefined when it is no number of MiB, 0 or more. */
|
|
12
|
+
export declare function minFreeMibOf(env: NodeJS.ProcessEnv): number | undefined;
|
|
13
|
+
/** `server` listening on `host`, from port `first`; with `nextFreePort`, a taken port passes to the next, up to 99 past
|
|
14
|
+
* `first`. Each attempt takes off both its handlers when it ends, so a taken port leaves no listener behind. */
|
|
15
|
+
export declare function listenOn(server: Server, host: string, first: number, nextFreePort: boolean): Promise<void>;
|
|
16
|
+
/** The URL a listening `server` on `host` is reached at on this machine: an address of every interface at its loopback one. */
|
|
17
|
+
export declare function urlOf(server: Server, host: string): string;
|
|
18
|
+
/** A server bound on `host` at `port`, answering warming (above) until `takeOver`. Undefined when that port is taken: the
|
|
19
|
+
* port is then left to the start's own listen, which waits for a server it replaces (a restart, a redeploy) to let go of
|
|
20
|
+
* the data directory first, and only then takes the port, or passes to the next free one, as it always has. Any other
|
|
21
|
+
* failure to listen throws. */
|
|
22
|
+
export declare function listenFirst(o: {
|
|
23
|
+
host: string;
|
|
24
|
+
port: number;
|
|
25
|
+
data: string;
|
|
26
|
+
env: NodeJS.ProcessEnv;
|
|
27
|
+
}): Promise<Server | undefined>;
|
|
28
|
+
/** The server's own handlers on `server` from now on, in place of the warming ones: a request already being answered
|
|
29
|
+
* finishes as it began. */
|
|
30
|
+
export declare function takeOver(server: Server, onRequest: (req: IncomingMessage, res: ServerResponse) => void, onUpgrade: (req: IncomingMessage, socket: Duplex, head: Buffer) => void): void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// The address first. The server's CLI binds its port here, before it loads the rest of the server: on a slow disk (a cold
|
|
2
|
+
// start, a loaded machine), loading the server's modules is most of a start, and the store, the harness probes and Docker
|
|
3
|
+
// come after it. Until the server takes this socket over (ServeOptions.listener), every request is answered here: the
|
|
4
|
+
// server is warming. GET /v2/health says so (503, status "warming", the store "opening"), the API answers 503
|
|
5
|
+
// `unavailable` with a Retry-After, and a browser gets a page that reloads itself. Only node's own modules load here.
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
import { statfs } from "node:fs/promises";
|
|
8
|
+
import { createServer } from "node:http";
|
|
9
|
+
/** The port a server takes when none is named: the first free one from here (cli.ts). */
|
|
10
|
+
export const DEFAULT_PORT = 7340;
|
|
11
|
+
/** The address a server listens on when none is named: this machine only. */
|
|
12
|
+
export const DEFAULT_HOST = "127.0.0.1";
|
|
13
|
+
/** The free disk under the data directory below which GET /v2/health fails, in MiB, unless AGENTRUN_MIN_FREE_MB says. */
|
|
14
|
+
export const MIN_FREE_MIB = 64;
|
|
15
|
+
/** How long a warming answer asks its caller to wait before it asks again (Retry-After), and the page's reload. */
|
|
16
|
+
export const WARMING_RETRY_S = 2;
|
|
17
|
+
/** AGENTRUN_MIN_FREE_MB as MiB (MIN_FREE_MIB when unset), or undefined when it is no number of MiB, 0 or more. */
|
|
18
|
+
export function minFreeMibOf(env) {
|
|
19
|
+
const mib = env.AGENTRUN_MIN_FREE_MB ? Number(env.AGENTRUN_MIN_FREE_MB) : MIN_FREE_MIB;
|
|
20
|
+
return Number.isFinite(mib) && mib >= 0 ? mib : undefined;
|
|
21
|
+
}
|
|
22
|
+
/** `server` listening on `host`, from port `first`; with `nextFreePort`, a taken port passes to the next, up to 99 past
|
|
23
|
+
* `first`. Each attempt takes off both its handlers when it ends, so a taken port leaves no listener behind. */
|
|
24
|
+
export async function listenOn(server, host, first, nextFreePort) {
|
|
25
|
+
const last = nextFreePort && first !== 0 ? Math.min(first + 99, 65_535) : first;
|
|
26
|
+
for (let port = first;; port++) {
|
|
27
|
+
try {
|
|
28
|
+
await new Promise((done, reject) => {
|
|
29
|
+
const onError = (error) => (server.off("listening", onListening), reject(error));
|
|
30
|
+
const onListening = () => (server.off("error", onError), done());
|
|
31
|
+
server.once("error", onError);
|
|
32
|
+
server.once("listening", onListening);
|
|
33
|
+
server.listen(port, host);
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code !== "EADDRINUSE")
|
|
39
|
+
throw error;
|
|
40
|
+
if (port < last)
|
|
41
|
+
continue;
|
|
42
|
+
throw last > first ? Object.assign(new Error(`every port from ${first} to ${last} on ${host} is taken`), { code: "EADDRINUSE" }) : error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** The URL a listening `server` on `host` is reached at on this machine: an address of every interface at its loopback one. */
|
|
47
|
+
export function urlOf(server, host) {
|
|
48
|
+
const shown = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host;
|
|
49
|
+
return `http://${shown.includes(":") ? `[${shown}]` : shown}:${server.address().port}`;
|
|
50
|
+
}
|
|
51
|
+
const PAGE = `<!doctype html>
|
|
52
|
+
<html lang="en"><head><meta charset="utf-8"><meta http-equiv="refresh" content="${WARMING_RETRY_S}"><meta name="color-scheme" content="light dark"><title>AgentRun is starting</title></head>
|
|
53
|
+
<body style="font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin: 3rem"><p>AgentRun is starting. This page reloads until it is ready.</p></body></html>
|
|
54
|
+
`;
|
|
55
|
+
/** The warming answer to one request: health, a browser's page, or the API's 503. Nothing in it is the server's: no
|
|
56
|
+
* token, no data, so it needs no Host check. */
|
|
57
|
+
function warming(data, minFreeBytes) {
|
|
58
|
+
return (req, res) => {
|
|
59
|
+
res.setHeader("x-request-id", `req_${randomBytes(8).toString("hex")}`);
|
|
60
|
+
res.setHeader("retry-after", String(WARMING_RETRY_S));
|
|
61
|
+
res.setHeader("cache-control", "no-store");
|
|
62
|
+
const path = (req.url ?? "/").split("?")[0];
|
|
63
|
+
const json = (body) => {
|
|
64
|
+
res.writeHead(503, { "content-type": "application/json" });
|
|
65
|
+
res.end(JSON.stringify(body));
|
|
66
|
+
};
|
|
67
|
+
req.resume();
|
|
68
|
+
if (path === "/v2/health") {
|
|
69
|
+
void statfs(data).then((fs) => fs.bavail * fs.bsize, () => undefined).then((free) => {
|
|
70
|
+
const disk = free === undefined || minFreeBytes === undefined ? "cannot_check" : free >= minFreeBytes ? "ok" : "below_floor";
|
|
71
|
+
json({ status: "warming", checks: { store: "opening", disk } });
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (req.method === "GET" && !path.startsWith("/v2/") && /\btext\/html\b/i.test(String(req.headers.accept ?? ""))) {
|
|
76
|
+
res.writeHead(503, { "content-type": "text/html; charset=utf-8" });
|
|
77
|
+
res.end(PAGE);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
json({ error: { code: "unavailable", message: `AgentRun is starting: its store is opening. Send the request again in ${WARMING_RETRY_S} s.`, retryable: true, request_id: res.getHeader("x-request-id") } });
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** A WebSocket asked for while warming: refused, to be asked again. */
|
|
84
|
+
function warmingUpgrade(_req, socket) {
|
|
85
|
+
socket.on("error", () => socket.destroy());
|
|
86
|
+
socket.end(`HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\nRetry-After: ${WARMING_RETRY_S}\r\nContent-Length: 0\r\n\r\n`);
|
|
87
|
+
}
|
|
88
|
+
/** A server bound on `host` at `port`, answering warming (above) until `takeOver`. Undefined when that port is taken: the
|
|
89
|
+
* port is then left to the start's own listen, which waits for a server it replaces (a restart, a redeploy) to let go of
|
|
90
|
+
* the data directory first, and only then takes the port, or passes to the next free one, as it always has. Any other
|
|
91
|
+
* failure to listen throws. */
|
|
92
|
+
export async function listenFirst(o) {
|
|
93
|
+
const mib = minFreeMibOf(o.env);
|
|
94
|
+
const server = createServer(warming(o.data, mib === undefined ? undefined : mib * 2 ** 20));
|
|
95
|
+
// A request's headers come within 10 s, as the server's own listener has them.
|
|
96
|
+
server.headersTimeout = 10_000;
|
|
97
|
+
server.on("upgrade", warmingUpgrade);
|
|
98
|
+
try {
|
|
99
|
+
await listenOn(server, o.host, o.port, false);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (error.code === "EADDRINUSE")
|
|
103
|
+
return undefined;
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
return server;
|
|
107
|
+
}
|
|
108
|
+
/** The server's own handlers on `server` from now on, in place of the warming ones: a request already being answered
|
|
109
|
+
* finishes as it began. */
|
|
110
|
+
export function takeOver(server, onRequest, onUpgrade) {
|
|
111
|
+
server.removeAllListeners("request");
|
|
112
|
+
server.removeAllListeners("upgrade");
|
|
113
|
+
server.on("request", onRequest);
|
|
114
|
+
server.on("upgrade", onUpgrade);
|
|
115
|
+
}
|
package/dist/live-reach.d.ts
CHANGED
|
@@ -33,5 +33,28 @@ export declare function runnerLiveOf(env: {
|
|
|
33
33
|
readonly AGENTRUN_RUNNER_LIVE_HOST?: string | undefined;
|
|
34
34
|
readonly AGENTRUN_RUNNER_LIVE_BIND?: string | undefined;
|
|
35
35
|
}, sealKey: Buffer): RunnerLive | undefined;
|
|
36
|
-
/**
|
|
37
|
-
export declare
|
|
36
|
+
/** The server's reach for run `runId`'s viewers: its hosts, under that run's key. */
|
|
37
|
+
export declare const reachForRun: (reach: LiveReach, runId: string) => LiveReach;
|
|
38
|
+
/** A runner's live address for run `runId`'s viewers: its host and bind, under that run's key. */
|
|
39
|
+
export declare const liveForRun: (live: RunnerLive, runId: string) => RunnerLive;
|
|
40
|
+
/** Whether `req` carries a good, fresh proof for viewer `viewerId` under `live`'s key: its time within `windowMs` of
|
|
41
|
+
* the endpoint's clock (LIVE_PROOF_MS by default). */
|
|
42
|
+
export declare function provenFor(req: Pick<IncomingMessage, "headers">, live: Pick<RunnerLive, "key">, viewerId: string, now?: number, windowMs?: number): boolean;
|
|
43
|
+
/** How far a relay's proof's time may be from the runner's clock: the one hop's time, and no more. */
|
|
44
|
+
export declare const RELAY_PROOF_MS = 10000;
|
|
45
|
+
/** What a relay's proof binds: the machine's token (its SHA-256), the runner its row names, and that runner's
|
|
46
|
+
* incarnation. A viewer's id has no newline, so no relay subject is ever a viewer's. */
|
|
47
|
+
export type RelayTo = {
|
|
48
|
+
readonly tokenSha256: string;
|
|
49
|
+
readonly runner: string;
|
|
50
|
+
readonly incarnation: string;
|
|
51
|
+
};
|
|
52
|
+
/** The server's proof for relaying the dial of token `to.tokenSha256` to runner `to.runner`, at `at` (ms). */
|
|
53
|
+
export declare const relayProof: (reach: Pick<LiveReach, "key">, to: RelayTo, at?: number) => string;
|
|
54
|
+
/** The proof's key, from the seal key, for a runner's attach listener (whatever host it answers on). */
|
|
55
|
+
export declare const relayKeyOf: (sealKey: Buffer) => Pick<LiveReach, "key">;
|
|
56
|
+
/** A runner's check of the relay's proofs: good, fresh (RELAY_PROOF_MS) and for `to`, and never one it took before, so
|
|
57
|
+
* a proof read off the hop opens no second socket. A proof is taken once by its MAC, not by the header as sent: the
|
|
58
|
+
* time reads as a number, so `0<ms>.<mac>` is the same signed proof as `<ms>.<mac>`, while the MAC (lower-case hex
|
|
59
|
+
* only) has one spelling for each subject and time. */
|
|
60
|
+
export declare function relayProofs(live: Pick<LiveReach, "key">, now?: () => number): (req: Pick<IncomingMessage, "headers">, to: RelayTo) => boolean;
|
package/dist/live-reach.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// host only when it is one of its runners' (AGENTRUN_RUNNER_HOSTS, a comma list), else the row reads as no viewer: a
|
|
5
5
|
// store writer that is no runner can't aim the server's socket elsewhere. Each request the server makes of a runner's
|
|
6
6
|
// viewer (the HEAD that asks whether it answers, and the proxied WebSocket) carries the proxy's proof: an HMAC of the
|
|
7
|
-
// viewer's id and the time, under
|
|
7
|
+
// viewer's id and the time, under the viewer's run's key (reachForRun, liveForRun), derived from a key derived from the
|
|
8
|
+
// seal key the server and its runners already share. A runner's
|
|
8
9
|
// endpoint off loopback takes no request without a good, fresh proof for its own viewer. The proof is not the viewer's:
|
|
9
10
|
// the hello's token still decides who watches. The hop is plain HTTP, for a private network (the server and its
|
|
10
11
|
// runners' own); TLS on it is a later step.
|
|
@@ -47,16 +48,57 @@ export function runnerLiveOf(env, sealKey) {
|
|
|
47
48
|
const bind = env.AGENTRUN_RUNNER_LIVE_BIND?.trim().toLowerCase();
|
|
48
49
|
return { host, bind: bind && (isLiveHost(bind) || bind === "0.0.0.0") ? bind : host, key: proofKey(sealKey) };
|
|
49
50
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
51
|
+
/** A run's own proof key, from the runners' shared one: what proves a request for one run's viewers and no other's. A
|
|
52
|
+
* run's own process is handed its run's (held.ts liveAt), never the shared key, so it can open no other run's viewer. */
|
|
53
|
+
const runKey = (key, runId) => createHmac("sha256", key).update(`${RUN_LABEL}\n${runId}`).digest();
|
|
54
|
+
/** The run label of runKey: another MAC than the proof's own. */
|
|
55
|
+
const RUN_LABEL = "agentrun live run v1";
|
|
56
|
+
/** The server's reach for run `runId`'s viewers: its hosts, under that run's key. */
|
|
57
|
+
export const reachForRun = (reach, runId) => ({ hosts: reach.hosts, key: runKey(reach.key, runId) });
|
|
58
|
+
/** A runner's live address for run `runId`'s viewers: its host and bind, under that run's key. */
|
|
59
|
+
export const liveForRun = (live, runId) => ({ host: live.host, bind: live.bind, key: runKey(live.key, runId) });
|
|
60
|
+
/** Whether `req` carries a good, fresh proof for viewer `viewerId` under `live`'s key: its time within `windowMs` of
|
|
61
|
+
* the endpoint's clock (LIVE_PROOF_MS by default). */
|
|
62
|
+
export function provenFor(req, live, viewerId, now = Date.now(), windowMs = LIVE_PROOF_MS) {
|
|
52
63
|
const said = req.headers[LIVE_PROOF_HEADER];
|
|
53
64
|
const match = typeof said === "string" ? /^(\d{1,16})\.([0-9a-f]{64})$/.exec(said) : null;
|
|
54
65
|
if (!match)
|
|
55
66
|
return false;
|
|
56
67
|
const at = Number(match[1]);
|
|
57
|
-
if (!Number.isSafeInteger(at) || Math.abs(now - at) >
|
|
68
|
+
if (!Number.isSafeInteger(at) || Math.abs(now - at) > windowMs)
|
|
58
69
|
return false;
|
|
59
70
|
const want = Buffer.from(mac(live.key, viewerId, at), "hex");
|
|
60
71
|
const got = Buffer.from(match[2], "hex");
|
|
61
72
|
return got.length === want.length && timingSafeEqual(got, want);
|
|
62
73
|
}
|
|
74
|
+
// A dial relayed to its runner (dial-relay.ts): a machine a runner in a process of its own made dials the server's
|
|
75
|
+
// attach route, and the server proxies its socket to that runner's attach listener with the same proof, under the same
|
|
76
|
+
// key, over a subject of its own. The subject binds the machine's token (its SHA-256), the runner the token's row names
|
|
77
|
+
// and that runner's incarnation (its process since its start), so a proof opens that one token's socket on that one
|
|
78
|
+
// runner and nowhere else. Its window is RELAY_PROOF_MS, and the runner takes each proof once (relayProofs).
|
|
79
|
+
/** How far a relay's proof's time may be from the runner's clock: the one hop's time, and no more. */
|
|
80
|
+
export const RELAY_PROOF_MS = 10_000;
|
|
81
|
+
const relaySubject = (to) => `attach relay\n${to.tokenSha256}\n${to.runner}\n${to.incarnation}`;
|
|
82
|
+
/** The server's proof for relaying the dial of token `to.tokenSha256` to runner `to.runner`, at `at` (ms). */
|
|
83
|
+
export const relayProof = (reach, to, at = Date.now()) => liveProof(reach, relaySubject(to), at);
|
|
84
|
+
/** The proof's key, from the seal key, for a runner's attach listener (whatever host it answers on). */
|
|
85
|
+
export const relayKeyOf = (sealKey) => ({ key: proofKey(sealKey) });
|
|
86
|
+
/** A runner's check of the relay's proofs: good, fresh (RELAY_PROOF_MS) and for `to`, and never one it took before, so
|
|
87
|
+
* a proof read off the hop opens no second socket. A proof is taken once by its MAC, not by the header as sent: the
|
|
88
|
+
* time reads as a number, so `0<ms>.<mac>` is the same signed proof as `<ms>.<mac>`, while the MAC (lower-case hex
|
|
89
|
+
* only) has one spelling for each subject and time. */
|
|
90
|
+
export function relayProofs(live, now = Date.now) {
|
|
91
|
+
const taken = new Map();
|
|
92
|
+
return (req, to) => {
|
|
93
|
+
const at = now();
|
|
94
|
+
for (const [proof, until] of taken)
|
|
95
|
+
if (until < at)
|
|
96
|
+
taken.delete(proof);
|
|
97
|
+
const said = req.headers[LIVE_PROOF_HEADER];
|
|
98
|
+
const signed = typeof said === "string" ? said.slice(said.indexOf(".") + 1) : undefined;
|
|
99
|
+
if (signed === undefined || taken.has(signed) || !provenFor(req, live, relaySubject(to), at, RELAY_PROOF_MS))
|
|
100
|
+
return false;
|
|
101
|
+
taken.set(signed, at + 2 * RELAY_PROOF_MS);
|
|
102
|
+
return true;
|
|
103
|
+
};
|
|
104
|
+
}
|
package/dist/llms.txt
CHANGED
|
@@ -17,7 +17,8 @@ Auth: the API's routes take `Authorization: Bearer <token>`, all but `GET /v2/he
|
|
|
17
17
|
- `POST /v2/agents` with `{definition: {name, instructions, tools, harness?, model?, thinking?}}` makes an agent (a workflow one holds `workflow` in place of `instructions`). A refusal is `422 input_invalid` naming each field. `PUT /v2/agents/{id}/definition` makes its next revision.
|
|
18
18
|
- `POST /v2/agents/{id}/runs` with `{input, file_ids?, effort?, revision?}` starts a run, answered at once, queued. An agentic run's input is `{content: "the first message"}`. An `Idempotency-Key` header makes a retry safe.
|
|
19
19
|
- `POST /v2/files?path=notes.md` with the file's bytes as the body (`curl --data-binary @notes.md`) uploads a file, answered `201` with the file, ready, its `file_id` under `file`. Name it in a run's `file_ids`, and the run finds it at `inputs/notes.md`. `GET /v2/files` lists the uploads, `DELETE /v2/files/{id}` removes one.
|
|
20
|
-
- `GET /v2/runs/{id}`: status (`queued`, `working`, `input_required`, `completed`, `failed`, `cancelled`, `paused`), `result` (`final_answer`, or a workflow's `output`), `error`, `cost` (`usd` is null while unknown, never $0).
|
|
20
|
+
- `GET /v2/runs/{id}`: status (`queued`, `working`, `input_required`, `completed`, `failed`, `cancelled`, `paused`), `result` (`final_answer`, or a workflow's `output`), `error`, `cost` (`usd` is null while unknown, never $0), `path` (`agent`, `workflow`, `handed_back`; null until it ends).
|
|
21
|
+
- An agent that learns: a run its learned workflow served (`path` `workflow`) has the workflow's answer as `result.final_answer`; one handed back (`handed_back`) has the agent's. Its timeline is its `user_message`, the learned_workflow `tool_use` and `tool_result` (its nodes in `learned_nodes`; they write no `decision` rows), then `final_answer` and `usage`; a hand-back puts a `phase` row and the agent's own rows before them. Learning spends on the agent's own model route, key and cap: on `GET /v2/runs/{id}`, `cost.usd` is the run's own spend, the job's; `cost.learning_usd` what learning spent for it (its audit's shadow run and its share of its workflow revision's compile turn and check, spread over the revision's first `compile_after` served runs; a compile that kept no draft is on no run, in the bill's `unattributed_usd`), `cost.all_in_usd` both. A shadow run is in no run list and sends no webhook. `GET /v2/agents/{id}/learning/cost` has the agent's whole bill (`bill`).
|
|
21
22
|
- `GET /v2/runs/{id}/timeline?after=0&limit=100` pages its steps; follow `next_after` until a page is `final` with `has_more` false.
|
|
22
23
|
- `GET /v2/runs/{id}/files`, then `GET /v2/runs/{id}/files/{path}`: what it wrote.
|
|
23
24
|
- `POST /v2/runs/{id}/messages` with `{content}` answers a run that asked a question (`input_required`), or follows up; `POST /v2/runs/{id}/cancel` ends one.
|
package/dist/local-models.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { Api, Model, MutableModels } from "@earendil-works/pi-ai";
|
|
2
2
|
import { type ModelPrice } from "@parcha/agentrun-kernel/kernel/cap";
|
|
3
|
-
|
|
4
|
-
* 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
|
|
5
|
-
export declare const PARTICLE_1_PRICE: {
|
|
6
|
-
readonly input: 0.25;
|
|
7
|
-
readonly output: 1;
|
|
8
|
-
readonly cacheRead: 0.03;
|
|
9
|
-
readonly cacheWrite: 0;
|
|
10
|
-
};
|
|
3
|
+
export { PARTICLE_1_PRICE } from "./particle-provider.js";
|
|
11
4
|
/** How a model takes its tools: "native", the request's own tools parameter (every model pi-ai lists), or "text", the
|
|
12
5
|
* tools described in its system prompt and its calls read back from its reply (runner/text-tools.ts, on the runner's
|
|
13
6
|
* translated route, runner/model-route.ts). A wire format of the model's provider, not a choice of a task's. */
|
|
@@ -60,7 +53,6 @@ export declare function isFree(model: {
|
|
|
60
53
|
api?: string;
|
|
61
54
|
cost?: ModelPrice | null;
|
|
62
55
|
}): boolean;
|
|
63
|
-
/** `models`
|
|
64
|
-
* ADDED_MODELS
|
|
65
|
-
* overridden price, with its toolsAs, and an added model as if the catalog listed it. */
|
|
56
|
+
/** `models` with serve's direct Particle provider registered, PRICE_OVERRIDES on the built-in providers' entries,
|
|
57
|
+
* and ADDED_MODELS beside them. Requests, prices and capability reads use this same catalog. */
|
|
66
58
|
export declare function withLocalModels<M extends MutableModels>(models: M): M;
|
package/dist/local-models.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { freeModel, ROUTERS } from "@parcha/agentrun-kernel/kernel/cap";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const PARTICLE_1_PRICE = { input: 0.25, output: 1, cacheRead: 0.03, cacheWrite: 0 };
|
|
2
|
+
import { PARTICLE_1_PRICE, particleProvider } from "./particle-provider.js";
|
|
3
|
+
export { PARTICLE_1_PRICE } from "./particle-provider.js";
|
|
5
4
|
/** What serve sets over pi-ai's own catalog entries, by provider and id: a price (`cost`), and how the model takes its
|
|
6
5
|
* tools (`toolsAs`, absent: native). pi-ai 1.5.0 lists particle-ai/particle-1 at
|
|
7
6
|
* OpenRouter's current promotional price ($0.05 input, $0.003 cache read, $0.50 output). A run's cap holds each request
|
|
@@ -64,10 +63,10 @@ export const isRouter = (provider, id) => provider === "openrouter" && ROUTERS.h
|
|
|
64
63
|
export function isFree(model) {
|
|
65
64
|
return freeModel({ id: model.id, api: model.api ?? "", price: model.cost ?? null, outputCeiling: null });
|
|
66
65
|
}
|
|
67
|
-
/** `models`
|
|
68
|
-
* ADDED_MODELS
|
|
69
|
-
* overridden price, with its toolsAs, and an added model as if the catalog listed it. */
|
|
66
|
+
/** `models` with serve's direct Particle provider registered, PRICE_OVERRIDES on the built-in providers' entries,
|
|
67
|
+
* and ADDED_MODELS beside them. Requests, prices and capability reads use this same catalog. */
|
|
70
68
|
export function withLocalModels(models) {
|
|
69
|
+
models.setProvider(particleProvider());
|
|
71
70
|
for (const providerId of new Set([...PRICE_OVERRIDES, ...ADDED_MODELS].map((entry) => entry.provider))) {
|
|
72
71
|
const own = models.getProvider(providerId);
|
|
73
72
|
if (!own)
|
|
@@ -144,15 +144,15 @@ export declare class McpServersOverStore {
|
|
|
144
144
|
headers?: string[] | undefined;
|
|
145
145
|
type: string;
|
|
146
146
|
};
|
|
147
|
-
credential: "sealed" | "
|
|
147
|
+
credential: "sealed" | "unreadable" | "expired" | null;
|
|
148
148
|
not_metered?: string[] | undefined;
|
|
149
149
|
tools: {
|
|
150
150
|
grant_problems?: Record<string, string>;
|
|
151
|
-
default_permission: "
|
|
152
|
-
permissions: ("
|
|
151
|
+
default_permission: "ask" | "allow" | "deny";
|
|
152
|
+
permissions: ("ask" | "allow" | "deny")[];
|
|
153
153
|
fallback_allow_reads?: true | undefined;
|
|
154
154
|
allow_reads?: true | undefined;
|
|
155
|
-
permission: "
|
|
155
|
+
permission: "ask" | "allow" | "deny";
|
|
156
156
|
effect: import("./tool-gate.js").ToolEffect;
|
|
157
157
|
name: string;
|
|
158
158
|
title?: string;
|
|
@@ -185,15 +185,15 @@ export declare class McpServersOverStore {
|
|
|
185
185
|
headers?: string[] | undefined;
|
|
186
186
|
type: string;
|
|
187
187
|
};
|
|
188
|
-
credential: "sealed" | "
|
|
188
|
+
credential: "sealed" | "unreadable" | "expired" | null;
|
|
189
189
|
not_metered?: string[] | undefined;
|
|
190
190
|
tools: {
|
|
191
191
|
grant_problems?: Record<string, string>;
|
|
192
|
-
default_permission: "
|
|
193
|
-
permissions: ("
|
|
192
|
+
default_permission: "ask" | "allow" | "deny";
|
|
193
|
+
permissions: ("ask" | "allow" | "deny")[];
|
|
194
194
|
fallback_allow_reads?: true | undefined;
|
|
195
195
|
allow_reads?: true | undefined;
|
|
196
|
-
permission: "
|
|
196
|
+
permission: "ask" | "allow" | "deny";
|
|
197
197
|
effect: import("./tool-gate.js").ToolEffect;
|
|
198
198
|
name: string;
|
|
199
199
|
title?: string;
|
|
@@ -255,15 +255,15 @@ export declare class McpServersOverStore {
|
|
|
255
255
|
headers?: string[] | undefined;
|
|
256
256
|
type: string;
|
|
257
257
|
};
|
|
258
|
-
credential: "sealed" | "
|
|
258
|
+
credential: "sealed" | "unreadable" | "expired" | null;
|
|
259
259
|
not_metered?: string[] | undefined;
|
|
260
260
|
tools: {
|
|
261
261
|
grant_problems?: Record<string, string>;
|
|
262
|
-
default_permission: "
|
|
263
|
-
permissions: ("
|
|
262
|
+
default_permission: "ask" | "allow" | "deny";
|
|
263
|
+
permissions: ("ask" | "allow" | "deny")[];
|
|
264
264
|
fallback_allow_reads?: true | undefined;
|
|
265
265
|
allow_reads?: true | undefined;
|
|
266
|
-
permission: "
|
|
266
|
+
permission: "ask" | "allow" | "deny";
|
|
267
267
|
effect: import("./tool-gate.js").ToolEffect;
|
|
268
268
|
name: string;
|
|
269
269
|
title?: string;
|
|
@@ -300,15 +300,15 @@ export declare class McpServersOverStore {
|
|
|
300
300
|
headers?: string[] | undefined;
|
|
301
301
|
type: string;
|
|
302
302
|
};
|
|
303
|
-
credential: "sealed" | "
|
|
303
|
+
credential: "sealed" | "unreadable" | "expired" | null;
|
|
304
304
|
not_metered?: string[] | undefined;
|
|
305
305
|
tools: {
|
|
306
306
|
grant_problems?: Record<string, string>;
|
|
307
|
-
default_permission: "
|
|
308
|
-
permissions: ("
|
|
307
|
+
default_permission: "ask" | "allow" | "deny";
|
|
308
|
+
permissions: ("ask" | "allow" | "deny")[];
|
|
309
309
|
fallback_allow_reads?: true | undefined;
|
|
310
310
|
allow_reads?: true | undefined;
|
|
311
|
-
permission: "
|
|
311
|
+
permission: "ask" | "allow" | "deny";
|
|
312
312
|
effect: import("./tool-gate.js").ToolEffect;
|
|
313
313
|
name: string;
|
|
314
314
|
title?: string;
|
package/dist/model-form.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// uses when a model is named in a form it does not take. One list, served in capabilities (`harnesses[].models`) and read
|
|
3
3
|
// by the console's Model picker, so the picker, the save's refusal and a run's refusal never name different forms.
|
|
4
4
|
// A leaf of model.ts and provider.ts (it reads their tables only when called, never as it loads).
|
|
5
|
-
import {
|
|
5
|
+
import { adapterFactsOf } from "./adapter-facts.js";
|
|
6
6
|
import { FAUX_ENV, MODEL_KEYS } from "./model.js";
|
|
7
7
|
import { openRouterName } from "./provider.js";
|
|
8
8
|
import { WIRES } from "./wires.js";
|
|
@@ -15,10 +15,11 @@ import { PLAN_HARNESSES } from "./harness.js";
|
|
|
15
15
|
export const PICKABLE = Object.freeze([
|
|
16
16
|
{ vendor: "anthropic", ids: Object.freeze(["claude-sonnet-5-5", "claude-opus-5-5", "claude-haiku-5-5", "claude-fable-5-2"]) },
|
|
17
17
|
{ vendor: "openai", ids: Object.freeze(["gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-luna"]) },
|
|
18
|
+
{ vendor: "particle", ids: Object.freeze(["particle-1"]) },
|
|
18
19
|
]);
|
|
19
20
|
/** The vendors whose models `harness` runs: pi any; an adapter harness, its wire's vendor. */
|
|
20
21
|
const vendorsOf = (harness) => {
|
|
21
|
-
const facts =
|
|
22
|
+
const facts = adapterFactsOf(harness);
|
|
22
23
|
return facts ? [WIRES[facts.wire].vendor] : PICKABLE.map((p) => p.vendor);
|
|
23
24
|
};
|
|
24
25
|
/** `vendor`'s model `id` in the form this server runs it: `vendor/id` on the vendor's own key, or through OpenRouter
|
|
@@ -26,7 +27,7 @@ const vendorsOf = (harness) => {
|
|
|
26
27
|
export function formOf(env, vendor, id) {
|
|
27
28
|
const row = MODEL_KEYS.find((r) => r.id === vendor);
|
|
28
29
|
if (row && !env[row.field] && env.OPENROUTER_API_KEY)
|
|
29
|
-
return `openrouter/${vendor}/${vendor === "anthropic" ? openRouterName(id) : id}`;
|
|
30
|
+
return `openrouter/${vendor === "particle" ? "particle-ai" : vendor}/${vendor === "anthropic" ? openRouterName(id) : id}`;
|
|
30
31
|
return `${vendor}/${id}`;
|
|
31
32
|
}
|
|
32
33
|
/** The models offered for `harness` on this server, each in the form it takes, before the harness's own catalog is asked
|
|
@@ -37,7 +38,7 @@ export function pickerCandidates(env, harness) {
|
|
|
37
38
|
return [];
|
|
38
39
|
// The gateway serves the harnesses whose wire goes through it (pi, and the OpenAI Responses wire: providerFor); the
|
|
39
40
|
// Anthropic Messages wire never does, so Claude is offered Anthropic's models on its own key.
|
|
40
|
-
const facts =
|
|
41
|
+
const facts = adapterFactsOf(harness);
|
|
41
42
|
if (env.AGENT_MODEL_BASE_URL && facts?.wire !== "anthropic-messages")
|
|
42
43
|
return [...new Set([env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].filter((id) => Boolean(id)))];
|
|
43
44
|
const vendors = vendorsOf(harness);
|
|
@@ -50,7 +51,7 @@ export function pickerCandidates(env, harness) {
|
|
|
50
51
|
* pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
|
|
51
52
|
* ids are its own) or with the faux model. */
|
|
52
53
|
export async function freeCandidates(env, harness) {
|
|
53
|
-
if (env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL || !env.OPENROUTER_API_KEY ||
|
|
54
|
+
if (env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL || !env.OPENROUTER_API_KEY || adapterFactsOf(harness))
|
|
54
55
|
return [];
|
|
55
56
|
const [{ builtinModels }, { withLocalModels, isFree }] = await Promise.all([import("@earendil-works/pi-ai/providers/all"), import("./local-models.js")]);
|
|
56
57
|
return withLocalModels(builtinModels()).getModels("openrouter").filter(isFree)
|
package/dist/model.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ import type { Revision } from "./agent-rows.js";
|
|
|
6
6
|
/** The child's environment names the faux module by absolute path. */
|
|
7
7
|
export declare const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
|
|
8
8
|
/** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
|
|
9
|
-
* (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name
|
|
9
|
+
* (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
|
|
10
|
+
* (HARNESS_MODULES_ENV). */
|
|
10
11
|
export declare const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
|
|
11
|
-
/** `env` without a test hook's name: serve sets those from startServe's options
|
|
12
|
-
* environment holds (an operator's export, a leftover) never gives its runs fake
|
|
12
|
+
/** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
|
|
13
|
+
* alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
|
|
14
|
+
* answers or loads a module. */
|
|
13
15
|
export declare const withoutFaux: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
|
|
14
16
|
/** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
|
|
15
17
|
* tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
|
|
@@ -51,6 +53,10 @@ export declare const MODEL_KEYS: readonly {
|
|
|
51
53
|
harnesses: readonly string[];
|
|
52
54
|
byVendor?: Readonly<Record<string, string>>;
|
|
53
55
|
}[];
|
|
56
|
+
/** The harnesses `row`'s key runs on `env`'s server: its own (`harnesses`), then each harness this server lists only once its
|
|
57
|
+
* owner installs it (Goose: harness-table.ts hidden, listed by harnessIds) whose wire runs the row's vendor's models, or
|
|
58
|
+
* any, on OpenRouter's. One not installed here is never named. */
|
|
59
|
+
export declare function keyHarnesses(row: (typeof MODEL_KEYS)[number], env: NodeJS.ProcessEnv): readonly string[];
|
|
54
60
|
/** What a person does when no model runs here: add a model provider's key in the console, or set one where AgentRun
|
|
55
61
|
* starts (MODEL_KEYS' fields), OpenRouter's named first, as its one key runs every harness. The order a default is
|
|
56
62
|
* taken in is MODEL_KEYS' own. */
|
|
@@ -229,7 +235,9 @@ export declare function catalogPrices(): Promise<Map<string, Listed[]>>;
|
|
|
229
235
|
* version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
|
|
230
236
|
* agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
|
|
231
237
|
* 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
|
|
232
|
-
* effort, as its catalog entries say (off: null), not the "none" it refuses.
|
|
238
|
+
* effort, as its catalog entries say (off: null), not the "none" it refuses. A model the catalog does not list (a local
|
|
239
|
+
* model, a gateway's own alias) is never asked to stop reasoning either (off: null): pi then thinks at its lowest level,
|
|
240
|
+
* so a model that reasons anyway has its reasoning split out of the answer, never written into it. */
|
|
233
241
|
export declare function catalogThinking(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): ThinkingLevelMap | undefined;
|
|
234
242
|
/** A gateway model's price in `catalog` (catalogPrices'), by its id as the host or the revision names it: a ref that names
|
|
235
243
|
* its provider (`named`), priced as that provider's entry, whether the id went whole or bare; a host model set whole
|