@theokit/sdk 1.5.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 (369) hide show
  1. package/CHANGELOG.md +1571 -0
  2. package/LICENSE +201 -0
  3. package/README.md +80 -0
  4. package/bin/theokit-migrate-config.mjs +269 -0
  5. package/bin/theokit-migrate-memory.mjs +116 -0
  6. package/dist/agent-builder.d.ts +52 -0
  7. package/dist/agent-factory.d.ts +39 -0
  8. package/dist/agent.d.ts +175 -0
  9. package/dist/batch.d.ts +11 -0
  10. package/dist/budget.d.ts +48 -0
  11. package/dist/cache.d.ts +74 -0
  12. package/dist/cron-1yxL3K2S.d.cts +221 -0
  13. package/dist/cron-BYVdYzob.d.ts +221 -0
  14. package/dist/cron.cjs +14655 -0
  15. package/dist/cron.cjs.map +1 -0
  16. package/dist/cron.d.cts +3 -0
  17. package/dist/cron.d.ts +71 -0
  18. package/dist/cron.js +14652 -0
  19. package/dist/cron.js.map +1 -0
  20. package/dist/define-tool.d.ts +35 -0
  21. package/dist/errors-CK8brCJ1.d.cts +448 -0
  22. package/dist/errors-CvAeEWgE.d.ts +448 -0
  23. package/dist/errors.cjs +255 -0
  24. package/dist/errors.cjs.map +1 -0
  25. package/dist/errors.d.cts +3 -0
  26. package/dist/errors.d.ts +356 -0
  27. package/dist/errors.js +238 -0
  28. package/dist/errors.js.map +1 -0
  29. package/dist/eval.cjs +14826 -0
  30. package/dist/eval.cjs.map +1 -0
  31. package/dist/eval.d.cts +35 -0
  32. package/dist/eval.d.ts +35 -0
  33. package/dist/eval.js +14821 -0
  34. package/dist/eval.js.map +1 -0
  35. package/dist/generate-object.d.ts +67 -0
  36. package/dist/handoff.d.ts +55 -0
  37. package/dist/index.cjs +17127 -0
  38. package/dist/index.cjs.map +1 -0
  39. package/dist/index.d.cts +1878 -0
  40. package/dist/index.d.ts +24 -0
  41. package/dist/index.js +17095 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/internal/agent-loop/loop-types.d.ts +29 -0
  44. package/dist/internal/agent-loop/loop.d.ts +2 -0
  45. package/dist/internal/agent-loop/message-builders.d.ts +6 -0
  46. package/dist/internal/agent-loop/tool-dispatch.d.ts +4 -0
  47. package/dist/internal/agent-loop/usage-and-cost.d.ts +25 -0
  48. package/dist/internal/budget/calendar-window.d.ts +19 -0
  49. package/dist/internal/budget/compute-cost.d.ts +28 -0
  50. package/dist/internal/budget/enforcement.d.ts +32 -0
  51. package/dist/internal/budget/ledger.d.ts +25 -0
  52. package/dist/internal/budget/normalize-usage.d.ts +27 -0
  53. package/dist/internal/budget/pricing-registry.d.ts +36 -0
  54. package/dist/internal/budget/registry.d.ts +16 -0
  55. package/dist/internal/budget/usage-accumulator.d.ts +31 -0
  56. package/dist/internal/cache/cosine.d.ts +14 -0
  57. package/dist/internal/cache/embed-helper.d.ts +15 -0
  58. package/dist/internal/cache/key.d.ts +15 -0
  59. package/dist/internal/cache/lookup.d.ts +28 -0
  60. package/dist/internal/cache/store-handler.d.ts +24 -0
  61. package/dist/internal/cache/store-json.d.ts +48 -0
  62. package/dist/internal/cache/store.d.ts +54 -0
  63. package/dist/internal/cache/telemetry.d.ts +20 -0
  64. package/dist/internal/cache/ttl.d.ts +11 -0
  65. package/dist/internal/catalog/fixtures.d.ts +16 -0
  66. package/dist/internal/catalog/local-models.d.ts +24 -0
  67. package/dist/internal/cron/run-job.d.ts +1 -0
  68. package/dist/internal/cron/scheduler.d.ts +1 -0
  69. package/dist/internal/cron/store.d.ts +1 -0
  70. package/dist/internal/cron/validate.d.ts +1 -0
  71. package/dist/internal/env.d.ts +1 -0
  72. package/dist/internal/errors/mappers/anthropic.d.ts +30 -0
  73. package/dist/internal/errors/mappers/bedrock.d.ts +16 -0
  74. package/dist/internal/errors/mappers/ollama.d.ts +41 -0
  75. package/dist/internal/errors/mappers/openai-compatible.d.ts +25 -0
  76. package/dist/internal/errors/mappers/shared.d.ts +10 -0
  77. package/dist/internal/errors/mappers/vertex.d.ts +15 -0
  78. package/dist/internal/eval/aggregate.d.ts +9 -0
  79. package/dist/internal/eval/dataset-iter.d.ts +9 -0
  80. package/dist/internal/eval/runner.d.ts +9 -0
  81. package/dist/internal/eval/single-flight.d.ts +16 -0
  82. package/dist/internal/eval/telemetry.d.ts +23 -0
  83. package/dist/internal/fixture-mode.d.ts +16 -0
  84. package/dist/internal/handoff/dispatcher.d.ts +29 -0
  85. package/dist/internal/handoff/registry.d.ts +23 -0
  86. package/dist/internal/handoff/telemetry.d.ts +18 -0
  87. package/dist/internal/handoff/tool-injector.d.ts +34 -0
  88. package/dist/internal/http.d.ts +1 -0
  89. package/dist/internal/ids.d.ts +1 -0
  90. package/dist/internal/judge/judge-call.d.ts +35 -0
  91. package/dist/internal/judge/parse-verdict.d.ts +11 -0
  92. package/dist/internal/judge/types.d.ts +17 -0
  93. package/dist/internal/llm/anthropic-shared.d.ts +89 -0
  94. package/dist/internal/llm/anthropic.d.ts +9 -0
  95. package/dist/internal/llm/bedrock-anthropic.d.ts +36 -0
  96. package/dist/internal/llm/bedrock-token-cache.d.ts +18 -0
  97. package/dist/internal/llm/credential-pool-context.d.ts +11 -0
  98. package/dist/internal/llm/credential-pool-types.d.ts +22 -0
  99. package/dist/internal/llm/credential-pool.d.ts +18 -0
  100. package/dist/internal/llm/fallback-client.d.ts +1 -0
  101. package/dist/internal/llm/fault-injection.d.ts +50 -0
  102. package/dist/internal/llm/finish.d.ts +1 -0
  103. package/dist/internal/llm/model-identifier.d.ts +24 -0
  104. package/dist/internal/llm/ollama-native.d.ts +27 -0
  105. package/dist/internal/llm/openai.d.ts +9 -0
  106. package/dist/internal/llm/pool-aware-client.d.ts +16 -0
  107. package/dist/internal/llm/router.d.ts +17 -0
  108. package/dist/internal/llm/sse.d.ts +9 -0
  109. package/dist/internal/llm/stream-relay.d.ts +17 -0
  110. package/dist/internal/llm/types.d.ts +70 -0
  111. package/dist/internal/llm/vertex-anthropic.d.ts +40 -0
  112. package/dist/internal/llm/vertex-auth.d.ts +30 -0
  113. package/dist/internal/llm/vertex-gemini.d.ts +28 -0
  114. package/dist/internal/llm/vertex-router.d.ts +21 -0
  115. package/dist/internal/mcp/client.d.ts +16 -0
  116. package/dist/internal/memory/active-memory-cache.d.ts +10 -0
  117. package/dist/internal/memory/active-memory.d.ts +45 -0
  118. package/dist/internal/memory/adapters/catalog.d.ts +1 -0
  119. package/dist/internal/memory/adapters/deepinfra-embedding.d.ts +2 -0
  120. package/dist/internal/memory/adapters/mistral-embedding.d.ts +2 -0
  121. package/dist/internal/memory/adapters/ollama-embedding.d.ts +34 -0
  122. package/dist/internal/memory/adapters/openai-compatible.d.ts +23 -0
  123. package/dist/internal/memory/adapters/openai-embedding.d.ts +2 -0
  124. package/dist/internal/memory/adapters/openrouter-embedding.d.ts +2 -0
  125. package/dist/internal/memory/adapters/voyage-embedding.d.ts +2 -0
  126. package/dist/internal/memory/atomic-write.d.ts +7 -0
  127. package/dist/internal/memory/chunk-markdown.d.ts +2 -0
  128. package/dist/internal/memory/circuit-breaker.d.ts +22 -0
  129. package/dist/internal/memory/cwd-mutex.d.ts +1 -0
  130. package/dist/internal/memory/dreaming/diary.d.ts +4 -0
  131. package/dist/internal/memory/dreaming/phases.d.ts +15 -0
  132. package/dist/internal/memory/dreaming/run.d.ts +10 -0
  133. package/dist/internal/memory/embedding-adapter.d.ts +42 -0
  134. package/dist/internal/memory/embedding-cache.d.ts +1 -0
  135. package/dist/internal/memory/index-db.d.ts +10 -0
  136. package/dist/internal/memory/index-manager-dispatch.d.ts +23 -0
  137. package/dist/internal/memory/index-manager.d.ts +68 -0
  138. package/dist/internal/memory/index-schema.d.ts +21 -0
  139. package/dist/internal/memory/lance-index.d.ts +32 -0
  140. package/dist/internal/memory/lance-memory-adapter.d.ts +43 -0
  141. package/dist/internal/memory/markdown-store.d.ts +16 -0
  142. package/dist/internal/memory/memory-index.d.ts +52 -0
  143. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +15 -0
  144. package/dist/internal/memory/migration.d.ts +9 -0
  145. package/dist/internal/memory/reader.d.ts +8 -0
  146. package/dist/internal/memory/session-loader.d.ts +1 -0
  147. package/dist/internal/memory/session-summary-writer.d.ts +2 -0
  148. package/dist/internal/memory/sqlite-vec-loader.d.ts +3 -0
  149. package/dist/internal/memory/tools.d.ts +14 -0
  150. package/dist/internal/memory/transcript-store.d.ts +1 -0
  151. package/dist/internal/memory/types.d.ts +17 -0
  152. package/dist/internal/memory/vec-index.d.ts +28 -0
  153. package/dist/internal/memory/wiki-loader.d.ts +2 -0
  154. package/dist/internal/observability/tracer-loader.d.ts +20 -0
  155. package/dist/internal/persistence/atomic-write.d.ts +1 -0
  156. package/dist/internal/persistence/conversation-storage-fs.d.ts +37 -0
  157. package/dist/internal/persistence/conversation-storage-memory.d.ts +24 -0
  158. package/dist/internal/persistence/cwd-mutex.d.ts +1 -0
  159. package/dist/internal/persistence/file-lock.d.ts +14 -0
  160. package/dist/internal/persistence/fts5-sanitize.d.ts +16 -0
  161. package/dist/internal/persistence/markdown-config-loader.d.ts +35 -0
  162. package/dist/internal/persistence/paths.d.ts +19 -0
  163. package/dist/internal/persistence/persistence-schema.d.ts +17 -0
  164. package/dist/internal/persistence/schema-version.d.ts +13 -0
  165. package/dist/internal/persistence/sqlite-wal.d.ts +10 -0
  166. package/dist/internal/personality/context.d.ts +17 -0
  167. package/dist/internal/personality/registry.d.ts +17 -0
  168. package/dist/internal/personality/store.d.ts +27 -0
  169. package/dist/internal/personality/switch.d.ts +36 -0
  170. package/dist/internal/personality/types.d.ts +18 -0
  171. package/dist/internal/plugins/context.d.ts +31 -0
  172. package/dist/internal/plugins/manager.d.ts +37 -0
  173. package/dist/internal/plugins/types.d.ts +102 -0
  174. package/dist/internal/providers/builtin/anthropic.d.ts +2 -0
  175. package/dist/internal/providers/builtin/bedrock.d.ts +25 -0
  176. package/dist/internal/providers/builtin/gemini.d.ts +10 -0
  177. package/dist/internal/providers/builtin/index.d.ts +19 -0
  178. package/dist/internal/providers/builtin/llamacpp.d.ts +1 -0
  179. package/dist/internal/providers/builtin/lmstudio.d.ts +1 -0
  180. package/dist/internal/providers/builtin/ollama.d.ts +17 -0
  181. package/dist/internal/providers/builtin/openai.d.ts +2 -0
  182. package/dist/internal/providers/builtin/openrouter.d.ts +2 -0
  183. package/dist/internal/providers/builtin/vertex.d.ts +27 -0
  184. package/dist/internal/providers/discovery.d.ts +14 -0
  185. package/dist/internal/providers/index.d.ts +8 -0
  186. package/dist/internal/providers/registry.d.ts +12 -0
  187. package/dist/internal/providers/types.d.ts +27 -0
  188. package/dist/internal/runtime/abort-utils.d.ts +21 -0
  189. package/dist/internal/runtime/agent-factory-registry.d.ts +16 -0
  190. package/dist/internal/runtime/agent-registry-store.d.ts +61 -0
  191. package/dist/internal/runtime/agent-registry.d.ts +34 -0
  192. package/dist/internal/runtime/agent-session-store.d.ts +3 -0
  193. package/dist/internal/runtime/agent-session.d.ts +2 -0
  194. package/dist/internal/runtime/async-local-storage.d.ts +20 -0
  195. package/dist/internal/runtime/async-semaphore.d.ts +24 -0
  196. package/dist/internal/runtime/budget.d.ts +36 -0
  197. package/dist/internal/runtime/cloud-agent.d.ts +1 -0
  198. package/dist/internal/runtime/cloud-config-serializer.d.ts +3 -0
  199. package/dist/internal/runtime/cloud-payload-types.d.ts +56 -0
  200. package/dist/internal/runtime/cloud-run.d.ts +1 -0
  201. package/dist/internal/runtime/cloud-tool-parity.d.ts +1 -0
  202. package/dist/internal/runtime/context-aggregator.d.ts +26 -0
  203. package/dist/internal/runtime/context-discovery-runner.d.ts +27 -0
  204. package/dist/internal/runtime/context-discovery.d.ts +21 -0
  205. package/dist/internal/runtime/context-frontmatter.d.ts +16 -0
  206. package/dist/internal/runtime/context-import-resolver.d.ts +24 -0
  207. package/dist/internal/runtime/context-loaders.d.ts +42 -0
  208. package/dist/internal/runtime/context-manager.d.ts +11 -0
  209. package/dist/internal/runtime/context-mdc-parser.d.ts +24 -0
  210. package/dist/internal/runtime/default-model.d.ts +1 -0
  211. package/dist/internal/runtime/fixture-events.d.ts +12 -0
  212. package/dist/internal/runtime/fixture-responder.d.ts +1 -0
  213. package/dist/internal/runtime/fixture-run-base.d.ts +45 -0
  214. package/dist/internal/runtime/fixture-scripts.d.ts +21 -0
  215. package/dist/internal/runtime/fixture-types.d.ts +1 -0
  216. package/dist/internal/runtime/fork-agent.d.ts +15 -0
  217. package/dist/internal/runtime/hooks-executor.d.ts +35 -0
  218. package/dist/internal/runtime/hooks-frontmatter.d.ts +26 -0
  219. package/dist/internal/runtime/hooks-source.d.ts +22 -0
  220. package/dist/internal/runtime/live-agent-registry.d.ts +87 -0
  221. package/dist/internal/runtime/local-agent-bootstrap.d.ts +37 -0
  222. package/dist/internal/runtime/local-agent-dispatch.d.ts +57 -0
  223. package/dist/internal/runtime/local-agent-invalidate.d.ts +8 -0
  224. package/dist/internal/runtime/local-agent-memory-direct.d.ts +12 -0
  225. package/dist/internal/runtime/local-agent-memory-hooks.d.ts +41 -0
  226. package/dist/internal/runtime/local-agent-memory.d.ts +1 -0
  227. package/dist/internal/runtime/local-agent-personality-extensions.d.ts +19 -0
  228. package/dist/internal/runtime/local-agent-plugins.d.ts +13 -0
  229. package/dist/internal/runtime/local-agent-runtime-extensions.d.ts +13 -0
  230. package/dist/internal/runtime/local-agent-task-wrap.d.ts +11 -0
  231. package/dist/internal/runtime/local-agent.d.ts +1 -0
  232. package/dist/internal/runtime/local-run.d.ts +1 -0
  233. package/dist/internal/runtime/memory-store.d.ts +4 -0
  234. package/dist/internal/runtime/plugin-frontmatter.d.ts +17 -0
  235. package/dist/internal/runtime/plugins-manager.d.ts +1 -0
  236. package/dist/internal/runtime/post-run-lifecycle.d.ts +1 -0
  237. package/dist/internal/runtime/providers-manager.d.ts +1 -0
  238. package/dist/internal/runtime/real-cloud-run.d.ts +2 -0
  239. package/dist/internal/runtime/real-local-run.d.ts +2 -0
  240. package/dist/internal/runtime/run-registry.d.ts +5 -0
  241. package/dist/internal/runtime/run-until.d.ts +22 -0
  242. package/dist/internal/runtime/shell-tool.d.ts +7 -0
  243. package/dist/internal/runtime/skill-frontmatter.d.ts +1 -0
  244. package/dist/internal/runtime/skills-manager.d.ts +1 -0
  245. package/dist/internal/runtime/spawn-collect.d.ts +8 -0
  246. package/dist/internal/runtime/subagents-loader.d.ts +1 -0
  247. package/dist/internal/runtime/system-prompt/escape.d.ts +1 -0
  248. package/dist/internal/runtime/system-prompt/local-assembly.d.ts +1 -0
  249. package/dist/internal/runtime/system-prompt/pipeline.d.ts +1 -0
  250. package/dist/internal/runtime/system-prompt/providers/active-memory-provider.d.ts +1 -0
  251. package/dist/internal/runtime/system-prompt/providers/base-provider.d.ts +1 -0
  252. package/dist/internal/runtime/system-prompt/providers/context-provider.d.ts +1 -0
  253. package/dist/internal/runtime/system-prompt/providers/memory-provider.d.ts +1 -0
  254. package/dist/internal/runtime/system-prompt/providers/skills-provider.d.ts +1 -0
  255. package/dist/internal/runtime/system-prompt/safe-call.d.ts +1 -0
  256. package/dist/internal/runtime/system-prompt/types.d.ts +5 -0
  257. package/dist/internal/runtime/system-prompt.d.ts +1 -0
  258. package/dist/internal/runtime/validate-agent-options.d.ts +1 -0
  259. package/dist/internal/runtime/workspace-dir.d.ts +9 -0
  260. package/dist/internal/runtime/yaml-frontmatter.d.ts +20 -0
  261. package/dist/internal/scorers/llm-judge.d.ts +24 -0
  262. package/dist/internal/security/index.d.ts +11 -0
  263. package/dist/internal/security/path-guard.d.ts +56 -0
  264. package/dist/internal/security/redact.d.ts +21 -0
  265. package/dist/internal/structured-output-helpers.d.ts +54 -0
  266. package/dist/internal/task/registry.d.ts +61 -0
  267. package/dist/internal/task/ring-buffer.d.ts +10 -0
  268. package/dist/internal/task/store.d.ts +59 -0
  269. package/dist/internal/task/subscribe.d.ts +15 -0
  270. package/dist/internal/task/telemetry.d.ts +27 -0
  271. package/dist/internal/telemetry/adapter-registry.d.ts +2 -0
  272. package/dist/internal/telemetry/adapters/langfuse.d.ts +2 -0
  273. package/dist/internal/telemetry/adapters/posthog.d.ts +2 -0
  274. package/dist/internal/telemetry/adapters/sentry.d.ts +2 -0
  275. package/dist/internal/telemetry/safe-require.d.ts +1 -0
  276. package/dist/internal/telemetry/tracer.d.ts +18 -0
  277. package/dist/internal/tool-dispatch/repair-middleware.d.ts +34 -0
  278. package/dist/internal/tool-dispatch/strip-think.d.ts +22 -0
  279. package/dist/internal/tool-registry/personality-filter.d.ts +37 -0
  280. package/dist/internal/workflow/ctx.d.ts +19 -0
  281. package/dist/internal/workflow/error-shape.d.ts +7 -0
  282. package/dist/internal/workflow/executor.d.ts +15 -0
  283. package/dist/internal/workflow/index.d.ts +12 -0
  284. package/dist/internal/workflow/retry-policy.d.ts +14 -0
  285. package/dist/internal/workflow/run-id.d.ts +9 -0
  286. package/dist/internal/workflow/single-flight.d.ts +18 -0
  287. package/dist/internal/workflow/snapshot-store.d.ts +23 -0
  288. package/dist/internal/workflow/step-agent.d.ts +12 -0
  289. package/dist/internal/workflow/step-branch.d.ts +10 -0
  290. package/dist/internal/workflow/step-dowhile.d.ts +8 -0
  291. package/dist/internal/workflow/step-fn.d.ts +10 -0
  292. package/dist/internal/workflow/step-foreach.d.ts +11 -0
  293. package/dist/internal/workflow/step-parallel.d.ts +17 -0
  294. package/dist/internal/workflow/step-sleep.d.ts +7 -0
  295. package/dist/internal/workflow/telemetry.d.ts +23 -0
  296. package/dist/internal/zod/to-json-schema.d.ts +21 -0
  297. package/dist/memory-adapter-helpers.d.ts +28 -0
  298. package/dist/memory.d.ts +123 -0
  299. package/dist/migrate.d.ts +33 -0
  300. package/dist/path-safety.cjs +126 -0
  301. package/dist/path-safety.cjs.map +1 -0
  302. package/dist/path-safety.d.cts +15 -0
  303. package/dist/path-safety.d.ts +15 -0
  304. package/dist/path-safety.js +120 -0
  305. package/dist/path-safety.js.map +1 -0
  306. package/dist/run-DkCD5DeO.d.cts +2181 -0
  307. package/dist/run-DkCD5DeO.d.ts +2181 -0
  308. package/dist/scorers.d.ts +75 -0
  309. package/dist/security.d.ts +67 -0
  310. package/dist/stream-object.d.ts +74 -0
  311. package/dist/task-store.cjs +237 -0
  312. package/dist/task-store.cjs.map +1 -0
  313. package/dist/task-store.d.cts +8 -0
  314. package/dist/task-store.d.ts +8 -0
  315. package/dist/task-store.js +233 -0
  316. package/dist/task-store.js.map +1 -0
  317. package/dist/task.d.ts +87 -0
  318. package/dist/theokit.d.ts +84 -0
  319. package/dist/tools/_path-scope.d.cts +8 -0
  320. package/dist/tools/_path-scope.d.ts +8 -0
  321. package/dist/tools/_subprocess.d.cts +28 -0
  322. package/dist/tools/_subprocess.d.ts +28 -0
  323. package/dist/tools/git-diff.d.cts +22 -0
  324. package/dist/tools/git-diff.d.ts +22 -0
  325. package/dist/tools/index.d.cts +29 -0
  326. package/dist/tools/index.d.ts +29 -0
  327. package/dist/tools/list-dir.d.cts +26 -0
  328. package/dist/tools/list-dir.d.ts +26 -0
  329. package/dist/tools/read-file.d.cts +31 -0
  330. package/dist/tools/read-file.d.ts +31 -0
  331. package/dist/tools/run-vitest.d.cts +46 -0
  332. package/dist/tools/run-vitest.d.ts +46 -0
  333. package/dist/tools/search-text.d.cts +32 -0
  334. package/dist/tools/search-text.d.ts +32 -0
  335. package/dist/tools.cjs +690 -0
  336. package/dist/tools.cjs.map +1 -0
  337. package/dist/tools.js +683 -0
  338. package/dist/tools.js.map +1 -0
  339. package/dist/trajectory-helpers.d.ts +31 -0
  340. package/dist/types/agent.d.ts +771 -0
  341. package/dist/types/batch.d.ts +112 -0
  342. package/dist/types/budget.d.ts +88 -0
  343. package/dist/types/cache.d.ts +76 -0
  344. package/dist/types/context.d.ts +93 -0
  345. package/dist/types/conversation-storage.d.ts +76 -0
  346. package/dist/types/conversation.d.ts +90 -0
  347. package/dist/types/cron.d.ts +150 -0
  348. package/dist/types/eval.d.ts +132 -0
  349. package/dist/types/goal-events.d.ts +95 -0
  350. package/dist/types/handoff.d.ts +135 -0
  351. package/dist/types/index.d.ts +20 -0
  352. package/dist/types/mcp.d.ts +64 -0
  353. package/dist/types/memory-adapter.d.ts +175 -0
  354. package/dist/types/messages.d.ts +154 -0
  355. package/dist/types/providers.d.ts +102 -0
  356. package/dist/types/run.d.ts +215 -0
  357. package/dist/types/task.d.ts +131 -0
  358. package/dist/types/theokit.d.ts +61 -0
  359. package/dist/types/trajectory.d.ts +49 -0
  360. package/dist/types/updates.d.ts +148 -0
  361. package/dist/types/usage.d.ts +61 -0
  362. package/dist/types/workflow.d.ts +217 -0
  363. package/dist/workflow.cjs +2405 -0
  364. package/dist/workflow.cjs.map +1 -0
  365. package/dist/workflow.d.cts +97 -0
  366. package/dist/workflow.d.ts +97 -0
  367. package/dist/workflow.js +2398 -0
  368. package/dist/workflow.js.map +1 -0
  369. package/package.json +183 -0
@@ -0,0 +1,771 @@
1
+ import type { ContextSettings, SDKContextManager } from "./context.js";
2
+ import type { McpServerConfig } from "./mcp.js";
3
+ import type { PluginsSettings, ProviderRoutingSettings, SDKProvidersManager } from "./providers.js";
4
+ import type { Run, SDKUserMessage, SendOptions } from "./run.js";
5
+ /**
6
+ * One slot in a {@link ModelSelection.params} array.
7
+ *
8
+ * @public
9
+ */
10
+ export interface ModelParameterValue {
11
+ id: string;
12
+ value: string;
13
+ }
14
+ /**
15
+ * Identifies a model plus optional per-model parameters (e.g. reasoning effort).
16
+ *
17
+ * Use `Theokit.models.list()` to discover valid ids and parameter definitions.
18
+ *
19
+ * @public
20
+ */
21
+ export interface ModelSelection {
22
+ id: string;
23
+ params?: ModelParameterValue[];
24
+ }
25
+ /**
26
+ * Which on-disk settings layers a local agent loads.
27
+ *
28
+ * @public
29
+ */
30
+ export type SettingSource = "project" | "user" | "team" | "mdm" | "plugins" | "all";
31
+ /**
32
+ * Local agent configuration.
33
+ *
34
+ * @public
35
+ */
36
+ export interface LocalOptions {
37
+ cwd?: string | string[];
38
+ settingSources?: SettingSource[];
39
+ sandboxOptions?: {
40
+ enabled: boolean;
41
+ };
42
+ }
43
+ /**
44
+ * Repo to clone into a cloud agent's VM.
45
+ *
46
+ * @public
47
+ */
48
+ export interface CloudRepo {
49
+ url: string;
50
+ startingRef?: string;
51
+ prUrl?: string;
52
+ }
53
+ /**
54
+ * Cloud execution environment.
55
+ *
56
+ * @public
57
+ */
58
+ export interface CloudEnv {
59
+ type: "cloud" | "pool" | "machine";
60
+ name?: string;
61
+ }
62
+ /**
63
+ * Cloud agent configuration.
64
+ *
65
+ * @public
66
+ */
67
+ export interface CloudOptions {
68
+ env?: CloudEnv;
69
+ repos?: CloudRepo[];
70
+ workOnCurrentBranch?: boolean;
71
+ autoCreatePR?: boolean;
72
+ skipReviewerRequest?: boolean;
73
+ /**
74
+ * Short-lived credentials scoped to the agent. Encrypted at rest, deleted
75
+ * with the agent. Names must not start with `THEOKIT_`.
76
+ */
77
+ envVars?: Record<string, string>;
78
+ }
79
+ /**
80
+ * Subagent definition. The parent agent spawns these via its Agent tool.
81
+ *
82
+ * @public
83
+ */
84
+ export interface AgentDefinition {
85
+ description: string;
86
+ prompt: string;
87
+ model?: ModelSelection | "inherit";
88
+ mcpServers?: Array<string | Record<string, McpServerConfig>>;
89
+ }
90
+ /**
91
+ * Public skill metadata exposed to the system-prompt resolver. Mirrors the
92
+ * shape returned by `agent.skills.list()` — name + description only, never
93
+ * full skill bodies.
94
+ *
95
+ * @public
96
+ */
97
+ export interface SystemPromptSkillRef {
98
+ name: string;
99
+ description: string;
100
+ }
101
+ /**
102
+ * Public skill listing handle exposed as `agent.skills`. Populated when
103
+ * `settingSources` includes `"project"` so the SDK discovers
104
+ * `.theokit/skills/<name>/SKILL.md` files OR when `skills.enabled` is set
105
+ * explicitly on the agent options.
106
+ *
107
+ * @public
108
+ */
109
+ export interface SDKAgentSkills {
110
+ list(): Promise<ReadonlyArray<SystemPromptSkillRef>>;
111
+ }
112
+ /**
113
+ * Public plugin metadata returned by `agent.plugins.list()`. Mirrors the
114
+ * `.theokit/plugins/<name>/MANIFEST.json` allow-listed shape; never exposes
115
+ * raw plugin bodies, credentials, or internal hooks.
116
+ *
117
+ * @public
118
+ */
119
+ export interface SDKPluginMetadata {
120
+ name: string;
121
+ description?: string;
122
+ }
123
+ /**
124
+ * Public plugin listing handle exposed as `agent.plugins`. Populated when
125
+ * `settingSources` includes `"plugins"` OR when `plugins.enabled` is set
126
+ * on the agent options.
127
+ *
128
+ * @public
129
+ */
130
+ export interface SDKAgentPlugins {
131
+ list(): Promise<ReadonlyArray<SDKPluginMetadata>>;
132
+ }
133
+ /**
134
+ * Public view of a recalled memory fact exposed to the system-prompt resolver.
135
+ *
136
+ * @public
137
+ */
138
+ export interface SystemPromptMemoryFact {
139
+ text: string;
140
+ }
141
+ /**
142
+ * Context passed to a {@link SystemPromptResolver}. Field order is a
143
+ * compatibility contract: new fields are appended, never reordered.
144
+ *
145
+ * @public
146
+ */
147
+ export interface SystemPromptContext {
148
+ agentId: string;
149
+ cwd: string | undefined;
150
+ model: ModelSelection | undefined;
151
+ skills: ReadonlyArray<SystemPromptSkillRef>;
152
+ userMessage: string;
153
+ /** Recalled durable facts when memory is enabled. Appended in v1.1. */
154
+ memory: ReadonlyArray<SystemPromptMemoryFact>;
155
+ }
156
+ /**
157
+ * Resolver function that produces the system prompt dynamically. Receives
158
+ * the {@link SystemPromptContext} and returns a string (or a Promise of one).
159
+ *
160
+ * The SDK does NOT impose a timeout on the resolver — wrap your own
161
+ * `Promise.race` if you call into slow resources. Errors propagate to the
162
+ * caller of `agent.send()`.
163
+ *
164
+ * @public
165
+ */
166
+ export type SystemPromptResolver = (ctx: SystemPromptContext) => string | Promise<string>;
167
+ /**
168
+ * Skills configuration accepted by `Agent.create()` via
169
+ * {@link AgentOptions.skills}.
170
+ *
171
+ * Skills are discovered from `.theokit/skills/<name>/SKILL.md` when
172
+ * `local.settingSources` includes `"project"`.
173
+ *
174
+ * @public
175
+ */
176
+ export interface SkillsSettings {
177
+ /**
178
+ * Names of skills the parent agent may invoke. When omitted, every
179
+ * discovered skill is enabled.
180
+ */
181
+ enabled?: string[];
182
+ /**
183
+ * Whether the SDK auto-injects the loaded skill list (name + description) as a
184
+ * `<skills>` block in the LLM system prompt. Default `true`.
185
+ *
186
+ * Set to `false` when supplying a custom `systemPrompt` resolver that formats
187
+ * skills itself.
188
+ */
189
+ autoInject?: boolean;
190
+ }
191
+ /**
192
+ * Memory configuration accepted by `Agent.create()` via {@link AgentOptions.memory}.
193
+ *
194
+ * Persists durable facts under `.theokit/memory/<namespace>/<scope>-<userId>.json`.
195
+ *
196
+ * @public
197
+ */
198
+ export interface MemorySettings {
199
+ enabled: boolean;
200
+ namespace?: string;
201
+ userId?: string;
202
+ scope?: "agent" | "user" | "team";
203
+ storePath?: string;
204
+ /**
205
+ * Whether the SDK auto-injects recalled facts as a `<memory>` block in the
206
+ * LLM system prompt. Default `true`.
207
+ */
208
+ autoInject?: boolean;
209
+ /**
210
+ * Index + tools configuration (memory-system-openclaw-parity).
211
+ *
212
+ * When `tools !== false`, the SDK registers `memory_search` and
213
+ * `memory_get` with the LLM. Backed by SQLite + FTS5 (and sqlite-vec
214
+ * when an embedding provider is configured).
215
+ */
216
+ index?: {
217
+ /** Whether to register `memory_search` + `memory_get` tools. Default `true`. */
218
+ tools?: boolean;
219
+ /**
220
+ * Vector index backend (ADR D43). Default `"sqlite-vec"`. Set to
221
+ * `"lance"` to use `@lancedb/lancedb` (optional peer dep) for scale.
222
+ */
223
+ backend?: "sqlite-vec" | "lance";
224
+ /** Embedding provider config. When omitted, the index runs in FTS-only mode. */
225
+ embedding?: {
226
+ provider: "openai" | "mistral" | "openrouter" | "voyage" | "deepinfra";
227
+ model?: string;
228
+ };
229
+ };
230
+ /**
231
+ * Active Memory blocking recall (Phase 7). When `enabled: true`, runs
232
+ * before each `send()` and prepends an `<active-memory>` block.
233
+ */
234
+ activeRecall?: {
235
+ enabled?: boolean;
236
+ queryMode?: "message" | "recent" | "full";
237
+ timeoutMs?: number;
238
+ maxSummaryChars?: number;
239
+ persistTranscripts?: boolean;
240
+ };
241
+ }
242
+ /**
243
+ * Inline custom tool — registered with the LLM under the given name + schema
244
+ * and dispatched locally to {@link CustomTool.handler} when the model emits a
245
+ * `tool_use` for it.
246
+ *
247
+ * Local runtime only (SDK v1.0). Cloud agents reject `tools` (handlers cannot
248
+ * cross the wire — use MCP servers or subagents for cloud tool surfaces).
249
+ *
250
+ * Handlers MUST be re-passed on `Agent.resume()` because closures cannot be
251
+ * persisted. The tool catalog (name + description + schema) is NOT serialized.
252
+ *
253
+ * @public
254
+ */
255
+ export interface CustomTool {
256
+ /**
257
+ * Tool name surfaced to the LLM. Must match `^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`
258
+ * and must not collide with `shell`, `memory_search`, `memory_get`, or any
259
+ * `mcp_*` prefix (reserved for the SDK's built-in tools).
260
+ */
261
+ name: string;
262
+ /** Description surfaced to the LLM. Required — drives tool-selection accuracy. */
263
+ description: string;
264
+ /** JSON Schema (Draft-7 subset) describing the `input` argument. Must be `type: "object"`. */
265
+ inputSchema: Record<string, unknown>;
266
+ /**
267
+ * Local handler invoked when the model emits `tool_use` for this tool.
268
+ * Returns a string (becomes the `tool_result.content` surfaced back to the
269
+ * model). Throws → SDK converts to `tool_result` with `isError: true` and
270
+ * the error `message` as content.
271
+ */
272
+ handler: (input: Record<string, unknown>) => string | Promise<string>;
273
+ }
274
+ /**
275
+ * Telemetry configuration for an agent. When `enabled: true`, the SDK emits
276
+ * OpenTelemetry spans for `agent.send`, `llm.call`, `tool.call`, and
277
+ * `memory.search`. See ADR D34.
278
+ *
279
+ * Privacy: content (prompts, responses, tool args) is OMITTED by default —
280
+ * only timing/counts/IDs are recorded. Opt in via `includeContent: true`
281
+ * to add prompt/response/args events to the spans (consumer's
282
+ * responsibility to sanitize PII).
283
+ *
284
+ * `@opentelemetry/api` is an OPTIONAL peer dependency. Without it
285
+ * installed, telemetry is a no-op even when `enabled: true`.
286
+ *
287
+ * @public
288
+ */
289
+ export interface TelemetrySettings {
290
+ /** Master switch. Default `false`. */
291
+ enabled: boolean;
292
+ /** Whether to include prompts/responses/tool args as span events. Default `false`. */
293
+ includeContent?: boolean;
294
+ /** Exporter selection. Default `"console"`. Custom exporters are passed-through. */
295
+ exporter?: "console" | "otlp" | unknown;
296
+ /** Service name on emitted spans. Default `"theokit-sdk"`. */
297
+ serviceName?: string;
298
+ /**
299
+ * Auto-detect and register OTel exporters for installed observability
300
+ * libs (Langfuse, Sentry, PostHog) via `createRequire` feature-detect.
301
+ * Default `true`. See ADR D42.
302
+ */
303
+ autoDetect?: boolean;
304
+ /**
305
+ * Per-adapter opt-out. Lowercase names: `"langfuse" | "sentry" | "posthog"`.
306
+ * Default `[]`.
307
+ */
308
+ disable?: string[];
309
+ }
310
+ /**
311
+ * Top-level options accepted by `Agent.create()`.
312
+ *
313
+ * Pass either `local` or `cloud` to pick a runtime.
314
+ *
315
+ * @public
316
+ */
317
+ export interface AgentOptions {
318
+ model?: ModelSelection;
319
+ /** Falls back to `THEOKIT_API_KEY`. */
320
+ apiKey?: string;
321
+ name?: string;
322
+ /**
323
+ * When `true`, `Agent.prompt` (and any helper that goes through `run.wait()`)
324
+ * rejects with `AgentRunError` instead of resolving with `{ status: 'error' }`.
325
+ * Cancelled runs (`status: 'cancelled'`) still resolve — cancel ≠ error.
326
+ * If `result.error` is undefined despite `status: 'error'` (malformed RunResult),
327
+ * the defensive guard resolves normally (no throw).
328
+ *
329
+ * Default `false` (backwards-compatible).
330
+ *
331
+ * @public
332
+ */
333
+ throwOnError?: boolean;
334
+ /**
335
+ * System prompt for the agent. Either a plain string or a resolver
336
+ * function that receives the {@link SystemPromptContext} and returns the
337
+ * prompt dynamically. Override per-call via {@link SendOptions.systemPrompt}.
338
+ *
339
+ * Subagents do NOT inherit this — they use {@link AgentDefinition.prompt}.
340
+ */
341
+ systemPrompt?: string | SystemPromptResolver;
342
+ local?: LocalOptions;
343
+ cloud?: CloudOptions;
344
+ mcpServers?: Record<string, McpServerConfig>;
345
+ agents?: Record<string, AgentDefinition>;
346
+ agentId?: string;
347
+ /** Context manager configuration. See `agent.context`. */
348
+ context?: ContextSettings;
349
+ /** Provider routing configuration. See `agent.providers`. */
350
+ providers?: ProviderRoutingSettings;
351
+ /** Plugins to enable. Plugin sources must also be active via `local.settingSources`. */
352
+ plugins?: PluginsSettings;
353
+ /** Skills configuration. See `agent.skills`. */
354
+ skills?: SkillsSettings;
355
+ /** Memory configuration. Persists durable facts; auto-recalled on send. */
356
+ memory?: MemorySettings;
357
+ /**
358
+ * Inline custom tools. Local runtime only — cloud agents reject any non-empty
359
+ * `tools` array. Handlers are not persisted; pass them again on resume.
360
+ * See {@link CustomTool}.
361
+ */
362
+ tools?: CustomTool[];
363
+ /**
364
+ * Telemetry (OpenTelemetry) configuration. Default disabled. See
365
+ * {@link TelemetrySettings} and ADR D34.
366
+ */
367
+ telemetry?: TelemetrySettings;
368
+ /**
369
+ * Arbitrary metadata bag for caller-supplied provenance. Currently used by
370
+ * the fork primitive (ADR D114) to tag `metadata.forkOrigin` and
371
+ * `metadata.parentAgentId` so memory writes downstream can be attributed.
372
+ *
373
+ * Not persisted to the agent registry — informational only at runtime.
374
+ *
375
+ * @public
376
+ */
377
+ metadata?: Record<string, unknown>;
378
+ /**
379
+ * Default `MemoryContext` for third-party memory adapter plugins
380
+ * (ADR D141). When set, `pre_user_send` / `post_assistant_reply`
381
+ * hooks receive this context unless the caller overrides it. The
382
+ * `agent.memory` direct API also defaults to it.
383
+ *
384
+ * @public
385
+ */
386
+ memoryContext?: import("./memory-adapter.js").MemoryContext;
387
+ /**
388
+ * Maximum byte length of the `<memory-context>` block injected by
389
+ * `pre_user_send` adapter hooks (EC-A). Larger recalls are sliced
390
+ * with `…[truncated]`. Default 16_000 (~4k tokens). Set lower for
391
+ * cheaper turns; higher for longer-context models.
392
+ *
393
+ * @public
394
+ */
395
+ maxRecallContextBytes?: number;
396
+ /**
397
+ * Declarative handoff destinations (Adoption Roadmap #4; ADRs D214-D229).
398
+ * Each entry is either a raw `SDKAgent` (auto-wrapped with defaults) OR a
399
+ * `HandoffDescriptor` from `Handoff.create(target, opts?)`.
400
+ *
401
+ * Runtime injects synthetic `transfer_to_<receiver.name>` tools per
402
+ * destination (D214/D215). When the LLM invokes one, the receiver takes
403
+ * over the next turn (peer-to-peer, D217).
404
+ *
405
+ * @public
406
+ */
407
+ handoffs?: ReadonlyArray<import("./agent.js").SDKAgent | import("./handoff.js").HandoffDescriptor>;
408
+ /**
409
+ * Maximum chain depth across handoffs per `agent.send()` call (D218).
410
+ * Default 5. Exceeding throws `HandoffLoopError`. Set to 0 to disable
411
+ * the handoff tools entirely (EC-8 / handoffs never fire).
412
+ *
413
+ * @public
414
+ */
415
+ maxHandoffDepth?: number;
416
+ /**
417
+ * Production-Readiness #6 — quota / abuse gates (ADRs D322-D323).
418
+ *
419
+ * `onBeforeCreate` fires BEFORE the agent is registered or persisted —
420
+ * throw to block creation. `onBeforeSend` fires BEFORE each `agent.send`
421
+ * (after `pre_user_send` adapter hooks, before any LLM call or storage
422
+ * write) — throw to block the send.
423
+ *
424
+ * Unlike `onTool*` (observation), these hooks are BLOCKERS — errors
425
+ * propagate as rejection on `Agent.create` / `agent.send`. Use them for
426
+ * per-user conversation caps, per-conversation message caps, abuse
427
+ * detection.
428
+ *
429
+ * @public
430
+ */
431
+ onBeforeCreate?: (event: {
432
+ conversationId: string;
433
+ userId?: string;
434
+ }) => Promise<void> | void;
435
+ /**
436
+ * Fires before each `agent.send`. `previousMessageCount` is the count of
437
+ * messages already persisted BEFORE the current send adds the user
438
+ * message. Throw to block.
439
+ *
440
+ * @public
441
+ */
442
+ onBeforeSend?: (event: {
443
+ conversationId: string;
444
+ previousMessageCount: number;
445
+ }) => Promise<void> | void;
446
+ /**
447
+ * Production-Readiness #4 — tool lifecycle hooks (ADRs D315-D317).
448
+ *
449
+ * `onToolStart` fires BEFORE the handler runs. `onToolEnd` fires after a
450
+ * successful handler return. `onToolError` fires when validation fails OR
451
+ * the handler throws — `event.error` is always an `Error` instance.
452
+ *
453
+ * Hook errors are SWALLOWED with a stderr warn (do not abort the run).
454
+ * The `callId` is unique per tool invocation and identical across the
455
+ * start/end (or start/error) pair, so consumers can correlate.
456
+ *
457
+ * Use cases: cost tracking, audit logs, per-tool retry/alerting,
458
+ * latency telemetry.
459
+ *
460
+ * @public
461
+ */
462
+ onToolStart?: (event: {
463
+ toolName: string;
464
+ args: unknown;
465
+ conversationId: string;
466
+ callId: string;
467
+ }) => void | Promise<void>;
468
+ /** Fires when a tool handler returns successfully. */
469
+ onToolEnd?: (event: {
470
+ toolName: string;
471
+ args: unknown;
472
+ result: unknown;
473
+ conversationId: string;
474
+ callId: string;
475
+ durationMs: number;
476
+ }) => void | Promise<void>;
477
+ /**
478
+ * Fires when a tool handler throws OR schema validation rejects the args.
479
+ * `event.error` is always an `Error` instance (D315/EC-6 — validation
480
+ * reasons are wrapped in `new Error(reason)`).
481
+ *
482
+ * `attempt` is always `1` in v1 (D317 — reserved for future retry policy).
483
+ */
484
+ onToolError?: (event: {
485
+ toolName: string;
486
+ args: unknown;
487
+ error: Error;
488
+ conversationId: string;
489
+ callId: string;
490
+ durationMs: number;
491
+ attempt: number;
492
+ }) => void | Promise<void>;
493
+ /**
494
+ * Pluggable conversation persistence (Production-Readiness #1; ADRs D303-D306).
495
+ *
496
+ * Default: undefined → `FileSystemConversationStorage` writing to
497
+ * `<cwd>/.theokit/agents/<id>/messages.jsonl` (byte-identical to pre-D303
498
+ * behavior). Pass `InMemoryConversationStorage` for tests, or a custom
499
+ * adapter (Postgres/Redis/Durable Objects) for serverless and multi-host
500
+ * deploys.
501
+ *
502
+ * NOTE: not persisted in the registry snapshot — closures don't serialize.
503
+ * On `Agent.resume`, pass the adapter again. If the agent was originally
504
+ * created with a custom `conversationStorage`, resume without it throws
505
+ * `ConfigurationError(code: "conversation_storage_required")` (D325) to
506
+ * avoid silent FS fallback that would lose history.
507
+ *
508
+ * @public
509
+ */
510
+ conversationStorage?: import("./conversation-storage.js").ConversationStorageAdapter;
511
+ }
512
+ /**
513
+ * Artifact produced inside an agent's workspace. Cloud-only.
514
+ *
515
+ * @public
516
+ */
517
+ export interface SDKArtifact {
518
+ path: string;
519
+ sizeBytes: number;
520
+ updatedAt: string;
521
+ }
522
+ /**
523
+ * Handle returned by `Agent.create()` and `Agent.resume()`.
524
+ *
525
+ * @public
526
+ */
527
+ export interface SDKAgent {
528
+ readonly agentId: string;
529
+ readonly model: ModelSelection | undefined;
530
+ /**
531
+ * Context manager for this agent. Populated when context is enabled via
532
+ * {@link AgentOptions.context}. See {@link SDKContextManager}.
533
+ */
534
+ readonly context?: SDKContextManager;
535
+ /**
536
+ * Provider routing inspector for this agent. Populated when at least one
537
+ * provider route is configured (via {@link AgentOptions.providers}, plugins,
538
+ * or model-implied providers). See {@link SDKProvidersManager}.
539
+ */
540
+ readonly providers?: SDKProvidersManager;
541
+ /**
542
+ * Skill listing for this agent. Populated when project-scoped skills are
543
+ * enabled (`settingSources: ["project"]`) or when `skills.enabled` is set.
544
+ * See {@link SDKAgentSkills}.
545
+ */
546
+ readonly skills?: SDKAgentSkills;
547
+ /**
548
+ * Plugin listing for this agent. Populated when project-scoped plugins are
549
+ * enabled (`settingSources: ["plugins"]`) or when `plugins.enabled` is set.
550
+ * See {@link SDKAgentPlugins}.
551
+ */
552
+ readonly plugins?: SDKAgentPlugins;
553
+ send(message: string | SDKUserMessage, options?: SendOptions): Promise<Run>;
554
+ /** Fire-and-forget disposal. */
555
+ close(): void;
556
+ /** Re-read filesystem config (context, hooks, project MCP, subagents) without disposing. */
557
+ reload(): Promise<void>;
558
+ /**
559
+ * Async disposal. Idempotent — calling more than once is a no-op (per ADR D5).
560
+ * Prefer `await using agent = await Agent.create(...)` over explicit
561
+ * `dispose()` for resource safety.
562
+ */
563
+ dispose(): Promise<void>;
564
+ /**
565
+ * `await using` support per ADR D5. Identical semantics to `dispose()` —
566
+ * idempotent across both surfaces.
567
+ */
568
+ [Symbol.asyncDispose](): Promise<void>;
569
+ /** Cloud-only. Local returns an empty array. */
570
+ listArtifacts(): Promise<SDKArtifact[]>;
571
+ /** Cloud-only. Local throws `UnsupportedRunOperationError`. */
572
+ downloadArtifact(path: string): Promise<Buffer>;
573
+ /**
574
+ * Signal that prompt cache should be invalidated. By default deferred —
575
+ * applied at the start of the next `send()`. Pass `{ applyNow: true }` to
576
+ * force immediate disposal (caller must `Agent.create()` again to use).
577
+ *
578
+ * Cache invalidation is a cost regression (provider charges full price
579
+ * for the rebuilt cache; see ADRs D94-D95). Use sparingly and deliberately.
580
+ *
581
+ * Cloud agents: no-op (cloud runtime reconstructs state per request).
582
+ *
583
+ * @public
584
+ */
585
+ invalidateCache?(reason: string, options?: InvalidateCacheOptions): Promise<void>;
586
+ /**
587
+ * Goal-driven Ralph loop (ADRs D115-D121). Iterates `agent.send` →
588
+ * judge → continuation until the auxiliary judge model returns `done`,
589
+ * the judge fails too many times in a row, max turns are exhausted,
590
+ * or the caller aborts via `AbortSignal`.
591
+ *
592
+ * Yields {@link import("./goal-events.js").GoalEvent} per state
593
+ * transition; returns a {@link import("./goal-events.js").GoalResult}
594
+ * summary as the generator's final value.
595
+ *
596
+ * Cloud agents throw {@link import("../errors.js").UnsupportedRunOperationError}
597
+ * **synchronously** (no AsyncGenerator returned) — wrap in try/catch
598
+ * if you support both runtimes.
599
+ *
600
+ * Caveat: do not call `agent.dispose()` mid-iteration; the next `send`
601
+ * propagates the disposal error through the generator to the consumer.
602
+ *
603
+ * @public
604
+ */
605
+ runUntil?(goal: string, options?: import("./goal-events.js").GoalOptions): import("./goal-events.js").RunUntilIterator;
606
+ /**
607
+ * Fork a short-lived sub-agent with parent's credentials + system
608
+ * prompt byte-identical (ADR D112 — cache hit) and a restricted tool
609
+ * whitelist (ADR D111 — AsyncLocalStorage isolation).
610
+ *
611
+ * Cloud agents throw {@link import("../errors.js").UnsupportedRunOperationError}.
612
+ *
613
+ * @public
614
+ */
615
+ fork?(options: import("../internal/runtime/fork-agent.js").ForkOptions): Promise<import("../internal/runtime/fork-agent.js").ForkResult>;
616
+ /**
617
+ * Direct API to third-party memory adapter(s) registered via
618
+ * `plugins: [...]` (ADR D141 / D142). Returns `null` when no adapter
619
+ * is registered. In multi-adapter setups `write` fans out to all;
620
+ * `recall` merges + dedupes; `delete` routes by `MemoryId` prefix.
621
+ *
622
+ * @public
623
+ */
624
+ memory?: import("./memory-adapter.js").AgentMemory;
625
+ /**
626
+ * Activate a personality preset for the next `send` (Hermes #26).
627
+ * Reserved names `"none"`, `"default"`, and `"neutral"` clear the
628
+ * active preset. Returns the resolved preset (or `null` when cleared).
629
+ *
630
+ * Persistence: pass `{ save: true }` to persist across process
631
+ * restarts (stored under `$THEOKIT_HOME/personality.json`).
632
+ *
633
+ * History: by default the conversation history is preserved across
634
+ * the switch. Pass `{ reset: true }` to also clear the session.
635
+ *
636
+ * Cloud agents throw {@link import("../errors.js").UnsupportedRunOperationError}.
637
+ *
638
+ * @public
639
+ */
640
+ usePersonality?(name: string, opts?: {
641
+ save?: boolean;
642
+ reset?: boolean;
643
+ }): Promise<PersonalityPreset | null>;
644
+ }
645
+ /**
646
+ * Resolved personality preset surfaced via {@link SDKAgent.usePersonality}
647
+ * (Hermes #26, ADRs D160-D169). Re-declared here so the public DTS bundle
648
+ * never crosses the `internal/` path boundary. The implementation type in
649
+ * `internal/personality/types.ts` is structurally identical.
650
+ *
651
+ * @public
652
+ */
653
+ export interface PersonalityPreset {
654
+ readonly name: string;
655
+ readonly description: string | undefined;
656
+ readonly tools: ReadonlyArray<string> | undefined;
657
+ readonly model: string | undefined;
658
+ readonly tags: ReadonlyArray<string> | undefined;
659
+ readonly systemPrompt: string;
660
+ readonly source: "project" | "user";
661
+ readonly sourcePath: string;
662
+ }
663
+ /**
664
+ * Options for {@link SDKAgent.invalidateCache}.
665
+ *
666
+ * @public
667
+ */
668
+ export interface InvalidateCacheOptions {
669
+ /**
670
+ * When `true`, dispose the agent immediately so caller must recreate it
671
+ * to continue. Default `false` (deferred — applied on next `send()`).
672
+ */
673
+ applyNow?: boolean;
674
+ }
675
+ /**
676
+ * Metadata returned by `Agent.list()` and `Agent.get()`.
677
+ *
678
+ * @public
679
+ */
680
+ export type SDKAgentInfo = {
681
+ agentId: string;
682
+ name: string;
683
+ summary: string;
684
+ lastModified: number;
685
+ status?: "running" | "finished" | "error";
686
+ createdAt?: number;
687
+ archived?: boolean;
688
+ } & ({
689
+ runtime?: undefined;
690
+ } | {
691
+ runtime: "local";
692
+ cwd?: string;
693
+ } | {
694
+ runtime: "cloud";
695
+ env?: CloudEnv;
696
+ repos?: string[];
697
+ });
698
+ /**
699
+ * Options for `Agent.list()`.
700
+ *
701
+ * @public
702
+ */
703
+ export type ListAgentsOptions = {
704
+ limit?: number;
705
+ cursor?: string;
706
+ } & ({
707
+ runtime?: undefined;
708
+ } | {
709
+ runtime: "local";
710
+ cwd?: string;
711
+ } | {
712
+ runtime: "cloud";
713
+ prUrl?: string;
714
+ includeArchived?: boolean;
715
+ apiKey?: string;
716
+ });
717
+ /**
718
+ * Options for `Agent.get()`.
719
+ *
720
+ * @public
721
+ */
722
+ export interface GetAgentOptions {
723
+ cwd?: string;
724
+ apiKey?: string;
725
+ }
726
+ /**
727
+ * Options for `Agent.listRuns()`.
728
+ *
729
+ * @public
730
+ */
731
+ export type ListRunsOptions = {
732
+ limit?: number;
733
+ cursor?: string;
734
+ } & ({
735
+ runtime?: "local";
736
+ cwd?: string;
737
+ } | {
738
+ runtime: "cloud";
739
+ apiKey?: string;
740
+ });
741
+ /**
742
+ * Options for `Agent.getRun()`. Cloud requires the parent `agentId`.
743
+ *
744
+ * @public
745
+ */
746
+ export type GetRunOptions = {
747
+ runtime?: "local";
748
+ cwd?: string;
749
+ } | {
750
+ runtime: "cloud";
751
+ agentId: string;
752
+ apiKey?: string;
753
+ };
754
+ /**
755
+ * Options for archive/unarchive/delete.
756
+ *
757
+ * @public
758
+ */
759
+ export interface AgentOperationOptions {
760
+ cwd?: string;
761
+ apiKey?: string;
762
+ }
763
+ /**
764
+ * Paginated list shape.
765
+ *
766
+ * @public
767
+ */
768
+ export interface ListResult<T> {
769
+ items: T[];
770
+ nextCursor?: string;
771
+ }