@agimon-ai/po-native 0.0.1-alpha.5 → 0.0.1-alpha.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-native",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.7",
|
|
4
4
|
"description": "Po for iOS and Android",
|
|
5
5
|
"homepage": "https://agimon.ai",
|
|
6
6
|
"bugs": {
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
33
|
-
"@agimon-ai/po-expo-signing": "0.0.1-alpha.
|
|
34
|
-
"@agimon-ai/po-identity": "0.0.2-alpha.
|
|
35
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
36
|
-
"@agimon-ai/po-template-advanced": "0.0.0-alpha.
|
|
37
|
-
"@agimon-ai/po-voice": "0.0.0-alpha.
|
|
38
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
39
|
-
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.
|
|
40
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
32
|
+
"@agimon-ai/po-core": "0.0.0-alpha.127",
|
|
33
|
+
"@agimon-ai/po-expo-signing": "0.0.1-alpha.7",
|
|
34
|
+
"@agimon-ai/po-identity": "0.0.2-alpha.74",
|
|
35
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.127",
|
|
36
|
+
"@agimon-ai/po-template-advanced": "0.0.0-alpha.127",
|
|
37
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.127",
|
|
38
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.127",
|
|
39
|
+
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.127",
|
|
40
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.127",
|
|
41
41
|
"@better-auth/expo": "1.7.12",
|
|
42
42
|
"@config-plugins/react-native-webrtc": "15.0.2",
|
|
43
43
|
"@earendil-works/chord": "1.5.0",
|
package/src/app/App.tsx
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
pluginSettingsPanels,
|
|
45
45
|
applySessionRemoved,
|
|
46
46
|
applySessionUpsert,
|
|
47
|
+
sessionMoveTarget,
|
|
47
48
|
applyWorkspaceRemoved,
|
|
48
49
|
applyWorkspaceUpsert,
|
|
49
50
|
renameSession,
|
|
@@ -140,7 +141,12 @@ import { McpAppView } from '../components/richActivity/McpAppView';
|
|
|
140
141
|
import { NativeAuthorCaptureSurface } from '../components/richActivity/NativeAuthorCaptureSurface';
|
|
141
142
|
import { NativeAuthorHtmlView } from '../components/richActivity/NativeAuthorHtmlView';
|
|
142
143
|
import { SessionOptionsSheet } from '../components/SessionOptionsSheet';
|
|
143
|
-
import {
|
|
144
|
+
import {
|
|
145
|
+
CoordinatorProfileSheet,
|
|
146
|
+
NewSessionSheet,
|
|
147
|
+
type NewSessionTarget,
|
|
148
|
+
ResumeSheet,
|
|
149
|
+
} from '../components/SessionSheets';
|
|
144
150
|
import {
|
|
145
151
|
nativeComposerMessage,
|
|
146
152
|
nativeSlotProps,
|
|
@@ -200,6 +206,7 @@ import {
|
|
|
200
206
|
renameSessionGroup,
|
|
201
207
|
requestWithStepUp,
|
|
202
208
|
restartSession,
|
|
209
|
+
moveSession,
|
|
203
210
|
type ResumeSource,
|
|
204
211
|
searchDirectories,
|
|
205
212
|
setSessionGroups,
|
|
@@ -1455,6 +1462,11 @@ function SessionsRoute({
|
|
|
1455
1462
|
const creations = useRef(new WeakMap<NewSessionTarget, { pending: boolean; sessionId?: string }>());
|
|
1456
1463
|
const [choosingGeneralHost, setChoosingGeneralHost] = useState(false);
|
|
1457
1464
|
const [resume, setResume] = useState<ResumeSource | null>(null);
|
|
1465
|
+
const [coordinatorTarget, setCoordinatorTarget] = useState<{
|
|
1466
|
+
hostId: string;
|
|
1467
|
+
workspaceId?: string;
|
|
1468
|
+
owner: string;
|
|
1469
|
+
} | null>(null);
|
|
1458
1470
|
|
|
1459
1471
|
/**
|
|
1460
1472
|
* Opens a session the hub has just been asked to start, once it is listed. A host answers with its
|
|
@@ -1501,7 +1513,13 @@ function SessionsRoute({
|
|
|
1501
1513
|
if (!canMutate(owner)) return unavailable;
|
|
1502
1514
|
const cloud = cloudHostFor(owner);
|
|
1503
1515
|
const result = cloud ? await addCloudCoordinator(cloud, workspaceId) : await addCoordinator(workspaceId, hostId);
|
|
1504
|
-
if ('error' in result)
|
|
1516
|
+
if ('error' in result) {
|
|
1517
|
+
if ('profileRequired' in result && result.profileRequired === true) {
|
|
1518
|
+
setCoordinatorTarget({ hostId, workspaceId, owner });
|
|
1519
|
+
return undefined;
|
|
1520
|
+
}
|
|
1521
|
+
return result;
|
|
1522
|
+
}
|
|
1505
1523
|
const error = await openWhenListed(owner, result.sessionId);
|
|
1506
1524
|
return error === undefined ? undefined : { error };
|
|
1507
1525
|
};
|
|
@@ -1597,6 +1615,20 @@ function SessionsRoute({
|
|
|
1597
1615
|
// the cockpit. Renaming another session needs a hub route; until then it is a no-op there.
|
|
1598
1616
|
whenConnected(sessionId, () => renameSession(trimmed, sessionId));
|
|
1599
1617
|
},
|
|
1618
|
+
async moveSession(sessionId, workspaceId) {
|
|
1619
|
+
if (!canMutate(sessionId) || !canMutate(workspaceId)) return unavailable;
|
|
1620
|
+
const summary = sessionsStore.state.byId[sessionId]?.summary;
|
|
1621
|
+
const target = summary
|
|
1622
|
+
? sessionMoveTarget(summary, workspacesStore.state.byId, workspacesStore.state.order)
|
|
1623
|
+
: undefined;
|
|
1624
|
+
if (!target || target.blocked || !target.destinations.some((workspace) => workspace.id === workspaceId))
|
|
1625
|
+
return { error: 'This session cannot move to that workspace now.' };
|
|
1626
|
+
const result = await moveSession(sessionId, workspaceId);
|
|
1627
|
+
if ('error' in result) return result;
|
|
1628
|
+
if (result.session) applySessionUpsert({ session: result.session }, splitHostId(sessionId)?.hostId);
|
|
1629
|
+
// SessionRuntime rebinds the restarted reference; the hub upsert retains the qualified ID.
|
|
1630
|
+
return undefined;
|
|
1631
|
+
},
|
|
1600
1632
|
restartSession(sessionId) {
|
|
1601
1633
|
if (!canMutate(sessionId)) return;
|
|
1602
1634
|
void restartSession(sessionId);
|
|
@@ -1826,6 +1858,16 @@ function SessionsRoute({
|
|
|
1826
1858
|
</SheetBody>
|
|
1827
1859
|
</SheetContent>
|
|
1828
1860
|
</Sheet>
|
|
1861
|
+
<CoordinatorProfileSheet
|
|
1862
|
+
target={coordinatorTarget}
|
|
1863
|
+
onClose={() => setCoordinatorTarget(null)}
|
|
1864
|
+
onCreate={async (target, profile) => {
|
|
1865
|
+
if (!canMutate(target.owner)) return unavailable.error;
|
|
1866
|
+
const result = await addCoordinator(target.workspaceId, target.hostId, profile);
|
|
1867
|
+
if ('error' in result) return result.error;
|
|
1868
|
+
return openWhenListed(target.owner, result.sessionId);
|
|
1869
|
+
}}
|
|
1870
|
+
/>
|
|
1829
1871
|
<NewSessionSheet
|
|
1830
1872
|
target={newSession && canMutate(targetOwner(newSession)) ? newSession : null}
|
|
1831
1873
|
context={newSessionContext}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { PoNativeProvider, Sheet, SheetContent } from '@agimon-ai/po-native-components';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { UnistylesRuntime } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { CoordinatorProfileSheetView } from './SessionSheets';
|
|
6
|
+
|
|
7
|
+
export const meta = {
|
|
8
|
+
title: 'Native/Design/Coordinator profile',
|
|
9
|
+
component: CoordinatorProfileSheetView,
|
|
10
|
+
tags: ['style-system', 'mockup', 'native'],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
const FILE_PROFILE_SOURCE = 'files';
|
|
15
|
+
function Preview({
|
|
16
|
+
scheme = 'light',
|
|
17
|
+
state = 'ready',
|
|
18
|
+
}: {
|
|
19
|
+
scheme?: 'light' | 'dark';
|
|
20
|
+
state?: 'ready' | 'loading' | 'empty' | 'error';
|
|
21
|
+
}) {
|
|
22
|
+
UnistylesRuntime.setAdaptiveThemes(false);
|
|
23
|
+
UnistylesRuntime.setTheme(scheme);
|
|
24
|
+
const [profile, setProfile] = useState<string>();
|
|
25
|
+
return (
|
|
26
|
+
<PoNativeProvider>
|
|
27
|
+
<Sheet open>
|
|
28
|
+
<SheetContent>
|
|
29
|
+
<CoordinatorProfileSheetView
|
|
30
|
+
loading={state === 'loading'}
|
|
31
|
+
busy={false}
|
|
32
|
+
profile={profile}
|
|
33
|
+
onProfile={setProfile}
|
|
34
|
+
catalog={{
|
|
35
|
+
readiness: 'ready',
|
|
36
|
+
profiles:
|
|
37
|
+
state === 'empty'
|
|
38
|
+
? []
|
|
39
|
+
: [
|
|
40
|
+
{
|
|
41
|
+
name: 'Calm planner',
|
|
42
|
+
sourceId: FILE_PROFILE_SOURCE,
|
|
43
|
+
},
|
|
44
|
+
{ name: 'Careful reviewer', sourceId: FILE_PROFILE_SOURCE },
|
|
45
|
+
],
|
|
46
|
+
}}
|
|
47
|
+
error={state === 'error' ? 'This computer is unavailable. Your profile choice is kept.' : ''}
|
|
48
|
+
onReload={() => {}}
|
|
49
|
+
onCreate={() => {}}
|
|
50
|
+
onClose={() => {}}
|
|
51
|
+
/>
|
|
52
|
+
</SheetContent>
|
|
53
|
+
</Sheet>
|
|
54
|
+
</PoNativeProvider>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Playground = () => <Preview />;
|
|
59
|
+
export const Light = () => <Preview />;
|
|
60
|
+
export const Dark = () => <Preview scheme="dark" />;
|
|
61
|
+
export const Loading = () => <Preview state="loading" />;
|
|
62
|
+
export const Empty = () => <Preview state="empty" />;
|
|
63
|
+
export const Failure = () => <Preview state="error" />;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { WebPluginNewSessionContext, WebPluginSlotProps } from '@agimon-ai/po-core/web';
|
|
1
|
+
import type { LaunchProfileCatalog, WebPluginNewSessionContext, WebPluginSlotProps } from '@agimon-ai/po-core/web';
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
4
|
Input,
|
|
5
5
|
Label,
|
|
6
|
+
Select,
|
|
6
7
|
Sheet,
|
|
7
8
|
SheetBody,
|
|
8
9
|
SheetContent,
|
|
@@ -14,7 +15,7 @@ import type { PiSessionHistoryItem } from '@agimon-ai/po-web-dashboard/types';
|
|
|
14
15
|
import { createElement, useEffect, useState } from 'react';
|
|
15
16
|
import { Text, View } from 'react-native';
|
|
16
17
|
|
|
17
|
-
import { listHistory, type ResumeSource, resumeThread } from '../services/hostActions';
|
|
18
|
+
import { coordinatorProfiles, listHistory, type ResumeSource, resumeThread } from '../services/hostActions';
|
|
18
19
|
import { ResumeSheetView, resumeSheetStyles as styles } from './ResumeSheetView';
|
|
19
20
|
|
|
20
21
|
export { ResumeSheetView } from './ResumeSheetView';
|
|
@@ -102,6 +103,168 @@ export function NewSessionSheet({ target, context, slotProps }: NewSessionSheetP
|
|
|
102
103
|
);
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
type CoordinatorTarget = { hostId: string; workspaceId?: string; owner: string };
|
|
107
|
+
|
|
108
|
+
/** A launch-only choice. Closing never posts or changes a default. */
|
|
109
|
+
export function CoordinatorProfileSheet({
|
|
110
|
+
target,
|
|
111
|
+
onClose,
|
|
112
|
+
onCreate,
|
|
113
|
+
}: {
|
|
114
|
+
target: CoordinatorTarget | null;
|
|
115
|
+
onClose: () => void;
|
|
116
|
+
onCreate: (target: CoordinatorTarget, profile: string) => Promise<string | undefined>;
|
|
117
|
+
}) {
|
|
118
|
+
const [busy, setBusy] = useState(false);
|
|
119
|
+
return (
|
|
120
|
+
<Sheet open={target !== null} onOpenChange={(open) => !open && !busy && onClose()}>
|
|
121
|
+
<SheetContent>
|
|
122
|
+
{target ? (
|
|
123
|
+
<CoordinatorProfileForm
|
|
124
|
+
key={JSON.stringify(target)}
|
|
125
|
+
target={target}
|
|
126
|
+
onClose={onClose}
|
|
127
|
+
onCreate={onCreate}
|
|
128
|
+
busy={busy}
|
|
129
|
+
setBusy={setBusy}
|
|
130
|
+
/>
|
|
131
|
+
) : null}
|
|
132
|
+
</SheetContent>
|
|
133
|
+
</Sheet>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function CoordinatorProfileForm({
|
|
138
|
+
target,
|
|
139
|
+
onClose,
|
|
140
|
+
onCreate,
|
|
141
|
+
busy,
|
|
142
|
+
setBusy,
|
|
143
|
+
}: {
|
|
144
|
+
target: CoordinatorTarget;
|
|
145
|
+
onClose: () => void;
|
|
146
|
+
onCreate: (target: CoordinatorTarget, profile: string) => Promise<string | undefined>;
|
|
147
|
+
busy: boolean;
|
|
148
|
+
setBusy: (busy: boolean) => void;
|
|
149
|
+
}) {
|
|
150
|
+
const [catalog, setCatalog] = useState<LaunchProfileCatalog>();
|
|
151
|
+
const [loading, setLoading] = useState(true);
|
|
152
|
+
const [revision, setRevision] = useState(0);
|
|
153
|
+
const [profile, setProfile] = useState<string>();
|
|
154
|
+
const [error, setError] = useState('');
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
const controller = new AbortController();
|
|
157
|
+
setLoading(true);
|
|
158
|
+
void coordinatorProfiles(target.hostId, target.workspaceId, controller.signal).then((value) => {
|
|
159
|
+
if (controller.signal.aborted) return;
|
|
160
|
+
setCatalog(value);
|
|
161
|
+
setLoading(false);
|
|
162
|
+
});
|
|
163
|
+
return () => controller.abort();
|
|
164
|
+
}, [target, revision]);
|
|
165
|
+
const create = async () => {
|
|
166
|
+
if (busy || !profile || !catalog?.profiles.some((item) => item.name === profile)) return;
|
|
167
|
+
setBusy(true);
|
|
168
|
+
setError('');
|
|
169
|
+
try {
|
|
170
|
+
const failure = await onCreate(target, profile);
|
|
171
|
+
if (failure === undefined) onClose();
|
|
172
|
+
else setError(failure);
|
|
173
|
+
} catch {
|
|
174
|
+
setError('Po could not add the coordinator. Try again.');
|
|
175
|
+
} finally {
|
|
176
|
+
setBusy(false);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
return (
|
|
180
|
+
<CoordinatorProfileSheetView
|
|
181
|
+
catalog={catalog}
|
|
182
|
+
loading={loading}
|
|
183
|
+
profile={profile}
|
|
184
|
+
busy={busy}
|
|
185
|
+
error={error}
|
|
186
|
+
onProfile={setProfile}
|
|
187
|
+
onReload={() => setRevision((value) => value + 1)}
|
|
188
|
+
onCreate={() => void create()}
|
|
189
|
+
onClose={onClose}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Deterministic composition shared by the recovery flow and its unapproved design stories. */
|
|
195
|
+
export function CoordinatorProfileSheetView({
|
|
196
|
+
catalog,
|
|
197
|
+
loading,
|
|
198
|
+
profile,
|
|
199
|
+
busy,
|
|
200
|
+
error,
|
|
201
|
+
onProfile,
|
|
202
|
+
onReload,
|
|
203
|
+
onCreate,
|
|
204
|
+
onClose,
|
|
205
|
+
}: {
|
|
206
|
+
catalog?: LaunchProfileCatalog;
|
|
207
|
+
loading: boolean;
|
|
208
|
+
profile?: string;
|
|
209
|
+
busy: boolean;
|
|
210
|
+
error: string;
|
|
211
|
+
onProfile: (profile: string) => void;
|
|
212
|
+
onReload: () => void;
|
|
213
|
+
onCreate: () => void;
|
|
214
|
+
onClose: () => void;
|
|
215
|
+
}) {
|
|
216
|
+
return (
|
|
217
|
+
<>
|
|
218
|
+
<SheetHeader>
|
|
219
|
+
<SheetTitle>Choose a coordinator profile</SheetTitle>
|
|
220
|
+
</SheetHeader>
|
|
221
|
+
<SheetBody style={styles.body}>
|
|
222
|
+
<Text style={styles.root}>Choose a profile for this coordinator. Your defaults stay unchanged.</Text>
|
|
223
|
+
<Select
|
|
224
|
+
title="Profile"
|
|
225
|
+
placeholder="Choose a profile"
|
|
226
|
+
value={profile}
|
|
227
|
+
onValueChange={onProfile}
|
|
228
|
+
disabled={loading || busy}
|
|
229
|
+
options={(catalog?.profiles ?? []).map((item) => ({
|
|
230
|
+
value: item.name,
|
|
231
|
+
label: item.identity?.name || item.name,
|
|
232
|
+
}))}
|
|
233
|
+
/>
|
|
234
|
+
{loading ? (
|
|
235
|
+
<Text style={styles.root}>Loading profiles…</Text>
|
|
236
|
+
) : !catalog || catalog.readiness === 'unavailable' ? (
|
|
237
|
+
<Text style={styles.root}>Some profiles could not be loaded.</Text>
|
|
238
|
+
) : catalog.profiles.length === 0 ? (
|
|
239
|
+
<Text style={styles.root}>No profiles are available on this computer.</Text>
|
|
240
|
+
) : null}
|
|
241
|
+
{!loading ? (
|
|
242
|
+
<Button variant="ghost" disabled={busy} onPress={onReload}>
|
|
243
|
+
Reload profiles
|
|
244
|
+
</Button>
|
|
245
|
+
) : null}
|
|
246
|
+
{error ? (
|
|
247
|
+
<Text style={styles.error} accessibilityRole="alert">
|
|
248
|
+
{error}
|
|
249
|
+
</Text>
|
|
250
|
+
) : null}
|
|
251
|
+
<Button
|
|
252
|
+
variant="primary"
|
|
253
|
+
loading={busy}
|
|
254
|
+
loadingLabel="Creating"
|
|
255
|
+
disabled={loading || !profile || !catalog?.profiles.some((item) => item.name === profile)}
|
|
256
|
+
onPress={onCreate}
|
|
257
|
+
>
|
|
258
|
+
Create coordinator
|
|
259
|
+
</Button>
|
|
260
|
+
<Button variant="ghost" disabled={busy} onPress={onClose}>
|
|
261
|
+
Cancel
|
|
262
|
+
</Button>
|
|
263
|
+
</SheetBody>
|
|
264
|
+
</>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
105
268
|
export interface ResumeSheetProps {
|
|
106
269
|
source: ResumeSource | null;
|
|
107
270
|
onClose: () => void;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
sessionApiAddress,
|
|
10
10
|
sessionApiPath,
|
|
11
11
|
} from '@agimon-ai/po-core/web';
|
|
12
|
+
import { parseProfileCatalog } from '@agimon-ai/po-web-components/text';
|
|
12
13
|
import { splitHostId } from '@agimon-ai/po-web-dashboard/core';
|
|
13
14
|
import {
|
|
14
15
|
DIRECTORIES_API_ROUTE,
|
|
@@ -41,6 +42,7 @@ const HOST_ROUTES = defineApiRoutes({
|
|
|
41
42
|
createSession: { method: 'POST', path: '/sessions', host: true, response: apiResponse<unknown>() },
|
|
42
43
|
sessionDetail: { method: 'GET', path: '/sessions/:sessionId', host: true, response: apiResponse<unknown>() },
|
|
43
44
|
restart: { method: 'POST', path: '/restart', host: true },
|
|
45
|
+
move: { method: 'POST', path: '/move', host: true },
|
|
44
46
|
role: { method: 'POST', path: '/role', host: true },
|
|
45
47
|
history: { method: 'GET', path: '/history', host: true, response: apiResponse<unknown>() },
|
|
46
48
|
resume: { method: 'POST', path: '/resume', host: true, response: apiResponse<unknown>() },
|
|
@@ -96,6 +98,22 @@ export async function restartSession(sessionId: string): Promise<{ error: string
|
|
|
96
98
|
return failureOf(await host.session(sessionId).restart());
|
|
97
99
|
}
|
|
98
100
|
|
|
101
|
+
/** Re-read destination metadata after restart, closing a missed hub-upsert race. */
|
|
102
|
+
export async function moveSession(
|
|
103
|
+
sessionId: string,
|
|
104
|
+
workspaceId: string,
|
|
105
|
+
): Promise<Result<{ session?: SessionSummary }>> {
|
|
106
|
+
const owner = splitHostId(sessionId);
|
|
107
|
+
if (owner?.hostId !== splitHostId(workspaceId)?.hostId) return { error: 'Choose a workspace on the same computer.' };
|
|
108
|
+
const result = await host
|
|
109
|
+
.session(sessionId)
|
|
110
|
+
.move({ body: { workspaceId: splitHostId(workspaceId)?.localId ?? workspaceId } });
|
|
111
|
+
const failure = failureOf(result);
|
|
112
|
+
if (failure) return failure;
|
|
113
|
+
const session = await sessionDetail(workspaceId, owner?.localId ?? sessionId);
|
|
114
|
+
return session ? { session } : {};
|
|
115
|
+
}
|
|
116
|
+
|
|
99
117
|
export async function removeWorkspace(workspaceId: string): Promise<{ error: string } | undefined> {
|
|
100
118
|
return failureOf(await host.workspace(workspaceId).remove({ query: { removeSessions: true } }));
|
|
101
119
|
}
|
|
@@ -197,7 +215,8 @@ const JSON_BODY = { 'content-type': 'application/json' };
|
|
|
197
215
|
export async function addCoordinator(
|
|
198
216
|
workspaceId?: string,
|
|
199
217
|
hostId?: string,
|
|
200
|
-
|
|
218
|
+
profile?: string,
|
|
219
|
+
): Promise<{ sessionId: string; created: boolean } | { error: string; profileRequired?: true }> {
|
|
201
220
|
const owner = workspaceId === undefined ? undefined : splitHostId(workspaceId);
|
|
202
221
|
if (owner && hostId !== undefined && owner.hostId !== hostId)
|
|
203
222
|
return { error: 'The workspace belongs to another computer.' };
|
|
@@ -206,10 +225,15 @@ export async function addCoordinator(
|
|
|
206
225
|
{
|
|
207
226
|
method: 'POST',
|
|
208
227
|
headers: JSON_BODY,
|
|
209
|
-
body: JSON.stringify(
|
|
228
|
+
body: JSON.stringify({
|
|
229
|
+
...(workspaceId === undefined ? {} : { workspaceId: owner?.localId ?? workspaceId }),
|
|
230
|
+
...(profile === undefined ? {} : { profile }),
|
|
231
|
+
}),
|
|
210
232
|
},
|
|
211
233
|
owner?.hostId ?? hostId,
|
|
212
234
|
);
|
|
235
|
+
if (!ok && status === 422 && isRecord(body) && body.profileRequired === true && typeof body.error === 'string')
|
|
236
|
+
return { error: body.error, profileRequired: true };
|
|
213
237
|
if (
|
|
214
238
|
!ok ||
|
|
215
239
|
!isRecord(body) ||
|
|
@@ -221,6 +245,17 @@ export async function addCoordinator(
|
|
|
221
245
|
return { sessionId: body.sessionId, created: body.created };
|
|
222
246
|
}
|
|
223
247
|
|
|
248
|
+
/** Reads only launch-safe profile metadata on the captured computer. */
|
|
249
|
+
export async function coordinatorProfiles(hostId: string, workspaceId: string | undefined, signal: AbortSignal) {
|
|
250
|
+
const prefix = workspaceId === undefined ? '/api' : `/api/workspaces/${encodeURIComponent(workspaceId)}`;
|
|
251
|
+
const { ok, body } = await rootRequest(
|
|
252
|
+
`${prefix}/plugins/profile/launch-profiles`,
|
|
253
|
+
{ cache: 'no-store', signal },
|
|
254
|
+
hostId,
|
|
255
|
+
);
|
|
256
|
+
return ok ? parseProfileCatalog(body) : undefined;
|
|
257
|
+
}
|
|
258
|
+
|
|
224
259
|
/** Changes the role on the session's owning computer. Busy sessions are refused by the host. */
|
|
225
260
|
export async function setSessionRole(sessionId: string, coordinator: boolean): Promise<{ error: string } | undefined> {
|
|
226
261
|
return failureOf(await host.session(sessionId).role({ body: { coordinator } }));
|