@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.47
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 +164 -1
- package/NOTICE +4 -0
- package/README.md +267 -40
- package/dist/acp-package.d.ts +35 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +5 -2
- package/dist/adapter-facts.js +6 -3
- package/dist/adapters.d.ts +7 -0
- package/dist/adapters.js +39 -0
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +7 -10
- package/dist/archil-routes.js +2 -1
- package/dist/cap.js +12 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +109 -41
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +9 -75
- package/dist/computers.js +20 -66
- package/dist/console/assets/index-BBFzAxLB.js +715 -0
- package/dist/console/assets/index-BRi-Rgq6.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +73 -0
- package/dist/harness-check.js +489 -0
- package/dist/harness-cursor.d.ts +45 -0
- package/dist/harness-cursor.js +121 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +357 -0
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +62 -2
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +3 -2
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +24 -4
- package/dist/import.js +108 -26
- package/dist/key-refusal.d.ts +1 -0
- package/dist/key-refusal.js +8 -3
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +12 -5
- package/dist/learn/promote.d.ts +69 -2
- package/dist/learn/promote.js +95 -3
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +1 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +22 -8
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +2 -1
- package/dist/model.js +9 -7
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +322 -39
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +8 -0
- package/dist/page.js +9 -1
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +6 -4
- package/dist/runner/adapter-loop.d.ts +10 -7
- package/dist/runner/adapter-loop.js +57 -22
- package/dist/runner/adapter-run-spec.d.ts +12 -0
- package/dist/runner/adapter-run-spec.js +40 -6
- package/dist/runner/adapters/index.js +16 -0
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +15 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +15 -7
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +62 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +41 -0
- package/dist/runner/presence.js +89 -0
- package/dist/runner/promotion.d.ts +9 -4
- package/dist/runner/promotion.js +33 -14
- package/dist/runner/run-child-host.js +40 -10
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runs-over-store.d.ts +6 -2
- package/dist/runs-over-store.js +14 -4
- package/dist/sdk/runs.d.ts +1 -1
- package/dist/sdk/runs.js +6 -1
- package/dist/sdk/schema.js +1 -1
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +31 -2
- package/dist/server.js +322 -51
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +106 -27
- package/dist/store/store.d.ts +75 -23
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +123 -14
- package/dist/store-view.js +154 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/timeline/timeline.js +18 -0
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.js +2 -2
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +19 -8
- package/dist/triggers.d.ts +2 -2
- package/dist/webhooks.d.ts +82 -8
- package/dist/webhooks.js +128 -45
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +18 -14
- package/dist/workspace/resolve-computer.js +47 -60
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/dist/console/assets/index-C2MYaUBa.css +0 -1
- package/dist/console/assets/index-CZZeCReB.js +0 -701
package/dist/acp-package.d.ts
CHANGED
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
import type { AdapterFacts, AgentAdapter } from "@parcha/agentrun-kernel";
|
|
2
2
|
export declare const ACP_PACKAGE = "@parcha/agentrun-harness-acp";
|
|
3
|
-
/** One platform's
|
|
3
|
+
/** One platform's release of an ACP agent, as the pin holds it (the package's AcpArchivePin). */
|
|
4
4
|
export type AcpRelease = {
|
|
5
5
|
readonly url: string;
|
|
6
6
|
readonly format: string;
|
|
7
7
|
readonly sha256: string;
|
|
8
8
|
readonly cmd: string;
|
|
9
9
|
readonly binarySha256?: string;
|
|
10
|
+
readonly treeSha256?: string;
|
|
11
|
+
};
|
|
12
|
+
/** A pinned release of an ACP agent (the package's AcpBinaryPin). */
|
|
13
|
+
export type AcpPin = {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly version: string;
|
|
16
|
+
readonly archives: Readonly<Partial<Record<string, AcpRelease>>>;
|
|
10
17
|
};
|
|
11
18
|
/** What serve reads of the package. */
|
|
12
19
|
export type AcpPackage = {
|
|
13
20
|
readonly gooseFacts: AdapterFacts;
|
|
14
|
-
readonly GOOSE_PIN:
|
|
15
|
-
readonly id: string;
|
|
16
|
-
readonly version: string;
|
|
17
|
-
readonly archives: Readonly<Partial<Record<string, AcpRelease>>>;
|
|
18
|
-
};
|
|
21
|
+
readonly GOOSE_PIN: AcpPin;
|
|
19
22
|
readonly GOOSE_INSTALL: string;
|
|
20
23
|
readonly GOOSE_NOT_INSTALLED: string;
|
|
24
|
+
readonly cursorFacts: AdapterFacts;
|
|
25
|
+
readonly CURSOR_PIN: AcpPin;
|
|
26
|
+
readonly CURSOR_INSTALL: string;
|
|
27
|
+
readonly CURSOR_CODES: {
|
|
28
|
+
readonly headlessDisabled: string;
|
|
29
|
+
readonly notInstalled: string;
|
|
30
|
+
};
|
|
31
|
+
readonly CURSOR_LIMITS: {
|
|
32
|
+
readonly maxTurns: number;
|
|
33
|
+
readonly maxToolCalls: number;
|
|
34
|
+
};
|
|
35
|
+
cursorCard(limits: {
|
|
36
|
+
readonly maxTurns: number;
|
|
37
|
+
readonly maxToolCalls: number;
|
|
38
|
+
}): string;
|
|
39
|
+
cursorAdapter(options: Record<string, unknown>): AgentAdapter;
|
|
40
|
+
/** Cursor's release pinned for `platform` (default this host's), its launcher's and tree's digests; undefined where none is. */
|
|
41
|
+
cursorRelease(platform?: string): {
|
|
42
|
+
readonly cmd: string;
|
|
43
|
+
readonly binarySha256: string;
|
|
44
|
+
readonly treeSha256: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
/** The form a model id an ACP agent lists takes (Cursor's `gpt-5.4-nano[reasoning=medium]` among them). */
|
|
47
|
+
readonly MODEL_ID: RegExp;
|
|
21
48
|
acpPlatform(): string | undefined;
|
|
22
49
|
gooseAdapter(options: Record<string, unknown>): AgentAdapter;
|
|
23
50
|
verifyPinnedBinary(path: string, sha256: string): void;
|
|
24
51
|
verifyPinnedBinaryAsync(path: string, sha256: string): Promise<void>;
|
|
52
|
+
treeDigest(root: string): Promise<string>;
|
|
53
|
+
verifyPinnedTree(root: string, sha256: string): Promise<void>;
|
|
25
54
|
};
|
|
26
55
|
/** The package, or undefined where it is not installed beside serve. Only its absence is: a package that is there and
|
|
27
56
|
* fails to load throws. */
|
package/dist/acp-package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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.
|
|
3
|
-
// installed from
|
|
4
|
-
//
|
|
2
|
+
// name, when serve first asks for it. Serve depends on it, so it is beside serve wherever serve is installed; a serve
|
|
3
|
+
// installed without it (an older release, from before it was published) runs, and its harness table has no goose row.
|
|
4
|
+
// A leaf: the harness table's own imports (adapter-facts.ts) read it in any import order.
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
export const ACP_PACKAGE = "@parcha/agentrun-harness-acp";
|
|
7
7
|
const requireHere = createRequire(import.meta.url);
|
package/dist/adapter-facts.d.ts
CHANGED
|
@@ -4,7 +4,10 @@ export declare const ADAPTER_FACTS: readonly AdapterFacts[];
|
|
|
4
4
|
/** Goose's facts (its package's, acp-package.ts), or undefined where that package is not beside serve: then the table has
|
|
5
5
|
* no goose row. Goose is listed only while its owner has installed it, so it is not one of HARNESSES. */
|
|
6
6
|
export declare const GOOSE_FACTS: AdapterFacts | undefined;
|
|
7
|
-
/**
|
|
7
|
+
/** Cursor's facts (the same package's), or undefined where it is not beside serve. Listed, as Goose is, only while its
|
|
8
|
+
* owner has installed it; billed to the owner's Cursor plan (its wire `plan`), never to a model key of ours. */
|
|
9
|
+
export declare const CURSOR_FACTS: AdapterFacts | undefined;
|
|
10
|
+
/** Every adapter harness's facts: the built-in ones, then Goose's and Cursor's where their package is. */
|
|
8
11
|
export declare const EVERY_ADAPTER_FACTS: readonly AdapterFacts[];
|
|
9
|
-
/** The facts of the adapter harness `id`, built-in or
|
|
12
|
+
/** The facts of the adapter harness `id`, built-in, Goose or Cursor; undefined for pi and for an id no adapter states. */
|
|
10
13
|
export declare const adapterFactsOf: (id: string) => AdapterFacts | undefined;
|
package/dist/adapter-facts.js
CHANGED
|
@@ -7,7 +7,10 @@ export const ADAPTER_FACTS = Object.freeze([claudeFacts, codexFacts, openCodeFac
|
|
|
7
7
|
/** Goose's facts (its package's, acp-package.ts), or undefined where that package is not beside serve: then the table has
|
|
8
8
|
* no goose row. Goose is listed only while its owner has installed it, so it is not one of HARNESSES. */
|
|
9
9
|
export const GOOSE_FACTS = acpPackage()?.gooseFacts;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/** Cursor's facts (the same package's), or undefined where it is not beside serve. Listed, as Goose is, only while its
|
|
11
|
+
* owner has installed it; billed to the owner's Cursor plan (its wire `plan`), never to a model key of ours. */
|
|
12
|
+
export const CURSOR_FACTS = acpPackage()?.cursorFacts;
|
|
13
|
+
/** Every adapter harness's facts: the built-in ones, then Goose's and Cursor's where their package is. */
|
|
14
|
+
export const EVERY_ADAPTER_FACTS = Object.freeze([...ADAPTER_FACTS, ...(GOOSE_FACTS ? [GOOSE_FACTS] : []), ...(CURSOR_FACTS ? [CURSOR_FACTS] : [])]);
|
|
15
|
+
/** The facts of the adapter harness `id`, built-in, Goose or Cursor; undefined for pi and for an id no adapter states. */
|
|
13
16
|
export const adapterFactsOf = (id) => EVERY_ADAPTER_FACTS.find((facts) => facts.id === id);
|
package/dist/adapters.d.ts
CHANGED
|
@@ -153,6 +153,13 @@ export declare function opencodeOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds,
|
|
|
153
153
|
* pinned binary, it says that command, and nothing here installs it. Its model goes where claude-agent's does (the host's
|
|
154
154
|
* Anthropic Messages provider, providerFor), through a model proxy of its own, priced and capped as every run is. */
|
|
155
155
|
export declare function gooseOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds): Promise<AgentAdapter>;
|
|
156
|
+
/** Cursor's adapter (its package's cursorAdapter, acp-package.ts), on the release its owner installed into the data's
|
|
157
|
+
* harnesses directory (`agentrun harness install cursor`, harness-cursor.ts), its launcher and every file beside it the
|
|
158
|
+
* pinned ones, and on its owner's Cursor API key (CURSOR_API_KEY), which the adapter reads by name from `env` at each
|
|
159
|
+
* start and hands to Cursor's process alone. Its model is Cursor's, billed to the owner's Cursor plan: no proxy and no
|
|
160
|
+
* price of ours; the run stops at the owner's turn and tool-call limits (cursorLimitsOf). `cursor/default` runs Cursor's
|
|
161
|
+
* own default model. */
|
|
162
|
+
export declare function cursorOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds): Promise<AgentAdapter>;
|
|
156
163
|
/** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
|
|
157
164
|
* the adapter's own check of the model `given` names (with none, a model of its wire's vendor: whether it runs here at
|
|
158
165
|
* 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
|
@@ -399,6 +399,45 @@ export async function gooseOf(env, needs) {
|
|
|
399
399
|
throw new HarnessUnavailable(error.message, fixOf(facts, error));
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
+
/** Cursor's adapter (its package's cursorAdapter, acp-package.ts), on the release its owner installed into the data's
|
|
403
|
+
* harnesses directory (`agentrun harness install cursor`, harness-cursor.ts), its launcher and every file beside it the
|
|
404
|
+
* pinned ones, and on its owner's Cursor API key (CURSOR_API_KEY), which the adapter reads by name from `env` at each
|
|
405
|
+
* start and hands to Cursor's process alone. Its model is Cursor's, billed to the owner's Cursor plan: no proxy and no
|
|
406
|
+
* price of ours; the run stops at the owner's turn and tool-call limits (cursorLimitsOf). `cursor/default` runs Cursor's
|
|
407
|
+
* own default model. */
|
|
408
|
+
export async function cursorOf(env, needs) {
|
|
409
|
+
const [{ acpPackage }, { cursorMissing, cursorLimitsOf, CURSOR_DEFAULT_MODEL, CURSOR_ID, CURSOR_KEY, CURSOR_PROVIDER }] = await Promise.all([import("./acp-package.js"), import("./harness-cursor.js")]);
|
|
410
|
+
const acp = acpPackage();
|
|
411
|
+
// What no key fixes is said first, as gooseOf does: the release, checked off the event loop.
|
|
412
|
+
const found = await cursorMissing(env);
|
|
413
|
+
if ("missing" in found)
|
|
414
|
+
throw new HarnessUnavailable(found.missing.message, acp && fixOf(acp.cursorFacts, found.missing));
|
|
415
|
+
if (!acp)
|
|
416
|
+
throw new HarnessUnavailable("Cursor's adapter is not installed beside this server");
|
|
417
|
+
const facts = acp.cursorFacts;
|
|
418
|
+
if (needs.model.provider !== CURSOR_PROVIDER)
|
|
419
|
+
throw new HarnessUnavailable(`${facts.label} runs Cursor's models, named ${CURSOR_PROVIDER}/<model-id>; the run's model is ${needs.model.provider}/${needs.model.modelId}.`);
|
|
420
|
+
if (!env[CURSOR_KEY])
|
|
421
|
+
throw new HarnessUnavailable(`${facts.label} runs on your Cursor API key, and ${CURSOR_KEY} is not set where AgentRun starts: set it there (it is handed to Cursor's runs alone), then restart AgentRun.`);
|
|
422
|
+
let limits;
|
|
423
|
+
try {
|
|
424
|
+
limits = cursorLimitsOf(acp, env);
|
|
425
|
+
}
|
|
426
|
+
catch (error) {
|
|
427
|
+
throw new HarnessUnavailable(error.message);
|
|
428
|
+
}
|
|
429
|
+
const model = needs.model.modelId === CURSOR_DEFAULT_MODEL ? undefined : needs.model.modelId;
|
|
430
|
+
try {
|
|
431
|
+
return acp.cursorAdapter({
|
|
432
|
+
binary: found.binary, limits, env, log: harnessLog(CURSOR_ID, env),
|
|
433
|
+
...(model ? { model } : {}),
|
|
434
|
+
...(needs.confine ? { confine: needs.confine } : {}),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
throw new HarnessUnavailable(error.message, fixOf(facts, error));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
402
441
|
/** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
|
|
403
442
|
* the adapter's own check of the model `given` names (with none, a model of its wire's vendor: whether it runs here at
|
|
404
443
|
* all). `atStart`: asked by the start's probe, whose offers hold until a restart, so a reason installing fixes ends
|
package/dist/agents-store.d.ts
CHANGED
|
@@ -71,9 +71,11 @@ export declare function makeRevision(definition: Json, files: Record<string, str
|
|
|
71
71
|
note?: string;
|
|
72
72
|
};
|
|
73
73
|
/** An edit: a new revision of the agent, made current. Without `skills` the current revision's skill files carry over. An
|
|
74
|
-
* edit that is the current revision writes nothing, so a PUT sent twice makes one revision. The agent keeps its id
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* edit that is the current revision writes nothing, so a PUT sent twice makes one revision. The agent keeps its id and name
|
|
75
|
+
* from its creation (a changed one is input_invalid). Its description is a label: an edit that names a new one makes a
|
|
76
|
+
* revision (even with the body unchanged) and writes the description with it in the store's one commit, so a stale or
|
|
77
|
+
* refused edit changes neither; one that leaves it out keeps it. `ifCurrent` (from If-Match) is the current revision the
|
|
78
|
+
* caller read, null for none; it is checked against the agent's current revision when the edit is read, and the write is conditional on the revision
|
|
77
79
|
* the edit was built on still being current, compared in the store's own transaction (addRevision's ifCurrent), so it
|
|
78
80
|
* holds across every server on the store. `check` may refuse the revision before a write; it runs outside the write, so
|
|
79
81
|
* another request may move the current revision meanwhile: an edit with If-Match is then precondition_failed, and one
|
package/dist/agents-store.js
CHANGED
|
@@ -229,9 +229,11 @@ export function makeRevision(definition, files, note) {
|
|
|
229
229
|
/** How many times an edit with no If-Match is built again on a current revision that moved while it was checked. */
|
|
230
230
|
const EDIT_TRIES = 5;
|
|
231
231
|
/** An edit: a new revision of the agent, made current. Without `skills` the current revision's skill files carry over. An
|
|
232
|
-
* edit that is the current revision writes nothing, so a PUT sent twice makes one revision. The agent keeps its id
|
|
233
|
-
*
|
|
234
|
-
*
|
|
232
|
+
* edit that is the current revision writes nothing, so a PUT sent twice makes one revision. The agent keeps its id and name
|
|
233
|
+
* from its creation (a changed one is input_invalid). Its description is a label: an edit that names a new one makes a
|
|
234
|
+
* revision (even with the body unchanged) and writes the description with it in the store's one commit, so a stale or
|
|
235
|
+
* refused edit changes neither; one that leaves it out keeps it. `ifCurrent` (from If-Match) is the current revision the
|
|
236
|
+
* caller read, null for none; it is checked against the agent's current revision when the edit is read, and the write is conditional on the revision
|
|
235
237
|
* the edit was built on still being current, compared in the store's own transaction (addRevision's ifCurrent), so it
|
|
236
238
|
* holds across every server on the store. `check` may refuse the revision before a write; it runs outside the write, so
|
|
237
239
|
* another request may move the current revision meanwhile: an edit with If-Match is then precondition_failed, and one
|
|
@@ -253,12 +255,13 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
253
255
|
const { agent } = entry;
|
|
254
256
|
const kept = [
|
|
255
257
|
...(definition.id !== undefined && definition.id !== agent.id ? [{ field: "definition.id", reason: "not_an_option", message: `definition.id is ${agent.id}, the agent's id` }] : []),
|
|
256
|
-
...["name", "
|
|
257
|
-
.filter((key) => definition[key] !== undefined && definition[key] !== agent[key])
|
|
258
|
-
.map((key) => ({ field: `definition.${key}`, reason: "not_allowed", message: `The agent store keeps an agent's ${key} from its creation; an edit does not change it.`, fix: `Remove definition.${key}.` })),
|
|
258
|
+
...(definition.name !== undefined && definition.name !== agent.name ? [{ field: "definition.name", reason: "not_allowed", message: "An agent keeps the name it was created with; an edit does not change it.", fix: "Remove definition.name." }] : []),
|
|
259
259
|
];
|
|
260
260
|
if (kept.length)
|
|
261
261
|
throw invalid(kept);
|
|
262
|
+
// The description is a label on the agent's row, not part of a revision: an edit that names one writes it with its
|
|
263
|
+
// revision, in addRevision's one commit. The validator has checked it is a string.
|
|
264
|
+
const description = typeof definition.description === "string" ? definition.description : undefined;
|
|
262
265
|
for (let tries = 1;; tries++) {
|
|
263
266
|
if (tries > 1)
|
|
264
267
|
entry = held((await getAgent(store, agent.id)) ?? entry);
|
|
@@ -269,7 +272,9 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
269
272
|
const base = entry.revision?.id ?? null;
|
|
270
273
|
const now = held((await getAgent(store, agent.id)) ?? entry);
|
|
271
274
|
if ((now.revision?.id ?? null) === base) {
|
|
272
|
-
|
|
275
|
+
// A new description is a real edit: a revision, even with the body unchanged. The same one again writes nothing.
|
|
276
|
+
const described = description !== undefined && description !== now.agent.description;
|
|
277
|
+
if (!contract && !described && now.revision && sameRevision(now.revision, revision)) {
|
|
273
278
|
checkVersion(definition, now.version);
|
|
274
279
|
return now;
|
|
275
280
|
}
|
|
@@ -280,7 +285,7 @@ export async function commitAgent(store, read, { definition, skills, note }, { i
|
|
|
280
285
|
else
|
|
281
286
|
checkVersion(definition, now.revisions + 1);
|
|
282
287
|
try {
|
|
283
|
-
await store.agents.addRevision({ agentId: agent.id, ifCurrent: base, ...revision });
|
|
288
|
+
await store.agents.addRevision({ agentId: agent.id, ifCurrent: base, ...revision, ...(described ? { description } : {}) });
|
|
284
289
|
return (await getAgent(store, agent.id));
|
|
285
290
|
}
|
|
286
291
|
catch (error) {
|
package/dist/api-only.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Route } from "./server.js";
|
|
2
2
|
/** The variable that turns the profile on. */
|
|
3
3
|
export declare const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
4
|
-
/** The routes (server.ts ROUTES, by name) an API-only server serves
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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). */
|
|
4
|
+
/** The routes (server.ts ROUTES, by name) an API-only server serves. Those past a run's own:
|
|
5
|
+
* - getComputerDaemon: a run's hosted machine that dials fetches computerd with its own token, as the attach upgrade
|
|
6
|
+
* takes such a machine alone (a paired computer is the console's).
|
|
7
|
+
* - listComputers, getWorkspaceArchil: the two reads a backend checks before it launches, naming keys and never a
|
|
8
|
+
* value; their writes and tests stay the console's.
|
|
9
|
+
* - getAgentArchil, deleteAgentArchil, deleteAgent: an agent's disk and the delete of an agent its inline runs made,
|
|
10
|
+
* which the backend that made it sends. */
|
|
14
11
|
export declare const API_ONLY_ROUTES: ReadonlySet<string>;
|
|
15
12
|
/** Whether `env` turns the profile on: `1` or `true` on; unset, empty, `0` or `false` off. Any other value is refused in
|
|
16
13
|
* 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
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/** The variable that turns the profile on. */
|
|
2
2
|
export const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
3
|
-
/** The routes (server.ts ROUTES, by name) an API-only server serves
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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). */
|
|
3
|
+
/** The routes (server.ts ROUTES, by name) an API-only server serves. Those past a run's own:
|
|
4
|
+
* - getComputerDaemon: a run's hosted machine that dials fetches computerd with its own token, as the attach upgrade
|
|
5
|
+
* takes such a machine alone (a paired computer is the console's).
|
|
6
|
+
* - listComputers, getWorkspaceArchil: the two reads a backend checks before it launches, naming keys and never a
|
|
7
|
+
* value; their writes and tests stay the console's.
|
|
8
|
+
* - getAgentArchil, deleteAgentArchil, deleteAgent: an agent's disk and the delete of an agent its inline runs made,
|
|
9
|
+
* which the backend that made it sends. */
|
|
13
10
|
export const API_ONLY_ROUTES = new Set([
|
|
14
11
|
"createRun", "createInlineRun", "getComputerDaemon",
|
|
15
12
|
"listComputers", "getWorkspaceArchil",
|
package/dist/archil-routes.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { agentDiskOf, ARCHIL_API_KEY_ROW, ARCHIL_SETTINGS_ENV, archilSettingsFromEnv, archilSettingsIssues, archilSettingsOf, clearArchilSettings, forgetAgentDisk, loadArchilSettings, saveArchilSettings, storeAgentDisk } from "./archil-settings.js";
|
|
24
24
|
import { ApiError, invalid } from "./errors.js";
|
|
25
25
|
import { envValue, keyMetaOf } from "./key-meta.js";
|
|
26
|
-
import { registerNotSecretWrite, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
26
|
+
import { registerNotSecretWrite, registerSecretPage, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
27
27
|
import { readLaunchBody } from "./run-launch.js";
|
|
28
28
|
import { putSealedKey, removeSealedKey } from "./server-keys.js";
|
|
29
29
|
import { unknownFields } from "./validate.js";
|
|
@@ -45,6 +45,7 @@ export const ARCHIL_KEY_NAMES = KEYS.map((key) => key.name);
|
|
|
45
45
|
// region and S3 URL too, which say where every run's files go, so a token never re-points them. The server's one dispatch
|
|
46
46
|
// check keeps it to the owner's session. Turning Archil off keeps the key, so it is not registered.
|
|
47
47
|
registerSecretWrite("putWorkspaceArchil", () => true);
|
|
48
|
+
registerSecretPage("putWorkspaceArchil", "/#/settings/workspace");
|
|
48
49
|
registerNotSecretWrite("deleteWorkspaceArchil", "Turning Archil off keeps its key: no secret is dropped or replaced.");
|
|
49
50
|
registerNotSecretWrite("testWorkspaceArchil", "A connection test reads the saved key and writes none.");
|
|
50
51
|
/** The account key as its one SecretMeta: named "workspace:archil", set by ARCHIL_API_KEY or its sealed row. */
|
package/dist/cap.js
CHANGED
|
@@ -79,13 +79,23 @@ const close = (open, figure) => {
|
|
|
79
79
|
* never left (REQUEST_REFUSED's error entry) and a harness answer's continuation close nothing. */
|
|
80
80
|
function openFigures(entries) {
|
|
81
81
|
const open = { generation: [], compaction: [] };
|
|
82
|
-
let [refused, continued] = [0, 0];
|
|
82
|
+
let [refused, continued, sideSummaries] = [0, 0, 0];
|
|
83
83
|
for (const entry of entries) {
|
|
84
84
|
const message = entry.model?.[0];
|
|
85
85
|
const data = (entry.data ?? {});
|
|
86
86
|
// A side request (a compaction's summary, a tool's own request): marked with a label, as the timeline reads it.
|
|
87
87
|
const kind = typeof data.request === "string" ? "compaction" : "generation";
|
|
88
|
-
if (entry.kind ===
|
|
88
|
+
if (entry.kind === REQUEST_STARTED && data.request === "compaction")
|
|
89
|
+
sideSummaries += 1;
|
|
90
|
+
// pi's compaction entry answers its summary request when that left marked as a generation (the timeline's meter):
|
|
91
|
+
// pi stores no answer for it. One marked as a side request is closed by its cost.
|
|
92
|
+
if (entry.kind === "pi.compaction") {
|
|
93
|
+
if (sideSummaries > 0)
|
|
94
|
+
sideSummaries = 0;
|
|
95
|
+
else
|
|
96
|
+
close(open.generation);
|
|
97
|
+
}
|
|
98
|
+
else if (entry.kind === REQUEST_REFUSED)
|
|
89
99
|
refused += 1;
|
|
90
100
|
else if (entry.kind === "pi.assistant" && refused > 0 && message?.stopReason === "error")
|
|
91
101
|
refused -= 1;
|
package/dist/chatgpt-plan.js
CHANGED
|
@@ -14,7 +14,7 @@ import { setTimeout as sleep } from "node:timers/promises";
|
|
|
14
14
|
import { inspect } from "node:util";
|
|
15
15
|
import { CredentialUnavailable } from "@parcha/agentrun-kernel/host";
|
|
16
16
|
import { holdSecret } from "./secrets.js";
|
|
17
|
-
import { registerSecretWrite } from "./secret-writes.js";
|
|
17
|
+
import { registerSecretPage, registerSecretWrite } from "./secret-writes.js";
|
|
18
18
|
import { putSealedKey } from "./server-keys.js";
|
|
19
19
|
import { held } from "./runner/held.js";
|
|
20
20
|
import { sealColumn, sealedAt, STORE_WRITE_DEADLINE_MS, unsealColumn } from "./store/index.js";
|
|
@@ -22,6 +22,7 @@ import { sealColumn, sealedAt, STORE_WRITE_DEADLINE_MS, unsealColumn } from "./s
|
|
|
22
22
|
// holds no token, but a pending sign-in's link is the owner's to open.
|
|
23
23
|
for (const operation of ["getChatGPTSignIn", "startChatGPTSignIn", "finishChatGPTSignIn", "signOutChatGPT"])
|
|
24
24
|
registerSecretWrite(operation, () => true);
|
|
25
|
+
registerSecretPage(["getChatGPTSignIn", "startChatGPTSignIn", "finishChatGPTSignIn", "signOutChatGPT"], "/#/settings/keys");
|
|
25
26
|
/** The sealed row that holds the sign-in. */
|
|
26
27
|
export const CHATGPT_PLAN_ROW = "chatgpt:plan";
|
|
27
28
|
/** The model provider a plan model is named under (`chatgpt/<model-id>`), so a run's billing is never chosen silently. */
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { spawn } from "node:child_process";
|
|
|
10
10
|
import { accessSync, chmodSync, constants as fsConstants, statSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { dirname, join, resolve } from "node:path";
|
|
12
12
|
import { defaultData, removeOwnRecord, SERVER_FILE, writeDurableSync } from "./server-fs.js";
|
|
13
|
-
import { REPEAT_MS, stopOnSignals } from "./stop-signals.js";
|
|
13
|
+
import { REPEAT_MS, stopOnce, stopOnSignals } from "./stop-signals.js";
|
|
14
14
|
import { resetPassword } from "./owner.js";
|
|
15
15
|
import { banner } from "./print.js";
|
|
16
16
|
import { parseTokens } from "./api-token.js";
|
|
@@ -31,11 +31,14 @@ installEnvProxy();
|
|
|
31
31
|
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--no-runner] [--harness-module MODULE ...]
|
|
32
32
|
agentrun-serve reset-password [--data DIR]
|
|
33
33
|
agentrun-serve validate-template DIR
|
|
34
|
-
agentrun-serve install-harness goose [--data DIR]
|
|
34
|
+
agentrun-serve install-harness goose|cursor [--data DIR]
|
|
35
|
+
agentrun-serve install-harness --recipe FILE [--data DIR]
|
|
36
|
+
agentrun-serve check-harness --recipe FILE [--model PROVIDER/MODEL] [--data DIR] [--report FILE] [--cap USD]
|
|
35
37
|
agentrun-serve eval-template DIR [--case NAME ...] [--runs N] [--server URL | --on-data DIR] [--grader-model PROVIDER/MODEL] [--report FILE] [--faux MODULE]
|
|
36
38
|
agentrun-serve import [--data DIR] [--from claude-code,codex,pi] [--dry-run] [--include-deleted] [--all] [--verbose] [--port N]
|
|
37
39
|
agentrun-serve runner --data DIR [--loops N] [--drain-timeout D] [--name NAME]
|
|
38
40
|
agentrun-serve runner --check --data DIR [--name NAME]
|
|
41
|
+
agentrun-serve native discover|connect --project PATH [--runtime claude-code|codex] [--agent NAME|--profile NAME] [--url URL] [--data DIR]
|
|
39
42
|
|
|
40
43
|
--data DIR the agent store and its runs (default ~/.local/share/agentrun/agents); the token is DIR/.token, mode 0600
|
|
41
44
|
--listen ADDR the address to listen on (default 127.0.0.1); on any other, every Host name is served and the token
|
|
@@ -90,13 +93,11 @@ or not (ChatGPT-plan requests don't count): the next is not sent and the run fai
|
|
|
90
93
|
end, and per refused credential; AGENTRUN_LOG=quiet leaves out the request lines.
|
|
91
94
|
|
|
92
95
|
AGENTRUN_TELEMETRY=0 (or DO_NOT_TRACK=1) turns off the anonymous usage counts (docs/telemetry.md): a random id, the
|
|
93
|
-
version, the platform and how many runs as a range, never prompts, files or keys. Off in CI and under --faux too;
|
|
96
|
+
version, the platform and how many runs as a range, never prompts, files or keys. Off in CI, under a test runner and under --faux too;
|
|
94
97
|
AGENTRUN_TELEMETRY=debug prints each event on stderr and sends none.
|
|
95
98
|
|
|
96
|
-
AGENTRUN_API_ONLY=1 serves the run
|
|
97
|
-
|
|
98
|
-
and usage. Every other address (the page, sign-in, setup, settings, MCP, triggers and their hooks, the rest of agents)
|
|
99
|
-
is a 404, and there are no accounts.
|
|
99
|
+
AGENTRUN_API_ONLY=1 serves the run API alone, for a server behind its caller's backend (the routes in api-only.ts; every
|
|
100
|
+
other address is a 404, and there are no accounts).
|
|
100
101
|
|
|
101
102
|
The page is for one person, who signs in with a password (AGENTRUN_ACCOUNTS=0 turns this off; the token works for
|
|
102
103
|
scripts and the CLI either way). With no AGENTRUN_PUBLIC_URL, listening on loopback, the first visit to the page sets the
|
|
@@ -132,6 +133,23 @@ times in place of its own count; --grader-model is the llm graders' model (defau
|
|
|
132
133
|
model request from MODULE, as the server's --faux does. Progress goes to stderr, a summary to stdout, the whole report
|
|
133
134
|
as JSON to --report FILE. Exit 0 when every case passed, 1 when one failed, 2 when the flags, the package or a case are
|
|
134
135
|
wrong and nothing ran. Real runs cost money: each case's prompt.md caps each of its runs (max_cost_usd).`;
|
|
136
|
+
// A command's --help (or -h), before the command reads anything else it was given: its own lines of USAGE and the
|
|
137
|
+
// paragraph that says what it does, where there is one, on stdout, exit 0. No store is opened and nothing is written,
|
|
138
|
+
// so `reset-password --help` clears no password and `install-harness goose --help` downloads nothing. A command USAGE
|
|
139
|
+
// has no line for (remote-bridge) has no --help of its own.
|
|
140
|
+
const command = process.argv[2];
|
|
141
|
+
const commandArgs = process.argv.slice(3);
|
|
142
|
+
/** The command's own lines of USAGE, the first "usage:" and the rest under it; empty when USAGE has none for it. */
|
|
143
|
+
const commandUsage = USAGE.split("\n")
|
|
144
|
+
.filter((line) => line.trimStart().replace(/^usage: /, "").startsWith(`agentrun-serve ${command} `))
|
|
145
|
+
.map((line, i) => `${i === 0 ? "usage:" : " "} ${line.trimStart()}`)
|
|
146
|
+
.join("\n");
|
|
147
|
+
const optionsEnd = commandArgs.indexOf("--");
|
|
148
|
+
if (commandUsage && (optionsEnd === -1 ? commandArgs : commandArgs.slice(0, optionsEnd)).some((arg) => arg === "--help" || arg === "-h")) {
|
|
149
|
+
const about = USAGE.split("\n\n").find((block) => block.startsWith(`\`agentrun-serve ${command}`));
|
|
150
|
+
console.log([commandUsage, ...(about ? [about] : []), "agentrun-serve --help says what the server's own flags and variables do."].join("\n\n"));
|
|
151
|
+
process.exit(0);
|
|
152
|
+
}
|
|
135
153
|
if (process.argv[2] === "remote-bridge") {
|
|
136
154
|
const { runRemoteWorkerBridge } = await import("./native/remote-worker-bridge.js");
|
|
137
155
|
await runRemoteWorkerBridge();
|
|
@@ -139,7 +157,7 @@ if (process.argv[2] === "remote-bridge") {
|
|
|
139
157
|
}
|
|
140
158
|
if (process.argv[2] === "native") {
|
|
141
159
|
const { nativeMain } = await import("./native/cli.js");
|
|
142
|
-
process.exit(await nativeMain(process.argv.slice(3)));
|
|
160
|
+
process.exit(await nativeMain(process.argv.slice(3), commandUsage));
|
|
143
161
|
}
|
|
144
162
|
if (process.argv[2] === "reset-password") {
|
|
145
163
|
let dir;
|
|
@@ -155,37 +173,66 @@ if (process.argv[2] === "reset-password") {
|
|
|
155
173
|
console.log(`The password is cleared and every browser is signed out (${target}). The next visit to the page sets a new one.`);
|
|
156
174
|
process.exit(0);
|
|
157
175
|
}
|
|
158
|
-
// A harness its owner installs (harness-goose.ts: Goose
|
|
159
|
-
// checked and unpacked into DIR/harnesses/<name> (harness-archive.ts). 0 once it is there (now or already), 1
|
|
160
|
-
// install failed (its code and the command to try again), 2 for a name it does not install. No provider key is
|
|
176
|
+
// A harness its owner installs (harness-goose.ts: Goose; harness-cursor.ts: Cursor), never a run: its pinned archive
|
|
177
|
+
// downloaded, checked and unpacked into DIR/harnesses/<name> (harness-archive.ts). 0 once it is there (now or already), 1
|
|
178
|
+
// when the install failed (its code and the command to try again), 2 for a name it does not install. No provider key is
|
|
179
|
+
// read, Cursor's included.
|
|
161
180
|
if (process.argv[2] === "install-harness") {
|
|
162
181
|
const usage = (message) => (console.error(`agentrun-serve install-harness: ${message}\n\n${USAGE}`), process.exit(2));
|
|
163
182
|
const read = () => {
|
|
164
183
|
try {
|
|
165
|
-
return parseArgs({ args: process.argv.slice(3), options: { data: { type: "string" } }, allowPositionals: true });
|
|
184
|
+
return parseArgs({ args: process.argv.slice(3), options: { data: { type: "string" }, recipe: { type: "string" } }, allowPositionals: true });
|
|
166
185
|
}
|
|
167
186
|
catch (error) {
|
|
168
187
|
return usage(error.message);
|
|
169
188
|
}
|
|
170
189
|
};
|
|
171
190
|
const { values, positionals } = read();
|
|
172
|
-
|
|
191
|
+
// A recipe's harness (harness-recipe.ts): the recipe loaded under its five rules first, so a refused one downloads
|
|
192
|
+
// nothing; then its release for this platform, as the Goose install does it.
|
|
193
|
+
if (values.recipe !== undefined) {
|
|
194
|
+
if (positionals.length)
|
|
195
|
+
usage("it takes a harness's name or --recipe FILE, not both.");
|
|
196
|
+
const [{ ArchiveInstallFailed }, { installRecipe, loadRecipe, recipeCheckLine, RecipeRefused }] = await Promise.all([import("./harness-archive.js"), import("./harness-recipe.js")]);
|
|
197
|
+
const data = resolve(values.data ?? defaultData());
|
|
198
|
+
try {
|
|
199
|
+
const { recipe, file } = loadRecipe(values.recipe);
|
|
200
|
+
const said = { downloaded: "the archive is downloaded and its sha256 matches the recipe", unpacked: "unpacked", verified: "the binary's sha256 is checked" };
|
|
201
|
+
const { version, installed, binary, pinnedBy } = await installRecipe(recipe, file, data, { onStep: (step) => console.error(`${recipe.label}: ${said[step]}`) });
|
|
202
|
+
const held = { recipe: "the recipe's pin", "first-seen": "the first sha256 an earlier install recorded", recorded: "its sha256 recorded now, as the first one; a later binary that differs is refused" }[pinnedBy];
|
|
203
|
+
console.log(installed === "already"
|
|
204
|
+
? `${recipe.label} ${version} is installed in ${dirname(binary)} (already: the pinned binary is there, so nothing was downloaded; held to ${held}).`
|
|
205
|
+
: `${recipe.label} ${version} is installed in ${dirname(binary)} (now; the binary held to ${held}). Check it with: ${recipeCheckLine(file, data)} --model PROVIDER/MODEL`);
|
|
206
|
+
process.exit(0);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (!(error instanceof ArchiveInstallFailed) && !(error instanceof RecipeRefused))
|
|
210
|
+
throw error;
|
|
211
|
+
console.error(error.message);
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const [{ GOOSE_ID, installGoose }, { CURSOR_ID, installCursor }] = await Promise.all([import("./harness-goose.js"), import("./harness-cursor.js")]);
|
|
216
|
+
const installers = { [GOOSE_ID]: { label: "Goose", install: installGoose, binary: "the binary's sha256 matches the pin" }, [CURSOR_ID]: { label: "Cursor", install: installCursor, binary: "its launcher's sha256 and every file's tree digest match the pin" } };
|
|
217
|
+
const names = Object.keys(installers).join(" or ");
|
|
173
218
|
if (positionals.length !== 1)
|
|
174
|
-
usage(`it takes one harness: ${
|
|
175
|
-
|
|
176
|
-
|
|
219
|
+
usage(`it takes one harness: ${names}.`);
|
|
220
|
+
const chosen = Object.hasOwn(installers, positionals[0]) ? installers[positionals[0]] : undefined;
|
|
221
|
+
if (!chosen)
|
|
222
|
+
usage(`it installs ${names}, not ${positionals[0]}: claude-agent and codex install on first use, and pi and opencode come with AgentRun.`);
|
|
223
|
+
const { label, install } = chosen;
|
|
177
224
|
const [{ ArchiveInstallFailed }, { acpPackage, ACP_PACKAGE }] = await Promise.all([import("./harness-archive.js"), import("./acp-package.js")]);
|
|
178
225
|
if (!acpPackage()) {
|
|
179
|
-
console.error(
|
|
226
|
+
console.error(`${label}'s adapter (${ACP_PACKAGE}) is not installed beside this server, so it has no pinned release to install.`);
|
|
180
227
|
process.exit(1);
|
|
181
228
|
}
|
|
182
229
|
const data = resolve(values.data ?? defaultData());
|
|
183
230
|
try {
|
|
184
|
-
const said = { downloaded: "the archive is downloaded and its sha256 matches the pin", unpacked: "unpacked", verified:
|
|
185
|
-
const { version, installed, binary } = await
|
|
231
|
+
const said = { downloaded: "the archive is downloaded and its sha256 matches the pin", unpacked: "unpacked", verified: chosen.binary };
|
|
232
|
+
const { version, installed, binary } = await install(data, { onStep: (step) => console.error(`${label}: ${said[step]}`) });
|
|
186
233
|
console.log(installed === "already"
|
|
187
|
-
?
|
|
188
|
-
:
|
|
234
|
+
? `${label} ${version} is installed in ${dirname(binary)} (already: the pinned release is there, so nothing was downloaded).`
|
|
235
|
+
: `${label} ${version} is installed in ${dirname(binary)} (now). Restart AgentRun to pick it up.`);
|
|
189
236
|
process.exit(0);
|
|
190
237
|
}
|
|
191
238
|
catch (error) {
|
|
@@ -195,6 +242,36 @@ if (process.argv[2] === "install-harness") {
|
|
|
195
242
|
process.exit(1);
|
|
196
243
|
}
|
|
197
244
|
}
|
|
245
|
+
// A recipe's agent run for real and judged (harness-check.ts): its report written as JSON, its stages and the three facts
|
|
246
|
+
// (resume, tool_gate, billing) printed. 0 when every stage passed, 1 when the recipe was refused, its binary is not the
|
|
247
|
+
// installed and pinned one, or a stage failed, 2 for usage. It spends: four short turns on --model, under --cap.
|
|
248
|
+
// `agentrun harness-check` runs it; its own word is check-harness, as install-harness is `agentrun harness install`'s.
|
|
249
|
+
if (process.argv[2] === "check-harness") {
|
|
250
|
+
const usage = (message) => (console.error(`agentrun-serve check-harness: ${message}\n\n${USAGE}`), process.exit(2));
|
|
251
|
+
const read = () => {
|
|
252
|
+
try {
|
|
253
|
+
return parseArgs({ args: process.argv.slice(3), options: { recipe: { type: "string" }, data: { type: "string" }, model: { type: "string" }, report: { type: "string" }, cap: { type: "string" } } });
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
return usage(error.message);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const { values } = read();
|
|
260
|
+
if (!values.recipe)
|
|
261
|
+
usage("--recipe FILE names the recipe to check.");
|
|
262
|
+
const cap = values.cap === undefined ? undefined : Number(values.cap);
|
|
263
|
+
if (cap !== undefined && !(Number.isFinite(cap) && cap > 0 && cap <= 5))
|
|
264
|
+
usage("--cap is the most the check may spend, in USD, above 0 and at most 5.");
|
|
265
|
+
const [{ harnessCheck, printedFacts, writeReport }, { withSecrets }] = await Promise.all([import("./harness-check.js"), import("./secrets.js")]);
|
|
266
|
+
const data = resolve(values.data ?? defaultData());
|
|
267
|
+
const report = await harnessCheck({ recipe: values.recipe, data, env: withSecrets(process.env), ...(values.model ? { model: values.model } : {}), ...(cap !== undefined ? { capUsd: cap } : {}), say: (line) => console.error(line) });
|
|
268
|
+
const file = resolve(values.report ?? `harness-check-${"id" in report.recipe ? report.recipe.id : "recipe"}.json`);
|
|
269
|
+
await writeReport(file, report);
|
|
270
|
+
for (const line of printedFacts(report))
|
|
271
|
+
console.log(line);
|
|
272
|
+
console.log(`report: ${file}`);
|
|
273
|
+
process.exit(report.ok ? 0 : 1);
|
|
274
|
+
}
|
|
198
275
|
// A template package folder checked by the one validator the server runs on the packages it ships (templates.ts): what
|
|
199
276
|
// it holds as one JSON line and 0, or each problem and 1. Nothing in the package runs.
|
|
200
277
|
if (process.argv[2] === "validate-template") {
|
|
@@ -269,22 +346,9 @@ if (process.argv[2] === "eval-template") {
|
|
|
269
346
|
usage(`--report's folder ${folder} is not a folder this command can write in, or the report's path is a folder or a file it can't write.`);
|
|
270
347
|
}
|
|
271
348
|
// The first Ctrl-C (or a stop) cancels the run in progress and cleans up what the eval made, as its end does: a run
|
|
272
|
-
// left going would go on spending. A second one leaves at once
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
let stoppedAt = 0;
|
|
276
|
-
const onStop = () => {
|
|
277
|
-
if (stop.signal.aborted) {
|
|
278
|
-
if (Date.now() - stoppedAt > REPEAT_MS)
|
|
279
|
-
process.exit(130);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
stoppedAt = Date.now();
|
|
283
|
-
console.error("agentrun-serve eval-template: stopping: cancelling the run in progress and cleaning up (again to leave now)");
|
|
284
|
-
stop.abort();
|
|
285
|
-
};
|
|
286
|
-
process.on("SIGINT", onStop);
|
|
287
|
-
process.on("SIGTERM", onStop);
|
|
349
|
+
// left going would go on spending. A second one leaves at once (stop-signals.ts stopOnce).
|
|
350
|
+
const stop = stopOnce(() => console.error("agentrun-serve eval-template: stopping: cancelling the run in progress and cleaning up (again to leave now)"));
|
|
351
|
+
stop.hook();
|
|
288
352
|
try {
|
|
289
353
|
const report = await evalTemplate({
|
|
290
354
|
dir: resolve(positionals[0]), cases: given.case, ...(given.runs !== undefined ? { runs: Number(given.runs) } : {}),
|
|
@@ -470,8 +534,7 @@ catch (error) {
|
|
|
470
534
|
// (besideRunnerOptions): at most --max-runs runs at once, the rest waiting queued, and on the stop each busy run finishes
|
|
471
535
|
// its turn for up to --drain-timeout.
|
|
472
536
|
let runnerProc;
|
|
473
|
-
// Anonymous usage counts (
|
|
474
|
-
// under --faux. It hears each run's end from the runner beside the server; with --no-runner it counts no runs.
|
|
537
|
+
// Anonymous usage counts (docs/telemetry.md). It hears each run's end from the runner beside the server; with --no-runner it counts no runs.
|
|
475
538
|
const telemetry = startTelemetry({ data: resolve(data), ...(values.faux ? { faux: true } : {}) });
|
|
476
539
|
const { loops, loopsTold, drainMs } = besideRunnerOptions(serveOptions, process.env);
|
|
477
540
|
// A stop asked during the server's start starts no runner: nothing is claimed for the stop to cut.
|
|
@@ -500,6 +563,9 @@ if (!values["no-runner"] && askedAt === undefined) {
|
|
|
500
563
|
process.exit(1);
|
|
501
564
|
}
|
|
502
565
|
console.error(`agentrun-serve: ${error.message}`);
|
|
566
|
+
// And said in the store, as the runner subcommand says it (presence.ts): while no runner that claims is there, the
|
|
567
|
+
// server refuses a launch in these words and fails the runs left queued, never queueing one for good.
|
|
568
|
+
serve.refuseRuns(error.message);
|
|
503
569
|
}
|
|
504
570
|
}
|
|
505
571
|
// A token from the environment is the operator's already, and the stored one is printed by the start that made it only.
|
|
@@ -514,10 +580,12 @@ if (serve.setupUrl && serve.setupOpen)
|
|
|
514
580
|
if (telemetry.notice)
|
|
515
581
|
console.error(telemetry.notice);
|
|
516
582
|
// The console's page, once the server listens: never its sign-in link, whose token would sit in the opener's arguments
|
|
517
|
-
// and the browser's history.
|
|
583
|
+
// and the browser's history. With no owner yet, the setup page instead, its code filled in when setup takes one: the
|
|
584
|
+
// first visit sets the password with nothing to look up. That code works once and for 30 minutes, unlike the token, so
|
|
585
|
+
// the opener's arguments and the browser's history hold nothing that outlasts the setup.
|
|
518
586
|
// API-only: there is no console, so nothing to open.
|
|
519
587
|
if (values.open && !apiOnly && canOpen(process.env))
|
|
520
|
-
spawn(process.platform === "darwin" ? "open" : "xdg-open", [`${publicUrl ?? serve.url}/`], { stdio: "ignore", detached: true }).on("error", () => { }).unref();
|
|
588
|
+
spawn(process.platform === "darwin" ? "open" : "xdg-open", [serve.setupUrl ?? `${publicUrl ?? serve.url}/`], { stdio: "ignore", detached: true }).on("error", () => { }).unref();
|
|
521
589
|
const record = join(resolve(data), SERVER_FILE);
|
|
522
590
|
// The record goes only while it is this server's: a server that takes the lock next writes its own, which this stop must
|
|
523
591
|
// not remove. One stop per press or process-manager stop; a later signal, or a stop past its deadline, stops at once
|