@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,65 @@
1
+ import { z } from 'zod';
2
+ import type { ContentPart } from '../../llm/index.js';
3
+ export declare const ToolResultPayloadSchema: z.ZodObject<{
4
+ output: z.ZodString;
5
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ type: z.ZodLiteral<"text">;
7
+ text: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ type: z.ZodLiteral<"image">;
10
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
11
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
12
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
13
+ detail: z.ZodDefault<z.ZodEnum<{
14
+ auto: "auto";
15
+ low: "low";
16
+ high: "high";
17
+ }>>;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ type: z.ZodLiteral<"file">;
20
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
21
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
22
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
23
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
24
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
25
+ }, z.core.$strip>], "type">>>;
26
+ is_error: z.ZodDefault<z.ZodBoolean>;
27
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
28
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
29
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
30
+ }, z.core.$strip>;
31
+ export type ToolResultPayload = z.infer<typeof ToolResultPayloadSchema>;
32
+ /** A payload as a tool writes one: `is_error`, `notes` and `metadata` may be left out. */
33
+ export type ToolResultPayloadInput = z.input<typeof ToolResultPayloadSchema>;
34
+ export declare const ToolResultSchema: z.ZodObject<{
35
+ output: z.ZodString;
36
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
37
+ type: z.ZodLiteral<"text">;
38
+ text: z.ZodString;
39
+ }, z.core.$strip>, z.ZodObject<{
40
+ type: z.ZodLiteral<"image">;
41
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
42
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
43
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
44
+ detail: z.ZodDefault<z.ZodEnum<{
45
+ auto: "auto";
46
+ low: "low";
47
+ high: "high";
48
+ }>>;
49
+ }, z.core.$strip>, z.ZodObject<{
50
+ type: z.ZodLiteral<"file">;
51
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
52
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
53
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
54
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
55
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
56
+ }, z.core.$strip>], "type">>>;
57
+ is_error: z.ZodDefault<z.ZodBoolean>;
58
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
59
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
61
+ call_id: z.ZodString;
62
+ name: z.ZodString;
63
+ }, z.core.$strip>;
64
+ export type ToolResult = z.infer<typeof ToolResultSchema>;
65
+ export declare function toolResultMessageContent(result: ToolResult): ContentPart[];
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The plugin-authoring kit: what a plugin imports beside `@leuduan/cordis`.
3
+ *
4
+ * Registering a tool, an agent or a prompt contribution; granting a tool; defining, mounting and
5
+ * validating the configuration of a preset (`definePreset`, `mountPreset`, `parsePresetConfig`), and
6
+ * handing one down to the children a thread's calls create (`handDown`);
7
+ * defining a durable `ext` event, writing it beside a send or a creation (`WriteRows`), and reading what a thread was
8
+ * told; defining a set of durable modes (`defineModes`); adding a typed value to every thread's catalog entry (`defineContribution`); claiming a thread for one plugin, refusing a mount in a thread's scope (`requireUnscoped`)
9
+ * and refusing a missing root service (`requireService`); running a process, reading paths and git as
10
+ * the shipped tools do (`sys/`);
11
+ * the contracts a tool and a step hook implement; and the `ctx.*` service types every plugin reads.
12
+ * A value lives on one door: the application API is the root entry point, the model contracts are
13
+ * `@leuduan/lagent/llm`, the serialized shapes (`JournalEvent`, `Seq`, `ToolResult`, `stepContribution`,
14
+ * `toJsonSchema`) are `@leuduan/lagent/models`.
15
+ */
16
+ export * from './context.js';
17
+ export { defineTool, errorResult, provideTool } from './kit/tool.js';
18
+ export type { JsonSchemaParameters, ToolDefinition, ToolReply } from './kit/tool.js';
19
+ export { grantTool } from './kit/grants.js';
20
+ export { drainBeforeUnload } from './kit/drain.js';
21
+ export { defineModes } from './kit/modes.js';
22
+ export type { Modes, ModesDefinition } from './kit/modes.js';
23
+ export { AgentSelectorSchema, isScopedAgentName, requireUnscoped, selects } from './kit/scope.js';
24
+ export { requireService } from './kit/service.js';
25
+ export type { AgentSelector } from './kit/scope.js';
26
+ export { registerAgent } from './services/agents.js';
27
+ export { definePreset, mountPreset, parsePresetConfig } from './services/preset.js';
28
+ export type { Preset, PresetInstallation, PresetMountOptions, PresetPlace, PresetPlacement, PresetSelection, } from './services/preset.js';
29
+ export { handDown } from './services/presets.js';
30
+ export type { HandDown } from './services/presets.js';
31
+ export type { AgentDefinition, AgentDefinitionInput } from './models/index.js';
32
+ export { contributePrompt } from './services/prompts.js';
33
+ export { defineContribution } from './services/contributions.js';
34
+ export type { ContributionDefinition, ContributionReading } from './services/contributions.js';
35
+ export type { PromptContribution, PromptRenderInput, PromptSlot } from './services/prompts.js';
36
+ export { ExtensionVersionError, defineExtensionEvent, latestNotice, latestVisible, tellOnStep, } from './kit/extension.js';
37
+ export type { NoticeEvent, StepNotice, ToldNotice, ToldNotices } from './kit/extension.js';
38
+ export { ProjectionFailedError, projection } from './journal/index.js';
39
+ export type { AppendOptions, Committed, PluginJournal, PluginProjection, Transaction } from './journal/index.js';
40
+ export type { CallerChain, OriginBreak, OriginOpening, Origins, RequiredOwner, RequiredOwners, } from './journal/index.js';
41
+ export type { BirthSpec, ForkOpening, FreshOpening, Refusal, RowsResult, RowsWrite, WriteRows } from './loop/index.js';
42
+ export { isWaitRequest, lastAssistantMessage, waitFor } from './loop/index.js';
43
+ export { provideStrategy } from './kit/strategy.js';
44
+ export type { AuxiliaryCall, AuxiliaryReply, InvocationContext, ModelRequestDraft, ModelStep, SentModelRequest, SentRequest, ReplacementInput, StopVerdict, AuxiliaryAnswer, FinalPlan, SurfacePlan, SurfacePrepareInput, SurfaceStrategy, Tool, ToolAuthorizationRequest, ToolDenial, ToolEntry, ToolExecutionMode, ToolInvocation, ToolOutcome, ToolPolicyDecision, TurnStop, WaitRequest, ResolvedWait, } from './loop/index.js';
45
+ export { stableStringify } from './util/json.js';
46
+ export { claimThread } from './kit/claim.js';
47
+ export { systemClock, timerQueue } from './kit/timers.js';
48
+ export type { Clock, TimerQueue } from './kit/timers.js';
49
+ export { pathBoundary } from './sys/paths.js';
50
+ export type { BoundaryScope, PathAccess, PathBoundary } from './sys/paths.js';
51
+ export { runToCompletion, spawnCommand } from './sys/spawn.js';
52
+ export type { AppendEntry } from './journal/index.js';
53
+ export type { SpawnEnvironment, SpawnOptions, SpawnResult, SpawnStdio, SpawnedCommand, SpawnedGroup, SpawnedPipes, StopCause, } from './sys/spawn.js';
package/dist/plugin.js ADDED
@@ -0,0 +1 @@
1
+ import{a as F}from"./chunks/6ECI2GGV.js";import{a as T}from"./chunks/4XVRUSCQ.js";import{b as x,c as B}from"./chunks/SGGMBSBA.js";import{c as S}from"./chunks/3QCW4WDJ.js";import{b as N,d as R}from"./chunks/J5S4URAW.js";import{a as U}from"./chunks/SL2YLB2F.js";import{b as C}from"./chunks/RK3VP2Q4.js";import"./chunks/74HKUGRR.js";import{a as M}from"./chunks/QMMLQJBS.js";import{a as P}from"./chunks/YIR5MYGU.js";import{a as c,b as u,e as g}from"./chunks/L3N4FIEN.js";import{a as b,b as h}from"./chunks/NAOUTU7A.js";import"./chunks/UKXMCHHT.js";import{b as j}from"./chunks/CDQG7RKA.js";import{a as E}from"./chunks/G6RXC3AL.js";import{b as l,c as d}from"./chunks/DXFXAYDN.js";import{a as v,b as y,c as A,d as q,e as w}from"./chunks/DRYAN665.js";import{a as m,b as f,c as s,d as a}from"./chunks/2OSESBIL.js";import{R as t,ia as i,ja as n,ka as p}from"./chunks/YLNJXQ3Z.js";import"./chunks/DDANMY45.js";import{d as e,h as o,j as r}from"./chunks/37YOGDGY.js";import"./chunks/KESCTXGO.js";import"./chunks/TYTQRLTX.js";import"./chunks/D7E6EWIE.js";export{m as AgentSelectorSchema,v as ExtensionVersionError,r as ProjectionFailedError,F as claimThread,C as contributePrompt,U as defineContribution,y as defineExtensionEvent,j as defineModes,c as definePreset,b as defineTool,P as drainBeforeUnload,p as errorResult,B as grantTool,S as handDown,s as isScopedAgentName,n as isWaitRequest,t as lastAssistantMessage,A as latestNotice,q as latestVisible,u as mountPreset,g as parsePresetConfig,E as pathBoundary,o as projection,T as provideStrategy,h as provideTool,x as registerAgent,M as requireService,a as requireUnscoped,d as runToCompletion,f as selects,l as spawnCommand,e as stableStringify,N as systemClock,w as tellOnStep,R as timerQueue,i as waitFor};
@@ -0,0 +1,76 @@
1
+ import { type Context } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Where a thread's instructions are found and how much of them it is told: the agents-md preset's
5
+ * whole configuration, and the plugin form's besides its selector. All depend on the host, so none
6
+ * has a default here.
7
+ */
8
+ export declare const AgentsMdDiscoverySchema: z.ZodObject<{
9
+ fileNames: z.ZodArray<z.ZodString>;
10
+ rootMarkers: z.ZodArray<z.ZodString>;
11
+ maxBytes: z.ZodNumber;
12
+ }, z.core.$strict>;
13
+ export type AgentsMdDiscovery = z.output<typeof AgentsMdDiscoverySchema>;
14
+ /** The preset's id, which `codexPreset` hands down. */
15
+ export declare const AGENTS_MD_PRESET = "agents-md";
16
+ /** The installation id the preset hands itself down under, so a child holds one and passes it on. */
17
+ export declare const AGENTS_MD_INSTALLATION = "agents-md";
18
+ /** Where instructions are found, and who tells them, as a refusal of a second briefing names it. */
19
+ export type Briefing = AgentsMdDiscovery & {
20
+ readonly holder: string;
21
+ };
22
+ /**
23
+ * Tells the thread whose scope the calling plugin is mounted in its instructions, for as long as
24
+ * that plugin lives; the plugin injects `journal` and `threadDirs`. The one implementation behind
25
+ * both forms, and what `codexPreset` mounts on its own thread. Only that thread's steps reach a
26
+ * listener in its scope, so the briefing needs no thread id or selector.
27
+ *
28
+ * It claims the thread's scope first, so a second briefing on the thread is refused, naming
29
+ * `holder`'s, and tells the thread at the first model step at which no notice found with the same
30
+ * discovery settings is the latest recorded: the files, or that none was found, as one recorded
31
+ * notice with those settings. Every later step under the same settings works from that record, so
32
+ * the files are never read again for them, a reopen or a retried call repeats nothing, and a fork
33
+ * inherits what its source was told; a briefing with other settings, such as an installation that
34
+ * replaced the first, finds and tells the files anew.
35
+ */
36
+ export declare function tellAgentsMd(ctx: Context, briefing: Briefing): void;
37
+ /**
38
+ * Tells a thread the instructions files from its project root down to its `cwd`, once, as a
39
+ * conversation message: on the first model step at which nothing of the kind is recorded for the
40
+ * thread, it finds the project root, the nearest directory at or above the `cwd` holding one of
41
+ * `rootMarkers` without leaving what the thread may read (its `cwd` and read roots), else the `cwd`
42
+ * itself; in each directory from there down to the `cwd` it reads the first of `fileNames` that
43
+ * exists and is not empty, root first, at most `maxBytes` of them all; and it records what it told,
44
+ * "none found" included, with those settings. A thread is never told twice under the same settings:
45
+ * every later step, a reopened journal and a retried call work from that record, and edits made
46
+ * while the thread lives are not told; the agent can read the files with its tools, since every
47
+ * file told is inside what it may read. A conversation already under way is told at its next step,
48
+ * and so is one whose briefing now has other settings than its latest notice recorded.
49
+ *
50
+ * The notice states how the files apply: each governs its directory's tree, the deeper wins on a
51
+ * conflict, direct instructions beat any file, and files below the `cwd` are the agent's to look
52
+ * for when it works there.
53
+ *
54
+ * The notice is recorded text, so once a replacement takes it off the surface it is told again as
55
+ * recorded: a copy of the notice row's content, under the same source, never a fresh read of the
56
+ * file, so a compaction is not the moment an edit gets told.
57
+ *
58
+ * Not a prompt section: `rebuildPrompt()` would pick up an edited file and change the thread's
59
+ * instructions with nothing in history saying when. A file that cannot be read is logged and
60
+ * skipped rather than failing the step, since an optional file must not block a thread.
61
+ *
62
+ * A thread has one briefing: a second, from another mount or installation, is refused when the
63
+ * thread activates, naming the first.
64
+ *
65
+ * Two placements. Installed on a thread, it tells that thread and hands itself down with the same
66
+ * settings under {@link AGENTS_MD_INSTALLATION}, so a child is born with it, and its children in
67
+ * turn; register it at startup, where a reopened child restores it whether or not its parent is
68
+ * live. Mounted on the root for an agent selector,
69
+ * `mountPreset(root, agentsMdPreset, discovery, { agents })`, it tells each activation whose agent
70
+ * the selector picks, and hands nothing down. Its configuration is only the discovery settings.
71
+ */
72
+ export declare const agentsMdPreset: import("../services/preset.js").Preset<z.ZodObject<{
73
+ fileNames: z.ZodArray<z.ZodString>;
74
+ rootMarkers: z.ZodArray<z.ZodString>;
75
+ maxBytes: z.ZodNumber;
76
+ }, z.core.$strict>>;
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"../chunks/P5ZHHOOM.js";import"../chunks/6ECI2GGV.js";import"../chunks/OVZFGILJ.js";import"../chunks/3QCW4WDJ.js";import"../chunks/74HKUGRR.js";import"../chunks/L3N4FIEN.js";import"../chunks/PUSUPTAT.js";import"../chunks/G6RXC3AL.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 AGENTS_MD_INSTALLATION,b as AGENTS_MD_PRESET,a as AgentsMdDiscoverySchema,e as agentsMdPreset,d as tellAgentsMd};
@@ -0,0 +1,9 @@
1
+ import type { Tool } from '../../loop/index.js';
2
+ /**
3
+ * Asks the user a question through the ask service (`ctx.ask`): the call suspends on a durable wait,
4
+ * its run gives up its slot, and the call runs again once the question resolves. It is then
5
+ * answered with the person's answer, or, past the host's deadline, told to go on without it, which
6
+ * is no error and conveys no approval. A cancel answers the call itself, so it never runs again.
7
+ * Offered as `name`, `ask_question` unless the plugin renames it.
8
+ */
9
+ export declare const askQuestionTool: (name: string) => Tool;
@@ -0,0 +1,26 @@
1
+ import type { Plugin } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type AskServiceConfig } from './service.js';
4
+ /**
5
+ * The questions agents ask the user, through the `ctx.ask` service it mounts: each is a durable wait
6
+ * the host lists with `open(threadId)` and answers with `answer({ threadId, callSeq }, text)`, which
7
+ * survives a reload and a restart. Its configuration is required: `deadlineMs`, how long a question
8
+ * waits before the agent is told to go on without it (`null` for no deadline), and the `clock` it is
9
+ * kept on.
10
+ *
11
+ * Root-only, mounted once by the application, before the presets that mount {@link askQuestion}.
12
+ * The worked example is in the plugin guide (`docs/plugins.md`, Run constraints).
13
+ */
14
+ export declare const ask: Plugin.Object<AskServiceConfig>;
15
+ declare const AskQuestionConfigSchema: z.ZodObject<{
16
+ name: z.ZodDefault<z.ZodString>;
17
+ agents: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodLiteral<"global">, z.ZodLiteral<"all">]>;
18
+ }, z.core.$strip>;
19
+ export type AskQuestionConfig = z.input<typeof AskQuestionConfigSchema>;
20
+ /**
21
+ * Lets agents ask the user questions: the `ask_question` tool, for the agents `agents` selects.
22
+ * Mounted where a preset grants it; refuses to mount without the {@link ask} service.
23
+ */
24
+ export declare const askQuestion: Plugin.Object<AskQuestionConfig>;
25
+ export { ASK_OWNER, QuestionAnsweredError, QuestionClosedError } from './service.js';
26
+ export type { AskService, AskServiceConfig, OpenQuestion } from './service.js';
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"../../chunks/UCTEU62F.js";import"../../chunks/C5LYCXJG.js";import"../../chunks/J5S4URAW.js";import"../../chunks/QMMLQJBS.js";import"../../chunks/YIR5MYGU.js";import"../../chunks/NAOUTU7A.js";import"../../chunks/UKXMCHHT.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{a as ASK_OWNER,b as QuestionAnsweredError,c as QuestionClosedError,d as ask,e as askQuestion};
@@ -0,0 +1,125 @@
1
+ import { Service, type Context } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type InvocationContext, type ResolvedWait, type WaitRequest } from '../../loop/index.js';
4
+ import type { Seq } from '../../models/index.js';
5
+ declare module '@leuduan/cordis' {
6
+ interface Context {
7
+ /** The questions agents ask the user, and their answers (optional plugin). */
8
+ ask: AskService;
9
+ }
10
+ }
11
+ /** The owner a question's wait names. */
12
+ export declare const ASK_OWNER = "lagent:ask";
13
+ export declare const AskServiceConfigSchema: z.ZodObject<{
14
+ deadlineMs: z.ZodNullable<z.ZodNumber>;
15
+ clock: z.ZodCustom<import("../../kit/timers.js").Clock, import("../../kit/timers.js").Clock>;
16
+ }, z.core.$strict>;
17
+ export type AskServiceConfig = z.input<typeof AskServiceConfigSchema>;
18
+ declare const AskOptionSchema: z.ZodObject<{
19
+ id: z.ZodString;
20
+ label: z.ZodString;
21
+ description: z.ZodString;
22
+ }, z.core.$strict>;
23
+ /** One predefined answer. The user may always reply freely instead. */
24
+ export type AskOption = z.output<typeof AskOptionSchema>;
25
+ /** How a question resolved, versioned by ask: the person's answer, or its deadline passing. */
26
+ declare const QuestionValueSchema: z.ZodUnion<readonly [z.ZodObject<{
27
+ v: z.ZodLiteral<1>;
28
+ answer: z.ZodString;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ v: z.ZodLiteral<1>;
31
+ timeout: z.ZodLiteral<true>;
32
+ }, z.core.$strict>]>;
33
+ export type QuestionValue = z.output<typeof QuestionValueSchema>;
34
+ /** A question waiting for its answer, from the asking thread's rows. */
35
+ export type OpenQuestion = {
36
+ readonly threadId: string;
37
+ /** The asking call's `tool/call` row: the question's identity. */
38
+ readonly callSeq: Seq;
39
+ readonly question: string;
40
+ readonly options: readonly AskOption[] | null;
41
+ readonly agent: string;
42
+ readonly deadlineAt: number | null;
43
+ };
44
+ /** An answer to a question that already has one, recorded first: a person's answer, or its timeout. */
45
+ export declare class QuestionAnsweredError extends Error {
46
+ readonly threadId: string;
47
+ readonly callSeq: Seq;
48
+ readonly recorded: QuestionValue;
49
+ constructor(threadId: string, callSeq: Seq, recorded: QuestionValue);
50
+ }
51
+ /** An answer to a question that is not open: its call was answered without one, or it was never asked. */
52
+ export declare class QuestionClosedError extends Error {
53
+ readonly threadId: string;
54
+ readonly callSeq: Seq;
55
+ constructor(threadId: string, callSeq: Seq);
56
+ }
57
+ /** What a resolved question's call is answered with: what it asked, and how it resolved. */
58
+ export declare function questionAnswer(wait: ResolvedWait): {
59
+ readonly question: string;
60
+ readonly value: QuestionValue;
61
+ };
62
+ /**
63
+ * The questions agents ask the user. A question is a durable wait under {@link ASK_OWNER}: the
64
+ * asking call suspends, its run gives up its slot and the thread is held `wait` until the answer, the
65
+ * deadline or a cancel, across restarts too. Core owns the suspension and the redispatch; this owns
66
+ * the question's content, its deadline and answer-once.
67
+ *
68
+ * Deadlines are kept on one timer queue: armed as a question is declared, and at startup from the
69
+ * catalog, where one that passed while the process was down times out in the repair. A recorded
70
+ * deadline is honoured whatever `deadlineMs` says now. At the chain limit a question is asked with
71
+ * no deadline, since a timeout opens a reactive turn.
72
+ */
73
+ export declare class AskService extends Service<AskServiceConfig> {
74
+ static inject: string[];
75
+ readonly config: z.output<typeof AskServiceConfigSchema>;
76
+ private readonly deadlines;
77
+ private handle;
78
+ /** Timeouts being written, which shutdown lets land. */
79
+ private readonly timingOut;
80
+ /** Timeouts whose write failed, by question: each is tried again, later. */
81
+ private readonly retries;
82
+ private closing;
83
+ constructor(ctx: Context, config: AskServiceConfig);
84
+ /** The wait a call asks `question` with, under the configured deadline. */
85
+ ask(context: InvocationContext, question: {
86
+ readonly question: string;
87
+ readonly options: AskOption[] | null;
88
+ }): WaitRequest;
89
+ /**
90
+ * The thread's open questions, in the order they were asked, from its rows. Synchronous, by a
91
+ * caller that holds the thread, as `ctx.threads.view` is; the catalog's `waits` under
92
+ * {@link ASK_OWNER} say which threads have one.
93
+ */
94
+ open(threadId: string): OpenQuestion[];
95
+ /**
96
+ * Answers the question of call `callSeq` on `threadId`, as a person: resolves once the answer is
97
+ * durable, and the asking call runs again with it. Refuses with {@link QuestionAnsweredError} when
98
+ * an answer or the deadline came first, and with {@link QuestionClosedError} when the question is
99
+ * not open.
100
+ */
101
+ answer(question: {
102
+ readonly threadId: string;
103
+ readonly callSeq: Seq;
104
+ }, text: string): Promise<void>;
105
+ private registration;
106
+ /** A question declared arms its deadline; one resolved, or whose call was answered, disarms it. */
107
+ private onRow;
108
+ private disarm;
109
+ private arm;
110
+ /**
111
+ * Closes a question at its deadline, unless an answer or a cancel came first. A write that fails is
112
+ * reported and tried again later, so the deadline is not lost with it.
113
+ */
114
+ private timeout;
115
+ /**
116
+ * The startup repair, from the catalog: every open question's deadline armed, and one that passed
117
+ * while the process was down timed out now. Resolves once those writes have landed, so the startup
118
+ * policy judges their causes. A timeout whose write failed is reported and tried again later, as at
119
+ * runtime, rather than failing the repair: a failed repair stays failed, and the retry recovers.
120
+ */
121
+ private repair;
122
+ /** Stops closing questions at their deadlines, which the next startup does, and lets those under way land. */
123
+ private shutdown;
124
+ }
125
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { Tool } from '../../loop/index.js';
2
+ import { type CommandsConfig } from './service.js';
3
+ export declare const startCommandTool: Tool;
4
+ /** `read_command_output`, reading within `config`'s output budget and wait cap. */
5
+ export declare const readCommandOutputTool: (config: CommandsConfig) => Tool;
6
+ export declare const listCommandsTool: Tool;
7
+ /** `stop_command`, reporting within `config`'s output budget. */
8
+ export declare const stopCommandTool: (config: CommandsConfig) => Tool;
@@ -0,0 +1,4 @@
1
+ import type { Tool } from '../../loop/index.js';
2
+ import { type CommandsConfig } from './service.js';
3
+ /** `run_command`: one shell command, run to completion under `config`. */
4
+ export declare const runCommandTool: (config: CommandsConfig) => Tool;
@@ -0,0 +1,40 @@
1
+ import type { Plugin } from '@leuduan/cordis';
2
+ import { type CommandsConfigInput } from './service.js';
3
+ export { commandRecords, commandRow, readCommandNotice } from './record.js';
4
+ export type { CommandEnded, CommandNotice, CommandRecord, CommandStarted } from './record.js';
5
+ export { commandWork } from './service.js';
6
+ export type { CommandInfo, CommandsConfigInput, CommandsService, CommandWork } from './service.js';
7
+ /** The tools `commands` registers, by name: the foreground one, then the four for background commands. */
8
+ export declare const COMMAND_TOOLS: readonly ["run_command", "start_command", "read_command_output", "list_commands", "stop_command"];
9
+ /**
10
+ * Shell commands: `run_command`, and background commands through `start_command`,
11
+ * `read_command_output`, `list_commands` and `stop_command`. Every command runs in a process group
12
+ * of its own (`sys/spawn`), so a timeout, a cancellation or a stop reaches everything it started,
13
+ * and nothing it started outlives lagent.
14
+ *
15
+ * All five tools are always registered; which agent may call which is a grant. An application that
16
+ * wants no background execution grants none of the four. A tool that starts a process must be held
17
+ * for confirmation wherever it is granted: `SAFE_WRITES_TOOLS` lists `run_command` and
18
+ * `start_command`.
19
+ *
20
+ * A background command started with `notify: "exit"` on a conversation with no caller wakes it with
21
+ * a notice when it exits on its own (`commandNotice`, which a host reads with `readCommandNotice`).
22
+ *
23
+ * Whether a thread's command work, or its subtree's, has ended has one answer, `commandWork`, from
24
+ * the threads' rows and what this process runs: a cleanup or a quiescence check reads it rather
25
+ * than the records. It holds whether or not this plugin is mounted: without it nothing drains, and
26
+ * a thread neither loaded nor carrying the plugin's catalog entry is unresolved.
27
+ *
28
+ * Every agent that may call `run_command` or `start_command` is told, in its prompt, what `/bin/sh`
29
+ * is on this system, read once at mount.
30
+ *
31
+ * Every command runs with exactly the `environment` the host configures, which nothing defaults:
32
+ * lagent passes on none of its own. Commands launch through `ctx.launches`, with the thread they serve,
33
+ * so a host that registers a launch handler, such as an OS sandbox, confines every `run_command` and
34
+ * `start_command` without this plugin knowing it. What the handler lets the model do is the
35
+ * handler's to tell, as a notice.
36
+ *
37
+ * Root-only: the background commands live on the `ctx.commands` service this mounts.
38
+ */
39
+ export declare const commands: Plugin.Object<CommandsConfigInput>;
40
+ export type { BackgroundCommand, CommandLookup, CommandsConfig, RecordedCommand, RecordedStatus } from './service.js';
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f}from"../../chunks/G74AGRAJ.js";import"../../chunks/SL2YLB2F.js";import"../../chunks/JPZFKSWT.js";import"../../chunks/RK3VP2Q4.js";import"../../chunks/74HKUGRR.js";import"../../chunks/QMMLQJBS.js";import"../../chunks/YIR5MYGU.js";import"../../chunks/NAOUTU7A.js";import"../../chunks/UKXMCHHT.js";import"../../chunks/GQGNVSKB.js";import"../../chunks/DXFXAYDN.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{e as COMMAND_TOOLS,b as commandRecords,a as commandRow,d as commandWork,f as commands,c as readCommandNotice};
@@ -0,0 +1,115 @@
1
+ import type { Readable } from 'node:stream';
2
+ import type { SpawnResult } from '../../sys/spawn.js';
3
+ /**
4
+ * A command's log, capped at `maxBytes` in two segments: `<id>.log`, the current one, and after a
5
+ * rotation `<id>.1.log`, the one before it. When the current segment reaches half the cap it
6
+ * replaces the older one, so the latest output is always kept.
7
+ *
8
+ * Written through one stream at a time and never awaited by a call: `write` returning `false` asks
9
+ * the caller to pause its source until `whenWritable()`, which also waits for every rotated
10
+ * segment to finish flushing. A failed write is reported once, and later output is dropped rather
11
+ * than held.
12
+ */
13
+ export declare class CommandLog {
14
+ readonly path: string;
15
+ readonly olderPath: string;
16
+ /** Logical bytes accepted since the command started. */
17
+ written: number;
18
+ /** Logical bytes no longer on disk. */
19
+ rotatedOut: number;
20
+ private stream;
21
+ /** Rotated streams that have not closed yet. */
22
+ private readonly flushing;
23
+ private segmentBytes;
24
+ private olderBytes;
25
+ private opened;
26
+ private failed;
27
+ private readonly maxBytes;
28
+ private readonly onError;
29
+ constructor(path: string, maxBytes: number, onError: (error: unknown) => void);
30
+ get rotated(): boolean;
31
+ /** Where the output is, and what rotation or a failed write removed from it. */
32
+ describe(): string;
33
+ /** `false` when the source should pause until {@link whenWritable}. */
34
+ write(chunk: Buffer): boolean;
35
+ whenWritable(): Promise<void>;
36
+ end(): void;
37
+ private needsDrain;
38
+ /**
39
+ * The file is opened synchronously and the stream writes to its descriptor, so a rename during a
40
+ * rotation never races an open, and writes still pending land in the segment they belong to.
41
+ * A re-dispatched command appends to its log after a separator line.
42
+ */
43
+ private open;
44
+ private rotate;
45
+ private fail;
46
+ }
47
+ export type CommandOutputOptions = {
48
+ /** Characters held for a result's head and for its tail; also the most one result shows. */
49
+ capacityChars: number;
50
+ openLog: () => CommandLog;
51
+ /** A background command logs from the start; a foreground one only once its output overflows. */
52
+ logFromStart: boolean;
53
+ };
54
+ /**
55
+ * One command's output: one pipe, in exact order, through one decoder, so a character split across
56
+ * chunks survives. Memory is bounded by a head and a tail of `capacityChars` each, plus one write
57
+ * buffer of the log; the log has the rest.
58
+ *
59
+ * Reads are relative to a mark. A foreground command's mark stays at the start; a background
60
+ * command's moves to the end of each read, so the next read shows only newer output.
61
+ */
62
+ export declare class CommandOutput {
63
+ private readonly decoder;
64
+ private log;
65
+ /** Raw output held until the log opens, so the log starts from the first byte. */
66
+ private pending;
67
+ private totalChars;
68
+ private markChars;
69
+ /** The first `capacityChars` since the mark, and whether that is everything since it. */
70
+ private sinceMark;
71
+ private sinceMarkComplete;
72
+ /** At least the last `capacityChars`, at most twice that. */
73
+ private recent;
74
+ private readonly listeners;
75
+ private finished;
76
+ private readonly options;
77
+ constructor(options: CommandOutputOptions);
78
+ /** The log's path once it exists. */
79
+ get logPath(): string | undefined;
80
+ get logDescription(): string | undefined;
81
+ get isFinished(): boolean;
82
+ get hasUnread(): boolean;
83
+ /** Reads `source` to its end, pausing it while the log's buffer is full. */
84
+ attach(source: Readable): void;
85
+ /** Adds text the command did not print, such as a launch handler's report; before {@link finish}. */
86
+ note(text: string): void;
87
+ /** Flushes the decoder and ends the log. Call once the command has settled. */
88
+ finish(): void;
89
+ /** Called on new output and on `finish`, after which `finished` holds; returns the unsubscribe function. */
90
+ onChange(listener: () => void): () => void;
91
+ /**
92
+ * Renders the output since the mark and then `trailer`, within `budget` characters. The trailer
93
+ * is laid out first and its length reserved, so no cut can remove it. What does not fit is cut
94
+ * from the middle, one part head to four parts tail, around the marker `omission` renders.
95
+ * `advance` moves the mark to the end, so what was skipped is not shown again.
96
+ */
97
+ render(options: {
98
+ budget: number;
99
+ trailer: readonly string[];
100
+ empty: string;
101
+ omission: (omittedChars: number, log: CommandLog) => string;
102
+ advance: boolean;
103
+ }): string;
104
+ private push;
105
+ private append;
106
+ private ensureLog;
107
+ private notify;
108
+ }
109
+ export declare const capitalize: (text: string) => string;
110
+ /** A duration as a person reads it: `850ms`, `12.4s`, `3m 12s`, `2h 5m`. */
111
+ export declare function formatDuration(ms: number): string;
112
+ /** How the command's leader ended: its exit code, its signal, or that it never exited. */
113
+ export declare function describeExit(result: SpawnResult): string;
114
+ /** The marker for a stop that could not be confirmed. */
115
+ export declare const stopFailedMarker: (graceSeconds: number) => string;