@theoremjs/studio 0.3.4-next.679.gcdf1a3a → 0.3.4-next.711.g78e504a
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/agreement.js +35 -5
- package/browser-connection.d.ts +1 -1
- package/browser-connection.js +3 -1
- package/browser-execution.js +1 -0
- package/compile-workspace.js +12 -5
- package/compile.d.ts +5 -3
- package/compile.js +80 -36
- package/cookbooks/catalog.d.ts +2 -2
- package/cookbooks/catalog.js +296 -51
- package/cookbooks/project.js +1 -0
- package/cookbooks/tools.js +64 -0
- package/draft.d.ts +23 -4
- package/draft.js +25 -2
- package/guardrail-probe.d.ts +3 -1
- package/guardrail-probe.js +37 -5
- package/mod.d.ts +2 -3
- package/mod.js +2 -3
- package/package.json +4 -4
- package/page/assets/Banner-GFaYsfrc.js +3 -0
- package/page/assets/Center-CgO0c-qo.js +1 -0
- package/page/assets/{ConsoleFrame-BMf3HicW.js → ConsoleFrame-KmyDVQkS.js} +3 -3
- package/page/assets/{MenuBottomSheet-sVJMYa4R.js → MenuBottomSheet-BSQO5V7g.js} +1 -1
- package/page/assets/{SchemaFields-DYormNVH.js → SchemaFields-CIsMisSq.js} +1 -1
- package/page/assets/{ToolResultCharts-Ce4lVdgN.js → ToolResultCharts-95plvcj4.js} +1 -1
- package/page/assets/{TraceInspector-DHyj0IHY.js → TraceInspector-D2113s73.js} +1 -1
- package/page/assets/{TraceOverview-CeiOIqk9.js → TraceOverview-Bz2EnBzL.js} +3 -3
- package/page/assets/{_virtual_studio-type-sources-BwSqfSwd.js → _virtual_studio-type-sources-La9AcR1O.js} +360 -97
- package/page/assets/browser-connection-B2a2EaIg.js +3 -0
- package/page/assets/browser-engine--lGbAmPM.js +13 -0
- package/page/assets/browser-transport-h1KAGUN4.js +45 -0
- package/page/assets/{crypto-CD14HeXH.js → crypto-BnoW7FFO.js} +1 -1
- package/page/assets/{encode-files-DhoC5hWG.js → encode-files-DoLGXgup.js} +1 -1
- package/page/assets/{export-agent-Cs2S0oXB.js → export-agent-CA42Pf8A.js} +3 -3
- package/page/assets/{guardrail-tester-IcJWVveC.js → guardrail-tester-fDJlewVB.js} +2 -2
- package/page/assets/index-Bd7U_fu_.js +149 -0
- package/page/assets/{labels-provider-t4c-5JMk.js → labels-provider-uONlWExD.js} +1 -1
- package/page/assets/live-messages-CTL-QEqM.js +1 -0
- package/page/assets/people-CIsR0-5R.js +1 -0
- package/page/assets/project-address-DjxPZuyn.js +1 -0
- package/page/assets/reader-COeSYhdZ.js +5 -0
- package/page/assets/{schemas-BQ9Jydzb.js → schemas-D7cgkv3L.js} +1 -1
- package/page/assets/shaped-data-7q5Be8sp.js +20 -0
- package/page/assets/{stub-nxRsh1jo.js → stub-DJBcKncO.js} +25 -7
- package/page/assets/studio-code-pane-MXm30Ppv.js +10 -0
- package/page/assets/{studio-console-Cn-v8Vvw.js → studio-console-dHEr6mr5.js} +1 -1
- package/page/assets/studio-decision-BoSmTyjn.js +1 -0
- package/page/assets/studio-embedding-B5E__vsY.js +2 -0
- package/page/assets/studio-host-console-CadL7PPh.js +2 -0
- package/page/assets/{studio-labels-CiLuAo3N.js → studio-labels-sxDmOFeL.js} +1 -1
- package/page/assets/studio-live-Cgt4zKeL.js +5 -0
- package/page/assets/studio-map-BgeqrIh_.js +1 -0
- package/page/assets/{studio-session-CjUQSXx0.js → studio-session-ClF2iNCX.js} +1 -1
- package/page/assets/studio-trace-replay-BqYGBZ1t.js +3 -0
- package/page/assets/{studio-type-checker-BbUSqqOS.js → studio-type-checker-DutkTKte.js} +1 -1
- package/page/assets/tool-schema-m1KPujBp.js +17 -0
- package/page/assets/{trace-record-DxgSKmYY.js → trace-record-Dm2jEhUR.js} +1 -1
- package/page/assets/trace-schema--4IGmLeE.js +1 -0
- package/page/assets/tree-5tuw5ISS.js +3 -0
- package/page/assets/turn-client-BmadRouD.js +2 -0
- package/page/assets/{use-one-call-BZKByPJh.js → use-one-call-IXfdRlUH.js} +1 -1
- package/page/assets/use-second-ticker-D6JSf9B3.js +1 -0
- package/page/assets/workspace-CMUi6xcQ.js +1 -0
- package/page/index.html +22 -20
- package/people.d.ts +2 -0
- package/people.js +3 -1
- package/policy.js +1 -0
- package/providers.d.ts +2 -2
- package/providers.js +8 -3
- package/read-source.js +67 -7
- package/registrations.d.ts +32 -4
- package/runtime-scope.d.ts +6 -3
- package/runtime-scope.js +16 -4
- package/runtime.js +15 -2
- package/section-notes.d.ts +1 -0
- package/section-notes.js +1 -0
- package/serve-page.mjs +8 -4
- package/server/draft-handler.d.ts +4 -4
- package/server/draft-handler.js +3 -2
- package/server/draft-probe.d.ts +9 -1
- package/server/draft-probe.js +2 -1
- package/server/handler.d.ts +0 -3
- package/server/handler.js +62 -38
- package/server/live.d.ts +7 -2
- package/server/live.js +11 -5
- package/server/run-traces.d.ts +5 -1
- package/server/run-traces.js +7 -3
- package/server/save-new.js +5 -5
- package/server/save-plan.js +2 -1
- package/server/save-session.js +4 -2
- package/server/serve.js +2 -1
- package/server/test-key.d.ts +2 -2
- package/server/test-key.js +1 -1
- package/slot-values.d.ts +2 -0
- package/slot-values.js +22 -0
- package/source.js +11 -4
- package/system-markup.d.ts +9 -7
- package/system-markup.js +38 -19
- package/tool-readers.d.ts +23 -0
- package/tool-readers.js +60 -0
- package/tools.js +5 -1
- package/types.d.ts +6 -1
- package/ui/inspector-context.d.ts +1 -8
- package/ui/inspector-context.js +0 -7
- package/ui/inspector.d.ts +43 -1
- package/ui/inspector.js +50 -9
- package/ui/lib/entries.d.ts +13 -0
- package/ui/lib/entries.js +43 -0
- package/ui/lib/project-traces.d.ts +5 -0
- package/ui/lib/project-traces.js +11 -1
- package/ui/lib/studio-page.d.ts +6 -1
- package/ui/lib/studio-page.js +33 -31
- package/ui/lib/studio-prefs.d.ts +0 -4
- package/ui/lib/studio-prefs.js +0 -7
- package/ui/lib/studio-project.d.ts +10 -6
- package/ui/lib/studio-project.js +19 -4
- package/ui/lib/studio-session.d.ts +2 -0
- package/ui/lib/studio-session.js +40 -2
- package/ui/lib/studio-store.d.ts +2 -2
- package/ui/lib/studio-store.js +9 -5
- package/ui/lib/tool-probe.d.ts +2 -0
- package/ui/lib/tool-probe.js +3 -2
- package/ui/lib/type-icons.d.ts +1 -0
- package/ui/lib/type-icons.js +2 -1
- package/ui/profile-editor.js +69 -45
- package/ui/studio-compare.d.ts +14 -4
- package/ui/studio-compare.js +58 -24
- package/ui/studio-live.d.ts +1 -1
- package/ui/studio-live.js +8 -3
- package/ui/studio-runner.d.ts +3 -2
- package/ui/studio-runner.js +16 -14
- package/ui/studio-screen.d.ts +1 -2
- package/ui/studio-screen.js +33 -37
- package/ui/studio-settings.js +4 -13
- package/ui/studio-trace-replay.js +7 -1
- package/workspace.js +3 -2
- package/asks.d.ts +0 -54
- package/asks.js +0 -69
- package/page/assets/Banner-CkcwUyOn.js +0 -4
- package/page/assets/Center-nHS1JSux.js +0 -1
- package/page/assets/browser-connection-DSUHVCT5.js +0 -3
- package/page/assets/browser-engine-BXSD3WU8.js +0 -11
- package/page/assets/browser-transport-cp9y8bBz.js +0 -45
- package/page/assets/index-JWco7tJJ.js +0 -145
- package/page/assets/live-messages-CiLmR89m.js +0 -1
- package/page/assets/reader-DrOfMM8I.js +0 -5
- package/page/assets/shaped-data-H1miOZm2.js +0 -20
- package/page/assets/studio-code-pane-B8MOEW9g.js +0 -8
- package/page/assets/studio-decision-CjJ_pqdJ.js +0 -1
- package/page/assets/studio-embedding-Cq3ePsfC.js +0 -2
- package/page/assets/studio-host-console-D__Of1no.js +0 -2
- package/page/assets/studio-live-DvDQbP5V.js +0 -5
- package/page/assets/studio-map-BZFYGG_Y.js +0 -1
- package/page/assets/studio-trace-replay-D22FgUA5.js +0 -3
- package/page/assets/tool-schema-BmRYaywn.js +0 -17
- package/page/assets/trace-schema-9CdEyG6Q.js +0 -1
- package/page/assets/tree-3N-1RPZz.js +0 -3
- package/page/assets/turn-client-DN8PawJr.js +0 -2
- package/page/assets/use-second-ticker-CEwOSS-d.js +0 -1
- package/page/assets/workspace-CTSW941G.js +0 -1
- package/ui/confirm-write.d.ts +0 -12
- package/ui/confirm-write.js +0 -45
|
@@ -0,0 +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-5tuw5ISS.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-
|
|
13
|
+
<script type="module" crossorigin src="/studio/assets/index-Bd7U_fu_.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">
|
|
@@ -45,23 +45,23 @@
|
|
|
45
45
|
<link rel="modulepreload" crossorigin href="/studio/assets/SidePanel-DEd3R1Q3.js">
|
|
46
46
|
<link rel="modulepreload" crossorigin href="/studio/assets/IconAlertTriangle-BqAEqqdU.js">
|
|
47
47
|
<link rel="modulepreload" crossorigin href="/studio/assets/isRenderable-DHkzpAoQ.js">
|
|
48
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-
|
|
49
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/schemas-
|
|
48
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-uONlWExD.js">
|
|
49
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/schemas-D7cgkv3L.js">
|
|
50
50
|
<link rel="modulepreload" crossorigin href="/studio/assets/host-patterns-F-KZIzkF.js">
|
|
51
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-
|
|
52
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-
|
|
51
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-7q5Be8sp.js">
|
|
52
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-m1KPujBp.js">
|
|
53
53
|
<link rel="modulepreload" crossorigin href="/studio/assets/live-ingress-OuSlQ6q7.js">
|
|
54
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/tree-
|
|
55
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-
|
|
56
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-
|
|
57
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/Banner-
|
|
54
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/tree-5tuw5ISS.js">
|
|
55
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-B2a2EaIg.js">
|
|
56
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-D6JSf9B3.js">
|
|
57
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/Banner-GFaYsfrc.js">
|
|
58
58
|
<link rel="modulepreload" crossorigin href="/studio/assets/row-keys-WByP9Hsh.js">
|
|
59
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/Center-
|
|
59
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/Center-CgO0c-qo.js">
|
|
60
60
|
<link rel="modulepreload" crossorigin href="/studio/assets/IconSearch-BTx66a40.js">
|
|
61
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/trace-schema
|
|
62
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/stub-
|
|
63
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/reader-
|
|
64
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-
|
|
61
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/trace-schema--4IGmLeE.js">
|
|
62
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/stub-DJBcKncO.js">
|
|
63
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/reader-COeSYhdZ.js">
|
|
64
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-h1KAGUN4.js">
|
|
65
65
|
<link rel="modulepreload" crossorigin href="/studio/assets/focusReturn-CTppP2k0.js">
|
|
66
66
|
<link rel="modulepreload" crossorigin href="/studio/assets/CheckboxInput-CFZ_Wq8-.js">
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/studio/assets/useScrollLock-Dyf6PHJt.js">
|
|
@@ -71,15 +71,17 @@
|
|
|
71
71
|
<link rel="modulepreload" crossorigin href="/studio/assets/CodeBlock-CfVOtDeO.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="/studio/assets/HoverCard-DMyWUvwP.js">
|
|
73
73
|
<link rel="modulepreload" crossorigin href="/studio/assets/IconEye-BB5aY-wQ.js">
|
|
74
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/encode-files-
|
|
75
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/turn-client-
|
|
74
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/encode-files-DoLGXgup.js">
|
|
75
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/turn-client-BmadRouD.js">
|
|
76
76
|
<link rel="modulepreload" crossorigin href="/studio/assets/CollapsibleGroup-BsIYDnJR.js">
|
|
77
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-
|
|
78
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/crypto-
|
|
79
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/workspace-
|
|
77
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-sxDmOFeL.js">
|
|
78
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/crypto-BnoW7FFO.js">
|
|
79
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/workspace-CMUi6xcQ.js">
|
|
80
80
|
<link rel="modulepreload" crossorigin href="/studio/assets/lent-keys-C32ems-I.js">
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/studio/assets/editors-BJX_S59A.js">
|
|
82
|
-
<link rel="modulepreload" crossorigin href="/studio/assets/
|
|
82
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/project-address-DjxPZuyn.js">
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/people-CIsR0-5R.js">
|
|
84
|
+
<link rel="modulepreload" crossorigin href="/studio/assets/studio-session-ClF2iNCX.js">
|
|
83
85
|
<link rel="modulepreload" crossorigin href="/studio/assets/EmptyState-C_uF9Wyj.js">
|
|
84
86
|
<link rel="modulepreload" crossorigin href="/studio/assets/useMenuPress-DLG1QOiE.js">
|
|
85
87
|
<link rel="modulepreload" crossorigin href="/studio/assets/useAdaptivePresentation-Bma4-u1a.js">
|
package/people.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export interface StudioPeopleOffer {
|
|
|
45
45
|
}
|
|
46
46
|
/** The header each run carries the builder's pick in. No header is no one. */
|
|
47
47
|
export declare const ACTING_AS_HEADER = "x-theorem-studio-acting-as";
|
|
48
|
+
/** The pick on a live socket's address: a browser's `WebSocket` sends no headers. */
|
|
49
|
+
export declare const ACTING_AS_PARAM = "acting-as";
|
|
48
50
|
/** The session a run acting as no one is in. */
|
|
49
51
|
export declare const NO_ONE_SESSION = "theorem-studio-local";
|
|
50
52
|
/** The pick as a header value: the label may be any text, and a header holds only some. */
|
package/people.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
/** The header each run carries the builder's pick in. No header is no one. */
|
|
13
13
|
export const ACTING_AS_HEADER = 'x-theorem-studio-acting-as';
|
|
14
|
+
/** The pick on a live socket's address: a browser's `WebSocket` sends no headers. */
|
|
15
|
+
export const ACTING_AS_PARAM = 'acting-as';
|
|
14
16
|
/** The session a run acting as no one is in. */
|
|
15
17
|
export const NO_ONE_SESSION = 'theorem-studio-local';
|
|
16
18
|
const nameSchema = z.object({ id: z.string().min(1), label: z.string().min(1) });
|
|
@@ -40,7 +42,7 @@ export function actingAsSession(actingAs) {
|
|
|
40
42
|
}
|
|
41
43
|
/** Reads a run's pick and checks its place is one the setup offers. */
|
|
42
44
|
export function readActingAs(request, people) {
|
|
43
|
-
const sent = request.headers.get(ACTING_AS_HEADER);
|
|
45
|
+
const sent = request.headers.get(ACTING_AS_HEADER) ?? new URL(request.url).searchParams.get(ACTING_AS_PARAM);
|
|
44
46
|
if (sent === null)
|
|
45
47
|
return { ok: true, actingAs: undefined };
|
|
46
48
|
let value;
|
package/policy.js
CHANGED
package/providers.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export interface ProtocolOptionField {
|
|
|
119
119
|
/** Where it sits under the model's `options`, dotted: `store`, `cache.mode`. */
|
|
120
120
|
path: string;
|
|
121
121
|
label: string;
|
|
122
|
-
kind: 'boolean' | 'choice' | 'text' | 'number';
|
|
122
|
+
kind: 'boolean' | 'choice' | 'text' | 'number' | 'names';
|
|
123
123
|
/** The protocol refuses the model without it. */
|
|
124
124
|
required: boolean;
|
|
125
125
|
/** What the protocol says the option is. */
|
|
@@ -135,7 +135,7 @@ export interface ProtocolOptionField {
|
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* The options `protocol` takes, a field per setting, read from its own schema. A setting inside an
|
|
138
|
-
* object is a field of its own; one a row cannot hold (a list, a free record) is left to code. Given
|
|
138
|
+
* object is a field of its own; one a row cannot hold (a list of objects, a free record) is left to code. Given
|
|
139
139
|
* the model, an option it refuses is left out, unless `options` already holds it: that row stays,
|
|
140
140
|
* where its issue shows.
|
|
141
141
|
*/
|
package/providers.js
CHANGED
|
@@ -208,11 +208,11 @@ export function modelRoute(providers, type, binding) {
|
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
function isModelProfileType(type) {
|
|
211
|
-
return ['text', 'image', 'speech', 'live', 'decision', 'embedding'].includes(type);
|
|
211
|
+
return ['text', 'image', 'speech', 'transcription', 'live', 'decision', 'embedding'].includes(type);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* The options `protocol` takes, a field per setting, read from its own schema. A setting inside an
|
|
215
|
-
* object is a field of its own; one a row cannot hold (a list, a free record) is left to code. Given
|
|
215
|
+
* object is a field of its own; one a row cannot hold (a list of objects, a free record) is left to code. Given
|
|
216
216
|
* the model, an option it refuses is left out, unless `options` already holds it: that row stays,
|
|
217
217
|
* where its issue shows.
|
|
218
218
|
*/
|
|
@@ -272,6 +272,8 @@ function fieldsOf(node, prefix, held) {
|
|
|
272
272
|
}
|
|
273
273
|
if (property.type === 'boolean')
|
|
274
274
|
return [{ ...base, kind: 'boolean' }];
|
|
275
|
+
if (property.type === 'array' && property.items?.type === 'string')
|
|
276
|
+
return [{ ...base, kind: 'names' }];
|
|
275
277
|
if (property.type === 'string')
|
|
276
278
|
return [{ ...base, kind: 'text' }];
|
|
277
279
|
if (property.type === 'number' || property.type === 'integer')
|
|
@@ -281,7 +283,10 @@ function fieldsOf(node, prefix, held) {
|
|
|
281
283
|
}
|
|
282
284
|
/** An option's name as a row labels it: `persistViaInteractionId` is Persist via interaction id. */
|
|
283
285
|
function optionLabel(name) {
|
|
284
|
-
const words = name
|
|
286
|
+
const words = name
|
|
287
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
288
|
+
.replace(/_/g, ' ')
|
|
289
|
+
.toLowerCase();
|
|
285
290
|
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
286
291
|
}
|
|
287
292
|
/** The value at `path` in `options`. */
|
package/read-source.js
CHANGED
|
@@ -13,6 +13,7 @@ import { canonical } from "./canonical.js";
|
|
|
13
13
|
import { createBlankDraft, defaultModelBinding, defaultToolSpec, draftKey, INLINE_LABELS, MODEL_LIMITS, STUDIO_PROFILE_TYPES, } from "./draft.js";
|
|
14
14
|
import { definitionFactory, definitionOfFactory, kernelDefinitions, } from "./providers.js";
|
|
15
15
|
import { stubOutputFromSchema } from "./stub.js";
|
|
16
|
+
import { parseSystemMarkup } from "./system-markup.js";
|
|
16
17
|
import { STUDIO_TOOL_TYPE_MESSAGE, STUDIO_TOOL_TYPES } from "./types.js";
|
|
17
18
|
class ReadFail extends Error {
|
|
18
19
|
line;
|
|
@@ -500,12 +501,12 @@ function readCall(src, parsed) {
|
|
|
500
501
|
if (typeof id !== 'string' || !isRecord(spec)) {
|
|
501
502
|
src.fail('registerStructured() needs an id and a spec.');
|
|
502
503
|
}
|
|
503
|
-
parsed.
|
|
504
|
+
parsed.structures.push({ id, spec });
|
|
504
505
|
}
|
|
505
506
|
}
|
|
506
507
|
function parseModule(text, of = 'profile') {
|
|
507
508
|
const src = new Src(text, of);
|
|
508
|
-
const parsed = { tools: [], spans: [] };
|
|
509
|
+
const parsed = { tools: [], structures: [], spans: [] };
|
|
509
510
|
for (src.skip(); !src.done; src.skip()) {
|
|
510
511
|
if (src.peekIdent() === 'import') {
|
|
511
512
|
src.expectIdent();
|
|
@@ -530,6 +531,13 @@ function parseModule(text, of = 'profile') {
|
|
|
530
531
|
function text(value, fallback = '') {
|
|
531
532
|
return typeof value === 'string' ? value : fallback;
|
|
532
533
|
}
|
|
534
|
+
function backgroundOf(value) {
|
|
535
|
+
if (value === 'always' || value === 'ask')
|
|
536
|
+
return value;
|
|
537
|
+
if (typeof value !== 'object' || value === null || !('afterMs' in value))
|
|
538
|
+
return undefined;
|
|
539
|
+
return typeof value.afterMs === 'number' ? { afterMs: value.afterMs } : undefined;
|
|
540
|
+
}
|
|
533
541
|
function whole(value) {
|
|
534
542
|
return typeof value === 'number' ? value : null;
|
|
535
543
|
}
|
|
@@ -544,12 +552,53 @@ function markup(value, srcMessage) {
|
|
|
544
552
|
.map((part) => {
|
|
545
553
|
if (typeof part === 'string')
|
|
546
554
|
return part;
|
|
555
|
+
if (Array.isArray(part))
|
|
556
|
+
return markup(part, srcMessage);
|
|
547
557
|
if (isRecord(part) && typeof part.private === 'string')
|
|
548
558
|
return `{private: ${part.private}}`;
|
|
549
559
|
throw new ReadFail(srcMessage, 1, 1);
|
|
550
560
|
})
|
|
551
561
|
.join('');
|
|
552
562
|
}
|
|
563
|
+
const WHEN_LINE = /^\s*when\s/;
|
|
564
|
+
/**
|
|
565
|
+
* A prompt as the draft holds it: its lines as one text, a blank line between them. A bare
|
|
566
|
+
* `{ private }` is no line, and a `when` line holding a blank line can't be told from two lines.
|
|
567
|
+
*/
|
|
568
|
+
function promptText(value) {
|
|
569
|
+
const srcMessage = 'The system prompt has to be text.';
|
|
570
|
+
const lines = Array.isArray(value) ? value : [value];
|
|
571
|
+
const texts = lines.map((line) => {
|
|
572
|
+
if (Array.isArray(value) && typeof line !== 'string' && !Array.isArray(line)) {
|
|
573
|
+
throw new ReadFail(srcMessage, 1, 1);
|
|
574
|
+
}
|
|
575
|
+
return markup(line, srcMessage);
|
|
576
|
+
});
|
|
577
|
+
for (const text of texts) {
|
|
578
|
+
const parsed = parseSystemMarkup(text);
|
|
579
|
+
if (WHEN_LINE.test(text) && parsed.ok && parsed.lines.length > 1) {
|
|
580
|
+
throw new ReadFail('A "when" line in the system prompt can\'t hold a blank line.', 1, 1);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return texts.join('\n\n');
|
|
584
|
+
}
|
|
585
|
+
/** Conditions as the draft holds them: a row each, keeping the row of a name it already has. */
|
|
586
|
+
function conditionRows(value, current) {
|
|
587
|
+
if (value === undefined)
|
|
588
|
+
return [];
|
|
589
|
+
const srcMessage = 'Conditions have to be lists of values.';
|
|
590
|
+
if (!isRecord(value))
|
|
591
|
+
throw new ReadFail(srcMessage, 1, 1);
|
|
592
|
+
return Object.entries(value).map(([name, values]) => {
|
|
593
|
+
if (!Array.isArray(values))
|
|
594
|
+
throw new ReadFail(srcMessage, 1, 1);
|
|
595
|
+
return {
|
|
596
|
+
key: current.find((row) => row.name === name)?.key ?? draftKey('condition'),
|
|
597
|
+
name,
|
|
598
|
+
values: values.map((each) => text(each)),
|
|
599
|
+
};
|
|
600
|
+
});
|
|
601
|
+
}
|
|
553
602
|
function jsonText(value) {
|
|
554
603
|
if (value === undefined)
|
|
555
604
|
return '';
|
|
@@ -847,6 +896,8 @@ function toolOf(spec, current, agentKeyOf) {
|
|
|
847
896
|
// A page tool's source has no handler: its stub is the studio's own, so it is kept.
|
|
848
897
|
stubOutputJson: page ? current?.stubOutputJson : stubOf(type, spec),
|
|
849
898
|
answeredBy: page ? 'page' : undefined,
|
|
899
|
+
after: spec.after === true ? true : undefined,
|
|
900
|
+
background: backgroundOf(spec.background),
|
|
850
901
|
...toolRoute(spec),
|
|
851
902
|
agentKey: agentId ? agentKeyOf?.(agentId) : undefined,
|
|
852
903
|
maxCallsPerTurn: whole(spec.maxCallsPerTurn),
|
|
@@ -971,14 +1022,13 @@ function allowTools(registered, allow, spans) {
|
|
|
971
1022
|
}
|
|
972
1023
|
function identityOf(current, profile, type) {
|
|
973
1024
|
const identity = record(profile.identity) ?? {};
|
|
974
|
-
const byRole = identity.systemByRole;
|
|
975
1025
|
return {
|
|
976
1026
|
...current,
|
|
977
1027
|
agentId: text(profile.id),
|
|
978
1028
|
profileType: type,
|
|
979
1029
|
handle: text(identity.handle),
|
|
980
|
-
system:
|
|
981
|
-
|
|
1030
|
+
system: promptText(identity.system),
|
|
1031
|
+
conditions: conditionRows(identity.conditions, current.conditions),
|
|
982
1032
|
};
|
|
983
1033
|
}
|
|
984
1034
|
function modelsOf(profile) {
|
|
@@ -1045,14 +1095,24 @@ function itemRulesOf(items) {
|
|
|
1045
1095
|
record(rule)?.onFail === 'fix' ? 'fix' : 'drop',
|
|
1046
1096
|
]));
|
|
1047
1097
|
}
|
|
1048
|
-
function outputsOf(outputs,
|
|
1098
|
+
function outputsOf(outputs, structures) {
|
|
1099
|
+
const picks = record(outputs?.structured);
|
|
1100
|
+
const structured = picks
|
|
1101
|
+
? structures.find(({ id }) => id === text(picks.fallback))
|
|
1102
|
+
: structures[0];
|
|
1049
1103
|
const schemaId = structured?.id ?? text(outputs?.structured);
|
|
1104
|
+
const shapes = Object.entries(record(picks?.map) ?? {}).map(([choice, id]) => ({
|
|
1105
|
+
choice,
|
|
1106
|
+
schemaId: text(id),
|
|
1107
|
+
schemaJson: jsonText(structures.find((shape) => shape.id === id)?.spec.jsonSchema),
|
|
1108
|
+
}));
|
|
1050
1109
|
const streaming = record(outputs?.streaming);
|
|
1051
1110
|
const validation = record(outputs?.validation);
|
|
1052
1111
|
return {
|
|
1053
1112
|
mode: schemaId ? 'structured' : 'text',
|
|
1054
1113
|
schemaId,
|
|
1055
1114
|
schemaJson: jsonText(structured?.spec.jsonSchema),
|
|
1115
|
+
...(picks ? { bySlot: { slot: text(picks.by), shapes } } : {}),
|
|
1056
1116
|
streamMode: text(streaming?.mode),
|
|
1057
1117
|
streamThoughts: streaming?.streamThoughts !== false,
|
|
1058
1118
|
validationEnabled: validation !== undefined,
|
|
@@ -1220,7 +1280,7 @@ function draftFrom(parsed, current, agentKeyOf) {
|
|
|
1220
1280
|
tools: { t2Loader: text(tools.t2Loader), parallel: tools.parallel === true },
|
|
1221
1281
|
toolSpecs: [],
|
|
1222
1282
|
inputs: inputs && type !== 'decision' ? inputsOf(inputs, current.inputs) : current.inputs,
|
|
1223
|
-
outputs: outputs || parsed.
|
|
1283
|
+
outputs: outputs || parsed.structures.length ? outputsOf(outputs, parsed.structures) : current.outputs,
|
|
1224
1284
|
turnBehaviour: section(profile.turnBehaviour, turnOf, current.turnBehaviour),
|
|
1225
1285
|
guardrails: section(profile.guardrails, guardrailsOf, current.guardrails),
|
|
1226
1286
|
observability: section(profile.observability, observabilityOf, current.observability),
|
package/registrations.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DecisionQuestion } from '@theoremjs/agents';
|
|
2
|
+
import type { StructuredSpec, ToolAuthConfig, ToolBackground, ToolLabels } from '@theoremjs/agents/kernel';
|
|
2
3
|
import type { HttpMethod, ToolAccess, ToolLoadTier, ToolPermission } from '@theoremjs/agents/schema';
|
|
3
4
|
/** The kernel's auth config; the host's OAuth endpoints are never set from the studio. */
|
|
4
5
|
export type StudioToolAuth = Omit<ToolAuthConfig, 'preResolved'>;
|
|
@@ -6,6 +7,11 @@ export type StudioToolLabels = Pick<ToolLabels, 'activity' | 'activityPast' | 'a
|
|
|
6
7
|
export type StructuredRegistration = {
|
|
7
8
|
id: string;
|
|
8
9
|
spec: StructuredSpec;
|
|
10
|
+
/** The shapes a slot's value picks, beside the fallback `id`. */
|
|
11
|
+
also?: {
|
|
12
|
+
id: string;
|
|
13
|
+
spec: StructuredSpec;
|
|
14
|
+
}[];
|
|
9
15
|
};
|
|
10
16
|
export type FunctionToolRegistration = {
|
|
11
17
|
type: 'function';
|
|
@@ -19,12 +25,18 @@ export type FunctionToolRegistration = {
|
|
|
19
25
|
inputSchema: Record<string, unknown>;
|
|
20
26
|
outputSchema: Record<string, unknown>;
|
|
21
27
|
labels?: StudioToolLabels;
|
|
28
|
+
/** The model can name tools of its step that finish before this one starts. */
|
|
29
|
+
after?: boolean;
|
|
30
|
+
/** When the model gets its reply while the body goes on. */
|
|
31
|
+
background?: ToolBackground;
|
|
22
32
|
/**Overrides the generic stub. */
|
|
23
33
|
stubResponse?: Record<string, unknown>;
|
|
24
34
|
/** The page answers the call: the kernel supplies the handler, and the page sends the output. */
|
|
25
35
|
answeredBy?: 'page';
|
|
26
|
-
/** The decision
|
|
36
|
+
/** The decision profile that reads this tool's output at `post_tool`. */
|
|
27
37
|
stageAgent?: string;
|
|
38
|
+
/** What `stageAgent` asks of each passage, by id. A run fills it from that agent. */
|
|
39
|
+
stageQuestions?: Record<string, DecisionQuestion>;
|
|
28
40
|
};
|
|
29
41
|
export type HttpToolRegistration = {
|
|
30
42
|
type: 'http';
|
|
@@ -48,8 +60,14 @@ export type HttpToolRegistration = {
|
|
|
48
60
|
inputSchema: Record<string, unknown>;
|
|
49
61
|
outputSchema: Record<string, unknown>;
|
|
50
62
|
labels?: StudioToolLabels;
|
|
51
|
-
/** The
|
|
63
|
+
/** The model can name tools of its step that finish before this one starts. */
|
|
64
|
+
after?: boolean;
|
|
65
|
+
/** When the model gets its reply while the body goes on. */
|
|
66
|
+
background?: ToolBackground;
|
|
67
|
+
/** The decision profile that reads this tool's output at `post_tool`. */
|
|
52
68
|
stageAgent?: string;
|
|
69
|
+
/** What `stageAgent` asks of each passage, by id. A run fills it from that agent. */
|
|
70
|
+
stageQuestions?: Record<string, DecisionQuestion>;
|
|
53
71
|
};
|
|
54
72
|
export type McpToolRegistration = {
|
|
55
73
|
type: 'mcp';
|
|
@@ -72,8 +90,14 @@ export type McpToolRegistration = {
|
|
|
72
90
|
inputSchema: Record<string, unknown>;
|
|
73
91
|
outputSchema: Record<string, unknown>;
|
|
74
92
|
labels?: StudioToolLabels;
|
|
75
|
-
/** The
|
|
93
|
+
/** The model can name tools of its step that finish before this one starts. */
|
|
94
|
+
after?: boolean;
|
|
95
|
+
/** When the model gets its reply while the body goes on. */
|
|
96
|
+
background?: ToolBackground;
|
|
97
|
+
/** The decision profile that reads this tool's output at `post_tool`. */
|
|
76
98
|
stageAgent?: string;
|
|
99
|
+
/** What `stageAgent` asks of each passage, by id. A run fills it from that agent. */
|
|
100
|
+
stageQuestions?: Record<string, DecisionQuestion>;
|
|
77
101
|
};
|
|
78
102
|
/** Runs one turn of another registered agent; its schemas are the kernel's fixed ones. */
|
|
79
103
|
export type AgentToolRegistration = {
|
|
@@ -91,5 +115,9 @@ export type AgentToolRegistration = {
|
|
|
91
115
|
inputSchema: Record<string, unknown>;
|
|
92
116
|
outputSchema: Record<string, unknown>;
|
|
93
117
|
labels?: StudioToolLabels;
|
|
118
|
+
/** The model can name tools of its step that finish before this one starts. */
|
|
119
|
+
after?: boolean;
|
|
120
|
+
/** When the model gets its reply while the body goes on. */
|
|
121
|
+
background?: ToolBackground;
|
|
94
122
|
};
|
|
95
123
|
export type ToolRegistration = FunctionToolRegistration | HttpToolRegistration | McpToolRegistration | AgentToolRegistration;
|
package/runtime-scope.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Studio drafts, each run on a kernel scope of its own. Two visitors can
|
|
3
3
|
* name the same profile, tool, or schema without either one seeing the other's.
|
|
4
4
|
*/
|
|
5
|
-
import { defineProfile, type KernelScope, type Profile, type ProfileDefinition, type Provider, type ResolveHost, type ToolExecutionCoordinator } from '@theoremjs/agents';
|
|
5
|
+
import { defineProfile, type KernelScope, type Profile, type ProfileDefinition, type Provider, type RegisteredProvider, type ResolveHost, type ToolExecutionCoordinator } from '@theoremjs/agents';
|
|
6
6
|
import { type DetectSpec } from '@theoremjs/agents/guardrails';
|
|
7
7
|
import type { AgentCall, AgentCallHook, ProviderHostOptions, TurnModel } from '@theoremjs/agents/kernel';
|
|
8
8
|
export interface StudioProviderOptions extends ProviderHostOptions {
|
|
@@ -34,6 +34,8 @@ export interface StudioRuntimeBase {
|
|
|
34
34
|
} | undefined | Promise<{
|
|
35
35
|
refuse: string;
|
|
36
36
|
} | undefined>;
|
|
37
|
+
/** Before a tool's reader reads each passage: throw to stop it, and the model reads the output whole. */
|
|
38
|
+
onReaderCall?: () => void | Promise<void>;
|
|
37
39
|
}
|
|
38
40
|
/** A run, and what it runs on: a run on lent keys carries the keys it is held to. */
|
|
39
41
|
export type StudioRuntime = StudioRuntimeBase & StudioRunsOn;
|
|
@@ -76,9 +78,10 @@ export declare function studioScope(profile: ProfileDefinition, customTools: rea
|
|
|
76
78
|
/**
|
|
77
79
|
* A new scope holding drafts as written, the last one returned: no runtime
|
|
78
80
|
* rewrites their guardrails or checks their model bindings. For a run that
|
|
79
|
-
* calls no model and reaches no host. Never cache or share it.
|
|
81
|
+
* calls no model and reaches no host. Never cache or share it. `providers` are the project's: a
|
|
82
|
+
* draft's model names them, and they stand over a studio provider of the same id.
|
|
80
83
|
*/
|
|
81
|
-
export declare function writtenScope(drafts: readonly StudioDependency[]): Promise<{
|
|
84
|
+
export declare function writtenScope(drafts: readonly StudioDependency[], providers?: readonly RegisteredProvider[]): Promise<{
|
|
82
85
|
scope: KernelScope;
|
|
83
86
|
profile: Profile | undefined;
|
|
84
87
|
}>;
|
package/runtime-scope.js
CHANGED
|
@@ -165,8 +165,11 @@ function withDraftItemChecks(def) {
|
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
function runtimeProfileDefinition(def, runtime) {
|
|
168
|
-
// A speech, decision, or embedding profile calls no tools: no network or taint hold governs it.
|
|
169
|
-
if (def.type === 'speech' ||
|
|
168
|
+
// A speech, transcription, decision, or embedding profile calls no tools: no network or taint hold governs it.
|
|
169
|
+
if (def.type === 'speech' ||
|
|
170
|
+
def.type === 'transcription' ||
|
|
171
|
+
def.type === 'decision' ||
|
|
172
|
+
def.type === 'embedding')
|
|
170
173
|
return def;
|
|
171
174
|
// A host runs one tool per call, so a turn never reads before it acts; the kernel refuses taint there.
|
|
172
175
|
if (def.type === 'host') {
|
|
@@ -319,11 +322,20 @@ export async function studioScope(profile, customTools, structured, runtime, dep
|
|
|
319
322
|
/**
|
|
320
323
|
* A new scope holding drafts as written, the last one returned: no runtime
|
|
321
324
|
* rewrites their guardrails or checks their model bindings. For a run that
|
|
322
|
-
* calls no model and reaches no host. Never cache or share it.
|
|
325
|
+
* calls no model and reaches no host. Never cache or share it. `providers` are the project's: a
|
|
326
|
+
* draft's model names them, and they stand over a studio provider of the same id.
|
|
323
327
|
*/
|
|
324
|
-
export async function writtenScope(drafts) {
|
|
328
|
+
export async function writtenScope(drafts, providers = []) {
|
|
325
329
|
const scope = createKernelScope();
|
|
326
330
|
registerRuntimeProviders(scope);
|
|
331
|
+
for (const { definition, id, connection, keySlot, fallbackKeySlot } of providers) {
|
|
332
|
+
scope.providers.replace(definition, {
|
|
333
|
+
id,
|
|
334
|
+
connection,
|
|
335
|
+
...(keySlot ? { keySlot } : {}),
|
|
336
|
+
...(fallbackKeySlot ? { fallbackKeySlot } : {}),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
327
339
|
let profile;
|
|
328
340
|
for (const draft of drafts) {
|
|
329
341
|
await refuseSlowSchemaPatterns(draft.customTools);
|
package/runtime.js
CHANGED
|
@@ -6,6 +6,7 @@ import { answerReply, checkRequest, conversationView, messageReply, openConversa
|
|
|
6
6
|
import { STUDIO_TRACE_DESTINATION } from "./policy.js";
|
|
7
7
|
import { studioReader } from "./reader.js";
|
|
8
8
|
import { agentCallHook, runtimeProvider, studioScope, } from "./runtime-scope.js";
|
|
9
|
+
import { bothStages, toolReaderStage, toolReaders } from "./tool-readers.js";
|
|
9
10
|
import { createStudioTraceRouter } from "./traces.js";
|
|
10
11
|
// Profiles that write to the studio destination get their records back on the run's own stream.
|
|
11
12
|
export const studioTraces = createStudioTraceRouter();
|
|
@@ -67,6 +68,7 @@ function studioRunner(args) {
|
|
|
67
68
|
pageExecution: runtime.pageExecution,
|
|
68
69
|
metadata,
|
|
69
70
|
input: turn.input,
|
|
71
|
+
...turn.stated,
|
|
70
72
|
...(turn.conversationId ? { conversationId: turn.conversationId } : {}),
|
|
71
73
|
providerState: turn.providerState,
|
|
72
74
|
sessionPermissions: args.sessionPermissions,
|
|
@@ -74,6 +76,7 @@ function studioRunner(args) {
|
|
|
74
76
|
signal,
|
|
75
77
|
...(turn.model ? { model: turn.model } : {}),
|
|
76
78
|
...(turn.effort ? { effort: turn.effort } : {}),
|
|
79
|
+
...(turn.promoted ? { promoted: turn.promoted } : {}),
|
|
77
80
|
...(args.onStage ? { onStage: args.onStage } : {}),
|
|
78
81
|
onAgentCall: agentCallHook(scope, runtime),
|
|
79
82
|
}, runtimeProvider(runtime, scope, profile, turn.model)),
|
|
@@ -83,6 +86,7 @@ function studioRunner(args) {
|
|
|
83
86
|
},
|
|
84
87
|
...(args.model ? { model: args.model } : {}),
|
|
85
88
|
...(args.effort ? { effort: args.effort } : {}),
|
|
89
|
+
...(args.stated ? { stated: args.stated } : {}),
|
|
86
90
|
signal,
|
|
87
91
|
};
|
|
88
92
|
}
|
|
@@ -150,11 +154,20 @@ export async function* streamStudioTurn(args) {
|
|
|
150
154
|
sessionPermissions,
|
|
151
155
|
...(request.model ? { model: request.model } : {}),
|
|
152
156
|
...(request.effort ? { effort: request.effort } : {}),
|
|
157
|
+
...(request.stated ? { stated: request.stated } : {}),
|
|
153
158
|
signal,
|
|
154
|
-
onStage: steerStage(args.steer, inbox),
|
|
159
|
+
onStage: bothStages(steerStage(args.steer, inbox), toolReaderStage(toolReaders(args.customTools), async (reader, state) => {
|
|
160
|
+
await runtime.onReaderCall?.();
|
|
161
|
+
return scope.runDecision({ profile: reader.profile, state, questions: reader.questions, signal }, runtimeProvider(runtime, scope, scope.profiles.get(reader.profile)));
|
|
162
|
+
})),
|
|
155
163
|
});
|
|
156
164
|
if (!host || !opened) {
|
|
157
|
-
return runner.run({
|
|
165
|
+
return runner.run({
|
|
166
|
+
input: message.input,
|
|
167
|
+
model: request.model,
|
|
168
|
+
effort: request.effort,
|
|
169
|
+
...(request.stated ? { stated: request.stated } : {}),
|
|
170
|
+
});
|
|
158
171
|
}
|
|
159
172
|
const walkAway = walked.map(({ reference, invoke }) => ({
|
|
160
173
|
...reference,
|
package/section-notes.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare const SECTION_NOTES: {
|
|
|
7
7
|
readonly models: "Add a model here, then select its binding in the tree to configure it.";
|
|
8
8
|
readonly 'models.decision': "A decision uses one model. Select its binding in the tree to configure it.";
|
|
9
9
|
readonly decisionModel: "This binding answers the questions configured under Decision.";
|
|
10
|
+
readonly system: "A blank line starts a new line. Wrap private text as {private: …}.";
|
|
10
11
|
readonly slots: "Each slot's picker sets what the preview sends. It is not saved in the profile.";
|
|
11
12
|
readonly context: "Preview is what the studio sends as the page. It is not saved in the profile.";
|
|
12
13
|
readonly compaction: "The studio's chat compacts only before a turn.";
|
package/section-notes.js
CHANGED
|
@@ -7,6 +7,7 @@ const SECTION_NOTES = {
|
|
|
7
7
|
models: 'Add a model here, then select its binding in the tree to configure it.',
|
|
8
8
|
'models.decision': 'A decision uses one model. Select its binding in the tree to configure it.',
|
|
9
9
|
decisionModel: 'This binding answers the questions configured under Decision.',
|
|
10
|
+
system: 'A blank line starts a new line. Wrap private text as {private: …}.',
|
|
10
11
|
slots: "Each slot's picker sets what the preview sends. It is not saved in the profile.",
|
|
11
12
|
context: 'Preview is what the studio sends as the page. It is not saved in the profile.',
|
|
12
13
|
compaction: "The studio's chat compacts only before a turn.",
|
package/serve-page.mjs
CHANGED
|
@@ -42,13 +42,17 @@ if (!Number.isInteger(port) || !project) {
|
|
|
42
42
|
|
|
43
43
|
const page = readFileSync(PAGE_FILE, 'utf8').replaceAll(PROJECT_PLACEHOLDER, project);
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The build's files, each with the path a request names it by, less the page (served with its project filled in). Nothing else is ever read.
|
|
47
|
+
* why: held from the start, so a reinstall while the studio runs can't pull a file from under the page it opened with.
|
|
48
|
+
*/
|
|
46
49
|
const FILES = [];
|
|
47
50
|
(function list(dir, named) {
|
|
48
51
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
49
52
|
const file = path.join(dir, entry.name);
|
|
50
53
|
if (entry.isDirectory()) list(file, `${named}${entry.name}/`);
|
|
51
|
-
else if (entry.isFile() && file !== PAGE_FILE)
|
|
54
|
+
else if (entry.isFile() && file !== PAGE_FILE)
|
|
55
|
+
FILES.push([`${named}${entry.name}`, file, readFileSync(file)]);
|
|
52
56
|
}
|
|
53
57
|
})(root, '');
|
|
54
58
|
|
|
@@ -61,8 +65,8 @@ function fileFor(pathname) {
|
|
|
61
65
|
return undefined;
|
|
62
66
|
}
|
|
63
67
|
// why: the request only picks among the build's own files; what is read comes from the list, never from the address.
|
|
64
|
-
for (const [name, file] of FILES) {
|
|
65
|
-
if (name === relative) return { body
|
|
68
|
+
for (const [name, file, body] of FILES) {
|
|
69
|
+
if (name === relative) return { body, type: TYPES[path.extname(file)] };
|
|
66
70
|
}
|
|
67
71
|
return undefined;
|
|
68
72
|
}
|