@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
|
@@ -17,7 +17,7 @@ import { serialWriter, startModelProxy } from "@parcha/agentrun-kernel/host";
|
|
|
17
17
|
import { openCodeHarness, sentSubmissions } from "./harness.js";
|
|
18
18
|
import { openCodePolicy, TOOL_PREFIX } from "./host/policy.js";
|
|
19
19
|
import { verifyOpenCode } from "./verify.js";
|
|
20
|
-
import { learnedFront } from "../learn/
|
|
20
|
+
import { learnedFront } from "../learn/workflow-draft.js";
|
|
21
21
|
/** A name OpenCode keeps whole for an MCP tool (it turns anything else into `_`), short enough that `hands_<name>` is a
|
|
22
22
|
* function name the Responses API takes (at most 64). */
|
|
23
23
|
const TOOL_NAME = new RegExp(`^[A-Za-z0-9_-]{1,${64 - TOOL_PREFIX.length}}$`);
|
package/dist/harness-table.d.ts
CHANGED
|
@@ -4,8 +4,13 @@ import type { AdapterNeeds } from "./adapters.js";
|
|
|
4
4
|
import { type HarnessInstallEntry, type HarnessPins } from "./harness-install.js";
|
|
5
5
|
import { type ModelChoice } from "./provider.js";
|
|
6
6
|
import type { SkillCheck } from "./skills.js";
|
|
7
|
+
import type { RunnerHarness } from "./runner/adapters/index.js";
|
|
7
8
|
/** A module of entries a test merges over the built-in ones (HarnessTableModule), by absolute path. */
|
|
8
9
|
export declare const HARNESS_TABLE_ENV = "AGENTRUN_HARNESS_TABLE";
|
|
10
|
+
/** The harness modules the owner names (the server's `harnessModules`), as a JSON array of absolute paths: each adds
|
|
11
|
+
* harnesses of its own to the table, under a test runner or not, and never replaces a built-in one. The server sets it
|
|
12
|
+
* from its options alone (model.ts withoutFaux drops an operator's). */
|
|
13
|
+
export declare const HARNESS_MODULES_ENV = "AGENTRUN_HARNESS_MODULES";
|
|
9
14
|
/** Why a harness cannot run here, in words a person can act on, and the model keys any one of which would let it
|
|
10
15
|
* (HarnessUnavailable's `keys`). */
|
|
11
16
|
export type Refusal = {
|
|
@@ -18,8 +23,27 @@ export type SessionRoute = {
|
|
|
18
23
|
api: AdapterFacts["wire"];
|
|
19
24
|
options: Pick<ModelProxyOptions, "policy" | "model" | "origin" | "credential" | "price">;
|
|
20
25
|
};
|
|
26
|
+
/** What a harness promises, as capabilities show it (each a person can rely on, measured, never named): how a run resumes
|
|
27
|
+
* after a crash (`exact`: its state mirrored into the journal; `load`: the agent's own session load; `restart`: the turn
|
|
28
|
+
* restarts with a recovery note), what holds its tool calls (`every_call`: each blocks until journaled; `permission`: the
|
|
29
|
+
* agent's permission requests; `config`: its built-ins are off by its config, our tools gated), and who pays for its
|
|
30
|
+
* model (`proxy`: through the session's proxy, on this server's cap; `plan`: the vendor bills the person's own plan). */
|
|
31
|
+
export type HarnessPromises = {
|
|
32
|
+
readonly resume: "exact" | "load" | "restart";
|
|
33
|
+
readonly tool_gate: "every_call" | "permission" | "config";
|
|
34
|
+
readonly billing: "proxy" | "plan";
|
|
35
|
+
};
|
|
36
|
+
/** The native harnesses' promises: pi and the three CLI adapters. */
|
|
37
|
+
export declare const NATIVE_PROMISES: HarnessPromises;
|
|
21
38
|
export interface HarnessEntry {
|
|
22
39
|
readonly id: string;
|
|
40
|
+
/** Its name in a sentence ("Pi", "Claude"): an adapter's facts' label. */
|
|
41
|
+
readonly label: string;
|
|
42
|
+
/** What it promises (HarnessPromises). Absent: a native harness's (NATIVE_PROMISES). */
|
|
43
|
+
readonly promises?: HarnessPromises;
|
|
44
|
+
/** The runner's harness for it (runner/adapters/index.ts RunnerHarness): absent on a built-in, whose runner is the
|
|
45
|
+
* runner's own (RUNNER_HARNESSES); a harness module's entry brings its own. */
|
|
46
|
+
readonly runner?: RunnerHarness;
|
|
23
47
|
/** Whether it takes a message mid-turn; else a message waits for the turn's end. */
|
|
24
48
|
readonly steer: boolean;
|
|
25
49
|
/** What one of its runs reserves in memory while its process lives, in MiB (host.ts). */
|
|
@@ -52,19 +76,51 @@ export interface HarnessEntry {
|
|
|
52
76
|
skillCheck?(): Promise<SkillCheck | undefined>;
|
|
53
77
|
/** What its first-use install needs (installs). */
|
|
54
78
|
pins?(): Promise<HarnessPins>;
|
|
79
|
+
/** Why it is not listed on `env` (harnessIds: capabilities, the tools' harnesses), in words that end with what to do;
|
|
80
|
+
* undefined while it is. One its owner installs (Goose: harness-goose.ts) is listed only once it is there and verified.
|
|
81
|
+
* It is still in the table, so a run or a save naming it is refused with these words. */
|
|
82
|
+
hidden?(env: NodeJS.ProcessEnv): string | undefined;
|
|
55
83
|
}
|
|
56
84
|
/** What a test's table module exports: entries by id, each merged over the built-in one of that id (all of it, for one
|
|
57
85
|
* the server has none of), given the built-ins to build on. Loaded with require: the module has no top-level await. */
|
|
58
86
|
export type HarnessTableModule = {
|
|
59
87
|
entries(builtins: Readonly<Record<string, HarnessEntry>>): Record<string, Partial<HarnessEntry>>;
|
|
60
88
|
};
|
|
61
|
-
/** The table `env` runs on: the built-in entries,
|
|
62
|
-
*
|
|
63
|
-
*
|
|
89
|
+
/** The table `env` runs on: the built-in entries; then, only under a test runner (node --test's NODE_TEST_CONTEXT, which a
|
|
90
|
+
* server's and a run's processes there carry), a test's module's (HARNESS_TABLE_ENV) merged over them by id; then the
|
|
91
|
+
* harnesses each of the owner's harness modules adds (HARNESS_MODULES_ENV), under a test runner or not. A module adds
|
|
92
|
+
* whole entries of new ids: one whose id is not one the API carries (HARNESS_ID_PATTERN), naming a name serve's own runs
|
|
93
|
+
* carry or every object has (RESERVED_HARNESS_IDS: a learning run's `learning` would reach the learning loop, and
|
|
94
|
+
* `constructor` would read Object's own member where serve looks a harness up in a plain object), naming a built-in harness, an
|
|
95
|
+
* id another module adds, or an entry missing a member is refused by name, so no module changes what a built-in harness
|
|
96
|
+
* is (grep pins claude-agent). Loaded once per setting. */
|
|
64
97
|
export declare function harnessTable(env: NodeJS.ProcessEnv): Readonly<Record<string, HarnessEntry>>;
|
|
98
|
+
/** The owner's setting that names harness modules when no option does: package names or paths, comma-separated. */
|
|
99
|
+
export declare const HARNESS_MODULES_SETTING = "AGENTRUN_SERVE_HARNESS_MODULES";
|
|
100
|
+
/** The harness modules `given` names (a server's or a runner's `--harness-module`, else HARNESS_MODULES_SETTING): none
|
|
101
|
+
* when neither names one. */
|
|
102
|
+
export declare const harnessModulesOf: (given: readonly string[] | undefined, env: NodeJS.ProcessEnv) => string[];
|
|
103
|
+
/** Each harness module `names` names, as the absolute path HARNESS_MODULES_ENV carries: a path as it resolves; a package
|
|
104
|
+
* from `<data>/harnesses` (where its owner installs it: npm install --prefix <data>/harnesses <package>), else from
|
|
105
|
+
* where the server runs. One that resolves nowhere refuses the start, naming the command that installs it. */
|
|
106
|
+
export declare function harnessModulePaths(names: readonly string[], data: string): string[];
|
|
107
|
+
/** HARNESS_MODULES_ENV for the harness modules `names` names: none for none. */
|
|
108
|
+
export declare const harnessModulesEnv: (names: readonly string[], data: string) => NodeJS.ProcessEnv;
|
|
109
|
+
/** The ids of the harnesses `env`'s table lists, in its order: the built-in ones (pi first), then those its modules add;
|
|
110
|
+
* not one its entry hides on `env` (HarnessEntry.hidden: Goose until it is installed). */
|
|
111
|
+
export declare const harnessIds: (env: NodeJS.ProcessEnv) => readonly string[];
|
|
112
|
+
/** The ids of every harness `env`'s table has, hidden ones too: those a definition may name (a save warns of a hidden one,
|
|
113
|
+
* a run is refused with why). */
|
|
114
|
+
export declare const tableIds: (env: NodeJS.ProcessEnv) => readonly string[];
|
|
65
115
|
/** The built-in entry of harness `id` (none: the default, pi), for what a test's entry never changes: its memory (host.ts),
|
|
66
116
|
* which a stand-in reserves as the harness it stands in for does, so tests admit as a real server does. */
|
|
67
117
|
export declare const builtinHarness: (id: string | undefined) => HarnessEntry | undefined;
|
|
118
|
+
/** The owner's table on `env`: the built-in entries and those its harness modules add (HARNESS_MODULES_ENV), never a test
|
|
119
|
+
* table's. What a run weighs and whether one fits (host.ts, runner/memory-claim.ts) read it, so a test's stand-in admits
|
|
120
|
+
* as the built-in harness it stands in for, and a module's harness as its entry declares. */
|
|
121
|
+
export declare const ownerTable: (env: NodeJS.ProcessEnv) => Readonly<Record<string, HarnessEntry>>;
|
|
122
|
+
/** The entry of harness `id` (none: the default, pi) on the owner's table (ownerTable); undefined for one it has not. */
|
|
123
|
+
export declare const ownerHarness: (env: NodeJS.ProcessEnv, id: string | undefined) => HarnessEntry | undefined;
|
|
68
124
|
/** The entry of harness `id` (none: the default, pi) on `env`'s table; undefined for an id this server has none of. */
|
|
69
125
|
export declare const harnessOf: (env: NodeJS.ProcessEnv, id: string | undefined) => HarnessEntry | undefined;
|
|
70
126
|
/** Whether `id` runs on an adapter (every harness but pi): a session of its own, beside the run's process. */
|
package/dist/harness-table.js
CHANGED
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
// these by id: what a test stands in for is an entry, never a branch here or anywhere else. The server sets the variable
|
|
9
9
|
// from its options alone (model.ts withoutFaux), so an operator's environment never loads a module.
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
|
-
import { resolve } from "node:path";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
12
|
import { facts as claudeFacts } from "@parcha/agentrun-harness-claude/facts";
|
|
13
13
|
import { facts as codexFacts } from "@parcha/agentrun-harness-codex/facts";
|
|
14
14
|
import { facts as openCodeFacts } from "./harness-opencode/facts.js";
|
|
15
|
-
import {
|
|
15
|
+
import { GOOSE_FACTS } from "./adapter-facts.js";
|
|
16
|
+
import { gooseHidden } from "./harness-goose.js";
|
|
17
|
+
import { DEFAULT_HARNESS, HARNESS_ID_PATTERN, PLAN_HARNESSES, RESERVED_HARNESS_IDS } from "./harness.js";
|
|
16
18
|
import { HARNESS_INSTALLS } from "./harness-install.js";
|
|
17
19
|
import { chooseModel } from "./model.js";
|
|
18
20
|
import { HarnessUnavailable, modelOn, openRouterOnly, priceModelFor, providerFor } from "./provider.js";
|
|
@@ -20,6 +22,12 @@ import { WIRES } from "./wires.js";
|
|
|
20
22
|
import { PLAN_PROVIDER, signedIn } from "./chatgpt-plan.js";
|
|
21
23
|
/** A module of entries a test merges over the built-in ones (HarnessTableModule), by absolute path. */
|
|
22
24
|
export const HARNESS_TABLE_ENV = "AGENTRUN_HARNESS_TABLE";
|
|
25
|
+
/** The harness modules the owner names (the server's `harnessModules`), as a JSON array of absolute paths: each adds
|
|
26
|
+
* harnesses of its own to the table, under a test runner or not, and never replaces a built-in one. The server sets it
|
|
27
|
+
* from its options alone (model.ts withoutFaux drops an operator's). */
|
|
28
|
+
export const HARNESS_MODULES_ENV = "AGENTRUN_HARNESS_MODULES";
|
|
29
|
+
/** The native harnesses' promises: pi and the three CLI adapters. */
|
|
30
|
+
export const NATIVE_PROMISES = Object.freeze({ resume: "exact", tool_gate: "every_call", billing: "proxy" });
|
|
23
31
|
// The memory one run of each harness reserves while its process lives, in MiB (each entry's runMib, an adapter's from its
|
|
24
32
|
// facts): what admission counts (host.ts).
|
|
25
33
|
// Measured 2026-11-03 on 529c3882e with the pinned binaries' sha256 checked a chunk at a time, not read whole: a
|
|
@@ -41,6 +49,7 @@ export const HARNESS_TABLE_ENV = "AGENTRUN_HARNESS_TABLE";
|
|
|
41
49
|
/** pi: the run's own process, on its own models. */
|
|
42
50
|
const PI = Object.freeze({
|
|
43
51
|
id: DEFAULT_HARNESS,
|
|
52
|
+
label: "Pi",
|
|
44
53
|
steer: true,
|
|
45
54
|
runMib: 128,
|
|
46
55
|
oneAlwaysFits: true,
|
|
@@ -60,6 +69,7 @@ function adapterEntry(facts, make, extra = {}) {
|
|
|
60
69
|
const onPlan = PLAN_HARNESSES.includes(id);
|
|
61
70
|
const entry = {
|
|
62
71
|
id,
|
|
72
|
+
label: facts.label,
|
|
63
73
|
steer: facts.steer,
|
|
64
74
|
runMib: facts.runMib,
|
|
65
75
|
oneAlwaysFits: false,
|
|
@@ -76,6 +86,9 @@ function adapterEntry(facts, make, extra = {}) {
|
|
|
76
86
|
route: async (env, needs) => {
|
|
77
87
|
const { nativeOptions, priceOf } = await import("./adapters.js");
|
|
78
88
|
const provider = providerFor(wire, env, needs.model, id);
|
|
89
|
+
// A person's Claude Code login is its CLI's alone: no request of serve's own goes on it.
|
|
90
|
+
if (provider.login)
|
|
91
|
+
throw new HarnessUnavailable(`${id} runs on Claude Code's login on this machine, which only its CLI uses: this request needs a model key.`);
|
|
79
92
|
const policy = facts.policy({ model: provider.modelId, tools: [], auth: provider.auth, ...nativeOptions(facts, env), ...(provider.billing === "plan" ? { plan: true } : {}) });
|
|
80
93
|
return { api: wire, options: { policy, model: provider.modelId, origin: provider.origin, credential: async () => provider.credential(), price: priceOf({ ...needs, model: provider.priceModel }) } };
|
|
81
94
|
},
|
|
@@ -114,35 +127,127 @@ const BUILTIN = Object.freeze({
|
|
|
114
127
|
[openCodeFacts.id]: adapterEntry(openCodeFacts, async (env, needs) => (await import("./adapters.js")).opencodeOf(env, needs), {
|
|
115
128
|
// Checked as OpenCode is handed them (servedSkills, opencodeOf's): one size check on what it gets.
|
|
116
129
|
skillCheck: async () => {
|
|
117
|
-
const [{ packageSkillCheck }, { servedSkills }] = await Promise.all([import("./adapters.js"), import("./learn/
|
|
130
|
+
const [{ packageSkillCheck }, { servedSkills }] = await Promise.all([import("./adapters.js"), import("./learn/workflow-draft.js")]);
|
|
118
131
|
const check = await packageSkillCheck(() => import("./harness-opencode/index.js"));
|
|
119
132
|
return check && ((skills) => check(servedSkills(skills)));
|
|
120
133
|
},
|
|
121
134
|
}),
|
|
135
|
+
// Goose, over ACP, where its package is beside serve (acp-package.ts): its owner installs its pinned binary
|
|
136
|
+
// (`agentrun harness install goose`, harness-goose.ts), never a run; listed only once it is installed and verified.
|
|
137
|
+
...(GOOSE_FACTS ? {
|
|
138
|
+
[GOOSE_FACTS.id]: adapterEntry(GOOSE_FACTS, async (env, needs) => (await import("./adapters.js")).gooseOf(env, needs), {
|
|
139
|
+
promises: Object.freeze({ resume: "load", tool_gate: "permission", billing: "proxy" }),
|
|
140
|
+
hidden: gooseHidden,
|
|
141
|
+
}),
|
|
142
|
+
} : {}),
|
|
122
143
|
});
|
|
123
144
|
const loaded = new Map();
|
|
124
145
|
const requireHere = createRequire(import.meta.url);
|
|
125
|
-
/** The
|
|
126
|
-
|
|
127
|
-
|
|
146
|
+
/** The members a harness module's new entry gives: what the table's readers ask of every entry. */
|
|
147
|
+
const WHOLE = Object.freeze(["label", "steer", "runMib", "oneAlwaysFits", "runs", "onWire", "model", "priceModel", "refusal", "runner"]);
|
|
148
|
+
/** The entries module `path` gives (HarnessTableModule), `named` saying which setting named it. */
|
|
149
|
+
function entriesOf(path, named) {
|
|
150
|
+
const module = requireHere(resolve(path));
|
|
151
|
+
if (typeof module.entries !== "function")
|
|
152
|
+
throw new Error(`${named} names ${path}, which exports no entries(builtins)`);
|
|
153
|
+
return module.entries(BUILTIN);
|
|
154
|
+
}
|
|
155
|
+
/** The harness modules `env` names (HARNESS_MODULES_ENV): none when it names none. */
|
|
156
|
+
function modulesOf(env) {
|
|
157
|
+
const given = env[HARNESS_MODULES_ENV];
|
|
158
|
+
if (!given)
|
|
159
|
+
return [];
|
|
160
|
+
const paths = JSON.parse(given);
|
|
161
|
+
if (!Array.isArray(paths) || !paths.every((path) => typeof path === "string"))
|
|
162
|
+
throw new Error(`${HARNESS_MODULES_ENV} is a JSON array of module paths`);
|
|
163
|
+
return paths;
|
|
164
|
+
}
|
|
165
|
+
const harnessId = new RegExp(HARNESS_ID_PATTERN);
|
|
166
|
+
/** The table `env` runs on: the built-in entries; then, only under a test runner (node --test's NODE_TEST_CONTEXT, which a
|
|
167
|
+
* server's and a run's processes there carry), a test's module's (HARNESS_TABLE_ENV) merged over them by id; then the
|
|
168
|
+
* harnesses each of the owner's harness modules adds (HARNESS_MODULES_ENV), under a test runner or not. A module adds
|
|
169
|
+
* whole entries of new ids: one whose id is not one the API carries (HARNESS_ID_PATTERN), naming a name serve's own runs
|
|
170
|
+
* carry or every object has (RESERVED_HARNESS_IDS: a learning run's `learning` would reach the learning loop, and
|
|
171
|
+
* `constructor` would read Object's own member where serve looks a harness up in a plain object), naming a built-in harness, an
|
|
172
|
+
* id another module adds, or an entry missing a member is refused by name, so no module changes what a built-in harness
|
|
173
|
+
* is (grep pins claude-agent). Loaded once per setting. */
|
|
128
174
|
export function harnessTable(env) {
|
|
129
175
|
const path = env.NODE_TEST_CONTEXT ? env[HARNESS_TABLE_ENV] : undefined;
|
|
130
|
-
|
|
176
|
+
const modules = modulesOf(env);
|
|
177
|
+
if (!path && !modules.length)
|
|
131
178
|
return BUILTIN;
|
|
132
|
-
|
|
179
|
+
const key = JSON.stringify([path ?? null, modules]);
|
|
180
|
+
let table = loaded.get(key);
|
|
133
181
|
if (!table) {
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
182
|
+
const built = { ...BUILTIN };
|
|
183
|
+
if (path)
|
|
184
|
+
for (const [id, entry] of Object.entries(entriesOf(path, HARNESS_TABLE_ENV)))
|
|
185
|
+
built[id] = Object.freeze({ ...BUILTIN[id], ...entry, id });
|
|
186
|
+
for (const module of modules) {
|
|
187
|
+
for (const [id, entry] of Object.entries(entriesOf(module, HARNESS_MODULES_ENV))) {
|
|
188
|
+
if (!harnessId.test(id))
|
|
189
|
+
throw new Error(`harness module ${module} names ${id}, which is not a harness id: an id matches ${HARNESS_ID_PATTERN}`);
|
|
190
|
+
if (RESERVED_HARNESS_IDS.includes(id))
|
|
191
|
+
throw new Error(`harness module ${module} names ${id}, a name serve's own runs carry or every object already has: a module's harness takes none of ${RESERVED_HARNESS_IDS.join(", ")}`);
|
|
192
|
+
if (Object.hasOwn(BUILTIN, id))
|
|
193
|
+
throw new Error(`harness module ${module} names ${id}, a built-in harness: a module adds a harness and never replaces one`);
|
|
194
|
+
if (Object.hasOwn(built, id))
|
|
195
|
+
throw new Error(`harness module ${module} names ${id}, which another module already adds`);
|
|
196
|
+
const missing = WHOLE.filter((member) => entry[member] === undefined);
|
|
197
|
+
if (missing.length)
|
|
198
|
+
throw new Error(`harness module ${module}: its entry ${id} lacks ${missing.join(", ")}`);
|
|
199
|
+
built[id] = Object.freeze({ ...entry, id });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
table = Object.freeze(built);
|
|
203
|
+
loaded.set(key, table);
|
|
140
204
|
}
|
|
141
205
|
return table;
|
|
142
206
|
}
|
|
207
|
+
/** The owner's setting that names harness modules when no option does: package names or paths, comma-separated. */
|
|
208
|
+
export const HARNESS_MODULES_SETTING = "AGENTRUN_SERVE_HARNESS_MODULES";
|
|
209
|
+
/** The harness modules `given` names (a server's or a runner's `--harness-module`, else HARNESS_MODULES_SETTING): none
|
|
210
|
+
* when neither names one. */
|
|
211
|
+
export const harnessModulesOf = (given, env) => given?.length ? [...given] : (env[HARNESS_MODULES_SETTING] ?? "").split(",").map((name) => name.trim()).filter(Boolean);
|
|
212
|
+
/** Each harness module `names` names, as the absolute path HARNESS_MODULES_ENV carries: a path as it resolves; a package
|
|
213
|
+
* from `<data>/harnesses` (where its owner installs it: npm install --prefix <data>/harnesses <package>), else from
|
|
214
|
+
* where the server runs. One that resolves nowhere refuses the start, naming the command that installs it. */
|
|
215
|
+
export function harnessModulePaths(names, data) {
|
|
216
|
+
return names.map((name) => {
|
|
217
|
+
if (name.startsWith("/") || name.startsWith("."))
|
|
218
|
+
return resolve(name);
|
|
219
|
+
for (const from of [join(resolve(data), "harnesses", "package.json"), join(process.cwd(), "package.json")]) {
|
|
220
|
+
try {
|
|
221
|
+
return createRequire(from).resolve(name);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// Not there: the next place.
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
throw new Error(`harness module ${name} is not installed: npm install --prefix ${join(resolve(data), "harnesses")} ${name}`);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/** HARNESS_MODULES_ENV for the harness modules `names` names: none for none. */
|
|
231
|
+
export const harnessModulesEnv = (names, data) => (names.length ? { [HARNESS_MODULES_ENV]: JSON.stringify(harnessModulePaths(names, data)) } : {});
|
|
232
|
+
/** The ids of the harnesses `env`'s table lists, in its order: the built-in ones (pi first), then those its modules add;
|
|
233
|
+
* not one its entry hides on `env` (HarnessEntry.hidden: Goose until it is installed). */
|
|
234
|
+
export const harnessIds = (env) => Object.entries(harnessTable(env)).filter(([, entry]) => entry.hidden?.(env) === undefined).map(([id]) => id);
|
|
235
|
+
/** The ids of every harness `env`'s table has, hidden ones too: those a definition may name (a save warns of a hidden one,
|
|
236
|
+
* a run is refused with why). */
|
|
237
|
+
export const tableIds = (env) => Object.keys(harnessTable(env));
|
|
143
238
|
/** The built-in entry of harness `id` (none: the default, pi), for what a test's entry never changes: its memory (host.ts),
|
|
144
239
|
* which a stand-in reserves as the harness it stands in for does, so tests admit as a real server does. */
|
|
145
240
|
export const builtinHarness = (id) => BUILTIN[id ?? DEFAULT_HARNESS];
|
|
241
|
+
/** The owner's table on `env`: the built-in entries and those its harness modules add (HARNESS_MODULES_ENV), never a test
|
|
242
|
+
* table's. What a run weighs and whether one fits (host.ts, runner/memory-claim.ts) read it, so a test's stand-in admits
|
|
243
|
+
* as the built-in harness it stands in for, and a module's harness as its entry declares. */
|
|
244
|
+
export const ownerTable = (env) => harnessTable(env[HARNESS_MODULES_ENV] ? { [HARNESS_MODULES_ENV]: env[HARNESS_MODULES_ENV] } : {});
|
|
245
|
+
/** The entry of harness `id` (none: the default, pi) on the owner's table (ownerTable); undefined for one it has not. */
|
|
246
|
+
export const ownerHarness = (env, id) => {
|
|
247
|
+
const table = ownerTable(env);
|
|
248
|
+
const key = id ?? DEFAULT_HARNESS;
|
|
249
|
+
return Object.hasOwn(table, key) ? table[key] : undefined;
|
|
250
|
+
};
|
|
146
251
|
/** The entry of harness `id` (none: the default, pi) on `env`'s table; undefined for an id this server has none of. */
|
|
147
252
|
export const harnessOf = (env, id) => harnessTable(env)[id ?? DEFAULT_HARNESS];
|
|
148
253
|
/** Whether `id` runs on an adapter (every harness but pi): a session of its own, beside the run's process. */
|
package/dist/harness.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
import type { HarnessPromises } from "./harness-table.js";
|
|
2
|
+
/** The built-in harnesses' ids, in the table's order (harness-table.ts BUILTIN; harness-one-table.test.mjs holds them
|
|
3
|
+
* equal): the ids a definition may name on any server, and the type of a built-in one. What a server runs is its table's
|
|
4
|
+
* (harnessIds), which an owner's harness module may add to. */
|
|
1
5
|
export declare const HARNESSES: readonly ["pi", "claude-agent", "codex", "opencode"];
|
|
2
6
|
export type HarnessId = (typeof HARNESSES)[number];
|
|
3
7
|
export declare const DEFAULT_HARNESS: HarnessId;
|
|
8
|
+
/** What a harness id is, as the API says it (openapi.ts): a harness module's id that is not one refuses the start. */
|
|
9
|
+
export declare const HARNESS_ID_PATTERN = "^[a-z][a-z0-9-]{0,39}$";
|
|
10
|
+
/** The names serve's own runs carry where a harness id goes, so a harness module may not take one (its start is refused):
|
|
11
|
+
* `learning`, the launch harness the stores' learning queries match; `sdk`, an SDK run's launch harness
|
|
12
|
+
* (sdk/runs.ts); and the names analytics files a run's harness under: `workflow`, a workflow revision's, and each SDK
|
|
13
|
+
* runtime's (sdk/schema.ts SDK_BINDING). Also every name a plain object already has that the id pattern admits
|
|
14
|
+
* (`constructor`): serve looks harnesses up by id in plain objects, where such an id would read Object's own member. */
|
|
15
|
+
export declare const RESERVED_HARNESS_IDS: readonly string[];
|
|
4
16
|
/** The harnesses that run on a person's ChatGPT plan (chatgpt-plan.ts): those whose requests go to OpenAI's Responses
|
|
5
17
|
* API as the plan takes them. The others need a model key. */
|
|
6
18
|
export declare const PLAN_HARNESSES: readonly string[];
|
|
@@ -13,8 +25,12 @@ export declare const PLAN_HARNESSES: readonly string[];
|
|
|
13
25
|
* server's own: capabilities never serve it. */
|
|
14
26
|
/** `installs`: `on_first_use` on claude-agent or codex while its CLI is not installed in this server's data: its first run
|
|
15
27
|
* (or the first agent made on it) installs it (harness-install.ts). */
|
|
28
|
+
/** `id`: one of the table's (harness-table.ts harnessIds): a built-in one (HARNESSES) or one an owner's harness module adds.
|
|
29
|
+
* `label`: its name in a sentence. `promises`: what it promises (HarnessPromises), as capabilities show it. */
|
|
16
30
|
export type HarnessOffer = {
|
|
17
|
-
id:
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
promises: HarnessPromises;
|
|
18
34
|
available: boolean;
|
|
19
35
|
steer: boolean;
|
|
20
36
|
reason?: string;
|
package/dist/harness.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// capabilities, and a revision naming one it does not run saves with a warning and is refused at run time.
|
|
1
|
+
/** The built-in harnesses' ids, in the table's order (harness-table.ts BUILTIN; harness-one-table.test.mjs holds them
|
|
2
|
+
* equal): the ids a definition may name on any server, and the type of a built-in one. What a server runs is its table's
|
|
3
|
+
* (harnessIds), which an owner's harness module may add to. */
|
|
5
4
|
export const HARNESSES = ["pi", "claude-agent", "codex", "opencode"];
|
|
6
5
|
export const DEFAULT_HARNESS = "pi";
|
|
6
|
+
/** What a harness id is, as the API says it (openapi.ts): a harness module's id that is not one refuses the start. */
|
|
7
|
+
export const HARNESS_ID_PATTERN = "^[a-z][a-z0-9-]{0,39}$";
|
|
8
|
+
/** The names serve's own runs carry where a harness id goes, so a harness module may not take one (its start is refused):
|
|
9
|
+
* `learning`, the launch harness the stores' learning queries match; `sdk`, an SDK run's launch harness
|
|
10
|
+
* (sdk/runs.ts); and the names analytics files a run's harness under: `workflow`, a workflow revision's, and each SDK
|
|
11
|
+
* runtime's (sdk/schema.ts SDK_BINDING). Also every name a plain object already has that the id pattern admits
|
|
12
|
+
* (`constructor`): serve looks harnesses up by id in plain objects, where such an id would read Object's own member. */
|
|
13
|
+
export const RESERVED_HARNESS_IDS = Object.freeze([
|
|
14
|
+
"learning", "sdk", "workflow", "claude-agent-sdk", "codex-sdk",
|
|
15
|
+
...Object.getOwnPropertyNames(Object.prototype).filter((name) => new RegExp(HARNESS_ID_PATTERN).test(name)),
|
|
16
|
+
]);
|
|
7
17
|
/** The harnesses that run on a person's ChatGPT plan (chatgpt-plan.ts): those whose requests go to OpenAI's Responses
|
|
8
18
|
* API as the plan takes them. The others need a model key. */
|
|
9
19
|
export const PLAN_HARNESSES = Object.freeze(["pi", "codex"]);
|
|
@@ -29,25 +39,26 @@ export function harnessOffers(env) {
|
|
|
29
39
|
const { hostMemory, neverFits } = await import("./host.js");
|
|
30
40
|
const memory = hostMemory();
|
|
31
41
|
const { harnessInstalled } = await import("./adapters.js");
|
|
32
|
-
const { harnessOf } = await import("./harness-table.js");
|
|
33
|
-
const probed = await Promise.all(
|
|
42
|
+
const { harnessIds, harnessOf, NATIVE_PROMISES } = await import("./harness-table.js");
|
|
43
|
+
const probed = await Promise.all(harnessIds(env).map(async (id) => {
|
|
34
44
|
const entry = harnessOf(env, id);
|
|
45
|
+
const named = { label: entry.label, promises: entry.promises ?? NATIVE_PROMISES };
|
|
35
46
|
// The start's probe: these offers hold until a restart (server.ts), so the reason says so where installing fixes it.
|
|
36
47
|
// Claude Code not installed yet says so (its install probes the offers again).
|
|
37
48
|
const firstUse = entry.installs && !(await harnessInstalled(entry, env)) ? { installs: "on_first_use" } : {};
|
|
38
49
|
const refused = await entry.refusal(env, undefined, { atStart: true });
|
|
39
50
|
if (refused !== undefined)
|
|
40
|
-
return { id, available: false, steer: entry.steer, ...refused, ...firstUse };
|
|
51
|
+
return { id, ...named, available: false, steer: entry.steer, ...refused, ...firstUse };
|
|
41
52
|
// Available: which model keys run it here is what it would ask for with none of them (a key's row names it only
|
|
42
53
|
// when that key is one), so a row reads the same before and after another provider's key is saved.
|
|
43
54
|
const keyless = await entry.refusal(await withoutModelKeys(env), undefined, { atStart: true });
|
|
44
|
-
return { id, available: true, steer: entry.steer, ...(keyless?.keys?.length ? { keys: keyless.keys } : {}), ...firstUse };
|
|
55
|
+
return { id, ...named, available: true, steer: entry.steer, ...(keyless?.keys?.length ? { keys: keyless.keys } : {}), ...firstUse };
|
|
45
56
|
}));
|
|
46
57
|
// A harness that runs here but whose one run is more than this host's memory for runs never starts: said here, so
|
|
47
58
|
// a save warns and a run is refused at once with why (runnable.ts), never a 429 to try again. One that lacks only a
|
|
48
59
|
// key keeps its reason, but no key would run it: it has no `keys`.
|
|
49
60
|
const base = probed.map((offer) => {
|
|
50
|
-
const tooBig = offer.available || offer.keys ? neverFits(offer.id, memory) : undefined;
|
|
61
|
+
const tooBig = offer.available || offer.keys ? neverFits(offer.id, memory, env) : undefined;
|
|
51
62
|
if (!tooBig)
|
|
52
63
|
return offer;
|
|
53
64
|
const { keys: _keys, ...rest } = offer;
|
|
@@ -74,9 +85,9 @@ export function harnessOffers(env) {
|
|
|
74
85
|
// lacks only a key is (a save warns of that, never refuses).
|
|
75
86
|
const { MODEL_REF } = await import("./validate.js");
|
|
76
87
|
const { providerFor, HarnessUnavailable } = await import("./provider.js");
|
|
77
|
-
const {
|
|
88
|
+
const { adapterFactsOf } = await import("./adapter-facts.js");
|
|
78
89
|
const { FAUX_ENV } = await import("./model.js");
|
|
79
|
-
const facts =
|
|
90
|
+
const facts = adapterFactsOf(offer.id);
|
|
80
91
|
for (const id of new Set([...pickerCandidates(env, offer.id), ...free.map((m) => m.id)])) {
|
|
81
92
|
if (!MODEL_REF.test(id))
|
|
82
93
|
continue;
|
package/dist/host.d.ts
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import { statfs } from "node:fs/promises";
|
|
2
2
|
import type { Store } from "./store/index.js";
|
|
3
3
|
/** The port a server listens on unless --port says otherwise (cli.ts), and the one a standalone runner's loopback reads
|
|
4
|
-
* never go to (runner/main.ts runnerLoopback)
|
|
5
|
-
|
|
4
|
+
* never go to (runner/main.ts runnerLoopback); and the free disk under the data directory below which health fails,
|
|
5
|
+
* unless the server says otherwise. Both live in listen-first.ts, which the CLI loads before the rest of the server. */
|
|
6
|
+
export { DEFAULT_PORT, MIN_FREE_MIB } from "./listen-first.js";
|
|
6
7
|
/** Memory the server keeps for itself, before any run, in MiB. Measured with the runs' (harness-table.ts): the server's anon
|
|
7
8
|
* 3 s after its start, 32 starts at limits of 512M to 2048M, was 58 to 81 MB, with no peak at the start over that;
|
|
8
9
|
* reserved for the high end, 81, plus 47 (+58%), since what it holds grows with the agents and runs it keeps. That is
|
|
9
10
|
* with the pinned binaries' sha256 checked a chunk at a time: a start that reads the codex binary (294 MB) and the
|
|
10
11
|
* claude-agent CLI (230 MB) whole sat at 341 to 348 MB on a host of 1 GB or less. */
|
|
11
12
|
export declare const SERVER_MIB = 128;
|
|
12
|
-
/** Free disk under the data directory below which health fails, unless the server says otherwise. */
|
|
13
|
-
export declare const MIN_FREE_MIB = 64;
|
|
14
13
|
/** The memory this server may use: its container's limit when it has one (cgroup), else the machine's. */
|
|
15
14
|
export declare function hostMemory(): number;
|
|
16
15
|
/** The memory runs may hold on a host of `memory` bytes, in MiB: all of it less the server's own. */
|
|
17
16
|
export declare const runsMemoryMib: (memory: number) => number;
|
|
18
|
-
/** What a run of `harness` reserves, in MiB
|
|
19
|
-
|
|
17
|
+
/** What a run of `harness` reserves, in MiB: its entry's on the owner's table of `env` (harness-table.ts ownerHarness: a
|
|
18
|
+
* built-in's, or what a harness module declares; a test's stand-in reserves as the built-in it stands in for). A harness
|
|
19
|
+
* outside that table (no saved revision names one) reserves the most a built-in one does. */
|
|
20
|
+
export declare const runMibOf: (harness: string | undefined, env?: NodeJS.ProcessEnv) => number;
|
|
20
21
|
/** How many runs of `harness` alone fit on a host of `memory` bytes. One whose entry says one always fits (pi, the
|
|
21
22
|
* default) always has one place, as before runs were admitted by memory: a server too small for even that still runs
|
|
22
|
-
* one at a time. */
|
|
23
|
-
export declare function runsThatFit(harness: string, memory: number): number;
|
|
23
|
+
* one at a time. `env`: whose owner's table says what a run weighs (runMibOf). */
|
|
24
|
+
export declare function runsThatFit(harness: string, memory: number, env?: NodeJS.ProcessEnv): number;
|
|
24
25
|
/** The default cap on how many runs at once: as many pi runs, the smallest, as fit. */
|
|
25
26
|
export declare const defaultMaxRuns: (memory: number) => number;
|
|
26
|
-
/** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits.
|
|
27
|
-
|
|
27
|
+
/** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits. `env`: whose
|
|
28
|
+
* owner's table says what each run weighs (runMibOf), and which harnesses the words list. */
|
|
29
|
+
export declare function neverFits(harness: string, memory: number, env?: NodeJS.ProcessEnv): string | undefined;
|
|
28
30
|
/** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. A runner
|
|
29
31
|
* holds at most this many; a run past it waits queued, never refused for a place. */
|
|
30
32
|
export declare function maxRunsOf(env: NodeJS.ProcessEnv, given?: number): number;
|
package/dist/host.js
CHANGED
|
@@ -6,10 +6,11 @@ import { statfs } from "node:fs/promises";
|
|
|
6
6
|
import { totalmem } from "node:os";
|
|
7
7
|
import { REQUEST_BUSY_MS, whenFree } from "./agents.js";
|
|
8
8
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
9
|
-
import { builtinHarness } from "./harness-table.js";
|
|
9
|
+
import { builtinHarness, ownerHarness, ownerTable } from "./harness-table.js";
|
|
10
10
|
/** The port a server listens on unless --port says otherwise (cli.ts), and the one a standalone runner's loopback reads
|
|
11
|
-
* never go to (runner/main.ts runnerLoopback)
|
|
12
|
-
|
|
11
|
+
* never go to (runner/main.ts runnerLoopback); and the free disk under the data directory below which health fails,
|
|
12
|
+
* unless the server says otherwise. Both live in listen-first.ts, which the CLI loads before the rest of the server. */
|
|
13
|
+
export { DEFAULT_PORT, MIN_FREE_MIB } from "./listen-first.js";
|
|
13
14
|
const MiB = 2 ** 20;
|
|
14
15
|
/** Memory the server keeps for itself, before any run, in MiB. Measured with the runs' (harness-table.ts): the server's anon
|
|
15
16
|
* 3 s after its start, 32 starts at limits of 512M to 2048M, was 58 to 81 MB, with no peak at the start over that;
|
|
@@ -17,8 +18,6 @@ const MiB = 2 ** 20;
|
|
|
17
18
|
* with the pinned binaries' sha256 checked a chunk at a time: a start that reads the codex binary (294 MB) and the
|
|
18
19
|
* claude-agent CLI (230 MB) whole sat at 341 to 348 MB on a host of 1 GB or less. */
|
|
19
20
|
export const SERVER_MIB = 128;
|
|
20
|
-
/** Free disk under the data directory below which health fails, unless the server says otherwise. */
|
|
21
|
-
export const MIN_FREE_MIB = 64;
|
|
22
21
|
/** The memory this server may use: its container's limit when it has one (cgroup), else the machine's. */
|
|
23
22
|
export function hostMemory() {
|
|
24
23
|
const total = totalmem();
|
|
@@ -27,14 +26,16 @@ export function hostMemory() {
|
|
|
27
26
|
}
|
|
28
27
|
/** The memory runs may hold on a host of `memory` bytes, in MiB: all of it less the server's own. */
|
|
29
28
|
export const runsMemoryMib = (memory) => Math.floor(memory / MiB) - SERVER_MIB;
|
|
30
|
-
/** What a run of `harness` reserves, in MiB
|
|
31
|
-
|
|
29
|
+
/** What a run of `harness` reserves, in MiB: its entry's on the owner's table of `env` (harness-table.ts ownerHarness: a
|
|
30
|
+
* built-in's, or what a harness module declares; a test's stand-in reserves as the built-in it stands in for). A harness
|
|
31
|
+
* outside that table (no saved revision names one) reserves the most a built-in one does. */
|
|
32
|
+
export const runMibOf = (harness, env = {}) => ownerHarness(env, harness)?.runMib ?? Math.max(...HARNESSES.map((id) => builtinHarness(id).runMib));
|
|
32
33
|
/** How many runs of `harness` alone fit on a host of `memory` bytes. One whose entry says one always fits (pi, the
|
|
33
34
|
* default) always has one place, as before runs were admitted by memory: a server too small for even that still runs
|
|
34
|
-
* one at a time. */
|
|
35
|
-
export function runsThatFit(harness, memory) {
|
|
36
|
-
const fit = Math.max(0, Math.floor(runsMemoryMib(memory) / runMibOf(harness)));
|
|
37
|
-
return
|
|
35
|
+
* one at a time. `env`: whose owner's table says what a run weighs (runMibOf). */
|
|
36
|
+
export function runsThatFit(harness, memory, env = {}) {
|
|
37
|
+
const fit = Math.max(0, Math.floor(runsMemoryMib(memory) / runMibOf(harness, env)));
|
|
38
|
+
return ownerHarness(env, harness)?.oneAlwaysFits ? Math.max(1, fit) : fit;
|
|
38
39
|
}
|
|
39
40
|
/** The default cap on how many runs at once: as many pi runs, the smallest, as fit. */
|
|
40
41
|
export const defaultMaxRuns = (memory) => runsThatFit(DEFAULT_HARNESS, memory);
|
|
@@ -43,12 +44,14 @@ const sizeOf = (mib) => `${Math.round(mib)} MB`;
|
|
|
43
44
|
const aRun = (harness) => `${/^[aeiou]/i.test(harness) ? "an" : "a"} ${harness} run`;
|
|
44
45
|
/** "pi", "pi and codex", "pi, claude-agent and codex". */
|
|
45
46
|
const listed = (names) => (names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names.join(""));
|
|
46
|
-
/** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits.
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits. `env`: whose
|
|
48
|
+
* owner's table says what each run weighs (runMibOf), and which harnesses the words list. */
|
|
49
|
+
export function neverFits(harness, memory, env = {}) {
|
|
50
|
+
if (runsThatFit(harness, memory, env) > 0)
|
|
49
51
|
return undefined;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
// Those the server lists (an entry it hides, Goose before it is installed, is never named: harness-table.ts hidden).
|
|
53
|
+
const fit = Object.entries(ownerTable(env)).filter(([id, entry]) => entry.hidden?.(env) === undefined && runsThatFit(id, memory, env) > 0).map(([id]) => id);
|
|
54
|
+
return `This server has ${sizeOf(memory / MiB)} of memory and keeps ${sizeOf(SERVER_MIB)} for itself; ${aRun(harness)} needs about ${sizeOf(runMibOf(harness, env))} more, so it can't start here. ${listed(fit)} runs fit.`;
|
|
52
55
|
}
|
|
53
56
|
/** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. A runner
|
|
54
57
|
* holds at most this many; a run past it waits queued, never refused for a place. */
|
package/dist/import-worker.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./quiet-sqlite-warning.js";
|
|
2
|
+
import { type ImportCandidate } from "./import.js";
|
|
2
3
|
/** `secrets`: the server's own, cut out of everything the import writes and never put in an environment; the seal key
|
|
3
4
|
* among them, so the worker opens the saved tool keys the import cuts too (read over the port from the server's store). */
|
|
4
5
|
export type ImportTask = {
|
|
@@ -7,12 +8,14 @@ export type ImportTask = {
|
|
|
7
8
|
home: string;
|
|
8
9
|
temp?: string;
|
|
9
10
|
secrets?: Record<string, string>;
|
|
11
|
+
projects?: readonly string[];
|
|
10
12
|
};
|
|
11
13
|
/** `took`: what this start's import took (stopped too: what it took before it stopped), its agents by id, so the server
|
|
12
14
|
* adds it to what earlier starts took. */
|
|
13
15
|
export type ImportAnswer = {
|
|
14
16
|
projects: number;
|
|
15
17
|
sessions: number;
|
|
18
|
+
candidates: ImportCandidate[];
|
|
16
19
|
} | {
|
|
17
20
|
took: {
|
|
18
21
|
agents: string[];
|
package/dist/import-worker.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// Setup's import of this machine's sessions, on a worker thread: node:sqlite's wait for a busy store and the parsing of
|
|
2
2
|
// every session line happen here, so neither holds up a request the server answers. `plan` counts what an import would
|
|
3
|
-
// take
|
|
3
|
+
// take, and names its projects for the owner to choose from; `import` takes it, only the projects chosen when some were
|
|
4
|
+
// (`projects`). The message "stop" ends either between two files or two sessions; what is written stays, and
|
|
4
5
|
// the next import goes on from there. Its one message back is its answer.
|
|
5
6
|
// Before anything loads node:sqlite, as in the server's own thread: its ExperimentalWarning is not the server's to print.
|
|
6
7
|
import "./quiet-sqlite-warning.js";
|
|
7
8
|
import { parentPort, workerData } from "node:worker_threads";
|
|
8
|
-
import { ownSecrets, planImport, runImport } from "./import.js";
|
|
9
|
+
import { candidatesOf, ownSecrets, planImport, runImport, sessionsOf } from "./import.js";
|
|
9
10
|
import { importStoreProxy } from "./import-proxy.js";
|
|
10
11
|
import { toolKeysOverStore } from "./tool-keys-store.js";
|
|
11
|
-
const { task, data, home, temp, secrets = {} } = workerData;
|
|
12
|
+
const { task, data, home, temp, secrets = {}, projects } = workerData;
|
|
12
13
|
const stop = new AbortController();
|
|
13
14
|
parentPort.on("message", (message) => void (message === "stop" && stop.abort()));
|
|
14
15
|
// The port does not keep the thread alive on its own: the task does (the proxy references it only while it waits for the
|
|
@@ -25,7 +26,7 @@ const answer = async () => {
|
|
|
25
26
|
// A count keeps no transcript: no key scan (a whole history read through secretlint at every start).
|
|
26
27
|
const plan = await planImport({ ...options, keys: false });
|
|
27
28
|
// Sessions as the import takes them: a session written in several files (a resumed thread) is one run.
|
|
28
|
-
return stop.signal.aborted ? { stopped: true } : { projects: plan.projects.length, sessions: plan.projects.reduce((n, p) => n +
|
|
29
|
+
return stop.signal.aborted ? { stopped: true } : { projects: plan.projects.length, sessions: plan.projects.reduce((n, p) => n + sessionsOf(p.sessions).length, 0), candidates: candidatesOf(plan, env) };
|
|
29
30
|
}
|
|
30
31
|
// No store of its own: the worker reaches the server's one open store over the port. The server holds the exclusive owner
|
|
31
32
|
// lock, so a second opener here would be refused; every read and write the import needs crosses the port instead.
|
|
@@ -35,7 +36,8 @@ const answer = async () => {
|
|
|
35
36
|
const keys = toolKeysOverStore(store, env, () => { });
|
|
36
37
|
await keys.load();
|
|
37
38
|
// The secrets this server made and keeps, read from the store as the import starts: cut by their values too.
|
|
38
|
-
|
|
39
|
+
// The owner's choice, when the setup named projects: nothing of another project is read for keys or written.
|
|
40
|
+
const taking = { ...options, stored: keys.values(), own: await ownSecrets(store, data, env), ...(projects ? { only: projects } : {}) };
|
|
39
41
|
const report = await runImport(store, await planImport(taking, store), taking);
|
|
40
42
|
const took = { agents: report.agents.filter((a) => a.runs > 0).map((a) => a.id), runs: report.agents.reduce((n, a) => n + a.runs, 0), skipped: report.skipped.length };
|
|
41
43
|
return stop.signal.aborted ? { took, stopped: true } : { took };
|