moi-computer 0.8.1-next.0 → 0.9.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 (103) hide show
  1. package/client/assets/hermes.png +0 -0
  2. package/client/components/shared/IconGhost.tsx +15 -18
  3. package/client/components/ui/button.tsx +2 -2
  4. package/client/components/ui/hover-card.tsx +1 -1
  5. package/client/components/ui/popover.tsx +3 -1
  6. package/client/features/chat/ChatEmptyState.tsx +25 -7
  7. package/client/features/chat/ChatPanel.tsx +70 -28
  8. package/client/features/chat/ChatPopup.tsx +3 -2
  9. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  10. package/client/features/chat/MarkdownContent.tsx +1 -1
  11. package/client/features/chat/attachment-staging.ts +153 -0
  12. package/client/features/chat/chat-send.ts +55 -0
  13. package/client/features/chat/chat-store.ts +32 -8
  14. package/client/features/chat/composer/ChatComposer.tsx +190 -77
  15. package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
  16. package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
  17. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
  18. package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
  19. package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
  20. package/client/features/chat/tool-group/format/claude.ts +48 -0
  21. package/client/features/chat/tool-group/format/codex.ts +126 -0
  22. package/client/features/chat/tool-group/format/hermes.ts +68 -0
  23. package/client/features/chat/tool-group/format/index.ts +34 -0
  24. package/client/features/chat/tool-group/format/mcp.ts +64 -0
  25. package/client/features/chat/tool-group/format/openclaw.ts +116 -0
  26. package/client/features/chat/tool-group/format/shared.ts +49 -0
  27. package/client/features/chat/useChat.ts +5 -10
  28. package/client/features/dev/ChatStatesPage.tsx +40 -2
  29. package/client/features/drawings/DrawingLayer.tsx +49 -0
  30. package/client/features/drawings/DrawingToolbar.tsx +95 -0
  31. package/client/features/drawings/annotation-availability.ts +10 -0
  32. package/client/features/drawings/capture-element.ts +45 -0
  33. package/client/features/drawings/useChatAnnotation.ts +222 -0
  34. package/client/features/drawings/useDrawingLayer.ts +758 -0
  35. package/client/features/drawings/useViewBuilderSketch.ts +151 -0
  36. package/client/features/home/workspace-presentation.tsx +6 -2
  37. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +12 -6
  38. package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
  39. package/client/features/views/ViewBuilder.tsx +224 -0
  40. package/client/features/views/api.ts +1 -0
  41. package/client/features/views/useViewBuilderActions.ts +24 -3
  42. package/client/features/views/useViewBuilderDrafts.ts +66 -0
  43. package/client/features/widgets/Widgets.tsx +23 -39
  44. package/client/features/workspace/CustomizePanel.tsx +1 -1
  45. package/client/features/workspace/WorkspaceScreen.tsx +157 -57
  46. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  47. package/client/features/workspace/useFitsSplitLayout.ts +14 -8
  48. package/client/index.css +8 -0
  49. package/client/store/ui.ts +19 -0
  50. package/client/theme.css +33 -8
  51. package/dist/chunk-3becmq75.js +81 -0
  52. package/dist/{chunk-kkj86722.js → chunk-6w6j9g4b.js} +78 -78
  53. package/dist/{chunk-xeyxk7ep.js → chunk-8ew39cvq.js} +4 -4
  54. package/dist/chunk-c8gtrjwp.js +1 -0
  55. package/dist/{chunk-2vaafjp4.js → chunk-pp62fnxh.js} +1 -1
  56. package/dist/{chunk-35fq49qa.js → chunk-sxc24vfp.js} +1 -1
  57. package/dist/{chunk-xzx7c9hq.js → chunk-v964b5g7.js} +1 -1
  58. package/dist/chunk-zx33ts9d.css +1 -0
  59. package/dist/hermes-pznd63x9.png +0 -0
  60. package/dist/index.html +1 -1
  61. package/lib/format.ts +21 -7
  62. package/lib/themes.ts +8 -8
  63. package/lib/types.ts +8 -1
  64. package/lib/workspace-types.ts +2 -1
  65. package/package.json +6 -4
  66. package/server/api.ts +21 -2
  67. package/server/bundler/build-applet.ts +35 -44
  68. package/server/cli-env.ts +2 -2
  69. package/server/cli.ts +227 -56
  70. package/server/constants.ts +8 -0
  71. package/server/control-client.ts +124 -0
  72. package/server/control.ts +2 -2
  73. package/server/harness/README.md +74 -23
  74. package/server/harness/acp/adapter.ts +220 -0
  75. package/server/harness/acp/archived.ts +88 -0
  76. package/server/harness/acp/client.ts +328 -0
  77. package/server/harness/acp/discovery.ts +130 -0
  78. package/server/harness/acp/run-durations.ts +68 -0
  79. package/server/harness/acp/session.ts +788 -0
  80. package/server/harness/acp/wire.ts +132 -0
  81. package/server/harness/executable.ts +15 -1
  82. package/server/harness/hermes/NOTES.md +815 -0
  83. package/server/harness/hermes/discovery.ts +155 -0
  84. package/server/harness/hermes/index.ts +155 -0
  85. package/server/harness/hermes/models.ts +79 -0
  86. package/server/harness/openclaw/NOTES.md +196 -94
  87. package/server/harness/openclaw/adapter.ts +28 -55
  88. package/server/harness/openclaw/compat.ts +4 -8
  89. package/server/harness/openclaw/session.ts +257 -238
  90. package/server/harness/openclaw/strip.ts +10 -34
  91. package/server/harness/openclaw/thinking.ts +5 -53
  92. package/server/harness/registry.ts +3 -1
  93. package/server/service.ts +2 -2
  94. package/server/view-builders.ts +4 -2
  95. package/server/workspace-import.ts +30 -1
  96. package/workspace/.claude/skills/moi-workspace/SKILL.md +6 -6
  97. package/client/features/chat/tool-group/format.ts +0 -359
  98. package/client/features/views/ViewBuilderTab.tsx +0 -152
  99. package/dist/chunk-gny990qx.css +0 -1
  100. package/dist/chunk-gt7n06ef.js +0 -1
  101. package/dist/chunk-n7pga5x3.js +0 -80
  102. /package/workspace/.claude/skills/moi-workspace/{DESIGN.md → references/DESIGN.md} +0 -0
  103. /package/workspace/.claude/skills/moi-workspace/{SCRATCHPAD.md → references/SCRATCHPAD.md} +0 -0
@@ -0,0 +1,49 @@
1
+ import type { KeyboardEventHandler, PointerEventHandler, ReactNode, RefObject } from 'react'
2
+
3
+ export type DrawingCanvasPointerProps = {
4
+ onPointerDown: PointerEventHandler<HTMLCanvasElement>
5
+ onPointerMove: PointerEventHandler<HTMLCanvasElement>
6
+ onPointerUp: PointerEventHandler<HTMLCanvasElement>
7
+ onPointerCancel: PointerEventHandler<HTMLCanvasElement>
8
+ }
9
+
10
+ export type DrawingLayerProps = {
11
+ visible: boolean
12
+ editing: boolean
13
+ canvasRef: RefObject<HTMLCanvasElement | null>
14
+ width: number
15
+ height: number
16
+ pointerProps: DrawingCanvasPointerProps
17
+ onKeyDown: KeyboardEventHandler<HTMLDivElement>
18
+ children?: ReactNode
19
+ }
20
+
21
+ // The layer only renders the drawing canvas and an optional controls slot. All
22
+ // capture, history, and export behavior belongs to useDrawingLayer.
23
+ export function DrawingLayer({
24
+ visible,
25
+ editing,
26
+ canvasRef,
27
+ width,
28
+ height,
29
+ pointerProps,
30
+ onKeyDown,
31
+ children
32
+ }: DrawingLayerProps) {
33
+ if (!visible) return null
34
+
35
+ return (
36
+ <div className="absolute inset-0 animate-in duration-100 fade-in" onKeyDown={onKeyDown}>
37
+ <canvas
38
+ ref={canvasRef}
39
+ {...pointerProps}
40
+ width={width}
41
+ height={height}
42
+ aria-label="Drawing area"
43
+ tabIndex={0}
44
+ className="absolute inset-0 size-full cursor-pencil touch-none outline-none"
45
+ />
46
+ {editing && children}
47
+ </div>
48
+ )
49
+ }
@@ -0,0 +1,95 @@
1
+ import { IconArrowBackUp, IconArrowForwardUp, IconCheck, IconX } from '@tabler/icons-react'
2
+ import { AnimatePresence, motion } from 'motion/react'
3
+
4
+ import { Button } from '@/client/components/ui/button'
5
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
6
+ import { cn } from '@/client/lib/cn'
7
+
8
+ import { type DrawingControls, useDrawingHistoryState } from './useDrawingLayer'
9
+
10
+ type DrawingToolbarProps = {
11
+ controls: DrawingControls
12
+ title: string
13
+ busy: boolean
14
+ onComplete: () => void
15
+ }
16
+
17
+ export function DrawingToolbar({ controls, title, busy, onComplete }: DrawingToolbarProps) {
18
+ const { canUndo, canRedo, hasStrokes } = useDrawingHistoryState(controls)
19
+
20
+ return (
21
+ <div className="absolute bottom-3 left-1/2 flex -translate-x-1/2 items-center gap-2 rounded-lg bg-popover p-1.5 shadow-md">
22
+ <span className="mr-2 ml-2 text-sm font-medium">{title}</span>
23
+ <div className="flex gap-1">
24
+ <Tooltip>
25
+ <TooltipTrigger
26
+ render={
27
+ <Button
28
+ type="button"
29
+ variant="outline"
30
+ size="icon-sm"
31
+ onClick={controls.undo}
32
+ disabled={busy || !canUndo}
33
+ aria-label="Undo"
34
+ >
35
+ <IconArrowBackUp stroke={1.75} />
36
+ </Button>
37
+ }
38
+ />
39
+ <TooltipContent>Undo</TooltipContent>
40
+ </Tooltip>
41
+ <Tooltip>
42
+ <TooltipTrigger
43
+ render={
44
+ <Button
45
+ type="button"
46
+ variant="outline"
47
+ size="icon-sm"
48
+ onClick={controls.redo}
49
+ disabled={busy || !canRedo}
50
+ aria-label="Redo"
51
+ >
52
+ <IconArrowForwardUp stroke={1.75} />
53
+ </Button>
54
+ }
55
+ />
56
+ <TooltipContent>Redo</TooltipContent>
57
+ </Tooltip>
58
+ <Button
59
+ type="button"
60
+ variant="outline"
61
+ size="sm"
62
+ onClick={controls.clear}
63
+ disabled={busy || !hasStrokes}
64
+ >
65
+ Clear
66
+ </Button>
67
+ </div>
68
+ <AnimatePresence mode="popLayout" initial={false}>
69
+ <motion.div
70
+ key={hasStrokes ? 'complete' : 'cancel'}
71
+ variants={{
72
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
73
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
74
+ }}
75
+ initial="from"
76
+ animate="to"
77
+ exit="from"
78
+ transition={{ type: 'spring', duration: 0.1, bounce: 0 }}
79
+ >
80
+ <Button
81
+ type="button"
82
+ variant={hasStrokes ? 'default' : 'ghost'}
83
+ size="icon-sm"
84
+ onClick={onComplete}
85
+ disabled={busy}
86
+ aria-label="Complete"
87
+ className={cn(!hasStrokes && 'text-muted-foreground')}
88
+ >
89
+ {hasStrokes ? <IconCheck stroke={1.75} /> : <IconX stroke={1.75} />}
90
+ </Button>
91
+ </motion.div>
92
+ </AnimatePresence>
93
+ </div>
94
+ )
95
+ }
@@ -0,0 +1,10 @@
1
+ import type { WorkspaceTabId } from '@/lib/types'
2
+
3
+ export function canAnnotateWorkspaceContent(
4
+ activeTab: WorkspaceTabId,
5
+ widgetControlsIdle: boolean,
6
+ hasBuiltView: boolean
7
+ ): boolean {
8
+ if (!widgetControlsIdle) return false
9
+ return activeTab === 'widgets' || (activeTab.startsWith('view:') && hasBuiltView)
10
+ }
@@ -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
+ }