@parcha/agentrun-serve 0.1.0-beta.54 → 0.1.0-beta.56

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 (234) hide show
  1. package/CHANGELOG.md +142 -2
  2. package/README.md +310 -98
  3. package/dist/adapters.d.ts +11 -0
  4. package/dist/adapters.js +49 -0
  5. package/dist/agent-package.d.ts +3 -3
  6. package/dist/agent-package.js +6 -13
  7. package/dist/agents-store.js +6 -5
  8. package/dist/answer-json.d.ts +6 -2
  9. package/dist/answer-json.js +22 -4
  10. package/dist/api-only.d.ts +16 -4
  11. package/dist/api-only.js +23 -7
  12. package/dist/calendar/tools.js +3 -2
  13. package/dist/chatgpt-plan.d.ts +16 -1
  14. package/dist/chatgpt-plan.js +116 -12
  15. package/dist/claude-login.d.ts +34 -5
  16. package/dist/claude-login.js +31 -7
  17. package/dist/claude-sign-in.d.ts +35 -0
  18. package/dist/claude-sign-in.js +90 -0
  19. package/dist/cli.js +5 -3
  20. package/dist/composio-made.d.ts +26 -1
  21. package/dist/composio-made.js +39 -2
  22. package/dist/composio-preset.d.ts +3 -2
  23. package/dist/composio-preset.js +46 -14
  24. package/dist/computer-held-routes.js +2 -3
  25. package/dist/computer-setting.d.ts +4 -2
  26. package/dist/computer-setting.js +0 -2
  27. package/dist/computers-running.d.ts +8 -0
  28. package/dist/computers-running.js +27 -0
  29. package/dist/console/assets/backend-Boh7tC4i.js +166 -0
  30. package/dist/console/assets/index-CQ3cJRzI.js +746 -0
  31. package/dist/console/assets/index-DKkaS3a0.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/docker-host-addresses.d.ts +23 -3
  34. package/dist/docker-host-addresses.js +90 -18
  35. package/dist/exa-keyless.d.ts +2 -3
  36. package/dist/exa-keyless.js +43 -127
  37. package/dist/firecrawl-keyless.d.ts +41 -0
  38. package/dist/firecrawl-keyless.js +152 -0
  39. package/dist/handed-secret.d.ts +3 -1
  40. package/dist/handed-secret.js +4 -2
  41. package/dist/harness-keys.d.ts +98 -0
  42. package/dist/harness-keys.js +247 -0
  43. package/dist/harness-recipe-entry.d.ts +14 -9
  44. package/dist/harness-recipe-entry.js +25 -14
  45. package/dist/harness-table.d.ts +16 -1
  46. package/dist/harness-table.js +19 -7
  47. package/dist/harness.d.ts +4 -0
  48. package/dist/harness.js +12 -1
  49. package/dist/host-check.d.ts +6 -0
  50. package/dist/host-check.js +10 -0
  51. package/dist/import-summary.d.ts +1 -1
  52. package/dist/import-summary.js +1 -1
  53. package/dist/import.d.ts +5 -5
  54. package/dist/import.js +54 -67
  55. package/dist/key-refusal.d.ts +21 -5
  56. package/dist/key-refusal.js +231 -37
  57. package/dist/keyless-mcp.d.ts +36 -0
  58. package/dist/keyless-mcp.js +127 -0
  59. package/dist/learn/audit.d.ts +3 -3
  60. package/dist/learn/audit.js +3 -3
  61. package/dist/learn/commit.d.ts +8 -7
  62. package/dist/learn/commit.js +60 -20
  63. package/dist/learn/compile.d.ts +4 -3
  64. package/dist/learn/compile.js +7 -5
  65. package/dist/learn/folder.d.ts +16 -3
  66. package/dist/learn/folder.js +46 -13
  67. package/dist/learn/promote.d.ts +37 -13
  68. package/dist/learn/promote.js +112 -40
  69. package/dist/learn/secrets.d.ts +20 -10
  70. package/dist/learn/secrets.js +44 -176
  71. package/dist/learning-routes.d.ts +22 -17
  72. package/dist/learning-routes.js +40 -39
  73. package/dist/learning.js +2 -2
  74. package/dist/llms.txt +1 -1
  75. package/dist/manifest.d.ts +10 -0
  76. package/dist/manifest.js +30 -0
  77. package/dist/mcp-pin-first.d.ts +4 -2
  78. package/dist/mcp-pin-first.js +5 -2
  79. package/dist/mcp-secret-writes.d.ts +16 -7
  80. package/dist/mcp-secret-writes.js +35 -27
  81. package/dist/mcp-servers-store.d.ts +30 -6
  82. package/dist/mcp-servers-store.js +112 -28
  83. package/dist/mcp-sources.d.ts +10 -2
  84. package/dist/mcp-sources.js +9 -2
  85. package/dist/mcp-store.d.ts +13 -7
  86. package/dist/mcp-store.js +12 -9
  87. package/dist/model-form.d.ts +3 -2
  88. package/dist/model-form.js +11 -7
  89. package/dist/model.d.ts +20 -4
  90. package/dist/model.js +68 -9
  91. package/dist/native/history.d.ts +1 -1
  92. package/dist/native/history.js +2 -2
  93. package/dist/ollama-provider.d.ts +92 -0
  94. package/dist/ollama-provider.js +495 -0
  95. package/dist/openapi/agentrun-v2.openapi.json +2 -2
  96. package/dist/openapi.d.ts +3 -3
  97. package/dist/openapi.js +197 -55
  98. package/dist/page.d.ts +11 -3
  99. package/dist/page.js +22 -7
  100. package/dist/place-offers.d.ts +25 -1
  101. package/dist/place-offers.js +62 -8
  102. package/dist/print.js +1 -1
  103. package/dist/purged-workflow.d.ts +35 -7
  104. package/dist/purged-workflow.js +73 -26
  105. package/dist/redact/match.d.ts +74 -0
  106. package/dist/redact/match.js +771 -0
  107. package/dist/run-computer.d.ts +2 -0
  108. package/dist/run-computer.js +2 -0
  109. package/dist/run-files.d.ts +4 -0
  110. package/dist/run-files.js +4 -0
  111. package/dist/run-keys.d.ts +2 -4
  112. package/dist/run-keys.js +6 -7
  113. package/dist/run-launch.d.ts +4 -0
  114. package/dist/run-launch.js +4 -0
  115. package/dist/run-reads-over-store.d.ts +3 -2
  116. package/dist/run-reads-over-store.js +66 -2
  117. package/dist/run-secrets.js +5 -2
  118. package/dist/run-timeline-served.d.ts +1 -1
  119. package/dist/run-timeline-served.js +4 -4
  120. package/dist/runner/adapter-loop.d.ts +9 -3
  121. package/dist/runner/adapter-loop.js +34 -15
  122. package/dist/runner/adapter-run-spec.d.ts +3 -0
  123. package/dist/runner/adapter-run-spec.js +9 -4
  124. package/dist/runner/audit.js +8 -4
  125. package/dist/runner/beside.d.ts +2 -1
  126. package/dist/runner/beside.js +13 -5
  127. package/dist/runner/claim-secrets.d.ts +5 -8
  128. package/dist/runner/claim-secrets.js +6 -0
  129. package/dist/runner/cli-run-spec.d.ts +1 -1
  130. package/dist/runner/cli-run-spec.js +41 -7
  131. package/dist/runner/harness-loops.d.ts +22 -9
  132. package/dist/runner/harness-loops.js +21 -11
  133. package/dist/runner/held.d.ts +3 -0
  134. package/dist/runner/learning-end.d.ts +1 -1
  135. package/dist/runner/learning-end.js +8 -3
  136. package/dist/runner/loop-contract.d.ts +9 -4
  137. package/dist/runner/main.js +12 -6
  138. package/dist/runner/mcp-claim.d.ts +3 -0
  139. package/dist/runner/mcp-claim.js +26 -2
  140. package/dist/runner/mcp-run.d.ts +3 -0
  141. package/dist/runner/mcp-run.js +2 -1
  142. package/dist/runner/metrics.d.ts +10 -10
  143. package/dist/runner/metrics.js +19 -38
  144. package/dist/runner/model-route.d.ts +3 -0
  145. package/dist/runner/model-route.js +6 -2
  146. package/dist/runner/presence.d.ts +4 -3
  147. package/dist/runner/presence.js +4 -2
  148. package/dist/runner/promotion.d.ts +15 -9
  149. package/dist/runner/promotion.js +25 -15
  150. package/dist/runner/run-child-host.d.ts +2 -0
  151. package/dist/runner/run-child-host.js +19 -9
  152. package/dist/runner/run-child.js +3 -1
  153. package/dist/runner/runner.d.ts +4 -0
  154. package/dist/runner/runner.js +33 -3
  155. package/dist/runner/sdk-loop.js +2 -0
  156. package/dist/runner/workflow-loop.d.ts +2 -2
  157. package/dist/runner/workflow-loop.js +1 -2
  158. package/dist/runner/workflow-spec.d.ts +1 -1
  159. package/dist/runner/workflow-spec.js +6 -6
  160. package/dist/sdk/check.d.ts +4 -1
  161. package/dist/sdk/check.js +2 -1
  162. package/dist/sdk/runs.d.ts +2 -2
  163. package/dist/sdk/runs.js +8 -6
  164. package/dist/secret-cut.js +2 -1
  165. package/dist/secret-writes.d.ts +3 -2
  166. package/dist/secret-writes.js +1 -1
  167. package/dist/server.d.ts +49 -10
  168. package/dist/server.js +324 -118
  169. package/dist/standard-webhooks.d.ts +11 -0
  170. package/dist/standard-webhooks.js +20 -2
  171. package/dist/store/dialect.d.ts +3 -0
  172. package/dist/store/dialect.js +1 -0
  173. package/dist/store/index.d.ts +2 -2
  174. package/dist/store/index.js +1 -1
  175. package/dist/store/postgres/dialect.js +3 -0
  176. package/dist/store/schema.js +5 -2
  177. package/dist/store/sqlite/store.js +133 -47
  178. package/dist/store/store.d.ts +64 -15
  179. package/dist/store/store.js +7 -0
  180. package/dist/store-reads/journal.d.ts +7 -2
  181. package/dist/store-reads/journal.js +9 -6
  182. package/dist/store-reads/learning.d.ts +12 -9
  183. package/dist/store-reads/learning.js +18 -24
  184. package/dist/store-view.d.ts +0 -5
  185. package/dist/store-view.js +10 -9
  186. package/dist/template-eval.d.ts +51 -6
  187. package/dist/template-eval.js +177 -53
  188. package/dist/template-import.js +4 -2
  189. package/dist/templates.d.ts +5 -3
  190. package/dist/templates.js +19 -40
  191. package/dist/timeline/index.d.ts +1 -1
  192. package/dist/timeline/index.js +1 -1
  193. package/dist/timeline/labels.d.ts +2 -2
  194. package/dist/timeline/labels.js +2 -2
  195. package/dist/timeline/timeline.d.ts +14 -9
  196. package/dist/timeline/timeline.js +15 -7
  197. package/dist/tool-gate.js +3 -1
  198. package/dist/tool-plane.d.ts +17 -9
  199. package/dist/tool-plane.js +38 -17
  200. package/dist/tools.js +2 -2
  201. package/dist/trigger-launch-hook.d.ts +16 -8
  202. package/dist/trigger-launch-hook.js +32 -23
  203. package/dist/trigger-targets.d.ts +18 -8
  204. package/dist/trigger-targets.js +42 -19
  205. package/dist/triggers.d.ts +85 -23
  206. package/dist/triggers.js +303 -96
  207. package/dist/validate.js +1 -1
  208. package/dist/web-fake.js +3 -3
  209. package/dist/web-fetch-direct.d.ts +4 -0
  210. package/dist/web-fetch-direct.js +8 -1
  211. package/dist/web-fetch.d.ts +12 -3
  212. package/dist/web-fetch.js +47 -14
  213. package/dist/web-search.d.ts +33 -4
  214. package/dist/web-search.js +100 -41
  215. package/dist/webhooks.js +4 -5
  216. package/dist/workspace/computer-deps.d.ts +2 -1
  217. package/dist/workspace/computer-deps.js +5 -4
  218. package/dist/workspace/computer-for-claim.d.ts +8 -2
  219. package/dist/workspace/computer-for-claim.js +28 -9
  220. package/dist/workspace/computer-janitor.d.ts +15 -7
  221. package/dist/workspace/computer-janitor.js +33 -8
  222. package/dist/workspace/computer-kept.d.ts +52 -4
  223. package/dist/workspace/computer-kept.js +118 -6
  224. package/dist/workspace/run-end-computers.d.ts +5 -1
  225. package/dist/workspace/run-end-computers.js +27 -1
  226. package/dist/wrapped.d.ts +57 -0
  227. package/dist/wrapped.js +51 -0
  228. package/launcher/agentrun-serve +5 -1
  229. package/package.json +17 -13
  230. package/templates/README.md +10 -9
  231. package/dist/console/assets/index-B_85An2t.js +0 -745
  232. package/dist/console/assets/index-n1YsbnYh.css +0 -1
  233. package/dist/import-sources.d.ts +0 -116
  234. package/dist/import-sources.js +0 -693
@@ -22,6 +22,17 @@ export declare function installedHere(name: string, from?: string): string | und
22
22
  * (~/.agentrun) is not the server's default, and after the server's own command when the store is not its default.
23
23
  */
24
24
  export declare function npxLine(spec: string, env?: NodeJS.ProcessEnv, installed?: (name: string) => string | undefined): string;
25
+ /**
26
+ * A start the agentrun launcher made (NPX_PACKAGE_ENV: by npx, or by the installer's bin/agentrun and its service, the
27
+ * same launcher) that a data directory refused because an earlier version wrote it (store.ts StoreFromEarlierVersion,
28
+ * or SchemaVersionUnknown on an earlier release's store): the refusal's own first line,
29
+ * then the two ways on as commands to paste. That command keeps its data in ~/.agentrun wherever it is run, so a new
30
+ * folder alone is not a new AgentRun. First, the old folder moved aside whole, so the same command starts this version
31
+ * where it was, and the earlier version still opens what it holds; then this version on a new, empty folder: the same
32
+ * command with --data. Nothing is deleted either way. Any other error, or a start the launcher did not
33
+ * make, is undefined: the refusal's own words stand.
34
+ */
35
+ export declare function earlierDataRefusal(error: unknown, data: string, env?: NodeJS.ProcessEnv, exists?: (path: string) => boolean): string | undefined;
25
36
  /** The port the server was started on when `--port` named one, and whether `--open` was given (1 or 0): set by its CLI
26
37
  * for itself and its runs (startedWith), read by npxLine, so a hint keeps them. */
27
38
  export declare const STARTED_PORT_ENV = "AGENTRUN_SERVE_PORT";
package/dist/adapters.js CHANGED
@@ -5,6 +5,7 @@
5
5
  // alone (harness-install.ts); opencode's pinned CLI that is missing says so with the one line that installs it: an npm
6
6
  // install beside serve, or, when serve runs from npx, the npx line that runs it with the missing package.
7
7
  import { accessSync, constants, existsSync, readFileSync, statSync } from "node:fs";
8
+ import { homedir } from "node:os";
8
9
  import { dirname, join, resolve, sep } from "node:path";
9
10
  import { fileURLToPath } from "node:url";
10
11
  import { facts as claudeFacts } from "@parcha/agentrun-harness-claude/facts";
@@ -74,6 +75,54 @@ export function npxLine(spec, env = {}, installed = installedHere) {
74
75
  const flags = [...(port && /^\d{1,5}$/.test(port) ? [`--port ${port}`] : []), ...(command && env[STARTED_OPEN_ENV] === "0" ? ["--no-open"] : []), ...(!command && env[STARTED_OPEN_ENV] === "1" ? ["--open"] : [])];
75
76
  return `npx ${yes}${packages.map((name) => `-p ${name}`).join(" ")} ${command ? "agentrun" : "agentrun-serve"}${named}${flags.map((flag) => ` ${flag}`).join("")}`;
76
77
  }
78
+ /** The first of `base`, `base-2`, `base-3`… that is not there. */
79
+ const freeName = (base, exists) => {
80
+ let name = base;
81
+ for (let n = 2; exists(name); n++)
82
+ name = `${base}-${n}`;
83
+ return name;
84
+ };
85
+ /**
86
+ * A start the agentrun launcher made (NPX_PACKAGE_ENV: by npx, or by the installer's bin/agentrun and its service, the
87
+ * same launcher) that a data directory refused because an earlier version wrote it (store.ts StoreFromEarlierVersion,
88
+ * or SchemaVersionUnknown on an earlier release's store): the refusal's own first line,
89
+ * then the two ways on as commands to paste. That command keeps its data in ~/.agentrun wherever it is run, so a new
90
+ * folder alone is not a new AgentRun. First, the old folder moved aside whole, so the same command starts this version
91
+ * where it was, and the earlier version still opens what it holds; then this version on a new, empty folder: the same
92
+ * command with --data. Nothing is deleted either way. Any other error, or a start the launcher did not
93
+ * make, is undefined: the refusal's own words stand.
94
+ */
95
+ export function earlierDataRefusal(error, data, env = {}, exists = existsSync) {
96
+ const refused = error;
97
+ const earlier = refused?.name === "StoreFromEarlierVersion" || (refused?.name === "SchemaVersionUnknown" && typeof refused.found === "number" && typeof refused.known === "number" && refused.found < refused.known);
98
+ const door = env[NPX_PACKAGE_ENV];
99
+ if (!earlier || typeof refused?.message !== "string" || door === undefined || !/^@parcha\/agentrun@\d[\w.+-]*$/.test(door))
100
+ return undefined;
101
+ const dir = resolve(data);
102
+ const yes = env.npm_config_yes === "true" ? "-y " : "";
103
+ const port = env[STARTED_PORT_ENV];
104
+ const flags = `${port && /^\d{1,5}$/.test(port) ? ` --port ${port}` : ""}${env[STARTED_OPEN_ENV] === "0" ? " --no-open" : ""}`;
105
+ const command = `npx ${yes}${door}`;
106
+ // The launcher's own folder when --data names none (agentrun start.mjs): this same command opens `dir` again with no
107
+ // --data only when `dir` is it.
108
+ const launcherData = resolve(env.HOME || homedir(), ".agentrun");
109
+ const again = `${command}${dir === launcherData ? "" : ` --data ${shellWord(dir)}`}${flags}`;
110
+ const fresh = freeName(`${dir}-new`, exists);
111
+ const aside = freeName(`${dir}-earlier`, exists);
112
+ // install.sh keeps its Node, its packages and the command in the folder beside the data (node/, lib/, bin/agentrun):
113
+ // that command, or the service that runs it, may be what started this. Moved, they go too, whichever version they are.
114
+ const installed = exists(join(dir, "bin", "agentrun")) ? " That takes the agentrun the installer put there with it (its Node in node/, lib/ and bin/agentrun): run the installer again to put this version's back." : "";
115
+ return [
116
+ refused.message.split("\n")[0],
117
+ // Moved aside first: every later command (doctor, the harness commands, the service) then finds this version where it
118
+ // looks with nothing more to remember; a new folder means the same --data on each of them.
119
+ `To keep all of it where the earlier version still opens it and start this version in ${dir}: mv ${shellWord(dir)} ${shellWord(aside)}, then ${again}. The earlier version opens the old data with --data ${shellWord(aside)}.${installed}`,
120
+ `Or start this version on a new, empty folder: ${command} --data ${shellWord(fresh)}${flags}`,
121
+ ` (every later agentrun command then takes the same --data: without it, they open ${launcherData})`,
122
+ // The store's own refusal already says to add them again; an earlier release's schema says it only in the lines cut here.
123
+ `Either way, nothing is deleted.${refused.name === "SchemaVersionUnknown" ? " Add your agents, MCP servers, keys and sign-ins again in this version." : ""}`,
124
+ ].join("\n");
125
+ }
77
126
  /** The port the server was started on when `--port` named one, and whether `--open` was given (1 or 0): set by its CLI
78
127
  * for itself and its runs (startedWith), read by npxLine, so a hint keeps them. */
79
128
  export const STARTED_PORT_ENV = "AGENTRUN_SERVE_PORT";
@@ -8,7 +8,7 @@ export type PackageFile = {
8
8
  };
9
9
  /** What an export's note can be about: the document's enum of them (openapi.ts), so a note of a kind not here fails the
10
10
  * build, and an answer the document does not list fails its schema check. */
11
- export declare const EXPORT_NOTE_KINDS: readonly ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "secrets", "input_schema", "budget", "package"];
11
+ export declare const EXPORT_NOTE_KINDS: readonly ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "input_schema", "budget", "package"];
12
12
  /** One thing an export could not carry as it is here: what it is, which one, and why, in words. */
13
13
  export type ExportNote = {
14
14
  kind: (typeof EXPORT_NOTE_KINDS)[number];
@@ -46,8 +46,8 @@ export type ExportInput = {
46
46
  definition: Json;
47
47
  /** The revision's skill files, by path under the agent's skills folder. */
48
48
  skills: Readonly<Record<string, string>>;
49
- /** The package the agent was applied from (agentView's `template`) with the key names its apply kept (absent on a
50
- * revision applied before they were kept), and that package as this server holds it now. */
49
+ /** The package the agent was applied from (agentView's `template`) with the key names its apply kept, and that package
50
+ * as this server holds it now. */
51
51
  template: {
52
52
  id: string;
53
53
  version: string;
@@ -8,7 +8,7 @@
8
8
  import { createHash } from "node:crypto";
9
9
  import { stringify } from "yaml";
10
10
  import { LOOPBACK } from "./mcp-oauth.js";
11
- import { MANIFEST, memoryFiles, onServerNames, PackageError, readPackage } from "./templates.js";
11
+ import { INPUT_KEYS, ITEM_KEYS, MANIFEST, memoryFiles, onServerNames, PackageError, readPackage } from "./templates.js";
12
12
  import { isMcpName, isMonidName, mcpToolName, parseToolName } from "./tool-names.js";
13
13
  import { isPinKeys, permissionKeys, SHELL_FAMILY } from "./tool-gate.js";
14
14
  import { toolOf } from "./tools.js";
@@ -18,7 +18,7 @@ import { isObject, MODEL_TIER_NAMES, stable } from "./validate.js";
18
18
  import { PAIRED_ID_PREFIX } from "./workspace/attached-computers.js";
19
19
  /** What an export's note can be about: the document's enum of them (openapi.ts), so a note of a kind not here fails the
20
20
  * build, and an answer the document does not list fails its schema check. */
21
- export const EXPORT_NOTE_KINDS = ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "secrets", "input_schema", "budget", "package"];
21
+ export const EXPORT_NOTE_KINDS = ["mcp_server", "trigger", "pin", "tool_setting", "tool_policy", "computer", "paired_computer", "sign_in", "learning", "input_schema", "budget", "package"];
22
22
  /** The package's digest: sha256, in hex, over its files sorted by path, each written as `path NUL bytes NUL`. */
23
23
  export function packageSha256(files) {
24
24
  const hash = createHash("sha256");
@@ -37,9 +37,8 @@ const REMADE_TRIGGERS = {
37
37
  composio: "A composio trigger is made again on the target's Composio project.",
38
38
  email: "An email trigger receives at an address the target gives it: point the sender at the new one.",
39
39
  };
40
- /** The input fields' keys in the order a package writes them (templates.ts INPUT_KEYS), and a list's items'. */
41
- const FIELD_KEYS = ["type", "title", "description", "pattern", "format", "minLength", "maxLength", "minimum", "maximum", "enum", "examples", "default"];
42
- const ITEM_KEYS = ["type", "pattern", "format", "minLength", "maxLength", "minimum", "maximum", "enum"];
40
+ /** An input field's own keys, in the order a package writes them: `required` and `items` are written after them. */
41
+ const FIELD_KEYS = INPUT_KEYS.filter((key) => key !== "required" && key !== "items");
43
42
  const pick = (from, keys) => Object.fromEntries(keys.flatMap((key) => (from[key] !== undefined ? [[key, from[key]]] : [])));
44
43
  /** Each field of `value`, a part of the agent an export copies as it is, that holds a credential in the clear, as its
45
44
  * path from `at` (source.urls.0, target.input.api_key): by the walk a composio trigger's config is sealed by
@@ -71,7 +70,6 @@ export function agentPackage(input) {
71
70
  const remade = [];
72
71
  // Its name: the template's it was applied from, else the agent's own as a package name.
73
72
  const pkgName = origin?.name || (template ? slug(template.id.split(/[/:]/).at(-1) ?? "") : "") || slug(agent.name) || slug(agent.id) || "agent";
74
- const sameVersion = !!origin && !!template && origin.version === template.version;
75
73
  const settings = (isObject(definition.tool_settings) ? definition.tool_settings : {});
76
74
  // Denied as the gate reads the agent's own settings: a shell tool by bash's, then the most specific key set (the tool's
77
75
  // own, else its MCP server's or monid provider's wildcard).
@@ -287,13 +285,8 @@ export function agentPackage(input) {
287
285
  const inputs = inputSchema && inputsOf(inputSchema);
288
286
  if (inputSchema && !inputs)
289
287
  blocked.push({ kind: "input_schema", name: "inputs", reason: "Its input schema is not a closed object of fields, which is what a package's inputs are." });
290
- // The keys its package declared, as its apply kept them; for a revision applied before they were kept, the package as
291
- // this server holds it, which names them only while it is the same version.
292
- const declared = template?.secrets ?? (sameVersion ? origin.secrets : []);
293
- const secrets = [...new Set([...declared, ...((plain ?? []).some(isMonidName) ? ["MONID_API_KEY"] : [])])].sort();
294
- // Such a revision of a package updated or removed since its apply: the keys it was applied with are unknown here.
295
- if (template && !template.secrets && !sameVersion)
296
- remade.push({ kind: "secrets", name: template.id, reason: `The keys version ${template.version} of ${template.id} names are not known here: ${origin ? `this server holds version ${origin.version}` : "this server no longer holds it"}. Save the keys the agent uses on the target, and name them under secrets in ${MANIFEST}.` });
288
+ // The keys its package declared, as its apply kept them.
289
+ const secrets = [...new Set([...(template?.secrets ?? []), ...((plain ?? []).some(isMonidName) ? ["MONID_API_KEY"] : [])])].sort();
297
290
  const bash = settings.bash?.policy;
298
291
  // Bash's policy holds every shell tool, and a package writes it only beside bash: a shell tool kept without bash would
299
292
  // run there what the policy refuses here.
@@ -17,7 +17,7 @@ import { learningSettingForBody } from "./store/agent-body.js";
17
17
  import { storedHarness } from "./harness-table.js";
18
18
  import { AgentBodyInvalid, RevisionMoved, bodyOf, canonical, isObject, StoreConstraint, } from "./store/index.js";
19
19
  import { canonicalToolSettings, settingsIssues } from "./tool-plane.js";
20
- import { computerOfPlace, settingOfDefinition } from "./computer-setting.js";
20
+ import { settingOfDefinition } from "./computer-setting.js";
21
21
  import { skillIssues, skillNames } from "./validate.js";
22
22
  const ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
23
23
  /** A store refusal as the request's answer: a duplicate name (agent exists) and a constraint map the right way. */
@@ -400,6 +400,9 @@ export const etagOf = (entry) => `"${entry.revision?.id ?? "none"}"`;
400
400
  export function definitionOf(agent, revision, version) {
401
401
  const body = revision.body;
402
402
  const common = { ...(body.maxCostUsd !== undefined ? { max_cost_usd: body.maxCostUsd } : {}), ...(body.maxRequests !== undefined ? { max_requests: body.maxRequests } : {}) };
403
+ // A revision saved before the computer setting keeps its place alone; one that names neither has no computer here
404
+ // (the host's default applies).
405
+ const computer = settingOfDefinition(body)?.computer;
403
406
  const kindBody = revision.kind === "agentic"
404
407
  ? { instructions: body.instructions, ...(body.model ? { model: body.model } : {}), ...(body.modelTiers ? { model_tiers: body.modelTiers } : {}), ...(body.thinking ? { thinking: body.thinking } : {}), ...(learningSettingForBody(body) !== undefined ? { learning: learningSettingForBody(body) } : {}), ...(body.inputSchema !== undefined ? { input_schema: body.inputSchema } : {}), ...(body.outputSchema !== undefined ? { output_schema: body.outputSchema } : {}), ...(body.checkout !== undefined ? { checkout: body.checkout } : {}), ...common }
405
408
  : { workflow: body.workflow, ...common };
@@ -416,9 +419,7 @@ export function definitionOf(agent, revision, version) {
416
419
  approvals: approvalsOf(body.approvals),
417
420
  harness: harnessOfBody(body),
418
421
  ...(body.place ? { place: body.place } : {}),
419
- // A revision's computer as the API shows it: its own, else the one its place says (a revision saved before the
420
- // setting keeps its place alone); none when it names neither (the host's default applies).
421
- ...(body.computer ? { computer: body.computer } : body.place ? { computer: computerOfPlace(body.place) } : {}),
422
+ ...(computer ? { computer } : {}),
422
423
  skills: skillNames(Object.keys(body.skills ?? {})),
423
424
  tools: body.tools,
424
425
  ...(body.toolSettings ? { tool_settings: body.toolSettings } : {}),
@@ -442,7 +443,7 @@ export function agentView(entry, origin, extra = {}) {
442
443
  revisions: entry.revisions,
443
444
  source: null,
444
445
  ...(sourceSyncOf(body) ? { source_sync: { moved: true } } : {}),
445
- // The template package it was applied from (its first revision keeps it): the package's id, version and the commit an
446
+ // The package its current revision came from (packageOf): the package's id, version and the commit an
446
447
  // imported one was read at (null for a bundled one). Null for an agent made otherwise.
447
448
  template: entry.template ? { id: entry.template.id, version: entry.template.version, sha: entry.template.sha ?? null } : null,
448
449
  skills: Object.entries(body.skills ?? {}).map(([path, sha]) => ({ path, sha256: sha, size_bytes: entry.sizes.get(sha) ?? null })),
@@ -1,7 +1,11 @@
1
1
  import { Compile } from "typebox/schema";
2
2
  /** The text of the last fenced `json` block in `text` (```json or a longer fence, ~~~ too), or undefined. */
3
3
  export declare function lastJsonBlock(text: string): string | undefined;
4
- /** The answer's last fenced json block, parsed, or why there is none. */
4
+ /** An answer's json block: its last fenced `json` block, else the whole answer when its trimmed text is one JSON object
5
+ * and nothing else (a reply that is the object alone). The one rule every reader of an answer's JSON keeps: a run's
6
+ * output, a template eval's target and its grader's verdict. */
7
+ export declare function jsonBlockOf(text: string): string | undefined;
8
+ /** The answer's json block (jsonBlockOf), parsed, or why there is none. */
5
9
  export declare function answerJson(answer: string): {
6
10
  value: unknown;
7
11
  } | {
@@ -33,7 +37,7 @@ export declare const outputRetryWords: (why: string) => string;
33
37
  /** Why `answer` misses `schema`, in the retry's words (structuredAnswer's why, less MISSES), or undefined when it meets
34
38
  * it. Undefined too when the schema does not compile (a save refuses one): asking the model again cannot mend a schema. */
35
39
  export declare function outputMiss(answer: string, schema: unknown): string | undefined;
36
- /** A final answer's structured part against an agent's output schema: the value of its last fenced json block when it
40
+ /** A final answer's structured part against an agent's output schema: the value of its json block (jsonBlockOf) when it
37
41
  * meets the schema, else why not (no block, not JSON, the first problems against the schema). */
38
42
  export declare function structuredAnswer(answer: string, schema: unknown): {
39
43
  value: unknown;
@@ -1,4 +1,5 @@
1
- // An answer's structured part: the last fenced `json` block of a final answer, parsed, and checked against an agent's
1
+ // An answer's structured part: the last fenced `json` block of a final answer (or the whole answer when it is one JSON
2
+ // object and nothing else), parsed, and checked against an agent's
2
3
  // output schema (definition.output_schema). The one reader of it: a completed agentic run's result.output (store-view.ts)
3
4
  // and a template eval's target graders (template-eval.ts) read an answer's JSON alike. The runner tells the
4
5
  // model the schema (outputContract, in every harness's system prompt) and asks once more on a miss (outputRetryWords,
@@ -22,9 +23,26 @@ export function lastJsonBlock(text) {
22
23
  }
23
24
  return found;
24
25
  }
25
- /** The answer's last fenced json block, parsed, or why there is none. */
26
+ /** An answer's json block: its last fenced `json` block, else the whole answer when its trimmed text is one JSON object
27
+ * and nothing else (a reply that is the object alone). The one rule every reader of an answer's JSON keeps: a run's
28
+ * output, a template eval's target and its grader's verdict. */
29
+ export function jsonBlockOf(text) {
30
+ const fenced = lastJsonBlock(text);
31
+ if (fenced !== undefined)
32
+ return fenced;
33
+ const whole = text.trim();
34
+ if (!whole.startsWith("{"))
35
+ return undefined;
36
+ try {
37
+ return isObject(JSON.parse(whole)) ? whole : undefined;
38
+ }
39
+ catch {
40
+ return undefined;
41
+ }
42
+ }
43
+ /** The answer's json block (jsonBlockOf), parsed, or why there is none. */
26
44
  export function answerJson(answer) {
27
- const block = lastJsonBlock(answer);
45
+ const block = jsonBlockOf(answer);
28
46
  if (block === undefined)
29
47
  return { why: "the answer has no fenced json block" };
30
48
  try {
@@ -80,7 +98,7 @@ export function outputMiss(answer, schema) {
80
98
  const read = structuredAnswer(answer, schema);
81
99
  return "why" in read ? read.why.replace(MISSES, "") : undefined;
82
100
  }
83
- /** A final answer's structured part against an agent's output schema: the value of its last fenced json block when it
101
+ /** A final answer's structured part against an agent's output schema: the value of its json block (jsonBlockOf) when it
84
102
  * meets the schema, else why not (no block, not JSON, the first problems against the schema). */
85
103
  export function structuredAnswer(answer, schema) {
86
104
  const compiled = schemaCheck(schema);
@@ -3,8 +3,9 @@ import type { Route } from "./server.js";
3
3
  /** The routes (server.ts ROUTES, by name) an API-only server serves. Past a run's own, why each group is here:
4
4
  * - a run's hosted machine fetches computerd with the token its create minted, not the server's;
5
5
  * - the computers list and the Archil settings are read before a launch, naming keys, never a value;
6
- * - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it (a run
7
- * of an agent made here is refused by the purge's route itself, server.ts deleteRun, in this profile's words);
6
+ * - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it. A run
7
+ * of an agent made here is purged too (deleteRun): the token may archive and delete that whole agent below, every
8
+ * run of it purged, so one run of it is no more;
8
9
  * - a run's computer, take-over, hand-back and viewer link go to the backend, which has no owner's session here;
9
10
  * - a backend reads what its agents learned (loop, promotions, cost per run, a run's learning), cut as the console's,
10
11
  * and resets it (deleteAgentLearning: the agent and its runs kept) when it erases what an agent learned;
@@ -15,8 +16,19 @@ import type { Route } from "./server.js";
15
16
  * words, template-import.ts), which an apply then makes into its agent;
16
17
  * - a backend that deploys agents here applies their template, reads the agent and its revisions, moves its current
17
18
  * revision back, and archives it before its delete (or unarchives it, the schedule and feed triggers its archive
18
- * turned off on again when the server has the launch hook): its token already makes agents through inline runs, so it
19
- * gains no new power. A trigger the apply can't make here is skipped, and said (apiOnlyTriggerSkipped). */
19
+ * turned off on again when the server has the launch hook). That is more than inline runs give its token: it makes
20
+ * agents and revisions that stay, archives and deletes any agent made here and purges any run of one, as the whole
21
+ * server's token does, and with the launch hook its apply makes schedule and feed triggers. A trigger the apply can't
22
+ * make here is skipped, and said (apiOnlyTriggerSkipped). One the agent had before the profile stays as it was:
23
+ * without the hook, an enabled one still fires here on this server's keys until the agent is archived;
24
+ * - an API-only server has no owner, so the token is the backend's own, as with take-over: it saves the Composio servers
25
+ * its agents need through the preset (saveComposioServer), saves over or deletes only a server it saved
26
+ * (mcp-secret-writes.ts tokenWriteOverRefused), and never writes a secret (secret-writes.ts). A Composio server names
27
+ * its key by api_key_env (COMPOSIO_API_KEY, on the launcher's list of secrets, read at each use through secrets.ts
28
+ * secret, sent to Composio's origin alone: composio-made.ts composioEnvKey), and its body names no address or headers.
29
+ * There is no list or read of the servers here (listMcpServerNames above is the listing), and no generic save (saveMcpServer), so the
30
+ * token saves no server at an address or with headers of its own. Previews, refreshes, sign-ins and Composio's
31
+ * triggers stay refused. */
20
32
  export declare const API_ONLY_ROUTES: ReadonlySet<string>;
21
33
  /** The trigger sources an apply on an API-only server makes once the server has the launch hook: the ones that fire on
22
34
  * its own clock and need nothing a refused route sets up. Each firing goes to the backend in front of it
package/dist/api-only.js CHANGED
@@ -1,15 +1,17 @@
1
1
  // The API-only profile (AGENTRUN_API_ONLY=1): a server that runs behind its caller's backend serves the run routes and a
2
2
  // deploy's routes alone, and refuses every other address before anything else reads the request: the console at "/" and
3
- // its assets, sign-in and setup, settings, MCP, triggers and their webhook hooks, the rest of agents and templates.
4
- // Off by default.
3
+ // its assets, sign-in and setup, settings but the MCP servers' names, a Composio server's save and the delete of a server
4
+ // (the secret-write gate lets the token save over or delete only a server it saved, mcp-secret-writes.ts), the MCP
5
+ // endpoint, triggers and their webhook hooks, the rest of agents and templates. Off by default.
5
6
  import { API_ONLY_ENV } from "./env-switch.js";
6
7
  import { NOT_SET_UP } from "./runnable.js";
7
8
  import { LAUNCH_HOOK_SECRET_ENV, LAUNCH_HOOK_URL_ENV } from "./trigger-launch-hook.js";
8
9
  /** The routes (server.ts ROUTES, by name) an API-only server serves. Past a run's own, why each group is here:
9
10
  * - a run's hosted machine fetches computerd with the token its create minted, not the server's;
10
11
  * - the computers list and the Archil settings are read before a launch, naming keys, never a value;
11
- * - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it (a run
12
- * of an agent made here is refused by the purge's route itself, server.ts deleteRun, in this profile's words);
12
+ * - an agent its inline runs made has its disk, its delete and its runs' purges sent by the backend that made it. A run
13
+ * of an agent made here is purged too (deleteRun): the token may archive and delete that whole agent below, every
14
+ * run of it purged, so one run of it is no more;
13
15
  * - a run's computer, take-over, hand-back and viewer link go to the backend, which has no owner's session here;
14
16
  * - a backend reads what its agents learned (loop, promotions, cost per run, a run's learning), cut as the console's,
15
17
  * and resets it (deleteAgentLearning: the agent and its runs kept) when it erases what an agent learned;
@@ -20,12 +22,23 @@ import { LAUNCH_HOOK_SECRET_ENV, LAUNCH_HOOK_URL_ENV } from "./trigger-launch-ho
20
22
  * words, template-import.ts), which an apply then makes into its agent;
21
23
  * - a backend that deploys agents here applies their template, reads the agent and its revisions, moves its current
22
24
  * revision back, and archives it before its delete (or unarchives it, the schedule and feed triggers its archive
23
- * turned off on again when the server has the launch hook): its token already makes agents through inline runs, so it
24
- * gains no new power. A trigger the apply can't make here is skipped, and said (apiOnlyTriggerSkipped). */
25
+ * turned off on again when the server has the launch hook). That is more than inline runs give its token: it makes
26
+ * agents and revisions that stay, archives and deletes any agent made here and purges any run of one, as the whole
27
+ * server's token does, and with the launch hook its apply makes schedule and feed triggers. A trigger the apply can't
28
+ * make here is skipped, and said (apiOnlyTriggerSkipped). One the agent had before the profile stays as it was:
29
+ * without the hook, an enabled one still fires here on this server's keys until the agent is archived;
30
+ * - an API-only server has no owner, so the token is the backend's own, as with take-over: it saves the Composio servers
31
+ * its agents need through the preset (saveComposioServer), saves over or deletes only a server it saved
32
+ * (mcp-secret-writes.ts tokenWriteOverRefused), and never writes a secret (secret-writes.ts). A Composio server names
33
+ * its key by api_key_env (COMPOSIO_API_KEY, on the launcher's list of secrets, read at each use through secrets.ts
34
+ * secret, sent to Composio's origin alone: composio-made.ts composioEnvKey), and its body names no address or headers.
35
+ * There is no list or read of the servers here (listMcpServerNames above is the listing), and no generic save (saveMcpServer), so the
36
+ * token saves no server at an address or with headers of its own. Previews, refreshes, sign-ins and Composio's
37
+ * triggers stay refused. */
25
38
  export const API_ONLY_ROUTES = new Set([
26
39
  "createRun", "createInlineRun", "getComputerDaemon",
27
40
  "getRunComputer", "takeOverRunComputer", "handBackRunComputer", "createRunComputerViewer",
28
- "listComputers", "getWorkspaceArchil",
41
+ "listComputers", "listRunningComputers", "getWorkspaceArchil",
29
42
  "getAgentArchil", "deleteAgentArchil", "deleteAgent", "deleteAgentLearning", "deleteRun",
30
43
  "getLearningLoop", "listLearningPromotions", "getLearningCost", "getRunLearning",
31
44
  "getRun", "getRunUsage", "listRuns", "listAllRuns", "getTimeline",
@@ -34,6 +47,9 @@ export const API_ONLY_ROUTES = new Set([
34
47
  "createFile", "listFiles", "getFile", "uploadFile", "deleteFile",
35
48
  "getCapabilities", "getHealth", "getUsage", "getCapacity", "listMcpServerNames",
36
49
  "importTemplate", "applyTemplate", "getAgent", "listRevisions", "setCurrent", "archiveAgent", "unarchiveAgent",
50
+ "saveComposioServer", "deleteMcpServer",
51
+ // Refused in its own words (403): it reads the machine's session files, which a server behind a backend does not have to give.
52
+ "getWrapped",
37
53
  ]);
38
54
  /** The trigger sources an apply on an API-only server makes once the server has the launch hook: the ones that fire on
39
55
  * its own clock and need nothing a refused route sets up. Each firing goes to the backend in front of it
@@ -14,8 +14,9 @@ import { openCalendar, scrubAddress } from "./address.js";
14
14
  import { CALENDAR_ANSWER_MAX_CHARS, CALENDAR_DESCRIPTION, CALENDAR_ERROR_MAX_CHARS, CALENDAR_EVENTS, NAME_MAX, NO_CALENDAR } from "./names.js";
15
15
  import { held } from "../runner/held.js";
16
16
  /** `value` as JSON with a line break before each field and item: the longest line is one field's cut value. The run's
17
- * redactor (key-refusal.ts redactedAnswer) reads an answer in pieces split at whitespace and gives "[redacted]" for a run
18
- * of 8,192 characters with none, which compact JSON of a busy week (one-word titles, no description) is. */
17
+ * redactor (key-refusal.ts redactedAnswer) reads an answer in pieces split at whitespace, a run of 8,192 characters with
18
+ * none at a JSON string's end, and gives "[redacted]" for such a run with no such end; a line a field keeps every cut at
19
+ * whitespace, whatever a value holds. */
19
20
  const lined = (value) => {
20
21
  if (Array.isArray(value))
21
22
  return value.length ? `[\n${value.map(lined).join(",\n")}\n]` : "[]";
@@ -12,7 +12,7 @@ export declare const PLAN_FALLBACK_MODELS: readonly string[];
12
12
  /** The model a run on the plan gets when it names none. */
13
13
  export declare const PLAN_DEFAULT_MODEL = "gpt-6.1-sol";
14
14
  export type PlanState = "signed_out" | "pending" | "signed_in" | "expired";
15
- /** GET /settings/chatgpt: never a token. */
15
+ /** GET /settings/chatgpt: never a token. `problem`: why the last sign-in ended without signing in, in words. */
16
16
  export type PlanView = {
17
17
  state: PlanState;
18
18
  email?: string;
@@ -20,6 +20,7 @@ export type PlanView = {
20
20
  authorize_url?: string;
21
21
  expires_at?: string;
22
22
  models?: string[];
23
+ problem?: string;
23
24
  };
24
25
  /** The words a run or a request gets when there is no plan token to send. */
25
26
  export declare const SIGNED_OUT = "This server is not signed in to ChatGPT: sign in under Settings \u2192 Model keys, or name a model on a key.";
@@ -50,6 +51,14 @@ export declare const planOf: (env: NodeJS.ProcessEnv) => PlanReader | undefined;
50
51
  export declare function withPlan<E extends NodeJS.ProcessEnv>(env: E, plan: PlanReader | undefined): E;
51
52
  /** Whether `env` runs on the plan now. */
52
53
  export declare const signedIn: (env: NodeJS.ProcessEnv) => boolean;
54
+ /** Why a sign-in past its browser step ended without signing in, from what pi-ai's flow or keep threw: `reason` for the
55
+ * log (OpenAI's status and error code, a missing field's name, a network error's code; never a token or a code) and
56
+ * `words` a person reads. pi-ai's page says the sign-in completed before it exchanges the code, so these are the only
57
+ * word of a failure after it. */
58
+ export declare function signInFailure(error: unknown): {
59
+ reason: string;
60
+ words: string;
61
+ };
53
62
  export interface ChatGPTPlanDeps {
54
63
  /** `settings`: where a server keeps its host id, for a sign-in; a runner, which never signs in, has none. */
55
64
  readonly store: {
@@ -98,6 +107,9 @@ export declare class ChatGPTPlan implements PlanReader {
98
107
  /** This server's id at OpenAI (its agent host id): a UUID made once and kept in the store's settings. Not a credential. */
99
108
  private hostId;
100
109
  private cancel;
110
+ /** Ends the sign-in waiting past its 10 minutes: a cancel, which says nothing by itself, that says it timed out. One
111
+ * whose code OpenAI answered is past waiting (it is being kept) and never times out. */
112
+ private expire;
101
113
  /** Starts a sign-in (one at a time: a new start cancels the one waiting) and gives the address to open. It lasts 10
102
114
  * minutes: the loopback callback finishes it where the browser runs on this machine; elsewhere finishSignIn does. */
103
115
  startSignIn(): Promise<{
@@ -112,6 +124,9 @@ export declare class ChatGPTPlan implements PlanReader {
112
124
  * of is revoked first, then replaced only while the row still holds it (a renewal of it that wrote back meanwhile is
113
125
  * read, revoked and replaced in turn), so no earlier pair is left alive. */
114
126
  private keep;
127
+ /** Takes again a sign-in's change the server failed to take (changed_failed), at the server's read of the sign-in, so
128
+ * what it offers does not wait for a restart. Nothing when none is owed; a failure again stays owed, said once. */
129
+ changeAgain(): Promise<void>;
115
130
  /** The plan's models from OpenAI's list (GET /v1/models with the token), those of the current families; the fallback
116
131
  * list when it can't be read. */
117
132
  private listModels;