@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,65 @@
1
+ import { z } from 'zod';
2
+ import type { ContentPart } from '../llm/content.js';
3
+ export declare const ToolResultPayloadSchema: z.ZodObject<{
4
+ output: z.ZodString;
5
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ type: z.ZodLiteral<"text">;
7
+ text: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ type: z.ZodLiteral<"image">;
10
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
11
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
12
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
13
+ detail: z.ZodDefault<z.ZodEnum<{
14
+ auto: "auto";
15
+ low: "low";
16
+ high: "high";
17
+ }>>;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ type: z.ZodLiteral<"file">;
20
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
21
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
22
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
23
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
24
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
25
+ }, z.core.$strip>], "type">>>;
26
+ is_error: z.ZodDefault<z.ZodBoolean>;
27
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
28
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
29
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
30
+ }, z.core.$strip>;
31
+ export type ToolResultPayload = z.infer<typeof ToolResultPayloadSchema>;
32
+ /** A payload as a tool writes one: `is_error`, `notes` and `metadata` may be left out. */
33
+ export type ToolResultPayloadInput = z.input<typeof ToolResultPayloadSchema>;
34
+ export declare const ToolResultSchema: z.ZodObject<{
35
+ output: z.ZodString;
36
+ content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
37
+ type: z.ZodLiteral<"text">;
38
+ text: z.ZodString;
39
+ }, z.core.$strip>, z.ZodObject<{
40
+ type: z.ZodLiteral<"image">;
41
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
42
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
43
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
44
+ detail: z.ZodDefault<z.ZodEnum<{
45
+ auto: "auto";
46
+ low: "low";
47
+ high: "high";
48
+ }>>;
49
+ }, z.core.$strip>, z.ZodObject<{
50
+ type: z.ZodLiteral<"file">;
51
+ file_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
52
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
53
+ data: z.ZodDefault<z.ZodNullable<z.ZodString>>;
54
+ filename: z.ZodDefault<z.ZodNullable<z.ZodString>>;
55
+ media_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
56
+ }, z.core.$strip>], "type">>>;
57
+ is_error: z.ZodDefault<z.ZodBoolean>;
58
+ notes: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
59
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
+ concludes_turn: z.ZodOptional<z.ZodLiteral<true>>;
61
+ call_id: z.ZodString;
62
+ name: z.ZodString;
63
+ }, z.core.$strip>;
64
+ export type ToolResult = z.infer<typeof ToolResultSchema>;
65
+ export declare function toolResultMessageContent(result: ToolResult): ContentPart[];
@@ -0,0 +1,62 @@
1
+ import { Context, Service, type ScopeKey } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type AgentDefinition, type AgentDefinitionInput } from '../loop/index.js';
4
+ /** A definition and the layer that registered it: `undefined` for the global one. */
5
+ export type AgentResolution = {
6
+ readonly agent: AgentDefinition;
7
+ readonly layer: ScopeKey | undefined;
8
+ };
9
+ /**
10
+ * The agents this process can run. Live: a registration lasts exactly as long as the plugin
11
+ * that made it, and a thread resolves its agent from the scope it runs in, not when it was created.
12
+ *
13
+ * Layered by Cordis scope like tools: an untagged registration is global, a scoped one is visible
14
+ * from that scope and its descendants, and the closest definition of a name wins. Global and scoped
15
+ * names are disjoint (`isScopedAgentName`): a scoped name contains a dot and a global one does not,
16
+ * so a scoped agent can never answer to a name a global one has, or will have.
17
+ */
18
+ export declare class AgentsService extends Service {
19
+ private readonly layers;
20
+ constructor(ctx: Context);
21
+ /** Agent names visible from `scope`, sorted and deduplicated. */
22
+ names(scope: ScopeKey | undefined): string[];
23
+ /**
24
+ * Every agent visible from `scope`, each name once with its closest definition: the global
25
+ * layer's first, then each closer layer's, each in registration order.
26
+ */
27
+ all(scope: ScopeKey | undefined): AgentDefinition[];
28
+ has(scope: ScopeKey | undefined, name: string): boolean;
29
+ get(scope: ScopeKey | undefined, name: string): AgentDefinition | undefined;
30
+ /** The definition, or a thrown `UnknownAgentError`. */
31
+ require(scope: ScopeKey | undefined, name: string): AgentDefinition;
32
+ /** The closest definition of `name` visible from `scope`, with the layer that registered it. */
33
+ resolve(scope: ScopeKey | undefined, name: string): AgentResolution | undefined;
34
+ /** Adds an agent to one layer; returns the unregister function. Duplicates fail within that layer. */
35
+ register(scope: ScopeKey | undefined, agent: AgentDefinitionInput): () => void;
36
+ }
37
+ /** Registers an agent in the calling plugin's layer for the lifetime of its fiber. */
38
+ export declare const registerAgent: (ctx: Context, agent: AgentDefinitionInput) => (() => void | Promise<void>);
39
+ /**
40
+ * The agents a plugin's `agents` option selects. Required wherever it appears: which agents a
41
+ * composition has is the host's to say, so none of the shipped plugins defaults it. `'global'` is
42
+ * every globally registered agent, those registered later included; `'all'` is every thread's agent,
43
+ * scoped ones included; a list names agents, global or scoped.
44
+ */
45
+ export declare const AgentSelectorSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodLiteral<"global">, z.ZodLiteral<"all">]>;
46
+ export type AgentSelector = readonly string[] | 'global' | 'all';
47
+ /**
48
+ * Whether `selector` selects `agentName`. One meaning wherever a selector appears, whether the plugin
49
+ * equips (a grant, a prompt section, a notice) or restricts (a mode, a stop check). `'global'` never
50
+ * selects a scoped agent (`isScopedAgentName`), so a role child gets only what names it or says
51
+ * `'all'`; a gate that must cover role children says `'all'`.
52
+ *
53
+ * Registries are live, so a selector is a predicate evaluated when the plugin acts — granting,
54
+ * rendering a prompt section, authorizing a call — rather than a list resolved once at mount.
55
+ */
56
+ export declare const selects: (selector: AgentSelector, agentName: string) => boolean;
57
+ /**
58
+ * Whether `name` is an agent name for a scoped registration: one containing a dot, such as
59
+ * `codex.explore`. Global agent names never contain one, so the two kinds cannot collide, and the
60
+ * agents registry refuses a registration of the wrong kind.
61
+ */
62
+ export declare const isScopedAgentName: (name: string) => boolean;
@@ -0,0 +1,73 @@
1
+ import type { Context } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import type { PluginJournal, ThreadSummaryCore } from '../journal/index.js';
4
+ import type { DeepReadonly, JsonValue } from '../util/json.js';
5
+ /** What one thread's contribution says, as {@link ContributionDefinition.read} reports it. */
6
+ export type ContributionReading<T> =
7
+ /** The thread's value: computed from its folds when it is loaded, else the catalog's cached copy. */
8
+ {
9
+ readonly status: 'available';
10
+ readonly value: DeepReadonly<T>;
11
+ }
12
+ /** The contribution is not about this thread: its `applies` says no. */
13
+ | {
14
+ readonly status: 'not-applicable';
15
+ }
16
+ /** It applies, but there is no valid value to read: nothing nor no one computed it, or it fails its schema or version. Never read as an empty value. */
17
+ | {
18
+ readonly status: 'unavailable';
19
+ readonly reason: string;
20
+ };
21
+ export type ContributionDefinitionInput<T extends JsonValue> = {
22
+ /** Where the value sits in a thread's catalog entry; one definition per key. */
23
+ key: string;
24
+ /** The shape of what is cached; a changed shape is recomputed, never migrated. */
25
+ schema: z.ZodType<T>;
26
+ /** An integer that changes when the value's meaning does, though its shape does not: entries with another one are recomputed. */
27
+ version: number;
28
+ /** Whether the thread has a value. Decided from the catalog entry alone, so a reader needs nothing loaded. */
29
+ applies(summary: ThreadSummaryCore): boolean;
30
+ /**
31
+ * The value from the thread's folds, synchronously. Total for a thread that applies: a failure
32
+ * throws, and the entry is then missing and reads `unavailable`, never an empty value. It
33
+ * must return JSON, and may return what a fold holds read-only: the result is validated and copied.
34
+ */
35
+ compute(journal: PluginJournal, threadId: string): NoInfer<DeepReadonly<T>>;
36
+ };
37
+ /** A summary contribution: define it once at module level, register it from a service, read it where it is needed. */
38
+ export type ContributionDefinition<T extends JsonValue> = {
39
+ readonly key: string;
40
+ /**
41
+ * Computes the value into every thread's catalog entry with each write group, for the lifetime of
42
+ * `ctx`, and queues the refresh of the entries that are missing, fail the schema or carry another
43
+ * version. `refreshed` settles when it has run, with the threads whose repair failed: they keep
44
+ * an entry without the key and read `unavailable`. A service waits for it before it serves from
45
+ * the catalog.
46
+ */
47
+ register(ctx: Context): {
48
+ readonly refreshed: Promise<string[]>;
49
+ };
50
+ /**
51
+ * What `threadId` says. A loaded thread computes from its folds, so it reads the same with the
52
+ * contributing service unmounted; any other validates the cached entry. Never loads a thread and
53
+ * never queues a repair.
54
+ */
55
+ read(journal: PluginJournal, threadId: string): ContributionReading<T>;
56
+ };
57
+ /**
58
+ * Defines a typed, versioned contribution to every thread's catalog entry: what is read of a thread
59
+ * that is not loaded, as after a restart, or by a listing that loads nothing.
60
+ *
61
+ * ```ts
62
+ * const openTasks = defineContribution({
63
+ * key: 'app:open-tasks',
64
+ * version: 1,
65
+ * schema: z.number(),
66
+ * applies: (summary) => summary.origin !== null,
67
+ * compute: (journal, threadId) => journal.state(tasks, threadId).size,
68
+ * })
69
+ * openTasks.register(ctx) // in a service
70
+ * openTasks.read(ctx.journal, threadId) // { status: 'available', value: 2 }
71
+ * ```
72
+ */
73
+ export declare function defineContribution<T extends JsonValue>(input: ContributionDefinitionInput<T>): ContributionDefinition<T>;
@@ -0,0 +1,118 @@
1
+ import { type Stats } from 'node:fs';
2
+ import type { FileAccess, FilePolicy } from './service.js';
3
+ /**
4
+ * The scoped file facade: how file tools touch the file system. One implementation, owned by the
5
+ * operation (`ConfinementOperation.files`), which applies the operation's `FilePolicy` to every
6
+ * path and ends with the operation. With no policy it authorizes everything but keeps the same
7
+ * lifetime rules, so a tool cannot tell which it has.
8
+ *
9
+ * Every check covers the path as requested (absolute and normalized) and the path it resolves to,
10
+ * resolved natively so it carries the volume's own spelling, and a path is refused when either is.
11
+ * A file is opened by its resolved path without following a final link, and the handle is verified
12
+ * (the file opened is the file approved, and the requested path still leads to it) before any byte
13
+ * is read through it. This narrows the race between check and use to the revalidation window; it does
14
+ * not close it, and hard links are not detected.
15
+ *
16
+ * Changes are primitives on regular files, never a write of a whole file: a file is created exclusively
17
+ * (never opened for writing over what exists, and never truncated), and committed by `link` or
18
+ * `rename`, which the caller owns. A directory is never renamed or removed, and nothing is changed
19
+ * through a link: the target of a change is refused when it is itself a symbolic link, naming where it
20
+ * leads. Each primitive judges its paths at the moment it runs, so a path swapped after the caller's
21
+ * own checks is judged as it is then.
22
+ */
23
+ /** A refusal by the file policy, whose message is for the model. */
24
+ export declare class FileAccessError extends Error {
25
+ constructor(message: string);
26
+ }
27
+ /** An open file as a tool may use it: reads only, through the handle the facade verified. */
28
+ export type ReadHandle = {
29
+ /** Up to `length` bytes from `position`; fewer only at the end of the file. */
30
+ read(position: number, length: number): Promise<Buffer>;
31
+ /** All of the file from its start. */
32
+ readAll(): Promise<Buffer>;
33
+ /** The opened file's own metadata. */
34
+ stat(): Promise<Stats>;
35
+ close(): Promise<void>;
36
+ };
37
+ /** A new file as a tool may fill it: writes only, through the handle the facade created. */
38
+ export type WriteHandle = {
39
+ /** Appends all of `data`. */
40
+ write(data: Uint8Array): Promise<void>;
41
+ /** Flushes what was written to the device. */
42
+ sync(): Promise<void>;
43
+ /** The created file's own metadata. */
44
+ stat(): Promise<Stats>;
45
+ close(): Promise<void>;
46
+ };
47
+ /** Which access a call judges its paths for: a read unless the caller says what it intends. */
48
+ export type PathOptions = {
49
+ readonly access?: readonly FileAccess[];
50
+ };
51
+ /** One entry of a directory the policy lets through. */
52
+ export type DirEntry = {
53
+ readonly name: string;
54
+ readonly isDirectory: boolean;
55
+ readonly isSymbolicLink: boolean;
56
+ };
57
+ /** A directory's allowed entries, and how many the policy hid. */
58
+ export type DirListing = {
59
+ readonly entries: readonly DirEntry[];
60
+ readonly hidden: number;
61
+ };
62
+ /**
63
+ * What a tool does to files, within one operation. Paths are absolute. Every method rejects with a
64
+ * {@link FileAccessError} for a path the policy refuses, and with an ordinary error once the
65
+ * operation has ended or was aborted: a reference that outlives its call is dead.
66
+ */
67
+ export type FileScope = {
68
+ /**
69
+ * Names how this facade judges reads (`FilePolicy.identity`, or `unrestricted` with no policy): taking
70
+ * it takes the operation's snapshot, so a refused operation rejects here. What a reader that keeps
71
+ * its result for another thread to use keys it by.
72
+ */
73
+ identity(): Promise<string>;
74
+ /** Opens a file for reading, where links resolve and are checked. Never a raw descriptor. */
75
+ open(path: string): Promise<ReadHandle>;
76
+ /** The entries of a directory, with every entry the policy refuses (or a link resolving to one) left out and counted. */
77
+ readdir(path: string): Promise<DirListing>;
78
+ /** Metadata of the file a path leads to. */
79
+ stat(path: string, options?: PathOptions): Promise<Stats>;
80
+ /** Metadata of a path itself, not of what a final link leads to. */
81
+ lstat(path: string, options?: PathOptions): Promise<Stats>;
82
+ /**
83
+ * The path with every link resolved, as the checks see it; a missing tail stays as named, after the
84
+ * nearest existing ancestor's real path. `options.access` names what the caller means to do with it.
85
+ */
86
+ realpath(path: string, options?: PathOptions): Promise<string>;
87
+ /**
88
+ * Creates a new file that must not exist, with `mode` as given, for writing; never replaces or truncates.
89
+ * A `temporary` file is the caller's scratch: it may be removed with `unlink` even after a cancellation,
90
+ * and is removed when the operation ends unless the caller has put it elsewhere.
91
+ */
92
+ create(path: string, options?: {
93
+ readonly mode?: number;
94
+ readonly temporary?: boolean;
95
+ }): Promise<WriteHandle>;
96
+ /** Creates a directory and any missing parents. */
97
+ mkdir(path: string): Promise<void>;
98
+ /** Hard-links the regular file `existing` as `created`, which must not exist. */
99
+ link(existing: string, created: string): Promise<void>;
100
+ /** Renames a regular file over `to`, which is absent or a regular file; a directory is never renamed. */
101
+ rename(from: string, to: string): Promise<void>;
102
+ /** Removes a regular file; a directory is never removed. A `temporary` file this operation created goes even after a stop. */
103
+ unlink(path: string): Promise<void>;
104
+ /** Sets the mode of a regular file. */
105
+ chmod(path: string, mode: number): Promise<void>;
106
+ };
107
+ /** What the operation hands its facade. */
108
+ export type FileScopeHost = {
109
+ /** The operation's policy, which the first call takes; `null` for no path policy. Rejects when the operation is refused. */
110
+ policy(): Promise<FilePolicy | null>;
111
+ /** Aborts when the call is cancelled, the operation ends or its handler is released: checked between file system calls. */
112
+ signal(): AbortSignal;
113
+ };
114
+ /** The facade's lifetime: `end` closes what it opened and kills its methods. */
115
+ export type EndableFileScope = FileScope & {
116
+ end(): Promise<void>;
117
+ };
118
+ export declare function fileScope(host: FileScopeHost): EndableFileScope;
@@ -0,0 +1,219 @@
1
+ import { Service, type Context } from '@leuduan/cordis';
2
+ import { z } from 'zod';
3
+ import { type SpawnedCommand, type SpawnedGroup, type SpawnedPipes, type SpawnEnvironment } from '../../sys/spawn.js';
4
+ import { type FileScope } from './files.js';
5
+ /**
6
+ * How a model-driven process becomes a local launch: the one place `run_command`, the search tools,
7
+ * and later other model-driven processes such as MCP stdio servers, start a process, so a host's
8
+ * confinement sees every one. Not `sys/spawn`: lagent's own spawns (git, the shell probe, stop-check
9
+ * hooks) call `spawnCommand` directly and are never intercepted.
10
+ */
11
+ /** Which launch a process got, recorded with it: never secrets, ids or ports. */
12
+ export declare const LaunchProvenanceSchema: z.ZodObject<{
13
+ launcher: z.ZodString;
14
+ version: z.ZodString;
15
+ policy: z.ZodString;
16
+ }, z.core.$strict>;
17
+ export type LaunchProvenance = z.output<typeof LaunchProvenanceSchema>;
18
+ /** The `policy` of a launch a handler chose to run unconfined: what a host or a listing marks as such. */
19
+ export declare const UNCONFINED_LAUNCH = "unconfined";
20
+ /**
21
+ * What runs. `shell` is text for `/bin/sh -c`, launched with stdout and stderr joined in order, as a
22
+ * command line is. `argv` is a program and its arguments, run without a shell, launched with a
23
+ * writable stdin and stdout and stderr apart, as a tool that parses a program's output needs them.
24
+ */
25
+ export type LaunchProgram = {
26
+ readonly shell: string;
27
+ } | {
28
+ readonly argv: readonly [string, ...string[]];
29
+ };
30
+ /**
31
+ * What to launch and the geometry to confine (`root`, `scratch`). The thread it serves, the subject
32
+ * of a handler's per-thread policy, is the one its operation was opened for.
33
+ */
34
+ export type LaunchRequest = {
35
+ readonly program: LaunchProgram;
36
+ /** Absolute: where it starts. */
37
+ readonly workdir: string;
38
+ /** The writable root the protected names are rebuilt for: the thread's working directory for commands. */
39
+ readonly root: string;
40
+ /** Keys the process's temporary directory: `threadScratch(id)` for commands. Equal keys share one directory. */
41
+ readonly scratch: string;
42
+ /** The process's environment: the caller's. */
43
+ readonly environment: SpawnEnvironment;
44
+ /** Aborting it stops the launch: preparation at once, and the process within its stop bound. */
45
+ readonly signal: AbortSignal;
46
+ };
47
+ export type LaunchOptions = {
48
+ readonly timeoutMs?: number;
49
+ readonly killGraceMs: number;
50
+ /** Awaited before the process is released, as `spawnCommand`'s, with the launch it got. */
51
+ readonly beforeRelease?: (pgid: number, launch: LaunchProvenance | null) => Promise<void>;
52
+ };
53
+ /** The program a launch runs when nothing confines it: the argv itself, or `/bin/sh -c` for shell text. */
54
+ export declare function plainArgv(program: LaunchProgram): readonly [string, ...string[]];
55
+ /** A local process to spawn in place of the request's program, from the same stdio form. */
56
+ export type PreparedLaunch = {
57
+ readonly argv: readonly [string, ...string[]];
58
+ readonly cwd: string;
59
+ readonly env: SpawnEnvironment;
60
+ readonly provenance: LaunchProvenance;
61
+ /** After the process ended: bounded report lines, or `null`. Never rejects the process's outcome. */
62
+ violations(): Promise<string | null>;
63
+ };
64
+ /** What a tool does to a path. */
65
+ export type FileAccess = 'read' | 'write';
66
+ /** A path's verdict: allowed, or refused with a message for the model. */
67
+ export type FileVerdict = {
68
+ readonly allowed: true;
69
+ } | {
70
+ readonly allowed: false;
71
+ readonly reason: string;
72
+ };
73
+ /**
74
+ * What a handler lets file tools reach, judged by name over absolute paths and never from the file
75
+ * system: a tool that follows links asks about the path it was given and about where it resolves,
76
+ * and needs both allowed.
77
+ */
78
+ export type FilePolicy = {
79
+ check(path: string, access: FileAccess): FileVerdict;
80
+ /**
81
+ * Names how this policy judges a read: two policies with equal identities answer every read alike.
82
+ * What a reader that shares its result between threads (a catalog of skills) keys it by, so what
83
+ * one thread was allowed to read is never handed to another that was not.
84
+ */
85
+ readonly identity: string;
86
+ };
87
+ /** The `scratch` key of a thread's own processes, which is also the directory its file tools may write besides its root. */
88
+ export declare const threadScratch: (threadId: string) => string;
89
+ /**
90
+ * What one operation's launches are prepared under: the handler's decisions for a thread, taken
91
+ * once, so every launch of the operation gets the same ones whatever changes meanwhile.
92
+ */
93
+ export type ConfinementSnapshot = {
94
+ /** The thread's file policy, the one its launches are confined by; `null` for no path policy at all. */
95
+ readonly files: FilePolicy | null;
96
+ /** Rejects, with a message for the model, to refuse the launch. */
97
+ prepare(request: LaunchRequest): Promise<PreparedLaunch>;
98
+ };
99
+ /** What confines launches, such as the OS sandbox of `@leuduan/lagent/plugins/sandbox`. */
100
+ export type ConfinementHandler = {
101
+ /** Rejects, with a message for the model, to refuse the operation: nothing of it is admitted. */
102
+ snapshot(threadId: string): Promise<ConfinementSnapshot>;
103
+ };
104
+ export type ConfinementHandle = {
105
+ /**
106
+ * Says that what an operation opened from now on would be allowed has changed, such as a thread's
107
+ * mode: content a reader prepared before (`ConfinementService.epoch` then differs from the one it
108
+ * noted) was read under what no longer holds, and is not delivered.
109
+ */
110
+ changed(): void;
111
+ /**
112
+ * Stops admitting through the handler, aborts every launch it prepared, and waits for each one's
113
+ * preparation, process and report within `timeoutMs`. Resolves `true` only when every group was
114
+ * confirmed stopped: no `stopFailed` result, ever, and nothing still running at the bound.
115
+ * Idempotent: every caller shares the first call's result.
116
+ */
117
+ release(timeoutMs: number): Promise<boolean>;
118
+ };
119
+ /**
120
+ * A launched process: its group, what it was launched as, and the handler's report once it ends.
121
+ * A `shell` program is a joined {@link SpawnedCommand}, an `argv` program {@link SpawnedPipes}.
122
+ */
123
+ export type Launched<Spawned extends SpawnedGroup = SpawnedCommand> = {
124
+ /** The actual directory selected for the process, including a confinement handler's choice. */
125
+ readonly cwd: string;
126
+ readonly spawned: Spawned;
127
+ readonly launch: LaunchProvenance | null;
128
+ /** Settles after `spawned.result`, within {@link DIAGNOSTICS_MS}; `null` for nothing to report. Never rejects. */
129
+ readonly diagnostics: Promise<string | null>;
130
+ };
131
+ /** How long after a process ended its report may take. */
132
+ export declare const DIAGNOSTICS_MS = 1000;
133
+ /**
134
+ * What one piece of model-driven work does under confinement: its launches and its file access, all
135
+ * under the one snapshot the operation takes on first use. What `run_command` takes for one command,
136
+ * and what the execution of one tool call is handed (`InvocationContext.operation`).
137
+ */
138
+ export type ConfinementOperation = {
139
+ /** Launches under the operation's snapshot, or plainly when no handler is registered. */
140
+ launch(request: LaunchRequest & {
141
+ program: {
142
+ shell: string;
143
+ };
144
+ }, options: LaunchOptions): Promise<Launched>;
145
+ launch(request: LaunchRequest & {
146
+ program: {
147
+ argv: readonly [string, ...string[]];
148
+ };
149
+ }, options: LaunchOptions): Promise<Launched<SpawnedPipes>>;
150
+ /**
151
+ * File access under the snapshot's {@link FilePolicy}, or none: the one way a tool touches files.
152
+ * Valid until {@link end}.
153
+ */
154
+ readonly files: FileScope;
155
+ /**
156
+ * Ends the file access: calls in flight settle, every handle it opened is closed, and every later
157
+ * use of `files`, or of a handle, fails. Launches are not ended with it: a process has a lifetime
158
+ * of its own. Idempotent.
159
+ */
160
+ end(): Promise<void>;
161
+ };
162
+ /**
163
+ * The confinement seam. With no handler, a launch is a plain spawn: `/bin/sh -c <command>` for shell
164
+ * text, the argv itself for an argv. The first {@link handle} declares for the root's lifetime that
165
+ * launches go through a handler, which decides what each operation gets (confinement, or refusal):
166
+ * from then on an operation with no live handler, because it was released, failed or never mounted
167
+ * again, is refused, and nothing falls back to a plain spawn. A host mounts the handler before
168
+ * anything launches.
169
+ *
170
+ * A handler is told nothing about consumers. It is released as a whole: core aborts what it
171
+ * admitted and reports whether every group stopped, so the handler may then free what confined them.
172
+ */
173
+ export declare class ConfinementService extends Service {
174
+ private readonly root;
175
+ private changes;
176
+ private holdReads;
177
+ constructor(ctx: Context);
178
+ /**
179
+ * Registers the one handler. Throws while another is live. Afterwards, until the root ends, an
180
+ * operation with no live handler is refused.
181
+ */
182
+ handle(handler: ConfinementHandler): ConfinementHandle;
183
+ /**
184
+ * A count of the changes to what an operation would be allowed: a handler registered or released,
185
+ * or one saying so (`ConfinementHandle.changed`). A reader that prepares content ahead of its
186
+ * delivery notes it before it reads, and delivers only if it still reads the same.
187
+ */
188
+ get epoch(): number;
189
+ /**
190
+ * Opens one operation for `threadId`. Nothing happens until it is used: its first launch or file
191
+ * access takes the handler's snapshot, once, which everything the operation does is prepared and
192
+ * checked under, and a refusal (the handler refuses the operation, or has stopped, or the caller's
193
+ * `signal` aborts first) rejects that use with a {@link CommandStartFailure}. With no handler
194
+ * registered the operation launches plainly and its file access has no policy. The caller ends it
195
+ * (`end`) when its call does.
196
+ */
197
+ open(threadId: string, signal: AbortSignal): ConfinementOperation;
198
+ /** The thread and the callers out to its origin root, held loaded; none for a thread the journal does not hold. */
199
+ private retainReads;
200
+ /**
201
+ * For the threads service, which owns what is loaded: how a thread and the histories a snapshot
202
+ * of it reads (its callers out to its origin root) are held loaded while the snapshot is taken;
203
+ * `null` for a thread the journal does not hold. Core's own, so that the dependency runs from
204
+ * threads to confinement. Returns what takes it back.
205
+ */
206
+ holdReadsWith(hold: (threadId: string) => Promise<{
207
+ release(): void;
208
+ } | null>): () => void;
209
+ /** The operation's one snapshot, tracked from before the handler hears of it, or none when no handler is registered. */
210
+ private takeSnapshot;
211
+ private requireLive;
212
+ /** One launch under a snapshot. */
213
+ private launchThrough;
214
+ private spawnPlain;
215
+ private spawnThrough;
216
+ private release;
217
+ /** Whether every operation settled within `timeoutMs` and no stop ever failed. */
218
+ private settle;
219
+ }
@@ -0,0 +1,28 @@
1
+ import type { Plugin } from '@leuduan/cordis';
2
+ import type { JournalStore } from '../journal/index.js';
3
+ import { type TurnLimits } from '../state/index.js';
4
+ export type CoreConfig = {
5
+ /** The journal's backing, constructed by the application. */
6
+ store: JournalStore;
7
+ /** Default `environment.cwd` for new threads; absolute. */
8
+ cwd: string;
9
+ limits?: Partial<TurnLimits>;
10
+ /**
11
+ * What becomes of a thread the owner loaded to run once its run lets go: `retire` takes it out of
12
+ * memory, `keep` leaves it loaded. Required: what to cache is the application's choice.
13
+ */
14
+ retention: 'retire' | 'keep';
15
+ /**
16
+ * How many reactive turns in a row a thread may run (turns its own work woke, such as notices)
17
+ * before a producer of more unattended work refuses: `ctx.threads.chain(threadId).atLimit`. A
18
+ * person's or an assignment's authority resets the count. Required: how much unattended work to
19
+ * allow is the application's choice.
20
+ */
21
+ chainLimit: number;
22
+ };
23
+ /**
24
+ * Mounts the core services on one root: `ctx.journal`, `ctx.llm`, `ctx.agents`, `ctx.tools`,
25
+ * `ctx.prompts`, `ctx.confinement`, `ctx.presets` and `ctx.threads`. Providers, tools, agents and
26
+ * capability plugins mount beside it.
27
+ */
28
+ export declare const core: Plugin.Object<CoreConfig>;