@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
package/dist/context.d.ts CHANGED
@@ -1,16 +1,25 @@
1
1
  import type { Scoped } from '@leuduan/cordis';
2
2
  import type { JournalCommitError, PluginJournal } from './journal/index.js';
3
3
  import type { ModelRequestDraft, ModelStep, SentRequest, StopVerdict, ToolAuthorizationRequest, ToolPolicyDecision, ToolInvocation, ToolOutcome, TurnStop } from './loop/index.js';
4
- import type { StreamingLLMResponse } from './llm/index.js';
4
+ import type { StreamingLLMResponse } from './llm/client.js';
5
5
  import type { AgentsService } from './services/agents.js';
6
6
  import type { LlmService } from './services/llm.js';
7
- import type { LaunchesService } from './services/launches.js';
7
+ import type { ConfinementOperation, ConfinementService } from './services/confinement/service.js';
8
8
  import type { PromptsService } from './services/prompts.js';
9
- import type { ThreadDirsService } from './services/threadDirs.js';
10
- import type { PresetsService } from './services/presets.js';
11
- import type { Threads } from './services/threads.js';
9
+ import type { PresetsService } from './services/presets/installations.js';
10
+ import type { Threads } from './services/threads/index.js';
12
11
  import type { ToolsService } from './services/tools.js';
13
- import type { Thread } from './services/thread.js';
12
+ import type { Thread } from './services/threads/index.js';
13
+ declare module './loop/tool.js' {
14
+ interface InvocationContext {
15
+ /**
16
+ * The call's confinement operation: its file access (`files`) and the launches of any process it
17
+ * starts, under one snapshot taken on first use. Opened for the call and ended with it, so a
18
+ * reference that outlives the call is dead.
19
+ */
20
+ readonly operation: ConfinementOperation;
21
+ }
22
+ }
14
23
  declare module '@leuduan/cordis' {
15
24
  interface Context {
16
25
  /** The journal: the one durable state, and the folds over it; a plugin appends its own `ext` rows. */
@@ -25,12 +34,10 @@ declare module '@leuduan/cordis' {
25
34
  prompts: PromptsService;
26
35
  /** Starting and finding threads, and what happens to them as a set; one thread is driven through its `Thread`. */
27
36
  threads: Threads;
28
- /** Each thread's own directory under the application data directory. */
29
- threadDirs: ThreadDirsService;
30
37
  /** Presets a thread can install, their validation, hand-downs and restoration. */
31
38
  presets: PresetsService;
32
39
  /** How model-driven processes launch: plain, or through the one handler a host registers. */
33
- launches: LaunchesService;
40
+ confinement: ConfinementService;
34
41
  }
35
42
  interface Events {
36
43
  /**
@@ -65,7 +72,8 @@ declare module '@leuduan/cordis' {
65
72
  * A turn's answer — a reply with no tool calls, or a result that concluded the turn — is about
66
73
  * to become the thread's answer. Return `undefined` to accept it, `{ decision: 'continue',
67
74
  * message }` to send the model back in the same turn, or `{ decision: 'reject', reason, source }`
68
- * to end the turn `rejected`. Any rejection wins, then any continuation. Consulted whatever the
75
+ * to end the turn `rejected`, or `{ decision: 'prepare', request }` to plan a runtime operation
76
+ * before final judgment. Rejection wins, then continuation, then preparation. Consulted whatever the
69
77
  * step budget, and again after a crash, abort or failure left the answer unjudged. A check
70
78
  * declares the facts its verdict rests on with `stop.observe(read)`; the judgment is discarded if
71
79
  * one reads differently when it is recorded.
package/dist/index.d.ts CHANGED
@@ -4,11 +4,12 @@
4
4
  *
5
5
  * The package has a few doors and nothing else: this one for applications, `@leuduan/lagent/plugin`
6
6
  * for plugin authors, `@leuduan/lagent/llm` for the model and provider contracts,
7
- * `@leuduan/lagent/providers` for the shipped providers, `@leuduan/lagent/sqlite` for the SQLite store
8
- * (which needs `node:sqlite`), `@leuduan/lagent/models` for the serialized shapes, one
7
+ * `@leuduan/lagent/providers` for the shipped providers, `@leuduan/lagent/stores/sqlite` for the SQLite store
8
+ * (which needs `node:sqlite`), `@leuduan/lagent/records` for the serialized shapes, one
9
9
  * `@leuduan/lagent/plugins/<name>` per shipped plugin, and `@leuduan/lagent/testing` for test doubles. A
10
10
  * value lives on one door: this one holds what an application constructs (the core, the memory
11
- * store), catches (the errors) or composes from `presets/`; a shipped plugin's exports, its presets
11
+ * store), catches (the errors), composes from `compositions/` or runs as a host-owned process
12
+ * (`spawnCommand`, `runToCompletion`: servers and probes the host starts, never a tool's work); a shipped plugin's exports, its presets
12
13
  * included, are on its own door. The core's services are reached as `ctx.<name>`, so their classes
13
14
  * are exported as types only. Keep this
14
15
  * entry point small enough that an embedder can understand it without first learning the engine
@@ -22,26 +23,33 @@ export type { ToolsService } from './services/tools.js';
22
23
  export { registerProvider } from './services/llm.js';
23
24
  export type { LlmService, RetryPolicy } from './services/llm.js';
24
25
  export type { PromptsService } from './services/prompts.js';
25
- export { registerPreset } from './services/presets.js';
26
- export type { ConfigurationPlan, InitialInstallationInput, InstallationInput, PresetsService, } from './services/presets.js';
27
- export { UNCONFINED_LAUNCH } from './services/launches.js';
28
- export type { LaunchesService, Launched, LaunchHandle, LaunchHandler, LaunchOptions, LaunchProvenance, LaunchRequest, PreparedLaunch, } from './services/launches.js';
29
- export type { ThreadDirsConfig, ThreadDirsService } from './services/threadDirs.js';
30
- export type { ConfigurationChange, ConfigurationResult, RetainOptions, RetainedMembers, Retention, ThreadFilter, Threads, ThreadsConfig, ThreadsService, } from './services/threads.js';
31
- export type { MissingDetail, OwnerHandle, OwnerReadiness, OwnerRegistration, StartOptions, StartupPolicy, ThreadInspection, WaitResolution, WaitValue, } from './services/owner.js';
32
- export { heldOrSettled, UnknownRunError, waitForRun } from './services/runEvents.js';
33
- export type { RunEvent, RunSource, RunState } from './services/runEvents.js';
34
- export type { BirthChoice, BirthInput, CreateThreadOptions, ForkCut, ForkOptions, Opening, Reuse, } from './services/birth.js';
35
- export { Thread } from './services/thread.js';
36
- export type { ThreadView } from './services/threadView.js';
37
- export type { CancelOptions, ConfirmationAnswer } from './services/thread.js';
38
- export { repositoryReadRoots } from './sys/git.js';
39
- export { buildSpawnEnvironment, CODEX_ENVIRONMENT_POLICY, NON_INTERACTIVE_ENVIRONMENT, resolveTrustedPrograms, } from './sys/environment.js';
26
+ export { registerPreset } from './services/presets/installations.js';
27
+ export type { ConfigurationPlan, InitialInstallationInput, InstallationInput, PresetsService, } from './services/presets/installations.js';
28
+ export { UNCONFINED_LAUNCH } from './services/confinement/service.js';
29
+ export { FileAccessError } from './services/confinement/files.js';
30
+ export type { DirEntry, DirListing, FileScope, PathOptions, ReadHandle, WriteHandle, } from './services/confinement/files.js';
31
+ export type { ConfinementHandle, ConfinementHandler, ConfinementOperation, ConfinementService, ConfinementSnapshot, FileAccess, FilePolicy, FileVerdict, Launched, LaunchOptions, LaunchProgram, LaunchProvenance, LaunchRequest, PreparedLaunch, } from './services/confinement/service.js';
32
+ export type { ConfigurationChange, ConfigurationResult, RetainOptions, RetainedMembers, Retention, ThreadFilter, Threads, ThreadsConfig, ThreadsService, } from './services/threads/index.js';
33
+ export type { MissingDetail, OwnerHandle, OwnerReadiness, OwnerRegistration, StartOptions, StartupPolicy, ThreadInspection, WaitResolution, WaitValue, } from './services/threads/index.js';
34
+ export { heldOrSettled, UnknownRunError, waitForRun } from './services/threads/index.js';
35
+ export type { RunEvent, RunSource, RunState } from './services/threads/index.js';
36
+ export type { BirthChoice, BirthInput, CreateThreadOptions, ForkCut, ForkOptions, Opening, Reuse, } from './services/threads/index.js';
37
+ export type { Thread } from './services/threads/index.js';
38
+ export type { ThreadView } from './services/threads/index.js';
39
+ export type { CancelOptions, ConfirmationAnswer } from './services/threads/index.js';
40
+ export { buildSpawnEnvironment, NON_INTERACTIVE_ENVIRONMENT, resolveTrustedPrograms } from './sys/environment.js';
41
+ export { CODEX_ENVIRONMENT_POLICY } from './compositions/codex.js';
40
42
  export type { SpawnEnvironmentPolicy, TrustedPrograms } from './sys/environment.js';
41
- export type { ChainStanding, CompactOptions, ConfirmationState, ForkPoint, InputFate, InstallationRecord, ModelSelection, ReplacementRule, RouteStatement, Target, ConstraintAnswer, Hold, HoldBasis, HoldReason, BirthConflict, BirthSpec, ForkOpening, FreshOpening, Refusal, RowRef, RunOutcome, RowsResult, RowsWrite, InputReceipt, SendOptions, SendOutcome, StreamedChunk, SurfacePrepareOutcome, TurnLimits, WaitDeclaration, WaitEntry, WithdrawOptions, WithdrawOutcome, WithdrawRows, } from './loop/index.js';
42
- export { AuxiliaryRefusedError, BirthConflictError, ConfirmationAnsweredError, CorruptHistoryError, DepthExceededError, ForkCutError, ReplacementRefusedError, RestoreFailedError, RouteConflictError, RouteUnavailableError, ThreadActivatingError, ThreadBusyError, ThreadUnsettledError, UnknownAgentError, UnknownThreadError, WriteRefusedError, } from './loop/index.js';
43
+ export { runToCompletion, spawnCommand } from './sys/spawn.js';
44
+ export type { SpawnEnvironment, SpawnOptions, SpawnResult, SpawnStdio, SpawnedCommand, SpawnedGroup, SpawnedPipes, StopCause, } from './sys/spawn.js';
45
+ export type { ChainStanding, ConfirmationState, ForkPoint, InputFate, InstallationRecord, ReplacementRule, RouteStatement, Target, ConstraintAnswer, Hold, HoldBasis, HoldReason, BirthSpec, ForkOpening, FreshOpening, Refusal, RowRef, RunOutcome, RowsResult, RowsWrite, InputReceipt, SendOptions, SendOutcome, TurnLimits, WaitDeclaration, WaitEntry, WithdrawOptions, WithdrawOutcome, WithdrawRows, } from './state/index.js';
46
+ export type { CompactOptions, BirthConflict, StreamedChunk, SurfacePrepareOutcome } from './loop/index.js';
47
+ export type { ModelSelection } from './llm/provider.js';
48
+ export { AuxiliaryRefusedError, BirthConflictError, ConfirmationAnsweredError, CorruptHistoryError, DepthExceededError, RestoreFailedError, ThreadActivatingError, ThreadBusyError, ThreadUnsettledError, UnknownAgentError, WriteRefusedError, } from './loop/index.js';
49
+ export { ForkCutError, ReplacementRefusedError, RouteConflictError, RouteUnavailableError, UnknownThreadError, } from './state/index.js';
43
50
  export { CorruptJournalError, forkChain, IncompatibleJournalError, InvalidOriginError, JournalBusyError, JournalCommitError, StoreBusyError, } from './journal/index.js';
44
51
  export type { AppendOutcome, Attempt, ForkLink, InvalidOriginReason, JournalStore, ThreadIndexEntry, ThreadSummaryCore, WriterLease, } from './journal/index.js';
45
- export { MemoryJournalStore } from './plugins/store/memory.js';
46
- export { base, codexPreset } from './presets/index.js';
47
- export { COMMUNICATION_GUIDANCE_PROMPT, FORMATTING_PROMPT } from './presets/prompts.js';
52
+ export { MemoryJournalStore } from './stores/memory.js';
53
+ export { base } from './compositions/base.js';
54
+ export { codexPreset } from './compositions/codex.js';
55
+ export { COMMUNICATION_GUIDANCE_PROMPT, FORMATTING_PROMPT } from './compositions/codexPrompts.js';
package/dist/index.js CHANGED
@@ -1,77 +1 @@
1
- import{d as L}from"./chunks/3LQHQRIU.js";import{a as S}from"./chunks/ADHERZLW.js";import{a as N,b as A}from"./chunks/BM3S37EZ.js";import{a as F}from"./chunks/TOOIB6J2.js";import{c as d}from"./chunks/X65X4KP5.js";import{a as B}from"./chunks/IJ2WNMD5.js";import{a as s,b as x,c as i}from"./chunks/ENWFSU27.js";import{a as Me,b as Ue,c as Ye,d as Ke}from"./chunks/2O7ZGEIT.js";import{a as C,b as m,c as D,d as f}from"./chunks/P5ZHHOOM.js";import"./chunks/6ECI2GGV.js";import{e as W}from"./chunks/UCTEU62F.js";import{b as Y}from"./chunks/UC3FVVJ2.js";import"./chunks/4XVRUSCQ.js";import{a as G}from"./chunks/O4PPOM5Z.js";import{c as Fe}from"./chunks/OVZFGILJ.js";import{t as U}from"./chunks/EGZI4XQX.js";import{b as De,c as We,d as Ge}from"./chunks/UD3VJER6.js";import{b as v,c as M}from"./chunks/SGGMBSBA.js";import{b as Ce,c as I}from"./chunks/3QCW4WDJ.js";import"./chunks/C5LYCXJG.js";import"./chunks/J5S4URAW.js";import{e as w}from"./chunks/G74AGRAJ.js";import"./chunks/SL2YLB2F.js";import{b as Be,c as je,d as Ve,f as qe}from"./chunks/JPZFKSWT.js";import{b as p}from"./chunks/RK3VP2Q4.js";import"./chunks/74HKUGRR.js";import"./chunks/QMMLQJBS.js";import"./chunks/YIR5MYGU.js";import{a as P}from"./chunks/L3N4FIEN.js";import"./chunks/NAOUTU7A.js";import"./chunks/UKXMCHHT.js";import"./chunks/WUUKTSRT.js";import"./chunks/NDIM7MEW.js";import"./chunks/34KW6VNQ.js";import"./chunks/PUSUPTAT.js";import"./chunks/CDQG7RKA.js";import"./chunks/G6RXC3AL.js";import{b as Se}from"./chunks/GQGNVSKB.js";import"./chunks/DXFXAYDN.js";import"./chunks/DRYAN665.js";import"./chunks/2OSESBIL.js";import{A as ve,B as Pe,C as Ie,D as xe,E as Ne,H as Ae,I as Le,r as we,s as ye,t as ke,u as Oe,v as Ee,w as Te,x as be,y as Re,z as _e}from"./chunks/YLNJXQ3Z.js";import"./chunks/DDANMY45.js";import{b as ce,c as le,l as ue,m as ge,q as pe,u as me,x as fe}from"./chunks/37YOGDGY.js";import{a as _}from"./chunks/KESCTXGO.js";import"./chunks/TYTQRLTX.js";import"./chunks/D7E6EWIE.js";var y=["edit_files"],j={name:"main",basePrompt:"You are a helpful AI assistant."};var He={name:"lagent:base",inject:["agents"],async apply(e){v(e,j),await e.plugin(S),await e.plugin(L),await e.plugin(N,{confirm:A})}};import{z as R}from"zod";var V="You are a coding agent working in the user's workspace. You and the user share its files: with the tools you are given, you read, search and change them and run commands there. Your job is to carry the user's task through to a result they can review.",q=`- Carry the task through to the end within the turn: understand it, make the change, validate it, and report. Do not stop at analysis, a proposal or a half-finished fix.
2
- - Unless the user asks a question, asks for a plan or a review, or is brainstorming, assume they want the change made, and make it rather than describe it.
3
- - When you hit a blocker, try to work through it yourself first. Ask the user, with ask_question, only when the answer changes what you would do and you cannot find it out yourself.
4
- - Do not guess or make up an answer: read the code, run the command, look it up.
5
- - Messages may arrive while you work. When they conflict, the newest one steers; otherwise honour every request since your last answer, and make sure your final answer responds to the newest.`,K='Before a group of related tool calls, write one short line saying what you are about to do, and after the first, how it follows from what you found; for example "The loader is in src/config.ts; now checking its callers." Group related calls under one line instead of narrating each, and write none before a trivial read. Before a large edit, say what you are changing.',k=`- Read the code you are about to change, and let it show you how to change it: follow the repository's existing patterns, helpers and style.
6
- - Fix the problem at its root cause rather than patching the symptom, and keep the solution as simple as the problem allows. Add an abstraction only when it removes real complexity.
7
- - Follow the AGENTS.md files you are told for the files you touch. Each governs its directory's tree and the deeper one wins on a conflict; the user's direct instructions beat any of them. Working below your working directory, look for AGENTS.md there too.
8
- - Keep the change to what the task needs. Do not fix unrelated bugs or failing tests; mention them in your final answer.
9
- - Update the documentation your change makes wrong.
10
- - Default to ASCII in files, and add a comment only where the code does not explain itself.
11
- - Never add copyright or licence headers unless asked. Do not commit or create branches unless asked.`,c="- Make every change to a file with edit_files: creating, updating, moving or deleting it. Never write a file through a command, such as a shell heredoc, `echo >`, `sed -i` or a script; running the project's own formatter or code generator is fine.\n- Read the lines you change before editing them: an edit's old text must match the file as it is now.\n- edit_files answers with the diff it applied. Trust it, and do not re-read the file to check.\n- If an edit is interrupted, or applies only some of its files, re-read the files it named before editing them again.",l="The worktree may hold changes you did not make. Assume they are the user's, and never revert them unless asked.\n- Leave changes unrelated to your task alone.\n- In files you are working on, read the changes carefully and work with them.\n- Never run `git reset --hard`, `git checkout --`, `git restore`, `git clean` or anything else that discards changes unless the user clearly asked for that operation; when the request is ambiguous, ask first.\n- If those changes make your task impossible, ask the user how to proceed.",O=`- When the project can be built or tested, use that to check your work. Start with the tests closest to what you changed, then widen as you gain confidence.
12
- - Let coverage scale with risk: focused for a narrow change, broader when the change touches shared behaviour, contracts between modules, or what users do.
13
- - Add a test where the codebase has an obvious place for one. Do not add a test suite or a formatter to a repository that has none, and do not write tests that only mirror the implementation.
14
- - Run the project's formatter and linter on the files you changed when it has them.
15
- - A failure your change did not cause is not yours to fix: mention it.`,H=`- Independent tool calls can run in parallel: make every call that does not need another's result in the same response. When a call depends on an earlier one's output, wait for that result first.
16
- - Hand work to a sub-agent when you do not need to see its steps, so your conversation keeps only its outcome:
17
- - explore: find and understand things in the workspace, such as where something is handled, how a module works or what a change would affect. It only reads.
18
- - delegate: a self-contained task that needs nothing from this conversation but the task you write, including one that changes files or runs commands, such as updating every call site of a function and making the tests pass, or finding out why a command fails and fixing it.
19
- - fork: a task of several steps that needs your context: answering a question by experiment, working out why something fails, checking whether an approach works.
20
- - review: a second reading of a change, or of any code, when the user asks for one or a change is large or subtle enough that one helps; never as a routine step. Its findings are evidence: weigh each against the code before acting on it. To get them fixed, delegate the findings with their evidence. Check the repository's status before asking for a review of uncommitted work: an empty change still starts a reviewer.
21
- - Work directly when one or two calls will do, when you need the raw output yourself (the exact lines you are about to edit, command output you must reason over), when the next step waits on a decision, or when the answer is already in the conversation.
22
- - Give independent parts separate calls in one response, so they run concurrently. Write each task as an outcome: what to find out or do, and what to return, such as "the function that validates tokens, with its file and line" rather than "look at the auth code". Explore, delegate and review see only the task you write; a fork sees your conversation too. Either way, name the target (for a review, "the uncommitted changes", "the current work against main", "commit abc123" or the code to read), the outcome you expect, the constraints, and which files you or other sub-agents are changing and which commands share outputs, such as test discovery, a build directory or a server port.
23
- - Start a review only after the work it reviews has settled, in a later response than the calls that make that work: a waiting call does not stop the others in its response.
24
- - In a forked task, do the work yourself rather than forking again.`,E="A long task can outgrow your context. The conversation may then be compacted: a checkpoint stands in for the messages it condensed. Compaction does not end the task. Continue from the checkpoint without restarting or redoing finished work, and keep the original objective together with every correction the user made since.",J="When you need the exact text of something condensed, such as the user's wording or a command's output, read it back with history_read or find it with history_search rather than reconstructing it.",u=`- Your file tools read and change files in the working directory and the application data directory, and also read the read roots your workspace notice names. Do not go looking through the rest of the machine, such as other projects or the home directory, unless the task needs it.
25
- - Avoid destructive or irreversible commands, such as deleting what you did not create, force-pushing or dropping data, unless the user asked for them.
26
- - Do not push, publish, deploy or send anything to others unless asked.
27
- - Do not search for, print or copy out secrets such as credentials, API keys and tokens.`,$=`- For a task with no prior context, where the user is starting something new, be ambitious and show creativity in the implementation.
28
- - In an existing codebase, do exactly what the user asks with surgical precision. Treat the surrounding code with respect and do not overstep, for example by renaming files or variables unnecessarily, while still being proactive enough to finish the task well.
29
- - Use judicious initiative to choose the right level of detail and complexity for the user's needs: high-value, creative touches when the scope is vague; surgical, targeted work when it is tightly specified; no gold-plating either way.`,X=`- Lead with the outcome, then give what the user needs to trust it and act on it, like a concise teammate handing off work.
30
- - Size the answer by the change: a sentence or two for a small fix, a short walkthrough grouped by theme for a large one, a plain conversational reply to a casual question. Even a large one keeps to the points that matter, well under fifty lines.
31
- - Say what you ran to validate the work, and what you did not run and why.
32
- - Point to code as \`path:line\`, with the path relative to the working directory and a single line rather than a range.
33
- - Do not paste before-and-after code or the contents of files you wrote: the user has the files. Never ask them to save or copy anything.
34
- - Mention the problems you noticed but left alone, and anything you could not do.
35
- - When there is an obvious next step, such as running the wider test suite, committing, or building the next piece, offer it as a short question rather than doing it unasked.`,T=`- Write in English unless the user asks for another language.
36
- - Be direct and concise, and state the assumptions you made. Leave out flattery, filler and needless apologies.
37
- - Use plain characters: no emoji unless asked, and no look-alike or invisible Unicode, such as an en dash for a hyphen.`,b=`- Answer in Markdown, with only as much structure as helps: short paragraphs by default, flat lists for parallel items, and a heading only when a long answer has distinct parts.
38
- - Put code, commands and multi-line output in fenced code blocks labelled with their language.
39
- - Wrap file paths, commands, environment variables and code identifiers in backticks.`,z=e=>{let t=e("rg_search"),o=e("rg_files");return`You are an exploration sub-agent: you investigate the workspace to answer the task you are given, and report what you found without changing anything.
40
-
41
- Use read_file${t?" and rg_search to inspect and search":" to inspect"} code; read_file reads by line, so read the part you need.
42
- Use ${o?"rg_files to find files by name pattern, and ":""}list_dir to see what a directory holds or for an overview of the workspace.
43
- Request only the output you need, since tool output may be truncated, and make several targeted calls rather than one broad one.
44
- Answer with your findings, pointing to code as \`path:line\`, and say what you looked for but could not find.`},Q="Sub-agent that explores the workspace without changing it: codebase exploration, file discovery and code understanding. It reports its findings.",Z="Fork yourself to execute one sub-task in isolation. The forked thread gets a clone of your current conversation context, executes the task independently, and its result is returned to you. Use this when you want to 'clone yourself' to do a sub-task without polluting your main conversation thread. Call this tool once per task; several calls in one response run concurrently.",ee="Sub-agents inherit your permissions and share your working directory. Give sub-agents that run at the same time disjoint files to write, or let only one of them write; disjoint files still share test discovery, build output and ports, so do not run tests or builds in two of them at once.",Je="You are a sub-agent: another agent handed you one task, which you carry out in the user's workspace with the tools you are given, reading, searching and changing its files and running commands there. You do not see the conversation that led to the task: the task is all you know of it. Your answer goes back to the agent that asked, not to the user.",te=`- Where these instructions say to ask the user, you cannot: stop there, and put the question in your answer, with what you found and what each answer would change.
45
- - Before you answer, wait for every background command whose result you rely on, and stop every background command you started.`,$e=`Your answer is all the agent that asked gets back, so make it complete on its own:
46
- - Lead with the outcome: what you did, or what you found.
47
- - Point to code as \`path:line\`, with the path relative to the working directory.
48
- - Say what you ran to check it, each command exactly, and what it showed.
49
- - Say what is left undone, what you could not do, and what you are unsure of.`,Xe="You are a code review sub-agent: another agent asked you for a second reading of code in the user's workspace, a change or code as it stands, and you report the problems you find, with their evidence. You do not see the conversation that led to the task: the task names what to review and anything to focus on. Your answer goes back to the agent that asked, not to the user.",ze="- Read the change with git through run_command: a diff of the uncommitted changes, of the current work against a branch's merge base, or of one commit, with the repository's status and log. Note which commits you compared. Read the code around each change, and the code that depends on it, as far as you need to judge it. When the task names code rather than a change, review that code as it stands.\n- Review and report; do not fix. Run a command only when a finding needs the evidence: an existing test, the type checker, a linter, or a small reproduction. Prefer existing tests.\n- When a check needs a file inside the repository, create a new, uniquely named file with edit_files. Never change a file that existed before you started, the user's untracked files included.\n- Clean up what you created. Just before deleting a temporary file, read it again, and delete it only if it is still exactly what you wrote. Never restore the workspace wholesale, such as with `git checkout`, `git restore`, `git stash` or `git clean`.\n- Running tests writes caches and build output, which is fine: what you keep intact is the user's work.\n- When the target is a commit, or anything but the current work, your commands run on the checkout, not on the reviewed revision. Say which HEAD and which local changes they ran on, and do not claim that a check passing there shows the reviewed revision passes.\n- If files your findings rely on change while you review, check those findings again, or mark them uncertain.",Qe=`Flag a problem only when all of these hold:
50
- - It meaningfully affects the correctness, performance, security or maintainability of the code.
51
- - It is discrete and actionable: one issue, not a remark about the codebase in general or several issues together.
52
- - When the task names a change, the change introduced it: problems that were there before are not flagged. When it names code, the problem is in that code.
53
- - You can show it from the code or from what you ran. Speculating that something may break elsewhere is not enough: name the code that is affected. It must not rest on assumptions about the codebase or the author's intent that you have not stated.
54
- - It is clearly not a deliberate choice, and the author would fix it if they knew.
55
- - Fixing it does not demand more rigour than the rest of the codebase shows.
56
-
57
- Ignore style, formatting, naming and typos unless they hide a bug or break a rule the repository's AGENTS.md files state. When a rule supports a finding, cite the AGENTS.md file and line it comes from.
58
-
59
- Report every finding the author would want to fix, not only the first; when nothing clearly qualifies, report none. For each finding:
60
- - A short title tagged with its priority: [P0] blocks a release or major use, whatever the inputs; [P1] urgent, for the next cycle; [P2] normal, to fix eventually; [P3] low, nice to have.
61
- - Its location as \`path:line\` in the reviewed code, with the path relative to the repository, keeping the range as short as possible.
62
- - One short paragraph saying why it is a problem and the inputs, scenarios or environments it needs, so its severity is clear, and the evidence: what you read or ran. Claim no more severity than it has, quote no more than three lines of code, and keep the tone matter-of-fact, with no praise.
63
-
64
- When the task asks for a design assessment, alternatives or improvements, give them after the findings, under a heading of their own, apart from the problems you showed. When it asks for a severity scale or an output format, follow it instead of these.
65
-
66
- End with:
67
- - the scope you reviewed, and for a git target the commits you compared;
68
- - the checks you ran, each command exactly, with its result;
69
- - every experiment, what it left behind, and where its reproduction is kept, with how to run it;
70
- - the limits of the review: what you did not read or could not check.
71
- Then a one-line verdict: whether the reviewed code is correct, meaning existing code and tests will not break and it has no blocking problem. Non-blocking issues such as style do not count against it. "No qualifying findings" is not a guarantee of correctness: when you found none, say so plainly, with what you covered.
72
-
73
- Answer in plain text, not JSON. The task may narrow what to look at, and the repository's AGENTS.md files may add rules; both take precedence over these guidelines.`,oe=(e,t)=>[e,...t.map(([o,a])=>_(o,a))].join(`
74
-
75
- `),re=oe(Je,[["codebase",k],["editing",c],["dirtyWorktree",l],["validation",O],["safety",u],["subAgent",te],["answer",$e]]),ne=oe(Xe,[["evidence",ze],["editing",c],["dirtyWorktree",l],["safety",u],["subAgent",te],["rubric",Qe]]),ae="Sub-agent that carries out one self-contained task in the workspace with a fresh context: it reads, changes files, runs commands, and reports what it did and found. It sees only the task you write, not this conversation, so state the target, the outcome you expect and any constraints.",se="Sub-agent that reviews code in the workspace with a fresh context: a change (the uncommitted changes, the current work against a branch such as main, or one commit) or code as it stands. It may run tests and reproductions to gather evidence, changes nothing of yours, and reports the problems it can show, each tagged [P0] to [P3] at a file and line. Name the target and any focus in the task.";var Ze=[...s,...y,...w,...i,d,...U],et=[{tool:d,plugin:"skills"}],tt=[{tag:"autonomy",render:()=>q},{tag:"preambles",render:()=>K},{tag:"codebase",render:()=>k},{tag:"editing",render:()=>c},{tag:"dirtyWorktree",render:()=>l},{tag:"validation",render:()=>O},{tag:"delegation",render:()=>H},{tag:"forking",render:()=>ee},{tag:"longWork",render:({tools:e})=>Y.every(t=>e.some(o=>o.name===t))?`${E}
76
-
77
- ${J}`:E},{tag:"safety",render:()=>u},{tag:"ambitionPrecision",render:()=>$},{tag:"finalAnswer",render:()=>X},{tag:"communication",render:()=>T},{tag:"formatting",render:()=>b}],ot=R.strictObject({explore:R.strictObject({web:R.boolean().default(!1)}).prefault({}),agentsMd:C}),rt="codex.explore",nt="codex.general",at="codex.review",he=[...x,"web_search"],st=(e,t)=>[...s,...e?i:[]].filter(o=>t(o)||!he.includes(o)),ie=e=>[...s,...y,...w,...i,d].filter(t=>e(t)||!he.includes(t)),it=P({id:"codex#2",placement:"thread",schema:ot,inject:["tools","prompts","journal","threadDirs"],async setup(e,{explore:t,agentsMd:o},a){let r=[a.thread.agentName];if(e.get("presets")?.has(m)!==!0)throw new Error("codex hands down agents-md, which is not registered: register agentsMdPreset at startup");for(let{tool:n,plugin:g}of et)if(!e.tools.has(void 0,n))throw new Error(`codex grants ${n}, which is not registered: mount the ${g} plugin on the root`);for(let n of Ze)M(e,n,r);p(e,{tag:"base",slot:"base",agents:r,render:()=>V}),tt.forEach(({tag:n,render:g},de)=>p(e,{tag:n,slot:"instruction",agents:r,order:de,render:g})),a.kind==="installation"?(f(e,{holder:`codex in installation ${a.installationId}`,...o}),I(e,{presetId:m,config:o,installationId:D})):f(e,{holder:"codex for its agents",...o}),await e.plugin(F),await e.plugin(W,{agents:r});let h=n=>e.tools.has(void 0,n);await e.plugin(B,{endpoints:[{toolName:"explore",callers:r,description:Q,target:{kind:"role",id:rt,basePrompt:z(h),tools:st(t.web,h)}},{toolName:"delegate",callers:r,description:ae,target:{kind:"role",id:nt,basePrompt:re,tools:ie(h)}},{toolName:"fork",callers:r,description:Z,target:{kind:"fork"}},{toolName:"review",callers:r,description:se,target:{kind:"role",id:at,basePrompt:ne,tools:ie(h)}}]}),await e.plugin(G,{agents:r})}});export{Ne as AuxiliaryRefusedError,be as BirthConflictError,je as CODEX_ENVIRONMENT_POLICY,T as COMMUNICATION_GUIDANCE_PROMPT,ve as ConfirmationAnsweredError,xe as CorruptHistoryError,pe as CorruptJournalError,Ee as DepthExceededError,b as FORMATTING_PROMPT,Te as ForkCutError,me as IncompatibleJournalError,ce as InvalidOriginError,ue as JournalBusyError,fe as JournalCommitError,Ke as MemoryJournalStore,Be as NON_INTERACTIVE_ENVIRONMENT,Ie as ReplacementRefusedError,Oe as RestoreFailedError,Ae as RouteConflictError,Le as RouteUnavailableError,ge as StoreBusyError,Ue as Thread,_e as ThreadActivatingError,ke as ThreadBusyError,Pe as ThreadUnsettledError,Se as UNCONFINED_LAUNCH,we as UnknownAgentError,De as UnknownRunError,ye as UnknownThreadError,Re as WriteRefusedError,He as base,Ve as buildSpawnEnvironment,it as codexPreset,Ye as core,le as forkChain,Ge as heldOrSettled,Ce as registerPreset,Me as registerProvider,Fe as repositoryReadRoots,qe as resolveTrustedPrograms,We as waitForRun};
1
+ import{a as n}from"./chunks/Q7S5LFGN.js";import{a as e,b as t}from"./chunks/ASSQZH3F.js";import{b,c as J,d as V,e as G,f as H,g as W,h as Y}from"./chunks/B4FXK5ER.js";import"./chunks/SS3B5W34.js";import"./chunks/IAAEP6VL.js";import"./chunks/OCBPT7KE.js";import"./chunks/2P47AHNK.js";import"./chunks/MHC6VPB4.js";import"./chunks/EMRB4KCN.js";import"./chunks/RCIHV3KG.js";import"./chunks/2GCIWSOA.js";import"./chunks/GGSVIIWJ.js";import{b as S,c as k,d as v}from"./chunks/CANPZYTH.js";import"./chunks/VYMT4TXD.js";import"./chunks/MNJ4SRF7.js";import"./chunks/JFZZXVWD.js";import{b as B,c as D,e as L}from"./chunks/N6IXG2VL.js";import{b as M}from"./chunks/6DRCKZ2C.js";import{c as h,d as y}from"./chunks/7LI64H5X.js";import{a as U}from"./chunks/3UMZMPWW.js";import"./chunks/Q75FUN7D.js";import"./chunks/PUSUPTAT.js";import"./chunks/34KW6VNQ.js";import"./chunks/DDZ7YF26.js";import"./chunks/KUZCL2SH.js";import{b as F}from"./chunks/CQEVREBT.js";import"./chunks/HK6ZSONF.js";import"./chunks/7VAPNE3L.js";import"./chunks/EPYQ5M3B.js";import"./chunks/5IRF47YB.js";import"./chunks/OL5A6ITQ.js";import"./chunks/JFX2MXBA.js";import"./chunks/S34ZA2R6.js";import"./chunks/6FRNHMCV.js";import{b as o}from"./chunks/CUK7CGC7.js";import{J as N,K as T,L as c,M as R,N as O,O as A,P as I,Q as g,R as P,S as w,T as _,j as l,k as u,u as d,v as x,w as C}from"./chunks/BPRCULZH.js";import"./chunks/FJLU4UH3.js";import"./chunks/DDANMY45.js";import{a,b as i,l as m,m as E,q as p,u as s,x as f}from"./chunks/BBCW2FZK.js";import"./chunks/MMNNZCBO.js";import"./chunks/G44LG6VL.js";import"./chunks/D4PQP5MA.js";var j={name:"lagent:base",inject:["agents"],async apply(r){o(r,X),await r.plugin(n),await r.plugin(e,{confirm:t})}},X={name:"main",basePrompt:"You are a helpful AI assistant."};export{_ as AuxiliaryRefusedError,O as BirthConflictError,H as CODEX_ENVIRONMENT_POLICY,V as COMMUNICATION_GUIDANCE_PROMPT,g as ConfirmationAnsweredError,w as CorruptHistoryError,p as CorruptJournalError,R as DepthExceededError,G as FORMATTING_PROMPT,U as FileAccessError,x as ForkCutError,s as IncompatibleJournalError,a as InvalidOriginError,m as JournalBusyError,f as JournalCommitError,Y as MemoryJournalStore,B as NON_INTERACTIVE_ENVIRONMENT,C as ReplacementRefusedError,c as RestoreFailedError,l as RouteConflictError,u as RouteUnavailableError,E as StoreBusyError,I as ThreadActivatingError,T as ThreadBusyError,P as ThreadUnsettledError,M as UNCONFINED_LAUNCH,N as UnknownAgentError,S as UnknownRunError,d as UnknownThreadError,A as WriteRefusedError,j as base,D as buildSpawnEnvironment,W as codexPreset,J as core,i as forkChain,v as heldOrSettled,F as registerPreset,b as registerProvider,L as resolveTrustedPrograms,y as runToCompletion,h as spawnCommand,k as waitForRun};
@@ -1,4 +1,4 @@
1
- import type { ThreadOrigin, ThreadSummary } from '../models/index.js';
1
+ import type { ThreadOrigin, ThreadSummary } from '../records/journal.js';
2
2
  /**
3
3
  * Why a walk up the origin tree stopped short of a thread with no caller: `missing`, the caller is
4
4
  * not in the catalog; `cycle`, the caller was already met. `at` is the last thread the walk reached,
@@ -1,4 +1,4 @@
1
- import type { JournalEventInput, JournalEventType, JournalEvent, Seq, ThreadSummary } from '../models/index.js';
1
+ import type { JournalEventInput, JournalEventType, JournalEvent, Seq, ThreadSummary } from '../records/journal.js';
2
2
  import { type JsonValue } from '../util/json.js';
3
3
  import type { ReadonlyState } from '../util/foldState.js';
4
4
  import type { CoreFold, PluginProjection, Projection } from './projection.js';
@@ -111,7 +111,7 @@ export type JournalOptions = {
111
111
  * The append-only journal, the folds over it, and the catalog of its threads.
112
112
  *
113
113
  * Everything the loop needs to resume is a projection of these events, never a snapshot beside
114
- * them (`docs/architecture.md#state-and-lifetimes`).
114
+ * them (`docs/guides/architecture.md#state-and-lifetimes`).
115
115
  *
116
116
  * **Writes** go through one queue. `transact(threadId, build)` runs `build` once every earlier write
117
117
  * has landed and been folded, synchronously, against durable state, and appends what it returns in
@@ -131,7 +131,7 @@ export type JournalOptions = {
131
131
  * the catalog takes them, so a read hands out the journal's own and copies nothing.
132
132
  *
133
133
  * A thread may be a fork: its thread-scoped state is the fold over its **lineage**, the source's up
134
- * to the row its spawn row names, then its own rows (`docs/forks.md`). Seqs are global, so one bound
134
+ * to the row its spawn row names, then its own rows (`docs/records/forks.md`). Seqs are global, so one bound
135
135
  * applies at every hop of a fork of a fork.
136
136
  *
137
137
  * The journal parses what it is given and writes it. A row whose meaning depends on the state it
@@ -1,4 +1,4 @@
1
- import { type JournalEvent } from '../models/index.js';
1
+ import { type JournalEvent } from '../records/journal.js';
2
2
  /**
3
3
  * A fold over the journal, as the journal itself holds it.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { JournalEvent, Seq, ThreadSummary } from '../models/index.js';
1
+ import type { JournalEvent, Seq, ThreadSummary } from '../records/journal.js';
2
2
  /**
3
3
  * One group's write: a fresh identity, the head it was numbered from, the writer's acquisition, and
4
4
  * the rows. Immutable once made, so a write whose answer was lost can be sent again as it was.
@@ -31,7 +31,7 @@ export type WriterLease = {
31
31
  * Durable backing for the journal: the rows, one thread at a time, an index of the threads, the
32
32
  * catalog of summaries beside them, and the record of who may write. Every method is asynchronous,
33
33
  * so a store across a network implements the same contract as SQLite; the conformance suite
34
- * (`plugins/store/conformance.ts`) is what every store passes.
34
+ * (`stores/testing/conformance.ts`) is what every store passes.
35
35
  *
36
36
  * `append` must be durable enough that a crash after it resolves still replays the rows, because
37
37
  * nothing else records them. That is also why `read` refuses a row it cannot parse rather than
@@ -166,7 +166,7 @@ export declare function parseStoredSummary(payload: string): ThreadSummary;
166
166
  * A breaking change to persisted rows bumps it too, a plugin's extension row version bump included.
167
167
  * Indexes enforcing existing invariants do not change the format.
168
168
  */
169
- export declare const JOURNAL_VERSION = 38;
169
+ export declare const JOURNAL_VERSION = 44;
170
170
  /** A journal written by a build whose format this one cannot read. */
171
171
  export declare class IncompatibleJournalError extends Error {
172
172
  readonly found: number;
@@ -1,16 +1,22 @@
1
1
  /**
2
- * The model layer's entry point inside the package: the model-facing alphabet and the provider
3
- * contract, every name its modules export. Outer layers import from here only. What the package
4
- * offers others is the narrower `door.ts` (`@leuduan/lagent/llm`).
2
+ * `@leuduan/lagent/llm`: the model and provider contracts as the package offers them, for a provider
3
+ * written outside it and a host that calls a model. Every type the contract mentions, and the values
4
+ * a consumer uses; the schemas and helpers the engine uses itself stay in their modules, which the
5
+ * package imports directly.
5
6
  *
6
- * It depends on `zod` alone, so a provider client built on it works in any harness, not only in a
7
- * lagent session.
7
+ * It depends on `zod` alone, so a provider client built on it works in any harness.
8
8
  */
9
- export * from './client.js';
10
- export * from './content.js';
11
- export * from './failure.js';
12
- export * from './primitives.js';
13
- export * from './prompt.js';
14
- export * from './provider.js';
15
- export * from './readLedger.js';
16
- export * from './request.js';
9
+ export { ContextOverflowError, ProviderUnsupportedError, ResponseInterruptedError, ResponseSettlementError, StreamIdleError, } from './client.js';
10
+ export type { LLMClient, ModelCapacity, ModelOption, ResponseSettlementKind, StreamingLLMResponse } from './client.js';
11
+ export { contentText } from './content.js';
12
+ export { ModelCallError } from './failure.js';
13
+ export type { FailureClassification, FailureKind, ModelCallClient, ModelCallHandle } from './failure.js';
14
+ export type { DeepReadonly, ReadonlyJsonValue } from '../util/json.js';
15
+ export type { ContentPart, ContentPartInput, ContentPartKind } from './content.js';
16
+ export { conversationMessage, LLMStreamChunkSchema, messageText, ThinkingEffortSchema } from './primitives.js';
17
+ export type { ConversationMessage, JsonObject, LLMStreamChunk, LLMUsage, MalformedToolCall, MessageRole, ModelResponse, ParsedToolCall, ProviderCall, ProviderState, ResponseFinish, ThinkingEffort, ToolCall, ToolSpec, } from './primitives.js';
18
+ export { renderPromptBlocks } from './prompt.js';
19
+ export type { PromptBlock } from './prompt.js';
20
+ export { defaultRoute } from './provider.js';
21
+ export type { LLMProvider, ModelRoute } from './provider.js';
22
+ export type { ModelRequest, RequestPurpose, ResponseFormat, ToolChoice } from './request.js';
@@ -0,0 +1 @@
1
+ import{b as m,e as l}from"../chunks/G44LG6VL.js";import{A as d,d as r,f as e,o,q as t,r as n,u as p,v as s,w as f,x as a,y as x}from"../chunks/D4PQP5MA.js";export{s as ContextOverflowError,o as LLMStreamChunkSchema,l as ModelCallError,p as ProviderUnsupportedError,x as ResponseInterruptedError,f as ResponseSettlementError,a as StreamIdleError,e as ThinkingEffortSchema,r as contentText,t as conversationMessage,m as defaultRoute,n as messageText,d as renderPromptBlocks};
@@ -23,6 +23,17 @@ export declare const ModelRouteSchema: z.ZodObject<{
23
23
  }>>;
24
24
  }, z.core.$strip>;
25
25
  export type ModelRoute = z.infer<typeof ModelRouteSchema>;
26
+ /**
27
+ * Route fields to fold over a route (`LlmService.resolveRoute`): absent fields keep the route's own;
28
+ * naming a different provider resets what is left unnamed to that provider's defaults. A `null`
29
+ * effort names the provider's own default, as a route records it, so a complete route resolves to
30
+ * itself.
31
+ */
32
+ export type ModelSelection = {
33
+ readonly provider?: string;
34
+ readonly model?: string;
35
+ readonly thinkingEffort?: ThinkingEffort | null;
36
+ };
26
37
  /** A model provider plugin registers one of these. */
27
38
  export interface LLMProvider {
28
39
  readonly name: string;
@@ -1,134 +1,18 @@
1
- import type { Seq, TurnEndReason } from '../models/index.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';
1
+ import { z } from 'zod';
5
2
  /**
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.
3
+ * One agent: its name and the base of its prompt. Registered programmatically with
4
+ * `ctx.agents.register` (usually through `registerAgent`); the name is how threads
5
+ * and other agents refer to it.
6
+ *
7
+ * Strict: an agent says who it is, and nothing else. What it may call is granted to it by name
8
+ * (`grantTool`) by the plugins that compose the application; instruction and context sections come
9
+ * from plugins through `ctx.prompts`; how callers see it, a description and guidance, belongs to the
10
+ * `subAgents` endpoint that offers it. A plugin that needs per-agent configuration keys it by agent
11
+ * name in its own config, so a misspelled key is rejected here instead of silently ignored there.
8
12
  */
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 LoopAgent {
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
- }
13
+ export declare const AgentDefinitionSchema: z.ZodObject<{
14
+ name: z.ZodString;
15
+ basePrompt: z.ZodDefault<z.ZodString>;
16
+ }, z.core.$strict>;
17
+ export type AgentDefinition = z.infer<typeof AgentDefinitionSchema>;
18
+ export type AgentDefinitionInput = z.input<typeof AgentDefinitionSchema>;
@@ -0,0 +1,41 @@
1
+ import type { AppendEntry, Journal } from '../journal/index.js';
2
+ import type { ExtensionRecord, Seq } from '../records/journal.js';
3
+ import type { LoopRuntime } from './runtime.js';
4
+ import type { ToolAuthorization, ToolAuthorizationRequest } from './hooks.js';
5
+ /**
6
+ * One owner for authorization ordering: flush policy writes, read approval, collect all policies,
7
+ * then commit only against the policy state they saw. Authorization and any approval request are
8
+ * one write guarded against cancellation. Both model and runtime dispatch use it.
9
+ */
10
+ export declare function authorizeOperation(options: {
11
+ runtime: LoopRuntime;
12
+ request: ToolAuthorizationRequest;
13
+ signal: AbortSignal;
14
+ approval(): {
15
+ approved: boolean;
16
+ rejection_message: string | null;
17
+ } | undefined;
18
+ validate?(): void;
19
+ record(authorization: ToolAuthorization): readonly [AppendEntry<'tool/authorization' | 'execution/authorization'>, ...AppendEntry<'confirm/requested'>[]];
20
+ }): Promise<{
21
+ kind: 'decided';
22
+ authorization: ToolAuthorization;
23
+ attemptSeq: Seq;
24
+ } | {
25
+ kind: 'rejected';
26
+ reason: string | null;
27
+ } | {
28
+ kind: 'unstarted';
29
+ }>;
30
+ /**
31
+ * Declares the `ext` rows of one plugin event state a `lagent/tool/authorize` listener decides
32
+ * from: one that lands while a call is authorized sends the decision round again, which no other
33
+ * `ext` row does. `defineExtensionEvent({ policyState: true })` is the way in.
34
+ */
35
+ export declare function declarePolicyState(record: Pick<ExtensionRecord, 'plugin' | 'instance_id' | 'kind'>): void;
36
+ /**
37
+ * Whether policy state — declared `ext` rows or answers (`confirm/resolved`) — landed after `from`
38
+ * on `threadId` or a thread that called it: what a running thread's policies read. A thread of that
39
+ * chain that is not loaded counts as changed if anything landed on it.
40
+ */
41
+ export declare function policyChangedSince(journal: Journal, threadId: string, from: Seq): boolean;
@@ -1,6 +1,10 @@
1
- import type { ContentPartInput, ConversationMessage, LLMUsage, ModelRoute, ResponseFinish, ToolChoice } from '../llm/index.js';
2
- import type { Seq } from '../models/index.js';
3
- import type { LoopRuntime, ModelSelection } from './runtime.js';
1
+ import type { ContentPartInput } from '../llm/content.js';
2
+ import type { ConversationMessage, LLMUsage, ResponseFinish } from '../llm/primitives.js';
3
+ import type { ToolChoice } from '../llm/request.js';
4
+ import type { ModelRoute } from '../llm/provider.js';
5
+ import type { Seq } from '../records/journal.js';
6
+ import type { LoopRuntime } from './runtime.js';
7
+ import type { ModelSelection } from '../llm/provider.js';
4
8
  /**
5
9
  * One auxiliary model call as a strategy asks for it. The engine builds the request: the head a step
6
10
  * would send now (the recorded prompt and the tools the agent is granted), then the current surface
@@ -1,8 +1,8 @@
1
- import type { LLMStreamChunk } from '../llm/index.js';
1
+ import type { LLMStreamChunk } from '../llm/primitives.js';
2
2
  /** One delta off a model stream, with enough context for a frontend to place it. */
3
3
  export type StreamedChunk = {
4
- readonly thread_id: string;
5
- readonly llm_call_id: string;
4
+ readonly threadId: string;
5
+ readonly llmCallId: string;
6
6
  readonly turn: number;
7
7
  readonly step: number;
8
8
  readonly chunk: LLMStreamChunk;