moi-computer 0.13.0 → 0.13.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/api/app-config.ts +0 -1
- package/client/api/query-client.ts +5 -0
- package/client/app/app-router.tsx +1 -1
- package/client/app/routes/workspace-route.tsx +5 -6
- package/client/features/account/account-provider.tsx +28 -77
- package/client/features/account/account-test-utils.tsx +103 -93
- package/client/features/account/api.ts +36 -111
- package/client/features/account/profile-actions.ts +31 -0
- package/client/features/app-settings/avatar-upload.tsx +62 -0
- package/client/features/app-settings/profile-settings.tsx +10 -0
- package/client/features/app-settings/settings-page.tsx +0 -4
- package/client/features/chat/applet-chat-intents.ts +4 -4
- package/client/features/chat/sessions/api.ts +5 -5
- package/client/features/chat/sessions/use-selected-session.ts +3 -3
- package/client/features/chat/use-chat.ts +4 -4
- package/client/features/collab/applet-api.ts +1 -1
- package/client/features/collab/components/cursors.tsx +6 -1
- package/client/features/collab/components/presence-avatars.tsx +1 -1
- package/client/features/collab/components/presence-frame.tsx +1 -1
- package/client/features/collab/components/presence-group.tsx +1 -1
- package/client/features/collab/components/presence-helpers.ts +2 -2
- package/client/features/collab/components/user-avatar-group.tsx +1 -1
- package/client/features/collab/components/user-avatar.tsx +1 -1
- package/client/features/collab/components/user.tsx +1 -1
- package/client/features/collab/host-state.ts +45 -85
- package/client/features/collab/index.ts +3 -3
- package/client/features/collab/members/api.ts +23 -0
- package/client/features/collab/members/hooks.ts +103 -0
- package/client/features/collab/members/keys.ts +6 -0
- package/client/features/collab/members/store.ts +123 -0
- package/client/features/collab/members/types.ts +53 -0
- package/client/features/collab/{client.ts → presence/client.ts} +38 -13
- package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +9 -8
- package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
- package/client/features/collab/{users.ts → presence/users.ts} +19 -33
- package/client/features/collab/sharing/agent-invite.tsx +30 -0
- package/client/features/collab/sharing/workspace-members.tsx +277 -0
- package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
- package/client/features/collab/testing/component-fixtures.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +15 -3
- package/client/features/dev/collab/collab-playground.tsx +2 -2
- package/client/features/dev/workspace-setup-mocks.ts +0 -1
- package/client/features/identity/host-api.ts +34 -0
- package/client/features/identity/store.ts +32 -0
- package/client/features/identity/types.ts +41 -0
- package/client/features/identity/use-identity.ts +6 -0
- package/client/features/views/use-view-actions.ts +3 -3
- package/client/features/workspace/browser-tab-state.ts +6 -6
- package/client/features/workspace/workspace-content.tsx +10 -6
- package/client/index.html +1 -1
- package/client/index.tsx +5 -9
- package/client/main.tsx +2 -2
- package/dist/{chunk-cqt3s31j.js → chunk-3smkkcfw.js} +86 -86
- package/dist/chunk-47h9c2qy.js +2 -0
- package/dist/chunk-8qed2gqp.js +75 -0
- package/dist/{chunk-bncc7heg.js → chunk-8zy3vesm.js} +1 -1
- package/dist/chunk-a47zy276.js +2 -0
- package/dist/chunk-g4c1nte9.css +1 -0
- package/dist/chunk-kcactdr4.js +2 -0
- package/dist/chunk-m8bhx6tw.js +1 -0
- package/dist/{chunk-58dyt9bk.js → chunk-pf19zcrn.js} +2 -2
- package/dist/{chunk-2y59vrxg.js → chunk-th91xfnp.js} +1 -1
- package/dist/chunk-ygzxah0e.js +1 -0
- package/dist/index.html +2 -2
- package/lib/types.ts +0 -1
- package/package.json +5 -4
- package/server/app-config.ts +2 -5
- package/server/applets/declarations.ts +6 -7
- package/server/cli/commands/init.ts +0 -11
- package/server/collab/config.ts +1 -5
- package/server/collab/manager.ts +5 -2
- package/server/collab/skill/index.ts +1 -47
- package/server/skills/template.ts +3 -2
- package/server/skills/update.ts +1 -1
- package/server/skills/workspace.ts +0 -2
- package/server/web.ts +1 -2
- package/server/workspaces/scaffold.ts +1 -0
- package/skill/SKILL.md +1 -1
- package/client/features/account/identity.ts +0 -23
- package/client/features/app-settings/users-settings.tsx +0 -195
- package/client/features/collab/workspace-users-menu.tsx +0 -190
- package/dist/chunk-dcmks9sm.js +0 -75
- package/dist/chunk-md45evr2.css +0 -1
- package/dist/chunk-n0nab26d.js +0 -1
- package/dist/chunk-nmzhgyp9.js +0 -2
- package/dist/chunk-q37knr3m.js +0 -2
- package/dist/chunk-s90m4qkz.js +0 -1
- package/dist/chunk-wjvd4byz.js +0 -2
- /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
- /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
- /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { queryClient } from '@/client/api/query-client'
|
|
2
|
+
import { memberKeys } from '../collab/members/keys'
|
|
3
|
+
import { identityKey, parseIdentity } from './types'
|
|
4
|
+
import type { Identity } from './types'
|
|
5
|
+
|
|
6
|
+
let current: Identity | null | undefined
|
|
7
|
+
// Changes only when the account changes; guards requests from a previous account.
|
|
8
|
+
let accountGeneration = 0
|
|
9
|
+
// Changes on every identity write; guards against older profile responses.
|
|
10
|
+
let identityRevision = 0
|
|
11
|
+
const listeners = new Set<() => void>()
|
|
12
|
+
export const getIdentity = () => current
|
|
13
|
+
export const getIdentityRevision = () => identityRevision
|
|
14
|
+
export const getAccountGeneration = () => accountGeneration
|
|
15
|
+
export function subscribeIdentity(listener: () => void) {
|
|
16
|
+
listeners.add(listener)
|
|
17
|
+
return () => {
|
|
18
|
+
listeners.delete(listener)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function setIdentity(value: Identity | null): void {
|
|
22
|
+
const next = value === null ? null : parseIdentity(value)
|
|
23
|
+
const changedAccount = (current && identityKey(current)) !== (next && identityKey(next))
|
|
24
|
+
if (changedAccount) {
|
|
25
|
+
accountGeneration++
|
|
26
|
+
void queryClient.cancelQueries({ queryKey: memberKeys.all })
|
|
27
|
+
queryClient.removeQueries({ queryKey: memberKeys.all })
|
|
28
|
+
}
|
|
29
|
+
identityRevision++
|
|
30
|
+
current = next
|
|
31
|
+
listeners.forEach(listener => listener())
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isRecord } from '@/lib/collab/protocol'
|
|
2
|
+
|
|
3
|
+
export type Identity =
|
|
4
|
+
| { id: string; type: 'user'; name: string; email: string; avatar?: string; isAnonymous: boolean }
|
|
5
|
+
| { id: string; type: 'agent'; name: string; avatar?: string }
|
|
6
|
+
|
|
7
|
+
function text(value: unknown, max: number): value is string {
|
|
8
|
+
return typeof value === 'string' && value.length <= max && !value.includes('\0')
|
|
9
|
+
}
|
|
10
|
+
function isAvatar(value: unknown): value is string {
|
|
11
|
+
if (!text(value, 2048)) return false
|
|
12
|
+
try {
|
|
13
|
+
return ['http:', 'https:'].includes(new URL(value).protocol)
|
|
14
|
+
} catch {
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function parseIdentity(value: unknown): Identity {
|
|
19
|
+
if (
|
|
20
|
+
!isRecord(value) ||
|
|
21
|
+
!text(value.id, 240) ||
|
|
22
|
+
!value.id.trim() ||
|
|
23
|
+
value.id !== value.id.trim() ||
|
|
24
|
+
!text(value.name, 256) ||
|
|
25
|
+
(value.avatar !== undefined && !isAvatar(value.avatar))
|
|
26
|
+
)
|
|
27
|
+
throw new Error('Invalid identity')
|
|
28
|
+
const common = {
|
|
29
|
+
id: value.id,
|
|
30
|
+
name: value.name,
|
|
31
|
+
...(value.avatar !== undefined ? { avatar: value.avatar } : {})
|
|
32
|
+
}
|
|
33
|
+
if (value.type === 'agent') return { ...common, type: 'agent' }
|
|
34
|
+
if (value.type === 'user' && text(value.email, 320) && typeof value.isAnonymous === 'boolean')
|
|
35
|
+
return { ...common, type: 'user', email: value.email, isAnonymous: value.isAnonymous }
|
|
36
|
+
throw new Error('Invalid identity')
|
|
37
|
+
}
|
|
38
|
+
export const identityKey = (identity: Identity) => `${identity.type}:${identity.id}`
|
|
39
|
+
// Existing human collaboration ids stay compatible; agent ids cannot collide.
|
|
40
|
+
export const collabIdentityId = (identity: Identity) =>
|
|
41
|
+
identity.type === 'agent' ? `agent:${identity.id}` : identity.id
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
changeWorkspaceStateCache,
|
|
20
20
|
getCachedWorkspaceState
|
|
21
21
|
} from '@/client/features/workspace/workspace-state'
|
|
22
|
-
import {
|
|
22
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
23
23
|
import { useWorkspaceHarness } from '@/client/features/workspace/api'
|
|
24
24
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
25
25
|
import {
|
|
@@ -34,8 +34,8 @@ import { viewTabId } from '@/lib/workspace-tabs'
|
|
|
34
34
|
|
|
35
35
|
export function useViewActions() {
|
|
36
36
|
const queryClient = useQueryClient()
|
|
37
|
-
const
|
|
38
|
-
const selectionScope =
|
|
37
|
+
const cloud = useAppConfig().environment === 'cloud'
|
|
38
|
+
const selectionScope = cloud ? 'browser-tab' : 'shared'
|
|
39
39
|
const { workspaceId, layout } = useWorkspaceLayoutCtx()
|
|
40
40
|
const { pinnedSessionId } = usePinnedSession()
|
|
41
41
|
const modelData = useWorkspaceHarness(workspaceId).data
|
|
@@ -2,7 +2,7 @@ import { useCallback, useMemo, useState } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import type { WorkspaceTabsState } from '@/lib/types'
|
|
4
4
|
import { normalizeWorkspaceTabs } from '@/lib/workspace-layout'
|
|
5
|
-
import {
|
|
5
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
6
6
|
import { useWorkspaceLayoutCtx } from './workspace-layout-context'
|
|
7
7
|
|
|
8
8
|
const keyFor = (workspaceId: string) => `moi:collab:${workspaceId}:tabs`
|
|
@@ -29,15 +29,15 @@ export function writeWorkspaceTabs(workspaceId: string, tabs: WorkspaceTabsState
|
|
|
29
29
|
|
|
30
30
|
export function useWorkspaceTabs() {
|
|
31
31
|
const { workspaceId, layout, setLayout } = useWorkspaceLayoutCtx()
|
|
32
|
-
const
|
|
32
|
+
const cloud = useAppConfig().environment === 'cloud'
|
|
33
33
|
const defaults = useMemo(() => normalizeWorkspaceTabs(layout.tabs), [layout.tabs])
|
|
34
34
|
const [local, setLocal] = useState<WorkspaceTabsState>(() =>
|
|
35
|
-
|
|
35
|
+
cloud ? readWorkspaceTabs(workspaceId, defaults) : defaults
|
|
36
36
|
)
|
|
37
37
|
const setTabs = useCallback(
|
|
38
38
|
(tabs: WorkspaceTabsState) => {
|
|
39
39
|
const next = normalizeWorkspaceTabs(tabs)
|
|
40
|
-
if (
|
|
40
|
+
if (cloud) {
|
|
41
41
|
setLocal(next)
|
|
42
42
|
writeWorkspaceTabs(workspaceId, next)
|
|
43
43
|
} else {
|
|
@@ -45,7 +45,7 @@ export function useWorkspaceTabs() {
|
|
|
45
45
|
}
|
|
46
46
|
return next
|
|
47
47
|
},
|
|
48
|
-
[
|
|
48
|
+
[cloud, setLayout, workspaceId]
|
|
49
49
|
)
|
|
50
|
-
return [
|
|
50
|
+
return [cloud ? local : defaults, setTabs] as const
|
|
51
51
|
}
|
|
@@ -17,7 +17,8 @@ import type { WelcomeDestination } from '@/client/features/chat/messages/chat-em
|
|
|
17
17
|
import { ChatPopup } from '@/client/features/chat/chat-popup'
|
|
18
18
|
import { ThemePanel } from '@/client/features/workspace/theme-panel'
|
|
19
19
|
import { Overview } from '@/client/features/overview/overview'
|
|
20
|
-
import {
|
|
20
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
21
|
+
import { WorkspaceSharingMenu } from '@/client/features/collab'
|
|
21
22
|
import { PanelHeader } from '@/client/components/shared/panel-header'
|
|
22
23
|
import { Button } from '@/client/components/ui/button'
|
|
23
24
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
@@ -117,6 +118,7 @@ function tabItemFor(
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentProps) {
|
|
121
|
+
const { environment } = useAppConfig()
|
|
120
122
|
const { layout, workspaceId } = useWorkspaceLayoutCtx()
|
|
121
123
|
const theme = resolveWorkspaceTheme(layout.theme)
|
|
122
124
|
const viewActions = useViewActions()
|
|
@@ -543,11 +545,13 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
543
545
|
onReorder={reorderTabs}
|
|
544
546
|
/>
|
|
545
547
|
</div>
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
548
|
+
{environment === 'cloud' && (
|
|
549
|
+
<WorkspaceSharingMenu
|
|
550
|
+
workspaceId={workspaceId}
|
|
551
|
+
describeTab={tab => tabItemFor(tab, allViews, false, () => false)}
|
|
552
|
+
onOpenTab={openTab}
|
|
553
|
+
/>
|
|
554
|
+
)}
|
|
551
555
|
{canUseSplit && mode === 'fullscreen' && (
|
|
552
556
|
<Tooltip>
|
|
553
557
|
<TooltipTrigger
|
package/client/index.html
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
<body>
|
|
60
60
|
<div id="root"></div>
|
|
61
61
|
<script type="module" src="./index.tsx"></script>
|
|
62
|
-
<script type="module">
|
|
62
|
+
<script id="moi-start" type="module">
|
|
63
63
|
const [react, jsxRuntime, jsxDevRuntime, reactDom, reactDomClient] = await Promise.all([
|
|
64
64
|
import('react'),
|
|
65
65
|
import('react/jsx-runtime'),
|
package/client/index.tsx
CHANGED
|
@@ -4,11 +4,9 @@ import './structured-clone-shim'
|
|
|
4
4
|
import 'blobatar/motion.css'
|
|
5
5
|
import './index.css'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
subscribeLocalProfileStorage
|
|
11
|
-
} from './features/collab/host-state'
|
|
7
|
+
import { initializeLocalUser, subscribeLocalProfileStorage } from './features/collab/host-state'
|
|
8
|
+
|
|
9
|
+
import { installIdentityHostApi } from './features/identity/host-api'
|
|
12
10
|
|
|
13
11
|
import { startHmrWatchdog } from './runtime/hmr-watchdog'
|
|
14
12
|
|
|
@@ -27,10 +25,8 @@ if (import.meta.hot) {
|
|
|
27
25
|
startHmrWatchdog()
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
// straight away, before the async startup below has finished.
|
|
33
|
-
installHostApi()
|
|
28
|
+
// A host can call this API after the entry chunk and before #moi-start mounts React.
|
|
29
|
+
installIdentityHostApi()
|
|
34
30
|
subscribeLocalProfileStorage()
|
|
35
31
|
|
|
36
32
|
export async function init(el: HTMLElement) {
|
package/client/main.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryClientProvider } from '@tanstack/react-query'
|
|
2
2
|
import { createRoot } from 'react-dom/client'
|
|
3
3
|
import { Router } from 'wouter'
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import { AccountProvider } from '@/client/features/account/account-provider'
|
|
|
10
10
|
import { AppProvider } from './app/app-provider'
|
|
11
11
|
import { AppRouter } from './app/app-router'
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import { queryClient } from './api/query-client'
|
|
14
14
|
|
|
15
15
|
// Open the single app-wide chat WebSocket once and hand it the query client so
|
|
16
16
|
// live frames fold into the RQ transcript cache. Lives for the page's lifetime.
|