moi-computer 0.13.1-next.1 → 0.13.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/client/api/app-config.ts +12 -1
- package/client/api/http.ts +11 -1
- package/client/app/app-router.tsx +3 -2
- package/client/app/routes/home-route.tsx +1 -1
- package/client/app/routes/workspace-registration.tsx +68 -0
- package/client/app/routes/workspace-route.tsx +33 -6
- package/client/app/shell/sidebar-layout.tsx +10 -5
- package/client/components/shared/workspace-icon.tsx +8 -17
- package/client/features/account/account-test-utils.tsx +15 -9
- package/client/features/account/api.ts +6 -6
- package/client/features/account/profile-actions.ts +5 -7
- package/client/features/app-settings/settings-page.tsx +2 -1
- package/client/features/applets/api.ts +6 -6
- package/client/features/applets/applet-cache.ts +6 -5
- package/client/features/applets/applet-log.ts +2 -1
- package/client/features/applets/applet-runtime.ts +2 -1
- package/client/features/applets/use-applet.ts +73 -18
- package/client/features/applets/widget-shell.tsx +4 -2
- package/client/features/chat/applet-chat-intents.ts +5 -13
- package/client/features/chat/chat-popup.tsx +8 -4
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/composer/model-order.ts +4 -4
- package/client/features/chat/composer/model-picker.tsx +12 -10
- package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
- package/client/features/chat/sessions/api.ts +11 -28
- package/client/features/chat/sessions/use-selected-session.ts +14 -109
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/members/api.ts +4 -10
- package/client/features/collab/members/hooks.ts +32 -38
- package/client/features/collab/members/store.ts +96 -71
- package/client/features/collab/members/types.ts +5 -3
- package/client/features/collab/presence/client.ts +2 -3
- package/client/features/collab/presence/hooks.tsx +1 -1
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/workspace-members.tsx +0 -8
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -1
- package/client/features/dev/workspace-setup-preview.tsx +6 -4
- package/client/features/harness/api.ts +13 -10
- package/client/features/harness/harness-login-panel.tsx +9 -5
- package/client/features/harness/harness-presentation.ts +4 -4
- package/client/features/harness/harness-selector.tsx +13 -13
- package/client/features/harness/use-harness-login.ts +5 -5
- package/client/features/home/api.ts +38 -2
- package/client/features/home/home-page.tsx +43 -13
- package/client/features/home/shared-workspaces.tsx +70 -0
- package/client/features/home/workspace-invitations.tsx +101 -0
- package/client/features/identity/host-api.ts +3 -2
- package/client/features/identity/store.ts +1 -7
- package/client/features/onboarding/agent-setup-step.tsx +8 -8
- package/client/features/onboarding/onboarding-page.tsx +3 -2
- package/client/features/onboarding/workspace-setup-step.tsx +1 -1
- package/client/features/overview/api.ts +3 -5
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/views-widget.tsx +2 -2
- package/client/features/overview/hidden-panel.tsx +7 -5
- package/client/features/overview/overview.tsx +18 -16
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +9 -7
- package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
- package/client/features/views/api.ts +66 -23
- package/client/features/views/use-view-actions.ts +10 -41
- package/client/features/views/view-manager.tsx +1 -1
- package/client/features/views/view-submission.ts +2 -21
- package/client/features/workspace/add/api.ts +5 -4
- package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
- package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
- package/client/features/workspace/add/use-workspace-import.ts +10 -10
- package/client/features/workspace/add/workspace-agent-options.ts +21 -20
- package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
- package/client/features/workspace/api.ts +60 -13
- package/client/features/workspace/harness-transition.ts +7 -13
- package/client/features/workspace/remote.ts +25 -0
- package/client/features/workspace/settings/api.ts +7 -12
- package/client/features/workspace/settings/connectors-settings.tsx +3 -3
- package/client/features/workspace/settings/general-settings.tsx +8 -8
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
- package/client/features/workspace/setup/workspace-setup.tsx +6 -6
- package/client/features/workspace/tab-resolution.ts +1 -8
- package/client/features/workspace/use-workspace-navigation.ts +11 -7
- package/client/features/workspace/workspace-content.tsx +24 -31
- package/client/features/workspace/workspace-frame.tsx +13 -26
- package/client/features/workspace/workspace-layout-context.tsx +45 -12
- package/client/features/workspace/workspace-menu.tsx +2 -2
- package/client/features/workspace/workspace-pane.tsx +22 -0
- package/client/features/workspace/workspace-pending-screen.tsx +1 -1
- package/client/features/workspace/workspace-preferences.ts +91 -0
- package/client/features/workspace/workspace-presentation.tsx +12 -16
- package/client/features/workspace/workspace-screen.tsx +2 -2
- package/client/features/workspace/workspace-state.ts +42 -16
- package/client/features/workspace/workspace-tabs.tsx +1 -1
- package/client/features/workspace/workspace-test-utils.ts +23 -0
- package/client/runtime/use-workspace-events.ts +14 -0
- package/client/runtime/workspace-events.ts +9 -9
- package/client/store/ui.ts +24 -9
- package/client/store/workspace-session.ts +30 -0
- package/dist/chunk-0h4zypgf.js +1 -0
- package/dist/chunk-1tksq43z.js +72 -0
- package/dist/chunk-6gxf0xr8.js +5 -0
- package/dist/chunk-a865c7x4.js +1 -0
- package/dist/chunk-f44cs6mw.js +2 -0
- package/dist/chunk-h3qag4a6.js +2 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/chunk-q2tpy0h7.js +2 -0
- package/dist/chunk-r95acex1.js +546 -0
- package/dist/chunk-w5h9grdr.js +1 -0
- package/dist/{chunk-th91xfnp.js → chunk-xj1pjhng.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/moi-context.ts +19 -5
- package/lib/types.ts +38 -54
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +5 -24
- package/package.json +5 -2
- package/server/AGENTS.md +1 -1
- package/server/README.md +36 -31
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +268 -162
- package/server/applets/index.ts +15 -9
- package/server/applets/views.ts +2 -17
- package/server/applets/widgets.ts +3 -2
- package/server/cli/commands/config.ts +8 -20
- package/server/cli/commands/hermes.ts +2 -2
- package/server/cli/commands/init.ts +102 -54
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +330 -0
- package/server/cli/commands/skill.ts +4 -4
- package/server/cli/commands/tabs.ts +5 -12
- package/server/cli/control.ts +35 -4
- package/server/cli/index.ts +10 -6
- package/server/cli/remote-command.ts +77 -0
- package/server/cli/remote-control.ts +73 -0
- package/server/cli/remote-operations.ts +247 -0
- package/server/collab/config.ts +3 -3
- package/server/collab/skill/index.ts +3 -3
- package/server/control.ts +47 -12
- package/server/harness/acp/session.ts +4 -4
- package/server/harness/auth.ts +26 -31
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/codex/discovery.ts +1 -1
- package/server/harness/codex/session.ts +1 -1
- package/server/harness/detect.ts +14 -19
- package/server/harness/executable.ts +10 -10
- package/server/harness/hermes/NOTES.md +2 -2
- package/server/harness/hermes/index.ts +1 -1
- package/server/harness/install.ts +11 -11
- package/server/harness/openclaw/index.ts +1 -1
- package/server/harness/registry.ts +7 -6
- package/server/harness/types.ts +4 -4
- package/server/onboarding/jobs.ts +2 -2
- package/server/operations/commands.ts +46 -0
- package/server/operations/files.ts +148 -0
- package/server/operations/server.ts +206 -0
- package/server/remote/agent.ts +103 -0
- package/server/remote/broker-client.ts +76 -0
- package/server/remote/broker.ts +81 -0
- package/server/remote/client.ts +725 -0
- package/server/remote/errors.ts +2 -0
- package/server/remote/routes.ts +121 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +33 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +17 -0
- package/server/sessions/send-message.ts +102 -0
- package/server/sessions/view-sessions.ts +9 -101
- package/server/skills/locations.ts +4 -4
- package/server/skills/update.ts +11 -11
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -11
- package/server/web.ts +13 -9
- package/server/workspace-state/file.ts +4 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +24 -0
- package/server/workspaces/change-harness.ts +15 -26
- package/server/workspaces/import.ts +4 -4
- package/server/workspaces/init.ts +15 -13
- package/server/workspaces/layout.ts +60 -66
- package/server/workspaces/registry.ts +43 -18
- package/server/workspaces/shared.ts +74 -0
- package/server/workspaces/tabs.ts +5 -12
- package/skill/SKILL.md +80 -19
- package/skill/references/SCRATCHPAD.md +4 -0
- package/skill/references/UI-COMPONENTS.md +1 -1
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/members/keys.ts +0 -6
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-3smkkcfw.js +0 -546
- package/dist/chunk-47h9c2qy.js +0 -2
- package/dist/chunk-8qed2gqp.js +0 -75
- package/dist/chunk-8zy3vesm.js +0 -1
- package/dist/chunk-a47zy276.js +0 -2
- package/dist/chunk-g4c1nte9.css +0 -1
- package/dist/chunk-kcactdr4.js +0 -2
- package/dist/chunk-m8bhx6tw.js +0 -1
- package/dist/chunk-pf19zcrn.js +0 -2
- package/dist/chunk-ygzxah0e.js +0 -1
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
package/server/skills/update.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename } from 'node:path'
|
|
2
2
|
|
|
3
|
-
import type { WorkspaceSkillsStatus, WorkspaceSkillStatus,
|
|
3
|
+
import type { WorkspaceSkillsStatus, WorkspaceSkillStatus, HarnessType } from '@/lib/types'
|
|
4
4
|
|
|
5
5
|
import type { AppletDeclarationFile } from '../applets/declarations'
|
|
6
6
|
import { syncAppletDeclarations } from '../applets/declarations'
|
|
@@ -31,29 +31,29 @@ export function summarizeSkillStatuses(skills: WorkspaceSkillStatus[]): Workspac
|
|
|
31
31
|
|
|
32
32
|
export async function getWorkspaceSkillsStatus(
|
|
33
33
|
workspaceRoot: string,
|
|
34
|
-
|
|
34
|
+
harness?: HarnessType
|
|
35
35
|
): Promise<WorkspaceSkillsStatus> {
|
|
36
|
-
return summarizeSkillStatuses(await skillStatuses(workspaceRoot,
|
|
36
|
+
return summarizeSkillStatuses(await skillStatuses(workspaceRoot, harness))
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export async function updateWorkspaceSkills(
|
|
40
40
|
workspaceRoot: string,
|
|
41
|
-
|
|
41
|
+
harness: HarnessType = 'claude-code'
|
|
42
42
|
): Promise<WorkspaceSkillUpdateResult> {
|
|
43
|
-
return withSkillLock(workspaceSkillLockPath(workspaceRoot,
|
|
44
|
-
updateWorkspaceSkillFiles(workspaceRoot,
|
|
43
|
+
return withSkillLock(workspaceSkillLockPath(workspaceRoot, harness), () =>
|
|
44
|
+
updateWorkspaceSkillFiles(workspaceRoot, harness)
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
async function updateWorkspaceSkillFiles(
|
|
49
49
|
workspaceRoot: string,
|
|
50
|
-
|
|
50
|
+
harness: HarnessType
|
|
51
51
|
): Promise<WorkspaceSkillUpdateResult> {
|
|
52
|
-
const locations = await resolveSkillLocations(workspaceRoot,
|
|
52
|
+
const locations = await resolveSkillLocations(workspaceRoot, harness)
|
|
53
53
|
const before = await skillStatusesForLocations(locations)
|
|
54
54
|
let changedSkillPaths: string[]
|
|
55
|
-
if (usesSharedWorkspaceSkill(
|
|
56
|
-
changedSkillPaths = await installWorkspaceSkillFiles(workspaceRoot,
|
|
55
|
+
if (usesSharedWorkspaceSkill(harness)) {
|
|
56
|
+
changedSkillPaths = await installWorkspaceSkillFiles(workspaceRoot, harness)
|
|
57
57
|
} else {
|
|
58
58
|
for (const location of locations) {
|
|
59
59
|
if (location.brokenLink) {
|
|
@@ -82,7 +82,7 @@ async function updateWorkspaceSkillFiles(
|
|
|
82
82
|
// Applet declarations ship with the CLI, so refresh installed copies along
|
|
83
83
|
// with skills.
|
|
84
84
|
const updatedAppletTypes = await syncAppletDeclarations(workspaceRoot)
|
|
85
|
-
const skills = await skillStatuses(workspaceRoot,
|
|
85
|
+
const skills = await skillStatuses(workspaceRoot, harness)
|
|
86
86
|
|
|
87
87
|
return {
|
|
88
88
|
before,
|
package/server/skills/version.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// drives both the CLI status and the frontend's automatic update check.
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
|
|
6
|
-
import type { WorkspaceSkillStatus,
|
|
6
|
+
import type { WorkspaceSkillStatus, HarnessType } from '@/lib/types'
|
|
7
7
|
|
|
8
8
|
import { findWorkspaceForPath, liftToWorkspaceRoot, listWorkspaces } from '../workspaces/registry'
|
|
9
9
|
import { bundledSkillDirectory } from './template'
|
|
@@ -74,9 +74,9 @@ export const isBehind = (installed: string | null, bundled: string | null): bool
|
|
|
74
74
|
// Report every installed copy, plus the required primary harness destination.
|
|
75
75
|
export async function skillStatuses(
|
|
76
76
|
workspaceRoot: string,
|
|
77
|
-
|
|
77
|
+
harness?: HarnessType
|
|
78
78
|
): Promise<WorkspaceSkillStatus[]> {
|
|
79
|
-
return skillStatusesForLocations(await resolveSkillLocations(workspaceRoot,
|
|
79
|
+
return skillStatusesForLocations(await resolveSkillLocations(workspaceRoot, harness))
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export async function skillStatusesForLocations(
|
|
@@ -92,7 +92,7 @@ export async function skillStatusesForLocations(
|
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export type ResolvedWorkspace = { root: string;
|
|
95
|
+
export type ResolvedWorkspace = { root: string; harness?: HarnessType }
|
|
96
96
|
|
|
97
97
|
// Resolve a path to its workspace root: the registered workspace that owns it
|
|
98
98
|
// (carrying its backend type), else lifted out of any `.moi/`, else the path
|
|
@@ -100,7 +100,7 @@ export type ResolvedWorkspace = { root: string; type?: WorkspaceType }
|
|
|
100
100
|
// the same places.
|
|
101
101
|
export async function resolveWorkspace(cwd: string): Promise<ResolvedWorkspace> {
|
|
102
102
|
const ws = findWorkspaceForPath(await listWorkspaces(), cwd)
|
|
103
|
-
if (ws) return { root: ws.path,
|
|
103
|
+
if (ws) return { root: ws.path, harness: ws.harness }
|
|
104
104
|
return { root: liftToWorkspaceRoot(cwd) }
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -114,8 +114,8 @@ export async function resolveWorkspaceRoot(cwd: string): Promise<string> {
|
|
|
114
114
|
// version checks must not break the command they ride on.
|
|
115
115
|
export async function staleSkillNotice(cwd: string): Promise<string | null> {
|
|
116
116
|
try {
|
|
117
|
-
const { root,
|
|
118
|
-
const stale = (await skillStatuses(root,
|
|
117
|
+
const { root, harness } = await resolveWorkspace(cwd)
|
|
118
|
+
const stale = (await skillStatuses(root, harness)).filter(s =>
|
|
119
119
|
isMinorBehind(s.installed, s.bundled)
|
|
120
120
|
)
|
|
121
121
|
if (stale.length === 0) return null
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lstat, mkdir, mkdtemp, readlink, realpath, rename, rm, symlink } from 'node:fs/promises'
|
|
2
2
|
import { dirname, join, relative, resolve } from 'node:path'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { HarnessType } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
import { installBundledSkill, installBundledSkills, matchesBundledSkill } from './template'
|
|
7
7
|
import { skillsDirFor } from '../workspaces/init'
|
|
@@ -9,8 +9,8 @@ import { withSkillLock } from './lock'
|
|
|
9
9
|
|
|
10
10
|
const SKILL_NAME = 'moi-workspace'
|
|
11
11
|
|
|
12
|
-
export function usesSharedWorkspaceSkill(
|
|
13
|
-
return
|
|
12
|
+
export function usesSharedWorkspaceSkill(harness?: HarnessType): boolean {
|
|
13
|
+
return harness === undefined || harness === 'claude-code' || harness === 'codex'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async function entryAt(path: string) {
|
|
@@ -31,24 +31,26 @@ async function checkSkillsDirectory(path: string): Promise<void> {
|
|
|
31
31
|
|
|
32
32
|
export async function installWorkspaceSkills(
|
|
33
33
|
root: string,
|
|
34
|
-
|
|
34
|
+
harness?: HarnessType
|
|
35
35
|
): Promise<string[]> {
|
|
36
|
-
return withSkillLock(workspaceSkillLockPath(root,
|
|
37
|
-
installWorkspaceSkillFiles(root,
|
|
36
|
+
return withSkillLock(workspaceSkillLockPath(root, harness), () =>
|
|
37
|
+
installWorkspaceSkillFiles(root, harness)
|
|
38
38
|
)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export function workspaceSkillLockPath(root: string,
|
|
42
|
-
return usesSharedWorkspaceSkill(
|
|
41
|
+
export function workspaceSkillLockPath(root: string, harness?: HarnessType): string {
|
|
42
|
+
return usesSharedWorkspaceSkill(harness)
|
|
43
|
+
? join(root, '.agents', 'skills')
|
|
44
|
+
: skillsDirFor(root, harness)
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
// Callers must hold the workspace skill lock across any surrounding status reads.
|
|
46
48
|
export async function installWorkspaceSkillFiles(
|
|
47
49
|
root: string,
|
|
48
|
-
|
|
50
|
+
harness?: HarnessType
|
|
49
51
|
): Promise<string[]> {
|
|
50
|
-
if (usesSharedWorkspaceSkill(
|
|
51
|
-
const directory = skillsDirFor(root,
|
|
52
|
+
if (usesSharedWorkspaceSkill(harness)) return resetWorkspaceSkill(root)
|
|
53
|
+
const directory = skillsDirFor(root, harness)
|
|
52
54
|
return (await installBundledSkills(directory)).map(name => join(directory, name))
|
|
53
55
|
}
|
|
54
56
|
|
package/server/web.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { ClientMessage, StatusSnapshotMessage } from '@/lib/types'
|
|
|
5
5
|
import { isMoiContext } from '@/lib/moi-context'
|
|
6
6
|
|
|
7
7
|
import { rm } from 'node:fs/promises'
|
|
8
|
+
import { dirname, join } from 'node:path'
|
|
9
|
+
import { startOperations, stopOperations } from './operations/server'
|
|
8
10
|
|
|
9
11
|
import index from '../client/index.html'
|
|
10
12
|
import devSandbox from '../client/dev/index.html'
|
|
@@ -23,9 +25,9 @@ import { navigationRelay } from './navigation-relay'
|
|
|
23
25
|
import { resolveScratchOp } from './scratchpad/relay'
|
|
24
26
|
import { allHarnesses, harnessFor } from './harness/registry'
|
|
25
27
|
import { getWorkspace, listWorkspaces } from './workspaces/registry'
|
|
26
|
-
import { failInterruptedViewStarts
|
|
28
|
+
import { failInterruptedViewStarts } from './sessions/view-sessions'
|
|
29
|
+
import { sendWorkspaceMessage } from './sessions/send-message'
|
|
27
30
|
import { prepareWorkspaceStates } from './workspace-state'
|
|
28
|
-
import { migrateLegacyWorkspaceState } from './workspace-state/legacy-migration'
|
|
29
31
|
import {
|
|
30
32
|
addClient,
|
|
31
33
|
broadcast,
|
|
@@ -55,7 +57,6 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
55
57
|
sessionId?: unknown
|
|
56
58
|
content?: unknown
|
|
57
59
|
isNew?: unknown
|
|
58
|
-
selectedSessionScope?: unknown
|
|
59
60
|
optimisticId?: unknown
|
|
60
61
|
model?: unknown
|
|
61
62
|
effort?: unknown
|
|
@@ -71,9 +72,6 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
71
72
|
typeof v.content === 'string' &&
|
|
72
73
|
typeof v.sessionId === 'string' &&
|
|
73
74
|
typeof v.isNew === 'boolean' &&
|
|
74
|
-
(v.selectedSessionScope === undefined ||
|
|
75
|
-
v.selectedSessionScope === 'shared' ||
|
|
76
|
-
v.selectedSessionScope === 'browser-tab') &&
|
|
77
75
|
(v.optimisticId === undefined || typeof v.optimisticId === 'string') &&
|
|
78
76
|
(v.model === undefined || typeof v.model === 'string') &&
|
|
79
77
|
(v.effort === undefined || typeof v.effort === 'string') &&
|
|
@@ -111,7 +109,6 @@ function upgrade(server: Upgradable, req: Request, data: WsData) {
|
|
|
111
109
|
// WebSocket channels (which need Bun's native `server.upgrade` + pub/sub). Every
|
|
112
110
|
// HTTP API route is delegated to the Hono app (`./api`) via `fetch`.
|
|
113
111
|
const registeredWorkspaces = await listWorkspaces()
|
|
114
|
-
await migrateLegacyWorkspaceState(registeredWorkspaces)
|
|
115
112
|
await prepareWorkspaceStates(registeredWorkspaces)
|
|
116
113
|
await Promise.all(registeredWorkspaces.map(failInterruptedViewStarts))
|
|
117
114
|
|
|
@@ -125,6 +122,10 @@ const listen = unixSocket
|
|
|
125
122
|
? { unix: unixSocket }
|
|
126
123
|
: { port: PORT, hostname: process.env.HOST ?? '127.0.0.1' }
|
|
127
124
|
|
|
125
|
+
const operations = unixSocket
|
|
126
|
+
? await startOperations(join(dirname(unixSocket), 'ops.sock'))
|
|
127
|
+
: undefined
|
|
128
|
+
|
|
128
129
|
export const app = Bun.serve<WsData>({
|
|
129
130
|
// Bun types the port and Unix-socket listeners as separate overloads, so a
|
|
130
131
|
// listener picked at runtime is cast to one of them; the runtime takes either.
|
|
@@ -153,6 +154,8 @@ export const app = Bun.serve<WsData>({
|
|
|
153
154
|
|
|
154
155
|
// Client-side routes — serve the SPA shell.
|
|
155
156
|
'/': shell,
|
|
157
|
+
// Demo serves home at /demo (see homePath in client/api/app-config.ts).
|
|
158
|
+
...(getAppConfig().demo ? { '/demo': shell } : {}),
|
|
156
159
|
'/dev': shell,
|
|
157
160
|
'/dev/*': shell,
|
|
158
161
|
// Isolated sandboxes bypass app startup and share the client/dev entry point.
|
|
@@ -174,7 +177,7 @@ export const app = Bun.serve<WsData>({
|
|
|
174
177
|
'/api/workspaces/ws': (req: Request, server: Bun.Server<WsData>) =>
|
|
175
178
|
upgrade(server, req, { channel: 'events', workspaceId: '' }),
|
|
176
179
|
|
|
177
|
-
'/api/workspaces/:id/collab
|
|
180
|
+
'/api/workspaces/:id/collab': async (req: Request, server: Bun.Server<WsData>) => {
|
|
178
181
|
const workspaceId = decodeURIComponent(new URL(req.url).pathname.split('/')[3] ?? '')
|
|
179
182
|
const workspace = await getWorkspace(workspaceId)
|
|
180
183
|
if (!workspace) return new Response('Workspace not found', { status: 404 })
|
|
@@ -246,7 +249,6 @@ export const app = Bun.serve<WsData>({
|
|
|
246
249
|
workspacePath: workspace.path,
|
|
247
250
|
sessionId: data.sessionId,
|
|
248
251
|
isNew: data.isNew,
|
|
249
|
-
selectedSessionScope: data.selectedSessionScope,
|
|
250
252
|
content: data.content.trim(),
|
|
251
253
|
attachments: data.attachments,
|
|
252
254
|
optimisticId: data.optimisticId,
|
|
@@ -321,6 +323,8 @@ async function shutdown() {
|
|
|
321
323
|
shuttingDown = true
|
|
322
324
|
try {
|
|
323
325
|
app.stop(true)
|
|
326
|
+
operations?.stop(true)
|
|
327
|
+
stopOperations()
|
|
324
328
|
} catch {}
|
|
325
329
|
try {
|
|
326
330
|
control.stop(true)
|
|
@@ -4,6 +4,7 @@ import { dirname } from 'node:path'
|
|
|
4
4
|
|
|
5
5
|
import type { PendingView, SessionFork, WorkspaceSessionState } from '@/lib/types'
|
|
6
6
|
import { isWorkspaceTabId } from '@/lib/workspace-tabs'
|
|
7
|
+
import { normalizeOpenTabs } from '@/lib/workspace-layout'
|
|
7
8
|
import { LockTimeoutError, type Lease } from './lock'
|
|
8
9
|
import { WORKSPACE_STATE_VERSION, type StoredWorkspaceState } from './types'
|
|
9
10
|
|
|
@@ -95,8 +96,11 @@ export function normalizeWorkspaceState(
|
|
|
95
96
|
workspacePath: string
|
|
96
97
|
): StoredWorkspaceState {
|
|
97
98
|
const state = emptyWorkspaceState(optionalString(value.workspacePath) ?? workspacePath)
|
|
99
|
+
if (Array.isArray(value.openTabs)) state.openTabs = normalizeOpenTabs(value.openTabs)
|
|
98
100
|
if (typeof value.revision === 'number' && Number.isSafeInteger(value.revision))
|
|
99
101
|
state.revision = value.revision
|
|
102
|
+
if (isRecord(value.chatDefaults))
|
|
103
|
+
state.chatDefaults = normalizeSession({ config: value.chatDefaults }).config ?? {}
|
|
100
104
|
const pinned = optionalString(value.pinnedSessionId)
|
|
101
105
|
if (pinned) state.pinnedSessionId = pinned
|
|
102
106
|
if (isRecord(value.selected)) {
|
|
@@ -104,10 +104,6 @@ export async function updateWorkspaceState<T>(
|
|
|
104
104
|
})
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
export function hasWorkspaceState(workspaceId: string): boolean {
|
|
108
|
-
return existsSync(statePath(workspaceId))
|
|
109
|
-
}
|
|
110
|
-
|
|
111
107
|
async function listStateIds(): Promise<string[]> {
|
|
112
108
|
try {
|
|
113
109
|
const entries = await readdir(root, { withFileTypes: true })
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RemoteWorkspaceTarget } from '@/lib/workspace-config'
|
|
2
|
+
import { remoteRequest } from '../remote/client'
|
|
3
|
+
|
|
4
|
+
export type WorkspaceApiTarget = { remote: RemoteWorkspaceTarget }
|
|
5
|
+
|
|
6
|
+
// CLI requests for a linked folder's shared content go to the owner's workspace API.
|
|
7
|
+
// Local workspaces never come through here; their handlers read the folder directly.
|
|
8
|
+
// `path` comes from `cloudRoutes` (server/remote/routes.ts).
|
|
9
|
+
export async function requestWorkspace(path: string, init?: RequestInit): Promise<Response> {
|
|
10
|
+
// Serialize multipart bodies once so the signature and content type match the bytes sent.
|
|
11
|
+
const payload = new Request('http://workspace.local', {
|
|
12
|
+
method: init?.method ?? 'POST',
|
|
13
|
+
body: init?.body,
|
|
14
|
+
headers: init?.headers
|
|
15
|
+
})
|
|
16
|
+
// Bun materializes multipart headers lazily; read the boundary before consuming the body.
|
|
17
|
+
const contentType = payload.headers.get('content-type') ?? undefined
|
|
18
|
+
return remoteRequest(path, {
|
|
19
|
+
method: init?.method,
|
|
20
|
+
body: init?.body == null ? undefined : new Uint8Array(await payload.arrayBuffer()),
|
|
21
|
+
signal: init?.signal ?? undefined,
|
|
22
|
+
contentType
|
|
23
|
+
})
|
|
24
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { WorkspaceEntry, WorkspaceType } from '@/lib/types'
|
|
1
|
+
import type { WorkspaceEntry, HarnessType } from '@/lib/types'
|
|
3
2
|
import { harnessFor } from '../harness/registry'
|
|
4
3
|
import { harnessStore } from '../harness/auth'
|
|
5
4
|
import { getWorkspaceSkillsStatus } from '../skills/update'
|
|
@@ -12,13 +11,13 @@ import { installWorkspaceSkills } from '../skills/workspace'
|
|
|
12
11
|
// Keep successful preparation for this server lifetime; failed attempts can retry.
|
|
13
12
|
const preparation = new Map<string, Promise<void>>()
|
|
14
13
|
export function prepareWorkspaceHarness(ws: WorkspaceEntry): Promise<void> {
|
|
15
|
-
const key = `${ws.path}:${ws.
|
|
14
|
+
const key = `${ws.path}:${ws.harness ?? 'claude-code'}`
|
|
16
15
|
let pending = preparation.get(key)
|
|
17
16
|
if (!pending) {
|
|
18
|
-
pending = getWorkspaceSkillsStatus(ws.path, ws.
|
|
17
|
+
pending = getWorkspaceSkillsStatus(ws.path, ws.harness)
|
|
19
18
|
.then(async status => {
|
|
20
19
|
if (status.skills.some(skill => !skill.installed))
|
|
21
|
-
await installWorkspaceSkills(ws.path, ws.
|
|
20
|
+
await installWorkspaceSkills(ws.path, ws.harness)
|
|
22
21
|
})
|
|
23
22
|
.catch(error => {
|
|
24
23
|
preparation.delete(key)
|
|
@@ -29,23 +28,23 @@ export function prepareWorkspaceHarness(ws: WorkspaceEntry): Promise<void> {
|
|
|
29
28
|
return pending
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
export async function changeWorkspaceHarness(ws: WorkspaceEntry,
|
|
31
|
+
export async function changeWorkspaceHarness(ws: WorkspaceEntry, next: HarnessType) {
|
|
33
32
|
return withHarnessTransition(ws, async () => {
|
|
34
33
|
const current = await getWorkspace(ws.id)
|
|
35
34
|
if (!current) throw new HarnessTransitionError('Workspace not found')
|
|
36
|
-
const
|
|
35
|
+
const previousHarness = current.harness ?? 'claude-code'
|
|
37
36
|
const harness = harnessFor(current)
|
|
38
37
|
if (
|
|
39
|
-
!['claude-code', 'codex'].includes(
|
|
40
|
-
!['claude-code', 'codex'].includes(
|
|
38
|
+
!['claude-code', 'codex'].includes(previousHarness) ||
|
|
39
|
+
!['claude-code', 'codex'].includes(next)
|
|
41
40
|
)
|
|
42
41
|
throw new HarnessTransitionError('This workspace’s agent cannot be changed')
|
|
43
|
-
if (
|
|
42
|
+
if (next === previousHarness) return current
|
|
44
43
|
if (harness.activeSessions().some(session => session.workspaceId === ws.id))
|
|
45
44
|
throw new HarnessTransitionError('Wait for the agent to finish before changing it')
|
|
46
|
-
const layoutBefore = await loadLayout(current.path)
|
|
47
45
|
const before = await updateWorkspaceState(current, state => {
|
|
48
46
|
const before = structuredClone(state)
|
|
47
|
+
state.chatDefaults = {}
|
|
49
48
|
state.selected = {}
|
|
50
49
|
delete state.pinnedSessionId
|
|
51
50
|
for (const view of Object.values(state.pendingViews)) {
|
|
@@ -57,21 +56,11 @@ export async function changeWorkspaceHarness(ws: WorkspaceEntry, type: Workspace
|
|
|
57
56
|
})
|
|
58
57
|
let updated: WorkspaceEntry
|
|
59
58
|
try {
|
|
60
|
-
|
|
61
|
-
delete layout.selectedModel
|
|
62
|
-
delete layout.selectedEffort
|
|
63
|
-
delete layout.selectedSpeedMode
|
|
64
|
-
await saveLayout(layout, current.path)
|
|
65
|
-
updated = await updateWorkspaceHarness(ws.id, type)
|
|
59
|
+
updated = await updateWorkspaceHarness(ws.id, next)
|
|
66
60
|
} catch (error) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
])
|
|
71
|
-
for (const result of recovery) {
|
|
72
|
-
if (result.status === 'rejected')
|
|
73
|
-
console.error('Could not restore workspace state', result.reason)
|
|
74
|
-
}
|
|
61
|
+
await updateWorkspaceState(current, state => Object.assign(state, before)).catch(error => {
|
|
62
|
+
console.error('Could not restore workspace state', error)
|
|
63
|
+
})
|
|
75
64
|
throw error
|
|
76
65
|
}
|
|
77
66
|
// Capture and dispose the old runtime before allowing another transition.
|
|
@@ -82,7 +71,7 @@ export async function changeWorkspaceHarness(ws: WorkspaceEntry, type: Workspace
|
|
|
82
71
|
console.error('Could not stop previous workspace runtime', error)
|
|
83
72
|
}
|
|
84
73
|
harnessStore.invalidate(current)
|
|
85
|
-
publishEvent({ type: 'workspace-harness:switched', workspaceId: ws.id, harness:
|
|
74
|
+
publishEvent({ type: 'workspace-harness:switched', workspaceId: ws.id, harness: next })
|
|
86
75
|
return updated
|
|
87
76
|
})
|
|
88
77
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { HarnessType } from '@/lib/types'
|
|
4
4
|
|
|
5
5
|
import { discoverHermesProfiles } from '../harness/hermes/discovery'
|
|
6
6
|
import type { HermesProfile } from '../harness/hermes/discovery'
|
|
@@ -49,12 +49,12 @@ async function resolveHermesImportMetadata(
|
|
|
49
49
|
|
|
50
50
|
export async function resolveWorkspaceImportMetadata(
|
|
51
51
|
path: string,
|
|
52
|
-
|
|
52
|
+
harness: HarnessType,
|
|
53
53
|
discoverAgents: DiscoverOpenClawAgents = discoverOpenClawAgents,
|
|
54
54
|
discoverProfiles: DiscoverHermesProfiles = discoverHermesProfiles
|
|
55
55
|
): Promise<WorkspaceImportMetadata> {
|
|
56
|
-
if (
|
|
57
|
-
if (
|
|
56
|
+
if (harness === 'hermes') return resolveHermesImportMetadata(path, discoverProfiles)
|
|
57
|
+
if (harness !== 'openclaw') return {}
|
|
58
58
|
|
|
59
59
|
const normalizedPath = resolve(path)
|
|
60
60
|
const agent = (await discoverAgents())
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { loadWorkspaceFileConfig } from './layout'
|
|
1
2
|
// The one place that knows how to turn a directory into a Moi workspace:
|
|
2
3
|
// bundled skills + the `.moi/` scaffold, with the skills location keyed on the
|
|
3
4
|
// agent backend. `moi init`, `moi openclaw init`, and the HTTP API (UI import /
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
import { mkdir } from 'node:fs/promises'
|
|
7
8
|
import { join } from 'node:path'
|
|
8
9
|
|
|
9
|
-
import type {
|
|
10
|
+
import type { HarnessType } from '@/lib/types'
|
|
10
11
|
import { workspaceIdFromName } from '@/lib/workspace-name'
|
|
11
12
|
import { validateWorkspaceId } from '@/lib/ids'
|
|
12
13
|
import { getWorkspace } from './registry'
|
|
@@ -40,20 +41,18 @@ export async function createWorkspaceDirectory(
|
|
|
40
41
|
// (Claude Code: `.claude/skills/`; OpenClaw: `<workspace>/skills/`; Codex:
|
|
41
42
|
// `.agents/skills/` per the Agent Skills standard). An untyped entry is
|
|
42
43
|
// Claude Code.
|
|
43
|
-
export function skillsDirFor(workspaceRoot: string,
|
|
44
|
-
return harnessFor(
|
|
44
|
+
export function skillsDirFor(workspaceRoot: string, harness?: HarnessType): string {
|
|
45
|
+
return harnessFor(harness).skillsDir?.(workspaceRoot) ?? join(workspaceRoot, '.claude', 'skills')
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export type ProvisionResult = {
|
|
48
49
|
// Where the skills were installed (backend-dependent, see skillsDirFor).
|
|
49
50
|
skillsDir: string
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
scaffold: '
|
|
54
|
-
|
|
55
|
-
installLogPath: string
|
|
56
|
-
}
|
|
51
|
+
} & (
|
|
52
|
+
| { scaffold: 'skipped' | 'exists'; installLogPath?: never }
|
|
53
|
+
// Dependency installation is running or finished with this exit code.
|
|
54
|
+
| { scaffold: 'installing' | number; installLogPath: string }
|
|
55
|
+
)
|
|
57
56
|
|
|
58
57
|
// Lay down everything a workspace needs: reset Claude/Codex's shared skill
|
|
59
58
|
// (or copy skills to other backends' own destinations), and bootstrap `.moi/`.
|
|
@@ -61,12 +60,15 @@ export type ProvisionResult = {
|
|
|
61
60
|
// Registration in the workspace registry is a separate, caller-owned step.
|
|
62
61
|
export async function provisionWorkspace(
|
|
63
62
|
workspaceRoot: string,
|
|
64
|
-
|
|
63
|
+
harness?: HarnessType
|
|
65
64
|
): Promise<ProvisionResult> {
|
|
66
|
-
const skillsDir = skillsDirFor(workspaceRoot,
|
|
65
|
+
const skillsDir = skillsDirFor(workspaceRoot, harness)
|
|
67
66
|
await mkdir(workspaceRoot, { recursive: true })
|
|
68
|
-
await
|
|
67
|
+
const config = await loadWorkspaceFileConfig(workspaceRoot)
|
|
68
|
+
await installWorkspaceSkills(workspaceRoot, harness)
|
|
69
|
+
if (config.remote) return { skillsDir, scaffold: 'skipped' }
|
|
69
70
|
const installLogPath = createDependencyInstallLogPath()
|
|
70
71
|
const scaffold = await scaffoldMoiDir(workspaceRoot, undefined, undefined, installLogPath)
|
|
72
|
+
if (scaffold === 'exists') return { skillsDir, scaffold }
|
|
71
73
|
return { skillsDir, scaffold, installLogPath }
|
|
72
74
|
}
|