@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 +0,0 @@
1
- import{a,b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l}from"../../chunks/WUUKTSRT.js";import"../../chunks/NDIM7MEW.js";import"../../chunks/34KW6VNQ.js";import"../../chunks/PUSUPTAT.js";import"../../chunks/DDANMY45.js";import"../../chunks/D7E6EWIE.js";export{c as CODEX_PROVIDER_NAME,a as CodexCredentialError,d as DEEPSEEK_RESPONSES_PROVIDER_NAME,f as OPENCODE_COPILOT_PROVIDER_NAME,e as OPENCODE_GO_PROVIDER_NAME,b as codexAuthPath,j as codexProvider,i as deepseekProvider,k as openaiChatProvider,h as openaiResponsesProvider,g as opencodeCopilotProvider,l as opencodeGoProvider};
@@ -1,6 +0,0 @@
1
- /**
2
- * The package's own entry point to the providers: the public door, and `codexBackend`, which the web
3
- * search tool uses and the package does not offer.
4
- */
5
- export * from './door.js';
6
- export { codexBackend } from './codexAuth.js';
@@ -1 +0,0 @@
1
- import{a,b,c}from"../chunks/TOOIB6J2.js";import"../chunks/DRYAN665.js";import"../chunks/2OSESBIL.js";import"../chunks/YLNJXQ3Z.js";import"../chunks/DDANMY45.js";import"../chunks/37YOGDGY.js";import"../chunks/KESCTXGO.js";import"../chunks/TYTQRLTX.js";import"../chunks/D7E6EWIE.js";export{c as renderRoute,b as renderRouteNotice,a as routeContext};
@@ -1 +0,0 @@
1
- import{a as c}from"../../chunks/AP6Q4EPT.js";import{l as i}from"../../chunks/37YOGDGY.js";import"../../chunks/KESCTXGO.js";import"../../chunks/TYTQRLTX.js";import"../../chunks/D7E6EWIE.js";function o(e){return{exec:t=>{e.sql.exec(t).toArray()},run:(t,...r)=>{e.sql.exec(t,...r).toArray()},all:(t,...r)=>e.sql.exec(t,...r).toArray(),transaction:async t=>{let r=e.transactionSync(t);return await e.sync(),r},close:()=>{}}}var n=new WeakMap;function s(e,t){if(n.has(e))throw new i(t);let r={};return n.set(e,r),{identity:t,release:()=>{n.get(e)===r&&n.delete(e)}}}var l=class extends c{storage;identity;constructor(t,r){super(r.identity),this.storage=t,this.identity=r.identity}connect(){return o(this.storage)}async exclusive(){return s(this.storage,this.identity)}};export{l as DurableObjectJournalStore};
@@ -1 +0,0 @@
1
- import{a as m}from"../../chunks/AP6Q4EPT.js";import{l as u,m as h}from"../../chunks/37YOGDGY.js";import"../../chunks/KESCTXGO.js";import"../../chunks/TYTQRLTX.js";import"../../chunks/D7E6EWIE.js";import{closeSync as d,mkdirSync as c,openSync as w,realpathSync as f,statSync as p}from"node:fs";import{isAbsolute as M,join as n}from"node:path";import{DatabaseSync as y}from"node:sqlite";var b=class extends m{lockDirectory;busyTimeoutMs;directory;constructor(t,e){super(n(t,"journal.db")),this.directory=t;let{lockDirectory:r,busyTimeoutMs:s}=e;if(!M(r))throw new TypeError(`lockDirectory must be an absolute path: ${r}`);if(!Number.isFinite(s)||s<0)throw new TypeError(`busyTimeoutMs must be a finite number of milliseconds, zero or more: ${s}`);this.lockDirectory=r,this.busyTimeoutMs=s}get databasePath(){return n(this.directory,"journal.db")}connect(){return c(this.directory,{recursive:!0}),new a(this.databasePath,this.busyTimeoutMs)}async exclusive(){c(this.directory,{recursive:!0}),d(w(this.databasePath,"a",384));let t=f(this.databasePath),{dev:e,ino:r}=p(t,{bigint:!0});c(this.lockDirectory,{recursive:!0,mode:448});let s=new y(n(this.lockDirectory,`${e}-${r}.db`));try{s.exec("PRAGMA busy_timeout=0; BEGIN EXCLUSIVE")}catch(i){throw s.close(),l(i)?new u(t):i}return{identity:`sqlite:${e}:${r}`,release:()=>s.close()}}},a=class{db;path;busyTimeoutMs;statements=new Map;writes=Promise.resolve();constructor(t,e){this.path=t,this.busyTimeoutMs=e,this.db=new y(t);try{this.db.exec("PRAGMA journal_mode=WAL")}catch(r){throw this.db.close(),r}}exec(t){this.db.exec(t)}run(t,...e){this.statement(t).run(...e)}all(t,...e){return this.statement(t).all(...e)}transaction(t){let e=()=>this.write(t),r=this.writes.then(e,e);return this.writes=r.catch(()=>{}),r}close(){this.statements.clear(),this.db.close()}statement(t){let e=this.statements.get(t);return e===void 0&&(e=this.db.prepare(t),this.statements.set(t,e)),e}async write(t){await this.beginWrite();try{let e=t();return this.db.exec("COMMIT"),e}catch(e){throw this.rollback(),e}}async beginWrite(){let t=Date.now();for(let e=5;;e=Math.min(e*2,100))try{this.db.exec("BEGIN IMMEDIATE");return}catch(r){if(!l(r))throw r;let s=Date.now()-t;if(s>=this.busyTimeoutMs)throw new h(this.path,s);await new Promise(i=>setTimeout(i,Math.min(e,this.busyTimeoutMs-s)))}}rollback(){if(this.db.isTransaction)try{this.db.exec("ROLLBACK")}catch(t){console.error(t)}}},l=o=>{let t=o?.errcode;return typeof t=="number"&&(t&255)===5};export{b as SqliteJournalStore};
@@ -1,38 +0,0 @@
1
- import { z } from 'zod';
2
- import type { Tool } from '../../loop/index.js';
3
- import { type DelegationTarget } from '../delegations/index.js';
4
- /** Parameters an agent accepts when another agent invokes it as a tool. */
5
- export declare const SubAgentRequestParameters: z.ZodPreprocess<z.ZodObject<{
6
- task: z.ZodString;
7
- background: z.ZodDefault<z.ZodBoolean>;
8
- provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
9
- model: z.ZodDefault<z.ZodNullable<z.ZodString>>;
10
- thinking_effort: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
11
- low: "low";
12
- high: "high";
13
- none: "none";
14
- medium: "medium";
15
- max: "max";
16
- }>>>;
17
- }, z.core.$strip>, unknown>;
18
- /** How an endpoint describes its target to callers. */
19
- export type EndpointDescription = {
20
- readonly toolName: string;
21
- readonly description: string;
22
- };
23
- /**
24
- * Delegation, as a tool.
25
- *
26
- * One of these is registered per target, a global agent or a role endpoint, so a target is
27
- * advertised to the model exactly like any other tool and reaching it is an ordinary grant. The
28
- * child is a normal thread: created with this call as its `origin` and its task in the same
29
- * write, and driven by `ctx.delegations` until the task settles. The tool only starts: its result
30
- * names the child's `thread_id`, whether the child answered or failed, and `message_agent` is how a
31
- * later call continues it.
32
- *
33
- * The child is born on the caller's route with the fields the call names folded over it, and keeps
34
- * that route, so a child started on a cheap model stays on it when continued without naming one.
35
- */
36
- export declare const subAgentTool: ({ toolName, description }: EndpointDescription, target: Exclude<DelegationTarget, {
37
- kind: "fork";
38
- }>) => Tool;
@@ -1,59 +0,0 @@
1
- import type { Plugin } from '@leuduan/cordis';
2
- import { z } from 'zod';
3
- import type { Tool } from '../../loop/index.js';
4
- /**
5
- * What the builtin tools are configured with, all of it the host's choice: the spawn environment and
6
- * the trusted programs the search tools run (`rg`, with `rg: null` for none), what `web_fetch`
7
- * may reach (`web.privateNetwork`: `refuse` keeps it on the public internet), and the Codex login
8
- * `web_search` searches through (`web.search`; with `null` there is no `web_search`).
9
- */
10
- declare const BuiltinToolsConfigSchema: z.ZodObject<{
11
- environment: z.ZodRecord<z.ZodString, z.ZodString>;
12
- programs: z.ZodObject<{
13
- git: z.ZodString;
14
- rg: z.ZodNullable<z.ZodString>;
15
- }, z.core.$strict>;
16
- web: z.ZodObject<{
17
- privateNetwork: z.ZodEnum<{
18
- allow: "allow";
19
- refuse: "refuse";
20
- }>;
21
- search: z.ZodNullable<z.ZodObject<{
22
- authPath: z.ZodString;
23
- refreshTimeoutMs: z.ZodNumber;
24
- model: z.ZodString;
25
- maxOutputTokens: z.ZodNumber;
26
- responseLength: z.ZodEnum<{
27
- medium: "medium";
28
- short: "short";
29
- long: "long";
30
- }>;
31
- }, z.core.$strict>>;
32
- }, z.core.$strict>;
33
- }, z.core.$strict>;
34
- export type BuiltinToolsConfig = z.input<typeof BuiltinToolsConfigSchema>;
35
- export type { WebSearchConfig } from './web.js';
36
- /** The builtin tools that read the workspace without changing it. */
37
- export declare const READ_ONLY_TOOLS: readonly ["read_file", "list_dir", "rg_search", "rg_files"];
38
- /** The builtin tools that run `rg`, provided only where the host has it (`programs.rg`). */
39
- export declare const RG_TOOLS: readonly string[];
40
- /** Builtin tools that fetch and search the web; `web_search` only where the host configures `web.search`. */
41
- export declare const WEB_TOOLS: readonly ["web_fetch", "web_search"];
42
- /**
43
- * Every tool that ships with the engine. Registration is explicit: no import side effects.
44
- *
45
- * `ask_question` is deliberately absent — it needs a host that can reach the user, so it ships as
46
- * the `lagent:ask` plugin instead of as a builtin that would fail wherever nobody is listening.
47
- * Shell commands ship as the `commands` plugin, which owns their processes.
48
- *
49
- * The search tools, `rg_search` and `rg_files`, run the trusted `rg` and take configuration: the
50
- * {@link BuiltinToolsConfig}. Without `rg` (`programs.rg: null`) neither is provided; nothing searches
51
- * by another means. Likewise `web_search` searches only through the Codex login `web.search` names.
52
- */
53
- export declare const builtinToolsFor: (config: z.output<typeof BuiltinToolsConfigSchema>) => readonly Tool[];
54
- /**
55
- * Registers every builtin tool for the life of the plugin. The host names the environment and the
56
- * trusted programs the search tools run with, what `web_fetch` may reach and what `web_search`
57
- * searches through; there is no default for any of them.
58
- */
59
- export declare const builtinTools: Plugin.Object<BuiltinToolsConfig>;
@@ -1 +0,0 @@
1
- import{a,b,c,d,e}from"../../chunks/ENWFSU27.js";import"../../chunks/OVZFGILJ.js";import"../../chunks/JPZFKSWT.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/G6RXC3AL.js";import"../../chunks/DXFXAYDN.js";import"../../chunks/YLNJXQ3Z.js";import"../../chunks/DDANMY45.js";import"../../chunks/37YOGDGY.js";import"../../chunks/KESCTXGO.js";import"../../chunks/TYTQRLTX.js";import"../../chunks/D7E6EWIE.js";export{a as READ_ONLY_TOOLS,b as RG_TOOLS,c as WEB_TOOLS,e as builtinTools,d as builtinToolsFor};
@@ -1,356 +0,0 @@
1
- import { z } from 'zod';
2
- import { type PluginJournal } from '../../journal/index.js';
3
- import { type Refusal, type StopVerdict } from '../../loop/index.js';
4
- import type { Seq } from '../../models/index.js';
5
- import type { ReadonlyState } from '../../util/foldState.js';
6
- /** The verify preset's id. */
7
- export declare const VERIFY_PRESET = "verify";
8
- /** Times a thread is sent back to verify, since its last change, the person's last message or a requirement's arming, before its answer is rejected. */
9
- export declare const VERIFY_REMINDERS = 2;
10
- /** A verification: the command text `run_command` must be given, and the absolute directory it must run in. */
11
- export type Verification = {
12
- readonly command: string;
13
- readonly cwd: string;
14
- };
15
- /** What the model is told up front: the verification this conversation finishes with. Neither a change nor a reminder. */
16
- export declare const notice: {
17
- record: (value: {
18
- command: string;
19
- cwd: string;
20
- }) => import("../../models/index.js").ExtensionRecord;
21
- parse: (value: {
22
- command: string;
23
- cwd: string;
24
- }) => {
25
- command: string;
26
- cwd: string;
27
- };
28
- entry: (value: {
29
- command: string;
30
- cwd: string;
31
- }, options: import("../../journal/journal.js").AppendOptions) => {
32
- type: "ext";
33
- data: {
34
- plugin: string;
35
- instance_id: string;
36
- kind: string;
37
- version: number;
38
- data: z.core.util.JSONType;
39
- };
40
- options: import("../../journal/journal.js").AppendOptions;
41
- };
42
- append(journal: PluginJournal, value: {
43
- command: string;
44
- cwd: string;
45
- }, options: import("../../journal/journal.js").AppendOptions): Promise<import("../../models/index.js").JournalEvent<"ext">>;
46
- read(event: import("../../models/index.js").JournalEvent): {
47
- command: string;
48
- cwd: string;
49
- } | undefined;
50
- contribution(message: {
51
- role?: import("../../models/index.js").InputRole;
52
- content: string | readonly import("../../llm/content.js").ContentPartInput[];
53
- }, value: {
54
- command: string;
55
- cwd: string;
56
- }, options?: {
57
- sourceSeqs?: readonly Seq[];
58
- }): import("../../models/index.js").StepContribution;
59
- matchesSource(record: import("../../util/json.js").DeepReadonly<import("../../models/index.js").ExtensionRecord>): boolean;
60
- rejection(reason: string, value: {
61
- command: string;
62
- cwd: string;
63
- }): {
64
- decision: "reject";
65
- reason: string;
66
- source: import("../../models/index.js").ExtensionRecord;
67
- };
68
- readContribution: (event: import("../../models/index.js").JournalEvent) => {
69
- command: string;
70
- cwd: string;
71
- } | undefined;
72
- readSource: (source: import("../../util/json.js").DeepReadonly<import("../../models/index.js").ExtensionRecord> | null) => {
73
- command: string;
74
- cwd: string;
75
- } | undefined;
76
- told: import("../../journal/projection.js").PluginProjection<import("../../kit/extension.js").ToldNotices<{
77
- command: string;
78
- cwd: string;
79
- }>>;
80
- projection<State>(fold: {
81
- key: string;
82
- init(): State;
83
- apply(state: State, value: {
84
- command: string;
85
- cwd: string;
86
- }, event: import("../../models/index.js").JournalEvent<"ext">): State;
87
- onFork?: "inherit" | "reset";
88
- }): import("../../journal/projection.js").PluginProjection<State>;
89
- };
90
- /** An `edit_files` or `run_command` call the model asked for, until its result lands. */
91
- type TrackedCall = {
92
- /** A `run_command`'s command, by {@link commandKey}, and the directory it runs in; `null` for an `edit_files` call. */
93
- readonly run: PlacedRun | null;
94
- /** Its latest allowed `tool/authorization` row: the moment it may have begun. `null` while it has none. */
95
- allowedAt: Seq | null;
96
- };
97
- /** A `run_command` call as it is placed: its key, and the directory, when the thread's cwd is known. */
98
- type PlacedRun = {
99
- readonly key: string;
100
- readonly cwd: string | null;
101
- };
102
- /** What the thread's runs of one command text in one directory came to. */
103
- type CommandFacts = {
104
- /** The latest result row of an allowed run, whatever its outcome. */
105
- resultAt: Seq | null;
106
- /** The latest result row of an allowed run that did not pass. */
107
- failedAt: Seq | null;
108
- /** The latest allowed attempt of a run that passed: everything settled before it is proven. */
109
- provenAt: Seq | null;
110
- /** The latest `tool/authorization` row of a call of it, and whether policy denied it. */
111
- decision: {
112
- readonly seq: Seq;
113
- readonly denied: boolean;
114
- } | null;
115
- };
116
- /**
117
- * What every gate needs of a thread, folded from its rows whatever the gate's verification is: the
118
- * calls in flight, and what each command run, each other change and the person came to. A gate
119
- * judges its own verification from these when it is asked, so one fold serves every configuration.
120
- */
121
- export type VerifyFacts = {
122
- /** The thread's cwd, from its spawn row: what a `run_command` without `workdir` runs in. */
123
- threadCwd: string | null;
124
- calls: Map<string, TrackedCall>;
125
- /** The latest row settling a change no verification could be: an `edit_files` result, a background command's start or end. */
126
- changedAt: Seq | null;
127
- /** Each command text and directory run, by {@link commandKey}. */
128
- commands: Map<string, CommandFacts>;
129
- /** The person's latest message. */
130
- personAt: Seq | null;
131
- /**
132
- * The reminder rows of each verification, by {@link commandKey}, since the last row that starts
133
- * its count over: the person writing, or a change other than a run of that verification.
134
- */
135
- reminders: Map<string, Seq[]>;
136
- };
137
- /** A command text and the directory it runs in, as one key; a directory not known never matches a verification. */
138
- export declare const commandKey: (command: string, cwd: string | null) => string;
139
- export declare const verifyFacts: import("../../journal/projection.js").PluginProjection<VerifyFacts>;
140
- /**
141
- * What a thread's catalog entry says of its changes, for a caller above it whose work it is
142
- * ({@link delegatedChange}), contributed for every thread while the `verify` service is mounted. A
143
- * thread whose facts cannot be read reads `unavailable`, which nothing reads as "none".
144
- */
145
- export declare const changes: import("../../services/contributions.js").ContributionDefinition<{
146
- changed_at: number | null;
147
- }>;
148
- /** The last change a thread's delegated work made, or why it cannot be read. */
149
- export type DelegatedChange = {
150
- readonly at: Seq | null;
151
- } | {
152
- readonly unreadable: string;
153
- };
154
- /**
155
- * The last change made by the work `threadId` delegated ({@link lastChange}): each thread
156
- * its calls started, at any depth, from its facts when it is loaded, else its catalog entry, so it
157
- * holds across a restart; or why one of them cannot be read, which fails closed. A thread an owner
158
- * assigned (an assignment origin, such as a workflow's isolated participant) is that owner's work,
159
- * judged by its own verification, so neither it nor anything under it is the caller's.
160
- *
161
- * Row seqs are one journal's, assigned in append order whichever thread a row belongs to, so a
162
- * descendant's change and the caller's verification attempt compare directly: a change whose row
163
- * was written before the attempt settled before the verification began.
164
- */
165
- export declare function delegatedChange(journal: PluginJournal, threadId: string): DelegatedChange;
166
- /** What one verification's gate judges from a thread's facts. */
167
- type Judgment = {
168
- /** The latest row settling a possible change, the thread's own or its delegated work's: a verification that passed is not one. */
169
- readonly mutatedAt: Seq | null;
170
- /** The allowed attempt of the latest verification that passed. */
171
- readonly provenAt: Seq | null;
172
- /** Whether policy denied the latest verification attempt since the person last wrote or the requirement armed. */
173
- readonly denied: boolean;
174
- /** Reminders since the last change other than a verification run, the person's last message, or the arming. */
175
- readonly reminders: number;
176
- };
177
- /**
178
- * One verification's judgment of a thread's facts, `delegatedAt` the last change its delegated work
179
- * made: one starts the count of reminders over as the thread's own change does, which its fold
180
- * already did for its own.
181
- */
182
- export declare function judgment(facts: ReadonlyState<VerifyFacts>, verification: Verification, armedAt: Seq | null, delegatedAt: Seq | null): Judgment;
183
- /**
184
- * A verification owed for one assignment, recorded on the thread serving it: the assignment's
185
- * identity (its owner, id and participant generation, as an assignment origin names them), the
186
- * input whose claim activates it, and the pinned verification. Its identity is the assignment's.
187
- */
188
- declare const RequirementSchema: z.ZodObject<{
189
- owner: z.ZodString;
190
- assignment: z.ZodString;
191
- generation: z.ZodNumber;
192
- input: z.ZodString;
193
- command: z.ZodString;
194
- cwd: z.ZodString;
195
- }, z.core.$strict>;
196
- export type RequirementInput = z.input<typeof RequirementSchema>;
197
- export type Requirement = z.output<typeof RequirementSchema>;
198
- declare const requirement: {
199
- record: (value: {
200
- owner: string;
201
- assignment: string;
202
- generation: number;
203
- input: string;
204
- command: string;
205
- cwd: string;
206
- }) => import("../../models/index.js").ExtensionRecord;
207
- parse: (value: {
208
- owner: string;
209
- assignment: string;
210
- generation: number;
211
- input: string;
212
- command: string;
213
- cwd: string;
214
- }) => {
215
- owner: string;
216
- assignment: string;
217
- generation: number;
218
- input: string;
219
- command: string;
220
- cwd: string;
221
- };
222
- entry: (value: {
223
- owner: string;
224
- assignment: string;
225
- generation: number;
226
- input: string;
227
- command: string;
228
- cwd: string;
229
- }, options: import("../../journal/journal.js").AppendOptions) => {
230
- type: "ext";
231
- data: {
232
- plugin: string;
233
- instance_id: string;
234
- kind: string;
235
- version: number;
236
- data: z.core.util.JSONType;
237
- };
238
- options: import("../../journal/journal.js").AppendOptions;
239
- };
240
- append(journal: PluginJournal, value: {
241
- owner: string;
242
- assignment: string;
243
- generation: number;
244
- input: string;
245
- command: string;
246
- cwd: string;
247
- }, options: import("../../journal/journal.js").AppendOptions): Promise<import("../../models/index.js").JournalEvent<"ext">>;
248
- read(event: import("../../models/index.js").JournalEvent): {
249
- owner: string;
250
- assignment: string;
251
- generation: number;
252
- input: string;
253
- command: string;
254
- cwd: string;
255
- } | undefined;
256
- contribution(message: {
257
- role?: import("../../models/index.js").InputRole;
258
- content: string | readonly import("../../llm/content.js").ContentPartInput[];
259
- }, value: {
260
- owner: string;
261
- assignment: string;
262
- generation: number;
263
- input: string;
264
- command: string;
265
- cwd: string;
266
- }, options?: {
267
- sourceSeqs?: readonly Seq[];
268
- }): import("../../models/index.js").StepContribution;
269
- matchesSource(record: import("../../util/json.js").DeepReadonly<import("../../models/index.js").ExtensionRecord>): boolean;
270
- rejection(reason: string, value: {
271
- owner: string;
272
- assignment: string;
273
- generation: number;
274
- input: string;
275
- command: string;
276
- cwd: string;
277
- }): {
278
- decision: "reject";
279
- reason: string;
280
- source: import("../../models/index.js").ExtensionRecord;
281
- };
282
- readContribution: (event: import("../../models/index.js").JournalEvent) => {
283
- owner: string;
284
- assignment: string;
285
- generation: number;
286
- input: string;
287
- command: string;
288
- cwd: string;
289
- } | undefined;
290
- readSource: (source: import("../../util/json.js").DeepReadonly<import("../../models/index.js").ExtensionRecord> | null) => {
291
- owner: string;
292
- assignment: string;
293
- generation: number;
294
- input: string;
295
- command: string;
296
- cwd: string;
297
- } | undefined;
298
- told: import("../../journal/projection.js").PluginProjection<import("../../kit/extension.js").ToldNotices<{
299
- owner: string;
300
- assignment: string;
301
- generation: number;
302
- input: string;
303
- command: string;
304
- cwd: string;
305
- }>>;
306
- projection<State>(fold: {
307
- key: string;
308
- init(): State;
309
- apply(state: State, value: {
310
- owner: string;
311
- assignment: string;
312
- generation: number;
313
- input: string;
314
- command: string;
315
- cwd: string;
316
- }, event: import("../../models/index.js").JournalEvent<"ext">): State;
317
- onFork?: "inherit" | "reset";
318
- }): import("../../journal/projection.js").PluginProjection<State>;
319
- };
320
- /** `value` validated as a requirement, its directory normalized as a placed run's is. */
321
- export declare function requirementValue(value: RequirementInput): Requirement;
322
- /**
323
- * The rows recording `value` on `threadId`, decided inside its write: one row for a requirement
324
- * not recorded yet; none for one recorded already exactly so (a replay renews nothing); a refusal
325
- * for one recorded under its identity otherwise. A thread being opened has none recorded.
326
- */
327
- export declare function requirementRows(journal: PluginJournal, threadId: string, opening: boolean, parsed: Requirement): ReturnType<typeof requirement.entry>[] | {
328
- refuse: Refusal;
329
- };
330
- /**
331
- * The requirement in force on a thread: the one armed last, with the moment it armed, the later of
332
- * its input's claim and its own row (so one recorded after the claim arms at its row); `null` while
333
- * none has armed. A participant serves one assignment at a time, so a later arming supersedes every
334
- * earlier requirement: two of them, pinned to different commands, would otherwise each count the
335
- * other's runs as changes and never both pass. A requirement lives for the assignment that armed it:
336
- * a delegation task opened on the thread after it armed, a successor assignment owing no
337
- * verification included, retires it. Row seqs are one journal's, so the two compare directly.
338
- */
339
- export declare function inForce(journal: PluginJournal, threadId: string): {
340
- verification: Verification;
341
- at: Seq;
342
- } | null;
343
- /**
344
- * The gate's say on a thread's answer for one verification, `armedAt` the moment its latest
345
- * requirement armed, if one did, and `delegated` the last change its delegated work made
346
- * ({@link delegatedChange}). What must be proven is everything settled before the barrier, the
347
- * later of the last possible change, the thread's own or its delegated work's, and that arming, kept
348
- * apart: an arming is no change, and a thread that changed nothing still owes its requirement a
349
- * pass. It holds the answer until a verification whose allowed attempt came after the barrier
350
- * passed, sending the model back at most {@link VERIFY_REMINDERS} times since the last change other
351
- * than a verification run, the person's last message or the arming, then rejecting; it rejects at
352
- * once when policy denied the latest attempt since the person last wrote or the requirement armed,
353
- * and when the delegated work's changes cannot be read.
354
- */
355
- export declare function verdict(facts: ReadonlyState<VerifyFacts>, verification: Verification, armedAt: Seq | null, delegated: DelegatedChange): StopVerdict | undefined;
356
- export {};
@@ -1,8 +0,0 @@
1
- import type { Context } from '@leuduan/cordis';
2
- import { type Governance } from './policy.js';
3
- /**
4
- * Mounts submission on the application root: `submit_workflow_output`, registered in the root's
5
- * scope and granted to no agent (each instance root's and participant child's activation grants it,
6
- * `policy.ts`), and the stop check that reminds a thread to submit.
7
- */
8
- export declare function acceptSubmissions(ctx: Context, governance: Governance): void;
@@ -1 +0,0 @@
1
- import{a,b,c}from"../chunks/ADHERZLW.js";import"../chunks/RK3VP2Q4.js";import"../chunks/DRYAN665.js";import"../chunks/2OSESBIL.js";import"../chunks/YLNJXQ3Z.js";import"../chunks/DDANMY45.js";import"../chunks/37YOGDGY.js";import"../chunks/KESCTXGO.js";import"../chunks/TYTQRLTX.js";import"../chunks/D7E6EWIE.js";export{c as renderEnvironmentInfo,b as renderWorkspaceNotice,a as workspaceContext};
@@ -1,7 +0,0 @@
1
- import type { AgentDefinitionInput } from '../models/index.js';
2
- /** The builtin tools define these; the compositions here name them. */
3
- export { READ_ONLY_TOOLS, WEB_TOOLS } from '../plugins/tools/index.js';
4
- /** Tools that create or modify files. */
5
- export declare const WRITE_TOOLS: readonly ["edit_files"];
6
- /** `base`'s one agent, registered with no grants: a preset equips it. */
7
- export declare const mainAgent: AgentDefinitionInput;
@@ -1,10 +0,0 @@
1
- import type { Plugin } from '@leuduan/cordis';
2
- /**
3
- * The plumbing a host mounts on the root beside `core` and a provider: one
4
- * `main` agent, granted nothing; the workspace notice; output truncation; and writes and started
5
- * commands held for confirmation. It registers no tools and decides nothing about what an agent
6
- * can do: a host registers the tools beside it, ungranted (`builtinTools`, `commands`), and a preset
7
- * such as `codexPreset` grants them. Root-only, since it registers an agent; mount it before any
8
- * thread activates.
9
- */
10
- export declare const base: Plugin.Object<undefined>;
@@ -1,4 +0,0 @@
1
- export * from './agents.js';
2
- export * from './base.js';
3
- export * from './codex.js';
4
- export * from './prompts.js';
@@ -1,4 +0,0 @@
1
- import{a as Q,b as Z}from"../chunks/CDQG7RKA.js";import{c as b}from"../chunks/G6RXC3AL.js";import{b as T,c as z}from"../chunks/GQGNVSKB.js";import{c as J}from"../chunks/DXFXAYDN.js";import{b as V,c as Y,e as K}from"../chunks/DRYAN665.js";import{d as v}from"../chunks/2OSESBIL.js";import"../chunks/YLNJXQ3Z.js";import{d as E}from"../chunks/DDANMY45.js";import{d as X}from"../chunks/37YOGDGY.js";import"../chunks/KESCTXGO.js";import"../chunks/TYTQRLTX.js";import"../chunks/D7E6EWIE.js";import{createRequire as st}from"node:module";import{dirname as it,join as at}from"node:path";import{randomUUID as Ye}from"node:crypto";import{homedir as Ke}from"node:os";import{isAbsolute as O}from"node:path";import{Service as xe}from"@leuduan/cordis";import{z as i}from"zod";import{Worker as Ae}from"node:worker_threads";var A=class{worker;pending=new Map;nextId=1;ended=null;closing=!1;onDeath;constructor(e,n,r){this.onDeath=r,this.worker=new Ae(e,{env:n}),this.worker.on("message",o=>this.settle(o)),this.worker.on("error",o=>this.end(new Error(`The sandbox worker failed: ${o.message}`))),this.worker.on("exit",o=>this.end(new Error(`The sandbox worker exited with code ${o}`)))}get alive(){return this.ended===null&&!this.closing}request(e,n){if(this.ended!==null)return Promise.reject(this.ended);if(this.closing)return Promise.reject(new Error("The sandbox worker is shutting down"));let{signal:r}=n;if(r?.aborted)return Promise.reject(r.reason instanceof Error?r.reason:new Error("aborted"));let o=this.nextId++;return new Promise((s,a)=>{let d=p=>{this.pending.delete(o)&&(clearTimeout(l),c(),e.type==="wrap"&&this.send({type:"cancel",id:o}),a(p))},m=()=>d(r?.reason instanceof Error?r.reason:new Error("aborted")),l=setTimeout(()=>d(new Error(`The sandbox worker did not answer ${e.type} within ${n.timeoutMs} ms`)),n.timeoutMs),c=()=>r?.removeEventListener("abort",m);r?.addEventListener("abort",m,{once:!0}),this.pending.set(o,{resolve:s,reject:a,timer:l,cleanup:c}),this.send({...e,id:o})})}async terminate(){this.closing=!0,this.rejectAll(new Error("The sandbox worker is shutting down")),await this.worker.terminate()}unref(){this.worker.unref()}send(e){try{this.worker.postMessage(e)}catch(n){this.end(new Error(`The sandbox worker could not be reached: ${n instanceof Error?n.message:n}`))}}settle(e){let n=this.pending.get(e.id);n!==void 0&&(this.pending.delete(e.id),clearTimeout(n.timer),n.cleanup(),e.ok?n.resolve(e.value):n.reject(new Error(e.error)))}end(e){this.ended===null&&(this.ended=e,this.rejectAll(e),this.closing||this.onDeath(e))}rejectAll(e){let n=[...this.pending.values()];this.pending.clear();for(let r of n)clearTimeout(r.timer),r.cleanup(),r.reject(e)}};import{createHash as M,randomUUID as Se}from"node:crypto";import{existsSync as De,linkSync as ke,lstatSync as te,mkdirSync as ne,readdirSync as _e,readFileSync as q,unlinkSync as re,writeFileSync as $e}from"node:fs";import{join as g}from"node:path";var ee=t=>g(t,".srt"),Re=(t,e)=>g(t,"scratch",M("sha256").update(e).digest("hex"));function L(t){try{ne(t,{mode:448})}catch(n){if(!E(n,"EEXIST"))throw n}let e=te(t);if(!e.isDirectory()||e.uid!==process.getuid?.())throw new Error(`${t} is not a directory owned by this user`)}function oe(t){return ne(t,{recursive:!0,mode:448}),L(ee(t)),ee(t)}function C(t,e){L(g(t,"scratch"));let n=Re(t,e);return L(n),n}function se(t){let e=[];for(let n of _e(t)){let r=/^srt-mux-(\d+)-[0-9a-z]+\.sock$/.exec(n);if(!(r===null||Oe(Number(r[1]))))try{re(g(t,n)),e.push(n)}catch{}}return e}function Oe(t){if(t===process.pid)return!0;try{return process.kill(t,0),!0}catch(e){return E(e,"EPERM")}}function ie(t,e){let n=q(e),r=M("sha256").update(n).digest("hex"),o=g(t,`srt-proxy-agent-${r}.jar`);if(!De(o)){let a=g(t,`.publish-${Se()}.tmp`);$e(a,n,{flag:"wx",mode:292});try{ke(a,o)}catch(d){if(!E(d,"EEXIST"))throw d}finally{re(a)}}if(!te(o).isFile()||M("sha256").update(q(o)).digest("hex")!==r)throw new Error(`${o} exists and is not the Java agent it is named for`);return{path:o,sha256:r}}import{createHash as Ne}from"node:crypto";import{existsSync as ce,realpathSync as de}from"node:fs";import{basename as Pe,dirname as ae,isAbsolute as je,join as x,resolve as Me}from"node:path";var Le=/^(LD_.*|DYLD_.*|BASH_ENV|ENV|SHELLOPTS|BASHOPTS|BASH_FUNC_.*)$/;function le(t){let e=Object.keys(t).filter(n=>Le.test(n));if(e.length>0)throw new Error(`The command sandbox refuses an environment that sets ${e.join(", ")}: they run code before the sandbox holds`)}var H=128*1024;function h(t){let e=Me(t),n=[];for(;!ce(e)&&ae(e)!==e;)n.unshift(Pe(e)),e=ae(e);return x(de.native(e),...n)}var u=t=>({path:t,literal:!0}),Ce=/[*?[\]]/,He=["__GLOBSTAR_SLASH__","__GLOBSTAR__"];function he(t){if(!je(t))throw new Error(`The command sandbox needs an absolute root, not ${t}`);let e=h(t);if(Ce.test(e)||He.some(n=>e.includes(n)))throw new Error(`The command sandbox refuses ${e} as a root: its name holds glob characters, which sandbox-runtime would read as a pattern`);return e}var Ie=[".gitconfig",".gitmodules",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",".ripgreprc",".mcp.json"],Ue=[".vscode",".idea",".claude/commands",".claude/agents"];function We(t){let e=[];for(let n of Ie)e.push(u(x(t,n)),`${t}/**/${n}`);for(let n of Ue)e.push(u(x(t,n)),`${t}/**/${n}/**`);return e.push(u(x(t,".git/hooks")),`${t}/**/.git/hooks/**`),e.push(u(x(t,".git/config")),`${t}/**/.git/config`),e}var Be=["env","which","log","/bin/sh","/usr/bin/sandbox-exec"];function me(t){let e=t.split(":"),n=Be.flatMap(r=>(r.startsWith("/")?[r]:e.map(o=>x(o,r))).filter(o=>ce(o)).map(o=>de.native(o)));return[...e,...n]}function I(t,e,n){let r=(o,s)=>b(o,s)||b(s,o);for(let o of t){let s=e.find(a=>r(a,o));if(s!==void 0)throw new Error(`The command sandbox refuses to let commands write ${o}: it overlaps ${s}, which the sandbox runs before confinement`);if(r(n,o))throw new Error(`The command sandbox refuses to let commands write ${o}: it overlaps the temporary root`)}}function ue(t,e,n){return{allowWrite:[e,...t.allowWrite,n].map(u),denyWrite:[...[...t.denyWrite,t.dataDir,...t.conveniences,"/tmp/claude","/private/tmp/claude",t.privateDirectory].map(u),...We(e)],denyRead:t.denyRead.map(u)}}var U=['if [ -n "${LAGENT_SANDBOX_PATH+x}" ]; then PATH=$LAGENT_SANDBOX_PATH; export PATH; else unset PATH; fi',"TMPDIR=$LAGENT_SANDBOX_TMPDIR; export TMPDIR",'set -- "$LAGENT_SANDBOX_COMMAND"',"unset LAGENT_SANDBOX_PATH LAGENT_SANDBOX_TMPDIR LAGENT_SANDBOX_COMMAND",'exec /bin/sh -c "$1"'].join("; ");function fe(t,e,n,r){let{PATH:o,...s}=t;return{...s,PATH:e,LAGENT_SANDBOX_TMPDIR:n,LAGENT_SANDBOX_COMMAND:r,...o===void 0?{}:{LAGENT_SANDBOX_PATH:o}}}var S="lagent-srt",Ge="5",pe=t=>`${S}/${Ge} sandbox-runtime/${t}`;function we(t){return`sha256:${Ne("sha256").update(X({...t,bootstrap:U})).digest("hex")}`}function ge(t){let e=t.filesystem.allowWrite.length===0?"":`, in ${t.filesystem.allowWrite.join(", ")}`,{network:n}=t,r=n.mode==="unrestricted"?"They have unrestricted network access.":n.allowedDomains.length===0?"They have no network access.":`They reach the network only through a proxy, and only these hosts: ${n.allowedDomains.join(", ")}; any other host is refused with HTTP 403. Tools that ignore HTTP_PROXY cannot connect. Refused requests are usually, not always, listed after the command's output.`;return[`run_command and start_command run in an OS sandbox. They can write only inside the conversation's working directory${e}, and in $TMPDIR. Writes elsewhere fail with "Operation not permitted", which is all a refused write reports. Inside the working directory, git hooks, .git/config, shell startup files and editor settings cannot be written from a command.`,r,"A refusal is the sandbox, not a fault to work around: say what you needed instead."].join(" ")}import{z as W}from"zod";var f=Z({name:"lagent:sandbox",authority:"conversation",initial:"confined",modes:["confined","unconfined"]});function k(t,e){if(t.journal.summary(e)===void 0)throw new Error(`Unknown thread: ${e}`);return f.recorded(t.journal,f.authorityOf(t,e))}var Fe=(t,e)=>f.recorded(t,e),Xe=W.strictObject({mode:W.enum(["confined","unconfined"]),guidance:W.string().nullable()}),Je=V({plugin:"lagent:sandbox",kind:"notice",version:1,schema:Xe}),ze="The sandbox is off: commands you start from now on run with the user's full permissions and network; commands already preparing or running keep the confinement they started with.",Ve="Commands you start from now on are sandboxed; commands already preparing or running keep how they were launched.",B="The sandbox is unavailable on this host: run_command and start_command are refused for this conversation.";function _(t,e){K(t,{event:Je,agents:"all",rank:1,current:n=>{try{return e(n.threadId)}catch(r){if(r instanceof Q)return;throw r}},render:(n,r,{notices:o})=>{let s=Y(o)?.value??null;return n.mode==="unconfined"?(r??(s?.mode==="confined"?s:null))?.mode==="confined"?ze:null:n.guidance===null?null:n.guidance===B?n.guidance:`${Ve} ${n.guidance}`}})}var D=new WeakMap;function $(t,e){let n=t.reflect.target,r=D.get(n);if(r!==void 0)throw new Error(`${e} cannot mount: ${r} already owns this application's sandbox, and the two exclude each other`);D.set(n,e),t.effect(()=>()=>{D.get(n)===e&&D.delete(n)})}var y=i.string().refine(O,{message:"Expected an absolute path"}),be=i.url({protocol:/^https?$/}).refine(t=>new URL(t).username===""&&new URL(t).password==="",{message:"A parent proxy URL carrying credentials is not supported"}),Ee=i.strictObject({worker:i.union([i.instanceof(URL),i.string().min(1)]),searchPath:i.string().refine(t=>t.split(":").every(O),{message:"Every searchPath entry must be absolute"}),tmpRoot:y,javaAgentJar:y,unconfined:i.enum(["allowed","refused"]),filesystem:i.strictObject({allowWrite:i.array(y),denyRead:i.array(y),denyWrite:i.array(y)}),network:i.discriminatedUnion("mode",[i.strictObject({mode:i.literal("allowlist"),allowedDomains:i.array(i.string().min(1)),deniedDomains:i.array(i.string().min(1)),parentProxy:i.union([i.literal("none"),i.strictObject({http:be.optional(),https:be.optional(),noProxy:i.string().optional()})])}),i.strictObject({mode:i.literal("unrestricted")})]),drainTimeoutMs:i.number().int().positive().default(2e4)});function Qe(t){if(t.mode==="unrestricted")return{deniedDomains:[]};let{parentProxy:e}=t;return{allowedDomains:t.allowedDomains,deniedDomains:t.deniedDomains,...e==="none"?{}:{parentProxy:e}}}function Ze(t,e,n){return t==="allowlist"?e.isCopy?[]:[`sandbox-runtime does not advertise the Java agent copy ${n}`]:e.flags===0?[]:["sandbox-runtime advertises a Java agent although the network is unrestricted"]}var R=3e4,qe=15e3,et=5e3,ye=!1,N=class extends xe{static inject=["threadDirs","launches","journal","threads"];guidance;config;dataDir;state="new";failure=null;admitting=!0;client=null;host=null;handle;releasing=null;constructor(e,n){super(e,"sandbox"),this.dataDir=e.threadDirs.require("sandbox"),v(e,"sandbox"),this.config=Ee.parse(n),this.guidance=ge(this.config),$(e,"sandbox"),_(e,r=>{let o=this.mode(r);return{mode:o,guidance:o==="confined"?this.guidance:null}}),this.handle=e.launches.handle(this),e.fiber.beforeUnload(()=>this.closeAndRelease())}async[xe.init](){try{await this.start()}catch(e){this.state="failed",this.admitting=!1;let n=this.releaseHandle();throw this.announceFailure(),await n,await this.client?.terminate(),this.client=null,e}return()=>this.release()}get unconfined(){return this.config.unconfined}get health(){return this.state==="ready"&&this.admitting?"ready":"failed"}mode(e){return this.config.unconfined==="refused"?"confined":f.of(this.ctx,e)}async setMode(e,n){this.refuseGated(n);let r=this.ctx.journal.summary(e);if(r===void 0)throw new Error(`Unknown thread: ${e}`);if(r.origin!==null)throw new Error(`Thread ${e} is in its conversation's sandbox mode`);await f.set(this.ctx,e,n)}opening(e){return this.refuseGated(e),f.opening(e)}refuseGated(e){if(e==="unconfined"&&this.config.unconfined==="refused")throw new Error("This host refuses unconfined commands")}async prepare(e){if(this.requireOpen(),this.ctx.journal.summary(e.threadId)===void 0)throw new Error(`The command sandbox cannot launch for unknown thread ${e.threadId}`);if(!O(e.workdir))throw new Error(`The command sandbox needs an absolute workdir, not ${e.workdir}`);return this.mode(e.threadId)==="unconfined"?this.plain(e):this.build(e,!1)}plain(e){let n=this.host;if(n===null)throw new Error("The command sandbox is not running");return{argv:["/bin/sh","-c",e.program.shell],cwd:e.workdir,env:e.environment,provenance:{launcher:S,version:n.version,policy:T},violations:async()=>null}}async start(){if(process.platform!=="darwin")throw new Error(`The command sandbox supports macOS only; on ${process.platform}, sandbox-runtime's launches sharing a directory can remove each other's protective mount points`);if(ye)throw new Error("The command sandbox starts once per process: sandbox-runtime keeps process-wide state and is never restarted, so restart the host");ye=!0,this.state="starting";let{config:e}=this,n=h(e.tmpRoot),r=h(this.dataDir);if(b(n,r))throw new Error("tmpRoot must be outside the data directory, which commands may not write");let o=e.searchPath.split(":").map(h).join(":"),s=me(o),a=e.filesystem.allowWrite.map(h);I(a,s,n);let d=e.filesystem.denyWrite.map(h),m=e.filesystem.denyRead.map(h),l=Ke(),c=oe(n);se(c);let p=ie(c,e.javaAgentJar),P=new A(e.worker,{PATH:o,HOME:l,TMPDIR:c,CLAUDE_CODE_TMPDIR:c},j=>this.onWorkerDeath(j));this.client=P;let G=j=>({path:j,literal:!0}),Te={network:Qe(e.network),filesystem:{denyRead:m.map(G),allowWrite:[],denyWrite:[...d,r].map(G)},javaAgentJarPath:p.path},w=await P.request({type:"init",config:Te,expect:{tmpdir:c,home:l}},{timeoutMs:R}),F=[...w.supported?[]:["this platform is not supported"],...w.errors,...w.warnings,...Ze(e.network.mode,w.javaAgent,p.path)];if(F.length>0)throw new Error(`The command sandbox cannot start here: ${F.join("; ")}`);if(this.host={tmpRoot:n,cwd:process.cwd(),home:l,searchPath:o,trusted:s,extraRoots:e.filesystem.allowWrite,facts:{allowWrite:a,denyWrite:d,denyRead:m,dataDir:r,conveniences:w.conveniences,privateDirectory:c},version:pe(w.version),javaAgentSha256:p.sha256},await this.selfCheck(n),!P.alive||this.failure!==null)throw new Error(`The command sandbox worker ended while it started${this.failure===null?"":`: ${this.failure.message}`}`);this.state="ready"}async selfCheck(e){let n=C(e,"self-check"),r=await this.build({program:{shell:"exit 0"},workdir:n,root:n,scratch:"self-check",environment:{},signal:AbortSignal.timeout(R)},!0),o=await J({command:r.argv,cwd:r.cwd,env:r.env,signal:AbortSignal.timeout(R),timeoutMs:R});if(o.exitCode!==0){let s=o.exitSignal===null?`exit code ${o.exitCode}`:`signal ${o.exitSignal}`;throw new Error(`The command sandbox could not run a confined command: ${o.output.trim()||s}`)}}requireOpen(){if(this.state==="failed")throw new Error(`The command sandbox failed${this.failure===null?"":`: ${this.failure.message}`}. Commands cannot run unconfined; it stays failed until lagent restarts.`);if(this.state==="new"||this.state==="starting")throw new Error("The command sandbox is still starting");if(this.state!=="ready"||!this.admitting)throw new Error("The command sandbox is shutting down")}async build(e,n){let r=this.host,o=this.client;if(r===null||o===null)throw new Error("The command sandbox is not running");if(le(e.environment),!O(e.workdir))throw new Error(`The command sandbox needs an absolute workdir, not ${e.workdir}`);if(Buffer.byteLength(e.program.shell)>H)throw new Error(`The command sandbox refuses a command longer than ${H} bytes`);if(process.cwd()!==r.cwd)throw new Error(`The host changed its working directory from ${r.cwd} to ${process.cwd()}: the command sandbox refuses to launch`);let s=he(e.root),a=r.extraRoots.map(h);I(n?a:[s,...a],r.trusted,r.tmpRoot);let d=C(r.tmpRoot,e.scratch),m={...r.facts,allowWrite:a},l=ue(m,s,d),c=Ye();return{argv:["/bin/sh","-c",`exec ${await o.request({type:"wrap",command:U,commandId:c,commandText:e.program.shell.slice(0,1e3),config:{filesystem:l}},{timeoutMs:qe,signal:e.signal})}`],cwd:e.workdir,env:fe(e.environment,r.searchPath,d,e.program.shell),provenance:{launcher:S,version:r.version,policy:we({filesystem:l,network:this.config.network,searchPath:r.searchPath,cwd:r.cwd,home:r.home,conveniences:r.facts.conveniences,javaAgent:r.javaAgentSha256,version:r.version})},violations:()=>this.violationsOf(c)}}async violationsOf(e){if(this.client===null)return null;let n=await this.client.request({type:"violations",commandId:e},{timeoutMs:z});return n.length===0?null:`<sandbox_violations>
2
- ${n.join(`
3
- `)}
4
- </sandbox_violations>`}onWorkerDeath(e){this.failure??=e,this.state==="ready"&&(this.state="failed",this.admitting=!1,this.ctx.reportError(e),this.releaseHandle(),this.announceFailure())}announceFailure(){this.ctx.parallel("lagent/sandbox/health","failed").catch(e=>this.ctx.reportError(e))}async closeAndRelease(){this.admitting=!1,this.state==="ready"&&(this.state="stopping"),await this.releaseHandle()}releaseHandle(){return this.releasing??=this.handle.release(this.config.drainTimeoutMs).then(e=>(e||this.ctx.reportError(new Error(`A command could not be confirmed stopped within ${this.config.drainTimeoutMs} ms: a confined process may still run, so the sandbox worker is kept until the process exits`)),e)),this.releasing}async release(){let e=this.client;if(e!==null){if(!await this.releaseHandle()){e.unref();return}e.alive&&await e.request({type:"reset"},{timeoutMs:et}).catch(()=>{}),await e.terminate(),this.client=null}}};import{z as ve}from"zod";var tt=ve.strictObject({drainTimeoutMs:ve.number().int().positive()}),nt="lagent-sandbox-absent",rt="1",ot={name:"lagent:sandbox-absent",inject:["journal","threads","launches"],apply(t,e){v(t,"sandboxAbsent");let n=tt.parse(e);$(t,"sandboxAbsent");let r=t.launches.handle({async prepare(s){if(k(t,s.threadId)==="confined")throw new Error("This conversation is sandboxed, and the host started without a sandbox, so its commands are refused.");return{argv:["/bin/sh","-c",s.program.shell],cwd:s.workdir,env:s.environment,provenance:{launcher:nt,version:rt,policy:T},violations:async()=>null}}}),o=null;t.fiber.beforeUnload(()=>(o??=r.release(n.drainTimeoutMs).then(s=>(s||t.reportError(new Error(`A command could not be confirmed stopped within ${n.drainTimeoutMs} ms`)),s)),o.then(()=>{}))),_(t,s=>k(t,s)==="confined"?{mode:"confined",guidance:B}:{mode:"unconfined",guidance:null})}};var zt=N,Vt=new URL("./worker.js",import.meta.url);function Yt(){let t=st(import.meta.url).resolve("@anthropic-ai/sandbox-runtime/package.json");return at(it(t),"vendor","java-proxy-agent","srt-proxy-agent.jar")}export{Ee as SandboxConfigSchema,zt as sandbox,ot as sandboxAbsent,k as sandboxRecorded,Fe as sandboxRecordedOn,Vt as sandboxWorker,Yt as srtJavaAgentJar};