@leuduan/lagent 0.0.0-stage → 0.1.2

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 (327) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +144 -2
  3. package/dist/chunks/2O7ZGEIT.js +1 -0
  4. package/dist/chunks/2OSESBIL.js +1 -0
  5. package/dist/chunks/34KW6VNQ.js +1 -0
  6. package/dist/chunks/37YOGDGY.js +1 -0
  7. package/dist/chunks/3LQHQRIU.js +6 -0
  8. package/dist/chunks/3QCW4WDJ.js +1 -0
  9. package/dist/chunks/4XVRUSCQ.js +1 -0
  10. package/dist/chunks/6ECI2GGV.js +1 -0
  11. package/dist/chunks/74HKUGRR.js +1 -0
  12. package/dist/chunks/ADHERZLW.js +2 -0
  13. package/dist/chunks/AP6Q4EPT.js +36 -0
  14. package/dist/chunks/BM3S37EZ.js +1 -0
  15. package/dist/chunks/C5LYCXJG.js +1 -0
  16. package/dist/chunks/CDQG7RKA.js +1 -0
  17. package/dist/chunks/D7E6EWIE.js +3 -0
  18. package/dist/chunks/DDANMY45.js +3 -0
  19. package/dist/chunks/DRYAN665.js +1 -0
  20. package/dist/chunks/DXFXAYDN.js +17 -0
  21. package/dist/chunks/EGZI4XQX.js +24 -0
  22. package/dist/chunks/ENWFSU27.js +41 -0
  23. package/dist/chunks/G6RXC3AL.js +1 -0
  24. package/dist/chunks/G74AGRAJ.js +15 -0
  25. package/dist/chunks/GQGNVSKB.js +1 -0
  26. package/dist/chunks/IJ2WNMD5.js +7 -0
  27. package/dist/chunks/J5S4URAW.js +1 -0
  28. package/dist/chunks/JPZFKSWT.js +1 -0
  29. package/dist/chunks/KESCTXGO.js +5 -0
  30. package/dist/chunks/L3N4FIEN.js +1 -0
  31. package/dist/chunks/NAOUTU7A.js +4 -0
  32. package/dist/chunks/NDIM7MEW.js +1 -0
  33. package/dist/chunks/O4PPOM5Z.js +2 -0
  34. package/dist/chunks/OVZFGILJ.js +1 -0
  35. package/dist/chunks/P5ZHHOOM.js +6 -0
  36. package/dist/chunks/PUSUPTAT.js +1 -0
  37. package/dist/chunks/QMMLQJBS.js +1 -0
  38. package/dist/chunks/RK3VP2Q4.js +3 -0
  39. package/dist/chunks/SGGMBSBA.js +1 -0
  40. package/dist/chunks/SL2YLB2F.js +1 -0
  41. package/dist/chunks/TOOIB6J2.js +1 -0
  42. package/dist/chunks/TYTQRLTX.js +1 -0
  43. package/dist/chunks/UC3FVVJ2.js +5 -0
  44. package/dist/chunks/UCTEU62F.js +1 -0
  45. package/dist/chunks/UD3VJER6.js +1 -0
  46. package/dist/chunks/UKXMCHHT.js +1 -0
  47. package/dist/chunks/WUUKTSRT.js +7 -0
  48. package/dist/chunks/X65X4KP5.js +7 -0
  49. package/dist/chunks/YIR5MYGU.js +1 -0
  50. package/dist/chunks/YLNJXQ3Z.js +1 -0
  51. package/dist/context.d.ts +101 -0
  52. package/dist/index.d.ts +47 -0
  53. package/dist/index.js +77 -0
  54. package/dist/journal/catalog.d.ts +112 -0
  55. package/dist/journal/forkChain.d.ts +16 -0
  56. package/dist/journal/index.d.ts +15 -0
  57. package/dist/journal/journal.d.ts +475 -0
  58. package/dist/journal/projection.d.ts +87 -0
  59. package/dist/journal/store.d.ts +181 -0
  60. package/dist/kit/claim.d.ts +13 -0
  61. package/dist/kit/drain.d.ts +10 -0
  62. package/dist/kit/extension.d.ts +180 -0
  63. package/dist/kit/grants.d.ts +9 -0
  64. package/dist/kit/modes.d.ts +65 -0
  65. package/dist/kit/retries.d.ts +25 -0
  66. package/dist/kit/scope.d.ts +32 -0
  67. package/dist/kit/service.d.ts +7 -0
  68. package/dist/kit/strategy.d.ts +10 -0
  69. package/dist/kit/timers.d.ts +43 -0
  70. package/dist/kit/tool.d.ts +72 -0
  71. package/dist/llm/client.d.ts +135 -0
  72. package/dist/llm/content.d.ts +52 -0
  73. package/dist/llm/door.d.ts +21 -0
  74. package/dist/llm/door.js +1 -0
  75. package/dist/llm/failure.d.ts +82 -0
  76. package/dist/llm/index.d.ts +16 -0
  77. package/dist/llm/primitives.d.ts +286 -0
  78. package/dist/llm/prompt.d.ts +21 -0
  79. package/dist/llm/provider.d.ts +63 -0
  80. package/dist/llm/readLedger.d.ts +24 -0
  81. package/dist/llm/request.d.ts +58 -0
  82. package/dist/loop/agent.d.ts +134 -0
  83. package/dist/loop/auxiliary.d.ts +54 -0
  84. package/dist/loop/chain.d.ts +46 -0
  85. package/dist/loop/chunks.d.ts +27 -0
  86. package/dist/loop/continuation.d.ts +166 -0
  87. package/dist/loop/decide.d.ts +64 -0
  88. package/dist/loop/errors.d.ts +162 -0
  89. package/dist/loop/forks.d.ts +61 -0
  90. package/dist/loop/holds.d.ts +104 -0
  91. package/dist/loop/hooks.d.ts +241 -0
  92. package/dist/loop/inbox.d.ts +188 -0
  93. package/dist/loop/index.d.ts +37 -0
  94. package/dist/loop/limits.d.ts +14 -0
  95. package/dist/loop/opening.d.ts +42 -0
  96. package/dist/loop/prepare.d.ts +30 -0
  97. package/dist/loop/projections.d.ts +307 -0
  98. package/dist/loop/replace.d.ts +33 -0
  99. package/dist/loop/requests.d.ts +129 -0
  100. package/dist/loop/route.d.ts +53 -0
  101. package/dist/loop/runtime.d.ts +85 -0
  102. package/dist/loop/state.d.ts +70 -0
  103. package/dist/loop/strategy.d.ts +71 -0
  104. package/dist/loop/summary.d.ts +3 -0
  105. package/dist/loop/surface.d.ts +153 -0
  106. package/dist/loop/threadState.d.ts +72 -0
  107. package/dist/loop/tool.d.ts +101 -0
  108. package/dist/loop/toolCalls.d.ts +42 -0
  109. package/dist/loop/wake.d.ts +32 -0
  110. package/dist/models/config/agent.d.ts +18 -0
  111. package/dist/models/config/prompt.d.ts +18 -0
  112. package/dist/models/door.d.ts +12 -0
  113. package/dist/models/door.js +1 -0
  114. package/dist/models/index.d.ts +7 -0
  115. package/dist/models/jsonSchema.d.ts +7 -0
  116. package/dist/models/wire/journal.d.ts +2772 -0
  117. package/dist/models/wire/primitives.d.ts +65 -0
  118. package/dist/plugin.d.ts +53 -0
  119. package/dist/plugin.js +1 -0
  120. package/dist/plugins/agentsMd.d.ts +76 -0
  121. package/dist/plugins/agentsMd.js +1 -0
  122. package/dist/plugins/ask/askQuestion.d.ts +9 -0
  123. package/dist/plugins/ask/index.d.ts +26 -0
  124. package/dist/plugins/ask/index.js +1 -0
  125. package/dist/plugins/ask/service.d.ts +125 -0
  126. package/dist/plugins/commands/background.d.ts +8 -0
  127. package/dist/plugins/commands/foreground.d.ts +4 -0
  128. package/dist/plugins/commands/index.d.ts +40 -0
  129. package/dist/plugins/commands/index.js +1 -0
  130. package/dist/plugins/commands/output.d.ts +115 -0
  131. package/dist/plugins/commands/record.d.ts +549 -0
  132. package/dist/plugins/commands/service.d.ts +314 -0
  133. package/dist/plugins/commands/shell.d.ts +25 -0
  134. package/dist/plugins/compaction/checkpoint.d.ts +91 -0
  135. package/dist/plugins/compaction/config.d.ts +133 -0
  136. package/dist/plugins/compaction/estimate.d.ts +29 -0
  137. package/dist/plugins/compaction/index.d.ts +2 -0
  138. package/dist/plugins/compaction/index.js +7 -0
  139. package/dist/plugins/compaction/log.d.ts +61 -0
  140. package/dist/plugins/compaction/planner.d.ts +207 -0
  141. package/dist/plugins/compaction/preset.d.ts +86 -0
  142. package/dist/plugins/compaction/prune.d.ts +9 -0
  143. package/dist/plugins/compaction/records.d.ts +227 -0
  144. package/dist/plugins/compaction/segments.d.ts +23 -0
  145. package/dist/plugins/compaction/shared.d.ts +14 -0
  146. package/dist/plugins/compaction/summarize.d.ts +13 -0
  147. package/dist/plugins/dateAndBranch.d.ts +47 -0
  148. package/dist/plugins/dateAndBranch.js +1 -0
  149. package/dist/plugins/delegations/answers.d.ts +39 -0
  150. package/dist/plugins/delegations/assignmentKey.d.ts +22 -0
  151. package/dist/plugins/delegations/cleanup.d.ts +161 -0
  152. package/dist/plugins/delegations/constraint.d.ts +76 -0
  153. package/dist/plugins/delegations/index.d.ts +39 -0
  154. package/dist/plugins/delegations/index.js +1 -0
  155. package/dist/plugins/delegations/notices.d.ts +261 -0
  156. package/dist/plugins/delegations/obligations.d.ts +210 -0
  157. package/dist/plugins/delegations/record.d.ts +632 -0
  158. package/dist/plugins/delegations/request.d.ts +381 -0
  159. package/dist/plugins/delegations/role.d.ts +30 -0
  160. package/dist/plugins/delegations/service.d.ts +562 -0
  161. package/dist/plugins/delegations/standing.d.ts +19 -0
  162. package/dist/plugins/delegations/stopCheck.d.ts +21 -0
  163. package/dist/plugins/delegations/testing.d.ts +16 -0
  164. package/dist/plugins/delegations/tools.d.ts +71 -0
  165. package/dist/plugins/delegations/waitBook.d.ts +116 -0
  166. package/dist/plugins/delegations/waits.d.ts +118 -0
  167. package/dist/plugins/diagnostics/digest.d.ts +14 -0
  168. package/dist/plugins/diagnostics/index.d.ts +68 -0
  169. package/dist/plugins/diagnostics/index.js +1 -0
  170. package/dist/plugins/historyRecall/history.d.ts +9 -0
  171. package/dist/plugins/historyRecall/index.d.ts +31 -0
  172. package/dist/plugins/historyRecall/index.js +1 -0
  173. package/dist/plugins/historyRecall/render.d.ts +34 -0
  174. package/dist/plugins/historyRecall/tools.d.ts +4 -0
  175. package/dist/plugins/mcp/catalog.d.ts +36 -0
  176. package/dist/plugins/mcp/config.d.ts +63 -0
  177. package/dist/plugins/mcp/connection.d.ts +53 -0
  178. package/dist/plugins/mcp/errors.d.ts +32 -0
  179. package/dist/plugins/mcp/index.d.ts +33 -0
  180. package/dist/plugins/mcp/index.js +5 -0
  181. package/dist/plugins/mcp/mount.d.ts +98 -0
  182. package/dist/plugins/mcp/names.d.ts +25 -0
  183. package/dist/plugins/mcp/render.d.ts +29 -0
  184. package/dist/plugins/mcp/slots.d.ts +15 -0
  185. package/dist/plugins/mcp/stdio.d.ts +49 -0
  186. package/dist/plugins/mcp/tool.d.ts +41 -0
  187. package/dist/plugins/providers/anthropic.d.ts +175 -0
  188. package/dist/plugins/providers/anthropicMessages.d.ts +65 -0
  189. package/dist/plugins/providers/codex.d.ts +60 -0
  190. package/dist/plugins/providers/codexAuth.d.ts +116 -0
  191. package/dist/plugins/providers/deepseek.d.ts +55 -0
  192. package/dist/plugins/providers/door.d.ts +61 -0
  193. package/dist/plugins/providers/door.js +1 -0
  194. package/dist/plugins/providers/failure.d.ts +23 -0
  195. package/dist/plugins/providers/gateway.d.ts +23 -0
  196. package/dist/plugins/providers/index.d.ts +6 -0
  197. package/dist/plugins/providers/openaiChat.d.ts +62 -0
  198. package/dist/plugins/providers/openaiResponses.d.ts +100 -0
  199. package/dist/plugins/providers/opencodeCopilot.d.ts +23 -0
  200. package/dist/plugins/providers/opencodeGo.d.ts +98 -0
  201. package/dist/plugins/providers/shared.d.ts +104 -0
  202. package/dist/plugins/providers/stream.d.ts +154 -0
  203. package/dist/plugins/routeContext.d.ts +22 -0
  204. package/dist/plugins/routeContext.js +1 -0
  205. package/dist/plugins/schedules/index.d.ts +21 -0
  206. package/dist/plugins/schedules/index.js +5 -0
  207. package/dist/plugins/schedules/record.d.ts +396 -0
  208. package/dist/plugins/schedules/service.d.ts +120 -0
  209. package/dist/plugins/schedules/time.d.ts +26 -0
  210. package/dist/plugins/schedules/tools.d.ts +6 -0
  211. package/dist/plugins/skills/discovery.d.ts +54 -0
  212. package/dist/plugins/skills/index.d.ts +31 -0
  213. package/dist/plugins/skills/index.js +1 -0
  214. package/dist/plugins/skills/tool.d.ts +11 -0
  215. package/dist/plugins/store/durableObject.d.ts +23 -0
  216. package/dist/plugins/store/durableObject.js +1 -0
  217. package/dist/plugins/store/durableObjectConnection.d.ts +27 -0
  218. package/dist/plugins/store/memory.d.ts +29 -0
  219. package/dist/plugins/store/sql.d.ts +59 -0
  220. package/dist/plugins/store/sqlite.d.ts +31 -0
  221. package/dist/plugins/store/sqlite.js +1 -0
  222. package/dist/plugins/subAgents/availableRoutes.d.ts +53 -0
  223. package/dist/plugins/subAgents/fork.d.ts +32 -0
  224. package/dist/plugins/subAgents/index.d.ts +67 -0
  225. package/dist/plugins/subAgents/index.js +1 -0
  226. package/dist/plugins/subAgents/tool.d.ts +38 -0
  227. package/dist/plugins/toolPolicy/index.d.ts +61 -0
  228. package/dist/plugins/toolPolicy/index.js +1 -0
  229. package/dist/plugins/tools/editFiles.d.ts +128 -0
  230. package/dist/plugins/tools/fsRead.d.ts +17 -0
  231. package/dist/plugins/tools/html.d.ts +23 -0
  232. package/dist/plugins/tools/index.d.ts +59 -0
  233. package/dist/plugins/tools/index.js +1 -0
  234. package/dist/plugins/tools/network.d.ts +23 -0
  235. package/dist/plugins/tools/ripgrep.d.ts +20 -0
  236. package/dist/plugins/tools/textEdit.d.ts +67 -0
  237. package/dist/plugins/tools/web.d.ts +32 -0
  238. package/dist/plugins/truncateToolOutput.d.ts +26 -0
  239. package/dist/plugins/truncateToolOutput.js +1 -0
  240. package/dist/plugins/usage/index.d.ts +24 -0
  241. package/dist/plugins/usage/index.js +1 -0
  242. package/dist/plugins/usage/tracker.d.ts +34 -0
  243. package/dist/plugins/verify/facts.d.ts +356 -0
  244. package/dist/plugins/verify/index.d.ts +75 -0
  245. package/dist/plugins/verify/index.js +1 -0
  246. package/dist/plugins/verify/service.d.ts +90 -0
  247. package/dist/plugins/workflows/assignment.d.ts +16 -0
  248. package/dist/plugins/workflows/bindings.d.ts +95 -0
  249. package/dist/plugins/workflows/cleanup.d.ts +38 -0
  250. package/dist/plugins/workflows/definition.d.ts +184 -0
  251. package/dist/plugins/workflows/fold.d.ts +373 -0
  252. package/dist/plugins/workflows/index.d.ts +28 -0
  253. package/dist/plugins/workflows/index.js +6 -0
  254. package/dist/plugins/workflows/observations.d.ts +81 -0
  255. package/dist/plugins/workflows/participants.d.ts +143 -0
  256. package/dist/plugins/workflows/policy.d.ts +112 -0
  257. package/dist/plugins/workflows/providers.d.ts +146 -0
  258. package/dist/plugins/workflows/record.d.ts +2863 -0
  259. package/dist/plugins/workflows/routing.d.ts +116 -0
  260. package/dist/plugins/workflows/schema.d.ts +26 -0
  261. package/dist/plugins/workflows/service.d.ts +477 -0
  262. package/dist/plugins/workflows/submit.d.ts +8 -0
  263. package/dist/plugins/workflows/view.d.ts +103 -0
  264. package/dist/plugins/workflows/work.d.ts +21 -0
  265. package/dist/plugins/workspaceContext.d.ts +38 -0
  266. package/dist/plugins/workspaceContext.js +1 -0
  267. package/dist/presets/agents.d.ts +7 -0
  268. package/dist/presets/base.d.ts +10 -0
  269. package/dist/presets/codex.d.ts +60 -0
  270. package/dist/presets/index.d.ts +4 -0
  271. package/dist/presets/prompts.d.ts +56 -0
  272. package/dist/sandbox/absent.d.ts +32 -0
  273. package/dist/sandbox/client.d.ts +39 -0
  274. package/dist/sandbox/files.d.ts +28 -0
  275. package/dist/sandbox/index.d.ts +49 -0
  276. package/dist/sandbox/index.js +4 -0
  277. package/dist/sandbox/mode.d.ts +57 -0
  278. package/dist/sandbox/policy.d.ts +86 -0
  279. package/dist/sandbox/protocol.d.ts +107 -0
  280. package/dist/sandbox/service.d.ts +143 -0
  281. package/dist/sandbox/worker.d.ts +12 -0
  282. package/dist/sandbox/worker.js +1 -0
  283. package/dist/services/admission.d.ts +174 -0
  284. package/dist/services/agents.d.ts +37 -0
  285. package/dist/services/birth.d.ts +220 -0
  286. package/dist/services/contributions.d.ts +73 -0
  287. package/dist/services/core.d.ts +34 -0
  288. package/dist/services/journal.d.ts +26 -0
  289. package/dist/services/launches.d.ts +104 -0
  290. package/dist/services/llm.d.ts +80 -0
  291. package/dist/services/owner.d.ts +367 -0
  292. package/dist/services/preset.d.ts +154 -0
  293. package/dist/services/presets.d.ts +139 -0
  294. package/dist/services/prompts.d.ts +67 -0
  295. package/dist/services/runEvents.d.ts +79 -0
  296. package/dist/services/thread.d.ts +267 -0
  297. package/dist/services/threadActivation.d.ts +100 -0
  298. package/dist/services/threadDirs.d.ts +38 -0
  299. package/dist/services/threadView.d.ts +92 -0
  300. package/dist/services/threads.d.ts +449 -0
  301. package/dist/services/tools.d.ts +41 -0
  302. package/dist/sys/environment.d.ts +47 -0
  303. package/dist/sys/git.d.ts +60 -0
  304. package/dist/sys/paths.d.ts +56 -0
  305. package/dist/sys/spawn.d.ts +176 -0
  306. package/dist/testing/clock.d.ts +17 -0
  307. package/dist/testing/fakeLlm.d.ts +74 -0
  308. package/dist/testing/fedLlm.d.ts +32 -0
  309. package/dist/testing/helpers.d.ts +344 -0
  310. package/dist/testing/index.d.ts +13 -0
  311. package/dist/testing/index.js +1 -0
  312. package/dist/testing/processes.d.ts +13 -0
  313. package/dist/testing/sandbox.d.ts +71 -0
  314. package/dist/testing/settlement.d.ts +6 -0
  315. package/dist/testing/tmpDirs.d.ts +17 -0
  316. package/dist/util/async.d.ts +8 -0
  317. package/dist/util/diff.d.ts +25 -0
  318. package/dist/util/dispatch.d.ts +8 -0
  319. package/dist/util/errors.d.ts +28 -0
  320. package/dist/util/foldState.d.ts +17 -0
  321. package/dist/util/freeze.d.ts +2 -0
  322. package/dist/util/ids.d.ts +2 -0
  323. package/dist/util/json.d.ts +37 -0
  324. package/dist/util/log.d.ts +6 -0
  325. package/dist/util/text.d.ts +21 -0
  326. package/dist/util/version.d.ts +2 -0
  327. package/package.json +175 -3
@@ -0,0 +1 @@
1
+ import{a as C,c as j,d as m}from"../chunks/2O7ZGEIT.js";import"../chunks/4XVRUSCQ.js";import{a as N}from"../chunks/OVZFGILJ.js";import{c as M,d as D}from"../chunks/UD3VJER6.js";import{b as R,c as B}from"../chunks/SGGMBSBA.js";import"../chunks/3QCW4WDJ.js";import{b as J}from"../chunks/J5S4URAW.js";import{c as F,d as W,f as $}from"../chunks/JPZFKSWT.js";import{b as I}from"../chunks/RK3VP2Q4.js";import{b as A}from"../chunks/74HKUGRR.js";import"../chunks/YIR5MYGU.js";import"../chunks/L3N4FIEN.js";import{a as z}from"../chunks/NAOUTU7A.js";import"../chunks/UKXMCHHT.js";import{a as v}from"../chunks/NDIM7MEW.js";import"../chunks/34KW6VNQ.js";import{a as L}from"../chunks/G6RXC3AL.js";import"../chunks/GQGNVSKB.js";import"../chunks/DXFXAYDN.js";import"../chunks/2OSESBIL.js";import{F as S,S as b,ha as P,o as E}from"../chunks/YLNJXQ3Z.js";import{f as O}from"../chunks/DDANMY45.js";import{w as q}from"../chunks/37YOGDGY.js";import"../chunks/KESCTXGO.js";import"../chunks/TYTQRLTX.js";import{t as T,v as p,w}from"../chunks/D7E6EWIE.js";var u=class{claimed=!1;ledger=new v;failure;chunks;settled;options;constructor(e,r,n={}){this.chunks=e,this.settled=r,this.options=n}[Symbol.asyncIterator](){if(this.claimed)throw new Error("A response is read once: it has been claimed already");this.claimed=!0;let e=this.read();return{next:()=>this.ledger.operation(()=>e.next()),return:r=>this.ledger.operation(()=>e.return(r),!0),throw:r=>this.ledger.operation(()=>e.throw(r),!0)}}async*read(){try{for await(let r of this.chunks)yield T.parse(r);let e=this.options.readFailure===!0?this.settlement():void 0;if(e instanceof Error)throw e}catch(e){throw this.failure={error:e},e}finally{this.ledger.finish()}}settlement(){return typeof this.settled=="function"?this.settled():this.settled}async completed(){if(this.claimed){if(!this.ledger.ended)throw new Error("A response is settled before its read or after it, not while the read is under way")}else for await(let r of this);if(this.failure!==void 0)throw this.failure.error;let e=this.settlement();if(e instanceof Error)throw e;return"finish"in e?e:{message:e,finish:this.options.finish??"completed",provider_metadata:{}}}},g=class t{providerName="fake";requests=[];handler;constructor(e){this.handler=e}static scripted(...e){let r=0;return new t(()=>{let n=e[r];if(n===void 0)throw new Error(`Unexpected LLM call #${r+1}`);return r+=1,n})}async chat(e){if(this.requests.push(e),e.signal?.aborted)throw e.signal.reason instanceof Error?e.signal.reason:new Error("aborted");let r=await this.handler(e.messages,e);return"failure"in r?new u(r.chunks,r.failure):"chunks"in r?new u(r.chunks,r.message):new u([],r)}},ie=(t,e={})=>p({role:"assistant",content:t,...e}),le=(t,e=null)=>p({role:"assistant",content:e,tool_calls:t.map(r=>r.arguments===void 0?{...r,arguments:{}}:r)});var y=class{request;queue=[];ended=null;text="";wake=null;constructor(e){this.request=e,e.signal?.addEventListener("abort",()=>{this.ended??={cutOff:!0},this.wake?.()},{once:!0})}push(e){this.queue.push(e),this.wake?.()}finish(e,r={}){this.ended??={message:p({role:"assistant",content:e,...r})},this.wake?.()}fail(e){this.ended??={error:e},this.wake?.()}stream=new u(this.feed(),()=>this.ended!==null&&"cutOff"in this.ended?{message:p({role:"assistant",content:this.text||null}),finish:"other",provider_metadata:{}}:this.ended!==null&&"message"in this.ended?this.ended.message:new Error("The stream did not finish"));async*feed(){for(;;){let e=this.queue.shift();if(e!==void 0){this.text+=e.text_delta??"",yield e;continue}if(this.ended!==null){if("error"in this.ended)throw this.ended.error;return}await new Promise(r=>this.wake=r),this.wake=null}}},x=class{providerName="fake";calls=[];waiting=[];taken=0;async chat(e){let r=new y(e);return this.calls.push(r),this.waiting.shift()?.(r),r.stream}next(){let e=this.taken++,r=this.calls[e];return r!==void 0?Promise.resolve(r):new Promise(n=>this.waiting.push(n))}};import{randomUUID as _}from"node:crypto";import{readFileSync as me}from"node:fs";import{Context as he,scopeOf as we}from"@leuduan/cordis";import{onTestFinished as ge,vi as tt}from"vitest";import{z as Q}from"zod";import{mkdtempSync as de,rmSync as ce}from"node:fs";import{tmpdir as ue}from"node:os";import{join as pe}from"node:path";import{onTestFinished as fe}from"vitest";var U=new Set;function H(t){let e=de(pe(ue(),t));return U.add(e),e}function V(t){U.delete(t),ce(t,{recursive:!0,force:!0})}function Y(t="lagent-test-"){let e=H(t);return fe(()=>V(e)),{root:e}}function G(t,e="lagent-test-"){let r=H(e);return t.effect(()=>()=>V(r)),r}var Z=(t,e="fake")=>({name:`test:provider:${e}`,inject:["llm"],apply:(r,n)=>C(r,{name:e,defaultModel:"test-model",...n?.thinkingEffort===void 0?{}:{defaultThinkingEffort:n.thinkingEffort},capacity:n?.capacity??(()=>({contextWindow:null,providerTools:!1,toolResultImages:!1})),createClient:()=>t,classify:n?.classify??(()=>({kind:"other"}))},{retry:n?.retry??xe})}),ye=Object.freeze({provider:"fake",model:"test-model",thinking_effort:null}),xe={maxAttempts:1,baseDelayMs:0,maxDelayMs:0},_e=10,K={resume:"all",startLimit:64};function ee(t={}){return{from:"defaults",route:ye,...t}}async function ke(t){let e=new he;return t.disposal!=="manual"&&ge(()=>e.fiber.dispose()),await e.plugin(j,{store:t.store??new m,cwd:t.cwd??process.cwd(),dataDir:t.dataDir===void 0?G(e,"lagent-data-"):t.dataDir,retention:t.retention??"keep",chainLimit:t.chainLimit??_e,...t.limits===void 0?{}:{limits:t.limits}}),await e.plugin(Z(t.llm),{...t.capacity===void 0?{}:{capacity:t.capacity},...t.classify===void 0?{}:{classify:t.classify},...t.retry===void 0?{}:{retry:t.retry}}),await e.plugin(te(t.agents??re())),await e.plugin({name:"test:tools",inject:["tools"],apply(r){for(let{name:n,tool:a}of t.tools??Se())r.effect(()=>r.tools.register(we(r),n,a))}}),e.appended=[],e.journal.subscribe(r=>e.appended.push(r)),e.newThread=({id:r=_(),agent:n="main_agent",...a}={})=>e.threads.create(n,{id:r,...a.birth===void 0?{reuse:"identity",birth:ee()}:{},...a}),t.start!=="defer"&&await e.threads.start(K),e}var Te=()=>{let t=W(process.env,F);for(let e of N)delete t[e];return t},ve=()=>$(process.env.PATH??""),qe=Q.strictObject({path:Q.string()}),Ee=z({name:"read_file",description:"Read a file from the workspace.",parameters:qe,onInterrupted:"rerun",executionMode:"parallel",async execute(t,e){let r=L(e,"read").resolve(t.path);return{output:me(r,"utf8")}}}),Se=()=>[{name:"read_file",tool:Ee}],te=t=>({name:"test:agents",inject:["agents","tools"],apply(e){for(let{tools:r=[],...n}of t){R(e,n);for(let a of r)B(e,a,[n.name])}}}),X=(t={})=>({name:"main_agent",tools:["read_file"],...t}),re=(...t)=>t.length>0?t.map(e=>X(e)):[X()];async function be(t,e={}){let{route:r,signal:n,untilWait:a=!1}=e,l=()=>t.cancel(n===void 0?"Turn cancelled":O(n.reason),{intent:"user"});if(n?.aborted)return await l(),{thread_id:t.id,ended:"cancelled",reason:null,pending_confirmations:null};let s,o=()=>{s=l(),s.catch(()=>{})};n?.addEventListener("abort",o,{once:!0});let d=t.service,h=t.summary.through_seq;try{let f=await t.resume(r===void 0?{}:{route:r});if(s!==void 0)return await s,{thread_id:t.id,ended:"cancelled",reason:null,pending_confirmations:null};let c=await M(d,t.id,f,i=>D(i)&&(a||i.state!=="held"||i.hold.reason!=="wait"));await s;let k=await t.read(i=>i.replay().filter(oe=>oe.seq>h)),se=n?.aborted===!0||c.state==="held"&&c.hold.reason==="shutdown"||c.state==="settled"&&(c.outcome==="cancelled"||c.outcome==="superseded");return{thread_id:t.id,ended:se?"cancelled":k.some(i=>i.type==="turn/start")?"turns":"none",reason:k.some(i=>i.type==="turn/end")?t.lastOutcome():null,pending_confirmations:await t.read(i=>i.pendingConfirmations())}}finally{n?.removeEventListener("abort",o)}}var Oe=(t={})=>({maxOpenTasks:8,clock:J,...t});async function Pe(t,e,r,n,a={}){let l=t,[s]=await P(l,e,{trigger:"request",turn:null,step:null},[{kind:"span",stand_in:{role:a.role??"user",content:n},source:a.source??{plugin:"test:strategy",kind:"checkpoint",version:1,data:null},source_seqs:r.map(o=>o.seq)}]);return l.eventAt(s.seq)}var Re=t=>t===void 0?"":w(t);var Ae=t=>{let e=[...t].reverse().find(r=>r.role==="tool");return e===void 0?null:w(e)},Ce=t=>t.service.view(t.id);function Ie(t=new m,e={}){return new q(t,{summarize:e.summarize??((r,n)=>b(r,n,S())),...e.onListenerError===void 0?{}:{onListenerError:e.onListenerError},coreFolds:e.coreFolds??(e.summarize===void 0?[E]:[])})}async function Le(t){let e=t;return await Promise.all(t.summaries().map(r=>e.load(r.thread_id))),t.summaries().flatMap(r=>t.rows(r.thread_id)).sort((r,n)=>r.seq-n.seq)}async function ne(t){let e=t.isOpen;e||await t.open();try{let r=await t.threads();return(await Promise.all(r.map(({threadId:a})=>t.read(a)))).flat().sort((a,l)=>a.seq-l.seq)}finally{e||await t.close()}}async function ae(t,e,r){let n=await t.acquireWriter();try{for(let a of e)await t.append({id:_(),baseHead:await t.head(),writer:n.acquisitionId,rows:[a]});await t.putSummaries(r,n.acquisitionId)}finally{await n.release()}}async function Me(t){let e=new m;await e.open();let r=t.isOpen;r||await t.open();try{await ae(e,await ne(t),await t.summaries())}finally{r||await t.close()}return e}async function De(t){let e=new m;await e.open(),await ae(e,t,[]);let r=Ie(e);return await r.open(),await r.close(),e}async function je(t,e){let r=await A(t).append("tool/call",{turn:1,step:1,call_id:`call-${_()}`,name:"test_call"},{threadId:e});return{caller_thread_id:e,source_seq:r.seq,cause:{kind:"call"}}}var Ne=t=>({name:`test:prompt:${t.tag}`,inject:["prompts"],apply:e=>I(e,t)});function Fe(t=Date.parse("2026-01-05T09:00:00Z")){let e=t,r=0,n=0,a=new Map,l=(s,o)=>{for(;;){let d;for(let c of a)c[1].due<=s&&(d===void 0||c[1].due<d[1].due)&&(d=c);if(d===void 0)break;let[h,f]=d;o&&(e+=f.due-r),r=f.due,a.delete(h),f.fire()}o&&(e+=s-r),r=s};return{now:()=>e,setTimer(s,o){let d=n++;return a.set(d,{due:r+Math.max(0,s),fire:o}),()=>{a.delete(d)}},advance:s=>l(r+s,!0),jump(s){e+=s},elapse:s=>l(r+s,!1),pending:()=>[...a.values()].map(s=>s.due-r).sort((s,o)=>s-o)}}export{g as FakeLLMClient,x as FedLLM,K as TEST_START,ie as assistant,je as callOrigin,Me as copyStore,ke as createTestRoot,be as drive,Z as fakeProvider,Le as journalRows,Ae as lastToolMessage,Fe as manualClock,Pe as replaceSpan,De as replayStore,ne as storeRows,re as testAgents,te as testAgentsPlugin,ee as testBirth,Oe as testDelegations,Te as testEnvironment,ve as testPrograms,Ne as testPromptPlugin,Re as textOf,Y as tmpWorkspace,Ce as viewOf,le as withToolCalls};
@@ -0,0 +1,13 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ /** The URL of a source module, such as `sys/spawn.ts`, for a {@link lagentProcess} script to import. */
3
+ export declare const sourceModule: (path: string) => string;
4
+ /**
5
+ * Another lagent process, running `script` as an ES module against the TypeScript sources, for
6
+ * tests of what happens when a process ends — which a test cannot do to its own. Only for tests
7
+ * run from the sources. The caller kills it.
8
+ */
9
+ export declare function lagentProcess(script: string): {
10
+ child: ChildProcess;
11
+ line: () => Promise<string>;
12
+ exited: () => Promise<number | null>;
13
+ };
@@ -0,0 +1,71 @@
1
+ import type { Fiber } from '@leuduan/cordis';
2
+ import { type LLMClient } from '../llm/index.js';
3
+ import type { ToolResult } from '../models/index.js';
4
+ import { type SandboxConfigInput } from '../sandbox/index.js';
5
+ import type { Launched, LaunchOptions } from '../services/launches.js';
6
+ import type { SandboxService } from '../sandbox/service.js';
7
+ import { type TestRoot } from './helpers.js';
8
+ /**
9
+ * A root with the OS sandbox mounted over real sandbox-runtime, for the sandbox's tests. The sandbox
10
+ * starts once per process, so a test file starts one harness and every test in it shares the service.
11
+ */
12
+ /** Whether this machine can run the sandbox: macOS with Seatbelt. */
13
+ export declare const sandboxSupported: boolean;
14
+ type RunOptions = {
15
+ signal?: AbortSignal;
16
+ workdir?: string;
17
+ root?: string;
18
+ /** Keys the launch's scratch directory. */
19
+ threadId?: string;
20
+ /** The thread the launch serves, which must exist: its conversation's mode decides it. */
21
+ subject?: string;
22
+ beforeRelease?: LaunchOptions['beforeRelease'];
23
+ };
24
+ type RunOutcome = {
25
+ launched: Launched;
26
+ output: string;
27
+ result: Awaited<Launched['spawned']['result']>;
28
+ report: string | null;
29
+ };
30
+ export type SandboxHarness = {
31
+ readonly root: TestRoot;
32
+ /** Canonical, like every path the sandbox judges. */
33
+ readonly base: string;
34
+ readonly workspace: string;
35
+ /** The extra writable root, when the harness was started with one. */
36
+ readonly extraRoot: string;
37
+ readonly data: string;
38
+ readonly tmpRoot: string;
39
+ readonly config: SandboxConfigInput;
40
+ readonly fiber: Fiber;
41
+ readonly service: SandboxService;
42
+ readonly environment: Record<string, string>;
43
+ /** Calls a `commands` tool as a thread's model would; needs the harness started with `commands`. */
44
+ tool(name: string, args: Record<string, unknown>, options?: {
45
+ threadId?: string;
46
+ callSeq?: number;
47
+ }): Promise<ToolResult>;
48
+ /**
49
+ * Launches `command` through `ctx.launches` as `commands` does:
50
+ * resolves once it runs, with output attached, and `done` settles when it has ended.
51
+ */
52
+ launch(command: string, options?: RunOptions): Promise<{
53
+ launched: Launched;
54
+ done: Promise<RunOutcome>;
55
+ }>;
56
+ /** {@link launch}, then waits for the end. */
57
+ run(command: string, options?: RunOptions): Promise<RunOutcome>;
58
+ dispose(): Promise<void>;
59
+ };
60
+ export declare function startSandboxHarness(options?: {
61
+ config?: Partial<SandboxConfigInput>;
62
+ /** The model the root's threads run on; one with no script unless a test drives turns. */
63
+ llm?: LLMClient;
64
+ /** Mount `commands` over it, as a host does. */
65
+ commands?: boolean;
66
+ /** Lists `<workspace>/cache` as an extra writable root, created. */
67
+ extraRoot?: boolean;
68
+ /** The worker entry; the sources' `worker.ts` unless a test needs another. */
69
+ worker?: URL;
70
+ }): Promise<SandboxHarness>;
71
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { StreamingLLMResponse } from '../llm/index.js';
2
+ /**
3
+ * Asks `stream` to settle at every turn of the microtask queue while `closing` is pending, and fails
4
+ * when one settles with `closing` still pending at the moment it was asked: the read is not over.
5
+ */
6
+ export declare function settlementNeverEarly(stream: StreamingLLMResponse, closing: Promise<unknown>): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import type { Context } from '@leuduan/cordis';
2
+ /**
3
+ * A temporary directory that lives as long as the test that made it, in its body or a
4
+ * `beforeEach`: removed once that test finishes, after any root made after it is disposed.
5
+ */
6
+ export declare function tmpWorkspace(prefix?: string): {
7
+ root: string;
8
+ };
9
+ /** A temporary directory removed when `ctx` is disposed. */
10
+ export declare function ownedTmpDir(ctx: Context, prefix?: string): string;
11
+ /**
12
+ * Removes every temporary directory made by `tmpWorkspace` or `ownedTmpDir` that nothing cleaned
13
+ * up, such as the data directory of a root a test never disposed. The vitest setup file calls it
14
+ * after each test file, so no directory outlives the file that made it. Kept apart from the
15
+ * helpers so that setup file imports nothing else.
16
+ */
17
+ export declare function removeLeftoverTmpDirs(): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `task`, or the signal's reason once it aborts: stops waiting, not the work, which keeps running.
3
+ * A signal aborted already rejects at once, even when `task` has settled: the abort is raced first.
4
+ * `task` is always observed, so its later failure is never an unhandled rejection.
5
+ */
6
+ export declare function abortable<T>(task: Promise<T>, signal: AbortSignal): Promise<T>;
7
+ /** The longest delay a Node timer honours; a longer one fires at once. The bound of every timer setting. */
8
+ export declare const MAX_TIMER_MS: number;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A line diff between two texts, as unified diff text.
3
+ *
4
+ * Myers' algorithm over the lines left once the common head and tail are set aside, which is all
5
+ * that differs when an edit changed a few places. Its search is bounded: past
6
+ * {@link MAX_EDIT_DISTANCE} differing lines, or work proportional to it, the middle is given as
7
+ * removed and added whole, which is still a correct diff, only not the shortest.
8
+ */
9
+ export type UnifiedDiff = {
10
+ /** The diff, with `---`/`+++` headers; empty when the texts have the same lines. */
11
+ readonly text: string;
12
+ readonly added: number;
13
+ readonly removed: number;
14
+ };
15
+ /**
16
+ * The unified diff from `before` to `after`, with `context` lines around each change. Lines split
17
+ * on `\n`, a carriage return right before it dropped, and a last line without a newline is marked
18
+ * as git marks it.
19
+ */
20
+ export declare function unifiedDiff(before: string, after: string, labels: {
21
+ readonly from: string;
22
+ readonly to: string;
23
+ }, context?: number): UnifiedDiff;
24
+ /** How many lines a text has: a last line without a newline counts. */
25
+ export declare function lineCount(text: string): number;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Calls every listener with `event`, synchronously and in order, and never awaits one. A throw, or
3
+ * the rejection of anything a listener returns with a `then`, is reported, and the other listeners
4
+ * still run. A returned thenable is adopted, so its `then` is called once. The one rule for "a
5
+ * listener failed"; the caller owns the event, freezing it when the listeners must not change what
6
+ * the others see.
7
+ */
8
+ export declare function dispatch<T>(listeners: Iterable<(event: T) => unknown>, event: T, report: (error: unknown) => void): void;
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ export declare const formatError: (error: unknown) => string;
3
+ /**
4
+ * `formatError` followed by the `cause` chain. A transport failure's own message says nothing (the
5
+ * OpenAI SDK's is just `Connection error.`); what actually broke is in its causes.
6
+ */
7
+ export declare function formatErrorWithCauses(error: unknown): string;
8
+ /** The Node system-error code of `error`, such as `ENOENT`, when it has one. */
9
+ export declare const errnoCode: (error: unknown) => string | undefined;
10
+ /** Whether `error` is a Node system error with one of `codes`. */
11
+ export declare const hasErrnoCode: (error: unknown, ...codes: string[]) => boolean;
12
+ /** A zod failure as one line per bad field, in the form the calling model is told about. */
13
+ export declare function formatValidationError(error: z.ZodError): string;
14
+ /** What a failure says in the journal: a validation error as its fields, anything else with its causes. */
15
+ export declare const failureText: (error: unknown) => string;
16
+ /**
17
+ * Whether `error` is how work stops on `signal`: its reason, or one wrapping it as Node's abortable
18
+ * APIs do (`cause`), possibly again (`Promise.any` over them), a few levels down. A failure that only
19
+ * coincided with the abort is not.
20
+ */
21
+ export declare function stoppedOn(signal: AbortSignal, error: unknown, depth?: number): boolean;
22
+ /**
23
+ * Whether `error` is the cancellation of work on `signal`, not a failure that coincided with it: its
24
+ * reason (see {@link stoppedOn}), or the `AbortError` a platform transport (`fetch`, a stream) throws
25
+ * when the signal it was handed fired. Either needs the signal to have fired. An adapter whose SDK
26
+ * throws an abort error of its own turns it into the signal's reason.
27
+ */
28
+ export declare function isCancellation(signal: AbortSignal, error: unknown): boolean;
@@ -0,0 +1,17 @@
1
+ import type { JsonValue, ReadonlyJsonValue } from './json.js';
2
+ /**
3
+ * A fold's state as a reader sees it: read-only all the way down. Arrays become `readonly`, `Map`
4
+ * and `Set` their read-only forms, and records map property by property. Fold state is plain data
5
+ * (primitives, arrays, records, `Map` and `Set`), so a function-typed member becomes `never`: the
6
+ * state cannot hand a reader a way to change it. A field typed exactly `JsonValue` becomes
7
+ * {@link ReadonlyJsonValue}, as in `DeepReadonly`, since mapping the recursive alias does not
8
+ * terminate. This is cooperative authoring, not a sandbox: reducers keep the mutable state and
9
+ * nothing is copied or frozen on read, so a cast, or a narrowing TypeScript widens, can still reach
10
+ * the mutable value. `Array.isArray` is the known one: it narrows a read-only array to `any[]`, so
11
+ * `push` on a JSON array payload compiles. The type does not exclude every cast-free mutation.
12
+ */
13
+ export type ReadonlyState<S> = [S] extends [JsonValue] ? [JsonValue] extends [S] ? ReadonlyJsonValue : ReadonlyStateOf<S> : [S] extends [ReadonlyJsonValue] ? [ReadonlyJsonValue] extends [S] ? S : ReadonlyStateOf<S> : ReadonlyStateOf<S>;
14
+ type ReadonlyStateOf<S> = S extends (...args: never[]) => unknown ? never : S extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<ReadonlyState<K>, ReadonlyState<V>> : S extends ReadonlySet<infer T> ? ReadonlySet<ReadonlyState<T>> : S extends object ? {
15
+ readonly [K in keyof S]: ReadonlyState<S[K]>;
16
+ } : S;
17
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Recursively freezes a tree of data values. Call on an owned copy, never a live service. */
2
+ export declare function freezeData<T>(value: T): T;
@@ -0,0 +1,2 @@
1
+ /** A prefixed unique id, for things a reader has to tell apart at a glance in a journal. */
2
+ export declare const nextId: (prefix: string) => string;
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Recursively drops `null` object values, so a field left unset and one set to null compare equal.
4
+ *
5
+ * This is for comparing, not for storing: the session journal writes events as they stand, because
6
+ * a row that read back differently from the event in memory made a live session and a resumed one
7
+ * disagree about their own history.
8
+ */
9
+ export declare function stripNone<T>(value: T): T;
10
+ /**
11
+ * JSON with object keys sorted at every level, so equal values produce equal strings. Like
12
+ * `JSON.stringify`, it leaves out properties whose value is `undefined`, so a value compares equal
13
+ * to itself read back from storage.
14
+ */
15
+ export declare function stableStringify(value: unknown): string;
16
+ export declare const JsonValueSchema: z.ZodJSONSchema;
17
+ export type JsonValue = z.infer<typeof JsonValueSchema>;
18
+ /** A {@link JsonValue} no reader may change: what a frozen fact holds. */
19
+ export type ReadonlyJsonValue = string | number | boolean | null | readonly ReadonlyJsonValue[] | {
20
+ readonly [key: string]: ReadonlyJsonValue;
21
+ };
22
+ /**
23
+ * `T` with every property and array readonly, all the way down: the type of a frozen fact. A field
24
+ * typed exactly `JsonValue` or `ReadonlyJsonValue` becomes {@link ReadonlyJsonValue}, since mapping
25
+ * the recursive alias itself does not terminate; so a type that is already deeply readonly maps to
26
+ * itself.
27
+ */
28
+ export type DeepReadonly<T> = [T] extends [ReadonlyJsonValue] ? [ReadonlyJsonValue] extends [T] ? ReadonlyJsonValue : [JsonValue] extends [T] ? ReadonlyJsonValue : DeepReadonlyObject<T> : DeepReadonlyObject<T>;
29
+ type DeepReadonlyObject<T> = T extends object ? {
30
+ readonly [K in keyof T]: DeepReadonly<T[K]>;
31
+ } : T;
32
+ /**
33
+ * A mutable copy of a read-only JSON value: for a payload read from a fold that a row or a public
34
+ * result is made of, which must not share what the fold holds.
35
+ */
36
+ export declare function copyJson(value: ReadonlyJsonValue): JsonValue;
37
+ export {};
@@ -0,0 +1,6 @@
1
+ /** Minimal logger: warnings and errors go to stderr, debug output only with LAGENT_DEBUG set. */
2
+ export declare const log: {
3
+ debug(message: string, ...args: unknown[]): void;
4
+ warn(message: string, ...args: unknown[]): void;
5
+ error(message: string, ...args: unknown[]): void;
6
+ };
@@ -0,0 +1,21 @@
1
+ export type RenderTagOptions = {
2
+ attrs?: Record<string, string>;
3
+ namespace?: string;
4
+ };
5
+ /** The XML-ish block format prompts and tool results are written in. */
6
+ export declare function renderTag(name: string, content: string, options?: RenderTagOptions): string;
7
+ /**
8
+ * Text that a section's author did not write, with every opening and closing tag of the named
9
+ * sections defused, `<name` into `<\name` and `</name` into `<\/name`, so it can neither end one of
10
+ * them early nor open a second. Matching ignores case and the space after `<` or `</`, as a lenient
11
+ * reader would; a tag of any other name is left alone.
12
+ */
13
+ export declare function neutralizeTags(text: string, names: readonly string[]): string;
14
+ /**
15
+ * `index` moved off the middle of a surrogate pair, so a slice never holds half of one: the end of a
16
+ * slice goes back to before the pair, the start of one forward past it. Any other index is returned
17
+ * as it is; the caller keeps its own policy for where it cuts.
18
+ */
19
+ export declare function cutAt(text: string, index: number, edge: 'start' | 'end'): number;
20
+ /** Code-unit order, not locale order, so listings are stable across machines. */
21
+ export declare const sortStrings: (values: Iterable<string>) => string[];
@@ -0,0 +1,2 @@
1
+ /** The package version, for client/server identification strings. */
2
+ export declare function lagentVersion(): string;
package/package.json CHANGED
@@ -1,6 +1,178 @@
1
1
  {
2
2
  "name": "@leuduan/lagent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.2",
4
+ "description": "Plugin-based agent execution engine built on @leuduan/cordis",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "author": "Duan Leu",
7
+ "files": [
8
+ "dist",
9
+ "!dist/**/*.map"
10
+ ],
11
+ "type": "module",
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./models": {
19
+ "types": "./dist/models/door.d.ts",
20
+ "import": "./dist/models/door.js"
21
+ },
22
+ "./llm": {
23
+ "types": "./dist/llm/door.d.ts",
24
+ "import": "./dist/llm/door.js"
25
+ },
26
+ "./providers": {
27
+ "types": "./dist/plugins/providers/door.d.ts",
28
+ "import": "./dist/plugins/providers/door.js"
29
+ },
30
+ "./sqlite": {
31
+ "types": "./dist/plugins/store/sqlite.d.ts",
32
+ "import": "./dist/plugins/store/sqlite.js"
33
+ },
34
+ "./durable-object": {
35
+ "types": "./dist/plugins/store/durableObject.d.ts",
36
+ "import": "./dist/plugins/store/durableObject.js"
37
+ },
38
+ "./sandbox": {
39
+ "types": "./dist/sandbox/index.d.ts",
40
+ "import": "./dist/sandbox/index.js"
41
+ },
42
+ "./plugin": {
43
+ "types": "./dist/plugin.d.ts",
44
+ "import": "./dist/plugin.js"
45
+ },
46
+ "./testing": {
47
+ "types": "./dist/testing/index.d.ts",
48
+ "import": "./dist/testing/index.js"
49
+ },
50
+ "./plugins/agentsMd": {
51
+ "types": "./dist/plugins/agentsMd.d.ts",
52
+ "import": "./dist/plugins/agentsMd.js"
53
+ },
54
+ "./plugins/ask": {
55
+ "types": "./dist/plugins/ask/index.d.ts",
56
+ "import": "./dist/plugins/ask/index.js"
57
+ },
58
+ "./plugins/commands": {
59
+ "types": "./dist/plugins/commands/index.d.ts",
60
+ "import": "./dist/plugins/commands/index.js"
61
+ },
62
+ "./plugins/compaction": {
63
+ "types": "./dist/plugins/compaction/index.d.ts",
64
+ "import": "./dist/plugins/compaction/index.js"
65
+ },
66
+ "./plugins/dateAndBranch": {
67
+ "types": "./dist/plugins/dateAndBranch.d.ts",
68
+ "import": "./dist/plugins/dateAndBranch.js"
69
+ },
70
+ "./plugins/delegations": {
71
+ "types": "./dist/plugins/delegations/index.d.ts",
72
+ "import": "./dist/plugins/delegations/index.js"
73
+ },
74
+ "./plugins/diagnostics": {
75
+ "types": "./dist/plugins/diagnostics/index.d.ts",
76
+ "import": "./dist/plugins/diagnostics/index.js"
77
+ },
78
+ "./plugins/historyRecall": {
79
+ "types": "./dist/plugins/historyRecall/index.d.ts",
80
+ "import": "./dist/plugins/historyRecall/index.js"
81
+ },
82
+ "./plugins/mcp": {
83
+ "types": "./dist/plugins/mcp/index.d.ts",
84
+ "import": "./dist/plugins/mcp/index.js"
85
+ },
86
+ "./plugins/routeContext": {
87
+ "types": "./dist/plugins/routeContext.d.ts",
88
+ "import": "./dist/plugins/routeContext.js"
89
+ },
90
+ "./plugins/schedules": {
91
+ "types": "./dist/plugins/schedules/index.d.ts",
92
+ "import": "./dist/plugins/schedules/index.js"
93
+ },
94
+ "./plugins/skills": {
95
+ "types": "./dist/plugins/skills/index.d.ts",
96
+ "import": "./dist/plugins/skills/index.js"
97
+ },
98
+ "./plugins/subAgents": {
99
+ "types": "./dist/plugins/subAgents/index.d.ts",
100
+ "import": "./dist/plugins/subAgents/index.js"
101
+ },
102
+ "./plugins/tools": {
103
+ "types": "./dist/plugins/tools/index.d.ts",
104
+ "import": "./dist/plugins/tools/index.js"
105
+ },
106
+ "./plugins/toolPolicy": {
107
+ "types": "./dist/plugins/toolPolicy/index.d.ts",
108
+ "import": "./dist/plugins/toolPolicy/index.js"
109
+ },
110
+ "./plugins/truncateToolOutput": {
111
+ "types": "./dist/plugins/truncateToolOutput.d.ts",
112
+ "import": "./dist/plugins/truncateToolOutput.js"
113
+ },
114
+ "./plugins/usage": {
115
+ "types": "./dist/plugins/usage/index.d.ts",
116
+ "import": "./dist/plugins/usage/index.js"
117
+ },
118
+ "./plugins/verify": {
119
+ "types": "./dist/plugins/verify/index.d.ts",
120
+ "import": "./dist/plugins/verify/index.js"
121
+ },
122
+ "./plugins/workflows": {
123
+ "types": "./dist/plugins/workflows/index.d.ts",
124
+ "import": "./dist/plugins/workflows/index.js"
125
+ },
126
+ "./plugins/workspaceContext": {
127
+ "types": "./dist/plugins/workspaceContext.d.ts",
128
+ "import": "./dist/plugins/workspaceContext.js"
129
+ },
130
+ "./package.json": "./package.json"
131
+ },
132
+ "dependencies": {
133
+ "@modelcontextprotocol/sdk": "1.30.0",
134
+ "openai": "7.10.0",
135
+ "yaml": "2.9.0",
136
+ "zod": "4.5.4",
137
+ "@leuduan/cordis": "1.0.3"
138
+ },
139
+ "peerDependencies": {
140
+ "@anthropic-ai/sandbox-runtime": "0.0.79",
141
+ "vitest": "4.1.5"
142
+ },
143
+ "peerDependenciesMeta": {
144
+ "@anthropic-ai/sandbox-runtime": {
145
+ "optional": true
146
+ },
147
+ "vitest": {
148
+ "optional": true
149
+ }
150
+ },
151
+ "devDependencies": {
152
+ "@anthropic-ai/sandbox-runtime": "0.0.79",
153
+ "@cloudflare/vitest-plugin": "1.3.6",
154
+ "@types/node": "22.19.1",
155
+ "esbuild": "0.28.1",
156
+ "typescript": "^6.0.3",
157
+ "vitest": "4.1.5",
158
+ "@local/tsconfig": "1.0.0"
159
+ },
160
+ "repository": {
161
+ "type": "git",
162
+ "url": "git+https://github.com/leuduan/luna.git",
163
+ "directory": "js/packages/lagent"
164
+ },
165
+ "publishConfig": {
166
+ "access": "public"
167
+ },
168
+ "engines": {
169
+ "node": ">=22.13"
170
+ },
171
+ "scripts": {
172
+ "clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
173
+ "ts-check": "tsc --noEmit && tsc --noEmit -p tsconfig.workers.json",
174
+ "build": "tsc --build tsconfig.build.json",
175
+ "test": "vitest run",
176
+ "test:workers": "vitest run --config vitest.workers.config.ts"
177
+ }
6
178
  }