moi-computer 0.11.1-dev.1c52199 → 0.11.1-dev.be1ed10
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 +1 -2
- package/client/app/routes/WorkspaceRoute.tsx +19 -27
- package/client/features/applets/AppletMount.tsx +1 -4
- package/client/features/applets/applet-runtime.ts +2 -13
- package/client/features/chat/applet-chat-intents.ts +6 -15
- package/client/features/chat/sessions/useSelectedSession.ts +20 -64
- package/client/features/chat/useChat.ts +0 -4
- package/client/features/dev/DevIndexPage.tsx +0 -5
- package/client/features/dev/DevRoutes.tsx +1 -14
- package/client/features/views/ViewManager.tsx +1 -4
- package/client/features/views/api.ts +2 -2
- package/client/features/views/useViewBuilderActions.ts +0 -3
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -18
- package/client/features/workspace/WorkspaceScreen.tsx +11 -19
- package/client/features/workspace/api.ts +1 -3
- package/client/features/workspace/moi-context.ts +2 -7
- package/client/features/workspace/useWorkspaceNavigation.ts +3 -12
- package/client/index.tsx +3 -4
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-wnmf38ta.js → chunk-mzrgr577.js} +1 -1
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -0
- package/dist/index.html +1 -1
- package/lib/moi-context.ts +0 -7
- package/lib/types.ts +6 -12
- package/package.json +1 -3
- package/server/api.ts +2 -23
- package/server/app-config.ts +34 -127
- package/server/applet-typecheck.ts +1 -6
- package/server/applets/build-applet.ts +0 -10
- package/server/cli.ts +12 -57
- package/server/layout.ts +3 -16
- package/server/skills-template.ts +2 -14
- package/server/web.ts +17 -62
- package/ui-components/avatar.tsx +4 -5
- package/ui-components/docs/avatar.md +5 -5
- package/client/features/collab/DevCollabIdentity.tsx +0 -170
- package/client/features/collab/DevCollabKit.tsx +0 -501
- package/client/features/collab/DevCollabPage.tsx +0 -25
- package/client/features/collab/WorkspaceCollabControls.tsx +0 -313
- package/client/features/collab/client.ts +0 -146
- package/client/features/collab/components.tsx +0 -307
- package/client/features/collab/dev-persona.ts +0 -66
- package/client/features/collab/engine.ts +0 -96
- package/client/features/collab/entry.tsx +0 -35
- package/client/features/collab/facehash-avatar.ts +0 -132
- package/client/features/collab/fake-engine.ts +0 -130
- package/client/features/collab/hooks.tsx +0 -253
- package/client/features/collab/identity.ts +0 -305
- package/client/features/collab/index.ts +0 -45
- package/client/features/collab/people.ts +0 -102
- package/client/features/collab/personal-state.ts +0 -61
- package/client/features/collab/presence-publisher.ts +0 -29
- package/client/features/collab/presence-target.ts +0 -10
- package/client/features/collab/primitives.tsx +0 -398
- package/client/features/collab/proxy-identity.ts +0 -24
- package/client/features/collab/store.ts +0 -156
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-1ftessc8.js +0 -2
- package/dist/chunk-3802vh2p.js +0 -2
- package/dist/chunk-542a2m9m.js +0 -1
- package/dist/chunk-5745d83v.js +0 -2
- package/dist/chunk-5zxdsjym.js +0 -1
- package/dist/chunk-7r4z77ry.js +0 -2
- package/dist/chunk-9cm0wjah.js +0 -79
- package/dist/chunk-cvgdm1hq.js +0 -2
- package/dist/chunk-gptm4jpd.js +0 -546
- package/dist/chunk-xaehhr1j.css +0 -1
- package/dist/chunk-xpt063fx.js +0 -1
- package/lib/collab/colors.ts +0 -24
- package/lib/collab/protocol.ts +0 -83
- package/lib/collab/types.ts +0 -63
- package/lib/experimental.ts +0 -14
- package/server/chat-selection.ts +0 -23
- package/server/collab/applet-module.ts +0 -50
- package/server/collab/cloudflare-access.ts +0 -77
- package/server/collab/config.ts +0 -18
- package/server/collab/ipc.ts +0 -10
- package/server/collab/manager.ts +0 -407
- package/server/collab/service.ts +0 -137
- package/server/collab/skill/collab-env.d.ts +0 -92
- package/server/collab/skill/index.ts +0 -59
- package/server/collab/worker.ts +0 -52
- package/workspace/.claude/skills/moi-workspace/references/COLLABORATIVE.md +0 -151
package/dist/chunk-xpt063fx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f,ee}from"/chunk-7r4z77ry.js";import{Fe}from"/chunk-3802vh2p.js";async function t(){try{Fe(await f("/api/identity"))}catch{}}async function r(){await t(),ee(()=>{t()})}export{r as loadProxyIdentity};
|
package/lib/collab/colors.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Backgrounds that keep the black face readable and still work as a cursor
|
|
2
|
-
// color on light and dark surfaces.
|
|
3
|
-
export const PERSONA_COLORS = [
|
|
4
|
-
['Pink', '#ec4899'],
|
|
5
|
-
['Orange', '#f97316'],
|
|
6
|
-
['Amber', '#f59e0b'],
|
|
7
|
-
['Lime', '#84cc16'],
|
|
8
|
-
['Emerald', '#10b981'],
|
|
9
|
-
['Cyan', '#06b6d4'],
|
|
10
|
-
['Blue', '#3b82f6'],
|
|
11
|
-
['Violet', '#8b5cf6']
|
|
12
|
-
] as const
|
|
13
|
-
|
|
14
|
-
// A random-looking but stable pick (FNV-1a), so a user id gets the same color
|
|
15
|
-
// on the server and in every browser.
|
|
16
|
-
export function colorForId(id: string): string {
|
|
17
|
-
let hash = 0x811c9dc5
|
|
18
|
-
for (let index = 0; index < id.length; index++) {
|
|
19
|
-
hash ^= id.charCodeAt(index)
|
|
20
|
-
hash = Math.imul(hash, 0x01000193)
|
|
21
|
-
}
|
|
22
|
-
const [, color] = PERSONA_COLORS[(hash >>> 0) % PERSONA_COLORS.length] ?? PERSONA_COLORS[0]
|
|
23
|
-
return color
|
|
24
|
-
}
|
package/lib/collab/protocol.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { CollabClientMessage, CollabIdentity, CollabJsonValue, CollabLocation } from './types'
|
|
2
|
-
|
|
3
|
-
export const COLLAB_PROTOCOL_VERSION = 2
|
|
4
|
-
export const COLLAB_MAX_CONNECTIONS = 64
|
|
5
|
-
export const COLLAB_MAX_REGISTRATIONS = 128
|
|
6
|
-
export const COLLAB_MAX_MESSAGE_BYTES = 256 * 1024
|
|
7
|
-
export const COLLAB_MAX_PRESENCE_BYTES = 4 * 1024
|
|
8
|
-
export const COLLAB_MAX_AVATAR_BYTES = 8 * 1024
|
|
9
|
-
export const COLLAB_MAX_EMAIL_BYTES = 320
|
|
10
|
-
|
|
11
|
-
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
12
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function isCollabString(value: unknown, max = 256): value is string {
|
|
16
|
-
return (
|
|
17
|
-
typeof value === 'string' &&
|
|
18
|
-
value.length > 0 &&
|
|
19
|
-
!value.includes('\0') &&
|
|
20
|
-
new TextEncoder().encode(value).length <= max
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function isCollabJson(value: unknown, depth = 0): value is CollabJsonValue {
|
|
25
|
-
if (depth > 24) return false
|
|
26
|
-
if (value === null || typeof value === 'string' || typeof value === 'boolean') return true
|
|
27
|
-
if (typeof value === 'number') return Number.isFinite(value)
|
|
28
|
-
if (Array.isArray(value)) return value.every(item => isCollabJson(item, depth + 1))
|
|
29
|
-
if (!isRecord(value)) return false
|
|
30
|
-
return Object.values(value).every(item => isCollabJson(item, depth + 1))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function isCollabIdentity(value: unknown): value is CollabIdentity {
|
|
34
|
-
return (
|
|
35
|
-
isRecord(value) &&
|
|
36
|
-
isCollabString(value.id, 240) &&
|
|
37
|
-
value.id.trim().length > 0 &&
|
|
38
|
-
(value.name === undefined || value.name === '' || isCollabString(value.name)) &&
|
|
39
|
-
isCollabString(value.color, 64) &&
|
|
40
|
-
(value.avatar === undefined || isCollabString(value.avatar, COLLAB_MAX_AVATAR_BYTES)) &&
|
|
41
|
-
(value.email === undefined || isCollabString(value.email, COLLAB_MAX_EMAIL_BYTES))
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function isLocation(value: unknown): value is CollabLocation | null {
|
|
46
|
-
return (
|
|
47
|
-
value === null ||
|
|
48
|
-
(isRecord(value) &&
|
|
49
|
-
isCollabString(value.page, 1024) &&
|
|
50
|
-
(value.title === undefined || isCollabString(value.title)) &&
|
|
51
|
-
(value.away === undefined || typeof value.away === 'boolean'))
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function isCollabClientMessage(value: unknown): value is CollabClientMessage {
|
|
56
|
-
if (!isRecord(value)) return false
|
|
57
|
-
switch (value.type) {
|
|
58
|
-
case 'join':
|
|
59
|
-
return (
|
|
60
|
-
value.version === COLLAB_PROTOCOL_VERSION &&
|
|
61
|
-
isCollabIdentity(value.identity) &&
|
|
62
|
-
(value.location === undefined || isLocation(value.location))
|
|
63
|
-
)
|
|
64
|
-
case 'identity':
|
|
65
|
-
return isCollabIdentity(value.identity)
|
|
66
|
-
case 'location':
|
|
67
|
-
return isLocation(value.location)
|
|
68
|
-
case 'presence:set':
|
|
69
|
-
return (
|
|
70
|
-
isCollabString(value.registrationId) &&
|
|
71
|
-
isCollabString(value.surface) &&
|
|
72
|
-
isCollabString(value.channel) &&
|
|
73
|
-
isCollabJson(value.value) &&
|
|
74
|
-
new TextEncoder().encode(JSON.stringify(value.value)).length <= COLLAB_MAX_PRESENCE_BYTES
|
|
75
|
-
)
|
|
76
|
-
case 'presence:delete':
|
|
77
|
-
return isCollabString(value.registrationId)
|
|
78
|
-
case 'ping':
|
|
79
|
-
return true
|
|
80
|
-
default:
|
|
81
|
-
return false
|
|
82
|
-
}
|
|
83
|
-
}
|
package/lib/collab/types.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export type CollabJsonValue =
|
|
2
|
-
| null
|
|
3
|
-
| boolean
|
|
4
|
-
| number
|
|
5
|
-
| string
|
|
6
|
-
| CollabJsonValue[]
|
|
7
|
-
| { [key: string]: CollabJsonValue }
|
|
8
|
-
|
|
9
|
-
export type CollabIdentity = {
|
|
10
|
-
id: string
|
|
11
|
-
name?: string
|
|
12
|
-
color: string
|
|
13
|
-
avatar?: string
|
|
14
|
-
email?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// An authenticating proxy in front of the deployment that moi trusts for identity.
|
|
18
|
-
export type CollabIdentityProvider = 'cloudflare-access'
|
|
19
|
-
|
|
20
|
-
// GET /api/identity. `identity` is the profile the proxy verified for this
|
|
21
|
-
// request: null without a configured provider or without a valid proxy token.
|
|
22
|
-
export type ProxyIdentity = {
|
|
23
|
-
provider: CollabIdentityProvider | null
|
|
24
|
-
identity: CollabIdentity | null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type CollabLocation = { page: string; title?: string; away?: boolean }
|
|
28
|
-
|
|
29
|
-
export type CollabPresenceRegistration = {
|
|
30
|
-
registrationId: string
|
|
31
|
-
surface: string
|
|
32
|
-
channel: string
|
|
33
|
-
value: CollabJsonValue
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type CollabParticipant = {
|
|
37
|
-
connectionId: string
|
|
38
|
-
userId: string
|
|
39
|
-
location: CollabLocation | null
|
|
40
|
-
presence: CollabPresenceRegistration[]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type CollabClientMessage =
|
|
44
|
-
| { type: 'join'; version: 2; identity: CollabIdentity; location?: CollabLocation | null }
|
|
45
|
-
| { type: 'identity'; identity: CollabIdentity }
|
|
46
|
-
| { type: 'location'; location: CollabLocation | null }
|
|
47
|
-
| ({ type: 'presence:set' } & CollabPresenceRegistration)
|
|
48
|
-
| { type: 'presence:delete'; registrationId: string }
|
|
49
|
-
| { type: 'ping' }
|
|
50
|
-
|
|
51
|
-
export type CollabServerMessage =
|
|
52
|
-
| {
|
|
53
|
-
type: 'welcome'
|
|
54
|
-
version: 2
|
|
55
|
-
connectionId: string
|
|
56
|
-
participants: CollabParticipant[]
|
|
57
|
-
// Profile fallback for currently connected users only. The host owns
|
|
58
|
-
// the full workspace directory, including users who are offline.
|
|
59
|
-
users: CollabIdentity[]
|
|
60
|
-
}
|
|
61
|
-
| { type: 'participants'; participants: CollabParticipant[]; users: CollabIdentity[] }
|
|
62
|
-
| { type: 'error'; code: string; message: string }
|
|
63
|
-
| { type: 'pong' }
|
package/lib/experimental.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Add a default here to register an experimental startup feature. The CLI and
|
|
2
|
-
// browser config both use these keys.
|
|
3
|
-
export const EXPERIMENTAL_DEFAULTS = {
|
|
4
|
-
collab: false
|
|
5
|
-
} satisfies Record<string, false>
|
|
6
|
-
|
|
7
|
-
export type ExperimentalFeatures = { [Key in keyof typeof EXPERIMENTAL_DEFAULTS]: boolean }
|
|
8
|
-
export type ExperimentalFeature = keyof ExperimentalFeatures
|
|
9
|
-
|
|
10
|
-
export const EXPERIMENTAL_FEATURES = Object.keys(EXPERIMENTAL_DEFAULTS) as ExperimentalFeature[]
|
|
11
|
-
|
|
12
|
-
export function experimentalFlagName(feature: string): string {
|
|
13
|
-
return `experimental-${feature.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)}`
|
|
14
|
-
}
|
package/server/chat-selection.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceEntry } from '@/lib/types'
|
|
2
|
-
|
|
3
|
-
import { publishEvent } from './events'
|
|
4
|
-
import { saveSelectedSession } from './selected-session'
|
|
5
|
-
|
|
6
|
-
// Starting a chat can select it for this installation, but a browser with
|
|
7
|
-
// personal selection has already selected it locally and must not move peers.
|
|
8
|
-
export async function selectChatSession(
|
|
9
|
-
workspace: Pick<WorkspaceEntry, 'id' | 'path'>,
|
|
10
|
-
sessionId: string,
|
|
11
|
-
personalSelection = false,
|
|
12
|
-
previousSessionId?: string | null
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
if (personalSelection) return
|
|
15
|
-
const selection = await saveSelectedSession(workspace.path, sessionId, previousSessionId)
|
|
16
|
-
if (selection.changed) {
|
|
17
|
-
publishEvent({
|
|
18
|
-
type: 'selected-session:updated',
|
|
19
|
-
workspaceId: workspace.id,
|
|
20
|
-
sessionId: selection.sessionId
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Evaluated in the browser bundle only. All state and React contexts remain
|
|
2
|
-
// in the host feature, shared by every applet and revoked with its bridge.
|
|
3
|
-
export const COLLAB_MODULE_SOURCE = `
|
|
4
|
-
import { createElement } from 'react';
|
|
5
|
-
import { __getBridge } from 'moi';
|
|
6
|
-
const empty = () => [];
|
|
7
|
-
const nothing = () => null;
|
|
8
|
-
const fallback = {
|
|
9
|
-
useMe: nothing,
|
|
10
|
-
useUser: nothing,
|
|
11
|
-
usePeers: empty,
|
|
12
|
-
useWorkspaceUsers: empty,
|
|
13
|
-
useWorkspaceUsersStatus: () => 'unavailable',
|
|
14
|
-
usePresence: empty,
|
|
15
|
-
usePublishPresence() {},
|
|
16
|
-
Cursors: nothing,
|
|
17
|
-
Activity: nothing,
|
|
18
|
-
Selection: nothing,
|
|
19
|
-
User: nothing,
|
|
20
|
-
Facepile: nothing,
|
|
21
|
-
PresenceFrame: nothing,
|
|
22
|
-
PresenceGroup: nothing,
|
|
23
|
-
PresenceGutter: nothing,
|
|
24
|
-
};
|
|
25
|
-
let warned = false;
|
|
26
|
-
function api() {
|
|
27
|
-
const collab = __getBridge()?.collab;
|
|
28
|
-
if (collab) return collab;
|
|
29
|
-
if (!warned) {
|
|
30
|
-
warned = true;
|
|
31
|
-
console.warn('[moi/collab] Collaboration API is unavailable. Hooks return empty values and components render nothing.');
|
|
32
|
-
}
|
|
33
|
-
return fallback;
|
|
34
|
-
}
|
|
35
|
-
export function useMe(...args) { return api().useMe(...args); }
|
|
36
|
-
export function usePeers(...args) { return api().usePeers(...args); }
|
|
37
|
-
export function useUser(...args) { return api().useUser(...args); }
|
|
38
|
-
export function useWorkspaceUsers(...args) { return api().useWorkspaceUsers(...args); }
|
|
39
|
-
export function useWorkspaceUsersStatus(...args) { return api().useWorkspaceUsersStatus(...args); }
|
|
40
|
-
export function usePresence(...args) { return api().usePresence(...args); }
|
|
41
|
-
export function usePublishPresence(...args) { return api().usePublishPresence(...args); }
|
|
42
|
-
export function Cursors(props) { return createElement(api().Cursors, props); }
|
|
43
|
-
export function Activity(props) { return createElement(api().Activity, props); }
|
|
44
|
-
export function Selection(props) { return createElement(api().Selection, props); }
|
|
45
|
-
export function User(props) { return createElement(api().User, props); }
|
|
46
|
-
export function Facepile(props) { return createElement(api().Facepile, props); }
|
|
47
|
-
export function PresenceFrame(props) { return createElement(api().PresenceFrame, props); }
|
|
48
|
-
export function PresenceGroup(props) { return createElement(api().PresenceGroup, props); }
|
|
49
|
-
export function PresenceGutter(props) { return createElement(api().PresenceGutter, props); }
|
|
50
|
-
`
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createRemoteJWKSet, customFetch, errors, jwtVerify } from 'jose'
|
|
2
|
-
import type { FetchImplementation } from 'jose'
|
|
3
|
-
|
|
4
|
-
import { colorForId } from '@/lib/collab/colors'
|
|
5
|
-
import { isCollabIdentity } from '@/lib/collab/protocol'
|
|
6
|
-
import type { CollabIdentity, ProxyIdentity } from '@/lib/collab/types'
|
|
7
|
-
|
|
8
|
-
import { type CloudflareAccessConfig, getAppConfig } from '../app-config'
|
|
9
|
-
|
|
10
|
-
// Cloudflare Access adds a signed application token (an RS256 JWT) to every
|
|
11
|
-
// request it lets through. Only the verified signature, issuer, and audience
|
|
12
|
-
// make the identity trustworthy: anyone who reaches the origin some other way
|
|
13
|
-
// can send the header too.
|
|
14
|
-
// https://developers.cloudflare.com/cloudflare-one/access-controls/applications/http-apps/authorization-cookie/validating-json/
|
|
15
|
-
export const ACCESS_TOKEN_HEADER = 'cf-access-jwt-assertion'
|
|
16
|
-
// Browsers hold the same application token in this cookie on the app's domain.
|
|
17
|
-
export const ACCESS_TOKEN_COOKIE = 'CF_Authorization'
|
|
18
|
-
|
|
19
|
-
// Failing to load the team's keys is a setup problem worth logging; a bad
|
|
20
|
-
// token is expected noise.
|
|
21
|
-
const KEY_ERRORS = new Set(['ERR_JOSE_GENERIC', 'ERR_JWKS_INVALID', 'ERR_JWKS_TIMEOUT'])
|
|
22
|
-
|
|
23
|
-
export type AccessUser = { id: string; email: string }
|
|
24
|
-
export type AccessVerifier = (token: string) => Promise<AccessUser | null>
|
|
25
|
-
|
|
26
|
-
// jose caches the team's signing keys for ten minutes and refetches them for
|
|
27
|
-
// an unknown key id at most every 30 seconds, which covers key rotation.
|
|
28
|
-
export function accessVerifier(
|
|
29
|
-
config: CloudflareAccessConfig,
|
|
30
|
-
fetch?: FetchImplementation
|
|
31
|
-
): AccessVerifier {
|
|
32
|
-
const url = new URL('/cdn-cgi/access/certs', config.teamDomain)
|
|
33
|
-
const keys = createRemoteJWKSet(url, fetch ? { [customFetch]: fetch } : {})
|
|
34
|
-
return async token => {
|
|
35
|
-
try {
|
|
36
|
-
const { payload } = await jwtVerify(token, keys, {
|
|
37
|
-
issuer: config.teamDomain,
|
|
38
|
-
audience: [...config.audience],
|
|
39
|
-
algorithms: ['RS256'],
|
|
40
|
-
requiredClaims: ['exp'],
|
|
41
|
-
clockTolerance: 60
|
|
42
|
-
})
|
|
43
|
-
// Service tokens have an empty `sub` and no email: there is no person.
|
|
44
|
-
const { sub, email } = payload
|
|
45
|
-
return sub && typeof email === 'string' && email ? { id: sub, email } : null
|
|
46
|
-
} catch (error) {
|
|
47
|
-
if (!(error instanceof errors.JOSEError) || KEY_ERRORS.has(error.code)) {
|
|
48
|
-
console.error(`[moi] Cloudflare Access: could not load signing keys from ${url}: ${error}`)
|
|
49
|
-
}
|
|
50
|
-
return null
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Access tokens carry an id and an email but no display name, so the profile
|
|
56
|
-
// has none and labels fall back to the email. The color is a stable pick from the id.
|
|
57
|
-
export function accessProfile({ id, email }: AccessUser): CollabIdentity | null {
|
|
58
|
-
const profile: CollabIdentity = { id, color: colorForId(id), email }
|
|
59
|
-
return isCollabIdentity(profile) ? profile : null
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// The verifier and its key cache live as long as the resolved config object.
|
|
63
|
-
let current: { config: CloudflareAccessConfig; verify: AccessVerifier } | null = null
|
|
64
|
-
|
|
65
|
-
// Who the configured proxy says sent this request. Without Cloudflare Access
|
|
66
|
-
// configured, moi trusts no proxy and every request resolves to no provider.
|
|
67
|
-
export async function proxyIdentity(req: Request): Promise<ProxyIdentity> {
|
|
68
|
-
const config = getAppConfig().cloudflareAccess
|
|
69
|
-
if (!config) return { provider: null, identity: null }
|
|
70
|
-
if (current?.config !== config) current = { config, verify: accessVerifier(config) }
|
|
71
|
-
// The header Access adds wins; the cookie covers proxies that drop it.
|
|
72
|
-
const token =
|
|
73
|
-
req.headers.get(ACCESS_TOKEN_HEADER) ??
|
|
74
|
-
new Bun.CookieMap(req.headers.get('cookie') ?? '').get(ACCESS_TOKEN_COOKIE)
|
|
75
|
-
const user = token ? await current.verify(token) : null
|
|
76
|
-
return { provider: 'cloudflare-access', identity: user ? accessProfile(user) : null }
|
|
77
|
-
}
|
package/server/collab/config.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceType } from '@/lib/types'
|
|
2
|
-
|
|
3
|
-
import { getAppConfig } from '../app-config'
|
|
4
|
-
import { collabSkillReferencePath } from './skill'
|
|
5
|
-
|
|
6
|
-
// Only an explicit startup CLI flag enables this process setting.
|
|
7
|
-
export function isCollabEnabled(): boolean {
|
|
8
|
-
return getAppConfig().experimental.collab
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function getCollabReferencePath(
|
|
12
|
-
workspacePath: string,
|
|
13
|
-
type?: WorkspaceType
|
|
14
|
-
): Promise<string | undefined> {
|
|
15
|
-
if (!isCollabEnabled()) return undefined
|
|
16
|
-
const referencePath = collabSkillReferencePath(workspacePath, type)
|
|
17
|
-
return (await Bun.file(referencePath).exists()) ? referencePath : undefined
|
|
18
|
-
}
|
package/server/collab/ipc.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CollabClientMessage, CollabServerMessage } from '@/lib/collab/types'
|
|
2
|
-
|
|
3
|
-
export type ParentMessage =
|
|
4
|
-
| { type: 'client'; connectionId: string; message: CollabClientMessage }
|
|
5
|
-
| { type: 'leave'; connectionId: string }
|
|
6
|
-
| { type: 'shutdown' }
|
|
7
|
-
|
|
8
|
-
export type WorkerMessage =
|
|
9
|
-
| { type: 'ready'; generation: string }
|
|
10
|
-
| { type: 'client'; generation: string; connectionId: string; message: CollabServerMessage }
|