@theoremjs/studio 0.3.4-next.805.g5285614 → 0.3.4-next.809.g208c24f

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 (52) hide show
  1. package/browser-transport.js +1 -0
  2. package/forwarded-fetch.d.ts +23 -0
  3. package/forwarded-fetch.js +56 -0
  4. package/package.json +4 -4
  5. package/page/assets/{ConsoleFrame-DQyZm23d.js → ConsoleFrame-CLSrnRnK.js} +1 -1
  6. package/page/assets/{MenuBottomSheet-5NR9DSO0.js → MenuBottomSheet-BP_2gZdX.js} +1 -1
  7. package/page/assets/{SchemaFields-C-QSmL4_.js → SchemaFields-DlTdOHrn.js} +1 -1
  8. package/page/assets/{ToolResultCharts-HzVICCSx.js → ToolResultCharts-BO7U9xMi.js} +1 -1
  9. package/page/assets/{Toolbar-BxoZGKST.js → Toolbar-DMk7Kk0W.js} +1 -1
  10. package/page/assets/{TraceInspector-BlMYajbW.js → TraceInspector-Dv_LvC82.js} +1 -1
  11. package/page/assets/{TraceOverview-DFhMeLSM.js → TraceOverview-D6cjqdSF.js} +1 -1
  12. package/page/assets/{_virtual_studio-type-sources-COu6NXwi.js → _virtual_studio-type-sources-DOtDWhMs.js} +10 -0
  13. package/page/assets/{browser-connection-yG5WpBzp.js → browser-connection-DWbMIMKt.js} +1 -1
  14. package/page/assets/browser-engine-BFADFOZI.js +16 -0
  15. package/page/assets/{browser-transport-CfH9Ml_u.js → browser-transport-BTXOGGaX.js} +3 -3
  16. package/page/assets/{compile-C9JvVXdv.js → compile-Cg9kbAEZ.js} +2 -2
  17. package/page/assets/{export-agent-DXunvBt5.js → export-agent-BpEwfwNk.js} +1 -1
  18. package/page/assets/{guardrail-tester-DwP9tFB-.js → guardrail-tester-Bj9MT1z3.js} +1 -1
  19. package/page/assets/{index-ruFXkTFR.js → index-CNH4_31U.js} +72 -72
  20. package/page/assets/{json-code-DLymI95f.js → json-code-BeDzwxVd.js} +1 -1
  21. package/page/assets/{live-messages-CGCJrd3G.js → live-messages-C6UyO-mP.js} +1 -1
  22. package/page/assets/{prompt-row-BH0DhPf_.js → prompt-row-isPVUq8W.js} +1 -1
  23. package/page/assets/reader-C70KfSX1.js +5 -0
  24. package/page/assets/registry-CcJjk12d.js +1 -0
  25. package/page/assets/{schema-DHkmUj_T.js → schema-DfzrdK9g.js} +2 -2
  26. package/page/assets/{stub-B_588HBv.js → stub-DZFdwuE4.js} +1 -1
  27. package/page/assets/{studio-code-pane-C8xjMD-W.js → studio-code-pane-CQ2EgEJJ.js} +3 -3
  28. package/page/assets/{studio-console-B4phXSQk.js → studio-console-BTMg2W_g.js} +1 -1
  29. package/page/assets/{studio-decision-CSlWeEth.js → studio-decision-PiYlpQv2.js} +1 -1
  30. package/page/assets/{studio-embedding-D9R60GSt.js → studio-embedding-C2zGBKbv.js} +1 -1
  31. package/page/assets/{studio-host-console-O69CyJsH.js → studio-host-console-CapKC41a.js} +2 -2
  32. package/page/assets/{studio-labels-Clo1KCIy.js → studio-labels-DHvvRumb.js} +1 -1
  33. package/page/assets/{studio-live-CTXBCaH5.js → studio-live-B_Q6C1LR.js} +1 -1
  34. package/page/assets/{studio-map-BftN_Vq1.js → studio-map-DVLHfSF9.js} +1 -1
  35. package/page/assets/{studio-trace-replay-BubKrWKn.js → studio-trace-replay-MslLSmtG.js} +1 -1
  36. package/page/assets/{studio-type-checker-DmEXB7gp.js → studio-type-checker-DvLElJ45.js} +1 -1
  37. package/page/assets/{tool-schema-DpOILaLF.js → tool-schema-AZU-YfMK.js} +1 -1
  38. package/page/assets/{tree-D8Bhb2Iv.js → tree-D1_fvfef.js} +2 -2
  39. package/page/assets/{turn-client-CUnAfL-k.js → turn-client-PcVLCWF6.js} +2 -2
  40. package/page/assets/{use-one-call-CxCetbVx.js → use-one-call-7p_Ds2ce.js} +1 -1
  41. package/page/assets/{workspace-BtgRpaRk.js → workspace-oTW7J6dm.js} +1 -1
  42. package/page/index.html +13 -13
  43. package/runtime-scope.d.ts +2 -0
  44. package/runtime.js +3 -0
  45. package/server/draft-handler.js +3 -0
  46. package/server/forward.d.ts +17 -0
  47. package/server/forward.js +57 -0
  48. package/server/handler.js +3 -0
  49. package/ui/studio-connection.js +3 -0
  50. package/page/assets/browser-engine-D2YXgu31.js +0 -16
  51. package/page/assets/reader-Dszdlhfg.js +0 -5
  52. package/page/assets/registry-CH73Rdrf.js +0 -1
@@ -1 +1 @@
1
- import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{Cn as r,H as i,Sn as a,Tn as o,Xt as s,bn as c,fn as l,ln as ee,nr as te,un as ne,xn as u}from"./tool-schema-DpOILaLF.js";import{c as d}from"./host-patterns-F-KZIzkF.js";import{Cr as re,Hr as f,In as ie,Jn as p,Ln as ae,Nn as oe,Rn as se,Rr as ce,Ur as le,ar as ue,cn as de,gn as m,hn as fe,in as h,kr as pe,mr as me,or as he,xn as g}from"./shaped-data-F3datIeG.js";import{E as ge,b as _e,j as ve,k as ye,v as _,w as be}from"./schema-DHkmUj_T.js";import{a as xe,n as Se}from"./live-ingress-OuSlQ6q7.js";var Ce=2,we=4,Te=3,Ee=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,De=/^[A-Za-z0-9+/]*={0,2}$/,Oe=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 ke(e,t){if(t.limitsByMime){let n=o(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 Ae(e){if(e.type===`speech`)throw new d(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new d(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new d(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new d(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function je(e){let t=0;return e.endsWith(`==`)?t=Ce:e.endsWith(`=`)&&(t=1),Math.floor(e.length*Te/we)-t}function Me(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Ne(e){return e.replace(Ee,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Pe(e,t,n){let r=Me(t);return e===`text/csv`&&(r=Ne(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=>!u(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function Fe(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=ke(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,...Fe([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Ie={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:Ie[e.code],params:t}}function Le(e,t){let n=C(e);return f(n.key,n.params,t)}function Re(e){return new d(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function w(e){if(!De.test(e))throw new d(`request`,`attachment data must be base64`);return je(e)}function T(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=w(e.data)),t}function ze(e,t,n){if(!Be(t,n))return;let r=Ae(e),i=S({attachments:a(e,`attachments`),voice:a(e,`voice`),limits:r},(t??[]).map(T),(n??[]).map(T));if(i.length>0)throw Re(i)}function E(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Oe.has(o(n)))return e;let i=Pe(n,ue(r),t);return{...e,data:he(i)}}function Be(e,t){return(e?.length??0)>0||(t?.length??0)>0}function Ve(e,t,n,r){return ze(e,t,n),{attachments:t?.length?t.map(e=>E(e,r.attachment)):t,voice:n?.length?n.map(e=>E(e,r.voice)):n}}function D(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function O(e){return e==null}function k(e){return O(e)||typeof e!=`object`||Array.isArray(e)?null:e}function A(e){let t=k(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function j(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function M(e){let t=e.properties;return k(t)??{}}function He(e,t){return e?`${e}.${t}`:t}function N(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function Ue(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 We(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s}=e;if(O(r)){i&&N(t,s);return}await Ue(t,r,a?.[t],o,s);let c=A(n),l=c?k(r):null;c&&l&&await P(c,l,t,a,o,s)}async function P(e,t,n,r,i,a){let o=M(e),s=new Set(j(e)),c=new Set([...Object.keys(o),...s]),l=k(t);for(let e of c)await We({path:He(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,options:i,failures:a})}async function Ge(e,t,n,r){let i=A(e);if(!i)throw new d(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!k(t)){for(let e of j(i))N(e,a);return a}return await P(i,t,``,n,r,a),a}function Ke(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return!1;let r=M(t);if(!Object.hasOwn(r,e)&&!j(t).includes(e))return!1;n=r[e]}return!0}function qe(e){return e.map(e=>e.error).join(`; `)}function F(e,t){let n=e;for(let e of t.split(`.`))n=k(n)?.[e];return n}function I(e,t,n){let[r,...i]=t.split(`.`),a=k(e)??{};return r===void 0?e:{...a,[r]:i.length?I(a[r],i.join(`.`),n):n}}async function Je(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=F(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 L(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return;n=M(t)[e]}let r=k(n);if(r?.type===`array`)return k(r.items)??void 0}function Ye(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new d(`config`,f(`provider.binding_identity`))}function Xe(e){z(e.id,e.models),J(e.id,e.observability),Z(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Ze(e){z(e.id,e.models),K(e.id,e.guardrails),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new d(`config`,`Profile ${e.id}: a transcription takes a voice clip, so inputs.text must be false`);return{type:`transcription`,id:e.id,identity:{handle:e.identity.handle},...U(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function R(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new d(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function Qe(e,t,n){if(R(e,t,n,ne),Ye(e,t,n,`decision`),`retry`in n)throw new d(`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 d(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function $e(e){let t=e.models?D(e.models):void 0;if(!t)throw new d(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Qe(e.id,t,e.models[t])}function et(e){if(e.inputs.state!==`json`)throw new d(`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 d(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new d(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function tt(e){return $e(e),et(e),J(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function nt(e){return e===void 0?{}:{parallel:e}}function rt(e){return it(e.id,e.tools),J(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function it(e,t){if(!Array.isArray(t.allow))throw new d(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function z(e,t){if(Object.keys(t).length===0)throw new d(`config`,`Profile ${e} must declare at least one model`)}function B(e,t){let n=t.defaultModel??D(t.models);if(!n)throw new d(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new d(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function V(e,t,n){H(e,t,n),R(e,t,n,l),H(e,t,n)}function H(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new d(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!g.includes(i))throw new d(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${g.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new d(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new d(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new d(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function U(e){return{providerContinuation:e.providerContinuation?te.parse(e.providerContinuation):{},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function W(e,t,n){if(n?.length){for(let r of n)if(!s(r))throw new d(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function at(e,t){t&&(W(e,`allowContinue`,t.allowContinue),W(e,`autoContinue`,t.autoContinue))}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ot(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>G(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var st=Object.entries(fe).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function ct(e){if(!G(e))throw new d(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new d(`config`,`Profile definition must set id`);if(!m.find(t=>t===e.type))throw new d(`config`,`Profile ${t}: type must be one of ${m.join(`, `)}`)}function lt(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 d(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function ut(e){let{id:t,type:n}=e,r=e;for(let[e,i]of st){if(i&&!i.includes(n))continue;let a=ae(e),o=ot(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!G(e))return!1;let t=e[s];return t==null||t===``}))throw new d(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function dt(e){let{id:t,type:n}=e;if(n!==`live`&&se(`inputs`).includes(n)&&e.inputs==null)throw new d(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ft(e){let[t]=ie(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new d(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function pt(e,t){let n=t.turnBehaviour;at(e,n?.resumption)}function mt(e,t){let n=t=>new d(`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 K(e,t){let n=t=>new d(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!q.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${q.join(`, `)}`);gt(t?.blockedReply,n)}var q=[`quota`,`detect`,`blockedReply`,`network`,`taint`],ht=[`onBlock`,`maxRetries`];function gt(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!ht.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&&!me.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${me.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function _t(e){let t=e.guardrails?.detect,n=e.type===`host`?p(`guardrails.detect`,t,re):p(`guardrails.detect`,t);if(n!==void 0)throw new d(`config`,`Profile ${e.id}: ${n}`)}function J(e,t){try{let n=xe(t);if(!Number.isFinite(n.retainForDays))throw new d(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new d(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof d&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new d(pe(t),`Profile ${e}: ${n}`,{cause:t})}}function vt(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`transcription`||e.type===`embedding`)return;let{options:t,system:n}=e.identity,r=n??``;be(r,`Profile ${e.id} identity.system`);let i=ge(r,t,e.inputs?.options);if(i)throw new d(`config`,`Profile ${e.id} identity.system: ${i}`)}function Y(e){let t=yt(e),[n]=oe(e);if(n)throw new d(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function yt(e){ct(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new d(`config`,f(`provider.profile_configuration`,{profile:e.id,field:t}));ft(e),dt(e),ut(e),lt(e),e.labels&&le(e.labels,`Profile ${e.id}`);for(let t of ce)if(e.labels?.[t]!==void 0)throw new d(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(vt(e),_t(e),e.type===`host`)return rt(e);if(e.type===`decision`)return tt(e);if(e.type===`embedding`)return Xe(e);if(e.type===`transcription`)return Ze(e);z(e.id,e.models),pt(e.id,e),K(e.id,e.guardrails),e.type===`text`&&mt(e.id,e.outputs?.validation),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,options:e.identity.options,system:e.identity.system},n=e.guardrails,r=e.observability,i=e.labels,a=U(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs: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:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Tt(o.id,o.inputs.attachments?.accept),wt(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,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Se(o),Dt(o.id,o.live.contextCompression),Et(o);break;default:throw new d(`config`,`Unknown profile type '${String(e)}'`)}return St(o),bt(o),xt(o),o}function bt(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function xt(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new d(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function St(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=ve(e,t.by);if(!n)throw new d(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=ye(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new d(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var Ct={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 wt(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Ct)){let a=t[n];if(a!==void 0&&!r(a))throw new d(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(c(t.mimeType)!==`image`)throw new d(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(y(t)?t.uri:t.data))throw new d(`config`,`${r} needs its bytes or its uri`)})}function Tt(e,t){let n=t?.filter(e=>!u(de,e));if(n?.length)throw new d(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Et(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 d(`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 d(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new d(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new d(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function Dt(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(X(`${n}.triggerTokens`,r),X(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new d(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function X(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`${e} must be a whole number above 0`)}function Ot(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(kt(i,r),At(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new d(`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 d(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new d(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function kt(e,t){if(t.maxTokens<=0)throw new d(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new d(`config`,`${e}: compactAt must be in (0, 1)`)}function At(e,t){if(t.previousExchanges<0)throw new d(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new d(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new d(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function jt(e,t){for(let n of _(t))if(e.get(n)?.type===`builtin`)throw new d(`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 Mt(e,t){let n=_e(t)?.t2Loader;if(n){if(!_(t).includes(n))throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Nt(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Pt(e,t){for(let{modelId:n,id:r}of Nt(t))if(e.get(r)?.type!==`builtin`)throw new d(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Ft(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 It(e,t){let n=Ft(t).map(n=>{let r=e.find(n);if(!r)throw new d(`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 d(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>L(t.jsonSchema,e)));if(o.length)throw new d(`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=>Ke(t.jsonSchema,e)));if(s.length)throw new d(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function Lt(e){let t=r(e)?.context;if(!t)return;let n=h;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new d(`config`,`Profile ${e.id}: inputs.context.from must list ${h.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new d(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function Z(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 d(`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 d(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Rt(e,t,n){let i=new Map,a=a=>{let o=Y(a),s=n&&o.type!==`host`?{...o,models:Object.fromEntries(Object.entries(o.models).map(([e,t])=>[e,ee(n.require(t.provider,t.apiId),t,o.type)]))}:o;if(jt(e,s),Mt(e,s),s.type!==`host`&&s.type!==`decision`&&s.type!==`embedding`){Pt(e,s),Z(s.id,r(s)),Lt(s),It(t,s);for(let[e,t]of Object.entries(s.models))t.compaction&&Ot(i,s,e,t.compaction)}i.set(s.id,s)};return{register:a,registerMany(e){for(let t of e)a(t)},get(e){let t=i.get(e);if(!t)throw new d(`config`,`Unknown profile '${e}'`);return t},find:e=>i.get(e),has:e=>i.has(e),list:()=>[...i.values()],clear:()=>i.clear()}}function zt(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 d(`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 d(`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 d(`blocked`,`Local requests must stay on the configured origin.`))}}var Bt=n({data:t(n({id:e().min(1)}))});async function Vt(e,t){let n=Q(e);if(!n?.fetch)throw new d(`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 d(`network`,`Local model list returned HTTP ${r.status}.`);let i=Bt.safeParse(await r.json());if(!i.success)throw new d(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var Ht=`https://openrouter.ai/api/v1/models`,Ut=`https://openrouter.ai/api/v1/embeddings/models`,Wt=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],Gt=[{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)`}],Kt={text:`text`,image:`image`,speech:`speech`,transcription:`transcription`,live:void 0,embedding:void 0},qt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Jt=n({data:t(n({id:e().min(1),name:e().optional()}))}),Yt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),Xt=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 d(`auth`,`${e} refused the key.`);if(!r.ok)throw new d(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Zt(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?Gt:Wt];if(e===`openrouter`)return await Qt(t,i,r);if(!i)throw new d(`auth`,`Choose a key to list Gemini models.`);return await en(t,i,r)}async function Qt(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Jt.safeParse(await $(`OpenRouter`,Ut,r));if(!e.success)throw new d(`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=Kt[e];if(!i)return[];let a=qt.safeParse(await $(`OpenRouter`,`${Ht}?output_modalities=${i}`,r));if(!a.success)throw new d(`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 $t={live:`bidiGenerateContent`,embedding:`embedContent`};async function en(e,t,n){let r=$t[e]??`generateContent`,a=[],o;for(let e=0;e<Xt;e++){let e=new URL(i);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=Yt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new d(`bad_response`,`Google returned an invalid model list.`);for(let e of s.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);a.push({id:t,label:e.displayName??t})}if(o=s.data.nextPageToken,!o)break}return a}function tn(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function nn(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Ve as S,S as _,tn as a,y as b,Y as c,qe as d,L as f,Le as g,D as h,Q as i,Je as l,I as m,Vt as n,nn as o,F as p,Zt as r,Rt as s,zt as t,Ge as u,Re as v,v as x,w as y};
1
+ import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{Cn as r,Dn as i,H as a,Sn as o,Tn as s,Xt as c,fn as l,ir as ee,ln as te,un as ne,wn as u}from"./tool-schema-AZU-YfMK.js";import{c as d}from"./host-patterns-F-KZIzkF.js";import{Cr as re,Hr as f,In as ie,Jn as p,Ln as ae,Nn as oe,Rn as se,Rr as ce,Ur as le,ar as ue,cn as de,gn as m,hn as fe,in as h,kr as pe,mr as me,or as he,xn as g}from"./shaped-data-F3datIeG.js";import{E as ge,b as _e,j as ve,k as ye,v as _,w as be}from"./schema-DfzrdK9g.js";import{a as xe,n as Se}from"./live-ingress-OuSlQ6q7.js";var Ce=2,we=4,Te=3,Ee=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,De=/^[A-Za-z0-9+/]*={0,2}$/,Oe=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 ke(e,t){if(t.limitsByMime){let n=i(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),a=`${r}/*`;if(t.limitsByMime[a])return t.limitsByMime[a]}return t.maxBytes}function y(e){return`uri`in e}function Ae(e){if(e.type===`speech`)throw new d(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new d(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new d(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new d(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function je(e){let t=0;return e.endsWith(`==`)?t=Ce:e.endsWith(`=`)&&(t=1),Math.floor(e.length*Te/we)-t}function Me(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Ne(e){return e.replace(Ee,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Pe(e,t,n){let r=Me(t);return e===`text/csv`&&(r=Ne(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=>!r(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function Fe(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=ke(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,...Fe([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Ie={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:Ie[e.code],params:t}}function Le(e,t){let n=C(e);return f(n.key,n.params,t)}function Re(e){return new d(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function w(e){if(!De.test(e))throw new d(`request`,`attachment data must be base64`);return je(e)}function T(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=w(e.data)),t}function ze(e,t,n){if(!Be(t,n))return;let r=Ae(e),i=S({attachments:u(e,`attachments`),voice:u(e,`voice`),limits:r},(t??[]).map(T),(n??[]).map(T));if(i.length>0)throw Re(i)}function E(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Oe.has(i(n)))return e;let a=Pe(n,ue(r),t);return{...e,data:he(a)}}function Be(e,t){return(e?.length??0)>0||(t?.length??0)>0}function Ve(e,t,n,r){return ze(e,t,n),{attachments:t?.length?t.map(e=>E(e,r.attachment)):t,voice:n?.length?n.map(e=>E(e,r.voice)):n}}function D(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function O(e){return e==null}function k(e){return O(e)||typeof e!=`object`||Array.isArray(e)?null:e}function A(e){let t=k(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function j(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function M(e){let t=e.properties;return k(t)??{}}function He(e,t){return e?`${e}.${t}`:t}function N(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function Ue(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 We(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s}=e;if(O(r)){i&&N(t,s);return}await Ue(t,r,a?.[t],o,s);let c=A(n),l=c?k(r):null;c&&l&&await P(c,l,t,a,o,s)}async function P(e,t,n,r,i,a){let o=M(e),s=new Set(j(e)),c=new Set([...Object.keys(o),...s]),l=k(t);for(let e of c)await We({path:He(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,options:i,failures:a})}async function Ge(e,t,n,r){let i=A(e);if(!i)throw new d(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!k(t)){for(let e of j(i))N(e,a);return a}return await P(i,t,``,n,r,a),a}function Ke(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return!1;let r=M(t);if(!Object.hasOwn(r,e)&&!j(t).includes(e))return!1;n=r[e]}return!0}function qe(e){return e.map(e=>e.error).join(`; `)}function F(e,t){let n=e;for(let e of t.split(`.`))n=k(n)?.[e];return n}function I(e,t,n){let[r,...i]=t.split(`.`),a=k(e)??{};return r===void 0?e:{...a,[r]:i.length?I(a[r],i.join(`.`),n):n}}async function Je(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=F(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 L(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return;n=M(t)[e]}let r=k(n);if(r?.type===`array`)return k(r.items)??void 0}function Ye(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new d(`config`,f(`provider.binding_identity`))}function Xe(e){z(e.id,e.models),J(e.id,e.observability),Z(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Ze(e){z(e.id,e.models),K(e.id,e.guardrails),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new d(`config`,`Profile ${e.id}: a transcription takes a voice clip, so inputs.text must be false`);return{type:`transcription`,id:e.id,identity:{handle:e.identity.handle},...U(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function R(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new d(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function Qe(e,t,n){if(R(e,t,n,ne),Ye(e,t,n,`decision`),`retry`in n)throw new d(`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 d(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function $e(e){let t=e.models?D(e.models):void 0;if(!t)throw new d(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Qe(e.id,t,e.models[t])}function et(e){if(e.inputs.state!==`json`)throw new d(`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 d(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new d(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function tt(e){return $e(e),et(e),J(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function nt(e){return e===void 0?{}:{parallel:e}}function rt(e){return it(e.id,e.tools),J(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function it(e,t){if(!Array.isArray(t.allow))throw new d(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function z(e,t){if(Object.keys(t).length===0)throw new d(`config`,`Profile ${e} must declare at least one model`)}function B(e,t){let n=t.defaultModel??D(t.models);if(!n)throw new d(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new d(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function V(e,t,n){H(e,t,n),R(e,t,n,l),H(e,t,n)}function H(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new d(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!g.includes(i))throw new d(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${g.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new d(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new d(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new d(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function U(e){return{providerContinuation:e.providerContinuation?ee.parse(e.providerContinuation):{},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function W(e,t,n){if(n?.length){for(let r of n)if(!c(r))throw new d(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function at(e,t){t&&(W(e,`allowContinue`,t.allowContinue),W(e,`autoContinue`,t.autoContinue))}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ot(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>G(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var st=Object.entries(fe).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function ct(e){if(!G(e))throw new d(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new d(`config`,`Profile definition must set id`);if(!m.find(t=>t===e.type))throw new d(`config`,`Profile ${t}: type must be one of ${m.join(`, `)}`)}function lt(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 d(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function ut(e){let{id:t,type:n}=e,r=e;for(let[e,i]of st){if(i&&!i.includes(n))continue;let a=ae(e),o=ot(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!G(e))return!1;let t=e[s];return t==null||t===``}))throw new d(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function dt(e){let{id:t,type:n}=e;if(n!==`live`&&se(`inputs`).includes(n)&&e.inputs==null)throw new d(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ft(e){let[t]=ie(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new d(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function pt(e,t){let n=t.turnBehaviour;at(e,n?.resumption)}function mt(e,t){let n=t=>new d(`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 K(e,t){let n=t=>new d(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!q.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${q.join(`, `)}`);gt(t?.blockedReply,n)}var q=[`quota`,`detect`,`blockedReply`,`network`,`taint`],ht=[`onBlock`,`maxRetries`];function gt(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!ht.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&&!me.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${me.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function _t(e){let t=e.guardrails?.detect,n=e.type===`host`?p(`guardrails.detect`,t,re):p(`guardrails.detect`,t);if(n!==void 0)throw new d(`config`,`Profile ${e.id}: ${n}`)}function J(e,t){try{let n=xe(t);if(!Number.isFinite(n.retainForDays))throw new d(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new d(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof d&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new d(pe(t),`Profile ${e}: ${n}`,{cause:t})}}function vt(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`transcription`||e.type===`embedding`)return;let{options:t,system:n}=e.identity,r=n??``;be(r,`Profile ${e.id} identity.system`);let i=ge(r,t,e.inputs?.options);if(i)throw new d(`config`,`Profile ${e.id} identity.system: ${i}`)}function Y(e){let t=yt(e),[n]=oe(e);if(n)throw new d(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function yt(e){ct(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new d(`config`,f(`provider.profile_configuration`,{profile:e.id,field:t}));ft(e),dt(e),ut(e),lt(e),e.labels&&le(e.labels,`Profile ${e.id}`);for(let t of ce)if(e.labels?.[t]!==void 0)throw new d(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(vt(e),_t(e),e.type===`host`)return rt(e);if(e.type===`decision`)return tt(e);if(e.type===`embedding`)return Xe(e);if(e.type===`transcription`)return Ze(e);z(e.id,e.models),pt(e.id,e),K(e.id,e.guardrails),e.type===`text`&&mt(e.id,e.outputs?.validation),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,options:e.identity.options,system:e.identity.system},n=e.guardrails,r=e.observability,i=e.labels,a=U(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs: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:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Tt(o.id,o.inputs.attachments?.accept),wt(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,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Se(o),Dt(o.id,o.live.contextCompression),Et(o);break;default:throw new d(`config`,`Unknown profile type '${String(e)}'`)}return St(o),bt(o),xt(o),o}function bt(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function xt(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new d(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function St(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=ve(e,t.by);if(!n)throw new d(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=ye(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new d(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var Ct={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 wt(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Ct)){let a=t[n];if(a!==void 0&&!r(a))throw new d(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(o(t.mimeType)!==`image`)throw new d(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(y(t)?t.uri:t.data))throw new d(`config`,`${r} needs its bytes or its uri`)})}function Tt(e,t){let n=t?.filter(e=>!r(de,e));if(n?.length)throw new d(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Et(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 d(`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 d(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new d(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new d(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function Dt(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(X(`${n}.triggerTokens`,r),X(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new d(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function X(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`${e} must be a whole number above 0`)}function Ot(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(kt(i,r),At(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new d(`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 d(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new d(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function kt(e,t){if(t.maxTokens<=0)throw new d(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new d(`config`,`${e}: compactAt must be in (0, 1)`)}function At(e,t){if(t.previousExchanges<0)throw new d(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new d(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new d(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function jt(e,t){for(let n of _(t))if(e.get(n)?.type===`builtin`)throw new d(`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 Mt(e,t){let n=_e(t)?.t2Loader;if(n){if(!_(t).includes(n))throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Nt(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Pt(e,t){for(let{modelId:n,id:r}of Nt(t))if(e.get(r)?.type!==`builtin`)throw new d(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Ft(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 It(e,t){let n=Ft(t).map(n=>{let r=e.find(n);if(!r)throw new d(`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 d(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>L(t.jsonSchema,e)));if(o.length)throw new d(`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=>Ke(t.jsonSchema,e)));if(s.length)throw new d(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function Lt(e){let t=s(e)?.context;if(!t)return;let n=h;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new d(`config`,`Profile ${e.id}: inputs.context.from must list ${h.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new d(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function Z(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 d(`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 d(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Rt(e,t,n){let r=new Map,i=i=>{let a=Y(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,te(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(jt(e,o),Mt(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){Pt(e,o),Z(o.id,s(o)),Lt(o),It(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&Ot(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 d(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function zt(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 d(`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 d(`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 d(`blocked`,`Local requests must stay on the configured origin.`))}}var Bt=n({data:t(n({id:e().min(1)}))});async function Vt(e,t){let n=Q(e);if(!n?.fetch)throw new d(`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 d(`network`,`Local model list returned HTTP ${r.status}.`);let i=Bt.safeParse(await r.json());if(!i.success)throw new d(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var Ht=`https://openrouter.ai/api/v1/models`,Ut=`https://openrouter.ai/api/v1/embeddings/models`,Wt=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],Gt=[{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)`}],Kt={text:`text`,image:`image`,speech:`speech`,transcription:`transcription`,live:void 0,embedding:void 0},qt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Jt=n({data:t(n({id:e().min(1),name:e().optional()}))}),Yt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),Xt=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 d(`auth`,`${e} refused the key.`);if(!r.ok)throw new d(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Zt(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?Gt:Wt];if(e===`openrouter`)return await Qt(t,i,r);if(!i)throw new d(`auth`,`Choose a key to list Gemini models.`);return await en(t,i,r)}async function Qt(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Jt.safeParse(await $(`OpenRouter`,Ut,r));if(!e.success)throw new d(`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=Kt[e];if(!i)return[];let a=qt.safeParse(await $(`OpenRouter`,`${Ht}?output_modalities=${i}`,r));if(!a.success)throw new d(`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 $t={live:`bidiGenerateContent`,embedding:`embedContent`};async function en(e,t,n){let r=$t[e]??`generateContent`,i=[],o;for(let e=0;e<Xt;e++){let e=new URL(a);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=Yt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new d(`bad_response`,`Google returned an invalid model list.`);for(let e of s.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);i.push({id:t,label:e.displayName??t})}if(o=s.data.nextPageToken,!o)break}return i}function tn(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function nn(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Ve as S,S as _,tn as a,y as b,Y as c,qe as d,L as f,Le as g,D as h,Q as i,Je as l,I as m,Vt as n,nn as o,F as p,Zt as r,Rt as s,zt as t,Ge as u,Re as v,v as x,w as y};