@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,17 @@
1
+ import type { ModelRoute } from '../llm/provider.js';
2
+ import type { Seq, ThreadEnvironment } from '../records/journal.js';
3
+ import type { CompletionRequest } from './hooks.js';
4
+ import type { LoopRuntime } from './runtime.js';
5
+ /** Dispatches a pure completion plan once, under its candidate's durable identity and current policy. */
6
+ export declare function prepareCompletion(options: {
7
+ runtime: LoopRuntime;
8
+ threadId: string;
9
+ agentName: string;
10
+ environment: ThreadEnvironment;
11
+ route: ModelRoute;
12
+ turn: number;
13
+ candidateSeq: Seq;
14
+ request: CompletionRequest;
15
+ signal: AbortSignal;
16
+ validate(): void;
17
+ }): Promise<'settled' | 'blocked'>;
@@ -1,6 +1,5 @@
1
1
  import type { ReadonlyJsonValue } from '../util/json.js';
2
- import type { Refusal } from './inbox.js';
3
- import type { ReplacementRule, RowRef } from './surface.js';
2
+ import type { Refusal, RowRef } from '../state/index.js';
4
3
  /** What holds a thread while an operation on it is refused busy. */
5
4
  export type ThreadHolding = 'run' | 'compact' | 'rebuild' | 'configure' | 'release' | 'cancel';
6
5
  /** A human's answer to an approval request. */
@@ -13,12 +12,10 @@ export declare class UnknownAgentError extends ReferenceError {
13
12
  readonly agentName: string;
14
13
  constructor(agentName: string);
15
14
  }
16
- /** No thread has this id. */
17
- export declare class UnknownThreadError extends ReferenceError {
18
- readonly threadId: string;
19
- constructor(threadId: string);
20
- }
21
- /** A turn is already running on this thread; one driver at a time. */
15
+ /**
16
+ * An operation already holds this thread: a run, compaction, prompt rebuild, configuration change,
17
+ * release or cancel (`holding`), admitted one at a time.
18
+ */
22
19
  export declare class ThreadBusyError extends Error {
23
20
  readonly threadId: string;
24
21
  readonly holding?: ThreadHolding;
@@ -48,7 +45,7 @@ export declare class StaleActivation extends Error {
48
45
  constructor();
49
46
  }
50
47
  /**
51
- * Thrown by a judgment whose fence broke while the activation stayed valid (`LoopAgent.fenced`): a
48
+ * Thrown by a judgment whose fence broke while the activation stayed valid (`TurnRunner.fenced`): a
52
49
  * required registration is gone or was replaced, or a fact a stop check declared it observed
53
50
  * changed. The turn ends `interrupted` (`judgment-invalidated`), the answer still owed its checks.
54
51
  */
@@ -60,12 +57,6 @@ export declare class RecordedTurnFailure extends Error {
60
57
  readonly cause: unknown;
61
58
  constructor(cause: unknown);
62
59
  }
63
- /** A fork was asked for at a row it cannot be cut at; nothing was appended. */
64
- export declare class ForkCutError extends Error {
65
- readonly threadId: string;
66
- readonly seq: number;
67
- constructor(threadId: string, seq: number, reason: string);
68
- }
69
60
  /** What a thread's recorded birth says about one field of a request that differs from it. */
70
61
  export type BirthConflict = {
71
62
  readonly field: 'agent' | 'origin' | 'kind' | 'cut' | 'route' | 'environment' | 'installations' | 'requires';
@@ -123,20 +114,6 @@ export declare class ThreadUnsettledError extends Error {
123
114
  readonly threadId: string;
124
115
  constructor(threadId: string, reason: string);
125
116
  }
126
- /**
127
- * A replacement `replaceSurface` refused: it breaks a rule of the surface it would land on (see
128
- * `judgeReplacement`). Nothing of its group was recorded. Distinct from any other failure, so a
129
- * strategy can tell a plan the surface refused from a journal that could not write.
130
- */
131
- export declare class ReplacementRefusedError extends Error {
132
- readonly index: number;
133
- readonly rule: ReplacementRule;
134
- constructor(message: string,
135
- /** The refused replacement's position in the group it was offered with. */
136
- index: number,
137
- /** The surface rule it breaks. */
138
- rule: ReplacementRule);
139
- }
140
117
  /**
141
118
  * A thread whose surface refused a replacement row, one written past `replaceSurface`: a bug or a
142
119
  * hand-edited store. Its history can be read, and forked before that row, but nothing executes on
@@ -1,7 +1,12 @@
1
- import type { AgentDefinition, ExtensionRecord, JournalEvent, JournalEventInput, QueuedInput, Seq, StepContribution, StepContributionInput, TurnRejection } from '../models/index.js';
2
- import type { ModelCallClient, ModelRequest, ModelRoute, ParsedToolCall, RequestPurpose, ResponseFinish, StreamingLLMResponse, ThinkingEffort } from '../llm/index.js';
1
+ import type { AgentDefinition } from './agent.js';
2
+ import type { ExtensionRecord, JournalEvent, JournalEventInput, QueuedInput, Seq, StepContribution, StepContributionInput, TurnRejection } from '../records/journal.js';
3
+ import type { ModelCallClient } from '../llm/failure.js';
4
+ import type { JsonObject, ParsedToolCall, ResponseFinish, ThinkingEffort } from '../llm/primitives.js';
5
+ import type { ModelRequest, RequestPurpose } from '../llm/request.js';
6
+ import type { ModelRoute } from '../llm/provider.js';
7
+ import type { StreamingLLMResponse } from '../llm/client.js';
3
8
  import type { LoopRuntime } from './runtime.js';
4
- import type { RowRef } from './surface.js';
9
+ import type { RowRef } from '../state/index.js';
5
10
  import type { InvocationContext, Tool, ToolOutcome } from './tool.js';
6
11
  /**
7
12
  * Every point at which the loop hands control to a plugin.
@@ -24,6 +29,12 @@ export interface ToolAuthorizationRequest {
24
29
  readonly toolCall: ParsedToolCall;
25
30
  readonly agent: AgentDefinition;
26
31
  readonly threadId: string;
32
+ /** Runtime provenance is explicit; an absent origin is an ordinary model tool call. */
33
+ readonly origin?: {
34
+ readonly owner: string;
35
+ readonly candidateSeq: Seq;
36
+ readonly requestSeq: Seq;
37
+ };
27
38
  }
28
39
  /** A denial that tells the model why, so it can change course rather than retry the call. */
29
40
  export interface ToolDenial {
@@ -147,6 +158,18 @@ export type StopVerdict = {
147
158
  decision: 'reject';
148
159
  reason: string;
149
160
  source: ExtensionRecord;
161
+ } | {
162
+ decision: 'prepare';
163
+ request: CompletionRequest;
164
+ };
165
+ /** A pure plan. Core owns its durable dispatch after every stop check permits preparation. */
166
+ export type CompletionRequest = {
167
+ readonly owner: string;
168
+ readonly key: string;
169
+ readonly operation: {
170
+ readonly name: string;
171
+ readonly arguments: JsonObject;
172
+ };
150
173
  };
151
174
  /** What the checks concluded together. */
152
175
  export type StopJudgement = {
@@ -157,16 +180,26 @@ export type StopJudgement = {
157
180
  } | {
158
181
  kind: 'reject';
159
182
  rejections: TurnRejection[];
183
+ } | {
184
+ kind: 'prepare';
185
+ requests: CompletionRequest[];
160
186
  };
161
187
  /**
162
188
  * Asks every stop check about an answer. The outcome is independent of registration order: any
163
- * rejection ends the turn, otherwise any continuation sends the model back, otherwise the answer
164
- * is accepted. A throwing check, or an invalid verdict, fails the check without deciding anything.
189
+ * rejection ends the turn, otherwise any continuation sends the model back, otherwise a preparation
190
+ * plan runs before rejudgment, otherwise the answer is accepted. A throwing check, or an invalid
191
+ * verdict, fails the check without deciding anything.
165
192
  * The facts the checks declare they observed collect in `observations`, which the caller validates
166
193
  * when it records the outcome.
167
194
  */
168
195
  export declare function judgeAnswer(runtime: LoopRuntime, stop: Omit<TurnStop, 'observe'>, observations: StopObservation[]): Promise<StopJudgement>;
169
- /** Runs a tool through its listeners. One that does not call `next()` has answered the call itself. */
196
+ /**
197
+ * Runs `use` with the confinement operation of one tool execution, opened for it and ended when it
198
+ * settles, whatever it did: the file access its tool was given dies with the call, and what it still
199
+ * had open is closed.
200
+ */
201
+ export declare function withOperation<T>(runtime: LoopRuntime, threadId: string, signal: AbortSignal, use: (operation: InvocationContext['operation']) => Promise<T>): Promise<T>;
202
+ /** Runs middleware and binds its final result to the dispatched call, for every execution path. */
170
203
  export declare const executeTool: (runtime: LoopRuntime, invocation: ToolInvocation, run: () => Promise<ToolOutcome>) => Promise<ToolOutcome>;
171
204
  /**
172
205
  * A model request as `lagent/llm/request` middleware sees it. The turn's route is fixed, so `model`
@@ -1,37 +1,16 @@
1
1
  /**
2
- * What the rest of the package may use from the loop.
3
- *
4
- * Journal operations (projections, inbox, recovery) need no execution runtime. A live thread
5
- * activation drives execution through LoopAgent; plugins extend it through tools and hooks.
2
+ * What the rest of the package may use from the loop: live execution against an activation. A live
3
+ * thread activation drives execution through TurnRunner; plugins extend it through tools and hooks.
4
+ * What the journal records, without a runtime, is `state/`.
6
5
  */
7
- export * from './projections.js';
8
- export * from './surface.js';
9
- export * from './threadState.js';
10
6
  export * from './chunks.js';
11
7
  export * from './errors.js';
12
- export * from './limits.js';
13
8
  export * from './runtime.js';
14
- export { Inbox } from './inbox.js';
15
- export { isVeto } from './inbox.js';
16
- export type { BirthSpec, ForkOpening, FreshOpening } from './opening.js';
17
- export type { Refusal, RowsResult, RowsWrite, InputReceipt, SendOptions, SendOutcome, WithdrawOptions, WithdrawOutcome, WithdrawRows, WriteRows, } from './inbox.js';
18
- export { closeInterruptedTurn, hasThreadWork, inputFate, lastAssistantMessage, refusedReplacement, unfinishedConfirmations, } from './state.js';
19
- export type { InputFate } from './state.js';
20
- export * from './summary.js';
21
- export * from './requests.js';
22
- export { chainStanding } from './chain.js';
23
- export type { ChainStanding } from './chain.js';
24
- export * from './wake.js';
25
- export * from './route.js';
26
- export * from './holds.js';
27
- export * from './continuation.js';
28
- export * from './forks.js';
29
9
  export * from './hooks.js';
30
10
  export type { AuxiliaryCall, AuxiliaryReply } from './auxiliary.js';
31
- export { replaceSurface } from './replace.js';
32
- export type { ReplacementContext, ReplacementInput } from './replace.js';
11
+ export * from './agent.js';
33
12
  export * from './strategy.js';
34
13
  export * from './tool.js';
35
- export { declarePolicyState, errorResult } from './toolCalls.js';
36
- export { LoopAgent } from './agent.js';
37
- export type { CompactOptions, ServedRun } from './agent.js';
14
+ export { declarePolicyState } from './authorization.js';
15
+ export { TurnRunner } from './runner.js';
16
+ export type { CompactOptions, ServedRun } from './runner.js';
@@ -0,0 +1,134 @@
1
+ import type { Seq, TurnEndReason } from '../records/journal.js';
2
+ import type { DeepReadonly, JsonValue } from '../util/json.js';
3
+ import type { SurfacePrepareOutcome } from './hooks.js';
4
+ import type { Lease, LoopRuntime } from './runtime.js';
5
+ /**
6
+ * What one `compact()` is given: a cancellation signal, and options for the strategy, which the
7
+ * engine passes on as they are and never reads.
8
+ */
9
+ export type CompactOptions = {
10
+ readonly signal?: AbortSignal;
11
+ readonly options?: JsonValue;
12
+ };
13
+ /**
14
+ * The run request an execution serves, as its turns see it: the id every `turn/start` records, the
15
+ * attempt cutoff of the execution, and the continuation decision, asked after each turn whether to
16
+ * open another.
17
+ */
18
+ export type ServedRun = {
19
+ readonly id: string;
20
+ readonly attemptCutoff: Seq;
21
+ continueAfter(ending: DeepReadonly<TurnEndReason>, turnStart: Seq): boolean;
22
+ };
23
+ /** Executes journal-driven turns. Admission, readiness and cancellation ownership live outside the loop. */
24
+ export declare class TurnRunner {
25
+ private readonly runtime;
26
+ private readonly threadId;
27
+ private readonly agentName;
28
+ private readonly inbox;
29
+ constructor(options: {
30
+ runtime: LoopRuntime;
31
+ threadId: string;
32
+ agentName: string;
33
+ });
34
+ private stepsTaken;
35
+ /**
36
+ * The caller already owns the lease, has resolved the agent in a ready runtime, has decided the
37
+ * run should advance, and supplies a combined turn signal and the run it serves. Opens a turn,
38
+ * then another for as long as the run's continuation decision says to advance.
39
+ */
40
+ run(options: {
41
+ signal: AbortSignal;
42
+ lease: Lease;
43
+ served: ServedRun;
44
+ }): Promise<void>;
45
+ /**
46
+ * One turn: decide, do it, append what happened, decide again.
47
+ *
48
+ * Every branch of the decision lives in {@link nextAction}; this only carries out what it asked
49
+ * for.
50
+ */
51
+ private turn;
52
+ /**
53
+ * Why a judgment made under `fence` may not stand, or `null` when it does. `activation-changed`:
54
+ * the activation's plugins changed since readiness, and takes precedence. `judgment-invalidated`:
55
+ * the constraint registrations the thread requires, by origin too, are not those it was judged
56
+ * under, one missing or replaced, or a fact a check declared it observed reads differently now.
57
+ * Such a registration's owner, or a plugin of the activation, can be the checker that would
58
+ * object, and core accepts whatever no check objects to; one that came back meanwhile did not
59
+ * judge it; and a verdict resting on a fact that moved while another check awaited is no verdict
60
+ * on the answer as it stands. Read inside the write that records the judgment.
61
+ */
62
+ private fenced;
63
+ /**
64
+ * Records how a judged turn ends, `ending` the checks' verdict or their failure, decided inside
65
+ * the write: one whose fence broke ends the turn `interrupted` instead, the answer still owed its
66
+ * checks, so a later run judges it again, held while a required owner is missing, rather than
67
+ * accepting it unchecked or failing the task because its checker was briefly gone or a fact it
68
+ * read moved. Returns the reason recorded.
69
+ */
70
+ private endJudged;
71
+ /**
72
+ * Records `turn/start` with the thread's route and the run the turn serves, decided in the write's
73
+ * builder, the turn's opening point: a cancel that landed while the loop awaited opens nothing,
74
+ * and a route whose provider is not registered opens nothing either, claims no input, and throws
75
+ * `RouteUnavailableError`, which fails the run before the turn. A provider lost once the row is
76
+ * built, its append still waiting on storage included, fails the opened turn.
77
+ *
78
+ * The route is the turn's for good, since every model step builds its client from it; it cannot
79
+ * change under an execution, which holds the thread while its request is pending.
80
+ */
81
+ private openTurn;
82
+ /** The thread's route as its rows stand. */
83
+ private threadRoute;
84
+ /**
85
+ * Asks the thread's strategy for a plan for a caller between turns (the `request` trigger): no turn
86
+ * opens, no step hook runs and no queued input is claimed; the route is resolved as a turn's would
87
+ * be. The caller owns the lease, as for a run, and composed the signal as a run's is. An
88
+ * interrupted open turn is closed first, as a run closes it; a thread with a tool call unanswered,
89
+ * a confirmation open or an answer unjudged is refused with `ThreadUnsettledError`. Resolves with
90
+ * the outcome, cancellation included.
91
+ */
92
+ compact(options: {
93
+ signal: AbortSignal;
94
+ lease: Lease;
95
+ options: JsonValue | null;
96
+ }): Promise<SurfacePrepareOutcome>;
97
+ /** One request to the thread's strategy, carried out by the engine. */
98
+ private prepare;
99
+ /**
100
+ * Asks the stop checks about the provisional answer. Returns how the turn ends — accepted as
101
+ * `completed`, or `rejected` — or `null` once their continuation messages are recorded.
102
+ *
103
+ * An acceptance ends the turn at once. Steering that arrived while the checks ran is still in the
104
+ * `next-step` inbox, and `run()` opens another turn for it.
105
+ */
106
+ private judge;
107
+ /**
108
+ * Lets the surface be prepared (`pressure`), then records plugin contributions and the claimed
109
+ * input, then asks the model.
110
+ *
111
+ * The dispatch is the first `await` between deciding this step and recording its input, and the
112
+ * lease does not exclude `send()` or `withdraw()`. So once it settles the signal is checked and the
113
+ * inbox read again: only input this step was decided on that is still queued is claimed, so a
114
+ * withdrawn input stays withdrawn, and input that arrived meanwhile waits for the next step. A step
115
+ * left with nothing to claim and no reply owed ends without a model call, and the decider decides
116
+ * again.
117
+ */
118
+ private askModel;
119
+ /** Reports a dispatch a listener ended in failure; one that was cancelled is the turn's to report. */
120
+ private reportFailedDispatch;
121
+ /** Runs a step's tool calls. What they did — answered, waited, ended the turn — lands in the journal. */
122
+ private answerCalls;
123
+ /**
124
+ * One model call. What it produced goes to the journal — `assistant/message`, or
125
+ * `assistant/attempt` when the stream gave nothing usable, which keeps it off the conversation.
126
+ *
127
+ * A request the provider refused as longer than the context window is recorded as an attempt
128
+ * marked `overflow`, and the thread's strategy is asked with `overflow` inside this step, before
129
+ * any `error` row. The rule is one sentence: an overflow fails the turn unless that request
130
+ * committed a replacement, however it ended. When it did, the step ends without an error and the
131
+ * decider asks the model again, from the replaced surface, in a new step.
132
+ */
133
+ private callModel;
134
+ }
@@ -1,13 +1,15 @@
1
1
  import type { Context, Scoped } from '@leuduan/cordis';
2
- import type { ModelCallClient, ModelRoute, ThinkingEffort, ToolSpec } from '../llm/index.js';
2
+ import type { ModelCallClient } from '../llm/failure.js';
3
+ import type { ModelRoute, ModelSelection } from '../llm/provider.js';
4
+ import type { ToolSpec } from '../llm/primitives.js';
3
5
  import type { DeepReadonly } from '../util/json.js';
4
6
  import type { Journal } from '../journal/index.js';
5
- import type { AgentDefinition } from '../models/index.js';
7
+ import type { AgentDefinition } from './agent.js';
6
8
  import type { ChunkChannel } from './chunks.js';
7
- import type { TurnLimits } from './limits.js';
9
+ import type { TurnLimits } from '../state/index.js';
8
10
  import type { SurfaceStrategy } from './strategy.js';
9
11
  import type { Tool } from './tool.js';
10
- /** Anything advertised to the model — a builtin tool or a sub-agent. */
12
+ /** Anything advertised to the model — a registered tool or a sub-agent. */
11
13
  export type ToolEntry = {
12
14
  readonly name: string;
13
15
  readonly tool: Tool;
@@ -17,17 +19,6 @@ export type ToolEntry = {
17
19
  */
18
20
  readonly spec: DeepReadonly<ToolSpec>;
19
21
  };
20
- /**
21
- * Route fields to fold over a route (`LlmService.resolveRoute`): absent fields keep the route's own;
22
- * naming a different provider resets what is left unnamed to that provider's defaults. A `null`
23
- * effort names the provider's own default, as a route records it, so a complete route resolves to
24
- * itself.
25
- */
26
- export type ModelSelection = {
27
- readonly provider?: string;
28
- readonly model?: string;
29
- readonly thinkingEffort?: ThinkingEffort | null;
30
- };
31
22
  /**
32
23
  * What the loop runs against.
33
24
  *
@@ -72,7 +63,7 @@ export interface LoopRuntime extends LoopServices {
72
63
  * new once they have, and ends the turn as `interrupted` at its next boundary.
73
64
  */
74
65
  stale(): boolean;
75
- /** The strategy that prepares the thread's surface, if one is provided (`provideStrategy`). */
66
+ /** The strategy that prepares the thread's surface, if one is provided (`registerSurfaceStrategy`). */
76
67
  strategy(): SurfaceStrategy | undefined;
77
68
  }
78
69
  /**
@@ -1,8 +1,9 @@
1
- import type { ExtensionRecord, QueuedInput, ReplacementTrigger } from '../models/index.js';
1
+ import type { Context } from '@leuduan/cordis';
2
+ import type { ExtensionRecord, QueuedInput, ReplacementTrigger } from '../records/journal.js';
2
3
  import type { JsonValue } from '../util/json.js';
3
- import type { ModelRoute } from '../llm/index.js';
4
+ import type { ModelRoute } from '../llm/provider.js';
4
5
  import type { AuxiliaryCall, AuxiliaryReply } from './auxiliary.js';
5
- import type { ReplacementInput } from './replace.js';
6
+ import type { ReplacementInput } from '../state/index.js';
6
7
  /** What a strategy is told about one request to prepare the surface. */
7
8
  export type SurfacePrepareInput = {
8
9
  readonly threadId: string;
@@ -69,3 +70,11 @@ export interface SurfaceStrategy {
69
70
  readonly name: string;
70
71
  plan(input: SurfacePrepareInput): SurfacePlan | Promise<SurfacePlan>;
71
72
  }
73
+ /**
74
+ * Makes `strategy` the one that prepares `threadId`'s surface, for as long as the calling plugin's
75
+ * fiber lives. A thread runs one strategy: a second, from another mount or installation, throws, so
76
+ * the plugin that came later fails, and with it the activation, rather than running beside the first.
77
+ */
78
+ export declare function registerSurfaceStrategy(ctx: Context, threadId: string, strategy: SurfaceStrategy): void;
79
+ /** The strategy that prepares `threadId`'s surface, if any. */
80
+ export declare function strategyOf(ctx: Context, threadId: string): SurfaceStrategy | undefined;
@@ -1,6 +1,6 @@
1
- import type { QueuedInput, ReplacementTrigger } from '../models/index.js';
1
+ import type { QueuedInput, ReplacementTrigger } from '../records/journal.js';
2
2
  import type { JsonValue } from '../util/json.js';
3
- import { type ModelRoute } from '../llm/index.js';
3
+ import { type ModelRoute } from '../llm/provider.js';
4
4
  import type { SurfacePrepareOutcome } from './hooks.js';
5
5
  import type { Lease, LoopRuntime } from './runtime.js';
6
6
  /** One request to prepare the surface, as the loop or `thread.compact()` starts it. */
@@ -1,7 +1,12 @@
1
1
  import type { Context } from '@leuduan/cordis';
2
- import type { InterruptionPolicy, JsonValue, Seq, ThreadEnvironment, ToolResult } from '../models/index.js';
2
+ import type { InterruptionPolicy, Seq, ThreadEnvironment } from '../records/journal.js';
3
+ import type { JsonValue } from '../util/json.js';
4
+ import type { ToolResult } from '../records/toolResult.js';
3
5
  import type { ReadonlyJsonValue } from '../util/json.js';
4
- import type { ModelRoute, ParsedToolCall, ToolSpec } from '../llm/index.js';
6
+ import type { ModelRoute } from '../llm/provider.js';
7
+ import type { ParsedToolCall, ToolCall, ToolSpec } from '../llm/primitives.js';
8
+ /** An error result answering the dispatched call. */
9
+ export declare const errorResult: (call: ToolCall, output: string) => ToolResult;
5
10
  /**
6
11
  * How a tool's calls may overlap. `exclusive` forms a barrier: it starts only once the calls before
7
12
  * it have settled, and nothing starts beside it.
@@ -39,7 +44,7 @@ export type ResolvedWait = {
39
44
  };
40
45
  };
41
46
  /**
42
- * What a tool implements. `defineTool` in `kit/tool.ts` builds one, with validation and timing; this
47
+ * What a tool implements. `defineTool` in `services/tools.ts` builds one, with validation and timing; this
43
48
  * is the contract underneath it.
44
49
  */
45
50
  export interface Tool {
@@ -75,14 +80,14 @@ export interface InvocationContext {
75
80
  readonly threadId: string;
76
81
  readonly callId: string;
77
82
  /**
78
- * The `tool/call` row this invocation answers. The durable identity of the dispatch: unique in the
79
- * journal and kept across a re-dispatch, where a provider's `callId` may be neither.
83
+ * The `tool/call` or runtime `execution/requested` row this invocation serves. The durable
84
+ * identity of the dispatch: unique in the journal, where a provider's `callId` may not be.
80
85
  */
81
86
  readonly callSeq: Seq;
82
87
  /**
83
88
  * The `llm/request` row that produced this call: exactly what the model was sent when it asked.
84
89
  * Where a tool that forks this thread cuts, so the fork shares that request's cached prefix.
85
- * `null` only for a reply recorded without its request, which the loop never writes.
90
+ * `null` for runtime completion preparation, which has no model request.
86
91
  */
87
92
  readonly requestSeq: Seq | null;
88
93
  /** Where this thread's work happens. */
@@ -1,5 +1,6 @@
1
- import type { ExtensionRecord, ThreadEnvironment, ToolResult } from '../models/index.js';
2
- import type { ModelRoute, ToolCall } from '../llm/index.js';
1
+ import type { ThreadEnvironment } from '../records/journal.js';
2
+ import type { ToolCall } from '../llm/primitives.js';
3
+ import type { ModelRoute } from '../llm/provider.js';
3
4
  import type { LoopRuntime } from './runtime.js';
4
5
  export type ExecuteToolCallsOptions = {
5
6
  runtime: LoopRuntime;
@@ -13,8 +14,6 @@ export type ExecuteToolCallsOptions = {
13
14
  calls: readonly ToolCall[];
14
15
  signal: AbortSignal;
15
16
  };
16
- /** An error result for a call. */
17
- export declare const errorResult: (call: ToolCall, output: string) => ToolResult;
18
17
  /**
19
18
  * Runs one step's tool calls.
20
19
  *
@@ -34,9 +33,3 @@ export declare const errorResult: (call: ToolCall, output: string) => ToolResult
34
33
  * disagreeing.
35
34
  */
36
35
  export declare function executeToolCalls(options: ExecuteToolCallsOptions): Promise<void>;
37
- /**
38
- * Declares the `ext` rows of one plugin event state a `lagent/tool/authorize` listener decides
39
- * from: one that lands while a call is authorized sends the decision round again, which no other
40
- * `ext` row does. `defineExtensionEvent({ policyState: true })` is the way in.
41
- */
42
- export declare function declarePolicyState(record: Pick<ExtensionRecord, 'plugin' | 'instance_id' | 'kind'>): void;
package/dist/plugin.d.ts CHANGED
@@ -1,53 +1,50 @@
1
1
  /**
2
- * The plugin-authoring kit: what a plugin imports beside `@leuduan/cordis`.
2
+ * The plugin-authoring door: what a plugin imports beside `@leuduan/cordis`.
3
3
  *
4
4
  * Registering a tool, an agent or a prompt contribution; granting a tool; defining, mounting and
5
5
  * validating the configuration of a preset (`definePreset`, `mountPreset`, `parsePresetConfig`), and
6
6
  * handing one down to the children a thread's calls create (`handDown`);
7
7
  * defining a durable `ext` event, writing it beside a send or a creation (`WriteRows`), and reading what a thread was
8
8
  * told; defining a set of durable modes (`defineModes`); adding a typed value to every thread's catalog entry (`defineContribution`); claiming a thread for one plugin, refusing a mount in a thread's scope (`requireUnscoped`)
9
- * and refusing a missing root service (`requireService`); running a process, reading paths and git as
10
- * the shipped tools do (`sys/`);
9
+ * and refusing a missing root service (`requireService`); reading paths and git as the shipped tools
10
+ * do (`sys/`). A tool touches files and starts processes through `InvocationContext.operation`, so the
11
+ * confinement policy judges them; the raw process launches (`spawnCommand`, `runToCompletion`) are on
12
+ * the root door, for the host's own processes;
11
13
  * the contracts a tool and a step hook implement; and the `ctx.*` service types every plugin reads.
12
14
  * A value lives on one door: the application API is the root entry point, the model contracts are
13
15
  * `@leuduan/lagent/llm`, the serialized shapes (`JournalEvent`, `Seq`, `ToolResult`, `stepContribution`,
14
- * `toJsonSchema`) are `@leuduan/lagent/models`.
16
+ * `toJsonSchema`) are `@leuduan/lagent/records`.
15
17
  */
16
18
  export * from './context.js';
17
- export { defineTool, errorResult, provideTool } from './kit/tool.js';
18
- export type { JsonSchemaParameters, ToolDefinition, ToolReply } from './kit/tool.js';
19
- export { grantTool } from './kit/grants.js';
20
- export { drainBeforeUnload } from './kit/drain.js';
21
- export { defineModes } from './kit/modes.js';
22
- export type { Modes, ModesDefinition } from './kit/modes.js';
23
- export { AgentSelectorSchema, isScopedAgentName, requireUnscoped, selects } from './kit/scope.js';
24
- export { requireService } from './kit/service.js';
25
- export type { AgentSelector } from './kit/scope.js';
26
- export { registerAgent } from './services/agents.js';
27
- export { definePreset, mountPreset, parsePresetConfig } from './services/preset.js';
28
- export type { Preset, PresetInstallation, PresetMountOptions, PresetPlace, PresetPlacement, PresetSelection, } from './services/preset.js';
29
- export { handDown } from './services/presets.js';
30
- export type { HandDown } from './services/presets.js';
31
- export type { AgentDefinition, AgentDefinitionInput } from './models/index.js';
19
+ export { defineTool, errorResult, grantTool, registerTool } from './services/tools.js';
20
+ export type { JsonSchemaParameters, ToolDefinition, ToolReply } from './services/tools.js';
21
+ export { claimThread, drainBeforeUnload, requireService, requireUnscoped } from './services/plugins.js';
22
+ export { defineModes } from './services/modes.js';
23
+ export type { Modes, ModesDefinition } from './services/modes.js';
24
+ export { AgentSelectorSchema, isScopedAgentName, registerAgent, selects } from './services/agents.js';
25
+ export type { AgentSelector } from './services/agents.js';
26
+ export { definePreset, mountPreset, parsePresetConfig } from './services/presets/definition.js';
27
+ export type { Preset, PresetInstallation, PresetMountOptions, PresetPlace, PresetPlacement, PresetSelection, } from './services/presets/definition.js';
28
+ export { handDown } from './services/presets/installations.js';
29
+ export type { HandDown } from './services/presets/installations.js';
30
+ export type { AgentDefinition, AgentDefinitionInput } from './loop/index.js';
32
31
  export { contributePrompt } from './services/prompts.js';
33
- export { defineContribution } from './services/contributions.js';
34
- export type { ContributionDefinition, ContributionReading } from './services/contributions.js';
32
+ export { defineContribution } from './services/catalogContributions.js';
33
+ export type { ContributionDefinition, ContributionReading } from './services/catalogContributions.js';
35
34
  export type { PromptContribution, PromptRenderInput, PromptSlot } from './services/prompts.js';
36
- export { ExtensionVersionError, defineExtensionEvent, latestNotice, latestVisible, tellOnStep, } from './kit/extension.js';
37
- export type { NoticeEvent, StepNotice, ToldNotice, ToldNotices } from './kit/extension.js';
35
+ export { ExtensionVersionError, defineExtensionEvent, latestNotice, latestVisible, tellOnStep, } from './services/extensionEvents.js';
36
+ export type { NoticeEvent, StepNotice, ToldNotice, ToldNotices } from './services/extensionEvents.js';
38
37
  export { ProjectionFailedError, projection } from './journal/index.js';
39
38
  export type { AppendOptions, Committed, PluginJournal, PluginProjection, Transaction } from './journal/index.js';
40
39
  export type { CallerChain, OriginBreak, OriginOpening, Origins, RequiredOwner, RequiredOwners, } from './journal/index.js';
41
- export type { BirthSpec, ForkOpening, FreshOpening, Refusal, RowsResult, RowsWrite, WriteRows } from './loop/index.js';
42
- export { isWaitRequest, lastAssistantMessage, waitFor } from './loop/index.js';
43
- export { provideStrategy } from './kit/strategy.js';
44
- export type { AuxiliaryCall, AuxiliaryReply, InvocationContext, ModelRequestDraft, ModelStep, SentModelRequest, SentRequest, ReplacementInput, StopVerdict, AuxiliaryAnswer, FinalPlan, SurfacePlan, SurfacePrepareInput, SurfaceStrategy, Tool, ToolAuthorizationRequest, ToolDenial, ToolEntry, ToolExecutionMode, ToolInvocation, ToolOutcome, ToolPolicyDecision, TurnStop, WaitRequest, ResolvedWait, } from './loop/index.js';
40
+ export type { BirthSpec, ForkOpening, FreshOpening, Refusal, RowsResult, RowsWrite, WriteRows } from './state/index.js';
41
+ export { isWaitRequest, waitFor } from './loop/index.js';
42
+ export { lastAssistantMessage } from './state/index.js';
43
+ export { registerSurfaceStrategy } from './loop/index.js';
44
+ export type { AuxiliaryCall, AuxiliaryReply, CompletionRequest, InvocationContext, ModelRequestDraft, ModelStep, SentModelRequest, SentRequest, StopVerdict, AuxiliaryAnswer, FinalPlan, SurfacePlan, SurfacePrepareInput, SurfaceStrategy, Tool, ToolAuthorizationRequest, ToolDenial, ToolEntry, ToolExecutionMode, ToolInvocation, ToolOutcome, ToolPolicyDecision, TurnStop, WaitRequest, ResolvedWait, } from './loop/index.js';
45
+ export type { ReplacementInput } from './state/index.js';
45
46
  export { stableStringify } from './util/json.js';
46
- export { claimThread } from './kit/claim.js';
47
- export { systemClock, timerQueue } from './kit/timers.js';
48
- export type { Clock, TimerQueue } from './kit/timers.js';
49
- export { pathBoundary } from './sys/paths.js';
50
- export type { BoundaryScope, PathAccess, PathBoundary } from './sys/paths.js';
51
- export { runToCompletion, spawnCommand } from './sys/spawn.js';
47
+ export { systemClock, timerQueue } from './util/timers.js';
48
+ export type { Clock, TimerQueue } from './util/timers.js';
52
49
  export type { AppendEntry } from './journal/index.js';
53
- export type { SpawnEnvironment, SpawnOptions, SpawnResult, SpawnStdio, SpawnedCommand, SpawnedGroup, SpawnedPipes, StopCause, } from './sys/spawn.js';
50
+ export type { SpawnEnvironment } from './sys/spawn.js';
package/dist/plugin.js CHANGED
@@ -1 +1 @@
1
- import{a as F}from"./chunks/6ECI2GGV.js";import{a as T}from"./chunks/4XVRUSCQ.js";import{b as x,c as B}from"./chunks/SGGMBSBA.js";import{c as S}from"./chunks/3QCW4WDJ.js";import{b as N,d as R}from"./chunks/J5S4URAW.js";import{a as U}from"./chunks/SL2YLB2F.js";import{b as C}from"./chunks/RK3VP2Q4.js";import"./chunks/74HKUGRR.js";import{a as M}from"./chunks/QMMLQJBS.js";import{a as P}from"./chunks/YIR5MYGU.js";import{a as c,b as u,e as g}from"./chunks/L3N4FIEN.js";import{a as b,b as h}from"./chunks/NAOUTU7A.js";import"./chunks/UKXMCHHT.js";import{b as j}from"./chunks/CDQG7RKA.js";import{a as E}from"./chunks/G6RXC3AL.js";import{b as l,c as d}from"./chunks/DXFXAYDN.js";import{a as v,b as y,c as A,d as q,e as w}from"./chunks/DRYAN665.js";import{a as m,b as f,c as s,d as a}from"./chunks/2OSESBIL.js";import{R as t,ia as i,ja as n,ka as p}from"./chunks/YLNJXQ3Z.js";import"./chunks/DDANMY45.js";import{d as e,h as o,j as r}from"./chunks/37YOGDGY.js";import"./chunks/KESCTXGO.js";import"./chunks/TYTQRLTX.js";import"./chunks/D7E6EWIE.js";export{m as AgentSelectorSchema,v as ExtensionVersionError,r as ProjectionFailedError,F as claimThread,C as contributePrompt,U as defineContribution,y as defineExtensionEvent,j as defineModes,c as definePreset,b as defineTool,P as drainBeforeUnload,p as errorResult,B as grantTool,S as handDown,s as isScopedAgentName,n as isWaitRequest,t as lastAssistantMessage,A as latestNotice,q as latestVisible,u as mountPreset,g as parsePresetConfig,E as pathBoundary,o as projection,T as provideStrategy,h as provideTool,x as registerAgent,M as requireService,a as requireUnscoped,d as runToCompletion,f as selects,l as spawnCommand,e as stableStringify,N as systemClock,w as tellOnStep,R as timerQueue,i as waitFor};
1
+ import{b as N}from"./chunks/DDZ7YF26.js";import{b as t}from"./chunks/KUZCL2SH.js";import{c as P}from"./chunks/CQEVREBT.js";import{b as w,d as F}from"./chunks/HK6ZSONF.js";import{a as M}from"./chunks/7VAPNE3L.js";import{b}from"./chunks/EPYQ5M3B.js";import"./chunks/5IRF47YB.js";import{a as u,b as S,e as E}from"./chunks/OL5A6ITQ.js";import{b as A,c as T,e as h}from"./chunks/JFX2MXBA.js";import{a as l,b as c,c as d,d as g}from"./chunks/S34ZA2R6.js";import{a as q,b as y,c as C,d as j,e as v}from"./chunks/6FRNHMCV.js";import{b as m,c as p,d as a,e as x}from"./chunks/CUK7CGC7.js";import{U as i,V as n,W as s,Y as f}from"./chunks/BPRCULZH.js";import"./chunks/FJLU4UH3.js";import"./chunks/DDANMY45.js";import{c as e,h as r,j as o}from"./chunks/BBCW2FZK.js";import"./chunks/MMNNZCBO.js";import"./chunks/G44LG6VL.js";import"./chunks/D4PQP5MA.js";export{p as AgentSelectorSchema,q as ExtensionVersionError,o as ProjectionFailedError,l as claimThread,b as contributePrompt,M as defineContribution,y as defineExtensionEvent,N as defineModes,u as definePreset,A as defineTool,c as drainBeforeUnload,i as errorResult,h as grantTool,P as handDown,x as isScopedAgentName,s as isWaitRequest,t as lastAssistantMessage,C as latestNotice,j as latestVisible,S as mountPreset,E as parsePresetConfig,r as projection,m as registerAgent,f as registerSurfaceStrategy,T as registerTool,d as requireService,g as requireUnscoped,a as selects,e as stableStringify,w as systemClock,v as tellOnStep,F as timerQueue,n as waitFor};