moi-computer 0.11.1-next.2 → 0.11.1-next.3
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.
- package/README.md +2 -2
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/toast.tsx +2 -2
- package/client/features/applets/AppletMount.tsx +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +19 -10
- package/client/features/chat/ChatPopup.tsx +7 -2
- package/client/features/chat/applet-chat-intents.ts +170 -0
- package/client/features/chat/chat-send.ts +103 -62
- package/client/features/chat/chat-store.ts +50 -59
- package/client/features/chat/composer/ChatComposer.tsx +43 -132
- package/client/features/chat/composer/ModelPicker.tsx +1 -1
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +2 -2
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +22 -15
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +1 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +1 -1
- package/client/features/chat/useChat.ts +32 -15
- package/client/features/dev/ChatStatesPage.tsx +5 -6
- package/client/features/dev/HarnessDebugPage.tsx +10 -7
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +21 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +1 -1
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +24 -16
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +11 -13
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +205 -161
- package/client/features/workspace/WorkspaceSplitLayout.tsx +1 -1
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +0 -26
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +1 -1
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/chunk-1pp135b4.js +1 -0
- package/dist/chunk-2gs8jjx4.css +1 -0
- package/dist/chunk-94m3q9ce.js +1 -0
- package/dist/chunk-azkjzc7a.js +68 -0
- package/dist/{chunk-w482ew2c.js → chunk-brr0zbeh.js} +73 -73
- package/dist/chunk-m1fvqssh.js +2 -0
- package/dist/chunk-p34hvqt3.js +1 -0
- package/dist/{chunk-4s15axjs.js → chunk-p83f0jnj.js} +2 -2
- package/dist/{chunk-j3wvxjr7.js → chunk-tzz101ea.js} +1 -1
- package/dist/chunk-xg01f6pn.js +10 -0
- package/dist/{chunk-53a7pxcz.js → chunk-zs4mte79.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/default-widgets.ts +32 -0
- package/lib/format.ts +12 -1
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/types.ts +79 -24
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +27 -27
- package/registry.json +13 -0
- package/server/AGENTS.md +1 -0
- package/server/api.ts +114 -37
- package/server/applet-typecheck.ts +95 -0
- package/server/{bundler → applets}/build-applet.ts +13 -246
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +15 -161
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/cli.ts +163 -97
- package/server/control.ts +63 -42
- package/server/harness/README.md +4 -2
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/session.ts +31 -50
- package/server/harness/claude-code/NOTES.md +8 -2
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/index.ts +2 -0
- package/server/harness/claude-code/session.ts +42 -47
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/adapter.ts +8 -7
- package/server/harness/codex/index.ts +1 -0
- package/server/harness/codex/permissions.ts +1 -1
- package/server/harness/codex/session.ts +20 -47
- package/server/harness/hermes/NOTES.md +1 -1
- package/server/harness/hermes/index.ts +4 -0
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +5 -3
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +21 -13
- package/server/navigation-relay.ts +110 -0
- package/server/registry.ts +8 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +48 -9
- package/server/tabs.ts +19 -33
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +18 -1
- package/server/views.ts +126 -6
- package/server/web.ts +35 -9
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/ui-components/button.tsx +2 -2
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/dropdown-menu.tsx +1 -1
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/slider.tsx +1 -1
- package/ui-components/switch.tsx +1 -1
- package/ui-components/tabs.tsx +1 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +284 -228
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -153
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -95
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -262
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-245wt82v.css +0 -1
- package/dist/chunk-87thzbtw.js +0 -2
- package/dist/chunk-a6jad1a6.js +0 -1
- package/dist/chunk-dghwstd2.js +0 -9
- package/dist/chunk-eg120aca.js +0 -1
- package/dist/chunk-j7hh2ab4.js +0 -70
- package/dist/chunk-y8eyahwx.js +0 -1
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +0 -0
- /package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
- /package/client/features/chat/{session-view.ts → sessions/session-view.ts} +0 -0
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
- /package/server/{bundler → applets}/applet-css.ts +0 -0
- /package/server/{bundler → applets}/build-worker.ts +0 -0
|
@@ -13,9 +13,21 @@ export type SelectedSessionUpdate = {
|
|
|
13
13
|
export const DEFAULT_SELECTED_SESSION_PATH = join(DATA_DIR, 'selected-sessions.json')
|
|
14
14
|
|
|
15
15
|
let storePath = DEFAULT_SELECTED_SESSION_PATH
|
|
16
|
+
const renamedSessions = new Map<string, Map<string, string>>()
|
|
16
17
|
|
|
17
18
|
export function setSelectedSessionPath(path: string): void {
|
|
18
19
|
storePath = path
|
|
20
|
+
renamedSessions.clear()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function rememberSessionRename(workspacePath: string, from: string, to: string): void {
|
|
24
|
+
const renames = renamedSessions.get(workspacePath) ?? new Map<string, string>()
|
|
25
|
+
renames.set(from, to)
|
|
26
|
+
renamedSessions.set(workspacePath, renames)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function resolveRenamedSession(workspacePath: string, sessionId: string): string {
|
|
30
|
+
return renamedSessions.get(workspacePath)?.get(sessionId) ?? sessionId
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
async function readStore(): Promise<Store> {
|
|
@@ -84,14 +96,21 @@ export async function saveSelectedSession(
|
|
|
84
96
|
const current = Object.prototype.hasOwnProperty.call(store, workspacePath)
|
|
85
97
|
? store[workspacePath]
|
|
86
98
|
: undefined
|
|
87
|
-
|
|
99
|
+
const resolvedSessionId =
|
|
100
|
+
sessionId === null ? null : resolveRenamedSession(workspacePath, sessionId)
|
|
101
|
+
const resolvedPreviousSessionId =
|
|
102
|
+
previousSessionId == null
|
|
103
|
+
? previousSessionId
|
|
104
|
+
: resolveRenamedSession(workspacePath, previousSessionId)
|
|
105
|
+
|
|
106
|
+
if (resolvedPreviousSessionId !== undefined && current !== resolvedPreviousSessionId) {
|
|
88
107
|
return { changed: false, sessionId: current ?? null }
|
|
89
108
|
}
|
|
90
|
-
if (current ===
|
|
109
|
+
if (current === resolvedSessionId) return { changed: false, sessionId: resolvedSessionId }
|
|
91
110
|
|
|
92
|
-
store[workspacePath] =
|
|
111
|
+
store[workspacePath] = resolvedSessionId
|
|
93
112
|
await writeStore(store)
|
|
94
|
-
return { changed: true, sessionId }
|
|
113
|
+
return { changed: true, sessionId: resolvedSessionId }
|
|
95
114
|
})
|
|
96
115
|
}
|
|
97
116
|
|
|
@@ -102,6 +121,7 @@ export async function renameSelectedSession(
|
|
|
102
121
|
): Promise<SelectedSessionUpdate> {
|
|
103
122
|
if (from === to) return { changed: false, sessionId: to }
|
|
104
123
|
return locked(async () => {
|
|
124
|
+
rememberSessionRename(workspacePath, from, to)
|
|
105
125
|
const store = await readStore()
|
|
106
126
|
const current = Object.prototype.hasOwnProperty.call(store, workspacePath)
|
|
107
127
|
? store[workspacePath]
|
package/server/skill-update.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { WorkspaceSkillsStatus, WorkspaceSkillStatus, WorkspaceType } from '@/lib/types'
|
|
2
2
|
|
|
3
3
|
import { writeAppletEnvDts } from './moi-scaffold'
|
|
4
|
-
import {
|
|
4
|
+
import { isBehind, skillStatuses } from './skill-version'
|
|
5
5
|
import { installBundledSkills } from './skills-template'
|
|
6
6
|
import { skillsDirFor } from './workspace-init'
|
|
7
7
|
|
|
8
8
|
export type WorkspaceSkillUpdateResult = {
|
|
9
9
|
before: WorkspaceSkillStatus[]
|
|
10
10
|
status: WorkspaceSkillsStatus
|
|
11
|
+
changedSkills: string[]
|
|
11
12
|
// False when the workspace has no `.moi/` to refresh — nothing was written.
|
|
12
13
|
appletTypesWritten: boolean
|
|
13
14
|
}
|
|
@@ -15,7 +16,7 @@ export type WorkspaceSkillUpdateResult = {
|
|
|
15
16
|
export function summarizeSkillStatuses(skills: WorkspaceSkillStatus[]): WorkspaceSkillsStatus {
|
|
16
17
|
return {
|
|
17
18
|
skills,
|
|
18
|
-
updateAvailable: skills.some(skill =>
|
|
19
|
+
updateAvailable: skills.some(skill => isBehind(skill.installed, skill.bundled))
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -31,7 +32,7 @@ export async function updateWorkspaceSkills(
|
|
|
31
32
|
type: WorkspaceType = 'claude-code'
|
|
32
33
|
): Promise<WorkspaceSkillUpdateResult> {
|
|
33
34
|
const before = await skillStatuses(workspaceRoot, type)
|
|
34
|
-
await installBundledSkills(skillsDirFor(workspaceRoot, type))
|
|
35
|
+
const changedSkills = await installBundledSkills(skillsDirFor(workspaceRoot, type))
|
|
35
36
|
// The ambient applet types ship with the CLI just like the skills do, and go
|
|
36
37
|
// stale the same way — refresh both in one operation so `moi skill update`
|
|
37
38
|
// (and the UI's update button) leaves nothing behind. Skipped when the
|
|
@@ -42,6 +43,7 @@ export async function updateWorkspaceSkills(
|
|
|
42
43
|
return {
|
|
43
44
|
before,
|
|
44
45
|
status: summarizeSkillStatuses(skills),
|
|
46
|
+
changedSkills,
|
|
45
47
|
appletTypesWritten
|
|
46
48
|
}
|
|
47
49
|
}
|
package/server/skill-version.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
// Skill versioning for
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// copy against the bundled copy, and reports drift. Updating is never
|
|
5
|
-
// automatic: the agent (which reads command output) sees the notice and runs
|
|
6
|
-
// `moi skill update`. See `moi skill` in `cli.ts`.
|
|
1
|
+
// Skill versioning for a workspace's installed skill copy drifting behind the
|
|
2
|
+
// version this moi installation ships. The marker in each skill's `SKILL.md`
|
|
3
|
+
// drives both the CLI status and the frontend's automatic update check.
|
|
7
4
|
import { readdir } from 'node:fs/promises'
|
|
8
5
|
import { join } from 'node:path'
|
|
9
6
|
|
|
@@ -70,7 +67,7 @@ export const isMinorBehind = (installed: string | null, bundled: string | null):
|
|
|
70
67
|
compare(installed, bundled).minorBehind
|
|
71
68
|
|
|
72
69
|
// Any difference at all, patch included — decides whether `moi skill update`
|
|
73
|
-
// would change anything
|
|
70
|
+
// would change anything and whether the frontend should offer or run it.
|
|
74
71
|
export const isBehind = (installed: string | null, bundled: string | null): boolean =>
|
|
75
72
|
compare(installed, bundled).behind
|
|
76
73
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// (Claude Code workspace) and `moi openclaw init <agent>` (OpenClaw agent
|
|
3
3
|
// workspace). Both commands take a fresh or existing directory and lay
|
|
4
4
|
// down the same set of skill folders.
|
|
5
|
-
import { cp, mkdir } from 'node:fs/promises'
|
|
5
|
+
import { cp, lstat, mkdir, readFile, readdir, readlink } from 'node:fs/promises'
|
|
6
6
|
import { join } from 'node:path'
|
|
7
7
|
|
|
8
8
|
// Source directory for shipped templates. Resolved relative to this file so
|
|
@@ -14,18 +14,57 @@ export const TEMPLATE_DIR = join(import.meta.dir, '..', 'workspace')
|
|
|
14
14
|
// for what `moi skill update` copies and what versions it compares against.
|
|
15
15
|
export const BUNDLED_SKILLS_DIR = join(TEMPLATE_DIR, '.claude', 'skills')
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
async function matchesBundledPath(source: string, target: string): Promise<boolean> {
|
|
18
|
+
const sourceStat = await lstat(source)
|
|
19
|
+
const targetStat = await lstat(target).catch(() => null)
|
|
20
|
+
if (!targetStat) return false
|
|
21
|
+
|
|
22
|
+
if (sourceStat.isDirectory()) {
|
|
23
|
+
if (!targetStat.isDirectory()) return false
|
|
24
|
+
const entries = await readdir(source)
|
|
25
|
+
const matches = await Promise.all(
|
|
26
|
+
entries.map(entry => matchesBundledPath(join(source, entry), join(target, entry)))
|
|
27
|
+
)
|
|
28
|
+
return matches.every(Boolean)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (sourceStat.isFile()) {
|
|
32
|
+
if (!targetStat.isFile() || sourceStat.size !== targetStat.size) return false
|
|
33
|
+
const [sourceContents, targetContents] = await Promise.all([readFile(source), readFile(target)])
|
|
34
|
+
return sourceContents.equals(targetContents)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (sourceStat.isSymbolicLink()) {
|
|
38
|
+
if (!targetStat.isSymbolicLink()) return false
|
|
39
|
+
const [sourceLink, targetLink] = await Promise.all([readlink(source), readlink(target)])
|
|
40
|
+
return sourceLink === targetLink
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Copy changed shipped skill folders into `targetSkillsDir`. Leaves identical
|
|
47
|
+
// skills untouched, along with unrelated directories and extra local files.
|
|
48
|
+
// Creates the target if missing and returns the names whose bundled files changed.
|
|
20
49
|
//
|
|
21
50
|
// The ui-components section used to be stripped here unless a workspace opted
|
|
22
51
|
// in with `moi init --experimental-shadcn`. It ships to everyone now; the skill
|
|
23
52
|
// version bump is what pulls it into workspaces installed before the flag went
|
|
24
53
|
// away (the copy below restores both the section and its cheat sheet).
|
|
25
|
-
export async function installBundledSkills(targetSkillsDir: string): Promise<
|
|
54
|
+
export async function installBundledSkills(targetSkillsDir: string): Promise<string[]> {
|
|
26
55
|
await mkdir(targetSkillsDir, { recursive: true })
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
56
|
+
const changedSkills: string[] = []
|
|
57
|
+
const skillEntries = await readdir(BUNDLED_SKILLS_DIR, { withFileTypes: true })
|
|
58
|
+
|
|
59
|
+
for (const entry of skillEntries) {
|
|
60
|
+
if (!entry.isDirectory()) continue
|
|
61
|
+
const source = join(BUNDLED_SKILLS_DIR, entry.name)
|
|
62
|
+
const target = join(targetSkillsDir, entry.name)
|
|
63
|
+
if (await matchesBundledPath(source, target)) continue
|
|
64
|
+
|
|
65
|
+
await cp(source, target, { recursive: true, force: true })
|
|
66
|
+
changedSkills.push(entry.name)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return changedSkills
|
|
31
70
|
}
|
package/server/tabs.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
// validate a focus target. Pure given its inputs — the control handler wires
|
|
3
|
-
// in the workspace lookups (see control.ts), tests pass fakes.
|
|
1
|
+
// Tab discovery with portable navigation addresses.
|
|
4
2
|
import type { ViewInfo, WorkspaceTabId } from '@/lib/types'
|
|
5
|
-
import {
|
|
3
|
+
import { moiHref } from '@/lib/navigation'
|
|
4
|
+
import { viewTabId } from '@/lib/workspace-tabs'
|
|
6
5
|
|
|
7
6
|
// One row of `moi tabs`. `isDefault` marks the workspace's saved default tab
|
|
8
7
|
// (`layout.tabs.active`) — where a bare `/workspace/:id` lands.
|
|
@@ -10,12 +9,13 @@ export type TabRow = {
|
|
|
10
9
|
id: WorkspaceTabId
|
|
11
10
|
title: string
|
|
12
11
|
isDefault: boolean
|
|
12
|
+
href?: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// The always-present tabs, titled like the tab bar renders them.
|
|
16
16
|
const STATIC_TABS: { id: WorkspaceTabId; title: string }[] = [
|
|
17
|
+
{ id: 'overview', title: 'Overview' },
|
|
17
18
|
{ id: 'agent', title: 'Agent' },
|
|
18
|
-
{ id: 'widgets', title: 'Widgets' },
|
|
19
19
|
{ id: 'scratchpad', title: 'Scratchpad' }
|
|
20
20
|
]
|
|
21
21
|
|
|
@@ -26,34 +26,20 @@ export function assembleTabRows(views: ViewInfo[], defaultTab: WorkspaceTabId):
|
|
|
26
26
|
return [
|
|
27
27
|
...STATIC_TABS,
|
|
28
28
|
...views.map(view => ({ id: viewTabId(view.id), title: view.config.title || view.id }))
|
|
29
|
-
].map(row => ({
|
|
29
|
+
].map(row => ({
|
|
30
|
+
...row,
|
|
31
|
+
isDefault: row.id === defaultTab,
|
|
32
|
+
...(row.id === 'agent' ? {} : { href: moiHref(row.id) })
|
|
33
|
+
}))
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Validate a `moi tab focus` target: static ids pass as-is, `view:<id>` must
|
|
42
|
-
// name a real view. Anything else — including view-builder tabs — fails with
|
|
43
|
-
// the list of valid ids. Addressing is by tab id, never by title.
|
|
44
|
-
export async function resolveFocusTab(raw: unknown, deps: FocusTabDeps): Promise<FocusTabResult> {
|
|
45
|
-
const tab = typeof raw === 'string' ? raw.trim() : ''
|
|
46
|
-
if (STATIC_TABS.some(row => row.id === tab)) return { ok: true, tab: tab as WorkspaceTabId }
|
|
47
|
-
|
|
48
|
-
const viewId = tab.startsWith('view:') ? viewIdFromTab(tab as WorkspaceTabId) : null
|
|
49
|
-
if (viewId && (await deps.hasView(viewId))) return { ok: true, tab: tab as WorkspaceTabId }
|
|
50
|
-
|
|
51
|
-
const validIds = [
|
|
52
|
-
...STATIC_TABS.map(row => row.id),
|
|
53
|
-
...(await deps.viewList()).map(view => viewTabId(view.id))
|
|
54
|
-
]
|
|
55
|
-
return {
|
|
56
|
-
ok: false,
|
|
57
|
-
error: `Unknown tab "${tab || String(raw ?? '')}". Valid tabs: ${validIds.join(', ')}`
|
|
58
|
-
}
|
|
36
|
+
// CLI navigation checks the server's current built-view list before asking a
|
|
37
|
+
// browser to move. The browser repeats the availability check in case its view
|
|
38
|
+
// list is stale in either direction.
|
|
39
|
+
export function assertNavigableTab(tab: WorkspaceTabId, views: ViewInfo[]): void {
|
|
40
|
+
const rows = assembleTabRows(views, 'agent').filter(row => row.href)
|
|
41
|
+
if (rows.some(row => row.id === tab)) return
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Unknown destination "${moiHref(tab)}". Valid addresses: ${rows.map(row => row.href).join(', ')}`
|
|
44
|
+
)
|
|
59
45
|
}
|
package/server/uploads.ts
CHANGED
|
Binary file
|
package/server/view-builders.ts
CHANGED
|
@@ -151,7 +151,7 @@ export async function beginViewBuilder(
|
|
|
151
151
|
): Promise<ViewBuilder> {
|
|
152
152
|
const text = requirements.trim()
|
|
153
153
|
if (!text && !hasSketch)
|
|
154
|
-
throw new ViewBuilderError('View requirements or
|
|
154
|
+
throw new ViewBuilderError('View requirements or an attachment are required', 400)
|
|
155
155
|
const builder = await mutateBuilders(workspacePath, builders => {
|
|
156
156
|
const [current, index] = findBuilder(builders, builderId)
|
|
157
157
|
if (current.status !== 'draft') {
|
|
@@ -434,3 +434,20 @@ export async function deleteViewBuilder(
|
|
|
434
434
|
})
|
|
435
435
|
publishEvent({ type: 'view-builder:deleted', workspaceId, builderId })
|
|
436
436
|
}
|
|
437
|
+
|
|
438
|
+
export async function deleteViewBuilderForView(
|
|
439
|
+
workspaceId: string,
|
|
440
|
+
workspacePath: string,
|
|
441
|
+
viewId: string
|
|
442
|
+
): Promise<void> {
|
|
443
|
+
const deleted = await mutateBuilders(workspacePath, builders => {
|
|
444
|
+
const index = builders.findIndex(
|
|
445
|
+
builder => builder.viewId === viewId && (builder.kind ?? 'view') === 'view'
|
|
446
|
+
)
|
|
447
|
+
if (index === -1) return null
|
|
448
|
+
return builders.splice(index, 1)[0]
|
|
449
|
+
})
|
|
450
|
+
if (deleted) {
|
|
451
|
+
publishEvent({ type: 'view-builder:deleted', workspaceId, builderId: deleted.id })
|
|
452
|
+
}
|
|
453
|
+
}
|
package/server/views.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
2
|
|
|
3
|
+
import { viewTabId } from '@/lib/workspace-tabs'
|
|
3
4
|
import type { ViewConfig, ViewInfo } from '@/lib/types'
|
|
4
5
|
|
|
5
6
|
import { syncAppletLogAfterBuild } from './applet-log'
|
|
@@ -11,11 +12,15 @@ import {
|
|
|
11
12
|
scanSources,
|
|
12
13
|
serveApplet
|
|
13
14
|
} from './applets'
|
|
15
|
+
import { serializeWorkspaceBundle } from './bundle-queue'
|
|
14
16
|
import { reloadModules } from './functions'
|
|
15
|
-
import {
|
|
17
|
+
import { loadLayout, saveLayout } from './layout'
|
|
18
|
+
import { deleteViewBuilderForView, markViewBuilderReady } from './view-builders'
|
|
19
|
+
import { setViewSourceTitle } from './applets/config'
|
|
20
|
+
import { deleteViewSourceFiles, readViewSource, ViewSourceInUseError } from './applets/view-source'
|
|
16
21
|
|
|
17
22
|
// The view applet kind. Sources in `.moi/views/`, compiled output + manifest in
|
|
18
|
-
// `.moi/.build/views/`; the shared mechanics live in `applets.ts`. Manifest
|
|
23
|
+
// `.moi/.build/views/`; the shared mechanics live in `applets/index.ts`. Manifest
|
|
19
24
|
// shape: `{ config: { <name>: ViewConfig }, order: [<name>, …] }`. `order` is the nav
|
|
20
25
|
// tab order — first-seen (creation) order, persisted so it's stable across
|
|
21
26
|
// rebuilds (the filesystem can't recover creation order).
|
|
@@ -24,6 +29,16 @@ type ViewManifest = {
|
|
|
24
29
|
order: string[]
|
|
25
30
|
}
|
|
26
31
|
|
|
32
|
+
export class ViewMutationError extends Error {
|
|
33
|
+
constructor(
|
|
34
|
+
message: string,
|
|
35
|
+
public status: 404 | 409 | 422
|
|
36
|
+
) {
|
|
37
|
+
super(message)
|
|
38
|
+
this.name = 'ViewMutationError'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
27
42
|
async function readManifest(workspacePath: string): Promise<ViewManifest> {
|
|
28
43
|
const { manifestPath } = getAppletPaths(workspacePath, 'view')
|
|
29
44
|
try {
|
|
@@ -60,9 +75,15 @@ export type ViewBuildResult = {
|
|
|
60
75
|
|
|
61
76
|
export async function buildAllViews(
|
|
62
77
|
workspacePath: string,
|
|
63
|
-
force = false
|
|
78
|
+
force = false,
|
|
79
|
+
target?: string
|
|
64
80
|
): Promise<ViewBuildResult[]> {
|
|
65
|
-
const { names, results, ms } = await buildApplets<ViewConfig>(
|
|
81
|
+
const { names, results, ms } = await buildApplets<ViewConfig>(
|
|
82
|
+
workspacePath,
|
|
83
|
+
'view',
|
|
84
|
+
force,
|
|
85
|
+
target
|
|
86
|
+
)
|
|
66
87
|
|
|
67
88
|
const manifest = await readManifest(workspacePath)
|
|
68
89
|
for (const r of results) {
|
|
@@ -162,11 +183,12 @@ export async function handleBundleViews(
|
|
|
162
183
|
force = false,
|
|
163
184
|
// When set, compile without advancing any view builder to `ready` (the
|
|
164
185
|
// `moi bundle --no-status` opt-out). The build still publishes `view:updated`.
|
|
165
|
-
skipStatus = false
|
|
186
|
+
skipStatus = false,
|
|
187
|
+
target?: string
|
|
166
188
|
) {
|
|
167
189
|
const before = await readManifest(workspacePath)
|
|
168
190
|
const beforeBuilt = new Set(await listBuiltViews(workspacePath))
|
|
169
|
-
const results = await buildAllViews(workspacePath, force)
|
|
191
|
+
const results = await buildAllViews(workspacePath, force, target)
|
|
170
192
|
const after = await readManifest(workspacePath)
|
|
171
193
|
const afterBuilt = new Set(await listBuiltViews(workspacePath))
|
|
172
194
|
|
|
@@ -215,6 +237,104 @@ export async function handleBundleViews(
|
|
|
215
237
|
return results
|
|
216
238
|
}
|
|
217
239
|
|
|
240
|
+
export async function updateViewTitle(
|
|
241
|
+
publish: (msg: unknown) => void,
|
|
242
|
+
workspaceId: string,
|
|
243
|
+
workspacePath: string,
|
|
244
|
+
viewId: string,
|
|
245
|
+
title: string
|
|
246
|
+
): Promise<ViewInfo> {
|
|
247
|
+
return serializeWorkspaceBundle(workspacePath, async () => {
|
|
248
|
+
const current = (await getViewList(workspacePath)).find(view => view.id === viewId)
|
|
249
|
+
if (!current) throw new ViewMutationError('View not found', 404)
|
|
250
|
+
if (current.config.title === title) return current
|
|
251
|
+
|
|
252
|
+
const source = await readViewSource(workspacePath, viewId)
|
|
253
|
+
if (!source) throw new ViewMutationError('View source not found', 409)
|
|
254
|
+
|
|
255
|
+
let updated: string
|
|
256
|
+
try {
|
|
257
|
+
updated = setViewSourceTitle(source.source, title)
|
|
258
|
+
} catch (error) {
|
|
259
|
+
throw new ViewMutationError(
|
|
260
|
+
error instanceof Error ? error.message : 'Could not update the view title',
|
|
261
|
+
409
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
if (updated === source.source) return current
|
|
265
|
+
|
|
266
|
+
await Bun.write(source.path, updated)
|
|
267
|
+
try {
|
|
268
|
+
// A rename changed this entry; rebuild only it and preserve builder status.
|
|
269
|
+
const results = await handleBundleViews(
|
|
270
|
+
publish,
|
|
271
|
+
workspaceId,
|
|
272
|
+
workspacePath,
|
|
273
|
+
true,
|
|
274
|
+
true,
|
|
275
|
+
viewId
|
|
276
|
+
)
|
|
277
|
+
const result = results.find(candidate => candidate.name === viewId)
|
|
278
|
+
if (result?.status !== 'built') {
|
|
279
|
+
throw new ViewMutationError(result?.error ?? 'Could not rebuild the renamed view', 422)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const renamed = (await getViewList(workspacePath)).find(view => view.id === viewId)
|
|
283
|
+
if (!renamed) {
|
|
284
|
+
throw new ViewMutationError('Renamed view was not found after rebuilding', 422)
|
|
285
|
+
}
|
|
286
|
+
return renamed
|
|
287
|
+
} catch (error) {
|
|
288
|
+
// An agent may have edited or removed the source while the build ran.
|
|
289
|
+
if (
|
|
290
|
+
(await Bun.file(source.path)
|
|
291
|
+
.text()
|
|
292
|
+
.catch(() => null)) === updated
|
|
293
|
+
) {
|
|
294
|
+
await Bun.write(source.path, source.source)
|
|
295
|
+
}
|
|
296
|
+
throw error
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export async function deleteView(
|
|
302
|
+
publish: (msg: unknown) => void,
|
|
303
|
+
workspaceId: string,
|
|
304
|
+
workspacePath: string,
|
|
305
|
+
viewId: string
|
|
306
|
+
): Promise<void> {
|
|
307
|
+
await serializeWorkspaceBundle(workspacePath, async () => {
|
|
308
|
+
const current = (await getViewList(workspacePath)).some(view => view.id === viewId)
|
|
309
|
+
if (!current) throw new ViewMutationError('View not found', 404)
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
await deleteViewSourceFiles(workspacePath, viewId)
|
|
313
|
+
} catch (error) {
|
|
314
|
+
if (error instanceof ViewSourceInUseError) throw new ViewMutationError(error.message, 409)
|
|
315
|
+
throw error
|
|
316
|
+
}
|
|
317
|
+
reloadModules([`views/${viewId}`], workspacePath)
|
|
318
|
+
await deleteViewBuilderForView(workspaceId, workspacePath, viewId)
|
|
319
|
+
const layout = await loadLayout(workspacePath)
|
|
320
|
+
const tab = viewTabId(viewId)
|
|
321
|
+
await saveLayout(
|
|
322
|
+
{
|
|
323
|
+
...layout,
|
|
324
|
+
tabs: {
|
|
325
|
+
open: layout.tabs.open.filter(candidate => candidate !== tab),
|
|
326
|
+
active: layout.tabs.active === tab ? 'overview' : layout.tabs.active
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
workspacePath
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
publish({ type: 'view:deleted', workspaceId, name: viewId })
|
|
333
|
+
publish({ type: 'workspace:updated' })
|
|
334
|
+
await handleBundleViews(publish, workspaceId, workspacePath, false, false, viewId)
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
|
|
218
338
|
export function serveView(
|
|
219
339
|
name: string,
|
|
220
340
|
file: string,
|
package/server/web.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
+
import { isMessageAttachments } from '@/lib/message-attachments'
|
|
1
2
|
import type { ClientMessage, StatusSnapshotMessage } from '@/lib/types'
|
|
2
3
|
import { isMoiContext } from '@/lib/moi-context'
|
|
3
4
|
|
|
4
5
|
import index from '../client/index.html'
|
|
5
6
|
import { api } from './api'
|
|
7
|
+
import { AttachmentUploadError } from './attachment-message'
|
|
6
8
|
import { PORT } from './constants'
|
|
7
9
|
import { control } from './control'
|
|
8
10
|
import { EVENTS_TOPIC, publishEvent, setEventServer } from './events'
|
|
9
|
-
import { killBuildWorkers } from './
|
|
11
|
+
import { killBuildWorkers } from './applets/build-worker'
|
|
10
12
|
import { killAllWorkers } from './functions'
|
|
11
13
|
import { startScratchpadSweeper } from './scratchpad'
|
|
14
|
+
import { navigationRelay } from './navigation-relay'
|
|
12
15
|
import { resolveScratchOp } from './scratchpad-relay'
|
|
13
16
|
import { allHarnesses, harnessFor } from './harness/registry'
|
|
14
17
|
import { getWorkspace } from './registry'
|
|
15
18
|
import { saveSelectedSession } from './selected-session'
|
|
16
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
addClient,
|
|
21
|
+
broadcast,
|
|
22
|
+
broadcastAll,
|
|
23
|
+
getClientCount,
|
|
24
|
+
removeClient,
|
|
25
|
+
sendToClient
|
|
26
|
+
} from './state'
|
|
17
27
|
import { startServiceLogMaintenance } from './service'
|
|
18
28
|
import { distShell, prebuilt } from './static'
|
|
19
29
|
import { renderStatus } from './status'
|
|
@@ -50,8 +60,7 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
50
60
|
(v.fastMode === undefined || typeof v.fastMode === 'boolean') &&
|
|
51
61
|
(v.stream === undefined || typeof v.stream === 'boolean') &&
|
|
52
62
|
(v.context === undefined || isMoiContext(v.context)) &&
|
|
53
|
-
(v.attachments === undefined ||
|
|
54
|
-
(Array.isArray(v.attachments) && v.attachments.every(a => typeof a === 'string')))
|
|
63
|
+
(v.attachments === undefined || isMessageAttachments(v.attachments))
|
|
55
64
|
)
|
|
56
65
|
if (v.type === 'stop') return typeof v.workspaceId === 'string' && typeof v.sessionId === 'string'
|
|
57
66
|
if (v.type === 'scratchpad:op-result') return typeof v.opId === 'string'
|
|
@@ -138,7 +147,12 @@ export const app = Bun.serve<WsData>({
|
|
|
138
147
|
}
|
|
139
148
|
},
|
|
140
149
|
async message(ws, message) {
|
|
141
|
-
if (ws.data.channel
|
|
150
|
+
if (ws.data.channel === 'events') {
|
|
151
|
+
try {
|
|
152
|
+
navigationRelay.receive(ws, JSON.parse(String(message)))
|
|
153
|
+
} catch {}
|
|
154
|
+
return
|
|
155
|
+
}
|
|
142
156
|
try {
|
|
143
157
|
const data = JSON.parse(String(message))
|
|
144
158
|
if (!isClientMessage(data)) return
|
|
@@ -157,8 +171,9 @@ export const app = Bun.serve<WsData>({
|
|
|
157
171
|
})
|
|
158
172
|
}
|
|
159
173
|
}
|
|
160
|
-
// Harnesses ignore fields they don't support (see SendMessageInput)
|
|
161
|
-
// failures surface
|
|
174
|
+
// Harnesses ignore fields they don't support (see SendMessageInput).
|
|
175
|
+
// Their failures surface internally; attachment resolution happens
|
|
176
|
+
// before a harness owns the send, so surface that one here.
|
|
162
177
|
void harnessFor(workspace)
|
|
163
178
|
.sendMessage({
|
|
164
179
|
workspaceId: data.workspaceId,
|
|
@@ -175,7 +190,15 @@ export const app = Bun.serve<WsData>({
|
|
|
175
190
|
context: data.context,
|
|
176
191
|
agentId: workspace.agentId
|
|
177
192
|
})
|
|
178
|
-
.catch(
|
|
193
|
+
.catch(error => {
|
|
194
|
+
if (error instanceof AttachmentUploadError) {
|
|
195
|
+
broadcast(data.workspaceId, {
|
|
196
|
+
kind: 'error',
|
|
197
|
+
sessionId: data.sessionId,
|
|
198
|
+
content: error.message
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
})
|
|
179
202
|
}
|
|
180
203
|
if (data.type === 'stop') {
|
|
181
204
|
const workspace = await getWorkspace(data.workspaceId)
|
|
@@ -192,7 +215,10 @@ export const app = Bun.serve<WsData>({
|
|
|
192
215
|
},
|
|
193
216
|
close(ws) {
|
|
194
217
|
if (ws.data.channel === 'chat') removeClient(ws)
|
|
195
|
-
else
|
|
218
|
+
else {
|
|
219
|
+
navigationRelay.remove(ws)
|
|
220
|
+
ws.unsubscribe(EVENTS_TOPIC)
|
|
221
|
+
}
|
|
196
222
|
}
|
|
197
223
|
}
|
|
198
224
|
})
|
package/server/widgets.ts
CHANGED
|
@@ -11,7 +11,7 @@ const VALID_SPANS = [1, 2, 3, 4]
|
|
|
11
11
|
|
|
12
12
|
// The widget applet kind. Sources in `.moi/widgets/`, compiled output +
|
|
13
13
|
// manifest in `.moi/.build/widgets/`; the shared mechanics live in
|
|
14
|
-
// `applets.ts`. Manifest shape: `{ config: { <name>: WidgetConfig } }`.
|
|
14
|
+
// `applets/index.ts`. Manifest shape: `{ config: { <name>: WidgetConfig } }`.
|
|
15
15
|
async function readManifest(workspacePath: string): Promise<Record<string, WidgetConfig>> {
|
|
16
16
|
const { manifestPath } = getAppletPaths(workspacePath, 'widget')
|
|
17
17
|
try {
|
|
@@ -40,9 +40,15 @@ export type WidgetBuildResult = {
|
|
|
40
40
|
|
|
41
41
|
export async function buildAllWidgets(
|
|
42
42
|
workspacePath: string,
|
|
43
|
-
force = false
|
|
43
|
+
force = false,
|
|
44
|
+
target?: string
|
|
44
45
|
): Promise<WidgetBuildResult[]> {
|
|
45
|
-
const { names, results, ms } = await buildApplets<WidgetConfig>(
|
|
46
|
+
const { names, results, ms } = await buildApplets<WidgetConfig>(
|
|
47
|
+
workspacePath,
|
|
48
|
+
'widget',
|
|
49
|
+
force,
|
|
50
|
+
target
|
|
51
|
+
)
|
|
46
52
|
|
|
47
53
|
const manifest = await readManifest(workspacePath)
|
|
48
54
|
for (const r of results) {
|
|
@@ -118,11 +124,12 @@ export async function listWidgets(workspacePath: string): Promise<Response> {
|
|
|
118
124
|
export async function handleBundle(
|
|
119
125
|
publish: (msg: unknown) => void,
|
|
120
126
|
workspacePath: string,
|
|
121
|
-
force = false
|
|
127
|
+
force = false,
|
|
128
|
+
target?: string
|
|
122
129
|
) {
|
|
123
130
|
const before = new Set(await listBuiltWidgets(workspacePath))
|
|
124
131
|
const manifestBefore = await readManifest(workspacePath)
|
|
125
|
-
const results = await buildAllWidgets(workspacePath, force)
|
|
132
|
+
const results = await buildAllWidgets(workspacePath, force, target)
|
|
126
133
|
const after = new Set(await listBuiltWidgets(workspacePath))
|
|
127
134
|
|
|
128
135
|
// Keep the applet error journal honest: record build failures, clear entries
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type { WorkspaceLayout } from '@/lib/types'
|
|
1
|
+
import type { WorkspaceIcon, WorkspaceLayout } from '@/lib/types'
|
|
2
2
|
|
|
3
3
|
import { loadLayout, saveLayout } from './layout'
|
|
4
4
|
|
|
5
|
-
// Workspace identity stored in the layout: a display-name override
|
|
6
|
-
//
|
|
7
|
-
// defaults at the API layer.
|
|
5
|
+
// Workspace identity stored in the layout: a display-name override, an icon,
|
|
6
|
+
// and its optional host-painted background.
|
|
8
7
|
export type WorkspaceConfig = {
|
|
9
8
|
name?: string
|
|
10
|
-
icon?:
|
|
9
|
+
icon?: WorkspaceIcon
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type WorkspaceConfigPatch = {
|
|
13
|
+
name?: string | null
|
|
14
|
+
icon?: WorkspaceIcon | null
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
export async function getWorkspaceConfig(workspacePath: string): Promise<WorkspaceConfig> {
|
|
@@ -15,12 +19,12 @@ export async function getWorkspaceConfig(workspacePath: string): Promise<Workspa
|
|
|
15
19
|
return { name: layout.name, icon: layout.icon }
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
// Apply
|
|
19
|
-
//
|
|
20
|
-
//
|
|
22
|
+
// Apply an identity patch to the workspace layout. For each field: a value sets
|
|
23
|
+
// it, `null` clears it, and `undefined` leaves it unchanged. Clearing the icon
|
|
24
|
+
// always clears its presentation metadata too.
|
|
21
25
|
export async function setWorkspaceConfig(
|
|
22
26
|
workspacePath: string,
|
|
23
|
-
patch:
|
|
27
|
+
patch: WorkspaceConfigPatch
|
|
24
28
|
): Promise<WorkspaceLayout> {
|
|
25
29
|
const layout = await loadLayout(workspacePath)
|
|
26
30
|
const next: WorkspaceLayout = { ...layout }
|