@leuduan/lagent 0.1.2 → 44.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/README.md +28 -15
  2. package/dist/chunks/{UC3FVVJ2.js → 2GCIWSOA.js} +2 -2
  3. package/dist/chunks/2P47AHNK.js +7 -0
  4. package/dist/chunks/3UMZMPWW.js +1 -0
  5. package/dist/chunks/5IRF47YB.js +1 -0
  6. package/dist/chunks/6DRCKZ2C.js +1 -0
  7. package/dist/chunks/6FRNHMCV.js +1 -0
  8. package/dist/chunks/7LI64H5X.js +17 -0
  9. package/dist/chunks/{SL2YLB2F.js → 7VAPNE3L.js} +1 -1
  10. package/dist/chunks/{BM3S37EZ.js → ASSQZH3F.js} +1 -1
  11. package/dist/chunks/B4FXK5ER.js +77 -0
  12. package/dist/chunks/{37YOGDGY.js → BBCW2FZK.js} +1 -1
  13. package/dist/chunks/BPRCULZH.js +1 -0
  14. package/dist/chunks/CANPZYTH.js +24 -0
  15. package/dist/chunks/CQEVREBT.js +1 -0
  16. package/dist/chunks/CUK7CGC7.js +1 -0
  17. package/dist/chunks/D4PQP5MA.js +3 -0
  18. package/dist/chunks/{CDQG7RKA.js → DDZ7YF26.js} +1 -1
  19. package/dist/chunks/EMRB4KCN.js +6 -0
  20. package/dist/chunks/EPYQ5M3B.js +3 -0
  21. package/dist/chunks/G44LG6VL.js +1 -0
  22. package/dist/chunks/GGSVIIWJ.js +2 -0
  23. package/dist/chunks/IAAEP6VL.js +30 -0
  24. package/dist/chunks/{AP6Q4EPT.js → JCTBX33H.js} +1 -1
  25. package/dist/chunks/JFX2MXBA.js +4 -0
  26. package/dist/chunks/JFZZXVWD.js +15 -0
  27. package/dist/chunks/KUZCL2SH.js +1 -0
  28. package/dist/chunks/MHC6VPB4.js +7 -0
  29. package/dist/chunks/MMNNZCBO.js +5 -0
  30. package/dist/chunks/{C5LYCXJG.js → MNJ4SRF7.js} +1 -1
  31. package/dist/chunks/N6IXG2VL.js +1 -0
  32. package/dist/chunks/OCBPT7KE.js +1 -0
  33. package/dist/chunks/OL5A6ITQ.js +1 -0
  34. package/dist/chunks/Q75FUN7D.js +2 -0
  35. package/dist/chunks/Q7S5LFGN.js +1 -0
  36. package/dist/chunks/RCIHV3KG.js +1 -0
  37. package/dist/chunks/S34ZA2R6.js +1 -0
  38. package/dist/chunks/SS3B5W34.js +12 -0
  39. package/dist/chunks/VYMT4TXD.js +1 -0
  40. package/dist/chunks/W57RW55W.js +1 -0
  41. package/dist/compositions/base.d.ts +11 -0
  42. package/dist/{presets → compositions}/codex.d.ts +12 -6
  43. package/dist/{presets/prompts.d.ts → compositions/codexPrompts.d.ts} +1 -1
  44. package/dist/context.d.ts +18 -10
  45. package/dist/index.d.ts +31 -23
  46. package/dist/index.js +1 -77
  47. package/dist/journal/catalog.d.ts +1 -1
  48. package/dist/journal/journal.d.ts +3 -3
  49. package/dist/journal/projection.d.ts +1 -1
  50. package/dist/journal/store.d.ts +3 -3
  51. package/dist/llm/index.d.ts +19 -13
  52. package/dist/llm/index.js +1 -0
  53. package/dist/llm/provider.d.ts +11 -0
  54. package/dist/loop/agent.d.ts +16 -132
  55. package/dist/loop/authorization.d.ts +41 -0
  56. package/dist/loop/auxiliary.d.ts +7 -3
  57. package/dist/loop/chunks.d.ts +3 -3
  58. package/dist/loop/completion.d.ts +17 -0
  59. package/dist/loop/errors.d.ts +6 -29
  60. package/dist/loop/hooks.d.ts +39 -6
  61. package/dist/loop/index.d.ts +7 -28
  62. package/dist/loop/runner.d.ts +134 -0
  63. package/dist/loop/runtime.d.ts +7 -16
  64. package/dist/loop/strategy.d.ts +12 -3
  65. package/dist/loop/{prepare.d.ts → surfacePrepare.d.ts} +2 -2
  66. package/dist/loop/tool.d.ts +11 -6
  67. package/dist/loop/toolCalls.d.ts +3 -10
  68. package/dist/plugin.d.ts +31 -34
  69. package/dist/plugin.js +1 -1
  70. package/dist/plugins/agentsMd.d.ts +24 -20
  71. package/dist/plugins/agentsMd.js +1 -1
  72. package/dist/plugins/ask/index.d.ts +2 -2
  73. package/dist/plugins/ask/index.js +1 -1
  74. package/dist/plugins/ask/service.d.ts +2 -2
  75. package/dist/plugins/commands/index.d.ts +5 -2
  76. package/dist/plugins/commands/index.js +1 -1
  77. package/dist/plugins/commands/output.d.ts +1 -1
  78. package/dist/plugins/commands/record.d.ts +31 -22
  79. package/dist/plugins/commands/service.d.ts +18 -11
  80. package/dist/plugins/commands/{background.d.ts → tools.d.ts} +2 -0
  81. package/dist/plugins/compaction/checkpoint.d.ts +4 -1
  82. package/dist/plugins/compaction/config.d.ts +3 -3
  83. package/dist/plugins/compaction/estimate.d.ts +9 -1
  84. package/dist/plugins/compaction/index.d.ts +87 -2
  85. package/dist/plugins/compaction/index.js +5 -5
  86. package/dist/plugins/compaction/{records.d.ts → record.d.ts} +36 -36
  87. package/dist/plugins/compaction/{log.d.ts → state.d.ts} +8 -1
  88. package/dist/plugins/dateAndBranch.js +1 -1
  89. package/dist/plugins/delegations/answers.d.ts +1 -1
  90. package/dist/plugins/delegations/assignmentKey.d.ts +1 -1
  91. package/dist/plugins/delegations/cleanup.d.ts +1 -1
  92. package/dist/plugins/delegations/index.js +1 -1
  93. package/dist/plugins/delegations/notices.d.ts +8 -8
  94. package/dist/plugins/delegations/obligations.d.ts +13 -13
  95. package/dist/plugins/delegations/record.d.ts +11 -10
  96. package/dist/plugins/delegations/request.d.ts +8 -5
  97. package/dist/plugins/delegations/role.d.ts +1 -1
  98. package/dist/plugins/delegations/service.d.ts +9 -8
  99. package/dist/plugins/delegations/{waitBook.d.ts → waitResolver.d.ts} +9 -9
  100. package/dist/plugins/diagnostics/digest.d.ts +1 -1
  101. package/dist/plugins/diagnostics/index.d.ts +1 -1
  102. package/dist/plugins/diagnostics/index.js +1 -1
  103. package/dist/plugins/fileTools/config.d.ts +10 -0
  104. package/dist/plugins/{tools → fileTools}/editFiles.d.ts +16 -27
  105. package/dist/plugins/fileTools/gitDiscovery.d.ts +9 -0
  106. package/dist/plugins/fileTools/index.d.ts +18 -0
  107. package/dist/plugins/fileTools/index.js +1 -0
  108. package/dist/plugins/fileTools/tools.d.ts +6 -0
  109. package/dist/plugins/historyRecall/history.d.ts +1 -1
  110. package/dist/plugins/historyRecall/index.js +1 -1
  111. package/dist/plugins/historyRecall/render.d.ts +1 -1
  112. package/dist/plugins/mcp/catalog.d.ts +1 -1
  113. package/dist/plugins/mcp/index.d.ts +2 -2
  114. package/dist/plugins/mcp/index.js +1 -1
  115. package/dist/plugins/mcp/mount.d.ts +2 -2
  116. package/dist/plugins/mcp/render.d.ts +1 -1
  117. package/dist/plugins/mcp/{tool.d.ts → tools.d.ts} +1 -1
  118. package/dist/plugins/{routeContext.d.ts → routeNotice.d.ts} +2 -2
  119. package/dist/plugins/routeNotice.js +1 -0
  120. package/dist/{sandbox → plugins/sandbox}/absent.d.ts +11 -10
  121. package/dist/{sandbox → plugins/sandbox}/index.d.ts +5 -2
  122. package/dist/plugins/sandbox/index.js +4 -0
  123. package/dist/{sandbox → plugins/sandbox}/mode.d.ts +5 -5
  124. package/dist/plugins/sandbox/policy.d.ts +163 -0
  125. package/dist/{sandbox → plugins/sandbox}/service.d.ts +23 -13
  126. package/dist/plugins/schedules/index.js +3 -3
  127. package/dist/plugins/schedules/record.d.ts +18 -18
  128. package/dist/plugins/schedules/service.d.ts +2 -2
  129. package/dist/plugins/skills/discovery.d.ts +38 -9
  130. package/dist/plugins/skills/index.d.ts +1 -1
  131. package/dist/plugins/skills/index.js +1 -1
  132. package/dist/plugins/subAgents/index.js +1 -1
  133. package/dist/plugins/subAgents/{fork.d.ts → tools.d.ts} +36 -1
  134. package/dist/plugins/threadDirs.d.ts +36 -0
  135. package/dist/plugins/threadDirs.js +1 -0
  136. package/dist/plugins/toolPolicy/index.d.ts +2 -2
  137. package/dist/plugins/toolPolicy/index.js +1 -1
  138. package/dist/plugins/truncateToolOutput.d.ts +14 -10
  139. package/dist/plugins/truncateToolOutput.js +6 -1
  140. package/dist/plugins/usage/index.d.ts +4 -2
  141. package/dist/plugins/usage/index.js +1 -1
  142. package/dist/plugins/usage/tracker.d.ts +1 -1
  143. package/dist/plugins/verify/index.d.ts +7 -55
  144. package/dist/plugins/verify/index.js +6 -1
  145. package/dist/plugins/verify/judgement.d.ts +16 -0
  146. package/dist/plugins/verify/record.d.ts +382 -0
  147. package/dist/plugins/verify/service.d.ts +7 -4
  148. package/dist/plugins/verify/state.d.ts +58 -0
  149. package/dist/plugins/webTools/index.d.ts +34 -0
  150. package/dist/plugins/webTools/index.js +1 -0
  151. package/dist/plugins/workflows/assignment.d.ts +6 -2
  152. package/dist/plugins/workflows/cleanup.d.ts +1 -1
  153. package/dist/plugins/workflows/definition.d.ts +2 -2
  154. package/dist/plugins/workflows/{bindings.d.ts → entryPlan.d.ts} +2 -2
  155. package/dist/plugins/workflows/{providers.d.ts → hostBindings.d.ts} +2 -2
  156. package/dist/plugins/workflows/index.d.ts +4 -4
  157. package/dist/plugins/workflows/index.js +10 -5
  158. package/dist/plugins/workflows/observations.d.ts +3 -3
  159. package/dist/plugins/workflows/participantModels.d.ts +28 -0
  160. package/dist/plugins/workflows/participants.d.ts +2 -2
  161. package/dist/plugins/workflows/policy.d.ts +2 -2
  162. package/dist/plugins/workflows/record.d.ts +51 -65
  163. package/dist/plugins/workflows/routing.d.ts +2 -2
  164. package/dist/plugins/workflows/service.d.ts +24 -24
  165. package/dist/plugins/workflows/{fold.d.ts → state.d.ts} +2 -2
  166. package/dist/plugins/workflows/stopCheck.d.ts +13 -0
  167. package/dist/plugins/workflows/tools.d.ts +13 -0
  168. package/dist/plugins/workflows/view.d.ts +2 -2
  169. package/dist/plugins/{workspaceContext.d.ts → workspaceNotice.d.ts} +5 -7
  170. package/dist/plugins/workspaceNotice.js +1 -0
  171. package/dist/{plugins/providers → providers}/anthropic.d.ts +6 -3
  172. package/dist/{plugins/providers → providers}/anthropicMessages.d.ts +2 -1
  173. package/dist/{plugins/providers → providers}/codex.d.ts +14 -3
  174. package/dist/{plugins/providers → providers}/deepseek.d.ts +6 -2
  175. package/dist/{plugins/providers → providers}/failure.d.ts +1 -1
  176. package/dist/{plugins/providers → providers}/gateway.d.ts +2 -1
  177. package/dist/providers/index.d.ts +18 -0
  178. package/dist/providers/index.js +6 -0
  179. package/dist/{plugins/providers → providers}/openaiChat.d.ts +13 -2
  180. package/dist/{plugins/providers → providers}/openaiResponses.d.ts +12 -3
  181. package/dist/{plugins/providers → providers}/opencodeCopilot.d.ts +2 -2
  182. package/dist/{plugins/providers → providers}/opencodeGo.d.ts +18 -7
  183. package/dist/{plugins/providers → providers}/shared.d.ts +9 -1
  184. package/dist/{plugins/providers → providers}/stream.d.ts +4 -2
  185. package/dist/{models/door.d.ts → records/index.d.ts} +8 -7
  186. package/dist/records/index.js +1 -0
  187. package/dist/{models/wire → records}/journal.d.ts +210 -14
  188. package/dist/{models/wire/primitives.d.ts → records/toolResult.d.ts} +1 -1
  189. package/dist/services/agents.d.ts +26 -1
  190. package/dist/services/confinement/files.d.ts +118 -0
  191. package/dist/services/confinement/service.d.ts +219 -0
  192. package/dist/services/core.d.ts +2 -8
  193. package/dist/{kit/extension.d.ts → services/extensionEvents.d.ts} +5 -4
  194. package/dist/services/journal.d.ts +1 -1
  195. package/dist/services/llm.d.ts +4 -2
  196. package/dist/{kit → services}/modes.d.ts +1 -1
  197. package/dist/services/plugins.d.ts +34 -0
  198. package/dist/services/{preset.d.ts → presets/definition.d.ts} +4 -4
  199. package/dist/services/{presets.d.ts → presets/installations.d.ts} +3 -3
  200. package/dist/services/prompts.d.ts +23 -5
  201. package/dist/services/{threadActivation.d.ts → threads/activation.d.ts} +3 -3
  202. package/dist/services/{admission.d.ts → threads/admission.d.ts} +3 -3
  203. package/dist/services/{birth.d.ts → threads/birth.d.ts} +9 -10
  204. package/dist/services/threads/index.d.ts +14 -0
  205. package/dist/services/{runEvents.d.ts → threads/runEvents.d.ts} +2 -2
  206. package/dist/services/{owner.d.ts → threads/runOwner.d.ts} +5 -4
  207. package/dist/services/{threads.d.ts → threads/service.d.ts} +9 -8
  208. package/dist/services/{thread.d.ts → threads/thread.d.ts} +8 -7
  209. package/dist/services/{threadView.d.ts → threads/view.d.ts} +7 -6
  210. package/dist/services/tools.d.ts +79 -2
  211. package/dist/{loop/opening.d.ts → state/birth.d.ts} +22 -2
  212. package/dist/{loop → state}/chain.d.ts +3 -3
  213. package/dist/state/confirmations.d.ts +64 -0
  214. package/dist/{loop → state}/continuation.d.ts +3 -2
  215. package/dist/{loop → state}/decide.d.ts +10 -2
  216. package/dist/state/dispatches.d.ts +54 -0
  217. package/dist/state/errors.d.ts +26 -0
  218. package/dist/{loop → state}/forks.d.ts +1 -1
  219. package/dist/{loop → state}/holds.d.ts +1 -1
  220. package/dist/{loop → state}/inbox.d.ts +2 -2
  221. package/dist/state/index.d.ts +31 -0
  222. package/dist/state/inputs.d.ts +58 -0
  223. package/dist/state/installations.d.ts +28 -0
  224. package/dist/state/prompt.d.ts +13 -0
  225. package/dist/state/recovery.d.ts +7 -0
  226. package/dist/{loop → state}/replace.d.ts +2 -2
  227. package/dist/{loop → state}/requests.d.ts +3 -3
  228. package/dist/{loop → state}/route.d.ts +10 -2
  229. package/dist/state/summary.d.ts +16 -0
  230. package/dist/{loop → state}/surface.d.ts +3 -3
  231. package/dist/state/surfaceRead.d.ts +20 -0
  232. package/dist/{loop/threadState.d.ts → state/thread.d.ts} +12 -11
  233. package/dist/state/turns.d.ts +87 -0
  234. package/dist/state/waits.d.ts +38 -0
  235. package/dist/{loop → state}/wake.d.ts +1 -1
  236. package/dist/stores/durableObject.js +1 -0
  237. package/dist/{plugins/store → stores}/memory.d.ts +2 -2
  238. package/dist/{plugins/store → stores}/sql.d.ts +2 -2
  239. package/dist/stores/sqlite.js +1 -0
  240. package/dist/sys/environment.d.ts +0 -5
  241. package/dist/sys/git.d.ts +0 -13
  242. package/dist/sys/paths.d.ts +0 -47
  243. package/dist/sys/spawn.d.ts +16 -6
  244. package/dist/testing/clock.d.ts +1 -1
  245. package/dist/testing/fakeLlm.d.ts +4 -2
  246. package/dist/testing/fedLlm.d.ts +3 -1
  247. package/dist/testing/helpers.d.ts +31 -13
  248. package/dist/testing/index.js +1 -1
  249. package/dist/testing/settlement.d.ts +1 -1
  250. package/package.json +36 -28
  251. package/dist/chunks/2O7ZGEIT.js +0 -1
  252. package/dist/chunks/2OSESBIL.js +0 -1
  253. package/dist/chunks/3LQHQRIU.js +0 -6
  254. package/dist/chunks/3QCW4WDJ.js +0 -1
  255. package/dist/chunks/4XVRUSCQ.js +0 -1
  256. package/dist/chunks/6ECI2GGV.js +0 -1
  257. package/dist/chunks/74HKUGRR.js +0 -1
  258. package/dist/chunks/ADHERZLW.js +0 -2
  259. package/dist/chunks/D7E6EWIE.js +0 -3
  260. package/dist/chunks/DRYAN665.js +0 -1
  261. package/dist/chunks/DXFXAYDN.js +0 -17
  262. package/dist/chunks/EGZI4XQX.js +0 -24
  263. package/dist/chunks/ENWFSU27.js +0 -41
  264. package/dist/chunks/G6RXC3AL.js +0 -1
  265. package/dist/chunks/G74AGRAJ.js +0 -15
  266. package/dist/chunks/GQGNVSKB.js +0 -1
  267. package/dist/chunks/IJ2WNMD5.js +0 -7
  268. package/dist/chunks/JPZFKSWT.js +0 -1
  269. package/dist/chunks/KESCTXGO.js +0 -5
  270. package/dist/chunks/L3N4FIEN.js +0 -1
  271. package/dist/chunks/NAOUTU7A.js +0 -4
  272. package/dist/chunks/NDIM7MEW.js +0 -1
  273. package/dist/chunks/O4PPOM5Z.js +0 -2
  274. package/dist/chunks/OVZFGILJ.js +0 -1
  275. package/dist/chunks/P5ZHHOOM.js +0 -6
  276. package/dist/chunks/QMMLQJBS.js +0 -1
  277. package/dist/chunks/RK3VP2Q4.js +0 -3
  278. package/dist/chunks/SGGMBSBA.js +0 -1
  279. package/dist/chunks/TOOIB6J2.js +0 -1
  280. package/dist/chunks/TYTQRLTX.js +0 -1
  281. package/dist/chunks/UCTEU62F.js +0 -1
  282. package/dist/chunks/UD3VJER6.js +0 -1
  283. package/dist/chunks/WUUKTSRT.js +0 -7
  284. package/dist/chunks/X65X4KP5.js +0 -7
  285. package/dist/chunks/YIR5MYGU.js +0 -1
  286. package/dist/chunks/YLNJXQ3Z.js +0 -1
  287. package/dist/kit/claim.d.ts +0 -13
  288. package/dist/kit/drain.d.ts +0 -10
  289. package/dist/kit/grants.d.ts +0 -9
  290. package/dist/kit/scope.d.ts +0 -32
  291. package/dist/kit/service.d.ts +0 -7
  292. package/dist/kit/strategy.d.ts +0 -10
  293. package/dist/kit/tool.d.ts +0 -72
  294. package/dist/llm/door.d.ts +0 -21
  295. package/dist/llm/door.js +0 -1
  296. package/dist/loop/projections.d.ts +0 -307
  297. package/dist/loop/state.d.ts +0 -70
  298. package/dist/loop/summary.d.ts +0 -3
  299. package/dist/models/config/agent.d.ts +0 -18
  300. package/dist/models/config/prompt.d.ts +0 -18
  301. package/dist/models/door.js +0 -1
  302. package/dist/models/index.d.ts +0 -7
  303. package/dist/plugins/commands/foreground.d.ts +0 -4
  304. package/dist/plugins/compaction/preset.d.ts +0 -86
  305. package/dist/plugins/compaction/shared.d.ts +0 -14
  306. package/dist/plugins/delegations/testing.d.ts +0 -16
  307. package/dist/plugins/providers/door.d.ts +0 -61
  308. package/dist/plugins/providers/door.js +0 -1
  309. package/dist/plugins/providers/index.d.ts +0 -6
  310. package/dist/plugins/routeContext.js +0 -1
  311. package/dist/plugins/store/durableObject.js +0 -1
  312. package/dist/plugins/store/sqlite.js +0 -1
  313. package/dist/plugins/subAgents/tool.d.ts +0 -38
  314. package/dist/plugins/tools/index.d.ts +0 -59
  315. package/dist/plugins/tools/index.js +0 -1
  316. package/dist/plugins/verify/facts.d.ts +0 -356
  317. package/dist/plugins/workflows/submit.d.ts +0 -8
  318. package/dist/plugins/workspaceContext.js +0 -1
  319. package/dist/presets/agents.d.ts +0 -7
  320. package/dist/presets/base.d.ts +0 -10
  321. package/dist/presets/index.d.ts +0 -4
  322. package/dist/sandbox/index.js +0 -4
  323. package/dist/sandbox/policy.d.ts +0 -86
  324. package/dist/services/launches.d.ts +0 -104
  325. package/dist/services/threadDirs.d.ts +0 -38
  326. package/dist/testing/sandbox.d.ts +0 -71
  327. /package/dist/chunks/{UKXMCHHT.js → FJLU4UH3.js} +0 -0
  328. /package/dist/chunks/{J5S4URAW.js → HK6ZSONF.js} +0 -0
  329. /package/dist/plugins/ask/{askQuestion.d.ts → tools.d.ts} +0 -0
  330. /package/dist/plugins/delegations/{waits.d.ts → waitContracts.d.ts} +0 -0
  331. /package/dist/plugins/{tools → fileTools}/fsRead.d.ts +0 -0
  332. /package/dist/plugins/{tools → fileTools}/ripgrep.d.ts +0 -0
  333. /package/dist/plugins/{tools → fileTools}/textEdit.d.ts +0 -0
  334. /package/dist/{util → plugins/mcp}/version.d.ts +0 -0
  335. /package/dist/{sandbox → plugins/sandbox}/client.d.ts +0 -0
  336. /package/dist/{sandbox → plugins/sandbox}/files.d.ts +0 -0
  337. /package/dist/{sandbox → plugins/sandbox}/protocol.d.ts +0 -0
  338. /package/dist/{sandbox → plugins/sandbox}/worker.d.ts +0 -0
  339. /package/dist/{sandbox → plugins/sandbox}/worker.js +0 -0
  340. /package/dist/plugins/skills/{tool.d.ts → tools.d.ts} +0 -0
  341. /package/dist/plugins/{tools → webTools}/html.d.ts +0 -0
  342. /package/dist/plugins/{tools → webTools}/network.d.ts +0 -0
  343. /package/dist/plugins/{tools → webTools}/web.d.ts +0 -0
  344. /package/dist/plugins/workflows/{work.d.ts → workStatus.d.ts} +0 -0
  345. /package/dist/{plugins/providers → providers}/codexAuth.d.ts +0 -0
  346. /package/dist/services/{contributions.d.ts → catalogContributions.d.ts} +0 -0
  347. /package/dist/{loop → state}/limits.d.ts +0 -0
  348. /package/dist/{plugins/store → stores}/durableObject.d.ts +0 -0
  349. /package/dist/{plugins/store → stores}/durableObjectConnection.d.ts +0 -0
  350. /package/dist/{plugins/store → stores}/sqlite.d.ts +0 -0
  351. /package/dist/{models → util}/jsonSchema.d.ts +0 -0
  352. /package/dist/{kit → util}/retries.d.ts +0 -0
  353. /package/dist/{kit → util}/timers.d.ts +0 -0
@@ -0,0 +1,219 @@
1
+ import { Service, type Context } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type SpawnedCommand, type SpawnedGroup, type SpawnedPipes, type SpawnEnvironment } from '../../sys/spawn.js';
4
+ import { type FileScope } from './files.js';
5
+ /**
6
+ * How a model-driven process becomes a local launch: the one place `run_command`, the search tools,
7
+ * and later other model-driven processes such as MCP stdio servers, start a process, so a host's
8
+ * confinement sees every one. Not `sys/spawn`: lagent's own spawns (git, the shell probe, stop-check
9
+ * hooks) call `spawnCommand` directly and are never intercepted.
10
+ */
11
+ /** Which launch a process got, recorded with it: never secrets, ids or ports. */
12
+ export declare const LaunchProvenanceSchema: z.ZodObject<{
13
+ launcher: z.ZodString;
14
+ version: z.ZodString;
15
+ policy: z.ZodString;
16
+ }, z.core.$strict>;
17
+ export type LaunchProvenance = z.output<typeof LaunchProvenanceSchema>;
18
+ /** The `policy` of a launch a handler chose to run unconfined: what a host or a listing marks as such. */
19
+ export declare const UNCONFINED_LAUNCH = "unconfined";
20
+ /**
21
+ * What runs. `shell` is text for `/bin/sh -c`, launched with stdout and stderr joined in order, as a
22
+ * command line is. `argv` is a program and its arguments, run without a shell, launched with a
23
+ * writable stdin and stdout and stderr apart, as a tool that parses a program's output needs them.
24
+ */
25
+ export type LaunchProgram = {
26
+ readonly shell: string;
27
+ } | {
28
+ readonly argv: readonly [string, ...string[]];
29
+ };
30
+ /**
31
+ * What to launch and the geometry to confine (`root`, `scratch`). The thread it serves, the subject
32
+ * of a handler's per-thread policy, is the one its operation was opened for.
33
+ */
34
+ export type LaunchRequest = {
35
+ readonly program: LaunchProgram;
36
+ /** Absolute: where it starts. */
37
+ readonly workdir: string;
38
+ /** The writable root the protected names are rebuilt for: the thread's working directory for commands. */
39
+ readonly root: string;
40
+ /** Keys the process's temporary directory: `threadScratch(id)` for commands. Equal keys share one directory. */
41
+ readonly scratch: string;
42
+ /** The process's environment: the caller's. */
43
+ readonly environment: SpawnEnvironment;
44
+ /** Aborting it stops the launch: preparation at once, and the process within its stop bound. */
45
+ readonly signal: AbortSignal;
46
+ };
47
+ export type LaunchOptions = {
48
+ readonly timeoutMs?: number;
49
+ readonly killGraceMs: number;
50
+ /** Awaited before the process is released, as `spawnCommand`'s, with the launch it got. */
51
+ readonly beforeRelease?: (pgid: number, launch: LaunchProvenance | null) => Promise<void>;
52
+ };
53
+ /** The program a launch runs when nothing confines it: the argv itself, or `/bin/sh -c` for shell text. */
54
+ export declare function plainArgv(program: LaunchProgram): readonly [string, ...string[]];
55
+ /** A local process to spawn in place of the request's program, from the same stdio form. */
56
+ export type PreparedLaunch = {
57
+ readonly argv: readonly [string, ...string[]];
58
+ readonly cwd: string;
59
+ readonly env: SpawnEnvironment;
60
+ readonly provenance: LaunchProvenance;
61
+ /** After the process ended: bounded report lines, or `null`. Never rejects the process's outcome. */
62
+ violations(): Promise<string | null>;
63
+ };
64
+ /** What a tool does to a path. */
65
+ export type FileAccess = 'read' | 'write';
66
+ /** A path's verdict: allowed, or refused with a message for the model. */
67
+ export type FileVerdict = {
68
+ readonly allowed: true;
69
+ } | {
70
+ readonly allowed: false;
71
+ readonly reason: string;
72
+ };
73
+ /**
74
+ * What a handler lets file tools reach, judged by name over absolute paths and never from the file
75
+ * system: a tool that follows links asks about the path it was given and about where it resolves,
76
+ * and needs both allowed.
77
+ */
78
+ export type FilePolicy = {
79
+ check(path: string, access: FileAccess): FileVerdict;
80
+ /**
81
+ * Names how this policy judges a read: two policies with equal identities answer every read alike.
82
+ * What a reader that shares its result between threads (a catalog of skills) keys it by, so what
83
+ * one thread was allowed to read is never handed to another that was not.
84
+ */
85
+ readonly identity: string;
86
+ };
87
+ /** The `scratch` key of a thread's own processes, which is also the directory its file tools may write besides its root. */
88
+ export declare const threadScratch: (threadId: string) => string;
89
+ /**
90
+ * What one operation's launches are prepared under: the handler's decisions for a thread, taken
91
+ * once, so every launch of the operation gets the same ones whatever changes meanwhile.
92
+ */
93
+ export type ConfinementSnapshot = {
94
+ /** The thread's file policy, the one its launches are confined by; `null` for no path policy at all. */
95
+ readonly files: FilePolicy | null;
96
+ /** Rejects, with a message for the model, to refuse the launch. */
97
+ prepare(request: LaunchRequest): Promise<PreparedLaunch>;
98
+ };
99
+ /** What confines launches, such as the OS sandbox of `@leuduan/lagent/plugins/sandbox`. */
100
+ export type ConfinementHandler = {
101
+ /** Rejects, with a message for the model, to refuse the operation: nothing of it is admitted. */
102
+ snapshot(threadId: string): Promise<ConfinementSnapshot>;
103
+ };
104
+ export type ConfinementHandle = {
105
+ /**
106
+ * Says that what an operation opened from now on would be allowed has changed, such as a thread's
107
+ * mode: content a reader prepared before (`ConfinementService.epoch` then differs from the one it
108
+ * noted) was read under what no longer holds, and is not delivered.
109
+ */
110
+ changed(): void;
111
+ /**
112
+ * Stops admitting through the handler, aborts every launch it prepared, and waits for each one's
113
+ * preparation, process and report within `timeoutMs`. Resolves `true` only when every group was
114
+ * confirmed stopped: no `stopFailed` result, ever, and nothing still running at the bound.
115
+ * Idempotent: every caller shares the first call's result.
116
+ */
117
+ release(timeoutMs: number): Promise<boolean>;
118
+ };
119
+ /**
120
+ * A launched process: its group, what it was launched as, and the handler's report once it ends.
121
+ * A `shell` program is a joined {@link SpawnedCommand}, an `argv` program {@link SpawnedPipes}.
122
+ */
123
+ export type Launched<Spawned extends SpawnedGroup = SpawnedCommand> = {
124
+ /** The actual directory selected for the process, including a confinement handler's choice. */
125
+ readonly cwd: string;
126
+ readonly spawned: Spawned;
127
+ readonly launch: LaunchProvenance | null;
128
+ /** Settles after `spawned.result`, within {@link DIAGNOSTICS_MS}; `null` for nothing to report. Never rejects. */
129
+ readonly diagnostics: Promise<string | null>;
130
+ };
131
+ /** How long after a process ended its report may take. */
132
+ export declare const DIAGNOSTICS_MS = 1000;
133
+ /**
134
+ * What one piece of model-driven work does under confinement: its launches and its file access, all
135
+ * under the one snapshot the operation takes on first use. What `run_command` takes for one command,
136
+ * and what the execution of one tool call is handed (`InvocationContext.operation`).
137
+ */
138
+ export type ConfinementOperation = {
139
+ /** Launches under the operation's snapshot, or plainly when no handler is registered. */
140
+ launch(request: LaunchRequest & {
141
+ program: {
142
+ shell: string;
143
+ };
144
+ }, options: LaunchOptions): Promise<Launched>;
145
+ launch(request: LaunchRequest & {
146
+ program: {
147
+ argv: readonly [string, ...string[]];
148
+ };
149
+ }, options: LaunchOptions): Promise<Launched<SpawnedPipes>>;
150
+ /**
151
+ * File access under the snapshot's {@link FilePolicy}, or none: the one way a tool touches files.
152
+ * Valid until {@link end}.
153
+ */
154
+ readonly files: FileScope;
155
+ /**
156
+ * Ends the file access: calls in flight settle, every handle it opened is closed, and every later
157
+ * use of `files`, or of a handle, fails. Launches are not ended with it: a process has a lifetime
158
+ * of its own. Idempotent.
159
+ */
160
+ end(): Promise<void>;
161
+ };
162
+ /**
163
+ * The confinement seam. With no handler, a launch is a plain spawn: `/bin/sh -c <command>` for shell
164
+ * text, the argv itself for an argv. The first {@link handle} declares for the root's lifetime that
165
+ * launches go through a handler, which decides what each operation gets (confinement, or refusal):
166
+ * from then on an operation with no live handler, because it was released, failed or never mounted
167
+ * again, is refused, and nothing falls back to a plain spawn. A host mounts the handler before
168
+ * anything launches.
169
+ *
170
+ * A handler is told nothing about consumers. It is released as a whole: core aborts what it
171
+ * admitted and reports whether every group stopped, so the handler may then free what confined them.
172
+ */
173
+ export declare class ConfinementService extends Service {
174
+ private readonly root;
175
+ private changes;
176
+ private holdReads;
177
+ constructor(ctx: Context);
178
+ /**
179
+ * Registers the one handler. Throws while another is live. Afterwards, until the root ends, an
180
+ * operation with no live handler is refused.
181
+ */
182
+ handle(handler: ConfinementHandler): ConfinementHandle;
183
+ /**
184
+ * A count of the changes to what an operation would be allowed: a handler registered or released,
185
+ * or one saying so (`ConfinementHandle.changed`). A reader that prepares content ahead of its
186
+ * delivery notes it before it reads, and delivers only if it still reads the same.
187
+ */
188
+ get epoch(): number;
189
+ /**
190
+ * Opens one operation for `threadId`. Nothing happens until it is used: its first launch or file
191
+ * access takes the handler's snapshot, once, which everything the operation does is prepared and
192
+ * checked under, and a refusal (the handler refuses the operation, or has stopped, or the caller's
193
+ * `signal` aborts first) rejects that use with a {@link CommandStartFailure}. With no handler
194
+ * registered the operation launches plainly and its file access has no policy. The caller ends it
195
+ * (`end`) when its call does.
196
+ */
197
+ open(threadId: string, signal: AbortSignal): ConfinementOperation;
198
+ /** The thread and the callers out to its origin root, held loaded; none for a thread the journal does not hold. */
199
+ private retainReads;
200
+ /**
201
+ * For the threads service, which owns what is loaded: how a thread and the histories a snapshot
202
+ * of it reads (its callers out to its origin root) are held loaded while the snapshot is taken;
203
+ * `null` for a thread the journal does not hold. Core's own, so that the dependency runs from
204
+ * threads to confinement. Returns what takes it back.
205
+ */
206
+ holdReadsWith(hold: (threadId: string) => Promise<{
207
+ release(): void;
208
+ } | null>): () => void;
209
+ /** The operation's one snapshot, tracked from before the handler hears of it, or none when no handler is registered. */
210
+ private takeSnapshot;
211
+ private requireLive;
212
+ /** One launch under a snapshot. */
213
+ private launchThrough;
214
+ private spawnPlain;
215
+ private spawnThrough;
216
+ private release;
217
+ /** Whether every operation settled within `timeoutMs` and no stop ever failed. */
218
+ private settle;
219
+ }
@@ -1,17 +1,11 @@
1
1
  import type { Plugin } from '@leuduan/cordis';
2
2
  import type { JournalStore } from '../journal/index.js';
3
- import { type TurnLimits } from '../loop/index.js';
3
+ import { type TurnLimits } from '../state/index.js';
4
4
  export type CoreConfig = {
5
5
  /** The journal's backing, constructed by the application. */
6
6
  store: JournalStore;
7
7
  /** Default `environment.cwd` for new threads; absolute. */
8
8
  cwd: string;
9
- /**
10
- * Absolute application data directory holding each thread's own directory, or `null` for none:
11
- * plugins that need directories then refuse to mount. Required: where to keep files is the
12
- * application's choice.
13
- */
14
- dataDir: string | null;
15
9
  limits?: Partial<TurnLimits>;
16
10
  /**
17
11
  * What becomes of a thread the owner loaded to run once its run lets go: `retire` takes it out of
@@ -28,7 +22,7 @@ export type CoreConfig = {
28
22
  };
29
23
  /**
30
24
  * Mounts the core services on one root: `ctx.journal`, `ctx.llm`, `ctx.agents`, `ctx.tools`,
31
- * `ctx.prompts`, `ctx.threadDirs`, `ctx.launches`, `ctx.presets` and `ctx.threads`. Providers, tools, agents and
25
+ * `ctx.prompts`, `ctx.confinement`, `ctx.presets` and `ctx.threads`. Providers, tools, agents and
32
26
  * capability plugins mount beside it.
33
27
  */
34
28
  export declare const core: Plugin.Object<CoreConfig>;
@@ -1,10 +1,11 @@
1
1
  import type { Context } from '@leuduan/cordis';
2
2
  import type { z } from 'zod';
3
3
  import type { AppendOptions, PluginJournal, PluginProjection } from '../journal/index.js';
4
- import type { ContentPartInput } from '../llm/index.js';
5
- import { type ModelStep, type RowRef } from '../loop/index.js';
6
- import { type AgentSelector } from './scope.js';
7
- import type { ExtensionRecord, InputRole, JournalEvent, Seq, StepContribution } from '../models/index.js';
4
+ import type { ContentPartInput } from '../llm/content.js';
5
+ import { type ModelStep } from '../loop/index.js';
6
+ import { type RowRef } from '../state/index.js';
7
+ import { type AgentSelector } from './agents.js';
8
+ import type { ExtensionRecord, InputRole, JournalEvent, Seq, StepContribution } from '../records/journal.js';
8
9
  import type { ReadonlyState } from '../util/foldState.js';
9
10
  import type { DeepReadonly } from '../util/json.js';
10
11
  export declare class ExtensionVersionError extends Error {
@@ -1,6 +1,6 @@
1
1
  import type { Context, Plugin } from '@leuduan/cordis';
2
2
  import { Journal, type JournalStore } from '../journal/index.js';
3
- import { type TurnLimits } from '../loop/index.js';
3
+ import { type TurnLimits } from '../state/index.js';
4
4
  export type JournalConfig = {
5
5
  /** Durable backing. A store that is already open stays caller-owned. */
6
6
  store: JournalStore;
@@ -1,7 +1,9 @@
1
1
  import { Context, Service } from '@leuduan/cordis';
2
2
  import { z } from 'zod';
3
- import { type LLMProvider, type ModelCallClient, type ModelCapacity, type ModelRoute } from '../llm/index.js';
4
- import { type ModelSelection } from '../loop/index.js';
3
+ import { type ModelCallClient } from '../llm/failure.js';
4
+ import { type LLMProvider, type ModelRoute } from '../llm/provider.js';
5
+ import { type ModelCapacity } from '../llm/client.js';
6
+ import { type ModelSelection } from '../llm/provider.js';
5
7
  /**
6
8
  * How `ctx.llm` retries a provider's failed call, required at registration. `maxAttempts` counts the
7
9
  * first request, so `1` retries nothing. The wait before a retry is exponential from `baseDelayMs`
@@ -1,6 +1,6 @@
1
1
  import type { Context } from '@leuduan/cordis';
2
2
  import type { PluginJournal } from '../journal/index.js';
3
- import type { WriteRows } from '../loop/index.js';
3
+ import type { WriteRows } from '../state/index.js';
4
4
  /** One set of durable modes, as {@link defineModes} takes it. */
5
5
  export type ModesDefinition<Mode extends string> = {
6
6
  /** Names the modes in the journal, so two sets never mix. */
@@ -0,0 +1,34 @@
1
+ import { type Context } from '@leuduan/cordis';
2
+ /**
3
+ * Claims `key`, a thread by its id or by its activation's scope, for the calling plugin within
4
+ * `kind`, for as long as the calling plugin's fiber lives: for a behaviour a thread runs at most
5
+ * once, such as an `AGENTS.md` briefing. `holder` is
6
+ * how a later refusal names this claim. Throws `refusal(holder)` with the holder of a live claim of
7
+ * the same kind on the same key, so the plugin that claimed later fails, and with it the
8
+ * activation, rather than running beside the first. Claims of different kinds never meet.
9
+ *
10
+ * Synchronous: the check and the claim are one step, and the claim is an effect of the caller's
11
+ * fiber, so a release, an unload or a failed setup frees the thread for the next activation.
12
+ */
13
+ export declare function claimThread(ctx: Context, kind: string, key: unknown, holder: string, refusal: (holder: string) => string): void;
14
+ /**
15
+ * Runs `drain` before any owner of `ctx` starts its cleanup, and before the journal's owner does:
16
+ * as an unload guard on every fiber from `ctx` up to the root, and on the fiber that provides the
17
+ * journal. Guards on one fiber run together before its disposers, so every service draining this
18
+ * way is signalled before any of them is awaited, and the journal is still writable for their final
19
+ * rows. `drain` must be idempotent, since several owners can unload, and must not await its own
20
+ * owner's teardown, which waits for the guard.
21
+ */
22
+ export declare function drainBeforeUnload(ctx: Context, drain: () => Promise<void>): void;
23
+ /**
24
+ * The root service `name`, or a refusal naming `user`, the plugin or tool that depends on it, when
25
+ * it is not mounted. Checked where a plugin mounts, so a composition without the service fails
26
+ * there rather than leaving the plugin silently inactive, and looked up again at each call.
27
+ */
28
+ export declare function requireService<K extends string & keyof Context>(ctx: Context, name: K, user: string): NonNullable<Context[K]>;
29
+ /**
30
+ * Refuses a plugin mounted in a thread's scope when `name`, the thing mounted, serves every thread
31
+ * from the application root. The predicate is `scopeOf(ctx) === undefined`: an untagged application
32
+ * context passes, so this is not a root-identity check.
33
+ */
34
+ export declare function requireUnscoped(ctx: Context, name: string): void;
@@ -1,9 +1,9 @@
1
1
  import { type Context, type Fiber, type Inject, type Plugin } from '@leuduan/cordis';
2
2
  import type { z } from 'zod';
3
- import type { InstallationLifetime } from '../models/index.js';
4
- import { type JsonValue } from '../util/json.js';
5
- import { type AgentSelector } from '../kit/scope.js';
6
- import type { Thread } from './thread.js';
3
+ import type { InstallationLifetime } from '../../records/journal.js';
4
+ import { type JsonValue } from '../../util/json.js';
5
+ import { type AgentSelector } from '../agents.js';
6
+ import type { Thread } from '../threads/index.js';
7
7
  /** What a preset's setup is told when it is mounted as one thread's recorded installation. */
8
8
  export type PresetInstallation = {
9
9
  readonly kind: 'installation';
@@ -1,7 +1,7 @@
1
1
  import { Service, type Context, type ScopeKey } from '@leuduan/cordis';
2
- import type { InitialInstallation, Installation, InstallationLifetime } from '../models/index.js';
3
- import { type AnyPreset } from './preset.js';
4
- import type { Thread } from './thread.js';
2
+ import type { InitialInstallation, Installation, InstallationLifetime } from '../../records/journal.js';
3
+ import { type AnyPreset } from './definition.js';
4
+ import type { Thread } from '../threads/index.js';
5
5
  /**
6
6
  * An installation a caller asks for, at creation (as an {@link InitialInstallationInput}) or later
7
7
  * (`Thread.configure`).
@@ -1,8 +1,9 @@
1
1
  import { Context, Service, type ScopeKey } from '@leuduan/cordis';
2
- import type { PromptBlock } from '../llm/index.js';
3
- import type { ToolEntry } from '../loop/index.js';
4
- import type { AgentDefinition, ThreadSummary } from '../models/index.js';
5
- import { type AgentSelector } from '../kit/scope.js';
2
+ import { type PromptBlock } from '../llm/prompt.js';
3
+ import { type ToolEntry } from '../loop/index.js';
4
+ import type { AgentDefinition } from '../loop/index.js';
5
+ import type { ThreadSummary } from '../records/journal.js';
6
+ import { type AgentSelector } from './agents.js';
6
7
  export type PromptSlot = 'base' | 'instruction' | 'context';
7
8
  /**
8
9
  * What a contribution is rendered against: the agent, where the thread works, and the tools it
@@ -11,7 +12,7 @@ export type PromptSlot = 'base' | 'instruction' | 'context';
11
12
  * Deliberately not the thread's id or metadata. A recorded prompt is the head of every request a
12
13
  * provider caches, so it must not depend on which thread it is: threads of one agent in one
13
14
  * workspace then render the same prompt. Anything thread-specific belongs in the conversation, as
14
- * a step contribution (see `workspaceContext`).
15
+ * a step contribution (see `workspaceNotice`).
15
16
  */
16
17
  export type PromptRenderInput = {
17
18
  readonly agent: AgentDefinition;
@@ -65,3 +66,20 @@ export declare class PromptsService extends Service {
65
66
  }
66
67
  /** Registers a contribution in the calling plugin's layer for the lifetime of its fiber. */
67
68
  export declare const contributePrompt: (ctx: Context, contribution: PromptContribution) => (() => void | Promise<void>);
69
+ export type TaggedSection = {
70
+ tag: string;
71
+ content: string;
72
+ };
73
+ /**
74
+ * A prompt as `ctx.prompts` assembles it: the agent's base prompt, then instruction sections, then
75
+ * context sections, so a section's bucket is what decides its position. The rendered result is
76
+ * recorded per thread.
77
+ */
78
+ export type SystemPrompt = {
79
+ basePrompt: string;
80
+ instructions: TaggedSection[];
81
+ contextSections: TaggedSection[];
82
+ };
83
+ /** The prompt as ordered blocks — the one place its order is decided. */
84
+ export declare function systemPromptBlocks(prompt: SystemPrompt): PromptBlock[];
85
+ export declare const renderSystemPrompt: (prompt: SystemPrompt) => string;
@@ -1,9 +1,9 @@
1
1
  import { type Context, type Scope, type Scoped, type ScopeKey } from '@leuduan/cordis';
2
- import { type CompactOptions, type Lease, type LoopServices, type SurfacePrepareOutcome } from '../loop/index.js';
3
- import type { ServedRun } from '../loop/index.js';
2
+ import { type CompactOptions, type Lease, type LoopServices, type SurfacePrepareOutcome } from '../../loop/index.js';
3
+ import type { ServedRun } from '../../loop/index.js';
4
4
  import type { Thread } from './thread.js';
5
5
  import type { AdmissionView } from './admission.js';
6
- import type { ThreadsService } from './threads.js';
6
+ import type { ThreadsService } from './service.js';
7
7
  /**
8
8
  * One process-local activation: the thread's Cordis scope, the plugins mounted in it, their
9
9
  * readiness, and the loop that runs in it. It owns resources, never admission: which operation
@@ -1,5 +1,5 @@
1
- import type { Lease } from '../loop/index.js';
2
- import type { CancelIntent, InboxTarget } from '../models/index.js';
1
+ import type { Lease } from '../../loop/index.js';
2
+ import type { CancelIntent, InboxTarget } from '../../records/journal.js';
3
3
  /**
4
4
  * An exclusive operation on one thread; see `Admission.onOperation`. A `cancel` holds the thread from a
5
5
  * `cancel()` until its write has landed and what it cancelled has released the thread.
@@ -62,7 +62,7 @@ export type CancelHandle = {
62
62
  /**
63
63
  * The one owner of which operation holds each thread: admission or refusal, the releasing phase,
64
64
  * cancellation, and the publication of admission and settlement in the order
65
- * docs/lifecycle.md#ordering states. It knows nothing of activations; the threads service runs
65
+ * docs/guides/threads.md#ordering states. It knows nothing of activations; the threads service runs
66
66
  * each operation's work, and disposes activations under it, through `hold`.
67
67
  */
68
68
  export declare class Admission {
@@ -1,10 +1,11 @@
1
- import { type ModelRoute } from '../llm/index.js';
2
- import type { Journal } from '../journal/index.js';
3
- import { type BirthConflict, type BirthSpec, type ForkOpening, type FreshOpening, type RowRef, type WriteRows } from '../loop/index.js';
4
- import type { InitialInstallation, Installation, JournalEventInput, Seq, ThreadEnvironment, ThreadInput, ThreadOrigin, ThreadSummary } from '../models/index.js';
5
- import type { Wake } from '../loop/index.js';
6
- import { type DeepReadonly, type ReadonlyJsonValue } from '../util/json.js';
7
- import type { InitialInstallationInput, PresetsService } from './presets.js';
1
+ import { type ModelRoute } from '../../llm/provider.js';
2
+ import type { Journal } from '../../journal/index.js';
3
+ import { type BirthConflict } from '../../loop/index.js';
4
+ import { type BirthSpec, type ForkOpening, type FreshOpening, type RowRef, type WriteRows } from '../../state/index.js';
5
+ import type { InitialInstallation, Installation, JournalEventInput, Seq, ThreadEnvironment, ThreadInput, ThreadOrigin, ThreadSummary } from '../../records/journal.js';
6
+ import type { Wake } from '../../state/index.js';
7
+ import { type DeepReadonly, type ReadonlyJsonValue } from '../../util/json.js';
8
+ import type { InitialInstallationInput, PresetsService } from '../presets/installations.js';
8
9
  /**
9
10
  * What must match when a creation or fork finds its id taken: `identity` is the thread's agent,
10
11
  * origin and whether it is a fork, and for a fork its cut; `configuration` also compares the
@@ -49,7 +50,7 @@ export type BirthInput<I> = {
49
50
  route: ModelRoute;
50
51
  /**
51
52
  * Where the thread's work happens, field by field. An omitted field is the default: the root's
52
- * `cwd` and no read roots, or with `caller` the caller's. The cwd and every read root must be absolute.
53
+ * `cwd`, or with `caller` the caller's. The cwd must be absolute.
53
54
  */
54
55
  environment?: Partial<DeepReadonly<ThreadEnvironment>>;
55
56
  /**
@@ -169,8 +170,6 @@ export type ResolvedOpening = {
169
170
  readonly kind: 'fork';
170
171
  readonly opening: ForkOpening;
171
172
  };
172
- /** Read roots as a spawn row records them: each normalized, once, in the order given. A relative one is refused. */
173
- export declare function readRoots(roots: readonly string[]): string[];
174
173
  /** Constraint owners as a spawn row records them: a set, sorted and without repeats. */
175
174
  export declare const canonicalRequires: (requires: readonly string[] | undefined) => string[];
176
175
  /**
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What the rest of the package uses of `services/threads/`: the thread handle and its read view, run
3
+ * events, run-owner registration and the creation and fork shapes. Code outside this folder imports
4
+ * from here; `admission.ts`, `activation.ts` and the run owner's internals stay private to it.
5
+ */
6
+ export { ThreadsService } from './service.js';
7
+ export type { ConfigurationChange, ConfigurationResult, RetainOptions, RetainedMembers, Retention, ThreadFilter, Threads, ThreadsConfig, } from './service.js';
8
+ export type { Thread } from './thread.js';
9
+ export type { CancelOptions, ConfirmationAnswer } from './thread.js';
10
+ export type { ThreadView } from './view.js';
11
+ export type { BirthChoice, BirthInput, CreateThreadOptions, ForkCut, ForkOptions, Opening, Reuse } from './birth.js';
12
+ export type { MissingDetail, OwnerHandle, OwnerReadiness, OwnerRegistration, StartOptions, StartupPolicy, ThreadInspection, WaitResolution, WaitValue, } from './runOwner.js';
13
+ export { UnknownRunError, heldOrSettled, waitForRun } from './runEvents.js';
14
+ export type { RunEvent, RunSource, RunState } from './runEvents.js';
@@ -1,5 +1,5 @@
1
- import type { RunOutcomeKind, RunSettledReason } from '../models/index.js';
2
- import type { DurableRunState, Hold, HoldBasis } from '../loop/index.js';
1
+ import type { RunOutcomeKind, RunSettledReason } from '../../records/journal.js';
2
+ import type { DurableRunState, Hold, HoldBasis } from '../../state/index.js';
3
3
  /**
4
4
  * Where one run request stands, as its waiters see it: waiting to be admitted (`requested`), with
5
5
  * an execution serving it (`running`, finalization included), held with the request still pending,
@@ -1,7 +1,8 @@
1
- import type { JsonValue, Seq, ThreadSummary } from '../models/index.js';
2
- import type { ReadonlyJsonValue } from '../util/json.js';
3
- import { type Continuation, type ConstraintAnswer, type DecisionTurn, type Hold, type HoldBasis, type TurnLimits, type WaitDeclaration } from '../loop/index.js';
4
- import type { Journal, OriginBreak } from '../journal/index.js';
1
+ import type { Seq, ThreadSummary } from '../../records/journal.js';
2
+ import type { JsonValue } from '../../util/json.js';
3
+ import type { ReadonlyJsonValue } from '../../util/json.js';
4
+ import { type Continuation, type ConstraintAnswer, type DecisionTurn, type Hold, type HoldBasis, type TurnLimits, type WaitDeclaration } from '../../state/index.js';
5
+ import type { Journal, OriginBreak } from '../../journal/index.js';
5
6
  import type { Admission, AdmittedOperation, OperationKind } from './admission.js';
6
7
  import { type RunEvent, type RunState } from './runEvents.js';
7
8
  /**
@@ -1,15 +1,16 @@
1
1
  import { Context, Service, type ScopeKey } from '@leuduan/cordis';
2
- import type { PromptBlock } from '../llm/index.js';
3
- import type { ChainStanding, CompactOptions, ConfirmationState, RouteAuthority, StreamedChunk, SurfacePrepareOutcome, Target, TurnLimits, BirthConflict, BirthSpec, HoldBasis } from '../loop/index.js';
4
- import { ChunkChannel } from '../loop/index.js';
5
- import type { ThreadOrigin } from '../models/index.js';
6
- import { type DeepReadonly } from '../util/json.js';
7
- import { type OwnerHandle, type OwnerRegistration, type StartOptions, type ThreadInspection } from './owner.js';
2
+ import type { PromptBlock } from '../../llm/prompt.js';
3
+ import type { ChainStanding, ConfirmationState, RouteAuthority, Target, TurnLimits, BirthSpec, HoldBasis } from '../../state/index.js';
4
+ import type { CompactOptions, StreamedChunk, SurfacePrepareOutcome, BirthConflict } from '../../loop/index.js';
5
+ import { ChunkChannel } from '../../loop/index.js';
6
+ import type { ThreadOrigin } from '../../records/journal.js';
7
+ import { type DeepReadonly } from '../../util/json.js';
8
+ import { type OwnerHandle, type OwnerRegistration, type StartOptions, type ThreadInspection } from './runOwner.js';
8
9
  import type { RunEvent, RunState } from './runEvents.js';
9
- import type { InstallationInput } from './presets.js';
10
+ import type { InstallationInput } from '../presets/installations.js';
10
11
  import { type CreateThreadOptions, type ForkOptions } from './birth.js';
11
12
  import { Thread } from './thread.js';
12
- import { ThreadView } from './threadView.js';
13
+ import { ThreadView } from './view.js';
13
14
  export type ThreadsConfig = {
14
15
  /** Default `environment.cwd` for threads created without one; absolute. */
15
16
  cwd: string;
@@ -1,13 +1,14 @@
1
1
  import type { Context } from '@leuduan/cordis';
2
- import type { AppendEntry, Journal } from '../journal/index.js';
3
- import type { PromptBlock } from '../llm/index.js';
4
- import type { CompactOptions, RouteStatement, RowRef, SendOptions, SendOutcome, StreamedChunk, SurfacePrepareOutcome, WithdrawOptions, WithdrawOutcome } from '../loop/index.js';
5
- import type { CancelIntent, JournalEvent, ThreadInput, ThreadOrigin, ThreadSummary, TurnEndReason } from '../models/index.js';
6
- import type { DeepReadonly } from '../util/json.js';
2
+ import type { AppendEntry, Journal } from '../../journal/index.js';
3
+ import type { PromptBlock } from '../../llm/prompt.js';
4
+ import type { CompactOptions, StreamedChunk, SurfacePrepareOutcome } from '../../loop/index.js';
5
+ import type { RouteStatement, RowRef, SendOptions, SendOutcome, WithdrawOptions, WithdrawOutcome } from '../../state/index.js';
6
+ import type { CancelIntent, JournalEvent, ThreadInput, ThreadOrigin, ThreadSummary, TurnEndReason } from '../../records/journal.js';
7
+ import type { DeepReadonly } from '../../util/json.js';
7
8
  import type { AdmissionView } from './admission.js';
8
9
  import type { ForkOptions } from './birth.js';
9
- import type { ConfigurationChange, ConfigurationResult, ThreadsService } from './threads.js';
10
- import type { ThreadView } from './threadView.js';
10
+ import type { ConfigurationChange, ConfigurationResult, ThreadsService } from './service.js';
11
+ import type { ThreadView } from './view.js';
11
12
  /** One answer to a parked confirmation. */
12
13
  export type ConfirmationAnswer = {
13
14
  request_id: string;
@@ -1,9 +1,10 @@
1
- import type { ConversationMessage, PromptBlock, ToolSpec } from '../llm/index.js';
2
- import type { ConfirmationState, ForkPoint, InputFate, InstallationRecord, RowRef, RunOutcome, Target, WaitEntry } from '../loop/index.js';
3
- import type { JournalEvent, QueuedInput, Seq } from '../models/index.js';
4
- import type { DeepReadonly } from '../util/json.js';
5
- import type { Journal } from '../journal/index.js';
6
- import type { ReadonlyState } from '../util/foldState.js';
1
+ import type { ConversationMessage, ToolSpec } from '../../llm/primitives.js';
2
+ import type { PromptBlock } from '../../llm/prompt.js';
3
+ import type { ConfirmationState, ForkPoint, InputFate, InstallationRecord, RowRef, RunOutcome, Target, WaitEntry } from '../../state/index.js';
4
+ import type { JournalEvent, QueuedInput, Seq } from '../../records/journal.js';
5
+ import type { DeepReadonly } from '../../util/json.js';
6
+ import type { Journal } from '../../journal/index.js';
7
+ import type { ReadonlyState } from '../../util/foldState.js';
7
8
  /**
8
9
  * What one thread's folds say, read synchronously (`ctx.threads.view`, `thread.read`): valid while
9
10
  * something holds the thread in memory — a journal write or a contributor running for it, a run, a