@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,66 @@
1
+ import { z } from 'zod';
2
+ import { type SpawnEnvironmentPolicy } from '../sys/environment.js';
3
+ /**
4
+ * Codex's policy: variables that look like credentials are dropped, the locale is fixed to UTF-8,
5
+ * and the {@link NON_INTERACTIVE_ENVIRONMENT} overrides are set.
6
+ */
7
+ export declare const CODEX_ENVIRONMENT_POLICY: SpawnEnvironmentPolicy;
8
+ /** Tools that create or modify files. */
9
+ export declare const WRITE_TOOLS: readonly ["edit_files"];
10
+ export declare const CodexPresetConfigSchema: z.ZodObject<{
11
+ explore: z.ZodPrefault<z.ZodObject<{
12
+ web: z.ZodDefault<z.ZodBoolean>;
13
+ }, z.core.$strict>>;
14
+ agentsMd: z.ZodObject<{
15
+ fileNames: z.ZodArray<z.ZodString>;
16
+ maxBytes: z.ZodNumber;
17
+ }, z.core.$strict>;
18
+ }, z.core.$strict>;
19
+ /** The explorer's role id, which is also the agent its children run on. */
20
+ export declare const EXPLORE_ROLE_ID = "codex.explore";
21
+ /** The general sub-agent's role id, which `delegate` starts. */
22
+ export declare const GENERAL_ROLE_ID = "codex.general";
23
+ /** The reviewer's role id, which `review` starts. */
24
+ export declare const REVIEW_ROLE_ID = "codex.review";
25
+ /**
26
+ * Equips a thread's agent for autonomous coding: the workspace tools that read and write, shell
27
+ * commands, web fetch and search, skills, questions to the user, the route notice, the date and
28
+ * branch at the start of each turn (`dateAndBranch`, for the agents it equips and not handed down),
29
+ * one `subAgents` with four endpoints, an `explore` sub-agent that only reads, a `delegate`
30
+ * sub-agent with a fresh context for a self-contained task, a `fork` of the caller, and a `review`
31
+ * sub-agent with the general sub-agent's tools and a reviewer's persona (`workerTools`),
32
+ * `message_agent`, `list_agents`, `read_agent` and `stop_agent` to continue, list, read and stop any
33
+ * of them, and a coding prompt that replaces the agent's base prompt. A sub-agent's role is frozen
34
+ * on it, so a reviewer continued with `message_agent` stays a reviewer; nothing but its prompt keeps
35
+ * it from repairing, and the host's permission policy decides what its calls may do.
36
+ * It grants the file and web tools, the command tools, `skill` and the `delegations` tools rather than
37
+ * registering them: it relies on the host registering `fileTools`, `webTools`, `commands`, `skills` and
38
+ * `delegations` on the root, where its endpoints also find the tools they grant their children, and
39
+ * mounting the `ask` service there, which `ask_question` asks through and refuses to mount without.
40
+ * `skills` searches the host's skill roots, which a configuration may not record, so codex refuses
41
+ * to mount without it. The `subAgents` codex mounts refuses to mount without `delegations`, which
42
+ * owns every delegation and registers its tools.
43
+ *
44
+ * It equips the agent of the thread it is placed on: installed there, mounted from the setup of a
45
+ * host preset placed there, or chosen by a root mount for an agent selector.
46
+ *
47
+ * Workspace instructions (`agentsMd`): it tells its thread. Installed, its own installation or the
48
+ * host preset's that mounts it, it also hands the `agents-md` preset down with the same settings, so
49
+ * every sub-agent the thread starts, the explorer included, and their children in turn, are told
50
+ * too; so it refuses to mount unless `agentsMdPreset` is registered. Selected, it hands nothing
51
+ * down, since a selection is process policy rather than the thread's recorded choice: a child is
52
+ * then told only if a root selector reaches its agent.
53
+ *
54
+ * Safe per thread: tools, grants, prompt sections and step listeners, all in the thread's own
55
+ * layer. A thread records its prompt when it first runs, so an installation applied later adds its
56
+ * tools but not its prompt sections.
57
+ */
58
+ export declare const codexPreset: import("../services/presets/definition.js").Preset<z.ZodObject<{
59
+ explore: z.ZodPrefault<z.ZodObject<{
60
+ web: z.ZodDefault<z.ZodBoolean>;
61
+ }, z.core.$strict>>;
62
+ agentsMd: z.ZodObject<{
63
+ fileNames: z.ZodArray<z.ZodString>;
64
+ maxBytes: z.ZodNumber;
65
+ }, z.core.$strict>;
66
+ }, z.core.$strict>>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The prompt text `codexPreset` contributes, its sub-agents' included, adapted from Codex CLI's base
3
+ * instructions and its model templates. Each block is exported so a consumer can reuse one in an
4
+ * agent of its own. None assumes how an answer is drawn: a host whose renderer has rules of its own,
5
+ * such as which diagrams or images it shows, contributes a section saying so.
6
+ */
7
+ export declare const CODE_ROLE_PROMPT = "You are a coding agent working in the user's workspace. You and the user share its files: with the tools you are given, you read, search and change them and run commands there. Your job is to carry the user's task through to a result they can review.";
8
+ export declare const AUTONOMY_PROMPT = "- Carry the task through to the end within the turn: understand it, make the change, validate it, and report. Do not stop at analysis, a proposal or a half-finished fix.\n- Unless the user asks a question, asks for a plan or a review, or is brainstorming, assume they want the change made, and make it rather than describe it.\n- When you hit a blocker, try to work through it yourself first. Ask the user, with ask_question, only when the answer changes what you would do and you cannot find it out yourself.\n- Do not guess or make up an answer: read the code, run the command, look it up.\n- Messages may arrive while you work. When they conflict, the newest one steers; otherwise honour every request since your last answer, and make sure your final answer responds to the newest.";
9
+ export declare const PREAMBLES_PROMPT = "Before a group of related tool calls, write one short line saying what you are about to do, and after the first, how it follows from what you found; for example \"The loader is in src/config.ts; now checking its callers.\" Group related calls under one line instead of narrating each, and write none before a trivial read. Before a large edit, say what you are changing.";
10
+ export declare const CODEBASE_PROMPT = "- Read the code you are about to change, and let it show you how to change it: follow the repository's existing patterns, helpers and style.\n- Fix the problem at its root cause rather than patching the symptom, and keep the solution as simple as the problem allows. Add an abstraction only when it removes real complexity.\n- Follow the AGENTS.md files you are told for the files you touch. Each governs its directory's tree and the deeper one wins on a conflict; the user's direct instructions beat any of them. Working below your working directory, look for AGENTS.md there too.\n- Keep the change to what the task needs. Do not fix unrelated bugs or failing tests; mention them in your final answer.\n- Update the documentation your change makes wrong.\n- Default to ASCII in files, and add a comment only where the code does not explain itself.\n- Never add copyright or licence headers unless asked. Do not commit or create branches unless asked.";
11
+ export declare const EDITING_PROMPT = "- Make every change to a file with edit_files: creating, updating, moving or deleting it. Never write a file through a command, such as a shell heredoc, `echo >`, `sed -i` or a script; running the project's own formatter or code generator is fine.\n- Read the lines you change before editing them: an edit's old text must match the file as it is now.\n- edit_files answers with the diff it applied. Trust it, and do not re-read the file to check.\n- If an edit is interrupted, or applies only some of its files, re-read the files it named before editing them again.";
12
+ export declare const DIRTY_WORKTREE_PROMPT = "The worktree may hold changes you did not make. Assume they are the user's, and never revert them unless asked.\n- Leave changes unrelated to your task alone.\n- In files you are working on, read the changes carefully and work with them.\n- Never run `git reset --hard`, `git checkout --`, `git restore`, `git clean` or anything else that discards changes unless the user clearly asked for that operation; when the request is ambiguous, ask first.\n- If those changes make your task impossible, ask the user how to proceed.";
13
+ export declare const VALIDATION_PROMPT = "- When the project can be built or tested, use that to check your work. Start with the tests closest to what you changed, then widen as you gain confidence.\n- Let coverage scale with risk: focused for a narrow change, broader when the change touches shared behaviour, contracts between modules, or what users do.\n- Add a test where the codebase has an obvious place for one. Do not add a test suite or a formatter to a repository that has none, and do not write tests that only mirror the implementation.\n- Run the project's formatter and linter on the files you changed when it has them.\n- A failure your change did not cause is not yours to fix: mention it.";
14
+ /** The delegation section: when to hand work to a sub-agent, and how. */
15
+ export declare const DELEGATION_PROMPT = "- Independent tool calls can run in parallel: make every call that does not need another's result in the same response. When a call depends on an earlier one's output, wait for that result first.\n- Hand work to a sub-agent when you do not need to see its steps, so your conversation keeps only its outcome:\n - explore: find and understand things in the workspace, such as where something is handled, how a module works or what a change would affect. It only reads.\n - delegate: a self-contained task that needs nothing from this conversation but the task you write, including one that changes files or runs commands, such as updating every call site of a function and making the tests pass, or finding out why a command fails and fixing it.\n - fork: a task of several steps that needs your context: answering a question by experiment, working out why something fails, checking whether an approach works.\n - review: a second reading of a change, or of any code, when the user asks for one or a change is large or subtle enough that one helps; never as a routine step. Its findings are evidence: weigh each against the code before acting on it. To get them fixed, delegate the findings with their evidence. Check the repository's status before asking for a review of uncommitted work: an empty change still starts a reviewer.\n- Work directly when one or two calls will do, when you need the raw output yourself (the exact lines you are about to edit, command output you must reason over), when the next step waits on a decision, or when the answer is already in the conversation.\n- Give independent parts separate calls in one response, so they run concurrently. Write each task as an outcome: what to find out or do, and what to return, such as \"the function that validates tokens, with its file and line\" rather than \"look at the auth code\". Explore, delegate and review see only the task you write; a fork sees your conversation too. Either way, name the target (for a review, \"the uncommitted changes\", \"the current work against main\", \"commit abc123\" or the code to read), the outcome you expect, the constraints, and which files you or other sub-agents are changing and which commands share outputs, such as test discovery, a build directory or a server port.\n- Start a review only after the work it reviews has settled, in a later response than the calls that make that work: a waiting call does not stop the others in its response.\n- In a forked task, do the work yourself rather than forking again.";
16
+ export declare const LONG_WORK_PROMPT = "A long task can outgrow your context. The conversation may then be compacted: a checkpoint stands in for the messages it condensed. Compaction does not end the task. Continue from the checkpoint without restarting or redoing finished work, and keep the original objective together with every correction the user made since.";
17
+ /** Added to {@link LONG_WORK_PROMPT} when the agent may call the recall tools. */
18
+ export declare const HISTORY_RECALL_PROMPT = "When you need the exact text of something condensed, such as the user's wording or a command's output, read it back with history_read or find it with history_search rather than reconstructing it.";
19
+ export declare const SAFETY_PROMPT = "- Your file tools and commands work under the confinement the application sets. Do not go looking through the rest of the machine, such as other projects or the home directory, unless the task needs it.\n- Avoid destructive or irreversible commands, such as deleting what you did not create, force-pushing or dropping data, unless the user asked for them.\n- Do not push, publish, deploy or send anything to others unless asked.\n- Do not search for, print or copy out secrets such as credentials, API keys and tokens.";
20
+ export declare const AMBITION_PRECISION_PROMPT = "- For a task with no prior context, where the user is starting something new, be ambitious and show creativity in the implementation.\n- In an existing codebase, do exactly what the user asks with surgical precision. Treat the surrounding code with respect and do not overstep, for example by renaming files or variables unnecessarily, while still being proactive enough to finish the task well.\n- Use judicious initiative to choose the right level of detail and complexity for the user's needs: high-value, creative touches when the scope is vague; surgical, targeted work when it is tightly specified; no gold-plating either way.";
21
+ export declare const FINAL_ANSWER_PROMPT = "- Lead with the outcome, then give what the user needs to trust it and act on it, like a concise teammate handing off work.\n- Size the answer by the change: a sentence or two for a small fix, a short walkthrough grouped by theme for a large one, a plain conversational reply to a casual question. Even a large one keeps to the points that matter, well under fifty lines.\n- Say what you ran to validate the work, and what you did not run and why.\n- Point to code as `path:line`, with the path relative to the working directory and a single line rather than a range.\n- Do not paste before-and-after code or the contents of files you wrote: the user has the files. Never ask them to save or copy anything.\n- Mention the problems you noticed but left alone, and anything you could not do.\n- When there is an obvious next step, such as running the wider test suite, committing, or building the next piece, offer it as a short question rather than doing it unasked.";
22
+ export declare const COMMUNICATION_GUIDANCE_PROMPT = "- Write in English unless the user asks for another language.\n- Be direct and concise, and state the assumptions you made. Leave out flattery, filler and needless apologies.\n- Use plain characters: no emoji unless asked, and no look-alike or invisible Unicode, such as an en dash for a hyphen.";
23
+ /** Markdown conventions any renderer draws; what a particular one adds is its host's to say. */
24
+ export declare const FORMATTING_PROMPT = "- Answer in Markdown, with only as much structure as helps: short paragraphs by default, flat lists for parallel items, and a heading only when a long answer has distinct parts.\n- Put code, commands and multi-line output in fenced code blocks labelled with their language.\n- Wrap file paths, commands, environment variables and code identifiers in backticks.";
25
+ /**
26
+ * The explorer's base prompt, naming the search tools only when `has` says they are registered: they
27
+ * are provided only where the host has `rg`.
28
+ */
29
+ export declare const exploreRolePrompt: (has: (tool: string) => boolean) => string;
30
+ export declare const EXPLORE_TOOL_DESCRIPTION = "Sub-agent that explores the workspace without changing it: codebase exploration, file discovery and code understanding. It reports its findings.";
31
+ export declare const FORK_TOOL_DESCRIPTION = "Fork yourself to execute one sub-task in isolation. The forked thread gets a clone of your current conversation context, executes the task independently, and its result is returned to you. Use this when you want to 'clone yourself' to do a sub-task without polluting your main conversation thread. Call this tool once per task; several calls in one response run concurrently.";
32
+ export declare const FORKING_PROMPT = "Sub-agents inherit your permissions and share your working directory. Give sub-agents that run at the same time disjoint files to write, or let only one of them write; disjoint files still share test discovery, build output and ports, so do not run tests or builds in two of them at once.";
33
+ /** The general sub-agent's opening: one delegated task, and no view of the caller's conversation. */
34
+ export declare const GENERAL_ROLE_OPENING = "You are a sub-agent: another agent handed you one task, which you carry out in the user's workspace with the tools you are given, reading, searching and changing its files and running commands there. You do not see the conversation that led to the task: the task is all you know of it. Your answer goes back to the agent that asked, not to the user.";
35
+ /** What every sub-agent codex starts with tools follows, since it answers an agent and cannot ask the user. */
36
+ export declare const SUB_AGENT_RULES_PROMPT = "- Where these instructions say to ask the user, you cannot: stop there, and put the question in your answer, with what you found and what each answer would change.\n- Before you answer, wait for every background command whose result you rely on, and stop every background command you started.";
37
+ /** How the general sub-agent answers: the whole of what its caller gets back. */
38
+ export declare const SUB_AGENT_ANSWER_PROMPT = "Your answer is all the agent that asked gets back, so make it complete on its own:\n- Lead with the outcome: what you did, or what you found.\n- Point to code as `path:line`, with the path relative to the working directory.\n- Say what you ran to check it, each command exactly, and what it showed.\n- Say what is left undone, what you could not do, and what you are unsure of.";
39
+ /** The reviewer's opening, adapted from Codex CLI's review rubric (\`prompts/templates/review/rubric.md\`). */
40
+ export declare const REVIEW_ROLE_OPENING = "You are a code review sub-agent: another agent asked you for a second reading of code in the user's workspace, a change or code as it stands, and you report the problems you find, with their evidence. You do not see the conversation that led to the task: the task names what to review and anything to focus on. Your answer goes back to the agent that asked, not to the user.";
41
+ /** What the reviewer reads, and how it may gather evidence without repairing anything. */
42
+ export declare const REVIEW_EVIDENCE_PROMPT = "- Read the change with git through run_command: a diff of the uncommitted changes, of the current work against a branch's merge base, or of one commit, with the repository's status and log. Note which commits you compared. Read the code around each change, and the code that depends on it, as far as you need to judge it. When the task names code rather than a change, review that code as it stands.\n- Review and report; do not fix. Run a command only when a finding needs the evidence: an existing test, the type checker, a linter, or a small reproduction. Prefer existing tests.\n- When a check needs a file inside the repository, create a new, uniquely named file with edit_files. Never change a file that existed before you started, the user's untracked files included.\n- Clean up what you created. Just before deleting a temporary file, read it again, and delete it only if it is still exactly what you wrote. Never restore the workspace wholesale, such as with `git checkout`, `git restore`, `git stash` or `git clean`.\n- Running tests writes caches and build output, which is fine: what you keep intact is the user's work.\n- When the target is a commit, or anything but the current work, your commands run on the checkout, not on the reviewed revision. Say which HEAD and which local changes they ran on, and do not claim that a check passing there shows the reviewed revision passes.\n- If files your findings rely on change while you review, check those findings again, or mark them uncertain.";
43
+ /** What the reviewer flags and how it reports, adapted from Codex CLI's review rubric. */
44
+ export declare const REVIEW_RUBRIC_PROMPT = "Flag a problem only when all of these hold:\n- It meaningfully affects the correctness, performance, security or maintainability of the code.\n- It is discrete and actionable: one issue, not a remark about the codebase in general or several issues together.\n- When the task names a change, the change introduced it: problems that were there before are not flagged. When it names code, the problem is in that code.\n- You can show it from the code or from what you ran. Speculating that something may break elsewhere is not enough: name the code that is affected. It must not rest on assumptions about the codebase or the author's intent that you have not stated.\n- It is clearly not a deliberate choice, and the author would fix it if they knew.\n- Fixing it does not demand more rigour than the rest of the codebase shows.\n\nIgnore style, formatting, naming and typos unless they hide a bug or break a rule the repository's AGENTS.md files state. When a rule supports a finding, cite the AGENTS.md file and line it comes from.\n\nReport every finding the author would want to fix, not only the first; when nothing clearly qualifies, report none. For each finding:\n- A short title tagged with its priority: [P0] blocks a release or major use, whatever the inputs; [P1] urgent, for the next cycle; [P2] normal, to fix eventually; [P3] low, nice to have.\n- Its location as `path:line` in the reviewed code, with the path relative to the repository, keeping the range as short as possible.\n- One short paragraph saying why it is a problem and the inputs, scenarios or environments it needs, so its severity is clear, and the evidence: what you read or ran. Claim no more severity than it has, quote no more than three lines of code, and keep the tone matter-of-fact, with no praise.\n\nWhen the task asks for a design assessment, alternatives or improvements, give them after the findings, under a heading of their own, apart from the problems you showed. When it asks for a severity scale or an output format, follow it instead of these.\n\nEnd with:\n- the scope you reviewed, and for a git target the commits you compared;\n- the checks you ran, each command exactly, with its result;\n- every experiment, what it left behind, and where its reproduction is kept, with how to run it;\n- the limits of the review: what you did not read or could not check.\nThen a one-line verdict: whether the reviewed code is correct, meaning existing code and tests will not break and it has no blocking problem. Non-blocking issues such as style do not count against it. \"No qualifying findings\" is not a guarantee of correctness: when you found none, say so plainly, with what you covered.\n\nAnswer in plain text, not JSON. The task may narrow what to look at, and the repository's AGENTS.md files may add rules; both take precedence over these guidelines.";
45
+ /**
46
+ * The general sub-agent's base prompt: one delegated task, carried out with the workspace, command,
47
+ * web and skill tools, by codex's own working rules, answered to the agent that asked.
48
+ */
49
+ export declare const GENERAL_ROLE_PROMPT: string;
50
+ /**
51
+ * The reviewer's base prompt: the same tools as the general sub-agent, used to gather evidence, never
52
+ * to repair; none of the blocks that tell an agent to fix, document or add tests.
53
+ */
54
+ export declare const REVIEW_ROLE_PROMPT: string;
55
+ export declare const DELEGATE_TOOL_DESCRIPTION = "Sub-agent that carries out one self-contained task in the workspace with a fresh context: it reads, changes files, runs commands, and reports what it did and found. It sees only the task you write, not this conversation, so state the target, the outcome you expect and any constraints.";
56
+ export declare const REVIEW_TOOL_DESCRIPTION = "Sub-agent that reviews code in the workspace with a fresh context: a change (the uncommitted changes, the current work against a branch such as main, or one commit) or code as it stands. It may run tests and reproductions to gather evidence, changes nothing of yours, and reports the problems it can show, each tagged [P0] to [P3] at a file and line. Name the target and any focus in the task.";
@@ -0,0 +1,109 @@
1
+ import type { Scoped } from '@leuduan/cordis';
2
+ import type { JournalCommitError, PluginJournal } from './journal/index.js';
3
+ import type { ModelRequestDraft, ModelStep, SentRequest, StopVerdict, ToolAuthorizationRequest, ToolPolicyDecision, ToolInvocation, ToolOutcome, TurnStop } from './loop/index.js';
4
+ import type { StreamingLLMResponse } from './llm/client.js';
5
+ import type { AgentsService } from './services/agents.js';
6
+ import type { LlmService } from './services/llm.js';
7
+ import type { ConfinementOperation, ConfinementService } from './services/confinement/service.js';
8
+ import type { PromptsService } from './services/prompts.js';
9
+ import type { PresetsService } from './services/presets/installations.js';
10
+ import type { Threads } from './services/threads/index.js';
11
+ import type { ToolsService } from './services/tools.js';
12
+ import type { Thread } from './services/threads/index.js';
13
+ declare module './loop/tool.js' {
14
+ interface InvocationContext {
15
+ /**
16
+ * The call's confinement operation: its file access (`files`) and the launches of any process it
17
+ * starts, under one snapshot taken on first use. Opened for the call and ended with it, so a
18
+ * reference that outlives the call is dead.
19
+ */
20
+ readonly operation: ConfinementOperation;
21
+ }
22
+ }
23
+ declare module '@leuduan/cordis' {
24
+ interface Context {
25
+ /** The journal: the one durable state, and the folds over it; a plugin appends its own `ext` rows. */
26
+ journal: PluginJournal;
27
+ /** Global and scope-layered tool registry and grants. */
28
+ tools: ToolsService;
29
+ /** Agent-definition registry. */
30
+ agents: AgentsService;
31
+ /** Model-provider registry and client construction. */
32
+ llm: LlmService;
33
+ /** Prompt contributions, rendered when a thread first runs, and recorded on it. */
34
+ prompts: PromptsService;
35
+ /** Starting and finding threads, and what happens to them as a set; one thread is driven through its `Thread`. */
36
+ threads: Threads;
37
+ /** Presets a thread can install, their validation, hand-downs and restoration. */
38
+ presets: PresetsService;
39
+ /** How model-driven processes launch: plain, or through the one handler a host registers. */
40
+ confinement: ConfinementService;
41
+ }
42
+ interface Events {
43
+ /**
44
+ * Configure a live activation through thread.ctx. Independent plugins compose here.
45
+ * @mode parallel — all listeners settle before readiness; any failure prevents execution.
46
+ * The signal belongs to the activation, not an individual turn.
47
+ */
48
+ 'lagent/thread/activate'(this: Scoped, thread: Thread, signal: AbortSignal): void | Promise<void>;
49
+ /**
50
+ * The store failed to commit a group after the folds took it. The journal refuses every later
51
+ * write and reads show what the store holds, and the threads service has already closed
52
+ * execution admission and stopped every loop. The host must exit, and reopen to continue.
53
+ * @mode parallel — fired once, on the root; every listener runs, whichever throws.
54
+ */
55
+ 'lagent/journal/revoked'(error: JournalCommitError): void;
56
+ /**
57
+ * Around every tool invocation. The terminal runs `invocation.tool.invoke(...)`.
58
+ * @mode waterfall
59
+ */
60
+ 'lagent/tool/execute'(this: Scoped, invocation: ToolInvocation, next: () => Promise<ToolOutcome>): Promise<ToolOutcome>;
61
+ /**
62
+ * A model step is about to record its input. Listeners may `step.contribute()` messages, which
63
+ * enter the conversation ahead of the step's claimed input, in the same atomic journal group, by
64
+ * ascending `rank` (default 0) and then listener order; an identical contribution, source and
65
+ * message alike, is recorded once, and at two different ranks it throws.
66
+ * Fires only once a model step is already due — never for a tool step, and it cannot make one due.
67
+ * @mode emit — synchronous; listeners must not await. A throwing listener fails the step before
68
+ * any of its input is recorded.
69
+ */
70
+ 'lagent/llm/step'(this: Scoped, step: ModelStep): void;
71
+ /**
72
+ * A turn's answer — a reply with no tool calls, or a result that concluded the turn — is about
73
+ * to become the thread's answer. Return `undefined` to accept it, `{ decision: 'continue',
74
+ * message }` to send the model back in the same turn, or `{ decision: 'reject', reason, source }`
75
+ * to end the turn `rejected`, or `{ decision: 'prepare', request }` to plan a runtime operation
76
+ * before final judgment. Rejection wins, then continuation, then preparation. Consulted whatever the
77
+ * step budget, and again after a crash, abort or failure left the answer unjudged. A check
78
+ * declares the facts its verdict rests on with `stop.observe(read)`; the judgment is discarded if
79
+ * one reads differently when it is recorded.
80
+ * @mode collect — a throwing check, or an invalid verdict, ends the turn `error` and leaves the
81
+ * answer to be judged on the next run.
82
+ */
83
+ 'lagent/turn/stop'(this: Scoped, stop: TurnStop): StopVerdict | undefined | Promise<StopVerdict | undefined>;
84
+ /**
85
+ * Around every model request. The terminal records `llm/request` and calls the route's client
86
+ * with the (possibly rewritten) request. `model` and `thinkingEffort` are the turn's route and
87
+ * read-only, so the route a step was told is the one lagent sends, and so are the correlation
88
+ * ids, `purpose` and `signal` the journal recorded the call under; a listener that answers
89
+ * without calling `next()` sends nothing through lagent.
90
+ * @mode waterfall
91
+ */
92
+ 'lagent/llm/request'(this: Scoped, request: ModelRequestDraft, next: () => Promise<StreamingLLMResponse>): Promise<StreamingLLMResponse>;
93
+ /**
94
+ * A model request as it was sent, after middleware, with the row that
95
+ * recorded it, before the client has it: model steps and auxiliary calls alike. Read-only;
96
+ * awaited; a listener that throws is reported, and the request still goes out.
97
+ * @mode parallel
98
+ */
99
+ 'lagent/llm/sent'(this: Scoped, sent: SentRequest): void | Promise<void>;
100
+ /**
101
+ * Every matching policy contributes `deny`, `confirm` or `approve`, or no opinion. Deny wins
102
+ * over everything, and `{ decision: 'deny', reason }` tells the model why; `confirm` holds the
103
+ * call for the user unless the user already approved it or a policy approves it. A throwing
104
+ * policy prevents execution. Re-evaluated when a confirmed call resumes.
105
+ * @mode collect
106
+ */
107
+ 'lagent/tool/authorize'(this: Scoped, request: ToolAuthorizationRequest): ToolPolicyDecision | undefined | Promise<ToolPolicyDecision | undefined>;
108
+ }
109
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The application-facing API: mount the core on a root, compose providers, tools, agents and
3
+ * presets, and drive threads through `ctx.threads`.
4
+ *
5
+ * The package has a few doors and nothing else: this one for applications, `@leuduan/lagent/plugin`
6
+ * for plugin authors, `@leuduan/lagent/llm` for the model and provider contracts,
7
+ * `@leuduan/lagent/providers` for the shipped providers, `@leuduan/lagent/stores/sqlite` for the SQLite store
8
+ * (which needs `node:sqlite`), `@leuduan/lagent/records` for the serialized shapes, one
9
+ * `@leuduan/lagent/plugins/<name>` per shipped plugin, and `@leuduan/lagent/testing` for test doubles. A
10
+ * value lives on one door: this one holds what an application constructs (the core, the memory
11
+ * store), catches (the errors), composes from `compositions/` or runs as a host-owned process
12
+ * (`spawnCommand`, `runToCompletion`: servers and probes the host starts, never a tool's work); a shipped plugin's exports, its presets
13
+ * included, are on its own door. The core's services are reached as `ctx.<name>`, so their classes
14
+ * are exported as types only. Keep this
15
+ * entry point small enough that an embedder can understand it without first learning the engine
16
+ * internals.
17
+ */
18
+ export * from './context.js';
19
+ export { core } from './services/core.js';
20
+ export type { CoreConfig } from './services/core.js';
21
+ export type { AgentResolution, AgentsService } from './services/agents.js';
22
+ export type { ToolsService } from './services/tools.js';
23
+ export { registerProvider } from './services/llm.js';
24
+ export type { LlmService, RetryPolicy } from './services/llm.js';
25
+ export type { PromptsService } from './services/prompts.js';
26
+ export { registerPreset } from './services/presets/installations.js';
27
+ export type { ConfigurationPlan, InitialInstallationInput, InstallationInput, PresetsService, } from './services/presets/installations.js';
28
+ export { UNCONFINED_LAUNCH } from './services/confinement/service.js';
29
+ export { FileAccessError } from './services/confinement/files.js';
30
+ export type { DirEntry, DirListing, FileScope, PathOptions, ReadHandle, WriteHandle, } from './services/confinement/files.js';
31
+ export type { ConfinementHandle, ConfinementHandler, ConfinementOperation, ConfinementService, ConfinementSnapshot, FileAccess, FilePolicy, FileVerdict, Launched, LaunchOptions, LaunchProgram, LaunchProvenance, LaunchRequest, PreparedLaunch, } from './services/confinement/service.js';
32
+ export type { ConfigurationChange, ConfigurationResult, RetainOptions, RetainedMembers, Retention, ThreadFilter, Threads, ThreadsConfig, ThreadsService, } from './services/threads/index.js';
33
+ export type { MissingDetail, OwnerHandle, OwnerReadiness, OwnerRegistration, StartOptions, StartupPolicy, ThreadInspection, WaitResolution, WaitValue, } from './services/threads/index.js';
34
+ export { heldOrSettled, UnknownRunError, waitForRun } from './services/threads/index.js';
35
+ export type { RunEvent, RunSource, RunState } from './services/threads/index.js';
36
+ export type { BirthChoice, BirthInput, CreateThreadOptions, ForkCut, ForkOptions, Opening, Reuse, } from './services/threads/index.js';
37
+ export type { Thread } from './services/threads/index.js';
38
+ export type { ThreadView } from './services/threads/index.js';
39
+ export type { CancelOptions, ConfirmationAnswer } from './services/threads/index.js';
40
+ export { buildSpawnEnvironment, NON_INTERACTIVE_ENVIRONMENT, resolveTrustedPrograms } from './sys/environment.js';
41
+ export { CODEX_ENVIRONMENT_POLICY } from './compositions/codex.js';
42
+ export type { SpawnEnvironmentPolicy, TrustedPrograms } from './sys/environment.js';
43
+ export { runToCompletion, spawnCommand } from './sys/spawn.js';
44
+ export type { SpawnEnvironment, SpawnOptions, SpawnResult, SpawnStdio, SpawnedCommand, SpawnedGroup, SpawnedPipes, StopCause, } from './sys/spawn.js';
45
+ export type { ChainStanding, ConfirmationState, ForkPoint, InputFate, InstallationRecord, ReplacementRule, RouteStatement, Target, ConstraintAnswer, Hold, HoldBasis, HoldReason, BirthSpec, ForkOpening, FreshOpening, Refusal, RowRef, RunOutcome, RowsResult, RowsWrite, InputReceipt, SendOptions, SendOutcome, TurnLimits, WaitDeclaration, WaitEntry, WithdrawOptions, WithdrawOutcome, WithdrawRows, } from './state/index.js';
46
+ export type { CompactOptions, BirthConflict, StreamedChunk, SurfacePrepareOutcome } from './loop/index.js';
47
+ export type { ModelSelection } from './llm/provider.js';
48
+ export { AuxiliaryRefusedError, BirthConflictError, ConfirmationAnsweredError, CorruptHistoryError, DepthExceededError, RestoreFailedError, ThreadActivatingError, ThreadBusyError, ThreadUnsettledError, UnknownAgentError, WriteRefusedError, } from './loop/index.js';
49
+ export { ForkCutError, ReplacementRefusedError, RouteConflictError, RouteUnavailableError, UnknownThreadError, } from './state/index.js';
50
+ export { CorruptJournalError, forkChain, IncompatibleJournalError, InvalidOriginError, JournalBusyError, JournalCommitError, StoreBusyError, } from './journal/index.js';
51
+ export type { AppendOutcome, Attempt, ForkLink, InvalidOriginReason, JournalStore, ThreadIndexEntry, ThreadSummaryCore, WriterLease, } from './journal/index.js';
52
+ export { MemoryJournalStore } from './stores/memory.js';
53
+ export { base } from './compositions/base.js';
54
+ export { codexPreset } from './compositions/codex.js';
55
+ export { COMMUNICATION_GUIDANCE_PROMPT, FORMATTING_PROMPT } from './compositions/codexPrompts.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunks/Q7S5LFGN.js";import{a as e,b as t}from"./chunks/ASSQZH3F.js";import{b,c as J,d as V,e as G,f as H,g as W,h as Y}from"./chunks/B4FXK5ER.js";import"./chunks/SS3B5W34.js";import"./chunks/IAAEP6VL.js";import"./chunks/OCBPT7KE.js";import"./chunks/2P47AHNK.js";import"./chunks/MHC6VPB4.js";import"./chunks/EMRB4KCN.js";import"./chunks/RCIHV3KG.js";import"./chunks/2GCIWSOA.js";import"./chunks/GGSVIIWJ.js";import{b as S,c as k,d as v}from"./chunks/CANPZYTH.js";import"./chunks/VYMT4TXD.js";import"./chunks/MNJ4SRF7.js";import"./chunks/JFZZXVWD.js";import{b as B,c as D,e as L}from"./chunks/N6IXG2VL.js";import{b as M}from"./chunks/6DRCKZ2C.js";import{c as h,d as y}from"./chunks/7LI64H5X.js";import{a as U}from"./chunks/3UMZMPWW.js";import"./chunks/Q75FUN7D.js";import"./chunks/PUSUPTAT.js";import"./chunks/34KW6VNQ.js";import"./chunks/DDZ7YF26.js";import"./chunks/KUZCL2SH.js";import{b as F}from"./chunks/CQEVREBT.js";import"./chunks/HK6ZSONF.js";import"./chunks/7VAPNE3L.js";import"./chunks/EPYQ5M3B.js";import"./chunks/5IRF47YB.js";import"./chunks/OL5A6ITQ.js";import"./chunks/JFX2MXBA.js";import"./chunks/S34ZA2R6.js";import"./chunks/6FRNHMCV.js";import{b as o}from"./chunks/CUK7CGC7.js";import{J as N,K as T,L as c,M as R,N as O,O as A,P as I,Q as g,R as P,S as w,T as _,j as l,k as u,u as d,v as x,w as C}from"./chunks/BPRCULZH.js";import"./chunks/FJLU4UH3.js";import"./chunks/DDANMY45.js";import{a,b as i,l as m,m as E,q as p,u as s,x as f}from"./chunks/BBCW2FZK.js";import"./chunks/MMNNZCBO.js";import"./chunks/G44LG6VL.js";import"./chunks/D4PQP5MA.js";var j={name:"lagent:base",inject:["agents"],async apply(r){o(r,X),await r.plugin(n),await r.plugin(e,{confirm:t})}},X={name:"main",basePrompt:"You are a helpful AI assistant."};export{_ as AuxiliaryRefusedError,O as BirthConflictError,H as CODEX_ENVIRONMENT_POLICY,V as COMMUNICATION_GUIDANCE_PROMPT,g as ConfirmationAnsweredError,w as CorruptHistoryError,p as CorruptJournalError,R as DepthExceededError,G as FORMATTING_PROMPT,U as FileAccessError,x as ForkCutError,s as IncompatibleJournalError,a as InvalidOriginError,m as JournalBusyError,f as JournalCommitError,Y as MemoryJournalStore,B as NON_INTERACTIVE_ENVIRONMENT,C as ReplacementRefusedError,c as RestoreFailedError,l as RouteConflictError,u as RouteUnavailableError,E as StoreBusyError,I as ThreadActivatingError,T as ThreadBusyError,P as ThreadUnsettledError,M as UNCONFINED_LAUNCH,N as UnknownAgentError,S as UnknownRunError,d as UnknownThreadError,A as WriteRefusedError,j as base,D as buildSpawnEnvironment,W as codexPreset,J as core,i as forkChain,v as heldOrSettled,F as registerPreset,b as registerProvider,L as resolveTrustedPrograms,y as runToCompletion,h as spawnCommand,k as waitForRun};
@@ -0,0 +1,112 @@
1
+ import type { ThreadOrigin, ThreadSummary } from '../records/journal.js';
2
+ /**
3
+ * Why a walk up the origin tree stopped short of a thread with no caller: `missing`, the caller is
4
+ * not in the catalog; `cycle`, the caller was already met. `at` is the last thread the walk reached,
5
+ * the one whose caller could not be followed, or `null` when that is a prospective opening, which has
6
+ * no id yet. Neither happens in a journal that kept its rules: a
7
+ * caller exists before the threads it creates, so origins cannot form a cycle.
8
+ */
9
+ export type OriginBreak = {
10
+ readonly broken: 'missing' | 'cycle';
11
+ readonly at: string | null;
12
+ };
13
+ /** A thread and the threads that called it, nearest first, with whether the walk reached a root. */
14
+ export type CallerChain = {
15
+ /** `threadId` first, then its caller, that one's caller, out to a thread with no caller. */
16
+ readonly threads: readonly ThreadSummary[];
17
+ readonly chain: 'complete' | OriginBreak;
18
+ };
19
+ /** A thread not written yet, as far as its callers and requirements go: a write's resolved opening supplies both. */
20
+ export type OriginOpening = {
21
+ readonly origin: ThreadOrigin | null;
22
+ readonly requires: readonly string[];
23
+ };
24
+ /** A constraint owner a run needs, and the threads whose `requires` name it. */
25
+ export type RequiredOwner = {
26
+ readonly owner: string;
27
+ /** Nearest first. Empty for an owner only a prospective opening's own `requires` names. */
28
+ readonly introducedBy: readonly string[];
29
+ };
30
+ /** What `requiredOwners` found, with whether the callers it read up to a root. */
31
+ export type RequiredOwners = {
32
+ readonly owners: readonly RequiredOwner[];
33
+ readonly chain: 'complete' | OriginBreak;
34
+ };
35
+ /** Which rule an origin broke: see {@link Origins.validate}. */
36
+ export type InvalidOriginReason = 'unknown-caller' | 'source-missing' | 'source-off-lineage' | 'source-not-a-call';
37
+ /** An origin whose caller or cited row breaks `origins.validate`'s rule; `reason` says which. */
38
+ export declare class InvalidOriginError extends Error {
39
+ readonly origin: ThreadOrigin;
40
+ readonly reason: InvalidOriginReason;
41
+ constructor(origin: ThreadOrigin, reason: InvalidOriginReason);
42
+ }
43
+ /**
44
+ * The origin tree, read from the catalog: each thread's spawn row names the caller whose
45
+ * `tool/call` created it, and the threads with no caller head a tree each. Queries read summaries
46
+ * only and load nothing; they follow `origin` and never fork lineage, which is `Thread.lineageRoot`'s.
47
+ * A thread the catalog does not hold has no chain and no subtree.
48
+ */
49
+ export interface Origins {
50
+ /**
51
+ * `threadId` and the threads that called it, upward to its origin root; see {@link CallerChain}.
52
+ * An incomplete chain says so, and its last thread still has an `origin`.
53
+ */
54
+ callers(threadId: string): CallerChain;
55
+ /** The last thread of {@link callers}: the origin root, or the last thread reached when the chain is incomplete. */
56
+ root(threadId: string): ThreadSummary | undefined;
57
+ /**
58
+ * The threads created under `threadId` at any depth, in spawn order, a caller before the threads
59
+ * it created, with `threadId` itself first when `self`. Each thread is listed once, so a cycle
60
+ * ends the walk rather than repeating it, and `self: false` drops the start in a cycle too.
61
+ */
62
+ subtree(threadId: string, options: {
63
+ readonly self: boolean;
64
+ }): ThreadSummary[];
65
+ /** Whether `threadId` is `ancestorId` or was created under it. */
66
+ isUnder(threadId: string, ancestorId: string): boolean;
67
+ /**
68
+ * The constraint owners a thread's run needs: what its own `requires` names and what every thread
69
+ * above it by origin requires, each with the threads that introduced it. A prospective opening
70
+ * stands for a thread not written yet; its callers are read from the catalog, and a caller the
71
+ * catalog does not hold is `missing` at `null`, the opening itself. Only readiness is inherited, never a
72
+ * caller's holds.
73
+ */
74
+ requiredOwners(threadOrOpening: string | OriginOpening): RequiredOwners;
75
+ /**
76
+ * Checks the one rule an origin's cited row must meet, whoever records the origin: its caller is a
77
+ * known thread, `source_seq` is a row of the caller's lineage, its own or one a fork it continues
78
+ * inherits, and for a `call` cause it is a `tool/call` row. What an assignment's granting row means
79
+ * is the owner's. Throws {@link InvalidOriginError} naming what is wrong. Reads the one row from
80
+ * the store when it is not loaded and loads nothing else, so a caller that is not loaded validates.
81
+ */
82
+ validate(origin: ThreadOrigin): Promise<void>;
83
+ }
84
+ /**
85
+ * The catalog of one summary per thread, in spawn order, with the index of which threads each
86
+ * caller created: the one owner of the origin graph, so the index cannot trail the summaries. Every
87
+ * change to the catalog goes through it. An origin never changes, so a thread's caller is indexed
88
+ * when its summary first enters.
89
+ */
90
+ export declare class Catalog {
91
+ private readonly summaries;
92
+ /** Position in spawn order: kept by a replaced summary, new for one added after a delete. */
93
+ private readonly ranks;
94
+ /** Caller id to the threads it created, among those the catalog holds. The caller itself may not be held. */
95
+ private readonly children;
96
+ private nextRank;
97
+ readonly origins: Omit<Origins, 'validate'>;
98
+ get(threadId: string): ThreadSummary | undefined;
99
+ has(threadId: string): boolean;
100
+ keys(): IterableIterator<string>;
101
+ values(): IterableIterator<ThreadSummary>;
102
+ /** The summaries by thread id, live: a read sees later changes. */
103
+ view(): ReadonlyMap<string, ThreadSummary>;
104
+ /** Adds a thread's summary after the others, or replaces it where it stands. */
105
+ set(threadId: string, summary: ThreadSummary): void;
106
+ delete(threadId: string): void;
107
+ /** Replaces every summary, the new ones in the order given. */
108
+ reset(summaries: Iterable<ThreadSummary>): void;
109
+ private callers;
110
+ private subtree;
111
+ private requiredOwners;
112
+ }
@@ -0,0 +1,16 @@
1
+ /** What a fork walk reads of a catalog summary. */
2
+ export type ForkLink = {
3
+ readonly thread_id: string;
4
+ readonly fork: {
5
+ readonly thread_id: string;
6
+ } | null;
7
+ };
8
+ /**
9
+ * `threadId` and the threads it was forked from, nearest first, out to the thread no fork leads
10
+ * from: the catalog's view of the lineage the journal folds, without loading a row. It follows
11
+ * `fork` and never delegation origin (`origins.callers`'). The start is first and an unknown start
12
+ * yields nothing; the walk stops at a source the catalog does not hold and at a thread it already
13
+ * met, so a journal that broke its rules, with a cycle or a lost source, ends the chain rather than
14
+ * looping or throwing.
15
+ */
16
+ export declare function forkChain<S extends ForkLink>(summaries: ReadonlyMap<string, S>, threadId: string): S[];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The journal: an append-only event stream and the folds over it.
3
+ *
4
+ * Knows envelopes and one row shape: a `thread/spawned` naming a fork point, where a thread's folds
5
+ * continue from another's. A writer judges what it writes inside its own `transact` callback; the
6
+ * journal parses and records. Nothing here has heard of agents, turns or tools. A store
7
+ * backend implements `JournalStore`; a plugin that wants durable state registers a `PluginProjection`. Neither
8
+ * needs the loop.
9
+ */
10
+ export { InvalidOriginError } from './catalog.js';
11
+ export type { CallerChain, InvalidOriginReason, OriginBreak, OriginOpening, Origins, RequiredOwner, RequiredOwners, } from './catalog.js';
12
+ export * from './forkChain.js';
13
+ export * from './journal.js';
14
+ export * from './projection.js';
15
+ export * from './store.js';