@theokit/sdk 1.6.2 → 1.8.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 (371) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/bin/init-claude.mjs +34 -0
  3. package/claude-template/AGENTS.md +139 -0
  4. package/claude-template/CLAUDE.md +51 -0
  5. package/claude-template/dot-claude/rules/theokit-conventions.md +33 -0
  6. package/claude-template/dot-claude/settings.json +16 -0
  7. package/claude-template/dot-claude/skills/theokit-agent-core/SKILL.md +209 -0
  8. package/claude-template/dot-claude/skills/theokit-budget/SKILL.md +176 -0
  9. package/claude-template/dot-claude/skills/theokit-config/SKILL.md +139 -0
  10. package/claude-template/dot-claude/skills/theokit-cron/SKILL.md +148 -0
  11. package/claude-template/dot-claude/skills/theokit-di/SKILL.md +233 -0
  12. package/claude-template/dot-claude/skills/theokit-di-agent/SKILL.md +294 -0
  13. package/claude-template/dot-claude/skills/theokit-errors/SKILL.md +172 -0
  14. package/claude-template/dot-claude/skills/theokit-eval/SKILL.md +144 -0
  15. package/claude-template/dot-claude/skills/theokit-gateways/SKILL.md +209 -0
  16. package/claude-template/dot-claude/skills/theokit-memory/SKILL.md +176 -0
  17. package/claude-template/dot-claude/skills/theokit-rag/SKILL.md +226 -0
  18. package/claude-template/dot-claude/skills/theokit-streaming/SKILL.md +156 -0
  19. package/claude-template/dot-claude/skills/theokit-subscriptions/SKILL.md +148 -0
  20. package/claude-template/dot-claude/skills/theokit-tools/SKILL.md +170 -0
  21. package/claude-template/dot-claude/skills/theokit-workflows/SKILL.md +218 -0
  22. package/dist/a2a/agent-mailbox.d.cts +27 -0
  23. package/dist/a2a/agent-mailbox.d.ts +27 -0
  24. package/dist/a2a/index.cjs +16850 -0
  25. package/dist/a2a/index.cjs.map +1 -0
  26. package/dist/a2a/index.d.cts +9 -0
  27. package/dist/a2a/index.d.ts +9 -0
  28. package/dist/a2a/index.js +16844 -0
  29. package/dist/a2a/index.js.map +1 -0
  30. package/dist/a2a/message-bus.d.cts +27 -0
  31. package/dist/a2a/message-bus.d.ts +27 -0
  32. package/dist/a2a/subagent.d.cts +25 -0
  33. package/dist/a2a/subagent.d.ts +25 -0
  34. package/dist/a2a/types.d.cts +12 -0
  35. package/dist/a2a/types.d.ts +12 -0
  36. package/dist/agent.d.ts +1 -1
  37. package/dist/client/index.cjs +73 -0
  38. package/dist/client/index.cjs.map +1 -0
  39. package/dist/client/index.d.cts +7 -0
  40. package/dist/client/index.d.ts +7 -0
  41. package/dist/client/index.js +71 -0
  42. package/dist/client/index.js.map +1 -0
  43. package/dist/client/theokit-client.d.cts +18 -0
  44. package/dist/client/theokit-client.d.ts +18 -0
  45. package/dist/client/types.d.cts +19 -0
  46. package/dist/client/types.d.ts +19 -0
  47. package/dist/{run-DkCD5DeO.d.cts → cron-BnywDYLq.d.cts} +496 -910
  48. package/dist/{run-DkCD5DeO.d.ts → cron-CtZvJD9J.d.ts} +496 -910
  49. package/dist/cron.cjs +4285 -2893
  50. package/dist/cron.cjs.map +1 -1
  51. package/dist/cron.d.cts +2 -3
  52. package/dist/cron.d.ts +2 -71
  53. package/dist/cron.js +4289 -2897
  54. package/dist/cron.js.map +1 -1
  55. package/dist/{errors-CvAeEWgE.d.ts → errors-ChqOmFH1.d.cts} +52 -6
  56. package/dist/{errors-CK8brCJ1.d.cts → errors-DV9e0rcp.d.ts} +52 -6
  57. package/dist/errors.cjs +218 -3
  58. package/dist/errors.cjs.map +1 -1
  59. package/dist/errors.d.cts +2 -3
  60. package/dist/errors.d.ts +50 -4
  61. package/dist/errors.js +217 -4
  62. package/dist/errors.js.map +1 -1
  63. package/dist/eval.cjs +4285 -2893
  64. package/dist/eval.cjs.map +1 -1
  65. package/dist/eval.d.cts +35 -0
  66. package/dist/eval.js +4289 -2897
  67. package/dist/eval.js.map +1 -1
  68. package/dist/event-bus.d.ts +23 -0
  69. package/dist/index.cjs +5132 -4200
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.d.cts +298 -278
  72. package/dist/index.d.ts +1898 -24
  73. package/dist/index.js +6441 -5509
  74. package/dist/index.js.map +1 -1
  75. package/dist/internal/agent-loop/loop-context-init.d.ts +2 -0
  76. package/dist/internal/agent-loop/tool-dispatch.d.ts +22 -1
  77. package/dist/internal/auth/api-key-validator.d.ts +46 -0
  78. package/dist/internal/llm/anthropic-shared.d.ts +8 -1
  79. package/dist/internal/llm/retry.d.ts +22 -0
  80. package/dist/internal/llm/types.d.ts +47 -1
  81. package/dist/internal/memory/active-memory-cache.d.ts +3 -3
  82. package/dist/internal/memory/active-memory-types.d.ts +8 -0
  83. package/dist/internal/memory/active-memory.d.ts +24 -20
  84. package/dist/internal/memory/adapters/azure-openai-embedding.d.ts +2 -0
  85. package/dist/internal/memory/adapters/cohere-embedding.d.ts +2 -0
  86. package/dist/internal/memory/adapters/gemini-embedding.d.ts +2 -0
  87. package/dist/internal/memory/adapters/jina-embedding.d.ts +2 -0
  88. package/dist/internal/memory/index-manager-contract.d.ts +26 -0
  89. package/dist/internal/memory/index-manager-dispatch.d.ts +1 -1
  90. package/dist/internal/memory/index-manager.d.ts +8 -26
  91. package/dist/internal/memory/{chunk-markdown.d.ts → storage/chunk-markdown.d.ts} +1 -1
  92. package/dist/internal/memory/{markdown-store.d.ts → storage/markdown-store.d.ts} +1 -1
  93. package/dist/internal/memory/{reader.d.ts → storage/reader.d.ts} +1 -1
  94. package/dist/internal/observability/context.d.cts +23 -0
  95. package/dist/internal/observability/context.d.ts +23 -0
  96. package/dist/internal/observability/index.cjs +38 -0
  97. package/dist/internal/observability/index.cjs.map +1 -0
  98. package/dist/internal/observability/index.d.cts +8 -0
  99. package/dist/internal/observability/index.d.ts +8 -0
  100. package/dist/internal/observability/index.js +33 -0
  101. package/dist/internal/observability/index.js.map +1 -0
  102. package/dist/internal/observability/tracer-loader.d.cts +20 -0
  103. package/dist/internal/persistence/conversation-storage-fs.d.cts +37 -0
  104. package/dist/internal/persistence/conversation-storage-memory.d.cts +24 -0
  105. package/dist/internal/persistence/credential-pool-store.d.cts +32 -0
  106. package/dist/internal/persistence/credential-pool-store.d.ts +32 -0
  107. package/dist/internal/persistence/cwd-mutex.d.cts +1 -0
  108. package/dist/internal/persistence/exclusive-create.d.cts +22 -0
  109. package/dist/internal/persistence/exclusive-create.d.ts +22 -0
  110. package/dist/internal/persistence/file-lock.d.cts +14 -0
  111. package/dist/internal/persistence/fts5-sanitize.d.cts +16 -0
  112. package/dist/internal/persistence/index.cjs +359 -0
  113. package/dist/internal/persistence/index.cjs.map +1 -0
  114. package/dist/internal/persistence/index.d.cts +20 -0
  115. package/dist/internal/persistence/index.d.ts +20 -0
  116. package/dist/internal/persistence/index.js +341 -0
  117. package/dist/internal/persistence/index.js.map +1 -0
  118. package/dist/internal/persistence/markdown-config-loader.d.cts +35 -0
  119. package/dist/internal/persistence/paths.d.cts +19 -0
  120. package/dist/internal/persistence/persistence-schema.d.cts +21 -0
  121. package/dist/internal/persistence/persistence-schema.d.ts +4 -0
  122. package/dist/internal/persistence/schema-version.d.cts +13 -0
  123. package/dist/internal/persistence/sqlite-cas.d.cts +25 -0
  124. package/dist/internal/persistence/sqlite-cas.d.ts +25 -0
  125. package/dist/internal/persistence/sqlite-wal.d.cts +10 -0
  126. package/dist/internal/plugins/context.d.cts +31 -0
  127. package/dist/internal/plugins/index.cjs +228 -0
  128. package/dist/internal/plugins/index.cjs.map +1 -0
  129. package/dist/internal/plugins/index.d.cts +8 -0
  130. package/dist/internal/plugins/index.d.ts +8 -0
  131. package/dist/internal/plugins/index.js +222 -0
  132. package/dist/internal/plugins/index.js.map +1 -0
  133. package/dist/internal/plugins/lifecycle.d.cts +14 -0
  134. package/dist/internal/plugins/lifecycle.d.ts +14 -0
  135. package/dist/internal/plugins/manager.d.cts +37 -0
  136. package/dist/internal/plugins/types.d.cts +102 -0
  137. package/dist/internal/providers/catalog-loader.d.ts +39 -0
  138. package/dist/internal/runtime/agent-session-store.d.ts +1 -1
  139. package/dist/internal/runtime/agent-session.d.ts +1 -0
  140. package/dist/internal/runtime/budget-tracker.d.ts +73 -0
  141. package/dist/internal/runtime/{context-manager.d.ts → context/context-manager.d.ts} +1 -1
  142. package/dist/internal/runtime/{fixture-events.d.ts → fixtures/fixture-events.d.ts} +1 -1
  143. package/dist/internal/runtime/{fixture-run-base.d.ts → fixtures/fixture-run-base.d.ts} +4 -4
  144. package/dist/internal/runtime/{fixture-scripts.d.ts → fixtures/fixture-scripts.d.ts} +1 -1
  145. package/dist/internal/runtime/local-agent-bootstrap.d.ts +2 -2
  146. package/dist/internal/runtime/local-agent-memory-provider.d.ts +57 -0
  147. package/dist/internal/runtime/memory-path-selector.d.ts +73 -0
  148. package/dist/internal/runtime/memory-provider.d.ts +165 -0
  149. package/dist/internal/runtime/{agent-registry.d.ts → registry/agent-registry-contract.d.ts} +15 -9
  150. package/dist/internal/runtime/registry/agent-registry.d.ts +7 -0
  151. package/dist/internal/runtime/{live-agent-registry.d.ts → registry/live-agent-registry.d.ts} +1 -1
  152. package/dist/internal/runtime/{run-registry.d.ts → registry/run-registry.d.ts} +1 -1
  153. package/dist/internal/runtime/session-types.d.ts +35 -0
  154. package/dist/internal/runtime/system-prompt/sources/skills-provider.d.ts +1 -0
  155. package/dist/internal/runtime/validate-response.d.ts +18 -0
  156. package/dist/internal/security/index.cjs +361 -0
  157. package/dist/internal/security/index.cjs.map +1 -0
  158. package/dist/internal/security/index.d.cts +11 -0
  159. package/dist/internal/security/index.js +350 -0
  160. package/dist/internal/security/index.js.map +1 -0
  161. package/dist/internal/security/path-guard.d.cts +59 -0
  162. package/dist/internal/security/path-guard.d.ts +3 -0
  163. package/dist/internal/security/redact.d.cts +21 -0
  164. package/dist/internal/security/secret-redactor.d.cts +1 -0
  165. package/dist/internal/security/secret-redactor.d.ts +1 -0
  166. package/dist/internal/security/test-reset.d.cts +10 -0
  167. package/dist/internal/security/test-reset.d.ts +10 -0
  168. package/dist/internal/telemetry/adapters/arize.d.ts +2 -0
  169. package/dist/internal/telemetry/adapters/braintrust.d.ts +2 -0
  170. package/dist/internal/telemetry/adapters/datadog.d.ts +2 -0
  171. package/dist/internal/telemetry/adapters/langsmith.d.ts +2 -0
  172. package/dist/internal/telemetry/span-names.d.ts +6 -0
  173. package/dist/internal/telemetry/tracer.d.ts +1 -0
  174. package/dist/internal/workflow/evented-executor.d.ts +42 -0
  175. package/dist/internal/workflow/scheduler.d.ts +23 -0
  176. package/dist/internal/zod/to-json-schema.d.ts +5 -15
  177. package/dist/job-queue.d.ts +28 -0
  178. package/dist/path-safety.cjs +67 -6
  179. package/dist/path-safety.cjs.map +1 -1
  180. package/dist/path-safety.d.cts +15 -0
  181. package/dist/path-safety.d.ts +1 -1
  182. package/dist/path-safety.js +67 -7
  183. package/dist/path-safety.js.map +1 -1
  184. package/dist/permission-engine.d.ts +21 -0
  185. package/dist/provider-catalog.json +702 -0
  186. package/dist/rag/index.cjs +136 -0
  187. package/dist/rag/index.cjs.map +1 -0
  188. package/dist/rag/index.d.cts +11 -0
  189. package/dist/rag/index.d.ts +11 -0
  190. package/dist/rag/index.js +129 -0
  191. package/dist/rag/index.js.map +1 -0
  192. package/dist/rag/reranker.d.cts +26 -0
  193. package/dist/rag/reranker.d.ts +26 -0
  194. package/dist/rag/retriever.d.cts +25 -0
  195. package/dist/rag/retriever.d.ts +25 -0
  196. package/dist/rag/text-splitter.d.cts +12 -0
  197. package/dist/rag/text-splitter.d.ts +12 -0
  198. package/dist/rag/types.d.cts +37 -0
  199. package/dist/rag/types.d.ts +37 -0
  200. package/dist/run-DrwUpFxZ.d.cts +823 -0
  201. package/dist/run-DrwUpFxZ.d.ts +823 -0
  202. package/dist/sandbox/index.cjs +133 -0
  203. package/dist/sandbox/index.cjs.map +1 -0
  204. package/dist/sandbox/index.d.cts +2 -0
  205. package/dist/sandbox/index.d.ts +2 -0
  206. package/dist/sandbox/index.js +128 -0
  207. package/dist/sandbox/index.js.map +1 -0
  208. package/dist/sandbox/local-sandbox.d.cts +17 -0
  209. package/dist/sandbox/local-sandbox.d.ts +17 -0
  210. package/dist/sandbox/types.d.cts +44 -0
  211. package/dist/sandbox/types.d.ts +44 -0
  212. package/dist/server/adapter/express.d.cts +9 -0
  213. package/dist/server/adapter/express.d.ts +9 -0
  214. package/dist/server/adapter/fastify.d.cts +9 -0
  215. package/dist/server/adapter/fastify.d.ts +9 -0
  216. package/dist/server/adapter/hono.d.cts +9 -0
  217. package/dist/server/adapter/hono.d.ts +9 -0
  218. package/dist/server/adapter/index.d.cts +8 -0
  219. package/dist/server/adapter/index.d.ts +8 -0
  220. package/dist/server/adapter/shared-handler.d.cts +9 -0
  221. package/dist/server/adapter/shared-handler.d.ts +9 -0
  222. package/dist/server/adapter/types.d.cts +33 -0
  223. package/dist/server/adapter/types.d.ts +33 -0
  224. package/dist/server/auth/errors.d.cts +53 -0
  225. package/dist/server/auth/errors.d.ts +53 -0
  226. package/dist/server/auth/index.cjs +38 -41
  227. package/dist/server/auth/index.cjs.map +1 -1
  228. package/dist/server/auth/index.d.cts +11 -172
  229. package/dist/server/auth/index.d.ts +11 -172
  230. package/dist/server/auth/index.js +39 -42
  231. package/dist/server/auth/index.js.map +1 -1
  232. package/dist/server/auth/oauth-transaction-store.d.cts +39 -0
  233. package/dist/server/auth/oauth-transaction-store.d.ts +39 -0
  234. package/dist/server/auth/orchestrator.d.cts +8 -0
  235. package/dist/server/auth/orchestrator.d.ts +8 -0
  236. package/dist/server/auth/types.d.cts +91 -0
  237. package/dist/server/auth/types.d.ts +91 -0
  238. package/dist/server/auth/validate-return-to.d.cts +17 -0
  239. package/dist/server/auth/validate-return-to.d.ts +17 -0
  240. package/dist/server/errors-envelope.cjs +409 -0
  241. package/dist/server/errors-envelope.cjs.map +1 -0
  242. package/dist/server/errors-envelope.d.cts +61 -0
  243. package/dist/server/errors-envelope.d.ts +61 -0
  244. package/dist/server/errors-envelope.js +405 -0
  245. package/dist/server/errors-envelope.js.map +1 -0
  246. package/dist/subscription/define-subscription.d.cts +63 -0
  247. package/dist/subscription/define-subscription.d.ts +63 -0
  248. package/dist/subscription/index.cjs +402 -0
  249. package/dist/subscription/index.cjs.map +1 -0
  250. package/dist/subscription/index.d.cts +18 -0
  251. package/dist/subscription/index.d.ts +18 -0
  252. package/dist/subscription/index.js +394 -0
  253. package/dist/subscription/index.js.map +1 -0
  254. package/dist/subscription/internal/adapter-types.d.cts +11 -0
  255. package/dist/subscription/internal/adapter-types.d.ts +11 -0
  256. package/dist/subscription/internal/backpressure.d.cts +24 -0
  257. package/dist/subscription/internal/backpressure.d.ts +24 -0
  258. package/dist/subscription/internal/server-integration.d.cts +17 -0
  259. package/dist/subscription/internal/server-integration.d.ts +17 -0
  260. package/dist/subscription/internal/sse-encoder.d.cts +13 -0
  261. package/dist/subscription/internal/sse-encoder.d.ts +13 -0
  262. package/dist/subscription/internal/sse-parser.d.cts +15 -0
  263. package/dist/subscription/internal/sse-parser.d.ts +15 -0
  264. package/dist/subscription/internal/subscription-runtime.d.cts +9 -0
  265. package/dist/subscription/internal/subscription-runtime.d.ts +9 -0
  266. package/dist/subscription/internal/ws-adapter-node.d.cts +10 -0
  267. package/dist/subscription/internal/ws-adapter-node.d.ts +10 -0
  268. package/dist/subscription/theokit-subscribe.d.cts +41 -0
  269. package/dist/subscription/theokit-subscribe.d.ts +41 -0
  270. package/dist/subscription/types.d.cts +140 -0
  271. package/dist/subscription/types.d.ts +140 -0
  272. package/dist/task-store.cjs +30 -2
  273. package/dist/task-store.cjs.map +1 -1
  274. package/dist/task-store.d.cts +8 -0
  275. package/dist/task-store.js +31 -3
  276. package/dist/task-store.js.map +1 -1
  277. package/dist/types/agent-prims.d.ts +61 -0
  278. package/dist/types/agent.d.ts +48 -53
  279. package/dist/types/conversation.d.ts +20 -8
  280. package/dist/types/index.d.ts +0 -2
  281. package/dist/types/messages-base.d.ts +20 -0
  282. package/dist/types/messages.d.ts +1 -1
  283. package/dist/types/run.d.ts +1 -1
  284. package/dist/types/updates.d.ts +1 -1
  285. package/dist/voice/index.d.ts +7 -0
  286. package/dist/voice/openai-realtime.d.ts +21 -0
  287. package/dist/voice/types.d.ts +35 -0
  288. package/dist/workflow.cjs +179 -88
  289. package/dist/workflow.cjs.map +1 -1
  290. package/dist/workflow.d.cts +97 -0
  291. package/dist/workflow.js +180 -89
  292. package/dist/workflow.js.map +1 -1
  293. package/package.json +128 -25
  294. package/dist/budget.d.ts +0 -48
  295. package/dist/cache.d.ts +0 -74
  296. package/dist/cron-1yxL3K2S.d.cts +0 -221
  297. package/dist/cron-BYVdYzob.d.ts +0 -221
  298. package/dist/handoff.d.ts +0 -55
  299. package/dist/internal/budget/calendar-window.d.ts +0 -19
  300. package/dist/internal/budget/enforcement.d.ts +0 -32
  301. package/dist/internal/budget/ledger.d.ts +0 -25
  302. package/dist/internal/budget/normalize-usage.d.ts +0 -27
  303. package/dist/internal/budget/registry.d.ts +0 -16
  304. package/dist/internal/cache/cosine.d.ts +0 -14
  305. package/dist/internal/cache/embed-helper.d.ts +0 -15
  306. package/dist/internal/cache/key.d.ts +0 -15
  307. package/dist/internal/cache/lookup.d.ts +0 -28
  308. package/dist/internal/cache/store-handler.d.ts +0 -24
  309. package/dist/internal/cache/store-json.d.ts +0 -48
  310. package/dist/internal/cache/store.d.ts +0 -54
  311. package/dist/internal/cache/telemetry.d.ts +0 -20
  312. package/dist/internal/cache/ttl.d.ts +0 -11
  313. package/dist/internal/catalog/fixtures.d.ts +0 -16
  314. package/dist/internal/catalog/local-models.d.ts +0 -24
  315. package/dist/internal/handoff/dispatcher.d.ts +0 -29
  316. package/dist/internal/handoff/registry.d.ts +0 -23
  317. package/dist/internal/handoff/telemetry.d.ts +0 -18
  318. package/dist/internal/handoff/tool-injector.d.ts +0 -34
  319. package/dist/internal/memory/atomic-write.d.ts +0 -7
  320. package/dist/internal/memory/dreaming/diary.d.ts +0 -4
  321. package/dist/internal/memory/dreaming/phases.d.ts +0 -15
  322. package/dist/internal/memory/dreaming/run.d.ts +0 -10
  323. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +0 -15
  324. package/dist/memory-adapter-helpers.d.ts +0 -28
  325. package/dist/memory.d.ts +0 -123
  326. package/dist/migrate.d.ts +0 -33
  327. package/dist/security.d.ts +0 -67
  328. package/dist/task.d.ts +0 -87
  329. package/dist/theokit.d.ts +0 -84
  330. package/dist/tools/_path-scope.d.ts +0 -8
  331. package/dist/tools/_subprocess.d.ts +0 -28
  332. package/dist/tools/git-diff.d.ts +0 -22
  333. package/dist/tools/index.d.ts +0 -29
  334. package/dist/tools/list-dir.d.ts +0 -26
  335. package/dist/tools/read-file.d.ts +0 -31
  336. package/dist/tools/run-vitest.d.ts +0 -46
  337. package/dist/tools/search-text.d.ts +0 -32
  338. package/dist/tools.cjs +0 -690
  339. package/dist/tools.cjs.map +0 -1
  340. package/dist/tools.js +0 -683
  341. package/dist/tools.js.map +0 -1
  342. package/dist/trajectory-helpers.d.ts +0 -31
  343. package/dist/types/cache.d.ts +0 -76
  344. package/dist/types/handoff.d.ts +0 -135
  345. /package/dist/{internal/cron/run-job.d.ts → agent-helpers.d.ts} +0 -0
  346. /package/dist/internal/{cron/scheduler.d.ts → agent-loop/loop-llm-stream.d.ts} +0 -0
  347. /package/dist/internal/{cron/store.d.ts → agent-loop/tool-executors.d.ts} +0 -0
  348. /package/dist/internal/{cron/validate.d.ts → memory/index-manager-helpers.d.ts} +0 -0
  349. /package/dist/internal/memory/{session-loader.d.ts → storage/session-loader.d.ts} +0 -0
  350. /package/dist/internal/memory/{session-summary-writer.d.ts → storage/session-summary-writer.d.ts} +0 -0
  351. /package/dist/internal/memory/{transcript-store.d.ts → storage/transcript-store.d.ts} +0 -0
  352. /package/dist/internal/memory/{wiki-loader.d.ts → storage/wiki-loader.d.ts} +0 -0
  353. /package/dist/internal/{memory/cwd-mutex.d.ts → persistence/atomic-write.d.cts} +0 -0
  354. /package/dist/internal/runtime/{context-aggregator.d.ts → context/context-aggregator.d.ts} +0 -0
  355. /package/dist/internal/runtime/{context-discovery-runner.d.ts → context/context-discovery-runner.d.ts} +0 -0
  356. /package/dist/internal/runtime/{context-discovery.d.ts → context/context-discovery.d.ts} +0 -0
  357. /package/dist/internal/runtime/{context-frontmatter.d.ts → context/context-frontmatter.d.ts} +0 -0
  358. /package/dist/internal/runtime/{context-import-resolver.d.ts → context/context-import-resolver.d.ts} +0 -0
  359. /package/dist/internal/runtime/{context-loaders.d.ts → context/context-loaders.d.ts} +0 -0
  360. /package/dist/internal/runtime/{context-mdc-parser.d.ts → context/context-mdc-parser.d.ts} +0 -0
  361. /package/dist/internal/runtime/{fixture-responder.d.ts → fixtures/fixture-responder.d.ts} +0 -0
  362. /package/dist/internal/runtime/{fixture-types.d.ts → fixtures/fixture-types.d.ts} +0 -0
  363. /package/dist/internal/runtime/{plugins-manager.d.ts → local-agent-send.d.ts} +0 -0
  364. /package/dist/internal/runtime/{plugin-frontmatter.d.ts → plugins/plugin-frontmatter.d.ts} +0 -0
  365. /package/dist/internal/runtime/{system-prompt/providers/active-memory-provider.d.ts → plugins/plugins-manager.d.ts} +0 -0
  366. /package/dist/internal/runtime/{agent-factory-registry.d.ts → registry/agent-factory-registry.d.ts} +0 -0
  367. /package/dist/internal/runtime/{agent-registry-store.d.ts → registry/agent-registry-store.d.ts} +0 -0
  368. /package/dist/internal/runtime/system-prompt/{providers/base-provider.d.ts → sources/active-memory-provider.d.ts} +0 -0
  369. /package/dist/internal/runtime/system-prompt/{providers/context-provider.d.ts → sources/base-provider.d.ts} +0 -0
  370. /package/dist/internal/runtime/system-prompt/{providers/memory-provider.d.ts → sources/context-provider.d.ts} +0 -0
  371. /package/dist/internal/runtime/system-prompt/{providers/skills-provider.d.ts → sources/memory-provider.d.ts} +0 -0
@@ -1,221 +0,0 @@
1
- import { aG as SDKUserMessage, A as AgentOptions, j as ListResult, m as Run } from './run-DkCD5DeO.js';
2
-
3
- /**
4
- * Runtime hosting a cron job. Mirrors the agent runtime split.
5
- *
6
- * - `local` — the in-process scheduler activated via `Cron.start()` fires the
7
- * job while the host process is alive.
8
- * - `cloud` — Theo PaaS schedules the job server-side; fires independent of
9
- * any SDK process.
10
- *
11
- * @public
12
- */
13
- type CronRuntime = "local" | "cloud";
14
- /**
15
- * Lifecycle state reported by `Cron.list()` / `Cron.get()`.
16
- *
17
- * @public
18
- */
19
- type CronJobStatus = "scheduled" | "running" | "paused" | "errored";
20
- /**
21
- * Persistent cron-scheduled invocation of the Theo agent.
22
- *
23
- * Exactly one of {@link CronJob.agent} (ephemeral agent created on each fire)
24
- * or {@link CronJob.agentId} (bound to an existing agent for context
25
- * continuity) is set.
26
- *
27
- * @public
28
- */
29
- interface CronJob {
30
- id: string;
31
- name?: string;
32
- /** Standard 5-field POSIX cron expression or shorthand (`@hourly`, `@daily`, ...). */
33
- cron: string;
34
- /** IANA timezone identifier. Defaults to `"UTC"`. */
35
- timezone?: string;
36
- /** Message sent to the agent on each fire. */
37
- message: string | SDKUserMessage;
38
- /** Ephemeral agent options. Mutually exclusive with `agentId`. */
39
- agent?: AgentOptions;
40
- /** ID of an existing agent to reuse for context continuity. Mutually exclusive with `agent`. */
41
- agentId?: string;
42
- /** Whether the scheduler will fire this job on schedule. */
43
- enabled: boolean;
44
- /** Current status. */
45
- status: CronJobStatus;
46
- /** Runtime that hosts this job. Inferred from `agent`/`agentId` at create time. */
47
- runtime: CronRuntime;
48
- /** Unix ms of the last successful fire, if any. */
49
- lastRunAt?: number;
50
- /** Unix ms of the next scheduled fire, computed by the scheduler. */
51
- nextRunAt?: number;
52
- /** Unix ms when the job was created. */
53
- createdAt: number;
54
- }
55
- /**
56
- * Options for `Cron.create()`.
57
- *
58
- * Pass `agent` for an ephemeral agent created fresh on each fire, OR
59
- * `agentId` to reuse an existing agent (preserves conversation context across
60
- * fires). Setting both is a `ConfigurationError`.
61
- *
62
- * @public
63
- */
64
- interface CronCreateOptions {
65
- cron: string;
66
- message: string | SDKUserMessage;
67
- agent?: AgentOptions;
68
- agentId?: string;
69
- name?: string;
70
- timezone?: string;
71
- /** Defaults to `true`. */
72
- enabled?: boolean;
73
- /** Falls back to `THEOKIT_API_KEY`. */
74
- apiKey?: string;
75
- }
76
- /**
77
- * Options for `Cron.list()`.
78
- *
79
- * @public
80
- */
81
- type CronListOptions = {
82
- limit?: number;
83
- cursor?: string;
84
- } & ({
85
- runtime?: undefined;
86
- } | {
87
- runtime: "local";
88
- cwd?: string;
89
- } | {
90
- runtime: "cloud";
91
- apiKey?: string;
92
- });
93
- /**
94
- * Options for `Cron.get()`.
95
- *
96
- * @public
97
- */
98
- interface CronGetOptions {
99
- cwd?: string;
100
- apiKey?: string;
101
- }
102
- /**
103
- * Options for `Cron.delete()` / `Cron.enable()` / `Cron.disable()`.
104
- *
105
- * @public
106
- */
107
- interface CronOperationOptions {
108
- cwd?: string;
109
- apiKey?: string;
110
- }
111
- /**
112
- * Options for `Cron.run()` — manually trigger a job off-schedule.
113
- *
114
- * @public
115
- */
116
- interface CronRunOptions {
117
- cwd?: string;
118
- apiKey?: string;
119
- }
120
- /**
121
- * Options for `Cron.start()` — activates the in-process scheduler for local
122
- * jobs.
123
- *
124
- * @public
125
- */
126
- interface CronStartOptions {
127
- /** Local workspace whose `.theokit/cron/jobs.json` to load. Defaults to `process.cwd()`. */
128
- cwd?: string;
129
- /** Override the env API key. */
130
- apiKey?: string;
131
- }
132
- /**
133
- * Snapshot of the local scheduler returned by `Cron.status()`.
134
- *
135
- * @public
136
- */
137
- interface CronSchedulerStatus {
138
- /** Whether the in-process scheduler is currently running. */
139
- running: boolean;
140
- /** Number of jobs loaded into the scheduler. */
141
- jobCount: number;
142
- /** Unix ms of the next scheduled fire across all jobs, if any. */
143
- nextFireAt?: number;
144
- /** Last error observed in the scheduler, if any. */
145
- lastError?: {
146
- jobId: string;
147
- message: string;
148
- at: number;
149
- };
150
- }
151
-
152
- /**
153
- * Static façade for scheduling Theo agent runs on a cron expression.
154
- *
155
- * @public
156
- */
157
- declare class Cron {
158
- private constructor();
159
- /**
160
- * Create and persist a cron job.
161
- *
162
- * @public
163
- */
164
- static create(options: CronCreateOptions): Promise<CronJob>;
165
- /**
166
- * List cron jobs (local, cloud, or both).
167
- *
168
- * @public
169
- */
170
- static list(options?: CronListOptions): Promise<ListResult<CronJob>>;
171
- /**
172
- * Get a single cron job by ID.
173
- *
174
- * @public
175
- */
176
- static get(jobId: string, _options?: CronGetOptions): Promise<CronJob>;
177
- /**
178
- * Delete a cron job permanently.
179
- *
180
- * @public
181
- */
182
- static delete(jobId: string, _options?: CronOperationOptions): Promise<void>;
183
- /**
184
- * Re-enable a paused cron job.
185
- *
186
- * @public
187
- */
188
- static enable(jobId: string, _options?: CronOperationOptions): Promise<CronJob>;
189
- /**
190
- * Pause a cron job without deleting it.
191
- *
192
- * @public
193
- */
194
- static disable(jobId: string, _options?: CronOperationOptions): Promise<CronJob>;
195
- /**
196
- * Manually trigger a cron job off-schedule. Returns the resulting `Run`.
197
- *
198
- * @public
199
- */
200
- static run(jobId: string, _options?: CronRunOptions): Promise<Run>;
201
- /**
202
- * Activate the in-process scheduler for local cron jobs.
203
- *
204
- * @public
205
- */
206
- static start(options?: CronStartOptions): Promise<void>;
207
- /**
208
- * Stop the in-process scheduler. Jobs are preserved.
209
- *
210
- * @public
211
- */
212
- static stop(): Promise<void>;
213
- /**
214
- * Snapshot of the local scheduler.
215
- *
216
- * @public
217
- */
218
- static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
219
- }
220
-
221
- export { Cron as C, type CronCreateOptions as a, type CronGetOptions as b, type CronJob as c, type CronJobStatus as d, type CronListOptions as e, type CronOperationOptions as f, type CronRunOptions as g, type CronRuntime as h, type CronSchedulerStatus as i, type CronStartOptions as j };
package/dist/handoff.d.ts DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * Public `Handoff` class — factory for handoff descriptors (Adoption
3
- * Roadmap #4; ADRs D214-D229).
4
- *
5
- * Usage:
6
- *
7
- * import { Agent, Handoff } from "@theokit/sdk";
8
- *
9
- * const billing = await Agent.create({
10
- * name: "billing",
11
- * systemPrompt: "You handle billing questions.",
12
- * model: { id: "openai/gpt-4o-mini" },
13
- * apiKey: process.env.OPENROUTER_API_KEY,
14
- * });
15
- *
16
- * const triage = await Agent.create({
17
- * name: "triage",
18
- * systemPrompt: "Classify the user's intent and transfer to the right specialist.",
19
- * model: { id: "openai/gpt-4o-mini" },
20
- * apiKey: process.env.OPENROUTER_API_KEY,
21
- * handoffs: [
22
- * billing, // auto-wrapped as Handoff.create(billing)
23
- * Handoff.create(supportAgent, { inputFilter: redactCreditCards }),
24
- * ],
25
- * });
26
- *
27
- * @public
28
- */
29
- import type { ZodType } from "zod";
30
- import type { SDKAgent } from "./types/agent.js";
31
- import type { HandoffDescriptor, HandoffOptions } from "./types/handoff.js";
32
- /** Recommended system-prompt prefix for senders (D215 / EC-13). */
33
- export declare const RECOMMENDED_HANDOFF_PROMPT_PREFIX: string;
34
- export declare class Handoff {
35
- private constructor();
36
- /**
37
- * Build a `HandoffDescriptor` for a target agent. Wrap with custom options
38
- * (filter / inputType / callback / whitelist / etc); pass to
39
- * `Agent.create({ handoffs: [...] })`.
40
- *
41
- * Raw `SDKAgent` instances in `handoffs[]` are auto-wrapped by the runtime
42
- * — call `Handoff.create()` explicitly only when you need to customize.
43
- */
44
- static create<TInput extends ZodType = ZodType>(target: SDKAgent, options?: HandoffOptions<TInput>): HandoffDescriptor<TInput>;
45
- }
46
- /**
47
- * Imperative escape hatch (D225). Useful for tests / programmatic flows
48
- * that need deterministic handoff without LLM routing.
49
- *
50
- * NOTE: this is a STANDALONE helper rather than a method on `SDKAgent`
51
- * to avoid invasive refactor of the agent class. Behavior is identical
52
- * to invoking the corresponding synthetic tool would be.
53
- */
54
- export declare function handoffTo(sender: SDKAgent, target: SDKAgent, message: string, options?: HandoffOptions): Promise<string>;
55
- export { HandoffLoopError, HandoffNameCollisionError, HandoffPairLoopError, HandoffReceiverDisposedError, HandoffSelfReferenceError, } from "./types/handoff.js";
@@ -1,19 +0,0 @@
1
- /**
2
- * UTC-aligned calendar window helpers (ADR D382).
3
- *
4
- * - `1h` — relative (now - 1 hour).
5
- * - `1d` — UTC midnight (current UTC day).
6
- * - `1w` — UTC monday 00:00:00 (current UTC week, Monday is week start).
7
- * - `30d` — relative 30 days.
8
- * - `365d` — relative 365 days.
9
- *
10
- * `1d` and `1w` are calendar-aligned because users expect "1 USD per day"
11
- * = "since midnight UTC", not a rolling 24h.
12
- * `30d`/`365d` are relative because nobody expects "since the 1st".
13
- *
14
- * @internal
15
- */
16
- export declare function startOfDayUtc(now?: Date): Date;
17
- export declare function startOfWeekUtc(now?: Date): Date;
18
- /** Returns the inclusive start timestamp (ms) for the given window relative to `now`. */
19
- export declare function windowStartMs(window: BudgetWindow, now?: Date): number;
@@ -1,32 +0,0 @@
1
- /**
2
- * Budget enforcement (ADRs D383, D386, EC-7/8/9).
3
- *
4
- * - `preflightCheck(name, estimatedUsd)` — em `block` mode, throw
5
- * `BudgetExceededError` antes da LLM call se qualquer limit seria
6
- * excedido (EC-9 — caller chama dentro do mutex section).
7
- * - `chargeAndCheckThresholds(name, actualUsd)` — apply charge ao
8
- * ledger + invoca onThreshold/onExceed callbacks isolated em
9
- * try/catch (EC-8).
10
- *
11
- * @internal
12
- */
13
- /**
14
- * Throws BudgetExceededError if `mode === "block"` and any limit
15
- * would be exceeded. No-op for audit/warn modes (post-charge checks
16
- * handle those).
17
- *
18
- * Caller invokes this BEFORE the LLM call.
19
- */
20
- export declare function preflightCheck(name: string, estimatedUsd: number): void;
21
- /**
22
- * Charge the budget + dispatch threshold/exceed callbacks (EC-8 isolated).
23
- *
24
- * - In `audit` mode: charge only, no callbacks.
25
- * - In `warn` mode: charge + onThreshold (80/95) + onExceed (100). No throw.
26
- * - In `block` mode: charge + onThreshold + onExceed. No throw post-call
27
- * (preflightCheck already prevented exceed for the upcoming call;
28
- * this protects against simultaneous-call races where multiple sends
29
- * each pass preflight independently — last one to charge may still
30
- * tip a limit. We document the case rather than retroactively throw).
31
- */
32
- export declare function chargeAndCheckThresholds(name: string, actualUsd: number): Promise<void>;
@@ -1,25 +0,0 @@
1
- /**
2
- * In-process Budget ledger (ADR D385).
3
- *
4
- * Singleton mutex-protected. Stores per-budget ChargeLog[] arrays;
5
- * `spentIn(window)` filters by timestamp.
6
- *
7
- * EC-6: GC eviction runs DENTRO do mesmo mutex que charge — sem race.
8
- * EC-9: charge() é called inside same critical section as preflight
9
- * check by Budget enforcement.
10
- *
11
- * Persistence cross-restart: deferred to v0.2 (JsonFile pattern).
12
- *
13
- * @internal
14
- */
15
- /** Charge a budget. Idempotent across concurrent calls via withCwdMutex. */
16
- export declare function charge(name: string, amountUsd: number): Promise<void>;
17
- /** Return total spend in the given window for `name`. Snapshot read (no mutex needed). */
18
- export declare function spentIn(name: string, window: BudgetWindow, now?: Date): number;
19
- /** Diagnostic — total logs across all budgets. */
20
- export declare function __getLogCountForTests(name?: string): number;
21
- export declare function __resetLedgerForTests(): void;
22
- /** Force GC manually (tests only). */
23
- export declare function __evictNowForTests(): Promise<void>;
24
- /** Force-insert a log at a specific timestamp (tests only). */
25
- export declare function __injectLogForTests(name: string, timestamp: number, amountUsd: number): void;
@@ -1,27 +0,0 @@
1
- /**
2
- * normalizeUsage — convert provider-shaped raw `usage` object to
3
- * canonical `TokenUsage`. Ports Hermes Agent's `normalize_usage`
4
- * (referencia/hermes-agent/agent/usage_pricing.py:672-742).
5
- *
6
- * Handles 3 API shapes:
7
- * - Anthropic Messages: 4 explicit buckets (input/output/cache_read/cache_creation).
8
- * - OpenAI Chat Completions: prompt_tokens INCLUDES cache; subtract cached_tokens.
9
- * - OpenAI Responses (Codex): input_tokens INCLUDES cache; same subtraction.
10
- *
11
- * Edge cases:
12
- * - cline#10266 — OpenAI-compat proxies (OpenRouter, Vercel AI Gateway,
13
- * Cline) routing Claude expose Anthropic-style top-level fields
14
- * (cache_read_input_tokens / cache_creation_input_tokens). Both
15
- * locations are checked with top-level fallback.
16
- * - Null/undefined fields → 0 via `int()` coerce.
17
- * - String token counts → parsed via int.
18
- * - Negative values → clamped to 0 (defensive against proxy bugs).
19
- *
20
- * @internal
21
- */
22
- export type ApiMode = "anthropic_messages" | "openai_chat_completions" | "openai_responses";
23
- export declare function inferApiMode(provider: string): ApiMode;
24
- export declare function normalizeUsage(rawUsage: unknown, opts: {
25
- provider: string;
26
- apiMode?: ApiMode;
27
- }): TokenUsage;
@@ -1,16 +0,0 @@
1
- /**
2
- * Internal Budget registry — keeps live `BudgetOptions` per name.
3
- * Singleton; no persistence (D385).
4
- *
5
- * @internal
6
- */
7
- import type { BudgetHandle, BudgetMode, BudgetOptions, BudgetSnapshot } from "../../types/budget.js";
8
- export declare function __resetRegistryForTests(): void;
9
- export declare function validateBudgetName(name: string): void;
10
- export declare function createBudget(opts: BudgetOptions): BudgetHandle;
11
- export declare function getBudget(name: string): BudgetHandle | undefined;
12
- export declare function listBudgets(): readonly BudgetHandle[];
13
- export declare function deleteBudget(name: string): boolean;
14
- export declare function snapshotAll(): readonly BudgetSnapshot[];
15
- export declare function getBudgetOptionsRaw(name: string): BudgetOptions | undefined;
16
- export declare function defaultMode(opts: BudgetOptions): BudgetMode;
@@ -1,14 +0,0 @@
1
- /**
2
- * Cosine distance between two equal-length vectors.
3
- *
4
- * Returns `1 - cos(a, b)`. Range:
5
- * - 0.0 = identical direction
6
- * - 1.0 = orthogonal
7
- * - 2.0 = opposite (rare in normalized embeddings)
8
- *
9
- * Throws on dim mismatch. (Callers MUST filter by dim before calling
10
- * — EC-2 absorbed at the store level.)
11
- *
12
- * @internal
13
- */
14
- export {};
@@ -1,15 +0,0 @@
1
- /**
2
- * Shared embed-with-graceful-degradation helper — used by both `lookup.ts`
3
- * and `store-handler.ts`. Extracted to remove the embed-failure boilerplate
4
- * clone flagged by jscpd. EC-1 absorbed: embedder failure is silent (caller
5
- * decides what to do via the boolean return).
6
- *
7
- * @internal
8
- */
9
- import type { InMemoryCacheStore } from "./store.js";
10
- import type { JsonFileCacheStore } from "./store-json.js";
11
- interface SpanLike {
12
- setAttribute(key: string, value: string | number | boolean): SpanLike;
13
- }
14
- export declare function embedOrDegrade(embedder: CacheEmbedderRuntime, prompt: string, store: InMemoryCacheStore | JsonFileCacheStore, span: SpanLike, context: "lookup" | "store"): Promise<number[] | undefined>;
15
- export {};
@@ -1,15 +0,0 @@
1
- /**
2
- * Composite cache key (ADR D253).
3
- *
4
- * Format: `${namespace}:${embedderId}:${modelId}:${hash(normalizedPrompt)}`.
5
- * Normalizes whitespace + lowercases. Hash = first 16 hex chars of SHA-256.
6
- *
7
- * @internal
8
- */
9
- export interface CacheKeyParams {
10
- namespace: string;
11
- embedderId: string;
12
- modelId: string;
13
- prompt: string;
14
- }
15
- export declare function computeCacheKey(p: CacheKeyParams): string;
@@ -1,28 +0,0 @@
1
- /**
2
- * Cache lookup handler — wired to `pre_user_send` hook (ADRs D259, D260).
3
- *
4
- * EC-1: embedder failure degrades to miss (cache is transparent).
5
- * EC-3: empty / whitespace prompt bypasses cache (avoids hash collision).
6
- * EC-5: telemetry span ends in finally even on early-return.
7
- *
8
- * @internal
9
- */
10
- import type { InMemoryCacheStore } from "./store.js";
11
- import type { JsonFileCacheStore } from "./store-json.js";
12
- export type LookupableStore = InMemoryCacheStore | JsonFileCacheStore;
13
- export interface LookupParams {
14
- prompt: string;
15
- store: LookupableStore;
16
- embedder: CacheEmbedderRuntime;
17
- threshold: number;
18
- ttl: CacheTTLConfig;
19
- namespace: string;
20
- modelId: string;
21
- }
22
- export interface LookupResult {
23
- cached: boolean;
24
- response?: string;
25
- source?: "kv" | "semantic";
26
- distance?: number;
27
- }
28
- export declare function performLookup(p: LookupParams): Promise<LookupResult>;
@@ -1,24 +0,0 @@
1
- /**
2
- * Cache store handler — wired to `post_assistant_reply` hook (ADRs D260, D266).
3
- *
4
- * EC-1: embedder failure during store is silent (LLM call already succeeded;
5
- * no cache entry written).
6
- * EC-3: empty prompt bypass.
7
- * EC-10 / D266: skip storage when the run invoked tools (replay loses
8
- * side-effects).
9
- *
10
- * @internal
11
- */
12
- import type { LookupableStore } from "./lookup.js";
13
- export interface StoreParams {
14
- prompt: string;
15
- response: string;
16
- /** D266: skip cache when tools were used. */
17
- usedTools?: boolean;
18
- store: LookupableStore;
19
- embedder: CacheEmbedderRuntime;
20
- ttl: CacheTTLConfig;
21
- namespace: string;
22
- modelId: string;
23
- }
24
- export declare function performStore(p: StoreParams): Promise<void>;
@@ -1,48 +0,0 @@
1
- /**
2
- * JSON disk-backed cache store (ADR D265).
3
- *
4
- * One file per namespace at `<dir>/<namespace>.json`. Uses
5
- * `atomicWriteText` (D60) for crash-safe writes. Debounced flush (200ms)
6
- * to coalesce bursts.
7
- *
8
- * EC-7: corrupt JSON load → log warn + treat as empty cache. Never
9
- * propagates parse errors that would block `Agent.create`.
10
- *
11
- * Layered behind `InMemoryCacheStore` — disk is just persistence; all
12
- * lookups still hit the in-memory Map for O(1) KV / O(N) vector scan.
13
- *
14
- * @internal
15
- */
16
- import type { CacheEntry, CacheStats } from "../../types/cache.js";
17
- import { type CacheStore } from "./store.js";
18
- export declare class JsonFileCacheStore implements CacheStore {
19
- private readonly dir;
20
- private readonly namespace;
21
- private readonly inner;
22
- private flushTimer;
23
- private dirty;
24
- constructor(dir: string, namespace: string, maxEntries: number);
25
- /** Hydrate from disk. EC-7: corrupt file → empty cache. */
26
- hydrate(): Promise<void>;
27
- kvGet(key: string, now: number): CacheEntry | undefined;
28
- semanticSearch(vector: ReadonlyArray<number>, threshold: number, embedderId: string, namespace: string, now: number): {
29
- entry: CacheEntry;
30
- distance: number;
31
- } | undefined;
32
- set(entry: CacheEntry): void;
33
- delete(key: string): void;
34
- clear(): Promise<void>;
35
- stats(): CacheStats;
36
- evictExpired(now: number): number;
37
- /** Force write the current snapshot. Called on shutdown / clear. */
38
- flush(): Promise<void>;
39
- /** Counters proxied to inner. */
40
- incrementKvHits(): void;
41
- incrementSemanticHits(): void;
42
- incrementMisses(): void;
43
- incrementExcluded(): void;
44
- incrementEmbedderFailures(): void;
45
- private filePath;
46
- private markDirty;
47
- private writeSnapshot;
48
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * Cache store interface + in-memory implementation (ADRs D252, D259, D261).
3
- *
4
- * INVARIANT (EC-9, EC-13): KV map and vector view are the SAME Map.
5
- * `semanticSearch` iterates `Map.values()`. No parallel list. `set` replaces
6
- * by key (Map semantics) — no duplicate-on-race possible.
7
- *
8
- * EC-2: `semanticSearch` filters by `embedderId === currentEmbedderId &&
9
- * vector.length === currentDim` before cosine compare. Protects against
10
- * dim mismatch when disk-loaded entries used a different embedder.
11
- *
12
- * @internal
13
- */
14
- export interface CacheStore {
15
- kvGet(key: string, now: number): CacheEntry | undefined;
16
- semanticSearch(vector: ReadonlyArray<number>, threshold: number, embedderId: string, namespace: string, now: number): {
17
- entry: CacheEntry;
18
- distance: number;
19
- } | undefined;
20
- set(entry: CacheEntry): void;
21
- delete(key: string): void;
22
- clear(): Promise<void>;
23
- stats(): CacheStats;
24
- evictExpired(now: number): number;
25
- /** For persistence backends — bulk import. */
26
- loadAll?(entries: ReadonlyArray<CacheEntry>): void;
27
- /** For persistence backends — snapshot for serialization. */
28
- dump?(): ReadonlyArray<CacheEntry>;
29
- }
30
- export declare class InMemoryCacheStore implements CacheStore {
31
- private readonly maxEntries;
32
- private readonly map;
33
- private readonly counters;
34
- constructor(maxEntries: number);
35
- kvGet(key: string, now: number): CacheEntry | undefined;
36
- private isEligibleForSearch;
37
- semanticSearch(vector: ReadonlyArray<number>, threshold: number, embedderId: string, namespace: string, now: number): {
38
- entry: CacheEntry;
39
- distance: number;
40
- } | undefined;
41
- set(entry: CacheEntry): void;
42
- delete(key: string): void;
43
- clear(): Promise<void>;
44
- stats(): CacheStats;
45
- evictExpired(now: number): number;
46
- loadAll(entries: ReadonlyArray<CacheEntry>): void;
47
- dump(): ReadonlyArray<CacheEntry>;
48
- /** Internal helpers for counters (used by lookup/store handlers). */
49
- incrementKvHits(): void;
50
- incrementSemanticHits(): void;
51
- incrementMisses(): void;
52
- incrementExcluded(): void;
53
- incrementEmbedderFailures(): void;
54
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * OTel telemetry for semantic cache (ADR D262).
3
- *
4
- * Spans:
5
- * - `cache.lookup` — per `pre_user_send`. Attributes: namespace, embedder.id,
6
- * hit (kv|semantic|miss), distance, ttl_remaining_s, bypass_reason.
7
- * - `cache.store` — per `post_assistant_reply`. Attributes: bypass_reason, stored.
8
- *
9
- * @internal
10
- */
11
- export declare function startCacheLookupSpan(info: {
12
- namespace: string;
13
- embedderId: string;
14
- }): SpanLike;
15
- export declare function startCacheStoreSpan(info: {
16
- namespace: string;
17
- embedderId: string;
18
- }): SpanLike;
19
- /** Test seam — reset tracer cache so a fresh require attempt happens. */
20
- export declare function __resetCacheTelemetryForTests(): void;
@@ -1,11 +0,0 @@
1
- /**
2
- * TTL string parser. Accepts:
3
- * - number → treated as SECONDS
4
- * - string `"\d+(s|m|h|d|w)"` → seconds/minutes/hours/days/weeks
5
- *
6
- * EC-8: `"0s"` / `0` returns 0 (effectively disables cache for that entry).
7
- * Negative numbers throw `CacheInvalidTtlError`.
8
- *
9
- * @internal
10
- */
11
- export declare function parseTtlMs(input: string | number): number;
@@ -1,16 +0,0 @@
1
- import type { SDKProvider } from "../../types/providers.js";
2
- import type { SDKModel, SDKRepository, SDKUser } from "../../types/theokit.js";
3
- /** Fixture user identity (matches `tests/golden/theokit/me.json`). */
4
- export declare const FIXTURE_USER: SDKUser;
5
- /** Fixture model catalog (matches `tests/golden/theokit/models.json`). */
6
- export declare const FIXTURE_MODELS: SDKModel[];
7
- /** Fixture connected repos (matches `tests/golden/theokit/repositories.json`). */
8
- export declare const FIXTURE_REPOSITORIES: SDKRepository[];
9
- /**
10
- * Fixture provider catalog. Covers chat, web_search, image, and embedding
11
- * capabilities. The `setupSchema` is intentionally generic JSON Schema —
12
- * consumers drive UI from these definitions.
13
- *
14
- * Public and secret-free by design — no tokens or API key examples.
15
- */
16
- export declare const FIXTURE_PROVIDERS: SDKProvider[];