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.
- package/client/features/chat/chat-frames.ts +4 -5
- package/client/features/chat/chat-send.ts +13 -2
- package/client/features/chat/chat-store.ts +1 -3
- package/client/features/chat/composer/ModelPicker.tsx +40 -41
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/group-turns.ts +1 -0
- package/client/features/chat/interleave-notices.ts +7 -11
- package/client/features/chat/tool-group/ToolCallGroup.tsx +1 -4
- package/client/features/chat/tool-group/format/codex.ts +4 -1
- package/client/features/chat/useChat.ts +5 -8
- package/dist/chunk-245wt82v.css +1 -0
- package/dist/{chunk-yc471zah.js → chunk-j7hh2ab4.js} +48 -48
- package/dist/{chunk-vwjeezeb.js → chunk-y8eyahwx.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/format.ts +6 -5
- package/lib/types.ts +5 -2
- package/package.json +1 -1
- package/server/api.ts +1 -1
- package/server/bundler/applet-css.ts +1 -106
- package/server/harness/README.md +28 -39
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +94 -45
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +31 -7
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +549 -136
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/web.ts +3 -0
- package/ui-components/alert-dialog.tsx +1 -1
- package/ui-components/alert.tsx +1 -1
- package/ui-components/avatar.tsx +1 -1
- package/ui-components/checkbox.tsx +2 -1
- package/ui-components/combobox.tsx +3 -1
- package/ui-components/field.tsx +1 -1
- package/ui-components/input-group.tsx +2 -2
- package/ui-components/radio-group.tsx +2 -1
- package/ui-components/switch.tsx +2 -1
- package/dist/chunk-6664vxpk.css +0 -1
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// their own lifecycle (`item/started` → `item/completed`), not raw
|
|
5
|
-
// tool_use/tool_result pairs. Each item becomes one Turn: `userMessage` a
|
|
6
|
-
// user turn, everything else an assistant turn; tool-shaped items carry a
|
|
7
|
-
// single `tool-call` part whose state tracks the item's `status`.
|
|
8
|
-
//
|
|
9
|
-
// Type shapes are hand-written against `codex app-server generate-ts`
|
|
10
|
-
// (CLI 0.144.5) and read defensively — see ./NOTES.md.
|
|
1
|
+
// Pure Codex wire → display mapping. A rendered item becomes a Turn or notice;
|
|
2
|
+
// tool items carry their native lifecycle through a tool-call part. The wire
|
|
3
|
+
// types are a defensive subset; see NOTES.md for maintenance.
|
|
11
4
|
import type {
|
|
12
5
|
Part,
|
|
13
6
|
StreamEvent,
|
|
@@ -18,7 +11,7 @@ import type {
|
|
|
18
11
|
Turn
|
|
19
12
|
} from '@/lib/format'
|
|
20
13
|
import { stripMoiContext, stripMoiContextLoose } from '@/lib/moi-context'
|
|
21
|
-
import type { Model, SessionInfo } from '@/lib/types'
|
|
14
|
+
import type { McpServer, Model, SessionInfo } from '@/lib/types'
|
|
22
15
|
|
|
23
16
|
import type { WorkspaceActivityPreview } from '../types'
|
|
24
17
|
|
|
@@ -66,7 +59,13 @@ export type CodexThreadItem = {
|
|
|
66
59
|
error?: { message?: string } | null
|
|
67
60
|
// webSearch
|
|
68
61
|
query?: string
|
|
69
|
-
action?: {
|
|
62
|
+
action?: {
|
|
63
|
+
type?: string
|
|
64
|
+
query?: string | null
|
|
65
|
+
queries?: (string | null)[] | null
|
|
66
|
+
url?: string | null
|
|
67
|
+
pattern?: string | null
|
|
68
|
+
} | null
|
|
70
69
|
// imageGeneration
|
|
71
70
|
revisedPrompt?: string | null
|
|
72
71
|
// collabAgentToolCall (tool reused from mcpToolCall above)
|
|
@@ -85,6 +84,8 @@ export type CodexTurn = {
|
|
|
85
84
|
status: string
|
|
86
85
|
error?: { message?: string; codexErrorInfo?: unknown } | null
|
|
87
86
|
durationMs?: number | null
|
|
87
|
+
startedAt?: number | null
|
|
88
|
+
completedAt?: number | null
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
export type CodexThread = {
|
|
@@ -94,7 +95,7 @@ export type CodexThread = {
|
|
|
94
95
|
createdAt?: number
|
|
95
96
|
updatedAt?: number
|
|
96
97
|
name?: string | null
|
|
97
|
-
status?: { type?: string }
|
|
98
|
+
status?: { type?: string; activeFlags?: string[] }
|
|
98
99
|
turns?: CodexTurn[]
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -111,10 +112,11 @@ export type CodexModel = {
|
|
|
111
112
|
hidden?: boolean
|
|
112
113
|
supportedReasoningEfforts?: { reasoningEffort: string; description?: string }[]
|
|
113
114
|
defaultReasoningEffort?: string
|
|
115
|
+
inputModalities?: string[]
|
|
114
116
|
isDefault?: boolean
|
|
115
117
|
serviceTiers?: { id: string; name: string; description: string }[]
|
|
116
118
|
defaultServiceTier?: string | null
|
|
117
|
-
//
|
|
119
|
+
// Deprecated by Codex; retained for catalogs without serviceTiers.
|
|
118
120
|
additionalSpeedTiers?: string[]
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -134,10 +136,7 @@ export function codexServiceTierForFastMode(
|
|
|
134
136
|
return fastMode ? CODEX_FAST_SERVICE_TIER : null
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
//
|
|
138
|
-
// the pre-0.135 fallback path that text carries the appended context envelope,
|
|
139
|
-
// so previews strip it like transcript turns do. Loose variant: previews are
|
|
140
|
-
// truncated snippets, so a mid-envelope cut must still strip.
|
|
139
|
+
// Legacy context can be cut mid-envelope in a thread/list preview.
|
|
141
140
|
function cleanPreview(preview: string | undefined): string {
|
|
142
141
|
return preview ? stripMoiContextLoose(preview).trim() : ''
|
|
143
142
|
}
|
|
@@ -186,8 +185,9 @@ export function codexModelToModel(m: CodexModel, configuredServiceTier?: string
|
|
|
186
185
|
const efforts = (m.supportedReasoningEfforts ?? []).map(e => e.reasoningEffort)
|
|
187
186
|
const displayName = m.displayName.replace(/^GPT-/, '').replaceAll('-', ' ')
|
|
188
187
|
const supportsFastMode =
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
m.serviceTiers !== undefined
|
|
189
|
+
? m.serviceTiers.some(tier => tier.id === CODEX_FAST_SERVICE_TIER)
|
|
190
|
+
: (m.additionalSpeedTiers ?? []).includes('fast')
|
|
191
191
|
// The effective user/project config governs omitted wire values. A null
|
|
192
192
|
// config value leaves the model catalog's default in charge.
|
|
193
193
|
const defaultServiceTier = configuredServiceTier ?? m.defaultServiceTier
|
|
@@ -195,14 +195,15 @@ export function codexModelToModel(m: CodexModel, configuredServiceTier?: string
|
|
|
195
195
|
value: m.id,
|
|
196
196
|
resolvedModel: m.model,
|
|
197
197
|
displayName,
|
|
198
|
-
//
|
|
199
|
-
// (the picker renders the first segment as the row label), so lead with
|
|
200
|
-
// the display name and let Codex's one-liner be the tagline.
|
|
198
|
+
// The picker uses the first " · " segment as its row label.
|
|
201
199
|
...(m.description
|
|
202
200
|
? { description: `${displayName} · ${m.description}` }
|
|
203
201
|
: { description: displayName }),
|
|
204
202
|
supportsEffort: efforts.length > 0,
|
|
205
203
|
...(efforts.length > 0 ? { supportedEffortLevels: efforts } : {}),
|
|
204
|
+
...(m.defaultReasoningEffort && efforts.includes(m.defaultReasoningEffort)
|
|
205
|
+
? { defaultEffort: m.defaultReasoningEffort }
|
|
206
|
+
: {}),
|
|
206
207
|
...(supportsFastMode
|
|
207
208
|
? {
|
|
208
209
|
supportsFastMode: true,
|
|
@@ -212,6 +213,55 @@ export function codexModelToModel(m: CodexModel, configuredServiceTier?: string
|
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
215
|
|
|
216
|
+
export type CodexConfig = {
|
|
217
|
+
model?: string
|
|
218
|
+
model_reasoning_effort?: string
|
|
219
|
+
service_tier?: string | null
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const mcpRuntimeStates = new Map<string, McpServer['status']>([
|
|
223
|
+
['connected', 'connected'],
|
|
224
|
+
['authenticationRequired', 'needs-auth'],
|
|
225
|
+
['failed', 'failed'],
|
|
226
|
+
['cancelled', 'failed'],
|
|
227
|
+
['disabled', 'disabled'],
|
|
228
|
+
['starting', 'pending'],
|
|
229
|
+
['notStarted', 'pending']
|
|
230
|
+
])
|
|
231
|
+
|
|
232
|
+
export function codexMcpServerToServer(server: {
|
|
233
|
+
name: string
|
|
234
|
+
authStatus?: string
|
|
235
|
+
runtimeStatus?: string | null
|
|
236
|
+
}): McpServer {
|
|
237
|
+
return {
|
|
238
|
+
name: server.name,
|
|
239
|
+
status:
|
|
240
|
+
mcpRuntimeStates.get(server.runtimeStatus ?? '') ??
|
|
241
|
+
(server.authStatus === 'notLoggedIn' ? 'needs-auth' : 'pending')
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function codexModelsToModels(models: CodexModel[], config: CodexConfig): Model[] {
|
|
246
|
+
const mapped = models.map(model => {
|
|
247
|
+
const row = codexModelToModel(model, config.service_tier)
|
|
248
|
+
// Apply configured effort to every model that supports it, even with an
|
|
249
|
+
// explicit model override. Otherwise retain the catalog default.
|
|
250
|
+
if (
|
|
251
|
+
config.model_reasoning_effort &&
|
|
252
|
+
row.supportedEffortLevels?.includes(config.model_reasoning_effort)
|
|
253
|
+
) {
|
|
254
|
+
row.defaultEffort = config.model_reasoning_effort
|
|
255
|
+
}
|
|
256
|
+
return row
|
|
257
|
+
})
|
|
258
|
+
const defaultModel =
|
|
259
|
+
mapped.find(model => model.resolvedModel === config.model || model.value === config.model) ??
|
|
260
|
+
mapped.find(model => models.find(raw => raw.id === model.value)?.isDefault) ??
|
|
261
|
+
mapped[0]
|
|
262
|
+
return defaultModel ? [{ ...defaultModel, value: 'default' }, ...mapped] : []
|
|
263
|
+
}
|
|
264
|
+
|
|
215
265
|
// ---- item → turn -------------------------------------------------------------
|
|
216
266
|
|
|
217
267
|
function statusToToolState(status: string | undefined): ToolState {
|
|
@@ -232,8 +282,7 @@ function statusToToolState(status: string | undefined): ToolState {
|
|
|
232
282
|
function userInputToParts(content: CodexUserInput[] | undefined): Part[] {
|
|
233
283
|
const parts: Part[] = []
|
|
234
284
|
for (const c of content ?? []) {
|
|
235
|
-
//
|
|
236
|
-
// the native echo and thread replays carry it back, so peel it here.
|
|
285
|
+
// Strip context from older sends that used the text-envelope fallback.
|
|
237
286
|
if (c.type === 'text' && c.text) {
|
|
238
287
|
const text = stripMoiContext(c.text)
|
|
239
288
|
if (text) parts.push({ type: 'text', text })
|
|
@@ -245,8 +294,7 @@ function userInputToParts(content: CodexUserInput[] | undefined): Part[] {
|
|
|
245
294
|
return parts
|
|
246
295
|
}
|
|
247
296
|
|
|
248
|
-
//
|
|
249
|
-
// approach as the OpenClaw adapter — text blocks joined, others tagged).
|
|
297
|
+
// Prefer structured MCP output; otherwise join text and label non-text blocks.
|
|
250
298
|
function flattenMcpResult(result: CodexThreadItem['result']): string {
|
|
251
299
|
if (!result) return ''
|
|
252
300
|
if (result.structuredContent !== undefined && result.structuredContent !== null) {
|
|
@@ -336,7 +384,12 @@ function itemToToolCall(item: CodexThreadItem): ToolCall | null {
|
|
|
336
384
|
provider: 'codex',
|
|
337
385
|
// webSearch items have no lifecycle status; they appear when done.
|
|
338
386
|
state: 'success',
|
|
339
|
-
input: {
|
|
387
|
+
input: {
|
|
388
|
+
query: item.action?.query ?? item.query,
|
|
389
|
+
...(queries.length ? { queries } : {}),
|
|
390
|
+
...(item.action?.url ? { url: item.action.url } : {}),
|
|
391
|
+
...(item.action?.pattern ? { pattern: item.action.pattern } : {})
|
|
392
|
+
}
|
|
340
393
|
}
|
|
341
394
|
}
|
|
342
395
|
case 'plan': {
|
|
@@ -349,14 +402,9 @@ function itemToToolCall(item: CodexThreadItem): ToolCall | null {
|
|
|
349
402
|
input: { plan: item.text }
|
|
350
403
|
}
|
|
351
404
|
}
|
|
352
|
-
//
|
|
353
|
-
// `send_input`, `resume_agent`, `wait`, `close_agent`). The child agent
|
|
354
|
-
// runs as its OWN thread whose items stream on the same connection under
|
|
355
|
-
// `agentThreadId`; its transcript nests into the `subAgentActivity` card
|
|
356
|
-
// (see session.ts), so this card only narrates the parent's side.
|
|
405
|
+
// Parent tool activity; child transcripts live in subAgentActivity cards.
|
|
357
406
|
case 'collabAgentToolCall': {
|
|
358
|
-
//
|
|
359
|
-
// the activity card that already shows the child running. Drop it.
|
|
407
|
+
// The child's activity card already shows what the parent is waiting on.
|
|
360
408
|
if (item.tool === 'wait') return null
|
|
361
409
|
return {
|
|
362
410
|
toolCallId: item.id,
|
|
@@ -372,9 +420,7 @@ function itemToToolCall(item: CodexThreadItem): ToolCall | null {
|
|
|
372
420
|
}
|
|
373
421
|
}
|
|
374
422
|
case 'subAgentActivity': {
|
|
375
|
-
//
|
|
376
|
-
// session layer correlates the child thread (`agentThreadId`) and
|
|
377
|
-
// attaches a SubagentRecord to this call (see session.ts).
|
|
423
|
+
// session.ts attaches the child transcript using agentThreadId.
|
|
378
424
|
return {
|
|
379
425
|
toolCallId: item.id,
|
|
380
426
|
name: 'subagent_activity',
|
|
@@ -409,9 +455,7 @@ function itemToToolCall(item: CodexThreadItem): ToolCall | null {
|
|
|
409
455
|
}
|
|
410
456
|
}
|
|
411
457
|
case 'imageGeneration': {
|
|
412
|
-
//
|
|
413
|
-
// `result` — the ENTIRE generated image as base64 (megabytes). Never
|
|
414
|
-
// fold that into the turn: it would ride every broadcast/replay.
|
|
458
|
+
// Keep the base64 image result out of repeated display broadcasts/replay.
|
|
415
459
|
return {
|
|
416
460
|
toolCallId: item.id,
|
|
417
461
|
name: 'generate_image',
|
|
@@ -427,7 +471,7 @@ function itemToToolCall(item: CodexThreadItem): ToolCall | null {
|
|
|
427
471
|
}
|
|
428
472
|
|
|
429
473
|
// Build a Turn from one Codex ThreadItem, or null for item kinds we don't
|
|
430
|
-
// render (contextCompaction becomes a notice — see
|
|
474
|
+
// render (contextCompaction becomes a notice — see codexItemToNotice).
|
|
431
475
|
export function codexItemToTurn(item: CodexThreadItem, threadId: string): Turn | null {
|
|
432
476
|
const turnId = `codex:${threadId}:${item.id}`
|
|
433
477
|
if (item.type === 'userMessage') {
|
|
@@ -538,8 +582,7 @@ export function childThreadToSubagentRecord(
|
|
|
538
582
|
description: activity.agentPath?.split('/').pop() || 'sub-agent',
|
|
539
583
|
progress: [],
|
|
540
584
|
status,
|
|
541
|
-
//
|
|
542
|
-
// items, and a "Took 0 steps" subline reads as broken.
|
|
585
|
+
// Replay can omit tool items; do not present missing counts as zero work.
|
|
543
586
|
...(durationMs || toolUses
|
|
544
587
|
? {
|
|
545
588
|
usage: {
|
|
@@ -565,6 +608,8 @@ export function codexThreadToEvents(
|
|
|
565
608
|
for (const item of turn.items ?? []) {
|
|
566
609
|
const t = codexItemToTurn(item, thread.id)
|
|
567
610
|
if (t) {
|
|
611
|
+
if (typeof turn.startedAt === 'number')
|
|
612
|
+
t.timestamp = new Date(turn.startedAt * 1000).toISOString()
|
|
568
613
|
if (item.type === 'subAgentActivity' && item.agentThreadId) {
|
|
569
614
|
const sub = subagents?.get(item.agentThreadId)
|
|
570
615
|
const part = t.parts.find(p => p.type === 'tool-call')
|
|
@@ -577,7 +622,11 @@ export function codexThreadToEvents(
|
|
|
577
622
|
continue
|
|
578
623
|
}
|
|
579
624
|
const n = codexItemToNotice(item, thread.id)
|
|
580
|
-
if (n)
|
|
625
|
+
if (n) {
|
|
626
|
+
const time = turn.completedAt ?? turn.startedAt
|
|
627
|
+
if (typeof time === 'number') n.at = new Date(time * 1000).toISOString()
|
|
628
|
+
events.push({ kind: 'notice', notice: n })
|
|
629
|
+
}
|
|
581
630
|
}
|
|
582
631
|
}
|
|
583
632
|
return events
|
|
@@ -38,9 +38,7 @@ export function codexAccountReadiness(response: unknown): HarnessAvailability {
|
|
|
38
38
|
return CODEX_AVAILABLE
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
// bare "Invalid request", which the probe would surface as a generic failure —
|
|
43
|
-
// report the actionable cause instead.
|
|
41
|
+
// Report a known protocol-version mismatch before making the account probe.
|
|
44
42
|
export function codexOutdatedAvailability(
|
|
45
43
|
cliVersion: string | undefined
|
|
46
44
|
): HarnessAvailability | undefined {
|