@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,218 @@
|
|
|
1
|
+
---
|
|
2
|
+
user-invocable: false
|
|
3
|
+
description: Workflow orchestration -- Workflow.create, steps, branching, retry, suspend/resume.
|
|
4
|
+
paths:
|
|
5
|
+
- "**/*workflow*"
|
|
6
|
+
- "**/*Workflow*"
|
|
7
|
+
- "**/*step*"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# TheoKit SDK -- Workflows
|
|
11
|
+
|
|
12
|
+
Quick reference for declarative multi-step orchestration (v1.17+).
|
|
13
|
+
|
|
14
|
+
## Workflow.create / .run
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { Agent, Workflow, fn, agentStep } from "@theokit/sdk";
|
|
18
|
+
|
|
19
|
+
const classifier = await Agent.create({ /* ... */ });
|
|
20
|
+
const billingExpert = await Agent.create({ /* ... */ });
|
|
21
|
+
|
|
22
|
+
const wf = Workflow.create<{ claim: string }, string>({ name: "refund-pipeline" })
|
|
23
|
+
.then(fn("validate", (input) => {
|
|
24
|
+
if (!input.claim) throw new Error("missing claim");
|
|
25
|
+
return input;
|
|
26
|
+
}))
|
|
27
|
+
.then(agentStep("classify", classifier, (i) => `Classify: ${JSON.stringify(i)}`))
|
|
28
|
+
.branch([
|
|
29
|
+
[(out) => String(out).includes("BILLING"), [agentStep("resolve", billingExpert, "Handle it")]],
|
|
30
|
+
], { fallback: [fn("escalate", () => "escalated")] })
|
|
31
|
+
.commit();
|
|
32
|
+
|
|
33
|
+
const run = await wf.run({ claim: "I was charged twice" });
|
|
34
|
+
console.log(run.status, run.output);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Step types
|
|
38
|
+
|
|
39
|
+
### fn step (pure function)
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { fn } from "@theokit/sdk";
|
|
43
|
+
|
|
44
|
+
fn("validate", (input, ctx) => {
|
|
45
|
+
// input: previous step's output
|
|
46
|
+
// ctx: { signal, suspend(), stepId }
|
|
47
|
+
return transformedInput;
|
|
48
|
+
}, {
|
|
49
|
+
inputSchema: z.object({ /* ... */ }), // optional Zod validation
|
|
50
|
+
outputSchema: z.object({ /* ... */ }), // optional Zod validation
|
|
51
|
+
retry: {
|
|
52
|
+
maxAttempts: 3,
|
|
53
|
+
initialBackoffMs: 1000,
|
|
54
|
+
backoffCoefficient: 2.0,
|
|
55
|
+
maximumBackoffMs: 30_000,
|
|
56
|
+
nonRetryableErrors: ["ConfigurationError"],
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### agentStep (agent.send wrapper)
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { agentStep } from "@theokit/sdk";
|
|
65
|
+
|
|
66
|
+
agentStep("classify", agent, (input) => `Classify this: ${JSON.stringify(input)}`, {
|
|
67
|
+
retry: { maxAttempts: 2, initialBackoffMs: 2000 },
|
|
68
|
+
});
|
|
69
|
+
// Third arg is a prompt renderer: (stepInput) => string
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Control-flow primitives
|
|
73
|
+
|
|
74
|
+
### .then (sequential)
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
wf.then(fn("a", ...)).then(fn("b", ...))
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### .parallel (fan-out)
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
wf.parallel([
|
|
84
|
+
[fn("branch-a", ...)],
|
|
85
|
+
[fn("branch-b", ...)],
|
|
86
|
+
], {
|
|
87
|
+
concurrency: 4,
|
|
88
|
+
errorPolicy: "fail-fast", // or "collect"
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### .branch (first-match routing)
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
wf.branch([
|
|
96
|
+
[(output) => output.category === "billing", [agentStep("billing", billingAgent, "Handle")]],
|
|
97
|
+
[(output) => output.category === "support", [agentStep("support", supportAgent, "Handle")]],
|
|
98
|
+
], {
|
|
99
|
+
fallback: [fn("unknown", () => "escalated")],
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### .foreach (map over array)
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
wf.foreach("source-step-id", fn("process", (item) => transform(item)), {
|
|
107
|
+
concurrency: 4,
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### .dowhile (loop)
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
wf.dowhile(
|
|
115
|
+
fn("iterate", (input) => { /* ... */ return { done: false, data: input }; }),
|
|
116
|
+
(output) => !output.done,
|
|
117
|
+
{ maxIterations: 100 },
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### .sleep
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
wf.sleep(5000, "wait-for-api") // abortable via signal
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### .suspend (human-in-the-loop)
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
wf.then(fn("wait_approval", async (input, ctx) => {
|
|
131
|
+
await ctx.suspend({ awaiting: "human-approval", draft: input });
|
|
132
|
+
return "sentinel"; // never reached
|
|
133
|
+
}))
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Suspend / resume
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const first = await wf.run(undefined);
|
|
140
|
+
// first.status === "suspended"
|
|
141
|
+
|
|
142
|
+
// Later, after human approves:
|
|
143
|
+
const resumed = await Workflow.resume({
|
|
144
|
+
runId: first.id,
|
|
145
|
+
workflow: wf,
|
|
146
|
+
payload: { approved: true, by: "manager" },
|
|
147
|
+
});
|
|
148
|
+
// resumed.status === "completed"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Persistence
|
|
152
|
+
|
|
153
|
+
| Backend | When | How |
|
|
154
|
+
|---|---|---|
|
|
155
|
+
| `memory` (default) | Same-process suspend/resume | `Workflow.create({ name })` |
|
|
156
|
+
| `json` | Survive process restart | `Workflow.create({ name, persistence: { backend: "json", dir: ".theokit/workflows" } })` |
|
|
157
|
+
|
|
158
|
+
## Retry policy
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
retry: {
|
|
162
|
+
maxAttempts: 3, // 1..20, required
|
|
163
|
+
initialBackoffMs: 1000, // default 1000
|
|
164
|
+
backoffCoefficient: 2.0, // default 2.0
|
|
165
|
+
maximumBackoffMs: 30_000, // default 30s
|
|
166
|
+
nonRetryableErrors: ["ConfigurationError", "AbortError"],
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Retry sleeps are abortable via `AbortSignal`. Non-retryable errors skip the retry loop.
|
|
171
|
+
|
|
172
|
+
## Cancellation
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const ctrl = new AbortController();
|
|
176
|
+
const promise = wf.run(input, { signal: ctrl.signal });
|
|
177
|
+
|
|
178
|
+
ctrl.abort("user cancelled");
|
|
179
|
+
const run = await promise;
|
|
180
|
+
// run.status === "cancelled"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`AbortSignal` is checked at step boundaries AND mid-backoff sleep. `ctx.signal` is passed to step functions so `fetch` / `agent.send` can be cancelled too.
|
|
184
|
+
|
|
185
|
+
## WorkflowRun result
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
interface WorkflowRun<O> {
|
|
189
|
+
id: string;
|
|
190
|
+
status: "completed" | "suspended" | "cancelled" | "failed";
|
|
191
|
+
output?: O;
|
|
192
|
+
error?: Error;
|
|
193
|
+
steps: WorkflowStepResult[];
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Telemetry
|
|
198
|
+
|
|
199
|
+
When OTel is installed, each `wf.run` emits a `workflow.run` root span and per-step `workflow.step.<id>` child spans with attributes: `workflow.name`, `workflow.run_id`, `step.kind`, `step.attempts`, `step.status`.
|
|
200
|
+
|
|
201
|
+
## Errors
|
|
202
|
+
|
|
203
|
+
| Error | Cause |
|
|
204
|
+
|---|---|
|
|
205
|
+
| `WorkflowDuplicateStepIdError` | Two steps with same id at `.commit()` |
|
|
206
|
+
| `WorkflowAlreadyRunningError` | Concurrent `.run()` with same `(workflowId, runId)` |
|
|
207
|
+
| `WorkflowSnapshotNotFoundError` | `Workflow.resume(runId)` with unknown runId |
|
|
208
|
+
| `WorkflowMaxIterationsExceededError` | `.dowhile` over `maxIterations` |
|
|
209
|
+
| `WorkflowNotSerializableError` | `ctx.suspend(payload)` with non-JSON value |
|
|
210
|
+
| `WorkflowResumeStepNotFoundError` | Resume against a diverged workflow definition |
|
|
211
|
+
| `WorkflowParallelError` | Aggregate of branch failures in fail-fast mode |
|
|
212
|
+
| `WorkflowCompensateNotImplementedError` | `compensate` field set (saga deferred to v1.2) |
|
|
213
|
+
|
|
214
|
+
## Limitations (v1)
|
|
215
|
+
|
|
216
|
+
- **LocalAgent only** -- cloud agent steps throw `UnsupportedRunOperationError`.
|
|
217
|
+
- **Saga compensation deferred** -- `compensate?` field reserved but throws if set.
|
|
218
|
+
- **No cron-trigger integration** -- wire via `Cron.create` calling `wf.run` directly.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentMailbox — per-agent inbox for A2A communication (T20.1, ADR D453).
|
|
3
|
+
*
|
|
4
|
+
* Wraps MessageBus registration with a convenient API for sending,
|
|
5
|
+
* receiving, and requesting messages.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
import type { MessageBus, RequestOptions } from "./message-bus.js";
|
|
10
|
+
import type { MessageHandler } from "./types.js";
|
|
11
|
+
export declare class AgentMailbox {
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
private readonly _bus;
|
|
14
|
+
private _handler;
|
|
15
|
+
constructor(agentId: string, bus: MessageBus);
|
|
16
|
+
onMessage(handler: MessageHandler): void;
|
|
17
|
+
send(to: string, partial: {
|
|
18
|
+
type: string;
|
|
19
|
+
payload: unknown;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
request(to: string, partial: {
|
|
22
|
+
type: string;
|
|
23
|
+
payload: unknown;
|
|
24
|
+
}, opts?: RequestOptions): Promise<unknown>;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
private _dispatch;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentMailbox — per-agent inbox for A2A communication (T20.1, ADR D453).
|
|
3
|
+
*
|
|
4
|
+
* Wraps MessageBus registration with a convenient API for sending,
|
|
5
|
+
* receiving, and requesting messages.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
import type { MessageBus, RequestOptions } from "./message-bus.js";
|
|
10
|
+
import type { MessageHandler } from "./types.js";
|
|
11
|
+
export declare class AgentMailbox {
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
private readonly _bus;
|
|
14
|
+
private _handler;
|
|
15
|
+
constructor(agentId: string, bus: MessageBus);
|
|
16
|
+
onMessage(handler: MessageHandler): void;
|
|
17
|
+
send(to: string, partial: {
|
|
18
|
+
type: string;
|
|
19
|
+
payload: unknown;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
request(to: string, partial: {
|
|
22
|
+
type: string;
|
|
23
|
+
payload: unknown;
|
|
24
|
+
}, opts?: RequestOptions): Promise<unknown>;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
private _dispatch;
|
|
27
|
+
}
|