@ramme-io/kernel 5.0.1 → 6.0.0

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.
@@ -1,5 +1,5 @@
1
- import { z as o } from "zod";
2
- const _t = {
1
+ import { z as n } from "zod";
2
+ const Jt = {
3
3
  // ── ROOM 1: STRATEGY OFFICE ──────────────────────────────────────
4
4
  strategist: {
5
5
  id: "strategist",
@@ -114,63 +114,63 @@ Provide a structured audit report with:
114
114
  `.trim()
115
115
  }
116
116
  };
117
- var te = Object.defineProperty, re = (n, e) => {
117
+ var ie = Object.defineProperty, se = (a, e) => {
118
118
  for (var r in e)
119
- te(n, r, { get: e[r], enumerable: !0 });
120
- }, ne = o.object({
121
- key: o.string(),
122
- label: o.string(),
123
- type: o.enum(["text", "number", "currency", "percent", "delta", "date", "boolean", "status", "email", "image", "textarea"]),
124
- required: o.boolean().optional(),
125
- description: o.string().optional(),
126
- defaultValue: o.any().optional()
127
- }), ae = o.object({
128
- id: o.string(),
129
- name: o.string(),
130
- fields: o.array(ne),
131
- defaultView: o.enum(["table", "grid", "list"]).optional(),
132
- features: o.object({
133
- searchable: o.boolean().optional(),
134
- creatable: o.boolean().optional(),
135
- editable: o.boolean().optional(),
136
- deletable: o.boolean().optional(),
137
- exportable: o.boolean().optional()
119
+ ie(a, r, { get: e[r], enumerable: !0 });
120
+ }, ce = n.object({
121
+ key: n.string(),
122
+ label: n.string(),
123
+ type: n.enum(["text", "number", "currency", "percent", "delta", "date", "boolean", "status", "email", "image", "textarea"]),
124
+ required: n.boolean().optional(),
125
+ description: n.string().optional(),
126
+ defaultValue: n.any().optional()
127
+ }), le = n.object({
128
+ id: n.string(),
129
+ name: n.string(),
130
+ fields: n.array(ce),
131
+ defaultView: n.enum(["table", "grid", "list"]).optional(),
132
+ features: n.object({
133
+ searchable: n.boolean().optional(),
134
+ creatable: n.boolean().optional(),
135
+ editable: n.boolean().optional(),
136
+ deletable: n.boolean().optional(),
137
+ exportable: n.boolean().optional()
138
138
  }).optional()
139
- }), oe = o.object({
140
- id: o.string().min(1, "Signal ID is required"),
141
- label: o.string(),
142
- description: o.string().optional(),
143
- kind: o.enum(["sensor", "actuator", "setpoint", "metric", "status", "kpi"]),
144
- source: o.enum(["mock", "mqtt", "http", "derived", "local"]),
139
+ }), ue = n.object({
140
+ id: n.string().min(1, "Signal ID is required"),
141
+ label: n.string(),
142
+ description: n.string().optional(),
143
+ kind: n.enum(["sensor", "actuator", "setpoint", "metric", "status", "kpi"]),
144
+ source: n.enum(["mock", "mqtt", "http", "derived", "local"]),
145
145
  // Connectivity
146
- topic: o.string().optional(),
147
- endpoint: o.string().optional(),
148
- jsonPath: o.string().optional(),
149
- refreshRate: o.number().optional().default(1e3),
146
+ topic: n.string().optional(),
147
+ endpoint: n.string().optional(),
148
+ jsonPath: n.string().optional(),
149
+ refreshRate: n.number().optional().default(1e3),
150
150
  // Values
151
- defaultValue: o.any().optional(),
152
- unit: o.string().optional(),
153
- min: o.number().optional(),
154
- max: o.number().optional()
155
- }), ie = o.object({
156
- id: o.string(),
157
- name: o.string(),
158
- description: o.string().optional(),
159
- type: o.string(),
160
- category: o.string().default("logical"),
161
- signals: o.array(o.string()),
162
- ui: o.object({
163
- icon: o.string().optional(),
164
- color: o.string().optional(),
165
- dashboardComponent: o.string().optional()
151
+ defaultValue: n.any().optional(),
152
+ unit: n.string().optional(),
153
+ min: n.number().optional(),
154
+ max: n.number().optional()
155
+ }), me = n.object({
156
+ id: n.string(),
157
+ name: n.string(),
158
+ description: n.string().optional(),
159
+ type: n.string(),
160
+ category: n.string().default("logical"),
161
+ signals: n.array(n.string()),
162
+ ui: n.object({
163
+ icon: n.string().optional(),
164
+ color: n.string().optional(),
165
+ dashboardComponent: n.string().optional()
166
166
  }).optional()
167
- }), se = o.object({
168
- id: o.string(),
169
- type: o.enum(["signal_change", "manual_action", "schedule", "webhook"]),
170
- config: o.record(o.string(), o.any())
171
- }), ce = o.object({
172
- id: o.string(),
173
- type: o.enum([
167
+ }), de = n.object({
168
+ id: n.string(),
169
+ type: n.enum(["signal_change", "manual_action", "schedule", "webhook"]),
170
+ config: n.record(n.string(), n.any())
171
+ }), pe = n.object({
172
+ id: n.string(),
173
+ type: n.enum([
174
174
  "update_resource",
175
175
  "send_notification",
176
176
  "mqtt_publish",
@@ -178,92 +178,92 @@ var te = Object.defineProperty, re = (n, e) => {
178
178
  "navigate",
179
179
  "agent_task"
180
180
  ]),
181
- config: o.record(o.string(), o.any())
182
- }), le = o.object({
183
- id: o.string(),
184
- name: o.string(),
185
- active: o.boolean().default(!0),
186
- trigger: se,
187
- actions: o.array(ce)
188
- }), de = o.object({
189
- id: o.string(),
190
- type: o.string(),
191
- props: o.record(o.string(), o.any()),
192
- layout: o.object({
193
- colSpan: o.number().optional(),
194
- rowSpan: o.number().optional()
181
+ config: n.record(n.string(), n.any())
182
+ }), ge = n.object({
183
+ id: n.string(),
184
+ name: n.string(),
185
+ active: n.boolean().default(!0),
186
+ trigger: de,
187
+ actions: n.array(pe)
188
+ }), he = n.object({
189
+ id: n.string(),
190
+ type: n.string(),
191
+ props: n.record(n.string(), n.any()),
192
+ layout: n.object({
193
+ colSpan: n.number().optional(),
194
+ rowSpan: n.number().optional()
195
195
  }).optional()
196
- }), ue = o.object({
197
- id: o.string(),
198
- title: o.string().optional(),
199
- description: o.string().optional(),
200
- layout: o.object({
201
- columns: o.number().optional(),
202
- variant: o.enum(["grid", "stack", "split"]).optional()
196
+ }), fe = n.object({
197
+ id: n.string(),
198
+ title: n.string().optional(),
199
+ description: n.string().optional(),
200
+ layout: n.object({
201
+ columns: n.number().optional(),
202
+ variant: n.enum(["grid", "stack", "split"]).optional()
203
203
  }).optional(),
204
- blocks: o.array(de)
205
- }), me = o.object({
206
- id: o.string(),
207
- slug: o.string(),
208
- title: o.string(),
209
- description: o.string().optional(),
210
- icon: o.string().optional(),
211
- sections: o.array(ue)
212
- }), pe = o.enum(["ENVIRONMENT", "SESSION_BYOK", "VAULT"]), ge = o.object({
213
- strategy: pe,
214
- status: o.enum(["VALID", "KEY_EXPIRED", "BYOK_REQUIRED", "DEGRADED", "UNKNOWN"]).default("UNKNOWN")
215
- }), Tt = o.object({
216
- meta: o.object({
217
- name: o.string(),
218
- version: o.string(),
219
- description: o.string().optional(),
220
- author: o.string().optional(),
221
- createdAt: o.string().optional()
204
+ blocks: n.array(he)
205
+ }), ye = n.object({
206
+ id: n.string(),
207
+ slug: n.string(),
208
+ title: n.string(),
209
+ description: n.string().optional(),
210
+ icon: n.string().optional(),
211
+ sections: n.array(fe)
212
+ }), be = n.enum(["ENVIRONMENT", "SESSION_BYOK", "VAULT"]), we = n.object({
213
+ strategy: be,
214
+ status: n.enum(["VALID", "KEY_EXPIRED", "BYOK_REQUIRED", "DEGRADED", "UNKNOWN"]).default("UNKNOWN")
215
+ }), Kt = n.object({
216
+ meta: n.object({
217
+ name: n.string(),
218
+ version: n.string(),
219
+ description: n.string().optional(),
220
+ author: n.string().optional(),
221
+ createdAt: n.string().optional()
222
222
  }),
223
- config: o.object({
224
- theme: o.enum(["light", "dark", "system", "corporate", "midnight", "blueprint"]).default("system"),
225
- layout: o.enum(["dashboard", "explorer", "studio", "focus"]).default("dashboard"),
226
- mockMode: o.boolean().default(!0),
227
- brokerUrl: o.string().optional(),
228
- aiKeyManifest: ge.optional()
223
+ config: n.object({
224
+ theme: n.enum(["light", "dark", "system", "corporate", "midnight", "blueprint"]).default("system"),
225
+ layout: n.enum(["dashboard", "explorer", "studio", "focus"]).default("dashboard"),
226
+ mockMode: n.boolean().default(!0),
227
+ brokerUrl: n.string().optional(),
228
+ aiKeyManifest: we.optional()
229
229
  }),
230
- modules: o.array(o.string()).optional(),
231
- resources: o.array(ae).optional(),
232
- domain: o.object({
233
- signals: o.array(oe),
234
- entities: o.array(ie),
235
- workflows: o.array(le).optional()
230
+ modules: n.array(n.string()).optional(),
231
+ resources: n.array(le).optional(),
232
+ domain: n.object({
233
+ signals: n.array(ue),
234
+ entities: n.array(me),
235
+ workflows: n.array(ge).optional()
236
236
  }),
237
- pages: o.array(me).optional()
238
- }), St = o.object({
239
- timestamp: o.number(),
240
- soilMoisture: o.number().min(0).max(100),
241
- ambientLight: o.number().min(0).max(1e5),
242
- temperature: o.number().min(-40).max(125)
243
- }), he = o.object({
244
- id: o.string(),
245
- source: o.enum(["mqtt", "http", "ws", "mock"]),
246
- domain: o.string(),
247
- key: o.string(),
248
- value: o.union([o.number(), o.string(), o.boolean()]),
249
- unit: o.string().optional(),
250
- timestamp: o.number(),
251
- meta: o.record(o.unknown()).optional()
237
+ pages: n.array(ye).optional()
238
+ }), Ft = n.object({
239
+ timestamp: n.number(),
240
+ soilMoisture: n.number().min(0).max(100),
241
+ ambientLight: n.number().min(0).max(1e5),
242
+ temperature: n.number().min(-40).max(125)
243
+ }), Ee = n.object({
244
+ id: n.string(),
245
+ source: n.enum(["mqtt", "http", "ws", "mock"]),
246
+ domain: n.string(),
247
+ key: n.string(),
248
+ value: n.union([n.number(), n.string(), n.boolean()]),
249
+ unit: n.string().optional(),
250
+ timestamp: n.number(),
251
+ meta: n.record(n.unknown()).optional()
252
252
  });
253
- o.array(he);
254
- var fe = o.enum(["telemetry", "market", "system", "logic"]), ye = o.enum(["mqtt", "http", "ws", "mock"]);
255
- o.object({
253
+ n.array(Ee);
254
+ var Ae = n.enum(["telemetry", "market", "system", "logic"]), ke = n.enum(["mqtt", "http", "ws", "mock"]);
255
+ n.object({
256
256
  /**
257
257
  * Globally unique signal identifier.
258
258
  * Convention: '<device-or-entity-id>:<key>'
259
259
  * Examples: 'sensor-01:soil_vwc', 'AAPL:price', 'server-01:cpu_pct'
260
260
  */
261
- id: o.string(),
261
+ id: n.string(),
262
262
  /**
263
263
  * The semantic category of this signal.
264
264
  * Determines which Methodology Engine processes it.
265
265
  */
266
- kind: fe,
266
+ kind: Ae,
267
267
  /**
268
268
  * The specific measurement or metric key within its kind.
269
269
  * RULE: Keys MUST be abstract and domain-agnostic where possible.
@@ -271,108 +271,210 @@ o.object({
271
271
  * Hardware-specific keys (soil_vwc) MUST be mapped to abstract keys
272
272
  * at the adapter layer BEFORE the SignalPacket is created.
273
273
  */
274
- key: o.string(),
274
+ key: n.string(),
275
275
  /**
276
276
  * The scalar value. Accepts number, string, or boolean.
277
277
  * Structured data MUST be flattened into multiple SignalPackets,
278
278
  * one per measurable dimension.
279
279
  */
280
- value: o.union([o.number(), o.string(), o.boolean()]),
280
+ value: n.union([n.number(), n.string(), n.boolean()]),
281
281
  /**
282
282
  * Optional unit of measurement.
283
283
  * Examples: 'VWC%', 'USD', 'bpm', 'ms', '°C', 'pct'
284
284
  */
285
- unit: o.string().optional(),
285
+ unit: n.string().optional(),
286
286
  /**
287
287
  * Unix timestamp in milliseconds (Date.now() format).
288
288
  * MUST represent when the measurement was taken, not when it was received.
289
289
  */
290
- ts: o.number(),
290
+ ts: n.number(),
291
291
  /**
292
292
  * The transport source that produced this signal.
293
293
  */
294
- source: ye.optional(),
294
+ source: ke.optional(),
295
295
  /**
296
296
  * Optional domain namespace for grouping related signals.
297
297
  * Examples: 'bodewell', 'finance', 'infrastructure', 'user_behavior'
298
298
  */
299
- domain: o.string().optional(),
299
+ domain: n.string().optional(),
300
300
  /**
301
301
  * Optional pass-through for source-specific metadata that does NOT
302
302
  * belong in the core contract (e.g. device firmware version, exchange name).
303
303
  * RULE: If you find yourself reading from meta in UI components, that
304
304
  * field should be promoted to the core schema or handled in the adapter.
305
305
  */
306
- meta: o.record(o.unknown()).optional()
306
+ meta: n.record(n.unknown()).optional()
307
307
  });
308
- var be = {};
309
- re(be, {
310
- BodewellCommandSchema: () => Ee,
311
- BodewellDeviceID: () => z,
312
- BodewellTelemetrySchema: () => we
308
+ var ve = {};
309
+ se(ve, {
310
+ BodewellCommandSchema: () => _e,
311
+ BodewellDeviceID: () => K,
312
+ BodewellTelemetrySchema: () => Se
313
313
  });
314
- var z = o.enum([
314
+ var K = n.enum([
315
315
  "STK-V1-001",
316
316
  "STK-V1-002",
317
317
  "STK-V1-003",
318
318
  "STK-PRO-001",
319
319
  "STK-VIS-001"
320
- ]), we = o.object({
321
- device_id: z,
322
- stick_id: o.string().optional().describe("Firmware alias for device_id"),
323
- timestamp: o.number().optional().describe("Epoch timestamp from NTP"),
324
- air_temp: o.number().optional().describe("Celsius"),
325
- air_humid: o.number().optional().describe("Relative Humidity %"),
326
- humidity: o.number().optional().describe("Firmware alias for air_humid"),
327
- air_pressure: o.number().optional().describe("hPa"),
328
- pressure: o.number().optional().describe("Firmware alias for air_pressure"),
329
- light_lux: o.number().optional().describe("Lux level"),
330
- soil_temp_stemma: o.number().optional().describe("Celsius"),
331
- soil_vwc: o.number().describe("Volumetric Water Content / Raw Capacitance"),
332
- soil_moisture: o.number().optional().describe("Firmware alias for raw capacitance"),
333
- soil_moisture_raw: o.number().optional().describe("Unscaled capacitance (300-1100)")
334
- }).passthrough(), Ee = o.object({
335
- stick_id: z,
320
+ ]), Se = n.object({
321
+ device_id: K,
322
+ stick_id: n.string().optional().describe("Firmware alias for device_id"),
323
+ timestamp: n.number().optional().describe("Epoch timestamp from NTP"),
324
+ air_temp: n.number().optional().describe("Celsius"),
325
+ air_humid: n.number().optional().describe("Relative Humidity %"),
326
+ humidity: n.number().optional().describe("Firmware alias for air_humid"),
327
+ air_pressure: n.number().optional().describe("hPa"),
328
+ pressure: n.number().optional().describe("Firmware alias for air_pressure"),
329
+ light_lux: n.number().optional().describe("Lux level"),
330
+ soil_temp_stemma: n.number().optional().describe("Celsius"),
331
+ soil_vwc: n.number().describe("Volumetric Water Content / Raw Capacitance"),
332
+ soil_moisture: n.number().optional().describe("Firmware alias for raw capacitance"),
333
+ soil_moisture_raw: n.number().optional().describe("Unscaled capacitance (300-1100)")
334
+ }).passthrough(), _e = n.object({
335
+ stick_id: K,
336
336
  // Note: Your API uses stick_id here, not device_id
337
- type: o.enum(["dry", "wet"]),
338
- value: o.number()
337
+ type: n.enum(["dry", "wet"]),
338
+ value: n.number()
339
+ }), Te = n.enum([
340
+ "esp32-touch-28",
341
+ // 2.8" 240x320 resistive touch, the workshop board
342
+ "esp32-headless",
343
+ // no display; sensor node
344
+ "simulator"
345
+ // browser-side stand-in, for building without hardware
346
+ ]), X = n.enum([
347
+ "weather",
348
+ "clock",
349
+ "aircraft",
350
+ "sensor",
351
+ "blank"
352
+ ]), Oe = n.object({
353
+ /** Postal code is what a person knows; the portal resolves it to coordinates. */
354
+ postalCode: n.string().min(3).max(12),
355
+ latitude: n.number().min(-90).max(90).optional(),
356
+ longitude: n.number().min(-180).max(180).optional(),
357
+ units: n.enum(["imperial", "metric"]).default("imperial"),
358
+ showForecast: n.boolean().default(!0),
359
+ refreshSeconds: n.number().int().min(300).max(86400).default(900)
360
+ }), xe = n.object({
361
+ /** IANA zone, e.g. "America/New_York". */
362
+ timezone: n.string().default("America/New_York"),
363
+ twentyFourHour: n.boolean().default(!1),
364
+ showSeconds: n.boolean().default(!1),
365
+ showDate: n.boolean().default(!0)
366
+ }), Ie = n.object({
367
+ latitude: n.number().min(-90).max(90),
368
+ longitude: n.number().min(-180).max(180),
369
+ radiusKm: n.number().min(5).max(400).default(80),
370
+ /** Rows the list view can show before the screen runs out. */
371
+ maxRows: n.number().int().min(1).max(12).default(8),
372
+ refreshSeconds: n.number().int().min(10).max(600).default(30)
373
+ }), Pe = n.object({
374
+ /** Signal keys to display, in order. Abstract keys per the Signal contract. */
375
+ keys: n.array(n.string()).min(1).max(6),
376
+ refreshSeconds: n.number().int().min(1).max(3600).default(10)
377
+ }), je = n.object({
378
+ weather: Oe.optional(),
379
+ clock: xe.optional(),
380
+ aircraft: Ie.optional(),
381
+ sensor: Pe.optional()
382
+ }), Re = n.object({
383
+ brightness: n.number().int().min(5).max(100).default(80),
384
+ /** Degrees clockwise. The board can sit either way up in a case. */
385
+ rotation: n.union([n.literal(0), n.literal(90), n.literal(180), n.literal(270)]).default(0),
386
+ /** Dim rather than sleep — a desk display that blanks looks broken. */
387
+ dimAfterSeconds: n.number().int().min(0).max(86400).default(0),
388
+ dimBrightness: n.number().int().min(0).max(100).default(15),
389
+ /** Local 24h times, e.g. "22:30". Empty disables night dimming. */
390
+ nightStart: n.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional(),
391
+ nightEnd: n.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional()
392
+ }), C = n.string().regex(
393
+ /^\d{1,3} \d{1,3} \d{1,3}$/,
394
+ 'Expected space-separated RGB integers, e.g. "13 110 253"'
395
+ ), Ne = n.object({
396
+ preset: n.enum(["light", "dark", "corporate", "midnight", "blueprint", "custom"]).default("dark"),
397
+ background: C.optional(),
398
+ foreground: C.optional(),
399
+ accent: C.optional(),
400
+ muted: C.optional(),
401
+ warning: C.optional()
339
402
  });
340
- o.object({
341
- deviceId: o.string().min(1, "Device ID is required"),
342
- timeRange: o.enum(["1h", "24h", "7d"], {
403
+ n.object({
404
+ /** Bumped only on breaking shape changes, so old firmware can refuse safely. */
405
+ schemaVersion: n.literal(1),
406
+ deviceId: n.string().min(1),
407
+ /** Monotonic. Portal increments on write; device echoes what it is running. */
408
+ revision: n.number().int().nonnegative(),
409
+ updatedAt: n.string().datetime().optional(),
410
+ activeApp: X,
411
+ apps: je,
412
+ display: Re,
413
+ theme: Ne
414
+ });
415
+ var De = n.enum([
416
+ "unprovisioned",
417
+ "connecting",
418
+ "online",
419
+ "offline",
420
+ "failed"
421
+ ]);
422
+ n.object({
423
+ deviceId: n.string().min(1),
424
+ kind: Te,
425
+ firmwareVersion: n.string(),
426
+ /** Shown on the device's own screen at boot — how the user finds it. */
427
+ ipAddress: n.string().optional(),
428
+ provisioning: De,
429
+ /** Revision the device is actually running, not the one it was sent. */
430
+ configRevision: n.number().int().nonnegative(),
431
+ activeApp: X,
432
+ rssi: n.number().int().optional().describe("dBm"),
433
+ uptimeSeconds: n.number().int().nonnegative().optional(),
434
+ freeHeapBytes: n.number().int().nonnegative().optional()
435
+ });
436
+ n.object({
437
+ deviceId: n.string().min(1, "Device ID is required"),
438
+ timeRange: n.enum(["1h", "24h", "7d"], {
343
439
  errorMap: () => ({ message: "Time range must be 1h, 24h, or 7d" })
344
440
  }),
345
- metrics: o.array(
346
- o.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
441
+ metrics: n.array(
442
+ n.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
347
443
  ).min(1, "At least one metric is required").max(4, "Maximum 4 metrics per graph")
348
444
  });
349
- o.object({
350
- ticker: o.string().min(1).describe("The stock ticker symbol explicitly requested by the user. YOU MUST EXTRACT AND PROVIDE THIS (e.g., 'AAPL', 'MSFT')."),
351
- timeRange: o.enum(["1D", "1W", "1M", "1Y"], {
445
+ n.object({
446
+ ticker: n.string().min(1).describe("The stock ticker symbol explicitly requested by the user. YOU MUST EXTRACT AND PROVIDE THIS (e.g., 'AAPL', 'MSFT')."),
447
+ timeRange: n.enum(["1D", "1W", "1M", "1Y"], {
352
448
  errorMap: () => ({ message: "Time range must be 1D, 1W, 1M, or 1Y" })
353
449
  }).describe("The time range for the chart. Choose based on user request or default to '1M'."),
354
- metrics: o.array(o.enum(["price", "volume", "moving_average"])).min(1, "At least one metric is required").describe("Array of metrics to display. Always include 'price' and 'volume' unless user specifies otherwise.")
450
+ metrics: n.array(n.enum(["price", "volume", "moving_average"])).min(1, "At least one metric is required").describe("Array of metrics to display. Always include 'price' and 'volume' unless user specifies otherwise.")
355
451
  });
356
- var J = o.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
357
- o.object({ ticker: J });
358
- o.object({ ticker: J });
359
- o.object({ ticker: J });
360
- var U = "gemini-2.5-flash", Ae = "gemini-2.5-flash", ke = "gemini-2.5-pro", vt = {
452
+ var U = n.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
453
+ n.object({ ticker: U });
454
+ n.object({ ticker: U });
455
+ n.object({ ticker: U });
456
+ n.object({
457
+ ticker: U,
458
+ hops: n.number().int().min(1).max(2).optional().describe("How many relationship hops to traverse (1 = direct counterparties only, 2 = counterparties-of-counterparties too). Defaults to 1 if omitted.")
459
+ });
460
+ n.object({ ticker: U });
461
+ n.object({});
462
+ var z = "gemini-2.5-flash", Me = "gemini-2.5-flash", $e = "gemini-2.5-pro", Vt = {
361
463
  /** The Strategist: high creativity, exploratory conversation */
362
464
  STRATEGIST: {
363
- model: Ae,
465
+ model: Me,
364
466
  provider: "google-gemini",
365
467
  temperature: 0.7
366
468
  },
367
469
  /** The Architect: data schema and resource modeling — precision required */
368
470
  ARCHITECT: {
369
- model: U,
471
+ model: z,
370
472
  provider: "google-gemini",
371
473
  temperature: 0.3
372
474
  },
373
475
  /** The Designer: UI layout generation — moderate creativity */
374
476
  DESIGNER: {
375
- model: U,
477
+ model: z,
376
478
  provider: "google-gemini",
377
479
  temperature: 0.5
378
480
  },
@@ -380,81 +482,81 @@ var U = "gemini-2.5-flash", Ae = "gemini-2.5-flash", ke = "gemini-2.5-pro", vt =
380
482
  * Uses the Pro tier for superior reasoning on complex structured tasks.
381
483
  */
382
484
  REVIEWER: {
383
- model: ke,
485
+ model: $e,
384
486
  provider: "google-gemini",
385
487
  temperature: 0.2
386
488
  },
387
489
  /** The Genesis Engine: one-shot app generation — must be schema-strict */
388
490
  GENESIS: {
389
- model: U,
491
+ model: z,
390
492
  provider: "google-gemini",
391
493
  temperature: 0.2
392
494
  }
393
- }, S = o.string().regex(
495
+ }, _ = n.string().regex(
394
496
  /^\d{1,3}\s+\d{1,3}\s+\d{1,3}$/,
395
497
  'Must be space-separated RGB integers (e.g. "13 110 253")'
396
- ), _e = o.object({
498
+ ), Le = n.object({
397
499
  // ── Core Brand ───────────────────────────────────────────────────────────
398
- "--app-primary-color": S.optional(),
399
- "--app-primary-foreground-color": S.optional(),
400
- "--app-secondary-color": S.optional(),
401
- "--app-secondary-foreground-color": S.optional(),
402
- "--app-accent-color": S.optional(),
403
- "--app-accent-foreground-color": S.optional(),
500
+ "--app-primary-color": _.optional(),
501
+ "--app-primary-foreground-color": _.optional(),
502
+ "--app-secondary-color": _.optional(),
503
+ "--app-secondary-foreground-color": _.optional(),
504
+ "--app-accent-color": _.optional(),
505
+ "--app-accent-foreground-color": _.optional(),
404
506
  // ── Base Surface ─────────────────────────────────────────────────────────
405
- "--app-bg-color": S.optional(),
406
- "--app-card-bg-color": S.optional(),
407
- "--app-text-color": S.optional(),
408
- "--app-border-color": S.optional(),
409
- "--app-muted-bg": S.optional(),
410
- "--app-muted-text": S.optional(),
507
+ "--app-bg-color": _.optional(),
508
+ "--app-card-bg-color": _.optional(),
509
+ "--app-text-color": _.optional(),
510
+ "--app-border-color": _.optional(),
511
+ "--app-muted-bg": _.optional(),
512
+ "--app-muted-text": _.optional(),
411
513
  // ── Shape ────────────────────────────────────────────────────────────────
412
- "--app-border-radius-sm": o.string().optional(),
413
- "--app-border-radius-md": o.string().optional(),
414
- "--app-border-radius-lg": o.string().optional(),
514
+ "--app-border-radius-sm": n.string().optional(),
515
+ "--app-border-radius-md": n.string().optional(),
516
+ "--app-border-radius-lg": n.string().optional(),
415
517
  // ── Form Controls ────────────────────────────────────────────────────────
416
- "--app-input-bg-color": S.optional(),
417
- "--app-input-text-color": S.optional(),
418
- "--app-input-border-color": S.optional(),
419
- "--app-input-focus-ring-color": S.optional(),
420
- "--app-input-placeholder-color": S.optional(),
518
+ "--app-input-bg-color": _.optional(),
519
+ "--app-input-text-color": _.optional(),
520
+ "--app-input-border-color": _.optional(),
521
+ "--app-input-focus-ring-color": _.optional(),
522
+ "--app-input-placeholder-color": _.optional(),
421
523
  // ── Chart Palette ────────────────────────────────────────────────────────
422
- "--app-chart-1": S.optional(),
423
- "--app-chart-2": S.optional(),
424
- "--app-chart-3": S.optional(),
425
- "--app-chart-4": S.optional(),
426
- "--app-chart-5": S.optional()
427
- }).strict(), Te = o.object({
524
+ "--app-chart-1": _.optional(),
525
+ "--app-chart-2": _.optional(),
526
+ "--app-chart-3": _.optional(),
527
+ "--app-chart-4": _.optional(),
528
+ "--app-chart-5": _.optional()
529
+ }).strict(), Ce = n.object({
428
530
  /** Google Font name for headings (h1–h4, .font-serif). Example: "Playfair Display" */
429
- heading: o.string(),
531
+ heading: n.string(),
430
532
  /** Google Font name for body text. Example: "Inter" */
431
- body: o.string(),
533
+ body: n.string(),
432
534
  /** Optional monospace font. Example: "Roboto Mono" */
433
- mono: o.string().optional()
535
+ mono: n.string().optional()
434
536
  });
435
- o.object({
537
+ n.object({
436
538
  /** Short descriptive theme name. Example: "Midnight Garden" */
437
- name: o.string(),
539
+ name: n.string(),
438
540
  /** One-sentence vibe description. Example: "Dark indigo with golden accents." */
439
- description: o.string(),
541
+ description: n.string(),
440
542
  /** Google Font pairing for heading and body text. */
441
- fonts: Te.optional(),
543
+ fonts: Ce.optional(),
442
544
  /**
443
545
  * CSS variable overrides.
444
546
  * Every key must match an --app-* variable name.
445
547
  * All color values must be space-separated RGB integers.
446
548
  */
447
- cssVars: _e
549
+ cssVars: Le
448
550
  });
449
- o.object({
450
- primary: S,
451
- neutral: S,
452
- success: S,
453
- warning: S,
454
- destructive: S,
455
- radius: o.enum(["none", "sm", "md", "lg", "full"])
551
+ n.object({
552
+ primary: _,
553
+ neutral: _,
554
+ success: _,
555
+ warning: _,
556
+ destructive: _,
557
+ radius: n.enum(["none", "sm", "md", "lg", "full"])
456
558
  });
457
- var Ot = {
559
+ var Yt = {
458
560
  primary: "13 110 253",
459
561
  neutral: "24 24 27",
460
562
  success: "34 197 94",
@@ -462,75 +564,177 @@ var Ot = {
462
564
  destructive: "239 68 68",
463
565
  radius: "md"
464
566
  };
465
- o.object({
466
- id: o.string().default(""),
467
- name: o.string(),
468
- email: o.string().email(),
469
- password: o.string().optional(),
470
- role: o.string(),
471
- status: o.string().optional(),
472
- joinedAt: o.string().optional(),
473
- lastActive: o.string().optional(),
474
- avatarUrl: o.string().optional()
567
+ n.object({
568
+ id: n.string().default(""),
569
+ name: n.string(),
570
+ email: n.string().email(),
571
+ password: n.string().optional(),
572
+ role: n.string(),
573
+ status: n.string().optional(),
574
+ joinedAt: n.string().optional(),
575
+ lastActive: n.string().optional(),
576
+ avatarUrl: n.string().optional()
475
577
  });
476
- var Se = o.enum([
578
+ var Ue = n.enum([
477
579
  "supplier",
478
580
  "customer",
479
581
  "partner",
480
582
  "competitor",
481
583
  "regulator",
482
584
  "unknown"
585
+ ]), Ze = n.enum([
586
+ "public",
587
+ "public_uncovered",
588
+ "private",
589
+ "unresolved"
483
590
  ]);
484
- o.object({
485
- id: o.string(),
486
- ticker: o.string().nullable(),
487
- name: o.string(),
488
- type: Se,
489
- confidence: o.number().min(0).max(1),
490
- sourceSignalIds: o.array(o.number()),
491
- firstSeenAt: o.string().datetime(),
492
- lastSeenAt: o.string().datetime()
591
+ n.object({
592
+ id: n.string(),
593
+ ticker: n.string().nullable(),
594
+ /** Name as it appeared in the source signal — e.g. "Nike". Not the registered name. */
595
+ name: n.string(),
596
+ /** Registered legal name from `profiles` — e.g. "NIKE, Inc.". Null unless `public`. */
597
+ publicName: n.string().nullable(),
598
+ lei: n.string().nullable(),
599
+ resolution: Ze,
600
+ type: Ue,
601
+ confidence: n.number().min(0).max(1),
602
+ sourceSignalIds: n.array(n.number()),
603
+ firstSeenAt: n.string().datetime(),
604
+ lastSeenAt: n.string().datetime()
493
605
  });
494
- var ve = o.enum([
606
+ var qe = n.enum([
495
607
  "supplies_to",
496
608
  "purchases_from",
497
609
  "partners_with",
498
610
  "competes_with",
499
- "regulated_by"
611
+ "regulated_by",
612
+ "invests_in",
613
+ "acquires",
614
+ /**
615
+ * Identity equivalence, not a business relationship: source and target are
616
+ * the same real-world entity under two different node ids (typically a
617
+ * slug-keyed node that predates LEI resolution, pointing at the canonical
618
+ * LEI-keyed node once resolution succeeds). Never delete/merge either
619
+ * node — this edge exists so a consumer wanting a deduped view can follow
620
+ * it to the canonical id, reversibly.
621
+ */
622
+ "same_as"
500
623
  ]);
501
- o.object({
502
- id: o.string(),
503
- sourceId: o.string(),
504
- targetId: o.string(),
505
- edgeType: ve,
506
- weight: o.number().min(0).max(1),
507
- evidenceSignalIds: o.array(o.number()),
508
- updatedAt: o.string().datetime()
624
+ n.object({
625
+ id: n.string(),
626
+ sourceId: n.string(),
627
+ targetId: n.string(),
628
+ edgeType: qe,
629
+ weight: n.number().min(0).max(1),
630
+ evidenceSignalIds: n.array(n.number()),
631
+ updatedAt: n.string().datetime(),
632
+ validFrom: n.string().datetime(),
633
+ /** null = currently valid. Set when a differently-typed edge supersedes this one. */
634
+ validTo: n.string().datetime().nullable()
635
+ });
636
+ var ze = n.object({
637
+ signalId: n.number(),
638
+ weight: n.number().min(0).max(1),
639
+ reason: n.string().max(280)
640
+ });
641
+ n.object({
642
+ ticker: n.string(),
643
+ // 'operations'/'customer' are current; 'operational'/'ux' are pre-rename
644
+ // values that still exist on rows written before the backend's rename —
645
+ // kept here so reading old rows doesn't fail validation.
646
+ metric: n.enum(["operations", "customer", "operational", "ux"]),
647
+ score: n.number(),
648
+ baseline: n.number(),
649
+ observed: n.number(),
650
+ computedAt: n.string().datetime(),
651
+ contributingSignals: n.array(ze)
509
652
  });
510
- var Oe = o.object({
511
- signalId: o.number(),
512
- weight: o.number().min(0).max(1),
513
- reason: o.string().max(280)
653
+ n.object({
654
+ lei: n.string().nullable(),
655
+ entityName: n.string(),
656
+ jurisdiction: n.string().nullable(),
657
+ registrationStatus: n.string(),
658
+ parentEntityLei: n.string().nullable(),
659
+ materialMetadata: n.record(n.unknown()),
660
+ discoveredAt: n.string().datetime()
514
661
  });
515
- o.object({
516
- ticker: o.string(),
517
- metric: o.enum(["operational", "ux"]),
518
- score: o.number(),
519
- baseline: o.number(),
520
- observed: o.number(),
521
- computedAt: o.string().datetime(),
522
- contributingSignals: o.array(Oe)
662
+ var q = n.enum(["db", "mock"]), F = n.enum(["news", "filing", "report"]), Q = n.enum(["graded", "binary", "default", "none"]), Be = n.enum(["second", "day"]), Je = n.object({
663
+ /** Namespaced so ids never collide across sources: `news:1234`, `filing:AAPL:2026-07-31`. */
664
+ id: n.string(),
665
+ kind: F,
666
+ /**
667
+ * The producer's own type string, unmodified — `NEWS_YAHOO FINANCE_YAHOO RSS`,
668
+ * `ANNUAL`, `SNAPSHOT`. There are 31 distinct NEWS variants in the live table,
669
+ * so this is for filtering and debugging: never render it raw to a user.
670
+ */
671
+ subtype: n.string().nullable(),
672
+ ticker: n.string(),
673
+ /** Always `YYYY-MM-DDTHH:MM:SSZ`. Fixed-width, so lexical order == chronological order. */
674
+ occurredAt: n.string(),
675
+ precision: Be,
676
+ title: n.string(),
677
+ summary: n.string().nullable(),
678
+ url: n.string().nullable(),
679
+ impact: n.number().nullable(),
680
+ impactScale: Q,
681
+ /** 0 bearish … 50 neutral … 100 bullish. */
682
+ sentiment: n.number().nullable(),
683
+ /** False for filings, and for any event sitting at exactly neutral. */
684
+ sentimentIsMeaningful: n.boolean(),
685
+ source: q,
686
+ meta: n.record(n.unknown()).nullable()
523
687
  });
524
- o.object({
525
- lei: o.string().nullable(),
526
- entityName: o.string(),
527
- jurisdiction: o.string().nullable(),
528
- registrationStatus: o.string(),
529
- parentEntityLei: o.string().nullable(),
530
- materialMetadata: o.record(o.unknown()),
531
- discoveredAt: o.string().datetime()
688
+ n.object({
689
+ total: n.number(),
690
+ page: n.number(),
691
+ page_size: n.number(),
692
+ data: n.array(Je)
532
693
  });
533
- const Ie = Symbol("Let zodToJsonSchema decide on which parser to use"), V = {
694
+ var Ke = n.enum(["day", "week", "month"]), Fe = n.object({
695
+ bucketStart: n.string(),
696
+ kind: F,
697
+ count: n.number(),
698
+ /** Null when no event in the bucket had meaningful sentiment. */
699
+ avgSentiment: n.number().nullable(),
700
+ maxImpact: n.number().nullable()
701
+ });
702
+ n.object({
703
+ ticker: n.string(),
704
+ bucket: Ke,
705
+ buckets: n.array(Fe),
706
+ /** So the client can set its time domain without a second request. */
707
+ range: n.object({ min: n.string(), max: n.string() }),
708
+ source: q
709
+ });
710
+ var Ve = n.object({
711
+ kind: F,
712
+ count: n.number(),
713
+ earliest: n.string().nullable(),
714
+ latest: n.string().nullable(),
715
+ impactScale: Q,
716
+ sentimentUsable: n.boolean()
717
+ });
718
+ n.object({
719
+ ticker: n.string(),
720
+ facets: n.array(Ve),
721
+ source: q
722
+ });
723
+ var Ye = n.object({
724
+ date: n.string(),
725
+ open: n.number().nullable(),
726
+ high: n.number().nullable(),
727
+ low: n.number().nullable(),
728
+ close: n.number(),
729
+ volume: n.number().nullable()
730
+ });
731
+ n.object({
732
+ ticker: n.string(),
733
+ series: n.array(Ye),
734
+ source: q
735
+ });
736
+ var Gt = 50;
737
+ const Ge = Symbol("Let zodToJsonSchema decide on which parser to use"), G = {
534
738
  name: void 0,
535
739
  $refStrategy: "root",
536
740
  basePath: ["#"],
@@ -553,23 +757,23 @@ const Ie = Symbol("Let zodToJsonSchema decide on which parser to use"), V = {
553
757
  base64Strategy: "contentEncoding:base64",
554
758
  nameStrategy: "ref",
555
759
  openAiAnyTypeName: "OpenAiAnyType"
556
- }, Pe = (n) => typeof n == "string" ? {
557
- ...V,
558
- name: n
760
+ }, We = (a) => typeof a == "string" ? {
761
+ ...G,
762
+ name: a
559
763
  } : {
560
- ...V,
561
- ...n
562
- }, xe = (n) => {
563
- const e = Pe(n), r = e.name !== void 0 ? [...e.basePath, e.definitionPath, e.name] : e.basePath;
764
+ ...G,
765
+ ...a
766
+ }, He = (a) => {
767
+ const e = We(a), r = e.name !== void 0 ? [...e.basePath, e.definitionPath, e.name] : e.basePath;
564
768
  return {
565
769
  ...e,
566
770
  flags: { hasReferencedOpenAiAnyType: !1 },
567
771
  currentPath: r,
568
772
  propertyPath: void 0,
569
- seen: new Map(Object.entries(e.definitions).map(([t, a]) => [
570
- a._def,
773
+ seen: new Map(Object.entries(e.definitions).map(([t, o]) => [
774
+ o._def,
571
775
  {
572
- def: a._def,
776
+ def: o._def,
573
777
  path: [...e.basePath, e.definitionPath, t],
574
778
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
575
779
  jsonSchema: void 0
@@ -577,82 +781,82 @@ const Ie = Symbol("Let zodToJsonSchema decide on which parser to use"), V = {
577
781
  ]))
578
782
  };
579
783
  };
580
- function G(n, e, r, t) {
581
- t != null && t.errorMessages && r && (n.errorMessage = {
582
- ...n.errorMessage,
784
+ function ee(a, e, r, t) {
785
+ t != null && t.errorMessages && r && (a.errorMessage = {
786
+ ...a.errorMessage,
583
787
  [e]: r
584
788
  });
585
789
  }
586
- function T(n, e, r, t, a) {
587
- n[e] = r, G(n, e, t, a);
790
+ function S(a, e, r, t, o) {
791
+ a[e] = r, ee(a, e, t, o);
588
792
  }
589
- const W = (n, e) => {
793
+ const te = (a, e) => {
590
794
  let r = 0;
591
- for (; r < n.length && r < e.length && n[r] === e[r]; r++)
795
+ for (; r < a.length && r < e.length && a[r] === e[r]; r++)
592
796
  ;
593
- return [(n.length - r).toString(), ...e.slice(r)].join("/");
797
+ return [(a.length - r).toString(), ...e.slice(r)].join("/");
594
798
  };
595
799
  var y;
596
- (function(n) {
597
- n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
800
+ (function(a) {
801
+ a.ZodString = "ZodString", a.ZodNumber = "ZodNumber", a.ZodNaN = "ZodNaN", a.ZodBigInt = "ZodBigInt", a.ZodBoolean = "ZodBoolean", a.ZodDate = "ZodDate", a.ZodSymbol = "ZodSymbol", a.ZodUndefined = "ZodUndefined", a.ZodNull = "ZodNull", a.ZodAny = "ZodAny", a.ZodUnknown = "ZodUnknown", a.ZodNever = "ZodNever", a.ZodVoid = "ZodVoid", a.ZodArray = "ZodArray", a.ZodObject = "ZodObject", a.ZodUnion = "ZodUnion", a.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", a.ZodIntersection = "ZodIntersection", a.ZodTuple = "ZodTuple", a.ZodRecord = "ZodRecord", a.ZodMap = "ZodMap", a.ZodSet = "ZodSet", a.ZodFunction = "ZodFunction", a.ZodLazy = "ZodLazy", a.ZodLiteral = "ZodLiteral", a.ZodEnum = "ZodEnum", a.ZodEffects = "ZodEffects", a.ZodNativeEnum = "ZodNativeEnum", a.ZodOptional = "ZodOptional", a.ZodNullable = "ZodNullable", a.ZodDefault = "ZodDefault", a.ZodCatch = "ZodCatch", a.ZodPromise = "ZodPromise", a.ZodBranded = "ZodBranded", a.ZodPipeline = "ZodPipeline", a.ZodReadonly = "ZodReadonly";
598
802
  })(y || (y = {}));
599
- function I(n) {
600
- if (n.target !== "openAi")
803
+ function x(a) {
804
+ if (a.target !== "openAi")
601
805
  return {};
602
806
  const e = [
603
- ...n.basePath,
604
- n.definitionPath,
605
- n.openAiAnyTypeName
807
+ ...a.basePath,
808
+ a.definitionPath,
809
+ a.openAiAnyTypeName
606
810
  ];
607
- return n.flags.hasReferencedOpenAiAnyType = !0, {
608
- $ref: n.$refStrategy === "relative" ? W(e, n.currentPath) : e.join("/")
811
+ return a.flags.hasReferencedOpenAiAnyType = !0, {
812
+ $ref: a.$refStrategy === "relative" ? te(e, a.currentPath) : e.join("/")
609
813
  };
610
814
  }
611
- function Re(n, e) {
612
- var t, a, i;
815
+ function Xe(a, e) {
816
+ var t, o, i;
613
817
  const r = {
614
818
  type: "array"
615
819
  };
616
- return (t = n.type) != null && t._def && ((i = (a = n.type) == null ? void 0 : a._def) == null ? void 0 : i.typeName) !== y.ZodAny && (r.items = k(n.type._def, {
820
+ return (t = a.type) != null && t._def && ((i = (o = a.type) == null ? void 0 : o._def) == null ? void 0 : i.typeName) !== y.ZodAny && (r.items = k(a.type._def, {
617
821
  ...e,
618
822
  currentPath: [...e.currentPath, "items"]
619
- })), n.minLength && T(r, "minItems", n.minLength.value, n.minLength.message, e), n.maxLength && T(r, "maxItems", n.maxLength.value, n.maxLength.message, e), n.exactLength && (T(r, "minItems", n.exactLength.value, n.exactLength.message, e), T(r, "maxItems", n.exactLength.value, n.exactLength.message, e)), r;
823
+ })), a.minLength && S(r, "minItems", a.minLength.value, a.minLength.message, e), a.maxLength && S(r, "maxItems", a.maxLength.value, a.maxLength.message, e), a.exactLength && (S(r, "minItems", a.exactLength.value, a.exactLength.message, e), S(r, "maxItems", a.exactLength.value, a.exactLength.message, e)), r;
620
824
  }
621
- function Ne(n, e) {
825
+ function Qe(a, e) {
622
826
  const r = {
623
827
  type: "integer",
624
828
  format: "int64"
625
829
  };
626
- if (!n.checks)
830
+ if (!a.checks)
627
831
  return r;
628
- for (const t of n.checks)
832
+ for (const t of a.checks)
629
833
  switch (t.kind) {
630
834
  case "min":
631
- e.target === "jsonSchema7" ? t.inclusive ? T(r, "minimum", t.value, t.message, e) : T(r, "exclusiveMinimum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMinimum = !0), T(r, "minimum", t.value, t.message, e));
835
+ e.target === "jsonSchema7" ? t.inclusive ? S(r, "minimum", t.value, t.message, e) : S(r, "exclusiveMinimum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMinimum = !0), S(r, "minimum", t.value, t.message, e));
632
836
  break;
633
837
  case "max":
634
- e.target === "jsonSchema7" ? t.inclusive ? T(r, "maximum", t.value, t.message, e) : T(r, "exclusiveMaximum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMaximum = !0), T(r, "maximum", t.value, t.message, e));
838
+ e.target === "jsonSchema7" ? t.inclusive ? S(r, "maximum", t.value, t.message, e) : S(r, "exclusiveMaximum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMaximum = !0), S(r, "maximum", t.value, t.message, e));
635
839
  break;
636
840
  case "multipleOf":
637
- T(r, "multipleOf", t.value, t.message, e);
841
+ S(r, "multipleOf", t.value, t.message, e);
638
842
  break;
639
843
  }
640
844
  return r;
641
845
  }
642
- function je() {
846
+ function et() {
643
847
  return {
644
848
  type: "boolean"
645
849
  };
646
850
  }
647
- function H(n, e) {
648
- return k(n.type._def, e);
851
+ function re(a, e) {
852
+ return k(a.type._def, e);
649
853
  }
650
- const De = (n, e) => k(n.innerType._def, e);
651
- function X(n, e, r) {
854
+ const tt = (a, e) => k(a.innerType._def, e);
855
+ function ne(a, e, r) {
652
856
  const t = r ?? e.dateStrategy;
653
857
  if (Array.isArray(t))
654
858
  return {
655
- anyOf: t.map((a, i) => X(n, e, a))
859
+ anyOf: t.map((o, i) => ne(a, e, o))
656
860
  };
657
861
  switch (t) {
658
862
  case "string":
@@ -667,20 +871,20 @@ function X(n, e, r) {
667
871
  format: "date"
668
872
  };
669
873
  case "integer":
670
- return Me(n, e);
874
+ return rt(a, e);
671
875
  }
672
876
  }
673
- const Me = (n, e) => {
877
+ const rt = (a, e) => {
674
878
  const r = {
675
879
  type: "integer",
676
880
  format: "unix-time"
677
881
  };
678
882
  if (e.target === "openApi3")
679
883
  return r;
680
- for (const t of n.checks)
884
+ for (const t of a.checks)
681
885
  switch (t.kind) {
682
886
  case "min":
683
- T(
887
+ S(
684
888
  r,
685
889
  "minimum",
686
890
  t.value,
@@ -690,7 +894,7 @@ const Me = (n, e) => {
690
894
  );
691
895
  break;
692
896
  case "max":
693
- T(
897
+ S(
694
898
  r,
695
899
  "maximum",
696
900
  t.value,
@@ -702,38 +906,38 @@ const Me = (n, e) => {
702
906
  }
703
907
  return r;
704
908
  };
705
- function $e(n, e) {
909
+ function nt(a, e) {
706
910
  return {
707
- ...k(n.innerType._def, e),
708
- default: n.defaultValue()
911
+ ...k(a.innerType._def, e),
912
+ default: a.defaultValue()
709
913
  };
710
914
  }
711
- function Le(n, e) {
712
- return e.effectStrategy === "input" ? k(n.schema._def, e) : I(e);
915
+ function at(a, e) {
916
+ return e.effectStrategy === "input" ? k(a.schema._def, e) : x(e);
713
917
  }
714
- function Ce(n) {
918
+ function ot(a) {
715
919
  return {
716
920
  type: "string",
717
- enum: Array.from(n.values)
921
+ enum: Array.from(a.values)
718
922
  };
719
923
  }
720
- const Ue = (n) => "type" in n && n.type === "string" ? !1 : "allOf" in n;
721
- function Ze(n, e) {
924
+ const it = (a) => "type" in a && a.type === "string" ? !1 : "allOf" in a;
925
+ function st(a, e) {
722
926
  const r = [
723
- k(n.left._def, {
927
+ k(a.left._def, {
724
928
  ...e,
725
929
  currentPath: [...e.currentPath, "allOf", "0"]
726
930
  }),
727
- k(n.right._def, {
931
+ k(a.right._def, {
728
932
  ...e,
729
933
  currentPath: [...e.currentPath, "allOf", "1"]
730
934
  })
731
935
  ].filter((i) => !!i);
732
936
  let t = e.target === "jsonSchema2019-09" ? { unevaluatedProperties: !1 } : void 0;
733
- const a = [];
937
+ const o = [];
734
938
  return r.forEach((i) => {
735
- if (Ue(i))
736
- a.push(...i.allOf), i.unevaluatedProperties === void 0 && (t = void 0);
939
+ if (it(i))
940
+ o.push(...i.allOf), i.unevaluatedProperties === void 0 && (t = void 0);
737
941
  else {
738
942
  let s = i;
739
943
  if ("additionalProperties" in i && i.additionalProperties === !1) {
@@ -741,27 +945,27 @@ function Ze(n, e) {
741
945
  s = c;
742
946
  } else
743
947
  t = void 0;
744
- a.push(s);
948
+ o.push(s);
745
949
  }
746
- }), a.length ? {
747
- allOf: a,
950
+ }), o.length ? {
951
+ allOf: o,
748
952
  ...t
749
953
  } : void 0;
750
954
  }
751
- function qe(n, e) {
752
- const r = typeof n.value;
955
+ function ct(a, e) {
956
+ const r = typeof a.value;
753
957
  return r !== "bigint" && r !== "number" && r !== "boolean" && r !== "string" ? {
754
- type: Array.isArray(n.value) ? "array" : "object"
958
+ type: Array.isArray(a.value) ? "array" : "object"
755
959
  } : e.target === "openApi3" ? {
756
960
  type: r === "bigint" ? "integer" : r,
757
- enum: [n.value]
961
+ enum: [a.value]
758
962
  } : {
759
963
  type: r === "bigint" ? "integer" : r,
760
- const: n.value
964
+ const: a.value
761
965
  };
762
966
  }
763
- let Z;
764
- const x = {
967
+ let B;
968
+ const P = {
765
969
  /**
766
970
  * `c` was changed to `[cC]` to replicate /i flag
767
971
  */
@@ -783,7 +987,7 @@ const x = {
783
987
  * Fix in Zod:
784
988
  * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
785
989
  */
786
- emoji: () => (Z === void 0 && (Z = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), Z),
990
+ emoji: () => (B === void 0 && (B = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), B),
787
991
  /**
788
992
  * Unused
789
993
  */
@@ -803,260 +1007,260 @@ const x = {
803
1007
  nanoid: /^[a-zA-Z0-9_-]{21}$/,
804
1008
  jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
805
1009
  };
806
- function Q(n, e) {
1010
+ function ae(a, e) {
807
1011
  const r = {
808
1012
  type: "string"
809
1013
  };
810
- if (n.checks)
811
- for (const t of n.checks)
1014
+ if (a.checks)
1015
+ for (const t of a.checks)
812
1016
  switch (t.kind) {
813
1017
  case "min":
814
- T(r, "minLength", typeof r.minLength == "number" ? Math.max(r.minLength, t.value) : t.value, t.message, e);
1018
+ S(r, "minLength", typeof r.minLength == "number" ? Math.max(r.minLength, t.value) : t.value, t.message, e);
815
1019
  break;
816
1020
  case "max":
817
- T(r, "maxLength", typeof r.maxLength == "number" ? Math.min(r.maxLength, t.value) : t.value, t.message, e);
1021
+ S(r, "maxLength", typeof r.maxLength == "number" ? Math.min(r.maxLength, t.value) : t.value, t.message, e);
818
1022
  break;
819
1023
  case "email":
820
1024
  switch (e.emailStrategy) {
821
1025
  case "format:email":
822
- R(r, "email", t.message, e);
1026
+ j(r, "email", t.message, e);
823
1027
  break;
824
1028
  case "format:idn-email":
825
- R(r, "idn-email", t.message, e);
1029
+ j(r, "idn-email", t.message, e);
826
1030
  break;
827
1031
  case "pattern:zod":
828
- O(r, x.email, t.message, e);
1032
+ O(r, P.email, t.message, e);
829
1033
  break;
830
1034
  }
831
1035
  break;
832
1036
  case "url":
833
- R(r, "uri", t.message, e);
1037
+ j(r, "uri", t.message, e);
834
1038
  break;
835
1039
  case "uuid":
836
- R(r, "uuid", t.message, e);
1040
+ j(r, "uuid", t.message, e);
837
1041
  break;
838
1042
  case "regex":
839
1043
  O(r, t.regex, t.message, e);
840
1044
  break;
841
1045
  case "cuid":
842
- O(r, x.cuid, t.message, e);
1046
+ O(r, P.cuid, t.message, e);
843
1047
  break;
844
1048
  case "cuid2":
845
- O(r, x.cuid2, t.message, e);
1049
+ O(r, P.cuid2, t.message, e);
846
1050
  break;
847
1051
  case "startsWith":
848
- O(r, RegExp(`^${q(t.value, e)}`), t.message, e);
1052
+ O(r, RegExp(`^${J(t.value, e)}`), t.message, e);
849
1053
  break;
850
1054
  case "endsWith":
851
- O(r, RegExp(`${q(t.value, e)}$`), t.message, e);
1055
+ O(r, RegExp(`${J(t.value, e)}$`), t.message, e);
852
1056
  break;
853
1057
  case "datetime":
854
- R(r, "date-time", t.message, e);
1058
+ j(r, "date-time", t.message, e);
855
1059
  break;
856
1060
  case "date":
857
- R(r, "date", t.message, e);
1061
+ j(r, "date", t.message, e);
858
1062
  break;
859
1063
  case "time":
860
- R(r, "time", t.message, e);
1064
+ j(r, "time", t.message, e);
861
1065
  break;
862
1066
  case "duration":
863
- R(r, "duration", t.message, e);
1067
+ j(r, "duration", t.message, e);
864
1068
  break;
865
1069
  case "length":
866
- T(r, "minLength", typeof r.minLength == "number" ? Math.max(r.minLength, t.value) : t.value, t.message, e), T(r, "maxLength", typeof r.maxLength == "number" ? Math.min(r.maxLength, t.value) : t.value, t.message, e);
1070
+ S(r, "minLength", typeof r.minLength == "number" ? Math.max(r.minLength, t.value) : t.value, t.message, e), S(r, "maxLength", typeof r.maxLength == "number" ? Math.min(r.maxLength, t.value) : t.value, t.message, e);
867
1071
  break;
868
1072
  case "includes": {
869
- O(r, RegExp(q(t.value, e)), t.message, e);
1073
+ O(r, RegExp(J(t.value, e)), t.message, e);
870
1074
  break;
871
1075
  }
872
1076
  case "ip": {
873
- t.version !== "v6" && R(r, "ipv4", t.message, e), t.version !== "v4" && R(r, "ipv6", t.message, e);
1077
+ t.version !== "v6" && j(r, "ipv4", t.message, e), t.version !== "v4" && j(r, "ipv6", t.message, e);
874
1078
  break;
875
1079
  }
876
1080
  case "base64url":
877
- O(r, x.base64url, t.message, e);
1081
+ O(r, P.base64url, t.message, e);
878
1082
  break;
879
1083
  case "jwt":
880
- O(r, x.jwt, t.message, e);
1084
+ O(r, P.jwt, t.message, e);
881
1085
  break;
882
1086
  case "cidr": {
883
- t.version !== "v6" && O(r, x.ipv4Cidr, t.message, e), t.version !== "v4" && O(r, x.ipv6Cidr, t.message, e);
1087
+ t.version !== "v6" && O(r, P.ipv4Cidr, t.message, e), t.version !== "v4" && O(r, P.ipv6Cidr, t.message, e);
884
1088
  break;
885
1089
  }
886
1090
  case "emoji":
887
- O(r, x.emoji(), t.message, e);
1091
+ O(r, P.emoji(), t.message, e);
888
1092
  break;
889
1093
  case "ulid": {
890
- O(r, x.ulid, t.message, e);
1094
+ O(r, P.ulid, t.message, e);
891
1095
  break;
892
1096
  }
893
1097
  case "base64": {
894
1098
  switch (e.base64Strategy) {
895
1099
  case "format:binary": {
896
- R(r, "binary", t.message, e);
1100
+ j(r, "binary", t.message, e);
897
1101
  break;
898
1102
  }
899
1103
  case "contentEncoding:base64": {
900
- T(r, "contentEncoding", "base64", t.message, e);
1104
+ S(r, "contentEncoding", "base64", t.message, e);
901
1105
  break;
902
1106
  }
903
1107
  case "pattern:zod": {
904
- O(r, x.base64, t.message, e);
1108
+ O(r, P.base64, t.message, e);
905
1109
  break;
906
1110
  }
907
1111
  }
908
1112
  break;
909
1113
  }
910
1114
  case "nanoid":
911
- O(r, x.nanoid, t.message, e);
1115
+ O(r, P.nanoid, t.message, e);
912
1116
  }
913
1117
  return r;
914
1118
  }
915
- function q(n, e) {
916
- return e.patternStrategy === "escape" ? Je(n) : n;
1119
+ function J(a, e) {
1120
+ return e.patternStrategy === "escape" ? ut(a) : a;
917
1121
  }
918
- const ze = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
919
- function Je(n) {
1122
+ const lt = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
1123
+ function ut(a) {
920
1124
  let e = "";
921
- for (let r = 0; r < n.length; r++)
922
- ze.has(n[r]) || (e += "\\"), e += n[r];
1125
+ for (let r = 0; r < a.length; r++)
1126
+ lt.has(a[r]) || (e += "\\"), e += a[r];
923
1127
  return e;
924
1128
  }
925
- function R(n, e, r, t) {
926
- var a;
927
- n.format || (a = n.anyOf) != null && a.some((i) => i.format) ? (n.anyOf || (n.anyOf = []), n.format && (n.anyOf.push({
928
- format: n.format,
929
- ...n.errorMessage && t.errorMessages && {
930
- errorMessage: { format: n.errorMessage.format }
931
- }
932
- }), delete n.format, n.errorMessage && (delete n.errorMessage.format, Object.keys(n.errorMessage).length === 0 && delete n.errorMessage)), n.anyOf.push({
1129
+ function j(a, e, r, t) {
1130
+ var o;
1131
+ a.format || (o = a.anyOf) != null && o.some((i) => i.format) ? (a.anyOf || (a.anyOf = []), a.format && (a.anyOf.push({
1132
+ format: a.format,
1133
+ ...a.errorMessage && t.errorMessages && {
1134
+ errorMessage: { format: a.errorMessage.format }
1135
+ }
1136
+ }), delete a.format, a.errorMessage && (delete a.errorMessage.format, Object.keys(a.errorMessage).length === 0 && delete a.errorMessage)), a.anyOf.push({
933
1137
  format: e,
934
1138
  ...r && t.errorMessages && { errorMessage: { format: r } }
935
- })) : T(n, "format", e, r, t);
1139
+ })) : S(a, "format", e, r, t);
936
1140
  }
937
- function O(n, e, r, t) {
938
- var a;
939
- n.pattern || (a = n.allOf) != null && a.some((i) => i.pattern) ? (n.allOf || (n.allOf = []), n.pattern && (n.allOf.push({
940
- pattern: n.pattern,
941
- ...n.errorMessage && t.errorMessages && {
942
- errorMessage: { pattern: n.errorMessage.pattern }
943
- }
944
- }), delete n.pattern, n.errorMessage && (delete n.errorMessage.pattern, Object.keys(n.errorMessage).length === 0 && delete n.errorMessage)), n.allOf.push({
945
- pattern: F(e, t),
1141
+ function O(a, e, r, t) {
1142
+ var o;
1143
+ a.pattern || (o = a.allOf) != null && o.some((i) => i.pattern) ? (a.allOf || (a.allOf = []), a.pattern && (a.allOf.push({
1144
+ pattern: a.pattern,
1145
+ ...a.errorMessage && t.errorMessages && {
1146
+ errorMessage: { pattern: a.errorMessage.pattern }
1147
+ }
1148
+ }), delete a.pattern, a.errorMessage && (delete a.errorMessage.pattern, Object.keys(a.errorMessage).length === 0 && delete a.errorMessage)), a.allOf.push({
1149
+ pattern: W(e, t),
946
1150
  ...r && t.errorMessages && { errorMessage: { pattern: r } }
947
- })) : T(n, "pattern", F(e, t), r, t);
1151
+ })) : S(a, "pattern", W(e, t), r, t);
948
1152
  }
949
- function F(n, e) {
1153
+ function W(a, e) {
950
1154
  var c;
951
- if (!e.applyRegexFlags || !n.flags)
952
- return n.source;
1155
+ if (!e.applyRegexFlags || !a.flags)
1156
+ return a.source;
953
1157
  const r = {
954
- i: n.flags.includes("i"),
955
- m: n.flags.includes("m"),
956
- s: n.flags.includes("s")
1158
+ i: a.flags.includes("i"),
1159
+ m: a.flags.includes("m"),
1160
+ s: a.flags.includes("s")
957
1161
  // `.` matches newlines
958
- }, t = r.i ? n.source.toLowerCase() : n.source;
959
- let a = "", i = !1, s = !1, l = !1;
960
- for (let d = 0; d < t.length; d++) {
1162
+ }, t = r.i ? a.source.toLowerCase() : a.source;
1163
+ let o = "", i = !1, s = !1, l = !1;
1164
+ for (let u = 0; u < t.length; u++) {
961
1165
  if (i) {
962
- a += t[d], i = !1;
1166
+ o += t[u], i = !1;
963
1167
  continue;
964
1168
  }
965
1169
  if (r.i) {
966
1170
  if (s) {
967
- if (t[d].match(/[a-z]/)) {
968
- l ? (a += t[d], a += `${t[d - 2]}-${t[d]}`.toUpperCase(), l = !1) : t[d + 1] === "-" && ((c = t[d + 2]) != null && c.match(/[a-z]/)) ? (a += t[d], l = !0) : a += `${t[d]}${t[d].toUpperCase()}`;
1171
+ if (t[u].match(/[a-z]/)) {
1172
+ l ? (o += t[u], o += `${t[u - 2]}-${t[u]}`.toUpperCase(), l = !1) : t[u + 1] === "-" && ((c = t[u + 2]) != null && c.match(/[a-z]/)) ? (o += t[u], l = !0) : o += `${t[u]}${t[u].toUpperCase()}`;
969
1173
  continue;
970
1174
  }
971
- } else if (t[d].match(/[a-z]/)) {
972
- a += `[${t[d]}${t[d].toUpperCase()}]`;
1175
+ } else if (t[u].match(/[a-z]/)) {
1176
+ o += `[${t[u]}${t[u].toUpperCase()}]`;
973
1177
  continue;
974
1178
  }
975
1179
  }
976
1180
  if (r.m) {
977
- if (t[d] === "^") {
978
- a += `(^|(?<=[\r
1181
+ if (t[u] === "^") {
1182
+ o += `(^|(?<=[\r
979
1183
  ]))`;
980
1184
  continue;
981
- } else if (t[d] === "$") {
982
- a += `($|(?=[\r
1185
+ } else if (t[u] === "$") {
1186
+ o += `($|(?=[\r
983
1187
  ]))`;
984
1188
  continue;
985
1189
  }
986
1190
  }
987
- if (r.s && t[d] === ".") {
988
- a += s ? `${t[d]}\r
989
- ` : `[${t[d]}\r
1191
+ if (r.s && t[u] === ".") {
1192
+ o += s ? `${t[u]}\r
1193
+ ` : `[${t[u]}\r
990
1194
  ]`;
991
1195
  continue;
992
1196
  }
993
- a += t[d], t[d] === "\\" ? i = !0 : s && t[d] === "]" ? s = !1 : !s && t[d] === "[" && (s = !0);
1197
+ o += t[u], t[u] === "\\" ? i = !0 : s && t[u] === "]" ? s = !1 : !s && t[u] === "[" && (s = !0);
994
1198
  }
995
1199
  try {
996
- new RegExp(a);
1200
+ new RegExp(o);
997
1201
  } catch {
998
- return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`), n.source;
1202
+ return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`), a.source;
999
1203
  }
1000
- return a;
1204
+ return o;
1001
1205
  }
1002
- function ee(n, e) {
1003
- var t, a, i, s, l, c;
1004
- if (e.target === "openAi" && console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."), e.target === "openApi3" && ((t = n.keyType) == null ? void 0 : t._def.typeName) === y.ZodEnum)
1206
+ function oe(a, e) {
1207
+ var t, o, i, s, l, c;
1208
+ if (e.target === "openAi" && console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."), e.target === "openApi3" && ((t = a.keyType) == null ? void 0 : t._def.typeName) === y.ZodEnum)
1005
1209
  return {
1006
1210
  type: "object",
1007
- required: n.keyType._def.values,
1008
- properties: n.keyType._def.values.reduce((d, u) => ({
1009
- ...d,
1010
- [u]: k(n.valueType._def, {
1211
+ required: a.keyType._def.values,
1212
+ properties: a.keyType._def.values.reduce((u, m) => ({
1213
+ ...u,
1214
+ [m]: k(a.valueType._def, {
1011
1215
  ...e,
1012
- currentPath: [...e.currentPath, "properties", u]
1013
- }) ?? I(e)
1216
+ currentPath: [...e.currentPath, "properties", m]
1217
+ }) ?? x(e)
1014
1218
  }), {}),
1015
1219
  additionalProperties: e.rejectedAdditionalProperties
1016
1220
  };
1017
1221
  const r = {
1018
1222
  type: "object",
1019
- additionalProperties: k(n.valueType._def, {
1223
+ additionalProperties: k(a.valueType._def, {
1020
1224
  ...e,
1021
1225
  currentPath: [...e.currentPath, "additionalProperties"]
1022
1226
  }) ?? e.allowedAdditionalProperties
1023
1227
  };
1024
1228
  if (e.target === "openApi3")
1025
1229
  return r;
1026
- if (((a = n.keyType) == null ? void 0 : a._def.typeName) === y.ZodString && ((i = n.keyType._def.checks) != null && i.length)) {
1027
- const { type: d, ...u } = Q(n.keyType._def, e);
1230
+ if (((o = a.keyType) == null ? void 0 : o._def.typeName) === y.ZodString && ((i = a.keyType._def.checks) != null && i.length)) {
1231
+ const { type: u, ...m } = ae(a.keyType._def, e);
1028
1232
  return {
1029
1233
  ...r,
1030
- propertyNames: u
1234
+ propertyNames: m
1031
1235
  };
1032
1236
  } else {
1033
- if (((s = n.keyType) == null ? void 0 : s._def.typeName) === y.ZodEnum)
1237
+ if (((s = a.keyType) == null ? void 0 : s._def.typeName) === y.ZodEnum)
1034
1238
  return {
1035
1239
  ...r,
1036
1240
  propertyNames: {
1037
- enum: n.keyType._def.values
1241
+ enum: a.keyType._def.values
1038
1242
  }
1039
1243
  };
1040
- if (((l = n.keyType) == null ? void 0 : l._def.typeName) === y.ZodBranded && n.keyType._def.type._def.typeName === y.ZodString && ((c = n.keyType._def.type._def.checks) != null && c.length)) {
1041
- const { type: d, ...u } = H(n.keyType._def, e);
1244
+ if (((l = a.keyType) == null ? void 0 : l._def.typeName) === y.ZodBranded && a.keyType._def.type._def.typeName === y.ZodString && ((c = a.keyType._def.type._def.checks) != null && c.length)) {
1245
+ const { type: u, ...m } = re(a.keyType._def, e);
1042
1246
  return {
1043
1247
  ...r,
1044
- propertyNames: u
1248
+ propertyNames: m
1045
1249
  };
1046
1250
  }
1047
1251
  }
1048
1252
  return r;
1049
1253
  }
1050
- function Be(n, e) {
1254
+ function mt(a, e) {
1051
1255
  if (e.mapStrategy === "record")
1052
- return ee(n, e);
1053
- const r = k(n.keyType._def, {
1256
+ return oe(a, e);
1257
+ const r = k(a.keyType._def, {
1054
1258
  ...e,
1055
1259
  currentPath: [...e.currentPath, "items", "items", "0"]
1056
- }) || I(e), t = k(n.valueType._def, {
1260
+ }) || x(e), t = k(a.valueType._def, {
1057
1261
  ...e,
1058
1262
  currentPath: [...e.currentPath, "items", "items", "1"]
1059
- }) || I(e);
1263
+ }) || x(e);
1060
1264
  return {
1061
1265
  type: "array",
1062
1266
  maxItems: 125,
@@ -1068,168 +1272,168 @@ function Be(n, e) {
1068
1272
  }
1069
1273
  };
1070
1274
  }
1071
- function Ke(n) {
1072
- const e = n.values, t = Object.keys(n.values).filter((i) => typeof e[e[i]] != "number").map((i) => e[i]), a = Array.from(new Set(t.map((i) => typeof i)));
1275
+ function dt(a) {
1276
+ const e = a.values, t = Object.keys(a.values).filter((i) => typeof e[e[i]] != "number").map((i) => e[i]), o = Array.from(new Set(t.map((i) => typeof i)));
1073
1277
  return {
1074
- type: a.length === 1 ? a[0] === "string" ? "string" : "number" : ["string", "number"],
1278
+ type: o.length === 1 ? o[0] === "string" ? "string" : "number" : ["string", "number"],
1075
1279
  enum: t
1076
1280
  };
1077
1281
  }
1078
- function Ve(n) {
1079
- return n.target === "openAi" ? void 0 : {
1080
- not: I({
1081
- ...n,
1082
- currentPath: [...n.currentPath, "not"]
1282
+ function pt(a) {
1283
+ return a.target === "openAi" ? void 0 : {
1284
+ not: x({
1285
+ ...a,
1286
+ currentPath: [...a.currentPath, "not"]
1083
1287
  })
1084
1288
  };
1085
1289
  }
1086
- function Fe(n) {
1087
- return n.target === "openApi3" ? {
1290
+ function gt(a) {
1291
+ return a.target === "openApi3" ? {
1088
1292
  enum: ["null"],
1089
1293
  nullable: !0
1090
1294
  } : {
1091
1295
  type: "null"
1092
1296
  };
1093
1297
  }
1094
- const C = {
1298
+ const Z = {
1095
1299
  ZodString: "string",
1096
1300
  ZodNumber: "number",
1097
1301
  ZodBigInt: "integer",
1098
1302
  ZodBoolean: "boolean",
1099
1303
  ZodNull: "null"
1100
1304
  };
1101
- function Ye(n, e) {
1305
+ function ht(a, e) {
1102
1306
  if (e.target === "openApi3")
1103
- return Y(n, e);
1104
- const r = n.options instanceof Map ? Array.from(n.options.values()) : n.options;
1105
- if (r.every((t) => t._def.typeName in C && (!t._def.checks || !t._def.checks.length))) {
1106
- const t = r.reduce((a, i) => {
1107
- const s = C[i._def.typeName];
1108
- return s && !a.includes(s) ? [...a, s] : a;
1307
+ return H(a, e);
1308
+ const r = a.options instanceof Map ? Array.from(a.options.values()) : a.options;
1309
+ if (r.every((t) => t._def.typeName in Z && (!t._def.checks || !t._def.checks.length))) {
1310
+ const t = r.reduce((o, i) => {
1311
+ const s = Z[i._def.typeName];
1312
+ return s && !o.includes(s) ? [...o, s] : o;
1109
1313
  }, []);
1110
1314
  return {
1111
1315
  type: t.length > 1 ? t : t[0]
1112
1316
  };
1113
1317
  } else if (r.every((t) => t._def.typeName === "ZodLiteral" && !t.description)) {
1114
- const t = r.reduce((a, i) => {
1318
+ const t = r.reduce((o, i) => {
1115
1319
  const s = typeof i._def.value;
1116
1320
  switch (s) {
1117
1321
  case "string":
1118
1322
  case "number":
1119
1323
  case "boolean":
1120
- return [...a, s];
1324
+ return [...o, s];
1121
1325
  case "bigint":
1122
- return [...a, "integer"];
1326
+ return [...o, "integer"];
1123
1327
  case "object":
1124
1328
  if (i._def.value === null)
1125
- return [...a, "null"];
1329
+ return [...o, "null"];
1126
1330
  case "symbol":
1127
1331
  case "undefined":
1128
1332
  case "function":
1129
1333
  default:
1130
- return a;
1334
+ return o;
1131
1335
  }
1132
1336
  }, []);
1133
1337
  if (t.length === r.length) {
1134
- const a = t.filter((i, s, l) => l.indexOf(i) === s);
1338
+ const o = t.filter((i, s, l) => l.indexOf(i) === s);
1135
1339
  return {
1136
- type: a.length > 1 ? a : a[0],
1340
+ type: o.length > 1 ? o : o[0],
1137
1341
  enum: r.reduce((i, s) => i.includes(s._def.value) ? i : [...i, s._def.value], [])
1138
1342
  };
1139
1343
  }
1140
1344
  } else if (r.every((t) => t._def.typeName === "ZodEnum"))
1141
1345
  return {
1142
1346
  type: "string",
1143
- enum: r.reduce((t, a) => [
1347
+ enum: r.reduce((t, o) => [
1144
1348
  ...t,
1145
- ...a._def.values.filter((i) => !t.includes(i))
1349
+ ...o._def.values.filter((i) => !t.includes(i))
1146
1350
  ], [])
1147
1351
  };
1148
- return Y(n, e);
1352
+ return H(a, e);
1149
1353
  }
1150
- const Y = (n, e) => {
1151
- const r = (n.options instanceof Map ? Array.from(n.options.values()) : n.options).map((t, a) => k(t._def, {
1354
+ const H = (a, e) => {
1355
+ const r = (a.options instanceof Map ? Array.from(a.options.values()) : a.options).map((t, o) => k(t._def, {
1152
1356
  ...e,
1153
- currentPath: [...e.currentPath, "anyOf", `${a}`]
1357
+ currentPath: [...e.currentPath, "anyOf", `${o}`]
1154
1358
  })).filter((t) => !!t && (!e.strictUnions || typeof t == "object" && Object.keys(t).length > 0));
1155
1359
  return r.length ? { anyOf: r } : void 0;
1156
1360
  };
1157
- function Ge(n, e) {
1158
- if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(n.innerType._def.typeName) && (!n.innerType._def.checks || !n.innerType._def.checks.length))
1361
+ function ft(a, e) {
1362
+ if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(a.innerType._def.typeName) && (!a.innerType._def.checks || !a.innerType._def.checks.length))
1159
1363
  return e.target === "openApi3" ? {
1160
- type: C[n.innerType._def.typeName],
1364
+ type: Z[a.innerType._def.typeName],
1161
1365
  nullable: !0
1162
1366
  } : {
1163
1367
  type: [
1164
- C[n.innerType._def.typeName],
1368
+ Z[a.innerType._def.typeName],
1165
1369
  "null"
1166
1370
  ]
1167
1371
  };
1168
1372
  if (e.target === "openApi3") {
1169
- const t = k(n.innerType._def, {
1373
+ const t = k(a.innerType._def, {
1170
1374
  ...e,
1171
1375
  currentPath: [...e.currentPath]
1172
1376
  });
1173
1377
  return t && "$ref" in t ? { allOf: [t], nullable: !0 } : t && { ...t, nullable: !0 };
1174
1378
  }
1175
- const r = k(n.innerType._def, {
1379
+ const r = k(a.innerType._def, {
1176
1380
  ...e,
1177
1381
  currentPath: [...e.currentPath, "anyOf", "0"]
1178
1382
  });
1179
1383
  return r && { anyOf: [r, { type: "null" }] };
1180
1384
  }
1181
- function We(n, e) {
1385
+ function yt(a, e) {
1182
1386
  const r = {
1183
1387
  type: "number"
1184
1388
  };
1185
- if (!n.checks)
1389
+ if (!a.checks)
1186
1390
  return r;
1187
- for (const t of n.checks)
1391
+ for (const t of a.checks)
1188
1392
  switch (t.kind) {
1189
1393
  case "int":
1190
- r.type = "integer", G(r, "type", t.message, e);
1394
+ r.type = "integer", ee(r, "type", t.message, e);
1191
1395
  break;
1192
1396
  case "min":
1193
- e.target === "jsonSchema7" ? t.inclusive ? T(r, "minimum", t.value, t.message, e) : T(r, "exclusiveMinimum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMinimum = !0), T(r, "minimum", t.value, t.message, e));
1397
+ e.target === "jsonSchema7" ? t.inclusive ? S(r, "minimum", t.value, t.message, e) : S(r, "exclusiveMinimum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMinimum = !0), S(r, "minimum", t.value, t.message, e));
1194
1398
  break;
1195
1399
  case "max":
1196
- e.target === "jsonSchema7" ? t.inclusive ? T(r, "maximum", t.value, t.message, e) : T(r, "exclusiveMaximum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMaximum = !0), T(r, "maximum", t.value, t.message, e));
1400
+ e.target === "jsonSchema7" ? t.inclusive ? S(r, "maximum", t.value, t.message, e) : S(r, "exclusiveMaximum", t.value, t.message, e) : (t.inclusive || (r.exclusiveMaximum = !0), S(r, "maximum", t.value, t.message, e));
1197
1401
  break;
1198
1402
  case "multipleOf":
1199
- T(r, "multipleOf", t.value, t.message, e);
1403
+ S(r, "multipleOf", t.value, t.message, e);
1200
1404
  break;
1201
1405
  }
1202
1406
  return r;
1203
1407
  }
1204
- function He(n, e) {
1408
+ function bt(a, e) {
1205
1409
  const r = e.target === "openAi", t = {
1206
1410
  type: "object",
1207
1411
  properties: {}
1208
- }, a = [], i = n.shape();
1412
+ }, o = [], i = a.shape();
1209
1413
  for (const l in i) {
1210
1414
  let c = i[l];
1211
1415
  if (c === void 0 || c._def === void 0)
1212
1416
  continue;
1213
- let d = Qe(c);
1214
- d && r && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), d = !1);
1215
- const u = k(c._def, {
1417
+ let u = Et(c);
1418
+ u && r && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), u = !1);
1419
+ const m = k(c._def, {
1216
1420
  ...e,
1217
1421
  currentPath: [...e.currentPath, "properties", l],
1218
1422
  propertyPath: [...e.currentPath, "properties", l]
1219
1423
  });
1220
- u !== void 0 && (t.properties[l] = u, d || a.push(l));
1424
+ m !== void 0 && (t.properties[l] = m, u || o.push(l));
1221
1425
  }
1222
- a.length && (t.required = a);
1223
- const s = Xe(n, e);
1426
+ o.length && (t.required = o);
1427
+ const s = wt(a, e);
1224
1428
  return s !== void 0 && (t.additionalProperties = s), t;
1225
1429
  }
1226
- function Xe(n, e) {
1227
- if (n.catchall._def.typeName !== "ZodNever")
1228
- return k(n.catchall._def, {
1430
+ function wt(a, e) {
1431
+ if (a.catchall._def.typeName !== "ZodNever")
1432
+ return k(a.catchall._def, {
1229
1433
  ...e,
1230
1434
  currentPath: [...e.currentPath, "additionalProperties"]
1231
1435
  });
1232
- switch (n.unknownKeys) {
1436
+ switch (a.unknownKeys) {
1233
1437
  case "passthrough":
1234
1438
  return e.allowedAdditionalProperties;
1235
1439
  case "strict":
@@ -1238,155 +1442,155 @@ function Xe(n, e) {
1238
1442
  return e.removeAdditionalStrategy === "strict" ? e.allowedAdditionalProperties : e.rejectedAdditionalProperties;
1239
1443
  }
1240
1444
  }
1241
- function Qe(n) {
1445
+ function Et(a) {
1242
1446
  try {
1243
- return n.isOptional();
1447
+ return a.isOptional();
1244
1448
  } catch {
1245
1449
  return !0;
1246
1450
  }
1247
1451
  }
1248
- const et = (n, e) => {
1452
+ const At = (a, e) => {
1249
1453
  var t;
1250
1454
  if (e.currentPath.toString() === ((t = e.propertyPath) == null ? void 0 : t.toString()))
1251
- return k(n.innerType._def, e);
1252
- const r = k(n.innerType._def, {
1455
+ return k(a.innerType._def, e);
1456
+ const r = k(a.innerType._def, {
1253
1457
  ...e,
1254
1458
  currentPath: [...e.currentPath, "anyOf", "1"]
1255
1459
  });
1256
1460
  return r ? {
1257
1461
  anyOf: [
1258
1462
  {
1259
- not: I(e)
1463
+ not: x(e)
1260
1464
  },
1261
1465
  r
1262
1466
  ]
1263
- } : I(e);
1264
- }, tt = (n, e) => {
1467
+ } : x(e);
1468
+ }, kt = (a, e) => {
1265
1469
  if (e.pipeStrategy === "input")
1266
- return k(n.in._def, e);
1470
+ return k(a.in._def, e);
1267
1471
  if (e.pipeStrategy === "output")
1268
- return k(n.out._def, e);
1269
- const r = k(n.in._def, {
1472
+ return k(a.out._def, e);
1473
+ const r = k(a.in._def, {
1270
1474
  ...e,
1271
1475
  currentPath: [...e.currentPath, "allOf", "0"]
1272
- }), t = k(n.out._def, {
1476
+ }), t = k(a.out._def, {
1273
1477
  ...e,
1274
1478
  currentPath: [...e.currentPath, "allOf", r ? "1" : "0"]
1275
1479
  });
1276
1480
  return {
1277
- allOf: [r, t].filter((a) => a !== void 0)
1481
+ allOf: [r, t].filter((o) => o !== void 0)
1278
1482
  };
1279
1483
  };
1280
- function rt(n, e) {
1281
- return k(n.type._def, e);
1484
+ function vt(a, e) {
1485
+ return k(a.type._def, e);
1282
1486
  }
1283
- function nt(n, e) {
1487
+ function St(a, e) {
1284
1488
  const t = {
1285
1489
  type: "array",
1286
1490
  uniqueItems: !0,
1287
- items: k(n.valueType._def, {
1491
+ items: k(a.valueType._def, {
1288
1492
  ...e,
1289
1493
  currentPath: [...e.currentPath, "items"]
1290
1494
  })
1291
1495
  };
1292
- return n.minSize && T(t, "minItems", n.minSize.value, n.minSize.message, e), n.maxSize && T(t, "maxItems", n.maxSize.value, n.maxSize.message, e), t;
1496
+ return a.minSize && S(t, "minItems", a.minSize.value, a.minSize.message, e), a.maxSize && S(t, "maxItems", a.maxSize.value, a.maxSize.message, e), t;
1293
1497
  }
1294
- function at(n, e) {
1295
- return n.rest ? {
1498
+ function _t(a, e) {
1499
+ return a.rest ? {
1296
1500
  type: "array",
1297
- minItems: n.items.length,
1298
- items: n.items.map((r, t) => k(r._def, {
1501
+ minItems: a.items.length,
1502
+ items: a.items.map((r, t) => k(r._def, {
1299
1503
  ...e,
1300
1504
  currentPath: [...e.currentPath, "items", `${t}`]
1301
1505
  })).reduce((r, t) => t === void 0 ? r : [...r, t], []),
1302
- additionalItems: k(n.rest._def, {
1506
+ additionalItems: k(a.rest._def, {
1303
1507
  ...e,
1304
1508
  currentPath: [...e.currentPath, "additionalItems"]
1305
1509
  })
1306
1510
  } : {
1307
1511
  type: "array",
1308
- minItems: n.items.length,
1309
- maxItems: n.items.length,
1310
- items: n.items.map((r, t) => k(r._def, {
1512
+ minItems: a.items.length,
1513
+ maxItems: a.items.length,
1514
+ items: a.items.map((r, t) => k(r._def, {
1311
1515
  ...e,
1312
1516
  currentPath: [...e.currentPath, "items", `${t}`]
1313
1517
  })).reduce((r, t) => t === void 0 ? r : [...r, t], [])
1314
1518
  };
1315
1519
  }
1316
- function ot(n) {
1520
+ function Tt(a) {
1317
1521
  return {
1318
- not: I(n)
1522
+ not: x(a)
1319
1523
  };
1320
1524
  }
1321
- function it(n) {
1322
- return I(n);
1525
+ function Ot(a) {
1526
+ return x(a);
1323
1527
  }
1324
- const st = (n, e) => k(n.innerType._def, e), ct = (n, e, r) => {
1528
+ const xt = (a, e) => k(a.innerType._def, e), It = (a, e, r) => {
1325
1529
  switch (e) {
1326
1530
  case y.ZodString:
1327
- return Q(n, r);
1531
+ return ae(a, r);
1328
1532
  case y.ZodNumber:
1329
- return We(n, r);
1533
+ return yt(a, r);
1330
1534
  case y.ZodObject:
1331
- return He(n, r);
1535
+ return bt(a, r);
1332
1536
  case y.ZodBigInt:
1333
- return Ne(n, r);
1537
+ return Qe(a, r);
1334
1538
  case y.ZodBoolean:
1335
- return je();
1539
+ return et();
1336
1540
  case y.ZodDate:
1337
- return X(n, r);
1541
+ return ne(a, r);
1338
1542
  case y.ZodUndefined:
1339
- return ot(r);
1543
+ return Tt(r);
1340
1544
  case y.ZodNull:
1341
- return Fe(r);
1545
+ return gt(r);
1342
1546
  case y.ZodArray:
1343
- return Re(n, r);
1547
+ return Xe(a, r);
1344
1548
  case y.ZodUnion:
1345
1549
  case y.ZodDiscriminatedUnion:
1346
- return Ye(n, r);
1550
+ return ht(a, r);
1347
1551
  case y.ZodIntersection:
1348
- return Ze(n, r);
1552
+ return st(a, r);
1349
1553
  case y.ZodTuple:
1350
- return at(n, r);
1554
+ return _t(a, r);
1351
1555
  case y.ZodRecord:
1352
- return ee(n, r);
1556
+ return oe(a, r);
1353
1557
  case y.ZodLiteral:
1354
- return qe(n, r);
1558
+ return ct(a, r);
1355
1559
  case y.ZodEnum:
1356
- return Ce(n);
1560
+ return ot(a);
1357
1561
  case y.ZodNativeEnum:
1358
- return Ke(n);
1562
+ return dt(a);
1359
1563
  case y.ZodNullable:
1360
- return Ge(n, r);
1564
+ return ft(a, r);
1361
1565
  case y.ZodOptional:
1362
- return et(n, r);
1566
+ return At(a, r);
1363
1567
  case y.ZodMap:
1364
- return Be(n, r);
1568
+ return mt(a, r);
1365
1569
  case y.ZodSet:
1366
- return nt(n, r);
1570
+ return St(a, r);
1367
1571
  case y.ZodLazy:
1368
- return () => n.getter()._def;
1572
+ return () => a.getter()._def;
1369
1573
  case y.ZodPromise:
1370
- return rt(n, r);
1574
+ return vt(a, r);
1371
1575
  case y.ZodNaN:
1372
1576
  case y.ZodNever:
1373
- return Ve(r);
1577
+ return pt(r);
1374
1578
  case y.ZodEffects:
1375
- return Le(n, r);
1579
+ return at(a, r);
1376
1580
  case y.ZodAny:
1377
- return I(r);
1581
+ return x(r);
1378
1582
  case y.ZodUnknown:
1379
- return it(r);
1583
+ return Ot(r);
1380
1584
  case y.ZodDefault:
1381
- return $e(n, r);
1585
+ return nt(a, r);
1382
1586
  case y.ZodBranded:
1383
- return H(n, r);
1587
+ return re(a, r);
1384
1588
  case y.ZodReadonly:
1385
- return st(n, r);
1589
+ return xt(a, r);
1386
1590
  case y.ZodCatch:
1387
- return De(n, r);
1591
+ return tt(a, r);
1388
1592
  case y.ZodPipeline:
1389
- return tt(n, r);
1593
+ return kt(a, r);
1390
1594
  case y.ZodFunction:
1391
1595
  case y.ZodVoid:
1392
1596
  case y.ZodSymbol:
@@ -1396,51 +1600,51 @@ const st = (n, e) => k(n.innerType._def, e), ct = (n, e, r) => {
1396
1600
  })();
1397
1601
  }
1398
1602
  };
1399
- function k(n, e, r = !1) {
1603
+ function k(a, e, r = !1) {
1400
1604
  var l;
1401
- const t = e.seen.get(n);
1605
+ const t = e.seen.get(a);
1402
1606
  if (e.override) {
1403
- const c = (l = e.override) == null ? void 0 : l.call(e, n, e, t, r);
1404
- if (c !== Ie)
1607
+ const c = (l = e.override) == null ? void 0 : l.call(e, a, e, t, r);
1608
+ if (c !== Ge)
1405
1609
  return c;
1406
1610
  }
1407
1611
  if (t && !r) {
1408
- const c = lt(t, e);
1612
+ const c = Pt(t, e);
1409
1613
  if (c !== void 0)
1410
1614
  return c;
1411
1615
  }
1412
- const a = { def: n, path: e.currentPath, jsonSchema: void 0 };
1413
- e.seen.set(n, a);
1414
- const i = ct(n, n.typeName, e), s = typeof i == "function" ? k(i(), e) : i;
1415
- if (s && dt(n, e, s), e.postProcess) {
1416
- const c = e.postProcess(s, n, e);
1417
- return a.jsonSchema = s, c;
1616
+ const o = { def: a, path: e.currentPath, jsonSchema: void 0 };
1617
+ e.seen.set(a, o);
1618
+ const i = It(a, a.typeName, e), s = typeof i == "function" ? k(i(), e) : i;
1619
+ if (s && jt(a, e, s), e.postProcess) {
1620
+ const c = e.postProcess(s, a, e);
1621
+ return o.jsonSchema = s, c;
1418
1622
  }
1419
- return a.jsonSchema = s, s;
1623
+ return o.jsonSchema = s, s;
1420
1624
  }
1421
- const lt = (n, e) => {
1625
+ const Pt = (a, e) => {
1422
1626
  switch (e.$refStrategy) {
1423
1627
  case "root":
1424
- return { $ref: n.path.join("/") };
1628
+ return { $ref: a.path.join("/") };
1425
1629
  case "relative":
1426
- return { $ref: W(e.currentPath, n.path) };
1630
+ return { $ref: te(e.currentPath, a.path) };
1427
1631
  case "none":
1428
1632
  case "seen":
1429
- return n.path.length < e.currentPath.length && n.path.every((r, t) => e.currentPath[t] === r) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`), I(e)) : e.$refStrategy === "seen" ? I(e) : void 0;
1633
+ return a.path.length < e.currentPath.length && a.path.every((r, t) => e.currentPath[t] === r) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`), x(e)) : e.$refStrategy === "seen" ? x(e) : void 0;
1430
1634
  }
1431
- }, dt = (n, e, r) => (n.description && (r.description = n.description, e.markdownDescription && (r.markdownDescription = n.description)), r), ut = (n, e) => {
1432
- const r = xe(e);
1433
- let t = typeof e == "object" && e.definitions ? Object.entries(e.definitions).reduce((c, [d, u]) => ({
1635
+ }, jt = (a, e, r) => (a.description && (r.description = a.description, e.markdownDescription && (r.markdownDescription = a.description)), r), Rt = (a, e) => {
1636
+ const r = He(e);
1637
+ let t = typeof e == "object" && e.definitions ? Object.entries(e.definitions).reduce((c, [u, m]) => ({
1434
1638
  ...c,
1435
- [d]: k(u._def, {
1639
+ [u]: k(m._def, {
1436
1640
  ...r,
1437
- currentPath: [...r.basePath, r.definitionPath, d]
1438
- }, !0) ?? I(r)
1641
+ currentPath: [...r.basePath, r.definitionPath, u]
1642
+ }, !0) ?? x(r)
1439
1643
  }), {}) : void 0;
1440
- const a = typeof e == "string" ? e : (e == null ? void 0 : e.nameStrategy) === "title" || e == null ? void 0 : e.name, i = k(n._def, a === void 0 ? r : {
1644
+ const o = typeof e == "string" ? e : (e == null ? void 0 : e.nameStrategy) === "title" || e == null ? void 0 : e.name, i = k(a._def, o === void 0 ? r : {
1441
1645
  ...r,
1442
- currentPath: [...r.basePath, r.definitionPath, a]
1443
- }, !1) ?? I(r), s = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
1646
+ currentPath: [...r.basePath, r.definitionPath, o]
1647
+ }, !1) ?? x(r), s = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
1444
1648
  s !== void 0 && (i.title = s), r.flags.hasReferencedOpenAiAnyType && (t || (t = {}), t[r.openAiAnyTypeName] || (t[r.openAiAnyTypeName] = {
1445
1649
  // Skipping "object" as no properties can be defined and additionalProperties must be "false"
1446
1650
  type: ["string", "number", "integer", "boolean", "array", "null"],
@@ -1452,52 +1656,52 @@ const lt = (n, e) => {
1452
1656
  ].join("/")
1453
1657
  }
1454
1658
  }));
1455
- const l = a === void 0 ? t ? {
1659
+ const l = o === void 0 ? t ? {
1456
1660
  ...i,
1457
1661
  [r.definitionPath]: t
1458
1662
  } : i : {
1459
1663
  $ref: [
1460
1664
  ...r.$refStrategy === "relative" ? [] : r.basePath,
1461
1665
  r.definitionPath,
1462
- a
1666
+ o
1463
1667
  ].join("/"),
1464
1668
  [r.definitionPath]: {
1465
1669
  ...t,
1466
- [a]: i
1670
+ [o]: i
1467
1671
  }
1468
1672
  };
1469
1673
  return r.target === "jsonSchema7" ? l.$schema = "http://json-schema.org/draft-07/schema#" : (r.target === "jsonSchema2019-09" || r.target === "openAi") && (l.$schema = "https://json-schema.org/draft/2019-09/schema#"), r.target === "openAi" && ("anyOf" in l || "oneOf" in l || "allOf" in l || "type" in l && Array.isArray(l.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), l;
1470
1674
  };
1471
- function It(n) {
1472
- const e = ut(n.parameters, { target: "jsonSchema7", $refStrategy: "none" });
1675
+ function Wt(a) {
1676
+ const e = Rt(a.parameters, { target: "jsonSchema7", $refStrategy: "none" });
1473
1677
  return {
1474
- name: n.name,
1475
- description: n.description,
1678
+ name: a.name,
1679
+ description: a.description,
1476
1680
  parameters: e
1477
1681
  };
1478
1682
  }
1479
- function mt(n) {
1683
+ function Nt(a) {
1480
1684
  const e = /* @__PURE__ */ new Set(["$schema", "additionalProperties", "default"]), r = (t) => Array.isArray(t) ? t.map(r) : t && typeof t == "object" ? Object.fromEntries(
1481
- Object.entries(t).filter(([a]) => !e.has(a)).map(([a, i]) => [a, r(i)])
1685
+ Object.entries(t).filter(([o]) => !e.has(o)).map(([o, i]) => [o, r(i)])
1482
1686
  ) : t;
1483
- return r(n);
1687
+ return r(a);
1484
1688
  }
1485
- class pt {
1689
+ class Dt {
1486
1690
  async *streamChat(e, r, t) {
1487
1691
  var g, h, w, f;
1488
- const { apiKey: a, model: i = "gemini-1.5-flash" } = r;
1489
- if (!a) throw new Error("Gemini API key required");
1692
+ const { apiKey: o, model: i = "gemini-1.5-flash" } = r;
1693
+ if (!o) throw new Error("Gemini API key required");
1490
1694
  const s = e.find((b) => b.role === "system"), l = e.filter((b) => b.role !== "system").map((b) => ({ role: b.role === "assistant" ? "model" : "user", parts: [{ text: b.content }] })), c = t != null && t.length ? [{
1491
1695
  functionDeclarations: t.map((b) => ({
1492
1696
  name: b.name,
1493
1697
  description: b.description,
1494
- parameters: mt(b.parameters)
1698
+ parameters: Nt(b.parameters)
1495
1699
  }))
1496
- }] : void 0, d = await fetch(
1700
+ }] : void 0, u = await fetch(
1497
1701
  `https://generativelanguage.googleapis.com/v1beta/models/${i}:streamGenerateContent?alt=sse`,
1498
1702
  {
1499
1703
  method: "POST",
1500
- headers: { "Content-Type": "application/json", "x-goog-api-key": a },
1704
+ headers: { "Content-Type": "application/json", "x-goog-api-key": o },
1501
1705
  body: JSON.stringify({
1502
1706
  contents: l,
1503
1707
  ...s && { systemInstruction: { parts: [{ text: s.content }] } },
@@ -1505,30 +1709,30 @@ class pt {
1505
1709
  })
1506
1710
  }
1507
1711
  );
1508
- if (!d.ok) {
1509
- const b = await d.text();
1510
- throw new Error(`Gemini Error ${d.status}: ${b}`);
1712
+ if (!u.ok) {
1713
+ const b = await u.text();
1714
+ throw new Error(`Gemini Error ${u.status}: ${b}`);
1511
1715
  }
1512
- const u = (g = d.body) == null ? void 0 : g.getReader();
1513
- if (!u) throw new Error("No response body");
1514
- const m = new TextDecoder();
1716
+ const m = (g = u.body) == null ? void 0 : g.getReader();
1717
+ if (!m) throw new Error("No response body");
1718
+ const d = new TextDecoder();
1515
1719
  let p = "";
1516
1720
  for (; ; ) {
1517
- const { done: b, value: A } = await u.read();
1721
+ const { done: b, value: A } = await m.read();
1518
1722
  if (b) break;
1519
- p += m.decode(A, { stream: !0 });
1520
- const v = p.split(`
1723
+ p += d.decode(A, { stream: !0 });
1724
+ const T = p.split(`
1521
1725
  `);
1522
- p = v.pop() || "";
1523
- for (const E of v) {
1524
- const _ = E.trim();
1525
- if (!(!_ || !_.startsWith("data: ")))
1726
+ p = T.pop() || "";
1727
+ for (const E of T) {
1728
+ const v = E.trim();
1729
+ if (!(!v || !v.startsWith("data: ")))
1526
1730
  try {
1527
- const D = ((f = (w = (h = JSON.parse(_.slice(6)).candidates) == null ? void 0 : h[0]) == null ? void 0 : w.content) == null ? void 0 : f.parts) ?? [];
1528
- for (const j of D)
1529
- j.text && (yield { type: "text-delta", text: j.text }), j.functionCall && (yield {
1731
+ const D = ((f = (w = (h = JSON.parse(v.slice(6)).candidates) == null ? void 0 : h[0]) == null ? void 0 : w.content) == null ? void 0 : f.parts) ?? [];
1732
+ for (const N of D)
1733
+ N.text && (yield { type: "text-delta", text: N.text }), N.functionCall && (yield {
1530
1734
  type: "tool-call",
1531
- toolCall: { name: j.functionCall.name, arguments: j.functionCall.args ?? {} }
1735
+ toolCall: { name: N.functionCall.name, arguments: N.functionCall.args ?? {} }
1532
1736
  });
1533
1737
  } catch {
1534
1738
  }
@@ -1536,12 +1740,12 @@ class pt {
1536
1740
  }
1537
1741
  }
1538
1742
  async generateText(e, r) {
1539
- var c, d, u, m, p;
1540
- const { apiKey: t, model: a = "gemini-1.5-flash", temperature: i = 0.7 } = r;
1743
+ var c, u, m, d, p;
1744
+ const { apiKey: t, model: o = "gemini-1.5-flash", temperature: i = 0.7 } = r;
1541
1745
  if (!t) throw new Error("Gemini API key required");
1542
- if (!a) throw new Error("GeminiAdapter: model is required but was undefined");
1746
+ if (!o) throw new Error("GeminiAdapter: model is required but was undefined");
1543
1747
  const s = await fetch(
1544
- `https://generativelanguage.googleapis.com/v1beta/models/${a}:generateContent`,
1748
+ `https://generativelanguage.googleapis.com/v1beta/models/${o}:generateContent`,
1545
1749
  {
1546
1750
  method: "POST",
1547
1751
  headers: {
@@ -1558,15 +1762,15 @@ class pt {
1558
1762
  const g = await s.text();
1559
1763
  throw new Error(`Gemini Error ${s.status}: ${g}`);
1560
1764
  }
1561
- return ((p = (m = (u = (d = (c = (await s.json()).candidates) == null ? void 0 : c[0]) == null ? void 0 : d.content) == null ? void 0 : u.parts) == null ? void 0 : m[0]) == null ? void 0 : p.text) || "";
1765
+ return ((p = (d = (m = (u = (c = (await s.json()).candidates) == null ? void 0 : c[0]) == null ? void 0 : u.content) == null ? void 0 : m.parts) == null ? void 0 : d[0]) == null ? void 0 : p.text) || "";
1562
1766
  }
1563
1767
  async *streamText(e, r) {
1564
- var d, u, m, p, g, h;
1565
- const { apiKey: t, model: a = "gemini-1.5-flash" } = r;
1768
+ var u, m, d, p, g, h;
1769
+ const { apiKey: t, model: o = "gemini-1.5-flash" } = r;
1566
1770
  if (!t) throw new Error("Gemini API key required");
1567
- if (!a) throw new Error("GeminiAdapter: model is required but was undefined");
1771
+ if (!o) throw new Error("GeminiAdapter: model is required but was undefined");
1568
1772
  const i = await fetch(
1569
- `https://generativelanguage.googleapis.com/v1beta/models/${a}:streamGenerateContent?alt=sse`,
1773
+ `https://generativelanguage.googleapis.com/v1beta/models/${o}:streamGenerateContent?alt=sse`,
1570
1774
  {
1571
1775
  method: "POST",
1572
1776
  headers: {
@@ -1582,7 +1786,7 @@ class pt {
1582
1786
  const w = await i.text();
1583
1787
  throw new Error(`Gemini Error ${i.status}: ${w}`);
1584
1788
  }
1585
- const s = (d = i.body) == null ? void 0 : d.getReader();
1789
+ const s = (u = i.body) == null ? void 0 : u.getReader();
1586
1790
  if (!s) throw new Error("No response body");
1587
1791
  const l = new TextDecoder();
1588
1792
  let c = "";
@@ -1594,11 +1798,11 @@ class pt {
1594
1798
  `);
1595
1799
  c = b.pop() || "";
1596
1800
  for (const A of b) {
1597
- const v = A.trim();
1598
- if (!(!v || !v.startsWith("data: ")))
1801
+ const T = A.trim();
1802
+ if (!(!T || !T.startsWith("data: ")))
1599
1803
  try {
1600
- const _ = (h = (g = (p = (m = (u = JSON.parse(v.slice(6)).candidates) == null ? void 0 : u[0]) == null ? void 0 : m.content) == null ? void 0 : p.parts) == null ? void 0 : g[0]) == null ? void 0 : h.text;
1601
- _ && (yield _);
1804
+ const v = (h = (g = (p = (d = (m = JSON.parse(T.slice(6)).candidates) == null ? void 0 : m[0]) == null ? void 0 : d.content) == null ? void 0 : p.parts) == null ? void 0 : g[0]) == null ? void 0 : h.text;
1805
+ v && (yield v);
1602
1806
  } catch {
1603
1807
  continue;
1604
1808
  }
@@ -1606,9 +1810,9 @@ class pt {
1606
1810
  }
1607
1811
  }
1608
1812
  async generateObject(e, r, t) {
1609
- var d, u, m, p, g;
1610
- const { apiKey: a, model: i = "gemini-1.5-flash" } = t;
1611
- if (!a) throw new Error("Gemini API key required");
1813
+ var u, m, d, p, g;
1814
+ const { apiKey: o, model: i = "gemini-1.5-flash" } = t;
1815
+ if (!o) throw new Error("Gemini API key required");
1612
1816
  if (!i) throw new Error("GeminiAdapter: model is required but was undefined");
1613
1817
  const s = await fetch(
1614
1818
  `https://generativelanguage.googleapis.com/v1beta/models/${i}:generateContent`,
@@ -1616,7 +1820,7 @@ class pt {
1616
1820
  method: "POST",
1617
1821
  headers: {
1618
1822
  "Content-Type": "application/json",
1619
- "x-goog-api-key": a
1823
+ "x-goog-api-key": o
1620
1824
  },
1621
1825
  body: JSON.stringify({
1622
1826
  contents: [{ parts: [{ text: e }] }],
@@ -1631,11 +1835,11 @@ class pt {
1631
1835
  const h = await s.json();
1632
1836
  throw this.normalizeError(h, s.status);
1633
1837
  }
1634
- const c = ((g = (p = (m = (u = (d = (await s.json()).candidates) == null ? void 0 : d[0]) == null ? void 0 : u.content) == null ? void 0 : m.parts) == null ? void 0 : p[0]) == null ? void 0 : g.text) || "{}";
1838
+ const c = ((g = (p = (d = (m = (u = (await s.json()).candidates) == null ? void 0 : u[0]) == null ? void 0 : m.content) == null ? void 0 : d.parts) == null ? void 0 : p[0]) == null ? void 0 : g.text) || "{}";
1635
1839
  return JSON.parse(c);
1636
1840
  }
1637
1841
  async listModels(e) {
1638
- var a;
1842
+ var o;
1639
1843
  if (!e) throw new Error("API key required to list models");
1640
1844
  const r = await fetch(
1641
1845
  "https://generativelanguage.googleapis.com/v1beta/models",
@@ -1645,22 +1849,22 @@ class pt {
1645
1849
  );
1646
1850
  if (!r.ok)
1647
1851
  throw new Error("Failed to fetch model list");
1648
- return ((a = (await r.json()).models) == null ? void 0 : a.map((i) => i.name)) || [];
1852
+ return ((o = (await r.json()).models) == null ? void 0 : o.map((i) => i.name)) || [];
1649
1853
  }
1650
1854
  normalizeError(e, r) {
1651
1855
  var t;
1652
1856
  if (r === 429) {
1653
- const a = new Error("Rate limit exceeded. Please wait 30 seconds before retrying.");
1654
- return a.code = "RATE_LIMIT", a;
1857
+ const o = new Error("Rate limit exceeded. Please wait 30 seconds before retrying.");
1858
+ return o.code = "RATE_LIMIT", o;
1655
1859
  }
1656
1860
  if (r === 401 || r === 403) {
1657
- const a = new Error("Invalid API key.");
1658
- return a.code = "AUTH_ERROR", a;
1861
+ const o = new Error("Invalid API key.");
1862
+ return o.code = "AUTH_ERROR", o;
1659
1863
  }
1660
1864
  return new Error(((t = e.error) == null ? void 0 : t.message) || "Unknown error");
1661
1865
  }
1662
1866
  }
1663
- class gt {
1867
+ class Mt {
1664
1868
  /**
1665
1869
  * Tool calling requires /api/chat, not /api/generate (which has no tool
1666
1870
  * support at all). Tool support itself is model-dependent (llama3.1+,
@@ -1669,8 +1873,8 @@ class gt {
1669
1873
  * this degrades gracefully rather than special-casing it.
1670
1874
  */
1671
1875
  async *streamChat(e, r, t) {
1672
- var m, p, g, h, w;
1673
- const { baseUrl: a = "http://localhost:11434", model: i = "llama3.2" } = r, s = t != null && t.length ? t.map((f) => ({ type: "function", function: { name: f.name, description: f.description, parameters: f.parameters } })) : void 0, l = await fetch(`${a}/api/chat`, {
1876
+ var d, p, g, h, w;
1877
+ const { baseUrl: o = "http://localhost:11434", model: i = "llama3.2" } = r, s = t != null && t.length ? t.map((f) => ({ type: "function", function: { name: f.name, description: f.description, parameters: f.parameters } })) : void 0, l = await fetch(`${o}/api/chat`, {
1674
1878
  method: "POST",
1675
1879
  headers: { "Content-Type": "application/json" },
1676
1880
  body: JSON.stringify({
@@ -1684,27 +1888,27 @@ class gt {
1684
1888
  const f = await l.text();
1685
1889
  throw new Error(`Ollama Error ${l.status}: ${f}`);
1686
1890
  }
1687
- const c = (m = l.body) == null ? void 0 : m.getReader();
1891
+ const c = (d = l.body) == null ? void 0 : d.getReader();
1688
1892
  if (!c) throw new Error("No response body");
1689
- const d = new TextDecoder();
1690
- let u = "";
1893
+ const u = new TextDecoder();
1894
+ let m = "";
1691
1895
  for (; ; ) {
1692
1896
  const { done: f, value: b } = await c.read();
1693
1897
  if (f) break;
1694
- u += d.decode(b, { stream: !0 });
1695
- const A = u.split(`
1898
+ m += u.decode(b, { stream: !0 });
1899
+ const A = m.split(`
1696
1900
  `);
1697
- u = A.pop() || "";
1698
- for (const v of A) {
1699
- const E = v.trim();
1901
+ m = A.pop() || "";
1902
+ for (const T of A) {
1903
+ const E = T.trim();
1700
1904
  if (E)
1701
1905
  try {
1702
- const _ = JSON.parse(E);
1703
- if ((p = _.message) != null && p.content && (yield { type: "text-delta", text: _.message.content }), (g = _.message) != null && g.tool_calls)
1704
- for (const N of _.message.tool_calls)
1906
+ const v = JSON.parse(E);
1907
+ if ((p = v.message) != null && p.content && (yield { type: "text-delta", text: v.message.content }), (g = v.message) != null && g.tool_calls)
1908
+ for (const R of v.message.tool_calls)
1705
1909
  yield {
1706
1910
  type: "tool-call",
1707
- toolCall: { name: (h = N.function) == null ? void 0 : h.name, arguments: ((w = N.function) == null ? void 0 : w.arguments) ?? {} }
1911
+ toolCall: { name: (h = R.function) == null ? void 0 : h.name, arguments: ((w = R.function) == null ? void 0 : w.arguments) ?? {} }
1708
1912
  };
1709
1913
  } catch {
1710
1914
  }
@@ -1712,11 +1916,11 @@ class gt {
1712
1916
  }
1713
1917
  }
1714
1918
  async generateText(e, r) {
1715
- const { baseUrl: t = "http://localhost:11434", model: a = "llama3.2" } = r, i = await fetch(`${t}/api/generate`, {
1919
+ const { baseUrl: t = "http://localhost:11434", model: o = "llama3.2" } = r, i = await fetch(`${t}/api/generate`, {
1716
1920
  method: "POST",
1717
1921
  headers: { "Content-Type": "application/json" },
1718
1922
  body: JSON.stringify({
1719
- model: a,
1923
+ model: o,
1720
1924
  prompt: e,
1721
1925
  stream: !1
1722
1926
  })
@@ -1728,28 +1932,28 @@ class gt {
1728
1932
  return (await i.json()).response;
1729
1933
  }
1730
1934
  async *streamText(e, r) {
1731
- var d;
1732
- const { baseUrl: t = "http://localhost:11434", model: a = "llama3.2" } = r, i = await fetch(`${t}/api/generate`, {
1935
+ var u;
1936
+ const { baseUrl: t = "http://localhost:11434", model: o = "llama3.2" } = r, i = await fetch(`${t}/api/generate`, {
1733
1937
  method: "POST",
1734
1938
  headers: { "Content-Type": "application/json" },
1735
1939
  body: JSON.stringify({
1736
- model: a,
1940
+ model: o,
1737
1941
  prompt: e,
1738
1942
  stream: !0
1739
1943
  })
1740
1944
  });
1741
1945
  if (!i.ok) {
1742
- const u = await i.text();
1743
- throw new Error(`Ollama Error ${i.status}: ${u}`);
1946
+ const m = await i.text();
1947
+ throw new Error(`Ollama Error ${i.status}: ${m}`);
1744
1948
  }
1745
- const s = (d = i.body) == null ? void 0 : d.getReader();
1949
+ const s = (u = i.body) == null ? void 0 : u.getReader();
1746
1950
  if (!s) throw new Error("No response body");
1747
1951
  const l = new TextDecoder();
1748
1952
  let c = "";
1749
1953
  for (; ; ) {
1750
- const { done: u, value: m } = await s.read();
1751
- if (u) break;
1752
- c += l.decode(m, { stream: !0 });
1954
+ const { done: m, value: d } = await s.read();
1955
+ if (m) break;
1956
+ c += l.decode(d, { stream: !0 });
1753
1957
  const p = c.split(`
1754
1958
  `);
1755
1959
  c = p.pop() || "";
@@ -1766,12 +1970,12 @@ class gt {
1766
1970
  }
1767
1971
  }
1768
1972
  async generateObject(e, r, t) {
1769
- const a = `${e}
1973
+ const o = `${e}
1770
1974
 
1771
1975
  IMPORTANT: Return ONLY valid JSON matching this schema:
1772
1976
  ${JSON.stringify(r, null, 2)}
1773
1977
 
1774
- Do not include any explanation, only the raw JSON object.`, i = await this.generateText(a, t), s = i.match(/```json\n?([\s\S]*?)\n?```/) || i.match(/\{[\s\S]*\}/), l = s ? s[1] || s[0] : i;
1978
+ Do not include any explanation, only the raw JSON object.`, i = await this.generateText(o, t), s = i.match(/```json\n?([\s\S]*?)\n?```/) || i.match(/\{[\s\S]*\}/), l = s ? s[1] || s[0] : i;
1775
1979
  return JSON.parse(l.trim());
1776
1980
  }
1777
1981
  async listModels(e, r = "http://localhost:11434") {
@@ -1782,33 +1986,33 @@ Do not include any explanation, only the raw JSON object.`, i = await this.gener
1782
1986
  return ((i = (await t.json()).models) == null ? void 0 : i.map((s) => s.name)) || [];
1783
1987
  }
1784
1988
  }
1785
- class ht {
1989
+ class $t {
1786
1990
  async *streamChat(e, r, t) {
1787
- var b, A, v;
1991
+ var b, A, T;
1788
1992
  const {
1789
- apiKey: a,
1993
+ apiKey: o,
1790
1994
  model: i = "claude-sonnet-4-5-20250929",
1791
1995
  temperature: s = 0.7,
1792
1996
  maxTokens: l = 4096,
1793
1997
  baseUrl: c = "https://api.anthropic.com/v1"
1794
1998
  } = r;
1795
- if (!a) throw new Error("Anthropic API key required");
1796
- const d = e.find((E) => E.role === "system"), u = e.filter((E) => E.role !== "system").map((E) => ({ role: E.role, content: E.content })), m = t != null && t.length ? t.map((E) => ({ name: E.name, description: E.description, input_schema: E.parameters })) : void 0, p = await fetch(`${c}/messages`, {
1999
+ if (!o) throw new Error("Anthropic API key required");
2000
+ const u = e.find((E) => E.role === "system"), m = e.filter((E) => E.role !== "system").map((E) => ({ role: E.role, content: E.content })), d = t != null && t.length ? t.map((E) => ({ name: E.name, description: E.description, input_schema: E.parameters })) : void 0, p = await fetch(`${c}/messages`, {
1797
2001
  method: "POST",
1798
2002
  headers: {
1799
2003
  "Content-Type": "application/json",
1800
- "x-api-key": a,
2004
+ "x-api-key": o,
1801
2005
  "anthropic-version": "2023-06-01",
1802
2006
  "anthropic-dangerous-direct-browser-access": "true"
1803
2007
  },
1804
2008
  body: JSON.stringify({
1805
2009
  model: i,
1806
- messages: u,
1807
- ...d && { system: d.content },
2010
+ messages: m,
2011
+ ...u && { system: u.content },
1808
2012
  max_tokens: l,
1809
2013
  temperature: s,
1810
2014
  stream: !0,
1811
- ...m && { tools: m }
2015
+ ...d && { tools: d }
1812
2016
  })
1813
2017
  });
1814
2018
  if (!p.ok) {
@@ -1820,22 +2024,22 @@ class ht {
1820
2024
  let w = "", f = null;
1821
2025
  try {
1822
2026
  for (; ; ) {
1823
- const { done: E, value: _ } = await g.read();
2027
+ const { done: E, value: v } = await g.read();
1824
2028
  if (E) break;
1825
- w += h.decode(_, { stream: !0 });
1826
- const N = w.split(`
2029
+ w += h.decode(v, { stream: !0 });
2030
+ const R = w.split(`
1827
2031
  `);
1828
- w = N.pop() || "";
1829
- for (const D of N) {
1830
- const j = D.trim();
1831
- if (!(!j || !j.startsWith("data: ")))
2032
+ w = R.pop() || "";
2033
+ for (const D of R) {
2034
+ const N = D.trim();
2035
+ if (!(!N || !N.startsWith("data: ")))
1832
2036
  try {
1833
- const P = JSON.parse(j.slice(6));
1834
- if (P.type === "content_block_start" && ((b = P.content_block) == null ? void 0 : b.type) === "tool_use")
1835
- f = { id: P.content_block.id, name: P.content_block.name, argsBuf: "" };
1836
- else if (P.type === "content_block_delta")
1837
- ((A = P.delta) == null ? void 0 : A.type) === "text_delta" && P.delta.text ? yield { type: "text-delta", text: P.delta.text } : ((v = P.delta) == null ? void 0 : v.type) === "input_json_delta" && f && (f.argsBuf += P.delta.partial_json ?? "");
1838
- else if (P.type === "content_block_stop" && f) {
2037
+ const I = JSON.parse(N.slice(6));
2038
+ if (I.type === "content_block_start" && ((b = I.content_block) == null ? void 0 : b.type) === "tool_use")
2039
+ f = { id: I.content_block.id, name: I.content_block.name, argsBuf: "" };
2040
+ else if (I.type === "content_block_delta")
2041
+ ((A = I.delta) == null ? void 0 : A.type) === "text_delta" && I.delta.text ? yield { type: "text-delta", text: I.delta.text } : ((T = I.delta) == null ? void 0 : T.type) === "input_json_delta" && f && (f.argsBuf += I.delta.partial_json ?? "");
2042
+ else if (I.type === "content_block_stop" && f) {
1839
2043
  try {
1840
2044
  yield {
1841
2045
  type: "tool-call",
@@ -1858,18 +2062,18 @@ class ht {
1858
2062
  }
1859
2063
  }
1860
2064
  async generateText(e, r) {
1861
- var u, m, p;
2065
+ var m, d, p;
1862
2066
  const {
1863
2067
  apiKey: t,
1864
- model: a = "claude-sonnet-4-5-20250929",
2068
+ model: o = "claude-sonnet-4-5-20250929",
1865
2069
  temperature: i = 0.7,
1866
2070
  maxTokens: s = 4096,
1867
2071
  baseUrl: l = "https://api.anthropic.com/v1"
1868
2072
  } = r;
1869
2073
  if (!t) throw new Error("Anthropic API key required");
1870
- if (!a) throw new Error("Model is required but was undefined");
2074
+ if (!o) throw new Error("Model is required but was undefined");
1871
2075
  console.log("🔵 Anthropic Request:", {
1872
- model: a,
2076
+ model: o,
1873
2077
  maxTokens: s,
1874
2078
  temperature: i,
1875
2079
  endpoint: `${l}/messages`,
@@ -1885,7 +2089,7 @@ class ht {
1885
2089
  "anthropic-dangerous-direct-browser-access": "true"
1886
2090
  },
1887
2091
  body: JSON.stringify({
1888
- model: a,
2092
+ model: o,
1889
2093
  messages: [{ role: "user", content: e }],
1890
2094
  max_tokens: s,
1891
2095
  // REQUIRED by Anthropic
@@ -1894,27 +2098,27 @@ class ht {
1894
2098
  });
1895
2099
  if (!c.ok) {
1896
2100
  const g = await c.text();
1897
- console.error("🔴 RAW ANTHROPIC ERROR:", c.status, g), console.error("🔴 Request was made to:", `${l}/messages`), console.error("🔴 Model requested:", a);
2101
+ console.error("🔴 RAW ANTHROPIC ERROR:", c.status, g), console.error("🔴 Request was made to:", `${l}/messages`), console.error("🔴 Model requested:", o);
1898
2102
  try {
1899
2103
  const h = JSON.parse(g);
1900
- throw new Error(`Anthropic ${c.status}: ${((u = h.error) == null ? void 0 : u.message) || JSON.stringify(h)}`);
2104
+ throw new Error(`Anthropic ${c.status}: ${((m = h.error) == null ? void 0 : m.message) || JSON.stringify(h)}`);
1901
2105
  } catch {
1902
2106
  throw new Error(`Anthropic ${c.status}: ${g}`);
1903
2107
  }
1904
2108
  }
1905
- return ((p = (m = (await c.json()).content) == null ? void 0 : m[0]) == null ? void 0 : p.text) || "";
2109
+ return ((p = (d = (await c.json()).content) == null ? void 0 : d[0]) == null ? void 0 : p.text) || "";
1906
2110
  }
1907
2111
  async *streamText(e, r) {
1908
2112
  var p, g;
1909
2113
  const {
1910
2114
  apiKey: t,
1911
- model: a = "claude-sonnet-4-5-20250929",
2115
+ model: o = "claude-sonnet-4-5-20250929",
1912
2116
  temperature: i = 0.7,
1913
2117
  maxTokens: s = 4096,
1914
2118
  baseUrl: l = "https://api.anthropic.com/v1"
1915
2119
  } = r;
1916
2120
  if (!t) throw new Error("Anthropic API key required");
1917
- if (!a) throw new Error("Model is required but was undefined");
2121
+ if (!o) throw new Error("Model is required but was undefined");
1918
2122
  const c = await fetch(`${l}/messages`, {
1919
2123
  method: "POST",
1920
2124
  headers: {
@@ -1924,7 +2128,7 @@ class ht {
1924
2128
  "anthropic-dangerous-direct-browser-access": "true"
1925
2129
  },
1926
2130
  body: JSON.stringify({
1927
- model: a,
2131
+ model: o,
1928
2132
  messages: [{ role: "user", content: e }],
1929
2133
  max_tokens: s,
1930
2134
  // REQUIRED by Anthropic
@@ -1934,7 +2138,7 @@ class ht {
1934
2138
  });
1935
2139
  if (!c.ok) {
1936
2140
  const h = await c.text();
1937
- console.error("🔴 RAW ANTHROPIC STREAM ERROR:", c.status, h), console.error("🔴 Request was made to:", `${l}/messages`), console.error("🔴 Model requested:", a);
2141
+ console.error("🔴 RAW ANTHROPIC STREAM ERROR:", c.status, h), console.error("🔴 Request was made to:", `${l}/messages`), console.error("🔴 Model requested:", o);
1938
2142
  try {
1939
2143
  const w = JSON.parse(h);
1940
2144
  throw new Error(`Anthropic ${c.status}: ${((p = w.error) == null ? void 0 : p.message) || JSON.stringify(w)}`);
@@ -1943,22 +2147,22 @@ class ht {
1943
2147
  }
1944
2148
  }
1945
2149
  if (!c.body) throw new Error("No response body for streaming");
1946
- const d = c.body.getReader(), u = new TextDecoder();
1947
- let m = "";
2150
+ const u = c.body.getReader(), m = new TextDecoder();
2151
+ let d = "";
1948
2152
  try {
1949
2153
  for (; ; ) {
1950
- const { done: h, value: w } = await d.read();
2154
+ const { done: h, value: w } = await u.read();
1951
2155
  if (h) break;
1952
- m += u.decode(w, { stream: !0 });
1953
- const f = m.split(`
2156
+ d += m.decode(w, { stream: !0 });
2157
+ const f = d.split(`
1954
2158
  `);
1955
- m = f.pop() || "";
2159
+ d = f.pop() || "";
1956
2160
  for (const b of f) {
1957
2161
  const A = b.trim();
1958
2162
  if (!A || !A.startsWith("data: ")) continue;
1959
- const v = A.slice(6);
2163
+ const T = A.slice(6);
1960
2164
  try {
1961
- const E = JSON.parse(v);
2165
+ const E = JSON.parse(T);
1962
2166
  E.type === "content_block_delta" && ((g = E.delta) != null && g.text) && (yield E.delta.text);
1963
2167
  } catch {
1964
2168
  continue;
@@ -1966,23 +2170,23 @@ class ht {
1966
2170
  }
1967
2171
  }
1968
2172
  } finally {
1969
- d.releaseLock();
2173
+ u.releaseLock();
1970
2174
  }
1971
2175
  }
1972
2176
  async generateObject(e, r) {
1973
2177
  var h, w, f;
1974
2178
  const {
1975
2179
  apiKey: t,
1976
- model: a = "claude-sonnet-4-5-20250929",
2180
+ model: o = "claude-sonnet-4-5-20250929",
1977
2181
  temperature: i = 0.7,
1978
2182
  maxTokens: s = 4096,
1979
2183
  baseUrl: l = "https://api.anthropic.com/v1"
1980
2184
  } = r;
1981
2185
  if (!t) throw new Error("Anthropic API key required");
1982
- if (!a) throw new Error("Model is required but was undefined");
2186
+ if (!o) throw new Error("Model is required but was undefined");
1983
2187
  const c = `${e}
1984
2188
 
1985
- IMPORTANT: Respond ONLY with valid JSON. No markdown, no explanation, just the JSON object.`, d = await fetch(`${l}/messages`, {
2189
+ IMPORTANT: Respond ONLY with valid JSON. No markdown, no explanation, just the JSON object.`, u = await fetch(`${l}/messages`, {
1986
2190
  method: "POST",
1987
2191
  headers: {
1988
2192
  "Content-Type": "application/json",
@@ -1991,24 +2195,24 @@ IMPORTANT: Respond ONLY with valid JSON. No markdown, no explanation, just the J
1991
2195
  "anthropic-dangerous-direct-browser-access": "true"
1992
2196
  },
1993
2197
  body: JSON.stringify({
1994
- model: a,
2198
+ model: o,
1995
2199
  messages: [{ role: "user", content: c }],
1996
2200
  max_tokens: s,
1997
2201
  // REQUIRED by Anthropic
1998
2202
  temperature: i
1999
2203
  })
2000
2204
  });
2001
- if (!d.ok) {
2002
- const b = await d.text();
2003
- console.error("🔴 RAW ANTHROPIC OBJECT ERROR:", d.status, b), console.error("🔴 Request was made to:", `${l}/messages`), console.error("🔴 Model requested:", a);
2205
+ if (!u.ok) {
2206
+ const b = await u.text();
2207
+ console.error("🔴 RAW ANTHROPIC OBJECT ERROR:", u.status, b), console.error("🔴 Request was made to:", `${l}/messages`), console.error("🔴 Model requested:", o);
2004
2208
  try {
2005
2209
  const A = JSON.parse(b);
2006
- throw new Error(`Anthropic ${d.status}: ${((h = A.error) == null ? void 0 : h.message) || JSON.stringify(A)}`);
2210
+ throw new Error(`Anthropic ${u.status}: ${((h = A.error) == null ? void 0 : h.message) || JSON.stringify(A)}`);
2007
2211
  } catch {
2008
- throw new Error(`Anthropic ${d.status}: ${b}`);
2212
+ throw new Error(`Anthropic ${u.status}: ${b}`);
2009
2213
  }
2010
2214
  }
2011
- const m = ((f = (w = (await d.json()).content) == null ? void 0 : w[0]) == null ? void 0 : f.text) || "{}", p = m.match(/\{[\s\S]*\}/), g = p ? p[0] : m;
2215
+ const d = ((f = (w = (await u.json()).content) == null ? void 0 : w[0]) == null ? void 0 : f.text) || "{}", p = d.match(/\{[\s\S]*\}/), g = p ? p[0] : d;
2012
2216
  return JSON.parse(g);
2013
2217
  }
2014
2218
  async listModels(e, r) {
@@ -2034,30 +2238,30 @@ IMPORTANT: Respond ONLY with valid JSON. No markdown, no explanation, just the J
2034
2238
  const s = new Error(`Bad request: ${t}`);
2035
2239
  return s.code = "INVALID_REQUEST", s.status = 400, s;
2036
2240
  }
2037
- const a = new Error(t);
2038
- return a.code = "API_ERROR", a.status = e, a;
2241
+ const o = new Error(t);
2242
+ return o.code = "API_ERROR", o.status = e, o;
2039
2243
  }
2040
2244
  }
2041
- function L(n) {
2042
- if (!(!n || n.length === 0))
2043
- return n.map((e) => ({
2245
+ function L(a) {
2246
+ if (!(!a || a.length === 0))
2247
+ return a.map((e) => ({
2044
2248
  type: "function",
2045
2249
  function: { name: e.name, description: e.description, parameters: e.parameters }
2046
2250
  }));
2047
2251
  }
2048
- async function* B(n, e, r, t) {
2049
- var d, u, m, p;
2050
- const a = await fetch(n, {
2252
+ async function* V(a, e, r, t) {
2253
+ var u, m, d, p;
2254
+ const o = await fetch(a, {
2051
2255
  method: "POST",
2052
2256
  headers: e,
2053
2257
  body: JSON.stringify(r)
2054
2258
  });
2055
- if (!a.ok) {
2056
- const g = await a.json().catch(() => ({}));
2057
- throw t(a.status, g);
2259
+ if (!o.ok) {
2260
+ const g = await o.json().catch(() => ({}));
2261
+ throw t(o.status, g);
2058
2262
  }
2059
- if (!a.body) throw new Error("No response body for streaming");
2060
- const i = a.body.getReader(), s = new TextDecoder();
2263
+ if (!o.body) throw new Error("No response body for streaming");
2264
+ const i = o.body.getReader(), s = new TextDecoder();
2061
2265
  let l = "";
2062
2266
  const c = /* @__PURE__ */ new Map();
2063
2267
  try {
@@ -2074,12 +2278,12 @@ async function* B(n, e, r, t) {
2074
2278
  const A = b.slice(6);
2075
2279
  if (A !== "[DONE]")
2076
2280
  try {
2077
- const E = (u = (d = JSON.parse(A).choices) == null ? void 0 : d[0]) == null ? void 0 : u.delta;
2281
+ const E = (m = (u = JSON.parse(A).choices) == null ? void 0 : u[0]) == null ? void 0 : m.delta;
2078
2282
  if (!E) continue;
2079
2283
  if (E.content && (yield { type: "text-delta", text: E.content }), E.tool_calls)
2080
- for (const _ of E.tool_calls) {
2081
- const N = _.index ?? 0, D = c.get(N) ?? { name: "", args: "" };
2082
- _.id && (D.id = _.id), (m = _.function) != null && m.name && (D.name += _.function.name), (p = _.function) != null && p.arguments && (D.args += _.function.arguments), c.set(N, D);
2284
+ for (const v of E.tool_calls) {
2285
+ const R = v.index ?? 0, D = c.get(R) ?? { name: "", args: "" };
2286
+ v.id && (D.id = v.id), (d = v.function) != null && d.name && (D.name += v.function.name), (p = v.function) != null && p.arguments && (D.args += v.function.arguments), c.set(R, D);
2083
2287
  }
2084
2288
  } catch {
2085
2289
  }
@@ -2102,19 +2306,19 @@ async function* B(n, e, r, t) {
2102
2306
  } catch {
2103
2307
  }
2104
2308
  }
2105
- function K(n) {
2106
- return n.map((e) => ({ role: e.role, content: e.content }));
2309
+ function Y(a) {
2310
+ return a.map((e) => ({ role: e.role, content: e.content }));
2107
2311
  }
2108
- class ft {
2312
+ class Lt {
2109
2313
  async *streamChat(e, r, t) {
2110
- const { apiKey: a, model: i = "gpt-4o-mini", temperature: s = 0.7, baseUrl: l = "https://api.openai.com/v1" } = r;
2111
- if (!a) throw new Error("OpenAI API key required");
2112
- yield* B(
2314
+ const { apiKey: o, model: i = "gpt-4o-mini", temperature: s = 0.7, baseUrl: l = "https://api.openai.com/v1" } = r;
2315
+ if (!o) throw new Error("OpenAI API key required");
2316
+ yield* V(
2113
2317
  `${l}/chat/completions`,
2114
- { "Content-Type": "application/json", Authorization: `Bearer ${a}` },
2318
+ { "Content-Type": "application/json", Authorization: `Bearer ${o}` },
2115
2319
  {
2116
2320
  model: i,
2117
- messages: K(e),
2321
+ messages: Y(e),
2118
2322
  temperature: s,
2119
2323
  stream: !0,
2120
2324
  ...L(t) && { tools: L(t), tool_choice: "auto" }
@@ -2123,8 +2327,8 @@ class ft {
2123
2327
  );
2124
2328
  }
2125
2329
  async generateText(e, r) {
2126
- var d, u, m;
2127
- const { apiKey: t, model: a = "gpt-4o-mini", temperature: i = 0.7, baseUrl: s = "https://api.openai.com/v1" } = r;
2330
+ var u, m, d;
2331
+ const { apiKey: t, model: o = "gpt-4o-mini", temperature: i = 0.7, baseUrl: s = "https://api.openai.com/v1" } = r;
2128
2332
  if (!t) throw new Error("OpenAI API key required");
2129
2333
  const l = await fetch(`${s}/chat/completions`, {
2130
2334
  method: "POST",
@@ -2133,7 +2337,7 @@ class ft {
2133
2337
  Authorization: `Bearer ${t}`
2134
2338
  },
2135
2339
  body: JSON.stringify({
2136
- model: a,
2340
+ model: o,
2137
2341
  messages: [{ role: "user", content: e }],
2138
2342
  temperature: i
2139
2343
  })
@@ -2142,11 +2346,11 @@ class ft {
2142
2346
  const p = await l.json();
2143
2347
  throw this.normalizeError(l.status, p);
2144
2348
  }
2145
- return ((m = (u = (d = (await l.json()).choices) == null ? void 0 : d[0]) == null ? void 0 : u.message) == null ? void 0 : m.content) || "";
2349
+ return ((d = (m = (u = (await l.json()).choices) == null ? void 0 : u[0]) == null ? void 0 : m.message) == null ? void 0 : d.content) || "";
2146
2350
  }
2147
2351
  async *streamText(e, r) {
2148
- var m, p, g;
2149
- const { apiKey: t, model: a = "gpt-4o-mini", temperature: i = 0.7, baseUrl: s = "https://api.openai.com/v1" } = r;
2352
+ var d, p, g;
2353
+ const { apiKey: t, model: o = "gpt-4o-mini", temperature: i = 0.7, baseUrl: s = "https://api.openai.com/v1" } = r;
2150
2354
  if (!t) throw new Error("OpenAI API key required");
2151
2355
  const l = await fetch(`${s}/chat/completions`, {
2152
2356
  method: "POST",
@@ -2155,7 +2359,7 @@ class ft {
2155
2359
  Authorization: `Bearer ${t}`
2156
2360
  },
2157
2361
  body: JSON.stringify({
2158
- model: a,
2362
+ model: o,
2159
2363
  messages: [{ role: "user", content: e }],
2160
2364
  temperature: i,
2161
2365
  stream: !0
@@ -2166,24 +2370,24 @@ class ft {
2166
2370
  throw this.normalizeError(l.status, h);
2167
2371
  }
2168
2372
  if (!l.body) throw new Error("No response body for streaming");
2169
- const c = l.body.getReader(), d = new TextDecoder();
2170
- let u = "";
2373
+ const c = l.body.getReader(), u = new TextDecoder();
2374
+ let m = "";
2171
2375
  try {
2172
2376
  for (; ; ) {
2173
2377
  const { done: h, value: w } = await c.read();
2174
2378
  if (h) break;
2175
- u += d.decode(w, { stream: !0 });
2176
- const f = u.split(`
2379
+ m += u.decode(w, { stream: !0 });
2380
+ const f = m.split(`
2177
2381
  `);
2178
- u = f.pop() || "";
2382
+ m = f.pop() || "";
2179
2383
  for (const b of f) {
2180
2384
  const A = b.trim();
2181
2385
  if (!A || !A.startsWith("data: ")) continue;
2182
- const v = A.slice(6);
2183
- if (v !== "[DONE]")
2386
+ const T = A.slice(6);
2387
+ if (T !== "[DONE]")
2184
2388
  try {
2185
- const _ = (g = (p = (m = JSON.parse(v).choices) == null ? void 0 : m[0]) == null ? void 0 : p.delta) == null ? void 0 : g.content;
2186
- _ && (yield _);
2389
+ const v = (g = (p = (d = JSON.parse(T).choices) == null ? void 0 : d[0]) == null ? void 0 : p.delta) == null ? void 0 : g.content;
2390
+ v && (yield v);
2187
2391
  } catch {
2188
2392
  }
2189
2393
  }
@@ -2193,14 +2397,14 @@ class ft {
2193
2397
  }
2194
2398
  }
2195
2399
  async generateObject(e, r, t) {
2196
- var m, p, g;
2197
- const { apiKey: a, model: i = "gpt-4o-mini", temperature: s = 0.7, baseUrl: l = "https://api.openai.com/v1" } = t;
2198
- if (!a) throw new Error("OpenAI API key required");
2400
+ var d, p, g;
2401
+ const { apiKey: o, model: i = "gpt-4o-mini", temperature: s = 0.7, baseUrl: l = "https://api.openai.com/v1" } = t;
2402
+ if (!o) throw new Error("OpenAI API key required");
2199
2403
  const c = await fetch(`${l}/chat/completions`, {
2200
2404
  method: "POST",
2201
2405
  headers: {
2202
2406
  "Content-Type": "application/json",
2203
- Authorization: `Bearer ${a}`
2407
+ Authorization: `Bearer ${o}`
2204
2408
  },
2205
2409
  body: JSON.stringify({
2206
2410
  model: i,
@@ -2213,23 +2417,23 @@ class ft {
2213
2417
  const h = await c.json();
2214
2418
  throw this.normalizeError(c.status, h);
2215
2419
  }
2216
- const u = ((g = (p = (m = (await c.json()).choices) == null ? void 0 : m[0]) == null ? void 0 : p.message) == null ? void 0 : g.content) || "{}";
2217
- return JSON.parse(u);
2420
+ const m = ((g = (p = (d = (await c.json()).choices) == null ? void 0 : d[0]) == null ? void 0 : p.message) == null ? void 0 : g.content) || "{}";
2421
+ return JSON.parse(m);
2218
2422
  }
2219
2423
  async listModels(e, r) {
2220
2424
  var s, l;
2221
2425
  const t = r || "https://api.openai.com/v1";
2222
2426
  if (!e) throw new Error("OpenAI API key required");
2223
- const a = await fetch(`${t}/models`, {
2427
+ const o = await fetch(`${t}/models`, {
2224
2428
  headers: {
2225
2429
  Authorization: `Bearer ${e}`
2226
2430
  }
2227
2431
  });
2228
- if (!a.ok) {
2229
- const c = await a.json();
2230
- throw this.normalizeError(a.status, c);
2432
+ if (!o.ok) {
2433
+ const c = await o.json();
2434
+ throw this.normalizeError(o.status, c);
2231
2435
  }
2232
- return ((l = (s = (await a.json()).data) == null ? void 0 : s.filter((c) => c.id.startsWith("gpt-"))) == null ? void 0 : l.map((c) => c.id)) || [];
2436
+ return ((l = (s = (await o.json()).data) == null ? void 0 : s.filter((c) => c.id.startsWith("gpt-"))) == null ? void 0 : l.map((c) => c.id)) || [];
2233
2437
  }
2234
2438
  normalizeError(e, r) {
2235
2439
  var i;
@@ -2242,20 +2446,20 @@ class ft {
2242
2446
  const s = new Error(`Authentication failed: ${t}`);
2243
2447
  return s.code = "AUTH_ERROR", s.status = e, s;
2244
2448
  }
2245
- const a = new Error(t);
2246
- return a.code = "API_ERROR", a.status = e, a;
2449
+ const o = new Error(t);
2450
+ return o.code = "API_ERROR", o.status = e, o;
2247
2451
  }
2248
2452
  }
2249
- class yt {
2453
+ class Ct {
2250
2454
  async *streamChat(e, r, t) {
2251
- const { apiKey: a, model: i = "grok-beta", temperature: s = 0.7, baseUrl: l = "https://api.x.ai/v1" } = r;
2252
- if (!a) throw new Error("Grok API key required");
2253
- yield* B(
2455
+ const { apiKey: o, model: i = "grok-beta", temperature: s = 0.7, baseUrl: l = "https://api.x.ai/v1" } = r;
2456
+ if (!o) throw new Error("Grok API key required");
2457
+ yield* V(
2254
2458
  `${l}/chat/completions`,
2255
- { "Content-Type": "application/json", Authorization: `Bearer ${a}` },
2459
+ { "Content-Type": "application/json", Authorization: `Bearer ${o}` },
2256
2460
  {
2257
2461
  model: i,
2258
- messages: K(e),
2462
+ messages: Y(e),
2259
2463
  temperature: s,
2260
2464
  stream: !0,
2261
2465
  ...L(t) && { tools: L(t), tool_choice: "auto" }
@@ -2264,8 +2468,8 @@ class yt {
2264
2468
  );
2265
2469
  }
2266
2470
  async generateText(e, r) {
2267
- var d, u, m;
2268
- const { apiKey: t, model: a = "grok-beta", temperature: i = 0.7, baseUrl: s = "https://api.x.ai/v1" } = r;
2471
+ var u, m, d;
2472
+ const { apiKey: t, model: o = "grok-beta", temperature: i = 0.7, baseUrl: s = "https://api.x.ai/v1" } = r;
2269
2473
  if (!t) throw new Error("Grok API key required");
2270
2474
  const l = await fetch(`${s}/chat/completions`, {
2271
2475
  method: "POST",
@@ -2274,7 +2478,7 @@ class yt {
2274
2478
  Authorization: `Bearer ${t}`
2275
2479
  },
2276
2480
  body: JSON.stringify({
2277
- model: a,
2481
+ model: o,
2278
2482
  messages: [{ role: "user", content: e }],
2279
2483
  temperature: i
2280
2484
  })
@@ -2283,11 +2487,11 @@ class yt {
2283
2487
  const p = await l.json();
2284
2488
  throw this.normalizeError(l.status, p);
2285
2489
  }
2286
- return ((m = (u = (d = (await l.json()).choices) == null ? void 0 : d[0]) == null ? void 0 : u.message) == null ? void 0 : m.content) || "";
2490
+ return ((d = (m = (u = (await l.json()).choices) == null ? void 0 : u[0]) == null ? void 0 : m.message) == null ? void 0 : d.content) || "";
2287
2491
  }
2288
2492
  async *streamText(e, r) {
2289
- var m, p, g;
2290
- const { apiKey: t, model: a = "grok-beta", temperature: i = 0.7, baseUrl: s = "https://api.x.ai/v1" } = r;
2493
+ var d, p, g;
2494
+ const { apiKey: t, model: o = "grok-beta", temperature: i = 0.7, baseUrl: s = "https://api.x.ai/v1" } = r;
2291
2495
  if (!t) throw new Error("Grok API key required");
2292
2496
  const l = await fetch(`${s}/chat/completions`, {
2293
2497
  method: "POST",
@@ -2296,7 +2500,7 @@ class yt {
2296
2500
  Authorization: `Bearer ${t}`
2297
2501
  },
2298
2502
  body: JSON.stringify({
2299
- model: a,
2503
+ model: o,
2300
2504
  messages: [{ role: "user", content: e }],
2301
2505
  temperature: i,
2302
2506
  stream: !0
@@ -2307,24 +2511,24 @@ class yt {
2307
2511
  throw this.normalizeError(l.status, h);
2308
2512
  }
2309
2513
  if (!l.body) throw new Error("No response body for streaming");
2310
- const c = l.body.getReader(), d = new TextDecoder();
2311
- let u = "";
2514
+ const c = l.body.getReader(), u = new TextDecoder();
2515
+ let m = "";
2312
2516
  try {
2313
2517
  for (; ; ) {
2314
2518
  const { done: h, value: w } = await c.read();
2315
2519
  if (h) break;
2316
- u += d.decode(w, { stream: !0 });
2317
- const f = u.split(`
2520
+ m += u.decode(w, { stream: !0 });
2521
+ const f = m.split(`
2318
2522
  `);
2319
- u = f.pop() || "";
2523
+ m = f.pop() || "";
2320
2524
  for (const b of f) {
2321
2525
  const A = b.trim();
2322
2526
  if (!A || !A.startsWith("data: ")) continue;
2323
- const v = A.slice(6);
2324
- if (v !== "[DONE]")
2527
+ const T = A.slice(6);
2528
+ if (T !== "[DONE]")
2325
2529
  try {
2326
- const _ = (g = (p = (m = JSON.parse(v).choices) == null ? void 0 : m[0]) == null ? void 0 : p.delta) == null ? void 0 : g.content;
2327
- _ && (yield _);
2530
+ const v = (g = (p = (d = JSON.parse(T).choices) == null ? void 0 : d[0]) == null ? void 0 : p.delta) == null ? void 0 : g.content;
2531
+ v && (yield v);
2328
2532
  } catch {
2329
2533
  }
2330
2534
  }
@@ -2335,15 +2539,15 @@ class yt {
2335
2539
  }
2336
2540
  async generateObject(e, r, t) {
2337
2541
  var h, w, f;
2338
- const { apiKey: a, model: i = "grok-beta", temperature: s = 0.7, baseUrl: l = "https://api.x.ai/v1" } = t;
2339
- if (!a) throw new Error("Grok API key required");
2542
+ const { apiKey: o, model: i = "grok-beta", temperature: s = 0.7, baseUrl: l = "https://api.x.ai/v1" } = t;
2543
+ if (!o) throw new Error("Grok API key required");
2340
2544
  const c = `${e}
2341
2545
 
2342
- Respond with valid JSON only.`, d = await fetch(`${l}/chat/completions`, {
2546
+ Respond with valid JSON only.`, u = await fetch(`${l}/chat/completions`, {
2343
2547
  method: "POST",
2344
2548
  headers: {
2345
2549
  "Content-Type": "application/json",
2346
- Authorization: `Bearer ${a}`
2550
+ Authorization: `Bearer ${o}`
2347
2551
  },
2348
2552
  body: JSON.stringify({
2349
2553
  model: i,
@@ -2351,11 +2555,11 @@ Respond with valid JSON only.`, d = await fetch(`${l}/chat/completions`, {
2351
2555
  temperature: s
2352
2556
  })
2353
2557
  });
2354
- if (!d.ok) {
2355
- const b = await d.json();
2356
- throw this.normalizeError(d.status, b);
2558
+ if (!u.ok) {
2559
+ const b = await u.json();
2560
+ throw this.normalizeError(u.status, b);
2357
2561
  }
2358
- const m = ((f = (w = (h = (await d.json()).choices) == null ? void 0 : h[0]) == null ? void 0 : w.message) == null ? void 0 : f.content) || "{}", p = m.match(/\{[\s\S]*\}/), g = p ? p[0] : m;
2562
+ const d = ((f = (w = (h = (await u.json()).choices) == null ? void 0 : h[0]) == null ? void 0 : w.message) == null ? void 0 : f.content) || "{}", p = d.match(/\{[\s\S]*\}/), g = p ? p[0] : d;
2359
2563
  return JSON.parse(g);
2360
2564
  }
2361
2565
  async listModels(e, r) {
@@ -2372,20 +2576,20 @@ Respond with valid JSON only.`, d = await fetch(`${l}/chat/completions`, {
2372
2576
  const s = new Error(`Authentication failed: ${t}`);
2373
2577
  return s.code = "AUTH_ERROR", s.status = e, s;
2374
2578
  }
2375
- const a = new Error(t);
2376
- return a.code = "API_ERROR", a.status = e, a;
2579
+ const o = new Error(t);
2580
+ return o.code = "API_ERROR", o.status = e, o;
2377
2581
  }
2378
2582
  }
2379
- class bt {
2583
+ class Ut {
2380
2584
  async *streamChat(e, r, t) {
2381
- const { apiKey: a, model: i = "deepseek-chat", temperature: s = 0.7, baseUrl: l = "https://api.deepseek.com/v1" } = r;
2382
- if (!a) throw new Error("DeepSeek API key required");
2383
- yield* B(
2585
+ const { apiKey: o, model: i = "deepseek-chat", temperature: s = 0.7, baseUrl: l = "https://api.deepseek.com/v1" } = r;
2586
+ if (!o) throw new Error("DeepSeek API key required");
2587
+ yield* V(
2384
2588
  `${l}/chat/completions`,
2385
- { "Content-Type": "application/json", Authorization: `Bearer ${a}` },
2589
+ { "Content-Type": "application/json", Authorization: `Bearer ${o}` },
2386
2590
  {
2387
2591
  model: i,
2388
- messages: K(e),
2592
+ messages: Y(e),
2389
2593
  temperature: s,
2390
2594
  stream: !0,
2391
2595
  ...L(t) && { tools: L(t), tool_choice: "auto" }
@@ -2394,8 +2598,8 @@ class bt {
2394
2598
  );
2395
2599
  }
2396
2600
  async generateText(e, r) {
2397
- var d, u, m;
2398
- const { apiKey: t, model: a = "deepseek-chat", temperature: i = 0.7, baseUrl: s = "https://api.deepseek.com/v1" } = r;
2601
+ var u, m, d;
2602
+ const { apiKey: t, model: o = "deepseek-chat", temperature: i = 0.7, baseUrl: s = "https://api.deepseek.com/v1" } = r;
2399
2603
  if (!t) throw new Error("DeepSeek API key required");
2400
2604
  const l = await fetch(`${s}/chat/completions`, {
2401
2605
  method: "POST",
@@ -2404,7 +2608,7 @@ class bt {
2404
2608
  Authorization: `Bearer ${t}`
2405
2609
  },
2406
2610
  body: JSON.stringify({
2407
- model: a,
2611
+ model: o,
2408
2612
  messages: [{ role: "user", content: e }],
2409
2613
  temperature: i
2410
2614
  })
@@ -2413,11 +2617,11 @@ class bt {
2413
2617
  const p = await l.json();
2414
2618
  throw this.normalizeError(l.status, p);
2415
2619
  }
2416
- return ((m = (u = (d = (await l.json()).choices) == null ? void 0 : d[0]) == null ? void 0 : u.message) == null ? void 0 : m.content) || "";
2620
+ return ((d = (m = (u = (await l.json()).choices) == null ? void 0 : u[0]) == null ? void 0 : m.message) == null ? void 0 : d.content) || "";
2417
2621
  }
2418
2622
  async *streamText(e, r) {
2419
- var m, p, g;
2420
- const { apiKey: t, model: a = "deepseek-chat", temperature: i = 0.7, baseUrl: s = "https://api.deepseek.com/v1" } = r;
2623
+ var d, p, g;
2624
+ const { apiKey: t, model: o = "deepseek-chat", temperature: i = 0.7, baseUrl: s = "https://api.deepseek.com/v1" } = r;
2421
2625
  if (!t) throw new Error("DeepSeek API key required");
2422
2626
  const l = await fetch(`${s}/chat/completions`, {
2423
2627
  method: "POST",
@@ -2426,7 +2630,7 @@ class bt {
2426
2630
  Authorization: `Bearer ${t}`
2427
2631
  },
2428
2632
  body: JSON.stringify({
2429
- model: a,
2633
+ model: o,
2430
2634
  messages: [{ role: "user", content: e }],
2431
2635
  temperature: i,
2432
2636
  stream: !0
@@ -2437,24 +2641,24 @@ class bt {
2437
2641
  throw this.normalizeError(l.status, h);
2438
2642
  }
2439
2643
  if (!l.body) throw new Error("No response body for streaming");
2440
- const c = l.body.getReader(), d = new TextDecoder();
2441
- let u = "";
2644
+ const c = l.body.getReader(), u = new TextDecoder();
2645
+ let m = "";
2442
2646
  try {
2443
2647
  for (; ; ) {
2444
2648
  const { done: h, value: w } = await c.read();
2445
2649
  if (h) break;
2446
- u += d.decode(w, { stream: !0 });
2447
- const f = u.split(`
2650
+ m += u.decode(w, { stream: !0 });
2651
+ const f = m.split(`
2448
2652
  `);
2449
- u = f.pop() || "";
2653
+ m = f.pop() || "";
2450
2654
  for (const b of f) {
2451
2655
  const A = b.trim();
2452
2656
  if (!A || !A.startsWith("data: ")) continue;
2453
- const v = A.slice(6);
2454
- if (v !== "[DONE]")
2657
+ const T = A.slice(6);
2658
+ if (T !== "[DONE]")
2455
2659
  try {
2456
- const _ = (g = (p = (m = JSON.parse(v).choices) == null ? void 0 : m[0]) == null ? void 0 : p.delta) == null ? void 0 : g.content;
2457
- _ && (yield _);
2660
+ const v = (g = (p = (d = JSON.parse(T).choices) == null ? void 0 : d[0]) == null ? void 0 : p.delta) == null ? void 0 : g.content;
2661
+ v && (yield v);
2458
2662
  } catch {
2459
2663
  }
2460
2664
  }
@@ -2464,14 +2668,14 @@ class bt {
2464
2668
  }
2465
2669
  }
2466
2670
  async generateObject(e, r, t) {
2467
- var m, p, g;
2468
- const { apiKey: a, model: i = "deepseek-chat", temperature: s = 0.7, baseUrl: l = "https://api.deepseek.com/v1" } = t;
2469
- if (!a) throw new Error("DeepSeek API key required");
2671
+ var d, p, g;
2672
+ const { apiKey: o, model: i = "deepseek-chat", temperature: s = 0.7, baseUrl: l = "https://api.deepseek.com/v1" } = t;
2673
+ if (!o) throw new Error("DeepSeek API key required");
2470
2674
  const c = await fetch(`${l}/chat/completions`, {
2471
2675
  method: "POST",
2472
2676
  headers: {
2473
2677
  "Content-Type": "application/json",
2474
- Authorization: `Bearer ${a}`
2678
+ Authorization: `Bearer ${o}`
2475
2679
  },
2476
2680
  body: JSON.stringify({
2477
2681
  model: i,
@@ -2484,8 +2688,8 @@ class bt {
2484
2688
  const h = await c.json();
2485
2689
  throw this.normalizeError(c.status, h);
2486
2690
  }
2487
- const u = ((g = (p = (m = (await c.json()).choices) == null ? void 0 : m[0]) == null ? void 0 : p.message) == null ? void 0 : g.content) || "{}";
2488
- return JSON.parse(u);
2691
+ const m = ((g = (p = (d = (await c.json()).choices) == null ? void 0 : d[0]) == null ? void 0 : p.message) == null ? void 0 : g.content) || "{}";
2692
+ return JSON.parse(m);
2489
2693
  }
2490
2694
  async listModels(e, r) {
2491
2695
  return ["deepseek-chat", "deepseek-coder"];
@@ -2501,11 +2705,11 @@ class bt {
2501
2705
  const s = new Error(`Authentication failed: ${t}`);
2502
2706
  return s.code = "AUTH_ERROR", s.status = e, s;
2503
2707
  }
2504
- const a = new Error(t);
2505
- return a.code = "API_ERROR", a.status = e, a;
2708
+ const o = new Error(t);
2709
+ return o.code = "API_ERROR", o.status = e, o;
2506
2710
  }
2507
2711
  }
2508
- let wt = class {
2712
+ let Zt = class {
2509
2713
  constructor(e) {
2510
2714
  this.requests = [], this.config = e;
2511
2715
  }
@@ -2523,16 +2727,16 @@ let wt = class {
2523
2727
  };
2524
2728
  class $ {
2525
2729
  constructor() {
2526
- this.rateLimiter = new wt({
2730
+ this.rateLimiter = new Zt({
2527
2731
  maxRequests: 10,
2528
2732
  windowMs: 6e4
2529
2733
  }), this.adapters = /* @__PURE__ */ new Map([
2530
- ["google-gemini", new pt()],
2531
- ["ollama", new gt()],
2532
- ["anthropic", new ht()],
2533
- ["openai", new ft()],
2534
- ["grok", new yt()],
2535
- ["deepseek", new bt()]
2734
+ ["google-gemini", new Dt()],
2735
+ ["ollama", new Mt()],
2736
+ ["anthropic", new $t()],
2737
+ ["openai", new Lt()],
2738
+ ["grok", new Ct()],
2739
+ ["deepseek", new Ut()]
2536
2740
  ]);
2537
2741
  }
2538
2742
  static getInstance() {
@@ -2543,16 +2747,16 @@ class $ {
2543
2747
  */
2544
2748
  async generateText(e, r) {
2545
2749
  if (!this.rateLimiter.checkLimit()) {
2546
- const a = this.rateLimiter.getResetTime(), i = new Error("Rate limit exceeded. Please wait before making another request.");
2547
- throw i.code = "RATE_LIMIT_EXCEEDED", i.resetTime = a, i;
2750
+ const o = this.rateLimiter.getResetTime(), i = new Error("Rate limit exceeded. Please wait before making another request.");
2751
+ throw i.code = "RATE_LIMIT_EXCEEDED", i.resetTime = o, i;
2548
2752
  }
2549
2753
  const t = this.adapters.get(r.provider);
2550
2754
  if (!t)
2551
2755
  throw new Error(`Provider ${r.provider} not supported yet.`);
2552
2756
  try {
2553
2757
  return await t.generateText(e, r);
2554
- } catch (a) {
2555
- throw console.error("[AiGateway] Error:", a), a;
2758
+ } catch (o) {
2759
+ throw console.error("[AiGateway] Error:", o), o;
2556
2760
  }
2557
2761
  }
2558
2762
  /**
@@ -2560,8 +2764,8 @@ class $ {
2560
2764
  */
2561
2765
  async *streamText(e, r) {
2562
2766
  if (!this.rateLimiter.checkLimit()) {
2563
- const a = new Error("Rate limit exceeded");
2564
- throw a.code = "RATE_LIMIT_EXCEEDED", a;
2767
+ const o = new Error("Rate limit exceeded");
2768
+ throw o.code = "RATE_LIMIT_EXCEEDED", o;
2565
2769
  }
2566
2770
  const t = this.adapters.get(r.provider);
2567
2771
  if (!t)
@@ -2577,12 +2781,12 @@ class $ {
2577
2781
  const i = new Error("Rate limit exceeded");
2578
2782
  throw i.code = "RATE_LIMIT_EXCEEDED", i;
2579
2783
  }
2580
- const a = this.adapters.get(r.provider);
2581
- if (!a)
2784
+ const o = this.adapters.get(r.provider);
2785
+ if (!o)
2582
2786
  throw new Error(`Provider ${r.provider} not supported yet.`);
2583
- if (!a.streamChat)
2787
+ if (!o.streamChat)
2584
2788
  throw new Error(`Provider ${r.provider} does not implement native chat streaming yet.`);
2585
- yield* a.streamChat(e, r, t);
2789
+ yield* o.streamChat(e, r, t);
2586
2790
  }
2587
2791
  /**
2588
2792
  * Generate structured object (JSON mode)
@@ -2592,10 +2796,10 @@ class $ {
2592
2796
  const i = new Error("Rate limit exceeded");
2593
2797
  throw i.code = "RATE_LIMIT_EXCEEDED", i;
2594
2798
  }
2595
- const a = this.adapters.get(t.provider);
2596
- if (!a)
2799
+ const o = this.adapters.get(t.provider);
2800
+ if (!o)
2597
2801
  throw new Error(`Provider ${t.provider} not supported yet.`);
2598
- return a.generateObject(e, r, t);
2802
+ return o.generateObject(e, r, t);
2599
2803
  }
2600
2804
  /**
2601
2805
  * Get remaining requests before rate limit
@@ -2607,14 +2811,14 @@ class $ {
2607
2811
  * List available models for a provider
2608
2812
  */
2609
2813
  async listModels(e, r, t) {
2610
- const a = this.adapters.get(e);
2611
- if (!a)
2814
+ const o = this.adapters.get(e);
2815
+ if (!o)
2612
2816
  throw new Error(`Provider ${e} not supported yet.`);
2613
- return a.listModels(r, t);
2817
+ return o.listModels(r, t);
2614
2818
  }
2615
2819
  }
2616
- const xt = $.getInstance(), M = {};
2617
- class Rt {
2820
+ const Xt = $.getInstance(), M = {};
2821
+ class Qt {
2618
2822
  /**
2619
2823
  * Resolve configuration with 3-tier priority:
2620
2824
  * 1. User's localStorage override (highest priority)
@@ -2622,12 +2826,12 @@ class Rt {
2622
2826
  * 3. System defaults (fallback)
2623
2827
  */
2624
2828
  static resolve(e, r) {
2625
- const t = (e == null ? void 0 : e.provider) || (r == null ? void 0 : r.provider) || "ollama", a = (e == null ? void 0 : e.model) || (r == null ? void 0 : r.model) || this.getDefaultModel(t), i = (e == null ? void 0 : e.apiKey) || (r == null ? void 0 : r.apiKey), s = (e == null ? void 0 : e.ollamaUrl) || (r == null ? void 0 : r.ollamaUrl) || "/ollama";
2829
+ const t = (e == null ? void 0 : e.provider) || (r == null ? void 0 : r.provider) || "ollama", o = (e == null ? void 0 : e.model) || (r == null ? void 0 : r.model) || this.getDefaultModel(t), i = (e == null ? void 0 : e.apiKey) || (r == null ? void 0 : r.apiKey), s = (e == null ? void 0 : e.ollamaUrl) || (r == null ? void 0 : r.ollamaUrl) || "/ollama";
2626
2830
  if (t !== "ollama" && !i)
2627
2831
  throw new Error(`API key required for provider: ${t}`);
2628
2832
  return {
2629
2833
  provider: t,
2630
- model: a,
2834
+ model: o,
2631
2835
  apiKey: i,
2632
2836
  baseUrl: t === "ollama" ? s : void 0
2633
2837
  };
@@ -2659,21 +2863,21 @@ class Rt {
2659
2863
  * Never call this from UI components; use hasEnvKey() for status badges.
2660
2864
  */
2661
2865
  static getEnvKeyForProvider(e) {
2662
- var t, a, i, s, l;
2866
+ var t, o, i, s, l;
2663
2867
  if (typeof import.meta < "u" && M) {
2664
- const c = M, d = (m) => (m == null ? void 0 : m.trim()) || void 0;
2868
+ const c = M, u = (d) => (d == null ? void 0 : d.trim()) || void 0;
2665
2869
  return {
2666
- "google-gemini": d(c == null ? void 0 : c.VITE_DEFAULT_GEMINI_KEY),
2667
- openai: d(c == null ? void 0 : c.VITE_DEFAULT_OPENAI_KEY),
2668
- anthropic: d(c == null ? void 0 : c.VITE_DEFAULT_ANTHROPIC_KEY),
2669
- grok: d(c == null ? void 0 : c.VITE_DEFAULT_GROK_KEY),
2670
- deepseek: d(c == null ? void 0 : c.VITE_DEFAULT_DEEPSEEK_KEY)
2870
+ "google-gemini": u(c == null ? void 0 : c.VITE_DEFAULT_GEMINI_KEY),
2871
+ openai: u(c == null ? void 0 : c.VITE_DEFAULT_OPENAI_KEY),
2872
+ anthropic: u(c == null ? void 0 : c.VITE_DEFAULT_ANTHROPIC_KEY),
2873
+ grok: u(c == null ? void 0 : c.VITE_DEFAULT_GROK_KEY),
2874
+ deepseek: u(c == null ? void 0 : c.VITE_DEFAULT_DEEPSEEK_KEY)
2671
2875
  }[e];
2672
2876
  }
2673
2877
  if (typeof process < "u" && process.env)
2674
2878
  return {
2675
2879
  "google-gemini": (t = process.env.VITE_DEFAULT_GEMINI_KEY) == null ? void 0 : t.trim(),
2676
- openai: (a = process.env.VITE_DEFAULT_OPENAI_KEY) == null ? void 0 : a.trim(),
2880
+ openai: (o = process.env.VITE_DEFAULT_OPENAI_KEY) == null ? void 0 : o.trim(),
2677
2881
  anthropic: (i = process.env.VITE_DEFAULT_ANTHROPIC_KEY) == null ? void 0 : i.trim(),
2678
2882
  grok: (s = process.env.VITE_DEFAULT_GROK_KEY) == null ? void 0 : s.trim(),
2679
2883
  deepseek: (l = process.env.VITE_DEFAULT_DEEPSEEK_KEY) == null ? void 0 : l.trim()
@@ -2685,13 +2889,13 @@ class Rt {
2685
2889
  */
2686
2890
  static hasEnvKey(e) {
2687
2891
  if (typeof import.meta < "u" && M) {
2688
- const t = M, a = (s) => (s == null ? void 0 : s.trim()) || void 0;
2892
+ const t = M, o = (s) => (s == null ? void 0 : s.trim()) || void 0;
2689
2893
  return !!{
2690
- "google-gemini": a(t == null ? void 0 : t.VITE_DEFAULT_GEMINI_KEY),
2691
- openai: a(t == null ? void 0 : t.VITE_DEFAULT_OPENAI_KEY),
2692
- anthropic: a(t == null ? void 0 : t.VITE_DEFAULT_ANTHROPIC_KEY),
2693
- grok: a(t == null ? void 0 : t.VITE_DEFAULT_GROK_KEY),
2694
- deepseek: a(t == null ? void 0 : t.VITE_DEFAULT_DEEPSEEK_KEY)
2894
+ "google-gemini": o(t == null ? void 0 : t.VITE_DEFAULT_GEMINI_KEY),
2895
+ openai: o(t == null ? void 0 : t.VITE_DEFAULT_OPENAI_KEY),
2896
+ anthropic: o(t == null ? void 0 : t.VITE_DEFAULT_ANTHROPIC_KEY),
2897
+ grok: o(t == null ? void 0 : t.VITE_DEFAULT_GROK_KEY),
2898
+ deepseek: o(t == null ? void 0 : t.VITE_DEFAULT_DEEPSEEK_KEY)
2695
2899
  }[e];
2696
2900
  }
2697
2901
  return typeof process < "u" && process.env ? !!{
@@ -2707,20 +2911,20 @@ class Rt {
2707
2911
  static loadAppDefaults() {
2708
2912
  var r, t;
2709
2913
  if (typeof import.meta < "u" && M) {
2710
- const a = M, i = (a == null ? void 0 : a.VITE_DEFAULT_AI_PROVIDER) || "", s = (m) => (m == null ? void 0 : m.trim()) || void 0, l = {
2711
- "google-gemini": s(a == null ? void 0 : a.VITE_DEFAULT_GEMINI_KEY),
2712
- openai: s(a == null ? void 0 : a.VITE_DEFAULT_OPENAI_KEY),
2713
- anthropic: s(a == null ? void 0 : a.VITE_DEFAULT_ANTHROPIC_KEY),
2714
- grok: s(a == null ? void 0 : a.VITE_DEFAULT_GROK_KEY),
2715
- deepseek: s(a == null ? void 0 : a.VITE_DEFAULT_DEEPSEEK_KEY)
2914
+ const o = M, i = (o == null ? void 0 : o.VITE_DEFAULT_AI_PROVIDER) || "", s = (d) => (d == null ? void 0 : d.trim()) || void 0, l = {
2915
+ "google-gemini": s(o == null ? void 0 : o.VITE_DEFAULT_GEMINI_KEY),
2916
+ openai: s(o == null ? void 0 : o.VITE_DEFAULT_OPENAI_KEY),
2917
+ anthropic: s(o == null ? void 0 : o.VITE_DEFAULT_ANTHROPIC_KEY),
2918
+ grok: s(o == null ? void 0 : o.VITE_DEFAULT_GROK_KEY),
2919
+ deepseek: s(o == null ? void 0 : o.VITE_DEFAULT_DEEPSEEK_KEY)
2716
2920
  };
2717
2921
  let c = i || "ollama";
2718
- const u = ["google-gemini", "anthropic", "openai", "grok", "deepseek"].filter((m) => !!l[m]);
2719
- return c === "ollama" && u.length > 0 && (c = u[0]), {
2922
+ const m = ["google-gemini", "anthropic", "openai", "grok", "deepseek"].filter((d) => !!l[d]);
2923
+ return c === "ollama" && m.length > 0 && (c = m[0]), {
2720
2924
  provider: c,
2721
- model: a == null ? void 0 : a.VITE_DEFAULT_AI_MODEL,
2925
+ model: o == null ? void 0 : o.VITE_DEFAULT_AI_MODEL,
2722
2926
  apiKey: l[c],
2723
- ollamaUrl: a == null ? void 0 : a.VITE_DEFAULT_OLLAMA_URL
2927
+ ollamaUrl: o == null ? void 0 : o.VITE_DEFAULT_OLLAMA_URL
2724
2928
  };
2725
2929
  }
2726
2930
  return typeof process < "u" && process.env ? {
@@ -2729,7 +2933,7 @@ class Rt {
2729
2933
  } : {};
2730
2934
  }
2731
2935
  }
2732
- class Et {
2936
+ class qt {
2733
2937
  constructor(e) {
2734
2938
  this.requests = [], this.config = e;
2735
2939
  }
@@ -2745,14 +2949,14 @@ class Et {
2745
2949
  return this.requests.length === 0 ? 0 : this.requests[0] + this.config.windowMs;
2746
2950
  }
2747
2951
  }
2748
- class At {
2952
+ class zt {
2749
2953
  constructor(e = { maxRequests: 10, windowMs: 6e4 }) {
2750
- this.rateLimiter = new Et(e);
2954
+ this.rateLimiter = new qt(e);
2751
2955
  }
2752
2956
  async makeRequest(e, r) {
2753
2957
  if (!this.rateLimiter.checkLimit()) {
2754
- const t = this.rateLimiter.getResetTime(), a = new Error("Rate limit exceeded. Please wait before making another request.");
2755
- throw a.code = "RATE_LIMIT_EXCEEDED", a.resetTime = t, r && r(t), a;
2958
+ const t = this.rateLimiter.getResetTime(), o = new Error("Rate limit exceeded. Please wait before making another request.");
2959
+ throw o.code = "RATE_LIMIT_EXCEEDED", o.resetTime = t, r && r(t), o;
2756
2960
  }
2757
2961
  return await e();
2758
2962
  }
@@ -2760,37 +2964,38 @@ class At {
2760
2964
  return this.rateLimiter.getRemainingRequests();
2761
2965
  }
2762
2966
  }
2763
- const Nt = new At({ maxRequests: 10, windowMs: 6e4 });
2967
+ const er = new zt({ maxRequests: 10, windowMs: 6e4 });
2764
2968
  export {
2765
- Rt as A,
2766
- de as B,
2767
- Ot as D,
2768
- ie as E,
2769
- St as F,
2770
- pt as G,
2771
- wt as I,
2772
- gt as O,
2773
- ue as P,
2774
- ae as R,
2775
- he as S,
2776
- se as T,
2777
- le as W,
2778
- Ae as a,
2779
- xt as b,
2969
+ Qt as A,
2970
+ he as B,
2971
+ Yt as D,
2972
+ me as E,
2973
+ Ft as F,
2974
+ Dt as G,
2975
+ Zt as I,
2976
+ Mt as O,
2977
+ fe as P,
2978
+ le as R,
2979
+ Ee as S,
2980
+ de as T,
2981
+ ge as W,
2982
+ Me as a,
2983
+ Xt as b,
2780
2984
  $ as c,
2781
- At as d,
2782
- Nt as e,
2783
- _t as f,
2784
- ht as g,
2785
- ft as h,
2786
- yt as i,
2787
- bt as j,
2788
- ne as k,
2985
+ Gt as d,
2986
+ zt as e,
2987
+ er as f,
2988
+ Jt as g,
2989
+ $t as h,
2990
+ Lt as i,
2991
+ Ct as j,
2992
+ Ut as k,
2789
2993
  ce as l,
2790
- me as m,
2791
- Tt as n,
2792
- vt as o,
2793
- U as p,
2794
- mt as s,
2795
- It as t
2994
+ pe as m,
2995
+ ye as n,
2996
+ Kt as o,
2997
+ Vt as p,
2998
+ z as q,
2999
+ Nt as s,
3000
+ Wt as t
2796
3001
  };