moi-computer 0.3.0 → 0.3.1-next.1

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 (121) hide show
  1. package/client/api/workspace-keys.ts +2 -2
  2. package/client/app/AppRouter.tsx +0 -2
  3. package/client/app/routes/WorkspaceRoute.tsx +3 -1
  4. package/client/app/shell/SidebarLayout.tsx +3 -16
  5. package/client/assets/openai.svg +1 -3
  6. package/client/components/shared/Composer.tsx +112 -0
  7. package/client/components/ui/button.tsx +1 -1
  8. package/client/components/ui/dropdown-menu.tsx +3 -3
  9. package/client/components/ui/tooltip.tsx +12 -15
  10. package/client/features/applets/WidgetErrorBoundary.tsx +19 -3
  11. package/client/features/applets/WidgetShell.tsx +8 -1
  12. package/client/features/applets/applet-log.ts +100 -0
  13. package/client/features/applets/useApplet.ts +21 -7
  14. package/client/features/chat/ChatComposer.tsx +33 -30
  15. package/client/features/chat/ChatPanel.tsx +5 -2
  16. package/client/features/chat/MarkdownContent.tsx +20 -2
  17. package/client/features/chat/ModelPicker.tsx +29 -41
  18. package/client/features/chat/TurnView.tsx +2 -2
  19. package/client/features/chat/chat-frames.ts +14 -6
  20. package/client/features/chat/chat-send.ts +1 -1
  21. package/client/features/chat/chat-store.ts +22 -17
  22. package/client/features/chat/model-order.ts +47 -0
  23. package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
  24. package/client/features/chat/tool-group/format.ts +0 -6
  25. package/client/features/chat/useChat.ts +15 -2
  26. package/client/features/connectors/McpServerCards.tsx +95 -0
  27. package/client/features/connectors/api.ts +0 -11
  28. package/client/features/home/HomePage.tsx +45 -42
  29. package/client/features/home/WorkspacePreview.tsx +179 -38
  30. package/client/features/home/api.ts +24 -12
  31. package/client/features/home/workspace-presentation.tsx +17 -15
  32. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
  33. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
  34. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
  35. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
  36. package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
  37. package/client/features/settings/ConnectorsSettings.tsx +89 -0
  38. package/client/features/settings/GeneralSettings.tsx +12 -0
  39. package/client/features/settings/SettingsLayout.tsx +2 -2
  40. package/client/features/settings/WorkspaceSettings.tsx +8 -4
  41. package/client/features/views/ViewBuilderTab.tsx +28 -29
  42. package/client/features/views/useViewBuilderActions.ts +1 -1
  43. package/client/features/widgets/WidgetFrame.tsx +3 -0
  44. package/client/features/widgets/WidgetGrid.tsx +1 -0
  45. package/client/features/widgets/Widgets.tsx +12 -3
  46. package/client/features/widgets/api.ts +47 -0
  47. package/client/features/widgets/useWidgetThumbnails.ts +107 -0
  48. package/client/features/widgets/widget-snapshot.ts +71 -0
  49. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
  50. package/client/features/workspace/WorkspaceScreen.tsx +19 -4
  51. package/client/features/workspace/api.ts +25 -3
  52. package/client/features/workspace/moi-context.ts +85 -0
  53. package/client/index.css +0 -5
  54. package/client/main.tsx +13 -4
  55. package/dist/{chunk-cs8vbert.js → chunk-1dfbr7n2.js} +2 -2
  56. package/dist/chunk-339jds4x.js +15 -0
  57. package/dist/chunk-3xsvsnhr.css +1 -0
  58. package/dist/{chunk-zpxrb1ce.js → chunk-anqmsbjt.js} +2 -2
  59. package/dist/chunk-hbvfb6sk.js +63 -0
  60. package/dist/chunk-jen6xcm1.js +14 -0
  61. package/dist/{chunk-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
  62. package/dist/{chunk-fjksw6xf.js → chunk-sxbfh73c.js} +1 -1
  63. package/dist/chunk-yp4srgqt.js +10 -0
  64. package/dist/index.html +1 -1
  65. package/dist/openai-ep9ht2pq.svg +1 -0
  66. package/lib/ids.ts +15 -0
  67. package/lib/moi-context.ts +170 -0
  68. package/lib/types.ts +95 -13
  69. package/lib/view-builder-directives.ts +16 -0
  70. package/lib/workspace-types.ts +12 -0
  71. package/package.json +4 -2
  72. package/server/api.ts +180 -34
  73. package/server/applet-log.ts +149 -0
  74. package/server/cli.ts +161 -7
  75. package/server/control.ts +81 -1
  76. package/server/functions.ts +44 -14
  77. package/server/harness/README.md +26 -9
  78. package/server/harness/claude-code/NOTES.md +20 -6
  79. package/server/harness/claude-code/adapter.ts +2 -2
  80. package/server/harness/claude-code/git-worktree.ts +32 -0
  81. package/server/harness/claude-code/index.ts +35 -13
  82. package/server/harness/claude-code/mcp.ts +16 -65
  83. package/server/harness/claude-code/models.ts +3 -0
  84. package/server/harness/claude-code/session.ts +196 -61
  85. package/server/harness/claude-code/sessions.ts +51 -0
  86. package/server/harness/codex/NOTES.md +41 -11
  87. package/server/harness/codex/adapter.ts +52 -6
  88. package/server/harness/codex/client.ts +69 -18
  89. package/server/harness/codex/discovery.ts +114 -0
  90. package/server/harness/codex/index.ts +12 -5
  91. package/server/harness/codex/probe.ts +4 -2
  92. package/server/harness/codex/session.ts +57 -5
  93. package/server/harness/executable.ts +82 -0
  94. package/server/harness/openclaw/adapter.ts +8 -1
  95. package/server/harness/openclaw/discovery.ts +139 -6
  96. package/server/harness/openclaw/gateway.ts +40 -18
  97. package/server/harness/openclaw/index.ts +12 -15
  98. package/server/harness/openclaw/session.ts +50 -10
  99. package/server/harness/openclaw/strip.ts +2 -2
  100. package/server/harness/shell-path.ts +79 -0
  101. package/server/harness/types.ts +37 -5
  102. package/server/layout.ts +81 -51
  103. package/server/registry.ts +57 -12
  104. package/server/scratchpad-assets.ts +41 -6
  105. package/server/scratchpad.ts +30 -0
  106. package/server/view-builders.ts +3 -2
  107. package/server/views.ts +5 -0
  108. package/server/web.ts +30 -8
  109. package/server/widgets.ts +23 -2
  110. package/server/workspace-import.ts +45 -0
  111. package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -3
  112. package/client/features/connectors/ConnectorsPage.tsx +0 -92
  113. package/client/features/connectors/McpMenu.tsx +0 -145
  114. package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
  115. package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
  116. package/dist/chunk-4vf1t6v1.js +0 -10
  117. package/dist/chunk-4z52b2av.css +0 -1
  118. package/dist/chunk-b4b276wx.js +0 -15
  119. package/dist/chunk-y82s1jxm.js +0 -61
  120. package/dist/openai-h13pza4b.svg +0 -3
  121. package/lib/view-builder-meta.ts +0 -35
@@ -14,7 +14,6 @@ import {
14
14
  import { ChatPanel } from '@/client/features/chat/ChatPanel'
15
15
  import { ChatPopup } from '@/client/features/chat/ChatPopup'
16
16
  import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
17
- import { McpMenu } from '@/client/features/connectors/McpMenu'
18
17
  import { AppletMount } from '@/client/features/applets/AppletMount'
19
18
  import { WidgetErrorBoundary } from '@/client/features/applets/WidgetErrorBoundary'
20
19
  import { Widgets } from '@/client/features/widgets/Widgets'
@@ -28,7 +27,9 @@ import { useView } from '@/client/features/applets/useApplet'
28
27
  import { ViewBuilderTab } from '@/client/features/views/ViewBuilderTab'
29
28
  import { useViewBuilderActions } from '@/client/features/views/useViewBuilderActions'
30
29
  import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
30
+ import { useWorkspaceAvailability } from '@/client/features/workspace/api'
31
31
  import { useWorkspaceTheme } from '@/client/features/workspace/useWorkspaceTheme'
32
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
32
33
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
33
34
  import { resolveAppIcon } from '@/client/lib/app-icon-registry'
34
35
  import { cn } from '@/client/lib/cn'
@@ -100,6 +101,7 @@ type ViewAppProps = {
100
101
  // layout + scroll, so we give it a plain filled box and fade it in (mirroring
101
102
  // WidgetShell, but full-area instead of a grid cell).
102
103
  function ViewApp({ view }: ViewAppProps) {
104
+ const workspaceId = useWorkspaceId()
103
105
  const bundle = useView(view.id)
104
106
 
105
107
  return (
@@ -120,7 +122,12 @@ function ViewApp({ view }: ViewAppProps) {
120
122
  exit={{ opacity: 0, filter: 'blur(4px)' }}
121
123
  transition={{ duration: 0.3, ease: 'easeInOut' }}
122
124
  >
123
- <WidgetErrorBoundary name={view.id} resetKey={bundle.version}>
125
+ <WidgetErrorBoundary
126
+ name={view.id}
127
+ kind="view"
128
+ workspaceId={workspaceId}
129
+ resetKey={bundle.version}
130
+ >
124
131
  <bundle.Component />
125
132
  </WidgetErrorBoundary>
126
133
  </motion.div>
@@ -150,7 +157,7 @@ type WorkspaceCustomizeActionProps = {
150
157
 
151
158
  function WorkspaceCustomizeAction({ active, onToggle }: WorkspaceCustomizeActionProps) {
152
159
  return (
153
- <Tooltip delay={50}>
160
+ <Tooltip>
154
161
  <TooltipTrigger
155
162
  render={
156
163
  <Button
@@ -267,6 +274,11 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
267
274
  dismissError
268
275
  } = useChat()
269
276
  const { layout, setLayout, name, icon, provider, workspaceId } = useWorkspaceLayoutCtx()
277
+ // Keep the composer read/write, but block sends when its agent executable is
278
+ // missing. The Send button explains how to install it.
279
+ const availability = useWorkspaceAvailability(workspaceId).data
280
+ const unavailableReason =
281
+ availability === undefined ? undefined : availability.available ? null : availability.reason
270
282
  const builderActions = useViewBuilderActions()
271
283
  const { ref: rowRef, fits: canUseSplit } = useFitsSplitLayout<HTMLDivElement>()
272
284
  const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
@@ -517,6 +529,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
517
529
  processing={processing}
518
530
  error={error}
519
531
  onDismissError={dismissError}
532
+ unavailableReason={unavailableReason}
520
533
  send={send}
521
534
  stop={stop}
522
535
  onSwitchThread={switchThread}
@@ -533,6 +546,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
533
546
  processing={processing}
534
547
  error={error}
535
548
  onDismissError={dismissError}
549
+ unavailableReason={unavailableReason}
536
550
  send={send}
537
551
  stop={stop}
538
552
  onSwitchThread={switchThread}
@@ -581,7 +595,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
581
595
  setWidgetMode(widgetMode === 'customizing' ? 'idle' : 'customizing')
582
596
  }
583
597
  />
584
- <McpMenu />
585
598
  <WorkspaceSettings />
586
599
  {hasWorkspaceContent && canUseSplit && (
587
600
  <SectionControls
@@ -609,6 +622,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
609
622
  <ViewBuilderTab
610
623
  key={activeBuilder.id}
611
624
  builder={activeBuilder}
625
+ unavailableReason={unavailableReason}
612
626
  onSave={requirements => builderActions.save(activeBuilder.id, requirements)}
613
627
  onSubmit={requirements => {
614
628
  if (mode === 'fullscreen') setFloatingChatOpen(true)
@@ -662,6 +676,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
662
676
  processing={processing}
663
677
  error={error}
664
678
  onDismissError={dismissError}
679
+ unavailableReason={unavailableReason}
665
680
  send={send}
666
681
  stop={stop}
667
682
  onSwitchThread={switchThread}
@@ -1,9 +1,15 @@
1
- import { useMutation, useQuery } from '@tanstack/react-query'
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
2
2
 
3
3
  import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
4
4
  import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
5
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
- import type { ViewInfo, WidgetInfo, WorkspaceLayout, WorkspaceType } from '@/lib/types'
6
+ import type {
7
+ HarnessAvailability,
8
+ ViewInfo,
9
+ WidgetInfo,
10
+ WorkspaceLayout,
11
+ WorkspaceType
12
+ } from '@/lib/types'
7
13
 
8
14
  export type WorkspaceLayoutResponse = WorkspaceLayout & {
9
15
  cwd: string
@@ -20,6 +26,18 @@ export function useWorkspaceLayout(workspaceId: string) {
20
26
  })
21
27
  }
22
28
 
29
+ // Is the workspace's agent executable installed? Drives the Send button's
30
+ // disabled state and tooltip. Refetches on window focus so installing the
31
+ // missing runtime and returning to the tab unlocks the composer.
32
+ export function useWorkspaceAvailability(workspaceId: string) {
33
+ return useQuery<HarnessAvailability>({
34
+ queryKey: workspaceKeys.availability(workspaceId),
35
+ queryFn: () => requestJson(`/api/workspaces/${workspaceId}/availability`),
36
+ staleTime: 30_000,
37
+ refetchOnWindowFocus: true
38
+ })
39
+ }
40
+
23
41
  export function useWorkspaceWidgets(workspaceId: string) {
24
42
  return useQuery<WidgetInfo[]>({
25
43
  queryKey: workspaceKeys.widgets(workspaceId),
@@ -45,12 +63,16 @@ export function useWorkspaceViews(workspaceId: string) {
45
63
  }
46
64
 
47
65
  export function useSaveLayout(workspaceId: string) {
66
+ const queryClient = useQueryClient()
48
67
  return useMutation<void, Error, WorkspaceLayout>({
49
68
  mutationFn: layout =>
50
69
  requestVoid(
51
70
  `/api/workspaces/${workspaceId}`,
52
71
  jsonRequest('PUT', layout),
53
72
  'Failed to save layout'
54
- )
73
+ ),
74
+ onSuccess: () => {
75
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.preview(workspaceId) })
76
+ }
55
77
  })
56
78
  }
@@ -0,0 +1,85 @@
1
+ // Central assembly of the moi context sent with every chat message — the one
2
+ // place that snapshots the workspace's primary UI state (active tab, view
3
+ // titles) and drains queued one-shot directives. The structured `MoiContext`
4
+ // travels to the server as-is; harnesses render it (lib/moi-context.ts).
5
+ //
6
+ // Quick API:
7
+ //
8
+ // pushChatDirective(workspaceId, 'The user clicked "Sync now" on the stock-ticker widget.')
9
+ // Queue a one-shot instruction from anywhere in the app — event handlers,
10
+ // stores, non-React code. It rides the NEXT chat message's
11
+ // "# This message only" section and is delivered exactly once.
12
+ //
13
+ // useMoiUserMessageContext()
14
+ // Hook for the chat send path: returns a builder that snapshots ambient
15
+ // state (active tab, view title) and drains the directive queue. Call
16
+ // the builder only for a message that actually goes out.
17
+ //
18
+ // Adding a new ambient field (e.g. scratchpad selection): extend the
19
+ // `MoiContext` type and its renderer in lib/moi-context.ts, then supply
20
+ // the field in `useMoiUserMessageContext`'s builder below.
21
+ import { useCallback } from 'react'
22
+
23
+ import { useViewBuilders } from '@/client/features/views/api'
24
+ import { useWorkspaceViews } from '@/client/features/workspace/api'
25
+ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
26
+ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
27
+ import type { MoiContext } from '@/lib/moi-context'
28
+ import type { ViewBuilder, ViewInfo, WorkspaceTabId } from '@/lib/types'
29
+
30
+ // One-shot directives queued per workspace, drained into the NEXT chat
31
+ // message's `# This message only` section. Module-level (not React state):
32
+ // contributors may not live under a workspace React tree, and the queue must
33
+ // survive re-renders without causing any.
34
+ const directiveQueues = new Map<string, string[]>()
35
+
36
+ // Queue a one-shot instruction for the next message sent from `workspaceId`.
37
+ // Write a complete sentence; it reaches the agent once and is not re-sent.
38
+ export function pushChatDirective(workspaceId: string, directive: string): void {
39
+ const queue = directiveQueues.get(workspaceId) ?? []
40
+ queue.push(directive)
41
+ directiveQueues.set(workspaceId, queue)
42
+ }
43
+
44
+ // Exported for unit tests; production code drains only via `useMoiUserMessageContext`.
45
+ export function drainChatDirectives(workspaceId: string): string[] {
46
+ const queue = directiveQueues.get(workspaceId) ?? []
47
+ directiveQueues.delete(workspaceId)
48
+ return queue
49
+ }
50
+
51
+ // The UI label of the active tab when it has one beyond its id: a view's
52
+ // configured title, or a builder's claimed title while the build runs.
53
+ // Undefined otherwise (the envelope then falls back to the id, like the tab
54
+ // bar).
55
+ export function activeTabTitle(
56
+ tab: WorkspaceTabId,
57
+ views: ViewInfo[] | undefined,
58
+ builders: ViewBuilder[] | undefined
59
+ ): string | undefined {
60
+ if (tab.startsWith('view:'))
61
+ return views?.find(v => v.id === tab.slice('view:'.length))?.config.title || undefined
62
+ if (tab.startsWith('view-builder:'))
63
+ return builders?.find(b => b.id === tab.slice('view-builder:'.length))?.title || undefined
64
+ return undefined
65
+ }
66
+
67
+ // Returns a builder that snapshots the workspace state at call time — invoke
68
+ // it when the message is actually sent, not at render. Draining the
69
+ // directive queue is part of the snapshot, so only call it for a message
70
+ // that will really go out.
71
+ export function useMoiUserMessageContext(): () => MoiContext {
72
+ const workspaceId = useWorkspaceId()
73
+ const { layout } = useWorkspaceLayoutCtx()
74
+ const views = useWorkspaceViews(workspaceId).data
75
+ const builders = useViewBuilders(workspaceId).data
76
+ const activeTab = layout.tabs.active
77
+ return useCallback(() => {
78
+ const directives = drainChatDirectives(workspaceId)
79
+ return {
80
+ activeTab,
81
+ tabTitle: activeTabTitle(activeTab, views, builders),
82
+ ...(directives.length > 0 ? { directives } : {})
83
+ }
84
+ }, [workspaceId, activeTab, views, builders])
85
+ }
package/client/index.css CHANGED
@@ -83,11 +83,6 @@
83
83
  /* Color/radius/shadow tokens — shared with widget bundles via theme.css */
84
84
  @import './theme.css';
85
85
 
86
- /* Lift all grid items so the placeholder (z-index: 0) stays behind them */
87
- .react-grid-item:not(.react-grid-placeholder) {
88
- z-index: 1;
89
- }
90
-
91
86
  /* Dragged card floats above all others */
92
87
  .react-grid-item.react-draggable-dragging {
93
88
  z-index: 10;
package/client/main.tsx CHANGED
@@ -3,6 +3,8 @@ import { Agentation } from 'agentation'
3
3
  import { createRoot } from 'react-dom/client'
4
4
  import { Router } from 'wouter'
5
5
 
6
+ import { TooltipProvider } from '@/client/components/ui/tooltip'
7
+ import { installAppletErrorHook } from '@/client/features/applets/applet-log'
6
8
  import { initConnection } from '@/client/features/chat/chat-connection'
7
9
  import { AppRouter } from './app/AppRouter'
8
10
 
@@ -12,14 +14,21 @@ const queryClient = new QueryClient()
12
14
  // live frames fold into the RQ transcript cache. Lives for the page's lifetime.
13
15
  initConnection(queryClient)
14
16
 
17
+ // Catch applet errors that escape React (handlers, async effects) and journal
18
+ // them for `moi debug logs` — attribution is by bundle URL in the stack, so
19
+ // host-app errors never match (see features/applets/applet-log.ts).
20
+ installAppletErrorHook()
21
+
15
22
  export function mount(el: HTMLElement) {
16
23
  function Root() {
17
24
  return (
18
25
  <QueryClientProvider client={queryClient}>
19
- <Router>
20
- <AppRouter />
21
- </Router>
22
- {process.env.NODE_ENV === 'development' && <Agentation />}
26
+ <TooltipProvider>
27
+ <Router>
28
+ <AppRouter />
29
+ </Router>
30
+ {process.env.NODE_ENV === 'development' && <Agentation />}
31
+ </TooltipProvider>
23
32
  </QueryClientProvider>
24
33
  )
25
34
  }