@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,181 @@
1
+ import type { Context } from '@leuduan/cordis';
2
+ import type { z } from 'zod';
3
+ import type { AppendOptions, PluginJournal, PluginProjection } from '../journal/index.js';
4
+ import type { ContentPartInput } from '../llm/content.js';
5
+ import { type ModelStep } from '../loop/index.js';
6
+ import { type RowRef } from '../state/index.js';
7
+ import { type AgentSelector } from './agents.js';
8
+ import type { ExtensionRecord, InputRole, JournalEvent, Seq, StepContribution } from '../records/journal.js';
9
+ import type { ReadonlyState } from '../util/foldState.js';
10
+ import type { DeepReadonly } from '../util/json.js';
11
+ export declare class ExtensionVersionError extends Error {
12
+ readonly record: ExtensionRecord;
13
+ readonly supportedVersion: number;
14
+ constructor(record: ExtensionRecord, supportedVersion: number);
15
+ }
16
+ /**
17
+ * One plugin-owned event schema. A row of another version is refused with
18
+ * {@link ExtensionVersionError}: the journal is not migrated, and neither are a plugin's rows.
19
+ *
20
+ * `policyState` says a `lagent/tool/authorize` listener decides from these rows: one that lands
21
+ * while a call is authorized sends the decision round again. Rows of an event that does not say so
22
+ * never do, so diagnostics and notices cost an authorization nothing.
23
+ */
24
+ export declare function defineExtensionEvent<Schema extends z.ZodType>(definition: {
25
+ plugin: string;
26
+ instanceId?: string;
27
+ kind: string;
28
+ version: number;
29
+ schema: Schema;
30
+ policyState?: boolean;
31
+ }): {
32
+ /** A validated record carrying `value`: what an `ext` row holds, and a contribution's `source`. */
33
+ record: (value: z.input<Schema>) => ExtensionRecord;
34
+ /** `value` validated as this event's payload, its defaults applied. */
35
+ parse: (value: z.input<Schema>) => z.output<Schema>;
36
+ /** A validated row for an atomic `journal.appendAll` batch; every row names its thread. */
37
+ entry: (value: z.input<Schema>, options: AppendOptions) => {
38
+ type: "ext";
39
+ data: {
40
+ plugin: string;
41
+ instance_id: string;
42
+ kind: string;
43
+ version: number;
44
+ data: z.core.util.JSONType;
45
+ };
46
+ options: AppendOptions;
47
+ };
48
+ /** Appends one row carrying `value`; resolves once it is durable. */
49
+ append(journal: PluginJournal, value: z.input<Schema>, options: AppendOptions): Promise<JournalEvent<"ext">>;
50
+ read(event: JournalEvent): z.output<Schema> | undefined;
51
+ /** A validated `lagent/llm/step` contribution whose `source` is this event carrying `value`. */
52
+ contribution(message: {
53
+ role?: InputRole;
54
+ content: string | readonly ContentPartInput[];
55
+ }, value: z.input<Schema>, options?: {
56
+ sourceSeqs?: readonly Seq[];
57
+ }): StepContribution;
58
+ /** Whether `record` — a contribution's or a rejection's `source` — is one of this event's. */
59
+ matchesSource(record: DeepReadonly<ExtensionRecord>): boolean;
60
+ /** A `lagent/turn/stop` rejection whose `source` is this event carrying `value`. */
61
+ rejection(reason: string, value: z.input<Schema>): {
62
+ decision: "reject";
63
+ reason: string;
64
+ source: ExtensionRecord;
65
+ };
66
+ /** The value a contributed `input/message` carries, when this event is its source. */
67
+ readContribution: (event: JournalEvent) => z.output<Schema> | undefined;
68
+ /**
69
+ * The value `source` carries — a queued input's or a contribution's — when it is one of this
70
+ * event's; `undefined` for any other. Another version is refused, as for a row.
71
+ */
72
+ readSource: (source: DeepReadonly<ExtensionRecord> | null) => z.output<Schema> | undefined;
73
+ /**
74
+ * What a thread was told through this event's contributions: every notice row, with the value
75
+ * it carried and whether it is still on the thread's surface. Read it with {@link latestNotice}
76
+ * and {@link latestVisible}.
77
+ *
78
+ * A thread was told something only while the notice is on its surface. A `surface/replaced`
79
+ * row that cites a notice row clears that row's visibility, for good; nothing else does. So a
80
+ * plugin that tells a thread a fact compares it with what the model can still see, and tells it
81
+ * again once a replacement took it away, with no scan of the surface at any step. Thread-scoped
82
+ * and inherited: a fork, and `stateAt`, see what was visible at their row of the lineage.
83
+ */
84
+ told: PluginProjection<ToldNotices<z.output<Schema>>>;
85
+ /**
86
+ * Unrelated events are ignored. Failure makes this projection unavailable, not the journal.
87
+ *
88
+ * A fork inherits a thread-scoped state by default; `onFork: 'reset'` starts each fork from
89
+ * `init()` instead, for state that describes what the source did rather than its conversation.
90
+ * `apply` also gets the `ext` row that carried the value.
91
+ */
92
+ projection<State>(fold: {
93
+ key: string;
94
+ init(): State;
95
+ apply(state: State, value: z.output<Schema>, event: JournalEvent<"ext">): State;
96
+ onFork?: "inherit" | "reset";
97
+ }): PluginProjection<State>;
98
+ };
99
+ /**
100
+ * One notice a thread was told: the row that told it, the value its `source` carried, and whether
101
+ * the model can still see it.
102
+ */
103
+ export type ToldNotice<Value> = {
104
+ readonly row: RowRef;
105
+ readonly value: Value;
106
+ /**
107
+ * Whether the notice is still on the thread's surface: cleared by the first `surface/replaced`
108
+ * row that cites it. What was recorded is one fact; whether the model can still see it, another.
109
+ */
110
+ readonly visible: boolean;
111
+ };
112
+ /** Every notice of one kind a thread was told, oldest first: the state of an event's `told` fold. */
113
+ export type ToldNotices<Value> = {
114
+ readonly notices: readonly ToldNotice<Value>[];
115
+ };
116
+ /**
117
+ * The latest notice told, visible or not; `null` when none was ever told. For recorded text: a
118
+ * notice whose latest telling is no longer visible is told again from that row, as recorded.
119
+ */
120
+ export declare function latestNotice<Value>(told: ToldNotices<Value>): ToldNotice<Value> | null;
121
+ /**
122
+ * What the latest notice the model can still see says; `null` when none is visible. For live facts:
123
+ * compare the fact as it stands with this, and tell it when they differ, rendered against this
124
+ * value, as a first telling when it is `null` and as a change from it otherwise.
125
+ *
126
+ * Not the latest notice's value: an earlier notice can outlive a later one. A restriction told
127
+ * early and lifted by a later notice that a replacement took away is still what the model sees, so
128
+ * the lift has to be told again.
129
+ */
130
+ export declare function latestVisible<Value>(told: ToldNotices<Value>): Value | null;
131
+ /** What {@link tellOnStep} uses of an event `defineExtensionEvent` declared, `Input` and `Output` its payload's. */
132
+ export type NoticeEvent<Input, Output> = {
133
+ parse(value: Input): Output;
134
+ readonly told: PluginProjection<ToldNotices<Output>>;
135
+ contribution(message: {
136
+ content: string;
137
+ }, value: Input): StepContribution;
138
+ };
139
+ /** One fact a thread is told at its model steps; see {@link tellOnStep}. */
140
+ export type StepNotice<Input, Output> = {
141
+ /** The event each notice is recorded as, whose `told` fold says what the model can still see. */
142
+ readonly event: NoticeEvent<Input, Output>;
143
+ /** Whose threads are told; without it, every thread this plugin's listener reaches. */
144
+ readonly agents?: AgentSelector;
145
+ /**
146
+ * Where the notice is recorded among the step's contributions: lower first, equal ranks in
147
+ * listener order, 0 when omitted. See {@link ModelStep.contribute}.
148
+ */
149
+ readonly rank?: number;
150
+ /** What is true for this step, or `undefined` to tell nothing at it. */
151
+ current(step: ModelStep): Input | undefined;
152
+ /**
153
+ * The notice's text: `value` as a first telling when `told`, the latest notice the model can still
154
+ * see, is `null`, and as a change from it otherwise; `null` to tell nothing. `notices` is every
155
+ * notice of the event, for a plugin whose rule needs more than the latest visible one. What was
156
+ * told is read from the journal's fold, so it is the read-only view of `Output`.
157
+ */
158
+ render(value: Output, told: ReadonlyState<Output> | null, at: {
159
+ readonly step: ModelStep;
160
+ readonly notices: ToldNotices<ReadonlyState<Output>>;
161
+ }): string | null;
162
+ };
163
+ /**
164
+ * Tells a thread a fact as a conversation message at its model steps: at each step already due,
165
+ * `current` says what is true, and when it differs from the latest notice the model can still see
166
+ * the step carries the rendered notice, recorded as the event. So a fact is told on the first step,
167
+ * again when it changes, and again after a replacement took the notice off the surface; several
168
+ * changes between two steps are one notice, and a change back is none. A plugin whose notice one
169
+ * plugin's failure must not silence keeps its own event, as every notice does. The event's schema
170
+ * must give the same value parsed twice, since the notice is recorded from `current` and compared
171
+ * after it is read back.
172
+ *
173
+ * ```ts
174
+ * tellOnStep(ctx, {
175
+ * event: routeNotice,
176
+ * current: (step) => step.route,
177
+ * render: (route, told) => (told === null ? `You run on ${route.model}.` : `You now run on ${route.model}.`),
178
+ * })
179
+ * ```
180
+ */
181
+ export declare function tellOnStep<Input, Output>(ctx: Context, notice: StepNotice<Input, Output>): void;
@@ -0,0 +1,26 @@
1
+ import type { Context, Plugin } from '@leuduan/cordis';
2
+ import { Journal, type JournalStore } from '../journal/index.js';
3
+ import { type TurnLimits } from '../state/index.js';
4
+ export type JournalConfig = {
5
+ /** Durable backing. A store that is already open stays caller-owned. */
6
+ store: JournalStore;
7
+ /** What a thread's summary asks of the folds: whether a run would find work depends on them. */
8
+ limits: TurnLimits;
9
+ };
10
+ /**
11
+ * Opens the one journal this process runs against and provides it as `ctx.journal`.
12
+ *
13
+ * The journal takes the store's writer lease before reading: another process may hold this journal.
14
+ *
15
+ * Core's one fold, `threadState`, is registered before the journal opens and never removed: it
16
+ * holds every row before the first write, which `replaceSurface` judges against its surface.
17
+ * The loop's summary is what the journal writes to the catalog with every group; `journal/` knows
18
+ * only its shape. A journal that can no longer be written is announced as `lagent/journal/revoked`;
19
+ * it has already refused every later write, and the host must exit.
20
+ */
21
+ export declare const journalPlugin: Plugin.Object<JournalConfig>;
22
+ /**
23
+ * The journal with core's writes, for the engine's own services: the same journal `ctx.journal`
24
+ * holds, which types it for plugins as one that appends `ext` rows only.
25
+ */
26
+ export declare const engineJournal: (ctx: Context) => Journal;
@@ -0,0 +1,82 @@
1
+ import { Context, Service } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type ModelCallClient } from '../llm/failure.js';
4
+ import { type LLMProvider, type ModelRoute } from '../llm/provider.js';
5
+ import { type ModelCapacity } from '../llm/client.js';
6
+ import { type ModelSelection } from '../llm/provider.js';
7
+ /**
8
+ * How `ctx.llm` retries a provider's failed call, required at registration. `maxAttempts` counts the
9
+ * first request, so `1` retries nothing. The wait before a retry is exponential from `baseDelayMs`
10
+ * with full jitter, capped at `maxDelayMs`; a wait the provider asked for (`retryAfterMs`) at or below
11
+ * `maxDelayMs` is the wait, and one above it stops retrying.
12
+ */
13
+ export declare const RetryPolicySchema: z.ZodObject<{
14
+ maxAttempts: z.ZodNumber;
15
+ baseDelayMs: z.ZodNumber;
16
+ maxDelayMs: z.ZodNumber;
17
+ }, z.core.$strict>;
18
+ export type RetryPolicy = z.input<typeof RetryPolicySchema>;
19
+ /** The service's own registration, reachable only through {@link registerProvider}. */
20
+ declare const register: unique symbol;
21
+ /**
22
+ * Offers `provider` to route selection and to the agents told about routes, for the life of the
23
+ * calling fiber, with `retry` the policy its calls are retried by. Register only what should be
24
+ * offered. Returns the disposer, as `registerAgent` does.
25
+ */
26
+ export declare const registerProvider: (ctx: Context, provider: LLMProvider, options: {
27
+ retry: RetryPolicy;
28
+ }) => (() => void | Promise<void>);
29
+ /**
30
+ * Provider registry, route resolution and client construction.
31
+ *
32
+ * One client per provider, built when first asked for and kept until the provider is withdrawn: a
33
+ * client is asked for on every model call, and rebuilding a transport each time would be waste. The
34
+ * model and the effort travel on each request, so neither is part of the key. A route's effort is
35
+ * the route's to resolve (`resolveRoute`, `routeOn`); the client only supplies the provider's own
36
+ * default when a request carries none.
37
+ */
38
+ export declare class LlmService extends Service {
39
+ private readonly providers;
40
+ private readonly policies;
41
+ /** By provider name. */
42
+ private readonly clients;
43
+ constructor(ctx: Context);
44
+ get providerNames(): string[];
45
+ /**
46
+ * Offers `provider` until the returned disposer runs (see {@link registerProvider}, the one way in).
47
+ * The disposer withdraws it and its client at once, so a provider registered again under the name
48
+ * never reaches the old one, and resolves once it is disposed, rejecting with what its cleanup threw.
49
+ */
50
+ [register](provider: LLMProvider, retry: z.output<typeof RetryPolicySchema>): () => Promise<void>;
51
+ /** The provider registered under `name`; throws `RouteUnavailableError` when none is. */
52
+ provider(name: string): LLMProvider;
53
+ /** Why `route` cannot run now: its provider is not registered; `null` when it can. */
54
+ unavailable(route: Pick<ModelRoute, 'provider'>): string | null;
55
+ /**
56
+ * `selection` folded over `base`, the route it changes: a named model or effort replaces that
57
+ * field, and a named different provider takes that provider's defaults for whatever it leaves
58
+ * unnamed, since a model or an effort means nothing on another provider. Throws
59
+ * `RouteUnavailableError` when the resulting provider is not registered. Registry lookup only; no
60
+ * client is built. Resolved once, as the route is written, so a recorded route is always complete.
61
+ */
62
+ resolveRoute(selection: ModelSelection, base: ModelRoute): ModelRoute;
63
+ /**
64
+ * What the route's provider declares for its model: the usable context window, `null` when it
65
+ * declares none, whether its requests may carry provider-executed tools, and whether its tool
66
+ * results may carry images. Registry lookup only; throws when the provider is not registered.
67
+ */
68
+ capacity(route: Pick<ModelRoute, 'provider' | 'model'>): ModelCapacity;
69
+ /**
70
+ * The client a resolved route's provider sends through, the same for every model and effort: the
71
+ * provider's own, wrapped so a failed call is retried by its policy and otherwise throws a
72
+ * `ModelCallError` with its kind and attempt count (see {@link RetryingClient}). The route's effort
73
+ * is not applied here: a request carries it, or leaves the provider's own default. Throws when its
74
+ * provider is not registered.
75
+ */
76
+ clientFor(route: ModelRoute): ModelCallClient;
77
+ /** Removes the clients of the providers `owned` names, synchronously. */
78
+ private detachClients;
79
+ /** Disposes each provider client, once: the one that owns its transport owns its cleanup. */
80
+ private disposeClients;
81
+ }
82
+ export {};
@@ -0,0 +1,65 @@
1
+ import type { Context } from '@leuduan/cordis';
2
+ import type { PluginJournal } from '../journal/index.js';
3
+ import type { WriteRows } from '../state/index.js';
4
+ /** One set of durable modes, as {@link defineModes} takes it. */
5
+ export type ModesDefinition<Mode extends string> = {
6
+ /** Names the modes in the journal, so two sets never mix. */
7
+ readonly name: string;
8
+ /**
9
+ * Where a thread's mode is recorded and read: on the thread itself, or on its origin root
10
+ * (`Thread.originRoot`), so a delegated thread is in its conversation's mode and switching the
11
+ * conversation switches every thread it started.
12
+ */
13
+ readonly authority: 'thread' | 'conversation';
14
+ /** The mode before one is recorded. */
15
+ readonly initial: NoInfer<Mode>;
16
+ /** Every mode the set has; what each one means belongs to the feature that reads it. */
17
+ readonly modes: readonly Mode[];
18
+ };
19
+ /**
20
+ * A set of durable modes: the state a feature reads to decide what a thread may do, and the host's
21
+ * way to set it. Each read and write takes a context that injects `journal` and `threads`.
22
+ */
23
+ export type Modes<Mode extends string = string> = ModesDefinition<Mode> & {
24
+ /** The mode in force on `threadId`: its authority's latest recorded mode, or `initial`. */
25
+ of(ctx: Context, threadId: string): Mode;
26
+ /** Records `mode` on `threadId`'s authority, only when it changes it, decided inside the write. */
27
+ set(ctx: Context, threadId: string, mode: Mode): Promise<void>;
28
+ /**
29
+ * The rows that record `mode` in the write that creates or forks a thread (`Opening.rows`),
30
+ * so the thread never exists in another mode: always one row, `initial` included, so an opening
31
+ * leaves evidence of the choice (a fork would otherwise go on in the mode it inherits). The mode
32
+ * is validated here, before anything is written. Refused inside the write, which then records
33
+ * nothing, anywhere but an opening write, and for a thread with an `origin` under `conversation`
34
+ * authority, which is in its conversation's mode.
35
+ */
36
+ opening(mode: Mode): WriteRows;
37
+ /**
38
+ * The thread a mode is recorded on for `threadId`: itself, or for `conversation`, its
39
+ * `originRoot`. Throws {@link MissingAuthorityError} when that root cannot be found, so no thread
40
+ * part-way up is taken for it; a thread the catalog does not hold is its own.
41
+ */
42
+ authorityOf(ctx: Context, threadId: string): string;
43
+ /** The mode recorded on `threadId` itself, or `null`: what a catalog contribution computes. */
44
+ recorded(journal: PluginJournal, threadId: string): Mode | null;
45
+ };
46
+ /** A conversation mode asked for a thread whose caller chain does not reach its origin root. */
47
+ export declare class MissingAuthorityError extends Error {
48
+ constructor(threadId: string, modes: string);
49
+ }
50
+ /**
51
+ * Defines a set of durable modes, once per `name` in a process. A mode is an `ext` row on the
52
+ * authority thread, declared policy state, so a switch while a call is authorized decides it again.
53
+ * The set owns that state only: what a mode means, and what the model is told about it, belong to
54
+ * the feature that reads it (see `toolPolicy`).
55
+ *
56
+ * ```ts
57
+ * const permissions = defineModes<'ask' | 'auto'>({
58
+ * name: 'app:permission',
59
+ * authority: 'conversation',
60
+ * initial: 'ask',
61
+ * modes: ['ask', 'auto'],
62
+ * })
63
+ * ```
64
+ */
65
+ export declare function defineModes<Mode extends string>(definition: ModesDefinition<Mode>): Modes<Mode>;
@@ -0,0 +1,34 @@
1
+ import { type Context } from '@leuduan/cordis';
2
+ /**
3
+ * Claims `key`, a thread by its id or by its activation's scope, for the calling plugin within
4
+ * `kind`, for as long as the calling plugin's fiber lives: for a behaviour a thread runs at most
5
+ * once, such as an `AGENTS.md` briefing. `holder` is
6
+ * how a later refusal names this claim. Throws `refusal(holder)` with the holder of a live claim of
7
+ * the same kind on the same key, so the plugin that claimed later fails, and with it the
8
+ * activation, rather than running beside the first. Claims of different kinds never meet.
9
+ *
10
+ * Synchronous: the check and the claim are one step, and the claim is an effect of the caller's
11
+ * fiber, so a release, an unload or a failed setup frees the thread for the next activation.
12
+ */
13
+ export declare function claimThread(ctx: Context, kind: string, key: unknown, holder: string, refusal: (holder: string) => string): void;
14
+ /**
15
+ * Runs `drain` before any owner of `ctx` starts its cleanup, and before the journal's owner does:
16
+ * as an unload guard on every fiber from `ctx` up to the root, and on the fiber that provides the
17
+ * journal. Guards on one fiber run together before its disposers, so every service draining this
18
+ * way is signalled before any of them is awaited, and the journal is still writable for their final
19
+ * rows. `drain` must be idempotent, since several owners can unload, and must not await its own
20
+ * owner's teardown, which waits for the guard.
21
+ */
22
+ export declare function drainBeforeUnload(ctx: Context, drain: () => Promise<void>): void;
23
+ /**
24
+ * The root service `name`, or a refusal naming `user`, the plugin or tool that depends on it, when
25
+ * it is not mounted. Checked where a plugin mounts, so a composition without the service fails
26
+ * there rather than leaving the plugin silently inactive, and looked up again at each call.
27
+ */
28
+ export declare function requireService<K extends string & keyof Context>(ctx: Context, name: K, user: string): NonNullable<Context[K]>;
29
+ /**
30
+ * Refuses a plugin mounted in a thread's scope when `name`, the thing mounted, serves every thread
31
+ * from the application root. The predicate is `scopeOf(ctx) === undefined`: an untagged application
32
+ * context passes, so this is not a root-identity check.
33
+ */
34
+ export declare function requireUnscoped(ctx: Context, name: string): void;
@@ -0,0 +1,154 @@
1
+ import { type Context, type Fiber, type Inject, type Plugin } from '@leuduan/cordis';
2
+ import type { z } from 'zod';
3
+ import type { InstallationLifetime } from '../../records/journal.js';
4
+ import { type JsonValue } from '../../util/json.js';
5
+ import { type AgentSelector } from '../agents.js';
6
+ import type { Thread } from '../threads/index.js';
7
+ /** What a preset's setup is told when it is mounted as one thread's recorded installation. */
8
+ export type PresetInstallation = {
9
+ readonly kind: 'installation';
10
+ readonly thread: Thread;
11
+ readonly installationId: string;
12
+ /**
13
+ * `defining` when the thread's spawn row recorded it so (`create`'s `installations`, or a
14
+ * hand-down), on this thread or on the one a fork inherited it from, and it can never be removed;
15
+ * `configurable` otherwise. Read from the record.
16
+ */
17
+ readonly lifetime: InstallationLifetime;
18
+ /**
19
+ * Aborts when this run of `setup` is unloaded, before its cleanups: when the thread's activation
20
+ * is released, which every application or removal on the thread does, when the application shuts
21
+ * down, and when an injected service goes away once `setup` has returned, after which `setup` runs
22
+ * again with a new signal. A `setup` still pending when a service goes away is not interrupted:
23
+ * it is unloaded, and run again, once it returns. A setup that rejects with the reason it was
24
+ * aborted with, or with an error whose `cause` is that reason, as Node's abortable APIs do, is not
25
+ * a failure, since the installation is going away; any other error is reported.
26
+ */
27
+ readonly signal: AbortSignal;
28
+ };
29
+ /**
30
+ * What a preset's setup is told when a root mount for an agent selector runs it on a thread whose
31
+ * agent it selects: the thread, never recorded. A selected setup hands nothing down: a hand-down
32
+ * belongs to a thread's recorded installation, so a setup that hands down checks its place first.
33
+ */
34
+ export type PresetSelection = {
35
+ readonly kind: 'selected';
36
+ readonly thread: Thread;
37
+ /**
38
+ * Aborts when this run of `setup` is unloaded, before its cleanups: when the activation goes,
39
+ * when the root mount is disposed, and when an injected service goes away. A setup that rejects
40
+ * with the reason it was aborted with is not a failure, as for an installation.
41
+ */
42
+ readonly signal: AbortSignal;
43
+ };
44
+ /**
45
+ * Where a setup runs: a thread's installation, or a thread a root mount for an agent selector chose.
46
+ * Every setup runs in its thread's scope, where the agent it equips is `[place.thread.agentName]`.
47
+ * A preset mounted from a setup is told the same place, with a signal that also aborts when that
48
+ * setup is unloaded.
49
+ *
50
+ * A setup still pending is not interrupted by its own unload: cordis defers a `dispose`, `update`
51
+ * or `restart` until the setup returns, and only then aborts its signal and runs its cleanups. So a
52
+ * setup that waits for its signal ends only on an abort from outside: the activation going, or an
53
+ * enclosing setup that has returned being unloaded.
54
+ */
55
+ export type PresetPlace = PresetInstallation | PresetSelection;
56
+ /**
57
+ * Where a preset may be placed. `thread`: applied to one thread at any time, or mounted on the root
58
+ * for an agent selector, once per installation or selected activation, so only for members safe to mount many times
59
+ * (agents with scoped names, tools, grants, prompt contributions and listeners; no services,
60
+ * installers or nested scopes). `creation`: recorded only with a thread's spawn row as a defining
61
+ * installation, never mounted or applied later, and never removable.
62
+ */
63
+ export type PresetPlacement = 'thread' | 'creation';
64
+ /**
65
+ * A preset: a named, configurable set of plugins, as plain data and a `setup`. `mountPreset`
66
+ * mounts it directly, and the presets service mounts it as a thread's recorded installation;
67
+ * declare it with `definePreset`, which checks it.
68
+ */
69
+ export type Preset<Schema extends z.ZodType = z.ZodType> = {
70
+ /**
71
+ * What a thread's installation records and is restored by. Give the preset a new id (convention:
72
+ * a `#N` suffix, `codex#2`) when the configuration it records changes shape or meaning, so an
73
+ * old installation is refused as an unknown preset; behaviour and prompt changes keep the id.
74
+ */
75
+ readonly id: string;
76
+ /**
77
+ * JSON in and JSON out: validate strictly (`z.strictObject`), apply defaults, and leave runtime
78
+ * transformations to `setup`. The parsed result is what a thread records, and restoring parses it
79
+ * again, so it must parse back to itself. An omitted configuration parses as `{}`, so give fields
80
+ * defaults rather than the schema a top-level `.default()`.
81
+ */
82
+ readonly schema: Schema;
83
+ readonly placement: PresetPlacement;
84
+ /**
85
+ * For a creation preset that defines the agent its thread runs on: the agent name its
86
+ * configuration defines. A creation checks it against the thread's agent before anything is
87
+ * recorded. Refused on any other placement, where nothing would check it.
88
+ */
89
+ readonly definesAgent?: (config: z.output<Schema>) => string;
90
+ /** The services `setup` uses directly, as for any plugin; members declare their own. */
91
+ readonly inject?: Inject;
92
+ /**
93
+ * Mounts the preset's members through `ctx`, in the scope of the thread `place` names: one
94
+ * thread's recorded installation, or a thread a root mount for an agent selector chose. A preset
95
+ * mounted from another's setup is told that one's place.
96
+ */
97
+ setup(ctx: Context, config: z.output<Schema>, place: PresetPlace): void | Promise<void>;
98
+ };
99
+ /** A preset whatever its schema, where presets of every schema are kept or passed through. */
100
+ export type AnyPreset = Preset<any>;
101
+ /** Checks `preset`, which is otherwise used as it is given. */
102
+ export declare function definePreset<Schema extends z.ZodType>(preset: Preset<Schema>): Preset<Schema>;
103
+ /** Where a mount places a preset. */
104
+ export type PresetMountOptions = {
105
+ /**
106
+ * Runs the setup in the scope of each activation whose agent this selects, from then on;
107
+ * disposing the mount disposes it on live threads too. Required on the untagged application
108
+ * context, and refused anywhere else.
109
+ */
110
+ readonly agents?: AgentSelector;
111
+ };
112
+ /** Optional exactly when the schema accepts an empty object, which is what an omitted one parses as. */
113
+ type MountArguments<Schema extends z.ZodType> = {} extends z.input<Schema> ? [config?: z.input<Schema>, options?: PresetMountOptions] : [config: z.input<Schema>, options?: PresetMountOptions];
114
+ /**
115
+ * Mounts `preset` with `config`, validated by its schema. With `agents`, on the root for those
116
+ * agents: the setup runs in each selected activation's scope, told the thread (`PresetSelection`),
117
+ * the one way to put a per-thread capability on every thread of some agents. Without, from another
118
+ * preset's setup, beside its members: told that setup's place, it serves the same thread for as long
119
+ * as that setup runs. Refused anywhere else, since a setup always serves one thread. Nothing is
120
+ * recorded either way; a thread keeps a preset across reopening and forks only through
121
+ * `thread.configure`. A creation preset cannot be mounted. Resolves like `ctx.plugin`, and fails the
122
+ * same way when the configuration is refused or the setup throws.
123
+ */
124
+ export declare function mountPreset<Schema extends z.ZodType>(ctx: Context, preset: Preset<Schema>, ...[config, options]: MountArguments<Schema>): Fiber & PromiseLike<Fiber>;
125
+ declare const kInstalled: unique symbol;
126
+ /**
127
+ * How the presets service mounts a thread's installation through {@link presetPlugin}: the recorded
128
+ * configuration with the installation, under a key no caller's configuration carries, so a direct
129
+ * mount's configuration stays the caller's own, `fiber.update()` included.
130
+ */
131
+ export declare const installedMount: (config: JsonValue, installation: Omit<PresetInstallation, "kind">) => {
132
+ [kInstalled]: {
133
+ config: z.core.util.JSONType;
134
+ installation: Omit<PresetInstallation, "kind">;
135
+ };
136
+ };
137
+ /**
138
+ * The one plugin that mounts `preset`, as a thread's installation, for a selected thread, or from
139
+ * another preset's setup: one per preset, named after it, injecting what its setup declares.
140
+ */
141
+ export declare function presetPlugin(preset: AnyPreset): Plugin.Object<unknown>;
142
+ /**
143
+ * Validates `input` with the preset's schema, defaults applied, and returns the result as frozen
144
+ * JSON: the value both a direct mount and a thread installation hand to `setup`, and the one a
145
+ * thread records. Throws when the schema rejects the input or its result is not JSON.
146
+ */
147
+ export declare function parsePresetConfig(preset: AnyPreset, input: unknown): JsonValue;
148
+ /**
149
+ * Throws `message` unless `config`, a configuration the schema produced, parses back to itself: all
150
+ * that restoring a recorded installation relies on. Checked before recording, so a schema that
151
+ * transforms its output fails when applied rather than every time the thread reopens.
152
+ */
153
+ export declare function assertRereadable(preset: AnyPreset, config: JsonValue, message: string): void;
154
+ export {};