@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,188 @@
1
+ import type { ExtensionRecord, InboxTarget, QueuedInput, Seq, ThreadInput } from '../records/journal.js';
2
+ import type { AppendEntry, Journal } from '../journal/index.js';
3
+ import type { DeepReadonly, ReadonlyJsonValue } from '../util/json.js';
4
+ import type { RouteAuthority } from './route.js';
5
+ import type { FreshOpening, ForkOpening } from './birth.js';
6
+ import { type Wake } from './wake.js';
7
+ /**
8
+ * Why a write-time callback refused its write, as data a host or plugin can act on without parsing
9
+ * `message`: the text a person is shown, an optional `code` for the cause when a reader branches on
10
+ * one, and optional `data` for its facts.
11
+ */
12
+ export type Refusal = {
13
+ readonly message: string;
14
+ readonly code?: string;
15
+ readonly data?: ReadonlyJsonValue;
16
+ };
17
+ /**
18
+ * What a write-time callback returns: the plugin rows to add to the write's group, or `{ refuse }`,
19
+ * its explicit veto, which writes nothing and gives the {@link Refusal} to whoever asked. Anything
20
+ * the callback throws is a failure, not a veto: it propagates as it was thrown.
21
+ */
22
+ export type RowsResult = readonly AppendEntry<'ext'>[] | {
23
+ readonly refuse: Refusal;
24
+ };
25
+ /** Whether a callback vetoed its write. */
26
+ export declare const isVeto: (result: RowsResult) => result is {
27
+ readonly refuse: Refusal;
28
+ };
29
+ /** What every write that queues input tells its callback: the thread, where the input waits, and the run its cause joins. */
30
+ type WriteBase = {
31
+ readonly threadId: string;
32
+ /** Where the input waits, which `send` decides inside the write; a creation always queues for `next-turn`. */
33
+ readonly target: InboxTarget;
34
+ /** The run request the write's cause joins or opens; `null` when it brings none. */
35
+ readonly runId: string | null;
36
+ };
37
+ /**
38
+ * What a write-time callback is told, by the write it runs in. A creation or a fork carries the
39
+ * resolved opening it records, a frozen copy, so a callback reads what core records and cannot
40
+ * change it; `inputId` is the first input's id, `null` when the write queues none. A `send`
41
+ * carries the id it queues.
42
+ */
43
+ export type RowsWrite = (WriteBase & {
44
+ readonly kind: 'create';
45
+ readonly inputId: string | null;
46
+ readonly opening: DeepReadonly<FreshOpening>;
47
+ }) | (WriteBase & {
48
+ readonly kind: 'fork';
49
+ readonly inputId: string | null;
50
+ readonly opening: DeepReadonly<ForkOpening>;
51
+ }) | (WriteBase & {
52
+ readonly kind: 'send';
53
+ readonly inputId: string;
54
+ });
55
+ /**
56
+ * A write-time callback on a write that queues input — `create`, `fork` or `send`: run inside the
57
+ * write's transaction, once the write's own rows are built and before anything is stored, it returns
58
+ * plugin rows for the same group, or vetoes the write by returning `{ refuse }` (see
59
+ * {@link RowsResult}). Synchronous, as every `transact` callback is.
60
+ */
61
+ export type WriteRows = (write: RowsWrite) => RowsResult;
62
+ /**
63
+ * What `send` returns for input it accepted: the input's id and `queuedAt`, the seq of the row that
64
+ * queued it. The id is the one the caller passed or the one `send` made.
65
+ */
66
+ export type InputReceipt = {
67
+ readonly inputId: string;
68
+ readonly queuedAt: Seq;
69
+ };
70
+ /**
71
+ * What a `send` did: queued the input, with the run request its wake joined or opened in the same
72
+ * write (`runId`, `null` when it had no wake; see `waitForRun`); found its id already known and
73
+ * wrote nothing, its receipt naming the row that queued it the first time; or wrote nothing because
74
+ * its `rows` callback vetoed, for `refusal`.
75
+ */
76
+ export type SendOutcome = ({
77
+ readonly status: 'queued';
78
+ readonly runId: string | null;
79
+ } & InputReceipt) | ({
80
+ readonly status: 'known';
81
+ } & InputReceipt) | {
82
+ readonly status: 'refused';
83
+ readonly refusal: Refusal;
84
+ };
85
+ /**
86
+ * How `send` queues: under `id`, attributed to `source`, with `rows` added to its write, and with
87
+ * `wake`, a cause in the same write that asks the thread to run (`{}` for a person's). A sourced
88
+ * input needs its `id`.
89
+ */
90
+ export type SendOptions = {
91
+ readonly id?: string;
92
+ readonly source?: ExtensionRecord;
93
+ readonly rows?: WriteRows;
94
+ readonly wake?: Wake;
95
+ /**
96
+ * Where the input waits; omitted, admission places it (a running turn's next step, else a turn of
97
+ * its own). `next-turn` waits for a turn of its own even while a run holds the thread. `next-step`
98
+ * joins the next model step whichever turn takes it: a running turn's, a resumed turn's once its
99
+ * parked calls are answered, or a new turn's first step together with what waits for that turn.
100
+ */
101
+ readonly target?: InboxTarget;
102
+ };
103
+ /**
104
+ * A write-time callback on a `withdraw`: run inside its transaction, told whether the input was
105
+ * still queued and is withdrawn by this write, it returns plugin rows for the same group, written
106
+ * either way, or vetoes the withdrawal by returning `{ refuse }` (see {@link RowsResult}).
107
+ */
108
+ export type WithdrawRows = (write: {
109
+ readonly threadId: string;
110
+ readonly withdrawn: boolean;
111
+ }) => RowsResult;
112
+ export type WithdrawOptions = {
113
+ readonly rows?: WithdrawRows;
114
+ };
115
+ /**
116
+ * What a `withdraw` did: took the input out of the queue (`withdrawn`); found it not queued, being
117
+ * claimed, discarded or unknown (`not-queued`), writing only what `rows` returned; or wrote nothing
118
+ * because `rows` vetoed, with its `refusal`.
119
+ */
120
+ export type WithdrawOutcome = {
121
+ readonly status: 'withdrawn' | 'not-queued';
122
+ } | {
123
+ readonly status: 'refused';
124
+ readonly refusal: Refusal;
125
+ };
126
+ /**
127
+ * Input waiting for a boundary, held in the journal rather than in memory.
128
+ *
129
+ * Every mutation is an `inbox/spliced` event, so a message queued while the agent was busy survives
130
+ * a crash exactly like the conversation does. `next-turn` is claimed only by a turn's first step,
131
+ * when that step asks the model: a turn that opens by answering calls an earlier turn left leaves it
132
+ * for the next turn. `next-step` joins the next model step of whichever turn takes it: the turn in
133
+ * flight, which is what makes steering possible, a resumed turn once its calls are answered, or the
134
+ * first step of the next turn.
135
+ */
136
+ export declare class Inbox {
137
+ private readonly journal;
138
+ private readonly threadId;
139
+ constructor(journal: Journal, threadId: string);
140
+ private get queues();
141
+ private get state();
142
+ get nextTurn(): readonly QueuedInput[];
143
+ get nextStep(): readonly QueuedInput[];
144
+ /** The row that queued input `id`, or `undefined` when this thread was never handed that id. */
145
+ private queuedAt;
146
+ /** Everything waiting for a step to claim it, in the order it was sent. */
147
+ get pending(): QueuedInput[];
148
+ /**
149
+ * Idempotent durable input. The target is the sender's when it names one; otherwise execution
150
+ * admission chooses it (`target`), asked inside the write, as is whether the id was queued
151
+ * before: two sends of one id queue it once, and a known id calls no `rows`. Input attributed to
152
+ * a plugin (`source`) needs the id the plugin derived, since a redelivery must find it. `routes`
153
+ * checks a wake's route statement.
154
+ */
155
+ send(input: ThreadInput, target: () => InboxTarget, options?: SendOptions, routes?: RouteAuthority): Promise<SendOutcome>;
156
+ /**
157
+ * Discards one queued input by id, wherever it waits, deciding inside the write whether it is still
158
+ * queued; `rows` adds a plugin's rows to the same write either way (see {@link WithdrawRows}).
159
+ */
160
+ withdraw(id: string, options?: WithdrawOptions): Promise<WithdrawOutcome>;
161
+ /**
162
+ * The rows that discard everything pending, `next-step` first so a drained turn cannot pick it
163
+ * up: none when nothing waits. Built inside the write that carries them, a cancel's.
164
+ */
165
+ clearRows(): AppendEntry<'inbox/spliced'>[];
166
+ /**
167
+ * The batch one step will consume: everything queued for the next step, plus, when this boundary
168
+ * opens a turn, the head of what waits for one: a single unsourced input, or every consecutive
169
+ * sourced input at the head. The batch is ordered by seq; order holds within a batch, not across
170
+ * the whole queue, so `next-step` input sent after something still waiting for a turn can enter
171
+ * before it. A person's message is never skipped to collect plugin input waiting for a turn behind
172
+ * it, so sourced input left at `next-turn` (notice, notice, person, notice) opens three turns:
173
+ * `[N, N]`, `[U]`, `[N]`; with the notices at `next-step`, it opens one: `[N, N, U, N]`. With
174
+ * `sentBack`, a later step takes the next such batch too: a turn that opened by answering calls
175
+ * claimed nothing that waited for a turn, and once a stop check sent its answer back, what waits
176
+ * could be what the check holds the answer for.
177
+ *
178
+ * Reading only. The input leaves the queue when its `input/message` is appended, so recording it
179
+ * and claiming it are the same event and a crash between them is not a thing that can happen.
180
+ */
181
+ peek(target: InboxTarget, sentBack?: boolean): QueuedInput[];
182
+ /**
183
+ * Array-splice semantics, normalized against the inbox as it stands: the row that records it, or
184
+ * nothing to record. Built inside a write, so the indices are the ones the row lands on.
185
+ */
186
+ private spliceEntry;
187
+ }
188
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What the rest of the package may use of recorded state: the folds of a thread's rows, the queries
3
+ * over them, and the writes that need no activation (the inbox, closing an interrupted turn, the
4
+ * surface replacement writer). Nothing here runs a turn or imports Cordis; the loop executes against
5
+ * these and the services read them. The journal substrate itself is `journal/`, imported directly.
6
+ */
7
+ export * from './thread.js';
8
+ export * from './turns.js';
9
+ export * from './dispatches.js';
10
+ export * from './waits.js';
11
+ export * from './confirmations.js';
12
+ export * from './prompt.js';
13
+ export * from './inputs.js';
14
+ export * from './installations.js';
15
+ export * from './surface.js';
16
+ export * from './requests.js';
17
+ export * from './holds.js';
18
+ export * from './chain.js';
19
+ export * from './route.js';
20
+ export * from './errors.js';
21
+ export * from './limits.js';
22
+ export * from './birth.js';
23
+ export * from './continuation.js';
24
+ export * from './decide.js';
25
+ export * from './forks.js';
26
+ export * from './inbox.js';
27
+ export * from './recovery.js';
28
+ export * from './replace.js';
29
+ export * from './surfaceRead.js';
30
+ export * from './summary.js';
31
+ export * from './wake.js';
@@ -0,0 +1,58 @@
1
+ import type { InboxTarget, QueuedInput, Seq } from '../records/journal.js';
2
+ import type { ReadonlyState } from '../util/foldState.js';
3
+ import type { Reducer, ThreadState } from './thread.js';
4
+ export type InboxState = Record<InboxTarget, QueuedInput[]>;
5
+ /**
6
+ * Input waiting for a turn or a step boundary. Durable, so a crash does not lose a queued message.
7
+ * A fork starts with nothing queued: its source's queued input is not the fork's.
8
+ */
9
+ export declare const inbox: Reducer<InboxState>;
10
+ /** Where one input id's life is recorded: the row that queued it, and the step's row that claimed it. */
11
+ export type InputRows = {
12
+ readonly queuedAt: Seq;
13
+ readonly claimedAt: Seq | null;
14
+ };
15
+ /**
16
+ * Every input id this thread was ever handed: the row that queued it and, once a step took it, the
17
+ * `input/message` that claimed it. Never forgets: this is what makes `send` with an explicit id
18
+ * idempotent across a re-dispatch or a restart, and why a withdrawn or cancelled id stays
19
+ * spent. A fork starts over: the ids its source was handed are the source's.
20
+ */
21
+ export declare const inputs: Reducer<Map<string, InputRows>>;
22
+ /**
23
+ * What became of the input id a thread was handed: `unknown` when it never was; `queued` while it
24
+ * waits, for `target`; `claimed` once a step took it; `discarded` when it left the queue unclaimed,
25
+ * withdrawn or cleared by a cancel. Each names the row that queued it, and a claim the
26
+ * `input/message` that took it. A discarded or claimed id stays spent: it is never queued again.
27
+ */
28
+ export type InputFate = {
29
+ readonly state: 'unknown';
30
+ } | {
31
+ readonly state: 'queued';
32
+ readonly queuedAt: Seq;
33
+ readonly target: InboxTarget;
34
+ } | {
35
+ readonly state: 'claimed';
36
+ readonly queuedAt: Seq;
37
+ readonly claimedAt: Seq;
38
+ } | {
39
+ readonly state: 'discarded';
40
+ readonly queuedAt: Seq;
41
+ };
42
+ /**
43
+ * The fate of input `id` from a thread's state: the one answer to "what became of input X", read
44
+ * inside a write or a contributor from the state the journal folds, or through `ThreadView.input`.
45
+ * A fork's own ids only: its source's are the source's.
46
+ */
47
+ export declare function inputFate(state: ReadonlyState<Pick<ThreadState, 'inputs' | 'inbox'>>, id: string): InputFate;
48
+ /**
49
+ * Whether a fork has yet to claim the task it was created with. A fork cut at a request inherits a
50
+ * conversation that ends on input its source is answering. Created to regenerate that answer, the
51
+ * fork owes it; created with a task, it owes only the task. So a task discarded before it was
52
+ * claimed — by `cancel()` — leaves the fork with nothing to do, rather than answering its source's
53
+ * request. Any input the fork records settles it.
54
+ */
55
+ export declare const forkTask: Reducer<{
56
+ spawnSeq: Seq | null;
57
+ unclaimed: boolean;
58
+ }>;
@@ -0,0 +1,28 @@
1
+ import type { InstallationLifetime } from '../records/journal.js';
2
+ import type { JsonValue } from '../util/json.js';
3
+ import type { Reducer } from './thread.js';
4
+ /** One installation a thread holds, as its folds read it. */
5
+ export type InstallationRecord = {
6
+ readonly installationId: string;
7
+ readonly presetId: string;
8
+ /** The validated configuration, defaults included: exactly what `setup` receives. */
9
+ readonly config: JsonValue;
10
+ /**
11
+ * `defining` for one recorded as such in its thread's spawn row, on this thread or on the one a
12
+ * fork inherited it from, which cannot be removed; `configurable` for any other, one applied
13
+ * later included.
14
+ */
15
+ readonly lifetime: InstallationLifetime;
16
+ };
17
+ /** A thread's installations: the current ones in application order, and every id it ever used. */
18
+ export type InstallationsState = {
19
+ readonly current: Map<string, InstallationRecord>;
20
+ readonly used: Set<string>;
21
+ };
22
+ /**
23
+ * The preset installations that define a thread's plugins. A fork inherits its source's
24
+ * installations and reserved ids at the cut: its own spawn row carries none, and the source's spawn
25
+ * row, which it folds through lineage, keeps a defining installation defining on every fork.
26
+ * Installations never move, so application order is also the order they are restored in.
27
+ */
28
+ export declare const installations: Reducer<InstallationsState>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What bounds a runaway turn. Each is a number the loop can hand back to the model as a tool result
3
+ * or a turn ending it can react to; together with the depth cap they bound total spend.
4
+ */
5
+ export type TurnLimits = {
6
+ /** Positive finite integer: steps in one thread's turn before it stops with `max-steps`. */
7
+ maxStepsPerTurn: number;
8
+ /** Non-negative finite integer: nesting below a root. Zero forbids delegation; each hop is one level. */
9
+ maxThreadDepth: number;
10
+ /** Positive finite integer: tool calls dispatched at once within one step; the rest wait for a slot. */
11
+ maxParallelToolCalls: number;
12
+ };
13
+ export declare const DEFAULT_TURN_LIMITS: TurnLimits;
14
+ export declare const resolveLimits: (overrides?: Partial<TurnLimits>) => TurnLimits;
@@ -0,0 +1,13 @@
1
+ import type { ToolSpec } from '../llm/primitives.js';
2
+ import type { PromptBlock } from '../llm/prompt.js';
3
+ import type { Reducer } from './thread.js';
4
+ /**
5
+ * The system prompt a thread sends: the latest `thread/prompt` row, or none yet. A fork inherits
6
+ * it and never renders its own, so it sends its source's exact prompt.
7
+ */
8
+ export declare const threadPrompt: Reducer<PromptBlock[] | null>;
9
+ /**
10
+ * The tool specifications a thread's requests send: the latest `thread/tools` row, or none before
11
+ * its first request. Read at a request's seq, what that request sent. A fork inherits it.
12
+ */
13
+ export declare const threadTools: Reducer<readonly ToolSpec[] | null>;
@@ -0,0 +1,7 @@
1
+ import type { Journal } from '../journal/index.js';
2
+ import type { TurnLimits } from './limits.js';
3
+ /**
4
+ * Close a process-interrupted turn from journal state, including when no new execution is needed.
5
+ * Decided inside the write, so a turn something else closed meanwhile is not closed twice.
6
+ */
7
+ export declare function closeInterruptedTurn(journal: Journal, threadId: string, limits: TurnLimits): Promise<void>;
@@ -0,0 +1,33 @@
1
+ import type { Journal } from '../journal/index.js';
2
+ import { type JournalEventInput, type ReplacementTrigger, type Seq } from '../records/journal.js';
3
+ import { type RowRef } from './surface.js';
4
+ type ReplacedData = JournalEventInput['surface/replaced'];
5
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
6
+ /**
7
+ * One replacement as a strategy offers it: what a `surface/replaced` row records that the strategy
8
+ * decides — its kind, stand-in and `source` — and the rows it replaces, in surface order. The
9
+ * engine fills in the rest.
10
+ */
11
+ export type ReplacementInput = DistributiveOmit<ReplacedData, 'trigger' | 'turn' | 'step' | 'auxiliary_request_seq'> & {
12
+ /** The rows replaced: a contiguous run of the current surface for a `span`, one row for a `rewrite`. */
13
+ readonly source_seqs: readonly Seq[];
14
+ /** The `auxiliary/request` row the stand-in was made from, when a model call made it. */
15
+ readonly auxiliary_request_seq?: Seq | null;
16
+ };
17
+ /** Where a replacement is recorded: what caused it, and the turn and step, both `null` between turns. */
18
+ export type ReplacementContext = {
19
+ readonly trigger: ReplacementTrigger;
20
+ readonly turn: number | null;
21
+ readonly step: number | null;
22
+ };
23
+ /**
24
+ * The one way a replacement reaches the journal: appends `replacements` as one atomic group on
25
+ * `threadId`, each with the context filled in. The group is judged inside the write, against the
26
+ * durable surface, each row against the surface the previous one left, and refused whole with a
27
+ * {@link ReplacementRefusedError} when one breaks a rule; nothing of it is written then. Counts
28
+ * nothing and judges nothing of its own: the rules are the surface's (`judgeGroup`).
29
+ *
30
+ * The caller holds the thread's lease; `runSurfacePrepare` checks it before recording.
31
+ */
32
+ export declare function replaceSurface(journal: Journal, threadId: string, context: ReplacementContext, replacements: readonly ReplacementInput[]): Promise<RowRef[]>;
33
+ export {};
@@ -0,0 +1,129 @@
1
+ import type { CancelIntent, RunChain, RunOutcomeKind, RunSettledReason, Seq } from '../records/journal.js';
2
+ import type { InputFate } from './inputs.js';
3
+ import type { Reducer } from './thread.js';
4
+ /** One `run/cause` row as the request fold keeps it. */
5
+ export type RunCause = {
6
+ readonly seq: Seq;
7
+ /** The row's timestamp: how old the cause is, which the startup policy judges. */
8
+ readonly at: string;
9
+ readonly inputId: string | null;
10
+ readonly releases: boolean;
11
+ readonly chain: RunChain;
12
+ };
13
+ /** The request a thread is authorized to run, with every cause it holds, residual ones first. */
14
+ export type PendingRun = {
15
+ readonly runId: string;
16
+ /** The `run/requested` row. */
17
+ readonly requestedAt: Seq;
18
+ readonly causes: readonly RunCause[];
19
+ };
20
+ /** One `run/settled` row as the request fold keeps it. */
21
+ export type RunSettlement = {
22
+ readonly runId: string;
23
+ readonly seq: Seq;
24
+ readonly outcome: RunOutcomeKind;
25
+ readonly reason: RunSettledReason;
26
+ readonly errorText: string | null;
27
+ readonly through: Seq;
28
+ readonly residual: readonly Seq[];
29
+ };
30
+ /** One `thread/cancel` row as the request fold keeps it. */
31
+ export type CancelRecord = {
32
+ readonly seq: Seq;
33
+ readonly cancelId: string;
34
+ readonly intent: CancelIntent;
35
+ readonly runId: string | null;
36
+ readonly reason: string;
37
+ };
38
+ /**
39
+ * A thread's run requests, folded from its `run/*` and `thread/cancel` rows: the pending request,
40
+ * the first cancel that captured it, the latest settlement and user cancel, the latest releasing
41
+ * cause, and every request it ever
42
+ * opened with its settlement, so a waiter can read any run by id. A row that breaks the request
43
+ * rules (a cause or settlement for a run that is not pending, a request opened over a pending one)
44
+ * is kept in `inconsistencies` rather than thrown: core's fold is fatal, and a bad row must not
45
+ * stop the thread from being read.
46
+ */
47
+ export type RequestsState = {
48
+ pending: PendingRun | null;
49
+ /**
50
+ * The first cancel row naming the pending request's execution, whichever its intent: what a
51
+ * recovery settles that request by when the process died before its execution's finalization did.
52
+ * The first capture fixes the intent; a later cancel joining it changes nothing here.
53
+ */
54
+ pendingCancel: CancelRecord | null;
55
+ latestSettlement: RunSettlement | null;
56
+ latestUserCancel: CancelRecord | null;
57
+ /** The seq of the latest cause that releases holds, on any request. */
58
+ latestReleasing: Seq | null;
59
+ /** Every request by id: its `run/requested` row, and its settlement once it has one. */
60
+ readonly runs: Map<string, {
61
+ readonly requestedAt: Seq;
62
+ settlement: RunSettlement | null;
63
+ }>;
64
+ /**
65
+ * The latest `turn/start`: the run it served and the attempt cutoff of the execution that opened
66
+ * it, which a recovery settles a failure recorded before a crash with.
67
+ */
68
+ latestTurn: {
69
+ readonly seq: Seq;
70
+ readonly runId: string;
71
+ readonly attemptCutoff: Seq;
72
+ } | null;
73
+ /**
74
+ * The turns of the pending request in a row, since its latest releasing cause, that ended
75
+ * `interrupted` with the activation or the judgment as the cause; an abandonment by recovery leaves
76
+ * the count as it was. What an
77
+ * entry decision spends its repairs against: a request held on an interrupted turn that was
78
+ * already repaired is not repaired again until a releasing cause releases it.
79
+ */
80
+ interruptions: number;
81
+ /** The causes a settlement carried over, until the successor request it opened takes them. */
82
+ carried: readonly RunCause[];
83
+ readonly inconsistencies: string[];
84
+ };
85
+ /**
86
+ * The request fold: core's {@link RequestsState} concern of `threadState`. A fork starts with none
87
+ * of its source's requests.
88
+ */
89
+ export declare const requests: Reducer<RequestsState>;
90
+ /** Where a run stands from its rows alone: pending, settled with its settlement, or unknown on this thread. */
91
+ export type DurableRunState = {
92
+ readonly state: 'pending';
93
+ } | {
94
+ readonly state: 'settled';
95
+ readonly settlement: RunSettlement;
96
+ } | {
97
+ readonly state: 'unknown';
98
+ };
99
+ export declare function durableRunState(state: RequestsState, runId: string): DurableRunState;
100
+ /**
101
+ * What a settlement decided, and where its execution's cutoffs fall, for {@link residualOf}: the
102
+ * attempt cutoff, the position the execution was admitted at, and the cancel's write, when a cancel
103
+ * settled the request and its write landed.
104
+ */
105
+ export type ResidualRule = {
106
+ readonly outcome: RunOutcomeKind;
107
+ readonly reason: RunSettledReason;
108
+ readonly attemptCutoff: Seq;
109
+ readonly cancelSeq: Seq | null;
110
+ };
111
+ /**
112
+ * The causes of `pending` a settlement carries over to a successor request, by seq. A cause whose
113
+ * input a step claimed, or that left the queue unclaimed, carries nothing whatever its position;
114
+ * of the rest:
115
+ *
116
+ * - `completed` carries the causes recorded after the attempt cutoff: a wake that landed while the
117
+ * execution was finishing runs once more;
118
+ * - `failed` carries only the releasing ones recorded after the cutoff: a person's message that
119
+ * arrived during the attempt runs, while the cause that started it, and a notice or a fire, does
120
+ * not retry a failure;
121
+ * - a cancel's carries those recorded after its write, which it did not clear, or, when that write
122
+ * failed and cleared nothing, those after the attempt cutoff;
123
+ * - an `obsolete` request carries nothing: its authority is gone, and a successor comes with causes
124
+ * of its own.
125
+ *
126
+ * `fate` reads an input's fate on the thread (`inputFate`). Input left queued with no cause runs
127
+ * again only when a new cause arrives.
128
+ */
129
+ export declare function residualOf(pending: PendingRun, rule: ResidualRule, fate: (inputId: string) => InputFate['state']): Seq[];
@@ -0,0 +1,61 @@
1
+ import type { ModelRoute } from '../llm/provider.js';
2
+ import type { ModelSelection } from '../llm/provider.js';
3
+ import type { Reducer } from './thread.js';
4
+ /**
5
+ * What a wake says about the route it runs on, checked by core inside the write that records it:
6
+ * `expect`, the route the caller was shown and did not change; `select`, the route to run on,
7
+ * folded over the thread's route as a creation's fields are, so a complete one is itself. A wake
8
+ * that states none runs on the thread's route as it is, unchecked.
9
+ */
10
+ export type RouteStatement = {
11
+ readonly expect: ModelRoute;
12
+ } | {
13
+ readonly select: ModelSelection;
14
+ };
15
+ /**
16
+ * The thread's route as a statement is checked against: the route, why it cannot run here
17
+ * (its provider is not registered), and whether a route change is accepted now — no run serving the
18
+ * pending request holds the thread, and no request is pending, the route cannot run, or the
19
+ * request is held by a failure or a cancellation.
20
+ */
21
+ export type Target = {
22
+ readonly route: ModelRoute;
23
+ readonly blocked: string | null;
24
+ readonly selectable: boolean;
25
+ };
26
+ /** What checks a route statement inside its write: the thread owner, which knows admission and the registry. */
27
+ export interface RouteAuthority {
28
+ /** The thread's target as its rows and the process stand now. */
29
+ target(threadId: string): Target;
30
+ /** `selection` folded over `base`; throws `RouteUnavailableError` when the provider is not registered. */
31
+ resolve(selection: ModelSelection, base: ModelRoute): ModelRoute;
32
+ }
33
+ /** A route statement does not match the thread's route as it stands, or would change it when it may not. */
34
+ export declare class RouteConflictError extends Error {
35
+ readonly threadId: string;
36
+ readonly route: ModelRoute;
37
+ constructor(threadId: string,
38
+ /** The thread's route when the statement was refused. */
39
+ route: ModelRoute, reason: string);
40
+ }
41
+ /** A route cannot run here: its provider is not registered. Nothing was written, or no turn opened. */
42
+ export declare class RouteUnavailableError extends Error {
43
+ readonly route: Pick<ModelRoute, 'provider'> & Partial<ModelRoute>;
44
+ constructor(route: Pick<ModelRoute, 'provider'> & Partial<ModelRoute>);
45
+ }
46
+ /** Whether two routes are the same tuple; a `null` effort (the provider's own default) is a value like any other. */
47
+ export declare const sameRoute: (a: ModelRoute, b: ModelRoute) => boolean;
48
+ /**
49
+ * The route a cause records for `statement`, read inside its write: `null` when the cause leaves
50
+ * the thread's route as it is. `expect` needs the route runnable, then matching; `select` resolves
51
+ * over it, and a different route is written only while the target is selectable. Refusals throw,
52
+ * which refuses the whole write.
53
+ */
54
+ export declare function statedRoute(threadId: string, statement: RouteStatement, routes: RouteAuthority): ModelRoute | null;
55
+ /**
56
+ * The thread's route: the one its spawn row was born with, replaced by each cause that changed it.
57
+ * A lineage fold: a fork, born with none of its own, goes on with the route its inherited rows fold
58
+ * to at the cut, which keeps it on the model whose cache holds its history. Nothing else changes it:
59
+ * not turns, settlements, cancels or compaction. `null` only before a spawn row, which no thread lacks.
60
+ */
61
+ export declare const threadRoute: Reducer<ModelRoute | null>;
@@ -0,0 +1,16 @@
1
+ import type { Journal, ThreadSummaryCore } from '../journal/index.js';
2
+ import type { TurnLimits } from './limits.js';
3
+ /**
4
+ * A thread's catalog summary, from its folds as they stand: the spawn row's identity, how its last
5
+ * turn ended, the thread's route, whether a turn is open, whether a run would find
6
+ * work, and where its run requests stand — the pending one the run owner picks its candidates by at
7
+ * `threads.start`, from the catalog, so only those are loaded and run; the latest settlement and person's cancel the holds
8
+ * derive from; and the latest answer, which tells a parked caller an answer landed under it. The confirmations it waits on and the calls it
9
+ * suspended are listed as descriptors, enough to find them without the thread's rows; the full
10
+ * requests and dependencies come from the thread once it is loaded.
11
+ *
12
+ * Registered with the journal by the journal plugin, which is how `journal/` never learns what a
13
+ * turn is. Everything here is a thread-scoped fold, so the summary is a function of the thread's
14
+ * own lineage and nothing else.
15
+ */
16
+ export declare function summarizeThread(journal: Journal, threadId: string, limits: TurnLimits): ThreadSummaryCore;