@deslop/workbench 0.0.401 → 0.0.407

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 (53) hide show
  1. package/dist/{anthropic-DcE0yHBZ.mjs → anthropic-messages--JAnb97W.mjs} +38 -51
  2. package/dist/{azure-openai-responses-ecGypQVA.mjs → azure-openai-responses-g-awH_uA.mjs} +9 -16
  3. package/dist/client/assets/{-workbench-terminal-Af-sz4R6.js → -workbench-terminal-C3m5o50g.js} +8 -8
  4. package/dist/client/assets/agent-BXm8Dnfe.js +2 -0
  5. package/dist/client/assets/agent-DWi_bAGy.js +1 -0
  6. package/dist/client/assets/{dialog-CTIcy8Vy.js → dialog-CpMhdP-y.js} +1 -1
  7. package/dist/client/assets/{diff-MiGOu0DY.js → diff-BDdajfz3.js} +2 -2
  8. package/dist/client/assets/{diff-_Gk9o1mg.js → diff-mRZ3PeyD.js} +9 -9
  9. package/dist/client/assets/{external-link-BxixiKaa.js → external-link-Bw3Ptvfw.js} +1 -1
  10. package/dist/client/assets/{fallbacks-D21cBTdH.js → fallbacks-f8E4aL2c.js} +3 -3
  11. package/dist/client/assets/{index-DW7dKhgZ.js → index-D53pFEJY.js} +1 -1
  12. package/dist/client/assets/index-YmJ_EbaF.css +2 -0
  13. package/dist/client/assets/{input-DW9ssWUO.js → input-BVvU6Eiy.js} +1 -1
  14. package/dist/client/assets/portless-BYTEgoik.js +1 -0
  15. package/dist/client/assets/portless-Cke08ZHX.js +2 -0
  16. package/dist/client/assets/{resizable-CZjAW7-J.js → resizable-CYsJ6Kg2.js} +1 -1
  17. package/dist/client/assets/{route-DwWgYFyk.js → route-BzHtbTaZ.js} +2 -2
  18. package/dist/client/assets/route-DD4r__Zm.js +45 -0
  19. package/dist/client/assets/{run-CeqkWWtZ.js → run-C8QYJmux.js} +1 -1
  20. package/dist/client/assets/run-CW5YhyWI.js +2 -0
  21. package/dist/client/assets/{sonner-BKURESHO.js → sonner-CrB5PaMX.js} +1 -1
  22. package/dist/client/assets/state-CvX-YRlC.js +2 -0
  23. package/dist/client/assets/terminal-DJzGIrES.js +2 -0
  24. package/dist/client/assets/{terminal-CcfbU9tU.js → terminal-Dj-VWVHI.js} +1 -1
  25. package/dist/client/assets/{triangle-alert-DLHVemGQ.js → triangle-alert-llGGn6BK.js} +1 -1
  26. package/dist/client/index.html +11 -11
  27. package/dist/github-copilot-headers-BB6z1RAk.mjs +23 -0
  28. package/dist/{google-Jzn1v4-q.mjs → google-generative-ai-r4Wb8Eaq.mjs} +15 -20
  29. package/dist/{google-shared-DNNqX1gf.mjs → google-shared-DN1OvwJM.mjs} +4 -4
  30. package/dist/{google-vertex-z0Cbw7eq.mjs → google-vertex-Clcq7cAd.mjs} +15 -20
  31. package/dist/{hash-CScAQ-b_.mjs → hash-wSEYO-QF.mjs} +1 -1
  32. package/dist/headers-SFoLwUHv.mjs +15 -0
  33. package/dist/{mistral-CxEIkz4y.mjs → mistral-conversations-Bnpuiv3e.mjs} +12 -19
  34. package/dist/{openai-codex-responses-7ZUsVcbT.mjs → openai-codex-responses-4Te8RbRb.mjs} +62 -46
  35. package/dist/{openai-completions-CaGFVr3X.mjs → openai-completions-B4nInzTS.mjs} +69 -96
  36. package/dist/{openai-responses-Vjw8-3qm.mjs → openai-responses-GeDULmTh.mjs} +28 -31
  37. package/dist/{openai-responses-shared-DtEshy-7.mjs → openai-responses-shared-CG93Thoy.mjs} +37 -32
  38. package/dist/{openrouter-CZ-H_QwG.mjs → openrouter-images-CgbIytYQ.mjs} +7 -14
  39. package/dist/{sanitize-unicode-BbVojtka.mjs → sanitize-unicode-Ga8nHda1.mjs} +1 -1
  40. package/dist/server.js +27722 -24346
  41. package/dist/{transform-messages-CLmkH5Gu.mjs → transform-messages-D9fZ7fnU.mjs} +2 -2
  42. package/package.json +3 -2
  43. package/dist/client/assets/agent-BnkD1Glf.js +0 -2
  44. package/dist/client/assets/agent-DQPX2IZb.js +0 -1
  45. package/dist/client/assets/index-B2S_w1d1.css +0 -2
  46. package/dist/client/assets/portless-3KC81g42.js +0 -2
  47. package/dist/client/assets/portless-CxovsEbp.js +0 -1
  48. package/dist/client/assets/route-te6-VkZE.js +0 -45
  49. package/dist/client/assets/run-B-qmimXV.js +0 -2
  50. package/dist/client/assets/state-a4d_PikB.js +0 -2
  51. package/dist/client/assets/terminal-BHNxWKc6.js +0 -2
  52. package/dist/github-copilot-headers-P0xZolzq.mjs +0 -39
  53. package/dist/headers-oksLmLNC.mjs +0 -9
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
- import { Ir as calculateCost, Lr as clampThinkingLevel, Vr as registerApiProvider, zr as AssistantMessageEventStream } from "./server.js";
3
- import { t as sanitizeSurrogates } from "./sanitize-unicode-BbVojtka.mjs";
4
- import { r as buildBaseOptions } from "./transform-messages-CLmkH5Gu.mjs";
5
- import { a as mapToolChoice, i as mapStopReason, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as GoogleGenAI, t as convertMessages } from "./google-shared-DNNqX1gf.mjs";
6
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/providers/google.js
2
+ import { Ir as calculateCost, Lr as clampThinkingLevel, zr as AssistantMessageEventStream } from "./server.js";
3
+ import { n as providerHeadersToRecord } from "./headers-SFoLwUHv.mjs";
4
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-Ga8nHda1.mjs";
5
+ import { r as buildBaseOptions } from "./transform-messages-D9fZ7fnU.mjs";
6
+ import { a as mapToolChoice, i as mapStopReason, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as GoogleGenAI, t as convertMessages } from "./google-shared-DN1OvwJM.mjs";
7
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js
7
8
  let toolCallCounter = 0;
8
- const streamGoogle = (model, context, options) => {
9
+ const stream = (model, context, options) => {
9
10
  const stream = new AssistantMessageEventStream();
10
11
  (async () => {
11
12
  const output = {
@@ -210,25 +211,25 @@ const streamGoogle = (model, context, options) => {
210
211
  })();
211
212
  return stream;
212
213
  };
213
- const streamSimpleGoogle = (model, context, options) => {
214
+ const streamSimple = (model, context, options) => {
214
215
  const apiKey = options?.apiKey;
215
216
  if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
216
217
  const base = buildBaseOptions(model, options, apiKey);
217
- if (!options?.reasoning) return streamGoogle(model, context, {
218
+ if (!options?.reasoning) return stream(model, context, {
218
219
  ...base,
219
220
  thinking: { enabled: false }
220
221
  });
221
222
  const clampedReasoning = clampThinkingLevel(model, options.reasoning);
222
223
  const effort = clampedReasoning === "off" ? "high" : clampedReasoning;
223
224
  const googleModel = model;
224
- if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) return streamGoogle(model, context, {
225
+ if (isGemini3ProModel(googleModel) || isGemini3FlashModel(googleModel) || isGemma4Model(googleModel)) return stream(model, context, {
225
226
  ...base,
226
227
  thinking: {
227
228
  enabled: true,
228
229
  level: getThinkingLevel(effort, googleModel)
229
230
  }
230
231
  });
231
- return streamGoogle(model, context, {
232
+ return stream(model, context, {
232
233
  ...base,
233
234
  thinking: {
234
235
  enabled: true,
@@ -236,23 +237,17 @@ const streamSimpleGoogle = (model, context, options) => {
236
237
  }
237
238
  });
238
239
  };
239
- function register() {
240
- registerApiProvider({
241
- api: "google-generative-ai",
242
- stream: streamGoogle,
243
- streamSimple: streamSimpleGoogle
244
- });
245
- }
246
240
  function createClient(model, apiKey, optionsHeaders) {
247
241
  const httpOptions = {};
248
242
  if (model.baseUrl) {
249
243
  httpOptions.baseUrl = model.baseUrl;
250
244
  httpOptions.apiVersion = "";
251
245
  }
252
- if (model.headers || optionsHeaders) httpOptions.headers = {
246
+ const headers = providerHeadersToRecord({
253
247
  ...model.headers,
254
248
  ...optionsHeaders
255
- };
249
+ });
250
+ if (headers) httpOptions.headers = headers;
256
251
  return new GoogleGenAI({
257
252
  apiKey,
258
253
  httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
@@ -345,4 +340,4 @@ function getGoogleBudget(model, effort, customBudgets) {
345
340
  return -1;
346
341
  }
347
342
  //#endregion
348
- export { register, streamGoogle, streamSimpleGoogle };
343
+ export { stream, streamSimple };
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
2
  import { i as __require, o as __toESM, t as __commonJSMin } from "./rolldown-runtime-EQORzF3F.mjs";
3
- import { Hr as import_websocket } from "./server.js";
4
- import { t as sanitizeSurrogates } from "./sanitize-unicode-BbVojtka.mjs";
5
- import { t as transformMessages } from "./transform-messages-CLmkH5Gu.mjs";
3
+ import { Br as import_websocket } from "./server.js";
4
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-Ga8nHda1.mjs";
5
+ import { t as transformMessages } from "./transform-messages-D9fZ7fnU.mjs";
6
6
  import { Readable } from "node:stream";
7
7
  import { finished } from "node:stream/promises";
8
8
  import { createWriteStream } from "fs";
@@ -25121,7 +25121,7 @@ function getApiKeyFromEnv() {
25121
25121
  return envGoogleApiKey || envGeminiApiKey || void 0;
25122
25122
  }
25123
25123
  //#endregion
25124
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js
25124
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js
25125
25125
  /**
25126
25126
  * Shared utilities for Google Generative AI and Google Vertex providers.
25127
25127
  */
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
- import { Ir as calculateCost, Lr as clampThinkingLevel, Rr as getProviderEnvValue, Vr as registerApiProvider, zr as AssistantMessageEventStream } from "./server.js";
3
- import { t as sanitizeSurrogates } from "./sanitize-unicode-BbVojtka.mjs";
4
- import { r as buildBaseOptions } from "./transform-messages-CLmkH5Gu.mjs";
5
- import { a as mapToolChoice, c as ResourceScope, i as mapStopReason, l as ThinkingLevel, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as GoogleGenAI, t as convertMessages } from "./google-shared-DNNqX1gf.mjs";
6
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js
2
+ import { Ir as calculateCost, Lr as clampThinkingLevel, Rr as getProviderEnvValue, zr as AssistantMessageEventStream } from "./server.js";
3
+ import { n as providerHeadersToRecord } from "./headers-SFoLwUHv.mjs";
4
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-Ga8nHda1.mjs";
5
+ import { r as buildBaseOptions } from "./transform-messages-D9fZ7fnU.mjs";
6
+ import { a as mapToolChoice, c as ResourceScope, i as mapStopReason, l as ThinkingLevel, n as convertTools, o as retainThoughtSignature, r as isThinkingPart, s as GoogleGenAI, t as convertMessages } from "./google-shared-DN1OvwJM.mjs";
7
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js
7
8
  const API_VERSION = "v1";
8
9
  const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
9
10
  const THINKING_LEVEL_MAP = {
@@ -14,7 +15,7 @@ const THINKING_LEVEL_MAP = {
14
15
  HIGH: ThinkingLevel.HIGH
15
16
  };
16
17
  let toolCallCounter = 0;
17
- const streamGoogleVertex = (model, context, options) => {
18
+ const stream = (model, context, options) => {
18
19
  const stream = new AssistantMessageEventStream();
19
20
  (async () => {
20
21
  const output = {
@@ -218,23 +219,23 @@ const streamGoogleVertex = (model, context, options) => {
218
219
  })();
219
220
  return stream;
220
221
  };
221
- const streamSimpleGoogleVertex = (model, context, options) => {
222
+ const streamSimple = (model, context, options) => {
222
223
  const base = buildBaseOptions(model, options, void 0);
223
- if (!options?.reasoning) return streamGoogleVertex(model, context, {
224
+ if (!options?.reasoning) return stream(model, context, {
224
225
  ...base,
225
226
  thinking: { enabled: false }
226
227
  });
227
228
  const clampedReasoning = clampThinkingLevel(model, options.reasoning);
228
229
  const effort = clampedReasoning === "off" ? "high" : clampedReasoning;
229
230
  const geminiModel = model;
230
- if (isGemini3ProModel(geminiModel) || isGemini3FlashModel(geminiModel)) return streamGoogleVertex(model, context, {
231
+ if (isGemini3ProModel(geminiModel) || isGemini3FlashModel(geminiModel)) return stream(model, context, {
231
232
  ...base,
232
233
  thinking: {
233
234
  enabled: true,
234
235
  level: getGemini3ThinkingLevel(effort, geminiModel)
235
236
  }
236
237
  });
237
- return streamGoogleVertex(model, context, {
238
+ return stream(model, context, {
238
239
  ...base,
239
240
  thinking: {
240
241
  enabled: true,
@@ -242,13 +243,6 @@ const streamSimpleGoogleVertex = (model, context, options) => {
242
243
  }
243
244
  });
244
245
  };
245
- function register() {
246
- registerApiProvider({
247
- api: "google-vertex",
248
- stream: streamGoogleVertex,
249
- streamSimple: streamSimpleGoogleVertex
250
- });
251
- }
252
246
  function createClient(model, project, location, optionsHeaders, env) {
253
247
  const googleAuthOptions = buildGoogleAuthOptions(env);
254
248
  return new GoogleGenAI({
@@ -276,10 +270,11 @@ function buildHttpOptions(model, optionsHeaders) {
276
270
  httpOptions.baseUrlResourceScope = ResourceScope.COLLECTION;
277
271
  if (baseUrlIncludesApiVersion(baseUrl)) httpOptions.apiVersion = "";
278
272
  }
279
- if (model.headers || optionsHeaders) httpOptions.headers = {
273
+ const headers = providerHeadersToRecord({
280
274
  ...model.headers,
281
275
  ...optionsHeaders
282
- };
276
+ });
277
+ if (headers) httpOptions.headers = headers;
283
278
  return Object.keys(httpOptions).length > 0 ? httpOptions : void 0;
284
279
  }
285
280
  function resolveCustomBaseUrl(baseUrl) {
@@ -388,4 +383,4 @@ function getGoogleBudget(model, effort, customBudgets) {
388
383
  return -1;
389
384
  }
390
385
  //#endregion
391
- export { register, streamGoogleVertex, streamSimpleGoogleVertex };
386
+ export { stream, streamSimple };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/hash.js
2
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/hash.js
3
3
  /** Fast deterministic hash to shorten long strings */
4
4
  function shortHash(str) {
5
5
  let h1 = 3735928559;
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/headers.js
3
+ function headersToRecord(headers) {
4
+ const result = {};
5
+ for (const [key, value] of headers.entries()) result[key] = value;
6
+ return result;
7
+ }
8
+ function providerHeadersToRecord(headers) {
9
+ if (!headers) return void 0;
10
+ const result = {};
11
+ for (const [key, value] of Object.entries(headers)) if (value !== null) result[key] = value;
12
+ return Object.keys(result).length > 0 ? result : void 0;
13
+ }
14
+ //#endregion
15
+ export { providerHeadersToRecord as n, headersToRecord as t };
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
- import { Ir as calculateCost, Lr as clampThinkingLevel, Vr as registerApiProvider, jr as parseStreamingJson, zr as AssistantMessageEventStream } from "./server.js";
3
- import { t as sanitizeSurrogates } from "./sanitize-unicode-BbVojtka.mjs";
4
- import { r as buildBaseOptions, t as transformMessages } from "./transform-messages-CLmkH5Gu.mjs";
5
- import { t as shortHash } from "./hash-CScAQ-b_.mjs";
2
+ import { Ir as calculateCost, Lr as clampThinkingLevel, jr as parseStreamingJson, zr as AssistantMessageEventStream } from "./server.js";
3
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-Ga8nHda1.mjs";
4
+ import { r as buildBaseOptions, t as transformMessages } from "./transform-messages-D9fZ7fnU.mjs";
5
+ import { t as shortHash } from "./hash-wSEYO-QF.mjs";
6
6
  import { $ as $ZodError, A as compactMap, B as date, C as smartUnion, D as outboundSchema, E as inboundSchemaInt, F as _void, G as number, H as lazy, I as any, J as string, K as object, L as array, M as formatZodError, N as ZodBoolean$1, O as outboundSchemaInt, P as _enum, Q as _coercedBoolean, R as boolean$1, S as DocumentURLChunk$outboundSchema, T as inboundSchema, U as literal, V as int, W as nullable, X as datetime, Y as union, Z as toJSONSchema, _ as TextChunk$outboundSchema, a as DeltaMessage$inboundSchema, b as FileChunk$outboundSchema, c as ContentChunk$inboundSchema, d as ThinkChunk$outboundSchema, et as NEVER, f as ToolReferenceChunk$inboundSchema, g as TextChunk$inboundSchema, h as BuiltInConnectors$outboundSchema, i as UsageInfo$outboundSchema, j as remap, k as safeParse, l as ContentChunk$outboundSchema, m as BuiltInConnectors$inboundSchema, nt as OK$1, o as ToolCall$inboundSchema, p as ToolReferenceChunk$outboundSchema, q as record, r as UsageInfo$inboundSchema, rt as unwrapAsync, s as ToolCall$outboundSchema, t as CompletionChunk$inboundSchema, tt as ERR, u as ThinkChunk$inboundSchema, v as ImageURLChunk$inboundSchema, w as discriminatedUnion, x as DocumentURLChunk$inboundSchema, y as ImageURLChunk$outboundSchema, z as custom } from "./completionchunk-DDfxP5hO.mjs";
7
7
  //#region ../../node_modules/.pnpm/@mistralai+mistralai@2.2.6_@opentelemetry+api@1.9.0/node_modules/@mistralai/mistralai/esm/lib/url.js
8
8
  const hasOwn = Object.prototype.hasOwnProperty;
@@ -1023,7 +1023,7 @@ function json(codes, schema, options) {
1023
1023
  schema
1024
1024
  };
1025
1025
  }
1026
- function stream(codes, schema, options) {
1026
+ function stream$1(codes, schema, options) {
1027
1027
  return {
1028
1028
  ...options,
1029
1029
  enc: "stream",
@@ -12742,7 +12742,7 @@ async function $do$205(client, request, options) {
12742
12742
  Response: response,
12743
12743
  Request: req
12744
12744
  } };
12745
- const [result] = await match(stream(200, custom((x) => x instanceof ReadableStream), { ctype: "audio/wav" }), jsonErr(422, HTTPValidationError$inboundSchema), fail("4XX"), fail("5XX"))(response, req, { extraFields: responseFields });
12745
+ const [result] = await match(stream$1(200, custom((x) => x instanceof ReadableStream), { ctype: "audio/wav" }), jsonErr(422, HTTPValidationError$inboundSchema), fail("4XX"), fail("5XX"))(response, req, { extraFields: responseFields });
12746
12746
  if (!result.ok) return [result, {
12747
12747
  status: "complete",
12748
12748
  request: req,
@@ -30850,7 +30850,7 @@ async function $do$59(client, request, options) {
30850
30850
  request: req
30851
30851
  }];
30852
30852
  const response = doResult.value;
30853
- const [result] = await match(stream(200, custom((x) => x instanceof ReadableStream)), fail("4XX"), fail("5XX"))(response, req);
30853
+ const [result] = await match(stream$1(200, custom((x) => x instanceof ReadableStream)), fail("4XX"), fail("5XX"))(response, req);
30854
30854
  if (!result.ok) return [result, {
30855
30855
  status: "complete",
30856
30856
  request: req,
@@ -36295,13 +36295,13 @@ var Mistral = class extends ClientSDK {
36295
36295
  }
36296
36296
  };
36297
36297
  //#endregion
36298
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js
36298
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js
36299
36299
  const MISTRAL_TOOL_CALL_ID_LENGTH = 9;
36300
36300
  const MAX_MISTRAL_ERROR_BODY_CHARS = 4e3;
36301
36301
  /**
36302
36302
  * Stream responses from Mistral using `chat.stream`.
36303
36303
  */
36304
- const streamMistral = (model, context, options) => {
36304
+ const stream = (model, context, options) => {
36305
36305
  const stream = new AssistantMessageEventStream();
36306
36306
  (async () => {
36307
36307
  const output = createOutput(model);
@@ -36347,26 +36347,19 @@ const streamMistral = (model, context, options) => {
36347
36347
  /**
36348
36348
  * Maps provider-agnostic `SimpleStreamOptions` to Mistral options.
36349
36349
  */
36350
- const streamSimpleMistral = (model, context, options) => {
36350
+ const streamSimple = (model, context, options) => {
36351
36351
  const apiKey = options?.apiKey;
36352
36352
  if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
36353
36353
  const base = buildBaseOptions(model, options, apiKey);
36354
36354
  const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
36355
36355
  const reasoning = clampedReasoning === "off" ? void 0 : clampedReasoning;
36356
36356
  const shouldUseReasoning = model.reasoning && reasoning !== void 0;
36357
- return streamMistral(model, context, {
36357
+ return stream(model, context, {
36358
36358
  ...base,
36359
36359
  promptMode: shouldUseReasoning && usesPromptModeReasoning(model) ? "reasoning" : void 0,
36360
36360
  reasoningEffort: shouldUseReasoning && usesReasoningEffort(model) ? mapReasoningEffort(model, reasoning) : void 0
36361
36361
  });
36362
36362
  };
36363
- function register() {
36364
- registerApiProvider({
36365
- api: "mistral-conversations",
36366
- stream: streamMistral,
36367
- streamSimple: streamSimpleMistral
36368
- });
36369
- }
36370
36363
  function createOutput(model) {
36371
36364
  return {
36372
36365
  role: "assistant",
@@ -36803,4 +36796,4 @@ function mapChatStopReason(reason) {
36803
36796
  }
36804
36797
  }
36805
36798
  //#endregion
36806
- export { register, streamMistral, streamSimpleMistral };
36799
+ export { stream, streamSimple };
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
- import { Fr as registerSessionResourceCleanup, Lr as clampThinkingLevel, Mr as appendAssistantMessageDiagnostic, Nr as createAssistantMessageDiagnostic, Pr as formatThrownValue, Rr as getProviderEnvValue, Vr as registerApiProvider, zr as AssistantMessageEventStream } from "./server.js";
3
- import { t as headersToRecord } from "./headers-oksLmLNC.mjs";
4
- import { r as buildBaseOptions } from "./transform-messages-CLmkH5Gu.mjs";
2
+ import { Fr as registerSessionResourceCleanup, Lr as clampThinkingLevel, Mr as appendAssistantMessageDiagnostic, Nr as createAssistantMessageDiagnostic, Pr as formatThrownValue, Rr as getProviderEnvValue, zr as AssistantMessageEventStream } from "./server.js";
3
+ import { t as headersToRecord } from "./headers-SFoLwUHv.mjs";
4
+ import { r as buildBaseOptions } from "./transform-messages-D9fZ7fnU.mjs";
5
5
  import { t as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-6hf3xB_x.mjs";
6
- import { n as convertResponsesTools, r as processResponsesStream, t as convertResponsesMessages } from "./openai-responses-shared-DtEshy-7.mjs";
7
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js
6
+ import { n as convertResponsesTools, r as processResponsesStream, t as convertResponsesMessages } from "./openai-responses-shared-CG93Thoy.mjs";
7
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js
8
8
  function combineAbortSignals(signals) {
9
9
  const activeSignals = signals.filter((signal) => signal !== void 0);
10
10
  if (activeSignals.length === 0) return { cleanup: () => {} };
@@ -37,7 +37,7 @@ function combineAbortSignals(signals) {
37
37
  };
38
38
  }
39
39
  //#endregion
40
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js
40
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js
41
41
  const DEFAULT_PROXY_PORTS = {
42
42
  ftp: 21,
43
43
  gopher: 70,
@@ -97,7 +97,7 @@ function resolveHttpProxyUrlForTarget(targetUrl, env) {
97
97
  return proxyUrl;
98
98
  }
99
99
  //#endregion
100
- //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.79.10_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js
100
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.80.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__ws@8.21.0_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js
101
101
  var __rewriteRelativeImportExtension = function(path, preserveJsx) {
102
102
  if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
103
103
  return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
@@ -123,6 +123,7 @@ const CODEX_TOOL_CALL_PROVIDERS = new Set([
123
123
  "opencode"
124
124
  ]);
125
125
  const WEBSOCKET_MESSAGE_TOO_BIG_CLOSE_CODE = 1009;
126
+ const WEBSOCKET_CONNECTION_LIMIT_REACHED_CODE = "websocket_connection_limit_reached";
126
127
  const CODEX_RESPONSE_STATUSES = new Set([
127
128
  "completed",
128
129
  "incomplete",
@@ -187,7 +188,7 @@ function createSSEHeaderTimeout() {
187
188
  error: () => error
188
189
  };
189
190
  }
190
- const streamOpenAICodexResponses = (model, context, options) => {
191
+ const stream = (model, context, options) => {
191
192
  const stream = new AssistantMessageEventStream();
192
193
  (async () => {
193
194
  const output = {
@@ -231,30 +232,41 @@ const streamOpenAICodexResponses = (model, context, options) => {
231
232
  if (websocketDisabledForSession) recordWebSocketSseFallback(options?.sessionId);
232
233
  if (transport !== "sse" && !websocketDisabledForSession) {
233
234
  let websocketStarted = false;
234
- try {
235
- await processWebSocketStream(resolveCodexWebSocketUrl(model.baseUrl), body, websocketHeaders, output, stream, model, () => {
236
- websocketStarted = true;
237
- }, idleTimeoutMs, websocketConnectTimeoutMs, options);
238
- if (options?.signal?.aborted) throw new Error("Request was aborted");
239
- stream.push({
240
- type: "done",
241
- reason: output.stopReason,
242
- message: output
243
- });
244
- stream.end();
245
- return;
246
- } catch (error) {
247
- if (options?.signal?.aborted || isCodexNonTransportError(error)) throw error;
248
- appendAssistantMessageDiagnostic(output, createAssistantMessageDiagnostic("provider_transport_failure", error, {
249
- configuredTransport: transport,
250
- fallbackTransport: websocketStarted ? void 0 : "sse",
251
- eventsEmitted: websocketStarted,
252
- phase: websocketStarted ? "after_message_stream_start" : "before_message_stream_start",
253
- requestBytes: new TextEncoder().encode(bodyJson).byteLength
254
- }));
255
- recordWebSocketFailure(options?.sessionId, error);
256
- if (websocketStarted) throw error;
257
- recordWebSocketSseFallback(options?.sessionId);
235
+ let retriedWebSocketConnectionLimit = false;
236
+ while (true) {
237
+ websocketStarted = false;
238
+ try {
239
+ await processWebSocketStream(resolveCodexWebSocketUrl(model.baseUrl), body, websocketHeaders, output, stream, model, () => {
240
+ websocketStarted = true;
241
+ }, idleTimeoutMs, websocketConnectTimeoutMs, options);
242
+ if (options?.signal?.aborted) throw new Error("Request was aborted");
243
+ stream.push({
244
+ type: "done",
245
+ reason: output.stopReason,
246
+ message: output
247
+ });
248
+ stream.end();
249
+ return;
250
+ } catch (error) {
251
+ const aborted = options?.signal?.aborted;
252
+ const connectionLimitBeforeStart = !websocketStarted && isWebSocketConnectionLimitReachedError(error);
253
+ if (!aborted && connectionLimitBeforeStart && !retriedWebSocketConnectionLimit) {
254
+ retriedWebSocketConnectionLimit = true;
255
+ continue;
256
+ }
257
+ if (aborted || isCodexNonTransportError(error) && !connectionLimitBeforeStart) throw error;
258
+ appendAssistantMessageDiagnostic(output, createAssistantMessageDiagnostic("provider_transport_failure", error, {
259
+ configuredTransport: transport,
260
+ fallbackTransport: websocketStarted ? void 0 : "sse",
261
+ eventsEmitted: websocketStarted,
262
+ phase: websocketStarted ? "after_message_stream_start" : "before_message_stream_start",
263
+ requestBytes: new TextEncoder().encode(bodyJson).byteLength
264
+ }));
265
+ recordWebSocketFailure(options?.sessionId, error);
266
+ if (websocketStarted) throw error;
267
+ recordWebSocketSseFallback(options?.sessionId);
268
+ break;
269
+ }
258
270
  }
259
271
  }
260
272
  let response;
@@ -335,24 +347,17 @@ const streamOpenAICodexResponses = (model, context, options) => {
335
347
  })();
336
348
  return stream;
337
349
  };
338
- const streamSimpleOpenAICodexResponses = (model, context, options) => {
350
+ const streamSimple = (model, context, options) => {
339
351
  const apiKey = options?.apiKey;
340
352
  if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
341
353
  const base = buildBaseOptions(model, options, apiKey);
342
354
  const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
343
355
  const reasoningEffort = clampedReasoning === "off" ? void 0 : clampedReasoning;
344
- return streamOpenAICodexResponses(model, context, {
356
+ return stream(model, context, {
345
357
  ...base,
346
358
  reasoningEffort
347
359
  });
348
360
  };
349
- function register() {
350
- registerApiProvider({
351
- api: "openai-codex-responses",
352
- stream: streamOpenAICodexResponses,
353
- streamSimple: streamSimpleOpenAICodexResponses
354
- });
355
- }
356
361
  function buildRequestBody(model, context, options) {
357
362
  const messages = convertResponsesMessages(model, context, CODEX_TOOL_CALL_PROVIDERS, { includeSystemPrompt: false });
358
363
  const body = {
@@ -441,14 +446,24 @@ var CodexProtocolError = class extends Error {
441
446
  function isCodexNonTransportError(error) {
442
447
  return error instanceof CodexApiError || error instanceof CodexProtocolError;
443
448
  }
449
+ function isWebSocketConnectionLimitReachedError(error) {
450
+ return error instanceof CodexApiError && error.code === WEBSOCKET_CONNECTION_LIMIT_REACHED_CODE;
451
+ }
452
+ function extractCodexEventError(event) {
453
+ const nested = event.error && typeof event.error === "object" ? event.error : void 0;
454
+ return {
455
+ code: typeof event.code === "string" ? event.code : typeof nested?.code === "string" ? nested.code : void 0,
456
+ message: typeof event.message === "string" ? event.message : typeof nested?.message === "string" ? nested.message : void 0
457
+ };
458
+ }
444
459
  async function* mapCodexEvents(events) {
445
460
  for await (const event of events) {
446
461
  const type = typeof event.type === "string" ? event.type : void 0;
447
462
  if (!type) continue;
448
463
  if (type === "error") {
449
- const code = event.code || "";
450
- throw new CodexApiError(`Codex error: ${event.message || code || JSON.stringify(event)}`, {
451
- code: code || void 0,
464
+ const { code, message } = extractCodexEventError(event);
465
+ throw new CodexApiError(`Codex error: ${message || code || JSON.stringify(event)}`, {
466
+ code,
452
467
  payload: event
453
468
  });
454
469
  }
@@ -1047,7 +1062,8 @@ function createCodexRequestId() {
1047
1062
  }
1048
1063
  function buildBaseCodexHeaders(initHeaders, additionalHeaders, accountId, token) {
1049
1064
  const headers = new Headers(initHeaders);
1050
- for (const [key, value] of Object.entries(additionalHeaders || {})) headers.set(key, value);
1065
+ for (const [key, value] of Object.entries(additionalHeaders || {})) if (value === null) headers.delete(key);
1066
+ else headers.set(key, value);
1051
1067
  headers.set("Authorization", `Bearer ${token}`);
1052
1068
  headers.set("chatgpt-account-id", accountId);
1053
1069
  headers.set("originator", "pi");
@@ -1078,4 +1094,4 @@ function buildWebSocketHeaders(initHeaders, additionalHeaders, accountId, token,
1078
1094
  return headers;
1079
1095
  }
1080
1096
  //#endregion
1081
- export { closeOpenAICodexWebSocketSessions, getOpenAICodexWebSocketDebugStats, register, resetOpenAICodexWebSocketDebugStats, streamOpenAICodexResponses, streamSimpleOpenAICodexResponses };
1097
+ export { closeOpenAICodexWebSocketSessions, getOpenAICodexWebSocketDebugStats, resetOpenAICodexWebSocketDebugStats, stream, streamSimple };