@theoremjs/studio 0.3.5-next.907.g49f9ef9 → 0.3.5-next.911.g193d75c

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 (60) hide show
  1. package/package.json +4 -4
  2. package/page/assets/{BottomSheet-DJ9cb5VC.js → BottomSheet-gvxs6HLX.js} +1 -1
  3. package/page/assets/{ConsoleFrame-CrkDuz92.js → ConsoleFrame-DjKftiM3.js} +1 -1
  4. package/page/assets/{DateInput-D_kPjzMj.js → DateInput-BpXRJu6W.js} +1 -1
  5. package/page/assets/{MenuBottomSheet-B6ylzErW.js → MenuBottomSheet-C-aSCSIv.js} +1 -1
  6. package/page/assets/{PowerSearchBottomSheet-_QAApNi8.js → PowerSearchBottomSheet-CadUl0hQ.js} +1 -1
  7. package/page/assets/{RankedBars-DFNp1J7P.js → RankedBars-BqvXkuhw.js} +1 -1
  8. package/page/assets/{SchemaFields-Bnse-WrK.js → SchemaFields-BA_tTlTT.js} +1 -1
  9. package/page/assets/{TokenizerBottomSheet-CFzmh_oP.js → TokenizerBottomSheet-BVgCEcFv.js} +1 -1
  10. package/page/assets/{ToolResultCharts-BwBVFDBV.js → ToolResultCharts-Ju_2APDe.js} +1 -1
  11. package/page/assets/{Toolbar-C5dAAZpA.js → Toolbar-Bodaemo6.js} +1 -1
  12. package/page/assets/{TraceInspector-BvH3QZkb.js → TraceInspector-CCjkzWyI.js} +2 -2
  13. package/page/assets/{TraceOverview-CqDj_hQK.js → TraceOverview-BtC8GQVd.js} +1 -1
  14. package/page/assets/{_virtual_studio-type-sources-eJav4ja9.js → _virtual_studio-type-sources-CdnMqL-n.js} +77 -16
  15. package/page/assets/browser-connection-8HG8E7-I.js +1 -0
  16. package/page/assets/browser-engine-nrFEmQVr.js +16 -0
  17. package/page/assets/{browser-transport-DgVZiZ-t.js → browser-transport-C4b9Cns1.js} +2 -2
  18. package/page/assets/compile--gO-Z1FH.js +4 -0
  19. package/page/assets/{encode-files-BY9Pg5LN.js → encode-files-7UPrYBrF.js} +1 -1
  20. package/page/assets/{export-agent-BeXD1eV-.js → export-agent-CJU4yuZq.js} +1 -1
  21. package/page/assets/{getRadiusAndStrokeWidthFromDot-BrBnbwsB.js → getRadiusAndStrokeWidthFromDot-Ecj-jR5D.js} +1 -1
  22. package/page/assets/{guardrail-health-Bb4E1WZU.js → guardrail-health-DFvepe74.js} +2 -2
  23. package/page/assets/{guardrail-tester-o6E552V3.js → guardrail-tester-D0nvciLt.js} +1 -1
  24. package/page/assets/{index-C-fxwEsY.js → index-DdfSX5Od.js} +18 -18
  25. package/page/assets/{json-code-BcVmPEws.js → json-code-ChVouP8g.js} +1 -1
  26. package/page/assets/{labels-provider-DlvOtCm7.js → labels-provider-BO_XYaPQ.js} +1 -1
  27. package/page/assets/{live-messages-Csldhc_K.js → live-messages-BrXwocbM.js} +1 -1
  28. package/page/assets/{prompt-row-DMhSHwaK.js → prompt-row-D7xmJLxc.js} +1 -1
  29. package/page/assets/reader-CfENH3jS.js +5 -0
  30. package/page/assets/registry-BOVP_lQO.js +1 -0
  31. package/page/assets/{schema-B3Tv1Fpx.js → schema-dtr41Lr7.js} +2 -2
  32. package/page/assets/{shaped-data-Dp2yZFfd.js → shaped-data-9kDvR1de.js} +8 -8
  33. package/page/assets/{stub-BlSgwV6N.js → stub-B275bXj-.js} +1 -1
  34. package/page/assets/{studio-code-pane-C39Jn0aZ.js → studio-code-pane-epOb7YCi.js} +3 -3
  35. package/page/assets/{studio-console-D7AL_5Jk.js → studio-console-KObtCJyc.js} +1 -1
  36. package/page/assets/{studio-decision-DZy88Msx.js → studio-decision-CJWMloET.js} +1 -1
  37. package/page/assets/{studio-embedding-CPuNB8Cx.js → studio-embedding-CGKFrG_-.js} +1 -1
  38. package/page/assets/{studio-host-console-C4Waj0p6.js → studio-host-console-C5oeUj4u.js} +2 -2
  39. package/page/assets/studio-labels-EVPkcfTG.js +3 -0
  40. package/page/assets/{studio-live-DreXKuYt.js → studio-live-B6Iy_esj.js} +1 -1
  41. package/page/assets/{studio-map-BM9X_QWw.js → studio-map-DnuXEuzm.js} +1 -1
  42. package/page/assets/{studio-trace-replay-OT4Dv2jU.js → studio-trace-replay-Dxc3ePxC.js} +1 -1
  43. package/page/assets/{studio-type-checker-DfOTBf8z.js → studio-type-checker-Cg2BuLET.js} +1 -1
  44. package/page/assets/{tool-schema-BSpmtaaV.js → tool-schema-D6i-fwc5.js} +1 -1
  45. package/page/assets/{trace-record-DGajv3HL.js → trace-record-DFHRIoSR.js} +1 -1
  46. package/page/assets/tree-DXvClIpQ.js +3 -0
  47. package/page/assets/{turn-client-CdXgO5_p.js → turn-client-Cl1P1QP9.js} +2 -2
  48. package/page/assets/types-Bl2lxigr.js +1 -0
  49. package/page/assets/{use-one-call-JqYC-s7k.js → use-one-call-BKua0dRg.js} +1 -1
  50. package/page/assets/{useDismissSearchOnTouchDrag-BIu0LXgG.js → useDismissSearchOnTouchDrag-lH0YZH1H.js} +1 -1
  51. package/page/assets/{workspace-Cb2ALxS2.js → workspace-BpEiFb5f.js} +1 -1
  52. package/page/index.html +17 -17
  53. package/page/assets/browser-connection-EIPuJ9Z-.js +0 -1
  54. package/page/assets/browser-engine-Z4OjlXXG.js +0 -16
  55. package/page/assets/compile-C8OL7ghD.js +0 -4
  56. package/page/assets/reader-nH_7s6ie.js +0 -5
  57. package/page/assets/registry-DT8TxCzH.js +0 -1
  58. package/page/assets/studio-labels-jMBxTLIr.js +0 -3
  59. package/page/assets/tree-VPRvFY4g.js +0 -3
  60. package/page/assets/types-Dxa9Ol2S.js +0 -1
@@ -1,4 +0,0 @@
1
- import{t as e}from"./createReactComponent-DVEyVJ-p.js";import{F as t,R as n,Y as r,_ as i,h as a,i as o,j as s,q as c,v as l,z as u}from"./tool-schema-BSpmtaaV.js";import{$i as d,Ba as f,Ia as p,Ki as m,Pa as h,Si as g,Yi as _,ia as v,na as ee,no as te,nt as ne,oa as re,xi as ie,yn as ae}from"./shaped-data-Dp2yZFfd.js";import{c as oe,r as se}from"./host-patterns-F-KZIzkF.js";import{C as y,G as ce,J as le,K as ue,S as b,U as de,_ as fe,h as pe,l as me,m as he,q as ge,s as x,t as S}from"./tree-VPRvFY4g.js";import{c as _e}from"./browser-connection-EIPuJ9Z-.js";import{T as ve,k as ye,l as be,n as C,s as xe}from"./schema-B3Tv1Fpx.js";import{a as Se,r as Ce}from"./live-ingress-OuSlQ6q7.js";import{n as we,t as Te}from"./types-Dxa9Ol2S.js";var Ee=e(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),De=e(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),w=`••••`,Oe=/auth|key|token|secret|passw|pwd|cookie|session|signature|^sig$|credential|^code$|appid/i,ke=/auth|key|token|secret|passw|pwd|signature|credential|appid/i,Ae=[[/^AIza/,`Google API key`],[/^sk-or-/,`OpenRouter key`],[/^sk-ant-/,`Anthropic key`],[/^sk-/,`OpenAI key`],[/^(?:ghp_|github_pat_)/,`GitHub token`],[/^xox[baprs]-/,`Slack token`],[/^AKIA/,`AWS access key id`],[/^eyJ[\w-]+\.[\w-]+\./,`JWT`],[/^Bearer\s/i,`a whole Bearer header, not a bare token`],[/^https?:\/\//i,`a URL, not a key`]],je=16;function Me(e,t={}){let n=typeof e==`string`?e:``,r=n.trim(),i=[];/^(?:<.*>|x{3,}|\.{3}|your[-_ ]?(?:api[-_ ]?)?key|changeme|todo)$/i.test(r)?i.push(`a placeholder, not a real value`):(r&&r!==n&&i.push(`spaces or a line break around it`),/[\r\n]/.test(r)?i.push(`a line break inside`):/\s/.test(r)&&i.push(`a space inside`),/^(['"`]).*\1$/.test(r)&&i.push(`wrapped in quotes`),r&&r.length<je&&i.push(`shorter than keys usually are`));let a=Ae.find(([e])=>e.test(r))?.[1];return{secret:!0,set:r.length>0,...a?{looksLike:a}:{},problems:i,sameAs:[...t.sameAs??[]],usedBy:[...t.usedBy??[]]}}var T=/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]*)@/i,E=/([?&;])([^=?&;#\s]*)=([^&;#\s]*)/g;function D(e){let t=e.indexOf(`:`);return t<0?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function Ne(e){try{return decodeURIComponent(e)}catch{return e}}function O(e){return Oe.test(e)}function Pe(e){let t=URL.canParse(e)?Oe:ke;return e.replace(T,(e,t,n)=>{let[r,i]=D(n);return`${t}${r&&`••••`}${i===void 0?``:`:${i&&`••••`}`}@`}).replace(E,(e,n,r,i)=>i&&t.test(Ne(r))?`${n}${r}=${w}`:e)}function Fe(e,t){let[n,r]=D(T.exec(t)?.[2]??``),i=new Map;for(let[,,e=``,n=``]of t.matchAll(E))i.set(e,[...i.get(e)??[],n]);return e.replace(T,(e,t,i)=>{let[a,o]=D(i),s=a===`••••`&&n?n:a,c=o===`••••`&&r?r:o;return`${t}${s}${c===void 0?``:`:${c}`}@`}).replace(E,(e,t,n,r)=>{let a=r===`••••`?i.get(n)?.shift():void 0;return a?`${t}${n}=${a}`:e})}function Ie(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n===`••••`?t?.[e]??n:n]))}function Le(e){if(e==null||e===``)return e;let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return`(not a JSON object, ${String(e.length)} characters)`}if(typeof t!=`object`||!t||Array.isArray(t))return`(not a JSON object)`;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,O(e)?w:t]));return typeof e==`string`?JSON.stringify(n):n}var Re=/\{\s*private\s*:/g,ze=/\n(?:[ \t]*\n)+/;function Be(e){let[t,...n]=e;if(t===void 0)return;if(n.length===0&&typeof t==`string`)return t.trim()||void 0;let r=[...e],i=e.at(-1);typeof t==`string`&&(r[0]=t.trimStart()),typeof i==`string`&&(r[r.length-1]=i.trimEnd());let a=r.filter(e=>e!==``),[o,...s]=a;return s.length===0&&typeof o==`string`?o:a}function Ve(e){let t=[[]],n=e=>{let[n=``,...r]=e.split(ze);t.at(-1)?.push(n),t.push(...r.map(e=>[e]))},r=0;for(let i of e.matchAll(Re)){if(i.index<r)continue;let a=1,o=i.index+i[0].length;for(;o<e.length&&a>0;o++)e[o]===`{`?a++:e[o]===`}`&&a--;if(n(e.slice(r,i.index)),a>0)return{ok:!1,message:`The {private: section on line ${String(t.length)} has no closing }.`};let s=e.slice(i.index+i[0].length,o-1).trim();if(!s)return{ok:!1,message:`The {private: section on line ${String(t.length)} is empty.`};t.at(-1)?.push({private:s}),r=o}return n(e.slice(r)),{ok:!0,lines:t.flatMap(e=>{let t=Be(e.filter(e=>e!==``));return t===void 0?[]:[t]})}}function k(e){return typeof e==`string`?e.trim()?[e]:[]:[...e]}function He(e){return k(e).map(e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:`{private: ${e.private}}`).join(``)).join(`
2
-
3
- `)}function Ue(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}var We=()=>void 0,Ge=()=>void 0;function A(e){return(e??[]).map(e=>e.trim()).filter(Boolean)}function j(e,t,n,r,i,a){i===null||Number.isInteger(i)&&i>=a||e(t,`${r} must be a ${a?`positive`:`non-negative`} whole number.`,n)}var Ke={agentId:{label:`Profile id`,max:64},handle:{label:`Handle`,max:32}};function M(e,t,n){let{label:r,max:i}=Ke[t];n.trim()?Array.from(n).length>i&&e(`identity`,`${r} is at most ${i} characters.`,t):e(`identity`,`${r} is required.`,t)}function qe(e,t){M(t,`agentId`,e.identity.agentId),e.identity.profileType!==`host`&&M(t,`handle`,e.identity.handle)}function N(e,t,r,i){let a=S(e.key),o=s(r,t,{...e,apiId:e.apiId.trim()}),c=r.find(t=>t.id===e.provider);if(!c)i(a,`No provider is defined as ${e.provider}.`,`provider`);else if(!u(c,t))i(a,`${e.provider} doesn't serve ${t} agents.`,`provider`);else if(!u(c,t,e.protocol)){let r=(n(c,t)??[]).map(e=>e.id).join(` or `);i(a,r?`${e.provider} runs ${t} agents on ${r}, not ${e.protocol}.`:`${e.provider} doesn't serve ${t} agents on ${e.protocol}.`,`protocol`)}return o.apiId||i(a,`API model is required.`,`apiId`),o}function P(e){return e.length<2?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function Je(e,n){let r=t(e).map(e=>e.path.split(`.`)[0]??e.path).find(e=>e.toLowerCase()===n.toLowerCase());return r?`${e.id} has no option ${n}. Did you mean ${r}?`:`${e.id} has no option ${n}.`}function Ye(e,t,n,i){let o={};e.efforts.forEach(({alias:s,level:c},l)=>{let u=s.trim();u?u in o?i(n,`Effort alias '${u}' is used twice.`,`efforts`,l):o[u]=c:i(n,`Every effort needs an alias.`,`efforts`,l),a(t)&&!r.includes(c)&&i(n,`${e.provider} takes the ${P(r)} thinking level, not ${c}.`,`efforts`,l)}),e.allowEffortSelect&&Object.keys(o).length<2&&i(n,`Effort select needs at least two efforts.`,`allowEffortSelect`);let s=e.defaultEffort.trim();if(!s&&ue(e))i(n,`Pick a default effort — there is more than one.`,`defaultEffort`);else if(s&&!(s in o)){let e=Object.keys(o);i(n,e.length?`Default effort '${s}' is not one of the efforts. Pick ${P(e)}.`:`Default effort '${s}' is not one of the efforts.`,`defaultEffort`)}return{efforts:o,defaultEffort:s}}function Xe(e,t,n,r,i){let a=S(e.key),o=N(e,t,n,r),{apiId:s}=o,{efforts:c,defaultEffort:l}=Ye(e,o,a,r),u=Object.keys(c).length;j(r,a,`maxOutputTokens`,`Max output tokens`,e.maxOutputTokens,1),e.temperature!==null&&!(Number.isFinite(e.temperature)&&e.temperature>=0)&&r(a,`Temperature must be zero or more.`,`temperature`),I(e,n,t,a,r);let d=Ze(e,t,a,r,i),f=F(e,a,r);return{protocol:e.protocol,provider:e.provider,apiId:s,...e.keySlot?{keySlot:e.keySlot}:{},...e.fallbackKeySlot?{fallbackKeySlot:e.fallbackKeySlot}:{},...u?{efforts:c}:{},...l?{defaultEffort:l}:{},...e.allowEffortSelect?{allowEffortSelect:!0}:{},...e.summaries===null?{}:{summaries:e.summaries},...e.maxOutputTokens===null?{}:{maxOutputTokens:e.maxOutputTokens},...e.temperature===null?{}:{temperature:e.temperature},...e.builtInTools.length?{builtInTools:[...e.builtInTools]}:{},...Object.keys(e.options).length?{options:e.options}:{},...f?{limits:f}:{},...d?{compaction:d}:{}}}function F(e,t,n){let r={};for(let{name:i,label:a,isTimer:o}of pe){let s=e.limits?.[i]??null;s!==null&&(j(n,t,`limits.${i}`,a,s,1),o&&s>2147483647&&n(t,`${a} must be at most ${fe} ms.`,`limits.${i}`),r[i]=s)}return Object.keys(r).length?r:void 0}function I(e,t,r,i,a){let o=t.find(t=>t.id===e.provider),s=o&&n(o,r)?.find(t=>t.id===e.protocol);for(let t of s?.options.safeParse(e.options).error?.issues??[]){let e=t.code===`unrecognized_keys`?t.keys[0]:t.path[0];a(i,s&&t.code===`unrecognized_keys`&&typeof e==`string`?Je(s,e):t.message,typeof e==`string`?`options.${e}`:`options`)}let c=e.apiId.trim();for(let t of c?s?.refusedOptions?.(c)??[]:[])e.options[t]!==void 0&&a(i,`${c} takes no ${t}.`,`options.${t}`)}function Ze(e,t,n,r,i){let a=e.compactTiming;if(!a)return;t!==`text`&&r(n,`Only a text agent compacts its own history.`,`compactTiming`);let o=e.compactMaxTokens??null,s=e.compactAt??me.compactAt,c=e.compactKeep??null;o===null&&r(n,`Compaction needs a budget.`,`compactMaxTokens`),j(r,n,`compactMaxTokens`,`Budget`,o,1),s>0&&s<1||r(n,`Compaction must start between 0 and 1 of the budget.`,`compactAt`),c!==null&&(c===0||Number.isInteger(c)&&c>=1||c>0&&c<s)||r(n,`Keep a whole number of exchanges, a fraction of the budget below where compaction starts, or 0.`,`compactKeep`);let l=e.compactWith??``,u=l?i(l):void 0;return l&&!u&&r(n,`The agent that summarised is gone. Pick another, or this agent.`,`compactWith`),{maxTokens:o??0,compactAt:s,...u?{profile:u}:{},previousExchanges:c??0,timing:a,...e.compactMeter?{meter:e.compactMeter}:{}}}function Qe(e,t,n){let{models:r,modelBindings:i}=e;i.length||n(`models`,`Add at least one model.`);let a=r.defaultModel.trim();return a&&!(a in t)?n(`models`,`Default model '${a}' is not one of the models.`,`defaultModel`):!a&&ge(e)&&n(`models`,`Pick a default model — there is more than one.`,`defaultModel`),r.maxSteps!==null&&!Number.isInteger(r.maxSteps)&&n(`models`,`Max steps must be a whole number.`,`maxSteps`),a}function $e(e,t,n,r){let{models:i,modelBindings:a}=e,o={};for(let s of a){let a=Xe({...s,keySlot:s.keySlot||i.key||void 0,fallbackKeySlot:s.fallbackKeySlot||i.fallbackKey||void 0},t,e.providers,n,r),c=s.modelId.trim(),l=S(s.key);c?c in o?n(l,`Model id '${c}' is used twice.`,`modelId`):o[c]=a:n(l,`Model id is required.`,`modelId`)}let s=Qe(e,o,n),c=i.providerHistory===`provider`||i.providerHistory===`stateless`?i.providerHistory:void 0;return{models:o,...s?{defaultModel:s}:{},...c?{providerContinuation:{history:c}}:{},...i.allowModelSelect?{allowModelSelect:!0}:{},...i.maxSteps===null?{}:{maxSteps:i.maxSteps}}}function L(e,t){if(!e?.trim())return;let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=Object.entries(n);return r.every(([,e])=>t(e))?r.length?Object.fromEntries(r):void 0:null}var et=e=>typeof e==`string`,tt=e=>!0;function nt(e){return L(e,et)}function rt(e){let t=new Set;return e.flatMap(e=>{let n=e.name.trim();return!n||e.choices.length===0||t.has(n)?[]:(t.add(n),[{...e,name:n}])})}function R(e){if(e.length!==0)return Object.fromEntries(e.map(({name:e,label:t,choices:n})=>[e,{...t.trim()?{label:t.trim()}:{},choices:n.map(({value:e,description:t})=>t.trim()?{value:e,description:t.trim()}:{value:e})}]))}function it({choices:e}){let t=e.find((t,n)=>e.findIndex(e=>e.value===t.value)!==n)?.value;return t===void 0?void 0:`${t} is listed twice.`}function at(e,t){let n=new Set,r=!1;return e.forEach((e,i)=>{let a=e.name.trim();if(!a&&e.choices.length===0)return;let o={[a]:{choices:e.choices.map(({value:e})=>({value:e}))}},s=a?n.has(a)?`Two options are called "${a}".`:e.choices.length===0?`This option needs a value.`:it(e)??ye(o,void 0):`This option needs a name.`;n.add(a),s&&(r=!0,t(`identity`,s,`options`,i))}),r}function z(e,t){let n=e.identity.system,r=k(n).length===0?void 0:n,i=at(e.identity.options,t),a=rt(e.identity.options),o=R(a.filter(e=>!e.isShownInChat)),s=R(a.filter(e=>e.isShownInChat));if(r!==void 0&&!i){let e=ve(r,o,s);e&&t(`identity`,e,`system`)}return{system:r,code:o,person:s}}function ot(e,t,n){let r=L(e,t);return r===null&&n(),r??void 0}function st(e,t){if(!e.authType||e.authType===`none`)return;let n=e.authService?.trim()??``;n||t(`Service is required.`,`authService`);let r=A(e.authScopes),i=e.authType===`api_key`?e.authQueryParam?.trim():void 0;i&&A(e.queryParams).includes(i)&&t(`${i} is also one of the query parameters the model fills.`,`authQueryParam`);let a=i?{queryParam:i}:{...e.authHeaderName?.trim()?{headerName:e.authHeaderName.trim()}:{},...e.authHeaderPrefix===void 0?{}:{headerPrefix:e.authHeaderPrefix}};return{slot:e.authSlot?.trim()||`default`,type:e.authType,service:n,...a,onUnauthenticated:e.authUnauthenticated??`gate`,...r.length?{scopes:r}:{},...e.authClientId?.trim()?{clientId:e.authClientId.trim()}:{},...e.authRedirectUri?.trim()?{redirectUri:e.authRedirectUri.trim()}:{}}}function ct(e){try{return new URL(e),!0}catch{return!1}}function lt(e,t){e?i(e)&&t(`${e} is a provider builtin — turn it on under the model's built-in tools.`,`toolName`):t(`Tool name is required.`,`toolName`)}function ut(e,t,n){let r=e.toolName.trim();lt(r,t);let i=e.description.trim();i||t(`Description is required.`,`description`);let a=e.toolType===`agent`?{inputSchema:n(e.agentKey??``)??ft,outputSchema:pt}:dt(e,t),o=A(e.paths);return{name:r,description:i,category:e.category.trim()||`studio`,access:e.access,permission:e.permission,loadTier:e.loadTier,paths:o.length?o:[`*`],...e.after?{after:!0}:{},...e.background?{background:e.background}:{},...a}}function dt(e,t){let n=o(e.inputJson,`Input`);n.ok||t(n.error,`inputJson`);let r=o(e.outputJson,`Output`);return r.ok||t(r.error,`outputJson`),{inputSchema:n.ok?n.schema:{},outputSchema:r.ok?r.schema:{}}}var ft=C(xe({type:`text`}),`input`),pt=C(be,`output`);function mt(e){let t=e.identity.profileType;if(t!==`text`&&t!==`image`&&t!==`speech`)return;let n=t!==`speech`&&y(e).includes(`inputs`)?G(e.inputs,z(e,()=>{}).person,t,()=>{}):void 0;return C(xe({type:t,...n?{inputs:n}:{}}),`input`)}function ht(e){return(e??``).split(`
4
- `).map(e=>e.trim()).filter(Boolean)}function gt(e,t,n){let r={},i={activity:{input:t.inputSchema},activityPast:{input:t.inputSchema,output:t.outputSchema},activityFailed:{input:t.inputSchema},request:{input:t.inputSchema}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let a=ht(e[t]),[o]=a;if(o===void 0)continue;let s=a.length===1?o:a,c=ne(s,i[t]);c?n(c,t):r[t]=s}return Object.keys(r).length?r:void 0}function B(e){let t=Object.entries(e??{}).find(([e,t])=>O(e)&&t!==`••••`)?.[0];return t?`${t} looks like a credential. Put it under Auth instead: Auth asks for it when a call runs and nothing saves it.`:void 0}function V(e){if(!e||!URL.canParse(e))return;let t=[...new URL(e).searchParams].find(([e,t])=>O(e)&&t&&t!==`••••`)?.[0];return t?`${t} in the URL looks like a credential. Put it under Auth instead, as an API key with ${t} as its query parameter: Auth asks for it when a call runs and nothing saves it.`:void 0}function H(e,t){let n=nt(e.headersJson);n===null&&t(`Headers must be a JSON object of strings. Until they are, a reload brings back the headers as they started.`,`headersJson`);let r=B(n??void 0);r&&t(r,`headersJson`);let i=e.toolType===`mcp`?`serverUrl`:`endpoint`,a=V(e[i]?.trim());a&&t(a,i);let o=st(e,t),s=e.maxResponseBytes??null;return s!==null&&!(Number.isInteger(s)&&s>=1)&&t(`Max response must be a positive whole number.`,`maxResponseBytes`),{...n?{headers:n}:{},...o?{auth:o}:{},...s===null?{}:{maxResponseBytes:s}}}function U(e,t,n,r){let i=e[t]?.trim()??``;return i?ct(i)||r(`${n} must be a full URL.`,t):r(`${n} is required.`,t),i}function _t(e,t,n){let r=U(e,`endpoint`,`Endpoint URL`,n),i=A(e.pathParams),a=A(e.queryParams),o=e.bodyParam?.trim(),s={...i.length?{pathParams:i}:{},...a.length?{queryParams:a}:{},...o?{bodyParam:o}:{}};return{type:`http`,...t,endpoint:r,method:e.method??ie[0],...H(e,n),...Object.keys(s).length?{mapping:s}:{}}}function vt(e,t,n){let r=U(e,`serverUrl`,`MCP server URL`,n),i=e.mcpToolName?.trim()??``;return i||n(`MCP tool name is required.`,`mcpToolName`),{type:`mcp`,...t,serverUrl:r,mcpToolName:i,...H(e,n),...yt(e,n)}}function yt(e,t){let n=e.sessionIdleMs??null,r=e.sessionMax??null;n!==null&&!(Number.isInteger(n)&&n>=1)&&t(`Idle must be a positive whole number.`,`sessionIdleMs`),r!==null&&!(Number.isInteger(r)&&r>=1)&&t(`Max must be a positive whole number.`,`sessionMax`);let i={...n===null?{}:{idleMs:n},...r===null?{}:{max:r}};return Object.keys(i).length?{session:i}:{}}function bt(e,t,n){let r=e.answeredBy===`page`?{answeredBy:`page`}:{};if(!e.stubOutputJson?.trim())return{type:`function`,...t,...r};let i=o(e.stubOutputJson,`Stub output`);return i.ok||n(i.error.replace(` JSON Schema`,``),`stubOutputJson`),{type:`function`,...t,...r,...i.ok?{stubResponse:i.schema}:{}}}function xt(e,t,n,r){let i=e.agentKey??``,a=i?r(i):void 0;i?a||n(`The agent this tool ran is gone. Pick another.`,`agentKey`):n(`Pick the agent this tool runs.`,`agentKey`);let o=e.maxCallsPerTurn??null;return o!==null&&!(Number.isInteger(o)&&o>=1)&&n(`Calls per turn must be a positive whole number.`,`maxCallsPerTurn`),{type:`agent`,...t,profile:a??``,...o===null?{}:{maxCallsPerTurn:o}}}var St={http:_t,mcp:vt,function:bt,agent:xt};function Ct(e){return Te.includes(e)}function wt(e,t,n,r){let i=x(e.key);if(!Ct(e.toolType)){t(i,we,`toolType`);return}let a=!1,o=(e,n)=>{a=!0,t(i,e,n)},s=ut(e,o,r),c=gt(e,s,o),l=St[e.toolType](e,s,o,n),u=e.toolType===`agent`?``:e.stageAgentKey?.trim()??``,d=u?n(u):void 0;return a?void 0:{...l,...c?{labels:c}:{},...d&&l.type!==`agent`?{stageAgent:d}:{}}}function W(e,t,n,r,i,a){let o=[],s=new Set;for(let t of e.toolSpecs){let e=wt(t,r,i,a);e&&(s.has(e.name)?r(x(t.key),`Tool name '${e.name}' is used twice.`,`toolName`):(s.add(e.name),o.push(e)))}let c=o.map(e=>e.name),l=t?e.tools.t2Loader.trim():``;l&&!s.has(l)&&r(`tools`,`T2 loader '${l}' must be one of the custom tools.`,`t2Loader`);let u=n&&e.tools.parallel;return{customTools:o,tools:{allow:c,...l?{t2Loader:l}:{},...u?{parallel:u}:{}}}}function G(e,t,n,r){let i=n===`image`?e.attachmentsAccept.filter(e=>!ae(g,e)):[];if(i.length&&r(`inputs`,`An image profile takes images, video, and PDF only, not ${i.join(`, `)}.`,`attachmentsAccept`),!e.text&&!e.attachmentsAccept.length&&!e.voiceAccept.length&&r(`inputs`,`Take text, files, or voice notes: with none, the agent can be sent nothing.`,`text`),le(e)){let t=[[`maxFiles`,`Max files`,e.maxFiles],[`maxBytes`,`Max bytes`,e.maxBytes],[`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes]];for(let[e,n,i]of t)i===null&&r(`inputs`,`${n} is required with attachments or voice.`,e)}j(r,`inputs`,`maxFiles`,`Max files`,e.maxFiles,1),j(r,`inputs`,`maxBytes`,`Max bytes`,e.maxBytes,1),j(r,`inputs`,`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes,1);let a=Tt(e,r),o=K(e,r);return{...e.text?{}:{text:!1},...e.attachmentsAccept.length?{attachments:{accept:[...e.attachmentsAccept]}}:{},...e.voiceAccept.length?{voice:{accept:[...e.voiceAccept]}}:{},...e.maxFiles===null?{}:{maxFiles:e.maxFiles},...e.maxBytes===null?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===null?{}:{maxTurnBytes:e.maxTurnBytes},...a?{limitsByMime:a}:{},...t?{options:t}:{},...o?{context:o}:{}}}function K(e,t){if(e.contextFrom.length)return e.contextMaxChars===null&&t(`inputs`,`Max characters is required with context.`,`contextMaxChars`),j(t,`inputs`,`contextMaxChars`,`Max characters`,e.contextMaxChars,1),{from:[...e.contextFrom],maxChars:e.contextMaxChars??0}}function Tt(e,t){let n=Object.entries(e.limitsByMime);for(let[e,r]of n)Number.isInteger(r)&&r>=1||t(`inputs`,`Max size for ${e} must be a whole number of at least 1.`,`limitsByMime`);return n.length?{...e.limitsByMime}:void 0}function Et(e,t,n){let r=K(e,n);return!t&&!r?{}:{inputs:{...t?{options:t}:{},...r?{context:r}:{}}}}function Dt(e,t,n){let{option:r,shapes:i}=e.byOption??{option:``,shapes:[]},a=[],s={};for(let e of i){let t=o(e.schemaJson,`The reply shape for '${e.choice}'`);t.ok?(a.push({id:e.schemaId,spec:{jsonSchema:t.schema}}),s[e.choice]=e.schemaId):n(`outputs`,t.error,`schemaJson`)}return a.length?{also:a,written:{by:r,map:s,fallback:t}}:void 0}function Ot(e,t,n){let r,i=t&&e.validationEnabled;if(t&&e.mode===`structured`){let t=e.schemaId.trim();t||n(`outputs`,`Structured output needs a schema id.`,`schemaId`);let i=o(e.schemaJson,`Structured output`);i.ok||n(`outputs`,i.error,`schemaJson`),t&&i.ok&&(r={id:t,spec:{jsonSchema:i.schema}})}let a=r&&Dt(e,r.id,n);r&&a&&(r={...r,also:a.also}),i&&j(n,`outputs`,`maxRetries`,`Validation max retries`,e.maxRetries,0);let s=Object.fromEntries(Object.entries(e.itemRules).map(([e,t])=>[e,{onFail:t}])),c=i?{...e.maxRetries===null?{}:{maxRetries:e.maxRetries},...Object.keys(s).length?{items:s}:{}}:{},l={...e.streamMode?{mode:e.streamMode}:{},...e.streamThoughts?{}:{streamThoughts:!1}},u={...r?{structured:a?.written??r.id}:{},...Object.keys(c).length?{validation:c}:{},...Object.keys(l).length?{streaming:l}:{}};return{...Object.keys(u).length?{outputs:u}:{},...r?{structured:r}:{}}}function kt(e,t){return e.resumeEnabled?(j(t,`turnBehaviour`,`maxContinues`,`Max continues`,e.maxContinues,1),{allowContinue:[...e.allowContinue],autoContinue:[...e.autoContinue],...e.maxContinues===null?{}:{maxContinues:e.maxContinues}}):{allowContinue:[],autoContinue:[]}}function At(e,t,n){let r=t?kt(e,n):void 0,i={...r?{resumption:r}:{},...e.allowSteering?{}:{allowSteering:!1},...e.atStepLimit===`answer`?{atStepLimit:e.atStepLimit}:{}};return Object.keys(i).length?i:void 0}function jt(e,t,n,r){let i=[],a=e=>t.has(e)||t.has(`labels`),{turnBehaviour:o,guardrails:s,outputs:c}=e;if(a(`turnBehaviour`)&&de(e)&&i.push([`turnBehaviour`,`continueInstruction`,`continue.instruction`,o.continueInstruction.trim()]),a(`guardrails`)&&n(`identity.system`)&&i.push([`guardrails`,`canaryBindNote`,`canary.bind_note`,s.canaryBindNote.trim()]),a(`guardrails`)&&n(`guardrails.quota`)&&i.push([`guardrails`,`quotaMessage`,`quota.exhausted`,s.quotaMessage.trim()]),a(`outputs`)&&n(`outputs.validation`)&&i.push([`outputs`,`repairGuidance`,`repair.default_guidance`,c.repairGuidance.trim()]),a(`guardrails`)&&n(`guardrails.blockedReply`)&&(i.push([`guardrails`,`egressRepairGuidance`,`egress.default_repair_guidance`,s.egressRepairGuidance.trim()]),i.push([`guardrails`,`egressRefusal`,`egress.refusal`,s.egressRefusal.trim()])),t.has(`labels`))for(let[t,n]of Object.entries(e.labels))he[t]||i.push([`labels`,t,t,n.trim()]);let l={};for(let[e,t,n,a]of i)if(a)try{te({[n]:a},`Profile labels`),l[n]=a}catch(n){r(e,f(n),t)}return Object.keys(l).length?l:void 0}function Mt(e,t){if(e.quotaEnabled){if(e.quotaPerDay===null)t(`guardrails`,`Quota needs turns per day.`,`quotaPerDay`);else return j(t,`guardrails`,`quotaPerDay`,`Quota per day`,e.quotaPerDay,1),{perDay:e.quotaPerDay}}}function Nt(e,t){j(t,`guardrails`,`blockedReplyMaxRetries`,`Blocked reply max retries`,e.blockedReplyMaxRetries,0);let n={...e.blockedReplyOnBlock?{onBlock:e.blockedReplyOnBlock}:{},...e.blockedReplyMaxRetries===null?{}:{maxRetries:e.blockedReplyMaxRetries}};return Object.keys(n).length?n:void 0}function Pt(e){return q(e,()=>{})}function q(e,t){let n=e.allowedHosts.map(e=>e.trim()),r=n.indexOf(``);r!==-1&&t(`guardrails`,`Allowed hosts cannot be blank.`,`allowedHosts`,r);let i=A(e.allowedSchemes);if(e.allowPrivateNetworks||n.length||i.length)return{...e.allowPrivateNetworks?{allowPrivateNetworks:!0}:{},...n.length?{allowedHosts:n}:{},...i.length?{allowedSchemes:i}:{}}}function Ft(e,t,n){let r=t.hosts.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed hosts cannot be blank.`,`allow.${e}.hosts`,i);let a=r.filter(Boolean),o={...a.length?{hosts:a}:{},...t.fromTools?{}:{fromTools:!1}};return Object.keys(o).length?o:void 0}function It(e,t){for(let[t,n]of e.entries()){let e=`Pattern ${t+1}`;if(!n.name.trim())return`${e} needs a name.`;if(n.kind===`words`){if(!A(n.words).length)return`${e} needs a word to match.`}else if(!n.pattern)return`${e} needs a regular expression.`}let n=se(``,t);if(n===void 0)return;let r=/^\.patterns\[(\d+)\](?:\.(\w+))?:? (.*)$/s.exec(n);if(!r)return n.replace(/^\.patterns/,`This`);let[,i,a,o]=r;return`Pattern ${Number(i)+1}${a?`, ${a}`:``}: ${o}`}function J(e,t,n){let r=e.map(e=>{let t=e.name.trim();if(e.kind===`words`)return{name:t,words:A(e.words)};let n=e.flags.trim();return{name:t,pattern:e.pattern,...n?{flags:n}:{}}}),i=It(e,r);return i!==void 0&&n(`guardrails`,i,t),r}function Lt(e,t,n){if(!t||!d[e].patterns)return{};let r=Y(t.hint,`sources.${e}.hint`,n),i=J(t.patterns,`sources.${e}.patterns`,n);return{...t.theorem?{}:{theorem:!1},...i.length?{patterns:i}:{},...i.length&&r?{hint:r}:{}}}function Y(e,t,n){let r=e.trim();if(!r)return;let i=re(`The retry hint`,r);return i!==void 0&&n(`guardrails`,`${i}.`,t),r}function Rt(e,t){if(!e)return`Give this detector a key, such as acme.codenames.`;let n={label:e,action:`flag`,find:X};return v(`Detect`,{[e]:n},t)===void 0?void 0:`A key is a namespace, a dot, and a name, in lower case letters, digits and _, such as acme.codenames.`}function zt(e,t,n){let r={};for(let[i,a]of e.entries()){let e=a.key.trim();if(Object.hasOwn(r,e)){n(`guardrails`,`Detector ${e} is listed twice.`,`own`,i);continue}let o=t.filter(e=>a.at[e]!==`ignore`),s=Y(a.hint,`own.${i}.hint`,n),c=J(a.patterns,`own.${i}.patterns`,n),l=a.label.trim(),u=Rt(e,t);u!==void 0&&n(`guardrails`,u,`own`,i),l||n(`guardrails`,`Give this detector a name.`,`own.${i}.label`),o.length||n(`guardrails`,`Pick what a match does. It is ignored now.`,`own.${i}.at`),u===void 0&&l&&o.length&&(r[e]={label:l,at:Object.fromEntries(o.map(e=>[e,a.at[e]])),patterns:c,...s?{hint:s}:{}})}return r}var X=()=>[];function Z(e){return e===void 0||typeof e==`string`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>{if(typeof t==`string`||t.patterns===void 0)return[e,t];let{patterns:n,...r}=t;if(e.includes(`.`))return[e,{...r,find:X}];let{hint:i,...a}=r;return[e,a]}))}function Q(e){let{guardrails:t}=e;return!t||!(`detect`in t)||t.detect===void 0?e:{...e,guardrails:{...t,detect:Z(t.detect)}}}function Bt(e,t,n){let{detect:r}=e,i={};for(let a of _){let o=t.filter(e=>r[a][e]!==ee[a][e]),s=t.some(e=>r[a][e]!==`ignore`)?Vt(a,e,n):void 0,c=Lt(a,e.sources[a],n);(o.length||s||Object.keys(c).length)&&(i[a]={...o.length?{at:Object.fromEntries(o.map(e=>[e,r[a][e]]))}:{},...c,...s?{allow:s}:{}})}Object.assign(i,zt(e.own,t,n));let a=v(`Detect`,Z(i),t);return a!==void 0&&n(`guardrails`,a,`detect`),Object.keys(i).length?i:void 0}function Vt(e,t,n){if(Ht(e))return Ft(e,t.allow[e],n);if(d[e].allow!==`names`)return;let r=t.innocentNames.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed names cannot be blank.`,`innocentNames`,i);let a=r.filter(Boolean);return a.length?{names:a}:void 0}function Ht(e){return d[e].allow===`urls`}function Ut(e){let{taintAfterRemoteRead:t,taintRemoteDestination:n}=e;if(t||n)return{...t?{afterRemoteRead:t}:{},...n?{remoteDestination:n}:{}}}function Wt(e,t,n=h){let r={detect:Bt(e,n,t),quota:Mt(e,t),blockedReply:Nt(e,t),network:q(e,t),taint:Ut(e)},i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return Object.keys(i).length?i:void 0}function Gt(e,t){let n=Se({}),{writeTo:r}=e,{sampleRate:i}=e;Number.isFinite(i)&&i>=0&&i<=1||t(`observability`,`Sample rate must be between 0 and 1.`,`sampleRate`),e.retainForDays!==null&&!Number.isFinite(e.retainForDays)&&t(`observability`,`Retain for days must be a number.`,`retainForDays`),e.rotateAfterMiB!==null&&!(Number.isFinite(e.rotateAfterMiB)&&e.rotateAfterMiB>0)&&t(`observability`,`Rotate after MiB must be more than zero.`,`rotateAfterMiB`);let a=ot(e.resourceJson,tt,()=>{t(`observability`,`Resource must be a JSON object.`,`resourceJson`)}),o=Object.fromEntries(Object.entries(e.include).filter(([e,t])=>t!==n.include[e])),s=Object.fromEntries(Object.entries(e.scrub).filter(([e,t])=>t!==n.scrub[e])),c={writeTo:r,...i===n.sampleRate?{}:{sampleRate:i},...Object.keys(o).length?{include:o}:{},...Object.keys(s).length?{scrub:s}:{},...e.retainForDays===null?{}:{retainForDays:e.retainForDays},...e.rotateAfterMiB===null?{}:{rotateAfterMiB:e.rotateAfterMiB},...a?{resource:a}:{}};return Object.keys(c).length?c:void 0}var Kt={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function qt(e){if(!URL.canParse(e))return;let t=new URL(e);return t.protocol!==`https:`&&t.protocol!==`http:`?void 0:Kt[t.pathname.split(`.`).pop()?.toLowerCase()??``]}function Jt(e,t){return e.flatMap((e,n)=>{if(`data`in e)return e.mimeType.startsWith(`image/`)&&e.data?[{mimeType:e.mimeType,data:e.data,name:e.name}]:(t(`image`,`${e.name||`A reference`} is not an image.`,`references`,n),[]);let r=e.uri.trim(),i=qt(r);return i?[{mimeType:i,uri:r,...e.name?{name:e.name}:{}}]:(t(`image`,r?`Link to a .png, .jpg, .webp or .gif image over http(s).`:`Add a link or remove the reference.`,`references`,n),[])})}function Yt(e,t){j(t,`image`,`n`,`Images per request`,e.n,1),j(t,`image`,`seed`,`Seed`,e.seed,0),j(t,`image`,`outputCompression`,`Compression`,e.outputCompression,0),e.outputCompression!==null&&e.outputCompression>100&&t(`image`,`Compression goes from 0 to 100.`,`outputCompression`);let n=Jt(e.references,t);return{...e.aspectRatio.trim()?{aspectRatio:e.aspectRatio.trim()}:{},...e.resolution.trim()?{resolution:e.resolution.trim()}:{},...e.mimeType.trim()?{mimeType:e.mimeType.trim()}:{},...e.quality.trim()?{quality:e.quality.trim()}:{},...e.background.trim()?{background:e.background.trim()}:{},...e.n===null?{}:{n:e.n},...e.seed===null?{}:{seed:e.seed},...e.outputCompression===null?{}:{outputCompression:e.outputCompression},...e.includeText?{includeText:!0}:{},...n.length?{references:n}:{}}}function Xt(e,t,n){let{format:r}=e;if(r){let e=t.modelBindings.find(e=>a(s(t.providers,`speech`,e))&&!c.includes(r));e&&n(`speech`,`Google doesn't make ${r}; ${e.modelId} is on ${e.provider}.`,`format`)}let i=t.modelBindings.find(e=>a(s(t.providers,`speech`,e)));i&&!e.voice.trim()&&n(`speech`,`Gemini needs a voice to speak; ${i.modelId} is on ${i.provider}.`,`voice`);let{speed:o}=e;return{...e.voice.trim()?{voice:e.voice.trim()}:{},...e.style.trim()?{style:e.style.trim()}:{},...o===null?{}:{speed:o},...r?{format:r}:{}}}function Zt(e,t){j(t,`live`,`resumedAfterMs`,`Away for`,e.resumedAfterMs,0);let n=e.resumedPrompt.trim();if(n&&!e.sessionResumption&&t(`live`,`A resume prompt needs Resumption on.`,`resumedPrompt`),!n)e.resumedAfterMs!==null&&t(`live`,`Away for needs a resume prompt.`,`resumedAfterMs`);else return{prompt:n,...e.resumedAfterMs===null?{}:{afterMs:e.resumedAfterMs}}}function Qt(e,t,n){!e.ingressAudio&&!e.ingressVideo&&!e.ingressText&&t(`live`,`Turn on at least one ingress channel.`),j(t,`live`,`vadPrefixPaddingMs`,`VAD prefix padding`,e.vadPrefixPaddingMs,0),j(t,`live`,`vadSilenceDurationMs`,`VAD silence duration`,e.vadSilenceDurationMs,0),e.contextCompression&&$t(e,t,n.mode===`demo`?n.keys.liveInputTokens:void 0);let r=Zt(e,t),i={audio:e.ingressAudio,video:e.ingressVideo,text:e.ingressText},a=Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==Ce(e))),o={...e.vadActivityHandling?{activityHandling:e.vadActivityHandling}:{},...e.vadStartSensitivity?{startSensitivity:e.vadStartSensitivity}:{},...e.vadEndSensitivity?{endSensitivity:e.vadEndSensitivity}:{},...e.vadPrefixPaddingMs===null?{}:{prefixPaddingMs:e.vadPrefixPaddingMs},...e.vadSilenceDurationMs===null?{}:{silenceDurationMs:e.vadSilenceDurationMs}},s={...e.transcriptionInput?{input:!0}:{},...e.transcriptionOutput?{output:!0}:{}};return{...Object.keys(a).length?{ingress:a}:{},...e.voice.trim()?{voice:e.voice.trim()}:{},...Object.keys(o).length?{vad:o}:{},...e.sessionResumption?{sessionResumption:!0}:{},...e.greeting.trim()?{greeting:e.greeting.trim()}:{},...r?{resumed:r}:{},...e.contextCompression?{contextCompression:en(e)}:{},...Object.keys(s).length?{transcription:s}:{}}}function $t(e,t,n){j(t,`live`,`compressionTriggerTokens`,`Compression trigger`,e.compressionTriggerTokens,1),j(t,`live`,`compressionTargetTokens`,`Compression target`,e.compressionTargetTokens,1);let r=e.compressionTriggerTokens,i=e.compressionTargetTokens,a=n?.toLocaleString(`en-US`);n!==void 0&&r!==null&&r>n&&t(`live`,`Compression trigger can't exceed the ${a} input tokens a session holds on these keys.`,`compressionTriggerTokens`),i!==null&&(r!==null&&i>=r||n!==void 0&&r===null&&i>=n)&&t(`live`,r===null?`Compression target must be below the ${a} input tokens a session holds on these keys.`:`Compression target must be below the trigger.`,`compressionTargetTokens`)}function en(e){let t=e.compressionTriggerTokens,n=e.compressionTargetTokens;return{...t===null?{}:{triggerTokens:t},slidingWindow:n===null?{}:{targetTokens:n}}}function tn(e,t){let[n,...r]=t,{[n]:i,...a}=e;return!r.length||typeof i!=`object`||!i?a:{...a,[n]:tn(i,r)}}function nn(e){let t=e;for(let{path:n}of m(e))t=tn(t,n.split(`.`));return t}function rn(e,t){let n=Object.create(null);return e.questionsBuilt||(e.questions.length||t(`decision`,`Add at least one question.`,`questions`),e.questions.forEach((e,r)=>{let i=e=>t(`decision`,e,`questions`,r),a=e.id.trim(),o=e.instructions.trim();a?Object.hasOwn(n,a)&&i(`Question id '${a}' is used twice.`):i(`Each question needs an id.`),o||i(`Question '${a||r+1}' needs instructions.`);let s=e.criteria.map(e=>({label:e.label.trim(),text:e.text.trim()}));if(!a||!o)return;if(e.type===`box`){let t=e.image?.trim();n[a]={type:`box`,instructions:o,...t?{image:t}:{}};return}if(e.type===`score`){(s.length<2||s.some(e=>!e.text))&&i(`Score '${a}' needs at least two levels, each described.`),n[a]={type:`score`,instructions:o,criteria:s.map(e=>e.text)};return}let c=Object.create(null);for(let e of s)e.label?Object.hasOwn(c,e.label)?i(`Option '${e.label}' of '${a}' is used twice.`):c[e.label]=e.text||e.label:i(`Every option of '${a}' needs a label.`);e.type===`choice`?(s.length<2&&i(`Choice '${a}' needs at least two options.`),n[a]={type:`choice`,instructions:o,criteria:c}):n[a]={type:`noul`,instructions:o,...s.length?{criteria:c}:{}}})),n}var an=/^[a-z0-9_]+$/,on=[`image/png`,`image/jpeg`];function sn(e,t){let n=Object.create(null);return e.images.forEach((e,r)=>{let i=e=>t(`decision`,e,`images`,r),a=e.name.trim(),o=`<${a}>`;an.test(a)?Object.hasOwn(n,o)?i(`Image ${o} is used twice.`):!on.includes(e.mimeType)||!e.data?i(`${o} is not a PNG or JPEG.`):n[o]={mimeType:e.mimeType,data:e.data}:i(`Name an image with lowercase letters, digits, and _.`)}),e.questions.forEach((e,r)=>{let i=[...e.instructions.matchAll(/<[a-z0-9_]+>/g)].map(([e])=>e),a=e.type===`box`?e.image?.trim():void 0;a?.startsWith(`<`)&&i.push(a);for(let e of new Set(i))Object.hasOwn(n,e)||t(`decision`,`No image is named ${e}.`,`questions`,r)}),n}function $(e,t,n){let r=t.has(`observability`)?Gt(e.observability,n):void 0,i=jt(e,t,t=>b(e,t),n);return{...r?{observability:r}:{},...i?{labels:i}:{}}}function cn(e,t){let{decision:n}=e,r=n.contract.trim();return r||t(`decision`,`Contract is required.`,`contract`),r}function ln(e,t,n,r){let i=n.decision,{decision:a,identity:o}=e,c=(e,t)=>e.trim().length>t;c(a.contract,i.idChars)&&r(`decision`,`Contract is limited to ${i.idChars} characters on these keys.`,`contract`),c(o.agentId,i.idChars)&&r(`identity`,`Profile id is limited to ${i.idChars} characters on these keys.`,`agentId`),c(o.handle,i.nameChars)&&r(`identity`,`Handle is limited to ${i.nameChars} characters on these keys.`,`handle`);let l=e.modelBindings[0];if(l){let e=S(l.key);l.timeoutMs!==null&&l.timeoutMs>i.timeoutMs&&r(e,`Timeout is limited to ${i.timeoutMs} ms on these keys.`,`timeoutMs`),c(l.modelId,i.nameChars)&&r(e,`Model id is limited to ${i.nameChars} characters on these keys.`,`modelId`),c(l.apiId,i.idChars)&&r(e,`API model is limited to ${i.idChars} characters on these keys.`,`apiId`)}a.maxStateBytes!==null&&a.maxStateBytes>i.stateBytes&&r(`decision`,`These keys take at most ${i.stateBytes} bytes of state.`,`maxStateBytes`),a.questions.length>i.questions&&r(`decision`,`These keys ask at most ${i.questions} questions.`,`questions`),a.images.length>i.images&&r(`decision`,`These keys send at most ${i.images} images.`,`images`),a.images.forEach((e,t)=>{Math.floor(e.data.length*3/4)>i.imageBytes&&r(`decision`,`Each image is limited to ${i.imageBytes} bytes on these keys.`,`images`,t)}),a.questions.forEach((a,o)=>{let u=e=>r(`decision`,e,`questions`,o);c(a.id,i.nameChars)&&u(`Question ids are limited to ${i.nameChars} characters on these keys.`),a.type===`box`&&i.images===0&&u(`These keys take no images, so a Box question has nothing to read.`),c(a.instructions,i.instructionsChars)&&u(`Instructions are limited to ${i.instructionsChars} characters on these keys.`),a.criteria.length>i.criteria&&u(`A question has at most ${i.criteria} options or levels on these keys.`),a.criteria.some(e=>c(e.text,i.criterionChars))&&u(`Each option or level is limited to ${i.criterionChars} characters on these keys.`),a.criteria.some(e=>c(e.label,i.nameChars))&&u(`Option labels are limited to ${i.nameChars} characters on these keys.`);let d=t[a.id.trim()],f=l&&d&&n.questionViolation(s(e.providers,`decision`,l),d);f&&u(f)})}function un(e,t,n){let{decision:r}=e,i=new Set(y(e)),a=cn(e,t);e.modelBindings.length!==1&&t(`models`,`A decision needs exactly one model binding.`);let o=e.modelBindings[0],s=o?S(o.key):`models`;o&&(N(o,`decision`,e.providers,t),I(o,e.providers,`decision`,s,t),o.modelId.trim()||t(s,`Model id is required.`,`modelId`),j(t,s,`timeoutMs`,`Timeout`,o.timeoutMs,1));let c=o?F(o,s,t):void 0;j(t,`decision`,`maxStateBytes`,`Max state`,r.maxStateBytes,1);let l=rn(r,t),u=sn(r,t);return n.mode===`demo`&&ln(e,l,n.keys,t),{profile:{type:`decision`,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim()},models:o?{[o.modelId.trim()]:{protocol:o.protocol,provider:o.provider,apiId:o.apiId.trim(),...Object.keys(o.options).length?{options:o.options}:{},...o.keySlot||e.models.key?{keySlot:o.keySlot||e.models.key}:{},...o.fallbackKeySlot?{fallbackKeySlot:o.fallbackKeySlot}:{},...o.timeoutMs===null?{}:{timeoutMs:o.timeoutMs},...c?{limits:c}:{}}}:{},inputs:{state:`json`,...r.maxStateBytes===null?{}:{maxStateBytes:r.maxStateBytes}},decision:{contract:a},...$(e,i,t)},customTools:[],...r.questionsBuilt?{}:{questions:l},...Object.keys(u).length?{images:{...u}}:{}}}function dn(e,t,n,r){let i=new Set(y(e)),{customTools:a,tools:o}=W(e,b(e,`tools.t2Loader`),b(e,`tools.parallel`),t,n,r);a.length||t(`tools`,`Add at least one tool: a host runs only its tools.`);let s=i.has(`guardrails`)?Wt(e.guardrails,t,p):void 0;return{profile:nn({type:`host`,id:e.identity.agentId.trim(),tools:o,...s?{guardrails:s}:{},...$(e,i,t)}),customTools:a}}function fn(e,t,n,r,i,a){let o=new Set(y(e)),s=t=>b(e,t),{system:c,code:l,person:u}=z(e,n),d=$e(e,t,n,i),{outputs:f,structured:p}=o.has(`outputs`)?Ot(e.outputs,s(`outputs.structured`),n):{},{customTools:m,tools:h}=o.has(`tools`)?W(e,s(`tools.t2Loader`),s(`tools.parallel`),n,i,a):{customTools:[]},g=o.has(`turnBehaviour`)?At(e.turnBehaviour,s(`turnBehaviour.resumption`),n):void 0,_=o.has(`guardrails`)?Wt(e.guardrails,n):void 0;return{profile:nn({type:t,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim(),...l?{options:l}:{},...c?{system:c}:{}},...d,...o.has(`image`)?{image:Yt(e.image,n)}:{},...o.has(`speech`)?{speech:Xt(e.speech,e,n)}:{},...o.has(`live`)?{live:Qt(e.live,n,r)}:{},...h?{tools:h}:{},...o.has(`inputs`)?t===`live`?Et(e.inputs,u,n):{inputs:G(e.inputs,u,t,n)}:{},...f?{outputs:f}:{},...g?{turnBehaviour:g}:{},..._?{guardrails:_}:{},...$(e,o,n)}),customTools:m,...p?{structured:p}:{}}}function pn(e,t,n=We,r=Ge){let i=[],a=(e,t,n,r)=>{i.push({nodeId:e,message:t,...n===void 0?{}:{field:n},...r===void 0?{}:{index:r}})};qe(e,a),new Set([e.models.key,e.models.fallbackKey,...e.modelBindings.flatMap(t=>{let{keySlot:n,fallbackKeySlot:r}=ce(e,t);return[n,r]})].filter(Boolean)).size>32&&a(`models`,`The studio supports up to 32 key slots.`,`key`);let o=e.identity.profileType;if(!o)return a(`identity`,`Pick a profile type.`,`profileType`),{ok:!1,issues:i};if(o!==`host`)for(let n of e.modelBindings){if(!n.apiId.trim())continue;let r=l({...s(e.providers,o,n),builtInTools:n.builtInTools},t);r&&a(S(n.key),r.message,r.field)}let c=o===`decision`?un(e,a,t):o===`host`?dn(e,a,n,r):fn(e,o,a,t,n,r);if(i.length)return{ok:!1,issues:i};try{_e(Q(c.profile))}catch(e){if(!(e instanceof oe))throw e;return{ok:!1,issues:[{nodeId:`identity`,message:e.message}]}}return{ok:!0,agentId:c.profile.id,providers:e.providers,...c}}export{De as _,Pt as a,He as c,w as d,Le as f,Fe as g,Ie as h,V as i,Ve as l,Me as m,pn as n,Q as o,Pe as p,B as r,k as s,mt as t,Ue as u,Ee as v};
@@ -1,5 +0,0 @@
1
- import{t as e}from"./preload-helper-DpV6A1kQ.js";import{C as t,D as n,E as r,O as i,S as a,T as o,b as s,c,d as l,g as u,h as d,l as f,m as p,p as m,u as h,v as g,x as _}from"./schemas-D7cgkv3L.js";import{U as v,X as y,s as b}from"./tool-schema-BSpmtaaV.js";import{$a as x,$r as S,Ai as ee,Ba as te,Br as C,Ci as w,Cn as T,Cr as E,Da as D,Ea as ne,Fi as O,Fr as re,Gn as ie,Gr as ae,Hn as oe,Hr as se,Ht as ce,Ja as le,Jn as ue,Jr as de,Kn as fe,Kr as pe,Ma as me,Mi as he,Nr as ge,Nt as _e,Oa as ve,Pa as ye,Qa as be,Qn as xe,Qr as Se,Ra as Ce,Sa as we,Sn as Te,Ti as Ee,Ua as De,Un as Oe,Vn as ke,Vr as Ae,Vt as je,Wa as Me,Wn as Ne,Wr as Pe,Xa as Fe,Xr as Ie,Ya as Le,Yi as Re,Yr as ze,Zr as Be,_i as Ve,_r as He,aa as Ue,ar as We,cr as Ge,di as Ke,dr as qe,ea as Je,ei as Ye,fi as Xe,gi as Ze,ji as Qe,jr as $e,ka as et,ki as tt,kr as nt,lr as rt,mi as it,ni as at,pt as ot,qr as st,ri as ct,rr as lt,si as ut,sr as dt,tn as ft,to as k,ur as pt,ut as mt,vi as ht,vn as gt,wi as _t,wn as A,xa as vt,xn as yt,yi as bt,yn as xt,yr as St,zi as Ct,zn as wt}from"./shaped-data-Dp2yZFfd.js";import{c as j}from"./host-patterns-F-KZIzkF.js";import{C as Tt,S as Et,v as Dt,x as Ot}from"./browser-connection-EIPuJ9Z-.js";import{D as kt,E as At,F as jt,N as Mt,P as Nt,S as Pt,_ as Ft,j as It,v as Lt,w as Rt,y as zt}from"./schema-B3Tv1Fpx.js";import{a as Bt}from"./live-ingress-OuSlQ6q7.js";import{n as Vt,t as Ht}from"./trace-schema--4IGmLeE.js";import{n as Ut}from"./stub-BlSgwV6N.js";function Wt(e){return{type:`guardrail`,guardrail:e}}function Gt(e,t,n,r=`redact`,i){if(n.length!==0)return Wt({stage:e,trust:t,action:r,hits:n,...i?{provenance:i}:{}})}function Kt(e,t){return e.type===`guardrail`?{...e,guardrail:we(e.guardrail,t)}:e}var qt=65536;function M(e){let t=e.classStarts.length,n=new Uint16Array(qt);for(let r=0;r<t;r++)n.fill(r,e.classStarts[r],e.classStarts[r+1]??qt);let r=e.charsets.map(e=>{let n=new Uint8Array(t);for(let t of e)n[t]=1;return n}),i=e.nodes.length,a=new Int32Array(i),o=new Uint8Array(i),s=[];return e.nodes.forEach((e,t)=>{a[t]=e[0],o[t]=e[1],s.push(Int32Array.from(e.slice(2)))}),{classOf:n,has:r,pattern:a,final:o,edges:s,initials:e.initials,leads:e.leads,size:i}}var Jt,N,Yt;async function Xt(){if(Jt)return;let{FORWARD_AUTOMATON:t,REVERSED_AUTOMATON:n}=await e(async()=>{let{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}=await import(`./egress-automata-CFjB39wS.js`);return{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}},[]);Jt={forward:t,reversed:n}}function Zt(){if(!Jt)throw Error(`A stream was opened before loadEgressAutomata() finished.`);return Jt}var P;function Qt(e){let t=String.fromCharCode(e).toUpperCase();if(t.length!==1)return e;let n=t.charCodeAt(0);return e>=128&&n<128?e:n}function $t(e){if(!P){P=new Map;for(let e=0;e<qt;e++){let t=Qt(e),n=P.get(t);n?n.push(e):P.set(t,[e])}}return P.get(Qt(e))??[e]}function en(e){let t=[0];for(let n of e)t.at(-1)!==n&&t.push(n),n+1<qt&&t.push(n+1);return t}var F=new Map;function tn(e){let t=F.get(e);if(t)return t;let n=Array.from({length:e.length},(t,n)=>$t(e.charCodeAt(n))),r=en([...new Set(n.flat())].sort((e,t)=>e-t)),i=e=>r.indexOf(e),a=M({classStarts:r,charsets:n.map(e=>e.map(i)),initials:[0],leads:[-1],nodes:[...n.map((e,t)=>[0,0,t+1,t]),[0,1]]});return F.set(e,a),a}function nn(e){let t=JSON.stringify(e),n=F.get(t);if(n)return n;let r=[...new Set(e.flatMap(e=>Array.from(e,e=>e.charCodeAt(0))))];r.sort((e,t)=>e-t);let i=en(r),a=r.map(e=>[i.indexOf(e)]),o=[],s=M({classStarts:i,charsets:a,initials:e.map((e,t)=>{let n=o.length;for(let n=0;n<e.length;n++)o.push([t,0,o.length+1,r.indexOf(e.charCodeAt(n))]);return o.push([t,1]),n}),leads:e.map(()=>-1),nodes:o});return F.set(t,s),s}function rn(e,t){let n=e.has[0]?.length??0,r=Array.from({length:n},()=>[]);for(let i of t){let t=e.edges[e.initials[i]];for(let i=0;i<t.length;i+=2){let a=e.has[t[i+1]];for(let e=0;e<n;e++)a[e]&&r[e]?.push(t[i])}}return r.map(e=>Int32Array.from(e))}function an(e,t){e.text+=t,e.fresh+=t}function on(e){return e.text.length-e.fresh.length}function I(e,t){let n=on(e);return t>=n?e.fresh.charCodeAt(t-n):e.text.charCodeAt(t)}function sn(e,t,n=e.text.length){let r=on(e);return t>=r?e.fresh.slice(t-r,n-r):e.text.slice(t,n)}function cn(e){let t={text:``,fresh:``,rawAt:e=>e,update(){t.text=e.text,t.fresh=e.fresh}};return t}function ln(e,t){let n={text:``,fresh:``,rawAt:e.rawAt,update(){n.fresh=``,an(n,t(sn(e,n.text.length)))}};return n}var un=/\w/,dn=Math.max(...pe.map(e=>e.length));function fn(e){return e.length<=dn+1&&/^[A-Za-z]*$/.test(e)}function pn(e){let t=0,n,r=!1,i=[],a=(e,t,n)=>{an(o,e);for(let r=0;r<e.length;r++)i.push(t+Math.min(r,n-1))},o={text:``,fresh:``,rawAt:r=>e.rawAt(r<i.length?i[r]:t-(n?.length??0)),update(){o.fresh=``;for(let i=e.text.length;t<i;t++){let i=String.fromCharCode(I(e,t)),o=un.test(i);o&&!r&&(n=``),r=o,o?n===void 0?a(i,t,1):n+=i:(n!==void 0&&a(Ie(n),t-n.length,n.length),n=void 0,a(i,t,1))}n!==void 0&&!fn(n)&&(a(n,t-n.length,n.length),n=void 0)}};return o}function mn(e){let t={text:``,fresh:``,from:[],rawAt:n=>n<t.from.length?t.from[n]:e(),update(){}};return t}function L(e,t,n){an(e,t);for(let r=0;r<t.length;r++)e.from.push(n)}var hn=55296,gn=56319,_n=/[A-Za-z]/,vn=56320,yn=57343;function bn(e){let t=0,n=``,r=[],i=``,a=[],o=!1,s=-1,c=mn(()=>Math.min(t,r[0]??t,a[0]??t,s<0?t:s));function l(e,t){s>=0&&(_n.test(e)||L(c,`\\`,s),s=-1),e===`\\`?s=t:L(c,e,t)}function u(e,t){if(Be(e)&&(o||i)){i+=e;for(let n=0;n<e.length;n++)a.push(t)}else{if(i){if(!_n.test(e))for(let e=0;e<i.length;e++)l(i[e],a[e]);i=``,a=[]}for(let n=0;n<e.length;n++)l(e[n],t);o=_n.test(e)&&e.length===1}}function d(){let e=0;for(;e<n.length;){let t=n.charCodeAt(e),i=t>=hn&&t<=gn;if(i&&e+1>=n.length)break;let a=n.charCodeAt(e+1),o=i&&a>=vn&&a<=yn?2:1;u(n.slice(e,e+o),r[e]),e+=o}n=n.slice(e),r=r.slice(e)}return c.update=()=>{c.fresh=``;let i=e.text.length;for(;t<i;){let a=I(e,t),o=a>=hn&&a<=gn;if(o&&t+1>=i)break;let s=I(e,t+1),c=o&&s>=vn&&s<=yn?2:1,l=Se(sn(e,t,t+c));n+=l;for(let e=0;e<l.length;e++)r.push(t);t+=c}d()},c}var xn=/[0-9A-Fa-f]/;function Sn(e){let t=0,n=-1,r=mn(()=>n<0?t:n);r.update=()=>{r.fresh=``;let a=e.text.length;for(;t<a;){let a=String.fromCharCode(I(e,t));if(n<0){a===`%`?n=t:(L(r,a,t),t++);continue}let o=(t-n)%3;if(o===0?a===`%`:xn.test(a))t++;else{i(t-o);for(let n=t-o;n<t;n++)L(r,String.fromCharCode(I(e,n)),n)}}};function i(t){t>n&&L(r,st(sn(e,n,t)),n),n=-1}return r}var Cn=new Set([`injection`,`base64`,`hex`,`spaced`,`pipe`]),wn=new Map(ae.map(({pattern:e,hit:t})=>[e,t])),Tn=new Map(Ge.flatMap(({pattern:e,hit:t})=>t?[[e,t]]:[]));function R(e){return{rule:ne(e),severity:`high`,detector:e}}var En=R(`injection`),Dn=R(`marker_leak`),On=R(`tool_leak`);function kn({kind:e,group:t}){if(Cn.has(e))return En;switch(e){case`sensitive`:case`card`:return t===void 0?void 0:R(t);case`boundary`:return Dn;case`image`:return R(`ungiven_images`);default:return R(`ungiven_links`)}}function An(e,t,n){if(e===`card`)return{hit:rt};if(e===`image`||e===`link`){let r=(e===`image`?pt:qe).indexOf(t),i=n[e][r];return`find`in i?{find:i.find}:{hit:i.test}}let r=wn.get(t)??Tn.get(t);return r?{hit:r}:{}}function jn(e,{given:t,allow:n,skipImages:r}){let i=e=>({...e,...t?{given:t}:{}}),a={image:He(i(n?.ungiven_images)),link:St(i(n?.ungiven_links),r??e.includes(`ungiven_images`))},o=[];return We.forEach((t,n)=>{let r=kn(t);r?.detector&&e.includes(r.detector)&&o.push({...r,id:n,regex:Ye(t.pattern),...An(t.kind,t.pattern,a)})}),o}function Mn(){let e=[];return We.forEach(({kind:t,pattern:n},r)=>{if(t!==`injection`)return;let i=wn.get(n);e.push({...En,id:r,regex:Ye(n),...i?{hit:i}:{}})}),e}function Nn(){return S.map((e,t)=>({...En,id:t,regex:new RegExp(e.source,e.flags)}))}function Pn(e,t,n){let r=rn(t,n.map(e=>e.id)),i=new Int32Array(t.initials.length).fill(-1);n.forEach((e,t)=>{i[e.id]=t});let a=new Int32Array(t.size),o=new Int32Array(t.size),s=new Int32Array(t.size),c=new Int32Array(t.size),l=0,u=new Int32Array(t.size),d=new Int32Array(t.size),f=0,p=0,m=new Uint8Array(n.length),h=new Uint8Array(n.length),g=new Int32Array(n.length),_=new Int32Array(n.length),v=new Uint8Array(n.length),y=Uint8Array.from(n,e=>+!!e.find),b=new Int32Array(n.length).fill(-1),x=new Int32Array(n.length).fill(-1),S=Int32Array.from(n,e=>t.leads[e.id]??-1),ee=[...new Set(S)].filter(e=>e>=0),te=n.flatMap((e,t)=>S[t]<0?[]:[t]),C=new Int32Array(t.has.length).fill(-1);function w(){let{text:n,fresh:h}=e,g=on(e),{classOf:_,has:v,edges:te,final:w,pattern:T}=t;for(;p<n.length;p++){let e=_[p>=g?h.charCodeAt(p-g):n.charCodeAt(p)];f++;let t=0,E=(e,n)=>{if(d[e]===f){let t=u[e];n<c[t]&&(c[t]=n)}else d[e]=f,u[e]=t,s[t]=e,c[t]=n,t++,w[e]&&(m[i[T[e]]]=1)};for(let t=0;t<l;t++){let n=te[a[t]],r=o[t];for(let t=0;t<n.length;t+=2)v[n[t+1]][e]&&E(n[t],r)}let D=r[e];for(let e=0;e<D.length;e++){let t=D[e],n=i[T[t]],r=S[n],a=r<0?-1:C[r],o=a<0?p:a;E(t,o),y[n]&&(x[n]=p,b[n]<0&&(b[n]=o))}for(let t of ee)v[t][e]?C[t]<0&&(C[t]=p):C[t]=-1;[a,s]=[s,a],[o,c]=[c,o],l=t}}function T(){let n=e.text.length;_.fill(n),v.fill(0);let r=n;for(let e=0;e<l;e++){let n=a[e],s=i[t.pattern[n]],c=o[e];c<_[s]&&(_[s]=c),t.final[n]&&(v[s]=1),c<r&&(r=c)}for(let e of te){let t=C[S[e]];t<0||(t<_[e]&&(_[e]=t),t<r&&(r=t))}return r}function E(t,r){let i=b[t],a=g[t];if(i<0||i>=r){g[t]=r;return}let{find:o,rule:s,severity:c,detector:l}=n[t],u=o?.(e.text,a,r);if(u===void 0)g[t]=r,b[t]=x[t]>=r?r:-1;else return g[t]=Math.max(a,u)+1,{rule:s,severity:c,start:e.rawAt(u),detector:l}}let D={text:``,lower:``},ne=()=>(D.text!==e.text&&(D={text:e.text,lower:e.text.toLowerCase()}),D.lower);function O(t,r){if(!m[t]&&!h[t]){g[t]=r;return}m[t]=0;let i=e.text,{regex:a,hit:o,rule:s,severity:c,detector:l}=n[t];for(a.lastIndex=g[t];;){let n=a.exec(i);if(!n||n.index>=r){g[t]=r,h[t]=n||v[t]?1:0;return}let[u]=n;if(u&&(!o||o(u,i,n.index,ne)))return g[t]=a.lastIndex,h[t]=1,{rule:s,severity:c,start:e.rawAt(n.index),detector:l};u||a.lastIndex++,g[t]=a.lastIndex}}function re(){for(let e=0;e<n.length;e++){let t=_[e];if(t<=g[e])continue;let r=n[e].find?E(e,t):O(e,t);if(r)return r}}return{run(t){w();let n=T();for(let e=re();e;e=re())t.push(e);return e.rawAt(n)}}}var Fn=new WeakMap;function In(e){let t=Fn.get(e);return t||(t=M(e),Fn.set(e,t)),t}function Ln(e={}){let t={text:``,fresh:``},n=cn(t),r=[n],i=(e,t,n)=>(r.includes(e)||r.push(e),Pn(e,t,n)),a=[],o=e.detect??[],s=jn(o,e);if(s.length>0&&(N??=M(Zt().forward),a.push(i(n,N,s))),o.includes(`injection`)){N??=M(Zt().forward),Yt??=M(Zt().reversed);let e=bn(t),r=Mn();a.push(i(n,Yt,Nn()),i(pn(n),N,r),i(e,N,r),i(pn(e),N,r),i(ln(n,ze),N,r),i(ln(n,e=>de(e)??e),N,r),i(Sn(t),N,r))}if(o.includes(`marker_leak`)&&e.note){let t=dt(e.note);a.push(i(n,tn(e.note),[{...Dn,id:0,regex:t}]))}if(o.includes(`tool_leak`)&&e.tools){let t=xe(e.tools),r=t.map(({regex:e},t)=>({...On,id:t,regex:e}));t.length>0&&a.push(i(n,nn(t.map(({literal:e})=>e)),r))}for(let{detector:t,compiled:r,matchers:o}of e.own??[]){let e=o.map(({regex:e},n)=>({...R(t),id:n,regex:new RegExp(e.source,e.flags)}));a.push(i(n,In(r.automaton),e))}let c=0;return{push(e){t.text+=e,t.fresh=e;for(let e of r)e.update();let n=[],i=t.text.length;for(let e of a)i=Math.min(i,e.run(n));return c=i,n},holdFrom:()=>c}}function Rn(e,t,n={},r=[]){let i=Ne(e,t).filter(e=>!(fe(e)||r.includes(e))),a=ie(e,t);if(i.length===0&&a.length===0)return;let o=[...i,...a.map(({id:e})=>e)],s=t.sources??{},c=[...i.map(e=>({detector:e,...s[e]})),...a.map(({id:e,matchers:t,compiled:n})=>({detector:e,matchers:t,compiled:n}))],l=c.some(({matchers:e,compiled:t})=>e?.length&&!t),u=Ln({detect:i.filter(e=>s[e]?.theorem!==!1),own:c.flatMap(({detector:e,compiled:t,matchers:n=[]})=>t?[{detector:e,compiled:t,matchers:n}]:[]),skipImages:t.ungiven_images[e]!==`ignore`,...n.allow?{allow:n.allow}:{},...n.givenUrls?{given:n.givenUrls}:{},...n.note?{note:n.note}:{},...n.ownTools?{tools:n.ownTools}:{}}),d=a.some(({find:e})=>e),f=e===`live_reply`?96:256,p=``,m=[];return{push(e){p+=e;for(let{start:t,detector:n}of u.push(e))n&&m.push({start:t,detector:n})},holdFrom(){if(l)return 0;let e=u.holdFrom();return d?Math.min(e,Math.max(0,p.length-f)):e},take(r,i,a=!1){let s=m.filter(({start:e})=>e<i);if(s.length===0&&!a&&!d)return{action:`allow`,text:p.slice(r,i),hits:[],taken:i-r};let c={from:r,to:i,settled:s.map(({detector:e})=>e)},l=Oe(p,c,e,t,{detectors:o,scope:n});return m=m.filter(({start:e})=>e>=r+l.taken),l}}}function zn(e){let{context:t}=e,n=e.detect,r=n?Rn(n.boundary,n.matrix,n.scope):void 0,i=e=>n?n.matrix[e][n.boundary]:`block`,a=i(`canary_leak`),o=i(`prompt_leak`),s=t.canaryGiven||a===`ignore`?void 0:t.canary,c=o===`ignore`?void 0:t.privateSystem,l=s!==void 0||c!==void 0,u=l?e.carry??``:``,d=[],f=new Set,p=``,m=0,h=``,g=u.slice(-E),_=u,v=0,y=u,b=0,x=0,S=s?$e(s):void 0;S?.push(u);function ee(e){let n=[];if(S?.push(e)&&n.push([a,vt]),c){let r=_.length;_+=e;let i=Pe(_,r);_=_.slice(i),v+=i;let[a]=lt(_,c,t.canary);a&&n.push([o,a])}for(let[e,t]of n)e!==`flag`||f.has(t.rule)||(f.add(t.rule),d.push(t));return n.filter(([e])=>e!==`flag`).map(([,e])=>e)}function te(e){let t=l?ee(e??``):[];return e&&r?.push(e),t.length===0?null:{hits:t,...n?{boundary:n.boundary}:{}}}function C(){let e=s&&a!==`flag`?T(s):h.length,n=c&&o!==`flag`?D(c,t.canary):h.length;return m+Math.min(e,n)}function w(e){if(d.length===0)return e;let t=[...d,...e.found?.hits??[]];return d=[],{...e,found:{action:e.found?.action??`flag`,hits:t}}}function T(e){let t=u.length+m,n=Math.max(t,x),r=Math.max(b,n-E),i=r+nt(y.slice(r-b),e);i<n&&n>t&&(y=g+h,b=t-g.length,i=b+nt(y,e)),x=Math.min(i,u.length+p.length-E);let a=Math.max(b,Math.max(t,x)-E);return y=y.slice(a-b),b=a,Math.max(0,i-t)}function D(e,t){let n=m===0?u:``,r=u.length+m-n.length,[i,a]=v>=r?[_,v]:[n+h,r];return Math.max(0,a+se(i,e,t)-u.length-m)}function ne(e){let t=te(e);if(t)return{blocked:!0,...t};let i=e===void 0,a=i?p.length:Math.min(C(),r?.holdFrom()??p.length),o=Math.max(0,a-m);if(!(n&&r))return w({blocked:!1,emit:O(o)});let s=r.take(m,m+o,i);return s.action===`block`||s.action===`redact`&&!n.rewrite?{blocked:!0,hits:s.hits,boundary:n.boundary}:(O(s.taken),w({blocked:!1,emit:s.text??``,...s.action===`allow`?{}:{found:{action:s.action,hits:s.hits}}}))}function O(e){let t=h.slice(0,e);return h=h.slice(e),m+=t.length,l&&(g=(g+t).slice(-E)),t}return{process(e){return e?(p+=e,h+=e,l&&(y+=e),ne(e)):{blocked:!1,emit:``}},flush:()=>ne(),accumulated:()=>p,unreleased:()=>h,drainUnreleased:()=>O(h.length),carryOut:()=>l?re(u+p,s,c):``}}function z(e,t,n){return oe(t,e.detect,n)}async function Bn(e,t,n,r){return z(e,[n],t)?(await Xt(),Vn(e,t,n,r)):null}function Vn(e,t,n,r){return z(e,[n],t)?zn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:n===`reply`,scope:ue(e,t)},...r?{carry:r}:{}}):null}async function Hn(e,t,n,r){return z(e,[n],r??t)?(await Xt(),zn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:!1,scope:r??ue(e,t)}})):null}var Un=class{open;gate;constructor(e){this.open=e}async read(e){if(this.gate===void 0&&(this.gate=await this.open()),this.gate===`stopped`)return``;if(!this.gate)return e;let t=this.gate.process(e);return t.blocked?(this.gate=`stopped`,``):t.emit}end(){if(!this.gate||this.gate===`stopped`)return``;let e=this.gate.flush();return e.blocked?``:e.emit}},Wn=[`user`,`options`,`repair`,`attachment`,`voice`,`history`,`system`];function Gn(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t.read(n)]))}var Kn={client:`untrusted`,server:`assembled`};function qn(e){return typeof e==`string`?e:JSON.stringify(e)}function Jn(e,t){let n=[],r=!1;if(!e)return{context:e,events:n,blocked:r};let i={};for(let a of ht){let o=e[a];if(o===void 0)continue;let s=t();i[a]=s.read(qn(o));let c=s.found(),l=ke(`context`,c);l&&n.push({...l,trust:Kn[a]}),r||=c.action===`block`}return{context:i,events:n,blocked:r}}var Yn=/^[A-Za-z0-9._-]+$/,Xn=/^[A-Za-z0-9._:-]{1,32}$/;function Zn(e){if(e===void 0||Xn.test(e))return e;throw new j(`request`,`input.messageId must be 1 to 32 letters, digits, ".", "_", ":" or "-"`)}function Qn(e){let t=e?.trim();return t&&Yn.test(t)?t:void 0}function $n(e,t){if(!e)return e;let n=e.guidance?t.read(e.guidance):void 0;return{previousOutput:t.read(e.previousOutput),rejection:t.read(e.rejection),...n?{guidance:n}:{}}}function er(e,t){return e.map(e=>{let n=e.content===void 0?void 0:t.read(e.content),r=e.parts?.map(e=>e.type===`text`?{...e,text:t.read(e.text)}:e);return{role:e.role,...n===void 0?{}:{content:n},...r?{parts:r}:{},...e.tool_calls?{tool_calls:e.tool_calls}:{},...e.tool_call_id?{tool_call_id:e.tool_call_id}:{},...e.name?{name:e.name}:{},...e.metadata?{metadata:e.metadata}:{},...e.reasoning?{reasoning:e.reasoning}:{}}})}function tr(e,t){let n=t?`: ${t}`:``;return new j(`input`,`guardrails.detect blocked the request at ${e}${n}`,{copy:{key:`detect.blocked`}})}function nr(e,t){let{detect:n}=A(t.guardrails),r=Ce(Wn,e=>wt(e,n)),i=e.input??{},a=Zn(i.messageId),o=i.text===void 0?void 0:r.user.read(i.text),s=e.system===void 0?void 0:Nt(e.system,`TurnRequest.system`,e=>r.system.read(e)),c=Gn(i.options,r.options),l=Jn(i.context,()=>wt(`context`,n)),u=$n(i.repair,r.repair),d=i.history?er(i.history,r.history):void 0,{attachments:f,voice:p}=i.attachments?.length||i.voice?.length?Tt(t,i.attachments,i.voice,r):i,m=[],h;for(let e of Wn){let t=r[e].found(),n=ke(e,t);n&&m.push(Wt(n)),t.action===`block`&&(h??=tr(e,t.errorInternal))}return m.push(...l.events.map(Wt)),l.blocked&&(h??=tr(`context`)),{request:{...e,system:s,projectId:Qn(e.projectId),input:{...i,text:o,...a===void 0?{}:{messageId:a},options:c,...l.context?{context:l.context}:{},repair:u,history:d,attachments:f,voice:p}},events:m,...h?{refusal:h}:{}}}function rr(e,t){let{request:n,refusal:r}=nr(e,t);if(r)throw r;return n}function ir(e,t){return[...new Set([...t.filter(t=>xt(e,t)),...e.filter(e=>xt(t,e))])]}function ar(e,t){let n=e.attachments?t?ir(e.attachments.accept,t.media.flatMap(e=>e.accept)):[...e.attachments.accept]:[],r=(t?.media??[]).flatMap(e=>e.maxPerInput===void 0?[]:[{accept:[...e.accept],max:e.maxPerInput}]);return{text:e.text!==!1,...n.length>0?{attachments:{accept:n}}:{},...e.maxFiles===void 0?{}:{maxFiles:e.maxFiles},...e.maxBytes===void 0?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===void 0?{}:{maxTurnBytes:e.maxTurnBytes},...e.limitsByMime===void 0?{}:{limitsByMime:{...e.limitsByMime}},...t?.maxInputs===void 0?{}:{maxInputs:t.maxInputs},...r.length>0?{perInput:r}:{}}}function or(e){let t=T(e[0]??``);return t===`application/pdf`?`PDF`:t.split(`/`)[0]??t}function sr(e,t){let n=Et(e),r=Dt({attachments:e.attachments?.accept,...n?{limits:{...n,maxFiles:2**53-1}}:{}},t.flat(),[]);if(n)for(let i of t){i.length>n.maxFiles&&r.push({code:`too_many_files`,params:{maxFiles:n.maxFiles}});for(let t of e.perInput??[])i.filter(e=>xt(t.accept,e.mimeType)).length>t.max&&r.push({code:`too_many_of_kind`,params:{maxFiles:t.max,kind:or(t.accept)}})}let i=new Set;return r.filter(e=>{let t=JSON.stringify(e);return!i.has(t)&&(i.add(t),!0)})}var cr=`final_answer`;function lr(e){return e.structured!==null&&e.tools.wire.length>0}function ur(e,t,n){let{structured:r}=t;if(!r||!lr(t))return e;let i={type:`function`,name:cr,description:k(`structured.answer_tool`,{},n),parameters:r.jsonSchema};return{...e,structured:null,wireTools:[...e.wireTools??[],i]}}function dr(e,t){return e.get(t)||{name:t,missing:!0}}function fr(e){let t=new Set;if(e.type===`host`||e.type===`decision`||e.type===`embedding`)return[];for(let n of Object.values(e.models))for(let e of n.builtInTools??[])t.add(e);return[...t]}function pr(e,t){return[...Ft(t),...fr(t)].map(t=>dr(e,t))}function B(e,t){if(Array.isArray(e)){for(let n of e)B(n,t);return}if(typeof e!=`object`||!e)return;let{properties:n,...r}=e;if(typeof n==`object`&&n)for(let[e,r]of Object.entries(n))t.add(e),B(r,t);for(let e of Object.values(r))B(e,t)}function mr(e,t){let n=pr(e,t);if(n.length===0)return;let r=new Set;for(let e of n)`inputSchema`in e&&B(mt(e.inputSchema),r);return{names:n.map(({name:e})=>e),params:[...r]}}function hr(e){return!e||e.length===0?[]:e.slice(-4)}function gr(e,t){if(e.length===0)return``;let n=e.map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`);return`${k(`repair.history_heading`,{count:e.length},t)}\n${n.join(`
2
- `)}\n\n`}function _r(e){let{profile:t,repair:n,history:r}=e,i=n.guidance||k(`repair.default_guidance`,{},t.labels),a=gr(hr(r),t.labels),o=`${k(`repair.prompt_header`,{},t.labels)}\n\n`;return o+=`${k(`repair.prompt_intro`,{},t.labels)}\n\n`,o+=`${k(`repair.section_previous_output`,{},t.labels)}\n\`\`\`\n${n.previousOutput.trim()}\n\`\`\`\n\n`,o+=`${k(`repair.section_validator_rejection`,{},t.labels)}\n${n.rejection.trim()}\n\n`,i.trim()&&(o+=`${k(`repair.section_repair_guidance`,{},t.labels)}\n${i.trim()}\n\n`),a&&(o+=a),o+=`${k(`repair.section_instructions`,{},t.labels)}\n`,o+=k(`repair.prompt_instructions`,{},t.labels),o}function vr(e,t){let n=[];return t&&n.push(`structured`),e.type===`image`&&n.push(`image`),e.type===`speech`&&n.push(`speech`),n}function yr(e,t){let n=vr(e,t);if(!(n.length<=1))throw new j(`config`,`Profile ${e.id} declares multiple output wire formats (${n.join(`, `)}). Only one of a structured JSON schema (outputs.structured), image, or speech may be active.`)}function br(e,t){if(e.type!==`speech`){if(t.speech)throw new j(`request`,`Profile ${e.id} (${e.type}) takes no speech settings — only a speech profile speaks`)}else if(t.system)throw new j(`config`,`Profile ${e.id} (speech) takes no system prompt — the input text is the transcript`)}function xr(e,t){if(e.type===`transcription`){if(t.system)throw new j(`config`,`Profile ${e.id} (transcription) takes no system prompt — the input is the clip`);if(!t.input?.voice?.length)throw new j(`request`,`Profile ${e.id} (transcription) requires a voice clip`)}}function Sr(e,t){return e.type===`speech`?{...e.speech,...Cr(t.speech)}:void 0}function Cr(e){return Object.fromEntries(Object.entries(e??{}).filter(([,e])=>e!==void 0))}function wr(e){if(e.type!==`image`)return null;let t=e.image;return{type:`image`,mimeType:t.mimeType,aspectRatio:t.aspectRatio,resolution:t.resolution,quality:t.quality,background:t.background,n:t.n,seed:t.seed,outputCompression:t.outputCompression,includeText:t.includeText===!0}}function Tr(e){let t=gt(e);if(!t)throw new j(`input`,`MIME '${e}' is not a supported media input type`);return t}function Er(e){return e.map(e=>{let t=Tr(e.mimeType),n=T(e.mimeType),r=n===`image/jpg`?`image/jpeg`:n;return Ot(e)?{type:t,mimeType:r,uri:e.uri}:{type:t,mimeType:r,data:e.data}})}function Dr(e,t){let{text:n,repair:r,history:i}=t.input??{};if(e.type===`speech`&&!n?.trim())throw new j(`request`,`Profile ${e.id} (speech) requires text input`);if(yt(e)?.text===!1&&n)throw new j(`request`,`Profile ${e.id} does not accept text input`);let a=r?_r({profile:e,repair:r,history:i}):kr(e,t)??n;if(e.type===`speech`)return a?{type:`text`,text:a}:null;let o=[...Or(t),...a?[Ae(a,t.input?.messageId)]:[]];return o.length>0?{type:`text`,text:o.join(`
3
-
4
- `)}:null}function Or(e){let t=e.input?.context??{};return[...ht].reverse().filter(e=>t[e]!==void 0).map(e=>C(e,qn(t[e])))}function kr(e,t){if(t.continueFrom&&_e.includes(e.type)){if(t.input?.text)throw new j(`request`,`Profile ${e.id}: a continueFrom turn takes no input.text — its user message is the continue instruction`);return k(`continue.instruction`,{},e.labels)}}function Ar(e){return e.type===`image`&&e.image.references?Er(e.image.references):[]}function jr(e,t){let n=t.input?.attachments??[],r=t.input?.voice??[];return[...Ar(e),...Er(n),...Er(r)]}function Mr(e,t){let n=[],r=Dr(e,t);return r&&n.push(r),n.push(...jr(e,t)),n}function Nr(e,t){let n=t.input?.context;if(!n)return;let r=yt(e)?.context;for(let[t,i]of Object.entries(n))if(i!==void 0){if(!ht.includes(t)||!r?.from.some(e=>e===t))throw new j(`request`,`Profile ${e.id} takes no context from '${t}'`);if(qn(i).length>r.maxChars)throw new j(`request`,`Profile ${e.id}: context from '${t}' is over inputs.context.maxChars (${String(r.maxChars)})`)}}function Pr(e,t){if(e.type===`speech`||e.type===`transcription`)return[];let n=e.identity.system;if(!n)return[];let r=It(e,t);return Rt(n,r,t=>kt(e,t,r))}function Fr(e,t){let n=Pr(e,t);return{pieces:Mt([...n.map(({pieces:e})=>e),t.system===void 0?[]:jt(t.system)]),lines:n.map(({line:e})=>e)}}function Ir(e){return e.type!==`host`&&e.type!==`decision`&&e.type!==`embedding`}function Lr(e,t){if(Ir(e))return e;throw e.type===`host`?new j(`request`,`Profile ${e.id}: type 'host' never runs a model — ${t} is not supported; execute tools with invokeTool`):e.type===`embedding`?new j(`request`,`Profile ${e.id}: type 'embedding' runs through runEmbedding — ${t} is not supported`):new j(`request`,`Profile ${e.id}: type 'decision' runs through runDecision — ${t} is not supported`)}function Rr(e,t){if(t){if(!e.allowModelSelect)throw new j(`request`,`Profile ${e.id} does not allow model selection`);if(!e.models[t])throw new j(`request`,`Unknown model '${t}' for ${e.id}`);return t}return e.defaultModel}function zr(e,t,n,r){let i=t.efforts;if(!i||Object.keys(i).length===0){if(r)throw new j(`request`,`Profile ${e.id} model '${n}' has no selectable efforts`);return}let a=Object.keys(i);if(r){if(!t.allowEffortSelect)throw new j(`request`,`Profile ${e.id} model '${n}' does not allow effort selection`);let a=i[r];if(!a)throw new j(`request`,`Unknown effort '${r}' for ${e.id} model '${n}'`);return a}return i[t.defaultEffort??a[0]]}function Br(e){if(e.summaries===!0)return`auto`;if(e.summaries===!1)return`none`}function Vr(e,t){if(e.type===`live`)return null;let n=e.outputs?.structured;if(!n)return null;if(typeof n==`string`)return n;let r=t[n.by];if(r){let e=n.map[r];if(e)return e}return n.fallback}function Hr(e){return e.type===`live`||e.outputs?.streaming?.mode!==`buffered`}function Ur(e,t){return e.type===`live`?`live`:`turn`}function Wr(e,t){if(!t.continueFrom)return;if(e.type===`live`)throw new j(`request`,`Profile ${e.id}: type 'live' uses live.sessionResumption, not turnBehaviour.resumption/continueFrom`);let n=ce(e)?.maxContinues;if(n===void 0)return;let r=t.continuation;if(r===void 0)throw new j(`request`,`Profile ${e.id}: continueFrom requires TurnRequest.continuation when turnBehaviour.resumption.maxContinues is set`);if(r<1)throw new j(`request`,`Profile ${e.id}: continuation must be >= 1`);if(r>n)throw new j(`request`,`Profile ${e.id}: continuation ${r} exceeds turnBehaviour.resumption.maxContinues (${n})`)}function Gr(e,t){return z(A(t),[`live_reply`])?{...e,transcription:{...e?.transcription,output:!0}}:e}function Kr(e){let{detect:t}=A(e.guardrails);return e.type!==`speech`&&e.type!==`transcription`&&Ue(t,`canary_leak`)?ge():``}function qr(e,t,n,r){if(!r)return;let i={};for(let[a,o]of Object.entries(r)){if(!n.builtInTools?.includes(a))throw new j(`request`,`Profile ${e.id}: builtInArgs names '${a}', which model '${t}' does not list in builtInTools`);i[a]=o}return i}function Jr(e,t,n){let r=Lr(e.profiles.get(t.profile),`resolveTurn`);At(r,t),Nr(r,t);let i=rr(t,r),a=i.input??{};Wr(r,i);let o=n??Rr(r,i.model),s=Te(r,o),c=Pt(e.tools,r,i,o),l=c.builtins,u=Vr(r,It(r,i));if(yr(r,u),u&&c.wire.some(e=>e.name===`final_answer`))throw new j(`config`,`Profile ${r.id}: a structured turn answers through '${cr}', so no tool of its own may take that name`);br(r,i),xr(r,i);let d=qr(r,o,s,i.builtInArgs),f=Ur(r,s),p=e.providers.get(s.provider),m=p&&ft(p,s,r.type),h=Fr(r,i);return{profile:r,generation:{model:o,apiId:s.apiId,transport:f,...m?{operationName:m}:{},stream:Hr(r),thinking:zr(r,s,o,i.effort),summaries:Br(s),maxOutputTokens:s.maxOutputTokens,temperature:s.temperature,builtins:l,builtInArgs:d,sessionId:i.sessionId,tools:c,sessionPermissions:i.sessionPermissions,execution:i.execution,pageExecution:i.pageExecution,history:a.history,maxSteps:r.maxSteps??20,structured:u?{id:u,jsonSchema:ot(e.schemas.get(u).jsonSchema)}:null,image:wr(r),speech:Sr(r,i),live:r.type===`live`?Gr(r.live,r.guardrails):void 0,input:Mr(r,i),canary:Kr(r),resolvedSystem:h.pieces,systemLines:h.lines,host:i.host}}}function Yr(e){return e.type===`image`?e.image:null}function Xr(e,t){let n=Lr(t,`projectProfile`),{identity:r}=n,i=yt(n)??null,a=n.type===`live`?null:n.outputs??null;return{id:n.id,type:n.type,handle:r.handle,models:n.models,defaultModel:n.defaultModel,allowModelSelect:n.allowModelSelect,maxSteps:n.maxSteps,tools:pr(e,n),inputs:i,outputs:a,image:Yr(n),speech:n.type===`speech`?n.speech:null,live:n.type===`live`?n.live:null}}function Zr(e,t){return Xr(e.tools,e.profiles.get(t))}var Qr=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/wav`,`audio/mpeg`];function $r(e){return e.join(`,`)}function ei(e){let t=e?.attachments?.accept,n=e?.voice?.accept;return{text:e?.text!==!1,attachments:t?.length?{accept:t,acceptAttr:$r(t)}:null,voice:n?.length?{accept:n}:null,maxFiles:e?.maxFiles,maxBytes:e?.maxBytes,maxTurnBytes:e?.maxTurnBytes,limitsByMime:e?.limitsByMime,options:e?.options,context:e?.context}}function ti(e){return{text:e.text,attachments:e.attachments?{accept:e.attachments.accept}:void 0,voice:e.voice?{accept:e.voice.accept}:void 0,maxFiles:e.maxFiles,maxBytes:e.maxBytes,maxTurnBytes:e.maxTurnBytes,limitsByMime:e.limitsByMime,options:e.options,context:e.context}}function ni(e,t){let n=e=>(e??[]).map(({name:e,mimeType:t,sizeBytes:n})=>({name:e,mimeType:t,sizeBytes:n})),r=Dt({attachments:e.attachments?.accept,voice:e.voice?.accept,limits:Et(ti(e))},n(t.attachments),n(t.voice));return{ok:r.length===0,issues:r}}function ri(e){let t=globalThis.MediaRecorder;if(t===void 0)return;let n=e=>t.isTypeSupported(e),r=e=>e.find(n);return e?.length?r(Qr.filter(t=>xt(e,t)))??e.find(n):r(Qr)}var ii=_({protocol:r(),provider:r(),apiId:r(),options:t(r(),u()).optional(),keySlot:r().optional(),fallbackKeySlot:r().optional(),efforts:t(r(),c(he)).optional(),defaultEffort:r().optional(),allowEffortSelect:m().optional(),summaries:m().optional(),maxOutputTokens:s().optional(),temperature:s().optional(),builtInTools:l(r()).optional(),compaction:_({maxTokens:s(),compactAt:s(),previousExchanges:s(),profile:r().optional(),timing:c(Ve),meter:c(Ze).optional()}).optional(),limits:_({operationTimeoutMs:s().optional(),connectTimeoutMs:s().optional(),liveStepTimeoutMs:s().optional(),maxWireRecordBytes:s().optional(),maxWireResponseBytes:s().optional(),maxEventBytes:s().optional(),maxStepBytes:s().optional(),maxStepEvents:s().optional(),maxPendingToolCalls:s().optional()}).optional()}),V=_({structured:n([r(),_({by:r(),map:t(r(),r()),fallback:r()}),f()]).optional(),streaming:_({mode:c(Qe).optional(),streamThoughts:m().optional()}).optional()}),ai=_(Ce(ye,()=>c(Je))),oi=_(Ce(Re,()=>ai)),si=_({id:r(),label:r(),actions:ai,names:l(r()),find:m()}),ci=_({hosts:l(r()),fromTools:m()}),li=_({quota:_({perDay:s()}).optional(),detect:oi,patterns:a(c(Re),_({theorem:m(),names:l(r())})).optional(),host:l(si).optional(),allow:_({ungiven_images:ci,ungiven_links:ci}),blockedReply:_({onBlock:c(me),maxRetries:s()})}),ui=n([m(),_({theorem:m(),host:m()})]),di=_({record:m(),writeTo:n([g(!1),r()]).optional(),sampleRate:s(),include:_({upstreamLog:m(),outboundWire:m(),evidenceRaw:m(),usage:m(),guardrailDecisions:m(),guardrailMatchPreview:m()}),scrub:_({sensitive:ui,injection:ui,canary:ui}),resource:Ht,retainForDays:s(),rotateAfterMiB:s(),hasOnWriteError:m()}),fi=t(r(),_({label:r().optional(),choices:l(_({value:r(),description:r().optional()}))})),H=_({text:m(),attachments:_({accept:l(r()),acceptAttr:r()}).nullable(),voice:_({accept:l(r())}).nullable(),maxFiles:s().optional(),maxBytes:s().optional(),maxTurnBytes:s().optional(),limitsByMime:t(r(),s()).optional(),options:fi.optional(),context:_({from:l(c(ht)),maxChars:s()}).optional()}),pi=_({allowContinue:l(c(bt)).optional(),autoContinue:l(c(bt)).optional(),maxContinues:s().optional()}),mi=_({resumption:pi.optional()}),hi=_({allow:l(r()),page:l(r()),t2Loader:r().optional(),parallel:m().optional()}),U={providerContinuation:_({history:c([`host`,`stateless`,`provider`]).optional()}).optional(),id:r(),models:t(r(),ii),defaultModel:r(),allowModelSelect:m().optional(),maxSteps:s().optional(),labels:a(c(be),r()),guardrails:li.optional(),observability:di.optional()},gi=n([r(),o({private:r().min(1)})]),_i=n([r(),l(n([r(),l(gi).readonly()])).min(1).readonly()]),vi=_({handle:r(),options:fi.optional(),system:_i.optional()}),W=d(`type`,[_({...U,type:g(`text`),identity:vi,outputs:V.optional(),inputs:H,tools:hi,turnBehaviour:_({resumption:pi.optional(),allowSteering:m().optional(),atStepLimit:c(ee).optional()}).optional(),canStop:g(!0),allowSteering:m()}),_({...U,type:g(`image`),identity:vi,outputs:V.optional(),image:_({aspectRatio:r().optional(),resolution:r().optional(),mimeType:r().optional(),quality:r().optional(),background:r().optional(),n:s().int().min(1).optional(),seed:s().int().optional(),outputCompression:s().int().min(0).max(100).optional(),references:l(n([_({mimeType:r(),data:r(),name:r().optional()}),_({mimeType:r(),uri:r(),name:r().optional()})])).optional(),includeText:m().optional()}),inputs:H,tools:hi,turnBehaviour:mi.optional(),canStop:g(!0)}),_({...U,type:g(`transcription`),identity:_({handle:r()}),maxSteps:h().optional(),outputs:V.optional(),inputs:H,canStop:g(!0)}),_({...U,type:g(`speech`),identity:_({handle:r()}),outputs:V.optional(),speech:_({voice:r().optional(),style:r().optional(),speed:s().optional(),format:c(tt).optional()}),inputs:H,turnBehaviour:mi.optional(),canStop:g(!0)}),_({...U,type:g(`live`),identity:vi,inputs:H.pick({options:!0,context:!0}).optional(),live:_({ingress:_({audio:m().optional(),video:m().optional(),text:m().optional()}).optional(),voice:r().optional(),vad:_({activityHandling:c(w).optional(),startSensitivity:c(Ee).optional(),endSensitivity:c(_t).optional(),prefixPaddingMs:s().optional(),silenceDurationMs:s().optional()}).optional(),sessionResumption:m().optional(),contextCompression:_({triggerTokens:s().optional(),slidingWindow:_({targetTokens:s().optional()})}).optional(),transcription:_({input:m().optional(),output:m().optional()}).optional()}),tools:hi.pick({allow:!0,page:!0}),turnBehaviour:_({allowSteering:m().optional()}).optional()})]);function yi(e){let t=A(e),{sources:n,host:r,...i}=t.detect;return{quota:t.quota,detect:i,...n?{patterns:Object.fromEntries(Object.entries(n).map(([e,{theorem:t,matchers:n}])=>[e,{theorem:t,names:n.map(({name:e})=>e)}]))}:{},...r?{host:r.map(({id:e,label:t,actions:n,matchers:r,find:i})=>({id:e,label:t,actions:n,names:r.map(({name:e})=>e),find:!!i}))}:{},allow:{ungiven_images:bi(t.allow.ungiven_images),ungiven_links:bi(t.allow.ungiven_links)},blockedReply:t.blockedReply}}function bi(e){return{hosts:[...e.hosts??[]],fromTools:e.fromTools??!0}}function xi(e){return e===void 0||e===!1||typeof e==`string`?e:`custom`}function Si(e){if(!e)return;let t=Bt(e);return{record:t.record,writeTo:xi(t.writeTo),sampleRate:t.sampleRate,include:t.include,scrub:t.scrub,resource:t.resource,retainForDays:t.retainForDays,rotateAfterMiB:t.rotateAfterMiB,hasOnWriteError:!!t.onWriteError}}function Ci(e){let{greeting:t,resumed:n,...r}=e??{};return r}function wi(e,t){let n=e.tools.filter(e=>`type`in e&&e.type===`function`&&e.answeredBy===`page`).map(e=>e.name);if(t){let e=zt(t),r=Lt(t);return{allow:[...Ft(t)],page:n,...e?.t2Loader?{t2Loader:e.t2Loader}:{},...r===void 0?{}:{parallel:r}}}return{allow:e.tools.filter(e=>!(`type`in e&&e.type===`builtin`)).map(e=>e.name),page:n}}function Ti({allow:e,page:t}){return{allow:e,page:t}}function Ei(e,t){let n=ei(e.inputs),r=t?.identity??{handle:e.handle},i=t?yi(t.guardrails):void 0,a=t?Si(t.observability):void 0,o=e.outputs??void 0,s={id:e.id,identity:r,models:e.models,defaultModel:e.defaultModel,allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps,providerContinuation:e.providerContinuation,outputs:o,guardrails:i,observability:a,labels:x(t?.labels)};switch(e.type){case`text`:return W.parse({...s,type:`text`,inputs:n,tools:wi(e,t),turnBehaviour:t?.type===`text`?t.turnBehaviour:void 0,canStop:!0,allowSteering:!t||je(t)});case`image`:return W.parse({...s,type:`image`,image:e.image??{},inputs:n,tools:wi(e,t),turnBehaviour:t?.type===`image`?t.turnBehaviour:void 0,canStop:!0});case`speech`:return W.parse({...s,type:`speech`,speech:e.speech??{},inputs:n,turnBehaviour:t?.type===`speech`?t.turnBehaviour:void 0,canStop:!0});case`transcription`:return W.parse({...s,type:`transcription`,inputs:n,canStop:!0});case`live`:return W.parse({...s,type:`live`,live:Ci(e.live),...e.inputs?{inputs:{options:n.options,context:n.context}}:{},tools:Ti(wi(e,t))});default:return e.type}}function Di(e,t){let n=Lr(e,`interfaceFromProfile`);return Ei(Xr(t,n),n)}function Oi(e){return p(t=>Ke.safeParse(e(t)).success)}var ki=[`running`,`gate`,`background`,`complete`,`error`,`cancel`],Ai=p(e=>{let t=Ke.safeParse({type:`tool`,tool:e});if(!t.success||t.data.type!==`tool`||!(`phase`in t.data.tool))return!1;let{phase:n}=t.data.tool;return ki.some(e=>e===n)}),ji=t(r(),i()),Mi=_({operationId:r().optional(),name:r(),callId:r(),arguments:ji,draft:r().optional(),reasoning:l(ut).optional(),stepId:r().optional(),edited:_({from:ji,to:ji}).optional(),activity:r().optional(),activityPast:r().optional(),outputDraft:r().optional(),state:Ai.optional(),startedAt:s().optional(),endedAt:s().optional(),artifacts:l(i()),get steps(){return l(Mi).optional()}}),Ni=_({kind:c(Ct),native:r().optional()}),G={id:r()},K=d(`kind`,[_({...G,kind:g(`user-text`),text:r()}),_({...G,kind:c([`user-attachment`,`user-voice`]),name:r(),mimeType:r(),sizeBytes:s(),data:r().optional()}),_({...G,kind:g(`thought`),text:r()}),_({...G,kind:g(`text`),text:r()}),_({...G,kind:g(`tool`),tool:Mi}),_({...G,kind:g(`structured`),value:i(),draft:r().optional()}),_({...G,kind:g(`media`),mimeType:r(),data:r().optional(),url:r().optional(),previewUrl:r().optional()}),_({...G,kind:g(`grounding`),grounding:Oi(e=>({type:`grounding`,grounding:e}))}),_({...G,kind:g(`citation`),sources:Oi(e=>({type:`citation`,sources:e})),callId:r().optional()}),_({...G,kind:g(`evidence`),evidence:Oi(e=>({type:`evidence`,evidence:e}))}),_({...G,kind:g(`guardrail`),guardrail:et}),_({...G,kind:g(`late-results`),text:r()}),_({...G,kind:g(`error`),message:r()}),_({...G,kind:g(`turn-done`),stop:Ni.optional(),tokens:Oi(e=>({type:`tokens`,tokens:e})).optional(),interactionId:r().optional(),compaction:m().optional(),workedMs:s().optional(),endedAt:s().optional()})]),Pi=_({type:r()});function Fi(e,t){return Object.hasOwn(e,t)}function Ii(e,t){return e.map(e=>{let n=[...t,...e.path],r=`${n.map(String).join(`.`)||`(root)`} ${e.code}`;return e.code!==`invalid_union`||e.errors.length===0?r:`${r} [${e.errors.map(e=>Ii(e,n)).join(` | `)}]`}).join(`; `)}function Li(e){return Ii(e.issues,[])}function Ri(e,t){return new j(`bad_response`,`${e} failed its wire check: ${Li(t)}`)}function q(e,t,n){let r=e.safeParse(t);if(!r.success)throw Ri(n,r.error);return r.data}function zi(e){return{type:`malformed`,error:new j(`bad_response`,e,{copy:{key:`session.part_skipped`}})}}function Bi(e,t){let n=Pi.safeParse(t);if(!n.success)return zi(`a line without a kind failed its wire check: ${Li(n.error)}`);let{type:r}=n.data;if(!Fi(e,r))return{type:`unsupported`,received:r,raw:t};let i=e[r].safeParse(t);return i.success?i.data:zi(`a '${r}' line failed its wire check: ${Li(i.error)}`)}function Vi(e){try{return{value:JSON.parse(e)}}catch(e){if(e instanceof SyntaxError)return;throw e}}function Hi(e,t){let n=Vi(t);return n?Bi(e,n.value):zi(`a line is not JSON`)}function Ui(e){let t=Vi(e);if(!t)throw new j(`bad_response`,`a line is not JSON`);return t.value}var Wi=_({name:r(),mimeType:r(),data:r()}),Gi=_({options:t(r(),r()).optional(),context:i().optional(),text:r().optional(),attachments:l(Wi).optional(),voice:l(Wi).optional()}),Ki=_({gateKind:c(O).optional(),sessionPermissions:l(r()).optional(),name:r().optional(),input:i().optional(),snapshot:it.optional(),promoted:l(r()).optional(),model:r().optional(),effort:r().optional()}),J=r().trim().min(1),qi=_({path:r().optional(),options:t(r(),r()).optional()}),Ji=qi;_({input:Gi,conversation:r().min(1).optional(),model:r().optional(),effort:r().optional(),stated:qi.optional(),turnId:J.optional(),abandon:l(ct).min(1).optional(),replay:Ki.pick({sessionPermissions:!0}).optional(),transcript:l(K).optional()});var Yi=[`approve`,`deny`],Xi=n([o({unanswered:g(!0)}),o({output:i()}).refine(e=>`output`in e).transform(e=>({output:e.output}))]);_({gateId:r().min(1),operationId:r().min(1).max(256),decision:c(Yi),input:i().optional(),secret:r().optional(),page:Xi.optional(),conversation:r().min(1).optional(),turnId:J.optional(),replay:Ki.optional()}),_({turnId:J,id:J,inject:l(Xe).min(1)}),_({turnId:J});var Zi=_({type:g(`conversation`),ref:r().min(1),posted:g(!0).optional()}),Qi={...at,conversation:Zi},$i=_({transcript:l(K),paused:_({events:l(Ke),blocks:l(K)}).optional(),notify:_({retryMs:s().optional()}).optional()});_({conversation:r().min(1)}),o({});var ea={changed:_({type:g(`changed`)})};_({conversation:r().min(1),at:s().int().min(-1)}),_({blocks:l(K)});var ta=_({conversation:r().min(1),view:$i}),na=class extends Error{kind;publicMessage;internalMessage;copy;constructor(e,t,n,r){super(n??t??e),this.name=`TheoremStreamError`,this.kind=e,t&&(this.publicMessage=t),n&&(this.internalMessage=n),r&&(this.copy=r)}};function ra(e){return e instanceof na}function ia(e){return e?.trim()||void 0}var aa=_({error:r().optional(),errorKind:ve.optional(),errorCopy:D.optional(),errorInternal:r().optional()}),oa=aa;function sa(e,t){let n=ia(e.error),r=ia(e.errorInternal);return new na(e.errorKind??t,n,r&&r!==n?r:void 0,e.errorCopy)}function ca(e){return!ra(e)||e.copy===void 0?!1:(Array.isArray(e.copy)?e.copy:[e.copy]).some(e=>e.key===`session.conversation_unknown`)}function la(e,t){let n=Hi(e,t);if(n.type===`error`)throw sa(aa.parse(n),`internal`);return n}function ua(e,t,n){let r=e.split(`
5
- `),i=r.pop()??``;for(let e of r)e.trim()&&n(la(t,e));return i}async function da(e,t,n,r){if(!e.body)throw new j(`bad_response`,`stream reply has no body`);let i=e.body.getReader(),a=new TextDecoder,o=``,s=()=>{i.cancel()};r?.addEventListener(`abort`,s,{once:!0});try{for(;;){le(r);let{done:e,value:s}=await i.read();if(e)break;o=ua(o+a.decode(s,{stream:!0}),t,n)}let e=o.trim();e&&n(la(t,e))}finally{r?.removeEventListener(`abort`,s)}}async function fa(e){let t=typeof e.headers==`function`?await e.headers():e.headers,n=new Headers(t);return n.set(`content-type`,`application/json`),n}async function pa(e,t){let n=await e.text(),r;try{r=JSON.parse(n),t?.(r)}catch{return sa({errorInternal:`HTTP ${String(e.status)}`},Me(e.status))}let i=aa.safeParse(r);return i.success?sa({...i.data,errorInternal:i.data.errorInternal??`HTTP ${String(e.status)}`},Me(e.status)):new j(`bad_response`,`HTTP ${String(e.status)} error body failed its wire check`)}async function ma(e,t,n){let r=n.fetch??globalThis.fetch.bind(globalThis);try{return await r(e,{...t,headers:await fa(n),credentials:n.credentials??`same-origin`})}catch(e){throw De(e)?e:new j(`network`,te(e),{cause:e})}}async function ha(e,t,n,r,i={}){await da(await ga(e,t,i),n,r,i.signal)}async function ga(e,t,n){let r=await ma(e,{method:`POST`,body:JSON.stringify(t),signal:n.signal},n);if(!r.ok)throw await pa(r);return r}async function _a(e,t,n={}){await ga(e,t,n)}async function Y(e,t,n={}){let r=await ma(e,{...t.body===void 0?{method:`GET`}:{method:`POST`,body:JSON.stringify(t.body)},signal:t.signal},n);if(!r.ok)throw await pa(r,t.failed);return Ui(await r.text())}async function va(e,t,n={}){let{signal:r,...i}=n;return q($i,await Y(e,{body:t,signal:r},i),`the conversation`)}async function ya(e,t,n,r){let{signal:i,...a}=n;return q(ta,await Y(e,{body:t,signal:i},a),r)}function ba(e,t,n={}){return ya(e,t,n,`the rewound conversation`)}function xa(e,t,n={}){return ya(e,t,n,`the started conversation`)}function Sa(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}var Ca=_({interface:W});function wa(e={}){let t=Sa(e.endpoint??`/api/theorem`);return{async describe(n){let r=await ma(t,{method:`GET`,signal:n},e);if(!r.ok)throw await pa(r);return q(Ca,Ui(await r.text()),`the profile description`).interface},turn:({replay:n,...r},i,a)=>ha(`${t}/turn`,r,Qi,i,{...e,signal:a}),invoke:({replay:n,...r},i,a)=>ha(`${t}/invoke`,r,Qi,i,{...e,signal:a}),conversation:(n,r)=>va(`${t}/conversation`,n,{...e,signal:r}),notify:(n,r)=>ha(`${t}/notify`,{},ea,e=>{e.type===`changed`&&n()},{...e,signal:r}),rewind:(n,r)=>ba(`${t}/rewind`,n,{...e,signal:r}),pageResult:(n,r)=>_a(`${t}/page-result`,n,{...e,signal:r}),steer:n=>_a(`${t}/steer`,n,e),stop:n=>_a(`${t}/stop`,n,e)}}function Ta(e,t){if(typeof e==`string`)return e;let n=Array.isArray(e)?e:Object.keys(e);return n.length?Ta(n[0],t):t}function Ea(e){return Object.entries(e).map(([e,t])=>({id:e,type:t.type,labels:t.type===`choice`?Object.keys(t.criteria):t.type===`score`?t.criteria.map((e,t)=>Ta(e,String(t))):[],...t.type===`box`&&t.image!==void 0?{image:t.image}:{}}))}function Da(e,t,n){return{type:`decision`,identity:{handle:e.identity.handle},contract:e.decision.contract,...e.inputs.maxStateBytes===void 0?{}:{maxStateBytes:e.inputs.maxStateBytes},questions:Ea(t),...n&&Object.keys(n).length>0?{images:n}:{},...e.observability?{observability:{record:Bt(e.observability).record}}:{}}}function Oa(e,t){let n=Object.keys(t??{}).find(t=>e&&Object.hasOwn(e,t));if(n!==void 0)throw new j(`request`,`the image ${n} is the host's, so the page's needs another name`);let r={...e,...t};return Object.keys(r).length>0?r:void 0}var X=s().min(0).max(1),ka=t(r(),X),Aa=d(`type`,[_({type:g(`choice`),choice:r(),confidence:X,probabilities:ka}),_({type:g(`noul`),noul:X}),_({type:g(`box`),box:_({top:X,bottom:X,left:X,right:X}),confidence:X}),_({type:g(`score`),score:s().nonnegative(),confidence:X,legend:t(r(),r().min(1)),probabilities:ka})]),ja=_({id:r(),type:c([`choice`,`noul`,`score`,`box`]),labels:l(r()),image:r().optional()}),Ma=_({result:_({model:r().min(1),questions:l(ja).optional(),answers:t(r(),Aa),usage:_({inputTokens:s().int().nonnegative(),outputTokens:s().int().nonnegative(),costUsd:s().nonnegative().optional()}).optional()}),traces:l(Vt).optional()}),Na=new WeakMap;function Pa(e,t){return t.length>0&&typeof e==`object`&&e&&Na.set(e,t),e}function Fa(e){return typeof e==`object`&&!!e&&Na.get(e)||[]}var Ia=_({traces:l(Vt)});async function La(e,t,n,r,i){let a=[],o=e=>{let t=Ia.safeParse(e);t.success&&(a=t.data.traces)};try{return i(await Y(e,{body:t,signal:n,failed:o},r))}catch(e){throw Pa(e,a)}}function Ra(e,t,n,r={}){return La(e,t,n,r,za)}function za(e){return q(Ma,e,`the decision`)}var Ba=_({interface:_({type:g(`decision`),identity:_({handle:r()}),contract:r(),maxStateBytes:s().optional(),questions:l(ja),build:_({input:t(r(),i()).optional()}).optional(),images:t(r(),_({mimeType:c([`image/png`,`image/jpeg`]),data:r()})).optional(),observability:_({record:m()}).optional()})});function Va(e={}){let t=(e.endpoint??`/api/decision`).replace(/\/$/,``);return{async describe(n){return q(Ba,await Y(t,{signal:n},e),`the decision description`).interface},decide:(n,r,i,a)=>Ra(`${t}/decide`,{state:n,...i?{assets:i}:{},...a===void 0?{}:{input:a}},r,e)}}function Ha(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function Q(e,t){if(!URL.canParse(t))return;let n=new URL(t);if(n.protocol===`http:`||n.protocol===`https:`)return{title:e.trim()||n.hostname.replace(/^www\./,``),uri:n.href,type:`web`}}function Ua(e){let t=new Set;return e.filter(e=>!t.has(e.uri)&&(t.add(e.uri),!0))}function Wa(e){let t=[...e.matchAll(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g)].flatMap(e=>Q(e[1]??``,e[2]??``)??[]),n=[...e.matchAll(/https?:\/\/[^\s"'<>\]]+/g)].flatMap(e=>{let t=(e[0]??``).replace(/[),.;:]+$/,``);return Q(t,t)??[]});return Ua([...t,...n])}function Ga(e){if(Array.isArray(e))return e;if(!Ha(e))return[];for(let t of[`items`,`results`,`search_results`,`models`,`datasets`]){let n=e[t];if(Array.isArray(n))return n}return[]}function Ka(e,t){return Ua(e.flatMap(e=>Ha(e)?t(e)??[]:[]))}function qa(e,t){let n=t===`dataset`?`https://huggingface.co/datasets/`:`https://huggingface.co/`;return Ka(Ga(e),e=>{let t=Z(e,`id`)??Z(e,`modelId`);return t?Q(t,`${n}${t}`):void 0})}function Ja(e){return Ka(Ga(e),e=>{let t=Z(e,`html_url`),n=Z(e,`full_name`)??Z(e,`name`);return t?Q(n??t,t):void 0})}function Ya(e){let t=e,n;do n=t,t=t.replace(/<[^>]+>/g,``);while(t!==n);return t.replace(/\s+/g,` `).trim()}function Xa(e){if(typeof e!=`string`)return Wa(JSON.stringify(e));let t=[...e.matchAll(/<entry\b[\s\S]*?<\/entry>/g)];return t.length===0?Wa(e):Ua(t.flatMap(e=>{let t=/<id>(https?:\/\/[^<]+)<\/id>/.exec(e[0]??``)?.[1],n=/<title>([\s\S]*?)<\/title>/.exec(e[0]??``)?.[1];return t?Q(Ya(n??t),t)??[]:[]}))}function $(e){if(typeof e==`string`)return Wa(e);if(Array.isArray(e)||Ha(e)){let t=Ka(Ga(e),e=>{let t=Z(e,`html_url`)??Z(e,`url`)??Z(e,`source_url`)??Z(e,`contentUrl`),n=Z(e,`title`)??Z(e,`name`)??t;return t?Q(n??t,t):void 0});return t.length>0?t:Wa(JSON.stringify(e))}return[]}var Za={search_models:e=>qa(e,`model`),search_datasets:e=>qa(e,`dataset`),search_github:Ja,list_arxiv:Xa,search_web:$,read_pages:$,read_model_card:$,read_dataset_card:$,read_readme:$,find_library:$,read_library_docs:$,ask_repo_docs:$};function Qa(e){return Za[e]}function $a(e,t){let n=Qa(e);return n?{...t,sources:n}:t}function eo(e,t,n={}){let r={name:t.name,description:t.description,category:t.category,access:t.access,paths:t.paths,loadTier:t.loadTier,permission:t.permission,...t.labels?{labels:t.labels}:{},...t.after?{after:!0}:{},...t.background?{background:t.background}:{}};if(t.type===`agent`){e.register({...r,type:`agent`,profile:t.profile,...t.maxCallsPerTurn===void 0?{}:{maxCallsPerTurn:t.maxCallsPerTurn}});return}let i={...r,input:b(t.inputSchema),output:b(t.outputSchema)};if(t.type===`http`){e.register($a(t.name,{...i,type:`http`,endpoint:t.endpoint,method:t.method,headers:t.headers,mapping:t.mapping,auth:t.auth,maxResponseBytes:t.maxResponseBytes}));return}if(t.type===`mcp`){e.register($a(t.name,{...i,type:`mcp`,serverUrl:t.serverUrl,mcpToolName:t.mcpToolName,headers:t.headers,auth:t.auth,maxResponseBytes:t.maxResponseBytes,session:t.session}));return}if(t.answeredBy===`page`){e.register({...i,type:`function`,answeredBy:`page`});return}let a=t.stubResponse||!Object.hasOwn(n,t.name)?void 0:n[t.name],o=t.stubResponse??Ut(t.outputSchema);e.register({...i,type:`function`,handler:a?e=>{try{return Promise.resolve(a(e))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}}:()=>Promise.resolve(o)})}function to(e,t,n){e.registerMany([...v,...y]);for(let r of t)eo(e,r,n)}function no(e,t,n,r,i){if(to(e.tools,n,i),r&&t.type!==`live`)for(let{id:t,spec:n}of[r,...r.also??[]])e.schemas.register(t,n);return e.profiles.register(t),t}function ro(e){if(e.type===`error`&&e.errorInternal!==void 0){let{errorInternal:t,...n}=e;return{...n,error:t}}if(e.type===`session`&&e.session.kind===`ended`&&e.errorInternal!==void 0){let{errorInternal:t,...n}=e;return{...n,session:{...e.session,message:t}}}if(e.type===`tool`&&e.tool.phase===`error`&&e.tool.failure.error!==void 0){let{failure:t}=e.tool;return{...e,tool:{...e.tool,failure:{...t,error:t.message}}}}return e}function io(e){if(e.type!==`error`&&e.type!==`session`&&e.type!==`tool`&&e.type!==`hook_failed`||e.errorInternal===void 0)return e;let{errorInternal:t,...n}=e;return n}function ao(e){if(e.type!==`compaction`||e.failure?.errorInternal===void 0)return e;let{errorInternal:t,...n}=e.failure;return{...e,failure:n}}function oo(e){if(e.type!==`guardrail`||!(e.guardrail?.errorInternal||e.guardrail?.errorSummary))return e;let{errorInternal:t,errorSummary:n,...r}=e.guardrail;return{...e,guardrail:r}}function so(e){if(e.type!==`done`||e.mediaRefused===void 0)return e;let{mediaRefused:t,...n}=e;return n}function co(e){if(e.type!==`evidence`||!e.evidence?.raw)return e;let{raw:t,...n}=e.evidence;return{...e,evidence:n}}function lo(e,t){if(e.type!==`tool`||e.tool.phase!==`progress`)return e;let{data:n}=e.tool;if(typeof n!=`object`||!n||!(`agent`in n)||!(`event`in n))return e;let r=uo(n.event,t);return{...e,tool:{...e.tool,data:{...n,event:r}}}}function uo(e,t){let n=lo(e,t),r=t?.reader===`builder`?ro(n):so(ao(oo(io(n))));return t?.includeEvidenceRaw||(r=co(r)),r=Kt(r,!1),r}function fo(e,t){return e.map(e=>uo(e,t))}function po(e,t,n){let{error:r=``,errorKind:i,errorCopy:a}=uo(Fe(Le(e),t),n);return{error:r,errorKind:i,...a?{errorCopy:a}:{}}}var mo={reader:`builder`};function ho(e){return e.mode===`demo`?{reader:`visitor`}:mo}export{Un as $,Li as A,Nr as B,oa as C,ha as D,_a as E,ri as F,ur as G,mr as H,ni as I,tr as J,sr as K,Rr as L,Bi as M,K as N,Ji as O,Di as P,nr as Q,Zr as R,sa as S,ca as T,cr as U,Mr as V,lr as W,er as X,Jn as Y,rr as Z,wa as _,fo as a,Ln as at,ba as b,Va as c,Wt as ct,Fa as d,Hn as et,Ra as f,na as g,Qi as h,uo as i,Rn as it,Hi as j,q as k,Oa as l,Kt as lt,Pa as m,ho as n,Vn as nt,no as o,Xt as ot,La as p,ar as q,po as r,z as rt,to as s,Gt as st,mo as t,Bn as tt,Da as u,va as v,ra as w,xa as x,Y as y,Jr as z};
@@ -1 +0,0 @@
1
- import{D as e,E as t,T as n,b as r,c as i,d as a,h as o,o as s,p as c,pt as l,s as ee,t as u,v as d}from"./schemas-D7cgkv3L.js";import{Aa as te,Oa as ne,Wi as re,X as ie,ct as f,fi as ae,ii as p,ja as m,ma as h,ni as g,nt as _,pa as oe,q as se,to as v,xn as ce}from"./shaped-data-Dp2yZFfd.js";import{c as y}from"./host-patterns-F-KZIzkF.js";import{d as le,f as ue,i as b,l as de,n as x,s as fe,t as S}from"./schema-B3Tv1Fpx.js";var pe=n({accepted:oe,preparedInput:h});function C(e){return new y(`internal`,e)}function w(e,t,n){return new y(e,t,{copy:{key:`tool.execution_uncertain`},cause:n})}function T(e){return w(`conflict`,`The tool operation is ${e}, so it does not run again until the host settles it`)}async function E(e){let t=e=>Array.isArray(e)?e.map(t):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,n])=>[e,t(n)])):e,n=h.parse(t(M(e))),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,`0`)).join(``)}var D=g.tool.transform((e,t)=>e.tool.phase===`complete`||e.tool.phase===`error`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),O=n({finding:t(),data:h.optional(),parts:a(p).optional(),modelText:t().optional(),provenance:m.optional(),suspicious:a(te).optional()}),k=g.tool.transform((e,t)=>e.tool.phase===`background`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),A=n({event:k,replay:n({modelResult:O})}),j=n({event:D,effects:i([`not_started`,`completed`,`unknown`]),replay:n({modelResult:O.optional(),outputRaw:h.optional(),failure:n({code:t(),kind:ne,message:t(),error:t().optional(),details:h.optional()}).optional(),awaiting:c().optional(),denied:d(!0).optional(),callNotStarted:c().optional(),aborted:e([c(),n({reason:t().optional()})]).optional(),pendingInject:a(n({id:t().optional(),messages:a(ae),released:r().int().nonnegative().optional()})).optional()})});function M(e){let t=new Set,n=e=>{if(!e||typeof e!=`object`)return e;if(t.has(e))throw C(`Tool operation value has a cycle`);let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&r!==null)throw C(`Tool operation value holds an object that is not plain data`);if(Object.hasOwn(e,`__proto__`))throw C(`Tool operation value has an own __proto__ key`);t.add(e);try{if(Array.isArray(e))return e.map(n);let t=Object.entries(Object.getOwnPropertyDescriptors(e)),r=t.find(([,e])=>e.get||e.set);if(r)throw C(`Tool operation value has a getter or setter at '${r[0]}'`);return Object.fromEntries(t.filter(([,e])=>e.enumerable&&e.value!==void 0).map(([e,t])=>[e,n(t.value)]))}finally{t.delete(e)}};return h.parse(n(e))}var N=e([i([`always`,`ask`,`never`]),n({afterMs:r().finite().nonnegative()})]),P=`background`;function F(){return c().optional().describe(v(`tool.background_field`))}function I(e,t){if(e?.background!==`ask`||typeof t!=`object`||!t)return{input:t,asked:!1};let{[P]:n,...r}=t;return{input:r,asked:n===!0}}function L(e,t){let{background:n}=e;if(n!==void 0&&n!==`never`)return n===`always`?`claim`:n===`ask`?I(e,t).asked?`claim`:void 0:n}function R(e,t){return e.type===`agent`?t?.takesSteers(e)?void 0:`steering_off`:`not_agent`}function z(e){let{tool:t,support:n,base:r,labels:i}=e;if(!t||t.type===`builtin`||!n)return;let a=L(t,e.input);if(a===void 0)return;let o=R(t,e.agents);return{at:a,support:n,...o?{refuseSteers:o}:{},trace:n.openTrace(r.callId),reply:()=>{let e={finding:v(`tool.background_started`,{tool:t.name},i)},n=ie(e),a=se(r,{phase:`background`,readBack:n});return A.parse(M({event:a,replay:{modelResult:e}}))}}}function B(e,t){if(e&&!t?.detach)throw new y(`config`,`A request with a background service needs a coordinator with detach`)}function me(e){let{name:t,background:n}=e;if(n!==void 0&&n!==`never`){if(e.answeredBy===`page`)throw new y(`config`,`Tool '${t}' sets background, which a tool answered by the page cannot`);if(!N.safeParse(n).success)throw new y(`config`,typeof n==`object`?`Tool '${t}' sets background.afterMs, which must be a time in milliseconds`:`Tool '${t}' sets background to ${JSON.stringify(n)}; it takes 'always', 'ask', 'never' or { afterMs }`)}}var he=/^[\x21-\x7E]{1,256}$/;function V(e=Date.now){let t=new Map,n=new Map,r=({tool:e,max:n})=>{if(n===void 0)return;let r=[...t.values()].filter(t=>t.tool===e).length;for(let[i,a]of t){if(r<=n)break;a.tool===e&&(t.delete(i),r--)}};return{get(n,i){let a=t.get(n);if(a&&(t.delete(n),!(i.idleMs!==void 0&&e()-a.usedAt>i.idleMs)))return t.set(n,{...a,usedAt:e(),tool:i.tool}),r(i),{id:a.id,protocolVersion:a.protocolVersion}},open(i,a,o){let s=n.get(i);if(s)return s;let c=o().then(n=>(t.delete(i),t.set(i,{...n,usedAt:e(),tool:a.tool}),r(a),n)).finally(()=>n.delete(i));return n.set(i,c),c},drop(e,n){t.get(e)?.id===n&&t.delete(e)},clear(){t.clear(),n.clear()}}}function ge(e){return e!==null&&he.test(e)}async function _e(e,t){let n=JSON.stringify([e,Object.entries(t).map(([e,t])=>[e.toLowerCase(),t]).sort(([e],[t])=>e<t?-1:+(e>t))]),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(n));return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var H=`after`;function ve(){return a(t()).optional().describe(v(`tool.after_field`))}function U(t,n,r,i){let a=n=>{if(n instanceof s){if(r in n.shape)throw new y(`config`,`Tool '${t}' sets ${r}, and its input already has a field of that name`);return n.safeExtend({[r]:i()})}if(n instanceof u){let e=n.options.map(a);return o(n.def.discriminator,e)}if(n instanceof ee)return e(n.options.map(a));throw new y(`config`,`Tool '${t}' sets ${r}, which needs an object input or a union of objects`)};return a(n)}function W(e,t){return U(e,t,H,ve)}function ye(e,t){if(!e.after||typeof t!=`object`||!t)return{input:t,names:[]};let{[H]:n,...r}=t;return{input:r,names:n??[]}}function be(e,t,n){return n?e.flatMap(e=>{let r=n.filter(n=>n.tool===e&&n.callId!==t).map(e=>e.callId);return r.length>0?r:[e]}):[]}var G=class{value;constructor(e){this.value=e}};function xe(e){return new G(e)}function Se(e){return(t,n)=>{let{page:r}=n;if(r&&`output`in r)return xe(r.output);let{labels:i}=n.profile;throw r?.timedOut?Error(v(`tool.page_timed_out`,{},i)):Error(v(`tool.page_no_answer`,{tool:e},i))}}var K=new WeakMap;function q(e,t){let n=K.get(e);n||(n=new WeakMap,K.set(e,n));let r=n.get(t);if(!r){let i=x(e,`input`);b(i,`input`);let a=x(t,`output`);b(a,`output`),r={inputSchema:i,outputSchema:a},n.set(t,r)}return r}function J(e){let{inputSchema:t,outputSchema:n}=q(e.input,e.output);f(t,`Tool "${e.name}" input`,`input`),f(n,`Tool "${e.name}" output`,`output`);let r={activity:{input:t},activityPast:{input:t,output:n},activityFailed:{input:t},request:{input:t}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let n=e.labels?.[t],i=n?_(n,r[t]):void 0;if(i)throw new y(`config`,`Tool "${e.name}" ${t} label: ${i}`)}return{inputSchema:structuredClone(t),outputSchema:structuredClone(n)}}function Ce(e,t){if(t&&(typeof t.service!=`string`||!t.service.trim()))throw new y(`config`,`Tool "${e}" signs in with slot "${t.slot}" but names no service`)}function Y(e,t,n=[]){if(t?.queryParam===void 0)return;let r=t.queryParam.trim()?t.type===`api_key`?t.headerName!==void 0||t.headerPrefix!==void 0?`is set with headerName or headerPrefix; the key goes in one place`:n.includes(t.queryParam)?`"${t.queryParam}" is also one of mapping.queryParams`:void 0:`is set on a '${t.type}' sign-in; only an API key goes in the URL`:`is blank`;if(r)throw new y(`config`,`Tool "${e}" auth.queryParam ${r}`)}function we(e,t){if(t!==void 0&&!(Number.isInteger(t.requests)&&t.requests>0&&Number.isFinite(t.windowMs)&&t.windowMs>0))throw new y(`config`,`Tool "${e}" limit needs a whole number of requests above 0 and a window above 0 ms`)}function X(e,t){if(!(t===void 0||Number.isFinite(t)&&t>0))throw new y(`config`,`Tool "${e}" timeoutMs needs a finite number of ms above 0`)}function Z(e,t,n){if(!(n===void 0||Number.isInteger(n)&&n>0))throw new y(`config`,`Tool "${e}" ${t} needs a whole number above 0`)}function Q(e){Z(e.name,`maxResponseBytes`,e.maxResponseBytes);let t=e.imageLimits;t&&(Z(e.name,`imageLimits.count`,t.count),Z(e.name,`imageLimits.bytes`,t.bytes),Z(e.name,`imageLimits.totalBytes`,t.totalBytes),X(e.name,t.timeoutMs))}function $(e){if(e.type!==`builtin`&&me({name:e.name,...e.background===void 0?{}:{background:e.background},...e.answeredBy?{answeredBy:e.answeredBy}:{}}),e.type===`builtin`||e.type===`agent`)return;Ce(e.name,e.auth),e.type===`http`?(e.endpoint?.trim()&&S(e.endpoint),Y(e.name,e.auth,e.mapping?.queryParams),we(e.name,e.limit),X(e.name,e.timeoutMs)):Y(e.name,e.auth),(e.type===`http`||e.type===`mcp`)&&Q(e),e.type===`mcp`&&(Z(e.name,`session.idleMs`,e.session?.idleMs),Z(e.name,`session.max`,e.session?.max));let[t]=re(e);if(t)throw new y(`config`,`Tool "${e.name}" ${t.path} ${t.message}`)}function Te(e){return S(e.endpoint),{...e,type:`http`,...J(e)}}function Ee(e){return{...e,type:`mcp`,...J(e)}}function De(e){let t=e.answeredBy===`page`?Se(e.name):e.handler;if(typeof t!=`function`)throw new y(`config`,`Tool '${e.name}' needs a handler, or answeredBy: 'page'`);return{...e,handler:t,type:`function`,...J(e)}}function Oe(e){if(e.type===`builtin`||e.background!==`ask`)return e;let t=e.input,n=U(e.name,t,`background`,F);return{...e,askInputSchema:q(n,e.output).inputSchema}}function ke(e,t,n){return $(e),Oe(Ae(e,t,n))}function Ae(e,t,n){if(e.type===`builtin`)return e;if(e.type===`agent`){let r=le(e,t,n),i=ce(r),a=fe({type:r.type,...i?{inputs:i}:{}},e),o=e.after?W(e.name,a):a,s=J({...e,input:o,output:de});return ue(e,o,s)}let r=e.after?{...e,input:W(e.name,e.input)}:e;return r.type===`http`?Te(r):r.type===`mcp`?Ee(r):De(r)}function je(e=()=>void 0,t=()=>[]){let n=new Map,r=V(),i=e=>n.get(e),a=t=>{let r=ke(t,e,i);return n.set(r.name,r),r};return{register:a,registerMany:e=>e.map(e=>a(e)),get:i,require(e){let t=i(e);if(!t)throw new y(`config`,`Tool '${e}' is not registered`);return t},has:e=>n.has(e),list:()=>[...n.values()],findProfile:e,structuredReplies:t,reset:()=>{n.clear(),r.clear()},mcpSessions:r}}export{j as _,be as a,_e as c,I as d,T as f,E as g,pe as h,ye as i,B as l,M as m,je as n,V as o,C as p,G as r,ge as s,$ as t,z as u,A as v,w as y};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n,r,u as i}from"./themeProps-Bo2jNkIC.js";import{t as a}from"./mergeProps-ptS-gIMz.js";import{t as o}from"./Icon-Cd9sDRzY.js";import{t as s}from"./Text-Cq4yqBpQ.js";import{t as c}from"./Button-Bwkht0RI.js";import{t as l}from"./Token-CGIAH1hn.js";import{w as u}from"./browser-transport-DgVZiZ-t.js";import{t as d}from"./CodeBlock-QRlV-wmv.js";import{t as f}from"./createReactComponent-DVEyVJ-p.js";import{n as ee}from"./useAdaptivePresentation-D53OuCPm.js";import{Ha as te,Ka as ne,a as p,pn as m,to as h,zt as g}from"./shaped-data-Dp2yZFfd.js";import{k as _}from"./turn-client-CdXgO5_p.js";import{n as v}from"./stub-BlSgwV6N.js";import{t as y}from"./Badge-BUFlIXVD.js";import{n as b,t as x}from"./labels-provider-DlvOtCm7.js";import{t as S}from"./HStack-B00ufja5.js";import{t as re}from"./VStack-D1ZLA9g3.js";import{t as ie}from"./Card-C6l0Ne1A.js";import{n as C}from"./CollapsibleGroup-483UEs5v.js";import{t as w}from"./TextInput-DwHcdc-E.js";var T=f(`outline`,`flame`,`Flame`,[[`path`,{d:`M12 10.941c2.333 -3.308 .167 -7.823 -1 -8.941c0 3.395 -2.235 5.299 -3.667 6.706c-1.43 1.408 -2.333 3.294 -2.333 5.588c0 3.704 3.134 6.706 7 6.706c3.866 0 7 -3.002 7 -6.706c0 -1.712 -1.232 -4.403 -2.333 -5.588c-2.084 3.353 -3.257 3.353 -4.667 2.235`,key:`svg-0`}]]),E=[`cancelled`,`interrupted`,`length`,`filtered`,`provider_error`,`stream_incomplete`,`step_limit`,`answer_missing`],D=new Set(E);function O(e){return D.has(e)}function k(e,t,n){if(!e||!O(e.kind)||g(e)||t.some(e=>e.kind===`error`))return;let r=`stop.${e.kind}`;return h(r,{},n)}function A(e,t){let n=(n,r)=>{let i=new Set;return a=>{if(n(a),a.type!==`tool`||a.tool.phase!==`dispatch`)return;let{tool:o}=a;if(!e.pageResult||!o.operationId||r?.aborted)return;let s=JSON.stringify([o.operationId,o.grantId]);if(i.has(s))return;i.add(s);let c=t&&Object.hasOwn(t,o.name)?t[o.name]:void 0,l={callId:o.callId,operationId:o.operationId,grantId:o.grantId};Promise.resolve().then(async()=>{if(r?.aborted)return;let t=c?await Promise.resolve().then(()=>c(o.arguments,l)).catch(()=>({unanswered:!0})):{unanswered:!0};await e.pageResult?.({...l,page:t},r)}).catch(e=>{r?.aborted||n({type:`error`,errorKind:te(e),error:ne(e)})})}},r=(e,t)=>{let r=n(e,t);return t=>t.type===`conversation`?e(t):r(t)};return`call`in e?{...e,describe:e.describe.bind(e),invoke:(t,r,i)=>e.invoke(t,n(r,i),i),call:(t,r,i)=>e.call(t,n(r,i),i)}:{...e,describe:e.describe.bind(e),invoke:(t,n,i)=>e.invoke(t,r(n,i),i),turn:(t,n,i)=>e.turn(t,r(n,i),i),steer:e.steer.bind(e),stop:e.stop.bind(e),conversation:e.conversation.bind(e),rewind:e.rewind.bind(e)}}function j(e){if(e.resolution.action===`deny`)return{decision:`deny`};let{resolution:t}=e;return{decision:`approve`,...t.action===`auth`&&t.secret!==void 0?{secret:t.secret}:{},...t.action===`page`?{page:t.page}:{},sessionPermissions:_(e.sessionPermissions,e.toolName,e.gate.permission)}}var M=`theorem.oauth_complete`;function N(e,t){if(e.source!==t.popup||e.origin!==t.origin)return!1;let n=e.data;return m(n)&&n.type===M&&n.slot===t.slot}function P(e){return{openMessage:{type:`draft`,profile:e.profile,customTools:e.customTools}}}function F(e){let t={};for(let n of e.customTools){if(n.type!==`function`||n.answeredBy!==`page`)continue;let e=n.stubResponse??v(n.outputSchema);t[n.name]=()=>({output:e})}return t}var I=n(),L={container:{kVAEAm:`x1n2onr6`,kzqmXN:`xh8yej3`,kVQacm:`x7giv3`,kAzted:`x2lwn1j`,kmuXW:`x2lah0s`,$$css:!0},ellipse:{kaIpWk:`x16rqkct`,$$css:!0}},R={ratio:e=>[{kOBAk4:e==null?e:`x10y9f9r`,$$css:!0},{"--x-aspectRatio":e??void 0}]};function z({ratio:e,shape:t=`rectangle`,fit:n,children:o,xstyle:s,className:c,style:l,ref:u,...d}){return(0,I.jsx)(`div`,{ref:u,...a(r(`aspect-ratio`,{shape:t}),i(L.container,R.ratio(e),t===`ellipse`&&L.ellipse,s),c,l),...d,children:(0,I.jsx)(`div`,{"data-astryx-aspect-ratio-override":n,...{0:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d`},8:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k`},4:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d xyz6fim x1m6kvgq`},12:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k xyz6fim x1m6kvgq`},2:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x492jj3`},10:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k x492jj3`},6:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d xyz6fim x1m6kvgq x492jj3`},14:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k xyz6fim x1m6kvgq x492jj3`},1:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x16lv2iq`},9:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k x16lv2iq`},5:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d xyz6fim x1m6kvgq x16lv2iq`},13:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k xyz6fim x1m6kvgq x16lv2iq`},3:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x16lv2iq`},11:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k x16lv2iq`},7:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d xyz6fim x1m6kvgq x16lv2iq`},15:{className:`x10l6tqk x13vifvy x1o0tod xh8yej3 x5yr21d x78zum5 x6s0dn4 xl56j7k xyz6fim x1m6kvgq x16lv2iq`}}[(n===`center`)<<3|(n===`cover`||n===`contain`)<<2|(n===`cover`)<<1|n===`contain`],children:o})})}z.displayName=`AspectRatio`;function B(e,t){if(!e)return t;let n=e.total+t.total;return!e.cost&&!t.cost?{total:n}:{total:n,cost:{usd:(e.cost?.usd??0)+(t.cost?.usd??0),...!e.cost||!t.cost||e.cost.partial||t.cost.partial?{partial:!0}:{}}}}var V={citation:`last`};function H(e,t){if(!t)return[...e];let n=[],r=[],i=[];for(let a of e){let e=t[a.kind];e===`first`?n.push(a):e===`last`?i.push(a):r.push(a)}return[...n,...r,...i]}var U=new Set(E),W=new Set([`user-text`,`user-attachment`,`user-voice`]);function G(e){return W.has(e.kind)}function K(e){return e.kind===`turn-done`}function ae(e,t){e?.kind===`user`?t.stop&&U.has(t.stop.kind)&&(e.stop=t.stop):e&&(t.workedMs!==void 0&&(e.workedMs=t.workedMs,e.endedAt=t.endedAt),t.tokens&&(e.usage=B(e.usage,t.tokens)),t.stop&&(e.stop=t.stop))}function q(e,t){return!e||e.kind!==(t?`user`:`assistant`)?!1:!(e.kind===`user`&&e.stop)}function J(e,t){let n=[];for(let r of e){if(r.kind===`turn-done`&&ae(n.at(-1),r),K(r))continue;let e=G(r),i=n.at(-1);i&&q(i,e)&&!t?.has(r.id)?i.blocks.push(r):n.push({kind:e?`user`:`assistant`,key:r.id,blocks:[r]})}return n}function oe(e){return e.filter(e=>e.kind===`text`).map(e=>e.text).filter(Boolean).join(`
2
-
3
- `)}function se(e){let t=e.elapsedMs===void 0?{}:{elapsedMs:e.elapsedMs};return e.streaming?{phase:`working`,...t}:e.elapsedMs!==void 0&&e.elapsedMs>0?{phase:`worked`,elapsedMs:e.elapsedMs}:e.hasTrace?{phase:`worked`}:null}function ce(e){return e.kind===`tool`&&e.tool.state?.phase===`gate`}function le(e){for(let t=e.length-1;t>=0;--t)if(e[t]?.kind===`tool`)return t;return-1}function ue(e,t,n,r){t.hasTools&&t.index<t.lastToolIndex?e.text.trim()&&n.push({kind:`narration`,id:e.id,text:e.text}):r.push(e)}function de(e,t,n,r){e.kind===`thought`?e.text.trim()&&n.push({kind:`reasoning`,id:e.id,text:e.text}):e.kind===`tool`?n.push({kind:`tool`,id:e.id,block:e}):e.kind===`text`?ue(e,t,n,r):r.push(e)}function fe(e,t){let n=e.filter(e=>!K(e)),r=n.find(ce),i=r?[r]:[],a=n.filter(e=>e!==r),o=le(a),s=o>=0,c=[],l=[];for(let[e,t]of a.entries())de(t,{hasTools:s,index:e,lastToolIndex:o},c,l);return{trace:c,gatedTools:i,body:H(l,t?.bodyKindPlacement??V),hasTrace:c.length>0}}function pe(e){let t=e.at(-1);return t?.kind===`user`?t:void 0}function Y(e,t){let n=e[t-1];return n?.kind===`user`?X(n):e[t]?.key??String(t)}function X(e){return`${e.key}:reply`}function me(e,t,n){let r=e[t+1];return r?.kind===`assistant`&&r.endedAt!==void 0&&r.workedMs!==void 0?r.endedAt-r.workedMs:n(e[t]?.key??``)}function he(e){let t=Y(e.groups,e.index),n=e.streaming&&e.index===e.groups.length-1,r=e.groups[e.index];if(!n)return r?.kind===`assistant`&&r.workedMs!==void 0?{key:t,live:n,workedMs:r.workedMs,endedAt:r.endedAt}:{key:t,live:n};let i=e.groups[e.index-1],a=i?.kind===`user`?e.spans.get(i.key):void 0;return!i||!a?{key:t,live:n}:{key:t,live:n,startedAt:e.timeOf(i.key)+a.pausedMs}}function ge(e){let t=e.state?.phase;return t===`cancel`?p(e.name):(t===`complete`||t===`error`?e.activityPast:e.activity)??p(e.name)}var Z=e(t(),1);function _e(e,t,n,r){let i=t.request??e(`@theorem.gate.approval.use_tool`,{tool:p(n).toLowerCase()});return r?e(`@theorem.gate.approval.title`,{agent:r,request:i}):e(`@theorem.gate.approval.title_no_agent`,{request:i})}var ve={outline:`none`};function ye(e){return typeof e==`string`?e:e==null?``:JSON.stringify(e,null,2)}function Q(e){return(0,I.jsx)(ie,{variant:`bubble`,elevation:`med`,maxWidth:400,children:(0,I.jsxs)(re,{gap:3,children:[(0,I.jsxs)(S,{justify:`between`,align:`start`,gap:3,children:[(0,I.jsx)(s,{type:`large`,weight:`semibold`,tabIndex:-1,"data-autofocus":!0,style:ve,children:e.heading}),e.tag]}),e.children]})})}var be={"read-only":ee,"read-write":u,destructive:T};function $({access:e}){let t=b();return(0,I.jsxs)(S,{gap:1,align:`center`,children:[(0,I.jsx)(o,{icon:be[e],size:`sm`,color:e===`destructive`?`error`:`secondary`}),(0,I.jsx)(s,{type:`supporting`,textWrap:`nowrap`,children:t(`@theorem.tool.access.${e}`)})]})}function xe(e){return(0,I.jsx)(x,{children:(0,I.jsx)(Se,{...e})})}function Se({gate:e,toolName:t,agent:n,input:r,decided:i=null,onDecision:a}){let o=b(),l=ye(e.preparedArguments??r);return(0,I.jsxs)(Q,{heading:_e(o,e,t,n),tag:e.access?(0,I.jsx)($,{access:e.access}):null,children:[e.summary?(0,I.jsx)(s,{color:`secondary`,children:e.summary}):null,l?(0,I.jsx)(C,{defaultIsOpen:!1,trigger:(0,I.jsx)(s,{type:`supporting`,children:o(`@theorem.gate.approval.input`)}),children:(0,I.jsx)(d,{code:l,language:`json`,size:`sm`})}):null,(0,I.jsxs)(S,{gap:2,justify:`end`,children:[(0,I.jsx)(c,{label:o(`@theorem.gate.approval.deny`),variant:`ghost`,isLoading:i===`deny`,isDisabled:i===`allow`,onClick:()=>a?.(`deny`)}),(0,I.jsx)(c,{label:o(`@theorem.gate.approval.approve`),variant:`primary`,isLoading:i===`allow`,isDisabled:i===`deny`,onClick:()=>a?.(`allow`)})]})]})}function Ce({challenge:e}){let t=b();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(s,{color:`secondary`,children:e.message}),e.resource?(0,I.jsx)(s,{type:`supporting`,color:`secondary`,children:t(`@theorem.gate.auth.resource`,{resource:e.resource})}):null,e.requiredScopes?.length?(0,I.jsx)(S,{gap:1,wrap:`wrap`,children:e.requiredScopes.map(e=>(0,I.jsx)(l,{label:e,size:`sm`},e))}):null]})}function we(e){return(0,I.jsx)(x,{children:(0,I.jsx)(Ee,{...e})})}function Te(e,t){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!n)return;function i(i){n&&N(i,{popup:n,slot:e,origin:globalThis.location.origin})&&(r(null),t())}return globalThis.addEventListener(`message`,i),()=>globalThis.removeEventListener(`message`,i)},[n,e,t]),e=>r(globalThis.open(e,`_blank`,`width=600,height=700`))}function Ee({gate:e,toolName:t,onAuthenticated:n,submitted:r=!1}){let i=b(),a=e.authChallenge,{authType:o,slot:c}=a,[l,u]=(0,Z.useState)(``),d=Te(c,(0,Z.useCallback)(()=>n?.(),[n]));function f(){let e=l.trim();e&&(u(``),n?.(e))}return(0,I.jsxs)(Q,{heading:i(`@theorem.gate.auth.title`,{tool:p(t).toLowerCase()}),tag:(0,I.jsx)(s,{type:`supporting`,textWrap:`nowrap`,children:i(`@theorem.gate.tag.${o}`)}),children:[(0,I.jsx)(Ce,{challenge:a}),(0,I.jsx)(De,{authType:o,authUrl:a.authorizationUrl,slot:c,secret:l,submitted:r,onSecretChange:u,onSubmit:f,onOpenSignIn:d})]})}function De(e){let t=b();if(e.submitted)return(0,I.jsx)(y,{variant:`success`,label:t(`@theorem.gate.auth.provided`,{slot:e.slot})});if(e.authType===`oauth2`)return e.authUrl?(0,I.jsx)(S,{justify:`end`,children:(0,I.jsx)(c,{label:t(`@theorem.gate.auth.authorize`),variant:`primary`,onClick:()=>{e.authUrl&&e.onOpenSignIn(e.authUrl)}})}):(0,I.jsx)(s,{color:`secondary`,children:t(`@theorem.gate.auth.no_oauth`)});let n=t(e.authType===`api_key`?`@theorem.gate.auth.api_key`:`@theorem.gate.auth.bearer`),r=t(`@theorem.gate.auth.secret_note`).trim();return(0,I.jsxs)(S,{gap:2,align:`end`,children:[(0,I.jsx)(w,{type:`password`,label:n,...r?{description:r}:{},value:e.secret,placeholder:t(`@theorem.gate.auth.secret_placeholder`,{slot:e.slot}),autoComplete:`off`,onChange:e.onSecretChange,onEnter:e.onSubmit,width:`100%`}),(0,I.jsx)(c,{label:t(`@theorem.gate.auth.submit`),variant:`primary`,isDisabled:!e.secret.trim(),onClick:e.onSubmit})]})}var Oe={en:{"@theorem.gate.auth.secret_note":`Used for this call only. theorem doesn't store it.`,"@astryx.chat.status.sending":`sending`,"@astryx.chat.status.sent":`sent`,"@astryx.chat.status.delivered":`delivered`,"@astryx.chat.status.read":`read`}};export{j as _,he as a,T as b,pe as c,Y as d,ge as f,F as g,P as h,oe as i,X as l,z as m,xe as n,fe as o,se as p,we as r,J as s,Oe as t,me as u,A as v,k as y};
@@ -1,3 +0,0 @@
1
- import{C as e,M as t,h as n,j as r,n as i,p as a,t as o,y as s,z as c}from"./tool-schema-BSpmtaaV.js";import{Bt as l,Gi as u,Ii as d,Ji as f,Li as ee,Ni as te,Nt as ne,Oi as re,Pa as ie,Ra as p,Si as ae,Yi as oe,aa as se,ra as m,wn as h,yn as g}from"./shaped-data-Dp2yZFfd.js";import{a as _,r as v}from"./live-ingress-OuSlQ6q7.js";var ce=[{id:`identity`,profilePath:`identity`,role:`root`,optional:!1,editor:`structural`,label:`Identity`,ownsFields:[`profile.id`,`profile.type`]},{id:`models`,profilePath:`models`,role:`spine`,optional:!1,editor:`structural`,label:`Models`,ownsFields:[`profile.defaultModel`,`profile.allowModelSelect`,`profile.maxSteps`,`providerContinuation`]},{id:`modelBinding`,profilePath:`models.*`,role:`branch`,parent:`models`,optional:!1,editor:`structural`,label:`Model binding`},{id:`decision`,profilePath:`decision`,role:`spine`,optional:!1,editor:`structural`,label:`Decision`,ownsFields:[`inputs`]},{id:`image`,profilePath:`image`,role:`spine`,optional:!1,editor:`structural`,label:`Image`},{id:`speech`,profilePath:`speech`,role:`spine`,optional:!1,editor:`structural`,label:`Speech`},{id:`live`,profilePath:`live`,role:`spine`,optional:!1,editor:`structural`,label:`Live`},{id:`tools`,profilePath:`tools`,role:`spine`,optional:!1,editor:`structural`,label:`Tools`},{id:`toolSpec`,profilePath:`tools.allow`,role:`branch`,parent:`tools`,optional:!0,editor:`structural`,label:`Tool`},{id:`inputs`,profilePath:`inputs`,role:`spine`,optional:!1,editor:`structural`,label:`Inputs`},{id:`outputs`,profilePath:`outputs`,role:`spine`,optional:!0,editor:`structural`,label:`Outputs`},{id:`turnBehaviour`,profilePath:`turnBehaviour`,role:`spine`,optional:!0,editor:`structural`,label:`Turn behaviour`},{id:`guardrails`,profilePath:`guardrails`,role:`spine`,optional:!0,editor:`structural`,label:`Guardrails`},{id:`observability`,profilePath:`observability`,role:`spine`,optional:!0,editor:`structural`,label:`Observability`},{id:`labels`,profilePath:`labels`,role:`spine`,optional:!0,editor:`structural`,label:`Labels`}],le={identity:u,inputs:f(`inputs`).filter(e=>e!==`decision`)},y=ce.map(e=>({...e,profileTypes:le[e.id]??f(e.profilePath)}));function ue(e){return y.find(t=>t.id===e)}function de(e){return e.modelBindings.length>1}function fe(e){return e.modelBindings.some(n=>n.provider!==`local`&&!t(e.providers,n).keySlot)}function b(e,n){let r={provider:n.provider,keySlot:n.keySlot||e.models.key,fallbackKeySlot:n.fallbackKeySlot||e.models.fallbackKey},i=t(e.providers,r);return{...i,given:{keySlot:!!i.keySlot&&!r.keySlot,fallbackKeySlot:!!i.fallbackKeySlot&&!r.fallbackKeySlot}}}function pe(e,t){let n=new Set(e.modelBindings.filter(n=>{let r=b(e,n);return r.keySlot===t||r.fallbackKeySlot===t}).map(e=>e.provider));return e.providers.filter(e=>n.has(e.id))}function me(e){let t=e.efforts.map(({alias:e})=>e.trim()).filter(Boolean);return new Set(t).size>1}function he(e){return e.attachmentsAccept.length>0||e.voiceAccept.length>0}var x=re,S=[{name:`operationTimeoutMs`,label:`Call timeout`,units:`ms`,isTimer:!0},{name:`connectTimeoutMs`,label:`Connect timeout`,units:`ms`,isTimer:!0},{name:`liveStepTimeoutMs`,label:`Live step timeout`,units:`ms`,isTimer:!0},{name:`maxWireRecordBytes`,label:`Wire record`,units:`bytes`,isTimer:!1},{name:`maxWireResponseBytes`,label:`Wire response`,units:`bytes`,isTimer:!1},{name:`maxEventBytes`,label:`Event`,units:`bytes`,isTimer:!1},{name:`maxStepBytes`,label:`Step`,units:`bytes`,isTimer:!1},{name:`maxStepEvents`,label:`Step events`,units:`events`,isTimer:!1},{name:`maxPendingToolCalls`,label:`Tool calls`,units:`calls`,isTimer:!1}],C=2147483647,w={compactMaxTokens:32e3,compactAt:.75,compactKeep:4},T={"continue.instruction":`turnBehaviour`,"canary.bind_note":`guardrails`,"quota.exhausted":`guardrails`,"repair.default_guidance":`outputs`,"egress.default_repair_guidance":`guardrails`,"egress.refusal":`guardrails`};function E(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function D(e){return{key:E(`model`),modelId:`fast`,protocol:`openRouterOpenAi`,provider:`openrouter`,apiId:``,options:{},timeoutMs:null,efforts:[],defaultEffort:``,allowEffortSelect:!1,summaries:null,maxOutputTokens:null,temperature:null,builtInTools:[],...e}}var O=`Studio stub tool — returns a fixed result.`;function k(e){return{key:E(`tool`),toolName:`my_tool`,toolType:`function`,description:O,category:`studio`,access:te[0],permission:ee[0],loadTier:d[0],paths:[`*`],inputJson:o,outputJson:i,...e}}function A(e,t,n){return(!e.description.trim()||e.description===O)&&n?{agentKey:t,description:`Asks ${n} and returns its answer.`}:{agentKey:t}}function j(){return{name:``,kind:`words`,pattern:``,flags:``,words:[]}}function M(){return{key:``,label:``,at:p(ie,()=>`ignore`),patterns:[j()],hint:``}}function N(){let e=h(void 0);return{canaryBindNote:``,detect:p(oe,t=>({...e.detect[t]})),sources:Object.fromEntries(m.map(e=>[e,{theorem:!0,patterns:[],hint:``}])),own:[],quotaEnabled:!1,quotaPerDay:null,quotaMessage:``,allow:{ungiven_images:{hosts:[],fromTools:!0},ungiven_links:{hosts:[],fromTools:!0}},innocentNames:[],blockedReplyOnBlock:``,blockedReplyMaxRetries:null,egressRepairGuidance:``,egressRefusal:``,allowPrivateNetworks:!1,allowedHosts:[],allowedSchemes:[],taintAfterRemoteRead:``,taintRemoteDestination:``}}function P(){let e=_({});return{writeTo:a,destination:a,sampleRate:e.sampleRate,include:{...e.include},scrub:{sensitive:e.scrub.sensitive,injection:e.scrub.injection,canary:e.scrub.canary},retainForDays:null,rotateAfterMiB:null,resourceJson:``}}function F(e){return e.map(([e,t])=>({key:E(`criterion`),label:e,text:t}))}function I(){return{contract:`guardrails.tool_call.v1`,maxStateBytes:null,questions:[{key:E(`question`),id:`verdict`,type:`choice`,instructions:`Given what the user asked for and what the call would do, should it run?`,criteria:F([[`allow`,`Safe, and what the user asked for.`],[`flag`,`Probably fine, but unusual or sensitive enough for a person to look first.`],[`block`,`Harmful, or clearly beyond what the user asked for.`]])},{key:E(`question`),id:`risk`,type:`score`,instructions:`How much harm would this call do if it were wrong?`,criteria:F([[``,`Low: reversible, and affects only the user.`],[``,`High: hard to undo, or affects other people or money.`]])}],images:[]}}var L=JSON.stringify({context:`The user asked the agent to tidy up old screenshots on their desktop.`,tool_call:{name:`delete_files`,path:`~/Documents`,recursive:!0},outcome:`Would delete 1,284 files, including tax_return_2025.pdf.`},null,2),R=JSON.stringify(`The user asked to tidy screenshots. The proposed call recursively deletes 1,284 files, including a tax return.`),ge=`To clear your desktop, select the screenshots and move them to the Trash. Empty the Trash to delete them for good.(Screen captures save to the desktop by default. You can change where they go in the Screenshot app's Options menu.(Press Command-Shift-5 to record the screen or capture a window. Recordings are saved as movie files next to your screenshots.(Stacks group desktop files by kind, date or tag, so a cluttered desktop folds into a few piles you can open one at a time.(Deleted files stay in the Trash for 30 days. Drag a file out of the Trash to put it back where it was.(When your disk is almost full, open Storage settings and review the largest files. Old downloads and installers are safe to remove.(Offloading unused apps frees space and keeps their documents. Reinstalling an app brings its data back.(Photos you have backed up can be optimised so the originals live in the cloud and smaller copies stay on the device.(Your plan renews on the same date each month. You can see the next charge under Billing, then Upcoming invoices.(To get a refund, open the invoice and choose Request refund. Charges from the last 14 days are refunded in full.(Update your card under Billing, then Payment methods. The new card is used for the next renewal, not for past invoices.(Annual plans cost two months less than paying monthly. Switching mid-term credits the unused months to the new plan.(Invoices are emailed as PDFs and list your company name and tax number. Edit those details before the invoice is issued.(Turn on two-step verification under Security. You will be asked for a code from your authenticator app each time you sign in on a new device.(If you forget your password, choose Forgot password on the sign-in page. The reset link expires after one hour.(Review signed-in devices under Security and sign out any you don't recognise. This ends their sessions immediately.(Passkeys replace your password with your fingerprint or face. Create one under Security, then Passkeys.(To close your account, export your data first. Closing deletes your workspace after a 30-day grace period.(Share a folder by choosing Share, then entering an email address. Viewers can read; editors can change and delete.(Public links work for anyone who has them. Set an expiry date, or turn the link off to stop sharing at once.(Transfer ownership of a folder before you leave a team, or its contents will be archived with your account.(Lisbon has mild, wet winters and warm, dry summers. Expect highs near 28 °C in August.(The best months for the Algarve coast are May, June and September, when the beaches are warm and the crowds are thin.(Trams in Lisbon climb the steep hills of Alfama and Graça. Line 28 is the famous one, and the busiest.(For a crisp pizza base, preheat the oven and the baking tray together at the highest setting for at least thirty minutes.(Rest steak for five minutes after cooking so the juices settle back into the meat instead of running onto the board.`.split(`(`).join(`
2
-
3
- `),_e=`How do I delete every screenshot on my desktop?`;function ve(e,t=`choice`){let n=q(`question`,e.decision.questions.map(e=>e.id),e=>`question_${e}`);return{key:E(`question`),id:n,type:t,instructions:``,criteria:B(t)}}function ye(e,t,n){let r=t.replace(/\.[^.]*$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``)||`image`,i=q(r,e.decision.images.map(e=>e.name),e=>`${r}_${e}`);return{key:E(`image`),name:i,...n}}function be(){return{key:E(`option`),name:``,label:``,isShownInChat:!1,choices:[]}}function xe(e,t){return e.map(e=>t.find(t=>t.value===e)??{key:E(`choice`),value:e,description:``})}function z(){return{key:E(`criterion`),label:``,text:``}}function B(e){return e===`noul`||e===`box`?[]:F(e===`choice`?[[`yes`,``],[`no`,``]]:[[``,``],[``,``]])}function Se(){return{identity:{agentId:``,profileType:``,handle:``,system:``,options:[]},included:[`observability`,`labels`],models:{defaultModel:``,allowModelSelect:!1,maxSteps:null,key:``},modelBindings:[],providers:[...e],tools:{t2Loader:``,parallel:!1},toolSpecs:[],inputs:{text:!0,attachmentsAccept:[],voiceAccept:[],maxFiles:null,maxBytes:null,maxTurnBytes:null,limitsByMime:{},contextFrom:[],contextMaxChars:null},outputs:{mode:`text`,schemaId:``,schemaJson:``,streamMode:``,streamThoughts:!0,validationEnabled:!1,maxRetries:null,itemRules:{},repairGuidance:``},turnBehaviour:{resumeEnabled:!1,allowContinue:[],autoContinue:[],maxContinues:null,continueInstruction:``,allowSteering:l({type:`text`}),atStepLimit:`stop`},guardrails:N(),observability:P(),image:{aspectRatio:``,resolution:``,mimeType:``,quality:``,background:``,n:null,seed:null,outputCompression:null,includeText:!1,references:[]},speech:{voice:``,style:``,speed:null,format:``},live:{ingressAudio:v(`audio`),ingressVideo:v(`video`),ingressText:v(`text`),voice:``,sessionResumption:!1,greeting:``,resumedPrompt:``,resumedAfterMs:null,contextCompression:!1,compressionTriggerTokens:null,compressionTargetTokens:null,transcriptionInput:!1,transcriptionOutput:!1,vadActivityHandling:``,vadStartSensitivity:``,vadEndSensitivity:``,vadPrefixPaddingMs:null,vadSilenceDurationMs:null},decision:I(),labels:{}}}var Ce=new Set([`guardrails`]);function V(e,t){return e.profileTypes.includes(t)&&!(t===`decision`&&Ce.has(e.id))}function H(e){let t=e.identity.profileType;if(!t)return[`identity`];let n=new Set(e.included);return y.filter(e=>e.role!==`branch`&&V(e,t)&&(!e.optional||n.has(e.id))).map(e=>e.id)}function U(e,t){let n=e.identity.profileType;return n!==``&&f(t).includes(n)}function we(e,t,n){if((!n||n.includes(t.key))&&t.loadTier===`T2`&&U(e,`tools.t2Loader`)&&!e.tools.t2Loader.trim())return`No T2 loader is set under Tools, so this tool never loads.`}function Te(e){return U(e,`identity.system`)&&se(e.guardrails.detect,`canary_leak`)}function Ee(e){let t=e.identity.profileType;return t!==``&&ne.includes(t)}function W(e){let t=e.identity.profileType;return t?y.filter(n=>n.role===`spine`&&n.optional&&V(n,t)&&!e.included.includes(n.id)).map(e=>e.id):[]}function De(e){return{...e,attachmentsAccept:e.attachmentsAccept.filter(e=>g(ae,e)),voiceAccept:[]}}function Oe(e){return{...e,text:!1,attachmentsAccept:[],voiceAccept:e.voiceAccept.length?e.voiceAccept:[`audio/*`]}}function ke(e,t,n){let r=e.modelBindings.find(e=>e.key===t);return r?{...e,models:n.modelId!==void 0&&e.models.defaultModel===r.modelId?{...e.models,defaultModel:n.modelId}:e.models,modelBindings:e.modelBindings.map(e=>e.key===t?{...e,...n}:e)}:e}function G(e,t){if(t.some(t=>t.modelId===e))return e;let[n,...r]=t;return n&&!r.length?n.modelId:``}function Ae(e,t){if(!e.modelBindings.find(e=>e.key===t))return e;let n=e.modelBindings.filter(e=>e.key!==t);return{...e,models:{...e.models,defaultModel:G(e.models.defaultModel,n)},modelBindings:n}}function K(e,t){let n=e.identity.profileType,r=n&&n!==`host`?n:`text`,i=e.modelBindings.map(e=>e.modelId),a=s(r,t),o=q(a.modelId,i,e=>`${a.modelId}${e}`);return D({...a,modelId:o})}function je(e){return k({toolName:q(`my_tool`,e.toolSpecs.map(e=>e.toolName),e=>`my_tool_${e}`)})}function q(e,t,n){let r=new Set(t),i=e;for(let e=2;r.has(i);e++)i=n(e);return i}function Me(e,t,i){if(t===`host`)return{...e,identity:{...e.identity,profileType:t}};let a=e.modelBindings.filter(n=>{let a=r(e.providers,t,n),o=e.providers.find(e=>e.id===n.provider);return c(o,t,n.protocol)&&!Fe(i,t,a)}),o={...e,identity:{...e.identity,profileType:t},modelBindings:a},s=a.length?a:[K(o,i?.start)],l=!e.models.key&&fe({...o,modelBindings:s}),u=t===`speech`&&!e.speech.voice.trim()&&s.some(i=>n(r(e.providers,t,i)));return{...o,inputs:t===`image`?De(e.inputs):t===`transcription`?Oe(e.inputs):e.inputs,...u?{speech:{...e.speech,voice:Ne}}:{},models:{...e.models,defaultModel:G(e.models.defaultModel,s),key:l?Ie:e.models.key},modelBindings:s}}var Ne=`Kore`,Pe=[`text`,`image`,`speech`,`transcription`,`live`,`decision`];function Fe(e,t,n){if(!e)return!1;let r=t=>e.models(t,n.definition).some(e=>e.id===n.apiId.trim());return!r(t)&&Pe.some(e=>e!==t&&r(e))}var Ie=`slot_a`;function Le(e,t){return W(e).includes(t)?{...e,included:[...e.included,t]}:e}function Re(e,t){return{...e,included:e.included.filter(e=>e!==t)}}function J(e){return`modelBinding:${e}`}var Y=`toolSpec:`;function X(e){return`${Y}${e}`}function Z(e){return e.startsWith(Y)?e.slice(9):void 0}var Q=`provider:`;function ze(e){return`${Q}${e}`}function Be(e){return e.startsWith(Q)?e.slice(9):void 0}var Ve=new Map(y.map(e=>[e.id,e.label]));function He(e){return Ve.get(e)??e}function Ue(e,t){let[n,r]=t.split(`:`,2);if(n===`modelBinding`&&r!==void 0)return e.modelBindings.some(e=>e.key===r)?{facet:n,key:r}:void 0;let i=Z(t);if(i!==void 0)return e.toolSpecs.some(e=>e.key===i)?{facet:`toolSpec`,key:i}:void 0;let a=H(e);if(r===void 0&&a.includes(t))return{facet:t}}function We(e,t){return t===`models`?e.modelBindings.map(e=>({id:J(e.key),ref:{facet:`modelBinding`,key:e.key},label:e.modelId.trim()||`Unnamed model`,children:[]})):t===`tools`?$(e.toolSpecs):[]}function $(e){return e.map(e=>({id:X(e.key),ref:{facet:`toolSpec`,key:e.key},label:e.toolName.trim()||`Unnamed tool`,children:[]}))}function Ge(e){let t=H(e).filter(e=>e!==`identity`).map(t=>({id:t,ref:{facet:t},label:He(t),children:We(e,t)}));return{id:`identity`,ref:{facet:`identity`},label:e.identity.agentId.trim()||`Unnamed agent`,children:t}}export{B as A,Te as B,H as C,W as D,q as E,be as F,b as G,Me as H,M as I,he as J,me as K,j as L,ye as M,ve as N,Le as O,K as P,je as R,U as S,Re as T,Ee as U,Ae as V,ke as W,y as X,pe as Y,ue as Z,C as _,Ge as a,D as b,$ as c,_e as d,ge as f,x as g,S as h,Ue as i,z as j,we as k,w as l,T as m,Be as n,Z as o,R as p,de as q,ze as r,X as s,J as t,L as u,A as v,E as w,k as x,Se as y,xe as z};
@@ -1 +0,0 @@
1
- import{Ri as e}from"./shaped-data-Dp2yZFfd.js";var t=e.filter(e=>e!==`builtin`),n=`Tool type must be ${t.join(`, `).replace(/, ([^,]+)$/,`, or $1`)}.`;export{n,t};