sliccy 2.8.0 → 2.9.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.
- package/dist/ui/assets/{anthropic-H12_Atst.js → anthropic-CMVA8z4u.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-BFJMXroi.js → azure-openai-responses-BcVCOWjr.js} +1 -1
- package/dist/ui/assets/{es-Cb53P3vr.js → es-Dh2rgMJQ.js} +1 -1
- package/dist/ui/assets/{google-CBNil8p2.js → google-CJIGxdKe.js} +1 -1
- package/dist/ui/assets/{index-B87TbZRu.js → index-CwOoNoZz.js} +898 -903
- package/dist/ui/assets/{mistral-ROS5ivdx.js → mistral-BO8fQ2lz.js} +1 -1
- package/dist/ui/assets/{openai-codex-responses-C9PwP_vv.js → openai-codex-responses-DglthLmz.js} +1 -1
- package/dist/ui/assets/{openai-completions-C6XmF6cd.js → openai-completions-B9-2Retb.js} +1 -1
- package/dist/ui/assets/{openai-responses-C5uhM4oI.js → openai-responses-Bay2AY5u.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-DhRsugmK.js → openai-responses-shared-BU6CEk9U.js} +1 -1
- package/dist/ui/assets/{provider-settings-DP1WW4DW.js → provider-settings-lbdVYpIy.js} +2 -2
- package/dist/ui/assets/{skills-CZB3ZWfP.js → skills-O_vTBFE5.js} +1 -1
- package/dist/ui/index.html +4 -4
- package/dist/ui/lucide-icons.js +1 -1
- package/dist/ui/packages/webapp/index.html +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,s as i}from"./simple-options-DEbfD_Ko.js";import{a,o}from"./index-B87TbZRu.js";import{t as s}from"./sanitize-unicode-ncMKN_SD.js";import{t as c}from"./hash-BwzabXYv.js";var l=Object.prototype.hasOwnProperty;function u(e,t){let n=/\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;return function(r={}){return e.replace(n,function(e,n){if(!l.call(r,n))throw Error(`Parameter '${n}' is required`);let i=r[n];if(typeof i!=`string`&&typeof i!=`number`)throw Error(`Parameter '${n}' must be a string or number`);return t?.charEncoding===`percent`?encodeURIComponent(`${i}`):`${i}`}).replace(/^\/+/,``)}}var d={eu:`https://api.mistral.ai`};function f(e){let t=e.serverURL,n={};t||=d[e.server??`eu`]||``;let r=u(t)(n);return new URL(r)}var p={language:`typescript`,openapiDocVersion:`1.0.0`,sdkVersion:`2.2.0`,genVersion:`2.879.6`,userAgent:`speakeasy-sdk/typescript 2.2.0 2.879.6 1.0.0 @mistralai/mistralai`};async function m(e){let t=e.getReader(),n=[],r=0,i=!1;for(;!i;){let{value:e,done:a}=await t.read();a?i=!0:(n.push(e),r+=e.length)}let a=new Uint8Array(r),o=0;for(let e of n)a.set(e,o),o+=e.length;return a.buffer}function h(e){if(!e)return null;let t=e.toLowerCase().split(`.`).pop();return t&&{json:`application/json`,xml:`application/xml`,html:`text/html`,htm:`text/html`,txt:`text/plain`,csv:`text/csv`,pdf:`application/pdf`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,svg:`image/svg+xml`,js:`application/javascript`,css:`text/css`,zip:`application/zip`,tar:`application/x-tar`,gz:`application/gzip`,mp4:`video/mp4`,mp3:`audio/mpeg`,wav:`audio/wav`,webp:`image/webp`,ico:`image/x-icon`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`}[t]||null}function g(e,t){return e instanceof Uint8Array?new Blob([new Uint8Array(e)],{type:t}):new Blob([e],{type:t})}var _=(e,t)=>t==null?fetch(e):fetch(e,t),v=class e{options;fetcher;requestHooks=[];requestErrorHooks=[];responseHooks=[];constructor(e={}){this.options=e,this.fetcher=e.fetcher||_}async request(e){let t=e;for(let e of this.requestHooks){let n=await e(t);n&&(t=n)}try{let e=await this.fetcher(t);for(let n of this.responseHooks)await n(e,t);return e}catch(e){for(let n of this.requestErrorHooks)await n(e,t);throw e}}addHook(...e){if(e[0]===`beforeRequest`)this.requestHooks.push(e[1]);else if(e[0]===`requestError`)this.requestErrorHooks.push(e[1]);else if(e[0]===`response`)this.responseHooks.push(e[1]);else throw Error(`Invalid hook type: ${e[0]}`);return this}removeHook(...e){let t;if(e[0]===`beforeRequest`)t=this.requestHooks;else if(e[0]===`requestError`)t=this.requestErrorHooks;else if(e[0]===`response`)t=this.responseHooks;else throw Error(`Invalid hook type: ${e[0]}`);let n=t.findIndex(t=>t===e[1]);return n>=0&&t.splice(n,1),this}clone(){let t=new e(this.options);return t.requestHooks=this.requestHooks.slice(),t.requestErrorHooks=this.requestErrorHooks.slice(),t.responseHooks=this.responseHooks.slice(),t}},ee=/\s*;\s*/g;function te(e,t){if(t===`*`)return!0;let n=e.headers.get(`content-type`)?.trim()||`application/octet-stream`;n=n.toLowerCase();let[r=``,...i]=t.toLowerCase().trim().split(ee);if(r.split(`/`).length!==2)return!1;let[a=``,...o]=n.split(ee),[s=``,c=``]=a.split(`/`);if(!s||!c||r!==`*/*`&&a!==r&&`${s}/*`!==r&&`*/${c}`!==r||o.length<i.length)return!1;let l=new Set(o);for(let e of i)if(!l.has(e))return!1;return!0}var ne=RegExp(`^[0-9]xx$`,`i`);function re(e,t){let n=`${e.status}`,r=Array.isArray(t)?t:[t];return r.length?r.some(e=>{let t=`${e}`;if(t===`default`)return!0;if(!ne.test(`${t}`))return t===n;let r=t.charAt(0);if(!r)throw Error(`Invalid status code range`);let i=n.charAt(0);if(!i)throw Error(`Invalid response status code: ${n}`);return i===r}):!1}function ie(e,t,n){return re(e,t)&&te(e,n)}function ae(e){if(typeof e!=`object`||!e)return!1;let t=e instanceof TypeError&&e.message.toLowerCase().startsWith(`failed to fetch`),n=e instanceof TypeError&&e.message.toLowerCase().startsWith(`fetch failed`),r=`name`in e&&e.name===`ConnectionError`,i=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnreset`;return t||n||i||r}function oe(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e&&e.name===`TimeoutError`,n=`code`in e&&e.code===23,r=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnaborted`;return t||n||r}function se(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e&&e.name===`AbortError`,n=`code`in e&&e.code===20,r=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnaborted`;return t||n||r}var ce=class{beforeRequest(e,t){let n=`mistral-client-typescript/${p.sdkVersion}`;return t.headers.set(`user-agent`,n),t.headers.get(`user-agent`)||t.headers.set(`x-mistral-user-agent`,n),t}},le=`x-model-deprecation-timestamp`,ue=class{afterSuccess(e,t){return t.headers.has(le)&&t.clone().json().then(e=>{let n=e.model;console.warn(`WARNING: The model ${n} is deprecated and will be removed on ${t.headers.get(le)}. Please refer to https://docs.mistral.ai/getting-started/models/#api-versioning for more information.`)}),t}};function de(e){let t=new ce;e.registerBeforeRequestHook(t);let n=new ue;e.registerAfterSuccessHook(n)}var fe=class{sdkInitHooks=[];beforeCreateRequestHooks=[];beforeRequestHooks=[];afterSuccessHooks=[];afterErrorHooks=[];constructor(){for(let e of[])`sdkInit`in e&&this.registerSDKInitHook(e),`beforeCreateRequest`in e&&this.registerBeforeCreateRequestHook(e),`beforeRequest`in e&&this.registerBeforeRequestHook(e),`afterSuccess`in e&&this.registerAfterSuccessHook(e),`afterError`in e&&this.registerAfterErrorHook(e);de(this)}registerSDKInitHook(e){this.sdkInitHooks.push(e)}registerBeforeCreateRequestHook(e){this.beforeCreateRequestHooks.push(e)}registerBeforeRequestHook(e){this.beforeRequestHooks.push(e)}registerAfterSuccessHook(e){this.afterSuccessHooks.push(e)}registerAfterErrorHook(e){this.afterErrorHooks.push(e)}sdkInit(e){return this.sdkInitHooks.reduce((e,t)=>t.sdkInit(e),e)}beforeCreateRequest(e,t){let n=t;for(let t of this.beforeCreateRequestHooks)n=t.beforeCreateRequest(e,n);return n}async beforeRequest(e,t){let n=t;for(let t of this.beforeRequestHooks)n=await t.beforeRequest(e,n);return n}async afterSuccess(e,t){let n=t;for(let t of this.afterSuccessHooks)n=await t.afterSuccess(e,n);return n}async afterError(e,t,n){let r=t,i=n;for(let t of this.afterErrorHooks){let n=await t.afterError(e,r,i);r=n.response,i=n.error}return{response:r,error:i}}},pe=class extends Error{cause;name=`HTTPClientError`;constructor(e,t){let n=e;t?.cause&&(n+=`: ${t.cause}`),super(n,t),this.cause===void 0&&(this.cause=t?.cause)}},me=class extends pe{name=`UnexpectedClientError`},he=class extends pe{name=`InvalidRequestError`},ge=class extends pe{name=`RequestAbortedError`},_e=class extends pe{name=`RequestTimeoutError`},ve=class extends pe{name=`ConnectionError`};function ye(e){return{ok:!0,value:e}}function be(e){return{ok:!1,error:e}}async function y(e){let t=await e;if(!t.ok)throw t.error;return t.value}var xe=Object.freeze({status:`aborted`});function b(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Se=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ce=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},we={};function Te(e){return e&&Object.assign(we,e),we}function Ee(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function De(e,t){return typeof t==`bigint`?t.toString():t}function Oe(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function ke(e){return e==null}function Ae(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function je(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var Me=Symbol(`evaluating`);function Ne(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Me)return r===void 0&&(r=Me,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fe(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Ie(e){return JSON.stringify(e)}function Le(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Re=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Be=Oe(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ve(e){if(ze(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ze(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function He(e){return Ve(e)?{...e}:Array.isArray(e)?[...e]:e}var Ue=new Set([`string`,`number`,`symbol`]);function We(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ge(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ke(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var qe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Je(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Ge(e,Fe(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Pe(this,`shape`,e),e},checks:[]}))}function Ye(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Ge(e,Fe(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Pe(this,`shape`,r),r},checks:[]}))}function Xe(e,t){if(!Ve(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ge(e,Fe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pe(this,`shape`,n),n}}))}function Ze(e,t){if(!Ve(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ge(e,Fe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pe(this,`shape`,n),n}}))}function Qe(e,t){return Ge(e,Fe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Pe(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function $e(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Ge(t,Fe(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Pe(this,`shape`,i),i},checks:[]}))}function et(e,t,n){return Ge(t,Fe(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Pe(this,`shape`,i),i}}))}function tt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function nt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function rt(e){return typeof e==`string`?e:e?.message}function it(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=rt(e.inst?._zod.def?.error?.(e))??rt(t?.error?.(e))??rt(n.customError?.(e))??rt(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function at(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ot(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var st=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,De,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},ct=b(`$ZodError`,st),lt=b(`$ZodError`,st,{Parent:Error});function ut(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function dt(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}function ft(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function pt(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${ft(e.path)}`);return t.join(`
|
|
1
|
+
import{a as e,i as t,n,r,s as i}from"./simple-options-DEbfD_Ko.js";import{a,o}from"./index-CwOoNoZz.js";import{t as s}from"./sanitize-unicode-ncMKN_SD.js";import{t as c}from"./hash-BwzabXYv.js";var l=Object.prototype.hasOwnProperty;function u(e,t){let n=/\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;return function(r={}){return e.replace(n,function(e,n){if(!l.call(r,n))throw Error(`Parameter '${n}' is required`);let i=r[n];if(typeof i!=`string`&&typeof i!=`number`)throw Error(`Parameter '${n}' must be a string or number`);return t?.charEncoding===`percent`?encodeURIComponent(`${i}`):`${i}`}).replace(/^\/+/,``)}}var d={eu:`https://api.mistral.ai`};function f(e){let t=e.serverURL,n={};t||=d[e.server??`eu`]||``;let r=u(t)(n);return new URL(r)}var p={language:`typescript`,openapiDocVersion:`1.0.0`,sdkVersion:`2.2.0`,genVersion:`2.879.6`,userAgent:`speakeasy-sdk/typescript 2.2.0 2.879.6 1.0.0 @mistralai/mistralai`};async function m(e){let t=e.getReader(),n=[],r=0,i=!1;for(;!i;){let{value:e,done:a}=await t.read();a?i=!0:(n.push(e),r+=e.length)}let a=new Uint8Array(r),o=0;for(let e of n)a.set(e,o),o+=e.length;return a.buffer}function h(e){if(!e)return null;let t=e.toLowerCase().split(`.`).pop();return t&&{json:`application/json`,xml:`application/xml`,html:`text/html`,htm:`text/html`,txt:`text/plain`,csv:`text/csv`,pdf:`application/pdf`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,svg:`image/svg+xml`,js:`application/javascript`,css:`text/css`,zip:`application/zip`,tar:`application/x-tar`,gz:`application/gzip`,mp4:`video/mp4`,mp3:`audio/mpeg`,wav:`audio/wav`,webp:`image/webp`,ico:`image/x-icon`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`}[t]||null}function g(e,t){return e instanceof Uint8Array?new Blob([new Uint8Array(e)],{type:t}):new Blob([e],{type:t})}var _=(e,t)=>t==null?fetch(e):fetch(e,t),v=class e{options;fetcher;requestHooks=[];requestErrorHooks=[];responseHooks=[];constructor(e={}){this.options=e,this.fetcher=e.fetcher||_}async request(e){let t=e;for(let e of this.requestHooks){let n=await e(t);n&&(t=n)}try{let e=await this.fetcher(t);for(let n of this.responseHooks)await n(e,t);return e}catch(e){for(let n of this.requestErrorHooks)await n(e,t);throw e}}addHook(...e){if(e[0]===`beforeRequest`)this.requestHooks.push(e[1]);else if(e[0]===`requestError`)this.requestErrorHooks.push(e[1]);else if(e[0]===`response`)this.responseHooks.push(e[1]);else throw Error(`Invalid hook type: ${e[0]}`);return this}removeHook(...e){let t;if(e[0]===`beforeRequest`)t=this.requestHooks;else if(e[0]===`requestError`)t=this.requestErrorHooks;else if(e[0]===`response`)t=this.responseHooks;else throw Error(`Invalid hook type: ${e[0]}`);let n=t.findIndex(t=>t===e[1]);return n>=0&&t.splice(n,1),this}clone(){let t=new e(this.options);return t.requestHooks=this.requestHooks.slice(),t.requestErrorHooks=this.requestErrorHooks.slice(),t.responseHooks=this.responseHooks.slice(),t}},ee=/\s*;\s*/g;function te(e,t){if(t===`*`)return!0;let n=e.headers.get(`content-type`)?.trim()||`application/octet-stream`;n=n.toLowerCase();let[r=``,...i]=t.toLowerCase().trim().split(ee);if(r.split(`/`).length!==2)return!1;let[a=``,...o]=n.split(ee),[s=``,c=``]=a.split(`/`);if(!s||!c||r!==`*/*`&&a!==r&&`${s}/*`!==r&&`*/${c}`!==r||o.length<i.length)return!1;let l=new Set(o);for(let e of i)if(!l.has(e))return!1;return!0}var ne=RegExp(`^[0-9]xx$`,`i`);function re(e,t){let n=`${e.status}`,r=Array.isArray(t)?t:[t];return r.length?r.some(e=>{let t=`${e}`;if(t===`default`)return!0;if(!ne.test(`${t}`))return t===n;let r=t.charAt(0);if(!r)throw Error(`Invalid status code range`);let i=n.charAt(0);if(!i)throw Error(`Invalid response status code: ${n}`);return i===r}):!1}function ie(e,t,n){return re(e,t)&&te(e,n)}function ae(e){if(typeof e!=`object`||!e)return!1;let t=e instanceof TypeError&&e.message.toLowerCase().startsWith(`failed to fetch`),n=e instanceof TypeError&&e.message.toLowerCase().startsWith(`fetch failed`),r=`name`in e&&e.name===`ConnectionError`,i=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnreset`;return t||n||i||r}function oe(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e&&e.name===`TimeoutError`,n=`code`in e&&e.code===23,r=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnaborted`;return t||n||r}function se(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e&&e.name===`AbortError`,n=`code`in e&&e.code===20,r=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnaborted`;return t||n||r}var ce=class{beforeRequest(e,t){let n=`mistral-client-typescript/${p.sdkVersion}`;return t.headers.set(`user-agent`,n),t.headers.get(`user-agent`)||t.headers.set(`x-mistral-user-agent`,n),t}},le=`x-model-deprecation-timestamp`,ue=class{afterSuccess(e,t){return t.headers.has(le)&&t.clone().json().then(e=>{let n=e.model;console.warn(`WARNING: The model ${n} is deprecated and will be removed on ${t.headers.get(le)}. Please refer to https://docs.mistral.ai/getting-started/models/#api-versioning for more information.`)}),t}};function de(e){let t=new ce;e.registerBeforeRequestHook(t);let n=new ue;e.registerAfterSuccessHook(n)}var fe=class{sdkInitHooks=[];beforeCreateRequestHooks=[];beforeRequestHooks=[];afterSuccessHooks=[];afterErrorHooks=[];constructor(){for(let e of[])`sdkInit`in e&&this.registerSDKInitHook(e),`beforeCreateRequest`in e&&this.registerBeforeCreateRequestHook(e),`beforeRequest`in e&&this.registerBeforeRequestHook(e),`afterSuccess`in e&&this.registerAfterSuccessHook(e),`afterError`in e&&this.registerAfterErrorHook(e);de(this)}registerSDKInitHook(e){this.sdkInitHooks.push(e)}registerBeforeCreateRequestHook(e){this.beforeCreateRequestHooks.push(e)}registerBeforeRequestHook(e){this.beforeRequestHooks.push(e)}registerAfterSuccessHook(e){this.afterSuccessHooks.push(e)}registerAfterErrorHook(e){this.afterErrorHooks.push(e)}sdkInit(e){return this.sdkInitHooks.reduce((e,t)=>t.sdkInit(e),e)}beforeCreateRequest(e,t){let n=t;for(let t of this.beforeCreateRequestHooks)n=t.beforeCreateRequest(e,n);return n}async beforeRequest(e,t){let n=t;for(let t of this.beforeRequestHooks)n=await t.beforeRequest(e,n);return n}async afterSuccess(e,t){let n=t;for(let t of this.afterSuccessHooks)n=await t.afterSuccess(e,n);return n}async afterError(e,t,n){let r=t,i=n;for(let t of this.afterErrorHooks){let n=await t.afterError(e,r,i);r=n.response,i=n.error}return{response:r,error:i}}},pe=class extends Error{cause;name=`HTTPClientError`;constructor(e,t){let n=e;t?.cause&&(n+=`: ${t.cause}`),super(n,t),this.cause===void 0&&(this.cause=t?.cause)}},me=class extends pe{name=`UnexpectedClientError`},he=class extends pe{name=`InvalidRequestError`},ge=class extends pe{name=`RequestAbortedError`},_e=class extends pe{name=`RequestTimeoutError`},ve=class extends pe{name=`ConnectionError`};function ye(e){return{ok:!0,value:e}}function be(e){return{ok:!1,error:e}}async function y(e){let t=await e;if(!t.ok)throw t.error;return t.value}var xe=Object.freeze({status:`aborted`});function b(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Se=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ce=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},we={};function Te(e){return e&&Object.assign(we,e),we}function Ee(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function De(e,t){return typeof t==`bigint`?t.toString():t}function Oe(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function ke(e){return e==null}function Ae(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function je(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var Me=Symbol(`evaluating`);function Ne(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Me)return r===void 0&&(r=Me,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fe(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Ie(e){return JSON.stringify(e)}function Le(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Re=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Be=Oe(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ve(e){if(ze(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ze(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function He(e){return Ve(e)?{...e}:Array.isArray(e)?[...e]:e}var Ue=new Set([`string`,`number`,`symbol`]);function We(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ge(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ke(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var qe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Je(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Ge(e,Fe(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Pe(this,`shape`,e),e},checks:[]}))}function Ye(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Ge(e,Fe(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Pe(this,`shape`,r),r},checks:[]}))}function Xe(e,t){if(!Ve(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ge(e,Fe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pe(this,`shape`,n),n}}))}function Ze(e,t){if(!Ve(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ge(e,Fe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pe(this,`shape`,n),n}}))}function Qe(e,t){return Ge(e,Fe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Pe(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function $e(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Ge(t,Fe(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Pe(this,`shape`,i),i},checks:[]}))}function et(e,t,n){return Ge(t,Fe(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Pe(this,`shape`,i),i}}))}function tt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function nt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function rt(e){return typeof e==`string`?e:e?.message}function it(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=rt(e.inst?._zod.def?.error?.(e))??rt(t?.error?.(e))??rt(n.customError?.(e))??rt(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function at(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ot(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var st=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,De,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},ct=b(`$ZodError`,st),lt=b(`$ZodError`,st,{Parent:Error});function ut(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function dt(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}function ft(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function pt(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${ft(e.path)}`);return t.join(`
|
|
2
2
|
`)}var mt=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Se;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>it(e,a,Te())));throw Re(t,i?.callee),t}return o.value},ht=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>it(e,a,Te())));throw Re(t,i?.callee),t}return o.value},gt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Se;return a.issues.length?{success:!1,error:new(e??ct)(a.issues.map(e=>it(e,i,Te())))}:{success:!0,data:a.value}},_t=gt(lt),vt=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>it(e,i,Te())))}:{success:!0,data:a.value}},yt=vt(lt),bt=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return mt(e)(t,n,i)},xt=e=>(t,n,r)=>mt(e)(t,n,r),St=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ht(e)(t,n,i)},Ct=e=>async(t,n,r)=>ht(e)(t,n,r),wt=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return gt(e)(t,n,i)},Tt=e=>(t,n,r)=>gt(e)(t,n,r),Et=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return vt(e)(t,n,i)},Dt=e=>async(t,n,r)=>vt(e)(t,n,r),Ot=/^[cC][^\s-]{8,}$/,kt=/^[0-9a-z]+$/,At=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jt=/^[0-9a-vA-V]{20}$/,Mt=/^[A-Za-z0-9]{27}$/,Nt=/^[a-zA-Z0-9_-]{21}$/,Pt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ft=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,It=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Lt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rt=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function zt(){return new RegExp(Rt,`u`)}var Bt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ht=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ut=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gt=/^[A-Za-z0-9_-]*$/,Kt=/^\+[1-9]\d{6,14}$/,qt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Jt=RegExp(`^${qt}$`);function Yt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Xt(e){return RegExp(`^${Yt(e)}$`)}function Zt(e){let t=Yt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${qt}T(?:${r})$`)}var Qt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},$t=/^-?\d+$/,en=/^-?\d+(?:\.\d+)?$/,tn=/^(?:true|false)$/i,nn=/^[^A-Z]*$/,rn=/^[^a-z]*$/,an=b(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),on={number:`number`,bigint:`bigint`,object:`date`},sn=b(`$ZodCheckLessThan`,(e,t)=>{an.init(e,t);let n=on[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),cn=b(`$ZodCheckGreaterThan`,(e,t)=>{an.init(e,t);let n=on[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ln=b(`$ZodCheckMultipleOf`,(e,t)=>{an.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):je(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),un=b(`$ZodCheckNumberFormat`,(e,t)=>{an.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=qe[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=$t)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),dn=b(`$ZodCheckMaxLength`,(e,t)=>{var n;an.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ke(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=at(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fn=b(`$ZodCheckMinLength`,(e,t)=>{var n;an.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ke(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=at(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pn=b(`$ZodCheckLengthEquals`,(e,t)=>{var n;an.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ke(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=at(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),mn=b(`$ZodCheckStringFormat`,(e,t)=>{var n,r;an.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hn=b(`$ZodCheckRegex`,(e,t)=>{mn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gn=b(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=nn,mn.init(e,t)}),_n=b(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=rn,mn.init(e,t)}),vn=b(`$ZodCheckIncludes`,(e,t)=>{an.init(e,t);let n=We(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),yn=b(`$ZodCheckStartsWith`,(e,t)=>{an.init(e,t);let n=RegExp(`^${We(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bn=b(`$ZodCheckEndsWith`,(e,t)=>{an.init(e,t);let n=RegExp(`.*${We(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),xn=b(`$ZodCheckOverwrite`,(e,t)=>{an.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Sn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
4
4
|
`))}},Cn={major:4,minor:3,patch:6},wn=b(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cn;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=tt(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Se;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=tt(e,t))});else{if(e.issues.length===t)continue;r||=tt(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(tt(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Se;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Se;return o.then(e=>t(e,r,a))}return t(o,r,a)}}Ne(e,`~standard`,()=>({validate:t=>{try{let n=_t(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return yt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Tn=b(`$ZodString`,(e,t)=>{wn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Qt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),En=b(`$ZodStringFormat`,(e,t)=>{mn.init(e,t),Tn.init(e,t)}),Dn=b(`$ZodGUID`,(e,t)=>{t.pattern??=Ft,En.init(e,t)}),On=b(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=It(e)}else t.pattern??=It();En.init(e,t)}),kn=b(`$ZodEmail`,(e,t)=>{t.pattern??=Lt,En.init(e,t)}),An=b(`$ZodURL`,(e,t)=>{En.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),jn=b(`$ZodEmoji`,(e,t)=>{t.pattern??=zt(),En.init(e,t)}),Mn=b(`$ZodNanoID`,(e,t)=>{t.pattern??=Nt,En.init(e,t)}),Nn=b(`$ZodCUID`,(e,t)=>{t.pattern??=Ot,En.init(e,t)}),Pn=b(`$ZodCUID2`,(e,t)=>{t.pattern??=kt,En.init(e,t)}),Fn=b(`$ZodULID`,(e,t)=>{t.pattern??=At,En.init(e,t)}),In=b(`$ZodXID`,(e,t)=>{t.pattern??=jt,En.init(e,t)}),Ln=b(`$ZodKSUID`,(e,t)=>{t.pattern??=Mt,En.init(e,t)}),Rn=b(`$ZodISODateTime`,(e,t)=>{t.pattern??=Zt(t),En.init(e,t)}),zn=b(`$ZodISODate`,(e,t)=>{t.pattern??=Jt,En.init(e,t)}),Bn=b(`$ZodISOTime`,(e,t)=>{t.pattern??=Xt(t),En.init(e,t)}),Vn=b(`$ZodISODuration`,(e,t)=>{t.pattern??=Pt,En.init(e,t)}),Hn=b(`$ZodIPv4`,(e,t)=>{t.pattern??=Bt,En.init(e,t),e._zod.bag.format=`ipv4`}),Un=b(`$ZodIPv6`,(e,t)=>{t.pattern??=Vt,En.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Wn=b(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ht,En.init(e,t)}),Gn=b(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ut,En.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Kn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var qn=b(`$ZodBase64`,(e,t)=>{t.pattern??=Wt,En.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Kn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Jn(e){if(!Gt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Kn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Yn=b(`$ZodBase64URL`,(e,t)=>{t.pattern??=Gt,En.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Jn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Xn=b(`$ZodE164`,(e,t)=>{t.pattern??=Kt,En.init(e,t)});function Zn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Qn=b(`$ZodJWT`,(e,t)=>{En.init(e,t),e._zod.check=n=>{Zn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),$n=b(`$ZodNumber`,(e,t)=>{wn.init(e,t),e._zod.pattern=e._zod.bag.pattern??en,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),er=b(`$ZodNumberFormat`,(e,t)=>{un.init(e,t),$n.init(e,t)}),tr=b(`$ZodBoolean`,(e,t)=>{wn.init(e,t),e._zod.pattern=tn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),nr=b(`$ZodAny`,(e,t)=>{wn.init(e,t),e._zod.parse=e=>e}),rr=b(`$ZodUnknown`,(e,t)=>{wn.init(e,t),e._zod.parse=e=>e}),ir=b(`$ZodNever`,(e,t)=>{wn.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),ar=b(`$ZodVoid`,(e,t)=>{wn.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),or=b(`$ZodDate`,(e,t)=>{wn.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}});function sr(e,t,n){e.issues.length&&t.issues.push(...nt(n,e.issues)),t.value[n]=e.value}var cr=b(`$ZodArray`,(e,t)=>{wn.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>sr(t,n,e))):sr(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function lr(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...nt(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function ur(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Ke(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function dr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>lr(e,n,i,t,u))):lr(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var fr=b(`$ZodObject`,(e,t)=>{if(wn.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=Oe(()=>ur(t));Ne(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ze,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>lr(n,t,e,s,r))):lr(i,t,e,s,r)}return i?dr(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),pr=b(`$ZodObjectJIT`,(e,t)=>{fr.init(e,t);let n=e._zod.parse,r=Oe(()=>ur(t)),i=e=>{let t=new Sn([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Ie(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Ie(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
|
package/dist/ui/assets/{openai-codex-responses-C9PwP_vv.js → openai-codex-responses-DglthLmz.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./preload-helper-D4M6sveU.js";import{a as t,d as n,n as r,r as i}from"./simple-options-DEbfD_Ko.js";import{o as a}from"./index-
|
|
1
|
+
import{t as e}from"./preload-helper-D4M6sveU.js";import{a as t,d as n,n as r,r as i}from"./simple-options-DEbfD_Ko.js";import{o as a}from"./index-CwOoNoZz.js";import{t as o}from"./headers-BCPSYYop.js";import{n as s,r as c,t as l}from"./openai-responses-shared-BU6CEk9U.js";var u=null;typeof process<`u`&&(process.versions?.node||process.versions?.bun)&&(t=>e(()=>import(t),[]))(`node:os`).then(e=>{u=e});var d=`https://chatgpt.com/backend-api`,f=`https://api.openai.com/auth`,p=3,m=1e3,h=new Set([`openai`,`openai-codex`,`opencode`]),g=new Set([`completed`,`incomplete`,`failed`,`cancelled`,`queued`,`in_progress`]);function _(e,t){return e===429||e===500||e===502||e===503||e===504?!0:/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(t)}function v(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Request was aborted`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Request was aborted`))})})}var y=(e,n,r)=>{let i=new t;return(async()=>{let t={role:`assistant`,content:[],api:`openai-codex-responses`,provider:e.provider,model:e.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 s=r?.apiKey||a(e.provider)||``;if(!s)throw Error(`No API key for provider: ${e.provider}`);let c=J(s),l=x(e,n,r),u=await r?.onPayload?.(l,e);u!==void 0&&(l=u);let d=r?.sessionId||Y(),f=Z(e.headers,r?.headers,c,s,r?.sessionId),h=Q(e.headers,r?.headers,c,s,d),g=JSON.stringify(l),y=r?.transport||`sse`;if(y!==`sse`){let n=!1;try{if(await K(D(e.baseUrl),l,h,t,i,e,()=>{n=!0},r),r?.signal?.aborted)throw Error(`Request was aborted`);i.push({type:`done`,reason:t.stopReason,message:t}),i.end();return}catch(e){if(y===`websocket`||n)throw e}}let b,S;for(let t=0;t<=p;t++){if(r?.signal?.aborted)throw Error(`Request was aborted`);try{if(b=await fetch(E(e.baseUrl),{method:`POST`,headers:f,body:g,signal:r?.signal}),await r?.onResponse?.({status:b.status,headers:o(b.headers)},e),b.ok)break;let n=await b.text();if(t<p&&_(b.status,n)){await v(m*2**t,r?.signal);continue}let i=await q(new Response(n,{status:b.status,statusText:b.statusText}));throw Error(i.friendlyMessage||i.message)}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.message===`Request was aborted`))throw Error(`Request was aborted`);if(S=e instanceof Error?e:Error(String(e)),t<p&&!S.message.includes(`usage limit`)){await v(m*2**t,r?.signal);continue}throw S}}if(!b?.ok)throw S??Error(`Failed after retries`);if(!b.body)throw Error(`No response body`);if(i.push({type:`start`,partial:t}),await O(b,t,i,e,r),r?.signal?.aborted)throw Error(`Request was aborted`);i.push({type:`done`,reason:t.stopReason,message:t}),i.end()}catch(e){for(let e of t.content)delete e.partialJson;t.stopReason=r?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:String(e),i.push({type:`error`,reason:t.stopReason,error:t}),i.end()}})(),i},b=(e,t,o)=>{let s=o?.apiKey||a(e.provider);if(!s)throw Error(`No API key for provider: ${e.provider}`);let c=r(e,o,s),l=n(e)?o?.reasoning:i(o?.reasoning);return y(e,t,{...c,reasoningEffort:l})};function x(e,t,n){let r=l(e,t,h,{includeSystemPrompt:!1}),i={model:e.id,store:!1,stream:!0,instructions:t.systemPrompt,input:r,text:{verbosity:n?.textVerbosity||`medium`},include:[`reasoning.encrypted_content`],prompt_cache_key:n?.sessionId,tool_choice:`auto`,parallel_tool_calls:!0};return n?.temperature!==void 0&&(i.temperature=n.temperature),n?.serviceTier!==void 0&&(i.service_tier=n.serviceTier),t.tools&&(i.tools=s(t.tools,{strict:null})),n?.reasoningEffort!==void 0&&(i.reasoning={effort:S(e.id,n.reasoningEffort),summary:n.reasoningSummary??`auto`}),i}function S(e,t){let n=e.includes(`/`)?e.split(`/`).pop():e;return(n.startsWith(`gpt-5.2`)||n.startsWith(`gpt-5.3`)||n.startsWith(`gpt-5.4`))&&t===`minimal`?`low`:n===`gpt-5.1`&&t===`xhigh`?`high`:n===`gpt-5.1-codex-mini`?t===`high`||t===`xhigh`?`high`:`medium`:t}function C(e){switch(e){case`flex`:return .5;case`priority`:return 2;default:return 1}}function w(e,t){let n=C(t);n!==1&&(e.cost.input*=n,e.cost.output*=n,e.cost.cacheRead*=n,e.cost.cacheWrite*=n,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite)}function T(e,t){return e===`default`&&(t===`flex`||t===`priority`)?t:e??t}function E(e){let t=(e&&e.trim().length>0?e:d).replace(/\/+$/,``);return t.endsWith(`/codex/responses`)?t:t.endsWith(`/codex`)?`${t}/responses`:`${t}/codex/responses`}function D(e){let t=new URL(E(e));return t.protocol===`https:`&&(t.protocol=`wss:`),t.protocol===`http:`&&(t.protocol=`ws:`),t.toString()}async function O(e,t,n,r,i){await c(k(j(e)),t,n,r,{serviceTier:i?.serviceTier,resolveServiceTier:T,applyServiceTierPricing:w})}async function*k(e){for await(let t of e){let e=typeof t.type==`string`?t.type:void 0;if(e){if(e===`error`){let e=t.code||``,n=t.message||``;throw Error(`Codex error: ${n||e||JSON.stringify(t)}`)}if(e===`response.failed`){let e=t.response?.error?.message;throw Error(e||`Codex response failed`)}if(e===`response.done`||e===`response.completed`||e===`response.incomplete`){let e=t.response,n=e&&{...e,status:A(e.status)};yield{...t,type:`response.completed`,response:n};return}yield t}}}function A(e){if(typeof e==`string`)return g.has(e)?e:void 0}async function*j(e){if(!e.body)return;let t=e.body.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
|
|
2
2
|
|
|
3
3
|
`);for(;a!==-1;){let e=r.slice(0,a);r=r.slice(a+2);let t=e.split(`
|
|
4
4
|
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trim());if(t.length>0){let e=t.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,d as t,i as n,n as r,r as i,s as a}from"./simple-options-DEbfD_Ko.js";import{n as o}from"./openai-CuiHR4mv.js";import{a as s,o as c}from"./index-
|
|
1
|
+
import{a as e,d as t,i as n,n as r,r as i,s as a}from"./simple-options-DEbfD_Ko.js";import{n as o}from"./openai-CuiHR4mv.js";import{a as s,o as c}from"./index-CwOoNoZz.js";import{t as l}from"./headers-BCPSYYop.js";import{t as u}from"./sanitize-unicode-ncMKN_SD.js";import{n as d,t as f}from"./github-copilot-headers-BxUvy78-.js";function p(e){for(let t of e)if(t.role===`toolResult`||t.role===`assistant`&&t.content.some(e=>e.type===`toolCall`))return!0;return!1}function m(e){return e.type===`text`}function h(e){return e.type===`thinking`}function g(e){return e.type===`toolCall`}function _(e){return e.type===`image`}function v(e){return e||(typeof process<`u`&&{}.PI_CACHE_RETENTION===`long`?`long`:`short`)}var y=(t,n,r)=>{let i=new e;return(async()=>{let e={role:`assistant`,content:[],api:t.api,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 a=r?.apiKey||c(t.provider)||``,o=L(t),u=v(r?.cacheRetention),d=u===`none`?void 0:r?.sessionId,f=x(t,n,a,r?.headers,d,o),p=S(t,n,r,o,u),m=await r?.onPayload?.(p,t);m!==void 0&&(p=m);let{data:h,response:g}=await f.chat.completions.create(p,{signal:r?.signal}).withResponse();await r?.onResponse?.({status:g.status,headers:l(g.headers)},t),i.push({type:`start`,partial:e});let _=null,y=e.content,b=()=>y.length-1,C=t=>{t&&(t.type===`text`?i.push({type:`text_end`,contentIndex:b(),content:t.text,partial:e}):t.type===`thinking`?i.push({type:`thinking_end`,contentIndex:b(),content:t.thinking,partial:e}):t.type===`toolCall`&&(t.arguments=s(t.partialArgs),delete t.partialArgs,i.push({type:`toolcall_end`,contentIndex:b(),toolCall:t,partial:e})))};for await(let n of h){if(!n||typeof n!=`object`)continue;e.responseId||=n.id,n.usage&&(e.usage=P(n.usage,t));let r=Array.isArray(n.choices)?n.choices[0]:void 0;if(r){if(!n.usage&&r.usage&&(e.usage=P(r.usage,t)),r.finish_reason){let t=F(r.finish_reason);e.stopReason=t.stopReason,t.errorMessage&&(e.errorMessage=t.errorMessage)}if(r.delta){r.delta.content!==null&&r.delta.content!==void 0&&r.delta.content.length>0&&((!_||_.type!==`text`)&&(C(_),_={type:`text`,text:``},e.content.push(_),i.push({type:`text_start`,contentIndex:b(),partial:e})),_.type===`text`&&(_.text+=r.delta.content,i.push({type:`text_delta`,contentIndex:b(),delta:r.delta.content,partial:e})));let t=[`reasoning_content`,`reasoning`,`reasoning_text`],n=null;for(let e of t)if(r.delta[e]!==null&&r.delta[e]!==void 0&&r.delta[e].length>0&&!n){n=e;break}if(n&&((!_||_.type!==`thinking`)&&(C(_),_={type:`thinking`,thinking:``,thinkingSignature:n},e.content.push(_),i.push({type:`thinking_start`,contentIndex:b(),partial:e})),_.type===`thinking`)){let t=r.delta[n];_.thinking+=t,i.push({type:`thinking_delta`,contentIndex:b(),delta:t,partial:e})}if(r?.delta?.tool_calls){for(let t of r.delta.tool_calls)if((!_||_.type!==`toolCall`||t.id&&_.id!==t.id)&&(C(_),_={type:`toolCall`,id:t.id||``,name:t.function?.name||``,arguments:{},partialArgs:``},e.content.push(_),i.push({type:`toolcall_start`,contentIndex:b(),partial:e})),_.type===`toolCall`){t.id&&(_.id=t.id),t.function?.name&&(_.name=t.function.name);let n=``;t.function?.arguments&&(n=t.function.arguments,_.partialArgs+=t.function.arguments,_.arguments=s(_.partialArgs)),i.push({type:`toolcall_delta`,contentIndex:b(),delta:n,partial:e})}}let a=r.delta.reasoning_details;if(a&&Array.isArray(a)){for(let t of a)if(t.type===`reasoning.encrypted`&&t.id&&t.data){let n=e.content.find(e=>e.type===`toolCall`&&e.id===t.id);n&&(n.thoughtSignature=JSON.stringify(t))}}}}}if(C(_),r?.signal?.aborted||e.stopReason===`aborted`)throw Error(`Request was aborted`);if(e.stopReason===`error`)throw Error(e.errorMessage||`Provider returned an error stop reason`);i.push({type:`done`,reason:e.stopReason,message:e}),i.end()}catch(t){for(let t of e.content)delete t.index,delete t.partialArgs;e.stopReason=r?.signal?.aborted?`aborted`:`error`,e.errorMessage=t instanceof Error?t.message:JSON.stringify(t);let n=t?.error?.metadata?.raw;n&&(e.errorMessage+=`\n${n}`),i.push({type:`error`,reason:e.stopReason,error:e}),i.end()}})(),i},b=(e,n,a)=>{let o=a?.apiKey||c(e.provider);if(!o)throw Error(`No API key for provider: ${e.provider}`);let s=r(e,a,o),l=t(e)?a?.reasoning:i(a?.reasoning),u=a?.toolChoice;return y(e,n,{...s,reasoningEffort:l,toolChoice:u})};function x(e,t,n,r,i,a=L(e)){if(!n){if(!{}.OPENAI_API_KEY)throw Error(`OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.`);n={}.OPENAI_API_KEY}let s={...e.headers};if(e.provider===`github-copilot`){let e=d(t.messages),n=f({messages:t.messages,hasImages:e});Object.assign(s,n)}return i&&a.sendSessionAffinityHeaders&&(s.session_id=i,s[`x-client-request-id`]=i,s[`x-session-affinity`]=i),r&&Object.assign(s,r),new o({apiKey:n,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:s})}function S(e,t,n,r=L(e),i=v(n?.cacheRetention)){let a=M(e,t,r),o=w(e,r,i),s={model:e.id,messages:a,stream:!0,prompt_cache_key:e.baseUrl.includes(`api.openai.com`)&&i!==`none`?n?.sessionId:void 0,prompt_cache_retention:e.baseUrl.includes(`api.openai.com`)&&i===`long`?`24h`:void 0};if(r.supportsUsageInStreaming!==!1&&(s.stream_options={include_usage:!0}),r.supportsStore&&(s.store=!1),n?.maxTokens&&(r.maxTokensField===`max_tokens`?s.max_tokens=n.maxTokens:s.max_completion_tokens=n.maxTokens),n?.temperature!==void 0&&(s.temperature=n.temperature),t.tools?(s.tools=N(t.tools,r),r.zaiToolStream&&(s.tool_stream=!0)):p(t.messages)&&(s.tools=[]),o&&T(a,s.tools,o),n?.toolChoice&&(s.tool_choice=n.toolChoice),r.thinkingFormat===`zai`&&e.reasoning)s.enable_thinking=!!n?.reasoningEffort;else if(r.thinkingFormat===`qwen`&&e.reasoning)s.enable_thinking=!!n?.reasoningEffort;else if(r.thinkingFormat===`qwen-chat-template`&&e.reasoning)s.chat_template_kwargs={enable_thinking:!!n?.reasoningEffort,preserve_thinking:!0};else if(r.thinkingFormat===`openrouter`&&e.reasoning){let e=s;n?.reasoningEffort?e.reasoning={effort:C(n.reasoningEffort,r.reasoningEffortMap)}:e.reasoning={effort:`none`}}else n?.reasoningEffort&&e.reasoning&&r.supportsReasoningEffort&&(s.reasoning_effort=C(n.reasoningEffort,r.reasoningEffortMap));if(e.baseUrl.includes(`openrouter.ai`)&&e.compat?.openRouterRouting&&(s.provider=e.compat.openRouterRouting),e.baseUrl.includes(`ai-gateway.vercel.sh`)&&e.compat?.vercelGatewayRouting){let t=e.compat.vercelGatewayRouting;if(t.only||t.order){let e={};t.only&&(e.only=t.only),t.order&&(e.order=t.order),s.providerOptions={gateway:e}}}return s}function C(e,t){return t[e]??e}function w(e,t,n){if(t.cacheControlFormat!==`anthropic`||n===`none`)return;let r=n===`long`&&e.baseUrl.includes(`api.anthropic.com`)?`1h`:void 0;return{type:`ephemeral`,...r?{ttl:r}:{}}}function T(e,t,n){E(e,n),O(t,n),D(e,n)}function E(e,t){for(let n of e)if(n.role===`system`||n.role===`developer`){k(n,t);return}}function D(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if((r.role===`user`||r.role===`assistant`)&&A(r,t))return}}function O(e,t){if(!e||e.length===0)return;let n=e[e.length-1];n.cache_control=t}function k(e,t){return j(e,t)}function A(e,t){return e.role===`user`||e.role===`assistant`?j(e,t):!1}function j(e,t){let n=e.content;if(typeof n==`string`)return n.length===0?!1:(e.content=[{type:`text`,text:n,cache_control:t}],!0);if(!Array.isArray(n))return!1;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r?.type===`text`){let e=r;return e.cache_control=t,!0}}return!1}function M(e,t,r){let i=[],a=t=>{if(t.includes(`|`)){let[e]=t.split(`|`);return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,40)}return e.provider===`openai`&&t.length>40?t.slice(0,40):t},o=n(t.messages,e,e=>a(e));if(t.systemPrompt){let n=e.reasoning&&r.supportsDeveloperRole?`developer`:`system`;i.push({role:n,content:u(t.systemPrompt)})}let s=null;for(let t=0;t<o.length;t++){let n=o[t];if(r.requiresAssistantAfterToolResult&&s===`toolResult`&&n.role===`user`&&i.push({role:`assistant`,content:`I have processed the tool results.`}),n.role===`user`)if(typeof n.content==`string`)i.push({role:`user`,content:u(n.content)});else{let e=n.content.map(e=>e.type===`text`?{type:`text`,text:u(e.text)}:{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}});if(e.length===0)continue;i.push({role:`user`,content:e})}else if(n.role===`assistant`){let e={role:`assistant`,content:r.requiresAssistantAfterToolResult?``:null},t=n.content.filter(m).filter(e=>e.text.trim().length>0).map(e=>({type:`text`,text:u(e.text)})),a=t.map(e=>e.text).join(``),o=n.content.filter(h).filter(e=>e.thinking.trim().length>0);if(o.length>0)if(r.requiresThinkingAsText)e.content=[{type:`text`,text:o.map(e=>u(e.thinking)).join(`
|
|
2
2
|
|
|
3
3
|
`)},...t];else{a.length>0&&(e.content=a);let t=o[0].thinkingSignature;t&&t.length>0&&(e[t]=o.map(e=>e.thinking).join(`
|
|
4
4
|
`))}else a.length>0&&(e.content=a);let s=n.content.filter(g);if(s.length>0){e.tool_calls=s.map(e=>({id:e.id,type:`function`,function:{name:e.name,arguments:JSON.stringify(e.arguments)}}));let t=s.filter(e=>e.thoughtSignature).map(e=>{try{return JSON.parse(e.thoughtSignature)}catch{return null}}).filter(Boolean);t.length>0&&(e.reasoning_details=t)}let c=e.content;if(!(c!=null&&c.length>0)&&!e.tool_calls)continue;i.push(e)}else if(n.role===`toolResult`){let n=[],a=t;for(;a<o.length&&o[a].role===`toolResult`;a++){let t=o[a],s=t.content.filter(m).map(e=>e.text).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,n,r}from"./simple-options-DEbfD_Ko.js";import{n as i}from"./openai-CuiHR4mv.js";import{o as a}from"./index-
|
|
1
|
+
import{a as e,d as t,n,r}from"./simple-options-DEbfD_Ko.js";import{n as i}from"./openai-CuiHR4mv.js";import{o as a}from"./index-CwOoNoZz.js";import{t as o}from"./headers-BCPSYYop.js";import{n as s,t as c}from"./github-copilot-headers-BxUvy78-.js";import{n as l,r as u,t as d}from"./openai-responses-shared-BU6CEk9U.js";var f=new Set([`openai`,`openai-codex`,`opencode`]);function p(e){return e||(typeof process<`u`&&{}.PI_CACHE_RETENTION===`long`?`long`:`short`)}function m(e,t){if(t===`long`&&e.includes(`api.openai.com`))return`24h`}var h=(t,n,r)=>{let i=new e;return(async()=>{let e={role:`assistant`,content:[],api:t.api,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 s=r?.apiKey||a(t.provider)||``,c=p(r?.cacheRetention)===`none`?void 0:r?.sessionId,l=_(t,n,s,r?.headers,c),d=v(t,n,r),f=await r?.onPayload?.(d,t);f!==void 0&&(d=f);let{data:m,response:h}=await l.responses.create(d,r?.signal?{signal:r.signal}:void 0).withResponse();if(await r?.onResponse?.({status:h.status,headers:o(h.headers)},t),i.push({type:`start`,partial:e}),await u(m,e,i,t,{serviceTier:r?.serviceTier,applyServiceTierPricing:b}),r?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(`An unknown error occurred`);i.push({type:`done`,reason:e.stopReason,message:e}),i.end()}catch(t){for(let t of e.content)delete t.index,delete t.partialJson;e.stopReason=r?.signal?.aborted?`aborted`:`error`,e.errorMessage=t instanceof Error?t.message:JSON.stringify(t),i.push({type:`error`,reason:e.stopReason,error:e}),i.end()}})(),i},g=(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 h(e,i,{...c,reasoningEffort:l})};function _(e,t,n,r,a){if(!n){if(!{}.OPENAI_API_KEY)throw Error(`OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.`);n={}.OPENAI_API_KEY}let o={...e.headers};if(e.provider===`github-copilot`){let e=s(t.messages),n=c({messages:t.messages,hasImages:e});Object.assign(o,n)}return a&&(o.session_id=a,o[`x-client-request-id`]=a),r&&Object.assign(o,r),new i({apiKey:n,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:o})}function v(e,t,n){let r=d(e,t,f),i=p(n?.cacheRetention),a={model:e.id,input:r,stream:!0,prompt_cache_key:i===`none`?void 0:n?.sessionId,prompt_cache_retention:m(e.baseUrl,i),store:!1};return n?.maxTokens&&(a.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(a.temperature=n?.temperature),n?.serviceTier!==void 0&&(a.service_tier=n.serviceTier),t.tools&&(a.tools=l(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(a.reasoning={effort:n?.reasoningEffort||`medium`,summary:n?.reasoningSummary||`auto`},a.include=[`reasoning.encrypted_content`]):e.provider!==`github-copilot`&&(a.reasoning={effort:`none`})),a}function y(e){switch(e){case`flex`:return .5;case`priority`:return 2;default:return 1}}function b(e,t){let n=y(t);n!==1&&(e.cost.input*=n,e.cost.output*=n,e.cost.cacheRead*=n,e.cost.cacheWrite*=n,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite)}export{h as streamOpenAIResponses,g as streamSimpleOpenAIResponses};
|
package/dist/ui/assets/{openai-responses-shared-DhRsugmK.js → openai-responses-shared-BU6CEk9U.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,s as t}from"./simple-options-DEbfD_Ko.js";import{a as n}from"./index-
|
|
1
|
+
import{i as e,s as t}from"./simple-options-DEbfD_Ko.js";import{a as n}from"./index-CwOoNoZz.js";import{t as r}from"./sanitize-unicode-ncMKN_SD.js";import{t as i}from"./hash-BwzabXYv.js";function a(e,t){let n={v:1,id:e};return t&&(n.phase=t),JSON.stringify(n)}function o(e){if(e){if(e.startsWith(`{`))try{let t=JSON.parse(e);if(t.v===1&&typeof t.id==`string`)return t.phase===`commentary`||t.phase===`final_answer`?{id:t.id,phase:t.phase}:{id:t.id}}catch{}return{id:e}}}function s(t,n,a,s){let c=[],l=e=>{let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);return(t.length>64?t.slice(0,64):t).replace(/_+$/,``)},u=e=>{let t=`fc_${i(e)}`;return t.length>64?t.slice(0,64):t},d=e(n.messages,t,(e,n,r)=>{if(!a.has(t.provider)||!e.includes(`|`))return l(e);let[i,o]=e.split(`|`),s=l(i),c=r.provider!==t.provider||r.api!==t.api?u(o):l(o);return c.startsWith(`fc_`)||(c=l(`fc_${c}`)),`${s}|${c}`});if((s?.includeSystemPrompt??!0)&&n.systemPrompt){let e=t.reasoning?`developer`:`system`;c.push({role:e,content:r(n.systemPrompt)})}let f=0;for(let e of d){if(e.role===`user`)if(typeof e.content==`string`)c.push({role:`user`,content:[{type:`input_text`,text:r(e.content)}]});else{let t=e.content.map(e=>e.type===`text`?{type:`input_text`,text:r(e.text)}:{type:`input_image`,detail:`auto`,image_url:`data:${e.mimeType};base64,${e.data}`});if(t.length===0)continue;c.push({role:`user`,content:t})}else if(e.role===`assistant`){let n=[],a=e,s=a.model!==t.id&&a.provider===t.provider&&a.api===t.api;for(let t of e.content)if(t.type===`thinking`){if(t.thinkingSignature){let e=JSON.parse(t.thinkingSignature);n.push(e)}}else if(t.type===`text`){let e=t,a=o(e.textSignature),s=a?.id;s?s.length>64&&(s=`msg_${i(s)}`):s=`msg_${f}`,n.push({type:`message`,role:`assistant`,content:[{type:`output_text`,text:r(e.text),annotations:[]}],status:`completed`,id:s,phase:a?.phase})}else if(t.type===`toolCall`){let e=t,[r,i]=e.id.split(`|`),a=i;s&&a?.startsWith(`fc_`)&&(a=void 0),n.push({type:`function_call`,id:a,call_id:r,name:e.name,arguments:JSON.stringify(e.arguments)})}if(n.length===0)continue;c.push(...n)}else if(e.role===`toolResult`){let n=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2
2
|
`),i=e.content.some(e=>e.type===`image`),a=n.length>0,[o]=e.toolCallId.split(`|`),s;if(i&&t.input.includes(`image`)){let t=[];a&&t.push({type:`input_text`,text:r(n)});for(let n of e.content)n.type===`image`&&t.push({type:`input_image`,detail:`auto`,image_url:`data:${n.mimeType};base64,${n.data}`});s=t}else s=r(a?n:`(see attached image)`);c.push({type:`function_call_output`,call_id:o,output:s})}f++}return c}function c(e,t){let n=t?.strict===void 0?!1:t.strict;return e.map(e=>({type:`function`,name:e.name,description:e.description,parameters:e.parameters,strict:n}))}async function l(e,r,i,o,s){let c=null,l=null,d=r.content,f=()=>d.length-1;for await(let d of e)if(d.type===`response.created`)r.responseId=d.response.id;else if(d.type===`response.output_item.added`){let e=d.item;e.type===`reasoning`?(c=e,l={type:`thinking`,thinking:``},r.content.push(l),i.push({type:`thinking_start`,contentIndex:f(),partial:r})):e.type===`message`?(c=e,l={type:`text`,text:``},r.content.push(l),i.push({type:`text_start`,contentIndex:f(),partial:r})):e.type===`function_call`&&(c=e,l={type:`toolCall`,id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||``},r.content.push(l),i.push({type:`toolcall_start`,contentIndex:f(),partial:r}))}else if(d.type===`response.reasoning_summary_part.added`)c&&c.type===`reasoning`&&(c.summary=c.summary||[],c.summary.push(d.part));else if(d.type===`response.reasoning_summary_text.delta`){if(c?.type===`reasoning`&&l?.type===`thinking`){c.summary=c.summary||[];let e=c.summary[c.summary.length-1];e&&(l.thinking+=d.delta,e.text+=d.delta,i.push({type:`thinking_delta`,contentIndex:f(),delta:d.delta,partial:r}))}}else if(d.type===`response.reasoning_summary_part.done`){if(c?.type===`reasoning`&&l?.type===`thinking`){c.summary=c.summary||[];let e=c.summary[c.summary.length-1];e&&(l.thinking+=`
|
|
3
3
|
|
|
4
4
|
`,e.text+=`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/anthropic-
|
|
2
|
-
import{a as e,n as t,o as n,r,t as i}from"./chunk-jRWAZmH_.js";import{t as a}from"./logger-B-No_qN_.js";import{t as o}from"./preload-helper-D4M6sveU.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,t as h,u as g}from"./simple-options-DEbfD_Ko.js";import{t as _}from"./openai-CuiHR4mv.js";import{c as v,i as y,n as b,r as x,s as S}from"./index-B87TbZRu.js";var C=new Map;function w(e,t){return(n,r,i)=>{if(n.api!==e)throw Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,r,i)}}function T(e,t){return(n,r,i)=>{if(n.api!==e)throw Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,r,i)}}function E(e,t){C.set(e.api,{provider:{api:e.api,stream:w(e.api,e.stream),streamSimple:T(e.api,e.streamSimple)},sourceId:t})}function D(e){return C.get(e)?.provider}var O=e=>o(()=>import(e),[]),k,A,j,M,N,P,ee,F,I,te,ne;function re(e,t){(async()=>{for await(let n of t)e.push(n);e.end()})()}function ie(e,t){return{role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function L(e){return(t,n,r)=>{let i=new s;return e().then(e=>{re(i,e.stream(t,n,r))}).catch(e=>{let n=ie(t,e);i.push({type:`error`,reason:`error`,error:n}),i.end(n)}),i}}function R(e){return(t,n,r)=>{let i=new s;return e().then(e=>{re(i,e.streamSimple(t,n,r))}).catch(e=>{let n=ie(t,e);i.push({type:`error`,reason:`error`,error:n}),i.end(n)}),i}}function ae(){return k||=o(()=>import(`./anthropic-H12_Atst.js`).then(e=>{let t=e;return{stream:t.streamAnthropic,streamSimple:t.streamSimpleAnthropic}}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),k}function oe(){return A||=o(()=>import(`./azure-openai-responses-BFJMXroi.js`).then(e=>{let t=e;return{stream:t.streamAzureOpenAIResponses,streamSimple:t.streamSimpleAzureOpenAIResponses}}),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,16,17,14,13,18])),A}function se(){return j||=o(()=>import(`./google-CBNil8p2.js`).then(e=>{let t=e;return{stream:t.streamGoogle,streamSimple:t.streamSimpleGoogle}}),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,20,11,14])),j}function ce(){return M||=o(()=>import(`./google-gemini-cli-CBH9v3m0.js`).then(e=>{let t=e;return{stream:t.streamGoogleGeminiCli,streamSimple:t.streamSimpleGoogleGeminiCli}}),__vite__mapDeps([21,20,2,11,14,13])),M}function le(){return N||=o(()=>import(`./google-vertex-BrN3Tz3e.js`).then(e=>{let t=e;return{stream:t.streamGoogleVertex,streamSimple:t.streamSimpleGoogleVertex}}),__vite__mapDeps([22,20,2,11,14])),N}function ue(){return P||=o(()=>import(`./mistral-ROS5ivdx.js`).then(e=>{let t=e;return{stream:t.streamMistral,streamSimple:t.streamSimpleMistral}}),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,10,11,17,14])),P}function de(){return ee||=o(()=>import(`./openai-codex-responses-C9PwP_vv.js`).then(e=>{let t=e;return{stream:t.streamOpenAICodexResponses,streamSimple:t.streamSimpleOpenAICodexResponses}}),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,11,16,17,14,13])),ee}function fe(){return F||=o(()=>import(`./openai-completions-C6XmF6cd.js`).then(e=>{let t=e;return{stream:t.streamOpenAICompletions,streamSimple:t.streamSimpleOpenAICompletions}}),__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18])),F}function pe(){return I||=o(()=>import(`./openai-responses-C5uhM4oI.js`).then(e=>{let t=e;return{stream:t.streamOpenAIResponses,streamSimple:t.streamSimpleOpenAIResponses}}),__vite__mapDeps([26,1,2,3,4,5,6,7,8,9,10,11,12,16,17,14,13,18])),I}function me(){return te?Promise.resolve(te):(ne||=O(`./amazon-bedrock.js`).then(e=>{let t=e;return{stream:t.streamBedrock,streamSimple:t.streamSimpleBedrock}}),ne)}var he=L(ae),ge=R(ae),_e=L(oe),ve=R(oe),ye=L(se),be=R(se),xe=L(ce),Se=R(ce),Ce=L(le),we=R(le),Te=L(ue),Ee=R(ue),De=L(de),Oe=R(de),ke=L(fe),Ae=R(fe),je=L(pe),Me=R(pe),Ne=L(me),Pe=R(me);function Fe(){E({api:`anthropic-messages`,stream:he,streamSimple:ge}),E({api:`openai-completions`,stream:ke,streamSimple:Ae}),E({api:`mistral-conversations`,stream:Te,streamSimple:Ee}),E({api:`openai-responses`,stream:je,streamSimple:Me}),E({api:`azure-openai-responses`,stream:_e,streamSimple:ve}),E({api:`openai-codex-responses`,stream:De,streamSimple:Oe}),E({api:`google-generative-ai`,stream:ye,streamSimple:be}),E({api:`google-gemini-cli`,stream:xe,streamSimple:Se}),E({api:`google-vertex`,stream:Ce,streamSimple:we}),E({api:`bedrock-converse-stream`,stream:Ne,streamSimple:Pe})}Fe();function Ie(e){let t=D(e);if(!t)throw Error(`No API provider registered for api: ${e}`);return t}function Le(e,t,n){return Ie(e.api).streamSimple(e,t,n)}async function Re(e,t,n){return Le(e,t,n).result()}var ze=[/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i],Be=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function Ve(e,t){return!!(e.stopReason===`error`&&e.errorMessage&&!Be.some(t=>t.test(e.errorMessage))&&ze.some(t=>t.test(e.errorMessage))||t&&e.stopReason===`stop`&&e.usage.input+e.usage.cacheRead>t)}var He=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Ue=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=He(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),z=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=He(),n=Ue(),r=He();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=Ue();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/anthropic-CMVA8z4u.js","assets/index-CwOoNoZz.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-D4M6sveU.js","assets/constants-BnzYaC4L.js","assets/logger-B-No_qN_.js","assets/path-utils-CgbXfwyO.js","assets/db-ybNEUfR8.js","assets/magick-wasm-BtLTRPKb.js","assets/skills-O_vTBFE5.js","assets/index-Bj1XpXDE.css","assets/simple-options-DEbfD_Ko.js","assets/github-copilot-headers-BxUvy78-.js","assets/headers-BCPSYYop.js","assets/sanitize-unicode-ncMKN_SD.js","assets/azure-openai-responses-BcVCOWjr.js","assets/openai-responses-shared-BU6CEk9U.js","assets/hash-BwzabXYv.js","assets/openai-CuiHR4mv.js","assets/google-CJIGxdKe.js","assets/google-shared-jyMmIrwc.js","assets/google-gemini-cli-CBH9v3m0.js","assets/google-vertex-BrN3Tz3e.js","assets/mistral-BO8fQ2lz.js","assets/openai-codex-responses-DglthLmz.js","assets/openai-completions-B9-2Retb.js","assets/openai-responses-Bay2AY5u.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,n as t,o as n,r,t as i}from"./chunk-jRWAZmH_.js";import{t as a}from"./logger-B-No_qN_.js";import{t as o}from"./preload-helper-D4M6sveU.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,t as h,u as g}from"./simple-options-DEbfD_Ko.js";import{t as _}from"./openai-CuiHR4mv.js";import{c as v,i as y,n as b,r as x,s as S}from"./index-CwOoNoZz.js";var C=new Map;function w(e,t){return(n,r,i)=>{if(n.api!==e)throw Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,r,i)}}function T(e,t){return(n,r,i)=>{if(n.api!==e)throw Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,r,i)}}function E(e,t){C.set(e.api,{provider:{api:e.api,stream:w(e.api,e.stream),streamSimple:T(e.api,e.streamSimple)},sourceId:t})}function D(e){return C.get(e)?.provider}var O=e=>o(()=>import(e),[]),k,A,j,M,N,P,ee,F,I,te,ne;function re(e,t){(async()=>{for await(let n of t)e.push(n);e.end()})()}function ie(e,t){return{role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function L(e){return(t,n,r)=>{let i=new s;return e().then(e=>{re(i,e.stream(t,n,r))}).catch(e=>{let n=ie(t,e);i.push({type:`error`,reason:`error`,error:n}),i.end(n)}),i}}function R(e){return(t,n,r)=>{let i=new s;return e().then(e=>{re(i,e.streamSimple(t,n,r))}).catch(e=>{let n=ie(t,e);i.push({type:`error`,reason:`error`,error:n}),i.end(n)}),i}}function ae(){return k||=o(()=>import(`./anthropic-CMVA8z4u.js`).then(e=>{let t=e;return{stream:t.streamAnthropic,streamSimple:t.streamSimpleAnthropic}}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),k}function oe(){return A||=o(()=>import(`./azure-openai-responses-BcVCOWjr.js`).then(e=>{let t=e;return{stream:t.streamAzureOpenAIResponses,streamSimple:t.streamSimpleAzureOpenAIResponses}}),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,16,17,14,13,18])),A}function se(){return j||=o(()=>import(`./google-CJIGxdKe.js`).then(e=>{let t=e;return{stream:t.streamGoogle,streamSimple:t.streamSimpleGoogle}}),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,20,11,14])),j}function ce(){return M||=o(()=>import(`./google-gemini-cli-CBH9v3m0.js`).then(e=>{let t=e;return{stream:t.streamGoogleGeminiCli,streamSimple:t.streamSimpleGoogleGeminiCli}}),__vite__mapDeps([21,20,2,11,14,13])),M}function le(){return N||=o(()=>import(`./google-vertex-BrN3Tz3e.js`).then(e=>{let t=e;return{stream:t.streamGoogleVertex,streamSimple:t.streamSimpleGoogleVertex}}),__vite__mapDeps([22,20,2,11,14])),N}function ue(){return P||=o(()=>import(`./mistral-BO8fQ2lz.js`).then(e=>{let t=e;return{stream:t.streamMistral,streamSimple:t.streamSimpleMistral}}),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,10,11,17,14])),P}function de(){return ee||=o(()=>import(`./openai-codex-responses-DglthLmz.js`).then(e=>{let t=e;return{stream:t.streamOpenAICodexResponses,streamSimple:t.streamSimpleOpenAICodexResponses}}),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,11,16,17,14,13])),ee}function fe(){return F||=o(()=>import(`./openai-completions-B9-2Retb.js`).then(e=>{let t=e;return{stream:t.streamOpenAICompletions,streamSimple:t.streamSimpleOpenAICompletions}}),__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18])),F}function pe(){return I||=o(()=>import(`./openai-responses-Bay2AY5u.js`).then(e=>{let t=e;return{stream:t.streamOpenAIResponses,streamSimple:t.streamSimpleOpenAIResponses}}),__vite__mapDeps([26,1,2,3,4,5,6,7,8,9,10,11,12,16,17,14,13,18])),I}function me(){return te?Promise.resolve(te):(ne||=O(`./amazon-bedrock.js`).then(e=>{let t=e;return{stream:t.streamBedrock,streamSimple:t.streamSimpleBedrock}}),ne)}var he=L(ae),ge=R(ae),_e=L(oe),ve=R(oe),ye=L(se),be=R(se),xe=L(ce),Se=R(ce),Ce=L(le),we=R(le),Te=L(ue),Ee=R(ue),De=L(de),Oe=R(de),ke=L(fe),Ae=R(fe),je=L(pe),Me=R(pe),Ne=L(me),Pe=R(me);function Fe(){E({api:`anthropic-messages`,stream:he,streamSimple:ge}),E({api:`openai-completions`,stream:ke,streamSimple:Ae}),E({api:`mistral-conversations`,stream:Te,streamSimple:Ee}),E({api:`openai-responses`,stream:je,streamSimple:Me}),E({api:`azure-openai-responses`,stream:_e,streamSimple:ve}),E({api:`openai-codex-responses`,stream:De,streamSimple:Oe}),E({api:`google-generative-ai`,stream:ye,streamSimple:be}),E({api:`google-gemini-cli`,stream:xe,streamSimple:Se}),E({api:`google-vertex`,stream:Ce,streamSimple:we}),E({api:`bedrock-converse-stream`,stream:Ne,streamSimple:Pe})}Fe();function Ie(e){let t=D(e);if(!t)throw Error(`No API provider registered for api: ${e}`);return t}function Le(e,t,n){return Ie(e.api).streamSimple(e,t,n)}async function Re(e,t,n){return Le(e,t,n).result()}var ze=[/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i],Be=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function Ve(e,t){return!!(e.stopReason===`error`&&e.errorMessage&&!Be.some(t=>t.test(e.errorMessage))&&ze.some(t=>t.test(e.errorMessage))||t&&e.stopReason===`stop`&&e.usage.input+e.usage.cacheRead>t)}var He=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Ue=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=He(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),z=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=He(),n=Ue(),r=He();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=Ue();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
3
3
|
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${I(e)}`}e.not=j;var M=F(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=F(e.operators.OR);function ee(...e){return e.reduce(P)}e.or=ee;function F(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${I(n)} ${e} ${I(r)}`}function I(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),B=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=z(),n=He();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),V=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=z();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),We=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=z(),n=B(),r=V();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Ge=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=We(),n=z(),r=V(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),Ke=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),qe=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Je=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=Ke(),n=qe(),r=We(),i=z(),a=B(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
4
4
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
5
5
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,d as r,f as i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./constants-BnzYaC4L.js";import{r as f,t as p}from"./path-utils-CgbXfwyO.js";import"./index-
|
|
1
|
+
import{r as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,d as r,f as i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./constants-BnzYaC4L.js";import{r as f,t as p}from"./path-utils-CgbXfwyO.js";import"./index-CwOoNoZz.js";function m(e){let t={},n=e.split(`
|
|
2
2
|
`),r=null,i=!1,a={},o=null;for(let e of n){let n=e.trim();if(!n||n.startsWith(`#`))continue;if(n.startsWith(`- `)){let e=n.slice(2).trim();i&&o?o.push(e):r&&r.push(e);continue}let s=n.indexOf(`:`);if(s===-1)continue;let c=n.slice(0,s).trim(),l=n.slice(s+1).trim(),u=e.search(/\S/);if(c===`structured`){i=!0,a={},t.structured=a;continue}if(i&&u>=2){if(u>=4&&o)continue;l===``||l===`[]`?(o=[],a[c]=o):(a[c]=l,o=null);continue}u===0&&(i=!1),l===``||l===`[]`?(r=[],t[c]=r):(t[c]=l,r=null)}return t}function h(e,t=u){let n=m(e);if(!n.skill||typeof n.skill!=`string`)throw Error(`Invalid manifest: missing 'skill' field in ${t}`);if(!n.version||typeof n.version!=`string`)throw Error(`Invalid manifest: missing 'version' field in ${t}`);return{skill:n.skill,version:n.version,description:n.description||``,adds:n.adds||[],modifies:n.modifies||[],structured:n.structured,conflicts:n.conflicts||[],depends:n.depends||[],test:n.test,author:n.author}}async function g(e,t){let n=`${t}/${u}`;return h(await e.readTextFile(n),n)}function _(e,t){let n=(e.depends||[]).filter(e=>!t.includes(e));return{ok:n.length===0,missing:n}}function v(e,t){let n=(e.conflicts||[]).filter(e=>t.includes(e));return{ok:n.length===0,conflicting:n}}var y=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,b=class extends Error{};function x(e){return new TextDecoder().decode(e)}function S(e){let t=e.replace(/\\/g,`/`);if(!t||t.endsWith(`/`))return null;if(t.startsWith(`/`)||/^[A-Za-z]:\//.test(t))throw Error(`Blocked suspicious path "${e}".`);let n=t.split(`/`);if(n.some(e=>e===``||e===`.`||e===`..`))throw Error(`Blocked suspicious path "${e}".`);return n.join(`/`)}function ee(e){if(!y.test(e))throw Error(`Invalid manifest: skill name "${e}" must be a simple directory name.`)}function C(e){let t=[];for(let[n,r]of Object.entries(e)){let e=S(n);e&&t.push({originalPath:n,path:e,bytes:r})}return t}function w(e){let t=e.filter(e=>e.path===`manifest.yaml`||e.path.endsWith(`/manifest.yaml`));if(t.length===0)throw Error(`Skill archive is missing ${u}.`);if(t.length>1)throw Error(`Skill archive contains multiple ${u} files.`);return t[0]}function T(e){let t=0,n=0;return i(e,{filter(e){if(t++,t>1e3)throw new b(`Skill archives may contain at most ${o} entries.`);if(n+=e.originalSize,n>52428800)throw new b(`Skill archives must expand to 50 MB or smaller after extraction.`);return!0}})}function E(e){return p(r,`.${e}.tmp-${`${Date.now()}-${Math.random().toString(16).slice(2,8)}`}`)}async function D(e,t){if(!t.name.toLowerCase().endsWith(`.skill`))throw Error(`Only ${l} archives can be installed with drag and drop.`);if(t.size>52428800)throw Error(`Skill archives must be 50 MB or smaller.`);let n;try{n=T(new Uint8Array(await t.arrayBuffer()))}catch(e){if(e instanceof b)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Invalid .skill archive: ${t}`)}let i=C(n),a=w(i),o=h(x(a.bytes),a.path);ee(o.skill);let s=p(r,o.skill);if(await e.exists(s))throw Error(`Skill "${o.skill}" already exists at ${s}.`);let c=E(o.skill),d=a.path===`manifest.yaml`?``:a.path.slice(0,-(u.length+1));await e.mkdir(c,{recursive:!0});try{let t=0;for(let n of i){if(d&&(n.path===d||!n.path.startsWith(`${d}/`)))continue;let r=d?n.path.slice(d.length+1):n.path;if(!r)continue;let i=p(c,r),{dir:a}=f(i);a!==`/`&&await e.mkdir(a,{recursive:!0}),await e.writeFile(i,n.bytes),t++}return await e.rename(c,s),{skillName:o.skill,destinationPath:s,fileCount:t}}catch(t){throw await e.exists(c)&&await e.rm(c,{recursive:!0}),t}}var O=`/${a}/${d}`;async function k(e){try{await e.mkdir(`/${a}`)}catch{}try{await e.stat(O)}catch{let t={version:s,applied_skills:[]};await e.writeFile(O,JSON.stringify(t,null,2))}}async function A(e){try{let t=await e.readTextFile(O);return JSON.parse(t)}catch(e){if(typeof e==`object`&&e&&e.code===`ENOENT`)return{version:s,applied_skills:[]};throw e}}async function j(e,t){await k(e),await e.writeFile(O,JSON.stringify(t,null,2))}async function M(e){return(await A(e)).applied_skills.map(e=>e.name)}async function N(e,t){let n=await A(e);n.applied_skills=n.applied_skills.filter(e=>e.name!==t.name),n.applied_skills.push(t),await j(e,n)}async function te(e,t){let n=await A(e);n.applied_skills=n.applied_skills.filter(e=>e.name!==t),await j(e,n)}async function P(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function F(e){return e.startsWith(`/`)?{valid:!1,error:`Absolute path not allowed: ${e}`}:e.split(`/`).some(e=>e===`..`)?{valid:!1,error:`Path traversal not allowed: ${e}`}:e.includes(`%2e%2e`)||e.includes(`%2E%2E`)?{valid:!1,error:`Encoded path traversal not allowed: ${e}`}:{valid:!0}}async function I(e,t){let n=t.split(`/`).filter(Boolean),r=``;for(let t of n){r+=`/`+t;try{await e.mkdir(r)}catch{}}}async function L(e,t,n=`/workspace/skills`){let r=`${n}/${t}`;await k(e);let i;try{i=await g(e,r)}catch(e){return{success:!1,skill:t,version:`unknown`,error:`Failed to read manifest: ${e instanceof Error?e.message:String(e)}`}}if(i.skill!==t)return{success:!1,skill:t,version:i.version,error:`Manifest skill name "${i.skill}" does not match directory name "${t}"`};let a=await M(e);if(a.includes(i.skill))return{success:!1,skill:i.skill,version:i.version,error:`Skill "${i.skill}" is already installed`};let o=_(i,a);if(!o.ok)return{success:!1,skill:i.skill,version:i.version,error:`Missing dependencies: ${o.missing.join(`, `)}`};let s=v(i,a);if(!s.ok)return{success:!1,skill:i.skill,version:i.version,error:`Conflicting skills: ${s.conflicting.join(`, `)}`};let c={},l=[];try{if(i.adds&&i.adds.length>0)for(let t of i.adds){let n=F(t);if(!n.valid)return{success:!1,skill:i.skill,version:i.version,error:n.error};let a=`${r}/add/${t}`,o=`/${t}`;try{let n=o.substring(0,o.lastIndexOf(`/`));n&&await I(e,n),await e.copyFile(a,o),l.push(t),c[t]=await P(await e.readTextFile(o))}catch(e){return{success:!1,skill:i.skill,version:i.version,error:`Failed to copy ${t}: ${e instanceof Error?e.message:String(e)}`}}}if(i.modifies&&i.modifies.length>0)for(let t of i.modifies){let n=F(t);if(!n.valid)return{success:!1,skill:i.skill,version:i.version,error:n.error};let a=`${r}/modify/${t}`;try{let n=await e.readTextFile(a),r=``;try{r=await e.readTextFile(`/${t}`)}catch{}let i;if(n.includes(`// APPEND_AFTER:`)){let e=n.split(`
|
|
3
3
|
`),t=e.find(e=>e.includes(`// APPEND_AFTER:`))?.split(`// APPEND_AFTER:`)[1]?.trim(),a=e.filter(e=>!e.includes(`// APPEND_AFTER:`)).join(`
|
|
4
4
|
`);if(t&&r.includes(t)){let e=r.indexOf(t)+t.length,n=r.indexOf(`
|
package/dist/ui/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CwOoNoZz.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-jRWAZmH_.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-D4M6sveU.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/constants-BnzYaC4L.js">
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/path-utils-CgbXfwyO.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/db-ybNEUfR8.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/magick-wasm-BtLTRPKb.js">
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/skills-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/skills-O_vTBFE5.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/index-CwOoNoZz.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/simple-options-DEbfD_Ko.js">
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/openai-CuiHR4mv.js">
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/provider-settings-
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/provider-settings-lbdVYpIy.js">
|
|
21
21
|
<link rel="stylesheet" crossorigin href="/assets/index-Bj1XpXDE.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body>
|