@leuduan/lagent 0.0.0-stage → 44.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +157 -2
  3. package/dist/chunks/2GCIWSOA.js +5 -0
  4. package/dist/chunks/2P47AHNK.js +7 -0
  5. package/dist/chunks/34KW6VNQ.js +1 -0
  6. package/dist/chunks/3UMZMPWW.js +1 -0
  7. package/dist/chunks/5IRF47YB.js +1 -0
  8. package/dist/chunks/6DRCKZ2C.js +1 -0
  9. package/dist/chunks/6FRNHMCV.js +1 -0
  10. package/dist/chunks/7LI64H5X.js +17 -0
  11. package/dist/chunks/7VAPNE3L.js +1 -0
  12. package/dist/chunks/ASSQZH3F.js +1 -0
  13. package/dist/chunks/B4FXK5ER.js +77 -0
  14. package/dist/chunks/BBCW2FZK.js +1 -0
  15. package/dist/chunks/BPRCULZH.js +1 -0
  16. package/dist/chunks/CANPZYTH.js +24 -0
  17. package/dist/chunks/CQEVREBT.js +1 -0
  18. package/dist/chunks/CUK7CGC7.js +1 -0
  19. package/dist/chunks/D4PQP5MA.js +3 -0
  20. package/dist/chunks/DDANMY45.js +3 -0
  21. package/dist/chunks/DDZ7YF26.js +1 -0
  22. package/dist/chunks/EMRB4KCN.js +6 -0
  23. package/dist/chunks/EPYQ5M3B.js +3 -0
  24. package/dist/chunks/FJLU4UH3.js +1 -0
  25. package/dist/chunks/G44LG6VL.js +1 -0
  26. package/dist/chunks/GGSVIIWJ.js +2 -0
  27. package/dist/chunks/HK6ZSONF.js +1 -0
  28. package/dist/chunks/IAAEP6VL.js +30 -0
  29. package/dist/chunks/JCTBX33H.js +36 -0
  30. package/dist/chunks/JFX2MXBA.js +4 -0
  31. package/dist/chunks/JFZZXVWD.js +15 -0
  32. package/dist/chunks/KUZCL2SH.js +1 -0
  33. package/dist/chunks/MHC6VPB4.js +7 -0
  34. package/dist/chunks/MMNNZCBO.js +5 -0
  35. package/dist/chunks/MNJ4SRF7.js +1 -0
  36. package/dist/chunks/N6IXG2VL.js +1 -0
  37. package/dist/chunks/OCBPT7KE.js +1 -0
  38. package/dist/chunks/OL5A6ITQ.js +1 -0
  39. package/dist/chunks/PUSUPTAT.js +1 -0
  40. package/dist/chunks/Q75FUN7D.js +2 -0
  41. package/dist/chunks/Q7S5LFGN.js +1 -0
  42. package/dist/chunks/RCIHV3KG.js +1 -0
  43. package/dist/chunks/S34ZA2R6.js +1 -0
  44. package/dist/chunks/SS3B5W34.js +12 -0
  45. package/dist/chunks/VYMT4TXD.js +1 -0
  46. package/dist/chunks/W57RW55W.js +1 -0
  47. package/dist/compositions/base.d.ts +11 -0
  48. package/dist/compositions/codex.d.ts +66 -0
  49. package/dist/compositions/codexPrompts.d.ts +56 -0
  50. package/dist/context.d.ts +109 -0
  51. package/dist/index.d.ts +55 -0
  52. package/dist/index.js +1 -0
  53. package/dist/journal/catalog.d.ts +112 -0
  54. package/dist/journal/forkChain.d.ts +16 -0
  55. package/dist/journal/index.d.ts +15 -0
  56. package/dist/journal/journal.d.ts +475 -0
  57. package/dist/journal/projection.d.ts +87 -0
  58. package/dist/journal/store.d.ts +181 -0
  59. package/dist/llm/client.d.ts +135 -0
  60. package/dist/llm/content.d.ts +52 -0
  61. package/dist/llm/failure.d.ts +82 -0
  62. package/dist/llm/index.d.ts +22 -0
  63. package/dist/llm/index.js +1 -0
  64. package/dist/llm/primitives.d.ts +286 -0
  65. package/dist/llm/prompt.d.ts +21 -0
  66. package/dist/llm/provider.d.ts +74 -0
  67. package/dist/llm/readLedger.d.ts +24 -0
  68. package/dist/llm/request.d.ts +58 -0
  69. package/dist/loop/agent.d.ts +18 -0
  70. package/dist/loop/authorization.d.ts +41 -0
  71. package/dist/loop/auxiliary.d.ts +58 -0
  72. package/dist/loop/chunks.d.ts +27 -0
  73. package/dist/loop/completion.d.ts +17 -0
  74. package/dist/loop/errors.d.ts +139 -0
  75. package/dist/loop/hooks.d.ts +274 -0
  76. package/dist/loop/index.d.ts +16 -0
  77. package/dist/loop/runner.d.ts +134 -0
  78. package/dist/loop/runtime.d.ts +76 -0
  79. package/dist/loop/strategy.d.ts +80 -0
  80. package/dist/loop/surfacePrepare.d.ts +30 -0
  81. package/dist/loop/tool.d.ts +106 -0
  82. package/dist/loop/toolCalls.d.ts +35 -0
  83. package/dist/plugin.d.ts +50 -0
  84. package/dist/plugin.js +1 -0
  85. package/dist/plugins/agentsMd.d.ts +80 -0
  86. package/dist/plugins/agentsMd.js +1 -0
  87. package/dist/plugins/ask/index.d.ts +26 -0
  88. package/dist/plugins/ask/index.js +1 -0
  89. package/dist/plugins/ask/service.d.ts +125 -0
  90. package/dist/plugins/ask/tools.d.ts +9 -0
  91. package/dist/plugins/commands/index.d.ts +43 -0
  92. package/dist/plugins/commands/index.js +1 -0
  93. package/dist/plugins/commands/output.d.ts +115 -0
  94. package/dist/plugins/commands/record.d.ts +558 -0
  95. package/dist/plugins/commands/service.d.ts +321 -0
  96. package/dist/plugins/commands/shell.d.ts +25 -0
  97. package/dist/plugins/commands/tools.d.ts +10 -0
  98. package/dist/plugins/compaction/checkpoint.d.ts +94 -0
  99. package/dist/plugins/compaction/config.d.ts +133 -0
  100. package/dist/plugins/compaction/estimate.d.ts +37 -0
  101. package/dist/plugins/compaction/index.d.ts +87 -0
  102. package/dist/plugins/compaction/index.js +7 -0
  103. package/dist/plugins/compaction/planner.d.ts +207 -0
  104. package/dist/plugins/compaction/prune.d.ts +9 -0
  105. package/dist/plugins/compaction/record.d.ts +227 -0
  106. package/dist/plugins/compaction/segments.d.ts +23 -0
  107. package/dist/plugins/compaction/state.d.ts +68 -0
  108. package/dist/plugins/compaction/summarize.d.ts +13 -0
  109. package/dist/plugins/dateAndBranch.d.ts +47 -0
  110. package/dist/plugins/dateAndBranch.js +1 -0
  111. package/dist/plugins/delegations/answers.d.ts +39 -0
  112. package/dist/plugins/delegations/assignmentKey.d.ts +22 -0
  113. package/dist/plugins/delegations/cleanup.d.ts +161 -0
  114. package/dist/plugins/delegations/constraint.d.ts +76 -0
  115. package/dist/plugins/delegations/index.d.ts +39 -0
  116. package/dist/plugins/delegations/index.js +1 -0
  117. package/dist/plugins/delegations/notices.d.ts +261 -0
  118. package/dist/plugins/delegations/obligations.d.ts +210 -0
  119. package/dist/plugins/delegations/record.d.ts +633 -0
  120. package/dist/plugins/delegations/request.d.ts +384 -0
  121. package/dist/plugins/delegations/role.d.ts +30 -0
  122. package/dist/plugins/delegations/service.d.ts +563 -0
  123. package/dist/plugins/delegations/standing.d.ts +19 -0
  124. package/dist/plugins/delegations/stopCheck.d.ts +21 -0
  125. package/dist/plugins/delegations/tools.d.ts +71 -0
  126. package/dist/plugins/delegations/waitContracts.d.ts +118 -0
  127. package/dist/plugins/delegations/waitResolver.d.ts +116 -0
  128. package/dist/plugins/diagnostics/digest.d.ts +14 -0
  129. package/dist/plugins/diagnostics/index.d.ts +68 -0
  130. package/dist/plugins/diagnostics/index.js +1 -0
  131. package/dist/plugins/fileTools/config.d.ts +10 -0
  132. package/dist/plugins/fileTools/editFiles.d.ts +117 -0
  133. package/dist/plugins/fileTools/fsRead.d.ts +17 -0
  134. package/dist/plugins/fileTools/gitDiscovery.d.ts +9 -0
  135. package/dist/plugins/fileTools/index.d.ts +18 -0
  136. package/dist/plugins/fileTools/index.js +1 -0
  137. package/dist/plugins/fileTools/ripgrep.d.ts +20 -0
  138. package/dist/plugins/fileTools/textEdit.d.ts +67 -0
  139. package/dist/plugins/fileTools/tools.d.ts +6 -0
  140. package/dist/plugins/historyRecall/history.d.ts +9 -0
  141. package/dist/plugins/historyRecall/index.d.ts +31 -0
  142. package/dist/plugins/historyRecall/index.js +1 -0
  143. package/dist/plugins/historyRecall/render.d.ts +34 -0
  144. package/dist/plugins/historyRecall/tools.d.ts +4 -0
  145. package/dist/plugins/mcp/catalog.d.ts +36 -0
  146. package/dist/plugins/mcp/config.d.ts +63 -0
  147. package/dist/plugins/mcp/connection.d.ts +53 -0
  148. package/dist/plugins/mcp/errors.d.ts +32 -0
  149. package/dist/plugins/mcp/index.d.ts +33 -0
  150. package/dist/plugins/mcp/index.js +5 -0
  151. package/dist/plugins/mcp/mount.d.ts +98 -0
  152. package/dist/plugins/mcp/names.d.ts +25 -0
  153. package/dist/plugins/mcp/render.d.ts +29 -0
  154. package/dist/plugins/mcp/slots.d.ts +15 -0
  155. package/dist/plugins/mcp/stdio.d.ts +49 -0
  156. package/dist/plugins/mcp/tools.d.ts +41 -0
  157. package/dist/plugins/mcp/version.d.ts +2 -0
  158. package/dist/plugins/routeNotice.d.ts +22 -0
  159. package/dist/plugins/routeNotice.js +1 -0
  160. package/dist/plugins/sandbox/absent.d.ts +33 -0
  161. package/dist/plugins/sandbox/client.d.ts +39 -0
  162. package/dist/plugins/sandbox/files.d.ts +28 -0
  163. package/dist/plugins/sandbox/index.d.ts +52 -0
  164. package/dist/plugins/sandbox/index.js +4 -0
  165. package/dist/plugins/sandbox/mode.d.ts +57 -0
  166. package/dist/plugins/sandbox/policy.d.ts +163 -0
  167. package/dist/plugins/sandbox/protocol.d.ts +107 -0
  168. package/dist/plugins/sandbox/service.d.ts +153 -0
  169. package/dist/plugins/sandbox/worker.d.ts +12 -0
  170. package/dist/plugins/sandbox/worker.js +1 -0
  171. package/dist/plugins/schedules/index.d.ts +21 -0
  172. package/dist/plugins/schedules/index.js +5 -0
  173. package/dist/plugins/schedules/record.d.ts +396 -0
  174. package/dist/plugins/schedules/service.d.ts +120 -0
  175. package/dist/plugins/schedules/time.d.ts +26 -0
  176. package/dist/plugins/schedules/tools.d.ts +6 -0
  177. package/dist/plugins/skills/discovery.d.ts +83 -0
  178. package/dist/plugins/skills/index.d.ts +31 -0
  179. package/dist/plugins/skills/index.js +1 -0
  180. package/dist/plugins/skills/tools.d.ts +11 -0
  181. package/dist/plugins/subAgents/availableRoutes.d.ts +53 -0
  182. package/dist/plugins/subAgents/index.d.ts +67 -0
  183. package/dist/plugins/subAgents/index.js +1 -0
  184. package/dist/plugins/subAgents/tools.d.ts +67 -0
  185. package/dist/plugins/threadDirs.d.ts +36 -0
  186. package/dist/plugins/threadDirs.js +1 -0
  187. package/dist/plugins/toolPolicy/index.d.ts +61 -0
  188. package/dist/plugins/toolPolicy/index.js +1 -0
  189. package/dist/plugins/truncateToolOutput.d.ts +30 -0
  190. package/dist/plugins/truncateToolOutput.js +6 -0
  191. package/dist/plugins/usage/index.d.ts +26 -0
  192. package/dist/plugins/usage/index.js +1 -0
  193. package/dist/plugins/usage/tracker.d.ts +34 -0
  194. package/dist/plugins/verify/index.d.ts +27 -0
  195. package/dist/plugins/verify/index.js +6 -0
  196. package/dist/plugins/verify/judgement.d.ts +16 -0
  197. package/dist/plugins/verify/record.d.ts +382 -0
  198. package/dist/plugins/verify/service.d.ts +93 -0
  199. package/dist/plugins/verify/state.d.ts +58 -0
  200. package/dist/plugins/webTools/html.d.ts +23 -0
  201. package/dist/plugins/webTools/index.d.ts +34 -0
  202. package/dist/plugins/webTools/index.js +1 -0
  203. package/dist/plugins/webTools/network.d.ts +23 -0
  204. package/dist/plugins/webTools/web.d.ts +32 -0
  205. package/dist/plugins/workflows/assignment.d.ts +20 -0
  206. package/dist/plugins/workflows/cleanup.d.ts +38 -0
  207. package/dist/plugins/workflows/definition.d.ts +184 -0
  208. package/dist/plugins/workflows/entryPlan.d.ts +95 -0
  209. package/dist/plugins/workflows/hostBindings.d.ts +146 -0
  210. package/dist/plugins/workflows/index.d.ts +28 -0
  211. package/dist/plugins/workflows/index.js +11 -0
  212. package/dist/plugins/workflows/observations.d.ts +81 -0
  213. package/dist/plugins/workflows/participantModels.d.ts +28 -0
  214. package/dist/plugins/workflows/participants.d.ts +143 -0
  215. package/dist/plugins/workflows/policy.d.ts +112 -0
  216. package/dist/plugins/workflows/record.d.ts +2849 -0
  217. package/dist/plugins/workflows/routing.d.ts +116 -0
  218. package/dist/plugins/workflows/schema.d.ts +26 -0
  219. package/dist/plugins/workflows/service.d.ts +477 -0
  220. package/dist/plugins/workflows/state.d.ts +373 -0
  221. package/dist/plugins/workflows/stopCheck.d.ts +13 -0
  222. package/dist/plugins/workflows/tools.d.ts +13 -0
  223. package/dist/plugins/workflows/view.d.ts +103 -0
  224. package/dist/plugins/workflows/workStatus.d.ts +21 -0
  225. package/dist/plugins/workspaceNotice.d.ts +36 -0
  226. package/dist/plugins/workspaceNotice.js +1 -0
  227. package/dist/providers/anthropic.d.ts +178 -0
  228. package/dist/providers/anthropicMessages.d.ts +66 -0
  229. package/dist/providers/codex.d.ts +71 -0
  230. package/dist/providers/codexAuth.d.ts +116 -0
  231. package/dist/providers/deepseek.d.ts +59 -0
  232. package/dist/providers/failure.d.ts +23 -0
  233. package/dist/providers/gateway.d.ts +24 -0
  234. package/dist/providers/index.d.ts +18 -0
  235. package/dist/providers/index.js +6 -0
  236. package/dist/providers/openaiChat.d.ts +73 -0
  237. package/dist/providers/openaiResponses.d.ts +109 -0
  238. package/dist/providers/opencodeCopilot.d.ts +23 -0
  239. package/dist/providers/opencodeGo.d.ts +109 -0
  240. package/dist/providers/shared.d.ts +112 -0
  241. package/dist/providers/stream.d.ts +156 -0
  242. package/dist/records/index.d.ts +13 -0
  243. package/dist/records/index.js +1 -0
  244. package/dist/records/journal.d.ts +2968 -0
  245. package/dist/records/toolResult.d.ts +65 -0
  246. package/dist/services/agents.d.ts +62 -0
  247. package/dist/services/catalogContributions.d.ts +73 -0
  248. package/dist/services/confinement/files.d.ts +118 -0
  249. package/dist/services/confinement/service.d.ts +219 -0
  250. package/dist/services/core.d.ts +28 -0
  251. package/dist/services/extensionEvents.d.ts +181 -0
  252. package/dist/services/journal.d.ts +26 -0
  253. package/dist/services/llm.d.ts +82 -0
  254. package/dist/services/modes.d.ts +65 -0
  255. package/dist/services/plugins.d.ts +34 -0
  256. package/dist/services/presets/definition.d.ts +154 -0
  257. package/dist/services/presets/installations.d.ts +139 -0
  258. package/dist/services/prompts.d.ts +85 -0
  259. package/dist/services/threads/activation.d.ts +100 -0
  260. package/dist/services/threads/admission.d.ts +174 -0
  261. package/dist/services/threads/birth.d.ts +219 -0
  262. package/dist/services/threads/index.d.ts +14 -0
  263. package/dist/services/threads/runEvents.d.ts +79 -0
  264. package/dist/services/threads/runOwner.d.ts +368 -0
  265. package/dist/services/threads/service.d.ts +450 -0
  266. package/dist/services/threads/thread.d.ts +268 -0
  267. package/dist/services/threads/view.d.ts +93 -0
  268. package/dist/services/tools.d.ts +118 -0
  269. package/dist/state/birth.d.ts +62 -0
  270. package/dist/state/chain.d.ts +46 -0
  271. package/dist/state/confirmations.d.ts +64 -0
  272. package/dist/state/continuation.d.ts +167 -0
  273. package/dist/state/decide.d.ts +72 -0
  274. package/dist/state/dispatches.d.ts +54 -0
  275. package/dist/state/errors.d.ts +26 -0
  276. package/dist/state/forks.d.ts +61 -0
  277. package/dist/state/holds.d.ts +104 -0
  278. package/dist/state/inbox.d.ts +188 -0
  279. package/dist/state/index.d.ts +31 -0
  280. package/dist/state/inputs.d.ts +58 -0
  281. package/dist/state/installations.d.ts +28 -0
  282. package/dist/state/limits.d.ts +14 -0
  283. package/dist/state/prompt.d.ts +13 -0
  284. package/dist/state/recovery.d.ts +7 -0
  285. package/dist/state/replace.d.ts +33 -0
  286. package/dist/state/requests.d.ts +129 -0
  287. package/dist/state/route.d.ts +61 -0
  288. package/dist/state/summary.d.ts +16 -0
  289. package/dist/state/surface.d.ts +153 -0
  290. package/dist/state/surfaceRead.d.ts +20 -0
  291. package/dist/state/thread.d.ts +73 -0
  292. package/dist/state/turns.d.ts +87 -0
  293. package/dist/state/waits.d.ts +38 -0
  294. package/dist/state/wake.d.ts +32 -0
  295. package/dist/stores/durableObject.d.ts +23 -0
  296. package/dist/stores/durableObject.js +1 -0
  297. package/dist/stores/durableObjectConnection.d.ts +27 -0
  298. package/dist/stores/memory.d.ts +29 -0
  299. package/dist/stores/sql.d.ts +59 -0
  300. package/dist/stores/sqlite.d.ts +31 -0
  301. package/dist/stores/sqlite.js +1 -0
  302. package/dist/sys/environment.d.ts +42 -0
  303. package/dist/sys/git.d.ts +47 -0
  304. package/dist/sys/paths.d.ts +9 -0
  305. package/dist/sys/spawn.d.ts +186 -0
  306. package/dist/testing/clock.d.ts +17 -0
  307. package/dist/testing/fakeLlm.d.ts +76 -0
  308. package/dist/testing/fedLlm.d.ts +34 -0
  309. package/dist/testing/helpers.d.ts +362 -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/settlement.d.ts +6 -0
  314. package/dist/testing/tmpDirs.d.ts +17 -0
  315. package/dist/util/async.d.ts +8 -0
  316. package/dist/util/diff.d.ts +25 -0
  317. package/dist/util/dispatch.d.ts +8 -0
  318. package/dist/util/errors.d.ts +28 -0
  319. package/dist/util/foldState.d.ts +17 -0
  320. package/dist/util/freeze.d.ts +2 -0
  321. package/dist/util/ids.d.ts +2 -0
  322. package/dist/util/json.d.ts +37 -0
  323. package/dist/util/jsonSchema.d.ts +7 -0
  324. package/dist/util/log.d.ts +6 -0
  325. package/dist/util/retries.d.ts +25 -0
  326. package/dist/util/text.d.ts +21 -0
  327. package/dist/util/timers.d.ts +43 -0
  328. package/package.json +183 -3
@@ -0,0 +1,71 @@
1
+ import { z } from 'zod';
2
+ export declare const LIST_AGENTS_TOOL = "list_agents";
3
+ export declare const READ_AGENT_TOOL = "read_agent";
4
+ export declare const STOP_AGENT_TOOL = "stop_agent";
5
+ /**
6
+ * The tools the `delegations` plugin registers, granted to nobody: continuing, listing, reading and
7
+ * stopping the children a thread started, whichever tool started them. A preset grants them wherever
8
+ * it grants a start tool.
9
+ */
10
+ export declare const DELEGATION_TOOLS: readonly ["message_agent", "list_agents", "read_agent", "stop_agent"];
11
+ /**
12
+ * Validates a `message_agent` call, and is the source of the schema advertised to the model: one
13
+ * object, whose `kind` says which of the two gestures the call is. `background` and the route fields
14
+ * belong to `continue`; a steer naming one is refused as invalid arguments.
15
+ */
16
+ export declare const MessageAgentParameters: z.ZodPreprocess<z.ZodObject<{
17
+ thread_id: z.ZodString;
18
+ kind: z.ZodEnum<{
19
+ continue: "continue";
20
+ steer: "steer";
21
+ }>;
22
+ message: z.ZodString;
23
+ background: z.ZodDefault<z.ZodBoolean>;
24
+ provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
25
+ model: z.ZodDefault<z.ZodNullable<z.ZodString>>;
26
+ thinking_effort: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
27
+ low: "low";
28
+ high: "high";
29
+ none: "none";
30
+ medium: "medium";
31
+ max: "max";
32
+ }>>>;
33
+ }, z.core.$strip>, unknown>;
34
+ /**
35
+ * Messages a child this thread created, whichever start tool made it; `kind` is required and kept
36
+ * across a re-dispatch, so a correction never becomes a new assignment.
37
+ *
38
+ * `continue` opens the child's next task, queued as plain input with the task's `started` row under
39
+ * an id derived from this call, and the child runs on its own history; blocking, it waits for the
40
+ * answer, and with `background` it returns a receipt. A fork is not framed as a fork task again.
41
+ * Refused without a turn when the id names no thread, a thread this one did not create, or a child
42
+ * that stopped mid-work or still has a task open; a child a run holds is refused busy. A
43
+ * re-dispatch returns the recorded answer, or the receipt, without judging the route again.
44
+ *
45
+ * `steer` queues a correction into the task the call addresses, by row order as `read_agent` and
46
+ * `stop_agent` do, while that task's own drive runs the child (`ctx.delegations.steer`), and returns
47
+ * at once; it is refused, naming the outcome, on a task that has ended, and naming the state on one
48
+ * nothing runs now, a child whose run has not started yet included: the call never waits for a run
49
+ * to start, since the caller's own run slot may be what that run waits for, and its model tries
50
+ * again later. A re-dispatch reports what became of the message it sent.
51
+ */
52
+ export declare const messageAgentTool: import("../../loop/tool.js").Tool;
53
+ /** `list_agents`: this thread's children, however they were started, from the catalog. */
54
+ export declare const listAgentsTool: import("../../loop/tool.js").Tool;
55
+ /**
56
+ * `read_agent`: each named child's addressed task, its state and, once it settled, its answer or
57
+ * its failure (a background task's only when its notice does not carry it, or with `full`), or
58
+ * before that its recent activity; and the child's status now. Waits through `ctx.delegations.read`,
59
+ * a durable wait that releases the caller's run slot, for any named task to settle, or with
60
+ * `activity` for any named child to record anything, until nothing can advance them or the time is
61
+ * up; dispatched again once that wait resolves, it reports where the tasks stand then.
62
+ */
63
+ export declare const readAgentTool: import("../../loop/tool.js").Tool;
64
+ /**
65
+ * `stop_agent`: stops the addressed task of a child this thread started, by `ctx.delegations.stop`
66
+ * with this call's seq, and returns once the stop is durable. A settled task keeps its outcome, and
67
+ * a late turn its run still runs is cut off; a newer task of the child is never touched. A rerun
68
+ * repeats its own reply: the `stopped` row names the call that wrote it. The reply also says what
69
+ * the child is doing now.
70
+ */
71
+ export declare const stopAgentTool: import("../../loop/tool.js").Tool;
@@ -0,0 +1,118 @@
1
+ import { z } from 'zod';
2
+ import type { ResolvedWait } from '../../loop/index.js';
3
+ import type { TaskRef } from './record.js';
4
+ import type { DelegationOutcome } from './request.js';
5
+ export declare const TaskWaitSchema: z.ZodObject<{
6
+ task_id: z.ZodString;
7
+ child_id: z.ZodString;
8
+ v: z.ZodLiteral<1>;
9
+ kind: z.ZodLiteral<"task">;
10
+ }, z.core.$strict>;
11
+ export type TaskWait = z.output<typeof TaskWaitSchema>;
12
+ export declare const ReadWaitSchema: z.ZodObject<{
13
+ v: z.ZodLiteral<1>;
14
+ kind: z.ZodLiteral<"read">;
15
+ tasks: z.ZodArray<z.ZodObject<{
16
+ task_id: z.ZodString;
17
+ child_id: z.ZodString;
18
+ }, z.core.$strict>>;
19
+ until: z.ZodEnum<{
20
+ settled: "settled";
21
+ activity: "activity";
22
+ }>;
23
+ since: z.ZodRecord<z.ZodString, z.ZodNumber>;
24
+ }, z.core.$strict>;
25
+ export type ReadWait = z.output<typeof ReadWaitSchema>;
26
+ /**
27
+ * What a delegating call waits on, as its `wait/declared` row records it, versioned by delegations:
28
+ * a blocking call waits on its `task`; `read_agent` on the first of its named tasks to settle, or
29
+ * with `until: 'activity'` to record anything after `since` (each child's `through_seq` as the call
30
+ * looked), until its deadline.
31
+ */
32
+ export declare const DelegationWaitSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
33
+ task_id: z.ZodString;
34
+ child_id: z.ZodString;
35
+ v: z.ZodLiteral<1>;
36
+ kind: z.ZodLiteral<"task">;
37
+ }, z.core.$strict>, z.ZodObject<{
38
+ v: z.ZodLiteral<1>;
39
+ kind: z.ZodLiteral<"read">;
40
+ tasks: z.ZodArray<z.ZodObject<{
41
+ task_id: z.ZodString;
42
+ child_id: z.ZodString;
43
+ }, z.core.$strict>>;
44
+ until: z.ZodEnum<{
45
+ settled: "settled";
46
+ activity: "activity";
47
+ }>;
48
+ since: z.ZodRecord<z.ZodString, z.ZodNumber>;
49
+ }, z.core.$strict>], "kind">;
50
+ export type DelegationWait = z.output<typeof DelegationWaitSchema>;
51
+ /**
52
+ * A blocking call's value: the answer chosen as its task's serving run settled, not handed on to a
53
+ * successor, or was held for a cancellation or a failure; and that run's state then. A later change
54
+ * of the task's state cannot change an answer recorded.
55
+ */
56
+ export declare const TaskValueSchema: z.ZodObject<{
57
+ v: z.ZodLiteral<1>;
58
+ kind: z.ZodLiteral<"task">;
59
+ outcome: z.ZodObject<{
60
+ status: z.ZodEnum<{
61
+ completed: "completed";
62
+ failed: "failed";
63
+ }>;
64
+ output: z.ZodString;
65
+ }, z.core.$strict>;
66
+ run_id: z.ZodString;
67
+ state: z.ZodEnum<{
68
+ settled: "settled";
69
+ held: "held";
70
+ }>;
71
+ reason: z.ZodString;
72
+ error_text: z.ZodNullable<z.ZodString>;
73
+ }, z.core.$strict>;
74
+ export type TaskValue = z.output<typeof TaskValueSchema>;
75
+ /**
76
+ * Why a `read_agent` wait returned: a named task ended (`settled`); a named child recorded anything,
77
+ * with `until: 'activity'`; nothing can advance a named open task (`no_progress`); or the deadline.
78
+ */
79
+ export declare const ReadWhySchema: z.ZodEnum<{
80
+ timeout: "timeout";
81
+ settled: "settled";
82
+ activity: "activity";
83
+ no_progress: "no_progress";
84
+ }>;
85
+ export type ReadWhy = z.output<typeof ReadWhySchema>;
86
+ export declare const ReadValueSchema: z.ZodObject<{
87
+ v: z.ZodLiteral<1>;
88
+ kind: z.ZodLiteral<"read">;
89
+ why: z.ZodEnum<{
90
+ timeout: "timeout";
91
+ settled: "settled";
92
+ activity: "activity";
93
+ no_progress: "no_progress";
94
+ }>;
95
+ }, z.core.$strict>;
96
+ /** A blocking call's dependency. */
97
+ export declare const taskWait: (task: TaskRef) => TaskWait;
98
+ /** A blocking call's value. */
99
+ export declare const taskValue: (outcome: DelegationOutcome, run: {
100
+ readonly runId: string;
101
+ readonly state: "settled" | "held";
102
+ readonly reason: string;
103
+ readonly errorText: string | null;
104
+ }) => TaskValue;
105
+ /** The children a wait names: a blocking call's task's, or each a read names. */
106
+ export declare const waitedOn: (wait: DelegationWait) => string[];
107
+ /** The tasks a read wait names, as task references. */
108
+ export declare const readTasks: (wait: ReadWait) => TaskRef[];
109
+ /** A blocking call's recorded answer, from the wait it resolved; throws on a payload of another version or kind. */
110
+ export declare function taskAnswer(wait: ResolvedWait): {
111
+ readonly childId: string;
112
+ readonly outcome: DelegationOutcome;
113
+ };
114
+ /** A `read_agent` call's resolved wait: the tasks it named, and why it returned. */
115
+ export declare function readAnswer(wait: ResolvedWait): {
116
+ readonly tasks: TaskRef[];
117
+ readonly why: ReadWhy;
118
+ };
@@ -0,0 +1,116 @@
1
+ import type { Context } from '@leuduan/cordis';
2
+ import { type Clock } from '../../util/timers.js';
3
+ import type { JournalEvent } from '../../records/journal.js';
4
+ import type { OwnerHandle } from '../../services/threads/index.js';
5
+ import type { NoticeDelivery } from './notices.js';
6
+ import { type ReadWait, type ReadWhy } from './waitContracts.js';
7
+ /**
8
+ * Why a read wait returns now, or `null` while it waits: a named task ended (`settled`); with
9
+ * `activity`, a named child recorded a row after the read looked; nothing can advance a named open
10
+ * task (`no_progress`): none of their children runs, waits to run, or is held for something that
11
+ * passes, such as an approval, a wait of its own, the startup policy, a missing owner or a
12
+ * constraint. Read from the catalog and the owner, synchronously.
13
+ */
14
+ export declare function readCondition(ctx: Context, wait: ReadWait): ReadWhy | null;
15
+ /** What the resolver is handed by the service that mounts it. */
16
+ export type WaitResolverOptions = {
17
+ /** The clock `read_agent`'s deadlines and the retries of failed decisions are kept on. */
18
+ readonly clock: Clock;
19
+ /** Resolves once the task state can be served: no decision is taken before. */
20
+ readonly ready: Promise<void>;
21
+ /** Whose notices a read that finds a task ended waits to be durable. */
22
+ readonly notices: NoticeDelivery;
23
+ /** The task constraint's registration, which resolves the waits; `undefined` while not registered. */
24
+ readonly constraint: () => OwnerHandle | undefined;
25
+ };
26
+ /**
27
+ * Every delegation wait, from its `wait/declared` row to its call's answer: the one owner of when a
28
+ * blocking call's or a `read_agent` call's wait resolves, and with what. A blocking call's wait
29
+ * resolves once its task's serving run settles, not handed on to a successor, or is held for a
30
+ * person's cancellation or a failure, with the answer chosen then; a read's once a named task ended,
31
+ * after that task's notice is durable, a named child recorded anything, nothing can advance them, or
32
+ * its deadline. The condition is read again inside the resolving write, which declines when it no
33
+ * longer holds.
34
+ *
35
+ * Its index is kept by rows alone, never by reading core's wait state: a declaration under
36
+ * delegations is booked, its resolution stops its deadline and its decisions, and its call's answer
37
+ * forgets it; any row or run event of a child a wait names decides that wait again. One decision at
38
+ * a time per wait: a trigger meanwhile is handed the one under way, and decides again after it. A
39
+ * decision that fails, reading or writing, is reported and taken again later, so a wait nothing else
40
+ * would trigger again is not lost with it. Its task's child is told whenever a blocking call starts
41
+ * or stops being its task's authority: as the wait is declared, and as the call is answered.
42
+ *
43
+ * The repair books every wait the catalog shows suspended on delegations, and decides at once those
44
+ * satisfied while the process was down; the drain stops deciding at shutdown, leaving what is due to
45
+ * the next startup's repair.
46
+ */
47
+ export declare class WaitResolver {
48
+ /** Every delegation wait whose call is not answered yet, by caller and call. */
49
+ private readonly waits;
50
+ /** The unresolved waits by each child they name. */
51
+ private readonly waitsOn;
52
+ /** The decision under way for each wait, and the waits to decide again once it is done. */
53
+ private readonly checking;
54
+ private readonly recheck;
55
+ /** Decisions that failed, by wait: each is taken again later (`retryLater`). */
56
+ private readonly retries;
57
+ /** `read_agent`'s deadlines. */
58
+ private readonly deadlines;
59
+ private closing;
60
+ private readonly ctx;
61
+ private readonly options;
62
+ constructor(ctx: Context, options: WaitResolverOptions);
63
+ /**
64
+ * What a row does to the resolver: a declaration naming delegations is booked; a resolution stops
65
+ * deciding its wait, and a result of a booked call forgets it, telling a blocking call's task's
66
+ * child, whose authority the call was; any row of a child a wait names decides that wait again, so
67
+ * `until: 'activity'` sees the row and a task that ended is seen at once.
68
+ */
69
+ onRow(event: JournalEvent): void;
70
+ /** Decides again every unresolved wait naming `threadId`, after a run event of it. */
71
+ onRunEvent(threadId: string): void;
72
+ /**
73
+ * The startup repair of delegation waits: every caller the catalog shows suspended on delegations
74
+ * is read, its waits booked, and the unresolved ones decided, so a read's deadline that passed
75
+ * meanwhile times out and a wait whose child finished while the process was down resolves now.
76
+ * Resolves once those writes have landed, so the startup policy judges their causes.
77
+ */
78
+ repair(): Promise<void>;
79
+ /** Stops deciding, so the next startup's repair decides what is due; resolves once each decision under way has landed. */
80
+ drain(): Promise<void>;
81
+ /**
82
+ * Books a declared delegation wait: indexed by its caller's call and, until it resolves, by each
83
+ * child it names, a read's deadline armed, and its condition checked at once, since the child may
84
+ * have finished first. Its task's child is told: the call waiting is now its task's authority. A
85
+ * wait the repair finds resolved is only kept until its call is answered.
86
+ */
87
+ private book;
88
+ /** Stops deciding a wait whose value is recorded: its call waits only to be dispatched again. */
89
+ private resolved;
90
+ /** Forgets a wait whose call was answered, resolved or not; a blocking call's task's child is told. */
91
+ private answered;
92
+ private stopDeciding;
93
+ /** Checks every unresolved wait naming `childId`, after a row or a run event of it. */
94
+ private checkWaitsOn;
95
+ /** Resolves the wait under `key` if its condition holds, one decision at a time; see the class. */
96
+ private check;
97
+ /** One decision of `check`. */
98
+ private resolveIfDue;
99
+ /** Takes a failed decision again later, while its wait is still decided. */
100
+ private retryLater;
101
+ /**
102
+ * Where a blocking task's serving run stands once it lets its call's wait resolve, or `null` while
103
+ * the call keeps waiting: settled, not handed on to a successor (the task fold follows the run
104
+ * while the task is open, so a settled serving run is the last); or held for a person's
105
+ * cancellation or a failure. It keeps waiting through every hold that passes, an approval or a
106
+ * startup decline included. Read at the owner's published boundary, never from a raw row.
107
+ */
108
+ private taskRun;
109
+ /**
110
+ * What a blocking call is told once its task's serving run lets its wait resolve: the task's
111
+ * outcome once it settled; otherwise why the task did not end, which the call's result then ends
112
+ * it for: a person's cancel of the child, a failure it is held on, or a run that settled with the
113
+ * task still open.
114
+ */
115
+ private taskOutcome;
116
+ }
@@ -0,0 +1,14 @@
1
+ import type { ConversationMessage } from '../../llm/primitives.js';
2
+ import { type DeepReadonly } from '../../util/json.js';
3
+ import type { SentModelRequest } from '../../loop/index.js';
4
+ /** Enough of a fingerprint to tell one value from another across restarts. */
5
+ export declare const digestOf: (text: string) => string;
6
+ /**
7
+ * A digest of everything a request sends ahead of its messages: the prompt,
8
+ * the tools and every option, the model included. Correlation, the ids and the purpose, is left
9
+ * out, so two threads sending the same head get the same digest — which is what a fork's prefix
10
+ * check compares.
11
+ */
12
+ export declare function headDigest(request: SentModelRequest): string;
13
+ /** A digest of a message list; a prefix of it digests the same as the same messages sent alone. */
14
+ export declare const messagesDigest: (messages: readonly DeepReadonly<ConversationMessage>[]) => string;
@@ -0,0 +1,68 @@
1
+ import type { Plugin } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import type { PluginJournal } from '../../journal/index.js';
4
+ import type { RowRef } from '../../state/index.js';
5
+ /**
6
+ * How a fork's first request compares with its source's request at the cut: whether it sent the
7
+ * same head and route, and extended the same messages. `unavailable` when there is nothing to
8
+ * compare with: the fork was cut before its source asked the model, or that request was never
9
+ * measured. Measured, not enforced: nothing sent is altered.
10
+ */
11
+ export declare const PrefixCheckSchema: z.ZodObject<{
12
+ status: z.ZodEnum<{
13
+ unavailable: "unavailable";
14
+ matched: "matched";
15
+ mismatched: "mismatched";
16
+ }>;
17
+ differs: z.ZodArray<z.ZodEnum<{
18
+ route: "route";
19
+ head: "head";
20
+ messages: "messages";
21
+ }>>;
22
+ replaced: z.ZodNullable<z.ZodNumber>;
23
+ }, z.core.$strict>;
24
+ export type PrefixCheck = z.infer<typeof PrefixCheckSchema>;
25
+ declare const MeasuresSchema: z.ZodObject<{
26
+ purpose: z.ZodEnum<{
27
+ step: "step";
28
+ auxiliary: "auxiliary";
29
+ }>;
30
+ system_prompt_chars: z.ZodNumber;
31
+ system_prompt_digest: z.ZodString;
32
+ head_digest: z.ZodString;
33
+ messages_digest: z.ZodString;
34
+ prefix_check: z.ZodNullable<z.ZodObject<{
35
+ status: z.ZodEnum<{
36
+ unavailable: "unavailable";
37
+ matched: "matched";
38
+ mismatched: "mismatched";
39
+ }>;
40
+ differs: z.ZodArray<z.ZodEnum<{
41
+ route: "route";
42
+ head: "head";
43
+ messages: "messages";
44
+ }>>;
45
+ replaced: z.ZodNullable<z.ZodNumber>;
46
+ }, z.core.$strict>>;
47
+ }, z.core.$strict>;
48
+ /** What the plugin measured of one request. */
49
+ export type RequestMeasures = z.output<typeof MeasuresSchema>;
50
+ /**
51
+ * Measures every model request a thread sends, through `lagent/llm/sent`, and records it as an `ext`
52
+ * row citing the request row: the prompt's size and digest, a digest of the head, one of the
53
+ * messages, and on a fork's first model step how it compares with its source's request at the cut,
54
+ * which tells whether it can reuse the source's cached prefix. A mismatch with no replacement since
55
+ * the reference is reported. Mount it on the untagged application context.
56
+ *
57
+ * ```ts
58
+ * await root.plugin(diagnostics)
59
+ * ```
60
+ */
61
+ export declare const diagnostics: Plugin.Object<undefined>;
62
+ /**
63
+ * What was measured of the request recorded at `row`, or `undefined` when it was not: the plugin
64
+ * was not mounted then, or the request row is not loaded. Found on the request's own thread, by
65
+ * the citation, wherever it lies, since a fork cut at a request row is cut before its measures.
66
+ */
67
+ export declare function requestMeasures(journal: Pick<PluginJournal, 'rowsAfter'>, row: RowRef): RequestMeasures | undefined;
68
+ export {};
@@ -0,0 +1 @@
1
+ import{d as y}from"../../chunks/S34ZA2R6.js";import{b as q}from"../../chunks/6FRNHMCV.js";import"../../chunks/CUK7CGC7.js";import"../../chunks/BPRCULZH.js";import"../../chunks/DDANMY45.js";import{c}from"../../chunks/BBCW2FZK.js";import"../../chunks/MMNNZCBO.js";import"../../chunks/G44LG6VL.js";import{A as _}from"../../chunks/D4PQP5MA.js";import{z as r}from"zod";import{createHash as I}from"node:crypto";var m=e=>I("sha256").update(e).digest("hex").slice(0,12);function b(e){let{messages:s,agentName:t,threadId:a,llmCallId:o,purpose:n,...u}=e;return m(c(u))}var f=e=>m(c(e));var S=r.strictObject({status:r.enum(["matched","mismatched","unavailable"]),differs:r.array(r.enum(["head","route","messages"])),replaced:r.number().int().positive().nullable()}),j=r.strictObject({purpose:r.enum(["step","auxiliary"]),system_prompt_chars:r.number().int().nonnegative(),system_prompt_digest:r.string(),head_digest:r.string(),messages_digest:r.string(),prefix_check:S.nullable()}),x=q({plugin:"lagent:diagnostics",kind:"request",version:1,schema:j}),L={name:"lagent:diagnostics",inject:["journal"],apply(e){y(e,"diagnostics"),e.on("lagent/llm/sent",async({request:s,row:t})=>{let a=_(s.systemPrompt),o=b(s),n=t.type==="llm/request"?E(e.journal,t,o,s.messages):null;await x.append(e.journal,{purpose:s.purpose,system_prompt_chars:a.length,system_prompt_digest:m(a),head_digest:o,messages_digest:f(s.messages),prefix_check:n},{threadId:t.thread_id,sourceSeqs:[t.seq]}),n?.status==="mismatched"&&n.replaced===null&&e.reportError(new Error(`Thread ${t.thread_id}: a fork's first request differs from its source's in ${n.differs.join(", ")}`))})}};function D(e,s){for(let t of e.rowsAfter(s.threadId,s.seq)){if(!t.source_seqs.includes(s.seq))continue;let a=x.read(t);if(a!==void 0)return a}}function E(e,s,t,a){let o=e.rows(s.thread_id),n=o[0];if(n?.type!=="thread/spawned"||n.data.fork===null||o.some(i=>i.type==="llm/request"&&i.seq!==s.seq))return null;let{thread_id:u,seq:v}=n.data.fork,d=e.lineage(u,v).findLast(i=>i.type==="llm/request");if(d===void 0||d.type!=="llm/request")return k;let p=D(e,{threadId:d.thread_id,seq:d.seq});if(p===void 0)return k;let l=[];t!==p.head_digest&&l.push("head"),c(s.data.route)!==c(d.data.route)&&l.push("route");let g=d.data.message_count,h=null;return(a.length<g||f(a.slice(0,g))!==p.messages_digest)&&(l.push("messages"),h=e.lineage(s.thread_id).find(i=>i.type==="surface/replaced"&&i.seq>d.seq&&i.seq<s.seq)?.seq??null),{status:l.length===0?"matched":"mismatched",differs:l,replaced:h}}var k={status:"unavailable",differs:[],replaced:null};export{S as PrefixCheckSchema,L as diagnostics,D as requestMeasures};
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * What the file tools are configured with, all of it the host's choice: the spawn environment and
4
+ * the trusted `rg` the search tools run (`rg: null` for none).
5
+ */
6
+ export declare const FileToolsConfigSchema: z.ZodObject<{
7
+ environment: z.ZodRecord<z.ZodString, z.ZodString>;
8
+ rg: z.ZodNullable<z.ZodString>;
9
+ }, z.core.$strict>;
10
+ export type FileToolsConfig = z.input<typeof FileToolsConfigSchema>;
@@ -0,0 +1,117 @@
1
+ import { z } from 'zod';
2
+ import type { InvocationContext } from '../../loop/index.js';
3
+ import type { ToolResultPayload } from '../../records/toolResult.js';
4
+ import type { FileAccess } from '../../services/confinement/service.js';
5
+ import { type UnifiedDiff } from '../../util/diff.js';
6
+ /** The largest file `edit_files` reads, which bounds the memory one call takes. */
7
+ export declare const MAX_EDIT_FILE_BYTES: number;
8
+ declare const OperationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ op: z.ZodLiteral<"create">;
10
+ path: z.ZodString;
11
+ content: z.ZodString;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ op: z.ZodLiteral<"update">;
14
+ path: z.ZodString;
15
+ hunks: z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ old_text: z.ZodString;
17
+ new_text: z.ZodString;
18
+ }, z.core.$strict>>>;
19
+ content: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strict>, z.ZodObject<{
21
+ op: z.ZodLiteral<"delete">;
22
+ path: z.ZodString;
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ op: z.ZodLiteral<"move">;
25
+ path: z.ZodString;
26
+ to: z.ZodString;
27
+ hunks: z.ZodOptional<z.ZodArray<z.ZodObject<{
28
+ old_text: z.ZodString;
29
+ new_text: z.ZodString;
30
+ }, z.core.$strict>>>;
31
+ }, z.core.$strict>], "op">;
32
+ type Operation = z.infer<typeof OperationSchema>;
33
+ /**
34
+ * The one tool that changes files: creates, updates, deletes and moves, any number in one call.
35
+ *
36
+ * Everything is checked before anything is written: every path is judged by the call's file policy
37
+ * (read and write for what is changed or moved, write for what is created or moved to) and kept out
38
+ * of every git directory, every file read, every hunk located, and the operations checked against
39
+ * each other. Each file is then written to a temporary sibling and renamed over its target, or
40
+ * hard-linked into place when it must not replace anything, so no reader sees half of it; a
41
+ * filesystem without hard links gets no new file. The call touches files only through its
42
+ * operation's facade, which judges every step again as it happens, and never opens an existing file
43
+ * for writing. There is no transaction across files: when one
44
+ * fails to commit, or the call is cancelled, the call stops there, before its next filesystem
45
+ * change, and its result says which files were committed and which were not.
46
+ *
47
+ * Calls are serialized per file across every thread of the process: each holds its files' locks
48
+ * from reading them to the last rename, and re-checks each file just before replacing it, so a
49
+ * change by anything else in between fails that file instead of being overwritten.
50
+ */
51
+ export declare const editFilesTool: import("../../loop/tool.js").Tool;
52
+ /** A path an operation names: as named, as shown, and where it really is. */
53
+ type Target = {
54
+ readonly named: string;
55
+ /** Resolved against the cwd, symbolic links kept. */
56
+ readonly absolute: string;
57
+ /** As results show it. */
58
+ readonly display: string;
59
+ /** With its symbolic links resolved: what is read, written, compared and locked. */
60
+ readonly real: string;
61
+ /** What the policy was asked to allow for it, and is asked again when it is committed. */
62
+ readonly access: readonly FileAccess[];
63
+ };
64
+ /** What a file was when it was read, to tell whether it changed before it is replaced. */
65
+ type Snapshot = {
66
+ readonly size: number;
67
+ readonly mtimeMs: number;
68
+ readonly hash: string;
69
+ readonly mode: number;
70
+ /** Which file it was: a file replaced by another with the same content is not the one that was read. */
71
+ readonly dev: number;
72
+ readonly ino: number;
73
+ };
74
+ type Planned = {
75
+ readonly kind: 'created';
76
+ readonly target: Target;
77
+ readonly bytes: Buffer;
78
+ readonly lines: number;
79
+ } | {
80
+ readonly kind: 'updated';
81
+ readonly target: Target;
82
+ readonly snapshot: Snapshot;
83
+ readonly bytes: Buffer;
84
+ readonly diff: UnifiedDiff;
85
+ /** The hunks that matched loosely, each as the result words it. */
86
+ readonly looseHunks: readonly string[];
87
+ } | {
88
+ readonly kind: 'deleted';
89
+ readonly target: Target;
90
+ readonly snapshot: Snapshot;
91
+ readonly lines: number | null;
92
+ } | {
93
+ readonly kind: 'moved';
94
+ readonly target: Target;
95
+ readonly to: Target;
96
+ readonly snapshot: Snapshot;
97
+ readonly bytes: Buffer;
98
+ readonly diff: UnifiedDiff | null;
99
+ readonly looseHunks: readonly string[];
100
+ };
101
+ /** One file's outcome, as `metadata.files` records it. */
102
+ export type EditedFile = {
103
+ readonly path: string;
104
+ readonly kind: Planned['kind'];
105
+ /** A move's destination. */
106
+ readonly to?: string;
107
+ readonly added: number;
108
+ readonly removed: number;
109
+ /** `destination_only`: a move whose destination was written and whose source could not be removed. */
110
+ readonly status: 'committed' | 'not_committed' | 'destination_only';
111
+ };
112
+ /**
113
+ * Applies `operations` for a call: the whole of `edit_files` but its parameter parsing. See
114
+ * {@link editFilesTool}.
115
+ */
116
+ export declare function applyFileOperations(operations: readonly Operation[], context: InvocationContext): Promise<ToolResultPayload>;
117
+ export {};
@@ -0,0 +1,17 @@
1
+ /** The most lines one read returns. */
2
+ export declare const MAX_LINES_PER_READ = 2000;
3
+ /** The most bytes of a file's lines one read returns, line numbers aside. */
4
+ export declare const MAX_PAGE_BYTES: number;
5
+ /** A longer line is cut to this many characters, and the cut is stated. */
6
+ export declare const MAX_LINE_CHARS = 2000;
7
+ /**
8
+ * The largest image `read_file` answers with as an image: low, as the `mcp` plugin's default is,
9
+ * because an image stays in the conversation and every later request sends it again.
10
+ */
11
+ export declare const MAX_IMAGE_BYTES: number;
12
+ export declare const readFileTool: import("../../loop/tool.js").Tool;
13
+ /** The image type a file's first bytes declare, for the formats a model reads. */
14
+ export declare function imageMediaType(head: Buffer): string | null;
15
+ /** Directories that only ever hold build output, dependencies or version control. */
16
+ export declare const SKIPPED_DIRECTORIES: ReadonlySet<string>;
17
+ export declare const listDirTool: import("../../loop/tool.js").Tool;
@@ -0,0 +1,9 @@
1
+ import type { FileScope } from '../../services/confinement/files.js';
2
+ import type { RepositoryLocation } from '../../sys/git.js';
3
+ /**
4
+ * The repository containing `path`: the nearest directory at or above it holding a `.git` entry, as
5
+ * `findRepository` finds it, with every file read through `files`. A path the policy refuses to be
6
+ * read rejects with its `FileAccessError`, since whether it is git's own cannot then be told; a file
7
+ * system error counts as not there.
8
+ */
9
+ export declare function findRepositoryThrough(files: FileScope, path: string): Promise<RepositoryLocation | null>;
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from '@leuduan/cordis';
2
+ import { type FileToolsConfig } from './config.js';
3
+ export type { FileToolsConfig } from './config.js';
4
+ /** The file tools that read the workspace without changing it. */
5
+ export declare const READ_ONLY_TOOLS: readonly ["read_file", "list_dir", "rg_search", "rg_files"];
6
+ /** The file tools that run `rg`, provided only where the host has it (`rg` in the configuration). */
7
+ export declare const RG_TOOLS: readonly string[];
8
+ /**
9
+ * Registers `read_file`, `list_dir`, `rg_search`, `rg_files` and `edit_files` for the life of the
10
+ * plugin. A tool reaches files through `InvocationContext.operation`, so the confinement policy
11
+ * judges every path; the host names the spawn environment and the trusted `rg` the search tools
12
+ * run, and there is no default for either.
13
+ *
14
+ * Ungranted: `agents` choose which of them each agent sees. The web tools ship as `webTools`, the
15
+ * shell commands as `commands`, which owns their processes, and `ask_question` as the `lagent:ask`
16
+ * plugin, since it needs a host that can reach the user.
17
+ */
18
+ export declare const fileTools: Plugin.Object<FileToolsConfig>;
@@ -0,0 +1 @@
1
+ import{a,b,c}from"../../chunks/IAAEP6VL.js";import"../../chunks/VYMT4TXD.js";import"../../chunks/N6IXG2VL.js";import"../../chunks/6DRCKZ2C.js";import"../../chunks/7LI64H5X.js";import"../../chunks/3UMZMPWW.js";import"../../chunks/34KW6VNQ.js";import"../../chunks/JFX2MXBA.js";import"../../chunks/CUK7CGC7.js";import"../../chunks/BPRCULZH.js";import"../../chunks/FJLU4UH3.js";import"../../chunks/DDANMY45.js";import"../../chunks/BBCW2FZK.js";import"../../chunks/MMNNZCBO.js";import"../../chunks/G44LG6VL.js";import"../../chunks/D4PQP5MA.js";export{a as READ_ONLY_TOOLS,b as RG_TOOLS,c as fileTools};
@@ -0,0 +1,20 @@
1
+ import type { Tool } from '../../loop/index.js';
2
+ import { type SpawnEnvironment } from '../../sys/spawn.js';
3
+ /**
4
+ * What both search tools run: the trusted `rg`, in the host's spawn environment, and how long one
5
+ * search's `rg` may run before what it found so far is returned as partial.
6
+ */
7
+ export type SearchProgram = {
8
+ rg: string;
9
+ environment: SpawnEnvironment;
10
+ timeoutMs: number;
11
+ };
12
+ /** The most matches one search returns. */
13
+ export declare const MAX_RG_RESULTS = 200;
14
+ /** `rg_search`, running the trusted `rg` in the host's environment; its name and description say so. */
15
+ export declare const rgSearchTool: (program: SearchProgram) => Tool;
16
+ /**
17
+ * `rg_files`: `rg --files` lists what the search admits, and the pattern is matched against each
18
+ * listed path, relative to the search directory, so a pattern never lets an ignored file in.
19
+ */
20
+ export declare const rgFilesTool: (program: SearchProgram) => Tool;