@theokit/sdk 2.18.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/a2a/index.cjs +41 -8
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +41 -8
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-Bbg0mBOv.d.ts → cron-Cep07kTz.d.ts} +1 -1
- package/dist/{cron-ZLSKbDbB.d.cts → cron-D_wK1S-0.d.cts} +1 -1
- package/dist/cron.cjs +41 -8
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +41 -8
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +1 -0
- package/dist/{errors-qyVYfk9H.d.ts → errors-5lj1EWgs.d.ts} +1 -1
- package/dist/{errors-1tVcX3Fq.d.cts → errors-CE-lMBi2.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +41 -8
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +41 -8
- package/dist/eval.js.map +1 -1
- package/dist/generate-object.d.ts +11 -0
- package/dist/index.cjs +41 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -6
- package/dist/index.d.ts +18 -6
- package/dist/index.js +41 -8
- package/dist/index.js.map +1 -1
- package/dist/{run-pE-34AAo.d.cts → run-BgfBWX-z.d.cts} +13 -1
- package/dist/{run-pE-34AAo.d.ts → run-BgfBWX-z.d.ts} +13 -1
- package/dist/types/agent-prims.d.ts +4 -1
- package/dist/types/run.d.ts +9 -0
- package/package.json +14 -14
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-
|
|
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-
|
|
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-
|
|
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-
|
|
5
|
-
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-
|
|
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-
|
|
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-D_wK1S-0.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-D_wK1S-0.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
|
|
|
@@ -223,6 +223,17 @@ interface GenerateObjectOptions<T extends ZodType> {
|
|
|
223
223
|
* when the right env key is set under a different provider name.
|
|
224
224
|
*/
|
|
225
225
|
providers?: ProviderRoutingSettings;
|
|
226
|
+
/**
|
|
227
|
+
* What to do when the model's output fails schema validation after all
|
|
228
|
+
* retries are exhausted (M14):
|
|
229
|
+
* - `'throw'` (default) — throw {@link GenerateObjectError} `parse_failed`.
|
|
230
|
+
* - `'return-raw'` — resolve with the raw, UNVALIDATED input the model sent
|
|
231
|
+
* (`object` may not match the schema; inspect `raw` too).
|
|
232
|
+
* - `'return-partial'` — for object schemas, resolve with only the fields that
|
|
233
|
+
* individually validate (best-effort salvage); non-object schemas fall back
|
|
234
|
+
* to raw.
|
|
235
|
+
*/
|
|
236
|
+
errorStrategy?: "throw" | "return-partial" | "return-raw";
|
|
226
237
|
}
|
|
227
238
|
/**
|
|
228
239
|
* Successful return from {@link Agent.generateObject}.
|
|
@@ -912,6 +923,7 @@ interface DefineToolSpec<T extends ZodType> {
|
|
|
912
923
|
*/
|
|
913
924
|
handler: (input: z.infer<T>, ctx?: {
|
|
914
925
|
signal?: AbortSignal;
|
|
926
|
+
context?: unknown;
|
|
915
927
|
}) => string | Promise<string>;
|
|
916
928
|
/**
|
|
917
929
|
* Sanitize the raw model-emitted args BEFORE schema validation (`@theokit/sdk/sanitize`).
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
5
|
-
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-
|
|
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-
|
|
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-Cep07kTz.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-Cep07kTz.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
|
|
|
@@ -223,6 +223,17 @@ interface GenerateObjectOptions<T extends ZodType> {
|
|
|
223
223
|
* when the right env key is set under a different provider name.
|
|
224
224
|
*/
|
|
225
225
|
providers?: ProviderRoutingSettings;
|
|
226
|
+
/**
|
|
227
|
+
* What to do when the model's output fails schema validation after all
|
|
228
|
+
* retries are exhausted (M14):
|
|
229
|
+
* - `'throw'` (default) — throw {@link GenerateObjectError} `parse_failed`.
|
|
230
|
+
* - `'return-raw'` — resolve with the raw, UNVALIDATED input the model sent
|
|
231
|
+
* (`object` may not match the schema; inspect `raw` too).
|
|
232
|
+
* - `'return-partial'` — for object schemas, resolve with only the fields that
|
|
233
|
+
* individually validate (best-effort salvage); non-object schemas fall back
|
|
234
|
+
* to raw.
|
|
235
|
+
*/
|
|
236
|
+
errorStrategy?: "throw" | "return-partial" | "return-raw";
|
|
226
237
|
}
|
|
227
238
|
/**
|
|
228
239
|
* Successful return from {@link Agent.generateObject}.
|
|
@@ -912,6 +923,7 @@ interface DefineToolSpec<T extends ZodType> {
|
|
|
912
923
|
*/
|
|
913
924
|
handler: (input: z.infer<T>, ctx?: {
|
|
914
925
|
signal?: AbortSignal;
|
|
926
|
+
context?: unknown;
|
|
915
927
|
}) => string | Promise<string>;
|
|
916
928
|
/**
|
|
917
929
|
* Sanitize the raw model-emitted args BEFORE schema validation (`@theokit/sdk/sanitize`).
|
package/dist/index.js
CHANGED
|
@@ -3797,6 +3797,19 @@ __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
|
+
}
|
|
3800
3813
|
async function generateObjectImpl(options, deps) {
|
|
3801
3814
|
const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
|
|
3802
3815
|
options.schema,
|
|
@@ -3863,6 +3876,22 @@ async function generateObjectImpl(options, deps) {
|
|
|
3863
3876
|
}
|
|
3864
3877
|
lastParseError = parsed.error;
|
|
3865
3878
|
}
|
|
3879
|
+
if (options.errorStrategy === "return-raw") {
|
|
3880
|
+
return {
|
|
3881
|
+
object: capturedRaw,
|
|
3882
|
+
raw: capturedRaw,
|
|
3883
|
+
usage: lastUsage,
|
|
3884
|
+
finishReason: "tool_use"
|
|
3885
|
+
};
|
|
3886
|
+
}
|
|
3887
|
+
if (options.errorStrategy === "return-partial") {
|
|
3888
|
+
return {
|
|
3889
|
+
object: salvagePartial(options.schema, capturedRaw),
|
|
3890
|
+
raw: capturedRaw,
|
|
3891
|
+
usage: lastUsage,
|
|
3892
|
+
finishReason: "tool_use"
|
|
3893
|
+
};
|
|
3894
|
+
}
|
|
3866
3895
|
throw new GenerateObjectError(
|
|
3867
3896
|
"parse_failed",
|
|
3868
3897
|
"Schema parse failed after all retries.",
|
|
@@ -11679,22 +11708,23 @@ async function executeTool(inputs, resolved, call) {
|
|
|
11679
11708
|
return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
|
|
11680
11709
|
}
|
|
11681
11710
|
if (resolved.origin === "shell") return runShellTool(inputs, call);
|
|
11682
|
-
if (resolved.origin === "memory") return runMemoryTool(resolved, call);
|
|
11683
|
-
if (resolved.origin === "custom")
|
|
11711
|
+
if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
|
|
11712
|
+
if (resolved.origin === "custom")
|
|
11713
|
+
return runCustomTool(resolved, call, inputs.signal, inputs.context);
|
|
11684
11714
|
return runMcpTool(inputs, resolved, call);
|
|
11685
11715
|
}
|
|
11686
|
-
async function runMemoryTool(resolved, call) {
|
|
11687
|
-
return runHandlerTool("memory", resolved.memoryHandler, call);
|
|
11716
|
+
async function runMemoryTool(resolved, call, context) {
|
|
11717
|
+
return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
|
|
11688
11718
|
}
|
|
11689
|
-
async function runCustomTool(resolved, call, signal) {
|
|
11690
|
-
return runHandlerTool("custom", resolved.customHandler, call, signal);
|
|
11719
|
+
async function runCustomTool(resolved, call, signal, context) {
|
|
11720
|
+
return runHandlerTool("custom", resolved.customHandler, call, signal, context);
|
|
11691
11721
|
}
|
|
11692
|
-
async function runHandlerTool(kind, handler, call, signal) {
|
|
11722
|
+
async function runHandlerTool(kind, handler, call, signal, context) {
|
|
11693
11723
|
if (handler === void 0) {
|
|
11694
11724
|
return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
|
|
11695
11725
|
}
|
|
11696
11726
|
try {
|
|
11697
|
-
const stdout = await handler(call.input, { signal });
|
|
11727
|
+
const stdout = await handler(call.input, { signal, context });
|
|
11698
11728
|
return { stdout, stderr: "", exitCode: 0 };
|
|
11699
11729
|
} catch (cause) {
|
|
11700
11730
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -15593,6 +15623,9 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
15593
15623
|
// D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
|
|
15594
15624
|
// can attach it to the LLM `fetch({ signal })` call.
|
|
15595
15625
|
...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
|
|
15626
|
+
// M7 — forward SendOptions.context to the loop so every tool handler receives
|
|
15627
|
+
// it on `ctx.context` (shared run config set once, e.g. projectRoot).
|
|
15628
|
+
...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
|
|
15596
15629
|
// #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
|
|
15597
15630
|
// can enable them via SendOptions (not only internal AgentLoopInputs).
|
|
15598
15631
|
...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
|