@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,36 @@
1
+ /**
2
+ * performPersonalitySwitch — orchestrates the full lifecycle of a
3
+ * personality activation: store mutation, optional history reset,
4
+ * transcript marker injection, and cache invalidation (T5.1, ADR D164).
5
+ *
6
+ * The marker is emitted as a **user role** message because (a) the
7
+ * switch is a directive from the operator (not a model utterance), and
8
+ * (b) LLMs treat user-role lines as instructions that survive history
9
+ * compaction (EC-D from arXiv:2412.00804).
10
+ *
11
+ * Same-slug switches are no-ops: no marker, no cache invalidation, no
12
+ * store write (EC-18).
13
+ *
14
+ * @internal
15
+ */
16
+ import { PersonalityRegistry } from "./registry.js";
17
+ import type { PersonalityStore } from "./store.js";
18
+ export interface PerformPersonalitySwitchArgs {
19
+ agentId: string;
20
+ /** Previous active slug (undefined = no active preset). */
21
+ prevSlug: string | undefined;
22
+ /** Next active slug or reserved clear alias (none / default / neutral). */
23
+ requestedName: string;
24
+ registry: PersonalityRegistry;
25
+ store: PersonalityStore;
26
+ invalidateCache: (reason: string) => Promise<void>;
27
+ appendSessionMessage: (msg: {
28
+ role: "user" | "assistant";
29
+ text: string;
30
+ }) => void;
31
+ clearSession?: () => void;
32
+ opts: {
33
+ save?: boolean;
34
+ reset?: boolean;
35
+ };
36
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Personality preset types + Zod frontmatter schema (T1.1, ADR D161).
3
+ *
4
+ * **EC-C:** name regex is **lowercase-only** (NO `/i` flag) to prevent
5
+ * `Coder` vs `coder` becoming distinct registry keys (Map verbatim).
6
+ * Forcing lowercase eliminates the ambiguity at validation time.
7
+ *
8
+ * @internal
9
+ */
10
+ export type PersonalityFrontmatter = z.infer<typeof PersonalityFrontmatterSchema>;
11
+ /**
12
+ * Resolved personality preset — frontmatter + body + source provenance.
13
+ * Defined publicly in `types/agent.ts` so the DTS bundle never crosses
14
+ * `internal/`. Re-exported here for ergonomic internal callers.
15
+ *
16
+ * @public
17
+ */
18
+ export type { PersonalityPreset } from "../../types/agent.js";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * PluginContext implementation + dev-mode seal (T1.2, ADR D99).
3
+ *
4
+ * `createPluginContext()` returns a fresh `{ ctx, registrations }` pair
5
+ * for each plugin. In dev mode (`NODE_ENV !== "production"`) the context
6
+ * is wrapped in a Proxy that throws on `set`/`delete` to catch plugin
7
+ * abuse early. In production the raw impl is returned (zero overhead).
8
+ *
9
+ * @internal
10
+ */
11
+ import type { CommandHandler, HookHandler, HookName, PluginContext } from "./types.js";
12
+ interface CommandEntry {
13
+ name: string;
14
+ handler: CommandHandler;
15
+ description?: string;
16
+ }
17
+ interface InjectedMessage {
18
+ content: string;
19
+ role: "user" | "system";
20
+ }
21
+ export interface PluginRegistrations {
22
+ tools: CustomTool[];
23
+ commands: CommandEntry[];
24
+ hooks: Map<HookName, HookHandler[]>;
25
+ injected: InjectedMessage[];
26
+ }
27
+ export declare function createPluginContext(): {
28
+ ctx: PluginContext;
29
+ registrations: PluginRegistrations;
30
+ };
31
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * PluginManager — constructs PluginContext per plugin, invokes register()
3
+ * once, aggregates registrations + provider profiles + memory factories
4
+ * (T1.3, ADRs D97-D101).
5
+ *
6
+ * @internal
7
+ */
8
+ import { type PluginRegistrations } from "./context.js";
9
+ import type { MemoryProviderFactory, Plugin, PreToolCallContext, PreToolCallDecision } from "./types.js";
10
+ export interface ProviderEntry {
11
+ pluginName: string;
12
+ profile: ProviderProfile;
13
+ }
14
+ export interface MemoryEntry {
15
+ pluginName: string;
16
+ createProvider: MemoryProviderFactory;
17
+ }
18
+ export interface AggregatedPlugins {
19
+ tools: PluginRegistrations["tools"];
20
+ commands: PluginRegistrations["commands"];
21
+ hooks: PluginRegistrations["hooks"];
22
+ injected: PluginRegistrations["injected"];
23
+ providerProfiles: ProviderEntry[];
24
+ memoryProviders: MemoryEntry[];
25
+ }
26
+ export declare class PluginManager {
27
+ #private;
28
+ initialize(plugins: ReadonlyArray<Plugin>): Promise<void>;
29
+ get aggregated(): Readonly<AggregatedPlugins>;
30
+ /**
31
+ * Run all `pre_tool_call` hooks; first decision with `block: true` wins.
32
+ * D101: veto pattern — return `{ block: true, message }` makes the loop
33
+ * surface a tool_result with `isError: false, content: message` so the
34
+ * LLM can self-correct.
35
+ */
36
+ runPreToolCallHooks(ctx: PreToolCallContext): Promise<PreToolCallDecision | undefined>;
37
+ }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Plugin contract types (T1.1, ADRs D97-D101).
3
+ *
4
+ * Discriminated union by `kind`:
5
+ * - `"general"` — registers tools/hooks/commands via `register(ctx)`.
6
+ * - `"model-provider"` — declares a `ProviderProfile` consumed by router.
7
+ * - `"memory"` — supplies a memory provider factory.
8
+ *
9
+ * Hooks are a fixed enum (D100) to prevent sprawl; `pre_tool_call` supports
10
+ * veto via `{ block: true, message }` (D101) so plugins can implement safety
11
+ * guards without crashing the agent loop.
12
+ *
13
+ * @public
14
+ */
15
+ import type { CustomTool } from "../../types/agent.js";
16
+ import type { ProviderProfile } from "../providers/types.js";
17
+ export type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
18
+ export interface PreToolCallContext {
19
+ name: string;
20
+ args: Record<string, unknown>;
21
+ agentId: string;
22
+ runId: string;
23
+ }
24
+ export interface PreToolCallDecision {
25
+ block: true;
26
+ message: string;
27
+ }
28
+ /**
29
+ * Context passed to `pre_user_send` hook handlers (ADR D145).
30
+ *
31
+ * @public
32
+ */
33
+ export interface PreUserSendContext {
34
+ prompt: string;
35
+ agentId: string;
36
+ runId: string;
37
+ /** Caller-supplied memory context, flowing through from `AgentOptions.memoryContext`. */
38
+ memoryContext?: import("../../types/memory-adapter.js").MemoryContext;
39
+ /** Forwarded `AbortSignal` so adapter recall HTTP can be cancelled mid-flight (EC-H). */
40
+ signal?: AbortSignal;
41
+ }
42
+ /**
43
+ * Optional result returned by `pre_user_send` handlers. The agent loop
44
+ * concatenates `recalledContext` from all handlers and injects it as a
45
+ * `<memory-context>...</memory-context>` block before the user prompt.
46
+ *
47
+ * @public
48
+ */
49
+ export interface PreUserSendResult {
50
+ recalledContext?: string;
51
+ }
52
+ /**
53
+ * Context passed to `post_assistant_reply` hook handlers (ADR D145).
54
+ * Fire-and-forget — exceptions are caught and surfaced to stderr; the
55
+ * caller's `wait()` never blocks on this dispatch.
56
+ *
57
+ * @public
58
+ */
59
+ export interface PostAssistantReplyContext {
60
+ prompt: string;
61
+ reply: string;
62
+ agentId: string;
63
+ runId: string;
64
+ memoryContext?: import("../../types/memory-adapter.js").MemoryContext;
65
+ }
66
+ export type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
67
+ export type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
68
+ export interface CommandOptions {
69
+ description?: string;
70
+ }
71
+ export interface PluginContext {
72
+ /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
73
+ registerTool(tool: CustomTool): void;
74
+ /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
75
+ registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
76
+ /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
77
+ on(hook: HookName, handler: HookHandler): void;
78
+ /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
79
+ injectMessage(content: string, role?: "user" | "system"): void;
80
+ }
81
+ interface BasePlugin {
82
+ name: string;
83
+ version: string;
84
+ }
85
+ export type Plugin = (BasePlugin & {
86
+ kind: "general";
87
+ register: (ctx: PluginContext) => void | Promise<void>;
88
+ }) | (BasePlugin & {
89
+ kind: "model-provider";
90
+ profile: ProviderProfile;
91
+ }) | (BasePlugin & {
92
+ kind: "memory";
93
+ createProvider: MemoryProviderFactory;
94
+ });
95
+ /**
96
+ * Identity helper for plugin authors. TS-only convenience — preserves
97
+ * inferred type without forcing manual `Plugin` annotation.
98
+ *
99
+ * @public
100
+ */
101
+ export declare function definePlugin<P extends Plugin>(p: P): P;
102
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ProviderProfile } from "../types.js";
2
+ export declare const ANTHROPIC: ProviderProfile;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * AWS Bedrock profile (Adoption Roadmap #8; ADRs D286-D302).
3
+ *
4
+ * Bearer-only auth via `AWS_BEARER_TOKEN_BEDROCK` env (GA Sep 2025).
5
+ * Optional `@aws/bedrock-token-generator` peer dep auto-refreshes short-term
6
+ * tokens (D287). Transport via native `fetch`; no `@aws-sdk/*` dependency.
7
+ *
8
+ * Model IDs follow the `bedrock/{aws-id}` convention so the router can
9
+ * infer the provider via prefix routing (D186). The client strips the
10
+ * `bedrock/` prefix before building the URL.
11
+ *
12
+ * @internal
13
+ */
14
+ export declare const BEDROCK: ProviderProfile;
15
+ /** Strip `"bedrock/"` prefix so the raw AWS model id is used in the URL. */
16
+ export declare function stripBedrockPrefix(modelId: string): string;
17
+ /**
18
+ * Infer AWS region from a Bedrock model id prefix (D290).
19
+ *
20
+ * `global.*` routes via `us-east-1` (AWS default entrypoint for global
21
+ * inference profiles).
22
+ */
23
+ export declare function inferRegionFromModelId(modelId: string): string | undefined;
24
+ /** Resolve baseUrl from model id; falls back to `AWS_REGION` env or `us-east-1`. */
25
+ export declare function resolveBedrockBaseUrl(modelId: string): string;
@@ -0,0 +1,10 @@
1
+ import type { ProviderProfile } from "../types.js";
2
+ /**
3
+ * Gemini via OpenRouter passthrough. Direct Gemini API uses a different
4
+ * dialect (`generateContent`); SDK currently routes through OpenRouter's
5
+ * OpenAI-compatible endpoint so the chat_completions transport works.
6
+ *
7
+ * A future plugin `@theokit-provider-gemini-direct` can override this with
8
+ * `apiMode: "gemini_generate_content"` once that transport ships.
9
+ */
10
+ export declare const GEMINI: ProviderProfile;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Eager registration of builtin providers (T3.3). Side-effect import:
3
+ * importing this module registers the 4 builtins with the registry.
4
+ *
5
+ * Lazy user-plugin discovery is handled by `discovery.ts` (T3.4).
6
+ *
7
+ * @internal
8
+ */
9
+ import { ANTHROPIC } from "./anthropic.js";
10
+ import { BEDROCK } from "./bedrock.js";
11
+ import { GEMINI } from "./gemini.js";
12
+ import { LLAMACPP } from "./llamacpp.js";
13
+ import { LMSTUDIO } from "./lmstudio.js";
14
+ import { OLLAMA } from "./ollama.js";
15
+ import { OPENAI } from "./openai.js";
16
+ import { OPENROUTER } from "./openrouter.js";
17
+ import { VERTEX } from "./vertex.js";
18
+ export declare function registerBuiltins(): void;
19
+ export { ANTHROPIC, BEDROCK, GEMINI, LLAMACPP, LMSTUDIO, OLLAMA, OPENAI, OPENROUTER, VERTEX };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { ProviderProfile } from "../types.js";
2
+ /**
3
+ * Ollama — local-first LLM runtime (ADR D182).
4
+ *
5
+ * Ships as a builtin so `Agent.create({ model: "ollama/llama3.2" })` works
6
+ * with zero configuration when `ollama serve` is running on the default
7
+ * port. `authType: "none"` signals the router to skip env-key resolution
8
+ * and use a placeholder credential (Ollama ignores Authorization headers
9
+ * on local installs).
10
+ *
11
+ * Overrides:
12
+ * - `OLLAMA_HOST` — replaces the default `http://localhost:11434` baseUrl
13
+ * (advanced users running Ollama on a remote machine).
14
+ * - `OLLAMA_API_KEY` — replaces the placeholder when Ollama is behind a
15
+ * reverse-proxy with auth or when using Ollama Cloud (paid tier).
16
+ */
17
+ export declare const OLLAMA: ProviderProfile;
@@ -0,0 +1,2 @@
1
+ import type { ProviderProfile } from "../types.js";
2
+ export declare const OPENAI: ProviderProfile;
@@ -0,0 +1,2 @@
1
+ import type { ProviderProfile } from "../types.js";
2
+ export declare const OPENROUTER: ProviderProfile;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * GCP Vertex AI profile (Adoption Roadmap #8; ADRs D286-D302).
3
+ *
4
+ * Required peer dep: `google-auth-library` (D288). Resolves access tokens
5
+ * via ADC (env → gcloud → metadata server → WIF).
6
+ *
7
+ * Model IDs follow the convention `vertex/{dialect}/{model}`:
8
+ * - `vertex/google/gemini-2.0-flash-001` → OpenAI-compat endpoint (D291)
9
+ * - `vertex/anthropic/claude-sonnet-4-5@20250929` → :rawPredict (D292)
10
+ *
11
+ * @internal
12
+ */
13
+ export declare const VERTEX: ProviderProfile;
14
+ /**
15
+ * D293 absorbed: when location === "global", use `aiplatform.googleapis.com`
16
+ * (no `global-` prefix) — known bug `streamRawPredict` 404 at
17
+ * `global-aiplatform.googleapis.com` (cline#10287).
18
+ */
19
+ export declare function resolveVertexBaseUrl(opts: {
20
+ projectId: string;
21
+ location: string;
22
+ modelDialect: "anthropic" | "gemini";
23
+ }): string;
24
+ /** Detect dialect from a `vertex/{dialect}/{model}` id. Default: gemini. */
25
+ export declare function inferModelDialect(modelId: string): "anthropic" | "gemini";
26
+ /** Strip the `vertex/{dialect}/` prefix so the raw model id is used in the URL. */
27
+ export declare function stripVertexPrefix(modelId: string): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Lazy provider discovery (T3.4, ADR D107).
3
+ *
4
+ * Scans `~/.theokit/plugins/model-providers/<name>/index.{js,mjs}` and
5
+ * imports each as a Plugin. Plugins with `kind: "model-provider"` register
6
+ * their profile. Errors per plugin are logged + skipped. Idempotent per
7
+ * process.
8
+ *
9
+ * EC-9: dynamic `import()` in Node 22 needs `file://` URL for absolute
10
+ * paths in ESM contexts. `pathToFileURL` handles both.
11
+ *
12
+ * @internal
13
+ */
14
+ export declare function discoverProviderPlugins(): Promise<void>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Barrel for the provider-as-plugin system (ADRs D105-D107).
3
+ *
4
+ * @internal
5
+ */
6
+ export { _resetDiscovery, discoverProviderPlugins } from "./discovery.js";
7
+ export { _resetProvidersForTests, getProviderProfile, listProviders, registerProvider, } from "./registry.js";
8
+ export type { ApiMode, AuthType, ProviderProfile } from "./types.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Provider registry (T3.2, ADR D107).
3
+ *
4
+ * `registerProvider` is idempotent and surface-warning: re-registering
5
+ * a `name` logs to stderr (D107 last-writer-wins with WARN). Alias
6
+ * collisions also warn (EC-5).
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function registerProvider(profile: ProviderProfile): void;
11
+ export declare function getProviderProfile(name: string): ProviderProfile | undefined;
12
+ export declare function listProviders(): ProviderProfile[];
@@ -0,0 +1,27 @@
1
+ /**
2
+ * ProviderProfile + ApiMode types (T3.1, ADR D105).
3
+ *
4
+ * Profile is **data-only** — no methods. Adding a provider is declaring an
5
+ * object literal; the Transport layer (D106) consumes `apiMode` to pick
6
+ * the HTTP dialect.
7
+ *
8
+ * @public
9
+ */
10
+ export type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
11
+ export type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
12
+ export interface ProviderProfile {
13
+ name: string;
14
+ apiMode: ApiMode;
15
+ aliases?: ReadonlyArray<string>;
16
+ displayName?: string;
17
+ description?: string;
18
+ signupUrl?: string;
19
+ envVars: ReadonlyArray<string>;
20
+ authType: AuthType;
21
+ baseUrl: string;
22
+ modelsUrl?: string;
23
+ hostname?: string;
24
+ fallbackModels: ReadonlyArray<string>;
25
+ extraHeaders?: Record<string, string>;
26
+ bodyOverrides?: Record<string, unknown>;
27
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `AbortSignal` composition helpers (Production-Readiness #5 / EC-5, ADR D324).
3
+ *
4
+ * `AbortSignal.any` is available in Node 22+ and Cloudflare Workers, but
5
+ * some runtime environments (Vercel Edge subset, older Bun, embedded shells)
6
+ * still lag. The ponyfill mirrors the spec semantics — abort on first signal,
7
+ * propagate `reason` — without depending on the host symbol.
8
+ *
9
+ * @internal
10
+ */
11
+ /**
12
+ * `true` when the given (possibly undefined) signal has aborted. `undefined`
13
+ * signal counts as not aborted (no-signal semantics).
14
+ */
15
+ export declare function isAborted(signal: AbortSignal | undefined): boolean;
16
+ /**
17
+ * Extract the abort reason as an `Error` for wrapping into `AgentRunError`.
18
+ * Spec: `signal.reason` is `unknown` — wrap non-Error values into a generic
19
+ * error so callers always have a `.message` to inspect.
20
+ */
21
+ export declare function abortReasonAsError(signal: AbortSignal): Error;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Tiny DI registry for `Agent.create` (T4.2 + T4.3 wiring).
3
+ *
4
+ * `LocalAgent.runUntil` and `LocalAgent.fork` need to spawn auxiliary
5
+ * agents via `Agent.create`. A direct import would form a cycle
6
+ * (`agent.ts` already imports `LocalAgent`). This module is the seam:
7
+ * `agent.ts` registers the factory at module init time; LocalAgent
8
+ * reads it on-demand.
9
+ *
10
+ * Throws if accessed before registration — should never happen because
11
+ * `agent.ts` evaluation always precedes `LocalAgent.runUntil()` calls
12
+ * (the user must call `Agent.create()` to obtain the LocalAgent first).
13
+ *
14
+ * @internal
15
+ */
16
+ export type AgentCreateFn = (options: AgentOptions) => Promise<SDKAgent>;
@@ -0,0 +1,61 @@
1
+ export interface SerializedAgentOptions {
2
+ name?: string;
3
+ model?: {
4
+ id: string;
5
+ };
6
+ systemPrompt?: string;
7
+ local?: {
8
+ cwd?: string;
9
+ settingSources?: ReadonlyArray<string>;
10
+ sandboxOptions?: {
11
+ enabled: boolean;
12
+ };
13
+ };
14
+ cloud?: {
15
+ repos: ReadonlyArray<{
16
+ url: string;
17
+ startingRef?: string;
18
+ }>;
19
+ autoCreatePR?: boolean;
20
+ };
21
+ memory?: {
22
+ enabled: boolean;
23
+ namespace?: string;
24
+ userId?: string;
25
+ scope?: string;
26
+ index?: {
27
+ tools?: boolean;
28
+ backend?: string;
29
+ embedding?: {
30
+ provider: string;
31
+ model?: string;
32
+ };
33
+ };
34
+ activeRecall?: Record<string, unknown>;
35
+ };
36
+ skills?: {
37
+ enabled?: ReadonlyArray<string>;
38
+ };
39
+ plugins?: {
40
+ enabled?: ReadonlyArray<string>;
41
+ };
42
+ context?: {
43
+ manager?: string;
44
+ maxTokens?: number;
45
+ };
46
+ providers?: {
47
+ routes: ReadonlyArray<{
48
+ capability: string;
49
+ provider: string;
50
+ model?: string;
51
+ }>;
52
+ fallback?: ReadonlyArray<string>;
53
+ };
54
+ agents?: Record<string, {
55
+ description: string;
56
+ prompt: string;
57
+ model?: {
58
+ id: string;
59
+ } | "inherit";
60
+ }>;
61
+ }
@@ -0,0 +1,34 @@
1
+ import type { AgentOptions, ModelSelection } from "../../types/agent.js";
2
+ export interface RegisteredAgent {
3
+ agentId: string;
4
+ runtime: AgentRuntime;
5
+ name?: string;
6
+ summary?: string;
7
+ model?: ModelSelection;
8
+ createdAt: number;
9
+ lastModified: number;
10
+ archived: boolean;
11
+ options: AgentOptions;
12
+ /** Local workspace cwd; only set when runtime is local. Also used as the
13
+ * persistence routing key (cloud agents default to `process.cwd()`). */
14
+ cwd?: string;
15
+ /** Cloud repo URLs; only set when runtime is cloud. */
16
+ repos?: string[];
17
+ /** Optional explicit status reported via SDKAgentInfo.status. */
18
+ status?: "running" | "finished" | "error";
19
+ /**
20
+ * EC-3 (ADR D325): marker set at create-time when
21
+ * `AgentOptions.conversationStorage` was non-undefined. `Agent.resume`
22
+ * checks this flag — if `true` AND the caller did not pass
23
+ * `conversationStorage` again, throws `ConfigurationError(code:
24
+ * "conversation_storage_required")` instead of silently falling back to
25
+ * the FS adapter (which would lose Postgres/Redis history).
26
+ */
27
+ requiresCustomStorage?: boolean;
28
+ }
29
+ export declare function registerAgent(agent: RegisteredAgent): void;
30
+ export declare function getRegisteredAgent(agentId: string): RegisteredAgent | undefined;
31
+ export declare function listRegisteredAgents(runtime?: AgentRuntime): RegisteredAgent[];
32
+ export declare function updateRegisteredAgent(agentId: string, update: Partial<RegisteredAgent>): RegisteredAgent | undefined;
33
+ export declare function removeRegisteredAgent(agentId: string): boolean;
34
+ export declare function clearAgentRegistry(): void;
@@ -0,0 +1,3 @@
1
+ import type { SessionMessage } from "./agent-session.js";
2
+ export declare function sessionFilePath(cwd: string, agentId: string): string;
3
+ export declare function readSessionFile(cwd: string, agentId: string): Promise<SessionMessage[]>;
@@ -0,0 +1,2 @@
1
+ export declare function getSessionMessages(agentId: string): SessionMessage[];
2
+ export declare function clearSession(agentId: string): void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Per-fork tool whitelist via `AsyncLocalStorage` (ADR D111).
3
+ *
4
+ * Forked agents (background review, curator, judge) need a tool subset
5
+ * distinct from the parent's. A global mutable `let _whitelist` would
6
+ * corrupt state when two forks run in parallel. `AsyncLocalStorage`
7
+ * propagates the whitelist through the async chain so each fork sees its
8
+ * own — no cross-fork bleed.
9
+ *
10
+ * Outside a `withToolWhitelist(...)` scope, `currentToolWhitelist()`
11
+ * returns `undefined` and `checkToolWhitelist` allows every tool — the
12
+ * parent agent is unaffected.
13
+ *
14
+ * Wire site: `internal/agent-loop/tool-dispatch.ts:dispatchSingleCall`
15
+ * calls `checkToolWhitelist` after the repair middleware and before
16
+ * `tools.find`.
17
+ *
18
+ * @internal
19
+ */
20
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Async-aware counting semaphore (ADR D135).
3
+ *
4
+ * N-permit gate for cooperative concurrency control inside a single
5
+ * Node process. Used by `Agent.batch` to bound parallel agent count
6
+ * without pulling in `p-limit` or `p-queue` (~30 LoC in-house).
7
+ *
8
+ * Contract: `acquire()` returns a release function. Caller MUST call
9
+ * release exactly once when done — typically in a `finally` block.
10
+ * Release is idempotent (multiple calls are no-ops after the first)
11
+ * for defense against caller bugs, but leaking the release function
12
+ * permanently consumes one permit (EC-G — caller responsibility).
13
+ *
14
+ * @internal
15
+ */
16
+ export interface AsyncSemaphore {
17
+ /** Acquire a permit. Returns the release function (call once). */
18
+ acquire(): Promise<() => void>;
19
+ /** Permits currently held in flight. */
20
+ inFlight(): number;
21
+ /** Total: in-flight + queued waiters. */
22
+ pending(): number;
23
+ }
24
+ export declare function createSemaphore(permits: number): AsyncSemaphore;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Iteration budget for the agent loop (T2.1, ADRs D90-D91).
3
+ *
4
+ * Tracks remaining iterations + compression attempts + grace-call usage.
5
+ * Caps prevent the 4 compression death spirals Hermes shipped:
6
+ * - v0.4 #1723: `compression_attempts` never reset
7
+ * - v0.7 #4750: compression triggers → fails → triggers again
8
+ * - v0.11 #10065: stale agent timeout, empty response after tools
9
+ * - v0.11 #10472: empty-tools after tools, premature loop exit
10
+ *
11
+ * Default: max 8 iterations, max 3 compressions per session, 1 grace call.
12
+ *
13
+ * NOTE on caller-supplied huge maxIterations (EC-12): `Number.MAX_SAFE_INTEGER`
14
+ * is honored — caller is responsible for picking a reasonable cap. Recommended
15
+ * ≤32 for production workloads.
16
+ *
17
+ * NOTE on per-send reset (EC-14): each `Agent.send` should construct a fresh
18
+ * `IterationBudget`. This is intentional — every send is its own iteration
19
+ * round, not a long-running budget shared across sends.
20
+ *
21
+ * @internal
22
+ */
23
+ export declare class CompressionExhaustedError extends Error {
24
+ readonly name: string;
25
+ }
26
+ export declare class CompressionIneffectiveError extends Error {
27
+ readonly name: string;
28
+ }
29
+ export interface IterationBudgetOptions {
30
+ /** Total iterations before grace call. Default 8. */
31
+ maxIterations?: number;
32
+ /** Max compression attempts per session (D91). Default 3. */
33
+ maxCompressions?: number;
34
+ /** When true (default), one final iteration is allowed after budget exhausted. */
35
+ allowGraceCall?: boolean;
36
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { AgentOptions } from "../../types/agent.js";
2
+ import type { CloudAgentPayload } from "./cloud-payload-types.js";
3
+ export declare function serializeCloudAgentConfig(options: AgentOptions): CloudAgentPayload;