@theoremjs/studio 0.3.5-next.933.gfc0e83b → 0.3.5-next.935.ga3dc485

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-CFmWCLNs.js → BottomSheet-BeZNOmva.js} +1 -1
  3. package/page/assets/{ConsoleFrame-sWIg1UlI.js → ConsoleFrame-Durgrfa8.js} +1 -1
  4. package/page/assets/{ContextMenu-kJvPbe2l.js → ContextMenu-CdZPGyrH.js} +2 -2
  5. package/page/assets/{DateInput-DFW6ZGmz.js → DateInput-DxxKNbFy.js} +1 -1
  6. package/page/assets/{DropdownMenu-kC1ynF9P.js → DropdownMenu-CLdHjD_O.js} +2 -2
  7. package/page/assets/{Link-cEUGqR4E.js → Link-B8qtW9Me.js} +1 -1
  8. package/page/assets/{MenuBottomSheet-CXQHH9x8.js → MenuBottomSheet-BJz5pzDE.js} +1 -1
  9. package/page/assets/{PowerSearchBottomSheet-DT2J58Od.js → PowerSearchBottomSheet-xO313kak.js} +1 -1
  10. package/page/assets/{RankedBars-DBJRNmPe.js → RankedBars-D0yn-ri0.js} +1 -1
  11. package/page/assets/{SchemaFields-Cjm83Nt8.js → SchemaFields-Dvwzr5ZO.js} +1 -1
  12. package/page/assets/{ShapedData-DYOCaGlk.js → ShapedData-DYRlNRy_.js} +1 -1
  13. package/page/assets/{TokenizerBottomSheet-BU9l3CaI.js → TokenizerBottomSheet-DhPibEHt.js} +1 -1
  14. package/page/assets/{ToolResultCharts-CSyUS1-z.js → ToolResultCharts-BGJbKsDT.js} +1 -1
  15. package/page/assets/{Toolbar-BmuypKxW.js → Toolbar-DVp0Jb7c.js} +1 -1
  16. package/page/assets/{TraceInspector-CPWC9lS8.js → TraceInspector-Cs8SNp3b.js} +2 -2
  17. package/page/assets/{TraceOverview-DKAyP6oW.js → TraceOverview-BN5UDJe8.js} +1 -1
  18. package/page/assets/{_virtual_studio-type-sources-C6e3ZJtP.js → _virtual_studio-type-sources-ekRa45Mf.js} +49 -19
  19. package/page/assets/{browser-connection-DzO00xRy.js → browser-connection-BWOEEs03.js} +1 -1
  20. package/page/assets/browser-engine-BxtG9nJ-.js +16 -0
  21. package/page/assets/{browser-transport-BPAKt_cc.js → browser-transport-rFxtbMn0.js} +2 -2
  22. package/page/assets/{compile-oGEpwgkY.js → compile-C4Q50p5E.js} +2 -2
  23. package/page/assets/{encode-files-Bn5i8t9U.js → encode-files-MPtLTYyk.js} +1 -1
  24. package/page/assets/{export-agent-BcjOjktu.js → export-agent-CEB-vrfl.js} +1 -1
  25. package/page/assets/{getRadiusAndStrokeWidthFromDot-CuVjZhu8.js → getRadiusAndStrokeWidthFromDot-Ck-kRNvB.js} +1 -1
  26. package/page/assets/{guardrail-health-DzeSNMix.js → guardrail-health-DMd_p8rH.js} +2 -2
  27. package/page/assets/{guardrail-tester-BQ7BHdiW.js → guardrail-tester-DAis9Gsd.js} +1 -1
  28. package/page/assets/{index-hSIwfi4j.js → index-C6pyNvXU.js} +16 -16
  29. package/page/assets/{json-code-D6l475BW.js → json-code-DqpAF4hg.js} +1 -1
  30. package/page/assets/{labels-provider-D_7O3BSI.js → labels-provider-BOmB5WmP.js} +1 -1
  31. package/page/assets/{live-messages-DvMnxecr.js → live-messages-DekE0UkG.js} +1 -1
  32. package/page/assets/{prompt-row-OoetsUr1.js → prompt-row-BHTY1SfP.js} +1 -1
  33. package/page/assets/reader-BZ-mDuss.js +5 -0
  34. package/page/assets/{registry-Bjkfo9zx.js → registry-CqweoU_Q.js} +1 -1
  35. package/page/assets/{schema-DI2QKpYi.js → schema-Do4wX6Sr.js} +2 -2
  36. package/page/assets/{shaped-data-BxGL5na3.js → shaped-data-BxDmEUJe.js} +17 -17
  37. package/page/assets/{stub-CY0cuGPg.js → stub-CUHiDLLw.js} +1 -1
  38. package/page/assets/{studio-code-pane-CXo-J0fe.js → studio-code-pane-i0bu-gwb.js} +3 -3
  39. package/page/assets/{studio-console-BA7bGrU2.js → studio-console-Cn5vtx-w.js} +1 -1
  40. package/page/assets/{studio-decision-C1U7AGDn.js → studio-decision-CwWJLFnm.js} +1 -1
  41. package/page/assets/{studio-embedding-DS7pVE5l.js → studio-embedding-Dya8zKKM.js} +1 -1
  42. package/page/assets/{studio-host-console-C3uC7P_C.js → studio-host-console-BbnDPTbG.js} +2 -2
  43. package/page/assets/studio-live-uS2TgNK2.js +5 -0
  44. package/page/assets/{studio-map-CqLgnQNk.js → studio-map-Bqv8T8BY.js} +1 -1
  45. package/page/assets/{studio-media-CmbCThcX.js → studio-media-C6h3z2kJ.js} +1 -1
  46. package/page/assets/{studio-trace-replay-R8IQNP3s.js → studio-trace-replay-B-WZNREk.js} +1 -1
  47. package/page/assets/{studio-type-checker-BQAMVf_u.js → studio-type-checker-2_B50AHd.js} +1 -1
  48. package/page/assets/{tool-schema-Bfe2TkD-.js → tool-schema-CnrGGkcr.js} +1 -1
  49. package/page/assets/{trace-record--OEcC7x1.js → trace-record-CRYVqBZW.js} +1 -1
  50. package/page/assets/{tree-CMulctlY.js → tree-CZVr90dg.js} +2 -2
  51. package/page/assets/{turn-client-sADYJHV9.js → turn-client-C_-rA6KF.js} +2 -2
  52. package/page/assets/types-DfwVnkMI.js +1 -0
  53. package/page/assets/{use-one-call-CJqcEomh.js → use-one-call-By1S3qBT.js} +1 -1
  54. package/page/assets/{useDismissSearchOnTouchDrag-Cjqhp30f.js → useDismissSearchOnTouchDrag-L_mBp0Dm.js} +1 -1
  55. package/page/assets/{workspace-BrQUhBOf.js → workspace-ChRm7M3S.js} +1 -1
  56. package/page/index.html +21 -21
  57. package/page/assets/browser-engine-BciA9NL-.js +0 -16
  58. package/page/assets/reader-Bz6rc3qr.js +0 -5
  59. package/page/assets/studio-live-DaQMlVSh.js +0 -5
  60. package/page/assets/types-7mVE39E8.js +0 -1
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,B as r,F as i,G as a,H as o,I as s,J as c,K as l,L as ee,M as te,N as ne,P as re,Q as ie,R as ae,U as oe,V as se,W as ce,X as le,Y as ue,Z as de,a as u,at as fe,ct as pe,dt as me,et as he,ht as ge,i as d,it as _e,j as ve,lt as ye,mt as f,n as p,nt as be,ot as xe,q as Se,r as m,rt as Ce,st as we,tt as Te,ut as Ee,w as De,z as Oe}from"./schemas-D7cgkv3L.js";import{A as ke,C as Ae,D as je,S as Me,T as Ne,a as Pe,c as h,en as Fe,j as Ie,k as Le,qt as Re,so as g,tn as ze,w as Be}from"./shaped-data-BxGL5na3.js";var Ve=e({endsWith:()=>ve,gt:()=>te,gte:()=>ne,includes:()=>re,length:()=>Oe,lowercase:()=>r,lt:()=>se,lte:()=>o,maxLength:()=>oe,maxSize:()=>ce,mime:()=>a,minLength:()=>l,minSize:()=>Se,multipleOf:()=>c,negative:()=>ue,nonnegative:()=>le,nonpositive:()=>de,normalize:()=>ie,overwrite:()=>t,positive:()=>he,properties:()=>Te,property:()=>be,regex:()=>Ce,size:()=>_e,slugify:()=>fe,startsWith:()=>xe,toLowerCase:()=>we,toUpperCase:()=>pe,trim:()=>ye,uppercase:()=>Ee}),He=e({ZodISODate:()=>p,ZodISODateTime:()=>m,ZodISODuration:()=>d,ZodISOTime:()=>u,date:()=>We,datetime:()=>Ue,duration:()=>Ke,time:()=>Ge});function Ue(e){return s(m,e)}function We(e){return i(p,e)}function Ge(e){return ae(u,e)}function Ke(e){return ee(d,e)}var _={...De,...Ve,iso:He},qe=new Set(`$schema.$ref.$defs.definitions.$id.id.$comment.$anchor.$vocabulary.$dynamicRef.$dynamicAnchor.type.enum.const.anyOf.oneOf.allOf.not.properties.required.additionalProperties.patternProperties.propertyNames.minProperties.maxProperties.items.prefixItems.additionalItems.minItems.maxItems.uniqueItems.contains.minContains.maxContains.minLength.maxLength.pattern.format.minimum.maximum.exclusiveMinimum.exclusiveMaximum.multipleOf.description.default.contentEncoding.contentMediaType.contentSchema.unevaluatedItems.unevaluatedProperties.if.then.else.dependentSchemas.dependentRequired.nullable.readOnly`.split(`.`));function Je(e,t){let n=e.$schema;return n===`https://json-schema.org/draft/2020-12/schema`?`draft-2020-12`:n===`http://json-schema.org/draft-07/schema#`?`draft-7`:n===`http://json-schema.org/draft-04/schema#`?`draft-4`:t??`draft-2020-12`}function v(e,t){return e.map((e,n)=>n<t?e:e.optional())}function Ye(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Xe(e,t){if(!e.startsWith(`#`))throw Error(`External $ref is not supported, only local refs (#/...) are allowed`);let n=e.slice(1).split(`/`).filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version===`draft-2020-12`?`$defs`:`definitions`;if(n[0]===r){let r=n[1]===void 0?void 0:Ye(n[1]);if(!r||!t.defs[r])throw Error(`Reference not found: ${e}`);return t.defs[r]}throw Error(`Reference not found: ${e}`)}function Ze(e,t){return _.transform(e=>e).check(n=>{let r=n.value;if(typeof r!=`object`||!r||Array.isArray(r))return;let i=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&i.length<t.minProperties&&n.issues.push({origin:`object`,code:`too_small`,minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&n.issues.push({origin:`object`,code:`too_big`,maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let e of i){let r=t.keySchema.safeParse(e);r.success||n.issues.push({code:`invalid_key`,origin:`record`,issues:r.error.issues,input:e,path:[e],continue:!0})}}).pipe(e)}function y(e,t){if(e===null)return`z`;let n=typeof e;if(n!==`object`){if(n===`number`&&Number.isNaN(e))return null;let t=String(e);return`${n[0]}${t.length}:${t}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let n=[];for(let r of e){let e=y(r,t);if(e===null)return null;n.push(e)}return`a${n.length}:[${n.join(`,`)}]`}let n=Object.keys(e).sort(),r=[];for(let i of n){let n=y(e[i],t);if(n===null)return null;r.push(`${i.length}:${i}=${n}`)}return`o${r.length}:{${r.join(`,`)}}`}finally{t.delete(e)}}var Qe=new Set([`items`,`prefixItems`,`additionalItems`,`additionalProperties`,`contains`,`propertyNames`,`not`,`if`,`then`,`else`,`allOf`,`anyOf`,`oneOf`,`unevaluatedItems`,`unevaluatedProperties`,`contentSchema`]),$e=new Set([`properties`,`patternProperties`,`dependentSchemas`,`dependencies`,`$defs`,`definitions`]);function b(e){return typeof e!=`object`||!e?!1:Array.isArray(e)?e.some(b):typeof e.$ref==`string`||Object.entries(e).some(([e,t])=>Qe.has(e)?b(t):!$e.has(e)||typeof t!=`object`||!t?!1:Object.values(t).some(b))}function x(e){return e===1?`element`:`elements`}function et(e,t){return _.transform(e=>e).check(e=>{let n=e.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let t=new Map;for(let r=0;r<n.length;r++){let i=y(n[r],new Set);if(i===null)continue;let a=t.get(i);a===void 0?t.set(i,r):e.issues.push({code:`custom`,message:`Array items must be unique: element at index ${r} duplicates the one at index ${a}`,input:n,path:[r],continue:!0})}}if(t.containsSchema){let r=t.minContains??1,i=t.maxContains===void 0?1/0:t.maxContains+1,a=0;for(let e of n)if(t.containsSchema.safeParse(e).success&&++a>=i)break;a<r&&e.issues.push({code:`custom`,message:`Array must contain at least ${r} matching ${x(r)}; found ${a}`,input:n,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&e.issues.push({code:`custom`,message:`Array must contain at most ${t.maxContains} matching ${x(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function S(e,t){if(e!==!1)return e===void 0||e===!0?_.any():w(e,t)}var tt=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function C(e,t){if(e.not!==void 0){if(typeof e.not==`object`&&Object.keys(e.not).length===0)return _.never();throw Error(`not is not supported in Zod (except { not: {} } for never)`)}if(e.unevaluatedItems!==void 0)throw Error(`unevaluatedItems is not supported`);if(e.unevaluatedProperties!==void 0)throw Error(`unevaluatedProperties is not supported`);if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error(`Conditional schemas (if/then/else) are not supported`);if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error(`dependentSchemas and dependentRequired are not supported`);if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return _.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let r=w(Xe(n,t),t);return t.refs.set(n,r),t.processing.delete(n),r}if(e.enum!==void 0){let n=e.enum;if(t.version===`openapi-3.0`&&e.nullable===!0&&n.length===1&&n[0]===null)return _.null();if(n.length===0)return _.never();if(n.length===1)return _.literal(n[0]);if(n.every(e=>typeof e==`string`))return _.enum(n);let r=n.map(e=>_.literal(e));return r.length<2?r[0]:_.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return _.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(n=>C({...e,type:n},t));return r.length===0?_.never():r.length===1?r[0]:_.union(r)}if(!n)return _.any();let r;switch(n){case`string`:{let t=_.string();if(e.format){let n=e.format;n===`email`?t=t.check(_.email()):n===`uri`||n===`uri-reference`?t=t.check(_.url()):n===`uuid`||n===`guid`?t=t.check(_.uuid()):n===`date-time`?t=t.check(_.iso.datetime({offset:!0})):n===`date`?t=t.check(_.iso.date()):n===`time`?t=t.check(_.regex(tt)):n===`duration`?t=t.check(_.iso.duration()):n===`hostname`?t=t.check(_.hostname()):n===`ipv4`?t=t.check(_.ipv4()):n===`ipv6`?t=t.check(_.ipv6()):n===`mac`?t=t.check(_.mac()):n===`cidr`?t=t.check(_.cidrv4()):n===`cidr-v6`?t=t.check(_.cidrv6()):n===`base64`?t=t.check(_.base64()):n===`base64url`?t=t.check(_.base64url()):n===`e164`?t=t.check(_.e164()):n===`credit_card`?t=t.check(_.creditCard()):n===`iban`?t=t.check(_.iban()):n===`jwt`?t=t.check(_.jwt()):n===`emoji`?t=t.check(_.emoji()):n===`nanoid`?t=t.check(_.nanoid()):n===`cuid`?t=t.check(_.cuid()):n===`cuid2`?t=t.check(_.cuid2()):n===`ulid`?t=t.check(_.ulid()):n===`xid`?t=t.check(_.xid()):n===`ksuid`&&(t=t.check(_.ksuid()))}typeof e.minLength==`number`&&(t=t.min(e.minLength)),typeof e.maxLength==`number`&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),r=t;break}case`number`:case`integer`:{let t=n===`integer`?_.number().int():_.number();typeof e.minimum==`number`&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum==`number`&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum==`number`?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum==`number`&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum==`number`?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum==`number`&&(t=t.lt(e.maximum)),typeof e.multipleOf==`number`&&(t=t.multipleOf(e.multipleOf)),r=t;break}case`boolean`:r=_.boolean();break;case`null`:r=_.null();break;case`object`:{let n={},i=e.properties||{},a=new Set(e.required||[]),o=typeof e.additionalProperties==`object`?w(e.additionalProperties,t):void 0;for(let[e,r]of Object.entries(i)){let i=w(r,t);f(n,e,a.has(e)?i:i.optional())}if(e.patternProperties){let i=e.patternProperties,a=Object.keys(i),o=[];for(let e of a){let n=w(i[e],t),r=_.string().regex(new RegExp(e));o.push(_.looseRecord(r,n))}let s=[];if(Object.keys(n).length>0&&s.push(_.object(n).passthrough()),s.push(...o),s.length===0)r=_.object({}).passthrough();else if(s.length===1)r=s[0];else{let e=_.intersection(s[0],s[1]);for(let t=2;t<s.length;t++)e=_.intersection(e,s[t]);r=e}if(e.additionalProperties===!1){let e=Object.keys(n),t=a.map(e=>new RegExp(e)),i=r;r=r.check(n=>{if(!ge(n.value))return;let r=[];for(let i of Object.keys(n.value))e.includes(i)||t.some(e=>e.test(i))||r.push(i);r.length&&n.issues.push({code:`unrecognized_keys`,keys:r,input:n.value,inst:i})})}}else{let t=_.object(n);r=e.additionalProperties===!1?t.strict():o?t.catchall(o):t.passthrough()}let s=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties==`number`?e.minProperties:void 0,l=typeof e.maxProperties==`number`?e.maxProperties:void 0;if(s||c!==void 0||l!==void 0){let n;s&&(n=w(typeof e.propertyNames==`object`&&e.propertyNames.type===void 0?{type:`string`,...e.propertyNames}:e.propertyNames,t)),r=Ze(r,{keySchema:n,minProperties:c,maxProperties:l})}break}case`array`:{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems==`number`?e.minItems:0,o=v(n.map(e=>w(e,t)),a),s=Array.isArray(i)?void 0:S(i,t),c=_.tuple(o);r=s?c.rest(s):c,typeof e.minItems==`number`&&(r=r.check(_.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(_.maxLength(e.maxItems)))}else if(Array.isArray(i)){let n=typeof e.minItems==`number`?e.minItems:0,a=v(i.map(e=>w(e,t)),n),o=S(e.additionalItems,t),s=_.tuple(a);r=o?s.rest(o):s,typeof e.minItems==`number`&&(r=r.check(_.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(_.maxLength(e.maxItems)))}else if(i!==void 0){let n=w(i,t),a=_.array(n);typeof e.minItems==`number`&&(a=a.min(e.minItems)),typeof e.maxItems==`number`&&(a=a.max(e.maxItems)),r=a}else r=_.array(_.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=et(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains===void 0?void 0:w(e.contains,t),minContains:typeof e.minContains==`number`?e.minContains:void 0,maxContains:typeof e.maxContains==`number`?e.maxContains:void 0}));break}default:throw Error(`Unsupported type: ${n}`)}return r}function w(e,t){if(typeof e==`boolean`)return e?_.any():_.never();let n=C(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let i=e.anyOf.map(e=>w(e,t)),a=_.union(i);n=r?_.intersection(n,a):a}if(e.oneOf&&Array.isArray(e.oneOf)){let i=e.oneOf.map(e=>w(e,t)),a=_.xor(i);n=r?_.intersection(n,a):a}if(e.allOf&&Array.isArray(e.allOf)){if(e.allOf.length===0)n=r?n:_.any();else{let i=r?n:w(e.allOf[0],t),a=+!r;for(let n=a;n<e.allOf.length;n++)i=_.intersection(i,w(e.allOf[n],t));n=i}}e.nullable===!0&&t.version===`openapi-3.0`&&(n=_.nullable(n)),e.readOnly===!0&&(n=_.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let i={};for(let t of[`$id`,`id`,`$comment`,`$anchor`,`$vocabulary`,`$dynamicRef`,`$dynamicAnchor`])t in e&&(i[t]=e[t]);for(let t of[`contentEncoding`,`contentMediaType`,`contentSchema`])t in e&&(i[t]=e[t]);if(e.type===`object`&&e.$ref===void 0){e.propertyNames!==void 0&&!b(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(let t of[`minProperties`,`maxProperties`])e[t]!==void 0&&(i[t]=e[t])}if(e.type===`array`&&e.$ref===void 0){e.contains!==void 0&&!b(e.contains)&&(i.contains=e.contains);for(let t of[`uniqueItems`,`minContains`,`maxContains`])e[t]!==void 0&&(i[t]=e[t])}for(let t of Object.keys(e))qe.has(t)||f(i,t,e[t]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function nt(e,t){if(typeof e==`boolean`)return e?_.any():_.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw Error(`fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas`)}let r={version:Je(n,t?.defaultTarget),defs:n.$defs||n.definitions||{},refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??me};return w(n,r)}var rt=`https://generativelanguage.googleapis.com/v1beta/models`,it=`Zephyr.Puck.Charon.Kore.Fenrir.Leda.Orus.Aoede.Callirrhoe.Autonoe.Enceladus.Iapetus.Umbriel.Algieba.Despina.Erinome.Algenib.Rasalgethi.Laomedeia.Achernar.Alnilam.Schedar.Gacrux.Pulcherrima.Achird.Zubenelgenubi.Vindemiatrix.Sadachbia.Sadaltager.Sulafat`.split(`.`),at=[`minimal`,`low`,`medium`,`high`],ot=[`pcm`],st=[`1:1`,`3:2`,`2:3`,`3:4`,`4:3`,`4:5`,`5:4`,`9:16`,`16:9`,`21:9`],ct=[`1K`,`2K`,`4K`],lt=[`image/png`,`image/jpeg`],T=[{type:`builtin`,name:`googleSearch`,description:`Google Search grounding`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`},{type:`builtin`,name:`googleMaps`,description:`Google Maps grounding`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`,conflictsWith:[`googleSearch`,`urlContext`]},{type:`builtin`,name:`urlContext`,description:`Fetch URL context`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`},{type:`builtin`,name:`codeExecution`,description:`Google code execution`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`}],ut=[{type:`builtin`,name:`webSearch`,description:`OpenRouter web search`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`}],E=`local`;function dt(e,t){return!t&&e===`local`}function D(e=`http://localhost:11434`){return`${e.replace(/\/$/,``)}/v1`}var O=[{id:`gemini`,definition:`gemini`},{id:`openrouter`,definition:`openrouter`},{id:E,definition:`local`,connection:{baseUrl:D()}},{id:`typesafe`,definition:`typesafe`}],k={gemini:{provider:Le,factory:`geminiProvider`},openrouter:{provider:Ae,factory:`openRouterProvider`},local:{provider:je,factory:`localProvider`},typesafe:{provider:Me,factory:`typesafeProvider`}};function A(e){return e===void 0?void 0:k[e]?.provider}function ft(){return Object.keys(k)}function pt(e){return Object.keys(k).find(t=>k[t]?.factory===e)}function mt(e){return k[e]?.factory}function j(e,t){return e.find(e=>e.id===t)?.definition}function ht(e){return{id:e.id,...e.connection===void 0?{}:{connection:e.connection},...e.keySlot===void 0?{}:{keySlot:e.keySlot},...e.fallbackKeySlot===void 0?{}:{fallbackKeySlot:e.fallbackKeySlot}}}function M(e,t,n=A(t.definition),r=`register`){if(!n)throw Error(`The studio does not hold the provider definition '${t.definition}'.`);return e[r](n,ht(t))}function gt(e){let t=A(e);if(!t)return;if(!t.connection)return[];let r=n(t.connection,{io:`input`});return Object.entries(r.properties??{}).map(([e,t])=>({name:e,required:r.required?.includes(e)??!1,url:t.format===`uri`,...t.description?{description:t.description}:{}}))}function _t(e){let t=A(e);return t===void 0||t.key!==void 0}function N(e){let t=[];e.id.trim()||t.push({field:`id`,message:`Provider id is required.`});let n=A(e.definition),r=e.connection??{},i=n?.connection?.safeParse(r);for(let e of i?.error?.issues??[]){if(e.code===`unrecognized_keys`){for(let n of e.keys)t.push({field:`connection.${n}`,message:`This provider takes no '${n}'.`});continue}let n=e.path[0];if(typeof n!=`string`){t.push({message:e.message});continue}let i=n in r?e.message:`${n} is required.`;t.push({field:`connection.${n}`,message:i})}for(let n of[`keySlot`,`fallbackKeySlot`]){let r=e[n];r!==void 0&&!Fe.safeParse(r).success&&t.push({field:n,message:`A key slot is 1 to 32 letters, digits, hyphens, or underscores.`})}return e.keySlot&&e.keySlot===e.fallbackKeySlot&&t.push({field:`fallbackKeySlot`,message:g(`provider.fallback_slot`)}),(e.keySlot||e.fallbackKeySlot)&&n&&!n.key&&t.push({field:`keySlot`,message:g(`protocol.no_key`,{provider:e.id})}),t}function vt(e,t){let n=e.find(e=>e.id===t.provider)??{};return ze(n,{...t.keySlot?{keySlot:t.keySlot}:{},...t.fallbackKeySlot?{fallbackKeySlot:t.fallbackKeySlot}:{}})}function P(e,t){let n=A(e.definition);if(!n)return;let r;try{r=M(Re(),e,n)}catch{return[]}return r.serves.map(e=>e.protocol).filter(e=>t===void 0||e.endpoints[t]!==void 0)}function F(e,t,n){if(!e)return!1;let r=P(e,t);return r===void 0?!0:n===void 0?r.length>0:r.some(e=>e.id===n)}function yt(e,t,n){if(!bt(t))throw Error(`Cannot create a model route without a profile type.`);return{profileType:t,protocol:n.protocol,provider:n.provider,definition:j(e,n.provider),apiId:n.apiId,decision:t===`decision`}}function bt(e){return[`text`,`image`,`speech`,`transcription`,`live`,`decision`,`embedding`].includes(e)}function xt(e,t){let r=I(n(e.options,{io:`input`,unrepresentable:`any`}),``,!0),i=t?e.refusedOptions?.(t.apiId.trim())??[]:[];return r.filter(e=>{let n=e.path.split(`.`)[0]??e.path;return!i.includes(n)||t?.options[n]!==void 0})}function I(e,t,n){return Object.entries(e.properties??{}).flatMap(([r,i])=>{let a=t?`${t}.${r}`:r,o=n&&(e.required?.includes(r)??!1);if(i.type===`object`&&i.properties)return I(i,a,o);let s={path:a,label:St(r),required:o,...i.description?{description:i.description}:{}},c=i.anyOf?.filter(e=>typeof e.const==`string`||typeof e.const==`number`),l=c?.map(e=>e.const);if(i.enum?.every(e=>typeof e==`string`))return[{...s,kind:`choice`,choices:i.enum.map(e=>({value:e}))}];if(l&&l.length===i.anyOf?.length&&l.length>0){let e=l.every(e=>typeof e==`number`);if(e||l.every(e=>typeof e==`string`))return[{...s,kind:`choice`,choices:(c??[]).map(e=>({value:String(e.const),...e.title?{label:e.title}:{},...e.description?{description:e.description}:{}})),...e?{choiceType:`number`}:{}}]}return i.type===`boolean`?[{...s,kind:`boolean`}]:i.type===`array`&&i.items?.type===`string`?[{...s,kind:`names`}]:i.type===`string`?[{...s,kind:`text`}]:i.type===`number`||i.type===`integer`?[{...s,kind:`number`}]:[]})}function St(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Ct(e,t){return t.split(`.`).reduce((e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e[t]:void 0,e)}function L(e,t,n){let[r=``,...i]=t.split(`.`),{[r]:a,...o}=e,s=i.length?L(a&&typeof a==`object`&&!Array.isArray(a)?a:{},i.join(`.`),n):n;return s===void 0||typeof s==`object`&&s&&!Array.isArray(s)&&!Object.keys(s).length?o:{...o,[r]:s}}var R=`studio`,wt={"observability.writeTo":R};function Tt(e){return Object.entries(wt).reduce((e,[t,n])=>z(e,t.split(`.`),n),e)}function z(e,[t,...n],r){if(t===void 0||!Object.hasOwn(e,t))return e;let i=e[t];if(!n.length)return i===r?Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)):e;if(typeof i!=`object`||!i||Array.isArray(i))return e;let a=z(i,n,r);return a===i?e:Object.fromEntries(Object.entries(e).flatMap(([e,n])=>e===t?Object.keys(a).length?[[e,a]]:[]:[[e,n]]))}var Et=new Set(T.map(e=>e.name));function Dt(e){return e.protocol===Ie.id||e.protocol===ke.id}function Ot(e){return e.protocol===Be.id||e.protocol===Ne.id}function kt(e){return Et.has(e)}function At(e,t,n){return n.mode===`demo`?n.keys.runs(e,t?.definition):F(t,e)}var jt={text:`fast`,image:`image`,speech:`voice`,transcription:`transcription`,live:`live`,decision:`decision`,embedding:`embedding`};function Mt(e,t){let n=t?.(e)??{...B(e===`decision`?`typesafe`:`gemini`,e),apiId:``};return{modelId:jt[e],...n}}function B(e,t){let n=O.find(t=>t.id===e),r=n&&P(n,t)?.[0];if(!r)throw Error(`The studio provider '${e}' serves no ${t} agents.`);return{protocol:r.id,provider:e}}function Nt(e,t){return t.mode===`demo`?t.keys.violation(e):t.mode===`local`&&e.provider!==`local`?{field:`provider`,message:`Local runs require local models. Switch the model provider to Local.`}:null}var Pt=5,Ft=100,It=120;function V(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`string`||t===`number`||t===`integer`||t===`boolean`||t===`array`?t:t===`object`||h(e.properties)?`object`:Array.isArray(e.enum)?`string`:`unknown`}function Lt(e){return h(e.items)?e.items:void 0}function H(e){let t=e?.enum;return Array.isArray(t)&&t.length>0&&t.every(e=>typeof e==`string`)?t:void 0}function U(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function W(e,t){let n=U(e,`minimum`),r=U(e,`maximum`);return t&&n!==void 0&&r!==void 0&&r>n&&r-n<=Ft?{kind:`range`,min:n,max:r}:{kind:`number`,isInteger:t,...n===void 0?{}:{min:n},...r===void 0?{}:{max:r}}}function Rt(e){if(e.format===`date`)return{kind:`date`};let t=U(e,`maxLength`);return{kind:`text`,isLong:t!==void 0&&t>It,type:e.format===`email`?`email`:`text`}}function zt(e){let t=Lt(e),n=H(t);if(n)return{kind:`choices`,options:n};let r=t?V(t):`unknown`;return r===`string`||r===`number`||r===`integer`?{kind:`words`}:t&&r===`object`?{kind:`rows`,item:t}:{kind:`json`}}function Bt(e){let t=H(e);if(t)return{kind:`choice`,options:t,isMenu:t.length>Pt};switch(V(e)){case`boolean`:return{kind:`switch`};case`number`:return W(e,!1);case`integer`:return W(e,!0);case`string`:return Rt(e);case`array`:return zt(e);case`object`:return h(e.properties)?{kind:`group`,schema:e}:{kind:`json`};default:return{kind:`json`}}}function G(e){return new Set(Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[])}function K(e){let t=h(e.properties)?e.properties:{},n=G(e);return Object.entries(t).flatMap(([e,t])=>h(t)?[{key:e,label:typeof t.title==`string`&&t.title?t.title:Pe(e),...typeof t.description==`string`&&t.description?{description:t.description}:{},isRequired:n.has(e),control:Bt(t)}]:[])}function Vt(e){if(Array.isArray(e.examples)&&e.examples.length)return{value:e.examples[0]};if(`default`in e)return{value:e.default};if(`const`in e)return{value:e.const};if(Array.isArray(e.enum)&&e.enum.length)return{value:e.enum[0]}}function Ht(e){let t=Vt(e);if(t)return t.value;switch(V(e)){case`number`:case`integer`:return U(e,`minimum`)??1;case`boolean`:return!0;case`array`:return[];case`object`:return q(e);case`string`:case`unknown`:return`example`}}function q(e){let t=h(e.properties)?e.properties:{},n=new Set(G(e)),r={};for(let[e,i]of Object.entries(t))h(i)&&(n.has(e)?r[e]=Ht(i):Array.isArray(i.examples)&&i.examples.length&&(r[e]=i.examples[0]));return r}function Ut(e){return q(e)}function Wt(e,t,n){let r={...e};return n===void 0||n===``?delete r[t]:r[t]=n,r}function J(e,t,n=``){return h(t)?K(e).flatMap(e=>{let r=t[e.key],i=n?`${n} › ${e.label}`:e.label;return r==null||r===``?e.isRequired?[i]:[]:e.control.kind===`group`?J(e.control.schema,r,i):[]}):[]}var Gt=`{
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,B as r,F as i,G as a,H as o,I as s,J as c,K as l,L as ee,M as te,N as ne,P as re,Q as ie,R as ae,U as oe,V as se,W as ce,X as le,Y as ue,Z as de,a as u,at as fe,ct as pe,dt as me,et as he,ht as ge,i as d,it as _e,j as ve,lt as ye,mt as f,n as p,nt as be,ot as xe,q as Se,r as m,rt as Ce,st as we,tt as Te,ut as Ee,w as De,z as Oe}from"./schemas-D7cgkv3L.js";import{A as ke,C as Ae,D as je,S as Me,T as Ne,a as Pe,c as h,co as g,en as Fe,j as Ie,k as Le,qt as Re,tn as ze,w as Be}from"./shaped-data-BxDmEUJe.js";var Ve=e({endsWith:()=>ve,gt:()=>te,gte:()=>ne,includes:()=>re,length:()=>Oe,lowercase:()=>r,lt:()=>se,lte:()=>o,maxLength:()=>oe,maxSize:()=>ce,mime:()=>a,minLength:()=>l,minSize:()=>Se,multipleOf:()=>c,negative:()=>ue,nonnegative:()=>le,nonpositive:()=>de,normalize:()=>ie,overwrite:()=>t,positive:()=>he,properties:()=>Te,property:()=>be,regex:()=>Ce,size:()=>_e,slugify:()=>fe,startsWith:()=>xe,toLowerCase:()=>we,toUpperCase:()=>pe,trim:()=>ye,uppercase:()=>Ee}),He=e({ZodISODate:()=>p,ZodISODateTime:()=>m,ZodISODuration:()=>d,ZodISOTime:()=>u,date:()=>We,datetime:()=>Ue,duration:()=>Ke,time:()=>Ge});function Ue(e){return s(m,e)}function We(e){return i(p,e)}function Ge(e){return ae(u,e)}function Ke(e){return ee(d,e)}var _={...De,...Ve,iso:He},qe=new Set(`$schema.$ref.$defs.definitions.$id.id.$comment.$anchor.$vocabulary.$dynamicRef.$dynamicAnchor.type.enum.const.anyOf.oneOf.allOf.not.properties.required.additionalProperties.patternProperties.propertyNames.minProperties.maxProperties.items.prefixItems.additionalItems.minItems.maxItems.uniqueItems.contains.minContains.maxContains.minLength.maxLength.pattern.format.minimum.maximum.exclusiveMinimum.exclusiveMaximum.multipleOf.description.default.contentEncoding.contentMediaType.contentSchema.unevaluatedItems.unevaluatedProperties.if.then.else.dependentSchemas.dependentRequired.nullable.readOnly`.split(`.`));function Je(e,t){let n=e.$schema;return n===`https://json-schema.org/draft/2020-12/schema`?`draft-2020-12`:n===`http://json-schema.org/draft-07/schema#`?`draft-7`:n===`http://json-schema.org/draft-04/schema#`?`draft-4`:t??`draft-2020-12`}function v(e,t){return e.map((e,n)=>n<t?e:e.optional())}function Ye(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Xe(e,t){if(!e.startsWith(`#`))throw Error(`External $ref is not supported, only local refs (#/...) are allowed`);let n=e.slice(1).split(`/`).filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version===`draft-2020-12`?`$defs`:`definitions`;if(n[0]===r){let r=n[1]===void 0?void 0:Ye(n[1]);if(!r||!t.defs[r])throw Error(`Reference not found: ${e}`);return t.defs[r]}throw Error(`Reference not found: ${e}`)}function Ze(e,t){return _.transform(e=>e).check(n=>{let r=n.value;if(typeof r!=`object`||!r||Array.isArray(r))return;let i=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&i.length<t.minProperties&&n.issues.push({origin:`object`,code:`too_small`,minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&n.issues.push({origin:`object`,code:`too_big`,maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let e of i){let r=t.keySchema.safeParse(e);r.success||n.issues.push({code:`invalid_key`,origin:`record`,issues:r.error.issues,input:e,path:[e],continue:!0})}}).pipe(e)}function y(e,t){if(e===null)return`z`;let n=typeof e;if(n!==`object`){if(n===`number`&&Number.isNaN(e))return null;let t=String(e);return`${n[0]}${t.length}:${t}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let n=[];for(let r of e){let e=y(r,t);if(e===null)return null;n.push(e)}return`a${n.length}:[${n.join(`,`)}]`}let n=Object.keys(e).sort(),r=[];for(let i of n){let n=y(e[i],t);if(n===null)return null;r.push(`${i.length}:${i}=${n}`)}return`o${r.length}:{${r.join(`,`)}}`}finally{t.delete(e)}}var Qe=new Set([`items`,`prefixItems`,`additionalItems`,`additionalProperties`,`contains`,`propertyNames`,`not`,`if`,`then`,`else`,`allOf`,`anyOf`,`oneOf`,`unevaluatedItems`,`unevaluatedProperties`,`contentSchema`]),$e=new Set([`properties`,`patternProperties`,`dependentSchemas`,`dependencies`,`$defs`,`definitions`]);function b(e){return typeof e!=`object`||!e?!1:Array.isArray(e)?e.some(b):typeof e.$ref==`string`||Object.entries(e).some(([e,t])=>Qe.has(e)?b(t):!$e.has(e)||typeof t!=`object`||!t?!1:Object.values(t).some(b))}function x(e){return e===1?`element`:`elements`}function et(e,t){return _.transform(e=>e).check(e=>{let n=e.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let t=new Map;for(let r=0;r<n.length;r++){let i=y(n[r],new Set);if(i===null)continue;let a=t.get(i);a===void 0?t.set(i,r):e.issues.push({code:`custom`,message:`Array items must be unique: element at index ${r} duplicates the one at index ${a}`,input:n,path:[r],continue:!0})}}if(t.containsSchema){let r=t.minContains??1,i=t.maxContains===void 0?1/0:t.maxContains+1,a=0;for(let e of n)if(t.containsSchema.safeParse(e).success&&++a>=i)break;a<r&&e.issues.push({code:`custom`,message:`Array must contain at least ${r} matching ${x(r)}; found ${a}`,input:n,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&e.issues.push({code:`custom`,message:`Array must contain at most ${t.maxContains} matching ${x(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function S(e,t){if(e!==!1)return e===void 0||e===!0?_.any():w(e,t)}var tt=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function C(e,t){if(e.not!==void 0){if(typeof e.not==`object`&&Object.keys(e.not).length===0)return _.never();throw Error(`not is not supported in Zod (except { not: {} } for never)`)}if(e.unevaluatedItems!==void 0)throw Error(`unevaluatedItems is not supported`);if(e.unevaluatedProperties!==void 0)throw Error(`unevaluatedProperties is not supported`);if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error(`Conditional schemas (if/then/else) are not supported`);if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error(`dependentSchemas and dependentRequired are not supported`);if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return _.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let r=w(Xe(n,t),t);return t.refs.set(n,r),t.processing.delete(n),r}if(e.enum!==void 0){let n=e.enum;if(t.version===`openapi-3.0`&&e.nullable===!0&&n.length===1&&n[0]===null)return _.null();if(n.length===0)return _.never();if(n.length===1)return _.literal(n[0]);if(n.every(e=>typeof e==`string`))return _.enum(n);let r=n.map(e=>_.literal(e));return r.length<2?r[0]:_.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return _.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(n=>C({...e,type:n},t));return r.length===0?_.never():r.length===1?r[0]:_.union(r)}if(!n)return _.any();let r;switch(n){case`string`:{let t=_.string();if(e.format){let n=e.format;n===`email`?t=t.check(_.email()):n===`uri`||n===`uri-reference`?t=t.check(_.url()):n===`uuid`||n===`guid`?t=t.check(_.uuid()):n===`date-time`?t=t.check(_.iso.datetime({offset:!0})):n===`date`?t=t.check(_.iso.date()):n===`time`?t=t.check(_.regex(tt)):n===`duration`?t=t.check(_.iso.duration()):n===`hostname`?t=t.check(_.hostname()):n===`ipv4`?t=t.check(_.ipv4()):n===`ipv6`?t=t.check(_.ipv6()):n===`mac`?t=t.check(_.mac()):n===`cidr`?t=t.check(_.cidrv4()):n===`cidr-v6`?t=t.check(_.cidrv6()):n===`base64`?t=t.check(_.base64()):n===`base64url`?t=t.check(_.base64url()):n===`e164`?t=t.check(_.e164()):n===`credit_card`?t=t.check(_.creditCard()):n===`iban`?t=t.check(_.iban()):n===`jwt`?t=t.check(_.jwt()):n===`emoji`?t=t.check(_.emoji()):n===`nanoid`?t=t.check(_.nanoid()):n===`cuid`?t=t.check(_.cuid()):n===`cuid2`?t=t.check(_.cuid2()):n===`ulid`?t=t.check(_.ulid()):n===`xid`?t=t.check(_.xid()):n===`ksuid`&&(t=t.check(_.ksuid()))}typeof e.minLength==`number`&&(t=t.min(e.minLength)),typeof e.maxLength==`number`&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),r=t;break}case`number`:case`integer`:{let t=n===`integer`?_.number().int():_.number();typeof e.minimum==`number`&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum==`number`&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum==`number`?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum==`number`&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum==`number`?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum==`number`&&(t=t.lt(e.maximum)),typeof e.multipleOf==`number`&&(t=t.multipleOf(e.multipleOf)),r=t;break}case`boolean`:r=_.boolean();break;case`null`:r=_.null();break;case`object`:{let n={},i=e.properties||{},a=new Set(e.required||[]),o=typeof e.additionalProperties==`object`?w(e.additionalProperties,t):void 0;for(let[e,r]of Object.entries(i)){let i=w(r,t);f(n,e,a.has(e)?i:i.optional())}if(e.patternProperties){let i=e.patternProperties,a=Object.keys(i),o=[];for(let e of a){let n=w(i[e],t),r=_.string().regex(new RegExp(e));o.push(_.looseRecord(r,n))}let s=[];if(Object.keys(n).length>0&&s.push(_.object(n).passthrough()),s.push(...o),s.length===0)r=_.object({}).passthrough();else if(s.length===1)r=s[0];else{let e=_.intersection(s[0],s[1]);for(let t=2;t<s.length;t++)e=_.intersection(e,s[t]);r=e}if(e.additionalProperties===!1){let e=Object.keys(n),t=a.map(e=>new RegExp(e)),i=r;r=r.check(n=>{if(!ge(n.value))return;let r=[];for(let i of Object.keys(n.value))e.includes(i)||t.some(e=>e.test(i))||r.push(i);r.length&&n.issues.push({code:`unrecognized_keys`,keys:r,input:n.value,inst:i})})}}else{let t=_.object(n);r=e.additionalProperties===!1?t.strict():o?t.catchall(o):t.passthrough()}let s=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties==`number`?e.minProperties:void 0,l=typeof e.maxProperties==`number`?e.maxProperties:void 0;if(s||c!==void 0||l!==void 0){let n;s&&(n=w(typeof e.propertyNames==`object`&&e.propertyNames.type===void 0?{type:`string`,...e.propertyNames}:e.propertyNames,t)),r=Ze(r,{keySchema:n,minProperties:c,maxProperties:l})}break}case`array`:{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems==`number`?e.minItems:0,o=v(n.map(e=>w(e,t)),a),s=Array.isArray(i)?void 0:S(i,t),c=_.tuple(o);r=s?c.rest(s):c,typeof e.minItems==`number`&&(r=r.check(_.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(_.maxLength(e.maxItems)))}else if(Array.isArray(i)){let n=typeof e.minItems==`number`?e.minItems:0,a=v(i.map(e=>w(e,t)),n),o=S(e.additionalItems,t),s=_.tuple(a);r=o?s.rest(o):s,typeof e.minItems==`number`&&(r=r.check(_.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(_.maxLength(e.maxItems)))}else if(i!==void 0){let n=w(i,t),a=_.array(n);typeof e.minItems==`number`&&(a=a.min(e.minItems)),typeof e.maxItems==`number`&&(a=a.max(e.maxItems)),r=a}else r=_.array(_.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=et(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains===void 0?void 0:w(e.contains,t),minContains:typeof e.minContains==`number`?e.minContains:void 0,maxContains:typeof e.maxContains==`number`?e.maxContains:void 0}));break}default:throw Error(`Unsupported type: ${n}`)}return r}function w(e,t){if(typeof e==`boolean`)return e?_.any():_.never();let n=C(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let i=e.anyOf.map(e=>w(e,t)),a=_.union(i);n=r?_.intersection(n,a):a}if(e.oneOf&&Array.isArray(e.oneOf)){let i=e.oneOf.map(e=>w(e,t)),a=_.xor(i);n=r?_.intersection(n,a):a}if(e.allOf&&Array.isArray(e.allOf)){if(e.allOf.length===0)n=r?n:_.any();else{let i=r?n:w(e.allOf[0],t),a=+!r;for(let n=a;n<e.allOf.length;n++)i=_.intersection(i,w(e.allOf[n],t));n=i}}e.nullable===!0&&t.version===`openapi-3.0`&&(n=_.nullable(n)),e.readOnly===!0&&(n=_.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let i={};for(let t of[`$id`,`id`,`$comment`,`$anchor`,`$vocabulary`,`$dynamicRef`,`$dynamicAnchor`])t in e&&(i[t]=e[t]);for(let t of[`contentEncoding`,`contentMediaType`,`contentSchema`])t in e&&(i[t]=e[t]);if(e.type===`object`&&e.$ref===void 0){e.propertyNames!==void 0&&!b(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(let t of[`minProperties`,`maxProperties`])e[t]!==void 0&&(i[t]=e[t])}if(e.type===`array`&&e.$ref===void 0){e.contains!==void 0&&!b(e.contains)&&(i.contains=e.contains);for(let t of[`uniqueItems`,`minContains`,`maxContains`])e[t]!==void 0&&(i[t]=e[t])}for(let t of Object.keys(e))qe.has(t)||f(i,t,e[t]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function nt(e,t){if(typeof e==`boolean`)return e?_.any():_.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw Error(`fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas`)}let r={version:Je(n,t?.defaultTarget),defs:n.$defs||n.definitions||{},refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??me};return w(n,r)}var rt=`https://generativelanguage.googleapis.com/v1beta/models`,it=`Zephyr.Puck.Charon.Kore.Fenrir.Leda.Orus.Aoede.Callirrhoe.Autonoe.Enceladus.Iapetus.Umbriel.Algieba.Despina.Erinome.Algenib.Rasalgethi.Laomedeia.Achernar.Alnilam.Schedar.Gacrux.Pulcherrima.Achird.Zubenelgenubi.Vindemiatrix.Sadachbia.Sadaltager.Sulafat`.split(`.`),at=[`minimal`,`low`,`medium`,`high`],ot=[`pcm`],st=[`1:1`,`3:2`,`2:3`,`3:4`,`4:3`,`4:5`,`5:4`,`9:16`,`16:9`,`21:9`],ct=[`1K`,`2K`,`4K`],lt=[`image/png`,`image/jpeg`],T=[{type:`builtin`,name:`googleSearch`,description:`Google Search grounding`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`},{type:`builtin`,name:`googleMaps`,description:`Google Maps grounding`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`,conflictsWith:[`googleSearch`,`urlContext`]},{type:`builtin`,name:`urlContext`,description:`Fetch URL context`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`},{type:`builtin`,name:`codeExecution`,description:`Google code execution`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`}],ut=[{type:`builtin`,name:`webSearch`,description:`OpenRouter web search`,category:`grounding`,access:`read-only`,paths:[`*`],loadTier:`T0`,permission:`auto`}],E=`local`;function dt(e,t){return!t&&e===`local`}function D(e=`http://localhost:11434`){return`${e.replace(/\/$/,``)}/v1`}var O=[{id:`gemini`,definition:`gemini`},{id:`openrouter`,definition:`openrouter`},{id:E,definition:`local`,connection:{baseUrl:D()}},{id:`typesafe`,definition:`typesafe`}],k={gemini:{provider:Le,factory:`geminiProvider`},openrouter:{provider:Ae,factory:`openRouterProvider`},local:{provider:je,factory:`localProvider`},typesafe:{provider:Me,factory:`typesafeProvider`}};function A(e){return e===void 0?void 0:k[e]?.provider}function ft(){return Object.keys(k)}function pt(e){return Object.keys(k).find(t=>k[t]?.factory===e)}function mt(e){return k[e]?.factory}function j(e,t){return e.find(e=>e.id===t)?.definition}function ht(e){return{id:e.id,...e.connection===void 0?{}:{connection:e.connection},...e.keySlot===void 0?{}:{keySlot:e.keySlot},...e.fallbackKeySlot===void 0?{}:{fallbackKeySlot:e.fallbackKeySlot}}}function M(e,t,n=A(t.definition),r=`register`){if(!n)throw Error(`The studio does not hold the provider definition '${t.definition}'.`);return e[r](n,ht(t))}function gt(e){let t=A(e);if(!t)return;if(!t.connection)return[];let r=n(t.connection,{io:`input`});return Object.entries(r.properties??{}).map(([e,t])=>({name:e,required:r.required?.includes(e)??!1,url:t.format===`uri`,...t.description?{description:t.description}:{}}))}function _t(e){let t=A(e);return t===void 0||t.key!==void 0}function N(e){let t=[];e.id.trim()||t.push({field:`id`,message:`Provider id is required.`});let n=A(e.definition),r=e.connection??{},i=n?.connection?.safeParse(r);for(let e of i?.error?.issues??[]){if(e.code===`unrecognized_keys`){for(let n of e.keys)t.push({field:`connection.${n}`,message:`This provider takes no '${n}'.`});continue}let n=e.path[0];if(typeof n!=`string`){t.push({message:e.message});continue}let i=n in r?e.message:`${n} is required.`;t.push({field:`connection.${n}`,message:i})}for(let n of[`keySlot`,`fallbackKeySlot`]){let r=e[n];r!==void 0&&!Fe.safeParse(r).success&&t.push({field:n,message:`A key slot is 1 to 32 letters, digits, hyphens, or underscores.`})}return e.keySlot&&e.keySlot===e.fallbackKeySlot&&t.push({field:`fallbackKeySlot`,message:g(`provider.fallback_slot`)}),(e.keySlot||e.fallbackKeySlot)&&n&&!n.key&&t.push({field:`keySlot`,message:g(`protocol.no_key`,{provider:e.id})}),t}function vt(e,t){let n=e.find(e=>e.id===t.provider)??{};return ze(n,{...t.keySlot?{keySlot:t.keySlot}:{},...t.fallbackKeySlot?{fallbackKeySlot:t.fallbackKeySlot}:{}})}function P(e,t){let n=A(e.definition);if(!n)return;let r;try{r=M(Re(),e,n)}catch{return[]}return r.serves.map(e=>e.protocol).filter(e=>t===void 0||e.endpoints[t]!==void 0)}function F(e,t,n){if(!e)return!1;let r=P(e,t);return r===void 0?!0:n===void 0?r.length>0:r.some(e=>e.id===n)}function yt(e,t,n){if(!bt(t))throw Error(`Cannot create a model route without a profile type.`);return{profileType:t,protocol:n.protocol,provider:n.provider,definition:j(e,n.provider),apiId:n.apiId,decision:t===`decision`}}function bt(e){return[`text`,`image`,`speech`,`transcription`,`live`,`decision`,`embedding`].includes(e)}function xt(e,t){let r=I(n(e.options,{io:`input`,unrepresentable:`any`}),``,!0),i=t?e.refusedOptions?.(t.apiId.trim())??[]:[];return r.filter(e=>{let n=e.path.split(`.`)[0]??e.path;return!i.includes(n)||t?.options[n]!==void 0})}function I(e,t,n){return Object.entries(e.properties??{}).flatMap(([r,i])=>{let a=t?`${t}.${r}`:r,o=n&&(e.required?.includes(r)??!1);if(i.type===`object`&&i.properties)return I(i,a,o);let s={path:a,label:St(r),required:o,...i.description?{description:i.description}:{}},c=i.anyOf?.filter(e=>typeof e.const==`string`||typeof e.const==`number`),l=c?.map(e=>e.const);if(i.enum?.every(e=>typeof e==`string`))return[{...s,kind:`choice`,choices:i.enum.map(e=>({value:e}))}];if(l&&l.length===i.anyOf?.length&&l.length>0){let e=l.every(e=>typeof e==`number`);if(e||l.every(e=>typeof e==`string`))return[{...s,kind:`choice`,choices:(c??[]).map(e=>({value:String(e.const),...e.title?{label:e.title}:{},...e.description?{description:e.description}:{}})),...e?{choiceType:`number`}:{}}]}return i.type===`boolean`?[{...s,kind:`boolean`}]:i.type===`array`&&i.items?.type===`string`?[{...s,kind:`names`}]:i.type===`string`?[{...s,kind:`text`}]:i.type===`number`||i.type===`integer`?[{...s,kind:`number`}]:[]})}function St(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Ct(e,t){return t.split(`.`).reduce((e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e[t]:void 0,e)}function L(e,t,n){let[r=``,...i]=t.split(`.`),{[r]:a,...o}=e,s=i.length?L(a&&typeof a==`object`&&!Array.isArray(a)?a:{},i.join(`.`),n):n;return s===void 0||typeof s==`object`&&s&&!Array.isArray(s)&&!Object.keys(s).length?o:{...o,[r]:s}}var R=`studio`,wt={"observability.writeTo":R};function Tt(e){return Object.entries(wt).reduce((e,[t,n])=>z(e,t.split(`.`),n),e)}function z(e,[t,...n],r){if(t===void 0||!Object.hasOwn(e,t))return e;let i=e[t];if(!n.length)return i===r?Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)):e;if(typeof i!=`object`||!i||Array.isArray(i))return e;let a=z(i,n,r);return a===i?e:Object.fromEntries(Object.entries(e).flatMap(([e,n])=>e===t?Object.keys(a).length?[[e,a]]:[]:[[e,n]]))}var Et=new Set(T.map(e=>e.name));function Dt(e){return e.protocol===Ie.id||e.protocol===ke.id}function Ot(e){return e.protocol===Be.id||e.protocol===Ne.id}function kt(e){return Et.has(e)}function At(e,t,n){return n.mode===`demo`?n.keys.runs(e,t?.definition):F(t,e)}var jt={text:`fast`,image:`image`,speech:`voice`,transcription:`transcription`,live:`live`,decision:`decision`,embedding:`embedding`};function Mt(e,t){let n=t?.(e)??{...B(e===`decision`?`typesafe`:`gemini`,e),apiId:``};return{modelId:jt[e],...n}}function B(e,t){let n=O.find(t=>t.id===e),r=n&&P(n,t)?.[0];if(!r)throw Error(`The studio provider '${e}' serves no ${t} agents.`);return{protocol:r.id,provider:e}}function Nt(e,t){return t.mode===`demo`?t.keys.violation(e):t.mode===`local`&&e.provider!==`local`?{field:`provider`,message:`Local runs require local models. Switch the model provider to Local.`}:null}var Pt=5,Ft=100,It=120;function V(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`string`||t===`number`||t===`integer`||t===`boolean`||t===`array`?t:t===`object`||h(e.properties)?`object`:Array.isArray(e.enum)?`string`:`unknown`}function Lt(e){return h(e.items)?e.items:void 0}function H(e){let t=e?.enum;return Array.isArray(t)&&t.length>0&&t.every(e=>typeof e==`string`)?t:void 0}function U(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function W(e,t){let n=U(e,`minimum`),r=U(e,`maximum`);return t&&n!==void 0&&r!==void 0&&r>n&&r-n<=Ft?{kind:`range`,min:n,max:r}:{kind:`number`,isInteger:t,...n===void 0?{}:{min:n},...r===void 0?{}:{max:r}}}function Rt(e){if(e.format===`date`)return{kind:`date`};let t=U(e,`maxLength`);return{kind:`text`,isLong:t!==void 0&&t>It,type:e.format===`email`?`email`:`text`}}function zt(e){let t=Lt(e),n=H(t);if(n)return{kind:`choices`,options:n};let r=t?V(t):`unknown`;return r===`string`||r===`number`||r===`integer`?{kind:`words`}:t&&r===`object`?{kind:`rows`,item:t}:{kind:`json`}}function Bt(e){let t=H(e);if(t)return{kind:`choice`,options:t,isMenu:t.length>Pt};switch(V(e)){case`boolean`:return{kind:`switch`};case`number`:return W(e,!1);case`integer`:return W(e,!0);case`string`:return Rt(e);case`array`:return zt(e);case`object`:return h(e.properties)?{kind:`group`,schema:e}:{kind:`json`};default:return{kind:`json`}}}function G(e){return new Set(Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[])}function K(e){let t=h(e.properties)?e.properties:{},n=G(e);return Object.entries(t).flatMap(([e,t])=>h(t)?[{key:e,label:typeof t.title==`string`&&t.title?t.title:Pe(e),...typeof t.description==`string`&&t.description?{description:t.description}:{},isRequired:n.has(e),control:Bt(t)}]:[])}function Vt(e){if(Array.isArray(e.examples)&&e.examples.length)return{value:e.examples[0]};if(`default`in e)return{value:e.default};if(`const`in e)return{value:e.const};if(Array.isArray(e.enum)&&e.enum.length)return{value:e.enum[0]}}function Ht(e){let t=Vt(e);if(t)return t.value;switch(V(e)){case`number`:case`integer`:return U(e,`minimum`)??1;case`boolean`:return!0;case`array`:return[];case`object`:return q(e);case`string`:case`unknown`:return`example`}}function q(e){let t=h(e.properties)?e.properties:{},n=new Set(G(e)),r={};for(let[e,i]of Object.entries(t))h(i)&&(n.has(e)?r[e]=Ht(i):Array.isArray(i.examples)&&i.examples.length&&(r[e]=i.examples[0]));return r}function Ut(e){return q(e)}function Wt(e,t,n){let r={...e};return n===void 0||n===``?delete r[t]:r[t]=n,r}function J(e,t,n=``){return h(t)?K(e).flatMap(e=>{let r=t[e.key],i=n?`${n} › ${e.label}`:e.label;return r==null||r===``?e.isRequired?[i]:[]:e.control.kind===`group`?J(e.control.schema,r,i):[]}):[]}var Gt=`{
2
2
  "type": "object",
3
3
  "properties": {
4
4
  "query": { "type": "string" }
@@ -1 +1 @@
1
- import{Br as e,Ca as t,Qn as n,Zn as r,ai as i,cn as a,ha as o,ln as s,un as c,wa as l,xa as u}from"./shaped-data-BxGL5na3.js";var d=/^data:([^;,]+);base64,/,f=new Map([[`image`,`data`],[`audio`,`data`],[`thought_signature`,`signature`],[`thought`,`signature`],[`function_call`,`signature`],[`reasoning.encrypted`,`data`]]);function p(e){if(typeof(e.mime_type??e.mimeType)==`string`&&typeof e.data==`string`)return`data`;if(typeof e.media_type==`string`&&typeof e.b64_json==`string`)return`b64_json`;let t=typeof e.type==`string`?f.get(e.type):void 0;return t&&typeof e[t]==`string`&&e[t]!==``?t:void 0}var m=`sha256`,h=`text_sha256`;async function g(e){let n=await l(e);return n?{kind:m,hash:n.hash}:{kind:h,hash:await t(e)}}async function _(e){let t=d.exec(e);if(!t)return e;let{kind:n,hash:r}=await g(e.slice(t[0].length));return`data:${t[1]};${n},${r}`}async function v(e){let t=p(e),n,r=await Promise.all(Object.entries(e).map(async([e,r])=>{if(e===t&&typeof r==`string`){let{kind:t,hash:i}=await g(r);return n=t,[e,i]}return[e,await y(r)]})),i=Object.fromEntries(r);return n&&(i.dataKind=n),i}function y(e){return typeof e==`string`?_(e):Array.isArray(e)?Promise.all(e.map(e=>y(e))):e&&typeof e==`object`?v(e):Promise.resolve(e)}function b(t,n){return n.reduce((t,n)=>e(t,n),t)}function x(e,t){return t.some(Boolean)?u(e,e=>b(e,t)):e}async function S(e,t){return x(await y(e),t)}var C=`https://github.com/open-telemetry/semantic-conventions-genai/tree/8ffdf56`,w=`content_sha256`,T=`json_sha256`,E=[`gen_ai.usage.`,`theorem.usage.`],D={"theorem.upstream.row":`upstreamLog`,"theorem.wire.request":`outboundWire`,"theorem.guardrail":`guardrailDecisions`},O=`raw`,k=`match`,A=[`injection`];function j(e,t){return e===!0||e!==!1&&e[t]}function M(e,{scrub:t,detect:a}){let{sensitive:s,injection:c}=t;return i(e,[...s?n(e,o,s,a):[],...j(s,`host`)?r(e,a):[],...c?n(e,A,c,a):[]])}async function N(e,n){let r=await t(e);return n.content[r]=e,n.known.set(e,r),r}function P(e,t){let{[t]:n,...r}=e;return r}async function F(e,n){if(s(e)){let t=b(M(e.$content,n),n.canaries);return{...P(e,`$content`),[w]:await N(t,n)}}if(a(e)){let n=P(e,`$bytes`),r=await l(e.$bytes);return r?{...n,content_sha256:r.hash,bytes:r.bytes}:{...n,invalid_base64:!0,text_sha256:await t(e.$bytes)}}return c(e)?e:await z(e,e=>F(e,n))}function I(e,t){return typeof e==`string`?t(e):Array.isArray(e)?e.map(e=>I(e,t)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,I(n,t)])):e}function L(e,t){return I(e,e=>{let n=M(e,t),r=t.known.get(n);return r?{[w]:r}:n})}async function R(e,n){if(c(e)){let r=await S(e.$json,n.canaries),i=JSON.stringify(L(r,n)),a=await t(i);return n.content[a]=i,{...P(e,`$json`),[T]:a}}return await z(e,e=>R(e,n))}async function z(e,t){if(Array.isArray(e))return await Promise.all(e.map(t));if(e&&typeof e==`object`){let n=await Promise.all(Object.entries(e).map(async([e,n])=>[e,await t(n)]));return Object.fromEntries(n)}return e}async function B(e,t){let n=await Promise.all(Object.entries(e).map(async([e,n])=>[e,await t(n)]));return Object.fromEntries(n)}async function V(e,t){let n=await Promise.all(e.events.map(async e=>({...e,attributes:await B(e.attributes,t)})));return{...e,attributes:await B(e.attributes,t),events:n}}function H(e,t){return t.usage?e:Object.fromEntries(Object.entries(e).filter(([e])=>!E.some(t=>e.startsWith(t))))}function U(e){return e.map(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let{[k]:t,...n}=e;return n})}function W(e,t){let n=D[e.name];if(n&&!t[n])return;if(e.name===`theorem.grounding`&&!t.evidenceRaw){let{[O]:t,...n}=e.attributes;return{...e,attributes:n}}let{hits:r}=e.attributes;return e.name===`theorem.guardrail`&&!t.guardrailMatchPreview&&Array.isArray(r)?{...e,attributes:{...e.attributes,hits:U(r)}}:e}function G(e,t){return{...e,attributes:H(e.attributes,t),events:e.events.flatMap(e=>W(e,t)??[])}}function K(e){return Object.entries(e).flatMap(([e,t])=>t?[e]:[])}async function q(e){let{policy:t}=e,n={scrub:t.scrub,detect:t.detect,canaries:j(t.scrub.canary,`theorem`)?e.canaries??[]:[],content:{},known:new Map},r=e.spans.map(e=>G(e,t.include)),[i]=r;i&&(i.attributes={...i.attributes,"theorem.record.include":K(t.include),"theorem.record.scrub":K(t.scrub)});let a=await Promise.all(r.map(e=>V(e,e=>F(e,n)))),o=await Promise.all(a.map(e=>V(e,e=>R(e,n))));return{v:3,schemaUrl:C,resource:{...t.resource},...e.metadata?{metadata:e.metadata}:{},spans:o,content:n.content}}function J(e,t){if(Array.isArray(t))return t.map(t=>J(e,t));if(!t||typeof t!=`object`)return t;let n=Object.fromEntries(Object.entries(t).map(([t,n])=>[t,J(e,n)])),{[w]:r,[T]:i,...a}=n,o=typeof r==`string`?e.content[r]:void 0;if(o!==void 0)return Object.keys(a).length===0?o:{...a,content:o};let s=typeof i==`string`?e.content[i]:void 0;if(s===void 0)return n;let c=J(e,JSON.parse(s));return Object.keys(a).length===0?c:c&&typeof c==`object`&&!Array.isArray(c)?{...c,...a}:n}export{J as n,q as t};
1
+ import{Qn as e,Sa as t,Ta as n,Vr as r,Zn as i,cn as a,ga as o,ln as s,oi as c,un as l,wa as u}from"./shaped-data-BxDmEUJe.js";var d=/^data:([^;,]+);base64,/,f=new Map([[`image`,`data`],[`audio`,`data`],[`thought_signature`,`signature`],[`thought`,`signature`],[`function_call`,`signature`],[`reasoning.encrypted`,`data`]]);function p(e){if(typeof(e.mime_type??e.mimeType)==`string`&&typeof e.data==`string`)return`data`;if(typeof e.media_type==`string`&&typeof e.b64_json==`string`)return`b64_json`;let t=typeof e.type==`string`?f.get(e.type):void 0;return t&&typeof e[t]==`string`&&e[t]!==``?t:void 0}var m=`sha256`,h=`text_sha256`;async function g(e){let t=await n(e);return t?{kind:m,hash:t.hash}:{kind:h,hash:await u(e)}}async function _(e){let t=d.exec(e);if(!t)return e;let{kind:n,hash:r}=await g(e.slice(t[0].length));return`data:${t[1]};${n},${r}`}async function v(e){let t=p(e),n,r=await Promise.all(Object.entries(e).map(async([e,r])=>{if(e===t&&typeof r==`string`){let{kind:t,hash:i}=await g(r);return n=t,[e,i]}return[e,await y(r)]})),i=Object.fromEntries(r);return n&&(i.dataKind=n),i}function y(e){return typeof e==`string`?_(e):Array.isArray(e)?Promise.all(e.map(e=>y(e))):e&&typeof e==`object`?v(e):Promise.resolve(e)}function b(e,t){return t.reduce((e,t)=>r(e,t),e)}function x(e,n){return n.some(Boolean)?t(e,e=>b(e,n)):e}async function S(e,t){return x(await y(e),t)}var C=`https://github.com/open-telemetry/semantic-conventions-genai/tree/8ffdf56`,w=`content_sha256`,T=`json_sha256`,E=[`gen_ai.usage.`,`theorem.usage.`],D={"theorem.upstream.row":`upstreamLog`,"theorem.wire.request":`outboundWire`,"theorem.guardrail":`guardrailDecisions`},O=`raw`,k=`match`,A=[`injection`];function j(e,t){return e===!0||e!==!1&&e[t]}function M(t,{scrub:n,detect:r}){let{sensitive:a,injection:s}=n;return c(t,[...a?e(t,o,a,r):[],...j(a,`host`)?i(t,r):[],...s?e(t,A,s,r):[]])}async function N(e,t){let n=await u(e);return t.content[n]=e,t.known.set(e,n),n}function P(e,t){let{[t]:n,...r}=e;return r}async function F(e,t){if(s(e)){let n=b(M(e.$content,t),t.canaries);return{...P(e,`$content`),[w]:await N(n,t)}}if(a(e)){let t=P(e,`$bytes`),r=await n(e.$bytes);return r?{...t,content_sha256:r.hash,bytes:r.bytes}:{...t,invalid_base64:!0,text_sha256:await u(e.$bytes)}}return l(e)?e:await z(e,e=>F(e,t))}function I(e,t){return typeof e==`string`?t(e):Array.isArray(e)?e.map(e=>I(e,t)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,I(n,t)])):e}function L(e,t){return I(e,e=>{let n=M(e,t),r=t.known.get(n);return r?{[w]:r}:n})}async function R(e,t){if(l(e)){let n=await S(e.$json,t.canaries),r=JSON.stringify(L(n,t)),i=await u(r);return t.content[i]=r,{...P(e,`$json`),[T]:i}}return await z(e,e=>R(e,t))}async function z(e,t){if(Array.isArray(e))return await Promise.all(e.map(t));if(e&&typeof e==`object`){let n=await Promise.all(Object.entries(e).map(async([e,n])=>[e,await t(n)]));return Object.fromEntries(n)}return e}async function B(e,t){let n=await Promise.all(Object.entries(e).map(async([e,n])=>[e,await t(n)]));return Object.fromEntries(n)}async function V(e,t){let n=await Promise.all(e.events.map(async e=>({...e,attributes:await B(e.attributes,t)})));return{...e,attributes:await B(e.attributes,t),events:n}}function H(e,t){return t.usage?e:Object.fromEntries(Object.entries(e).filter(([e])=>!E.some(t=>e.startsWith(t))))}function U(e){return e.map(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let{[k]:t,...n}=e;return n})}function W(e,t){let n=D[e.name];if(n&&!t[n])return;if(e.name===`theorem.grounding`&&!t.evidenceRaw){let{[O]:t,...n}=e.attributes;return{...e,attributes:n}}let{hits:r}=e.attributes;return e.name===`theorem.guardrail`&&!t.guardrailMatchPreview&&Array.isArray(r)?{...e,attributes:{...e.attributes,hits:U(r)}}:e}function G(e,t){return{...e,attributes:H(e.attributes,t),events:e.events.flatMap(e=>W(e,t)??[])}}function K(e){return Object.entries(e).flatMap(([e,t])=>t?[e]:[])}async function q(e){let{policy:t}=e,n={scrub:t.scrub,detect:t.detect,canaries:j(t.scrub.canary,`theorem`)?e.canaries??[]:[],content:{},known:new Map},r=e.spans.map(e=>G(e,t.include)),[i]=r;i&&(i.attributes={...i.attributes,"theorem.record.include":K(t.include),"theorem.record.scrub":K(t.scrub)});let a=await Promise.all(r.map(e=>V(e,e=>F(e,n)))),o=await Promise.all(a.map(e=>V(e,e=>R(e,n))));return{v:3,schemaUrl:C,resource:{...t.resource},...e.metadata?{metadata:e.metadata}:{},spans:o,content:n.content}}function J(e,t){if(Array.isArray(t))return t.map(t=>J(e,t));if(!t||typeof t!=`object`)return t;let n=Object.fromEntries(Object.entries(t).map(([t,n])=>[t,J(e,n)])),{[w]:r,[T]:i,...a}=n,o=typeof r==`string`?e.content[r]:void 0;if(o!==void 0)return Object.keys(a).length===0?o:{...a,content:o};let s=typeof i==`string`?e.content[i]:void 0;if(s===void 0)return n;let c=J(e,JSON.parse(s));return Object.keys(a).length===0?c:c&&typeof c==`object`&&!Array.isArray(c)?{...c,...a}:n}export{J as n,q as t};
@@ -1,3 +1,3 @@
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 ee}from"./tool-schema-Bfe2TkD-.js";import{Ba as c,Di as l,En as u,Ft as d,Hi as te,Ht as ne,Pi as re,Ui as ie,Wa as f,Zi as ae,da as oe,ea as p,la as se,ta as m,xn as h,zi as g}from"./shaped-data-BxGL5na3.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:ae,inputs:p(`inputs`).filter(e=>e!==`decision`)},y=ce.map(e=>({...e,profileTypes:le[e.id]??p(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:g[0],permission:ie[0],loadTier:te[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:f(c,()=>`ignore`),patterns:[j()],hint:``}}function N(){let e=u(void 0);return{canaryBindNote:``,detect:f(m,t=>({...e.detect[t]})),sources:Object.fromEntries(se.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(`
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-CnrGGkcr.js";import{Bi as l,En as u,Fi as d,Ft as f,Ga as p,Ht as ee,Oi as te,Qi as ne,Ui as re,Va as ie,Wi as ae,fa as oe,na as se,ta as m,ua as h,xn as g}from"./shaped-data-BxDmEUJe.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:ne,inputs:m(`inputs`).filter(e=>e!==`decision`)},y=ce.map(e=>({...e,profileTypes:le[e.id]??m(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=d,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:l[0],permission:ae[0],loadTier:re[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=u(void 0);return{canaryBindNote:``,detect:p(se,t=>({...e.detect[t]})),sources:Object.fromEntries(h.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
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:ne({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!==``&&p(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`)&&oe(e.guardrails.detect,`canary_leak`)}function Ee(e){let t=e.identity.profileType;return t!==``&&d.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=>h(l,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 ee(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)],c=!e.models.key&&fe({...o,modelBindings:s}),l=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,...l?{speech:{...e.speech,voice:Ne}}:{},models:{...e.models,defaultModel:G(e.models.defaultModel,s),key:c?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};
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:ee({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!==``&&m(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`)&&oe(e.guardrails.detect,`canary_leak`)}function Ee(e){let t=e.identity.profileType;return t!==``&&f.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(te,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,2 +1,2 @@
1
- import{Hn as e,Nt as t,ca as n,gi as r,so as i,ui as a}from"./shaped-data-BxGL5na3.js";import{c as o}from"./host-patterns-F-KZIzkF.js";import{I as s}from"./reader-Bz6rc3qr.js";import{h as c}from"./schema-DI2QKpYi.js";import{r as l}from"./encode-files-Bn5i8t9U.js";function ee(e,t){let n=typeof t==`string`?t.trim():``;if(!n)throw new o(`request`,`A typed credential must be a non-empty string`);if(e===`bearer`)return{type:`bearer`,token:n};if(e===`api_key`)return{type:`api_key`,key:n};throw new o(`request`,`A '${e}' sign-in takes no typed credential; the host's callback saves it`)}function u(e,t){if(!e)throw new o(`request`,`a typed credential answers only a sign-in gate`);return{slot:e.slot,credential:ee(e.authType,t)}}function te(e,t){if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new o(`config`,`${e} gateTtlMs must be a positive number of milliseconds; got ${t}.`);return t}}function ne(e,t,n){return n!==void 0&&t-e>=n}var re=[`approve`,`deny`,`abandon`];function d(e,t=!1){return e.decision===`approve`?{granted:!0,...e.edited?{edited:e.edited}:{},...t?{signIn:t}:{}}:{granted:!1,cause:e.decision===`deny`?`declined`:`abandoned`,...t?{signIn:t}:{}}}function f(e,t,n){return n!==`session_consent`||e.includes(t)?[...e]:[...e,t]}function p(e,t,n){let{callId:r,decision:i,input:a,secret:s,page:c}=e;if((a!==void 0||s!==void 0||c!==void 0)&&i!==`approve`)throw new o(`request`,`only an approval takes edited input, a secret, or a page answer (call ${r})`);if(i!==`approve`)return{resume:d({decision:i},t.auth!==void 0),input:t.arguments,sessionPermissions:[...n]};let l=s===void 0?void 0:u(t.auth,s);return{resume:{...d(a===void 0?{decision:i}:{decision:i,edited:{from:t.arguments}},t.auth!==void 0),...t.gateKind?{gateKind:t.gateKind}:{}},input:a??t.arguments,sessionPermissions:f(n,t.name,t.permission),...l?{typed:l}:{},...c?{page:c}:{}}}var m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
- `,r:`\r`,t:` `};function h(e,t){let n=``,r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`"`)return{text:n,end:r+1};if(t!==`\\`){n+=t,r++;continue}if(r+1>=e.length)break;let i=e.charAt(r+1);if(i===`u`){let t=e.slice(r+2,r+6);if(t.length<4)break;if(/^[0-9a-fA-F]{4}$/.test(t)){n+=String.fromCharCode(Number.parseInt(t,16)),r+=6;continue}}n+=m[i]??i,r+=2}return{text:n}}function g(e,t){let n=t;for(;/\s/.test(e.charAt(n));)n++;return n}function ie(e,t){if(e.charAt(t)===`"`){let n=h(e,t);return n.end===void 0?void 0:_(e,t,n.end)}let n=0;for(let r=t;r<e.length;r++){let i=e.charAt(r);if(i===`"`){let t=h(e,r).end;if(t===void 0)return;r=t-1}else if(i===`{`||i===`[`)n++;else if(i===`}`||i===`]`){if(n===0)return _(e,t,r);if(n--,n===0)return _(e,t,r+1)}else if(i===`,`&&n===0)return _(e,t,r)}}function _(e,t,n){try{return{value:JSON.parse(e.slice(t,n)),end:n}}catch{return}}function v(e){let t={},n=g(e,0);if(e.charAt(n)!==`{`)return t;for(n++;;){if(n=g(e,n),e.charAt(n)===`,`&&(n=g(e,n+1)),e.charAt(n)!==`"`)return t;let r=h(e,n);if(r.end===void 0||(n=g(e,r.end),e.charAt(n)!==`:`)||(n=g(e,n+1),n>=e.length))return t;let i=ie(e,n);if(!i)return e.charAt(n)===`"`&&(t[r.text]=h(e,n).text),t;t[r.text]=i.value,n=i.end}}function y(e,t){if(t.phase===void 0)return{name:t.name,callId:t.callId,...t.operationId?{operationId:t.operationId}:{},arguments:t.arguments,...t.reasoning?{reasoning:t.reasoning}:{},...t.stepId?{stepId:t.stepId}:{}};if(e===void 0)throw new o(`bad_response`,`Tool event '${t.phase}' for call '${t.callId}' arrived before the call.`);if(e.callId!==t.callId||e.name!==t.name)throw new o(`bad_response`,i(`error.bad_response`));switch(t.phase){case`running`:{let{endedAt:n,outputDraft:r,...i}=e;return{...i,state:t,startedAt:t.at,...t.edited?{edited:t.edited}:{},...t.activity?{activity:t.activity}:{}}}case`complete`:case`error`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`cancel`:case`gate`:case`background`:return{...b(e),state:t,endedAt:t.at};case`draft`:return{...e,outputDraft:(e.outputDraft??``)+t.text};case`progress`:return se(e,t.data);case`dispatch`:case`trace`:case`warning`:return e}}function b(e){let{outputDraft:t,...n}=e;return n}function x(e,t){return{arguments:{},...e,name:t.name,callId:t.callId,draft:(e?.draft??``)+t.text}}function S(e,t){if(t.type===`tool_draft`){e.set(t.callId,x(e.get(t.callId),t));return}let{tool:n}=t,r=n.operationId??n.callId;n.phase===void 0&&e.get(n.callId)?.draft!==void 0&&e.delete(n.callId),e.set(r,y(e.get(r),n))}function ae(e){let t=new Map;for(let n of e)(n.type===`tool_draft`||n.type===`tool`)&&S(t,n);return[...t.values()]}function oe(e){if(typeof e!=`object`||!e||!(`agent`in e)||!(`event`in e))return;let{event:t}=e;if(t?.type!==`tool`&&t?.type!==`tool_draft`)return;let n=r.safeParse(t);return n.success?n.data:void 0}function se(e,t){let n=oe(t),r=n&&ce(e.steps??[],n);return r?{...e,steps:r}:e}function ce(e,t){let n=new Map(e.map(e=>[e.operationId??e.callId,e]));if(t.type===`tool`&&t.tool.phase!==void 0){let e=n.get(t.tool.operationId??t.tool.callId);if(e?.callId!==t.tool.callId||e.name!==t.tool.name)return}return S(n,t),[...n.values()]}function le(e){return(e.state?.phase===`gate`?e.state.gate.preparedArguments:void 0)??e.edited?.to??e.arguments}function ue(e,t){return e.type!==`tool`||e.tool.callId!==t?!1:e.tool.phase===`complete`||e.tool.phase===`error`||e.tool.phase===`background`}var C=0;function w(e){return e===`user`?`user-${globalThis.crypto.randomUUID()}`:(C+=1,`${e}-${String(C)}`)}function de(e,t){return e?.kind===t}function T(e,t,n,r){let i=e.at(-1);de(i,t)?i.text+=n:e.push({id:w(r),kind:t,text:n})}function fe(e,t){let n=e.at(-1),r=n?.kind===`text`||n?.kind===`thought`;e.splice(r?e.length-1:e.length,0,t)}function E(e,t){return e.find(e=>e.kind===`tool`&&e.id===t)}function pe(e,t){let n=`tool-${t.operationId??t.callId}`,r=E(e,n),i=y(r?.tool,t);if(r){r.tool=i;return}let a=t.phase===void 0?E(e,`tool-${t.callId}`):void 0;a?.tool.draft===void 0?e.push({id:n,kind:`tool`,tool:i}):(a.id=n,a.tool=i)}function me(e,t){let n=`tool-${t.callId}`,r=E(e,n),i=x(r?.tool,t);r?r.tool=i:e.push({id:n,kind:`tool`,tool:i})}function D(e){return e.findLast(e=>e.kind===`structured`&&e.draft!==void 0)}function O(e,t,n){let r=D(e),i=(r?.draft??``)+t;r?(r.draft=i,r.value=v(i)):e.push({id:w(n),kind:`structured`,value:v(i),draft:i})}function k(e,t,n){let r=D(e);r?(r.value=t,delete r.draft):e.push({id:w(n),kind:`structured`,value:t})}function A(e,t){return e.type===t.type?e.placeId&&t.placeId?e.placeId===t.placeId:e.uri===t.uri:!1}function j(e,t,n){let r=e.find(e=>e.kind===`citation`&&e.callId===t.callId),i=r?[...r.sources]:[];for(let e of t.sources)i.some(t=>A(t,e))||i.push(e);r?r.sources=i:e.push({id:w(n),kind:`citation`,sources:i,...t.callId===void 0?{}:{callId:t.callId}})}function M(e,t){return e.messages.flatMap(e=>{if(e.role!==`user`)return[];let n=e.parts??[],r=[e.content??``,...n.map(e=>`text`in e?e.text:``)].join(``).trim();return[...r?[{id:w(t),kind:`user-text`,text:r}]:[],...n.flatMap(e=>`text`in e?[]:[{id:w(t),kind:e.type===`audio`?`user-voice`:`user-attachment`,name:e.mimeType,mimeType:e.mimeType,...`data`in e?{sizeBytes:Math.floor(e.data.length*3/4),data:e.data}:{sizeBytes:0}}])]})}function N(e,t=`user`){let n=[],r=e.text?.trim();r&&n.push({id:w(t),kind:`user-text`,text:r});for(let r of e.attachments??[])n.push({id:w(t),kind:`user-attachment`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});for(let r of e.voice??[])n.push({id:w(t),kind:`user-voice`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});return n}function P(e,t){switch(e.type){case`media`:return e.media?{id:w(t),kind:`media`,mimeType:e.media.mimeType,data:e.media.data}:void 0;case`grounding`:return{id:w(t),kind:`grounding`,grounding:e.grounding};case`evidence`:return{id:w(t),kind:`evidence`,evidence:e.evidence};case`late_results`:return{id:w(t),kind:`late-results`,text:e.text,operationIds:e.operationIds};case`error`:return e.error?{id:w(t),kind:`error`,message:e.error}:void 0;case`done`:return{id:w(t),kind:`turn-done`,stop:e.stop,tokens:e.tokens,interactionId:e.interactionId,compaction:e.compaction!==void 0};default:return}}function F(e,t,n){if(t.phase===`complete`)for(let r of t.parts??[])r.type!==`text`&&e.push({id:w(n),kind:`media`,mimeType:r.mimeType,fromTool:!0,...`data`in r?{data:r.data,...r.sent?{sent:!0}:{}}:{uri:r.uri,type:r.type,sent:!0}})}function I(e,t={}){let n=t.idPrefix??`turn`,r=t.showThoughts??!0;C=0;let i=[];for(let t of a(e))switch(t.type){case`thought`:r&&t.text&&T(i,`thought`,t.text,n);break;case`text`:t.text&&T(i,`text`,t.text,n);break;case`tool_draft`:me(i,t);break;case`tool`:pe(i,t.tool),F(i,t.tool,n);break;case`structured_draft`:O(i,t.text,n);break;case`structured`:k(i,t.structured,n);break;case`citation`:j(i,t,n);break;case`guardrail`:fe(i,{id:w(n),kind:`guardrail`,guardrail:t.guardrail});break;case`stage`:for(let e of t.injected??[])i.push(...M(e,n));break;default:{let e=P(t,n);e&&i.push(e)}}return i}function L(e,t,n={}){return[...N(e,`user`),...I(t,n)]}function R(e){if(!e)return n;let{detect:t,patterns:r}=e;if(!r)return t;let i=Object.fromEntries(Object.entries(r).map(([e,{theorem:t}])=>[e,{theorem:t,matchers:[]}]));return{...t,sources:i}}function z(t,n){if(t.text===void 0)return t;let r=e(t.text,`user`,R(n));return{...t,text:r.text??t.text}}function B(e,t,n){let r=s(e,t);if(!r.ok)return{ok:!1,issues:r.issues};let i=z(t,n);return{ok:!0,draft:i,blocks:N(i)}}function V(e,t){if(t)return e.models[t]}function H(e){return!!(e.allowModelSelect&&Object.keys(e.models).length>=2)}function U(e,t){let n=V(e,t);return n?.allowEffortSelect?Object.keys(n.efforts??{}).length>=2:!1}function W(e,t){let n=V(e,t);if(!n?.efforts)return;let r=n.defaultEffort?.trim();return r&&n.efforts[r]?r:Object.keys(n.efforts)[0]}function he(e){return H(e)?Object.entries(e.models).map(([e,t])=>({id:e,label:t.apiId})):[]}function ge(e,t){if(!U(e,t))return[];let n=V(e,t);return n?.efforts?Object.entries(n.efforts).map(([e,t])=>({alias:e,level:t})):[]}function G(e){let t=new Set;for(let n of e)if(n.type===`tool`&&n.tool.phase===`complete`)for(let e of c(n.tool.output)??[])t.add(e);return[...t]}function K(e){let n=t(e,e=>e.type===`done`&&e.tools!==void 0);return n?.type===`done`?n.tools:void 0}function _e(e){let n=K(e)?.visible??[],r=t(e,e=>e.type===`done`&&e.steps!==void 0);return{promoted:[...new Set([...n,...G(e)])],stepsTaken:r?.type===`done`?r.steps??0:0}}function q(e){return e?.streaming?.streamThoughts!==!1}function J(e){return e.defaultModel??Object.keys(e.models)[0]}function ve(e,t,n){let r=t.model!==void 0&&Object.hasOwn(e.models,t.model)&&(n===void 0||t.model!==J(n))?t.model:J(e),i=r===void 0?void 0:e.models[r]?.efforts;return{model:r,effort:r===t.model&&t.effort!==void 0&&i!==void 0&&Object.hasOwn(i,t.effort)&&(n===void 0||t.effort!==W(n,r))?t.effort:W(e,r)}}function Y(e){if(!e.operationId)throw new o(`request`,i(`session.gate_expired`));return e.operationId}function ye(e,t){return t.selectedModel??J(e)}function be(e,t,n){let r=t.selectedEffort;if(!n||!Object.hasOwn(e.models,n))return r;let i=e.models[n];return i.allowEffortSelect?r??i.defaultEffort:r===W(e,n)?void 0:r}function X(e,t){let n=ye(e,t),r=e.allowModelSelect||n!==J(e)?n:void 0,i=be(e,t,n);return{...r?{model:r}:{},...i?{effort:i}:{}}}function xe(e,t,n){return{name:n.name,input:n.input,...n.gateKind?{gateKind:n.gateKind}:{},sessionPermissions:n.sessionPermissions??t.sessionPermissions,...t.toolSnapshot?{snapshot:t.toolSnapshot}:{},...t.promotedToolIds.length?{promoted:[...t.promotedToolIds]}:{},...X(e,t)}}function Z(e){return{...e.conversation?{conversation:e.conversation}:{},...e.turnId?{turnId:e.turnId}:{}}}function Q(e,t,n,r={}){let i=(r.walkAway?.calls??[]).map(e=>({callId:e.callId,operationId:Y(e)}));return{...Z(r),...X(e,t),input:n,...i.length?{abandon:i}:{},replay:{sessionPermissions:t.sessionPermissions}}}function Se(e,t,n,r={}){return{conversation:n,...r.turnId?{turnId:r.turnId}:{},...X(e,t)}}function Ce(e,t,n,r={}){return{...Z(r),gateId:n.gateId,operationId:n.operationId,decision:n.decision,...n.secret===void 0?{}:{secret:n.secret},...n.page===void 0?{}:{page:n.page},replay:xe(e,t,{...n,gateKind:n.gateKind??(t.gatedTool?.callId===n.gateId?t.gatedTool.gateKind:void 0)})}}function $(e,t){return B(e.inputs,t,e.guardrails)}function we(e,t,n,r=[]){return $(e,{...t.trim()?{text:t}:{},...n.length?{attachments:l(n)}:{},...r.length?{voice:l(r)}:{}})}function Te(e,t){return I(t,{showThoughts:q(e.outputs)})}export{f as A,le as C,ne as D,p as E,te as O,ue as S,re as T,H as _,Y as a,I as b,ve as c,_e as d,K as f,he as g,ge as h,Te as i,d as k,q as l,U as m,Q as n,we as o,W as p,Se as r,$ as s,Ce as t,G as u,B as v,ae as w,y as x,L as y};
1
+ import{Hn as e,Nt as t,_i as n,co as r,di as i,la as a}from"./shaped-data-BxDmEUJe.js";import{c as o}from"./host-patterns-F-KZIzkF.js";import{I as s}from"./reader-BZ-mDuss.js";import{h as c}from"./schema-Do4wX6Sr.js";import{r as l}from"./encode-files-MPtLTYyk.js";function ee(e,t){let n=typeof t==`string`?t.trim():``;if(!n)throw new o(`request`,`A typed credential must be a non-empty string`);if(e===`bearer`)return{type:`bearer`,token:n};if(e===`api_key`)return{type:`api_key`,key:n};throw new o(`request`,`A '${e}' sign-in takes no typed credential; the host's callback saves it`)}function u(e,t){if(!e)throw new o(`request`,`a typed credential answers only a sign-in gate`);return{slot:e.slot,credential:ee(e.authType,t)}}function te(e,t){if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new o(`config`,`${e} gateTtlMs must be a positive number of milliseconds; got ${t}.`);return t}}function ne(e,t,n){return n!==void 0&&t-e>=n}var re=[`approve`,`deny`,`abandon`];function d(e,t=!1){return e.decision===`approve`?{granted:!0,...e.edited?{edited:e.edited}:{},...t?{signIn:t}:{}}:{granted:!1,cause:e.decision===`deny`?`declined`:`abandoned`,...t?{signIn:t}:{}}}function f(e,t,n){return n!==`session_consent`||e.includes(t)?[...e]:[...e,t]}function p(e,t,n){let{callId:r,decision:i,input:a,secret:s,page:c}=e;if((a!==void 0||s!==void 0||c!==void 0)&&i!==`approve`)throw new o(`request`,`only an approval takes edited input, a secret, or a page answer (call ${r})`);if(i!==`approve`)return{resume:d({decision:i},t.auth!==void 0),input:t.arguments,sessionPermissions:[...n]};let l=s===void 0?void 0:u(t.auth,s);return{resume:{...d(a===void 0?{decision:i}:{decision:i,edited:{from:t.arguments}},t.auth!==void 0),...t.gateKind?{gateKind:t.gateKind}:{}},input:a??t.arguments,sessionPermissions:f(n,t.name,t.permission),...l?{typed:l}:{},...c?{page:c}:{}}}var m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
+ `,r:`\r`,t:` `};function h(e,t){let n=``,r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`"`)return{text:n,end:r+1};if(t!==`\\`){n+=t,r++;continue}if(r+1>=e.length)break;let i=e.charAt(r+1);if(i===`u`){let t=e.slice(r+2,r+6);if(t.length<4)break;if(/^[0-9a-fA-F]{4}$/.test(t)){n+=String.fromCharCode(Number.parseInt(t,16)),r+=6;continue}}n+=m[i]??i,r+=2}return{text:n}}function g(e,t){let n=t;for(;/\s/.test(e.charAt(n));)n++;return n}function ie(e,t){if(e.charAt(t)===`"`){let n=h(e,t);return n.end===void 0?void 0:_(e,t,n.end)}let n=0;for(let r=t;r<e.length;r++){let i=e.charAt(r);if(i===`"`){let t=h(e,r).end;if(t===void 0)return;r=t-1}else if(i===`{`||i===`[`)n++;else if(i===`}`||i===`]`){if(n===0)return _(e,t,r);if(n--,n===0)return _(e,t,r+1)}else if(i===`,`&&n===0)return _(e,t,r)}}function _(e,t,n){try{return{value:JSON.parse(e.slice(t,n)),end:n}}catch{return}}function v(e){let t={},n=g(e,0);if(e.charAt(n)!==`{`)return t;for(n++;;){if(n=g(e,n),e.charAt(n)===`,`&&(n=g(e,n+1)),e.charAt(n)!==`"`)return t;let r=h(e,n);if(r.end===void 0||(n=g(e,r.end),e.charAt(n)!==`:`)||(n=g(e,n+1),n>=e.length))return t;let i=ie(e,n);if(!i)return e.charAt(n)===`"`&&(t[r.text]=h(e,n).text),t;t[r.text]=i.value,n=i.end}}function y(e,t){if(t.phase===void 0)return{name:t.name,callId:t.callId,...t.operationId?{operationId:t.operationId}:{},arguments:t.arguments,...t.reasoning?{reasoning:t.reasoning}:{},...t.stepId?{stepId:t.stepId}:{}};if(e===void 0)throw new o(`bad_response`,`Tool event '${t.phase}' for call '${t.callId}' arrived before the call.`);if(e.callId!==t.callId||e.name!==t.name)throw new o(`bad_response`,r(`error.bad_response`));switch(t.phase){case`running`:{let{endedAt:n,outputDraft:r,...i}=e;return{...i,state:t,startedAt:t.at,...t.edited?{edited:t.edited}:{},...t.activity?{activity:t.activity}:{}}}case`complete`:case`error`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`cancel`:case`gate`:case`background`:return{...b(e),state:t,endedAt:t.at};case`draft`:return{...e,outputDraft:(e.outputDraft??``)+t.text};case`progress`:return se(e,t.data);case`dispatch`:case`trace`:case`warning`:return e}}function b(e){let{outputDraft:t,...n}=e;return n}function x(e,t){return{arguments:{},...e,name:t.name,callId:t.callId,draft:(e?.draft??``)+t.text}}function S(e,t){if(t.type===`tool_draft`){e.set(t.callId,x(e.get(t.callId),t));return}let{tool:n}=t,r=n.operationId??n.callId;n.phase===void 0&&e.get(n.callId)?.draft!==void 0&&e.delete(n.callId),e.set(r,y(e.get(r),n))}function ae(e){let t=new Map;for(let n of e)(n.type===`tool_draft`||n.type===`tool`)&&S(t,n);return[...t.values()]}function oe(e){if(typeof e!=`object`||!e||!(`agent`in e)||!(`event`in e))return;let{event:t}=e;if(t?.type!==`tool`&&t?.type!==`tool_draft`)return;let r=n.safeParse(t);return r.success?r.data:void 0}function se(e,t){let n=oe(t),r=n&&ce(e.steps??[],n);return r?{...e,steps:r}:e}function ce(e,t){let n=new Map(e.map(e=>[e.operationId??e.callId,e]));if(t.type===`tool`&&t.tool.phase!==void 0){let e=n.get(t.tool.operationId??t.tool.callId);if(e?.callId!==t.tool.callId||e.name!==t.tool.name)return}return S(n,t),[...n.values()]}function le(e){return(e.state?.phase===`gate`?e.state.gate.preparedArguments:void 0)??e.edited?.to??e.arguments}function ue(e,t){return e.type!==`tool`||e.tool.callId!==t?!1:e.tool.phase===`complete`||e.tool.phase===`error`||e.tool.phase===`background`}var C=0;function w(e){return e===`user`?`user-${globalThis.crypto.randomUUID()}`:(C+=1,`${e}-${String(C)}`)}function de(e,t){return e?.kind===t}function T(e,t,n,r){let i=e.at(-1);de(i,t)?i.text+=n:e.push({id:w(r),kind:t,text:n})}function fe(e,t){let n=e.at(-1),r=n?.kind===`text`||n?.kind===`thought`;e.splice(r?e.length-1:e.length,0,t)}function E(e,t){return e.find(e=>e.kind===`tool`&&e.id===t)}function pe(e,t){let n=`tool-${t.operationId??t.callId}`,r=E(e,n),i=y(r?.tool,t);if(r){r.tool=i;return}let a=t.phase===void 0?E(e,`tool-${t.callId}`):void 0;a?.tool.draft===void 0?e.push({id:n,kind:`tool`,tool:i}):(a.id=n,a.tool=i)}function me(e,t){let n=`tool-${t.callId}`,r=E(e,n),i=x(r?.tool,t);r?r.tool=i:e.push({id:n,kind:`tool`,tool:i})}function D(e){return e.findLast(e=>e.kind===`structured`&&e.draft!==void 0)}function O(e,t,n){let r=D(e),i=(r?.draft??``)+t;r?(r.draft=i,r.value=v(i)):e.push({id:w(n),kind:`structured`,value:v(i),draft:i})}function k(e,t,n){let r=D(e);r?(r.value=t,delete r.draft):e.push({id:w(n),kind:`structured`,value:t})}function A(e,t){return e.type===t.type?e.placeId&&t.placeId?e.placeId===t.placeId:e.uri===t.uri:!1}function j(e,t,n){let r=e.find(e=>e.kind===`citation`&&e.callId===t.callId),i=r?[...r.sources]:[];for(let e of t.sources)i.some(t=>A(t,e))||i.push(e);r?r.sources=i:e.push({id:w(n),kind:`citation`,sources:i,...t.callId===void 0?{}:{callId:t.callId}})}function M(e,t){return e.messages.flatMap(e=>{if(e.role!==`user`)return[];let n=e.parts??[],r=[e.content??``,...n.map(e=>`text`in e?e.text:``)].join(``).trim();return[...r?[{id:w(t),kind:`user-text`,text:r}]:[],...n.flatMap(e=>`text`in e?[]:[{id:w(t),kind:e.type===`audio`?`user-voice`:`user-attachment`,name:e.mimeType,mimeType:e.mimeType,...`data`in e?{sizeBytes:Math.floor(e.data.length*3/4),data:e.data}:{sizeBytes:0}}])]})}function N(e,t=`user`){let n=[],r=e.text?.trim();r&&n.push({id:w(t),kind:`user-text`,text:r});for(let r of e.attachments??[])n.push({id:w(t),kind:`user-attachment`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});for(let r of e.voice??[])n.push({id:w(t),kind:`user-voice`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});return n}function P(e,t){switch(e.type){case`media`:return e.media?{id:w(t),kind:`media`,mimeType:e.media.mimeType,data:e.media.data}:void 0;case`grounding`:return{id:w(t),kind:`grounding`,grounding:e.grounding};case`evidence`:return{id:w(t),kind:`evidence`,evidence:e.evidence};case`late_results`:return{id:w(t),kind:`late-results`,text:e.text,operationIds:e.operationIds,inReply:e.inReply};case`error`:return e.error?{id:w(t),kind:`error`,message:e.error}:void 0;case`done`:return{id:w(t),kind:`turn-done`,stop:e.stop,tokens:e.tokens,interactionId:e.interactionId,compaction:e.compaction!==void 0};default:return}}function F(e,t,n){if(t.phase===`complete`)for(let r of t.parts??[])r.type!==`text`&&e.push({id:w(n),kind:`media`,mimeType:r.mimeType,fromTool:!0,...`data`in r?{data:r.data,...r.sent?{sent:!0}:{}}:{uri:r.uri,type:r.type,sent:!0}})}function I(e,t={}){let n=t.idPrefix??`turn`,r=t.showThoughts??!0;C=0;let a=[];for(let t of i(e))switch(t.type){case`thought`:r&&t.text&&T(a,`thought`,t.text,n);break;case`text`:t.text&&T(a,`text`,t.text,n);break;case`tool_draft`:me(a,t);break;case`tool`:pe(a,t.tool),F(a,t.tool,n);break;case`structured_draft`:O(a,t.text,n);break;case`structured`:k(a,t.structured,n);break;case`citation`:j(a,t,n);break;case`guardrail`:fe(a,{id:w(n),kind:`guardrail`,guardrail:t.guardrail});break;case`stage`:for(let e of t.injected??[])a.push(...M(e,n));break;default:{let e=P(t,n);e&&a.push(e)}}return a}function L(e,t,n={}){return[...N(e,`user`),...I(t,n)]}function R(e){if(!e)return a;let{detect:t,patterns:n}=e;if(!n)return t;let r=Object.fromEntries(Object.entries(n).map(([e,{theorem:t}])=>[e,{theorem:t,matchers:[]}]));return{...t,sources:r}}function z(t,n){if(t.text===void 0)return t;let r=e(t.text,`user`,R(n));return{...t,text:r.text??t.text}}function B(e,t,n){let r=s(e,t);if(!r.ok)return{ok:!1,issues:r.issues};let i=z(t,n);return{ok:!0,draft:i,blocks:N(i)}}function V(e,t){if(t)return e.models[t]}function H(e){return!!(e.allowModelSelect&&Object.keys(e.models).length>=2)}function U(e,t){let n=V(e,t);return n?.allowEffortSelect?Object.keys(n.efforts??{}).length>=2:!1}function W(e,t){let n=V(e,t);if(!n?.efforts)return;let r=n.defaultEffort?.trim();return r&&n.efforts[r]?r:Object.keys(n.efforts)[0]}function he(e){return H(e)?Object.entries(e.models).map(([e,t])=>({id:e,label:t.apiId})):[]}function ge(e,t){if(!U(e,t))return[];let n=V(e,t);return n?.efforts?Object.entries(n.efforts).map(([e,t])=>({alias:e,level:t})):[]}function G(e){let t=new Set;for(let n of e)if(n.type===`tool`&&n.tool.phase===`complete`)for(let e of c(n.tool.output)??[])t.add(e);return[...t]}function K(e){let n=t(e,e=>e.type===`done`&&e.tools!==void 0);return n?.type===`done`?n.tools:void 0}function _e(e){let n=K(e)?.visible??[],r=t(e,e=>e.type===`done`&&e.steps!==void 0);return{promoted:[...new Set([...n,...G(e)])],stepsTaken:r?.type===`done`?r.steps??0:0}}function q(e){return e?.streaming?.streamThoughts!==!1}function J(e){return e.defaultModel??Object.keys(e.models)[0]}function ve(e,t,n){let r=t.model!==void 0&&Object.hasOwn(e.models,t.model)&&(n===void 0||t.model!==J(n))?t.model:J(e),i=r===void 0?void 0:e.models[r]?.efforts;return{model:r,effort:r===t.model&&t.effort!==void 0&&i!==void 0&&Object.hasOwn(i,t.effort)&&(n===void 0||t.effort!==W(n,r))?t.effort:W(e,r)}}function Y(e){if(!e.operationId)throw new o(`request`,r(`session.gate_expired`));return e.operationId}function ye(e,t){return t.selectedModel??J(e)}function be(e,t,n){let r=t.selectedEffort;if(!n||!Object.hasOwn(e.models,n))return r;let i=e.models[n];return i.allowEffortSelect?r??i.defaultEffort:r===W(e,n)?void 0:r}function X(e,t){let n=ye(e,t),r=e.allowModelSelect||n!==J(e)?n:void 0,i=be(e,t,n);return{...r?{model:r}:{},...i?{effort:i}:{}}}function xe(e,t,n){return{name:n.name,input:n.input,...n.gateKind?{gateKind:n.gateKind}:{},sessionPermissions:n.sessionPermissions??t.sessionPermissions,...t.toolSnapshot?{snapshot:t.toolSnapshot}:{},...t.promotedToolIds.length?{promoted:[...t.promotedToolIds]}:{},...X(e,t)}}function Z(e){return{...e.conversation?{conversation:e.conversation}:{},...e.turnId?{turnId:e.turnId}:{}}}function Q(e,t,n,r={}){let i=(r.walkAway?.calls??[]).map(e=>({callId:e.callId,operationId:Y(e)}));return{...Z(r),...X(e,t),input:n,...i.length?{abandon:i}:{},replay:{sessionPermissions:t.sessionPermissions}}}function Se(e,t,n,r={}){return{conversation:n,...r.turnId?{turnId:r.turnId}:{},...X(e,t)}}function Ce(e,t,n,r={}){return{...Z(r),gateId:n.gateId,operationId:n.operationId,decision:n.decision,...n.secret===void 0?{}:{secret:n.secret},...n.page===void 0?{}:{page:n.page},replay:xe(e,t,{...n,gateKind:n.gateKind??(t.gatedTool?.callId===n.gateId?t.gatedTool.gateKind:void 0)})}}function $(e,t){return B(e.inputs,t,e.guardrails)}function we(e,t,n,r=[]){return $(e,{...t.trim()?{text:t}:{},...n.length?{attachments:l(n)}:{},...r.length?{voice:l(r)}:{}})}function Te(e,t){return I(t,{showThoughts:q(e.outputs)})}export{f as A,le as C,ne as D,p as E,te as O,ue as S,re as T,H as _,Y as a,I as b,ve as c,_e as d,K as f,he as g,ge as h,Te as i,d as k,q as l,U as m,Q as n,we as o,W as p,Se as r,$ as s,Ce as t,G as u,B as v,ae as w,y as x,L as y};
@@ -0,0 +1 @@
1
+ import{Gi as e}from"./shaped-data-BxDmEUJe.js";var t=e.filter(e=>e!==`builtin`),n=`Tool type must be ${t.join(`, `).replace(/, ([^,]+)$/,`, or $1`)}.`;export{n,t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{t as r}from"./Icon-Cd9sDRzY.js";import{t as i}from"./Text-Cq4yqBpQ.js";import{t as a}from"./Tooltip-Rh2iV9Vn.js";import{b as o,w as s}from"./browser-transport-BPAKt_cc.js";import{d as c}from"./reader-Bz6rc3qr.js";import{n as l,o as u}from"./labels-provider-D_7O3BSI.js";import{t as d}from"./useLocale-CPtOawsd.js";import{t as f}from"./HStack-B00ufja5.js";import{t as p}from"./IconButton-BenRR-zK.js";import{t as m}from"./VStack-D1ZLA9g3.js";import{i as h,n as g,o as _,t as v}from"./arrive-DnkDKJb5.js";import{_ as y,b,g as x,y as S}from"./ConsoleFrame-sWIg1UlI.js";import{c as C,i as w}from"./trace-patterns-Bka_qf33.js";import{n as T}from"./studio-console-BA7bGrU2.js";var E=e(t(),1),D=n(),O=`var(--duration-medium) var(--ease-standard)`,k=12;function A(){let e=d();return(0,E.useMemo)(()=>({percent:new Intl.NumberFormat(e,{style:`percent`,maximumFractionDigits:0}),decimal:new Intl.NumberFormat(e,{maximumFractionDigits:2}),usd:new Intl.NumberFormat(e,{style:`currency`,currency:`USD`,maximumSignificantDigits:2})}),[e])}function j(e){return C(e?`clear`:`shade2`)}function M({value:e,isLead:t}){return(0,D.jsx)(`div`,{style:{height:k,width:`${String(Math.max(e,.01)*100)}%`,borderRadius:4,background:j(t),transition:`width ${O}`}})}function N({title:e,aside:t,detail:n,answer:r}){let a=l(),o=A(),s=Object.entries(r.probabilities).sort(([,e],[,t])=>t-e);return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:r.choice,note:a(`@theorem.decision.confidence`,{percent:o.percent.format(r.confidence)}),children:(0,D.jsx)(m,{gap:2,role:`list`,children:s.map(([e,t])=>(0,D.jsxs)(m,{gap:1,role:`listitem`,"aria-label":a(`@theorem.decision.option`,{label:e,percent:o.percent.format(t)}),children:[(0,D.jsxs)(f,{gap:2,hAlign:`between`,"aria-hidden":!0,children:[(0,D.jsx)(i,{type:`supporting`,color:`secondary`,maxLines:1,children:e}),(0,D.jsx)(i,{type:`supporting`,hasTabularNumbers:!0,children:o.percent.format(t)})]}),(0,D.jsx)(M,{value:t,isLead:e===r.choice})]},e))})})}var P=56;function F(e){let t=e.split(/[:—–]\s/)[0]?.trim()??``;return t&&t.length<=32&&t!==e?t:e}function I({title:e,aside:t,detail:n,answer:r,labels:a}){let o=l(),s=A(),c=a.length,u=Math.min(c-1,Math.max(0,Math.round(r.score)));return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a[u]===void 0?s.decimal.format(r.score):F(a[u]),note:[o(`@theorem.decision.score_of`,{score:s.decimal.format(r.score),max:s.decimal.format(c-1)}),o(`@theorem.decision.confidence`,{percent:s.percent.format(r.confidence)})].join(` · `),children:(0,D.jsxs)(m,{gap:1,children:[(0,D.jsxs)(`div`,{"aria-hidden":!0,style:{position:`relative`,display:`flex`,alignItems:`flex-end`,gap:4,height:P},children:[a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,height:`${String(Math.max(.04,r.probabilities[String(t)]??0)*100)}%`,borderRadius:4,background:j(t===u),transition:`height ${O}`}},`${String(t)}:${e}`)),(0,D.jsx)(`div`,{style:{position:`absolute`,insetBlock:-4,left:`${String((r.score+.5)/c*100)}%`,width:0,borderInlineStart:`1.5px dashed var(--color-text-secondary)`,transition:`left ${O}`}})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,minWidth:0},title:e,children:(0,D.jsx)(i,{type:`supporting`,color:`secondary`,maxLines:1,children:F(e)})},`${String(t)}:${e}`))}),(0,D.jsx)(`span`,{style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clipPath:`inset(50%)`},children:a.map((e,t)=>o(`@theorem.decision.option`,{label:e,percent:s.percent.format(r.probabilities[String(t)]??0)})).join(`; `)})]})})}function L({title:e,aside:t,detail:n,answer:r}){let i=A();return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:i.decimal.format(r.noul)})}var R=72,z=168;function B(e){let[t,n]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let t=new Image;t.onload=()=>{n({width:t.naturalWidth,height:t.naturalHeight})},t.src=e},[e]),t}function V(e,t){let n=e.style.color;e.style.color=`var(${t})`;let r=getComputedStyle(e).color;return e.style.color=n,r}function H({source:e,box:t,caption:n}){let r=l(),i=S(e),o=B(i),[s,c]=(0,E.useState)(null);if(!o)return null;let u=y(t),d=o.width*(t.right-t.left)/(o.height*(t.bottom-t.top)),f=r(`@theorem.decision.open_box`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(a,{content:f,children:(0,D.jsx)(_,{label:f,padding:0,onClick:e=>{let n={outline:V(e.currentTarget,`--color-accent`),shade:V(e.currentTarget,`--color-overlay`)};b(i,t,n).then(c)},children:(0,D.jsx)(`div`,{role:`img`,"aria-label":r(`@theorem.decision.box_in`),style:{position:`relative`,overflow:`hidden`,aspectRatio:String(d),height:z,maxWidth:`100%`,borderRadius:4},children:(0,D.jsx)(`img`,{src:i,alt:``,style:{position:`absolute`,width:`${String(u.width)}%`,height:`${String(u.height)}%`,left:`${String(u.left)}%`,top:`${String(u.top)}%`,maxWidth:`none`}})})})}),(0,D.jsx)(h,{isOpen:s!==null,onOpenChange:e=>{e||c(null)},media:{src:s??i,alt:r(`@theorem.decision.box_marked`),caption:n},hasZoom:!0})]})}function U({title:e,aside:t,detail:n,answer:r,image:i,asked:a}){let o=l(),s=a&&x(a.images,a.state,i),c=A(),{top:u,bottom:d,left:f,right:p}=r.box,m=o(`@theorem.decision.box_edges`,{left:c.percent.format(f),top:c.percent.format(u),right:c.percent.format(p),bottom:c.percent.format(d)});return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:m,note:o(`@theorem.decision.confidence`,{percent:c.percent.format(r.confidence)}),children:s?(0,D.jsx)(H,{source:s,box:r.box,caption:`${e}: ${m}`}):(0,D.jsx)(`div`,{"aria-hidden":!0,style:{position:`relative`,height:R,borderRadius:4,border:`1px solid var(--color-border)`},children:(0,D.jsx)(`div`,{style:{position:`absolute`,insetInlineStart:`${String(f*100)}%`,insetBlockStart:`${String(u*100)}%`,width:`${String((p-f)*100)}%`,height:`${String((d-u)*100)}%`,borderRadius:2,background:j(!0),transition:`all ${O}`}})})})}function W({question:e,answer:t,asked:n,onQuestion:i,detail:a}){let o=l(),c=`${e.id} · ${o(`@theorem.decision.type.${e.type}`)}`;if(!t)return null;let u=o(`@theorem.decision.edit_question`,{question:e.id}),d={title:c,detail:a,aside:i?(0,D.jsx)(p,{label:u,tooltip:u,size:`sm`,variant:`ghost`,icon:(0,D.jsx)(r,{icon:s,size:`xsm`,color:`secondary`}),onClick:()=>{i(e.id)}}):void 0};return t.type===`choice`?(0,D.jsx)(N,{...d,answer:t}):t.type===`score`?(0,D.jsx)(I,{...d,answer:t,labels:e.labels}):t.type===`noul`?(0,D.jsx)(L,{...d,answer:t}):(0,D.jsx)(U,{...d,answer:t,image:e.image,asked:n})}function G({model:e,usage:t,elapsedMs:n,isStale:r,tokens:a,children:o}){let s=l(),c=A();return(0,D.jsx)(g,{children:(0,D.jsxs)(m,{gap:3,style:{opacity:r?.5:1,transition:`opacity ${O}`},"aria-busy":r,children:[o,(0,D.jsx)(v,{children:(0,D.jsx)(i,{type:`supporting`,color:`secondary`,hasTabularNumbers:!0,children:u(s,c.usd,{model:e,usage:t,elapsedMs:n,tokens:a})})})]},n??0)})}function K({iface:e,result:t,elapsedMs:n,isStale:r,asked:i,onQuestion:a,questionText:o}){let s=l();return(0,D.jsx)(G,{model:t.model,usage:t.usage,elapsedMs:n,isStale:r,tokens:e=>s(`@theorem.decision.tokens`,{count:e}),children:(0,D.jsx)(T,{minWidth:260,children:e.questions.map(e=>(0,D.jsx)(v,{children:(0,D.jsx)(W,{question:e,answer:t.answers[e.id],asked:i,onQuestion:a,detail:o?.[e.id]})},e.id))})})}var q={status:`idle`,result:null,elapsedMs:null,startedAt:null,failure:null};function J(e,t){for(let n of t??[])e.traces?.push(n)}function Y(e,t,n){let[r,i]=(0,E.useState)(q),a=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>a.current?.abort(),[]);let s=(0,E.useCallback)(()=>{a.current?.abort(),a.current=null,i(e=>e.status===t?{...e,status:e.result?`done`:`idle`,startedAt:null}:e)},[t]),l=(0,E.useCallback)(async(...r)=>{a.current?.abort();let s=new AbortController;a.current=s,i(e=>({status:t,result:e.result,elapsedMs:e.elapsedMs,startedAt:Date.now(),failure:null}));let l=performance.now();try{let t=await n(e,s.signal,...r);if(s.signal.aborted)return;J(e,t.traces),i({status:`done`,result:t.result,elapsedMs:performance.now()-l,startedAt:null,failure:null})}catch(t){if(s.signal.aborted)return;J(e,c(t)),i(e=>({...e,status:`error`,startedAt:null,failure:o(t)}))}finally{a.current===s&&(a.current=null)}},[e,t,n]);return{...r,call:l,cancel:s}}export{A as a,K as i,G as n,M as r,Y as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{t as r}from"./Icon-Cd9sDRzY.js";import{t as i}from"./Text-Cq4yqBpQ.js";import{t as a}from"./Tooltip-Rh2iV9Vn.js";import{b as o,w as s}from"./browser-transport-rFxtbMn0.js";import{d as c}from"./reader-BZ-mDuss.js";import{n as l,o as u}from"./labels-provider-BOmB5WmP.js";import{t as d}from"./useLocale-CPtOawsd.js";import{t as f}from"./HStack-B00ufja5.js";import{t as p}from"./IconButton-BenRR-zK.js";import{t as m}from"./VStack-D1ZLA9g3.js";import{i as h,n as g,o as _,t as v}from"./arrive-DnkDKJb5.js";import{_ as y,b,g as x,y as S}from"./ConsoleFrame-Durgrfa8.js";import{c as C,i as w}from"./trace-patterns-Bka_qf33.js";import{n as T}from"./studio-console-Cn5vtx-w.js";var E=e(t(),1),D=n(),O=`var(--duration-medium) var(--ease-standard)`,k=12;function A(){let e=d();return(0,E.useMemo)(()=>({percent:new Intl.NumberFormat(e,{style:`percent`,maximumFractionDigits:0}),decimal:new Intl.NumberFormat(e,{maximumFractionDigits:2}),usd:new Intl.NumberFormat(e,{style:`currency`,currency:`USD`,maximumSignificantDigits:2})}),[e])}function j(e){return C(e?`clear`:`shade2`)}function M({value:e,isLead:t}){return(0,D.jsx)(`div`,{style:{height:k,width:`${String(Math.max(e,.01)*100)}%`,borderRadius:4,background:j(t),transition:`width ${O}`}})}function N({title:e,aside:t,detail:n,answer:r}){let a=l(),o=A(),s=Object.entries(r.probabilities).sort(([,e],[,t])=>t-e);return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:r.choice,note:a(`@theorem.decision.confidence`,{percent:o.percent.format(r.confidence)}),children:(0,D.jsx)(m,{gap:2,role:`list`,children:s.map(([e,t])=>(0,D.jsxs)(m,{gap:1,role:`listitem`,"aria-label":a(`@theorem.decision.option`,{label:e,percent:o.percent.format(t)}),children:[(0,D.jsxs)(f,{gap:2,hAlign:`between`,"aria-hidden":!0,children:[(0,D.jsx)(i,{type:`supporting`,color:`secondary`,maxLines:1,children:e}),(0,D.jsx)(i,{type:`supporting`,hasTabularNumbers:!0,children:o.percent.format(t)})]}),(0,D.jsx)(M,{value:t,isLead:e===r.choice})]},e))})})}var P=56;function F(e){let t=e.split(/[:—–]\s/)[0]?.trim()??``;return t&&t.length<=32&&t!==e?t:e}function I({title:e,aside:t,detail:n,answer:r,labels:a}){let o=l(),s=A(),c=a.length,u=Math.min(c-1,Math.max(0,Math.round(r.score)));return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a[u]===void 0?s.decimal.format(r.score):F(a[u]),note:[o(`@theorem.decision.score_of`,{score:s.decimal.format(r.score),max:s.decimal.format(c-1)}),o(`@theorem.decision.confidence`,{percent:s.percent.format(r.confidence)})].join(` · `),children:(0,D.jsxs)(m,{gap:1,children:[(0,D.jsxs)(`div`,{"aria-hidden":!0,style:{position:`relative`,display:`flex`,alignItems:`flex-end`,gap:4,height:P},children:[a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,height:`${String(Math.max(.04,r.probabilities[String(t)]??0)*100)}%`,borderRadius:4,background:j(t===u),transition:`height ${O}`}},`${String(t)}:${e}`)),(0,D.jsx)(`div`,{style:{position:`absolute`,insetBlock:-4,left:`${String((r.score+.5)/c*100)}%`,width:0,borderInlineStart:`1.5px dashed var(--color-text-secondary)`,transition:`left ${O}`}})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,minWidth:0},title:e,children:(0,D.jsx)(i,{type:`supporting`,color:`secondary`,maxLines:1,children:F(e)})},`${String(t)}:${e}`))}),(0,D.jsx)(`span`,{style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clipPath:`inset(50%)`},children:a.map((e,t)=>o(`@theorem.decision.option`,{label:e,percent:s.percent.format(r.probabilities[String(t)]??0)})).join(`; `)})]})})}function L({title:e,aside:t,detail:n,answer:r}){let i=A();return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:i.decimal.format(r.noul)})}var R=72,z=168;function B(e){let[t,n]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let t=new Image;t.onload=()=>{n({width:t.naturalWidth,height:t.naturalHeight})},t.src=e},[e]),t}function V(e,t){let n=e.style.color;e.style.color=`var(${t})`;let r=getComputedStyle(e).color;return e.style.color=n,r}function H({source:e,box:t,caption:n}){let r=l(),i=S(e),o=B(i),[s,c]=(0,E.useState)(null);if(!o)return null;let u=y(t),d=o.width*(t.right-t.left)/(o.height*(t.bottom-t.top)),f=r(`@theorem.decision.open_box`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(a,{content:f,children:(0,D.jsx)(_,{label:f,padding:0,onClick:e=>{let n={outline:V(e.currentTarget,`--color-accent`),shade:V(e.currentTarget,`--color-overlay`)};b(i,t,n).then(c)},children:(0,D.jsx)(`div`,{role:`img`,"aria-label":r(`@theorem.decision.box_in`),style:{position:`relative`,overflow:`hidden`,aspectRatio:String(d),height:z,maxWidth:`100%`,borderRadius:4},children:(0,D.jsx)(`img`,{src:i,alt:``,style:{position:`absolute`,width:`${String(u.width)}%`,height:`${String(u.height)}%`,left:`${String(u.left)}%`,top:`${String(u.top)}%`,maxWidth:`none`}})})})}),(0,D.jsx)(h,{isOpen:s!==null,onOpenChange:e=>{e||c(null)},media:{src:s??i,alt:r(`@theorem.decision.box_marked`),caption:n},hasZoom:!0})]})}function U({title:e,aside:t,detail:n,answer:r,image:i,asked:a}){let o=l(),s=a&&x(a.images,a.state,i),c=A(),{top:u,bottom:d,left:f,right:p}=r.box,m=o(`@theorem.decision.box_edges`,{left:c.percent.format(f),top:c.percent.format(u),right:c.percent.format(p),bottom:c.percent.format(d)});return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:m,note:o(`@theorem.decision.confidence`,{percent:c.percent.format(r.confidence)}),children:s?(0,D.jsx)(H,{source:s,box:r.box,caption:`${e}: ${m}`}):(0,D.jsx)(`div`,{"aria-hidden":!0,style:{position:`relative`,height:R,borderRadius:4,border:`1px solid var(--color-border)`},children:(0,D.jsx)(`div`,{style:{position:`absolute`,insetInlineStart:`${String(f*100)}%`,insetBlockStart:`${String(u*100)}%`,width:`${String((p-f)*100)}%`,height:`${String((d-u)*100)}%`,borderRadius:2,background:j(!0),transition:`all ${O}`}})})})}function W({question:e,answer:t,asked:n,onQuestion:i,detail:a}){let o=l(),c=`${e.id} · ${o(`@theorem.decision.type.${e.type}`)}`;if(!t)return null;let u=o(`@theorem.decision.edit_question`,{question:e.id}),d={title:c,detail:a,aside:i?(0,D.jsx)(p,{label:u,tooltip:u,size:`sm`,variant:`ghost`,icon:(0,D.jsx)(r,{icon:s,size:`xsm`,color:`secondary`}),onClick:()=>{i(e.id)}}):void 0};return t.type===`choice`?(0,D.jsx)(N,{...d,answer:t}):t.type===`score`?(0,D.jsx)(I,{...d,answer:t,labels:e.labels}):t.type===`noul`?(0,D.jsx)(L,{...d,answer:t}):(0,D.jsx)(U,{...d,answer:t,image:e.image,asked:n})}function G({model:e,usage:t,elapsedMs:n,isStale:r,tokens:a,children:o}){let s=l(),c=A();return(0,D.jsx)(g,{children:(0,D.jsxs)(m,{gap:3,style:{opacity:r?.5:1,transition:`opacity ${O}`},"aria-busy":r,children:[o,(0,D.jsx)(v,{children:(0,D.jsx)(i,{type:`supporting`,color:`secondary`,hasTabularNumbers:!0,children:u(s,c.usd,{model:e,usage:t,elapsedMs:n,tokens:a})})})]},n??0)})}function K({iface:e,result:t,elapsedMs:n,isStale:r,asked:i,onQuestion:a,questionText:o}){let s=l();return(0,D.jsx)(G,{model:t.model,usage:t.usage,elapsedMs:n,isStale:r,tokens:e=>s(`@theorem.decision.tokens`,{count:e}),children:(0,D.jsx)(T,{minWidth:260,children:e.questions.map(e=>(0,D.jsx)(v,{children:(0,D.jsx)(W,{question:e,answer:t.answers[e.id],asked:i,onQuestion:a,detail:o?.[e.id]})},e.id))})})}var q={status:`idle`,result:null,elapsedMs:null,startedAt:null,failure:null};function J(e,t){for(let n of t??[])e.traces?.push(n)}function Y(e,t,n){let[r,i]=(0,E.useState)(q),a=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>a.current?.abort(),[]);let s=(0,E.useCallback)(()=>{a.current?.abort(),a.current=null,i(e=>e.status===t?{...e,status:e.result?`done`:`idle`,startedAt:null}:e)},[t]),l=(0,E.useCallback)(async(...r)=>{a.current?.abort();let s=new AbortController;a.current=s,i(e=>({status:t,result:e.result,elapsedMs:e.elapsedMs,startedAt:Date.now(),failure:null}));let l=performance.now();try{let t=await n(e,s.signal,...r);if(s.signal.aborted)return;J(e,t.traces),i({status:`done`,result:t.result,elapsedMs:performance.now()-l,startedAt:null,failure:null})}catch(t){if(s.signal.aborted)return;J(e,c(t)),i(e=>({...e,status:`error`,startedAt:null,failure:o(t)}))}finally{a.current===s&&(a.current=null)}},[e,t,n]);return{...r,call:l,cancel:s}}export{A as a,K as i,G as n,M as r,Y as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n,r}from"./themeProps-Bo2jNkIC.js";import{n as i,t as a}from"./LayoutContent-BWpUj2Iy.js";import{t as o}from"./Stack-3jR93LgR.js";import{t as s}from"./Text-Cq4yqBpQ.js";import{t as c}from"./Button-Bwkht0RI.js";import{n as l}from"./CheckboxIndicator-BvfHW9OX.js";import{t as u}from"./Dialog-tyH-Jv5A.js";import{L as d}from"./index-hSIwfi4j.js";var f=e(t(),1),p=n(),m={action:{kzqmXN:`xh8yej3`,$$css:!0}};function h({isOpen:e,onOpenChange:t,title:n,description:h,cancelLabel:g,actionLabel:_,onAction:v}){let y=(0,f.useId)(),b=(0,f.useId)();return(0,p.jsx)(u,{...r(`alert-dialog`),isOpen:e,onOpenChange:t,purpose:`info`,role:`alertdialog`,"aria-labelledby":y,"aria-describedby":b,width:400,children:(0,p.jsx)(i,{content:(0,p.jsxs)(a,{children:[(0,p.jsx)(l,{level:2,id:y,children:n}),(0,p.jsx)(s,{type:`body`,color:`secondary`,id:b,children:h})]}),footer:(0,p.jsx)(d,{children:(0,p.jsxs)(o,{direction:`vertical`,gap:4,hAlign:`stretch`,children:[(0,p.jsx)(c,{label:_,variant:`destructive`,size:`lg`,onClick:v,xstyle:m.action}),(0,p.jsx)(c,{label:g,variant:`secondary`,size:`lg`,onClick:()=>t(!1),"data-autofocus":!0,xstyle:m.action})]})})})})}var g=8;function _(e,t){let n=(0,f.useRef)(null),r=()=>{n.current=null};return{onTouchStart:e=>{n.current=e.touches.length===1?e.touches[0].clientY:null},onTouchMove:i=>{if(i.touches.length!==1){r();return}let a=n.current;if(a==null||Math.abs(i.touches[0].clientY-a)<g)return;r();let o=e().find(e=>e!=null&&e===document.activeElement);if(o==null)return;let s=t?.();s==null?o.blur():s.focus({preventScroll:!0})},onTouchEnd:r,onTouchCancel:r}}export{h as n,_ as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n,r}from"./themeProps-Bo2jNkIC.js";import{n as i,t as a}from"./LayoutContent-BWpUj2Iy.js";import{t as o}from"./Stack-3jR93LgR.js";import{t as s}from"./Text-Cq4yqBpQ.js";import{t as c}from"./Button-Bwkht0RI.js";import{n as l}from"./CheckboxIndicator-BvfHW9OX.js";import{t as u}from"./Dialog-tyH-Jv5A.js";import{L as d}from"./index-C6pyNvXU.js";var f=e(t(),1),p=n(),m={action:{kzqmXN:`xh8yej3`,$$css:!0}};function h({isOpen:e,onOpenChange:t,title:n,description:h,cancelLabel:g,actionLabel:_,onAction:v}){let y=(0,f.useId)(),b=(0,f.useId)();return(0,p.jsx)(u,{...r(`alert-dialog`),isOpen:e,onOpenChange:t,purpose:`info`,role:`alertdialog`,"aria-labelledby":y,"aria-describedby":b,width:400,children:(0,p.jsx)(i,{content:(0,p.jsxs)(a,{children:[(0,p.jsx)(l,{level:2,id:y,children:n}),(0,p.jsx)(s,{type:`body`,color:`secondary`,id:b,children:h})]}),footer:(0,p.jsx)(d,{children:(0,p.jsxs)(o,{direction:`vertical`,gap:4,hAlign:`stretch`,children:[(0,p.jsx)(c,{label:_,variant:`destructive`,size:`lg`,onClick:v,xstyle:m.action}),(0,p.jsx)(c,{label:g,variant:`secondary`,size:`lg`,onClick:()=>t(!1),"data-autofocus":!0,xstyle:m.action})]})})})})}var g=8;function _(e,t){let n=(0,f.useRef)(null),r=()=>{n.current=null};return{onTouchStart:e=>{n.current=e.touches.length===1?e.touches[0].clientY:null},onTouchMove:i=>{if(i.touches.length!==1){r();return}let a=n.current;if(a==null||Math.abs(i.touches[0].clientY-a)<g)return;r();let o=e().find(e=>e!=null&&e===document.activeElement);if(o==null)return;let s=t?.();s==null?o.blur():s.focus({preventScroll:!0})},onTouchEnd:r,onTouchCancel:r}}export{h as n,_ as t};
@@ -1 +1 @@
1
- import{E as e,a as t,c as n,i as r,n as i,o as a,r as o,s,w as c,y as l}from"./tree-CMulctlY.js";function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e=>{if(Array.isArray(e))return e.map(t);if(!u(e))return e;let n=Object.keys(e).filter(t=>e[t]!==void 0).sort();return Object.fromEntries(n.map(n=>[n,t(e[n])]))};return JSON.stringify(t(e))??`undefined`}var f=`agent:`;function p(e,t=`identity`){return t===`identity`?`${f}${e}`:`${f}${e}/${t}`}function m(e){if(!e.startsWith(f))return;let t=e.slice(6),n=t.indexOf(`/`);return n<0?{key:t,inner:`identity`}:{key:t.slice(0,n),inner:t.slice(n+1)}}function h(e,t){return a(t)===void 0?p(e,t):t}function g(e,t){let n=a(t);if(n!==void 0)return e.toolSpecs.some(e=>e.key===n)?{tool:n}:void 0;let o=i(t);if(o!==void 0)return e.providers.some(e=>e.id===o)?{provider:o}:void 0;let s=m(t),c=s&&e.agents.find(e=>e.key===s.key);if(!s||!c||a(s.inner)!==void 0)return;let l=r(_(c,[],e.providers),s.inner);return l?{agent:c.key,ref:l}:void 0}function _(e,t,n){let{key:r,tools:{allow:i,...a},...o}=e,s=new Map(t.map(e=>[e.key,e]));return{...o,providers:n,tools:a,toolSpecs:i.flatMap(e=>s.get(e)??[])}}function ee(e,t){let n=e.agents.find(e=>e.key===t);return n&&_(n,e.toolSpecs,e.providers)}function v(e,t=c(`agent`)){let{toolSpecs:n,tools:r,providers:i,...a}=e;return{...a,key:t,tools:{...r,allow:n.map(e=>e.key)}}}function y(e,t){let n=new Map(t.map(e=>[e.key,e])),r=new Set(e.map(e=>e.key)),i=t.filter(e=>!r.has(e.key));return!e.some(e=>(n.get(e.key)??e)!==e)&&i.length===0?e:[...e.map(e=>n.get(e.key)??e),...i]}function b(e,t,n){return e.agents.map(e=>e.key===t?n(e):e)}var x=e=>e.key,S=e=>e.id;function C(e){let t=Object.fromEntries(e.agents.map(t=>[t.key,e.starts.agents[t.key]??t])),n=new Map(e.toolSpecs.map(e=>[e.key,e])),r=new Set([...n.keys(),...Object.values(t).flatMap(e=>e.tools.allow)]),i={};for(let t of r){let r=e.starts.tools[t]??n.get(t);r&&(i[t]=r)}let a=Object.fromEntries(e.providers.map(t=>[t.id,e.starts.providers[t.id]??t]));for(let n of Object.values(t).flatMap(w)){let t=e.starts.providers[n];t&&!(n in a)&&(a[n]=t)}return{...e,starts:{agents:t,tools:i,providers:a}}}var w=e=>e.modelBindings.map(e=>e.provider);function te(e,t){let n=new Set(e.providers.map(S)),r=[...new Set(t.flatMap(w))].flatMap(t=>{let r=e.starts.providers[t];return r&&!n.has(t)?[r]:[]});return r.length?[...e.providers,...r]:e.providers}function T(e,t){let n=e.agents.find(e=>e.key===t);return n?C({...e,starts:{...e.starts,agents:{...e.starts.agents,[t]:n}}}):e}function ne(e,t,n,r){if(!e.agents.some(e=>e.key===t))return e;let i=r?y(e.toolSpecs,[...r]):e.toolSpecs;return C({...e,toolSpecs:y(i,n.toolSpecs),agents:b(e,t,()=>v(n,t))})}function E(e,t=`identity`){let n=v(e);return K(C({v:5,agents:[n],toolSpecs:e.toolSpecs,providers:e.providers,selected:h(n.key,t),chatWith:n.key,starts:{agents:{},tools:{},providers:{}}}))}function re(e,t){let n=e.agents.find(e=>e.key===t);return n&&{..._(n,[],e.providers),toolSpecs:e.toolSpecs}}function ie(e,t,n){if(!e.agents.find(e=>e.key===t))return e;let r=new Set(n.toolSpecs.map(e=>e.key)),i=new Set(e.toolSpecs.map(e=>e.key)),a=n.toolSpecs.filter(e=>!i.has(e.key)).map(e=>e.key),o=e=>e.filter(e=>r.has(e)),{toolSpecs:s,providers:c,tools:l,...u}=n;return C({...e,toolSpecs:n.toolSpecs,agents:e.agents.map(e=>e.key===t?{...u,key:t,tools:{...l,allow:[...o(e.tools.allow),...a]}}:e.tools.allow.every(e=>r.has(e))?e:{...e,tools:{...e.tools,allow:o(e.tools.allow)}})})}function ae(t,n=l()){let r=new Map(t.toolSpecs.map(e=>[e.toolName,e.key])),i=n.identity.agentId.trim(),a=t.agents.map(e=>e.identity.agentId),o=i&&e(i,a,e=>`${i}_${e}`),s=v({...n,identity:{...n.identity,agentId:o}});return s.tools.allow=n.toolSpecs.map(e=>r.get(e.toolName)??e.key),C({...t,agents:[...t.agents,s],toolSpecs:[...t.toolSpecs,...n.toolSpecs.filter(e=>!r.has(e.toolName))],selected:p(s.key)})}function D(t,n){let r=t.agents.findIndex(e=>e.key===n),i=t.agents[r];if(!i)return t;let a=i.identity.agentId.trim()||`agent`,o=t.agents.map(e=>e.identity.agentId),s={...structuredClone(i),key:c(`agent`)};s.identity.agentId=e(`${a}_copy`,o,e=>`${a}_copy${e}`);let l=[...t.agents];return l.splice(r+1,0,s),C({...t,agents:l,selected:p(s.key)})}function O(e,t){let n=e.agents.findIndex(e=>e.key===t);if(n<0||e.agents.length===1)return e;let r=e.agents[n+1]??e.agents[n-1];if(!r)return e;let i=new Set(e.toolSpecs.filter(e=>e.toolType===`agent`&&e.agentKey===t).map(e=>e.key)),a=e.agents.filter(e=>e.key!==t).map(e=>({...e,tools:{...e.tools,allow:e.tools.allow.filter(e=>!i.has(e))},modelBindings:e.modelBindings.map(e=>e.compactWith===t?{...e,compactWith:void 0}:e)})),o=m(e.selected)?.key===t||[...i].some(t=>e.selected===s(t));return C({...e,agents:a,toolSpecs:e.toolSpecs.filter(e=>!i.has(e.key)).map(e=>e.stageAgentKey===t?{...e,stageAgentKey:void 0}:e),selected:o?p(r.key):e.selected,chatWith:e.chatWith===t?r.key:e.chatWith})}function k(e,t,n,r){let i=e.agents.find(e=>e.key===t);if(!i||!e.toolSpecs.some(e=>e.key===n)||i.tools.allow.includes(n)===r)return e;let a=r?[...i.tools.allow,n]:i.tools.allow.filter(e=>e!==n);return{...e,agents:b(e,t,()=>({...i,tools:{...i.tools,allow:a}}))}}function A(e,t){if(!e.toolSpecs.some(e=>e.key===t))return e;let n=e.agents.map(e=>e.tools.allow.includes(t)?{...e,tools:{...e.tools,allow:e.tools.allow.filter(e=>e!==t)}}:e);return C({...e,agents:n,toolSpecs:e.toolSpecs.filter(e=>e.key!==t),selected:e.selected===s(t)?p(e.agents[0]?.key??``):e.selected})}var j=(e,t)=>e===t||N(e)===N(t),M=new WeakMap;function N(e){if(typeof e!=`object`||!e)return d(e);let t=M.get(e);if(t!==void 0)return t;let n=d(e);return M.set(e,n),n}var P=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function oe(e){let{agents:t,tools:n,providers:r}=e.starts;return e.agents.every(e=>j(e,t[e.key]))&&e.toolSpecs.every(e=>j(e,n[e.key]))&&e.providers.every(e=>j(e,r[e.id]))&&Object.keys(n).length===e.toolSpecs.length}function se(e){return{...e,starts:{agents:Object.fromEntries(e.agents.map(e=>[e.key,e])),tools:Object.fromEntries(e.toolSpecs.map(e=>[e.key,e])),providers:Object.fromEntries(e.providers.map(e=>[e.id,e]))}}}function ce(e,t,n,r){return{...e,identity:{...e.identity,agentId:t},tools:{...e.tools,allow:e.tools.allow.filter(e=>n.has(e))},modelBindings:e.modelBindings.map(e=>e.compactWith&&!r.has(e.compactWith)?{...e,compactWith:void 0}:e)}}function F(t,n){let r=t.starts.agents[n],i=t.agents.find(e=>e.key===n);if(!r||!i)return t;let a=new Set(t.agents.map(e=>e.key)),o=new Set(t.toolSpecs.map(e=>e.key)),s=t.toolSpecs.map(e=>e.toolName),c=[];for(let n of r.tools.allow){let r=t.starts.tools[n];if(o.has(n)||!r||r.toolType===`agent`&&!a.has(r.agentKey??``))continue;let i=e(r.toolName,s,e=>`${r.toolName}_${e}`);s.push(i),c.push({...r,toolName:i})}let l=c.length?[...t.toolSpecs,...c]:t.toolSpecs,u=new Set(l.map(e=>e.key)),d=r.identity.agentId,f=t.agents.filter(e=>e.key!==n).map(e=>e.identity.agentId),m=ce(r,d&&e(d,f,e=>`${d}_${e}`),u,a);if(c.length===0&&j(m,i))return t;let h=te(t,[r]),_={...t,agents:b(t,n,()=>m),toolSpecs:l,providers:h};return g(_,_.selected)?_:{..._,selected:p(n)}}function le(e,t,n){if(n.facet===`identity`)return F(e,t);if(n.facet===`toolSpec`)return X(e,n.key);let r=F(e,t),i=r.agents.find(e=>e.key===t),a=e.agents.find(e=>e.key===t);if(r===e||!i||!a)return e;let o=ue(a,i,n);return j(o,a)?e:{...e,agents:b(e,t,()=>o),toolSpecs:n.facet===`tools`?r.toolSpecs:e.toolSpecs,providers:n.facet===`models`||n.facet===`modelBinding`?r.providers:e.providers}}function ue(e,t,n){if(n.facet===`models`)return{...e,models:t.models,modelBindings:t.modelBindings};if(n.facet===`modelBinding`){let r=t.modelBindings.find(e=>e.key===n.key);return r?{...e,modelBindings:e.modelBindings.map(e=>e.key===n.key?r:e)}:e}return n.facet===`toolSpec`?e:de(e,t,n.facet)}function de(e,t,n){return{...e,[n]:t[n]}}function I(e,t){let n=new Map(Object.values(t.starts.agents).map(e=>[e.identity.agentId,e.key])),r=new Map(Object.values(t.starts.tools).map(e=>[e.toolName,e.key])),i=JSON.stringify(e),a=(e,t)=>{t!==void 0&&t!==e&&(i=i.split(e).join(t))};for(let t of e.agents)a(t.key,n.get(t.identity.agentId));for(let t of e.toolSpecs)a(t.key,r.get(t.toolName));let o=JSON.parse(i);return{...o,selected:g(o,t.selected)?t.selected:o.selected,chatWith:o.agents.some(e=>e.key===t.chatWith)?t.chatWith:o.chatWith}}function L(e,t){let n=I(t,e),r=(e,t,n,r,i)=>{let a=new Map(r.map(t=>[e(t),t])),o=new Set([...t.map(e),...Object.keys(n)]),s=t.map(t=>j(t,n[e(t)])?a.get(e(t))??t:t),c=s.filter(t=>!(e(t)in i)).map(t=>[e(t),n[e(t)]??t]);return{held:[...s,...r.filter(t=>!o.has(e(t)))],starts:{...Object.fromEntries(c),...i}}},i=r(x,e.agents,e.starts.agents,n.agents,n.starts.agents),a=r(x,e.toolSpecs,e.starts.tools,n.toolSpecs,n.starts.tools),o=r(S,e.providers,e.starts.providers,n.providers,n.starts.providers);return{...e,agents:i.held,toolSpecs:a.held,providers:o.held,starts:{agents:i.starts,tools:a.starts,providers:o.starts}}}function R(e){let t=new Map,n=e=>{if(Array.isArray(e))for(let t of e)n(t);else if(typeof e==`object`&&e)for(let[r,i]of Object.entries(e))r!==`key`||typeof i!=`string`?n(i):t.has(i)||t.set(i,`#${t.size}`)},r=e=>typeof e==`string`?t.get(e)??e:Array.isArray(e)?e.map(r):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[t.get(e)??e,r(n)])),i={agents:e.agents,toolSpecs:e.toolSpecs,providers:e.providers};n(i);let a=JSON.stringify(r(i)),o=2166136261,s=16777619;for(let e=0;e<a.length;e+=1){let t=a.charCodeAt(e);o=Math.imul(o^t,16777619),s=Math.imul(s^t,2246822507)}return`${a.length.toString(36)}-${(o>>>0).toString(36)}${(s>>>0).toString(36)}`}function z(e,t){return R(e)!==t}var B=`(agent|line|model|tool|question|criterion|reference)-[0-9a-f]{8}`,V=RegExp(`^${B}$`);function H(e){let t=new Map;return JSON.stringify(e).replace(RegExp(`\\b${B}\\b`,`g`),e=>(t.has(e)||t.set(e,`#${t.size}`),t.get(e)??e))}function fe(e,t){let n=t.map(H),r=new Set,i=[],a=[];for(let o of e){let e=H(o),s=n.findIndex((t,n)=>t===e&&!r.has(n));s<0?a.push(o):(r.add(s),i.push([o,t[s]]))}let o=t.filter((e,t)=>!r.has(t));for(let[e,t]of a.slice(0,o.length).entries())i.push([t,o[e]]);return i}function pe(e,t){let n=JSON.stringify(e),r=(e,t,r,i)=>{let a=new Set(r.map(e=>e.key)),o=new Set(e.map(e=>e.key)),s=e.flatMap(e=>a.has(e.key)?[]:t[e.key]??[]),c=r.filter(e=>!o.has(e.key)&&!t[e.key]),[l,u]=[s[0],c[0]];s.length===1&&c.length===1&&l&&u&&H(i(l))===H(i(u))&&(n=n.split(u.key).join(l.key))};return r(t.agents,t.starts.agents,e.agents,e=>({...e,identity:{...e.identity,agentId:``}})),r(t.toolSpecs,t.starts.tools,e.toolSpecs,e=>({...e,toolName:``})),JSON.parse(n)}function me(e,t){let n=JSON.stringify(e);for(let e=0;e<4;e+=1){let e=JSON.parse(n),r=new Map,i=(e,t)=>{if(Array.isArray(e)&&Array.isArray(t))for(let[n,r]of fe(e,t))i(n,r);else if(P(e)&&P(t))for(let[n,a]of Object.entries(e)){let e=t[n];n===`key`?typeof a==`string`&&typeof e==`string`&&a!==e&&V.test(a)&&V.test(e)&&r.set(e,a):i(a,e)}};for(let n of e.agents)i(t.agents[n.key],n);for(let n of e.toolSpecs)i(t.tools[n.key],n);if(r.size===0)return e;for(let[e,t]of r)n=n.split(e).join(t)}return JSON.parse(n)}var U=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)&&new Set(e).size===e.length,W=e=>Array.isArray(e)&&e.every(e=>P(e)&&typeof e.key==`string`);function G(e,t,n,r,i){if(j(e,n)||j(t,n))return t;if(P(e)&&P(t)&&P(n)){let a={};for(let o of new Set([...Object.keys(n),...Object.keys(t),...Object.keys(e)])){let s=G(e[o],t[o],n[o],[...r,o],i);s!==void 0&&(a[o]=s)}return a}if(W(e)&&W(t)&&W(n)){let a=new Map(e.map(e=>[e.key,e])),o=new Map(n.map(e=>[e.key,e])),s=[];for(let e of t){let[t,n]=[a.get(e.key),o.get(e.key)],c=[...r,s.length];t?n?s.push(G(t,e,n,c,i)):j(e,t)?i.updated(c):(i.conflict(c,e,void 0),s.push(e)):s.push(e)}let c=new Set(t.map(e=>e.key)),l=s.length;for(let e of n){if(c.has(e.key))continue;let t=a.get(e.key);t?j(e,t)||i.conflict([...r,l++],void 0,e):(i.updated([...r,s.length]),s.push(e),l+=1)}return s}if(j(e,t))return i.updated(r),n;if(U(e)&&U(t)&&U(n)){let a=e.filter(e=>!n.includes(e)),o=n.filter(n=>!e.includes(n)&&!t.includes(n));return i.updated(r),[...t.filter(e=>!a.includes(e)),...o]}return i.conflict(r,t,n),t}function K(e){let t=new Set(e.agents.map(e=>e.key)),n=e.toolSpecs.filter(e=>e.toolType!==`agent`||t.has(e.agentKey??``)).map(e=>e.stageAgentKey&&!t.has(e.stageAgentKey)?{...e,stageAgentKey:void 0}:e),r=new Set(n.map(e=>e.key)),i=e.agents.map(e=>{let n=e.tools.allow.filter(e=>r.has(e)),i=e.modelBindings.map(e=>e.compactWith&&!t.has(e.compactWith)?{...e,compactWith:void 0}:e),a={...e,tools:{...e.tools,allow:n},modelBindings:i};return j(a,e)?e:a}),a=C({...e,agents:i,toolSpecs:n}),o=i[0];return{...a,selected:g(a,a.selected)||!o?a.selected:p(o.key),chatWith:t.has(a.chatWith)||!o?a.chatWith:o.key}}function he(e,t,n){let r=me(pe(I(t,e),e),e.starts),i=[],a=[],o=(e,t,n,r,o,s,c,l)=>{let u=new Map(s.map(e=>[t(e),e])),d=new Set(r.map(e=>t(e))),f=new Set(r.map(e=>n(o[t(e)]??e))),p=new Set(l?.map(n)),m=[],h={...c};for(let s of r){let[r,c]=[o[t(s)],u.get(t(s))],l={kind:e,key:t(s),name:n(c??r??s)};!r||!c&&!p.has(n(r))?(m.push(s),h[t(s)]=r??s):c?m.push(G(r,s,c,[],{updated:e=>i.push({...l,path:e}),conflict:(e,t,n)=>a.push({...l,path:e,mine:t,theirs:n})})):j(s,r)?i.push({...l,path:[]}):(a.push({...l,path:[],mine:s,theirs:void 0}),m.push(s),h[t(s)]=r)}let g=e=>{let r=o[t(e)]??l?.find(t=>n(t)===n(e)&&!f.has(n(t)));if(r)return H(r)===H(e)?`unchanged`:`changed`};for(let r of s){if(d.has(t(r)))continue;let o={kind:e,key:t(r),name:n(r),path:[]},s=g(r);s===`changed`?a.push({...o,mine:void 0,theirs:r}):s===void 0&&(m.push(r),i.push(o))}return{held:m,starts:h}},s=o(`agent`,x,e=>e.identity.agentId,e.agents,e.starts.agents,r.agents,r.starts.agents,n?.agents),c=o(`tool`,x,e=>e.toolName,e.toolSpecs,e.starts.tools,r.toolSpecs,r.starts.tools,n?.toolSpecs),l=o(`provider`,S,S,e.providers,e.starts.providers,r.providers,r.starts.providers,n?.providers);return{workspace:K({...e,agents:s.held,toolSpecs:c.held,providers:l.held,starts:{agents:s.starts,tools:c.starts,providers:l.starts}}),updated:i,conflicts:a,files:r}}var q=Object.freeze({gone:!0});function J(e){if(Array.isArray(e))return e.filter(e=>e!==q).map(J);if(!P(e))return e;let t=Object.entries(e).map(([e,t])=>[e,J(t)]);return Object.fromEntries(t)}function Y(e,t,n){let[r,...i]=t;if(r===void 0)return n;if(Array.isArray(e))return typeof r==`number`&&r>=e.length?n===void 0?e:[...e,n]:e.map((e,t)=>t===r?i.length===0&&n===void 0?q:Y(e,i,n):e);let a={...P(e)?e:{}},o=Y(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function ge(e,t){let{agents:n,toolSpecs:r,providers:i}=e.workspace,a={agents:{...e.workspace.starts.agents},tools:{...e.workspace.starts.tools},providers:{...e.workspace.starts.providers}},o=(e,t,n,r)=>r.path.length>0?t.map(t=>e(t)===r.key?Y(t,r.path,r.theirs):t):r.theirs===void 0?(delete n[r.key],t.filter(t=>e(t)!==r.key)):(n[r.key]=r.theirs,[...t,r.theirs]);for(let s of new Set(t)){let t=e.conflicts[s];if(t){if(t.kind===`tool`)r=o(x,r,a.tools,t);else if(t.kind===`provider`)i=o(S,i,a.providers,t);else{if(n=o(x,n,a.agents,t),t.path.length>0||t.theirs===void 0)continue;let i=new Set(r.map(e=>e.key)),s=e.files.toolSpecs.filter(e=>e.toolType===`agent`&&e.agentKey===t.key&&!i.has(e.key));for(let e of s)a.tools[e.key]=e;r=[...r,...s],n=n.map(t=>{let n=e.files.agents.find(e=>e.key===t.key)?.tools.allow??[],r=s.map(e=>e.key).filter(e=>n.includes(e)&&!t.tools.allow.includes(e));return r.length?{...t,tools:{...t.tools,allow:[...t.tools.allow,...r]}}:t})}}}return[n,r]=[J(n),J(r)],K({...e.workspace,agents:n,toolSpecs:r,providers:i,starts:a})}function X(t,n){let r=t.starts.tools[n],i=t.toolSpecs.find(e=>e.key===n);if(!r||!i)return t;let a=t.toolSpecs.filter(e=>e.key!==n).map(e=>e.toolName),o={...r,toolName:e(r.toolName,a,e=>`${r.toolName}_${e}`)};return j(o,i)?t:{...t,toolSpecs:t.toolSpecs.map(e=>e.key===n?o:e)}}function Z(e,t){let n=e.providers.find(e=>e.id===t.id);return!n||j(n,t)?e:{...e,providers:e.providers.map(e=>e.id===t.id?t:e)}}function Q(e,t){let n=e.agents.map(e=>w(e).filter(e=>e===t).length);return{models:n.reduce((e,t)=>e+t,0),agents:n.filter(e=>e>0).length}}function _e(e,t,n,r,i){let a=e=>e.provider===r&&e.apiId.trim()===i.trim();return{models:(e.agents.find(e=>e.key===t)?.modelBindings??[]).filter(e=>e.key!==n&&a(e)).map(e=>e.modelId.trim()||`Unnamed model`),agents:e.agents.filter(e=>e.key!==t&&e.modelBindings.some(a)).map(e=>e.identity.agentId.trim()||`Unnamed agent`)}}function ve(t,n){return{id:e(`provider`,t,e=>`provider_${e}`),definition:n,connection:{}}}function ye(e,t){return e.providers.some(e=>e.id===t.id)?e:C({...e,providers:[...e.providers,t],selected:o(t.id)})}function be(e,t){return!e.providers.some(e=>e.id===t)||Q(e,t).models>0?e:C({...e,providers:e.providers.filter(e=>e.id!==t),selected:e.selected===o(t)?p(e.agents[0]?.key??``):e.selected})}function xe(e,t,n){let r=n.trim();if(!e.providers.some(e=>e.id===t)||!r||e.providers.some(e=>e.id===r))return e;let{[t]:i,...a}=e.starts.providers,s=e=>e.provider===t;return{...e,providers:e.providers.map(e=>e.id===t?{...e,id:r}:e),agents:e.agents.map(e=>e.modelBindings.some(s)?{...e,modelBindings:e.modelBindings.map(e=>s(e)?{...e,provider:r}:e)}:e),selected:e.selected===o(t)?o(r):e.selected,starts:{...e.starts,providers:i?{...a,[r]:{...i,id:r}}:a}}}function Se(e){return e.providers.flatMap(t=>{let n=e.starts.providers[t.id];return n&&j(n,t)?[t.id]:[]})}function Ce(e,t){let n=e.starts.providers[t];return n?Z(e,n):e}function $(e,t){return{...t,id:p(e,t.id),children:t.children.map(t=>$(e,t))}}function we(e,n){return $(e.key,t(_(e,[],n)))}function Te(e){return{agents:e.agents.map(t=>we(t,e.providers)),tools:n(e.toolSpecs)}}export{ge as A,le as C,k as D,h as E,Te as F,d as I,Z as M,E as N,se as O,g as P,F as S,Ce as T,O as _,oe as a,xe as b,R as c,he as d,_e as f,L as g,Se as h,p as i,ie as j,ne as k,re as l,Q as m,ye as n,D as o,ve as p,ee as r,z as s,ae as t,T as u,A as v,X as w,I as x,be as y};
1
+ import{E as e,a as t,c as n,i as r,n as i,o as a,r as o,s,w as c,y as l}from"./tree-CZVr90dg.js";function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e=>{if(Array.isArray(e))return e.map(t);if(!u(e))return e;let n=Object.keys(e).filter(t=>e[t]!==void 0).sort();return Object.fromEntries(n.map(n=>[n,t(e[n])]))};return JSON.stringify(t(e))??`undefined`}var f=`agent:`;function p(e,t=`identity`){return t===`identity`?`${f}${e}`:`${f}${e}/${t}`}function m(e){if(!e.startsWith(f))return;let t=e.slice(6),n=t.indexOf(`/`);return n<0?{key:t,inner:`identity`}:{key:t.slice(0,n),inner:t.slice(n+1)}}function h(e,t){return a(t)===void 0?p(e,t):t}function g(e,t){let n=a(t);if(n!==void 0)return e.toolSpecs.some(e=>e.key===n)?{tool:n}:void 0;let o=i(t);if(o!==void 0)return e.providers.some(e=>e.id===o)?{provider:o}:void 0;let s=m(t),c=s&&e.agents.find(e=>e.key===s.key);if(!s||!c||a(s.inner)!==void 0)return;let l=r(_(c,[],e.providers),s.inner);return l?{agent:c.key,ref:l}:void 0}function _(e,t,n){let{key:r,tools:{allow:i,...a},...o}=e,s=new Map(t.map(e=>[e.key,e]));return{...o,providers:n,tools:a,toolSpecs:i.flatMap(e=>s.get(e)??[])}}function ee(e,t){let n=e.agents.find(e=>e.key===t);return n&&_(n,e.toolSpecs,e.providers)}function v(e,t=c(`agent`)){let{toolSpecs:n,tools:r,providers:i,...a}=e;return{...a,key:t,tools:{...r,allow:n.map(e=>e.key)}}}function y(e,t){let n=new Map(t.map(e=>[e.key,e])),r=new Set(e.map(e=>e.key)),i=t.filter(e=>!r.has(e.key));return!e.some(e=>(n.get(e.key)??e)!==e)&&i.length===0?e:[...e.map(e=>n.get(e.key)??e),...i]}function b(e,t,n){return e.agents.map(e=>e.key===t?n(e):e)}var x=e=>e.key,S=e=>e.id;function C(e){let t=Object.fromEntries(e.agents.map(t=>[t.key,e.starts.agents[t.key]??t])),n=new Map(e.toolSpecs.map(e=>[e.key,e])),r=new Set([...n.keys(),...Object.values(t).flatMap(e=>e.tools.allow)]),i={};for(let t of r){let r=e.starts.tools[t]??n.get(t);r&&(i[t]=r)}let a=Object.fromEntries(e.providers.map(t=>[t.id,e.starts.providers[t.id]??t]));for(let n of Object.values(t).flatMap(w)){let t=e.starts.providers[n];t&&!(n in a)&&(a[n]=t)}return{...e,starts:{agents:t,tools:i,providers:a}}}var w=e=>e.modelBindings.map(e=>e.provider);function te(e,t){let n=new Set(e.providers.map(S)),r=[...new Set(t.flatMap(w))].flatMap(t=>{let r=e.starts.providers[t];return r&&!n.has(t)?[r]:[]});return r.length?[...e.providers,...r]:e.providers}function T(e,t){let n=e.agents.find(e=>e.key===t);return n?C({...e,starts:{...e.starts,agents:{...e.starts.agents,[t]:n}}}):e}function ne(e,t,n,r){if(!e.agents.some(e=>e.key===t))return e;let i=r?y(e.toolSpecs,[...r]):e.toolSpecs;return C({...e,toolSpecs:y(i,n.toolSpecs),agents:b(e,t,()=>v(n,t))})}function E(e,t=`identity`){let n=v(e);return K(C({v:5,agents:[n],toolSpecs:e.toolSpecs,providers:e.providers,selected:h(n.key,t),chatWith:n.key,starts:{agents:{},tools:{},providers:{}}}))}function re(e,t){let n=e.agents.find(e=>e.key===t);return n&&{..._(n,[],e.providers),toolSpecs:e.toolSpecs}}function ie(e,t,n){if(!e.agents.find(e=>e.key===t))return e;let r=new Set(n.toolSpecs.map(e=>e.key)),i=new Set(e.toolSpecs.map(e=>e.key)),a=n.toolSpecs.filter(e=>!i.has(e.key)).map(e=>e.key),o=e=>e.filter(e=>r.has(e)),{toolSpecs:s,providers:c,tools:l,...u}=n;return C({...e,toolSpecs:n.toolSpecs,agents:e.agents.map(e=>e.key===t?{...u,key:t,tools:{...l,allow:[...o(e.tools.allow),...a]}}:e.tools.allow.every(e=>r.has(e))?e:{...e,tools:{...e.tools,allow:o(e.tools.allow)}})})}function ae(t,n=l()){let r=new Map(t.toolSpecs.map(e=>[e.toolName,e.key])),i=n.identity.agentId.trim(),a=t.agents.map(e=>e.identity.agentId),o=i&&e(i,a,e=>`${i}_${e}`),s=v({...n,identity:{...n.identity,agentId:o}});return s.tools.allow=n.toolSpecs.map(e=>r.get(e.toolName)??e.key),C({...t,agents:[...t.agents,s],toolSpecs:[...t.toolSpecs,...n.toolSpecs.filter(e=>!r.has(e.toolName))],selected:p(s.key)})}function D(t,n){let r=t.agents.findIndex(e=>e.key===n),i=t.agents[r];if(!i)return t;let a=i.identity.agentId.trim()||`agent`,o=t.agents.map(e=>e.identity.agentId),s={...structuredClone(i),key:c(`agent`)};s.identity.agentId=e(`${a}_copy`,o,e=>`${a}_copy${e}`);let l=[...t.agents];return l.splice(r+1,0,s),C({...t,agents:l,selected:p(s.key)})}function O(e,t){let n=e.agents.findIndex(e=>e.key===t);if(n<0||e.agents.length===1)return e;let r=e.agents[n+1]??e.agents[n-1];if(!r)return e;let i=new Set(e.toolSpecs.filter(e=>e.toolType===`agent`&&e.agentKey===t).map(e=>e.key)),a=e.agents.filter(e=>e.key!==t).map(e=>({...e,tools:{...e.tools,allow:e.tools.allow.filter(e=>!i.has(e))},modelBindings:e.modelBindings.map(e=>e.compactWith===t?{...e,compactWith:void 0}:e)})),o=m(e.selected)?.key===t||[...i].some(t=>e.selected===s(t));return C({...e,agents:a,toolSpecs:e.toolSpecs.filter(e=>!i.has(e.key)).map(e=>e.stageAgentKey===t?{...e,stageAgentKey:void 0}:e),selected:o?p(r.key):e.selected,chatWith:e.chatWith===t?r.key:e.chatWith})}function k(e,t,n,r){let i=e.agents.find(e=>e.key===t);if(!i||!e.toolSpecs.some(e=>e.key===n)||i.tools.allow.includes(n)===r)return e;let a=r?[...i.tools.allow,n]:i.tools.allow.filter(e=>e!==n);return{...e,agents:b(e,t,()=>({...i,tools:{...i.tools,allow:a}}))}}function A(e,t){if(!e.toolSpecs.some(e=>e.key===t))return e;let n=e.agents.map(e=>e.tools.allow.includes(t)?{...e,tools:{...e.tools,allow:e.tools.allow.filter(e=>e!==t)}}:e);return C({...e,agents:n,toolSpecs:e.toolSpecs.filter(e=>e.key!==t),selected:e.selected===s(t)?p(e.agents[0]?.key??``):e.selected})}var j=(e,t)=>e===t||N(e)===N(t),M=new WeakMap;function N(e){if(typeof e!=`object`||!e)return d(e);let t=M.get(e);if(t!==void 0)return t;let n=d(e);return M.set(e,n),n}var P=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function oe(e){let{agents:t,tools:n,providers:r}=e.starts;return e.agents.every(e=>j(e,t[e.key]))&&e.toolSpecs.every(e=>j(e,n[e.key]))&&e.providers.every(e=>j(e,r[e.id]))&&Object.keys(n).length===e.toolSpecs.length}function se(e){return{...e,starts:{agents:Object.fromEntries(e.agents.map(e=>[e.key,e])),tools:Object.fromEntries(e.toolSpecs.map(e=>[e.key,e])),providers:Object.fromEntries(e.providers.map(e=>[e.id,e]))}}}function ce(e,t,n,r){return{...e,identity:{...e.identity,agentId:t},tools:{...e.tools,allow:e.tools.allow.filter(e=>n.has(e))},modelBindings:e.modelBindings.map(e=>e.compactWith&&!r.has(e.compactWith)?{...e,compactWith:void 0}:e)}}function F(t,n){let r=t.starts.agents[n],i=t.agents.find(e=>e.key===n);if(!r||!i)return t;let a=new Set(t.agents.map(e=>e.key)),o=new Set(t.toolSpecs.map(e=>e.key)),s=t.toolSpecs.map(e=>e.toolName),c=[];for(let n of r.tools.allow){let r=t.starts.tools[n];if(o.has(n)||!r||r.toolType===`agent`&&!a.has(r.agentKey??``))continue;let i=e(r.toolName,s,e=>`${r.toolName}_${e}`);s.push(i),c.push({...r,toolName:i})}let l=c.length?[...t.toolSpecs,...c]:t.toolSpecs,u=new Set(l.map(e=>e.key)),d=r.identity.agentId,f=t.agents.filter(e=>e.key!==n).map(e=>e.identity.agentId),m=ce(r,d&&e(d,f,e=>`${d}_${e}`),u,a);if(c.length===0&&j(m,i))return t;let h=te(t,[r]),_={...t,agents:b(t,n,()=>m),toolSpecs:l,providers:h};return g(_,_.selected)?_:{..._,selected:p(n)}}function le(e,t,n){if(n.facet===`identity`)return F(e,t);if(n.facet===`toolSpec`)return X(e,n.key);let r=F(e,t),i=r.agents.find(e=>e.key===t),a=e.agents.find(e=>e.key===t);if(r===e||!i||!a)return e;let o=ue(a,i,n);return j(o,a)?e:{...e,agents:b(e,t,()=>o),toolSpecs:n.facet===`tools`?r.toolSpecs:e.toolSpecs,providers:n.facet===`models`||n.facet===`modelBinding`?r.providers:e.providers}}function ue(e,t,n){if(n.facet===`models`)return{...e,models:t.models,modelBindings:t.modelBindings};if(n.facet===`modelBinding`){let r=t.modelBindings.find(e=>e.key===n.key);return r?{...e,modelBindings:e.modelBindings.map(e=>e.key===n.key?r:e)}:e}return n.facet===`toolSpec`?e:de(e,t,n.facet)}function de(e,t,n){return{...e,[n]:t[n]}}function I(e,t){let n=new Map(Object.values(t.starts.agents).map(e=>[e.identity.agentId,e.key])),r=new Map(Object.values(t.starts.tools).map(e=>[e.toolName,e.key])),i=JSON.stringify(e),a=(e,t)=>{t!==void 0&&t!==e&&(i=i.split(e).join(t))};for(let t of e.agents)a(t.key,n.get(t.identity.agentId));for(let t of e.toolSpecs)a(t.key,r.get(t.toolName));let o=JSON.parse(i);return{...o,selected:g(o,t.selected)?t.selected:o.selected,chatWith:o.agents.some(e=>e.key===t.chatWith)?t.chatWith:o.chatWith}}function L(e,t){let n=I(t,e),r=(e,t,n,r,i)=>{let a=new Map(r.map(t=>[e(t),t])),o=new Set([...t.map(e),...Object.keys(n)]),s=t.map(t=>j(t,n[e(t)])?a.get(e(t))??t:t),c=s.filter(t=>!(e(t)in i)).map(t=>[e(t),n[e(t)]??t]);return{held:[...s,...r.filter(t=>!o.has(e(t)))],starts:{...Object.fromEntries(c),...i}}},i=r(x,e.agents,e.starts.agents,n.agents,n.starts.agents),a=r(x,e.toolSpecs,e.starts.tools,n.toolSpecs,n.starts.tools),o=r(S,e.providers,e.starts.providers,n.providers,n.starts.providers);return{...e,agents:i.held,toolSpecs:a.held,providers:o.held,starts:{agents:i.starts,tools:a.starts,providers:o.starts}}}function R(e){let t=new Map,n=e=>{if(Array.isArray(e))for(let t of e)n(t);else if(typeof e==`object`&&e)for(let[r,i]of Object.entries(e))r!==`key`||typeof i!=`string`?n(i):t.has(i)||t.set(i,`#${t.size}`)},r=e=>typeof e==`string`?t.get(e)??e:Array.isArray(e)?e.map(r):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[t.get(e)??e,r(n)])),i={agents:e.agents,toolSpecs:e.toolSpecs,providers:e.providers};n(i);let a=JSON.stringify(r(i)),o=2166136261,s=16777619;for(let e=0;e<a.length;e+=1){let t=a.charCodeAt(e);o=Math.imul(o^t,16777619),s=Math.imul(s^t,2246822507)}return`${a.length.toString(36)}-${(o>>>0).toString(36)}${(s>>>0).toString(36)}`}function z(e,t){return R(e)!==t}var B=`(agent|line|model|tool|question|criterion|reference)-[0-9a-f]{8}`,V=RegExp(`^${B}$`);function H(e){let t=new Map;return JSON.stringify(e).replace(RegExp(`\\b${B}\\b`,`g`),e=>(t.has(e)||t.set(e,`#${t.size}`),t.get(e)??e))}function fe(e,t){let n=t.map(H),r=new Set,i=[],a=[];for(let o of e){let e=H(o),s=n.findIndex((t,n)=>t===e&&!r.has(n));s<0?a.push(o):(r.add(s),i.push([o,t[s]]))}let o=t.filter((e,t)=>!r.has(t));for(let[e,t]of a.slice(0,o.length).entries())i.push([t,o[e]]);return i}function pe(e,t){let n=JSON.stringify(e),r=(e,t,r,i)=>{let a=new Set(r.map(e=>e.key)),o=new Set(e.map(e=>e.key)),s=e.flatMap(e=>a.has(e.key)?[]:t[e.key]??[]),c=r.filter(e=>!o.has(e.key)&&!t[e.key]),[l,u]=[s[0],c[0]];s.length===1&&c.length===1&&l&&u&&H(i(l))===H(i(u))&&(n=n.split(u.key).join(l.key))};return r(t.agents,t.starts.agents,e.agents,e=>({...e,identity:{...e.identity,agentId:``}})),r(t.toolSpecs,t.starts.tools,e.toolSpecs,e=>({...e,toolName:``})),JSON.parse(n)}function me(e,t){let n=JSON.stringify(e);for(let e=0;e<4;e+=1){let e=JSON.parse(n),r=new Map,i=(e,t)=>{if(Array.isArray(e)&&Array.isArray(t))for(let[n,r]of fe(e,t))i(n,r);else if(P(e)&&P(t))for(let[n,a]of Object.entries(e)){let e=t[n];n===`key`?typeof a==`string`&&typeof e==`string`&&a!==e&&V.test(a)&&V.test(e)&&r.set(e,a):i(a,e)}};for(let n of e.agents)i(t.agents[n.key],n);for(let n of e.toolSpecs)i(t.tools[n.key],n);if(r.size===0)return e;for(let[e,t]of r)n=n.split(e).join(t)}return JSON.parse(n)}var U=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)&&new Set(e).size===e.length,W=e=>Array.isArray(e)&&e.every(e=>P(e)&&typeof e.key==`string`);function G(e,t,n,r,i){if(j(e,n)||j(t,n))return t;if(P(e)&&P(t)&&P(n)){let a={};for(let o of new Set([...Object.keys(n),...Object.keys(t),...Object.keys(e)])){let s=G(e[o],t[o],n[o],[...r,o],i);s!==void 0&&(a[o]=s)}return a}if(W(e)&&W(t)&&W(n)){let a=new Map(e.map(e=>[e.key,e])),o=new Map(n.map(e=>[e.key,e])),s=[];for(let e of t){let[t,n]=[a.get(e.key),o.get(e.key)],c=[...r,s.length];t?n?s.push(G(t,e,n,c,i)):j(e,t)?i.updated(c):(i.conflict(c,e,void 0),s.push(e)):s.push(e)}let c=new Set(t.map(e=>e.key)),l=s.length;for(let e of n){if(c.has(e.key))continue;let t=a.get(e.key);t?j(e,t)||i.conflict([...r,l++],void 0,e):(i.updated([...r,s.length]),s.push(e),l+=1)}return s}if(j(e,t))return i.updated(r),n;if(U(e)&&U(t)&&U(n)){let a=e.filter(e=>!n.includes(e)),o=n.filter(n=>!e.includes(n)&&!t.includes(n));return i.updated(r),[...t.filter(e=>!a.includes(e)),...o]}return i.conflict(r,t,n),t}function K(e){let t=new Set(e.agents.map(e=>e.key)),n=e.toolSpecs.filter(e=>e.toolType!==`agent`||t.has(e.agentKey??``)).map(e=>e.stageAgentKey&&!t.has(e.stageAgentKey)?{...e,stageAgentKey:void 0}:e),r=new Set(n.map(e=>e.key)),i=e.agents.map(e=>{let n=e.tools.allow.filter(e=>r.has(e)),i=e.modelBindings.map(e=>e.compactWith&&!t.has(e.compactWith)?{...e,compactWith:void 0}:e),a={...e,tools:{...e.tools,allow:n},modelBindings:i};return j(a,e)?e:a}),a=C({...e,agents:i,toolSpecs:n}),o=i[0];return{...a,selected:g(a,a.selected)||!o?a.selected:p(o.key),chatWith:t.has(a.chatWith)||!o?a.chatWith:o.key}}function he(e,t,n){let r=me(pe(I(t,e),e),e.starts),i=[],a=[],o=(e,t,n,r,o,s,c,l)=>{let u=new Map(s.map(e=>[t(e),e])),d=new Set(r.map(e=>t(e))),f=new Set(r.map(e=>n(o[t(e)]??e))),p=new Set(l?.map(n)),m=[],h={...c};for(let s of r){let[r,c]=[o[t(s)],u.get(t(s))],l={kind:e,key:t(s),name:n(c??r??s)};!r||!c&&!p.has(n(r))?(m.push(s),h[t(s)]=r??s):c?m.push(G(r,s,c,[],{updated:e=>i.push({...l,path:e}),conflict:(e,t,n)=>a.push({...l,path:e,mine:t,theirs:n})})):j(s,r)?i.push({...l,path:[]}):(a.push({...l,path:[],mine:s,theirs:void 0}),m.push(s),h[t(s)]=r)}let g=e=>{let r=o[t(e)]??l?.find(t=>n(t)===n(e)&&!f.has(n(t)));if(r)return H(r)===H(e)?`unchanged`:`changed`};for(let r of s){if(d.has(t(r)))continue;let o={kind:e,key:t(r),name:n(r),path:[]},s=g(r);s===`changed`?a.push({...o,mine:void 0,theirs:r}):s===void 0&&(m.push(r),i.push(o))}return{held:m,starts:h}},s=o(`agent`,x,e=>e.identity.agentId,e.agents,e.starts.agents,r.agents,r.starts.agents,n?.agents),c=o(`tool`,x,e=>e.toolName,e.toolSpecs,e.starts.tools,r.toolSpecs,r.starts.tools,n?.toolSpecs),l=o(`provider`,S,S,e.providers,e.starts.providers,r.providers,r.starts.providers,n?.providers);return{workspace:K({...e,agents:s.held,toolSpecs:c.held,providers:l.held,starts:{agents:s.starts,tools:c.starts,providers:l.starts}}),updated:i,conflicts:a,files:r}}var q=Object.freeze({gone:!0});function J(e){if(Array.isArray(e))return e.filter(e=>e!==q).map(J);if(!P(e))return e;let t=Object.entries(e).map(([e,t])=>[e,J(t)]);return Object.fromEntries(t)}function Y(e,t,n){let[r,...i]=t;if(r===void 0)return n;if(Array.isArray(e))return typeof r==`number`&&r>=e.length?n===void 0?e:[...e,n]:e.map((e,t)=>t===r?i.length===0&&n===void 0?q:Y(e,i,n):e);let a={...P(e)?e:{}},o=Y(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function ge(e,t){let{agents:n,toolSpecs:r,providers:i}=e.workspace,a={agents:{...e.workspace.starts.agents},tools:{...e.workspace.starts.tools},providers:{...e.workspace.starts.providers}},o=(e,t,n,r)=>r.path.length>0?t.map(t=>e(t)===r.key?Y(t,r.path,r.theirs):t):r.theirs===void 0?(delete n[r.key],t.filter(t=>e(t)!==r.key)):(n[r.key]=r.theirs,[...t,r.theirs]);for(let s of new Set(t)){let t=e.conflicts[s];if(t){if(t.kind===`tool`)r=o(x,r,a.tools,t);else if(t.kind===`provider`)i=o(S,i,a.providers,t);else{if(n=o(x,n,a.agents,t),t.path.length>0||t.theirs===void 0)continue;let i=new Set(r.map(e=>e.key)),s=e.files.toolSpecs.filter(e=>e.toolType===`agent`&&e.agentKey===t.key&&!i.has(e.key));for(let e of s)a.tools[e.key]=e;r=[...r,...s],n=n.map(t=>{let n=e.files.agents.find(e=>e.key===t.key)?.tools.allow??[],r=s.map(e=>e.key).filter(e=>n.includes(e)&&!t.tools.allow.includes(e));return r.length?{...t,tools:{...t.tools,allow:[...t.tools.allow,...r]}}:t})}}}return[n,r]=[J(n),J(r)],K({...e.workspace,agents:n,toolSpecs:r,providers:i,starts:a})}function X(t,n){let r=t.starts.tools[n],i=t.toolSpecs.find(e=>e.key===n);if(!r||!i)return t;let a=t.toolSpecs.filter(e=>e.key!==n).map(e=>e.toolName),o={...r,toolName:e(r.toolName,a,e=>`${r.toolName}_${e}`)};return j(o,i)?t:{...t,toolSpecs:t.toolSpecs.map(e=>e.key===n?o:e)}}function Z(e,t){let n=e.providers.find(e=>e.id===t.id);return!n||j(n,t)?e:{...e,providers:e.providers.map(e=>e.id===t.id?t:e)}}function Q(e,t){let n=e.agents.map(e=>w(e).filter(e=>e===t).length);return{models:n.reduce((e,t)=>e+t,0),agents:n.filter(e=>e>0).length}}function _e(e,t,n,r,i){let a=e=>e.provider===r&&e.apiId.trim()===i.trim();return{models:(e.agents.find(e=>e.key===t)?.modelBindings??[]).filter(e=>e.key!==n&&a(e)).map(e=>e.modelId.trim()||`Unnamed model`),agents:e.agents.filter(e=>e.key!==t&&e.modelBindings.some(a)).map(e=>e.identity.agentId.trim()||`Unnamed agent`)}}function ve(t,n){return{id:e(`provider`,t,e=>`provider_${e}`),definition:n,connection:{}}}function ye(e,t){return e.providers.some(e=>e.id===t.id)?e:C({...e,providers:[...e.providers,t],selected:o(t.id)})}function be(e,t){return!e.providers.some(e=>e.id===t)||Q(e,t).models>0?e:C({...e,providers:e.providers.filter(e=>e.id!==t),selected:e.selected===o(t)?p(e.agents[0]?.key??``):e.selected})}function xe(e,t,n){let r=n.trim();if(!e.providers.some(e=>e.id===t)||!r||e.providers.some(e=>e.id===r))return e;let{[t]:i,...a}=e.starts.providers,s=e=>e.provider===t;return{...e,providers:e.providers.map(e=>e.id===t?{...e,id:r}:e),agents:e.agents.map(e=>e.modelBindings.some(s)?{...e,modelBindings:e.modelBindings.map(e=>s(e)?{...e,provider:r}:e)}:e),selected:e.selected===o(t)?o(r):e.selected,starts:{...e.starts,providers:i?{...a,[r]:{...i,id:r}}:a}}}function Se(e){return e.providers.flatMap(t=>{let n=e.starts.providers[t.id];return n&&j(n,t)?[t.id]:[]})}function Ce(e,t){let n=e.starts.providers[t];return n?Z(e,n):e}function $(e,t){return{...t,id:p(e,t.id),children:t.children.map(t=>$(e,t))}}function we(e,n){return $(e.key,t(_(e,[],n)))}function Te(e){return{agents:e.agents.map(t=>we(t,e.providers)),tools:n(e.toolSpecs)}}export{ge as A,le as C,k as D,h as E,Te as F,d as I,Z as M,E as N,se as O,g as P,F as S,Ce as T,O as _,oe as a,xe as b,R as c,he as d,_e as f,L as g,Se as h,p as i,ie as j,ne as k,re as l,Q as m,ye as n,D as o,ve as p,ee as r,z as s,ae as t,T as u,A as v,X as w,I as x,be as y};
package/page/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%23000'/%3E%3Cg transform='translate(4 4)' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4.5 18.5c2 0 3-1.2 4.2-3.4l2.6-5c1-1.9 2.1-3.1 4.2-3.1'/%3E%3Cpath d='M5.5 8.2c1.6-.9 3.2-.4 3.8 1.6l2.3 6.6c.6 1.7 2.1 2.4 3.9 1.7'/%3E%3Ccircle cx='19.5' cy='4.5' r='1.6' fill='%23fff' stroke='none'/%3E%3C/g%3E%3C/svg%3E"
11
11
  />
12
12
  <title>theorem studio</title>
13
- <script type="module" crossorigin src="/studio/assets/index-hSIwfi4j.js"></script>
13
+ <script type="module" crossorigin src="/studio/assets/index-C6pyNvXU.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/studio/assets/rolldown-runtime-hePW80VL.js">
15
15
  <link rel="modulepreload" crossorigin href="/studio/assets/themeProps-Bo2jNkIC.js">
16
16
  <link rel="modulepreload" crossorigin href="/studio/assets/coarsePointer-B10KWVuz.js">
@@ -82,14 +82,14 @@
82
82
  <link rel="modulepreload" crossorigin href="/studio/assets/IconAlertTriangle-CL88MFAk.js">
83
83
  <link rel="modulepreload" crossorigin href="/studio/assets/schemas-D7cgkv3L.js">
84
84
  <link rel="modulepreload" crossorigin href="/studio/assets/host-patterns-F-KZIzkF.js">
85
- <link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-BxGL5na3.js">
86
- <link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-Bfe2TkD-.js">
85
+ <link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-BxDmEUJe.js">
86
+ <link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-CnrGGkcr.js">
87
87
  <link rel="modulepreload" crossorigin href="/studio/assets/live-ingress-OuSlQ6q7.js">
88
- <link rel="modulepreload" crossorigin href="/studio/assets/tree-CMulctlY.js">
89
- <link rel="modulepreload" crossorigin href="/studio/assets/schema-DI2QKpYi.js">
90
- <link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-DzO00xRy.js">
91
- <link rel="modulepreload" crossorigin href="/studio/assets/types-7mVE39E8.js">
92
- <link rel="modulepreload" crossorigin href="/studio/assets/compile-oGEpwgkY.js">
88
+ <link rel="modulepreload" crossorigin href="/studio/assets/tree-CZVr90dg.js">
89
+ <link rel="modulepreload" crossorigin href="/studio/assets/schema-Do4wX6Sr.js">
90
+ <link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-BWOEEs03.js">
91
+ <link rel="modulepreload" crossorigin href="/studio/assets/types-DfwVnkMI.js">
92
+ <link rel="modulepreload" crossorigin href="/studio/assets/compile-C4Q50p5E.js">
93
93
  <link rel="modulepreload" crossorigin href="/studio/assets/row-keys-0Bn7ZyYy.js">
94
94
  <link rel="modulepreload" crossorigin href="/studio/assets/Center-CPu_uP6i.js">
95
95
  <link rel="modulepreload" crossorigin href="/studio/assets/IconFilter-DYCjUyWk.js">
@@ -97,10 +97,10 @@
97
97
  <link rel="modulepreload" crossorigin href="/studio/assets/IconSearch-BN1R3FIx.js">
98
98
  <link rel="modulepreload" crossorigin href="/studio/assets/IconTool-BHps7rbl.js">
99
99
  <link rel="modulepreload" crossorigin href="/studio/assets/trace-schema--4IGmLeE.js">
100
- <link rel="modulepreload" crossorigin href="/studio/assets/stub-CY0cuGPg.js">
101
- <link rel="modulepreload" crossorigin href="/studio/assets/reader-Bz6rc3qr.js">
102
- <link rel="modulepreload" crossorigin href="/studio/assets/registry-Bjkfo9zx.js">
103
- <link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-BPAKt_cc.js">
100
+ <link rel="modulepreload" crossorigin href="/studio/assets/stub-CUHiDLLw.js">
101
+ <link rel="modulepreload" crossorigin href="/studio/assets/reader-BZ-mDuss.js">
102
+ <link rel="modulepreload" crossorigin href="/studio/assets/registry-CqweoU_Q.js">
103
+ <link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-rFxtbMn0.js">
104
104
  <link rel="modulepreload" crossorigin href="/studio/assets/useCalendarSystem-Crg71MEB.js">
105
105
  <link rel="modulepreload" crossorigin href="/studio/assets/useLocale-CPtOawsd.js">
106
106
  <link rel="modulepreload" crossorigin href="/studio/assets/useClipboard-CE6Krn40.js">
@@ -111,12 +111,12 @@
111
111
  <link rel="modulepreload" crossorigin href="/studio/assets/IconWorld-DkkGLUyH.js">
112
112
  <link rel="modulepreload" crossorigin href="/studio/assets/type-icons-ImkV_hD4.js">
113
113
  <link rel="modulepreload" crossorigin href="/studio/assets/useAdaptivePresentation-D53OuCPm.js">
114
- <link rel="modulepreload" crossorigin href="/studio/assets/encode-files-Bn5i8t9U.js">
115
- <link rel="modulepreload" crossorigin href="/studio/assets/turn-client-sADYJHV9.js">
114
+ <link rel="modulepreload" crossorigin href="/studio/assets/encode-files-MPtLTYyk.js">
115
+ <link rel="modulepreload" crossorigin href="/studio/assets/turn-client-C_-rA6KF.js">
116
116
  <link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-Dd57a-0O.js">
117
117
  <link rel="modulepreload" crossorigin href="/studio/assets/fullEnglishFallback-Css2A5hC.js">
118
118
  <link rel="modulepreload" crossorigin href="/studio/assets/useTranslator-BKF5qhFP.js">
119
- <link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-D_7O3BSI.js">
119
+ <link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-BOmB5WmP.js">
120
120
  <link rel="modulepreload" crossorigin href="/studio/assets/rubberBand-urxgJfJ0.js">
121
121
  <link rel="modulepreload" crossorigin href="/studio/assets/LongPressGestureRecognizer-DsJzrIAQ.js">
122
122
  <link rel="modulepreload" crossorigin href="/studio/assets/arrive-DnkDKJb5.js">
@@ -135,20 +135,20 @@
135
135
  <link rel="modulepreload" crossorigin href="/studio/assets/useMenuOverflow-C6hNF-rg.js">
136
136
  <link rel="modulepreload" crossorigin href="/studio/assets/menuBottomSheet.stylex-BF-z_H3I.js">
137
137
  <link rel="modulepreload" crossorigin href="/studio/assets/MenuBottomSheetActionList-CZkxfDz5.js">
138
- <link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-kJvPbe2l.js">
139
- <link rel="modulepreload" crossorigin href="/studio/assets/Link-cEUGqR4E.js">
138
+ <link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-CdZPGyrH.js">
139
+ <link rel="modulepreload" crossorigin href="/studio/assets/Link-B8qtW9Me.js">
140
140
  <link rel="modulepreload" crossorigin href="/studio/assets/MetadataListItem-D_UEO4Yo.js">
141
141
  <link rel="modulepreload" crossorigin href="/studio/assets/ToggleButton-DS8nQhRT.js">
142
- <link rel="modulepreload" crossorigin href="/studio/assets/ShapedData-DYOCaGlk.js">
142
+ <link rel="modulepreload" crossorigin href="/studio/assets/ShapedData-DYRlNRy_.js">
143
143
  <link rel="modulepreload" crossorigin href="/studio/assets/Badge-BUFlIXVD.js">
144
144
  <link rel="modulepreload" crossorigin href="/studio/assets/useFocusReturnVisibility-Brk7Chog.js">
145
- <link rel="modulepreload" crossorigin href="/studio/assets/DropdownMenu-kC1ynF9P.js">
145
+ <link rel="modulepreload" crossorigin href="/studio/assets/DropdownMenu-CLdHjD_O.js">
146
146
  <link rel="modulepreload" crossorigin href="/studio/assets/inputStyles.stylex-CwhFgCYO.js">
147
147
  <link rel="modulepreload" crossorigin href="/studio/assets/textEntryTraits-C_EOnS4-.js">
148
148
  <link rel="modulepreload" crossorigin href="/studio/assets/TextInput-DwHcdc-E.js">
149
- <link rel="modulepreload" crossorigin href="/studio/assets/studio-media-CmbCThcX.js">
149
+ <link rel="modulepreload" crossorigin href="/studio/assets/studio-media-C6h3z2kJ.js">
150
150
  <link rel="modulepreload" crossorigin href="/studio/assets/project-address-DjxPZuyn.js">
151
- <link rel="modulepreload" crossorigin href="/studio/assets/workspace-BrQUhBOf.js">
151
+ <link rel="modulepreload" crossorigin href="/studio/assets/workspace-ChRm7M3S.js">
152
152
  <link rel="modulepreload" crossorigin href="/studio/assets/lent-keys-C32ems-I.js">
153
153
  <link rel="modulepreload" crossorigin href="/studio/assets/editors-BJX_S59A.js">
154
154
  <link rel="modulepreload" crossorigin href="/studio/assets/people-CIsR0-5R.js">