@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.48

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.
Files changed (292) hide show
  1. package/CHANGELOG.md +211 -1
  2. package/NOTICE +4 -0
  3. package/README.md +350 -53
  4. package/dist/acp-package.d.ts +53 -6
  5. package/dist/acp-package.js +3 -3
  6. package/dist/adapter-facts.d.ts +3 -4
  7. package/dist/adapter-facts.js +4 -4
  8. package/dist/adapters.d.ts +3 -5
  9. package/dist/adapters.js +1 -31
  10. package/dist/agents-store.d.ts +5 -3
  11. package/dist/agents-store.js +13 -8
  12. package/dist/answer-json.d.ts +10 -0
  13. package/dist/answer-json.js +24 -0
  14. package/dist/api-only.d.ts +11 -11
  15. package/dist/api-only.js +16 -11
  16. package/dist/archil-routes.js +2 -1
  17. package/dist/browser-live.d.ts +9 -4
  18. package/dist/browser-live.js +18 -5
  19. package/dist/cap.js +10 -2
  20. package/dist/chatgpt-plan.js +2 -1
  21. package/dist/cli.js +109 -41
  22. package/dist/composio-made.d.ts +19 -2
  23. package/dist/composio-made.js +17 -5
  24. package/dist/composio-preset.d.ts +42 -7
  25. package/dist/composio-preset.js +106 -70
  26. package/dist/composio-triggers.d.ts +9 -4
  27. package/dist/composio-triggers.js +20 -13
  28. package/dist/computer-attach.d.ts +11 -10
  29. package/dist/computer-attach.js +13 -14
  30. package/dist/computer-commands.d.ts +3 -0
  31. package/dist/computer-commands.js +3 -2
  32. package/dist/computer-lost.d.ts +4 -0
  33. package/dist/computer-lost.js +8 -3
  34. package/dist/computer-routes.d.ts +8 -5
  35. package/dist/computer-routes.js +7 -5
  36. package/dist/computer-setting.d.ts +2 -0
  37. package/dist/computer-setting.js +2 -0
  38. package/dist/computers.d.ts +14 -76
  39. package/dist/computers.js +24 -68
  40. package/dist/conformance.d.ts +4 -0
  41. package/dist/conformance.js +6 -0
  42. package/dist/console/assets/index-CTGegcKt.css +1 -0
  43. package/dist/console/assets/index-D1Se6mgG.js +715 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/cost-heal.d.ts +13 -0
  46. package/dist/cost-heal.js +27 -0
  47. package/dist/dial-relay.d.ts +6 -2
  48. package/dist/dial-relay.js +9 -12
  49. package/dist/email/routes.js +2 -1
  50. package/dist/errors.d.ts +2 -0
  51. package/dist/errors.js +5 -0
  52. package/dist/exa-keyless.d.ts +1 -1
  53. package/dist/exa-keyless.js +1 -1
  54. package/dist/faux-computers.d.ts +2 -3
  55. package/dist/faux-computers.js +9 -31
  56. package/dist/github-connection.js +2 -1
  57. package/dist/harness-archive.d.ts +19 -2
  58. package/dist/harness-archive.js +49 -15
  59. package/dist/harness-check.d.ts +75 -0
  60. package/dist/harness-check.js +518 -0
  61. package/dist/harness-cursor.d.ts +28 -0
  62. package/dist/harness-cursor.js +42 -0
  63. package/dist/harness-goose.d.ts +4 -29
  64. package/dist/harness-goose.js +6 -86
  65. package/dist/harness-module.d.ts +4 -0
  66. package/dist/harness-module.js +1 -0
  67. package/dist/harness-owned.d.ts +52 -0
  68. package/dist/harness-owned.js +92 -0
  69. package/dist/harness-recipe.d.ts +127 -0
  70. package/dist/harness-recipe.js +335 -0
  71. package/dist/harness-table.d.ts +120 -5
  72. package/dist/harness-table.js +280 -6
  73. package/dist/harness.d.ts +2 -0
  74. package/dist/harness.js +5 -4
  75. package/dist/host-check.d.ts +6 -0
  76. package/dist/host-check.js +14 -0
  77. package/dist/host.d.ts +10 -3
  78. package/dist/host.js +17 -3
  79. package/dist/import-sources.d.ts +2 -0
  80. package/dist/import-sources.js +2 -0
  81. package/dist/import-summary.d.ts +15 -5
  82. package/dist/import-summary.js +24 -8
  83. package/dist/import.d.ts +24 -4
  84. package/dist/import.js +108 -26
  85. package/dist/key-refusal.d.ts +3 -1
  86. package/dist/key-refusal.js +26 -5
  87. package/dist/key-words.d.ts +1 -1
  88. package/dist/key-words.js +4 -4
  89. package/dist/learn/check.d.ts +3 -0
  90. package/dist/learn/check.js +31 -20
  91. package/dist/learn/compile.js +12 -5
  92. package/dist/learn/promote.d.ts +80 -2
  93. package/dist/learn/promote.js +95 -3
  94. package/dist/learn/secrets.d.ts +4 -0
  95. package/dist/learn/secrets.js +23 -0
  96. package/dist/learned-nodes.d.ts +4 -3
  97. package/dist/learned-workflow.js +4 -1
  98. package/dist/learning-cost.d.ts +6 -16
  99. package/dist/learning-cost.js +6 -12
  100. package/dist/learning-model.d.ts +18 -0
  101. package/dist/learning-model.js +77 -0
  102. package/dist/learning-words.d.ts +2 -0
  103. package/dist/learning-words.js +1 -1
  104. package/dist/listen-first.d.ts +10 -0
  105. package/dist/listen-first.js +25 -1
  106. package/dist/llms.txt +2 -1
  107. package/dist/mcp-gateway.d.ts +2 -1
  108. package/dist/mcp-gateway.js +31 -15
  109. package/dist/mcp-probe.d.ts +18 -6
  110. package/dist/mcp-probe.js +41 -8
  111. package/dist/mcp-secret-writes.d.ts +8 -0
  112. package/dist/mcp-secret-writes.js +104 -4
  113. package/dist/mcp-servers-store.d.ts +11 -5
  114. package/dist/mcp-servers-store.js +46 -20
  115. package/dist/model-form.d.ts +2 -1
  116. package/dist/model-form.js +30 -16
  117. package/dist/model-gateway.d.ts +113 -0
  118. package/dist/model-gateway.js +433 -0
  119. package/dist/model.d.ts +5 -3
  120. package/dist/model.js +26 -18
  121. package/dist/monid.js +1 -1
  122. package/dist/native/binding.d.ts +4 -0
  123. package/dist/native/binding.js +9 -0
  124. package/dist/native/cli.d.ts +3 -2
  125. package/dist/native/cli.js +6 -5
  126. package/dist/openapi.d.ts +2 -0
  127. package/dist/openapi.js +356 -43
  128. package/dist/owner.d.ts +4 -2
  129. package/dist/owner.js +10 -4
  130. package/dist/page.d.ts +9 -0
  131. package/dist/page.js +10 -2
  132. package/dist/port-models.js +17 -10
  133. package/dist/provider.d.ts +3 -3
  134. package/dist/provider.js +12 -3
  135. package/dist/public-address.d.ts +28 -0
  136. package/dist/public-address.js +62 -0
  137. package/dist/run-launch.d.ts +1 -1
  138. package/dist/run-launch.js +1 -1
  139. package/dist/run-secrets.d.ts +3 -2
  140. package/dist/run-secrets.js +7 -4
  141. package/dist/run-trace.js +6 -3
  142. package/dist/runner/adapter-loop.d.ts +14 -8
  143. package/dist/runner/adapter-loop.js +58 -24
  144. package/dist/runner/adapter-run-spec.d.ts +15 -2
  145. package/dist/runner/adapter-run-spec.js +48 -10
  146. package/dist/runner/adapters/index.d.ts +4 -2
  147. package/dist/runner/adapters/index.js +6 -26
  148. package/dist/runner/adapters/pi.d.ts +5 -2
  149. package/dist/runner/adapters/pi.js +7 -4
  150. package/dist/runner/audit.d.ts +7 -0
  151. package/dist/runner/audit.js +15 -6
  152. package/dist/runner/claim-secrets.js +5 -1
  153. package/dist/runner/cli-run-spec.js +22 -10
  154. package/dist/runner/compare-end.d.ts +43 -0
  155. package/dist/runner/compare-end.js +95 -0
  156. package/dist/runner/computer-journal.d.ts +3 -0
  157. package/dist/runner/computer-journal.js +22 -2
  158. package/dist/runner/conformance/host-tools.d.ts +4 -0
  159. package/dist/runner/conformance/host-tools.js +14 -0
  160. package/dist/runner/harness-loops.d.ts +6 -1
  161. package/dist/runner/harness-loops.js +94 -54
  162. package/dist/runner/held.d.ts +5 -4
  163. package/dist/runner/journal-kinds.d.ts +4 -1
  164. package/dist/runner/journal-kinds.js +3 -0
  165. package/dist/runner/loop-contract.d.ts +10 -0
  166. package/dist/runner/main.d.ts +5 -5
  167. package/dist/runner/main.js +62 -11
  168. package/dist/runner/mcp-claim.js +40 -12
  169. package/dist/runner/meta-tools.js +4 -2
  170. package/dist/runner/metrics.d.ts +26 -0
  171. package/dist/runner/metrics.js +44 -1
  172. package/dist/runner/presence.d.ts +44 -0
  173. package/dist/runner/presence.js +96 -0
  174. package/dist/runner/promotion.d.ts +70 -7
  175. package/dist/runner/promotion.js +178 -28
  176. package/dist/runner/run-child-host.js +40 -10
  177. package/dist/runner/runner.d.ts +5 -0
  178. package/dist/runner/runner.js +8 -0
  179. package/dist/runner/sdk-loop.js +25 -1
  180. package/dist/runner/store-port.d.ts +3 -0
  181. package/dist/runner/store-secrets.js +19 -7
  182. package/dist/runner/workflow-first.d.ts +5 -2
  183. package/dist/runner/workflow-first.js +6 -3
  184. package/dist/runner/workflow-spec.js +3 -2
  185. package/dist/runs-over-store.d.ts +7 -2
  186. package/dist/runs-over-store.js +12 -4
  187. package/dist/sdk/check.d.ts +31 -0
  188. package/dist/sdk/check.js +58 -0
  189. package/dist/sdk/runs.d.ts +11 -3
  190. package/dist/sdk/runs.js +90 -15
  191. package/dist/sdk/schema.js +12 -4
  192. package/dist/secret-writes.d.ts +16 -3
  193. package/dist/secret-writes.js +28 -3
  194. package/dist/server-secrets-store.js +5 -0
  195. package/dist/server.d.ts +34 -2
  196. package/dist/server.js +437 -90
  197. package/dist/sign-ins-secrets.js +4 -1
  198. package/dist/skills/agentrun-serve/SKILL.md +11 -0
  199. package/dist/slack-url.d.ts +5 -0
  200. package/dist/slack-url.js +11 -0
  201. package/dist/slack.d.ts +107 -0
  202. package/dist/slack.js +292 -0
  203. package/dist/start-switches.d.ts +28 -0
  204. package/dist/start-switches.js +37 -0
  205. package/dist/stats.d.ts +1 -1
  206. package/dist/stats.js +2 -1
  207. package/dist/stop-signals.d.ts +11 -0
  208. package/dist/stop-signals.js +22 -0
  209. package/dist/store/agent-body.d.ts +1 -1
  210. package/dist/store/agent-body.js +2 -2
  211. package/dist/store/index.d.ts +3 -3
  212. package/dist/store/index.js +1 -1
  213. package/dist/store/postgres/migrations/0020_runners.sql +18 -0
  214. package/dist/store/postgres/store.d.ts +1 -1
  215. package/dist/store/postgres/store.js +4 -2
  216. package/dist/store/schema.d.ts +13 -5
  217. package/dist/store/schema.js +20 -11
  218. package/dist/store/seal.d.ts +16 -4
  219. package/dist/store/sqlite/store.d.ts +1 -1
  220. package/dist/store/sqlite/store.js +112 -28
  221. package/dist/store/store.d.ts +78 -24
  222. package/dist/store/store.js +11 -0
  223. package/dist/store-reads/analytics.js +3 -2
  224. package/dist/store-reads/cap.d.ts +7 -0
  225. package/dist/store-reads/cap.js +11 -1
  226. package/dist/store-reads/journal.js +27 -1
  227. package/dist/store-reads/learning.d.ts +23 -2
  228. package/dist/store-reads/learning.js +29 -8
  229. package/dist/store-reads/runs.d.ts +9 -0
  230. package/dist/store-reads/runs.js +19 -6
  231. package/dist/store-reads/stats.d.ts +4 -1
  232. package/dist/store-reads/stats.js +15 -6
  233. package/dist/store-view.d.ts +125 -14
  234. package/dist/store-view.js +156 -21
  235. package/dist/telemetry.d.ts +7 -7
  236. package/dist/telemetry.js +38 -15
  237. package/dist/template-eval.js +5 -2
  238. package/dist/template-github-permissions.d.ts +5 -1
  239. package/dist/template-github-permissions.js +7 -3
  240. package/dist/timeline/index.d.ts +1 -1
  241. package/dist/timeline/index.js +1 -1
  242. package/dist/timeline/timeline.d.ts +8 -0
  243. package/dist/timeline/timeline.js +30 -0
  244. package/dist/tool-gate.d.ts +8 -4
  245. package/dist/tool-gate.js +6 -7
  246. package/dist/tool-keys-store.js +2 -2
  247. package/dist/tool-keys.js +2 -1
  248. package/dist/tool-plane.d.ts +4 -0
  249. package/dist/tool-plane.js +12 -12
  250. package/dist/trigger-adapter.d.ts +3 -4
  251. package/dist/trigger-adapter.js +2 -2
  252. package/dist/trigger-composio.js +3 -3
  253. package/dist/trigger-email.js +0 -2
  254. package/dist/trigger-feed.js +0 -2
  255. package/dist/trigger-schedule.js +3 -0
  256. package/dist/trigger-secrets-shown.d.ts +6 -3
  257. package/dist/trigger-secrets-shown.js +22 -13
  258. package/dist/trigger-targets.d.ts +12 -3
  259. package/dist/trigger-targets.js +90 -10
  260. package/dist/triggers.d.ts +2 -2
  261. package/dist/validate.js +5 -1
  262. package/dist/viewer-credential.d.ts +25 -0
  263. package/dist/viewer-credential.js +51 -0
  264. package/dist/webhooks.d.ts +82 -8
  265. package/dist/webhooks.js +128 -45
  266. package/dist/wires.d.ts +6 -1
  267. package/dist/wires.js +5 -0
  268. package/dist/workspace/attach.d.ts +3 -2
  269. package/dist/workspace/attach.js +2 -1
  270. package/dist/workspace/attached-computers.d.ts +6 -8
  271. package/dist/workspace/attached-computers.js +27 -24
  272. package/dist/workspace/computer-deps.d.ts +2 -3
  273. package/dist/workspace/computer-deps.js +3 -6
  274. package/dist/workspace/computer-for-claim.js +72 -96
  275. package/dist/workspace/computer-kept.d.ts +0 -7
  276. package/dist/workspace/computer-kept.js +0 -17
  277. package/dist/workspace/resolve-computer.d.ts +23 -14
  278. package/dist/workspace/resolve-computer.js +66 -61
  279. package/dist/workspace/synced-folder.d.ts +20 -15
  280. package/dist/workspace/synced-folder.js +33 -43
  281. package/launcher/agentrun-serve +4 -1
  282. package/package.json +18 -10
  283. package/skills/agentrun-serve/SKILL.md +11 -0
  284. package/templates/README.md +1 -1
  285. package/templates/code-review/agent.md +2 -3
  286. package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
  287. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
  288. package/templates/code-review/evals/other-repo/case.yaml +0 -1
  289. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
  290. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
  291. package/dist/console/assets/index-C2MYaUBa.css +0 -1
  292. package/dist/console/assets/index-CZZeCReB.js +0 -701
@@ -1,27 +1,74 @@
1
1
  import type { AdapterFacts, AgentAdapter } from "@parcha/agentrun-kernel";
2
+ import type { AcpRecipe } from "@parcha/agentrun-harness-acp";
2
3
  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
+ /** One platform's release of an ACP agent, as the pin holds it (the package's AcpArchivePin). */
4
5
  export type AcpRelease = {
5
6
  readonly url: string;
6
7
  readonly format: string;
7
8
  readonly sha256: string;
8
9
  readonly cmd: string;
9
10
  readonly binarySha256?: string;
11
+ readonly treeSha256?: string;
12
+ };
13
+ /** A pinned release of an ACP agent (the package's AcpBinaryPin). */
14
+ export type AcpPin = {
15
+ readonly id: string;
16
+ readonly version: string;
17
+ readonly archives: Readonly<Partial<Record<string, AcpRelease>>>;
10
18
  };
11
19
  /** What serve reads of the package. */
12
20
  export type AcpPackage = {
13
21
  readonly gooseFacts: AdapterFacts;
14
- readonly GOOSE_PIN: {
15
- readonly id: string;
16
- readonly version: string;
17
- readonly archives: Readonly<Partial<Record<string, AcpRelease>>>;
18
- };
22
+ readonly GOOSE_PIN: AcpPin;
19
23
  readonly GOOSE_INSTALL: string;
20
24
  readonly GOOSE_NOT_INSTALLED: string;
25
+ readonly cursorFacts: AdapterFacts;
26
+ readonly CURSOR_PIN: AcpPin;
27
+ readonly CURSOR_INSTALL: string;
28
+ readonly CURSOR_CODES: {
29
+ readonly headlessDisabled: string;
30
+ readonly notInstalled: string;
31
+ };
32
+ readonly CURSOR_LIMITS: {
33
+ readonly maxTurns: number;
34
+ readonly maxToolCalls: number;
35
+ };
36
+ cursorCard(limits: {
37
+ readonly maxTurns: number;
38
+ readonly maxToolCalls: number;
39
+ }): string;
40
+ cursorAdapter(options: Record<string, unknown>): AgentAdapter;
41
+ /** Cursor's recipe for a run: its launcher, the run's limits, and its model (none: Cursor's own default). */
42
+ cursorRecipe(options: {
43
+ command: string;
44
+ limits: {
45
+ readonly maxTurns: number;
46
+ readonly maxToolCalls: number;
47
+ };
48
+ model?: string;
49
+ }): AcpRecipe;
50
+ /** The folder Cursor was installed into, from its launcher's path and the pin's `cmd`; undefined when it is not there. */
51
+ cursorRootOf(binary: string, cmd: string): string | undefined;
52
+ /** The form a model id an ACP agent lists takes (Cursor's `gpt-5.4-nano[reasoning=medium]` among them). */
53
+ readonly MODEL_ID: RegExp;
21
54
  acpPlatform(): string | undefined;
55
+ /** `pin`'s release for `platform` (default this host's) with its binary's digest, and its tree's when `tree`; undefined
56
+ * where none is pinned so. */
57
+ pinnedRelease(pin: AcpPin, platform?: string, tree?: boolean): (AcpRelease & {
58
+ readonly binarySha256: string;
59
+ }) | undefined;
22
60
  gooseAdapter(options: Record<string, unknown>): AgentAdapter;
61
+ /** Any ACP agent's adapter, from its recipe (a harness module's, harness-table.ts acpEntry). */
62
+ acpAdapter(options: Record<string, unknown>): AgentAdapter;
63
+ /** The model proxy on Anthropic's Messages, Goose's policy (a recipe's under harness-check). */
64
+ gooseProxy(options: Record<string, unknown>): (session: unknown) => Promise<{
65
+ env: Record<string, string>;
66
+ close(): Promise<void>;
67
+ }>;
23
68
  verifyPinnedBinary(path: string, sha256: string): void;
24
69
  verifyPinnedBinaryAsync(path: string, sha256: string): Promise<void>;
70
+ treeDigest(root: string): Promise<string>;
71
+ verifyPinnedTree(root: string, sha256: string): Promise<void>;
25
72
  };
26
73
  /** The package, or undefined where it is not installed beside serve. Only its absence is: a package that is there and
27
74
  * fails to load throws. */
@@ -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. 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.
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);
@@ -4,7 +4,6 @@ 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
- /** 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;
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;
@@ -7,7 +7,7 @@ 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
- /** 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);
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
+ // A harness's facts by id are its table entry's (harness-table.ts factsOf), so a module's harness is read as a built-in is.
@@ -2,6 +2,7 @@ import type { AdapterFacts, AgentAdapter, SessionSpec } from "@parcha/agentrun-k
2
2
  import { type HarnessPins, type LoadedSdk } from "./harness-install.js";
3
3
  import { type HarnessEntry } from "./harness-table.js";
4
4
  import type { ModelRef } from "./model.js";
5
+ import { type InstallFix } from "./provider.js";
5
6
  import type { SkillCheck, SkillFiles } from "./skills.js";
6
7
  /** Whether this server runs from npx's cache (`npx @parcha/agentrun-serve`), where there is no project to install a
7
8
  * package into: npm keeps what npx runs under `<npm cache>/_npx/<hash>/node_modules`. Read from where this file is, not
@@ -53,6 +54,8 @@ export declare const HARNESS_LOG_EVENT = "harness";
53
54
  * place, or one serve holds, never reaches the log.
54
55
  */
55
56
  export declare function harnessLog(harness: string, env: NodeJS.ProcessEnv, write?: (line: string) => void): (message: string, fields?: Record<string, unknown>) => void;
57
+ /** What an adapter's own setup error says installing fixes, by the code its facts name for each: none for any other error. */
58
+ export declare function fixOf(facts: AdapterFacts, error: unknown): InstallFix | undefined;
56
59
  /** The reason the start's probe gives for `error`: its message, ending with the restart (RESTART) where installing is
57
60
  * the fix. A message whose install line is npx's has no `fix`: running that line is the restart. */
58
61
  export declare function startReason(error: unknown): string;
@@ -148,11 +151,6 @@ export declare function codexOf(env: NodeJS.ProcessEnv, needs: AdapterNeeds, loa
148
151
  * its wire's do (providerFor): serve's gateway (AGENT_MODEL_BASE_URL), OpenAI or OpenRouter, on the Responses API,
149
152
  * through the adapter's proxy. */
150
153
  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>;
156
154
  /** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
157
155
  * 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
156
  * 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
@@ -139,7 +139,7 @@ export function harnessLog(harness, env, write = (line) => void process.stderr.w
139
139
  };
140
140
  }
141
141
  /** What an adapter's own setup error says installing fixes, by the code its facts name for each: none for any other error. */
142
- function fixOf(facts, error) {
142
+ export function fixOf(facts, error) {
143
143
  const code = error?.code;
144
144
  return code === facts.install.codes.install ? "install" : code === facts.install.codes.pins ? "pins" : undefined;
145
145
  }
@@ -369,36 +369,6 @@ export async function opencodeOf(env, needs, load = () => import("./harness-open
369
369
  const skills = needs.skills && servedSkills(needs.skills);
370
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 } : {}) });
371
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
- }
402
372
  /** Why `harness` cannot run here, or undefined when it can (its entry's refusal): its package and pins, its provider, and
403
373
  * 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
374
  * all). `atStart`: asked by the start's probe, whose offers hold until a restart, so a reason installing fixes ends
@@ -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, name
75
- * and description from its creation. `ifCurrent` (from If-Match) is the current revision the caller read, null for none;
76
- * it is checked against the agent's current revision when the edit is read, and the write is conditional on the revision
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
@@ -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, name
233
- * and description from its creation. `ifCurrent` (from If-Match) is the current revision the caller read, null for none;
234
- * it is checked against the agent's current revision when the edit is read, and the write is conditional on the revision
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", "description"]
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
- if (!contract && now.revision && sameRevision(now.revision, revision)) {
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) {
@@ -53,4 +53,14 @@ export declare function answerAsServed(output: string, schema: unknown): {
53
53
  } | {
54
54
  why: string;
55
55
  };
56
+ /** The output-schema annotation naming the top-level fields of an answer that its agent's next run reads back: a list of
57
+ * the root's property names (a scheduled watch's `seen`, a digest's `open_urgent`). The runtime reads it alone: when a
58
+ * trigger's last completed result is too large to hand whole, its next run is handed those fields
59
+ * (trigger-targets.ts previousResultOf). Never a tool's schema keyword: dsl submitParameters leaves it out. */
60
+ export declare const X_CARRIED = "x-carried";
61
+ /** Why `schema`'s `x-carried` is not a list of unique names of the root's `properties`; undefined when it is, or absent. */
62
+ export declare function carriedProblem(schema: Record<string, unknown>): string | undefined;
63
+ /** The fields `schema` names in `x-carried`, when it names a list of them (one saved before the save checked it may not):
64
+ * undefined for none. */
65
+ export declare function carriedFields(schema: unknown): readonly string[] | undefined;
56
66
  export {};
@@ -138,3 +138,27 @@ export function answerAsServed(output, schema) {
138
138
  const problems = compiled.check(shapes.find(isObject) ?? shapes[0]);
139
139
  return { why: `its answer does not meet the agent's output schema: ${problems.slice(0, 3).join("; ")}` };
140
140
  }
141
+ /** The output-schema annotation naming the top-level fields of an answer that its agent's next run reads back: a list of
142
+ * the root's property names (a scheduled watch's `seen`, a digest's `open_urgent`). The runtime reads it alone: when a
143
+ * trigger's last completed result is too large to hand whole, its next run is handed those fields
144
+ * (trigger-targets.ts previousResultOf). Never a tool's schema keyword: dsl submitParameters leaves it out. */
145
+ export const X_CARRIED = "x-carried";
146
+ /** Why `schema`'s `x-carried` is not a list of unique names of the root's `properties`; undefined when it is, or absent. */
147
+ export function carriedProblem(schema) {
148
+ const carried = schema[X_CARRIED];
149
+ if (carried === undefined)
150
+ return undefined;
151
+ if (!Array.isArray(carried) || !carried.every((name) => typeof name === "string" && name !== ""))
152
+ return "is a list of the names of the root's properties";
153
+ if (new Set(carried).size !== carried.length)
154
+ return "names a property twice";
155
+ const properties = isObject(schema.properties) ? schema.properties : {};
156
+ const unknown = carried.filter((name) => !Object.hasOwn(properties, name));
157
+ return unknown.length ? `names ${unknown.map((name) => JSON.stringify(name)).join(", ")}, which the root's properties have no field for` : undefined;
158
+ }
159
+ /** The fields `schema` names in `x-carried`, when it names a list of them (one saved before the save checked it may not):
160
+ * undefined for none. */
161
+ export function carriedFields(schema) {
162
+ const carried = isObject(schema) ? schema[X_CARRIED] : undefined;
163
+ return Array.isArray(carried) && carried.length > 0 && carried.every((name) => typeof name === "string") ? carried : undefined;
164
+ }
@@ -1,22 +1,22 @@
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: a run's launch, read, list, timeline, messages,
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); 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). */
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.
11
+ * - getRunComputer, takeOverRunComputer, handBackRunComputer, createRunComputerViewer: a run's computer, its take-over
12
+ * and hand-back, and its viewer credential's mint (viewer-credential.ts), by the server's token, the backend's own;
13
+ * the live page and socket take that credential. */
14
14
  export declare const API_ONLY_ROUTES: ReadonlySet<string>;
15
15
  /** Whether `env` turns the profile on: `1` or `true` on; unset, empty, `0` or `false` off. Any other value is refused in
16
16
  * words (a TypeError), so a typo never leaves the console open on a server meant to be API-only. */
17
17
  export declare function apiOnlyFrom(env?: NodeJS.ProcessEnv): boolean;
18
18
  /** Whether an API-only server serves `method` on `raw` (the path as sent, its query cut): a /v2 path one of
19
- * API_ONLY_ROUTES matches for that method (HEAD as GET). */
19
+ * API_ONLY_ROUTES matches for that method (HEAD as GET), or a GET of a run's computer live view. */
20
20
  export declare function servedApiOnly(routes: readonly Route[], method: string | undefined, raw: string): boolean;
21
21
  /** The refusal's words for `raw` on an API-only server. */
22
22
  export declare const apiOnlyRefusal: (raw: string) => string;
package/dist/api-only.js CHANGED
@@ -1,17 +1,18 @@
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: a run's launch, read, list, timeline, messages,
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); 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). */
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.
10
+ * - getRunComputer, takeOverRunComputer, handBackRunComputer, createRunComputerViewer: a run's computer, its take-over
11
+ * and hand-back, and its viewer credential's mint (viewer-credential.ts), by the server's token, the backend's own;
12
+ * the live page and socket take that credential. */
13
13
  export const API_ONLY_ROUTES = new Set([
14
14
  "createRun", "createInlineRun", "getComputerDaemon",
15
+ "getRunComputer", "takeOverRunComputer", "handBackRunComputer", "createRunComputerViewer",
15
16
  "listComputers", "getWorkspaceArchil",
16
17
  "getAgentArchil", "deleteAgentArchil", "deleteAgent",
17
18
  "getRun", "listRuns", "listAllRuns", "getTimeline",
@@ -30,13 +31,17 @@ export function apiOnlyFrom(env = process.env) {
30
31
  return false;
31
32
  throw new TypeError(`${API_ONLY_ENV} is 1 (serve the run API only) or 0 (the whole server), not ${JSON.stringify(env[API_ONLY_ENV])}`);
32
33
  }
34
+ /** A run's computer live view: its page, files and socket, which take the viewer credential alone here (server.ts). */
35
+ const COMPUTER_LIVE = /^\/v2\/runs\/[^/]+\/computer\/live\//;
33
36
  /** Whether an API-only server serves `method` on `raw` (the path as sent, its query cut): a /v2 path one of
34
- * API_ONLY_ROUTES matches for that method (HEAD as GET). */
37
+ * API_ONLY_ROUTES matches for that method (HEAD as GET), or a GET of a run's computer live view. */
35
38
  export function servedApiOnly(routes, method, raw) {
36
39
  if (!raw.startsWith("/v2/"))
37
40
  return false;
38
41
  const path = raw.slice(3);
39
42
  const asked = method === "HEAD" ? "GET" : method;
43
+ if (asked === "GET" && COMPUTER_LIVE.test(raw))
44
+ return true;
40
45
  return routes.some((route) => API_ONLY_ROUTES.has(route.name) && route.method === asked && route.pattern.test(path));
41
46
  }
42
47
  /** The refusal's words for `raw` on an API-only server. */
@@ -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. */
@@ -101,13 +101,18 @@ export declare function serveViewerFile(req: IncomingMessage, res: ServerRespons
101
101
  /** How often an open viewer's session is checked again. A reset-password run in another process and a cookie past its end
102
102
  * are seen by no call in this one, so a viewer they end closes within this. */
103
103
  export declare const LIVE_RECHECK_MS = 2000;
104
- /** The viewers' sockets open now, each with the check of the sessions that let it in. A socket whose sessions no longer
105
- * hold is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or a
106
- * password set in this process), else within LIVE_RECHECK_MS. The timer runs only while a viewer is open. */
104
+ /** The viewers' sockets open now, each with the check of what let it in: the owner's sessions, or on an API-only server
105
+ * the viewer credential's run not ended (viewer-credential.ts), read from the store. A socket whose check no longer holds,
106
+ * or fails, is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or
107
+ * a password set in this process; a store read as soon as it answers), else within LIVE_RECHECK_MS. A socket has one
108
+ * store read in flight at most: a slow store is not asked again for it until that read answers. The timer runs only
109
+ * while a viewer is open. */
107
110
  export declare class OpenViewers {
108
111
  private readonly open;
112
+ /** The sockets whose store read is in flight. */
113
+ private readonly reading;
109
114
  private timer;
110
- watch(socket: Duplex, admitted: () => boolean): void;
115
+ watch(socket: Duplex, admitted: () => boolean | Promise<boolean>): void;
111
116
  recheck(): void;
112
117
  /** The server closes: every viewer goes. */
113
118
  close(): void;
@@ -190,11 +190,16 @@ export async function serveViewerFile(req, res, rest, page = "browser") {
190
190
  /** How often an open viewer's session is checked again. A reset-password run in another process and a cookie past its end
191
191
  * are seen by no call in this one, so a viewer they end closes within this. */
192
192
  export const LIVE_RECHECK_MS = 2_000;
193
- /** The viewers' sockets open now, each with the check of the sessions that let it in. A socket whose sessions no longer
194
- * hold is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or a
195
- * password set in this process), else within LIVE_RECHECK_MS. The timer runs only while a viewer is open. */
193
+ /** The viewers' sockets open now, each with the check of what let it in: the owner's sessions, or on an API-only server
194
+ * the viewer credential's run not ended (viewer-credential.ts), read from the store. A socket whose check no longer holds,
195
+ * or fails, is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or
196
+ * a password set in this process; a store read as soon as it answers), else within LIVE_RECHECK_MS. A socket has one
197
+ * store read in flight at most: a slow store is not asked again for it until that read answers. The timer runs only
198
+ * while a viewer is open. */
196
199
  export class OpenViewers {
197
200
  open = new Map();
201
+ /** The sockets whose store read is in flight. */
202
+ reading = new Set();
198
203
  timer;
199
204
  watch(socket, admitted) {
200
205
  this.open.set(socket, admitted);
@@ -202,9 +207,17 @@ export class OpenViewers {
202
207
  this.timer ??= setInterval(() => this.recheck(), LIVE_RECHECK_MS).unref();
203
208
  }
204
209
  recheck() {
205
- for (const [socket, admitted] of this.open)
206
- if (!admitted())
210
+ for (const [socket, admitted] of this.open) {
211
+ if (this.reading.has(socket))
212
+ continue;
213
+ const holds = admitted();
214
+ if (holds === false)
207
215
  this.end(socket);
216
+ else if (holds !== true) {
217
+ this.reading.add(socket);
218
+ holds.then((still) => still || this.end(socket), () => this.end(socket)).finally(() => this.reading.delete(socket));
219
+ }
220
+ }
208
221
  }
209
222
  /** The server closes: every viewer goes. */
210
223
  close() {
package/dist/cap.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // What a run's spend cap leaves behind in serve once the kernel's cap (run-adapters kernel/cap) holds the money: the
2
2
  // refusal's code and words as every reader of a refusal reads them, the cap modes a run is created with, and the spend
3
3
  // and /usage meters read back from a run's entries (spentFrom, meterFiguresFrom), over marks the kernel's cap also reads.
4
- import { REQUEST_COST, REQUEST_COST_LATE, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, REQUEST_CONTINUED, timelineOf, TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
4
+ import { compactionAnswers, REQUEST_COST, REQUEST_COST_LATE, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, REQUEST_CONTINUED, timelineOf, TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
5
5
  /** How a request the cap refused begins its error, which the server ends the run with. */
6
6
  export const SPEND_CAP_REACHED = "spend_cap_reached";
7
7
  /** How near two dollar figures are the same figure: a sum a float puts a hair past the cap (0.0028 + 0.3072 is
@@ -80,12 +80,20 @@ const close = (open, figure) => {
80
80
  function openFigures(entries) {
81
81
  const open = { generation: [], compaction: [] };
82
82
  let [refused, continued] = [0, 0];
83
+ const sideSummaries = { count: 0 };
83
84
  for (const entry of entries) {
84
85
  const message = entry.model?.[0];
85
86
  const data = (entry.data ?? {});
86
87
  // A side request (a compaction's summary, a tool's own request): marked with a label, as the timeline reads it.
87
88
  const kind = typeof data.request === "string" ? "compaction" : "generation";
88
- if (entry.kind === REQUEST_REFUSED)
89
+ // pi's compaction entry answers its summary request when that left marked as a generation, by the timeline's own
90
+ // rule (compactionAnswers). One marked as a side request is closed by its cost.
91
+ const summaryAnswered = compactionAnswers(entry, sideSummaries);
92
+ if (entry.kind === "pi.compaction") {
93
+ if (summaryAnswered)
94
+ close(open.generation);
95
+ }
96
+ else if (entry.kind === REQUEST_REFUSED)
89
97
  refused += 1;
90
98
  else if (entry.kind === "pi.assistant" && refused > 0 && message?.stopReason === "error")
91
99
  refused -= 1;
@@ -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. */