@theokit/sdk 1.6.2 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +193 -0
- package/bin/init-claude.mjs +34 -0
- package/claude-template/AGENTS.md +139 -0
- package/claude-template/CLAUDE.md +51 -0
- package/claude-template/dot-claude/rules/theokit-conventions.md +33 -0
- package/claude-template/dot-claude/settings.json +16 -0
- package/claude-template/dot-claude/skills/theokit-agent-core/SKILL.md +209 -0
- package/claude-template/dot-claude/skills/theokit-budget/SKILL.md +176 -0
- package/claude-template/dot-claude/skills/theokit-config/SKILL.md +139 -0
- package/claude-template/dot-claude/skills/theokit-cron/SKILL.md +148 -0
- package/claude-template/dot-claude/skills/theokit-di/SKILL.md +233 -0
- package/claude-template/dot-claude/skills/theokit-di-agent/SKILL.md +294 -0
- package/claude-template/dot-claude/skills/theokit-errors/SKILL.md +172 -0
- package/claude-template/dot-claude/skills/theokit-eval/SKILL.md +144 -0
- package/claude-template/dot-claude/skills/theokit-gateways/SKILL.md +209 -0
- package/claude-template/dot-claude/skills/theokit-memory/SKILL.md +176 -0
- package/claude-template/dot-claude/skills/theokit-rag/SKILL.md +226 -0
- package/claude-template/dot-claude/skills/theokit-streaming/SKILL.md +156 -0
- package/claude-template/dot-claude/skills/theokit-subscriptions/SKILL.md +148 -0
- package/claude-template/dot-claude/skills/theokit-tools/SKILL.md +170 -0
- package/claude-template/dot-claude/skills/theokit-workflows/SKILL.md +218 -0
- package/dist/a2a/agent-mailbox.d.cts +27 -0
- package/dist/a2a/agent-mailbox.d.ts +27 -0
- package/dist/a2a/index.cjs +16850 -0
- package/dist/a2a/index.cjs.map +1 -0
- package/dist/a2a/index.d.cts +9 -0
- package/dist/a2a/index.d.ts +9 -0
- package/dist/a2a/index.js +16844 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/message-bus.d.cts +27 -0
- package/dist/a2a/message-bus.d.ts +27 -0
- package/dist/a2a/subagent.d.cts +25 -0
- package/dist/a2a/subagent.d.ts +25 -0
- package/dist/a2a/types.d.cts +12 -0
- package/dist/a2a/types.d.ts +12 -0
- package/dist/agent.d.ts +1 -1
- package/dist/client/index.cjs +73 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +7 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +71 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/theokit-client.d.cts +18 -0
- package/dist/client/theokit-client.d.ts +18 -0
- package/dist/client/types.d.cts +19 -0
- package/dist/client/types.d.ts +19 -0
- package/dist/{run-DkCD5DeO.d.cts → cron-BnywDYLq.d.cts} +496 -910
- package/dist/{run-DkCD5DeO.d.ts → cron-CtZvJD9J.d.ts} +496 -910
- package/dist/cron.cjs +4285 -2893
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -3
- package/dist/cron.d.ts +2 -71
- package/dist/cron.js +4289 -2897
- package/dist/cron.js.map +1 -1
- package/dist/{errors-CvAeEWgE.d.ts → errors-ChqOmFH1.d.cts} +52 -6
- package/dist/{errors-CK8brCJ1.d.cts → errors-DV9e0rcp.d.ts} +52 -6
- package/dist/errors.cjs +218 -3
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +2 -3
- package/dist/errors.d.ts +50 -4
- package/dist/errors.js +217 -4
- package/dist/errors.js.map +1 -1
- package/dist/eval.cjs +4285 -2893
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +35 -0
- package/dist/eval.js +4289 -2897
- package/dist/eval.js.map +1 -1
- package/dist/event-bus.d.ts +23 -0
- package/dist/index.cjs +5132 -4200
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +298 -278
- package/dist/index.d.ts +1898 -24
- package/dist/index.js +6441 -5509
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop-context-init.d.ts +2 -0
- package/dist/internal/agent-loop/tool-dispatch.d.ts +22 -1
- package/dist/internal/auth/api-key-validator.d.ts +46 -0
- package/dist/internal/llm/anthropic-shared.d.ts +8 -1
- package/dist/internal/llm/retry.d.ts +22 -0
- package/dist/internal/llm/types.d.ts +47 -1
- package/dist/internal/memory/active-memory-cache.d.ts +3 -3
- package/dist/internal/memory/active-memory-types.d.ts +8 -0
- package/dist/internal/memory/active-memory.d.ts +24 -20
- package/dist/internal/memory/adapters/azure-openai-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/cohere-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/gemini-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/jina-embedding.d.ts +2 -0
- package/dist/internal/memory/index-manager-contract.d.ts +26 -0
- package/dist/internal/memory/index-manager-dispatch.d.ts +1 -1
- package/dist/internal/memory/index-manager.d.ts +8 -26
- package/dist/internal/memory/{chunk-markdown.d.ts → storage/chunk-markdown.d.ts} +1 -1
- package/dist/internal/memory/{markdown-store.d.ts → storage/markdown-store.d.ts} +1 -1
- package/dist/internal/memory/{reader.d.ts → storage/reader.d.ts} +1 -1
- package/dist/internal/observability/context.d.cts +23 -0
- package/dist/internal/observability/context.d.ts +23 -0
- package/dist/internal/observability/index.cjs +38 -0
- package/dist/internal/observability/index.cjs.map +1 -0
- package/dist/internal/observability/index.d.cts +8 -0
- package/dist/internal/observability/index.d.ts +8 -0
- package/dist/internal/observability/index.js +33 -0
- package/dist/internal/observability/index.js.map +1 -0
- package/dist/internal/observability/tracer-loader.d.cts +20 -0
- package/dist/internal/persistence/conversation-storage-fs.d.cts +37 -0
- package/dist/internal/persistence/conversation-storage-memory.d.cts +24 -0
- package/dist/internal/persistence/credential-pool-store.d.cts +32 -0
- package/dist/internal/persistence/credential-pool-store.d.ts +32 -0
- package/dist/internal/persistence/cwd-mutex.d.cts +1 -0
- package/dist/internal/persistence/exclusive-create.d.cts +22 -0
- package/dist/internal/persistence/exclusive-create.d.ts +22 -0
- package/dist/internal/persistence/file-lock.d.cts +14 -0
- package/dist/internal/persistence/fts5-sanitize.d.cts +16 -0
- package/dist/internal/persistence/index.cjs +359 -0
- package/dist/internal/persistence/index.cjs.map +1 -0
- package/dist/internal/persistence/index.d.cts +20 -0
- package/dist/internal/persistence/index.d.ts +20 -0
- package/dist/internal/persistence/index.js +341 -0
- package/dist/internal/persistence/index.js.map +1 -0
- package/dist/internal/persistence/markdown-config-loader.d.cts +35 -0
- package/dist/internal/persistence/paths.d.cts +19 -0
- package/dist/internal/persistence/persistence-schema.d.cts +21 -0
- package/dist/internal/persistence/persistence-schema.d.ts +4 -0
- package/dist/internal/persistence/schema-version.d.cts +13 -0
- package/dist/internal/persistence/sqlite-cas.d.cts +25 -0
- package/dist/internal/persistence/sqlite-cas.d.ts +25 -0
- package/dist/internal/persistence/sqlite-wal.d.cts +10 -0
- package/dist/internal/plugins/context.d.cts +31 -0
- package/dist/internal/plugins/index.cjs +228 -0
- package/dist/internal/plugins/index.cjs.map +1 -0
- package/dist/internal/plugins/index.d.cts +8 -0
- package/dist/internal/plugins/index.d.ts +8 -0
- package/dist/internal/plugins/index.js +222 -0
- package/dist/internal/plugins/index.js.map +1 -0
- package/dist/internal/plugins/lifecycle.d.cts +14 -0
- package/dist/internal/plugins/lifecycle.d.ts +14 -0
- package/dist/internal/plugins/manager.d.cts +37 -0
- package/dist/internal/plugins/types.d.cts +102 -0
- package/dist/internal/providers/catalog-loader.d.ts +39 -0
- package/dist/internal/runtime/agent-session-store.d.ts +1 -1
- package/dist/internal/runtime/agent-session.d.ts +1 -0
- package/dist/internal/runtime/budget-tracker.d.ts +73 -0
- package/dist/internal/runtime/{context-manager.d.ts → context/context-manager.d.ts} +1 -1
- package/dist/internal/runtime/{fixture-events.d.ts → fixtures/fixture-events.d.ts} +1 -1
- package/dist/internal/runtime/{fixture-run-base.d.ts → fixtures/fixture-run-base.d.ts} +4 -4
- package/dist/internal/runtime/{fixture-scripts.d.ts → fixtures/fixture-scripts.d.ts} +1 -1
- package/dist/internal/runtime/local-agent-bootstrap.d.ts +2 -2
- package/dist/internal/runtime/local-agent-memory-provider.d.ts +57 -0
- package/dist/internal/runtime/memory-path-selector.d.ts +73 -0
- package/dist/internal/runtime/memory-provider.d.ts +165 -0
- package/dist/internal/runtime/{agent-registry.d.ts → registry/agent-registry-contract.d.ts} +15 -9
- package/dist/internal/runtime/registry/agent-registry.d.ts +7 -0
- package/dist/internal/runtime/{live-agent-registry.d.ts → registry/live-agent-registry.d.ts} +1 -1
- package/dist/internal/runtime/{run-registry.d.ts → registry/run-registry.d.ts} +1 -1
- package/dist/internal/runtime/session-types.d.ts +35 -0
- package/dist/internal/runtime/system-prompt/sources/skills-provider.d.ts +1 -0
- package/dist/internal/runtime/validate-response.d.ts +18 -0
- package/dist/internal/security/index.cjs +361 -0
- package/dist/internal/security/index.cjs.map +1 -0
- package/dist/internal/security/index.d.cts +11 -0
- package/dist/internal/security/index.js +350 -0
- package/dist/internal/security/index.js.map +1 -0
- package/dist/internal/security/path-guard.d.cts +59 -0
- package/dist/internal/security/path-guard.d.ts +3 -0
- package/dist/internal/security/redact.d.cts +21 -0
- package/dist/internal/security/secret-redactor.d.cts +1 -0
- package/dist/internal/security/secret-redactor.d.ts +1 -0
- package/dist/internal/security/test-reset.d.cts +10 -0
- package/dist/internal/security/test-reset.d.ts +10 -0
- package/dist/internal/telemetry/adapters/arize.d.ts +2 -0
- package/dist/internal/telemetry/adapters/braintrust.d.ts +2 -0
- package/dist/internal/telemetry/adapters/datadog.d.ts +2 -0
- package/dist/internal/telemetry/adapters/langsmith.d.ts +2 -0
- package/dist/internal/telemetry/span-names.d.ts +6 -0
- package/dist/internal/telemetry/tracer.d.ts +1 -0
- package/dist/internal/workflow/evented-executor.d.ts +42 -0
- package/dist/internal/workflow/scheduler.d.ts +23 -0
- package/dist/internal/zod/to-json-schema.d.ts +5 -15
- package/dist/job-queue.d.ts +28 -0
- package/dist/path-safety.cjs +67 -6
- package/dist/path-safety.cjs.map +1 -1
- package/dist/path-safety.d.cts +15 -0
- package/dist/path-safety.d.ts +1 -1
- package/dist/path-safety.js +67 -7
- package/dist/path-safety.js.map +1 -1
- package/dist/permission-engine.d.ts +21 -0
- package/dist/provider-catalog.json +702 -0
- package/dist/rag/index.cjs +136 -0
- package/dist/rag/index.cjs.map +1 -0
- package/dist/rag/index.d.cts +11 -0
- package/dist/rag/index.d.ts +11 -0
- package/dist/rag/index.js +129 -0
- package/dist/rag/index.js.map +1 -0
- package/dist/rag/reranker.d.cts +26 -0
- package/dist/rag/reranker.d.ts +26 -0
- package/dist/rag/retriever.d.cts +25 -0
- package/dist/rag/retriever.d.ts +25 -0
- package/dist/rag/text-splitter.d.cts +12 -0
- package/dist/rag/text-splitter.d.ts +12 -0
- package/dist/rag/types.d.cts +37 -0
- package/dist/rag/types.d.ts +37 -0
- package/dist/run-DrwUpFxZ.d.cts +823 -0
- package/dist/run-DrwUpFxZ.d.ts +823 -0
- package/dist/sandbox/index.cjs +133 -0
- package/dist/sandbox/index.cjs.map +1 -0
- package/dist/sandbox/index.d.cts +2 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.js +128 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/local-sandbox.d.cts +17 -0
- package/dist/sandbox/local-sandbox.d.ts +17 -0
- package/dist/sandbox/types.d.cts +44 -0
- package/dist/sandbox/types.d.ts +44 -0
- package/dist/server/adapter/express.d.cts +9 -0
- package/dist/server/adapter/express.d.ts +9 -0
- package/dist/server/adapter/fastify.d.cts +9 -0
- package/dist/server/adapter/fastify.d.ts +9 -0
- package/dist/server/adapter/hono.d.cts +9 -0
- package/dist/server/adapter/hono.d.ts +9 -0
- package/dist/server/adapter/index.d.cts +8 -0
- package/dist/server/adapter/index.d.ts +8 -0
- package/dist/server/adapter/shared-handler.d.cts +9 -0
- package/dist/server/adapter/shared-handler.d.ts +9 -0
- package/dist/server/adapter/types.d.cts +33 -0
- package/dist/server/adapter/types.d.ts +33 -0
- package/dist/server/auth/errors.d.cts +53 -0
- package/dist/server/auth/errors.d.ts +53 -0
- package/dist/server/auth/index.cjs +38 -41
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +11 -172
- package/dist/server/auth/index.d.ts +11 -172
- package/dist/server/auth/index.js +39 -42
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/oauth-transaction-store.d.cts +39 -0
- package/dist/server/auth/oauth-transaction-store.d.ts +39 -0
- package/dist/server/auth/orchestrator.d.cts +8 -0
- package/dist/server/auth/orchestrator.d.ts +8 -0
- package/dist/server/auth/types.d.cts +91 -0
- package/dist/server/auth/types.d.ts +91 -0
- package/dist/server/auth/validate-return-to.d.cts +17 -0
- package/dist/server/auth/validate-return-to.d.ts +17 -0
- package/dist/server/errors-envelope.cjs +409 -0
- package/dist/server/errors-envelope.cjs.map +1 -0
- package/dist/server/errors-envelope.d.cts +61 -0
- package/dist/server/errors-envelope.d.ts +61 -0
- package/dist/server/errors-envelope.js +405 -0
- package/dist/server/errors-envelope.js.map +1 -0
- package/dist/subscription/define-subscription.d.cts +63 -0
- package/dist/subscription/define-subscription.d.ts +63 -0
- package/dist/subscription/index.cjs +402 -0
- package/dist/subscription/index.cjs.map +1 -0
- package/dist/subscription/index.d.cts +18 -0
- package/dist/subscription/index.d.ts +18 -0
- package/dist/subscription/index.js +394 -0
- package/dist/subscription/index.js.map +1 -0
- package/dist/subscription/internal/adapter-types.d.cts +11 -0
- package/dist/subscription/internal/adapter-types.d.ts +11 -0
- package/dist/subscription/internal/backpressure.d.cts +24 -0
- package/dist/subscription/internal/backpressure.d.ts +24 -0
- package/dist/subscription/internal/server-integration.d.cts +17 -0
- package/dist/subscription/internal/server-integration.d.ts +17 -0
- package/dist/subscription/internal/sse-encoder.d.cts +13 -0
- package/dist/subscription/internal/sse-encoder.d.ts +13 -0
- package/dist/subscription/internal/sse-parser.d.cts +15 -0
- package/dist/subscription/internal/sse-parser.d.ts +15 -0
- package/dist/subscription/internal/subscription-runtime.d.cts +9 -0
- package/dist/subscription/internal/subscription-runtime.d.ts +9 -0
- package/dist/subscription/internal/ws-adapter-node.d.cts +10 -0
- package/dist/subscription/internal/ws-adapter-node.d.ts +10 -0
- package/dist/subscription/theokit-subscribe.d.cts +41 -0
- package/dist/subscription/theokit-subscribe.d.ts +41 -0
- package/dist/subscription/types.d.cts +140 -0
- package/dist/subscription/types.d.ts +140 -0
- package/dist/task-store.cjs +30 -2
- package/dist/task-store.cjs.map +1 -1
- package/dist/task-store.d.cts +8 -0
- package/dist/task-store.js +31 -3
- package/dist/task-store.js.map +1 -1
- package/dist/types/agent-prims.d.ts +61 -0
- package/dist/types/agent.d.ts +48 -53
- package/dist/types/conversation.d.ts +20 -8
- package/dist/types/index.d.ts +0 -2
- package/dist/types/messages-base.d.ts +20 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/run.d.ts +1 -1
- package/dist/types/updates.d.ts +1 -1
- package/dist/voice/index.d.ts +7 -0
- package/dist/voice/openai-realtime.d.ts +21 -0
- package/dist/voice/types.d.ts +35 -0
- package/dist/workflow.cjs +179 -88
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +97 -0
- package/dist/workflow.js +180 -89
- package/dist/workflow.js.map +1 -1
- package/package.json +128 -25
- package/dist/budget.d.ts +0 -48
- package/dist/cache.d.ts +0 -74
- package/dist/cron-1yxL3K2S.d.cts +0 -221
- package/dist/cron-BYVdYzob.d.ts +0 -221
- package/dist/handoff.d.ts +0 -55
- package/dist/internal/budget/calendar-window.d.ts +0 -19
- package/dist/internal/budget/enforcement.d.ts +0 -32
- package/dist/internal/budget/ledger.d.ts +0 -25
- package/dist/internal/budget/normalize-usage.d.ts +0 -27
- package/dist/internal/budget/registry.d.ts +0 -16
- package/dist/internal/cache/cosine.d.ts +0 -14
- package/dist/internal/cache/embed-helper.d.ts +0 -15
- package/dist/internal/cache/key.d.ts +0 -15
- package/dist/internal/cache/lookup.d.ts +0 -28
- package/dist/internal/cache/store-handler.d.ts +0 -24
- package/dist/internal/cache/store-json.d.ts +0 -48
- package/dist/internal/cache/store.d.ts +0 -54
- package/dist/internal/cache/telemetry.d.ts +0 -20
- package/dist/internal/cache/ttl.d.ts +0 -11
- package/dist/internal/catalog/fixtures.d.ts +0 -16
- package/dist/internal/catalog/local-models.d.ts +0 -24
- package/dist/internal/handoff/dispatcher.d.ts +0 -29
- package/dist/internal/handoff/registry.d.ts +0 -23
- package/dist/internal/handoff/telemetry.d.ts +0 -18
- package/dist/internal/handoff/tool-injector.d.ts +0 -34
- package/dist/internal/memory/atomic-write.d.ts +0 -7
- package/dist/internal/memory/dreaming/diary.d.ts +0 -4
- package/dist/internal/memory/dreaming/phases.d.ts +0 -15
- package/dist/internal/memory/dreaming/run.d.ts +0 -10
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +0 -15
- package/dist/memory-adapter-helpers.d.ts +0 -28
- package/dist/memory.d.ts +0 -123
- package/dist/migrate.d.ts +0 -33
- package/dist/security.d.ts +0 -67
- package/dist/task.d.ts +0 -87
- package/dist/theokit.d.ts +0 -84
- package/dist/tools/_path-scope.d.ts +0 -8
- package/dist/tools/_subprocess.d.ts +0 -28
- package/dist/tools/git-diff.d.ts +0 -22
- package/dist/tools/index.d.ts +0 -29
- package/dist/tools/list-dir.d.ts +0 -26
- package/dist/tools/read-file.d.ts +0 -31
- package/dist/tools/run-vitest.d.ts +0 -46
- package/dist/tools/search-text.d.ts +0 -32
- package/dist/tools.cjs +0 -690
- package/dist/tools.cjs.map +0 -1
- package/dist/tools.js +0 -683
- package/dist/tools.js.map +0 -1
- package/dist/trajectory-helpers.d.ts +0 -31
- package/dist/types/cache.d.ts +0 -76
- package/dist/types/handoff.d.ts +0 -135
- /package/dist/{internal/cron/run-job.d.ts → agent-helpers.d.ts} +0 -0
- /package/dist/internal/{cron/scheduler.d.ts → agent-loop/loop-llm-stream.d.ts} +0 -0
- /package/dist/internal/{cron/store.d.ts → agent-loop/tool-executors.d.ts} +0 -0
- /package/dist/internal/{cron/validate.d.ts → memory/index-manager-helpers.d.ts} +0 -0
- /package/dist/internal/memory/{session-loader.d.ts → storage/session-loader.d.ts} +0 -0
- /package/dist/internal/memory/{session-summary-writer.d.ts → storage/session-summary-writer.d.ts} +0 -0
- /package/dist/internal/memory/{transcript-store.d.ts → storage/transcript-store.d.ts} +0 -0
- /package/dist/internal/memory/{wiki-loader.d.ts → storage/wiki-loader.d.ts} +0 -0
- /package/dist/internal/{memory/cwd-mutex.d.ts → persistence/atomic-write.d.cts} +0 -0
- /package/dist/internal/runtime/{context-aggregator.d.ts → context/context-aggregator.d.ts} +0 -0
- /package/dist/internal/runtime/{context-discovery-runner.d.ts → context/context-discovery-runner.d.ts} +0 -0
- /package/dist/internal/runtime/{context-discovery.d.ts → context/context-discovery.d.ts} +0 -0
- /package/dist/internal/runtime/{context-frontmatter.d.ts → context/context-frontmatter.d.ts} +0 -0
- /package/dist/internal/runtime/{context-import-resolver.d.ts → context/context-import-resolver.d.ts} +0 -0
- /package/dist/internal/runtime/{context-loaders.d.ts → context/context-loaders.d.ts} +0 -0
- /package/dist/internal/runtime/{context-mdc-parser.d.ts → context/context-mdc-parser.d.ts} +0 -0
- /package/dist/internal/runtime/{fixture-responder.d.ts → fixtures/fixture-responder.d.ts} +0 -0
- /package/dist/internal/runtime/{fixture-types.d.ts → fixtures/fixture-types.d.ts} +0 -0
- /package/dist/internal/runtime/{plugins-manager.d.ts → local-agent-send.d.ts} +0 -0
- /package/dist/internal/runtime/{plugin-frontmatter.d.ts → plugins/plugin-frontmatter.d.ts} +0 -0
- /package/dist/internal/runtime/{system-prompt/providers/active-memory-provider.d.ts → plugins/plugins-manager.d.ts} +0 -0
- /package/dist/internal/runtime/{agent-factory-registry.d.ts → registry/agent-factory-registry.d.ts} +0 -0
- /package/dist/internal/runtime/{agent-registry-store.d.ts → registry/agent-registry-store.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/base-provider.d.ts → sources/active-memory-provider.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/context-provider.d.ts → sources/base-provider.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/memory-provider.d.ts → sources/context-provider.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/skills-provider.d.ts → sources/memory-provider.d.ts} +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
user-invocable: false
|
|
3
|
+
paths:
|
|
4
|
+
- "**/*eval*"
|
|
5
|
+
- "**/*Eval*"
|
|
6
|
+
- "**/*scorer*"
|
|
7
|
+
description: TheoKit SDK Eval suite API reference — Eval.create, scorers, datasets, EvalRun
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# TheoKit Eval Suite
|
|
11
|
+
|
|
12
|
+
Eval-as-code primitive for production deploy gates. Run evals against real LLM
|
|
13
|
+
providers to measure quality, latency, and cost before shipping.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Eval, Scorers } from "@theokit/sdk";
|
|
19
|
+
|
|
20
|
+
const run = await Eval.create({
|
|
21
|
+
name: "qa-smoke",
|
|
22
|
+
dataset: [
|
|
23
|
+
{ input: "Reply with the word: ok.", expected: "ok" },
|
|
24
|
+
{ input: "Say jazz in one word.", expected: "jazz" },
|
|
25
|
+
],
|
|
26
|
+
scorers: [
|
|
27
|
+
Scorers.containsExpected({ caseSensitive: false }),
|
|
28
|
+
Scorers.regex(/[a-zA-Z]/),
|
|
29
|
+
],
|
|
30
|
+
agent: {
|
|
31
|
+
apiKey: process.env.OPENROUTER_API_KEY,
|
|
32
|
+
model: { id: "openai/gpt-4o-mini" },
|
|
33
|
+
local: { cwd: process.cwd(), sandboxOptions: { enabled: false } },
|
|
34
|
+
},
|
|
35
|
+
concurrency: 4,
|
|
36
|
+
}).run();
|
|
37
|
+
|
|
38
|
+
console.log(run.aggregate.meanScore); // 0.95
|
|
39
|
+
console.log(run.aggregate.passRatio); // 1.0
|
|
40
|
+
console.log(run.aggregate.tokensInTotal); // 142
|
|
41
|
+
console.log(run.aggregate.durationMsP95); // 1830
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Built-in scorers (`Scorers`)
|
|
45
|
+
|
|
46
|
+
| Scorer | What it checks |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `Scorers.exactMatch({ caseSensitive? })` | `output.trim() === expected.trim()` — refuses empty `expected` |
|
|
49
|
+
| `Scorers.containsExpected({ caseSensitive? })` | `output.includes(expected)` — refuses empty `expected` |
|
|
50
|
+
| `Scorers.regex(pattern)` | `pattern.test(output)` — test patterns against adversarial output to avoid ReDoS |
|
|
51
|
+
| `Scorers.jsonShape(zodSchema, { strict? })` | `JSON.parse(output)` + Zod validation — caps output at 1 MB before parse |
|
|
52
|
+
| `Scorers.llmJudge({ model, apiKey, criteria, rubric? })` | Second LLM scores against criteria — requires SEPARATE `apiKey` |
|
|
53
|
+
|
|
54
|
+
### Custom scorer
|
|
55
|
+
|
|
56
|
+
A scorer is an async function returning a number between 0 and 1:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const myScorer = async (row: { input: string; output: string; expected?: string }) => {
|
|
60
|
+
return row.output.length < 100 ? 1.0 : 0.5;
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Dataset
|
|
65
|
+
|
|
66
|
+
The `dataset` field accepts an array of objects with `input` and optional `expected`:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
interface EvalDatasetRow {
|
|
70
|
+
input: string;
|
|
71
|
+
expected?: string;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Recommended ceiling: ~10k rows (v1 materializes in memory). For larger evals,
|
|
76
|
+
partition into multiple `Eval.create` calls.
|
|
77
|
+
|
|
78
|
+
## `EvalRun` shape
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
interface EvalRun {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
startedAt: number;
|
|
85
|
+
endedAt: number;
|
|
86
|
+
durationMs: number;
|
|
87
|
+
aggregate: EvalAggregate;
|
|
88
|
+
rows: ReadonlyArray<EvalRowResult>;
|
|
89
|
+
metadata?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface EvalAggregate {
|
|
93
|
+
meanScore: number;
|
|
94
|
+
medianScore: number;
|
|
95
|
+
passRatio: number; // rows where meanScore >= 0.5
|
|
96
|
+
perScorer: Record<string, { mean; median; min; max }>;
|
|
97
|
+
totalRows: number;
|
|
98
|
+
errorRows: number;
|
|
99
|
+
durationMsP50: number;
|
|
100
|
+
durationMsP95: number;
|
|
101
|
+
tokensInTotal: number;
|
|
102
|
+
tokensOutTotal: number;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`EvalRun` is plain JSON — `JSON.stringify(run)` works directly.
|
|
107
|
+
|
|
108
|
+
## Concurrency
|
|
109
|
+
|
|
110
|
+
`concurrency` defaults to 4. Allowed range: `[1, 64]` (integer). 0 and
|
|
111
|
+
Infinity are rejected at `Eval.create` time.
|
|
112
|
+
|
|
113
|
+
## Concurrent runs
|
|
114
|
+
|
|
115
|
+
Per-process single-flight per `name`. Two `Eval.run` calls with the same
|
|
116
|
+
`name` running simultaneously throw `EvalAlreadyRunningError`. Include model
|
|
117
|
+
id in the name for matrix runs.
|
|
118
|
+
|
|
119
|
+
## CLI integration
|
|
120
|
+
|
|
121
|
+
The `theokit eval` CLI invokes `Eval.run` internally. User-authored
|
|
122
|
+
`eval.config.{ts,mjs}` files are forward-compatible.
|
|
123
|
+
|
|
124
|
+
## Telemetry
|
|
125
|
+
|
|
126
|
+
When `agent.telemetry.enabled === true`, `Eval.run` emits a parent `eval.run`
|
|
127
|
+
OTel span; `agent.send` / `llm.call` spans nest under it.
|
|
128
|
+
|
|
129
|
+
## Cost forecasting
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
aggregate.tokensInTotal x provider_input_price
|
|
133
|
+
+ aggregate.tokensOutTotal x provider_output_price
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
With `llmJudge`, add ~1 judge call per row. 1000 rows with `gpt-4o-mini`
|
|
137
|
+
costs roughly $3.00 total (base + judge).
|
|
138
|
+
|
|
139
|
+
## Errors
|
|
140
|
+
|
|
141
|
+
| Error | When |
|
|
142
|
+
|---|---|
|
|
143
|
+
| `EvalAlreadyRunningError` | Same `name` already running in this process |
|
|
144
|
+
| `ConfigurationError` | Invalid concurrency, missing required fields |
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
---
|
|
2
|
+
user-invocable: false
|
|
3
|
+
description: Gateway architecture and 10 platform adapters (Telegram, Slack, Discord, WhatsApp, Teams, Email, SMS, Mattermost, LINE, Matrix).
|
|
4
|
+
paths:
|
|
5
|
+
- "**/*gateway*"
|
|
6
|
+
- "**/*Gateway*"
|
|
7
|
+
- "**/*telegram*"
|
|
8
|
+
- "**/*slack*"
|
|
9
|
+
- "**/*discord*"
|
|
10
|
+
- "**/*whatsapp*"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# TheoKit SDK -- Gateways
|
|
14
|
+
|
|
15
|
+
Quick reference for the gateway architecture and all 10 platform adapters.
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
The gateway system uses a base adapter pattern. Each platform adapter extends `BasePlatformAdapter` from `@theokit/gateway`. The core package defines:
|
|
20
|
+
|
|
21
|
+
- `BasePlatformAdapter` -- abstract class with `connect`, `disconnect`, `sendMessage`, `onInbound`.
|
|
22
|
+
- `GatewayMessageEvent` -- discriminated union of all platform inbound events (keyed by `platform`).
|
|
23
|
+
- `OutboundMessage` -- what `sendMessage` accepts.
|
|
24
|
+
- `SendResult` -- `{ ok, messageId?, error? }`.
|
|
25
|
+
- Session router for multi-platform agent dispatch.
|
|
26
|
+
|
|
27
|
+
## BasePlatformAdapter
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
abstract class BasePlatformAdapter {
|
|
31
|
+
abstract readonly platform: PlatformName;
|
|
32
|
+
abstract connect(): Promise<boolean>;
|
|
33
|
+
abstract disconnect(): Promise<void>;
|
|
34
|
+
abstract sendMessage(out: OutboundMessage): Promise<SendResult>;
|
|
35
|
+
abstract onInbound(handler: (event: GatewayMessageEvent) => Promise<void>): () => void;
|
|
36
|
+
async startTyping(channelId: string): Promise<void> { /* noop */ }
|
|
37
|
+
async stopTyping(channelId: string): Promise<void> { /* noop */ }
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## GatewayMessageEvent (common fields)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
interface BaseMessageEvent {
|
|
45
|
+
id: string;
|
|
46
|
+
platform: PlatformName;
|
|
47
|
+
sender: { id: string; username?: string; displayName?: string };
|
|
48
|
+
channel: { id: string; type: "dm" | "group" | "thread"; topicId?: string };
|
|
49
|
+
text: string;
|
|
50
|
+
receivedAt: number;
|
|
51
|
+
replyTo?: string;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## PlatformName
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
type PlatformName =
|
|
59
|
+
| "telegram" | "discord" | "slack" | "whatsapp" | "teams"
|
|
60
|
+
| "email" | "sms" | "mattermost" | "line" | "matrix";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Platform adapters
|
|
64
|
+
|
|
65
|
+
### 1. Telegram (`@theokit/gateway-telegram`)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pnpm add @theokit/gateway-telegram @theokit/gateway grammy
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { TelegramAdapter } from "@theokit/gateway-telegram";
|
|
73
|
+
|
|
74
|
+
const adapter = new TelegramAdapter({ botToken: process.env.TELEGRAM_BOT_TOKEN! });
|
|
75
|
+
await adapter.connect();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Platform-specific: `event.telegram.chatId`, `event.telegram.messageId`, `event.telegram.threadId?`.
|
|
79
|
+
|
|
80
|
+
### 2. Discord (`@theokit/gateway-discord`)
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm add @theokit/gateway-discord @theokit/gateway discord.js
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { DiscordAdapter } from "@theokit/gateway-discord";
|
|
88
|
+
|
|
89
|
+
const adapter = new DiscordAdapter({ botToken: process.env.DISCORD_BOT_TOKEN! });
|
|
90
|
+
await adapter.connect();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Platform-specific: `event.discord.guildId`, `event.discord.channelId`, `event.discord.messageId`.
|
|
94
|
+
|
|
95
|
+
### 3. Slack (`@theokit/gateway-slack`)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm add @theokit/gateway-slack @theokit/gateway @slack/bolt @slack/web-api
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { SlackAdapter } from "@theokit/gateway-slack";
|
|
103
|
+
|
|
104
|
+
const adapter = new SlackAdapter({
|
|
105
|
+
botToken: process.env.SLACK_BOT_TOKEN!,
|
|
106
|
+
appToken: process.env.SLACK_APP_TOKEN!,
|
|
107
|
+
requireMention: true, // default; public channels need @bot mention
|
|
108
|
+
});
|
|
109
|
+
await adapter.connect();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Platform-specific: `event.slack.teamId`, `event.slack.channelId`, `event.slack.ts`, `event.slack.threadTs?`.
|
|
113
|
+
|
|
114
|
+
### 4. WhatsApp (`@theokit/gateway-whatsapp`)
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm add @theokit/gateway-whatsapp @theokit/gateway
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Two backends: `"cloud"` (Meta Cloud API) and `"web"` (whatsapp-web.js bridge).
|
|
121
|
+
|
|
122
|
+
Platform-specific: `event.whatsapp.wamid`, `event.whatsapp.backend`, `event.whatsapp.phoneNumberId?`.
|
|
123
|
+
|
|
124
|
+
### 5. Teams (`@theokit/gateway-teams`)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pnpm add @theokit/gateway-teams @theokit/gateway botbuilder
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Platform-specific: `event.teams.activityId`, `event.teams.conversationId`, `event.teams.conversationType`, `event.teams.tenantId?`.
|
|
131
|
+
|
|
132
|
+
### 6. Email (`@theokit/gateway-email`)
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pnpm add @theokit/gateway-email @theokit/gateway
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Uses IMAP for inbound and SMTP for outbound.
|
|
139
|
+
|
|
140
|
+
Platform-specific: `event.email.messageId`, `event.email.subject`, `event.email.fromAddress`, `event.email.recipients`.
|
|
141
|
+
|
|
142
|
+
### 7. SMS (`@theokit/gateway-sms`)
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pnpm add @theokit/gateway-sms @theokit/gateway
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Backends: `"twilio"`, `"plivo"`, `"vonage"`. Inbound via webhook server.
|
|
149
|
+
|
|
150
|
+
Platform-specific: `event.sms.backend`, `event.sms.from` (E.164), `event.sms.to` (E.164).
|
|
151
|
+
|
|
152
|
+
### 8. Mattermost (`@theokit/gateway-mattermost`)
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pnpm add @theokit/gateway-mattermost @theokit/gateway
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Platform-specific: `event.mattermost.postId`, `event.mattermost.channelId`, `event.mattermost.rootId?`.
|
|
159
|
+
|
|
160
|
+
### 9. LINE (`@theokit/gateway-line`)
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pnpm add @theokit/gateway-line @theokit/gateway
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Inbound via webhook with signature verification. Reply tokens are cached (one-shot, 60s TTL).
|
|
167
|
+
|
|
168
|
+
Platform-specific: `event.line.sourceType`, `event.line.sourceId`, `event.line.messageId`.
|
|
169
|
+
|
|
170
|
+
### 10. Matrix (`@theokit/gateway-matrix`)
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
pnpm add @theokit/gateway-matrix @theokit/gateway matrix-js-sdk
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Platform-specific: `event.matrix.roomId`, `event.matrix.eventId`, `event.matrix.memberCount`.
|
|
177
|
+
|
|
178
|
+
## Common usage pattern
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { Agent } from "@theokit/sdk";
|
|
182
|
+
|
|
183
|
+
const adapter = new TelegramAdapter({ botToken: process.env.TELEGRAM_BOT_TOKEN! });
|
|
184
|
+
await adapter.connect();
|
|
185
|
+
|
|
186
|
+
adapter.onInbound(async (event) => {
|
|
187
|
+
const agent = await Agent.getOrCreate(`${event.platform}-${event.sender.id}`, {
|
|
188
|
+
apiKey: process.env.THEOKIT_API_KEY!,
|
|
189
|
+
model: { id: "google/gemini-2.0-flash-001" },
|
|
190
|
+
local: { cwd: process.cwd() },
|
|
191
|
+
memory: { enabled: true, namespace: "bot", scope: "user", userId: event.sender.id },
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
await adapter.startTyping(event.channel.id);
|
|
195
|
+
const run = await agent.send(event.text);
|
|
196
|
+
const result = await run.wait();
|
|
197
|
+
await adapter.stopTyping(event.channel.id);
|
|
198
|
+
|
|
199
|
+
await adapter.sendMessage({
|
|
200
|
+
channel: event.channel,
|
|
201
|
+
text: result.result ?? "No response.",
|
|
202
|
+
replyTo: event.id,
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Error mapping convention
|
|
208
|
+
|
|
209
|
+
Each adapter maps platform errors to canonical `SendResult.error.code` values: `rate_limit`, `channel_not_found`, `no_permission`, `auth_error`, `message_too_long`, `platform_error`.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
user-invocable: false
|
|
3
|
+
description: Memory API, embedding providers, dreaming, active recall, and backends for @theokit/sdk.
|
|
4
|
+
paths:
|
|
5
|
+
- "**/*memory*"
|
|
6
|
+
- "**/*Memory*"
|
|
7
|
+
- "**/*embed*"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# TheoKit SDK -- Memory
|
|
11
|
+
|
|
12
|
+
Quick reference for durable memory, embedding providers, dreaming, and backends.
|
|
13
|
+
|
|
14
|
+
## Enabling memory on an agent
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { Agent } from "@theokit/sdk";
|
|
18
|
+
|
|
19
|
+
const agent = await Agent.create({
|
|
20
|
+
apiKey: process.env.THEOKIT_API_KEY!,
|
|
21
|
+
model: { id: "google/gemini-2.0-flash-001" },
|
|
22
|
+
local: { cwd: process.cwd() },
|
|
23
|
+
memory: {
|
|
24
|
+
enabled: true,
|
|
25
|
+
namespace: "my-app",
|
|
26
|
+
userId: "user-123",
|
|
27
|
+
scope: "user",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await (await agent.send("Remember: my preferred test runner is Vitest.")).wait();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## MemoryOptions
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface MemoryOptions {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
namespace?: string; // separates application domains
|
|
40
|
+
userId?: string; // isolates user memories
|
|
41
|
+
scope?: "agent" | "user" | "team";
|
|
42
|
+
storePath?: string; // relative to workspace; cannot escape
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Scopes
|
|
47
|
+
|
|
48
|
+
| Scope | Use for |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `"agent"` | Durable state for one agent ID. Default scope. |
|
|
51
|
+
| `"user"` | Stable user preferences across agent instances. Requires `userId`. |
|
|
52
|
+
| `"team"` | Shared team facts safe for every authorized caller. |
|
|
53
|
+
|
|
54
|
+
## Safety rules
|
|
55
|
+
|
|
56
|
+
- Memory MUST NOT store API keys, bearer tokens, passwords, or credential material.
|
|
57
|
+
- Local `storePath` is resolved relative to the workspace. Path traversal raises `ConfigurationError`.
|
|
58
|
+
- Memory is durable by `{ namespace, userId, scope }`, not by JavaScript process.
|
|
59
|
+
|
|
60
|
+
## SDKMemoryManager
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
interface SDKMemoryManager {
|
|
64
|
+
// Reserved for explicit inspection and deletion APIs.
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The agent uses memory during runs automatically. Public management APIs are narrow until deletion and audit semantics are finalized.
|
|
69
|
+
|
|
70
|
+
## Memory backends (v1.2+)
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { Memory } from "@theokit/sdk";
|
|
74
|
+
|
|
75
|
+
const memory = await Memory.create({
|
|
76
|
+
cwd: process.cwd(),
|
|
77
|
+
index: {
|
|
78
|
+
backend: "sqlite-vec", // default
|
|
79
|
+
embedding: { provider: "openai", model: "text-embedding-3-small" },
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Or use LanceDB for >100k facts:
|
|
84
|
+
const memory = await Memory.create({
|
|
85
|
+
cwd: process.cwd(),
|
|
86
|
+
index: {
|
|
87
|
+
backend: "lance",
|
|
88
|
+
embedding: { provider: "openai", model: "text-embedding-3-small" },
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `@lancedb/lancedb` is an optional peer dep. If missing with `backend: "lance"`, throws `ConfigurationError(code: "lance_backend_unavailable")`.
|
|
94
|
+
- Embedding dimension validated when opening existing index. Mismatch throws `ConfigurationError(code: "embedding_dimension_mismatch")`.
|
|
95
|
+
|
|
96
|
+
## Embedding providers (ADR D11)
|
|
97
|
+
|
|
98
|
+
Locked provider union: `openai`, `mistral`, `openrouter`, `voyage`, `deepinfra`.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
index: {
|
|
102
|
+
embedding: {
|
|
103
|
+
provider: "openai",
|
|
104
|
+
model: "text-embedding-3-small",
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Each provider adapter implements:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
interface EmbeddingAdapter {
|
|
113
|
+
id: string;
|
|
114
|
+
model: string;
|
|
115
|
+
dimension: number;
|
|
116
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Memory migration CLI (v1.2+)
|
|
121
|
+
|
|
122
|
+
Migrate SQLite memory index to LanceDB without data loss:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Dry-run (preview, no writes)
|
|
126
|
+
pnpm exec theokit-migrate-memory --cwd . --dry-run
|
|
127
|
+
|
|
128
|
+
# Real migration
|
|
129
|
+
pnpm exec theokit-migrate-memory --cwd .
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Options: `--cwd <path>`, `--dry-run`, `--keep-sqlite`, `--batch-size <n>`.
|
|
133
|
+
|
|
134
|
+
Algorithm: read SQLite, write to staging `lance-new/`, validate count + sample text match, atomic rename, prompt to delete SQLite.
|
|
135
|
+
|
|
136
|
+
## Dreaming (consolidation sweeps)
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
await Memory.runDreamingSweep({
|
|
140
|
+
cwd: process.cwd(),
|
|
141
|
+
embedding: { provider: "openai", model: "text-embedding-3-small" },
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Dreaming consolidates redundant facts into compressed summaries. In v1.x, consolidation is deterministic only (no LLM-mediated narrative). LLM narrative mode is deferred.
|
|
146
|
+
|
|
147
|
+
## Active recall
|
|
148
|
+
|
|
149
|
+
Active recall queries memory during `agent.send` to inject relevant facts into the LLM context. Configured via the memory options on the agent. Query modes:
|
|
150
|
+
|
|
151
|
+
- `"embedding"` -- cosine similarity search against the vector index.
|
|
152
|
+
- `"keyword"` -- keyword-based search.
|
|
153
|
+
- `"hybrid"` -- combines embedding and keyword results.
|
|
154
|
+
|
|
155
|
+
## Semantic cache (related)
|
|
156
|
+
|
|
157
|
+
`Cache.semantic` from `@theokit/sdk` reuses embedding adapters for LLM response caching with cosine-similarity matching. See the cache documentation for details.
|
|
158
|
+
|
|
159
|
+
## Resume behavior
|
|
160
|
+
|
|
161
|
+
Memory is durable by `{ namespace, userId, scope }`, not by process. Recreating or resuming an agent with the same memory config can recall durable facts. Inline secrets and MCP servers are NOT persisted through memory.
|
|
162
|
+
|
|
163
|
+
## Conversation storage (pluggable persistence)
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { Agent, InMemoryConversationStorage } from "@theokit/sdk";
|
|
167
|
+
|
|
168
|
+
const agent = await Agent.create({
|
|
169
|
+
apiKey, model,
|
|
170
|
+
conversationStorage: new InMemoryConversationStorage(),
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Built-in adapters: `FileSystemConversationStorage`, `InMemoryConversationStorage`. Custom adapters implement `ConversationStorageAdapter`.
|
|
175
|
+
|
|
176
|
+
When using custom storage, `Agent.resume` requires the adapter to be passed again -- silent FS fallback is rejected with `ConfigurationError(code: "conversation_storage_required")`.
|