moi-computer 0.10.1-next.3 → 0.10.1-next.4
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/app/shell/SidebarLayout.tsx +53 -14
- package/client/components/shared/AgentBlobatar.tsx +3 -3
- package/client/components/shared/Composer.tsx +4 -10
- package/client/features/chat/ChatEmptyState.tsx +2 -9
- package/client/features/chat/ChatPanel.tsx +21 -23
- package/client/features/chat/ChatPopup.tsx +1 -2
- package/client/features/chat/composer/ChatComposer.tsx +2 -2
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +101 -0
- package/client/features/chat/composer/banners/{ChatErrorBanner.tsx → ErrorBanner.tsx} +2 -2
- package/client/features/chat/composer/banners/{WorkspaceSkillUpdateBanner.tsx → SkillUpdateBanner.tsx} +3 -3
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +14 -24
- package/client/features/chat/composer/useWorkspaceSkillUpdates.ts +6 -6
- package/client/features/chat/useAppletChatMessage.ts +9 -5
- package/client/features/dev/BlobatarShapesPage.tsx +344 -0
- package/client/features/dev/ChatStatesPage.tsx +3 -4
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/home/HomePage.tsx +47 -5
- package/client/features/home/WorkspacePreview.tsx +4 -4
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +1 -1
- package/client/features/update/{Update.tsx → UpdateControl.tsx} +33 -9
- package/client/features/workspace/CustomizePanel.tsx +1 -1
- package/client/features/workspace/WorkspaceScreen.tsx +5 -5
- package/client/features/workspace/api.ts +10 -1
- package/client/lib/agent-availability.ts +19 -0
- package/client/runtime/useWorkspaceEvents.ts +16 -2
- package/client/runtime/workspace-theme.ts +2 -8
- package/dist/chunk-104m57qw.js +2 -0
- package/dist/chunk-4vyggdzq.css +1 -0
- package/dist/chunk-bj3akjs2.js +1 -0
- package/dist/{chunk-0pcdwjkp.js → chunk-c9pjqx9m.js} +1 -1
- package/dist/chunk-gbp4m9p2.js +1 -0
- package/dist/{chunk-8jh75pjg.js → chunk-j2w2vak4.js} +2 -2
- package/dist/chunk-jpdn7nx7.js +83 -0
- package/dist/chunk-k2r9c95m.js +10 -0
- package/dist/chunk-kmbxhgwv.js +1 -0
- package/dist/{chunk-yt2qjn3m.js → chunk-tny85yt2.js} +2 -2
- package/dist/{chunk-9y2zbzqz.js → chunk-v7wr1df4.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/themes.ts +31 -7
- package/lib/types.ts +9 -8
- package/package.json +1 -1
- package/server/AGENTS.md +1 -1
- package/server/agent.ts +46 -22
- package/server/api.ts +6 -6
- package/server/cli-ui-components.ts +63 -22
- package/server/harness/README.md +21 -12
- package/server/harness/claude-code/auth.ts +38 -23
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/claude-code/permissions.ts +34 -0
- package/server/harness/claude-code/session.ts +7 -15
- package/server/harness/codex/auth.ts +31 -21
- package/server/harness/codex/client.ts +5 -14
- package/server/harness/codex/index.ts +1 -1
- package/server/harness/codex/permissions.ts +56 -0
- package/server/harness/codex/session.ts +25 -20
- package/server/harness/executable.ts +2 -2
- package/server/harness/hermes/index.ts +4 -5
- package/server/ui-components.ts +29 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +9 -7
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +24 -12
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +0 -82
- package/dist/chunk-4xmcsjjv.js +0 -1
- package/dist/chunk-76j95afs.css +0 -1
- package/dist/chunk-dfs36zgc.js +0 -1
- package/dist/chunk-e4e993yf.js +0 -83
- package/dist/chunk-vq8ga42s.js +0 -1
- package/dist/chunk-yhj9bg1s.js +0 -2
- package/dist/chunk-yz743a75.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Rc as a,Sc as b}from"/chunk-tny85yt2.js";import"/chunk-104m57qw.js";import"/chunk-v7wr1df4.js";export{b as useAppConfig,a as loadAppConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{u as
|
|
1
|
+
import{Tc as w,Vc as s}from"/chunk-104m57qw.js";import{Xc as q}from"/chunk-v7wr1df4.js";var R=q(w(),1);async function i(o,t){let a=await o.text();return Error(a||t)}async function u(o,t,a="Request failed"){let n=await fetch(o,t);if(!n.ok)throw await i(n,a);return n.json()}async function T(o,t,a="Request failed"){let n=await fetch(o,t);if(!n.ok)throw await i(n,a)}function y(o,t){return{method:o,headers:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)}}var r={cloudDemo:!1,experiments:[],demoInstallUrl:"https://moi.computer"},d=r,e=new Set;function I(o){return e.add(o),()=>{e.delete(o)}}async function f(){try{d=await u("/api/config");for(let o of e)o()}catch{}}async function c(){await f(),s(()=>{f()})}function h(){return R.useSyncExternalStore(I,()=>d)}
|
|
2
|
+
export{u as Oc,T as Pc,y as Qc,c as Rc,h as Sc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var j=Object.create;var{getPrototypeOf:k,defineProperty:f,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,s=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of l(a))if(!m.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0});if(g)h.set(a,d);return d};var t=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var u=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var v=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
|
|
2
|
-
export{s as
|
|
2
|
+
export{s as Xc,t as Yc,u as Zc,v as _c};
|
package/dist/index.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
</script>
|
|
38
38
|
|
|
39
|
-
<link rel="stylesheet" crossorigin href="/chunk-
|
|
39
|
+
<link rel="stylesheet" crossorigin href="/chunk-4vyggdzq.css"><script type="module" crossorigin src="/chunk-gbp4m9p2.js"></script></head>
|
|
40
40
|
<body>
|
|
41
41
|
<div id="root"></div>
|
|
42
42
|
|
package/lib/themes.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TraitOverrides } from 'blobatar'
|
|
1
2
|
import { wcagLuminance } from 'culori'
|
|
2
3
|
|
|
3
4
|
export type FontTheme =
|
|
@@ -82,18 +83,18 @@ export const RADIUS_THEMES: Record<RadiusTheme, RadiusThemeConfig> = {
|
|
|
82
83
|
square: { label: 'Square', radius: '0' }
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
export type AgentTheme = '
|
|
86
|
+
export type AgentTheme = 'blob' | 'boxy' | 'pill' | 'dorito'
|
|
86
87
|
|
|
87
88
|
export type AgentThemeConfig = {
|
|
88
89
|
label: string
|
|
89
|
-
|
|
90
|
+
traits: TraitOverrides
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
export const AGENT_THEMES: Record<AgentTheme, AgentThemeConfig> = {
|
|
93
|
-
|
|
94
|
-
boxy: { label: 'Boxy', shape: 0.54 },
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
blob: { label: 'Blob', traits: { shape: 0.11, 'body.r': 0.5, 'body.ratio': 0, 'body.n': 0.5 } },
|
|
95
|
+
boxy: { label: 'Boxy', traits: { shape: 0.54, 'body.r': 1, 'body.ratio': 0 } },
|
|
96
|
+
pill: { label: 'Pill', traits: { shape: 0.65, 'body.r': 1 } },
|
|
97
|
+
dorito: { label: 'Dorito', traits: { shape: 0.99, 'body.r': 1, 'body.ratio': 0, 'body.rot': 0 } }
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
export type ColorTheme =
|
|
@@ -212,6 +213,29 @@ export const DEFAULT_WORKSPACE_THEME: WorkspaceTheme = {
|
|
|
212
213
|
agent: 'boxy'
|
|
213
214
|
}
|
|
214
215
|
|
|
216
|
+
function resolveThemePreset<T extends string>(
|
|
217
|
+
value: unknown,
|
|
218
|
+
presets: Record<T, unknown>,
|
|
219
|
+
fallback: T
|
|
220
|
+
): T {
|
|
221
|
+
return typeof value === 'string' && Object.hasOwn(presets, value) ? (value as T) : fallback
|
|
222
|
+
}
|
|
223
|
+
|
|
215
224
|
export function resolveWorkspaceTheme(theme?: Partial<WorkspaceTheme>): WorkspaceTheme {
|
|
216
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
font: resolveThemePreset(theme?.font, FONT_THEMES, DEFAULT_WORKSPACE_THEME.font),
|
|
227
|
+
color: resolveThemePreset(theme?.color, COLOR_THEMES, DEFAULT_WORKSPACE_THEME.color),
|
|
228
|
+
radius: resolveThemePreset(theme?.radius, RADIUS_THEMES, DEFAULT_WORKSPACE_THEME.radius),
|
|
229
|
+
agent: resolveThemePreset(theme?.agent, AGENT_THEMES, DEFAULT_WORKSPACE_THEME.agent)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function resolveThemeColorOverrides(
|
|
234
|
+
theme?: Partial<WorkspaceTheme>,
|
|
235
|
+
mode: ThemeColorMode = 'workspace'
|
|
236
|
+
): ThemeColors | undefined {
|
|
237
|
+
const resolved = resolveWorkspaceTheme(theme)
|
|
238
|
+
const color = COLOR_THEMES[resolved.color]
|
|
239
|
+
const primary = color.primary ?? (mode === 'widget' ? DEFAULT_PRIMARY_COLOR : undefined)
|
|
240
|
+
return primary ? deriveThemeColors(primary, mode) : undefined
|
|
217
241
|
}
|
package/lib/types.ts
CHANGED
|
@@ -418,19 +418,20 @@ export type WorkspaceSkillsUpdateFailure = WorkspaceSkillsStatus & {
|
|
|
418
418
|
error: string
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
// Setup checks only runtime availability. Workspace checks may also
|
|
422
|
-
//
|
|
421
|
+
// Setup checks only runtime availability. Workspace checks may also report
|
|
422
|
+
// that the provider needs a login the host can start.
|
|
423
423
|
export type HarnessAvailability =
|
|
424
|
-
| {
|
|
425
|
-
| {
|
|
424
|
+
| { status: 'available' }
|
|
425
|
+
| { status: 'login-required'; reason: string }
|
|
426
|
+
| { status: 'unavailable'; reason: string }
|
|
426
427
|
|
|
427
428
|
// Codex returns a URL for the browser. Claude opens it from its own CLI.
|
|
428
429
|
export type HarnessLogin = { url?: string }
|
|
429
430
|
|
|
430
|
-
// The server-owned login ceremony
|
|
431
|
-
//
|
|
432
|
-
//
|
|
433
|
-
//
|
|
431
|
+
// The server-owned login ceremony for a workspace. `pending` means a watch loop
|
|
432
|
+
// is re-probing the provider until the login lands or the deadline passes;
|
|
433
|
+
// transitions arrive as `agent:updated` events, so every tab shows the same
|
|
434
|
+
// ceremony without polling.
|
|
434
435
|
export type AgentLoginState =
|
|
435
436
|
| { state: 'pending'; url?: string }
|
|
436
437
|
| { state: 'failed'; reason: string }
|
package/package.json
CHANGED
package/server/AGENTS.md
CHANGED
|
@@ -6,4 +6,4 @@ Bun server on port 13337. Serves the client at `/`, upgrades `/ws` to WebSocket.
|
|
|
6
6
|
- `state.ts` holds the connected chat clients and `broadcast()` (which also feeds the harness debug tap).
|
|
7
7
|
- `harness/` holds every agent backend (Claude Code, OpenClaw, Codex): per-harness adapter + session + transport + protocol NOTES, colocated. Read `harness/README.md` for the message-type layers, the adapter contract, and the folder conventions before touching agent-backend code.
|
|
8
8
|
- WebSocket protocol: server sends `ServerMessage`, client sends `ClientMessage` — both defined in `lib/types.ts`.
|
|
9
|
-
- Agents run in the workspace directory
|
|
9
|
+
- Agents run in the workspace directory; Claude Code and Codex approve every permission request by default (a `PreToolUse` allow hook and a transport-level accept, respectively) until UI approvals land. Each backend persists its own session history (see `harness/README.md`).
|
package/server/agent.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
//
|
|
3
3
|
// The client never polls for auth. `GET /api/workspaces/:id/agent` serves the
|
|
4
4
|
// snapshot from this store (one probe per workspace inside the TTL, however
|
|
5
|
-
// many tabs are open); `POST .../auth/login` starts
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// transition is pushed to all tabs as an
|
|
9
|
-
// workspace events socket.
|
|
5
|
+
// many tabs are open); `POST .../auth/login` starts a ceremony per workspace.
|
|
6
|
+
// Browser-based logins reuse their pending URL, while URL-less provider flows
|
|
7
|
+
// can be started again. A watch loop re-probes until the login lands or the
|
|
8
|
+
// deadline passes, and every transition is pushed to all tabs as an
|
|
9
|
+
// `agent:updated` event on the workspace events socket.
|
|
10
10
|
import type {
|
|
11
11
|
AgentLoginState,
|
|
12
12
|
HarnessAvailability,
|
|
@@ -53,6 +53,17 @@ type AgentEntry = {
|
|
|
53
53
|
login?: LoginCeremony
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function failedProbeAvailability(ws: AgentWorkspace, err: unknown): HarnessAvailability {
|
|
57
|
+
console.error(`[agent] availability probe failed for ${ws.type ?? 'claude-code'}`, err)
|
|
58
|
+
return { status: 'unavailable', reason: 'Could not check agent availability' }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function sameAvailability(a: HarnessAvailability, b: HarnessAvailability): boolean {
|
|
62
|
+
if (a.status !== b.status) return false
|
|
63
|
+
if (a.status === 'available' || b.status === 'available') return true
|
|
64
|
+
return a.reason === b.reason
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
export function createAgentStore(options: AgentStoreOptions) {
|
|
57
68
|
const ttlMs = options.availabilityTtlMs ?? 30_000
|
|
58
69
|
const pollMs = options.loginPollMs ?? 2_000
|
|
@@ -81,9 +92,12 @@ export function createAgentStore(options: AgentStoreOptions) {
|
|
|
81
92
|
async function probeFresh(ws: AgentWorkspace): Promise<HarnessAvailability> {
|
|
82
93
|
const entry = entryFor(ws.id)
|
|
83
94
|
if (!entry.probe) {
|
|
84
|
-
entry.probe =
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
entry.probe = Promise.resolve()
|
|
96
|
+
.then(() => options.probe(ws))
|
|
97
|
+
.catch(err => failedProbeAvailability(ws, err))
|
|
98
|
+
.finally(() => {
|
|
99
|
+
entry.probe = undefined
|
|
100
|
+
})
|
|
87
101
|
}
|
|
88
102
|
const value = await entry.probe
|
|
89
103
|
entry.cached = { value, checkedAt: Date.now() }
|
|
@@ -114,24 +128,24 @@ export function createAgentStore(options: AgentStoreOptions) {
|
|
|
114
128
|
|
|
115
129
|
// Re-probe until the login lands or the deadline passes. One loop per
|
|
116
130
|
// ceremony; a replaced or completed ceremony stops its loop.
|
|
117
|
-
function watch(
|
|
131
|
+
function watch(
|
|
132
|
+
ws: AgentWorkspace,
|
|
133
|
+
login: LoginCeremony,
|
|
134
|
+
initialAvailability: HarnessAvailability
|
|
135
|
+
) {
|
|
118
136
|
const deadline = Date.now() + deadlineMs
|
|
119
137
|
let stopped = false
|
|
138
|
+
let publishedAvailability = initialAvailability
|
|
120
139
|
let timer: ReturnType<typeof setTimeout>
|
|
121
140
|
login.stop = () => {
|
|
122
141
|
stopped = true
|
|
123
142
|
clearTimeout(timer)
|
|
124
143
|
}
|
|
125
144
|
const tick = async () => {
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
value = await probeFresh(ws)
|
|
129
|
-
} catch {
|
|
130
|
-
value = { available: false, reason: 'Could not verify the login' }
|
|
131
|
-
}
|
|
145
|
+
const value = await probeFresh(ws)
|
|
132
146
|
if (stopped) return
|
|
133
147
|
const entry = entryFor(ws.id)
|
|
134
|
-
if (value.available) {
|
|
148
|
+
if (value.status === 'available') {
|
|
135
149
|
entry.login = undefined
|
|
136
150
|
publish(ws.id, value)
|
|
137
151
|
return
|
|
@@ -143,6 +157,10 @@ export function createAgentStore(options: AgentStoreOptions) {
|
|
|
143
157
|
publish(ws.id, value)
|
|
144
158
|
return
|
|
145
159
|
}
|
|
160
|
+
if (!sameAvailability(value, publishedAvailability)) {
|
|
161
|
+
publishedAvailability = value
|
|
162
|
+
publish(ws.id, value)
|
|
163
|
+
}
|
|
146
164
|
timer = setTimeout(tick, pollMs)
|
|
147
165
|
timer.unref?.()
|
|
148
166
|
}
|
|
@@ -153,11 +171,13 @@ export function createAgentStore(options: AgentStoreOptions) {
|
|
|
153
171
|
|
|
154
172
|
async function startLogin(ws: AgentWorkspace): Promise<HarnessLogin> {
|
|
155
173
|
const entry = entryFor(ws.id)
|
|
156
|
-
//
|
|
157
|
-
//
|
|
174
|
+
// Concurrent starts share the provider call. Once started, browser-based
|
|
175
|
+
// flows reuse their URL; URL-less flows can be launched again on demand.
|
|
158
176
|
const current = entry.login
|
|
159
177
|
if (current?.starting) return current.starting
|
|
160
|
-
if (current?.state.state === 'pending'
|
|
178
|
+
if (current?.state.state === 'pending' && current.state.url) {
|
|
179
|
+
return { url: current.state.url }
|
|
180
|
+
}
|
|
161
181
|
|
|
162
182
|
current?.stop()
|
|
163
183
|
const starting = options.startLogin(ws)
|
|
@@ -167,8 +187,12 @@ export function createAgentStore(options: AgentStoreOptions) {
|
|
|
167
187
|
const result = await starting
|
|
168
188
|
login.starting = undefined
|
|
169
189
|
login.state = { state: 'pending', ...(result.url ? { url: result.url } : {}) }
|
|
170
|
-
|
|
171
|
-
|
|
190
|
+
const availability = entry.cached?.value ?? {
|
|
191
|
+
status: 'login-required',
|
|
192
|
+
reason: 'Waiting for sign-in'
|
|
193
|
+
}
|
|
194
|
+
publish(ws.id, availability)
|
|
195
|
+
watch(ws, login, availability)
|
|
172
196
|
return result
|
|
173
197
|
} catch (err) {
|
|
174
198
|
entry.login = undefined
|
|
@@ -189,7 +213,7 @@ export function createAgentStore(options: AgentStoreOptions) {
|
|
|
189
213
|
export type AgentStore = ReturnType<typeof createAgentStore>
|
|
190
214
|
|
|
191
215
|
export const agentStore = createAgentStore({
|
|
192
|
-
probe: async ws => (await harnessFor(ws).availability?.(ws)) ?? {
|
|
216
|
+
probe: async ws => (await harnessFor(ws).availability?.(ws)) ?? { status: 'available' },
|
|
193
217
|
startLogin: ws => {
|
|
194
218
|
const start = harnessFor(ws).startLogin
|
|
195
219
|
if (!start) throw new Error('This agent requires terminal sign-in')
|
package/server/api.ts
CHANGED
|
@@ -289,7 +289,7 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
289
289
|
return c.text('Sketch attachment not found or expired', 400)
|
|
290
290
|
}
|
|
291
291
|
const availability = await workspaceTypeAvailability(ws.type ?? 'claude-code')
|
|
292
|
-
if (
|
|
292
|
+
if (availability.status !== 'available') return c.text(availability.reason, 400)
|
|
293
293
|
try {
|
|
294
294
|
const builder = await beginViewBuilder(
|
|
295
295
|
ws.id,
|
|
@@ -681,8 +681,8 @@ one.put('/env', async c => {
|
|
|
681
681
|
|
|
682
682
|
// Start a provider login ceremony. Codex returns a browser OAuth URL for the
|
|
683
683
|
// host to open; Claude launches its browser flow through the CLI itself.
|
|
684
|
-
//
|
|
685
|
-
//
|
|
684
|
+
// Browser-based logins reuse a pending URL; URL-less provider flows restart
|
|
685
|
+
// when requested again. Completion is pushed as `agent:updated`.
|
|
686
686
|
one.post('/auth/login', async c => {
|
|
687
687
|
const ws = c.get('ws')
|
|
688
688
|
if (!harnessFor(ws).startLogin) return c.text('This agent requires terminal sign-in', 409)
|
|
@@ -966,7 +966,7 @@ workspaces.post('/', async c => {
|
|
|
966
966
|
if (!isHarnessType(requestedType)) return c.text('Unknown workspace type', 400)
|
|
967
967
|
const type: WorkspaceType = requestedType
|
|
968
968
|
const availability = await workspaceTypeAvailability(type)
|
|
969
|
-
if (
|
|
969
|
+
if (availability.status !== 'available') return c.text(availability.reason, 400)
|
|
970
970
|
const path = resolve(String(body.path))
|
|
971
971
|
let metadata: WorkspaceImportMetadata
|
|
972
972
|
try {
|
|
@@ -998,7 +998,7 @@ workspaces.get('/discover', async c => c.json(await discoverWorkspaces()))
|
|
|
998
998
|
const CREATABLE_TYPES = new Set<WorkspaceType>(['claude-code', 'codex'])
|
|
999
999
|
|
|
1000
1000
|
async function workspaceTypeAvailability(type: WorkspaceType): Promise<HarnessAvailability> {
|
|
1001
|
-
return (await harnessFor(type).availability?.()) ?? {
|
|
1001
|
+
return (await harnessFor(type).availability?.()) ?? { status: 'available' }
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
1004
1004
|
// Per-backend runtime availability, keyed by workspace type. Harnesses without
|
|
@@ -1036,7 +1036,7 @@ workspaces.post('/create', async c => {
|
|
|
1036
1036
|
return c.text('Workspaces of this type arrive through discovery, not creation', 400)
|
|
1037
1037
|
}
|
|
1038
1038
|
const availability = await workspaceTypeAvailability(type)
|
|
1039
|
-
if (
|
|
1039
|
+
if (availability.status !== 'available') return c.text(availability.reason, 400)
|
|
1040
1040
|
const name = typeof body?.name === 'string' ? body.name.trim() : ''
|
|
1041
1041
|
const invalid = validateWorkspaceFolderName(name)
|
|
1042
1042
|
if (invalid) return c.text(invalid, 400)
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
// moi ui-components add <name…> → fetch, transform, write to .moi/ui/
|
|
6
6
|
// moi ui-components docs <name…> → official docs as markdown, on stdout
|
|
7
7
|
//
|
|
8
|
-
// The command is deliberately not smart: add never
|
|
9
|
-
//
|
|
10
|
-
// agent owns them.
|
|
8
|
+
// The command is deliberately not smart: add never rebuilds and never edits
|
|
9
|
+
// existing files, and installs dependencies only when asked to (--install) —
|
|
10
|
+
// otherwise it prints next steps and the agent owns them.
|
|
11
11
|
import { defineCommand } from 'citty'
|
|
12
12
|
import { existsSync } from 'node:fs'
|
|
13
13
|
import { mkdir } from 'node:fs/promises'
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
UI_COMPONENT_NAMES,
|
|
22
22
|
UI_DOCS_BASE,
|
|
23
23
|
fetchUiComponents,
|
|
24
|
+
partitionUiWrites,
|
|
24
25
|
planUiWrites,
|
|
25
26
|
resolveUiComponentRequest,
|
|
26
27
|
suggestUiComponents,
|
|
@@ -59,6 +60,11 @@ const add = defineCommand({
|
|
|
59
60
|
type: 'boolean',
|
|
60
61
|
default: false,
|
|
61
62
|
description: 'Overwrite existing files of the requested components'
|
|
63
|
+
},
|
|
64
|
+
install: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
default: false,
|
|
67
|
+
description: 'Run `bun install` in .moi/ for the printed dependencies'
|
|
62
68
|
}
|
|
63
69
|
},
|
|
64
70
|
async run({ args }) {
|
|
@@ -89,17 +95,19 @@ const add = defineCommand({
|
|
|
89
95
|
exists: existsSync
|
|
90
96
|
})
|
|
91
97
|
|
|
92
|
-
// Hand-customized components are never silently overwritten:
|
|
93
|
-
// file that already exists
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
// Hand-customized components are never silently overwritten: without
|
|
99
|
+
// --force a requested file that already exists is skipped and reported, so
|
|
100
|
+
// a bulk add still installs everything new. Only when every requested
|
|
101
|
+
// component already exists does the add fail. Existing support files
|
|
102
|
+
// (utils, applet-portal, registry deps that rode along) are kept as-is
|
|
103
|
+
// either way, even under --force.
|
|
104
|
+
const partition = partitionUiWrites(plans, args.force)
|
|
105
|
+
if (partition.allInstalled) {
|
|
98
106
|
console.error(
|
|
99
107
|
'\n' +
|
|
100
108
|
pc.red('✗') +
|
|
101
109
|
' Already installed: ' +
|
|
102
|
-
|
|
110
|
+
partition.skipInstalled.map(plan => pc.bold(plan.name)).join(', ') +
|
|
103
111
|
'\n' +
|
|
104
112
|
pc.dim(' Files in .moi/ui/ may carry your customizations.\n') +
|
|
105
113
|
pc.dim(' Re-run with --force to overwrite them.\n')
|
|
@@ -109,18 +117,15 @@ const add = defineCommand({
|
|
|
109
117
|
|
|
110
118
|
await mkdir(uiDir, { recursive: true })
|
|
111
119
|
const written: string[] = []
|
|
112
|
-
const
|
|
113
|
-
for (const plan of plans) {
|
|
114
|
-
if (plan.exists && plan.support) {
|
|
115
|
-
kept.push(plan.name)
|
|
116
|
-
continue
|
|
117
|
-
}
|
|
120
|
+
for (const plan of partition.write) {
|
|
118
121
|
const content = plan.name.endsWith('.tsx')
|
|
119
122
|
? await transformUiComponentSource(plan.name, plan.content)
|
|
120
123
|
: plan.content
|
|
121
124
|
await Bun.write(plan.path, content)
|
|
122
125
|
written.push(plan.name)
|
|
123
126
|
}
|
|
127
|
+
const kept = partition.keepSupport.map(plan => plan.name)
|
|
128
|
+
const skipped = partition.skipInstalled.map(plan => plan.name)
|
|
124
129
|
|
|
125
130
|
// Deps the `moi init` scaffold already pre-seeds never need a mention;
|
|
126
131
|
// registry specifiers may be versioned (`recharts@3.8.0`), so compare by
|
|
@@ -135,16 +140,52 @@ const add = defineCommand({
|
|
|
135
140
|
if (kept.length > 0) {
|
|
136
141
|
console.log(pc.dim(` kept existing: ${kept.join(', ')}`))
|
|
137
142
|
}
|
|
143
|
+
if (skipped.length > 0) {
|
|
144
|
+
console.log(
|
|
145
|
+
pc.dim(
|
|
146
|
+
` already installed, kept: ${skipped.join(', ')} — re-run with --force to overwrite`
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
const moiDir = join(entry.path, '.moi')
|
|
151
|
+
let installNeeded = deps.length > 0
|
|
152
|
+
if (args.install) {
|
|
153
|
+
// `bun install` with no extra deps still materializes the pre-seeded
|
|
154
|
+
// baseline, which older workspaces may be missing — always run it.
|
|
155
|
+
const proc = Bun.spawnSync(['bun', 'install', ...deps], {
|
|
156
|
+
cwd: moiDir,
|
|
157
|
+
stdout: 'inherit',
|
|
158
|
+
stderr: 'inherit'
|
|
159
|
+
})
|
|
160
|
+
if (proc.exitCode !== 0) {
|
|
161
|
+
console.error(
|
|
162
|
+
'\n' +
|
|
163
|
+
pc.red('✗') +
|
|
164
|
+
` bun install failed in ${pc.bold('.moi/')} — install the dependencies yourself:\n` +
|
|
165
|
+
pc.dim(` bun install ${deps.join(' ')}\n`)
|
|
166
|
+
)
|
|
167
|
+
process.exit(1)
|
|
168
|
+
}
|
|
169
|
+
console.log(
|
|
170
|
+
pc.green('✓') +
|
|
171
|
+
' Installed dependencies in ' +
|
|
172
|
+
pc.bold('.moi/') +
|
|
173
|
+
(deps.length > 0 ? pc.dim(` (${deps.join(', ')})`) : '')
|
|
174
|
+
)
|
|
175
|
+
installNeeded = false
|
|
176
|
+
}
|
|
177
|
+
|
|
138
178
|
console.log('\nNext steps (yours):')
|
|
139
|
-
if (
|
|
179
|
+
if (installNeeded) {
|
|
140
180
|
// The command runs from anywhere inside the workspace (resolveCwdWorkspace),
|
|
141
181
|
// so point the install at the real `.moi/` relative to the caller's cwd —
|
|
142
182
|
// a literal `cd .moi` is wrong from `.moi/` itself or a widgets/ subdir.
|
|
143
|
-
const moiDir = join(entry.path, '.moi')
|
|
144
183
|
const rel = relative(process.cwd(), moiDir)
|
|
145
184
|
const cdPrefix = rel === '' ? '' : `cd ${/\s/.test(rel) ? JSON.stringify(rel) : rel} && `
|
|
146
185
|
console.log(
|
|
147
|
-
' 1. Install dependencies: ' +
|
|
186
|
+
' 1. Install dependencies: ' +
|
|
187
|
+
pc.bold(`${cdPrefix}bun install ${deps.join(' ')}`) +
|
|
188
|
+
pc.dim(' (or re-run add with --install)')
|
|
148
189
|
)
|
|
149
190
|
console.log(' 2. Import relatively — ' + pc.bold(`import { … } from '../ui/<name>'`))
|
|
150
191
|
console.log(' 3. Rebuild: ' + pc.bold('moi bundle'))
|
|
@@ -152,7 +193,7 @@ const add = defineCommand({
|
|
|
152
193
|
console.log(' 1. Import relatively — ' + pc.bold(`import { … } from '../ui/<name>'`))
|
|
153
194
|
console.log(' 2. Rebuild: ' + pc.bold('moi bundle'))
|
|
154
195
|
}
|
|
155
|
-
console.log(pc.dim(`\n Component docs: moi ui-components docs ${request.entries
|
|
196
|
+
console.log(pc.dim(`\n Component docs: moi ui-components docs ${request.entries.join(' ')}\n`))
|
|
156
197
|
}
|
|
157
198
|
})
|
|
158
199
|
|
|
@@ -216,9 +257,9 @@ function renderCatalog(uiDir: string, query?: string): void {
|
|
|
216
257
|
console.log(
|
|
217
258
|
'\n' +
|
|
218
259
|
pc.dim(' ✓ installed in .moi/ui/ · add: ') +
|
|
219
|
-
pc.bold('moi ui-components add <name
|
|
260
|
+
pc.bold('moi ui-components add <name…>') +
|
|
220
261
|
pc.dim(' · docs: ') +
|
|
221
|
-
pc.bold('moi ui-components docs <name
|
|
262
|
+
pc.bold('moi ui-components docs <name…>') +
|
|
222
263
|
'\n'
|
|
223
264
|
)
|
|
224
265
|
}
|
package/server/harness/README.md
CHANGED
|
@@ -146,9 +146,15 @@ SDK's `.jsonl` files, with per-turn token usage folded into the final
|
|
|
146
146
|
assistant turn. The Agent SDK remains the transport, while every query is
|
|
147
147
|
forced through the `claude` executable resolved via `executable.ts` (server
|
|
148
148
|
PATH merged with the login-shell PATH).
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
Sessions approve every tool call up front: a `PreToolUse` hook returns
|
|
150
|
+
`allow` (`claude-code/permissions.ts`), which short-circuits the whole
|
|
151
|
+
permission chain — settings rules, the `auto` mode classifier, and
|
|
152
|
+
`canUseTool` alike. `canUseTool` stays registered as a fallback for anything
|
|
153
|
+
that reaches a prompt without passing through `PreToolUse`. This is strictly
|
|
154
|
+
more access than the CLI default — the classifier's safety verdicts no longer
|
|
155
|
+
apply — and is an interim policy until UI approvals land. Known gaps: no
|
|
156
|
+
interactive approval flow yet, and effort/streaming changes require a
|
|
157
|
+
teardown-and-resume because the SDK has no live setter for them.
|
|
152
158
|
|
|
153
159
|
**OpenClaw — shipped.** Chat over the local gateway's WebSocket JSON-RPC
|
|
154
160
|
(wire protocol 4 — the 2026.7.x and 2026.6.x lines; protocol-3 gateways are
|
|
@@ -198,11 +204,14 @@ MCP-startup notices. Workspace discovery scans `~/.codex/sessions` rollout
|
|
|
198
204
|
heads for cwds (`codex/discovery.ts` — no binary needed), and `availability()`
|
|
199
205
|
reports a missing `codex` executable (PATH + login-shell PATH lookup, with a
|
|
200
206
|
Codex Desktop app-bundle fallback — `executable.ts`) to setup flows and the
|
|
201
|
-
workspace composer.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
workspace composer. Sessions use `workspace-write` with network disabled by
|
|
208
|
+
default and `approvalPolicy: on-request`; server→client approval requests are
|
|
209
|
+
accepted by moi at the transport — an interim default-approve policy until UI
|
|
210
|
+
approvals land (`codex/permissions.ts`). The same policy is reapplied on
|
|
211
|
+
thread start, resume, and every turn. Known gaps: no interactive approval flow
|
|
212
|
+
yet. Per-turn application context tells Codex to request escalated localhost
|
|
213
|
+
access before control-server commands. Images ride inline as data URLs only
|
|
214
|
+
(no `localImage` path mode).
|
|
206
215
|
|
|
207
216
|
Workspace availability also checks provider authentication when a workspace is
|
|
208
217
|
given. Claude Code is probed with `claude auth status` under the effective
|
|
@@ -210,10 +219,10 @@ workspace env; `claude auth login` launches its browser sign-in from the compose
|
|
|
210
219
|
uses app-server `account/read` and returns a browser OAuth URL through
|
|
211
220
|
`account/login/start`. The server owns the recovery loop (`server/agent.ts`):
|
|
212
221
|
`GET /api/workspaces/:id/agent` serves a cached availability snapshot alongside
|
|
213
|
-
the model catalog, `POST .../auth/login`
|
|
214
|
-
|
|
215
|
-
out, pushing `agent:updated` events to every tab. The composer
|
|
216
|
-
state; it never polls.
|
|
222
|
+
the model catalog, `POST .../auth/login` reuses a pending browser URL or restarts
|
|
223
|
+
a URL-less provider flow, and a server-side watch loop re-probes until the login
|
|
224
|
+
lands or times out, pushing `agent:updated` events to every tab. The composer
|
|
225
|
+
renders that state; it never polls.
|
|
217
226
|
|
|
218
227
|
## What a harness adapter must support
|
|
219
228
|
|
|
@@ -4,37 +4,52 @@ import { resolveWorkspaceEnv } from '../../workspace-env'
|
|
|
4
4
|
import { findHarnessExecutable } from '../executable'
|
|
5
5
|
|
|
6
6
|
function signedOut(reason: string): HarnessAvailability {
|
|
7
|
-
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
7
|
+
return { status: 'login-required', reason }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function unavailable(reason: string): HarnessAvailability {
|
|
11
|
+
return { status: 'unavailable', reason }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type ClaudeAuthProbeResult = {
|
|
15
|
+
exitCode: number
|
|
16
|
+
timedOut: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CLAUDE_AUTH_UNAVAILABLE = 'Could not check the Claude login status'
|
|
20
|
+
|
|
21
|
+
export function claudeAuthReadiness(result: ClaudeAuthProbeResult): HarnessAvailability {
|
|
22
|
+
if (result.timedOut) return unavailable(CLAUDE_AUTH_UNAVAILABLE)
|
|
23
|
+
if (result.exitCode === 0) return { status: 'available' }
|
|
24
|
+
if (result.exitCode === 1) return signedOut('Claude is signed out. Sign in to send messages')
|
|
25
|
+
return unavailable(CLAUDE_AUTH_UNAVAILABLE)
|
|
12
26
|
}
|
|
13
27
|
|
|
14
|
-
// Claude Code
|
|
15
|
-
// workspace env as the actual Agent SDK subprocess so
|
|
16
|
-
//
|
|
28
|
+
// Claude Code documents exit 0 as logged in and exit 1 as logged out. Run the
|
|
29
|
+
// probe with the same workspace env as the actual Agent SDK subprocess so
|
|
30
|
+
// API-key and enterprise provider configuration match the eventual send.
|
|
17
31
|
export async function getClaudeAuthReadiness(workspacePath: string): Promise<HarnessAvailability> {
|
|
18
32
|
const executable = findHarnessExecutable('claude-code')
|
|
19
|
-
if (!executable) return
|
|
33
|
+
if (!executable) return unavailable('Claude is not installed')
|
|
20
34
|
|
|
35
|
+
const workspaceEnv = await resolveWorkspaceEnv(workspacePath)
|
|
36
|
+
const proc = Bun.spawn([executable, 'auth', 'status'], {
|
|
37
|
+
cwd: workspacePath,
|
|
38
|
+
env: { ...process.env, ...workspaceEnv },
|
|
39
|
+
stdin: 'ignore',
|
|
40
|
+
stdout: 'ignore',
|
|
41
|
+
stderr: 'ignore'
|
|
42
|
+
})
|
|
43
|
+
let timedOut = false
|
|
44
|
+
const timeout = setTimeout(() => {
|
|
45
|
+
timedOut = true
|
|
46
|
+
proc.kill()
|
|
47
|
+
}, 5_000)
|
|
21
48
|
try {
|
|
22
|
-
const workspaceEnv = await resolveWorkspaceEnv(workspacePath)
|
|
23
|
-
const proc = Bun.spawn([executable, 'auth', 'status'], {
|
|
24
|
-
cwd: workspacePath,
|
|
25
|
-
env: { ...process.env, ...workspaceEnv },
|
|
26
|
-
stdin: 'ignore',
|
|
27
|
-
stdout: 'ignore',
|
|
28
|
-
stderr: 'ignore'
|
|
29
|
-
})
|
|
30
|
-
const timeout = setTimeout(() => proc.kill(), 5_000)
|
|
31
49
|
const exitCode = await proc.exited
|
|
50
|
+
return claudeAuthReadiness({ exitCode, timedOut })
|
|
51
|
+
} finally {
|
|
32
52
|
clearTimeout(timeout)
|
|
33
|
-
return exitCode === 0
|
|
34
|
-
? { available: true }
|
|
35
|
-
: signedOut('Claude is signed out. Sign in to send messages')
|
|
36
|
-
} catch {
|
|
37
|
-
return signedOut('Could not verify the Claude login')
|
|
38
53
|
}
|
|
39
54
|
}
|
|
40
55
|
|
|
@@ -99,7 +99,7 @@ export const claudeCodeHarness: Harness = {
|
|
|
99
99
|
discoverWorkspaces,
|
|
100
100
|
availability: async ws => {
|
|
101
101
|
const runtime = await pathHarnessAvailability('claude-code')
|
|
102
|
-
return runtime.available && ws ? getClaudeAuthReadiness(ws.path) : runtime
|
|
102
|
+
return runtime.status === 'available' && ws ? getClaudeAuthReadiness(ws.path) : runtime
|
|
103
103
|
},
|
|
104
104
|
startLogin: ws => startClaudeLogin(ws.path),
|
|
105
105
|
|