moi-computer 0.7.0 → 0.8.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 (123) hide show
  1. package/README.md +2 -2
  2. package/client/api/workspace-keys.ts +1 -2
  3. package/client/app/AppRouter.tsx +10 -3
  4. package/client/app/routes/HomeRoute.tsx +1 -1
  5. package/client/app/shell/SidebarLayout.tsx +2 -14
  6. package/client/components/shared/BottomPanel.tsx +2 -1
  7. package/client/components/shared/Composer.tsx +20 -7
  8. package/client/components/shared/PanelHeader.tsx +8 -1
  9. package/client/components/ui/button.tsx +3 -3
  10. package/client/components/ui/dialog.tsx +1 -1
  11. package/client/components/ui/dropdown-menu.tsx +2 -2
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/popover.tsx +1 -1
  14. package/client/components/ui/resizable.tsx +40 -0
  15. package/client/features/applets/AppletMount.tsx +9 -22
  16. package/client/features/applets/applet-cache.ts +7 -0
  17. package/client/features/applets/applet-styles.ts +21 -1
  18. package/client/features/applets/useApplet.ts +1 -1
  19. package/client/features/chat/ChatEmptyState.tsx +9 -11
  20. package/client/features/chat/ChatPanel.tsx +76 -48
  21. package/client/features/chat/ChatPopup.tsx +16 -2
  22. package/client/features/chat/ChatPromptBubbles.tsx +6 -8
  23. package/client/features/chat/ChatSelector.tsx +25 -8
  24. package/client/features/chat/ModelPicker.tsx +5 -4
  25. package/client/features/chat/TurnView.tsx +108 -13
  26. package/client/features/chat/api.ts +1 -18
  27. package/client/features/chat/chat-send.ts +2 -2
  28. package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +24 -9
  29. package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
  30. package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
  31. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
  32. package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
  33. package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
  34. package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
  35. package/client/features/chat/group-turns.ts +46 -28
  36. package/client/features/chat/interleave-notices.ts +84 -0
  37. package/client/features/chat/model-order.ts +9 -3
  38. package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
  39. package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
  40. package/client/features/chat/tool-group/format.ts +23 -7
  41. package/client/features/chat/useAppletChatMessage.ts +11 -16
  42. package/client/features/chat/useChat.ts +3 -7
  43. package/client/features/dev/ChatStatesPage.tsx +428 -0
  44. package/client/features/dev/DevIndexPage.tsx +52 -0
  45. package/client/features/dev/DevRoutes.tsx +6 -3
  46. package/client/features/dev/HarnessDebugPage.tsx +3 -3
  47. package/client/features/dev/chat-states-fixtures.ts +744 -0
  48. package/client/features/home/api.ts +0 -10
  49. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
  50. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
  51. package/client/features/scratchpad/Scratchpad.tsx +5 -3
  52. package/client/features/scratchpad/scratch-session.ts +71 -0
  53. package/client/features/views/ViewBuilderTab.tsx +5 -4
  54. package/client/features/views/ViewManager.tsx +258 -0
  55. package/client/features/views/useViewBuilderActions.ts +2 -2
  56. package/client/features/views/view-residency.ts +77 -0
  57. package/client/features/widgets/WidgetFrame.tsx +6 -2
  58. package/client/features/workspace/CustomizePanel.tsx +40 -24
  59. package/client/features/workspace/WorkspaceLayoutContext.tsx +12 -2
  60. package/client/features/workspace/WorkspaceScreen.tsx +131 -201
  61. package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
  62. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  63. package/client/features/workspace/api.ts +33 -8
  64. package/client/features/workspace/useFitsSplitLayout.ts +31 -5
  65. package/client/index.css +5 -2
  66. package/client/lib/flags.ts +4 -3
  67. package/client/runtime/useWorkspaceEvents.ts +18 -1
  68. package/client/runtime/workspace-theme.ts +29 -10
  69. package/client/store/ui.ts +5 -1
  70. package/client/theme.css +96 -6
  71. package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
  72. package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
  73. package/dist/chunk-gny990qx.css +1 -0
  74. package/dist/chunk-gt7n06ef.js +1 -0
  75. package/dist/{chunk-rxvx4ta9.js → chunk-kkj86722.js} +75 -75
  76. package/dist/chunk-n7pga5x3.js +80 -0
  77. package/dist/chunk-xeyxk7ep.js +10 -0
  78. package/dist/{chunk-w3tnv51j.js → chunk-xzx7c9hq.js} +1 -1
  79. package/dist/index.html +1 -1
  80. package/lib/format.ts +17 -1
  81. package/lib/themes.ts +123 -51
  82. package/lib/types.ts +40 -13
  83. package/lib/workspace-layout.ts +2 -2
  84. package/package.json +6 -4
  85. package/server/agent.ts +199 -0
  86. package/server/api.ts +38 -90
  87. package/server/bundler/build-applet.ts +7 -4
  88. package/server/cli.ts +46 -15
  89. package/server/control.ts +13 -6
  90. package/server/env-apply.ts +4 -0
  91. package/server/harness/README.md +28 -12
  92. package/server/harness/claude-code/auth.ts +54 -0
  93. package/server/harness/claude-code/index.ts +6 -1
  94. package/server/harness/codex/adapter.ts +9 -1
  95. package/server/harness/codex/auth.ts +50 -0
  96. package/server/harness/codex/index.ts +6 -1
  97. package/server/harness/codex/session.ts +33 -14
  98. package/server/harness/openclaw/NOTES.md +518 -187
  99. package/server/harness/openclaw/adapter.ts +125 -31
  100. package/server/harness/openclaw/compat.ts +99 -0
  101. package/server/harness/openclaw/cron-view.ts +78 -0
  102. package/server/harness/openclaw/discovery.ts +145 -52
  103. package/server/harness/openclaw/gateway.ts +224 -36
  104. package/server/harness/openclaw/index.ts +56 -21
  105. package/server/harness/openclaw/session.ts +971 -55
  106. package/server/harness/openclaw/strip.ts +87 -15
  107. package/server/harness/openclaw/thinking.ts +198 -0
  108. package/server/harness/types.ts +10 -5
  109. package/server/layout.ts +5 -2
  110. package/server/moi-scaffold.ts +1 -1
  111. package/server/registry.ts +0 -20
  112. package/server/theme.ts +24 -27
  113. package/workspace/.claude/skills/moi-workspace/DESIGN.md +100 -53
  114. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
  115. package/client/features/dev/PixelPainter.tsx +0 -94
  116. package/client/features/dev/PlaygroundPage.tsx +0 -69
  117. package/dist/chunk-175bm057.js +0 -27
  118. package/dist/chunk-55sh4dty.js +0 -2
  119. package/dist/chunk-afgbg75t.js +0 -50
  120. package/dist/chunk-agtetn7n.css +0 -1
  121. package/dist/chunk-dfs36zgc.js +0 -1
  122. package/dist/chunk-exj6hr30.js +0 -9
  123. package/dist/chunk-m11ckkxd.js +0 -51
@@ -1 +1 @@
1
- import{Xc as t}from"/chunk-9y2zbzqz.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function e(r){let{mount:a}=await import("/chunk-175bm057.js");a(r)}globalThis.__init=e;
1
+ import{Ic as t}from"/chunk-35fq49qa.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function e(r){let{mount:a}=await import("/chunk-n7pga5x3.js");a(r)}globalThis.__init=e;
package/dist/index.html CHANGED
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </script>
23
23
 
24
- <link rel="stylesheet" crossorigin href="/chunk-agtetn7n.css"><script type="module" crossorigin src="/chunk-w3tnv51j.js"></script></head>
24
+ <link rel="stylesheet" crossorigin href="/chunk-gny990qx.css"><script type="module" crossorigin src="/chunk-xzx7c9hq.js"></script></head>
25
25
  <body>
26
26
  <div id="root"></div>
27
27
 
package/lib/format.ts CHANGED
@@ -51,7 +51,17 @@ export type Citation = { url?: string; title?: string; quote?: string }
51
51
 
52
52
  export type Part =
53
53
  | { type: 'text'; text: string; citations?: Citation[] }
54
- | { type: 'reasoning'; text: string; redacted?: boolean; signature?: string }
54
+ // `redacted` marks reasoning the backend acknowledges but won't hand over:
55
+ // Anthropic's `redacted_thinking`, and the codex app-server's `Reasoning`
56
+ // item, which reports that the model thought (and for how long) but carries
57
+ // no text. Such a part has empty `text` and renders as a duration, not a body.
58
+ | {
59
+ type: 'reasoning'
60
+ text: string
61
+ redacted?: boolean
62
+ signature?: string
63
+ durationMs?: number
64
+ }
55
65
  | { type: 'tool-call'; call: ToolCall }
56
66
  | { type: 'file'; mediaType: string; url: string; filename?: string }
57
67
  | { type: 'source-url'; url: string; title?: string; sourceId: string }
@@ -87,6 +97,9 @@ export type TurnMeta = {
87
97
  model?: string
88
98
  provider?: string
89
99
  stopReason?: string
100
+ // Agent-run duration. Derived from transcript timestamps when available;
101
+ // Codex supplies its native duration because its transcript items lack them.
102
+ durationMs?: number
90
103
  usage?: { inputTokens?: number; outputTokens?: number; totalTokens?: number; costUsd?: number }
91
104
  // The API message id (`msg_...`) that produced this assistant turn, when the
92
105
  // backend reports one. NOT the Turn `id`. Used to reconcile a live streaming
@@ -143,6 +156,9 @@ export type SystemNotice =
143
156
  error?: string
144
157
  }
145
158
  | { id: string; kind: 'compact'; at: string; metadata?: unknown }
159
+ // Mid-session model switch observed on the backend (e.g. OpenClaw
160
+ // `sessions.patch { model }` — from moi's picker or any other client).
161
+ | { id: string; kind: 'model-change'; at: string; model: string; prev?: string }
146
162
  | {
147
163
  id: string
148
164
  kind: 'hook'
package/lib/themes.ts CHANGED
@@ -1,85 +1,131 @@
1
- import { colord, extend } from 'colord'
2
- import a11yPlugin from 'colord/plugins/a11y'
1
+ import { wcagLuminance } from 'culori'
3
2
 
4
- // Registers optional WCAG helpers such as luminance() on Colord.
5
- extend([a11yPlugin])
6
-
7
- export type FontTheme = 'default' | 'serif' | 'mono' | 'blobby' | 'geometric' | 'awkward'
3
+ export type FontTheme =
4
+ | 'sans'
5
+ | 'serif'
6
+ | 'mono'
7
+ | 'geometric'
8
+ | 'rounded'
9
+ | 'blobby'
10
+ | 'awkward'
11
+ | 'comic'
8
12
 
9
13
  export type FontThemeConfig = {
10
14
  label: string
11
- feel: string
12
15
  sans: string
13
16
  mono: string
14
17
  googleFontsQuery?: string // passed as `family=` param to Google Fonts API
15
18
  }
16
19
 
17
20
  export const FONT_THEMES: Record<FontTheme, FontThemeConfig> = {
18
- default: {
19
- label: 'Default',
20
- feel: 'System font',
21
+ sans: {
22
+ label: 'Sans',
21
23
  sans: 'system-ui',
22
24
  mono: 'Geist Mono',
23
25
  googleFontsQuery: 'Geist+Mono:wght@400;500'
24
26
  },
25
27
  serif: {
26
28
  label: 'Serif',
27
- feel: 'Literata',
28
29
  sans: 'Literata',
29
30
  mono: 'Geist Mono',
30
31
  googleFontsQuery: 'Literata:wght@400;600;700&family=Geist+Mono:wght@400;500'
31
32
  },
32
33
  mono: {
33
34
  label: 'Mono',
34
- feel: 'Geist Mono',
35
35
  sans: 'Geist Mono',
36
36
  mono: 'Geist Mono',
37
37
  googleFontsQuery: 'Geist+Mono:wght@400;500;600'
38
38
  },
39
- blobby: {
40
- label: 'Blobby',
41
- feel: 'Sour Gummy',
42
- sans: 'Sour Gummy',
43
- mono: 'Azeret Mono',
44
- googleFontsQuery: 'Sour+Gummy:wght@400;500;600&family=Azeret+Mono:wght@400;500'
45
- },
46
39
  geometric: {
47
40
  label: 'Geometric',
48
- feel: 'Manrope',
49
41
  sans: 'Manrope',
50
42
  mono: 'Geist Mono',
51
43
  googleFontsQuery: 'Manrope:wght@400;500;600&family=Geist+Mono:wght@400;500'
52
44
  },
45
+ rounded: {
46
+ label: 'Rounded',
47
+ sans: 'SN Pro',
48
+ mono: 'Geist Mono',
49
+ googleFontsQuery: 'SN+Pro:wght@400;500;600&family=Geist+Mono:wght@400;500'
50
+ },
51
+ blobby: {
52
+ label: 'Blobby',
53
+ sans: 'Sour Gummy',
54
+ mono: 'Azeret Mono',
55
+ googleFontsQuery: 'Sour+Gummy:wght@400;500;600&family=Azeret+Mono:wght@400;500'
56
+ },
53
57
  awkward: {
54
58
  label: 'Awkward',
55
- feel: 'Averia Sans Libre',
56
59
  sans: 'Averia Sans Libre',
57
60
  mono: 'Azeret Mono',
58
61
  googleFontsQuery: 'Averia+Sans+Libre:wght@400;500;600&family=Azeret+Mono:wght@400;500'
62
+ },
63
+ comic: {
64
+ label: 'Comic',
65
+ sans: 'Comic Sans MS, Comic Sans, cursive',
66
+ mono: 'Geist Mono',
67
+ googleFontsQuery: 'Geist+Mono:wght@400;500'
59
68
  }
60
69
  }
61
70
 
62
- export type ColorTheme = 'default' | 'paper' | 'sand' | 'rose' | 'lavender' | 'mint' | 'sky'
71
+ export type RadiusTheme = 'squishy' | 'soft' | 'subtle' | 'square'
63
72
 
64
- function foregroundForPrimary(primary: string): string {
65
- if (!/^#[0-9a-f]{6}$/i.test(primary)) {
66
- throw new Error(`Primary theme color must use #rrggbb: ${primary}`)
67
- }
73
+ export type RadiusThemeConfig = {
74
+ label: string
75
+ radius: string
76
+ }
77
+
78
+ export const RADIUS_THEMES: Record<RadiusTheme, RadiusThemeConfig> = {
79
+ squishy: { label: 'Squishy', radius: '0.875rem' },
80
+ soft: { label: 'Soft', radius: '0.625rem' },
81
+ subtle: { label: 'Subtle', radius: '0.375rem' },
82
+ square: { label: 'Square', radius: '0' }
83
+ }
68
84
 
69
- return colord(primary).luminance() > 0.24 ? '#000000' : '#ffffff'
85
+ export type ColorTheme =
86
+ | 'default'
87
+ | 'paper'
88
+ | 'rose'
89
+ | 'tangerine'
90
+ | 'sand'
91
+ | 'mint'
92
+ | 'sky'
93
+ | 'lavender'
94
+
95
+ export type ThemeColorMode = 'workspace' | 'widget'
96
+
97
+ export const DEFAULT_PRIMARY_COLOR = 'oklch(0.205 0 0)'
98
+
99
+ function foregroundForPrimary(primary: string): string {
100
+ return wcagLuminance(primary) > 0.3 ? 'oklch(0 0 0)' : 'oklch(1 0 0)'
70
101
  }
71
102
 
72
103
  const THEME_COLOR_DERIVATIONS = {
73
- primary: primary => primary,
74
- primaryForeground: primary => foregroundForPrimary(primary),
75
- background: () => 'color-mix(in oklch, var(--primary) 3%, white 97%)',
76
- foreground: () => 'color-mix(in oklch, var(--primary) 24%, black 76%)',
77
- muted: () => 'color-mix(in oklch, var(--background) 95%, var(--foreground) 5%)',
78
- mutedForeground: () => 'color-mix(in oklch, var(--background) 58%, var(--foreground) 42%)',
79
- accent: () => 'color-mix(in oklch, var(--primary) 4%, var(--foreground) 4%)'
80
- } satisfies Record<string, (primary: string) => string>
81
-
82
- export type ThemeColorToken = keyof typeof THEME_COLOR_DERIVATIONS
104
+ workspace: {
105
+ primary: primary => primary,
106
+ primaryForeground: primary => foregroundForPrimary(primary),
107
+ background: () => 'color-mix(var(--primary) 3%, oklch(1 0 0) 97%)',
108
+ foreground: () => 'color-mix(var(--primary) 20%, oklch(0 0 0) 80%)',
109
+ muted: () => 'color-mix(var(--background) 96%, var(--foreground) 4%)',
110
+ mutedForeground: () => 'color-mix(var(--background) 50%, var(--foreground) 50%)',
111
+ accent: () => 'color-mix(var(--primary) 4%, var(--foreground) 4%)',
112
+ accentForeground: () => 'var(--foreground)',
113
+ border: () => 'color-mix(var(--foreground) 7%, transparent)'
114
+ },
115
+ widget: {
116
+ background: primary => primary,
117
+ foreground: primary => foregroundForPrimary(primary),
118
+ primary: () => 'color-mix(var(--background) 3%, oklch(1 0 0) 97%)',
119
+ primaryForeground: () => 'color-mix(var(--background) 20%, oklch(0 0 0) 80%)',
120
+ muted: () => 'color-mix(var(--background) 97%, var(--foreground) 3%)',
121
+ mutedForeground: () => 'color-mix(var(--background) 50%, var(--foreground) 50%)',
122
+ accent: () => 'color-mix(var(--primary) 4%, var(--foreground) 4%)',
123
+ accentForeground: () => 'var(--foreground)',
124
+ border: () => 'color-mix(var(--foreground) 15%, transparent)'
125
+ }
126
+ } satisfies Record<ThemeColorMode, Record<string, (primary: string) => string>>
127
+
128
+ export type ThemeColorToken = keyof (typeof THEME_COLOR_DERIVATIONS)['workspace']
83
129
  export type ThemeColors = Record<ThemeColorToken, string>
84
130
 
85
131
  export type ColorThemeConfig = {
@@ -88,12 +134,18 @@ export type ColorThemeConfig = {
88
134
  primary?: string
89
135
  }
90
136
 
91
- export const THEME_COLOR_TOKENS = Object.keys(THEME_COLOR_DERIVATIONS) as ThemeColorToken[]
137
+ export const THEME_COLOR_TOKENS = Object.keys(
138
+ THEME_COLOR_DERIVATIONS.workspace
139
+ ) as ThemeColorToken[]
92
140
 
93
- export function deriveThemeColors(primary: string): ThemeColors {
141
+ export function deriveThemeColors(
142
+ primary: string,
143
+ mode: ThemeColorMode = 'workspace'
144
+ ): ThemeColors {
94
145
  const colors = {} as ThemeColors
146
+ const derivations = THEME_COLOR_DERIVATIONS[mode]
95
147
  for (const token of THEME_COLOR_TOKENS) {
96
- colors[token] = THEME_COLOR_DERIVATIONS[token](primary)
148
+ colors[token] = derivations[token](primary)
97
149
  }
98
150
  return colors
99
151
  }
@@ -102,26 +154,46 @@ export const COLOR_THEMES: Record<ColorTheme, ColorThemeConfig> = {
102
154
  default: { label: 'Default' },
103
155
  paper: {
104
156
  label: 'Paper',
105
- primary: '#453521'
106
- },
107
- sand: {
108
- label: 'Sand',
109
- primary: '#ff8700'
157
+ primary: 'oklch(0.4328 0.0351 66.67)'
110
158
  },
111
159
  rose: {
112
160
  label: 'Rose',
113
- primary: '#f13c3c'
161
+ primary: 'oklch(0.6322 0.2171 26.02)'
114
162
  },
115
- lavender: {
116
- label: 'Lavender',
117
- primary: '#9051ff'
163
+ tangerine: {
164
+ label: 'Tangerine',
165
+ primary: 'oklch(0.6886 0.22 37.15)'
166
+ },
167
+ sand: {
168
+ label: 'Sand',
169
+ primary: 'oklch(0.8334 0.1271 67.80)'
118
170
  },
119
171
  mint: {
120
172
  label: 'Tropics',
121
- primary: '#009155'
173
+ primary: 'oklch(0.5774 0.1399 156.06)'
122
174
  },
123
175
  sky: {
124
176
  label: 'Sky',
125
- primary: '#007ae3'
177
+ primary: 'oklch(0.5824 0.1830 253.59)'
178
+ },
179
+ lavender: {
180
+ label: 'Lavender',
181
+ primary: 'oklch(0.6025 0.2426 294.58)'
126
182
  }
127
183
  }
184
+
185
+ export type WorkspaceTheme = {
186
+ font: FontTheme
187
+ color: ColorTheme
188
+ radius: RadiusTheme
189
+ }
190
+
191
+ export const DEFAULT_WORKSPACE_THEME: WorkspaceTheme = {
192
+ font: 'sans',
193
+ color: 'default',
194
+ radius: 'soft'
195
+ }
196
+
197
+ export function resolveWorkspaceTheme(theme?: Partial<WorkspaceTheme>): WorkspaceTheme {
198
+ return { ...DEFAULT_WORKSPACE_THEME, ...theme }
199
+ }
package/lib/types.ts CHANGED
@@ -256,6 +256,12 @@ export type SessionInfo = {
256
256
  summary: string
257
257
  lastModified: number
258
258
  cwd?: string
259
+ // Where the conversation originates when the backend routes external
260
+ // channels into it (OpenClaw: telegram/irc/discord/…; absent = app chat).
261
+ origin?: { provider: string; label?: string }
262
+ // Session flavor beyond a plain chat: scheduled cron runs and spawned
263
+ // subagent sessions get a badge in the chat selector.
264
+ flavor?: 'chat' | 'cron' | 'subagent'
259
265
  }
260
266
 
261
267
  // Per-session agent settings, persisted server-side in one global file in moi's
@@ -392,11 +398,22 @@ export type WorkspaceSkillsUpdateFailure = WorkspaceSkillsStatus & {
392
398
  error: string
393
399
  }
394
400
 
395
- // Whether an agent backend's runtime is installed on this machine. `reason` is
396
- // user-facing copy explaining what to do next. Surfaced by
397
- // GET /api/workspaces/create (per-type map, drives setup dialogs) and
398
- // GET /api/workspaces/:id/availability (disables Send in existing workspaces).
399
- export type HarnessAvailability = { available: true } | { available: false; reason: string }
401
+ // Setup checks only runtime availability. Workspace checks may also attach a
402
+ // login command, which makes the composer show its Sign in action.
403
+ export type HarnessAvailability =
404
+ | { available: true }
405
+ | { available: false; reason: string; loginCommand?: string }
406
+
407
+ // Codex returns a URL for the browser. Claude opens it from its own CLI.
408
+ export type HarnessLogin = { url?: string }
409
+
410
+ // The server-owned login ceremony, one per workspace. `pending` means a watch
411
+ // loop is re-probing the provider until the login lands or the deadline
412
+ // passes; transitions arrive as `agent:updated` events, so every tab shows
413
+ // the same ceremony without polling.
414
+ export type AgentLoginState =
415
+ | { state: 'pending'; url?: string }
416
+ | { state: 'failed'; reason: string }
400
417
 
401
418
  // One MCP server's connection status, as surfaced by GET /api/workspaces/:id/mcp
402
419
  // (a subset of the agent SDK's McpServerStatus — only what the UI renders).
@@ -503,7 +520,7 @@ export type WorkspaceTabsState = {
503
520
  active: WorkspaceTabId
504
521
  }
505
522
 
506
- export type { FontTheme, ColorTheme } from './themes'
523
+ export type { ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from './themes'
507
524
 
508
525
  export type WorkspaceLayout = {
509
526
  version: 1
@@ -533,10 +550,7 @@ export type WorkspaceLayout = {
533
550
  selectedEffort?: string
534
551
  // Fast-mode default for new sessions. Undefined inherits the provider setting.
535
552
  selectedFastMode?: boolean
536
- theme?: {
537
- font: import('./themes').FontTheme
538
- primary?: string
539
- }
553
+ theme?: import('./themes').WorkspaceTheme
540
554
  // Widget thumbnails captured client-side from the live grid, used for
541
555
  // home-screen previews. Saved through their own endpoint (PUT
542
556
  // .../thumbnails), never through the layout PUT.
@@ -616,6 +630,10 @@ export type Model = {
616
630
  // the SDK under-types (e.g. 'xhigh'), so it stays string[].
617
631
  supportsEffort?: boolean
618
632
  supportedEffortLevels?: string[]
633
+ // Provider-resolved effort default when the user hasn't picked one (OpenClaw
634
+ // `thinkingDefault`, which differs per model — `low`/`medium`/`off`). Must be
635
+ // one of `supportedEffortLevels`.
636
+ defaultEffort?: string
619
637
  supportsAdaptiveThinking?: boolean
620
638
  supportsFastMode?: boolean
621
639
  // Provider-resolved default when moi has no stored Fast-mode preference.
@@ -623,10 +641,19 @@ export type Model = {
623
641
  supportsAutoMode?: boolean
624
642
  }
625
643
 
626
- // GET /api/workspaces/:id/models payload.
627
- export type WorkspaceModels = {
628
- // The agent backend that produced this list — matches the workspace provider.
644
+ // GET /api/workspaces/:id/agent payload — everything the client needs to know
645
+ // about the workspace's agent backend in one request at workspace open.
646
+ // `models` and capabilities are stable per process; `availability` and `login`
647
+ // are the volatile part, kept fresh after load by `agent:updated` events
648
+ // instead of refetches.
649
+ export type WorkspaceAgent = {
650
+ // The agent backend that produced this snapshot — matches the workspace
651
+ // provider.
629
652
  provider: WorkspaceType
653
+ // Runtime presence and provider auth state, from the server-side cache.
654
+ availability: HarnessAvailability
655
+ // Present while a login ceremony is in flight or after one failed.
656
+ login?: AgentLoginState
630
657
  models: Model[]
631
658
  // Whether this provider supports live token-by-token streaming (the picker
632
659
  // shows the "Live typing" toggle only when true). Provider-wide, not per-model
@@ -1,14 +1,14 @@
1
1
  import type { WorkspaceLayout, WorkspaceTabsState } from './types'
2
2
 
3
3
  export function createDefaultWorkspaceTabs(): WorkspaceTabsState {
4
- return { open: ['agent', 'widgets'], active: 'agent' }
4
+ return { open: ['agent', 'widgets', 'scratchpad'], active: 'agent' }
5
5
  }
6
6
 
7
7
  export function createDefaultWorkspaceLayout(): WorkspaceLayout {
8
8
  return {
9
9
  version: 1,
10
10
  widgetGrid: [],
11
- layoutMode: 'fullscreen',
11
+ layoutMode: 'split',
12
12
  tabs: createDefaultWorkspaceTabs()
13
13
  }
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moi-computer",
3
- "version": "0.7.0",
3
+ "version": "0.8.1-next.0",
4
4
  "description": "Local AI workspace powered by the Claude Agent SDK, Bun, React, and Tailwind. Requires Bun.",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
@@ -69,8 +69,8 @@
69
69
  "citty": "^0.2.1",
70
70
  "class-variance-authority": "^0.7.1",
71
71
  "clsx": "^2.1.1",
72
- "colord": "^2.9.3",
73
72
  "conf": "^15.1.0",
73
+ "culori": "^4.0.2",
74
74
  "devalue": "^5.6.4",
75
75
  "env-paths": "^4.0.0",
76
76
  "frimousse": "^0.3.0",
@@ -89,13 +89,14 @@
89
89
  "react-grid-layout": "^2.2.3",
90
90
  "react-markdown": "^10.1.0",
91
91
  "react-resizable": "^3.1.3",
92
+ "react-resizable-panels": "^4.12.2",
92
93
  "rehype-highlight": "^7.0.2",
93
94
  "remark-gfm": "^4.0.1",
94
95
  "shadcn": "^4.13.0",
95
96
  "sharp": "^0.35.1",
96
97
  "sugar-high": "^1.2.1",
97
- "tailwind-merge": "^3.5.0",
98
- "tailwindcss": "^4.1.11",
98
+ "tailwind-merge": "^3.6.0",
99
+ "tailwindcss": "^4.3.3",
99
100
  "tldraw": "5.2.3",
100
101
  "tw-animate-css": "^1.4.0",
101
102
  "typescript": "^5.9.3",
@@ -107,6 +108,7 @@
107
108
  },
108
109
  "devDependencies": {
109
110
  "@types/bun": "latest",
111
+ "@types/culori": "^4.0.1",
110
112
  "@types/react": "^19",
111
113
  "@types/react-dom": "^19",
112
114
  "@types/react-grid-layout": "^2.1.0",
@@ -0,0 +1,199 @@
1
+ // Server-owned agent state: the availability cache and the login ceremony.
2
+ //
3
+ // The client never polls for auth. `GET /api/workspaces/:id/agent` serves the
4
+ // snapshot from this store (one probe per workspace inside the TTL, however
5
+ // many tabs are open); `POST .../auth/login` starts — or joins — the single
6
+ // ceremony per workspace. While a ceremony is pending, a watch loop re-probes
7
+ // the provider until the login lands or the deadline passes, and every
8
+ // transition is pushed to all tabs as an `agent:updated` event on the
9
+ // workspace events socket.
10
+ import type {
11
+ AgentLoginState,
12
+ HarnessAvailability,
13
+ HarnessLogin,
14
+ WorkspaceEntry
15
+ } from '@/lib/types'
16
+
17
+ import { publishEvent } from './events'
18
+ import { harnessFor } from './harness/registry'
19
+
20
+ export type AgentUpdatedEvent = {
21
+ type: 'agent:updated'
22
+ workspaceId: string
23
+ availability: HarnessAvailability
24
+ login?: AgentLoginState
25
+ }
26
+
27
+ // Only the fields the probe/login provider calls actually read — lets callers
28
+ // that don't have a full registry entry on hand (e.g. a harness session
29
+ // reacting to a mid-conversation send failure) still trigger a refresh.
30
+ export type AgentWorkspace = Pick<WorkspaceEntry, 'id' | 'path' | 'type'>
31
+
32
+ export type AgentStoreOptions = {
33
+ probe: (ws: AgentWorkspace) => Promise<HarnessAvailability>
34
+ startLogin: (ws: AgentWorkspace) => Promise<HarnessLogin>
35
+ publish: (event: AgentUpdatedEvent) => void
36
+ availabilityTtlMs?: number
37
+ loginPollMs?: number
38
+ loginDeadlineMs?: number
39
+ }
40
+
41
+ type LoginCeremony = {
42
+ state: AgentLoginState
43
+ // The in-flight provider call; joiners await it instead of starting a
44
+ // second flow. Cleared once settled.
45
+ starting?: Promise<HarnessLogin>
46
+ stop: () => void
47
+ }
48
+
49
+ type AgentEntry = {
50
+ cached?: { value: HarnessAvailability; checkedAt: number }
51
+ // In-flight probe, shared by concurrent callers.
52
+ probe?: Promise<HarnessAvailability>
53
+ login?: LoginCeremony
54
+ }
55
+
56
+ export function createAgentStore(options: AgentStoreOptions) {
57
+ const ttlMs = options.availabilityTtlMs ?? 30_000
58
+ const pollMs = options.loginPollMs ?? 2_000
59
+ const deadlineMs = options.loginDeadlineMs ?? 3 * 60_000
60
+ const entries = new Map<string, AgentEntry>()
61
+
62
+ function entryFor(workspaceId: string): AgentEntry {
63
+ let entry = entries.get(workspaceId)
64
+ if (!entry) {
65
+ entry = {}
66
+ entries.set(workspaceId, entry)
67
+ }
68
+ return entry
69
+ }
70
+
71
+ function publish(workspaceId: string, availability: HarnessAvailability) {
72
+ const login = entries.get(workspaceId)?.login?.state
73
+ options.publish({
74
+ type: 'agent:updated',
75
+ workspaceId,
76
+ availability,
77
+ ...(login ? { login } : {})
78
+ })
79
+ }
80
+
81
+ async function probeFresh(ws: AgentWorkspace): Promise<HarnessAvailability> {
82
+ const entry = entryFor(ws.id)
83
+ if (!entry.probe) {
84
+ entry.probe = options.probe(ws).finally(() => {
85
+ entry.probe = undefined
86
+ })
87
+ }
88
+ const value = await entry.probe
89
+ entry.cached = { value, checkedAt: Date.now() }
90
+ return value
91
+ }
92
+
93
+ async function getAvailability(ws: AgentWorkspace): Promise<HarnessAvailability> {
94
+ const entry = entryFor(ws.id)
95
+ if (entry.cached && Date.now() - entry.cached.checkedAt < ttlMs) {
96
+ return entry.cached.value
97
+ }
98
+ return probeFresh(ws)
99
+ }
100
+
101
+ // Bypass the TTL and push the result even if it's unchanged. For callers
102
+ // that suspect the cached snapshot is stale for a reason other than an env
103
+ // change (e.g. a send just failed, which can mean the provider was signed
104
+ // out from outside moi — a `codex logout` in a terminal, say).
105
+ async function refresh(ws: AgentWorkspace): Promise<HarnessAvailability> {
106
+ const value = await probeFresh(ws)
107
+ publish(ws.id, value)
108
+ return value
109
+ }
110
+
111
+ function getLogin(workspaceId: string): AgentLoginState | undefined {
112
+ return entries.get(workspaceId)?.login?.state
113
+ }
114
+
115
+ // Re-probe until the login lands or the deadline passes. One loop per
116
+ // ceremony; a replaced or completed ceremony stops its loop.
117
+ function watch(ws: AgentWorkspace, login: LoginCeremony) {
118
+ const deadline = Date.now() + deadlineMs
119
+ let stopped = false
120
+ let timer: ReturnType<typeof setTimeout>
121
+ login.stop = () => {
122
+ stopped = true
123
+ clearTimeout(timer)
124
+ }
125
+ const tick = async () => {
126
+ let value: HarnessAvailability
127
+ try {
128
+ value = await probeFresh(ws)
129
+ } catch {
130
+ value = { available: false, reason: 'Could not verify the login' }
131
+ }
132
+ if (stopped) return
133
+ const entry = entryFor(ws.id)
134
+ if (value.available) {
135
+ entry.login = undefined
136
+ publish(ws.id, value)
137
+ return
138
+ }
139
+ if (Date.now() >= deadline) {
140
+ // Keep the failed state so the composer can show it; the next
141
+ // startLogin replaces it.
142
+ login.state = { state: 'failed', reason: 'Sign-in did not complete. Try again' }
143
+ publish(ws.id, value)
144
+ return
145
+ }
146
+ timer = setTimeout(tick, pollMs)
147
+ timer.unref?.()
148
+ }
149
+ // Unref'd so a pending ceremony never keeps the process alive on its own.
150
+ timer = setTimeout(tick, pollMs)
151
+ timer.unref?.()
152
+ }
153
+
154
+ async function startLogin(ws: AgentWorkspace): Promise<HarnessLogin> {
155
+ const entry = entryFor(ws.id)
156
+ // Join the in-flight ceremony instead of starting a second provider flow
157
+ // (two tabs, a remount, a double-click — all land here).
158
+ const current = entry.login
159
+ if (current?.starting) return current.starting
160
+ if (current?.state.state === 'pending') return { url: current.state.url }
161
+
162
+ current?.stop()
163
+ const starting = options.startLogin(ws)
164
+ const login: LoginCeremony = { state: { state: 'pending' }, starting, stop: () => {} }
165
+ entry.login = login
166
+ try {
167
+ const result = await starting
168
+ login.starting = undefined
169
+ login.state = { state: 'pending', ...(result.url ? { url: result.url } : {}) }
170
+ publish(ws.id, entry.cached?.value ?? { available: false, reason: 'Waiting for sign-in' })
171
+ watch(ws, login)
172
+ return result
173
+ } catch (err) {
174
+ entry.login = undefined
175
+ throw err
176
+ }
177
+ }
178
+
179
+ // Drop the cached snapshot so the next read re-probes (e.g. after an env
180
+ // change swaps credentials).
181
+ function invalidate(workspaceId: string) {
182
+ const entry = entries.get(workspaceId)
183
+ if (entry) entry.cached = undefined
184
+ }
185
+
186
+ return { getAvailability, refresh, getLogin, startLogin, invalidate }
187
+ }
188
+
189
+ export type AgentStore = ReturnType<typeof createAgentStore>
190
+
191
+ export const agentStore = createAgentStore({
192
+ probe: async ws => (await harnessFor(ws).availability?.(ws)) ?? { available: true },
193
+ startLogin: ws => {
194
+ const start = harnessFor(ws).startLogin
195
+ if (!start) throw new Error('This agent requires terminal sign-in')
196
+ return start(ws)
197
+ },
198
+ publish: publishEvent
199
+ })