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
package/server/api.ts CHANGED
@@ -11,13 +11,14 @@ import type {
11
11
  SessionInfo,
12
12
  UploadInfo,
13
13
  ViewBuilderInput,
14
+ WorkspaceAgent,
14
15
  WorkspaceEntry,
15
- WorkspaceModels,
16
16
  WorkspaceType
17
17
  } from '@/lib/types'
18
18
  import type { MoiContext } from '@/lib/moi-context'
19
19
  import { viewBuilderDirectives } from '@/lib/view-builder-directives'
20
20
 
21
+ import { agentStore } from './agent'
21
22
  import { getAppSettings, pickAppSettingsPatch, saveAppSettings } from './app-settings'
22
23
  import { appletForModule, recordAppletError } from './applet-log'
23
24
  import { apiBaseFor, parseAppletTail, serveWorkspaceFile } from './applets'
@@ -36,7 +37,6 @@ import { getClientFrameLog, getWireLog } from './harness/debug'
36
37
  import { allHarnesses, harnessFor, isHarnessType } from './harness/registry'
37
38
  import { broadcast } from './state'
38
39
  import {
39
- discoverWorkspace,
40
40
  discoverWorkspaces,
41
41
  getWorkspace,
42
42
  listWorkspaces,
@@ -517,7 +517,11 @@ one.post('/sessions/:sessionId/archive', async c => {
517
517
  return c.body(null, 204)
518
518
  } catch (error) {
519
519
  console.error(`[api] archive chat failed for ${harness.id}`, error)
520
- return c.text('Couldn’t archive chat', 500)
520
+ // Harnesses translate backend refusals into actionable one-liners (e.g.
521
+ // OpenClaw: main chat not archivable, gateway too old) — surface them.
522
+ const message =
523
+ error instanceof Error && error.message ? error.message : 'Couldn’t archive chat'
524
+ return c.text(message, 500)
521
525
  }
522
526
  })
523
527
 
@@ -639,12 +643,18 @@ one.put('/env', async c => {
639
643
  return c.json(await getWorkspaceEnvView(ws.path, requiredEnvFor(ws.path)))
640
644
  })
641
645
 
642
- // Is the workspace's agent backend usable right now? (e.g. a codex workspace
643
- // on a machine without the codex CLI). The chat surfaces the `reason` as a
644
- // banner instead of letting the first send fail cold.
645
- one.get('/availability', async c => {
646
- const availability = await workspaceTypeAvailability(c.get('ws').type ?? 'claude-code')
647
- return c.json(availability satisfies HarnessAvailability)
646
+ // Start a provider login ceremony. Codex returns a browser OAuth URL for the
647
+ // host to open; Claude launches its browser flow through the CLI itself.
648
+ // Idempotent per workspace: a second call joins the pending ceremony instead
649
+ // of starting another provider flow. Completion is pushed as `agent:updated`.
650
+ one.post('/auth/login', async c => {
651
+ const ws = c.get('ws')
652
+ if (!harnessFor(ws).startLogin) return c.text('This agent requires terminal sign-in', 409)
653
+ try {
654
+ return c.json(await agentStore.startLogin(ws))
655
+ } catch (err) {
656
+ return c.text(err instanceof Error ? err.message : 'Could not start sign-in', 500)
657
+ }
648
658
  })
649
659
 
650
660
  one.get('/skills', async c => {
@@ -658,25 +668,33 @@ one.post('/skills/update', async c => {
658
668
  return c.json(result.status)
659
669
  })
660
670
 
661
- // Models the workspace's agent backend can run, normalized across providers.
662
- // OpenClaw queries the gateway catalog; everything else (Claude Code) reads the
663
- // account-wide Agent SDK model list.
664
- one.get('/models', async c => {
671
+ // The workspace's agent backend in one snapshot: provider, availability
672
+ // (runtime presence + auth, from the server-side cache), any in-flight login
673
+ // ceremony, the model catalog, and capabilities. One request at workspace
674
+ // open; the volatile parts stay fresh afterwards via `agent:updated` events,
675
+ // not refetches.
676
+ one.get('/agent', async c => {
665
677
  const ws = c.get('ws')
666
678
  const harness = harnessFor(ws)
667
679
  // A backend that can't answer (codex CLI missing, gateway down) degrades to
668
680
  // an empty catalog — the picker hides and chat surfaces the real problem via
669
681
  // the availability banner, instead of this endpoint 500ing on page load.
670
- const models = await harness.listModels(ws).catch(err => {
671
- console.error(`[api] listModels failed for ${harness.id}`, err)
672
- return []
673
- })
682
+ const [availability, models] = await Promise.all([
683
+ agentStore.getAvailability(ws),
684
+ harness.listModels(ws).catch(err => {
685
+ console.error(`[api] listModels failed for ${harness.id}`, err)
686
+ return []
687
+ })
688
+ ])
689
+ const login = agentStore.getLogin(ws.id)
674
690
  return c.json({
675
691
  provider: harness.id,
692
+ availability,
693
+ ...(login ? { login } : {}),
676
694
  models,
677
695
  supportsStreaming: harness.capabilities.supportsStreaming,
678
696
  supportsArchiving: Boolean(harness.archiveSession)
679
- } satisfies WorkspaceModels)
697
+ } satisfies WorkspaceAgent)
680
698
  })
681
699
 
682
700
  // Workspace identity (name). GET returns the current {name, icon}; PUT a JSON
@@ -933,14 +951,12 @@ async function harnessAvailability(): Promise<Record<string, HarnessAvailability
933
951
  }
934
952
 
935
953
  // Where `/workspace/create` places new folders — the client shows the resolved
936
- // location while the user types a name. `canChooseFolder` tells the UI whether
937
- // the native folder picker is available (macOS only for now). `availability`
938
- // lets the dialog disable backends whose runtime is missing.
954
+ // location while the user types a name. `availability` lets the dialog disable
955
+ // backends whose runtime is missing.
939
956
  workspaces.get('/create', async c =>
940
957
  c.json({
941
958
  root: CREATED_WORKSPACES_ROOT,
942
959
  displayRoot: tildify(CREATED_WORKSPACES_ROOT),
943
- canChooseFolder: process.platform === 'darwin',
944
960
  availability: await harnessAvailability()
945
961
  })
946
962
  )
@@ -976,74 +992,6 @@ workspaces.post('/create', async c => {
976
992
  return c.json(entry, 201)
977
993
  })
978
994
 
979
- // Guards against opening a second native picker while one is already up — a
980
- // duplicate request (e.g. a quick re-click) resolves as canceled instead of
981
- // spawning a second Finder dialog on top of the first.
982
- let folderPickerOpen = false
983
-
984
- export function isSameOriginRequest(req: Request): boolean {
985
- const site = req.headers.get('sec-fetch-site')
986
- if (site === 'cross-site') return false
987
- // Modern browsers state the relationship directly — trust it. Reaching the
988
- // Origin fallback below with a full-origin comparison would 403 every request
989
- // behind a TLS-terminating proxy (Cloudflare Tunnel, nginx, ngrok — see
990
- // client/lib/ws-url.ts): the browser sends `https://…` while `req.url` is
991
- // built from the plain-HTTP listener.
992
- if (site === 'same-origin') return true
993
- const origin = req.headers.get('origin')
994
- if (!origin) return true
995
- // Older browsers without sec-fetch-site: compare hosts only, since the
996
- // scheme the browser saw is unknowable behind TLS termination.
997
- try {
998
- return new URL(origin).host === new URL(req.url).host
999
- } catch {
1000
- return false
1001
- }
1002
- }
1003
-
1004
- // Open the OS-native folder picker so the user can choose an existing folder to
1005
- // import (the create dialog's "Use existing folder"). The server runs on the
1006
- // user's machine, so it can drive the real system dialog — the browser can't.
1007
- // Returns the same grouped provider discovery shape as `/discover`, or
1008
- // `{ canceled: true }` if the dialog is dismissed. macOS only for now.
1009
- workspaces.post('/choose-folder', async c => {
1010
- if (!isSameOriginRequest(c.req.raw)) return c.text('Forbidden', 403)
1011
- if (process.platform !== 'darwin') {
1012
- return c.text('Choosing a folder is only supported on macOS for now', 400)
1013
- }
1014
- if (folderPickerOpen) return c.json({ canceled: true })
1015
- folderPickerOpen = true
1016
- try {
1017
- // The picker is spawned by osascript, a background helper, so macOS won't
1018
- // give it focus by default. `tell me to activate` forces the script runner
1019
- // frontmost, and the short delay lets that settle before the panel opens so
1020
- // it appears focused rather than behind other windows.
1021
- const proc = Bun.spawn(
1022
- [
1023
- 'osascript',
1024
- '-e',
1025
- 'tell me to activate',
1026
- '-e',
1027
- 'delay 0.2',
1028
- '-e',
1029
- 'POSIX path of (choose folder with prompt "Select a project folder")'
1030
- ],
1031
- { stdout: 'pipe', stderr: 'pipe' }
1032
- )
1033
- const exitCode = await proc.exited
1034
- // osascript exits non-zero when the user presses Cancel.
1035
- if (exitCode !== 0) return c.json({ canceled: true })
1036
- const path = (await new Response(proc.stdout).text()).trim()
1037
- if (!path) return c.json({ canceled: true })
1038
- return c.json(await discoverWorkspace(path))
1039
- } catch (err) {
1040
- const message = err instanceof Error ? err.message : String(err)
1041
- return c.text(`Could not open the folder picker: ${message}`, 500)
1042
- } finally {
1043
- folderPickerOpen = false
1044
- }
1045
- })
1046
-
1047
995
  // `/:id` is registered after the static `/discover` so the literal path wins.
1048
996
  // `/api/workspaces/ws` (the live-event WebSocket) is intercepted by Bun's routes
1049
997
  // table before it ever reaches Hono, so it never collides with `:id`.
@@ -415,12 +415,11 @@ function appletRuntimePlugin(
415
415
  return { plugin, serverModules, assets }
416
416
  }
417
417
 
418
- // Path to the host's `@theme inline` block — shared with `client/index.css`.
419
- // Inlined into the widget's synthetic CSS at build time so Tailwind sees the
420
- // theme tokens.
418
+ // Shared Tailwind input for applet bundles. It maps semantic tokens and
419
+ // provides the same texture utilities available to host components.
421
420
  const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
422
421
 
423
- // Three things matter for widget styling:
422
+ // Three things matter for applet styling:
424
423
  // 1. The umbrella `@import 'tailwindcss'` brings in @layer theme + base +
425
424
  // utilities — which is what spacing/color utilities like `left-2.5`,
426
425
  // `gap-1.5`, `text-amber-500` need to resolve. The split
@@ -433,6 +432,7 @@ const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
433
432
  // means the widget's CSS does NOT redefine the underlying
434
433
  // `--background`/`--foreground` variables — those stay host-owned and
435
434
  // the widget picks them up from `:root` at runtime.
435
+ // The same shared file also defines texture utilities for both surfaces.
436
436
  // 3. Tailwind's auto-detection treats `.moi/` as a hidden directory
437
437
  // and skips it. An explicit `@source` bypasses the dot-dir + gitignore
438
438
  // filters.
@@ -461,6 +461,9 @@ async function writeSyntheticTailwindCss(
461
461
  // back to `@media (prefers-color-scheme: dark)`, which diverges from the
462
462
  // host and injects OS-preference media queries into the page.
463
463
  `@custom-variant dark (&:is(.dark *));`,
464
+ // Textures use their light-on-dark treatment in every widget, regardless
465
+ // of the widget's selected workspace color.
466
+ `@custom-variant dark-or-widget (&:is(.dark *, [data-widget-chrome] *));`,
464
467
  `@source "${sourceDir}";`
465
468
  ].join('\n')
466
469
  await Bun.write(cssPath, contents)
package/server/cli.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import './cli-colors' // must precede citty: sets NO_COLOR before its color flag is computed
3
3
  import { defineCommand, runMain, showUsage } from 'citty'
4
+ import { formatHex } from 'culori'
4
5
  import { parse as devalueParse } from 'devalue'
5
6
  import { existsSync } from 'node:fs'
6
7
  import { tmpdir } from 'node:os'
@@ -9,8 +10,14 @@ import pc from './cli-pc'
9
10
 
10
11
  import { isAgentCaller } from './agent-caller'
11
12
 
12
- import { COLOR_THEMES, FONT_THEMES, deriveThemeColors } from '@/lib/themes'
13
- import type { ColorTheme, FontTheme } from '@/lib/themes'
13
+ import {
14
+ COLOR_THEMES,
15
+ DEFAULT_WORKSPACE_THEME,
16
+ FONT_THEMES,
17
+ RADIUS_THEMES,
18
+ deriveThemeColors
19
+ } from '@/lib/themes'
20
+ import type { ColorTheme, FontTheme, RadiusTheme } from '@/lib/themes'
14
21
  import { isParamsRecord } from '@/lib/workspace-tabs'
15
22
  import type {
16
23
  AppletLogEntry,
@@ -678,9 +685,9 @@ const refresh = defineCommand({
678
685
  }
679
686
  })
680
687
 
681
- function hexToRgb(h: string): [number, number, number] {
682
- const n = parseInt(h.replace('#', ''), 16)
683
- return [(n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]
688
+ function hexToRgb(hex: string): [number, number, number] {
689
+ const value = Number.parseInt(hex.slice(1), 16)
690
+ return [(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]
684
691
  }
685
692
 
686
693
  // Truecolor swatch using raw ANSI 24-bit escapes (picocolors maxes at 8 colors).
@@ -695,11 +702,11 @@ function swatch(bg?: string, fg?: string): string {
695
702
  function themeSwatch(primary?: string): string {
696
703
  if (!primary) return swatch()
697
704
  const colors = deriveThemeColors(primary)
698
- return swatch(colors.primary, colors.primaryForeground)
705
+ return swatch(formatHex(colors.primary), formatHex(colors.primaryForeground))
699
706
  }
700
707
 
701
708
  const theme = defineCommand({
702
- meta: { name: 'theme', description: 'Show or set the workspace font and color themes' },
709
+ meta: { name: 'theme', description: 'Show or set the workspace appearance' },
703
710
  args: {
704
711
  dir: {
705
712
  type: 'positional',
@@ -707,7 +714,8 @@ const theme = defineCommand({
707
714
  description: 'Workspace directory (default: current)'
708
715
  },
709
716
  font: { type: 'string', description: 'Font theme key to apply' },
710
- color: { type: 'string', description: 'Color preset key to apply' }
717
+ color: { type: 'string', description: 'Color preset key to apply' },
718
+ radius: { type: 'string', description: 'Radius preset key to apply' }
711
719
  },
712
720
  async run({ args }) {
713
721
  const path = resolve(args.dir)
@@ -720,7 +728,8 @@ const theme = defineCommand({
720
728
  type: 'theme',
721
729
  path,
722
730
  font: args.font ?? null,
723
- color: args.color ?? null
731
+ color: args.color ?? null,
732
+ radius: args.radius ?? null
724
733
  })
725
734
  )
726
735
 
@@ -749,16 +758,21 @@ const theme = defineCommand({
749
758
  const chip = themeSwatch(preset.primary)
750
759
  console.log(pc.green('✓') + ' Color set to ' + pc.bold(preset.label) + ' ' + chip)
751
760
  }
761
+ if (res.radius) {
762
+ const preset = RADIUS_THEMES[res.radius as RadiusTheme]
763
+ console.log(pc.green('✓') + ' Radius set to ' + pc.bold(preset.label))
764
+ }
752
765
  console.log()
753
766
  if (notice) console.log(pc.yellow(notice) + '\n')
754
767
  ws.close()
755
768
  process.exit(0)
756
769
  }
757
770
 
758
- const currentFont: FontTheme = res.currentFont ?? 'default'
759
- const currentColor: ColorTheme | null = res.currentColor ?? null
771
+ const currentFont: FontTheme = res.currentFont ?? DEFAULT_WORKSPACE_THEME.font
772
+ const currentColor: ColorTheme = res.currentColor ?? DEFAULT_WORKSPACE_THEME.color
773
+ const currentRadius: RadiusTheme = res.currentRadius ?? DEFAULT_WORKSPACE_THEME.radius
760
774
  console.log('\n' + pc.bold('moi theme') + ' — workspace appearance')
761
- console.log(pc.dim(' Usage: moi theme --font=<key> --color=<key>') + '\n')
775
+ console.log(pc.dim(' Usage: moi theme --font=<key> --color=<key> --radius=<key>') + '\n')
762
776
 
763
777
  const fontRows = (Object.keys(FONT_THEMES) as FontTheme[]).map(key => {
764
778
  const f = FONT_THEMES[key]
@@ -768,14 +782,13 @@ const theme = defineCommand({
768
782
  selected ? pc.bold(key) : key,
769
783
  f.label,
770
784
  pc.dim(f.sans),
771
- pc.dim(f.mono),
772
- pc.dim(f.feel)
785
+ pc.dim(f.mono)
773
786
  ]
774
787
  })
775
788
  console.log(pc.dim(' Fonts'))
776
789
  console.log(
777
790
  columns(
778
- ['', 'key', 'label', 'sans', 'mono', 'feel'].map(h => pc.dim(h)),
791
+ ['', 'key', 'label', 'sans', 'mono'].map(h => pc.dim(h)),
779
792
  fontRows
780
793
  ) + '\n'
781
794
  )
@@ -798,6 +811,24 @@ const theme = defineCommand({
798
811
  ) + '\n'
799
812
  )
800
813
 
814
+ const radiusRows = (Object.keys(RADIUS_THEMES) as RadiusTheme[]).map(key => {
815
+ const radius = RADIUS_THEMES[key]
816
+ const selected = key === currentRadius
817
+ return [
818
+ selected ? pc.green('→') : ' ',
819
+ selected ? pc.bold(key) : key,
820
+ radius.label,
821
+ pc.dim(radius.radius)
822
+ ]
823
+ })
824
+ console.log(pc.dim(' Radius'))
825
+ console.log(
826
+ columns(
827
+ ['', 'key', 'label', 'value'].map(h => pc.dim(h)),
828
+ radiusRows
829
+ ) + '\n'
830
+ )
831
+
801
832
  if (notice) console.log(pc.yellow(notice) + '\n')
802
833
  ws.close()
803
834
  process.exit(0)
package/server/control.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { stringify as devalueStringify } from 'devalue'
2
2
  import { resolve } from 'path'
3
3
 
4
+ import { resolveWorkspaceTheme } from '@/lib/themes'
4
5
  import type { WorkspaceEntry } from '@/lib/types'
5
6
  import { isParamsRecord } from '@/lib/workspace-tabs'
6
7
 
@@ -18,7 +19,7 @@ import { readScratchpadImage, readScratchpadShapes } from './scratchpad'
18
19
  import { relayScratchOp } from './scratchpad-relay'
19
20
  import { broadcastAll } from './state'
20
21
  import { assembleTabRows, resolveFocusTab } from './tabs'
21
- import { applyThemeUpdate, matchColorTheme } from './theme'
22
+ import { applyThemeUpdate } from './theme'
22
23
  import { handleBundle } from './widgets'
23
24
  import { getViewList, handleBundleViews, hasViewId } from './views'
24
25
  import {
@@ -353,18 +354,24 @@ export const control = Bun.serve({
353
354
  const workspacePath = match.path
354
355
  const layout = await loadLayout(workspacePath)
355
356
 
356
- // Listing mode — neither axis requested
357
- if (!data.font && !data.color) {
357
+ // Listing mode — no theme setting requested
358
+ if (!data.font && !data.color && !data.radius) {
359
+ const theme = resolveWorkspaceTheme(layout.theme)
358
360
  ws.send(
359
361
  JSON.stringify({
360
- currentFont: layout.theme?.font ?? 'default',
361
- currentColor: matchColorTheme(layout.theme?.primary)
362
+ currentFont: theme.font,
363
+ currentColor: theme.color,
364
+ currentRadius: theme.radius
362
365
  })
363
366
  )
364
367
  return
365
368
  }
366
369
 
367
- const result = applyThemeUpdate(layout.theme, { font: data.font, color: data.color })
370
+ const result = applyThemeUpdate(layout.theme, {
371
+ font: data.font,
372
+ color: data.color,
373
+ radius: data.radius
374
+ })
368
375
  if (!result.ok) {
369
376
  ws.send(JSON.stringify({ error: result.error }))
370
377
  return
@@ -3,6 +3,7 @@
3
3
  // relayed over the control port — the workspace's processes must be reaped and
4
4
  // every connected client told to refetch. Both entry points call this so the
5
5
  // side effects can never drift apart.
6
+ import { agentStore } from './agent'
6
7
  import { publishEvent } from './events'
7
8
  import { restartWorker } from './functions'
8
9
  import { allHarnesses } from './harness/registry'
@@ -12,5 +13,8 @@ export function applyEnvChanged(workspace: { id: string; path: string }): void {
12
13
  // down idle agent sessions (busy ones keep their snapshot until turn end).
13
14
  restartWorker(workspace.path)
14
15
  for (const h of allHarnesses()) h.onEnvChanged?.(workspace.path)
16
+ // Env can carry credentials (ANTHROPIC_API_KEY, provider config) — drop the
17
+ // cached availability so the next agent snapshot re-probes.
18
+ agentStore.invalidate(workspace.id)
15
19
  publishEvent({ type: 'env:updated', workspaceId: workspace.id })
16
20
  }
@@ -118,13 +118,16 @@ Known gaps: runs with `bypassPermissions` only (no interactive approval
118
118
  flow), and effort/streaming changes require a teardown-and-resume because the
119
119
  SDK has no live setter for them.
120
120
 
121
- **OpenClaw — shipped, experimental.** Chat over the local gateway's WebSocket
122
- JSON-RPC: sessions seeded cold from `sessions.get` then updated from live
123
- `session.message` frames, abort via `sessions.abort`, per-turn usage (tokens +
124
- cost) into `TurnMeta`, optimistic user-echo rendezvous (the gateway echoes
125
- sends with lag), uploads materialized to file paths. Known gaps: no
126
- token-delta streaming (durable message rows only — deliberate v2 cut), no
127
- model/effort selection, and the gateway is the sole source of truth (no local
121
+ **OpenClaw — shipped.** Chat over the local gateway's WebSocket JSON-RPC
122
+ (wire protocol 4 — the 2026.7.x and 2026.6.x lines; protocol-3 gateways are
123
+ detected and surfaced, see `openclaw/compat.ts`): sessions seeded cold from
124
+ `sessions.get` then updated from live `session.message` frames, token-delta
125
+ previews from `chat` frames, live tool state + output from `session.tool`
126
+ frames, model/effort applied per send via `sessions.patch`, abort via
127
+ `sessions.abort`, per-turn usage (tokens + cost) into `TurnMeta`, user-echo
128
+ rendezvous by `<runId>:user` idempotency key (text fallback), uploads
129
+ materialized to file paths. Known gaps: no rich vision blocks (string-only
130
+ `sessions.send`), and the gateway is the sole source of truth (no local
128
131
  persistence; cold restarts re-seed).
129
132
 
130
133
  **Codex — shipped, experimental.** Chat over `codex app-server` (stdio
@@ -148,6 +151,17 @@ approval flow (server→client approval requests are auto-accepted
148
151
  defensively), and images ride inline as data URLs only (no `localImage` path
149
152
  mode).
150
153
 
154
+ Workspace availability also checks provider authentication when a workspace is
155
+ given. Claude Code is probed with `claude auth status` under the effective
156
+ workspace env; `claude auth login` launches its browser sign-in from the composer. Codex
157
+ uses app-server `account/read` and returns a browser OAuth URL through
158
+ `account/login/start`. The server owns the recovery loop (`server/agent.ts`):
159
+ `GET /api/workspaces/:id/agent` serves a cached availability snapshot alongside
160
+ the model catalog, `POST .../auth/login` starts (or joins) the one ceremony per
161
+ workspace, and a server-side watch loop re-probes until the login lands or times
162
+ out, pushing `agent:updated` events to every tab. The composer renders that
163
+ state; it never polls.
164
+
151
165
  ## What a harness adapter must support
152
166
 
153
167
  The checklist below is distilled from what the Claude Code integration
@@ -222,7 +236,9 @@ doubles as the evaluation rubric for new harnesses.
222
236
  - Compaction trigger/observe.
223
237
  - Queued-message semantics: does the backend queue natively or must the
224
238
  server?
225
- - Health/auth status events.
239
+ - Push health/auth status events from the backend itself (the server watch
240
+ loop still discovers login completion by re-probing; a provider callback
241
+ would let `agent:updated` fire without polling anywhere).
226
242
 
227
243
  ## Capability comparison
228
244
 
@@ -234,10 +250,10 @@ Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing.
234
250
  | Queue/steer mid-turn | ⚠️ queued next turn | ⚠️ | ✅ `turn/steer` into live turn |
235
251
  | Resume | ✅ | ✅ | ✅ + fork |
236
252
  | Interrupt | ✅ `interrupt()` | ✅ | ✅ `turn/interrupt` |
237
- | List models | ✅ `supportedModels()` | ❌ | ✅ `model/list` |
238
- | Live model switch | ✅ `setModel()` | ❌ | ✅ per-turn override |
239
- | Live effort switch | ❌ rebuild | ❌ | ✅ per-turn |
240
- | Token deltas | ✅ opt-in | ❌ (v2) | ✅ `item/*/delta` |
253
+ | List models | ✅ `supportedModels()` | ✅ `models.list` | ✅ `model/list` |
254
+ | Live model switch | ✅ `setModel()` | ✅ `sessions.patch` | ✅ per-turn override |
255
+ | Live effort switch | ❌ rebuild | ✅ `thinkingLevel` patch | ✅ per-turn |
256
+ | Token deltas | ✅ opt-in | ✅ `chat` frames | ✅ `item/*/delta` |
241
257
  | Images in input | ✅ base64 blocks | ⚠️ materialize to path | ✅ data URL or path |
242
258
  | Interactive approvals | ⚠️ (we bypass) | ✅ | ✅ server→client requests (we bypass) |
243
259
  | Session list/history API | ✅ `listSessions()` + jsonl | ✅ `sessions.get` | ✅ `thread/list`/`read` |
@@ -0,0 +1,54 @@
1
+ import type { HarnessAvailability, HarnessLogin } from '@/lib/types'
2
+
3
+ import { resolveWorkspaceEnv } from '../../workspace-env'
4
+ import { findHarnessExecutable } from '../executable'
5
+
6
+ function signedOut(reason: string): HarnessAvailability {
7
+ return {
8
+ available: false,
9
+ reason,
10
+ loginCommand: 'claude auth login'
11
+ }
12
+ }
13
+
14
+ // Claude Code 2.1.42+ exposes a stable JSON auth probe. Run it with the same
15
+ // workspace env as the actual Agent SDK subprocess so API-key and enterprise
16
+ // provider configuration are evaluated consistently with the eventual send.
17
+ export async function getClaudeAuthReadiness(workspacePath: string): Promise<HarnessAvailability> {
18
+ const executable = findHarnessExecutable('claude-code')
19
+ if (!executable) return signedOut('Claude is not installed')
20
+
21
+ try {
22
+ const workspaceEnv = await resolveWorkspaceEnv(workspacePath)
23
+ const proc = Bun.spawn([executable, 'auth', 'status'], {
24
+ cwd: workspacePath,
25
+ env: { ...process.env, ...workspaceEnv },
26
+ stdin: 'ignore',
27
+ stdout: 'ignore',
28
+ stderr: 'ignore'
29
+ })
30
+ const timeout = setTimeout(() => proc.kill(), 5_000)
31
+ const exitCode = await proc.exited
32
+ clearTimeout(timeout)
33
+ return exitCode === 0
34
+ ? { available: true }
35
+ : signedOut('Claude is signed out. Sign in to send messages')
36
+ } catch {
37
+ return signedOut('Could not verify the Claude login')
38
+ }
39
+ }
40
+
41
+ export async function startClaudeLogin(workspacePath: string): Promise<HarnessLogin> {
42
+ const executable = findHarnessExecutable('claude-code')
43
+ if (!executable) throw new Error('Claude is not installed')
44
+
45
+ const workspaceEnv = await resolveWorkspaceEnv(workspacePath)
46
+ Bun.spawn([executable, 'auth', 'login'], {
47
+ cwd: workspacePath,
48
+ env: { ...process.env, ...workspaceEnv },
49
+ stdin: 'ignore',
50
+ stdout: 'ignore',
51
+ stderr: 'ignore'
52
+ }).unref()
53
+ return {}
54
+ }
@@ -6,6 +6,7 @@ import type { McpServer } from '@/lib/types'
6
6
 
7
7
  import type { DiscoveredWorkspaceCandidate, Harness } from '../types'
8
8
  import { findHarnessExecutable, pathHarnessAvailability } from '../executable'
9
+ import { getClaudeAuthReadiness, startClaudeLogin } from './auth'
9
10
  import { isLinkedGitWorktree } from './git-worktree'
10
11
  import { getMcpStatus } from './mcp'
11
12
  import { getClaudeModels } from './models'
@@ -96,7 +97,11 @@ export const claudeCodeHarness: Harness = {
96
97
  // fields are ignored by the client) — pass it through unchanged.
97
98
  mcpStatus: async ws => (await getMcpStatus(ws.path)) as unknown as McpServer[],
98
99
  discoverWorkspaces,
99
- availability: async () => pathHarnessAvailability('claude-code'),
100
+ availability: async ws => {
101
+ const runtime = await pathHarnessAvailability('claude-code')
102
+ return runtime.available && ws ? getClaudeAuthReadiness(ws.path) : runtime
103
+ },
104
+ startLogin: ws => startClaudeLogin(ws.path),
100
105
 
101
106
  onEnvChanged: workspacePath => restartWorkspaceSessions(workspacePath),
102
107
  shutdown: () => killAllCCSessions(),
@@ -118,6 +118,11 @@ export type CodexModel = {
118
118
  additionalSpeedTiers?: string[]
119
119
  }
120
120
 
121
+ export function withCodexTurnDuration(turn: Turn, durationMs: number | null | undefined): Turn {
122
+ if (typeof durationMs !== 'number' || !Number.isFinite(durationMs) || durationMs < 0) return turn
123
+ return { ...turn, meta: { ...turn.meta, durationMs } }
124
+ }
125
+
121
126
  // ---- discovery mappings ------------------------------------------------------
122
127
 
123
128
  const CODEX_FAST_SERVICE_TIER = 'priority'
@@ -565,7 +570,10 @@ export function codexThreadToEvents(
565
570
  const part = t.parts.find(p => p.type === 'tool-call')
566
571
  if (sub && part?.type === 'tool-call') part.call.subagent = sub.record
567
572
  }
568
- events.push({ kind: 'turn', turn: t })
573
+ events.push({
574
+ kind: 'turn',
575
+ turn: t.role === 'assistant' ? withCodexTurnDuration(t, turn.durationMs) : t
576
+ })
569
577
  continue
570
578
  }
571
579
  const n = codexItemToNotice(item, thread.id)
@@ -0,0 +1,50 @@
1
+ import type { HarnessAvailability, HarnessLogin } from '@/lib/types'
2
+
3
+ import { getCodexClient } from './client'
4
+
5
+ export type CodexAccountResponse = {
6
+ account: unknown | null
7
+ requiresOpenaiAuth: boolean
8
+ }
9
+
10
+ type CodexLoginResponse = { type: string; authUrl?: string }
11
+
12
+ function needsCodexLogin(reason: string): HarnessAvailability {
13
+ return {
14
+ available: false,
15
+ reason,
16
+ loginCommand: 'codex login'
17
+ }
18
+ }
19
+
20
+ export function codexAccountReadiness(response: CodexAccountResponse): HarnessAvailability {
21
+ // Non-OpenAI model providers can run without a Codex account. For OpenAI,
22
+ // an account object is the app-server's authoritative logged-in signal.
23
+ if (!response.requiresOpenaiAuth || response.account) return { available: true }
24
+ return needsCodexLogin('Codex is signed out. Sign in to send messages')
25
+ }
26
+
27
+ export async function getCodexAuthReadiness(workspacePath: string): Promise<HarnessAvailability> {
28
+ try {
29
+ const client = await getCodexClient(workspacePath)
30
+ const account = await client.rpc<CodexAccountResponse>('account/read', { refreshToken: true })
31
+ return codexAccountReadiness(account)
32
+ } catch {
33
+ return needsCodexLogin('Could not verify the Codex login')
34
+ }
35
+ }
36
+
37
+ export async function startCodexLogin(workspacePath: string): Promise<HarnessLogin> {
38
+ const client = await getCodexClient(workspacePath)
39
+ const login = await client.rpc<CodexLoginResponse>('account/login/start', {
40
+ type: 'chatgpt',
41
+ useHostedLoginSuccessPage: true,
42
+ appBrand: 'codex'
43
+ })
44
+ if (login.type !== 'chatgpt' || !login.authUrl) {
45
+ throw new Error('Codex did not return a browser login URL')
46
+ }
47
+ const url = new URL(login.authUrl)
48
+ if (url.protocol !== 'https:') throw new Error('Codex returned an unsafe login URL')
49
+ return { url: url.toString() }
50
+ }