@theokit/sdk 5.13.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 (241) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/{agent-DSMuwADp.d.ts → agent-B6C9i_qu.d.ts} +31 -213
  3. package/dist/{agent-iW5kPpfT.d.cts → agent-B6FQad6P.d.cts} +31 -213
  4. package/dist/{agent-5DSDDH7K.js → agent-DRDGUU6T.js} +21 -20
  5. package/dist/{agent-5DSDDH7K.js.map → agent-DRDGUU6T.js.map} +1 -1
  6. package/dist/{agent-WOMRT3KX.cjs → agent-VI2HITPT.cjs} +22 -21
  7. package/dist/{agent-WOMRT3KX.cjs.map → agent-VI2HITPT.cjs.map} +1 -1
  8. package/dist/agent.d.ts +2 -3
  9. package/dist/auth/index.cjs +17 -16
  10. package/dist/auth/index.cjs.map +1 -1
  11. package/dist/auth/index.js +5 -4
  12. package/dist/auth/index.js.map +1 -1
  13. package/dist/{batch-EP3FCL6D.js → batch-N2XDYZED.js} +4 -4
  14. package/dist/{batch-EP3FCL6D.js.map → batch-N2XDYZED.js.map} +1 -1
  15. package/dist/{batch-IZ5EDKJ5.cjs → batch-VFR2MAUE.cjs} +7 -7
  16. package/dist/{batch-IZ5EDKJ5.cjs.map → batch-VFR2MAUE.cjs.map} +1 -1
  17. package/dist/{chunk-XOYNB3YN.js → chunk-23SS4ID4.js} +3 -3
  18. package/dist/{chunk-XOYNB3YN.js.map → chunk-23SS4ID4.js.map} +1 -1
  19. package/dist/{chunk-NHOEXFZT.js → chunk-2HXTNVLM.js} +5 -2
  20. package/dist/chunk-2HXTNVLM.js.map +1 -0
  21. package/dist/{chunk-2C24NSNV.js → chunk-3BBTHFGJ.js} +3 -3
  22. package/dist/{chunk-2C24NSNV.js.map → chunk-3BBTHFGJ.js.map} +1 -1
  23. package/dist/{chunk-NP362THY.cjs → chunk-3F53FLQ7.cjs} +5 -7
  24. package/dist/chunk-3F53FLQ7.cjs.map +1 -0
  25. package/dist/{chunk-3FSBE4PS.js → chunk-3GTN4HOO.js} +10 -6
  26. package/dist/chunk-3GTN4HOO.js.map +1 -0
  27. package/dist/{chunk-7WARNHWW.cjs → chunk-3UMPP553.cjs} +5 -2
  28. package/dist/chunk-3UMPP553.cjs.map +1 -0
  29. package/dist/{chunk-SXH37C7X.cjs → chunk-55LLQFHW.cjs} +6 -6
  30. package/dist/{chunk-SXH37C7X.cjs.map → chunk-55LLQFHW.cjs.map} +1 -1
  31. package/dist/{chunk-QISSETTG.cjs → chunk-5645PMVU.cjs} +6 -4
  32. package/dist/chunk-5645PMVU.cjs.map +1 -0
  33. package/dist/{chunk-JX4LB6XO.js → chunk-5M5GQYBM.js} +617 -250
  34. package/dist/chunk-5M5GQYBM.js.map +1 -0
  35. package/dist/{chunk-KL7ZUMK3.cjs → chunk-64ECM3XM.cjs} +704 -337
  36. package/dist/chunk-64ECM3XM.cjs.map +1 -0
  37. package/dist/{chunk-ZJAYFSVI.js → chunk-7ACS6P5Z.js} +5 -7
  38. package/dist/chunk-7ACS6P5Z.js.map +1 -0
  39. package/dist/{chunk-5A4UFBHW.cjs → chunk-A77UMVMD.cjs} +15 -11
  40. package/dist/chunk-A77UMVMD.cjs.map +1 -0
  41. package/dist/{chunk-ZTP6ZACR.js → chunk-ARC2V7NY.js} +3 -3
  42. package/dist/{chunk-ZTP6ZACR.js.map → chunk-ARC2V7NY.js.map} +1 -1
  43. package/dist/{chunk-WDVG5R2Q.cjs → chunk-AUH2EVWY.cjs} +4 -3
  44. package/dist/chunk-AUH2EVWY.cjs.map +1 -0
  45. package/dist/chunk-BNEUB52I.cjs +55 -0
  46. package/dist/chunk-BNEUB52I.cjs.map +1 -0
  47. package/dist/chunk-BPL5CVZ5.js +53 -0
  48. package/dist/chunk-BPL5CVZ5.js.map +1 -0
  49. package/dist/{chunk-2SFLLOMN.js → chunk-CBBT42VX.js} +3 -3
  50. package/dist/{chunk-2SFLLOMN.js.map → chunk-CBBT42VX.js.map} +1 -1
  51. package/dist/chunk-CHKV2L2Y.cjs +416 -0
  52. package/dist/chunk-CHKV2L2Y.cjs.map +1 -0
  53. package/dist/{chunk-4UYHP6NF.cjs → chunk-DJKGDLYZ.cjs} +93 -63
  54. package/dist/chunk-DJKGDLYZ.cjs.map +1 -0
  55. package/dist/{chunk-354F3OF5.js → chunk-FGGVSHDW.js} +3 -3
  56. package/dist/{chunk-354F3OF5.js.map → chunk-FGGVSHDW.js.map} +1 -1
  57. package/dist/{chunk-6OCJWGVD.cjs → chunk-FTXY4D44.cjs} +4 -4
  58. package/dist/{chunk-6OCJWGVD.cjs.map → chunk-FTXY4D44.cjs.map} +1 -1
  59. package/dist/chunk-INVEGVGO.js +405 -0
  60. package/dist/chunk-INVEGVGO.js.map +1 -0
  61. package/dist/{chunk-2PRGRYEQ.js → chunk-IOBHFP2E.js} +50 -20
  62. package/dist/chunk-IOBHFP2E.js.map +1 -0
  63. package/dist/{chunk-47EACDOC.cjs → chunk-KMFBNKCT.cjs} +4 -4
  64. package/dist/{chunk-47EACDOC.cjs.map → chunk-KMFBNKCT.cjs.map} +1 -1
  65. package/dist/{chunk-DF77RBF4.js → chunk-LCCT5ZXJ.js} +6 -6
  66. package/dist/{chunk-DF77RBF4.js.map → chunk-LCCT5ZXJ.js.map} +1 -1
  67. package/dist/{chunk-G7XBVM3T.cjs → chunk-MHUOVS5I.cjs} +5 -5
  68. package/dist/{chunk-G7XBVM3T.cjs.map → chunk-MHUOVS5I.cjs.map} +1 -1
  69. package/dist/{chunk-CWQPQTUZ.cjs → chunk-NEH3BPFD.cjs} +15 -15
  70. package/dist/{chunk-CWQPQTUZ.cjs.map → chunk-NEH3BPFD.cjs.map} +1 -1
  71. package/dist/{chunk-5AR6O7GW.js → chunk-NK5EOTDY.js} +3 -3
  72. package/dist/{chunk-5AR6O7GW.js.map → chunk-NK5EOTDY.js.map} +1 -1
  73. package/dist/{chunk-S46WJTDL.cjs → chunk-P7QYG4RZ.cjs} +27 -19
  74. package/dist/chunk-P7QYG4RZ.cjs.map +1 -0
  75. package/dist/chunk-PPU2D4FZ.js +19 -0
  76. package/dist/chunk-PPU2D4FZ.js.map +1 -0
  77. package/dist/{chunk-MS3TQSXU.js → chunk-QD6B6W6I.js} +6 -4
  78. package/dist/chunk-QD6B6W6I.js.map +1 -0
  79. package/dist/{chunk-AB4OPJLD.js → chunk-RGVMJU57.js} +3 -3
  80. package/dist/{chunk-AB4OPJLD.js.map → chunk-RGVMJU57.js.map} +1 -1
  81. package/dist/{chunk-NWWTYBD3.cjs → chunk-RTDVSHJR.cjs} +5 -5
  82. package/dist/{chunk-NWWTYBD3.cjs.map → chunk-RTDVSHJR.cjs.map} +1 -1
  83. package/dist/{chunk-5HSMH2ZZ.js → chunk-RZL2W4C3.js} +25 -17
  84. package/dist/chunk-RZL2W4C3.js.map +1 -0
  85. package/dist/chunk-SPEN7RJU.cjs +18 -0
  86. package/dist/{chunk-LO6LIUZ6.cjs.map → chunk-SPEN7RJU.cjs.map} +1 -1
  87. package/dist/{chunk-ZF2LDKQQ.cjs → chunk-U3DW3WDE.cjs} +9 -8
  88. package/dist/chunk-U3DW3WDE.cjs.map +1 -0
  89. package/dist/{chunk-DVP3YMDA.cjs → chunk-U7PRI3XM.cjs} +3 -3
  90. package/dist/{chunk-DVP3YMDA.cjs.map → chunk-U7PRI3XM.cjs.map} +1 -1
  91. package/dist/{chunk-H7G65PNI.js → chunk-VCQ37TC5.js} +3 -3
  92. package/dist/{chunk-H7G65PNI.js.map → chunk-VCQ37TC5.js.map} +1 -1
  93. package/dist/{chunk-SDZ4XDWS.cjs → chunk-VWYFGE27.cjs} +9 -9
  94. package/dist/{chunk-SDZ4XDWS.cjs.map → chunk-VWYFGE27.cjs.map} +1 -1
  95. package/dist/{chunk-RN3XDZGS.js → chunk-WM646HEN.js} +4 -3
  96. package/dist/chunk-WM646HEN.js.map +1 -0
  97. package/dist/chunk-X7CE7Y5W.js +305 -0
  98. package/dist/chunk-X7CE7Y5W.js.map +1 -0
  99. package/dist/{chunk-CGH4BCIY.cjs → chunk-XE3CAY6Z.cjs} +5 -5
  100. package/dist/{chunk-CGH4BCIY.cjs.map → chunk-XE3CAY6Z.cjs.map} +1 -1
  101. package/dist/chunk-XOU3CL7S.cjs +312 -0
  102. package/dist/chunk-XOU3CL7S.cjs.map +1 -0
  103. package/dist/{chunk-NKQVLWDF.js → chunk-YKNBTHMD.js} +3 -3
  104. package/dist/{chunk-NKQVLWDF.js.map → chunk-YKNBTHMD.js.map} +1 -1
  105. package/dist/{compact-session-B7P6EU3Z.cjs → compact-session-NX7HUNTB.cjs} +18 -18
  106. package/dist/{compact-session-B7P6EU3Z.cjs.map → compact-session-NX7HUNTB.cjs.map} +1 -1
  107. package/dist/{compact-session-5HMX6KYT.js → compact-session-Q5IGNFPW.js} +9 -9
  108. package/dist/{compact-session-5HMX6KYT.js.map → compact-session-Q5IGNFPW.js.map} +1 -1
  109. package/dist/{cron-BvxrLW5J.d.cts → cron-Bh3aWgQ2.d.cts} +2 -2
  110. package/dist/{cron-DdKzwJqK.d.ts → cron-CCDxeeFZ.d.ts} +2 -2
  111. package/dist/cron.cjs +21 -20
  112. package/dist/cron.d.cts +4 -3
  113. package/dist/cron.d.ts +4 -3
  114. package/dist/cron.js +20 -19
  115. package/dist/eval.cjs +20 -19
  116. package/dist/eval.cjs.map +1 -1
  117. package/dist/eval.js +19 -18
  118. package/dist/eval.js.map +1 -1
  119. package/dist/fs-session-store-CYNTEPJZ.cjs +20 -0
  120. package/dist/{fs-session-store-S2AXVJIX.cjs.map → fs-session-store-CYNTEPJZ.cjs.map} +1 -1
  121. package/dist/fs-session-store-MYQEVUFL.js +11 -0
  122. package/dist/{fs-session-store-6ZCCJX3K.js.map → fs-session-store-MYQEVUFL.js.map} +1 -1
  123. package/dist/{index-manager-HO456AVW.cjs → index-manager-2KH75BRW.cjs} +7 -7
  124. package/dist/{index-manager-HO456AVW.cjs.map → index-manager-2KH75BRW.cjs.map} +1 -1
  125. package/dist/{index-manager-QDH56FER.js → index-manager-NF2WRLOU.js} +6 -6
  126. package/dist/{index-manager-QDH56FER.js.map → index-manager-NF2WRLOU.js.map} +1 -1
  127. package/dist/index.cjs +93 -273
  128. package/dist/index.cjs.map +1 -1
  129. package/dist/index.d.cts +13 -46
  130. package/dist/index.d.ts +13 -46
  131. package/dist/index.js +52 -236
  132. package/dist/index.js.map +1 -1
  133. package/dist/{inject-session-75L3NCNL.js → inject-session-4ROYLZHY.js} +3 -3
  134. package/dist/{inject-session-75L3NCNL.js.map → inject-session-4ROYLZHY.js.map} +1 -1
  135. package/dist/{inject-session-WOH7TPDX.cjs → inject-session-AWKDCGHV.cjs} +4 -4
  136. package/dist/{inject-session-WOH7TPDX.cjs.map → inject-session-AWKDCGHV.cjs.map} +1 -1
  137. package/dist/internal/agent-loop/doom-loop-tracker.d.ts +3 -0
  138. package/dist/internal/agent-loop/prune-tool-results.d.ts +37 -0
  139. package/dist/internal/agent-loop/types.d.ts +6 -0
  140. package/dist/internal/auth/credential-store.d.ts +1 -1
  141. package/dist/internal/auth/types.d.ts +4 -0
  142. package/dist/internal/error-mappers/anthropic.d.ts +3 -0
  143. package/dist/internal/error-mappers/openai-compatible.d.ts +2 -3
  144. package/dist/internal/local-agent/local-agent-dispatch.d.ts +3 -1
  145. package/dist/internal/local-agent/send-queue.d.ts +31 -0
  146. package/dist/internal/mcp/client.d.ts +2 -0
  147. package/dist/internal/mcp/oauth-bearer.d.ts +2 -0
  148. package/dist/internal/memory/adapters/index.cjs +3 -3
  149. package/dist/internal/memory/adapters/index.js +2 -2
  150. package/dist/internal/memory/dreaming/phases.d.ts +15 -0
  151. package/dist/internal/memory/dreaming/run.d.ts +29 -0
  152. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +2 -0
  153. package/dist/internal/memory/storage/index.cjs +51 -35
  154. package/dist/internal/memory/storage/index.d.cts +2 -0
  155. package/dist/internal/memory/storage/index.d.ts +2 -0
  156. package/dist/internal/memory/storage/index.js +4 -4
  157. package/dist/internal/persistence/cwd-mutex.d.cts +4 -2
  158. package/dist/internal/persistence/cwd-mutex.d.ts +4 -2
  159. package/dist/internal/persistence/index.cjs +4 -4
  160. package/dist/internal/persistence/index.js +2 -2
  161. package/dist/internal/persistence/sqlite-session-store.d.cts +25 -0
  162. package/dist/internal/persistence/sqlite-session-store.d.ts +25 -0
  163. package/dist/internal/providers/registry.d.ts +5 -1
  164. package/dist/internal/runtime/skills/binary-on-path.d.ts +1 -0
  165. package/dist/internal/runtime/skills/discover-skills.d.ts +2 -0
  166. package/dist/mcp-auth.cjs +25 -307
  167. package/dist/mcp-auth.cjs.map +1 -1
  168. package/dist/mcp-auth.js +5 -305
  169. package/dist/mcp-auth.js.map +1 -1
  170. package/dist/models.cjs +11 -11
  171. package/dist/models.js +4 -4
  172. package/dist/persistence.cjs +9 -4
  173. package/dist/persistence.cjs.map +1 -1
  174. package/dist/persistence.d.cts +744 -40
  175. package/dist/persistence.d.ts +744 -40
  176. package/dist/persistence.js +3 -2
  177. package/dist/persistence.js.map +1 -1
  178. package/dist/providers.cjs +6 -6
  179. package/dist/providers.js +4 -4
  180. package/dist/sandbox/docker-sandbox.d.cts +58 -0
  181. package/dist/sandbox/docker-sandbox.d.ts +58 -0
  182. package/dist/sandbox/index.cjs +129 -1
  183. package/dist/sandbox/index.cjs.map +1 -1
  184. package/dist/sandbox/index.d.cts +1 -0
  185. package/dist/sandbox/index.d.ts +1 -0
  186. package/dist/sandbox/index.js +132 -5
  187. package/dist/sandbox/index.js.map +1 -1
  188. package/dist/{sdk-agent-4-dXI2GS.d.cts → sdk-agent-BA_6_wtc.d.cts} +57 -4
  189. package/dist/{sdk-agent-CTOJlWA_.d.ts → sdk-agent-CnwPODYH.d.ts} +57 -4
  190. package/dist/session-store-Dh07jr9N.d.cts +209 -0
  191. package/dist/session-store-Dh07jr9N.d.ts +209 -0
  192. package/dist/skills.cjs +4 -4
  193. package/dist/skills.js +1 -1
  194. package/dist/sqlite-session-store-BbcpKY1L.d.ts +64 -0
  195. package/dist/sqlite-session-store-TKXtT4ON.d.cts +64 -0
  196. package/dist/subagents-loader-KLWF4QPD.cjs +16 -0
  197. package/dist/{subagents-loader-TXOA5EJJ.cjs.map → subagents-loader-KLWF4QPD.cjs.map} +1 -1
  198. package/dist/subagents-loader-SXETS2F2.js +7 -0
  199. package/dist/{subagents-loader-Z744TAKD.js.map → subagents-loader-SXETS2F2.js.map} +1 -1
  200. package/dist/subagents-loader.cjs +2 -2
  201. package/dist/subagents-loader.d.cts +3 -2
  202. package/dist/subagents-loader.d.ts +3 -2
  203. package/dist/subagents-loader.js +1 -1
  204. package/dist/types/agent.d.ts +20 -1
  205. package/dist/types/budget-tracker.d.ts +6 -2
  206. package/dist/types/mcp.d.ts +14 -0
  207. package/dist/types/run.d.ts +42 -3
  208. package/dist/workflow.d.cts +1 -1
  209. package/dist/workflow.d.ts +1 -1
  210. package/docs/adr/mutation-testing-scope.md +66 -0
  211. package/docs/error-codes.md +48 -45
  212. package/docs/harness-capability-map.md +60 -6
  213. package/package.json +1 -1
  214. package/dist/chunk-2PRGRYEQ.js.map +0 -1
  215. package/dist/chunk-3FSBE4PS.js.map +0 -1
  216. package/dist/chunk-4UYHP6NF.cjs.map +0 -1
  217. package/dist/chunk-5A4UFBHW.cjs.map +0 -1
  218. package/dist/chunk-5HSMH2ZZ.js.map +0 -1
  219. package/dist/chunk-6CXRYPG7.cjs +0 -211
  220. package/dist/chunk-6CXRYPG7.cjs.map +0 -1
  221. package/dist/chunk-7WARNHWW.cjs.map +0 -1
  222. package/dist/chunk-JX4LB6XO.js.map +0 -1
  223. package/dist/chunk-KL7ZUMK3.cjs.map +0 -1
  224. package/dist/chunk-LO6LIUZ6.cjs +0 -18
  225. package/dist/chunk-MS3TQSXU.js.map +0 -1
  226. package/dist/chunk-MSEL5E5P.js +0 -204
  227. package/dist/chunk-MSEL5E5P.js.map +0 -1
  228. package/dist/chunk-NHOEXFZT.js.map +0 -1
  229. package/dist/chunk-NP362THY.cjs.map +0 -1
  230. package/dist/chunk-Q5EWJPRY.js +0 -18
  231. package/dist/chunk-Q5EWJPRY.js.map +0 -1
  232. package/dist/chunk-QISSETTG.cjs.map +0 -1
  233. package/dist/chunk-RN3XDZGS.js.map +0 -1
  234. package/dist/chunk-S46WJTDL.cjs.map +0 -1
  235. package/dist/chunk-WDVG5R2Q.cjs.map +0 -1
  236. package/dist/chunk-ZF2LDKQQ.cjs.map +0 -1
  237. package/dist/chunk-ZJAYFSVI.js.map +0 -1
  238. package/dist/fs-session-store-6ZCCJX3K.js +0 -11
  239. package/dist/fs-session-store-S2AXVJIX.cjs +0 -20
  240. package/dist/subagents-loader-TXOA5EJJ.cjs +0 -16
  241. package/dist/subagents-loader-Z744TAKD.js +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#913](https://github.com/usetheokit/theokit-sdk/pull/913) [`f944093`](https://github.com/usetheokit/theokit-sdk/commit/f9440934f33df86054a24a33120d40f7028789ec) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - `@theokit/sdk/sandbox` ships `DockerSandbox`, a `SandboxBackend` that runs each command in a
8
+ throwaway container with a read-only root filesystem, no network by default, dropped capabilities and
9
+ the workspace as the only writable mount, so a shell command cannot write outside its workspace.
10
+
11
+ - [#942](https://github.com/usetheokit/theokit-sdk/pull/942) [`ccaac78`](https://github.com/usetheokit/theokit-sdk/commit/ccaac78d735e0bbd6b7cb91fcfb019fbb0492d35) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - `McpStdioServerConfig` and `McpHttpServerConfig` accept `sequential: true` ([#932](https://github.com/usetheokit/theokit-sdk/issues/932)). The calls a model makes to that server's tools in one step then run one at a time, in the order the model listed them, and the results still come back in call order. Calls to other servers or to non-MCP tools in the same step are not held behind them. Without the option the calls still run at once. Use it for a stateful server such as Playwright MCP, where a snapshot must wait for the navigation before it.
12
+
13
+ - [#879](https://github.com/usetheokit/theokit-sdk/pull/879) [`de5c7bd`](https://github.com/usetheokit/theokit-sdk/commit/de5c7bdc65c6e9b01b1aa02c84069bfc00e03edf) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - New `SqliteSessionStore` (exported from `@theokit/sdk` and `@theokit/sdk/persistence`): a `SessionStore` backed by one SQLite file, passed as `local.sessionStore`. `Agent.transcript`, `injectSessionTurn` and `compact` now read from the agent's configured `local.sessionStore` instead of always opening the JSONL file.
14
+
15
+ ### Patch Changes
16
+
17
+ - [#905](https://github.com/usetheokit/theokit-sdk/pull/905) [`418b27c`](https://github.com/usetheokit/theokit-sdk/commit/418b27ceed5931bdce846b743f1e348df6ae2f46) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - `registerProvider` lowercases a profile's name and aliases, and `getProviderProfile` looks names up
18
+ in lowercase, so a profile registered as `AcmeAI` with alias `AcmeX` is reached by routes naming
19
+ either. This replaces the router's "register it in lowercase" errors for mixed-case names and
20
+ aliases (their two tests now assert routing instead), since such a registration can no longer occur.
21
+
22
+ - [#896](https://github.com/usetheokit/theokit-sdk/pull/896) [`419ba63`](https://github.com/usetheokit/theokit-sdk/commit/419ba631cb248ec6ab8e9e8432aee26b1a93b618) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - `skills.enabled` now restricts the local runtime: a skill not named in it is neither listed nor readable.
23
+
24
+ - [#940](https://github.com/usetheokit/theokit-sdk/pull/940) [`7f21de1`](https://github.com/usetheokit/theokit-sdk/commit/7f21de1b73d9fd62c4d6f26f220b87a7b8540dfe) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - Correction to the 5.12.0 note on malformed chat-completions `prompt_tokens`: the dropped count is left out of the per-call `LlmFinish` and no input budget event is emitted for it, and the SDK writes `provider reported an unusable inputTokens (…)` to the diagnostics sink. `RunResult.usage` and `usage.requests[]` still read that count as `inputTokens: 0`, because `TokenUsage.inputTokens` is a required number; only a consumer with a diagnostics sink can tell a dropped count from a real zero. The diagnostic prints `NaN` in place of the value the provider sent.
25
+
26
+ ## 5.14.0
27
+
28
+ ### Minor Changes
29
+
30
+ - [#859](https://github.com/usetheokit/theokit-sdk/pull/859) [`3f2e8fb`](https://github.com/usetheokit/theokit-sdk/commit/3f2e8fbdd14a06dc2bf65a0a97265b339d388843) Thanks [@usetheodev](https://github.com/usetheodev)! - An application can ship skills in its own package and gate them on a binary. `skills.bundledDirs`
31
+ lists extra skill roots read after the project roots and plugin bundles, so a workspace skill of the
32
+ same name always wins. A skill declaring `requires-bins: git, rg` in its frontmatter is not offered
33
+ to the model while one of those executables is absent from PATH; `skills.get(name)` still resolves
34
+ it. `SkillReadTool.create` also accepts a function returning the skills, evaluated on every call, so
35
+ a skill discovered after the agent was created is readable by the model.
36
+
37
+ - [#859](https://github.com/usetheokit/theokit-sdk/pull/859) [`8469d37`](https://github.com/usetheokit/theokit-sdk/commit/8469d37b56e3c4551f90b8707c55d4ed79c5621b) Thanks [@usetheodev](https://github.com/usetheodev)! - The OAuth ID token is now kept from the token response to the credential file ([#821](https://github.com/usetheokit/theokit-sdk/issues/821)). `exchangeCode`,
38
+ `refreshOAuthTokens`, `pollDeviceToken` and `openaiDeviceLogin` return it as `OAuthTokens.idToken` when
39
+ the provider sends a non-empty `id_token`, `persistOAuthTokens` writes it as `id_token`, and
40
+ `readStoredOAuth` reads it back on `StoredOAuthCredential.id_token`. `ensureFreshCredential` keeps the
41
+ stored ID token when a refresh response has none and stores the new one when it has one. It used to be
42
+ read only to derive the account id and then dropped, so a consumer that drives the Codex CLI, which reads
43
+ the plan and account from the ID token's claims, had to run its own login. A provider that sends no ID
44
+ token gets exactly the file it got before. A file that holds an `id_token` is refused by the read schema
45
+ of earlier SDK versions, so a store shared with an older reader should stay on one version.
46
+
47
+ - [#859](https://github.com/usetheokit/theokit-sdk/pull/859) [`f43cea5`](https://github.com/usetheokit/theokit-sdk/commit/f43cea503a2af8a2ca3ed842dbd0bb6d5732f7e9) Thanks [@usetheodev](https://github.com/usetheodev)! - A run can now stop resending old tool results to the model. Every tool result used to be resent on
48
+ every later LLM call of a run, so a run whose tools print a lot grew its request by that output on
49
+ every round. The new per-send option `pruneToolResults: { olderThanRounds: n }` replaces the
50
+ content of each tool result older than `n` tool rounds with a short stub in the request the agent
51
+ loop sends. The stub keeps the result's `toolUseId` and `isError`. The transcript the run keeps,
52
+ persists and resumes from stays whole, so the stub applies only to the request. The option is off by default, and
53
+ without it the request is unchanged. `olderThanRounds` must be an integer of at least 1. Any other
54
+ value fails the send with `ConfigurationError` code `invalid_prune_tool_results` before any provider
55
+ call. The option type is exported as `PruneToolResultsOptions`.
56
+ Pruning trades request size against prefix-cache reuse: each new round stubs one more previously
57
+ sent result, so on providers that cache message prefixes the cached prefix ends earlier. That cost
58
+ was not measured.
59
+
3
60
  ## 5.13.0
4
61
 
5
62
  ### Minor Changes
@@ -1,214 +1,7 @@
1
- import { W as MemoryFact, T as MemoryAdapter, V as MemoryContext, aU as SystemPromptSkillRef, M as McpServerConfig, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, c as Processor, S as SDKAgent } from './sdk-agent-CTOJlWA_.js';
1
+ import { W as MemoryFact, T as MemoryAdapter, V as MemoryContext, aW as SystemPromptSkillRef, M as McpServerConfig, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, c as Processor, S as SDKAgent } from './sdk-agent-CnwPODYH.js';
2
+ import { a as SessionStore } from './session-store-Dh07jr9N.js';
2
3
  import { M as ModelSelection, C as CustomTool, P as PermissionMode } from './agent-prims-CZyxfCmS.js';
3
4
 
4
- /**
5
- * Owner: `src/` (1 of 2 importers). Derived from the import graph, not
6
- * declared — `tests/lint/types-name-their-owner.test.ts` re-derives it.
7
- *
8
- * `SessionRecord` — the native on-disk transcript record shape (SE40).
9
- *
10
- * The theokit session format IS the Claude Code record shape: a
11
- * `uuid`/`parentUuid` DAG of records with structured
12
- * `text`/`tool_use`/`tool_result`/`thinking` blocks. This is the contract the
13
- * pluggable {@link SessionStore} seam operates over.
14
- *
15
- * DIP-correct home (SE46): the contract lives in the domain `types/` layer;
16
- * the application-layer DAG core (`internal/persistence/session-transcript.ts`)
17
- * re-exports it for back-compat while owning the record builders + reader.
18
- *
19
- * @public
20
- */
21
- /** A content block inside {@link TranscriptMessage}. */
22
- type TranscriptBlock = {
23
- type: "text";
24
- text: string;
25
- } | {
26
- type: "thinking";
27
- thinking?: string;
28
- signature?: string;
29
- } | {
30
- type: "tool_use";
31
- id: string;
32
- name: string;
33
- input: unknown;
34
- } | {
35
- type: "tool_result";
36
- tool_use_id: string;
37
- content: unknown;
38
- is_error?: boolean;
39
- };
40
- /**
41
- * The message body of a {@link SessionRecord}.
42
- *
43
- * **It is NOT called `SessionMessage`** — that name already exists in
44
- * `internal/session/session-types.ts` with the shape `{role, text}`, incompatible with this one.
45
- * Reusing an exported name for a new shape is
46
- * precisely the silent break M91 cost two patches to undo.
47
- *
48
- * Parsing from disk stays **tolerant** (`readTranscript` skips a malformed line): what changes here
49
- * is the **type**, not leniency — records written by earlier versions stay readable.
50
- *
51
- * @public
52
- */
53
- interface TranscriptMessage {
54
- role: "user" | "assistant";
55
- content: TranscriptBlock[];
56
- /**
57
- * The three fields below appear **only** on the assistant record, and come from the writer
58
- * (`SessionTranscript.appendAssistant`). Declared optional because the user record does not carry
59
- * them — measured in the writer itself, not assumed.
60
- */
61
- id?: string;
62
- type?: "message";
63
- model?: string;
64
- }
65
- /**
66
- * One transcript record — a single line of the session JSONL file, and the unit the pluggable
67
- * `SessionStore` seam reads and writes.
68
- *
69
- * Records form a `uuid`/`parentUuid` DAG, not a flat list: `parentUuid` names the preceding record
70
- * and is `null` at the root. Thread a session by following those links; a reader that assumes file
71
- * order is linear will mis-thread one that branched.
72
- *
73
- * `message` is absent on `system` records — a compaction boundary carries `compactMetadata` instead —
74
- * so it is optional even on records you would expect to be conversational, and `type` is what tells
75
- * you which you are holding.
76
- *
77
- * Reading is deliberately tolerant: a malformed line is skipped rather than failing the whole read.
78
- * Every record you receive is well-formed, but the file may have contained more than you got back,
79
- * so this is not the type to use for an exact-count audit of what was written.
80
- *
81
- * @public
82
- */
83
- interface SessionRecord {
84
- type: "user" | "assistant" | "system";
85
- uuid: string;
86
- parentUuid: string | null;
87
- sessionId: string;
88
- timestamp: string;
89
- isSidechain?: boolean;
90
- userType?: string;
91
- cwd?: string;
92
- version?: string;
93
- subtype?: string;
94
- compactMetadata?: {
95
- preTokens: number;
96
- trigger: string;
97
- };
98
- /**
99
- * The message body, in the shape the transcript writer actually writes.
100
- *
101
- * M94 — it was `Record<string, unknown>`, and the consumer recovered the type with a cast on every read.
102
- * The shape **has always been fixed** (`SessionTranscript.appendToolResults` / `#push` produce
103
- * it); it simply was not declared. It stays optional because system records carry no message.
104
- */
105
- message?: TranscriptMessage;
106
- }
107
-
108
- /**
109
- * Owner: `internal/session/` (4 of 8 importers). Derived from the import graph, not declared —
110
- * `tests/lint/types-name-their-owner.test.ts` re-derives it.
111
- *
112
- * SE41 — the pluggable `SessionStore` seam over the NATIVE session transcript.
113
- *
114
- * A minimal, two-method port so an external store (Postgres / Redis / KV /
115
- * durable object) can be the **primary store AND resume source** — the
116
- * serverless (ephemeral FS) and multi-host / multi-pod use case that SE40
117
- * dropped when it removed the `ConversationStorageAdapter`. This is deliberately
118
- * NOT that removed ~10-method adapter: the seam is JUST record read/append over
119
- * the native {@link SessionRecord} shape (no getMessages / getSessionMeta /
120
- * delete / objective methods).
121
- *
122
- * The SDK ships a real default implementation, `FsSessionStore`, that reads and
123
- * append-writes the native Claude-shaped `.jsonl` transcript — omitting
124
- * `local.sessionStore` yields byte-identical current behavior (back-compat, zero
125
- * consumer change). Injected via `local.sessionStore` for external stores.
126
- *
127
- * THIS SEAM DOES NOT HIDE THE STORAGE, AND IS NOT MEANT TO. A Repository
128
- * abstracts a persistence model away; this one is defined in terms of the
129
- * native one — the port speaks {@link SessionRecord}, "the exact SessionRecord
130
- * the SDK writes", and the on-disk layout's path helpers (`encodeProjectDir`,
131
- * `transcriptPath`, `transcriptRoot`) are published on purpose at
132
- * `@theokit/sdk/persistence` so a consumer can locate a transcript file.
133
- *
134
- * That is the whole design and the reason the seam is two methods rather than
135
- * ten: the format is the contract, and a store implements read/append over it.
136
- * A consumer supplying `local.sessionStore` is NOT bound by those paths — they
137
- * describe where the DEFAULT `FsSessionStore` puts files, not where an external
138
- * store must.
139
- *
140
- * Consistency contract: `appendRecords` is append-only and ordering-preserving.
141
- * The FS default serializes appends per agent with a cross-process file lock;
142
- * external implementations own (and MUST document) their own concurrency
143
- * guarantees for two hosts appending to the same `agentId`.
144
- *
145
- * @public
146
- */
147
-
148
- /**
149
- * The pluggable session-store seam. Exactly two methods over the native
150
- * {@link SessionRecord} shape.
151
- *
152
- * @public
153
- */
154
- interface SessionStore {
155
- /**
156
- * Return every persisted record for `agentId`, in append order. A session
157
- * that was never written MUST resolve to `[]` (not throw) — a fresh agent has
158
- * no history. The SDK reconstructs the resumable `LlmMessage[]` from these
159
- * records via the native DAG reader, so the shape MUST be the exact
160
- * {@link SessionRecord} the SDK writes.
161
- *
162
- * A store that cannot READ (e.g. the backing DB is unreachable on resume)
163
- * MUST throw a typed error rather than silently returning `[]` — a silent
164
- * empty read would masquerade as "no history" and drop the conversation.
165
- */
166
- readRecords(agentId: string): Promise<SessionRecord[]>;
167
- /**
168
- * Append `records` (the new-turn delta) to `agentId`'s session, append-only.
169
- * MUST preserve order and MUST NOT drop or rewrite prior records — the native
170
- * format is an append-only `parentUuid` DAG (compaction is a new-root
171
- * `compact_boundary` record, still an append).
172
- *
173
- * Note on the write path: per-turn persistence is fire-and-forget so `send()`
174
- * is never blocked by store I/O — an `appendRecords` rejection is logged to
175
- * stderr, NOT thrown to the caller (best-effort write). An external store that
176
- * must guarantee durability should make `appendRecords` resilient (retry /
177
- * durable write) internally. This differs from {@link SessionStore.readRecords},
178
- * which MUST throw on failure (a resume cannot proceed on a silent partial history).
179
- */
180
- appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void>;
181
- /**
182
- * Claim the single-writer lease for `agentId`, if this store has one. OPTIONAL.
183
- *
184
- * The SDK calls it when an agent starts and skips it when absent, so a two-method store keeps
185
- * working unchanged — declaring it here does not require it, which is the whole reason it is
186
- * optional. What declaring it DOES is make the capability discoverable: the SDK probed for this
187
- * method through an `as unknown` cast against an interface that never mentioned it, so a
188
- * third-party store author — the serverless / multi-pod case this port exists to serve — read a
189
- * two-method interface, implemented two methods, and never learned the hook was there.
190
- *
191
- * CONTRACT, and the half that matters: a rejection whose `name` is `"SessionBusyError"` PROPAGATES
192
- * to the caller, because another process holding the session is a decision the caller has to make
193
- * (`exec` forks to a new id). Any other rejection is treated as "no lease available here" —
194
- * logged, and the turn proceeds without single-writer protection, since the write is best-effort
195
- * by contract anyway.
196
- */
197
- acquire?(agentId: string): Promise<void>;
198
- /**
199
- * Release the lease `acquire` claimed, if this store has one. OPTIONAL.
200
- *
201
- * Called on agent disposal. A rejection is not handled specially.
202
- */
203
- release?(agentId: string): Promise<void>;
204
- /**
205
- * Release store-level resources — a connection pool, a file handle. OPTIONAL.
206
- *
207
- * Called once, on agent disposal, after {@link SessionStore.release}.
208
- */
209
- dispose?(): Promise<void>;
210
- }
211
-
212
5
  /**
213
6
  * A discovered skill's metadata. The skill BODY is never included — only the
214
7
  * strict frontmatter fields plus the resolved `source` path.
@@ -224,6 +17,8 @@ interface Skill$1 {
224
17
  source: string;
225
18
  category?: string;
226
19
  dependencies?: string[];
20
+ /** `requires-bins` — executables that must be on PATH for the model to be offered this skill. */
21
+ requiresBins?: string[];
227
22
  /** `disable-model-invocation: true` — the model is never told this skill exists. */
228
23
  disableModelInvocation?: boolean;
229
24
  /** `user-invocable: false` — carried for a host that has a picker; this SDK has no such surface. */
@@ -297,8 +92,12 @@ interface BudgetUsageEvent {
297
92
  readonly tokens: number;
298
93
  /** Provider/model identifier (e.g., `"openai/gpt-4o-mini"`). */
299
94
  readonly model: string;
300
- /** Whether this is an input (prompt) or output (completion) measurement. */
301
- readonly type: "input" | "output";
95
+ /**
96
+ * Whether this is an input (uncached prompt), output (completion), `cache_read` (prompt tokens
97
+ * served from the provider's cache) or `cache_write` (prompt tokens written to it) measurement.
98
+ * A tracker that has no separate rate for the cache types should treat them as input.
99
+ */
100
+ readonly type: "input" | "output" | "cache_read" | "cache_write";
302
101
  /** Optional ISO 8601 timestamp; defaults to now() if omitted. */
303
102
  readonly at?: string;
304
103
  }
@@ -1360,7 +1159,8 @@ type SystemPromptResolver = (ctx: SystemPromptContext) => string | Promise<strin
1360
1159
  */
1361
1160
  interface SkillsSettings {
1362
1161
  /**
1363
- * Names of skills the parent agent may invoke. When omitted, every
1162
+ * Names of skills the local runtime loads: a skill not named here cannot be listed or read.
1163
+ * When omitted, every
1364
1164
  * discovered skill is enabled.
1365
1165
  */
1366
1166
  enabled?: string[];
@@ -1377,6 +1177,12 @@ interface SkillsSettings {
1377
1177
  * default `<cwd>/.theokit/skills`. Absent ⇒ the default root.
1378
1178
  */
1379
1179
  skillsDir?: string;
1180
+ /**
1181
+ * B-546 — directories (each containing `<name>/SKILL.md`) an application ships inside its own
1182
+ * package. They are read AFTER the project roots and plugin bundles, so a workspace skill of the
1183
+ * same name always wins, and they are kept even when `skillsDir` replaces the default roots.
1184
+ */
1185
+ bundledDirs?: string[];
1380
1186
  /**
1381
1187
  * M22 — code-defined skills (from `createSkill`) merged with the discovered ones. An inline skill
1382
1188
  * overrides a discovered file skill of the same name.
@@ -1770,6 +1576,18 @@ interface AgentOptions {
1770
1576
  conversationId: string;
1771
1577
  userId?: string;
1772
1578
  }) => Promise<void> | void;
1579
+ /**
1580
+ * Start a fresh conversation when the agent has been idle this many minutes.
1581
+ *
1582
+ * Checked at the start of a local `send`: when more than this long has passed since the previous
1583
+ * `send` on the same agent began, the in-memory conversation is cleared first, so the model
1584
+ * receives no prior messages and `onBeforeSend` reports `previousMessageCount: 0`. Absent (the
1585
+ * default), or not a positive finite number, never resets. The first send of a process has no
1586
+ * previous send, so it never resets. The on-disk transcript is not deleted.
1587
+ *
1588
+ * @public
1589
+ */
1590
+ sessionIdleResetMinutes?: number;
1773
1591
  /**
1774
1592
  * Fires before each `agent.send`. `previousMessageCount` is the count of
1775
1593
  * messages already persisted BEFORE the current send adds the user
@@ -2062,4 +1880,4 @@ interface ListResult<T> {
2062
1880
  nextCursor?: string;
2063
1881
  }
2064
1882
 
2065
- export { type RecordSessionSummaryArgs as $, type AgentOptions as A, type BuiltinToolName as B, type CloudOptions as C, type CreateSkillSpec as D, type HookApprovalRequest as E, type HookName as F, type GetAgentOptions as G, type HookApprovalGate as H, type InlineSkill as I, type LlmCallContext as J, type MemoryProviderAgentRef as K, type LocalOptions as L, type MemorySettings as M, type MemoryProviderFactory as N, type MemoryProviderHandle as O, type Plugin as P, type MemoryProviderInitOptions as Q, type PluginContext as R, type SystemPromptResolver as S, type PluginHookDisposer as T, type PostAssistantReplyContext as U, type PostToolCallContext as V, type PreToolCallContext as W, type PreUserSendContext as X, type PreUserSendResult as Y, type ProviderTransform as Z, type ProviderTransformContext as _, type AgentDefinition as a, type SessionLifecycleContext as a0, type SessionRecord as a1, type SessionStore as a2, type SettingSource as a3, Skill as a4, type SkillsResolver as a5, type SkillsResolverContext as a6, type SystemPromptContext as a7, type SystemPromptMemoryFact as a8, type TelemetrySettings as a9, type ToolCallSummary as aa, type ToolContext as ab, type ToolResultTransformContext as ac, type TransformContext as ad, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type Skill$1 as k, type BudgetTracker as l, type MemoryProvider as m, type PreToolCallDecision as n, type ActiveMemoryPassArgs as o, type ActiveMemoryPassResult as p, type AgentSubagentDescription as q, type AgentToolDescription as r, type BudgetCheck as s, type BudgetTotal as t, type BudgetUsageEvent as u, type CloudEnv as v, type CloudRepo as w, type CompatSource as x, type CompatSourceAdapter as y, type CompatSurface as z };
1883
+ export { type RecordSessionSummaryArgs as $, type AgentOptions as A, type BuiltinToolName as B, type CloudOptions as C, type CreateSkillSpec as D, type HookApprovalRequest as E, type HookName as F, type GetAgentOptions as G, type HookApprovalGate as H, type InlineSkill as I, type LlmCallContext as J, type MemoryProviderAgentRef as K, type LocalOptions as L, type MemorySettings as M, type MemoryProviderFactory as N, type MemoryProviderHandle as O, type Plugin as P, type MemoryProviderInitOptions as Q, type PluginContext as R, type SystemPromptResolver as S, type PluginHookDisposer as T, type PostAssistantReplyContext as U, type PostToolCallContext as V, type PreToolCallContext as W, type PreUserSendContext as X, type PreUserSendResult as Y, type ProviderTransform as Z, type ProviderTransformContext as _, type AgentDefinition as a, type SessionLifecycleContext as a0, type SettingSource as a1, Skill as a2, type SkillsResolver as a3, type SkillsResolverContext as a4, type SystemPromptContext as a5, type SystemPromptMemoryFact as a6, type TelemetrySettings as a7, type ToolCallSummary as a8, type ToolContext as a9, type ToolResultTransformContext as aa, type TransformContext as ab, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type Skill$1 as k, type BudgetTracker as l, type MemoryProvider as m, type PreToolCallDecision as n, type ActiveMemoryPassArgs as o, type ActiveMemoryPassResult as p, type AgentSubagentDescription as q, type AgentToolDescription as r, type BudgetCheck as s, type BudgetTotal as t, type BudgetUsageEvent as u, type CloudEnv as v, type CloudRepo as w, type CompatSource as x, type CompatSourceAdapter as y, type CompatSurface as z };
@@ -1,214 +1,7 @@
1
- import { W as MemoryFact, T as MemoryAdapter, V as MemoryContext, aU as SystemPromptSkillRef, M as McpServerConfig, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, c as Processor, S as SDKAgent } from './sdk-agent-4-dXI2GS.cjs';
1
+ import { W as MemoryFact, T as MemoryAdapter, V as MemoryContext, aW as SystemPromptSkillRef, M as McpServerConfig, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, c as Processor, S as SDKAgent } from './sdk-agent-BA_6_wtc.cjs';
2
+ import { a as SessionStore } from './session-store-Dh07jr9N.cjs';
2
3
  import { M as ModelSelection, C as CustomTool, P as PermissionMode } from './agent-prims-CZyxfCmS.cjs';
3
4
 
4
- /**
5
- * Owner: `src/` (1 of 2 importers). Derived from the import graph, not
6
- * declared — `tests/lint/types-name-their-owner.test.ts` re-derives it.
7
- *
8
- * `SessionRecord` — the native on-disk transcript record shape (SE40).
9
- *
10
- * The theokit session format IS the Claude Code record shape: a
11
- * `uuid`/`parentUuid` DAG of records with structured
12
- * `text`/`tool_use`/`tool_result`/`thinking` blocks. This is the contract the
13
- * pluggable {@link SessionStore} seam operates over.
14
- *
15
- * DIP-correct home (SE46): the contract lives in the domain `types/` layer;
16
- * the application-layer DAG core (`internal/persistence/session-transcript.ts`)
17
- * re-exports it for back-compat while owning the record builders + reader.
18
- *
19
- * @public
20
- */
21
- /** A content block inside {@link TranscriptMessage}. */
22
- type TranscriptBlock = {
23
- type: "text";
24
- text: string;
25
- } | {
26
- type: "thinking";
27
- thinking?: string;
28
- signature?: string;
29
- } | {
30
- type: "tool_use";
31
- id: string;
32
- name: string;
33
- input: unknown;
34
- } | {
35
- type: "tool_result";
36
- tool_use_id: string;
37
- content: unknown;
38
- is_error?: boolean;
39
- };
40
- /**
41
- * The message body of a {@link SessionRecord}.
42
- *
43
- * **It is NOT called `SessionMessage`** — that name already exists in
44
- * `internal/session/session-types.ts` with the shape `{role, text}`, incompatible with this one.
45
- * Reusing an exported name for a new shape is
46
- * precisely the silent break M91 cost two patches to undo.
47
- *
48
- * Parsing from disk stays **tolerant** (`readTranscript` skips a malformed line): what changes here
49
- * is the **type**, not leniency — records written by earlier versions stay readable.
50
- *
51
- * @public
52
- */
53
- interface TranscriptMessage {
54
- role: "user" | "assistant";
55
- content: TranscriptBlock[];
56
- /**
57
- * The three fields below appear **only** on the assistant record, and come from the writer
58
- * (`SessionTranscript.appendAssistant`). Declared optional because the user record does not carry
59
- * them — measured in the writer itself, not assumed.
60
- */
61
- id?: string;
62
- type?: "message";
63
- model?: string;
64
- }
65
- /**
66
- * One transcript record — a single line of the session JSONL file, and the unit the pluggable
67
- * `SessionStore` seam reads and writes.
68
- *
69
- * Records form a `uuid`/`parentUuid` DAG, not a flat list: `parentUuid` names the preceding record
70
- * and is `null` at the root. Thread a session by following those links; a reader that assumes file
71
- * order is linear will mis-thread one that branched.
72
- *
73
- * `message` is absent on `system` records — a compaction boundary carries `compactMetadata` instead —
74
- * so it is optional even on records you would expect to be conversational, and `type` is what tells
75
- * you which you are holding.
76
- *
77
- * Reading is deliberately tolerant: a malformed line is skipped rather than failing the whole read.
78
- * Every record you receive is well-formed, but the file may have contained more than you got back,
79
- * so this is not the type to use for an exact-count audit of what was written.
80
- *
81
- * @public
82
- */
83
- interface SessionRecord {
84
- type: "user" | "assistant" | "system";
85
- uuid: string;
86
- parentUuid: string | null;
87
- sessionId: string;
88
- timestamp: string;
89
- isSidechain?: boolean;
90
- userType?: string;
91
- cwd?: string;
92
- version?: string;
93
- subtype?: string;
94
- compactMetadata?: {
95
- preTokens: number;
96
- trigger: string;
97
- };
98
- /**
99
- * The message body, in the shape the transcript writer actually writes.
100
- *
101
- * M94 — it was `Record<string, unknown>`, and the consumer recovered the type with a cast on every read.
102
- * The shape **has always been fixed** (`SessionTranscript.appendToolResults` / `#push` produce
103
- * it); it simply was not declared. It stays optional because system records carry no message.
104
- */
105
- message?: TranscriptMessage;
106
- }
107
-
108
- /**
109
- * Owner: `internal/session/` (4 of 8 importers). Derived from the import graph, not declared —
110
- * `tests/lint/types-name-their-owner.test.ts` re-derives it.
111
- *
112
- * SE41 — the pluggable `SessionStore` seam over the NATIVE session transcript.
113
- *
114
- * A minimal, two-method port so an external store (Postgres / Redis / KV /
115
- * durable object) can be the **primary store AND resume source** — the
116
- * serverless (ephemeral FS) and multi-host / multi-pod use case that SE40
117
- * dropped when it removed the `ConversationStorageAdapter`. This is deliberately
118
- * NOT that removed ~10-method adapter: the seam is JUST record read/append over
119
- * the native {@link SessionRecord} shape (no getMessages / getSessionMeta /
120
- * delete / objective methods).
121
- *
122
- * The SDK ships a real default implementation, `FsSessionStore`, that reads and
123
- * append-writes the native Claude-shaped `.jsonl` transcript — omitting
124
- * `local.sessionStore` yields byte-identical current behavior (back-compat, zero
125
- * consumer change). Injected via `local.sessionStore` for external stores.
126
- *
127
- * THIS SEAM DOES NOT HIDE THE STORAGE, AND IS NOT MEANT TO. A Repository
128
- * abstracts a persistence model away; this one is defined in terms of the
129
- * native one — the port speaks {@link SessionRecord}, "the exact SessionRecord
130
- * the SDK writes", and the on-disk layout's path helpers (`encodeProjectDir`,
131
- * `transcriptPath`, `transcriptRoot`) are published on purpose at
132
- * `@theokit/sdk/persistence` so a consumer can locate a transcript file.
133
- *
134
- * That is the whole design and the reason the seam is two methods rather than
135
- * ten: the format is the contract, and a store implements read/append over it.
136
- * A consumer supplying `local.sessionStore` is NOT bound by those paths — they
137
- * describe where the DEFAULT `FsSessionStore` puts files, not where an external
138
- * store must.
139
- *
140
- * Consistency contract: `appendRecords` is append-only and ordering-preserving.
141
- * The FS default serializes appends per agent with a cross-process file lock;
142
- * external implementations own (and MUST document) their own concurrency
143
- * guarantees for two hosts appending to the same `agentId`.
144
- *
145
- * @public
146
- */
147
-
148
- /**
149
- * The pluggable session-store seam. Exactly two methods over the native
150
- * {@link SessionRecord} shape.
151
- *
152
- * @public
153
- */
154
- interface SessionStore {
155
- /**
156
- * Return every persisted record for `agentId`, in append order. A session
157
- * that was never written MUST resolve to `[]` (not throw) — a fresh agent has
158
- * no history. The SDK reconstructs the resumable `LlmMessage[]` from these
159
- * records via the native DAG reader, so the shape MUST be the exact
160
- * {@link SessionRecord} the SDK writes.
161
- *
162
- * A store that cannot READ (e.g. the backing DB is unreachable on resume)
163
- * MUST throw a typed error rather than silently returning `[]` — a silent
164
- * empty read would masquerade as "no history" and drop the conversation.
165
- */
166
- readRecords(agentId: string): Promise<SessionRecord[]>;
167
- /**
168
- * Append `records` (the new-turn delta) to `agentId`'s session, append-only.
169
- * MUST preserve order and MUST NOT drop or rewrite prior records — the native
170
- * format is an append-only `parentUuid` DAG (compaction is a new-root
171
- * `compact_boundary` record, still an append).
172
- *
173
- * Note on the write path: per-turn persistence is fire-and-forget so `send()`
174
- * is never blocked by store I/O — an `appendRecords` rejection is logged to
175
- * stderr, NOT thrown to the caller (best-effort write). An external store that
176
- * must guarantee durability should make `appendRecords` resilient (retry /
177
- * durable write) internally. This differs from {@link SessionStore.readRecords},
178
- * which MUST throw on failure (a resume cannot proceed on a silent partial history).
179
- */
180
- appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void>;
181
- /**
182
- * Claim the single-writer lease for `agentId`, if this store has one. OPTIONAL.
183
- *
184
- * The SDK calls it when an agent starts and skips it when absent, so a two-method store keeps
185
- * working unchanged — declaring it here does not require it, which is the whole reason it is
186
- * optional. What declaring it DOES is make the capability discoverable: the SDK probed for this
187
- * method through an `as unknown` cast against an interface that never mentioned it, so a
188
- * third-party store author — the serverless / multi-pod case this port exists to serve — read a
189
- * two-method interface, implemented two methods, and never learned the hook was there.
190
- *
191
- * CONTRACT, and the half that matters: a rejection whose `name` is `"SessionBusyError"` PROPAGATES
192
- * to the caller, because another process holding the session is a decision the caller has to make
193
- * (`exec` forks to a new id). Any other rejection is treated as "no lease available here" —
194
- * logged, and the turn proceeds without single-writer protection, since the write is best-effort
195
- * by contract anyway.
196
- */
197
- acquire?(agentId: string): Promise<void>;
198
- /**
199
- * Release the lease `acquire` claimed, if this store has one. OPTIONAL.
200
- *
201
- * Called on agent disposal. A rejection is not handled specially.
202
- */
203
- release?(agentId: string): Promise<void>;
204
- /**
205
- * Release store-level resources — a connection pool, a file handle. OPTIONAL.
206
- *
207
- * Called once, on agent disposal, after {@link SessionStore.release}.
208
- */
209
- dispose?(): Promise<void>;
210
- }
211
-
212
5
  /**
213
6
  * A discovered skill's metadata. The skill BODY is never included — only the
214
7
  * strict frontmatter fields plus the resolved `source` path.
@@ -224,6 +17,8 @@ interface Skill$1 {
224
17
  source: string;
225
18
  category?: string;
226
19
  dependencies?: string[];
20
+ /** `requires-bins` — executables that must be on PATH for the model to be offered this skill. */
21
+ requiresBins?: string[];
227
22
  /** `disable-model-invocation: true` — the model is never told this skill exists. */
228
23
  disableModelInvocation?: boolean;
229
24
  /** `user-invocable: false` — carried for a host that has a picker; this SDK has no such surface. */
@@ -297,8 +92,12 @@ interface BudgetUsageEvent {
297
92
  readonly tokens: number;
298
93
  /** Provider/model identifier (e.g., `"openai/gpt-4o-mini"`). */
299
94
  readonly model: string;
300
- /** Whether this is an input (prompt) or output (completion) measurement. */
301
- readonly type: "input" | "output";
95
+ /**
96
+ * Whether this is an input (uncached prompt), output (completion), `cache_read` (prompt tokens
97
+ * served from the provider's cache) or `cache_write` (prompt tokens written to it) measurement.
98
+ * A tracker that has no separate rate for the cache types should treat them as input.
99
+ */
100
+ readonly type: "input" | "output" | "cache_read" | "cache_write";
302
101
  /** Optional ISO 8601 timestamp; defaults to now() if omitted. */
303
102
  readonly at?: string;
304
103
  }
@@ -1360,7 +1159,8 @@ type SystemPromptResolver = (ctx: SystemPromptContext) => string | Promise<strin
1360
1159
  */
1361
1160
  interface SkillsSettings {
1362
1161
  /**
1363
- * Names of skills the parent agent may invoke. When omitted, every
1162
+ * Names of skills the local runtime loads: a skill not named here cannot be listed or read.
1163
+ * When omitted, every
1364
1164
  * discovered skill is enabled.
1365
1165
  */
1366
1166
  enabled?: string[];
@@ -1377,6 +1177,12 @@ interface SkillsSettings {
1377
1177
  * default `<cwd>/.theokit/skills`. Absent ⇒ the default root.
1378
1178
  */
1379
1179
  skillsDir?: string;
1180
+ /**
1181
+ * B-546 — directories (each containing `<name>/SKILL.md`) an application ships inside its own
1182
+ * package. They are read AFTER the project roots and plugin bundles, so a workspace skill of the
1183
+ * same name always wins, and they are kept even when `skillsDir` replaces the default roots.
1184
+ */
1185
+ bundledDirs?: string[];
1380
1186
  /**
1381
1187
  * M22 — code-defined skills (from `createSkill`) merged with the discovered ones. An inline skill
1382
1188
  * overrides a discovered file skill of the same name.
@@ -1770,6 +1576,18 @@ interface AgentOptions {
1770
1576
  conversationId: string;
1771
1577
  userId?: string;
1772
1578
  }) => Promise<void> | void;
1579
+ /**
1580
+ * Start a fresh conversation when the agent has been idle this many minutes.
1581
+ *
1582
+ * Checked at the start of a local `send`: when more than this long has passed since the previous
1583
+ * `send` on the same agent began, the in-memory conversation is cleared first, so the model
1584
+ * receives no prior messages and `onBeforeSend` reports `previousMessageCount: 0`. Absent (the
1585
+ * default), or not a positive finite number, never resets. The first send of a process has no
1586
+ * previous send, so it never resets. The on-disk transcript is not deleted.
1587
+ *
1588
+ * @public
1589
+ */
1590
+ sessionIdleResetMinutes?: number;
1773
1591
  /**
1774
1592
  * Fires before each `agent.send`. `previousMessageCount` is the count of
1775
1593
  * messages already persisted BEFORE the current send adds the user
@@ -2062,4 +1880,4 @@ interface ListResult<T> {
2062
1880
  nextCursor?: string;
2063
1881
  }
2064
1882
 
2065
- export { type RecordSessionSummaryArgs as $, type AgentOptions as A, type BuiltinToolName as B, type CloudOptions as C, type CreateSkillSpec as D, type HookApprovalRequest as E, type HookName as F, type GetAgentOptions as G, type HookApprovalGate as H, type InlineSkill as I, type LlmCallContext as J, type MemoryProviderAgentRef as K, type LocalOptions as L, type MemorySettings as M, type MemoryProviderFactory as N, type MemoryProviderHandle as O, type Plugin as P, type MemoryProviderInitOptions as Q, type PluginContext as R, type SystemPromptResolver as S, type PluginHookDisposer as T, type PostAssistantReplyContext as U, type PostToolCallContext as V, type PreToolCallContext as W, type PreUserSendContext as X, type PreUserSendResult as Y, type ProviderTransform as Z, type ProviderTransformContext as _, type AgentDefinition as a, type SessionLifecycleContext as a0, type SessionRecord as a1, type SessionStore as a2, type SettingSource as a3, Skill as a4, type SkillsResolver as a5, type SkillsResolverContext as a6, type SystemPromptContext as a7, type SystemPromptMemoryFact as a8, type TelemetrySettings as a9, type ToolCallSummary as aa, type ToolContext as ab, type ToolResultTransformContext as ac, type TransformContext as ad, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type Skill$1 as k, type BudgetTracker as l, type MemoryProvider as m, type PreToolCallDecision as n, type ActiveMemoryPassArgs as o, type ActiveMemoryPassResult as p, type AgentSubagentDescription as q, type AgentToolDescription as r, type BudgetCheck as s, type BudgetTotal as t, type BudgetUsageEvent as u, type CloudEnv as v, type CloudRepo as w, type CompatSource as x, type CompatSourceAdapter as y, type CompatSurface as z };
1883
+ export { type RecordSessionSummaryArgs as $, type AgentOptions as A, type BuiltinToolName as B, type CloudOptions as C, type CreateSkillSpec as D, type HookApprovalRequest as E, type HookName as F, type GetAgentOptions as G, type HookApprovalGate as H, type InlineSkill as I, type LlmCallContext as J, type MemoryProviderAgentRef as K, type LocalOptions as L, type MemorySettings as M, type MemoryProviderFactory as N, type MemoryProviderHandle as O, type Plugin as P, type MemoryProviderInitOptions as Q, type PluginContext as R, type SystemPromptResolver as S, type PluginHookDisposer as T, type PostAssistantReplyContext as U, type PostToolCallContext as V, type PreToolCallContext as W, type PreUserSendContext as X, type PreUserSendResult as Y, type ProviderTransform as Z, type ProviderTransformContext as _, type AgentDefinition as a, type SessionLifecycleContext as a0, type SettingSource as a1, Skill as a2, type SkillsResolver as a3, type SkillsResolverContext as a4, type SystemPromptContext as a5, type SystemPromptMemoryFact as a6, type TelemetrySettings as a7, type ToolCallSummary as a8, type ToolContext as a9, type ToolResultTransformContext as aa, type TransformContext as ab, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type Skill$1 as k, type BudgetTracker as l, type MemoryProvider as m, type PreToolCallDecision as n, type ActiveMemoryPassArgs as o, type ActiveMemoryPassResult as p, type AgentSubagentDescription as q, type AgentToolDescription as r, type BudgetCheck as s, type BudgetTotal as t, type BudgetUsageEvent as u, type CloudEnv as v, type CloudRepo as w, type CompatSource as x, type CompatSourceAdapter as y, type CompatSurface as z };