@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
@@ -0,0 +1,209 @@
1
+ ---
2
+ user-invocable: false
3
+ description: Agent lifecycle, sending messages, streaming, and disposal patterns for @theokit/sdk.
4
+ paths:
5
+ - "**/*agent*"
6
+ - "**/*Agent*"
7
+ - "**/sdk.*"
8
+ ---
9
+
10
+ # TheoKit SDK -- Agent Core
11
+
12
+ Quick reference for Agent lifecycle, Run streaming, and disposal.
13
+
14
+ ## Agent.create
15
+
16
+ ```typescript
17
+ import { Agent } from "@theokit/sdk";
18
+
19
+ const agent = await Agent.create({
20
+ apiKey: process.env.THEOKIT_API_KEY!,
21
+ model: { id: "google/gemini-2.0-flash-001" },
22
+ local: { cwd: process.cwd() },
23
+ });
24
+ ```
25
+
26
+ Returns an `SDKAgent`. Local agents get `agent-<uuid>` IDs; cloud agents get `bc-<uuid>`.
27
+
28
+ ### AgentOptions (key fields)
29
+
30
+ | Property | Type | Notes |
31
+ |---|---|---|
32
+ | `model` | `ModelSelection` | Required for local; `{ id, params? }`. |
33
+ | `apiKey` | `string` | Falls back to `THEOKIT_API_KEY` env. |
34
+ | `local` | `{ cwd, settingSources?, sandboxOptions? }` | Local runtime config. |
35
+ | `cloud` | `CloudOptions` | Cloud runtime config (repos, autoCreatePR, envVars). |
36
+ | `systemPrompt` | `string \| (ctx: SystemPromptContext) => string` | Static string or async resolver. |
37
+ | `mcpServers` | `Record<string, McpServerConfig>` | Inline MCP server definitions. |
38
+ | `agents` | `Record<string, AgentDefinition>` | Subagent definitions. |
39
+ | `tools` | `CustomTool[]` | Inline custom tools (local only). |
40
+ | `memory` | `MemoryOptions` | Durable memory config. |
41
+ | `handoffs` | `Array<SDKAgent \| Handoff>` | Peer-to-peer agent handoffs. |
42
+ | `conversationStorage` | `ConversationStorageAdapter` | Pluggable persistence. |
43
+
44
+ ## Agent.prompt (one-shot)
45
+
46
+ ```typescript
47
+ const result = await Agent.prompt("What does the auth middleware do?", {
48
+ apiKey: process.env.THEOKIT_API_KEY!,
49
+ model: { id: "google/gemini-2.0-flash-001" },
50
+ local: { cwd: process.cwd() },
51
+ });
52
+ // result: { id, status, result?, model?, durationMs?, git? }
53
+ ```
54
+
55
+ Pass `throwOnError: true` to reject with `AgentRunError` instead of resolving with `status: 'error'`.
56
+
57
+ ## agent.send and Run
58
+
59
+ ```typescript
60
+ const run = await agent.send("Find the bug in src/auth.ts");
61
+ ```
62
+
63
+ ### Run interface
64
+
65
+ | Member | Type | Description |
66
+ |---|---|---|
67
+ | `id` | `string` | Run identifier. |
68
+ | `status` | `RunStatus` | `"running" \| "finished" \| "error" \| "cancelled"` |
69
+ | `stream()` | `AsyncGenerator<SDKMessage>` | Normalized event stream. |
70
+ | `wait()` | `Promise<RunResult>` | Block until finished. |
71
+ | `cancel()` | `Promise<void>` | Cancel the run. |
72
+ | `conversation()` | `Promise<ConversationTurn[]>` | Structured turn history. |
73
+ | `onDidChangeStatus(fn)` | `() => void` | Status change listener; returns unsubscribe. |
74
+
75
+ ### Streaming SDKMessage types
76
+
77
+ ```typescript
78
+ for await (const event of run.stream()) {
79
+ switch (event.type) {
80
+ case "assistant": /* event.message.content: (TextBlock | ToolUseBlock)[] */ break;
81
+ case "thinking": /* event.text, event.thinking_duration_ms? */ break;
82
+ case "tool_call": /* event.name, event.status, event.args?, event.result? */ break;
83
+ case "status": /* event.status: cloud lifecycle transitions */ break;
84
+ case "task": /* event.text: task milestones */ break;
85
+ case "request": /* event.request_id: awaiting user input */ break;
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### Per-send options
91
+
92
+ ```typescript
93
+ await agent.send("Plan the refactor", {
94
+ model: { id: "claude-sonnet-4-6", params: [{ id: "thinking", value: "high" }] },
95
+ systemPrompt: "Focus on performance.",
96
+ signal: abortController.signal,
97
+ onDelta: ({ update }) => { /* InteractionUpdate */ },
98
+ onStep: ({ step }) => { /* ConversationStep */ },
99
+ });
100
+ ```
101
+
102
+ ## Agent.resume
103
+
104
+ ```typescript
105
+ const agent = await Agent.resume("bc-abc123", {
106
+ apiKey: process.env.THEOKIT_API_KEY!,
107
+ });
108
+ ```
109
+
110
+ Runtime auto-detected from ID prefix. Inline `mcpServers` and `tools` are NOT persisted -- re-pass on resume.
111
+
112
+ ## Agent.getOrCreate
113
+
114
+ ```typescript
115
+ const agent = await Agent.getOrCreate(`tg-user-${userId}`, {
116
+ apiKey: process.env.THEOKIT_API_KEY!,
117
+ model: { id: "claude-sonnet-4-6" },
118
+ local: { cwd: process.cwd() },
119
+ });
120
+ ```
121
+
122
+ Tries resume first; on `UnknownAgentError` falls through to create.
123
+
124
+ ## Agent.get / Agent.list / Agent.listRuns
125
+
126
+ ```typescript
127
+ const info = await Agent.get(agentId);
128
+ const { items, nextCursor } = await Agent.list({ runtime: "local", cwd: process.cwd() });
129
+ const { items: runs } = await Agent.listRuns(agentId);
130
+ ```
131
+
132
+ ## createAgentFactory
133
+
134
+ ```typescript
135
+ import { createAgentFactory } from "@theokit/sdk";
136
+
137
+ const factory = createAgentFactory({
138
+ apiKey: process.env.THEOKIT_API_KEY!,
139
+ model: { id: "claude-sonnet-4-6" },
140
+ local: { cwd: process.cwd() },
141
+ systemPrompt: "You are a helpful assistant.",
142
+ });
143
+ const agent = await factory.getOrCreate(`user-${userId}`);
144
+ ```
145
+
146
+ ## Agent.builder (fluent API)
147
+
148
+ ```typescript
149
+ const agent = await Agent.builder()
150
+ .apiKey(process.env.THEOKIT_API_KEY!)
151
+ .model({ id: "claude-sonnet-4-6" })
152
+ .local({ cwd: process.cwd() })
153
+ .tools([myTool])
154
+ .getOrCreate(`user-${userId}`);
155
+ ```
156
+
157
+ ## Agent.generateObject / Agent.streamObject
158
+
159
+ ```typescript
160
+ import { z } from "zod";
161
+
162
+ const { object } = await Agent.generateObject({
163
+ schema: z.object({ title: z.string(), year: z.number().nullable() }),
164
+ prompt: "Fact card about jazz.",
165
+ model: { id: "google/gemini-2.0-flash-001" },
166
+ local: { cwd: process.cwd() },
167
+ });
168
+
169
+ for await (const evt of Agent.streamObject({ schema, prompt, model, local })) {
170
+ if (evt.type === "partial") render(evt.partial);
171
+ if (evt.type === "complete") finalize(evt.object);
172
+ }
173
+ ```
174
+
175
+ ## Disposal patterns
176
+
177
+ ```typescript
178
+ // Preferred: await using (auto-dispose on block exit)
179
+ await using agent = await Agent.create({ /* ... */ });
180
+
181
+ // Explicit dispose
182
+ await agent[Symbol.asyncDispose]();
183
+
184
+ // Fire-and-forget close
185
+ agent.close();
186
+
187
+ // Reload config without disposing
188
+ await agent.reload();
189
+ ```
190
+
191
+ ## Agent.registry (production)
192
+
193
+ ```typescript
194
+ Agent.registry.configure({ maxAgents: 1000, idleTimeoutMs: 15 * 60 * 1000 });
195
+ Agent.registry.size();
196
+ Agent.registry.evict("agent-42");
197
+ await Agent.registry.evictAll(); // graceful shutdown
198
+ ```
199
+
200
+ ## Cancellation
201
+
202
+ ```typescript
203
+ const run = await agent.send(message, { signal: request.signal });
204
+ // On abort: AgentRunError with code "aborted"
205
+
206
+ // Compose with timeout:
207
+ const composed = AbortSignal.any([request.signal, AbortSignal.timeout(30_000)]);
208
+ await agent.send(message, { signal: composed });
209
+ ```
@@ -0,0 +1,176 @@
1
+ ---
2
+ user-invocable: false
3
+ paths:
4
+ - "**/*budget*"
5
+ - "**/*Budget*"
6
+ - "**/*cost*"
7
+ - "**/*token*"
8
+ description: TheoKit SDK Budget API reference — cost tracking, token budget enforcement, usage reporting
9
+ ---
10
+
11
+ # TheoKit Budget
12
+
13
+ Token cost enforcement primitive. Track, warn, and block LLM spend at the
14
+ process level with stacked USD limits and configurable enforcement modes.
15
+
16
+ ## Quick start
17
+
18
+ ```typescript
19
+ import { Budget } from "@theokit/sdk";
20
+
21
+ const handle = Budget.create({
22
+ name: "my-bot",
23
+ scope: "process",
24
+ mode: "warn",
25
+ limits: [
26
+ { window: "1h", limitUsd: 5.0 },
27
+ { window: "1d", limitUsd: 50.0 },
28
+ ],
29
+ onThreshold: (event) => {
30
+ console.warn(`Budget ${event.budgetName}: ${event.threshold * 100}% of ${event.window} limit`);
31
+ },
32
+ onExceed: (event) => {
33
+ console.error(`Budget ${event.budgetName}: exceeded ${event.window} limit`);
34
+ },
35
+ });
36
+ ```
37
+
38
+ ## Enforcement modes
39
+
40
+ | Mode | Behavior |
41
+ |---|---|
42
+ | `"audit"` | Log only. Never throws, never blocks. |
43
+ | `"warn"` | Callbacks fire at 80%, 95%, and 100% thresholds. No throw. Default. |
44
+ | `"block"` | Preflight throw (`BudgetExceededError`) BEFORE the LLM call when would-exceed. |
45
+
46
+ ## Stacked limits
47
+
48
+ Pass multiple limits. ANY exceeded limit triggers enforcement:
49
+
50
+ ```typescript
51
+ Budget.create({
52
+ name: "emergency-stop",
53
+ scope: "process",
54
+ mode: "block",
55
+ limits: [
56
+ { window: "1h", limitUsd: 2.0 },
57
+ { window: "1d", limitUsd: 10.0 },
58
+ { window: "30d", limitUsd: 100.0 },
59
+ ],
60
+ });
61
+ ```
62
+
63
+ Empty `limits[]` is valid: pure tracking with no threshold/exceed callbacks.
64
+
65
+ ## Time windows
66
+
67
+ | Window | Alignment |
68
+ |---|---|
69
+ | `"1h"` | Relative (last 60 minutes) |
70
+ | `"1d"` | UTC midnight boundary |
71
+ | `"1w"` | Monday 00:00 UTC |
72
+ | `"30d"` | 1st of month 00:00 UTC |
73
+ | `"365d"` | Jan 1 00:00 UTC |
74
+
75
+ ## Managing budgets
76
+
77
+ ```typescript
78
+ // Retrieve a budget handle
79
+ const handle = Budget.get("my-bot");
80
+
81
+ // Check spend and remaining
82
+ handle?.spentIn("1d"); // USD spent in current day window
83
+ handle?.remainingIn("1d"); // USD remaining before limit
84
+
85
+ // List all active budgets
86
+ const budgets = Budget.list();
87
+
88
+ // Snapshot all windows for all budgets
89
+ const snapshots = Budget.snapshot();
90
+ // [{ name, window, spentUsd, limitUsd, ratio }, ...]
91
+
92
+ // Delete a budget
93
+ Budget.delete("my-bot");
94
+ ```
95
+
96
+ ## Type reference
97
+
98
+ ```typescript
99
+ type BudgetScope = "agent" | "call" | "process";
100
+ type BudgetWindow = "1h" | "1d" | "1w" | "30d" | "365d";
101
+ type BudgetMode = "audit" | "warn" | "block";
102
+
103
+ interface BudgetLimit {
104
+ readonly window: BudgetWindow;
105
+ readonly limitUsd: number;
106
+ }
107
+
108
+ interface BudgetOptions {
109
+ readonly name: string; // must match ^[a-z0-9][a-z0-9_-]*$
110
+ readonly scope: BudgetScope;
111
+ readonly limits: ReadonlyArray<BudgetLimit>;
112
+ readonly mode?: BudgetMode; // default "warn"
113
+ readonly onThreshold?: (event: BudgetThresholdEvent) => void | Promise<void>;
114
+ readonly onExceed?: (event: BudgetExceedEvent) => void | Promise<void>;
115
+ }
116
+
117
+ interface BudgetHandle {
118
+ readonly name: string;
119
+ readonly mode: BudgetMode;
120
+ readonly scope: BudgetScope;
121
+ readonly limits: ReadonlyArray<BudgetLimit>;
122
+ spentIn(window: BudgetWindow): number;
123
+ remainingIn(window: BudgetWindow): number;
124
+ }
125
+
126
+ interface BudgetSnapshot {
127
+ readonly name: string;
128
+ readonly window: BudgetWindow;
129
+ readonly spentUsd: number;
130
+ readonly limitUsd: number;
131
+ readonly ratio: number;
132
+ }
133
+
134
+ interface BudgetThresholdEvent {
135
+ readonly budgetName: string;
136
+ readonly window: BudgetWindow;
137
+ readonly threshold: 0.8 | 0.95;
138
+ readonly spentUsd: number;
139
+ readonly limitUsd: number;
140
+ }
141
+
142
+ interface BudgetExceedEvent {
143
+ readonly budgetName: string;
144
+ readonly window: BudgetWindow;
145
+ readonly spentUsd: number;
146
+ readonly limitUsd: number;
147
+ readonly mode: BudgetMode;
148
+ }
149
+ ```
150
+
151
+ ## Wiring with agents
152
+
153
+ Budget enforcement integrates with `agent.send()`. When a budget is active
154
+ and mode is `"block"`, a preflight check runs before the LLM call. If the
155
+ estimated cost would exceed a limit, `BudgetExceededError` is thrown.
156
+
157
+ The `turn-ended` InteractionUpdate carries token usage that feeds the budget
158
+ ledger automatically:
159
+
160
+ ```typescript
161
+ { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens }
162
+ ```
163
+
164
+ ## Errors
165
+
166
+ | Error | When |
167
+ |---|---|
168
+ | `ConfigurationError` | Invalid `name` (grammar violation) or duplicate `name` |
169
+ | `BudgetExceededError` | `mode: "block"` and spend would exceed a limit |
170
+
171
+ ## Known limitations
172
+
173
+ - v1 supports `scope: "process"` only. `"agent"` and `"call"` scopes are
174
+ reserved for future multi-tenant scenarios.
175
+ - In-flight `agent.send` calls referencing a deleted budget treat subsequent
176
+ charges as a silent no-op with a stderr warning.
@@ -0,0 +1,139 @@
1
+ ---
2
+ user-invocable: false
3
+ paths:
4
+ - "**/.theokit/**"
5
+ - "**/config.*"
6
+ - "**/theo.config.*"
7
+ description: TheoKit SDK configuration reference — .theokit/ structure, mcp.json, hooks, env vars, config discovery
8
+ ---
9
+
10
+ # TheoKit Configuration
11
+
12
+ ## Directory structure
13
+
14
+ ```
15
+ .theokit/
16
+ +-- hooks/ # one .md per hook
17
+ | +-- shell-policy.md
18
+ +-- context/ # one .md per context source
19
+ | +-- bot-readme.md
20
+ +-- skills/<name>/SKILL.md # named capability packs
21
+ +-- plugins/<name>/PLUGIN.md # plugin definitions
22
+ +-- cron/
23
+ | +-- jobs.json # local cron state (auto-created)
24
+ +-- agents/*.md # subagent definitions (name + description frontmatter)
25
+ +-- memory/ # local memory storage
26
+ ```
27
+
28
+ User-level config lives at `~/.theokit/` with the same structure.
29
+
30
+ ## Config file format (v1.5+)
31
+
32
+ Markdown + YAML frontmatter. One file per entity.
33
+
34
+ ### Hook example
35
+
36
+ ```markdown
37
+ ---
38
+ event: preToolUse
39
+ matcher: ^shell$
40
+ command: node .theokit/policy.js
41
+ ---
42
+
43
+ # Shell tool policy gate
44
+
45
+ Vets shell tool invocations before spawn.
46
+ ```
47
+
48
+ ### Disabling an entry
49
+
50
+ Rename `<name>.md` to `<name>.md.disabled` — the loader silently skips it.
51
+
52
+ ## Setting sources
53
+
54
+ `local.settingSources` controls which config layers a local agent loads:
55
+
56
+ | Value | Source |
57
+ |---|---|
58
+ | `"project"` | `.theokit/` in the workspace |
59
+ | `"user"` | `~/.theokit/` |
60
+ | `"team"` | Team settings synced from the dashboard |
61
+ | `"mdm"` | MDM-managed enterprise settings |
62
+ | `"plugins"` | Plugin-provided settings |
63
+ | `"all"` | All of the above |
64
+
65
+ Cloud agents always load project / team / plugins and ignore this field.
66
+
67
+ ```typescript
68
+ const agent = await Agent.create({
69
+ apiKey: process.env.THEOKIT_API_KEY!,
70
+ model: { id: "google/gemini-2.0-flash-001" },
71
+ local: { cwd: process.cwd(), settingSources: ["project", "user"] },
72
+ });
73
+ ```
74
+
75
+ ## Environment variables
76
+
77
+ | Env var | Purpose |
78
+ |---|---|
79
+ | `THEOKIT_API_KEY` | Default API key (user or service account) |
80
+ | `THEOKIT_REDACT_SECRETS` | Set `false` to disable secret redaction (default: `true`) |
81
+ | `OLLAMA_HOST` | Ollama server URL (default: `http://localhost:11434`) |
82
+ | `OLLAMA_API_KEY` | Bearer token for Ollama Cloud or proxy |
83
+ | `OPENROUTER_API_KEY` | OpenRouter provider key |
84
+ | `ANTHROPIC_API_KEY` | Anthropic provider key |
85
+ | `OPENAI_API_KEY` | OpenAI provider key |
86
+
87
+ ## MCP server discovery
88
+
89
+ Servers are loaded with first-match-wins precedence:
90
+
91
+ 1. `mcpServers` on `agent.send()` — fully replaces creation-time servers
92
+ 2. `mcpServers` on `Agent.create()` — used when no per-send override
93
+ 3. Plugin servers (if settingSources includes `"plugins"`)
94
+ 4. Project servers from `.theokit/mcp.json` (if settingSources includes `"project"`)
95
+ 5. User servers from `~/.theokit/mcp.json` (if settingSources includes `"user"`)
96
+
97
+ ## Context manager config
98
+
99
+ ```typescript
100
+ const agent = await Agent.create({
101
+ context: {
102
+ manager: "file", // reads .theokit/context/<name>.md
103
+ maxTokens: 1200,
104
+ },
105
+ local: { cwd: process.cwd(), settingSources: ["project"] },
106
+ });
107
+ ```
108
+
109
+ `manager: "inline"` uses `sources` passed directly in `Agent.create()`.
110
+
111
+ ## Skills config
112
+
113
+ ```typescript
114
+ const agent = await Agent.create({
115
+ skills: {
116
+ enabled: ["code-review", "test-architect"],
117
+ },
118
+ local: { cwd: process.cwd(), settingSources: ["project"] },
119
+ });
120
+ ```
121
+
122
+ Skills live at `.theokit/skills/<name>/SKILL.md` with strict YAML frontmatter
123
+ (`name`, `description` required).
124
+
125
+ ## Migration from legacy JSON
126
+
127
+ ```bash
128
+ npx theokit-migrate-config --apply
129
+ ```
130
+
131
+ Dry-run by default; `--apply` writes. Backs up originals to
132
+ `<file>.json.<unix-ts>.bak`. Legacy JSON still works in v1.x with a
133
+ deprecation warning. JSON support removed in v2.0.
134
+
135
+ ## `agent.reload()`
136
+
137
+ Re-reads filesystem config (context, skills, hooks, project MCP, subagents)
138
+ without disposing the agent or losing conversation state. Invalid files
139
+ raise `ConfigurationError`.
@@ -0,0 +1,148 @@
1
+ ---
2
+ user-invocable: false
3
+ paths:
4
+ - "**/*cron*"
5
+ - "**/*Cron*"
6
+ - "**/*job*"
7
+ - "**/*schedule*"
8
+ description: TheoKit SDK Cron jobs API reference — Cron.create, schedule syntax, job lifecycle
9
+ ---
10
+
11
+ # TheoKit Cron Jobs
12
+
13
+ Schedule Theo agent runs on a cron expression. Two runtimes mirror the agent
14
+ split: local (in-process scheduler) and cloud (Theo PaaS, pre-release).
15
+
16
+ ## Creating a job
17
+
18
+ ```typescript
19
+ import { Cron } from "@theokit/sdk";
20
+
21
+ const job = await Cron.create({
22
+ cron: "0 9 * * *", // every day at 09:00
23
+ timezone: "America/Sao_Paulo",
24
+ message: "Summarize yesterday's commits and post to #engineering",
25
+ agent: {
26
+ apiKey: process.env.THEOKIT_API_KEY!,
27
+ model: { id: "google/gemini-2.0-flash-001" },
28
+ local: { cwd: process.cwd() },
29
+ },
30
+ });
31
+
32
+ await Cron.start(); // required for local jobs to fire
33
+ ```
34
+
35
+ ## Agent binding
36
+
37
+ Pass exactly one of:
38
+
39
+ - **`agent`** (full `AgentOptions`) — a fresh agent is created on every fire.
40
+ Use for independent runs.
41
+ - **`agentId`** (string) — reuses an existing agent's conversation context
42
+ across fires. Use for continuity (e.g., weekly review building on past notes).
43
+
44
+ Setting both raises `ConfigurationError`.
45
+
46
+ ## Cron expressions
47
+
48
+ | Format | Example | Meaning |
49
+ |---|---|---|
50
+ | 5-field POSIX | `0 9 * * *` | Minute, hour, day-of-month, month, day-of-week |
51
+ | `@hourly` | `@hourly` | Every hour at minute 0 |
52
+ | `@daily` | `@daily` | Every day at midnight |
53
+ | `@weekly` | `@weekly` | Every Sunday at midnight |
54
+ | `@monthly` | `@monthly` | First day of month at midnight |
55
+ | `@yearly` | `@yearly` | January 1 at midnight |
56
+
57
+ `timezone` accepts any IANA identifier (default: `"UTC"`). Invalid expressions
58
+ throw `ConfigurationError` synchronously at create time.
59
+
60
+ ## Managing jobs
61
+
62
+ ```typescript
63
+ const { items } = await Cron.list({ runtime: "local", cwd: process.cwd() });
64
+ const job = await Cron.get(jobId);
65
+
66
+ await Cron.disable(jobId); // pause without deleting
67
+ await Cron.enable(jobId); // resume
68
+ await Cron.delete(jobId); // permanent removal
69
+ ```
70
+
71
+ ## Manual fire (off-schedule)
72
+
73
+ ```typescript
74
+ const run = await Cron.run(jobId);
75
+
76
+ for await (const event of run.stream()) {
77
+ // same SDKMessage events as any other run
78
+ }
79
+ ```
80
+
81
+ Manual fires do not update `lastRunAt` — only scheduled fires do.
82
+
83
+ ## Local scheduler lifecycle
84
+
85
+ ```typescript
86
+ await Cron.start({ cwd: process.cwd() }); // reads .theokit/cron/jobs.json
87
+ const status = await Cron.status();
88
+ // { running: true, jobCount: 3, nextFireAt: 1747... }
89
+ await Cron.stop(); // halts scheduling; does NOT delete jobs
90
+ ```
91
+
92
+ Local jobs only fire while the host process is alive. Run as `pm2` / `systemd`
93
+ service for 24/7 local scheduling.
94
+
95
+ ## Persistence
96
+
97
+ Local cron state lives in `.theokit/cron/jobs.json`. Created automatically by
98
+ `Cron.create()`. Commit it if jobs should travel with the repo; add to
99
+ `.gitignore` if environment-specific.
100
+
101
+ ## Type reference
102
+
103
+ ```typescript
104
+ interface CronJob {
105
+ id: string;
106
+ name?: string;
107
+ cron: string;
108
+ timezone?: string;
109
+ message: string | SDKUserMessage;
110
+ agent?: AgentOptions; // mutually exclusive with agentId
111
+ agentId?: string;
112
+ enabled: boolean;
113
+ status: "scheduled" | "running" | "paused" | "errored";
114
+ runtime: "local" | "cloud";
115
+ lastRunAt?: number;
116
+ nextRunAt?: number;
117
+ createdAt: number;
118
+ }
119
+
120
+ interface CronCreateOptions {
121
+ cron: string;
122
+ message: string | SDKUserMessage;
123
+ agent?: AgentOptions;
124
+ agentId?: string;
125
+ name?: string;
126
+ timezone?: string;
127
+ enabled?: boolean; // defaults to true
128
+ apiKey?: string;
129
+ }
130
+
131
+ interface CronSchedulerStatus {
132
+ running: boolean;
133
+ jobCount: number;
134
+ nextFireAt?: number;
135
+ lastError?: { jobId: string; message: string; at: number };
136
+ }
137
+ ```
138
+
139
+ ## Cloud jobs (pre-release)
140
+
141
+ Cloud jobs use Theo PaaS and do not need `Cron.start()`. Pass `agent.cloud`
142
+ to create a cloud-scheduled job. Pre-release — not yet GA.
143
+
144
+ ## Known limitations
145
+
146
+ - Local jobs only fire while the host process is alive.
147
+ - In-flight fires are not resumed if the host process crashes mid-run.
148
+ - `Cron.run()` (manual fire) does not update `lastRunAt`.