moi-computer 0.10.1-next.3 → 0.10.1-next.5

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.
Files changed (70) hide show
  1. package/README.md +2 -0
  2. package/client/app/shell/SidebarLayout.tsx +53 -14
  3. package/client/components/shared/AgentBlobatar.tsx +3 -3
  4. package/client/components/shared/Composer.tsx +4 -10
  5. package/client/features/chat/ChatEmptyState.tsx +2 -9
  6. package/client/features/chat/ChatPanel.tsx +21 -23
  7. package/client/features/chat/ChatPopup.tsx +3 -3
  8. package/client/features/chat/composer/ChatComposer.tsx +2 -2
  9. package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +101 -0
  10. package/client/features/chat/composer/banners/{ChatErrorBanner.tsx → ErrorBanner.tsx} +2 -2
  11. package/client/features/chat/composer/banners/{WorkspaceSkillUpdateBanner.tsx → SkillUpdateBanner.tsx} +3 -3
  12. package/client/features/chat/composer/useWorkspaceComposerState.tsx +14 -24
  13. package/client/features/chat/composer/useWorkspaceSkillUpdates.ts +6 -6
  14. package/client/features/chat/useAppletChatMessage.ts +9 -5
  15. package/client/features/dev/BlobatarShapesPage.tsx +344 -0
  16. package/client/features/dev/ChatStatesPage.tsx +3 -4
  17. package/client/features/dev/DevIndexPage.tsx +5 -0
  18. package/client/features/dev/DevRoutes.tsx +2 -0
  19. package/client/features/home/HomePage.tsx +47 -5
  20. package/client/features/home/WorkspacePreview.tsx +4 -4
  21. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +1 -1
  22. package/client/features/update/{Update.tsx → UpdateControl.tsx} +33 -9
  23. package/client/features/workspace/CustomizePanel.tsx +1 -1
  24. package/client/features/workspace/WorkspaceScreen.tsx +5 -5
  25. package/client/features/workspace/api.ts +10 -1
  26. package/client/lib/agent-availability.ts +19 -0
  27. package/client/runtime/useWorkspaceEvents.ts +16 -2
  28. package/client/runtime/workspace-theme.ts +2 -8
  29. package/dist/chunk-104m57qw.js +2 -0
  30. package/dist/chunk-bj3akjs2.js +1 -0
  31. package/dist/{chunk-0pcdwjkp.js → chunk-c9pjqx9m.js} +1 -1
  32. package/dist/chunk-ewwv181c.js +1 -0
  33. package/dist/{chunk-8jh75pjg.js → chunk-j2w2vak4.js} +2 -2
  34. package/dist/chunk-k2r9c95m.js +10 -0
  35. package/dist/chunk-kmbxhgwv.js +1 -0
  36. package/dist/chunk-r5y4gtdk.js +83 -0
  37. package/dist/chunk-r8s1b672.css +1 -0
  38. package/dist/{chunk-yt2qjn3m.js → chunk-tny85yt2.js} +2 -2
  39. package/dist/{chunk-9y2zbzqz.js → chunk-v7wr1df4.js} +1 -1
  40. package/dist/index.html +1 -1
  41. package/lib/themes.ts +31 -7
  42. package/lib/types.ts +9 -8
  43. package/package.json +1 -1
  44. package/server/AGENTS.md +1 -1
  45. package/server/agent.ts +46 -22
  46. package/server/api.ts +6 -6
  47. package/server/cli-ui-components.ts +63 -22
  48. package/server/harness/README.md +21 -12
  49. package/server/harness/claude-code/auth.ts +38 -23
  50. package/server/harness/claude-code/index.ts +1 -1
  51. package/server/harness/claude-code/permissions.ts +34 -0
  52. package/server/harness/claude-code/session.ts +7 -15
  53. package/server/harness/codex/auth.ts +31 -21
  54. package/server/harness/codex/client.ts +5 -14
  55. package/server/harness/codex/index.ts +1 -1
  56. package/server/harness/codex/permissions.ts +56 -0
  57. package/server/harness/codex/session.ts +25 -20
  58. package/server/harness/executable.ts +2 -2
  59. package/server/harness/hermes/index.ts +4 -5
  60. package/server/ui-components.ts +29 -0
  61. package/workspace/.claude/skills/moi-workspace/SKILL.md +9 -7
  62. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +24 -12
  63. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +0 -82
  64. package/dist/chunk-4xmcsjjv.js +0 -1
  65. package/dist/chunk-76j95afs.css +0 -1
  66. package/dist/chunk-dfs36zgc.js +0 -1
  67. package/dist/chunk-e4e993yf.js +0 -83
  68. package/dist/chunk-vq8ga42s.js +0 -1
  69. package/dist/chunk-yhj9bg1s.js +0 -2
  70. package/dist/chunk-yz743a75.js +0 -10
@@ -1,2 +1,2 @@
1
- import{Qc as w,Sc as s}from"/chunk-yhj9bg1s.js";import{Uc as q}from"/chunk-9y2zbzqz.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 Lc,T as Mc,y as Nc,c as Oc,h as Pc};
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 Uc,t as Vc,u as Wc,v as Xc};
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-76j95afs.css"><script type="module" crossorigin src="/chunk-vq8ga42s.js"></script></head>
39
+ <link rel="stylesheet" crossorigin href="/chunk-r8s1b672.css"><script type="module" crossorigin src="/chunk-ewwv181c.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 = 'round' | 'boxy' | 'capsule' | 'triangle'
86
+ export type AgentTheme = 'blob' | 'boxy' | 'pill' | 'dorito'
86
87
 
87
88
  export type AgentThemeConfig = {
88
89
  label: string
89
- shape: number
90
+ traits: TraitOverrides
90
91
  }
91
92
 
92
93
  export const AGENT_THEMES: Record<AgentTheme, AgentThemeConfig> = {
93
- round: { label: 'Round', shape: 0.11 },
94
- boxy: { label: 'Boxy', shape: 0.54 },
95
- capsule: { label: 'Capsule', shape: 0.65 },
96
- triangle: { label: 'Triangle', shape: 0.99 }
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 { ...DEFAULT_WORKSPACE_THEME, ...theme }
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 attach a
422
- // login command, which makes the composer show its Sign in action.
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
- | { available: true }
425
- | { available: false; reason: string; loginCommand?: string }
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, one per workspace. `pending` means a watch
431
- // loop is re-probing the provider until the login lands or the deadline
432
- // passes; transitions arrive as `agent:updated` events, so every tab shows
433
- // the same ceremony without polling.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moi-computer",
3
- "version": "0.10.1-next.3",
3
+ "version": "0.10.1-next.5",
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",
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 with bypass permissions; each backend persists its own session history (see `harness/README.md`).
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 — or joins — the single
6
- // ceremony per workspace. While a ceremony is pending, a watch loop re-probes
7
- // the provider until the login lands or the deadline passes, and every
8
- // transition is pushed to all tabs as an `agent:updated` event on the
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 = options.probe(ws).finally(() => {
85
- entry.probe = undefined
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(ws: AgentWorkspace, login: LoginCeremony) {
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
- let value: HarnessAvailability
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
- // Join the in-flight ceremony instead of starting a second provider flow
157
- // (two tabs, a remount, a double-click — all land here).
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') return { url: current.state.url }
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
- publish(ws.id, entry.cached?.value ?? { available: false, reason: 'Waiting for sign-in' })
171
- watch(ws, login)
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)) ?? { available: true },
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 (!availability.available) return c.text(availability.reason, 400)
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
- // Idempotent per workspace: a second call joins the pending ceremony instead
685
- // of starting another provider flow. Completion is pushed as `agent:updated`.
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 (!availability.available) return c.text(availability.reason, 400)
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?.()) ?? { available: true }
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 (!availability.available) return c.text(availability.reason, 400)
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 installs dependencies,
9
- // never rebuilds, never edits existing files — it prints next steps and the
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: any requested
93
- // file that already exists fails the whole add unless --force. Existing
94
- // support files (utils, applet-portal, registry deps that rode along) are
95
- // kept as-is either way.
96
- const conflicts = plans.filter(plan => plan.exists && !plan.support)
97
- if (conflicts.length > 0 && !args.force) {
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
- conflicts.map(plan => pc.bold(plan.name)).join(', ') +
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 kept: string[] = []
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 (deps.length > 0) {
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: ' + pc.bold(`${cdPrefix}bun install ${deps.join(' ')}`)
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[0]}\n`))
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
  }
@@ -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
- Known gaps: runs with `bypassPermissions` only (no interactive approval
150
- flow), and effort/streaming changes require a teardown-and-resume because the
151
- SDK has no live setter for them.
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. Runs `danger-full-access` + `approvalPolicy: never`
202
- to match moi's bypass-permissions trust model. Known gaps: no interactive
203
- approval flow (server→client approval requests are auto-accepted
204
- defensively), and images ride inline as data URLs only (no `localImage` path
205
- mode).
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` starts (or joins) the one ceremony per
214
- workspace, and a server-side watch loop re-probes until the login lands or times
215
- out, pushing `agent:updated` events to every tab. The composer renders that
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
- available: false,
9
- reason,
10
- loginCommand: 'claude auth login'
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 2.1.42+ exposes a stable JSON auth probe. Run it with the same
15
- // workspace env as the actual Agent SDK subprocess so API-key and enterprise
16
- // provider configuration are evaluated consistently with the eventual send.
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 signedOut('Claude is not installed')
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