@tonyclaw/agent-inspector 2.1.12 → 2.1.14

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 (83) hide show
  1. package/.output/cli.js +0 -8
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/assets/CompareDrawer-DjgjIFx7.js +1 -0
  4. package/.output/public/assets/ProxyViewerContainer-CWUQZLYy.js +106 -0
  5. package/.output/public/assets/{ReplayDialog-Cd1VsfRe.js → ReplayDialog-CU0Tbb2c.js} +1 -1
  6. package/.output/public/assets/{RequestAnatomy-QxSpbmsj.js → RequestAnatomy-BNahe83D.js} +1 -1
  7. package/.output/public/assets/ResponseView-DSOnGqi6.js +3 -0
  8. package/.output/public/assets/{StreamingChunkSequence-CwNGqJ5n.js → StreamingChunkSequence-BEKTDklB.js} +1 -1
  9. package/.output/public/assets/_sessionId-Cif8JZdn.js +1 -0
  10. package/.output/public/assets/index-DWOkqdCa.js +14 -0
  11. package/.output/public/assets/index-D_WfwzUi.js +1 -0
  12. package/.output/public/assets/index-DtLuQrs0.css +1 -0
  13. package/.output/public/assets/json-viewer-C2JpgcW0.js +1 -0
  14. package/.output/public/assets/{main-B_EcGyf-.js → main-CSONBwwn.js} +2 -2
  15. package/.output/server/_libs/lucide-react.mjs +20 -20
  16. package/.output/server/_libs/react-markdown.mjs +90 -2
  17. package/.output/server/{_sessionId-CmO9read.mjs → _sessionId-CPAa37n5.mjs} +6 -57
  18. package/.output/server/_ssr/{CompareDrawer-D9wf870o.mjs → CompareDrawer-ceW5VxMo.mjs} +17 -62
  19. package/.output/server/_ssr/{ProxyViewerContainer-BDLJSawP.mjs → ProxyViewerContainer-CDfEE_w-.mjs} +872 -688
  20. package/.output/server/_ssr/{ReplayDialog-B2dS4kmP.mjs → ReplayDialog-V0s_eEbR.mjs} +8 -59
  21. package/.output/server/_ssr/{RequestAnatomy-k49Peshi.mjs → RequestAnatomy-f1ccwR9d.mjs} +6 -57
  22. package/.output/server/_ssr/{ResponseView-Bk3B1suu.mjs → ResponseView-BIRrqG4H.mjs} +138 -60
  23. package/.output/server/_ssr/{StreamingChunkSequence-D6MDGCgh.mjs → StreamingChunkSequence-V3JFjCgX.mjs} +13 -58
  24. package/.output/server/_ssr/{index-CC8KdlTb.mjs → index-DsykulzS.mjs} +6 -57
  25. package/.output/server/_ssr/index.mjs +2 -2
  26. package/.output/server/_ssr/json-viewer-Dcnm0Ivf.mjs +478 -0
  27. package/.output/server/_ssr/{router-BEmMnVa7.mjs → router-4bdm6Mt2.mjs} +674 -173
  28. package/.output/server/{_tanstack-start-manifest_v-Bf_4hG4w.mjs → _tanstack-start-manifest_v-Xp4CO64V.mjs} +1 -1
  29. package/.output/server/index.mjs +70 -56
  30. package/package.json +1 -1
  31. package/src/components/ProxyViewerContainer.tsx +25 -17
  32. package/src/components/providers/ImportWizardDialog.tsx +7 -1
  33. package/src/components/providers/ProviderCard.tsx +10 -1
  34. package/src/components/providers/ProviderForm.tsx +157 -41
  35. package/src/components/providers/ProvidersPanel.tsx +5 -1
  36. package/src/components/proxy-viewer/AnswerMarkdown.tsx +8 -3
  37. package/src/components/proxy-viewer/CompareDrawer.tsx +20 -6
  38. package/src/components/proxy-viewer/ConversationGroup.tsx +11 -15
  39. package/src/components/proxy-viewer/LogEntry.tsx +31 -11
  40. package/src/components/proxy-viewer/LogEntryHeader.tsx +111 -40
  41. package/src/components/proxy-viewer/RequestToolsPanel.tsx +19 -13
  42. package/src/components/proxy-viewer/StreamingChunkSequence.tsx +9 -3
  43. package/src/components/proxy-viewer/TurnGroup.tsx +53 -7
  44. package/src/components/proxy-viewer/TurnGroupList.tsx +153 -0
  45. package/src/components/proxy-viewer/anatomy/sessionContextSummary.ts +74 -2
  46. package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +13 -7
  47. package/src/components/proxy-viewer/formats/index.tsx +10 -3
  48. package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +185 -17
  49. package/src/components/proxy-viewer/log-formats/openai.ts +107 -15
  50. package/src/components/proxy-viewer/logFocus.ts +15 -2
  51. package/src/components/proxy-viewer/requestTools.ts +7 -3
  52. package/src/components/proxy-viewer/viewerState.ts +72 -3
  53. package/src/components/ui/json-viewer-bulk.ts +41 -6
  54. package/src/components/ui/json-viewer.tsx +9 -8
  55. package/src/contracts/index.ts +15 -1
  56. package/src/contracts/openai.ts +94 -0
  57. package/src/lib/providerContract.ts +1 -0
  58. package/src/lib/providerModelMetadata.ts +7 -1
  59. package/src/lib/stopReason.ts +12 -0
  60. package/src/lib/upstreamUrl.ts +46 -0
  61. package/src/mcp/previewExtractor.ts +73 -3
  62. package/src/mcp/server.ts +2 -0
  63. package/src/mcp/toolHandlers.ts +2 -0
  64. package/src/proxy/constants.ts +2 -0
  65. package/src/proxy/formats/openai/handler.ts +40 -9
  66. package/src/proxy/formats/openai/index.ts +7 -0
  67. package/src/proxy/formats/openai/schemas.ts +15 -1
  68. package/src/proxy/formats/openai/stream.ts +529 -135
  69. package/src/proxy/formats/registry.ts +9 -1
  70. package/src/proxy/identityProxy.ts +0 -7
  71. package/src/proxy/providerImporters.ts +45 -5
  72. package/src/proxy/providers.ts +31 -11
  73. package/src/proxy/schemas.ts +6 -0
  74. package/src/proxy/toolSchemaWarnings.ts +25 -3
  75. package/src/proxy/upstream.ts +18 -37
  76. package/src/routes/api/providers.$providerId.ts +1 -0
  77. package/src/routes/api/providers.ts +2 -0
  78. package/.output/public/assets/CompareDrawer-XTdSOto9.js +0 -1
  79. package/.output/public/assets/ProxyViewerContainer-Cc944N8i.js +0 -117
  80. package/.output/public/assets/ResponseView-8GivXCzp.js +0 -1
  81. package/.output/public/assets/_sessionId-D89uDTQs.js +0 -1
  82. package/.output/public/assets/index-BsFdgXac.js +0 -1
  83. package/.output/public/assets/index-CmtfjQPv.css +0 -1
@@ -16,7 +16,7 @@ import { Worker } from "node:worker_threads";
16
16
  import { M as McpServer, W as WebStandardStreamableHTTPServerTransport, R as ResourceTemplate } from "../_libs/modelcontextprotocol__server.mjs";
17
17
  import { J as JSZip } from "../_libs/jszip.mjs";
18
18
  import { homedir } from "node:os";
19
- import { d as object, b as string, a as array, r as record, _ as _enum, u as union, n as number, c as boolean, e as unknown, l as literal, k as lazy, g as discriminatedUnion, h as _null } from "../_libs/zod.mjs";
19
+ import { d as object, b as string, a as array, r as record, _ as _enum, u as union, n as number, c as boolean, e as unknown, l as literal, h as _null, k as lazy, g as discriminatedUnion } from "../_libs/zod.mjs";
20
20
  import "../_libs/tiny-warning.mjs";
21
21
  import "../_libs/tanstack__router-core.mjs";
22
22
  import "../_libs/cookie-es.mjs";
@@ -65,7 +65,7 @@ import "../_libs/immediate.mjs";
65
65
  import "../_libs/setimmediate.mjs";
66
66
  import "../_libs/pako.mjs";
67
67
  const faviconSvg = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20role='img'%20aria-label='Agent%20Inspector'%3e%3cg%20fill='none'%20stroke='%23f59e0b'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%20%3e%3cpath%20d='M5%2013%20C5%209%208%207%2012%207%20C16%207%2019%209%2019%2013%20C19%2016%2016%2018%2012%2018%20C8%2018%205%2016%205%2013%20Z'%20/%3e%3cpath%20d='M5%2011%20C3.5%209.5%201.5%2010%202%2012.5%20C2.5%2014%204%2013.5%205%2012.5'%20/%3e%3cpath%20d='M19%2011%20C20.5%209.5%2022.5%2010%2022%2012.5%20C21.5%2014%2020%2013.5%2019%2012.5'%20/%3e%3cline%20x1='10'%20y1='7'%20x2='9.5'%20y2='5'%20/%3e%3cline%20x1='14'%20y1='7'%20x2='14.5'%20y2='5'%20/%3e%3cline%20x1='6.5'%20y1='16'%20x2='4.5'%20y2='19.5'%20/%3e%3cline%20x1='9'%20y1='17.5'%20x2='8'%20y2='20.5'%20/%3e%3cline%20x1='15'%20y1='17.5'%20x2='16'%20y2='20.5'%20/%3e%3cline%20x1='17.5'%20y1='16'%20x2='19.5'%20y2='19.5'%20/%3e%3c/g%3e%3ccircle%20cx='9.5'%20cy='4.5'%20r='0.9'%20fill='%23f59e0b'%20/%3e%3ccircle%20cx='14.5'%20cy='4.5'%20r='0.9'%20fill='%23f59e0b'%20/%3e%3c/svg%3e";
68
- const appCss = "/assets/index-CmtfjQPv.css";
68
+ const appCss = "/assets/index-DtLuQrs0.css";
69
69
  const Route$D = createRootRoute({
70
70
  head: () => ({
71
71
  meta: [
@@ -108,7 +108,7 @@ function RootDocument({ children }) {
108
108
  ] })
109
109
  ] });
110
110
  }
111
- const $$splitComponentImporter$1 = () => import("./index-CC8KdlTb.mjs");
111
+ const $$splitComponentImporter$1 = () => import("./index-DsykulzS.mjs");
112
112
  const Route$C = createFileRoute("/")({
113
113
  component: lazyRouteComponent($$splitComponentImporter$1, "component")
114
114
  });
@@ -151,7 +151,7 @@ function decodeSessionIdFromPath(encoded) {
151
151
  function getSessionPath(sessionId) {
152
152
  return `/session/${encodeSessionIdForPath(sessionId)}`;
153
153
  }
154
- const $$splitComponentImporter = () => import("../_sessionId-CmO9read.mjs");
154
+ const $$splitComponentImporter = () => import("../_sessionId-CPAa37n5.mjs");
155
155
  const Route$B = createFileRoute("/session/$sessionId")({
156
156
  component: lazyRouteComponent($$splitComponentImporter, "component"),
157
157
  parseParams: (params) => ({
@@ -685,6 +685,29 @@ const OpenAIRequestSchema = object({
685
685
  ]).optional(),
686
686
  user: string().optional()
687
687
  });
688
+ const OpenAIResponsesToolDefinition = object({
689
+ type: string(),
690
+ name: string().optional(),
691
+ description: string().optional(),
692
+ parameters: JsonValueSchema.optional(),
693
+ function: object({
694
+ name: string().optional(),
695
+ description: string().optional(),
696
+ parameters: JsonValueSchema.optional()
697
+ }).optional()
698
+ }).passthrough();
699
+ const OpenAIResponsesRequestSchema = object({
700
+ model: string(),
701
+ input: unknown().optional(),
702
+ instructions: union([string(), _null()]).optional(),
703
+ stream: boolean().optional(),
704
+ tools: array(OpenAIResponsesToolDefinition).optional(),
705
+ tool_choice: unknown().optional(),
706
+ max_output_tokens: number().optional(),
707
+ temperature: number().optional(),
708
+ user: string().optional(),
709
+ metadata: record(string(), unknown()).optional()
710
+ }).passthrough();
688
711
  const OpenAIChoiceDelta = object({
689
712
  role: _enum(["assistant"]).optional(),
690
713
  content: string().nullable().optional(),
@@ -750,6 +773,34 @@ const OpenAISSERawChunkSchema = object({
750
773
  total_tokens: number().nullable().optional()
751
774
  }).passthrough().nullable().optional()
752
775
  }).passthrough();
776
+ const OpenAIResponsesUsageSchema = object({
777
+ input_tokens: number().nullable().optional(),
778
+ output_tokens: number().nullable().optional(),
779
+ total_tokens: number().nullable().optional(),
780
+ input_tokens_details: object({
781
+ cached_tokens: number().nullable().optional()
782
+ }).passthrough().nullable().optional(),
783
+ output_tokens_details: object({
784
+ reasoning_tokens: number().nullable().optional()
785
+ }).passthrough().nullable().optional()
786
+ }).passthrough();
787
+ const OpenAIResponsesOutputItemSchema = object({
788
+ type: string()
789
+ }).passthrough();
790
+ const OpenAIResponsesResponseSchema = object({
791
+ id: string(),
792
+ object: literal("response").optional(),
793
+ created_at: number().optional(),
794
+ status: string().nullable().optional(),
795
+ model: string().optional(),
796
+ output: array(OpenAIResponsesOutputItemSchema).optional(),
797
+ output_text: string().optional(),
798
+ usage: OpenAIResponsesUsageSchema.nullable().optional(),
799
+ error: unknown().optional()
800
+ }).passthrough();
801
+ const OpenAIResponsesSSEventSchema = object({
802
+ type: string()
803
+ }).passthrough();
753
804
  function parseOpenAIResponse(rawBody) {
754
805
  try {
755
806
  const json = JSON.parse(rawBody);
@@ -760,6 +811,16 @@ function parseOpenAIResponse(rawBody) {
760
811
  return null;
761
812
  }
762
813
  }
814
+ function parseOpenAIResponsesResponse(rawBody) {
815
+ try {
816
+ const json = JSON.parse(rawBody);
817
+ const result = OpenAIResponsesResponseSchema.safeParse(json);
818
+ if (result.success) return result.data;
819
+ return null;
820
+ } catch {
821
+ return null;
822
+ }
823
+ }
763
824
  const RequestModelSchema = object({
764
825
  model: string()
765
826
  });
@@ -1000,7 +1061,7 @@ function objectFromUnknown$1(value) {
1000
1061
  if (typeof value === "object" || typeof value === "function") return value;
1001
1062
  return null;
1002
1063
  }
1003
- function readProperty$2(value, name) {
1064
+ function readProperty$3(value, name) {
1004
1065
  let current = objectFromUnknown$1(value);
1005
1066
  while (current !== null) {
1006
1067
  const desc = Object.getOwnPropertyDescriptor(current, name);
@@ -1014,7 +1075,7 @@ function readProperty$2(value, name) {
1014
1075
  return void 0;
1015
1076
  }
1016
1077
  function readFunction$1(value, name) {
1017
- const property = readProperty$2(value, name);
1078
+ const property = readProperty$3(value, name);
1018
1079
  return typeof property === "function" ? property : null;
1019
1080
  }
1020
1081
  function callMethod$1(target, methodName, args) {
@@ -1056,7 +1117,7 @@ function execSql$1(db, sql) {
1056
1117
  return result !== void 0;
1057
1118
  }
1058
1119
  function sqliteConstructorFromModule$1(moduleValue, exportName) {
1059
- const exportedValue = readProperty$2(moduleValue, exportName);
1120
+ const exportedValue = readProperty$3(moduleValue, exportName);
1060
1121
  if (typeof exportedValue === "function") {
1061
1122
  return (path2) => Reflect.construct(exportedValue, [path2]);
1062
1123
  }
@@ -1199,11 +1260,11 @@ function entryParams(entry) {
1199
1260
  ];
1200
1261
  }
1201
1262
  function readNumber$1(row, name) {
1202
- const value = readProperty$2(row, name);
1263
+ const value = readProperty$3(row, name);
1203
1264
  return typeof value === "number" && Number.isFinite(value) ? value : null;
1204
1265
  }
1205
1266
  function readString$2(row, name) {
1206
- const value = readProperty$2(row, name);
1267
+ const value = readProperty$3(row, name);
1207
1268
  return typeof value === "string" ? value : null;
1208
1269
  }
1209
1270
  function readBoolean(row, name) {
@@ -1927,8 +1988,10 @@ function buildSessionInfo(input) {
1927
1988
  const DEFAULT_UPSTREAM$1 = "https://api.anthropic.com";
1928
1989
  const DEFAULT_OPENAI_UPSTREAM$1 = "https://api.openai.com/v1";
1929
1990
  const PROXY_IDENTITY = process.env["PROXY_IDENTITY"] ?? "inspector9527@Tony";
1930
- const PATH_V1_CHAT_COMPLETIONS = "/v1/chat/completions";
1991
+ const PATH_V1_CHAT_COMPLETIONS$1 = "/v1/chat/completions";
1931
1992
  const PATH_CHAT_COMPLETIONS = "/chat/completions";
1993
+ const PATH_V1_RESPONSES = "/v1/responses";
1994
+ const PATH_RESPONSES = "/responses";
1932
1995
  const PATH_V1_MESSAGES = "/v1/messages";
1933
1996
  const HEADER_CONTENT_TYPE = "content-type";
1934
1997
  const HEADER_USER_AGENT = "user-agent";
@@ -1984,8 +2047,10 @@ function apiFormatForPath(path2) {
1984
2047
  return formatRegistry.getApiFormatByPath(path2) ?? "unknown";
1985
2048
  }
1986
2049
  formatRegistry.registerPath(PATH_V1_MESSAGES, "anthropic");
1987
- formatRegistry.registerPath(PATH_V1_CHAT_COMPLETIONS, "openai");
2050
+ formatRegistry.registerPath(PATH_V1_CHAT_COMPLETIONS$1, "openai");
1988
2051
  formatRegistry.registerPath(PATH_CHAT_COMPLETIONS, "openai");
2052
+ formatRegistry.registerPath(PATH_V1_RESPONSES, "openai");
2053
+ formatRegistry.registerPath(PATH_RESPONSES, "openai");
1989
2054
  const SESSION_ARCHIVE_DIR = "sessions";
1990
2055
  const SESSION_ARCHIVE_FILE = "session.sqlite";
1991
2056
  const SQLITE_PACKAGE_NAME = "better-sqlite3";
@@ -2036,7 +2101,7 @@ function objectFromUnknown(value) {
2036
2101
  if (typeof value === "object" || typeof value === "function") return value;
2037
2102
  return null;
2038
2103
  }
2039
- function readProperty$1(value, name) {
2104
+ function readProperty$2(value, name) {
2040
2105
  let current = objectFromUnknown(value);
2041
2106
  while (current !== null) {
2042
2107
  const desc = Object.getOwnPropertyDescriptor(current, name);
@@ -2050,7 +2115,7 @@ function readProperty$1(value, name) {
2050
2115
  return void 0;
2051
2116
  }
2052
2117
  function readFunction(value, name) {
2053
- const property = readProperty$1(value, name);
2118
+ const property = readProperty$2(value, name);
2054
2119
  return typeof property === "function" ? property : null;
2055
2120
  }
2056
2121
  function callMethod(target, methodName, args) {
@@ -2088,7 +2153,7 @@ function closeDatabase(db) {
2088
2153
  callMethod(db, "close", []);
2089
2154
  }
2090
2155
  function sqliteConstructorFromModule(moduleValue, exportName) {
2091
- const exportedValue = readProperty$1(moduleValue, exportName);
2156
+ const exportedValue = readProperty$2(moduleValue, exportName);
2092
2157
  if (typeof exportedValue === "function") {
2093
2158
  return (path2) => Reflect.construct(exportedValue, [path2]);
2094
2159
  }
@@ -2179,11 +2244,11 @@ async function archiveSessionLog(log) {
2179
2244
  }
2180
2245
  }
2181
2246
  function readString$1(row, name) {
2182
- const value = readProperty$1(row, name);
2247
+ const value = readProperty$2(row, name);
2183
2248
  return typeof value === "string" ? value : null;
2184
2249
  }
2185
2250
  function readNumber(row, name) {
2186
- const value = readProperty$1(row, name);
2251
+ const value = readProperty$2(row, name);
2187
2252
  return typeof value === "number" && Number.isFinite(value) ? value : null;
2188
2253
  }
2189
2254
  function logFromJson(value) {
@@ -3736,7 +3801,7 @@ function extractAnthropicStream(raw, log, fallbackModel, collectChunks) {
3736
3801
  let stopSequence = null;
3737
3802
  let inputTokens = 0;
3738
3803
  let outputTokens = 0;
3739
- const MAX_CHUNKS = 1e3;
3804
+ const MAX_CHUNKS2 = 1e3;
3740
3805
  let chunkIndex = 0;
3741
3806
  let streamStartMs = 0;
3742
3807
  const chunks = [];
@@ -3749,7 +3814,7 @@ function extractAnthropicStream(raw, log, fallbackModel, collectChunks) {
3749
3814
  if (!parsed.success) continue;
3750
3815
  const data = parsed.data;
3751
3816
  if (chunkIndex === 0) streamStartMs = Date.now();
3752
- if (collectChunks === true && chunks.length < MAX_CHUNKS) {
3817
+ if (collectChunks === true && chunks.length < MAX_CHUNKS2) {
3753
3818
  chunks.push({
3754
3819
  index: chunkIndex,
3755
3820
  timestamp: Date.now() - streamStartMs,
@@ -3843,7 +3908,7 @@ function extractAnthropicStream(raw, log, fallbackModel, collectChunks) {
3843
3908
  if (collectChunks === true) {
3844
3909
  log.streamingChunks = {
3845
3910
  chunks,
3846
- truncated: chunkIndex > MAX_CHUNKS
3911
+ truncated: chunkIndex > MAX_CHUNKS2
3847
3912
  };
3848
3913
  }
3849
3914
  const orderedContent = [...blocks.entries()].sort(([a], [b]) => a - b).map(([, block]) => finalizeBlock(block));
@@ -3981,7 +4046,98 @@ const anthropicProvider = {
3981
4046
  }
3982
4047
  };
3983
4048
  registry.register(anthropicProvider);
3984
- function extractOpenAIStream(raw, log, fallbackModel, collectChunks = true) {
4049
+ const MAX_CHUNKS = 1e3;
4050
+ function readProperty$1(value, key) {
4051
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
4052
+ return Object.getOwnPropertyDescriptor(value, key)?.value;
4053
+ }
4054
+ function readStringProperty$1(value, key) {
4055
+ const property = readProperty$1(value, key);
4056
+ return typeof property === "string" ? property : null;
4057
+ }
4058
+ function readNumberProperty(value, key) {
4059
+ const property = readProperty$1(value, key);
4060
+ return typeof property === "number" && Number.isFinite(property) ? property : null;
4061
+ }
4062
+ function readObjectProperty(value, key) {
4063
+ const property = readProperty$1(value, key);
4064
+ return property !== null && typeof property === "object" && !Array.isArray(property) ? property : null;
4065
+ }
4066
+ function readArrayProperty(value, key) {
4067
+ const property = readProperty$1(value, key);
4068
+ return Array.isArray(property) ? property : [];
4069
+ }
4070
+ function parseSseEvents(raw) {
4071
+ const events = [];
4072
+ let event = null;
4073
+ let dataLines = [];
4074
+ const commit = () => {
4075
+ if (event === null && dataLines.length === 0) return;
4076
+ events.push({ event, data: dataLines.join("\n") });
4077
+ event = null;
4078
+ dataLines = [];
4079
+ };
4080
+ for (const rawLine of raw.split("\n")) {
4081
+ const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
4082
+ if (line === "") {
4083
+ commit();
4084
+ continue;
4085
+ }
4086
+ if (line.startsWith(":")) continue;
4087
+ const separatorIndex = line.indexOf(":");
4088
+ const field = separatorIndex === -1 ? line : line.slice(0, separatorIndex);
4089
+ const rawValue = separatorIndex === -1 ? "" : line.slice(separatorIndex + 1);
4090
+ const value = rawValue.startsWith(" ") ? rawValue.slice(1) : rawValue;
4091
+ switch (field) {
4092
+ case "event":
4093
+ event = value;
4094
+ break;
4095
+ case "data":
4096
+ if (event === null && dataLines.length > 0 && (value.startsWith("{") || value === "[DONE]")) {
4097
+ commit();
4098
+ }
4099
+ dataLines.push(value);
4100
+ break;
4101
+ }
4102
+ }
4103
+ commit();
4104
+ return events;
4105
+ }
4106
+ function parseJson$2(data) {
4107
+ try {
4108
+ return JSON.parse(data);
4109
+ } catch {
4110
+ return null;
4111
+ }
4112
+ }
4113
+ function eventTypeFor(event, parsed) {
4114
+ if (event.event !== null && event.event !== "") return event.event;
4115
+ const typed = OpenAIResponsesSSEventSchema.safeParse(parsed);
4116
+ return typed.success ? typed.data.type : "";
4117
+ }
4118
+ function isResponsesEvent(event) {
4119
+ if (event.data === "[DONE]") return false;
4120
+ const parsed = parseJson$2(event.data);
4121
+ const type = eventTypeFor(event, parsed);
4122
+ return type.startsWith("response.") || type === "error";
4123
+ }
4124
+ function collectChunk(chunks, chunkIndex, streamStartMs, type, parsed) {
4125
+ if (chunks.length >= MAX_CHUNKS) return;
4126
+ chunks.push({
4127
+ index: chunkIndex,
4128
+ timestamp: Date.now() - streamStartMs,
4129
+ type,
4130
+ data: trustAsJsonValue(parsed)
4131
+ });
4132
+ }
4133
+ function setErrorFromPayload(log, payload) {
4134
+ const errorObject = readObjectProperty(payload, "error");
4135
+ const message = readStringProperty$1(errorObject, "message") ?? readStringProperty$1(payload, "message") ?? readStringProperty$1(payload, "error");
4136
+ if (message !== null && message.length > 0) {
4137
+ log.error = message;
4138
+ }
4139
+ }
4140
+ function extractChatCompletionsStream(events, log, fallbackModel, collectChunks) {
3985
4141
  let id = "";
3986
4142
  let model = "";
3987
4143
  let completionContent = "";
@@ -3992,106 +4148,78 @@ function extractOpenAIStream(raw, log, fallbackModel, collectChunks = true) {
3992
4148
  let usageCaptured = false;
3993
4149
  let started = false;
3994
4150
  const toolCalls = /* @__PURE__ */ new Map();
3995
- const MAX_CHUNKS = 1e3;
3996
4151
  let chunkIndex = 0;
3997
4152
  let streamStartMs = 0;
3998
4153
  const chunks = [];
3999
- for (const line of raw.split("\n")) {
4000
- const trimmedLine = line.trim();
4001
- if (!trimmedLine.startsWith("data: ")) continue;
4002
- const dataStr = trimmedLine.slice(6);
4003
- if (dataStr === "[DONE]") break;
4004
- try {
4005
- const parsed = JSON.parse(dataStr);
4006
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
4007
- const errorDesc = Object.getOwnPropertyDescriptor(parsed, "error");
4008
- if (errorDesc !== void 0 && typeof errorDesc.value === "object" && errorDesc.value !== null) {
4009
- const msgDesc = Object.getOwnPropertyDescriptor(errorDesc.value, "message");
4010
- if (msgDesc !== void 0 && typeof msgDesc.value === "string") {
4011
- log.error = msgDesc.value;
4012
- }
4013
- continue;
4014
- }
4154
+ for (const event of events) {
4155
+ if (event.data === "[DONE]") break;
4156
+ const parsed = parseJson$2(event.data);
4157
+ if (parsed === null) continue;
4158
+ setErrorFromPayload(log, parsed);
4159
+ const chunkResult = OpenAISSERawChunkSchema.safeParse(parsed);
4160
+ if (!chunkResult.success) continue;
4161
+ const chunk = chunkResult.data;
4162
+ if (chunkIndex === 0) streamStartMs = Date.now();
4163
+ if (collectChunks) {
4164
+ collectChunk(chunks, chunkIndex, streamStartMs, "chat.completion.chunk", chunk);
4165
+ }
4166
+ chunkIndex++;
4167
+ if (!started) {
4168
+ id = chunk.id;
4169
+ model = chunk.model;
4170
+ started = true;
4171
+ }
4172
+ if (!usageCaptured && chunk.usage !== void 0 && chunk.usage !== null) {
4173
+ promptTokens = chunk.usage.prompt_tokens ?? 0;
4174
+ completionTokens = chunk.usage.completion_tokens ?? 0;
4175
+ log.inputTokens = promptTokens;
4176
+ const usage = readObjectProperty(parsed, "usage");
4177
+ const details = readObjectProperty(usage, "prompt_tokens_details");
4178
+ const cachedTokens = readNumberProperty(details, "cached_tokens");
4179
+ if (cachedTokens !== null) {
4180
+ log.cacheReadInputTokens = cachedTokens;
4015
4181
  }
4016
- const chunkResult = OpenAISSERawChunkSchema.safeParse(parsed);
4017
- if (!chunkResult.success) continue;
4018
- const chunk = chunkResult.data;
4019
- if (chunkIndex === 0) streamStartMs = Date.now();
4020
- if (collectChunks === true && chunks.length < MAX_CHUNKS) {
4021
- chunks.push({
4022
- index: chunkIndex,
4023
- timestamp: Date.now() - streamStartMs,
4024
- type: "chat.completion.chunk",
4025
- data: trustAsJsonValue(chunk)
4026
- });
4182
+ usageCaptured = true;
4183
+ }
4184
+ for (const choice of chunk.choices) {
4185
+ const delta = choice.delta;
4186
+ if (delta.content !== void 0 && delta.content !== null) {
4187
+ completionContent += delta.content;
4027
4188
  }
4028
- chunkIndex++;
4029
- if (!started) {
4030
- id = chunk.id;
4031
- model = chunk.model;
4032
- started = true;
4189
+ if (delta.reasoning_content !== void 0 && delta.reasoning_content !== null) {
4190
+ reasoningContent += delta.reasoning_content;
4033
4191
  }
4034
- if (!usageCaptured && chunk.usage !== void 0 && chunk.usage !== null) {
4035
- promptTokens = chunk.usage.prompt_tokens ?? 0;
4036
- completionTokens = chunk.usage.completion_tokens ?? 0;
4037
- log.inputTokens = promptTokens;
4038
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
4039
- const usageDesc = Object.getOwnPropertyDescriptor(parsed, "usage");
4040
- if (usageDesc !== void 0 && typeof usageDesc.value === "object" && usageDesc.value !== null) {
4041
- const detailsDesc = Object.getOwnPropertyDescriptor(
4042
- usageDesc.value,
4043
- "prompt_tokens_details"
4044
- );
4045
- if (detailsDesc !== void 0 && typeof detailsDesc.value === "object" && detailsDesc.value !== null) {
4046
- const cacheDesc = Object.getOwnPropertyDescriptor(detailsDesc.value, "cached_tokens");
4047
- if (cacheDesc !== void 0 && typeof cacheDesc.value === "number") {
4048
- log.cacheReadInputTokens = cacheDesc.value;
4049
- }
4050
- }
4051
- }
4052
- }
4053
- usageCaptured = true;
4192
+ if (delta.thinking !== void 0 && delta.thinking !== null) {
4193
+ reasoningContent += delta.thinking;
4054
4194
  }
4055
- for (const choice of chunk.choices) {
4056
- const delta = choice.delta;
4057
- if (delta.content !== void 0 && delta.content !== null) {
4058
- completionContent += delta.content;
4059
- }
4060
- if (delta.reasoning_content !== void 0 && delta.reasoning_content !== null) {
4061
- reasoningContent += delta.reasoning_content;
4062
- }
4063
- if (delta.thinking !== void 0 && delta.thinking !== null) {
4064
- reasoningContent += delta.thinking;
4065
- }
4066
- const thinkValue = delta.think;
4067
- if (thinkValue !== void 0 && thinkValue !== null) {
4068
- reasoningContent += thinkValue;
4069
- }
4070
- if (choice.finish_reason !== void 0 && choice.finish_reason !== null) {
4071
- finishReason = choice.finish_reason;
4072
- }
4073
- if (delta.tool_calls !== void 0 && delta.tool_calls !== null) {
4074
- for (const tc of delta.tool_calls) {
4075
- let existing = toolCalls.get(tc.index);
4076
- if (existing === void 0) {
4077
- existing = {
4078
- index: tc.index,
4079
- type: "function",
4080
- function: { name: "", arguments: "" }
4081
- };
4082
- toolCalls.set(tc.index, existing);
4083
- }
4084
- if (tc.id !== void 0) existing.id = tc.id;
4085
- if (tc.function?.name !== void 0) existing.function.name += tc.function.name;
4086
- if (tc.function?.arguments !== void 0)
4087
- existing.function.arguments += tc.function.arguments;
4195
+ const thinkValue = delta.think;
4196
+ if (thinkValue !== void 0 && thinkValue !== null) {
4197
+ reasoningContent += thinkValue;
4198
+ }
4199
+ if (choice.finish_reason !== void 0 && choice.finish_reason !== null) {
4200
+ finishReason = choice.finish_reason;
4201
+ }
4202
+ if (delta.tool_calls !== void 0 && delta.tool_calls !== null) {
4203
+ for (const tc of delta.tool_calls) {
4204
+ let existing = toolCalls.get(tc.index);
4205
+ if (existing === void 0) {
4206
+ existing = {
4207
+ index: tc.index,
4208
+ type: "function",
4209
+ function: { name: "", arguments: "" }
4210
+ };
4211
+ toolCalls.set(tc.index, existing);
4212
+ }
4213
+ if (tc.id !== void 0) existing.id = tc.id;
4214
+ if (tc.function?.name !== void 0) existing.function.name += tc.function.name;
4215
+ if (tc.function?.arguments !== void 0) {
4216
+ existing.function.arguments += tc.function.arguments;
4088
4217
  }
4089
4218
  }
4090
4219
  }
4091
- } catch {
4092
4220
  }
4093
4221
  }
4094
- if (collectChunks === true) {
4222
+ if (collectChunks) {
4095
4223
  log.streamingChunks = {
4096
4224
  chunks,
4097
4225
  truncated: chunkIndex > MAX_CHUNKS
@@ -4105,7 +4233,7 @@ function extractOpenAIStream(raw, log, fallbackModel, collectChunks = true) {
4105
4233
  role: "assistant",
4106
4234
  content: completionContent
4107
4235
  };
4108
- if (reasoningContent) message.reasoning_content = reasoningContent;
4236
+ if (reasoningContent.length > 0) message.reasoning_content = reasoningContent;
4109
4237
  if (toolCalls.size > 0) message.tool_calls = [...toolCalls.values()];
4110
4238
  return JSON.stringify({
4111
4239
  id,
@@ -4126,6 +4254,241 @@ function extractOpenAIStream(raw, log, fallbackModel, collectChunks = true) {
4126
4254
  }
4127
4255
  });
4128
4256
  }
4257
+ function parseResponsesResponse(value) {
4258
+ const fromResponseProperty = OpenAIResponsesResponseSchema.safeParse(
4259
+ readProperty$1(value, "response")
4260
+ );
4261
+ if (fromResponseProperty.success) return fromResponseProperty.data;
4262
+ const direct = OpenAIResponsesResponseSchema.safeParse(value);
4263
+ return direct.success ? direct.data : null;
4264
+ }
4265
+ function responseTextFromOutput(response) {
4266
+ if (response.output_text !== void 0 && response.output_text.length > 0) {
4267
+ return response.output_text;
4268
+ }
4269
+ const parts = [];
4270
+ for (const outputItem of response.output ?? []) {
4271
+ const content = readArrayProperty(outputItem, "content");
4272
+ for (const contentPart of content) {
4273
+ const type = readStringProperty$1(contentPart, "type");
4274
+ const text = readStringProperty$1(contentPart, "text");
4275
+ if ((type === "output_text" || type === "text") && text !== null && text.length > 0) {
4276
+ parts.push(text);
4277
+ }
4278
+ }
4279
+ }
4280
+ return parts.join("\n");
4281
+ }
4282
+ function updateUsageFromResponse(response, log) {
4283
+ const usage = response.usage;
4284
+ const inputTokens = usage?.input_tokens ?? null;
4285
+ const outputTokens = usage?.output_tokens ?? null;
4286
+ if (inputTokens !== null) log.inputTokens = inputTokens;
4287
+ if (outputTokens !== null) log.outputTokens = outputTokens;
4288
+ const cachedTokens = usage?.input_tokens_details?.cached_tokens ?? null;
4289
+ if (cachedTokens !== null) log.cacheReadInputTokens = cachedTokens;
4290
+ return { inputTokens, outputTokens };
4291
+ }
4292
+ function functionCallKey(payload, fallbackIndex) {
4293
+ const itemId = readStringProperty$1(payload, "item_id");
4294
+ if (itemId !== null && itemId.length > 0) return itemId;
4295
+ const outputIndex = readNumberProperty(payload, "output_index");
4296
+ if (outputIndex !== null) return String(outputIndex);
4297
+ return `function-${String(fallbackIndex)}`;
4298
+ }
4299
+ function ensureFunctionCall(calls, key) {
4300
+ const existing = calls.get(key);
4301
+ if (existing !== void 0) return existing;
4302
+ const created = {
4303
+ type: "function_call",
4304
+ arguments: ""
4305
+ };
4306
+ calls.set(key, created);
4307
+ return created;
4308
+ }
4309
+ function updateFunctionCallFromItem(calls, key, item) {
4310
+ if (readStringProperty$1(item, "type") !== "function_call") return;
4311
+ const call = ensureFunctionCall(calls, key);
4312
+ const id = readStringProperty$1(item, "id");
4313
+ const callId = readStringProperty$1(item, "call_id");
4314
+ const name = readStringProperty$1(item, "name");
4315
+ const args = readStringProperty$1(item, "arguments");
4316
+ const status = readStringProperty$1(item, "status");
4317
+ if (id !== null) call.id = id;
4318
+ if (callId !== null) call.call_id = callId;
4319
+ if (name !== null) call.name = name;
4320
+ if (args !== null) call.arguments = args;
4321
+ if (status !== null) call.status = status;
4322
+ }
4323
+ function outputFromCollected(outputText, calls) {
4324
+ const output = [];
4325
+ if (outputText.length > 0) {
4326
+ output.push({
4327
+ type: "message",
4328
+ role: "assistant",
4329
+ content: [{ type: "output_text", text: outputText, annotations: [] }]
4330
+ });
4331
+ }
4332
+ for (const call of calls.values()) {
4333
+ output.push(call);
4334
+ }
4335
+ return output;
4336
+ }
4337
+ function responseUsage(inputTokens, outputTokens, outputText) {
4338
+ const finalOutputTokens = outputTokens ?? Math.ceil(outputText.length / 4);
4339
+ return {
4340
+ input_tokens: inputTokens,
4341
+ output_tokens: finalOutputTokens,
4342
+ total_tokens: inputTokens === null ? finalOutputTokens : inputTokens + finalOutputTokens
4343
+ };
4344
+ }
4345
+ function normalizeResponsesResponse(input) {
4346
+ const completedText = input.completedResponse === null ? "" : responseTextFromOutput(input.completedResponse);
4347
+ const outputText = completedText.length > 0 ? completedText : input.outputText;
4348
+ const completedOutput = input.completedResponse?.output;
4349
+ const output = completedOutput !== void 0 && completedOutput.length > 0 ? completedOutput : outputFromCollected(outputText, input.calls);
4350
+ const usage = input.completedResponse?.usage ?? responseUsage(input.inputTokens, input.outputTokens, outputText);
4351
+ return {
4352
+ ...input.completedResponse ?? {},
4353
+ id: input.completedResponse?.id ?? input.responseId,
4354
+ object: "response",
4355
+ created_at: input.completedResponse?.created_at ?? Math.floor(Date.now() / 1e3),
4356
+ status: input.completedResponse?.status ?? input.status ?? "completed",
4357
+ model: input.completedResponse?.model ?? input.model,
4358
+ output,
4359
+ output_text: outputText,
4360
+ usage
4361
+ };
4362
+ }
4363
+ function extractResponsesStream(events, log, fallbackModel, collectChunks) {
4364
+ let completedResponse = null;
4365
+ let responseId = "";
4366
+ let model = fallbackModel ?? "";
4367
+ let status = null;
4368
+ let outputText = "";
4369
+ let inputTokens = null;
4370
+ let outputTokens = null;
4371
+ let chunkIndex = 0;
4372
+ let streamStartMs = 0;
4373
+ const chunks = [];
4374
+ const calls = /* @__PURE__ */ new Map();
4375
+ for (const event of events) {
4376
+ if (event.data === "[DONE]") break;
4377
+ const parsed = parseJson$2(event.data);
4378
+ if (parsed === null) continue;
4379
+ const type = eventTypeFor(event, parsed);
4380
+ if (chunkIndex === 0) streamStartMs = Date.now();
4381
+ if (collectChunks) {
4382
+ collectChunk(
4383
+ chunks,
4384
+ chunkIndex,
4385
+ streamStartMs,
4386
+ type === "" ? "response.event" : type,
4387
+ parsed
4388
+ );
4389
+ }
4390
+ chunkIndex++;
4391
+ setErrorFromPayload(log, parsed);
4392
+ if (type === "error") continue;
4393
+ const response = parseResponsesResponse(parsed);
4394
+ if (response !== null) {
4395
+ completedResponse = response;
4396
+ responseId = response.id;
4397
+ model = response.model ?? model;
4398
+ status = response.status ?? status;
4399
+ const usage = updateUsageFromResponse(response, log);
4400
+ inputTokens = usage.inputTokens ?? inputTokens;
4401
+ outputTokens = usage.outputTokens ?? outputTokens;
4402
+ setErrorFromPayload(log, response);
4403
+ }
4404
+ const delta = readStringProperty$1(parsed, "delta");
4405
+ switch (type) {
4406
+ case "response.output_text.delta":
4407
+ if (delta !== null) outputText += delta;
4408
+ break;
4409
+ case "response.output_text.done": {
4410
+ const text = readStringProperty$1(parsed, "text");
4411
+ if (outputText.length === 0 && text !== null) outputText = text;
4412
+ break;
4413
+ }
4414
+ case "response.function_call_arguments.delta": {
4415
+ if (delta !== null) {
4416
+ const call = ensureFunctionCall(calls, functionCallKey(parsed, calls.size));
4417
+ call.arguments += delta;
4418
+ }
4419
+ break;
4420
+ }
4421
+ case "response.function_call_arguments.done": {
4422
+ const args = readStringProperty$1(parsed, "arguments");
4423
+ if (args !== null) {
4424
+ const call = ensureFunctionCall(calls, functionCallKey(parsed, calls.size));
4425
+ call.arguments = args;
4426
+ }
4427
+ break;
4428
+ }
4429
+ case "response.output_item.added":
4430
+ case "response.output_item.done": {
4431
+ const item = readObjectProperty(parsed, "item");
4432
+ updateFunctionCallFromItem(calls, functionCallKey(parsed, calls.size), item);
4433
+ break;
4434
+ }
4435
+ case "response.failed":
4436
+ case "response.incomplete":
4437
+ status = type.slice("response.".length);
4438
+ break;
4439
+ case "response.completed":
4440
+ status = "completed";
4441
+ break;
4442
+ }
4443
+ }
4444
+ if (collectChunks) {
4445
+ log.streamingChunks = {
4446
+ chunks,
4447
+ truncated: chunkIndex > MAX_CHUNKS
4448
+ };
4449
+ }
4450
+ const normalized = normalizeResponsesResponse({
4451
+ completedResponse,
4452
+ responseId,
4453
+ model,
4454
+ status,
4455
+ outputText,
4456
+ calls,
4457
+ inputTokens,
4458
+ outputTokens
4459
+ });
4460
+ const normalizedResponse = OpenAIResponsesResponseSchema.safeParse(normalized);
4461
+ if (normalizedResponse.success) {
4462
+ const finalUsage = updateUsageFromResponse(normalizedResponse.data, log);
4463
+ if (finalUsage.outputTokens === null) {
4464
+ const finalText = responseTextFromOutput(normalizedResponse.data);
4465
+ const estimatedOutputTokens = Math.ceil(finalText.length / 4);
4466
+ log.outputTokens = estimatedOutputTokens;
4467
+ }
4468
+ return JSON.stringify(normalizedResponse.data);
4469
+ }
4470
+ if (log.outputTokens === null) {
4471
+ const finalText = readStringProperty$1(normalized, "output_text") ?? outputText;
4472
+ const estimatedOutputTokens = Math.ceil(finalText.length / 4);
4473
+ log.outputTokens = estimatedOutputTokens;
4474
+ }
4475
+ return JSON.stringify(normalized);
4476
+ }
4477
+ function extractOpenAIStream(raw, log, fallbackModel, collectChunks = true) {
4478
+ const events = parseSseEvents(raw);
4479
+ if (events.some(isResponsesEvent)) {
4480
+ return extractResponsesStream(events, log, fallbackModel, collectChunks);
4481
+ }
4482
+ return extractChatCompletionsStream(events, log, fallbackModel, collectChunks);
4483
+ }
4484
+ function emptyTokens() {
4485
+ return {
4486
+ inputTokens: null,
4487
+ outputTokens: null,
4488
+ cacheCreationInputTokens: null,
4489
+ cacheReadInputTokens: null
4490
+ };
4491
+ }
4129
4492
  const OpenAIFormatHandler = {
4130
4493
  format: "openai",
4131
4494
  parseRequest(rawBody, headers) {
@@ -4138,6 +4501,13 @@ const OpenAIFormatHandler = {
4138
4501
  sessionId: headers?.get("x-session-affinity") ?? null
4139
4502
  };
4140
4503
  }
4504
+ const responsesResult = OpenAIResponsesRequestSchema.safeParse(json);
4505
+ if (responsesResult.success) {
4506
+ return {
4507
+ model: responsesResult.data.model,
4508
+ sessionId: headers?.get("x-session-affinity") ?? null
4509
+ };
4510
+ }
4141
4511
  return null;
4142
4512
  } catch {
4143
4513
  return null;
@@ -4173,12 +4543,17 @@ const OpenAIFormatHandler = {
4173
4543
  cacheReadInputTokens
4174
4544
  };
4175
4545
  }
4176
- return {
4177
- inputTokens: null,
4178
- outputTokens: null,
4179
- cacheCreationInputTokens: null,
4180
- cacheReadInputTokens: null
4181
- };
4546
+ const responsesParsed = parseOpenAIResponsesResponse(responseBody);
4547
+ if (responsesParsed !== null) {
4548
+ const usage = responsesParsed.usage;
4549
+ return {
4550
+ inputTokens: usage?.input_tokens ?? null,
4551
+ outputTokens: usage?.output_tokens ?? null,
4552
+ cacheCreationInputTokens: null,
4553
+ cacheReadInputTokens: usage?.input_tokens_details?.cached_tokens ?? null
4554
+ };
4555
+ }
4556
+ return emptyTokens();
4182
4557
  },
4183
4558
  extractStream(raw, log, fallbackModel, collectChunks) {
4184
4559
  return extractOpenAIStream(raw, log, fallbackModel, collectChunks);
@@ -4189,7 +4564,7 @@ const OpenAIFormatHandler = {
4189
4564
  const json = JSON.parse(rawBody);
4190
4565
  if (typeof json === "object" && json !== null && !Array.isArray(json)) {
4191
4566
  const keys = Object.keys(json);
4192
- return keys.includes("model") && keys.includes("messages") && !keys.includes("system");
4567
+ return keys.includes("model") && (keys.includes("messages") || keys.includes("input")) && !keys.includes("system");
4193
4568
  }
4194
4569
  return false;
4195
4570
  } catch {
@@ -4281,6 +4656,7 @@ const ProviderConfigSchema = object({
4281
4656
  baseUrl: string().optional(),
4282
4657
  anthropicBaseUrl: string().optional(),
4283
4658
  openaiBaseUrl: string().optional(),
4659
+ openaiResponsesBaseUrl: string().optional(),
4284
4660
  authHeader: _enum(["bearer", "x-api-key"]).optional().default("bearer"),
4285
4661
  apiDocsUrl: string().optional(),
4286
4662
  modelMetadataUrl: string().optional(),
@@ -4346,7 +4722,7 @@ const BUILTIN_PROVIDER_MODEL_REGISTRY = {
4346
4722
  {
4347
4723
  name: "MiniMax",
4348
4724
  aliases: ["minimax"],
4349
- baseUrls: ["https://api.minimaxi.com/anthropic"],
4725
+ baseUrls: ["https://api.minimaxi.com/anthropic", "https://api.minimaxi.com"],
4350
4726
  models: [
4351
4727
  {
4352
4728
  id: "MiniMax M3",
@@ -4506,6 +4882,9 @@ function providerBaseUrls(provider) {
4506
4882
  if (provider.openaiBaseUrl !== void 0 && provider.openaiBaseUrl.trim() !== "") {
4507
4883
  urls.push(provider.openaiBaseUrl);
4508
4884
  }
4885
+ if (provider.openaiResponsesBaseUrl !== void 0 && provider.openaiResponsesBaseUrl.trim() !== "") {
4886
+ urls.push(provider.openaiResponsesBaseUrl);
4887
+ }
4509
4888
  if (provider.baseUrl !== void 0 && provider.baseUrl.trim() !== "") {
4510
4889
  urls.push(provider.baseUrl);
4511
4890
  }
@@ -4670,6 +5049,7 @@ const LegacyProviderConfigSchema = object({
4670
5049
  baseUrl: string().optional(),
4671
5050
  anthropicBaseUrl: string().optional(),
4672
5051
  openaiBaseUrl: string().optional(),
5052
+ openaiResponsesBaseUrl: string().optional(),
4673
5053
  authHeader: _enum(["bearer", "x-api-key"]).optional(),
4674
5054
  apiDocsUrl: string().optional(),
4675
5055
  modelMetadataUrl: string().optional(),
@@ -4698,6 +5078,7 @@ function migrateLegacyProvider(provider, index, now) {
4698
5078
  const baseUrl = provider.baseUrl;
4699
5079
  const anthropicBaseUrl = provider.anthropicBaseUrl ?? (format === "anthropic" && baseUrl !== void 0 ? baseUrl : "");
4700
5080
  const openaiBaseUrl = provider.openaiBaseUrl ?? (format === "openai" && baseUrl !== void 0 ? baseUrl : "");
5081
+ const openaiResponsesBaseUrl = provider.openaiResponsesBaseUrl ?? "";
4701
5082
  const candidate = {
4702
5083
  id: provider.id ?? randomUUID(),
4703
5084
  name,
@@ -4708,6 +5089,7 @@ function migrateLegacyProvider(provider, index, now) {
4708
5089
  baseUrl,
4709
5090
  anthropicBaseUrl,
4710
5091
  openaiBaseUrl,
5092
+ openaiResponsesBaseUrl,
4711
5093
  authHeader: provider.authHeader ?? "bearer",
4712
5094
  apiDocsUrl: provider.apiDocsUrl,
4713
5095
  modelMetadataUrl: provider.modelMetadataUrl,
@@ -4788,13 +5170,13 @@ const store = new Conf({
4788
5170
  migrateFromDataDirConfig(store, dataDir);
4789
5171
  migrateFromLegacyConfLocation(store);
4790
5172
  function migrateProvider(p) {
4791
- if (p.anthropicBaseUrl !== void 0 || p.openaiBaseUrl !== void 0) {
5173
+ if (p.anthropicBaseUrl !== void 0 || p.openaiBaseUrl !== void 0 || p.openaiResponsesBaseUrl !== void 0) {
4792
5174
  return p;
4793
5175
  }
4794
5176
  if (p.format === void 0 || p.baseUrl === void 0 || p.baseUrl === "") {
4795
5177
  return p;
4796
5178
  }
4797
- return p.format === "openai" ? { ...p, anthropicBaseUrl: "", openaiBaseUrl: p.baseUrl } : { ...p, anthropicBaseUrl: p.baseUrl, openaiBaseUrl: "" };
5179
+ return p.format === "openai" ? { ...p, anthropicBaseUrl: "", openaiBaseUrl: p.baseUrl, openaiResponsesBaseUrl: "" } : { ...p, anthropicBaseUrl: p.baseUrl, openaiBaseUrl: "", openaiResponsesBaseUrl: "" };
4798
5180
  }
4799
5181
  function migrateProviders() {
4800
5182
  const providers = store.get("providers", []);
@@ -4817,7 +5199,7 @@ function migrateMultiModel() {
4817
5199
  });
4818
5200
  const groups = /* @__PURE__ */ new Map();
4819
5201
  for (const p of promoted) {
4820
- const key = `${p.apiKey}::${p.anthropicBaseUrl ?? ""}::${p.openaiBaseUrl ?? ""}`;
5202
+ const key = `${p.apiKey}::${p.anthropicBaseUrl ?? ""}::${p.openaiBaseUrl ?? ""}::${p.openaiResponsesBaseUrl ?? ""}`;
4821
5203
  const group = groups.get(key);
4822
5204
  if (group !== void 0) {
4823
5205
  group.push(p);
@@ -4905,14 +5287,15 @@ function redactProviders(providers) {
4905
5287
  function normalizeApiKey(apiKey) {
4906
5288
  return apiKey.replace(/^Bearer\s+/i, "").trim();
4907
5289
  }
4908
- function addProvider(name, apiKey, format, baseUrl, models, authHeader, apiDocsUrl, anthropicBaseUrl, openaiBaseUrl, source, modelMetadataUrl, modelMetadata) {
5290
+ function addProvider(name, apiKey, format, baseUrl, models, authHeader, apiDocsUrl, anthropicBaseUrl, openaiBaseUrl, source, modelMetadataUrl, modelMetadata, openaiResponsesBaseUrl) {
4909
5291
  const providers = getProviders();
4910
5292
  const normalizedKey = normalizeApiKey(apiKey);
4911
5293
  const resolvedAnthropicUrl = anthropicBaseUrl ?? "";
4912
5294
  const resolvedOpenaiUrl = openaiBaseUrl ?? "";
5295
+ const resolvedOpenaiResponsesUrl = openaiResponsesBaseUrl ?? "";
4913
5296
  const now = (/* @__PURE__ */ new Date()).toISOString();
4914
5297
  const existing = providers.find(
4915
- (p) => p.apiKey === normalizedKey && (p.anthropicBaseUrl ?? "") === (resolvedAnthropicUrl ?? "") && (p.openaiBaseUrl ?? "") === (resolvedOpenaiUrl ?? "")
5298
+ (p) => p.apiKey === normalizedKey && (p.anthropicBaseUrl ?? "") === (resolvedAnthropicUrl ?? "") && (p.openaiBaseUrl ?? "") === (resolvedOpenaiUrl ?? "") && (p.openaiResponsesBaseUrl ?? "") === (resolvedOpenaiResponsesUrl ?? "")
4916
5299
  );
4917
5300
  if (existing) {
4918
5301
  const existingIndex = providers.findIndex((p) => p.id === existing.id);
@@ -4937,7 +5320,7 @@ function addProvider(name, apiKey, format, baseUrl, models, authHeader, apiDocsU
4937
5320
  id: randomUUID(),
4938
5321
  name,
4939
5322
  apiKey: normalizedKey,
4940
- format: format ?? (anthropicBaseUrl !== void 0 ? "anthropic" : openaiBaseUrl !== void 0 ? "openai" : void 0),
5323
+ format: format ?? (anthropicBaseUrl !== void 0 ? "anthropic" : openaiBaseUrl !== void 0 || openaiResponsesBaseUrl !== void 0 ? "openai" : void 0),
4941
5324
  baseUrl,
4942
5325
  models: models ?? [],
4943
5326
  authHeader: authHeader ?? "bearer",
@@ -4948,6 +5331,7 @@ function addProvider(name, apiKey, format, baseUrl, models, authHeader, apiDocsU
4948
5331
  updatedAt: now,
4949
5332
  anthropicBaseUrl: resolvedAnthropicUrl,
4950
5333
  openaiBaseUrl: resolvedOpenaiUrl,
5334
+ openaiResponsesBaseUrl: resolvedOpenaiResponsesUrl,
4951
5335
  source
4952
5336
  },
4953
5337
  now
@@ -4978,6 +5362,7 @@ function updateProvider(id, updates) {
4978
5362
  // Handle format-specific URLs
4979
5363
  anthropicBaseUrl: updates.anthropicBaseUrl !== void 0 ? updates.anthropicBaseUrl : existing.anthropicBaseUrl,
4980
5364
  openaiBaseUrl: updates.openaiBaseUrl !== void 0 ? updates.openaiBaseUrl : existing.openaiBaseUrl,
5365
+ openaiResponsesBaseUrl: updates.openaiResponsesBaseUrl !== void 0 ? updates.openaiResponsesBaseUrl : existing.openaiResponsesBaseUrl,
4981
5366
  source: updates.source !== void 0 ? updates.source : existing.source
4982
5367
  },
4983
5368
  updatedAt
@@ -5095,6 +5480,9 @@ function providerRoutingUrls(provider) {
5095
5480
  if (provider.openaiBaseUrl !== void 0 && provider.openaiBaseUrl.trim() !== "") {
5096
5481
  urls.push(provider.openaiBaseUrl);
5097
5482
  }
5483
+ if (provider.openaiResponsesBaseUrl !== void 0 && provider.openaiResponsesBaseUrl.trim() !== "") {
5484
+ urls.push(provider.openaiResponsesBaseUrl);
5485
+ }
5098
5486
  if (provider.baseUrl !== void 0 && provider.baseUrl.trim() !== "") {
5099
5487
  urls.push(provider.baseUrl);
5100
5488
  }
@@ -6053,12 +6441,12 @@ function extractOpenAIToolSchemas(request) {
6053
6441
  const tools = /* @__PURE__ */ new Map();
6054
6442
  for (const tool of readArray(request, "tools")) {
6055
6443
  const functionDefinition = readObject(tool, "function");
6056
- if (functionDefinition === null) continue;
6057
- const name = readString(functionDefinition, "name");
6444
+ const name = functionDefinition === null ? readString(tool, "name") : readString(functionDefinition, "name") ?? readString(tool, "name");
6058
6445
  if (name === null || name === "") continue;
6446
+ const parameters = functionDefinition === null ? readObject(tool, "parameters") : readObject(functionDefinition, "parameters") ?? readObject(tool, "parameters");
6059
6447
  tools.set(name, {
6060
6448
  name,
6061
- schema: readObject(functionDefinition, "parameters")
6449
+ schema: parameters
6062
6450
  });
6063
6451
  }
6064
6452
  return tools;
@@ -6130,6 +6518,21 @@ function extractOpenAIToolCalls(response) {
6130
6518
  }
6131
6519
  choiceIndex++;
6132
6520
  }
6521
+ let outputIndex = 0;
6522
+ for (const item of readArray(response, "output")) {
6523
+ if (readString(item, "type") !== "function_call") {
6524
+ outputIndex++;
6525
+ continue;
6526
+ }
6527
+ const parsedArguments = parseOpenAIArguments(readProperty(item, "arguments"));
6528
+ calls.push({
6529
+ name: readString(item, "name"),
6530
+ arguments: parsedArguments.value,
6531
+ argumentIssue: parsedArguments.issue,
6532
+ location: `output[${outputIndex}]`
6533
+ });
6534
+ outputIndex++;
6535
+ }
6133
6536
  return calls;
6134
6537
  }
6135
6538
  function extractAnthropicToolCalls(response) {
@@ -6710,30 +7113,15 @@ class RawStreamCapture {
6710
7113
  this.chunks = [];
6711
7114
  }
6712
7115
  }
6713
- function describeApiRoute(apiPath) {
6714
- const endpointPath = apiPath.split("?")[0] ?? "";
6715
- const isChatCompletions = endpointPath === PATH_CHAT_COMPLETIONS || endpointPath === PATH_V1_CHAT_COMPLETIONS;
6716
- const normalizedPath = isChatCompletions && !apiPath.startsWith("/v1/") ? `/v1${apiPath}` : apiPath;
6717
- return { apiPath, endpointPath, isChatCompletions, normalizedPath };
6718
- }
6719
- function getProxyApiPath(url) {
6720
- return url.pathname.replace(/^\/proxy/, "") + url.search;
6721
- }
6722
- function selectUpstreamBase(route, provider) {
6723
- if (provider === null) {
6724
- return route.isChatCompletions ? DEFAULT_OPENAI_UPSTREAM$1 : DEFAULT_UPSTREAM$1;
6725
- }
6726
- const formatSpecificUrl = route.isChatCompletions ? provider.openaiBaseUrl : provider.anthropicBaseUrl;
6727
- if (formatSpecificUrl !== void 0 && formatSpecificUrl !== "") {
6728
- return formatSpecificUrl;
6729
- }
6730
- if (provider.baseUrl !== void 0 && provider.baseUrl !== "") {
6731
- return provider.baseUrl;
6732
- }
6733
- return provider.format === "openai" ? DEFAULT_OPENAI_UPSTREAM$1 : DEFAULT_UPSTREAM$1;
6734
- }
7116
+ const PATH_V1_CHAT_COMPLETIONS = "/v1/chat/completions";
6735
7117
  function buildUpstreamUrl(upstreamBase, normalizedPath) {
6736
7118
  const base = upstreamBase.endsWith("/") ? upstreamBase.slice(0, -1) : upstreamBase;
7119
+ const endpointPath = normalizedPath.split("?")[0] ?? normalizedPath;
7120
+ const queryIndex = normalizedPath.indexOf("?");
7121
+ const search = queryIndex >= 0 ? normalizedPath.slice(queryIndex) : "";
7122
+ if (endpointPath !== "" && base.endsWith(endpointPath)) {
7123
+ return base + search;
7124
+ }
6737
7125
  if (isZhipuVersionedOpenAIBase(base) && isVersionedChatCompletionsPath(normalizedPath)) {
6738
7126
  return base + normalizedPath.slice(3);
6739
7127
  }
@@ -6754,6 +7142,40 @@ function isZhipuVersionedOpenAIBase(base) {
6754
7142
  return false;
6755
7143
  }
6756
7144
  }
7145
+ function describeApiRoute(apiPath) {
7146
+ const endpointPath = apiPath.split("?")[0] ?? "";
7147
+ const isChatCompletions = endpointPath === PATH_CHAT_COMPLETIONS || endpointPath === PATH_V1_CHAT_COMPLETIONS$1;
7148
+ const isResponses = endpointPath === PATH_RESPONSES || endpointPath === PATH_V1_RESPONSES;
7149
+ const isOpenAI = isChatCompletions || isResponses;
7150
+ const normalizedPath = isOpenAI && !apiPath.startsWith("/v1/") ? `/v1${apiPath}` : apiPath;
7151
+ return { apiPath, endpointPath, isChatCompletions, isResponses, isOpenAI, normalizedPath };
7152
+ }
7153
+ function getProxyApiPath(url) {
7154
+ return url.pathname.replace(/^\/proxy/, "") + url.search;
7155
+ }
7156
+ function selectUpstreamBase(route, provider) {
7157
+ if (provider === null) {
7158
+ return route.isOpenAI ? DEFAULT_OPENAI_UPSTREAM$1 : DEFAULT_UPSTREAM$1;
7159
+ }
7160
+ const formatSpecificUrl = selectFormatSpecificUrl(route, provider);
7161
+ if (formatSpecificUrl !== void 0 && formatSpecificUrl !== "") {
7162
+ return formatSpecificUrl;
7163
+ }
7164
+ if (provider.baseUrl !== void 0 && provider.baseUrl !== "") {
7165
+ return provider.baseUrl;
7166
+ }
7167
+ return provider.format === "openai" ? DEFAULT_OPENAI_UPSTREAM$1 : DEFAULT_UPSTREAM$1;
7168
+ }
7169
+ function nonEmptyUrl(value) {
7170
+ return value !== void 0 && value !== "" ? value : void 0;
7171
+ }
7172
+ function selectFormatSpecificUrl(route, provider) {
7173
+ if (!route.isOpenAI) return provider.anthropicBaseUrl;
7174
+ if (route.isResponses) {
7175
+ return nonEmptyUrl(provider.openaiResponsesBaseUrl) ?? provider.openaiBaseUrl;
7176
+ }
7177
+ return provider.openaiBaseUrl;
7178
+ }
6757
7179
  function setUpstreamHost(headers, upstreamBase) {
6758
7180
  try {
6759
7181
  headers.set(HEADER_HOST, new URL(upstreamBase).host);
@@ -8498,6 +8920,7 @@ const ProviderInputSchema = object({
8498
8920
  format: _enum(["anthropic", "openai"]).optional(),
8499
8921
  anthropicBaseUrl: string().optional(),
8500
8922
  openaiBaseUrl: string().optional(),
8923
+ openaiResponsesBaseUrl: string().optional(),
8501
8924
  models: array(string()).min(1, "At least one model is required"),
8502
8925
  model: string().optional(),
8503
8926
  authHeader: _enum(["bearer", "x-api-key"]).optional().default("bearer"),
@@ -8533,7 +8956,8 @@ const Route$x = createFileRoute("/api/providers")({
8533
8956
  parsed.data.openaiBaseUrl,
8534
8957
  parsed.data.source,
8535
8958
  parsed.data.modelMetadataUrl,
8536
- parsed.data.modelMetadata
8959
+ parsed.data.modelMetadata,
8960
+ parsed.data.openaiResponsesBaseUrl
8537
8961
  );
8538
8962
  return Response.json(newProvider, { status: 201 });
8539
8963
  }
@@ -8547,7 +8971,7 @@ const Route$w = createFileRoute("/api/models")({
8547
8971
  }
8548
8972
  }
8549
8973
  });
8550
- const version = "2.1.12";
8974
+ const version = "2.1.14";
8551
8975
  const packageJson = {
8552
8976
  version
8553
8977
  };
@@ -9016,6 +9440,7 @@ async function callApi(path2, options = {}) {
9016
9440
  }
9017
9441
  }
9018
9442
  const PREVIEW_MAX_CHARS = 500;
9443
+ const UnknownArraySchema = array(unknown());
9019
9444
  function truncate(text) {
9020
9445
  return text.length <= PREVIEW_MAX_CHARS ? text : text.slice(0, PREVIEW_MAX_CHARS);
9021
9446
  }
@@ -9042,6 +9467,48 @@ function firstOpenAIText(content) {
9042
9467
  }
9043
9468
  return null;
9044
9469
  }
9470
+ function firstResponsesInputText(input) {
9471
+ if (typeof input === "string") return input.length > 0 ? input : null;
9472
+ const parsedInput = UnknownArraySchema.safeParse(input);
9473
+ if (!parsedInput.success) return null;
9474
+ for (let i = parsedInput.data.length - 1; i >= 0; i--) {
9475
+ const item = parsedInput.data[i];
9476
+ const role = safeGetOwnProperty(item, "role");
9477
+ if (role !== "user" && role !== void 0) continue;
9478
+ const directText = safeGetOwnProperty(item, "text");
9479
+ if (typeof directText === "string" && directText.length > 0) return directText;
9480
+ const content = safeGetOwnProperty(item, "content");
9481
+ if (typeof content === "string" && content.length > 0) return content;
9482
+ if (Array.isArray(content)) {
9483
+ for (const part of content) {
9484
+ const type = safeGetOwnProperty(part, "type");
9485
+ const text = safeGetOwnProperty(part, "text");
9486
+ if ((type === "input_text" || type === "text") && typeof text === "string" && text.length > 0) {
9487
+ return text;
9488
+ }
9489
+ }
9490
+ }
9491
+ }
9492
+ return null;
9493
+ }
9494
+ function firstResponsesOutputText(response) {
9495
+ const outputText = safeGetOwnProperty(response, "output_text");
9496
+ if (typeof outputText === "string" && outputText.length > 0) return outputText;
9497
+ const output = safeGetOwnProperty(response, "output");
9498
+ if (!Array.isArray(output)) return null;
9499
+ for (const item of output) {
9500
+ const content = safeGetOwnProperty(item, "content");
9501
+ if (!Array.isArray(content)) continue;
9502
+ for (const part of content) {
9503
+ const type = safeGetOwnProperty(part, "type");
9504
+ const text = safeGetOwnProperty(part, "text");
9505
+ if ((type === "output_text" || type === "text") && typeof text === "string" && text.length > 0) {
9506
+ return text;
9507
+ }
9508
+ }
9509
+ }
9510
+ return null;
9511
+ }
9045
9512
  function extractLastUserMessagePreview(log) {
9046
9513
  if (log.apiFormat === "unknown") return null;
9047
9514
  if (log.rawRequestBody === null) return null;
@@ -9065,7 +9532,12 @@ function extractLastUserMessagePreview(log) {
9065
9532
  }
9066
9533
  if (log.apiFormat === "openai") {
9067
9534
  const parsed = OpenAIRequestSchema.safeParse(json);
9068
- if (!parsed.success) return null;
9535
+ if (!parsed.success) {
9536
+ const responsesParsed = OpenAIResponsesRequestSchema.safeParse(json);
9537
+ if (!responsesParsed.success) return null;
9538
+ const text = firstResponsesInputText(responsesParsed.data.input);
9539
+ return text === null ? null : truncate(text);
9540
+ }
9069
9541
  for (let i = parsed.data.messages.length - 1; i >= 0; i--) {
9070
9542
  const msg = parsed.data.messages[i];
9071
9543
  if (msg && msg.role === "user") {
@@ -9098,7 +9570,12 @@ function extractResponsePreview(log) {
9098
9570
  }
9099
9571
  if (log.apiFormat === "openai") {
9100
9572
  const parsed = OpenAIResponseSchema$1.safeParse(json);
9101
- if (!parsed.success) return null;
9573
+ if (!parsed.success) {
9574
+ const responsesParsed = OpenAIResponsesResponseSchema.safeParse(json);
9575
+ if (!responsesParsed.success) return null;
9576
+ const text = firstResponsesOutputText(responsesParsed.data);
9577
+ return text === null ? null : truncate(text);
9578
+ }
9102
9579
  for (const choice of parsed.data.choices) {
9103
9580
  const msg = choice.message;
9104
9581
  if (!msg) continue;
@@ -10505,6 +10982,7 @@ Persists a new provider to <dataDir>/providers.json. Required fields: name, apiK
10505
10982
  model: string().min(1),
10506
10983
  anthropicBaseUrl: string().optional(),
10507
10984
  openaiBaseUrl: string().optional(),
10985
+ openaiResponsesBaseUrl: string().optional(),
10508
10986
  authHeader: _enum(["bearer", "x-api-key"]).optional(),
10509
10987
  apiDocsUrl: string().optional()
10510
10988
  })
@@ -10528,6 +11006,7 @@ PATCH-style update: only the fields you supply are changed. Returns the updated
10528
11006
  authHeader: _enum(["bearer", "x-api-key"]).optional(),
10529
11007
  anthropicBaseUrl: string().optional(),
10530
11008
  openaiBaseUrl: string().optional(),
11009
+ openaiResponsesBaseUrl: string().optional(),
10531
11010
  apiDocsUrl: string().optional()
10532
11011
  })
10533
11012
  },
@@ -11994,6 +12473,18 @@ const Route$p = createFileRoute("/api/runs/$runId")({
11994
12473
  const ZHIPU_OPENAI_BASE_URL = "https://open.bigmodel.cn/api/paas/v4";
11995
12474
  const ZHIPU_CODING_OPENAI_BASE_URL = "https://open.bigmodel.cn/api/coding/paas/v4";
11996
12475
  const ZHIPU_CODING_ANTHROPIC_BASE_URL = "https://open.bigmodel.cn/api/anthropic";
12476
+ const MINIMAX_OPENAI_BASE_URL = "https://api.minimaxi.com";
12477
+ function defaultOpenAIResponsesBaseUrl(providerId) {
12478
+ const normalized = providerId.toLowerCase();
12479
+ return normalized === "minimax" || normalized.startsWith("minimax-") ? MINIMAX_OPENAI_BASE_URL : "";
12480
+ }
12481
+ function openAIResponsesBaseUrlMatchesExisting(provider, externalProvider) {
12482
+ const existingUrl = provider.openaiResponsesBaseUrl ?? "";
12483
+ if (existingUrl === externalProvider.openaiResponsesBaseUrl) return true;
12484
+ const defaultUrl = defaultOpenAIResponsesBaseUrl(externalProvider.name);
12485
+ if (defaultUrl === "") return false;
12486
+ return existingUrl === "" && externalProvider.openaiResponsesBaseUrl === defaultUrl || existingUrl === defaultUrl && externalProvider.openaiResponsesBaseUrl === "";
12487
+ }
11997
12488
  function readJsonSafe(filePath) {
11998
12489
  try {
11999
12490
  if (!existsSync(filePath)) return null;
@@ -12088,6 +12579,7 @@ function detectClaudeCodeProviders() {
12088
12579
  format: "anthropic",
12089
12580
  anthropicBaseUrl: baseUrl,
12090
12581
  openaiBaseUrl: "",
12582
+ openaiResponsesBaseUrl: "",
12091
12583
  models,
12092
12584
  sourceTool: "claude-code",
12093
12585
  alreadyExists: false
@@ -12146,6 +12638,7 @@ function detectOpenCodeProviders() {
12146
12638
  format,
12147
12639
  anthropicBaseUrl: format === "anthropic" ? baseURL : "",
12148
12640
  openaiBaseUrl: format === "openai" ? baseURL : "",
12641
+ openaiResponsesBaseUrl: defaultOpenAIResponsesBaseUrl(providerId),
12149
12642
  models,
12150
12643
  sourceTool: "opencode",
12151
12644
  alreadyExists: false
@@ -12259,6 +12752,7 @@ function detectMiMoCodeProviders() {
12259
12752
  format,
12260
12753
  anthropicBaseUrl: format === "anthropic" ? baseURL : "",
12261
12754
  openaiBaseUrl: format === "openai" ? baseURL : "",
12755
+ openaiResponsesBaseUrl: defaultOpenAIResponsesBaseUrl(providerId),
12262
12756
  models,
12263
12757
  sourceTool: "mimo-code",
12264
12758
  alreadyExists: false
@@ -12273,12 +12767,14 @@ function detectMiMoCodeProviders() {
12273
12767
  },
12274
12768
  minimax: {
12275
12769
  anthropicBaseUrl: "https://api.minimaxi.com/anthropic",
12276
- openaiBaseUrl: "https://api.minimaxi.com",
12770
+ openaiBaseUrl: MINIMAX_OPENAI_BASE_URL,
12771
+ openaiResponsesBaseUrl: MINIMAX_OPENAI_BASE_URL,
12277
12772
  format: "anthropic"
12278
12773
  },
12279
12774
  "minimax-coding-plan": {
12280
12775
  anthropicBaseUrl: "https://api.minimaxi.com/anthropic",
12281
- openaiBaseUrl: "https://api.minimaxi.com",
12776
+ openaiBaseUrl: MINIMAX_OPENAI_BASE_URL,
12777
+ openaiResponsesBaseUrl: MINIMAX_OPENAI_BASE_URL,
12282
12778
  format: "anthropic"
12283
12779
  },
12284
12780
  openai: {
@@ -12368,6 +12864,7 @@ function detectMiMoCodeProviders() {
12368
12864
  format: defaults.format,
12369
12865
  anthropicBaseUrl: defaults.anthropicBaseUrl,
12370
12866
  openaiBaseUrl: defaults.openaiBaseUrl,
12867
+ openaiResponsesBaseUrl: defaults.openaiResponsesBaseUrl ?? defaultOpenAIResponsesBaseUrl(key),
12371
12868
  models: ["default"],
12372
12869
  sourceTool: "mimo-code",
12373
12870
  alreadyExists: false
@@ -12398,7 +12895,7 @@ function scanExternalProviders() {
12398
12895
  }
12399
12896
  const allProviders = [...claudeProviders, ...opencodeProviders, ...mimoProviders];
12400
12897
  const filteredProviders = allProviders.filter((p) => {
12401
- const url = p.anthropicBaseUrl || p.openaiBaseUrl;
12898
+ const url = p.anthropicBaseUrl || p.openaiBaseUrl || p.openaiResponsesBaseUrl;
12402
12899
  return !/(?:localhost|127\.0\.0\.1)/.test(url);
12403
12900
  });
12404
12901
  let existing = [];
@@ -12412,7 +12909,7 @@ function scanExternalProviders() {
12412
12909
  if (ext.format === "anthropic") {
12413
12910
  return (p.anthropicBaseUrl ?? "") === ext.anthropicBaseUrl;
12414
12911
  }
12415
- return (p.openaiBaseUrl ?? "") === ext.openaiBaseUrl;
12912
+ return (p.openaiBaseUrl ?? "") === ext.openaiBaseUrl && openAIResponsesBaseUrlMatchesExisting(p, ext);
12416
12913
  });
12417
12914
  }
12418
12915
  return { providers: filteredProviders, warnings };
@@ -12499,6 +12996,7 @@ const ProviderUpdateSchema = object({
12499
12996
  authHeader: _enum(["bearer", "x-api-key"]).optional(),
12500
12997
  anthropicBaseUrl: string().optional(),
12501
12998
  openaiBaseUrl: string().optional(),
12999
+ openaiResponsesBaseUrl: string().optional(),
12502
13000
  apiDocsUrl: string().optional(),
12503
13001
  modelMetadataUrl: string().optional(),
12504
13002
  modelMetadata: array(ProviderModelMetadataSchema).optional(),
@@ -15817,8 +16315,10 @@ const router = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
15817
16315
  }, Symbol.toStringTag, { value: "Module" }));
15818
16316
  export {
15819
16317
  AnthropicResponseSchema$1 as A,
16318
+ isPlainRecord as B,
15820
16319
  CapturedLogSchema as C,
15821
16320
  DEFAULT_CAPTURE_MODE as D,
16321
+ router as E,
15822
16322
  GroupEvidenceReadResponseSchema as G,
15823
16323
  InspectorGroupsListResponseSchema as I,
15824
16324
  KnowledgeCandidateSchema as K,
@@ -15834,23 +16334,24 @@ export {
15834
16334
  RuntimeConfigSchema as d,
15835
16335
  AnthropicRequestSchema as e,
15836
16336
  parseOpenAIResponse as f,
15837
- apiFormatForPath as g,
15838
- getSessionPath as h,
15839
- stripClaudeCodeBillingHeader as i,
15840
- AlertSummarySchema as j,
15841
- AlertListResponseSchema as k,
15842
- GroupEvidenceExportResultSchema as l,
15843
- DeleteInspectorGroupResponseSchema as m,
15844
- providerHasContextMetadata as n,
15845
- findProviderModelMetadata as o,
16337
+ parseOpenAIResponsesResponse as g,
16338
+ OpenAIResponsesRequestSchema as h,
16339
+ apiFormatForPath as i,
16340
+ getSessionPath as j,
16341
+ stripClaudeCodeBillingHeader as k,
16342
+ AlertSummarySchema as l,
16343
+ AlertListResponseSchema as m,
16344
+ GroupEvidenceExportResultSchema as n,
16345
+ DeleteInspectorGroupResponseSchema as o,
15846
16346
  packageJson as p,
15847
- maskApiKey as q,
15848
- createPendingProviderTestResults as r,
16347
+ providerHasContextMetadata as q,
16348
+ findProviderModelMetadata as r,
15849
16349
  safeGetOwnProperty as s,
15850
- ProviderTestResultsSchema as t,
15851
- createFailedProviderTestResults as u,
15852
- MAX_PROVIDER_TEST_TIMEOUT_SECONDS as v,
15853
- resolveProviderContextWindow as w,
15854
- isPlainRecord as x,
15855
- router as y
16350
+ maskApiKey as t,
16351
+ buildUpstreamUrl as u,
16352
+ createPendingProviderTestResults as v,
16353
+ ProviderTestResultsSchema as w,
16354
+ createFailedProviderTestResults as x,
16355
+ MAX_PROVIDER_TEST_TIMEOUT_SECONDS as y,
16356
+ resolveProviderContextWindow as z
15856
16357
  };