@theokit/sdk 1.6.1 → 1.7.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 (351) hide show
  1. package/CHANGELOG.md +187 -0
  2. package/dist/a2a/agent-mailbox.d.cts +27 -0
  3. package/dist/a2a/agent-mailbox.d.ts +27 -0
  4. package/dist/a2a/index.cjs +16850 -0
  5. package/dist/a2a/index.cjs.map +1 -0
  6. package/dist/a2a/index.d.cts +9 -0
  7. package/dist/a2a/index.d.ts +9 -0
  8. package/dist/a2a/index.js +16844 -0
  9. package/dist/a2a/index.js.map +1 -0
  10. package/dist/a2a/message-bus.d.cts +27 -0
  11. package/dist/a2a/message-bus.d.ts +27 -0
  12. package/dist/a2a/subagent.d.cts +25 -0
  13. package/dist/a2a/subagent.d.ts +25 -0
  14. package/dist/a2a/types.d.cts +12 -0
  15. package/dist/a2a/types.d.ts +12 -0
  16. package/dist/agent.d.ts +1 -1
  17. package/dist/client/index.cjs +73 -0
  18. package/dist/client/index.cjs.map +1 -0
  19. package/dist/client/index.d.cts +7 -0
  20. package/dist/client/index.d.ts +7 -0
  21. package/dist/client/index.js +71 -0
  22. package/dist/client/index.js.map +1 -0
  23. package/dist/client/theokit-client.d.cts +18 -0
  24. package/dist/client/theokit-client.d.ts +18 -0
  25. package/dist/client/types.d.cts +19 -0
  26. package/dist/client/types.d.ts +19 -0
  27. package/dist/{run-DkCD5DeO.d.cts → cron-BnywDYLq.d.cts} +496 -910
  28. package/dist/{run-DkCD5DeO.d.ts → cron-CtZvJD9J.d.ts} +496 -910
  29. package/dist/cron.cjs +4285 -2893
  30. package/dist/cron.cjs.map +1 -1
  31. package/dist/cron.d.cts +2 -3
  32. package/dist/cron.d.ts +2 -71
  33. package/dist/cron.js +4289 -2897
  34. package/dist/cron.js.map +1 -1
  35. package/dist/{errors-CvAeEWgE.d.ts → errors-ChqOmFH1.d.cts} +52 -6
  36. package/dist/{errors-CK8brCJ1.d.cts → errors-DV9e0rcp.d.ts} +52 -6
  37. package/dist/errors.cjs +218 -3
  38. package/dist/errors.cjs.map +1 -1
  39. package/dist/errors.d.cts +2 -3
  40. package/dist/errors.d.ts +50 -4
  41. package/dist/errors.js +217 -4
  42. package/dist/errors.js.map +1 -1
  43. package/dist/eval.cjs +4285 -2893
  44. package/dist/eval.cjs.map +1 -1
  45. package/dist/eval.d.cts +35 -0
  46. package/dist/eval.js +4289 -2897
  47. package/dist/eval.js.map +1 -1
  48. package/dist/event-bus.d.ts +23 -0
  49. package/dist/index.cjs +5132 -4200
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +298 -278
  52. package/dist/index.d.ts +1898 -24
  53. package/dist/index.js +6441 -5509
  54. package/dist/index.js.map +1 -1
  55. package/dist/internal/agent-loop/loop-context-init.d.ts +2 -0
  56. package/dist/internal/agent-loop/tool-dispatch.d.ts +22 -1
  57. package/dist/internal/auth/api-key-validator.d.ts +46 -0
  58. package/dist/internal/llm/anthropic-shared.d.ts +8 -1
  59. package/dist/internal/llm/retry.d.ts +22 -0
  60. package/dist/internal/llm/types.d.ts +47 -1
  61. package/dist/internal/memory/active-memory-cache.d.ts +3 -3
  62. package/dist/internal/memory/active-memory-types.d.ts +8 -0
  63. package/dist/internal/memory/active-memory.d.ts +24 -20
  64. package/dist/internal/memory/adapters/azure-openai-embedding.d.ts +2 -0
  65. package/dist/internal/memory/adapters/cohere-embedding.d.ts +2 -0
  66. package/dist/internal/memory/adapters/gemini-embedding.d.ts +2 -0
  67. package/dist/internal/memory/adapters/jina-embedding.d.ts +2 -0
  68. package/dist/internal/memory/index-manager-contract.d.ts +26 -0
  69. package/dist/internal/memory/index-manager-dispatch.d.ts +1 -1
  70. package/dist/internal/memory/index-manager.d.ts +8 -26
  71. package/dist/internal/memory/{chunk-markdown.d.ts → storage/chunk-markdown.d.ts} +1 -1
  72. package/dist/internal/memory/{markdown-store.d.ts → storage/markdown-store.d.ts} +1 -1
  73. package/dist/internal/memory/{reader.d.ts → storage/reader.d.ts} +1 -1
  74. package/dist/internal/observability/context.d.cts +23 -0
  75. package/dist/internal/observability/context.d.ts +23 -0
  76. package/dist/internal/observability/index.cjs +38 -0
  77. package/dist/internal/observability/index.cjs.map +1 -0
  78. package/dist/internal/observability/index.d.cts +8 -0
  79. package/dist/internal/observability/index.d.ts +8 -0
  80. package/dist/internal/observability/index.js +33 -0
  81. package/dist/internal/observability/index.js.map +1 -0
  82. package/dist/internal/observability/tracer-loader.d.cts +20 -0
  83. package/dist/internal/persistence/conversation-storage-fs.d.cts +37 -0
  84. package/dist/internal/persistence/conversation-storage-memory.d.cts +24 -0
  85. package/dist/internal/persistence/credential-pool-store.d.cts +32 -0
  86. package/dist/internal/persistence/credential-pool-store.d.ts +32 -0
  87. package/dist/internal/persistence/cwd-mutex.d.cts +1 -0
  88. package/dist/internal/persistence/exclusive-create.d.cts +22 -0
  89. package/dist/internal/persistence/exclusive-create.d.ts +22 -0
  90. package/dist/internal/persistence/file-lock.d.cts +14 -0
  91. package/dist/internal/persistence/fts5-sanitize.d.cts +16 -0
  92. package/dist/internal/persistence/index.cjs +359 -0
  93. package/dist/internal/persistence/index.cjs.map +1 -0
  94. package/dist/internal/persistence/index.d.cts +20 -0
  95. package/dist/internal/persistence/index.d.ts +20 -0
  96. package/dist/internal/persistence/index.js +341 -0
  97. package/dist/internal/persistence/index.js.map +1 -0
  98. package/dist/internal/persistence/markdown-config-loader.d.cts +35 -0
  99. package/dist/internal/persistence/paths.d.cts +19 -0
  100. package/dist/internal/persistence/persistence-schema.d.cts +21 -0
  101. package/dist/internal/persistence/persistence-schema.d.ts +4 -0
  102. package/dist/internal/persistence/schema-version.d.cts +13 -0
  103. package/dist/internal/persistence/sqlite-cas.d.cts +25 -0
  104. package/dist/internal/persistence/sqlite-cas.d.ts +25 -0
  105. package/dist/internal/persistence/sqlite-wal.d.cts +10 -0
  106. package/dist/internal/plugins/context.d.cts +31 -0
  107. package/dist/internal/plugins/index.cjs +228 -0
  108. package/dist/internal/plugins/index.cjs.map +1 -0
  109. package/dist/internal/plugins/index.d.cts +8 -0
  110. package/dist/internal/plugins/index.d.ts +8 -0
  111. package/dist/internal/plugins/index.js +222 -0
  112. package/dist/internal/plugins/index.js.map +1 -0
  113. package/dist/internal/plugins/lifecycle.d.cts +14 -0
  114. package/dist/internal/plugins/lifecycle.d.ts +14 -0
  115. package/dist/internal/plugins/manager.d.cts +37 -0
  116. package/dist/internal/plugins/types.d.cts +102 -0
  117. package/dist/internal/providers/catalog-loader.d.ts +39 -0
  118. package/dist/internal/runtime/agent-session-store.d.ts +1 -1
  119. package/dist/internal/runtime/agent-session.d.ts +1 -0
  120. package/dist/internal/runtime/budget-tracker.d.ts +73 -0
  121. package/dist/internal/runtime/{context-manager.d.ts → context/context-manager.d.ts} +1 -1
  122. package/dist/internal/runtime/{fixture-events.d.ts → fixtures/fixture-events.d.ts} +1 -1
  123. package/dist/internal/runtime/{fixture-run-base.d.ts → fixtures/fixture-run-base.d.ts} +4 -4
  124. package/dist/internal/runtime/{fixture-scripts.d.ts → fixtures/fixture-scripts.d.ts} +1 -1
  125. package/dist/internal/runtime/local-agent-bootstrap.d.ts +2 -2
  126. package/dist/internal/runtime/local-agent-memory-provider.d.ts +57 -0
  127. package/dist/internal/runtime/memory-path-selector.d.ts +73 -0
  128. package/dist/internal/runtime/memory-provider.d.ts +165 -0
  129. package/dist/internal/runtime/{agent-registry.d.ts → registry/agent-registry-contract.d.ts} +15 -9
  130. package/dist/internal/runtime/registry/agent-registry.d.ts +7 -0
  131. package/dist/internal/runtime/{live-agent-registry.d.ts → registry/live-agent-registry.d.ts} +1 -1
  132. package/dist/internal/runtime/{run-registry.d.ts → registry/run-registry.d.ts} +1 -1
  133. package/dist/internal/runtime/session-types.d.ts +35 -0
  134. package/dist/internal/runtime/system-prompt/sources/skills-provider.d.ts +1 -0
  135. package/dist/internal/runtime/validate-response.d.ts +18 -0
  136. package/dist/internal/security/index.cjs +361 -0
  137. package/dist/internal/security/index.cjs.map +1 -0
  138. package/dist/internal/security/index.d.cts +11 -0
  139. package/dist/internal/security/index.js +350 -0
  140. package/dist/internal/security/index.js.map +1 -0
  141. package/dist/internal/security/path-guard.d.cts +59 -0
  142. package/dist/internal/security/path-guard.d.ts +3 -0
  143. package/dist/internal/security/redact.d.cts +21 -0
  144. package/dist/internal/security/secret-redactor.d.cts +1 -0
  145. package/dist/internal/security/secret-redactor.d.ts +1 -0
  146. package/dist/internal/security/test-reset.d.cts +10 -0
  147. package/dist/internal/security/test-reset.d.ts +10 -0
  148. package/dist/internal/telemetry/adapters/arize.d.ts +2 -0
  149. package/dist/internal/telemetry/adapters/braintrust.d.ts +2 -0
  150. package/dist/internal/telemetry/adapters/datadog.d.ts +2 -0
  151. package/dist/internal/telemetry/adapters/langsmith.d.ts +2 -0
  152. package/dist/internal/telemetry/span-names.d.ts +6 -0
  153. package/dist/internal/telemetry/tracer.d.ts +1 -0
  154. package/dist/internal/workflow/evented-executor.d.ts +42 -0
  155. package/dist/internal/workflow/scheduler.d.ts +23 -0
  156. package/dist/internal/zod/to-json-schema.d.ts +5 -15
  157. package/dist/job-queue.d.ts +28 -0
  158. package/dist/path-safety.cjs +67 -6
  159. package/dist/path-safety.cjs.map +1 -1
  160. package/dist/path-safety.d.cts +15 -0
  161. package/dist/path-safety.d.ts +1 -1
  162. package/dist/path-safety.js +67 -7
  163. package/dist/path-safety.js.map +1 -1
  164. package/dist/permission-engine.d.ts +21 -0
  165. package/dist/provider-catalog.json +702 -0
  166. package/dist/rag/index.cjs +136 -0
  167. package/dist/rag/index.cjs.map +1 -0
  168. package/dist/rag/index.d.cts +11 -0
  169. package/dist/rag/index.d.ts +11 -0
  170. package/dist/rag/index.js +129 -0
  171. package/dist/rag/index.js.map +1 -0
  172. package/dist/rag/reranker.d.cts +26 -0
  173. package/dist/rag/reranker.d.ts +26 -0
  174. package/dist/rag/retriever.d.cts +25 -0
  175. package/dist/rag/retriever.d.ts +25 -0
  176. package/dist/rag/text-splitter.d.cts +12 -0
  177. package/dist/rag/text-splitter.d.ts +12 -0
  178. package/dist/rag/types.d.cts +37 -0
  179. package/dist/rag/types.d.ts +37 -0
  180. package/dist/run-DrwUpFxZ.d.cts +823 -0
  181. package/dist/run-DrwUpFxZ.d.ts +823 -0
  182. package/dist/sandbox/index.cjs +133 -0
  183. package/dist/sandbox/index.cjs.map +1 -0
  184. package/dist/sandbox/index.d.cts +2 -0
  185. package/dist/sandbox/index.d.ts +2 -0
  186. package/dist/sandbox/index.js +128 -0
  187. package/dist/sandbox/index.js.map +1 -0
  188. package/dist/sandbox/local-sandbox.d.cts +17 -0
  189. package/dist/sandbox/local-sandbox.d.ts +17 -0
  190. package/dist/sandbox/types.d.cts +44 -0
  191. package/dist/sandbox/types.d.ts +44 -0
  192. package/dist/server/adapter/express.d.cts +9 -0
  193. package/dist/server/adapter/express.d.ts +9 -0
  194. package/dist/server/adapter/fastify.d.cts +9 -0
  195. package/dist/server/adapter/fastify.d.ts +9 -0
  196. package/dist/server/adapter/hono.d.cts +9 -0
  197. package/dist/server/adapter/hono.d.ts +9 -0
  198. package/dist/server/adapter/index.d.cts +8 -0
  199. package/dist/server/adapter/index.d.ts +8 -0
  200. package/dist/server/adapter/shared-handler.d.cts +9 -0
  201. package/dist/server/adapter/shared-handler.d.ts +9 -0
  202. package/dist/server/adapter/types.d.cts +33 -0
  203. package/dist/server/adapter/types.d.ts +33 -0
  204. package/dist/server/auth/errors.d.cts +53 -0
  205. package/dist/server/auth/errors.d.ts +53 -0
  206. package/dist/server/auth/index.cjs +48 -42
  207. package/dist/server/auth/index.cjs.map +1 -1
  208. package/dist/server/auth/index.d.cts +11 -172
  209. package/dist/server/auth/index.d.ts +11 -172
  210. package/dist/server/auth/index.js +49 -43
  211. package/dist/server/auth/index.js.map +1 -1
  212. package/dist/server/auth/oauth-transaction-store.d.cts +39 -0
  213. package/dist/server/auth/oauth-transaction-store.d.ts +39 -0
  214. package/dist/server/auth/orchestrator.d.cts +8 -0
  215. package/dist/server/auth/orchestrator.d.ts +8 -0
  216. package/dist/server/auth/types.d.cts +91 -0
  217. package/dist/server/auth/types.d.ts +91 -0
  218. package/dist/server/auth/validate-return-to.d.cts +17 -0
  219. package/dist/server/auth/validate-return-to.d.ts +17 -0
  220. package/dist/server/errors-envelope.cjs +409 -0
  221. package/dist/server/errors-envelope.cjs.map +1 -0
  222. package/dist/server/errors-envelope.d.cts +61 -0
  223. package/dist/server/errors-envelope.d.ts +61 -0
  224. package/dist/server/errors-envelope.js +405 -0
  225. package/dist/server/errors-envelope.js.map +1 -0
  226. package/dist/subscription/define-subscription.d.cts +63 -0
  227. package/dist/subscription/define-subscription.d.ts +63 -0
  228. package/dist/subscription/index.cjs +402 -0
  229. package/dist/subscription/index.cjs.map +1 -0
  230. package/dist/subscription/index.d.cts +18 -0
  231. package/dist/subscription/index.d.ts +18 -0
  232. package/dist/subscription/index.js +394 -0
  233. package/dist/subscription/index.js.map +1 -0
  234. package/dist/subscription/internal/adapter-types.d.cts +11 -0
  235. package/dist/subscription/internal/adapter-types.d.ts +11 -0
  236. package/dist/subscription/internal/backpressure.d.cts +24 -0
  237. package/dist/subscription/internal/backpressure.d.ts +24 -0
  238. package/dist/subscription/internal/server-integration.d.cts +17 -0
  239. package/dist/subscription/internal/server-integration.d.ts +17 -0
  240. package/dist/subscription/internal/sse-encoder.d.cts +13 -0
  241. package/dist/subscription/internal/sse-encoder.d.ts +13 -0
  242. package/dist/subscription/internal/sse-parser.d.cts +15 -0
  243. package/dist/subscription/internal/sse-parser.d.ts +15 -0
  244. package/dist/subscription/internal/subscription-runtime.d.cts +9 -0
  245. package/dist/subscription/internal/subscription-runtime.d.ts +9 -0
  246. package/dist/subscription/internal/ws-adapter-node.d.cts +10 -0
  247. package/dist/subscription/internal/ws-adapter-node.d.ts +10 -0
  248. package/dist/subscription/theokit-subscribe.d.cts +41 -0
  249. package/dist/subscription/theokit-subscribe.d.ts +41 -0
  250. package/dist/subscription/types.d.cts +140 -0
  251. package/dist/subscription/types.d.ts +140 -0
  252. package/dist/task-store.cjs +30 -2
  253. package/dist/task-store.cjs.map +1 -1
  254. package/dist/task-store.d.cts +8 -0
  255. package/dist/task-store.js +31 -3
  256. package/dist/task-store.js.map +1 -1
  257. package/dist/types/agent-prims.d.ts +61 -0
  258. package/dist/types/agent.d.ts +48 -53
  259. package/dist/types/conversation.d.ts +20 -8
  260. package/dist/types/index.d.ts +0 -2
  261. package/dist/types/messages-base.d.ts +20 -0
  262. package/dist/types/messages.d.ts +1 -1
  263. package/dist/types/run.d.ts +1 -1
  264. package/dist/types/updates.d.ts +1 -1
  265. package/dist/voice/index.d.ts +7 -0
  266. package/dist/voice/openai-realtime.d.ts +21 -0
  267. package/dist/voice/types.d.ts +35 -0
  268. package/dist/workflow.cjs +179 -88
  269. package/dist/workflow.cjs.map +1 -1
  270. package/dist/workflow.d.cts +97 -0
  271. package/dist/workflow.js +180 -89
  272. package/dist/workflow.js.map +1 -1
  273. package/package.json +126 -25
  274. package/dist/budget.d.ts +0 -48
  275. package/dist/cache.d.ts +0 -74
  276. package/dist/cron-1yxL3K2S.d.cts +0 -221
  277. package/dist/cron-BYVdYzob.d.ts +0 -221
  278. package/dist/handoff.d.ts +0 -55
  279. package/dist/internal/budget/calendar-window.d.ts +0 -19
  280. package/dist/internal/budget/enforcement.d.ts +0 -32
  281. package/dist/internal/budget/ledger.d.ts +0 -25
  282. package/dist/internal/budget/normalize-usage.d.ts +0 -27
  283. package/dist/internal/budget/registry.d.ts +0 -16
  284. package/dist/internal/cache/cosine.d.ts +0 -14
  285. package/dist/internal/cache/embed-helper.d.ts +0 -15
  286. package/dist/internal/cache/key.d.ts +0 -15
  287. package/dist/internal/cache/lookup.d.ts +0 -28
  288. package/dist/internal/cache/store-handler.d.ts +0 -24
  289. package/dist/internal/cache/store-json.d.ts +0 -48
  290. package/dist/internal/cache/store.d.ts +0 -54
  291. package/dist/internal/cache/telemetry.d.ts +0 -20
  292. package/dist/internal/cache/ttl.d.ts +0 -11
  293. package/dist/internal/catalog/fixtures.d.ts +0 -16
  294. package/dist/internal/catalog/local-models.d.ts +0 -24
  295. package/dist/internal/handoff/dispatcher.d.ts +0 -29
  296. package/dist/internal/handoff/registry.d.ts +0 -23
  297. package/dist/internal/handoff/telemetry.d.ts +0 -18
  298. package/dist/internal/handoff/tool-injector.d.ts +0 -34
  299. package/dist/internal/memory/atomic-write.d.ts +0 -7
  300. package/dist/internal/memory/dreaming/diary.d.ts +0 -4
  301. package/dist/internal/memory/dreaming/phases.d.ts +0 -15
  302. package/dist/internal/memory/dreaming/run.d.ts +0 -10
  303. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +0 -15
  304. package/dist/memory-adapter-helpers.d.ts +0 -28
  305. package/dist/memory.d.ts +0 -123
  306. package/dist/migrate.d.ts +0 -33
  307. package/dist/security.d.ts +0 -67
  308. package/dist/task.d.ts +0 -87
  309. package/dist/theokit.d.ts +0 -84
  310. package/dist/tools/_path-scope.d.ts +0 -8
  311. package/dist/tools/_subprocess.d.ts +0 -28
  312. package/dist/tools/git-diff.d.ts +0 -22
  313. package/dist/tools/index.d.ts +0 -29
  314. package/dist/tools/list-dir.d.ts +0 -26
  315. package/dist/tools/read-file.d.ts +0 -31
  316. package/dist/tools/run-vitest.d.ts +0 -46
  317. package/dist/tools/search-text.d.ts +0 -32
  318. package/dist/tools.cjs +0 -690
  319. package/dist/tools.cjs.map +0 -1
  320. package/dist/tools.js +0 -683
  321. package/dist/tools.js.map +0 -1
  322. package/dist/trajectory-helpers.d.ts +0 -31
  323. package/dist/types/cache.d.ts +0 -76
  324. package/dist/types/handoff.d.ts +0 -135
  325. /package/dist/{internal/cron/run-job.d.ts → agent-helpers.d.ts} +0 -0
  326. /package/dist/internal/{cron/scheduler.d.ts → agent-loop/loop-llm-stream.d.ts} +0 -0
  327. /package/dist/internal/{cron/store.d.ts → agent-loop/tool-executors.d.ts} +0 -0
  328. /package/dist/internal/{cron/validate.d.ts → memory/index-manager-helpers.d.ts} +0 -0
  329. /package/dist/internal/memory/{session-loader.d.ts → storage/session-loader.d.ts} +0 -0
  330. /package/dist/internal/memory/{session-summary-writer.d.ts → storage/session-summary-writer.d.ts} +0 -0
  331. /package/dist/internal/memory/{transcript-store.d.ts → storage/transcript-store.d.ts} +0 -0
  332. /package/dist/internal/memory/{wiki-loader.d.ts → storage/wiki-loader.d.ts} +0 -0
  333. /package/dist/internal/{memory/cwd-mutex.d.ts → persistence/atomic-write.d.cts} +0 -0
  334. /package/dist/internal/runtime/{context-aggregator.d.ts → context/context-aggregator.d.ts} +0 -0
  335. /package/dist/internal/runtime/{context-discovery-runner.d.ts → context/context-discovery-runner.d.ts} +0 -0
  336. /package/dist/internal/runtime/{context-discovery.d.ts → context/context-discovery.d.ts} +0 -0
  337. /package/dist/internal/runtime/{context-frontmatter.d.ts → context/context-frontmatter.d.ts} +0 -0
  338. /package/dist/internal/runtime/{context-import-resolver.d.ts → context/context-import-resolver.d.ts} +0 -0
  339. /package/dist/internal/runtime/{context-loaders.d.ts → context/context-loaders.d.ts} +0 -0
  340. /package/dist/internal/runtime/{context-mdc-parser.d.ts → context/context-mdc-parser.d.ts} +0 -0
  341. /package/dist/internal/runtime/{fixture-responder.d.ts → fixtures/fixture-responder.d.ts} +0 -0
  342. /package/dist/internal/runtime/{fixture-types.d.ts → fixtures/fixture-types.d.ts} +0 -0
  343. /package/dist/internal/runtime/{plugins-manager.d.ts → local-agent-send.d.ts} +0 -0
  344. /package/dist/internal/runtime/{plugin-frontmatter.d.ts → plugins/plugin-frontmatter.d.ts} +0 -0
  345. /package/dist/internal/runtime/{system-prompt/providers/active-memory-provider.d.ts → plugins/plugins-manager.d.ts} +0 -0
  346. /package/dist/internal/runtime/{agent-factory-registry.d.ts → registry/agent-factory-registry.d.ts} +0 -0
  347. /package/dist/internal/runtime/{agent-registry-store.d.ts → registry/agent-registry-store.d.ts} +0 -0
  348. /package/dist/internal/runtime/system-prompt/{providers/base-provider.d.ts → sources/active-memory-provider.d.ts} +0 -0
  349. /package/dist/internal/runtime/system-prompt/{providers/context-provider.d.ts → sources/base-provider.d.ts} +0 -0
  350. /package/dist/internal/runtime/system-prompt/{providers/memory-provider.d.ts → sources/context-provider.d.ts} +0 -0
  351. /package/dist/internal/runtime/system-prompt/{providers/skills-provider.d.ts → sources/memory-provider.d.ts} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,10 +1,11 @@
1
- import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-CK8brCJ1.cjs';
2
- export { A as AgentRunError, c as AgentRunErrorCode, d as AuthenticationError, e as BudgetExceedEvent, f as BudgetExceededError, g as BudgetLimit, h as BudgetMode, i as BudgetScope, j as BudgetThresholdEvent, k as BudgetWindow, C as ConfigurationError, E as ErrorCode, l as ErrorMetadata, I as IntegrationNotConnectedError, m as InvalidTaskIdError, M as MemoryAdapterError, n as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, o as TaskNotFoundError, U as UnknownAgentError, p as UnsupportedBudgetOperationError, q as UnsupportedRunOperationError, r as UnsupportedTaskOperationError } from './errors-CK8brCJ1.cjs';
3
- import { A as AgentOptions, R as RunResult, M as ModelSelection, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, a as MemorySettings, b as CustomTool, c as McpServerConfig, d as AgentDefinition, e as ContextSettings, f as PluginsSettings, g as SkillsSettings, h as SDKAgent, i as ListAgentsOptions, j as ListResult, k as SDKAgentInfo, G as GetAgentOptions, l as ListRunsOptions, m as Run, n as GetRunOptions, o as AgentOperationOptions, H as HandoffOptions, p as HandoffDescriptor, q as ConversationStorageAdapter, r as StoredMessage, s as MemoryId, t as SDKProvider, u as SDKMessage } from './run-DkCD5DeO.cjs';
4
- export { v as AgentConversationTurn, w as AgentMemory, x as AssistantMessage, y as CloudEnv, z as CloudRepo, B as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, I as ContextSourceStatus, J as ConversationStep, K as ConversationTurn, N as CostBreakdown, O as CostSource, Q as CostStatus, T as GoalEvent, U as GoalOptions, V as GoalResult, W as HandoffContext, X as HandoffHistory, Y as HandoffLoopError, Z as HandoffNameCollisionError, _ as HandoffPairLoopError, $ as HandoffReceiverDisposedError, a0 as HandoffResult, a1 as HandoffSelfReferenceError, a2 as InteractionUpdate, a3 as InvalidateCacheOptions, a4 as McpAuthConfig, a5 as McpHttpServerConfig, a6 as McpOAuthConfig, a7 as McpStdioServerConfig, a8 as MemoryAdapter, a9 as MemoryAdapterCapabilities, aa as MemoryContext, ab as MemoryFact, ac as MemoryRevision, ad as MemoryToolSchema, ae as MemoryTurnMessage, af as ModelParameterValue, ag as PartialToolCallUpdate, ah as PersonalityPreset, ai as ProviderCapability, aj as ProviderRoute, ak as ResolvedProviderRoute, al as RunErrorDetail, am as RunGitInfo, an as RunOperation, ao as RunStatus, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkills, as as SDKArtifact, at as SDKAssistantMessage, au as SDKContextManager, av as SDKImage, aw as SDKImageDimension, ax as SDKObjectDelta, ay as SDKPluginMetadata, az as SDKProvidersManager, aA as SDKRequestMessage, aB as SDKStatusMessage, aC as SDKSystemMessage, aD as SDKTaskMessage, aE as SDKThinkingMessage, aF as SDKToolUseMessage, aG as SDKUserMessage, aH as SDKUserMessageEvent, aI as SendOptions, aJ as SettingSource, aK as ShellCommand, aL as ShellConversationTurn, aM as ShellOutput, aN as ShellOutputDeltaUpdate, aO as StepCompletedUpdate, aP as StepStartedUpdate, aQ as SummaryCompletedUpdate, aR as SummaryStartedUpdate, aS as SummaryUpdate, aT as SystemPromptContext, aU as SystemPromptMemoryFact, aV as SystemPromptSkillRef, aW as TelemetrySettings, aX as TextBlock, aY as TextDeltaUpdate, aZ as ThinkingCompletedUpdate, a_ as ThinkingDeltaUpdate, a$ as ThinkingMessage, b0 as TokenDeltaUpdate, b1 as TokenUsage, b2 as ToolCall, b3 as ToolCallCompletedUpdate, b4 as ToolCallStartedUpdate, b5 as ToolUseBlock, b6 as TurnEndedUpdate, b7 as UserMessage, b8 as UserMessageAppendedUpdate } from './run-DkCD5DeO.cjs';
1
+ import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-ChqOmFH1.cjs';
2
+ export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-ChqOmFH1.cjs';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-BnywDYLq.cjs';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-BnywDYLq.cjs';
5
+ import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.cjs';
6
+ export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.cjs';
5
7
  import * as zod from 'zod';
6
8
  import { ZodType, z } from 'zod';
7
- export { C as Cron, a as CronCreateOptions, b as CronGetOptions, c as CronJob, d as CronJobStatus, e as CronListOptions, f as CronOperationOptions, g as CronRunOptions, h as CronRuntime, i as CronSchedulerStatus, j as CronStartOptions } from './cron-1yxL3K2S.cjs';
8
9
 
9
10
  /**
10
11
  * Public types for `Agent.batch` (ADRs D134-D140).
@@ -765,6 +766,27 @@ declare class UsageAccumulator {
765
766
  * (preflight throw before LLM call).
766
767
  *
767
768
  * @public
769
+ *
770
+ * @deprecated since SDK 2.0 (iter 18+) — import this facade from
771
+ * `@theokit/sdk-budget` instead. The sources backing this facade have
772
+ * been physically extracted to `@theokit/sdk-budget/internal/` per
773
+ * ADR-008. The sdk-core copies are retained for the v1.x sync API
774
+ * contract; consumers MUST migrate before sdk-core v3.0.
775
+ *
776
+ * Migration:
777
+ *
778
+ * ```ts
779
+ * // Before (sdk-core, deprecated):
780
+ * import { Budget, computeCost } from "@theokit/sdk";
781
+ *
782
+ * // After (sdk-budget, authoritative):
783
+ * import {
784
+ * chargeAndCheckThresholds,
785
+ * createBudget,
786
+ * computeUsdCost, // replaces computeCost
787
+ * createUsdBudgetTracker,
788
+ * } from "@theokit/sdk-budget";
789
+ * ```
768
790
  */
769
791
 
770
792
  declare class Budget {
@@ -799,232 +821,6 @@ declare class Budget {
799
821
  static snapshot(): readonly BudgetSnapshot[];
800
822
  }
801
823
 
802
- /**
803
- * ProviderProfile + ApiMode types (T3.1, ADR D105).
804
- *
805
- * Profile is **data-only** — no methods. Adding a provider is declaring an
806
- * object literal; the Transport layer (D106) consumes `apiMode` to pick
807
- * the HTTP dialect.
808
- *
809
- * @public
810
- */
811
- type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
812
- type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
813
- interface ProviderProfile {
814
- name: string;
815
- apiMode: ApiMode;
816
- aliases?: ReadonlyArray<string>;
817
- displayName?: string;
818
- description?: string;
819
- signupUrl?: string;
820
- envVars: ReadonlyArray<string>;
821
- authType: AuthType;
822
- baseUrl: string;
823
- modelsUrl?: string;
824
- hostname?: string;
825
- fallbackModels: ReadonlyArray<string>;
826
- extraHeaders?: Record<string, string>;
827
- bodyOverrides?: Record<string, unknown>;
828
- }
829
-
830
- type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
831
- interface PreToolCallContext {
832
- name: string;
833
- args: Record<string, unknown>;
834
- agentId: string;
835
- runId: string;
836
- }
837
- interface PreToolCallDecision {
838
- block: true;
839
- message: string;
840
- }
841
- type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
842
- type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
843
- interface CommandOptions {
844
- description?: string;
845
- }
846
- interface PluginContext {
847
- /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
848
- registerTool(tool: CustomTool): void;
849
- /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
850
- registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
851
- /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
852
- on(hook: HookName, handler: HookHandler): void;
853
- /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
854
- injectMessage(content: string, role?: "user" | "system"): void;
855
- }
856
- interface BasePlugin {
857
- name: string;
858
- version: string;
859
- }
860
- type Plugin = (BasePlugin & {
861
- kind: "general";
862
- register: (ctx: PluginContext) => void | Promise<void>;
863
- }) | (BasePlugin & {
864
- kind: "model-provider";
865
- profile: ProviderProfile;
866
- }) | (BasePlugin & {
867
- kind: "memory";
868
- createProvider: MemoryProviderFactory;
869
- });
870
- /**
871
- * Identity helper for plugin authors. TS-only convenience — preserves
872
- * inferred type without forcing manual `Plugin` annotation.
873
- *
874
- * @public
875
- */
876
- declare function definePlugin<P extends Plugin>(p: P): P;
877
-
878
- /**
879
- * Public type contract for `Cache.semantic / .asPlugin / .stats / .clear`
880
- * (Adoption Roadmap #6; ADRs D249-D266).
881
- *
882
- * @public
883
- */
884
- interface CacheTTLConfig {
885
- /** Default TTL applied to all entries. Format: `"1h" | "30m" | 86400 (seconds)`. */
886
- readonly default: string | number;
887
- /** Regex marking queries that must NEVER be cached (e.g. /weather|today|now/i). */
888
- readonly exclude?: RegExp;
889
- }
890
- interface CachePersistenceOptions {
891
- readonly backend: "memory" | "json";
892
- /** Required when backend = "json". */
893
- readonly dir?: string;
894
- }
895
- /**
896
- * Embedder runtime shape — minimal subset of `EmbeddingRuntime` (D11) the
897
- * Cache actually uses. Lets tests inject fake embedders without pulling
898
- * the full memory subsystem.
899
- */
900
- interface CacheEmbedderRuntime {
901
- readonly id: string;
902
- readonly model: string;
903
- readonly dimension: number;
904
- embed(texts: ReadonlyArray<string>): Promise<number[][]>;
905
- }
906
- interface CacheSemanticOptions {
907
- /** Embedder instance. REQUIRED in v1 — no autoselect (avoids surprise API calls). */
908
- readonly embedder: CacheEmbedderRuntime;
909
- /** Cosine distance threshold (0..2). Default 0.85; lower = stricter. */
910
- readonly threshold?: number;
911
- /** TTL config. Default `{ default: "1h" }`. */
912
- readonly ttl?: CacheTTLConfig;
913
- /** Multi-tenant namespace. Default `"global"`. */
914
- readonly namespace?: string;
915
- /** Default modelId attached to entries when caller doesn't override. */
916
- readonly modelId?: string;
917
- /** Max entries (LRU eviction). Default 1000. */
918
- readonly maxEntries?: number;
919
- /** Persistence backend. Default in-memory. */
920
- readonly persistence?: CachePersistenceOptions;
921
- }
922
- interface CacheEntry {
923
- readonly key: string;
924
- readonly namespace: string;
925
- readonly embedderId: string;
926
- readonly modelId: string;
927
- readonly prompt: string;
928
- readonly response: string;
929
- readonly vector: ReadonlyArray<number>;
930
- readonly createdAt: number;
931
- readonly expiresAt: number;
932
- readonly accessedAt: number;
933
- readonly accessCount: number;
934
- }
935
- interface CacheStats {
936
- readonly entries: number;
937
- readonly kvHits: number;
938
- readonly semanticHits: number;
939
- readonly misses: number;
940
- readonly excluded: number;
941
- readonly evicted: number;
942
- readonly embedderFailures: number;
943
- }
944
- declare class CacheEmbedderError extends Error {
945
- readonly name = "CacheEmbedderError";
946
- readonly cause?: Error;
947
- constructor(message: string, cause?: Error);
948
- }
949
- declare class CacheInvalidTtlError extends Error {
950
- readonly input: string | number;
951
- readonly name = "CacheInvalidTtlError";
952
- constructor(input: string | number);
953
- }
954
-
955
- /**
956
- * Public `Cache` class — semantic LLM response cache (Adoption Roadmap #6;
957
- * ADRs D249-D266).
958
- *
959
- * Usage:
960
- *
961
- * import { Agent, Cache, definePlugin } from "@theokit/sdk";
962
- *
963
- * const cache = Cache.semantic({
964
- * embedder: myEmbedderRuntime, // EmbeddingRuntime (D11)
965
- * threshold: 0.85,
966
- * ttl: { default: "1h", exclude: /weather|today|now/i },
967
- * namespace: "my-app",
968
- * modelId: "openai/gpt-4o-mini",
969
- * });
970
- *
971
- * const agent = await Agent.create({
972
- * model: { id: "openai/gpt-4o-mini" },
973
- * plugins: [cache.asPlugin()],
974
- * // ...
975
- * });
976
- *
977
- * await agent.send("What is the capital of France?"); // miss → LLM
978
- * await agent.send("Tell me the capital of France"); // semantic hit
979
- *
980
- * @public
981
- */
982
-
983
- declare class Cache {
984
- private readonly embedder;
985
- private readonly threshold;
986
- private readonly ttl;
987
- private readonly namespace;
988
- private readonly modelId;
989
- private readonly store;
990
- private _plugin?;
991
- private constructor();
992
- static semantic(options: CacheSemanticOptions): Cache;
993
- /**
994
- * EC-4 absorbed: memoized so repeated `asPlugin()` calls return the SAME
995
- * plugin descriptor — no duplicate hook registration.
996
- */
997
- asPlugin(): Plugin;
998
- /**
999
- * Explicit cache lookup — callers that want true LLM short-circuit
1000
- * call this BEFORE `agent.send()`, then dispatch to the LLM only on miss.
1001
- *
1002
- * v1 plugin mode provides recall + context-inject (LLM still called).
1003
- * v1.x will add transparent short-circuit via an agent-loop refactor.
1004
- */
1005
- consult(prompt: string): Promise<{
1006
- hit: false;
1007
- } | {
1008
- hit: true;
1009
- response: string;
1010
- source: "kv" | "semantic";
1011
- distance?: number;
1012
- }>;
1013
- /**
1014
- * Explicit cache store — pair with `consult()` to manually feed the
1015
- * cache after dispatching the LLM call yourself.
1016
- */
1017
- remember(prompt: string, response: string, opts?: {
1018
- usedTools?: boolean;
1019
- }): Promise<void>;
1020
- /** Stats snapshot — primary observable for dogfood verification. */
1021
- stats(): CacheStats;
1022
- /** Clear all entries (and flush to disk if JSON backend). */
1023
- clear(): Promise<void>;
1024
- /** Force-evict expired entries. Returns count removed. */
1025
- evictExpired(now?: number): number;
1026
- }
1027
-
1028
824
  /**
1029
825
  * Spec accepted by {@link defineTool}. `inputSchema` is a Zod schema; the
1030
826
  * `handler` argument type is inferred via `z.infer<T>` — no `as` casts.
@@ -1060,57 +856,27 @@ interface DefineToolSpec<T extends ZodType> {
1060
856
  declare function defineTool<T extends ZodType>(spec: DefineToolSpec<T>): CustomTool;
1061
857
 
1062
858
  /**
1063
- * Public `Handoff` class factory for handoff descriptors (Adoption
1064
- * Roadmap #4; ADRs D214-D229).
1065
- *
1066
- * Usage:
1067
- *
1068
- * import { Agent, Handoff } from "@theokit/sdk";
1069
- *
1070
- * const billing = await Agent.create({
1071
- * name: "billing",
1072
- * systemPrompt: "You handle billing questions.",
1073
- * model: { id: "openai/gpt-4o-mini" },
1074
- * apiKey: process.env.OPENROUTER_API_KEY,
1075
- * });
859
+ * `EventBus` — typed EventEmitter wrapper.
1076
860
  *
1077
- * const triage = await Agent.create({
1078
- * name: "triage",
1079
- * systemPrompt: "Classify the user's intent and transfer to the right specialist.",
1080
- * model: { id: "openai/gpt-4o-mini" },
1081
- * apiKey: process.env.OPENROUTER_API_KEY,
1082
- * handoffs: [
1083
- * billing, // auto-wrapped as Handoff.create(billing)
1084
- * Handoff.create(supportAgent, { inputFilter: redactCreditCards }),
1085
- * ],
1086
- * });
1087
- *
1088
- * @public
861
+ * Provides type-safe publish/subscribe with automatic unsubscribe cleanup.
862
+ * Each handler is try-caught (EC-2) so one failing handler cannot break others.
1089
863
  */
1090
-
1091
- /** Recommended system-prompt prefix for senders (D215 / EC-13). */
1092
- declare const RECOMMENDED_HANDOFF_PROMPT_PREFIX: string;
1093
- declare class Handoff {
1094
- private constructor();
864
+ type EventHandler<T> = (payload: T) => void;
865
+ declare class EventBus<Events extends Record<string, unknown>> {
866
+ private handlers;
1095
867
  /**
1096
- * Build a `HandoffDescriptor` for a target agent. Wrap with custom options
1097
- * (filter / inputType / callback / whitelist / etc); pass to
1098
- * `Agent.create({ handoffs: [...] })`.
1099
- *
1100
- * Raw `SDKAgent` instances in `handoffs[]` are auto-wrapped by the runtime
1101
- * — call `Handoff.create()` explicitly only when you need to customize.
868
+ * Subscribe to an event. Returns an unsubscribe function.
869
+ */
870
+ subscribe<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
871
+ /**
872
+ * Publish an event to all subscribers. EC-2: try-catch per handler.
873
+ */
874
+ publish<K extends keyof Events>(event: K, payload: Events[K]): void;
875
+ /**
876
+ * Subscribe to an event for a single firing. Returns an unsubscribe function.
1102
877
  */
1103
- static create<TInput extends ZodType = ZodType>(target: SDKAgent, options?: HandoffOptions<TInput>): HandoffDescriptor<TInput>;
878
+ once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
1104
879
  }
1105
- /**
1106
- * Imperative escape hatch (D225). Useful for tests / programmatic flows
1107
- * that need deterministic handoff without LLM routing.
1108
- *
1109
- * NOTE: this is a STANDALONE helper rather than a method on `SDKAgent`
1110
- * to avoid invasive refactor of the agent class. Behavior is identical
1111
- * to invoking the corresponding synthetic tool would be.
1112
- */
1113
- declare function handoffTo(sender: SDKAgent, target: SDKAgent, message: string, options?: HandoffOptions): Promise<string>;
1114
880
 
1115
881
  /**
1116
882
  * Filesystem-backed implementation of {@link ConversationStorageAdapter}
@@ -1175,6 +941,218 @@ declare class InMemoryConversationStorage implements ConversationStorageAdapter
1175
941
  dispose(): Promise<void>;
1176
942
  }
1177
943
 
944
+ declare function withCwdMutex<T>(key: string, fn: () => Promise<T>): Promise<T>;
945
+
946
+ /**
947
+ * ProviderProfile + ApiMode types (T3.1, ADR D105).
948
+ *
949
+ * Profile is **data-only** — no methods. Adding a provider is declaring an
950
+ * object literal; the Transport layer (D106) consumes `apiMode` to pick
951
+ * the HTTP dialect.
952
+ *
953
+ * @public
954
+ */
955
+ type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
956
+ type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
957
+ interface ProviderProfile {
958
+ name: string;
959
+ apiMode: ApiMode;
960
+ aliases?: ReadonlyArray<string>;
961
+ displayName?: string;
962
+ description?: string;
963
+ signupUrl?: string;
964
+ envVars: ReadonlyArray<string>;
965
+ authType: AuthType;
966
+ baseUrl: string;
967
+ modelsUrl?: string;
968
+ hostname?: string;
969
+ fallbackModels: ReadonlyArray<string>;
970
+ extraHeaders?: Record<string, string>;
971
+ bodyOverrides?: Record<string, unknown>;
972
+ }
973
+
974
+ type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
975
+ interface PreToolCallContext {
976
+ name: string;
977
+ args: Record<string, unknown>;
978
+ agentId: string;
979
+ runId: string;
980
+ }
981
+ interface PreToolCallDecision {
982
+ block: true;
983
+ message: string;
984
+ }
985
+ /**
986
+ * Context passed to `pre_user_send` hook handlers (ADR D145).
987
+ *
988
+ * @public
989
+ */
990
+ interface PreUserSendContext {
991
+ prompt: string;
992
+ agentId: string;
993
+ runId: string;
994
+ /** Caller-supplied memory context, flowing through from `AgentOptions.memoryContext`. */
995
+ memoryContext?: MemoryContext;
996
+ /** Forwarded `AbortSignal` so adapter recall HTTP can be cancelled mid-flight (EC-H). */
997
+ signal?: AbortSignal;
998
+ }
999
+ /**
1000
+ * Optional result returned by `pre_user_send` handlers. The agent loop
1001
+ * concatenates `recalledContext` from all handlers and injects it as a
1002
+ * `<memory-context>...</memory-context>` block before the user prompt.
1003
+ *
1004
+ * @public
1005
+ */
1006
+ interface PreUserSendResult {
1007
+ recalledContext?: string;
1008
+ }
1009
+ /**
1010
+ * Context passed to `post_assistant_reply` hook handlers (ADR D145).
1011
+ * Fire-and-forget — exceptions are caught and surfaced to stderr; the
1012
+ * caller's `wait()` never blocks on this dispatch.
1013
+ *
1014
+ * @public
1015
+ */
1016
+ interface PostAssistantReplyContext {
1017
+ prompt: string;
1018
+ reply: string;
1019
+ agentId: string;
1020
+ runId: string;
1021
+ memoryContext?: MemoryContext;
1022
+ }
1023
+ type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
1024
+ type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
1025
+ interface CommandOptions {
1026
+ description?: string;
1027
+ }
1028
+ interface PluginContext {
1029
+ /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
1030
+ registerTool(tool: CustomTool): void;
1031
+ /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
1032
+ registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
1033
+ /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
1034
+ on(hook: HookName, handler: HookHandler): void;
1035
+ /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
1036
+ injectMessage(content: string, role?: "user" | "system"): void;
1037
+ }
1038
+ interface BasePlugin {
1039
+ name: string;
1040
+ version: string;
1041
+ }
1042
+ type Plugin = (BasePlugin & {
1043
+ kind: "general";
1044
+ register: (ctx: PluginContext) => void | Promise<void>;
1045
+ }) | (BasePlugin & {
1046
+ kind: "model-provider";
1047
+ profile: ProviderProfile;
1048
+ }) | (BasePlugin & {
1049
+ kind: "memory";
1050
+ createProvider: MemoryProviderFactory;
1051
+ });
1052
+ /**
1053
+ * Identity helper for plugin authors. TS-only convenience — preserves
1054
+ * inferred type without forcing manual `Plugin` annotation.
1055
+ *
1056
+ * @public
1057
+ */
1058
+ declare function definePlugin<P extends Plugin>(p: P): P;
1059
+
1060
+ /**
1061
+ * Reference `BudgetTracker` impl — pure token + iteration counter
1062
+ * (SDK 2.0 Phase 2 / T2.1 — ADR D1 reference implementation).
1063
+ *
1064
+ * Counts tokens per type (input/output) + iteration count. Enforces
1065
+ * optional `maxTokens` / `maxIterations` ceilings via `check()`.
1066
+ *
1067
+ * Does NOT compute USD cost — leaves that to richer impls in
1068
+ * `@theokit/sdk-budget` (post-Phase-2). This file is intentionally
1069
+ * minimal so consumers can:
1070
+ * - use it as-is for simple guard-rails;
1071
+ * - read it as a worked example before authoring a custom tracker;
1072
+ * - rely on it as a fallback before sdk-budget ships.
1073
+ *
1074
+ * @public — surface-level reference impl.
1075
+ */
1076
+
1077
+ /** Options for `createCounterBudgetTracker`. */
1078
+ interface CounterBudgetTrackerOptions {
1079
+ /** Hard ceiling on total tokens (input + output). When reached, `check()` returns `allowed: false`. */
1080
+ readonly maxTokens?: number;
1081
+ /** Hard ceiling on iterations counted by `nextIteration()`. */
1082
+ readonly maxIterations?: number;
1083
+ }
1084
+ /**
1085
+ * Build a fresh tracker. The returned object is independent — call
1086
+ * `createCounterBudgetTracker()` per Agent instance.
1087
+ *
1088
+ * The tracker exposes the `BudgetTracker` contract PLUS a `nextIteration()`
1089
+ * helper for impls that want explicit iteration counting (the agent loop
1090
+ * calls it once per turn). Without `nextIteration()` calls, the iteration
1091
+ * cap is never reached.
1092
+ */
1093
+ declare function createCounterBudgetTracker(options?: CounterBudgetTrackerOptions): BudgetTracker & {
1094
+ nextIteration(): void;
1095
+ };
1096
+
1097
+ /**
1098
+ * Reference `MemoryProvider` impl — no-op fallback (SDK 2.0 Phase 1 /
1099
+ * T1.2 reference implementation, mirrors `createCounterBudgetTracker`).
1100
+ *
1101
+ * Every method is a degenerate identity:
1102
+ * - `init()` returns a handle wrapping a no-op `MemoryAdapter`.
1103
+ * - `buildTools()` returns `[]` (no memory tools surfaced to the LLM).
1104
+ * - `runActivePass()` returns `{ facts: [] }` (no recall fires).
1105
+ * - `dispose()` is a no-op.
1106
+ *
1107
+ * Why ship this:
1108
+ * - Default safety net before `@theokit/sdk-memory` is installed.
1109
+ * - Worked reference for authors of custom providers.
1110
+ * - Enables `Agent.create({ memoryProvider: createNoopMemoryProvider() })`
1111
+ * unit tests without pulling memory infrastructure.
1112
+ *
1113
+ * NOT a substitute for the existing `Memory` class — the legacy class
1114
+ * stays authoritative until the subsystem fully ports to providers
1115
+ * (Phase 1 / T1.6).
1116
+ *
1117
+ * @public — surface-level reference impl.
1118
+ */
1119
+
1120
+ /**
1121
+ * Build a fresh no-op MemoryProvider. The returned object is independent —
1122
+ * call `createNoopMemoryProvider()` per Agent instance. `init()` is
1123
+ * idempotent: subsequent calls return a NEW handle (no per-agent cache —
1124
+ * the no-op has no state worth caching).
1125
+ */
1126
+ declare function createNoopMemoryProvider(): MemoryProvider;
1127
+
1128
+ /**
1129
+ * `JobQueue` — background job queue with status tracking.
1130
+ *
1131
+ * EC-1: all enqueued functions are wrapped in Promise.resolve().then()
1132
+ * to ensure synchronous throws become rejections.
1133
+ */
1134
+ type JobStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
1135
+ interface Job<T> {
1136
+ id: string;
1137
+ status: JobStatus;
1138
+ result?: T;
1139
+ error?: string;
1140
+ }
1141
+ declare class JobQueue {
1142
+ private jobs;
1143
+ /**
1144
+ * Enqueue a background function. Returns the job ID immediately.
1145
+ * EC-1: wraps fn in Promise.resolve().then() so sync throws are caught.
1146
+ */
1147
+ enqueue<T>(fn: () => Promise<T>): string;
1148
+ getJob(id: string): Job<unknown> | undefined;
1149
+ list(): Job<unknown>[];
1150
+ /**
1151
+ * Cancel a pending or running job. Returns true if cancelled.
1152
+ */
1153
+ cancel(id: string): boolean;
1154
+ }
1155
+
1178
1156
  /**
1179
1157
  * Public handle to an open memory index. Mirrors the internal `MemoryIndex`
1180
1158
  * contract structurally; defined here (NOT re-exported from internal/) so
@@ -1362,6 +1340,28 @@ interface MigrateResult {
1362
1340
  */
1363
1341
  declare function migrateSqliteToLance(options: MigrateOptions): Promise<MigrateResult>;
1364
1342
 
1343
+ /**
1344
+ * `PermissionEngine` — first-match permission rules for tool invocations.
1345
+ *
1346
+ * Evaluates a tool name against an ordered list of rules.
1347
+ * First matching rule wins; default is "allow" when no rule matches.
1348
+ */
1349
+ type PermissionAction = "allow" | "deny" | "ask";
1350
+ interface PermissionRule {
1351
+ /** Tool name (exact string) or pattern (RegExp). */
1352
+ tool: string | RegExp;
1353
+ /** Action to take when rule matches. */
1354
+ action: PermissionAction;
1355
+ }
1356
+ declare class PermissionEngine {
1357
+ private readonly rules;
1358
+ constructor(rules: PermissionRule[]);
1359
+ /**
1360
+ * Evaluate a tool name against the rules. First match wins; default "allow".
1361
+ */
1362
+ evaluate(toolName: string): PermissionAction;
1363
+ }
1364
+
1365
1365
  /**
1366
1366
  * Public security namespace (T2.1, ADR D68).
1367
1367
  *
@@ -1650,6 +1650,25 @@ declare class Task {
1650
1650
  static subscribe(id: string): AsyncIterable<TaskEvent>;
1651
1651
  }
1652
1652
 
1653
+ /**
1654
+ * Dynamic provider catalog loader (T10.1, ADR D447).
1655
+ *
1656
+ * Loads provider metadata from `provider-catalog.json` at runtime.
1657
+ * Malformed entries are skipped with WARN (EC-1) — never crash.
1658
+ *
1659
+ * @internal
1660
+ */
1661
+
1662
+ interface ProviderCapabilities {
1663
+ supportsToolUse: boolean;
1664
+ supportsVision: boolean;
1665
+ supportsStructuredOutput: boolean;
1666
+ supportsStreaming: boolean;
1667
+ supportsCacheControl: boolean;
1668
+ maxContextTokens?: number;
1669
+ maxOutputTokens?: number;
1670
+ }
1671
+
1653
1672
  /**
1654
1673
  * Account-level user info returned by `Theokit.me()`.
1655
1674
  *
@@ -1751,6 +1770,7 @@ declare class Theokit {
1751
1770
  */
1752
1771
  static readonly models: {
1753
1772
  list: (options?: TheokitRequestOptions) => Promise<SDKModel[]>;
1773
+ capabilities: (providerOrModelId: string) => ProviderCapabilities | undefined;
1754
1774
  };
1755
1775
  /**
1756
1776
  * Connected GitHub repositories for the calling user's team. Cloud only.
@@ -1875,4 +1895,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
1875
1895
  model?: string;
1876
1896
  }): ShareGptTrajectory | null;
1877
1897
 
1878
- export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, Cache, CacheEmbedderError, type CacheEmbedderRuntime, type CacheEntry, CacheInvalidTtlError, type CachePersistenceOptions, type CacheSemanticOptions, type CacheStats, type CacheTTLConfig, CloudOptions, ContextSettings, ConversationStorageAdapter, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, Handoff, HandoffDescriptor, HandoffOptions, type HookName, InMemoryConversationStorage, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type Plugin, type PluginContext, PluginsSettings, type PreToolCallContext, type PreToolCallDecision, type ProviderProfile, ProviderRoutingSettings, RECOMMENDED_HANDOFF_PROMPT_PREFIX, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, definePlugin, defineTool, extractRawId, getPricingEntry, handoffTo, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory };
1898
+ export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };