@theoremjs/studio 0.3.4-next.564.g1c809f3 → 0.3.4-next.574.g44edd0f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/draft.d.ts +4 -3
- package/draft.js +3 -3
- package/package.json +4 -4
- package/page/assets/{Banner-CvokwmJs.js → Banner-fCdA5xuX.js} +3 -3
- package/page/assets/{ConsoleFrame-BOv1vfrW.js → ConsoleFrame-DToEAKll.js} +1 -1
- package/page/assets/{ContextMenu-MX6G-zIw.js → ContextMenu-B8KwzKYT.js} +2 -2
- package/page/assets/{MenuBottomSheet-G0YEGuwB.js → MenuBottomSheet-zGHY1Qv9.js} +1 -1
- package/page/assets/{SchemaFields-BWiPEsi6.js → SchemaFields-BixBUjiA.js} +1 -1
- package/page/assets/{ToolResultCharts-CTtSmmHo.js → ToolResultCharts-CwFb9gvT.js} +1 -1
- package/page/assets/{TraceInspector-D4nm1IQs.js → TraceInspector-BiGZIuRD.js} +1 -1
- package/page/assets/{TraceOverview-BDlKWqWh.js → TraceOverview-CE_CJPgZ.js} +1 -1
- package/page/assets/{browser-engine-mguKgk0d.js → browser-engine-D8Z5HFdN.js} +1 -1
- package/page/assets/{browser-transport-CnYs0V1g.js → browser-transport-CK1pmgre.js} +3 -3
- package/page/assets/{export-agent-BC_vAtoD.js → export-agent-BaT6Ugod.js} +1 -1
- package/page/assets/{guardrail-tester-DjMbzwlC.js → guardrail-tester-BC2B451Y.js} +1 -1
- package/page/assets/{index-Cp6wHGPk.js → index-pTlbT5-H.js} +13 -13
- package/page/assets/{studio-code-pane-Dv_mn857.js → studio-code-pane-DabjL4ZW.js} +1 -1
- package/page/assets/{studio-console-DuyyMj7e.js → studio-console-0do1lZHL.js} +1 -1
- package/page/assets/{studio-decision-D4TFJJno.js → studio-decision-4s8gxCEw.js} +1 -1
- package/page/assets/{studio-embedding-D3ozp2_P.js → studio-embedding-Ca_LK3qT.js} +1 -1
- package/page/assets/{studio-host-console-De7qn_Of.js → studio-host-console-CpSBV3GL.js} +2 -2
- package/page/assets/{studio-labels-CkioGPIh.js → studio-labels-BEisLSYH.js} +1 -1
- package/page/assets/{studio-live-Do8eMTm1.js → studio-live-1hhXypVq.js} +1 -1
- package/page/assets/{studio-map-D_0GJjN3.js → studio-map-CLJrLzii.js} +1 -1
- package/page/assets/{studio-trace-replay-BpdaqshC.js → studio-trace-replay-BJ6EScXk.js} +1 -1
- package/page/assets/{tree-Cy9xwG_l.js → tree-BxJ7bZId.js} +1 -1
- package/page/assets/{use-one-call-BrJg1kZE.js → use-one-call-CWqJ5Ljp.js} +1 -1
- package/page/assets/{workspace-BFrc6kx2.js → workspace-D9otnmy3.js} +1 -1
- package/page/index.html +7 -7
- package/ui/acting-as-button.d.ts +3 -1
- package/ui/acting-as-button.js +5 -2
- package/ui/lib/panel-motion.d.ts +8 -4
- package/ui/lib/panel-motion.js +58 -33
- package/ui/lib/studio-restore.js +3 -1
- package/ui/profile-editor.js +46 -4
- package/ui/studio-screen.js +11 -17
- package/ui/studio-settings.js +3 -3
- package/ui/use-phone.d.ts +8 -0
- package/ui/use-phone.js +23 -1
|
@@ -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-Cy9xwG_l.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 ne(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 T(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 G(C({v:5,agents:[n],toolSpecs:e.toolSpecs,providers:e.providers,selected:h(n.key,t),chatWith:n.key,starts:{agents:{},tools:{},providers:{}}}))}function D(e,t){let n=e.agents.find(e=>e.key===t);return n&&{..._(n,[],e.providers),toolSpecs:e.toolSpecs}}function O(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 re(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 ie(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 ae(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 oe(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 se(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 k=(e,t)=>d(e)===d(t),A=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function ce(e){let{agents:t,tools:n,providers:r}=e.starts;return e.agents.every(e=>k(e,t[e.key]))&&e.toolSpecs.every(e=>k(e,n[e.key]))&&e.providers.every(e=>k(e,r[e.id]))&&Object.keys(n).length===e.toolSpecs.length}function le(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 ue(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 j(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=ue(r,d&&e(d,f,e=>`${d}_${e}`),u,a);if(c.length===0&&k(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 de(e,t,n){if(n.facet===`identity`)return j(e,t);if(n.facet===`toolSpec`)return Y(e,n.key);let r=j(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=fe(a,i,n);return k(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 fe(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:M(e,t,n.facet)}function M(e,t,n){return{...e,[n]:t[n]}}function N(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 P(e,t){let n=N(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=>k(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 F(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 I(e,t){return F(e)!==t}var L=/^(agent|model|tool|question|criterion|reference)-[0-9a-f]{8}$/;function R(e){let t=new Map;return JSON.stringify(e).replace(/\b(agent|model|tool|question|criterion|reference)-[0-9a-f]{8}\b/g,e=>(t.has(e)||t.set(e,`#${t.size}`),t.get(e)??e))}function z(e,t){let n=t.map(R),r=new Set,i=[],a=[];for(let o of e){let e=R(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 B(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&&R(i(l))===R(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 V(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 z(e,t))i(n,r);else if(A(e)&&A(t))for(let[n,a]of Object.entries(e)){let e=t[n];n===`key`?typeof a==`string`&&typeof e==`string`&&a!==e&&L.test(a)&&L.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 H=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)&&new Set(e).size===e.length,U=e=>Array.isArray(e)&&e.every(e=>A(e)&&typeof e.key==`string`);function W(e,t,n,r,i){if(k(e,n)||k(t,n))return t;if(A(e)&&A(t)&&A(n)){let a={};for(let o of new Set([...Object.keys(n),...Object.keys(t),...Object.keys(e)])){let s=W(e[o],t[o],n[o],[...r,o],i);s!==void 0&&(a[o]=s)}return a}if(U(e)&&U(t)&&U(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(W(t,e,n,c,i)):k(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?k(e,t)||i.conflict([...r,l++],void 0,e):(i.updated([...r,s.length]),s.push(e),l+=1)}return s}if(k(e,t))return i.updated(r),n;if(H(e)&&H(t)&&H(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 G(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 k(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 pe(e,t,n){let r=V(B(N(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(W(r,s,c,[],{updated:e=>i.push({...l,path:e}),conflict:(e,t,n)=>a.push({...l,path:e,mine:t,theirs:n})})):k(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 R(r)===R(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:G({...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 K=Object.freeze({gone:!0});function q(e){if(Array.isArray(e))return e.filter(e=>e!==K).map(q);if(!A(e))return e;let t=Object.entries(e).map(([e,t])=>[e,q(t)]);return Object.fromEntries(t)}function J(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?K:J(e,i,n):e);let a={...A(e)?e:{}},o=J(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function me(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?J(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]=[q(n),q(r)],G({...e.workspace,agents:n,toolSpecs:r,providers:i,starts:a})}function Y(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 k(o,i)?t:{...t,toolSpecs:t.toolSpecs.map(e=>e.key===n?o:e)}}function X(e,t){let n=e.providers.find(e=>e.id===t.id);return!n||k(n,t)?e:{...e,providers:e.providers.map(e=>e.id===t.id?t:e)}}function Z(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 Q(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()||`new`),agents:e.agents.filter(e=>e.key!==t&&e.modelBindings.some(a)).map(e=>e.identity.agentId.trim()||`New agent`)}}function he(t,n){return{id:e(`provider`,t,e=>`provider_${e}`),definition:n,connection:{}}}function ge(e,t){return e.providers.some(e=>e.id===t.id)?e:C({...e,providers:[...e.providers,t],selected:o(t.id)})}function _e(e,t){return!e.providers.some(e=>e.id===t)||Z(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 ve(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 ye(e){return e.providers.flatMap(t=>{let n=e.starts.providers[t.id];return n&&k(n,t)?[t.id]:[]})}function be(e,t){let n=e.starts.providers[t];return n?X(e,n):e}function $(e,t){return{...t,id:p(e,t.id),children:t.children.map(t=>$(e,t))}}function xe(e,n){let r=$(e.key,t(_(e,[],n)));return e.identity.agentId.trim()?r:{...r,label:`New agent`}}function Se(e){return{agents:e.agents.map(t=>xe(t,e.providers)),tools:n(e.toolSpecs)}}export{me as A,de as C,oe as D,h as E,Se as F,d as I,X as M,E as N,le as O,g as P,j as S,be as T,ae as _,ce as a,ve as b,F as c,pe as d,Q as f,P as g,ye as h,p as i,O as j,T as k,D as l,Z as m,ge as n,ie as o,he as p,ee as r,I as s,re as t,ne as u,se as v,Y as w,N as x,_e 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-BxJ7bZId.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 ne(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 T(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 G(C({v:5,agents:[n],toolSpecs:e.toolSpecs,providers:e.providers,selected:h(n.key,t),chatWith:n.key,starts:{agents:{},tools:{},providers:{}}}))}function D(e,t){let n=e.agents.find(e=>e.key===t);return n&&{..._(n,[],e.providers),toolSpecs:e.toolSpecs}}function O(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 re(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 ie(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 ae(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 oe(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 se(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 k=(e,t)=>d(e)===d(t),A=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function ce(e){let{agents:t,tools:n,providers:r}=e.starts;return e.agents.every(e=>k(e,t[e.key]))&&e.toolSpecs.every(e=>k(e,n[e.key]))&&e.providers.every(e=>k(e,r[e.id]))&&Object.keys(n).length===e.toolSpecs.length}function le(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 ue(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 j(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=ue(r,d&&e(d,f,e=>`${d}_${e}`),u,a);if(c.length===0&&k(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 de(e,t,n){if(n.facet===`identity`)return j(e,t);if(n.facet===`toolSpec`)return Y(e,n.key);let r=j(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=fe(a,i,n);return k(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 fe(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:M(e,t,n.facet)}function M(e,t,n){return{...e,[n]:t[n]}}function N(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 P(e,t){let n=N(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=>k(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 F(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 I(e,t){return F(e)!==t}var L=/^(agent|model|tool|question|criterion|reference)-[0-9a-f]{8}$/;function R(e){let t=new Map;return JSON.stringify(e).replace(/\b(agent|model|tool|question|criterion|reference)-[0-9a-f]{8}\b/g,e=>(t.has(e)||t.set(e,`#${t.size}`),t.get(e)??e))}function z(e,t){let n=t.map(R),r=new Set,i=[],a=[];for(let o of e){let e=R(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 B(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&&R(i(l))===R(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 V(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 z(e,t))i(n,r);else if(A(e)&&A(t))for(let[n,a]of Object.entries(e)){let e=t[n];n===`key`?typeof a==`string`&&typeof e==`string`&&a!==e&&L.test(a)&&L.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 H=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)&&new Set(e).size===e.length,U=e=>Array.isArray(e)&&e.every(e=>A(e)&&typeof e.key==`string`);function W(e,t,n,r,i){if(k(e,n)||k(t,n))return t;if(A(e)&&A(t)&&A(n)){let a={};for(let o of new Set([...Object.keys(n),...Object.keys(t),...Object.keys(e)])){let s=W(e[o],t[o],n[o],[...r,o],i);s!==void 0&&(a[o]=s)}return a}if(U(e)&&U(t)&&U(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(W(t,e,n,c,i)):k(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?k(e,t)||i.conflict([...r,l++],void 0,e):(i.updated([...r,s.length]),s.push(e),l+=1)}return s}if(k(e,t))return i.updated(r),n;if(H(e)&&H(t)&&H(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 G(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 k(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 pe(e,t,n){let r=V(B(N(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(W(r,s,c,[],{updated:e=>i.push({...l,path:e}),conflict:(e,t,n)=>a.push({...l,path:e,mine:t,theirs:n})})):k(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 R(r)===R(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:G({...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 K=Object.freeze({gone:!0});function q(e){if(Array.isArray(e))return e.filter(e=>e!==K).map(q);if(!A(e))return e;let t=Object.entries(e).map(([e,t])=>[e,q(t)]);return Object.fromEntries(t)}function J(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?K:J(e,i,n):e);let a={...A(e)?e:{}},o=J(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function me(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?J(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]=[q(n),q(r)],G({...e.workspace,agents:n,toolSpecs:r,providers:i,starts:a})}function Y(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 k(o,i)?t:{...t,toolSpecs:t.toolSpecs.map(e=>e.key===n?o:e)}}function X(e,t){let n=e.providers.find(e=>e.id===t.id);return!n||k(n,t)?e:{...e,providers:e.providers.map(e=>e.id===t.id?t:e)}}function Z(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 Q(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()||`new`),agents:e.agents.filter(e=>e.key!==t&&e.modelBindings.some(a)).map(e=>e.identity.agentId.trim()||`New agent`)}}function he(t,n){return{id:e(`provider`,t,e=>`provider_${e}`),definition:n,connection:{}}}function ge(e,t){return e.providers.some(e=>e.id===t.id)?e:C({...e,providers:[...e.providers,t],selected:o(t.id)})}function _e(e,t){return!e.providers.some(e=>e.id===t)||Z(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 ve(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 ye(e){return e.providers.flatMap(t=>{let n=e.starts.providers[t.id];return n&&k(n,t)?[t.id]:[]})}function be(e,t){let n=e.starts.providers[t];return n?X(e,n):e}function $(e,t){return{...t,id:p(e,t.id),children:t.children.map(t=>$(e,t))}}function xe(e,n){let r=$(e.key,t(_(e,[],n)));return e.identity.agentId.trim()?r:{...r,label:`New agent`}}function Se(e){return{agents:e.agents.map(t=>xe(t,e.providers)),tools:n(e.toolSpecs)}}export{me as A,de as C,oe as D,h as E,Se as F,d as I,X as M,E as N,le as O,g as P,j as S,be as T,ae as _,ce as a,ve as b,F as c,pe as d,Q as f,P as g,ye as h,p as i,O as j,T as k,D as l,Z as m,ge as n,ie as o,he as p,ee as r,I as s,re as t,ne as u,se as v,Y as w,N as x,_e 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-
|
|
13
|
+
<script type="module" crossorigin src="/studio/assets/index-pTlbT5-H.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-3IqahpCr.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/studio/assets/tokens.stylex-DkHf0P9C.js">
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
<link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-AVV4e7rW.js">
|
|
53
53
|
<link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-DCF2M0n_.js">
|
|
54
54
|
<link rel="modulepreload" crossorigin href="/studio/assets/live-ingress-OuSlQ6q7.js">
|
|
55
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/tree-
|
|
55
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/tree-BxJ7bZId.js">
|
|
56
56
|
<link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-D9jsfxnA.js">
|
|
57
57
|
<link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-DQqJ4pIV.js">
|
|
58
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/Banner-
|
|
58
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/Banner-fCdA5xuX.js">
|
|
59
59
|
<link rel="modulepreload" crossorigin href="/studio/assets/arrive-DvbqpeRS.js">
|
|
60
60
|
<link rel="modulepreload" crossorigin href="/studio/assets/Center-nHS1JSux.js">
|
|
61
61
|
<link rel="modulepreload" crossorigin href="/studio/assets/IconSearch-BTx66a40.js">
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
<link rel="modulepreload" crossorigin href="/studio/assets/stub-BMUhx6B5.js">
|
|
64
64
|
<link rel="modulepreload" crossorigin href="/studio/assets/reader-Cn4QuGp2.js">
|
|
65
65
|
<link rel="modulepreload" crossorigin href="/studio/assets/useContainerReveal-BFy8N_QU.js">
|
|
66
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-
|
|
66
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-CK1pmgre.js">
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/studio/assets/focusReturn-CTppP2k0.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/studio/assets/CheckboxInput-CFZ_Wq8-.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/studio/assets/chainEventHandlers-C6ttXGfW.js">
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
<link rel="modulepreload" crossorigin href="/studio/assets/encode-files-BCf3-Q7y.js">
|
|
76
76
|
<link rel="modulepreload" crossorigin href="/studio/assets/turn-client-CFuTLOCL.js">
|
|
77
77
|
<link rel="modulepreload" crossorigin href="/studio/assets/CollapsibleGroup-FIawJRo4.js">
|
|
78
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-
|
|
78
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-BEisLSYH.js">
|
|
79
79
|
<link rel="modulepreload" crossorigin href="/studio/assets/crypto-CrMpJY2D.js">
|
|
80
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/workspace-
|
|
80
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/workspace-D9otnmy3.js">
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/studio/assets/lent-keys-C32ems-I.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/studio/assets/editors-BJX_S59A.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/studio/assets/studio-session-yEqFQo5o.js">
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
<link rel="modulepreload" crossorigin href="/studio/assets/ListItem-QF7KFt0h.js">
|
|
87
87
|
<link rel="modulepreload" crossorigin href="/studio/assets/MenuBottomSheetActionList-3L0HS4Kf.js">
|
|
88
88
|
<link rel="modulepreload" crossorigin href="/studio/assets/useAdaptivePresentation-Bma4-u1a.js">
|
|
89
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-
|
|
89
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-B8KwzKYT.js">
|
|
90
90
|
<link rel="modulepreload" crossorigin href="/studio/assets/useFocusReturnVisibility-BHKv5Jwr.js">
|
|
91
91
|
<link rel="stylesheet" crossorigin href="/studio/assets/use-second-ticker-GWBt83pd.css">
|
|
92
92
|
<link rel="stylesheet" crossorigin href="/studio/assets/index-C9rhrCGT.css">
|
package/ui/acting-as-button.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/** Who runs act as, in the chat's header: opens the People settings, where the pick is made. */
|
|
2
|
-
export declare function ActingAsButton(
|
|
2
|
+
export declare function ActingAsButton({ isIconOnly }: {
|
|
3
|
+
isIconOnly: boolean;
|
|
4
|
+
}): import("react").JSX.Element | null;
|
package/ui/acting-as-button.js
CHANGED
|
@@ -5,12 +5,15 @@ import { IconUser } from '@tabler/icons-react';
|
|
|
5
5
|
import { useActingAs } from "./lib/acting-as.js";
|
|
6
6
|
import { openSettings } from "./lib/studio-settings.js";
|
|
7
7
|
/** Who runs act as, in the chat's header: opens the People settings, where the pick is made. */
|
|
8
|
-
export function ActingAsButton() {
|
|
8
|
+
export function ActingAsButton({ isIconOnly }) {
|
|
9
9
|
const { offer, problem, actingAs } = useActingAs();
|
|
10
10
|
if (!offer && !problem)
|
|
11
11
|
return null;
|
|
12
12
|
const place = actingAs && offer?.places.find((each) => each.id === actingAs.place);
|
|
13
|
-
|
|
13
|
+
const who = actingAs && `${actingAs.person.label} · ${place?.label ?? actingAs.place}`;
|
|
14
|
+
return (_jsx(Button, { label: who ? `As: ${who}` : 'No one', isIconOnly: isIconOnly, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconUser, size: "sm" }),
|
|
15
|
+
// why: with only the icon showing, the tooltip is the one place that says who.
|
|
16
|
+
tooltip: isIconOnly ? `Acting as ${who ?? 'no one'}` : 'Who this run acts as', onClick: () => {
|
|
14
17
|
openSettings('people');
|
|
15
18
|
} }));
|
|
16
19
|
}
|
package/ui/lib/panel-motion.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
/** What the panel shows: the map beside the editor, Settings in place of both, or neither. */
|
|
2
|
+
export interface PanelView {
|
|
3
|
+
map: boolean;
|
|
4
|
+
settings: boolean;
|
|
5
|
+
}
|
|
1
6
|
/** A phone's panel already takes the frame, and reduced motion moves nothing. */
|
|
2
7
|
export declare function panelCanMove(): boolean;
|
|
3
8
|
/**
|
|
4
|
-
* Move the panel around `swap`, which puts
|
|
5
|
-
* time it returns.
|
|
6
|
-
* panel to move, the swap happens at once.
|
|
9
|
+
* Move the panel from `from` to `to` around `swap`, which puts `to` on screen and must have drawn
|
|
10
|
+
* it by the time it returns. Without a panel to move, the swap happens at once.
|
|
7
11
|
*/
|
|
8
|
-
export declare function movePanel(
|
|
12
|
+
export declare function movePanel(from: PanelView, to: PanelView, swap: () => void): Promise<void>;
|
package/ui/lib/panel-motion.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The panel takes the whole frame for the map or Settings, and gives it back.
|
|
3
|
-
* out, the panel's far edge moves
|
|
4
|
-
*
|
|
2
|
+
* The panel takes the whole frame for the map or Settings, and gives it back. What is on screen
|
|
3
|
+
* and will not stay eases out, the panel's far edge moves if its width changes, and what comes in
|
|
4
|
+
* eases in. The nav column is the studio's and Settings' both: its frame and head stay, and only
|
|
5
|
+
* the list under the head crosses.
|
|
5
6
|
*/
|
|
6
7
|
import { HOLD_MS, prefersReducedMotion, sleep } from "../shell-motion.js";
|
|
7
8
|
const MOVE_MS = 640;
|
|
8
9
|
const FADE_MS = 280;
|
|
9
10
|
const EASE = 'cubic-bezier(0.45, 0.02, 0.15, 1)';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const PARTS = {
|
|
12
|
+
tree: '.studio-tree .studio-nav-head ~ *',
|
|
13
|
+
editor: '.studio-view',
|
|
14
|
+
handle: '.studio-side-handle',
|
|
15
|
+
preview: '.studio-preview',
|
|
16
|
+
map: '.studio-map-pane, .studio-map-handle',
|
|
17
|
+
settingsNav: '.studio-settings .studio-nav-head ~ *, .studio-settings-tree',
|
|
18
|
+
settings: '.studio-settings-main',
|
|
19
|
+
};
|
|
20
|
+
function shown(view) {
|
|
21
|
+
if (view.settings)
|
|
22
|
+
return ['settingsNav', 'settings'];
|
|
23
|
+
if (view.map)
|
|
24
|
+
return ['tree', 'editor', 'map'];
|
|
25
|
+
return ['tree', 'editor', 'handle', 'preview'];
|
|
26
|
+
}
|
|
27
|
+
const isWide = (view) => view.map || view.settings;
|
|
14
28
|
/** A phone's panel already takes the frame, and reduced motion moves nothing. */
|
|
15
29
|
export function panelCanMove() {
|
|
16
30
|
return globalThis.matchMedia('(min-width: 768px)').matches && !prefersReducedMotion();
|
|
@@ -21,54 +35,65 @@ function ended(animations, ms) {
|
|
|
21
35
|
return Promise.race([all, sleep(ms + 200)]);
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
24
|
-
* Move the panel around `swap`, which puts
|
|
25
|
-
* time it returns.
|
|
26
|
-
* panel to move, the swap happens at once.
|
|
38
|
+
* Move the panel from `from` to `to` around `swap`, which puts `to` on screen and must have drawn
|
|
39
|
+
* it by the time it returns. Without a panel to move, the swap happens at once.
|
|
27
40
|
*/
|
|
28
|
-
export async function movePanel(
|
|
41
|
+
export async function movePanel(from, to, swap) {
|
|
29
42
|
const frame = document.querySelector('.studio-frame');
|
|
30
43
|
const surface = frame?.querySelector('[data-shell-frame]');
|
|
31
44
|
if (!frame || !surface || !panelCanMove()) {
|
|
32
45
|
swap();
|
|
33
46
|
return;
|
|
34
47
|
}
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
48
|
+
const find = (parts) => parts.flatMap((part) => [...frame.querySelectorAll(PARTS[part])]);
|
|
49
|
+
const before = shown(from);
|
|
50
|
+
const after = shown(to);
|
|
51
|
+
const leaving = find(before.filter((part) => !after.includes(part)));
|
|
52
|
+
const coming = after.filter((part) => !before.includes(part));
|
|
53
|
+
const held = [];
|
|
54
|
+
const hold = (els) => {
|
|
55
|
+
for (const each of els) {
|
|
56
|
+
held.push(each.animate({ opacity: [0, 0] }, { duration: MOVE_MS, fill: 'forwards' }));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const out = leaving.map((each) => each.animate({ opacity: [1, 0] }, { duration: HOLD_MS, easing: 'ease', fill: 'forwards' }));
|
|
60
|
+
await ended(out, HOLD_MS);
|
|
38
61
|
// The panel is drawn at its full width, cut back to the width it rests at: only the cut moves.
|
|
39
62
|
// The corners are the raised surface's own, which the frame wraps.
|
|
40
63
|
const drawn = surface.firstElementChild ?? surface;
|
|
41
64
|
const round = getComputedStyle(drawn).borderTopRightRadius || '0px';
|
|
42
65
|
const cut = (width) => `inset(0 calc(100% - ${String(width)}px) 0 0 round ${round})`;
|
|
43
66
|
const whole = `inset(0 0 0 0 round ${round})`;
|
|
44
|
-
|
|
67
|
+
const swapHidden = () => {
|
|
68
|
+
swap();
|
|
69
|
+
// invariant: what comes in is held out of sight in the same task as the swap, before a paint.
|
|
70
|
+
hold(find(coming));
|
|
71
|
+
};
|
|
72
|
+
let move;
|
|
73
|
+
if (isWide(to) && !isWide(from)) {
|
|
45
74
|
const narrow = surface.offsetWidth;
|
|
46
75
|
surface.dataset.rests = String(narrow);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const fades = [...incoming].map((each) => each.animate({ opacity: [0, 1] }, { duration: MOVE_MS, easing: EASE, fill: 'both' }));
|
|
51
|
-
await ended([move, ...fades], MOVE_MS);
|
|
52
|
-
move.cancel();
|
|
53
|
-
for (const each of fades)
|
|
54
|
-
each.cancel();
|
|
76
|
+
move = surface.animate({ clipPath: [cut(narrow), whole] }, { duration: MOVE_MS, easing: EASE, fill: 'both' });
|
|
77
|
+
swapHidden();
|
|
78
|
+
await ended([move], MOVE_MS);
|
|
55
79
|
}
|
|
56
|
-
else {
|
|
80
|
+
else if (!isWide(to) && isWide(from)) {
|
|
57
81
|
const narrow = Number(surface.dataset.rests);
|
|
58
82
|
delete surface.dataset.rests;
|
|
59
83
|
if (narrow > 0) {
|
|
60
|
-
|
|
84
|
+
move = surface.animate({ clipPath: [whole, cut(narrow)] }, { duration: MOVE_MS, easing: EASE, fill: 'both' });
|
|
61
85
|
await ended([move], MOVE_MS);
|
|
62
|
-
swap();
|
|
63
|
-
move.cancel();
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
swap();
|
|
67
86
|
}
|
|
87
|
+
swapHidden();
|
|
68
88
|
}
|
|
69
|
-
|
|
70
|
-
|
|
89
|
+
else {
|
|
90
|
+
swapHidden();
|
|
71
91
|
}
|
|
72
|
-
|
|
92
|
+
const fades = find(coming).map((each) => each.animate({ opacity: [0, 1] }, { duration: FADE_MS, easing: EASE, fill: 'backwards' }));
|
|
93
|
+
for (const each of held)
|
|
94
|
+
each.cancel();
|
|
95
|
+
move?.cancel();
|
|
96
|
+
await ended(fades, FADE_MS);
|
|
97
|
+
for (const each of out)
|
|
73
98
|
each.cancel();
|
|
74
99
|
}
|
package/ui/lib/studio-restore.js
CHANGED
|
@@ -40,12 +40,14 @@ function isWorkspace(value) {
|
|
|
40
40
|
if (!isRecord(starts.providers))
|
|
41
41
|
return false;
|
|
42
42
|
const blank = createBlankDraft();
|
|
43
|
+
// why: a scrub switch is on, off, or whose patterns clean the trace; only the record is checked.
|
|
44
|
+
const shape = { ...blank, observability: { ...blank.observability, scrub: {} } };
|
|
43
45
|
const workspace = value;
|
|
44
46
|
return agents.every((agent) => isRecord(agent) &&
|
|
45
47
|
typeof agent.key === 'string' &&
|
|
46
48
|
isRecord(agent.tools) &&
|
|
47
49
|
Array.isArray(agent.tools.allow) &&
|
|
48
|
-
hasShapeOf(agentDraft(workspace, agent.key),
|
|
50
|
+
hasShapeOf(agentDraft(workspace, agent.key), shape));
|
|
49
51
|
}
|
|
50
52
|
function isStoredWorkspace(value) {
|
|
51
53
|
return (isRecord(value) &&
|
package/ui/profile-editor.js
CHANGED
|
@@ -1717,11 +1717,52 @@ const INCLUDE_FLAGS = [
|
|
|
1717
1717
|
{ key: 'guardrailDecisions', label: 'Decisions' },
|
|
1718
1718
|
{ key: 'guardrailMatchPreview', label: 'Match preview' },
|
|
1719
1719
|
];
|
|
1720
|
-
const
|
|
1720
|
+
const SCRUB_ROWS = [
|
|
1721
1721
|
{ key: 'sensitive', label: 'Sensitive' },
|
|
1722
1722
|
{ key: 'injection', label: 'Injection' },
|
|
1723
1723
|
{ key: 'canary', label: 'Canary' },
|
|
1724
1724
|
];
|
|
1725
|
+
const SCRUB_CHOICES = [
|
|
1726
|
+
{ value: 'on', label: 'On', description: 'With the patterns each detector reads the turn with' },
|
|
1727
|
+
{
|
|
1728
|
+
value: 'both',
|
|
1729
|
+
label: "Theorem's and yours",
|
|
1730
|
+
description: 'Both sides, whatever the turn reads with',
|
|
1731
|
+
},
|
|
1732
|
+
{ value: 'theorem', label: "Theorem's only" },
|
|
1733
|
+
{
|
|
1734
|
+
value: 'host',
|
|
1735
|
+
label: 'Yours only',
|
|
1736
|
+
description: 'Your guardrails.detect patterns and detectors',
|
|
1737
|
+
},
|
|
1738
|
+
{ value: 'off', label: 'Off' },
|
|
1739
|
+
];
|
|
1740
|
+
// why: the canary is Theorem's, so only its side means anything.
|
|
1741
|
+
const CANARY_CHOICES = [
|
|
1742
|
+
{ value: 'on', label: 'On' },
|
|
1743
|
+
{ value: 'off', label: 'Off' },
|
|
1744
|
+
];
|
|
1745
|
+
/** The choice a scrub switch is: the object form names the sides, each on when left out. */
|
|
1746
|
+
function scrubChoice(name, value) {
|
|
1747
|
+
if (typeof value === 'boolean')
|
|
1748
|
+
return value ? 'on' : 'off';
|
|
1749
|
+
const theorem = value.theorem ?? true;
|
|
1750
|
+
if (name === 'canary')
|
|
1751
|
+
return theorem ? 'on' : 'off';
|
|
1752
|
+
const host = value.host ?? true;
|
|
1753
|
+
if (theorem && host)
|
|
1754
|
+
return 'both';
|
|
1755
|
+
if (theorem)
|
|
1756
|
+
return 'theorem';
|
|
1757
|
+
return host ? 'host' : 'off';
|
|
1758
|
+
}
|
|
1759
|
+
const SCRUB_SWITCHES = {
|
|
1760
|
+
on: true,
|
|
1761
|
+
both: { theorem: true, host: true },
|
|
1762
|
+
theorem: { theorem: true, host: false },
|
|
1763
|
+
host: { theorem: false, host: true },
|
|
1764
|
+
off: false,
|
|
1765
|
+
};
|
|
1725
1766
|
/** A set of on-or-off flags as one checklist: the ones on are checked. */
|
|
1726
1767
|
function FlagList({ label, path, flags, value, onChange, }) {
|
|
1727
1768
|
return (_jsx(CheckboxList, { label: label, isLabelHidden: true, density: "compact", value: flags.filter((flag) => value[flag.key]).map((flag) => flag.key), onChange: (checked) => {
|
|
@@ -1750,9 +1791,10 @@ function TracesSection({ observability, set }) {
|
|
|
1750
1791
|
function TraceContentSections({ observability, set }) {
|
|
1751
1792
|
return (_jsxs(_Fragment, { children: [_jsx(InspectorSection, { path: "observability.include", children: _jsx(FlagList, { label: "Keep", path: "observability.include", flags: INCLUDE_FLAGS, value: observability.include, onChange: (include) => {
|
|
1752
1793
|
set({ include });
|
|
1753
|
-
} }) }), _jsx(InspectorSection, { path: "observability.scrub", children: _jsx(
|
|
1754
|
-
|
|
1755
|
-
|
|
1794
|
+
} }) }), _jsx(InspectorSection, { path: "observability.scrub", children: SCRUB_ROWS.map(({ key, label }) => (_jsx(ChoiceRow, { label: label, path: `observability.scrub.${key}`, value: scrubChoice(key, observability.scrub[key]), options: key === 'canary' ? CANARY_CHOICES : SCRUB_CHOICES, onChange: (choice) => {
|
|
1795
|
+
if (choice)
|
|
1796
|
+
set({ scrub: { ...observability.scrub, [key]: SCRUB_SWITCHES[choice] } });
|
|
1797
|
+
} }, key))) })] }));
|
|
1756
1798
|
}
|
|
1757
1799
|
function TraceStorageSection({ observability, set }) {
|
|
1758
1800
|
return (_jsxs(InspectorSection, { title: "Storage", note: sectionNote('traces.storage'), children: [_jsx(NumberRow, { label: "Keep for", path: "observability.retainForDays", field: "retainForDays", units: "days", value: observability.retainForDays, isIntegerOnly: true, onChange: (retainForDays) => {
|
package/ui/studio-screen.js
CHANGED
|
@@ -66,7 +66,7 @@ import { StudioHostContext, useStudioHost, } from "./studio-host.js";
|
|
|
66
66
|
import { NAV_WIDTH } from "./studio-nav.js";
|
|
67
67
|
import { StudioRunner } from "./studio-runner.js";
|
|
68
68
|
import { ProjectSave, ProjectTokens, useProjectSave } from "./studio-save.js";
|
|
69
|
-
import {
|
|
69
|
+
import { useBelowDesktop } from "./use-phone.js";
|
|
70
70
|
// The tester, Settings, the map and the code view load when they first open, or once the page is idle.
|
|
71
71
|
const testerPanel = () => import("./guardrail-tester.js");
|
|
72
72
|
const settingsPanel = () => import("./studio-settings.js");
|
|
@@ -847,10 +847,9 @@ function useLeftIssues(issues, page, revealed) {
|
|
|
847
847
|
return { shown, leavePage };
|
|
848
848
|
}
|
|
849
849
|
/** Open in a new tab, for the agent being chatted with; off while the workspace has issues. */
|
|
850
|
-
function OpenInNewTabButton({ compiled, chattedId, blocked, connection, }) {
|
|
850
|
+
function OpenInNewTabButton({ compiled, chattedId, blocked, connection, isIconOnly, }) {
|
|
851
851
|
const project = useProject();
|
|
852
|
-
|
|
853
|
-
return (_jsx(Button, { label: "Open in a new tab", isIconOnly: phone, variant: "ghost", icon: _jsx(Icon, { icon: IconBrowserShare, size: "sm" }), isDisabled: !compiled, tooltip: blocked ??
|
|
852
|
+
return (_jsx(Button, { label: "Open in a new tab", isIconOnly: isIconOnly, variant: "ghost", icon: _jsx(Icon, { icon: IconBrowserShare, size: "sm" }), isDisabled: !compiled, tooltip: blocked ??
|
|
854
853
|
'Run this agent on a full page of its own, in a new tab, the way a person using it would see it', onClick: () => {
|
|
855
854
|
const run = compiled && workspaceRunAgent(compiled, chattedId);
|
|
856
855
|
if (run)
|
|
@@ -1365,8 +1364,8 @@ function offerEditsBack(toast, store, edits, key) {
|
|
|
1365
1364
|
});
|
|
1366
1365
|
setAside(key, edits);
|
|
1367
1366
|
}
|
|
1367
|
+
/** The panel at rest: neither the map nor Settings. */
|
|
1368
1368
|
const NARROW = { map: false, settings: false };
|
|
1369
|
-
const isWide = (panel) => panel.map || panel.settings;
|
|
1370
1369
|
/**
|
|
1371
1370
|
* Which view stands in the editor column, whether the map is open beside it, and opening a node
|
|
1372
1371
|
* there. The map takes the preview's place: the panel widens over it the way the shell moves after
|
|
@@ -1396,11 +1395,7 @@ function useEditorView(store) {
|
|
|
1396
1395
|
setSettings(to.settings);
|
|
1397
1396
|
});
|
|
1398
1397
|
};
|
|
1399
|
-
|
|
1400
|
-
if (isWide(to) === isWide(was))
|
|
1401
|
-
swap();
|
|
1402
|
-
else
|
|
1403
|
-
await movePanel(isWide(to), swap);
|
|
1398
|
+
await movePanel(was, to, swap);
|
|
1404
1399
|
});
|
|
1405
1400
|
}, []);
|
|
1406
1401
|
const setMapOpen = useCallback((next) => {
|
|
@@ -1519,7 +1514,7 @@ function SheetButton({ label, icon, sheet, setSheet, }) {
|
|
|
1519
1514
|
const TreeColumn = memo(function TreeColumn({ tree, draft, onAddAgent, listRef, setSheet, }) {
|
|
1520
1515
|
const project = useProject();
|
|
1521
1516
|
const { kernelVersion } = useStudioHost();
|
|
1522
|
-
return (_jsx(Section, { variant: "transparent", width: TREE_WIDTH, height: "100%", padding: 4, dividers: ['end'], children: _jsxs(VStack, { gap: 4, height: "100%", children: [_jsxs(HStack, { gap: 2, vAlign: "start", children: [_jsx(StackItem, { size: "fill", children: _jsxs(VStack, { gap: 1, children: [_jsx(Heading, { level: 3, children: "theorem studio" }), _jsx(Text, { type: "supporting", color: "secondary", children: `${project ? `${project.name} · ` : ''}@theoremjs/agents ${kernelVersion}` })] }) }), _jsx(SheetButton, { label: "Close sections", icon: IconX, sheet: null, setSheet: setSheet })] }), _jsx(StackItem, { size: "fill", children: _jsx(WorkspaceTreeLists, { tree: tree, draft: draft, onAddAgent: onAddAgent, listRef: listRef }) })] }) }));
|
|
1517
|
+
return (_jsx(Section, { variant: "transparent", width: TREE_WIDTH, height: "100%", padding: 4, dividers: ['end'], children: _jsxs(VStack, { gap: 4, height: "100%", children: [_jsxs(HStack, { gap: 2, vAlign: "start", className: "studio-nav-head", children: [_jsx(StackItem, { size: "fill", children: _jsxs(VStack, { gap: 1, children: [_jsx(Heading, { level: 3, children: "theorem studio" }), _jsx(Text, { type: "supporting", color: "secondary", children: `${project ? `${project.name} · ` : ''}@theoremjs/agents ${kernelVersion}` })] }) }), _jsx(SheetButton, { label: "Close sections", icon: IconX, sheet: null, setSheet: setSheet })] }), _jsx(StackItem, { size: "fill", children: _jsx(WorkspaceTreeLists, { tree: tree, draft: draft, onAddAgent: onAddAgent, listRef: listRef }) })] }) }));
|
|
1523
1518
|
});
|
|
1524
1519
|
/**
|
|
1525
1520
|
* The studio's editor for a workspace, open on its `selected` node: the toolbar, with the issue
|
|
@@ -1745,22 +1740,21 @@ function ClearHistoryButton({ run }) {
|
|
|
1745
1740
|
/** The types whose conversation a trace can hold, and so open and replay. */
|
|
1746
1741
|
const NO_CONVERSATION = new Set(['decision', 'host', 'embedding', 'live']);
|
|
1747
1742
|
/** Replay exchange, for a type whose conversation a trace holds. */
|
|
1748
|
-
function ReplayExchangeButton({ payload, tracing, }) {
|
|
1749
|
-
const phone = usePhone();
|
|
1743
|
+
function ReplayExchangeButton({ payload, tracing, isIconOnly, }) {
|
|
1750
1744
|
if (payload == null || NO_CONVERSATION.has(payload.profile.type))
|
|
1751
1745
|
return null;
|
|
1752
|
-
return (_jsx(Button, { label: tracing.open ? 'Close replay' : 'Replay exchange', isIconOnly:
|
|
1746
|
+
return (_jsx(Button, { label: tracing.open ? 'Close replay' : 'Replay exchange', isIconOnly: isIconOnly, variant: tracing.open ? 'secondary' : 'ghost', tooltip: tracing.open
|
|
1753
1747
|
? 'Back to the live conversation'
|
|
1754
1748
|
: 'Open a recorded conversation (a .trace.json file) to see what happened, then replay its messages through this agent as it is now and compare', icon: _jsx(Icon, { icon: IconFileImport, size: "sm" }), "aria-pressed": tracing.open, onClick: tracing.toggle }));
|
|
1755
1749
|
}
|
|
1756
1750
|
/** The preview's header: back to the editor, the agent to chat with, history, trace, and Export. */
|
|
1757
1751
|
function PreviewHeader({ store, chatAgents, chatWith, compile, run, connection, trace, testing, tracing, setSheet, }) {
|
|
1758
1752
|
const traceLabel = trace.open ? 'Hide trace' : 'View trace';
|
|
1759
|
-
const
|
|
1753
|
+
const { ref, below: iconsOnly } = useBelowDesktop();
|
|
1760
1754
|
const { compiled } = compile;
|
|
1761
|
-
return (_jsx(Section, { variant: "transparent", paddingInline: 3, paddingBlock: 0, children: _jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(SheetButton, { label: "Back to the editor", icon: IconArrowLeft, sheet: null, setSheet: setSheet }), _jsx(StackItem, { size: "fill", children: _jsx(ChatPicker, { agents: chatAgents, chatWith: chatWith, onChange: store.chatWith }) }), _jsx(StackItem, { size: "static", children: _jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx(ActingAsButton, {}), compile.payload && run.isUsed && !testing && !tracing.open && (_jsx(ClearHistoryButton, { run: run })), !testing && _jsx(ReplayExchangeButton, { payload: compile.payload, tracing: tracing }), (compile.traced || tracing.open) && !testing ? (_jsx(Button, { label: traceLabel, isIconOnly:
|
|
1755
|
+
return (_jsx(Section, { ref: ref, variant: "transparent", paddingInline: 3, paddingBlock: 0, children: _jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(SheetButton, { label: "Back to the editor", icon: IconArrowLeft, sheet: null, setSheet: setSheet }), _jsx(StackItem, { size: "fill", children: _jsx(ChatPicker, { agents: chatAgents, chatWith: chatWith, onChange: store.chatWith }) }), _jsx(StackItem, { size: "static", children: _jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx(ActingAsButton, { isIconOnly: iconsOnly }), compile.payload && run.isUsed && !testing && !tracing.open && (_jsx(ClearHistoryButton, { run: run })), !testing && (_jsx(ReplayExchangeButton, { payload: compile.payload, tracing: tracing, isIconOnly: iconsOnly })), (compile.traced || tracing.open) && !testing ? (_jsx(Button, { label: traceLabel, isIconOnly: iconsOnly, variant: trace.open ? 'secondary' : 'ghost', tooltip: trace.open
|
|
1762
1756
|
? 'Close the trace'
|
|
1763
|
-
: 'See how each reply was made, step by step: every model and tool call, guardrail check and gate, with its timing', icon: _jsx(Icon, { icon: IconActivity, size: "sm" }), "aria-pressed": trace.open, onClick: trace.toggle })) : null, _jsx(OpenInNewTabButton, { compiled: compiled.ok ? compiled : undefined, chattedId: compile.chattedId, blocked: compile.blocked, connection: {
|
|
1757
|
+
: 'See how each reply was made, step by step: every model and tool call, guardrail check and gate, with its timing', icon: _jsx(Icon, { icon: IconActivity, size: "sm" }), "aria-pressed": trace.open, onClick: trace.toggle })) : null, _jsx(OpenInNewTabButton, { isIconOnly: iconsOnly, compiled: compiled.ok ? compiled : undefined, chattedId: compile.chattedId, blocked: compile.blocked, connection: {
|
|
1764
1758
|
connectionMode: connection.mode,
|
|
1765
1759
|
localBaseUrl: connection.local.baseUrl,
|
|
1766
1760
|
} })] }) })] }) }));
|
package/ui/studio-settings.js
CHANGED
|
@@ -262,7 +262,7 @@ function SectionBody({ section, ...props }) {
|
|
|
262
262
|
const isSection = (value) => SETTINGS_SECTIONS.includes(value);
|
|
263
263
|
/** The nav's head, as the studio's tree and the docs head theirs: the name, what is open, then the search. */
|
|
264
264
|
function SettingsNavHead({ project, version }) {
|
|
265
|
-
return (_jsxs(VStack, { gap: 4, children: [_jsxs(VStack, { gap: 1, children: [_jsx(Heading, { level: 3, children: "theorem studio" }), _jsx(Text, { type: "supporting", color: "secondary", children: `${project.name} · @theoremjs/agents ${version}` })] }), _jsx(Typeahead, { label: "Search", isLabelHidden: true, placeholder: "Search settings...", searchSource: settingsSource, value: null, onChange: (item) => {
|
|
265
|
+
return (_jsxs(VStack, { gap: 4, children: [_jsxs(VStack, { gap: 1, className: "studio-nav-head", children: [_jsx(Heading, { level: 3, children: "theorem studio" }), _jsx(Text, { type: "supporting", color: "secondary", children: `${project.name} · @theoremjs/agents ${version}` })] }), _jsx(Typeahead, { label: "Search", isLabelHidden: true, placeholder: "Search settings...", searchSource: settingsSource, value: null, onChange: (item) => {
|
|
266
266
|
const found = SETTINGS.find((setting) => setting.id === item?.id);
|
|
267
267
|
if (found)
|
|
268
268
|
showSettingsSection(found.section);
|
|
@@ -274,14 +274,14 @@ const SETTINGS_WIDTH = '72rem';
|
|
|
274
274
|
export function StudioSettings(props) {
|
|
275
275
|
const isNarrow = useMediaQuery('(max-width: 768px)');
|
|
276
276
|
const { section } = useSettingsDoor();
|
|
277
|
-
return (_jsx(Section, { variant: "transparent", height: "100%", padding: 0, children: _jsx(Layout, { height: "fill", start: isNarrow ? undefined : (_jsx(Section, { variant: "transparent", width: NAV_WIDTH, height: "100%", padding: 4, dividers: ['end'], children: _jsxs(VStack, { gap: 4, height: "100%", children: [_jsx(SettingsNavHead, { project: props.project, version: props.version }), _jsx(TreeList, { className: "studio-settings-tree", density: "compact", "aria-label": "Settings", items: SETTINGS_SECTIONS.map((each) => ({
|
|
277
|
+
return (_jsx(Section, { variant: "transparent", height: "100%", padding: 0, className: "studio-settings", children: _jsx(Layout, { height: "fill", start: isNarrow ? undefined : (_jsx(Section, { variant: "transparent", width: NAV_WIDTH, height: "100%", padding: 4, dividers: ['end'], children: _jsxs(VStack, { gap: 4, height: "100%", children: [_jsx(SettingsNavHead, { project: props.project, version: props.version }), _jsx(TreeList, { className: "studio-settings-tree", density: "compact", "aria-label": "Settings", items: SETTINGS_SECTIONS.map((each) => ({
|
|
278
278
|
id: each,
|
|
279
279
|
label: SECTION_LABELS[each],
|
|
280
280
|
isSelected: section === each,
|
|
281
281
|
onClick: () => {
|
|
282
282
|
showSettingsSection(each);
|
|
283
283
|
},
|
|
284
|
-
})) })] }) })), content: _jsxs(LayoutContent, { padding: 0, children: [_jsx(Section, { variant: "transparent", padding: 3, dividers: ['bottom'], children: _jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(StackItem, { size: "fill", children: _jsx(Heading, { level: 4, maxLines: 1, children: SECTION_LABELS[section] }) }), _jsx(IconButton, { label: "Close settings", variant: "ghost", icon: _jsx(Icon, { icon: IconX, size: "sm" }), tooltip: "Back to the studio", onClick: closeSettings })] }) }), _jsx(Section, { variant: "transparent", padding: 3, maxWidth: SETTINGS_WIDTH, className: "studio-settings-body", children: _jsxs(VStack, { gap: 4, children: [isNarrow && _jsx(SettingsNavHead, { project: props.project, version: props.version }), isNarrow && (_jsx(VStack, { hAlign: "center", children: _jsx(TabList, { value: section, onChange: (next) => {
|
|
284
|
+
})) })] }) })), content: _jsxs(LayoutContent, { padding: 0, className: "studio-settings-main", children: [_jsx(Section, { variant: "transparent", padding: 3, dividers: ['bottom'], children: _jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(StackItem, { size: "fill", children: _jsx(Heading, { level: 4, maxLines: 1, children: SECTION_LABELS[section] }) }), _jsx(IconButton, { label: "Close settings", variant: "ghost", icon: _jsx(Icon, { icon: IconX, size: "sm" }), tooltip: "Back to the studio", onClick: closeSettings })] }) }), _jsx(Section, { variant: "transparent", padding: 3, maxWidth: SETTINGS_WIDTH, className: "studio-settings-body", children: _jsxs(VStack, { gap: 4, children: [isNarrow && _jsx(SettingsNavHead, { project: props.project, version: props.version }), isNarrow && (_jsx(VStack, { hAlign: "center", children: _jsx(TabList, { value: section, onChange: (next) => {
|
|
285
285
|
if (isSection(next))
|
|
286
286
|
showSettingsSection(next);
|
|
287
287
|
}, children: SETTINGS_SECTIONS.map((each) => (_jsx(Tab, { value: each, label: SECTION_LABELS[each] }, each))) }) })), _jsx(SectionBody, { section: section, ...props })] }) })] }) }) }));
|
package/ui/use-phone.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
/** Whether the page is phone-wide. */
|
|
2
2
|
export declare function usePhone(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the element `ref` is set on is narrower than the desktop width. It measures the row, not
|
|
5
|
+
* the window, so a pane beside the editor collapses as a narrow window does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useBelowDesktop(): {
|
|
8
|
+
ref: (node: HTMLElement | null) => (() => void) | undefined;
|
|
9
|
+
below: boolean;
|
|
10
|
+
};
|
package/ui/use-phone.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_WIDTH_BREAKPOINTS } from '@astryxdesign/core/theme';
|
|
2
|
+
import { useCallback, useState, useSyncExternalStore } from 'react';
|
|
2
3
|
/** The width below which the studio's text buttons keep only their icon. */
|
|
3
4
|
const PHONE = '(width < 768px)';
|
|
5
|
+
/** Astryx's desktop width: a row of text buttons narrower than it keeps only their icons. */
|
|
6
|
+
const DESKTOP = DEFAULT_WIDTH_BREAKPOINTS.lg;
|
|
4
7
|
/** Whether the page is phone-wide. */
|
|
5
8
|
export function usePhone() {
|
|
6
9
|
return useSyncExternalStore((change) => {
|
|
@@ -11,3 +14,22 @@ export function usePhone() {
|
|
|
11
14
|
};
|
|
12
15
|
}, () => globalThis.matchMedia(PHONE).matches, () => false);
|
|
13
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether the element `ref` is set on is narrower than the desktop width. It measures the row, not
|
|
19
|
+
* the window, so a pane beside the editor collapses as a narrow window does.
|
|
20
|
+
*/
|
|
21
|
+
export function useBelowDesktop() {
|
|
22
|
+
const [below, setBelow] = useState(false);
|
|
23
|
+
const ref = useCallback((node) => {
|
|
24
|
+
if (!node)
|
|
25
|
+
return;
|
|
26
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
27
|
+
setBelow((entry?.contentRect.width ?? DESKTOP) < DESKTOP);
|
|
28
|
+
});
|
|
29
|
+
observer.observe(node);
|
|
30
|
+
return () => {
|
|
31
|
+
observer.disconnect();
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return { ref, below };
|
|
35
|
+
}
|