@cleocode/core 2026.6.12 → 2026.6.13

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 (385) hide show
  1. package/dist/conduit/local-transport.d.ts +12 -0
  2. package/dist/conduit/local-transport.d.ts.map +1 -1
  3. package/dist/conduit/local-transport.js +53 -23
  4. package/dist/conduit/local-transport.js.map +1 -1
  5. package/dist/crypto/credentials.d.ts +37 -0
  6. package/dist/crypto/credentials.d.ts.map +1 -1
  7. package/dist/crypto/credentials.js +110 -0
  8. package/dist/crypto/credentials.js.map +1 -1
  9. package/dist/dispatch/contracts/derive-output-contract.d.ts +86 -0
  10. package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -0
  11. package/dist/dispatch/contracts/derive-output-contract.js +347 -0
  12. package/dist/dispatch/contracts/derive-output-contract.js.map +1 -0
  13. package/dist/dispatch/contracts/ensures-schema.d.ts +77 -0
  14. package/dist/dispatch/contracts/ensures-schema.d.ts.map +1 -0
  15. package/dist/dispatch/contracts/ensures-schema.js +91 -0
  16. package/dist/dispatch/contracts/ensures-schema.js.map +1 -0
  17. package/dist/dispatch/contracts/output-contracts.d.ts +27 -5
  18. package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
  19. package/dist/dispatch/contracts/output-contracts.js +29 -6
  20. package/dist/dispatch/contracts/output-contracts.js.map +1 -1
  21. package/dist/docs/export-document.js +2294 -1250
  22. package/dist/docs/export-document.js.map +3 -3
  23. package/dist/go/driver.d.ts +132 -7
  24. package/dist/go/driver.d.ts.map +1 -1
  25. package/dist/go/driver.js +135 -10
  26. package/dist/go/driver.js.map +1 -1
  27. package/dist/go/index.d.ts +1 -1
  28. package/dist/go/index.d.ts.map +1 -1
  29. package/dist/go/index.js +1 -1
  30. package/dist/go/index.js.map +1 -1
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal.d.ts +13 -10
  36. package/dist/internal.d.ts.map +1 -1
  37. package/dist/internal.js +11 -11
  38. package/dist/internal.js.map +1 -1
  39. package/dist/lifecycle/engine-ops.d.ts.map +1 -1
  40. package/dist/lifecycle/engine-ops.js +7 -4
  41. package/dist/lifecycle/engine-ops.js.map +1 -1
  42. package/dist/lifecycle/ivtr-loop.d.ts +108 -183
  43. package/dist/lifecycle/ivtr-loop.d.ts.map +1 -1
  44. package/dist/lifecycle/ivtr-loop.js +207 -522
  45. package/dist/lifecycle/ivtr-loop.js.map +1 -1
  46. package/dist/llm/auxiliary-fallback.js +1 -1
  47. package/dist/llm/auxiliary-fallback.js.map +1 -1
  48. package/dist/llm/cli-ops.d.ts +14 -1
  49. package/dist/llm/cli-ops.d.ts.map +1 -1
  50. package/dist/llm/cli-ops.js +41 -12
  51. package/dist/llm/cli-ops.js.map +1 -1
  52. package/dist/llm/concrete-session.d.ts.map +1 -1
  53. package/dist/llm/concrete-session.js +4 -0
  54. package/dist/llm/concrete-session.js.map +1 -1
  55. package/dist/llm/credentials.d.ts +35 -0
  56. package/dist/llm/credentials.d.ts.map +1 -1
  57. package/dist/llm/credentials.js +49 -0
  58. package/dist/llm/credentials.js.map +1 -1
  59. package/dist/llm/index.d.ts +4 -0
  60. package/dist/llm/index.d.ts.map +1 -1
  61. package/dist/llm/index.js +4 -0
  62. package/dist/llm/index.js.map +1 -1
  63. package/dist/llm/pi/gondolin-loader.d.ts +241 -0
  64. package/dist/llm/pi/gondolin-loader.d.ts.map +1 -0
  65. package/dist/llm/pi/gondolin-loader.js +195 -0
  66. package/dist/llm/pi/gondolin-loader.js.map +1 -0
  67. package/dist/llm/pi/index.d.ts +28 -0
  68. package/dist/llm/pi/index.d.ts.map +1 -0
  69. package/dist/llm/pi/index.js +27 -0
  70. package/dist/llm/pi/index.js.map +1 -0
  71. package/dist/llm/pi/pi-agent-adapter.d.ts +135 -0
  72. package/dist/llm/pi/pi-agent-adapter.d.ts.map +1 -0
  73. package/dist/llm/pi/pi-agent-adapter.js +329 -0
  74. package/dist/llm/pi/pi-agent-adapter.js.map +1 -0
  75. package/dist/llm/pi/pi-errors.d.ts +161 -0
  76. package/dist/llm/pi/pi-errors.d.ts.map +1 -0
  77. package/dist/llm/pi/pi-errors.js +296 -0
  78. package/dist/llm/pi/pi-errors.js.map +1 -0
  79. package/dist/llm/pi/pi-execution-env.d.ts +286 -0
  80. package/dist/llm/pi/pi-execution-env.d.ts.map +1 -0
  81. package/dist/llm/pi/pi-execution-env.js +406 -0
  82. package/dist/llm/pi/pi-execution-env.js.map +1 -0
  83. package/dist/llm/pi/pi-gondolin-env.d.ts +227 -0
  84. package/dist/llm/pi/pi-gondolin-env.d.ts.map +1 -0
  85. package/dist/llm/pi/pi-gondolin-env.js +541 -0
  86. package/dist/llm/pi/pi-gondolin-env.js.map +1 -0
  87. package/dist/llm/pi/pi-session-storage.d.ts +154 -0
  88. package/dist/llm/pi/pi-session-storage.d.ts.map +1 -0
  89. package/dist/llm/pi/pi-session-storage.js +314 -0
  90. package/dist/llm/pi/pi-session-storage.js.map +1 -0
  91. package/dist/llm/pi/pi-stream-fn.d.ts +124 -0
  92. package/dist/llm/pi/pi-stream-fn.d.ts.map +1 -0
  93. package/dist/llm/pi/pi-stream-fn.js +504 -0
  94. package/dist/llm/pi/pi-stream-fn.js.map +1 -0
  95. package/dist/llm/pi/pi-tool-bridge.d.ts +99 -0
  96. package/dist/llm/pi/pi-tool-bridge.d.ts.map +1 -0
  97. package/dist/llm/pi/pi-tool-bridge.js +117 -0
  98. package/dist/llm/pi/pi-tool-bridge.js.map +1 -0
  99. package/dist/llm/pi/pi-types.d.ts +56 -0
  100. package/dist/llm/pi/pi-types.d.ts.map +1 -0
  101. package/dist/llm/pi/pi-types.js +16 -0
  102. package/dist/llm/pi/pi-types.js.map +1 -0
  103. package/dist/llm/pi/resolve-execution-env.d.ts +194 -0
  104. package/dist/llm/pi/resolve-execution-env.d.ts.map +1 -0
  105. package/dist/llm/pi/resolve-execution-env.js +132 -0
  106. package/dist/llm/pi/resolve-execution-env.js.map +1 -0
  107. package/dist/llm/plugin-facade.js +2253 -1151
  108. package/dist/llm/plugin-facade.js.map +3 -3
  109. package/dist/llm/role-executor.d.ts.map +1 -1
  110. package/dist/llm/role-executor.js +8 -5
  111. package/dist/llm/role-executor.js.map +1 -1
  112. package/dist/llm/role-resolver.d.ts +46 -14
  113. package/dist/llm/role-resolver.d.ts.map +1 -1
  114. package/dist/llm/role-resolver.js +178 -20
  115. package/dist/llm/role-resolver.js.map +1 -1
  116. package/dist/llm/sealed-credential.d.ts +125 -0
  117. package/dist/llm/sealed-credential.d.ts.map +1 -0
  118. package/dist/llm/sealed-credential.js +133 -0
  119. package/dist/llm/sealed-credential.js.map +1 -0
  120. package/dist/llm/session-factory.d.ts.map +1 -1
  121. package/dist/llm/session-factory.js +6 -2
  122. package/dist/llm/session-factory.js.map +1 -1
  123. package/dist/llm/system-key.d.ts +67 -0
  124. package/dist/llm/system-key.d.ts.map +1 -0
  125. package/dist/llm/system-key.js +87 -0
  126. package/dist/llm/system-key.js.map +1 -0
  127. package/dist/llm/system-of-use-registry.d.ts +119 -0
  128. package/dist/llm/system-of-use-registry.d.ts.map +1 -0
  129. package/dist/llm/system-of-use-registry.js +200 -0
  130. package/dist/llm/system-of-use-registry.js.map +1 -0
  131. package/dist/llm/system-resolver.d.ts +32 -10
  132. package/dist/llm/system-resolver.d.ts.map +1 -1
  133. package/dist/llm/system-resolver.js +70 -18
  134. package/dist/llm/system-resolver.js.map +1 -1
  135. package/dist/memory/brain-writer-thread.d.ts.map +1 -1
  136. package/dist/memory/brain-writer-thread.js +116 -11
  137. package/dist/memory/brain-writer-thread.js.map +1 -1
  138. package/dist/memory/claude-mem-migration.d.ts.map +1 -1
  139. package/dist/memory/claude-mem-migration.js +21 -0
  140. package/dist/memory/claude-mem-migration.js.map +1 -1
  141. package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
  142. package/dist/memory/graph-memory-bridge.js +32 -25
  143. package/dist/memory/graph-memory-bridge.js.map +1 -1
  144. package/dist/memory/llm-backend-resolver.js +23 -5
  145. package/dist/memory/llm-backend-resolver.js.map +1 -1
  146. package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
  147. package/dist/nexus/migrations/M-split-graph.js +60 -53
  148. package/dist/nexus/migrations/M-split-graph.js.map +1 -1
  149. package/dist/orchestrate/pivot.d.ts.map +1 -1
  150. package/dist/orchestrate/pivot.js +20 -2
  151. package/dist/orchestrate/pivot.js.map +1 -1
  152. package/dist/release/engine-ops.js +2 -2
  153. package/dist/release/engine-ops.js.map +1 -1
  154. package/dist/routing/capability-matrix.d.ts.map +1 -1
  155. package/dist/routing/capability-matrix.js +0 -57
  156. package/dist/routing/capability-matrix.js.map +1 -1
  157. package/dist/selfimprove/budget.d.ts +206 -0
  158. package/dist/selfimprove/budget.d.ts.map +1 -0
  159. package/dist/selfimprove/budget.js +203 -0
  160. package/dist/selfimprove/budget.js.map +1 -0
  161. package/dist/selfimprove/dhq-adapter.d.ts +105 -0
  162. package/dist/selfimprove/dhq-adapter.d.ts.map +1 -0
  163. package/dist/selfimprove/dhq-adapter.js +95 -0
  164. package/dist/selfimprove/dhq-adapter.js.map +1 -0
  165. package/dist/selfimprove/draft-pr.d.ts +129 -0
  166. package/dist/selfimprove/draft-pr.d.ts.map +1 -0
  167. package/dist/selfimprove/draft-pr.js +158 -0
  168. package/dist/selfimprove/draft-pr.js.map +1 -0
  169. package/dist/selfimprove/envelope-diff.d.ts +162 -0
  170. package/dist/selfimprove/envelope-diff.d.ts.map +1 -0
  171. package/dist/selfimprove/envelope-diff.js +321 -0
  172. package/dist/selfimprove/envelope-diff.js.map +1 -0
  173. package/dist/selfimprove/replay.d.ts +121 -0
  174. package/dist/selfimprove/replay.d.ts.map +1 -0
  175. package/dist/selfimprove/replay.js +109 -0
  176. package/dist/selfimprove/replay.js.map +1 -0
  177. package/dist/selfimprove/run-loop.d.ts +148 -0
  178. package/dist/selfimprove/run-loop.d.ts.map +1 -0
  179. package/dist/selfimprove/run-loop.js +240 -0
  180. package/dist/selfimprove/run-loop.js.map +1 -0
  181. package/dist/selfimprove/scenario.d.ts +145 -0
  182. package/dist/selfimprove/scenario.d.ts.map +1 -0
  183. package/dist/selfimprove/scenario.js +243 -0
  184. package/dist/selfimprove/scenario.js.map +1 -0
  185. package/dist/sentient/daemon-entry.js +5 -0
  186. package/dist/sentient/daemon-entry.js.map +1 -1
  187. package/dist/sentient/daemon.d.ts.map +1 -1
  188. package/dist/sentient/daemon.js +19 -0
  189. package/dist/sentient/daemon.js.map +1 -1
  190. package/dist/sentient/hygiene-scan.d.ts.map +1 -1
  191. package/dist/sentient/hygiene-scan.js +14 -6
  192. package/dist/sentient/hygiene-scan.js.map +1 -1
  193. package/dist/sessions/briefing.d.ts.map +1 -1
  194. package/dist/sessions/briefing.js +13 -9
  195. package/dist/sessions/briefing.js.map +1 -1
  196. package/dist/sessions/connection-session-handle.d.ts +161 -0
  197. package/dist/sessions/connection-session-handle.d.ts.map +1 -0
  198. package/dist/sessions/connection-session-handle.js +168 -0
  199. package/dist/sessions/connection-session-handle.js.map +1 -0
  200. package/dist/sessions/handoff.d.ts.map +1 -1
  201. package/dist/sessions/handoff.js +9 -0
  202. package/dist/sessions/handoff.js.map +1 -1
  203. package/dist/sessions/index.d.ts +4 -1
  204. package/dist/sessions/index.d.ts.map +1 -1
  205. package/dist/sessions/index.js +31 -1
  206. package/dist/sessions/index.js.map +1 -1
  207. package/dist/sessions/session-id.d.ts +34 -0
  208. package/dist/sessions/session-id.d.ts.map +1 -1
  209. package/dist/sessions/session-id.js +37 -0
  210. package/dist/sessions/session-id.js.map +1 -1
  211. package/dist/sessions/session-manifest-mirror.d.ts +115 -0
  212. package/dist/sessions/session-manifest-mirror.d.ts.map +1 -0
  213. package/dist/sessions/session-manifest-mirror.js +250 -0
  214. package/dist/sessions/session-manifest-mirror.js.map +1 -0
  215. package/dist/sessions/session-switch.d.ts.map +1 -1
  216. package/dist/sessions/session-switch.js +5 -2
  217. package/dist/sessions/session-switch.js.map +1 -1
  218. package/dist/store/converters.d.ts.map +1 -1
  219. package/dist/store/converters.js +2 -0
  220. package/dist/store/converters.js.map +1 -1
  221. package/dist/store/db-helpers.d.ts.map +1 -1
  222. package/dist/store/db-helpers.js +2 -0
  223. package/dist/store/db-helpers.js.map +1 -1
  224. package/dist/store/dual-scope-db.d.ts.map +1 -1
  225. package/dist/store/dual-scope-db.js +87 -47
  226. package/dist/store/dual-scope-db.js.map +1 -1
  227. package/dist/store/pi-session-store.d.ts +151 -0
  228. package/dist/store/pi-session-store.d.ts.map +1 -0
  229. package/dist/store/pi-session-store.js +166 -0
  230. package/dist/store/pi-session-store.js.map +1 -0
  231. package/dist/store/safety-data-accessor.d.ts +1 -0
  232. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  233. package/dist/store/safety-data-accessor.js +5 -0
  234. package/dist/store/safety-data-accessor.js.map +1 -1
  235. package/dist/store/schema/cleo-global/accounts.d.ts +357 -0
  236. package/dist/store/schema/cleo-global/accounts.d.ts.map +1 -0
  237. package/dist/store/schema/cleo-global/accounts.js +136 -0
  238. package/dist/store/schema/cleo-global/accounts.js.map +1 -0
  239. package/dist/store/schema/cleo-global/index.d.ts +2 -0
  240. package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
  241. package/dist/store/schema/cleo-global/index.js +2 -0
  242. package/dist/store/schema/cleo-global/index.js.map +1 -1
  243. package/dist/store/schema/cleo-global/session-manifest.d.ts +217 -0
  244. package/dist/store/schema/cleo-global/session-manifest.d.ts.map +1 -0
  245. package/dist/store/schema/cleo-global/session-manifest.js +99 -0
  246. package/dist/store/schema/cleo-global/session-manifest.js.map +1 -0
  247. package/dist/store/schema/cleo-project/tasks-core.d.ts +16 -0
  248. package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
  249. package/dist/store/schema/cleo-project/tasks-core.js +14 -0
  250. package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
  251. package/dist/store/schema/tasks.d.ts +16 -0
  252. package/dist/store/schema/tasks.d.ts.map +1 -1
  253. package/dist/store/schema/tasks.js +10 -0
  254. package/dist/store/schema/tasks.js.map +1 -1
  255. package/dist/store/selfimprove-dhq-schema.d.ts +284 -0
  256. package/dist/store/selfimprove-dhq-schema.d.ts.map +1 -0
  257. package/dist/store/selfimprove-dhq-schema.js +128 -0
  258. package/dist/store/selfimprove-dhq-schema.js.map +1 -0
  259. package/dist/store/selfimprove-dhq-store.d.ts +175 -0
  260. package/dist/store/selfimprove-dhq-store.d.ts.map +1 -0
  261. package/dist/store/selfimprove-dhq-store.js +182 -0
  262. package/dist/store/selfimprove-dhq-store.js.map +1 -0
  263. package/dist/store/session-store.d.ts +52 -13
  264. package/dist/store/session-store.d.ts.map +1 -1
  265. package/dist/store/session-store.js +71 -13
  266. package/dist/store/session-store.js.map +1 -1
  267. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  268. package/dist/store/sqlite-data-accessor.js +7 -0
  269. package/dist/store/sqlite-data-accessor.js.map +1 -1
  270. package/dist/store/umbrella-data-accessor.d.ts +1 -0
  271. package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
  272. package/dist/store/umbrella-data-accessor.js +5 -0
  273. package/dist/store/umbrella-data-accessor.js.map +1 -1
  274. package/dist/store/validation-schemas.d.ts +32 -0
  275. package/dist/store/validation-schemas.d.ts.map +1 -1
  276. package/dist/store/writer-lease-schema.d.ts +392 -0
  277. package/dist/store/writer-lease-schema.d.ts.map +1 -0
  278. package/dist/store/writer-lease-schema.js +142 -0
  279. package/dist/store/writer-lease-schema.js.map +1 -0
  280. package/dist/store/writer-lease.d.ts +368 -0
  281. package/dist/store/writer-lease.d.ts.map +1 -0
  282. package/dist/store/writer-lease.js +1002 -0
  283. package/dist/store/writer-lease.js.map +1 -0
  284. package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
  285. package/dist/tasks/backfill-child-projections.js +14 -9
  286. package/dist/tasks/backfill-child-projections.js.map +1 -1
  287. package/dist/tasks/complete.d.ts.map +1 -1
  288. package/dist/tasks/complete.js +7 -10
  289. package/dist/tasks/complete.js.map +1 -1
  290. package/dist/tasks/duplicate-detector.d.ts.map +1 -1
  291. package/dist/tasks/duplicate-detector.js +14 -7
  292. package/dist/tasks/duplicate-detector.js.map +1 -1
  293. package/dist/telemetry/index.d.ts.map +1 -1
  294. package/dist/telemetry/index.js +10 -4
  295. package/dist/telemetry/index.js.map +1 -1
  296. package/dist/tools/agent-registry.d.ts +250 -0
  297. package/dist/tools/agent-registry.d.ts.map +1 -0
  298. package/dist/tools/agent-registry.js +292 -0
  299. package/dist/tools/agent-registry.js.map +1 -0
  300. package/dist/tools/agent-tool-families.d.ts +107 -0
  301. package/dist/tools/agent-tool-families.d.ts.map +1 -0
  302. package/dist/tools/agent-tool-families.js +527 -0
  303. package/dist/tools/agent-tool-families.js.map +1 -0
  304. package/dist/tools/browser-driver.d.ts +183 -0
  305. package/dist/tools/browser-driver.d.ts.map +1 -0
  306. package/dist/tools/browser-driver.js +242 -0
  307. package/dist/tools/browser-driver.js.map +1 -0
  308. package/dist/tools/builtin-agent-tools.d.ts +36 -0
  309. package/dist/tools/builtin-agent-tools.d.ts.map +1 -0
  310. package/dist/tools/builtin-agent-tools.js +150 -0
  311. package/dist/tools/builtin-agent-tools.js.map +1 -0
  312. package/dist/tools/dispatch.d.ts +370 -0
  313. package/dist/tools/dispatch.d.ts.map +1 -0
  314. package/dist/tools/dispatch.js +505 -0
  315. package/dist/tools/dispatch.js.map +1 -0
  316. package/dist/tools/env-scrub.d.ts +93 -0
  317. package/dist/tools/env-scrub.d.ts.map +1 -0
  318. package/dist/tools/env-scrub.js +176 -0
  319. package/dist/tools/env-scrub.js.map +1 -0
  320. package/dist/tools/fs.d.ts +30 -0
  321. package/dist/tools/fs.d.ts.map +1 -1
  322. package/dist/tools/fs.js +55 -2
  323. package/dist/tools/fs.js.map +1 -1
  324. package/dist/tools/guard.d.ts +15 -0
  325. package/dist/tools/guard.d.ts.map +1 -1
  326. package/dist/tools/guard.js +49 -12
  327. package/dist/tools/guard.js.map +1 -1
  328. package/dist/tools/index.d.ts +10 -0
  329. package/dist/tools/index.d.ts.map +1 -1
  330. package/dist/tools/index.js +37 -0
  331. package/dist/tools/index.js.map +1 -1
  332. package/dist/tools/pty.d.ts +45 -0
  333. package/dist/tools/pty.d.ts.map +1 -0
  334. package/dist/tools/pty.js +166 -0
  335. package/dist/tools/pty.js.map +1 -0
  336. package/dist/tools/schema-gen.d.ts +57 -0
  337. package/dist/tools/schema-gen.d.ts.map +1 -0
  338. package/dist/tools/schema-gen.js +52 -0
  339. package/dist/tools/schema-gen.js.map +1 -0
  340. package/dist/tools/shell.d.ts +12 -0
  341. package/dist/tools/shell.d.ts.map +1 -1
  342. package/dist/tools/shell.js +14 -1
  343. package/dist/tools/shell.js.map +1 -1
  344. package/dist/tools/web-agent-tools.d.ts +72 -0
  345. package/dist/tools/web-agent-tools.d.ts.map +1 -0
  346. package/dist/tools/web-agent-tools.js +393 -0
  347. package/dist/tools/web-agent-tools.js.map +1 -0
  348. package/dist/tools/web-search-backends.d.ts +156 -0
  349. package/dist/tools/web-search-backends.d.ts.map +1 -0
  350. package/dist/tools/web-search-backends.js +290 -0
  351. package/dist/tools/web-search-backends.js.map +1 -0
  352. package/dist/validation/ops.d.ts +1 -15
  353. package/dist/validation/ops.d.ts.map +1 -1
  354. package/dist/validation/ops.js +0 -20
  355. package/dist/validation/ops.js.map +1 -1
  356. package/migrations/drizzle-cleo-global/20260607000000_t11891-writer-leases/migration.sql +55 -0
  357. package/migrations/drizzle-cleo-global/20260607010000_t11639-session-manifest/migration.sql +43 -0
  358. package/migrations/drizzle-cleo-global/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
  359. package/migrations/drizzle-cleo-global/20260608010000_t11709-accounts-credential-pool/migration.sql +72 -0
  360. package/migrations/drizzle-cleo-global/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
  361. package/migrations/drizzle-cleo-project/20260607000000_t11891-writer-leases/migration.sql +55 -0
  362. package/migrations/drizzle-cleo-project/20260607010000_t11639-session-parent/migration.sql +22 -0
  363. package/migrations/drizzle-cleo-project/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
  364. package/migrations/drizzle-cleo-project/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
  365. package/package.json +15 -13
  366. package/dist/lifecycle/chain-composition.d.ts +0 -30
  367. package/dist/lifecycle/chain-composition.d.ts.map +0 -1
  368. package/dist/lifecycle/chain-composition.js +0 -152
  369. package/dist/lifecycle/chain-composition.js.map +0 -1
  370. package/dist/lifecycle/chain-store.d.ts +0 -70
  371. package/dist/lifecycle/chain-store.d.ts.map +0 -1
  372. package/dist/lifecycle/chain-store.js +0 -246
  373. package/dist/lifecycle/chain-store.js.map +0 -1
  374. package/dist/lifecycle/default-chain.d.ts +0 -39
  375. package/dist/lifecycle/default-chain.d.ts.map +0 -1
  376. package/dist/lifecycle/default-chain.js +0 -176
  377. package/dist/lifecycle/default-chain.js.map +0 -1
  378. package/dist/lifecycle/tessera-engine.d.ts +0 -48
  379. package/dist/lifecycle/tessera-engine.d.ts.map +0 -1
  380. package/dist/lifecycle/tessera-engine.js +0 -249
  381. package/dist/lifecycle/tessera-engine.js.map +0 -1
  382. package/dist/validation/chain-validation.d.ts +0 -43
  383. package/dist/validation/chain-validation.d.ts.map +0 -1
  384. package/dist/validation/chain-validation.js +0 -146
  385. package/dist/validation/chain-validation.js.map +0 -1
@@ -0,0 +1,296 @@
1
+ /**
2
+ * Pi error / exit containment (T11761 · S1 · T11897).
3
+ *
4
+ * The Pi agent loop runs **in-process** inside the Cleo daemon with ZERO
5
+ * authority. Two library packages are in the safe import set
6
+ * (`@earendil-works/pi-agent-core` + `@earendil-works/pi-ai`) and both are
7
+ * verified exit-clean, but the daemon MUST be protected from a process
8
+ * termination originating from a Pi code path. This module is the containment
9
+ * boundary: it converts a `process.exit()` call or a `process.exitCode` mutation
10
+ * attempted while running Pi code into a typed {@link PiContainmentError} thrown
11
+ * back to the caller.
12
+ *
13
+ * ## Containment scope (honest guarantee)
14
+ *
15
+ * The `process.exit` trap is process-global and REF-COUNTED across overlapping
16
+ * {@link wrapPiCall} scopes, so it covers the synchronous body, every awaited
17
+ * continuation, AND any deferred/detached exit (`setTimeout`, un-awaited
18
+ * promise, microtask) that fires while ANY Pi call is still active. The ONLY
19
+ * residual window is an exit fired AFTER the last active call has settled. To
20
+ * close that too — a daemon-lifetime guarantee covering ANY present/future Pi
21
+ * exit, synchronous or detached — the daemon calls {@link installDaemonExitGuard}
22
+ * once at startup to PIN the trap for its whole lifetime.
23
+ *
24
+ * Scope discipline (S1): NO `pi-ai`/`pi-agent-core` imports, NO DB access, NO
25
+ * LLM calls. Import-time side-effect free — the logger is resolved lazily
26
+ * (never at module top level).
27
+ *
28
+ * @epic T10403
29
+ * @task T11761
30
+ * @task T11897
31
+ */
32
+ import { ExitCode } from '@cleocode/contracts';
33
+ import { CleoError } from '../../errors.js';
34
+ import { getLogger } from '../../logger.js';
35
+ /**
36
+ * Typed containment error for the Pi in-process embed.
37
+ *
38
+ * Extends {@link CleoError} so it flows through the existing LAFS error
39
+ * projection (`toLAFSError`/`toProblemDetails`). It carries the Pi-specific
40
+ * string {@link PiContainmentCode} on {@link piCode} (the numeric `ExitCode`
41
+ * super-field is `INTERNAL`/`GENERAL_ERROR`-class — it is the daemon, not the
42
+ * caller, that is being protected, so the failure is an internal one).
43
+ */
44
+ export class PiContainmentError extends CleoError {
45
+ /** Machine-readable Pi-containment discriminator. */
46
+ piCode;
47
+ /**
48
+ * @param piCode - The Pi-containment discriminator.
49
+ * @param message - Human-readable description.
50
+ * @param options - Optional `cause` and the numeric `ExitCode` (defaults to
51
+ * {@link ExitCode.GENERAL_ERROR}).
52
+ */
53
+ constructor(piCode, message, options) {
54
+ super(options?.exitCode ?? ExitCode.GENERAL_ERROR, message, {
55
+ cause: options?.cause,
56
+ details: { field: 'pi', piCode },
57
+ });
58
+ this.name = 'PiContainmentError';
59
+ this.piCode = piCode;
60
+ }
61
+ }
62
+ /**
63
+ * Type guard for {@link PiContainmentError} (cross-realm-safe via `piCode`).
64
+ *
65
+ * @param err - The value to test.
66
+ * @returns `true` when `err` is a {@link PiContainmentError}.
67
+ */
68
+ export function isPiContainmentError(err) {
69
+ return err instanceof PiContainmentError;
70
+ }
71
+ /**
72
+ * Convert an arbitrary thrown value into a {@link PiContainmentError}.
73
+ *
74
+ * A value that is ALREADY a {@link PiContainmentError} passes through unchanged
75
+ * (so an exit-trap error is not re-wrapped as a generic loop failure). Anything
76
+ * else becomes an `E_PI_LOOP_FAILED` carrying the original as `cause`.
77
+ *
78
+ * @param err - The thrown value.
79
+ * @returns A typed {@link PiContainmentError}.
80
+ */
81
+ export function wrapPiError(err) {
82
+ if (isPiContainmentError(err))
83
+ return err;
84
+ const message = err instanceof Error ? err.message : String(err);
85
+ return new PiContainmentError('E_PI_LOOP_FAILED', `Pi loop failed: ${message}`, { cause: err });
86
+ }
87
+ /**
88
+ * The original `process.exit`, captured at the FIRST trap install and restored
89
+ * only when the ref-count returns to zero. `null` while no trap is installed.
90
+ */
91
+ let originalProcessExit = null;
92
+ /** Number of live {@link wrapPiCall} scopes currently holding the exit trap. */
93
+ let exitTrapRefCount = 0;
94
+ /** Whether the daemon has pinned the trap for its whole lifetime (never released). */
95
+ let daemonExitTrapPinned = false;
96
+ /** The trapped `process.exit` — throws instead of terminating. Built once, reused. */
97
+ const trappedExit = ((code) => {
98
+ throw new PiContainmentError('E_PI_PROCESS_EXIT_TRAPPED', `Pi attempted process.exit(${code ?? ''}) in-process; daemon-fatal exit neutralized`);
99
+ });
100
+ /**
101
+ * Install the process-global `process.exit` trap if it is not already installed.
102
+ * Idempotent — overlapping callers share ONE trap.
103
+ */
104
+ function ensureExitTrapInstalled() {
105
+ if (originalProcessExit === null) {
106
+ originalProcessExit = process.exit;
107
+ process.exit = trappedExit;
108
+ }
109
+ }
110
+ /**
111
+ * Restore the real `process.exit` when (and only when) no scope holds the trap
112
+ * and the daemon has not pinned it. A no-op otherwise.
113
+ */
114
+ function maybeRestoreExitTrap() {
115
+ if (exitTrapRefCount === 0 && !daemonExitTrapPinned && originalProcessExit !== null) {
116
+ process.exit = originalProcessExit;
117
+ originalProcessExit = null;
118
+ }
119
+ }
120
+ /**
121
+ * Pin the `process.exit` trap for the ENTIRE daemon lifetime.
122
+ *
123
+ * This is the durable, complete fix for the async-exit leak: once pinned, the
124
+ * trap is NEVER restored, so a `process.exit()` originating from ANY Pi code path
125
+ * — synchronous, awaited, deferred (`setTimeout`), detached (fire-and-forget),
126
+ * present or future — is neutralized for as long as the daemon runs. Call this
127
+ * once at daemon startup BEFORE any Pi-touching work is dispatched.
128
+ *
129
+ * Idempotent. The returned function un-pins (e.g. for a graceful shutdown that
130
+ * legitimately needs to exit); after un-pinning, the trap is restored when no
131
+ * {@link wrapPiCall} scope is active.
132
+ *
133
+ * @returns A function that un-pins the daemon-lifetime trap.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * // daemon bootstrap, before serving requests:
138
+ * const unpin = installDaemonExitGuard();
139
+ * // ... daemon runs; all Pi exits are trapped for the whole lifetime ...
140
+ * unpin(); // only if a controlled shutdown must reach the real process.exit
141
+ * ```
142
+ */
143
+ export function installDaemonExitGuard() {
144
+ daemonExitTrapPinned = true;
145
+ ensureExitTrapInstalled();
146
+ return releaseDaemonExitGuard;
147
+ }
148
+ /**
149
+ * Un-pin the daemon-lifetime `process.exit` trap (idempotent).
150
+ *
151
+ * Identical to the closure returned by {@link installDaemonExitGuard}, but
152
+ * callable WITHOUT that handle — for code paths that must reach the real
153
+ * `process.exit` yet do not hold the closure (e.g. a daemon bootstrap-failure
154
+ * handler in a different module). After un-pinning, the trap is restored once no
155
+ * {@link wrapPiCall} scope is active. A no-op if the guard was never pinned.
156
+ *
157
+ * Idempotent: safe to call multiple times and from multiple paths.
158
+ */
159
+ export function releaseDaemonExitGuard() {
160
+ daemonExitTrapPinned = false;
161
+ maybeRestoreExitTrap();
162
+ }
163
+ /**
164
+ * Acquire the ref-counted process-exit guard for one wrapped Pi call.
165
+ *
166
+ * Increments the global ref-count and installs the shared `process.exit` trap on
167
+ * the 0→1 transition; snapshots `process.exitCode` for this scope. The trap is
168
+ * released (and, at the last release, restored — unless daemon-pinned) via
169
+ * {@link ProcessExitGuard.release}.
170
+ *
171
+ * `process.exitCode` is, on modern Node, a NON-CONFIGURABLE native accessor — it
172
+ * cannot be redefined to intercept writes. It IS writable via its native setter,
173
+ * so the guard uses **snapshot + synchronous detect-and-restore**
174
+ * ({@link ProcessExitGuard.checkExitCode}).
175
+ *
176
+ * Re-entrant-safe: overlapping calls share the single installed trap; each holds
177
+ * its own `exitCode` snapshot and `release` is an idempotent decrement.
178
+ *
179
+ * @returns A scoped guard handle.
180
+ */
181
+ function acquireExitTrap() {
182
+ // Snapshot the value (NOT the descriptor — the property is non-configurable on
183
+ // modern Node, so we never redefine it; we compare-and-write via its setter).
184
+ const snapshotExitCode = process.exitCode;
185
+ let exitCodeChecked = false;
186
+ let released = false;
187
+ exitTrapRefCount += 1;
188
+ ensureExitTrapInstalled();
189
+ return {
190
+ checkExitCode() {
191
+ if (exitCodeChecked)
192
+ return undefined;
193
+ exitCodeChecked = true;
194
+ const current = process.exitCode;
195
+ if (current !== snapshotExitCode) {
196
+ process.exitCode = snapshotExitCode;
197
+ return { mutatedExitCode: current };
198
+ }
199
+ return undefined;
200
+ },
201
+ release() {
202
+ if (released)
203
+ return;
204
+ released = true;
205
+ exitTrapRefCount -= 1;
206
+ maybeRestoreExitTrap();
207
+ },
208
+ };
209
+ }
210
+ /**
211
+ * Run a Pi-touching async function under process-exit containment + abort
212
+ * routing.
213
+ *
214
+ * Behaviour:
215
+ * - Acquires the REF-COUNTED, process-global {@link acquireExitTrap} for the
216
+ * duration of `fn` and releases it in a `finally`. A `process.exit()` call —
217
+ * synchronous, awaited, OR deferred/detached but firing while ANY Pi call is
218
+ * still active — becomes a thrown {@link PiContainmentError} (the daemon
219
+ * survives). A `process.exitCode` mutation is detected-and-restored the instant
220
+ * `fn` settles, then surfaced as a thrown `E_PI_EXIT_CODE_MUTATION_TRAPPED`.
221
+ * For a guarantee that spans even an exit fired AFTER the last call settles,
222
+ * the daemon should additionally pin the trap once at startup via
223
+ * {@link installDaemonExitGuard}.
224
+ * - If `signal` is already aborted, rejects with `E_PI_ABORTED` WITHOUT invoking
225
+ * `fn`. Otherwise the signal is propagated to `fn` (the caller threads it into
226
+ * Pi's agent loop); an abort that surfaces as a thrown `AbortError`/`DOMException`
227
+ * is normalized to `E_PI_ABORTED`.
228
+ * - Any other thrown value is normalized via {@link wrapPiError}.
229
+ *
230
+ * @typeParam T - The resolved value type of the wrapped call.
231
+ * @param fn - The Pi-touching async function. Receives the (live) `AbortSignal`
232
+ * so it can thread cancellation into the agent loop.
233
+ * @param signal - Optional cancellation signal.
234
+ * @returns The resolved value of `fn`.
235
+ * @throws {PiContainmentError} On exit-trap, abort, or any failure from `fn`.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * const result = await wrapPiCall(async (sig) => runAgentLoop(prompts, ctx, cfg, emit, sig), signal);
240
+ * ```
241
+ */
242
+ export async function wrapPiCall(fn, signal) {
243
+ if (signal?.aborted) {
244
+ throw new PiContainmentError('E_PI_ABORTED', 'Pi call aborted before start');
245
+ }
246
+ // A local controller is always passed to `fn` so cancellation has a single
247
+ // shape; when an external signal is supplied we mirror its abort into ours.
248
+ const controller = new AbortController();
249
+ const onExternalAbort = () => controller.abort(signal?.reason);
250
+ if (signal)
251
+ signal.addEventListener('abort', onExternalAbort, { once: true });
252
+ const guard = acquireExitTrap();
253
+ try {
254
+ const value = await fn(controller.signal);
255
+ // Detect a quiet `process.exitCode` mutation SYNCHRONOUSLY here — the instant
256
+ // `fn` settled — while the value is still observable. If Pi set it, the value
257
+ // is restored and a typed error replaces the clean return.
258
+ const mutation = guard.checkExitCode();
259
+ if (mutation !== undefined) {
260
+ throw new PiContainmentError('E_PI_EXIT_CODE_MUTATION_TRAPPED', `Pi set process.exitCode=${String(mutation.mutatedExitCode)} in-process; neutralized`);
261
+ }
262
+ return value;
263
+ }
264
+ catch (err) {
265
+ // A mutation can also accompany a thrown failure — neutralize the leak even
266
+ // though the thrown error (below) is the primary signal.
267
+ guard.checkExitCode();
268
+ if (err instanceof PiContainmentError)
269
+ throw err;
270
+ if (isAbortError(err) || controller.signal.aborted) {
271
+ throw new PiContainmentError('E_PI_ABORTED', 'Pi call aborted', { cause: err });
272
+ }
273
+ throw wrapPiError(err);
274
+ }
275
+ finally {
276
+ guard.release();
277
+ if (signal)
278
+ signal.removeEventListener('abort', onExternalAbort);
279
+ // Lazy logger — never resolved at import time (S1 import-side-effect rule).
280
+ getLogger('pi-errors').debug({ aborted: controller.signal.aborted }, 'pi call boundary closed');
281
+ }
282
+ }
283
+ /**
284
+ * Whether a thrown value represents an abort (a `DOMException`/`Error` whose
285
+ * `name` is `AbortError`).
286
+ *
287
+ * @param err - The thrown value.
288
+ * @returns `true` when `err` is an abort error.
289
+ */
290
+ function isAbortError(err) {
291
+ return (typeof err === 'object' &&
292
+ err !== null &&
293
+ 'name' in err &&
294
+ err.name === 'AbortError');
295
+ }
296
+ //# sourceMappingURL=pi-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-errors.js","sourceRoot":"","sources":["../../../src/llm/pi/pi-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoB5C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,qDAAqD;IAC5C,MAAM,CAAoB;IAEnC;;;;;OAKG;IACH,YACE,MAAyB,EACzB,OAAe,EACf,OAAkD;QAElD,KAAK,CAAC,O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D,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACnD,MAAM,IAAI,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,MAAM;YAAE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QACjE,4EAA4E;QAC5E,SAAS,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,yBAAyB,CAAC,CAAC;IAClG,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,GAAY;IAChC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,MAAM,IAAI,GAAG;QACZ,GAA0B,CAAC,IAAI,KAAK,YAAY,CAClD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Guarded Pi `ExecutionEnv` (T11761 · S1 · T11897).
3
+ *
4
+ * Pi's agent loop performs ALL filesystem + shell work through a single
5
+ * pluggable seam: `ExecutionEnv extends FileSystem, Shell`. This module supplies
6
+ * Cleo's implementation of that seam — {@link GuardedExecutionEnv} — which routes
7
+ * every operation through the deny-first {@link ToolGuard} chokepoint and an
8
+ * injected **workspace boundary**, so Pi can touch nothing outside the
9
+ * allowlisted roots and runs no command on the denylist.
10
+ *
11
+ * Two layers of confinement (deny-first):
12
+ * 1. **Workspace boundary** — every fs path is canonicalized with SYMLINK
13
+ * RESOLUTION (`fs.realpath` on the nearest existing ancestor) and the REAL
14
+ * target MUST fall under the injected `workspaceRoot`; a `../` escape, an
15
+ * out-of-root absolute path, OR a symlink (file or parent dir) whose real
16
+ * target leaves the root is rejected as a Pi `Result.err(FileError)` BEFORE
17
+ * the guard is consulted. A purely lexical check is symlink-blind, so the
18
+ * boundary resolves symlinks first. (The guard's own `allowedRoots` is a
19
+ * second, ALSO-symlink-resolving net.)
20
+ * 2. **ToolGuard** — the allowed operations delegate to the `ToolGuard` surface
21
+ * (`readFileText`/`writeFileAtomic`/`pathExists`/`executeShell`/`runGit`),
22
+ * which applies the project's symlink-resolved path allowlist + shell
23
+ * denylist + subprocess-env scrub. A `GuardDeniedError` from enforce-mode is
24
+ * CAUGHT and converted to a Pi `Result.err` — Pi's `FileSystem`/`Shell` ops
25
+ * must NEVER throw. The guard MUST be constructed in `enforce` mode (the
26
+ * factory asserts it) — in `warn` mode its allowlist/denylist are advisory
27
+ * and confinement would collapse to the workspace boundary alone.
28
+ *
29
+ * Every other capability (binary reads, raw temp/dir mutation, listing, …) for
30
+ * which there is no atomic primitive in v0 is DENIED with a typed error rather
31
+ * than reaching the real filesystem. The structural Pi interfaces are declared
32
+ * locally here (the `@earendil-works/pi-agent-core` package is not yet a
33
+ * dependency); S2 replaces these with the real type-only imports — the shapes
34
+ * match `@earendil-works/pi-agent-core@0.78.1` `harness/types.ts:268-332`.
35
+ *
36
+ * Scope discipline (S1): NO `pi-ai`/`pi-agent-core` imports, NO DB access, NO
37
+ * LLM calls. Import-time side-effect free.
38
+ *
39
+ * @epic T10403
40
+ * @task T11761
41
+ * @task T11897
42
+ */
43
+ import { type GuardMode, type ToolGuard } from '../../tools/guard.js';
44
+ /**
45
+ * Pi's `Result<T, E>` discriminated union. Pi's `FileSystem`/`Shell` ops return
46
+ * this and MUST never throw — failures are encoded as `{ ok: false, error }`.
47
+ *
48
+ * Matches `@earendil-works/pi-agent-core@0.78.1` result shape.
49
+ */
50
+ export type PiResult<T, E> = {
51
+ readonly ok: true;
52
+ readonly value: T;
53
+ } | {
54
+ readonly ok: false;
55
+ readonly error: E;
56
+ };
57
+ /** A filesystem failure surfaced to Pi (never thrown). */
58
+ export interface PiFileError {
59
+ /** Stable failure kind. */
60
+ readonly code: string;
61
+ /** Human-readable description. */
62
+ readonly message: string;
63
+ /** The path the operation targeted, when applicable. */
64
+ readonly path?: string;
65
+ }
66
+ /** A shell-execution failure surfaced to Pi (never thrown). */
67
+ export interface PiExecutionError {
68
+ /** Stable failure kind. */
69
+ readonly code: string;
70
+ /** Human-readable description. */
71
+ readonly message: string;
72
+ }
73
+ /** Metadata returned by `fileInfo`. */
74
+ export interface PiFileInfo {
75
+ /** Whether the entry is a regular file. */
76
+ readonly isFile: boolean;
77
+ /** Whether the entry is a directory. */
78
+ readonly isDirectory: boolean;
79
+ }
80
+ /** Result of a `Shell.exec`. */
81
+ export interface PiExecResult {
82
+ /** Captured standard output. */
83
+ readonly stdout: string;
84
+ /** Captured standard error. */
85
+ readonly stderr: string;
86
+ /** Process exit code (`null` when killed by signal/timeout). */
87
+ readonly exitCode: number | null;
88
+ }
89
+ /** Options for a `Shell.exec`. */
90
+ export interface PiExecOptions {
91
+ /** Working directory. */
92
+ readonly cwd?: string;
93
+ /** Hard timeout in milliseconds. */
94
+ readonly timeout?: number;
95
+ /** Extra environment variables. */
96
+ readonly env?: Readonly<Record<string, string>>;
97
+ }
98
+ /**
99
+ * Pi's `FileSystem` interface (the fs half of `ExecutionEnv`). Every op returns
100
+ * a {@link PiResult} and must never throw. Mirrors
101
+ * `@earendil-works/pi-agent-core@0.78.1` `harness/types.ts:268-318`.
102
+ */
103
+ export interface PiFileSystem {
104
+ cwd(): string;
105
+ absolutePath(path: string): string;
106
+ joinPath(...segments: string[]): string;
107
+ readTextFile(path: string): Promise<PiResult<string, PiFileError>>;
108
+ readTextLines(path: string): Promise<PiResult<string[], PiFileError>>;
109
+ readBinaryFile(path: string): Promise<PiResult<Uint8Array, PiFileError>>;
110
+ writeFile(path: string, content: string): Promise<PiResult<void, PiFileError>>;
111
+ appendFile(path: string, content: string): Promise<PiResult<void, PiFileError>>;
112
+ fileInfo(path: string): Promise<PiResult<PiFileInfo, PiFileError>>;
113
+ listDir(path: string): Promise<PiResult<string[], PiFileError>>;
114
+ canonicalPath(path: string): Promise<PiResult<string, PiFileError>>;
115
+ exists(path: string): Promise<PiResult<boolean, PiFileError>>;
116
+ createDir(path: string): Promise<PiResult<void, PiFileError>>;
117
+ remove(path: string): Promise<PiResult<void, PiFileError>>;
118
+ createTempDir(prefix?: string): Promise<PiResult<string, PiFileError>>;
119
+ createTempFile(prefix?: string): Promise<PiResult<string, PiFileError>>;
120
+ cleanup(): Promise<void>;
121
+ }
122
+ /**
123
+ * Pi's `Shell` interface (the shell half of `ExecutionEnv`). Mirrors
124
+ * `@earendil-works/pi-agent-core@0.78.1` `harness/types.ts:321-328`.
125
+ */
126
+ export interface PiShell {
127
+ exec(command: string, options?: PiExecOptions): Promise<PiResult<PiExecResult, PiExecutionError>>;
128
+ cleanup(): Promise<void>;
129
+ }
130
+ /**
131
+ * Pi's `ExecutionEnv` — the single pluggable surface for all fs + process work.
132
+ * Mirrors `@earendil-works/pi-agent-core@0.78.1` `harness/types.ts:332`.
133
+ */
134
+ export interface PiExecutionEnv extends PiFileSystem, PiShell {
135
+ }
136
+ /** Construction dependencies for {@link GuardedExecutionEnv}. */
137
+ export interface GuardedExecutionEnvDeps {
138
+ /**
139
+ * The guarded primitive surface (path allowlist + shell denylist) the env
140
+ * delegates allowed operations to. Injected by the dispatcher — the env never
141
+ * constructs it (atomic primitives are Gate-11-bound to `core/src/tools`).
142
+ */
143
+ readonly guard: ToolGuard;
144
+ /**
145
+ * The absolute workspace root every fs path is confined under. A path that
146
+ * resolves outside this root is denied BEFORE the guard is consulted.
147
+ */
148
+ readonly workspaceRoot: string;
149
+ }
150
+ /**
151
+ * Deny-first {@link PiExecutionEnv} backed by the Cleo {@link ToolGuard} surface
152
+ * and a workspace boundary.
153
+ *
154
+ * - File reads/writes/existence checks route through the guard's atomic
155
+ * primitives, confined to `workspaceRoot`.
156
+ * - `exec` routes through the guard's `executeShell` (shell denylist applies).
157
+ * - Capabilities with no atomic primitive in v0 (binary read, `listDir`,
158
+ * `createDir`, `remove`, temp dir/file) are DENIED with a typed
159
+ * `Result.err` — they never reach the real filesystem.
160
+ * - Pure path arithmetic (`cwd`/`absolutePath`/`joinPath`) is computed locally
161
+ * (no fs access), anchored to `workspaceRoot`.
162
+ *
163
+ * Every method honours the Pi contract: it returns a {@link PiResult} and never
164
+ * throws — a {@link GuardDeniedError} from the guard is caught and converted.
165
+ */
166
+ export declare class GuardedExecutionEnv implements PiExecutionEnv {
167
+ #private;
168
+ /**
169
+ * @param deps - The guard surface + the workspace root to confine to.
170
+ */
171
+ constructor(deps: GuardedExecutionEnvDeps);
172
+ /** The workspace root (the in-process Pi run's working directory). */
173
+ cwd(): string;
174
+ /** Resolve `path` to an absolute path anchored at the workspace root. */
175
+ absolutePath(path: string): string;
176
+ /** Join path segments (pure). */
177
+ joinPath(...segments: string[]): string;
178
+ /** Read a file's text, confined to the workspace + guarded. */
179
+ readTextFile(path: string): Promise<PiResult<string, PiFileError>>;
180
+ /** Read a file's text as an array of lines. */
181
+ readTextLines(path: string): Promise<PiResult<string[], PiFileError>>;
182
+ /**
183
+ * Binary read — DENIED in v0. The atomic `readFileText` primitive is
184
+ * text-only (`ReadFileInput.encoding` has no binary variant); a binary
185
+ * primitive must be added under `core/src/tools` (Gate 11) before this is
186
+ * supported. Deny-first: never reaches the filesystem.
187
+ */
188
+ readBinaryFile(path: string): Promise<PiResult<Uint8Array, PiFileError>>;
189
+ /** Atomically write a file, confined to the workspace + guarded. */
190
+ writeFile(path: string, content: string): Promise<PiResult<void, PiFileError>>;
191
+ /**
192
+ * Append to a file. The atomic surface offers only whole-file atomic writes,
193
+ * so this reads-then-writes the concatenation (still confined + guarded). A
194
+ * missing file is treated as empty.
195
+ *
196
+ * Confinement happens EXACTLY ONCE here, then the read + write delegate
197
+ * straight to the guard with the already-resolved `abs`. Re-entering the
198
+ * public `readTextFile`/`writeFile` would re-`#confine` the value `#confine`
199
+ * just returned — and because `#confine` yields the SYMLINK-RESOLVED real path
200
+ * (e.g. macOS `/tmp`→`/private/tmp`, or a symlinked workspace root), that real
201
+ * path is `../`-outside the lexical `workspaceRoot`, so the second lexical
202
+ * gate would spuriously reject it (`E_PI_FS_DENIED`). Reading once through the
203
+ * guard — whose own allowlist canonicalizes both sides — avoids the
204
+ * double-confine while keeping the symlink-escape denial intact.
205
+ */
206
+ appendFile(path: string, content: string): Promise<PiResult<void, PiFileError>>;
207
+ /** Report whether a path is a file or directory, confined + guarded. */
208
+ fileInfo(path: string): Promise<PiResult<PiFileInfo, PiFileError>>;
209
+ /** Whether a path exists, confined + guarded. */
210
+ exists(path: string): Promise<PiResult<boolean, PiFileError>>;
211
+ /**
212
+ * Canonicalize a path inside the workspace. SYMLINK-RESOLVING: `#confine`
213
+ * follows every symlink component via `fs.realpath`, so the returned value is
214
+ * the REAL on-disk location (matching Pi's `NodeExecutionEnv.canonicalPath`
215
+ * contract), and a path whose real target escapes the workspace is denied.
216
+ */
217
+ canonicalPath(path: string): Promise<PiResult<string, PiFileError>>;
218
+ /** DENIED in v0 — no `listDir` atomic primitive. */
219
+ listDir(path: string): Promise<PiResult<string[], PiFileError>>;
220
+ /** DENIED in v0 — no `createDir` atomic primitive. */
221
+ createDir(path: string): Promise<PiResult<void, PiFileError>>;
222
+ /** DENIED in v0 — no `remove` atomic primitive. */
223
+ remove(path: string): Promise<PiResult<void, PiFileError>>;
224
+ /** DENIED in v0 — no temp-dir atomic primitive. */
225
+ createTempDir(): Promise<PiResult<string, PiFileError>>;
226
+ /** DENIED in v0 — no temp-file atomic primitive. */
227
+ createTempFile(): Promise<PiResult<string, PiFileError>>;
228
+ /**
229
+ * Execute a command through the guard's shell surface (denylist applies). The
230
+ * Pi `command` string is a bare executable name (args are passed by Pi via the
231
+ * loop, but the v0 seam takes only `command`); we forward it as the guard's
232
+ * `command` with empty args. `cwd` is symlink-confined to the workspace.
233
+ *
234
+ * ## Env is SCRUBBED before it leaves this seam (T11897 · security)
235
+ *
236
+ * Pi's `options.env` is UNTRUSTED model-driven input. Forwarding it verbatim
237
+ * would let Pi set `LD_PRELOAD`/`NODE_OPTIONS`/`GIT_SSH_COMMAND` (arbitrary
238
+ * native code execution outside any allowlist) or hijack `PATH` to make a
239
+ * workspace-resident impostor satisfy an allowed command basename. So the env
240
+ * is run through {@link scrubSubprocessEnv} HERE — forbidden keys (loader
241
+ * hooks, `PATH`, secrets) are dropped and `PATH` is pinned to a trusted value
242
+ * — before it reaches the guard (which scrubs again as a redundant net, as
243
+ * does `defaultShellExecutor`). This also prevents the daemon's own secrets
244
+ * from leaking into the child (the scrubbed env never inherits `process.env`).
245
+ */
246
+ exec(command: string, options?: PiExecOptions): Promise<PiResult<PiExecResult, PiExecutionError>>;
247
+ /** Best-effort cleanup; the guarded surface owns no resources, so a no-op. */
248
+ cleanup(): Promise<void>;
249
+ }
250
+ /**
251
+ * Thrown by {@link createGuardedExecutionEnv} when the injected guard is NOT in
252
+ * `enforce` mode. In `warn` mode the guard's path allowlist + command denylist
253
+ * are advisory (log-and-proceed), so the second confinement net does not exist
254
+ * and the boundary would collapse to the workspace check alone. The Pi adapter
255
+ * therefore REFUSES a non-enforce guard rather than running untrusted Pi work
256
+ * behind an advisory boundary.
257
+ */
258
+ export declare class PiGuardModeError extends Error {
259
+ /** Machine-readable code. */
260
+ readonly code = "E_PI_GUARD_NOT_ENFORCING";
261
+ /**
262
+ * @param mode - The (non-enforce) mode the guard was constructed with.
263
+ */
264
+ constructor(mode: GuardMode);
265
+ }
266
+ /**
267
+ * Construct a deny-first {@link GuardedExecutionEnv}.
268
+ *
269
+ * REQUIRES an `enforce`-mode guard: a `warn`-mode guard's allowlist/denylist are
270
+ * advisory, so handing untrusted Pi work behind one would leave confinement to
271
+ * the workspace boundary alone. The factory ASSERTS the mode and throws
272
+ * {@link PiGuardModeError} otherwise — the Pi adapter never silently degrades to
273
+ * an advisory boundary.
274
+ *
275
+ * @param deps - The guard surface + the workspace root to confine to.
276
+ * @returns A {@link PiExecutionEnv} safe to hand to Pi's agent loop.
277
+ * @throws {PiGuardModeError} When `deps.guard.mode !== 'enforce'`.
278
+ *
279
+ * @example
280
+ * ```ts
281
+ * const guard = createToolGuard({ allowedRoots: [projectRoot], mode: 'enforce' });
282
+ * const env = createGuardedExecutionEnv({ guard, workspaceRoot: projectRoot });
283
+ * ```
284
+ */
285
+ export declare function createGuardedExecutionEnv(deps: GuardedExecutionEnvDeps): PiExecutionEnv;
286
+ //# sourceMappingURL=pi-execution-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-execution-env.d.ts","sourceRoot":"","sources":["../../../src/llm/pi/pi-execution-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMxF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB,CAAC;AAEN,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,C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