@theokit/sdk 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/a2a/index.cjs +384 -317
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.js +384 -317
  5. package/dist/a2a/index.js.map +1 -1
  6. package/dist/concurrency.cjs +86 -0
  7. package/dist/concurrency.cjs.map +1 -0
  8. package/dist/concurrency.d.cts +13 -0
  9. package/dist/concurrency.d.ts +13 -0
  10. package/dist/concurrency.js +83 -0
  11. package/dist/concurrency.js.map +1 -0
  12. package/dist/{cron-Bse1MbaE.d.cts → cron-CSTqNZp9.d.cts} +2 -2
  13. package/dist/{cron-Ci_NUkUj.d.ts → cron-Da6vF_2y.d.ts} +2 -2
  14. package/dist/cron.cjs +346 -295
  15. package/dist/cron.cjs.map +1 -1
  16. package/dist/cron.d.cts +1 -1
  17. package/dist/cron.d.ts +1 -1
  18. package/dist/cron.js +349 -298
  19. package/dist/cron.js.map +1 -1
  20. package/dist/{errors-DV9e0rcp.d.ts → errors--VP2qrGc.d.ts} +23 -1
  21. package/dist/{errors-ChqOmFH1.d.cts → errors-C9xkhNEF.d.cts} +23 -1
  22. package/dist/errors.cjs +17 -11
  23. package/dist/errors.cjs.map +1 -1
  24. package/dist/errors.d.cts +1 -1
  25. package/dist/errors.d.ts +22 -0
  26. package/dist/errors.js +17 -12
  27. package/dist/errors.js.map +1 -1
  28. package/dist/eval.cjs +345 -291
  29. package/dist/eval.cjs.map +1 -1
  30. package/dist/eval.d.cts +1 -0
  31. package/dist/eval.d.ts +1 -0
  32. package/dist/eval.js +348 -294
  33. package/dist/eval.js.map +1 -1
  34. package/dist/index.cjs +342 -275
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +161 -119
  37. package/dist/index.d.ts +161 -119
  38. package/dist/index.js +342 -277
  39. package/dist/index.js.map +1 -1
  40. package/dist/internal/persistence/index.cjs +75 -0
  41. package/dist/internal/persistence/index.cjs.map +1 -1
  42. package/dist/internal/persistence/index.d.cts +2 -0
  43. package/dist/internal/persistence/index.d.ts +2 -0
  44. package/dist/internal/persistence/index.js +74 -1
  45. package/dist/internal/persistence/index.js.map +1 -1
  46. package/dist/internal/persistence/sqlite-open.d.cts +47 -0
  47. package/dist/internal/persistence/sqlite-open.d.ts +47 -0
  48. package/dist/internal/providers/register-plugin-providers.d.ts +22 -0
  49. package/dist/internal/runtime/concurrency/map-with-concurrency.d.ts +28 -0
  50. package/dist/internal/runtime/{fork-agent.d.ts → lifecycle/fork-agent.d.ts} +1 -1
  51. package/dist/internal/runtime/{run-until.d.ts → lifecycle/run-until.d.ts} +3 -3
  52. package/dist/internal/runtime/local-agent/local-agent-bootstrap.d.ts +1 -1
  53. package/dist/internal/runtime/registry/agent-factory-registry.d.ts +12 -9
  54. package/dist/internal/runtime/retry/with-retry.d.ts +40 -0
  55. package/dist/internal/runtime/validation/validate-agent-options.d.ts +1 -0
  56. package/dist/internal/scorers/llm-judge.d.ts +4 -4
  57. package/dist/internal/security/index.cjs +1 -0
  58. package/dist/internal/security/index.cjs.map +1 -1
  59. package/dist/internal/security/index.d.cts +1 -1
  60. package/dist/internal/security/index.d.ts +1 -1
  61. package/dist/internal/security/index.js +1 -0
  62. package/dist/internal/security/index.js.map +1 -1
  63. package/dist/path-safety.cjs +15 -0
  64. package/dist/path-safety.cjs.map +1 -1
  65. package/dist/path-safety.d.cts +1 -1
  66. package/dist/path-safety.d.ts +1 -1
  67. package/dist/path-safety.js +15 -1
  68. package/dist/path-safety.js.map +1 -1
  69. package/dist/retry.cjs +85 -0
  70. package/dist/retry.cjs.map +1 -0
  71. package/dist/retry.d.cts +9 -0
  72. package/dist/retry.d.ts +9 -0
  73. package/dist/retry.js +83 -0
  74. package/dist/retry.js.map +1 -0
  75. package/dist/server/errors-envelope.cjs +14 -12
  76. package/dist/server/errors-envelope.cjs.map +1 -1
  77. package/dist/server/errors-envelope.js +14 -12
  78. package/dist/server/errors-envelope.js.map +1 -1
  79. package/dist/subscription/index.cjs.map +1 -1
  80. package/dist/subscription/index.js.map +1 -1
  81. package/dist/task-store.cjs.map +1 -1
  82. package/dist/task-store.js.map +1 -1
  83. package/dist/types/fork.d.ts +1 -1
  84. package/dist/workflow.cjs +2 -2
  85. package/dist/workflow.cjs.map +1 -1
  86. package/dist/workflow.js +2 -2
  87. package/dist/workflow.js.map +1 -1
  88. package/package.json +26 -2
  89. /package/dist/internal/{runtime/default-model.d.ts → default-retriable.d.ts} +0 -0
  90. /package/dist/internal/{errors/mappers → error-mappers}/anthropic.d.ts +0 -0
  91. /package/dist/internal/{errors/mappers → error-mappers}/bedrock.d.ts +0 -0
  92. /package/dist/internal/{errors/mappers → error-mappers}/ollama.d.ts +0 -0
  93. /package/dist/internal/{errors/mappers → error-mappers}/openai-compatible.d.ts +0 -0
  94. /package/dist/internal/{errors/mappers → error-mappers}/shared.d.ts +0 -0
  95. /package/dist/internal/{errors/mappers → error-mappers}/vertex.d.ts +0 -0
  96. /package/dist/internal/runtime/{abort-utils.d.ts → concurrency/abort-utils.d.ts} +0 -0
  97. /package/dist/internal/runtime/{async-local-storage.d.ts → concurrency/async-local-storage.d.ts} +0 -0
  98. /package/dist/internal/runtime/{async-semaphore.d.ts → concurrency/async-semaphore.d.ts} +0 -0
  99. /package/dist/internal/runtime/{post-run-lifecycle.d.ts → config/default-model.d.ts} +0 -0
  100. /package/dist/internal/runtime/{providers-manager.d.ts → config/providers-manager.d.ts} +0 -0
  101. /package/dist/internal/runtime/{workspace-dir.d.ts → config/workspace-dir.d.ts} +0 -0
  102. /package/dist/internal/runtime/{yaml-frontmatter.d.ts → context/yaml-frontmatter.d.ts} +0 -0
  103. /package/dist/internal/runtime/{system-prompt.d.ts → lifecycle/post-run-lifecycle.d.ts} +0 -0
  104. /package/dist/internal/runtime/{spawn-collect.d.ts → lifecycle/spawn-collect.d.ts} +0 -0
  105. /package/dist/internal/runtime/{validate-agent-options.d.ts → system-prompt/system-prompt.d.ts} +0 -0
  106. /package/dist/internal/runtime/{shell-tool.d.ts → tools/shell-tool.d.ts} +0 -0
  107. /package/dist/internal/runtime/{validate-response.d.ts → validation/validate-response.d.ts} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-ChqOmFH1.cjs';
2
- export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-ChqOmFH1.cjs';
3
- import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Bse1MbaE.cjs';
4
- export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Bse1MbaE.cjs';
1
+ import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-C9xkhNEF.cjs';
2
+ export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-C9xkhNEF.cjs';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-CSTqNZp9.cjs';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-CSTqNZp9.cjs';
5
5
  import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.cjs';
6
6
  export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.cjs';
7
7
  import * as zod from 'zod';
@@ -821,6 +821,162 @@ declare class Budget {
821
821
  static snapshot(): readonly BudgetSnapshot[];
822
822
  }
823
823
 
824
+ /**
825
+ * ProviderProfile + ApiMode types (T3.1, ADR D105).
826
+ *
827
+ * Profile is **data-only** — no methods. Adding a provider is declaring an
828
+ * object literal; the Transport layer (D106) consumes `apiMode` to pick
829
+ * the HTTP dialect.
830
+ *
831
+ * @public
832
+ */
833
+ type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
834
+ type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
835
+ interface ProviderProfile {
836
+ name: string;
837
+ apiMode: ApiMode;
838
+ aliases?: ReadonlyArray<string>;
839
+ displayName?: string;
840
+ description?: string;
841
+ signupUrl?: string;
842
+ envVars: ReadonlyArray<string>;
843
+ authType: AuthType;
844
+ baseUrl: string;
845
+ modelsUrl?: string;
846
+ hostname?: string;
847
+ fallbackModels: ReadonlyArray<string>;
848
+ extraHeaders?: Record<string, string>;
849
+ bodyOverrides?: Record<string, unknown>;
850
+ }
851
+
852
+ type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
853
+ interface PreToolCallContext {
854
+ name: string;
855
+ args: Record<string, unknown>;
856
+ agentId: string;
857
+ runId: string;
858
+ }
859
+ interface PreToolCallDecision {
860
+ block: true;
861
+ message: string;
862
+ }
863
+ /**
864
+ * Context passed to `pre_user_send` hook handlers (ADR D145).
865
+ *
866
+ * @public
867
+ */
868
+ interface PreUserSendContext {
869
+ prompt: string;
870
+ agentId: string;
871
+ runId: string;
872
+ /** Caller-supplied memory context, flowing through from `AgentOptions.memoryContext`. */
873
+ memoryContext?: MemoryContext;
874
+ /** Forwarded `AbortSignal` so adapter recall HTTP can be cancelled mid-flight (EC-H). */
875
+ signal?: AbortSignal;
876
+ }
877
+ /**
878
+ * Optional result returned by `pre_user_send` handlers. The agent loop
879
+ * concatenates `recalledContext` from all handlers and injects it as a
880
+ * `<memory-context>...</memory-context>` block before the user prompt.
881
+ *
882
+ * @public
883
+ */
884
+ interface PreUserSendResult {
885
+ recalledContext?: string;
886
+ }
887
+ /**
888
+ * Context passed to `post_assistant_reply` hook handlers (ADR D145).
889
+ * Fire-and-forget — exceptions are caught and surfaced to stderr; the
890
+ * caller's `wait()` never blocks on this dispatch.
891
+ *
892
+ * @public
893
+ */
894
+ interface PostAssistantReplyContext {
895
+ prompt: string;
896
+ reply: string;
897
+ agentId: string;
898
+ runId: string;
899
+ memoryContext?: MemoryContext;
900
+ }
901
+ type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
902
+ type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
903
+ interface CommandOptions {
904
+ description?: string;
905
+ }
906
+ interface PluginContext {
907
+ /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
908
+ registerTool(tool: CustomTool): void;
909
+ /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
910
+ registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
911
+ /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
912
+ on(hook: HookName, handler: HookHandler): void;
913
+ /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
914
+ injectMessage(content: string, role?: "user" | "system"): void;
915
+ }
916
+ interface BasePlugin {
917
+ name: string;
918
+ version: string;
919
+ }
920
+ type Plugin = (BasePlugin & {
921
+ kind: "general";
922
+ register: (ctx: PluginContext) => void | Promise<void>;
923
+ }) | (BasePlugin & {
924
+ kind: "model-provider";
925
+ profile: ProviderProfile;
926
+ }) | (BasePlugin & {
927
+ kind: "memory";
928
+ createProvider: MemoryProviderFactory;
929
+ });
930
+ /**
931
+ * Identity helper for plugin authors. TS-only convenience — preserves
932
+ * inferred type without forcing manual `Plugin` annotation.
933
+ *
934
+ * @public
935
+ */
936
+ declare function definePlugin<P extends Plugin>(p: P): P;
937
+
938
+ /**
939
+ * Options for {@link defineProvider}.
940
+ *
941
+ * @public
942
+ */
943
+ interface DefineProviderOptions {
944
+ /** Plugin version surfaced in diagnostics. Default `"1.0.0"`. */
945
+ version?: string;
946
+ }
947
+ /**
948
+ * Canonical factory for a custom LLM provider, mirroring {@link defineTool} and
949
+ * {@link definePlugin} (Inviolable Rule 9 — every agentic capability ships as a
950
+ * factory function).
951
+ *
952
+ * A {@link ProviderProfile} is data-only: it declares the provider name, the
953
+ * HTTP dialect (`apiMode`), auth, base URL and fallback models. The transport
954
+ * is selected from `apiMode` by the router, so any OpenAI-/Anthropic-compatible
955
+ * endpoint (Groq, Together, Fireworks, a private gateway) is expressible as a
956
+ * profile with no new code.
957
+ *
958
+ * Pass the result to `Agent.create({ plugins: [...] })` and route to it with
959
+ * the `provider/model` id prefix or `providers.routes`:
960
+ *
961
+ * ```ts
962
+ * const groq = defineProvider({
963
+ * name: "groq",
964
+ * apiMode: "chat_completions",
965
+ * authType: "api_key",
966
+ * envVars: ["GROQ_API_KEY"],
967
+ * baseUrl: "https://api.groq.com/openai/v1",
968
+ * fallbackModels: ["groq/llama-3.1-8b-instant"],
969
+ * });
970
+ * const agent = await Agent.create({
971
+ * model: { id: "groq/llama-3.1-8b-instant" },
972
+ * plugins: [groq],
973
+ * });
974
+ * ```
975
+ *
976
+ * @public
977
+ */
978
+ declare function defineProvider(profile: ProviderProfile, opts?: DefineProviderOptions): Plugin;
979
+
824
980
  /**
825
981
  * Spec accepted by {@link defineTool}. `inputSchema` is a Zod schema; the
826
982
  * `handler` argument type is inferred via `z.infer<T>` — no `as` casts.
@@ -943,120 +1099,6 @@ declare class InMemoryConversationStorage implements ConversationStorageAdapter
943
1099
 
944
1100
  declare function withCwdMutex<T>(key: string, fn: () => Promise<T>): Promise<T>;
945
1101
 
946
- /**
947
- * ProviderProfile + ApiMode types (T3.1, ADR D105).
948
- *
949
- * Profile is **data-only** — no methods. Adding a provider is declaring an
950
- * object literal; the Transport layer (D106) consumes `apiMode` to pick
951
- * the HTTP dialect.
952
- *
953
- * @public
954
- */
955
- type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
956
- type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
957
- interface ProviderProfile {
958
- name: string;
959
- apiMode: ApiMode;
960
- aliases?: ReadonlyArray<string>;
961
- displayName?: string;
962
- description?: string;
963
- signupUrl?: string;
964
- envVars: ReadonlyArray<string>;
965
- authType: AuthType;
966
- baseUrl: string;
967
- modelsUrl?: string;
968
- hostname?: string;
969
- fallbackModels: ReadonlyArray<string>;
970
- extraHeaders?: Record<string, string>;
971
- bodyOverrides?: Record<string, unknown>;
972
- }
973
-
974
- type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
975
- interface PreToolCallContext {
976
- name: string;
977
- args: Record<string, unknown>;
978
- agentId: string;
979
- runId: string;
980
- }
981
- interface PreToolCallDecision {
982
- block: true;
983
- message: string;
984
- }
985
- /**
986
- * Context passed to `pre_user_send` hook handlers (ADR D145).
987
- *
988
- * @public
989
- */
990
- interface PreUserSendContext {
991
- prompt: string;
992
- agentId: string;
993
- runId: string;
994
- /** Caller-supplied memory context, flowing through from `AgentOptions.memoryContext`. */
995
- memoryContext?: MemoryContext;
996
- /** Forwarded `AbortSignal` so adapter recall HTTP can be cancelled mid-flight (EC-H). */
997
- signal?: AbortSignal;
998
- }
999
- /**
1000
- * Optional result returned by `pre_user_send` handlers. The agent loop
1001
- * concatenates `recalledContext` from all handlers and injects it as a
1002
- * `<memory-context>...</memory-context>` block before the user prompt.
1003
- *
1004
- * @public
1005
- */
1006
- interface PreUserSendResult {
1007
- recalledContext?: string;
1008
- }
1009
- /**
1010
- * Context passed to `post_assistant_reply` hook handlers (ADR D145).
1011
- * Fire-and-forget — exceptions are caught and surfaced to stderr; the
1012
- * caller's `wait()` never blocks on this dispatch.
1013
- *
1014
- * @public
1015
- */
1016
- interface PostAssistantReplyContext {
1017
- prompt: string;
1018
- reply: string;
1019
- agentId: string;
1020
- runId: string;
1021
- memoryContext?: MemoryContext;
1022
- }
1023
- type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
1024
- type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
1025
- interface CommandOptions {
1026
- description?: string;
1027
- }
1028
- interface PluginContext {
1029
- /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
1030
- registerTool(tool: CustomTool): void;
1031
- /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
1032
- registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
1033
- /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
1034
- on(hook: HookName, handler: HookHandler): void;
1035
- /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
1036
- injectMessage(content: string, role?: "user" | "system"): void;
1037
- }
1038
- interface BasePlugin {
1039
- name: string;
1040
- version: string;
1041
- }
1042
- type Plugin = (BasePlugin & {
1043
- kind: "general";
1044
- register: (ctx: PluginContext) => void | Promise<void>;
1045
- }) | (BasePlugin & {
1046
- kind: "model-provider";
1047
- profile: ProviderProfile;
1048
- }) | (BasePlugin & {
1049
- kind: "memory";
1050
- createProvider: MemoryProviderFactory;
1051
- });
1052
- /**
1053
- * Identity helper for plugin authors. TS-only convenience — preserves
1054
- * inferred type without forcing manual `Plugin` annotation.
1055
- *
1056
- * @public
1057
- */
1058
- declare function definePlugin<P extends Plugin>(p: P): P;
1059
-
1060
1102
  /**
1061
1103
  * Reference `BudgetTracker` impl — pure token + iteration counter
1062
1104
  * (SDK 2.0 Phase 2 / T2.1 — ADR D1 reference implementation).
@@ -2066,4 +2108,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2066
2108
  model?: string;
2067
2109
  }): ShareGptTrajectory | null;
2068
2110
 
2069
- export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
2111
+ export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-DV9e0rcp.js';
2
- export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-DV9e0rcp.js';
3
- import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Ci_NUkUj.js';
4
- export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Ci_NUkUj.js';
1
+ import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors--VP2qrGc.js';
2
+ export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors--VP2qrGc.js';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Da6vF_2y.js';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Da6vF_2y.js';
5
5
  import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.js';
6
6
  export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.js';
7
7
  import * as zod from 'zod';
@@ -821,6 +821,162 @@ declare class Budget {
821
821
  static snapshot(): readonly BudgetSnapshot[];
822
822
  }
823
823
 
824
+ /**
825
+ * ProviderProfile + ApiMode types (T3.1, ADR D105).
826
+ *
827
+ * Profile is **data-only** — no methods. Adding a provider is declaring an
828
+ * object literal; the Transport layer (D106) consumes `apiMode` to pick
829
+ * the HTTP dialect.
830
+ *
831
+ * @public
832
+ */
833
+ type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
834
+ type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
835
+ interface ProviderProfile {
836
+ name: string;
837
+ apiMode: ApiMode;
838
+ aliases?: ReadonlyArray<string>;
839
+ displayName?: string;
840
+ description?: string;
841
+ signupUrl?: string;
842
+ envVars: ReadonlyArray<string>;
843
+ authType: AuthType;
844
+ baseUrl: string;
845
+ modelsUrl?: string;
846
+ hostname?: string;
847
+ fallbackModels: ReadonlyArray<string>;
848
+ extraHeaders?: Record<string, string>;
849
+ bodyOverrides?: Record<string, unknown>;
850
+ }
851
+
852
+ type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
853
+ interface PreToolCallContext {
854
+ name: string;
855
+ args: Record<string, unknown>;
856
+ agentId: string;
857
+ runId: string;
858
+ }
859
+ interface PreToolCallDecision {
860
+ block: true;
861
+ message: string;
862
+ }
863
+ /**
864
+ * Context passed to `pre_user_send` hook handlers (ADR D145).
865
+ *
866
+ * @public
867
+ */
868
+ interface PreUserSendContext {
869
+ prompt: string;
870
+ agentId: string;
871
+ runId: string;
872
+ /** Caller-supplied memory context, flowing through from `AgentOptions.memoryContext`. */
873
+ memoryContext?: MemoryContext;
874
+ /** Forwarded `AbortSignal` so adapter recall HTTP can be cancelled mid-flight (EC-H). */
875
+ signal?: AbortSignal;
876
+ }
877
+ /**
878
+ * Optional result returned by `pre_user_send` handlers. The agent loop
879
+ * concatenates `recalledContext` from all handlers and injects it as a
880
+ * `<memory-context>...</memory-context>` block before the user prompt.
881
+ *
882
+ * @public
883
+ */
884
+ interface PreUserSendResult {
885
+ recalledContext?: string;
886
+ }
887
+ /**
888
+ * Context passed to `post_assistant_reply` hook handlers (ADR D145).
889
+ * Fire-and-forget — exceptions are caught and surfaced to stderr; the
890
+ * caller's `wait()` never blocks on this dispatch.
891
+ *
892
+ * @public
893
+ */
894
+ interface PostAssistantReplyContext {
895
+ prompt: string;
896
+ reply: string;
897
+ agentId: string;
898
+ runId: string;
899
+ memoryContext?: MemoryContext;
900
+ }
901
+ type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
902
+ type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
903
+ interface CommandOptions {
904
+ description?: string;
905
+ }
906
+ interface PluginContext {
907
+ /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
908
+ registerTool(tool: CustomTool): void;
909
+ /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
910
+ registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
911
+ /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
912
+ on(hook: HookName, handler: HookHandler): void;
913
+ /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
914
+ injectMessage(content: string, role?: "user" | "system"): void;
915
+ }
916
+ interface BasePlugin {
917
+ name: string;
918
+ version: string;
919
+ }
920
+ type Plugin = (BasePlugin & {
921
+ kind: "general";
922
+ register: (ctx: PluginContext) => void | Promise<void>;
923
+ }) | (BasePlugin & {
924
+ kind: "model-provider";
925
+ profile: ProviderProfile;
926
+ }) | (BasePlugin & {
927
+ kind: "memory";
928
+ createProvider: MemoryProviderFactory;
929
+ });
930
+ /**
931
+ * Identity helper for plugin authors. TS-only convenience — preserves
932
+ * inferred type without forcing manual `Plugin` annotation.
933
+ *
934
+ * @public
935
+ */
936
+ declare function definePlugin<P extends Plugin>(p: P): P;
937
+
938
+ /**
939
+ * Options for {@link defineProvider}.
940
+ *
941
+ * @public
942
+ */
943
+ interface DefineProviderOptions {
944
+ /** Plugin version surfaced in diagnostics. Default `"1.0.0"`. */
945
+ version?: string;
946
+ }
947
+ /**
948
+ * Canonical factory for a custom LLM provider, mirroring {@link defineTool} and
949
+ * {@link definePlugin} (Inviolable Rule 9 — every agentic capability ships as a
950
+ * factory function).
951
+ *
952
+ * A {@link ProviderProfile} is data-only: it declares the provider name, the
953
+ * HTTP dialect (`apiMode`), auth, base URL and fallback models. The transport
954
+ * is selected from `apiMode` by the router, so any OpenAI-/Anthropic-compatible
955
+ * endpoint (Groq, Together, Fireworks, a private gateway) is expressible as a
956
+ * profile with no new code.
957
+ *
958
+ * Pass the result to `Agent.create({ plugins: [...] })` and route to it with
959
+ * the `provider/model` id prefix or `providers.routes`:
960
+ *
961
+ * ```ts
962
+ * const groq = defineProvider({
963
+ * name: "groq",
964
+ * apiMode: "chat_completions",
965
+ * authType: "api_key",
966
+ * envVars: ["GROQ_API_KEY"],
967
+ * baseUrl: "https://api.groq.com/openai/v1",
968
+ * fallbackModels: ["groq/llama-3.1-8b-instant"],
969
+ * });
970
+ * const agent = await Agent.create({
971
+ * model: { id: "groq/llama-3.1-8b-instant" },
972
+ * plugins: [groq],
973
+ * });
974
+ * ```
975
+ *
976
+ * @public
977
+ */
978
+ declare function defineProvider(profile: ProviderProfile, opts?: DefineProviderOptions): Plugin;
979
+
824
980
  /**
825
981
  * Spec accepted by {@link defineTool}. `inputSchema` is a Zod schema; the
826
982
  * `handler` argument type is inferred via `z.infer<T>` — no `as` casts.
@@ -943,120 +1099,6 @@ declare class InMemoryConversationStorage implements ConversationStorageAdapter
943
1099
 
944
1100
  declare function withCwdMutex<T>(key: string, fn: () => Promise<T>): Promise<T>;
945
1101
 
946
- /**
947
- * ProviderProfile + ApiMode types (T3.1, ADR D105).
948
- *
949
- * Profile is **data-only** — no methods. Adding a provider is declaring an
950
- * object literal; the Transport layer (D106) consumes `apiMode` to pick
951
- * the HTTP dialect.
952
- *
953
- * @public
954
- */
955
- type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
956
- type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
957
- interface ProviderProfile {
958
- name: string;
959
- apiMode: ApiMode;
960
- aliases?: ReadonlyArray<string>;
961
- displayName?: string;
962
- description?: string;
963
- signupUrl?: string;
964
- envVars: ReadonlyArray<string>;
965
- authType: AuthType;
966
- baseUrl: string;
967
- modelsUrl?: string;
968
- hostname?: string;
969
- fallbackModels: ReadonlyArray<string>;
970
- extraHeaders?: Record<string, string>;
971
- bodyOverrides?: Record<string, unknown>;
972
- }
973
-
974
- type HookName = "pre_tool_call" | "post_tool_call" | "pre_llm_call" | "post_llm_call" | "on_session_start" | "on_session_end" | "transform_tool_result" | "transform_llm_output" | "pre_user_send" | "post_assistant_reply";
975
- interface PreToolCallContext {
976
- name: string;
977
- args: Record<string, unknown>;
978
- agentId: string;
979
- runId: string;
980
- }
981
- interface PreToolCallDecision {
982
- block: true;
983
- message: string;
984
- }
985
- /**
986
- * Context passed to `pre_user_send` hook handlers (ADR D145).
987
- *
988
- * @public
989
- */
990
- interface PreUserSendContext {
991
- prompt: string;
992
- agentId: string;
993
- runId: string;
994
- /** Caller-supplied memory context, flowing through from `AgentOptions.memoryContext`. */
995
- memoryContext?: MemoryContext;
996
- /** Forwarded `AbortSignal` so adapter recall HTTP can be cancelled mid-flight (EC-H). */
997
- signal?: AbortSignal;
998
- }
999
- /**
1000
- * Optional result returned by `pre_user_send` handlers. The agent loop
1001
- * concatenates `recalledContext` from all handlers and injects it as a
1002
- * `<memory-context>...</memory-context>` block before the user prompt.
1003
- *
1004
- * @public
1005
- */
1006
- interface PreUserSendResult {
1007
- recalledContext?: string;
1008
- }
1009
- /**
1010
- * Context passed to `post_assistant_reply` hook handlers (ADR D145).
1011
- * Fire-and-forget — exceptions are caught and surfaced to stderr; the
1012
- * caller's `wait()` never blocks on this dispatch.
1013
- *
1014
- * @public
1015
- */
1016
- interface PostAssistantReplyContext {
1017
- prompt: string;
1018
- reply: string;
1019
- agentId: string;
1020
- runId: string;
1021
- memoryContext?: MemoryContext;
1022
- }
1023
- type HookHandler = (ctx: unknown) => unknown | Promise<unknown>;
1024
- type CommandHandler = (args: Record<string, unknown>) => Promise<string> | string;
1025
- interface CommandOptions {
1026
- description?: string;
1027
- }
1028
- interface PluginContext {
1029
- /** Register a custom tool. Equivalent to passing in `AgentOptions.tools`. */
1030
- registerTool(tool: CustomTool): void;
1031
- /** Register a slash-command-style handler. Consumed by CLI/bot wrappers; NOT used by the agent loop. */
1032
- registerCommand(name: string, handler: CommandHandler, opts?: CommandOptions): void;
1033
- /** Attach a hook handler. `pre_tool_call` supports veto via `PreToolCallDecision`. */
1034
- on(hook: HookName, handler: HookHandler): void;
1035
- /** Inject a user/system message into the next agent turn. v1 supports only `on_session_start` context. */
1036
- injectMessage(content: string, role?: "user" | "system"): void;
1037
- }
1038
- interface BasePlugin {
1039
- name: string;
1040
- version: string;
1041
- }
1042
- type Plugin = (BasePlugin & {
1043
- kind: "general";
1044
- register: (ctx: PluginContext) => void | Promise<void>;
1045
- }) | (BasePlugin & {
1046
- kind: "model-provider";
1047
- profile: ProviderProfile;
1048
- }) | (BasePlugin & {
1049
- kind: "memory";
1050
- createProvider: MemoryProviderFactory;
1051
- });
1052
- /**
1053
- * Identity helper for plugin authors. TS-only convenience — preserves
1054
- * inferred type without forcing manual `Plugin` annotation.
1055
- *
1056
- * @public
1057
- */
1058
- declare function definePlugin<P extends Plugin>(p: P): P;
1059
-
1060
1102
  /**
1061
1103
  * Reference `BudgetTracker` impl — pure token + iteration counter
1062
1104
  * (SDK 2.0 Phase 2 / T2.1 — ADR D1 reference implementation).
@@ -2066,4 +2108,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2066
2108
  model?: string;
2067
2109
  }): ShareGptTrajectory | null;
2068
2110
 
2069
- export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
2111
+ export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };