moi-computer 0.12.1-next.3 → 0.12.1-next.4

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 (224) hide show
  1. package/bunfig.toml +1 -5
  2. package/client/api/app-config.ts +1 -2
  3. package/client/api/app-ui-keys.ts +3 -1
  4. package/client/api/http.ts +4 -1
  5. package/client/api/workspace-keys.ts +3 -3
  6. package/client/app/app-provider.tsx +22 -2
  7. package/client/app/app-router.tsx +4 -0
  8. package/client/app/routes/home-route.tsx +14 -0
  9. package/client/app/routes/onboarding-route.tsx +11 -0
  10. package/client/app/routes/settings-route.tsx +1 -1
  11. package/client/app/routes/workspace-route.tsx +21 -19
  12. package/client/components/shared/screen-shell.tsx +23 -0
  13. package/client/components/shared/ultrafast-icon.tsx +61 -0
  14. package/client/components/shared/workspace-icon.tsx +2 -2
  15. package/client/features/account/account-test-utils.tsx +4 -3
  16. package/client/features/app-settings/api.ts +33 -0
  17. package/client/features/app-settings/general-settings.tsx +39 -0
  18. package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
  19. package/client/features/chat/applet-chat-intents.ts +4 -20
  20. package/client/features/chat/chat-send.ts +17 -13
  21. package/client/features/chat/composer/model-order.ts +8 -4
  22. package/client/features/chat/composer/model-picker.tsx +88 -34
  23. package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
  24. package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
  25. package/client/features/chat/connection/chat-frames.ts +3 -15
  26. package/client/features/chat/messages/chat-empty-state.tsx +1 -4
  27. package/client/features/chat/messages/fork-history.ts +5 -5
  28. package/client/features/chat/messages/turn-view.tsx +3 -12
  29. package/client/features/chat/messages/user-message-bubble.tsx +63 -0
  30. package/client/features/chat/sessions/api.ts +121 -80
  31. package/client/features/chat/sessions/browser-tab-state.ts +14 -12
  32. package/client/features/chat/sessions/chat-selector.tsx +5 -6
  33. package/client/features/chat/sessions/use-selected-session.ts +172 -257
  34. package/client/features/chat/use-chat.ts +14 -19
  35. package/client/features/collab/workspace-users-menu.tsx +1 -1
  36. package/client/features/demo/demo-dialog.tsx +11 -3
  37. package/client/features/dev/dev-index-page.tsx +5 -0
  38. package/client/features/dev/dev-routes.tsx +2 -0
  39. package/client/features/dev/harness-debug-page.tsx +3 -3
  40. package/client/features/dev/onboarding-preview-page.tsx +76 -0
  41. package/client/features/dev/workspace-setup-mocks.ts +16 -14
  42. package/client/features/dev/workspace-setup-preview.tsx +11 -17
  43. package/client/features/harness/api.ts +45 -15
  44. package/client/features/harness/device-login-steps.tsx +9 -3
  45. package/client/features/harness/harness-login-panel.tsx +228 -0
  46. package/client/features/harness/harness-presentation.ts +15 -0
  47. package/client/features/harness/harness-selector.tsx +119 -0
  48. package/client/features/harness/use-harness-login.ts +77 -0
  49. package/client/features/home/home-page.tsx +7 -7
  50. package/client/features/onboarding/agent-setup-step.tsx +57 -0
  51. package/client/features/onboarding/api.ts +42 -0
  52. package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
  53. package/client/features/onboarding/onboarding-page.tsx +32 -0
  54. package/client/features/onboarding/onboarding-screen.tsx +20 -0
  55. package/client/features/onboarding/onboarding-status.tsx +24 -0
  56. package/client/features/onboarding/workspace-setup-step.tsx +239 -0
  57. package/client/features/overview/default/registry.tsx +2 -2
  58. package/client/features/overview/default/views-widget.tsx +6 -5
  59. package/client/features/overview/overview.tsx +9 -11
  60. package/client/features/overview/widget-canvas.tsx +1 -1
  61. package/client/features/overview/workspace-name.tsx +2 -2
  62. package/client/features/views/api.ts +69 -16
  63. package/client/features/views/pending-view-screen.tsx +30 -9
  64. package/client/features/views/use-view-actions.ts +19 -20
  65. package/client/features/views/view-presentation.ts +2 -2
  66. package/client/features/views/view-submission.ts +28 -41
  67. package/client/features/workspace/add/api.ts +3 -23
  68. package/client/features/workspace/add/create-workspace-dialog.tsx +6 -5
  69. package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
  70. package/client/features/workspace/add/workspace-agent-options.ts +11 -12
  71. package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
  72. package/client/features/workspace/api.ts +32 -36
  73. package/client/features/workspace/harness-transition.ts +88 -0
  74. package/client/features/{settings → workspace/settings}/api.ts +1 -34
  75. package/client/features/{settings → workspace/settings}/general-settings.tsx +76 -2
  76. package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
  77. package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
  78. package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
  79. package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
  80. package/client/features/workspace/setup/workspace-setup.tsx +34 -14
  81. package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
  82. package/client/features/workspace/use-workspace-navigation.ts +25 -9
  83. package/client/features/workspace/workspace-content.tsx +11 -8
  84. package/client/features/workspace/workspace-frame.tsx +2 -1
  85. package/client/features/workspace/workspace-layout-context.tsx +5 -2
  86. package/client/features/workspace/workspace-menu.tsx +12 -8
  87. package/client/features/workspace/workspace-pending-screen.tsx +10 -10
  88. package/client/features/workspace/workspace-presentation.tsx +5 -13
  89. package/client/features/workspace/workspace-state.ts +169 -0
  90. package/client/features/workspace/workspace-tabs.tsx +22 -2
  91. package/client/index.css +2 -0
  92. package/client/index.tsx +3 -3
  93. package/client/lib/flags.ts +1 -1
  94. package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
  95. package/client/runtime/workspace-events.ts +21 -4
  96. package/client/runtime/workspace-theme.ts +9 -0
  97. package/client/tailwind-config.ts +43 -0
  98. package/dist/chunk-0mjzg20x.js +2 -0
  99. package/dist/chunk-2y59vrxg.js +5 -0
  100. package/dist/chunk-58dyt9bk.js +2 -0
  101. package/dist/chunk-5aj040e5.css +1 -0
  102. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  103. package/dist/chunk-71fn6rmj.js +546 -0
  104. package/dist/chunk-7yg1m8hx.js +2 -0
  105. package/dist/chunk-825hys3h.js +1 -0
  106. package/dist/chunk-9bb8m9rx.js +2 -0
  107. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  108. package/dist/chunk-g0tcwqxc.js +1 -0
  109. package/dist/chunk-n0nab26d.js +1 -0
  110. package/dist/chunk-nf2wkvf9.js +14 -0
  111. package/dist/chunk-v88n1bay.js +74 -0
  112. package/dist/index.html +1 -1
  113. package/lib/harness-instructions.ts +1 -1
  114. package/lib/{app-icons.ts → identity-icons.ts} +6 -7
  115. package/lib/onboarding.ts +41 -0
  116. package/lib/speed-mode.ts +5 -0
  117. package/lib/types.ts +71 -62
  118. package/lib/view-build-directives.ts +1 -2
  119. package/lib/workspace-icon.ts +2 -2
  120. package/lib/workspace-layout.ts +1 -1
  121. package/lib/workspace-name.ts +15 -12
  122. package/package.json +9 -8
  123. package/server/README.md +27 -25
  124. package/server/api/harnesses.ts +31 -8
  125. package/server/api/index.ts +163 -126
  126. package/server/api/onboarding.ts +46 -0
  127. package/server/app-config.ts +16 -24
  128. package/server/app-settings.ts +6 -2
  129. package/server/applets/config.ts +5 -5
  130. package/server/applets/views.ts +19 -17
  131. package/server/cli/commands/init.ts +3 -3
  132. package/server/cli/commands/skill.ts +16 -17
  133. package/server/cli/commands/start.ts +8 -34
  134. package/server/cli/server.ts +18 -6
  135. package/server/collab/config.ts +1 -2
  136. package/server/collab/manager.ts +4 -1
  137. package/server/collab/skill/index.ts +1 -1
  138. package/server/control.ts +3 -3
  139. package/server/data-dir.ts +1 -1
  140. package/server/harness/README.md +24 -8
  141. package/server/harness/acp/session.ts +8 -4
  142. package/server/harness/auth.ts +14 -17
  143. package/server/harness/claude-code/NOTES.md +4 -3
  144. package/server/harness/claude-code/index.ts +2 -0
  145. package/server/harness/claude-code/models.ts +2 -20
  146. package/server/harness/claude-code/run-action.ts +123 -0
  147. package/server/harness/claude-code/session-title.ts +5 -7
  148. package/server/harness/claude-code/session.ts +24 -16
  149. package/server/harness/codex/NOTES.md +14 -9
  150. package/server/harness/codex/adapter.ts +14 -17
  151. package/server/harness/codex/index.ts +2 -0
  152. package/server/harness/codex/run-action.ts +93 -0
  153. package/server/harness/codex/session-title.ts +6 -8
  154. package/server/harness/codex/session.ts +11 -11
  155. package/server/harness/command.ts +45 -0
  156. package/server/harness/executable.ts +5 -0
  157. package/server/harness/fork.ts +6 -4
  158. package/server/harness/install.ts +49 -0
  159. package/server/harness/openclaw/session.ts +1 -2
  160. package/server/harness/run-action.ts +85 -0
  161. package/server/harness/session-title.ts +0 -46
  162. package/server/harness/types.ts +26 -2
  163. package/server/onboarding/brief.ts +29 -0
  164. package/server/onboarding/ideas.ts +48 -0
  165. package/server/onboarding/jobs.ts +291 -0
  166. package/server/onboarding/prompt.md +49 -0
  167. package/server/sessions/archive.ts +5 -14
  168. package/server/sessions/config.ts +17 -16
  169. package/server/sessions/lifecycle.ts +15 -13
  170. package/server/sessions/pending-views.ts +79 -108
  171. package/server/sessions/selected.ts +75 -161
  172. package/server/sessions/store.ts +40 -113
  173. package/server/sessions/view-sessions.ts +128 -111
  174. package/server/skills/locations.ts +82 -0
  175. package/server/skills/lock.ts +29 -0
  176. package/server/skills/template.ts +36 -25
  177. package/server/skills/update.ts +52 -5
  178. package/server/skills/version.ts +17 -22
  179. package/server/skills/workspace.ts +121 -0
  180. package/server/web.ts +22 -8
  181. package/server/workspace-state/file.ts +177 -0
  182. package/server/workspace-state/index.ts +162 -0
  183. package/server/workspace-state/legacy-migration.ts +79 -0
  184. package/server/workspace-state/lock.ts +42 -0
  185. package/server/workspace-state/types.ts +16 -0
  186. package/server/workspaces/change-harness.ts +88 -0
  187. package/server/workspaces/harness-transition.ts +29 -0
  188. package/server/workspaces/init.ts +29 -6
  189. package/server/workspaces/layout.ts +3 -0
  190. package/server/workspaces/registry.ts +27 -1
  191. package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
  192. package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
  193. package/skill/references/DESIGN.md +148 -0
  194. package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
  195. package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
  196. package/ui-components/badge.tsx +1 -1
  197. package/client/accept-hmr-dependencies.ts +0 -22
  198. package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
  199. package/dist/chunk-20ynagd4.js +0 -2
  200. package/dist/chunk-42tde9a6.js +0 -1
  201. package/dist/chunk-9w543s0r.js +0 -2
  202. package/dist/chunk-a5372n61.js +0 -546
  203. package/dist/chunk-aja9y1vn.js +0 -68
  204. package/dist/chunk-fvcvrh3d.css +0 -1
  205. package/dist/chunk-gtfjw3nx.js +0 -1
  206. package/dist/chunk-j39y2aky.js +0 -14
  207. package/dist/chunk-pcnahct1.js +0 -5
  208. package/dist/chunk-pja30km3.js +0 -1
  209. package/dist/chunk-rm894bc2.js +0 -2
  210. package/dist/chunk-tevvtfbk.js +0 -10
  211. package/dist/chunk-tgt9zd0r.js +0 -2
  212. package/dist/chunk-tv5k5z00.js +0 -1
  213. package/dist/chunk-zq2ae5dx.js +0 -2
  214. package/lib/experimental.ts +0 -14
  215. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
  216. /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
  217. /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
  218. /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
  219. /package/client/features/{settings → workspace/settings}/connectors-settings.tsx +0 -0
  220. /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
  221. /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
  222. /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
  223. /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
  224. /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
@@ -0,0 +1,123 @@
1
+ import { query, type Options, type Query } from '@anthropic-ai/claude-agent-sdk'
2
+ import { claudeCodeSpawn } from '../../agent-launcher'
3
+ import type { ActionModel, HarnessActionInput } from '../types'
4
+ import { requireHarnessExecutable } from '../executable'
5
+ import {
6
+ type ActionExecution,
7
+ actionProgressServerName,
8
+ actionProgressToolName,
9
+ executeHarnessAction
10
+ } from '../run-action'
11
+
12
+ const actionModels: Record<ActionModel, Required<Pick<Options, 'model' | 'effort'>>> = {
13
+ fast: { model: 'haiku', effort: 'high' },
14
+ normal: { model: 'sonnet', effort: 'medium' },
15
+ smart: { model: 'sonnet', effort: 'xhigh' }
16
+ }
17
+
18
+ const readTools = new Set([
19
+ 'Read',
20
+ 'Glob',
21
+ 'Grep',
22
+ 'WebSearch',
23
+ 'WebFetch',
24
+ 'ToolSearch',
25
+ 'ListMcpResources',
26
+ 'ReadMcpResource',
27
+ 'StructuredOutput'
28
+ ])
29
+ export function canReadTool(
30
+ name: string,
31
+ annotations?: { readOnly?: boolean; destructive?: boolean }
32
+ ) {
33
+ return (
34
+ readTools.has(name) ||
35
+ (name.startsWith('mcp__') && annotations?.readOnly === true && annotations.destructive !== true)
36
+ )
37
+ }
38
+
39
+ async function claudeAction(input: ActionExecution): Promise<unknown> {
40
+ const controller = new AbortController()
41
+ const abort = () => controller.abort()
42
+ input.signal.addEventListener('abort', abort, { once: true })
43
+ if (input.signal.aborted) controller.abort()
44
+ let run: Query | undefined
45
+ try {
46
+ run = query({
47
+ prompt: input.prompt,
48
+ options: {
49
+ ...actionModels[input.model],
50
+ cwd: input.cwd,
51
+ abortController: controller,
52
+ persistSession: false,
53
+ maxTurns: 24,
54
+ pathToClaudeCodeExecutable: requireHarnessExecutable('claude-code'),
55
+ spawnClaudeCodeProcess: claudeCodeSpawn(),
56
+ settingSources: [],
57
+ env: { ...process.env, CLAUDECODE: undefined },
58
+ outputFormat: { type: 'json_schema', schema: input.resultSchema },
59
+ mcpServers: input.progressUrl
60
+ ? {
61
+ [actionProgressServerName]: { type: 'http', url: input.progressUrl, alwaysLoad: true }
62
+ }
63
+ : undefined,
64
+ permissionMode: 'default',
65
+ hooks: {
66
+ PreToolUse: [
67
+ {
68
+ hooks: [
69
+ async event => {
70
+ if (event.hook_event_name !== 'PreToolUse') return {}
71
+ let allowed =
72
+ canReadTool(event.tool_name) ||
73
+ (!!input.progressUrl &&
74
+ event.tool_name ===
75
+ `mcp__${actionProgressServerName}__${actionProgressToolName}`)
76
+ if (!allowed && event.mcp_server && run) {
77
+ const servers = await run.mcpServerStatus()
78
+ const server = servers.find(server => server.name === event.mcp_server?.name)
79
+ const toolName = event.tool_name.split('__').slice(2).join('__')
80
+ allowed =
81
+ server?.tools?.some(
82
+ tool =>
83
+ tool.name === toolName && canReadTool(event.tool_name, tool.annotations)
84
+ ) ?? false
85
+ }
86
+ return {
87
+ hookSpecificOutput: {
88
+ hookEventName: 'PreToolUse',
89
+ permissionDecision: allowed ? 'allow' : 'deny',
90
+ permissionDecisionReason: 'This action only permits read/search tools'
91
+ }
92
+ }
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ },
98
+ canUseTool: async () => ({
99
+ behavior: 'deny',
100
+ message: 'This action only permits approved read/search tools'
101
+ })
102
+ }
103
+ })
104
+ for await (const message of run) {
105
+ if (message.type === 'result' && message.subtype === 'success' && !message.is_error)
106
+ return message.structured_output
107
+ if (message.type === 'result')
108
+ throw new Error(
109
+ message.subtype === 'success' ? message.result : 'The agent could not complete the action'
110
+ )
111
+ }
112
+ throw new Error('The agent returned no structured output')
113
+ } finally {
114
+ input.signal.removeEventListener('abort', abort)
115
+ run?.close()
116
+ }
117
+ }
118
+
119
+ export async function runClaudeAction<TResult, TProgress = never>(
120
+ input: HarnessActionInput<TResult, TProgress>
121
+ ): Promise<TResult> {
122
+ return executeHarnessAction(input, claudeAction)
123
+ }
@@ -1,13 +1,11 @@
1
+ import { createHarnessTempDir, removeHarnessTempDir, runHarnessCommand } from '../command'
1
2
  import { getSessionInfo, renameSession, type SDKSessionInfo } from '@anthropic-ai/claude-agent-sdk'
2
3
 
3
4
  import {
4
5
  SESSION_TITLE_SCHEMA,
5
6
  SESSION_TITLE_SYSTEM_PROMPT,
6
7
  SESSION_TITLE_TIMEOUT_MS,
7
- createSessionTitleTempDir,
8
- parseGeneratedSessionTitle,
9
- removeSessionTitleTempDir,
10
- runSessionTitleCommand
8
+ parseGeneratedSessionTitle
11
9
  } from '../session-title'
12
10
  import { requireHarnessExecutable } from '../executable'
13
11
 
@@ -61,8 +59,8 @@ export async function generateClaudeSessionTitle(input: {
61
59
  )
62
60
  let tempDir: string | undefined
63
61
  try {
64
- tempDir = await createSessionTitleTempDir()
65
- const output = await runSessionTitleCommand({
62
+ tempDir = await createHarnessTempDir()
63
+ const output = await runHarnessCommand({
66
64
  command: claudeSessionTitleCommand(requireHarnessExecutable('claude-code')),
67
65
  cwd: tempDir,
68
66
  stdin: JSON.stringify({ sessionTitleSource: input.source }),
@@ -72,7 +70,7 @@ export async function generateClaudeSessionTitle(input: {
72
70
  return output ? parseClaudeSessionTitleOutput(output) : null
73
71
  } finally {
74
72
  clearTimeout(timer)
75
- if (tempDir) await removeSessionTitleTempDir(tempDir).catch(() => {})
73
+ if (tempDir) await removeHarnessTempDir(tempDir).catch(() => {})
76
74
  }
77
75
  }
78
76
 
@@ -37,6 +37,9 @@ import { resolveWorkspaceEnv } from '../../workspaces/env'
37
37
  import { requireHarnessExecutable } from '../executable'
38
38
  import type { SendMessageInput } from '../types'
39
39
 
40
+ // Claude supports only the original two speed modes.
41
+ type ClaudeSendMessageInput = Omit<SendMessageInput, 'speedMode'> & { fastMode: boolean }
42
+
40
43
  // Media types Claude vision accepts; uploads.ts guarantees every image upload is
41
44
  // normalized to one of these, so the cast on `media_type` below is sound.
42
45
  type ImageMediaType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'
@@ -80,7 +83,7 @@ type InputQueue = {
80
83
  }
81
84
 
82
85
  type PendingMessage = {
83
- input: SendMessageInput
86
+ input: ClaudeSendMessageInput
84
87
  content: MessageContent
85
88
  titleSource: string
86
89
  turnId: string
@@ -129,8 +132,8 @@ type LiveSession = {
129
132
  // the SDK does not guarantee their ordering relative to snapshots.
130
133
  sawBackgroundSnapshot: boolean
131
134
  model: string | undefined
132
- // Live flag settings; undefined inherits provider defaults.
133
- fastMode: boolean | undefined
135
+ // Live flag settings; undefined effort inherits the provider default.
136
+ fastMode: boolean
134
137
  effort: string | undefined
135
138
  // `includePartialMessages` is fixed at creation, so changes require resume.
136
139
  stream: boolean
@@ -189,7 +192,7 @@ export type CCDebugSession = {
189
192
  workspaceId: string
190
193
  sessionId: string
191
194
  model: string | undefined
192
- fastMode: boolean | undefined
195
+ fastMode: boolean
193
196
  effort: string | undefined
194
197
  stream: boolean
195
198
  queuedMessages: number
@@ -420,18 +423,19 @@ async function consume(s: LiveSession) {
420
423
  const realId = msg.session_id
421
424
  if (realId && realId !== s.sessionId) {
422
425
  const from = renameSession(s, realId)
423
- await renameSessionReferences(s.workspaceId, s.workspacePath, from, s.sessionId)
426
+ await renameSessionReferences(
427
+ { id: s.workspaceId, path: s.workspacePath },
428
+ from,
429
+ s.sessionId
430
+ )
424
431
  }
425
432
  startClaudeSessionTitleJob(s)
426
433
  // Seed explicit startup settings only when no saved picker choice exists.
427
- if (
428
- (s.model || s.effort || s.fastMode !== undefined) &&
429
- !(await hasSessionConfig(s.workspacePath, s.sessionId))
430
- ) {
431
- await saveSessionConfig(s.workspacePath, s.sessionId, {
434
+ if (!(await hasSessionConfig({ id: s.workspaceId, path: s.workspacePath }, s.sessionId))) {
435
+ await saveSessionConfig({ id: s.workspaceId, path: s.workspacePath }, s.sessionId, {
432
436
  model: s.model,
433
437
  effort: s.effort,
434
- fastMode: s.fastMode
438
+ speedMode: s.fastMode ? 'fast' : 'normal'
435
439
  })
436
440
  }
437
441
  }
@@ -587,7 +591,7 @@ function createLiveSession(input: {
587
591
  isNew: boolean
588
592
  model: string | undefined
589
593
  effort: string | undefined
590
- fastMode: boolean | undefined
594
+ fastMode: boolean
591
595
  stream: boolean
592
596
  // Resolved workspace env, fixed for the lifetime of the subprocess.
593
597
  workspaceEnv: Record<string, string>
@@ -610,7 +614,7 @@ function createLiveSession(input: {
610
614
  // Harness-neutral settings are strings; the picker supplies this model's
611
615
  // supported effort levels from the SDK catalog.
612
616
  ...(input.effort ? { effort: input.effort as Options['effort'] } : {}),
613
- ...(input.fastMode !== undefined ? { settings: { fastMode: input.fastMode } } : {}),
617
+ settings: { fastMode: input.fastMode },
614
618
  // Partial frames enable the opt-in live preview.
615
619
  includePartialMessages: input.stream,
616
620
  permissionMode: 'auto',
@@ -659,7 +663,7 @@ function createLiveSession(input: {
659
663
  sessions.set(recKey(session.workspaceId, session.sessionId), session)
660
664
  input.messages.live = session
661
665
  debug(
662
- `cc create ${input.isNew ? 'new' : 'resume'} ws=${input.workspaceId} session=${input.sessionId} model=${input.model ?? 'default'} effort=${input.effort ?? 'default'} fast=${input.fastMode ?? 'default'} live=${sessions.size}`
666
+ `cc create ${input.isNew ? 'new' : 'resume'} ws=${input.workspaceId} session=${input.sessionId} model=${input.model ?? 'default'} effort=${input.effort ?? 'default'} fast=${input.fastMode} live=${sessions.size}`
663
667
  )
664
668
  void consume(session)
665
669
  return session
@@ -667,7 +671,11 @@ function createLiveSession(input: {
667
671
 
668
672
  // Accept immediately, but keep the prompt and its settings in Moi until its
669
673
  // turn starts. The returned promise settles when the message reaches the SDK.
670
- export async function sendCCMessage(input: SendMessageInput): Promise<void> {
674
+ export async function sendCCMessage(incoming: SendMessageInput): Promise<void> {
675
+ const input: ClaudeSendMessageInput = {
676
+ ...incoming,
677
+ fastMode: incoming.speedMode === 'fast'
678
+ }
671
679
  const prepared = prepareAttachmentMessage(input.workspaceId, input.content, input.attachments)
672
680
  if (!prepared.text) return
673
681
  const { content: userContent, parts } = buildUserMessage(prepared)
@@ -796,7 +804,7 @@ async function dispatchNextMessage(messages: SessionMessages): Promise<void> {
796
804
  ...(input.effort !== s.effort
797
805
  ? { effortLevel: (input.effort as Options['effort']) ?? null }
798
806
  : {}),
799
- ...(input.fastMode !== s.fastMode ? { fastMode: input.fastMode ?? null } : {})
807
+ ...(input.fastMode !== s.fastMode ? { fastMode: input.fastMode } : {})
800
808
  })
801
809
  if (!s.closed) {
802
810
  s.effort = input.effort
@@ -102,7 +102,7 @@ does not spawn one per card.
102
102
  Workspace import discovery separately reads up to 400 recent rollout heads
103
103
  under the server's `$CODEX_HOME/sessions`, without requiring a CLI executable.
104
104
 
105
- ## Models, effort, and fast mode
105
+ ## Models, effort, and speed modes
106
106
 
107
107
  `model/list` is the source of picker capabilities. The catalog is paginated,
108
108
  filters hidden rows, and is cached per client for one minute. Login/account
@@ -120,14 +120,19 @@ Changing a selection does not retry an earlier failed message.
120
120
  Configured reasoning effort applies when supported by the selected model;
121
121
  otherwise the adapter uses its advertised default. Fast mode is available when
122
122
  `serviceTiers` includes `priority`. Only catalogs missing that field fall back
123
- to `additionalSpeedTiers: ["fast"]`. A non-null configured tier takes precedence
124
- over the catalog default.
125
-
126
- | Moi fast-mode setting | Native `serviceTier` |
127
- | --------------------- | ---------------------------------------- |
128
- | On | `"priority"` |
129
- | Off | `null` |
130
- | Unset | Omitted; inherits the config/thread tier |
123
+ to `additionalSpeedTiers: ["fast"]`. Ultrafast uses the same capability check for
124
+ `ultrafast`, including the legacy fallback only when `serviceTiers` is missing.
125
+ The picker cycles regular → fast → ultrafast → regular, skipping unavailable
126
+ tiers. Moi stores `speedMode` as `normal`, `fast`, or `ultrafast`.
127
+
128
+ | Moi speed mode | Native `serviceTier` |
129
+ | --------------- | -------------------- |
130
+ | Normal or unset | `null` |
131
+ | Fast | `"priority"` |
132
+ | Ultrafast | `"ultrafast"` |
133
+
134
+ When the catalog is available, UI sends resolve speed against model capabilities.
135
+ Unsupported Ultrafast falls back to Fast when supported, otherwise Normal.
131
136
 
132
137
  Model, effort, and tier changes apply on the next **new turn**. `turn/steer`
133
138
  has no fields for changing them during an active turn. Moi uses the persistent
@@ -13,7 +13,7 @@ import type {
13
13
  Turn
14
14
  } from '@/lib/format'
15
15
  import { stripMoiContextLoose } from '@/lib/moi-context'
16
- import type { McpServer, Model, SessionSummary } from '@/lib/types'
16
+ import type { SpeedMode, McpServer, Model, SessionSummary } from '@/lib/types'
17
17
 
18
18
  import type { WorkspaceActivityPreview } from '../types'
19
19
 
@@ -133,11 +133,11 @@ export function withCodexTurnDuration(turn: Turn, durationMs: number | null | un
133
133
 
134
134
  const CODEX_FAST_SERVICE_TIER = 'priority'
135
135
 
136
- export function codexServiceTierForFastMode(
137
- fastMode: boolean | undefined
138
- ): typeof CODEX_FAST_SERVICE_TIER | null | undefined {
139
- if (fastMode === undefined) return undefined
140
- return fastMode ? CODEX_FAST_SERVICE_TIER : null
136
+ export function codexServiceTierForSpeedMode(
137
+ speedMode: SpeedMode | undefined
138
+ ): typeof CODEX_FAST_SERVICE_TIER | 'ultrafast' | null {
139
+ if (speedMode === 'ultrafast') return 'ultrafast'
140
+ return speedMode === 'fast' ? CODEX_FAST_SERVICE_TIER : null
141
141
  }
142
142
 
143
143
  // Legacy context can be cut mid-envelope in a thread/list preview.
@@ -185,16 +185,17 @@ export function selectCodexWorkspacePreview(
185
185
  }
186
186
  }
187
187
 
188
- export function codexModelToModel(m: CodexModel, configuredServiceTier?: string | null): Model {
188
+ export function codexModelToModel(m: CodexModel): Model {
189
189
  const efforts = (m.supportedReasoningEfforts ?? []).map(e => e.reasoningEffort)
190
190
  const displayName = m.displayName.replace(/^GPT-/, '').replaceAll('-', ' ')
191
191
  const supportsFastMode =
192
192
  m.serviceTiers !== undefined
193
193
  ? m.serviceTiers.some(tier => tier.id === CODEX_FAST_SERVICE_TIER)
194
194
  : (m.additionalSpeedTiers ?? []).includes('fast')
195
- // The effective user/project config governs omitted wire values. A null
196
- // config value leaves the model catalog's default in charge.
197
- const defaultServiceTier = configuredServiceTier ?? m.defaultServiceTier
195
+ const supportsUltrafastMode =
196
+ m.serviceTiers !== undefined
197
+ ? m.serviceTiers.some(tier => tier.id === 'ultrafast')
198
+ : (m.additionalSpeedTiers ?? []).includes('ultrafast')
198
199
  return {
199
200
  value: m.id,
200
201
  resolvedModel: m.model,
@@ -208,12 +209,8 @@ export function codexModelToModel(m: CodexModel, configuredServiceTier?: string
208
209
  ...(m.defaultReasoningEffort && efforts.includes(m.defaultReasoningEffort)
209
210
  ? { defaultEffort: m.defaultReasoningEffort }
210
211
  : {}),
211
- ...(supportsFastMode
212
- ? {
213
- supportsFastMode: true,
214
- defaultFastMode: defaultServiceTier === CODEX_FAST_SERVICE_TIER
215
- }
216
- : {})
212
+ ...(supportsUltrafastMode ? { supportsUltrafastMode: true } : {}),
213
+ ...(supportsFastMode ? { supportsFastMode: true } : {})
217
214
  }
218
215
  }
219
216
 
@@ -248,7 +245,7 @@ export function codexMcpServerToServer(server: {
248
245
 
249
246
  export function codexModelsToModels(models: CodexModel[], config: CodexConfig): Model[] {
250
247
  const mapped = models.map(model => {
251
- const row = codexModelToModel(model, config.service_tier)
248
+ const row = codexModelToModel(model)
252
249
  // Apply configured effort to every model that supports it, even with an
253
250
  // explicit model override. Otherwise retain the catalog default.
254
251
  if (
@@ -1,5 +1,6 @@
1
1
  // Codex as a Harness. Thin wiring over this folder's modules — see
2
2
  // ../types.ts for the contract and ../README.md for the architecture.
3
+ import { runCodexAction } from './run-action'
3
4
  import type { Harness } from '../types'
4
5
  import { ForkUnsupportedError } from '../fork'
5
6
  import { CodexRpcError } from './transport'
@@ -31,6 +32,7 @@ import { formatCodexStatusLines } from './status'
31
32
 
32
33
  export const codexHarness: Harness = {
33
34
  id: 'codex',
35
+ runAction: runCodexAction,
34
36
  capabilities: {
35
37
  supportsStreaming: true, // app-server always streams deltas; moi gates forwarding
36
38
  imagesInline: 'data-url',
@@ -0,0 +1,93 @@
1
+ import { join } from 'node:path'
2
+ import { runHarnessCommand } from '../command'
3
+ import type { ActionModel, HarnessActionInput } from '../types'
4
+ import { requireHarnessExecutable } from '../executable'
5
+ import { actionProgressServerName, executeHarnessAction } from '../run-action'
6
+
7
+ const actionModels: Record<ActionModel, { model: string; effort: 'medium' | 'xhigh' }> = {
8
+ fast: { model: 'gpt-6.1-terra', effort: 'medium' },
9
+ normal: { model: 'gpt-6.1-sol', effort: 'medium' },
10
+ smart: { model: 'gpt-6.1-sol', effort: 'xhigh' }
11
+ }
12
+
13
+ export function codexActionCommand(
14
+ executable: string,
15
+ cwd: string,
16
+ schema: string,
17
+ output: string,
18
+ progressUrl?: string,
19
+ model: ActionModel = 'normal'
20
+ ): string[] {
21
+ return [
22
+ executable,
23
+ 'exec',
24
+ '--model',
25
+ actionModels[model].model,
26
+ '-c',
27
+ `model_reasoning_effort=${JSON.stringify(actionModels[model].effort)}`,
28
+ '--ephemeral',
29
+ '--ignore-user-config',
30
+ '--ignore-rules',
31
+ '--strict-config',
32
+ '--skip-git-repo-check',
33
+ '--sandbox',
34
+ 'read-only',
35
+ '--cd',
36
+ cwd,
37
+ '--output-schema',
38
+ schema,
39
+ '--output-last-message',
40
+ output,
41
+ '-c',
42
+ 'approval_policy="never"',
43
+ // Native connected apps may read; writes require approval and this headless
44
+ // action never grants it. User MCP configs/hooks cannot override this policy.
45
+ '-c',
46
+ 'apps._default.default_tools_approval_mode="writes"',
47
+ '-c',
48
+ 'apps._default.destructive_enabled=false',
49
+ '-c',
50
+ 'apps._default.open_world_enabled=false',
51
+ '-c',
52
+ 'features.js_repl=false',
53
+ '-c',
54
+ 'features.multi_agent=false',
55
+ '-c',
56
+ 'notify=[]',
57
+ ...(progressUrl
58
+ ? ['-c', `mcp_servers.${actionProgressServerName}.url=${JSON.stringify(progressUrl)}`]
59
+ : []),
60
+ '-'
61
+ ]
62
+ }
63
+
64
+ export async function runCodexAction<TResult, TProgress = never>(
65
+ input: HarnessActionInput<TResult, TProgress>
66
+ ): Promise<TResult> {
67
+ return executeHarnessAction(input, async action => {
68
+ const { cwd } = action
69
+ const schema = join(cwd, 'schema.json'),
70
+ output = join(cwd, 'result.json')
71
+ await Bun.write(schema, JSON.stringify(action.resultSchema))
72
+ const result = await runHarnessCommand({
73
+ command: codexActionCommand(
74
+ requireHarnessExecutable('codex'),
75
+ cwd,
76
+ schema,
77
+ output,
78
+ action.progressUrl,
79
+ action.model
80
+ ),
81
+ cwd,
82
+ stdin: action.prompt,
83
+ signal: input.signal,
84
+ env: Object.fromEntries(
85
+ Object.entries(process.env).filter(
86
+ ([key]) => !key.startsWith('CODEX_') || key === 'CODEX_HOME' || key === 'CODEX_API_KEY'
87
+ )
88
+ )
89
+ })
90
+ if (result === null) throw new Error('The agent could not complete the action')
91
+ return JSON.parse(await Bun.file(output).text())
92
+ })
93
+ }
@@ -1,3 +1,4 @@
1
+ import { createHarnessTempDir, removeHarnessTempDir, runHarnessCommand } from '../command'
1
2
  import { join } from 'node:path'
2
3
 
3
4
  import type { CodexThread } from './adapter'
@@ -7,10 +8,7 @@ import {
7
8
  SESSION_TITLE_SCHEMA,
8
9
  SESSION_TITLE_SYSTEM_PROMPT,
9
10
  SESSION_TITLE_TIMEOUT_MS,
10
- createSessionTitleTempDir,
11
- parseGeneratedSessionTitleJson,
12
- removeSessionTitleTempDir,
13
- runSessionTitleCommand
11
+ parseGeneratedSessionTitleJson
14
12
  } from '../session-title'
15
13
  import { requireHarnessExecutable } from '../executable'
16
14
 
@@ -96,10 +94,10 @@ export async function generateCodexSessionTitle(input: {
96
94
  )
97
95
  let tempDir: string | undefined
98
96
  try {
99
- tempDir = await createSessionTitleTempDir()
97
+ tempDir = await createHarnessTempDir()
100
98
  const executable = requireHarnessExecutable('codex')
101
99
  const env = codexSessionTitleEnv()
102
- const featureOutput = await runSessionTitleCommand({
100
+ const featureOutput = await runHarnessCommand({
103
101
  command: [executable, 'features', 'list'],
104
102
  cwd: tempDir,
105
103
  signal: input.abortController.signal,
@@ -111,7 +109,7 @@ export async function generateCodexSessionTitle(input: {
111
109
  const schemaPath = join(tempDir, 'schema.json')
112
110
  const outputPath = join(tempDir, 'result.json')
113
111
  await Bun.write(schemaPath, JSON.stringify(SESSION_TITLE_SCHEMA))
114
- const output = await runSessionTitleCommand({
112
+ const output = await runHarnessCommand({
115
113
  command: codexSessionTitleCommand({
116
114
  executable,
117
115
  cwd: tempDir,
@@ -128,7 +126,7 @@ export async function generateCodexSessionTitle(input: {
128
126
  return parseGeneratedSessionTitleJson(await Bun.file(outputPath).text())
129
127
  } finally {
130
128
  clearTimeout(timer)
131
- if (tempDir) await removeSessionTitleTempDir(tempDir).catch(() => {})
129
+ if (tempDir) await removeHarnessTempDir(tempDir).catch(() => {})
132
130
  }
133
131
  }
134
132
 
@@ -1,3 +1,4 @@
1
+ import type { SpeedMode } from '@/lib/types'
1
2
  import type { MessageAttachment } from '@/lib/types'
2
3
  import { attachmentLabel } from '@/lib/moi-attachments'
3
4
  // Live state per (workspaceId, sessionId): display history, native lifecycle,
@@ -23,7 +24,7 @@ import {
23
24
  type CodexTokenUsage,
24
25
  type CodexTurn,
25
26
  type SubagentReplay,
26
- codexServiceTierForFastMode,
27
+ codexServiceTierForSpeedMode,
27
28
  codexItemToNotice,
28
29
  codexItemToTurn,
29
30
  codexThreadToEvents,
@@ -905,7 +906,7 @@ type CodexSendInput = {
905
906
  optimisticId?: string
906
907
  model?: string
907
908
  effort?: string
908
- fastMode?: boolean
909
+ speedMode?: SpeedMode
909
910
  stream?: boolean
910
911
  // Rendered through native additionalContext or the legacy text envelope.
911
912
  context?: MoiContext
@@ -936,7 +937,7 @@ async function sendMessage(
936
937
  : undefined
937
938
  const userInput = buildUserInput(prepared)
938
939
  const { parts } = prepared
939
- const serviceTier = codexServiceTierForFastMode(input.fastMode)
940
+ const serviceTier = codexServiceTierForSpeedMode(input.speedMode)
940
941
 
941
942
  let rec: SessionRecord
942
943
  try {
@@ -948,15 +949,14 @@ async function sendMessage(
948
949
  cwd: input.workspacePath,
949
950
  ...CODEX_THREAD_ACCESS,
950
951
  ...(input.model ? { model: input.model } : {}),
951
- ...(serviceTier !== undefined ? { serviceTier } : {})
952
+ serviceTier
952
953
  })
953
954
  const realId = started.thread.id
954
955
  if (realId !== input.sessionId) {
955
956
  aliases.set(recKey(input.workspaceId, input.sessionId), realId)
956
957
  sendLanes.set(recKey(input.workspaceId, realId), lane)
957
958
  await renameSessionReferences(
958
- input.workspaceId,
959
- input.workspacePath,
959
+ { id: input.workspaceId, path: input.workspacePath },
960
960
  input.sessionId,
961
961
  realId
962
962
  )
@@ -971,13 +971,13 @@ async function sendMessage(
971
971
  })
972
972
  rec.model = started.model ?? input.model
973
973
  if (
974
- (input.model || input.effort || input.fastMode !== undefined) &&
975
- !(await hasSessionConfig(input.workspacePath, realId))
974
+ (input.model || input.effort || input.speedMode !== undefined) &&
975
+ !(await hasSessionConfig({ id: input.workspaceId, path: input.workspacePath }, realId))
976
976
  ) {
977
- await saveSessionConfig(input.workspacePath, realId, {
977
+ await saveSessionConfig({ id: input.workspaceId, path: input.workspacePath }, realId, {
978
978
  model: input.model,
979
979
  effort: input.effort,
980
- fastMode: input.fastMode
980
+ speedMode: input.speedMode
981
981
  })
982
982
  }
983
983
  } else {
@@ -1075,7 +1075,7 @@ async function sendMessage(
1075
1075
  summary: 'detailed',
1076
1076
  ...(input.model ? { model: input.model } : {}),
1077
1077
  ...(input.effort ? { effort: input.effort } : {}),
1078
- ...(serviceTier !== undefined ? { serviceTier } : {})
1078
+ serviceTier
1079
1079
  }
1080
1080
  if (rec.activeTurnId) {
1081
1081
  try {
@@ -0,0 +1,45 @@
1
+ import { join } from 'node:path'
2
+ import { tmpdir } from 'node:os'
3
+ import { chmod, mkdtemp, rm } from 'node:fs/promises'
4
+
5
+ import { agentCommand } from '../agent-launcher'
6
+
7
+ export async function runHarnessCommand(input: {
8
+ command: readonly string[]
9
+ cwd: string
10
+ stdin?: string
11
+ signal: AbortSignal
12
+ env?: Record<string, string | undefined>
13
+ }): Promise<string | null> {
14
+ if (input.signal.aborted) return null
15
+ try {
16
+ const proc = Bun.spawn(agentCommand(input.command), {
17
+ cwd: input.cwd,
18
+ stdin: new Blob([input.stdin ?? '']),
19
+ stdout: 'pipe',
20
+ stderr: 'ignore',
21
+ signal: input.signal,
22
+ env: input.env,
23
+ maxBuffer: 128 * 1024
24
+ })
25
+ const [exitCode, stdout] = await Promise.all([proc.exited, new Response(proc.stdout).text()])
26
+ return exitCode === 0 && !input.signal.aborted ? stdout : null
27
+ } catch {
28
+ return null
29
+ }
30
+ }
31
+
32
+ // On managed machines the command runs as the agent's user, which is
33
+ // neither the folder's owner nor in its group, so the folder is open to
34
+ // everyone: the agent works in it and Codex writes its answer there. It holds
35
+ // only temporary inputs and output for one run. Moi stays the owner, which is
36
+ // what lets it remove the folder from /tmp afterwards.
37
+ export async function createHarnessTempDir(): Promise<string> {
38
+ const path = await mkdtemp(join(tmpdir(), 'moi-harness-'))
39
+ await chmod(path, 0o777)
40
+ return path
41
+ }
42
+
43
+ export async function removeHarnessTempDir(path: string): Promise<void> {
44
+ await rm(path, { recursive: true, force: true })
45
+ }