moi-computer 0.8.1-next.0 → 0.9.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.
@@ -5,22 +5,20 @@ import { stripMoiContext } from '@/lib/moi-context'
5
5
  // The gateway prepends AI-facing envelopes to every user message before storing
6
6
  // it: a leading timestamp (`[Fri 2026-04-24 18:12 GMT+2] `), sentinel JSON
7
7
  // blocks like `Sender (untrusted metadata):`, delivery hints for the `message`
8
- // tool, chat-window context blocks, and (on ≤2026.4.x) a `[Bootstrap pending]`
9
- // preamble. These are useful for the model but must never surface in chat
10
- // bubbles.
8
+ // tool, and chat-window context blocks. These are useful for the model but must
9
+ // never surface in chat bubbles.
11
10
  //
12
11
  // Canonical source: `src/auto-reply/reply/strip-inbound-meta.ts` in the
13
12
  // `openclaw` npm package (bundled as `dist/strip-inbound-meta-*.js`; hint
14
13
  // strings in `dist/message-tool-delivery-hints-*.js`). Not re-exported on a
15
- // stable subpath, so we mirror it here. If you bump `openclaw`, diff those
16
- // files and keep this in sync. Last synced against 2026.7.1 (also compared to
17
- // the 2026.6.33 copy — identical except the chat-window block pass, which is
18
- // 2026.7.x-only but harmless on 6.x rows).
14
+ // stable subpath, so we mirror it here.
19
15
  //
20
- // The bootstrap-preamble pass is ours — it was injected by the ≤2026.4.x
21
- // system-prompt builder, not the inbound-meta path, so upstream's stripper
22
- // deliberately leaves it alone. 2026.6.x+ no longer emits the marker; the pass
23
- // stays for transcripts written by old gateways and is a no-op otherwise.
16
+ // You don't have to diff it by hand on a bump: `strip-parity.test.ts` loads the
17
+ // real implementation out of the pinned bundle and asserts this mirror agrees
18
+ // with it case for case. If that test starts failing after `bun install`,
19
+ // upstream moved and this file needs to follow. (It also compares clean against
20
+ // the 2026.6.33 copy — identical except the chat-window block pass, which is
21
+ // 2026.7.x-only but harmless on 6.x rows.)
24
22
 
25
23
  const LEADING_TIMESTAMP_PREFIX_RE = /^\[[A-Za-z]{3} \d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\] */
26
24
 
@@ -30,10 +28,7 @@ const INBOUND_META_SENTINELS = [
30
28
  'Conversation info (untrusted metadata):',
31
29
  'Sender (untrusted metadata):',
32
30
  'Thread starter (untrusted, for context):',
33
- // 2026.6.x+ wording, and the ≤2026.5.x one it replaced — old transcripts
34
- // replay through `sessions.get`, so both must keep stripping.
35
31
  'Reply target of current user message (untrusted, for context):',
36
- 'Replied message (untrusted, for context):',
37
32
  'Forwarded message context (untrusted metadata):',
38
33
  CHAT_HISTORY_SENTINEL
39
34
  ]
@@ -175,25 +170,6 @@ export function stripInboundMetadata(text: string): string {
175
170
  .replace(LEADING_TIMESTAMP_PREFIX_RE, '')
176
171
  }
177
172
 
178
- // Removes a leading `[Bootstrap pending]` header plus every following
179
- // non-empty line up to the first blank line. Upstream produced a fixed 6-line
180
- // preamble on ≤2026.4.x (see `buildFullBootstrapPromptLines`), but we key off
181
- // structure rather than exact text so minor wording changes don't leak through.
182
- export function stripBootstrapPreamble(text: string): string {
183
- if (!text || !text.startsWith('[Bootstrap pending]')) return text
184
- const lines = text.split('\n')
185
- let i = 0
186
- while (i < lines.length && lines[i] !== '') i += 1
187
- while (i < lines.length && lines[i] === '') i += 1
188
- return lines.slice(i).join('\n')
189
- }
190
-
191
- // moi-side (not part of the upstream mirror above): the spawn tool wraps a
192
- // subagent's first user message as
193
- // "[Subagent Context] <paragraph>\n\n[Subagent Task]\n\n<task>\n\nBegin. …"
194
- // — surface the task itself in titles/previews/transcripts. Truncated
195
- // previews/derived titles can cut before the task marker; fall back to a
196
- // plain label rather than leaking the envelope.
197
173
  export function stripSubagentEnvelope(text: string): string {
198
174
  if (!text.startsWith('[Subagent Context]')) return text
199
175
  const taskAt = text.indexOf('[Subagent Task]')
@@ -204,5 +180,5 @@ export function stripSubagentEnvelope(text: string): string {
204
180
  }
205
181
 
206
182
  export function stripUserMessageMetadata(text: string): string {
207
- return stripSubagentEnvelope(stripMoiContext(stripInboundMetadata(stripBootstrapPreamble(text))))
183
+ return stripSubagentEnvelope(stripMoiContext(stripInboundMetadata(text)))
208
184
  }
@@ -95,60 +95,12 @@ export function recordOpenClawThinkingProfiles(rows: OpenClawThinkingRow[]): voi
95
95
  for (const row of rows) recordOpenClawThinkingProfile(row)
96
96
  }
97
97
 
98
- // The last segment of a ref — the model id without its provider.
99
- function openClawModelId(ref: string): string {
100
- const slash = ref.lastIndexOf('/')
101
- return slash === -1 ? ref : ref.slice(slash + 1)
102
- }
103
-
104
- // Providers that are agent RUNTIMES rather than model catalogs. A session
105
- // configured with `agentRuntime: { id: 'claude-cli' }` reports the runtime here,
106
- // so `anthropic/claude-opus-5` (the catalog ref, and what the picker sends)
107
- // and `claude-cli/claude-opus-5` (what the row reports back) name one model.
108
- const OPENCLAW_RUNTIME_PROVIDERS = new Set(['claude-cli'])
109
-
110
- function openClawModelProvider(ref: string): string {
111
- const slash = ref.lastIndexOf('/')
112
- return slash === -1 ? '' : ref.slice(0, slash)
113
- }
114
-
115
- // Do two refs name the same model? Used by the applied-model cache, which
116
- // compares the picker's catalog ref against the ref the wire reports. Only a
117
- // runtime alias collapses the provider — `ollama/kimi-k3:cloud` and
118
- // `openai/kimi-k3:cloud` are genuinely different models and stay unequal, so a
119
- // switch between them still patches.
120
- export function openClawModelRefsEquivalent(a: string, b: string): boolean {
121
- if (a === b) return true
122
- if (openClawModelId(a) !== openClawModelId(b)) return false
123
- const [pa, pb] = [openClawModelProvider(a), openClawModelProvider(b)]
124
- return OPENCLAW_RUNTIME_PROVIDERS.has(pa) || OPENCLAW_RUNTIME_PROVIDERS.has(pb)
125
- }
126
-
127
- // A model served by a CLI backend reports the RUNTIME as its provider, not the
128
- // catalog one. A session started on `anthropic/claude-opus-5` (its
129
- // `models.list` ref, and what `sessions.patch {model}` takes) comes back on the
130
- // wire as `claude-cli/claude-opus-5` — verified live on 2026.7.2-beta.7, where
131
- // every model configured with `agentRuntime: { id: 'claude-cli' }` does this.
132
- // Keying only on the exact ref drops those menus on the floor and the picker
133
- // falls back to the four-level intersection, costing Opus 5 `minimal`,
134
- // `adaptive`, `xhigh` and `max`.
135
- //
136
- // So a miss retries on the bare model id — but only when exactly one recorded
137
- // provider carries it. `kimi-k3:cloud` genuinely exists under both `ollama` and
138
- // `openai` with different menus, and guessing between them would offer a level
139
- // the gateway rejects, which is the failure this module exists to prevent.
98
+ // A model's menu, or null when no session row has reported one yet (the picker
99
+ // then falls back to OPENCLAW_FALLBACK_THINKING_LEVELS). Keyed by the exact
100
+ // `provider/model` ref: `sessions.list` echoes back the provider of the ref
101
+ // that was patched, so what the picker sends is what the rows come back under.
140
102
  export function openClawThinkingProfile(modelRef: string): OpenClawThinkingProfile | null {
141
- const exact = profiles.get(modelRef)
142
- if (exact) return exact
143
-
144
- const id = openClawModelId(modelRef)
145
- let match: OpenClawThinkingProfile | null = null
146
- for (const [ref, profile] of profiles) {
147
- if (openClawModelId(ref) !== id) continue
148
- if (match) return null
149
- match = profile
150
- }
151
- return match
103
+ return profiles.get(modelRef) ?? null
152
104
  }
153
105
 
154
106
  export function hasOpenClawThinkingProfiles(): boolean {
package/server/service.ts CHANGED
@@ -21,7 +21,7 @@ import { copyFile, mkdir, readFile, rm, stat, truncate, writeFile } from 'node:f
21
21
  import { homedir, userInfo } from 'node:os'
22
22
  import { dirname, join } from 'node:path'
23
23
 
24
- import { CONTROL_PORT } from './constants'
24
+ import { CONTROL_URL } from './constants'
25
25
  import { DATA_DIR } from './data-dir'
26
26
  import { mergeSearchPaths } from './harness/shell-path'
27
27
  import { PACKAGE_ROOT } from './version'
@@ -357,7 +357,7 @@ export function queryServerInfo(timeoutMs = 1500): Promise<ServerInfo | null> {
357
357
  }
358
358
  let ws: WebSocket
359
359
  try {
360
- ws = new WebSocket(`ws://localhost:${CONTROL_PORT}`)
360
+ ws = new WebSocket(CONTROL_URL)
361
361
  } catch {
362
362
  settle(null)
363
363
  return
@@ -17,7 +17,7 @@ Workspace features/pages:
17
17
  - "Widgets" - small reusable full-stack components displayed on the widgets page (dashboard). For
18
18
  overview, quick info, status or quick actions.
19
19
  - "Scratchpad" - a shared low-fi canvas for prototyping, working on ideas together, visualising
20
- concepts. Read `SCRATCHPAD.md` before building on or modifying it.
20
+ concepts. Read `references/SCRATCHPAD.md` before building on or modifying it.
21
21
  - "Views" - full-stack embedded apps for bigger work, consume more space, live in their own tab.
22
22
 
23
23
  User can switch between these, but can access the chat (this conversation and other chats) from
@@ -139,7 +139,7 @@ For more options, commands, use `moi help`.
139
139
 
140
140
  Every applet — a **Widget** or a **View** — is a default-exported React component in
141
141
  `.moi/<type>/<name>.tsx`, optionally paired with a `<name>.server.ts`. `moi bundle` compiles each
142
- into a live module the browser loads (edits hot-reload). Read `DESIGN.md` first.
142
+ into a live module the browser loads (edits hot-reload). Read `references/DESIGN.md` first.
143
143
  Write normal React + Tailwind — below is only what's **moi-specific**.
144
144
 
145
145
  ## Anatomy
@@ -329,7 +329,7 @@ export const config = {
329
329
  Render **content only**: a plain `h-full w-full` region with no card chrome (`rounded-*`,
330
330
  `shadow-*`, or outer `border`) — the dashboard owns the shell, spacing, and elevation. It does not
331
331
  own the fill, so the widget must set its own opaque background.
332
- Changing `colSpan`/`rowSpan` needs `moi bundle --force`. See `DESIGN.md`.
332
+ Changing `colSpan`/`rowSpan` needs `moi bundle --force`. See `references/DESIGN.md`.
333
333
 
334
334
  Typical loop: check/`bun install` deps → write the applet → `moi bundle` → run any checks.
335
335
  After the final successful bundle and any checks, always make tab focus the final workspace action:
@@ -392,7 +392,7 @@ export const config = {
392
392
  ```
393
393
 
394
394
  The inverse of a widget: a view **owns its whole page** — its own `h-full w-full` layout, scrolling
395
- (`overflow-auto`), padding, and chrome. Build it to read like an app screen. See `DESIGN.md`.
395
+ (`overflow-auto`), padding, and chrome. Build it to read like an app screen. See `references/DESIGN.md`.
396
396
 
397
397
  # Keeping this skill current
398
398
 
@@ -401,9 +401,9 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
401
401
  - **You'll know** — `moi` commands warn you when this skill is behind.
402
402
  - **To update** — run `moi skill update`. Never mid-task: finish first, or do it at the end.
403
403
  - **Re-read after updating** — `moi skill update` rewrites `SKILL.md` and its companion docs
404
- (`DESIGN.md` and `SCRATCHPAD.md`) on disk, so the copy already in your context is stale. Re-read
404
+ (`references/DESIGN.md` and `references/SCRATCHPAD.md`) on disk, so the copy already in your context is stale. Re-read
405
405
  this `SKILL.md` before you rely on it again — don't act on the old version.
406
406
  - **Then** — if you updated, mention it.
407
407
 
408
408
  <!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
409
- <moi-skill version="0.11.0" />
409
+ <moi-skill version="0.12.0" />