@relayflows/sdk 2.0.30 → 2.0.32

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 (347) hide show
  1. package/dist/agent-artifacts.d.ts.map +1 -1
  2. package/dist/agent-artifacts.js +2 -9
  3. package/dist/agent-artifacts.js.map +1 -1
  4. package/dist/agent-cwd.d.ts +69 -0
  5. package/dist/agent-cwd.d.ts.map +1 -0
  6. package/dist/agent-cwd.js +140 -0
  7. package/dist/agent-cwd.js.map +1 -0
  8. package/dist/artifact-scan-policy.d.ts +35 -0
  9. package/dist/artifact-scan-policy.d.ts.map +1 -0
  10. package/dist/artifact-scan-policy.js +49 -0
  11. package/dist/artifact-scan-policy.js.map +1 -0
  12. package/dist/authored-completion-record.d.ts +35 -0
  13. package/dist/authored-completion-record.d.ts.map +1 -0
  14. package/dist/authored-completion-record.js +92 -0
  15. package/dist/authored-completion-record.js.map +1 -0
  16. package/dist/authored-completion.d.ts +99 -0
  17. package/dist/authored-completion.d.ts.map +1 -0
  18. package/dist/authored-completion.js +184 -0
  19. package/dist/authored-completion.js.map +1 -0
  20. package/dist/authored-flow-error.d.ts +13 -1
  21. package/dist/authored-flow-error.d.ts.map +1 -1
  22. package/dist/authored-flow-error.js +12 -0
  23. package/dist/authored-flow-error.js.map +1 -1
  24. package/dist/authored-flow-executor.d.ts +7 -30
  25. package/dist/authored-flow-executor.d.ts.map +1 -1
  26. package/dist/authored-flow-executor.js +54 -47
  27. package/dist/authored-flow-executor.js.map +1 -1
  28. package/dist/authored-human.d.ts.map +1 -1
  29. package/dist/authored-human.js +1 -3
  30. package/dist/authored-human.js.map +1 -1
  31. package/dist/authored-node-entry.js +4 -1
  32. package/dist/authored-node-entry.js.map +1 -1
  33. package/dist/authored-node-runner.d.ts +9 -1
  34. package/dist/authored-node-runner.d.ts.map +1 -1
  35. package/dist/authored-node-runner.js +92 -17
  36. package/dist/authored-node-runner.js.map +1 -1
  37. package/dist/authored-preflight.d.ts +4 -0
  38. package/dist/authored-preflight.d.ts.map +1 -0
  39. package/dist/authored-preflight.js +50 -0
  40. package/dist/authored-preflight.js.map +1 -0
  41. package/dist/authored-root.d.ts +5 -0
  42. package/dist/authored-root.d.ts.map +1 -1
  43. package/dist/authored-root.js +20 -2
  44. package/dist/authored-root.js.map +1 -1
  45. package/dist/authored-step-output.d.ts +35 -10
  46. package/dist/authored-step-output.d.ts.map +1 -1
  47. package/dist/authored-step-output.js +108 -40
  48. package/dist/authored-step-output.js.map +1 -1
  49. package/dist/authored-verdict.d.ts +28 -0
  50. package/dist/authored-verdict.d.ts.map +1 -0
  51. package/dist/authored-verdict.js +79 -0
  52. package/dist/authored-verdict.js.map +1 -0
  53. package/dist/authored-worker-step.d.ts +5 -2
  54. package/dist/authored-worker-step.d.ts.map +1 -1
  55. package/dist/authored-worker-step.js +51 -13
  56. package/dist/authored-worker-step.js.map +1 -1
  57. package/dist/cli/check-worker-surface.d.ts +27 -0
  58. package/dist/cli/check-worker-surface.d.ts.map +1 -0
  59. package/dist/cli/check-worker-surface.js +63 -0
  60. package/dist/cli/check-worker-surface.js.map +1 -0
  61. package/dist/cli/check.d.ts +28 -3
  62. package/dist/cli/check.d.ts.map +1 -1
  63. package/dist/cli/check.js +27 -140
  64. package/dist/cli/check.js.map +1 -1
  65. package/dist/cli/cli-probe.d.ts +20 -0
  66. package/dist/cli/cli-probe.d.ts.map +1 -0
  67. package/dist/cli/cli-probe.js +166 -0
  68. package/dist/cli/cli-probe.js.map +1 -0
  69. package/dist/cli/cloud-format.d.ts +9 -0
  70. package/dist/cli/cloud-format.d.ts.map +1 -0
  71. package/dist/cli/cloud-format.js +77 -0
  72. package/dist/cli/cloud-format.js.map +1 -0
  73. package/dist/cli/cloud-live.d.ts +39 -0
  74. package/dist/cli/cloud-live.d.ts.map +1 -0
  75. package/dist/cli/cloud-live.js +325 -0
  76. package/dist/cli/cloud-live.js.map +1 -0
  77. package/dist/cli/cloud-mirror-session.d.ts +97 -0
  78. package/dist/cli/cloud-mirror-session.d.ts.map +1 -0
  79. package/dist/cli/cloud-mirror-session.js +264 -0
  80. package/dist/cli/cloud-mirror-session.js.map +1 -0
  81. package/dist/cli/cloud-read.d.ts +3 -7
  82. package/dist/cli/cloud-read.d.ts.map +1 -1
  83. package/dist/cli/cloud-read.js +14 -266
  84. package/dist/cli/cloud-read.js.map +1 -1
  85. package/dist/cli/cloud-refusal.d.ts +39 -0
  86. package/dist/cli/cloud-refusal.d.ts.map +1 -0
  87. package/dist/cli/cloud-refusal.js +95 -0
  88. package/dist/cli/cloud-refusal.js.map +1 -0
  89. package/dist/cli/cloud-status-view.d.ts +7 -0
  90. package/dist/cli/cloud-status-view.d.ts.map +1 -0
  91. package/dist/cli/cloud-status-view.js +214 -0
  92. package/dist/cli/cloud-status-view.js.map +1 -0
  93. package/dist/cli/direct-run.d.ts.map +1 -1
  94. package/dist/cli/direct-run.js +16 -2
  95. package/dist/cli/direct-run.js.map +1 -1
  96. package/dist/cli/hn-monitor.d.ts +0 -13
  97. package/dist/cli/hn-monitor.d.ts.map +1 -1
  98. package/dist/cli/hn-monitor.js +2 -1
  99. package/dist/cli/hn-monitor.js.map +1 -1
  100. package/dist/cli/local-agent-remedy.d.ts +80 -0
  101. package/dist/cli/local-agent-remedy.d.ts.map +1 -0
  102. package/dist/cli/local-agent-remedy.js +116 -0
  103. package/dist/cli/local-agent-remedy.js.map +1 -0
  104. package/dist/cli/observer-session.d.ts +41 -0
  105. package/dist/cli/observer-session.d.ts.map +1 -0
  106. package/dist/cli/observer-session.js +78 -0
  107. package/dist/cli/observer-session.js.map +1 -0
  108. package/dist/cli/run.d.ts +30 -2
  109. package/dist/cli/run.d.ts.map +1 -1
  110. package/dist/cli/run.js +186 -24
  111. package/dist/cli/run.js.map +1 -1
  112. package/dist/cli/status.d.ts +9 -0
  113. package/dist/cli/status.d.ts.map +1 -1
  114. package/dist/cli/status.js +31 -2
  115. package/dist/cli/status.js.map +1 -1
  116. package/dist/cli/step-evidence.d.ts +90 -0
  117. package/dist/cli/step-evidence.d.ts.map +1 -0
  118. package/dist/cli/step-evidence.js +259 -0
  119. package/dist/cli/step-evidence.js.map +1 -0
  120. package/dist/cli/step-failure.d.ts +14 -4
  121. package/dist/cli/step-failure.d.ts.map +1 -1
  122. package/dist/cli/step-failure.js +41 -76
  123. package/dist/cli/step-failure.js.map +1 -1
  124. package/dist/cli-commands.d.ts +12 -0
  125. package/dist/cli-commands.d.ts.map +1 -1
  126. package/dist/cli-commands.js +3 -0
  127. package/dist/cli-commands.js.map +1 -1
  128. package/dist/cli.d.ts +17 -0
  129. package/dist/cli.d.ts.map +1 -1
  130. package/dist/cli.js +134 -57
  131. package/dist/cli.js.map +1 -1
  132. package/dist/cloud-deploy.d.ts +1 -1
  133. package/dist/cloud-deploy.d.ts.map +1 -1
  134. package/dist/cloud-deploy.js +24 -8
  135. package/dist/cloud-deploy.js.map +1 -1
  136. package/dist/cloud-mirror-ledger.d.ts +40 -0
  137. package/dist/cloud-mirror-ledger.d.ts.map +1 -0
  138. package/dist/cloud-mirror-ledger.js +142 -0
  139. package/dist/cloud-mirror-ledger.js.map +1 -0
  140. package/dist/cloud-mirror-step.d.ts +168 -0
  141. package/dist/cloud-mirror-step.d.ts.map +1 -0
  142. package/dist/cloud-mirror-step.js +504 -0
  143. package/dist/cloud-mirror-step.js.map +1 -0
  144. package/dist/cloud-mirror-transport.d.ts +94 -0
  145. package/dist/cloud-mirror-transport.d.ts.map +1 -0
  146. package/dist/cloud-mirror-transport.js +163 -0
  147. package/dist/cloud-mirror-transport.js.map +1 -0
  148. package/dist/cloud-mirror.d.ts +132 -0
  149. package/dist/cloud-mirror.d.ts.map +1 -0
  150. package/dist/cloud-mirror.js +556 -0
  151. package/dist/cloud-mirror.js.map +1 -0
  152. package/dist/cloud-read.d.ts +15 -0
  153. package/dist/cloud-read.d.ts.map +1 -1
  154. package/dist/cloud-read.js +20 -1
  155. package/dist/cloud-read.js.map +1 -1
  156. package/dist/cloud-run-record.d.ts +27 -0
  157. package/dist/cloud-run-record.d.ts.map +1 -0
  158. package/dist/cloud-run-record.js +56 -0
  159. package/dist/cloud-run-record.js.map +1 -0
  160. package/dist/cloud-run.d.ts +2 -9
  161. package/dist/cloud-run.d.ts.map +1 -1
  162. package/dist/cloud-run.js +3 -20
  163. package/dist/cloud-run.js.map +1 -1
  164. package/dist/communication/local.d.ts.map +1 -1
  165. package/dist/communication/local.js +2 -1
  166. package/dist/communication/local.js.map +1 -1
  167. package/dist/communication/worker.d.ts +1 -1
  168. package/dist/communication/worker.d.ts.map +1 -1
  169. package/dist/communication/worker.js +13 -5
  170. package/dist/communication/worker.js.map +1 -1
  171. package/dist/compile.d.ts.map +1 -1
  172. package/dist/compile.js +28 -6
  173. package/dist/compile.js.map +1 -1
  174. package/dist/direct-input.d.ts.map +1 -1
  175. package/dist/direct-input.js +21 -1
  176. package/dist/direct-input.js.map +1 -1
  177. package/dist/failure-kinds.d.ts +96 -6
  178. package/dist/failure-kinds.d.ts.map +1 -1
  179. package/dist/failure-kinds.js +29 -2
  180. package/dist/failure-kinds.js.map +1 -1
  181. package/dist/flow-requirements.d.ts.map +1 -1
  182. package/dist/flow-requirements.js +24 -9
  183. package/dist/flow-requirements.js.map +1 -1
  184. package/dist/gate-contract.d.ts +7 -0
  185. package/dist/gate-contract.d.ts.map +1 -1
  186. package/dist/gate-contract.js +6 -1
  187. package/dist/gate-contract.js.map +1 -1
  188. package/dist/helper-preflight.d.ts.map +1 -1
  189. package/dist/helper-preflight.js +10 -3
  190. package/dist/helper-preflight.js.map +1 -1
  191. package/dist/helper-reference.d.ts +25 -0
  192. package/dist/helper-reference.d.ts.map +1 -0
  193. package/dist/helper-reference.js +129 -0
  194. package/dist/helper-reference.js.map +1 -0
  195. package/dist/hosted-extension-runtime.js +1 -1
  196. package/dist/index.d.ts +1 -1
  197. package/dist/index.d.ts.map +1 -1
  198. package/dist/index.js.map +1 -1
  199. package/dist/journal-client.d.ts +3 -1
  200. package/dist/journal-client.d.ts.map +1 -1
  201. package/dist/journal-client.js +17 -2
  202. package/dist/journal-client.js.map +1 -1
  203. package/dist/journal-projection.d.ts +16 -0
  204. package/dist/journal-projection.d.ts.map +1 -0
  205. package/dist/journal-projection.js +108 -0
  206. package/dist/journal-projection.js.map +1 -0
  207. package/dist/llm-worker.js +1 -1
  208. package/dist/llm-worker.js.map +1 -1
  209. package/dist/local-agent.d.ts +1 -1
  210. package/dist/local-agent.d.ts.map +1 -1
  211. package/dist/local-agent.js +4 -3
  212. package/dist/local-agent.js.map +1 -1
  213. package/dist/named-gate-lowering.js +35 -5
  214. package/dist/named-gate-lowering.js.map +1 -1
  215. package/dist/named-gate-preflight.d.ts +27 -0
  216. package/dist/named-gate-preflight.d.ts.map +1 -0
  217. package/dist/named-gate-preflight.js +47 -0
  218. package/dist/named-gate-preflight.js.map +1 -0
  219. package/dist/named-gates.d.ts +1 -1
  220. package/dist/named-gates.d.ts.map +1 -1
  221. package/dist/named-gates.js +3 -0
  222. package/dist/named-gates.js.map +1 -1
  223. package/dist/observer-link.d.ts +7 -0
  224. package/dist/observer-link.d.ts.map +1 -1
  225. package/dist/observer-link.js +3 -1
  226. package/dist/observer-link.js.map +1 -1
  227. package/dist/package-version.d.ts +10 -0
  228. package/dist/package-version.d.ts.map +1 -0
  229. package/dist/package-version.js +22 -0
  230. package/dist/package-version.js.map +1 -0
  231. package/dist/preflight.d.ts +14 -0
  232. package/dist/preflight.d.ts.map +1 -1
  233. package/dist/preflight.js +25 -3
  234. package/dist/preflight.js.map +1 -1
  235. package/dist/protocol.d.ts +2 -0
  236. package/dist/protocol.d.ts.map +1 -1
  237. package/dist/redact.d.ts +42 -0
  238. package/dist/redact.d.ts.map +1 -1
  239. package/dist/redact.js +128 -0
  240. package/dist/redact.js.map +1 -1
  241. package/dist/relay-cli.d.ts.map +1 -1
  242. package/dist/relay-cli.js +1 -21
  243. package/dist/relay-cli.js.map +1 -1
  244. package/dist/run-projection.d.ts +83 -0
  245. package/dist/run-projection.d.ts.map +1 -0
  246. package/dist/run-projection.js +199 -0
  247. package/dist/run-projection.js.map +1 -0
  248. package/dist/shell-word.d.ts +19 -0
  249. package/dist/shell-word.d.ts.map +1 -0
  250. package/dist/shell-word.js +23 -0
  251. package/dist/shell-word.js.map +1 -0
  252. package/dist/spec.d.ts +52 -3
  253. package/dist/spec.d.ts.map +1 -1
  254. package/dist/spec.js.map +1 -1
  255. package/dist/step-fields.d.ts +1 -1
  256. package/dist/step-fields.js +1 -1
  257. package/dist/step-fields.js.map +1 -1
  258. package/dist/steps-green.d.ts +27 -0
  259. package/dist/steps-green.d.ts.map +1 -0
  260. package/dist/steps-green.js +164 -0
  261. package/dist/steps-green.js.map +1 -0
  262. package/dist/validate.d.ts.map +1 -1
  263. package/dist/validate.js +39 -8
  264. package/dist/validate.js.map +1 -1
  265. package/dist/worker-lease.d.ts +8 -1
  266. package/dist/worker-lease.d.ts.map +1 -1
  267. package/dist/worker-lease.js +34 -4
  268. package/dist/worker-lease.js.map +1 -1
  269. package/dist/worker.d.ts +8 -0
  270. package/dist/worker.d.ts.map +1 -1
  271. package/dist/worker.js +17 -9
  272. package/dist/worker.js.map +1 -1
  273. package/package.json +3 -7
  274. package/src/agent-artifacts.ts +2 -10
  275. package/src/agent-cwd.ts +139 -0
  276. package/src/artifact-scan-policy.ts +51 -0
  277. package/src/authored-completion-record.ts +119 -0
  278. package/src/authored-completion.ts +203 -0
  279. package/src/authored-flow-error.ts +13 -1
  280. package/src/authored-flow-executor.ts +91 -58
  281. package/src/authored-human.ts +1 -4
  282. package/src/authored-node-entry.ts +4 -1
  283. package/src/authored-node-runner.ts +96 -22
  284. package/src/authored-preflight.ts +46 -0
  285. package/src/authored-root.ts +20 -2
  286. package/src/authored-step-output.ts +139 -42
  287. package/src/authored-verdict.ts +87 -0
  288. package/src/authored-worker-step.ts +63 -14
  289. package/src/cli/check-worker-surface.ts +66 -0
  290. package/src/cli/check.ts +59 -166
  291. package/src/cli/cli-probe.ts +194 -0
  292. package/src/cli/cloud-format.ts +82 -0
  293. package/src/cli/cloud-live.ts +366 -0
  294. package/src/cli/cloud-mirror-session.ts +329 -0
  295. package/src/cli/cloud-read.ts +13 -282
  296. package/src/cli/cloud-refusal.ts +113 -0
  297. package/src/cli/cloud-status-view.ts +213 -0
  298. package/src/cli/direct-run.ts +19 -2
  299. package/src/cli/hn-monitor.ts +2 -1
  300. package/src/cli/local-agent-remedy.ts +160 -0
  301. package/src/cli/observer-session.ts +107 -0
  302. package/src/cli/run.ts +233 -28
  303. package/src/cli/status.ts +59 -3
  304. package/src/cli/step-evidence.ts +310 -0
  305. package/src/cli/step-failure.ts +57 -81
  306. package/src/cli-commands.ts +3 -0
  307. package/src/cli.ts +155 -60
  308. package/src/cloud-deploy.ts +26 -8
  309. package/src/cloud-mirror-ledger.ts +161 -0
  310. package/src/cloud-mirror-step.ts +618 -0
  311. package/src/cloud-mirror-transport.ts +261 -0
  312. package/src/cloud-mirror.ts +633 -0
  313. package/src/cloud-read.ts +25 -1
  314. package/src/cloud-run-record.ts +64 -0
  315. package/src/cloud-run.ts +5 -24
  316. package/src/communication/local.ts +2 -1
  317. package/src/communication/worker.ts +13 -5
  318. package/src/compile.ts +28 -6
  319. package/src/direct-input.ts +22 -1
  320. package/src/failure-kinds.ts +104 -2
  321. package/src/flow-requirements.ts +24 -9
  322. package/src/gate-contract.ts +13 -1
  323. package/src/helper-preflight.ts +10 -3
  324. package/src/helper-reference.ts +130 -0
  325. package/src/hosted-extension-runtime.ts +1 -1
  326. package/src/index.ts +2 -0
  327. package/src/journal-client.ts +19 -2
  328. package/src/journal-projection.ts +106 -0
  329. package/src/llm-worker.ts +1 -1
  330. package/src/local-agent.ts +4 -2
  331. package/src/named-gate-lowering.ts +35 -5
  332. package/src/named-gate-preflight.ts +47 -0
  333. package/src/named-gates.ts +3 -0
  334. package/src/observer-link.ts +10 -1
  335. package/src/package-version.ts +23 -0
  336. package/src/preflight.ts +38 -7
  337. package/src/protocol.ts +2 -0
  338. package/src/redact.ts +111 -0
  339. package/src/relay-cli.ts +1 -24
  340. package/src/run-projection.ts +247 -0
  341. package/src/shell-word.ts +24 -0
  342. package/src/spec.ts +54 -3
  343. package/src/step-fields.ts +1 -1
  344. package/src/steps-green.ts +168 -0
  345. package/src/validate.ts +35 -8
  346. package/src/worker-lease.ts +35 -5
  347. package/src/worker.ts +27 -11
@@ -1 +1 @@
1
- {"version":3,"file":"agent-artifacts.d.ts","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAItF;AAsCD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAMpG"}
1
+ {"version":3,"file":"agent-artifacts.d.ts","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAItF;AAsCD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAMpG"}
@@ -1,17 +1,10 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readFile, readdir, stat } from 'node:fs/promises';
3
3
  import { join, relative, sep } from 'node:path';
4
+ import { isUnscannedEntryName } from './artifact-scan-policy.js';
4
5
  function isEnoent(error) {
5
6
  return error instanceof Error && error.code === 'ENOENT';
6
7
  }
7
- /**
8
- * Entry names never walked and never reported, matched exactly, at any depth,
9
- * before the entry's type is consulted — so a `.git` *file* (a worktree's
10
- * gitdir pointer) is skipped as surely as a `.git` directory. Exact names, not
11
- * prefixes: `.github`, `.relayflowd-notes` and every other author-chosen name
12
- * that merely starts the same way stays eligible.
13
- */
14
- const SKIPPED_ENTRY_NAMES = new Set(['.git', '.relayflowd', 'node_modules']);
15
8
  /**
16
9
  * A recursive snapshot of every regular file under `dir`, keyed by its
17
10
  * `dir`-relative POSIX path, valued by a content signature (size + sha256).
@@ -53,7 +46,7 @@ async function walk(root, current, out) {
53
46
  throw error;
54
47
  }
55
48
  for (const entry of entries) {
56
- if (SKIPPED_ENTRY_NAMES.has(entry.name))
49
+ if (isUnscannedEntryName(entry.name))
57
50
  continue;
58
51
  const path = join(current, entry.name);
59
52
  if (entry.isDirectory()) {
@@ -1 +1 @@
1
- {"version":3,"file":"agent-artifacts.js","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC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AE,CAAC;YACf,IAAI,QAAQ,CAAC,KAAK,CAAC;gBAAE,SAAS;YAC9B,MAAM,KAAK,CAAC;QACd,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzH,CAAC;AACH,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,kBAAkB,CAAC,MAA2B,EAAE,KAA0B;IACxF,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,KAAK,EAAE,CAAC;QACtC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Where an agent step runs.
3
+ *
4
+ * A declared `cwd` is a path relative to the **run root** — the working
5
+ * directory of the process running the agent worker, which is the directory
6
+ * `flows run` was invoked from and, on the Cloud path, the uploaded tree
7
+ * (docs/CLOUD.md, "Code sync"). Absent, a step runs in the run root itself.
8
+ *
9
+ * Two checks, in two places, because they are two different facts:
10
+ *
11
+ * - The **declaration** is lexical and filesystem-free, so `flows check`, the
12
+ * kernel's `validate()` and this worker all answer identically for the same
13
+ * spec. `testdata/agent-cwd-cases.json` is the shared corpus both dialects
14
+ * are tested against.
15
+ * - The **target** is resolved here, in the worker that spawns the CLI — the
16
+ * one process provably sharing the agent's filesystem. A directory that
17
+ * exists, and whose symlink-free path is inside the symlink-free run root.
18
+ * Repeated at execution even when a preflight already passed, because the
19
+ * filesystem moves underneath a spec.
20
+ *
21
+ * This contains a declaration; it does not sandbox an agent. Nothing stops a
22
+ * CLI from writing outside the directory it was started in. Per-step scoping
23
+ * is `permissions`, which is recorded and not enforced (gate 8 / #442).
24
+ */
25
+ export declare class AgentCwdError extends Error {
26
+ constructor(message: string);
27
+ }
28
+ /**
29
+ * Why a declared `cwd` is not a run-root-relative path, or `undefined` when it
30
+ * is one. Pure and lexical: the exact rule
31
+ * `relayflowd_core::spec::is_run_root_relative_path` applies at the kernel
32
+ * boundary, so a declaration that passes `flows check` is not refused later by
33
+ * the daemon for its shape.
34
+ */
35
+ export declare function agentCwdDeclarationError(cwd: unknown): string | undefined;
36
+ /**
37
+ * The refusal for a `cwd` declared on a step dispatched over the relay
38
+ * transport, or `undefined` when there is nothing to refuse.
39
+ *
40
+ * The relay agent runs on another host. This process can neither resolve that
41
+ * host's filesystem nor establish that the directory is inside that run's
42
+ * tree, and forwarding the string as `worker_cwd` would let a declaration this
43
+ * contract promises to contain go unchecked. Fail closed instead of pretending.
44
+ */
45
+ export declare function agentCwdTransportError(cwd: unknown, transport: unknown): string | undefined;
46
+ /**
47
+ * The directory to spawn the CLI in: `root` when nothing is declared, else the
48
+ * symlink-free directory `cwd` names beneath `root`.
49
+ *
50
+ * @throws AgentCwdError naming the declaration and what is wrong with it.
51
+ */
52
+ export declare function resolveAgentCwd(root: string, cwd: unknown, transport?: unknown): string | undefined;
53
+ /** Either the directory an agent step runs in, or why the step is refused. */
54
+ export type AgentCwdOutcome = {
55
+ directory: string | undefined;
56
+ } | {
57
+ refusal: string;
58
+ };
59
+ /**
60
+ * The dispatch-time form: resolve a dispatched agent step's `cwd` against the
61
+ * run root, or report the refusal for the worker to complete the step with.
62
+ * Reporting rather than throwing keeps the refusal on the step's completion —
63
+ * `worker_error`, with the reason journaled — instead of on the worker.
64
+ */
65
+ export declare function agentStepCwd(spec: {
66
+ cwd?: unknown;
67
+ transport?: unknown;
68
+ }, stepId: string, root?: string): AgentCwdOutcome;
69
+ //# sourceMappingURL=agent-cwd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-cwd.d.ts","sourceRoot":"","sources":["../src/agent-cwd.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAYzE;AAYD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI3F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA8BnG;AAED,8EAA8E;AAC9E,MAAM,MAAM,eAAe,GAAG;IAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,EAC5C,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAsB,GAC3B,eAAe,CAOjB"}
@@ -0,0 +1,140 @@
1
+ import { realpathSync, statSync } from 'node:fs';
2
+ import { resolve, sep } from 'node:path';
3
+ /**
4
+ * Where an agent step runs.
5
+ *
6
+ * A declared `cwd` is a path relative to the **run root** — the working
7
+ * directory of the process running the agent worker, which is the directory
8
+ * `flows run` was invoked from and, on the Cloud path, the uploaded tree
9
+ * (docs/CLOUD.md, "Code sync"). Absent, a step runs in the run root itself.
10
+ *
11
+ * Two checks, in two places, because they are two different facts:
12
+ *
13
+ * - The **declaration** is lexical and filesystem-free, so `flows check`, the
14
+ * kernel's `validate()` and this worker all answer identically for the same
15
+ * spec. `testdata/agent-cwd-cases.json` is the shared corpus both dialects
16
+ * are tested against.
17
+ * - The **target** is resolved here, in the worker that spawns the CLI — the
18
+ * one process provably sharing the agent's filesystem. A directory that
19
+ * exists, and whose symlink-free path is inside the symlink-free run root.
20
+ * Repeated at execution even when a preflight already passed, because the
21
+ * filesystem moves underneath a spec.
22
+ *
23
+ * This contains a declaration; it does not sandbox an agent. Nothing stops a
24
+ * CLI from writing outside the directory it was started in. Per-step scoping
25
+ * is `permissions`, which is recorded and not enforced (gate 8 / #442).
26
+ */
27
+ export class AgentCwdError extends Error {
28
+ constructor(message) {
29
+ super(message);
30
+ this.name = 'AgentCwdError';
31
+ }
32
+ }
33
+ /**
34
+ * Why a declared `cwd` is not a run-root-relative path, or `undefined` when it
35
+ * is one. Pure and lexical: the exact rule
36
+ * `relayflowd_core::spec::is_run_root_relative_path` applies at the kernel
37
+ * boundary, so a declaration that passes `flows check` is not refused later by
38
+ * the daemon for its shape.
39
+ */
40
+ export function agentCwdDeclarationError(cwd) {
41
+ const expected = 'expected a run-root-relative path';
42
+ if (typeof cwd !== 'string')
43
+ return `${expected} (got ${cwd === null ? 'null' : typeof cwd})`;
44
+ if (cwd === '')
45
+ return `${expected}, not an empty string`;
46
+ if (PADDING.test(cwd))
47
+ return `${expected} without surrounding whitespace`;
48
+ if (cwd.includes('\0'))
49
+ return `${expected} without NUL`;
50
+ if (cwd.startsWith('/'))
51
+ return `${expected}, not an absolute path`;
52
+ if (cwd.includes('://'))
53
+ return `${expected}, not a URI-like mount identity`;
54
+ if (cwd.split('/').some((part) => part === '' || part === '.' || part === '..')) {
55
+ return `${expected} without empty, "." or ".." components`;
56
+ }
57
+ return undefined;
58
+ }
59
+ /**
60
+ * Whitespace at either end, spelled so both dialects refuse the same set.
61
+ * JavaScript's `\s` is Unicode `White_Space` without U+0085 and with U+FEFF;
62
+ * Rust's `char::is_whitespace` is `White_Space` exactly. Naming U+0085 here
63
+ * and U+FEFF there makes both `White_Space ∪ {U+FEFF}`. Left to `trim()`
64
+ * alone, a path padded with either character would pass `flows check` and be
65
+ * refused by the kernel — the accept-then-refuse split this contract closes.
66
+ */
67
+ const PADDING = /^[\s\u0085]|[\s\u0085]$/u;
68
+ /**
69
+ * The refusal for a `cwd` declared on a step dispatched over the relay
70
+ * transport, or `undefined` when there is nothing to refuse.
71
+ *
72
+ * The relay agent runs on another host. This process can neither resolve that
73
+ * host's filesystem nor establish that the directory is inside that run's
74
+ * tree, and forwarding the string as `worker_cwd` would let a declaration this
75
+ * contract promises to contain go unchecked. Fail closed instead of pretending.
76
+ */
77
+ export function agentCwdTransportError(cwd, transport) {
78
+ if (cwd === undefined || transport !== 'relay')
79
+ return undefined;
80
+ return 'cwd is not supported with transport "relay": the agent runs on another host, '
81
+ + 'where this worker cannot resolve the directory or hold it inside the run root';
82
+ }
83
+ /**
84
+ * The directory to spawn the CLI in: `root` when nothing is declared, else the
85
+ * symlink-free directory `cwd` names beneath `root`.
86
+ *
87
+ * @throws AgentCwdError naming the declaration and what is wrong with it.
88
+ */
89
+ export function resolveAgentCwd(root, cwd, transport) {
90
+ if (cwd === undefined)
91
+ return undefined;
92
+ const refusal = (detail) => new AgentCwdError(`cwd ${JSON.stringify(cwd)}: ${detail}`);
93
+ const declaration = agentCwdDeclarationError(cwd);
94
+ if (declaration !== undefined)
95
+ throw refusal(declaration);
96
+ const unsupported = agentCwdTransportError(cwd, transport);
97
+ if (unsupported !== undefined)
98
+ throw new AgentCwdError(unsupported);
99
+ let realRoot;
100
+ try {
101
+ realRoot = realpathSync(root);
102
+ }
103
+ catch {
104
+ throw refusal(`the run root ${JSON.stringify(root)} cannot be resolved on this host`);
105
+ }
106
+ let target;
107
+ try {
108
+ target = realpathSync(resolve(realRoot, cwd));
109
+ }
110
+ catch {
111
+ throw refusal(`no such directory under the run root ${JSON.stringify(realRoot)}`);
112
+ }
113
+ // Component-aware, on the symlink-free forms of both: `checkout-b-old` is
114
+ // not inside `checkout-b`, and a symlink pointing out of the tree is not
115
+ // inside it either however it is spelled.
116
+ const prefix = realRoot.endsWith(sep) ? realRoot : realRoot + sep;
117
+ if (target !== realRoot && !target.startsWith(prefix)) {
118
+ throw refusal(`resolves to ${JSON.stringify(target)}, outside the run root ${JSON.stringify(realRoot)}`);
119
+ }
120
+ if (!statSync(target).isDirectory())
121
+ throw refusal(`${JSON.stringify(target)} is not a directory`);
122
+ return target;
123
+ }
124
+ /**
125
+ * The dispatch-time form: resolve a dispatched agent step's `cwd` against the
126
+ * run root, or report the refusal for the worker to complete the step with.
127
+ * Reporting rather than throwing keeps the refusal on the step's completion —
128
+ * `worker_error`, with the reason journaled — instead of on the worker.
129
+ */
130
+ export function agentStepCwd(spec, stepId, root = process.cwd()) {
131
+ try {
132
+ return { directory: resolveAgentCwd(root, spec.cwd, spec.transport) };
133
+ }
134
+ catch (error) {
135
+ if (!(error instanceof AgentCwdError))
136
+ throw error;
137
+ return { refusal: `agent step "${stepId}": ${error.message}` };
138
+ }
139
+ }
140
+ //# sourceMappingURL=agent-cwd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-cwd.js","sourceRoot":"","sources":["../src/agent-cwd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,MAAM,QAAQ,GAAG,mCAAmC,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M,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3G,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE;QAAE,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACnG,OAAO,MAAM,CAAC;AAChB,CAAC;AAKD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,IAA4C,EAC5C,MAAc,EACd,OAAe,OAAO,CAAC,GAAG,EAAE;IAE5B,IAAI,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;IACxE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,aAAa,CAAC;YAAE,MAAM,KAAK,CAAC;QACnD,OAAO,EAAE,OAAO,EAAE,eAAe,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACjE,CAAC;AACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The bundled agent worker's artifact-scan policy, as a pure predicate.
3
+ *
4
+ * `agent-artifacts.ts` walks an agent step's cwd and records every regular
5
+ * file it finds, except entries named exactly `.git`, `.relayflowd` or
6
+ * `node_modules` — files as well as directories, in both cases. Dotfiles and
7
+ * dot-directories ARE eligible: `.workflow-artifacts/` is the conventional
8
+ * place a flow tells its agents to write. What that walk records is one
9
+ * source of the journaled `output.artifacts` list, which is the only thing an
10
+ * `artifact_exists` gate reads (`named-gate-lowering.ts` tests exact
11
+ * membership in that list and never touches disk).
12
+ *
13
+ * Static analysis needs the same rule without importing filesystem traversal,
14
+ * so the rule lives here and both consume it. It bounds the *scan*, not the
15
+ * list: `worker.ts` journals object-shaped JSON stdout and completed Relay
16
+ * task output verbatim instead of the scanned wrapper, and
17
+ * `JournalClient.stepComplete` accepts any `output` from any worker — so a
18
+ * path this predicate excludes can still reach the list by those routes
19
+ * (`named-gate-preflight.ts` warns rather than refusing for exactly that
20
+ * reason).
21
+ */
22
+ export declare function isUnscannedEntryName(name: string): boolean;
23
+ /**
24
+ * The shortest `/`-prefix of a relative POSIX `path` the scan excludes, or
25
+ * `undefined` when every segment is scanned.
26
+ *
27
+ * Segments are compared exactly, with no normalization: the gate matches the
28
+ * author's literal string against the worker's literal list, so `node_modules`
29
+ * is excluded and `node_modules-copy` is not, and a backslash is an ordinary
30
+ * filename character rather than a separator. The whole prefix is returned,
31
+ * not the offending segment alone, because that prefix is the directory an
32
+ * author has to move the artifact out of.
33
+ */
34
+ export declare function unscannedArtifactPrefix(path: string): string | undefined;
35
+ //# sourceMappingURL=artifact-scan-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-scan-policy.d.ts","sourceRoot":"","sources":["../src/artifact-scan-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAWH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The bundled agent worker's artifact-scan policy, as a pure predicate.
3
+ *
4
+ * `agent-artifacts.ts` walks an agent step's cwd and records every regular
5
+ * file it finds, except entries named exactly `.git`, `.relayflowd` or
6
+ * `node_modules` — files as well as directories, in both cases. Dotfiles and
7
+ * dot-directories ARE eligible: `.workflow-artifacts/` is the conventional
8
+ * place a flow tells its agents to write. What that walk records is one
9
+ * source of the journaled `output.artifacts` list, which is the only thing an
10
+ * `artifact_exists` gate reads (`named-gate-lowering.ts` tests exact
11
+ * membership in that list and never touches disk).
12
+ *
13
+ * Static analysis needs the same rule without importing filesystem traversal,
14
+ * so the rule lives here and both consume it. It bounds the *scan*, not the
15
+ * list: `worker.ts` journals object-shaped JSON stdout and completed Relay
16
+ * task output verbatim instead of the scanned wrapper, and
17
+ * `JournalClient.stepComplete` accepts any `output` from any worker — so a
18
+ * path this predicate excludes can still reach the list by those routes
19
+ * (`named-gate-preflight.ts` warns rather than refusing for exactly that
20
+ * reason).
21
+ */
22
+ /**
23
+ * Entry names the walk never descends into or records, matched exactly, at
24
+ * any depth, before the entry's type is consulted — so a `.git` *file* (a
25
+ * worktree's gitdir pointer) is skipped as surely as a `.git` directory.
26
+ * Exact names, not prefixes: `.github`, `.relayflowd-notes` and every other
27
+ * author-chosen name that merely starts the same way stays eligible.
28
+ */
29
+ const SKIPPED_ENTRY_NAMES = new Set(['.git', '.relayflowd', 'node_modules']);
30
+ export function isUnscannedEntryName(name) {
31
+ return SKIPPED_ENTRY_NAMES.has(name);
32
+ }
33
+ /**
34
+ * The shortest `/`-prefix of a relative POSIX `path` the scan excludes, or
35
+ * `undefined` when every segment is scanned.
36
+ *
37
+ * Segments are compared exactly, with no normalization: the gate matches the
38
+ * author's literal string against the worker's literal list, so `node_modules`
39
+ * is excluded and `node_modules-copy` is not, and a backslash is an ordinary
40
+ * filename character rather than a separator. The whole prefix is returned,
41
+ * not the offending segment alone, because that prefix is the directory an
42
+ * author has to move the artifact out of.
43
+ */
44
+ export function unscannedArtifactPrefix(path) {
45
+ const segments = path.split('/');
46
+ const index = segments.findIndex(isUnscannedEntryName);
47
+ return index === -1 ? undefined : segments.slice(0, index + 1).join('/');
48
+ }
49
+ //# sourceMappingURL=artifact-scan-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-scan-policy.js","sourceRoot":"","sources":["../src/artifact-scan-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;AAE7E,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IACvD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { type LoweredCompletionReason } from './authored-completion.js';
2
+ import type { JournalClient } from './journal-client.js';
3
+ export declare const AUTHORED_VERDICT_STREAM = "authored-verdict";
4
+ export interface AuthoredVerdictRecord {
5
+ readonly reason: LoweredCompletionReason;
6
+ /** Recorded only when the body passed one; see the module comment. */
7
+ readonly detail?: string;
8
+ }
9
+ /**
10
+ * Commit this body's verdict, or recover the one this root already committed.
11
+ *
12
+ * Returns the verdict the marker must be built from — the recorded one when
13
+ * the root holds it, this attempt's otherwise. With no root run there is
14
+ * nothing durable to write to (the non-durable executor seam), so that path
15
+ * passes straight through without a round trip. A root run is always read
16
+ * first: a committed record stays authoritative even for an attempt that has
17
+ * no detail of its own — an optional source can be present on the first
18
+ * execution and gone on the retry, and "this attempt has no detail" is not
19
+ * "this root never recorded one". Only when no record exists AND this attempt
20
+ * has no detail does it return without appending, preserving the no-detail
21
+ * marker, spec hash, and journal exactly as before.
22
+ */
23
+ export declare function commitAuthoredVerdict(journal: JournalClient, rootRunId: string | undefined, step: string, verdict: AuthoredVerdictRecord): Promise<AuthoredVerdictRecord>;
24
+ /**
25
+ * The verdict this root recorded for `step`, or `undefined`.
26
+ *
27
+ * The FIRST valid record wins: it is the one the marker was — or was about to
28
+ * be — admitted from, and a later attempt's differently-redacted text must not
29
+ * displace it. Records this version does not recognise, and details that fail
30
+ * the durable check every other read boundary applies, are skipped rather than
31
+ * trusted; the marker then drifts and the kernel refuses it loudly, which is
32
+ * the right outcome for a record this process cannot read.
33
+ */
34
+ export declare function readAuthoredVerdict(journal: JournalClient, rootRunId: string, step: string): Promise<AuthoredVerdictRecord | undefined>;
35
+ //# sourceMappingURL=authored-completion-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-completion-record.d.ts","sourceRoot":"","sources":["../src/authored-completion-record.ts"],"names":[],"mappings":"AAwBA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAK1D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CAShC;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAgB5C"}
@@ -0,0 +1,92 @@
1
+ // The authored verdict, written to the root BEFORE the marker is admitted.
2
+ //
3
+ // The terminal marker's command embeds the detail, and the marker run is
4
+ // opened under a stable admission key (`authored-child:<hash(root, step)>`).
5
+ // Those two facts together mean the detail has to be a durable decision, not a
6
+ // recomputed one: normalization redacts against `process.env`, so a credential
7
+ // rotated or removed while this process was down makes the SAME authored
8
+ // sentence normalize differently. A body resumed into that environment would
9
+ // retry the marker's admission key with a drifted spec, and the kernel refuses
10
+ // that as `run_admission_conflict` — losing an explanation the root had
11
+ // already journaled, for a flow whose every step succeeded.
12
+ //
13
+ // So the verdict is appended to a stream on the root run before the marker run
14
+ // is opened, and a later attempt reaching the same terminal step reuses what
15
+ // is recorded. That is exactly the durability the executor already gives a
16
+ // predicate gate (`applyPredicateGate`): record the decision first, so the
17
+ // spec built from it is identical on every attempt and author code is never
18
+ // asked the question twice.
19
+ //
20
+ // Nothing is recorded for a `done()` with no detail. Without one the marker
21
+ // command is a function of the reason alone — no environment, no drift, and
22
+ // nothing to recover — so a flow that does not opt in writes exactly the
23
+ // journal it has always written.
24
+ import { isDurableCompletionDetail, isLoweredCompletion, } from './authored-completion.js';
25
+ export const AUTHORED_VERDICT_STREAM = 'authored-verdict';
26
+ /** Versioned so a reader can tell this record from a future one. */
27
+ const RECORD_KIND = 'relayflows.authored-verdict.v1';
28
+ /**
29
+ * Commit this body's verdict, or recover the one this root already committed.
30
+ *
31
+ * Returns the verdict the marker must be built from — the recorded one when
32
+ * the root holds it, this attempt's otherwise. With no root run there is
33
+ * nothing durable to write to (the non-durable executor seam), so that path
34
+ * passes straight through without a round trip. A root run is always read
35
+ * first: a committed record stays authoritative even for an attempt that has
36
+ * no detail of its own — an optional source can be present on the first
37
+ * execution and gone on the retry, and "this attempt has no detail" is not
38
+ * "this root never recorded one". Only when no record exists AND this attempt
39
+ * has no detail does it return without appending, preserving the no-detail
40
+ * marker, spec hash, and journal exactly as before.
41
+ */
42
+ export async function commitAuthoredVerdict(journal, rootRunId, step, verdict) {
43
+ if (rootRunId === undefined)
44
+ return verdict;
45
+ const committed = await readAuthoredVerdict(journal, rootRunId, step);
46
+ if (committed !== undefined)
47
+ return committed;
48
+ if (verdict.detail === undefined)
49
+ return verdict;
50
+ await journal.streamAppend(rootRunId, AUTHORED_VERDICT_STREAM, {
51
+ verdict: RECORD_KIND, step, reason: verdict.reason, detail: verdict.detail,
52
+ });
53
+ return verdict;
54
+ }
55
+ /**
56
+ * The verdict this root recorded for `step`, or `undefined`.
57
+ *
58
+ * The FIRST valid record wins: it is the one the marker was — or was about to
59
+ * be — admitted from, and a later attempt's differently-redacted text must not
60
+ * displace it. Records this version does not recognise, and details that fail
61
+ * the durable check every other read boundary applies, are skipped rather than
62
+ * trusted; the marker then drifts and the kernel refuses it loudly, which is
63
+ * the right outcome for a record this process cannot read.
64
+ */
65
+ export async function readAuthoredVerdict(journal, rootRunId, step) {
66
+ let offset = 0;
67
+ for (;;) {
68
+ const page = await journal.streamRead(rootRunId, AUTHORED_VERDICT_STREAM, offset, 1000);
69
+ for (const message of page.messages) {
70
+ // `stream.read` returns either the envelope or the bare message,
71
+ // matching how the executor reads predicate verdicts.
72
+ const raw = message.message ?? message;
73
+ if (isVerdictRecord(raw) && raw.step === step) {
74
+ return Object.freeze({ reason: raw.reason, detail: raw.detail });
75
+ }
76
+ }
77
+ if (page.messages.length === 0 || page.next_offset <= offset)
78
+ break;
79
+ offset = page.next_offset;
80
+ }
81
+ return undefined;
82
+ }
83
+ function isVerdictRecord(value) {
84
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
85
+ return false;
86
+ const record = value;
87
+ return record.verdict === RECORD_KIND
88
+ && typeof record.step === 'string' && record.step.length > 0
89
+ && isLoweredCompletion(record.reason)
90
+ && isDurableCompletionDetail(record.detail);
91
+ }
92
+ //# sourceMappingURL=authored-completion-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-completion-record.js","sourceRoot":"","sources":["../src/authored-completion-record.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,yEAAyE;AACzE,6EAA6E;AAC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,MAAM,EAAE,IAAI,CAAC,CAAC;QACxF,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,iEAAiE;YACjE,sDAAsD;YACtD,MAAM,GAAG,GAAI,OAAiC,CAAC,OAAO,IAAI,OAAO,CAAC;YAClE,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,IAAI,MAAM;YAAE,MAAM;QACpE,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AASD,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtF,MAAM,MAAM,GAAG,KAA+B,CAAC;IAC/C,OAAO,MAAM,CAAC,OAAO,KAAK,WAAW;WAChC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;WACzD,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC;WAClC,yBAAyB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * The completion reasons an authored body may declare and this executor lowers.
3
+ *
4
+ * `FlowCompletionReason` is wider than this on purpose — it is the journal's
5
+ * run vocabulary plus authored verdicts — but the two sets drifting silently is
6
+ * exactly what made a type-valid `done("step_failed")` die at runtime as
7
+ * `unsupported_completion`. Every gate that asks "is this a completion this
8
+ * runtime can lower?" now asks this one function, so a reason cannot be
9
+ * accepted in one place and rejected in another.
10
+ *
11
+ * These are internal cross-module helpers for the authored seam (the executor,
12
+ * the durable root, the IPC verifier, the CLI report and `flows status`), NOT
13
+ * public SDK surface. `src/index.ts` deliberately re-exports nothing from this
14
+ * module — keep it that way, or the whole authored seam leaks with them.
15
+ */
16
+ export declare const LOWERED_COMPLETIONS: readonly ["success", "needs_human", "step_failed", "declined"];
17
+ export type LoweredCompletionReason = (typeof LOWERED_COMPLETIONS)[number];
18
+ export declare function isLoweredCompletion(value: unknown): value is LoweredCompletionReason;
19
+ /**
20
+ * The bound on a normalized completion detail: 2,000 Unicode code points in
21
+ * the FINAL string, {@link COMPLETION_DETAIL_TRUNCATED_SUFFIX} included.
22
+ *
23
+ * Code points, not `String.length`: `.length` counts UTF-16 code units, so an
24
+ * emoji-heavy detail measured that way is half the length a reader would call
25
+ * it. The number matches `@relayflows/surface`'s
26
+ * `COMPLETION_DETAIL_MAX_CODE_POINTS`, which is what an author sees; it is the
27
+ * same order as the kernel's gate-detail cap
28
+ * (`kernel/relayflowd/src/engine/remote.rs`) but deliberately NOT the same
29
+ * bound — that one takes 2,000 characters and then appends its suffix, so its
30
+ * final string is longer than the number it advertises.
31
+ */
32
+ export declare const COMPLETION_DETAIL_MAX_CODE_POINTS = 2000;
33
+ /** Fixed width, so the bound above can reserve exactly its room. */
34
+ export declare const COMPLETION_DETAIL_TRUNCATED_SUFFIX = "\u2026 (truncated)";
35
+ /**
36
+ * Read `done()`'s optional second argument into the detail the marker carries.
37
+ *
38
+ * Absence has four spellings — no argument, `undefined`, `{}`, and
39
+ * `{ detail: undefined }` — and all four mean the same thing: no detail, and a
40
+ * marker command byte-identical to the one the one-argument call has always
41
+ * produced. Whitespace-only joins them: say nothing, or say something.
42
+ *
43
+ * A `detail` that is present and not a string is a programming error the type
44
+ * system already catches for TypeScript callers; the runtime check is here for
45
+ * the same reason `isSurfaceFlowCompletionReason` is, and it refuses with the
46
+ * existing closed `unsupported_completion` code rather than widening the
47
+ * taxonomy. Refusals name the type they got, never the value — a malformed
48
+ * detail is exactly the kind of text that may carry a credential.
49
+ *
50
+ * Redaction runs BEFORE truncation, and the order is load-bearing rather than
51
+ * cosmetic: truncating first can split a token so no pattern matches it any
52
+ * more, which is a truncation that *causes* a leak. What redaction recognises
53
+ * is the SDK's existing policy — known token shapes, named credential fields,
54
+ * and the values of secret-looking environment variables (`redact.ts`) — not a
55
+ * guarantee to recognise every possible secret.
56
+ *
57
+ * Lone surrogates are substituted here too, so what leaves this function is a
58
+ * well-formed string the journal protocol can carry — see {@link wellFormed}.
59
+ */
60
+ export declare function normalizeCompletionDetail(options: unknown, env?: NodeJS.ProcessEnv): string | undefined;
61
+ /**
62
+ * Is this a detail a durable record may carry?
63
+ *
64
+ * The gate every read boundary uses — the completed root's output, and the
65
+ * IPC frame the Bun runner returns — so an over-long or wrong-typed value
66
+ * fails closed there instead of flowing into a report as if it had been
67
+ * journaled by this process.
68
+ */
69
+ export declare function isDurableCompletionDetail(value: unknown): value is string;
70
+ /**
71
+ * The detail as ONE line, for a diagnostic message.
72
+ *
73
+ * Cloud renders a run's `error` through a line-oriented view that elides the
74
+ * middle of a long one (`cli/cloud-read.ts` `errorLines`), so a forty-line
75
+ * detail can lose the very finding it exists to carry. Escaping the breaks
76
+ * keeps the whole detail on the single line that renderer cannot elide, and
77
+ * keeps control characters out of a terminal. The unescaped normalized detail
78
+ * still travels in the structured fields beside it.
79
+ */
80
+ export declare function singleLineCompletionDetail(detail: string): string;
81
+ /**
82
+ * The deterministic command that carries an authored verdict into the journal.
83
+ *
84
+ * `success` with no detail lowers to `:` because success needs no marker: the
85
+ * marker run's own kernel `success` already IS that record. Every other
86
+ * lowered verdict is something the kernel's completion vocabulary cannot
87
+ * express on a step that *succeeded*, so it travels as data on stdout and is
88
+ * read back from `step.completed`. It is deliberately not lowered as a failing
89
+ * command: no step failed here, and a fabricated failure would put bogus
90
+ * evidence in the journal for a flow whose steps all ran correctly.
91
+ *
92
+ * A detail rides in the same JSON object, so the marker stays the one durable
93
+ * record of the verdict and the IPC verifier's existing command comparison
94
+ * checks the detail against the journal for free. With no detail the command
95
+ * is byte-identical to the one this function has always returned, which is
96
+ * what keeps `spec_hash` stable for every flow that does not opt in.
97
+ */
98
+ export declare function completionMarker(reason: LoweredCompletionReason, detail?: string): string;
99
+ //# sourceMappingURL=authored-completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-completion.d.ts","sourceRoot":"","sources":["../src/authored-completion.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,gEAAiE,CAAC;AAClG,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAEpF;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC,OAAO,CAAC;AAEtD,oEAAoE;AACpE,eAAO,MAAM,kCAAkC,uBAAkB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAkBpB;AAkCD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAKzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGjE;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CASzF"}