moi-computer 0.13.1-next.1 → 0.13.1-next.2
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 +18 -100
- 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 +34 -16
- package/client/features/views/use-view-actions.ts +10 -20
- 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 +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +7 -4
- package/client/features/workspace/workspace-content.tsx +22 -20
- 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 +34 -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 +2 -1
- 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 +29 -9
- package/dist/chunk-44khk4sp.js +2 -0
- package/dist/chunk-ba6mz56s.js +72 -0
- package/dist/chunk-ec5ennpv.js +1 -0
- package/dist/chunk-ectsnw81.js +2 -0
- package/dist/chunk-en7w5ypg.js +1 -0
- package/dist/chunk-f695wcx5.js +5 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/{chunk-th91xfnp.js → chunk-n0fawy9x.js} +1 -1
- package/dist/chunk-pdt9hxfw.js +2 -0
- package/dist/chunk-rmd0ctfx.js +546 -0
- package/dist/chunk-zv22wv0g.js +1 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/types.ts +34 -49
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +2 -4
- package/package.json +4 -2
- package/server/README.md +29 -27
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +170 -68
- 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 +96 -53
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +228 -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 +70 -0
- package/server/cli/remote-operations.ts +244 -0
- package/server/collab/config.ts +3 -3
- package/server/collab/skill/index.ts +3 -3
- package/server/control.ts +38 -11
- 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 +1 -1
- 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/client.ts +665 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +32 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +16 -0
- package/server/sessions/view-sessions.ts +10 -12
- 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 +11 -8
- package/server/workspace-state/file.ts +2 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +28 -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 +6 -12
- package/skill/SKILL.md +24 -4
- 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
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from 'citty'
|
|
2
2
|
import { resolve } from 'path'
|
|
3
|
-
import {
|
|
4
|
-
import { staleSkillNotice } from '../../skills/version'
|
|
5
|
-
import { exitControlUnreachable } from '../control'
|
|
3
|
+
import { sendControl } from '../control'
|
|
6
4
|
import pc from '../pc'
|
|
7
5
|
|
|
8
6
|
async function sendConfig(payload: {
|
|
@@ -12,27 +10,21 @@ async function sendConfig(payload: {
|
|
|
12
10
|
clearName?: boolean
|
|
13
11
|
clearIcon?: boolean
|
|
14
12
|
}) {
|
|
15
|
-
|
|
16
|
-
const ws = new WebSocket(CONTROL_URL)
|
|
17
|
-
ws.onopen = () => ws.send(JSON.stringify({ type: 'config', ...payload }))
|
|
18
|
-
ws.onmessage = event => {
|
|
19
|
-
const res = JSON.parse(String(event.data))
|
|
20
|
-
if (res.error) {
|
|
21
|
-
console.error('\n' + pc.red(pc.bold('Error:')) + ' ' + res.error + '\n')
|
|
22
|
-
ws.close()
|
|
23
|
-
process.exit(1)
|
|
24
|
-
}
|
|
13
|
+
await sendControl(payload.path, { type: 'config', ...payload }, res => {
|
|
25
14
|
console.log()
|
|
26
15
|
if (res.ok) {
|
|
27
16
|
if (res.clearedName) console.log(pc.green('✓') + ' Name reset to ' + pc.dim('(folder name)'))
|
|
28
|
-
else if (res.name) console.log(pc.green('✓') + ' Name set to ' + pc.bold(res.name))
|
|
17
|
+
else if (res.name) console.log(pc.green('✓') + ' Name set to ' + pc.bold(String(res.name)))
|
|
29
18
|
if (res.clearedIcon)
|
|
30
19
|
console.log(pc.green('✓') + ' Icon reset to ' + pc.dim('default (provider)'))
|
|
31
20
|
else if (res.icon) console.log(pc.green('✓') + ' Icon updated ' + pc.dim('(128×128 webp)'))
|
|
32
21
|
} else {
|
|
33
22
|
console.log(pc.bold('moi config') + ' — workspace identity\n')
|
|
34
23
|
console.log(
|
|
35
|
-
' ' +
|
|
24
|
+
' ' +
|
|
25
|
+
pc.dim('name') +
|
|
26
|
+
' ' +
|
|
27
|
+
(res.name ? pc.bold(String(res.name)) : pc.dim('(folder name)'))
|
|
36
28
|
)
|
|
37
29
|
console.log(
|
|
38
30
|
' ' +
|
|
@@ -42,11 +34,7 @@ async function sendConfig(payload: {
|
|
|
42
34
|
)
|
|
43
35
|
}
|
|
44
36
|
console.log()
|
|
45
|
-
|
|
46
|
-
ws.close()
|
|
47
|
-
process.exit(0)
|
|
48
|
-
}
|
|
49
|
-
ws.onerror = () => void exitControlUnreachable()
|
|
37
|
+
})
|
|
50
38
|
}
|
|
51
39
|
|
|
52
40
|
// A terse cheat sheet — one line per command — so an agent can grasp the
|
|
@@ -78,7 +78,7 @@ const hermesInit = defineCommand({
|
|
|
78
78
|
skillsDir: skillsRoot,
|
|
79
79
|
installLogPath
|
|
80
80
|
} = await provisionWorkspace(target.path, 'hermes')
|
|
81
|
-
if (scaffold !== 'exists') {
|
|
81
|
+
if (scaffold !== 'exists' && scaffold !== 'skipped') {
|
|
82
82
|
if (scaffold === 'installing') {
|
|
83
83
|
console.log('\n' + pc.dim(' Widget dependencies still installing in .moi/ (background)'))
|
|
84
84
|
console.log(pc.dim(' Install log: ' + installLogPath))
|
|
@@ -93,7 +93,7 @@ const hermesInit = defineCommand({
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const entry = await registerWorkspace(target.path, {
|
|
96
|
-
|
|
96
|
+
harness: 'hermes',
|
|
97
97
|
name: target.name,
|
|
98
98
|
agentId: target.agentId,
|
|
99
99
|
isDefault: target.isDefault
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { initializeRemoteWorkspace } from '../../remote/workspace'
|
|
2
|
+
import { loadWorkspaceFileConfig } from '../../workspaces/layout'
|
|
3
|
+
import { parseRemoteWorkspaceAddress } from '@/lib/workspace-config'
|
|
4
|
+
import type { HarnessType, WorkspaceEntry } from '@/lib/types'
|
|
2
5
|
import { defineCommand } from 'citty'
|
|
3
6
|
import { existsSync } from 'node:fs'
|
|
4
7
|
import { join, resolve } from 'path'
|
|
@@ -34,7 +37,7 @@ import { keyValue } from '../ui'
|
|
|
34
37
|
async function resolveInitHarness(
|
|
35
38
|
target: string,
|
|
36
39
|
requested: string | undefined
|
|
37
|
-
): Promise<{
|
|
40
|
+
): Promise<{ harness: HarnessType; agent: DetectedAgent | null }> {
|
|
38
41
|
if (requested !== undefined) {
|
|
39
42
|
const value = requested.trim()
|
|
40
43
|
if (!isHarnessName(value)) {
|
|
@@ -61,7 +64,7 @@ async function resolveInitHarness(
|
|
|
61
64
|
pc.dim(' to bind it once ' + harnessLabel[value] + ' can see the workspace.')
|
|
62
65
|
)
|
|
63
66
|
}
|
|
64
|
-
return {
|
|
67
|
+
return { harness: value, agent }
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
// A registered workspace has already answered this question, and may carry no
|
|
@@ -70,12 +73,12 @@ async function resolveInitHarness(
|
|
|
70
73
|
// to refresh skills.
|
|
71
74
|
const known = (await listWorkspaces()).find(e => e.path === target)
|
|
72
75
|
if (known) {
|
|
73
|
-
const
|
|
76
|
+
const harness = known.harness ?? 'claude-code'
|
|
74
77
|
console.log(
|
|
75
|
-
'\n' + pc.dim(' Already registered — initializing for ') + pc.bold(harnessLabel[
|
|
78
|
+
'\n' + pc.dim(' Already registered — initializing for ') + pc.bold(harnessLabel[harness])
|
|
76
79
|
)
|
|
77
80
|
return {
|
|
78
|
-
|
|
81
|
+
harness,
|
|
79
82
|
agent: known.agentId
|
|
80
83
|
? {
|
|
81
84
|
agentId: known.agentId,
|
|
@@ -95,10 +98,10 @@ async function resolveInitHarness(
|
|
|
95
98
|
' Detected ' +
|
|
96
99
|
detected.reason +
|
|
97
100
|
' — initializing for ' +
|
|
98
|
-
pc.bold(harnessLabel[detected.
|
|
101
|
+
pc.bold(harnessLabel[detected.harness]) +
|
|
99
102
|
'.'
|
|
100
103
|
)
|
|
101
|
-
return {
|
|
104
|
+
return { harness: detected.harness, agent: detected.agent ?? null }
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
console.error('\n' + pc.red('✗') + ' No agent harness detected in ' + pc.bold(target))
|
|
@@ -119,9 +122,11 @@ async function resolveInitHarness(
|
|
|
119
122
|
export const init = defineCommand({
|
|
120
123
|
meta: {
|
|
121
124
|
name: 'init',
|
|
122
|
-
description: 'Initialize
|
|
125
|
+
description: 'Initialize a local or remote workspace and install its skill'
|
|
123
126
|
},
|
|
124
127
|
args: {
|
|
128
|
+
remote: { type: 'string', description: 'Remote workspace address: ownerId:workspaceId' },
|
|
129
|
+
json: { type: 'boolean', description: 'Print remote initialization as JSON' },
|
|
125
130
|
dir: {
|
|
126
131
|
type: 'positional',
|
|
127
132
|
default: '.',
|
|
@@ -143,13 +148,23 @@ export const init = defineCommand({
|
|
|
143
148
|
}
|
|
144
149
|
},
|
|
145
150
|
async run({ args }) {
|
|
151
|
+
if (
|
|
152
|
+
(args.remote !== undefined && (args.harness || args.id)) ||
|
|
153
|
+
(args.json && (args.remote === undefined || args.web))
|
|
154
|
+
) {
|
|
155
|
+
console.error(
|
|
156
|
+
'--remote cannot be combined with --harness or --id; --json requires --remote without --web'
|
|
157
|
+
)
|
|
158
|
+
process.exitCode = 1
|
|
159
|
+
return
|
|
160
|
+
}
|
|
146
161
|
const requested = resolve(args.dir)
|
|
147
162
|
// Locate the workspace root first: if invoked from inside a `.moi/` (or a
|
|
148
163
|
// deeper accidental `.moi/.moi/…`), lift to the directory that owns it
|
|
149
164
|
// instead of scaffolding a nested workspace. This is what stops the
|
|
150
165
|
// `.moi/.moi` bug at the source.
|
|
151
166
|
const target = liftToWorkspaceRoot(requested)
|
|
152
|
-
if (target !== requested) {
|
|
167
|
+
if (target !== requested && !args.json) {
|
|
153
168
|
console.log(
|
|
154
169
|
'\n' +
|
|
155
170
|
pc.yellow('◆') +
|
|
@@ -163,7 +178,7 @@ export const init = defineCommand({
|
|
|
163
178
|
// Flag a stray nested `.moi/.moi` left by the old cwd bug — harmless but
|
|
164
179
|
// confusing, and easy to remove.
|
|
165
180
|
const stray = join(target, '.moi', '.moi')
|
|
166
|
-
if (existsSync(stray)) {
|
|
181
|
+
if (existsSync(stray) && !args.json) {
|
|
167
182
|
console.log(
|
|
168
183
|
'\n' +
|
|
169
184
|
pc.yellow('⚠') +
|
|
@@ -188,52 +203,80 @@ export const init = defineCommand({
|
|
|
188
203
|
const projectRoot = PACKAGE_ROOT
|
|
189
204
|
const isInteractive = process.stdout.isTTY
|
|
190
205
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// Provision: bundled skills + the `.moi/` bootstrap (widgets dir +
|
|
198
|
-
// package.json + bun install). An existing `.moi/` is left untouched.
|
|
199
|
-
console.log()
|
|
200
|
-
const { scaffold, skillsDir, installLogPath } = await provisionWorkspace(target, type)
|
|
201
|
-
if (scaffold !== 'exists') {
|
|
202
|
-
if (scaffold === 'installing') {
|
|
203
|
-
console.log(pc.dim(' Widget dependencies still installing in .moi/ (background)'))
|
|
204
|
-
console.log(pc.dim(' Install log: ' + installLogPath))
|
|
205
|
-
} else if (scaffold === 0) {
|
|
206
|
-
console.log(pc.dim(' Installed widget dependencies in .moi/'))
|
|
207
|
-
} else {
|
|
208
|
-
console.warn(
|
|
209
|
-
pc.yellow(` bun install failed (exit ${scaffold}) — run it manually in .moi/`)
|
|
206
|
+
let entry: Pick<WorkspaceEntry, 'id'>
|
|
207
|
+
if (args.remote !== undefined) {
|
|
208
|
+
try {
|
|
209
|
+
const result = await initializeRemoteWorkspace(
|
|
210
|
+
target,
|
|
211
|
+
parseRemoteWorkspaceAddress(args.remote)
|
|
210
212
|
)
|
|
211
|
-
|
|
213
|
+
if (args.json) {
|
|
214
|
+
console.log(JSON.stringify(result))
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
entry = result
|
|
218
|
+
console.log(pc.green('✓') + ' Initialized ' + pc.bold(result.path) + ' for ' + args.remote)
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error(error instanceof Error ? error.message : 'Remote initialization failed')
|
|
221
|
+
process.exitCode = 1
|
|
222
|
+
return
|
|
212
223
|
}
|
|
213
|
-
}
|
|
224
|
+
} else {
|
|
225
|
+
const config = await loadWorkspaceFileConfig(target)
|
|
226
|
+
if (config.remote) {
|
|
227
|
+
console.error(
|
|
228
|
+
`This is a remote workspace — use moi init --remote ${config.remote.user_id}:${config.remote.workspace_id}`
|
|
229
|
+
)
|
|
230
|
+
process.exitCode = 1
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
// Which backend this workspace is for has to be settled before
|
|
234
|
+
// provisioning: each harness reads skills from a different directory, and
|
|
235
|
+
// agent-owned ones (OpenClaw, Hermes) need their agent metadata on the
|
|
236
|
+
// registry entry — same as `moi <provider> init`.
|
|
237
|
+
const { harness, agent } = await resolveInitHarness(target, args.harness)
|
|
214
238
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
239
|
+
// Provision: bundled skills + the `.moi/` bootstrap (widgets dir +
|
|
240
|
+
// package.json + bun install). An existing `.moi/` is left untouched.
|
|
241
|
+
console.log()
|
|
242
|
+
const { scaffold, skillsDir, installLogPath } = await provisionWorkspace(target, harness)
|
|
243
|
+
if (scaffold !== 'exists' && scaffold !== 'skipped') {
|
|
244
|
+
if (scaffold === 'installing') {
|
|
245
|
+
console.log(pc.dim(' Widget dependencies still installing in .moi/ (background)'))
|
|
246
|
+
console.log(pc.dim(' Install log: ' + installLogPath))
|
|
247
|
+
} else if (scaffold === 0) {
|
|
248
|
+
console.log(pc.dim(' Installed widget dependencies in .moi/'))
|
|
249
|
+
} else {
|
|
250
|
+
console.warn(
|
|
251
|
+
pc.yellow(` bun install failed (exit ${scaffold}) — run it manually in .moi/`)
|
|
252
|
+
)
|
|
253
|
+
console.warn(pc.dim(' Install log: ' + installLogPath))
|
|
254
|
+
}
|
|
255
|
+
}
|
|
228
256
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
257
|
+
// Always register the workspace in the persistent registry
|
|
258
|
+
entry = await registerWorkspace(target, {
|
|
259
|
+
...(args.id ? { id: args.id } : {}),
|
|
260
|
+
harness: harness,
|
|
261
|
+
...(agent
|
|
262
|
+
? {
|
|
263
|
+
name: agent.name,
|
|
264
|
+
agentId: agent.agentId,
|
|
265
|
+
isDefault: agent.isDefault,
|
|
266
|
+
lastRunAt: agent.lastRunAt
|
|
267
|
+
}
|
|
268
|
+
: {})
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
console.log(pc.green('✓') + ' Initialized ' + pc.bold(target) + pc.dim(' (' + harness + ')'))
|
|
272
|
+
console.log(
|
|
273
|
+
' Skills installed to ' +
|
|
274
|
+
pc.dim(skillsDir) +
|
|
275
|
+
' — ask ' +
|
|
276
|
+
(harness === 'claude-code' ? 'Claude' : 'your agent') +
|
|
277
|
+
' to build a widget or a view to get started\n'
|
|
278
|
+
)
|
|
279
|
+
}
|
|
237
280
|
|
|
238
281
|
// If --web and server not running, start it (stay alive as wrapper)
|
|
239
282
|
let running = await isServerRunning()
|
|
@@ -91,7 +91,7 @@ const openclawInit = defineCommand({
|
|
|
91
91
|
skillsDir: skillsRoot,
|
|
92
92
|
installLogPath
|
|
93
93
|
} = await provisionWorkspace(target.path, 'openclaw')
|
|
94
|
-
if (scaffold !== 'exists') {
|
|
94
|
+
if (scaffold !== 'exists' && scaffold !== 'skipped') {
|
|
95
95
|
if (scaffold === 'installing') {
|
|
96
96
|
console.log('\n' + pc.dim(' Widget dependencies still installing in .moi/ (background)'))
|
|
97
97
|
console.log(pc.dim(' Install log: ' + installLogPath))
|
|
@@ -108,7 +108,7 @@ const openclawInit = defineCommand({
|
|
|
108
108
|
// Register in the moi registry so the agent's workspace appears in the
|
|
109
109
|
// UI workspace list. Mirrors what `moi init` does for Claude Code.
|
|
110
110
|
const entry = await registerWorkspace(target.path, {
|
|
111
|
-
|
|
111
|
+
harness: 'openclaw',
|
|
112
112
|
name: target.name,
|
|
113
113
|
agentId: target.agentId,
|
|
114
114
|
isDefault: target.isDefault,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { currentRemoteWorkspace } from '../../remote/workspace'
|
|
1
2
|
import { defineCommand } from 'citty'
|
|
2
3
|
import { CONTROL_URL } from '../../constants'
|
|
3
4
|
import { staleSkillNotice } from '../../skills/version'
|
|
@@ -17,9 +18,17 @@ export const refresh = defineCommand({
|
|
|
17
18
|
async run({ args }) {
|
|
18
19
|
const only = readAppletSelector(args.only)
|
|
19
20
|
const notice = await staleSkillNotice(process.cwd())
|
|
21
|
+
const linked = await currentRemoteWorkspace()
|
|
20
22
|
const ws = new WebSocket(CONTROL_URL)
|
|
21
23
|
|
|
22
|
-
ws.onopen = () =>
|
|
24
|
+
ws.onopen = () =>
|
|
25
|
+
ws.send(
|
|
26
|
+
JSON.stringify({
|
|
27
|
+
type: 'applets:refresh',
|
|
28
|
+
only,
|
|
29
|
+
path: linked?.path ?? process.env.MOI_REMOTE_WORKSPACE
|
|
30
|
+
})
|
|
31
|
+
)
|
|
23
32
|
|
|
24
33
|
ws.onmessage = event => {
|
|
25
34
|
const data = JSON.parse(String(event.data))
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { AGENT_CLIENTS } from '../../remote/agent'
|
|
2
|
+
import { defineCommand } from 'citty'
|
|
3
|
+
import open from 'open'
|
|
4
|
+
import { remoteOperations } from '../remote-operations'
|
|
5
|
+
import { clearLine, cursorTo } from 'node:readline'
|
|
6
|
+
import { currentRemoteWorkspace } from '../../remote/workspace'
|
|
7
|
+
import { parseRemoteWorkspaceAddress } from '@/lib/workspace-config'
|
|
8
|
+
import pc from '../pc'
|
|
9
|
+
import {
|
|
10
|
+
login as signIn,
|
|
11
|
+
logout as signOut,
|
|
12
|
+
CloudSignInRequired,
|
|
13
|
+
remoteConfig,
|
|
14
|
+
remoteStatus,
|
|
15
|
+
invitations as listInvitations,
|
|
16
|
+
accept as acceptInvitation,
|
|
17
|
+
renameAgent,
|
|
18
|
+
leave as leaveWorkspace
|
|
19
|
+
} from '../../remote/client'
|
|
20
|
+
|
|
21
|
+
// Profile fields are user supplied; they must not control the terminal.
|
|
22
|
+
// oxlint-disable-next-line no-control-regex -- Deliberately remove terminal control characters.
|
|
23
|
+
const text = (value: string) => Bun.stripANSI(value).replace(/[\u0000-\u001f\u007f-\u009f]/g, '')
|
|
24
|
+
|
|
25
|
+
async function reportErrors(action: () => Promise<void>): Promise<void> {
|
|
26
|
+
try {
|
|
27
|
+
await action()
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (
|
|
30
|
+
error instanceof CloudSignInRequired ||
|
|
31
|
+
(error instanceof Error && error.message === 'Not signed in — run moi remote login')
|
|
32
|
+
) {
|
|
33
|
+
console.error(`${pc.dim('›')} Signed out`)
|
|
34
|
+
console.error(
|
|
35
|
+
pc.dim('› Run ') + pc.cyan('moi remote login') + pc.dim(' to connect to Moi Cloud')
|
|
36
|
+
)
|
|
37
|
+
} else {
|
|
38
|
+
console.error(error instanceof Error ? error.message : 'Cloud request failed')
|
|
39
|
+
}
|
|
40
|
+
process.exitCode = 1
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function waitingForLogin(): () => void {
|
|
45
|
+
const message = 'Waiting for authentication…'
|
|
46
|
+
if (!process.stderr.isTTY) {
|
|
47
|
+
console.error(message)
|
|
48
|
+
return () => {}
|
|
49
|
+
}
|
|
50
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
|
51
|
+
let frame = 0
|
|
52
|
+
const draw = () => {
|
|
53
|
+
cursorTo(process.stderr, 0)
|
|
54
|
+
process.stderr.write(pc.dim(`${frames[frame++ % frames.length]} ${message}`))
|
|
55
|
+
}
|
|
56
|
+
draw()
|
|
57
|
+
const timer = setInterval(draw, 80)
|
|
58
|
+
const stop = () => {
|
|
59
|
+
clearInterval(timer)
|
|
60
|
+
clearLine(process.stderr, 0)
|
|
61
|
+
cursorTo(process.stderr, 0)
|
|
62
|
+
process.removeListener('SIGINT', interrupt)
|
|
63
|
+
}
|
|
64
|
+
const interrupt = () => {
|
|
65
|
+
stop()
|
|
66
|
+
process.exit(130)
|
|
67
|
+
}
|
|
68
|
+
process.once('SIGINT', interrupt)
|
|
69
|
+
return stop
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const login = defineCommand({
|
|
73
|
+
meta: { name: 'login', description: 'Sign in to Moi Cloud in your browser' },
|
|
74
|
+
args: {
|
|
75
|
+
browser: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
default: true,
|
|
78
|
+
description: 'Open the login page (use --no-browser to print its URL only)'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async run({ args }) {
|
|
82
|
+
await reportErrors(async () => {
|
|
83
|
+
let stopWaiting = () => {}
|
|
84
|
+
try {
|
|
85
|
+
await signIn(async (url, code) => {
|
|
86
|
+
console.log(`\nVisit ${pc.bold(url)}\nCode: ${text(code)}\n`)
|
|
87
|
+
if (args.browser) await open(url).catch(() => {})
|
|
88
|
+
stopWaiting = waitingForLogin()
|
|
89
|
+
})
|
|
90
|
+
} finally {
|
|
91
|
+
stopWaiting()
|
|
92
|
+
}
|
|
93
|
+
console.log(`\n${pc.green('Congratulations!')} You are now signed in.\n`)
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const logout = defineCommand({
|
|
99
|
+
meta: { name: 'logout', description: 'Sign out of Moi Cloud' },
|
|
100
|
+
args: { yes: { type: 'boolean', description: 'Confirm permanently revoking this agent login' } },
|
|
101
|
+
async run({ args }) {
|
|
102
|
+
await reportErrors(async () => {
|
|
103
|
+
await signOut(args.yes)
|
|
104
|
+
console.log(`${pc.green('✓')} Signed out`)
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const jsonArg = { type: 'boolean' as const, description: 'Print JSON' }
|
|
110
|
+
const pathArg = {
|
|
111
|
+
type: 'string' as const,
|
|
112
|
+
description: 'Local workspace folder (defaults to current folder)'
|
|
113
|
+
}
|
|
114
|
+
const rename = defineCommand({
|
|
115
|
+
meta: { name: 'rename-agent', description: 'Change your agent name across workspaces' },
|
|
116
|
+
args: { name: { type: 'positional', required: true }, json: jsonArg },
|
|
117
|
+
async run({ args }) {
|
|
118
|
+
await reportErrors(async () => {
|
|
119
|
+
const result = await renameAgent(args.name)
|
|
120
|
+
console.log(args.json ? JSON.stringify(result) : `Agent renamed to ${text(result.name)}`)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
const invitations = defineCommand({
|
|
125
|
+
meta: { name: 'invitations', description: 'List pending workspace invitations' },
|
|
126
|
+
args: { json: jsonArg },
|
|
127
|
+
async run({ args }) {
|
|
128
|
+
await reportErrors(async () => {
|
|
129
|
+
const result = await listInvitations()
|
|
130
|
+
if (args.json) console.log(JSON.stringify(result))
|
|
131
|
+
else if (!result.length) console.log('No pending invitations')
|
|
132
|
+
else
|
|
133
|
+
for (const invitation of result)
|
|
134
|
+
console.log(
|
|
135
|
+
`${text(invitation.id)} ${text(invitation.workspaceName)} — ${text(invitation.inviter.name)}`
|
|
136
|
+
)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
const accept = defineCommand({
|
|
141
|
+
meta: { name: 'accept', description: 'Accept a workspace invitation as a human or agent' },
|
|
142
|
+
args: {
|
|
143
|
+
invite: { type: 'positional', required: true },
|
|
144
|
+
name: { type: 'string', description: 'Name for a new agent identity' },
|
|
145
|
+
client: { type: 'string', description: 'Agent client: ' + AGENT_CLIENTS.join(', ') },
|
|
146
|
+
json: jsonArg
|
|
147
|
+
},
|
|
148
|
+
async run({ args }) {
|
|
149
|
+
await reportErrors(async () => {
|
|
150
|
+
const result = await acceptInvitation(args.invite, args.name, args.client)
|
|
151
|
+
console.log(
|
|
152
|
+
args.json
|
|
153
|
+
? JSON.stringify(result)
|
|
154
|
+
: `Invitation accepted\n\nmoi init --remote ${result.remote.user_id}:${result.remote.workspace_id}`
|
|
155
|
+
)
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
const leave = defineCommand({
|
|
160
|
+
meta: { name: 'leave', description: 'Leave a shared workspace; keep local files' },
|
|
161
|
+
args: {
|
|
162
|
+
workspace: {
|
|
163
|
+
type: 'positional',
|
|
164
|
+
required: false,
|
|
165
|
+
description: 'ownerId:workspaceId (defaults to current folder)'
|
|
166
|
+
},
|
|
167
|
+
path: pathArg,
|
|
168
|
+
json: jsonArg
|
|
169
|
+
},
|
|
170
|
+
async run({ args }) {
|
|
171
|
+
await reportErrors(async () => {
|
|
172
|
+
if (args.workspace !== undefined && args.path)
|
|
173
|
+
throw new Error('Use a workspace address or --path, not both')
|
|
174
|
+
const target =
|
|
175
|
+
args.workspace !== undefined
|
|
176
|
+
? parseRemoteWorkspaceAddress(args.workspace)
|
|
177
|
+
: await currentRemoteWorkspace(args.path)
|
|
178
|
+
if (!target)
|
|
179
|
+
throw new Error('No remote workspace here — provide ownerId:workspaceId or --path')
|
|
180
|
+
const result = await leaveWorkspace(target.user_id, target.workspace_id)
|
|
181
|
+
console.log(args.json ? JSON.stringify(result) : 'Left the workspace; local files kept')
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
const remoteSubCommands = {
|
|
186
|
+
...remoteOperations(reportErrors),
|
|
187
|
+
login,
|
|
188
|
+
logout,
|
|
189
|
+
'rename-agent': rename,
|
|
190
|
+
invitations,
|
|
191
|
+
accept,
|
|
192
|
+
leave
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const remote = defineCommand({
|
|
196
|
+
meta: { name: 'remote', description: 'Show your cloud account and shared workspaces' },
|
|
197
|
+
args: { json: jsonArg, path: pathArg },
|
|
198
|
+
subCommands: remoteSubCommands,
|
|
199
|
+
async run({ args, rawArgs }) {
|
|
200
|
+
// citty also runs the parent after a subcommand; only bare `remote` shows status.
|
|
201
|
+
const sub = rawArgs.find(arg => !arg.startsWith('-'))
|
|
202
|
+
if (sub && Object.hasOwn(remoteSubCommands, sub)) return
|
|
203
|
+
await reportErrors(async () => {
|
|
204
|
+
const status = {
|
|
205
|
+
...(await remoteStatus()),
|
|
206
|
+
currentWorkspace: await currentRemoteWorkspace(args.path)
|
|
207
|
+
}
|
|
208
|
+
if (args.json) {
|
|
209
|
+
console.log(JSON.stringify(status, null, 2))
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
console.log(
|
|
213
|
+
`\n${text(status.me.name || ('email' in status.me ? status.me.email : status.me.client))} <${text('email' in status.me ? status.me.email : status.me.client)}>\nAccount: ${text(status.me.id)}\nCloud: ${(await remoteConfig()).url}\n`
|
|
214
|
+
)
|
|
215
|
+
if (status.currentWorkspace)
|
|
216
|
+
console.log(
|
|
217
|
+
`Remote workspace: ${text(status.currentWorkspace.user_id)}:${text(status.currentWorkspace.workspace_id)}\n`
|
|
218
|
+
)
|
|
219
|
+
console.log('Shared workspaces')
|
|
220
|
+
if (!status.workspaces.length) console.log(' No shared workspaces')
|
|
221
|
+
for (const workspace of status.workspaces)
|
|
222
|
+
console.log(
|
|
223
|
+
` ${text(workspace.owner.id)}:${text(workspace.id)} — ${text(workspace.owner.name || workspace.owner.email)} <${text(workspace.owner.email)}>`
|
|
224
|
+
)
|
|
225
|
+
console.log()
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
})
|
|
@@ -14,8 +14,8 @@ import { columns } from '../ui'
|
|
|
14
14
|
// same way `moi bundle` does, so it works from `.moi/` or any subdirectory.
|
|
15
15
|
async function runSkillUpdate(cwd: string): Promise<void> {
|
|
16
16
|
// Include the primary harness destination and existing copies for other agents.
|
|
17
|
-
const { root,
|
|
18
|
-
const result = await updateWorkspaceSkills(root,
|
|
17
|
+
const { root, harness } = await resolveWorkspace(cwd)
|
|
18
|
+
const result = await updateWorkspaceSkills(root, harness)
|
|
19
19
|
const { changedSkills, updatedAppletTypes } = result
|
|
20
20
|
const heading = changedSkills.length > 0 ? 'Skills updated in ' : 'Skills unchanged in '
|
|
21
21
|
|
|
@@ -97,8 +97,8 @@ export const skill = defineCommand({
|
|
|
97
97
|
const sub = rawArgs.find(a => !a.startsWith('-'))
|
|
98
98
|
if (sub && sub in skillSubCommands) return
|
|
99
99
|
|
|
100
|
-
const { root,
|
|
101
|
-
const statuses = await skillStatuses(root,
|
|
100
|
+
const { root, harness } = await resolveWorkspace(resolve(args.dir))
|
|
101
|
+
const statuses = await skillStatuses(root, harness)
|
|
102
102
|
|
|
103
103
|
console.log('\n' + pc.bold('moi skill') + pc.dim(' — workspace skills') + '\n')
|
|
104
104
|
console.log(
|
|
@@ -5,25 +5,18 @@ import { sendControl } from '../control'
|
|
|
5
5
|
import pc from '../pc'
|
|
6
6
|
import { columns } from '../ui'
|
|
7
7
|
|
|
8
|
-
// The listing behind `moi tabs`: every tab (static + views), one per row
|
|
9
|
-
// saved default (`layout.tabs.active`) marked. The
|
|
8
|
+
// The listing behind `moi tabs`: every tab (static + views), one per row. The
|
|
10
9
|
// addresses are documented in docs/navigation.md.
|
|
11
10
|
function runTabsList(dir: string) {
|
|
12
11
|
const path = resolve(dir)
|
|
13
12
|
sendControl(path, { type: 'tabs', path }, res => {
|
|
14
|
-
type Row = { title: string;
|
|
13
|
+
type Row = { title: string; href: string }
|
|
15
14
|
const rows: Row[] = Array.isArray(res.tabs) ? (res.tabs as Row[]) : []
|
|
16
|
-
console.log(
|
|
17
|
-
'\n' + pc.bold('moi tabs') + pc.dim(' — workspace tabs, the default one marked') + '\n'
|
|
18
|
-
)
|
|
15
|
+
console.log('\n' + pc.bold('moi tabs') + pc.dim(' — workspace tabs') + '\n')
|
|
19
16
|
console.log(
|
|
20
17
|
columns(
|
|
21
|
-
['
|
|
22
|
-
rows.map(row => [
|
|
23
|
-
row.isDefault ? pc.green('●') : ' ',
|
|
24
|
-
row.isDefault ? pc.bold(row.title) : row.title,
|
|
25
|
-
row.href
|
|
26
|
-
])
|
|
18
|
+
['title', 'address'].map(h => pc.dim(h)),
|
|
19
|
+
rows.map(row => [row.title, row.href])
|
|
27
20
|
)
|
|
28
21
|
)
|
|
29
22
|
console.log('\n' + pc.dim(' Open one: moi navigate <address>') + '\n')
|