@theokit/sdk 2.29.0 → 3.0.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 (65) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/a2a/index.cjs +8 -1
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.d.cts +1 -1
  5. package/dist/a2a/index.d.ts +1 -1
  6. package/dist/a2a/index.js +8 -1
  7. package/dist/a2a/index.js.map +1 -1
  8. package/dist/a2a/subagent.d.cts +5 -1
  9. package/dist/a2a/subagent.d.ts +5 -1
  10. package/dist/agent-factory.d.ts +5 -20
  11. package/dist/concurrency.cjs +10 -1
  12. package/dist/concurrency.cjs.map +1 -1
  13. package/dist/concurrency.d.cts +7 -1
  14. package/dist/concurrency.d.ts +7 -1
  15. package/dist/concurrency.js +10 -1
  16. package/dist/concurrency.js.map +1 -1
  17. package/dist/create-skill.d.ts +7 -7
  18. package/dist/{cron-COSAehOL.d.ts → cron-BLRe166v.d.ts} +392 -31
  19. package/dist/{cron-yJoNUZxe.d.cts → cron-C2jWAvlQ.d.cts} +392 -31
  20. package/dist/cron.cjs +89 -44
  21. package/dist/cron.cjs.map +1 -1
  22. package/dist/cron.d.cts +2 -2
  23. package/dist/cron.d.ts +2 -2
  24. package/dist/cron.js +89 -44
  25. package/dist/cron.js.map +1 -1
  26. package/dist/define-tool.d.ts +12 -1
  27. package/dist/{errors-tP-8O-hR.d.cts → errors-DZpCGlYv.d.cts} +1 -1
  28. package/dist/{errors-BxMIlgLP.d.ts → errors-D_Bfo30u.d.ts} +1 -1
  29. package/dist/errors.d.cts +2 -2
  30. package/dist/index.cjs +179 -56
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +64 -246
  33. package/dist/index.d.ts +64 -246
  34. package/dist/index.js +168 -45
  35. package/dist/index.js.map +1 -1
  36. package/dist/internal/plugins/index.d.cts +1 -1
  37. package/dist/internal/plugins/index.d.ts +1 -1
  38. package/dist/internal/plugins/types.d.cts +4 -0
  39. package/dist/internal/plugins/types.d.ts +4 -0
  40. package/dist/retry.cjs +10 -1
  41. package/dist/retry.cjs.map +1 -1
  42. package/dist/retry.d.cts +12 -1
  43. package/dist/retry.d.ts +12 -1
  44. package/dist/retry.js +10 -1
  45. package/dist/retry.js.map +1 -1
  46. package/dist/{run-q_P0vHlY.d.cts → run-CLXKMRgq.d.cts} +1 -1
  47. package/dist/{run-q_P0vHlY.d.ts → run-CLXKMRgq.d.ts} +1 -1
  48. package/dist/server/auth/index.cjs +8 -1
  49. package/dist/server/auth/index.cjs.map +1 -1
  50. package/dist/server/auth/index.d.cts +1 -1
  51. package/dist/server/auth/index.d.ts +1 -1
  52. package/dist/server/auth/index.js +8 -1
  53. package/dist/server/auth/index.js.map +1 -1
  54. package/dist/server/auth/orchestrator.d.cts +5 -1
  55. package/dist/server/auth/orchestrator.d.ts +5 -1
  56. package/dist/subscription/define-subscription.d.cts +5 -0
  57. package/dist/subscription/define-subscription.d.ts +5 -0
  58. package/dist/subscription/index.cjs +8 -1
  59. package/dist/subscription/index.cjs.map +1 -1
  60. package/dist/subscription/index.d.cts +1 -1
  61. package/dist/subscription/index.d.ts +1 -1
  62. package/dist/subscription/index.js +8 -1
  63. package/dist/subscription/index.js.map +1 -1
  64. package/dist/types/cron.d.ts +30 -13
  65. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-tP-8O-hR.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, m as ErrorCode, 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-tP-8O-hR.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 ProviderProfile, m as Plugin, I as InlineSkill, n as ConversationStorageAdapter, o as StoredMessage, p as SessionMeta, q as SessionMetaPatch, O as ObjectiveRecord, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as SDKProvider } from './cron-yJoNUZxe.cjs';
4
- export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentGoalConfig, y as AgentMemory, z as BudgetCheck, D as BudgetTotal, E as BudgetUsageEvent, F as CloudEnv, H as CloudRepo, J as ContextBudget, K as ContextManagerKind, N as ContextSnapshot, Q as ContextSource, R as ContextSourceStatus, T as CreateSkillSpec, U as Cron, V as CronCreateOptions, W as CronGetOptions, X as CronJob, Y as CronJobStatus, Z as CronListOptions, _ as CronOperationOptions, $ as CronRunOptions, a0 as CronRuntime, a1 as CronSchedulerStatus, a2 as CronStartOptions, a3 as DurableGoalOptions, a4 as GoalEvent, a5 as GoalOptions, a6 as GoalResult, a7 as HookName, a8 as InvalidateCacheOptions, a9 as MemoryAdapter, aa as MemoryAdapterCapabilities, ab as MemoryContext, ac as MemoryFact, ad as MemoryProviderHandle, ae as MemoryProviderInitOptions, af as MemoryRevision, ag as MemoryToolSchema, ah as MemoryTurnMessage, ai as ObjectiveStatus, aj as PersonalityPreset, ak as PluginContext, al as PostAssistantReplyContext, am as PreToolCallContext, an as PreUserSendContext, ao as PreUserSendResult, ap as ProviderCapability, aq as ProviderRoute, ar as RecordSessionSummaryArgs, as as ResolvedProviderRoute, at as RunUntilIterator, au as SDKAgentPlugins, av as SDKAgentSkillDetail, aw as SDKAgentSkills, ax as SDKArtifact, ay as SDKContextManager, az as SDKPluginMetadata, aA as SDKProvidersManager, aB as SettingSource, aC as SkillsResolver, aD as SkillsResolverContext, aE as SystemPromptContext, aF as SystemPromptMemoryFact, aG as SystemPromptSkillRef, aH as TelemetrySettings, aI as createSkill, aJ as definePlugin } from './cron-yJoNUZxe.cjs';
5
- import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, S as SDKMessage, c as MessageOrigin } from './run-q_P0vHlY.cjs';
6
- export { A as AgentConversationTurn, d as AssistantMessage, e as CompletionCheck, f as CompletionCheckResult, g as ConversationStep, h as ConversationTurn, i as CostBreakdown, j as CostSource, k as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, l as GenerateRunResult, I as ImageBlock, m as InputProcessorContext, n as InteractionUpdate, o as McpAuthConfig, p as McpHttpServerConfig, q as McpOAuthConfig, r as McpStdioServerConfig, s as ModelParameterValue, O as OutputProcessorContext, t as PartialToolCallUpdate, u as ProcessorControls, v as ProcessorTripwire, w as ProcessorViolation, x as RunCompactBoundaryEvent, y as RunCompletionCheckEvent, z as RunErrorDetail, B as RunEvent, E as RunEventSink, F as RunGitInfo, H as RunOperation, J as RunPermissionDeniedEvent, K as RunRateLimitEvent, L as RunStatus, N as RunTaskCompletedEvent, Q as RunTaskStartedEvent, U as RunTaskUpdatedEvent, V as RunToCompletionOptions, W as RunToCompletionResult, X as RunToolProgressEvent, Y as RunTripwireEvent, Z as SDKAssistantMessage, _ as SDKImage, $ as SDKImageDimension, a0 as SDKObjectDelta, a1 as SDKRequestMessage, a2 as SDKStatusMessage, a3 as SDKSystemMessage, a4 as SDKTaskMessage, a5 as SDKThinkingMessage, a6 as SDKToolUseMessage, a7 as SDKUserMessage, a8 as SDKUserMessageEvent, a9 as SendOptions, aa as ShellCommand, ab as ShellConversationTurn, ac as ShellOutput, ad as ShellOutputDeltaUpdate, ae as StepCompletedUpdate, af as StepStartedUpdate, ag as StreamToCompletionResult, ah as SummaryCompletedUpdate, ai as SummaryStartedUpdate, aj as SummaryUpdate, ak as TextBlock, al as TextDeltaUpdate, am as ThinkingCompletedUpdate, an as ThinkingDeltaUpdate, ao as ThinkingMessage, ap as TokenDeltaUpdate, aq as TokenUsage, ar as ToolCall, as as ToolCallCompletedUpdate, at as ToolCallStartedUpdate, au as ToolContextMessage, av as ToolResult, aw as ToolResultGuardOptions, ax as ToolUseBlock, ay as TurnEndedUpdate, az as UserMessage, aA as UserMessageAppendedUpdate, aB as emitRunEvent } from './run-q_P0vHlY.cjs';
1
+ import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-DZpCGlYv.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, m as ErrorCode, 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-DZpCGlYv.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 ProviderProfile, m as Plugin, I as InlineSkill, n as ConversationStorageAdapter, o as StoredMessage, p as SessionMeta, q as SessionMetaPatch, O as ObjectiveRecord, B as BudgetTracker, r as MemoryProvider, s as MemoryId, t as PreToolCallDecision, u as StepResult, v as SDKProvider } from './cron-C2jWAvlQ.cjs';
4
+ export { w as ActiveMemoryPassArgs, x as ActiveMemoryPassResult, y as AgentGoalConfig, z as AgentMemory, D as BudgetCheck, E as BudgetTotal, F as BudgetUsageEvent, H as CloudEnv, J as CloudRepo, K as ContextBudget, N as ContextManagerKind, Q as ContextSnapshot, R as ContextSource, T as ContextSourceStatus, U as CreateSkillSpec, V as Cron, W as CronCreateOptions, X as CronGetOptions, Y as CronJob, Z as CronJobStatus, _ as CronListOptions, $ as CronOperationOptions, a0 as CronRunOptions, a1 as CronRuntime, a2 as CronSchedulerStatus, a3 as CronStartOptions, a4 as DurableGoalOptions, a5 as GoalEvent, a6 as GoalOptions, a7 as GoalResult, a8 as HookName, a9 as InvalidateCacheOptions, aa as MemoryAdapter, ab as MemoryAdapterCapabilities, ac as MemoryContext, ad as MemoryFact, ae as MemoryProviderHandle, af as MemoryProviderInitOptions, ag as MemoryRevision, ah as MemoryToolSchema, ai as MemoryTurnMessage, aj as ObjectiveStatus, ak as PersonalityPreset, al as PluginContext, am as PostAssistantReplyContext, an as PreToolCallContext, ao as PreUserSendContext, ap as PreUserSendResult, aq as ProviderCapability, ar as ProviderRoute, as as RecordSessionSummaryArgs, at as ResolvedProviderRoute, au as RunUntilIterator, av as SDKAgentPlugins, aw as SDKAgentSkillDetail, ax as SDKAgentSkills, ay as SDKArtifact, az as SDKContextManager, aA as SDKPluginMetadata, aB as SDKProvidersManager, aC as SettingSource, aD as Skill, aE as SkillsResolver, aF as SkillsResolverContext, aG as SystemPromptContext, aH as SystemPromptMemoryFact, aI as SystemPromptSkillRef, aJ as TelemetrySettings } from './cron-C2jWAvlQ.cjs';
5
+ import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, S as SDKMessage } from './run-CLXKMRgq.cjs';
6
+ export { A as AgentConversationTurn, c as AssistantMessage, d as CompletionCheck, e as CompletionCheckResult, f as ConversationStep, g as ConversationTurn, h as CostBreakdown, i as CostSource, j as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, k as GenerateRunResult, I as ImageBlock, l as InputProcessorContext, m as InteractionUpdate, n as McpAuthConfig, o as McpHttpServerConfig, p as McpOAuthConfig, q as McpStdioServerConfig, r as MessageOrigin, s as ModelParameterValue, O as OutputProcessorContext, t as PartialToolCallUpdate, u as ProcessorControls, v as ProcessorTripwire, w as ProcessorViolation, x as RunCompactBoundaryEvent, y as RunCompletionCheckEvent, z as RunErrorDetail, B as RunEvent, E as RunEventSink, F as RunGitInfo, H as RunOperation, J as RunPermissionDeniedEvent, K as RunRateLimitEvent, L as RunStatus, N as RunTaskCompletedEvent, Q as RunTaskStartedEvent, U as RunTaskUpdatedEvent, V as RunToCompletionOptions, W as RunToCompletionResult, X as RunToolProgressEvent, Y as RunTripwireEvent, Z as SDKAssistantMessage, _ as SDKImage, $ as SDKImageDimension, a0 as SDKObjectDelta, a1 as SDKRequestMessage, a2 as SDKStatusMessage, a3 as SDKSystemMessage, a4 as SDKTaskMessage, a5 as SDKThinkingMessage, a6 as SDKToolUseMessage, a7 as SDKUserMessage, a8 as SDKUserMessageEvent, a9 as SendOptions, aa as ShellCommand, ab as ShellConversationTurn, ac as ShellOutput, ad as ShellOutputDeltaUpdate, ae as StepCompletedUpdate, af as StepStartedUpdate, ag as StreamToCompletionResult, ah as SummaryCompletedUpdate, ai as SummaryStartedUpdate, aj as SummaryUpdate, ak as TextBlock, al as TextDeltaUpdate, am as ThinkingCompletedUpdate, an as ThinkingDeltaUpdate, ao as ThinkingMessage, ap as TokenDeltaUpdate, aq as TokenUsage, ar as ToolCall, as as ToolCallCompletedUpdate, at as ToolCallStartedUpdate, au as ToolContextMessage, av as ToolResult, aw as ToolResultGuardOptions, ax as ToolUseBlock, ay as TurnEndedUpdate, az as UserMessage, aA as UserMessageAppendedUpdate, aB as emitRunEvent } from './run-CLXKMRgq.cjs';
7
7
  import * as zod from 'zod';
8
8
  import { ZodType, z } from 'zod';
9
9
 
@@ -601,26 +601,11 @@ interface AgentFactory {
601
601
  */
602
602
  getOrCreate(agentId: string, overrides?: Partial<AgentOptions>): Promise<SDKAgent>;
603
603
  }
604
- /**
605
- * Capture a common {@link AgentOptions} prefix and produce per-session agents
606
- * with focused overrides. Useful for chat-bot patterns where most config is
607
- * shared across users/sessions.
608
- *
609
- * Merge rules (ADR D23):
610
- * - Top-level shallow merge with `overrides` winning.
611
- * - Deep merge for `local`, `memory`, `cloud` (configuration objects with
612
- * non-conflicting flat keys).
613
- * - Total replace for `mcpServers`, `agents`, `tools`, `providers`,
614
- * `plugins`, `skills`, `context` (collection-shaped).
615
- * - The function-level `agentId` always wins over both `common.agentId` and
616
- * `overrides.agentId`.
617
- *
618
- * The factory holds `common` by reference — mutating it after construction
619
- * leaks to subsequent `forSession` calls (documented caveat).
620
- *
621
- * @public
622
- */
623
- declare function createAgentFactory(common: Partial<AgentOptions>): AgentFactory;
604
+ /** SE36 — `AgentFactory.create` replaces `createAgentFactory` (ADR 0015). Merges with the `AgentFactory` interface. @public */
605
+ declare class AgentFactory {
606
+ private constructor();
607
+ static create(common: Partial<AgentOptions>): AgentFactory;
608
+ }
624
609
 
625
610
  /**
626
611
  * computeCost — apply pricing entries to a TokenUsage and produce a
@@ -865,15 +850,6 @@ interface UnicodeNormalizerOptions {
865
850
  /** Collapse runs of intra-line whitespace to one space, 3+ blank lines to one, and trim. Default `false`. Uses legacy `\s`; Unicode-only whitespace (U+00A0 NBSP, U+FEFF BOM, U+2000–U+200A) is NOT collapsed. */
866
851
  collapseWhitespace?: boolean;
867
852
  }
868
- /**
869
- * SE25 — an input processor that normalizes user text: Unicode NFC (so
870
- * canonically-equivalent sequences compare equal) plus optional control-char
871
- * stripping and whitespace collapsing. Pure + deterministic; no LLM. Mirrors
872
- * Mastra's `UnicodeNormalizer`.
873
- *
874
- * @public
875
- */
876
- declare function createUnicodeNormalizer(opts?: UnicodeNormalizerOptions): Processor;
877
853
  /** Options for {@link createTokenLimiter}. @public */
878
854
  interface TokenLimiterOptions {
879
855
  /** Positive integer token budget (estimate — see {@link estimateTokens}). */
@@ -881,15 +857,16 @@ interface TokenLimiterOptions {
881
857
  /** Over the limit: `"truncate"` (default, cut to fit) or `"block"` (abort with a tripwire). */
882
858
  strategy?: "truncate" | "block";
883
859
  }
884
- /**
885
- * SE25 — a processor that caps text to a token budget. Placed in
886
- * `inputProcessors` it limits the prompt; in `outputProcessors` it limits the
887
- * response. Uses a char-based estimate (no tokenizer dep). `truncate` cuts to
888
- * fit; `block` aborts (tripwire). Mirrors Mastra's `TokenLimiterProcessor`.
889
- *
890
- * @public
891
- */
892
- declare function createTokenLimiter(opts: TokenLimiterOptions): Processor;
860
+ /** SE36 — `TokenLimiter.create` replaces `createTokenLimiter` (ADR 0015). @public */
861
+ declare class TokenLimiter {
862
+ private constructor();
863
+ static create(opts: TokenLimiterOptions): Processor;
864
+ }
865
+ /** SE36 — `UnicodeNormalizer.create` replaces `createUnicodeNormalizer` (ADR 0015). @public */
866
+ declare class UnicodeNormalizer {
867
+ private constructor();
868
+ static create(opts?: UnicodeNormalizerOptions): Processor;
869
+ }
893
870
 
894
871
  /**
895
872
  * Options for {@link defineProvider}.
@@ -900,38 +877,11 @@ interface DefineProviderOptions {
900
877
  /** Plugin version surfaced in diagnostics. Default `"1.0.0"`. */
901
878
  version?: string;
902
879
  }
903
- /**
904
- * Canonical factory for a custom LLM provider, mirroring {@link defineTool} and
905
- * {@link definePlugin} (Inviolable Rule 9 — every agentic capability ships as a
906
- * factory function).
907
- *
908
- * A {@link ProviderProfile} is data-only: it declares the provider name, the
909
- * HTTP dialect (`apiMode`), auth, base URL and fallback models. The transport
910
- * is selected from `apiMode` by the router, so any OpenAI-/Anthropic-compatible
911
- * endpoint (Groq, Together, Fireworks, a private gateway) is expressible as a
912
- * profile with no new code.
913
- *
914
- * Pass the result to `Agent.create({ plugins: [...] })` and route to it with
915
- * the `provider/model` id prefix or `providers.routes`:
916
- *
917
- * ```ts
918
- * const groq = defineProvider({
919
- * name: "groq",
920
- * apiMode: "chat_completions",
921
- * authType: "api_key",
922
- * envVars: ["GROQ_API_KEY"],
923
- * baseUrl: "https://api.groq.com/openai/v1",
924
- * fallbackModels: ["groq/llama-3.1-8b-instant"],
925
- * });
926
- * const agent = await Agent.create({
927
- * model: { id: "groq/llama-3.1-8b-instant" },
928
- * plugins: [groq],
929
- * });
930
- * ```
931
- *
932
- * @public
933
- */
934
- declare function defineProvider(profile: ProviderProfile, opts?: DefineProviderOptions): Plugin;
880
+ /** SE36 — uniform namespace API. `Provider.create` replaces `defineProvider` (ADR 0015). @public */
881
+ declare class Provider {
882
+ private constructor();
883
+ static create(profile: ProviderProfile, opts?: DefineProviderOptions): Plugin;
884
+ }
935
885
 
936
886
  /**
937
887
  * SE23 — `defineSkillReadTool`: an OPT-IN factory that gives the MODEL on-demand
@@ -956,19 +906,11 @@ declare function defineProvider(profile: ProviderProfile, opts?: DefineProviderO
956
906
  * @public
957
907
  */
958
908
 
959
- /**
960
- * SE23 — build an OPT-IN `skill_read` {@link CustomTool} over the given inline
961
- * skills. When the model calls it with `{ name }`, the handler returns that
962
- * skill's body + references. An UNKNOWN (but well-formed) name returns a typed
963
- * "not found" string the model can act on — NOT a throw that kills the run.
964
- * Malformed input (missing `name`) fails at the trust boundary via the schema.
965
- *
966
- * The consumer controls exposure by choosing which skills to pass; the SDK
967
- * never auto-injects this tool.
968
- *
969
- * @public
970
- */
971
- declare function defineSkillReadTool(skills: ReadonlyArray<InlineSkill>): CustomTool;
909
+ /** SE36 — `SkillReadTool.create` replaces `defineSkillReadTool` (ADR 0015). @public */
910
+ declare class SkillReadTool {
911
+ private constructor();
912
+ static create(skills: ReadonlyArray<InlineSkill>): CustomTool;
913
+ }
972
914
 
973
915
  /**
974
916
  * Options for {@link sanitizeToolInput}. Trim is the only default-on rung — coercion and JSON
@@ -1056,7 +998,18 @@ interface DefineToolSpec<T extends ZodType, O extends ZodType = never> {
1056
998
  */
1057
999
  sanitize?: boolean | SanitizeOptions;
1058
1000
  }
1059
- declare function defineTool<T extends ZodType, O extends ZodType = never>(spec: DefineToolSpec<T, O>): CustomTool;
1001
+ /**
1002
+ * SE36 — the uniform `X.create()` namespace API. `Tool.create(spec)` is the sole public
1003
+ * constructor for a {@link CustomTool}; it wraps the internal builder so behavior is identical
1004
+ * (ADR 0015). A `private constructor` makes `Tool` a namespace, not an instantiable value —
1005
+ * `new Tool()` is a compile error. Mirrors `Agent.create` / `Cron.create`.
1006
+ *
1007
+ * @public
1008
+ */
1009
+ declare class Tool {
1010
+ private constructor();
1011
+ static create<T extends ZodType, O extends ZodType = never>(spec: DefineToolSpec<T, O>): CustomTool;
1012
+ }
1060
1013
 
1061
1014
  /**
1062
1015
  * `EventBus` — typed EventEmitter wrapper.
@@ -1274,13 +1227,11 @@ declare function buildReplayHistory(base: readonly StoredMessage[], events: read
1274
1227
  * @public — surface-level reference impl.
1275
1228
  */
1276
1229
 
1277
- /**
1278
- * Build a fresh no-op MemoryProvider. The returned object is independent —
1279
- * call `createNoopMemoryProvider()` per Agent instance. `init()` is
1280
- * idempotent: subsequent calls return a NEW handle (no per-agent cache —
1281
- * the no-op has no state worth caching).
1282
- */
1283
- declare function createNoopMemoryProvider(): MemoryProvider;
1230
+ /** SE36 — `NoopMemoryProvider.create` replaces `createNoopMemoryProvider` (ADR 0015). @public */
1231
+ declare class NoopMemoryProvider {
1232
+ private constructor();
1233
+ static create(): MemoryProvider;
1234
+ }
1284
1235
 
1285
1236
  /**
1286
1237
  * `JobQueue` — background job queue with status tracking, cancellation, and an
@@ -1669,12 +1620,11 @@ interface PermissionPluginOptions {
1669
1620
  */
1670
1621
  readonly onAsk?: (toolName: string) => PreToolCallDecision | undefined;
1671
1622
  }
1672
- /**
1673
- * Build a `general` plugin that vetoes tool calls per the engine's verdict, under
1674
- * the configured {@link PermissionMode}, resolving `ask` via the {@link canUseTool}
1675
- * gate. Register it on an agent's plugin manager (same as the ACP permission plugin).
1676
- */
1677
- declare function createPermissionPlugin(engine: PermissionEngine, opts?: PermissionPluginOptions): Plugin;
1623
+ /** SE36 — `PermissionPlugin.create` replaces `createPermissionPlugin` (ADR 0015). @public */
1624
+ declare class PermissionPlugin {
1625
+ private constructor();
1626
+ static create(engine: PermissionEngine, opts?: PermissionPluginOptions): Plugin;
1627
+ }
1678
1628
 
1679
1629
  /** The internal JSON-Schema shape the synthetic `output` tool consumes. */
1680
1630
  type NormalizedJsonSchema = Record<string, unknown>;
@@ -1870,12 +1820,11 @@ interface SessionManager {
1870
1820
  * @public
1871
1821
  */
1872
1822
 
1873
- /**
1874
- * Build a {@link SessionManager} bound to `storage`.
1875
- *
1876
- * @public
1877
- */
1878
- declare function createSessionManager(storage: ConversationStorageAdapter): SessionManager;
1823
+ /** SE36 — `Session.create` replaces `createSessionManager` (ADR 0015). @public */
1824
+ declare class Session {
1825
+ private constructor();
1826
+ static create(storage: ConversationStorageAdapter): SessionManager;
1827
+ }
1879
1828
 
1880
1829
  /**
1881
1830
  * M3 #62 — scoped session state.
@@ -1903,134 +1852,6 @@ declare function scopedConversationId(scope: SessionScope, id: string): string;
1903
1852
  /** M3 #62 — the id prefix (`"<scope>__"`) used to match a scope's conversations. */
1904
1853
  declare function sessionScopePrefix(scope: SessionScope): string;
1905
1854
 
1906
- /**
1907
- * Public type contract for `Workflow.create / .run / .resume` (Adoption
1908
- * Roadmap #5; ADRs D230-D248).
1909
- *
1910
- * Step types form a discriminated union by `kind`. Helper factory functions
1911
- * (`fn()`, `agentStep()`) live in `workflow.ts` and hide the discriminator
1912
- * from end users.
1913
- *
1914
- * @public
1915
- */
1916
-
1917
- type Step = FnStep | AgentStep | ParallelStep | BranchStep | ForeachStep | DowhileStep | SleepStep | SuspendStep;
1918
- /** A pure function step. */
1919
- interface FnStep {
1920
- readonly kind: "fn";
1921
- readonly id: string;
1922
- readonly fn: (input: unknown, ctx: StepContext) => Promise<unknown> | unknown;
1923
- readonly inputSchema?: ZodType;
1924
- readonly outputSchema?: ZodType;
1925
- readonly retry?: RetryPolicy;
1926
- /** D238 — slot reserved; runtime throws if engine not yet implemented. */
1927
- readonly compensate?: (input: unknown, output: unknown, error: Error) => Promise<void> | void;
1928
- }
1929
- /** An agent.send-driven step. */
1930
- interface AgentStep {
1931
- readonly kind: "agent";
1932
- readonly id: string;
1933
- readonly agent: SDKAgent;
1934
- readonly promptTemplate: string | ((input: unknown) => string);
1935
- readonly retry?: RetryPolicy;
1936
- /**
1937
- * SE3 — provenance stamped onto this step's `agent.send()` (forwarded to
1938
- * `RunResult.origin`). Squad sets `{ kind: "peer", from: "agent-<i-1>" }` on
1939
- * every step after the first so a peer-driven turn is attributable.
1940
- */
1941
- readonly origin?: MessageOrigin;
1942
- }
1943
- /** N concurrent branches, each its own mini-step-list. */
1944
- interface ParallelStep {
1945
- readonly kind: "parallel";
1946
- readonly id: string;
1947
- readonly branches: ReadonlyArray<ReadonlyArray<Step>>;
1948
- readonly concurrency?: number;
1949
- readonly errorPolicy?: "fail-fast" | "collect";
1950
- }
1951
- /** First-match-wins predicates + optional fallback. */
1952
- interface BranchStep {
1953
- readonly kind: "branch";
1954
- readonly id: string;
1955
- readonly predicates: ReadonlyArray<readonly [(input: unknown) => boolean | Promise<boolean>, ReadonlyArray<Step>]>;
1956
- readonly fallback?: ReadonlyArray<Step>;
1957
- }
1958
- /** Map a step over an upstream array output. */
1959
- interface ForeachStep {
1960
- readonly kind: "foreach";
1961
- readonly id: string;
1962
- /** ID of an upstream top-level step whose output is iterable. */
1963
- readonly iterableFrom: string;
1964
- readonly step: Step;
1965
- readonly concurrency?: number;
1966
- }
1967
- /** Loop a step until condFn returns false. */
1968
- interface DowhileStep {
1969
- readonly kind: "dowhile";
1970
- readonly id: string;
1971
- readonly step: Step;
1972
- readonly condFn: (output: unknown, iteration: number) => boolean | Promise<boolean>;
1973
- readonly maxIterations?: number;
1974
- }
1975
- /** Pause for a fixed duration. */
1976
- interface SleepStep {
1977
- readonly kind: "sleep";
1978
- readonly id: string;
1979
- readonly durationMs: number;
1980
- }
1981
- /** Standalone explicit suspend point. */
1982
- interface SuspendStep {
1983
- readonly kind: "suspend";
1984
- readonly id: string;
1985
- readonly payloadSchema?: ZodType;
1986
- }
1987
- /** D237 — retry policy applied per fn/agent step. */
1988
- interface RetryPolicy {
1989
- /** Total attempts (MIN 1, MAX 20). `1` = no retry. */
1990
- readonly maxAttempts: number;
1991
- readonly initialBackoffMs?: number;
1992
- readonly backoffCoefficient?: number;
1993
- readonly maximumBackoffMs?: number;
1994
- readonly nonRetryableErrors?: ReadonlyArray<string>;
1995
- }
1996
- /** D247 — context handed to every step.fn. */
1997
- interface StepContext {
1998
- readonly runId: string;
1999
- readonly signal: AbortSignal;
2000
- readonly log: {
2001
- debug: (msg: string, attrs?: Record<string, unknown>) => void;
2002
- info: (msg: string, attrs?: Record<string, unknown>) => void;
2003
- warn: (msg: string, attrs?: Record<string, unknown>) => void;
2004
- };
2005
- /** Pause the workflow; resume via `Workflow.resume({...})`. */
2006
- readonly suspend: (payload?: unknown) => Promise<never>;
2007
- /**
2008
- * SE29 — the workflow's shared state (from `WorkflowOptions.initialState`,
2009
- * mutated by {@link setState}), visible to every subsequent step in the run.
2010
- * `undefined` when no `initialState`/`setState` has run. Persisted across
2011
- * suspend/resume.
2012
- */
2013
- readonly state: unknown;
2014
- /**
2015
- * SE29 — update the shared state for subsequent steps. Validated against
2016
- * `WorkflowOptions.stateSchema` when set (a mismatch throws
2017
- * {@link WorkflowStateError}, which fails the step/run — Rule 8).
2018
- */
2019
- readonly setState: (next: unknown) => void;
2020
- }
2021
- interface StepResult {
2022
- readonly stepId: string;
2023
- readonly kind: Step["kind"];
2024
- readonly status: "completed" | "failed" | "skipped" | "suspended";
2025
- readonly attempts: number;
2026
- readonly durationMs: number;
2027
- readonly output?: unknown;
2028
- readonly error?: {
2029
- name: string;
2030
- message: string;
2031
- };
2032
- }
2033
-
2034
1855
  /**
2035
1856
  * `createSquad` — a sequential team of agents.
2036
1857
  *
@@ -2084,14 +1905,11 @@ interface Squad {
2084
1905
  /** Run the team over `input`, threading each agent's output to the next. */
2085
1906
  run(input: unknown): Promise<SquadRun>;
2086
1907
  }
2087
- /**
2088
- * Build a sequential agent team. The returned {@link Squad} composes a
2089
- * `Workflow` of `agentStep`s under the hood — all orchestration is delegated
2090
- * to the workflow engine.
2091
- *
2092
- * @public
2093
- */
2094
- declare function createSquad(options: SquadOptions): Squad;
1908
+ /** SE36 — `Squad.create` replaces `createSquad` (ADR 0015). Merges with the `Squad` interface. @public */
1909
+ declare class Squad {
1910
+ private constructor();
1911
+ static create(options: SquadOptions): Squad;
1912
+ }
2095
1913
 
2096
1914
  /**
2097
1915
  * Public type contract for the Task observability registry (ADRs D361-D374).
@@ -2588,4 +2406,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2588
2406
  model?: string;
2589
2407
  }): ShareGptTrajectory | null;
2590
2408
 
2591
- 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, ErrorMetadata, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, InMemoryConversationStorage, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, MessageOrigin, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, ObjectiveRecord, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, type PermissionMode, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, Processor, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, 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, type TokenLimiterOptions, ToolError, ToolResultContentBlock, type UnicodeNormalizerOptions, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSessionManager, createSquad, createTokenLimiter, createUnicodeNormalizer, defineProvider, defineSkillReadTool, defineTool, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
2409
+ export { Agent, AgentBuilder, AgentDefinition, 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, ErrorMetadata, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, InMemoryConversationStorage, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, ObjectiveRecord, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, type PermissionMode, PermissionPlugin, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, Session, type SessionCapabilityResult, type SessionListOptions, type SessionManager, SessionMeta, SessionMetaPatch, type SessionScope, type SessionSummary, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, 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, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, applyMode, buildReplayHistory, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };