@hongymagic/q 2026.302.0-next.db67a88 → 2026.303.0-next.8a37ded

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 (2) hide show
  1. package/dist/q.js +501 -126
  2. package/package.json +13 -11
package/dist/q.js CHANGED
@@ -14641,7 +14641,7 @@ import { parseArgs } from "node:util";
14641
14641
  // package.json
14642
14642
  var package_default = {
14643
14643
  name: "@hongymagic/q",
14644
- version: "2026.302.0-next.db67a88",
14644
+ version: "2026.303.0-next.8a37ded",
14645
14645
  description: "Quick AI answers from the command line",
14646
14646
  main: "dist/q.js",
14647
14647
  type: "module",
@@ -14674,6 +14674,7 @@ var package_default = {
14674
14674
  scripts: {
14675
14675
  start: "bun run src/cli.ts",
14676
14676
  test: "vitest run",
14677
+ "test:coverage": "vitest run --coverage",
14677
14678
  "test:watch": "vitest",
14678
14679
  typecheck: "tsc --noEmit",
14679
14680
  lint: "biome check .",
@@ -14690,23 +14691,24 @@ var package_default = {
14690
14691
  "release:dry": "bun run scripts/release.ts --dry-run"
14691
14692
  },
14692
14693
  dependencies: {
14693
- "@ai-sdk/amazon-bedrock": "4.0.67",
14694
- "@ai-sdk/anthropic": "3.0.48",
14695
- "@ai-sdk/azure": "3.0.37",
14696
- "@ai-sdk/google": "3.0.33",
14697
- "@ai-sdk/groq": "3.0.25",
14698
- "@ai-sdk/openai": "3.0.36",
14699
- "@ai-sdk/openai-compatible": "2.0.30",
14694
+ "@ai-sdk/amazon-bedrock": "4.0.70",
14695
+ "@ai-sdk/anthropic": "3.0.51",
14696
+ "@ai-sdk/azure": "3.0.39",
14697
+ "@ai-sdk/google": "3.0.35",
14698
+ "@ai-sdk/groq": "3.0.26",
14699
+ "@ai-sdk/openai": "3.0.38",
14700
+ "@ai-sdk/openai-compatible": "2.0.31",
14700
14701
  "@t3-oss/env-core": "0.13.10",
14701
- ai: "6.0.103",
14702
+ ai: "6.0.106",
14702
14703
  clipboardy: "5.3.1",
14703
14704
  "ollama-ai-provider-v2": "3.3.1",
14704
14705
  zod: "4.3.6"
14705
14706
  },
14706
14707
  devDependencies: {
14707
- "@biomejs/biome": "2.4.4",
14708
+ "@biomejs/biome": "2.4.5",
14708
14709
  "@types/bun": "1.3.9",
14709
- lefthook: "2.1.1",
14710
+ "@vitest/coverage-v8": "4.0.18",
14711
+ lefthook: "2.1.2",
14710
14712
  typescript: "5.9.3",
14711
14713
  vitest: "4.0.18"
14712
14714
  }
@@ -33350,25 +33352,30 @@ function combineHeaders(...headers) {
33350
33352
  }
33351
33353
  function createToolNameMapping({
33352
33354
  tools = [],
33353
- providerToolNames
33355
+ providerToolNames,
33356
+ resolveProviderToolName
33354
33357
  }) {
33358
+ var _a23;
33355
33359
  const customToolNameToProviderToolName = {};
33356
33360
  const providerToolNameToCustomToolName = {};
33357
33361
  for (const tool2 of tools) {
33358
- if (tool2.type === "provider" && tool2.id in providerToolNames) {
33359
- const providerToolName = providerToolNames[tool2.id];
33362
+ if (tool2.type === "provider") {
33363
+ const providerToolName = (_a23 = resolveProviderToolName == null ? undefined : resolveProviderToolName(tool2)) != null ? _a23 : (tool2.id in providerToolNames) ? providerToolNames[tool2.id] : undefined;
33364
+ if (providerToolName == null) {
33365
+ continue;
33366
+ }
33360
33367
  customToolNameToProviderToolName[tool2.name] = providerToolName;
33361
33368
  providerToolNameToCustomToolName[providerToolName] = tool2.name;
33362
33369
  }
33363
33370
  }
33364
33371
  return {
33365
33372
  toProviderToolName: (customToolName) => {
33366
- var _a23;
33367
- return (_a23 = customToolNameToProviderToolName[customToolName]) != null ? _a23 : customToolName;
33373
+ var _a32;
33374
+ return (_a32 = customToolNameToProviderToolName[customToolName]) != null ? _a32 : customToolName;
33368
33375
  },
33369
33376
  toCustomToolName: (providerToolName) => {
33370
- var _a23;
33371
- return (_a23 = providerToolNameToCustomToolName[providerToolName]) != null ? _a23 : providerToolName;
33377
+ var _a32;
33378
+ return (_a32 = providerToolNameToCustomToolName[providerToolName]) != null ? _a32 : providerToolName;
33372
33379
  }
33373
33380
  };
33374
33381
  }
@@ -33724,7 +33731,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
33724
33731
  normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
33725
33732
  return Object.fromEntries(normalizedHeaders.entries());
33726
33733
  }
33727
- var VERSION2 = "4.0.15";
33734
+ var VERSION2 = "4.0.16";
33728
33735
  var getOriginalFetch = () => globalThis.fetch;
33729
33736
  var getFromApi = async ({
33730
33737
  url: url2,
@@ -35488,7 +35495,7 @@ async function* executeTool({
35488
35495
  }
35489
35496
 
35490
35497
  // node_modules/@ai-sdk/anthropic/dist/index.mjs
35491
- var VERSION3 = "3.0.48";
35498
+ var VERSION3 = "3.0.51";
35492
35499
  var anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
35493
35500
  type: exports_external.literal("error"),
35494
35501
  error: exports_external.object({
@@ -37789,8 +37796,18 @@ var AnthropicMessagesLanguageModel = class {
37789
37796
  ...thinkingBudget != null && { budget_tokens: thinkingBudget }
37790
37797
  }
37791
37798
  },
37792
- ...(anthropicOptions == null ? undefined : anthropicOptions.effort) && {
37793
- output_config: { effort: anthropicOptions.effort }
37799
+ ...((anthropicOptions == null ? undefined : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null) && {
37800
+ output_config: {
37801
+ ...(anthropicOptions == null ? undefined : anthropicOptions.effort) && {
37802
+ effort: anthropicOptions.effort
37803
+ },
37804
+ ...useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && {
37805
+ format: {
37806
+ type: "json_schema",
37807
+ schema: responseFormat.schema
37808
+ }
37809
+ }
37810
+ }
37794
37811
  },
37795
37812
  ...(anthropicOptions == null ? undefined : anthropicOptions.speed) && {
37796
37813
  speed: anthropicOptions.speed
@@ -37798,12 +37815,6 @@ var AnthropicMessagesLanguageModel = class {
37798
37815
  ...(anthropicOptions == null ? undefined : anthropicOptions.cacheControl) && {
37799
37816
  cache_control: anthropicOptions.cacheControl
37800
37817
  },
37801
- ...useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && {
37802
- output_format: {
37803
- type: "json_schema",
37804
- schema: responseFormat.schema
37805
- }
37806
- },
37807
37818
  ...(anthropicOptions == null ? undefined : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
37808
37819
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
37809
37820
  type: server.type,
@@ -37966,10 +37977,6 @@ var AnthropicMessagesLanguageModel = class {
37966
37977
  if (stream && ((_f = anthropicOptions == null ? undefined : anthropicOptions.toolStreaming) != null ? _f : true)) {
37967
37978
  betas.add("fine-grained-tool-streaming-2025-05-14");
37968
37979
  }
37969
- const usingNativeOutputFormat = useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null;
37970
- if (usingNativeOutputFormat) {
37971
- betas.add("structured-outputs-2025-11-13");
37972
- }
37973
37980
  const {
37974
37981
  tools: anthropicTools2,
37975
37982
  toolChoice: anthropicToolChoice,
@@ -39185,7 +39192,7 @@ function getModelCapabilities(modelId) {
39185
39192
  supportsStructuredOutput: true,
39186
39193
  isKnownModel: true
39187
39194
  };
39188
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
39195
+ } else if (modelId.includes("claude-sonnet-4-")) {
39189
39196
  return {
39190
39197
  maxOutputTokens: 64000,
39191
39198
  supportsStructuredOutput: false,
@@ -39197,12 +39204,6 @@ function getModelCapabilities(modelId) {
39197
39204
  supportsStructuredOutput: false,
39198
39205
  isKnownModel: true
39199
39206
  };
39200
- } else if (modelId.includes("claude-3-5-haiku")) {
39201
- return {
39202
- maxOutputTokens: 8192,
39203
- supportsStructuredOutput: false,
39204
- isKnownModel: true
39205
- };
39206
39207
  } else if (modelId.includes("claude-3-haiku")) {
39207
39208
  return {
39208
39209
  maxOutputTokens: 4096,
@@ -39628,7 +39629,7 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
39628
39629
  function getOpenAILanguageModelCapabilities(modelId) {
39629
39630
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
39630
39631
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
39631
- const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("codex-mini") || modelId.startsWith("computer-use-preview") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
39632
+ const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
39632
39633
  const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2");
39633
39634
  const systemMessageMode = isReasoningModel ? "developer" : "system";
39634
39635
  return {
@@ -41670,9 +41671,10 @@ async function convertToOpenAIResponsesInput({
41670
41671
  hasConversation = false,
41671
41672
  hasLocalShellTool = false,
41672
41673
  hasShellTool = false,
41673
- hasApplyPatchTool = false
41674
+ hasApplyPatchTool = false,
41675
+ customProviderToolNames
41674
41676
  }) {
41675
- var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
41677
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
41676
41678
  const input = [];
41677
41679
  const warnings = [];
41678
41680
  const processedApprovalIds = /* @__PURE__ */ new Set;
@@ -41837,6 +41839,16 @@ async function convertToOpenAIResponsesInput({
41837
41839
  });
41838
41840
  break;
41839
41841
  }
41842
+ if (customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) {
41843
+ input.push({
41844
+ type: "custom_tool_call",
41845
+ call_id: part.toolCallId,
41846
+ name: resolvedToolName,
41847
+ input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
41848
+ id
41849
+ });
41850
+ break;
41851
+ }
41840
41852
  input.push({
41841
41853
  type: "function_call",
41842
41854
  call_id: part.toolCallId,
@@ -42036,6 +42048,61 @@ async function convertToOpenAIResponsesInput({
42036
42048
  });
42037
42049
  continue;
42038
42050
  }
42051
+ if (customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) {
42052
+ let outputValue;
42053
+ switch (output.type) {
42054
+ case "text":
42055
+ case "error-text":
42056
+ outputValue = output.value;
42057
+ break;
42058
+ case "execution-denied":
42059
+ outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
42060
+ break;
42061
+ case "json":
42062
+ case "error-json":
42063
+ outputValue = JSON.stringify(output.value);
42064
+ break;
42065
+ case "content":
42066
+ outputValue = output.value.map((item) => {
42067
+ var _a23;
42068
+ switch (item.type) {
42069
+ case "text":
42070
+ return { type: "input_text", text: item.text };
42071
+ case "image-data":
42072
+ return {
42073
+ type: "input_image",
42074
+ image_url: `data:${item.mediaType};base64,${item.data}`
42075
+ };
42076
+ case "image-url":
42077
+ return {
42078
+ type: "input_image",
42079
+ image_url: item.url
42080
+ };
42081
+ case "file-data":
42082
+ return {
42083
+ type: "input_file",
42084
+ filename: (_a23 = item.filename) != null ? _a23 : "data",
42085
+ file_data: `data:${item.mediaType};base64,${item.data}`
42086
+ };
42087
+ default:
42088
+ warnings.push({
42089
+ type: "other",
42090
+ message: `unsupported custom tool content part type: ${item.type}`
42091
+ });
42092
+ return;
42093
+ }
42094
+ }).filter(isNonNullable);
42095
+ break;
42096
+ default:
42097
+ outputValue = "";
42098
+ }
42099
+ input.push({
42100
+ type: "custom_tool_call_output",
42101
+ call_id: part.toolCallId,
42102
+ output: outputValue
42103
+ });
42104
+ continue;
42105
+ }
42039
42106
  let contentValue;
42040
42107
  switch (output.type) {
42041
42108
  case "text":
@@ -42043,7 +42110,7 @@ async function convertToOpenAIResponsesInput({
42043
42110
  contentValue = output.value;
42044
42111
  break;
42045
42112
  case "execution-denied":
42046
- contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
42113
+ contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
42047
42114
  break;
42048
42115
  case "json":
42049
42116
  case "error-json":
@@ -42244,6 +42311,13 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(exports_external.uni
42244
42311
  })
42245
42312
  ])
42246
42313
  }),
42314
+ exports_external.object({
42315
+ type: exports_external.literal("custom_tool_call"),
42316
+ id: exports_external.string(),
42317
+ call_id: exports_external.string(),
42318
+ name: exports_external.string(),
42319
+ input: exports_external.string()
42320
+ }),
42247
42321
  exports_external.object({
42248
42322
  type: exports_external.literal("shell_call"),
42249
42323
  id: exports_external.string(),
@@ -42294,6 +42368,14 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(exports_external.uni
42294
42368
  arguments: exports_external.string(),
42295
42369
  status: exports_external.literal("completed")
42296
42370
  }),
42371
+ exports_external.object({
42372
+ type: exports_external.literal("custom_tool_call"),
42373
+ id: exports_external.string(),
42374
+ call_id: exports_external.string(),
42375
+ name: exports_external.string(),
42376
+ input: exports_external.string(),
42377
+ status: exports_external.literal("completed")
42378
+ }),
42297
42379
  exports_external.object({
42298
42380
  type: exports_external.literal("code_interpreter_call"),
42299
42381
  id: exports_external.string(),
@@ -42464,6 +42546,12 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(exports_external.uni
42464
42546
  output_index: exports_external.number(),
42465
42547
  delta: exports_external.string()
42466
42548
  }),
42549
+ exports_external.object({
42550
+ type: exports_external.literal("response.custom_tool_call_input.delta"),
42551
+ item_id: exports_external.string(),
42552
+ output_index: exports_external.number(),
42553
+ delta: exports_external.string()
42554
+ }),
42467
42555
  exports_external.object({
42468
42556
  type: exports_external.literal("response.image_generation_call.partial_image"),
42469
42557
  item_id: exports_external.string(),
@@ -42688,6 +42776,13 @@ var openaiResponsesResponseSchema = lazySchema(() => zodSchema(exports_external.
42688
42776
  arguments: exports_external.string(),
42689
42777
  id: exports_external.string()
42690
42778
  }),
42779
+ exports_external.object({
42780
+ type: exports_external.literal("custom_tool_call"),
42781
+ call_id: exports_external.string(),
42782
+ name: exports_external.string(),
42783
+ input: exports_external.string(),
42784
+ id: exports_external.string()
42785
+ }),
42691
42786
  exports_external.object({
42692
42787
  type: exports_external.literal("computer_call"),
42693
42788
  id: exports_external.string(),
@@ -42811,16 +42906,10 @@ var openaiResponsesReasoningModelIds = [
42811
42906
  "o1-2024-12-17",
42812
42907
  "o3",
42813
42908
  "o3-2025-04-16",
42814
- "o3-deep-research",
42815
- "o3-deep-research-2025-06-26",
42816
42909
  "o3-mini",
42817
42910
  "o3-mini-2025-01-31",
42818
42911
  "o4-mini",
42819
42912
  "o4-mini-2025-04-16",
42820
- "o4-mini-deep-research",
42821
- "o4-mini-deep-research-2025-06-26",
42822
- "codex-mini-latest",
42823
- "computer-use-preview",
42824
42913
  "gpt-5",
42825
42914
  "gpt-5-2025-08-07",
42826
42915
  "gpt-5-codex",
@@ -42853,7 +42942,6 @@ var openaiResponsesModelIds = [
42853
42942
  "gpt-4o-2024-08-06",
42854
42943
  "gpt-4o-2024-11-20",
42855
42944
  "gpt-4o-audio-preview",
42856
- "gpt-4o-audio-preview-2024-10-01",
42857
42945
  "gpt-4o-audio-preview-2024-12-17",
42858
42946
  "gpt-4o-search-preview",
42859
42947
  "gpt-4o-search-preview-2025-03-11",
@@ -42861,19 +42949,9 @@ var openaiResponsesModelIds = [
42861
42949
  "gpt-4o-mini-search-preview-2025-03-11",
42862
42950
  "gpt-4o-mini",
42863
42951
  "gpt-4o-mini-2024-07-18",
42864
- "gpt-4-turbo",
42865
- "gpt-4-turbo-2024-04-09",
42866
- "gpt-4-turbo-preview",
42867
- "gpt-4-0125-preview",
42868
- "gpt-4-1106-preview",
42869
- "gpt-4",
42870
- "gpt-4-0613",
42871
- "gpt-4.5-preview",
42872
- "gpt-4.5-preview-2025-02-27",
42873
42952
  "gpt-3.5-turbo-0125",
42874
42953
  "gpt-3.5-turbo",
42875
42954
  "gpt-3.5-turbo-1106",
42876
- "chatgpt-4o-latest",
42877
42955
  "gpt-5-chat-latest",
42878
42956
  ...openaiResponsesReasoningModelIds
42879
42957
  ];
@@ -42988,6 +43066,25 @@ var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema({
42988
43066
  var imageGeneration = (args = {}) => {
42989
43067
  return imageGenerationToolFactory(args);
42990
43068
  };
43069
+ var customArgsSchema = lazySchema(() => zodSchema(exports_external.object({
43070
+ name: exports_external.string(),
43071
+ description: exports_external.string().optional(),
43072
+ format: exports_external.union([
43073
+ exports_external.object({
43074
+ type: exports_external.literal("grammar"),
43075
+ syntax: exports_external.enum(["regex", "lark"]),
43076
+ definition: exports_external.string()
43077
+ }),
43078
+ exports_external.object({
43079
+ type: exports_external.literal("text")
43080
+ })
43081
+ ]).optional()
43082
+ })));
43083
+ var customInputSchema = lazySchema(() => zodSchema(exports_external.string()));
43084
+ var customToolFactory = createProviderToolFactory({
43085
+ id: "openai.custom",
43086
+ inputSchema: customInputSchema
43087
+ });
42991
43088
  var jsonValueSchema = exports_external.lazy(() => exports_external.union([
42992
43089
  exports_external.string(),
42993
43090
  exports_external.number(),
@@ -43107,14 +43204,18 @@ var webSearchPreview = createProviderToolFactoryWithOutputSchema({
43107
43204
  });
43108
43205
  async function prepareResponsesTools({
43109
43206
  tools,
43110
- toolChoice
43207
+ toolChoice,
43208
+ toolNameMapping,
43209
+ customProviderToolNames
43111
43210
  }) {
43211
+ var _a16;
43112
43212
  tools = (tools == null ? undefined : tools.length) ? tools : undefined;
43113
43213
  const toolWarnings = [];
43114
43214
  if (tools == null) {
43115
43215
  return { tools: undefined, toolChoice: undefined, toolWarnings };
43116
43216
  }
43117
43217
  const openaiTools = [];
43218
+ const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set;
43118
43219
  for (const tool2 of tools) {
43119
43220
  switch (tool2.type) {
43120
43221
  case "function":
@@ -43256,6 +43357,20 @@ async function prepareResponsesTools({
43256
43357
  });
43257
43358
  break;
43258
43359
  }
43360
+ case "openai.custom": {
43361
+ const args = await validateTypes({
43362
+ value: tool2.args,
43363
+ schema: customArgsSchema
43364
+ });
43365
+ openaiTools.push({
43366
+ type: "custom",
43367
+ name: args.name,
43368
+ description: args.description,
43369
+ format: args.format
43370
+ });
43371
+ resolvedCustomProviderToolNames.add(args.name);
43372
+ break;
43373
+ }
43259
43374
  }
43260
43375
  break;
43261
43376
  }
@@ -43276,12 +43391,14 @@ async function prepareResponsesTools({
43276
43391
  case "none":
43277
43392
  case "required":
43278
43393
  return { tools: openaiTools, toolChoice: type, toolWarnings };
43279
- case "tool":
43394
+ case "tool": {
43395
+ const resolvedToolName = (_a16 = toolNameMapping == null ? undefined : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a16 : toolChoice.toolName;
43280
43396
  return {
43281
43397
  tools: openaiTools,
43282
- toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" || toolChoice.toolName === "mcp" || toolChoice.toolName === "apply_patch" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
43398
+ toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
43283
43399
  toolWarnings
43284
43400
  };
43401
+ }
43285
43402
  default: {
43286
43403
  const _exhaustiveCheck = type;
43287
43404
  throw new UnsupportedFunctionalityError({
@@ -43430,7 +43547,19 @@ var OpenAIResponsesLanguageModel = class {
43430
43547
  "openai.web_search_preview": "web_search_preview",
43431
43548
  "openai.mcp": "mcp",
43432
43549
  "openai.apply_patch": "apply_patch"
43433
- }
43550
+ },
43551
+ resolveProviderToolName: (tool2) => tool2.id === "openai.custom" ? tool2.args.name : undefined
43552
+ });
43553
+ const customProviderToolNames = /* @__PURE__ */ new Set;
43554
+ const {
43555
+ tools: openaiTools,
43556
+ toolChoice: openaiToolChoice,
43557
+ toolWarnings
43558
+ } = await prepareResponsesTools({
43559
+ tools,
43560
+ toolChoice,
43561
+ toolNameMapping,
43562
+ customProviderToolNames
43434
43563
  });
43435
43564
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
43436
43565
  prompt,
@@ -43442,7 +43571,8 @@ var OpenAIResponsesLanguageModel = class {
43442
43571
  hasConversation: (openaiOptions == null ? undefined : openaiOptions.conversation) != null,
43443
43572
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
43444
43573
  hasShellTool: hasOpenAITool("openai.shell"),
43445
- hasApplyPatchTool: hasOpenAITool("openai.apply_patch")
43574
+ hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
43575
+ customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : undefined
43446
43576
  });
43447
43577
  warnings.push(...inputWarnings);
43448
43578
  const strictJsonSchema = (_d = openaiOptions == null ? undefined : openaiOptions.strictJsonSchema) != null ? _d : true;
@@ -43571,14 +43701,6 @@ var OpenAIResponsesLanguageModel = class {
43571
43701
  });
43572
43702
  delete baseArgs.service_tier;
43573
43703
  }
43574
- const {
43575
- tools: openaiTools,
43576
- toolChoice: openaiToolChoice,
43577
- toolWarnings
43578
- } = await prepareResponsesTools({
43579
- tools,
43580
- toolChoice
43581
- });
43582
43704
  const shellToolEnvType = (_i = (_h = (_g = tools == null ? undefined : tools.find((tool2) => tool2.type === "provider" && tool2.id === "openai.shell")) == null ? undefined : _g.args) == null ? undefined : _h.environment) == null ? undefined : _i.type;
43583
43705
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
43584
43706
  return {
@@ -43824,6 +43946,22 @@ var OpenAIResponsesLanguageModel = class {
43824
43946
  });
43825
43947
  break;
43826
43948
  }
43949
+ case "custom_tool_call": {
43950
+ hasFunctionCall = true;
43951
+ const toolName = toolNameMapping.toCustomToolName(part.name);
43952
+ content.push({
43953
+ type: "tool-call",
43954
+ toolCallId: part.call_id,
43955
+ toolName,
43956
+ input: JSON.stringify(part.input),
43957
+ providerMetadata: {
43958
+ [providerOptionsName]: {
43959
+ itemId: part.id
43960
+ }
43961
+ }
43962
+ });
43963
+ break;
43964
+ }
43827
43965
  case "web_search_call": {
43828
43966
  content.push({
43829
43967
  type: "tool-call",
@@ -44075,6 +44213,17 @@ var OpenAIResponsesLanguageModel = class {
44075
44213
  id: value.item.call_id,
44076
44214
  toolName: value.item.name
44077
44215
  });
44216
+ } else if (value.item.type === "custom_tool_call") {
44217
+ const toolName = toolNameMapping.toCustomToolName(value.item.name);
44218
+ ongoingToolCalls[value.output_index] = {
44219
+ toolName,
44220
+ toolCallId: value.item.call_id
44221
+ };
44222
+ controller.enqueue({
44223
+ type: "tool-input-start",
44224
+ id: value.item.call_id,
44225
+ toolName
44226
+ });
44078
44227
  } else if (value.item.type === "web_search_call") {
44079
44228
  ongoingToolCalls[value.output_index] = {
44080
44229
  toolName: toolNameMapping.toCustomToolName(webSearchToolName != null ? webSearchToolName : "web_search"),
@@ -44250,6 +44399,25 @@ var OpenAIResponsesLanguageModel = class {
44250
44399
  }
44251
44400
  }
44252
44401
  });
44402
+ } else if (value.item.type === "custom_tool_call") {
44403
+ ongoingToolCalls[value.output_index] = undefined;
44404
+ hasFunctionCall = true;
44405
+ const toolName = toolNameMapping.toCustomToolName(value.item.name);
44406
+ controller.enqueue({
44407
+ type: "tool-input-end",
44408
+ id: value.item.call_id
44409
+ });
44410
+ controller.enqueue({
44411
+ type: "tool-call",
44412
+ toolCallId: value.item.call_id,
44413
+ toolName,
44414
+ input: JSON.stringify(value.item.input),
44415
+ providerMetadata: {
44416
+ [providerOptionsName]: {
44417
+ itemId: value.item.id
44418
+ }
44419
+ }
44420
+ });
44253
44421
  } else if (value.item.type === "web_search_call") {
44254
44422
  ongoingToolCalls[value.output_index] = undefined;
44255
44423
  controller.enqueue({
@@ -44486,6 +44654,15 @@ var OpenAIResponsesLanguageModel = class {
44486
44654
  delta: value.delta
44487
44655
  });
44488
44656
  }
44657
+ } else if (isResponseCustomToolCallInputDeltaChunk(value)) {
44658
+ const toolCall = ongoingToolCalls[value.output_index];
44659
+ if (toolCall != null) {
44660
+ controller.enqueue({
44661
+ type: "tool-input-delta",
44662
+ id: toolCall.toolCallId,
44663
+ delta: value.delta
44664
+ });
44665
+ }
44489
44666
  } else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
44490
44667
  const toolCall = ongoingToolCalls[value.output_index];
44491
44668
  if (toolCall == null ? undefined : toolCall.applyPatch) {
@@ -44743,6 +44920,9 @@ function isResponseCreatedChunk(chunk) {
44743
44920
  function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
44744
44921
  return chunk.type === "response.function_call_arguments.delta";
44745
44922
  }
44923
+ function isResponseCustomToolCallInputDeltaChunk(chunk) {
44924
+ return chunk.type === "response.custom_tool_call_input.delta";
44925
+ }
44746
44926
  function isResponseImageGenerationCallPartialImageChunk(chunk) {
44747
44927
  return chunk.type === "response.image_generation_call.partial_image";
44748
44928
  }
@@ -44801,7 +44981,7 @@ var azureOpenaiTools = {
44801
44981
  imageGeneration,
44802
44982
  webSearchPreview
44803
44983
  };
44804
- var VERSION4 = "3.0.37";
44984
+ var VERSION4 = "3.0.39";
44805
44985
  function createAzure(options = {}) {
44806
44986
  var _a16;
44807
44987
  const getHeaders = () => {
@@ -47723,7 +47903,7 @@ var BedrockChatLanguageModel = class {
47723
47903
  toolChoice,
47724
47904
  providerOptions
47725
47905
  }) {
47726
- var _a16, _b16, _c, _d, _e, _f, _g, _h;
47906
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
47727
47907
  const bedrockOptions = (_a16 = await parseProviderOptions({
47728
47908
  provider: "bedrock",
47729
47909
  providerOptions,
@@ -47770,7 +47950,10 @@ var BedrockChatLanguageModel = class {
47770
47950
  details: "Only text and json response formats are supported."
47771
47951
  });
47772
47952
  }
47773
- const jsonResponseTool = (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null ? {
47953
+ const isAnthropicModel = this.modelId.includes("anthropic");
47954
+ const isThinkingEnabled = ((_b16 = bedrockOptions.reasoningConfig) == null ? undefined : _b16.type) === "enabled" || ((_c = bedrockOptions.reasoningConfig) == null ? undefined : _c.type) === "adaptive";
47955
+ const useNativeStructuredOutput = isAnthropicModel && isThinkingEnabled && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null;
47956
+ const jsonResponseTool = (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput ? {
47774
47957
  type: "function",
47775
47958
  name: "json",
47776
47959
  description: "Respond with a JSON object.",
@@ -47789,18 +47972,16 @@ var BedrockChatLanguageModel = class {
47789
47972
  };
47790
47973
  }
47791
47974
  if (betas.size > 0 || bedrockOptions.anthropicBeta) {
47792
- const existingBetas = (_b16 = bedrockOptions.anthropicBeta) != null ? _b16 : [];
47975
+ const existingBetas = (_d = bedrockOptions.anthropicBeta) != null ? _d : [];
47793
47976
  const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
47794
47977
  bedrockOptions.additionalModelRequestFields = {
47795
47978
  ...bedrockOptions.additionalModelRequestFields,
47796
47979
  anthropic_beta: mergedBetas
47797
47980
  };
47798
47981
  }
47799
- const isAnthropicModel = this.modelId.includes("anthropic");
47800
- const thinkingType = (_c = bedrockOptions.reasoningConfig) == null ? undefined : _c.type;
47801
- const isThinkingRequested = thinkingType === "enabled" || thinkingType === "adaptive";
47802
- const thinkingBudget = thinkingType === "enabled" ? (_d = bedrockOptions.reasoningConfig) == null ? undefined : _d.budgetTokens : undefined;
47803
- const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
47982
+ const thinkingType = (_e = bedrockOptions.reasoningConfig) == null ? undefined : _e.type;
47983
+ const thinkingBudget = thinkingType === "enabled" ? (_f = bedrockOptions.reasoningConfig) == null ? undefined : _f.budgetTokens : undefined;
47984
+ const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingEnabled;
47804
47985
  const inferenceConfig = {
47805
47986
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
47806
47987
  ...temperature != null && { temperature },
@@ -47831,7 +48012,7 @@ var BedrockChatLanguageModel = class {
47831
48012
  };
47832
48013
  }
47833
48014
  } else if (!isAnthropicModel) {
47834
- if (((_e = bedrockOptions.reasoningConfig) == null ? undefined : _e.budgetTokens) != null) {
48015
+ if (((_g = bedrockOptions.reasoningConfig) == null ? undefined : _g.budgetTokens) != null) {
47835
48016
  warnings.push({
47836
48017
  type: "unsupported",
47837
48018
  feature: "budgetTokens",
@@ -47846,13 +48027,14 @@ var BedrockChatLanguageModel = class {
47846
48027
  });
47847
48028
  }
47848
48029
  }
47849
- const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? undefined : _f.maxReasoningEffort;
48030
+ const maxReasoningEffort = (_h = bedrockOptions.reasoningConfig) == null ? undefined : _h.maxReasoningEffort;
47850
48031
  const isOpenAIModel = this.modelId.startsWith("openai.");
47851
48032
  if (maxReasoningEffort != null) {
47852
48033
  if (isAnthropicModel) {
47853
48034
  bedrockOptions.additionalModelRequestFields = {
47854
48035
  ...bedrockOptions.additionalModelRequestFields,
47855
48036
  output_config: {
48037
+ ...(_i = bedrockOptions.additionalModelRequestFields) == null ? undefined : _i.output_config,
47856
48038
  effort: maxReasoningEffort
47857
48039
  }
47858
48040
  };
@@ -47872,6 +48054,18 @@ var BedrockChatLanguageModel = class {
47872
48054
  };
47873
48055
  }
47874
48056
  }
48057
+ if (useNativeStructuredOutput) {
48058
+ bedrockOptions.additionalModelRequestFields = {
48059
+ ...bedrockOptions.additionalModelRequestFields,
48060
+ output_config: {
48061
+ ...(_j = bedrockOptions.additionalModelRequestFields) == null ? undefined : _j.output_config,
48062
+ format: {
48063
+ type: "json_schema",
48064
+ schema: responseFormat.schema
48065
+ }
48066
+ }
48067
+ };
48068
+ }
47875
48069
  if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
47876
48070
  delete inferenceConfig.temperature;
47877
48071
  warnings.push({
@@ -47896,7 +48090,7 @@ var BedrockChatLanguageModel = class {
47896
48090
  details: "topK is not supported when thinking is enabled"
47897
48091
  });
47898
48092
  }
47899
- const hasAnyTools = ((_h = (_g = toolConfig.tools) == null ? undefined : _g.length) != null ? _h : 0) > 0 || additionalTools;
48093
+ const hasAnyTools = ((_l = (_k = toolConfig.tools) == null ? undefined : _k.length) != null ? _l : 0) > 0 || additionalTools;
47900
48094
  let filteredPrompt = prompt;
47901
48095
  if (!hasAnyTools) {
47902
48096
  const hasToolContent = prompt.some((message) => ("content" in message) && Array.isArray(message.content) && message.content.some((part) => part.type === "tool-call" || part.type === "tool-result"));
@@ -48780,7 +48974,7 @@ var bedrockImageResponseSchema = exports_external.object({
48780
48974
  details: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
48781
48975
  preview: exports_external.unknown().optional()
48782
48976
  });
48783
- var VERSION5 = "4.0.67";
48977
+ var VERSION5 = "4.0.70";
48784
48978
  function createSigV4FetchFunction(getCredentials, fetch2 = globalThis.fetch) {
48785
48979
  return async (input, init) => {
48786
48980
  var _a16, _b16;
@@ -49076,7 +49270,7 @@ function createBedrockProvider(config2, providerName) {
49076
49270
  }
49077
49271
 
49078
49272
  // node_modules/@ai-sdk/google/dist/index.mjs
49079
- var VERSION6 = "3.0.33";
49273
+ var VERSION6 = "3.0.35";
49080
49274
  var googleErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
49081
49275
  error: exports_external.object({
49082
49276
  code: exports_external.number().nullable(),
@@ -51900,7 +52094,7 @@ var browserSearch = createProviderToolFactory({
51900
52094
  var groqTools = {
51901
52095
  browserSearch
51902
52096
  };
51903
- var VERSION7 = "3.0.25";
52097
+ var VERSION7 = "3.0.26";
51904
52098
  function createGroq(options = {}) {
51905
52099
  var _a16;
51906
52100
  const baseURL = (_a16 = withoutTrailingSlash(options.baseURL)) != null ? _a16 : "https://api.groq.com/openai/v1";
@@ -53361,7 +53555,7 @@ var openaiFailedResponseHandler2 = createJsonErrorResponseHandler({
53361
53555
  function getOpenAILanguageModelCapabilities2(modelId) {
53362
53556
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
53363
53557
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
53364
- const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("codex-mini") || modelId.startsWith("computer-use-preview") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
53558
+ const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
53365
53559
  const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2");
53366
53560
  const systemMessageMode = isReasoningModel ? "developer" : "system";
53367
53561
  return {
@@ -55000,6 +55194,26 @@ var codeInterpreterToolFactory2 = createProviderToolFactoryWithOutputSchema({
55000
55194
  var codeInterpreter2 = (args = {}) => {
55001
55195
  return codeInterpreterToolFactory2(args);
55002
55196
  };
55197
+ var customArgsSchema2 = lazySchema(() => zodSchema(exports_external.object({
55198
+ name: exports_external.string(),
55199
+ description: exports_external.string().optional(),
55200
+ format: exports_external.union([
55201
+ exports_external.object({
55202
+ type: exports_external.literal("grammar"),
55203
+ syntax: exports_external.enum(["regex", "lark"]),
55204
+ definition: exports_external.string()
55205
+ }),
55206
+ exports_external.object({
55207
+ type: exports_external.literal("text")
55208
+ })
55209
+ ]).optional()
55210
+ })));
55211
+ var customInputSchema2 = lazySchema(() => zodSchema(exports_external.string()));
55212
+ var customToolFactory2 = createProviderToolFactory({
55213
+ id: "openai.custom",
55214
+ inputSchema: customInputSchema2
55215
+ });
55216
+ var customTool = (args) => customToolFactory2(args);
55003
55217
  var comparisonFilterSchema2 = exports_external.object({
55004
55218
  key: exports_external.string(),
55005
55219
  type: exports_external.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
@@ -55268,6 +55482,7 @@ var mcpToolFactory2 = createProviderToolFactoryWithOutputSchema({
55268
55482
  var mcp = (args) => mcpToolFactory2(args);
55269
55483
  var openaiTools = {
55270
55484
  applyPatch,
55485
+ customTool,
55271
55486
  codeInterpreter: codeInterpreter2,
55272
55487
  fileSearch: fileSearch3,
55273
55488
  imageGeneration: imageGeneration2,
@@ -55329,9 +55544,10 @@ async function convertToOpenAIResponsesInput2({
55329
55544
  hasConversation = false,
55330
55545
  hasLocalShellTool = false,
55331
55546
  hasShellTool = false,
55332
- hasApplyPatchTool = false
55547
+ hasApplyPatchTool = false,
55548
+ customProviderToolNames
55333
55549
  }) {
55334
- var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
55550
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
55335
55551
  const input = [];
55336
55552
  const warnings = [];
55337
55553
  const processedApprovalIds = /* @__PURE__ */ new Set;
@@ -55496,6 +55712,16 @@ async function convertToOpenAIResponsesInput2({
55496
55712
  });
55497
55713
  break;
55498
55714
  }
55715
+ if (customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) {
55716
+ input.push({
55717
+ type: "custom_tool_call",
55718
+ call_id: part.toolCallId,
55719
+ name: resolvedToolName,
55720
+ input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
55721
+ id
55722
+ });
55723
+ break;
55724
+ }
55499
55725
  input.push({
55500
55726
  type: "function_call",
55501
55727
  call_id: part.toolCallId,
@@ -55695,6 +55921,61 @@ async function convertToOpenAIResponsesInput2({
55695
55921
  });
55696
55922
  continue;
55697
55923
  }
55924
+ if (customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) {
55925
+ let outputValue;
55926
+ switch (output.type) {
55927
+ case "text":
55928
+ case "error-text":
55929
+ outputValue = output.value;
55930
+ break;
55931
+ case "execution-denied":
55932
+ outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
55933
+ break;
55934
+ case "json":
55935
+ case "error-json":
55936
+ outputValue = JSON.stringify(output.value);
55937
+ break;
55938
+ case "content":
55939
+ outputValue = output.value.map((item) => {
55940
+ var _a23;
55941
+ switch (item.type) {
55942
+ case "text":
55943
+ return { type: "input_text", text: item.text };
55944
+ case "image-data":
55945
+ return {
55946
+ type: "input_image",
55947
+ image_url: `data:${item.mediaType};base64,${item.data}`
55948
+ };
55949
+ case "image-url":
55950
+ return {
55951
+ type: "input_image",
55952
+ image_url: item.url
55953
+ };
55954
+ case "file-data":
55955
+ return {
55956
+ type: "input_file",
55957
+ filename: (_a23 = item.filename) != null ? _a23 : "data",
55958
+ file_data: `data:${item.mediaType};base64,${item.data}`
55959
+ };
55960
+ default:
55961
+ warnings.push({
55962
+ type: "other",
55963
+ message: `unsupported custom tool content part type: ${item.type}`
55964
+ });
55965
+ return;
55966
+ }
55967
+ }).filter(isNonNullable);
55968
+ break;
55969
+ default:
55970
+ outputValue = "";
55971
+ }
55972
+ input.push({
55973
+ type: "custom_tool_call_output",
55974
+ call_id: part.toolCallId,
55975
+ output: outputValue
55976
+ });
55977
+ continue;
55978
+ }
55698
55979
  let contentValue;
55699
55980
  switch (output.type) {
55700
55981
  case "text":
@@ -55702,7 +55983,7 @@ async function convertToOpenAIResponsesInput2({
55702
55983
  contentValue = output.value;
55703
55984
  break;
55704
55985
  case "execution-denied":
55705
- contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
55986
+ contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
55706
55987
  break;
55707
55988
  case "json":
55708
55989
  case "error-json":
@@ -55903,6 +56184,13 @@ var openaiResponsesChunkSchema2 = lazySchema(() => zodSchema(exports_external.un
55903
56184
  })
55904
56185
  ])
55905
56186
  }),
56187
+ exports_external.object({
56188
+ type: exports_external.literal("custom_tool_call"),
56189
+ id: exports_external.string(),
56190
+ call_id: exports_external.string(),
56191
+ name: exports_external.string(),
56192
+ input: exports_external.string()
56193
+ }),
55906
56194
  exports_external.object({
55907
56195
  type: exports_external.literal("shell_call"),
55908
56196
  id: exports_external.string(),
@@ -55953,6 +56241,14 @@ var openaiResponsesChunkSchema2 = lazySchema(() => zodSchema(exports_external.un
55953
56241
  arguments: exports_external.string(),
55954
56242
  status: exports_external.literal("completed")
55955
56243
  }),
56244
+ exports_external.object({
56245
+ type: exports_external.literal("custom_tool_call"),
56246
+ id: exports_external.string(),
56247
+ call_id: exports_external.string(),
56248
+ name: exports_external.string(),
56249
+ input: exports_external.string(),
56250
+ status: exports_external.literal("completed")
56251
+ }),
55956
56252
  exports_external.object({
55957
56253
  type: exports_external.literal("code_interpreter_call"),
55958
56254
  id: exports_external.string(),
@@ -56123,6 +56419,12 @@ var openaiResponsesChunkSchema2 = lazySchema(() => zodSchema(exports_external.un
56123
56419
  output_index: exports_external.number(),
56124
56420
  delta: exports_external.string()
56125
56421
  }),
56422
+ exports_external.object({
56423
+ type: exports_external.literal("response.custom_tool_call_input.delta"),
56424
+ item_id: exports_external.string(),
56425
+ output_index: exports_external.number(),
56426
+ delta: exports_external.string()
56427
+ }),
56126
56428
  exports_external.object({
56127
56429
  type: exports_external.literal("response.image_generation_call.partial_image"),
56128
56430
  item_id: exports_external.string(),
@@ -56347,6 +56649,13 @@ var openaiResponsesResponseSchema2 = lazySchema(() => zodSchema(exports_external
56347
56649
  arguments: exports_external.string(),
56348
56650
  id: exports_external.string()
56349
56651
  }),
56652
+ exports_external.object({
56653
+ type: exports_external.literal("custom_tool_call"),
56654
+ call_id: exports_external.string(),
56655
+ name: exports_external.string(),
56656
+ input: exports_external.string(),
56657
+ id: exports_external.string()
56658
+ }),
56350
56659
  exports_external.object({
56351
56660
  type: exports_external.literal("computer_call"),
56352
56661
  id: exports_external.string(),
@@ -56470,16 +56779,10 @@ var openaiResponsesReasoningModelIds2 = [
56470
56779
  "o1-2024-12-17",
56471
56780
  "o3",
56472
56781
  "o3-2025-04-16",
56473
- "o3-deep-research",
56474
- "o3-deep-research-2025-06-26",
56475
56782
  "o3-mini",
56476
56783
  "o3-mini-2025-01-31",
56477
56784
  "o4-mini",
56478
56785
  "o4-mini-2025-04-16",
56479
- "o4-mini-deep-research",
56480
- "o4-mini-deep-research-2025-06-26",
56481
- "codex-mini-latest",
56482
- "computer-use-preview",
56483
56786
  "gpt-5",
56484
56787
  "gpt-5-2025-08-07",
56485
56788
  "gpt-5-codex",
@@ -56512,7 +56815,6 @@ var openaiResponsesModelIds2 = [
56512
56815
  "gpt-4o-2024-08-06",
56513
56816
  "gpt-4o-2024-11-20",
56514
56817
  "gpt-4o-audio-preview",
56515
- "gpt-4o-audio-preview-2024-10-01",
56516
56818
  "gpt-4o-audio-preview-2024-12-17",
56517
56819
  "gpt-4o-search-preview",
56518
56820
  "gpt-4o-search-preview-2025-03-11",
@@ -56520,19 +56822,9 @@ var openaiResponsesModelIds2 = [
56520
56822
  "gpt-4o-mini-search-preview-2025-03-11",
56521
56823
  "gpt-4o-mini",
56522
56824
  "gpt-4o-mini-2024-07-18",
56523
- "gpt-4-turbo",
56524
- "gpt-4-turbo-2024-04-09",
56525
- "gpt-4-turbo-preview",
56526
- "gpt-4-0125-preview",
56527
- "gpt-4-1106-preview",
56528
- "gpt-4",
56529
- "gpt-4-0613",
56530
- "gpt-4.5-preview",
56531
- "gpt-4.5-preview-2025-02-27",
56532
56825
  "gpt-3.5-turbo-0125",
56533
56826
  "gpt-3.5-turbo",
56534
56827
  "gpt-3.5-turbo-1106",
56535
- "chatgpt-4o-latest",
56536
56828
  "gpt-5-chat-latest",
56537
56829
  ...openaiResponsesReasoningModelIds2
56538
56830
  ];
@@ -56565,14 +56857,18 @@ var openaiLanguageModelResponsesOptionsSchema2 = lazySchema(() => zodSchema(expo
56565
56857
  })));
56566
56858
  async function prepareResponsesTools3({
56567
56859
  tools,
56568
- toolChoice
56860
+ toolChoice,
56861
+ toolNameMapping,
56862
+ customProviderToolNames
56569
56863
  }) {
56864
+ var _a16;
56570
56865
  tools = (tools == null ? undefined : tools.length) ? tools : undefined;
56571
56866
  const toolWarnings = [];
56572
56867
  if (tools == null) {
56573
56868
  return { tools: undefined, toolChoice: undefined, toolWarnings };
56574
56869
  }
56575
56870
  const openaiTools2 = [];
56871
+ const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set;
56576
56872
  for (const tool2 of tools) {
56577
56873
  switch (tool2.type) {
56578
56874
  case "function":
@@ -56714,6 +57010,20 @@ async function prepareResponsesTools3({
56714
57010
  });
56715
57011
  break;
56716
57012
  }
57013
+ case "openai.custom": {
57014
+ const args = await validateTypes({
57015
+ value: tool2.args,
57016
+ schema: customArgsSchema2
57017
+ });
57018
+ openaiTools2.push({
57019
+ type: "custom",
57020
+ name: args.name,
57021
+ description: args.description,
57022
+ format: args.format
57023
+ });
57024
+ resolvedCustomProviderToolNames.add(args.name);
57025
+ break;
57026
+ }
56717
57027
  }
56718
57028
  break;
56719
57029
  }
@@ -56734,12 +57044,14 @@ async function prepareResponsesTools3({
56734
57044
  case "none":
56735
57045
  case "required":
56736
57046
  return { tools: openaiTools2, toolChoice: type, toolWarnings };
56737
- case "tool":
57047
+ case "tool": {
57048
+ const resolvedToolName = (_a16 = toolNameMapping == null ? undefined : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a16 : toolChoice.toolName;
56738
57049
  return {
56739
57050
  tools: openaiTools2,
56740
- toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" || toolChoice.toolName === "mcp" || toolChoice.toolName === "apply_patch" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
57051
+ toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
56741
57052
  toolWarnings
56742
57053
  };
57054
+ }
56743
57055
  default: {
56744
57056
  const _exhaustiveCheck = type;
56745
57057
  throw new UnsupportedFunctionalityError({
@@ -56888,7 +57200,19 @@ var OpenAIResponsesLanguageModel2 = class {
56888
57200
  "openai.web_search_preview": "web_search_preview",
56889
57201
  "openai.mcp": "mcp",
56890
57202
  "openai.apply_patch": "apply_patch"
56891
- }
57203
+ },
57204
+ resolveProviderToolName: (tool2) => tool2.id === "openai.custom" ? tool2.args.name : undefined
57205
+ });
57206
+ const customProviderToolNames = /* @__PURE__ */ new Set;
57207
+ const {
57208
+ tools: openaiTools2,
57209
+ toolChoice: openaiToolChoice,
57210
+ toolWarnings
57211
+ } = await prepareResponsesTools3({
57212
+ tools,
57213
+ toolChoice,
57214
+ toolNameMapping,
57215
+ customProviderToolNames
56892
57216
  });
56893
57217
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput2({
56894
57218
  prompt,
@@ -56900,7 +57224,8 @@ var OpenAIResponsesLanguageModel2 = class {
56900
57224
  hasConversation: (openaiOptions == null ? undefined : openaiOptions.conversation) != null,
56901
57225
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
56902
57226
  hasShellTool: hasOpenAITool("openai.shell"),
56903
- hasApplyPatchTool: hasOpenAITool("openai.apply_patch")
57227
+ hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
57228
+ customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : undefined
56904
57229
  });
56905
57230
  warnings.push(...inputWarnings);
56906
57231
  const strictJsonSchema = (_d = openaiOptions == null ? undefined : openaiOptions.strictJsonSchema) != null ? _d : true;
@@ -57029,14 +57354,6 @@ var OpenAIResponsesLanguageModel2 = class {
57029
57354
  });
57030
57355
  delete baseArgs.service_tier;
57031
57356
  }
57032
- const {
57033
- tools: openaiTools2,
57034
- toolChoice: openaiToolChoice,
57035
- toolWarnings
57036
- } = await prepareResponsesTools3({
57037
- tools,
57038
- toolChoice
57039
- });
57040
57357
  const shellToolEnvType = (_i = (_h = (_g = tools == null ? undefined : tools.find((tool2) => tool2.type === "provider" && tool2.id === "openai.shell")) == null ? undefined : _g.args) == null ? undefined : _h.environment) == null ? undefined : _i.type;
57041
57358
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
57042
57359
  return {
@@ -57282,6 +57599,22 @@ var OpenAIResponsesLanguageModel2 = class {
57282
57599
  });
57283
57600
  break;
57284
57601
  }
57602
+ case "custom_tool_call": {
57603
+ hasFunctionCall = true;
57604
+ const toolName = toolNameMapping.toCustomToolName(part.name);
57605
+ content.push({
57606
+ type: "tool-call",
57607
+ toolCallId: part.call_id,
57608
+ toolName,
57609
+ input: JSON.stringify(part.input),
57610
+ providerMetadata: {
57611
+ [providerOptionsName]: {
57612
+ itemId: part.id
57613
+ }
57614
+ }
57615
+ });
57616
+ break;
57617
+ }
57285
57618
  case "web_search_call": {
57286
57619
  content.push({
57287
57620
  type: "tool-call",
@@ -57533,6 +57866,17 @@ var OpenAIResponsesLanguageModel2 = class {
57533
57866
  id: value.item.call_id,
57534
57867
  toolName: value.item.name
57535
57868
  });
57869
+ } else if (value.item.type === "custom_tool_call") {
57870
+ const toolName = toolNameMapping.toCustomToolName(value.item.name);
57871
+ ongoingToolCalls[value.output_index] = {
57872
+ toolName,
57873
+ toolCallId: value.item.call_id
57874
+ };
57875
+ controller.enqueue({
57876
+ type: "tool-input-start",
57877
+ id: value.item.call_id,
57878
+ toolName
57879
+ });
57536
57880
  } else if (value.item.type === "web_search_call") {
57537
57881
  ongoingToolCalls[value.output_index] = {
57538
57882
  toolName: toolNameMapping.toCustomToolName(webSearchToolName != null ? webSearchToolName : "web_search"),
@@ -57708,6 +58052,25 @@ var OpenAIResponsesLanguageModel2 = class {
57708
58052
  }
57709
58053
  }
57710
58054
  });
58055
+ } else if (value.item.type === "custom_tool_call") {
58056
+ ongoingToolCalls[value.output_index] = undefined;
58057
+ hasFunctionCall = true;
58058
+ const toolName = toolNameMapping.toCustomToolName(value.item.name);
58059
+ controller.enqueue({
58060
+ type: "tool-input-end",
58061
+ id: value.item.call_id
58062
+ });
58063
+ controller.enqueue({
58064
+ type: "tool-call",
58065
+ toolCallId: value.item.call_id,
58066
+ toolName,
58067
+ input: JSON.stringify(value.item.input),
58068
+ providerMetadata: {
58069
+ [providerOptionsName]: {
58070
+ itemId: value.item.id
58071
+ }
58072
+ }
58073
+ });
57711
58074
  } else if (value.item.type === "web_search_call") {
57712
58075
  ongoingToolCalls[value.output_index] = undefined;
57713
58076
  controller.enqueue({
@@ -57944,6 +58307,15 @@ var OpenAIResponsesLanguageModel2 = class {
57944
58307
  delta: value.delta
57945
58308
  });
57946
58309
  }
58310
+ } else if (isResponseCustomToolCallInputDeltaChunk2(value)) {
58311
+ const toolCall = ongoingToolCalls[value.output_index];
58312
+ if (toolCall != null) {
58313
+ controller.enqueue({
58314
+ type: "tool-input-delta",
58315
+ id: toolCall.toolCallId,
58316
+ delta: value.delta
58317
+ });
58318
+ }
57947
58319
  } else if (isResponseApplyPatchCallOperationDiffDeltaChunk2(value)) {
57948
58320
  const toolCall = ongoingToolCalls[value.output_index];
57949
58321
  if (toolCall == null ? undefined : toolCall.applyPatch) {
@@ -58201,6 +58573,9 @@ function isResponseCreatedChunk2(chunk) {
58201
58573
  function isResponseFunctionCallArgumentsDeltaChunk2(chunk) {
58202
58574
  return chunk.type === "response.function_call_arguments.delta";
58203
58575
  }
58576
+ function isResponseCustomToolCallInputDeltaChunk2(chunk) {
58577
+ return chunk.type === "response.custom_tool_call_input.delta";
58578
+ }
58204
58579
  function isResponseImageGenerationCallPartialImageChunk2(chunk) {
58205
58580
  return chunk.type === "response.image_generation_call.partial_image";
58206
58581
  }
@@ -58540,7 +58915,7 @@ var OpenAITranscriptionModel2 = class {
58540
58915
  };
58541
58916
  }
58542
58917
  };
58543
- var VERSION8 = "3.0.36";
58918
+ var VERSION8 = "3.0.38";
58544
58919
  function createOpenAI(options = {}) {
58545
58920
  var _a16, _b16;
58546
58921
  const baseURL = (_a16 = withoutTrailingSlash(loadOptionalSetting({
@@ -60088,7 +60463,7 @@ async function fileToBlob3(file2) {
60088
60463
  function toCamelCase(str) {
60089
60464
  return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
60090
60465
  }
60091
- var VERSION9 = "2.0.30";
60466
+ var VERSION9 = "2.0.31";
60092
60467
  function createOpenAICompatible(options) {
60093
60468
  const baseURL = withoutTrailingSlash(options.baseURL);
60094
60469
  const providerName = options.name;
@@ -61367,7 +61742,7 @@ async function getVercelRequestId() {
61367
61742
  var _a92;
61368
61743
  return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
61369
61744
  }
61370
- var VERSION10 = "3.0.57";
61745
+ var VERSION10 = "3.0.60";
61371
61746
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
61372
61747
  function createGatewayProvider(options = {}) {
61373
61748
  var _a92, _b92;
@@ -62113,7 +62488,7 @@ function detectMediaType({
62113
62488
  }
62114
62489
  return;
62115
62490
  }
62116
- var VERSION11 = "6.0.103";
62491
+ var VERSION11 = "6.0.106";
62117
62492
  var download = async ({
62118
62493
  url: url2,
62119
62494
  maxBytes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hongymagic/q",
3
- "version": "2026.302.0-next.db67a88",
3
+ "version": "2026.303.0-next.8a37ded",
4
4
  "description": "Quick AI answers from the command line",
5
5
  "main": "dist/q.js",
6
6
  "type": "module",
@@ -33,6 +33,7 @@
33
33
  "scripts": {
34
34
  "start": "bun run src/cli.ts",
35
35
  "test": "vitest run",
36
+ "test:coverage": "vitest run --coverage",
36
37
  "test:watch": "vitest",
37
38
  "typecheck": "tsc --noEmit",
38
39
  "lint": "biome check .",
@@ -49,23 +50,24 @@
49
50
  "release:dry": "bun run scripts/release.ts --dry-run"
50
51
  },
51
52
  "dependencies": {
52
- "@ai-sdk/amazon-bedrock": "4.0.67",
53
- "@ai-sdk/anthropic": "3.0.48",
54
- "@ai-sdk/azure": "3.0.37",
55
- "@ai-sdk/google": "3.0.33",
56
- "@ai-sdk/groq": "3.0.25",
57
- "@ai-sdk/openai": "3.0.36",
58
- "@ai-sdk/openai-compatible": "2.0.30",
53
+ "@ai-sdk/amazon-bedrock": "4.0.70",
54
+ "@ai-sdk/anthropic": "3.0.51",
55
+ "@ai-sdk/azure": "3.0.39",
56
+ "@ai-sdk/google": "3.0.35",
57
+ "@ai-sdk/groq": "3.0.26",
58
+ "@ai-sdk/openai": "3.0.38",
59
+ "@ai-sdk/openai-compatible": "2.0.31",
59
60
  "@t3-oss/env-core": "0.13.10",
60
- "ai": "6.0.103",
61
+ "ai": "6.0.106",
61
62
  "clipboardy": "5.3.1",
62
63
  "ollama-ai-provider-v2": "3.3.1",
63
64
  "zod": "4.3.6"
64
65
  },
65
66
  "devDependencies": {
66
- "@biomejs/biome": "2.4.4",
67
+ "@biomejs/biome": "2.4.5",
67
68
  "@types/bun": "1.3.9",
68
- "lefthook": "2.1.1",
69
+ "@vitest/coverage-v8": "4.0.18",
70
+ "lefthook": "2.1.2",
69
71
  "typescript": "5.9.3",
70
72
  "vitest": "4.0.18"
71
73
  }