@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.
- package/CHANGELOG.md +1571 -0
- package/LICENSE +201 -0
- package/README.md +80 -0
- package/bin/theokit-migrate-config.mjs +269 -0
- package/bin/theokit-migrate-memory.mjs +116 -0
- package/dist/agent-builder.d.ts +52 -0
- package/dist/agent-factory.d.ts +39 -0
- package/dist/agent.d.ts +175 -0
- package/dist/batch.d.ts +11 -0
- package/dist/budget.d.ts +48 -0
- package/dist/cache.d.ts +74 -0
- package/dist/cron-1yxL3K2S.d.cts +221 -0
- package/dist/cron-BYVdYzob.d.ts +221 -0
- package/dist/cron.cjs +14655 -0
- package/dist/cron.cjs.map +1 -0
- package/dist/cron.d.cts +3 -0
- package/dist/cron.d.ts +71 -0
- package/dist/cron.js +14652 -0
- package/dist/cron.js.map +1 -0
- package/dist/define-tool.d.ts +35 -0
- package/dist/errors-CK8brCJ1.d.cts +448 -0
- package/dist/errors-CvAeEWgE.d.ts +448 -0
- package/dist/errors.cjs +255 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +3 -0
- package/dist/errors.d.ts +356 -0
- package/dist/errors.js +238 -0
- package/dist/errors.js.map +1 -0
- package/dist/eval.cjs +14826 -0
- package/dist/eval.cjs.map +1 -0
- package/dist/eval.d.cts +35 -0
- package/dist/eval.d.ts +35 -0
- package/dist/eval.js +14821 -0
- package/dist/eval.js.map +1 -0
- package/dist/generate-object.d.ts +67 -0
- package/dist/handoff.d.ts +55 -0
- package/dist/index.cjs +17127 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1878 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +17095 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/agent-loop/loop-types.d.ts +29 -0
- package/dist/internal/agent-loop/loop.d.ts +2 -0
- package/dist/internal/agent-loop/message-builders.d.ts +6 -0
- package/dist/internal/agent-loop/tool-dispatch.d.ts +4 -0
- package/dist/internal/agent-loop/usage-and-cost.d.ts +25 -0
- package/dist/internal/budget/calendar-window.d.ts +19 -0
- package/dist/internal/budget/compute-cost.d.ts +28 -0
- package/dist/internal/budget/enforcement.d.ts +32 -0
- package/dist/internal/budget/ledger.d.ts +25 -0
- package/dist/internal/budget/normalize-usage.d.ts +27 -0
- package/dist/internal/budget/pricing-registry.d.ts +36 -0
- package/dist/internal/budget/registry.d.ts +16 -0
- package/dist/internal/budget/usage-accumulator.d.ts +31 -0
- package/dist/internal/cache/cosine.d.ts +14 -0
- package/dist/internal/cache/embed-helper.d.ts +15 -0
- package/dist/internal/cache/key.d.ts +15 -0
- package/dist/internal/cache/lookup.d.ts +28 -0
- package/dist/internal/cache/store-handler.d.ts +24 -0
- package/dist/internal/cache/store-json.d.ts +48 -0
- package/dist/internal/cache/store.d.ts +54 -0
- package/dist/internal/cache/telemetry.d.ts +20 -0
- package/dist/internal/cache/ttl.d.ts +11 -0
- package/dist/internal/catalog/fixtures.d.ts +16 -0
- package/dist/internal/catalog/local-models.d.ts +24 -0
- package/dist/internal/cron/run-job.d.ts +1 -0
- package/dist/internal/cron/scheduler.d.ts +1 -0
- package/dist/internal/cron/store.d.ts +1 -0
- package/dist/internal/cron/validate.d.ts +1 -0
- package/dist/internal/env.d.ts +1 -0
- package/dist/internal/errors/mappers/anthropic.d.ts +30 -0
- package/dist/internal/errors/mappers/bedrock.d.ts +16 -0
- package/dist/internal/errors/mappers/ollama.d.ts +41 -0
- package/dist/internal/errors/mappers/openai-compatible.d.ts +25 -0
- package/dist/internal/errors/mappers/shared.d.ts +10 -0
- package/dist/internal/errors/mappers/vertex.d.ts +15 -0
- package/dist/internal/eval/aggregate.d.ts +9 -0
- package/dist/internal/eval/dataset-iter.d.ts +9 -0
- package/dist/internal/eval/runner.d.ts +9 -0
- package/dist/internal/eval/single-flight.d.ts +16 -0
- package/dist/internal/eval/telemetry.d.ts +23 -0
- package/dist/internal/fixture-mode.d.ts +16 -0
- package/dist/internal/handoff/dispatcher.d.ts +29 -0
- package/dist/internal/handoff/registry.d.ts +23 -0
- package/dist/internal/handoff/telemetry.d.ts +18 -0
- package/dist/internal/handoff/tool-injector.d.ts +34 -0
- package/dist/internal/http.d.ts +1 -0
- package/dist/internal/ids.d.ts +1 -0
- package/dist/internal/judge/judge-call.d.ts +35 -0
- package/dist/internal/judge/parse-verdict.d.ts +11 -0
- package/dist/internal/judge/types.d.ts +17 -0
- package/dist/internal/llm/anthropic-shared.d.ts +89 -0
- package/dist/internal/llm/anthropic.d.ts +9 -0
- package/dist/internal/llm/bedrock-anthropic.d.ts +36 -0
- package/dist/internal/llm/bedrock-token-cache.d.ts +18 -0
- package/dist/internal/llm/credential-pool-context.d.ts +11 -0
- package/dist/internal/llm/credential-pool-types.d.ts +22 -0
- package/dist/internal/llm/credential-pool.d.ts +18 -0
- package/dist/internal/llm/fallback-client.d.ts +1 -0
- package/dist/internal/llm/fault-injection.d.ts +50 -0
- package/dist/internal/llm/finish.d.ts +1 -0
- package/dist/internal/llm/model-identifier.d.ts +24 -0
- package/dist/internal/llm/ollama-native.d.ts +27 -0
- package/dist/internal/llm/openai.d.ts +9 -0
- package/dist/internal/llm/pool-aware-client.d.ts +16 -0
- package/dist/internal/llm/router.d.ts +17 -0
- package/dist/internal/llm/sse.d.ts +9 -0
- package/dist/internal/llm/stream-relay.d.ts +17 -0
- package/dist/internal/llm/types.d.ts +70 -0
- package/dist/internal/llm/vertex-anthropic.d.ts +40 -0
- package/dist/internal/llm/vertex-auth.d.ts +30 -0
- package/dist/internal/llm/vertex-gemini.d.ts +28 -0
- package/dist/internal/llm/vertex-router.d.ts +21 -0
- package/dist/internal/mcp/client.d.ts +16 -0
- package/dist/internal/memory/active-memory-cache.d.ts +10 -0
- package/dist/internal/memory/active-memory.d.ts +45 -0
- package/dist/internal/memory/adapters/catalog.d.ts +1 -0
- package/dist/internal/memory/adapters/deepinfra-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/mistral-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/ollama-embedding.d.ts +34 -0
- package/dist/internal/memory/adapters/openai-compatible.d.ts +23 -0
- package/dist/internal/memory/adapters/openai-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/openrouter-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/voyage-embedding.d.ts +2 -0
- package/dist/internal/memory/atomic-write.d.ts +7 -0
- package/dist/internal/memory/chunk-markdown.d.ts +2 -0
- package/dist/internal/memory/circuit-breaker.d.ts +22 -0
- package/dist/internal/memory/cwd-mutex.d.ts +1 -0
- package/dist/internal/memory/dreaming/diary.d.ts +4 -0
- package/dist/internal/memory/dreaming/phases.d.ts +15 -0
- package/dist/internal/memory/dreaming/run.d.ts +10 -0
- package/dist/internal/memory/embedding-adapter.d.ts +42 -0
- package/dist/internal/memory/embedding-cache.d.ts +1 -0
- package/dist/internal/memory/index-db.d.ts +10 -0
- package/dist/internal/memory/index-manager-dispatch.d.ts +23 -0
- package/dist/internal/memory/index-manager.d.ts +68 -0
- package/dist/internal/memory/index-schema.d.ts +21 -0
- package/dist/internal/memory/lance-index.d.ts +32 -0
- package/dist/internal/memory/lance-memory-adapter.d.ts +43 -0
- package/dist/internal/memory/markdown-store.d.ts +16 -0
- package/dist/internal/memory/memory-index.d.ts +52 -0
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +15 -0
- package/dist/internal/memory/migration.d.ts +9 -0
- package/dist/internal/memory/reader.d.ts +8 -0
- package/dist/internal/memory/session-loader.d.ts +1 -0
- package/dist/internal/memory/session-summary-writer.d.ts +2 -0
- package/dist/internal/memory/sqlite-vec-loader.d.ts +3 -0
- package/dist/internal/memory/tools.d.ts +14 -0
- package/dist/internal/memory/transcript-store.d.ts +1 -0
- package/dist/internal/memory/types.d.ts +17 -0
- package/dist/internal/memory/vec-index.d.ts +28 -0
- package/dist/internal/memory/wiki-loader.d.ts +2 -0
- package/dist/internal/observability/tracer-loader.d.ts +20 -0
- package/dist/internal/persistence/atomic-write.d.ts +1 -0
- package/dist/internal/persistence/conversation-storage-fs.d.ts +37 -0
- package/dist/internal/persistence/conversation-storage-memory.d.ts +24 -0
- package/dist/internal/persistence/cwd-mutex.d.ts +1 -0
- package/dist/internal/persistence/file-lock.d.ts +14 -0
- package/dist/internal/persistence/fts5-sanitize.d.ts +16 -0
- package/dist/internal/persistence/markdown-config-loader.d.ts +35 -0
- package/dist/internal/persistence/paths.d.ts +19 -0
- package/dist/internal/persistence/persistence-schema.d.ts +17 -0
- package/dist/internal/persistence/schema-version.d.ts +13 -0
- package/dist/internal/persistence/sqlite-wal.d.ts +10 -0
- package/dist/internal/personality/context.d.ts +17 -0
- package/dist/internal/personality/registry.d.ts +17 -0
- package/dist/internal/personality/store.d.ts +27 -0
- package/dist/internal/personality/switch.d.ts +36 -0
- package/dist/internal/personality/types.d.ts +18 -0
- package/dist/internal/plugins/context.d.ts +31 -0
- package/dist/internal/plugins/manager.d.ts +37 -0
- package/dist/internal/plugins/types.d.ts +102 -0
- package/dist/internal/providers/builtin/anthropic.d.ts +2 -0
- package/dist/internal/providers/builtin/bedrock.d.ts +25 -0
- package/dist/internal/providers/builtin/gemini.d.ts +10 -0
- package/dist/internal/providers/builtin/index.d.ts +19 -0
- package/dist/internal/providers/builtin/llamacpp.d.ts +1 -0
- package/dist/internal/providers/builtin/lmstudio.d.ts +1 -0
- package/dist/internal/providers/builtin/ollama.d.ts +17 -0
- package/dist/internal/providers/builtin/openai.d.ts +2 -0
- package/dist/internal/providers/builtin/openrouter.d.ts +2 -0
- package/dist/internal/providers/builtin/vertex.d.ts +27 -0
- package/dist/internal/providers/discovery.d.ts +14 -0
- package/dist/internal/providers/index.d.ts +8 -0
- package/dist/internal/providers/registry.d.ts +12 -0
- package/dist/internal/providers/types.d.ts +27 -0
- package/dist/internal/runtime/abort-utils.d.ts +21 -0
- package/dist/internal/runtime/agent-factory-registry.d.ts +16 -0
- package/dist/internal/runtime/agent-registry-store.d.ts +61 -0
- package/dist/internal/runtime/agent-registry.d.ts +34 -0
- package/dist/internal/runtime/agent-session-store.d.ts +3 -0
- package/dist/internal/runtime/agent-session.d.ts +2 -0
- package/dist/internal/runtime/async-local-storage.d.ts +20 -0
- package/dist/internal/runtime/async-semaphore.d.ts +24 -0
- package/dist/internal/runtime/budget.d.ts +36 -0
- package/dist/internal/runtime/cloud-agent.d.ts +1 -0
- package/dist/internal/runtime/cloud-config-serializer.d.ts +3 -0
- package/dist/internal/runtime/cloud-payload-types.d.ts +56 -0
- package/dist/internal/runtime/cloud-run.d.ts +1 -0
- package/dist/internal/runtime/cloud-tool-parity.d.ts +1 -0
- package/dist/internal/runtime/context-aggregator.d.ts +26 -0
- package/dist/internal/runtime/context-discovery-runner.d.ts +27 -0
- package/dist/internal/runtime/context-discovery.d.ts +21 -0
- package/dist/internal/runtime/context-frontmatter.d.ts +16 -0
- package/dist/internal/runtime/context-import-resolver.d.ts +24 -0
- package/dist/internal/runtime/context-loaders.d.ts +42 -0
- package/dist/internal/runtime/context-manager.d.ts +11 -0
- package/dist/internal/runtime/context-mdc-parser.d.ts +24 -0
- package/dist/internal/runtime/default-model.d.ts +1 -0
- package/dist/internal/runtime/fixture-events.d.ts +12 -0
- package/dist/internal/runtime/fixture-responder.d.ts +1 -0
- package/dist/internal/runtime/fixture-run-base.d.ts +45 -0
- package/dist/internal/runtime/fixture-scripts.d.ts +21 -0
- package/dist/internal/runtime/fixture-types.d.ts +1 -0
- package/dist/internal/runtime/fork-agent.d.ts +15 -0
- package/dist/internal/runtime/hooks-executor.d.ts +35 -0
- package/dist/internal/runtime/hooks-frontmatter.d.ts +26 -0
- package/dist/internal/runtime/hooks-source.d.ts +22 -0
- package/dist/internal/runtime/live-agent-registry.d.ts +87 -0
- package/dist/internal/runtime/local-agent-bootstrap.d.ts +37 -0
- package/dist/internal/runtime/local-agent-dispatch.d.ts +57 -0
- package/dist/internal/runtime/local-agent-invalidate.d.ts +8 -0
- package/dist/internal/runtime/local-agent-memory-direct.d.ts +12 -0
- package/dist/internal/runtime/local-agent-memory-hooks.d.ts +41 -0
- package/dist/internal/runtime/local-agent-memory.d.ts +1 -0
- package/dist/internal/runtime/local-agent-personality-extensions.d.ts +19 -0
- package/dist/internal/runtime/local-agent-plugins.d.ts +13 -0
- package/dist/internal/runtime/local-agent-runtime-extensions.d.ts +13 -0
- package/dist/internal/runtime/local-agent-task-wrap.d.ts +11 -0
- package/dist/internal/runtime/local-agent.d.ts +1 -0
- package/dist/internal/runtime/local-run.d.ts +1 -0
- package/dist/internal/runtime/memory-store.d.ts +4 -0
- package/dist/internal/runtime/plugin-frontmatter.d.ts +17 -0
- package/dist/internal/runtime/plugins-manager.d.ts +1 -0
- package/dist/internal/runtime/post-run-lifecycle.d.ts +1 -0
- package/dist/internal/runtime/providers-manager.d.ts +1 -0
- package/dist/internal/runtime/real-cloud-run.d.ts +2 -0
- package/dist/internal/runtime/real-local-run.d.ts +2 -0
- package/dist/internal/runtime/run-registry.d.ts +5 -0
- package/dist/internal/runtime/run-until.d.ts +22 -0
- package/dist/internal/runtime/shell-tool.d.ts +7 -0
- package/dist/internal/runtime/skill-frontmatter.d.ts +1 -0
- package/dist/internal/runtime/skills-manager.d.ts +1 -0
- package/dist/internal/runtime/spawn-collect.d.ts +8 -0
- package/dist/internal/runtime/subagents-loader.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/escape.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/local-assembly.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/pipeline.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/active-memory-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/base-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/context-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/memory-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/skills-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/safe-call.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/types.d.ts +5 -0
- package/dist/internal/runtime/system-prompt.d.ts +1 -0
- package/dist/internal/runtime/validate-agent-options.d.ts +1 -0
- package/dist/internal/runtime/workspace-dir.d.ts +9 -0
- package/dist/internal/runtime/yaml-frontmatter.d.ts +20 -0
- package/dist/internal/scorers/llm-judge.d.ts +24 -0
- package/dist/internal/security/index.d.ts +11 -0
- package/dist/internal/security/path-guard.d.ts +56 -0
- package/dist/internal/security/redact.d.ts +21 -0
- package/dist/internal/structured-output-helpers.d.ts +54 -0
- package/dist/internal/task/registry.d.ts +61 -0
- package/dist/internal/task/ring-buffer.d.ts +10 -0
- package/dist/internal/task/store.d.ts +59 -0
- package/dist/internal/task/subscribe.d.ts +15 -0
- package/dist/internal/task/telemetry.d.ts +27 -0
- package/dist/internal/telemetry/adapter-registry.d.ts +2 -0
- package/dist/internal/telemetry/adapters/langfuse.d.ts +2 -0
- package/dist/internal/telemetry/adapters/posthog.d.ts +2 -0
- package/dist/internal/telemetry/adapters/sentry.d.ts +2 -0
- package/dist/internal/telemetry/safe-require.d.ts +1 -0
- package/dist/internal/telemetry/tracer.d.ts +18 -0
- package/dist/internal/tool-dispatch/repair-middleware.d.ts +34 -0
- package/dist/internal/tool-dispatch/strip-think.d.ts +22 -0
- package/dist/internal/tool-registry/personality-filter.d.ts +37 -0
- package/dist/internal/workflow/ctx.d.ts +19 -0
- package/dist/internal/workflow/error-shape.d.ts +7 -0
- package/dist/internal/workflow/executor.d.ts +15 -0
- package/dist/internal/workflow/index.d.ts +12 -0
- package/dist/internal/workflow/retry-policy.d.ts +14 -0
- package/dist/internal/workflow/run-id.d.ts +9 -0
- package/dist/internal/workflow/single-flight.d.ts +18 -0
- package/dist/internal/workflow/snapshot-store.d.ts +23 -0
- package/dist/internal/workflow/step-agent.d.ts +12 -0
- package/dist/internal/workflow/step-branch.d.ts +10 -0
- package/dist/internal/workflow/step-dowhile.d.ts +8 -0
- package/dist/internal/workflow/step-fn.d.ts +10 -0
- package/dist/internal/workflow/step-foreach.d.ts +11 -0
- package/dist/internal/workflow/step-parallel.d.ts +17 -0
- package/dist/internal/workflow/step-sleep.d.ts +7 -0
- package/dist/internal/workflow/telemetry.d.ts +23 -0
- package/dist/internal/zod/to-json-schema.d.ts +21 -0
- package/dist/memory-adapter-helpers.d.ts +28 -0
- package/dist/memory.d.ts +123 -0
- package/dist/migrate.d.ts +33 -0
- package/dist/path-safety.cjs +126 -0
- package/dist/path-safety.cjs.map +1 -0
- package/dist/path-safety.d.cts +15 -0
- package/dist/path-safety.d.ts +15 -0
- package/dist/path-safety.js +120 -0
- package/dist/path-safety.js.map +1 -0
- package/dist/run-DkCD5DeO.d.cts +2181 -0
- package/dist/run-DkCD5DeO.d.ts +2181 -0
- package/dist/scorers.d.ts +75 -0
- package/dist/security.d.ts +67 -0
- package/dist/stream-object.d.ts +74 -0
- package/dist/task-store.cjs +237 -0
- package/dist/task-store.cjs.map +1 -0
- package/dist/task-store.d.cts +8 -0
- package/dist/task-store.d.ts +8 -0
- package/dist/task-store.js +233 -0
- package/dist/task-store.js.map +1 -0
- package/dist/task.d.ts +87 -0
- package/dist/theokit.d.ts +84 -0
- package/dist/tools/_path-scope.d.cts +8 -0
- package/dist/tools/_path-scope.d.ts +8 -0
- package/dist/tools/_subprocess.d.cts +28 -0
- package/dist/tools/_subprocess.d.ts +28 -0
- package/dist/tools/git-diff.d.cts +22 -0
- package/dist/tools/git-diff.d.ts +22 -0
- package/dist/tools/index.d.cts +29 -0
- package/dist/tools/index.d.ts +29 -0
- package/dist/tools/list-dir.d.cts +26 -0
- package/dist/tools/list-dir.d.ts +26 -0
- package/dist/tools/read-file.d.cts +31 -0
- package/dist/tools/read-file.d.ts +31 -0
- package/dist/tools/run-vitest.d.cts +46 -0
- package/dist/tools/run-vitest.d.ts +46 -0
- package/dist/tools/search-text.d.cts +32 -0
- package/dist/tools/search-text.d.ts +32 -0
- package/dist/tools.cjs +690 -0
- package/dist/tools.cjs.map +1 -0
- package/dist/tools.js +683 -0
- package/dist/tools.js.map +1 -0
- package/dist/trajectory-helpers.d.ts +31 -0
- package/dist/types/agent.d.ts +771 -0
- package/dist/types/batch.d.ts +112 -0
- package/dist/types/budget.d.ts +88 -0
- package/dist/types/cache.d.ts +76 -0
- package/dist/types/context.d.ts +93 -0
- package/dist/types/conversation-storage.d.ts +76 -0
- package/dist/types/conversation.d.ts +90 -0
- package/dist/types/cron.d.ts +150 -0
- package/dist/types/eval.d.ts +132 -0
- package/dist/types/goal-events.d.ts +95 -0
- package/dist/types/handoff.d.ts +135 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/mcp.d.ts +64 -0
- package/dist/types/memory-adapter.d.ts +175 -0
- package/dist/types/messages.d.ts +154 -0
- package/dist/types/providers.d.ts +102 -0
- package/dist/types/run.d.ts +215 -0
- package/dist/types/task.d.ts +131 -0
- package/dist/types/theokit.d.ts +61 -0
- package/dist/types/trajectory.d.ts +49 -0
- package/dist/types/updates.d.ts +148 -0
- package/dist/types/usage.d.ts +61 -0
- package/dist/types/workflow.d.ts +217 -0
- package/dist/workflow.cjs +2405 -0
- package/dist/workflow.cjs.map +1 -0
- package/dist/workflow.d.cts +97 -0
- package/dist/workflow.d.ts +97 -0
- package/dist/workflow.js +2398 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +183 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { ModelSelection } from "./agent.js";
|
|
2
|
+
/**
|
|
3
|
+
* Plain text content block emitted by the assistant or user.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface TextBlock {
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Tool invocation block emitted by the assistant.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface ToolUseBlock {
|
|
17
|
+
type: "tool_use";
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
/** Tool args are not part of the stable schema. Treat as unknown and parse defensively. */
|
|
21
|
+
input: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Init metadata. Emitted once at the start of a run.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export interface SDKSystemMessage {
|
|
29
|
+
type: "system";
|
|
30
|
+
subtype?: "init";
|
|
31
|
+
agent_id: string;
|
|
32
|
+
run_id: string;
|
|
33
|
+
model?: ModelSelection;
|
|
34
|
+
tools?: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Echo of the user prompt for this run.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export interface SDKUserMessageEvent {
|
|
42
|
+
type: "user";
|
|
43
|
+
agent_id: string;
|
|
44
|
+
run_id: string;
|
|
45
|
+
message: {
|
|
46
|
+
role: "user";
|
|
47
|
+
content: TextBlock[];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Model text output for this run.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export interface SDKAssistantMessage {
|
|
56
|
+
type: "assistant";
|
|
57
|
+
agent_id: string;
|
|
58
|
+
run_id: string;
|
|
59
|
+
message: {
|
|
60
|
+
role: "assistant";
|
|
61
|
+
content: Array<TextBlock | ToolUseBlock>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reasoning content.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export interface SDKThinkingMessage {
|
|
70
|
+
type: "thinking";
|
|
71
|
+
agent_id: string;
|
|
72
|
+
run_id: string;
|
|
73
|
+
text: string;
|
|
74
|
+
thinking_duration_ms?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Tool invocation lifecycle event. Emitted at start with `args`, then again on
|
|
78
|
+
* completion with `result`.
|
|
79
|
+
*
|
|
80
|
+
* Tool `args` and `result` are NOT part of the stable schema — treat as unknown.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export interface SDKToolUseMessage {
|
|
85
|
+
type: "tool_call";
|
|
86
|
+
agent_id: string;
|
|
87
|
+
run_id: string;
|
|
88
|
+
call_id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
status: "running" | "completed" | "error";
|
|
91
|
+
args?: unknown;
|
|
92
|
+
result?: unknown;
|
|
93
|
+
truncated?: {
|
|
94
|
+
args?: boolean;
|
|
95
|
+
result?: boolean;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Cloud run lifecycle transitions.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export interface SDKStatusMessage {
|
|
104
|
+
type: "status";
|
|
105
|
+
agent_id: string;
|
|
106
|
+
run_id: string;
|
|
107
|
+
status: "CREATING" | "RUNNING" | "FINISHED" | "ERROR" | "CANCELLED" | "EXPIRED";
|
|
108
|
+
message?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Task-level milestones and summaries.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export interface SDKTaskMessage {
|
|
116
|
+
type: "task";
|
|
117
|
+
agent_id: string;
|
|
118
|
+
run_id: string;
|
|
119
|
+
status?: string;
|
|
120
|
+
text?: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Awaiting user input or approval.
|
|
124
|
+
*
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export interface SDKRequestMessage {
|
|
128
|
+
type: "request";
|
|
129
|
+
agent_id: string;
|
|
130
|
+
run_id: string;
|
|
131
|
+
request_id: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Partial object emitted during `Agent.streamObject<T>` streaming (ADR D45).
|
|
135
|
+
* `partial` is `DeepPartial<z.infer<T>>` at the typed iterator level but
|
|
136
|
+
* erased to `unknown` here because SDKMessage union is non-generic.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
export interface SDKObjectDelta {
|
|
141
|
+
type: "object_delta";
|
|
142
|
+
agent_id: string;
|
|
143
|
+
run_id: string;
|
|
144
|
+
partial: unknown;
|
|
145
|
+
attempt: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Discriminated union of all stream events. Discriminate on `type`.
|
|
149
|
+
*
|
|
150
|
+
* All events include `agent_id` and `run_id`.
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export type SDKMessage = SDKSystemMessage | SDKUserMessageEvent | SDKAssistantMessage | SDKThinkingMessage | SDKToolUseMessage | SDKStatusMessage | SDKTaskMessage | SDKRequestMessage | SDKObjectDelta;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability slot a provider can fulfill.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type ProviderCapability = "chat" | "web_search" | "image" | "embedding";
|
|
7
|
+
/**
|
|
8
|
+
* A single user-declared routing rule. Maps a capability to a provider, and
|
|
9
|
+
* optionally pins a specific model.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface ProviderRoute {
|
|
14
|
+
capability: ProviderCapability;
|
|
15
|
+
provider: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Provider routing configuration accepted by `Agent.create()` via
|
|
20
|
+
* {@link AgentOptions.providers}.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export interface ProviderRoutingSettings {
|
|
25
|
+
/** Explicit `{ capability → provider }` map. First match wins per capability. */
|
|
26
|
+
routes: ProviderRoute[];
|
|
27
|
+
/** Provider names to try in order when a route has no provider available. */
|
|
28
|
+
fallback?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Multiple API keys per provider for same-provider key rotation
|
|
31
|
+
* (credential pool — ADRs D123-D133). When a key hits HTTP 429, 402,
|
|
32
|
+
* or 401, the SDK rotates to the next entry transparently before
|
|
33
|
+
* falling back to a different provider.
|
|
34
|
+
*
|
|
35
|
+
* Example:
|
|
36
|
+
* ```ts
|
|
37
|
+
* apiKeys: { openrouter: ["sk-or-...", "sk-or-..."], anthropic: ["..."] }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* Empty arrays and empty strings are filtered out. If a provider has
|
|
41
|
+
* exactly 1 effective key, the pool is transparent (no rotation behavior).
|
|
42
|
+
*
|
|
43
|
+
* Conflicts with the single-key shape `AgentOptions.apiKey: "..."` —
|
|
44
|
+
* use one OR the other, not both.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
apiKeys?: Record<string, string[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Rotation strategy per provider for the credential pool. Default is
|
|
51
|
+
* `"fill_first"` (use entries[0] until exhausted). Only consulted when
|
|
52
|
+
* `apiKeys[provider]` has ≥2 entries.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
credentialPoolStrategy?: Record<string, "fill_first" | "round_robin" | "least_used" | "random">;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Plugins configuration accepted by `Agent.create()` via
|
|
60
|
+
* {@link AgentOptions.plugins}.
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export interface PluginsSettings {
|
|
65
|
+
/** Plugin names to enable. Plugin discovery is plugin-provider specific. */
|
|
66
|
+
enabled?: string[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolved routing decision returned by `agent.providers.routes()`. Public and
|
|
70
|
+
* secret-free by design — safe to log.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export interface ResolvedProviderRoute {
|
|
75
|
+
capability: string;
|
|
76
|
+
provider: string;
|
|
77
|
+
model?: string;
|
|
78
|
+
/** Why the runtime picked this provider (e.g. `"explicit-model-provider"`). */
|
|
79
|
+
reason: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Public providers manager handle exposed as `agent.providers`.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export interface SDKProvidersManager {
|
|
87
|
+
/** Inspect which provider serves each capability for this agent. */
|
|
88
|
+
routes(): Promise<ResolvedProviderRoute[]>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Provider catalog entry returned by `Theokit.providers.list()`.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export interface SDKProvider {
|
|
96
|
+
name: string;
|
|
97
|
+
displayName: string;
|
|
98
|
+
capabilities: string[];
|
|
99
|
+
isAvailable: boolean;
|
|
100
|
+
/** JSON Schema describing the env vars / fields needed to enable this provider. */
|
|
101
|
+
setupSchema: object;
|
|
102
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { CustomTool, ModelSelection } from "./agent.js";
|
|
2
|
+
import type { ConversationStep, ConversationTurn } from "./conversation.js";
|
|
3
|
+
import type { McpServerConfig } from "./mcp.js";
|
|
4
|
+
import type { SDKMessage } from "./messages.js";
|
|
5
|
+
import type { InteractionUpdate } from "./updates.js";
|
|
6
|
+
import type { CostBreakdown, TokenUsage } from "./usage.js";
|
|
7
|
+
/**
|
|
8
|
+
* Lifecycle status of a {@link Run}.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type RunStatus = "running" | "finished" | "error" | "cancelled";
|
|
13
|
+
/**
|
|
14
|
+
* Operations that may or may not be supported on a given {@link Run}, or on
|
|
15
|
+
* its parent agent.
|
|
16
|
+
*
|
|
17
|
+
* Runtime-specific availability — query at runtime with `run.supports(op)` and
|
|
18
|
+
* read the human reason via `run.unsupportedReason(op)`.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "fork" | "usePersonality" | "workflow";
|
|
23
|
+
/**
|
|
24
|
+
* Git metadata attached to cloud runs.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export interface RunGitInfo {
|
|
29
|
+
branches: Array<{
|
|
30
|
+
repoUrl: string;
|
|
31
|
+
branch?: string;
|
|
32
|
+
prUrl?: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Terminal result of a {@link Run}.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export interface RunResult {
|
|
41
|
+
id: string;
|
|
42
|
+
status: "finished" | "error" | "cancelled";
|
|
43
|
+
result?: string;
|
|
44
|
+
model?: ModelSelection;
|
|
45
|
+
durationMs?: number;
|
|
46
|
+
git?: RunGitInfo;
|
|
47
|
+
/**
|
|
48
|
+
* Structured error detail, populated when `status === "error"`. Surfaces
|
|
49
|
+
* the diagnostic that emit-error-event pushes into the stream so callers
|
|
50
|
+
* that don't drain `run.stream()` still get the cause via `run.wait()`.
|
|
51
|
+
*
|
|
52
|
+
* For successful runs (`status: "finished"`) this is undefined.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
error?: RunErrorDetail;
|
|
57
|
+
/**
|
|
58
|
+
* Token usage observed for this run (ADR D376). Populated in every
|
|
59
|
+
* status where ≥1 LLM call completed — including partial-failure
|
|
60
|
+
* runs (EC-5). `undefined` only when zero LLM calls executed (e.g.,
|
|
61
|
+
* abort before send).
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
usage?: TokenUsage;
|
|
66
|
+
/**
|
|
67
|
+
* Estimated/actual USD cost for this run (ADR D377). Always paired
|
|
68
|
+
* with `usage` when populated. `cost.status` tells caller how to
|
|
69
|
+
* trust the figure.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
cost?: CostBreakdown;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Structured error attached to a {@link RunResult} when the underlying run
|
|
77
|
+
* transitioned to `"error"` status. `message` is always present; `code` is
|
|
78
|
+
* a stable identifier suitable for branching (e.g. `"llm_4xx"`,
|
|
79
|
+
* `"tool_dispatch_failed"`, `"mcp_init_failed"`); `cause` is the raw error
|
|
80
|
+
* for further inspection when available.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export interface RunErrorDetail {
|
|
85
|
+
message: string;
|
|
86
|
+
code?: string;
|
|
87
|
+
cause?: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Dimensions of an inline image attachment.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export interface SDKImageDimension {
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Either a remote URL or inline base64 payload.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export type SDKImage = {
|
|
104
|
+
url: string;
|
|
105
|
+
dimension?: SDKImageDimension;
|
|
106
|
+
} | {
|
|
107
|
+
data: string;
|
|
108
|
+
mimeType: string;
|
|
109
|
+
dimension?: SDKImageDimension;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Structured form of `agent.send()`'s message argument. Use it to send images
|
|
113
|
+
* alongside text.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
export interface SDKUserMessage {
|
|
118
|
+
text: string;
|
|
119
|
+
images?: SDKImage[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Per-send overrides and callbacks.
|
|
123
|
+
*
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export interface SendOptions {
|
|
127
|
+
model?: ModelSelection;
|
|
128
|
+
/**
|
|
129
|
+
* Per-call system prompt override. Wins over `AgentOptions.systemPrompt`.
|
|
130
|
+
* String only — for dynamic resolvers, configure on `AgentOptions`. An
|
|
131
|
+
* empty string is honoured (it explicitly clears the system context).
|
|
132
|
+
*/
|
|
133
|
+
systemPrompt?: string;
|
|
134
|
+
/** Fully replaces creation-time servers for this run (not merged). */
|
|
135
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
136
|
+
/**
|
|
137
|
+
* Per-call inline custom tools. Fully replaces `AgentOptions.tools` for
|
|
138
|
+
* this run (not merged). Local runtime only — cloud agents reject any
|
|
139
|
+
* non-empty per-call tools array with the same error code as creation
|
|
140
|
+
* (`cloud_custom_tools_rejected`). Semantics:
|
|
141
|
+
* - `undefined` → fall back to `AgentOptions.tools`
|
|
142
|
+
* - `[]` → explicitly clear (no custom tools for this run)
|
|
143
|
+
* - `[t1, t2]` → use exactly these tools for this run
|
|
144
|
+
*/
|
|
145
|
+
tools?: CustomTool[];
|
|
146
|
+
onStep?: (args: {
|
|
147
|
+
step: ConversationStep;
|
|
148
|
+
}) => void | Promise<void>;
|
|
149
|
+
onDelta?: (args: {
|
|
150
|
+
update: InteractionUpdate;
|
|
151
|
+
}) => void | Promise<void>;
|
|
152
|
+
/** Local agents only. Expire a stuck active run before starting this message. */
|
|
153
|
+
local?: {
|
|
154
|
+
force?: boolean;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Optional `AbortSignal` propagated to memory adapter `pre_user_send`
|
|
158
|
+
* hooks (EC-H). Note: the LLM HTTP call itself is NOT cancellable
|
|
159
|
+
* mid-stream — same constraint as `Agent.batch` (ADR D140).
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
signal?: AbortSignal;
|
|
164
|
+
/**
|
|
165
|
+
* Opt-in task wrapping (ADRs D363, D374). When truthy, the entire
|
|
166
|
+
* run is registered as a `Task` in the SDK's observable registry —
|
|
167
|
+
* caller can list / inspect / cancel / subscribe via the `Task`
|
|
168
|
+
* namespace. Default behavior (no `task` option) is byte-identical
|
|
169
|
+
* to v1.1 (no Task overhead).
|
|
170
|
+
*
|
|
171
|
+
* Accepts:
|
|
172
|
+
* - `true` — auto-generate task id; no extra metadata.
|
|
173
|
+
* - `{ id, meta }` — user-supplied id (D368 grammar enforced) and/or
|
|
174
|
+
* metadata attached to the handle's `meta` field.
|
|
175
|
+
*
|
|
176
|
+
* The work-fn `signal` is **merged** with `options.signal` (whichever
|
|
177
|
+
* aborts first wins). Local agents only — CloudAgent throws
|
|
178
|
+
* `UnsupportedTaskOperationError` (D370).
|
|
179
|
+
*
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
task?: true | {
|
|
183
|
+
id?: string;
|
|
184
|
+
meta?: Record<string, unknown>;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Handle to a single prompt submission.
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
*/
|
|
192
|
+
export interface Run {
|
|
193
|
+
readonly id: string;
|
|
194
|
+
readonly agentId: string;
|
|
195
|
+
readonly status: RunStatus;
|
|
196
|
+
readonly result?: string;
|
|
197
|
+
readonly model?: ModelSelection;
|
|
198
|
+
readonly durationMs?: number;
|
|
199
|
+
readonly git?: RunGitInfo;
|
|
200
|
+
readonly createdAt?: number;
|
|
201
|
+
/** AsyncGenerator of normalized stream events. Discriminate on `event.type`. */
|
|
202
|
+
stream(): AsyncGenerator<SDKMessage, void>;
|
|
203
|
+
/** Resolves to the terminal {@link RunResult}. */
|
|
204
|
+
wait(): Promise<RunResult>;
|
|
205
|
+
/** Move status to `"cancelled"`, abort the stream, stop in-flight tool calls. */
|
|
206
|
+
cancel(): Promise<void>;
|
|
207
|
+
/** Structured per-turn view of the conversation. */
|
|
208
|
+
conversation(): Promise<ConversationTurn[]>;
|
|
209
|
+
/** Whether the given operation is available on this run's runtime. */
|
|
210
|
+
supports(operation: RunOperation): boolean;
|
|
211
|
+
/** Human-readable reason that `supports(operation)` returned `false`. */
|
|
212
|
+
unsupportedReason(operation: RunOperation): string | undefined;
|
|
213
|
+
/** Subscribe to status changes. Returns an unsubscribe function. */
|
|
214
|
+
onDidChangeStatus(listener: (status: RunStatus) => void): () => void;
|
|
215
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type contract for the Task observability registry (ADRs D361-D374).
|
|
3
|
+
*
|
|
4
|
+
* Tasks are an opt-in observability layer over async work in the SDK
|
|
5
|
+
* (`Agent.send`, `Agent.batch`, `Workflow.run`, `Cron` fires). They have
|
|
6
|
+
* a closed 5-state lifecycle (D362), discriminated events (D366), and a
|
|
7
|
+
* pluggable store (D364). The `Task` facade in `task.ts` is the public
|
|
8
|
+
* surface; consumers import these types from `@theokit/sdk`.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Closed enum of the 5 lifecycle states (D362).
|
|
14
|
+
*
|
|
15
|
+
* Transitions are acyclic:
|
|
16
|
+
* queued → running → (finished | error | cancelled)
|
|
17
|
+
* queued → cancelled (direct, no run started)
|
|
18
|
+
*/
|
|
19
|
+
export type TaskState = "queued" | "running" | "finished" | "error" | "cancelled";
|
|
20
|
+
/** Discriminator of the runtime that produced a task (D374). */
|
|
21
|
+
export type TaskKind = "run" | "batch" | "workflow" | "cron" | "custom";
|
|
22
|
+
/** Discriminated union of task lifecycle events (D366). */
|
|
23
|
+
export type TaskEvent = {
|
|
24
|
+
readonly type: "submitted";
|
|
25
|
+
readonly taskId: string;
|
|
26
|
+
readonly kind: TaskKind;
|
|
27
|
+
readonly submittedAt: number;
|
|
28
|
+
readonly meta?: Record<string, unknown>;
|
|
29
|
+
/** D372 — flag set on the first yielded event when the ring buffer was at cap. */
|
|
30
|
+
readonly truncated?: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "started";
|
|
33
|
+
readonly taskId: string;
|
|
34
|
+
readonly startedAt: number;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "progress";
|
|
37
|
+
readonly taskId: string;
|
|
38
|
+
readonly at: number;
|
|
39
|
+
readonly payload: unknown;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "finished";
|
|
42
|
+
readonly taskId: string;
|
|
43
|
+
readonly finishedAt: number;
|
|
44
|
+
readonly result: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "errored";
|
|
47
|
+
readonly taskId: string;
|
|
48
|
+
readonly erroredAt: number;
|
|
49
|
+
readonly error: {
|
|
50
|
+
readonly code: string;
|
|
51
|
+
readonly message: string;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
readonly type: "cancelled";
|
|
55
|
+
readonly taskId: string;
|
|
56
|
+
readonly cancelledAt: number;
|
|
57
|
+
readonly reason?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Public read-only view of a task entry in the registry. */
|
|
60
|
+
export interface TaskHandle {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly kind: TaskKind;
|
|
63
|
+
readonly state: TaskState;
|
|
64
|
+
readonly submittedAt: number;
|
|
65
|
+
readonly startedAt?: number;
|
|
66
|
+
readonly finishedAt?: number;
|
|
67
|
+
readonly cancelledAt?: number;
|
|
68
|
+
readonly erroredAt?: number;
|
|
69
|
+
readonly result?: unknown;
|
|
70
|
+
readonly error?: {
|
|
71
|
+
readonly code: string;
|
|
72
|
+
readonly message: string;
|
|
73
|
+
};
|
|
74
|
+
readonly meta?: Record<string, unknown>;
|
|
75
|
+
/**
|
|
76
|
+
* EC-7 — cross-process best-effort cancel flag. Set by CLI
|
|
77
|
+
* `theokit tasks cancel` via JsonFileTaskStore. The owning process
|
|
78
|
+
* polls at checkpoints and honors via AbortController. Always
|
|
79
|
+
* `undefined` for in-process cancel paths (which go directly through
|
|
80
|
+
* AbortController).
|
|
81
|
+
*/
|
|
82
|
+
readonly cancelRequested?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** Query filter for `Task.list`. */
|
|
85
|
+
export interface TaskFilter {
|
|
86
|
+
readonly state?: TaskState | readonly TaskState[];
|
|
87
|
+
readonly kind?: TaskKind | readonly TaskKind[];
|
|
88
|
+
readonly submittedAfter?: number;
|
|
89
|
+
readonly submittedBefore?: number;
|
|
90
|
+
/** Defaults to 100. JsonFileTaskStore hard-caps loaded entries at 256 (D364). */
|
|
91
|
+
readonly limit?: number;
|
|
92
|
+
}
|
|
93
|
+
/** Options for `Task.submit`. */
|
|
94
|
+
export interface TaskSubmitOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Optional user-supplied ID. Must match grammar `^[a-z0-9][a-z0-9_-]*$`
|
|
97
|
+
* and MUST NOT start with the reserved prefixes `wf-` / `b-` / `cron-`
|
|
98
|
+
* (D368, EC-5). When omitted, `crypto.randomUUID()` is used.
|
|
99
|
+
*/
|
|
100
|
+
readonly id?: string;
|
|
101
|
+
readonly meta?: Record<string, unknown>;
|
|
102
|
+
/**
|
|
103
|
+
* Optional caller-provided AbortSignal. If already aborted at submit
|
|
104
|
+
* time, the registry short-circuits to `cancelled` without acquiring
|
|
105
|
+
* a semaphore slot (EC-4).
|
|
106
|
+
*/
|
|
107
|
+
readonly signal?: AbortSignal;
|
|
108
|
+
}
|
|
109
|
+
/** Options shape for `TaskStore` factory (D364). */
|
|
110
|
+
export type TaskStoreOptions = {
|
|
111
|
+
readonly backend: "memory";
|
|
112
|
+
} | {
|
|
113
|
+
readonly backend: "json";
|
|
114
|
+
readonly dir: string;
|
|
115
|
+
};
|
|
116
|
+
/** Result of `Task.cancel` (D365 — idempotent). */
|
|
117
|
+
export interface TaskCancelResult {
|
|
118
|
+
readonly cancelled: boolean;
|
|
119
|
+
readonly alreadyTerminal: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validates a task ID against the public grammar + reserved prefixes.
|
|
123
|
+
* Throws `InvalidTaskIdError` from `../errors.js` on rejection.
|
|
124
|
+
*
|
|
125
|
+
* Adapter callers (workflow/batch/cron) MUST set `allowReserved: true`
|
|
126
|
+
* to register their own IDs; user-facing surfaces (`Task.submit`,
|
|
127
|
+
* `agent.send({ task: { id } })`) leave it false.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isValidTaskId(id: string, allowReserved: boolean): boolean;
|
|
130
|
+
/** Re-exported for adapter implementations + tests. */
|
|
131
|
+
export declare const TASK_RESERVED_PREFIXES: readonly string[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account-level user info returned by `Theokit.me()`.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface SDKUser {
|
|
7
|
+
apiKeyName: string;
|
|
8
|
+
userEmail?: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Per-model parameter definition discovered from `Theokit.models.list()`.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface ModelParameterDefinition {
|
|
17
|
+
id: string;
|
|
18
|
+
displayName?: string;
|
|
19
|
+
values: Array<{
|
|
20
|
+
value: string;
|
|
21
|
+
displayName?: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Preset variant for a model — pre-filled parameter combinations.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export interface ModelVariant {
|
|
30
|
+
params: Array<{
|
|
31
|
+
id: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}>;
|
|
34
|
+
displayName: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
isDefault?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Single model entry in the catalog.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export interface ModelListItem {
|
|
44
|
+
id: string;
|
|
45
|
+
/** Short, plain-text model name. Mirrors `displayName` for typical SDKs. */
|
|
46
|
+
name?: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
parameters?: ModelParameterDefinition[];
|
|
50
|
+
variants?: ModelVariant[];
|
|
51
|
+
}
|
|
52
|
+
/** @public */
|
|
53
|
+
export type SDKModel = ModelListItem;
|
|
54
|
+
/**
|
|
55
|
+
* GitHub repository connected to the team. Cloud-only.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export interface SDKRepository {
|
|
60
|
+
url: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for ShareGPT trajectory export (ADR D139).
|
|
3
|
+
*
|
|
4
|
+
* Output format for fine-tuning datasets — consumed by HuggingFace, Axolotl,
|
|
5
|
+
* LLaMA-Factory, and most modern fine-tuning toolchains. Pure data shape;
|
|
6
|
+
* no runtime dependency.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* One ShareGPT message in a conversation. `from` identifies the role and
|
|
12
|
+
* `value` carries the textual content. Tool calls live in `tool_calls`
|
|
13
|
+
* (assistant-only) and tool results re-enter as `from: "tool"` entries.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface ShareGptMessage {
|
|
18
|
+
/** "human" for user, "gpt" for assistant, "tool" for tool result, "system" for system. */
|
|
19
|
+
from: "human" | "gpt" | "tool" | "system";
|
|
20
|
+
/** The message text. Empty string is valid (preserves turn boundary). */
|
|
21
|
+
value: string;
|
|
22
|
+
/** Optional tool calls — only emitted when `from === "gpt"`. */
|
|
23
|
+
tool_calls?: Array<{
|
|
24
|
+
name: string;
|
|
25
|
+
arguments: Record<string, unknown>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* One full ShareGPT-format trajectory — a single conversation plus
|
|
30
|
+
* metadata. JSONL-friendly (one trajectory per line when serialized).
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface ShareGptTrajectory {
|
|
35
|
+
conversations: ShareGptMessage[];
|
|
36
|
+
metadata?: {
|
|
37
|
+
model?: string;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
durationMs: number;
|
|
40
|
+
promptIndex: number;
|
|
41
|
+
};
|
|
42
|
+
/** `true` when the source `BatchResult.ok === true`. Always `true` in current shape. */
|
|
43
|
+
completed: boolean;
|
|
44
|
+
/** Token usage when surfaced by the underlying RunResult (provider-specific). */
|
|
45
|
+
usage?: {
|
|
46
|
+
inputTokens: number;
|
|
47
|
+
outputTokens: number;
|
|
48
|
+
};
|
|
49
|
+
}
|