@agimon-ai/po-native 0.0.1-alpha.5 → 0.0.1-alpha.6
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.6",
|
|
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.126",
|
|
33
|
+
"@agimon-ai/po-expo-signing": "0.0.1-alpha.6",
|
|
34
|
+
"@agimon-ai/po-identity": "0.0.2-alpha.73",
|
|
35
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.126",
|
|
36
|
+
"@agimon-ai/po-template-advanced": "0.0.0-alpha.126",
|
|
37
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.126",
|
|
38
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.126",
|
|
39
|
+
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.126",
|
|
40
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.126",
|
|
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
|
@@ -140,7 +140,12 @@ import { McpAppView } from '../components/richActivity/McpAppView';
|
|
|
140
140
|
import { NativeAuthorCaptureSurface } from '../components/richActivity/NativeAuthorCaptureSurface';
|
|
141
141
|
import { NativeAuthorHtmlView } from '../components/richActivity/NativeAuthorHtmlView';
|
|
142
142
|
import { SessionOptionsSheet } from '../components/SessionOptionsSheet';
|
|
143
|
-
import {
|
|
143
|
+
import {
|
|
144
|
+
CoordinatorProfileSheet,
|
|
145
|
+
NewSessionSheet,
|
|
146
|
+
type NewSessionTarget,
|
|
147
|
+
ResumeSheet,
|
|
148
|
+
} from '../components/SessionSheets';
|
|
144
149
|
import {
|
|
145
150
|
nativeComposerMessage,
|
|
146
151
|
nativeSlotProps,
|
|
@@ -1455,6 +1460,11 @@ function SessionsRoute({
|
|
|
1455
1460
|
const creations = useRef(new WeakMap<NewSessionTarget, { pending: boolean; sessionId?: string }>());
|
|
1456
1461
|
const [choosingGeneralHost, setChoosingGeneralHost] = useState(false);
|
|
1457
1462
|
const [resume, setResume] = useState<ResumeSource | null>(null);
|
|
1463
|
+
const [coordinatorTarget, setCoordinatorTarget] = useState<{
|
|
1464
|
+
hostId: string;
|
|
1465
|
+
workspaceId?: string;
|
|
1466
|
+
owner: string;
|
|
1467
|
+
} | null>(null);
|
|
1458
1468
|
|
|
1459
1469
|
/**
|
|
1460
1470
|
* Opens a session the hub has just been asked to start, once it is listed. A host answers with its
|
|
@@ -1501,7 +1511,13 @@ function SessionsRoute({
|
|
|
1501
1511
|
if (!canMutate(owner)) return unavailable;
|
|
1502
1512
|
const cloud = cloudHostFor(owner);
|
|
1503
1513
|
const result = cloud ? await addCloudCoordinator(cloud, workspaceId) : await addCoordinator(workspaceId, hostId);
|
|
1504
|
-
if ('error' in result)
|
|
1514
|
+
if ('error' in result) {
|
|
1515
|
+
if ('profileRequired' in result && result.profileRequired === true) {
|
|
1516
|
+
setCoordinatorTarget({ hostId, workspaceId, owner });
|
|
1517
|
+
return undefined;
|
|
1518
|
+
}
|
|
1519
|
+
return result;
|
|
1520
|
+
}
|
|
1505
1521
|
const error = await openWhenListed(owner, result.sessionId);
|
|
1506
1522
|
return error === undefined ? undefined : { error };
|
|
1507
1523
|
};
|
|
@@ -1826,6 +1842,16 @@ function SessionsRoute({
|
|
|
1826
1842
|
</SheetBody>
|
|
1827
1843
|
</SheetContent>
|
|
1828
1844
|
</Sheet>
|
|
1845
|
+
<CoordinatorProfileSheet
|
|
1846
|
+
target={coordinatorTarget}
|
|
1847
|
+
onClose={() => setCoordinatorTarget(null)}
|
|
1848
|
+
onCreate={async (target, profile) => {
|
|
1849
|
+
if (!canMutate(target.owner)) return unavailable.error;
|
|
1850
|
+
const result = await addCoordinator(target.workspaceId, target.hostId, profile);
|
|
1851
|
+
if ('error' in result) return result.error;
|
|
1852
|
+
return openWhenListed(target.owner, result.sessionId);
|
|
1853
|
+
}}
|
|
1854
|
+
/>
|
|
1829
1855
|
<NewSessionSheet
|
|
1830
1856
|
target={newSession && canMutate(targetOwner(newSession)) ? newSession : null}
|
|
1831
1857
|
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,
|
|
@@ -197,7 +198,8 @@ const JSON_BODY = { 'content-type': 'application/json' };
|
|
|
197
198
|
export async function addCoordinator(
|
|
198
199
|
workspaceId?: string,
|
|
199
200
|
hostId?: string,
|
|
200
|
-
|
|
201
|
+
profile?: string,
|
|
202
|
+
): Promise<{ sessionId: string; created: boolean } | { error: string; profileRequired?: true }> {
|
|
201
203
|
const owner = workspaceId === undefined ? undefined : splitHostId(workspaceId);
|
|
202
204
|
if (owner && hostId !== undefined && owner.hostId !== hostId)
|
|
203
205
|
return { error: 'The workspace belongs to another computer.' };
|
|
@@ -206,10 +208,15 @@ export async function addCoordinator(
|
|
|
206
208
|
{
|
|
207
209
|
method: 'POST',
|
|
208
210
|
headers: JSON_BODY,
|
|
209
|
-
body: JSON.stringify(
|
|
211
|
+
body: JSON.stringify({
|
|
212
|
+
...(workspaceId === undefined ? {} : { workspaceId: owner?.localId ?? workspaceId }),
|
|
213
|
+
...(profile === undefined ? {} : { profile }),
|
|
214
|
+
}),
|
|
210
215
|
},
|
|
211
216
|
owner?.hostId ?? hostId,
|
|
212
217
|
);
|
|
218
|
+
if (!ok && status === 422 && isRecord(body) && body.profileRequired === true && typeof body.error === 'string')
|
|
219
|
+
return { error: body.error, profileRequired: true };
|
|
213
220
|
if (
|
|
214
221
|
!ok ||
|
|
215
222
|
!isRecord(body) ||
|
|
@@ -221,6 +228,17 @@ export async function addCoordinator(
|
|
|
221
228
|
return { sessionId: body.sessionId, created: body.created };
|
|
222
229
|
}
|
|
223
230
|
|
|
231
|
+
/** Reads only launch-safe profile metadata on the captured computer. */
|
|
232
|
+
export async function coordinatorProfiles(hostId: string, workspaceId: string | undefined, signal: AbortSignal) {
|
|
233
|
+
const prefix = workspaceId === undefined ? '/api' : `/api/workspaces/${encodeURIComponent(workspaceId)}`;
|
|
234
|
+
const { ok, body } = await rootRequest(
|
|
235
|
+
`${prefix}/plugins/profile/launch-profiles`,
|
|
236
|
+
{ cache: 'no-store', signal },
|
|
237
|
+
hostId,
|
|
238
|
+
);
|
|
239
|
+
return ok ? parseProfileCatalog(body) : undefined;
|
|
240
|
+
}
|
|
241
|
+
|
|
224
242
|
/** Changes the role on the session's owning computer. Busy sessions are refused by the host. */
|
|
225
243
|
export async function setSessionRole(sessionId: string, coordinator: boolean): Promise<{ error: string } | undefined> {
|
|
226
244
|
return failureOf(await host.session(sessionId).role({ body: { coordinator } }));
|