@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.46
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 +148 -5
- package/README.md +385 -305
- 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 +62 -19
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- 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/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-C2MYaUBa.css +1 -0
- package/dist/console/assets/index-CZZeCReB.js +701 -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 +3 -1
- package/dist/errors.js +7 -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 +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/import.d.ts +10 -0
- package/dist/import.js +28 -8
- 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 +23 -89
- package/dist/learn/check.js +57 -335
- 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 +89 -104
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- 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 +23 -5
- package/dist/learn/promote.js +40 -2
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +21 -10
- package/dist/learning-setting.js +47 -11
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- 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 +273 -319
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- 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 +15 -1
- 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 +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- 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 +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +30 -13
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +35 -13
- package/dist/runner/conformance/subject.d.ts +6 -0
- 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 +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -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 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +82 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- 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 +12 -8
- package/dist/runner/promotion.js +37 -28
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- 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 +1230 -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 +1 -5
- 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 +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- 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 +55 -33
- package/dist/server.js +689 -322
- 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 +2 -2
- package/dist/store/index.js +1 -1
- 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/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +8 -4
- package/dist/templates.js +44 -6
- 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/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +65 -6
- package/dist/triggers.js +125 -19
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +7 -2
- package/dist/webhooks.js +12 -5
- 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 +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- 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 +33 -19
- 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 -10
- package/templates/README.md +8 -8
- package/templates/inbound-lead/agent.md +5 -4
- 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/kyb/agent.md +2 -1
- 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-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.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 -35
- package/dist/learning-evals.js +0 -99
- 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,28 @@
|
|
|
1
|
+
import type { AdapterFacts, AgentAdapter } from "@parcha/agentrun-kernel";
|
|
2
|
+
export declare const ACP_PACKAGE = "@parcha/agentrun-harness-acp";
|
|
3
|
+
/** One platform's Goose release, as the pin holds it (the package's AcpArchivePin). */
|
|
4
|
+
export type AcpRelease = {
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly format: string;
|
|
7
|
+
readonly sha256: string;
|
|
8
|
+
readonly cmd: string;
|
|
9
|
+
readonly binarySha256?: string;
|
|
10
|
+
};
|
|
11
|
+
/** What serve reads of the package. */
|
|
12
|
+
export type AcpPackage = {
|
|
13
|
+
readonly gooseFacts: AdapterFacts;
|
|
14
|
+
readonly GOOSE_PIN: {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly version: string;
|
|
17
|
+
readonly archives: Readonly<Partial<Record<string, AcpRelease>>>;
|
|
18
|
+
};
|
|
19
|
+
readonly GOOSE_INSTALL: string;
|
|
20
|
+
readonly GOOSE_NOT_INSTALLED: string;
|
|
21
|
+
acpPlatform(): string | undefined;
|
|
22
|
+
gooseAdapter(options: Record<string, unknown>): AgentAdapter;
|
|
23
|
+
verifyPinnedBinary(path: string, sha256: string): void;
|
|
24
|
+
verifyPinnedBinaryAsync(path: string, sha256: string): Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
/** The package, or undefined where it is not installed beside serve. Only its absence is: a package that is there and
|
|
27
|
+
* fails to load throws. */
|
|
28
|
+
export declare function acpPackage(): AcpPackage | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// The ACP harnesses' package (@parcha/agentrun-harness-acp: Goose's adapter, its pin and its facts), loaded here alone, by
|
|
2
|
+
// name, when serve first asks for it. The package is held from npm for now (its manifest is private), so a serve
|
|
3
|
+
// installed from npm runs without it, and its harness table has no goose row; in this repository it is always beside
|
|
4
|
+
// serve. A leaf: the harness table's own imports (adapter-facts.ts) read it in any import order.
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
export const ACP_PACKAGE = "@parcha/agentrun-harness-acp";
|
|
7
|
+
const requireHere = createRequire(import.meta.url);
|
|
8
|
+
let loaded;
|
|
9
|
+
/** The package, or undefined where it is not installed beside serve. Only its absence is: a package that is there and
|
|
10
|
+
* fails to load throws. */
|
|
11
|
+
export function acpPackage() {
|
|
12
|
+
if (loaded === undefined) {
|
|
13
|
+
let found = true;
|
|
14
|
+
try {
|
|
15
|
+
requireHere.resolve(ACP_PACKAGE);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
found = false;
|
|
19
|
+
}
|
|
20
|
+
loaded = found ? requireHere(ACP_PACKAGE) : null;
|
|
21
|
+
}
|
|
22
|
+
return loaded ?? undefined;
|
|
23
|
+
}
|
package/dist/adapter-facts.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { AdapterFacts } from "@parcha/agentrun-kernel";
|
|
2
|
-
/** The adapter harnesses' facts: claude-agent's, codex's and opencode's. */
|
|
2
|
+
/** The adapter harnesses' facts: claude-agent's, codex's and opencode's, the built-in harnesses the API names (HARNESSES). */
|
|
3
3
|
export declare const ADAPTER_FACTS: readonly AdapterFacts[];
|
|
4
|
+
/** Goose's facts (its package's, acp-package.ts), or undefined where that package is not beside serve: then the table has
|
|
5
|
+
* no goose row. Goose is listed only while its owner has installed it, so it is not one of HARNESSES. */
|
|
6
|
+
export declare const GOOSE_FACTS: AdapterFacts | undefined;
|
|
7
|
+
/** Every adapter harness's facts: the built-in ones, then Goose's where its package is. */
|
|
8
|
+
export declare const EVERY_ADAPTER_FACTS: readonly AdapterFacts[];
|
|
9
|
+
/** The facts of the adapter harness `id`, built-in or Goose; undefined for pi and for an id no adapter states. */
|
|
10
|
+
export declare const adapterFactsOf: (id: string) => AdapterFacts | undefined;
|
package/dist/adapter-facts.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { facts as claudeFacts } from "@parcha/agentrun-harness-claude/facts";
|
|
2
2
|
import { facts as codexFacts } from "@parcha/agentrun-harness-codex/facts";
|
|
3
3
|
import { facts as openCodeFacts } from "./harness-opencode/facts.js";
|
|
4
|
-
|
|
4
|
+
import { acpPackage } from "./acp-package.js";
|
|
5
|
+
/** The adapter harnesses' facts: claude-agent's, codex's and opencode's, the built-in harnesses the API names (HARNESSES). */
|
|
5
6
|
export const ADAPTER_FACTS = Object.freeze([claudeFacts, codexFacts, openCodeFacts]);
|
|
7
|
+
/** Goose's facts (its package's, acp-package.ts), or undefined where that package is not beside serve: then the table has
|
|
8
|
+
* no goose row. Goose is listed only while its owner has installed it, so it is not one of HARNESSES. */
|
|
9
|
+
export const GOOSE_FACTS = acpPackage()?.gooseFacts;
|
|
10
|
+
/** Every adapter harness's facts: the built-in ones, then Goose's where its package is. */
|
|
11
|
+
export const EVERY_ADAPTER_FACTS = Object.freeze([...ADAPTER_FACTS, ...(GOOSE_FACTS ? [GOOSE_FACTS] : [])]);
|
|
12
|
+
/** The facts of the adapter harness `id`, built-in or Goose; undefined for pi and for an id no adapter states. */
|
|
13
|
+
export const adapterFactsOf = (id) => EVERY_ADAPTER_FACTS.find((facts) => facts.id === id);
|
package/dist/adapters.d.ts
CHANGED
|
@@ -148,6 +148,11 @@ export declare function codexOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds, loa
|
|
|
148
148
|
* its wire's do (providerFor): serve's gateway (AGENT_MODEL_BASE_URL), OpenAI or OpenRouter, on the Responses API,
|
|
149
149
|
* through the adapter's proxy. */
|
|
150
150
|
export declare function opencodeOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds, load?: () => Promise<typeof import("./harness-opencode/index.js")>, npx?: boolean): Promise<AgentAdapter>;
|
|
151
|
+
/** Goose's adapter (its package's gooseAdapter, acp-package.ts), on the binary its owner installed into the data's
|
|
152
|
+
* harnesses directory (`agentrun harness install goose`, harness-goose.ts) and from nowhere else: not there, or not the
|
|
153
|
+
* pinned binary, it says that command, and nothing here installs it. Its model goes where claude-agent's does (the host's
|
|
154
|
+
* Anthropic Messages provider, providerFor), through a model proxy of its own, priced and capped as every run is. */
|
|
155
|
+
export declare function gooseOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds): Promise<AgentAdapter>;
|
|
151
156
|
/** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
|
|
152
157
|
* the adapter's own check of the model `given` names (with none, a model of its wire's vendor: whether it runs here at
|
|
153
158
|
* all). `atStart`: asked by the start's probe, whose offers hold until a restart, so a reason installing fixes ends
|
package/dist/adapters.js
CHANGED
|
@@ -15,7 +15,7 @@ import { DATA_ENV, defaultData } from "./files.js";
|
|
|
15
15
|
import { harnessOf, onAdapter } from "./harness-table.js";
|
|
16
16
|
import { HarnessUnavailable, providerFor } from "./provider.js";
|
|
17
17
|
import { keyShaped } from "./secret-cut.js";
|
|
18
|
-
import { servedSkills } from "./learn/
|
|
18
|
+
import { servedSkills } from "./learn/workflow-draft.js";
|
|
19
19
|
import { runKeyOf } from "./key-refusal.js";
|
|
20
20
|
import { planeOf } from "./tool-plane.js";
|
|
21
21
|
import { NATIVE_SEARCH_ALLOWANCE_TOKENS } from "./cap.js";
|
|
@@ -291,7 +291,10 @@ export async function claudeOf(env, needs, load = loadClaude, sdkOf = (version,
|
|
|
291
291
|
// order (the SDK before the CLI).
|
|
292
292
|
await claude.verifyClaudeAgentCliAsync(sdk.cliPath);
|
|
293
293
|
// The skills only when there are some: with none, the adapter keeps its Skill tool off.
|
|
294
|
-
|
|
294
|
+
// On Claude Code's login on this machine: the login's directories in place of a provider, billed to the plan, never
|
|
295
|
+
// priced here.
|
|
296
|
+
const source = provider?.login ? { login: provider.login, price: () => null } : { provider: endpoint, price: priceOf(priced) };
|
|
297
|
+
adapter = claude.claudeAgentAdapter({ model: { default: provider?.modelId ?? native.model.modelId }, ...source, log: harnessLog(claudeFacts.id, env), sdk: sdk.sdk, sdkVersion: sdk.sdkVersion, cliPath: sdk.cliPath, mcp: sdk.mcp, ...(needs.confine ? { confine: needs.confine } : {}), ...(needs.skills?.length ? { skills: needs.skills } : {}), ...(needs.now ? { now: needs.now } : {}), ...(needs.zone ? { zone: needs.zone } : {}), ...nativeOptions(claudeFacts, env) });
|
|
295
298
|
}
|
|
296
299
|
catch (error) {
|
|
297
300
|
// The adapter's own install line is a project's; here Claude Code is installed into the data's harnesses directory.
|
|
@@ -362,10 +365,40 @@ export async function opencodeOf(env, needs, load = () => import("./harness-open
|
|
|
362
365
|
const provider = providerFor(openCodeFacts.wire, env, needs.model, openCodeFacts.id);
|
|
363
366
|
// Its instructions list each skill by the description its SKILL.md's front matter gives on one LF line, which is all the
|
|
364
367
|
// adapter reads: each SKILL.md goes as servedSkill writes it (its name and description, as a prompt reads them, on one
|
|
365
|
-
// line each),
|
|
368
|
+
// line each), so a CRLF file or a folded description is listed by its own words.
|
|
366
369
|
const skills = needs.skills && servedSkills(needs.skills);
|
|
367
370
|
return opencode.openCodeAdapter({ model: provider.modelId, provider: { origin: provider.origin, credential: provider.credential }, price: priceOf({ ...needs, model: provider.priceModel }), log: harnessLog(openCodeFacts.id, env), ...(needs.confine ? { confine: needs.confine } : {}), ...(skills?.length ? { skills } : {}), ...(standIn ? { standIn } : {}) });
|
|
368
371
|
}
|
|
372
|
+
/** Goose's adapter (its package's gooseAdapter, acp-package.ts), on the binary its owner installed into the data's
|
|
373
|
+
* harnesses directory (`agentrun harness install goose`, harness-goose.ts) and from nowhere else: not there, or not the
|
|
374
|
+
* pinned binary, it says that command, and nothing here installs it. Its model goes where claude-agent's does (the host's
|
|
375
|
+
* Anthropic Messages provider, providerFor), through a model proxy of its own, priced and capped as every run is. */
|
|
376
|
+
export async function gooseOf(env, needs) {
|
|
377
|
+
const [{ acpPackage }, { gooseMissing, GOOSE_ID }] = await Promise.all([import("./acp-package.js"), import("./harness-goose.js")]);
|
|
378
|
+
const acp = acpPackage();
|
|
379
|
+
// What no key fixes is said first, as claudeOf does: the binary, checked off the event loop.
|
|
380
|
+
const found = await gooseMissing(env);
|
|
381
|
+
if ("missing" in found)
|
|
382
|
+
throw new HarnessUnavailable(found.missing.message, acp && fixOf(acp.gooseFacts, found.missing));
|
|
383
|
+
if (!acp)
|
|
384
|
+
throw new HarnessUnavailable("Goose's adapter is not installed beside this server");
|
|
385
|
+
const facts = acp.gooseFacts;
|
|
386
|
+
const provider = providerFor(facts.wire, env, needs.model, GOOSE_ID);
|
|
387
|
+
// A person's Claude Code login is its CLI's alone (claude-login.ts): Goose's requests never go on it.
|
|
388
|
+
if (provider.login)
|
|
389
|
+
throw new HarnessUnavailable("Goose runs on a model key: Claude Code's login on this machine is its CLI's alone.", undefined, ["ANTHROPIC_API_KEY", "OPENROUTER_API_KEY"]);
|
|
390
|
+
try {
|
|
391
|
+
return acp.gooseAdapter({
|
|
392
|
+
binary: found.binary, sha256: found.sha256, model: provider.modelId,
|
|
393
|
+
provider: { origin: provider.origin, credential: provider.credential, ...(provider.auth ? { auth: provider.auth } : {}) },
|
|
394
|
+
price: priceOf({ ...needs, model: provider.priceModel }), log: harnessLog(GOOSE_ID, env),
|
|
395
|
+
...(needs.confine ? { confine: needs.confine } : {}),
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
throw new HarnessUnavailable(error.message, fixOf(facts, error));
|
|
400
|
+
}
|
|
401
|
+
}
|
|
369
402
|
/** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
|
|
370
403
|
* the adapter's own check of the model `given` names (with none, a model of its wire's vendor: whether it runs here at
|
|
371
404
|
* all). `atStart`: asked by the start's probe, whose offers hold until a restart, so a reason installing fixes ends
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Store } from "./store/index.js";
|
|
2
|
+
/** The delete of an agent's learning: the server's is the learning module's deleteLearning over the agent's learning
|
|
3
|
+
* folder (learn/delete.ts). Idempotent; refuses with LearningInFlight while learning work of the agent is in flight. */
|
|
4
|
+
export type DeleteLearning = (store: Store, agentId: string) => Promise<unknown>;
|
|
5
|
+
/** A point of a delete a test may stop it at (AgentDeleteHost.at): after step 1, after step 2, in step 3 between a
|
|
6
|
+
* trigger's removal upstream and its settings', between its settings' and its row's, and in step 3 once its triggers
|
|
7
|
+
* and the agent's first run are gone. */
|
|
8
|
+
export type AgentDeleteStep = "after_step_1" | "after_step_2" | "in_step_3_trigger" | "in_step_3_trigger_settings" | "in_step_3";
|
|
9
|
+
/** What a delete does outside the store's own rows, as the server does it. */
|
|
10
|
+
export interface AgentDeleteHost {
|
|
11
|
+
readonly store: Store;
|
|
12
|
+
readonly deleteLearning: DeleteLearning;
|
|
13
|
+
/** Step 1's mark: the agent archived, its triggers off in the same commit (the trigger engine's agentArchived). */
|
|
14
|
+
refuse(agentId: string): Promise<void>;
|
|
15
|
+
/** The cancel path, for one run that is not final: true once a cancel stands for it (written now, or the run is ending
|
|
16
|
+
* already), false when this server cannot end it (an SDK run, which only its application ends; an imported run). */
|
|
17
|
+
cancel(runId: string): Promise<boolean>;
|
|
18
|
+
/** One trigger's registration upstream removed, the trigger kept (the trigger engine's removeThere); an ApiError
|
|
19
|
+
* (503 unavailable) while it is not. */
|
|
20
|
+
removeTriggerThere(triggerId: string): Promise<void>;
|
|
21
|
+
/** Then its adapter settings, the trigger kept (the engine's removeSettings): they have no link to its row. */
|
|
22
|
+
removeTriggerSettings(triggerId: string): Promise<void>;
|
|
23
|
+
/** Then the trigger itself, its row (the engine's removeHere, which removes any settings left first). */
|
|
24
|
+
removeTrigger(triggerId: string): Promise<void>;
|
|
25
|
+
/** Every saved sign-in of the agent forgotten, its object at the vendor deleted; an ApiError (503 unavailable) while a
|
|
26
|
+
* vendor has not deleted one, each kept as a tombstone for the next call. */
|
|
27
|
+
forgetSignIns(agentId: string): Promise<void>;
|
|
28
|
+
/** The agent's own computer deleted at its provider, and its record with it; an ApiError while it cannot be yet. */
|
|
29
|
+
removeOwnComputer(agentId: string): Promise<void>;
|
|
30
|
+
/** The agent's Archil disk deleted, when one is stored on it, whatever the server's Archil settings are now
|
|
31
|
+
* (archil-routes.ts removeAgentDisk); an ApiError (503 unavailable) while it is not, Archil off included. */
|
|
32
|
+
removeDisk(agentId: string): Promise<void>;
|
|
33
|
+
/** A final run's things outside its rows: its folders (its own folder on an Archil disk its launch named, read from its
|
|
34
|
+
* launch record, which goes with its rows after; an ApiError (503 unavailable) while that folder is not deleted
|
|
35
|
+
* there), its settings, the answers kept under its idempotency keys. */
|
|
36
|
+
forgetRun(agentId: string, runId: string): Promise<void>;
|
|
37
|
+
/** The agent's things outside its rows: its folders, its settings, the answers kept under its idempotency keys. */
|
|
38
|
+
forgetAgent(agentId: string): Promise<void>;
|
|
39
|
+
/** How long step 1 waits for the agent's runs to be final, and how often it reads them meanwhile. */
|
|
40
|
+
readonly waitMs: number;
|
|
41
|
+
readonly pollMs: number;
|
|
42
|
+
/** A test's seam: awaited at each step's point, so a throw there stops the delete as a crash would. */
|
|
43
|
+
at?(step: AgentDeleteStep, agentId: string): void | Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/** Deletes agent `agentId` (another system's, as the route checked) in the three steps above. Throws ApiError
|
|
46
|
+
* runs_in_flight while a run of it is not final by the wait's end, learning_busy while its learning refuses. */
|
|
47
|
+
export declare function deleteExternalAgent(host: AgentDeleteHost, agentId: string): Promise<void>;
|
|
48
|
+
/** One delete of an agent at a time: a second DELETE of the same agent waits for the first, then finds it gone (404) or
|
|
49
|
+
* finishes what the first left. */
|
|
50
|
+
export declare function oneAtATime(): <T>(agentId: string, work: () => Promise<T>) => Promise<T>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// DELETE /v2/agents/{agent_id}: an agent another system owns (made by an inline run, POST /runs with `external`) deleted
|
|
2
|
+
// whole, for a host that must delete what it sent. An agent made here is archived instead (409 agent_not_external).
|
|
3
|
+
//
|
|
4
|
+
// In order, each step finished before the next:
|
|
5
|
+
// 1. The agent refuses new runs, as a mark in the store that outlives a restart: its archive time, which only this
|
|
6
|
+
// delete writes on an agent another system owns (its archive route is refused), set by the trigger engine with its
|
|
7
|
+
// triggers off in the same commit. From that commit a person's run, an inline run, a trigger's firing, an SDK run and
|
|
8
|
+
// a follow-up that would open one of its runs again are refused (store AgentDeleting / AgentArchived, each read in
|
|
9
|
+
// the transaction that would start the run). Then each of its runs not yet final, its learning runs included, is
|
|
10
|
+
// cancelled through the cancel path, and waited for until it is final.
|
|
11
|
+
// 2. Its learning, by the learning module's deleteLearning (learn/delete.ts: its learning folder's files, then its
|
|
12
|
+
// promotions and grades; idempotent; it refuses with LearningInFlight while learning work
|
|
13
|
+
// is in flight, which answers 409 learning_busy with the agent left refusing runs).
|
|
14
|
+
// 3. Its things: its triggers through the trigger engine (each one's registration upstream first, then its adapter
|
|
15
|
+
// settings, then its row), its saved sign-ins (each vendor object too), its own computer, its Archil disk; then each
|
|
16
|
+
// run's folders (on a disk its launch named, the caller's, too: the run's own folder there, never the disk), settings
|
|
17
|
+
// and kept answers, and its rows (store runs.remove); then the agent's folders, settings and kept answers, and its
|
|
18
|
+
// rows (store agents.remove, which commits last).
|
|
19
|
+
// A DELETE stopped at any step finds the agent still there, marked, and does every step again: each is idempotent, so the
|
|
20
|
+
// next DELETE finishes it. Once the agent's row is gone the agent is unknown: 404. Nothing the agent owns elsewhere (a
|
|
21
|
+
// trigger's registration upstream, a saved sign-in at its vendor, its own computer, its Archil disk, a run's folder on a
|
|
22
|
+
// disk its launch named) is left with the agent's row gone: the record here that names it (for a run's folder, its launch
|
|
23
|
+
// record) is removed only once it is deleted there, and while it is not, the
|
|
24
|
+
// delete stops with 503 unavailable, the agent kept and refusing runs, for the next DELETE to finish. From step 1's mark
|
|
25
|
+
// the agent takes no new trigger, off or on (the trigger engine and the store refuse it), and no write to its home or its
|
|
26
|
+
// learning (the server's, in the delete's turn); a trigger that reached it anyway keeps its row (store TriggersLeft): the
|
|
27
|
+
// same 503, and the next DELETE removes that trigger as it removes the others.
|
|
28
|
+
import { ApiError } from "./errors.js";
|
|
29
|
+
import { LearningInFlight } from "./learn/delete.js";
|
|
30
|
+
import { FINAL_STATES, TriggersLeft } from "./store/index.js";
|
|
31
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
32
|
+
const isFinal = (state) => FINAL_STATES.includes(state);
|
|
33
|
+
/** Deletes agent `agentId` (another system's, as the route checked) in the three steps above. Throws ApiError
|
|
34
|
+
* runs_in_flight while a run of it is not final by the wait's end, learning_busy while its learning refuses. */
|
|
35
|
+
export async function deleteExternalAgent(host, agentId) {
|
|
36
|
+
// 1. No new run, then none in flight.
|
|
37
|
+
await host.refuse(agentId);
|
|
38
|
+
await stopRuns(host, agentId);
|
|
39
|
+
await host.at?.("after_step_1", agentId);
|
|
40
|
+
// 2. Its learning. Its refusal while learning work is in flight is learning_busy; any other failure is the server's own.
|
|
41
|
+
try {
|
|
42
|
+
await host.deleteLearning(host.store, agentId);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (!(error instanceof LearningInFlight))
|
|
46
|
+
throw error;
|
|
47
|
+
throw new ApiError("learning_busy", `The agent ${agentId}'s learning could not be deleted yet (${error.message}). The agent starts no run meanwhile: send the DELETE again later to finish it.`, { details: { runs: [...error.runs] }, retry_after_ms: 5_000 });
|
|
48
|
+
}
|
|
49
|
+
await host.at?.("after_step_2", agentId);
|
|
50
|
+
// 3. Its things, then its rows; the agent's row last.
|
|
51
|
+
for (const trigger of await host.store.triggers.list(agentId)) {
|
|
52
|
+
// Upstream first, then its settings, then its row: the row names what is left to remove until each is gone.
|
|
53
|
+
await host.removeTriggerThere(trigger.id);
|
|
54
|
+
await host.at?.("in_step_3_trigger", agentId);
|
|
55
|
+
await host.removeTriggerSettings(trigger.id);
|
|
56
|
+
await host.at?.("in_step_3_trigger_settings", agentId);
|
|
57
|
+
await host.removeTrigger(trigger.id);
|
|
58
|
+
}
|
|
59
|
+
await host.forgetSignIns(agentId);
|
|
60
|
+
await host.removeOwnComputer(agentId);
|
|
61
|
+
await host.removeDisk(agentId);
|
|
62
|
+
let first = true;
|
|
63
|
+
for (const run of await host.store.runs.every(agentId)) {
|
|
64
|
+
await host.forgetRun(agentId, run.id);
|
|
65
|
+
await host.store.runs.remove(run.id);
|
|
66
|
+
if (first)
|
|
67
|
+
await host.at?.("in_step_3", agentId);
|
|
68
|
+
first = false;
|
|
69
|
+
}
|
|
70
|
+
await host.forgetAgent(agentId);
|
|
71
|
+
try {
|
|
72
|
+
await host.store.agents.remove(agentId);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// A trigger that reached the agent after the listing above (the store refuses one once the agent is marked; this is
|
|
76
|
+
// its backstop): the agent is kept, refusing, for the next DELETE to remove it upstream, its settings, then its row.
|
|
77
|
+
if (!(error instanceof TriggersLeft))
|
|
78
|
+
throw error;
|
|
79
|
+
throw new ApiError("unavailable", `The agent ${agentId} has ${error.triggerIds.length === 1 ? "a trigger" : "triggers"} made while it was being deleted (${error.triggerIds.join(", ")}), not removed yet. It starts no run meanwhile: send the DELETE again to finish it.`, { details: { triggers: error.triggerIds }, retry_after_ms: 5_000 });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Step 1's second half: each run of the agent not final cancelled once, then read again until every one is final. A run's
|
|
83
|
+
* end may queue its learning run, so the runs are listed again on each read. A run this server cannot end, or one still
|
|
84
|
+
* going at the wait's end, is 409 runs_in_flight, the agent left refusing runs. */
|
|
85
|
+
async function stopRuns(host, agentId) {
|
|
86
|
+
const deadline = Date.now() + host.waitMs;
|
|
87
|
+
const asked = new Set();
|
|
88
|
+
for (;;) {
|
|
89
|
+
const live = (await host.store.runs.every(agentId)).filter((run) => !isFinal(run.state));
|
|
90
|
+
if (live.length === 0)
|
|
91
|
+
return;
|
|
92
|
+
const unended = [];
|
|
93
|
+
for (const run of live) {
|
|
94
|
+
if (asked.has(run.id))
|
|
95
|
+
continue;
|
|
96
|
+
if (await host.cancel(run.id))
|
|
97
|
+
asked.add(run.id);
|
|
98
|
+
else
|
|
99
|
+
unended.push(run.id);
|
|
100
|
+
}
|
|
101
|
+
if (unended.length) {
|
|
102
|
+
throw new ApiError("runs_in_flight", `The agent ${agentId} has ${unended.length === 1 ? "a run" : "runs"} this server cannot end (${unended.join(", ")}): an SDK run is ended by its application. It starts no run meanwhile: send the DELETE again once ${unended.length === 1 ? "it has" : "they have"} ended.`, { details: { runs: unended }, retry_after_ms: 5_000 });
|
|
103
|
+
}
|
|
104
|
+
if (Date.now() >= deadline) {
|
|
105
|
+
throw new ApiError("runs_in_flight", `The agent ${agentId}'s runs were cancelled and ${live.length === 1 ? "one has" : `${live.length} have`} not ended yet (${live.map((run) => run.id).join(", ")}). It starts no run meanwhile: send the DELETE again to finish it.`, { details: { runs: live.map((run) => run.id) }, retry_after_ms: 2_000 });
|
|
106
|
+
}
|
|
107
|
+
await sleep(host.pollMs);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** One delete of an agent at a time: a second DELETE of the same agent waits for the first, then finds it gone (404) or
|
|
111
|
+
* finishes what the first left. */
|
|
112
|
+
export function oneAtATime() {
|
|
113
|
+
const turns = new Map();
|
|
114
|
+
return (agentId, work) => {
|
|
115
|
+
const before = turns.get(agentId) ?? Promise.resolve();
|
|
116
|
+
const turn = before.then(work, work);
|
|
117
|
+
const settled = turn.then(() => undefined, () => undefined);
|
|
118
|
+
turns.set(agentId, settled);
|
|
119
|
+
void settled.then(() => {
|
|
120
|
+
if (turns.get(agentId) === settled)
|
|
121
|
+
turns.delete(agentId);
|
|
122
|
+
});
|
|
123
|
+
return turn;
|
|
124
|
+
};
|
|
125
|
+
}
|
package/dist/agents-store.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export type AgentEntry = {
|
|
|
16
16
|
version: number;
|
|
17
17
|
revisions: number;
|
|
18
18
|
sizes: Map<string, number>;
|
|
19
|
-
/** The template package it was applied from, as
|
|
19
|
+
/** The template package it was last applied from, as the newest revision an apply wrote keeps it (its first, until an
|
|
20
|
+
* apply with agent_id updates it); absent or null for one made otherwise. */
|
|
20
21
|
template?: TemplatePackage | null;
|
|
21
22
|
};
|
|
22
23
|
/** Refuses a write to an externally owned agent: one that mirrors an agent in another system (its `externalRef` set) is
|
|
@@ -77,11 +78,16 @@ export declare function makeRevision(definition: Json, files: Record<string, str
|
|
|
77
78
|
* holds across every server on the store. `check` may refuse the revision before a write; it runs outside the write, so
|
|
78
79
|
* another request may move the current revision meanwhile: an edit with If-Match is then precondition_failed, and one
|
|
79
80
|
* without is built and checked again on the new current revision, so what it leaves out (skill files, harness, place, learning, cap) is never carried over from a
|
|
80
|
-
* revision it does not follow. `contract`: an edit that always makes a new revision, even one equal to the current.
|
|
81
|
-
|
|
81
|
+
* revision it does not follow. `contract`: an edit that always makes a new revision, even one equal to the current.
|
|
82
|
+
* `template`: the package an apply with agent_id wrote it from, kept on the revision (getAgent's `template`).
|
|
83
|
+
* `fromPackage`: the definition is a whole package's (an apply with agent_id), so what it leaves out is not carried over
|
|
84
|
+
* (editOn). */
|
|
85
|
+
export declare function commitAgent(store: AgentsStore, read: AgentEntry, { definition, skills, note }: DefinitionBody, { ifCurrent, check, contract, template, fromPackage }?: {
|
|
82
86
|
ifCurrent?: string | null;
|
|
83
87
|
check?: SaveCheck;
|
|
84
88
|
contract?: boolean;
|
|
89
|
+
template?: TemplatePackage;
|
|
90
|
+
fromPackage?: boolean;
|
|
85
91
|
}): Promise<AgentEntry>;
|
|
86
92
|
/** Makes `revisionId`, one of the agent's own, its current one (POST /agents/{id}/current). */
|
|
87
93
|
export declare function setCurrentRevision(store: AgentsStore, entry: AgentEntry, revisionId: string): Promise<AgentEntry>;
|
package/dist/agents-store.js
CHANGED
|
@@ -103,7 +103,7 @@ function revisionInputOf(definition, files) {
|
|
|
103
103
|
// permissionOf with the revision's approvals): a call node on a tool set to ask runs under never, as on main.
|
|
104
104
|
if (isObject(definition.workflow))
|
|
105
105
|
return { kind: "workflow", workflow: definition.workflow, ...(definition.approvals === "never" ? { approvals: "never" } : {}), ...common, ...capped };
|
|
106
|
-
// true, false
|
|
106
|
+
// true, false or the loop's numbers (learning-setting.ts), checked by validate.ts and again by the body.
|
|
107
107
|
const learning = definition.learning !== undefined && learningSettingIssue(definition.learning) === undefined ? { learning: definition.learning } : {};
|
|
108
108
|
return {
|
|
109
109
|
kind: "agentic",
|
|
@@ -145,7 +145,9 @@ function checkPast(definition, current) {
|
|
|
145
145
|
* and the same pins: a save after a server changed a granted tool (or monid an endpoint) is a new revision, pinned anew
|
|
146
146
|
* (that is how a person takes a server's changed tools). */
|
|
147
147
|
function sameRevision(current, next) {
|
|
148
|
-
|
|
148
|
+
// A template's update (next.package) that changes only the package (its version, its parameters) is a new revision too.
|
|
149
|
+
return current.kind === next.kind && canonical(current.body) === canonical(next.body) && canonical(current.mcpPin ?? null) === canonical(next.mcpPin ?? null) && canonical(current.monidPin ?? null) === canonical(next.monidPin ?? null)
|
|
150
|
+
&& (next.package === undefined || canonical(current.package ?? null) === canonical(next.package));
|
|
149
151
|
}
|
|
150
152
|
/** `revision` with what its check stamped. */
|
|
151
153
|
const stamped = (revision, stamp) => ({ ...revision, ...(stamp?.mcpPin === undefined ? {} : { mcpPin: stamp.mcpPin }), ...(stamp?.monidPin === undefined ? {} : { monidPin: stamp.monidPin }) });
|
|
@@ -172,7 +174,7 @@ export async function getAgent(store, id) {
|
|
|
172
174
|
const revisions = await store.agents.revisions(id); // oldest first (created_at, id)
|
|
173
175
|
const at = agent.currentRevision === null ? -1 : revisions.findIndex((r) => r.id === agent.currentRevision);
|
|
174
176
|
const revision = at < 0 ? null : revisions[at];
|
|
175
|
-
return { agent, revision, version: at < 0 ? 0 : at + 1, revisions: revisions.length, sizes: sizesOf(revision), template: revisions
|
|
177
|
+
return { agent, revision, version: at < 0 ? 0 : at + 1, revisions: revisions.length, sizes: sizesOf(revision), template: revisions.findLast((r) => r.package)?.package ?? null };
|
|
176
178
|
}
|
|
177
179
|
/** Every agent here, newest first (its creation, then its id). Archived agents are left out by default. */
|
|
178
180
|
export async function listAgents(store, options = {}) {
|
|
@@ -234,8 +236,11 @@ const EDIT_TRIES = 5;
|
|
|
234
236
|
* holds across every server on the store. `check` may refuse the revision before a write; it runs outside the write, so
|
|
235
237
|
* another request may move the current revision meanwhile: an edit with If-Match is then precondition_failed, and one
|
|
236
238
|
* without is built and checked again on the new current revision, so what it leaves out (skill files, harness, place, learning, cap) is never carried over from a
|
|
237
|
-
* revision it does not follow. `contract`: an edit that always makes a new revision, even one equal to the current.
|
|
238
|
-
|
|
239
|
+
* revision it does not follow. `contract`: an edit that always makes a new revision, even one equal to the current.
|
|
240
|
+
* `template`: the package an apply with agent_id wrote it from, kept on the revision (getAgent's `template`).
|
|
241
|
+
* `fromPackage`: the definition is a whole package's (an apply with agent_id), so what it leaves out is not carried over
|
|
242
|
+
* (editOn). */
|
|
243
|
+
export async function commitAgent(store, read, { definition, skills, note }, { ifCurrent, check, contract = false, template, fromPackage = false } = {}) {
|
|
239
244
|
const stale = () => new ApiError("precondition_failed", "the agent's current revision moved since the If-Match it was read at: read the agent again");
|
|
240
245
|
const held = (entry) => {
|
|
241
246
|
if (ifCurrent !== undefined && (entry.revision?.id ?? null) !== ifCurrent)
|
|
@@ -257,7 +262,9 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
257
262
|
for (let tries = 1;; tries++) {
|
|
258
263
|
if (tries > 1)
|
|
259
264
|
entry = held((await getAgent(store, agent.id)) ?? entry);
|
|
260
|
-
|
|
265
|
+
// A template applied onto the agent (apply with agent_id) keeps its package on the revision it writes, as a create does.
|
|
266
|
+
const made = editOn(entry, definition, skills, note, fromPackage);
|
|
267
|
+
const edit = template ? { ...made, package: template } : made;
|
|
261
268
|
const revision = stamped(edit, await check?.(edit, entry.revision));
|
|
262
269
|
const base = entry.revision?.id ?? null;
|
|
263
270
|
const now = held((await getAgent(store, agent.id)) ?? entry);
|
|
@@ -290,7 +297,7 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
290
297
|
}
|
|
291
298
|
/** The revision an edit makes on `entry`'s current one: what the edit leaves out keeps the current revision's, its skill
|
|
292
299
|
* files, harness, place, learning switch and default cap. Absent here is unchanged, not the default. */
|
|
293
|
-
function editOn(entry, definition, skills, note) {
|
|
300
|
+
function editOn(entry, definition, skills, note, fromPackage = false) {
|
|
294
301
|
const current = entry.revision;
|
|
295
302
|
const currentBody = (current?.body ?? {});
|
|
296
303
|
let files = skills;
|
|
@@ -303,6 +310,13 @@ function editOn(entry, definition, skills, note) {
|
|
|
303
310
|
...(definition.harness === undefined && currentBody.harness ? { harness: currentBody.harness } : {}),
|
|
304
311
|
// The computer and its place go together: an edit naming neither keeps both (the computer, else the place).
|
|
305
312
|
...(definition.place === undefined && definition.computer === undefined ? (currentBody.computer ? { computer: currentBody.computer } : currentBody.place ? { place: currentBody.place } : {}) : {}),
|
|
313
|
+
}
|
|
314
|
+
: {};
|
|
315
|
+
// A template's update (fromPackage) replaces what the package owns: the learning switch, the default cap, the input and
|
|
316
|
+
// answer schemas and the checkout it leaves out are gone, never carried from the revision the package wrote before.
|
|
317
|
+
// What the host owns (the sdk and native references, the harness, the computer and place) carries as an edit's does.
|
|
318
|
+
const owned = current && !fromPackage
|
|
319
|
+
? {
|
|
306
320
|
...(definition.learning === undefined && current.kind === "agentic" && !isObject(definition.workflow) && currentBody.learning !== undefined ? { learning: currentBody.learning } : {}),
|
|
307
321
|
// No approvals here: an edit that leaves them out asks (openapi.ts DefinitionInput.approvals),
|
|
308
322
|
// so no edit makes an agent unattended by saying nothing. The console's edit sends back the approvals it read.
|
|
@@ -315,7 +329,7 @@ function editOn(entry, definition, skills, note) {
|
|
|
315
329
|
...(definition.checkout === undefined && current.kind === "agentic" && !isObject(definition.workflow) && currentBody.checkout !== undefined ? { checkout: currentBody.checkout } : {}),
|
|
316
330
|
}
|
|
317
331
|
: {};
|
|
318
|
-
return makeRevision({ ...definition, ...carried }, files, note);
|
|
332
|
+
return makeRevision({ ...definition, ...carried, ...owned }, files, note);
|
|
319
333
|
}
|
|
320
334
|
/** Makes `revisionId`, one of the agent's own, its current one (POST /agents/{id}/current). */
|
|
321
335
|
export async function setCurrentRevision(store, entry, revisionId) {
|
package/dist/agents.d.ts
CHANGED
|
@@ -13,8 +13,12 @@ export declare function whenFree<T>(act: () => T | Promise<T>, delaysMs: readonl
|
|
|
13
13
|
export declare const storeBusy: (error: unknown) => boolean;
|
|
14
14
|
/** The answer to a request the agent store stayed busy for. */
|
|
15
15
|
export declare const homeBusy: () => ApiError;
|
|
16
|
+
/** The answer to a run, a trigger or a write refused because its agent is being deleted (the store's AgentDeleting, read
|
|
17
|
+
* in the transaction that would start or reopen the run or write the trigger; the server's own check for a write). */
|
|
18
|
+
export declare const agentDeleting: (agentId: string) => ApiError;
|
|
16
19
|
/** What a request's error answers, over HTTP and through an MCP tool alike (server.ts, mcp.ts dispatch): an ApiError as
|
|
17
|
-
* it is; a busy store home_busy (409, retryable), never 500;
|
|
20
|
+
* it is; a busy store home_busy (409, retryable), never 500; a run of an agent being deleted agent_not_runnable (409);
|
|
21
|
+
* anything else internal, its message kept. */
|
|
18
22
|
export declare const answerOf: (error: unknown) => ApiError;
|
|
19
23
|
/** Whether a request's error goes to the server's log: every fault the server did not answer on purpose. A busy wait
|
|
20
24
|
* is not one; a transaction past its deadline is (something held the store that long). */
|
package/dist/agents.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// (whenFree), then answered home_busy. The agents themselves are over the one store (agents-store.ts).
|
|
3
3
|
import { ApiError } from "./errors.js";
|
|
4
4
|
import { isObject } from "./validate.js";
|
|
5
|
-
import { StoreBusy, StoreDeadline } from "./store/index.js";
|
|
5
|
+
import { AgentDeleting, StoreBusy, StoreDeadline } from "./store/index.js";
|
|
6
6
|
/** SQLITE_BUSY or SQLITE_LOCKED: another connection holds the database. */
|
|
7
7
|
export const sqliteBusy = (error) => isObject(error) && error.code === "ERR_SQLITE_ERROR" && typeof error.errcode === "number" && [5, 6].includes(error.errcode & 0xff);
|
|
8
8
|
/** How long a request waits for a busy agent store, step by step: short first, so a reader's overlap costs
|
|
@@ -33,9 +33,13 @@ export async function whenFree(act, delaysMs, onBusy) {
|
|
|
33
33
|
export const storeBusy = (error) => sqliteBusy(error) || error instanceof StoreBusy || error instanceof StoreDeadline;
|
|
34
34
|
/** The answer to a request the agent store stayed busy for. */
|
|
35
35
|
export const homeBusy = () => new ApiError("home_busy", "the agent store is busy with another write; try again", { retry_after_ms: 500 });
|
|
36
|
+
/** The answer to a run, a trigger or a write refused because its agent is being deleted (the store's AgentDeleting, read
|
|
37
|
+
* in the transaction that would start or reopen the run or write the trigger; the server's own check for a write). */
|
|
38
|
+
export const agentDeleting = (agentId) => new ApiError("agent_not_runnable", `The agent ${agentId} is being deleted (DELETE /v2/agents/${agentId}): it starts no run, opens none again and takes no new trigger or write. Send the DELETE again to finish it.`);
|
|
36
39
|
/** What a request's error answers, over HTTP and through an MCP tool alike (server.ts, mcp.ts dispatch): an ApiError as
|
|
37
|
-
* it is; a busy store home_busy (409, retryable), never 500;
|
|
38
|
-
|
|
40
|
+
* it is; a busy store home_busy (409, retryable), never 500; a run of an agent being deleted agent_not_runnable (409);
|
|
41
|
+
* anything else internal, its message kept. */
|
|
42
|
+
export const answerOf = (error) => error instanceof ApiError ? error : storeBusy(error) ? homeBusy() : error instanceof AgentDeleting ? agentDeleting(error.agentId) : new ApiError("internal", error?.message ?? String(error));
|
|
39
43
|
/** Whether a request's error goes to the server's log: every fault the server did not answer on purpose. A busy wait
|
|
40
44
|
* is not one; a transaction past its deadline is (something held the store that long). */
|
|
41
|
-
export const logged = (error) => !(error instanceof ApiError) && (!storeBusy(error) || error instanceof StoreDeadline);
|
|
45
|
+
export const logged = (error) => !(error instanceof ApiError) && !(error instanceof AgentDeleting) && (!storeBusy(error) || error instanceof StoreDeadline);
|
package/dist/api-only.d.ts
CHANGED
|
@@ -3,9 +3,14 @@ import type { Route } from "./server.js";
|
|
|
3
3
|
export declare const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
4
4
|
/** The routes (server.ts ROUTES, by name) an API-only server serves: a run's launch, read, list, timeline, messages,
|
|
5
5
|
* stop, cancel, cap raise and grade; its files and the uploads a launch names; an agent's Archil disk, read and removed (the
|
|
6
|
-
* agent layer of a run's disk, archil-routes.ts);
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* agent layer of a run's disk, archil-routes.ts); the delete of an agent its inline runs made (agent-delete.ts), which
|
|
7
|
+
* the backend that made it is the one to send; capabilities, health and usage; the two reads of the computer settings a
|
|
8
|
+
* backend checks before it launches, each by the token and naming keys and whether each is saved, never a value: the
|
|
9
|
+
* computer providers and whether each is ready (GET /computers, computers.ts) and the Archil settings, whether runs'
|
|
10
|
+
* folders are on Archil (GET /workspace/archil, archil-routes.ts), while their writes, tests and key choices stay the
|
|
11
|
+
* console's; and a run's hosted machine that dials fetching this server's computerd with its own token
|
|
12
|
+
* (computer-attach.ts), as it dials the attach socket, which the upgrade takes for such a machine alone (a paired
|
|
13
|
+
* computer is the console's). */
|
|
9
14
|
export declare const API_ONLY_ROUTES: ReadonlySet<string>;
|
|
10
15
|
/** Whether `env` turns the profile on: `1` or `true` on; unset, empty, `0` or `false` off. Any other value is refused in
|
|
11
16
|
* words (a TypeError), so a typo never leaves the console open on a server meant to be API-only. */
|
package/dist/api-only.js
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
export const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
3
3
|
/** The routes (server.ts ROUTES, by name) an API-only server serves: a run's launch, read, list, timeline, messages,
|
|
4
4
|
* stop, cancel, cap raise and grade; its files and the uploads a launch names; an agent's Archil disk, read and removed (the
|
|
5
|
-
* agent layer of a run's disk, archil-routes.ts);
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* agent layer of a run's disk, archil-routes.ts); the delete of an agent its inline runs made (agent-delete.ts), which
|
|
6
|
+
* the backend that made it is the one to send; capabilities, health and usage; the two reads of the computer settings a
|
|
7
|
+
* backend checks before it launches, each by the token and naming keys and whether each is saved, never a value: the
|
|
8
|
+
* computer providers and whether each is ready (GET /computers, computers.ts) and the Archil settings, whether runs'
|
|
9
|
+
* folders are on Archil (GET /workspace/archil, archil-routes.ts), while their writes, tests and key choices stay the
|
|
10
|
+
* console's; and a run's hosted machine that dials fetching this server's computerd with its own token
|
|
11
|
+
* (computer-attach.ts), as it dials the attach socket, which the upgrade takes for such a machine alone (a paired
|
|
12
|
+
* computer is the console's). */
|
|
8
13
|
export const API_ONLY_ROUTES = new Set([
|
|
9
14
|
"createRun", "createInlineRun", "getComputerDaemon",
|
|
10
|
-
"
|
|
15
|
+
"listComputers", "getWorkspaceArchil",
|
|
16
|
+
"getAgentArchil", "deleteAgentArchil", "deleteAgent",
|
|
11
17
|
"getRun", "listRuns", "listAllRuns", "getTimeline",
|
|
12
18
|
"sendMessage", "stopRun", "cancelRun", "raiseRunCap", "gradeRun",
|
|
13
19
|
"listRunFiles", "readRunFile",
|
package/dist/archil-routes.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type KeyEnv, type KeyMeta } from "./key-meta.js";
|
|
2
2
|
import type { Store } from "./store/index.js";
|
|
3
|
+
import { type ArchilDisk, type ArchilDiskOptions } from "./workspace/archil-disk.js";
|
|
3
4
|
/** The routes, by their operation names. */
|
|
4
5
|
export declare const ARCHIL_ROUTES: ReadonlySet<string>;
|
|
5
6
|
/** The key names the Archil settings take, as the document names them. */
|
|
@@ -46,10 +47,12 @@ export interface ArchilRoutesOptions {
|
|
|
46
47
|
readonly store: Pick<Store, "settings" | "sealedKeys">;
|
|
47
48
|
/** The server's seal key: there is always one (seal-key.ts bootSealKey, at the start). */
|
|
48
49
|
readonly sealKey: Buffer;
|
|
49
|
-
/** Another control plane than the region's, and its fetch
|
|
50
|
+
/** Another control plane than the region's, and its fetch, and another maker of a disk's file API than archilDisk:
|
|
51
|
+
* a test's fakes. */
|
|
50
52
|
readonly control?: {
|
|
51
53
|
readonly baseUrl?: string;
|
|
52
54
|
readonly fetch?: typeof fetch;
|
|
55
|
+
readonly makeDisk?: (options: ArchilDiskOptions) => ArchilDisk;
|
|
53
56
|
};
|
|
54
57
|
/** The server's environment: an ARCHIL_API_KEY variable overrides the saved key, and ARCHIL_SETTINGS_ENV the saved
|
|
55
58
|
* settings (source "env"). */
|
|
@@ -67,6 +70,7 @@ export declare function createArchilRoutes(options: ArchilRoutesOptions): {
|
|
|
67
70
|
} | null;
|
|
68
71
|
}>;
|
|
69
72
|
checkLaunchDisk: (diskId: string, signal?: AbortSignal) => Promise<void>;
|
|
73
|
+
removeRunFolder: (agentId: string, runId: string, diskId: string) => Promise<void>;
|
|
70
74
|
};
|
|
71
75
|
export type ArchilRoutes = ReturnType<typeof createArchilRoutes>;
|
|
72
76
|
/** One of the owner's Archil routes at its handler: its answer (sent 200), or an ApiError (sent with its status). An
|