@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
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { type ContentPartInput } from '../../llm/index.js';
3
- import type { DeepReadonly } from '../../util/json.js';
2
+ import { type ContentPartInput } from '../llm/content.js';
3
+ import type { DeepReadonly } from '../util/json.js';
4
4
  declare const seq: z.ZodNumber;
5
5
  /** Monotonic position in the journal. Assigned by `append`, never by a caller. */
6
6
  export type Seq = z.infer<typeof seq>;
@@ -385,7 +385,6 @@ export type ThreadFork = z.infer<typeof ThreadForkSchema>;
385
385
  /** Where a thread's work happens. Engine-read and typed, unlike `metadata`. */
386
386
  export declare const ThreadEnvironmentSchema: z.ZodObject<{
387
387
  cwd: z.ZodString;
388
- read_roots: z.ZodArray<z.ZodString>;
389
388
  }, z.core.$strip>;
390
389
  export type ThreadEnvironment = z.infer<typeof ThreadEnvironmentSchema>;
391
390
  /**
@@ -867,6 +866,65 @@ export declare const JOURNAL_EVENT_DATA: {
867
866
  turn: z.ZodNumber;
868
867
  step: z.ZodNumber;
869
868
  }, z.core.$strip>;
869
+ /** A runtime-owned operation preparing one candidate for acceptance; never a model message. */
870
+ readonly 'execution/requested': z.ZodObject<{
871
+ turn: z.ZodNumber;
872
+ candidate_seq: z.ZodNumber;
873
+ owner: z.ZodString;
874
+ key: z.ZodString;
875
+ operation: z.ZodObject<{
876
+ name: z.ZodString;
877
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
878
+ }, z.core.$strip>;
879
+ }, z.core.$strip>;
880
+ /** Durable before dispatch: an allowed execution without a result may already have taken effect. */
881
+ readonly 'execution/authorization': z.ZodObject<{
882
+ turn: z.ZodNumber;
883
+ request_seq: z.ZodNumber;
884
+ decision: z.ZodEnum<{
885
+ allow: "allow";
886
+ confirm: "confirm";
887
+ deny: "deny";
888
+ }>;
889
+ confirmed_by: z.ZodNullable<z.ZodEnum<{
890
+ user: "user";
891
+ policy: "policy";
892
+ }>>;
893
+ reasons: z.ZodArray<z.ZodString>;
894
+ }, z.core.$strip>;
895
+ readonly 'execution/result': z.ZodObject<{
896
+ request_seq: z.ZodNumber;
897
+ result: z.ZodObject<{
898
+ output: z.ZodString;
899
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
900
+ type: z.ZodLiteral<"text">;
901
+ text: z.ZodString;
902
+ }, z.core.$strip>, z.ZodObject<{
903
+ type: z.ZodLiteral<"image">;
904
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
905
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
906
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
907
+ detail: z.ZodDefault<z.ZodEnum<{
908
+ auto: "auto";
909
+ low: "low";
910
+ high: "high";
911
+ }>>;
912
+ }, z.core.$strip>, z.ZodObject<{
913
+ type: z.ZodLiteral<"file">;
914
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
915
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
916
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
917
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
918
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
919
+ }, z.core.$strip>], "type">>>;
920
+ is_error: z.ZodDefault<z.ZodBoolean>;
921
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
922
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
923
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
924
+ call_id: z.ZodString;
925
+ name: z.ZodString;
926
+ }, z.core.$strip>;
927
+ }, z.core.$strip>;
870
928
  /**
871
929
  * A dispatched call suspended: its tool waits on a dependency `owner`, a registered constraint
872
930
  * owner, alone interprets and resolves. The call stays unanswered and is not dispatched again until
@@ -892,6 +950,7 @@ export declare const JOURNAL_EVENT_DATA: {
892
950
  value: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
893
951
  }, z.core.$strip>;
894
952
  readonly 'confirm/requested': z.ZodObject<{
953
+ step: z.ZodNumber;
895
954
  request_id: z.ZodString;
896
955
  tool_call: z.ZodObject<{
897
956
  call_id: z.ZodString;
@@ -899,8 +958,14 @@ export declare const JOURNAL_EVENT_DATA: {
899
958
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
900
959
  }, z.core.$loose>;
901
960
  reason: z.ZodString;
961
+ target: z.ZodObject<{
962
+ kind: z.ZodEnum<{
963
+ model: "model";
964
+ runtime: "runtime";
965
+ }>;
966
+ seq: z.ZodNumber;
967
+ }, z.core.$strict>;
902
968
  turn: z.ZodNumber;
903
- step: z.ZodNumber;
904
969
  }, z.core.$strip>;
905
970
  readonly 'confirm/resolved': z.ZodObject<{
906
971
  request_id: z.ZodString;
@@ -932,7 +997,6 @@ export declare const JOURNAL_EVENT_DATA: {
932
997
  }, z.core.$strip>>>;
933
998
  environment: z.ZodObject<{
934
999
  cwd: z.ZodString;
935
- read_roots: z.ZodArray<z.ZodString>;
936
1000
  }, z.core.$strip>;
937
1001
  installations: z.ZodDefault<z.ZodArray<z.ZodObject<{
938
1002
  installation_id: z.ZodString;
@@ -1254,7 +1318,7 @@ export type JournalEvent<K extends JournalEventType = JournalEventType> = {
1254
1318
  /** Runtime validation for a stored row. Narrow with {@link JournalEvent}, not with `z.infer`. */
1255
1319
  export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1256
1320
  seq: z.ZodNumber;
1257
- type: z.ZodLiteral<"error" | "ext" | "turn/start" | "turn/end" | "step/start" | "step/end" | "input/message" | "llm/request" | "assistant/message" | "assistant/attempt" | "auxiliary/request" | "auxiliary/result" | "tool/call" | "tool/authorization" | "tool/result" | "wait/declared" | "wait/resolved" | "confirm/requested" | "confirm/resolved" | "thread/spawned" | "installation/applied" | "installation/removed" | "thread/prompt" | "thread/tools" | "run/requested" | "run/cause" | "run/settled" | "thread/cancel" | "inbox/spliced" | "surface/replaced">;
1321
+ type: z.ZodLiteral<"error" | "ext" | "turn/start" | "turn/end" | "step/start" | "step/end" | "input/message" | "llm/request" | "assistant/message" | "assistant/attempt" | "auxiliary/request" | "auxiliary/result" | "tool/call" | "tool/authorization" | "tool/result" | "execution/requested" | "execution/authorization" | "execution/result" | "wait/declared" | "wait/resolved" | "confirm/requested" | "confirm/resolved" | "thread/spawned" | "installation/applied" | "installation/removed" | "thread/prompt" | "thread/tools" | "run/requested" | "run/cause" | "run/settled" | "thread/cancel" | "inbox/spliced" | "surface/replaced">;
1258
1322
  timestamp: z.ZodDefault<z.ZodISODateTime>;
1259
1323
  thread_id: z.ZodString;
1260
1324
  data: z.ZodObject<{
@@ -1729,6 +1793,60 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1729
1793
  }, z.core.$strip>;
1730
1794
  turn: z.ZodNumber;
1731
1795
  step: z.ZodNumber;
1796
+ }, z.core.$strip> | z.ZodObject<{
1797
+ turn: z.ZodNumber;
1798
+ candidate_seq: z.ZodNumber;
1799
+ owner: z.ZodString;
1800
+ key: z.ZodString;
1801
+ operation: z.ZodObject<{
1802
+ name: z.ZodString;
1803
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1804
+ }, z.core.$strip>;
1805
+ }, z.core.$strip> | z.ZodObject<{
1806
+ turn: z.ZodNumber;
1807
+ request_seq: z.ZodNumber;
1808
+ decision: z.ZodEnum<{
1809
+ allow: "allow";
1810
+ confirm: "confirm";
1811
+ deny: "deny";
1812
+ }>;
1813
+ confirmed_by: z.ZodNullable<z.ZodEnum<{
1814
+ user: "user";
1815
+ policy: "policy";
1816
+ }>>;
1817
+ reasons: z.ZodArray<z.ZodString>;
1818
+ }, z.core.$strip> | z.ZodObject<{
1819
+ request_seq: z.ZodNumber;
1820
+ result: z.ZodObject<{
1821
+ output: z.ZodString;
1822
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1823
+ type: z.ZodLiteral<"text">;
1824
+ text: z.ZodString;
1825
+ }, z.core.$strip>, z.ZodObject<{
1826
+ type: z.ZodLiteral<"image">;
1827
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1828
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1829
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1830
+ detail: z.ZodDefault<z.ZodEnum<{
1831
+ auto: "auto";
1832
+ low: "low";
1833
+ high: "high";
1834
+ }>>;
1835
+ }, z.core.$strip>, z.ZodObject<{
1836
+ type: z.ZodLiteral<"file">;
1837
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1838
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1839
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1840
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1841
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1842
+ }, z.core.$strip>], "type">>>;
1843
+ is_error: z.ZodDefault<z.ZodBoolean>;
1844
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
1845
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1846
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
1847
+ call_id: z.ZodString;
1848
+ name: z.ZodString;
1849
+ }, z.core.$strip>;
1732
1850
  }, z.core.$strip> | z.ZodObject<{
1733
1851
  call_id: z.ZodString;
1734
1852
  call_seq: z.ZodNumber;
@@ -1742,6 +1860,7 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1742
1860
  call_seq: z.ZodNumber;
1743
1861
  value: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
1744
1862
  }, z.core.$strip> | z.ZodObject<{
1863
+ step: z.ZodNumber;
1745
1864
  request_id: z.ZodString;
1746
1865
  tool_call: z.ZodObject<{
1747
1866
  call_id: z.ZodString;
@@ -1749,8 +1868,14 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1749
1868
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1750
1869
  }, z.core.$loose>;
1751
1870
  reason: z.ZodString;
1871
+ target: z.ZodObject<{
1872
+ kind: z.ZodEnum<{
1873
+ model: "model";
1874
+ runtime: "runtime";
1875
+ }>;
1876
+ seq: z.ZodNumber;
1877
+ }, z.core.$strict>;
1752
1878
  turn: z.ZodNumber;
1753
- step: z.ZodNumber;
1754
1879
  }, z.core.$strip> | z.ZodObject<{
1755
1880
  request_id: z.ZodString;
1756
1881
  approved: z.ZodBoolean;
@@ -1775,7 +1900,6 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1775
1900
  }, z.core.$strip>>>;
1776
1901
  environment: z.ZodObject<{
1777
1902
  cwd: z.ZodString;
1778
- read_roots: z.ZodArray<z.ZodString>;
1779
1903
  }, z.core.$strip>;
1780
1904
  installations: z.ZodDefault<z.ZodArray<z.ZodObject<{
1781
1905
  installation_id: z.ZodString;
@@ -1929,7 +2053,7 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1929
2053
  source_seqs: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
1930
2054
  }, z.core.$strip>, ...z.ZodObject<{
1931
2055
  seq: z.ZodNumber;
1932
- type: z.ZodLiteral<"error" | "ext" | "turn/start" | "turn/end" | "step/start" | "step/end" | "input/message" | "llm/request" | "assistant/message" | "assistant/attempt" | "auxiliary/request" | "auxiliary/result" | "tool/call" | "tool/authorization" | "tool/result" | "wait/declared" | "wait/resolved" | "confirm/requested" | "confirm/resolved" | "thread/spawned" | "installation/applied" | "installation/removed" | "thread/prompt" | "thread/tools" | "run/requested" | "run/cause" | "run/settled" | "thread/cancel" | "inbox/spliced" | "surface/replaced">;
2056
+ type: z.ZodLiteral<"error" | "ext" | "turn/start" | "turn/end" | "step/start" | "step/end" | "input/message" | "llm/request" | "assistant/message" | "assistant/attempt" | "auxiliary/request" | "auxiliary/result" | "tool/call" | "tool/authorization" | "tool/result" | "execution/requested" | "execution/authorization" | "execution/result" | "wait/declared" | "wait/resolved" | "confirm/requested" | "confirm/resolved" | "thread/spawned" | "installation/applied" | "installation/removed" | "thread/prompt" | "thread/tools" | "run/requested" | "run/cause" | "run/settled" | "thread/cancel" | "inbox/spliced" | "surface/replaced">;
1933
2057
  timestamp: z.ZodDefault<z.ZodISODateTime>;
1934
2058
  thread_id: z.ZodString;
1935
2059
  data: z.ZodObject<{
@@ -2404,6 +2528,60 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2404
2528
  }, z.core.$strip>;
2405
2529
  turn: z.ZodNumber;
2406
2530
  step: z.ZodNumber;
2531
+ }, z.core.$strip> | z.ZodObject<{
2532
+ turn: z.ZodNumber;
2533
+ candidate_seq: z.ZodNumber;
2534
+ owner: z.ZodString;
2535
+ key: z.ZodString;
2536
+ operation: z.ZodObject<{
2537
+ name: z.ZodString;
2538
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2539
+ }, z.core.$strip>;
2540
+ }, z.core.$strip> | z.ZodObject<{
2541
+ turn: z.ZodNumber;
2542
+ request_seq: z.ZodNumber;
2543
+ decision: z.ZodEnum<{
2544
+ allow: "allow";
2545
+ confirm: "confirm";
2546
+ deny: "deny";
2547
+ }>;
2548
+ confirmed_by: z.ZodNullable<z.ZodEnum<{
2549
+ user: "user";
2550
+ policy: "policy";
2551
+ }>>;
2552
+ reasons: z.ZodArray<z.ZodString>;
2553
+ }, z.core.$strip> | z.ZodObject<{
2554
+ request_seq: z.ZodNumber;
2555
+ result: z.ZodObject<{
2556
+ output: z.ZodString;
2557
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2558
+ type: z.ZodLiteral<"text">;
2559
+ text: z.ZodString;
2560
+ }, z.core.$strip>, z.ZodObject<{
2561
+ type: z.ZodLiteral<"image">;
2562
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2563
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2564
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2565
+ detail: z.ZodDefault<z.ZodEnum<{
2566
+ auto: "auto";
2567
+ low: "low";
2568
+ high: "high";
2569
+ }>>;
2570
+ }, z.core.$strip>, z.ZodObject<{
2571
+ type: z.ZodLiteral<"file">;
2572
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2573
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2574
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2575
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2576
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
2577
+ }, z.core.$strip>], "type">>>;
2578
+ is_error: z.ZodDefault<z.ZodBoolean>;
2579
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
2580
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2581
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
2582
+ call_id: z.ZodString;
2583
+ name: z.ZodString;
2584
+ }, z.core.$strip>;
2407
2585
  }, z.core.$strip> | z.ZodObject<{
2408
2586
  call_id: z.ZodString;
2409
2587
  call_seq: z.ZodNumber;
@@ -2417,6 +2595,7 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2417
2595
  call_seq: z.ZodNumber;
2418
2596
  value: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
2419
2597
  }, z.core.$strip> | z.ZodObject<{
2598
+ step: z.ZodNumber;
2420
2599
  request_id: z.ZodString;
2421
2600
  tool_call: z.ZodObject<{
2422
2601
  call_id: z.ZodString;
@@ -2424,8 +2603,14 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2424
2603
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2425
2604
  }, z.core.$loose>;
2426
2605
  reason: z.ZodString;
2606
+ target: z.ZodObject<{
2607
+ kind: z.ZodEnum<{
2608
+ model: "model";
2609
+ runtime: "runtime";
2610
+ }>;
2611
+ seq: z.ZodNumber;
2612
+ }, z.core.$strict>;
2427
2613
  turn: z.ZodNumber;
2428
- step: z.ZodNumber;
2429
2614
  }, z.core.$strip> | z.ZodObject<{
2430
2615
  request_id: z.ZodString;
2431
2616
  approved: z.ZodBoolean;
@@ -2450,7 +2635,6 @@ export declare const JournalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2450
2635
  }, z.core.$strip>>>;
2451
2636
  environment: z.ZodObject<{
2452
2637
  cwd: z.ZodString;
2453
- read_roots: z.ZodArray<z.ZodString>;
2454
2638
  }, z.core.$strip>;
2455
2639
  installations: z.ZodDefault<z.ZodArray<z.ZodObject<{
2456
2640
  installation_id: z.ZodString;
@@ -2611,7 +2795,13 @@ export declare const isSurfaceEvent: (event: JournalEvent) => event is JournalEv
2611
2795
  /** One confirmation a thread still waits on, as its summary lists it: enough to find it, not to show it. */
2612
2796
  export declare const ConfirmationDescriptorSchema: z.ZodObject<{
2613
2797
  request_id: z.ZodString;
2614
- call_seq: z.ZodNullable<z.ZodNumber>;
2798
+ target: z.ZodObject<{
2799
+ kind: z.ZodEnum<{
2800
+ model: "model";
2801
+ runtime: "runtime";
2802
+ }>;
2803
+ seq: z.ZodNumber;
2804
+ }, z.core.$strict>;
2615
2805
  tool_name: z.ZodString;
2616
2806
  reason: z.ZodString;
2617
2807
  }, z.core.$strip>;
@@ -2660,7 +2850,6 @@ export declare const ThreadSummarySchema: z.ZodObject<{
2660
2850
  }, z.core.$strip>>;
2661
2851
  environment: z.ZodObject<{
2662
2852
  cwd: z.ZodString;
2663
- read_roots: z.ZodArray<z.ZodString>;
2664
2853
  }, z.core.$strip>;
2665
2854
  has_work: z.ZodBoolean;
2666
2855
  turn_open: z.ZodBoolean;
@@ -2723,9 +2912,16 @@ export declare const ThreadSummarySchema: z.ZodObject<{
2723
2912
  }>>;
2724
2913
  }, z.core.$strip>;
2725
2914
  queued_input: z.ZodNumber;
2915
+ queued_for_turn: z.ZodNumber;
2726
2916
  unanswered_confirmations: z.ZodArray<z.ZodObject<{
2727
2917
  request_id: z.ZodString;
2728
- call_seq: z.ZodNullable<z.ZodNumber>;
2918
+ target: z.ZodObject<{
2919
+ kind: z.ZodEnum<{
2920
+ model: "model";
2921
+ runtime: "runtime";
2922
+ }>;
2923
+ seq: z.ZodNumber;
2924
+ }, z.core.$strict>;
2729
2925
  tool_name: z.ZodString;
2730
2926
  reason: z.ZodString;
2731
2927
  }, z.core.$strip>>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import type { ContentPart } from '../../llm/index.js';
2
+ import type { ContentPart } from '../llm/content.js';
3
3
  export declare const ToolResultPayloadSchema: z.ZodObject<{
4
4
  output: z.ZodString;
5
5
  content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1,5 +1,6 @@
1
1
  import { Context, Service, type ScopeKey } from '@leuduan/cordis';
2
- import type { AgentDefinition, AgentDefinitionInput } from '../models/index.js';
2
+ import { z } from 'zod';
3
+ import { type AgentDefinition, type AgentDefinitionInput } from '../loop/index.js';
3
4
  /** A definition and the layer that registered it: `undefined` for the global one. */
4
5
  export type AgentResolution = {
5
6
  readonly agent: AgentDefinition;
@@ -35,3 +36,27 @@ export declare class AgentsService extends Service {
35
36
  }
36
37
  /** Registers an agent in the calling plugin's layer for the lifetime of its fiber. */
37
38
  export declare const registerAgent: (ctx: Context, agent: AgentDefinitionInput) => (() => void | Promise<void>);
39
+ /**
40
+ * The agents a plugin's `agents` option selects. Required wherever it appears: which agents a
41
+ * composition has is the host's to say, so none of the shipped plugins defaults it. `'global'` is
42
+ * every globally registered agent, those registered later included; `'all'` is every thread's agent,
43
+ * scoped ones included; a list names agents, global or scoped.
44
+ */
45
+ export declare const AgentSelectorSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodLiteral<"global">, z.ZodLiteral<"all">]>;
46
+ export type AgentSelector = readonly string[] | 'global' | 'all';
47
+ /**
48
+ * Whether `selector` selects `agentName`. One meaning wherever a selector appears, whether the plugin
49
+ * equips (a grant, a prompt section, a notice) or restricts (a mode, a stop check). `'global'` never
50
+ * selects a scoped agent (`isScopedAgentName`), so a role child gets only what names it or says
51
+ * `'all'`; a gate that must cover role children says `'all'`.
52
+ *
53
+ * Registries are live, so a selector is a predicate evaluated when the plugin acts — granting,
54
+ * rendering a prompt section, authorizing a call — rather than a list resolved once at mount.
55
+ */
56
+ export declare const selects: (selector: AgentSelector, agentName: string) => boolean;
57
+ /**
58
+ * Whether `name` is an agent name for a scoped registration: one containing a dot, such as
59
+ * `codex.explore`. Global agent names never contain one, so the two kinds cannot collide, and the
60
+ * agents registry refuses a registration of the wrong kind.
61
+ */
62
+ export declare const isScopedAgentName: (name: string) => boolean;
@@ -0,0 +1,118 @@
1
+ import { type Stats } from 'node:fs';
2
+ import type { FileAccess, FilePolicy } from './service.js';
3
+ /**
4
+ * The scoped file facade: how file tools touch the file system. One implementation, owned by the
5
+ * operation (`ConfinementOperation.files`), which applies the operation's `FilePolicy` to every
6
+ * path and ends with the operation. With no policy it authorizes everything but keeps the same
7
+ * lifetime rules, so a tool cannot tell which it has.
8
+ *
9
+ * Every check covers the path as requested (absolute and normalized) and the path it resolves to,
10
+ * resolved natively so it carries the volume's own spelling, and a path is refused when either is.
11
+ * A file is opened by its resolved path without following a final link, and the handle is verified
12
+ * (the file opened is the file approved, and the requested path still leads to it) before any byte
13
+ * is read through it. This narrows the race between check and use to the revalidation window; it does
14
+ * not close it, and hard links are not detected.
15
+ *
16
+ * Changes are primitives on regular files, never a write of a whole file: a file is created exclusively
17
+ * (never opened for writing over what exists, and never truncated), and committed by `link` or
18
+ * `rename`, which the caller owns. A directory is never renamed or removed, and nothing is changed
19
+ * through a link: the target of a change is refused when it is itself a symbolic link, naming where it
20
+ * leads. Each primitive judges its paths at the moment it runs, so a path swapped after the caller's
21
+ * own checks is judged as it is then.
22
+ */
23
+ /** A refusal by the file policy, whose message is for the model. */
24
+ export declare class FileAccessError extends Error {
25
+ constructor(message: string);
26
+ }
27
+ /** An open file as a tool may use it: reads only, through the handle the facade verified. */
28
+ export type ReadHandle = {
29
+ /** Up to `length` bytes from `position`; fewer only at the end of the file. */
30
+ read(position: number, length: number): Promise<Buffer>;
31
+ /** All of the file from its start. */
32
+ readAll(): Promise<Buffer>;
33
+ /** The opened file's own metadata. */
34
+ stat(): Promise<Stats>;
35
+ close(): Promise<void>;
36
+ };
37
+ /** A new file as a tool may fill it: writes only, through the handle the facade created. */
38
+ export type WriteHandle = {
39
+ /** Appends all of `data`. */
40
+ write(data: Uint8Array): Promise<void>;
41
+ /** Flushes what was written to the device. */
42
+ sync(): Promise<void>;
43
+ /** The created file's own metadata. */
44
+ stat(): Promise<Stats>;
45
+ close(): Promise<void>;
46
+ };
47
+ /** Which access a call judges its paths for: a read unless the caller says what it intends. */
48
+ export type PathOptions = {
49
+ readonly access?: readonly FileAccess[];
50
+ };
51
+ /** One entry of a directory the policy lets through. */
52
+ export type DirEntry = {
53
+ readonly name: string;
54
+ readonly isDirectory: boolean;
55
+ readonly isSymbolicLink: boolean;
56
+ };
57
+ /** A directory's allowed entries, and how many the policy hid. */
58
+ export type DirListing = {
59
+ readonly entries: readonly DirEntry[];
60
+ readonly hidden: number;
61
+ };
62
+ /**
63
+ * What a tool does to files, within one operation. Paths are absolute. Every method rejects with a
64
+ * {@link FileAccessError} for a path the policy refuses, and with an ordinary error once the
65
+ * operation has ended or was aborted: a reference that outlives its call is dead.
66
+ */
67
+ export type FileScope = {
68
+ /**
69
+ * Names how this facade judges reads (`FilePolicy.identity`, or `unrestricted` with no policy): taking
70
+ * it takes the operation's snapshot, so a refused operation rejects here. What a reader that keeps
71
+ * its result for another thread to use keys it by.
72
+ */
73
+ identity(): Promise<string>;
74
+ /** Opens a file for reading, where links resolve and are checked. Never a raw descriptor. */
75
+ open(path: string): Promise<ReadHandle>;
76
+ /** The entries of a directory, with every entry the policy refuses (or a link resolving to one) left out and counted. */
77
+ readdir(path: string): Promise<DirListing>;
78
+ /** Metadata of the file a path leads to. */
79
+ stat(path: string, options?: PathOptions): Promise<Stats>;
80
+ /** Metadata of a path itself, not of what a final link leads to. */
81
+ lstat(path: string, options?: PathOptions): Promise<Stats>;
82
+ /**
83
+ * The path with every link resolved, as the checks see it; a missing tail stays as named, after the
84
+ * nearest existing ancestor's real path. `options.access` names what the caller means to do with it.
85
+ */
86
+ realpath(path: string, options?: PathOptions): Promise<string>;
87
+ /**
88
+ * Creates a new file that must not exist, with `mode` as given, for writing; never replaces or truncates.
89
+ * A `temporary` file is the caller's scratch: it may be removed with `unlink` even after a cancellation,
90
+ * and is removed when the operation ends unless the caller has put it elsewhere.
91
+ */
92
+ create(path: string, options?: {
93
+ readonly mode?: number;
94
+ readonly temporary?: boolean;
95
+ }): Promise<WriteHandle>;
96
+ /** Creates a directory and any missing parents. */
97
+ mkdir(path: string): Promise<void>;
98
+ /** Hard-links the regular file `existing` as `created`, which must not exist. */
99
+ link(existing: string, created: string): Promise<void>;
100
+ /** Renames a regular file over `to`, which is absent or a regular file; a directory is never renamed. */
101
+ rename(from: string, to: string): Promise<void>;
102
+ /** Removes a regular file; a directory is never removed. A `temporary` file this operation created goes even after a stop. */
103
+ unlink(path: string): Promise<void>;
104
+ /** Sets the mode of a regular file. */
105
+ chmod(path: string, mode: number): Promise<void>;
106
+ };
107
+ /** What the operation hands its facade. */
108
+ export type FileScopeHost = {
109
+ /** The operation's policy, which the first call takes; `null` for no path policy. Rejects when the operation is refused. */
110
+ policy(): Promise<FilePolicy | null>;
111
+ /** Aborts when the call is cancelled, the operation ends or its handler is released: checked between file system calls. */
112
+ signal(): AbortSignal;
113
+ };
114
+ /** The facade's lifetime: `end` closes what it opened and kills its methods. */
115
+ export type EndableFileScope = FileScope & {
116
+ end(): Promise<void>;
117
+ };
118
+ export declare function fileScope(host: FileScopeHost): EndableFileScope;