@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,241 @@
1
+ /**
2
+ * Gondolin micro-VM sandbox — the OPTIONAL, lazily-loaded execution backend
3
+ * (T11908 · T11888-A · P5 Gondolin · epic T11599).
4
+ *
5
+ * The {@link import('./pi-execution-env.js').PiExecutionEnv} seam gains a SECOND
6
+ * implementation (`GondolinExecutionEnv`, T11888-B) whose confinement is a real
7
+ * micro-VM boundary instead of the in-process deny-first guard. The VM backend is
8
+ * powered by `@earendil-works/gondolin`, which is an OPTIONAL dependency
9
+ * (dependency-discipline · D11142): it is NEVER a hard dependency of
10
+ * `@cleocode/core`. Exactly like `playwright` (see {@link ../../tools/browser-driver.js})
11
+ * and `node-pty` (see {@link ../../tools/pty.js}), it is deliberately NOT declared
12
+ * in `core`'s `dependencies` / `optionalDependencies` and is loaded ONLY via a
13
+ * dynamic `import()` whose specifier is held in a variable — so neither the
14
+ * bundler nor TS treats the missing package as a hard, statically-resolved
15
+ * dependency, the published `@cleocode/core` carries no Gondolin / QEMU weight,
16
+ * and `core` builds + non-sandbox tests pass with Gondolin NOT installed.
17
+ *
18
+ * An environment that wants the sandbox opts in by installing the package itself
19
+ * (`pnpm add @earendil-works/gondolin`) AND providing the host infra (QEMU +
20
+ * `/dev/kvm`). Availability is the AND of all three — package present, `/dev/kvm`
21
+ * present, and a working `qemu-system-x86_64` — so a box with the package but no
22
+ * KVM still reports UNAVAILABLE and the selector ({@link ./resolve-execution-env.js},
23
+ * T11888-C) silently degrades to the in-process `GuardedExecutionEnv` rather than
24
+ * erroring.
25
+ *
26
+ * Import-time side-effect-free: NO top-level `@earendil-works/gondolin` import; the
27
+ * VM is booted lazily on the first `resolveExecutionEnv`. When Gondolin is absent,
28
+ * {@link loadGondolin} resolves `null` and {@link isGondolinAvailable} resolves
29
+ * `false` — nothing throws at import.
30
+ *
31
+ * The structural shapes of the consumed Gondolin surface are declared LOCALLY in
32
+ * this file (`VM`, `VMOptions`, `VmFs`, `ExecResult`, `RealFSProvider`,
33
+ * `createHttpHooks`); there is NO `import type` from the optional package, so the
34
+ * type-check passes with the package uninstalled.
35
+ *
36
+ * @epic T11599
37
+ * @task T11908
38
+ * @see ../../tools/browser-driver.js — the analogous optional-dep (Playwright) lazy-load pattern
39
+ * @see ./pi-execution-env.js — the `PiExecutionEnv` seam this backend implements
40
+ */
41
+ /**
42
+ * The npm install hint surfaced to the model / caller when the sandbox backend is
43
+ * unavailable because `@earendil-works/gondolin` (or its QEMU/KVM host infra) is
44
+ * not present. Gondolin is an OPTIONAL dep — the selector degrades to the
45
+ * in-process `GuardedExecutionEnv` regardless, but reports the sandbox
46
+ * UNAVAILABLE until this is satisfied.
47
+ */
48
+ export declare const GONDOLIN_INSTALL_HINT: string;
49
+ /**
50
+ * A buffered result of `vm.exec` (gondolin `exec.d.ts` `ExecResult`).
51
+ *
52
+ * `exitCode` is NON-nullable here (a `number`); a SEPARATE optional `signal`
53
+ * field is set when the process was killed by a signal. The Pi adapter
54
+ * (T11888-B) maps this to Pi's `exitCode: number | null` by emitting `null`
55
+ * whenever `signal` is present.
56
+ */
57
+ export interface ExecResult {
58
+ /** Captured standard output. */
59
+ readonly stdout: string;
60
+ /** Captured standard error. */
61
+ readonly stderr: string;
62
+ /** Process exit code (always a number; `signal` distinguishes signal-kills). */
63
+ readonly exitCode: number;
64
+ /** The terminating signal number, when the process was killed by a signal. */
65
+ readonly signal?: number;
66
+ }
67
+ /** Options for a single `vm.exec` invocation. */
68
+ export interface ExecOptions {
69
+ /** Working directory inside the guest. */
70
+ readonly cwd?: string;
71
+ /** Extra guest environment variables. */
72
+ readonly env?: Readonly<Record<string, string>>;
73
+ /** Host abort signal — cancels the in-flight guest process. */
74
+ readonly signal?: AbortSignal;
75
+ /** Hard timeout in milliseconds. */
76
+ readonly timeout?: number;
77
+ }
78
+ /** Metadata returned by `vm.fs.stat`. */
79
+ export interface VmStat {
80
+ /** Whether the entry is a regular file. */
81
+ isFile(): boolean;
82
+ /** Whether the entry is a directory. */
83
+ isDirectory(): boolean;
84
+ }
85
+ /**
86
+ * The guest filesystem surface (`vm.fs`). Only the members the sandbox backend
87
+ * consumes are modelled. All paths are guest-absolute under the single
88
+ * `/workspace` RW mount.
89
+ */
90
+ export interface VmFs {
91
+ readFile(path: string, options: {
92
+ readonly encoding: 'utf-8';
93
+ }): Promise<string>;
94
+ readFile(path: string): Promise<Uint8Array>;
95
+ writeFile(path: string, content: string): Promise<void>;
96
+ stat(path: string): Promise<VmStat>;
97
+ listDir(path: string): Promise<string[]>;
98
+ access(path: string): Promise<void>;
99
+ mkdir(path: string, options: {
100
+ readonly recursive: boolean;
101
+ }): Promise<void>;
102
+ deleteFile(path: string, options: {
103
+ readonly recursive: boolean;
104
+ readonly force: boolean;
105
+ }): Promise<void>;
106
+ }
107
+ /**
108
+ * A running micro-VM handle (gondolin `vm.d.ts` `VM`). The sandbox backend owns
109
+ * exactly one of these per run and releases it in `cleanup()` via `close()`.
110
+ */
111
+ export interface VM {
112
+ /** The guest filesystem surface. */
113
+ readonly fs: VmFs;
114
+ /**
115
+ * Run a command in the guest. STRING form runs via `/bin/sh -lc`; ARRAY form
116
+ * runs the argv directly with no `$PATH` / shell expansion. The returned value
117
+ * `implements PromiseLike<ExecResult>`, so `await vm.exec(...)` resolves the
118
+ * buffered result.
119
+ */
120
+ exec(command: string | readonly string[], options?: ExecOptions): PromiseLike<ExecResult>;
121
+ /** Tear down the VM and release its host resources (idempotent host-side guard recommended). */
122
+ close(): Promise<void>;
123
+ }
124
+ /**
125
+ * A single readable+writable secret the egress proxy injects HOST-side. The guest
126
+ * only ever sees `placeholder` — never the real `value` bytes.
127
+ */
128
+ export interface SecretDefinition {
129
+ /** Hosts the secret may be sent to. */
130
+ readonly hosts: readonly string[];
131
+ /** The real secret bytes — injected host-side, NEVER visible to the guest. */
132
+ readonly value: string;
133
+ /** The opaque token the guest sees in place of `value`. */
134
+ readonly placeholder: string;
135
+ }
136
+ /**
137
+ * Options for {@link CreateHttpHooks}. Per the gondolin docs, `allowedHosts`
138
+ * OMITTED = allow-all; `allowedHosts: []` (present-and-empty) = deny-all. The
139
+ * backend MUST pass it present-and-empty by default (the egress-deny footgun).
140
+ */
141
+ export interface CreateHttpHooksOptions {
142
+ /** Outbound host allowlist. Present-and-empty `[]` = deny all; omitted = allow all. */
143
+ readonly allowedHosts: readonly string[];
144
+ /** Host-side secret injection (guest sees only `placeholder`). */
145
+ readonly secrets?: Readonly<Record<string, SecretDefinition>>;
146
+ }
147
+ /** Opaque HTTP-hook handle wired into a VM's network namespace via {@link VMOptions}. */
148
+ export interface HttpHooks {
149
+ readonly __httpHooks: true;
150
+ }
151
+ /** The `createHttpHooks` factory — allowlists egress + injects credential placeholders. */
152
+ export type CreateHttpHooks = (options: CreateHttpHooksOptions) => HttpHooks;
153
+ /**
154
+ * A read/write filesystem provider rooted at a host directory, mounted into the
155
+ * guest VFS (gondolin `fs/real.d.ts` `RealFSProvider`). The sandbox backend
156
+ * mounts ONLY a disposable seeded-copy directory at `/workspace`; live
157
+ * `tasks.db`/`brain.db` are NEVER in the mount set.
158
+ */
159
+ export interface RealFSProviderInstance {
160
+ readonly __realFsProvider: true;
161
+ }
162
+ /** The `RealFSProvider` constructor surface. */
163
+ export interface RealFSProvider {
164
+ new (hostRootDir: string): RealFSProviderInstance;
165
+ }
166
+ /**
167
+ * Options for {@link VMConstructor.create}. The guest's environment is ONLY
168
+ * `env` (host `process.env` is NEVER inherited — that isolation is structural);
169
+ * `memory` bounds the guest in-process (default `"1G"`, set explicitly).
170
+ */
171
+ export interface VMOptions {
172
+ /** Guest memory bound (e.g. `"1G"`). Set explicitly — never rely on the default. */
173
+ readonly memory?: string;
174
+ /** Guest environment — the ONLY env the guest sees (no host `process.env` inheritance). */
175
+ readonly env?: Readonly<Record<string, string>>;
176
+ /** VFS mount set — guest path → host FS provider. Live DBs never appear here. */
177
+ readonly vfs?: {
178
+ readonly mounts: Readonly<Record<string, RealFSProviderInstance>>;
179
+ };
180
+ /** Network egress hooks (allowlist + credential injection). */
181
+ readonly httpHooks?: HttpHooks;
182
+ }
183
+ /** The `VM` constructor / factory surface (`VM.create`). */
184
+ export interface VMConstructor {
185
+ create(options?: VMOptions): Promise<VM>;
186
+ }
187
+ /**
188
+ * The minimal shape of the `@earendil-works/gondolin` module we depend on. Only
189
+ * the three named exports the sandbox backend consumes are modelled.
190
+ */
191
+ export interface GondolinModule {
192
+ readonly VM: VMConstructor;
193
+ readonly RealFSProvider: RealFSProvider;
194
+ readonly createHttpHooks: CreateHttpHooks;
195
+ }
196
+ /** A pluggable dynamic-importer (test seam). Defaults to the real `import()`. */
197
+ type DynamicImporter = (specifier: string) => Promise<unknown>;
198
+ /**
199
+ * Attempt to lazily load `@earendil-works/gondolin`. Returns `null` when the
200
+ * optional dep is not installed, fails to load, OR does not expose the expected
201
+ * `VM` / `RealFSProvider` / `createHttpHooks` surface — so callers can report the
202
+ * sandbox unavailable rather than crashing. NEVER throws.
203
+ *
204
+ * The import specifier is held in a variable (passed to the {@link importer}
205
+ * seam) so bundlers / TS do not treat the missing optional dep as a hard,
206
+ * statically-resolved dependency (same technique as
207
+ * {@link ../../tools/browser-driver.js}'s Playwright load).
208
+ *
209
+ * @returns The shape-checked module, or `null` when unavailable.
210
+ */
211
+ export declare function loadGondolin(): Promise<GondolinModule | null>;
212
+ export declare function isGondolinAvailable(): Promise<boolean>;
213
+ /**
214
+ * Reset the cached Gondolin-availability probe.
215
+ *
216
+ * EXPORTED FOR TESTS ONLY — lets a unit test toggle the mocked availability of
217
+ * the optional dep + host probes between cases without a fresh module graph.
218
+ *
219
+ * @internal
220
+ */
221
+ export declare function __resetGondolinAvailabilityCache(): void;
222
+ /**
223
+ * Override the dynamic-importer and/or host probes, and reset the availability
224
+ * cache.
225
+ *
226
+ * EXPORTED FOR TESTS ONLY — lets a unit test simulate "package absent" (importer
227
+ * rejects), "package present" (importer resolves a mock module), and "no
228
+ * `/dev/kvm`" / "no QEMU" deterministically, WITHOUT touching the module graph or
229
+ * launching a real QEMU VM. Pass `undefined` for a field to leave it at the real
230
+ * default; call with no arguments to restore the real importer + probes.
231
+ *
232
+ * @param hooks - Partial overrides for the importer and host probes.
233
+ * @internal
234
+ */
235
+ export declare function __setGondolinTestHooks(hooks?: {
236
+ importer?: DynamicImporter;
237
+ hasKvm?: () => boolean;
238
+ hasQemu?: () => boolean;
239
+ }): void;
240
+ export {};
241
+ //# sourceMappingURL=gondolin-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gondolin-loader.d.ts","sourceRoot":"","sources":["../../../src/llm/pi/gondol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CAC3C;AAYD,iFAAiF;AACjF,KAAK,eAAe,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAqE/D;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CASnE;AAmBD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAK5D;AAED;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,EAAE;IAC7C,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;CACzB,GAAG,IAAI,CAOP"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Gondolin micro-VM sandbox — the OPTIONAL, lazily-loaded execution backend
3
+ * (T11908 · T11888-A · P5 Gondolin · epic T11599).
4
+ *
5
+ * The {@link import('./pi-execution-env.js').PiExecutionEnv} seam gains a SECOND
6
+ * implementation (`GondolinExecutionEnv`, T11888-B) whose confinement is a real
7
+ * micro-VM boundary instead of the in-process deny-first guard. The VM backend is
8
+ * powered by `@earendil-works/gondolin`, which is an OPTIONAL dependency
9
+ * (dependency-discipline · D11142): it is NEVER a hard dependency of
10
+ * `@cleocode/core`. Exactly like `playwright` (see {@link ../../tools/browser-driver.js})
11
+ * and `node-pty` (see {@link ../../tools/pty.js}), it is deliberately NOT declared
12
+ * in `core`'s `dependencies` / `optionalDependencies` and is loaded ONLY via a
13
+ * dynamic `import()` whose specifier is held in a variable — so neither the
14
+ * bundler nor TS treats the missing package as a hard, statically-resolved
15
+ * dependency, the published `@cleocode/core` carries no Gondolin / QEMU weight,
16
+ * and `core` builds + non-sandbox tests pass with Gondolin NOT installed.
17
+ *
18
+ * An environment that wants the sandbox opts in by installing the package itself
19
+ * (`pnpm add @earendil-works/gondolin`) AND providing the host infra (QEMU +
20
+ * `/dev/kvm`). Availability is the AND of all three — package present, `/dev/kvm`
21
+ * present, and a working `qemu-system-x86_64` — so a box with the package but no
22
+ * KVM still reports UNAVAILABLE and the selector ({@link ./resolve-execution-env.js},
23
+ * T11888-C) silently degrades to the in-process `GuardedExecutionEnv` rather than
24
+ * erroring.
25
+ *
26
+ * Import-time side-effect-free: NO top-level `@earendil-works/gondolin` import; the
27
+ * VM is booted lazily on the first `resolveExecutionEnv`. When Gondolin is absent,
28
+ * {@link loadGondolin} resolves `null` and {@link isGondolinAvailable} resolves
29
+ * `false` — nothing throws at import.
30
+ *
31
+ * The structural shapes of the consumed Gondolin surface are declared LOCALLY in
32
+ * this file (`VM`, `VMOptions`, `VmFs`, `ExecResult`, `RealFSProvider`,
33
+ * `createHttpHooks`); there is NO `import type` from the optional package, so the
34
+ * type-check passes with the package uninstalled.
35
+ *
36
+ * @epic T11599
37
+ * @task T11908
38
+ * @see ../../tools/browser-driver.js — the analogous optional-dep (Playwright) lazy-load pattern
39
+ * @see ./pi-execution-env.js — the `PiExecutionEnv` seam this backend implements
40
+ */
41
+ import { execFileSync } from 'node:child_process';
42
+ import { existsSync } from 'node:fs';
43
+ import { getLogger } from '../../logger.js';
44
+ const log = getLogger('pi-gondolin');
45
+ /**
46
+ * The npm install hint surfaced to the model / caller when the sandbox backend is
47
+ * unavailable because `@earendil-works/gondolin` (or its QEMU/KVM host infra) is
48
+ * not present. Gondolin is an OPTIONAL dep — the selector degrades to the
49
+ * in-process `GuardedExecutionEnv` regardless, but reports the sandbox
50
+ * UNAVAILABLE until this is satisfied.
51
+ */
52
+ export const GONDOLIN_INSTALL_HINT = 'Sandbox execution requires the optional "@earendil-works/gondolin" package + QEMU/KVM. ' +
53
+ 'Install with `pnpm add @earendil-works/gondolin` (boots a ~200MB Alpine guest on first run), ' +
54
+ 'and ensure `/dev/kvm` plus a working `qemu-system-x86_64` are available on the host.';
55
+ // ---------------------------------------------------------------------------
56
+ // Injectable seams — overridable ONLY by the unit tests so a mocked import() /
57
+ // host probe can deterministically simulate "package absent" and "no /dev/kvm"
58
+ // WITHOUT touching the module graph or launching a real QEMU VM. In production
59
+ // these resolve to the real dynamic import + host probes.
60
+ // ---------------------------------------------------------------------------
61
+ /** The npm specifier — held in a VARIABLE so it is never statically resolved. */
62
+ const GONDOLIN_SPECIFIER = '@earendil-works/gondolin';
63
+ /**
64
+ * The real dynamic importer. The specifier is passed as an argument (held in a
65
+ * variable at the call site) so the bundler / TS never treats the optional
66
+ * package as a hard dependency.
67
+ */
68
+ const realImporter = (specifier) => import(specifier);
69
+ /** `true` when `/dev/kvm` exists — KVM acceleration is available on the host. */
70
+ function realHasKvm() {
71
+ try {
72
+ return existsSync('/dev/kvm');
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ }
78
+ /** `true` when `qemu-system-x86_64 --version` runs successfully (cheap probe). */
79
+ function realHasQemu() {
80
+ try {
81
+ execFileSync('qemu-system-x86_64', ['--version'], {
82
+ stdio: ['ignore', 'ignore', 'ignore'],
83
+ timeout: 5000,
84
+ });
85
+ return true;
86
+ }
87
+ catch {
88
+ return false;
89
+ }
90
+ }
91
+ /** The active importer (swapped only by {@link __setGondolinTestHooks}). */
92
+ let importer = realImporter;
93
+ /** The active host probes (swapped only by {@link __setGondolinTestHooks}). */
94
+ let hostProbes = { hasKvm: realHasKvm, hasQemu: realHasQemu };
95
+ /**
96
+ * Structurally validate a dynamically-imported candidate against the three
97
+ * Gondolin exports the backend consumes. Returns the typed module on a match,
98
+ * else `null` — so a shape-incompatible package version reports unavailable
99
+ * rather than crashing later at VM-boot time.
100
+ */
101
+ function shapeCheck(candidate) {
102
+ if (candidate === null || typeof candidate !== 'object')
103
+ return null;
104
+ const mod = candidate;
105
+ const vmOk = typeof mod.VM === 'object' &&
106
+ mod.VM !== null &&
107
+ typeof mod.VM.create === 'function';
108
+ const realFsOk = typeof mod.RealFSProvider === 'function';
109
+ const hooksOk = typeof mod.createHttpHooks === 'function';
110
+ if (vmOk && realFsOk && hooksOk) {
111
+ return candidate;
112
+ }
113
+ return null;
114
+ }
115
+ /**
116
+ * Attempt to lazily load `@earendil-works/gondolin`. Returns `null` when the
117
+ * optional dep is not installed, fails to load, OR does not expose the expected
118
+ * `VM` / `RealFSProvider` / `createHttpHooks` surface — so callers can report the
119
+ * sandbox unavailable rather than crashing. NEVER throws.
120
+ *
121
+ * The import specifier is held in a variable (passed to the {@link importer}
122
+ * seam) so bundlers / TS do not treat the missing optional dep as a hard,
123
+ * statically-resolved dependency (same technique as
124
+ * {@link ../../tools/browser-driver.js}'s Playwright load).
125
+ *
126
+ * @returns The shape-checked module, or `null` when unavailable.
127
+ */
128
+ export async function loadGondolin() {
129
+ try {
130
+ const mod = await importer(GONDOLIN_SPECIFIER);
131
+ const candidate = mod.default ?? mod;
132
+ return shapeCheck(candidate);
133
+ }
134
+ catch (err) {
135
+ log.debug({ err }, 'gondolin not loadable — sandbox execution unavailable');
136
+ return null;
137
+ }
138
+ }
139
+ /**
140
+ * Whether the Gondolin sandbox backend can run in this process. The AND of three
141
+ * conditions:
142
+ *
143
+ * 1. the `@earendil-works/gondolin` package loads ({@link loadGondolin} is non-`null`),
144
+ * 2. `/dev/kvm` exists (KVM acceleration is present),
145
+ * 3. a working `qemu-system-x86_64` is on `PATH`.
146
+ *
147
+ * A box with the package but no KVM still reports `false` so the selector
148
+ * ({@link ./resolve-execution-env.js}) degrades to the in-process
149
+ * `GuardedExecutionEnv` — it NEVER errors. The result is cached after the first
150
+ * probe so availability checks stay cheap; {@link __resetGondolinAvailabilityCache}
151
+ * clears it (tests only).
152
+ *
153
+ * @returns `true` only when package + `/dev/kvm` + QEMU are all present.
154
+ */
155
+ let cachedAvailable;
156
+ export async function isGondolinAvailable() {
157
+ if (cachedAvailable !== undefined)
158
+ return cachedAvailable;
159
+ const pkgPresent = (await loadGondolin()) !== null;
160
+ cachedAvailable = pkgPresent && hostProbes.hasKvm() && hostProbes.hasQemu();
161
+ return cachedAvailable;
162
+ }
163
+ /**
164
+ * Reset the cached Gondolin-availability probe.
165
+ *
166
+ * EXPORTED FOR TESTS ONLY — lets a unit test toggle the mocked availability of
167
+ * the optional dep + host probes between cases without a fresh module graph.
168
+ *
169
+ * @internal
170
+ */
171
+ export function __resetGondolinAvailabilityCache() {
172
+ cachedAvailable = undefined;
173
+ }
174
+ /**
175
+ * Override the dynamic-importer and/or host probes, and reset the availability
176
+ * cache.
177
+ *
178
+ * EXPORTED FOR TESTS ONLY — lets a unit test simulate "package absent" (importer
179
+ * rejects), "package present" (importer resolves a mock module), and "no
180
+ * `/dev/kvm`" / "no QEMU" deterministically, WITHOUT touching the module graph or
181
+ * launching a real QEMU VM. Pass `undefined` for a field to leave it at the real
182
+ * default; call with no arguments to restore the real importer + probes.
183
+ *
184
+ * @param hooks - Partial overrides for the importer and host probes.
185
+ * @internal
186
+ */
187
+ export function __setGondolinTestHooks(hooks) {
188
+ importer = hooks?.importer ?? realImporter;
189
+ hostProbes = {
190
+ hasKvm: hooks?.hasKvm ?? realHasKvm,
191
+ hasQemu: hooks?.hasQemu ?? realHasQemu,
192
+ };
193
+ cachedAvailable = undefined;
194
+ }
195
+ //# sourceMappingURL=gondolin-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gondolin-loader.js","sourceRoot":"","sources":["../../../src/llm/pi/gondolin-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,GAAG,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAChC,yFAAyF;IACzF,+FAA+F;IAC/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,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,UAAU;QACnC,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,WAAW;KACvC,CAAC;IACF,eAAe,GAAG,SAAS,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Pi in-process embed — public barrel (T11761 · S2 · T11898).
3
+ *
4
+ * The Pi agent loop runs in-process inside the Cleo daemon as the body of the
5
+ * `SkillRunner` strategy slot, with ZERO authority — resolving its LLM only
6
+ * through the E9 chokepoint, touching the filesystem/shell only through the
7
+ * deny-first guarded `ExecutionEnv`, and running under `process.exit`
8
+ * containment. See {@link ./pi-agent-adapter.js}.
9
+ *
10
+ * ## Public surface (intentionally minimal — Gate-4 Contracts Fan-Out)
11
+ *
12
+ * Only the SkillRunner factory + the default-OFF flag are exported. The adapter
13
+ * internals (`PiAgentAdapter`, the streamFn, the session storage, the run-context
14
+ * types) are core-internal and NOT re-exported here, so they cannot become a
15
+ * cross-package contract by accident. When a second consumer ever needs one,
16
+ * promote it to `@cleocode/contracts` then (YAGNI).
17
+ *
18
+ * The whole embed is gated by {@link isPiRunnerEnabled} (default-OFF): when the
19
+ * flag is off, {@link createPiSkillRunner} is never wired into the dispatcher and
20
+ * `defaultSkillRunner` runs instead.
21
+ *
22
+ * @epic T10403
23
+ * @task T11761
24
+ * @task T11898
25
+ */
26
+ export type { PiAgentAdapterDeps } from './pi-agent-adapter.js';
27
+ export { createPiSkillRunner, isPiRunnerEnabled } from './pi-agent-adapter.js';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/llm/pi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Pi in-process embed — public barrel (T11761 · S2 · T11898).
3
+ *
4
+ * The Pi agent loop runs in-process inside the Cleo daemon as the body of the
5
+ * `SkillRunner` strategy slot, with ZERO authority — resolving its LLM only
6
+ * through the E9 chokepoint, touching the filesystem/shell only through the
7
+ * deny-first guarded `ExecutionEnv`, and running under `process.exit`
8
+ * containment. See {@link ./pi-agent-adapter.js}.
9
+ *
10
+ * ## Public surface (intentionally minimal — Gate-4 Contracts Fan-Out)
11
+ *
12
+ * Only the SkillRunner factory + the default-OFF flag are exported. The adapter
13
+ * internals (`PiAgentAdapter`, the streamFn, the session storage, the run-context
14
+ * types) are core-internal and NOT re-exported here, so they cannot become a
15
+ * cross-package contract by accident. When a second consumer ever needs one,
16
+ * promote it to `@cleocode/contracts` then (YAGNI).
17
+ *
18
+ * The whole embed is gated by {@link isPiRunnerEnabled} (default-OFF): when the
19
+ * flag is off, {@link createPiSkillRunner} is never wired into the dispatcher and
20
+ * `defaultSkillRunner` runs instead.
21
+ *
22
+ * @epic T10403
23
+ * @task T11761
24
+ * @task T11898
25
+ */
26
+ export { createPiSkillRunner, isPiRunnerEnabled } from './pi-agent-adapter.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/llm/pi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * `PiAgentAdapter` — the in-process Pi agent-loop embed (T11761 · S2 · T11898).
3
+ *
4
+ * THE KEYSTONE of the Pi-harness work: the Pi agent loop runs **in-process**
5
+ * inside the Cleo daemon as the body of the `SkillRunner` strategy slot, with
6
+ * ZERO authority. It:
7
+ *
8
+ * - resolves its LLM ONLY through the E9 chokepoint (`resolveLLMForSystem` →
9
+ * `ModelRunner`) via the Cleo-owned {@link createPiStreamFn} — `pi-ai`'s
10
+ * registry env-fallback is never reached;
11
+ * - touches the filesystem/shell ONLY through the deny-first
12
+ * {@link GuardedExecutionEnv} (S1) bound to the injected guarded tool surface;
13
+ * - reads its session identity from the daemon-stamped env (NEVER mints one);
14
+ * - runs under {@link wrapPiCall} containment so a `process.exit()` from any Pi
15
+ * code path becomes a thrown typed error, not a daemon-fatal exit;
16
+ * - is gated behind a **default-OFF** feature flag ({@link isPiRunnerEnabled}).
17
+ *
18
+ * The `SkillRunner` slot (`SkillExecutorAdapterOptions.runner`, line 124 of
19
+ * `skill-executor-adapter.ts`) CALLS this adapter via {@link createPiSkillRunner};
20
+ * the adapter is NOT hosted inside `defaultSkillRunner` (which stays untouched).
21
+ *
22
+ * Session durability is S3's concern: this subtask uses
23
+ * {@link InMemorySessionStorage} (in-RAM, no DB writer, no lease) so the
24
+ * read/stream path is buildable with ZERO write authority.
25
+ *
26
+ * @epic T10403
27
+ * @task T11761
28
+ * @task T11898
29
+ */
30
+ import type { GuardedToolSurface } from '@cleocode/contracts/tools/skill-executor';
31
+ import type { SkillRunner } from '../../skills/skill-executor-adapter.js';
32
+ import type { AgentToolRegistry } from '../../tools/agent-registry.js';
33
+ import { type ToolBudgetLimits } from '../../tools/dispatch.js';
34
+ import type { PiAgentResult, PiAgentRunContext } from './pi-types.js';
35
+ /**
36
+ * Default-OFF feature flag controlling whether the Pi runner is constructed and
37
+ * used. Reads `CLEO_PI_RUNNER_ENABLED === '1'`. The whole adapter is gated by
38
+ * this — when disabled, {@link createPiSkillRunner} is never wired into the
39
+ * dispatcher and `defaultSkillRunner` runs instead.
40
+ *
41
+ * @returns `true` when the Pi runner is explicitly enabled.
42
+ */
43
+ export declare function isPiRunnerEnabled(): boolean;
44
+ /**
45
+ * Construction dependencies for {@link PiAgentAdapter}.
46
+ */
47
+ export interface PiAgentAdapterDeps {
48
+ /**
49
+ * The {@link SystemOfUseLabel} this adapter resolves its LLM through (E9).
50
+ * Defaults to `'task-executor'` when the SkillRunner closure builds the ctx.
51
+ */
52
+ readonly system?: PiAgentRunContext['system'];
53
+ /**
54
+ * Project root for config + credential resolution. Defaults to
55
+ * `process.cwd()` inside `resolveLLMForSystem`.
56
+ */
57
+ readonly projectRoot?: string;
58
+ /**
59
+ * The frozen {@link AgentToolRegistry} whose tools the loop may CALL (T1740 ·
60
+ * AC6). When supplied, {@link run} builds a {@link ToolDispatchEngine} over it
61
+ * + the injected guarded surface and projects executable `AgentTool`s onto the
62
+ * loop, so a model tool-call actually runs through the dispatch engine. When
63
+ * omitted the loop is text-only (no tools offered for execution) — the prior
64
+ * behaviour, preserved so existing callers are unchanged.
65
+ */
66
+ readonly registry?: AgentToolRegistry;
67
+ /**
68
+ * Optional per-run tool-call budget limits (T1740 · AC5) applied to the
69
+ * dispatch engine: max call count, per-call timeout, total time. Omitted →
70
+ * unbounded.
71
+ */
72
+ readonly budget?: ToolBudgetLimits;
73
+ }
74
+ /**
75
+ * In-process Pi agent-loop adapter with ZERO authority.
76
+ *
77
+ * {@link run} drives `pi-agent-core`'s `runAgentLoop` with a Cleo-owned streamFn
78
+ * (Gate-13), an in-RAM session (no DB writer), and `wrapPiCall` exit/error
79
+ * containment, then projects the terminal assistant message onto a
80
+ * {@link PiAgentResult}. It NEVER throws past the containment boundary for a Pi
81
+ * failure — a Pi error becomes a `{ status: 'failure', error }` result.
82
+ */
83
+ export declare class PiAgentAdapter {
84
+ #private;
85
+ /**
86
+ * Construct the adapter.
87
+ *
88
+ * `deps` supplies the construction-time defaults (resolution system + project
89
+ * root) that {@link run} merges UNDER the per-call context — a field the call
90
+ * supplies on `ctx` always wins. The factory {@link createPiSkillRunner} builds
91
+ * the full `ctx` from these same deps; a direct caller may pass a partial `ctx`
92
+ * and rely on the deps for the rest.
93
+ *
94
+ * @param deps - Resolution system + optional project root defaults.
95
+ */
96
+ constructor(deps?: PiAgentAdapterDeps);
97
+ /**
98
+ * Run one Pi agent turn over the guarded tool surface.
99
+ *
100
+ * The `tools` surface is the injected {@link GuardedToolSurface}; the v0
101
+ * read/stream path threads it into the loop for future tool wiring (S3+ maps
102
+ * Pi's `ExecutionEnv` onto it). Resolution + streaming are owned by
103
+ * {@link createPiStreamFn} (Gate-13). The session id MUST already be
104
+ * daemon-stamped (read from env in {@link createPiSkillRunner}); the adapter
105
+ * never mints one.
106
+ *
107
+ * @param prompt - The user prompt for this turn.
108
+ * @param tools - The deny-first guarded tool surface (injected, never built here).
109
+ * @param ctx - The run context (system label + daemon-stamped identity + signal).
110
+ * @returns The terminal {@link PiAgentResult}; never throws for a Pi failure.
111
+ */
112
+ run(prompt: string, tools: GuardedToolSurface, ctx: PiAgentRunContext): Promise<PiAgentResult>;
113
+ }
114
+ /**
115
+ * Factory returning a {@link SkillRunner} whose body delegates to
116
+ * {@link PiAgentAdapter.run}.
117
+ *
118
+ * This is the seam adaptation: the real `SkillRunner` shape is
119
+ * `(skill, input) => Promise<SkillExecuteResult>` — it carries NO free `prompt`
120
+ * / `ctx`, so the closure DERIVES the prompt from the skill+context and reads
121
+ * the daemon-stamped identity from env. When the env is un-stamped the runner
122
+ * fails closed (it NEVER mints a session id).
123
+ *
124
+ * Wire it into the dispatcher behind the default-OFF flag:
125
+ * ```ts
126
+ * new SkillExecutorAdapter({
127
+ * runner: isPiRunnerEnabled() ? createPiSkillRunner(deps) : undefined,
128
+ * });
129
+ * ```
130
+ *
131
+ * @param deps - Adapter construction deps (resolution system + project root).
132
+ * @returns A `SkillRunner` that runs the Pi loop in-process.
133
+ */
134
+ export declare function createPiSkillRunner(deps?: PiAgentAdapterDeps): SkillRunner;
135
+ //# sourceMappingURL=pi-agent-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-agent-adapter.d.ts","sourceRoot":"","sources":["../../../src/llm/pi/pi-agent-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAGnB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