@animalabs/agent-framework 0.26.2 → 0.28.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 (371) hide show
  1. package/README.md +99 -8
  2. package/dist/src/agent.d.ts +291 -23
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +596 -61
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/api/server.d.ts.map +1 -1
  7. package/dist/src/api/server.js +5 -4
  8. package/dist/src/api/server.js.map +1 -1
  9. package/dist/src/auto-continue.d.ts +34 -0
  10. package/dist/src/auto-continue.d.ts.map +1 -0
  11. package/dist/src/auto-continue.js +36 -0
  12. package/dist/src/auto-continue.js.map +1 -0
  13. package/dist/src/code-execution/isolate/scripts.d.ts +11 -0
  14. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
  15. package/dist/src/code-execution/isolate/scripts.js +5 -1
  16. package/dist/src/code-execution/isolate/scripts.js.map +1 -1
  17. package/dist/src/cut-off-round.d.ts +24 -0
  18. package/dist/src/cut-off-round.d.ts.map +1 -0
  19. package/dist/src/cut-off-round.js +87 -0
  20. package/dist/src/cut-off-round.js.map +1 -0
  21. package/dist/src/framework.d.ts +1038 -193
  22. package/dist/src/framework.d.ts.map +1 -1
  23. package/dist/src/framework.js +5967 -1514
  24. package/dist/src/framework.js.map +1 -1
  25. package/dist/src/gate/event-gate.d.ts +405 -46
  26. package/dist/src/gate/event-gate.d.ts.map +1 -1
  27. package/dist/src/gate/event-gate.js +2646 -399
  28. package/dist/src/gate/event-gate.js.map +1 -1
  29. package/dist/src/gate/index.d.ts +3 -2
  30. package/dist/src/gate/index.d.ts.map +1 -1
  31. package/dist/src/gate/index.js +2 -1
  32. package/dist/src/gate/index.js.map +1 -1
  33. package/dist/src/gate/recipe-reconcile.d.ts +103 -0
  34. package/dist/src/gate/recipe-reconcile.d.ts.map +1 -0
  35. package/dist/src/gate/recipe-reconcile.js +325 -0
  36. package/dist/src/gate/recipe-reconcile.js.map +1 -0
  37. package/dist/src/gate/reply-judge.d.ts +116 -0
  38. package/dist/src/gate/reply-judge.d.ts.map +1 -0
  39. package/dist/src/gate/reply-judge.js +467 -0
  40. package/dist/src/gate/reply-judge.js.map +1 -0
  41. package/dist/src/gate/types.d.ts +229 -8
  42. package/dist/src/gate/types.d.ts.map +1 -1
  43. package/dist/src/heartbeat/heartbeat.d.ts +184 -0
  44. package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
  45. package/dist/src/heartbeat/heartbeat.js +752 -0
  46. package/dist/src/heartbeat/heartbeat.js.map +1 -0
  47. package/dist/src/heartbeat/reminder-time.d.ts +5 -0
  48. package/dist/src/heartbeat/reminder-time.d.ts.map +1 -0
  49. package/dist/src/heartbeat/reminder-time.js +107 -0
  50. package/dist/src/heartbeat/reminder-time.js.map +1 -0
  51. package/dist/src/index.d.ts +10 -4
  52. package/dist/src/index.d.ts.map +1 -1
  53. package/dist/src/index.js +7 -2
  54. package/dist/src/index.js.map +1 -1
  55. package/dist/src/mcpl/capability-mask.d.ts.map +1 -1
  56. package/dist/src/mcpl/capability-mask.js +3 -2
  57. package/dist/src/mcpl/capability-mask.js.map +1 -1
  58. package/dist/src/mcpl/channel-registry.d.ts +433 -113
  59. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  60. package/dist/src/mcpl/channel-registry.js +1154 -435
  61. package/dist/src/mcpl/channel-registry.js.map +1 -1
  62. package/dist/src/mcpl/conversation-router.d.ts +16 -8
  63. package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
  64. package/dist/src/mcpl/conversation-router.js +29 -15
  65. package/dist/src/mcpl/conversation-router.js.map +1 -1
  66. package/dist/src/mcpl/convert-block.d.ts.map +1 -1
  67. package/dist/src/mcpl/convert-block.js +14 -2
  68. package/dist/src/mcpl/convert-block.js.map +1 -1
  69. package/dist/src/mcpl/hook-orchestrator.d.ts +7 -1
  70. package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
  71. package/dist/src/mcpl/hook-orchestrator.js +32 -7
  72. package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
  73. package/dist/src/mcpl/inbound-source.d.ts +26 -10
  74. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  75. package/dist/src/mcpl/inbound-source.js +40 -69
  76. package/dist/src/mcpl/inbound-source.js.map +1 -1
  77. package/dist/src/mcpl/index.d.ts +5 -1
  78. package/dist/src/mcpl/index.d.ts.map +1 -1
  79. package/dist/src/mcpl/index.js +4 -0
  80. package/dist/src/mcpl/index.js.map +1 -1
  81. package/dist/src/mcpl/inference-router.d.ts +14 -2
  82. package/dist/src/mcpl/inference-router.d.ts.map +1 -1
  83. package/dist/src/mcpl/inference-router.js +73 -28
  84. package/dist/src/mcpl/inference-router.js.map +1 -1
  85. package/dist/src/mcpl/prose-grammar.d.ts +4 -0
  86. package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
  87. package/dist/src/mcpl/prose-grammar.js +6 -0
  88. package/dist/src/mcpl/prose-grammar.js.map +1 -1
  89. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  90. package/dist/src/mcpl/protocol-family.js +3 -0
  91. package/dist/src/mcpl/protocol-family.js.map +1 -1
  92. package/dist/src/mcpl/push-coalescer.d.ts +20 -2
  93. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  94. package/dist/src/mcpl/push-coalescer.js +33 -11
  95. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  96. package/dist/src/mcpl/reference-fetcher.d.ts +63 -42
  97. package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
  98. package/dist/src/mcpl/reference-fetcher.js +177 -145
  99. package/dist/src/mcpl/reference-fetcher.js.map +1 -1
  100. package/dist/src/mcpl/references.d.ts +380 -46
  101. package/dist/src/mcpl/references.d.ts.map +1 -1
  102. package/dist/src/mcpl/references.js +736 -77
  103. package/dist/src/mcpl/references.js.map +1 -1
  104. package/dist/src/mcpl/server-connection.d.ts +93 -4
  105. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  106. package/dist/src/mcpl/server-connection.js +176 -11
  107. package/dist/src/mcpl/server-connection.js.map +1 -1
  108. package/dist/src/mcpl/tags.d.ts +9 -2
  109. package/dist/src/mcpl/tags.d.ts.map +1 -1
  110. package/dist/src/mcpl/tags.js +12 -2
  111. package/dist/src/mcpl/tags.js.map +1 -1
  112. package/dist/src/mcpl/tool-lifecycle.d.ts +11 -0
  113. package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
  114. package/dist/src/mcpl/tool-lifecycle.js +21 -0
  115. package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
  116. package/dist/src/mcpl/tool-presence.d.ts +311 -0
  117. package/dist/src/mcpl/tool-presence.d.ts.map +1 -0
  118. package/dist/src/mcpl/tool-presence.js +697 -0
  119. package/dist/src/mcpl/tool-presence.js.map +1 -0
  120. package/dist/src/mcpl/tool-result-normalize.d.ts +9 -3
  121. package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
  122. package/dist/src/mcpl/tool-result-normalize.js +14 -6
  123. package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
  124. package/dist/src/mcpl/tool-signature.d.ts +46 -0
  125. package/dist/src/mcpl/tool-signature.d.ts.map +1 -0
  126. package/dist/src/mcpl/tool-signature.js +321 -0
  127. package/dist/src/mcpl/tool-signature.js.map +1 -0
  128. package/dist/src/mcpl/toolset-host.d.ts +251 -0
  129. package/dist/src/mcpl/toolset-host.d.ts.map +1 -0
  130. package/dist/src/mcpl/toolset-host.js +720 -0
  131. package/dist/src/mcpl/toolset-host.js.map +1 -0
  132. package/dist/src/mcpl/toolsets-module.d.ts +83 -0
  133. package/dist/src/mcpl/toolsets-module.d.ts.map +1 -0
  134. package/dist/src/mcpl/toolsets-module.js +523 -0
  135. package/dist/src/mcpl/toolsets-module.js.map +1 -0
  136. package/dist/src/mcpl/transport.d.ts +2 -2
  137. package/dist/src/mcpl/transport.d.ts.map +1 -1
  138. package/dist/src/mcpl/transport.js +3 -2
  139. package/dist/src/mcpl/transport.js.map +1 -1
  140. package/dist/src/mcpl/types.d.ts +24 -2
  141. package/dist/src/mcpl/types.d.ts.map +1 -1
  142. package/dist/src/mcpl/types.js.map +1 -1
  143. package/dist/src/mcpl/visible-content.d.ts +7 -9
  144. package/dist/src/mcpl/visible-content.d.ts.map +1 -1
  145. package/dist/src/mcpl/visible-content.js +21 -9
  146. package/dist/src/mcpl/visible-content.js.map +1 -1
  147. package/dist/src/module-registry.d.ts +27 -9
  148. package/dist/src/module-registry.d.ts.map +1 -1
  149. package/dist/src/module-registry.js +77 -17
  150. package/dist/src/module-registry.js.map +1 -1
  151. package/dist/src/modules/discord/index.js +1 -1
  152. package/dist/src/modules/discord/index.js.map +1 -1
  153. package/dist/src/modules/history/index.d.ts +2 -1
  154. package/dist/src/modules/history/index.d.ts.map +1 -1
  155. package/dist/src/modules/history/index.js +73 -28
  156. package/dist/src/modules/history/index.js.map +1 -1
  157. package/dist/src/modules/history/semantic.d.ts +108 -6
  158. package/dist/src/modules/history/semantic.d.ts.map +1 -1
  159. package/dist/src/modules/history/semantic.js +273 -57
  160. package/dist/src/modules/history/semantic.js.map +1 -1
  161. package/dist/src/modules/workspace/answers.d.ts +22 -0
  162. package/dist/src/modules/workspace/answers.d.ts.map +1 -0
  163. package/dist/src/modules/workspace/answers.js +123 -0
  164. package/dist/src/modules/workspace/answers.js.map +1 -0
  165. package/dist/src/modules/workspace/branch-intent.d.ts +5 -3
  166. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
  167. package/dist/src/modules/workspace/branch-intent.js +6 -2
  168. package/dist/src/modules/workspace/branch-intent.js.map +1 -1
  169. package/dist/src/modules/workspace/direct-write.d.ts +184 -0
  170. package/dist/src/modules/workspace/direct-write.d.ts.map +1 -0
  171. package/dist/src/modules/workspace/direct-write.js +417 -0
  172. package/dist/src/modules/workspace/direct-write.js.map +1 -0
  173. package/dist/src/modules/workspace/disk-agreement.d.ts +33 -11
  174. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
  175. package/dist/src/modules/workspace/disk-agreement.js +48 -17
  176. package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
  177. package/dist/src/modules/workspace/edit-text.d.ts +27 -12
  178. package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
  179. package/dist/src/modules/workspace/edit-text.js +61 -29
  180. package/dist/src/modules/workspace/edit-text.js.map +1 -1
  181. package/dist/src/modules/workspace/effects.d.ts +10 -0
  182. package/dist/src/modules/workspace/effects.d.ts.map +1 -1
  183. package/dist/src/modules/workspace/effects.js +21 -14
  184. package/dist/src/modules/workspace/effects.js.map +1 -1
  185. package/dist/src/modules/workspace/index.d.ts +308 -78
  186. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  187. package/dist/src/modules/workspace/index.js +2103 -720
  188. package/dist/src/modules/workspace/index.js.map +1 -1
  189. package/dist/src/modules/workspace/observe.d.ts +75 -63
  190. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  191. package/dist/src/modules/workspace/observe.js +366 -180
  192. package/dist/src/modules/workspace/observe.js.map +1 -1
  193. package/dist/src/modules/workspace/read-page.d.ts +41 -0
  194. package/dist/src/modules/workspace/read-page.d.ts.map +1 -0
  195. package/dist/src/modules/workspace/read-page.js +219 -0
  196. package/dist/src/modules/workspace/read-page.js.map +1 -0
  197. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  198. package/dist/src/modules/workspace/reconcile.js +26 -16
  199. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  200. package/dist/src/modules/workspace/result-text.d.ts +68 -0
  201. package/dist/src/modules/workspace/result-text.d.ts.map +1 -0
  202. package/dist/src/modules/workspace/result-text.js +94 -0
  203. package/dist/src/modules/workspace/result-text.js.map +1 -0
  204. package/dist/src/modules/workspace/sync.d.ts +9 -0
  205. package/dist/src/modules/workspace/sync.d.ts.map +1 -1
  206. package/dist/src/modules/workspace/sync.js +14 -0
  207. package/dist/src/modules/workspace/sync.js.map +1 -1
  208. package/dist/src/modules/workspace/text.d.ts +29 -12
  209. package/dist/src/modules/workspace/text.d.ts.map +1 -1
  210. package/dist/src/modules/workspace/text.js +35 -33
  211. package/dist/src/modules/workspace/text.js.map +1 -1
  212. package/dist/src/modules/workspace/types.d.ts +137 -60
  213. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  214. package/dist/src/modules/workspace/types.js.map +1 -1
  215. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  216. package/dist/src/modules/workspace/watcher.js +8 -3
  217. package/dist/src/modules/workspace/watcher.js.map +1 -1
  218. package/dist/src/prose-drafts.d.ts +4 -3
  219. package/dist/src/prose-drafts.d.ts.map +1 -1
  220. package/dist/src/prose-drafts.js +3 -2
  221. package/dist/src/prose-drafts.js.map +1 -1
  222. package/dist/src/reasoning-loss-notice.d.ts +23 -0
  223. package/dist/src/reasoning-loss-notice.d.ts.map +1 -0
  224. package/dist/src/reasoning-loss-notice.js +50 -0
  225. package/dist/src/reasoning-loss-notice.js.map +1 -0
  226. package/dist/src/reasoning-loss.d.ts +24 -0
  227. package/dist/src/reasoning-loss.d.ts.map +1 -0
  228. package/dist/src/reasoning-loss.js +102 -0
  229. package/dist/src/reasoning-loss.js.map +1 -0
  230. package/dist/src/send-tools.d.ts +3 -2
  231. package/dist/src/send-tools.d.ts.map +1 -1
  232. package/dist/src/send-tools.js +3 -2
  233. package/dist/src/send-tools.js.map +1 -1
  234. package/dist/src/sent-rows.d.ts +59 -0
  235. package/dist/src/sent-rows.d.ts.map +1 -0
  236. package/dist/src/sent-rows.js +145 -0
  237. package/dist/src/sent-rows.js.map +1 -0
  238. package/dist/src/silent-heartbeat.d.ts +17 -10
  239. package/dist/src/silent-heartbeat.d.ts.map +1 -1
  240. package/dist/src/silent-heartbeat.js.map +1 -1
  241. package/dist/src/stable-hash.d.ts +3 -0
  242. package/dist/src/stable-hash.d.ts.map +1 -0
  243. package/dist/src/stable-hash.js +15 -0
  244. package/dist/src/stable-hash.js.map +1 -0
  245. package/dist/src/stored-injections.d.ts +99 -0
  246. package/dist/src/stored-injections.d.ts.map +1 -0
  247. package/dist/src/stored-injections.js +106 -0
  248. package/dist/src/stored-injections.js.map +1 -0
  249. package/dist/src/text-as-stored.d.ts +4 -3
  250. package/dist/src/text-as-stored.d.ts.map +1 -1
  251. package/dist/src/text-as-stored.js +4 -3
  252. package/dist/src/text-as-stored.js.map +1 -1
  253. package/dist/src/thinking-drops.d.ts +74 -0
  254. package/dist/src/thinking-drops.d.ts.map +1 -0
  255. package/dist/src/thinking-drops.js +96 -0
  256. package/dist/src/thinking-drops.js.map +1 -0
  257. package/dist/src/tool-args.d.ts +12 -0
  258. package/dist/src/tool-args.d.ts.map +1 -1
  259. package/dist/src/tool-args.js +35 -1
  260. package/dist/src/tool-args.js.map +1 -1
  261. package/dist/src/tool-image-ledger.d.ts +9 -8
  262. package/dist/src/tool-image-ledger.d.ts.map +1 -1
  263. package/dist/src/tool-image-ledger.js +9 -8
  264. package/dist/src/tool-image-ledger.js.map +1 -1
  265. package/dist/src/tool-presentation.d.ts.map +1 -1
  266. package/dist/src/tool-presentation.js +3 -1
  267. package/dist/src/tool-presentation.js.map +1 -1
  268. package/dist/src/tool-result-guard.d.ts +12 -6
  269. package/dist/src/tool-result-guard.d.ts.map +1 -1
  270. package/dist/src/tool-result-guard.js +44 -17
  271. package/dist/src/tool-result-guard.js.map +1 -1
  272. package/dist/src/tool-result-history.d.ts +176 -24
  273. package/dist/src/tool-result-history.d.ts.map +1 -1
  274. package/dist/src/tool-result-history.js +411 -91
  275. package/dist/src/tool-result-history.js.map +1 -1
  276. package/dist/src/tune-out/coordinator.d.ts +17 -9
  277. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  278. package/dist/src/tune-out/coordinator.js +84 -37
  279. package/dist/src/tune-out/coordinator.js.map +1 -1
  280. package/dist/src/tune-out/tools.d.ts +4 -1
  281. package/dist/src/tune-out/tools.d.ts.map +1 -1
  282. package/dist/src/types/agent.d.ts +217 -7
  283. package/dist/src/types/agent.d.ts.map +1 -1
  284. package/dist/src/types/events.d.ts +33 -9
  285. package/dist/src/types/events.d.ts.map +1 -1
  286. package/dist/src/types/framework.d.ts +39 -3
  287. package/dist/src/types/framework.d.ts.map +1 -1
  288. package/dist/src/types/module.d.ts +95 -9
  289. package/dist/src/types/module.d.ts.map +1 -1
  290. package/dist/src/types/trace.d.ts +91 -3
  291. package/dist/src/types/trace.d.ts.map +1 -1
  292. package/package.json +5 -4
  293. package/src/agent.ts +661 -67
  294. package/src/api/server.ts +5 -4
  295. package/src/auto-continue.ts +43 -0
  296. package/src/code-execution/isolate/scripts.ts +11 -3
  297. package/src/cut-off-round.ts +98 -0
  298. package/src/framework.ts +6168 -1540
  299. package/src/gate/event-gate.ts +2895 -405
  300. package/src/gate/index.ts +10 -1
  301. package/src/gate/recipe-reconcile.ts +355 -0
  302. package/src/gate/reply-judge.ts +512 -0
  303. package/src/gate/types.ts +234 -9
  304. package/src/heartbeat/heartbeat.ts +804 -0
  305. package/src/heartbeat/reminder-time.ts +107 -0
  306. package/src/index.ts +11 -4
  307. package/src/mcpl/capability-mask.ts +3 -2
  308. package/src/mcpl/channel-registry.ts +1222 -468
  309. package/src/mcpl/conversation-router.ts +34 -16
  310. package/src/mcpl/convert-block.ts +14 -1
  311. package/src/mcpl/hook-orchestrator.ts +33 -6
  312. package/src/mcpl/inbound-source.ts +42 -69
  313. package/src/mcpl/index.ts +6 -1
  314. package/src/mcpl/inference-router.ts +79 -34
  315. package/src/mcpl/prose-grammar.ts +7 -0
  316. package/src/mcpl/protocol-family.ts +2 -0
  317. package/src/mcpl/push-coalescer.ts +51 -13
  318. package/src/mcpl/reference-fetcher.ts +201 -162
  319. package/src/mcpl/references.ts +851 -77
  320. package/src/mcpl/server-connection.ts +189 -11
  321. package/src/mcpl/tags.ts +13 -2
  322. package/src/mcpl/tool-lifecycle.ts +21 -0
  323. package/src/mcpl/tool-presence.ts +716 -0
  324. package/src/mcpl/tool-result-normalize.ts +18 -6
  325. package/src/mcpl/tool-signature.ts +316 -0
  326. package/src/mcpl/toolset-host.ts +727 -0
  327. package/src/mcpl/toolsets-module.ts +545 -0
  328. package/src/mcpl/transport.ts +3 -2
  329. package/src/mcpl/types.ts +25 -2
  330. package/src/mcpl/visible-content.ts +22 -9
  331. package/src/module-registry.ts +85 -26
  332. package/src/modules/discord/index.ts +1 -1
  333. package/src/modules/history/index.ts +70 -30
  334. package/src/modules/history/semantic.ts +308 -54
  335. package/src/modules/workspace/answers.ts +133 -0
  336. package/src/modules/workspace/branch-intent.ts +10 -5
  337. package/src/modules/workspace/direct-write.ts +460 -0
  338. package/src/modules/workspace/disk-agreement.ts +52 -21
  339. package/src/modules/workspace/edit-text.ts +84 -35
  340. package/src/modules/workspace/effects.ts +22 -13
  341. package/src/modules/workspace/index.ts +2142 -723
  342. package/src/modules/workspace/observe.ts +381 -177
  343. package/src/modules/workspace/read-page.ts +228 -0
  344. package/src/modules/workspace/reconcile.ts +27 -15
  345. package/src/modules/workspace/result-text.ts +121 -0
  346. package/src/modules/workspace/sync.ts +16 -0
  347. package/src/modules/workspace/text.ts +58 -32
  348. package/src/modules/workspace/types.ts +137 -60
  349. package/src/modules/workspace/watcher.ts +8 -3
  350. package/src/prose-drafts.ts +4 -3
  351. package/src/reasoning-loss-notice.ts +62 -0
  352. package/src/reasoning-loss.ts +120 -0
  353. package/src/send-tools.ts +3 -2
  354. package/src/sent-rows.ts +162 -0
  355. package/src/silent-heartbeat.ts +17 -10
  356. package/src/stable-hash.ts +14 -0
  357. package/src/stored-injections.ts +131 -0
  358. package/src/text-as-stored.ts +4 -3
  359. package/src/thinking-drops.ts +135 -0
  360. package/src/tool-args.ts +34 -1
  361. package/src/tool-image-ledger.ts +9 -8
  362. package/src/tool-presentation.ts +3 -1
  363. package/src/tool-result-guard.ts +45 -17
  364. package/src/tool-result-history.ts +471 -90
  365. package/src/tune-out/coordinator.ts +80 -37
  366. package/src/tune-out/tools.ts +4 -1
  367. package/src/types/agent.ts +220 -7
  368. package/src/types/events.ts +33 -9
  369. package/src/types/framework.ts +36 -3
  370. package/src/types/module.ts +91 -9
  371. package/src/types/trace.ts +94 -3
@@ -0,0 +1,123 @@
1
+ import { constants } from 'node:os';
2
+ import { boundedErrorMessage } from '../../error-message.js';
3
+ export class Refusal extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = 'Refusal';
7
+ }
8
+ }
9
+ export function didNothing(tool, body, to) {
10
+ return `The ${tool} did nothing${to !== undefined ? ` to ${JSON.stringify(to)}` : ''}: ${body}`;
11
+ }
12
+ export function onlyTheHost(can) {
13
+ return `Calling again won't change that; whoever runs this host can ${can}.`;
14
+ }
15
+ // Node's own message for a failed system call names the host's absolute
16
+ // path, so an agent gets the code's plain words instead.
17
+ export function errnoWords(code) {
18
+ switch (code) {
19
+ case 'ENOENT': return 'nothing is there';
20
+ case 'ENOTDIR': return 'a part of the path isn\'t a directory';
21
+ case 'EACCES': return 'permission denied';
22
+ case 'EPERM': return 'not permitted';
23
+ case 'EISDIR': return 'it\'s a directory';
24
+ case 'EEXIST': return 'something is already there';
25
+ case 'ENOTEMPTY': return 'the directory isn\'t empty';
26
+ case 'EXDEV': return 'the move would cross from one filesystem to another';
27
+ case 'ELOOP': return 'too many symlinks, or a loop of them';
28
+ case 'ENAMETOOLONG': return 'a name too long for the filesystem';
29
+ case 'ENOSPC': return 'no space left on the disk';
30
+ case 'EDQUOT': return 'the disk quota is used up';
31
+ case 'EFBIG': return 'the file would be too large for the filesystem';
32
+ case 'EROFS': return 'the filesystem is read-only';
33
+ case 'EIO': return 'an input/output error on the disk';
34
+ case 'EBUSY':
35
+ case 'ETXTBSY': return 'the file is busy';
36
+ case 'EMFILE':
37
+ case 'ENFILE': return 'too many files are open on this host';
38
+ case 'ENOMEM': return 'this host is out of memory';
39
+ case 'EAGAIN':
40
+ case 'EWOULDBLOCK': return 'the system was busy';
41
+ case 'EINTR': return 'the system call was interrupted';
42
+ case 'ETIMEDOUT': return 'the system call timed out';
43
+ case 'ESTALE': return 'a stale network file handle';
44
+ case 'EINVAL': return 'the system refused an argument as invalid';
45
+ case undefined: return 'an error the system gave no code for';
46
+ default: return `a system error (${code})`;
47
+ }
48
+ }
49
+ export function hostFix(code) {
50
+ switch (code) {
51
+ case 'ENOSPC': return 'free space on its disk';
52
+ case 'EFBIG': return 'raise the limit on a file\'s size, or keep the files on a filesystem that holds larger ones';
53
+ case 'EDQUOT': return 'raise or free the disk quota';
54
+ case 'EROFS': return 'make the filesystem writable';
55
+ case 'EIO': return 'check the disk';
56
+ case 'EACCES':
57
+ case 'EPERM': return 'change the permissions';
58
+ case 'EMFILE':
59
+ case 'ENFILE': return 'raise the limit on open files';
60
+ case 'ELOOP': return 'fix the symlinks on that path';
61
+ case 'ENOMEM': return 'free memory';
62
+ default: return undefined;
63
+ }
64
+ }
65
+ const PASSING = new Set(['EIO', 'EMFILE', 'ENFILE', 'ENOMEM']);
66
+ const AS_DISK_IS = new Set(['EISDIR', 'ENOTDIR', 'EEXIST', 'ENOTEMPTY', 'EXDEV']);
67
+ export function systemWords(code, error) {
68
+ return code !== undefined ? errnoWords(code) : boundedErrorMessage(error);
69
+ }
70
+ export function errnoWayOn(code, otherwise = 'Calling again may work.', hostsName = false) {
71
+ if (code === 'ENAMETOOLONG' && hostsName)
72
+ return onlyTheHost("give the mount's directory a shorter path");
73
+ const fix = hostFix(code);
74
+ if (fix !== undefined) {
75
+ return code !== undefined && PASSING.has(code) ? `Calling again may work; if it fails the same way, whoever runs this host can ${fix}.` : onlyTheHost(fix);
76
+ }
77
+ if (code === 'ENAMETOOLONG')
78
+ return "Calling again won't change that; a shorter name would.";
79
+ if (code !== undefined && AS_DISK_IS.has(code))
80
+ return "Calling again won't change that while disk holds what it does there.";
81
+ return otherwise;
82
+ }
83
+ const OS_ERRNO = new Map();
84
+ for (const [name, number] of Object.entries(constants.errno))
85
+ if (!OS_ERRNO.has(number))
86
+ OS_ERRNO.set(number, name);
87
+ // Chronicle's store errors carry the code GenericFailure, and an I/O
88
+ // failure's message is "IO error: " and Rust's std::io::Error, which ends
89
+ // with the OS error's number: an errno on POSIX, a Win32 code on Windows.
90
+ export function errnoCode(error) {
91
+ const code = typeof error === 'object' && error !== null ? error.code : undefined;
92
+ if (typeof code === 'string' && /^E[A-Z0-9]+$/.test(code))
93
+ return code;
94
+ const os = error instanceof Error && process.platform !== 'win32' ? /^IO error: .*\(os error (\d+)\)$/s.exec(error.message) : null;
95
+ return os !== null ? OS_ERRNO.get(Number(os[1])) : undefined;
96
+ }
97
+ const CHANGING = new Set(['write', 'edit', 'edit_many', 'delete', 'materialize', 'sync']);
98
+ export function changesFiles(tool) {
99
+ return CHANGING.has(tool);
100
+ }
101
+ export const ROOT_RECHECK = "Calling again may work; if it fails the same way, whoever runs this host can check the mount's directory and its path.";
102
+ export const ROOT_UNCHECKED = "Calling again won't change that while the mount's directory is gone from its path, and checks it afresh otherwise; whoever runs this host can check the directory and its path.";
103
+ export const AWAITS_REOPEN = "The workspace can't check its files against disk until its store is reopened, so calling again won't change that; whoever runs this host can reopen it with a restart.";
104
+ export function unexpectedAnswer(tool, subject, error, how = {}) {
105
+ const stored = how.stored ?? 'unknown';
106
+ const code = errnoCode(error);
107
+ const words = how.said ?? systemWords(code, error);
108
+ const before = stored !== 'not' ? '' : tool === 'edit_many' ? ', before any of its edits was stored' : `, before the ${tool === 'delete' ? 'deletion' : tool} was stored`;
109
+ const head = `The ${tool}${subject !== undefined ? ` of ${subject}` : ''} stopped on an error the workspace didn't expect${before}: ${words.replace(/\.$/, '')}.`;
110
+ if (stored === 'held') {
111
+ return `${head} ${subject !== undefined ? subject : 'Its files'} already held what the call gave, so ${subject !== undefined ? 'it holds' : 'they hold'} that in the workspace either way.`;
112
+ }
113
+ const changing = stored === 'unknown' && CHANGING.has(tool);
114
+ if (how.reopen === true)
115
+ return [head, AWAITS_REOPEN, ...(changing ? ["Whether it changed anything isn't known until then."] : [])].join(' ');
116
+ const look = !changing ? null
117
+ : how.look ?? (subject === undefined ? 'read its files to see what they hold now' : `read ${subject} to see what the workspace holds there now`);
118
+ const on = code !== undefined
119
+ ? errnoWayOn(code, "Calling again may work; if it fails the same way, whoever runs this host can find the whole error in this host's log.")
120
+ : "Calling again may work; if it fails the same way, whoever runs this host can find the whole error in this host's log.";
121
+ return [head, ...(look !== null ? [`Whether it changed anything isn't known: ${look}.`] : []), on].join(' ');
122
+ }
123
+ //# sourceMappingURL=answers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answers.js","sourceRoot":"","sources":["../../../../src/modules/workspace/answers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,OAAO,OAAQ,SAAQ,KAAK;IAChC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF;AAED,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAAY,EAAE,EAAW;IAChE,OAAO,OAAO,IAAI,eAAe,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;AAClG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,+DAA+D,GAAG,GAAG,CAAC;AAC/E,CAAC;AAED,wEAAwE;AACxE,yDAAyD;AACzD,MAAM,UAAU,UAAU,CAAC,IAAwB;IACjD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,EAAE,OAAO,kBAAkB,CAAC;QACzC,KAAK,SAAS,EAAE,OAAO,uCAAuC,CAAC;QAC/D,KAAK,QAAQ,EAAE,OAAO,mBAAmB,CAAC;QAC1C,KAAK,OAAO,EAAE,OAAO,eAAe,CAAC;QACrC,KAAK,QAAQ,EAAE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AC,WAAW,oCAAoC,CAAC;IAC9L,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,qDAAqD,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9I,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;QAC3B,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,QAAQ,OAAO,4CAA4C,CAAC,CAAC;IACnJ,MAAM,EAAE,GAAG,IAAI,KAAK,SAAS;QAC3B,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,uHAAuH,CAAC;QAC3I,CAAC,CAAC,uHAAuH,CAAC;IAC5H,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,4CAA4C,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/G,CAAC"}
@@ -53,9 +53,11 @@ export interface BranchIntent {
53
53
  origin?: 'store';
54
54
  conflict?: ConflictRecord;
55
55
  /**
56
- * Why a recorded intent can't be read (its blob missing from the store, or
57
- * not an intent): a tombstone or conflict it held is unknown, never absent.
58
- * Never written; a put replaces the damaged record.
56
+ * Why a recorded intent can't be read (its blob missing from the store,
57
+ * a blob chronicle can't read, or not an intent): a tombstone or conflict
58
+ * it held is unknown, never absent.
59
+ * Never written; a put replaces the damaged record, unless it puts the same
60
+ * contents over a blob file chronicle can't read, which chronicle keeps.
59
61
  */
60
62
  unreadable?: string;
61
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"branch-intent.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/branch-intent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,YAAY;AACtB,yDAAyD;AACvD,cAAc;AAChB,gFAAgF;GAC9E,iBAAiB;AACnB,iDAAiD;GAC/C,gCAAgC;AAClC,sFAAsF;GACpF,wBAAwB;AAC1B,sFAAsF;GACpF,oBAAoB;AACtB,kFAAkF;GAChF,aAAa,CAAC;AAElB,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAoBD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAW,QAAQ,CAAC,WAAW,EAAE,MAAM;IAAzE,YAA6B,KAAK,EAAE,OAAO,EAAW,WAAW,EAAE,MAAM,EAAI;IAE7E,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAIrC;IAED,mEAAmE;IACnE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAYnD;IAED,yCAAyC;IACzC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,YAAY,GAAG,IAAI,CAE1E;IAED,qEAAqE;IACrE,IAAI,CAAC,MAAM,SAAK,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAU/C;CACF"}
1
+ {"version":3,"file":"branch-intent.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/branch-intent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,MAAM,YAAY;AACtB,yDAAyD;AACvD,cAAc;AAChB,gFAAgF;GAC9E,iBAAiB;AACnB,iDAAiD;GAC/C,gCAAgC;AAClC,sFAAsF;GACpF,wBAAwB;AAC1B,sFAAsF;GACpF,oBAAoB;AACtB,kFAAkF;GAChF,aAAa,CAAC;AAElB,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAsBD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAW,QAAQ,CAAC,WAAW,EAAE,MAAM;IAAzE,YAA6B,KAAK,EAAE,OAAO,EAAW,WAAW,EAAE,MAAM,EAAI;IAE7E,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAIrC;IAED,mEAAmE;IACnE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAYnD;IAED,yCAAyC;IACzC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,YAAY,GAAG,IAAI,CAE1E;IAED,qEAAqE;IACrE,IAAI,CAAC,MAAM,SAAK,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAU/C;CACF"}
@@ -17,15 +17,19 @@
17
17
  * Each record is a small JSON blob addressed from the tree, so reading one is
18
18
  * treeGet + getBlob and writing one is storeBlob + treeSet.
19
19
  */
20
+ import { storedBytes } from './sync.js';
20
21
  function isEmpty(intent) {
21
22
  return intent.tombstone === undefined && intent.origin === undefined && intent.conflict === undefined &&
22
23
  intent.unreadable === undefined;
23
24
  }
24
25
  /** A recorded intent's blob, read; a damaged one says why it can't be. */
25
26
  function readIntent(store, blobHash) {
26
- const blob = store.getBlob(blobHash);
27
- if (!blob)
27
+ const stored = storedBytes(store, blobHash);
28
+ if ('missing' in stored)
28
29
  return { unreadable: "its record's blob is missing from the store" };
30
+ if ('unreadable' in stored)
31
+ return { unreadable: `its record's blob can't be read from the store (${stored.unreadable})` };
32
+ const blob = stored.bytes;
29
33
  try {
30
34
  const parsed = JSON.parse(blob.toString('utf-8'));
31
35
  if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
@@ -1 +1 @@
1
- {"version":3,"file":"branch-int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AAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * A direct mount's writes (MountConfig.backend): disk is the only copy, so a
3
+ * write lands there whole when its call answers, or doesn't happen and leaves
4
+ * disk as it was. Ported from anima-research/hands-mcp's staged write
5
+ * (src/shared.ts), behind the mount's boundary as the workspace's other
6
+ * effects hold it (effects.ts):
7
+ *
8
+ * - The file's directory is located inside the mount (checkDir), and where
9
+ * the file lands is judged as a push's write judges it (refusedLanding):
10
+ * inside the mount, in no nested mount's directory, and covered by the
11
+ * mount's include. A link at the file is refused on a mount that doesn't
12
+ * follow links; on one that does, the write goes to the file it leads to
13
+ * when the call stages it, judged the same way, and the link stays.
14
+ * - The new bytes are staged beside the file, in `.workspace-staged-<id>`,
15
+ * at the file's mode, special bits included as far as the kernel lets this
16
+ * process set them (a setgid bit only for a member of the file's group),
17
+ * and renamed over it, so a reader beside the agent never sees half a file
18
+ * and a process killed mid-write leaves the old file whole. A file this
19
+ * process may not write is refused, as a push's write, which opens it for
20
+ * writing, is refused: the rename needs only the directory's permission.
21
+ * A process that dies between staging and its rename leaves the staged
22
+ * file, under that name, which `ls` and `git status` show; so does a
23
+ * refused write whose removal of its staged file fails or can't tell the
24
+ * file is its own, or whose directory another writer moved after the
25
+ * staging, since the removal goes by path (discard) and the path then
26
+ * leads elsewhere. Nothing sweeps it, and the answer doesn't name it.
27
+ * The removal checks the staged name holds that file and unlinks it with
28
+ * no turn of the event loop between, so only a file another writer puts
29
+ * there in that instant can be removed in its place, or one put there
30
+ * that a stat can't tell from it: on the freed inode number, with the
31
+ * same size, mode and owner, in the same tick of a coarse clock.
32
+ * - The rename gives a hard-linked path a file of its own, and the other
33
+ * links keep the old text: `otherLinks` counts them for the answer.
34
+ * - Just before the rename, an edit's file is checked unchanged since its
35
+ * read, by its bytes, read again, and its identity (checkUnchanged),
36
+ * synchronously, so the check and the renames after it run with no turn
37
+ * of the event loop between. Only a change landing in that instant isn't
38
+ * seen, which for edit_many runs from the check through its last rename:
39
+ * no rename can be made conditional.
40
+ * - No sync. The store-backed kind syncs its pushes for its agreement
41
+ * record (reconcile.ts), and a direct mount keeps none, so a power loss
42
+ * or a kernel crash can lose a direct write after its answer said it
43
+ * landed, as it can a hands-mcp write. A process dying can't: the rename is
44
+ * whole by then.
45
+ *
46
+ * Node has no openat or renameat, so the stage and the rename go through the
47
+ * checked directory's path: a directory replaced by another writer on disk
48
+ * between the directory's check and the staging, or after its last check
49
+ * (placedStill), can redirect them, as effects.ts says of a create. For
50
+ * edit_many that last check is each file's, before the other files' checks.
51
+ */
52
+ import type { BigIntStats } from 'node:fs';
53
+ import { type CheckedDir, type MountView } from './observe.js';
54
+ /** The name a staged file starts with, beside the file it replaces. */
55
+ export declare const STAGED_PREFIX = ".workspace-staged-";
56
+ /**
57
+ * Why a direct write didn't happen when its mount's root was replaced under
58
+ * it: a direct mount keeps no root to sync to (MountConfig.backend), so its
59
+ * next call works beneath whatever is there then.
60
+ */
61
+ export declare const ROOT_MOVED = "the mount root changed while this call was being applied: a new call works beneath whatever directory the mount's path leads to then";
62
+ /**
63
+ * A file's identity as a write must find it unchanged: device, inode, size,
64
+ * mode, owner, group, and modification and change times, to the nanosecond.
65
+ * The mode, owner and group are fields of their own, since a chmod or chown
66
+ * in the same tick of a coarse clock as the file's last change leaves its
67
+ * change time as it was (checkUnchanged).
68
+ */
69
+ export interface FileIdentity {
70
+ dev: bigint;
71
+ ino: bigint;
72
+ size: bigint;
73
+ mode: bigint;
74
+ uid: bigint;
75
+ gid: bigint;
76
+ mtimeNs: bigint;
77
+ ctimeNs: bigint;
78
+ }
79
+ export declare const identityOf: (info: BigIntStats) => FileIdentity;
80
+ export declare const sameIdentity: (a: FileIdentity, b: FileIdentity) => boolean;
81
+ /** Another writer replaced, changed or removed the file between its read and its rename; nothing was written. */
82
+ export declare class FileChanged extends Error {
83
+ }
84
+ /** Why a direct write didn't happen, in words for its answer; disk is as it was. */
85
+ export declare class WriteRefused extends Error {
86
+ readonly wayOn: string | null;
87
+ readonly errno?: string | undefined;
88
+ constructor(message: string, wayOn?: string | null, errno?: string | undefined);
89
+ }
90
+ /** A file's new bytes staged beside it, ready to be renamed over it (stageContained). */
91
+ export interface Staged {
92
+ /** Where the rename lands: the file's entry in its checked directory, a followed link's file's included. */
93
+ path: string;
94
+ /** The staged file, beside it. */
95
+ temp: string;
96
+ /**
97
+ * Which file the staged file is, so the rename moves, and a refusal
98
+ * removes, that one and no other put at its name: its whole identity,
99
+ * since a file made where it was unlinked can take its inode number.
100
+ */
101
+ tempIdentity: FileIdentity;
102
+ /** The mount's root and the file's directory, as checked when it was staged. */
103
+ root: CheckedDir;
104
+ parent: CheckedDir;
105
+ /**
106
+ * The other hard links the replaced file had, counted just before the
107
+ * rename and kept once it succeeds: the rename gives this path a file of
108
+ * its own, and they keep the old text. 0 until then, and for a new file.
109
+ */
110
+ otherLinks: number;
111
+ }
112
+ /**
113
+ * Test seams. `afterStage` is called once a call's files are staged, before
114
+ * they're checked unchanged (another writer acting then); `beforeRename`
115
+ * just before each rename, inside its refusal, so throwing stands for the
116
+ * rename failing. Production sets neither.
117
+ */
118
+ export declare const directWriteTestSeam: {
119
+ afterStage?: (paths: string[]) => void | Promise<void>;
120
+ beforeRename?: (path: string) => void;
121
+ };
122
+ /**
123
+ * Stage `bytes` beside the mount-relative file `rel`, to be renamed over it:
124
+ * the first half of a direct write. The file keeps its mode, special bits
125
+ * included, as far as the kernel lets this process set them; a new file
126
+ * takes `0666` less the umask, as a shell's would. Its owner and group are
127
+ * this process's and the ones its directory gives a new file, and an ACL or
128
+ * extended attribute on the file isn't carried over, as with any write that
129
+ * renames over a file. Anything there that isn't a regular file is refused,
130
+ * and a refusal removes the staged file it made, except where the header
131
+ * says one is left. The staged file is written and moded through its own
132
+ * handle, never through its name again.
133
+ */
134
+ export declare function stageContained(view: MountView, rootReal: string, rel: string, bytes: Buffer, { makeDirectory }?: {
135
+ makeDirectory?: boolean;
136
+ }): Promise<Staged>;
137
+ /**
138
+ * Throw unless the root and the file's directory are still the ones the
139
+ * staging checked, with a push's words for the directory (effects.ts
140
+ * moved()).
141
+ */
142
+ export declare function placedStill(staged: Staged): Promise<void>;
143
+ /**
144
+ * Throw unless the file is still what its read found: FileChanged when it
145
+ * changed or is gone, nothing written. `expected` is null for a write, which
146
+ * read nothing and replaces whatever is there. Either way a link swapped in
147
+ * at the file the rename replaces (on a mount that follows links, the file
148
+ * the link at the agent's path led to when the call staged it) is refused
149
+ * rather than replaced, and so is a file this process may not write. It reads the entry the
150
+ * rename replaces, and then the file's bytes, synchronously, as renameInto
151
+ * runs, so a check and the renames after it run with no turn of the event
152
+ * loop between.
153
+ *
154
+ * The identity, taken once the bytes are read, catches a file replaced or
155
+ * re-moded under the call, which equal bytes wouldn't show. The bytes are
156
+ * compared with the ones the edit read: a kernel that stamps files from a
157
+ * coarse clock, as Linux before 6.13 does, leaves a file's identity as it
158
+ * was after a second write of the same size within one tick of its last
159
+ * change (on Debian's Linux 6.12.113 with ext4, 1,632 to 1,752 of 2,000
160
+ * such rewrites kept every stamp, in three runs), and the bytes show that
161
+ * change on every clock. The bytes are read through an open that follows
162
+ * no link and doesn't wait on a pipe put at the path since its lstat, and
163
+ * at most one byte past what the edit read, so the check never blocks and
164
+ * reads no more than that.
165
+ */
166
+ export declare function checkUnchanged(staged: Staged, expected: {
167
+ identity: FileIdentity;
168
+ bytes: Buffer;
169
+ } | null): void;
170
+ /**
171
+ * Rename the staged file over the file, synchronously (checkUnchanged says
172
+ * why), counting the other hard links it splits the path from just before.
173
+ * A failed rename leaves the file as it was; the caller removes the staged
174
+ * file (discard).
175
+ */
176
+ export declare function renameInto(staged: Staged): void;
177
+ /**
178
+ * Remove a staged file that won't be renamed, best effort: only the file
179
+ * this call staged, by its whole identity, since whatever another writer
180
+ * put at its name since is theirs, as renameInto leaves it too. Checked and
181
+ * removed synchronously, as the rename is (checkUnchanged says why).
182
+ */
183
+ export declare function discard(staged: Staged): Promise<void>;
184
+ //# sourceMappingURL=direct-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct-write.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/direct-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAaf,MAAM,cAAc,CAAC;AAQtB,uEAAuE;AACvE,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,UAAU,yIAA0I,CAAC;AAElK;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,UAAU,SAAU,WAAW,KAAG,YAS7C,CAAC;AAEH,eAAO,MAAM,YAAY,MAAO,YAAY,KAAK,YAAY,KAAG,OAET,CAAC;AAExD,iHAAiH;AACjH,qBAAa,WAAY,SAAQ,KAAK;CAAG;AAEzC,oFAAoF;AACpF,qBAAa,YAAa,SAAQ,KAAK;IACR,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAAS,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM;IAA1F,YAAY,OAAO,EAAE,MAAM,EAAW,KAAK,GAAE,MAAM,GAAG,IAAW,EAAW,KAAK,CAAC,EAAE,MAAM,YAAA,EAEzF;CACF;AAmBD,yFAAyF;AACzF,MAAM,WAAW,MAAM;IACrB,4GAA4G;IAC5G,IAAI,EAAE,MAAM,CAAC;IACb,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