moi-computer 0.13.1-next.1 → 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/api/app-config.ts +12 -1
- package/client/api/http.ts +11 -1
- package/client/app/app-router.tsx +3 -2
- package/client/app/routes/home-route.tsx +1 -1
- package/client/app/routes/workspace-registration.tsx +68 -0
- package/client/app/routes/workspace-route.tsx +33 -6
- package/client/app/shell/sidebar-layout.tsx +10 -5
- package/client/components/shared/workspace-icon.tsx +8 -17
- package/client/features/account/account-test-utils.tsx +15 -9
- package/client/features/account/api.ts +6 -6
- package/client/features/account/profile-actions.ts +5 -7
- package/client/features/app-settings/settings-page.tsx +2 -1
- package/client/features/applets/api.ts +6 -6
- package/client/features/applets/applet-cache.ts +6 -5
- package/client/features/applets/applet-log.ts +2 -1
- package/client/features/applets/applet-runtime.ts +2 -1
- package/client/features/applets/use-applet.ts +73 -18
- package/client/features/applets/widget-shell.tsx +4 -2
- package/client/features/chat/applet-chat-intents.ts +5 -13
- package/client/features/chat/chat-popup.tsx +8 -4
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/composer/model-order.ts +4 -4
- package/client/features/chat/composer/model-picker.tsx +12 -10
- package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
- package/client/features/chat/sessions/api.ts +11 -28
- package/client/features/chat/sessions/use-selected-session.ts +14 -109
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/members/api.ts +4 -10
- package/client/features/collab/members/hooks.ts +32 -38
- package/client/features/collab/members/store.ts +96 -71
- package/client/features/collab/members/types.ts +5 -3
- package/client/features/collab/presence/client.ts +2 -3
- package/client/features/collab/presence/hooks.tsx +1 -1
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/workspace-members.tsx +0 -8
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -1
- package/client/features/dev/workspace-setup-preview.tsx +6 -4
- package/client/features/harness/api.ts +13 -10
- package/client/features/harness/harness-login-panel.tsx +9 -5
- package/client/features/harness/harness-presentation.ts +4 -4
- package/client/features/harness/harness-selector.tsx +13 -13
- package/client/features/harness/use-harness-login.ts +5 -5
- package/client/features/home/api.ts +38 -2
- package/client/features/home/home-page.tsx +43 -13
- package/client/features/home/shared-workspaces.tsx +70 -0
- package/client/features/home/workspace-invitations.tsx +101 -0
- package/client/features/identity/host-api.ts +3 -2
- package/client/features/identity/store.ts +1 -7
- package/client/features/onboarding/agent-setup-step.tsx +8 -8
- package/client/features/onboarding/onboarding-page.tsx +3 -2
- package/client/features/onboarding/workspace-setup-step.tsx +1 -1
- package/client/features/overview/api.ts +3 -5
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/views-widget.tsx +2 -2
- package/client/features/overview/hidden-panel.tsx +7 -5
- package/client/features/overview/overview.tsx +18 -16
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +9 -7
- package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
- package/client/features/views/api.ts +66 -23
- package/client/features/views/use-view-actions.ts +10 -41
- package/client/features/views/view-manager.tsx +1 -1
- package/client/features/views/view-submission.ts +2 -21
- package/client/features/workspace/add/api.ts +5 -4
- package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
- package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
- package/client/features/workspace/add/use-workspace-import.ts +10 -10
- package/client/features/workspace/add/workspace-agent-options.ts +21 -20
- package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
- package/client/features/workspace/api.ts +60 -13
- package/client/features/workspace/harness-transition.ts +7 -13
- package/client/features/workspace/remote.ts +25 -0
- package/client/features/workspace/settings/api.ts +7 -12
- package/client/features/workspace/settings/connectors-settings.tsx +3 -3
- package/client/features/workspace/settings/general-settings.tsx +8 -8
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
- package/client/features/workspace/setup/workspace-setup.tsx +6 -6
- package/client/features/workspace/tab-resolution.ts +1 -8
- package/client/features/workspace/use-workspace-navigation.ts +11 -7
- package/client/features/workspace/workspace-content.tsx +24 -31
- package/client/features/workspace/workspace-frame.tsx +13 -26
- package/client/features/workspace/workspace-layout-context.tsx +45 -12
- package/client/features/workspace/workspace-menu.tsx +2 -2
- package/client/features/workspace/workspace-pane.tsx +22 -0
- package/client/features/workspace/workspace-pending-screen.tsx +1 -1
- package/client/features/workspace/workspace-preferences.ts +91 -0
- package/client/features/workspace/workspace-presentation.tsx +12 -16
- package/client/features/workspace/workspace-screen.tsx +2 -2
- package/client/features/workspace/workspace-state.ts +42 -16
- package/client/features/workspace/workspace-tabs.tsx +1 -1
- package/client/features/workspace/workspace-test-utils.ts +23 -0
- package/client/runtime/use-workspace-events.ts +14 -0
- package/client/runtime/workspace-events.ts +9 -9
- package/client/store/ui.ts +24 -9
- 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-a865c7x4.js +1 -0
- package/dist/chunk-f44cs6mw.js +2 -0
- package/dist/chunk-h3qag4a6.js +2 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/chunk-q2tpy0h7.js +2 -0
- package/dist/chunk-r95acex1.js +546 -0
- package/dist/chunk-w5h9grdr.js +1 -0
- package/dist/{chunk-th91xfnp.js → chunk-xj1pjhng.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/moi-context.ts +19 -5
- package/lib/types.ts +38 -54
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +5 -24
- package/package.json +5 -2
- package/server/AGENTS.md +1 -1
- package/server/README.md +36 -31
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +268 -162
- package/server/applets/index.ts +15 -9
- package/server/applets/views.ts +2 -17
- package/server/applets/widgets.ts +3 -2
- package/server/cli/commands/config.ts +8 -20
- package/server/cli/commands/hermes.ts +2 -2
- package/server/cli/commands/init.ts +102 -54
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +330 -0
- package/server/cli/commands/skill.ts +4 -4
- package/server/cli/commands/tabs.ts +5 -12
- package/server/cli/control.ts +35 -4
- package/server/cli/index.ts +10 -6
- package/server/cli/remote-command.ts +77 -0
- package/server/cli/remote-control.ts +73 -0
- package/server/cli/remote-operations.ts +247 -0
- package/server/collab/config.ts +3 -3
- package/server/collab/skill/index.ts +3 -3
- package/server/control.ts +47 -12
- package/server/harness/acp/session.ts +4 -4
- package/server/harness/auth.ts +26 -31
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/codex/discovery.ts +1 -1
- package/server/harness/codex/session.ts +1 -1
- package/server/harness/detect.ts +14 -19
- package/server/harness/executable.ts +10 -10
- package/server/harness/hermes/NOTES.md +2 -2
- package/server/harness/hermes/index.ts +1 -1
- package/server/harness/install.ts +11 -11
- package/server/harness/openclaw/index.ts +1 -1
- package/server/harness/registry.ts +7 -6
- package/server/harness/types.ts +4 -4
- package/server/onboarding/jobs.ts +2 -2
- package/server/operations/commands.ts +46 -0
- package/server/operations/files.ts +148 -0
- package/server/operations/server.ts +206 -0
- package/server/remote/agent.ts +103 -0
- package/server/remote/broker-client.ts +76 -0
- package/server/remote/broker.ts +81 -0
- package/server/remote/client.ts +725 -0
- package/server/remote/errors.ts +2 -0
- package/server/remote/routes.ts +121 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +33 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +17 -0
- package/server/sessions/send-message.ts +102 -0
- package/server/sessions/view-sessions.ts +9 -101
- package/server/skills/locations.ts +4 -4
- package/server/skills/update.ts +11 -11
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -11
- package/server/web.ts +13 -9
- package/server/workspace-state/file.ts +4 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +24 -0
- package/server/workspaces/change-harness.ts +15 -26
- package/server/workspaces/import.ts +4 -4
- package/server/workspaces/init.ts +15 -13
- package/server/workspaces/layout.ts +60 -66
- package/server/workspaces/registry.ts +43 -18
- package/server/workspaces/shared.ts +74 -0
- package/server/workspaces/tabs.ts +5 -12
- package/skill/SKILL.md +80 -19
- package/skill/references/SCRATCHPAD.md +4 -0
- package/skill/references/UI-COMPONENTS.md +1 -1
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/members/keys.ts +0 -6
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-3smkkcfw.js +0 -546
- package/dist/chunk-47h9c2qy.js +0 -2
- package/dist/chunk-8qed2gqp.js +0 -75
- package/dist/chunk-8zy3vesm.js +0 -1
- package/dist/chunk-a47zy276.js +0 -2
- package/dist/chunk-g4c1nte9.css +0 -1
- package/dist/chunk-kcactdr4.js +0 -2
- package/dist/chunk-m8bhx6tw.js +0 -1
- package/dist/chunk-pf19zcrn.js +0 -2
- package/dist/chunk-ygzxah0e.js +0 -1
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
|
@@ -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-
|
|
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
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HarnessType } from './types'
|
|
2
2
|
|
|
3
3
|
type HarnessInstruction = {
|
|
4
4
|
reason: string
|
|
5
5
|
command: string
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export const HARNESS_INSTRUCTIONS: Record<
|
|
8
|
+
export const HARNESS_INSTRUCTIONS: Record<HarnessType, HarnessInstruction> = {
|
|
9
9
|
'claude-code': {
|
|
10
10
|
reason: 'Run in terminal to install Claude:',
|
|
11
11
|
command: 'curl -fsSL https://claude.ai/install.sh | bash'
|
|
@@ -24,7 +24,7 @@ export const HARNESS_INSTRUCTIONS: Record<WorkspaceType, HarnessInstruction> = {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function harnessInstructionMessage(
|
|
28
|
-
const { reason, command } = HARNESS_INSTRUCTIONS[
|
|
27
|
+
export function harnessInstructionMessage(harness: HarnessType): string {
|
|
28
|
+
const { reason, command } = HARNESS_INSTRUCTIONS[harness]
|
|
29
29
|
return `${reason} ${command}`
|
|
30
30
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HarnessType } from './types'
|
|
2
|
+
|
|
3
|
+
export const HARNESS_ORDER = [
|
|
4
|
+
'claude-code',
|
|
5
|
+
'codex',
|
|
6
|
+
'openclaw',
|
|
7
|
+
'hermes'
|
|
8
|
+
] as const satisfies readonly HarnessType[]
|
|
9
|
+
|
|
10
|
+
export function orderHarnesses(harnesses: Iterable<HarnessType>): HarnessType[] {
|
|
11
|
+
const unique = new Set(harnesses)
|
|
12
|
+
return HARNESS_ORDER.filter(harness => unique.has(harness))
|
|
13
|
+
}
|
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RemoteWorkspaceTarget } from './workspace-config'
|
|
1
2
|
import type { PreviewBlock, StreamEvent } from './format'
|
|
2
3
|
import type { IdentityIconId } from './identity-icons'
|
|
3
4
|
import type { MoiContext } from './moi-context'
|
|
@@ -230,8 +231,6 @@ export type MessageAttachment =
|
|
|
230
231
|
| ({ type: 'upload'; uploadId: string; purpose?: DrawingPurpose } & Partial<AttachmentOrigin>)
|
|
231
232
|
|
|
232
233
|
// Client → server messages, routed by workspaceId over the shared WebSocket.
|
|
233
|
-
export type SelectedSessionScope = 'shared' | 'browser-tab'
|
|
234
|
-
|
|
235
234
|
export type ClientMessage =
|
|
236
235
|
| {
|
|
237
236
|
type: 'chat'
|
|
@@ -239,9 +238,6 @@ export type ClientMessage =
|
|
|
239
238
|
content: string
|
|
240
239
|
sessionId: string
|
|
241
240
|
isNew: boolean
|
|
242
|
-
// Where this tab keeps its selected session. Browser-tab selection must
|
|
243
|
-
// not update the workspace's shared selection or switch other tabs.
|
|
244
|
-
selectedSessionScope?: SelectedSessionScope
|
|
245
241
|
// Text and upload references for this turn. The server resolves uploads
|
|
246
242
|
// and describes all attachments together, preserving their order.
|
|
247
243
|
attachments?: MessageAttachment[]
|
|
@@ -316,10 +312,14 @@ export type WorkspaceSessionState = {
|
|
|
316
312
|
fork?: SessionFork
|
|
317
313
|
}
|
|
318
314
|
|
|
319
|
-
//
|
|
320
|
-
// GET /api/workspaces/:id/state
|
|
321
|
-
// `state:changed`.
|
|
315
|
+
// Personal state on this Moi installation, shared across its browser windows.
|
|
316
|
+
// GET /api/workspaces/:id/state; writes publish `state:changed`.
|
|
322
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[]
|
|
321
|
+
// Personal defaults for new chats on this Moi installation.
|
|
322
|
+
chatDefaults?: SessionConfig
|
|
323
323
|
// Goes up by one with every saved change. Lets clients drop an older copy
|
|
324
324
|
// that arrives after a newer one.
|
|
325
325
|
revision: number
|
|
@@ -462,7 +462,7 @@ export type WorkspaceSwitchMessage = {
|
|
|
462
462
|
workspaceId: string
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
-
export type
|
|
465
|
+
export type HarnessType = 'claude-code' | 'openclaw' | 'codex' | 'hermes'
|
|
466
466
|
|
|
467
467
|
export type WorkspaceSkillStatus = {
|
|
468
468
|
name: string
|
|
@@ -480,11 +480,11 @@ export type WorkspaceSkillsUpdateFailure = WorkspaceSkillsStatus & {
|
|
|
480
480
|
error: string
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
-
export type HarnessInstallations = Record<
|
|
483
|
+
export type HarnessInstallations = Record<HarnessType, boolean>
|
|
484
484
|
|
|
485
485
|
// Shared runtime/account readiness and the current sign-in attempt.
|
|
486
486
|
export type HarnessStatus = { availability: HarnessAvailability; login?: HarnessLoginState }
|
|
487
|
-
export type HarnessStatuses = Record<
|
|
487
|
+
export type HarnessStatuses = Record<HarnessType, HarnessStatus>
|
|
488
488
|
|
|
489
489
|
export type HarnessAvailability =
|
|
490
490
|
| { status: 'available' }
|
|
@@ -523,10 +523,13 @@ export type McpServer = {
|
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
export type WorkspaceEntry = {
|
|
526
|
+
// Derived from .moi/.workspace.json; not persisted in workspaces.json.
|
|
527
|
+
remote?: RemoteWorkspaceTarget
|
|
526
528
|
id: string
|
|
527
529
|
path: string
|
|
528
530
|
addedAt: string
|
|
529
|
-
|
|
531
|
+
// The agent backend that runs this workspace's chats.
|
|
532
|
+
harness?: HarnessType
|
|
530
533
|
// Display name captured at add time (e.g. OpenClaw IDENTITY.md "Name:" or
|
|
531
534
|
// basename). Persisted so we don't re-probe the gateway for each listing.
|
|
532
535
|
// The list endpoint overrides this with the live layout `name` when set.
|
|
@@ -550,7 +553,7 @@ export type DiscoveredWorkspace = {
|
|
|
550
553
|
path: string
|
|
551
554
|
displayPath?: string
|
|
552
555
|
// Deduplicated in canonical provider order; empty for folders without agent history.
|
|
553
|
-
|
|
556
|
+
harnesses: HarnessType[]
|
|
554
557
|
}
|
|
555
558
|
|
|
556
559
|
export type SessionRenamedMessage = {
|
|
@@ -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
|
|
@@ -626,49 +625,35 @@ export type WorkspaceTabsState = {
|
|
|
626
625
|
|
|
627
626
|
export type { AgentTheme, ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from './themes'
|
|
628
627
|
|
|
629
|
-
export type WorkspaceLayoutSave = Omit<WorkspaceLayout, 'tabs'> & {
|
|
630
|
-
tabs?: WorkspaceTabsState
|
|
631
|
-
// Captured when the edit is made, so delayed saves cannot restore another harness's defaults.
|
|
632
|
-
harness?: WorkspaceType
|
|
633
|
-
}
|
|
634
|
-
|
|
635
628
|
export type WorkspaceLayout = {
|
|
636
|
-
version:
|
|
629
|
+
version: 2
|
|
637
630
|
widgetGrid: LayoutGridItem[]
|
|
638
|
-
layoutMode: LayoutMode
|
|
639
|
-
// Open tabs and active tab for the fullscreen/split workspace chrome. The
|
|
640
|
-
// `open` order is persisted so future drag-reordering has one source of truth.
|
|
641
|
-
tabs: WorkspaceTabsState
|
|
642
631
|
// User-set display-name override. When empty/undefined the API falls back to
|
|
643
632
|
// the workspace folder name, so the resolved name always comes from the API.
|
|
644
633
|
name?: string
|
|
645
634
|
// Workspace icon override. Emoji and glyphs may use a themed background.
|
|
646
635
|
icon?: WorkspaceIcon
|
|
647
|
-
// Model id chosen in the composer picker (`supportedModels()` `value`, an
|
|
648
|
-
// alias like `sonnet`). Persisted so the choice survives a reload. Sent with
|
|
649
|
-
// each chat frame; undefined means the agent runs on the SDK default. Note
|
|
650
|
-
// the transcript records the *resolved* id (e.g. `claude-sonnet-4-6`), which
|
|
651
|
-
// doesn't map back to these aliases — hence we persist the pick here.
|
|
652
|
-
//
|
|
653
|
-
// This (with `selectedEffort` and `selectedSpeedMode`) is the *workspace
|
|
654
|
-
// default*: the value the picker edits when no session is open, and the seed a
|
|
655
|
-
// brand-new session copies. Once a session exists it carries its own per-session
|
|
656
|
-
// override (see `SessionConfig`).
|
|
657
|
-
selectedModel?: string
|
|
658
|
-
// Reasoning-effort default for new sessions (a `supportedEffortLevels` value).
|
|
659
|
-
selectedEffort?: string
|
|
660
|
-
// Speed default for new sessions. Undefined behaves as normal.
|
|
661
|
-
selectedSpeedMode?: SpeedMode
|
|
662
636
|
theme?: WorkspaceTheme
|
|
663
637
|
}
|
|
664
638
|
|
|
665
|
-
// GET /api/workspaces/:id
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
639
|
+
// GET /api/workspaces/:id returns either a complete local layout or a remote reference.
|
|
640
|
+
type WorkspaceRouting = { apiBase: string; cwd: string }
|
|
641
|
+
type WorkspaceMetadata = { name: string; harness?: HarnessType; agentId?: string }
|
|
642
|
+
export type WorkspaceInfoResponse =
|
|
643
|
+
| (WorkspaceLayout & WorkspaceRouting & WorkspaceMetadata & { isRemote: false })
|
|
644
|
+
| (WorkspaceRouting &
|
|
645
|
+
Pick<WorkspaceMetadata, 'harness' | 'agentId'> & {
|
|
646
|
+
version: 2
|
|
647
|
+
isRemote: true
|
|
648
|
+
remote: RemoteWorkspaceTarget
|
|
649
|
+
})
|
|
650
|
+
|
|
651
|
+
// The client resolves a remote reference before exposing a complete layout to consumers.
|
|
652
|
+
export type WorkspaceLayoutResponse = WorkspaceLayout &
|
|
653
|
+
WorkspaceRouting &
|
|
654
|
+
WorkspaceMetadata & {
|
|
655
|
+
isRemote: boolean
|
|
656
|
+
}
|
|
672
657
|
|
|
673
658
|
// One applet's thumbnail freshness record. Image bytes live as files in the
|
|
674
659
|
// workspace's `.moi/.cache/thumbnails/` (server/applets/thumbnails.ts), never in
|
|
@@ -780,9 +765,8 @@ export type WorkspaceHarness = {
|
|
|
780
765
|
/** Credential overrides require workspace readiness instead of shared account status. */
|
|
781
766
|
hasAuthOverrides?: boolean
|
|
782
767
|
isFolderMissing?: boolean
|
|
783
|
-
// The harness that produced this snapshot — matches the workspace
|
|
784
|
-
|
|
785
|
-
provider: WorkspaceType
|
|
768
|
+
// The harness that produced this snapshot — matches the workspace's harness.
|
|
769
|
+
harness: HarnessType
|
|
786
770
|
// Runtime presence and provider auth state, from the server-side cache.
|
|
787
771
|
availability: HarnessAvailability
|
|
788
772
|
models: Model[]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { validateWorkspaceId } from './ids'
|
|
2
|
+
import type { WorkspaceLayout } from './types'
|
|
3
|
+
|
|
4
|
+
export type RemoteWorkspaceTarget = {
|
|
5
|
+
user_id: string
|
|
6
|
+
workspace_id: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type RemoteWorkspaceConfig = {
|
|
10
|
+
version: 2
|
|
11
|
+
remote: RemoteWorkspaceTarget
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type LocalWorkspaceConfig = WorkspaceLayout & { remote?: never }
|
|
15
|
+
|
|
16
|
+
export type WorkspaceFileConfig = LocalWorkspaceConfig | RemoteWorkspaceConfig
|
|
17
|
+
|
|
18
|
+
// Shared address format for workspace APIs, Cloud membership, and CLI operations.
|
|
19
|
+
export function workspaceAddress(id: string, userId?: string): string {
|
|
20
|
+
return userId ? `${encodeURIComponent(userId)}:${encodeURIComponent(id)}` : encodeURIComponent(id)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function workspaceApiBase(id: string, userId?: string): string {
|
|
24
|
+
return `/api/workspaces/${workspaceAddress(id, userId)}`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parseRemoteWorkspaceTarget(value: unknown): RemoteWorkspaceTarget {
|
|
28
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
29
|
+
throw new Error('Invalid remote workspace address')
|
|
30
|
+
const target = value as Record<string, unknown>
|
|
31
|
+
if (typeof target.user_id !== 'string' || !/^[A-Za-z0-9_-]{1,64}$/.test(target.user_id))
|
|
32
|
+
throw new Error('Invalid remote owner ID')
|
|
33
|
+
if (typeof target.workspace_id !== 'string') throw new Error('Invalid remote workspace ID')
|
|
34
|
+
const error = validateWorkspaceId(target.workspace_id)
|
|
35
|
+
if (error) throw new Error(error)
|
|
36
|
+
return { user_id: target.user_id, workspace_id: target.workspace_id }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function parseRemoteWorkspaceAddress(value: string): RemoteWorkspaceTarget {
|
|
40
|
+
const parts = value.split(':')
|
|
41
|
+
if (parts.length !== 2) throw new Error('Use a remote workspace address: ownerId:workspaceId')
|
|
42
|
+
return parseRemoteWorkspaceTarget({ user_id: parts[0], workspace_id: parts[1] })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function parseRemoteWorkspaceConfig(value: Record<string, unknown>): RemoteWorkspaceConfig {
|
|
46
|
+
if (value.version !== 2) throw new Error('Invalid remote workspace config')
|
|
47
|
+
return { version: 2, remote: parseRemoteWorkspaceTarget(value.remote) }
|
|
48
|
+
}
|
package/lib/workspace-layout.ts
CHANGED
|
@@ -2,33 +2,14 @@ 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 {
|
|
28
11
|
return {
|
|
29
|
-
version:
|
|
30
|
-
widgetGrid: createDefaultWidgetGrid()
|
|
31
|
-
layoutMode: 'split',
|
|
32
|
-
tabs: createDefaultWorkspaceTabs()
|
|
12
|
+
version: 2,
|
|
13
|
+
widgetGrid: createDefaultWidgetGrid()
|
|
33
14
|
}
|
|
34
15
|
}
|
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",
|
|
@@ -97,12 +97,14 @@
|
|
|
97
97
|
"pathe": "^2.0.3",
|
|
98
98
|
"picocolors": "^1.1.1",
|
|
99
99
|
"postcss": "^8.5.28",
|
|
100
|
+
"proper-lockfile": "4.1.2",
|
|
100
101
|
"react": "19.2.4",
|
|
101
102
|
"react-dom": "19.2.4",
|
|
102
103
|
"react-grid-layout": "^2.2.4",
|
|
103
104
|
"react-markdown": "^10.1.0",
|
|
104
105
|
"react-resizable": "^3.2.0",
|
|
105
106
|
"react-resizable-panels": "^4.12.4",
|
|
107
|
+
"regexparam": "^3.0.0",
|
|
106
108
|
"rehype-highlight": "^7.0.2",
|
|
107
109
|
"remark-gfm": "^4.0.1",
|
|
108
110
|
"shadcn": "4.21.0",
|
|
@@ -125,11 +127,12 @@
|
|
|
125
127
|
"@agentclientprotocol/sdk": "^1.4.0",
|
|
126
128
|
"@babel/types": "^7.29.8",
|
|
127
129
|
"@types/culori": "^4.0.1",
|
|
130
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
128
131
|
"@types/react": "^19.2.18",
|
|
129
132
|
"@types/react-dom": "^19.2.7",
|
|
130
133
|
"@types/react-grid-layout": "^2.1.0",
|
|
131
134
|
"@types/react-resizable": "^3.0.8",
|
|
132
|
-
"@uiverify/bun": "1.0.
|
|
135
|
+
"@uiverify/bun": "1.0.1",
|
|
133
136
|
"bun": ">=1.4.4",
|
|
134
137
|
"date-fns": "^4.4.0",
|
|
135
138
|
"embla-carousel-react": "^8.6.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
|
@@ -5,27 +5,31 @@ WebSocket handlers, and CLI commands call the same feature modules.
|
|
|
5
5
|
|
|
6
6
|
## Where code belongs
|
|
7
7
|
|
|
8
|
-
| Location | Owns
|
|
9
|
-
| ------------------ |
|
|
10
|
-
| `api/` | Hono HTTP routes, request validation, workspace lookup middleware, and API tests. `index.ts` assembles and defines the main routes; `harnesses.ts` defines login routes.
|
|
11
|
-
| `cli/commands/` | One module per top-level CLI command, with its subcommands and private helpers.
|
|
12
|
-
| `cli/` | Command registration, help, CLI access gates, terminal formatting, control requests, and server launching.
|
|
13
|
-
| `workspaces/` | Workspace discovery and registration, creation/import, `.moi/` scaffolding, layout,
|
|
14
|
-
| `sessions/` | Moi's session metadata, selection and pin state, archiving, ID renames, message attachments, and pending-view chat handoffs. Provider-owned history stays in the harnesses.
|
|
15
|
-
| `workspace-state/` | Per-workspace `state.json` storage: one writer per workspace, transactions, atomic writes, lock timeout, a revision and a `state:changed` event per change, re-adoption of a removed workspace's id
|
|
16
|
-
| `applets/` | View/widget manifests, source analysis, builds, CSS scoping, typechecking, bundle serving, server-function workers, thumbnails, UI component installation, and the error journal.
|
|
17
|
-
| `scratchpad/` | Canvas documents, assets, headless drawing, and browser screenshot requests.
|
|
18
|
-
| `skills/` | Bundled workspace skill installation, version checks, and updates. These modules manage the copies shipped under `workspace/`.
|
|
19
|
-
| `harness/` | Provider adapters, transports, sessions, discovery, authentication, and readiness. See [the harness guide](harness/README.md).
|
|
20
|
-
| `collab/` | Cloud collaboration workers, presence, proxy identity, and the optional collaboration skill.
|
|
21
|
-
| `onboarding/` | Idea discovery, its prompt and output validation, and workspace creation jobs. HTTP handlers live in [api/onboarding.ts](api/onboarding.ts).
|
|
22
|
-
| `test/` | Integration tests and existing tests that share fixtures. Other unit tests live beside their modules.
|
|
8
|
+
| Location | Owns |
|
|
9
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
10
|
+
| `api/` | Hono HTTP routes, request validation, workspace lookup middleware, and API tests. `index.ts` assembles and defines the main routes; `harnesses.ts` defines login routes. |
|
|
11
|
+
| `cli/commands/` | One module per top-level CLI command, with its subcommands and private helpers. |
|
|
12
|
+
| `cli/` | Command registration, help, CLI access gates, terminal formatting, control requests, and server launching. |
|
|
13
|
+
| `workspaces/` | Workspace discovery and registration, creation/import, `.moi/` scaffolding, shared layout, theme, icons, file previews, and environment settings. |
|
|
14
|
+
| `sessions/` | Moi's session metadata, selection and pin state, archiving, ID renames, message attachments, and pending-view chat handoffs. Provider-owned history stays in the harnesses. |
|
|
15
|
+
| `workspace-state/` | Per-workspace `state.json` storage: one writer per workspace, transactions, atomic writes, lock timeout, a revision and a `state:changed` event per change, re-adoption of a removed workspace's id. |
|
|
16
|
+
| `applets/` | View/widget manifests, source analysis, builds, CSS scoping, typechecking, bundle serving, server-function workers, thumbnails, UI component installation, and the error journal. |
|
|
17
|
+
| `scratchpad/` | Canvas documents, assets, headless drawing, and browser screenshot requests. |
|
|
18
|
+
| `skills/` | Bundled workspace skill installation, version checks, and updates. These modules manage the copies shipped under `workspace/`. |
|
|
19
|
+
| `harness/` | Provider adapters, transports, sessions, discovery, authentication, and readiness. See [the harness guide](harness/README.md). |
|
|
20
|
+
| `collab/` | Cloud collaboration workers, presence, proxy identity, and the optional collaboration skill. |
|
|
21
|
+
| `onboarding/` | Idea discovery, its prompt and output validation, and workspace creation jobs. HTTP handlers live in [api/onboarding.ts](api/onboarding.ts). |
|
|
22
|
+
| `test/` | Integration tests and existing tests that share fixtures. Other unit tests live beside their modules. |
|
|
23
23
|
|
|
24
24
|
Use direct module imports such as `workspaces/registry` or `sessions/store`.
|
|
25
25
|
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,22 +60,23 @@ corresponding directory above.
|
|
|
56
60
|
|
|
57
61
|
## Storage ownership
|
|
58
62
|
|
|
59
|
-
| State
|
|
60
|
-
|
|
|
61
|
-
| Workspace layout
|
|
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
|
-
|
|
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.
|
|
75
80
|
|
|
76
81
|
## Paths and process boundaries
|
|
77
82
|
|
package/server/api/harnesses.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Hono } from 'hono'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { HarnessType } from '@/lib/types'
|
|
4
4
|
|
|
5
5
|
import { loginShellPath } from '../harness/shell-path'
|
|
6
6
|
import { installHarness } from '../harness/install'
|
|
7
7
|
import { harnessStore } from '../harness/auth'
|
|
8
8
|
import { allHarnesses, harnessFor, isHarnessType } from '../harness/registry'
|
|
9
9
|
|
|
10
|
-
export const harnesses = new Hono<{ Variables: { harnessType:
|
|
10
|
+
export const harnesses = new Hono<{ Variables: { harnessType: HarnessType } }>()
|
|
11
11
|
|
|
12
12
|
harnesses.get('/status', async c => {
|
|
13
13
|
c.header('Cache-Control', 'no-store')
|
|
@@ -41,9 +41,9 @@ harnesses.post('/:type/auth/install', async c => {
|
|
|
41
41
|
const origin = c.req.header('Origin')
|
|
42
42
|
if (origin && origin !== new URL(c.req.url).origin) return c.text('Invalid origin', 403)
|
|
43
43
|
try {
|
|
44
|
-
const
|
|
45
|
-
await installHarness(
|
|
46
|
-
await harnessStore.refresh(
|
|
44
|
+
const harness = c.get('harnessType')
|
|
45
|
+
await installHarness(harness)
|
|
46
|
+
await harnessStore.refresh(harness)
|
|
47
47
|
return c.json({ ok: true })
|
|
48
48
|
} catch (error) {
|
|
49
49
|
return c.text(error instanceof Error ? error.message : 'Could not install agent', 400)
|