moi-computer 0.9.0 → 0.9.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 (120) hide show
  1. package/client/api/app-config.ts +51 -0
  2. package/client/api/workspace-keys.ts +1 -0
  3. package/client/app/routes/WorkspaceRoute.tsx +4 -2
  4. package/client/assets/hermes.png +0 -0
  5. package/client/components/shared/IconGhost.tsx +15 -18
  6. package/client/components/ui/button.tsx +2 -2
  7. package/client/components/ui/hover-card.tsx +1 -1
  8. package/client/components/ui/popover.tsx +3 -1
  9. package/client/features/applets/api.ts +38 -0
  10. package/client/features/applets/applet-thumbnail.ts +208 -0
  11. package/client/features/chat/ChatEmptyState.tsx +30 -10
  12. package/client/features/chat/ChatPanel.tsx +67 -31
  13. package/client/features/chat/ChatPopup.tsx +3 -2
  14. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  15. package/client/features/chat/ChatSelector.tsx +29 -10
  16. package/client/features/chat/MarkdownContent.tsx +3 -3
  17. package/client/features/chat/attachment-staging.ts +153 -0
  18. package/client/features/chat/chat-send.ts +55 -0
  19. package/client/features/chat/chat-store.ts +32 -8
  20. package/client/features/chat/composer/ChatComposer.tsx +190 -77
  21. package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
  22. package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
  23. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
  24. package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
  25. package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
  26. package/client/features/chat/tool-group/format/claude.ts +48 -0
  27. package/client/features/chat/tool-group/format/codex.ts +126 -0
  28. package/client/features/chat/tool-group/format/hermes.ts +68 -0
  29. package/client/features/chat/tool-group/format/index.ts +34 -0
  30. package/client/features/chat/tool-group/format/mcp.ts +64 -0
  31. package/client/features/chat/tool-group/format/openclaw.ts +116 -0
  32. package/client/features/chat/tool-group/format/shared.ts +49 -0
  33. package/client/features/chat/useChat.ts +5 -10
  34. package/client/features/drawings/DrawingLayer.tsx +49 -0
  35. package/client/features/drawings/DrawingToolbar.tsx +95 -0
  36. package/client/features/drawings/capture-element.ts +45 -0
  37. package/client/features/drawings/useChatAnnotation.ts +222 -0
  38. package/client/features/drawings/useDrawingLayer.ts +758 -0
  39. package/client/features/drawings/useViewBuilderSketch.ts +151 -0
  40. package/client/features/home/HomePage.tsx +13 -0
  41. package/client/features/home/WorkspacePreview.tsx +10 -5
  42. package/client/features/home/workspace-presentation.tsx +6 -2
  43. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
  44. package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
  45. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +13 -7
  46. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
  47. package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
  48. package/client/features/views/ViewBuilder.tsx +238 -0
  49. package/client/features/views/ViewManager.tsx +18 -2
  50. package/client/features/views/api.ts +1 -0
  51. package/client/features/views/useViewBuilderActions.ts +24 -3
  52. package/client/features/views/useViewBuilderDrafts.ts +66 -0
  53. package/client/features/widgets/WidgetFrame.tsx +1 -1
  54. package/client/features/widgets/WidgetGrid.tsx +1 -1
  55. package/client/features/widgets/Widgets.tsx +39 -54
  56. package/client/features/workspace/CustomizePanel.tsx +30 -9
  57. package/client/features/workspace/WorkspaceScreen.tsx +158 -64
  58. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  59. package/client/features/workspace/useFitsSplitLayout.ts +14 -8
  60. package/client/index.css +8 -0
  61. package/client/index.tsx +6 -1
  62. package/client/runtime/useWorkspaceEvents.ts +17 -0
  63. package/client/runtime/workspace-theme.ts +29 -6
  64. package/client/store/ui.ts +19 -0
  65. package/client/theme.css +33 -8
  66. package/dist/chunk-5c19v3zr.js +10 -0
  67. package/dist/chunk-6wx91x8j.js +1 -0
  68. package/dist/chunk-8s41nd3g.js +1 -0
  69. package/dist/{chunk-kkj86722.js → chunk-a7fzp0z0.js} +78 -78
  70. package/dist/{chunk-2vaafjp4.js → chunk-b959mdkj.js} +1 -1
  71. package/dist/chunk-cagtq45k.js +1 -0
  72. package/dist/chunk-cva7jpt4.js +82 -0
  73. package/dist/chunk-sapvd7he.css +1 -0
  74. package/dist/{chunk-35fq49qa.js → chunk-zbeq02yc.js} +1 -1
  75. package/dist/chunk-zbt8emsw.js +2 -0
  76. package/dist/chunk-zfz3b4xg.js +2 -0
  77. package/dist/hermes-pznd63x9.png +0 -0
  78. package/dist/index.html +1 -1
  79. package/lib/format.ts +1 -1
  80. package/lib/themes.ts +8 -8
  81. package/lib/types.ts +68 -42
  82. package/lib/workspace-types.ts +2 -1
  83. package/package.json +2 -1
  84. package/server/api.ts +90 -33
  85. package/server/app-config.ts +144 -0
  86. package/server/applets.ts +17 -0
  87. package/server/cli.ts +235 -14
  88. package/server/harness/README.md +64 -17
  89. package/server/harness/acp/adapter.ts +220 -0
  90. package/server/harness/acp/archived.ts +88 -0
  91. package/server/harness/acp/client.ts +328 -0
  92. package/server/harness/acp/discovery.ts +130 -0
  93. package/server/harness/acp/run-durations.ts +68 -0
  94. package/server/harness/acp/session.ts +788 -0
  95. package/server/harness/acp/wire.ts +132 -0
  96. package/server/harness/executable.ts +15 -1
  97. package/server/harness/hermes/NOTES.md +815 -0
  98. package/server/harness/hermes/discovery.ts +155 -0
  99. package/server/harness/hermes/index.ts +155 -0
  100. package/server/harness/hermes/models.ts +79 -0
  101. package/server/harness/registry.ts +3 -1
  102. package/server/layout.ts +40 -45
  103. package/server/moi-scaffold.ts +37 -1
  104. package/server/thumbnails.ts +197 -0
  105. package/server/view-builders.ts +4 -2
  106. package/server/views.ts +10 -1
  107. package/server/widgets.ts +4 -18
  108. package/server/workspace-import.ts +30 -1
  109. package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
  110. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
  111. package/client/features/chat/tool-group/format.ts +0 -384
  112. package/client/features/views/ViewBuilderTab.tsx +0 -152
  113. package/client/features/widgets/api.ts +0 -47
  114. package/client/features/widgets/useWidgetThumbnails.ts +0 -107
  115. package/client/features/widgets/widget-snapshot.ts +0 -71
  116. package/dist/chunk-3b3rkjet.js +0 -1
  117. package/dist/chunk-gt7n06ef.js +0 -1
  118. package/dist/chunk-ty1sqbmn.js +0 -80
  119. package/dist/chunk-xeyxk7ep.js +0 -10
  120. package/dist/chunk-yz6wd5vc.css +0 -1
@@ -0,0 +1,45 @@
1
+ const MAX_CAPTURE_EDGE = 1568
2
+ const ASSET_TIMEOUT_MS = 1_000
3
+ const CAPTURE_TIMEOUT_MS = 10_000
4
+
5
+ export function drawingCaptureScale(width: number, height: number, pixelRatio: number): number {
6
+ const longEdge = Math.max(width, height)
7
+ if (longEdge <= 0) return 1
8
+ return Math.min(Math.max(pixelRatio, 1), MAX_CAPTURE_EDGE / longEdge)
9
+ }
10
+
11
+ function rejectAfter(ms: number): Promise<never> {
12
+ return new Promise((_, reject) => {
13
+ setTimeout(() => reject(new Error('Annotation capture timed out')), ms)
14
+ })
15
+ }
16
+
17
+ // Capture one visible DOM region into a canvas. This is deliberately unaware
18
+ // of workspaces, chat, and drawing so other flows can reuse it later.
19
+ export async function captureElement(element: HTMLElement): Promise<HTMLCanvasElement> {
20
+ const bounds = element.getBoundingClientRect()
21
+ if (bounds.width <= 0 || bounds.height <= 0) {
22
+ throw new Error('Annotation target is not visible')
23
+ }
24
+
25
+ const { createContext, destroyContext, domToCanvas } = await import('modern-screenshot')
26
+ const run = async () => {
27
+ const context = await createContext(element, {
28
+ width: Math.round(bounds.width),
29
+ height: Math.round(bounds.height),
30
+ scale: drawingCaptureScale(bounds.width, bounds.height, window.devicePixelRatio),
31
+ type: 'image/png',
32
+ backgroundColor: getComputedStyle(element).backgroundColor,
33
+ timeout: ASSET_TIMEOUT_MS,
34
+ features: { restoreScrollPosition: true },
35
+ style: { overflow: 'hidden' }
36
+ })
37
+ try {
38
+ return await domToCanvas(context)
39
+ } finally {
40
+ destroyContext(context)
41
+ }
42
+ }
43
+
44
+ return Promise.race([run(), rejectAfter(CAPTURE_TIMEOUT_MS)])
45
+ }
@@ -0,0 +1,222 @@
1
+ import { useCallback, useEffect, useMemo, useRef } from 'react'
2
+
3
+ import { toast } from '@/client/components/ui/toast'
4
+ import { stageDrawing, stageDrawingDraft } from '@/client/features/chat/attachment-staging'
5
+ import { liveStore } from '@/client/features/chat/chat-store'
6
+ import type { ComposerAnnotationControls } from '@/client/features/chat/composer/ChatComposer'
7
+ import type { LayoutMode, WorkspaceTabId } from '@/lib/types'
8
+
9
+ import { type DrawingController, useDrawingLayer } from './useDrawingLayer'
10
+
11
+ type AnnotationOrigin = 'docked' | 'popup'
12
+
13
+ type ChatAnnotationDraft = {
14
+ workspaceId: string
15
+ sourceSessionId: string | null
16
+ sourceTab: WorkspaceTabId
17
+ origin: AnnotationOrigin
18
+ attachmentId: string
19
+ }
20
+
21
+ type UseChatAnnotationOptions = {
22
+ workspaceId: string
23
+ sessionId: string | null
24
+ activeTab: WorkspaceTabId
25
+ mode: LayoutMode
26
+ available: boolean
27
+ closePopup: () => void
28
+ openPopup: () => void
29
+ }
30
+
31
+ export type ChatAnnotationController = DrawingController & {
32
+ docked: ComposerAnnotationControls | undefined
33
+ popup: ComposerAnnotationControls | undefined
34
+ }
35
+
36
+ export function useChatAnnotation({
37
+ workspaceId,
38
+ sessionId,
39
+ activeTab,
40
+ mode,
41
+ available,
42
+ closePopup,
43
+ openPopup
44
+ }: UseChatAnnotationOptions): ChatAnnotationController {
45
+ const draftRef = useRef<ChatAnnotationDraft | null>(null)
46
+ const latestBlobRef = useRef<Blob | null>(null)
47
+ const uploadRevisionsRef = useRef(new Map<string, number>())
48
+ const closePopupRef = useRef(closePopup)
49
+ const openPopupRef = useRef(openPopup)
50
+ closePopupRef.current = closePopup
51
+ openPopupRef.current = openPopup
52
+
53
+ // While drawing, every commit only refreshes the chip's local preview. The
54
+ // single upload happens when the session ends: finish/send (complete) or an
55
+ // implicit cancel that keeps the attachment.
56
+ const change = useCallback((blob: Blob | null) => {
57
+ const draft = draftRef.current
58
+ if (!draft) return
59
+
60
+ latestBlobRef.current = blob
61
+ if (!blob) {
62
+ liveStore
63
+ .getState()
64
+ .removeAttachment(draft.workspaceId, draft.sourceSessionId, draft.attachmentId)
65
+ return
66
+ }
67
+
68
+ stageDrawingDraft({
69
+ workspaceId: draft.workspaceId,
70
+ sessionId: draft.sourceSessionId,
71
+ localId: draft.attachmentId,
72
+ purpose: 'annotation',
73
+ sourceTab: draft.sourceTab,
74
+ blob
75
+ })
76
+ }, [])
77
+
78
+ const upload = useCallback((draft: ChatAnnotationDraft, blob: Blob): Promise<void> => {
79
+ const revision = (uploadRevisionsRef.current.get(draft.attachmentId) ?? 0) + 1
80
+ uploadRevisionsRef.current.set(draft.attachmentId, revision)
81
+ return stageDrawing({
82
+ workspaceId: draft.workspaceId,
83
+ sessionId: draft.sourceSessionId,
84
+ localId: draft.attachmentId,
85
+ purpose: 'annotation',
86
+ sourceTab: draft.sourceTab,
87
+ blob,
88
+ isCurrent: () => uploadRevisionsRef.current.get(draft.attachmentId) === revision
89
+ })
90
+ }, [])
91
+
92
+ const complete = useCallback(
93
+ async (blob: Blob | null) => {
94
+ const draft = draftRef.current
95
+ draftRef.current = null
96
+ latestBlobRef.current = null
97
+ // Awaited so a send that finishes the drawing only dispatches once the
98
+ // attachment is uploaded and ready.
99
+ if (draft && blob) await upload(draft, blob)
100
+ if (draft?.origin === 'popup') openPopupRef.current()
101
+ },
102
+ [upload]
103
+ )
104
+
105
+ const annotation = useDrawingLayer({ onChange: change, onFinish: complete })
106
+ const { controls } = annotation
107
+ const { active, starting, open, finish, cancel: cancelLayer } = controls
108
+
109
+ const start = useCallback(
110
+ async (origin: AnnotationOrigin) => {
111
+ if (!available || active || starting) return
112
+
113
+ const draft: ChatAnnotationDraft = {
114
+ workspaceId,
115
+ sourceSessionId: sessionId,
116
+ sourceTab: activeTab,
117
+ origin,
118
+ attachmentId: crypto.randomUUID()
119
+ }
120
+ draftRef.current = draft
121
+ try {
122
+ const opened = await open()
123
+ if (!opened) {
124
+ if (draftRef.current === draft) draftRef.current = null
125
+ return
126
+ }
127
+ if (origin === 'popup') closePopupRef.current()
128
+ } catch {
129
+ if (draftRef.current !== draft) return
130
+ draftRef.current = null
131
+ toast.add({ title: 'Couldn’t capture this page', type: 'error' })
132
+ }
133
+ },
134
+ [active, activeTab, available, open, sessionId, starting, workspaceId]
135
+ )
136
+
137
+ const cancel = useCallback(async () => {
138
+ const draft = draftRef.current
139
+ await cancelLayer()
140
+ if (draftRef.current !== draft) return
141
+ draftRef.current = null
142
+ const blob = latestBlobRef.current
143
+ latestBlobRef.current = null
144
+ // An implicit cancel (tab/session switch) keeps the drawn-so-far
145
+ // annotation as an attachment, so it gets its one deferred upload here.
146
+ if (draft && blob) void upload(draft, blob)
147
+ }, [cancelLayer, upload])
148
+
149
+ const remove = useCallback(
150
+ (localId: string) => {
151
+ const revision = (uploadRevisionsRef.current.get(localId) ?? 0) + 1
152
+ uploadRevisionsRef.current.set(localId, revision)
153
+ liveStore.getState().removeAttachment(workspaceId, sessionId, localId)
154
+ if (draftRef.current?.attachmentId === localId) {
155
+ draftRef.current = null
156
+ latestBlobRef.current = null
157
+ void cancelLayer()
158
+ }
159
+ },
160
+ [cancelLayer, sessionId, workspaceId]
161
+ )
162
+
163
+ const finishDrawing = useCallback(async () => {
164
+ if (starting) {
165
+ await cancel()
166
+ return
167
+ }
168
+ await finish()
169
+ }, [cancel, finish, starting])
170
+ const toggleDocked = useCallback(() => {
171
+ if (active || starting) void finishDrawing()
172
+ else void start('docked')
173
+ }, [active, finishDrawing, start, starting])
174
+ const togglePopup = useCallback(() => {
175
+ if (active || starting) void finishDrawing()
176
+ else void start('popup')
177
+ }, [active, finishDrawing, start, starting])
178
+
179
+ useEffect(() => {
180
+ const draft = draftRef.current
181
+ if (!draft) return
182
+ const expectedMode = draft.origin === 'docked' ? 'split' : 'fullscreen'
183
+ if (
184
+ draft.workspaceId !== workspaceId ||
185
+ draft.sourceSessionId !== sessionId ||
186
+ draft.sourceTab !== activeTab ||
187
+ mode !== expectedMode ||
188
+ !available
189
+ ) {
190
+ void cancel()
191
+ }
192
+ }, [activeTab, available, cancel, mode, sessionId, workspaceId])
193
+
194
+ // Identity-stable (all callbacks hold state in refs) so ChatPanel and
195
+ // ChatComposer can be memoized against the `annotation` prop.
196
+ const docked = useMemo<ComposerAnnotationControls | undefined>(
197
+ () =>
198
+ available
199
+ ? {
200
+ active: active || starting,
201
+ finish: finishDrawing,
202
+ onRemove: remove,
203
+ onToggle: toggleDocked
204
+ }
205
+ : undefined,
206
+ [available, active, starting, finishDrawing, remove, toggleDocked]
207
+ )
208
+ const popup = useMemo<ComposerAnnotationControls | undefined>(
209
+ () =>
210
+ available
211
+ ? {
212
+ active: active || starting,
213
+ finish: finishDrawing,
214
+ onRemove: remove,
215
+ onToggle: togglePopup
216
+ }
217
+ : undefined,
218
+ [available, active, starting, finishDrawing, remove, togglePopup]
219
+ )
220
+
221
+ return useMemo(() => ({ ...annotation, docked, popup }), [annotation, docked, popup])
222
+ }