moi-computer 0.11.1-next.1 → 0.11.1-next.2

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 (43) hide show
  1. package/client/features/chat/chat-frames.ts +4 -5
  2. package/client/features/chat/chat-send.ts +13 -2
  3. package/client/features/chat/chat-store.ts +1 -3
  4. package/client/features/chat/composer/ModelPicker.tsx +40 -41
  5. package/client/features/chat/composer/model-order.ts +15 -0
  6. package/client/features/chat/group-turns.ts +1 -0
  7. package/client/features/chat/interleave-notices.ts +7 -11
  8. package/client/features/chat/tool-group/ToolCallGroup.tsx +1 -4
  9. package/client/features/chat/tool-group/format/codex.ts +4 -1
  10. package/client/features/chat/useChat.ts +5 -8
  11. package/dist/chunk-245wt82v.css +1 -0
  12. package/dist/{chunk-yc471zah.js → chunk-j7hh2ab4.js} +48 -48
  13. package/dist/{chunk-vwjeezeb.js → chunk-y8eyahwx.js} +1 -1
  14. package/dist/index.html +1 -1
  15. package/lib/format.ts +6 -5
  16. package/lib/types.ts +5 -2
  17. package/package.json +1 -1
  18. package/server/api.ts +1 -1
  19. package/server/bundler/applet-css.ts +1 -106
  20. package/server/harness/README.md +28 -39
  21. package/server/harness/codex/NOTES.md +222 -350
  22. package/server/harness/codex/adapter.ts +94 -45
  23. package/server/harness/codex/auth.ts +1 -3
  24. package/server/harness/codex/client.ts +169 -249
  25. package/server/harness/codex/discovery.ts +9 -17
  26. package/server/harness/codex/index.ts +2 -1
  27. package/server/harness/codex/pagination.ts +24 -0
  28. package/server/harness/codex/permissions.ts +31 -7
  29. package/server/harness/codex/probe.ts +10 -13
  30. package/server/harness/codex/session.ts +549 -136
  31. package/server/harness/codex/transport.ts +184 -0
  32. package/server/harness/debug.ts +1 -1
  33. package/server/web.ts +3 -0
  34. package/ui-components/alert-dialog.tsx +1 -1
  35. package/ui-components/alert.tsx +1 -1
  36. package/ui-components/avatar.tsx +1 -1
  37. package/ui-components/checkbox.tsx +2 -1
  38. package/ui-components/combobox.tsx +3 -1
  39. package/ui-components/field.tsx +1 -1
  40. package/ui-components/input-group.tsx +2 -2
  41. package/ui-components/radio-group.tsx +2 -1
  42. package/ui-components/switch.tsx +2 -1
  43. package/dist/chunk-6664vxpk.css +0 -1
@@ -1 +1 @@
1
- import{Lc as a}from"/chunk-j3wvxjr7.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function o(r){let[{mount:t}]=await Promise.all([import("/chunk-yc471zah.js"),import("/chunk-eg120aca.js").then((e)=>e.loadAppConfig())]);t(r)}globalThis.__init=o;
1
+ import{Lc as a}from"/chunk-j3wvxjr7.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function o(r){let[{mount:t}]=await Promise.all([import("/chunk-j7hh2ab4.js"),import("/chunk-eg120aca.js").then((e)=>e.loadAppConfig())]);t(r)}globalThis.__init=o;
package/dist/index.html CHANGED
@@ -36,7 +36,7 @@
36
36
  }
37
37
  </script>
38
38
 
39
- <link rel="stylesheet" crossorigin href="/chunk-6664vxpk.css"><script type="module" crossorigin src="/chunk-vwjeezeb.js"></script></head>
39
+ <link rel="stylesheet" crossorigin href="/chunk-245wt82v.css"><script type="module" crossorigin src="/chunk-y8eyahwx.js"></script></head>
40
40
  <body>
41
41
  <div id="root"></div>
42
42
 
package/lib/format.ts CHANGED
@@ -97,8 +97,8 @@ export type TurnMeta = {
97
97
  model?: string
98
98
  provider?: string
99
99
  stopReason?: string
100
- // Agent-run duration. Derived from transcript timestamps when available;
101
- // Codex supplies its native duration because its transcript items lack them.
100
+ // Agent-run duration. Prefer native duration when item timestamps cannot
101
+ // measure the run (Codex replay items can share one start timestamp).
102
102
  durationMs?: number
103
103
  usage?: { inputTokens?: number; outputTokens?: number; totalTokens?: number; costUsd?: number }
104
104
  // The API message id (`msg_...`) that produced this assistant turn, when the
@@ -142,6 +142,7 @@ export type SessionSnapshot = {
142
142
  }
143
143
 
144
144
  export type SystemNotice =
145
+ | { id: string; kind: 'warning'; at: string; message: string }
145
146
  | {
146
147
  id: string
147
148
  kind: 'rate-limit'
@@ -152,9 +153,9 @@ export type SystemNotice =
152
153
  id: string
153
154
  kind: 'api-retry'
154
155
  at: string
155
- attempt: number
156
- maxRetries: number
157
- delayMs: number
156
+ attempt?: number
157
+ maxRetries?: number
158
+ delayMs?: number
158
159
  error?: string
159
160
  }
160
161
  | { id: string; kind: 'compact'; at: string; metadata?: unknown }
package/lib/types.ts CHANGED
@@ -492,6 +492,9 @@ export type ErrorFrame = {
492
492
  workspaceId: string
493
493
  sessionId: string
494
494
  content: string
495
+ // A failed steer or interrupt leaves the current run active. Older senders
496
+ // omit this field and retain terminal-error behavior.
497
+ terminal?: boolean
495
498
  }
496
499
 
497
500
  export type StoppedFrame = {
@@ -504,8 +507,8 @@ export type StoppedFrame = {
504
507
  // lifecycle signal (CC `session_state_changed`, Codex `turn/*`, OpenClaw run
505
508
  // lifecycle) rather than derived by counting messages:
506
509
  // running — the agent is working; the client shows the loader/Stop
507
- // requires-action — the agent is blocked on user input (permission prompt,
508
- // MCP elicitation). Not rendered yet: no loader, no Stop.
510
+ // requires-action — waiting for user input; no loader/Stop. Input notices
511
+ // provide the answer form independently of this state.
509
512
  // idle — everything else, including interrupted/failed turns
510
513
  export type SessionActivity = 'idle' | 'running' | 'requires-action'
511
514
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moi-computer",
3
- "version": "0.11.1-next.1",
3
+ "version": "0.11.1-next.2",
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/api.ts CHANGED
@@ -600,7 +600,7 @@ one.get('/mcp', async c => {
600
600
  return c.json((await harnessFor(ws).mcpStatus?.(ws)) ?? [])
601
601
  })
602
602
 
603
- // Harness debug tap for /playground/harness: the backend's native wire frames
603
+ // Harness debug tap for /dev/harness: the backend's native wire frames
604
604
  // (Codex: app-server JSON-RPC, both directions; Claude Code: raw SDK messages
605
605
  // + enqueued inputs) and the exact frames the server pushed to chat clients.
606
606
  // `sinceWire`/`sinceBroadcast` are seq cursors so the page can poll deltas.
@@ -28,111 +28,6 @@ import postcss, { type Container, type Document } from 'postcss'
28
28
  // matching an unrelated tag/class prefix like `bodycopy`.
29
29
  const PAGE_ROOT_RE = /^(:root|:host|html|body)(?![\w-])/
30
30
 
31
- // Tailwind's `group-has-*` / `peer-has-*` utilities compile to
32
- // `.util:is(:where(.group):has(…) *)` — a non-subject `:has()` qualifying a
33
- // universal `*` subject. Chrome cannot build a precise invalidation set for
34
- // that shape and falls back to restyling the WHOLE document on unrelated DOM
35
- // mutations: with one such rule mounted, every keystroke anywhere on the page
36
- // recalculated styles for all ~10k elements (~140ms per key next to a large
37
- // view — measured, see the chat-input-lag investigation). The equivalent
38
- // descendant form `:where(.group):has(…) .util` matches the same elements
39
- // with the same specificity (`:is()` takes its most specific argument), and
40
- // Chrome invalidates it precisely.
41
- //
42
- // The rewrite is deliberately conservative, because it is only safe when it
43
- // cannot reorder ancestor constraints:
44
- // • The qualifier must sit on the LEFTMOST compound. That compound has no
45
- // ancestor constraints to its left, so prepending its anchor imposes
46
- // nothing new — this covers `.util:is(Q *)` and variant chains like
47
- // `.util:is(Q *) > svg` (the `[&>svg]:` arbitrary variant). On any later
48
- // compound (`A .util:is(Q *)`) the prepended anchor would force Q above
49
- // A, which the original never required, so those are skipped.
50
- // • Only the ONE `:is(…:has(…) *)` qualifier moves out. Every other
51
- // qualifier (`:is(:where(.group)[data-x] *)`, stacked pseudos) stays on
52
- // the subject, where it keeps constraining the same element — shadcn's
53
- // alert-dialog stacks `group-data-*` and `group-has-data-*` exactly like
54
- // this. Moving two anchors out would chain them into a strict ancestor
55
- // order the original didn't have, so a second `:has` qualifier is left
56
- // in place.
57
- // • A qualifier with a top-level comma (`:is(A *, B)`) is skipped — the
58
- // extraction is only equivalence-preserving for a single argument.
59
- // The trailing `~` of `peer-has-*` (`:is(:where(.peer):has(…) ~ *)`) rides
60
- // along, keeping the sibling combinator.
61
-
62
- // Index of the first top-level combinator (space, >, +, ~ outside parens,
63
- // brackets, and strings), or -1 when the selector is a single compound.
64
- function firstCombinatorIndex(selector: string): number {
65
- let depth = 0
66
- let quote: string | null = null
67
- for (let i = 0; i < selector.length; i++) {
68
- const ch = selector[i]!
69
- if (quote) {
70
- if (ch === '\\') i++
71
- else if (ch === quote) quote = null
72
- continue
73
- }
74
- if (ch === '"' || ch === "'") quote = ch
75
- else if (ch === '\\') i++
76
- else if (ch === '(' || ch === '[') depth++
77
- else if (ch === ')' || ch === ']') depth--
78
- else if (depth === 0 && (ch === ' ' || ch === '>' || ch === '+' || ch === '~')) return i
79
- }
80
- return -1
81
- }
82
-
83
- // The span of the first `:is(…)` qualifier whose single argument contains
84
- // `:has(` and ends with a universal `*` subject, or null.
85
- function findHasQualifier(selector: string): { start: number; end: number; anchor: string } | null {
86
- for (let from = 0; ; ) {
87
- const start = selector.indexOf(':is(', from)
88
- if (start === -1) return null
89
- // Find the matching close paren, tracking nested parens and strings.
90
- let depth = 0
91
- let quote: string | null = null
92
- let end = -1
93
- let topComma = false
94
- for (let i = start + 3; i < selector.length; i++) {
95
- const ch = selector[i]!
96
- if (quote) {
97
- if (ch === '\\') i++
98
- else if (ch === quote) quote = null
99
- continue
100
- }
101
- if (ch === '"' || ch === "'") quote = ch
102
- else if (ch === '\\') i++
103
- else if (ch === '(') depth++
104
- else if (ch === ')') {
105
- depth--
106
- if (depth === 0) {
107
- end = i
108
- break
109
- }
110
- } else if (ch === ',' && depth === 1) topComma = true
111
- }
112
- if (end === -1) return null
113
- const inner = selector.slice(start + 4, end).trim()
114
- if (!topComma && inner.includes(':has(') && inner.endsWith('*')) {
115
- const anchor = inner.slice(0, -1).trim()
116
- if (anchor.length > 0) return { start, end: end + 1, anchor }
117
- }
118
- from = end + 1
119
- }
120
- }
121
-
122
- export function unqualifyNonSubjectHas(selector: string): string {
123
- if (!selector.includes(':has(')) return selector
124
- const combinatorAt = firstCombinatorIndex(selector)
125
- const compound = combinatorAt === -1 ? selector : selector.slice(0, combinatorAt)
126
- const rest = combinatorAt === -1 ? '' : selector.slice(combinatorAt)
127
- const qualifier = findHasQualifier(compound)
128
- if (!qualifier) return selector
129
- const subject = (compound.slice(0, qualifier.start) + compound.slice(qualifier.end)).trim()
130
- if (subject.length === 0) return selector
131
- // `anchor` may end with the peer variant's `~`; the join keeps it a sibling
132
- // combinator, otherwise it's a descendant combinator.
133
- return `${qualifier.anchor} ${subject}${rest}`
134
- }
135
-
136
31
  function insideKeyframes(parent: Container | Document | undefined): boolean {
137
32
  return (
138
33
  parent?.type === 'atrule' &&
@@ -149,7 +44,7 @@ export function scopeAppletCss(css: string, scope: string): string {
149
44
  root.walkRules(rule => {
150
45
  if (insideKeyframes(rule.parent)) return
151
46
  rule.selectors = rule.selectors.map(selector => {
152
- const s = unqualifyNonSubjectHas(selector.trim())
47
+ const s = selector.trim()
153
48
  const rootToken = PAGE_ROOT_RE.exec(s)
154
49
  if (rootToken) return container + s.slice(rootToken[0].length)
155
50
  return `${container} ${s}`
@@ -57,8 +57,7 @@ Socket-protocol notes the layers rely on (all defined in `lib/types.ts`):
57
57
  lifecycle signal — never derived by counting sends vs results. The snapshot
58
58
  (sent on connect and re-broadcast periodically) is authoritative: the client
59
59
  rebuilds its whole activity map from it, so a lost terminal frame self-heals.
60
- `requires-action` (agent blocked on user input) is tracked but not rendered
61
- yet — the client shows no loader for it.
60
+ `requires-action` suppresses the loader.
62
61
  - **`preview`** — live token frames, cumulative text, never persisted;
63
62
  cleared when the turn with matching `meta.apiMessageId` lands.
64
63
 
@@ -75,9 +74,9 @@ server/harness/
75
74
  hand-written wire types it consumes
76
75
  session.ts live per-thread state machine (send/interrupt/turn
77
76
  accounting/preview forwarding)
78
- <transport>.ts process/connection management, named for what it is:
79
- codex/client.ts, openclaw/gateway.ts (CC has none — the
80
- Agent SDK is the transport)
77
+ <transport>.ts connection management: codex/client.ts owns processes and
78
+ codex/transport.ts frames stdio; openclaw/gateway.ts owns
79
+ the gateway connection (CC uses the Agent SDK)
81
80
  discovery.ts / models.ts / sessions.ts / mcp.ts as needed
82
81
  NOTES.md the backend's wire protocol, empirically verified
83
82
  *.test.ts tests live next to the code they cover
@@ -192,29 +191,19 @@ tool calls left unsettled at turn end are closed (Hermes never completes file
192
191
  read/write calls live), and a completing `tool_call_update` carries no title, so
193
192
  the established name is kept. See `hermes/NOTES.md`.
194
193
 
195
- **Codex — shipped, experimental.** Chat over `codex app-server` (stdio
196
- JSON-RPC, one process per workspace so `workspaceEnv` injects at spawn —
197
- `codex/client.ts`): thread create/resume with temp-id rename, per-turn model +
198
- effort overrides (both live — no rebuild dance), opt-in token streaming from
199
- `item/*/delta`, reasoning summaries via `summary: 'auto'`, mid-turn sends
200
- steered into the running turn (`turn/steer` with `turn/start` fallback),
201
- interrupt, per-turn token usage folded into `TurnMeta`, native optimistic-id
202
- rendezvous, session list via `thread/list` (cwd-filtered) and history replay
203
- via `thread/read`, subagent (collab) child threads nested as live
204
- SubagentRecord transcripts on the parent card, semantic exec labels from
205
- `commandActions`, MCP status via `mcpServerStatus/list`, and hook / failed
206
- MCP-startup notices. Workspace discovery scans `~/.codex/sessions` rollout
207
- heads for cwds (`codex/discovery.ts` — no binary needed), and `availability()`
208
- reports a missing `codex` executable (PATH + login-shell PATH lookup, with a
209
- Codex Desktop app-bundle fallback — `executable.ts`) to setup flows and the
210
- workspace composer. Sessions use `workspace-write` with network disabled by
211
- default and `approvalPolicy: on-request`; server→client approval requests are
212
- accepted by moi at the transport — an interim default-approve policy until UI
213
- approvals land (`codex/permissions.ts`). The same policy is reapplied on
214
- thread start, resume, and every turn. Known gaps: no interactive approval flow
215
- yet. Per-turn application context tells Codex to request escalated localhost
216
- access before control-server commands. Images ride inline as data URLs only
217
- (no `localImage` path mode).
194
+ **Codex — shipped, experimental.** One `codex app-server` per workspace supplies
195
+ chat, model/session catalogs, history, steering, and interruption. The harness
196
+ maps items into shared display events, including subagent transcripts, reasoning
197
+ previews, usage, and hook/MCP failure notices.
198
+ Model, effort, and fast-mode choices apply on the next new turn; the sent model
199
+ matches the picker even when Codex config names an unavailable model.
200
+
201
+ Workspace env is fixed at process spawn. Executable lookup prefers PATH over
202
+ the desktop bundle; config and credentials remain owned by Codex. Sessions use
203
+ workspace-write access with network disabled, and moi automatically accepts
204
+ supported permission requests. Command-approval UI, native question forms, and
205
+ MCP elicitation are not implemented. See [Codex harness notes](codex/NOTES.md)
206
+ for module ownership, ordering rules, runtime diagnostics, and boundaries.
218
207
 
219
208
  Workspace availability also checks provider authentication when a workspace is
220
209
  given. Claude Code is probed with `claude auth status` under the effective
@@ -260,8 +249,8 @@ doubles as the evaluation rubric for new harnesses.
260
249
  - **Set model** — ideally live mid-session.
261
250
  - **Set reasoning effort** — CC applies `applyFlagSettings({ effortLevel })`
262
251
  before the next message; Codex takes it per turn.
263
- - **Thinking/reasoning display mode** (Codex: `summary: 'auto'` is required or
264
- reasoning items arrive empty).
252
+ - **Thinking/reasoning display mode** (Codex requests `summary: 'detailed'`
253
+ so visible summaries do not depend on CLI defaults).
265
254
  - **Token streaming opt-in** (CC: `includePartialMessages`, construct-time;
266
255
  Codex: always streams, moi gates forwarding).
267
256
  - **Permissions / tool policy** — allowed tools, permission mode; backends
@@ -308,25 +297,26 @@ doubles as the evaluation rubric for new harnesses.
308
297
 
309
298
  ## Capability comparison
310
299
 
311
- Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing.
300
+ Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing. The Codex column
301
+ describes what moi exposes, not every RPC available in the upstream protocol.
312
302
 
313
303
  | Feature | Claude Agent SDK | OpenClaw gateway | Codex app-server | Hermes (ACP) |
314
304
  | ------------------------ | --------------------------------------------------- | ------------------------- | ------------------------------------- | ------------------------------------ |
315
305
  | Long-lived session | ✅ subprocess per session | ✅ gateway-side | ✅ server-side, N threads/process | ✅ process per workspace, N sessions |
316
306
  | Queue/steer mid-turn | ⚠️ queued next turn | ⚠️ | ✅ `turn/steer` into live turn | ⚠️ queued (ACP has no steer) |
317
- | Resume | ✅ | ✅ | ✅ + fork | ✅ `session/load` (+ fork) |
307
+ | Resume | ✅ | ✅ | ✅ `thread/resume` | ✅ `session/load` (+ fork) |
318
308
  | Interrupt | ✅ `interrupt()` | ✅ | ✅ `turn/interrupt` | ✅ `session/cancel` → `cancelled` |
319
309
  | List models | ✅ `supportedModels()` | ✅ `models.list` | ✅ `model/list` | ✅ inline on `session/new` |
320
310
  | Live model switch | ✅ `setModel()` | ✅ `sessions.patch` | ✅ per-turn override | ⚠️ drops session MCP servers |
321
311
  | Live effort switch | ✅ `applyFlagSettings` | ✅ `thinkingLevel` patch | ✅ per-turn | ❌ no effort concept in ACP |
322
312
  | Token deltas | ✅ opt-in | ✅ `chat` frames | ✅ `item/*/delta` | ✅ always on, thinking + text |
323
- | Images in input | ✅ base64 blocks | ⚠️ materialize to path | ✅ data URL or path | ✅ base64 blocks |
313
+ | Images in input | ✅ base64 blocks | ⚠️ materialize to path | ✅ inline data URLs | ✅ base64 blocks |
324
314
  | Interactive approvals | ⚠️ (we bypass) | ✅ | ✅ server→client requests (we bypass) | ✅ real, with diffs (we bypass) |
325
315
  | Session list/history API | ✅ `listSessions()` + jsonl | ✅ `sessions.get` | ✅ `thread/list`/`read` | ✅ `session/list` (cwd + cursor) |
326
316
  | Home card preview | ✅ session file scan | ✅ cached first message | ⚠️ live app-server only | ⚠️ live process only |
327
317
  | MCP status | ✅ `mcpServerStatus()` | n/a | ✅ `mcpServerStatus/list` | ⚠️ per-session config, no status RPC |
328
- | Usage reporting | ⚠️ cost/duration on `result` (adapter drops tokens) | ✅ tokens + cost per turn | ✅ live + rate limits | ✅ tokens per turn |
329
- | Structured output | ❌ | ❌ | ✅ per turn | ❌ |
318
+ | Usage reporting | ⚠️ cost/duration on `result` (adapter drops tokens) | ✅ tokens + cost per turn | ✅ per-turn tokens and duration | ✅ tokens per turn |
319
+ | Structured output | ❌ | ❌ | ⚠️ title generation only | ❌ |
330
320
 
331
321
  ## Design lessons so far
332
322
 
@@ -334,10 +324,9 @@ Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing.
334
324
  via `applyFlagSettings`) or construct-time (streaming).
335
325
  Encode that distinction per-setting in the adapter interface instead of
336
326
  hardcoding the drain-then-rebuild machinery.
337
- - Harnesses split into two topologies: **held-open** (CC subprocess, OpenClaw
338
- gateway, Codex app-server) and **spawn-per-turn** (Codex exec SDK — see
339
- `codex/NOTES.md` §1 for why we rejected it). The session manager should
340
- support both.
327
+ - Chat harnesses keep connections open (CC subprocess, OpenClaw gateway,
328
+ Codex app-server). Separate one-shot work, such as Codex title generation,
329
+ can use a short-lived process without changing chat session ownership.
341
330
  - Event vocabularies differ in kind, not just names: CC emits raw
342
331
  tool_use/tool_result pairs; Codex emits semantic items (a patch, a command)
343
332
  with their own lifecycle. The adapter layer is where that converges on