@theokit/sdk 5.14.0 → 5.15.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 (212) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{agent-Dfw3VsIX.d.ts → agent-B6C9i_qu.d.ts} +23 -213
  3. package/dist/{agent-DExqjqYy.d.cts → agent-B6FQad6P.d.cts} +23 -213
  4. package/dist/{agent-T34LCGQM.js → agent-DRDGUU6T.js} +18 -17
  5. package/dist/{agent-T34LCGQM.js.map → agent-DRDGUU6T.js.map} +1 -1
  6. package/dist/{agent-TL4K7BTG.cjs → agent-VI2HITPT.cjs} +19 -18
  7. package/dist/{agent-TL4K7BTG.cjs.map → agent-VI2HITPT.cjs.map} +1 -1
  8. package/dist/agent.d.ts +2 -3
  9. package/dist/{batch-EP3FCL6D.js → batch-N2XDYZED.js} +4 -4
  10. package/dist/{batch-EP3FCL6D.js.map → batch-N2XDYZED.js.map} +1 -1
  11. package/dist/{batch-IZ5EDKJ5.cjs → batch-VFR2MAUE.cjs} +7 -7
  12. package/dist/{batch-IZ5EDKJ5.cjs.map → batch-VFR2MAUE.cjs.map} +1 -1
  13. package/dist/{chunk-3ONIVO2I.js → chunk-23SS4ID4.js} +3 -3
  14. package/dist/{chunk-3ONIVO2I.js.map → chunk-23SS4ID4.js.map} +1 -1
  15. package/dist/{chunk-2C24NSNV.js → chunk-3BBTHFGJ.js} +3 -3
  16. package/dist/{chunk-2C24NSNV.js.map → chunk-3BBTHFGJ.js.map} +1 -1
  17. package/dist/{chunk-NP362THY.cjs → chunk-3F53FLQ7.cjs} +5 -7
  18. package/dist/chunk-3F53FLQ7.cjs.map +1 -0
  19. package/dist/{chunk-SXH37C7X.cjs → chunk-55LLQFHW.cjs} +6 -6
  20. package/dist/{chunk-SXH37C7X.cjs.map → chunk-55LLQFHW.cjs.map} +1 -1
  21. package/dist/{chunk-GARVAUCU.js → chunk-5M5GQYBM.js} +534 -236
  22. package/dist/chunk-5M5GQYBM.js.map +1 -0
  23. package/dist/{chunk-2WY2OFSC.cjs → chunk-64ECM3XM.cjs} +616 -318
  24. package/dist/chunk-64ECM3XM.cjs.map +1 -0
  25. package/dist/{chunk-ZJAYFSVI.js → chunk-7ACS6P5Z.js} +5 -7
  26. package/dist/chunk-7ACS6P5Z.js.map +1 -0
  27. package/dist/{chunk-NAVUTK6X.js → chunk-ARC2V7NY.js} +3 -3
  28. package/dist/{chunk-NAVUTK6X.js.map → chunk-ARC2V7NY.js.map} +1 -1
  29. package/dist/{chunk-WDVG5R2Q.cjs → chunk-AUH2EVWY.cjs} +4 -3
  30. package/dist/chunk-AUH2EVWY.cjs.map +1 -0
  31. package/dist/chunk-BNEUB52I.cjs +55 -0
  32. package/dist/chunk-BNEUB52I.cjs.map +1 -0
  33. package/dist/chunk-BPL5CVZ5.js +53 -0
  34. package/dist/chunk-BPL5CVZ5.js.map +1 -0
  35. package/dist/{chunk-NVQSBRG6.js → chunk-CBBT42VX.js} +3 -3
  36. package/dist/{chunk-NVQSBRG6.js.map → chunk-CBBT42VX.js.map} +1 -1
  37. package/dist/chunk-CHKV2L2Y.cjs +416 -0
  38. package/dist/chunk-CHKV2L2Y.cjs.map +1 -0
  39. package/dist/{chunk-SNVYOX46.cjs → chunk-DJKGDLYZ.cjs} +91 -61
  40. package/dist/chunk-DJKGDLYZ.cjs.map +1 -0
  41. package/dist/{chunk-354F3OF5.js → chunk-FGGVSHDW.js} +3 -3
  42. package/dist/{chunk-354F3OF5.js.map → chunk-FGGVSHDW.js.map} +1 -1
  43. package/dist/{chunk-6OCJWGVD.cjs → chunk-FTXY4D44.cjs} +4 -4
  44. package/dist/{chunk-6OCJWGVD.cjs.map → chunk-FTXY4D44.cjs.map} +1 -1
  45. package/dist/chunk-INVEGVGO.js +405 -0
  46. package/dist/chunk-INVEGVGO.js.map +1 -0
  47. package/dist/{chunk-ZOL3L4EH.js → chunk-IOBHFP2E.js} +49 -19
  48. package/dist/chunk-IOBHFP2E.js.map +1 -0
  49. package/dist/{chunk-BZK5QL3N.cjs → chunk-KMFBNKCT.cjs} +4 -4
  50. package/dist/{chunk-BZK5QL3N.cjs.map → chunk-KMFBNKCT.cjs.map} +1 -1
  51. package/dist/{chunk-DF77RBF4.js → chunk-LCCT5ZXJ.js} +6 -6
  52. package/dist/{chunk-DF77RBF4.js.map → chunk-LCCT5ZXJ.js.map} +1 -1
  53. package/dist/{chunk-G7XBVM3T.cjs → chunk-MHUOVS5I.cjs} +5 -5
  54. package/dist/{chunk-G7XBVM3T.cjs.map → chunk-MHUOVS5I.cjs.map} +1 -1
  55. package/dist/{chunk-CWQPQTUZ.cjs → chunk-NEH3BPFD.cjs} +15 -15
  56. package/dist/{chunk-CWQPQTUZ.cjs.map → chunk-NEH3BPFD.cjs.map} +1 -1
  57. package/dist/{chunk-5AR6O7GW.js → chunk-NK5EOTDY.js} +3 -3
  58. package/dist/{chunk-5AR6O7GW.js.map → chunk-NK5EOTDY.js.map} +1 -1
  59. package/dist/{chunk-4TEGFMSP.cjs → chunk-P7QYG4RZ.cjs} +23 -15
  60. package/dist/chunk-P7QYG4RZ.cjs.map +1 -0
  61. package/dist/chunk-PPU2D4FZ.js +19 -0
  62. package/dist/chunk-PPU2D4FZ.js.map +1 -0
  63. package/dist/{chunk-AB4OPJLD.js → chunk-RGVMJU57.js} +3 -3
  64. package/dist/{chunk-AB4OPJLD.js.map → chunk-RGVMJU57.js.map} +1 -1
  65. package/dist/{chunk-4KBI37F3.cjs → chunk-RTDVSHJR.cjs} +5 -5
  66. package/dist/{chunk-4KBI37F3.cjs.map → chunk-RTDVSHJR.cjs.map} +1 -1
  67. package/dist/{chunk-CJN5CEI3.js → chunk-RZL2W4C3.js} +23 -15
  68. package/dist/chunk-RZL2W4C3.js.map +1 -0
  69. package/dist/chunk-SPEN7RJU.cjs +18 -0
  70. package/dist/{chunk-R5UQL2R5.cjs.map → chunk-SPEN7RJU.cjs.map} +1 -1
  71. package/dist/{chunk-ZF2LDKQQ.cjs → chunk-U3DW3WDE.cjs} +9 -8
  72. package/dist/chunk-U3DW3WDE.cjs.map +1 -0
  73. package/dist/{chunk-LXG6VL6R.cjs → chunk-U7PRI3XM.cjs} +3 -3
  74. package/dist/{chunk-LXG6VL6R.cjs.map → chunk-U7PRI3XM.cjs.map} +1 -1
  75. package/dist/{chunk-H7G65PNI.js → chunk-VCQ37TC5.js} +3 -3
  76. package/dist/{chunk-H7G65PNI.js.map → chunk-VCQ37TC5.js.map} +1 -1
  77. package/dist/{chunk-SDZ4XDWS.cjs → chunk-VWYFGE27.cjs} +9 -9
  78. package/dist/{chunk-SDZ4XDWS.cjs.map → chunk-VWYFGE27.cjs.map} +1 -1
  79. package/dist/{chunk-RN3XDZGS.js → chunk-WM646HEN.js} +4 -3
  80. package/dist/chunk-WM646HEN.js.map +1 -0
  81. package/dist/chunk-X7CE7Y5W.js +305 -0
  82. package/dist/chunk-X7CE7Y5W.js.map +1 -0
  83. package/dist/{chunk-CGH4BCIY.cjs → chunk-XE3CAY6Z.cjs} +5 -5
  84. package/dist/{chunk-CGH4BCIY.cjs.map → chunk-XE3CAY6Z.cjs.map} +1 -1
  85. package/dist/chunk-XOU3CL7S.cjs +312 -0
  86. package/dist/chunk-XOU3CL7S.cjs.map +1 -0
  87. package/dist/{chunk-ULEK4OM4.js → chunk-YKNBTHMD.js} +3 -3
  88. package/dist/{chunk-ULEK4OM4.js.map → chunk-YKNBTHMD.js.map} +1 -1
  89. package/dist/{compact-session-D2MQDB6G.cjs → compact-session-NX7HUNTB.cjs} +16 -16
  90. package/dist/{compact-session-D2MQDB6G.cjs.map → compact-session-NX7HUNTB.cjs.map} +1 -1
  91. package/dist/{compact-session-N2PPHQO6.js → compact-session-Q5IGNFPW.js} +7 -7
  92. package/dist/{compact-session-N2PPHQO6.js.map → compact-session-Q5IGNFPW.js.map} +1 -1
  93. package/dist/{cron-CK2v0VWA.d.cts → cron-Bh3aWgQ2.d.cts} +2 -2
  94. package/dist/{cron-BubDpFJG.d.ts → cron-CCDxeeFZ.d.ts} +2 -2
  95. package/dist/cron.cjs +18 -17
  96. package/dist/cron.d.cts +4 -3
  97. package/dist/cron.d.ts +4 -3
  98. package/dist/cron.js +17 -16
  99. package/dist/eval.cjs +17 -16
  100. package/dist/eval.cjs.map +1 -1
  101. package/dist/eval.js +16 -15
  102. package/dist/eval.js.map +1 -1
  103. package/dist/fs-session-store-CYNTEPJZ.cjs +20 -0
  104. package/dist/{fs-session-store-S2AXVJIX.cjs.map → fs-session-store-CYNTEPJZ.cjs.map} +1 -1
  105. package/dist/fs-session-store-MYQEVUFL.js +11 -0
  106. package/dist/{fs-session-store-6ZCCJX3K.js.map → fs-session-store-MYQEVUFL.js.map} +1 -1
  107. package/dist/{index-manager-HO456AVW.cjs → index-manager-2KH75BRW.cjs} +7 -7
  108. package/dist/{index-manager-HO456AVW.cjs.map → index-manager-2KH75BRW.cjs.map} +1 -1
  109. package/dist/{index-manager-QDH56FER.js → index-manager-NF2WRLOU.js} +6 -6
  110. package/dist/{index-manager-QDH56FER.js.map → index-manager-NF2WRLOU.js.map} +1 -1
  111. package/dist/index.cjs +66 -262
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +10 -46
  114. package/dist/index.d.ts +10 -46
  115. package/dist/index.js +27 -227
  116. package/dist/index.js.map +1 -1
  117. package/dist/{inject-session-J26SHHIO.js → inject-session-4ROYLZHY.js} +3 -3
  118. package/dist/{inject-session-J26SHHIO.js.map → inject-session-4ROYLZHY.js.map} +1 -1
  119. package/dist/{inject-session-3ICZIJ2N.cjs → inject-session-AWKDCGHV.cjs} +4 -4
  120. package/dist/{inject-session-3ICZIJ2N.cjs.map → inject-session-AWKDCGHV.cjs.map} +1 -1
  121. package/dist/internal/agent-loop/doom-loop-tracker.d.ts +3 -0
  122. package/dist/internal/agent-loop/types.d.ts +6 -0
  123. package/dist/internal/error-mappers/anthropic.d.ts +3 -0
  124. package/dist/internal/error-mappers/openai-compatible.d.ts +2 -3
  125. package/dist/internal/local-agent/local-agent-dispatch.d.ts +3 -1
  126. package/dist/internal/local-agent/send-queue.d.ts +31 -0
  127. package/dist/internal/mcp/client.d.ts +2 -0
  128. package/dist/internal/mcp/oauth-bearer.d.ts +2 -0
  129. package/dist/internal/memory/adapters/index.cjs +3 -3
  130. package/dist/internal/memory/adapters/index.js +2 -2
  131. package/dist/internal/memory/dreaming/phases.d.ts +15 -0
  132. package/dist/internal/memory/dreaming/run.d.ts +29 -0
  133. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +2 -0
  134. package/dist/internal/memory/storage/index.cjs +51 -35
  135. package/dist/internal/memory/storage/index.d.cts +2 -0
  136. package/dist/internal/memory/storage/index.d.ts +2 -0
  137. package/dist/internal/memory/storage/index.js +4 -4
  138. package/dist/internal/persistence/cwd-mutex.d.cts +4 -2
  139. package/dist/internal/persistence/cwd-mutex.d.ts +4 -2
  140. package/dist/internal/persistence/index.cjs +4 -4
  141. package/dist/internal/persistence/index.js +2 -2
  142. package/dist/internal/persistence/sqlite-session-store.d.cts +25 -0
  143. package/dist/internal/persistence/sqlite-session-store.d.ts +25 -0
  144. package/dist/internal/providers/registry.d.ts +5 -1
  145. package/dist/mcp-auth.cjs +25 -307
  146. package/dist/mcp-auth.cjs.map +1 -1
  147. package/dist/mcp-auth.js +5 -305
  148. package/dist/mcp-auth.js.map +1 -1
  149. package/dist/models.cjs +9 -9
  150. package/dist/models.js +2 -2
  151. package/dist/persistence.cjs +9 -4
  152. package/dist/persistence.cjs.map +1 -1
  153. package/dist/persistence.d.cts +744 -40
  154. package/dist/persistence.d.ts +744 -40
  155. package/dist/persistence.js +3 -2
  156. package/dist/persistence.js.map +1 -1
  157. package/dist/providers.cjs +4 -4
  158. package/dist/providers.js +2 -2
  159. package/dist/sandbox/docker-sandbox.d.cts +58 -0
  160. package/dist/sandbox/docker-sandbox.d.ts +58 -0
  161. package/dist/sandbox/index.cjs +129 -1
  162. package/dist/sandbox/index.cjs.map +1 -1
  163. package/dist/sandbox/index.d.cts +1 -0
  164. package/dist/sandbox/index.d.ts +1 -0
  165. package/dist/sandbox/index.js +132 -5
  166. package/dist/sandbox/index.js.map +1 -1
  167. package/dist/{sdk-agent-DwzHcuxy.d.cts → sdk-agent-BA_6_wtc.d.cts} +30 -2
  168. package/dist/{sdk-agent-a3fW1xUK.d.ts → sdk-agent-CnwPODYH.d.ts} +30 -2
  169. package/dist/session-store-Dh07jr9N.d.cts +209 -0
  170. package/dist/session-store-Dh07jr9N.d.ts +209 -0
  171. package/dist/sqlite-session-store-BbcpKY1L.d.ts +64 -0
  172. package/dist/sqlite-session-store-TKXtT4ON.d.cts +64 -0
  173. package/dist/subagents-loader-KLWF4QPD.cjs +16 -0
  174. package/dist/{subagents-loader-TXOA5EJJ.cjs.map → subagents-loader-KLWF4QPD.cjs.map} +1 -1
  175. package/dist/subagents-loader-SXETS2F2.js +7 -0
  176. package/dist/{subagents-loader-Z744TAKD.js.map → subagents-loader-SXETS2F2.js.map} +1 -1
  177. package/dist/subagents-loader.cjs +2 -2
  178. package/dist/subagents-loader.d.cts +3 -2
  179. package/dist/subagents-loader.d.ts +3 -2
  180. package/dist/subagents-loader.js +1 -1
  181. package/dist/types/agent.d.ts +14 -1
  182. package/dist/types/budget-tracker.d.ts +6 -2
  183. package/dist/types/mcp.d.ts +14 -0
  184. package/dist/types/run.d.ts +15 -1
  185. package/dist/workflow.d.cts +1 -1
  186. package/dist/workflow.d.ts +1 -1
  187. package/docs/adr/mutation-testing-scope.md +12 -2
  188. package/docs/error-codes.md +41 -40
  189. package/docs/harness-capability-map.md +32 -6
  190. package/package.json +1 -1
  191. package/dist/chunk-2WY2OFSC.cjs.map +0 -1
  192. package/dist/chunk-4TEGFMSP.cjs.map +0 -1
  193. package/dist/chunk-6CXRYPG7.cjs +0 -211
  194. package/dist/chunk-6CXRYPG7.cjs.map +0 -1
  195. package/dist/chunk-CJN5CEI3.js.map +0 -1
  196. package/dist/chunk-GARVAUCU.js.map +0 -1
  197. package/dist/chunk-MSEL5E5P.js +0 -204
  198. package/dist/chunk-MSEL5E5P.js.map +0 -1
  199. package/dist/chunk-NP362THY.cjs.map +0 -1
  200. package/dist/chunk-Q5EWJPRY.js +0 -18
  201. package/dist/chunk-Q5EWJPRY.js.map +0 -1
  202. package/dist/chunk-R5UQL2R5.cjs +0 -18
  203. package/dist/chunk-RN3XDZGS.js.map +0 -1
  204. package/dist/chunk-SNVYOX46.cjs.map +0 -1
  205. package/dist/chunk-WDVG5R2Q.cjs.map +0 -1
  206. package/dist/chunk-ZF2LDKQQ.cjs.map +0 -1
  207. package/dist/chunk-ZJAYFSVI.js.map +0 -1
  208. package/dist/chunk-ZOL3L4EH.js.map +0 -1
  209. package/dist/fs-session-store-6ZCCJX3K.js +0 -11
  210. package/dist/fs-session-store-S2AXVJIX.cjs +0 -20
  211. package/dist/subagents-loader-TXOA5EJJ.cjs +0 -16
  212. package/dist/subagents-loader-Z744TAKD.js +0 -7
@@ -431,6 +431,13 @@ type McpStdioServerConfig = {
431
431
  * policy and always wins. Pass `"all"` to restore full inheritance.
432
432
  */
433
433
  envPolicy?: EnvPolicy;
434
+ /**
435
+ * Run the calls a model makes to this server's tools in ONE step one at a time, in the order the
436
+ * model listed them, instead of at once. Set it for a stateful server whose tools act on shared
437
+ * state, such as a browser MCP server where a snapshot must wait for the navigation before it.
438
+ * Calls to other servers or non-MCP tools in the same step are not held behind it. Default `false`.
439
+ */
440
+ sequential?: boolean;
434
441
  };
435
442
  /**
436
443
  * OAuth-style auth bundle for HTTP/SSE MCP servers.
@@ -482,6 +489,13 @@ type McpHttpServerConfig = {
482
489
  * `NetworkError` (`code: "mcp_timeout"`). Default 30_000.
483
490
  */
484
491
  requestTimeoutMs?: number;
492
+ /**
493
+ * Run the calls a model makes to this server's tools in ONE step one at a time, in the order the
494
+ * model listed them, instead of at once. Set it for a stateful server whose tools act on shared
495
+ * state, such as a browser MCP server where a snapshot must wait for the navigation before it.
496
+ * Calls to other servers or non-MCP tools in the same step are not held behind it. Default `false`.
497
+ */
498
+ sequential?: boolean;
485
499
  };
486
500
  /**
487
501
  * Union of MCP server configs.
@@ -1864,6 +1878,8 @@ type SDKImage = {
1864
1878
  mimeType: string;
1865
1879
  dimension?: SDKImageDimension;
1866
1880
  };
1881
+ /** How a message sent during a running turn is queued. See {@link SendOptions.queueMode}. @public */
1882
+ type QueueMode = "followup" | "steer" | "collect";
1867
1883
  /**
1868
1884
  * Structured form of `agent.send()`'s message argument. Use it to send images
1869
1885
  * alongside text.
@@ -1891,7 +1907,7 @@ interface SDKUserMessage {
1891
1907
  * | rendering a live UI | `onDelta`, `onStep`, `onRunEvent` |
1892
1908
  * | applying a policy | `permissionMode`, `activeTools`, `toolChoice`, `toolResultGuard`, `pruneToolResults`, `perToolTimeoutMs` |
1893
1909
  * | running an eval or a harness | `maxIterations`, `completionCheck`, `doomLoop`, `signal` |
1894
- * | orchestrating agents | `origin`, `task`, `context` |
1910
+ * | orchestrating agents | `origin`, `task`, `context`, `queueMode` |
1895
1911
  * | overriding this one send | `model`, `systemPrompt`, `tools`, `mcpServers`, `contextPaths`, `local` |
1896
1912
  *
1897
1913
  * Every field appears in exactly one row, and
@@ -1902,6 +1918,18 @@ interface SDKUserMessage {
1902
1918
  * @public
1903
1919
  */
1904
1920
  interface SendOptions {
1921
+ /**
1922
+ * What to do with this message when the agent is ALREADY running a turn (local runtime only; a
1923
+ * cloud agent always queues as `"followup"`). With no turn running, every mode just starts one.
1924
+ *
1925
+ * - `"followup"` (default) — wait for the running turn, then run as its own turn.
1926
+ * - `"steer"` — inject the text into the RUNNING turn as a user message, picked up before the
1927
+ * model's next call (after the current tool round). Resolves to the running turn's `Run`. If
1928
+ * the turn ends before it can pick the message up, it runs as a followup turn instead.
1929
+ * - `"collect"` — batch every `"collect"` message sent while a turn runs into ONE followup turn
1930
+ * (texts joined by a blank line). Every collecting caller resolves to that same batched `Run`.
1931
+ */
1932
+ queueMode?: QueueMode;
1905
1933
  /**
1906
1934
  * Per-send model override. SE8 — accepts a bare-string id shorthand
1907
1935
  * (`"openai/gpt-4o-mini"`, normalized to `{ id }`) OR a {@link ModelSelection}
@@ -2582,4 +2610,4 @@ interface InvalidateCacheOptions {
2582
2610
  applyNow?: boolean;
2583
2611
  }
2584
2612
 
2585
- export type { OutputProcessorContext as $, AgentConversationTurn as A, GenerateRunResult as B, ContextSettings as C, DoomLoopThresholds as D, EnvPolicy as E, ForkOptions as F, GoalOptions as G, InteractionUpdate as H, InputProcessorContext as I, JudgeResult as J, InvalidateCacheOptions as K, McpAuthConfig as L, McpServerConfig as M, McpHttpServerConfig as N, McpOAuthConfig as O, ProviderRoutingSettings as P, McpStdioServerConfig as Q, RunResult as R, SDKAgent as S, MemoryAdapter as T, MemoryAdapterCapabilities as U, MemoryContext as V, MemoryFact as W, MemoryRevision as X, MemoryToolSchema as Y, MemoryTurnMessage as Z, MessageOrigin as _, PluginsSettings as a, TokenUsage as a$, PartialToolCallUpdate as a0, PersonalityPreset as a1, ProcessorControls as a2, ProcessorTripwire as a3, ProcessorViolation as a4, ProviderCapability as a5, ProviderRoute as a6, PruneToolResultsOptions as a7, ResolvedProviderRoute as a8, RunCompactBoundaryEvent as a9, SDKPluginMetadata as aA, SDKProvidersManager as aB, SDKRequestMessage as aC, SDKStatusMessage as aD, SDKSystemMessage as aE, SDKTaskMessage as aF, SDKThinkingMessage as aG, SDKToolUseMessage as aH, SDKUserMessage as aI, SDKUserMessageEvent as aJ, SendOptions as aK, ShellCommand as aL, ShellConversationTurn as aM, ShellOutput as aN, ShellOutputDeltaUpdate as aO, StepCompletedUpdate as aP, StepStartedUpdate as aQ, StreamToCompletionResult as aR, SummaryCompletedUpdate as aS, SummaryStartedUpdate as aT, SummaryUpdate as aU, SystemPromptSkillRef as aV, TextDeltaUpdate as aW, ThinkingCompletedUpdate as aX, ThinkingDeltaUpdate as aY, ThinkingMessage as aZ, TokenDeltaUpdate as a_, RunCompletionCheckEvent as aa, RunErrorDetail as ab, RunEvent as ac, RunGitInfo as ad, RunMemoryDegradedEvent as ae, RunPermissionDeniedEvent as af, RunRateLimitEvent as ag, RunStatus as ah, RunTaskCompletedEvent as ai, RunTaskStartedEvent as aj, RunTaskUpdatedEvent as ak, RunTimelineEvent as al, RunToCompletionOptions as am, RunToCompletionResult as an, RunToolProgressEvent as ao, RunTripwireEvent as ap, RunUntilIterator as aq, SDKAgentPlugins as ar, SDKAgentSkillDetail as as, SDKAgentSkills as at, SDKArtifact as au, SDKAssistantMessage as av, SDKContextManager as aw, SDKImage as ax, SDKImageDimension as ay, SDKObjectDelta as az, Run as b, ToolCall as b0, ToolCallCompletedUpdate as b1, ToolCallStartedUpdate as b2, ToolResult as b3, ToolResultGuardOptions as b4, ToolUseBlock as b5, TurnEndedUpdate as b6, UserMessage as b7, UserMessageAppendedUpdate as b8, Verdict as b9, Processor as c, GoalEvent as d, GoalResult as e, MemoryId as f, RunEventSink as g, SDKProvider as h, SDKMessage as i, AgentMemory as j, AgentOperation as k, AssistantMessage as l, CompletionCheck as m, CompletionCheckResult as n, ContextBudget as o, ContextManagerKind as p, ContextSnapshot as q, ContextSource as r, ContextSourceStatus as s, ConversationStep as t, ConversationTurn as u, CostBreakdown as v, CostSource as w, CostStatus as x, ForkResult as y, GenerateOptions as z };
2613
+ export type { OutputProcessorContext as $, AgentConversationTurn as A, GenerateRunResult as B, ContextSettings as C, DoomLoopThresholds as D, EnvPolicy as E, ForkOptions as F, GoalOptions as G, InteractionUpdate as H, InputProcessorContext as I, JudgeResult as J, InvalidateCacheOptions as K, McpAuthConfig as L, McpServerConfig as M, McpHttpServerConfig as N, McpOAuthConfig as O, ProviderRoutingSettings as P, McpStdioServerConfig as Q, RunResult as R, SDKAgent as S, MemoryAdapter as T, MemoryAdapterCapabilities as U, MemoryContext as V, MemoryFact as W, MemoryRevision as X, MemoryToolSchema as Y, MemoryTurnMessage as Z, MessageOrigin as _, PluginsSettings as a, TokenDeltaUpdate as a$, PartialToolCallUpdate as a0, PersonalityPreset as a1, ProcessorControls as a2, ProcessorTripwire as a3, ProcessorViolation as a4, ProviderCapability as a5, ProviderRoute as a6, PruneToolResultsOptions as a7, QueueMode as a8, ResolvedProviderRoute as a9, SDKObjectDelta as aA, SDKPluginMetadata as aB, SDKProvidersManager as aC, SDKRequestMessage as aD, SDKStatusMessage as aE, SDKSystemMessage as aF, SDKTaskMessage as aG, SDKThinkingMessage as aH, SDKToolUseMessage as aI, SDKUserMessage as aJ, SDKUserMessageEvent as aK, SendOptions as aL, ShellCommand as aM, ShellConversationTurn as aN, ShellOutput as aO, ShellOutputDeltaUpdate as aP, StepCompletedUpdate as aQ, StepStartedUpdate as aR, StreamToCompletionResult as aS, SummaryCompletedUpdate as aT, SummaryStartedUpdate as aU, SummaryUpdate as aV, SystemPromptSkillRef as aW, TextDeltaUpdate as aX, ThinkingCompletedUpdate as aY, ThinkingDeltaUpdate as aZ, ThinkingMessage as a_, RunCompactBoundaryEvent as aa, RunCompletionCheckEvent as ab, RunErrorDetail as ac, RunEvent as ad, RunGitInfo as ae, RunMemoryDegradedEvent as af, RunPermissionDeniedEvent as ag, RunRateLimitEvent as ah, RunStatus as ai, RunTaskCompletedEvent as aj, RunTaskStartedEvent as ak, RunTaskUpdatedEvent as al, RunTimelineEvent as am, RunToCompletionOptions as an, RunToCompletionResult as ao, RunToolProgressEvent as ap, RunTripwireEvent as aq, RunUntilIterator as ar, SDKAgentPlugins as as, SDKAgentSkillDetail as at, SDKAgentSkills as au, SDKArtifact as av, SDKAssistantMessage as aw, SDKContextManager as ax, SDKImage as ay, SDKImageDimension as az, Run as b, TokenUsage as b0, ToolCall as b1, ToolCallCompletedUpdate as b2, ToolCallStartedUpdate as b3, ToolResult as b4, ToolResultGuardOptions as b5, ToolUseBlock as b6, TurnEndedUpdate as b7, UserMessage as b8, UserMessageAppendedUpdate as b9, Verdict as ba, Processor as c, GoalEvent as d, GoalResult as e, MemoryId as f, RunEventSink as g, SDKProvider as h, SDKMessage as i, AgentMemory as j, AgentOperation as k, AssistantMessage as l, CompletionCheck as m, CompletionCheckResult as n, ContextBudget as o, ContextManagerKind as p, ContextSnapshot as q, ContextSource as r, ContextSourceStatus as s, ConversationStep as t, ConversationTurn as u, CostBreakdown as v, CostSource as w, CostStatus as x, ForkResult as y, GenerateOptions as z };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Owner: `src/` (1 of 2 importers). Derived from the import graph, not
3
+ * declared — `tests/lint/types-name-their-owner.test.ts` re-derives it.
4
+ *
5
+ * `SessionRecord` — the native on-disk transcript record shape (SE40).
6
+ *
7
+ * The theokit session format IS the Claude Code record shape: a
8
+ * `uuid`/`parentUuid` DAG of records with structured
9
+ * `text`/`tool_use`/`tool_result`/`thinking` blocks. This is the contract the
10
+ * pluggable {@link SessionStore} seam operates over.
11
+ *
12
+ * DIP-correct home (SE46): the contract lives in the domain `types/` layer;
13
+ * the application-layer DAG core (`internal/persistence/session-transcript.ts`)
14
+ * re-exports it for back-compat while owning the record builders + reader.
15
+ *
16
+ * @public
17
+ */
18
+ /** A content block inside {@link TranscriptMessage}. */
19
+ type TranscriptBlock = {
20
+ type: "text";
21
+ text: string;
22
+ } | {
23
+ type: "thinking";
24
+ thinking?: string;
25
+ signature?: string;
26
+ } | {
27
+ type: "tool_use";
28
+ id: string;
29
+ name: string;
30
+ input: unknown;
31
+ } | {
32
+ type: "tool_result";
33
+ tool_use_id: string;
34
+ content: unknown;
35
+ is_error?: boolean;
36
+ };
37
+ /**
38
+ * The message body of a {@link SessionRecord}.
39
+ *
40
+ * **It is NOT called `SessionMessage`** — that name already exists in
41
+ * `internal/session/session-types.ts` with the shape `{role, text}`, incompatible with this one.
42
+ * Reusing an exported name for a new shape is
43
+ * precisely the silent break M91 cost two patches to undo.
44
+ *
45
+ * Parsing from disk stays **tolerant** (`readTranscript` skips a malformed line): what changes here
46
+ * is the **type**, not leniency — records written by earlier versions stay readable.
47
+ *
48
+ * @public
49
+ */
50
+ interface TranscriptMessage {
51
+ role: "user" | "assistant";
52
+ content: TranscriptBlock[];
53
+ /**
54
+ * The three fields below appear **only** on the assistant record, and come from the writer
55
+ * (`SessionTranscript.appendAssistant`). Declared optional because the user record does not carry
56
+ * them — measured in the writer itself, not assumed.
57
+ */
58
+ id?: string;
59
+ type?: "message";
60
+ model?: string;
61
+ }
62
+ /**
63
+ * One transcript record — a single line of the session JSONL file, and the unit the pluggable
64
+ * `SessionStore` seam reads and writes.
65
+ *
66
+ * Records form a `uuid`/`parentUuid` DAG, not a flat list: `parentUuid` names the preceding record
67
+ * and is `null` at the root. Thread a session by following those links; a reader that assumes file
68
+ * order is linear will mis-thread one that branched.
69
+ *
70
+ * `message` is absent on `system` records — a compaction boundary carries `compactMetadata` instead —
71
+ * so it is optional even on records you would expect to be conversational, and `type` is what tells
72
+ * you which you are holding.
73
+ *
74
+ * Reading is deliberately tolerant: a malformed line is skipped rather than failing the whole read.
75
+ * Every record you receive is well-formed, but the file may have contained more than you got back,
76
+ * so this is not the type to use for an exact-count audit of what was written.
77
+ *
78
+ * @public
79
+ */
80
+ interface SessionRecord {
81
+ type: "user" | "assistant" | "system";
82
+ uuid: string;
83
+ parentUuid: string | null;
84
+ sessionId: string;
85
+ timestamp: string;
86
+ isSidechain?: boolean;
87
+ userType?: string;
88
+ cwd?: string;
89
+ version?: string;
90
+ subtype?: string;
91
+ compactMetadata?: {
92
+ preTokens: number;
93
+ trigger: string;
94
+ };
95
+ /**
96
+ * The message body, in the shape the transcript writer actually writes.
97
+ *
98
+ * M94 — it was `Record<string, unknown>`, and the consumer recovered the type with a cast on every read.
99
+ * The shape **has always been fixed** (`SessionTranscript.appendToolResults` / `#push` produce
100
+ * it); it simply was not declared. It stays optional because system records carry no message.
101
+ */
102
+ message?: TranscriptMessage;
103
+ }
104
+
105
+ /**
106
+ * Owner: `internal/session/` (4 of 8 importers). Derived from the import graph, not declared —
107
+ * `tests/lint/types-name-their-owner.test.ts` re-derives it.
108
+ *
109
+ * SE41 — the pluggable `SessionStore` seam over the NATIVE session transcript.
110
+ *
111
+ * A minimal, two-method port so an external store (Postgres / Redis / KV /
112
+ * durable object) can be the **primary store AND resume source** — the
113
+ * serverless (ephemeral FS) and multi-host / multi-pod use case that SE40
114
+ * dropped when it removed the `ConversationStorageAdapter`. This is deliberately
115
+ * NOT that removed ~10-method adapter: the seam is JUST record read/append over
116
+ * the native {@link SessionRecord} shape (no getMessages / getSessionMeta /
117
+ * delete / objective methods).
118
+ *
119
+ * The SDK ships a real default implementation, `FsSessionStore`, that reads and
120
+ * append-writes the native Claude-shaped `.jsonl` transcript — omitting
121
+ * `local.sessionStore` yields byte-identical current behavior (back-compat, zero
122
+ * consumer change). Injected via `local.sessionStore` for external stores.
123
+ *
124
+ * THIS SEAM DOES NOT HIDE THE STORAGE, AND IS NOT MEANT TO. A Repository
125
+ * abstracts a persistence model away; this one is defined in terms of the
126
+ * native one — the port speaks {@link SessionRecord}, "the exact SessionRecord
127
+ * the SDK writes", and the on-disk layout's path helpers (`encodeProjectDir`,
128
+ * `transcriptPath`, `transcriptRoot`) are published on purpose at
129
+ * `@theokit/sdk/persistence` so a consumer can locate a transcript file.
130
+ *
131
+ * That is the whole design and the reason the seam is two methods rather than
132
+ * ten: the format is the contract, and a store implements read/append over it.
133
+ * A consumer supplying `local.sessionStore` is NOT bound by those paths — they
134
+ * describe where the DEFAULT `FsSessionStore` puts files, not where an external
135
+ * store must.
136
+ *
137
+ * Consistency contract: `appendRecords` is append-only and ordering-preserving.
138
+ * The FS default serializes appends per agent with a cross-process file lock;
139
+ * external implementations own (and MUST document) their own concurrency
140
+ * guarantees for two hosts appending to the same `agentId`.
141
+ *
142
+ * @public
143
+ */
144
+
145
+ /**
146
+ * The pluggable session-store seam. Exactly two methods over the native
147
+ * {@link SessionRecord} shape.
148
+ *
149
+ * @public
150
+ */
151
+ interface SessionStore {
152
+ /**
153
+ * Return every persisted record for `agentId`, in append order. A session
154
+ * that was never written MUST resolve to `[]` (not throw) — a fresh agent has
155
+ * no history. The SDK reconstructs the resumable `LlmMessage[]` from these
156
+ * records via the native DAG reader, so the shape MUST be the exact
157
+ * {@link SessionRecord} the SDK writes.
158
+ *
159
+ * A store that cannot READ (e.g. the backing DB is unreachable on resume)
160
+ * MUST throw a typed error rather than silently returning `[]` — a silent
161
+ * empty read would masquerade as "no history" and drop the conversation.
162
+ */
163
+ readRecords(agentId: string): Promise<SessionRecord[]>;
164
+ /**
165
+ * Append `records` (the new-turn delta) to `agentId`'s session, append-only.
166
+ * MUST preserve order and MUST NOT drop or rewrite prior records — the native
167
+ * format is an append-only `parentUuid` DAG (compaction is a new-root
168
+ * `compact_boundary` record, still an append).
169
+ *
170
+ * Note on the write path: per-turn persistence is fire-and-forget so `send()`
171
+ * is never blocked by store I/O — an `appendRecords` rejection is logged to
172
+ * stderr, NOT thrown to the caller (best-effort write). An external store that
173
+ * must guarantee durability should make `appendRecords` resilient (retry /
174
+ * durable write) internally. This differs from {@link SessionStore.readRecords},
175
+ * which MUST throw on failure (a resume cannot proceed on a silent partial history).
176
+ */
177
+ appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void>;
178
+ /**
179
+ * Claim the single-writer lease for `agentId`, if this store has one. OPTIONAL.
180
+ *
181
+ * The SDK calls it when an agent starts and skips it when absent, so a two-method store keeps
182
+ * working unchanged — declaring it here does not require it, which is the whole reason it is
183
+ * optional. What declaring it DOES is make the capability discoverable: the SDK probed for this
184
+ * method through an `as unknown` cast against an interface that never mentioned it, so a
185
+ * third-party store author — the serverless / multi-pod case this port exists to serve — read a
186
+ * two-method interface, implemented two methods, and never learned the hook was there.
187
+ *
188
+ * CONTRACT, and the half that matters: a rejection whose `name` is `"SessionBusyError"` PROPAGATES
189
+ * to the caller, because another process holding the session is a decision the caller has to make
190
+ * (`exec` forks to a new id). Any other rejection is treated as "no lease available here" —
191
+ * logged, and the turn proceeds without single-writer protection, since the write is best-effort
192
+ * by contract anyway.
193
+ */
194
+ acquire?(agentId: string): Promise<void>;
195
+ /**
196
+ * Release the lease `acquire` claimed, if this store has one. OPTIONAL.
197
+ *
198
+ * Called on agent disposal. A rejection is not handled specially.
199
+ */
200
+ release?(agentId: string): Promise<void>;
201
+ /**
202
+ * Release store-level resources — a connection pool, a file handle. OPTIONAL.
203
+ *
204
+ * Called once, on agent disposal, after {@link SessionStore.release}.
205
+ */
206
+ dispose?(): Promise<void>;
207
+ }
208
+
209
+ export type { SessionRecord as S, TranscriptBlock as T, SessionStore as a, TranscriptMessage as b };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Owner: `src/` (1 of 2 importers). Derived from the import graph, not
3
+ * declared — `tests/lint/types-name-their-owner.test.ts` re-derives it.
4
+ *
5
+ * `SessionRecord` — the native on-disk transcript record shape (SE40).
6
+ *
7
+ * The theokit session format IS the Claude Code record shape: a
8
+ * `uuid`/`parentUuid` DAG of records with structured
9
+ * `text`/`tool_use`/`tool_result`/`thinking` blocks. This is the contract the
10
+ * pluggable {@link SessionStore} seam operates over.
11
+ *
12
+ * DIP-correct home (SE46): the contract lives in the domain `types/` layer;
13
+ * the application-layer DAG core (`internal/persistence/session-transcript.ts`)
14
+ * re-exports it for back-compat while owning the record builders + reader.
15
+ *
16
+ * @public
17
+ */
18
+ /** A content block inside {@link TranscriptMessage}. */
19
+ type TranscriptBlock = {
20
+ type: "text";
21
+ text: string;
22
+ } | {
23
+ type: "thinking";
24
+ thinking?: string;
25
+ signature?: string;
26
+ } | {
27
+ type: "tool_use";
28
+ id: string;
29
+ name: string;
30
+ input: unknown;
31
+ } | {
32
+ type: "tool_result";
33
+ tool_use_id: string;
34
+ content: unknown;
35
+ is_error?: boolean;
36
+ };
37
+ /**
38
+ * The message body of a {@link SessionRecord}.
39
+ *
40
+ * **It is NOT called `SessionMessage`** — that name already exists in
41
+ * `internal/session/session-types.ts` with the shape `{role, text}`, incompatible with this one.
42
+ * Reusing an exported name for a new shape is
43
+ * precisely the silent break M91 cost two patches to undo.
44
+ *
45
+ * Parsing from disk stays **tolerant** (`readTranscript` skips a malformed line): what changes here
46
+ * is the **type**, not leniency — records written by earlier versions stay readable.
47
+ *
48
+ * @public
49
+ */
50
+ interface TranscriptMessage {
51
+ role: "user" | "assistant";
52
+ content: TranscriptBlock[];
53
+ /**
54
+ * The three fields below appear **only** on the assistant record, and come from the writer
55
+ * (`SessionTranscript.appendAssistant`). Declared optional because the user record does not carry
56
+ * them — measured in the writer itself, not assumed.
57
+ */
58
+ id?: string;
59
+ type?: "message";
60
+ model?: string;
61
+ }
62
+ /**
63
+ * One transcript record — a single line of the session JSONL file, and the unit the pluggable
64
+ * `SessionStore` seam reads and writes.
65
+ *
66
+ * Records form a `uuid`/`parentUuid` DAG, not a flat list: `parentUuid` names the preceding record
67
+ * and is `null` at the root. Thread a session by following those links; a reader that assumes file
68
+ * order is linear will mis-thread one that branched.
69
+ *
70
+ * `message` is absent on `system` records — a compaction boundary carries `compactMetadata` instead —
71
+ * so it is optional even on records you would expect to be conversational, and `type` is what tells
72
+ * you which you are holding.
73
+ *
74
+ * Reading is deliberately tolerant: a malformed line is skipped rather than failing the whole read.
75
+ * Every record you receive is well-formed, but the file may have contained more than you got back,
76
+ * so this is not the type to use for an exact-count audit of what was written.
77
+ *
78
+ * @public
79
+ */
80
+ interface SessionRecord {
81
+ type: "user" | "assistant" | "system";
82
+ uuid: string;
83
+ parentUuid: string | null;
84
+ sessionId: string;
85
+ timestamp: string;
86
+ isSidechain?: boolean;
87
+ userType?: string;
88
+ cwd?: string;
89
+ version?: string;
90
+ subtype?: string;
91
+ compactMetadata?: {
92
+ preTokens: number;
93
+ trigger: string;
94
+ };
95
+ /**
96
+ * The message body, in the shape the transcript writer actually writes.
97
+ *
98
+ * M94 — it was `Record<string, unknown>`, and the consumer recovered the type with a cast on every read.
99
+ * The shape **has always been fixed** (`SessionTranscript.appendToolResults` / `#push` produce
100
+ * it); it simply was not declared. It stays optional because system records carry no message.
101
+ */
102
+ message?: TranscriptMessage;
103
+ }
104
+
105
+ /**
106
+ * Owner: `internal/session/` (4 of 8 importers). Derived from the import graph, not declared —
107
+ * `tests/lint/types-name-their-owner.test.ts` re-derives it.
108
+ *
109
+ * SE41 — the pluggable `SessionStore` seam over the NATIVE session transcript.
110
+ *
111
+ * A minimal, two-method port so an external store (Postgres / Redis / KV /
112
+ * durable object) can be the **primary store AND resume source** — the
113
+ * serverless (ephemeral FS) and multi-host / multi-pod use case that SE40
114
+ * dropped when it removed the `ConversationStorageAdapter`. This is deliberately
115
+ * NOT that removed ~10-method adapter: the seam is JUST record read/append over
116
+ * the native {@link SessionRecord} shape (no getMessages / getSessionMeta /
117
+ * delete / objective methods).
118
+ *
119
+ * The SDK ships a real default implementation, `FsSessionStore`, that reads and
120
+ * append-writes the native Claude-shaped `.jsonl` transcript — omitting
121
+ * `local.sessionStore` yields byte-identical current behavior (back-compat, zero
122
+ * consumer change). Injected via `local.sessionStore` for external stores.
123
+ *
124
+ * THIS SEAM DOES NOT HIDE THE STORAGE, AND IS NOT MEANT TO. A Repository
125
+ * abstracts a persistence model away; this one is defined in terms of the
126
+ * native one — the port speaks {@link SessionRecord}, "the exact SessionRecord
127
+ * the SDK writes", and the on-disk layout's path helpers (`encodeProjectDir`,
128
+ * `transcriptPath`, `transcriptRoot`) are published on purpose at
129
+ * `@theokit/sdk/persistence` so a consumer can locate a transcript file.
130
+ *
131
+ * That is the whole design and the reason the seam is two methods rather than
132
+ * ten: the format is the contract, and a store implements read/append over it.
133
+ * A consumer supplying `local.sessionStore` is NOT bound by those paths — they
134
+ * describe where the DEFAULT `FsSessionStore` puts files, not where an external
135
+ * store must.
136
+ *
137
+ * Consistency contract: `appendRecords` is append-only and ordering-preserving.
138
+ * The FS default serializes appends per agent with a cross-process file lock;
139
+ * external implementations own (and MUST document) their own concurrency
140
+ * guarantees for two hosts appending to the same `agentId`.
141
+ *
142
+ * @public
143
+ */
144
+
145
+ /**
146
+ * The pluggable session-store seam. Exactly two methods over the native
147
+ * {@link SessionRecord} shape.
148
+ *
149
+ * @public
150
+ */
151
+ interface SessionStore {
152
+ /**
153
+ * Return every persisted record for `agentId`, in append order. A session
154
+ * that was never written MUST resolve to `[]` (not throw) — a fresh agent has
155
+ * no history. The SDK reconstructs the resumable `LlmMessage[]` from these
156
+ * records via the native DAG reader, so the shape MUST be the exact
157
+ * {@link SessionRecord} the SDK writes.
158
+ *
159
+ * A store that cannot READ (e.g. the backing DB is unreachable on resume)
160
+ * MUST throw a typed error rather than silently returning `[]` — a silent
161
+ * empty read would masquerade as "no history" and drop the conversation.
162
+ */
163
+ readRecords(agentId: string): Promise<SessionRecord[]>;
164
+ /**
165
+ * Append `records` (the new-turn delta) to `agentId`'s session, append-only.
166
+ * MUST preserve order and MUST NOT drop or rewrite prior records — the native
167
+ * format is an append-only `parentUuid` DAG (compaction is a new-root
168
+ * `compact_boundary` record, still an append).
169
+ *
170
+ * Note on the write path: per-turn persistence is fire-and-forget so `send()`
171
+ * is never blocked by store I/O — an `appendRecords` rejection is logged to
172
+ * stderr, NOT thrown to the caller (best-effort write). An external store that
173
+ * must guarantee durability should make `appendRecords` resilient (retry /
174
+ * durable write) internally. This differs from {@link SessionStore.readRecords},
175
+ * which MUST throw on failure (a resume cannot proceed on a silent partial history).
176
+ */
177
+ appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void>;
178
+ /**
179
+ * Claim the single-writer lease for `agentId`, if this store has one. OPTIONAL.
180
+ *
181
+ * The SDK calls it when an agent starts and skips it when absent, so a two-method store keeps
182
+ * working unchanged — declaring it here does not require it, which is the whole reason it is
183
+ * optional. What declaring it DOES is make the capability discoverable: the SDK probed for this
184
+ * method through an `as unknown` cast against an interface that never mentioned it, so a
185
+ * third-party store author — the serverless / multi-pod case this port exists to serve — read a
186
+ * two-method interface, implemented two methods, and never learned the hook was there.
187
+ *
188
+ * CONTRACT, and the half that matters: a rejection whose `name` is `"SessionBusyError"` PROPAGATES
189
+ * to the caller, because another process holding the session is a decision the caller has to make
190
+ * (`exec` forks to a new id). Any other rejection is treated as "no lease available here" —
191
+ * logged, and the turn proceeds without single-writer protection, since the write is best-effort
192
+ * by contract anyway.
193
+ */
194
+ acquire?(agentId: string): Promise<void>;
195
+ /**
196
+ * Release the lease `acquire` claimed, if this store has one. OPTIONAL.
197
+ *
198
+ * Called on agent disposal. A rejection is not handled specially.
199
+ */
200
+ release?(agentId: string): Promise<void>;
201
+ /**
202
+ * Release store-level resources — a connection pool, a file handle. OPTIONAL.
203
+ *
204
+ * Called once, on agent disposal, after {@link SessionStore.release}.
205
+ */
206
+ dispose?(): Promise<void>;
207
+ }
208
+
209
+ export type { SessionRecord as S, TranscriptBlock as T, SessionStore as a, TranscriptMessage as b };
@@ -0,0 +1,64 @@
1
+ import { a as SessionStore, S as SessionRecord } from './session-store-Dh07jr9N.js';
2
+
3
+ /**
4
+ * Run `fn` after every earlier `withCwdMutex` call for the same `key` has settled, and return
5
+ * what `fn` returns.
6
+ *
7
+ * Calls with the same key run strictly in the order they were made — FIFO, never concurrent.
8
+ * Calls with different keys never wait on each other. The key is an opaque string: two callers
9
+ * serialize against each other exactly when they pass equal keys, so a shared key IS the
10
+ * contract, and a mismatched one silently buys no protection at all.
11
+ *
12
+ * A rejection does not poison the queue. The next waiter runs whether the previous `fn` fulfilled
13
+ * or rejected, and the rejection is delivered only to the caller whose `fn` threw. This function
14
+ * neither retries nor swallows: the returned promise rejects with whatever `fn` rejected with.
15
+ *
16
+ * There is no timeout and no cancellation. An `fn` that never settles blocks that key for the
17
+ * lifetime of the process.
18
+ *
19
+ * **Scope — this is an in-process lock only.** State is a module-scoped Map, so it serializes
20
+ * callers that share one module instance and nothing else. Two processes, two worker threads, or
21
+ * two copies of the SDK resolved into the same tree do not see each other's queue. When the
22
+ * resource is a file that other processes can also write, use `withFileLock` from
23
+ * `./file-lock.ts` instead — it takes an OS-level lock and layers this mutex underneath, so it
24
+ * gives both guarantees. Reach for `withCwdMutex` directly when the shared state is in memory, or
25
+ * when the file is one only this process touches.
26
+ *
27
+ * Extracted packages (`@theokit/sdk-budget`, `@theokit/sdk-memory`) import this from
28
+ * `@theokit/sdk` rather than reimplementing it, precisely so the Map is the same one: a per-package
29
+ * copy would give each package its own queue and let their writes race.
30
+ *
31
+ * The Map is module-scoped, so nothing survives a process restart or a fresh module instance.
32
+ * An entry is dropped as soon as its key has no call pending.
33
+ * Signature and semantics will not change before sdk-core v3.0.
34
+ *
35
+ * @public
36
+ */
37
+ declare function withCwdMutex<T>(key: string, fn: () => Promise<T>): Promise<T>;
38
+
39
+ /** Options for {@link SqliteSessionStore}. */
40
+ interface SqliteSessionStoreOptions {
41
+ /** Absolute path of the SQLite file. Parent directories are created. */
42
+ filePath: string;
43
+ }
44
+ /**
45
+ * A {@link SessionStore} that keeps the native session records in one SQLite file instead of
46
+ * per-agent JSONL transcripts. Pass it as `local.sessionStore`.
47
+ *
48
+ * Uses `better-sqlite3` when installed, else the built-in `node:sqlite` (Node 22.5+).
49
+ * Appends are one transaction, so a batch lands whole or not at all; order is the
50
+ * autoincrement `seq`. Corruption is NOT silently rebuilt: opening a corrupt file throws.
51
+ *
52
+ * @public
53
+ */
54
+ declare class SqliteSessionStore implements SessionStore {
55
+ private readonly filePath;
56
+ private dbPromise;
57
+ constructor(options: SqliteSessionStoreOptions);
58
+ private db;
59
+ readRecords(agentId: string): Promise<SessionRecord[]>;
60
+ appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void>;
61
+ dispose(): Promise<void>;
62
+ }
63
+
64
+ export { SqliteSessionStore as S, type SqliteSessionStoreOptions as a, withCwdMutex as w };
@@ -0,0 +1,64 @@
1
+ import { a as SessionStore, S as SessionRecord } from './session-store-Dh07jr9N.cjs';
2
+
3
+ /**
4
+ * Run `fn` after every earlier `withCwdMutex` call for the same `key` has settled, and return
5
+ * what `fn` returns.
6
+ *
7
+ * Calls with the same key run strictly in the order they were made — FIFO, never concurrent.
8
+ * Calls with different keys never wait on each other. The key is an opaque string: two callers
9
+ * serialize against each other exactly when they pass equal keys, so a shared key IS the
10
+ * contract, and a mismatched one silently buys no protection at all.
11
+ *
12
+ * A rejection does not poison the queue. The next waiter runs whether the previous `fn` fulfilled
13
+ * or rejected, and the rejection is delivered only to the caller whose `fn` threw. This function
14
+ * neither retries nor swallows: the returned promise rejects with whatever `fn` rejected with.
15
+ *
16
+ * There is no timeout and no cancellation. An `fn` that never settles blocks that key for the
17
+ * lifetime of the process.
18
+ *
19
+ * **Scope — this is an in-process lock only.** State is a module-scoped Map, so it serializes
20
+ * callers that share one module instance and nothing else. Two processes, two worker threads, or
21
+ * two copies of the SDK resolved into the same tree do not see each other's queue. When the
22
+ * resource is a file that other processes can also write, use `withFileLock` from
23
+ * `./file-lock.ts` instead — it takes an OS-level lock and layers this mutex underneath, so it
24
+ * gives both guarantees. Reach for `withCwdMutex` directly when the shared state is in memory, or
25
+ * when the file is one only this process touches.
26
+ *
27
+ * Extracted packages (`@theokit/sdk-budget`, `@theokit/sdk-memory`) import this from
28
+ * `@theokit/sdk` rather than reimplementing it, precisely so the Map is the same one: a per-package
29
+ * copy would give each package its own queue and let their writes race.
30
+ *
31
+ * The Map is module-scoped, so nothing survives a process restart or a fresh module instance.
32
+ * An entry is dropped as soon as its key has no call pending.
33
+ * Signature and semantics will not change before sdk-core v3.0.
34
+ *
35
+ * @public
36
+ */
37
+ declare function withCwdMutex<T>(key: string, fn: () => Promise<T>): Promise<T>;
38
+
39
+ /** Options for {@link SqliteSessionStore}. */
40
+ interface SqliteSessionStoreOptions {
41
+ /** Absolute path of the SQLite file. Parent directories are created. */
42
+ filePath: string;
43
+ }
44
+ /**
45
+ * A {@link SessionStore} that keeps the native session records in one SQLite file instead of
46
+ * per-agent JSONL transcripts. Pass it as `local.sessionStore`.
47
+ *
48
+ * Uses `better-sqlite3` when installed, else the built-in `node:sqlite` (Node 22.5+).
49
+ * Appends are one transaction, so a batch lands whole or not at all; order is the
50
+ * autoincrement `seq`. Corruption is NOT silently rebuilt: opening a corrupt file throws.
51
+ *
52
+ * @public
53
+ */
54
+ declare class SqliteSessionStore implements SessionStore {
55
+ private readonly filePath;
56
+ private dbPromise;
57
+ constructor(options: SqliteSessionStoreOptions);
58
+ private db;
59
+ readRecords(agentId: string): Promise<SessionRecord[]>;
60
+ appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void>;
61
+ dispose(): Promise<void>;
62
+ }
63
+
64
+ export { SqliteSessionStore as S, type SqliteSessionStoreOptions as a, withCwdMutex as w };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunkAUH2EVWY_cjs = require('./chunk-AUH2EVWY.cjs');
4
+ require('./chunk-YQ3XC6C2.cjs');
5
+ require('./chunk-6XQLTQB6.cjs');
6
+ require('./chunk-CEGU5AVD.cjs');
7
+ require('./chunk-RNXXYF22.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "loadSubagents", {
12
+ enumerable: true,
13
+ get: function () { return chunkAUH2EVWY_cjs.loadSubagents; }
14
+ });
15
+ //# sourceMappingURL=subagents-loader-KLWF4QPD.cjs.map
16
+ //# sourceMappingURL=subagents-loader-KLWF4QPD.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-TXOA5EJJ.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-KLWF4QPD.cjs"}
@@ -0,0 +1,7 @@
1
+ export { loadSubagents } from './chunk-WM646HEN.js';
2
+ import './chunk-YMVTUV5K.js';
3
+ import './chunk-Q7UG242V.js';
4
+ import './chunk-TNFOU6SB.js';
5
+ import './chunk-3OY6H3I7.js';
6
+ //# sourceMappingURL=subagents-loader-SXETS2F2.js.map
7
+ //# sourceMappingURL=subagents-loader-SXETS2F2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-Z744TAKD.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-SXETS2F2.js"}