@theokit/sdk 2.18.1 → 2.20.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/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-1tVcX3Fq.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-1tVcX3Fq.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, n as ConversationStorageAdapter, o as StoredMessage, B as BudgetTracker, p as MemoryProvider, q as MemoryId, r as PreToolCallDecision, s as SDKProvider } from './cron-ZLSKbDbB.cjs';
4
- export { t as ActiveMemoryPassArgs, u as ActiveMemoryPassResult, v as AgentMemory, w as BudgetCheck, x as BudgetTotal, y as BudgetUsageEvent, z as CloudEnv, D as CloudRepo, E as ContextBudget, F as ContextManagerKind, H as ContextSnapshot, I as ContextSource, J as ContextSourceStatus, K as Cron, N as CronCreateOptions, O as CronGetOptions, Q as CronJob, R as CronJobStatus, T as CronListOptions, U as CronOperationOptions, V as CronRunOptions, W as CronRuntime, X as CronSchedulerStatus, Y as CronStartOptions, Z as GoalEvent, _ as GoalOptions, $ as GoalResult, a0 as HookName, a1 as InvalidateCacheOptions, a2 as MemoryAdapter, a3 as MemoryAdapterCapabilities, a4 as MemoryContext, a5 as MemoryFact, a6 as MemoryProviderHandle, a7 as MemoryProviderInitOptions, a8 as MemoryRevision, a9 as MemoryToolSchema, aa as MemoryTurnMessage, ab as PersonalityPreset, ac as PluginContext, ad as PostAssistantReplyContext, ae as PreToolCallContext, af as PreUserSendContext, ag as PreUserSendResult, ah as ProviderCapability, ai as ProviderRoute, aj as RecordSessionSummaryArgs, ak as ResolvedProviderRoute, al as RunUntilIterator, am as SDKAgentPlugins, an as SDKAgentSkills, ao as SDKArtifact, ap as SDKContextManager, aq as SDKPluginMetadata, ar as SDKProvidersManager, as as SettingSource, at as SystemPromptContext, au as SystemPromptMemoryFact, av as SystemPromptSkillRef, aw as TelemetrySettings, ax as definePlugin } from './cron-ZLSKbDbB.cjs';
5
- import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-pE-34AAo.cjs';
6
- export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, D as DoomLoopThresholds, 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 RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, E as SDKThinkingMessage, F as SDKToolUseMessage, G as SDKUserMessage, H as SDKUserMessageEvent, J as SendOptions, K as ShellCommand, L as ShellConversationTurn, N as ShellOutput, O as ShellOutputDeltaUpdate, Q as StepCompletedUpdate, T as StepStartedUpdate, U as StreamToCompletionResult, V as SummaryCompletedUpdate, W as SummaryStartedUpdate, X as SummaryUpdate, Y as TextBlock, Z as TextDeltaUpdate, _ as ThinkingCompletedUpdate, $ as ThinkingDeltaUpdate, a0 as ThinkingMessage, a1 as TokenDeltaUpdate, a2 as TokenUsage, a3 as ToolCall, a4 as ToolCallCompletedUpdate, a5 as ToolCallStartedUpdate, a6 as ToolResult, a7 as ToolResultGuardOptions, a8 as ToolUseBlock, a9 as TurnEndedUpdate, aa as UserMessage, ab as UserMessageAppendedUpdate } from './run-pE-34AAo.cjs';
1
+ import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-CE-lMBi2.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-CE-lMBi2.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, n as ConversationStorageAdapter, o as StoredMessage, B as BudgetTracker, p as MemoryProvider, q as MemoryId, r as PreToolCallDecision, s as SDKProvider } from './cron-B8fqui49.cjs';
4
+ export { t as ActiveMemoryPassArgs, u as ActiveMemoryPassResult, v as AgentMemory, w as BudgetCheck, x as BudgetTotal, y as BudgetUsageEvent, z as CloudEnv, D as CloudRepo, E as ContextBudget, F as ContextManagerKind, H as ContextSnapshot, I as ContextSource, J as ContextSourceStatus, K as CreateSkillSpec, N as Cron, O as CronCreateOptions, Q as CronGetOptions, R as CronJob, T as CronJobStatus, U as CronListOptions, V as CronOperationOptions, W as CronRunOptions, X as CronRuntime, Y as CronSchedulerStatus, Z as CronStartOptions, _ as GoalEvent, $ as GoalOptions, a0 as GoalResult, a1 as HookName, a2 as InlineSkill, a3 as InvalidateCacheOptions, a4 as MemoryAdapter, a5 as MemoryAdapterCapabilities, a6 as MemoryContext, a7 as MemoryFact, a8 as MemoryProviderHandle, a9 as MemoryProviderInitOptions, aa as MemoryRevision, ab as MemoryToolSchema, ac as MemoryTurnMessage, ad as PersonalityPreset, ae as PluginContext, af as PostAssistantReplyContext, ag as PreToolCallContext, ah as PreUserSendContext, ai as PreUserSendResult, aj as ProviderCapability, ak as ProviderRoute, al as RecordSessionSummaryArgs, am as ResolvedProviderRoute, an as RunUntilIterator, ao as SDKAgentPlugins, ap as SDKAgentSkills, aq as SDKArtifact, ar as SDKContextManager, as as SDKPluginMetadata, at as SDKProvidersManager, au as SettingSource, av as SystemPromptContext, aw as SystemPromptMemoryFact, ax as SystemPromptSkillRef, ay as TelemetrySettings, az as createSkill, aA as definePlugin } from './cron-B8fqui49.cjs';
5
+ import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-BgfBWX-z.cjs';
6
+ export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, D as DoomLoopThresholds, 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 RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, E as SDKThinkingMessage, F as SDKToolUseMessage, G as SDKUserMessage, H as SDKUserMessageEvent, J as SendOptions, K as ShellCommand, L as ShellConversationTurn, N as ShellOutput, O as ShellOutputDeltaUpdate, Q as StepCompletedUpdate, T as StepStartedUpdate, U as StreamToCompletionResult, V as SummaryCompletedUpdate, W as SummaryStartedUpdate, X as SummaryUpdate, Y as TextBlock, Z as TextDeltaUpdate, _ as ThinkingCompletedUpdate, $ as ThinkingDeltaUpdate, a0 as ThinkingMessage, a1 as TokenDeltaUpdate, a2 as TokenUsage, a3 as ToolCall, a4 as ToolCallCompletedUpdate, a5 as ToolCallStartedUpdate, a6 as ToolResult, a7 as ToolResultGuardOptions, a8 as ToolUseBlock, a9 as TurnEndedUpdate, aa as UserMessage, ab as UserMessageAppendedUpdate } from './run-BgfBWX-z.cjs';
7
7
  import * as zod from 'zod';
8
8
  import { ZodType, z } from 'zod';
9
9
 
@@ -205,6 +205,13 @@ interface GenerateObjectOptions<T extends ZodType> {
205
205
  systemPrompt?: string;
206
206
  /** Model selection. Required (transient agents need a model). */
207
207
  model: ModelSelection;
208
+ /**
209
+ * M21 — optional separate model for the STRUCTURING step. When set, `model` first produces a
210
+ * free-text reasoned answer to the prompt (phase 1), then `structuringModel` extracts the
211
+ * schema-matched object by calling the `output` tool over that answer (phase 2). Lets a large
212
+ * model reason while a cheap fast model does the extraction. Absent ⇒ today's single-model flow.
213
+ */
214
+ structuringModel?: ModelSelection;
208
215
  /** API key. Falls back to env (THEOKIT_API_KEY etc). */
209
216
  apiKey?: string;
210
217
  /** Local runtime config (cwd, sandbox). Required to keep the transient agent local-only. */
@@ -223,6 +230,17 @@ interface GenerateObjectOptions<T extends ZodType> {
223
230
  * when the right env key is set under a different provider name.
224
231
  */
225
232
  providers?: ProviderRoutingSettings;
233
+ /**
234
+ * What to do when the model's output fails schema validation after all
235
+ * retries are exhausted (M14):
236
+ * - `'throw'` (default) — throw {@link GenerateObjectError} `parse_failed`.
237
+ * - `'return-raw'` — resolve with the raw, UNVALIDATED input the model sent
238
+ * (`object` may not match the schema; inspect `raw` too).
239
+ * - `'return-partial'` — for object schemas, resolve with only the fields that
240
+ * individually validate (best-effort salvage); non-object schemas fall back
241
+ * to raw.
242
+ */
243
+ errorStrategy?: "throw" | "return-partial" | "return-raw";
226
244
  }
227
245
  /**
228
246
  * Successful return from {@link Agent.generateObject}.
@@ -912,6 +930,7 @@ interface DefineToolSpec<T extends ZodType> {
912
930
  */
913
931
  handler: (input: z.infer<T>, ctx?: {
914
932
  signal?: AbortSignal;
933
+ context?: unknown;
915
934
  }) => string | Promise<string>;
916
935
  /**
917
936
  * Sanitize the raw model-emitted args BEFORE schema validation (`@theokit/sdk/sanitize`).
@@ -1472,6 +1491,15 @@ interface PermissionPluginOptions {
1472
1491
  */
1473
1492
  declare function createPermissionPlugin(engine: PermissionEngine, opts?: PermissionPluginOptions): Plugin;
1474
1493
 
1494
+ /** The internal JSON-Schema shape the synthetic `output` tool consumes. */
1495
+ type NormalizedJsonSchema = Record<string, unknown>;
1496
+ /**
1497
+ * Normalize any supported schema to the internal JSON Schema. Async because the Valibot path
1498
+ * dynamically imports its optional converter. Throws a clear, typed-message error for an unsupported
1499
+ * schema or a missing Valibot peer (error-handling.md).
1500
+ */
1501
+ declare function normalizeSchema(schema: unknown): Promise<NormalizedJsonSchema>;
1502
+
1475
1503
  /**
1476
1504
  * Public security namespace (T2.1, ADR D68).
1477
1505
  *
@@ -2202,4 +2230,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2202
2230
  model?: string;
2203
2231
  }): ShareGptTrajectory | null;
2204
2232
 
2205
- 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, InMemoryConversationStorage, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, 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, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
2233
+ 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, InMemoryConversationStorage, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, 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, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-qyVYfk9H.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-qyVYfk9H.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 ProviderProfile, m as Plugin, n as ConversationStorageAdapter, o as StoredMessage, B as BudgetTracker, p as MemoryProvider, q as MemoryId, r as PreToolCallDecision, s as SDKProvider } from './cron-Bbg0mBOv.js';
4
- export { t as ActiveMemoryPassArgs, u as ActiveMemoryPassResult, v as AgentMemory, w as BudgetCheck, x as BudgetTotal, y as BudgetUsageEvent, z as CloudEnv, D as CloudRepo, E as ContextBudget, F as ContextManagerKind, H as ContextSnapshot, I as ContextSource, J as ContextSourceStatus, K as Cron, N as CronCreateOptions, O as CronGetOptions, Q as CronJob, R as CronJobStatus, T as CronListOptions, U as CronOperationOptions, V as CronRunOptions, W as CronRuntime, X as CronSchedulerStatus, Y as CronStartOptions, Z as GoalEvent, _ as GoalOptions, $ as GoalResult, a0 as HookName, a1 as InvalidateCacheOptions, a2 as MemoryAdapter, a3 as MemoryAdapterCapabilities, a4 as MemoryContext, a5 as MemoryFact, a6 as MemoryProviderHandle, a7 as MemoryProviderInitOptions, a8 as MemoryRevision, a9 as MemoryToolSchema, aa as MemoryTurnMessage, ab as PersonalityPreset, ac as PluginContext, ad as PostAssistantReplyContext, ae as PreToolCallContext, af as PreUserSendContext, ag as PreUserSendResult, ah as ProviderCapability, ai as ProviderRoute, aj as RecordSessionSummaryArgs, ak as ResolvedProviderRoute, al as RunUntilIterator, am as SDKAgentPlugins, an as SDKAgentSkills, ao as SDKArtifact, ap as SDKContextManager, aq as SDKPluginMetadata, ar as SDKProvidersManager, as as SettingSource, at as SystemPromptContext, au as SystemPromptMemoryFact, av as SystemPromptSkillRef, aw as TelemetrySettings, ax as definePlugin } from './cron-Bbg0mBOv.js';
5
- import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-pE-34AAo.js';
6
- export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, D as DoomLoopThresholds, 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 RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, E as SDKThinkingMessage, F as SDKToolUseMessage, G as SDKUserMessage, H as SDKUserMessageEvent, J as SendOptions, K as ShellCommand, L as ShellConversationTurn, N as ShellOutput, O as ShellOutputDeltaUpdate, Q as StepCompletedUpdate, T as StepStartedUpdate, U as StreamToCompletionResult, V as SummaryCompletedUpdate, W as SummaryStartedUpdate, X as SummaryUpdate, Y as TextBlock, Z as TextDeltaUpdate, _ as ThinkingCompletedUpdate, $ as ThinkingDeltaUpdate, a0 as ThinkingMessage, a1 as TokenDeltaUpdate, a2 as TokenUsage, a3 as ToolCall, a4 as ToolCallCompletedUpdate, a5 as ToolCallStartedUpdate, a6 as ToolResult, a7 as ToolResultGuardOptions, a8 as ToolUseBlock, a9 as TurnEndedUpdate, aa as UserMessage, ab as UserMessageAppendedUpdate } from './run-pE-34AAo.js';
1
+ import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-5lj1EWgs.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-5lj1EWgs.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 ProviderProfile, m as Plugin, n as ConversationStorageAdapter, o as StoredMessage, B as BudgetTracker, p as MemoryProvider, q as MemoryId, r as PreToolCallDecision, s as SDKProvider } from './cron-D2yLOrk2.js';
4
+ export { t as ActiveMemoryPassArgs, u as ActiveMemoryPassResult, v as AgentMemory, w as BudgetCheck, x as BudgetTotal, y as BudgetUsageEvent, z as CloudEnv, D as CloudRepo, E as ContextBudget, F as ContextManagerKind, H as ContextSnapshot, I as ContextSource, J as ContextSourceStatus, K as CreateSkillSpec, N as Cron, O as CronCreateOptions, Q as CronGetOptions, R as CronJob, T as CronJobStatus, U as CronListOptions, V as CronOperationOptions, W as CronRunOptions, X as CronRuntime, Y as CronSchedulerStatus, Z as CronStartOptions, _ as GoalEvent, $ as GoalOptions, a0 as GoalResult, a1 as HookName, a2 as InlineSkill, a3 as InvalidateCacheOptions, a4 as MemoryAdapter, a5 as MemoryAdapterCapabilities, a6 as MemoryContext, a7 as MemoryFact, a8 as MemoryProviderHandle, a9 as MemoryProviderInitOptions, aa as MemoryRevision, ab as MemoryToolSchema, ac as MemoryTurnMessage, ad as PersonalityPreset, ae as PluginContext, af as PostAssistantReplyContext, ag as PreToolCallContext, ah as PreUserSendContext, ai as PreUserSendResult, aj as ProviderCapability, ak as ProviderRoute, al as RecordSessionSummaryArgs, am as ResolvedProviderRoute, an as RunUntilIterator, ao as SDKAgentPlugins, ap as SDKAgentSkills, aq as SDKArtifact, ar as SDKContextManager, as as SDKPluginMetadata, at as SDKProvidersManager, au as SettingSource, av as SystemPromptContext, aw as SystemPromptMemoryFact, ax as SystemPromptSkillRef, ay as TelemetrySettings, az as createSkill, aA as definePlugin } from './cron-D2yLOrk2.js';
5
+ import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-BgfBWX-z.js';
6
+ export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, D as DoomLoopThresholds, 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 RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, E as SDKThinkingMessage, F as SDKToolUseMessage, G as SDKUserMessage, H as SDKUserMessageEvent, J as SendOptions, K as ShellCommand, L as ShellConversationTurn, N as ShellOutput, O as ShellOutputDeltaUpdate, Q as StepCompletedUpdate, T as StepStartedUpdate, U as StreamToCompletionResult, V as SummaryCompletedUpdate, W as SummaryStartedUpdate, X as SummaryUpdate, Y as TextBlock, Z as TextDeltaUpdate, _ as ThinkingCompletedUpdate, $ as ThinkingDeltaUpdate, a0 as ThinkingMessage, a1 as TokenDeltaUpdate, a2 as TokenUsage, a3 as ToolCall, a4 as ToolCallCompletedUpdate, a5 as ToolCallStartedUpdate, a6 as ToolResult, a7 as ToolResultGuardOptions, a8 as ToolUseBlock, a9 as TurnEndedUpdate, aa as UserMessage, ab as UserMessageAppendedUpdate } from './run-BgfBWX-z.js';
7
7
  import * as zod from 'zod';
8
8
  import { ZodType, z } from 'zod';
9
9
 
@@ -205,6 +205,13 @@ interface GenerateObjectOptions<T extends ZodType> {
205
205
  systemPrompt?: string;
206
206
  /** Model selection. Required (transient agents need a model). */
207
207
  model: ModelSelection;
208
+ /**
209
+ * M21 — optional separate model for the STRUCTURING step. When set, `model` first produces a
210
+ * free-text reasoned answer to the prompt (phase 1), then `structuringModel` extracts the
211
+ * schema-matched object by calling the `output` tool over that answer (phase 2). Lets a large
212
+ * model reason while a cheap fast model does the extraction. Absent ⇒ today's single-model flow.
213
+ */
214
+ structuringModel?: ModelSelection;
208
215
  /** API key. Falls back to env (THEOKIT_API_KEY etc). */
209
216
  apiKey?: string;
210
217
  /** Local runtime config (cwd, sandbox). Required to keep the transient agent local-only. */
@@ -223,6 +230,17 @@ interface GenerateObjectOptions<T extends ZodType> {
223
230
  * when the right env key is set under a different provider name.
224
231
  */
225
232
  providers?: ProviderRoutingSettings;
233
+ /**
234
+ * What to do when the model's output fails schema validation after all
235
+ * retries are exhausted (M14):
236
+ * - `'throw'` (default) — throw {@link GenerateObjectError} `parse_failed`.
237
+ * - `'return-raw'` — resolve with the raw, UNVALIDATED input the model sent
238
+ * (`object` may not match the schema; inspect `raw` too).
239
+ * - `'return-partial'` — for object schemas, resolve with only the fields that
240
+ * individually validate (best-effort salvage); non-object schemas fall back
241
+ * to raw.
242
+ */
243
+ errorStrategy?: "throw" | "return-partial" | "return-raw";
226
244
  }
227
245
  /**
228
246
  * Successful return from {@link Agent.generateObject}.
@@ -912,6 +930,7 @@ interface DefineToolSpec<T extends ZodType> {
912
930
  */
913
931
  handler: (input: z.infer<T>, ctx?: {
914
932
  signal?: AbortSignal;
933
+ context?: unknown;
915
934
  }) => string | Promise<string>;
916
935
  /**
917
936
  * Sanitize the raw model-emitted args BEFORE schema validation (`@theokit/sdk/sanitize`).
@@ -1472,6 +1491,15 @@ interface PermissionPluginOptions {
1472
1491
  */
1473
1492
  declare function createPermissionPlugin(engine: PermissionEngine, opts?: PermissionPluginOptions): Plugin;
1474
1493
 
1494
+ /** The internal JSON-Schema shape the synthetic `output` tool consumes. */
1495
+ type NormalizedJsonSchema = Record<string, unknown>;
1496
+ /**
1497
+ * Normalize any supported schema to the internal JSON Schema. Async because the Valibot path
1498
+ * dynamically imports its optional converter. Throws a clear, typed-message error for an unsupported
1499
+ * schema or a missing Valibot peer (error-handling.md).
1500
+ */
1501
+ declare function normalizeSchema(schema: unknown): Promise<NormalizedJsonSchema>;
1502
+
1475
1503
  /**
1476
1504
  * Public security namespace (T2.1, ADR D68).
1477
1505
  *
@@ -2202,4 +2230,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2202
2230
  model?: string;
2203
2231
  }): ShareGptTrajectory | null;
2204
2232
 
2205
- 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, InMemoryConversationStorage, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, 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, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
2233
+ 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, InMemoryConversationStorage, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, type NormalizedJsonSchema, type PermissionAction, PermissionEngine, type PermissionEngineOptions, type PermissionPluginOptions, type PermissionRule, Plugin, PluginsSettings, PreToolCallDecision, ProviderProfile, ProviderRoutingSettings, type ReplayHistoryOptions, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, 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, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
package/dist/index.js CHANGED
@@ -3797,6 +3797,37 @@ __export(generate_object_exports, {
3797
3797
  GenerateObjectError: () => GenerateObjectError,
3798
3798
  generateObjectImpl: () => generateObjectImpl
3799
3799
  });
3800
+ function salvagePartial(schema, raw) {
3801
+ if (typeof raw !== "object" || raw === null) return raw;
3802
+ const shape = schema.shape;
3803
+ if (shape === void 0 || typeof shape !== "object") return raw;
3804
+ const rawObj = raw;
3805
+ const out = {};
3806
+ for (const [key2, fieldSchema] of Object.entries(shape)) {
3807
+ if (typeof fieldSchema?.safeParse !== "function") continue;
3808
+ const parsed = fieldSchema.safeParse(rawObj[key2]);
3809
+ if (parsed.success) out[key2] = parsed.data;
3810
+ }
3811
+ return out;
3812
+ }
3813
+ async function runReasoningPhase(options, deps) {
3814
+ const reasoningOptions = {
3815
+ model: options.model,
3816
+ local: options.local,
3817
+ ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
3818
+ ...options.apiKey !== void 0 ? { apiKey: options.apiKey } : {},
3819
+ ...options.providers !== void 0 ? { providers: options.providers } : {}
3820
+ };
3821
+ const reasoningAgent = await deps.create(reasoningOptions);
3822
+ try {
3823
+ const run = await reasoningAgent.send(options.prompt);
3824
+ const result = await run.wait();
3825
+ const text = result.result;
3826
+ return typeof text === "string" ? text : options.prompt;
3827
+ } finally {
3828
+ await disposeAndDeleteTransient(reasoningAgent, deps.delete);
3829
+ }
3830
+ }
3800
3831
  async function generateObjectImpl(options, deps) {
3801
3832
  const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
3802
3833
  options.schema,
@@ -3819,8 +3850,11 @@ async function generateObjectImpl(options, deps) {
3819
3850
  }
3820
3851
  throw new CaptureSentinel(input);
3821
3852
  });
3853
+ const reasoningText = options.structuringModel !== void 0 ? await runReasoningPhase(options, deps) : void 0;
3854
+ const structuringModel = options.structuringModel ?? options.model;
3855
+ const structuringPrompt = reasoningText ?? options.prompt;
3822
3856
  const agentOptions = buildTransientAgentOptions({
3823
- model: options.model,
3857
+ model: structuringModel,
3824
3858
  local: options.local,
3825
3859
  outputTool,
3826
3860
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
@@ -3829,7 +3863,7 @@ async function generateObjectImpl(options, deps) {
3829
3863
  });
3830
3864
  const agent = await deps.create(agentOptions);
3831
3865
  try {
3832
- const userMessage = buildToolPrompt(options.prompt);
3866
+ const userMessage = buildToolPrompt(structuringPrompt);
3833
3867
  let lastParseError;
3834
3868
  for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
3835
3869
  capturedRaw = void 0;
@@ -3863,6 +3897,22 @@ async function generateObjectImpl(options, deps) {
3863
3897
  }
3864
3898
  lastParseError = parsed.error;
3865
3899
  }
3900
+ if (options.errorStrategy === "return-raw") {
3901
+ return {
3902
+ object: capturedRaw,
3903
+ raw: capturedRaw,
3904
+ usage: lastUsage,
3905
+ finishReason: "tool_use"
3906
+ };
3907
+ }
3908
+ if (options.errorStrategy === "return-partial") {
3909
+ return {
3910
+ object: salvagePartial(options.schema, capturedRaw),
3911
+ raw: capturedRaw,
3912
+ usage: lastUsage,
3913
+ finishReason: "tool_use"
3914
+ };
3915
+ }
3866
3916
  throw new GenerateObjectError(
3867
3917
  "parse_failed",
3868
3918
  "Schema parse failed after all retries.",
@@ -10771,23 +10821,27 @@ function tryParseSkill(raw, fallbackName, source, options) {
10771
10821
 
10772
10822
  // src/internal/runtime/skills/skills-manager.ts
10773
10823
  var SkillsManager = class {
10774
- constructor(cwd, _enabled, settingSourcesIncludeProject) {
10824
+ constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
10775
10825
  this.cwd = cwd;
10776
10826
  this.settingSourcesIncludeProject = settingSourcesIncludeProject;
10827
+ this.skillsDir = skillsDir;
10828
+ this.inline = inline;
10777
10829
  }
10778
10830
  cwd;
10779
10831
  settingSourcesIncludeProject;
10832
+ skillsDir;
10833
+ inline;
10780
10834
  skills = [];
10781
10835
  async initialize() {
10782
10836
  if (!this.settingSourcesIncludeProject) {
10783
- this.skills = [];
10837
+ this.skills = this.mergeInline([]);
10784
10838
  return;
10785
10839
  }
10786
10840
  await this.refresh();
10787
10841
  }
10788
10842
  async refresh() {
10789
- const skillsRoot = join(this.cwd, ".theokit", "skills");
10790
- this.skills = await discoverSkills(skillsRoot, {
10843
+ const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
10844
+ const discovered = await discoverSkills(skillsRoot, {
10791
10845
  onInvalidSkill: (info) => {
10792
10846
  process.stderr.write(
10793
10847
  `[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
@@ -10795,6 +10849,13 @@ var SkillsManager = class {
10795
10849
  );
10796
10850
  }
10797
10851
  });
10852
+ this.skills = this.mergeInline(discovered);
10853
+ }
10854
+ /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
10855
+ mergeInline(discovered) {
10856
+ if (this.inline === void 0 || this.inline.length === 0) return discovered;
10857
+ const inlineNames = new Set(this.inline.map((s) => s.name));
10858
+ return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
10798
10859
  }
10799
10860
  list() {
10800
10861
  return Promise.resolve(this.skills);
@@ -10839,7 +10900,10 @@ function bootstrapSubmanagers(args) {
10839
10900
  out.skillsManager = new SkillsManager(
10840
10901
  args.workspaceCwd,
10841
10902
  args.options.skills?.enabled,
10842
- args.settingSourcesIncludeProject
10903
+ args.settingSourcesIncludeProject,
10904
+ // M22 — custom skills directory + inline (code-defined) skills.
10905
+ args.options.skills?.skillsDir,
10906
+ args.options.skills?.inline
10843
10907
  );
10844
10908
  const localSkills = out.skillsManager;
10845
10909
  out.skills = { list: () => localSkills.list() };
@@ -11679,22 +11743,23 @@ async function executeTool(inputs, resolved, call) {
11679
11743
  return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
11680
11744
  }
11681
11745
  if (resolved.origin === "shell") return runShellTool(inputs, call);
11682
- if (resolved.origin === "memory") return runMemoryTool(resolved, call);
11683
- if (resolved.origin === "custom") return runCustomTool(resolved, call, inputs.signal);
11746
+ if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
11747
+ if (resolved.origin === "custom")
11748
+ return runCustomTool(resolved, call, inputs.signal, inputs.context);
11684
11749
  return runMcpTool(inputs, resolved, call);
11685
11750
  }
11686
- async function runMemoryTool(resolved, call) {
11687
- return runHandlerTool("memory", resolved.memoryHandler, call);
11751
+ async function runMemoryTool(resolved, call, context) {
11752
+ return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
11688
11753
  }
11689
- async function runCustomTool(resolved, call, signal) {
11690
- return runHandlerTool("custom", resolved.customHandler, call, signal);
11754
+ async function runCustomTool(resolved, call, signal, context) {
11755
+ return runHandlerTool("custom", resolved.customHandler, call, signal, context);
11691
11756
  }
11692
- async function runHandlerTool(kind, handler, call, signal) {
11757
+ async function runHandlerTool(kind, handler, call, signal, context) {
11693
11758
  if (handler === void 0) {
11694
11759
  return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
11695
11760
  }
11696
11761
  try {
11697
- const stdout = await handler(call.input, { signal });
11762
+ const stdout = await handler(call.input, { signal, context });
11698
11763
  return { stdout, stderr: "", exitCode: 0 };
11699
11764
  } catch (cause) {
11700
11765
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -15593,6 +15658,9 @@ function buildLoopInputs(options, runId, userText) {
15593
15658
  // D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
15594
15659
  // can attach it to the LLM `fetch({ signal })` call.
15595
15660
  ...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
15661
+ // M7 — forward SendOptions.context to the loop so every tool handler receives
15662
+ // it on `ctx.context` (shared run config set once, e.g. projectRoot).
15663
+ ...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
15596
15664
  // #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
15597
15665
  // can enable them via SendOptions (not only internal AgentLoopInputs).
15598
15666
  ...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
@@ -18737,6 +18805,20 @@ var Budget = class {
18737
18805
  }
18738
18806
  };
18739
18807
 
18808
+ // src/create-skill.ts
18809
+ function createSkill(spec) {
18810
+ if (!spec.name) throw new Error("createSkill: `name` is required.");
18811
+ if (!spec.description) throw new Error("createSkill: `description` is required.");
18812
+ return {
18813
+ name: spec.name,
18814
+ description: spec.description,
18815
+ source: `inline://${spec.name}`,
18816
+ instructions: spec.instructions,
18817
+ ...spec.category !== void 0 ? { category: spec.category } : {},
18818
+ ...spec.dependencies !== void 0 ? { dependencies: spec.dependencies } : {}
18819
+ };
18820
+ }
18821
+
18740
18822
  // src/cron.ts
18741
18823
  init_errors();
18742
18824
 
@@ -20091,6 +20173,53 @@ function createPermissionPlugin(engine, opts = {}) {
20091
20173
  });
20092
20174
  }
20093
20175
 
20176
+ // src/schema-normalizer.ts
20177
+ init_to_json_schema();
20178
+ function isJsonSchemaObject(s) {
20179
+ if (typeof s !== "object" || s === null) return false;
20180
+ const o = s;
20181
+ if ("$schema" in o) return true;
20182
+ return o.type === "object" && typeof o.properties === "object" && o.properties !== null;
20183
+ }
20184
+ function hasToJsonSchemaMethod(s) {
20185
+ return typeof s === "object" && s !== null && typeof s.toJsonSchema === "function";
20186
+ }
20187
+ function isZodSchema(s) {
20188
+ if (typeof s !== "object" || s === null) return false;
20189
+ const o = s;
20190
+ return typeof o.safeParse === "function" && ("_def" in o || "def" in o);
20191
+ }
20192
+ function isValibotSchema(s) {
20193
+ if (typeof s !== "object" || s === null) return false;
20194
+ const o = s;
20195
+ return o.kind === "schema" && "type" in o && typeof o.toJsonSchema !== "function";
20196
+ }
20197
+ async function normalizeSchema(schema) {
20198
+ if (isJsonSchemaObject(schema)) return schema;
20199
+ if (isValibotSchema(schema)) {
20200
+ const specifier = "@valibot/to-json-schema";
20201
+ try {
20202
+ const mod = await import(specifier);
20203
+ return mod.toJsonSchema(schema);
20204
+ } catch (err) {
20205
+ const missing = err instanceof Error && /Cannot find|Cannot resolve|ERR_MODULE_NOT_FOUND/.test(err.message);
20206
+ if (missing) {
20207
+ throw new Error(
20208
+ "normalizeSchema: a Valibot schema requires the optional '@valibot/to-json-schema' package. Install it, or use a Zod schema (the default recommendation)."
20209
+ );
20210
+ }
20211
+ throw err;
20212
+ }
20213
+ }
20214
+ if (isZodSchema(schema)) {
20215
+ return toJsonSchema(schema, { unrepresentable: "any" });
20216
+ }
20217
+ if (hasToJsonSchemaMethod(schema)) return schema.toJsonSchema();
20218
+ throw new Error(
20219
+ "normalizeSchema: unsupported schema. Supported: Zod (default), JSON Schema, ArkType (.toJsonSchema()), Valibot (with @valibot/to-json-schema)."
20220
+ );
20221
+ }
20222
+
20094
20223
  // src/security.ts
20095
20224
  init_security();
20096
20225
  var Security = class {
@@ -20868,6 +20997,6 @@ function safeStringify2(v) {
20868
20997
  }
20869
20998
  }
20870
20999
 
20871
- export { Agent, AgentBuilder, AgentDisposedError, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, FileSystemConversationStorage, GenerateObjectError, InMemoryConversationStorage, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, PermissionEngine, RateLimitError, Security, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
21000
+ export { Agent, AgentBuilder, AgentDisposedError, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, FileSystemConversationStorage, GenerateObjectError, InMemoryConversationStorage, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, PermissionEngine, RateLimitError, Security, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, buildReplayHistory, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createPermissionPlugin, createSkill, createSquad, definePlugin, defineProvider, defineTool, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
20872
21001
  //# sourceMappingURL=index.js.map
20873
21002
  //# sourceMappingURL=index.js.map