@keystrokehq/keystroke 0.1.91 → 0.1.92

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 (27) hide show
  1. package/dist/agent-types.d.cts +2 -2
  2. package/dist/agent-types.d.mts +2 -2
  3. package/dist/agent.cjs +78 -8
  4. package/dist/agent.cjs.map +1 -1
  5. package/dist/agent.d.cts +3 -3
  6. package/dist/agent.d.mts +3 -3
  7. package/dist/agent.mjs +78 -8
  8. package/dist/agent.mjs.map +1 -1
  9. package/dist/{index-BKn5COTH.d.cts → index-BAERW4m3.d.mts} +4 -4
  10. package/dist/{index-BKn5COTH.d.cts.map → index-BAERW4m3.d.mts.map} +1 -1
  11. package/dist/{index-CjWSlYyq.d.mts → index-BNptJCCC.d.mts} +4 -4
  12. package/dist/{index-C61TSfQB.d.cts.map → index-BNptJCCC.d.mts.map} +1 -1
  13. package/dist/{index-DHfxB8DH.d.mts → index-C614Tmd_.d.cts} +4 -4
  14. package/dist/{index-DHfxB8DH.d.mts.map → index-C614Tmd_.d.cts.map} +1 -1
  15. package/dist/{index-skjc11Qf.d.mts → index-CIz44roq.d.mts} +2 -2
  16. package/dist/{index-skjc11Qf.d.mts.map → index-CIz44roq.d.mts.map} +1 -1
  17. package/dist/{index-BowkmvyU.d.cts → index-DFkYFZEw.d.cts} +2 -2
  18. package/dist/{index-BowkmvyU.d.cts.map → index-DFkYFZEw.d.cts.map} +1 -1
  19. package/dist/{index-C61TSfQB.d.cts → index-N9Wzbx7A.d.cts} +4 -4
  20. package/dist/{index-CjWSlYyq.d.mts.map → index-N9Wzbx7A.d.cts.map} +1 -1
  21. package/dist/{schemas-lSbMfQRy-D7NW7SCj.d.mts → schemas-lSbMfQRy-CIfs2xv6.d.mts} +2 -2
  22. package/dist/{schemas-lSbMfQRy-D7NW7SCj.d.mts.map → schemas-lSbMfQRy-CIfs2xv6.d.mts.map} +1 -1
  23. package/dist/{schemas-lSbMfQRy-DdpE4_dC.d.cts → schemas-lSbMfQRy-YsonGA_B.d.cts} +2 -2
  24. package/dist/{schemas-lSbMfQRy-DdpE4_dC.d.cts.map → schemas-lSbMfQRy-YsonGA_B.d.cts.map} +1 -1
  25. package/dist/trigger.d.cts +1 -1
  26. package/dist/trigger.d.mts +1 -1
  27. package/package.json +1 -1
package/dist/agent.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as defineTool, P as modelSupportsMediaType, y as ModelCapabilities } from "./index-dDHyyZ6y.cjs";
2
- import { _ as resolveMaxSteps, a as AgentModelId, c as AgentStreamEvent, d as DEFAULT_THINKING_LEVEL, g as resolveAgentModel, h as parseAgentCreateInput, i as AgentMessage, l as DEFAULT_COMPACTION_MODEL_ID, m as ThinkingLevelSchema, n as AgentCreateInput, o as AgentModelIdSchema, p as ThinkingLevel, r as AgentCreateInputSchema, u as DEFAULT_MAX_STEPS, v as resolveModelCapabilities, y as resolveThinkingLevel } from "./schemas-lSbMfQRy-DdpE4_dC.cjs";
3
- import { a as McpDefinitionInput, c as McpStdioOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpDefinition, l as McpStdioTransport, m as connectMcpStdio, n as McpAuthOptions, o as McpHttpTransport, p as connectMcpServer, r as McpClient, s as McpServerOptions, t as ToolCredentialResolver, u as McpToolConnection } from "./index-BowkmvyU.cjs";
4
- import { A as currentLlmRunContext, B as resolveAgentTools, C as StreamAgentPromptOptions, D as WebToolsOptions, E as UsageSinkEvent, F as isWithinAgentPromptExecution, G as streamAgentPrompt, H as runAgentPrompt, I as normalizeAgentDefinition, J as withLlmRunContext, K as toSubagentTool, L as prepareAgentSession, M as getAgentPromptExecutionContext, N as hydrateChatAttachmentMessages, O as agentModelIdsFromStoredManifest, P as isAgent, R as resolveAgentAssets, S as SessionLifecycleContext, T as UsageSink, U as runDirectAgentPrompt, V as resolveAgentWorkspaceRoot, W as runLlm, _ as ResolvedAgentAssets, a as AgentDefinition, b as SessionAgentMismatchError, c as AgentPromptExecutionContext, d as AgentToolInput, f as BuildAgentRuntimeContext, g as QueuedSubagentToolExecutor, h as PromptResponse, i as AgentChildToolContext, j as defineAgent, k as buildAgentRuntime, l as AgentRunConfig, m as PromptInput, n as Agent, o as AgentDefinitionInput, p as LlmRunContext, q as validateAgentModelIds, r as AgentAssetInput, s as AgentExperimentalDownload, t as AGENT, u as AgentStreamPort, v as RunAgentPromptOptions, w as StreamAgentPromptResult, x as SessionLifecycle, y as SandboxedAgentRuntime, z as resolveAgentId } from "./index-C61TSfQB.cjs";
2
+ import { _ as resolveMaxSteps, a as AgentModelId, c as AgentStreamEvent, d as DEFAULT_THINKING_LEVEL, g as resolveAgentModel, h as parseAgentCreateInput, i as AgentMessage, l as DEFAULT_COMPACTION_MODEL_ID, m as ThinkingLevelSchema, n as AgentCreateInput, o as AgentModelIdSchema, p as ThinkingLevel, r as AgentCreateInputSchema, u as DEFAULT_MAX_STEPS, v as resolveModelCapabilities, y as resolveThinkingLevel } from "./schemas-lSbMfQRy-YsonGA_B.cjs";
3
+ import { a as McpDefinitionInput, c as McpStdioOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpDefinition, l as McpStdioTransport, m as connectMcpStdio, n as McpAuthOptions, o as McpHttpTransport, p as connectMcpServer, r as McpClient, s as McpServerOptions, t as ToolCredentialResolver, u as McpToolConnection } from "./index-DFkYFZEw.cjs";
4
+ import { A as currentLlmRunContext, B as resolveAgentTools, C as StreamAgentPromptOptions, D as WebToolsOptions, E as UsageSinkEvent, F as isWithinAgentPromptExecution, G as streamAgentPrompt, H as runAgentPrompt, I as normalizeAgentDefinition, J as withLlmRunContext, K as toSubagentTool, L as prepareAgentSession, M as getAgentPromptExecutionContext, N as hydrateChatAttachmentMessages, O as agentModelIdsFromStoredManifest, P as isAgent, R as resolveAgentAssets, S as SessionLifecycleContext, T as UsageSink, U as runDirectAgentPrompt, V as resolveAgentWorkspaceRoot, W as runLlm, _ as ResolvedAgentAssets, a as AgentDefinition, b as SessionAgentMismatchError, c as AgentPromptExecutionContext, d as AgentToolInput, f as BuildAgentRuntimeContext, g as QueuedSubagentToolExecutor, h as PromptResponse, i as AgentChildToolContext, j as defineAgent, k as buildAgentRuntime, l as AgentRunConfig, m as PromptInput, n as Agent, o as AgentDefinitionInput, p as LlmRunContext, q as validateAgentModelIds, r as AgentAssetInput, s as AgentExperimentalDownload, t as AGENT, u as AgentStreamPort, v as RunAgentPromptOptions, w as StreamAgentPromptResult, x as SessionLifecycle, y as SandboxedAgentRuntime, z as resolveAgentId } from "./index-N9Wzbx7A.cjs";
5
5
  import { U as loadAssetManifest } from "./index-BiuxubmU.cjs";
6
6
  export { AGENT, type Agent, type AgentAssetInput, type AgentChildToolContext, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentExperimentalDownload, type AgentMessage, type AgentModelId, AgentModelIdSchema, type AgentPromptExecutionContext, type AgentRunConfig, type AgentStreamEvent, type AgentStreamPort, type AgentToolInput, type BuildAgentRuntimeContext, DEFAULT_COMPACTION_MODEL_ID, DEFAULT_MAX_STEPS, DEFAULT_THINKING_LEVEL, type LlmRunContext, type McpAuthOptions, type McpClient, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpToolConnection, type McpTransport, type ModelCapabilities, type PromptInput, type PromptResponse, type QueuedSubagentToolExecutor, type ResolvedAgentAssets, type RunAgentPromptOptions, type SandboxedAgentRuntime, SessionAgentMismatchError, type SessionLifecycle, type SessionLifecycleContext, type StreamAgentPromptOptions, type StreamAgentPromptResult, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, type UsageSink, type UsageSinkEvent, type WebToolsOptions, agentModelIdsFromStoredManifest, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, currentLlmRunContext, defineAgent, defineMcp, defineTool, getAgentPromptExecutionContext, hydrateChatAttachmentMessages, isAgent, isMcp, isWithinAgentPromptExecution, loadAssetManifest, modelSupportsMediaType, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveMaxSteps, resolveModelCapabilities, resolveThinkingLevel, runAgentPrompt, runDirectAgentPrompt, runLlm, streamAgentPrompt, toSubagentTool, validateAgentModelIds, withLlmRunContext };
package/dist/agent.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as defineTool, P as modelSupportsMediaType, y as ModelCapabilities } from "./index-dDHyyZ6y.mjs";
2
- import { _ as resolveMaxSteps, a as AgentModelId, c as AgentStreamEvent, d as DEFAULT_THINKING_LEVEL, g as resolveAgentModel, h as parseAgentCreateInput, i as AgentMessage, l as DEFAULT_COMPACTION_MODEL_ID, m as ThinkingLevelSchema, n as AgentCreateInput, o as AgentModelIdSchema, p as ThinkingLevel, r as AgentCreateInputSchema, u as DEFAULT_MAX_STEPS, v as resolveModelCapabilities, y as resolveThinkingLevel } from "./schemas-lSbMfQRy-D7NW7SCj.mjs";
3
- import { a as McpDefinitionInput, c as McpStdioOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpDefinition, l as McpStdioTransport, m as connectMcpStdio, n as McpAuthOptions, o as McpHttpTransport, p as connectMcpServer, r as McpClient, s as McpServerOptions, t as ToolCredentialResolver, u as McpToolConnection } from "./index-skjc11Qf.mjs";
4
- import { A as currentLlmRunContext, B as resolveAgentTools, C as StreamAgentPromptOptions, D as WebToolsOptions, E as UsageSinkEvent, F as isWithinAgentPromptExecution, G as streamAgentPrompt, H as runAgentPrompt, I as normalizeAgentDefinition, J as withLlmRunContext, K as toSubagentTool, L as prepareAgentSession, M as getAgentPromptExecutionContext, N as hydrateChatAttachmentMessages, O as agentModelIdsFromStoredManifest, P as isAgent, R as resolveAgentAssets, S as SessionLifecycleContext, T as UsageSink, U as runDirectAgentPrompt, V as resolveAgentWorkspaceRoot, W as runLlm, _ as ResolvedAgentAssets, a as AgentDefinition, b as SessionAgentMismatchError, c as AgentPromptExecutionContext, d as AgentToolInput, f as BuildAgentRuntimeContext, g as QueuedSubagentToolExecutor, h as PromptResponse, i as AgentChildToolContext, j as defineAgent, k as buildAgentRuntime, l as AgentRunConfig, m as PromptInput, n as Agent, o as AgentDefinitionInput, p as LlmRunContext, q as validateAgentModelIds, r as AgentAssetInput, s as AgentExperimentalDownload, t as AGENT, u as AgentStreamPort, v as RunAgentPromptOptions, w as StreamAgentPromptResult, x as SessionLifecycle, y as SandboxedAgentRuntime, z as resolveAgentId } from "./index-CjWSlYyq.mjs";
2
+ import { _ as resolveMaxSteps, a as AgentModelId, c as AgentStreamEvent, d as DEFAULT_THINKING_LEVEL, g as resolveAgentModel, h as parseAgentCreateInput, i as AgentMessage, l as DEFAULT_COMPACTION_MODEL_ID, m as ThinkingLevelSchema, n as AgentCreateInput, o as AgentModelIdSchema, p as ThinkingLevel, r as AgentCreateInputSchema, u as DEFAULT_MAX_STEPS, v as resolveModelCapabilities, y as resolveThinkingLevel } from "./schemas-lSbMfQRy-CIfs2xv6.mjs";
3
+ import { a as McpDefinitionInput, c as McpStdioOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpDefinition, l as McpStdioTransport, m as connectMcpStdio, n as McpAuthOptions, o as McpHttpTransport, p as connectMcpServer, r as McpClient, s as McpServerOptions, t as ToolCredentialResolver, u as McpToolConnection } from "./index-CIz44roq.mjs";
4
+ import { A as currentLlmRunContext, B as resolveAgentTools, C as StreamAgentPromptOptions, D as WebToolsOptions, E as UsageSinkEvent, F as isWithinAgentPromptExecution, G as streamAgentPrompt, H as runAgentPrompt, I as normalizeAgentDefinition, J as withLlmRunContext, K as toSubagentTool, L as prepareAgentSession, M as getAgentPromptExecutionContext, N as hydrateChatAttachmentMessages, O as agentModelIdsFromStoredManifest, P as isAgent, R as resolveAgentAssets, S as SessionLifecycleContext, T as UsageSink, U as runDirectAgentPrompt, V as resolveAgentWorkspaceRoot, W as runLlm, _ as ResolvedAgentAssets, a as AgentDefinition, b as SessionAgentMismatchError, c as AgentPromptExecutionContext, d as AgentToolInput, f as BuildAgentRuntimeContext, g as QueuedSubagentToolExecutor, h as PromptResponse, i as AgentChildToolContext, j as defineAgent, k as buildAgentRuntime, l as AgentRunConfig, m as PromptInput, n as Agent, o as AgentDefinitionInput, p as LlmRunContext, q as validateAgentModelIds, r as AgentAssetInput, s as AgentExperimentalDownload, t as AGENT, u as AgentStreamPort, v as RunAgentPromptOptions, w as StreamAgentPromptResult, x as SessionLifecycle, y as SandboxedAgentRuntime, z as resolveAgentId } from "./index-BNptJCCC.mjs";
5
5
  import { U as loadAssetManifest } from "./index-C05t3LuY.mjs";
6
6
  export { AGENT, type Agent, type AgentAssetInput, type AgentChildToolContext, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentExperimentalDownload, type AgentMessage, type AgentModelId, AgentModelIdSchema, type AgentPromptExecutionContext, type AgentRunConfig, type AgentStreamEvent, type AgentStreamPort, type AgentToolInput, type BuildAgentRuntimeContext, DEFAULT_COMPACTION_MODEL_ID, DEFAULT_MAX_STEPS, DEFAULT_THINKING_LEVEL, type LlmRunContext, type McpAuthOptions, type McpClient, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpToolConnection, type McpTransport, type ModelCapabilities, type PromptInput, type PromptResponse, type QueuedSubagentToolExecutor, type ResolvedAgentAssets, type RunAgentPromptOptions, type SandboxedAgentRuntime, SessionAgentMismatchError, type SessionLifecycle, type SessionLifecycleContext, type StreamAgentPromptOptions, type StreamAgentPromptResult, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, type UsageSink, type UsageSinkEvent, type WebToolsOptions, agentModelIdsFromStoredManifest, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, currentLlmRunContext, defineAgent, defineMcp, defineTool, getAgentPromptExecutionContext, hydrateChatAttachmentMessages, isAgent, isMcp, isWithinAgentPromptExecution, loadAssetManifest, modelSupportsMediaType, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveMaxSteps, resolveModelCapabilities, resolveThinkingLevel, runAgentPrompt, runDirectAgentPrompt, runLlm, streamAgentPrompt, toSubagentTool, validateAgentModelIds, withLlmRunContext };
package/dist/agent.mjs CHANGED
@@ -840,6 +840,75 @@ function gateToolSetMedia(toolSet, capabilities) {
840
840
  }
841
841
  return gated;
842
842
  }
843
+ function withDescription(schema, source) {
844
+ return source.description ? schema.describe(source.description) : schema;
845
+ }
846
+ /** Wire accepts null; parse output uses undefined so `.optional()` consumers still match. */
847
+ function nullableWire(schema) {
848
+ return schema.nullable().transform((value) => value === null ? void 0 : value);
849
+ }
850
+ /**
851
+ * OpenAI (and Azure) strict structured outputs require every key in
852
+ * `properties` to also appear in `required`. Zod `.optional()` / `.nullish()`
853
+ * / `.default()` omit keys from `required`, which the API rejects before the
854
+ * model runs.
855
+ *
856
+ * Rewrite those wrappers to a wire-nullable shape, then map values back to what
857
+ * the original schema expects (null → undefined for `.optional()`, apply
858
+ * `.default()`), so workflow `output` / caller parses still succeed.
859
+ */
860
+ function toStrictStructuredOutputSchema(schema) {
861
+ return rewrite(schema);
862
+ }
863
+ /** Zod classic wrappers expose nested schemas as core `$ZodType`. */
864
+ function rewrite(schema) {
865
+ if (schema instanceof z.ZodOptional) {
866
+ const transformed = rewrite(schema.unwrap());
867
+ if (transformed instanceof z.ZodNullable) return withDescription(transformed, schema);
868
+ return withDescription(nullableWire(transformed), schema);
869
+ }
870
+ if (schema instanceof z.ZodNullable) return withDescription(rewrite(schema.unwrap()).nullable(), schema);
871
+ if (schema instanceof z.ZodDefault) {
872
+ const defaultValue = schema.def.defaultValue;
873
+ const inner = rewrite(schema.unwrap());
874
+ return withDescription(z.union([inner, z.null()]).transform((value) => {
875
+ if (value === null || value === void 0) return defaultValue;
876
+ return value;
877
+ }), schema);
878
+ }
879
+ if (schema instanceof z.ZodObject) {
880
+ const shape = {};
881
+ for (const [key, value] of Object.entries(schema.shape)) shape[key] = rewrite(value);
882
+ const catchall = schema.def.catchall;
883
+ let objectSchema = z.object(shape);
884
+ if (catchall instanceof z.ZodUnknown) objectSchema = objectSchema.loose();
885
+ else if (catchall instanceof z.ZodNever) objectSchema = objectSchema.strict();
886
+ else if (catchall) objectSchema = objectSchema.catchall(rewrite(catchall));
887
+ return withDescription(objectSchema, schema);
888
+ }
889
+ if (schema instanceof z.ZodArray) return withDescription(z.array(rewrite(schema.element)), schema);
890
+ if (schema instanceof z.ZodUnion) {
891
+ const options = schema.options.map(rewrite);
892
+ const first = options[0];
893
+ const second = options[1];
894
+ if (!first || !second) return schema;
895
+ return withDescription(z.union([
896
+ first,
897
+ second,
898
+ ...options.slice(2)
899
+ ]), schema);
900
+ }
901
+ if (schema instanceof z.ZodTuple) {
902
+ const { items, rest } = schema.def;
903
+ const transformed = items.map(rewrite);
904
+ const first = transformed[0];
905
+ if (!first) return schema;
906
+ return withDescription(rest ? z.tuple([first, ...transformed.slice(1)]).rest(rewrite(rest)) : z.tuple([first, ...transformed.slice(1)]), schema);
907
+ }
908
+ if (schema instanceof z.ZodRecord) return withDescription(z.record(schema.keyType, rewrite(schema.valueType)), schema);
909
+ if (schema instanceof z.ZodType) return schema;
910
+ throw new Error("Expected a Zod classic schema");
911
+ }
843
912
  function textFromContent(result) {
844
913
  return result.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
845
914
  }
@@ -1182,13 +1251,14 @@ async function streamAgentPrompt(config, input, options) {
1182
1251
  ...instrumentAiToolSet(config.mcpToolSet)
1183
1252
  }, config.resolvedModel.capabilities);
1184
1253
  const structuredOutput = Boolean(options.outputSchema);
1254
+ const outputSchema = options.outputSchema ? toStrictStructuredOutputSchema(options.outputSchema) : void 0;
1185
1255
  const hasTools = Object.keys(aiTools).length > 0;
1186
1256
  const submitToolOutput = usesStructuredOutputSubmitTool({
1187
1257
  modelId: config.resolvedModel.modelId,
1188
1258
  structuredOutput,
1189
1259
  hasTools
1190
1260
  });
1191
- if (submitToolOutput && options.outputSchema) aiTools = appendStructuredOutputSubmitTool(aiTools, options.outputSchema);
1261
+ if (submitToolOutput && outputSchema) aiTools = appendStructuredOutputSubmitTool(aiTools, outputSchema);
1192
1262
  let messagesForModel = await applyCapabilityPlaceholderToMessages(priorMessages, config.resolvedModel.capabilities);
1193
1263
  if (config.experimentalDownload) messagesForModel = await hydrateChatAttachmentMessages(messagesForModel, config.experimentalDownload);
1194
1264
  const modelMessages = await convertToModelMessages(messagesForModel, resume ? { ignoreIncompleteToolCalls: true } : void 0);
@@ -1287,7 +1357,7 @@ async function streamAgentPrompt(config, input, options) {
1287
1357
  tools: aiTools,
1288
1358
  reasoning: config.thinkingLevel,
1289
1359
  ...config.experimentalDownload ? { experimental_download: config.experimentalDownload } : {},
1290
- ...!submitToolOutput && options.outputSchema ? { output: output_exports.object({ schema: options.outputSchema }) } : {},
1360
+ ...!submitToolOutput && outputSchema ? { output: output_exports.object({ schema: outputSchema }) } : {},
1291
1361
  ...providerOptions ? { providerOptions } : {},
1292
1362
  prepareStep: prepareStepOnce,
1293
1363
  stopWhen
@@ -1389,10 +1459,10 @@ async function streamAgentPrompt(config, input, options) {
1389
1459
  });
1390
1460
  }
1391
1461
  text = await streamResult.text;
1392
- if (options.outputSchema) if (submitToolOutput) {
1462
+ if (outputSchema) if (submitToolOutput) {
1393
1463
  output = extractStructuredOutputFromSubmitTool({
1394
1464
  steps: await streamResult.steps,
1395
- schema: options.outputSchema
1465
+ schema: outputSchema
1396
1466
  });
1397
1467
  if (output === void 0) throw new Error(`Structured output was not submitted via ${STRUCTURED_OUTPUT_SUBMIT_TOOL_NAME}`);
1398
1468
  } else try {
@@ -1400,7 +1470,7 @@ async function streamAgentPrompt(config, input, options) {
1400
1470
  } catch (caught) {
1401
1471
  const repaired = parseRepairedStructuredOutput({
1402
1472
  text,
1403
- schema: options.outputSchema
1473
+ schema: outputSchema
1404
1474
  });
1405
1475
  if (repaired !== void 0) output = repaired;
1406
1476
  else throw caught;
@@ -2787,7 +2857,7 @@ async function runPromptText(opts, hooks) {
2787
2857
  return result.text;
2788
2858
  }
2789
2859
  async function runPromptObjectViaSubmitTool(opts, hooks) {
2790
- const schema = opts.outputSchema;
2860
+ const schema = opts.outputSchema ? toStrictStructuredOutputSchema(opts.outputSchema) : void 0;
2791
2861
  if (!schema) throw new Error("outputSchema is required for structured LLM output");
2792
2862
  const resolved = await resolvePromptModel(opts.model);
2793
2863
  const providerOptions = resolveProviderOptions({
@@ -2832,14 +2902,14 @@ async function runPromptObjectViaSubmitTool(opts, hooks) {
2832
2902
  throw new Error(`Structured output was not submitted via ${STRUCTURED_OUTPUT_SUBMIT_TOOL_NAME}`);
2833
2903
  }
2834
2904
  async function runPromptObject(opts, hooks) {
2835
- const schema = opts.outputSchema;
2836
- if (!schema) throw new Error("outputSchema is required for structured LLM output");
2837
2905
  const resolved = await resolvePromptModel(opts.model);
2838
2906
  if (usesStructuredOutputSubmitTool({
2839
2907
  modelId: resolved.modelId,
2840
2908
  structuredOutput: true,
2841
2909
  promptLlm: true
2842
2910
  })) return runPromptObjectViaSubmitTool(opts, hooks);
2911
+ const schema = opts.outputSchema ? toStrictStructuredOutputSchema(opts.outputSchema) : void 0;
2912
+ if (!schema) throw new Error("outputSchema is required for structured LLM output");
2843
2913
  const providerOptions = resolveProviderOptions({
2844
2914
  modelId: resolved.modelId,
2845
2915
  structuredOutput: true