stitchkit 0.127.0 → 0.129.0

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 (313) hide show
  1. package/CHANGELOG.md +194 -6
  2. package/dist/agent-executor/acp/v1-connect.d.ts +9 -1
  3. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  4. package/dist/agent-executor/acp/v1-driver.d.ts +8 -2
  5. package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
  6. package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
  7. package/dist/agent-executor/acp/v1-session.d.ts +8 -0
  8. package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
  9. package/dist/agent-executor/claude/cli-driver.d.ts +4 -0
  10. package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
  11. package/dist/agent-executor/claude/protocol.d.ts +20 -2
  12. package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
  13. package/dist/agent-executor/claude/session.d.ts +2 -1
  14. package/dist/agent-executor/claude/session.d.ts.map +1 -1
  15. package/dist/agent-executor/claude/transcript.d.ts +9 -6
  16. package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
  17. package/dist/agent-executor/claude-sdk/controls.d.ts +19 -0
  18. package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -0
  19. package/dist/agent-executor/claude-sdk/driver.d.ts +118 -4
  20. package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
  21. package/dist/agent-executor/claude-sdk/query-loop.d.ts +46 -0
  22. package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -0
  23. package/dist/agent-executor/claude-sdk/query-options.d.ts +27 -0
  24. package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -0
  25. package/dist/agent-executor/claude-sdk/session.d.ts +6 -5
  26. package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
  27. package/dist/agent-executor/codex/classify.d.ts.map +1 -1
  28. package/dist/agent-executor/codex/connect.d.ts +45 -0
  29. package/dist/agent-executor/codex/connect.d.ts.map +1 -0
  30. package/dist/agent-executor/codex/driver.d.ts +55 -10
  31. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  32. package/dist/agent-executor/codex/limits.d.ts +11 -2
  33. package/dist/agent-executor/codex/limits.d.ts.map +1 -1
  34. package/dist/agent-executor/codex/protocol.d.ts +75 -6
  35. package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
  36. package/dist/agent-executor/codex/session-controls.d.ts +155 -0
  37. package/dist/agent-executor/codex/session-controls.d.ts.map +1 -0
  38. package/dist/agent-executor/codex/session.d.ts +28 -30
  39. package/dist/agent-executor/codex/session.d.ts.map +1 -1
  40. package/dist/agent-executor/codex/unix-socket-target.d.ts +26 -0
  41. package/dist/agent-executor/codex/unix-socket-target.d.ts.map +1 -0
  42. package/dist/agent-executor/codex/unix-socket.d.ts +26 -0
  43. package/dist/agent-executor/codex/unix-socket.d.ts.map +1 -0
  44. package/dist/agent-executor/codex/ws-frame.d.ts +15 -0
  45. package/dist/agent-executor/codex/ws-frame.d.ts.map +1 -0
  46. package/dist/agent-executor/contract.d.ts +2 -0
  47. package/dist/agent-executor/contract.d.ts.map +1 -1
  48. package/dist/agent-executor/engine-process.d.ts +9 -0
  49. package/dist/agent-executor/engine-process.d.ts.map +1 -1
  50. package/dist/agent-executor/hello.d.ts +8 -0
  51. package/dist/agent-executor/hello.d.ts.map +1 -1
  52. package/dist/agent-executor/image-input.d.ts +71 -0
  53. package/dist/agent-executor/image-input.d.ts.map +1 -0
  54. package/dist/agent-executor/session-primitives.d.ts +0 -3
  55. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  56. package/dist/agent-runtime/agent-tool.d.ts +21 -7
  57. package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
  58. package/dist/agent-runtime/branch-contract.d.ts +1 -0
  59. package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
  60. package/dist/agent-runtime/branch-identities.d.ts +5 -2
  61. package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
  62. package/dist/agent-runtime/branch-messages.d.ts +9 -9
  63. package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
  64. package/dist/agent-runtime/branch-observations.d.ts +49 -36
  65. package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
  66. package/dist/agent-runtime/branch-provider.d.ts +14 -8
  67. package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
  68. package/dist/agent-runtime/branch-source.d.ts +13 -1
  69. package/dist/agent-runtime/branch-source.d.ts.map +1 -1
  70. package/dist/agent-runtime/child-tools.d.ts +64 -0
  71. package/dist/agent-runtime/child-tools.d.ts.map +1 -1
  72. package/dist/agent-runtime/event-search-tools.d.ts +82 -5
  73. package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
  74. package/dist/agent-runtime/invocation-attempt.d.ts +1 -1
  75. package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
  76. package/dist/agent-runtime/invocation-payload.d.ts +12 -0
  77. package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
  78. package/dist/agent-runtime/invocation-read.d.ts +6 -3
  79. package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
  80. package/dist/agent-runtime/invocation-schema.d.ts +50 -8
  81. package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
  82. package/dist/agent-runtime/invocations.d.ts +20 -9
  83. package/dist/agent-runtime/invocations.d.ts.map +1 -1
  84. package/dist/agent-runtime/postgres.d.ts.map +1 -1
  85. package/dist/agent-runtime/schedule-tools.d.ts +30 -0
  86. package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
  87. package/dist/agent-runtime/schemas-invocation-payload.d.ts +48 -0
  88. package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
  89. package/dist/agent-runtime/sql-events.d.ts.map +1 -1
  90. package/dist/agent-runtime/sql-rows.d.ts +10 -10
  91. package/dist/agent-runtime/sql-session.d.ts +11 -0
  92. package/dist/agent-runtime/sql-session.d.ts.map +1 -1
  93. package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
  94. package/dist/agent-runtime/state-tools.d.ts +55 -0
  95. package/dist/agent-runtime/state-tools.d.ts.map +1 -1
  96. package/dist/agent-runtime/store-branch.d.ts.map +1 -1
  97. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
  98. package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
  99. package/dist/agent-runtime/store-create.d.ts.map +1 -1
  100. package/dist/agent-runtime/store-driver-contract.d.ts +12 -0
  101. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  102. package/dist/agent-runtime/store-memory-events.d.ts.map +1 -1
  103. package/dist/agent-runtime/store.d.ts +7 -0
  104. package/dist/agent-runtime/store.d.ts.map +1 -1
  105. package/dist/agent-runtime/terminal-commit.d.ts +10 -10
  106. package/dist/declaration/declaration.d.ts +6 -3
  107. package/dist/declaration/declaration.d.ts.map +1 -1
  108. package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
  109. package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
  110. package/dist/entrypoints/agent-executor/acp.js +28 -17
  111. package/dist/entrypoints/agent-executor/claude-sdk.d.ts +1 -1
  112. package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
  113. package/dist/entrypoints/agent-executor/claude-sdk.js +543 -96
  114. package/dist/entrypoints/agent-executor/claude.js +40 -21
  115. package/dist/entrypoints/agent-executor/codex.d.ts +4 -0
  116. package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
  117. package/dist/entrypoints/agent-executor/codex.js +1530 -207
  118. package/dist/entrypoints/agent-executor.js +7 -7
  119. package/dist/entrypoints/agent-runtime/browser.js +1 -1
  120. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
  121. package/dist/entrypoints/agent-runtime/harness.js +10 -11
  122. package/dist/entrypoints/agent-runtime/openrouter.js +4 -4
  123. package/dist/entrypoints/agent-runtime/postgres.js +12 -7
  124. package/dist/entrypoints/agent-runtime/realtime.js +4 -4
  125. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  126. package/dist/entrypoints/agent-runtime/sqlite/bun.js +7 -7
  127. package/dist/entrypoints/agent-runtime/sqlite/node.js +7 -7
  128. package/dist/entrypoints/agent-runtime/testing.js +9 -9
  129. package/dist/entrypoints/agent-runtime.d.ts +9 -7
  130. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  131. package/dist/entrypoints/agent-runtime.js +254 -207
  132. package/dist/entrypoints/application/diagnostic-journal.js +4 -4
  133. package/dist/entrypoints/application/directory-inbox.js +8 -8
  134. package/dist/entrypoints/application/opentelemetry.js +2 -2
  135. package/dist/entrypoints/application.js +2 -2
  136. package/dist/entrypoints/cli/publish.js +8 -8
  137. package/dist/entrypoints/cli.js +12 -11
  138. package/dist/entrypoints/contract.js +2 -2
  139. package/dist/entrypoints/declaration.js +0 -1
  140. package/dist/entrypoints/files/packaging.js +2 -2
  141. package/dist/entrypoints/files.js +42 -19
  142. package/dist/entrypoints/handler.js +4 -4
  143. package/dist/entrypoints/http.js +5 -5
  144. package/dist/entrypoints/index.js +7 -7
  145. package/dist/entrypoints/node.js +7 -7
  146. package/dist/entrypoints/observability.js +4 -4
  147. package/dist/entrypoints/primitives.js +2 -2
  148. package/dist/entrypoints/process.js +6 -6
  149. package/dist/entrypoints/react.js +1 -1
  150. package/dist/entrypoints/remote.js +2 -2
  151. package/dist/entrypoints/server.js +10 -10
  152. package/dist/entrypoints/service-host/macos.js +6 -6
  153. package/dist/entrypoints/service-host.d.ts +4 -1
  154. package/dist/entrypoints/service-host.d.ts.map +1 -1
  155. package/dist/entrypoints/service-host.js +835 -224
  156. package/dist/entrypoints/spend.js +1 -1
  157. package/dist/entrypoints/sync/postgres.js +1 -1
  158. package/dist/entrypoints/sync.js +2 -2
  159. package/dist/entrypoints/telegram.js +5 -5
  160. package/dist/entrypoints/testing.js +5 -5
  161. package/dist/entrypoints/tools/agent.js +5 -4
  162. package/dist/entrypoints/tools/connections.js +2 -2
  163. package/dist/entrypoints/tools/invoker.js +4 -3
  164. package/dist/entrypoints/tools/mcp.js +5 -4
  165. package/dist/entrypoints/tools/toolkit.js +8 -7
  166. package/dist/entrypoints/tools.d.ts +1 -1
  167. package/dist/entrypoints/tools.d.ts.map +1 -1
  168. package/dist/entrypoints/tools.js +15 -13
  169. package/dist/entrypoints/tracking/contract.js +1 -1
  170. package/dist/entrypoints/xlsx.js +1 -1
  171. package/dist/files/directory-appearance.d.ts +20 -9
  172. package/dist/files/directory-appearance.d.ts.map +1 -1
  173. package/dist/files/polled-json.d.ts.map +1 -1
  174. package/dist/files/regular-file.d.ts +15 -5
  175. package/dist/files/regular-file.d.ts.map +1 -1
  176. package/dist/{index-prf6ayhf.js → index-13wmzpa6.js} +1 -1
  177. package/dist/{index-qnzhmk2s.js → index-17qgm6xe.js} +91 -48
  178. package/dist/{index-wv8dqy7q.js → index-205456mf.js} +1 -1
  179. package/dist/{index-3gwp8ez6.js → index-21cfxc4z.js} +13 -18
  180. package/dist/{index-xtkw9866.js → index-2c5w2d1d.js} +1 -1
  181. package/dist/{index-g1q7fwn9.js → index-2nwvn7m2.js} +1 -1
  182. package/dist/{index-d4svrknj.js → index-39c2hj6h.js} +2 -2
  183. package/dist/{index-sfzfd2m2.js → index-39rmc00v.js} +1 -1
  184. package/dist/{index-ky3ardqn.js → index-3fym4j8n.js} +1 -1
  185. package/dist/{index-d96c1n1q.js → index-5tdc0q43.js} +20 -19
  186. package/dist/{index-3ypvpkwr.js → index-669374qc.js} +1 -1
  187. package/dist/{index-x90w78yz.js → index-673drwkn.js} +23 -8
  188. package/dist/{index-83n766x4.js → index-7jqn3b3g.js} +16 -10
  189. package/dist/{index-5jyjb4s0.js → index-80acsm27.js} +1 -1
  190. package/dist/{index-xmr47znh.js → index-827bgv33.js} +1 -1
  191. package/dist/{index-xypxnzhp.js → index-93n6jwy0.js} +4 -4
  192. package/dist/{index-wbnpa8z6.js → index-9kpxz49v.js} +5 -5
  193. package/dist/{index-fcw255hd.js → index-9sfhje6y.js} +3 -3
  194. package/dist/{index-bh4pmtr9.js → index-afb6z77w.js} +3 -1
  195. package/dist/{index-9y0afd5f.js → index-apf5g7y9.js} +1 -1
  196. package/dist/{index-4qvyhn23.js → index-bjmj2q1z.js} +1 -1
  197. package/dist/{index-bbzvrq66.js → index-dcsxj68j.js} +457 -204
  198. package/dist/{index-j516jaaz.js → index-dnzxxf8a.js} +49 -2
  199. package/dist/{index-kmbpej2y.js → index-emgrmavr.js} +102 -61
  200. package/dist/index-fgahdc7s.js +100 -0
  201. package/dist/{index-kzavdze2.js → index-gr0kxymw.js} +5 -1
  202. package/dist/{index-e06z0tkb.js → index-gya4hwh3.js} +2 -2
  203. package/dist/{index-3djgv3ch.js → index-hab790s6.js} +26 -11
  204. package/dist/{index-j13gzgdv.js → index-j0ef04jw.js} +9 -5
  205. package/dist/{index-rhb33thr.js → index-jcge9tx3.js} +1 -1
  206. package/dist/{index-dvd1qdwa.js → index-ke02kxsr.js} +3 -3
  207. package/dist/{index-3agqmmrg.js → index-mkfhpk11.js} +7 -9
  208. package/dist/{index-a725ayvz.js → index-mttkdm5a.js} +1 -1
  209. package/dist/{index-9wh98cpa.js → index-n3bm7zqq.js} +131 -91
  210. package/dist/{index-7xp05h20.js → index-p06z7g7w.js} +7 -7
  211. package/dist/{index-kt6dh1n6.js → index-p16q492v.js} +1 -1
  212. package/dist/{index-5zwac8ft.js → index-pp97q86a.js} +3 -3
  213. package/dist/{index-39n02e0q.js → index-psye60qn.js} +1 -1
  214. package/dist/{index-5ptwb6ka.js → index-pzhqydxb.js} +1 -1
  215. package/dist/{index-7kfcb576.js → index-qa2jjb65.js} +1 -1
  216. package/dist/{index-0djnptn8.js → index-qhjmmsm2.js} +10 -3
  217. package/dist/{index-7grgs8cx.js → index-qpzyahe3.js} +2 -2
  218. package/dist/{index-8xr2eq99.js → index-r97ppg0g.js} +4 -4
  219. package/dist/{index-bmaz3jzy.js → index-rjs94dny.js} +1 -1
  220. package/dist/{index-p1m9djt6.js → index-rxh3qy4x.js} +33 -6
  221. package/dist/{index-en8e5zsj.js → index-ryxb427v.js} +1 -1
  222. package/dist/{index-nbv44x0x.js → index-s2e3h616.js} +137 -36
  223. package/dist/{index-dwa6pskj.js → index-sd4e5x5j.js} +86 -47
  224. package/dist/{index-g56ht6qf.js → index-t3qcac2a.js} +1 -1
  225. package/dist/index-vgzhw2zk.js +304 -0
  226. package/dist/{index-jrka9029.js → index-vmbxj75t.js} +2 -2
  227. package/dist/{index-caywx1c0.js → index-wv2amqm4.js} +109 -12
  228. package/dist/{index-5e0zsbf7.js → index-x2fb37t0.js} +2 -2
  229. package/dist/{index-z4k0hqp9.js → index-y71zn1gw.js} +137 -27
  230. package/dist/{index-wavv538x.js → index-ybdq8kk2.js} +3 -3
  231. package/dist/{index-4gk6k3zc.js → index-ycr4pk0z.js} +1 -1
  232. package/dist/{index-0tyt97nk.js → index-yrr3n391.js} +1 -1
  233. package/dist/{index-v37b2cd6.js → index-z20pdxeb.js} +2 -2
  234. package/dist/{index-0hdm5sx6.js → index-z9d74jmb.js} +8 -4
  235. package/dist/{index-4s2w4g37.js → index-zhshhxew.js} +80 -2
  236. package/dist/{index-3b31z0pc.js → index-znd1b57f.js} +12 -6
  237. package/dist/internal/bounded-file-confirm.d.ts +32 -0
  238. package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
  239. package/dist/internal/bounded-file-read.d.ts +10 -7
  240. package/dist/internal/bounded-file-read.d.ts.map +1 -1
  241. package/dist/internal/file-observation.d.ts +5 -1
  242. package/dist/internal/file-observation.d.ts.map +1 -1
  243. package/dist/internal/positive-integer.d.ts +2 -0
  244. package/dist/internal/positive-integer.d.ts.map +1 -1
  245. package/dist/internal/process-instance.d.ts +8 -0
  246. package/dist/internal/process-instance.d.ts.map +1 -1
  247. package/dist/internal/unix-socket.d.ts +10 -1
  248. package/dist/internal/unix-socket.d.ts.map +1 -1
  249. package/dist/server/unix-client.d.ts +7 -0
  250. package/dist/server/unix-client.d.ts.map +1 -1
  251. package/dist/service-host/systemd-inspect.d.ts +3 -1
  252. package/dist/service-host/systemd-inspect.d.ts.map +1 -1
  253. package/dist/service-host/systemd-render-shared.d.ts +64 -0
  254. package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
  255. package/dist/service-host/systemd-render.d.ts +31 -26
  256. package/dist/service-host/systemd-render.d.ts.map +1 -1
  257. package/dist/service-host/systemd-timer-render.d.ts +31 -0
  258. package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
  259. package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
  260. package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
  261. package/dist/service-host/systemd-timer.d.ts +82 -0
  262. package/dist/service-host/systemd-timer.d.ts.map +1 -0
  263. package/dist/service-host/systemd-unit-ops.d.ts +26 -0
  264. package/dist/service-host/systemd-unit-ops.d.ts.map +1 -0
  265. package/dist/service-host/systemd.d.ts +1 -1
  266. package/dist/service-host/systemd.d.ts.map +1 -1
  267. package/dist/tools/access.d.ts +30 -1
  268. package/dist/tools/access.d.ts.map +1 -1
  269. package/dist/tools/agent.d.ts +2 -2
  270. package/dist/tools/agent.d.ts.map +1 -1
  271. package/dist/tools/cli/args-scan.d.ts +5 -0
  272. package/dist/tools/cli/args-scan.d.ts.map +1 -1
  273. package/dist/tools/cli/args.d.ts +11 -5
  274. package/dist/tools/cli/args.d.ts.map +1 -1
  275. package/dist/tools/cli/invoke.d.ts +2 -1
  276. package/dist/tools/cli/invoke.d.ts.map +1 -1
  277. package/dist/tools/cli/notices.d.ts.map +1 -1
  278. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  279. package/dist/tools/cli/session.d.ts.map +1 -1
  280. package/dist/tools/execute.d.ts.map +1 -1
  281. package/dist/tools/invoker.d.ts +2 -1
  282. package/dist/tools/invoker.d.ts.map +1 -1
  283. package/dist/tools/list-names.d.ts +2 -3
  284. package/dist/tools/list-names.d.ts.map +1 -1
  285. package/dist/tools/manifest.d.ts +2 -3
  286. package/dist/tools/manifest.d.ts.map +1 -1
  287. package/dist/tools/mcp/mount.d.ts +5 -5
  288. package/dist/tools/mcp/mount.d.ts.map +1 -1
  289. package/dist/tools/mcp/register.d.ts +2 -1
  290. package/dist/tools/mcp/register.d.ts.map +1 -1
  291. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  292. package/llms/agent-executor-acp.txt +10 -6
  293. package/llms/agent-executor-claude-sdk.txt +13 -10
  294. package/llms/agent-executor-claude.txt +2 -2
  295. package/llms/agent-executor-codex.txt +9 -3
  296. package/llms/agent-executor.txt +2 -2
  297. package/llms/agent-runtime.4.txt +21 -9
  298. package/llms/cli.3.txt +4 -4
  299. package/llms/cli.txt +1 -0
  300. package/llms/declaration.txt +2 -2
  301. package/llms/files.txt +1 -1
  302. package/llms/node.txt +2 -2
  303. package/llms/server.5.txt +2 -2
  304. package/llms/service-host.txt +5 -5
  305. package/llms/stitchkit.txt +81 -77
  306. package/llms/tools.3.txt +3 -2
  307. package/llms/upgrading-0.128.0-0.129.0.txt +175 -0
  308. package/llms/upgrading.txt +1 -0
  309. package/llms-full.txt +323 -127
  310. package/llms.txt +15 -14
  311. package/package.json +1 -1
  312. package/dist/index-ajmtxsky.js +0 -193
  313. package/dist/index-ax3wns1a.js +0 -93
@@ -39,6 +39,82 @@ import {
39
39
  readSync
40
40
  } from "node:fs";
41
41
  import { open } from "node:fs/promises";
42
+
43
+ // src/internal/bounded-file-confirm.ts
44
+ import { lstatSync, statSync } from "node:fs";
45
+ import { lstat, stat } from "node:fs/promises";
46
+ function sameDeviceOrInode(a, b) {
47
+ return typeof a === "bigint" || typeof b === "bigint" ? BigInt(a) === BigInt(b) : a === b;
48
+ }
49
+ function sameSize(statSize, byteLength) {
50
+ return typeof statSize === "bigint" ? statSize === BigInt(byteLength) : statSize === byteLength;
51
+ }
52
+ function isPathSwapErrno(code, rejectSymlinks) {
53
+ return code === "ENOENT" || code === "ENOTDIR" || rejectSymlinks === true && code === "ELOOP";
54
+ }
55
+ function matchesNamedPath(after, named) {
56
+ return named.isFile() && sameDeviceOrInode(after.dev, named.dev) && sameDeviceOrInode(after.ino, named.ino);
57
+ }
58
+ function defaultNamedStat(path, rejectSymlinks) {
59
+ return rejectSymlinks ? lstat(path, { bigint: true }) : stat(path, { bigint: true });
60
+ }
61
+ function defaultNamedStatSync(path, rejectSymlinks) {
62
+ return rejectSymlinks ? lstatSync(path, { bigint: true }) : statSync(path, { bigint: true });
63
+ }
64
+ function isNanosecondStats(info) {
65
+ return typeof info.ino === "bigint" && "mtimeNs" in info && typeof info.mtimeNs === "bigint";
66
+ }
67
+ var observationOf = (info) => ({
68
+ dev: info.dev,
69
+ ino: info.ino,
70
+ size: info.size,
71
+ nlink: info.nlink,
72
+ mtimeMs: info.mtimeMs,
73
+ ctimeMs: info.ctimeMs
74
+ });
75
+ function nsToFloatMs(ns) {
76
+ return Number(ns / 1000000000n) * 1000 + Number(ns % 1000000000n) / 1e6;
77
+ }
78
+ var bigObservation = (info) => ({
79
+ dev: Number(info.dev),
80
+ ino: Number(info.ino),
81
+ size: Number(info.size),
82
+ nlink: Number(info.nlink),
83
+ mtimeMs: nsToFloatMs(info.mtimeNs),
84
+ ctimeMs: nsToFloatMs(info.ctimeNs)
85
+ });
86
+ function toObservation(info) {
87
+ return isNanosecondStats(info) ? bigObservation(info) : observationOf(info);
88
+ }
89
+ function statsViewOf(info) {
90
+ return {
91
+ dev: Number(info.dev),
92
+ ino: Number(info.ino),
93
+ size: Number(info.size),
94
+ nlink: Number(info.nlink),
95
+ mtimeMs: nsToFloatMs(info.mtimeNs),
96
+ ctimeMs: nsToFloatMs(info.ctimeNs),
97
+ mode: Number(info.mode),
98
+ uid: Number(info.uid),
99
+ gid: Number(info.gid),
100
+ isFile: () => info.isFile(),
101
+ isDirectory: () => info.isDirectory?.() ?? false,
102
+ isSymbolicLink: () => info.isSymbolicLink?.() ?? false
103
+ };
104
+ }
105
+ function sameBigStat(before, after, length) {
106
+ return after.isFile() && before.dev === after.dev && before.ino === after.ino && before.size === after.size && before.mtimeNs === after.mtimeNs && before.ctimeNs === after.ctimeNs && before.nlink === after.nlink && before.mode === after.mode && before.uid === after.uid && before.gid === after.gid && BigInt(length) === after.size;
107
+ }
108
+ function sameReadStat(before, after, length) {
109
+ if (isNanosecondStats(before) && isNanosecondStats(after)) {
110
+ return sameBigStat(before, after, length);
111
+ }
112
+ const b = toObservation(before);
113
+ const a = toObservation(after);
114
+ return after.isFile() && b.dev === a.dev && b.ino === a.ino && b.size === a.size && b.mtimeMs === a.mtimeMs && b.ctimeMs === a.ctimeMs && b.nlink === a.nlink && (before.mode === undefined ? undefined : Number(before.mode)) === (after.mode === undefined ? undefined : Number(after.mode)) && (before.uid === undefined ? undefined : Number(before.uid)) === (after.uid === undefined ? undefined : Number(after.uid)) && (before.gid === undefined ? undefined : Number(before.gid)) === (after.gid === undefined ? undefined : Number(after.gid)) && sameSize(after.size, length);
115
+ }
116
+
117
+ // src/internal/bounded-file-read.ts
42
118
  class BoundedFileReadError extends Error {
43
119
  code;
44
120
  observation;
@@ -49,14 +125,6 @@ class BoundedFileReadError extends Error {
49
125
  this.name = "BoundedFileReadError";
50
126
  }
51
127
  }
52
- var observationOf = (info) => ({
53
- dev: info.dev,
54
- ino: info.ino,
55
- size: info.size,
56
- nlink: info.nlink,
57
- mtimeMs: info.mtimeMs,
58
- ctimeMs: info.ctimeMs
59
- });
60
128
  function isNonRegularOpenErrno(code) {
61
129
  return code === "EISDIR" || code === "ENXIO" || code === "EOPNOTSUPP";
62
130
  }
@@ -79,11 +147,12 @@ async function openChecked(target, options, openDescriptor) {
79
147
  throw error;
80
148
  }
81
149
  try {
82
- const before = await handle.stat();
150
+ const before = await handle.stat({ bigint: true });
83
151
  if (!before.isFile())
84
152
  throw new BoundedFileReadError("FILE_NOT_REGULAR", "managed path is not a regular file");
85
- if (options.singleLink && before.nlink !== 1)
86
- throw new BoundedFileReadError("FILE_UNSAFE_LINK", "managed file has multiple links", observationOf(before));
153
+ const nlink = typeof before.nlink === "bigint" ? Number(before.nlink) : before.nlink;
154
+ if (options.singleLink && nlink !== 1)
155
+ throw new BoundedFileReadError("FILE_UNSAFE_LINK", "managed file has multiple links", toObservation(before));
87
156
  return { handle, before };
88
157
  } catch (error) {
89
158
  await handle.close().catch(() => {
@@ -92,35 +161,66 @@ async function openChecked(target, options, openDescriptor) {
92
161
  throw error;
93
162
  }
94
163
  }
95
- function openRegularFile(target, options = {}) {
96
- return openChecked(target, options, open);
164
+ async function openRegularFile(target, options = {}) {
165
+ const { handle, before } = await openChecked(target, options, open);
166
+ return { handle, before: toObservation(before) };
97
167
  }
98
168
  var tooLarge = (maxBytes, observation) => new BoundedFileReadError("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`, observation);
99
169
  function readBoundedFile(target, maxBytes, options = {}, openDescriptor = open) {
100
170
  return readBoundedFileFrom(target, maxBytes, options, openDescriptor);
101
171
  }
102
- async function readBoundedFileFrom(target, maxBytes, options, openDescriptor) {
172
+ function confirmNamedPath(after, named) {
173
+ if (!matchesNamedPath(after, named)) {
174
+ throw new BoundedFileReadError("FILE_CHANGED", "managed file path changed during read");
175
+ }
176
+ }
177
+ async function readBoundedFileFrom(target, maxBytes, options, openDescriptor, snapshot = {}) {
103
178
  options.signal?.throwIfAborted();
104
179
  const { handle, before } = await openChecked(target, options, openDescriptor);
105
180
  return closeAfter(handle, async () => {
106
181
  try {
107
182
  options.signal?.throwIfAborted();
108
- if (before.size > maxBytes)
183
+ const beforeSize = typeof before.size === "bigint" ? before.size : BigInt(before.size);
184
+ if (beforeSize > BigInt(maxBytes))
109
185
  throw tooLarge(maxBytes);
110
- options.inspect?.(before);
186
+ options.inspect?.(isNanosecondStats(before) ? statsViewOf(before) : before);
111
187
  const bytes = await readHandle(handle, maxBytes, options.signal);
112
- const after = await handle.stat();
113
- if (options.stable && (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || before.nlink !== after.nlink || before.mode !== after.mode || before.uid !== after.uid || before.gid !== after.gid || bytes.length !== after.size))
188
+ const after = await handle.stat({ bigint: true });
189
+ if (options.stable && !sameReadStat(before, after, bytes.length))
114
190
  throw new BoundedFileReadError("FILE_CHANGED", "managed file changed during read");
191
+ if (options.stable) {
192
+ options.signal?.throwIfAborted();
193
+ let named;
194
+ try {
195
+ named = snapshot.namedStat ? await snapshot.namedStat(target) : await defaultNamedStat(target, options.rejectSymlinks);
196
+ } catch (error) {
197
+ if (isPathSwapErrno(errnoOf(error), options.rejectSymlinks)) {
198
+ throw new BoundedFileReadError("FILE_CHANGED", "managed file path changed during read", undefined, {
199
+ cause: error
200
+ });
201
+ }
202
+ throw error;
203
+ }
204
+ confirmNamedPath(after, named);
205
+ }
115
206
  options.signal?.throwIfAborted();
116
- return { bytes, observation: observationOf(after), mode: after.mode };
207
+ return {
208
+ bytes,
209
+ observation: toObservation(after),
210
+ mode: after.mode === undefined ? undefined : Number(after.mode),
211
+ ...isNanosecondStats(after) && { after }
212
+ };
117
213
  } catch (error) {
118
214
  if (error instanceof BoundedFileReadError && error.code === "FILE_TOO_LARGE") {
119
- const current = await handle.stat().catch(() => {
215
+ const current = await handle.stat({ bigint: true }).catch(() => {
120
216
  return;
121
217
  });
122
- if (current?.isFile() && current.dev === before.dev && current.ino === before.ino)
123
- throw tooLarge(maxBytes, observationOf(current));
218
+ if (current?.isFile()) {
219
+ const curObs = toObservation(current);
220
+ const beforeObs = toObservation(before);
221
+ if (curObs.dev === beforeObs.dev && curObs.ino === beforeObs.ino)
222
+ throw tooLarge(maxBytes, curObs);
223
+ }
124
224
  }
125
225
  throw error;
126
226
  }
@@ -158,18 +258,7 @@ function readFdSync(fd, maxBytes) {
158
258
  }
159
259
  return bytes;
160
260
  }
161
- var bigObservation = (info) => ({
162
- dev: Number(info.dev),
163
- ino: Number(info.ino),
164
- size: Number(info.size),
165
- nlink: Number(info.nlink),
166
- mtimeMs: Number(info.mtimeMs),
167
- ctimeMs: Number(info.ctimeMs)
168
- });
169
- function sameBigStat(before, after, length) {
170
- return before.dev === after.dev && before.ino === after.ino && before.size === after.size && before.mtimeNs === after.mtimeNs && before.ctimeNs === after.ctimeNs && before.nlink === after.nlink && before.mode === after.mode && before.uid === after.uid && before.gid === after.gid && BigInt(length) === after.size;
171
- }
172
- function readBoundedFileSync(target, maxBytes, options = {}, openFd = openSync) {
261
+ function readBoundedFileSync(target, maxBytes, options = {}, openFd = openSync, snapshot = {}) {
173
262
  const flags = openReadFlags(options);
174
263
  let fd;
175
264
  try {
@@ -191,11 +280,23 @@ function readBoundedFileSync(target, maxBytes, options = {}, openFd = openSync)
191
280
  try {
192
281
  if (before.size > BigInt(maxBytes))
193
282
  throw tooLarge(maxBytes);
194
- options.inspect?.(fstatSync(fd));
283
+ options.inspect?.(statsViewOf(before));
195
284
  const bytes = readFdSync(fd, maxBytes);
196
285
  const after = fstatSync(fd, { bigint: true });
197
286
  if (options.stable && !sameBigStat(before, after, bytes.length))
198
287
  throw new BoundedFileReadError("FILE_CHANGED", "managed file changed during read");
288
+ if (options.stable) {
289
+ let named;
290
+ try {
291
+ named = snapshot.namedStatSync ? snapshot.namedStatSync(target) : defaultNamedStatSync(target, options.rejectSymlinks);
292
+ } catch (error) {
293
+ if (isPathSwapErrno(errnoOf(error), options.rejectSymlinks)) {
294
+ throw new BoundedFileReadError("FILE_CHANGED", "managed file path changed during read", undefined, { cause: error });
295
+ }
296
+ throw error;
297
+ }
298
+ confirmNamedPath(after, named);
299
+ }
199
300
  return { bytes, observation: bigObservation(after), mode: Number(after.mode), after };
200
301
  } catch (error) {
201
302
  if (error instanceof BoundedFileReadError && error.code === "FILE_TOO_LARGE") {
@@ -247,4 +348,4 @@ async function readHandle(handle, maxBytes, signal) {
247
348
  return bytes;
248
349
  }
249
350
 
250
- export { closeAfter, closeAfterSync, BoundedFileReadError, isNonRegularOpenErrno, openRegularFile, readBoundedFile, readBoundedFileFrom, readBoundedFileSync };
351
+ export { closeAfter, closeAfterSync, BoundedFileReadError, openRegularFile, readBoundedFile, readBoundedFileFrom, readBoundedFileSync };
@@ -15,7 +15,7 @@ import {
15
15
  assertUniqueToolName,
16
16
  buildToolPresentationSchema,
17
17
  projectedContractToolName
18
- } from "./index-3ypvpkwr.js";
18
+ } from "./index-669374qc.js";
19
19
  import {
20
20
  unwrapZodWrappers,
21
21
  objectShapeKeys,
@@ -28,12 +28,17 @@ import {
28
28
  coerceJsonArgs2
29
29
  } from "./index-j903yhp4.js";
30
30
  import {
31
+ isInspectOnlyLifecycle,
32
+ inspectOnlyError,
33
+ resolveOptionalCliToolAccess,
31
34
  toolResultFromError,
32
35
  toolErrorFromResult,
33
- toolCauseFromResult,
36
+ toolCauseFromResult
37
+ } from "./index-n3bm7zqq.js";
38
+ import {
34
39
  createToolRunner,
35
40
  formatToolError
36
- } from "./index-9wh98cpa.js";
41
+ } from "./index-fgahdc7s.js";
37
42
  import {
38
43
  isRepeatableRead
39
44
  } from "./index-0x4mnwg5.js";
@@ -48,7 +53,7 @@ import {
48
53
  } from "./index-5y7j383h.js";
49
54
  import {
50
55
  writeContainedFile
51
- } from "./index-bmaz3jzy.js";
56
+ } from "./index-rjs94dny.js";
52
57
  import {
53
58
  openPinnedDirectory,
54
59
  isSafeEntryName,
@@ -69,17 +74,14 @@ import {
69
74
  } from "./index-n20tybgk.js";
70
75
  import {
71
76
  collectToolSurface
72
- } from "./index-5e0zsbf7.js";
73
- import {
74
- resolveOptionalCliToolAccess
75
- } from "./index-ax3wns1a.js";
77
+ } from "./index-x2fb37t0.js";
76
78
  import {
77
79
  assertNoLegacyTransports
78
80
  } from "./index-akfgymyr.js";
79
81
  import {
80
82
  fetchGuarded,
81
83
  readCapped
82
- } from "./index-9y0afd5f.js";
84
+ } from "./index-apf5g7y9.js";
83
85
  import {
84
86
  isUnsafeKey,
85
87
  safeJsonParse
@@ -96,7 +98,7 @@ import {
96
98
  } from "./index-9pv126eh.js";
97
99
  import {
98
100
  assertPositiveSafeInteger
99
- } from "./index-kzavdze2.js";
101
+ } from "./index-gr0kxymw.js";
100
102
  import {
101
103
  isRecord,
102
104
  isAsyncIterable,
@@ -1758,7 +1760,8 @@ async function createCliInvoker2(config, globals) {
1758
1760
  assertNoLegacyCliPolicyKeys(config);
1759
1761
  assertCliAuthConfig(config);
1760
1762
  const typedGlobals = parseCliGlobalValues(config.globalOptions, globals);
1761
- const auth = await resolveCliIdentity(config, typedGlobals)();
1763
+ const hasManagedFactory = typeof config.services === "function" || typeof config.runtimeTools === "function";
1764
+ const auth = hasManagedFactory || !isInspectOnlyLifecycle(lifecycle) ? await resolveCliIdentity(config, typedGlobals)() : undefined;
1762
1765
  const natives = new Map;
1763
1766
  const allNativeHelp = new Map;
1764
1767
  for (const definition of config.commands ?? []) {
@@ -1769,7 +1772,7 @@ async function createCliInvoker2(config, globals) {
1769
1772
  natives.set(definition.name, definition);
1770
1773
  }
1771
1774
  const { tools, help } = buildCliSurface(config, auth, typedGlobals, allNativeHelp, new Set, invokerCommandShapeIssue);
1772
- const runTool = createCliToolRunner(config, lifecycle, auth, typedGlobals);
1775
+ const runTool = isInspectOnlyLifecycle(lifecycle) ? undefined : createCliToolRunner(config, lifecycle, auth, typedGlobals);
1773
1776
  return {
1774
1777
  commands: [
1775
1778
  ...[...natives].map(([name, definition]) => ({
@@ -1794,6 +1797,10 @@ async function createCliInvoker2(config, globals) {
1794
1797
  if (!tool) {
1795
1798
  return cliInvocationResult2(unknownCliCommand(command), command, config);
1796
1799
  }
1800
+ const inspectErr = inspectOnlyError(lifecycle);
1801
+ if (inspectErr || !runTool) {
1802
+ return shapeCliInvocationResult(toolResultFromError(inspectErr ?? new Error("Inspect-only surface refuses execution")), command, config, cliResultPolicy(config, command));
1803
+ }
1797
1804
  let result;
1798
1805
  try {
1799
1806
  result = await runTool(tool, args);
@@ -2185,9 +2192,42 @@ function answersBeforeArguments(scan) {
2185
2192
  return scan.topLevelHelp || scan.version || scan.framework.help || scan.framework.schema;
2186
2193
  }
2187
2194
  function scanCliInvocation2(argv, options) {
2188
- const res = scanCliArgv(argv, options);
2189
- if (!answersBeforeArguments(res) && res.deferredError !== undefined)
2190
- throw res.deferredError;
2195
+ let res;
2196
+ try {
2197
+ res = scanCliArgv(argv, options);
2198
+ } catch (error) {
2199
+ if (error instanceof CliArgumentError2) {
2200
+ return {
2201
+ framework: {
2202
+ json: false,
2203
+ wait: false,
2204
+ quiet: false,
2205
+ dryRun: false,
2206
+ help: false,
2207
+ schema: false
2208
+ },
2209
+ globals: parseCliGlobalValues(undefined, {}),
2210
+ commandTokens: [],
2211
+ separatedBefore: new Set,
2212
+ topLevelHelp: false,
2213
+ version: false,
2214
+ error
2215
+ };
2216
+ }
2217
+ throw error;
2218
+ }
2219
+ const error = answersBeforeArguments(res) ? undefined : res.deferredError;
2220
+ if (error !== undefined) {
2221
+ return {
2222
+ framework: res.framework,
2223
+ globals: res.globals,
2224
+ commandTokens: [],
2225
+ separatedBefore: new Set,
2226
+ topLevelHelp: false,
2227
+ version: false,
2228
+ error
2229
+ };
2230
+ }
2191
2231
  return {
2192
2232
  framework: res.framework,
2193
2233
  globals: res.globals,
@@ -2212,16 +2252,10 @@ function writeCliNotice(text) {
2212
2252
  invocation.stderr(text);
2213
2253
  return;
2214
2254
  }
2215
- let quiet;
2216
- try {
2217
- quiet = scanCliInvocation2(process.argv.slice(2)).framework.quiet;
2218
- } catch (error) {
2219
- if (error instanceof CliArgumentError2)
2220
- return;
2221
- throw error;
2222
- }
2223
- if (!quiet)
2224
- process.stderr.write(text);
2255
+ const scan = scanCliInvocation2(process.argv.slice(2));
2256
+ if (scan.error !== undefined || scan.framework.quiet)
2257
+ return;
2258
+ process.stderr.write(text);
2225
2259
  }
2226
2260
 
2227
2261
  // src/tools/cli/download.ts
@@ -2918,24 +2952,29 @@ function parseCommandArgv(argv, schema, config) {
2918
2952
  function extractCliGlobalOptions2(argv, schema) {
2919
2953
  if (schema === undefined)
2920
2954
  return { argv: [...argv], globals: {} };
2921
- const result = scanCliArgv(argv, { appGlobals: schema });
2955
+ let result;
2956
+ try {
2957
+ result = scanCliArgv(argv, { appGlobals: schema });
2958
+ } catch (error) {
2959
+ if (error instanceof CliArgumentError2) {
2960
+ return { argv: [], globals: {}, error };
2961
+ }
2962
+ throw error;
2963
+ }
2922
2964
  const early = answersBeforeArguments(result);
2923
- if (!early && result.appGlobalError !== undefined)
2924
- throw result.appGlobalError;
2925
- const refusal = early ? undefined : result.liftedBoundaryError;
2926
- if (refusal === undefined) {
2965
+ const error = early ? undefined : result.appGlobalError ?? result.liftedBoundaryError;
2966
+ if (error !== undefined) {
2927
2967
  return {
2928
- argv: result.withoutGlobals,
2968
+ argv: [],
2929
2969
  globals: result.globals,
2930
- ...result.separatedBeforeGlobals.size > 0 && {
2931
- separatedBefore: result.separatedBeforeGlobals
2932
- }
2970
+ error
2933
2971
  };
2934
2972
  }
2935
2973
  return {
2974
+ argv: result.withoutGlobals,
2936
2975
  globals: result.globals,
2937
- get argv() {
2938
- throw refusal;
2976
+ ...result.separatedBeforeGlobals.size > 0 && {
2977
+ separatedBefore: result.separatedBeforeGlobals
2939
2978
  }
2940
2979
  };
2941
2980
  }
@@ -3061,16 +3100,12 @@ function createCliSession(config, io) {
3061
3100
  function resolveCliRoute(session, argv) {
3062
3101
  const { config } = session;
3063
3102
  const { stdout, stderr, exit } = session.io;
3064
- let scan;
3065
- try {
3066
- scan = scanCliInvocation2(argv, {
3067
- appGlobals: config.globalOptions,
3068
- defaultCommand: config.defaultCommand
3069
- });
3070
- } catch (error) {
3071
- if (!(error instanceof CliArgumentError2))
3072
- throw error;
3073
- stderr(`${error.message}
3103
+ const scan = scanCliInvocation2(argv, {
3104
+ appGlobals: config.globalOptions,
3105
+ defaultCommand: config.defaultCommand
3106
+ });
3107
+ if (scan.error !== undefined) {
3108
+ stderr(`${scan.error.message}
3074
3109
  `);
3075
3110
  exit(2);
3076
3111
  return;
@@ -3268,7 +3303,7 @@ async function runManagedInvocation(session, route) {
3268
3303
  const { config } = session;
3269
3304
  const { stdout, stderr, exit } = session.io;
3270
3305
  const { command, topLevelHelp, helpRequested, schemaRequested } = route;
3271
- const managed = await buildManagedSurface(session, route.typedGlobals, !topLevelHelp && !helpRequested && !schemaRequested);
3306
+ const managed = await buildManagedSurface(session, route.typedGlobals, !topLevelHelp && !helpRequested && !schemaRequested && !isInspectOnlyLifecycle(session.lifecycle));
3272
3307
  if (topLevelHelp || command === undefined)
3273
3308
  return respondTopLevelHelp(session, route, managed);
3274
3309
  if (!managed.resolved) {
@@ -3316,6 +3351,10 @@ async function runManagedCommand(session, route, command, managed) {
3316
3351
  stdout(renderCommandSchema(command, descriptor));
3317
3352
  return exit(0);
3318
3353
  }
3354
+ const inspectErr = inspectOnlyError(session.lifecycle);
3355
+ if (inspectErr) {
3356
+ return exit(emitResult2(toolResultFromError(inspectErr), { stdout, stderr }, emitOptionsFor(config, route.framework.json, command)));
3357
+ }
3319
3358
  if (descriptor.unavailableReason !== undefined) {
3320
3359
  return exit(emitResult2(unavailableCommand(descriptor.unavailableReason), { stdout, stderr }, emitOptionsFor(config, route.framework.json, command)));
3321
3360
  }
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  readBoundedText,
6
6
  readBoundedUtf8
7
- } from "./index-xmr47znh.js";
7
+ } from "./index-827bgv33.js";
8
8
 
9
9
  // src/contract/bridge-envelope.ts
10
10
  import { z } from "zod";