moi-computer 0.8.1-next.0 → 0.9.1-next.0

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 (103) hide show
  1. package/client/assets/hermes.png +0 -0
  2. package/client/components/shared/IconGhost.tsx +15 -18
  3. package/client/components/ui/button.tsx +2 -2
  4. package/client/components/ui/hover-card.tsx +1 -1
  5. package/client/components/ui/popover.tsx +3 -1
  6. package/client/features/chat/ChatEmptyState.tsx +25 -7
  7. package/client/features/chat/ChatPanel.tsx +70 -28
  8. package/client/features/chat/ChatPopup.tsx +3 -2
  9. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  10. package/client/features/chat/MarkdownContent.tsx +1 -1
  11. package/client/features/chat/attachment-staging.ts +153 -0
  12. package/client/features/chat/chat-send.ts +55 -0
  13. package/client/features/chat/chat-store.ts +32 -8
  14. package/client/features/chat/composer/ChatComposer.tsx +190 -77
  15. package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
  16. package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
  17. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
  18. package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
  19. package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
  20. package/client/features/chat/tool-group/format/claude.ts +48 -0
  21. package/client/features/chat/tool-group/format/codex.ts +126 -0
  22. package/client/features/chat/tool-group/format/hermes.ts +68 -0
  23. package/client/features/chat/tool-group/format/index.ts +34 -0
  24. package/client/features/chat/tool-group/format/mcp.ts +64 -0
  25. package/client/features/chat/tool-group/format/openclaw.ts +116 -0
  26. package/client/features/chat/tool-group/format/shared.ts +49 -0
  27. package/client/features/chat/useChat.ts +5 -10
  28. package/client/features/dev/ChatStatesPage.tsx +40 -2
  29. package/client/features/drawings/DrawingLayer.tsx +49 -0
  30. package/client/features/drawings/DrawingToolbar.tsx +95 -0
  31. package/client/features/drawings/annotation-availability.ts +10 -0
  32. package/client/features/drawings/capture-element.ts +45 -0
  33. package/client/features/drawings/useChatAnnotation.ts +222 -0
  34. package/client/features/drawings/useDrawingLayer.ts +758 -0
  35. package/client/features/drawings/useViewBuilderSketch.ts +151 -0
  36. package/client/features/home/workspace-presentation.tsx +6 -2
  37. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +12 -6
  38. package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
  39. package/client/features/views/ViewBuilder.tsx +224 -0
  40. package/client/features/views/api.ts +1 -0
  41. package/client/features/views/useViewBuilderActions.ts +24 -3
  42. package/client/features/views/useViewBuilderDrafts.ts +66 -0
  43. package/client/features/widgets/Widgets.tsx +23 -39
  44. package/client/features/workspace/CustomizePanel.tsx +1 -1
  45. package/client/features/workspace/WorkspaceScreen.tsx +157 -57
  46. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  47. package/client/features/workspace/useFitsSplitLayout.ts +14 -8
  48. package/client/index.css +8 -0
  49. package/client/store/ui.ts +19 -0
  50. package/client/theme.css +33 -8
  51. package/dist/chunk-3becmq75.js +81 -0
  52. package/dist/{chunk-kkj86722.js → chunk-6w6j9g4b.js} +78 -78
  53. package/dist/{chunk-xeyxk7ep.js → chunk-8ew39cvq.js} +4 -4
  54. package/dist/chunk-c8gtrjwp.js +1 -0
  55. package/dist/{chunk-2vaafjp4.js → chunk-pp62fnxh.js} +1 -1
  56. package/dist/{chunk-35fq49qa.js → chunk-sxc24vfp.js} +1 -1
  57. package/dist/{chunk-xzx7c9hq.js → chunk-v964b5g7.js} +1 -1
  58. package/dist/chunk-zx33ts9d.css +1 -0
  59. package/dist/hermes-pznd63x9.png +0 -0
  60. package/dist/index.html +1 -1
  61. package/lib/format.ts +21 -7
  62. package/lib/themes.ts +8 -8
  63. package/lib/types.ts +8 -1
  64. package/lib/workspace-types.ts +2 -1
  65. package/package.json +6 -4
  66. package/server/api.ts +21 -2
  67. package/server/bundler/build-applet.ts +35 -44
  68. package/server/cli-env.ts +2 -2
  69. package/server/cli.ts +227 -56
  70. package/server/constants.ts +8 -0
  71. package/server/control-client.ts +124 -0
  72. package/server/control.ts +2 -2
  73. package/server/harness/README.md +74 -23
  74. package/server/harness/acp/adapter.ts +220 -0
  75. package/server/harness/acp/archived.ts +88 -0
  76. package/server/harness/acp/client.ts +328 -0
  77. package/server/harness/acp/discovery.ts +130 -0
  78. package/server/harness/acp/run-durations.ts +68 -0
  79. package/server/harness/acp/session.ts +788 -0
  80. package/server/harness/acp/wire.ts +132 -0
  81. package/server/harness/executable.ts +15 -1
  82. package/server/harness/hermes/NOTES.md +815 -0
  83. package/server/harness/hermes/discovery.ts +155 -0
  84. package/server/harness/hermes/index.ts +155 -0
  85. package/server/harness/hermes/models.ts +79 -0
  86. package/server/harness/openclaw/NOTES.md +196 -94
  87. package/server/harness/openclaw/adapter.ts +28 -55
  88. package/server/harness/openclaw/compat.ts +4 -8
  89. package/server/harness/openclaw/session.ts +257 -238
  90. package/server/harness/openclaw/strip.ts +10 -34
  91. package/server/harness/openclaw/thinking.ts +5 -53
  92. package/server/harness/registry.ts +3 -1
  93. package/server/service.ts +2 -2
  94. package/server/view-builders.ts +4 -2
  95. package/server/workspace-import.ts +30 -1
  96. package/workspace/.claude/skills/moi-workspace/SKILL.md +6 -6
  97. package/client/features/chat/tool-group/format.ts +0 -359
  98. package/client/features/views/ViewBuilderTab.tsx +0 -152
  99. package/dist/chunk-gny990qx.css +0 -1
  100. package/dist/chunk-gt7n06ef.js +0 -1
  101. package/dist/chunk-n7pga5x3.js +0 -80
  102. /package/workspace/.claude/skills/moi-workspace/{DESIGN.md → references/DESIGN.md} +0 -0
  103. /package/workspace/.claude/skills/moi-workspace/{SCRATCHPAD.md → references/SCRATCHPAD.md} +0 -0
@@ -12,6 +12,12 @@ gateways. Protocol-3 gateways (≤ 2026.5.x) reject the handshake with
12
12
  are detect-and-surface only (`compat.ts` → `classifyGatewayError`), never
13
13
  silently degraded into empty lists.
14
14
 
15
+ Claims here are only as good as their last capture. §6 was rewritten against
16
+ live 2026.7.1 traffic (`ollama-cloud/glm-5.2:cloud`, `openai/gpt-5.5`,
17
+ `claude-cli/claude-sonnet-5`), transcribed into `wire-replay.test.ts`. Much of
18
+ what this file used to say about "backend-specific" frame behavior was one
19
+ capture on one config generalized too far — record a run before trusting it.
20
+
15
21
  ## 1. What OpenClaw is
16
22
 
17
23
  A personal multi-channel AI assistant that runs on your own machine. The
@@ -148,8 +154,8 @@ first frame must be a `connect` request. On success the response payload is
148
154
  `advertise:false` (`sessions.get`, `sessions.resolve`, `sessions.usage*`) are
149
155
  omitted yet fully callable — both live gateways omit `sessions.get` from
150
156
  `features.methods` and still answer it (verified live against 2026.7.1 /
151
- 2026.6.33). Treat the list as advisory: gate optional niceties on it, never an
152
- essential call (`compat.ts → advertisesMethod`).
157
+ 2026.6.33). Absence proves nothing, so nothing in moi gates on the list; it is
158
+ carried for `/status` and for diagnosing a version mismatch.
153
159
 
154
160
  Rule for params in the other direction: gateways validate with
155
161
  `additionalProperties: false` and hard-reject unknown fields, so never send a
@@ -233,15 +239,21 @@ sendOpenClawMessageImpl`) and marks it applied on the record so
233
239
  `applySessionSettings` skips the model patch. Note the asymmetry that decides
234
240
  what may ride along on create:
235
241
 
236
- | create param | 2026.6.x | 2026.7.x |
237
- | --------------- | -------- | -------- |
238
- | `model` | yes | yes |
239
- | `thinkingLevel` | **no** | yes |
240
-
241
- Both lines validate create with `additionalProperties: false`, so passing
242
- `thinkingLevel` there would hard-reject **every new chat** on 2026.6.x. Effort
243
- stays a patch — it is session-scoped, writes no config, and so cannot supersede
244
- a run. Only the model ever needed moving.
242
+ `sessions.create` takes `model` on both lines. It does **not** take
243
+ `thinkingLevel` on either — re-checked live on 2026.7.1, which answers
244
+ `invalid sessions.create params: at root: unexpected property 'thinkingLevel'`
245
+ (an earlier revision of this file recorded it as 2026.7-only, which was wrong).
246
+ Create validates with `additionalProperties: false`, so passing it would
247
+ hard-reject every new chat. Effort stays a patch — it is session-scoped, writes
248
+ no config, and so cannot supersede a run.
249
+
250
+ **Scope of the race.** Re-tested on the pinned 2026.7.1: `sessions.patch
251
+ { model }` immediately followed by `sessions.send` completed normally, no
252
+ `chat.dispatch-error`. So this is a 2026.7.2-beta.x regression, not a property
253
+ of every line. moi keeps carrying the model in `sessions.create` anyway — it
254
+ costs nothing, the model belongs to the session from the start, and it is one
255
+ round-trip fewer on a new chat — but the workaround is for the NEXT line, not
256
+ this one.
245
257
 
246
258
  **Thinking levels are per model, not gateway-global** (an earlier version of
247
259
  this doc claimed otherwise and moi shipped one static list because of it).
@@ -361,15 +373,55 @@ content blocks), `deltaText` just the increment:
361
373
  ```
362
374
 
363
375
  **`session.message`** — durable transcript rows, pushed as they commit. The
364
- `message` carries `__openclaw` meta (see §7). Rows without `__openclaw.id`
365
- are transient pre-envelope echoes — skip them; the durable row follows
366
- seconds later. **`toolResult` rows DO stream here** on both lines (an earlier
367
- version of this doc claimed they didn't); `session.tool` additionally carries
368
- the same output live, and the run-end `sessions.get` reconcile is now just
369
- the safety net.
376
+ `message` carries `__openclaw` meta (see §7), including **`seq` — the row's
377
+ position in the transcript**, mirrored as a top-level `messageSeq`. That number
378
+ is the only ordering authority: the gateway serializes its broadcasts behind a
379
+ promise queue (`server-session-events.ts` → `createTranscriptUpdateBroadcastHandler`,
380
+ "Preserve transcript update order even when counting messages requires an async
381
+ read"), but a frame can still be lost to a dropped socket and arrive later via
382
+ the reconcile. moi carries `seq` onto `Turn.seq`, and `lib/format.ts`
383
+ `applyEvent` places a new turn by it, so a late row lands where it belongs
384
+ rather than after the reply it preceded.
385
+
386
+ Rows without `__openclaw.id` are transient pre-envelope echoes — skip them; the
387
+ durable row follows.
388
+
389
+ Two things about this stream are easy to get wrong, and both were (verified
390
+ live on 2026.7.1 against `ollama-cloud/glm-5.2:cloud` and `openai/gpt-5.5`,
391
+ frame orders transcribed into `wire-replay.test.ts`):
392
+
393
+ - **`toolResult` rows do NOT stream.** In every capture the transcript ends up
394
+ with `user(1) · assistant(2) · toolResult(3) · assistant(4)` and the frames
395
+ delivered are seq 1, 2 and 4 — never 3. A tool's output reaches us live only
396
+ on the tool stream below; the run-end `sessions.get` reconcile is the
397
+ backstop, not a nicety.
398
+ - **A row can grow after it streams.** When a model fans out several calls at
399
+ once, the assistant row is pushed as text and its `toolCall` blocks are
400
+ attached afterwards, with no second frame. The live view therefore has a row
401
+ the transcript disagrees with, which is why the reconcile refreshes rows whose
402
+ content changed instead of only adopting ids it has never seen.
403
+
404
+ **`session.tool` and `agent`/`tool` are the same payload, split by audience —
405
+ not by backend.** This is the single most important fact about this stream, and
406
+ believing otherwise is what produced every duplicate-card bug this harness has
407
+ shipped. From `server-chat.ts`: the gateway sends `agent`/`tool` to the
408
+ connections registered as run-scoped tool recipients — the connection that
409
+ issued `sessions.send` — and mirrors the identical payload as `session.tool` to
410
+ every _other_ session subscriber, `excludeConnIds(sessionEventSubscribers,
411
+ runToolRecipients)`. The two audiences are disjoint by construction.
412
+
413
+ Demonstrated directly: two connections, same gateway, same run, one sends and
414
+ one only subscribes.
415
+
416
+ ```
417
+ sender : agent/tool:start, agent/tool:update, agent/tool:result
418
+ observer: session.tool:start, session.tool:update, session.tool:result
419
+ ```
370
420
 
371
- **`session.tool`** — live tool state, `data.phase` `start`/`update`/`result`,
372
- with the **full output inline on both lines**:
421
+ So moi sees `agent`/`tool` for runs it starts and `session.tool` for everything
422
+ else — a channel message, a cron firing, another client, or a run already in
423
+ flight when it attached. `session.ts` routes both into one `handleToolFrame`.
424
+ Frame shape (`data.phase` `start`/`update`/`result`, full output inline):
373
425
 
374
426
  ```jsonc
375
427
  {
@@ -379,11 +431,11 @@ with the **full output inline on both lines**:
379
431
  "data": {
380
432
  "phase": "result", // start: name/toolCallId/args · update: +partialResult
381
433
  "name": "exec",
382
- "toolCallId": "toolu_01…",
434
+ "toolCallId": "call_y42lj8xv",
383
435
  "isError": false,
384
436
  "result": {
385
- "content": [{ "type": "text", "text": "8" }],
386
- "details": { "status": "completed", "exitCode": 0, "durationMs": 255, "cwd": "/…" }
437
+ "content": [{ "type": "text", "text": "hello" }],
438
+ "details": { "status": "completed", "exitCode": 0, "durationMs": 228, "cwd": "/…" }
387
439
  }
388
440
  },
389
441
  "session": {
@@ -398,77 +450,84 @@ with the **full output inline on both lines**:
398
450
  start|update|end, kind, status, name, toolCallId }`), `command_output`
399
451
  (`{ output, phase: delta|end, exitCode?, durationMs?, cwd? }`), `lifecycle`
400
452
  (phases `start` → `finishing` `{ stopReason, aborted }` → `end`, or `error`
401
- `{ error }`).
402
-
403
- **codex-app-server tool output is run-end only.** On the codex backend
404
- (OpenAI models — the `agent`/`tool` + `codex_app_server.*` streams, not
405
- `session.tool`; `codex_app_server.item` frames are present and no
406
- `command_output` frames are), the live `agent`/`tool` `phase:'result'` frame
407
- carries only `{ status, exitCode, durationMs }` — **never the stdout**.
408
- Verified on the wire (result frame at t≈16.2s has no `content`; the command's
409
- output first appears in the run-end `session.message` `toolResult` at t≈20.0s)
410
- and in the plugin: `@openclaw/codex` `itemToolResult(commandExecution)`
411
- returns exactly those three fields. A turn's assistant/`toolCall`/`toolResult`
412
- rows all commit together when the turn ends, so the durable `toolResult` (the
413
- only frame that carries stdout **with** a `toolCallId`) is run-end-gated. The
414
- one live-stdout path — the plugin's `handleOutputDelta`/`emitToolResultOutput`
415
- → `onToolResult` — is gated behind the agent's `verboseLevel:'full'` and
416
- arrives as formatted channel-progress text with no `toolCallId`, so it can't
417
- attach to a card. Net: moi renders a codex tool running and flips it to
418
- success/error (from `isError`/exitCode) live at the result frame, but the
419
- **output body only fills when the run ends**. This is a backend property, not
420
- a moi gap — `session.tool` (Anthropic) carries output live, which is why the
421
- two backends feel different.
422
-
423
- **Live tool synthesis is codex-only.** Because codex batches its durable rows
424
- at run end, tools would otherwise pop in all at once after the streamed text,
425
- so moi synthesizes an ephemeral `livetool:<toolCallId>` turn from the
426
- `agent`/`tool` `start` frame and merges the durable owner onto it by re-id
427
- (`session.ts` → `emitLiveToolTurn`/`emitTurn`). This is gated on a
428
- `codex_app_server.*` frame having been seen this session (`rec.codexBackend`).
429
- Native-loop providers (Anthropic, **ollama** — e.g. deepseek-v4-flash) are NOT
430
- gated in: their durable rows arrive during the run, so `session.tool` +
431
- `reemitToolCallOwners` already render tools live, and their `start`-frame
432
- `toolCallId` need not match the `result`/durable id (ollama uses a provisional
433
- start id, a final result id) — synthesizing there stranded the live card as a
434
- permanent duplicate (`○` stuck running beside the durable `●`), and broadcast
435
- turns can't be retracted (`applyEvent` only upserts by id). So synthesis stays
436
- off unless the positive codex signal fires.
453
+ `{ error }`, plus `fallback_step` when a model chain retries).
454
+
455
+ ### Who owns a tool card
456
+
457
+ The durable owner row and the tool `start` frame race, and which wins decides
458
+ what renders. Measured on both providers, single call:
459
+
460
+ ```
461
+ 11891 session.message assistant seq=2 blocks=toolCall ← owner commits first
462
+ 11895 agent/tool phase=start call_y42lj8xv ← 4ms later
463
+ 11936 agent/tool phase=result call_y42lj8xv
464
+ 13638 session.message assistant seq=4 blocks=text
465
+ ```
466
+
467
+ and the same run with three calls fanned out of one row:
468
+
469
+ ```
470
+ 30822 session.message assistant seq=2 blocks=text ← no toolCall blocks
471
+ 30827 agent/tool phase=start call_d88i21w1 ← the only evidence
472
+ 30831 agent/tool phase=start call_0f2nwkab these calls exist
473
+ 30835 agent/tool phase=start call_p7i1myi5
474
+ 34796 session.message assistant seq=6 blocks=text
475
+ ```
476
+
477
+ So the rule is a question about the run, not about the backend: **does a
478
+ durable row own this call yet?** If yes, that row renders the card and the
479
+ frames only fill in its state. If no, the frame gets a card of its own
480
+ (`livetool:<toolCallId>`), placed just past the last durable row ingested, and
481
+ it keeps that call for the rest of the session — durable rows that later grow
482
+ the same block suppress it (adapter `omitToolCallIds`).
483
+
484
+ Ownership is decided once, at creation: `applyEvent` upserts by id and can never
485
+ retract, so a card that changes identity mid-run is a duplicate on screen
486
+ forever. Getting this wrong is what made every single-tool run render twice.
487
+
488
+ Tool ids were stable across `start`/`update`/`result`/durable in every capture,
489
+ on both providers.
490
+
491
+ **Run failures are reported on three frames.** A dying run says why on `chat`
492
+ `state:'error'` (`errorMessage`), on `agent`/`lifecycle` `phase:'error'`
493
+ (`data.error`), and as a bare `sessions.changed phase:'error'` with no text at
494
+ all — with three wordings (the raw reason, then a wrapped "⚠️ Agent failed
495
+ before reply: … Logs: openclaw logs --follow"). `reportRunError` takes the
496
+ first with text. The error rides on `chat`, which moi otherwise ignores when
497
+ token streaming is off, so failures are surfaced regardless of that toggle.
437
498
 
438
499
  **Thinking blocks: who actually emits them.** The wire shape exists and moi
439
500
  renders it — durable rows carry `{ type: 'thinking', thinking,
440
- thinkingSignature }` and `adapter.ts` maps it to a `reasoning` part. What
441
- varies is whether a backend ever produces one. Measured live (2026.7.1-2, one
442
- send per backend, full frame capture):
443
-
444
- | backend (`agentRuntime`) | reasoning on the wire | text? |
445
- | ---------------------------------- | --------------------------------------------------------------------------------------------------------- | ----- |
446
- | codex app-server (`codex`) | `agent`/item `kind:'analysis' title:'Reasoning'` start→end, plus `codex_app_server.item type:'reasoning'` | no |
447
- | claude CLI (`claude-cli`) | `agent`/thinking `{ progressTokens: 50 }` | no |
448
- | native loop (`auto`, ollama) | nothing — the model writes its reasoning as plain text | n/a |
449
- | `openai-codex` responses transport | durable `thinking` blocks with full text | YES |
450
-
451
- Only the last one delivers text, and it is the path the current default config
452
- no longer takes: OpenAI models resolve to `agentRuntime: codex` (implicitly, or
453
- pinned per model in `agents.defaults.models`), which routes through the codex
454
- app-server. Its `appendCodexAcpConfigOverrides` forwards
455
- `model_reasoning_effort` but never `model_reasoning_summary`, and its item
456
- frames carry no payload; the plugin's one text-bearing reasoning path
457
- (`onReasoningStream`) is channel-progress formatting with no item id, so it
458
- can't attach to a row. Selecting `openai-codex/<model>` directly is blocked by
459
- the `agents.defaults.models` allowlist unless the user adds that ref.
460
-
461
- Setting `reasoningLevel` (§5) does not change any of the three "no" rows —
462
- verified with `on` and `stream`, each paired with `thinkingLevel: high` so
463
- `canShowReasoning` held. It is still set, because it is the documented gate and
464
- the one path that does carry text needs it.
465
-
466
- Given that, moi renders what the codex backend _does_ report: `session.ts →
467
- handleReasoningItemFrame` turns the analysis item into a textless
468
- `{ type: 'reasoning', text: '', redacted: true, durationMs }` part, so a codex
469
- run shows "Thinking" → "Thought for 1.1s" instead of a silent gap before the
470
- first token. Like the live tool cards it is not durable — nothing in the
471
- transcript backs it, so a cold reload drops the row.
501
+ thinkingSignature }` and `adapter.ts` maps it to a `reasoning` part. What varies
502
+ is whether a model produces one at all, and this varies by MODEL and by the
503
+ config it runs under, not by a fixed backend taxonomy. Measured on 2026.7.1
504
+ with the default config:
505
+
506
+ | model | reasoning on the wire | text? |
507
+ | ---------------------------- | ---------------------------------------------------------- | ----- |
508
+ | `openai/gpt-5.5` | `agent`/`thinking` deltas, then a durable `thinking` block | YES |
509
+ | `ollama-cloud/glm-5.2:cloud` | nothing — the model writes its reasoning as plain text | n/a |
510
+
511
+ An earlier revision of this file claimed OpenAI models route through a codex
512
+ app-server that never carries reasoning text. That is not what the default
513
+ config does on 2026.7.1: `openai/gpt-5.5` streams the words on `agent`/`thinking`
514
+ and commits them durably, and no `codex_app_server.*` frame appears anywhere in
515
+ the capture. (`models status` reporting "openai via codex" is about which auth
516
+ store the credential comes from, not which runtime serves the turn.) Treat
517
+ "which runtime is behind this model" as a config question, not something to
518
+ infer from frames — and never gate rendering on the answer.
519
+
520
+ `reasoningLevel` (§5) stays set whenever the picked effort is not `off`: it is
521
+ the gateway's documented gate (`reasoningMode = reasoningLevel ?? 'off'`,
522
+ further gated on `canShowReasoning = thinkingLevel !== 'off'`), and a model that
523
+ can surface reasoning needs it.
524
+
525
+ Some runtimes report reasoning only as an `agent`/`item` frame of
526
+ `kind:'analysis'` — presence and timing, no text. `session.ts →
527
+ handleReasoningItemFrame` turns that into a textless `{ type: 'reasoning',
528
+ text: '', redacted: true, durationMs }` part, so such a run shows "Thinking" →
529
+ "Thought for 1.1s" instead of a silent gap. Like the live tool cards it is not
530
+ durable — nothing in the transcript backs it, so a cold reload drops the row.
472
531
 
473
532
  **`task`** — subagent runs (2026.7.x; the event family is new there):
474
533
 
@@ -494,6 +553,34 @@ completed?, ts }`.
494
553
  health blob (`eventLoop`, `plugins`, `channels`, `sessions`); useful for
495
554
  liveness, ignored otherwise. `tick` is the heartbeat.
496
555
 
556
+ ### Tool vocabulary is per runtime
557
+
558
+ One agent's tools change name and argument shape depending on which runtime
559
+ serves the model, and all of them arrive as `provider: 'openclaw'`. Captured on
560
+ 2026.7.1:
561
+
562
+ | runtime | shell | edit | read |
563
+ | -------------------------- | ----------------------------- | --------------------------------------------- | -------------------------- |
564
+ | built-in loop | `exec` / `bash` `{ command }` | `edit` `{ path }` | `read` `{ path }` |
565
+ | codex (`extensions/codex`) | `bash` `{ command, cwd }` | `apply_patch` `{ changes: [{ path, kind }] }` | none — reads run as `bash` |
566
+ | `claude-cli` | `Bash` `{ command }` | `Edit` `{ file_path }` | `Read` `{ file_path }` |
567
+
568
+ So there is no Read card on a codex-backed run: the model reads by shelling out
569
+ (`bash -lc "sed -n '1,120p' notes.txt"`), and that is what the transcript
570
+ records. Nothing is being dropped.
571
+
572
+ The client's tool-card labels and briefs live in
573
+ `client/features/chat/tool-group/format.ts`; the OpenClaw path falls back to the
574
+ Claude Code vocabulary for the `claude-cli` case.
575
+
576
+ **`agent`/`item` frames are not a second source of tool cards.** They carry
577
+ `itemId`, `kind`, `title`, `status`, `summary`, `meta` — and **no `toolCallId`
578
+ and no `args`** (`AgentItemEventData` in `src/infra/agent-activity-events.ts`,
579
+ confirmed on the wire: every `command`/`patch` item frame arrives with
580
+ `toolCallId` absent). Every one of them is paired with a `tool` frame that has
581
+ both, a few milliseconds apart. moi renders from the `tool` frames and reads
582
+ item frames only for the textless `analysis` reasoning span.
583
+
497
584
  ### `sessions.changed`
498
585
 
499
586
  Two flavors share the event name (both lines, verified live):
@@ -615,18 +702,33 @@ subpath import wins over rolling a minimal client.
615
702
  replay, wire tap), config-path resolution, one-shot client for discovery,
616
703
  and the last connect outcome for `/status` (`getOpenClawGatewayStatus`).
617
704
  - `compat.ts` — protocol-4 tolerance layer: `parseHelloOk`,
618
- `advertisesMethod`, `classifyGatewayError`, `messageIdempotencyKey`. Read
619
- its header before sending any new param to the gateway.
705
+ `classifyGatewayError`, `messageIdempotencyKey`. Read its header before
706
+ sending any new param to the gateway.
620
707
  - `thinking.ts` — per-model thinking menus learned from session rows, plus the
621
708
  relearn-from-rejection path. The effort picker reads it (§5).
622
709
  - `discovery.ts` — agents → workspace candidates, models catalog, transcript
623
710
  seeds (2 round-trips: `agents.list` + `sessions.list`, then per-agent
624
711
  `agents.files.get(IDENTITY.md)`).
625
712
  - `session.ts` — live session records: `sessions.get` seed, `session.message`
626
- ingest, `chat` → StreamPreview, `session.tool` → live tool cards,
627
- `sessions.patch` before sends, echo rendezvous, run-end reconcile.
713
+ ingest, `chat` → StreamPreview, tool frames → tool cards, `sessions.patch`
714
+ before sends, echo rendezvous, run-end reconcile, run-error reporting.
628
715
  - `adapter.ts` — gateway rows/messages → moi turns; `strip.ts` — mirror of
629
716
  upstream `strip-inbound-meta` (re-diff on every bump, see its header).
717
+ - `wire-replay.test.ts` — the frame orders a live gateway produces, replayed
718
+ through the real session code. **Record a run before changing how frames are
719
+ interpreted** (`docs/openclaw-sandbox.md` shows how), then transcribe what it
720
+ shows into a scenario there. Every ordering and duplication bug this harness
721
+ has shipped came from reasoning about frame order in the abstract; a
722
+ recording is the only thing that argues back.
723
+
724
+ Two rules the modules above depend on, both learned the hard way:
725
+
726
+ 1. **Never branch on "which backend is this".** The frame families that look
727
+ backend-specific are audience-specific (§6), and which runtime serves a
728
+ model is a config choice. Ask about the state you actually have — does a
729
+ durable row own this call? — not about who is on the other end.
730
+ 2. **A broadcast turn can be upserted but never retracted.** Any id a turn is
731
+ published under is permanent. Decide identity once, at creation.
630
732
 
631
733
  ## 12. Commands worth knowing
632
734
 
@@ -1,21 +1,13 @@
1
1
  // Map OpenClaw gateway shapes into our agent-agnostic display format.
2
2
  //
3
- // OpenClaw stores one `OpenClawMessage` per role-turn: `user` (the prompt,
4
- // with AI-facing envelopes prepended — see `openclaw-strip.ts`), `assistant`
5
- // (text/reasoning/toolCall blocks + model metadata), and `toolResult` (one
6
- // per executed tool call, keyed by `toolCallId`). We turn that into:
7
- // - one Turn per user/assistant message, with tool-call parts rendered
8
- // inline on the assistant turn,
9
- // - no separate turn for toolResult rows — results are folded into the
10
- // assistant's matching tool-call part so the UI shows them as expandable
11
- // output under the call.
3
+ // OpenClaw stores one message per role-turn: `user` (the prompt, with AI-facing
4
+ // envelopes prepended — see `strip.ts`), `assistant` (text/thinking/toolCall
5
+ // blocks plus model metadata), and `toolResult` (one per executed call, keyed
6
+ // by `toolCallId`). Each user/assistant message becomes one Turn; toolResult
7
+ // rows get no turn of their own — they fold into the matching tool-call part.
12
8
  //
13
- // Two callers:
14
- // - `toStreamEvents(detail)` — static path used for cold-load (REST endpoint)
15
- // and tests.
16
- // - `messageToTurnLive(msg, sessionKey, idx, results)` — incremental path used
17
- // by the live session adapter (`openclaw-session.ts`) when a single
18
- // `session.message` frame arrives.
9
+ // `toStreamEvents` is the cold path (REST replay); `messageToTurn` is the
10
+ // per-frame path the live session uses.
19
11
  import type { Part, StreamEvent, ToolCall, ToolState, Turn, TurnMeta } from '@/lib/format'
20
12
  import type { SessionInfo } from '@/lib/types'
21
13
 
@@ -79,15 +71,12 @@ export type ToolResultInfo = {
79
71
  running?: boolean
80
72
  }
81
73
 
82
- // Pull a readable `output` string out of a `toolResult` message. The tool
83
- // result wire shape has drifted across OpenClaw lines (verified live):
84
- // - 2026.7.1 — `content: [{ type: 'text', text: 'hello' }]` (flat text)
85
- // - 2026.7.2+ — the exec sandbox nests the result as `[{ type: 'text',
86
- // text: '<json>' }]` or wraps it in a `{ type: 'toolResult', content: […] }`
87
- // block (which rendered as a bare `[toolResult]` placeholder before this).
88
- // So recurse: text/image blocks resolve directly, any other block that
89
- // carries its own `content` array or `text`/`output` string is unwrapped one
90
- // level, and only a truly opaque block falls back to `[type]`.
74
+ // Pull a readable `output` string out of a `toolResult` message. Rows are flat
75
+ // in practice (`content: [{ type: 'text', text: 'hello' }]`), but upstream
76
+ // types these blocks as an open `Record<string, unknown>` and says outright
77
+ // that provider SDKs spell them differently (`src/chat/tool-content.ts`), so a
78
+ // block carrying its own `content`/`text`/`output` is unwrapped one level
79
+ // rather than rendered as a bare `[toolResult]` placeholder.
91
80
  export function flattenToolResultContent(content: OpenClawMessage['content'], depth = 0): string {
92
81
  if (typeof content === 'string') return content
93
82
  if (!Array.isArray(content)) return ''
@@ -146,7 +135,8 @@ function collectToolResults(messages: OpenClawMessage[]): Map<string, ToolResult
146
135
  function blockToPart(
147
136
  block: OpenClawContentBlock,
148
137
  role: OpenClawMessage['role'],
149
- results: Map<string, ToolResultInfo>
138
+ results: Map<string, ToolResultInfo>,
139
+ omitToolCallIds?: ReadonlySet<string>
150
140
  ): Part | null {
151
141
  switch (block.type) {
152
142
  case 'text': {
@@ -158,39 +148,21 @@ function blockToPart(
158
148
  if (!text) return null
159
149
  return { type: 'text', text }
160
150
  }
161
- case 'thinking':
162
- case 'reasoning': {
163
- // Field drift across OpenClaw lines: 2026.7.1 ships `{ type: 'thinking',
164
- // thinking, thinkingSignature }`; newer lines emit `reasoning` and/or
165
- // carry the text in `text`. Read whichever is present so the Thought row
166
- // never silently vanishes.
167
- const b = block as {
168
- thinking?: unknown
169
- reasoning?: unknown
170
- text?: unknown
171
- thinkingSignature?: unknown
172
- signature?: unknown
173
- }
174
- const text =
175
- (typeof b.thinking === 'string' && b.thinking) ||
176
- (typeof b.reasoning === 'string' && b.reasoning) ||
177
- (typeof b.text === 'string' && b.text) ||
178
- ''
179
- if (!text) return null
180
- const sig =
181
- (typeof b.thinkingSignature === 'string' && b.thinkingSignature) ||
182
- (typeof b.signature === 'string' && b.signature) ||
183
- undefined
184
- return {
185
- type: 'reasoning',
186
- text,
187
- ...(sig ? { signature: sig } : {})
188
- }
151
+ case 'thinking': {
152
+ const b = block as { thinking?: unknown; thinkingSignature?: unknown }
153
+ if (typeof b.thinking !== 'string' || !b.thinking) return null
154
+ const sig = typeof b.thinkingSignature === 'string' ? b.thinkingSignature : undefined
155
+ return { type: 'reasoning', text: b.thinking, ...(sig ? { signature: sig } : {}) }
189
156
  }
190
157
  case 'toolCall': {
191
158
  const id = (block as { id?: unknown }).id
192
159
  const name = (block as { name?: unknown }).name
193
160
  if (typeof id !== 'string' || typeof name !== 'string') return null
161
+ // This call is already on screen as its own live card (the live session
162
+ // rendered it before this row carried the block). Rendering it here too
163
+ // would show the same call twice, and a broadcast card can't be
164
+ // retracted — so the live card keeps ownership for the session's life.
165
+ if (omitToolCallIds?.has(id)) return null
194
166
  const result = results.get(id)
195
167
  let state: ToolState = 'pending'
196
168
  if (result) state = result.running ? 'running' : result.isError ? 'error' : 'success'
@@ -243,7 +215,8 @@ export function messageToTurn(
243
215
  msg: OpenClawMessage,
244
216
  sessionKey: string,
245
217
  idx: number,
246
- results: Map<string, ToolResultInfo>
218
+ results: Map<string, ToolResultInfo>,
219
+ omitToolCallIds?: ReadonlySet<string>
247
220
  ): Turn | null {
248
221
  if (msg.role !== 'user' && msg.role !== 'assistant') return null
249
222
  const blocks: OpenClawContentBlock[] = Array.isArray(msg.content)
@@ -252,7 +225,7 @@ export function messageToTurn(
252
225
  ? [{ type: 'text', text: msg.content }]
253
226
  : []
254
227
  const parts = blocks
255
- .map(b => blockToPart(b, msg.role, results))
228
+ .map(b => blockToPart(b, msg.role, results, omitToolCallIds))
256
229
  .filter((p): p is Part => p !== null)
257
230
  if (parts.length === 0) return null
258
231
  const ocId = msg.__openclaw?.id
@@ -11,10 +11,10 @@
11
11
  // `additionalProperties: false` and reject unknown fields outright — never
12
12
  // send a param that only newer schemas know without gating on `GatewayInfo`.
13
13
 
14
- // What the gateway announced in `hello-ok`. `methods`/`events` are advisory:
15
- // 2026.6.33 answers `sessions.get` while omitting it from `features.methods`,
16
- // so absence must never disable an essential call — use `advertisesMethod`
17
- // only to unlock optional niceties.
14
+ // What the gateway announced in `hello-ok`. `methods`/`events` are advisory
15
+ // and UNDER-REPORT: 2026.6.33 answers `sessions.get` while omitting it from
16
+ // `features.methods`. Absence proves nothing, so nothing gates on this — the
17
+ // sets are carried for `/status` and for debugging a version mismatch.
18
18
  export type GatewayInfo = {
19
19
  protocol?: number
20
20
  serverVersion?: string
@@ -40,10 +40,6 @@ export function parseHelloOk(hello: unknown): GatewayInfo {
40
40
  }
41
41
  }
42
42
 
43
- export function advertisesMethod(info: GatewayInfo | null, method: string): boolean {
44
- return info?.methods.has(method) ?? false
45
- }
46
-
47
43
  export type GatewayFailureKind = 'protocol-mismatch' | 'auth' | 'unreachable' | 'unknown'
48
44
 
49
45
  export type GatewayFailure = {