sliccy 2.16.0 → 2.17.1

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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ If this scares, confuses, or excites you, keep reading.
11
11
 
12
12
  # slicc — Self-Licking Ice Cream Cone
13
13
 
14
- [![72% Vibe_Coded](https://img.shields.io/badge/72%25-Vibe_Coded-ff69b4?style=for-the-badge&logo=claude&logoColor=white)](https://github.com/ai-ecoverse/vibe-coded-badge-action)
14
+ [![73% Vibe_Coded](https://img.shields.io/badge/73%25-Vibe_Coded-ff69b4?style=for-the-badge&logo=claude&logoColor=white)](https://github.com/ai-ecoverse/vibe-coded-badge-action)
15
15
 
16
16
  [![npm](https://img.shields.io/npm/v/sliccy)](https://www.npmjs.com/package/sliccy)
17
17
 
@@ -1,5 +1,12 @@
1
1
  import { existsSync, readdirSync } from 'fs';
2
2
  import type { ChildProcess } from 'child_process';
3
+ /**
4
+ * Default startup timeout for Chrome's CDP listener. Overridable via the
5
+ * `SLICC_CDP_LAUNCH_TIMEOUT_MS` environment variable so cold/contended CI
6
+ * runners can give Chrome a longer cold-start window without code changes.
7
+ */
8
+ export declare const DEFAULT_CDP_LAUNCH_TIMEOUT_MS = 15000;
9
+ export declare function getDefaultCdpLaunchTimeoutMs(env?: NodeJS.ProcessEnv): number;
3
10
  export declare const CLI_PROFILE_NAMES: readonly ["leader", "follower", "extension"];
4
11
  export type CliProfileName = (typeof CLI_PROFILE_NAMES)[number];
5
12
  export interface ChromeLaunchProfile {
@@ -43,6 +50,38 @@ export declare function parseCdpPortFromStderr(line: string): number | null;
43
50
  * Watch a Chrome child process's stderr for the `DevTools listening on` line
44
51
  * and resolve with the actual CDP port. Rejects after `timeoutMs` if the line
45
52
  * never appears (e.g. Chrome failed to start).
53
+ *
54
+ * Buffers across chunk boundaries: stderr data events split on arbitrary
55
+ * byte boundaries (not on newlines), so the original "split each chunk by
56
+ * \n and regex each line" approach silently dropped the DevTools line
57
+ * whenever it spanned two chunks. We accumulate a rolling buffer and only
58
+ * parse complete lines (everything before the last `\n`); the trailing
59
+ * partial line is carried forward to the next chunk.
46
60
  */
47
61
  export declare function waitForCdpPortFromStderr(child: ChildProcess, timeoutMs?: number): Promise<number>;
62
+ /**
63
+ * Poll `<userDataDir>/DevToolsActivePort` for the CDP port. Chrome writes
64
+ * this file as soon as the DevTools listener is up — its first line is
65
+ * the port, the second is the websocket path. This is the canonical way
66
+ * Chromium itself recommends discovering the chosen port and is far more
67
+ * reliable than scraping stderr.
68
+ *
69
+ * Resolves with the parsed port. Rejects on timeout or process exit.
70
+ *
71
+ * @param userDataDir absolute path Chrome was launched with via `--user-data-dir=`
72
+ * @param child the Chrome child process (used to bail out on early exit)
73
+ * @param timeoutMs total budget before giving up
74
+ * @param pollMs polling cadence (default 50ms)
75
+ */
76
+ export declare function waitForCdpPortFromActivePortFile(userDataDir: string, child: ChildProcess, timeoutMs?: number, pollMs?: number): Promise<number>;
77
+ /**
78
+ * Race the stderr scraper and the `DevToolsActivePort` poller. Whichever
79
+ * resolves first wins; the loser is silently ignored. This is the
80
+ * recommended entry point for callers who already have a `--user-data-dir`
81
+ * on hand (which is the usual case in tests and CLI launches).
82
+ */
83
+ export declare function waitForCdpPort(child: ChildProcess, options?: {
84
+ userDataDir?: string;
85
+ timeoutMs?: number;
86
+ }): Promise<number>;
48
87
  export {};
@@ -2,6 +2,21 @@ import { existsSync, readdirSync } from 'fs';
2
2
  import { mkdir, readFile, writeFile } from 'fs/promises';
3
3
  import { homedir } from 'os';
4
4
  import { dirname, join } from 'path';
5
+ /**
6
+ * Default startup timeout for Chrome's CDP listener. Overridable via the
7
+ * `SLICC_CDP_LAUNCH_TIMEOUT_MS` environment variable so cold/contended CI
8
+ * runners can give Chrome a longer cold-start window without code changes.
9
+ */
10
+ export const DEFAULT_CDP_LAUNCH_TIMEOUT_MS = 15000;
11
+ export function getDefaultCdpLaunchTimeoutMs(env = process.env) {
12
+ const raw = env.SLICC_CDP_LAUNCH_TIMEOUT_MS;
13
+ if (!raw)
14
+ return DEFAULT_CDP_LAUNCH_TIMEOUT_MS;
15
+ const parsed = Number.parseInt(raw, 10);
16
+ if (!Number.isFinite(parsed) || parsed <= 0)
17
+ return DEFAULT_CDP_LAUNCH_TIMEOUT_MS;
18
+ return parsed;
19
+ }
5
20
  export const CLI_PROFILE_NAMES = ['leader', 'follower', 'extension'];
6
21
  const DEFAULT_USER_DATA_DIR_NAME = 'browser-coding-agent-chrome';
7
22
  const QA_PROFILE_ROOT_SEGMENTS = ['.qa', 'chrome'];
@@ -290,14 +305,22 @@ export function parseCdpPortFromStderr(line) {
290
305
  * Watch a Chrome child process's stderr for the `DevTools listening on` line
291
306
  * and resolve with the actual CDP port. Rejects after `timeoutMs` if the line
292
307
  * never appears (e.g. Chrome failed to start).
308
+ *
309
+ * Buffers across chunk boundaries: stderr data events split on arbitrary
310
+ * byte boundaries (not on newlines), so the original "split each chunk by
311
+ * \n and regex each line" approach silently dropped the DevTools line
312
+ * whenever it spanned two chunks. We accumulate a rolling buffer and only
313
+ * parse complete lines (everything before the last `\n`); the trailing
314
+ * partial line is carried forward to the next chunk.
293
315
  */
294
- export function waitForCdpPortFromStderr(child, timeoutMs = 15000) {
316
+ export function waitForCdpPortFromStderr(child, timeoutMs = getDefaultCdpLaunchTimeoutMs()) {
295
317
  return new Promise((resolve, reject) => {
296
318
  if (!child.stderr) {
297
319
  reject(new Error('Chrome process has no stderr stream'));
298
320
  return;
299
321
  }
300
322
  let settled = false;
323
+ let buffer = '';
301
324
  const timer = setTimeout(() => {
302
325
  if (!settled) {
303
326
  settled = true;
@@ -307,9 +330,12 @@ export function waitForCdpPortFromStderr(child, timeoutMs = 15000) {
307
330
  const onData = (chunk) => {
308
331
  if (settled)
309
332
  return;
310
- const text = chunk.toString('utf-8');
311
- // stderr may deliver multiple lines in one chunk
312
- for (const line of text.split('\n')) {
333
+ buffer += chunk.toString('utf-8');
334
+ // Parse all complete lines; keep the trailing partial in the buffer.
335
+ let nlIdx = buffer.indexOf('\n');
336
+ while (nlIdx !== -1) {
337
+ const line = buffer.slice(0, nlIdx);
338
+ buffer = buffer.slice(nlIdx + 1);
313
339
  const port = parseCdpPortFromStderr(line);
314
340
  if (port !== null) {
315
341
  settled = true;
@@ -318,6 +344,19 @@ export function waitForCdpPortFromStderr(child, timeoutMs = 15000) {
318
344
  resolve(port);
319
345
  return;
320
346
  }
347
+ nlIdx = buffer.indexOf('\n');
348
+ }
349
+ // Also try parsing the trailing partial: Chrome's DevTools line is
350
+ // typically flushed with a newline, but if the process exits before
351
+ // the newline reaches us we still want to recover the port. This is
352
+ // a no-op for normal traffic since `parseCdpPortFromStderr` requires
353
+ // a trailing `/` in the regex, which precedes the newline anyway.
354
+ const tailPort = parseCdpPortFromStderr(buffer);
355
+ if (tailPort !== null) {
356
+ settled = true;
357
+ clearTimeout(timer);
358
+ child.stderr.off('data', onData);
359
+ resolve(tailPort);
321
360
  }
322
361
  };
323
362
  child.stderr.on('data', onData);
@@ -330,3 +369,88 @@ export function waitForCdpPortFromStderr(child, timeoutMs = 15000) {
330
369
  });
331
370
  });
332
371
  }
372
+ /**
373
+ * Poll `<userDataDir>/DevToolsActivePort` for the CDP port. Chrome writes
374
+ * this file as soon as the DevTools listener is up — its first line is
375
+ * the port, the second is the websocket path. This is the canonical way
376
+ * Chromium itself recommends discovering the chosen port and is far more
377
+ * reliable than scraping stderr.
378
+ *
379
+ * Resolves with the parsed port. Rejects on timeout or process exit.
380
+ *
381
+ * @param userDataDir absolute path Chrome was launched with via `--user-data-dir=`
382
+ * @param child the Chrome child process (used to bail out on early exit)
383
+ * @param timeoutMs total budget before giving up
384
+ * @param pollMs polling cadence (default 50ms)
385
+ */
386
+ export function waitForCdpPortFromActivePortFile(userDataDir, child, timeoutMs = getDefaultCdpLaunchTimeoutMs(), pollMs = 50) {
387
+ return new Promise((resolve, reject) => {
388
+ let settled = false;
389
+ const path = join(userDataDir, 'DevToolsActivePort');
390
+ const startedAt = Date.now();
391
+ const finish = (action) => {
392
+ if (settled)
393
+ return;
394
+ settled = true;
395
+ action();
396
+ };
397
+ const tick = async () => {
398
+ if (settled)
399
+ return;
400
+ try {
401
+ const contents = await readFile(path, 'utf-8');
402
+ // First line is the port; second is the WS path. Chrome writes both
403
+ // atomically once the listener is up. If we read it mid-write we'll
404
+ // either get an empty file or the port-only first line — both fall
405
+ // through to the next tick.
406
+ const firstLine = contents.split('\n', 1)[0]?.trim();
407
+ if (firstLine) {
408
+ const port = Number.parseInt(firstLine, 10);
409
+ if (Number.isFinite(port) && port > 0) {
410
+ finish(() => resolve(port));
411
+ return;
412
+ }
413
+ }
414
+ }
415
+ catch (err) {
416
+ // ENOENT before Chrome writes the file — keep polling. Anything
417
+ // else is ignored too: we'd rather fall back to the stderr path
418
+ // racing alongside this poller than reject early.
419
+ void err;
420
+ }
421
+ if (Date.now() - startedAt >= timeoutMs) {
422
+ finish(() => reject(new Error(`Timed out waiting for DevToolsActivePort at ${path} (${timeoutMs}ms)`)));
423
+ return;
424
+ }
425
+ setTimeout(() => {
426
+ void tick();
427
+ }, pollMs);
428
+ };
429
+ child.on('exit', (code) => {
430
+ finish(() => reject(new Error(`Chrome exited with code ${code} before writing DevToolsActivePort`)));
431
+ });
432
+ void tick();
433
+ });
434
+ }
435
+ /**
436
+ * Race the stderr scraper and the `DevToolsActivePort` poller. Whichever
437
+ * resolves first wins; the loser is silently ignored. This is the
438
+ * recommended entry point for callers who already have a `--user-data-dir`
439
+ * on hand (which is the usual case in tests and CLI launches).
440
+ */
441
+ export function waitForCdpPort(child, options = {}) {
442
+ const timeoutMs = options.timeoutMs ?? getDefaultCdpLaunchTimeoutMs();
443
+ const stderrPromise = waitForCdpPortFromStderr(child, timeoutMs);
444
+ if (!options.userDataDir)
445
+ return stderrPromise;
446
+ const filePromise = waitForCdpPortFromActivePortFile(options.userDataDir, child, timeoutMs);
447
+ // Suppress unhandled-rejection warnings on the loser.
448
+ stderrPromise.catch(() => { });
449
+ filePromise.catch(() => { });
450
+ return Promise.any([stderrPromise, filePromise]).catch((agg) => {
451
+ // If both legs failed, surface the first error so callers see a
452
+ // meaningful message (timeout / exit) rather than an opaque AggregateError.
453
+ const first = agg.errors[0];
454
+ throw first instanceof Error ? first : new Error(String(first));
455
+ });
456
+ }
@@ -1,2 +1,4 @@
1
1
  export declare function updateManifestVersionContents(contents: string, version: string): string;
2
2
  export declare function writeManifestVersion(manifestPath: string, version: string): void;
3
+ export declare function buildVfsRootVersionContents(version: string, releasedAt: string): string;
4
+ export declare function writeVfsRootVersion(versionFilePath: string, version: string, releasedAt: string): void;
@@ -14,6 +14,13 @@ export function updateManifestVersionContents(contents, version) {
14
14
  export function writeManifestVersion(manifestPath, version) {
15
15
  writeFileSync(manifestPath, updateManifestVersionContents(readFileSync(manifestPath, 'utf8'), version));
16
16
  }
17
+ export function buildVfsRootVersionContents(version, releasedAt) {
18
+ const payload = { version, releasedAt };
19
+ return `${JSON.stringify(payload, null, 2)}\n`;
20
+ }
21
+ export function writeVfsRootVersion(versionFilePath, version, releasedAt) {
22
+ writeFileSync(versionFilePath, buildVfsRootVersionContents(version, releasedAt));
23
+ }
17
24
  function main() {
18
25
  const version = process.argv[2];
19
26
  if (!version) {
@@ -21,6 +28,9 @@ function main() {
21
28
  }
22
29
  writeManifestVersion(resolve(PROJECT_ROOT, 'packages/chrome-extension/manifest.json'), version);
23
30
  console.log(`Updated manifest.json version to ${version}`);
31
+ const releasedAt = new Date().toISOString();
32
+ writeVfsRootVersion(resolve(PROJECT_ROOT, 'packages/vfs-root/shared/version.json'), version, releasedAt);
33
+ console.log(`Updated vfs-root/shared/version.json to ${version} (releasedAt=${releasedAt})`);
24
34
  }
25
35
  if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {
26
36
  try {
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,n,s as r,t as i}from"./simple-options-CP_5aL7H.js";import{c as a,l as o,s}from"./index-BUtSuwcx.js";import{t as c}from"./headers-CrRy8cka.js";import{t as l}from"./sanitize-unicode-6mS7gbvU.js";import{n as u,t as ee}from"./github-copilot-headers-BFowJEWi.js";function d(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function f(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var p=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return p=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function m(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var h=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},g=class extends Error{},_=class e extends g{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new te({message:r,cause:h(n)});let a=n,o=a?.error?.type;return t===400?new re(t,a,r,i,o):t===401?new ie(t,a,r,i,o):t===403?new ae(t,a,r,i,o):t===404?new oe(t,a,r,i,o):t===409?new se(t,a,r,i,o):t===422?new ce(t,a,r,i,o):t===429?new le(t,a,r,i,o):t>=500?new ue(t,a,r,i,o):new e(t,a,r,i,o)}},v=class extends _{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},te=class extends _{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ne=class extends te{constructor({message:e}={}){super({message:e??`Request timed out.`})}},re=class extends _{},ie=class extends _{},ae=class extends _{},oe=class extends _{},se=class extends _{},ce=class extends _{},le=class extends _{},ue=class extends _{},de=/^[a-z][a-z0-9+.-]*:/i,fe=e=>de.test(e),pe=e=>(pe=Array.isArray,pe(e)),me=pe;function he(e){return typeof e==`object`?e??{}:{}}function ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function _e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ve=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new g(`${e} must be an integer`);if(t<0)throw new g(`${e} must be a positive integer`);return t},ye=e=>{try{return JSON.parse(e)}catch{return}},be=e=>new Promise(t=>setTimeout(t,e)),y=`0.90.0`,xe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Ce=()=>{let e=Se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":Ee(Deno.build.os),"X-Stainless-Arch":Te(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":Ee(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Te(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=we();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function we(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Te=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ee=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),De,Oe=()=>De??=Ce();function ke(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ae(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function je(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ae({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Me(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ne(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Pe=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Fe(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new g(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}function Ie(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Le;function Re(e){let t;return(Le??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var ze;function Be(e){let t;return(ze??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var b,x,S=class{constructor(){b.set(this,void 0),x.set(this,void 0),d(this,b,new Uint8Array,`f`),d(this,x,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Re(e):e;d(this,b,Ie([f(this,b,`f`),t]),`f`);let n=[],r;for(;(r=Ve(f(this,b,`f`),f(this,x,`f`)))!=null;){if(r.carriage&&f(this,x,`f`)==null){d(this,x,r.index,`f`);continue}if(f(this,x,`f`)!=null&&(r.index!==f(this,x,`f`)+1||r.carriage)){n.push(Be(f(this,b,`f`).subarray(0,f(this,x,`f`)-1))),d(this,b,f(this,b,`f`).subarray(f(this,x,`f`)),`f`),d(this,x,null,`f`);continue}let e=f(this,x,`f`)===null?r.preceding:r.preceding-1,t=Be(f(this,b,`f`).subarray(0,e));n.push(t),d(this,b,f(this,b,`f`).subarray(r.index),`f`),d(this,x,null,`f`)}return n}flush(){return f(this,b,`f`).length?this.decode(`
1
+ import{a as e,i as t,n,s as r,t as i}from"./simple-options-CP_5aL7H.js";import{c as a,l as o,s}from"./index-CGVzZoL9.js";import{t as c}from"./headers-CrRy8cka.js";import{t as l}from"./sanitize-unicode-6mS7gbvU.js";import{n as u,t as ee}from"./github-copilot-headers-BFowJEWi.js";function d(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function f(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var p=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return p=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function m(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var h=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},g=class extends Error{},_=class e extends g{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new te({message:r,cause:h(n)});let a=n,o=a?.error?.type;return t===400?new re(t,a,r,i,o):t===401?new ie(t,a,r,i,o):t===403?new ae(t,a,r,i,o):t===404?new oe(t,a,r,i,o):t===409?new se(t,a,r,i,o):t===422?new ce(t,a,r,i,o):t===429?new le(t,a,r,i,o):t>=500?new ue(t,a,r,i,o):new e(t,a,r,i,o)}},v=class extends _{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},te=class extends _{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ne=class extends te{constructor({message:e}={}){super({message:e??`Request timed out.`})}},re=class extends _{},ie=class extends _{},ae=class extends _{},oe=class extends _{},se=class extends _{},ce=class extends _{},le=class extends _{},ue=class extends _{},de=/^[a-z][a-z0-9+.-]*:/i,fe=e=>de.test(e),pe=e=>(pe=Array.isArray,pe(e)),me=pe;function he(e){return typeof e==`object`?e??{}:{}}function ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function _e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ve=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new g(`${e} must be an integer`);if(t<0)throw new g(`${e} must be a positive integer`);return t},ye=e=>{try{return JSON.parse(e)}catch{return}},be=e=>new Promise(t=>setTimeout(t,e)),y=`0.90.0`,xe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Ce=()=>{let e=Se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":Ee(Deno.build.os),"X-Stainless-Arch":Te(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":Ee(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Te(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=we();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function we(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Te=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ee=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),De,Oe=()=>De??=Ce();function ke(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ae(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function je(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ae({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Me(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ne(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Pe=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Fe(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new g(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}function Ie(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Le;function Re(e){let t;return(Le??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var ze;function Be(e){let t;return(ze??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var b,x,S=class{constructor(){b.set(this,void 0),x.set(this,void 0),d(this,b,new Uint8Array,`f`),d(this,x,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Re(e):e;d(this,b,Ie([f(this,b,`f`),t]),`f`);let n=[],r;for(;(r=Ve(f(this,b,`f`),f(this,x,`f`)))!=null;){if(r.carriage&&f(this,x,`f`)==null){d(this,x,r.index,`f`);continue}if(f(this,x,`f`)!=null&&(r.index!==f(this,x,`f`)+1||r.carriage)){n.push(Be(f(this,b,`f`).subarray(0,f(this,x,`f`)-1))),d(this,b,f(this,b,`f`).subarray(f(this,x,`f`)),`f`),d(this,x,null,`f`);continue}let e=f(this,x,`f`)===null?r.preceding:r.preceding-1,t=Be(f(this,b,`f`).subarray(0,e));n.push(t),d(this,b,f(this,b,`f`).subarray(r.index),`f`),d(this,x,null,`f`)}return n}flush(){return f(this,b,`f`).length?this.decode(`
2
2
  `):[]}};b=new WeakMap,x=new WeakMap,S.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),S.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ve(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function He(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var Ue={off:0,error:200,warn:300,info:400,debug:500},We=(e,t,n)=>{if(e){if(_e(Ue,e))return e;C(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ue))}`)}};function Ge(){}function Ke(e,t,n){return!t||Ue[e]>Ue[n]?Ge:t[e].bind(t)}var qe={error:Ge,warn:Ge,info:Ge,debug:Ge},Je=new WeakMap;function C(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return qe;let r=Je.get(t);if(r&&r[0]===n)return r[1];let i={error:Ke(`error`,t,n),warn:Ke(`warn`,t,n),info:Ke(`info`,t,n),debug:Ke(`debug`,t,n)};return Je.set(t,[n,i]),i}var w=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Ye,Xe=class e{constructor(e,t,n){this.iterator=e,Ye.set(this,void 0),this.controller=t,d(this,Ye,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?C(r):console;async function*o(){if(i)throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of Ze(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`||e.event===`message`||e.event===`user.message`||e.event===`user.interrupt`||e.event===`user.tool_confirmation`||e.event===`user.custom_tool_result`||e.event===`agent.message`||e.event===`agent.thinking`||e.event===`agent.tool_use`||e.event===`agent.tool_result`||e.event===`agent.mcp_tool_use`||e.event===`agent.mcp_tool_result`||e.event===`agent.custom_tool_use`||e.event===`agent.thread_context_compacted`||e.event===`session.status_running`||e.event===`session.status_idle`||e.event===`session.status_rescheduled`||e.event===`session.status_terminated`||e.event===`session.error`||e.event===`session.deleted`||e.event===`span.model_request_start`||e.event===`span.model_request_end`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=ye(e.data)??e.data,r=n?.error?.type;throw new _(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(m(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new S,n=Me(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(m(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Ye=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,f(this,Ye,`f`)),new e(()=>i(n),this.controller,f(this,Ye,`f`))]}toReadableStream(){let e=this,t;return Ae({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Re(JSON.stringify(n)+`
4
4
  `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}};async function*Ze(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new g(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new g(`Attempted to iterate over a response with no body`);let n=new $e,r=new S,i=Me(e.body);for await(let e of Qe(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Qe(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Re(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=He(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}var $e=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -1 +1 @@
1
- import{a as e,d as t,n,r}from"./simple-options-CP_5aL7H.js";import{t as i}from"./openai-CuiHR4mv.js";import{l as a}from"./index-BUtSuwcx.js";import{t as o}from"./headers-CrRy8cka.js";import{n as s,r as c,t as l}from"./openai-responses-shared-Djn4u9ch.js";var u=`v1`,d=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function f(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function p(e,t){return t?.azureDeploymentName?t.azureDeploymentName:f({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}var m=(t,n,r)=>{let i=new e;return(async()=>{let e=p(t,r),s={role:`assistant`,content:[],api:`azure-openai-responses`,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let l=y(t,r?.apiKey||a(t.provider)||``,r),u=b(t,n,r,e),d=await r?.onPayload?.(u,t);d!==void 0&&(u=d);let{data:f,response:p}=await l.responses.create(u,r?.signal?{signal:r.signal}:void 0).withResponse();if(await r?.onResponse?.({status:p.status,headers:o(p.headers)},t),i.push({type:`start`,partial:s}),await c(f,s,i,t),r?.signal?.aborted)throw Error(`Request was aborted`);if(s.stopReason===`aborted`||s.stopReason===`error`)throw Error(`An unknown error occurred`);i.push({type:`done`,reason:s.stopReason,message:s}),i.end()}catch(e){for(let e of s.content)delete e.index,delete e.partialJson;s.stopReason=r?.signal?.aborted?`aborted`:`error`,s.errorMessage=e instanceof Error?e.message:JSON.stringify(e),i.push({type:`error`,reason:s.stopReason,error:s}),i.end()}})(),i},h=(e,i,o)=>{let s=o?.apiKey||a(e.provider);if(!s)throw Error(`No API key for provider: ${e.provider}`);let c=n(e,o,s),l=t(e)?o?.reasoning:r(o?.reasoning);return m(e,i,{...c,reasoningEffort:l})};function g(e){return e.replace(/\/+$/,``)}function _(e){return`https://${e}.openai.azure.com/openai/v1`}function v(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||u,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=_(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:g(a),apiVersion:n}}function y(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:a,apiVersion:o}=v(e,n);return new i({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:a})}function b(e,t,n,r){let i={model:r,input:l(e,t,d),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&(i.tools=s(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):i.reasoning={effort:`none`}),i}export{m as streamAzureOpenAIResponses,h as streamSimpleAzureOpenAIResponses};
1
+ import{a as e,d as t,n,r}from"./simple-options-CP_5aL7H.js";import{t as i}from"./openai-CuiHR4mv.js";import{l as a}from"./index-CGVzZoL9.js";import{t as o}from"./headers-CrRy8cka.js";import{n as s,r as c,t as l}from"./openai-responses-shared-KYSbjY1h.js";var u=`v1`,d=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function f(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function p(e,t){return t?.azureDeploymentName?t.azureDeploymentName:f({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}var m=(t,n,r)=>{let i=new e;return(async()=>{let e=p(t,r),s={role:`assistant`,content:[],api:`azure-openai-responses`,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let l=y(t,r?.apiKey||a(t.provider)||``,r),u=b(t,n,r,e),d=await r?.onPayload?.(u,t);d!==void 0&&(u=d);let{data:f,response:p}=await l.responses.create(u,r?.signal?{signal:r.signal}:void 0).withResponse();if(await r?.onResponse?.({status:p.status,headers:o(p.headers)},t),i.push({type:`start`,partial:s}),await c(f,s,i,t),r?.signal?.aborted)throw Error(`Request was aborted`);if(s.stopReason===`aborted`||s.stopReason===`error`)throw Error(`An unknown error occurred`);i.push({type:`done`,reason:s.stopReason,message:s}),i.end()}catch(e){for(let e of s.content)delete e.index,delete e.partialJson;s.stopReason=r?.signal?.aborted?`aborted`:`error`,s.errorMessage=e instanceof Error?e.message:JSON.stringify(e),i.push({type:`error`,reason:s.stopReason,error:s}),i.end()}})(),i},h=(e,i,o)=>{let s=o?.apiKey||a(e.provider);if(!s)throw Error(`No API key for provider: ${e.provider}`);let c=n(e,o,s),l=t(e)?o?.reasoning:r(o?.reasoning);return m(e,i,{...c,reasoningEffort:l})};function g(e){return e.replace(/\/+$/,``)}function _(e){return`https://${e}.openai.azure.com/openai/v1`}function v(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||u,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=_(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:g(a),apiVersion:n}}function y(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:a,apiVersion:o}=v(e,n);return new i({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:a})}function b(e,t,n,r){let i={model:r,input:l(e,t,d),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&(i.tools=s(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):i.reasoning={effort:`none`}),i}export{m as streamAzureOpenAIResponses,h as streamSimpleAzureOpenAIResponses};
@@ -16,4 +16,11 @@ drwxr-xr-x 2 user user 4096 Jan 01 10:00 src`},{id:`fx-tc-err`,name:`edit_file`,
16
16
 
17
17
  A previously-mounted directory needs to be reauthorized:
18
18
 
19
- - \`/mnt/workspace\` (was \`workspace/\`)`,timestamp:r(16),source:`lick`,channel:`session-reload`}),n.push({id:`fx-queued-1`,role:`user`,content:`Also double-check the install.md formatting after you finish.`,timestamp:r(18),queued:!0}),n.push({id:`fx-assistant-streaming`,role:`assistant`,content:`Great, running the coverage suite now. I'll report back as soon as it `,timestamp:r(20),isStreaming:!0,toolCalls:[{id:`fx-tc-streaming`,name:`bash`,input:{command:`npm run test -- --coverage`}}]}),n}export{a as FIXTURE_SCOOP_NAME,i as FIXTURE_SESSION_ID,o as createChatFixture};
19
+ - \`/mnt/workspace\` (was \`workspace/\`)`,timestamp:r(16),source:`lick`,channel:`session-reload`}),n.push({id:`fx-lick-upgrade`,role:`user`,content:`[Upgrade Event: 0.4.1→0.5.0]
20
+
21
+ SLICC was upgraded from \`0.4.1\` to \`0.5.0\`.
22
+ Released: 2026-04-15T12:00:00Z
23
+
24
+ Use the **upgrade** skill (\`/workspace/skills/upgrade/SKILL.md\`) to:
25
+ - Show the user the changelog between these tags from GitHub
26
+ - Offer to merge new bundled vfs-root content into their workspace (three-way merge: bundled snapshot vs user's VFS, reconciled with the GitHub tag-to-tag diff).`,timestamp:r(17),source:`lick`,channel:`upgrade`}),n.push({id:`fx-queued-1`,role:`user`,content:`Also double-check the install.md formatting after you finish.`,timestamp:r(18),queued:!0}),n.push({id:`fx-assistant-streaming`,role:`assistant`,content:`Great, running the coverage suite now. I'll report back as soon as it `,timestamp:r(20),isStreaming:!0,toolCalls:[{id:`fx-tc-streaming`,name:`bash`,input:{command:`npm run test -- --coverage`}}]}),n}export{a as FIXTURE_SCOOP_NAME,i as FIXTURE_SESSION_ID,o as createChatFixture};