@theoremjs/studio 0.3.4-next.594.g145ceaf → 0.3.4-next.596.g481e1de

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +4 -4
  2. package/page/assets/{Banner-Dkm55rrw.js → Banner-CHeVMGoC.js} +3 -3
  3. package/page/assets/{ConsoleFrame-XWi4s16A.js → ConsoleFrame-Dda6SBPG.js} +1 -1
  4. package/page/assets/{ContextMenu-nPJ1PmDc.js → ContextMenu-C495-aZp.js} +2 -2
  5. package/page/assets/{MenuBottomSheet-oyHffLg2.js → MenuBottomSheet-aMEz6yoB.js} +1 -1
  6. package/page/assets/{SchemaFields-NVbu5_Cc.js → SchemaFields-DcDcvpsG.js} +1 -1
  7. package/page/assets/{ToolResultCharts-DeOf41wr.js → ToolResultCharts-aA2wFbId.js} +1 -1
  8. package/page/assets/{TraceInspector-CEJ8vkzk.js → TraceInspector-5ry_XWrM.js} +1 -1
  9. package/page/assets/{TraceOverview-Bnxm8Qgn.js → TraceOverview-Bm9BhnMp.js} +1 -1
  10. package/page/assets/{_virtual_studio-type-sources-BMmGKxQj.js → _virtual_studio-type-sources-BOljuYdZ.js} +3 -2
  11. package/page/assets/{browser-connection-eDifgoWE.js → browser-connection-BIUInCkF.js} +1 -1
  12. package/page/assets/browser-engine-DwNilPPx.js +11 -0
  13. package/page/assets/{browser-transport-BkryJMUS.js → browser-transport-D1j81h5x.js} +3 -3
  14. package/page/assets/{crypto-DnfkNtVa.js → crypto-qwXH_zFb.js} +1 -1
  15. package/page/assets/{encode-files-IayGPudJ.js → encode-files-v-W0DoVP.js} +1 -1
  16. package/page/assets/{export-agent-RCGd6JeA.js → export-agent-DAaryvB-.js} +1 -1
  17. package/page/assets/{guardrail-tester-C6UIAkIc.js → guardrail-tester-DlyBh4uQ.js} +1 -1
  18. package/page/assets/{index-DUyKTFWY.js → index-CTD7Bm4u.js} +7 -7
  19. package/page/assets/{live-messages-CZ4TB1Hc.js → live-messages-DNJY4_6_.js} +1 -1
  20. package/page/assets/{reader-8K9hS7XK.js → reader-DhxMA39i.js} +1 -1
  21. package/page/assets/{shaped-data-CF9zpotl.js → shaped-data-BO6EAfYh.js} +3 -3
  22. package/page/assets/{stub-BNZkgJpl.js → stub-CWWsL_k2.js} +1 -1
  23. package/page/assets/{studio-code-pane-DycfLQyz.js → studio-code-pane-DVvvv8F_.js} +3 -3
  24. package/page/assets/{studio-console-CmrNxi-E.js → studio-console-Bgo9j6-O.js} +1 -1
  25. package/page/assets/{studio-decision-D57UEh9l.js → studio-decision-DMAwsopk.js} +1 -1
  26. package/page/assets/{studio-embedding-CphomSV5.js → studio-embedding-DDPNL0_7.js} +1 -1
  27. package/page/assets/{studio-host-console-BRxKjfdn.js → studio-host-console-CSY1Fe84.js} +2 -2
  28. package/page/assets/{studio-labels-_aj9SVGX.js → studio-labels-TTCu8mYo.js} +1 -1
  29. package/page/assets/{studio-live-CiYmwoKl.js → studio-live-fMKQMfJP.js} +1 -1
  30. package/page/assets/{studio-map-CdQeXRQE.js → studio-map-abMXWAJe.js} +1 -1
  31. package/page/assets/{studio-trace-replay-jWMT1G-k.js → studio-trace-replay-CF0qyy1C.js} +1 -1
  32. package/page/assets/{studio-type-checker-DgnARQpA.js → studio-type-checker-BPZzvJmB.js} +1 -1
  33. package/page/assets/{tool-schema-CjkdSYeP.js → tool-schema-CSmvha7v.js} +1 -1
  34. package/page/assets/{trace-record-BA7Hqh6Z.js → trace-record-DjsOJFNa.js} +1 -1
  35. package/page/assets/{tree-BBGNZ3t7.js → tree-OCi2Y2Hk.js} +1 -1
  36. package/page/assets/{turn-client-Dj4sJ3Af.js → turn-client-d6laDQzK.js} +1 -1
  37. package/page/assets/{use-one-call-CjErskao.js → use-one-call-9B17zBP3.js} +1 -1
  38. package/page/assets/{use-second-ticker-BGYZC1eY.js → use-second-ticker-Csf4IJNZ.js} +1 -1
  39. package/page/assets/{workspace-9VIzjsm8.js → workspace-BLQkQuMh.js} +1 -1
  40. package/page/index.html +16 -16
  41. package/page/assets/browser-engine-Bj4wuN2U.js +0 -11
@@ -1,3 +1,3 @@
1
- import{C as e,E as t,O as n,T as r,l as i,o as a,u as o,v as s,w as c,y as l}from"./schemas-BQ9Jydzb.js";import{$n as ee,Cr as te,Er as ne,Fn as re,H as ie,Ln as ae,Pr as u,Sr as oe,Wt as se,Yn as d,ar as f,gn as p,hn as m,in as ce,ir as le,lr as ue,mn as de,nn as fe,pn as pe,tn as me,vn as he,xr as ge,zn as _e,zt as ve}from"./tool-schema-CjkdSYeP.js";import{c as h}from"./host-patterns-F-KZIzkF.js";import{An as ye,Un as g,Wn as be,k as xe,mn as Se,nn as _,pn as Ce,wn as we}from"./shaped-data-CF9zpotl.js";import{a as Te,n as Ee}from"./live-ingress-OuSlQ6q7.js";var De=2,Oe=4,ke=3,Ae=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,je=/^[A-Za-z0-9+/]*={0,2}$/,Me=new Set([`text/csv`,`text/plain`,`text/markdown`]);function v(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function Ne(e,t){if(t.limitsByMime){let n=he(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),i=`${r}/*`;if(t.limitsByMime[i])return t.limitsByMime[i]}return t.maxBytes}function y(e){return`uri`in e}function Pe(e){if(e.type===`speech`)throw new h(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new h(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new h(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new h(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function Fe(e){let t=0;return e.endsWith(`==`)?t=De:e.endsWith(`=`)&&(t=1),Math.floor(e.length*ke/Oe)-t}function Ie(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Le(e){return e.replace(Ae,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Re(e,t,n){let r=Ie(t);return e===`text/csv`&&(r=Le(r)),new TextEncoder().encode(n.read(r))}function b(e,t){return t?{...e,fileName:t}:e}function x(e,t,n){return t.filter(t=>!de(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function ze(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=Ne(i.mimeType,t);i.sizeBytes>e&&n.push(b({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function S(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...x(e.attachments,t,`attachment`)),e.voice&&r.push(...x(e.voice,n,`voice`)),e.limits?[...r,...ze([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Be={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function C(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:Be[e.code],params:t}}function Ve(e,t){let n=C(e);return g(n.key,n.params,t)}function w(e){return new h(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function T(e){if(!je.test(e))throw new h(`request`,`attachment data must be base64`);return Fe(e)}function E(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=T(e.data)),t}function He(e,t,n){if(!Ue(t,n))return;let r=Pe(e),i=S({attachments:m(e,`attachments`),voice:m(e,`voice`),limits:r},(t??[]).map(E),(n??[]).map(E));if(i.length>0)throw w(i)}function D(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Me.has(he(n)))return e;let i=Re(n,Ce(r),t);return{...e,data:Se(i)}}function Ue(e,t){return(e?.length??0)>0||(t?.length??0)>0}function We(e,t,n,r){return He(e,t,n),{attachments:t?.length?t.map(e=>D(e,r.attachment)):t,voice:n?.length?n.map(e=>D(e,r.voice)):n}}var Ge=`
1
+ import{C as e,E as t,O as n,T as r,l as i,o as a,u as o,v as s,w as c,y as l}from"./schemas-BQ9Jydzb.js";import{$n as ee,Cr as te,Er as ne,Fn as re,H as ie,Ln as ae,Pr as u,Sr as oe,Wt as se,Yn as d,ar as f,gn as p,hn as m,in as ce,ir as le,lr as ue,mn as de,nn as fe,pn as pe,tn as me,vn as he,xr as ge,zn as _e,zt as ve}from"./tool-schema-CSmvha7v.js";import{c as h}from"./host-patterns-F-KZIzkF.js";import{An as ye,Un as g,Wn as be,k as xe,mn as Se,nn as _,pn as Ce,wn as we}from"./shaped-data-BO6EAfYh.js";import{a as Te,n as Ee}from"./live-ingress-OuSlQ6q7.js";var De=2,Oe=4,ke=3,Ae=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,je=/^[A-Za-z0-9+/]*={0,2}$/,Me=new Set([`text/csv`,`text/plain`,`text/markdown`]);function v(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function Ne(e,t){if(t.limitsByMime){let n=he(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),i=`${r}/*`;if(t.limitsByMime[i])return t.limitsByMime[i]}return t.maxBytes}function y(e){return`uri`in e}function Pe(e){if(e.type===`speech`)throw new h(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new h(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new h(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new h(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function Fe(e){let t=0;return e.endsWith(`==`)?t=De:e.endsWith(`=`)&&(t=1),Math.floor(e.length*ke/Oe)-t}function Ie(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Le(e){return e.replace(Ae,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Re(e,t,n){let r=Ie(t);return e===`text/csv`&&(r=Le(r)),new TextEncoder().encode(n.read(r))}function b(e,t){return t?{...e,fileName:t}:e}function x(e,t,n){return t.filter(t=>!de(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function ze(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=Ne(i.mimeType,t);i.sizeBytes>e&&n.push(b({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function S(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...x(e.attachments,t,`attachment`)),e.voice&&r.push(...x(e.voice,n,`voice`)),e.limits?[...r,...ze([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Be={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function C(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:Be[e.code],params:t}}function Ve(e,t){let n=C(e);return g(n.key,n.params,t)}function w(e){return new h(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function T(e){if(!je.test(e))throw new h(`request`,`attachment data must be base64`);return Fe(e)}function E(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=T(e.data)),t}function He(e,t,n){if(!Ue(t,n))return;let r=Pe(e),i=S({attachments:m(e,`attachments`),voice:m(e,`voice`),limits:r},(t??[]).map(E),(n??[]).map(E));if(i.length>0)throw w(i)}function D(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Me.has(he(n)))return e;let i=Re(n,Ce(r),t);return{...e,data:Se(i)}}function Ue(e,t){return(e?.length??0)>0||(t?.length??0)>0}function We(e,t,n,r){return He(e,t,n),{attachments:t?.length?t.map(e=>D(e,r.attachment)):t,voice:n?.length?n.map(e=>D(e,r.voice)):n}}var Ge=`
2
2
 
3
3
  `;function Ke(e){if(typeof e==`string`)return;if(typeof e!=`object`||!e||Array.isArray(e))return`must be a string or { private: string }`;let t=Object.keys(e);if(t.length!==1||t[0]!==`private`)return`must have exactly one key, private`;let n=e.private;if(typeof n!=`string`)return`must be a string`;if(n===``)return`must not be empty`}function O(e,t){if(typeof e!=`string`){if(!Array.isArray(e))return`${t} must be a string or an array of parts`;if(e.length===0)return`${t} must not be an empty array`;for(let[n,r]of e.entries()){let e=Ke(r);if(e)return`${t}[${n}]${typeof r==`object`&&r&&`private`in r?`.private`:``} ${e}`}}}function k(e,t){let n=O(e,t);if(n)throw new h(`config`,n)}function qe(e,t,n){return k(e,t),typeof e==`string`?n(e):e.map(e=>typeof e==`string`?n(e):{private:n(e.private)})}function Je(e){if(typeof e==`string`)return[{text:e,private:!0}];let t=e.some(e=>typeof e!=`string`);return e.map(e=>typeof e==`string`?{text:e,private:!t}:{text:e.private,private:!0})}function A(e){let t=[];for(let n of e)n.some(e=>e.text)&&(t.length>0&&t.push({text:Ge,private:!0}),t.push(...n));return t}function Ye(e){return e.map(e=>e.text).join(``)}function Xe(e){let t=[],n=``;for(let r of e)r.private?n+=r.text:(n.trim()&&t.push(n),n=``);return n.trim()&&t.push(n),{text:Ye(e),private:t}}function Ze(e,t){return Xe(A([e,...t.map(e=>e?[{text:e,private:!0}]:[])]))}function j(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function M(e,t){let n=e.get(t);return n!==void 0&&n.type!==`builtin`}function N(e,t){return!e||e.includes(`*`)?!0:t?e.includes(t):!1}function Qe(e,t){return t.filter(n=>{let r=e.get(n);return r?.type!==`builtin`||!(r.conflictsWith??[]).some(e=>t.includes(e))})}function P(e){return`tools`in e?e.tools.allow:[]}function F(e){return e.type===`text`||e.type===`image`?e.tools:void 0}function $e(e){return`tools`in e?e.tools.parallel:void 0}function et(e,t,n){return P(t).filter(r=>{let i=e.get(r);return!i||i.type===`builtin`?!1:t.type===`host`||N(i.paths,n.path)})}function tt(e,t,n,r){let i=t.models[r];return i?(i.builtInTools??[]).filter(t=>{let r=e.get(t);return r?.type===`builtin`&&N(r.paths,n.path)}):[]}function I(e,t){let n=e.get(t);if(n&&n.type!==`builtin`)return{type:`function`,name:n.name,description:n.description,parameters:n.inputSchema}}function nt(e,t){let n=[];for(let r of t){let t=I(e,r);t&&n.push(t)}return n}function L(e,t,n){if(t.visible.includes(n))return;t.visible.push(n);let r=I(e,n);r&&!t.wire.some(e=>e.name===n)&&t.wire.push(r)}function rt(e,t,n){if(t.builtins.includes(n))return;let r=e.get(n);if(r?.type!==`builtin`)return;let i=r.conflictsWith??[];t.builtins=t.builtins.filter(t=>{if(i.includes(t))return!1;let r=e.get(t);return!(r?.type===`builtin`&&r.conflictsWith?.includes(n))}),t.builtins.push(n)}function it(e,t,n){return t.type===`live`||t.type===`host`?[...n]:n.filter(t=>e.get(t)?.loadTier===`T0`)}function at(e,t,n){return Qe(e,n.filter(n=>{let r=e.get(n);return r?.type===`builtin`&&(t.type===`live`||r.loadTier===`T0`)}))}function R(e,t,n,r){let i=et(e,t,n),a=t.type===`host`||t.type===`decision`||t.type===`embedding`||r===void 0?[]:tt(e,t,n,r),o=[...i,...a],s=at(e,t,o),c=it(e,t,o);return{builtins:s,gated:o,visible:c,executable:c.filter(t=>M(e,t)),path:n.path,sessionPermissions:n.sessionPermissions,wire:nt(e,c)}}async function ot(e,t,n,r){let i=R(e,t,n,r);return await z(e,i,t,n),i}function st(e){return{builtins:[...e.builtins],gated:[...e.gated],visible:[...e.visible],executable:[...e.executable],path:e.path,sessionPermissions:e.sessionPermissions?[...e.sessionPermissions]:void 0,wire:e.wire.map(e=>({...e,parameters:structuredClone(e.parameters)}))}}async function z(e,t,n,r){let i=F(n)?.t1Policy;if(!i)return;let a;try{a=await i({profile:n,input:r.input,path:r.path,sessionPermissions:r.sessionPermissions,gated:t.gated,host:r.host})}catch(e){let t=e instanceof Error?e.message:String(e);throw new h(`config`,`Profile '${n.id}' tools.t1Policy rejected: ${t}`,{cause:e})}if(!Array.isArray(a))throw new h(`config`,`Profile '${n.id}' tools.t1Policy must return ToolId[]`);for(let n of a){if(!t.gated.includes(n))continue;let r=e.get(n);r?.loadTier===`T2`&&(r.type===`builtin`?rt(e,t,n):L(e,t,n))}t.executable=t.visible.filter(t=>M(e,t))}var ct=new Set([`__proto__`,`constructor`,`prototype`]);function lt(e){if(!xe(e))return;let{loaded:t}=e;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t}function ut(e,t,n,r){if(r.type===`live`||r.type===`host`)return{promoted:[]};let i=[];for(let a of n){if(typeof a!=`string`||ct.has(a))return{promoted:[],failure:{code:`invalid_output`,kind:`bad_response`,message:`tools.t2Loader loaded ids must be plain strings`}};let n=dt(e,a,r);if(`failure`in n)return{promoted:[],failure:n.failure};let{tool:o}=n;N(o.paths,t.path)&&t.gated.includes(a)&&i.push(a)}let a=[];for(let n of i)L(e,t,n),a.push(n);return t.executable=t.visible.filter(t=>M(e,t)),{promoted:a}}function B(e){return{failure:{code:`invalid_output`,kind:`bad_response`,message:e}}}function dt(e,t,n){if(!P(n).includes(t))return B(`tools.t2Loader attempted to promote tool '${t}' outside profile allow`);let r=e.get(t);return r?r.type===`builtin`?B(`tools.t2Loader attempted to promote builtin '${t}' — only custom tools may be promoted`):r.loadTier===`T2`?{tool:r}:B(`tools.t2Loader attempted to promote tool '${t}' with loadTier '${r.loadTier}' — only T2 tools may be promoted`):B(`tools.t2Loader attempted to promote unknown tool '${t}'`)}function V(e){return Array.isArray(e)?[...e]:e.choices.map(e=>e.value)}function ft(e){return Array.isArray(e)?{choices:e.map(e=>({value:e}))}:{...e.label!==void 0&&e.label!==``?{label:e.label}:{},choices:e.choices.map(e=>({value:e.value,...e.description!==void 0&&e.description!==``?{description:e.description}:{}}))}}function pt(e){if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ft(t)]))}function H(e){return e?.slots?{...e,slots:pt(e.slots)}:e}function mt(e){return e==null}function U(e){return mt(e)||typeof e!=`object`||Array.isArray(e)?null:e}function W(e){let t=U(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function G(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function K(e){let t=e.properties;return U(t)??{}}function ht(e,t){return e?`${e}.${t}`:t}function gt(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function _t(e,t,n,r,i){if(!n)return;let a=await n(t,r);a.isValid||i.push({path:e,error:a.error||a.finding||`Validation failed for '${e}'`})}async function vt(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,slots:o,failures:s}=e;if(mt(r)){i&&gt(t,s);return}await _t(t,r,a?.[t],o,s);let c=W(n),l=c?U(r):null;c&&l&&await yt(c,l,t,a,o,s)}async function yt(e,t,n,r,i,a){let o=K(e),s=new Set(G(e)),c=new Set([...Object.keys(o),...s]),l=U(t);for(let e of c)await vt({path:ht(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,slots:i,failures:a})}async function bt(e,t,n,r){let i=W(e);if(!i)throw new h(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!U(t)){for(let e of G(i))gt(e,a);return a}return await yt(i,t,``,n,r,a),a}function xt(e,t){let n=e;for(let e of t.split(`.`)){let t=W(n);if(!t)return!1;let r=K(t);if(!Object.hasOwn(r,e)&&!G(t).includes(e))return!1;n=r[e]}return!0}function St(e){return e.map(e=>e.error).join(`; `)}function q(e,t){let n=e;for(let e of t.split(`.`))n=U(n)?.[e];return n}function Ct(e,t,n){let[r,...i]=t.split(`.`),a=U(e)??{};return r===void 0?e:{...a,[r]:i.length?Ct(a[r],i.join(`.`),n):n}}async function wt(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=q(e,i);if(Array.isArray(t))for(let[e,o]of t.entries()){let t=await a.check(o,n);t.isValid||r.push({path:i,index:e,item:o,reason:t.error||t.finding||`Validation failed for '${i}'`,onFail:a.onFail})}}return r}function Tt(e,t){let n=e;for(let e of t.split(`.`)){let t=W(n);if(!t)return;n=K(t)[e]}let r=U(n);if(r?.type===`array`)return U(r.items)??void 0}var Et=class extends Error{failure;constructor(e){super(e.message),this.failure=e}},Dt=new Set([`text`,`image`,`speech`]),Ot=c().regex(/\S/),kt=e({mimeType:c(),data:o(),name:c().optional()}),At=e({mimeType:c(),uri:c(),name:c().optional()}),jt=e({voice:c().optional(),style:c().optional(),speed:s().positive().optional()});function Mt(t){return e(Object.fromEntries(Object.entries(t).map(([e,t])=>{let n=V(t);return[e,a(n).optional()]})))}var Nt=new Set([`text`,`attachments`,`voice`,`slots`,`speech`]);function Pt(e,t){if(!e.hostFields)return{sent:t};let n={...t},r={};for(let t of Object.keys(e.hostFields))n[t]!==void 0&&(r[t]=n[t]);let{text:i,attachments:a,voice:o,slots:s,speech:c}=t;return{sent:{text:i,...a?{attachments:a}:{},...o?{voice:o}:{},...s?{slots:s}:{},...c?{speech:c}:{}},hostInput:r}}function Ft(t,n){let{inputs:a}=t,o={text:Ot};a?.attachments&&(o.attachments=i(r([kt,At])).optional()),a?.voice&&(o.voice=i(kt).optional()),a?.slots&&(o.slots=Mt(a.slots).optional()),t.type===`speech`&&(o.speech=jt.optional());for(let e of n?.hostOnly??[]){if(!o[e])throw new h(`config`,`Tool '${n?.name}' keeps '${e}' for the host, which its profile does not take`);delete o[e]}for(let[e,t]of Object.entries(n?.fieldText??{})){let r=o[e];if(!r)throw new h(`config`,`Tool '${n?.name}' describes '${e}', which its profile does not take`);o[e]=r.describe(t)}for(let[e,t]of Object.entries(n?.hostFields??{})){if(Nt.has(e))throw new h(`config`,`Tool '${n?.name}' declares the host field '${e}', which is a field of every agent tool`);o[e]=t}return e(o)}var It=l({text:c().optional(),structured:t().optional(),removed:i(l({path:c(),reason:c(),item:t()})).optional(),parts:i(re).optional(),sources:i(_e).optional()});function Lt(e){return e.type===`speech`||(e.type===`text`||e.type===`image`)&&e.inputs.text!==!1}function Rt(e){return e.type===`builtin`?!1:e.permission!==`auto`||`auth`in e&&e.auth!==void 0&&(e.auth.onUnauthenticated??`gate`)===`gate`}function zt(e,t){if(!Dt.has(e.type))return`it is a ${e.type} profile; an agent tool runs a text, image, or speech profile`;if(!Lt(e))return`it does not take text`;for(let n of P(e)){let e=t(n);if(!e)return`its tool '${n}' is not registered; register it first`;if(Rt(e))return`its tool '${n}' can stop on a gate; give it permission 'auto' and no sign-in`}}function Bt(e,t,n){let r=`Agent tool "${e.name}"`,i=e.maxCallsPerTurn;if(i!==void 0&&!(Number.isInteger(i)&&i>0))throw new h(`config`,`${r}: maxCallsPerTurn must be a whole number above 0`);let a=t(e.profile);if(!a)throw new h(`config`,`${r}: profile '${e.profile}' must be registered before the tool`);let o=zt(a,n);if(o)throw new h(`config`,`${r} can't run '${e.profile}': ${o}`);return a}function Vt(e){if(!e)return`delegated`;let t=`models`in e&&Object.values(e.models).some(e=>(e.builtInTools?.length??0)>0);return P(e).length===0&&!t?`local`:`delegated`}function Ht(e){let t=ae(e),n=t.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),r=ve(t,e=>e.type===`structured`),i=r?.structured,a=t.flatMap(e=>e.type===`media`?[{type:e.media.mimeType.startsWith(`audio/`)?`audio`:`image`,mimeType:e.media.mimeType,data:e.media.data}]:[]),o=t.flatMap(e=>e.type===`citation`?e.sources:[]);return{...i===void 0?{text:n}:{structured:i},...r?.removed?.length?{removed:r.removed}:{},...a.length>0?{parts:a}:{},...o.length>0?{sources:o}:{}}}function Ut(e,t,n){return{...e,type:`agent`,input:t,output:It,sources:e=>e.sources??[],...n}}function Wt(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n.push(`${t}: schema must be an object`),!1;let r=typeof e.type==`string`||Array.isArray(e.type),i=e.anyOf!==void 0||e.oneOf!==void 0;if(!r&&!i){if(t!==`$`)return!0;n.push(`${t}: missing type or combinator`)}return e.type===`array`&&e.items===void 0&&n.push(`${t}: array schema must define items`),!0}function Gt(e,t,n,r){let i=Array.isArray(t)?t:[];for(let t of i)typeof t==`string`&&!Object.hasOwn(e,t)&&r.push(`${n}: required key '${t}' missing from properties`);for(let[t,i]of Object.entries(e))i&&typeof i==`object`&&J(i,`${n}.properties.${t}`,r)}function J(e,t,n){if(!Wt(e,t,n))return;let r=e.properties;r&&typeof r==`object`&&!Array.isArray(r)&&Gt(r,e.required,t,n),e.items&&typeof e.items==`object`&&!Array.isArray(e.items)&&J(e.items,`${t}.items`,n);for(let r of[`anyOf`,`oneOf`]){let i=e[r];Array.isArray(i)&&i.forEach((e,i)=>{e&&typeof e==`object`&&J(e,`${t}.${r}[${i}]`,n)})}}function Kt(e,t){let n=[];if(J(e,`$`,n),n.length>0)throw new h(`config`,`Invalid tool ${t} schema: ${n.join(`; `)}`)}function qt(e,t=`output`){let r=n(e,{target:`draft-7`,io:t});return delete r.$schema,r.type||=`object`,r}function Y(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Y);let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=Y(e[n]));return t}function Jt(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e)?.[0];if(!t||/[{}]/.test(t))throw new h(`config`,`Endpoint "${e}" must start with a fixed scheme and host; placeholders belong in the path or query`)}function Yt(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new h(`config`,g(`provider.binding_identity`))}function Xt(e){on(e.id,e.models),Z(e.id,e.observability),Jn(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))cn(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:sn(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Zt(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new h(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function Qt(e,t,n){if(Zt(e,t,n,fe),Yt(e,t,n,`decision`),`retry`in n)throw new h(`config`,`Profile ${e} model '${t}': a decision binding takes no retry; a decision retries only a transient failure, by the kernel's rule`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0))throw new h(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function $t(e){let t=e.models?j(e.models):void 0;if(!t)throw new h(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Qt(e.id,t,e.models[t])}function en(e){if(e.inputs.state!==`json`)throw new h(`config`,`Profile ${e.id}: decision inputs.state must be 'json'`);let t=e.inputs.maxStateBytes;if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw new h(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new h(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function tn(e){return $t(e),en(e),Z(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function nn(e){return e===void 0?{}:{parallel:e}}function rn(e){return an(e.id,e.tools),Z(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...nn(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function an(e,t){if(!Array.isArray(t.allow))throw new h(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function on(e,t){if(Object.keys(t).length===0)throw new h(`config`,`Profile ${e} must declare at least one model`)}function sn(e,t){let n=t.defaultModel??j(t.models);if(!n)throw new h(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new h(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function cn(e,t,n){ln(e,t,n),Zt(e,t,n,ce),ln(e,t,n)}function ln(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new h(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!ue.includes(i))throw new h(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${ue.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new h(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new h(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new h(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function un(e){return{providerContinuation:e.providerContinuation?ne.parse(e.providerContinuation):{},models:e.models,defaultModel:sn(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function dn(e,t,n){if(n?.length){for(let r of n)if(!se(r))throw new h(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function fn(e,t){t&&(dn(e,`allowContinue`,t.allowContinue),dn(e,`autoContinue`,t.autoContinue))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pn(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>X(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var mn=Object.entries(le).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function hn(e){if(!X(e))throw new h(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new h(`config`,`Profile definition must set id`);if(!f.find(t=>t===e.type))throw new h(`config`,`Profile ${t}: type must be one of ${f.join(`, `)}`)}function gn(e){let t=e.identity?.handle,n=[[`id`,e.id,64],[`identity.handle`,typeof t==`string`?t:``,32]];for(let[t,r,i]of n)if(!(Array.from(r).length<=i))throw new h(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function _n(e){let{id:t,type:n}=e,r=e;for(let[e,i]of mn){if(i&&!i.includes(n))continue;let a=oe(e),o=pn(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!X(e))return!1;let t=e[s];return t==null||t===``}))throw new h(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function vn(e){let{id:t,type:n}=e;if(n!==`live`&&te(`inputs`).includes(n)&&e.inputs==null)throw new h(`config`,`Profile ${t}: type '${n}' must set inputs`)}function yn(e){let[t]=ge(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new h(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function bn(e,t){let n=t.turnBehaviour;fn(e,n?.resumption)}function xn(e,t){let n=t=>new h(`config`,`Profile ${e}: ${t}`),r=t?.maxRetries;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw n(`outputs.validation.maxRetries must be a non-negative integer`)}function Sn(e,t){let n=t=>new h(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!Cn.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${Cn.join(`, `)}`);Tn(t?.blockedReply,n)}var Cn=[`quota`,`detect`,`blockedReply`,`network`,`taint`],wn=[`onBlock`,`maxRetries`];function Tn(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!wn.includes(e));if(n!==void 0)throw t(`guardrails.blockedReply.${n} is not a setting; it takes onBlock and maxRetries`);let{onBlock:r,maxRetries:i}=e;if(r!==void 0&&!u.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${u.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function En(e){let t=e.guardrails?.detect,n=e.type===`host`?_(`guardrails.detect`,t,we):_(`guardrails.detect`,t);if(n!==void 0)throw new h(`config`,`Profile ${e.id}: ${n}`)}function Z(e,t){try{let n=Te(t);if(!Number.isFinite(n.retainForDays))throw new h(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new h(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof h&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new h(ye(t),`Profile ${e}: ${n}`,{cause:t})}}function Dn(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`embedding`)return;let{system:t,systemByRole:n}=e.identity;t!==void 0&&k(t,`Profile ${e.id} identity.system`);for(let[t,r]of Object.entries(n??{}))k(r,`Profile ${e.id} identity.systemByRole.${t}`)}function On(e){hn(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new h(`config`,g(`provider.profile_configuration`,{profile:e.id,field:t}));if(yn(e),vn(e),_n(e),gn(e),e.labels&&be(e.labels,`Profile ${e.id}`),Dn(e),En(e),e.type===`host`)return rn(e);if(e.type===`decision`)return tn(e);if(e.type===`embedding`)return Xt(e);on(e.id,e.models),bn(e.id,e),Sn(e.id,e.guardrails),e.type===`text`&&xn(e.id,e.outputs?.validation),Z(e.id,e.observability);for(let[t,n]of Object.entries(e.models))cn(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,system:e.identity.system,systemByRole:e.identity.systemByRole},n=e.guardrails,r=e.observability,i=e.labels,a=un(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs:H(e.inputs),outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`image`:o={type:`image`,id:e.id,identity:t,...a,image:e.image,tools:e.tools,inputs:H(e.inputs),outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Pn(o.id,o.inputs.attachments?.accept),Nn(o.id,o.image);break;case`speech`:o={type:`speech`,id:e.id,identity:t,...a,speech:e.speech,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`live`:o={type:`live`,id:e.id,identity:t,...a,live:e.live,inputs:e.inputs?H(e.inputs):e.inputs,tools:{allow:e.tools.allow,...nn(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Ee(o),In(o.id,o.live.contextCompression),Fn(o);break;default:throw new h(`config`,`Unknown profile type '${String(e)}'`)}return jn(o),kn(o),An(o),o}function kn(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new h(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function An(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new h(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function jn(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=p(e)?.slots?.[t.by];if(!n)throw new h(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not a slot in inputs.slots`);let r=V(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new h(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of slot '${t.by}'`)}var Mn={n:{ok:e=>Number.isInteger(e)&&e>=1,rule:`a whole number of 1 or more`},seed:{ok:Number.isInteger,rule:`a whole number`},outputCompression:{ok:e=>Number.isInteger(e)&&e>=0&&e<=100,rule:`a whole number from 0 to 100`}};function Nn(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Mn)){let a=t[n];if(a!==void 0&&!r(a))throw new h(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(pe(t.mimeType)!==`image`)throw new h(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(y(t)?t.uri:t.data))throw new h(`config`,`${r} needs its bytes or its uri`)})}function Pn(e,t){let n=t?.filter(e=>!de(ee,e));if(n?.length)throw new h(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Fn(e){let{greeting:t,resumed:n,sessionResumption:r}=e.live,i=`Profile ${e.id} live`;if(t!==void 0&&(typeof t!=`string`||!t.trim()))throw new h(`config`,`${i}.greeting must be a prompt; leave it out to wait`);if(!n)return;if(typeof n.prompt!=`string`||!n.prompt.trim())throw new h(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new h(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new h(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function In(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(Ln(`${n}.triggerTokens`,r),Ln(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new h(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function Ln(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new h(`config`,`${e} must be a whole number above 0`)}function Rn(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(zn(i,r),Bn(i,r),r.meter!=null&&r.meter!==`history`&&r.meter!==`input`)throw new h(`config`,`${i}: meter must be 'history' or 'input'`);if(r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new h(`config`,`${i}: a profile that compacts itself must be a text profile that takes text`);return}let a=e.get(r.profile);if(!a)throw new h(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new h(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function zn(e,t){if(t.maxTokens<=0)throw new h(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new h(`config`,`${e}: compactAt must be in (0, 1)`)}function Bn(e,t){if(t.previousExchanges<0)throw new h(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new h(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new h(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function Vn(e,t){for(let n of P(t))if(e.get(n)?.type===`builtin`)throw new h(`config`,t.type===`host`?`Profile ${t.id} lists builtin '${n}' in tools.allow — type 'host' never runs a model`:`Profile ${t.id} lists builtin '${n}' in tools.allow — declare it on models.*.builtInTools instead`)}function Hn(e,t){let n=F(t)?.t2Loader;if(n){if(!P(t).includes(n))throw new h(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new h(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Un(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Wn(e,t){for(let{modelId:n,id:r}of Un(t))if(e.get(r)?.type!==`builtin`)throw new h(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Gn(e){let t=e.type===`text`?e.outputs?.structured:void 0;return t?typeof t==`string`?[t]:[...new Set([...Object.values(t.map),t.fallback])]:[]}function Kn(e,t){let n=Gn(t).map(n=>{let r=e.find(n);if(!r)throw new h(`config`,`Profile ${t.id}: outputs.structured names '${n}', which is not a registered schema; register it before the profile`);return r}),r=t.type===`text`?t.outputs?.validation:void 0,i=Object.keys(r?.fields??{}),a=Object.keys(r?.items??{});if(!i.length&&!a.length)return;if(!n.length)throw new h(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>Tt(t.jsonSchema,e)));if(o.length)throw new h(`config`,`Profile ${t.id}: outputs.validation.items has ${o.join(`, `)}, which no structured schema reaches as a list with an items schema`);let s=i.filter(e=>!n.some(t=>xt(t.jsonSchema,e)));if(s.length)throw new h(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function qn(e){let t=p(e)?.context;if(!t)return;let n=d;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new h(`config`,`Profile ${e.id}: inputs.context.from must list ${d.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new h(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function Jn(e,t){if(!t)return;let{attachments:n,voice:r,maxFiles:i,maxBytes:a,maxTurnBytes:o,limitsByMime:s}=t,c={maxFiles:i,maxBytes:a,maxTurnBytes:o};if((n||r)&&Object.values(c).some(e=>e===void 0))throw new h(`config`,`Profile ${e} must set maxFiles, maxBytes, and maxTurnBytes`);for(let[e,t]of Object.entries(s??{}))c[`limitsByMime['${e}']`]=t;for(let[t,n]of Object.entries(c))if(n!==void 0&&!(Number.isInteger(n)&&n>0))throw new h(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Yn(e,t,n){let r=new Map,i=i=>{let a=On(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,me(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(Vn(e,o),Hn(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){Wn(e,o),Jn(o.id,p(o)),qn(o),Kn(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&Rn(r,o,e,t.compaction)}r.set(o.id,o)};return{register:i,registerMany(e){for(let t of e)i(t)},get(e){let t=r.get(e);if(!t)throw new h(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function Xn(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Q(e){let t;try{t=new URL(e.baseUrl)}catch{throw new h(`config`,`Enter a valid localhost URL.`)}if(![`http:`,`https:`].includes(t.protocol)||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash)throw new h(`config`,`Use a localhost URL without credentials, query parameters or a fragment.`);return{baseUrl:t.href.replace(/\/$/,``),fetch:(e,n)=>new URL(e instanceof Request?e.url:String(e)).origin===t.origin?fetch(e,{...n,redirect:`error`,credentials:`omit`}):Promise.reject(new h(`blocked`,`Local requests must stay on the configured origin.`))}}var Zn=l({data:i(l({id:c().min(1)}))});async function Qn(e,t){let n=Q(e);if(!n?.fetch)throw new h(`config`,`Enter a local endpoint.`);let r=await n.fetch(`${n.baseUrl}/v1/models`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)throw new h(`network`,`Local model list returned HTTP ${r.status}.`);let i=Zn.safeParse(await r.json());if(!i.success)throw new h(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var $n=`https://openrouter.ai/api/v1/models`,er=`https://openrouter.ai/api/v1/embeddings/models`,tr=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],nr=[{id:`liquid/lfm-2.5-embedding-350m:free`,label:`Liquid LFM 2.5 Embedding 350M (free)`},{id:`nvidia/nemotron-3-embed-1b:free`,label:`NVIDIA Nemotron 3 Embed 1B (free)`},{id:`nvidia/llama-nemotron-embed-vl-1b-v2:free`,label:`NVIDIA Llama Nemotron Embed VL 1B v2 (free)`}],rr={text:`text`,image:`image`,speech:`speech`,live:void 0,embedding:void 0},ir=l({data:i(l({id:c().min(1),name:c().optional(),architecture:l({output_modalities:i(c()).optional()}).optional()}))}),ar=l({data:i(l({id:c().min(1),name:c().optional()}))}),or=l({models:i(l({name:c().min(1),displayName:c().optional(),supportedGenerationMethods:i(c()).optional()})).optional(),nextPageToken:c().optional()}),sr=5;async function $(e,t,n){let r=await fetch(t,{...n,redirect:`error`,credentials:`omit`});if(r.status===400||r.status===401||r.status===403)throw new h(`auth`,`${e} refused the key.`);if(!r.ok)throw new h(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function cr(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?nr:tr];if(e===`openrouter`)return await lr(t,i,r);if(!i)throw new h(`auth`,`Choose a key to list Gemini models.`);return await dr(t,i,r)}async function lr(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=ar.safeParse(await $(`OpenRouter`,er,r));if(!e.success)throw new h(`bad_response`,`OpenRouter returned an invalid embedding model list.`);return e.data.data.map(e=>({id:e.id,label:e.name??e.id}))}let i=rr[e];if(!i)return[];let a=ir.safeParse(await $(`OpenRouter`,`${$n}?output_modalities=${i}`,r));if(!a.success)throw new h(`bad_response`,`OpenRouter returned an invalid model list.`);return a.data.data.filter(e=>e.architecture?.output_modalities?.includes(i)??!0).map(e=>({id:e.id,label:e.name??e.id}))}var ur={live:`bidiGenerateContent`,embedding:`embedContent`};async function dr(e,t,n){let r=ur[e]??`generateContent`,i=[],a;for(let e=0;e<sr;e++){let e=new URL(ie);e.searchParams.set(`pageSize`,`1000`),a&&e.searchParams.set(`pageToken`,a);let o=or.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!o.success)throw new h(`bad_response`,`Google returned an invalid model list.`);for(let e of o.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);i.push({id:t,label:e.displayName??t})}if(a=o.data.nextPageToken,!a)break}return i}function fr(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function pr(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{st as A,Ze as B,bt as C,Ct as D,q as E,$e as F,Ve as G,qe as H,F as I,T as J,S as K,ut as L,lt as M,ot as N,pt as O,P,R,wt as S,Tt as T,Je as U,A as V,O as W,v as X,y as Y,We as Z,It as _,fr as a,Ut as b,On as c,Y as d,Kt as f,Vt as g,Ft as h,Q as i,z as j,V as k,Jt as l,zt as m,Qn as n,pr as o,Et as p,w as q,cr as r,Yn as s,Xn as t,qt as u,Ht as v,St as w,Pt as x,Bt as y,j as z};