omnigateway 0.4.12 → 0.4.13

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 (25) hide show
  1. package/README.md +86 -238
  2. package/bin/omni.js +868 -377
  3. package/gateway.js +864 -348
  4. package/package.json +1 -1
  5. package/public/assets/{CopyValue-By5BAgv7.js → CopyValue-C2DkO9Yz.js} +1 -1
  6. package/public/assets/{Rack-fDZClWZL.js → Rack-HM36SprU.js} +1 -1
  7. package/public/assets/{Toggle-ClEeOh0F.js → Toggle-CRrH9nDt.js} +1 -1
  8. package/public/assets/{TokenBreakdown-D70VeZ2N.js → TokenBreakdown-C2NsJnqO.js} +1 -1
  9. package/public/assets/{_app-CDPKnQ72.js → _app-DVpIsUid.js} +1 -1
  10. package/public/assets/{_app.accounts-Dz0ox4Br.js → _app.accounts-64d_cxir.js} +2 -2
  11. package/public/assets/{_app.console-hPUmmYjp.js → _app.console-BBuBmLRI.js} +1 -1
  12. package/public/assets/{_app.database-DGtP4NdG.js → _app.database-J9Ujio8l.js} +1 -1
  13. package/public/assets/{_app.index-COcCAmbH.js → _app.index-BX4yKEXO.js} +1 -1
  14. package/public/assets/{_app.keys-yTXTbKTA.js → _app.keys-2sKwhZJc.js} +1 -1
  15. package/public/assets/{_app.logs-BhMvO_Fx.js → _app.logs-DuHXYrZU.js} +1 -1
  16. package/public/assets/{_app.models-0S3rurIl.js → _app.models-B0kTfPtn.js} +1 -1
  17. package/public/assets/{_app.plugins._pluginId-B-ZDQNPU.js → _app.plugins._pluginId-BOXRBToU.js} +1 -1
  18. package/public/assets/{_app.settings-DTnFwTeA.js → _app.settings-DoaOUmc1.js} +1 -1
  19. package/public/assets/{_app.usage-C2-VLiq9.js → _app.usage-B5sxB40E.js} +1 -1
  20. package/public/assets/{index-COwhxKU7.js → index-iCfSaRSG.js} +2 -2
  21. package/public/assets/{login-DjfMomJJ.js → login-B9CJqU--.js} +1 -1
  22. package/public/assets/plus-DKapAGoR.js +1 -0
  23. package/public/assets/{trash-2-U2ViYZum.js → trash-2-DwMK-JrZ.js} +1 -1
  24. package/public/index.html +1 -1
  25. package/public/assets/plus-UDQ_BTEr.js +0 -1
package/gateway.js CHANGED
@@ -4683,8 +4683,8 @@ class FileTypeParser {
4683
4683
  if (jsonSize > 12 && this.buffer.length >= jsonSize + 16) {
4684
4684
  try {
4685
4685
  const header = new TextDecoder().decode(this.buffer.subarray(16, jsonSize + 16));
4686
- const json7 = JSON.parse(header);
4687
- if (json7.files) {
4686
+ const json8 = JSON.parse(header);
4687
+ if (json8.files) {
4688
4688
  return {
4689
4689
  ext: "asar",
4690
4690
  mime: "application/x-asar"
@@ -5523,6 +5523,15 @@ function parseLogLevel(value) {
5523
5523
  function cacheControlOf(block) {
5524
5524
  return block.type === "thinking" ? undefined : block.cacheControl;
5525
5525
  }
5526
+ var REASONING_EFFORTS = [
5527
+ "none",
5528
+ "minimal",
5529
+ "low",
5530
+ "medium",
5531
+ "high",
5532
+ "xhigh",
5533
+ "max"
5534
+ ];
5526
5535
  // packages/ir/src/stream.ts
5527
5536
  function usageFromPromptTotal(promptTokens, outputTokens, cacheReadTokens, cacheWriteTokens = 0) {
5528
5537
  return {
@@ -7502,13 +7511,31 @@ var anthropicAdapter = {
7502
7511
  };
7503
7512
  }
7504
7513
  };
7505
- // packages/providers/src/kimi/decode.ts
7506
- var FINISH = {
7514
+ // packages/providers/src/custom/decode.ts
7515
+ var CHAT_FINISH = {
7507
7516
  stop: "endTurn",
7508
7517
  length: "maxTokens",
7509
7518
  tool_calls: "toolUse",
7510
7519
  content_filter: "contentFilter"
7511
7520
  };
7521
+ function reasoningText(delta) {
7522
+ if (typeof delta.reasoning === "string" && delta.reasoning.length > 0)
7523
+ return delta.reasoning;
7524
+ if (typeof delta.reasoning_content === "string" && delta.reasoning_content.length > 0) {
7525
+ return delta.reasoning_content;
7526
+ }
7527
+ if (!Array.isArray(delta.reasoning_details))
7528
+ return "";
7529
+ return delta.reasoning_details.flatMap((entry) => {
7530
+ if (entry === null || typeof entry !== "object")
7531
+ return [];
7532
+ if (typeof entry.text === "string" && entry.text.length > 0)
7533
+ return [entry.text];
7534
+ if (typeof entry.summary === "string" && entry.summary.length > 0)
7535
+ return [entry.summary];
7536
+ return [];
7537
+ }).join("");
7538
+ }
7512
7539
  function json2(data) {
7513
7540
  try {
7514
7541
  const v = JSON.parse(data);
@@ -7517,7 +7544,7 @@ function json2(data) {
7517
7544
  return null;
7518
7545
  }
7519
7546
  }
7520
- async function* decodeChat(messages) {
7547
+ async function* decodeCustomChat(messages) {
7521
7548
  let started = false;
7522
7549
  let done = false;
7523
7550
  let stopReason = "endTurn";
@@ -7546,6 +7573,21 @@ async function* decodeChat(messages) {
7546
7573
  if (!choice)
7547
7574
  continue;
7548
7575
  const delta = choice.delta ?? {};
7576
+ const reasoning = reasoningText(delta);
7577
+ if (reasoning.length > 0) {
7578
+ if (openKind !== "thinking") {
7579
+ if (openKind !== undefined)
7580
+ yield { type: "blockEnd", index: openIndex };
7581
+ openKind = "thinking";
7582
+ openIndex = nextIndex++;
7583
+ yield { type: "blockStart", index: openIndex, block: { type: "thinking" } };
7584
+ }
7585
+ yield {
7586
+ type: "blockDelta",
7587
+ index: openIndex,
7588
+ delta: { type: "thinking", text: reasoning }
7589
+ };
7590
+ }
7549
7591
  if (typeof delta.content === "string" && delta.content.length > 0) {
7550
7592
  if (openKind !== "text") {
7551
7593
  if (openKind !== undefined)
@@ -7586,7 +7628,7 @@ async function* decodeChat(messages) {
7586
7628
  }
7587
7629
  }
7588
7630
  if (typeof choice.finish_reason === "string") {
7589
- stopReason = FINISH[choice.finish_reason] ?? "endTurn";
7631
+ stopReason = CHAT_FINISH[choice.finish_reason] ?? "endTurn";
7590
7632
  }
7591
7633
  }
7592
7634
  if (done) {
@@ -7602,110 +7644,7 @@ async function* decodeChat(messages) {
7602
7644
  };
7603
7645
  }
7604
7646
  }
7605
-
7606
- // packages/providers/src/kimi/wire.ts
7607
- function encodeToolChoice2(c) {
7608
- switch (c.type) {
7609
- case "auto":
7610
- return "auto";
7611
- case "any":
7612
- return "required";
7613
- case "none":
7614
- return "none";
7615
- case "tool":
7616
- return { type: "function", function: { name: c.name } };
7617
- }
7618
- }
7619
- function toChatWire(req, model, vendor = "kimi") {
7620
- const degradations = [];
7621
- const note = (d) => {
7622
- if (!degradations.includes(d))
7623
- degradations.push(d);
7624
- };
7625
- if (req.betas?.includes(CONTEXT_1M_BETA))
7626
- note("kimi:context-1m-dropped");
7627
- const messages = [];
7628
- const system = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
7629
-
7630
- `);
7631
- if (system !== undefined && system.length > 0)
7632
- messages.push({ role: "system", content: system });
7633
- for (const message of req.messages) {
7634
- const text = [];
7635
- const toolCalls = [];
7636
- for (const block of message.content) {
7637
- switch (block.type) {
7638
- case "text":
7639
- text.push(block.text);
7640
- break;
7641
- case "image":
7642
- note("kimi:images-dropped");
7643
- break;
7644
- case "thinking":
7645
- note("kimi:thinking-dropped");
7646
- break;
7647
- case "toolUse":
7648
- toolCalls.push({
7649
- id: block.id,
7650
- type: "function",
7651
- function: { name: block.name, arguments: JSON.stringify(block.input) }
7652
- });
7653
- break;
7654
- case "toolResult":
7655
- messages.push({
7656
- role: "tool",
7657
- tool_call_id: block.toolUseId,
7658
- content: block.content
7659
- });
7660
- break;
7661
- case "anthropicNative":
7662
- note("kimi:anthropic-native-block-dropped");
7663
- break;
7664
- }
7665
- }
7666
- if (toolCalls.length > 0) {
7667
- messages.push({
7668
- role: message.role,
7669
- content: text.length > 0 ? text.join(`
7670
- `) : null,
7671
- tool_calls: toolCalls
7672
- });
7673
- } else if (text.length > 0) {
7674
- messages.push({ role: message.role, content: text.join(`
7675
- `) });
7676
- }
7677
- }
7678
- const body = {
7679
- model,
7680
- messages,
7681
- stream: req.stream,
7682
- stream_options: { include_usage: true }
7683
- };
7684
- if (req.maxTokens !== undefined)
7685
- body.max_tokens = req.maxTokens;
7686
- if (req.temperature !== undefined)
7687
- body.temperature = req.temperature;
7688
- if (req.stopSequences !== undefined)
7689
- body.stop = req.stopSequences;
7690
- if (req.tools !== undefined) {
7691
- const custom = req.tools.filter((t) => t.provider === "custom");
7692
- if (custom.length !== req.tools.length)
7693
- note("kimi:anthropic-tool-dropped");
7694
- body.tools = custom.map((t) => ({
7695
- type: "function",
7696
- function: { name: t.name, description: t.description, parameters: t.inputSchema }
7697
- }));
7698
- }
7699
- if (req.toolChoice !== undefined)
7700
- body.tool_choice = encodeToolChoice2(req.toolChoice);
7701
- if (req.reasoning !== undefined)
7702
- note("kimi:reasoning-dropped");
7703
- Object.assign(body, req.vendor?.[vendor] ?? {});
7704
- return { body, degradations };
7705
- }
7706
-
7707
- // packages/providers/src/openai/decode.ts
7708
- var ERROR_CODE = {
7647
+ var RESPONSES_ERROR_CODE = {
7709
7648
  rate_limit_exceeded: "RATE_LIMIT",
7710
7649
  insufficient_quota: "QUOTA_EXHAUSTED",
7711
7650
  invalid_api_key: "AUTH",
@@ -7713,15 +7652,7 @@ var ERROR_CODE = {
7713
7652
  context_length_exceeded: "BAD_REQUEST",
7714
7653
  content_policy_violation: "CONTENT_FILTER"
7715
7654
  };
7716
- function json3(data) {
7717
- try {
7718
- const v = JSON.parse(data);
7719
- return typeof v === "object" && v !== null ? v : null;
7720
- } catch {
7721
- return null;
7722
- }
7723
- }
7724
- async function* decodeResponses(messages) {
7655
+ async function* decodeCustomResponses(messages) {
7725
7656
  const indices = new Map;
7726
7657
  let next = 0;
7727
7658
  const irIndex = (outputIndex, contentIndex = 0) => {
@@ -7737,7 +7668,7 @@ async function* decodeResponses(messages) {
7737
7668
  let terminal = false;
7738
7669
  const ownsBlock = new Set;
7739
7670
  for await (const msg of messages) {
7740
- const d = json3(msg.data);
7671
+ const d = json2(msg.data);
7741
7672
  if (d === null)
7742
7673
  continue;
7743
7674
  switch (msg.event) {
@@ -7829,7 +7760,7 @@ async function* decodeResponses(messages) {
7829
7760
  case "error": {
7830
7761
  terminal = true;
7831
7762
  const err = d.response?.error ?? d.error ?? {};
7832
- const code = ERROR_CODE[String(err.code ?? err.type)] ?? "UPSTREAM";
7763
+ const code = RESPONSES_ERROR_CODE[String(err.code ?? err.type)] ?? "UPSTREAM";
7833
7764
  yield {
7834
7765
  type: "error",
7835
7766
  code,
@@ -7852,8 +7783,20 @@ async function* decodeResponses(messages) {
7852
7783
  }
7853
7784
  }
7854
7785
 
7855
- // packages/providers/src/openai/wire.ts
7856
- function encodeToolChoice3(c) {
7786
+ // packages/providers/src/custom/wire.ts
7787
+ function encodeChatToolChoice(c) {
7788
+ switch (c.type) {
7789
+ case "auto":
7790
+ return "auto";
7791
+ case "any":
7792
+ return "required";
7793
+ case "none":
7794
+ return "none";
7795
+ case "tool":
7796
+ return { type: "function", function: { name: c.name } };
7797
+ }
7798
+ }
7799
+ function encodeResponsesToolChoice(c) {
7857
7800
  switch (c.type) {
7858
7801
  case "auto":
7859
7802
  return "auto";
@@ -7865,20 +7808,115 @@ function encodeToolChoice3(c) {
7865
7808
  return { type: "function", name: c.name };
7866
7809
  }
7867
7810
  }
7868
- function toResponsesWire(req, model, opts = { oauth: false }) {
7811
+ function customEffort(reasoning) {
7812
+ if (reasoning === undefined || reasoning.mode !== "adaptive")
7813
+ return;
7814
+ return reasoning.effort ?? "medium";
7815
+ }
7816
+ function toCustomChatWire(req, model) {
7869
7817
  const degradations = [];
7870
- const input = [];
7871
7818
  const note = (d) => {
7872
7819
  if (!degradations.includes(d))
7873
7820
  degradations.push(d);
7874
7821
  };
7875
7822
  if (req.betas?.includes(CONTEXT_1M_BETA))
7876
- note("openai:context-1m-dropped");
7823
+ note("custom:context-1m-dropped");
7824
+ const messages = [];
7825
+ const system = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
7826
+
7827
+ `);
7828
+ if (system !== undefined && system.length > 0)
7829
+ messages.push({ role: "system", content: system });
7830
+ for (const message of req.messages) {
7831
+ const text = [];
7832
+ const toolCalls = [];
7833
+ for (const block of message.content) {
7834
+ switch (block.type) {
7835
+ case "text":
7836
+ text.push(block.text);
7837
+ break;
7838
+ case "image":
7839
+ note("custom:images-dropped");
7840
+ break;
7841
+ case "thinking":
7842
+ note("custom:thinking-dropped");
7843
+ break;
7844
+ case "toolUse":
7845
+ toolCalls.push({
7846
+ id: block.id,
7847
+ type: "function",
7848
+ function: { name: block.name, arguments: JSON.stringify(block.input) }
7849
+ });
7850
+ break;
7851
+ case "toolResult":
7852
+ messages.push({
7853
+ role: "tool",
7854
+ tool_call_id: block.toolUseId,
7855
+ content: block.content
7856
+ });
7857
+ break;
7858
+ case "anthropicNative":
7859
+ note("custom:anthropic-native-block-dropped");
7860
+ break;
7861
+ }
7862
+ }
7863
+ if (toolCalls.length > 0) {
7864
+ messages.push({
7865
+ role: message.role,
7866
+ content: text.length > 0 ? text.join(`
7867
+ `) : null,
7868
+ tool_calls: toolCalls
7869
+ });
7870
+ } else if (text.length > 0) {
7871
+ messages.push({ role: message.role, content: text.join(`
7872
+ `) });
7873
+ }
7874
+ }
7875
+ const body = {
7876
+ model,
7877
+ messages,
7878
+ stream: req.stream,
7879
+ stream_options: { include_usage: true }
7880
+ };
7881
+ if (req.maxTokens !== undefined)
7882
+ body.max_tokens = req.maxTokens;
7883
+ if (req.temperature !== undefined)
7884
+ body.temperature = req.temperature;
7885
+ if (req.stopSequences !== undefined)
7886
+ body.stop = req.stopSequences;
7887
+ if (req.tools !== undefined) {
7888
+ const portable = req.tools.filter((t) => t.provider === "custom");
7889
+ if (portable.length !== req.tools.length)
7890
+ note("custom:anthropic-tool-dropped");
7891
+ body.tools = portable.map((t) => ({
7892
+ type: "function",
7893
+ function: { name: t.name, description: t.description, parameters: t.inputSchema }
7894
+ }));
7895
+ }
7896
+ if (req.toolChoice !== undefined)
7897
+ body.tool_choice = encodeChatToolChoice(req.toolChoice);
7898
+ const effort = customEffort(req.reasoning);
7899
+ if (effort !== undefined)
7900
+ body.reasoning_effort = effort;
7901
+ else if (req.reasoning?.mode === "budget")
7902
+ note("custom:reasoning-budget-dropped");
7903
+ Object.assign(body, req.vendor?.openai ?? {});
7904
+ return { body, degradations };
7905
+ }
7906
+ function toCustomResponsesWire(req, model) {
7907
+ const degradations = [];
7908
+ const note = (d) => {
7909
+ if (!degradations.includes(d))
7910
+ degradations.push(d);
7911
+ };
7912
+ const input = [];
7913
+ if (req.betas?.includes(CONTEXT_1M_BETA))
7914
+ note("custom:context-1m-dropped");
7877
7915
  for (const message of req.messages) {
7878
7916
  const parts = [];
7879
7917
  const inlined = message.role === "system";
7880
7918
  if (inlined)
7881
- note("openai:system-turn-inlined");
7919
+ note("custom:system-turn-inlined");
7882
7920
  const role = inlined ? "user" : message.role;
7883
7921
  const flush = () => {
7884
7922
  if (parts.length === 0)
@@ -7903,9 +7941,7 @@ ${block.text}
7903
7941
  });
7904
7942
  break;
7905
7943
  case "thinking":
7906
- if (!degradations.includes("openai:thinking-dropped")) {
7907
- note("openai:thinking-dropped");
7908
- }
7944
+ note("custom:thinking-dropped");
7909
7945
  break;
7910
7946
  case "toolUse":
7911
7947
  flush();
@@ -7925,7 +7961,7 @@ ${block.text}
7925
7961
  });
7926
7962
  break;
7927
7963
  case "anthropicNative":
7928
- note("openai:anthropic-native-block-dropped");
7964
+ note("custom:anthropic-native-block-dropped");
7929
7965
  break;
7930
7966
  }
7931
7967
  }
@@ -7937,23 +7973,15 @@ ${block.text}
7937
7973
  `);
7938
7974
  if (instructions !== undefined && instructions.length > 0)
7939
7975
  body.instructions = instructions;
7940
- if (req.maxTokens !== undefined) {
7941
- if (opts.oauth)
7942
- note("openai:max-tokens-dropped");
7943
- else
7944
- body.max_output_tokens = req.maxTokens;
7945
- }
7946
- if (req.temperature !== undefined) {
7947
- if (opts.oauth)
7948
- note("openai:temperature-dropped");
7949
- else
7950
- body.temperature = req.temperature;
7951
- }
7976
+ if (req.maxTokens !== undefined)
7977
+ body.max_output_tokens = req.maxTokens;
7978
+ if (req.temperature !== undefined)
7979
+ body.temperature = req.temperature;
7952
7980
  if (req.tools !== undefined) {
7953
- const custom = req.tools.filter((t) => t.provider === "custom");
7954
- if (custom.length !== req.tools.length)
7955
- note("openai:anthropic-tool-dropped");
7956
- body.tools = custom.map((t) => ({
7981
+ const portable = req.tools.filter((t) => t.provider === "custom");
7982
+ if (portable.length !== req.tools.length)
7983
+ note("custom:anthropic-tool-dropped");
7984
+ body.tools = portable.map((t) => ({
7957
7985
  type: "function",
7958
7986
  name: t.name,
7959
7987
  description: t.description,
@@ -7961,20 +7989,12 @@ ${block.text}
7961
7989
  }));
7962
7990
  }
7963
7991
  if (req.toolChoice !== undefined)
7964
- body.tool_choice = encodeToolChoice3(req.toolChoice);
7965
- if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
7966
- const effort = req.reasoning.mode === "adaptive" ? req.reasoning.effort ?? "medium" : "medium";
7967
- if (effort === "xhigh" || effort === "max") {
7968
- degradations.push("openai:reasoning-effort-clamped");
7969
- }
7970
- body.reasoning = {
7971
- effort: effort === "xhigh" || effort === "max" ? "high" : effort,
7972
- summary: "auto"
7973
- };
7974
- if (req.reasoning.mode === "budget") {
7975
- degradations.push("openai:reasoning-budget-dropped");
7976
- }
7977
- }
7992
+ body.tool_choice = encodeResponsesToolChoice(req.toolChoice);
7993
+ const effort = customEffort(req.reasoning);
7994
+ if (effort !== undefined)
7995
+ body.reasoning = { effort, summary: "auto" };
7996
+ else if (req.reasoning?.mode === "budget")
7997
+ note("custom:reasoning-budget-dropped");
7978
7998
  Object.assign(body, req.vendor?.openai ?? {});
7979
7999
  return { body, degradations };
7980
8000
  }
@@ -7985,7 +8005,13 @@ function metadata(data) {
7985
8005
  if (typeof origin !== "string" || protocol !== "chat_completions" && protocol !== "responses") {
7986
8006
  throw new GatewayError("BAD_REQUEST", "custom credential has invalid endpoint metadata");
7987
8007
  }
7988
- return { origin, protocol };
8008
+ const basePath = typeof data.basePath === "string" ? data.basePath : "";
8009
+ return { origin, basePath, protocol };
8010
+ }
8011
+ function endpointUrl(origin, basePath, protocol) {
8012
+ const suffix = protocol === "chat_completions" ? "chat/completions" : "responses";
8013
+ const base = `${origin}${basePath}`.replace(/\/+$/, "");
8014
+ return base.endsWith("/v1") ? `${base}/${suffix}` : `${base}/v1/${suffix}`;
7989
8015
  }
7990
8016
  var customAdapter = {
7991
8017
  id: "custom",
@@ -7995,15 +8021,15 @@ var customAdapter = {
7995
8021
  if (apiKey === null) {
7996
8022
  throw new GatewayError("AUTH", "custom credential has no API key", { provider: "custom" });
7997
8023
  }
7998
- const { origin, protocol } = metadata(req.credentials.providerData);
7999
- const encoded = protocol === "chat_completions" ? toChatWire(req.request, req.model, "openai") : toResponsesWire(req.request, req.model);
8024
+ const { origin, basePath, protocol } = metadata(req.credentials.providerData);
8025
+ const encoded = protocol === "chat_completions" ? toCustomChatWire(req.request, req.model) : toCustomResponsesWire(req.request, req.model);
8000
8026
  const headers = [
8001
8027
  ["Content-Type", "application/json"],
8002
8028
  ["Authorization", `Bearer ${apiKey}`]
8003
8029
  ];
8004
8030
  const res = await req.http({
8005
8031
  provider: "custom",
8006
- url: `${origin}/v1/${protocol === "chat_completions" ? "chat/completions" : "responses"}`,
8032
+ url: endpointUrl(origin, basePath, protocol),
8007
8033
  method: "POST",
8008
8034
  headers,
8009
8035
  body: JSON.stringify({ ...encoded.body, stream: true }),
@@ -8015,8 +8041,8 @@ var customAdapter = {
8015
8041
  throw new GatewayError("UPSTREAM", "empty response body", { provider: "custom" });
8016
8042
  }
8017
8043
  return {
8018
- events: protocol === "chat_completions" ? decodeChat(parseSse(res.body)) : decodeResponses(parseSse(res.body)),
8019
- degradations: encoded.degradations.map((value) => value.replace(protocol === "chat_completions" ? /^kimi:/ : /^openai:/, "custom:"))
8044
+ events: protocol === "chat_completions" ? decodeCustomChat(parseSse(res.body)) : decodeCustomResponses(parseSse(res.body)),
8045
+ degradations: encoded.degradations
8020
8046
  };
8021
8047
  }
8022
8048
  };
@@ -8035,7 +8061,7 @@ function grokDeviceHeaders(providerData) {
8035
8061
  import { createHash as createHash2 } from "crypto";
8036
8062
 
8037
8063
  // packages/providers/src/grok/decode.ts
8038
- var ERROR_CODE2 = {
8064
+ var ERROR_CODE = {
8039
8065
  rate_limit_exceeded: "RATE_LIMIT",
8040
8066
  insufficient_quota: "QUOTA_EXHAUSTED",
8041
8067
  invalid_api_key: "AUTH",
@@ -8069,7 +8095,7 @@ var KNOWN_EVENTS2 = new Set([
8069
8095
  "response.failed",
8070
8096
  "error"
8071
8097
  ]);
8072
- function json4(data) {
8098
+ function json3(data) {
8073
8099
  try {
8074
8100
  const v = JSON.parse(data);
8075
8101
  return typeof v === "object" && v !== null ? v : null;
@@ -8104,7 +8130,7 @@ async function* decodeGrokResponses(messages) {
8104
8130
  };
8105
8131
  return;
8106
8132
  }
8107
- const d = json4(msg.data);
8133
+ const d = json3(msg.data);
8108
8134
  if (d === null)
8109
8135
  continue;
8110
8136
  switch (msg.event) {
@@ -8197,7 +8223,7 @@ async function* decodeGrokResponses(messages) {
8197
8223
  case "error": {
8198
8224
  terminal = true;
8199
8225
  const err = d.response?.error ?? d.error ?? {};
8200
- const code = ERROR_CODE2[String(err.code ?? err.type)] ?? "UPSTREAM";
8226
+ const code = ERROR_CODE[String(err.code ?? err.type)] ?? "UPSTREAM";
8201
8227
  yield {
8202
8228
  type: "error",
8203
8229
  code,
@@ -8223,7 +8249,7 @@ async function* decodeGrokResponses(messages) {
8223
8249
  // packages/providers/src/grok/wire.ts
8224
8250
  import { createHash } from "crypto";
8225
8251
  var MAX_TOOLS = 200;
8226
- function encodeToolChoice4(c) {
8252
+ function encodeToolChoice2(c) {
8227
8253
  switch (c.type) {
8228
8254
  case "auto":
8229
8255
  return "auto";
@@ -8334,12 +8360,14 @@ ${block.text}
8334
8360
  }));
8335
8361
  }
8336
8362
  if (req.toolChoice !== undefined)
8337
- body.tool_choice = encodeToolChoice4(req.toolChoice);
8363
+ body.tool_choice = encodeToolChoice2(req.toolChoice);
8338
8364
  if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
8339
- const effort = req.reasoning.mode === "adaptive" ? req.reasoning.effort ?? "medium" : "medium";
8340
- body.reasoning = { effort, summary: "concise" };
8341
- if (req.reasoning.mode === "budget")
8365
+ if (req.reasoning.mode === "budget") {
8342
8366
  note("grok:reasoning-budget-dropped");
8367
+ } else {
8368
+ const effort = req.reasoning.effort ?? "medium";
8369
+ body.reasoning = { effort, summary: "concise" };
8370
+ }
8343
8371
  }
8344
8372
  Object.assign(body, req.vendor?.grok ?? {});
8345
8373
  return { body, degradations };
@@ -8497,13 +8525,13 @@ function hasHeader(req, lowerName) {
8497
8525
  return req.headers.some(([name]) => name.toLowerCase() === lowerName);
8498
8526
  }
8499
8527
  // packages/providers/src/kilo/decode.ts
8500
- var FINISH2 = {
8528
+ var FINISH = {
8501
8529
  stop: "endTurn",
8502
8530
  length: "maxTokens",
8503
8531
  tool_calls: "toolUse",
8504
8532
  content_filter: "contentFilter"
8505
8533
  };
8506
- function reasoningText(delta) {
8534
+ function reasoningText2(delta) {
8507
8535
  if (typeof delta.reasoning === "string" && delta.reasoning.length > 0)
8508
8536
  return delta.reasoning;
8509
8537
  if (typeof delta.reasoning_content === "string" && delta.reasoning_content.length > 0) {
@@ -8521,7 +8549,7 @@ function reasoningText(delta) {
8521
8549
  return [];
8522
8550
  }).join("");
8523
8551
  }
8524
- function json5(data) {
8552
+ function json4(data) {
8525
8553
  try {
8526
8554
  const v = JSON.parse(data);
8527
8555
  return typeof v === "object" && v !== null ? v : null;
@@ -8543,7 +8571,7 @@ async function* decodeKiloChat(messages) {
8543
8571
  done = true;
8544
8572
  break;
8545
8573
  }
8546
- const d = json5(msg.data);
8574
+ const d = json4(msg.data);
8547
8575
  if (d === null)
8548
8576
  continue;
8549
8577
  if (!started && (d.id !== undefined || d.model !== undefined)) {
@@ -8558,7 +8586,7 @@ async function* decodeKiloChat(messages) {
8558
8586
  if (!choice)
8559
8587
  continue;
8560
8588
  const delta = choice.delta ?? {};
8561
- const reasoning = reasoningText(delta);
8589
+ const reasoning = reasoningText2(delta);
8562
8590
  if (reasoning.length > 0) {
8563
8591
  if (openKind !== "thinking") {
8564
8592
  if (openKind !== undefined)
@@ -8614,7 +8642,7 @@ async function* decodeKiloChat(messages) {
8614
8642
  }
8615
8643
  }
8616
8644
  if (typeof choice.finish_reason === "string") {
8617
- stopReason = FINISH2[choice.finish_reason] ?? "endTurn";
8645
+ stopReason = FINISH[choice.finish_reason] ?? "endTurn";
8618
8646
  }
8619
8647
  }
8620
8648
  if (done) {
@@ -8632,7 +8660,7 @@ async function* decodeKiloChat(messages) {
8632
8660
  }
8633
8661
 
8634
8662
  // packages/providers/src/kilo/wire.ts
8635
- function encodeToolChoice5(c) {
8663
+ function encodeToolChoice3(c) {
8636
8664
  switch (c.type) {
8637
8665
  case "auto":
8638
8666
  return "auto";
@@ -8745,15 +8773,12 @@ function toKiloWire(req, model) {
8745
8773
  }));
8746
8774
  }
8747
8775
  if (req.toolChoice !== undefined)
8748
- body.tool_choice = encodeToolChoice5(req.toolChoice);
8776
+ body.tool_choice = encodeToolChoice3(req.toolChoice);
8749
8777
  if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
8750
8778
  if (req.reasoning.mode === "budget") {
8751
8779
  body.reasoning = { max_tokens: req.reasoning.budgetTokens };
8752
8780
  } else {
8753
- const effort = req.reasoning.effort ?? "medium";
8754
- if (effort === "xhigh" || effort === "max")
8755
- note("kilo:reasoning-effort-clamped");
8756
- body.reasoning = { effort: effort === "xhigh" || effort === "max" ? "high" : effort };
8781
+ body.reasoning = { effort: req.reasoning.effort ?? "medium" };
8757
8782
  }
8758
8783
  }
8759
8784
  Object.assign(body, req.vendor?.kilo ?? {});
@@ -8823,6 +8848,208 @@ function kimiDeviceHeaders(providerData) {
8823
8848
  ["X-Msh-Os-Version", str(providerData.osVersion)]
8824
8849
  ];
8825
8850
  }
8851
+ // packages/providers/src/kimi/decode.ts
8852
+ var FINISH2 = {
8853
+ stop: "endTurn",
8854
+ length: "maxTokens",
8855
+ tool_calls: "toolUse",
8856
+ content_filter: "contentFilter"
8857
+ };
8858
+ function json5(data) {
8859
+ try {
8860
+ const v = JSON.parse(data);
8861
+ return typeof v === "object" && v !== null ? v : null;
8862
+ } catch {
8863
+ return null;
8864
+ }
8865
+ }
8866
+ async function* decodeChat(messages) {
8867
+ let started = false;
8868
+ let done = false;
8869
+ let stopReason = "endTurn";
8870
+ let usage = { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 };
8871
+ const toolIndex = new Map;
8872
+ let nextIndex = 0;
8873
+ let openKind;
8874
+ let openIndex = 0;
8875
+ for await (const msg of messages) {
8876
+ if (msg.data === "[DONE]") {
8877
+ done = true;
8878
+ break;
8879
+ }
8880
+ const d = json5(msg.data);
8881
+ if (d === null)
8882
+ continue;
8883
+ if (!started && (d.id !== undefined || d.model !== undefined)) {
8884
+ started = true;
8885
+ yield { type: "start", id: String(d.id ?? ""), model: String(d.model ?? "") };
8886
+ }
8887
+ if (d.usage) {
8888
+ const details = d.usage.prompt_tokens_details;
8889
+ usage = usageFromPromptTotal(d.usage.prompt_tokens ?? 0, d.usage.completion_tokens ?? 0, details?.cached_tokens ?? d.usage.prompt_cache_hit_tokens ?? 0, details?.cache_creation_tokens ?? details?.cache_write_tokens ?? 0);
8890
+ }
8891
+ const choice = d.choices?.[0];
8892
+ if (!choice)
8893
+ continue;
8894
+ const delta = choice.delta ?? {};
8895
+ if (typeof delta.content === "string" && delta.content.length > 0) {
8896
+ if (openKind !== "text") {
8897
+ if (openKind !== undefined)
8898
+ yield { type: "blockEnd", index: openIndex };
8899
+ openKind = "text";
8900
+ openIndex = nextIndex++;
8901
+ yield { type: "blockStart", index: openIndex, block: { type: "text" } };
8902
+ }
8903
+ yield {
8904
+ type: "blockDelta",
8905
+ index: openIndex,
8906
+ delta: { type: "text", text: delta.content }
8907
+ };
8908
+ }
8909
+ for (const call of delta.tool_calls ?? []) {
8910
+ const wireIndex = call.index ?? 0;
8911
+ let index = toolIndex.get(wireIndex);
8912
+ if (index === undefined) {
8913
+ if (openKind !== undefined)
8914
+ yield { type: "blockEnd", index: openIndex };
8915
+ index = nextIndex++;
8916
+ toolIndex.set(wireIndex, index);
8917
+ openKind = "tool";
8918
+ openIndex = index;
8919
+ yield {
8920
+ type: "blockStart",
8921
+ index,
8922
+ block: {
8923
+ type: "toolUse",
8924
+ id: String(call.id ?? `call_${wireIndex}`),
8925
+ name: String(call.function?.name ?? "")
8926
+ }
8927
+ };
8928
+ }
8929
+ const args = call.function?.arguments;
8930
+ if (typeof args === "string" && args.length > 0) {
8931
+ yield { type: "blockDelta", index, delta: { type: "toolJson", partial: args } };
8932
+ }
8933
+ }
8934
+ if (typeof choice.finish_reason === "string") {
8935
+ stopReason = FINISH2[choice.finish_reason] ?? "endTurn";
8936
+ }
8937
+ }
8938
+ if (done) {
8939
+ if (openKind !== undefined)
8940
+ yield { type: "blockEnd", index: openIndex };
8941
+ yield { type: "end", stopReason, usage };
8942
+ } else {
8943
+ yield {
8944
+ type: "error",
8945
+ code: "UPSTREAM",
8946
+ message: "upstream stream ended before [DONE]",
8947
+ retryable: RETRYABLE.UPSTREAM
8948
+ };
8949
+ }
8950
+ }
8951
+
8952
+ // packages/providers/src/kimi/wire.ts
8953
+ function encodeToolChoice4(c) {
8954
+ switch (c.type) {
8955
+ case "auto":
8956
+ return "auto";
8957
+ case "any":
8958
+ return "required";
8959
+ case "none":
8960
+ return "none";
8961
+ case "tool":
8962
+ return { type: "function", function: { name: c.name } };
8963
+ }
8964
+ }
8965
+ function toChatWire(req, model, vendor = "kimi") {
8966
+ const degradations = [];
8967
+ const note = (d) => {
8968
+ if (!degradations.includes(d))
8969
+ degradations.push(d);
8970
+ };
8971
+ if (req.betas?.includes(CONTEXT_1M_BETA))
8972
+ note("kimi:context-1m-dropped");
8973
+ const messages = [];
8974
+ const system = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
8975
+
8976
+ `);
8977
+ if (system !== undefined && system.length > 0)
8978
+ messages.push({ role: "system", content: system });
8979
+ for (const message of req.messages) {
8980
+ const text = [];
8981
+ const toolCalls = [];
8982
+ for (const block of message.content) {
8983
+ switch (block.type) {
8984
+ case "text":
8985
+ text.push(block.text);
8986
+ break;
8987
+ case "image":
8988
+ note("kimi:images-dropped");
8989
+ break;
8990
+ case "thinking":
8991
+ note("kimi:thinking-dropped");
8992
+ break;
8993
+ case "toolUse":
8994
+ toolCalls.push({
8995
+ id: block.id,
8996
+ type: "function",
8997
+ function: { name: block.name, arguments: JSON.stringify(block.input) }
8998
+ });
8999
+ break;
9000
+ case "toolResult":
9001
+ messages.push({
9002
+ role: "tool",
9003
+ tool_call_id: block.toolUseId,
9004
+ content: block.content
9005
+ });
9006
+ break;
9007
+ case "anthropicNative":
9008
+ note("kimi:anthropic-native-block-dropped");
9009
+ break;
9010
+ }
9011
+ }
9012
+ if (toolCalls.length > 0) {
9013
+ messages.push({
9014
+ role: message.role,
9015
+ content: text.length > 0 ? text.join(`
9016
+ `) : null,
9017
+ tool_calls: toolCalls
9018
+ });
9019
+ } else if (text.length > 0) {
9020
+ messages.push({ role: message.role, content: text.join(`
9021
+ `) });
9022
+ }
9023
+ }
9024
+ const body = {
9025
+ model,
9026
+ messages,
9027
+ stream: req.stream,
9028
+ stream_options: { include_usage: true }
9029
+ };
9030
+ if (req.maxTokens !== undefined)
9031
+ body.max_tokens = req.maxTokens;
9032
+ if (req.temperature !== undefined)
9033
+ body.temperature = req.temperature;
9034
+ if (req.stopSequences !== undefined)
9035
+ body.stop = req.stopSequences;
9036
+ if (req.tools !== undefined) {
9037
+ const custom = req.tools.filter((t) => t.provider === "custom");
9038
+ if (custom.length !== req.tools.length)
9039
+ note("kimi:anthropic-tool-dropped");
9040
+ body.tools = custom.map((t) => ({
9041
+ type: "function",
9042
+ function: { name: t.name, description: t.description, parameters: t.inputSchema }
9043
+ }));
9044
+ }
9045
+ if (req.toolChoice !== undefined)
9046
+ body.tool_choice = encodeToolChoice4(req.toolChoice);
9047
+ if (req.reasoning !== undefined)
9048
+ note("kimi:reasoning-dropped");
9049
+ Object.assign(body, req.vendor?.[vendor] ?? {});
9050
+ return { body, degradations };
9051
+ }
9052
+
8826
9053
  // packages/providers/src/kimi/index.ts
8827
9054
  var BASE_URL2 = "https://api.kimi.com/coding/v1/chat/completions";
8828
9055
  var kimiAdapter = {
@@ -8857,6 +9084,276 @@ var kimiAdapter = {
8857
9084
  return { events: decodeChat(parseSse(res.body)), degradations };
8858
9085
  }
8859
9086
  };
9087
+ // packages/providers/src/openai/decode.ts
9088
+ var ERROR_CODE2 = {
9089
+ rate_limit_exceeded: "RATE_LIMIT",
9090
+ insufficient_quota: "QUOTA_EXHAUSTED",
9091
+ invalid_api_key: "AUTH",
9092
+ server_error: "UPSTREAM",
9093
+ context_length_exceeded: "BAD_REQUEST",
9094
+ content_policy_violation: "CONTENT_FILTER"
9095
+ };
9096
+ function json6(data) {
9097
+ try {
9098
+ const v = JSON.parse(data);
9099
+ return typeof v === "object" && v !== null ? v : null;
9100
+ } catch {
9101
+ return null;
9102
+ }
9103
+ }
9104
+ async function* decodeResponses(messages) {
9105
+ const indices = new Map;
9106
+ let next = 0;
9107
+ const irIndex = (outputIndex, contentIndex = 0) => {
9108
+ const key = `${outputIndex}:${contentIndex}`;
9109
+ const existing = indices.get(key);
9110
+ if (existing !== undefined)
9111
+ return existing;
9112
+ const assigned = next++;
9113
+ indices.set(key, assigned);
9114
+ return assigned;
9115
+ };
9116
+ let sawToolCall = false;
9117
+ let terminal = false;
9118
+ const ownsBlock = new Set;
9119
+ for await (const msg of messages) {
9120
+ const d = json6(msg.data);
9121
+ if (d === null)
9122
+ continue;
9123
+ switch (msg.event) {
9124
+ case "response.created":
9125
+ yield {
9126
+ type: "start",
9127
+ id: String(d.response?.id ?? ""),
9128
+ model: String(d.response?.model ?? "")
9129
+ };
9130
+ break;
9131
+ case "response.output_item.added": {
9132
+ const item = d.item ?? {};
9133
+ if (item.type === "reasoning") {
9134
+ ownsBlock.add(d.output_index ?? 0);
9135
+ yield {
9136
+ type: "blockStart",
9137
+ index: irIndex(d.output_index ?? 0),
9138
+ block: { type: "thinking" }
9139
+ };
9140
+ } else if (item.type === "function_call") {
9141
+ sawToolCall = true;
9142
+ ownsBlock.add(d.output_index ?? 0);
9143
+ yield {
9144
+ type: "blockStart",
9145
+ index: irIndex(d.output_index ?? 0),
9146
+ block: { type: "toolUse", id: String(item.call_id), name: String(item.name) }
9147
+ };
9148
+ }
9149
+ break;
9150
+ }
9151
+ case "response.content_part.added":
9152
+ if (d.part?.type === "output_text") {
9153
+ yield {
9154
+ type: "blockStart",
9155
+ index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
9156
+ block: { type: "text" }
9157
+ };
9158
+ }
9159
+ break;
9160
+ case "response.output_text.delta":
9161
+ yield {
9162
+ type: "blockDelta",
9163
+ index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
9164
+ delta: { type: "text", text: String(d.delta ?? "") }
9165
+ };
9166
+ break;
9167
+ case "response.reasoning_summary_text.delta":
9168
+ yield {
9169
+ type: "blockDelta",
9170
+ index: irIndex(d.output_index ?? 0),
9171
+ delta: { type: "thinking", text: String(d.delta ?? "") }
9172
+ };
9173
+ break;
9174
+ case "response.function_call_arguments.delta":
9175
+ yield {
9176
+ type: "blockDelta",
9177
+ index: irIndex(d.output_index ?? 0),
9178
+ delta: { type: "toolJson", partial: String(d.delta ?? "") }
9179
+ };
9180
+ break;
9181
+ case "response.content_part.done":
9182
+ yield { type: "blockEnd", index: irIndex(d.output_index ?? 0, d.content_index ?? 0) };
9183
+ break;
9184
+ case "response.output_item.done": {
9185
+ const outputIndex = d.output_index ?? 0;
9186
+ if (ownsBlock.delete(outputIndex)) {
9187
+ yield { type: "blockEnd", index: irIndex(outputIndex) };
9188
+ }
9189
+ break;
9190
+ }
9191
+ case "response.completed":
9192
+ case "response.incomplete": {
9193
+ terminal = true;
9194
+ const r = d.response ?? {};
9195
+ const reason = r.incomplete_details?.reason;
9196
+ let stopReason = sawToolCall ? "toolUse" : "endTurn";
9197
+ if (reason === "max_output_tokens")
9198
+ stopReason = "maxTokens";
9199
+ else if (reason === "content_filter")
9200
+ stopReason = "contentFilter";
9201
+ yield {
9202
+ type: "end",
9203
+ stopReason,
9204
+ usage: usageFromPromptTotal(r.usage?.input_tokens ?? 0, r.usage?.output_tokens ?? 0, r.usage?.input_tokens_details?.cached_tokens ?? r.usage?.prompt_tokens_details?.cached_tokens ?? 0)
9205
+ };
9206
+ break;
9207
+ }
9208
+ case "response.failed":
9209
+ case "error": {
9210
+ terminal = true;
9211
+ const err = d.response?.error ?? d.error ?? {};
9212
+ const code = ERROR_CODE2[String(err.code ?? err.type)] ?? "UPSTREAM";
9213
+ yield {
9214
+ type: "error",
9215
+ code,
9216
+ message: String(err.message ?? "upstream error"),
9217
+ retryable: RETRYABLE[code]
9218
+ };
9219
+ break;
9220
+ }
9221
+ default:
9222
+ break;
9223
+ }
9224
+ }
9225
+ if (!terminal) {
9226
+ yield {
9227
+ type: "error",
9228
+ code: "UPSTREAM",
9229
+ message: "upstream stream ended before response completion",
9230
+ retryable: RETRYABLE.UPSTREAM
9231
+ };
9232
+ }
9233
+ }
9234
+
9235
+ // packages/providers/src/openai/wire.ts
9236
+ function encodeToolChoice5(c) {
9237
+ switch (c.type) {
9238
+ case "auto":
9239
+ return "auto";
9240
+ case "any":
9241
+ return "required";
9242
+ case "none":
9243
+ return "none";
9244
+ case "tool":
9245
+ return { type: "function", name: c.name };
9246
+ }
9247
+ }
9248
+ function toResponsesWire(req, model, opts = { oauth: false }) {
9249
+ const degradations = [];
9250
+ const input = [];
9251
+ const note = (d) => {
9252
+ if (!degradations.includes(d))
9253
+ degradations.push(d);
9254
+ };
9255
+ if (req.betas?.includes(CONTEXT_1M_BETA))
9256
+ note("openai:context-1m-dropped");
9257
+ for (const message of req.messages) {
9258
+ const parts = [];
9259
+ const inlined = message.role === "system";
9260
+ if (inlined)
9261
+ note("openai:system-turn-inlined");
9262
+ const role = inlined ? "user" : message.role;
9263
+ const flush = () => {
9264
+ if (parts.length === 0)
9265
+ return;
9266
+ input.push({ type: "message", role, content: [...parts] });
9267
+ parts.length = 0;
9268
+ };
9269
+ for (const block of message.content) {
9270
+ switch (block.type) {
9271
+ case "text":
9272
+ parts.push({
9273
+ type: role === "assistant" ? "output_text" : "input_text",
9274
+ text: inlined ? `<system-reminder>
9275
+ ${block.text}
9276
+ </system-reminder>` : block.text
9277
+ });
9278
+ break;
9279
+ case "image":
9280
+ parts.push({
9281
+ type: "input_image",
9282
+ image_url: `data:${block.mediaType};base64,${block.data}`
9283
+ });
9284
+ break;
9285
+ case "thinking":
9286
+ if (!degradations.includes("openai:thinking-dropped")) {
9287
+ note("openai:thinking-dropped");
9288
+ }
9289
+ break;
9290
+ case "toolUse":
9291
+ flush();
9292
+ input.push({
9293
+ type: "function_call",
9294
+ call_id: block.id,
9295
+ name: block.name,
9296
+ arguments: JSON.stringify(block.input)
9297
+ });
9298
+ break;
9299
+ case "toolResult":
9300
+ flush();
9301
+ input.push({
9302
+ type: "function_call_output",
9303
+ call_id: block.toolUseId,
9304
+ output: block.content
9305
+ });
9306
+ break;
9307
+ case "anthropicNative":
9308
+ note("openai:anthropic-native-block-dropped");
9309
+ break;
9310
+ }
9311
+ }
9312
+ flush();
9313
+ }
9314
+ const body = { model, input, stream: req.stream, store: false };
9315
+ const instructions = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
9316
+
9317
+ `);
9318
+ if (instructions !== undefined && instructions.length > 0)
9319
+ body.instructions = instructions;
9320
+ if (req.maxTokens !== undefined) {
9321
+ if (opts.oauth)
9322
+ note("openai:max-tokens-dropped");
9323
+ else
9324
+ body.max_output_tokens = req.maxTokens;
9325
+ }
9326
+ if (req.temperature !== undefined) {
9327
+ if (opts.oauth)
9328
+ note("openai:temperature-dropped");
9329
+ else
9330
+ body.temperature = req.temperature;
9331
+ }
9332
+ if (req.tools !== undefined) {
9333
+ const custom = req.tools.filter((t) => t.provider === "custom");
9334
+ if (custom.length !== req.tools.length)
9335
+ note("openai:anthropic-tool-dropped");
9336
+ body.tools = custom.map((t) => ({
9337
+ type: "function",
9338
+ name: t.name,
9339
+ description: t.description,
9340
+ parameters: t.inputSchema
9341
+ }));
9342
+ }
9343
+ if (req.toolChoice !== undefined)
9344
+ body.tool_choice = encodeToolChoice5(req.toolChoice);
9345
+ if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
9346
+ if (req.reasoning.mode === "budget") {
9347
+ degradations.push("openai:reasoning-budget-dropped");
9348
+ } else {
9349
+ const effort = req.reasoning.effort ?? "medium";
9350
+ body.reasoning = { effort, summary: "auto" };
9351
+ }
9352
+ }
9353
+ Object.assign(body, req.vendor?.openai ?? {});
9354
+ return { body, degradations };
9355
+ }
9356
+
8860
9357
  // packages/providers/src/openai/index.ts
8861
9358
  var OAUTH_URL2 = "https://chatgpt.com/backend-api/codex/responses";
8862
9359
  var API_URL3 = "https://api.openai.com/v1/responses";
@@ -9268,7 +9765,7 @@ __export(exports_external, {
9268
9765
  ipv4: () => ipv42,
9269
9766
  ipv6: () => ipv62,
9270
9767
  iso: () => exports_iso,
9271
- json: () => json6,
9768
+ json: () => json7,
9272
9769
  jwt: () => jwt,
9273
9770
  keyof: () => keyof,
9274
9771
  ksuid: () => ksuid2,
@@ -20709,29 +21206,29 @@ var formatMap = {
20709
21206
  regex: ""
20710
21207
  };
20711
21208
  var stringProcessor = (schema, ctx, _json, _params) => {
20712
- const json6 = _json;
20713
- json6.type = "string";
21209
+ const json7 = _json;
21210
+ json7.type = "string";
20714
21211
  const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
20715
21212
  if (typeof minimum === "number")
20716
- json6.minLength = minimum;
21213
+ json7.minLength = minimum;
20717
21214
  if (typeof maximum === "number")
20718
- json6.maxLength = maximum;
21215
+ json7.maxLength = maximum;
20719
21216
  if (format) {
20720
- json6.format = formatMap[format] ?? format;
20721
- if (json6.format === "")
20722
- delete json6.format;
21217
+ json7.format = formatMap[format] ?? format;
21218
+ if (json7.format === "")
21219
+ delete json7.format;
20723
21220
  if (format === "time") {
20724
- delete json6.format;
21221
+ delete json7.format;
20725
21222
  }
20726
21223
  }
20727
21224
  if (contentEncoding)
20728
- json6.contentEncoding = contentEncoding;
21225
+ json7.contentEncoding = contentEncoding;
20729
21226
  if (patterns && patterns.size > 0) {
20730
21227
  const regexes = [...patterns];
20731
21228
  if (regexes.length === 1)
20732
- json6.pattern = regexes[0].source;
21229
+ json7.pattern = regexes[0].source;
20733
21230
  else if (regexes.length > 1) {
20734
- json6.allOf = [
21231
+ json7.allOf = [
20735
21232
  ...regexes.map((regex) => ({
20736
21233
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
20737
21234
  pattern: regex.source
@@ -20741,40 +21238,40 @@ var stringProcessor = (schema, ctx, _json, _params) => {
20741
21238
  }
20742
21239
  };
20743
21240
  var numberProcessor = (schema, ctx, _json, _params) => {
20744
- const json6 = _json;
21241
+ const json7 = _json;
20745
21242
  const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
20746
21243
  if (typeof format === "string" && format.includes("int"))
20747
- json6.type = "integer";
21244
+ json7.type = "integer";
20748
21245
  else
20749
- json6.type = "number";
21246
+ json7.type = "number";
20750
21247
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
20751
21248
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
20752
21249
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
20753
21250
  if (exMin) {
20754
21251
  if (legacy) {
20755
- json6.minimum = exclusiveMinimum;
20756
- json6.exclusiveMinimum = true;
21252
+ json7.minimum = exclusiveMinimum;
21253
+ json7.exclusiveMinimum = true;
20757
21254
  } else {
20758
- json6.exclusiveMinimum = exclusiveMinimum;
21255
+ json7.exclusiveMinimum = exclusiveMinimum;
20759
21256
  }
20760
21257
  } else if (typeof minimum === "number") {
20761
- json6.minimum = minimum;
21258
+ json7.minimum = minimum;
20762
21259
  }
20763
21260
  if (exMax) {
20764
21261
  if (legacy) {
20765
- json6.maximum = exclusiveMaximum;
20766
- json6.exclusiveMaximum = true;
21262
+ json7.maximum = exclusiveMaximum;
21263
+ json7.exclusiveMaximum = true;
20767
21264
  } else {
20768
- json6.exclusiveMaximum = exclusiveMaximum;
21265
+ json7.exclusiveMaximum = exclusiveMaximum;
20769
21266
  }
20770
21267
  } else if (typeof maximum === "number") {
20771
- json6.maximum = maximum;
21268
+ json7.maximum = maximum;
20772
21269
  }
20773
21270
  if (typeof multipleOf === "number")
20774
- json6.multipleOf = multipleOf;
21271
+ json7.multipleOf = multipleOf;
20775
21272
  };
20776
- var booleanProcessor = (_schema, _ctx, json6, _params) => {
20777
- json6.type = "boolean";
21273
+ var booleanProcessor = (_schema, _ctx, json7, _params) => {
21274
+ json7.type = "boolean";
20778
21275
  };
20779
21276
  var bigintProcessor = (_schema, ctx, _json, _params) => {
20780
21277
  if (ctx.unrepresentable === "throw") {
@@ -20786,13 +21283,13 @@ var symbolProcessor = (_schema, ctx, _json, _params) => {
20786
21283
  throw new Error("Symbols cannot be represented in JSON Schema");
20787
21284
  }
20788
21285
  };
20789
- var nullProcessor = (_schema, ctx, json6, _params) => {
21286
+ var nullProcessor = (_schema, ctx, json7, _params) => {
20790
21287
  if (ctx.target === "openapi-3.0") {
20791
- json6.type = "string";
20792
- json6.nullable = true;
20793
- json6.enum = [null];
21288
+ json7.type = "string";
21289
+ json7.nullable = true;
21290
+ json7.enum = [null];
20794
21291
  } else {
20795
- json6.type = "null";
21292
+ json7.type = "null";
20796
21293
  }
20797
21294
  };
20798
21295
  var undefinedProcessor = (_schema, ctx, _json, _params) => {
@@ -20805,8 +21302,8 @@ var voidProcessor = (_schema, ctx, _json, _params) => {
20805
21302
  throw new Error("Void cannot be represented in JSON Schema");
20806
21303
  }
20807
21304
  };
20808
- var neverProcessor = (_schema, _ctx, json6, _params) => {
20809
- json6.not = {};
21305
+ var neverProcessor = (_schema, _ctx, json7, _params) => {
21306
+ json7.not = {};
20810
21307
  };
20811
21308
  var anyProcessor = (_schema, _ctx, _json, _params) => {};
20812
21309
  var unknownProcessor = (_schema, _ctx, _json, _params) => {};
@@ -20815,16 +21312,16 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
20815
21312
  throw new Error("Date cannot be represented in JSON Schema");
20816
21313
  }
20817
21314
  };
20818
- var enumProcessor = (schema, _ctx, json6, _params) => {
21315
+ var enumProcessor = (schema, _ctx, json7, _params) => {
20819
21316
  const def = schema._zod.def;
20820
21317
  const values = getEnumValues(def.entries);
20821
21318
  if (values.every((v) => typeof v === "number"))
20822
- json6.type = "number";
21319
+ json7.type = "number";
20823
21320
  if (values.every((v) => typeof v === "string"))
20824
- json6.type = "string";
20825
- json6.enum = values;
21321
+ json7.type = "string";
21322
+ json7.enum = values;
20826
21323
  };
20827
- var literalProcessor = (schema, ctx, json6, _params) => {
21324
+ var literalProcessor = (schema, ctx, json7, _params) => {
20828
21325
  const def = schema._zod.def;
20829
21326
  const vals = [];
20830
21327
  for (const val of def.values) {
@@ -20844,22 +21341,22 @@ var literalProcessor = (schema, ctx, json6, _params) => {
20844
21341
  }
20845
21342
  if (vals.length === 0) {} else if (vals.length === 1) {
20846
21343
  const val = vals[0];
20847
- json6.type = val === null ? "null" : typeof val;
21344
+ json7.type = val === null ? "null" : typeof val;
20848
21345
  if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
20849
- json6.enum = [val];
21346
+ json7.enum = [val];
20850
21347
  } else {
20851
- json6.const = val;
21348
+ json7.const = val;
20852
21349
  }
20853
21350
  } else {
20854
21351
  if (vals.every((v) => typeof v === "number"))
20855
- json6.type = "number";
21352
+ json7.type = "number";
20856
21353
  if (vals.every((v) => typeof v === "string"))
20857
- json6.type = "string";
21354
+ json7.type = "string";
20858
21355
  if (vals.every((v) => typeof v === "boolean"))
20859
- json6.type = "boolean";
21356
+ json7.type = "boolean";
20860
21357
  if (vals.every((v) => v === null))
20861
- json6.type = "null";
20862
- json6.enum = vals;
21358
+ json7.type = "null";
21359
+ json7.enum = vals;
20863
21360
  }
20864
21361
  };
20865
21362
  var nanProcessor = (_schema, ctx, _json, _params) => {
@@ -20867,16 +21364,16 @@ var nanProcessor = (_schema, ctx, _json, _params) => {
20867
21364
  throw new Error("NaN cannot be represented in JSON Schema");
20868
21365
  }
20869
21366
  };
20870
- var templateLiteralProcessor = (schema, _ctx, json6, _params) => {
20871
- const _json = json6;
21367
+ var templateLiteralProcessor = (schema, _ctx, json7, _params) => {
21368
+ const _json = json7;
20872
21369
  const pattern = schema._zod.pattern;
20873
21370
  if (!pattern)
20874
21371
  throw new Error("Pattern not found in template literal");
20875
21372
  _json.type = "string";
20876
21373
  _json.pattern = pattern.source;
20877
21374
  };
20878
- var fileProcessor = (schema, _ctx, json6, _params) => {
20879
- const _json = json6;
21375
+ var fileProcessor = (schema, _ctx, json7, _params) => {
21376
+ const _json = json7;
20880
21377
  const file = {
20881
21378
  type: "string",
20882
21379
  format: "binary",
@@ -20899,8 +21396,8 @@ var fileProcessor = (schema, _ctx, json6, _params) => {
20899
21396
  Object.assign(_json, file);
20900
21397
  }
20901
21398
  };
20902
- var successProcessor = (_schema, _ctx, json6, _params) => {
20903
- json6.type = "boolean";
21399
+ var successProcessor = (_schema, _ctx, json7, _params) => {
21400
+ json7.type = "boolean";
20904
21401
  };
20905
21402
  var customProcessor = (_schema, ctx, _json, _params) => {
20906
21403
  if (ctx.unrepresentable === "throw") {
@@ -20928,27 +21425,27 @@ var setProcessor = (_schema, ctx, _json, _params) => {
20928
21425
  }
20929
21426
  };
20930
21427
  var arrayProcessor = (schema, ctx, _json, params) => {
20931
- const json6 = _json;
21428
+ const json7 = _json;
20932
21429
  const def = schema._zod.def;
20933
21430
  const { minimum, maximum } = schema._zod.bag;
20934
21431
  if (typeof minimum === "number")
20935
- json6.minItems = minimum;
21432
+ json7.minItems = minimum;
20936
21433
  if (typeof maximum === "number")
20937
- json6.maxItems = maximum;
20938
- json6.type = "array";
20939
- json6.items = process2(def.element, ctx, {
21434
+ json7.maxItems = maximum;
21435
+ json7.type = "array";
21436
+ json7.items = process2(def.element, ctx, {
20940
21437
  ...params,
20941
21438
  path: [...params.path, "items"]
20942
21439
  });
20943
21440
  };
20944
21441
  var objectProcessor = (schema, ctx, _json, params) => {
20945
- const json6 = _json;
21442
+ const json7 = _json;
20946
21443
  const def = schema._zod.def;
20947
- json6.type = "object";
20948
- json6.properties = {};
21444
+ json7.type = "object";
21445
+ json7.properties = {};
20949
21446
  const shape = def.shape;
20950
21447
  for (const key in shape) {
20951
- json6.properties[key] = process2(shape[key], ctx, {
21448
+ json7.properties[key] = process2(shape[key], ctx, {
20952
21449
  ...params,
20953
21450
  path: [...params.path, "properties", key]
20954
21451
  });
@@ -20963,21 +21460,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
20963
21460
  }
20964
21461
  }));
20965
21462
  if (requiredKeys.size > 0) {
20966
- json6.required = Array.from(requiredKeys);
21463
+ json7.required = Array.from(requiredKeys);
20967
21464
  }
20968
21465
  if (def.catchall?._zod.def.type === "never") {
20969
- json6.additionalProperties = false;
21466
+ json7.additionalProperties = false;
20970
21467
  } else if (!def.catchall) {
20971
21468
  if (ctx.io === "output")
20972
- json6.additionalProperties = false;
21469
+ json7.additionalProperties = false;
20973
21470
  } else if (def.catchall) {
20974
- json6.additionalProperties = process2(def.catchall, ctx, {
21471
+ json7.additionalProperties = process2(def.catchall, ctx, {
20975
21472
  ...params,
20976
21473
  path: [...params.path, "additionalProperties"]
20977
21474
  });
20978
21475
  }
20979
21476
  };
20980
- var unionProcessor = (schema, ctx, json6, params) => {
21477
+ var unionProcessor = (schema, ctx, json7, params) => {
20981
21478
  const def = schema._zod.def;
20982
21479
  const isExclusive = def.inclusive === false;
20983
21480
  const options = def.options.map((x, i) => process2(x, ctx, {
@@ -20985,12 +21482,12 @@ var unionProcessor = (schema, ctx, json6, params) => {
20985
21482
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
20986
21483
  }));
20987
21484
  if (isExclusive) {
20988
- json6.oneOf = options;
21485
+ json7.oneOf = options;
20989
21486
  } else {
20990
- json6.anyOf = options;
21487
+ json7.anyOf = options;
20991
21488
  }
20992
21489
  };
20993
- var intersectionProcessor = (schema, ctx, json6, params) => {
21490
+ var intersectionProcessor = (schema, ctx, json7, params) => {
20994
21491
  const def = schema._zod.def;
20995
21492
  const a = process2(def.left, ctx, {
20996
21493
  ...params,
@@ -21005,12 +21502,12 @@ var intersectionProcessor = (schema, ctx, json6, params) => {
21005
21502
  ...isSimpleIntersection(a) ? a.allOf : [a],
21006
21503
  ...isSimpleIntersection(b) ? b.allOf : [b]
21007
21504
  ];
21008
- json6.allOf = allOf;
21505
+ json7.allOf = allOf;
21009
21506
  };
21010
21507
  var tupleProcessor = (schema, ctx, _json, params) => {
21011
- const json6 = _json;
21508
+ const json7 = _json;
21012
21509
  const def = schema._zod.def;
21013
- json6.type = "array";
21510
+ json7.type = "array";
21014
21511
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
21015
21512
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
21016
21513
  const prefixItems = def.items.map((x, i) => process2(x, ctx, {
@@ -21022,37 +21519,37 @@ var tupleProcessor = (schema, ctx, _json, params) => {
21022
21519
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
21023
21520
  }) : null;
21024
21521
  if (ctx.target === "draft-2020-12") {
21025
- json6.prefixItems = prefixItems;
21522
+ json7.prefixItems = prefixItems;
21026
21523
  if (rest) {
21027
- json6.items = rest;
21524
+ json7.items = rest;
21028
21525
  }
21029
21526
  } else if (ctx.target === "openapi-3.0") {
21030
- json6.items = {
21527
+ json7.items = {
21031
21528
  anyOf: prefixItems
21032
21529
  };
21033
21530
  if (rest) {
21034
- json6.items.anyOf.push(rest);
21531
+ json7.items.anyOf.push(rest);
21035
21532
  }
21036
- json6.minItems = prefixItems.length;
21533
+ json7.minItems = prefixItems.length;
21037
21534
  if (!rest) {
21038
- json6.maxItems = prefixItems.length;
21535
+ json7.maxItems = prefixItems.length;
21039
21536
  }
21040
21537
  } else {
21041
- json6.items = prefixItems;
21538
+ json7.items = prefixItems;
21042
21539
  if (rest) {
21043
- json6.additionalItems = rest;
21540
+ json7.additionalItems = rest;
21044
21541
  }
21045
21542
  }
21046
21543
  const { minimum, maximum } = schema._zod.bag;
21047
21544
  if (typeof minimum === "number")
21048
- json6.minItems = minimum;
21545
+ json7.minItems = minimum;
21049
21546
  if (typeof maximum === "number")
21050
- json6.maxItems = maximum;
21547
+ json7.maxItems = maximum;
21051
21548
  };
21052
21549
  var recordProcessor = (schema, ctx, _json, params) => {
21053
- const json6 = _json;
21550
+ const json7 = _json;
21054
21551
  const def = schema._zod.def;
21055
- json6.type = "object";
21552
+ json7.type = "object";
21056
21553
  const keyType = def.keyType;
21057
21554
  const keyBag = keyType._zod.bag;
21058
21555
  const patterns = keyBag?.patterns;
@@ -21061,18 +21558,18 @@ var recordProcessor = (schema, ctx, _json, params) => {
21061
21558
  ...params,
21062
21559
  path: [...params.path, "patternProperties", "*"]
21063
21560
  });
21064
- json6.patternProperties = {};
21561
+ json7.patternProperties = {};
21065
21562
  for (const pattern of patterns) {
21066
- json6.patternProperties[pattern.source] = valueSchema;
21563
+ json7.patternProperties[pattern.source] = valueSchema;
21067
21564
  }
21068
21565
  } else {
21069
21566
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
21070
- json6.propertyNames = process2(def.keyType, ctx, {
21567
+ json7.propertyNames = process2(def.keyType, ctx, {
21071
21568
  ...params,
21072
21569
  path: [...params.path, "propertyNames"]
21073
21570
  });
21074
21571
  }
21075
- json6.additionalProperties = process2(def.valueType, ctx, {
21572
+ json7.additionalProperties = process2(def.valueType, ctx, {
21076
21573
  ...params,
21077
21574
  path: [...params.path, "additionalProperties"]
21078
21575
  });
@@ -21081,19 +21578,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
21081
21578
  if (keyValues) {
21082
21579
  const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
21083
21580
  if (validKeyValues.length > 0) {
21084
- json6.required = validKeyValues;
21581
+ json7.required = validKeyValues;
21085
21582
  }
21086
21583
  }
21087
21584
  };
21088
- var nullableProcessor = (schema, ctx, json6, params) => {
21585
+ var nullableProcessor = (schema, ctx, json7, params) => {
21089
21586
  const def = schema._zod.def;
21090
21587
  const inner = process2(def.innerType, ctx, params);
21091
21588
  const seen = ctx.seen.get(schema);
21092
21589
  if (ctx.target === "openapi-3.0") {
21093
21590
  seen.ref = def.innerType;
21094
- json6.nullable = true;
21591
+ json7.nullable = true;
21095
21592
  } else {
21096
- json6.anyOf = [inner, { type: "null" }];
21593
+ json7.anyOf = [inner, { type: "null" }];
21097
21594
  }
21098
21595
  };
21099
21596
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
@@ -21102,22 +21599,22 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
21102
21599
  const seen = ctx.seen.get(schema);
21103
21600
  seen.ref = def.innerType;
21104
21601
  };
21105
- var defaultProcessor = (schema, ctx, json6, params) => {
21602
+ var defaultProcessor = (schema, ctx, json7, params) => {
21106
21603
  const def = schema._zod.def;
21107
21604
  process2(def.innerType, ctx, params);
21108
21605
  const seen = ctx.seen.get(schema);
21109
21606
  seen.ref = def.innerType;
21110
- json6.default = JSON.parse(JSON.stringify(def.defaultValue));
21607
+ json7.default = JSON.parse(JSON.stringify(def.defaultValue));
21111
21608
  };
21112
- var prefaultProcessor = (schema, ctx, json6, params) => {
21609
+ var prefaultProcessor = (schema, ctx, json7, params) => {
21113
21610
  const def = schema._zod.def;
21114
21611
  process2(def.innerType, ctx, params);
21115
21612
  const seen = ctx.seen.get(schema);
21116
21613
  seen.ref = def.innerType;
21117
21614
  if (ctx.io === "input")
21118
- json6._prefault = JSON.parse(JSON.stringify(def.defaultValue));
21615
+ json7._prefault = JSON.parse(JSON.stringify(def.defaultValue));
21119
21616
  };
21120
- var catchProcessor = (schema, ctx, json6, params) => {
21617
+ var catchProcessor = (schema, ctx, json7, params) => {
21121
21618
  const def = schema._zod.def;
21122
21619
  process2(def.innerType, ctx, params);
21123
21620
  const seen = ctx.seen.get(schema);
@@ -21128,7 +21625,7 @@ var catchProcessor = (schema, ctx, json6, params) => {
21128
21625
  } catch {
21129
21626
  throw new Error("Dynamic catch values are not supported in JSON Schema");
21130
21627
  }
21131
- json6.default = catchValue;
21628
+ json7.default = catchValue;
21132
21629
  };
21133
21630
  var pipeProcessor = (schema, ctx, _json, params) => {
21134
21631
  const def = schema._zod.def;
@@ -21138,12 +21635,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
21138
21635
  const seen = ctx.seen.get(schema);
21139
21636
  seen.ref = innerType;
21140
21637
  };
21141
- var readonlyProcessor = (schema, ctx, json6, params) => {
21638
+ var readonlyProcessor = (schema, ctx, json7, params) => {
21142
21639
  const def = schema._zod.def;
21143
21640
  process2(def.innerType, ctx, params);
21144
21641
  const seen = ctx.seen.get(schema);
21145
21642
  seen.ref = def.innerType;
21146
- json6.readOnly = true;
21643
+ json7.readOnly = true;
21147
21644
  };
21148
21645
  var promiseProcessor = (schema, ctx, _json, params) => {
21149
21646
  const def = schema._zod.def;
@@ -21413,7 +21910,7 @@ __export(exports_schemas2, {
21413
21910
  invertCodec: () => invertCodec,
21414
21911
  ipv4: () => ipv42,
21415
21912
  ipv6: () => ipv62,
21416
- json: () => json6,
21913
+ json: () => json7,
21417
21914
  jwt: () => jwt,
21418
21915
  keyof: () => keyof,
21419
21916
  ksuid: () => ksuid2,
@@ -21764,7 +22261,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
21764
22261
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
21765
22262
  $ZodString.init(inst, def);
21766
22263
  ZodType.init(inst, def);
21767
- inst._zod.processJSONSchema = (ctx, json6, params) => stringProcessor(inst, ctx, json6, params);
22264
+ inst._zod.processJSONSchema = (ctx, json7, params) => stringProcessor(inst, ctx, json7, params);
21768
22265
  const bag = inst._zod.bag;
21769
22266
  inst.format = bag.format ?? null;
21770
22267
  inst.minLength = bag.minimum ?? null;
@@ -22035,7 +22532,7 @@ function hash2(alg, params) {
22035
22532
  var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
22036
22533
  $ZodNumber.init(inst, def);
22037
22534
  ZodType.init(inst, def);
22038
- inst._zod.processJSONSchema = (ctx, json6, params) => numberProcessor(inst, ctx, json6, params);
22535
+ inst._zod.processJSONSchema = (ctx, json7, params) => numberProcessor(inst, ctx, json7, params);
22039
22536
  _installLazyMethods(inst, "ZodNumber", {
22040
22537
  gt(value, params) {
22041
22538
  return this.check(_gt(value, params));
@@ -22115,7 +22612,7 @@ function uint32(params) {
22115
22612
  var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
22116
22613
  $ZodBoolean.init(inst, def);
22117
22614
  ZodType.init(inst, def);
22118
- inst._zod.processJSONSchema = (ctx, json6, params) => booleanProcessor(inst, ctx, json6, params);
22615
+ inst._zod.processJSONSchema = (ctx, json7, params) => booleanProcessor(inst, ctx, json7, params);
22119
22616
  });
22120
22617
  function boolean2(params) {
22121
22618
  return _boolean(ZodBoolean, params);
@@ -22123,7 +22620,7 @@ function boolean2(params) {
22123
22620
  var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
22124
22621
  $ZodBigInt.init(inst, def);
22125
22622
  ZodType.init(inst, def);
22126
- inst._zod.processJSONSchema = (ctx, json6, params) => bigintProcessor(inst, ctx, json6, params);
22623
+ inst._zod.processJSONSchema = (ctx, json7, params) => bigintProcessor(inst, ctx, json7, params);
22127
22624
  inst.gte = (value, params) => inst.check(_gte(value, params));
22128
22625
  inst.min = (value, params) => inst.check(_gte(value, params));
22129
22626
  inst.gt = (value, params) => inst.check(_gt(value, params));
@@ -22158,7 +22655,7 @@ function uint64(params) {
22158
22655
  var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
22159
22656
  $ZodSymbol.init(inst, def);
22160
22657
  ZodType.init(inst, def);
22161
- inst._zod.processJSONSchema = (ctx, json6, params) => symbolProcessor(inst, ctx, json6, params);
22658
+ inst._zod.processJSONSchema = (ctx, json7, params) => symbolProcessor(inst, ctx, json7, params);
22162
22659
  });
22163
22660
  function symbol(params) {
22164
22661
  return _symbol(ZodSymbol, params);
@@ -22166,7 +22663,7 @@ function symbol(params) {
22166
22663
  var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
22167
22664
  $ZodUndefined.init(inst, def);
22168
22665
  ZodType.init(inst, def);
22169
- inst._zod.processJSONSchema = (ctx, json6, params) => undefinedProcessor(inst, ctx, json6, params);
22666
+ inst._zod.processJSONSchema = (ctx, json7, params) => undefinedProcessor(inst, ctx, json7, params);
22170
22667
  });
22171
22668
  function _undefined3(params) {
22172
22669
  return _undefined2(ZodUndefined, params);
@@ -22174,7 +22671,7 @@ function _undefined3(params) {
22174
22671
  var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
22175
22672
  $ZodNull.init(inst, def);
22176
22673
  ZodType.init(inst, def);
22177
- inst._zod.processJSONSchema = (ctx, json6, params) => nullProcessor(inst, ctx, json6, params);
22674
+ inst._zod.processJSONSchema = (ctx, json7, params) => nullProcessor(inst, ctx, json7, params);
22178
22675
  });
22179
22676
  function _null3(params) {
22180
22677
  return _null2(ZodNull, params);
@@ -22182,7 +22679,7 @@ function _null3(params) {
22182
22679
  var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
22183
22680
  $ZodAny.init(inst, def);
22184
22681
  ZodType.init(inst, def);
22185
- inst._zod.processJSONSchema = (ctx, json6, params) => anyProcessor(inst, ctx, json6, params);
22682
+ inst._zod.processJSONSchema = (ctx, json7, params) => anyProcessor(inst, ctx, json7, params);
22186
22683
  });
22187
22684
  function any() {
22188
22685
  return _any(ZodAny);
@@ -22190,7 +22687,7 @@ function any() {
22190
22687
  var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
22191
22688
  $ZodUnknown.init(inst, def);
22192
22689
  ZodType.init(inst, def);
22193
- inst._zod.processJSONSchema = (ctx, json6, params) => unknownProcessor(inst, ctx, json6, params);
22690
+ inst._zod.processJSONSchema = (ctx, json7, params) => unknownProcessor(inst, ctx, json7, params);
22194
22691
  });
22195
22692
  function unknown() {
22196
22693
  return _unknown(ZodUnknown);
@@ -22198,7 +22695,7 @@ function unknown() {
22198
22695
  var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
22199
22696
  $ZodNever.init(inst, def);
22200
22697
  ZodType.init(inst, def);
22201
- inst._zod.processJSONSchema = (ctx, json6, params) => neverProcessor(inst, ctx, json6, params);
22698
+ inst._zod.processJSONSchema = (ctx, json7, params) => neverProcessor(inst, ctx, json7, params);
22202
22699
  });
22203
22700
  function never(params) {
22204
22701
  return _never(ZodNever, params);
@@ -22206,7 +22703,7 @@ function never(params) {
22206
22703
  var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
22207
22704
  $ZodVoid.init(inst, def);
22208
22705
  ZodType.init(inst, def);
22209
- inst._zod.processJSONSchema = (ctx, json6, params) => voidProcessor(inst, ctx, json6, params);
22706
+ inst._zod.processJSONSchema = (ctx, json7, params) => voidProcessor(inst, ctx, json7, params);
22210
22707
  });
22211
22708
  function _void2(params) {
22212
22709
  return _void(ZodVoid, params);
@@ -22214,7 +22711,7 @@ function _void2(params) {
22214
22711
  var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
22215
22712
  $ZodDate.init(inst, def);
22216
22713
  ZodType.init(inst, def);
22217
- inst._zod.processJSONSchema = (ctx, json6, params) => dateProcessor(inst, ctx, json6, params);
22714
+ inst._zod.processJSONSchema = (ctx, json7, params) => dateProcessor(inst, ctx, json7, params);
22218
22715
  inst.min = (value, params) => inst.check(_gte(value, params));
22219
22716
  inst.max = (value, params) => inst.check(_lte(value, params));
22220
22717
  const c = inst._zod.bag;
@@ -22227,7 +22724,7 @@ function date3(params) {
22227
22724
  var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
22228
22725
  $ZodArray.init(inst, def);
22229
22726
  ZodType.init(inst, def);
22230
- inst._zod.processJSONSchema = (ctx, json6, params) => arrayProcessor(inst, ctx, json6, params);
22727
+ inst._zod.processJSONSchema = (ctx, json7, params) => arrayProcessor(inst, ctx, json7, params);
22231
22728
  inst.element = def.element;
22232
22729
  _installLazyMethods(inst, "ZodArray", {
22233
22730
  min(n, params) {
@@ -22257,7 +22754,7 @@ function keyof(schema) {
22257
22754
  var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
22258
22755
  $ZodObjectJIT.init(inst, def);
22259
22756
  ZodType.init(inst, def);
22260
- inst._zod.processJSONSchema = (ctx, json6, params) => objectProcessor(inst, ctx, json6, params);
22757
+ inst._zod.processJSONSchema = (ctx, json7, params) => objectProcessor(inst, ctx, json7, params);
22261
22758
  exports_util.defineLazy(inst, "shape", () => {
22262
22759
  return def.shape;
22263
22760
  });
@@ -22330,7 +22827,7 @@ function looseObject(shape, params) {
22330
22827
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
22331
22828
  $ZodUnion.init(inst, def);
22332
22829
  ZodType.init(inst, def);
22333
- inst._zod.processJSONSchema = (ctx, json6, params) => unionProcessor(inst, ctx, json6, params);
22830
+ inst._zod.processJSONSchema = (ctx, json7, params) => unionProcessor(inst, ctx, json7, params);
22334
22831
  inst.options = def.options;
22335
22832
  });
22336
22833
  function union(options, params) {
@@ -22343,7 +22840,7 @@ function union(options, params) {
22343
22840
  var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
22344
22841
  ZodUnion.init(inst, def);
22345
22842
  $ZodXor.init(inst, def);
22346
- inst._zod.processJSONSchema = (ctx, json6, params) => unionProcessor(inst, ctx, json6, params);
22843
+ inst._zod.processJSONSchema = (ctx, json7, params) => unionProcessor(inst, ctx, json7, params);
22347
22844
  inst.options = def.options;
22348
22845
  });
22349
22846
  function xor(options, params) {
@@ -22369,7 +22866,7 @@ function discriminatedUnion(discriminator, options, params) {
22369
22866
  var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
22370
22867
  $ZodIntersection.init(inst, def);
22371
22868
  ZodType.init(inst, def);
22372
- inst._zod.processJSONSchema = (ctx, json6, params) => intersectionProcessor(inst, ctx, json6, params);
22869
+ inst._zod.processJSONSchema = (ctx, json7, params) => intersectionProcessor(inst, ctx, json7, params);
22373
22870
  });
22374
22871
  function intersection(left, right) {
22375
22872
  return new ZodIntersection({
@@ -22381,7 +22878,7 @@ function intersection(left, right) {
22381
22878
  var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
22382
22879
  $ZodTuple.init(inst, def);
22383
22880
  ZodType.init(inst, def);
22384
- inst._zod.processJSONSchema = (ctx, json6, params) => tupleProcessor(inst, ctx, json6, params);
22881
+ inst._zod.processJSONSchema = (ctx, json7, params) => tupleProcessor(inst, ctx, json7, params);
22385
22882
  inst.rest = (rest) => inst.clone({
22386
22883
  ...inst._zod.def,
22387
22884
  rest
@@ -22401,7 +22898,7 @@ function tuple(items, _paramsOrRest, _params) {
22401
22898
  var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
22402
22899
  $ZodRecord.init(inst, def);
22403
22900
  ZodType.init(inst, def);
22404
- inst._zod.processJSONSchema = (ctx, json6, params) => recordProcessor(inst, ctx, json6, params);
22901
+ inst._zod.processJSONSchema = (ctx, json7, params) => recordProcessor(inst, ctx, json7, params);
22405
22902
  inst.keyType = def.keyType;
22406
22903
  inst.valueType = def.valueType;
22407
22904
  });
@@ -22443,7 +22940,7 @@ function looseRecord(keyType, valueType, params) {
22443
22940
  var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
22444
22941
  $ZodMap.init(inst, def);
22445
22942
  ZodType.init(inst, def);
22446
- inst._zod.processJSONSchema = (ctx, json6, params) => mapProcessor(inst, ctx, json6, params);
22943
+ inst._zod.processJSONSchema = (ctx, json7, params) => mapProcessor(inst, ctx, json7, params);
22447
22944
  inst.keyType = def.keyType;
22448
22945
  inst.valueType = def.valueType;
22449
22946
  inst.min = (...args) => inst.check(_minSize(...args));
@@ -22462,7 +22959,7 @@ function map(keyType, valueType, params) {
22462
22959
  var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
22463
22960
  $ZodSet.init(inst, def);
22464
22961
  ZodType.init(inst, def);
22465
- inst._zod.processJSONSchema = (ctx, json6, params) => setProcessor(inst, ctx, json6, params);
22962
+ inst._zod.processJSONSchema = (ctx, json7, params) => setProcessor(inst, ctx, json7, params);
22466
22963
  inst.min = (...args) => inst.check(_minSize(...args));
22467
22964
  inst.nonempty = (params) => inst.check(_minSize(1, params));
22468
22965
  inst.max = (...args) => inst.check(_maxSize(...args));
@@ -22478,7 +22975,7 @@ function set(valueType, params) {
22478
22975
  var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
22479
22976
  $ZodEnum.init(inst, def);
22480
22977
  ZodType.init(inst, def);
22481
- inst._zod.processJSONSchema = (ctx, json6, params) => enumProcessor(inst, ctx, json6, params);
22978
+ inst._zod.processJSONSchema = (ctx, json7, params) => enumProcessor(inst, ctx, json7, params);
22482
22979
  inst.enum = def.entries;
22483
22980
  inst.options = Object.values(def.entries);
22484
22981
  const keys = new Set(Object.keys(def.entries));
@@ -22531,7 +23028,7 @@ function nativeEnum(entries, params) {
22531
23028
  var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
22532
23029
  $ZodLiteral.init(inst, def);
22533
23030
  ZodType.init(inst, def);
22534
- inst._zod.processJSONSchema = (ctx, json6, params) => literalProcessor(inst, ctx, json6, params);
23031
+ inst._zod.processJSONSchema = (ctx, json7, params) => literalProcessor(inst, ctx, json7, params);
22535
23032
  inst.values = new Set(def.values);
22536
23033
  Object.defineProperty(inst, "value", {
22537
23034
  get() {
@@ -22552,7 +23049,7 @@ function literal(value, params) {
22552
23049
  var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
22553
23050
  $ZodFile.init(inst, def);
22554
23051
  ZodType.init(inst, def);
22555
- inst._zod.processJSONSchema = (ctx, json6, params) => fileProcessor(inst, ctx, json6, params);
23052
+ inst._zod.processJSONSchema = (ctx, json7, params) => fileProcessor(inst, ctx, json7, params);
22556
23053
  inst.min = (size, params) => inst.check(_minSize(size, params));
22557
23054
  inst.max = (size, params) => inst.check(_maxSize(size, params));
22558
23055
  inst.mime = (types2, params) => inst.check(_mime(Array.isArray(types2) ? types2 : [types2], params));
@@ -22563,7 +23060,7 @@ function file(params) {
22563
23060
  var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
22564
23061
  $ZodTransform.init(inst, def);
22565
23062
  ZodType.init(inst, def);
22566
- inst._zod.processJSONSchema = (ctx, json6, params) => transformProcessor(inst, ctx, json6, params);
23063
+ inst._zod.processJSONSchema = (ctx, json7, params) => transformProcessor(inst, ctx, json7, params);
22567
23064
  inst._zod.parse = (payload, _ctx) => {
22568
23065
  if (_ctx.direction === "backward") {
22569
23066
  throw new $ZodEncodeError(inst.constructor.name);
@@ -22603,7 +23100,7 @@ function transform(fn) {
22603
23100
  var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
22604
23101
  $ZodOptional.init(inst, def);
22605
23102
  ZodType.init(inst, def);
22606
- inst._zod.processJSONSchema = (ctx, json6, params) => optionalProcessor(inst, ctx, json6, params);
23103
+ inst._zod.processJSONSchema = (ctx, json7, params) => optionalProcessor(inst, ctx, json7, params);
22607
23104
  inst.unwrap = () => inst._zod.def.innerType;
22608
23105
  });
22609
23106
  function optional(innerType) {
@@ -22615,7 +23112,7 @@ function optional(innerType) {
22615
23112
  var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
22616
23113
  $ZodExactOptional.init(inst, def);
22617
23114
  ZodType.init(inst, def);
22618
- inst._zod.processJSONSchema = (ctx, json6, params) => optionalProcessor(inst, ctx, json6, params);
23115
+ inst._zod.processJSONSchema = (ctx, json7, params) => optionalProcessor(inst, ctx, json7, params);
22619
23116
  inst.unwrap = () => inst._zod.def.innerType;
22620
23117
  });
22621
23118
  function exactOptional(innerType) {
@@ -22627,7 +23124,7 @@ function exactOptional(innerType) {
22627
23124
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
22628
23125
  $ZodNullable.init(inst, def);
22629
23126
  ZodType.init(inst, def);
22630
- inst._zod.processJSONSchema = (ctx, json6, params) => nullableProcessor(inst, ctx, json6, params);
23127
+ inst._zod.processJSONSchema = (ctx, json7, params) => nullableProcessor(inst, ctx, json7, params);
22631
23128
  inst.unwrap = () => inst._zod.def.innerType;
22632
23129
  });
22633
23130
  function nullable(innerType) {
@@ -22642,7 +23139,7 @@ function nullish2(innerType) {
22642
23139
  var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
22643
23140
  $ZodDefault.init(inst, def);
22644
23141
  ZodType.init(inst, def);
22645
- inst._zod.processJSONSchema = (ctx, json6, params) => defaultProcessor(inst, ctx, json6, params);
23142
+ inst._zod.processJSONSchema = (ctx, json7, params) => defaultProcessor(inst, ctx, json7, params);
22646
23143
  inst.unwrap = () => inst._zod.def.innerType;
22647
23144
  inst.removeDefault = inst.unwrap;
22648
23145
  });
@@ -22658,7 +23155,7 @@ function _default2(innerType, defaultValue) {
22658
23155
  var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
22659
23156
  $ZodPrefault.init(inst, def);
22660
23157
  ZodType.init(inst, def);
22661
- inst._zod.processJSONSchema = (ctx, json6, params) => prefaultProcessor(inst, ctx, json6, params);
23158
+ inst._zod.processJSONSchema = (ctx, json7, params) => prefaultProcessor(inst, ctx, json7, params);
22662
23159
  inst.unwrap = () => inst._zod.def.innerType;
22663
23160
  });
22664
23161
  function prefault(innerType, defaultValue) {
@@ -22673,7 +23170,7 @@ function prefault(innerType, defaultValue) {
22673
23170
  var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
22674
23171
  $ZodNonOptional.init(inst, def);
22675
23172
  ZodType.init(inst, def);
22676
- inst._zod.processJSONSchema = (ctx, json6, params) => nonoptionalProcessor(inst, ctx, json6, params);
23173
+ inst._zod.processJSONSchema = (ctx, json7, params) => nonoptionalProcessor(inst, ctx, json7, params);
22677
23174
  inst.unwrap = () => inst._zod.def.innerType;
22678
23175
  });
22679
23176
  function nonoptional(innerType, params) {
@@ -22686,7 +23183,7 @@ function nonoptional(innerType, params) {
22686
23183
  var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
22687
23184
  $ZodSuccess.init(inst, def);
22688
23185
  ZodType.init(inst, def);
22689
- inst._zod.processJSONSchema = (ctx, json6, params) => successProcessor(inst, ctx, json6, params);
23186
+ inst._zod.processJSONSchema = (ctx, json7, params) => successProcessor(inst, ctx, json7, params);
22690
23187
  inst.unwrap = () => inst._zod.def.innerType;
22691
23188
  });
22692
23189
  function success(innerType) {
@@ -22698,7 +23195,7 @@ function success(innerType) {
22698
23195
  var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
22699
23196
  $ZodCatch.init(inst, def);
22700
23197
  ZodType.init(inst, def);
22701
- inst._zod.processJSONSchema = (ctx, json6, params) => catchProcessor(inst, ctx, json6, params);
23198
+ inst._zod.processJSONSchema = (ctx, json7, params) => catchProcessor(inst, ctx, json7, params);
22702
23199
  inst.unwrap = () => inst._zod.def.innerType;
22703
23200
  inst.removeCatch = inst.unwrap;
22704
23201
  });
@@ -22712,7 +23209,7 @@ function _catch2(innerType, catchValue) {
22712
23209
  var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
22713
23210
  $ZodNaN.init(inst, def);
22714
23211
  ZodType.init(inst, def);
22715
- inst._zod.processJSONSchema = (ctx, json6, params) => nanProcessor(inst, ctx, json6, params);
23212
+ inst._zod.processJSONSchema = (ctx, json7, params) => nanProcessor(inst, ctx, json7, params);
22716
23213
  });
22717
23214
  function nan(params) {
22718
23215
  return _nan(ZodNaN, params);
@@ -22720,7 +23217,7 @@ function nan(params) {
22720
23217
  var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
22721
23218
  $ZodPipe.init(inst, def);
22722
23219
  ZodType.init(inst, def);
22723
- inst._zod.processJSONSchema = (ctx, json6, params) => pipeProcessor(inst, ctx, json6, params);
23220
+ inst._zod.processJSONSchema = (ctx, json7, params) => pipeProcessor(inst, ctx, json7, params);
22724
23221
  inst.in = def.in;
22725
23222
  inst.out = def.out;
22726
23223
  });
@@ -22761,7 +23258,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
22761
23258
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
22762
23259
  $ZodReadonly.init(inst, def);
22763
23260
  ZodType.init(inst, def);
22764
- inst._zod.processJSONSchema = (ctx, json6, params) => readonlyProcessor(inst, ctx, json6, params);
23261
+ inst._zod.processJSONSchema = (ctx, json7, params) => readonlyProcessor(inst, ctx, json7, params);
22765
23262
  inst.unwrap = () => inst._zod.def.innerType;
22766
23263
  });
22767
23264
  function readonly(innerType) {
@@ -22773,7 +23270,7 @@ function readonly(innerType) {
22773
23270
  var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
22774
23271
  $ZodTemplateLiteral.init(inst, def);
22775
23272
  ZodType.init(inst, def);
22776
- inst._zod.processJSONSchema = (ctx, json6, params) => templateLiteralProcessor(inst, ctx, json6, params);
23273
+ inst._zod.processJSONSchema = (ctx, json7, params) => templateLiteralProcessor(inst, ctx, json7, params);
22777
23274
  });
22778
23275
  function templateLiteral(parts, params) {
22779
23276
  return new ZodTemplateLiteral({
@@ -22785,7 +23282,7 @@ function templateLiteral(parts, params) {
22785
23282
  var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
22786
23283
  $ZodLazy.init(inst, def);
22787
23284
  ZodType.init(inst, def);
22788
- inst._zod.processJSONSchema = (ctx, json6, params) => lazyProcessor(inst, ctx, json6, params);
23285
+ inst._zod.processJSONSchema = (ctx, json7, params) => lazyProcessor(inst, ctx, json7, params);
22789
23286
  inst.unwrap = () => inst._zod.def.getter();
22790
23287
  });
22791
23288
  function lazy(getter) {
@@ -22797,7 +23294,7 @@ function lazy(getter) {
22797
23294
  var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
22798
23295
  $ZodPromise.init(inst, def);
22799
23296
  ZodType.init(inst, def);
22800
- inst._zod.processJSONSchema = (ctx, json6, params) => promiseProcessor(inst, ctx, json6, params);
23297
+ inst._zod.processJSONSchema = (ctx, json7, params) => promiseProcessor(inst, ctx, json7, params);
22801
23298
  inst.unwrap = () => inst._zod.def.innerType;
22802
23299
  });
22803
23300
  function promise(innerType) {
@@ -22809,7 +23306,7 @@ function promise(innerType) {
22809
23306
  var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
22810
23307
  $ZodFunction.init(inst, def);
22811
23308
  ZodType.init(inst, def);
22812
- inst._zod.processJSONSchema = (ctx, json6, params) => functionProcessor(inst, ctx, json6, params);
23309
+ inst._zod.processJSONSchema = (ctx, json7, params) => functionProcessor(inst, ctx, json7, params);
22813
23310
  });
22814
23311
  function _function(params) {
22815
23312
  return new ZodFunction({
@@ -22821,7 +23318,7 @@ function _function(params) {
22821
23318
  var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
22822
23319
  $ZodCustom.init(inst, def);
22823
23320
  ZodType.init(inst, def);
22824
- inst._zod.processJSONSchema = (ctx, json6, params) => customProcessor(inst, ctx, json6, params);
23321
+ inst._zod.processJSONSchema = (ctx, json7, params) => customProcessor(inst, ctx, json7, params);
22825
23322
  });
22826
23323
  function check(fn) {
22827
23324
  const ch = new $ZodCheck({
@@ -22868,7 +23365,7 @@ var stringbool = (...args) => _stringbool({
22868
23365
  Boolean: ZodBoolean,
22869
23366
  String: ZodString
22870
23367
  }, ...args);
22871
- function json6(params) {
23368
+ function json7(params) {
22872
23369
  const jsonSchema = lazy(() => {
22873
23370
  return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
22874
23371
  });
@@ -24225,10 +24722,10 @@ function prepareArtifact(input) {
24225
24722
  attempts,
24226
24723
  error: error51.value
24227
24724
  };
24228
- const json7 = JSON.stringify(bounded);
24229
- const size = encoder2.encode(json7).length;
24725
+ const json8 = JSON.stringify(bounded);
24726
+ const size = encoder2.encode(json8).length;
24230
24727
  if (size <= MAX_ARTIFACT_BYTES)
24231
- return { artifact: bounded, json: json7 };
24728
+ return { artifact: bounded, json: json8 };
24232
24729
  const marker = omission(size);
24233
24730
  const omitted = omitBodies(bounded, marker);
24234
24731
  const omittedJson = JSON.stringify(omitted);
@@ -24238,8 +24735,8 @@ function prepareArtifact(input) {
24238
24735
  const stripped = { ...omitted, error: marker };
24239
24736
  return { artifact: stripped, json: JSON.stringify(stripped) };
24240
24737
  }
24241
- async function sealArtifact(key, json7) {
24242
- const bytes = encoder2.encode(await encrypt(key, json7));
24738
+ async function sealArtifact(key, json8) {
24739
+ const bytes = encoder2.encode(await encrypt(key, json8));
24243
24740
  return { bytes, sha256: await sha256Hex(bytes) };
24244
24741
  }
24245
24742
  async function readArtifact(key, dir, relPath, expectedSha256) {
@@ -26329,13 +26826,15 @@ function customProviderData(input) {
26329
26826
  } catch {
26330
26827
  throw new GatewayError("BAD_REQUEST", "origin: must be a valid URL");
26331
26828
  }
26332
- if (url2.protocol !== "http:" && url2.protocol !== "https:" || url2.hostname.length === 0 || url2.username.length > 0 || url2.password.length > 0 || url2.pathname !== "" && url2.pathname !== "/" || url2.search.length > 0 || url2.hash.length > 0) {
26829
+ if (url2.protocol !== "http:" && url2.protocol !== "https:" || url2.hostname.length === 0 || url2.username.length > 0 || url2.password.length > 0 || url2.search.length > 0 || url2.hash.length > 0) {
26333
26830
  throw new GatewayError("BAD_REQUEST", "origin: must be an HTTP(S) server origin");
26334
26831
  }
26335
- return { endpointId, endpointLabel, origin: url2.origin, protocol: input.protocol };
26832
+ const basePath = url2.pathname.replace(/\/+$/, "");
26833
+ return { endpointId, endpointLabel, origin: url2.origin, basePath, protocol: input.protocol };
26336
26834
  }
26337
26835
  function sameCustomEndpoint(a, b) {
26338
- return a.endpointId === b.endpointId && a.endpointLabel === b.endpointLabel && a.origin === b.origin && a.protocol === b.protocol;
26836
+ const basePath = typeof a.basePath === "string" ? a.basePath : "";
26837
+ return a.endpointId === b.endpointId && a.endpointLabel === b.endpointLabel && a.origin === b.origin && basePath === b.basePath && a.protocol === b.protocol;
26339
26838
  }
26340
26839
  async function createApiKeyCredential(store, input, logger2 = noopLogger) {
26341
26840
  const provider = parseOrThrow(providerIdSchema, input.provider);
@@ -27465,10 +27964,10 @@ function emailFromIdToken(idToken) {
27465
27964
  if (parts.length !== 3 || payload === undefined || payload.length === 0)
27466
27965
  return null;
27467
27966
  try {
27468
- const json7 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
27469
- if (!isRecord2(json7))
27967
+ const json8 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
27968
+ if (!isRecord2(json8))
27470
27969
  return null;
27471
- return typeof json7.email === "string" && json7.email.trim().length > 0 ? json7.email : null;
27970
+ return typeof json8.email === "string" && json8.email.trim().length > 0 ? json8.email : null;
27472
27971
  } catch {
27473
27972
  return null;
27474
27973
  }
@@ -27871,12 +28370,12 @@ function decodeClaims(idToken) {
27871
28370
  return { email: null, accountId: null };
27872
28371
  }
27873
28372
  try {
27874
- const json7 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
27875
- if (!isRecord5(json7))
28373
+ const json8 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
28374
+ if (!isRecord5(json8))
27876
28375
  return { email: null, accountId: null };
27877
- const auth = json7["https://api.openai.com/auth"];
28376
+ const auth = json8["https://api.openai.com/auth"];
27878
28377
  return {
27879
- email: typeof json7.email === "string" ? json7.email : null,
28378
+ email: typeof json8.email === "string" ? json8.email : null,
27880
28379
  accountId: isRecord5(auth) ? nonBlankStringOrNull(auth.chatgpt_account_id) : null
27881
28380
  };
27882
28381
  } catch {
@@ -43479,6 +43978,15 @@ async function* openaiStream(events, requestId, created) {
43479
43978
  finish_reason: null
43480
43979
  }));
43481
43980
  }
43981
+ } else if (event.block.type === "thinking") {
43982
+ if (!roleSent) {
43983
+ roleSent = true;
43984
+ yield emit(chunk(requestId, created, model, {
43985
+ index: 0,
43986
+ delta: { role: "assistant" },
43987
+ finish_reason: null
43988
+ }));
43989
+ }
43482
43990
  } else if (event.block.type === "toolUse") {
43483
43991
  const index = toolIndex.size;
43484
43992
  toolIndex.set(event.index, index);
@@ -43510,6 +44018,12 @@ async function* openaiStream(events, requestId, created) {
43510
44018
  delta: { content: d.text },
43511
44019
  finish_reason: null
43512
44020
  }));
44021
+ } else if (d.type === "thinking") {
44022
+ yield emit(chunk(requestId, created, model, {
44023
+ index: 0,
44024
+ delta: { reasoning_content: d.text },
44025
+ finish_reason: null
44026
+ }));
43513
44027
  } else if (d.type === "toolJson") {
43514
44028
  const index = toolIndex.get(event.index) ?? 0;
43515
44029
  yield emit(chunk(requestId, created, model, {
@@ -43538,6 +44052,7 @@ async function* openaiStream(events, requestId, created) {
43538
44052
  }
43539
44053
  function openaiResponse(collected, requestId, created) {
43540
44054
  const text = collected.content.flatMap((b) => b.type === "text" ? [b.text] : []).join("");
44055
+ const reasoning = collected.content.flatMap((b) => b.type === "thinking" ? [b.text] : []).join("");
43541
44056
  const toolCalls = collected.content.flatMap((b) => b.type === "toolUse" ? [
43542
44057
  {
43543
44058
  id: b.id,
@@ -43556,6 +44071,7 @@ function openaiResponse(collected, requestId, created) {
43556
44071
  message: {
43557
44072
  role: "assistant",
43558
44073
  content: toolCalls.length > 0 && text.length === 0 ? null : text,
44074
+ ...reasoning.length > 0 ? { reasoning_content: reasoning } : {},
43559
44075
  ...toolCalls.length > 0 ? { tool_calls: toolCalls } : {}
43560
44076
  },
43561
44077
  finish_reason: FINISH3[collected.stopReason]
@@ -47470,7 +47986,7 @@ function readBlock(raw, role, path) {
47470
47986
  function toIrToolChoice(c) {
47471
47987
  return c.type === "tool" ? { type: "tool", name: c.name } : { type: c.type };
47472
47988
  }
47473
- var EFFORTS = ["low", "medium", "high", "xhigh", "max"];
47989
+ var EFFORTS = REASONING_EFFORTS;
47474
47990
  function readEffort(body2) {
47475
47991
  if (!isRecord6(body2))
47476
47992
  return;
@@ -47627,7 +48143,7 @@ var schema2 = exports_external.object({
47627
48143
  exports_external.enum(["auto", "none", "required"]),
47628
48144
  exports_external.object({ type: exports_external.literal("function"), function: exports_external.object({ name: exports_external.string() }) })
47629
48145
  ]).optional(),
47630
- reasoning_effort: exports_external.enum(["low", "medium", "high"]).optional()
48146
+ reasoning_effort: exports_external.enum(REASONING_EFFORTS).optional()
47631
48147
  });
47632
48148
  var KNOWN2 = [
47633
48149
  "model",