@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,633 @@
1
+ import { z } from 'zod';
2
+ import { type PluginJournal } from '../../journal/index.js';
3
+ import { type AnswerCheck } from '../../state/index.js';
4
+ import type { JournalEvent, Seq, ThreadOrigin, ThreadSummary, TurnEndReason } from '../../records/journal.js';
5
+ import type { ToolResult, ToolResultPayloadInput } from '../../records/toolResult.js';
6
+ import type { DeepReadonly } from '../../util/json.js';
7
+ import { type AssignmentOutcome } from './request.js';
8
+ import type { ReadonlyState } from '../../util/foldState.js';
9
+ /**
10
+ * What the journal keeps of every delegation, on the child: the task was opened, stopped for good,
11
+ * and quiet after its stop. Written by the delegations service as `ext` rows of its own identity.
12
+ *
13
+ * `started` rides in the write that queues the task's input, the child's creation group or the
14
+ * `send` that continues it, so no child holds a task without its row. `stopped` is the durable intent
15
+ * of a stop; `stop_cleaned` says the stopped task's work went quiet, and changes no outcome.
16
+ */
17
+ declare const DelegationRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
18
+ op: z.ZodLiteral<"started">;
19
+ task_id: z.ZodString;
20
+ origin: z.ZodObject<{
21
+ caller_thread_id: z.ZodString;
22
+ source_seq: z.ZodNumber;
23
+ cause: z.ZodDiscriminatedUnion<[z.ZodObject<{
24
+ kind: z.ZodLiteral<"call">;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ kind: z.ZodLiteral<"assignment">;
27
+ owner: z.ZodString;
28
+ key: z.ZodJSONSchema;
29
+ }, z.core.$strip>], "kind">;
30
+ }, z.core.$strip>;
31
+ background: z.ZodBoolean;
32
+ notice: z.ZodBoolean;
33
+ run_id: z.ZodString;
34
+ task: z.ZodString;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ op: z.ZodLiteral<"stopped">;
37
+ task_id: z.ZodString;
38
+ by: z.ZodEnum<{
39
+ caller: "caller";
40
+ host: "host";
41
+ ancestor: "ancestor";
42
+ }>;
43
+ reason: z.ZodString;
44
+ call_seq: z.ZodNullable<z.ZodNumber>;
45
+ }, z.core.$strict>, z.ZodObject<{
46
+ op: z.ZodLiteral<"stop_cleaned">;
47
+ task_id: z.ZodString;
48
+ }, z.core.$strict>], "op">;
49
+ export type DelegationRow = z.output<typeof DelegationRowSchema>;
50
+ /** A task's origin as its `started` row is written: the shape a start builds, before a fold holds it read-only. */
51
+ export type StartedOrigin = Extract<DelegationRow, {
52
+ op: 'started';
53
+ }>['origin'];
54
+ export type TaskStarted = DeepReadonly<Extract<DelegationRow, {
55
+ op: 'started';
56
+ }>>;
57
+ export type TaskStopped = Extract<DelegationRow, {
58
+ op: 'stopped';
59
+ }>;
60
+ export declare const delegationRow: {
61
+ record: (value: {
62
+ op: "started";
63
+ task_id: string;
64
+ origin: {
65
+ caller_thread_id: string;
66
+ source_seq: number;
67
+ cause: {
68
+ kind: "call";
69
+ } | {
70
+ kind: "assignment";
71
+ owner: string;
72
+ key: z.core.util.JSONType;
73
+ };
74
+ };
75
+ background: boolean;
76
+ notice: boolean;
77
+ run_id: string;
78
+ task: string;
79
+ } | {
80
+ op: "stopped";
81
+ task_id: string;
82
+ by: "caller" | "host" | "ancestor";
83
+ reason: string;
84
+ call_seq: number | null;
85
+ } | {
86
+ op: "stop_cleaned";
87
+ task_id: string;
88
+ }) => import("../../records/journal.js").ExtensionRecord;
89
+ parse: (value: {
90
+ op: "started";
91
+ task_id: string;
92
+ origin: {
93
+ caller_thread_id: string;
94
+ source_seq: number;
95
+ cause: {
96
+ kind: "call";
97
+ } | {
98
+ kind: "assignment";
99
+ owner: string;
100
+ key: z.core.util.JSONType;
101
+ };
102
+ };
103
+ background: boolean;
104
+ notice: boolean;
105
+ run_id: string;
106
+ task: string;
107
+ } | {
108
+ op: "stopped";
109
+ task_id: string;
110
+ by: "caller" | "host" | "ancestor";
111
+ reason: string;
112
+ call_seq: number | null;
113
+ } | {
114
+ op: "stop_cleaned";
115
+ task_id: string;
116
+ }) => {
117
+ op: "started";
118
+ task_id: string;
119
+ origin: {
120
+ caller_thread_id: string;
121
+ source_seq: number;
122
+ cause: {
123
+ kind: "call";
124
+ } | {
125
+ kind: "assignment";
126
+ owner: string;
127
+ key: z.core.util.JSONType;
128
+ };
129
+ };
130
+ background: boolean;
131
+ notice: boolean;
132
+ run_id: string;
133
+ task: string;
134
+ } | {
135
+ op: "stopped";
136
+ task_id: string;
137
+ by: "caller" | "host" | "ancestor";
138
+ reason: string;
139
+ call_seq: number | null;
140
+ } | {
141
+ op: "stop_cleaned";
142
+ task_id: string;
143
+ };
144
+ entry: (value: {
145
+ op: "started";
146
+ task_id: string;
147
+ origin: {
148
+ caller_thread_id: string;
149
+ source_seq: number;
150
+ cause: {
151
+ kind: "call";
152
+ } | {
153
+ kind: "assignment";
154
+ owner: string;
155
+ key: z.core.util.JSONType;
156
+ };
157
+ };
158
+ background: boolean;
159
+ notice: boolean;
160
+ run_id: string;
161
+ task: string;
162
+ } | {
163
+ op: "stopped";
164
+ task_id: string;
165
+ by: "caller" | "host" | "ancestor";
166
+ reason: string;
167
+ call_seq: number | null;
168
+ } | {
169
+ op: "stop_cleaned";
170
+ task_id: string;
171
+ }, options: import("../../journal/journal.js").AppendOptions) => {
172
+ type: "ext";
173
+ data: {
174
+ plugin: string;
175
+ instance_id: string;
176
+ kind: string;
177
+ version: number;
178
+ data: z.core.util.JSONType;
179
+ };
180
+ options: import("../../journal/journal.js").AppendOptions;
181
+ };
182
+ append(journal: PluginJournal, value: {
183
+ op: "started";
184
+ task_id: string;
185
+ origin: {
186
+ caller_thread_id: string;
187
+ source_seq: number;
188
+ cause: {
189
+ kind: "call";
190
+ } | {
191
+ kind: "assignment";
192
+ owner: string;
193
+ key: z.core.util.JSONType;
194
+ };
195
+ };
196
+ background: boolean;
197
+ notice: boolean;
198
+ run_id: string;
199
+ task: string;
200
+ } | {
201
+ op: "stopped";
202
+ task_id: string;
203
+ by: "caller" | "host" | "ancestor";
204
+ reason: string;
205
+ call_seq: number | null;
206
+ } | {
207
+ op: "stop_cleaned";
208
+ task_id: string;
209
+ }, options: import("../../journal/journal.js").AppendOptions): Promise<JournalEvent<"ext">>;
210
+ read(event: JournalEvent): {
211
+ op: "started";
212
+ task_id: string;
213
+ origin: {
214
+ caller_thread_id: string;
215
+ source_seq: number;
216
+ cause: {
217
+ kind: "call";
218
+ } | {
219
+ kind: "assignment";
220
+ owner: string;
221
+ key: z.core.util.JSONType;
222
+ };
223
+ };
224
+ background: boolean;
225
+ notice: boolean;
226
+ run_id: string;
227
+ task: string;
228
+ } | {
229
+ op: "stopped";
230
+ task_id: string;
231
+ by: "caller" | "host" | "ancestor";
232
+ reason: string;
233
+ call_seq: number | null;
234
+ } | {
235
+ op: "stop_cleaned";
236
+ task_id: string;
237
+ } | undefined;
238
+ contribution(message: {
239
+ role?: import("../../records/journal.js").InputRole;
240
+ content: string | readonly import("../../llm/content.js").ContentPartInput[];
241
+ }, value: {
242
+ op: "started";
243
+ task_id: string;
244
+ origin: {
245
+ caller_thread_id: string;
246
+ source_seq: number;
247
+ cause: {
248
+ kind: "call";
249
+ } | {
250
+ kind: "assignment";
251
+ owner: string;
252
+ key: z.core.util.JSONType;
253
+ };
254
+ };
255
+ background: boolean;
256
+ notice: boolean;
257
+ run_id: string;
258
+ task: string;
259
+ } | {
260
+ op: "stopped";
261
+ task_id: string;
262
+ by: "caller" | "host" | "ancestor";
263
+ reason: string;
264
+ call_seq: number | null;
265
+ } | {
266
+ op: "stop_cleaned";
267
+ task_id: string;
268
+ }, options?: {
269
+ sourceSeqs?: readonly Seq[];
270
+ }): import("../../records/journal.js").StepContribution;
271
+ matchesSource(record: DeepReadonly<import("../../records/journal.js").ExtensionRecord>): boolean;
272
+ rejection(reason: string, value: {
273
+ op: "started";
274
+ task_id: string;
275
+ origin: {
276
+ caller_thread_id: string;
277
+ source_seq: number;
278
+ cause: {
279
+ kind: "call";
280
+ } | {
281
+ kind: "assignment";
282
+ owner: string;
283
+ key: z.core.util.JSONType;
284
+ };
285
+ };
286
+ background: boolean;
287
+ notice: boolean;
288
+ run_id: string;
289
+ task: string;
290
+ } | {
291
+ op: "stopped";
292
+ task_id: string;
293
+ by: "caller" | "host" | "ancestor";
294
+ reason: string;
295
+ call_seq: number | null;
296
+ } | {
297
+ op: "stop_cleaned";
298
+ task_id: string;
299
+ }): {
300
+ decision: "reject";
301
+ reason: string;
302
+ source: import("../../records/journal.js").ExtensionRecord;
303
+ };
304
+ readContribution: (event: JournalEvent) => {
305
+ op: "started";
306
+ task_id: string;
307
+ origin: {
308
+ caller_thread_id: string;
309
+ source_seq: number;
310
+ cause: {
311
+ kind: "call";
312
+ } | {
313
+ kind: "assignment";
314
+ owner: string;
315
+ key: z.core.util.JSONType;
316
+ };
317
+ };
318
+ background: boolean;
319
+ notice: boolean;
320
+ run_id: string;
321
+ task: string;
322
+ } | {
323
+ op: "stopped";
324
+ task_id: string;
325
+ by: "caller" | "host" | "ancestor";
326
+ reason: string;
327
+ call_seq: number | null;
328
+ } | {
329
+ op: "stop_cleaned";
330
+ task_id: string;
331
+ } | undefined;
332
+ readSource: (source: DeepReadonly<import("../../records/journal.js").ExtensionRecord> | null) => {
333
+ op: "started";
334
+ task_id: string;
335
+ origin: {
336
+ caller_thread_id: string;
337
+ source_seq: number;
338
+ cause: {
339
+ kind: "call";
340
+ } | {
341
+ kind: "assignment";
342
+ owner: string;
343
+ key: z.core.util.JSONType;
344
+ };
345
+ };
346
+ background: boolean;
347
+ notice: boolean;
348
+ run_id: string;
349
+ task: string;
350
+ } | {
351
+ op: "stopped";
352
+ task_id: string;
353
+ by: "caller" | "host" | "ancestor";
354
+ reason: string;
355
+ call_seq: number | null;
356
+ } | {
357
+ op: "stop_cleaned";
358
+ task_id: string;
359
+ } | undefined;
360
+ told: import("../../journal/projection.js").PluginProjection<import("../../services/extensionEvents.js").ToldNotices<{
361
+ op: "started";
362
+ task_id: string;
363
+ origin: {
364
+ caller_thread_id: string;
365
+ source_seq: number;
366
+ cause: {
367
+ kind: "call";
368
+ } | {
369
+ kind: "assignment";
370
+ owner: string;
371
+ key: z.core.util.JSONType;
372
+ };
373
+ };
374
+ background: boolean;
375
+ notice: boolean;
376
+ run_id: string;
377
+ task: string;
378
+ } | {
379
+ op: "stopped";
380
+ task_id: string;
381
+ by: "caller" | "host" | "ancestor";
382
+ reason: string;
383
+ call_seq: number | null;
384
+ } | {
385
+ op: "stop_cleaned";
386
+ task_id: string;
387
+ }>>;
388
+ projection<State>(fold: {
389
+ key: string;
390
+ init(): State;
391
+ apply(state: State, value: {
392
+ op: "started";
393
+ task_id: string;
394
+ origin: {
395
+ caller_thread_id: string;
396
+ source_seq: number;
397
+ cause: {
398
+ kind: "call";
399
+ } | {
400
+ kind: "assignment";
401
+ owner: string;
402
+ key: z.core.util.JSONType;
403
+ };
404
+ };
405
+ background: boolean;
406
+ notice: boolean;
407
+ run_id: string;
408
+ task: string;
409
+ } | {
410
+ op: "stopped";
411
+ task_id: string;
412
+ by: "caller" | "host" | "ancestor";
413
+ reason: string;
414
+ call_seq: number | null;
415
+ } | {
416
+ op: "stop_cleaned";
417
+ task_id: string;
418
+ }, event: JournalEvent<"ext">): State;
419
+ onFork?: "inherit" | "reset";
420
+ }): import("../../journal/projection.js").PluginProjection<State>;
421
+ };
422
+ /**
423
+ * What decided a task, from the first settling row on: an accepted answer, a failure, or a stop. A
424
+ * failure says why: the turn ending that failed it, or the run serving it that failed without one.
425
+ */
426
+ export type TaskSettlement = {
427
+ readonly kind: 'completed';
428
+ readonly output: string;
429
+ } | {
430
+ readonly kind: 'failed';
431
+ readonly why: string;
432
+ readonly latestText: string | null;
433
+ } | {
434
+ readonly kind: 'stopped';
435
+ readonly reason: string;
436
+ };
437
+ export type TaskState = 'open' | TaskSettlement['kind'];
438
+ /**
439
+ * Who stopped a task: one of the `stopped` row's, or `person`, a person's cancel of an owner's
440
+ * child, which the fold derives from the cancel row itself.
441
+ */
442
+ export type StopBy = TaskStopped['by'] | 'person';
443
+ /** One task, as its child's rows record it. */
444
+ export type TaskRecord = {
445
+ readonly started: TaskStarted;
446
+ /** The `started` row: a call addresses the latest task whose row precedes its own `tool/call` row. */
447
+ readonly startedSeq: Seq;
448
+ /**
449
+ * The run request serving the task: its assignment's, then each one the thread opens while the
450
+ * task is open, since every run of a delegated thread serves its open task; fixed once it settles.
451
+ */
452
+ runId: string;
453
+ /** The `input/message` row that claimed the task's input, once a step has. */
454
+ claimSeq: Seq | null;
455
+ settlement: TaskSettlement | null;
456
+ /** The task's stop: its `stopped` row, or a person's cancel of an owner's child; whether or not it settled the task. */
457
+ stop: {
458
+ readonly by: StopBy;
459
+ readonly reason: string;
460
+ readonly call_seq: Seq | null;
461
+ } | null;
462
+ cleaned: boolean;
463
+ /** The answer under check since the claim, read as core's stop checks read it. */
464
+ answer: AnswerCheck;
465
+ /** The latest assistant text since the claim. */
466
+ latestText: string | null;
467
+ /** How the latest turn since the task started ended, claimed or not: what a failed run that settles it reports. */
468
+ ending: TurnEndReason | null;
469
+ };
470
+ /** A task as a reader of the fold sees it. */
471
+ export type ReadTask = ReadonlyState<TaskRecord>;
472
+ /** A thread's tasks as its child: every one by id, and the latest, the only one that can be open. */
473
+ export type DelegationTasks = {
474
+ readonly byId: Map<string, TaskRecord>;
475
+ latest: TaskRecord | null;
476
+ };
477
+ /**
478
+ * The caller's `tool/call` row that opened a task of `origin`, or `null` for one an owner's
479
+ * assignment opened: what a path about calls (a call's result, receipt or wait) reads, so no
480
+ * granting row is ever taken for a call.
481
+ */
482
+ export declare const openingCall: (origin: ThreadOrigin) => Seq | null;
483
+ /**
484
+ * The owner's assignment that opened a task of `origin`, or `null` for one a call opened: what a
485
+ * path about owners (their authority, their outcome) reads.
486
+ */
487
+ export declare const openingAssignment: (origin: ThreadOrigin) => Extract<ThreadOrigin["cause"], {
488
+ kind: "assignment";
489
+ }> | null;
490
+ /** The latest task whose opening row strictly precedes a call, stable across re-dispatches. */
491
+ export declare function taskBeforeCall(tasks: ReadonlyState<DelegationTasks>, callSeq: Seq): ReadTask | null;
492
+ /**
493
+ * Whether a turn ending settles a delegated thread's work: `completed`, at which its pending answer is
494
+ * accepted, or a failure, `error`, `max-steps` or `rejected`. An `aborted`, `interrupted` or `blocked`
495
+ * ending settles nothing, since the next admission runs the thread again. The task fold reads it
496
+ * after its task's claim, and the backstop that stops what a delegated thread left open at every one.
497
+ */
498
+ export declare const settlingEnding: (reason: Pick<TurnEndReason, "kind">) => boolean;
499
+ /**
500
+ * The tasks a thread was given, read forward from each `started` row: the task's claim, then the
501
+ * answers and turn endings after it, until the first settling row: an accepted answer, a failure
502
+ * at a `settlingEnding`, or the failed settlement of the run serving it with no successor, which
503
+ * may have opened no turn at all. Any other ending settles nothing, so a task re-driven after a shutdown or a cancel
504
+ * settles on its next turn's answer. Raw rather than an `ext` fold because it reads core rows beside its own;
505
+ * resets at a fork's spawn row, so a fork owns none of its source's tasks.
506
+ */
507
+ export declare const delegationTasks: import("../../journal/projection.js").PluginProjection<DelegationTasks>;
508
+ /** The caller's result for its call at `callSeq`, from its loaded rows; `null` while the call has none. */
509
+ export declare function callResult(journal: PluginJournal, callerId: string, callSeq: Seq): ToolResult | null;
510
+ /**
511
+ * A background call's reply once its task is open: a non-error result whose metadata carries the
512
+ * receipt marker, the one result that does not end the task it cites. `toolName` is the start tool
513
+ * that opened it, or `null` for a continuation.
514
+ */
515
+ export declare function receiptReply(toolName: string | null, childId: string, taskId: string): ToolResultPayloadInput;
516
+ /** Whether `result` is task `taskId`'s receipt: a non-error result carrying the marker, which ends no task. */
517
+ export declare function isReceipt(result: ToolResult, taskId: string): boolean;
518
+ /**
519
+ * Whether the loaded thread's last turn left work behind: it ended `blocked`, or calls have no
520
+ * results. A task queued on it would wait behind an approval or calls that are not its own.
521
+ */
522
+ export declare function stoppedMidWork(journal: PluginJournal, threadId: string): boolean;
523
+ /** A task, by its id and the child it was given to. */
524
+ export type TaskRef = {
525
+ readonly taskId: string;
526
+ readonly childId: string;
527
+ };
528
+ /**
529
+ * Task `task.taskId` as its loaded child `task.childId` records it, for the owner that assigned it:
530
+ * how it settled, if it has, who stopped it, if anyone did, and its latest prose; `null` when that
531
+ * owner assigned no such task there. Synchronous, so an owner can read it inside a write of its own while it holds
532
+ * the child loaded.
533
+ */
534
+ export declare function assignmentOutcome(journal: PluginJournal, owner: string, task: TaskRef): AssignmentOutcome | null;
535
+ /**
536
+ * What opened task `task.taskId` on child `task.childId`, as its `started` row records it: a call, or
537
+ * an owner's assignment, whichever opened it, creation or continuation; `null` when the child records
538
+ * no such task, as for a steer's input, which opens none. Read while the child is loaded, as a host
539
+ * draws the task's input.
540
+ */
541
+ export declare function taskOrigin(journal: PluginJournal, task: TaskRef): ThreadOrigin | null;
542
+ /**
543
+ * The row that opened the latest task of the loaded child `childId` (its `started` row), or `null`
544
+ * while it records none: a journal seq, comparable with any other thread's. Read from its rows, so it
545
+ * holds across a restart.
546
+ */
547
+ export declare function latestTaskOpenedAt(journal: PluginJournal, childId: string): Seq | null;
548
+ declare const LatestTaskSchema: z.ZodObject<{
549
+ task_id: z.ZodString;
550
+ origin: z.ZodObject<{
551
+ caller_thread_id: z.ZodString;
552
+ source_seq: z.ZodNumber;
553
+ cause: z.ZodDiscriminatedUnion<[z.ZodObject<{
554
+ kind: z.ZodLiteral<"call">;
555
+ }, z.core.$strip>, z.ZodObject<{
556
+ kind: z.ZodLiteral<"assignment">;
557
+ owner: z.ZodString;
558
+ key: z.ZodJSONSchema;
559
+ }, z.core.$strip>], "kind">;
560
+ }, z.core.$strip>;
561
+ run_id: z.ZodString;
562
+ background: z.ZodBoolean;
563
+ notice: z.ZodBoolean;
564
+ state: z.ZodEnum<{
565
+ completed: "completed";
566
+ failed: "failed";
567
+ open: "open";
568
+ stopped: "stopped";
569
+ }>;
570
+ cleanup_pending: z.ZodBoolean;
571
+ first_line: z.ZodString;
572
+ }, z.core.$strip>;
573
+ /** A child's latest task, as its catalog entry carries it. */
574
+ export type LatestTask = DeepReadonly<z.output<typeof LatestTaskSchema>>;
575
+ /**
576
+ * What a thread's catalog entry says of its latest task: `null` for none, or for a thread
577
+ * delegations does not manage (`taskManaged`); `unavailable` when the entry cannot be read: the
578
+ * contribution failed or never ran for the thread, which nothing reads as "no task".
579
+ */
580
+ export type TaskReading = LatestTask | null | {
581
+ readonly state: 'unavailable';
582
+ readonly error: string;
583
+ };
584
+ /** The constraint owner a delegated child requires, recorded at its creation. */
585
+ export declare const DELEGATIONS_OWNER = "lagent:delegations";
586
+ /**
587
+ * Whether delegations governs the thread: it requires {@link DELEGATIONS_OWNER}, which every child a
588
+ * task opens records at creation. Origin alone says only where a thread sits in its tree: a thread
589
+ * made by hand under another takes no task and runs when its host wakes it, as a root does.
590
+ */
591
+ export declare const taskManaged: (summary: Pick<ThreadSummary, "requires">) => boolean;
592
+ /** A managed thread's latest task, contributed to its catalog entry while delegations is mounted. */
593
+ export declare const latestTask: import("../../services/catalogContributions.js").ContributionDefinition<{
594
+ task_id: string;
595
+ origin: {
596
+ caller_thread_id: string;
597
+ source_seq: number;
598
+ cause: {
599
+ kind: "call";
600
+ } | {
601
+ kind: "assignment";
602
+ owner: string;
603
+ key: z.core.util.JSONType;
604
+ };
605
+ };
606
+ run_id: string;
607
+ background: boolean;
608
+ notice: boolean;
609
+ state: "completed" | "failed" | "open" | "stopped";
610
+ cleanup_pending: boolean;
611
+ first_line: string;
612
+ } | null>;
613
+ /**
614
+ * Whether the thread's latest task settled while the run that served it still drains input it
615
+ * accepted before it settled: still work, though settled.
616
+ */
617
+ export declare function taskDraining(journal: PluginJournal, child: ThreadSummary): boolean;
618
+ /**
619
+ * What `threadId`'s latest task is, from its folds when it is loaded and its catalog entry
620
+ * otherwise: `null` for none or a thread delegations does not manage, `unavailable` for a managed
621
+ * thread whose entry has no valid value.
622
+ */
623
+ export declare function readTask(journal: PluginJournal, threadId: string): TaskReading;
624
+ /**
625
+ * Whether an approval holds up `childId`'s task, from the catalog: an unanswered confirmation on the
626
+ * child, or on a thread under it reached through the open tasks each thread above waits on. A thread
627
+ * waits on its open blocking tasks, whose calls run in its turn, and, once its own last turn ended
628
+ * `blocked`, on every open task it started, since it is parked on whatever it waits for. So a
629
+ * background grandchild's approval holds up the child's task only while the child is parked; and a
630
+ * parked thread whose approvals were all answered holds nothing up, and is driven again.
631
+ */
632
+ export declare function blockedUnder(journal: PluginJournal, childId: string): boolean;
633
+ export {};