@parcha/agentrun-serve 0.1.0-beta.52 → 0.1.0-beta.53

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 (261) hide show
  1. package/CHANGELOG.md +122 -1
  2. package/README.md +213 -24
  3. package/dist/agent-delete.d.ts +5 -6
  4. package/dist/agent-delete.js +30 -67
  5. package/dist/agent-package.d.ts +71 -0
  6. package/dist/agent-package.js +345 -0
  7. package/dist/agents-store.d.ts +26 -20
  8. package/dist/agents-store.js +41 -33
  9. package/dist/api-only.d.ts +26 -6
  10. package/dist/api-only.js +35 -13
  11. package/dist/claude-login.d.ts +1 -0
  12. package/dist/claude-login.js +1 -1
  13. package/dist/cli-learning/cli.d.ts +3 -0
  14. package/dist/cli-learning/cli.js +17 -3
  15. package/dist/cli-learning/connections.js +3 -2
  16. package/dist/cli-learning/schema.js +2 -1
  17. package/dist/cli.js +70 -7
  18. package/dist/composio-preset.d.ts +2 -1
  19. package/dist/composio-preset.js +4 -3
  20. package/dist/composio-triggers.d.ts +4 -0
  21. package/dist/composio-triggers.js +4 -1
  22. package/dist/computer-needs.d.ts +32 -0
  23. package/dist/computer-needs.js +80 -0
  24. package/dist/computer-setting.d.ts +1 -0
  25. package/dist/computer-setting.js +8 -1
  26. package/dist/console/assets/index-BFgyZzF_.js +734 -0
  27. package/dist/console/assets/index-DbilxljH.css +1 -0
  28. package/dist/console/index.html +2 -2
  29. package/dist/console-links.d.ts +1 -0
  30. package/dist/console-links.js +2 -0
  31. package/dist/env-switch.d.ts +14 -0
  32. package/dist/env-switch.js +23 -0
  33. package/dist/errors.d.ts +1 -0
  34. package/dist/errors.js +3 -0
  35. package/dist/eval-previous.js +4 -3
  36. package/dist/fal-price.js +10 -13
  37. package/dist/handed-secret.d.ts +4 -0
  38. package/dist/handed-secret.js +10 -0
  39. package/dist/harness-archive.d.ts +15 -5
  40. package/dist/harness-archive.js +71 -34
  41. package/dist/harness-check.d.ts +2 -1
  42. package/dist/harness-check.js +36 -95
  43. package/dist/harness-egress.d.ts +23 -0
  44. package/dist/harness-egress.js +69 -0
  45. package/dist/harness-recipe-entry.d.ts +71 -0
  46. package/dist/harness-recipe-entry.js +184 -0
  47. package/dist/harness-recipe.d.ts +73 -6
  48. package/dist/harness-recipe.js +185 -31
  49. package/dist/harness-sign-in.d.ts +29 -0
  50. package/dist/harness-sign-in.js +122 -0
  51. package/dist/harness-table.d.ts +21 -0
  52. package/dist/harness-table.js +58 -3
  53. package/dist/harness-zip.d.ts +6 -0
  54. package/dist/harness-zip.js +203 -0
  55. package/dist/ids.d.ts +11 -0
  56. package/dist/ids.js +36 -0
  57. package/dist/learn/commit.d.ts +14 -1
  58. package/dist/learn/commit.js +156 -1
  59. package/dist/learn/compile.js +22 -8
  60. package/dist/learn/folder.d.ts +5 -0
  61. package/dist/learn/folder.js +10 -1
  62. package/dist/learn/learning.sh +15 -3
  63. package/dist/learn/promote.d.ts +2 -2
  64. package/dist/learn/secrets.js +30 -7
  65. package/dist/learning-routes.d.ts +23 -11
  66. package/dist/learning-routes.js +110 -20
  67. package/dist/learning.d.ts +9 -6
  68. package/dist/learning.js +9 -4
  69. package/dist/mcp-gateway.js +15 -2
  70. package/dist/mcp-probe.d.ts +3 -0
  71. package/dist/mcp-probe.js +7 -2
  72. package/dist/mcp-resources.d.ts +44 -0
  73. package/dist/mcp-resources.js +100 -0
  74. package/dist/mcp-servers-store.d.ts +16 -12
  75. package/dist/model.d.ts +4 -4
  76. package/dist/model.js +6 -6
  77. package/dist/native/cli.js +9 -2
  78. package/dist/native/connection.d.ts +2 -2
  79. package/dist/native/connection.js +5 -2
  80. package/dist/native/discovery.d.ts +2 -0
  81. package/dist/native/discovery.js +10 -6
  82. package/dist/native/remote-worker-bridge.js +36 -4
  83. package/dist/native/remote.d.ts +18 -1
  84. package/dist/native/remote.js +126 -37
  85. package/dist/native/schema.d.ts +6 -0
  86. package/dist/native/schema.js +31 -6
  87. package/dist/native/source-account.d.ts +13 -0
  88. package/dist/native/source-account.js +114 -0
  89. package/dist/native/source-capture-hooks.d.ts +5 -0
  90. package/dist/native/source-capture-hooks.js +102 -0
  91. package/dist/native/source-mcp-selection.d.ts +13 -0
  92. package/dist/native/source-mcp-selection.js +72 -0
  93. package/dist/native/source-runtime-tools.d.ts +19 -0
  94. package/dist/native/source-runtime-tools.js +103 -0
  95. package/dist/native/source-snapshot-types.d.ts +138 -0
  96. package/dist/native/source-snapshot-types.js +12 -0
  97. package/dist/native/source-snapshot.d.ts +8 -0
  98. package/dist/native/source-snapshot.js +1201 -0
  99. package/dist/observation/learning.js +3 -2
  100. package/dist/openapi.js +167 -36
  101. package/dist/print.js +1 -1
  102. package/dist/purged-workflow.d.ts +12 -0
  103. package/dist/purged-workflow.js +43 -0
  104. package/dist/run-keys.d.ts +46 -0
  105. package/dist/run-keys.js +109 -0
  106. package/dist/run-launch.d.ts +16 -1
  107. package/dist/run-launch.js +30 -1
  108. package/dist/run-learning-served.d.ts +2 -2
  109. package/dist/run-model-key.d.ts +2 -2
  110. package/dist/run-model-key.js +5 -5
  111. package/dist/run-secrets.d.ts +2 -0
  112. package/dist/run-secrets.js +7 -4
  113. package/dist/run-view.d.ts +17 -0
  114. package/dist/run-view.js +25 -1
  115. package/dist/runner/adapter-loop.d.ts +11 -3
  116. package/dist/runner/adapter-loop.js +138 -22
  117. package/dist/runner/adapter-run-spec.js +25 -12
  118. package/dist/runner/audit.d.ts +2 -0
  119. package/dist/runner/audit.js +9 -1
  120. package/dist/runner/beside.js +2 -1
  121. package/dist/runner/claim-secrets.d.ts +29 -3
  122. package/dist/runner/claim-secrets.js +38 -4
  123. package/dist/runner/cli-run-spec.js +23 -12
  124. package/dist/runner/harness-loops.d.ts +6 -0
  125. package/dist/runner/harness-loops.js +11 -1
  126. package/dist/runner/held.d.ts +4 -0
  127. package/dist/runner/journal-kinds.d.ts +2 -0
  128. package/dist/runner/learned-first.d.ts +2 -0
  129. package/dist/runner/learned-first.js +1 -1
  130. package/dist/runner/learning-end.d.ts +7 -2
  131. package/dist/runner/learning-end.js +22 -10
  132. package/dist/runner/learning-seed.d.ts +9 -3
  133. package/dist/runner/learning-seed.js +2 -2
  134. package/dist/runner/main.d.ts +1 -0
  135. package/dist/runner/main.js +20 -13
  136. package/dist/runner/mcp-claim.js +6 -1
  137. package/dist/runner/mcp-run.d.ts +10 -7
  138. package/dist/runner/mcp-run.js +3 -5
  139. package/dist/runner/monid-run.js +9 -11
  140. package/dist/runner/project-checkpoint.d.ts +35 -0
  141. package/dist/runner/project-checkpoint.js +116 -0
  142. package/dist/runner/project-drain.d.ts +8 -0
  143. package/dist/runner/project-drain.js +25 -0
  144. package/dist/runner/project-host.d.ts +10 -0
  145. package/dist/runner/project-host.js +52 -0
  146. package/dist/runner/promotion.d.ts +14 -6
  147. package/dist/runner/promotion.js +98 -41
  148. package/dist/runner/redact.d.ts +13 -0
  149. package/dist/runner/redact.js +67 -1
  150. package/dist/runner/run-channel.d.ts +9 -0
  151. package/dist/runner/run-channel.js +15 -2
  152. package/dist/runner/run-child-host.d.ts +8 -4
  153. package/dist/runner/run-child-host.js +171 -41
  154. package/dist/runner/run-errors.js +2 -2
  155. package/dist/runner/runner-check.js +5 -2
  156. package/dist/runner/runner.js +26 -9
  157. package/dist/runner/store-secrets.js +7 -3
  158. package/dist/runner/workflow-first.d.ts +4 -0
  159. package/dist/runner/workflow-first.js +13 -0
  160. package/dist/runner/workflow-loop.d.ts +2 -1
  161. package/dist/runner/workflow-loop.js +2 -1
  162. package/dist/runner/workflow-spec.js +1 -1
  163. package/dist/runs-over-store.d.ts +34 -6
  164. package/dist/runs-over-store.js +133 -25
  165. package/dist/sdk/runs.d.ts +11 -1
  166. package/dist/sdk/runs.js +117 -26
  167. package/dist/sdk/schema.js +12 -2
  168. package/dist/sdk/workflows.d.ts +1 -1
  169. package/dist/server.d.ts +68 -32
  170. package/dist/server.js +600 -110
  171. package/dist/skills/agentrun-serve/SKILL.md +2 -1
  172. package/dist/source-sync/adoption.d.ts +15 -0
  173. package/dist/source-sync/adoption.js +36 -0
  174. package/dist/source-sync/auxiliary.d.ts +23 -0
  175. package/dist/source-sync/auxiliary.js +64 -0
  176. package/dist/source-sync/capture-git.d.ts +5 -0
  177. package/dist/source-sync/capture-git.js +272 -0
  178. package/dist/source-sync/capture-project.d.ts +53 -0
  179. package/dist/source-sync/capture-project.js +206 -0
  180. package/dist/source-sync/capture-refusal.d.ts +7 -0
  181. package/dist/source-sync/capture-refusal.js +16 -0
  182. package/dist/source-sync/capture.d.ts +11 -0
  183. package/dist/source-sync/capture.js +22 -0
  184. package/dist/source-sync/checkpoint-gate.d.ts +21 -0
  185. package/dist/source-sync/checkpoint-gate.js +52 -0
  186. package/dist/source-sync/checkpoints.d.ts +66 -0
  187. package/dist/source-sync/checkpoints.js +168 -0
  188. package/dist/source-sync/claim.d.ts +11 -0
  189. package/dist/source-sync/claim.js +48 -0
  190. package/dist/source-sync/destination.d.ts +47 -0
  191. package/dist/source-sync/destination.js +239 -0
  192. package/dist/source-sync/io.d.ts +15 -0
  193. package/dist/source-sync/io.js +52 -0
  194. package/dist/source-sync/local.d.ts +43 -0
  195. package/dist/source-sync/local.js +229 -0
  196. package/dist/source-sync/prepare.d.ts +59 -0
  197. package/dist/source-sync/prepare.js +93 -0
  198. package/dist/source-sync/projects.d.ts +61 -0
  199. package/dist/source-sync/projects.js +130 -0
  200. package/dist/source-sync/registry.d.ts +95 -0
  201. package/dist/source-sync/registry.js +226 -0
  202. package/dist/source-sync/service.d.ts +33 -0
  203. package/dist/source-sync/service.js +118 -0
  204. package/dist/source-sync/skill-edits.d.ts +12 -0
  205. package/dist/source-sync/skill-edits.js +122 -0
  206. package/dist/source-sync/snapshots.d.ts +48 -0
  207. package/dist/source-sync/snapshots.js +448 -0
  208. package/dist/source-sync/types.d.ts +9 -0
  209. package/dist/source-sync/types.js +14 -0
  210. package/dist/source-sync/workspace.d.ts +66 -0
  211. package/dist/source-sync/workspace.js +273 -0
  212. package/dist/store/agent-body.d.ts +4 -0
  213. package/dist/store/agent-body.js +16 -5
  214. package/dist/store/index.d.ts +2 -2
  215. package/dist/store/index.js +1 -1
  216. package/dist/store/schema.d.ts +2 -1
  217. package/dist/store/schema.js +2 -1
  218. package/dist/store/seal.d.ts +5 -1
  219. package/dist/store/seal.js +12 -3
  220. package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
  221. package/dist/store/sqlite/project-checkpoints.js +70 -0
  222. package/dist/store/sqlite/run-launch.d.ts +4 -12
  223. package/dist/store/sqlite/run-launch.js +5 -19
  224. package/dist/store/sqlite/store.js +224 -170
  225. package/dist/store/store.d.ts +116 -39
  226. package/dist/store/store.js +14 -1
  227. package/dist/store-reads/learning.d.ts +2 -2
  228. package/dist/store-view.d.ts +3 -1
  229. package/dist/store-view.js +17 -5
  230. package/dist/template-import.d.ts +10 -2
  231. package/dist/template-import.js +116 -13
  232. package/dist/templates.d.ts +26 -5
  233. package/dist/templates.js +62 -10
  234. package/dist/timeline/index.d.ts +1 -1
  235. package/dist/timeline/index.js +1 -1
  236. package/dist/timeline/timeline.d.ts +5 -0
  237. package/dist/timeline/timeline.js +8 -0
  238. package/dist/tool-plane.d.ts +12 -12
  239. package/dist/tools.d.ts +8 -8
  240. package/dist/trigger-launch-hook.d.ts +47 -0
  241. package/dist/trigger-launch-hook.js +90 -0
  242. package/dist/trigger-targets.d.ts +14 -1
  243. package/dist/trigger-targets.js +20 -0
  244. package/dist/triggers.d.ts +54 -5
  245. package/dist/triggers.js +143 -8
  246. package/dist/uploads-archil.js +1 -1
  247. package/dist/uploads.js +1 -1
  248. package/dist/validate.js +1 -2
  249. package/dist/workspace/computer-for-claim.d.ts +2 -0
  250. package/dist/workspace/computer-for-claim.js +43 -0
  251. package/dist/workspace/paths.d.ts +6 -0
  252. package/dist/workspace/paths.js +6 -0
  253. package/dist/workspace/resolve-computer.d.ts +1 -0
  254. package/dist/workspace/run-tools.d.ts +2 -0
  255. package/dist/workspace/run-tools.js +8 -0
  256. package/launcher/agentrun-serve +1 -1
  257. package/package.json +10 -10
  258. package/skills/agentrun-serve/SKILL.md +2 -1
  259. package/templates/README.md +5 -2
  260. package/dist/console/assets/index-B-D0EM3j.js +0 -733
  261. package/dist/console/assets/index-DlQepP2J.css +0 -1
@@ -149,11 +149,11 @@ export declare class McpServersOverStore {
149
149
  not_metered?: string[] | undefined;
150
150
  tools: {
151
151
  grant_problems?: Record<string, string>;
152
- default_permission: "ask" | "allow" | "deny";
153
- permissions: ("ask" | "allow" | "deny")[];
152
+ default_permission: "ask" | "deny" | "allow";
153
+ permissions: ("ask" | "deny" | "allow")[];
154
154
  fallback_allow_reads?: true | undefined;
155
155
  allow_reads?: true | undefined;
156
- permission: "ask" | "allow" | "deny";
156
+ permission: "ask" | "deny" | "allow";
157
157
  effect: import("./tool-gate.js").ToolEffect;
158
158
  name: string;
159
159
  title?: string;
@@ -161,6 +161,7 @@ export declare class McpServersOverStore {
161
161
  input_schema: unknown;
162
162
  output_schema?: unknown;
163
163
  annotations?: unknown;
164
+ resource?: import("./mcp-resources.js").ResourceOperation;
164
165
  }[];
165
166
  prices?: McpPrices | undefined;
166
167
  instructions?: string | undefined;
@@ -190,11 +191,11 @@ export declare class McpServersOverStore {
190
191
  not_metered?: string[] | undefined;
191
192
  tools: {
192
193
  grant_problems?: Record<string, string>;
193
- default_permission: "ask" | "allow" | "deny";
194
- permissions: ("ask" | "allow" | "deny")[];
194
+ default_permission: "ask" | "deny" | "allow";
195
+ permissions: ("ask" | "deny" | "allow")[];
195
196
  fallback_allow_reads?: true | undefined;
196
197
  allow_reads?: true | undefined;
197
- permission: "ask" | "allow" | "deny";
198
+ permission: "ask" | "deny" | "allow";
198
199
  effect: import("./tool-gate.js").ToolEffect;
199
200
  name: string;
200
201
  title?: string;
@@ -202,6 +203,7 @@ export declare class McpServersOverStore {
202
203
  input_schema: unknown;
203
204
  output_schema?: unknown;
204
205
  annotations?: unknown;
206
+ resource?: import("./mcp-resources.js").ResourceOperation;
205
207
  }[];
206
208
  prices?: McpPrices | undefined;
207
209
  instructions?: string | undefined;
@@ -261,11 +263,11 @@ export declare class McpServersOverStore {
261
263
  not_metered?: string[] | undefined;
262
264
  tools: {
263
265
  grant_problems?: Record<string, string>;
264
- default_permission: "ask" | "allow" | "deny";
265
- permissions: ("ask" | "allow" | "deny")[];
266
+ default_permission: "ask" | "deny" | "allow";
267
+ permissions: ("ask" | "deny" | "allow")[];
266
268
  fallback_allow_reads?: true | undefined;
267
269
  allow_reads?: true | undefined;
268
- permission: "ask" | "allow" | "deny";
270
+ permission: "ask" | "deny" | "allow";
269
271
  effect: import("./tool-gate.js").ToolEffect;
270
272
  name: string;
271
273
  title?: string;
@@ -273,6 +275,7 @@ export declare class McpServersOverStore {
273
275
  input_schema: unknown;
274
276
  output_schema?: unknown;
275
277
  annotations?: unknown;
278
+ resource?: import("./mcp-resources.js").ResourceOperation;
276
279
  }[];
277
280
  prices?: McpPrices | undefined;
278
281
  instructions?: string | undefined;
@@ -306,11 +309,11 @@ export declare class McpServersOverStore {
306
309
  not_metered?: string[] | undefined;
307
310
  tools: {
308
311
  grant_problems?: Record<string, string>;
309
- default_permission: "ask" | "allow" | "deny";
310
- permissions: ("ask" | "allow" | "deny")[];
312
+ default_permission: "ask" | "deny" | "allow";
313
+ permissions: ("ask" | "deny" | "allow")[];
311
314
  fallback_allow_reads?: true | undefined;
312
315
  allow_reads?: true | undefined;
313
- permission: "ask" | "allow" | "deny";
316
+ permission: "ask" | "deny" | "allow";
314
317
  effect: import("./tool-gate.js").ToolEffect;
315
318
  name: string;
316
319
  title?: string;
@@ -318,6 +321,7 @@ export declare class McpServersOverStore {
318
321
  input_schema: unknown;
319
322
  output_schema?: unknown;
320
323
  annotations?: unknown;
324
+ resource?: import("./mcp-resources.js").ResourceOperation;
321
325
  }[];
322
326
  prices?: McpPrices | undefined;
323
327
  instructions?: string | undefined;
package/dist/model.d.ts CHANGED
@@ -7,11 +7,11 @@ import type { Revision } from "./agent-rows.js";
7
7
  export declare const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
8
8
  /** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
9
9
  * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
10
- * (HARNESS_MODULES_ENV). */
10
+ * (HARNESS_MODULES_ENV) and recipes list (HARNESS_RECIPES_ENV). */
11
11
  export declare const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
12
- /** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
13
- * alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
14
- * answers or loads a module. */
12
+ /** `env` without a test hook's name or the resolved harness modules or recipes list: serve sets those from startServe's
13
+ * options alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs
14
+ * fake answers, loads a module or runs a recipe. */
15
15
  export declare const withoutFaux: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
16
16
  /** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
17
17
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
package/dist/model.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import { isRouter, withLocalModels } from "./local-models.js";
9
9
  import { pathToFileURL } from "node:url";
10
10
  import { DEFAULT_HARNESS, PLAN_HARNESSES } from "./harness.js";
11
- import { builtinHarness, factsOf, HARNESS_MODULES_ENV, HARNESS_TABLE_ENV, harnessIds, harnessOf } from "./harness-table.js";
11
+ import { builtinHarness, factsOf, HARNESS_MODULES_ENV, HARNESS_RECIPES_ENV, HARNESS_TABLE_ENV, harnessIds, harnessOf } from "./harness-table.js";
12
12
  import { gatewayBase, modelGatewayBase } from "./provider.js";
13
13
  import { modelFormWhy } from "./model-form.js";
14
14
  // Leaves, which the key rows below read as this module loads, in any import order (wires.ts, adapter-facts.ts).
@@ -21,12 +21,12 @@ import { LOGIN_DEFAULT_MODEL, onClaudeLogin } from "./claude-login.js";
21
21
  export const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
22
22
  /** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
23
23
  * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
24
- * (HARNESS_MODULES_ENV). */
24
+ * (HARNESS_MODULES_ENV) and recipes list (HARNESS_RECIPES_ENV). */
25
25
  export const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
26
- /** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
27
- * alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
28
- * answers or loads a module. */
29
- export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV && name !== HARNESS_MODULES_ENV));
26
+ /** `env` without a test hook's name or the resolved harness modules or recipes list: serve sets those from startServe's
27
+ * options alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs
28
+ * fake answers, loads a module or runs a recipe. */
29
+ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV && name !== HARNESS_MODULES_ENV && name !== HARNESS_RECIPES_ENV));
30
30
  /** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
31
31
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
32
32
  * request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
@@ -5,11 +5,13 @@ import { defaultData } from '../server-fs.js';
5
5
  import { discoverNative } from './discovery.js';
6
6
  import { nativeEnvironment } from './environment.js';
7
7
  import { secret } from '../secrets.js';
8
+ import { selectedNative } from './connection.js';
9
+ import { sourceLocalConsent } from '../source-sync/local.js';
8
10
  /** Source-machine handoff: discovery never launches a model; connection uses the existing local server credential.
9
11
  * `usage`: the command's own line of the server's USAGE (cli.ts), which names every flag parsed here. */
10
12
  export async function nativeMain(argv, usage) {
11
13
  try {
12
- const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { project: { type: 'string' }, runtime: { type: 'string' }, agent: { type: 'string' }, profile: { type: 'string' }, url: { type: 'string' }, data: { type: 'string' } } });
14
+ const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { project: { type: 'string' }, runtime: { type: 'string' }, agent: { type: 'string' }, profile: { type: 'string' }, url: { type: 'string' }, data: { type: 'string' }, 'no-sync': { type: 'boolean' } } });
13
15
  const operation = positionals[0];
14
16
  if (!values.project || !['discover', 'connect'].includes(operation ?? ''))
15
17
  throw new Error(usage);
@@ -35,7 +37,12 @@ export async function nativeMain(argv, usage) {
35
37
  if (!['localhost', '127.0.0.1', '[::1]'].includes(url.hostname))
36
38
  throw new Error('Run AgentRun on this source machine and connect to its loopback URL; hosted native pairing is not available yet.');
37
39
  const token = secret('AGENTRUN_API_KEY') || secret('AGENTRUN_TOKEN') || (await readFile(join(data, '.token'), 'utf8')).trim();
38
- const response = await fetch(new URL('/v2/native/connect', url), { method: 'POST', headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' }, body: JSON.stringify({ project: values.project, runtime: values.runtime, selector: values.agent ? { kind: 'agent', name: values.agent } : values.profile ? { kind: 'profile', name: values.profile } : { kind: 'project' } }) });
40
+ const selection = { project: values.project, runtime: values.runtime, selector: values.agent ? { kind: 'agent', name: values.agent } : values.profile ? { kind: 'profile', name: values.profile } : { kind: 'project' } };
41
+ const env = nativeEnvironment();
42
+ const sourceSync = values['no-sync'] ? undefined : await sourceLocalConsent(await selectedNative(selection, env), env);
43
+ if (sourceSync)
44
+ console.error('Setup sync copies this selected project, instructions, authored skills and assets, supported tools/settings and bounded Git history to AgentRun. Credentials stay here; future source changes keep syncing. Use --no-sync to opt out.');
45
+ const response = await fetch(new URL('/v2/native/connect', url), { method: 'POST', headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' }, body: JSON.stringify({ ...selection, ...(sourceSync ? { source_sync: sourceSync } : {}) }) });
39
46
  const body = await response.json();
40
47
  if (!response.ok)
41
48
  throw new Error(body.error?.message ?? `Connection failed (${response.status})`);
@@ -1,8 +1,8 @@
1
1
  import { type AgentEntry } from '../agents-store.js';
2
- import type { Store } from '../store/store.js';
2
+ import type { Store, SettingsGuard } from '../store/store.js';
3
3
  import type { NativeBinding, NativeTarget } from './types.js';
4
4
  export declare function selectedNative(input: unknown, env?: NodeJS.ProcessEnv): Promise<NativeTarget>;
5
5
  export declare function connectNative(store: Store, input: unknown, env?: NodeJS.ProcessEnv): Promise<AgentEntry>;
6
- export declare function updateNative(store: Store, entry: AgentEntry, native: NativeBinding): Promise<AgentEntry>;
6
+ export declare function updateNative(store: Store, entry: AgentEntry, native: NativeBinding, settingsGuards?: readonly SettingsGuard[]): Promise<AgentEntry>;
7
7
  export declare function verifyConnection(store: Store, entry: AgentEntry, env?: NodeJS.ProcessEnv): Promise<AgentEntry>;
8
8
  export declare function launchNative(binding: NativeBinding, env?: NodeJS.ProcessEnv): Promise<NativeBinding>;
@@ -1,3 +1,4 @@
1
+ import { sourceSyncOf } from "../source-sync/types.js";
1
2
  import { nativeEnvironment } from "./environment.js";
2
3
  import { basename } from 'node:path';
3
4
  import { ApiError, invalid } from '../errors.js';
@@ -42,7 +43,9 @@ export async function connectNative(store, input, env = nativeEnvironment()) {
42
43
  throw error;
43
44
  }
44
45
  }
45
- export async function updateNative(store, entry, native) {
46
+ export async function updateNative(store, entry, native, settingsGuards) {
47
+ if (sourceSyncOf(entry.revision?.body))
48
+ throw new ApiError("input_invalid", "This agent runs in AgentRun. Its source can sync setup, but reconnecting cannot take execution back.");
46
49
  const before = definitionOf(entry.agent, entry.revision, entry.version);
47
50
  const old = nativeOf(entry.revision?.body), execution = nativeExecutionOverrides(entry.revision?.body);
48
51
  // Disconnect must remain possible, retaining these execution restrictions. Reconnect/conversion must never erase
@@ -59,7 +62,7 @@ export async function updateNative(store, entry, native) {
59
62
  // on disconnect. Reconnect fills an absent legacy harness; managed conversion adopts the selected source harness.
60
63
  const sourceHarness = native.runtime === 'claude-code' ? 'claude-agent' : 'codex';
61
64
  const harness = old ? (entry.revision.body.harness ?? (native.connected ? sourceHarness : undefined)) : sourceHarness;
62
- return commitAgent(store, entry, { definition: { ...definition, ...(harness ? { harness } : {}), native } }, { ifCurrent: entry.revision?.id ?? null });
65
+ return commitAgent(store, entry, { definition: { ...definition, ...(harness ? { harness } : {}), native } }, { ifCurrent: entry.revision?.id ?? null, ...(settingsGuards ? { settingsGuards } : {}) });
63
66
  }
64
67
  export async function verifyConnection(store, entry, env = nativeEnvironment()) {
65
68
  const before = nativeOf(entry.revision?.body);
@@ -12,6 +12,8 @@ export declare function nativeMetadata(binary: string, args: string[], cwd: stri
12
12
  stdout: string;
13
13
  }>;
14
14
  export declare function nativeIdentity(target: Pick<NativeTarget, "runtime" | "project" | "selector" | "machine_id">): string;
15
+ /** The existing native machine identity, shared with explicit source-consent checks before any source scan. */
16
+ export declare function nativeMachineId(): Promise<string>;
15
17
  export declare function discoverNative(options: {
16
18
  project: string;
17
19
  runtime?: NativeRuntime;
@@ -69,6 +69,15 @@ export async function nativeMetadata(binary, args, cwd, env, timeoutMs = 5_000)
69
69
  export function nativeIdentity(target) {
70
70
  return hash(JSON.stringify([target.runtime, target.project, target.selector.kind, target.selector.name ?? null, target.machine_id]));
71
71
  }
72
+ /** The existing native machine identity, shared with explicit source-consent checks before any source scan. */
73
+ export async function nativeMachineId() {
74
+ let machine = hostname();
75
+ try {
76
+ machine = (await readFile("/etc/machine-id", "utf8")).trim();
77
+ }
78
+ catch { /* hostname fallback */ }
79
+ return hash(machine);
80
+ }
72
81
  export async function discoverNative(options) {
73
82
  const env = options.env ?? process.env, home = homeOf(env);
74
83
  let project;
@@ -80,12 +89,7 @@ export async function discoverNative(options) {
80
89
  catch {
81
90
  throw new NativeDiscoveryError();
82
91
  }
83
- let machine = hostname();
84
- try {
85
- machine = (await readFile("/etc/machine-id", "utf8")).trim();
86
- }
87
- catch { /* hostname fallback */ }
88
- const machine_id = hash(machine), targets = [];
92
+ const machine_id = await nativeMachineId(), targets = [];
89
93
  for (const runtime of options.runtime ? [options.runtime] : NATIVE_RUNTIMES) {
90
94
  const binary = await nativeExecutable(runtime, env);
91
95
  const versionResult = binary ? await nativeMetadata(binary, ["--version"], project, env) : null;
@@ -10,6 +10,8 @@ import { discoverNative, nativeIdentity, verifyNative } from './discovery.js';
10
10
  import { nativeEnvironment } from './environment.js';
11
11
  import { openNativeSession } from './runtime.js';
12
12
  import { snapshotNativeInstructions } from './instructions.js';
13
+ import { exportSourceSnapshot, SourceSnapshotError } from './source-snapshot.js';
14
+ import { homedir } from 'node:os';
13
15
  import { exportRemoteHistory } from '../import.js';
14
16
  import { runnerSecrets, secretRedactor } from '../runner/redact.js';
15
17
  import { redactedOutput } from '../key-refusal.js';
@@ -70,10 +72,15 @@ export async function runRemoteWorkerBridge(options = {}) {
70
72
  const output = (value) => {
71
73
  // These identities are generated by the connector, not native payload text. Redacting
72
74
  // a serialized JSON line can erase them (or its braces) when a payload has a long atom.
73
- const safe = 'result' in value ? { id: value.id, result: payload(value.result) }
75
+ // Export refuses secret-bearing content before digesting it. A second redaction pass would silently
76
+ // change authored bytes or content hashes; only this typed, local-only export can use its exact result.
77
+ const safe = 'result' in value ? { id: value.id, result: value.exactSnapshot ?? payload(value.result) }
74
78
  : 'event' in value ? { session_key: value.session_key, event: payload(value.event) }
75
- : { ...(value.id === undefined ? {} : { id: value.id }), error: redact(value.error) };
76
- return process.stdout.write(JSON.stringify(safe) + '\n');
79
+ : { ...(value.id === undefined ? {} : { id: value.id }), error: redact(value.error), ...(value.code ? { code: value.code } : {}) };
80
+ const line = JSON.stringify(safe) + '\n';
81
+ if ('exactSnapshot' in value && value.exactSnapshot && Buffer.byteLength(line) > 128 * 1024 * 1024)
82
+ throw new SourceSnapshotError('limit', 'The complete source snapshot exceeds its transport limit; nothing was truncated.');
83
+ return process.stdout.write(line);
77
84
  };
78
85
  const close = async (sessionKey) => {
79
86
  const held = sessions.get(sessionKey);
@@ -115,6 +122,25 @@ export async function runRemoteWorkerBridge(options = {}) {
115
122
  const payload = message.payload === undefined ? {} : object(message.payload), type = message.type;
116
123
  if (type === 'discover')
117
124
  return discoverNative({ project: text(payload.project, 4096), ...(payload.runtime ? { runtime: runtime(payload.runtime) } : {}), env });
125
+ if (type === 'source-snapshot') {
126
+ // Only a local connector action can send this type; remote command dispatch never admits it.
127
+ const chosen = targetOf(message.target);
128
+ if (!Array.isArray(payload.authorized_roots) || !payload.authorized_roots.length || payload.authorized_roots.length > 32)
129
+ throw new Error('Source export needs locally approved source roots. Enable sync on the source machine.');
130
+ // Private local IPC, never an accepted network command. The connector holds a scoped credential
131
+ // outside this process's environment; include it in refusal without echoing it or rewriting bytes.
132
+ const held = payload.secret_values === undefined ? [] : payload.secret_values;
133
+ if (!Array.isArray(held) || held.length > 16 || held.some(value => typeof value !== 'string' || !value.length || Buffer.byteLength(value) > 8192)
134
+ || held.reduce((bytes, value) => bytes + Buffer.byteLength(value), 0) > 64 * 1024)
135
+ throw new Error('Invalid local held-value envelope.');
136
+ const report = await discoverNative({ project: chosen.project, runtime: chosen.runtime, env });
137
+ const found = report.targets.find(target => nativeIdentity(target) === nativeIdentity(chosen));
138
+ if (!found)
139
+ throw new Error('The locally approved source target changed; discover it again.');
140
+ return exportSourceSnapshot({ target: found, authorizedRoots: payload.authorized_roots.map(root => text(root, 4096)),
141
+ home: env.HOME || homedir(), ...(env.CODEX_HOME ? { codexHome: env.CODEX_HOME } : {}),
142
+ ...(env.CLAUDE_CONFIG_DIR ? { claudeHome: env.CLAUDE_CONFIG_DIR } : {}), secretValues: [...secrets, ...held], environment: env, signal });
143
+ }
118
144
  // Local connector action only: the Python network worker never dispatches these operations.
119
145
  if (type === 'history-preview' || type === 'history-export') {
120
146
  const target = targetOf(message.target);
@@ -223,7 +249,13 @@ export async function runRemoteWorkerBridge(options = {}) {
223
249
  }
224
250
  const abort = new AbortController();
225
251
  operations.set(id, abort);
226
- const task = dispatch(message, abort.signal).then(result => { output({ id, result }); }, error => { output({ id, error: error instanceof Error ? error.message : 'Native operation failed.' }); }).finally(() => { operations.delete(id); pending.delete(task); });
252
+ const task = dispatch(message, abort.signal).then(result => { output({ id, result, ...(message.type === 'source-snapshot' ? { exactSnapshot: result } : {}) }); })
253
+ .catch(error => { if (message.type === 'source-snapshot') {
254
+ const code = error instanceof SourceSnapshotError ? (error.code === 'limit' ? 'snapshot_too_large' : error.code) : 'source_unavailable';
255
+ output({ id, error: 'The approved source snapshot could not be captured.', code });
256
+ }
257
+ else
258
+ output({ id, error: error instanceof Error ? error.message : 'Native operation failed.' }); }).finally(() => { operations.delete(id); pending.delete(task); });
227
259
  pending.add(task);
228
260
  }
229
261
  await shutdown();
@@ -1,3 +1,8 @@
1
+ /** Outbound connector transport. Credentials are scoped to one source; commands use source-approved opaque targets.
2
+ * The ordinary runner owns runs, journals and learning. A leased command is NEVER dispatched again after uncertainty.
3
+ * CAS settings rows keep this contract across API/runner processes and restarts without a second run registry. */
4
+ import type { AdoptionResolver } from "../source-sync/adoption.js";
5
+ import { type SourceAuthority } from "../source-sync/registry.js";
1
6
  import { type AgentEntry } from '../agents-store.js';
2
7
  import type { Store } from '../store/store.js';
3
8
  import type { NativeBinding, NativeEvent, NativeResult, NativeSession } from './types.js';
@@ -7,6 +12,8 @@ export type RemoteCommandType = 'prepare' | 'open' | 'send' | 'close';
7
12
  export declare class RemoteConnectors {
8
13
  readonly store: Store;
9
14
  readonly now: () => number;
15
+ /** One HTTP request's authenticated epoch. Reading its body can await a concurrent owner rotation. */
16
+ private authenticated?;
10
17
  constructor(store: Store, now?: () => number);
11
18
  private connector;
12
19
  private targets;
@@ -23,12 +30,14 @@ export declare class RemoteConnectors {
23
30
  observe: boolean;
24
31
  native_execution: boolean;
25
32
  history_import: boolean;
33
+ config_sync: boolean;
26
34
  };
27
35
  targets: {
28
36
  target_id: string;
29
37
  agent_id: string;
30
38
  name: string;
31
39
  history_only: boolean;
40
+ sync_only: boolean;
32
41
  runtime: "codex" | "claude-code";
33
42
  machine_id: string;
34
43
  state: "ready" | "needs_verification" | "needs_attention";
@@ -60,12 +69,14 @@ export declare class RemoteConnectors {
60
69
  observe: boolean;
61
70
  native_execution: boolean;
62
71
  history_import: boolean;
72
+ config_sync: boolean;
63
73
  };
64
74
  targets: {
65
75
  target_id: string;
66
76
  agent_id: string;
67
77
  name: string;
68
78
  history_only: boolean;
79
+ sync_only: boolean;
69
80
  runtime: "codex" | "claude-code";
70
81
  machine_id: string;
71
82
  state: "ready" | "needs_verification" | "needs_attention";
@@ -95,12 +106,14 @@ export declare class RemoteConnectors {
95
106
  observe: boolean;
96
107
  native_execution: boolean;
97
108
  history_import: boolean;
109
+ config_sync: boolean;
98
110
  };
99
111
  targets: {
100
112
  target_id: string;
101
113
  agent_id: string;
102
114
  name: string;
103
115
  history_only: boolean;
116
+ sync_only: boolean;
104
117
  runtime: "codex" | "claude-code";
105
118
  machine_id: string;
106
119
  state: "ready" | "needs_verification" | "needs_attention";
@@ -117,10 +130,14 @@ export declare class RemoteConnectors {
117
130
  }>;
118
131
  assertReady(binding: NativeBinding): Promise<void>;
119
132
  status(binding: NativeBinding): Promise<NativeBinding>;
120
- importTarget(id: string, input: unknown): Promise<{
133
+ importTarget(id: string, input: unknown, resolveAdoption?: AdoptionResolver): Promise<{
121
134
  agent_id: string;
122
135
  native: NativeBinding;
123
136
  }>;
137
+ syncAuthority(id: string, targetId: string): Promise<{
138
+ agentId: string;
139
+ authority: SourceAuthority;
140
+ }>;
124
141
  disconnectTarget(binding: NativeBinding): Promise<void>;
125
142
  importHistory(id: string, targetId: string, input: unknown, own?: readonly string[]): Promise<{
126
143
  agent_id: string;