@leuduan/lagent 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +144 -2
  3. package/dist/chunks/2O7ZGEIT.js +1 -0
  4. package/dist/chunks/2OSESBIL.js +1 -0
  5. package/dist/chunks/34KW6VNQ.js +1 -0
  6. package/dist/chunks/37YOGDGY.js +1 -0
  7. package/dist/chunks/3LQHQRIU.js +6 -0
  8. package/dist/chunks/3QCW4WDJ.js +1 -0
  9. package/dist/chunks/4XVRUSCQ.js +1 -0
  10. package/dist/chunks/6ECI2GGV.js +1 -0
  11. package/dist/chunks/74HKUGRR.js +1 -0
  12. package/dist/chunks/ADHERZLW.js +2 -0
  13. package/dist/chunks/AP6Q4EPT.js +36 -0
  14. package/dist/chunks/BM3S37EZ.js +1 -0
  15. package/dist/chunks/C5LYCXJG.js +1 -0
  16. package/dist/chunks/CDQG7RKA.js +1 -0
  17. package/dist/chunks/D7E6EWIE.js +3 -0
  18. package/dist/chunks/DDANMY45.js +3 -0
  19. package/dist/chunks/DRYAN665.js +1 -0
  20. package/dist/chunks/DXFXAYDN.js +17 -0
  21. package/dist/chunks/EGZI4XQX.js +24 -0
  22. package/dist/chunks/ENWFSU27.js +41 -0
  23. package/dist/chunks/G6RXC3AL.js +1 -0
  24. package/dist/chunks/G74AGRAJ.js +15 -0
  25. package/dist/chunks/GQGNVSKB.js +1 -0
  26. package/dist/chunks/IJ2WNMD5.js +7 -0
  27. package/dist/chunks/J5S4URAW.js +1 -0
  28. package/dist/chunks/JPZFKSWT.js +1 -0
  29. package/dist/chunks/KESCTXGO.js +5 -0
  30. package/dist/chunks/L3N4FIEN.js +1 -0
  31. package/dist/chunks/NAOUTU7A.js +4 -0
  32. package/dist/chunks/NDIM7MEW.js +1 -0
  33. package/dist/chunks/O4PPOM5Z.js +2 -0
  34. package/dist/chunks/OVZFGILJ.js +1 -0
  35. package/dist/chunks/P5ZHHOOM.js +6 -0
  36. package/dist/chunks/PUSUPTAT.js +1 -0
  37. package/dist/chunks/QMMLQJBS.js +1 -0
  38. package/dist/chunks/RK3VP2Q4.js +3 -0
  39. package/dist/chunks/SGGMBSBA.js +1 -0
  40. package/dist/chunks/SL2YLB2F.js +1 -0
  41. package/dist/chunks/TOOIB6J2.js +1 -0
  42. package/dist/chunks/TYTQRLTX.js +1 -0
  43. package/dist/chunks/UC3FVVJ2.js +5 -0
  44. package/dist/chunks/UCTEU62F.js +1 -0
  45. package/dist/chunks/UD3VJER6.js +1 -0
  46. package/dist/chunks/UKXMCHHT.js +1 -0
  47. package/dist/chunks/WUUKTSRT.js +7 -0
  48. package/dist/chunks/X65X4KP5.js +7 -0
  49. package/dist/chunks/YIR5MYGU.js +1 -0
  50. package/dist/chunks/YLNJXQ3Z.js +1 -0
  51. package/dist/context.d.ts +101 -0
  52. package/dist/index.d.ts +47 -0
  53. package/dist/index.js +77 -0
  54. package/dist/journal/catalog.d.ts +112 -0
  55. package/dist/journal/forkChain.d.ts +16 -0
  56. package/dist/journal/index.d.ts +15 -0
  57. package/dist/journal/journal.d.ts +475 -0
  58. package/dist/journal/projection.d.ts +87 -0
  59. package/dist/journal/store.d.ts +181 -0
  60. package/dist/kit/claim.d.ts +13 -0
  61. package/dist/kit/drain.d.ts +10 -0
  62. package/dist/kit/extension.d.ts +180 -0
  63. package/dist/kit/grants.d.ts +9 -0
  64. package/dist/kit/modes.d.ts +65 -0
  65. package/dist/kit/retries.d.ts +25 -0
  66. package/dist/kit/scope.d.ts +32 -0
  67. package/dist/kit/service.d.ts +7 -0
  68. package/dist/kit/strategy.d.ts +10 -0
  69. package/dist/kit/timers.d.ts +43 -0
  70. package/dist/kit/tool.d.ts +72 -0
  71. package/dist/llm/client.d.ts +135 -0
  72. package/dist/llm/content.d.ts +52 -0
  73. package/dist/llm/door.d.ts +21 -0
  74. package/dist/llm/door.js +1 -0
  75. package/dist/llm/failure.d.ts +82 -0
  76. package/dist/llm/index.d.ts +16 -0
  77. package/dist/llm/primitives.d.ts +286 -0
  78. package/dist/llm/prompt.d.ts +21 -0
  79. package/dist/llm/provider.d.ts +63 -0
  80. package/dist/llm/readLedger.d.ts +24 -0
  81. package/dist/llm/request.d.ts +58 -0
  82. package/dist/loop/agent.d.ts +134 -0
  83. package/dist/loop/auxiliary.d.ts +54 -0
  84. package/dist/loop/chain.d.ts +46 -0
  85. package/dist/loop/chunks.d.ts +27 -0
  86. package/dist/loop/continuation.d.ts +166 -0
  87. package/dist/loop/decide.d.ts +64 -0
  88. package/dist/loop/errors.d.ts +162 -0
  89. package/dist/loop/forks.d.ts +61 -0
  90. package/dist/loop/holds.d.ts +104 -0
  91. package/dist/loop/hooks.d.ts +241 -0
  92. package/dist/loop/inbox.d.ts +188 -0
  93. package/dist/loop/index.d.ts +37 -0
  94. package/dist/loop/limits.d.ts +14 -0
  95. package/dist/loop/opening.d.ts +42 -0
  96. package/dist/loop/prepare.d.ts +30 -0
  97. package/dist/loop/projections.d.ts +307 -0
  98. package/dist/loop/replace.d.ts +33 -0
  99. package/dist/loop/requests.d.ts +129 -0
  100. package/dist/loop/route.d.ts +53 -0
  101. package/dist/loop/runtime.d.ts +85 -0
  102. package/dist/loop/state.d.ts +70 -0
  103. package/dist/loop/strategy.d.ts +71 -0
  104. package/dist/loop/summary.d.ts +3 -0
  105. package/dist/loop/surface.d.ts +153 -0
  106. package/dist/loop/threadState.d.ts +72 -0
  107. package/dist/loop/tool.d.ts +101 -0
  108. package/dist/loop/toolCalls.d.ts +42 -0
  109. package/dist/loop/wake.d.ts +32 -0
  110. package/dist/models/config/agent.d.ts +18 -0
  111. package/dist/models/config/prompt.d.ts +18 -0
  112. package/dist/models/door.d.ts +12 -0
  113. package/dist/models/door.js +1 -0
  114. package/dist/models/index.d.ts +7 -0
  115. package/dist/models/jsonSchema.d.ts +7 -0
  116. package/dist/models/wire/journal.d.ts +2772 -0
  117. package/dist/models/wire/primitives.d.ts +65 -0
  118. package/dist/plugin.d.ts +53 -0
  119. package/dist/plugin.js +1 -0
  120. package/dist/plugins/agentsMd.d.ts +76 -0
  121. package/dist/plugins/agentsMd.js +1 -0
  122. package/dist/plugins/ask/askQuestion.d.ts +9 -0
  123. package/dist/plugins/ask/index.d.ts +26 -0
  124. package/dist/plugins/ask/index.js +1 -0
  125. package/dist/plugins/ask/service.d.ts +125 -0
  126. package/dist/plugins/commands/background.d.ts +8 -0
  127. package/dist/plugins/commands/foreground.d.ts +4 -0
  128. package/dist/plugins/commands/index.d.ts +40 -0
  129. package/dist/plugins/commands/index.js +1 -0
  130. package/dist/plugins/commands/output.d.ts +115 -0
  131. package/dist/plugins/commands/record.d.ts +549 -0
  132. package/dist/plugins/commands/service.d.ts +314 -0
  133. package/dist/plugins/commands/shell.d.ts +25 -0
  134. package/dist/plugins/compaction/checkpoint.d.ts +91 -0
  135. package/dist/plugins/compaction/config.d.ts +133 -0
  136. package/dist/plugins/compaction/estimate.d.ts +29 -0
  137. package/dist/plugins/compaction/index.d.ts +2 -0
  138. package/dist/plugins/compaction/index.js +7 -0
  139. package/dist/plugins/compaction/log.d.ts +61 -0
  140. package/dist/plugins/compaction/planner.d.ts +207 -0
  141. package/dist/plugins/compaction/preset.d.ts +86 -0
  142. package/dist/plugins/compaction/prune.d.ts +9 -0
  143. package/dist/plugins/compaction/records.d.ts +227 -0
  144. package/dist/plugins/compaction/segments.d.ts +23 -0
  145. package/dist/plugins/compaction/shared.d.ts +14 -0
  146. package/dist/plugins/compaction/summarize.d.ts +13 -0
  147. package/dist/plugins/dateAndBranch.d.ts +47 -0
  148. package/dist/plugins/dateAndBranch.js +1 -0
  149. package/dist/plugins/delegations/answers.d.ts +39 -0
  150. package/dist/plugins/delegations/assignmentKey.d.ts +22 -0
  151. package/dist/plugins/delegations/cleanup.d.ts +161 -0
  152. package/dist/plugins/delegations/constraint.d.ts +76 -0
  153. package/dist/plugins/delegations/index.d.ts +39 -0
  154. package/dist/plugins/delegations/index.js +1 -0
  155. package/dist/plugins/delegations/notices.d.ts +261 -0
  156. package/dist/plugins/delegations/obligations.d.ts +210 -0
  157. package/dist/plugins/delegations/record.d.ts +632 -0
  158. package/dist/plugins/delegations/request.d.ts +381 -0
  159. package/dist/plugins/delegations/role.d.ts +30 -0
  160. package/dist/plugins/delegations/service.d.ts +562 -0
  161. package/dist/plugins/delegations/standing.d.ts +19 -0
  162. package/dist/plugins/delegations/stopCheck.d.ts +21 -0
  163. package/dist/plugins/delegations/testing.d.ts +16 -0
  164. package/dist/plugins/delegations/tools.d.ts +71 -0
  165. package/dist/plugins/delegations/waitBook.d.ts +116 -0
  166. package/dist/plugins/delegations/waits.d.ts +118 -0
  167. package/dist/plugins/diagnostics/digest.d.ts +14 -0
  168. package/dist/plugins/diagnostics/index.d.ts +68 -0
  169. package/dist/plugins/diagnostics/index.js +1 -0
  170. package/dist/plugins/historyRecall/history.d.ts +9 -0
  171. package/dist/plugins/historyRecall/index.d.ts +31 -0
  172. package/dist/plugins/historyRecall/index.js +1 -0
  173. package/dist/plugins/historyRecall/render.d.ts +34 -0
  174. package/dist/plugins/historyRecall/tools.d.ts +4 -0
  175. package/dist/plugins/mcp/catalog.d.ts +36 -0
  176. package/dist/plugins/mcp/config.d.ts +63 -0
  177. package/dist/plugins/mcp/connection.d.ts +53 -0
  178. package/dist/plugins/mcp/errors.d.ts +32 -0
  179. package/dist/plugins/mcp/index.d.ts +33 -0
  180. package/dist/plugins/mcp/index.js +5 -0
  181. package/dist/plugins/mcp/mount.d.ts +98 -0
  182. package/dist/plugins/mcp/names.d.ts +25 -0
  183. package/dist/plugins/mcp/render.d.ts +29 -0
  184. package/dist/plugins/mcp/slots.d.ts +15 -0
  185. package/dist/plugins/mcp/stdio.d.ts +49 -0
  186. package/dist/plugins/mcp/tool.d.ts +41 -0
  187. package/dist/plugins/providers/anthropic.d.ts +175 -0
  188. package/dist/plugins/providers/anthropicMessages.d.ts +65 -0
  189. package/dist/plugins/providers/codex.d.ts +60 -0
  190. package/dist/plugins/providers/codexAuth.d.ts +116 -0
  191. package/dist/plugins/providers/deepseek.d.ts +55 -0
  192. package/dist/plugins/providers/door.d.ts +61 -0
  193. package/dist/plugins/providers/door.js +1 -0
  194. package/dist/plugins/providers/failure.d.ts +23 -0
  195. package/dist/plugins/providers/gateway.d.ts +23 -0
  196. package/dist/plugins/providers/index.d.ts +6 -0
  197. package/dist/plugins/providers/openaiChat.d.ts +62 -0
  198. package/dist/plugins/providers/openaiResponses.d.ts +100 -0
  199. package/dist/plugins/providers/opencodeCopilot.d.ts +23 -0
  200. package/dist/plugins/providers/opencodeGo.d.ts +98 -0
  201. package/dist/plugins/providers/shared.d.ts +104 -0
  202. package/dist/plugins/providers/stream.d.ts +154 -0
  203. package/dist/plugins/routeContext.d.ts +22 -0
  204. package/dist/plugins/routeContext.js +1 -0
  205. package/dist/plugins/schedules/index.d.ts +21 -0
  206. package/dist/plugins/schedules/index.js +5 -0
  207. package/dist/plugins/schedules/record.d.ts +396 -0
  208. package/dist/plugins/schedules/service.d.ts +120 -0
  209. package/dist/plugins/schedules/time.d.ts +26 -0
  210. package/dist/plugins/schedules/tools.d.ts +6 -0
  211. package/dist/plugins/skills/discovery.d.ts +54 -0
  212. package/dist/plugins/skills/index.d.ts +31 -0
  213. package/dist/plugins/skills/index.js +1 -0
  214. package/dist/plugins/skills/tool.d.ts +11 -0
  215. package/dist/plugins/store/durableObject.d.ts +23 -0
  216. package/dist/plugins/store/durableObject.js +1 -0
  217. package/dist/plugins/store/durableObjectConnection.d.ts +27 -0
  218. package/dist/plugins/store/memory.d.ts +29 -0
  219. package/dist/plugins/store/sql.d.ts +59 -0
  220. package/dist/plugins/store/sqlite.d.ts +31 -0
  221. package/dist/plugins/store/sqlite.js +1 -0
  222. package/dist/plugins/subAgents/availableRoutes.d.ts +53 -0
  223. package/dist/plugins/subAgents/fork.d.ts +32 -0
  224. package/dist/plugins/subAgents/index.d.ts +67 -0
  225. package/dist/plugins/subAgents/index.js +1 -0
  226. package/dist/plugins/subAgents/tool.d.ts +38 -0
  227. package/dist/plugins/toolPolicy/index.d.ts +61 -0
  228. package/dist/plugins/toolPolicy/index.js +1 -0
  229. package/dist/plugins/tools/editFiles.d.ts +128 -0
  230. package/dist/plugins/tools/fsRead.d.ts +17 -0
  231. package/dist/plugins/tools/html.d.ts +23 -0
  232. package/dist/plugins/tools/index.d.ts +59 -0
  233. package/dist/plugins/tools/index.js +1 -0
  234. package/dist/plugins/tools/network.d.ts +23 -0
  235. package/dist/plugins/tools/ripgrep.d.ts +20 -0
  236. package/dist/plugins/tools/textEdit.d.ts +67 -0
  237. package/dist/plugins/tools/web.d.ts +32 -0
  238. package/dist/plugins/truncateToolOutput.d.ts +26 -0
  239. package/dist/plugins/truncateToolOutput.js +1 -0
  240. package/dist/plugins/usage/index.d.ts +24 -0
  241. package/dist/plugins/usage/index.js +1 -0
  242. package/dist/plugins/usage/tracker.d.ts +34 -0
  243. package/dist/plugins/verify/facts.d.ts +356 -0
  244. package/dist/plugins/verify/index.d.ts +75 -0
  245. package/dist/plugins/verify/index.js +1 -0
  246. package/dist/plugins/verify/service.d.ts +90 -0
  247. package/dist/plugins/workflows/assignment.d.ts +16 -0
  248. package/dist/plugins/workflows/bindings.d.ts +95 -0
  249. package/dist/plugins/workflows/cleanup.d.ts +38 -0
  250. package/dist/plugins/workflows/definition.d.ts +184 -0
  251. package/dist/plugins/workflows/fold.d.ts +373 -0
  252. package/dist/plugins/workflows/index.d.ts +28 -0
  253. package/dist/plugins/workflows/index.js +6 -0
  254. package/dist/plugins/workflows/observations.d.ts +81 -0
  255. package/dist/plugins/workflows/participants.d.ts +143 -0
  256. package/dist/plugins/workflows/policy.d.ts +112 -0
  257. package/dist/plugins/workflows/providers.d.ts +146 -0
  258. package/dist/plugins/workflows/record.d.ts +2863 -0
  259. package/dist/plugins/workflows/routing.d.ts +116 -0
  260. package/dist/plugins/workflows/schema.d.ts +26 -0
  261. package/dist/plugins/workflows/service.d.ts +477 -0
  262. package/dist/plugins/workflows/submit.d.ts +8 -0
  263. package/dist/plugins/workflows/view.d.ts +103 -0
  264. package/dist/plugins/workflows/work.d.ts +21 -0
  265. package/dist/plugins/workspaceContext.d.ts +38 -0
  266. package/dist/plugins/workspaceContext.js +1 -0
  267. package/dist/presets/agents.d.ts +7 -0
  268. package/dist/presets/base.d.ts +10 -0
  269. package/dist/presets/codex.d.ts +60 -0
  270. package/dist/presets/index.d.ts +4 -0
  271. package/dist/presets/prompts.d.ts +56 -0
  272. package/dist/sandbox/absent.d.ts +32 -0
  273. package/dist/sandbox/client.d.ts +39 -0
  274. package/dist/sandbox/files.d.ts +28 -0
  275. package/dist/sandbox/index.d.ts +49 -0
  276. package/dist/sandbox/index.js +4 -0
  277. package/dist/sandbox/mode.d.ts +57 -0
  278. package/dist/sandbox/policy.d.ts +86 -0
  279. package/dist/sandbox/protocol.d.ts +107 -0
  280. package/dist/sandbox/service.d.ts +143 -0
  281. package/dist/sandbox/worker.d.ts +12 -0
  282. package/dist/sandbox/worker.js +1 -0
  283. package/dist/services/admission.d.ts +174 -0
  284. package/dist/services/agents.d.ts +37 -0
  285. package/dist/services/birth.d.ts +220 -0
  286. package/dist/services/contributions.d.ts +73 -0
  287. package/dist/services/core.d.ts +34 -0
  288. package/dist/services/journal.d.ts +26 -0
  289. package/dist/services/launches.d.ts +104 -0
  290. package/dist/services/llm.d.ts +80 -0
  291. package/dist/services/owner.d.ts +367 -0
  292. package/dist/services/preset.d.ts +154 -0
  293. package/dist/services/presets.d.ts +139 -0
  294. package/dist/services/prompts.d.ts +67 -0
  295. package/dist/services/runEvents.d.ts +79 -0
  296. package/dist/services/thread.d.ts +267 -0
  297. package/dist/services/threadActivation.d.ts +100 -0
  298. package/dist/services/threadDirs.d.ts +38 -0
  299. package/dist/services/threadView.d.ts +92 -0
  300. package/dist/services/threads.d.ts +449 -0
  301. package/dist/services/tools.d.ts +41 -0
  302. package/dist/sys/environment.d.ts +47 -0
  303. package/dist/sys/git.d.ts +60 -0
  304. package/dist/sys/paths.d.ts +56 -0
  305. package/dist/sys/spawn.d.ts +176 -0
  306. package/dist/testing/clock.d.ts +17 -0
  307. package/dist/testing/fakeLlm.d.ts +74 -0
  308. package/dist/testing/fedLlm.d.ts +32 -0
  309. package/dist/testing/helpers.d.ts +344 -0
  310. package/dist/testing/index.d.ts +13 -0
  311. package/dist/testing/index.js +1 -0
  312. package/dist/testing/processes.d.ts +13 -0
  313. package/dist/testing/sandbox.d.ts +71 -0
  314. package/dist/testing/settlement.d.ts +6 -0
  315. package/dist/testing/tmpDirs.d.ts +17 -0
  316. package/dist/util/async.d.ts +8 -0
  317. package/dist/util/diff.d.ts +25 -0
  318. package/dist/util/dispatch.d.ts +8 -0
  319. package/dist/util/errors.d.ts +28 -0
  320. package/dist/util/foldState.d.ts +17 -0
  321. package/dist/util/freeze.d.ts +2 -0
  322. package/dist/util/ids.d.ts +2 -0
  323. package/dist/util/json.d.ts +37 -0
  324. package/dist/util/log.d.ts +6 -0
  325. package/dist/util/text.d.ts +21 -0
  326. package/dist/util/version.d.ts +2 -0
  327. package/package.json +175 -3
@@ -0,0 +1,116 @@
1
+ import type { CommandWork } from '../commands/index.js';
2
+ import { type EntryEvidence, type EvidenceNeeds } from './bindings.js';
3
+ import { type CanonicalDefinition } from './definition.js';
4
+ import type { InstanceState, PendingDecision } from './fold.js';
5
+ import { type InstanceRowInput } from './record.js';
6
+ import type { ReadonlyState } from '../../util/foldState.js';
7
+ /**
8
+ * The decision a person owes, derived: a recovering attempt waits for its recovery decision; a
9
+ * gated step's ready result waits for its gate; an ungated one whose selected edge would exceed its
10
+ * target's allowance waits on exhaustion, marked with the transition it holds back. Nothing records
11
+ * a pending decision; its id is the attempt's and the reason's, so a decision on a superseded id is
12
+ * stale. Its actions are what the recorded facts alone offer: what a recovery waits on and must
13
+ * restart is added from its barrier ({@link offered}). Read with the copy recorded at opening, which
14
+ * a held instance renders from, a step that copy lacks (one added in place and entered since) owes
15
+ * no gate or exhaustion it can name, and offers no option.
16
+ */
17
+ export declare function pendingDecision(state: ReadonlyState<InstanceState>, definition: CanonicalDefinition): PendingDecision | null;
18
+ /**
19
+ * What a recovery's decision waits on and must restart, as the lifetime owners of the work answer it
20
+ * now (decision 18 of the slice-2 plan), combined by the service: `cleanup`, the recovering
21
+ * attempt's work still ending (`draining`) or whose end nothing establishes (`unresolved`): its tasks,
22
+ * their runs, descendants and commands, the stops of them not yet acknowledged, and conversations
23
+ * whose continuation cannot be judged yet; `uncontinuable`, each persistent participant with a
24
+ * conversation that delegations will not continue, with why. Also what a cancellation's end waits
25
+ * on, its `cleanup` covering everything under the root.
26
+ */
27
+ export type Barrier = {
28
+ readonly cleanup: CommandWork;
29
+ readonly uncontinuable: ReadonlyMap<string, string>;
30
+ };
31
+ /**
32
+ * `pending` as `decide` would take it now: a recovery's actions under `barrier`, with no verdict
33
+ * while its cleanup is pending (`cleanupPending`), and each revise choice required to restart the
34
+ * participants it allows that cannot be continued. Gate and exhaustion decisions wait on nothing.
35
+ */
36
+ export declare function offered(pending: PendingDecision, barrier: Barrier): PendingDecision;
37
+ /** Evidence the plan needs before it can be made, acquired outside any write; then plan again with it. */
38
+ export type Needs = {
39
+ readonly kind: 'needs';
40
+ readonly needs: EvidenceNeeds;
41
+ };
42
+ /** One transition's row, planned; or why it cannot be written; or the evidence its entry needs first. */
43
+ type Transition = {
44
+ readonly kind: 'transition';
45
+ readonly row: Extract<InstanceRowInput, {
46
+ op: 'entered' | 'completed';
47
+ }>;
48
+ } | {
49
+ readonly kind: 'refused';
50
+ readonly reason: string;
51
+ } | Needs;
52
+ /**
53
+ * What the instance does next on its own: nothing while it works, waits for a decision or has
54
+ * ended; otherwise the automatic transition its accepted, ungated result selects, to be written by
55
+ * its owner as a follow-up (repair writes the same one, by its deterministic id); or the reason the
56
+ * selected target cannot be entered, which blocks the instance (`entry-refused`) until it can; or
57
+ * the evidence its entry needs, when `evidence` is not what it acquired for that very attempt.
58
+ */
59
+ export declare function nextMove(state: ReadonlyState<InstanceState>, definition: CanonicalDefinition, evidence?: EntryEvidence): {
60
+ readonly kind: 'none';
61
+ } | Transition;
62
+ /** A host decision as `decide` takes it. */
63
+ export type DecisionRequest = {
64
+ readonly operationId: string;
65
+ /** The pending decision's id. */
66
+ readonly decision: string;
67
+ readonly verdict: 'approve' | 'revise';
68
+ readonly option: string | null;
69
+ readonly feedback: string | null;
70
+ /** The persistent participants to give a new conversation, as the host listed them. */
71
+ readonly restart: readonly string[];
72
+ readonly actor: string;
73
+ };
74
+ /**
75
+ * What a decision or cancellation writes: its rows, nothing (a replay of the same operation), a
76
+ * refusal, or, for a decision, the evidence its selected entry needs first.
77
+ */
78
+ export type Plan = {
79
+ readonly kind: 'rows';
80
+ readonly rows: readonly InstanceRowInput[];
81
+ } | {
82
+ readonly kind: 'replay';
83
+ } | {
84
+ readonly kind: 'refused';
85
+ readonly reason: string;
86
+ } | Needs;
87
+ /**
88
+ * Plans a host decision on the pending decision it names, for one write: the `decided` row and the
89
+ * transition it selects. Every host decision resets every step's count first, so the entry it
90
+ * opens always fits. Refused, writing nothing and leaving the decision pending: a stale or unknown
91
+ * id, a recovery whose cleanup `barrier` says is not established, a verdict or option the decision
92
+ * does not offer, a restart list naming someone twice, someone its choice may not restart or
93
+ * leaving out someone `barrier` says cannot be continued, a conflicting reuse of the operation
94
+ * id, an instance that cannot execute (`definition` is the executable one, `undefined` when
95
+ * blocked), and a selected target that cannot be entered, named in the reason. The same operation
96
+ * and payload again, its restart list compared as a set, is a replay, even after the instance moved
97
+ * on. A selected entry that binds evidence is planned with `evidence`, acquired for exactly that
98
+ * attempt, and needs it otherwise.
99
+ *
100
+ * A gate or exhaustion decision routes its result's edges over the result and the decision. A
101
+ * recovery has no result: a plain revise opens the same step again; a revise with an option routes
102
+ * the step's edges over the decision alone, and the edge that takes it must guard the recovery and
103
+ * that option and enter a step.
104
+ */
105
+ export declare function planDecision(state: ReadonlyState<InstanceState>, definition: CanonicalDefinition | undefined, request: DecisionRequest, barrier: Barrier, evidence?: EntryEvidence): Plan;
106
+ /**
107
+ * Plans admitting a cancellation: its `cancel-requested` row, which closes assignment authority.
108
+ * Available whatever is registered, since it executes no procedure; refused once the instance ended
109
+ * or another cancellation is under way. The same operation and payload again is a replay.
110
+ */
111
+ export declare function planCancel(state: ReadonlyState<InstanceState>, request: {
112
+ readonly operationId: string;
113
+ readonly reason: string;
114
+ readonly actor: string;
115
+ }): Plan;
116
+ export {};
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ /** An admitted schema, or why it is not. */
3
+ export type Admission = {
4
+ readonly problems: string[];
5
+ readonly schema: z.ZodType | undefined;
6
+ };
7
+ /**
8
+ * Admits `schema` (problems name where: `at`, then the path inside it), rebuilding it from the plain
9
+ * values the walk read, so the result shares nothing with the caller's schema: mutating that one
10
+ * later changes nothing. A JSON Schema rendering alone does not show what a zod schema validates: a
11
+ * pipe renders one side, a refinement or transform renders as its base type, regex flags are
12
+ * dropped, repeated checks collapse and metadata can overwrite validation keywords. So only nodes
13
+ * whose rendering describes their validation, and that never normalize what they accept, are
14
+ * admitted: strict objects, arrays, strings with length bounds and a flagless regex, numbers and
15
+ * integers with bounds and `multipleOf`, booleans, scalar enums and literals, inclusive unions
16
+ * (discriminated ones too), nullable and optional, with `title` and `description` metadata, each
17
+ * check once per node and with a parameter its rendering can state. Everything else is refused,
18
+ * recursion included. Custom error messages are not kept: they change no validation.
19
+ */
20
+ export declare function admitSchema(schema: unknown, at: string): Admission;
21
+ /**
22
+ * The schemas an admitted `schema` has at JSON Pointer `tokens` (already unescaped): one per union
23
+ * branch that reaches it, none when the pointer cannot hold a value. Nullable and optional wrappers
24
+ * are looked through.
25
+ */
26
+ export declare function schemasAt(schema: z.core.$ZodType, tokens: readonly string[]): z.core.$ZodType[];
@@ -0,0 +1,477 @@
1
+ import { Service, type Context } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type ThinkingEffort } from '../../llm/index.js';
4
+ import type { FreshOpening, WriteRows } from '../../loop/index.js';
5
+ import type { ThreadEnvironment } from '../../models/index.js';
6
+ import type { InitialInstallationInput } from '../../services/presets.js';
7
+ import type { DeepReadonly } from '../../util/json.js';
8
+ import type { AppendEntry } from '../../journal/index.js';
9
+ import { type CanonicalDefinition, type JsonSchema, type WorkflowDefinition } from './definition.js';
10
+ import { type Configured } from './providers.js';
11
+ import { type InstanceView } from './view.js';
12
+ declare module '@leuduan/cordis' {
13
+ interface Context {
14
+ /** Workflow definitions and the instances that run them (optional plugin). */
15
+ workflows: WorkflowsService;
16
+ }
17
+ }
18
+ /**
19
+ * A host check on the conversation an instance opens in, as its creation records it (agent,
20
+ * installations): `null` when it holds, otherwise why not, which refuses the opening.
21
+ */
22
+ export type Prerequisite = (conversation: DeepReadonly<FreshOpening>) => string | null;
23
+ /**
24
+ * A role's binding: what an isolated participant under it runs on besides its route, resolved from
25
+ * the conversation's configuration as the host proposes to create it; or why that conversation
26
+ * cannot have such a participant, which refuses the opening. Its installations are each defining
27
+ * and named by its id, as an assignment child's must be.
28
+ */
29
+ export type RoleBinding = (conversation: Configured) => {
30
+ readonly agent: string;
31
+ readonly environment: DeepReadonly<ThreadEnvironment>;
32
+ readonly installations: readonly InitialInstallationInput[];
33
+ } | {
34
+ readonly refused: string;
35
+ };
36
+ declare const WorkflowsConfigSchema: z.ZodObject<{
37
+ definitions: z.ZodArray<z.ZodCustom<CanonicalDefinition, CanonicalDefinition>>;
38
+ restrictions: z.ZodRecord<z.ZodString, z.ZodObject<{
39
+ allow: z.ZodArray<z.ZodString>;
40
+ denial: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strict>>;
42
+ coordination: z.ZodObject<{
43
+ allow: z.ZodArray<z.ZodString>;
44
+ denial: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strict>;
46
+ prerequisites: z.ZodRecord<z.ZodString, z.ZodCustom<Prerequisite, Prerequisite>>;
47
+ roles: z.ZodRecord<z.ZodString, z.ZodCustom<RoleBinding, RoleBinding>>;
48
+ modelProviders: z.ZodArray<z.ZodString>;
49
+ checks: z.ZodRecord<z.ZodString, z.ZodCustom<import("./providers.js").CheckProvider, import("./providers.js").CheckProvider>>;
50
+ evidence: z.ZodRecord<z.ZodString, z.ZodCustom<import("./providers.js").EvidenceProvider, import("./providers.js").EvidenceProvider>>;
51
+ }, z.core.$strict>;
52
+ export type WorkflowsConfig = z.input<typeof WorkflowsConfigSchema>;
53
+ /**
54
+ * One registered definition as a start form lists it: its id, its input's JSON Schema, and each
55
+ * isolated participant's model: the default its definition names (effort explicit or `null`) and
56
+ * whether the starter may choose another, from the model providers the host offers
57
+ * (`modelProviders`), which `opening` takes as `models`.
58
+ */
59
+ export type CatalogEntry = {
60
+ readonly id: string;
61
+ readonly input: JsonSchema;
62
+ readonly participants: Readonly<Record<string, {
63
+ readonly provider: string;
64
+ readonly model: string;
65
+ readonly thinkingEffort: ThinkingEffort | null;
66
+ readonly configurable: boolean;
67
+ }>>;
68
+ readonly modelProviders: readonly string[];
69
+ };
70
+ declare const OpeningRequestSchema: z.ZodObject<{
71
+ id: z.ZodString;
72
+ inputId: z.ZodString;
73
+ definition: z.ZodString;
74
+ input: z.ZodJSONSchema;
75
+ conversation: z.ZodObject<{
76
+ environment: z.ZodObject<{
77
+ cwd: z.ZodString;
78
+ read_roots: z.ZodArray<z.ZodString>;
79
+ }, z.core.$strict>;
80
+ installations: z.ZodArray<z.ZodCustom<InitialInstallationInput, InitialInstallationInput>>;
81
+ }, z.core.$strict>;
82
+ models: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
83
+ provider: z.ZodString;
84
+ model: z.ZodString;
85
+ thinkingEffort: z.ZodNullable<z.ZodEnum<{
86
+ low: "low";
87
+ high: "high";
88
+ none: "none";
89
+ medium: "medium";
90
+ max: "max";
91
+ }>>;
92
+ }, z.core.$strict>>>;
93
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
94
+ }, z.core.$strict>;
95
+ export type OpeningRequest = z.input<typeof OpeningRequestSchema>;
96
+ declare const DecideRequestSchema: z.ZodObject<{
97
+ operationId: z.ZodString;
98
+ instanceId: z.ZodString;
99
+ decision: z.ZodString;
100
+ verdict: z.ZodEnum<{
101
+ approve: "approve";
102
+ revise: "revise";
103
+ }>;
104
+ option: z.ZodOptional<z.ZodString>;
105
+ feedback: z.ZodOptional<z.ZodString>;
106
+ restart: z.ZodOptional<z.ZodArray<z.ZodString>>;
107
+ }, z.core.$strict>;
108
+ export type DecideRequest = z.input<typeof DecideRequestSchema>;
109
+ declare const CancelRequestSchema: z.ZodObject<{
110
+ operationId: z.ZodString;
111
+ instanceId: z.ZodString;
112
+ reason: z.ZodString;
113
+ }, z.core.$strict>;
114
+ export type CancelRequest = z.input<typeof CancelRequestSchema>;
115
+ /**
116
+ * The host's cancel of a root for a person's Stop, as {@link WorkflowsService.stop} runs it: it
117
+ * cancels the root with `rows` among its cancel `rows`, beside delegations' stop obligations, and
118
+ * settles with that write.
119
+ */
120
+ export type StopCancel = (rows: (threadId: string) => AppendEntry<'ext'>[]) => Promise<void>;
121
+ /** A request the workflow refuses, with why: nothing was recorded. */
122
+ export declare class WorkflowRefusedError extends Error {
123
+ constructor(reason: string);
124
+ }
125
+ /**
126
+ * Registered definitions and the instances that run them. An instance lives on its root thread,
127
+ * the conversation it was opened with: the root requires {@link WORKFLOWS_OWNER}, so it runs only
128
+ * while this service is mounted and repaired. Everything the instance records is written here, each
129
+ * write deciding again inside itself what it records:
130
+ *
131
+ * - `opening` gives the rows of the root's creation write: the opening, the entry attempt.
132
+ * - An accepted result routes on its own: after the turn ending that accepted it, one follow-up send
133
+ * on the root writes the transition with its input under the transition's deterministic id; the
134
+ * repair at startup sends any a crash missed, which that id makes idempotent.
135
+ * - `decide` records a host decision with the transition it selects and its input in one send: on a
136
+ * recovery, with the persistent participants it restarts.
137
+ * - Reconciliation, one pass at a time per root (`reconcile`), never waiting on a model turn of the
138
+ * root: an isolated participant's child is observed on the root (`observations.ts`), a write on
139
+ * the root recomputing from the retained child whether its task accepted a submission or ended
140
+ * without one; then the transition the instance owes on its own is routed; then each isolated
141
+ * assignment the instance owes a task is started (`participants.ts`), in the background, never
142
+ * waiting on the child's work. It runs after every row of the instance, at the root's turn end,
143
+ * when a participant's task settles, after a start ends, on rows under a root whose start waits
144
+ * on a slot or a previous task, on a provider's notice, and at the repair, so a remount resumes it.
145
+ * A start delegations refuses for good is recorded, rechecked inside the root's write, as an
146
+ * observation that recovers its attempt.
147
+ * - `cancel` admits a cancellation in a write of its own, then cancels the root's operation, stops
148
+ * its commands, and records the end once the evidence holds: the run released, each command's
149
+ * termination established from its records. A failed stop or unknown termination leaves the
150
+ * instance blocked on cleanup; a crash after the admission resumes at the repair.
151
+ * - A person's Stop of the root (`stop`) records, in its cancel write, what it met: isolated
152
+ * work open stops for good and the attempt recovers, an acceptance before it stands. A task that
153
+ * ends without acceptance recovers its attempt too, and the observation's write stops its
154
+ * siblings' tasks. A recovery's decision, its restarts and the successor it opens wait on one
155
+ * evidence barrier (`cleanup.ts`), as a cancellation's end does.
156
+ *
157
+ * Beside these writes it mounts what the fold derives for the model steps of the root, its
158
+ * participants' children and the threads they start: the presentation of assignments
159
+ * (`assignment.ts`), the vote and grant of their authority (`policy.ts`), and
160
+ * `submit_workflow_output` with the stop check reminding a thread to submit (`submit.ts`). Its
161
+ * constraint holds the root and every thread under it while the instance cannot execute.
162
+ *
163
+ * An entry that binds evidence has it acquired first, outside any write, for exactly that transition
164
+ * and attempt; its write plans the entry again with that evidence and records it only when the plan
165
+ * is unchanged. The providers' subscriptions and every acquisition in flight are this service's
166
+ * (`providers.ts`): a provider's notice decides again what it held, and the unload cancels and
167
+ * waits for what is in flight.
168
+ *
169
+ * Registration refuses a definition naming a restriction, prerequisite, role or provider the host
170
+ * does not bind, and a second definition under one id. An id is a definition's whole identity: an
171
+ * instance runs by the definition registered under its id now, edits included, and is held only
172
+ * where it cannot continue on it (`heldBy`); a breaking change registers under a new id.
173
+ */
174
+ export declare class WorkflowsService extends Service<WorkflowsConfig> {
175
+ static inject: string[];
176
+ private readonly config;
177
+ private readonly registered;
178
+ private readonly entries;
179
+ /** Cleanups under way, by root: each instance's runs once at a time. */
180
+ private readonly cleanups;
181
+ /** Roots whose admitted cancellation has not ended, whose cleanup a later row or run event may finish. */
182
+ private readonly cancelling;
183
+ /**
184
+ * Roots the repair could not read, clean up or reconcile, with why: held with every thread under
185
+ * them, never reconciled again and none of their participants' tasks started or admitted, until a
186
+ * remount repairs them again ({@link quarantined}).
187
+ */
188
+ private readonly unrepaired;
189
+ /** Follow-up sends in flight, which shutdown lets land. */
190
+ private readonly sends;
191
+ /** Each root's reconciliation in flight, and whether another was asked for while it ran. */
192
+ private readonly passes;
193
+ /** Set once shutdown began: no reconciliation starts after it. */
194
+ private closing;
195
+ /** Set once the repair began, which reconciles every root: none is reconciled before. */
196
+ private repairing;
197
+ private readonly participants;
198
+ /** The catalog refresh of the instance contribution registration queued; the repair awaits it. */
199
+ private refreshed;
200
+ private readonly providers;
201
+ private constraint;
202
+ /**
203
+ * The latest refusal of each root's automatic transition over evidence acquired for it, until a
204
+ * provider's notice retries it: a derived availability condition, never recorded.
205
+ */
206
+ private readonly entryRefusals;
207
+ constructor(ctx: Context, config: WorkflowsConfig);
208
+ /** Every registered definition, with its rendered input schema and participants' models, in registration order. */
209
+ catalog(): readonly CatalogEntry[];
210
+ /** The definition registered under `id`; `undefined` when none is. */
211
+ definition(id: string): WorkflowDefinition | undefined;
212
+ /**
213
+ * The rows that open an instance in the write creating its root, for `threads.create`'s `rows`:
214
+ * the opening (id, readable copy, input, pins) and the entry attempt, activated by
215
+ * the claim of the first input. The host creates the root under `id`, with its first input under
216
+ * `inputId`, `requires: [WORKFLOWS_OWNER]` and exactly the proposed `conversation`, in that one
217
+ * write, and with a wake exactly when the entry step assigns the conversation participant: an
218
+ * entry worked by isolated participants alone is started by reconciliation, with no root turn.
219
+ *
220
+ * Prepared outside the write, and cancelled by `signal`: each isolated participant's configuration
221
+ * resolved through its role and pinned with its complete route, the default or the starter's
222
+ * choice; each check provider pinned from its participant's configuration, and each evidence
223
+ * provider from the conversation's; and the entry step's evidence acquired.
224
+ *
225
+ * Refused here, with {@link WorkflowRefusedError}: a definition not registered under that id, an
226
+ * input its schema refuses, a model choice for a participant that takes none or with
227
+ * a provider the host does not offer, a role or provider that is unavailable or refuses this
228
+ * conversation, and an entry that cannot bind. Refused inside the write, which then creates nothing: a write that is not a
229
+ * new root's creation under `id` (a fork, a delegated thread), one without the owner or the first
230
+ * input, a wake where the entry needs one or one where it needs none, a conversation other than
231
+ * the one proposed, and one a prerequisite's check refuses. A root found again under `id` gets no rows: the host compares its recorded definition
232
+ * (`read`) with the one it asked for.
233
+ */
234
+ opening(request: OpeningRequest): Promise<WriteRows>;
235
+ /** The conversation a host proposes, as its creation records it, installation ids left out. */
236
+ private proposed;
237
+ /**
238
+ * What the instance runs on besides its definition, pinned: each participant's configuration and
239
+ * the pins of the checks its assignments list, then the evidence providers' pins.
240
+ */
241
+ private pins;
242
+ /**
243
+ * An isolated participant's complete configuration: its route, the default its definition names
244
+ * or the starter's complete choice, on a provider the host offers; and what its role resolves from
245
+ * the conversation, its installations validated and normalized as its creation records them.
246
+ */
247
+ private configuration;
248
+ /** Why the write `opening` describes cannot open this instance, or `null`. */
249
+ private openingRefusal;
250
+ /**
251
+ * The instance on root `instanceId`, as a host reads it now: synchronous, so a host can put it in
252
+ * the same snapshot as the thread's other reads. Read while the root is loaded, as
253
+ * `ctx.threads.view` is: the caller retains it (`ctx.threads.retain`), or it is running.
254
+ */
255
+ read(instanceId: string): InstanceView;
256
+ /**
257
+ * Records a host decision on the pending decision it names, with the transition it selects and an
258
+ * input, in one send on the root: the scheduling input of the root assignment the transition
259
+ * opens, or else a notice telling the root what was decided. A person's wake comes with it when
260
+ * the root gets work, or when the decision must release a person's Stop. Everything is decided
261
+ * again inside the write, serialized with the conversation's other input. The same operation and
262
+ * payload again returns the instance as it stands. Refused with {@link WorkflowRefusedError},
263
+ * recording nothing and leaving the decision pending: a stale or unknown decision, a verdict or
264
+ * option it does not offer (a recovery offers no approve), a restart list naming someone twice,
265
+ * someone its choice may not restart or leaving out someone it must, a conflicting reuse of the
266
+ * operation id, an instance that cannot execute, and a selected step that cannot be entered, whose
267
+ * reason names the missing binding, evidence that could not be acquired included. A selected entry that binds evidence has it
268
+ * acquired before the send; the send's write plans it again with that evidence.
269
+ */
270
+ decide(request: DecideRequest, actor: string): Promise<InstanceView>;
271
+ /**
272
+ * Cancels the instance on root `instanceId`. The cancellation is admitted first, in a write of its
273
+ * own that closes assignment authority: refused with {@link WorkflowRefusedError} once the instance
274
+ * ended, under another cancellation, or for a conflicting reuse of the operation id. Then the
275
+ * root's operation is cancelled, which clears its queued input, its commands are stopped, and the
276
+ * terminal row is written once the evidence holds: its run released, and every command it
277
+ * recorded known to have ended. A failed stop or an unknown termination leaves it blocked on
278
+ * cleanup, named in the view; the same operation again tries the cleanup again. Resolves with the
279
+ * instance as it then stands. Available whatever is registered.
280
+ */
281
+ cancel(request: CancelRequest, actor: string): Promise<InstanceView>;
282
+ /**
283
+ * A person's Stop of root `threadId`, through the host's own cancel of it (`cancel`), which
284
+ * composes the rows this gives beside delegations' stop obligations, which stop the tasks for good.
285
+ * The children of the current attempt's open isolated assignments are held loaded first, so the
286
+ * cancel's write reads what each shows then, and the rows decide there what the Stop met
287
+ * ({@link stopFact}): an acceptance before it stands; any other isolated work open is superseded
288
+ * with the root's own assignment, and the attempt recovers (cause `stop`), counting nothing; a
289
+ * result ready before it whose transition is still owed enters any isolated work it opens
290
+ * recovering. Nothing for a root running no workflow, a root-only attempt, which stays active
291
+ * across the Stop, or an attempt already recovering, whose decision, cause and subject a repeated
292
+ * Stop keeps. The row is declared policy state, so a call authorized under the instance as the
293
+ * Stop lands decides again.
294
+ *
295
+ * The write refuses, and the Stop is prepared again and its cancel made again, when what it meets
296
+ * is not what was held: another attempt, or a child of the attempt that is not loaded, whose
297
+ * acceptance would otherwise go unread. Rejects with what the cancel rejects with, or once the
298
+ * attempt kept changing.
299
+ */
300
+ stop(threadId: string, reason: string, cancel: StopCancel): Promise<void>;
301
+ /** What a Stop of `threadId` meets now: the current attempt, and its open isolated assignments' children that exist. */
302
+ private stopping;
303
+ /**
304
+ * The Stop's rows, inside its write: refused ({@link StaleStopError}) when the attempt it meets is
305
+ * not the one `prepared` held, or one of its children is not loaded.
306
+ */
307
+ private stopRows;
308
+ /** The instance on `threadId`, which the caller holds. */
309
+ private state;
310
+ /** The instance as a host reads it: an owned, frozen copy, never a reference into the fold. */
311
+ private view;
312
+ /** The one evidence barrier of the instance on `threadId` ({@link barrierOf}), with its participants' starts in flight. */
313
+ private barrier;
314
+ /** The definition `state` executes by, or `undefined` while it cannot continue on what is registered ({@link heldBy}). */
315
+ private executable;
316
+ /**
317
+ * What derived reads of `state` take its procedure from: the definition it executes by, or, while
318
+ * it is held, the copy recorded at its opening, which renders and is never executed.
319
+ */
320
+ private procedure;
321
+ private planDecision;
322
+ /** A decision's plan, with the evidence its selected entry needs acquired; cancelled, it is refused. */
323
+ private prepareDecision;
324
+ /** What the instance does on its own now, with `evidence` for the entry it owes; `none` when it cannot execute. */
325
+ private owed;
326
+ /**
327
+ * Writes the transition the instance owes on its own, if any: a follow-up send whose input is the
328
+ * scheduling input of the root assignment it opens, with a `fresh` wake that releases no hold,
329
+ * or else a notice the root reads at its next turn. An entry that binds evidence has it acquired
330
+ * first; one it refuses is kept as the instance's entry refusal until a provider's notice tries
331
+ * again, and one cancelled writes nothing. Nothing is acquired when nothing is owed, such as after
332
+ * an entry was recorded: replay reads what that entry recorded. Decided again inside the write; a
333
+ * send whose id is known, or whose transition is no longer owed, writes nothing.
334
+ */
335
+ private advance;
336
+ /**
337
+ * Why a write must not record `rows` now, rechecked inside it: a provider an entry among them
338
+ * depends on cannot serve the instance's pin (`Providers.problem`): an evidence binding its step
339
+ * declares, or a check its assignments list. `null` when every one can.
340
+ */
341
+ private entryProblem;
342
+ /** Why an opening must not be recorded now: a provider it pinned cannot serve its pin; `null` when all can. */
343
+ private pinsProblem;
344
+ /**
345
+ * Runs `plan` with the evidence the entry it plans needs: acquired outside any write, for exactly
346
+ * the transition and attempt it names, then planned again with it, and acquired again when the
347
+ * instance moved on meanwhile. Returns the plan with the evidence it was made with, which the
348
+ * write's own plan must be made with too.
349
+ */
350
+ private withEvidence;
351
+ private send;
352
+ /**
353
+ * `row`'s input: the scheduling input naming the root assignment the transition opens, or a notice
354
+ * of what happened, with the host decision that made it when one did.
355
+ */
356
+ private transition;
357
+ /**
358
+ * The cleanup of an admitted cancellation, once at a time per instance: the root's operation
359
+ * cancelled (`cleanup`, which holds nothing), with, in that cancel's write, delegations' stop
360
+ * obligation over every sub-agent task under the root, participants' included; then the commands
361
+ * of every thread under the root stopped; and the terminal row written once the evidence holds
362
+ * ({@link finishCleanup}). Work still ending finishes it later, as its rows land.
363
+ */
364
+ private cleanUp;
365
+ private runCleanup;
366
+ /**
367
+ * Writes an admitted cancellation's terminal row, decided inside its write, once nothing runs the
368
+ * root (no run or other operation holds it, read as the write is decided, so whatever operation a
369
+ * cancel captured, a retry's included, has released it) and everything under the root is known to
370
+ * have ended ({@link barrierOf}); otherwise nothing, and the instance stays blocked on
371
+ * cleanup until a later row under it, or the root's next run event, lets this decide again. The
372
+ * one rule every path to the terminal row takes.
373
+ */
374
+ private finishCleanup;
375
+ /**
376
+ * Whether the constraint governs `summary`'s thread: a workflow's root, or any thread under one by
377
+ * origin, which core's readiness alone would let run while its root is held (decision 12 of the
378
+ * slice-2 plan): only owner readiness passes down, never what this constraint says of the root.
379
+ */
380
+ private governs;
381
+ /**
382
+ * The constraint on a workflow's root and every thread under it: an instance that has not ended
383
+ * runs only on a definition registered under its id that it can continue on ({@link heldBy}), so
384
+ * all of them are held while there is none; and while a check an open assignment's entry
385
+ * recorded has no provider that serves the pin it recorded, which would drop the check, the
386
+ * thread working that assignment is held with the threads its line started: the root and its
387
+ * ordinary descendants for the root's checks, an isolated participant's child and its descendants
388
+ * for its own. A completed or cancelled instance is
389
+ * ordinary chat and holds nothing. A root the repair failed on is held with its error, whatever
390
+ * its instance says. Registration is fixed for this mount, so its hold changes only
391
+ * with a remount, which registers again; a provider's notice decides a check's hold again.
392
+ */
393
+ private evaluate;
394
+ /**
395
+ * Asks core to decide again every thread under the workflow root `root`, whose holds, and the
396
+ * owner's say on whose tasks, read the root's instance.
397
+ */
398
+ private governedChanged;
399
+ /** What the owner's say on a running task of `root` reads: the root's catalog entry, which needs nothing loaded. */
400
+ private runnable;
401
+ /**
402
+ * A provider's notice: each instance whose open assignments list a check is decided again, its root
403
+ * and every thread under it, and reconciled, as is each whose transition an entry refusal held, so
404
+ * a provider that returns resumes what it blocked, a start it held included. A disposed provider
405
+ * stays missing until a remount binds one.
406
+ */
407
+ private providerChanged;
408
+ /**
409
+ * What a row asks for: on a root, after a row of its instance or a turn ending that may have
410
+ * accepted its result, a reconciliation; under a root whose cancellation's cleanup is unfinished,
411
+ * or one of whose starts waits on a slot or a previous task, a row that may settle work asks for
412
+ * that cleanup's end, or a reconciliation that starts it. A participant's task settling is told by
413
+ * delegations (`Participants`), which asks for its root's reconciliation.
414
+ */
415
+ private onRow;
416
+ /**
417
+ * One reconciliation of the instance on `root` at a time, never waiting on a model turn: one asked
418
+ * for while it runs runs once more after it. With the root held: an admitted cancellation's
419
+ * cleanup end decided again; otherwise the observations its participants' children owe it
420
+ * written, the transition it owes on its own routed, and each isolated task it owes started, in
421
+ * the background ({@link Participants.dispatch}). Nothing before the repair, which reconciles every
422
+ * root, nor once shutdown began, nor on a root the repair failed on.
423
+ */
424
+ private reconcile;
425
+ /**
426
+ * Records delegations' refusal for good of `assignment`'s start as its attempt's recovery: an
427
+ * observation, decided again inside the root's write, with the children it reads held. Written
428
+ * only while the assignment still waits for its start, open in the current attempt with no task
429
+ * on its child, and, for a child that exists, while delegations still will not continue it.
430
+ */
431
+ private refused;
432
+ /**
433
+ * Writes the observations the root owes of its participants' children (`observations.ts`), with
434
+ * those children retained so the write reads them: decided again inside it from what they record,
435
+ * so an observation carries exactly what its child shows, once per task; one that ends a task
436
+ * without acceptance stops its unfinished siblings' tasks in the same write. The caller holds the root.
437
+ */
438
+ private observe;
439
+ private track;
440
+ /**
441
+ * What a crash or a remount left, before anything runs: each instance's unfinished cancellation
442
+ * resumed, and every other one reconciled ({@link reconcile}): the observations of its
443
+ * participants' children it missed written, the transition it owes on its own sent, and the
444
+ * isolated tasks it owes started, a start a crash cut off adopting the task it committed. Every
445
+ * root requiring this plugin is read; reconciliation starts here.
446
+ *
447
+ * A failure is the instance's alone: reported with its root, which stays held with the error
448
+ * ({@link evaluate}) and is not tried again until a remount, and the repair goes on to the next
449
+ * root, so the owner becomes ready for every other. A root missing from the catalog refresh is
450
+ * held by its absent entry.
451
+ */
452
+ private repair;
453
+ /**
454
+ * Why the repair failed on the root `root`, or `null`: the one question every path that would let
455
+ * its instance progress asks, its constraint, its reconciliation and its participants' starts,
456
+ * and every write of its rows, decided again inside that write, which then writes nothing on it:
457
+ * a refusal's or an observation's, a transition, a decision, a cancellation and its cleanup, and
458
+ * a person's Stop, whose own cancel still lands without the instance's row.
459
+ */
460
+ private quarantined;
461
+ /** Refuses a host operation on the root `root` while it is quarantined ({@link WorkflowRefusedError}). */
462
+ private refuseQuarantined;
463
+ /** Runs `work` with `threadId` loaded and held. */
464
+ private holding;
465
+ /** Runs `work` with `members` loaded and held, read again as the retention asks. */
466
+ private retaining;
467
+ /** `threadId` and every thread under it, as the catalog lists them now: what a retention of a root's work reads. */
468
+ private subtree;
469
+ /**
470
+ * Cancels the acquisitions in flight and waits for them, and lets the reconciliations, participants'
471
+ * starts, follow-up sends and cleanups under way land while the journal takes their rows, starting
472
+ * none; a transition whose evidence was cancelled, or a start that did not land, is owed again at
473
+ * the next mount's repair.
474
+ */
475
+ private shutdown;
476
+ }
477
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { Context } from '@leuduan/cordis';
2
+ import { type Governance } from './policy.js';
3
+ /**
4
+ * Mounts submission on the application root: `submit_workflow_output`, registered in the root's
5
+ * scope and granted to no agent (each instance root's and participant child's activation grants it,
6
+ * `policy.ts`), and the stop check that reminds a thread to submit.
7
+ */
8
+ export declare function acceptSubmissions(ctx: Context, governance: Governance): void;