moi-computer 0.13.1-next.2 → 0.13.1-next.3
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/client/features/chat/sessions/use-selected-session.ts +0 -13
- package/client/features/views/api.ts +33 -8
- package/client/features/views/use-view-actions.ts +2 -23
- package/client/features/workspace/tab-resolution.ts +1 -8
- package/client/features/workspace/use-workspace-navigation.ts +4 -3
- package/client/features/workspace/workspace-content.tsx +2 -11
- package/client/features/workspace/workspace-preferences.ts +67 -10
- package/client/features/workspace/workspace-state.ts +40 -15
- package/client/store/ui.ts +1 -6
- package/client/store/workspace-session.ts +30 -0
- package/dist/chunk-0h4zypgf.js +1 -0
- package/dist/chunk-1tksq43z.js +72 -0
- package/dist/chunk-6gxf0xr8.js +5 -0
- package/dist/{chunk-ec5ennpv.js → chunk-a865c7x4.js} +1 -1
- package/dist/{chunk-pdt9hxfw.js → chunk-f44cs6mw.js} +2 -2
- package/dist/{chunk-44khk4sp.js → chunk-h3qag4a6.js} +2 -2
- package/dist/{chunk-ectsnw81.js → chunk-q2tpy0h7.js} +2 -2
- package/dist/{chunk-rmd0ctfx.js → chunk-r95acex1.js} +74 -74
- package/dist/chunk-w5h9grdr.js +1 -0
- package/dist/{chunk-n0fawy9x.js → chunk-xj1pjhng.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/moi-context.ts +19 -5
- package/lib/types.ts +4 -5
- package/lib/workspace-layout.ts +3 -20
- package/package.json +2 -1
- package/server/AGENTS.md +1 -1
- package/server/README.md +21 -18
- package/server/api/index.ts +122 -118
- package/server/cli/commands/init.ts +7 -2
- package/server/cli/commands/remote.ts +128 -26
- package/server/cli/remote-control.ts +12 -9
- package/server/cli/remote-operations.ts +47 -44
- package/server/control.ts +9 -1
- package/server/onboarding/jobs.ts +1 -1
- package/server/remote/broker-client.ts +76 -0
- package/server/remote/broker.ts +81 -0
- package/server/remote/client.ts +212 -152
- package/server/remote/errors.ts +2 -0
- package/server/remote/routes.ts +121 -0
- package/server/scratchpad/document.ts +3 -2
- package/server/sessions/pending-views.ts +2 -1
- package/server/sessions/send-message.ts +102 -0
- package/server/sessions/view-sessions.ts +4 -94
- package/server/web.ts +2 -1
- package/server/workspace-state/file.ts +2 -0
- package/server/workspaces/api.ts +4 -8
- package/server/workspaces/tabs.ts +1 -2
- package/skill/SKILL.md +75 -34
- package/skill/references/SCRATCHPAD.md +4 -0
- package/skill/references/UI-COMPONENTS.md +1 -1
- package/dist/chunk-ba6mz56s.js +0 -72
- package/dist/chunk-en7w5ypg.js +0 -1
- package/dist/chunk-f695wcx5.js +0 -5
- package/dist/chunk-zv22wv0g.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ei,ne,B}from"/chunk-q2tpy0h7.js";export{ne as homePath,ei as loadAppConfig,B as useAppConfig};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* SVG/attribute allowlists and URI sanitization approach derived from DOMPurify.
|
|
3
3
|
* DOMPurify — MIT License, Copyright (c) 2015 Mario Heiderich
|
|
4
4
|
* https://github.com/cure53/DOMPurify/blob/main/LICENSE
|
|
5
|
-
*/var v=new Set(["svg","a","altglyph","altglyphdef","altglyphitem","animate","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","filter","font","foreignobject","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","set","stop","style","switch","symbol","text","textpath","title","tref","tspan","use","view","vkern"]),y=new Set(["a","b","blockquote","body","br","code","del","div","em","h1","h2","h3","h4","h5","h6","i","li","mark","ol","p","pre","span","strong","s","sub","sup","table","tbody","td","th","thead","tr","u","ul"]),A=new Set(["script","iframe","object","embed","form","input","textarea","select","button","link","meta","base","img","video","audio","source","picture","svg"]),x=new Set(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clip-path","clip-rule","clippathunits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","diffuseconstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","from","fx","fy","g1","g2","glyph-name","glyphref","gradienttransform","gradientunits","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","kernelmatrix","kernelunitlength","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","mask","mask-type","maskcontentunits","maskunits","max","media","method","min","mode","name","numoctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","radius","refx","refy","repeatcount","repeatdur","requiredfeatures","restart","result","role","rotate","rx","ry","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","text-anchor","text-decoration","text-rendering","textlength","to","transform","transform-origin","type","u1","u2","unicode","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewbox","visibility","width","word-spacing","wrap","writing-mode","x","x1","x2","xchannelselector","xlink:href","xml:id","xml:space","xlink:title","xmlns","xmlns:xlink","y","y1","y2","z","zoomandpan"]),k=new Set(["class","dir","href","id","lang","role","style","tabindex","title"]),d=/^data-/,p=/^aria-/,o=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,g=/^(?:https?:|mailto:)/i,S=/^data:/i,T=/^data:image\/(?:png|jpeg|jpg|gif|webp|avif|bmp|tiff|x-icon|vnd\.microsoft\.icon)[;,]/i,_=/^data:image\/svg\+xml[;,]/i,u=/^#/;function w(t){return t.replace(/\\([0-9a-fA-F]{1,6})\s?|\\([^\n])/g,(i,r,n)=>{if(r){let e=parseInt(r,16);if(e>1114111||e===0)return"�";return String.fromCodePoint(e)}return n})}var E=/^data:(?:image\/(?:png|jpeg|jpg|gif|webp|avif)|font\/(?:woff2?|opentype|truetype|sfnt)|application\/(?:x-font-woff|font-woff2?|x-font-ttf|x-font-opentype|font-sfnt))[;,]/i;function f(t){let i=w(t);return i=i.replace(/@import\s+(?:url\s*\([^)]*\)|"[^"]*"|'[^']*')[^;]*;?|@import\b[^;]*;?/gi,""),i=i.replace(/expression\s*\([^)]*\)/gi,""),i=i.replace(/-moz-binding\s*:[^;]*/gi,""),i=i.replace(/behavior\s*:[^;]*/gi,""),i=i.replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gis,(r,n,e)=>{let a=e.replace(o,"");if(E.test(a)||u.test(a))return r;return""}),i}function L(t){return f(t)}var N=new Set(["animate","set","animatecolor","animatetransform"]),R=/^(?:href|xlink:href|on)/i;function z(t){let i=t.getAttribute("attributeName");if(!i)return!1;return R.test(i.replace(o,""))}var h=/^on/i,D=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]),m=10;function I(t){let i=t.search(/;base64,/i);if(i>=0){let n=t.slice(i+8),e=Uint8Array.from(atob(n),(a)=>a.charCodeAt(0));return new TextDecoder().decode(e)}let r=t.indexOf(",");if(r<0)return null;return decodeURIComponent(t.slice(r+1))}function C(t){let i=new TextEncoder().encode(t),r=Array.from(i,(n)=>String.fromCharCode(n)).join("");return"data:image/svg+xml;base64,"+btoa(r)}function G(t,i){if(i>=m)return console.warn(`Embedded SVG data URI recursion depth limit (${m}) reached`),null;let r;try{let e=I(t);if(e===null)return null;r=e}catch{return null}let n=b(r,i+1);if(!n)return null;return C(n)}function O(t,i,r,n){let e=r.replace(o,""),a=t.tagName.toLowerCase();if(a==="image"||a==="feimage"){if(T.test(e))return r;if(_.test(e))return G(e,n);return null}if(a==="use"){if(u.test(e))return r;return null}if(a==="a"){if(g.test(e))return r;return null}if(S.test(e)||u.test(e))return r;return null}function l(t,i){for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!x.has(e)){t.removeAttribute(n.name);continue}if(e==="href"||e==="xlink:href"){let s=O(t,e,n.value,i);if(s===null)t.removeAttribute(n.name);else if(s!==n.value)n.value=s;continue}if(e==="style"){n.value=f(n.value);continue}if(D.has(e)&&/url\s*\(/i.test(n.value))n.value=f(n.value)}}function M(t){let i=t.tagName.toLowerCase();for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!k.has(e)){t.removeAttribute(n.name);continue}if(e==="href"){if(i!=="a"){t.removeAttribute(n.name);continue}let s=n.value.replace(o,"");if(!g.test(s))t.removeAttribute(n.name);continue}if(e==="style")n.value=f(n.value)}}function c(t,i,r){for(let n=t.children.length-1;n>=0;n--){let e=t.children[n],a=e.tagName.toLowerCase();if(i==="svg")if(a==="foreignobject")l(e,r),c(e,"html",r);else if(a==="style"){if(l(e,r),e.textContent)e.textContent=L(e.textContent)}else if(N.has(a)&&z(e))e.remove();else if(v.has(a))l(e,r),c(e,"svg",r);else e.remove();else if(A.has(a))e.remove();else if(y.has(a))M(e),c(e,"html",r);else e.remove()}}function b(t,i){let r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return"";let e=r.documentElement;if(e.tagName.toLowerCase()!=="svg")return"";if(l(e,i),c(e,"svg",i),e.children.length===0)return"";return new XMLSerializer().serializeToString(e)}function
|
|
5
|
+
*/var v=new Set(["svg","a","altglyph","altglyphdef","altglyphitem","animate","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","filter","font","foreignobject","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","set","stop","style","switch","symbol","text","textpath","title","tref","tspan","use","view","vkern"]),y=new Set(["a","b","blockquote","body","br","code","del","div","em","h1","h2","h3","h4","h5","h6","i","li","mark","ol","p","pre","span","strong","s","sub","sup","table","tbody","td","th","thead","tr","u","ul"]),A=new Set(["script","iframe","object","embed","form","input","textarea","select","button","link","meta","base","img","video","audio","source","picture","svg"]),x=new Set(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clip-path","clip-rule","clippathunits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","diffuseconstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","from","fx","fy","g1","g2","glyph-name","glyphref","gradienttransform","gradientunits","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","kernelmatrix","kernelunitlength","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","mask","mask-type","maskcontentunits","maskunits","max","media","method","min","mode","name","numoctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","radius","refx","refy","repeatcount","repeatdur","requiredfeatures","restart","result","role","rotate","rx","ry","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","text-anchor","text-decoration","text-rendering","textlength","to","transform","transform-origin","type","u1","u2","unicode","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewbox","visibility","width","word-spacing","wrap","writing-mode","x","x1","x2","xchannelselector","xlink:href","xml:id","xml:space","xlink:title","xmlns","xmlns:xlink","y","y1","y2","z","zoomandpan"]),k=new Set(["class","dir","href","id","lang","role","style","tabindex","title"]),d=/^data-/,p=/^aria-/,o=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,g=/^(?:https?:|mailto:)/i,S=/^data:/i,T=/^data:image\/(?:png|jpeg|jpg|gif|webp|avif|bmp|tiff|x-icon|vnd\.microsoft\.icon)[;,]/i,_=/^data:image\/svg\+xml[;,]/i,u=/^#/;function w(t){return t.replace(/\\([0-9a-fA-F]{1,6})\s?|\\([^\n])/g,(i,r,n)=>{if(r){let e=parseInt(r,16);if(e>1114111||e===0)return"�";return String.fromCodePoint(e)}return n})}var E=/^data:(?:image\/(?:png|jpeg|jpg|gif|webp|avif)|font\/(?:woff2?|opentype|truetype|sfnt)|application\/(?:x-font-woff|font-woff2?|x-font-ttf|x-font-opentype|font-sfnt))[;,]/i;function f(t){let i=w(t);return i=i.replace(/@import\s+(?:url\s*\([^)]*\)|"[^"]*"|'[^']*')[^;]*;?|@import\b[^;]*;?/gi,""),i=i.replace(/expression\s*\([^)]*\)/gi,""),i=i.replace(/-moz-binding\s*:[^;]*/gi,""),i=i.replace(/behavior\s*:[^;]*/gi,""),i=i.replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gis,(r,n,e)=>{let a=e.replace(o,"");if(E.test(a)||u.test(a))return r;return""}),i}function L(t){return f(t)}var N=new Set(["animate","set","animatecolor","animatetransform"]),R=/^(?:href|xlink:href|on)/i;function z(t){let i=t.getAttribute("attributeName");if(!i)return!1;return R.test(i.replace(o,""))}var h=/^on/i,D=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]),m=10;function I(t){let i=t.search(/;base64,/i);if(i>=0){let n=t.slice(i+8),e=Uint8Array.from(atob(n),(a)=>a.charCodeAt(0));return new TextDecoder().decode(e)}let r=t.indexOf(",");if(r<0)return null;return decodeURIComponent(t.slice(r+1))}function C(t){let i=new TextEncoder().encode(t),r=Array.from(i,(n)=>String.fromCharCode(n)).join("");return"data:image/svg+xml;base64,"+btoa(r)}function G(t,i){if(i>=m)return console.warn(`Embedded SVG data URI recursion depth limit (${m}) reached`),null;let r;try{let e=I(t);if(e===null)return null;r=e}catch{return null}let n=b(r,i+1);if(!n)return null;return C(n)}function O(t,i,r,n){let e=r.replace(o,""),a=t.tagName.toLowerCase();if(a==="image"||a==="feimage"){if(T.test(e))return r;if(_.test(e))return G(e,n);return null}if(a==="use"){if(u.test(e))return r;return null}if(a==="a"){if(g.test(e))return r;return null}if(S.test(e)||u.test(e))return r;return null}function l(t,i){for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!x.has(e)){t.removeAttribute(n.name);continue}if(e==="href"||e==="xlink:href"){let s=O(t,e,n.value,i);if(s===null)t.removeAttribute(n.name);else if(s!==n.value)n.value=s;continue}if(e==="style"){n.value=f(n.value);continue}if(D.has(e)&&/url\s*\(/i.test(n.value))n.value=f(n.value)}}function M(t){let i=t.tagName.toLowerCase();for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!k.has(e)){t.removeAttribute(n.name);continue}if(e==="href"){if(i!=="a"){t.removeAttribute(n.name);continue}let s=n.value.replace(o,"");if(!g.test(s))t.removeAttribute(n.name);continue}if(e==="style")n.value=f(n.value)}}function c(t,i,r){for(let n=t.children.length-1;n>=0;n--){let e=t.children[n],a=e.tagName.toLowerCase();if(i==="svg")if(a==="foreignobject")l(e,r),c(e,"html",r);else if(a==="style"){if(l(e,r),e.textContent)e.textContent=L(e.textContent)}else if(N.has(a)&&z(e))e.remove();else if(v.has(a))l(e,r),c(e,"svg",r);else e.remove();else if(A.has(a))e.remove();else if(y.has(a))M(e),c(e,"html",r);else e.remove()}}function b(t,i){let r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return"";let e=r.documentElement;if(e.tagName.toLowerCase()!=="svg")return"";if(l(e,i),c(e,"svg",i),e.children.length===0)return"";return new XMLSerializer().serializeToString(e)}function Qn(t){return b(t,0)}export{Qn};
|
package/dist/index.html
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<link rel="modulepreload" href="/vendor/react/19.2.4/production/react-dom-client.js" />
|
|
56
56
|
<link rel="modulepreload" href="/vendor/react/19.2.4/production/_impl/react-dom-client.js" />
|
|
57
57
|
|
|
58
|
-
<link rel="stylesheet" crossorigin href="/chunk-kffcah9w.css"><script type="module" crossorigin src="/chunk-
|
|
58
|
+
<link rel="stylesheet" crossorigin href="/chunk-kffcah9w.css"><script type="module" crossorigin src="/chunk-h3qag4a6.js"></script></head>
|
|
59
59
|
<body>
|
|
60
60
|
<div id="root"></div>
|
|
61
61
|
|
package/lib/moi-context.ts
CHANGED
|
@@ -27,8 +27,9 @@ const MOI_CONTEXT_OPEN = '<moi-context>'
|
|
|
27
27
|
const MOI_CONTEXT_CLOSE = '</moi-context>'
|
|
28
28
|
// Start of the first line inside the tag. Doubles as the strip guard: a user
|
|
29
29
|
// literally typing `<moi-context>` in their message won't have their text
|
|
30
|
-
// eaten.
|
|
31
|
-
const MOI_CONTEXT_MARKER = 'You are
|
|
30
|
+
// eaten. Retain older markers so persisted chat history still strips correctly.
|
|
31
|
+
const MOI_CONTEXT_MARKER = 'You are in a Moi workspace'
|
|
32
|
+
const LEGACY_MOI_CONTEXT_MARKER = 'You are running in a `moi` workspace'
|
|
32
33
|
|
|
33
34
|
const SYSTEM_REMINDER_OPEN = '<system-reminder>'
|
|
34
35
|
const SYSTEM_REMINDER_CLOSE = '</system-reminder>'
|
|
@@ -57,6 +58,8 @@ export type TabContext = {
|
|
|
57
58
|
// the server for programmatic pending-view sends. Extend this (and
|
|
58
59
|
// `renderMoiContext`) when new ambient fields land.
|
|
59
60
|
export type MoiContext = {
|
|
61
|
+
// Server-resolved; the browser cannot choose the execution location.
|
|
62
|
+
workspaceMode?: 'local' | 'remote'
|
|
60
63
|
// Server-resolved path to the installed COLLAB.md reference for this workspace.
|
|
61
64
|
collabReference?: string
|
|
62
65
|
// The workspace tab the user is on when they hit send.
|
|
@@ -133,10 +136,16 @@ function describeTab(tab: Pick<TabContext, 'id' | 'title'>): string {
|
|
|
133
136
|
// wrapped text would double-wrap it.
|
|
134
137
|
export function renderMoiContextBody(ctx: MoiContext): string {
|
|
135
138
|
const preamble = [
|
|
136
|
-
`${MOI_CONTEXT_MARKER}
|
|
137
|
-
'Read the
|
|
139
|
+
`${MOI_CONTEXT_MARKER}: a shared UI where the user chats with you, which you can extend and customize.`,
|
|
140
|
+
'Read the `moi-workspace` skill before responding unless already read in this chat.'
|
|
138
141
|
].join('\n')
|
|
139
142
|
const sections: string[] = []
|
|
143
|
+
if (ctx.workspaceMode) {
|
|
144
|
+
const lines = [`Workspace: ${ctx.workspaceMode}`]
|
|
145
|
+
if (ctx.workspaceMode === 'remote')
|
|
146
|
+
lines.push('You run in a local directory linked to a remote workspace.')
|
|
147
|
+
sections.push(lines.join('\n'))
|
|
148
|
+
}
|
|
140
149
|
const appletIsActiveView =
|
|
141
150
|
ctx.applet?.kind === 'view' && ctx.activeTab?.id === `views/${ctx.applet.id}`
|
|
142
151
|
if (ctx.activeTab) {
|
|
@@ -186,6 +195,7 @@ export function renderMoiContext(ctx: MoiContext): string {
|
|
|
186
195
|
export function isMoiContext(value: unknown): value is MoiContext {
|
|
187
196
|
if (!isParamsRecord(value)) return false
|
|
188
197
|
const v = value as {
|
|
198
|
+
workspaceMode?: unknown
|
|
189
199
|
collabReference?: unknown
|
|
190
200
|
activeTab?: unknown
|
|
191
201
|
applet?: unknown
|
|
@@ -193,6 +203,9 @@ export function isMoiContext(value: unknown): value is MoiContext {
|
|
|
193
203
|
directives?: unknown
|
|
194
204
|
}
|
|
195
205
|
return (
|
|
206
|
+
(v.workspaceMode === undefined ||
|
|
207
|
+
v.workspaceMode === 'local' ||
|
|
208
|
+
v.workspaceMode === 'remote') &&
|
|
196
209
|
(v.activeTab === undefined || isTabContext(v.activeTab)) &&
|
|
197
210
|
(v.collabReference === undefined || typeof v.collabReference === 'string') &&
|
|
198
211
|
(v.applet === undefined || isAppletContext(v.applet)) &&
|
|
@@ -263,7 +276,8 @@ function stripOneMoiContext(text: string): string {
|
|
|
263
276
|
if (start === -1) return text
|
|
264
277
|
const end = text.indexOf(MOI_CONTEXT_CLOSE, start)
|
|
265
278
|
if (end === -1) return text
|
|
266
|
-
|
|
279
|
+
const body = text.slice(start, end)
|
|
280
|
+
if (!body.includes(MOI_CONTEXT_MARKER) && !body.includes(LEGACY_MOI_CONTEXT_MARKER)) return text
|
|
267
281
|
let before = text.slice(0, start)
|
|
268
282
|
let after = text.slice(end + MOI_CONTEXT_CLOSE.length)
|
|
269
283
|
if (
|
package/lib/types.ts
CHANGED
|
@@ -315,6 +315,9 @@ export type WorkspaceSessionState = {
|
|
|
315
315
|
// Personal state on this Moi installation, shared across its browser windows.
|
|
316
316
|
// GET /api/workspaces/:id/state; writes publish `state:changed`.
|
|
317
317
|
export type WorkspaceState = {
|
|
318
|
+
// Personal tab list/order, excluding the always-open Overview.
|
|
319
|
+
// Missing opens all available tabs; an empty list opens only Overview.
|
|
320
|
+
openTabs?: WorkspaceTabId[]
|
|
318
321
|
// Personal defaults for new chats on this Moi installation.
|
|
319
322
|
chatDefaults?: SessionConfig
|
|
320
323
|
// Goes up by one with every saved change. Lets clients drop an older copy
|
|
@@ -614,11 +617,7 @@ export type LayoutMode = 'fullscreen' | 'split'
|
|
|
614
617
|
|
|
615
618
|
export type WorkspaceTabId = 'overview' | 'scratchpad' | `views/${string}`
|
|
616
619
|
|
|
617
|
-
//
|
|
618
|
-
// state — the live active tab is each browser tab's URL (`/workspace/:id/<tab>`).
|
|
619
|
-
// The saved default answers one question: where a bare `/workspace/:id` lands
|
|
620
|
-
// (and which row `moi tabs` marks). Navigating writes it, so it tracks the last
|
|
621
|
-
// tab switch, last writer wins across clients.
|
|
620
|
+
// Client tab list and remembered active tab; the URL determines live focus.
|
|
622
621
|
export type WorkspaceTabsState = {
|
|
623
622
|
open: WorkspaceTabId[]
|
|
624
623
|
active: WorkspaceTabId
|
package/lib/workspace-layout.ts
CHANGED
|
@@ -2,26 +2,9 @@ import { createDefaultWidgetGrid } from './default-widgets'
|
|
|
2
2
|
import type { WorkspaceLayout, WorkspaceTabsState } from './types'
|
|
3
3
|
import { isWorkspaceTabId } from './workspace-tabs'
|
|
4
4
|
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function normalizeWorkspaceTabs(value: unknown): WorkspaceTabsState {
|
|
10
|
-
const defaults = createDefaultWorkspaceTabs()
|
|
11
|
-
if (!value || typeof value !== 'object') return defaults
|
|
12
|
-
|
|
13
|
-
const raw = value as Record<string, unknown>
|
|
14
|
-
const savedOpen = Array.isArray(raw.open)
|
|
15
|
-
? raw.open.filter(isWorkspaceTabId).filter((tab, index, all) => all.indexOf(tab) === index)
|
|
16
|
-
: []
|
|
17
|
-
if (savedOpen.length === 0) return defaults
|
|
18
|
-
|
|
19
|
-
const open = [
|
|
20
|
-
'overview',
|
|
21
|
-
...savedOpen.filter(tab => tab !== 'overview')
|
|
22
|
-
] satisfies WorkspaceTabsState['open']
|
|
23
|
-
const active = isWorkspaceTabId(raw.active) && open.includes(raw.active) ? raw.active : 'overview'
|
|
24
|
-
return { open, active }
|
|
5
|
+
export function normalizeOpenTabs(value: unknown): WorkspaceTabsState['open'] {
|
|
6
|
+
if (!Array.isArray(value)) return []
|
|
7
|
+
return [...new Set(value.filter(tab => isWorkspaceTabId(tab) && tab !== 'overview'))]
|
|
25
8
|
}
|
|
26
9
|
|
|
27
10
|
export function createDefaultWorkspaceLayout(): WorkspaceLayout {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moi-computer",
|
|
3
|
-
"version": "0.13.1-next.
|
|
3
|
+
"version": "0.13.1-next.3",
|
|
4
4
|
"description": "Local AI workspace powered by the Claude Agent SDK, Bun, React, and Tailwind. Requires Bun.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"react-markdown": "^10.1.0",
|
|
105
105
|
"react-resizable": "^3.2.0",
|
|
106
106
|
"react-resizable-panels": "^4.12.4",
|
|
107
|
+
"regexparam": "^3.0.0",
|
|
107
108
|
"rehype-highlight": "^7.0.2",
|
|
108
109
|
"remark-gfm": "^4.0.1",
|
|
109
110
|
"shadcn": "4.21.0",
|
package/server/AGENTS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Bun server on port 13337 by default. Serves the client at `/`, upgrades `/ws` to WebSocket. Read [README.md](README.md) for the directory map, storage ownership, and test commands.
|
|
2
2
|
|
|
3
3
|
- `web.ts` owns the Bun fullstack surface only: the SPA HTML shell (dev bundler + HMR / prebuilt `dist/`), the two WebSocket channels (`/ws` chat, `/api/workspaces/ws` live events), and graceful shutdown. Every HTTP API request is delegated to the Hono app via `fetch`.
|
|
4
|
-
- `api/index.ts` assembles the Hono REST API (all `/api/*` routes). Harness authentication routes live in `api/harnesses.ts`. `
|
|
4
|
+
- `api/index.ts` assembles the Hono REST API (all `/api/*` routes). Harness authentication routes live in `api/harnesses.ts`. `personalWorkspace` and `ownerWorkspace` middleware resolve `:id` → workspace (404 if missing) and stash it on the context, so handlers read `c.get('ws')`. Declare the policy on each workspace route; owner routes reject local references to remote workspaces. Its catch-all serves the prebuilt client from `dist/` in prod via Hono's `serveStatic` (cached, traversal-safe).
|
|
5
5
|
- API tests live in `api/` without an `api-` filename prefix. Unit tests stay beside their modules; existing integration and fixture-based tests live in `test/`.
|
|
6
6
|
- `cli.ts` is the executable entry point and loads color setup before the command tree. `cli/index.ts` owns command registration, root help, and demo/managed-user gates; `cli/commands/` holds one module per top-level command, with its subcommands and private helpers. Shared CLI support lives directly in `cli/`. Server launches use `PACKAGE_ROOT` to find the entry point and package files, independent of the command module's location.
|
|
7
7
|
- `scratchpad/` owns document persistence and reads (`document.ts`), asset files and cleanup (`assets.ts`), headless writes (`executor.ts` and `shape-defaults.ts`), and browser operation forwarding (`relay.ts`). Its unit tests live beside those modules.
|
package/server/README.md
CHANGED
|
@@ -26,6 +26,10 @@ Keep shared helpers in the feature that owns them. A folder does not imply a
|
|
|
26
26
|
strict dependency layer: workspace setup installs skills, applets use workspace
|
|
27
27
|
environment settings, and view builds coordinate with session metadata.
|
|
28
28
|
|
|
29
|
+
[sessions/send-message.ts](sessions/send-message.ts) prepares and sends workspace messages
|
|
30
|
+
for chat, onboarding, and view builds, including the agent context envelope.
|
|
31
|
+
[sessions/view-sessions.ts](sessions/view-sessions.ts) owns view creation and build handoffs.
|
|
32
|
+
|
|
29
33
|
The two registries have different jobs: `workspaces/registry.ts` owns the local
|
|
30
34
|
workspace list; `harness/registry.ts` owns the available agent backends.
|
|
31
35
|
|
|
@@ -56,24 +60,23 @@ corresponding directory above.
|
|
|
56
60
|
|
|
57
61
|
## Storage ownership
|
|
58
62
|
|
|
59
|
-
| State
|
|
60
|
-
|
|
|
61
|
-
| Workspace widget layout and theme
|
|
62
|
-
| Applet source
|
|
63
|
-
| Generated bundles and thumbnails
|
|
64
|
-
| Scratchpad document and image bytes
|
|
65
|
-
| Installation-wide app settings, including `showOnboarding`
|
|
66
|
-
| Onboarding discovery results and workspace creation operation records
|
|
67
|
-
| Registered workspaces
|
|
68
|
-
|
|
|
69
|
-
| Workspace environment preferences and secrets
|
|
70
|
-
| Provider credentials and conversation history
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
must not change its storage paths or persisted formats.
|
|
63
|
+
| State | Location and owner |
|
|
64
|
+
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
65
|
+
| Workspace widget layout and theme | `.moi/.workspace.json`, read and written by `workspaces/layout.ts` |
|
|
66
|
+
| Applet source | `.moi/views/`, `.moi/widgets/`, and shared workspace source |
|
|
67
|
+
| Generated bundles and thumbnails | `.moi/.build/` and `.moi/.cache/`; re-creatable |
|
|
68
|
+
| Scratchpad document and image bytes | `.moi/.scratchpad.json` and `.moi/.scratchpad/`; preserve both |
|
|
69
|
+
| Installation-wide app settings, including `showOnboarding` | `DATA_DIR/settings.json`, owned by `app-settings.ts` |
|
|
70
|
+
| Onboarding discovery results and workspace creation operation records | `DATA_DIR/onboarding/`, owned by [onboarding/jobs.ts](onboarding/jobs.ts) |
|
|
71
|
+
| Registered workspaces | `DATA_DIR/workspaces.json`, owned by `workspaces/registry.ts` |
|
|
72
|
+
| Personal tabs and chat state, including pending views | `DATA_DIR/workspaces/<workspace id>/state.json`, stored by `workspace-state/`; session metadata managed by `sessions/` |
|
|
73
|
+
| Workspace environment preferences and secrets | `workspaces/env.ts`; metadata in `DATA_DIR`, secrets in the OS keychain or file fallback |
|
|
74
|
+
| Provider credentials and conversation history | Owned by each provider; see `harness/README.md` |
|
|
75
|
+
|
|
76
|
+
The active tab and floating-chat visibility live per workspace in sessionStorage (`moi:workspace-session`). Split/fullscreen mode and panel widths live in localStorage (`moi:ui`).
|
|
77
|
+
|
|
78
|
+
See [navigation](../docs/navigation.md) and [view/chat behavior](../docs/view-chats.md) for how
|
|
79
|
+
this state is used. Moving a module must not change its storage paths or persisted formats.
|
|
77
80
|
|
|
78
81
|
## Paths and process boundaries
|
|
79
82
|
|