@agimon-ai/po-native 0.0.1-alpha.13 → 0.0.1-alpha.15

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.13",
3
+ "version": "0.0.1-alpha.15",
4
4
  "description": "Po for iOS and Android",
5
5
  "homepage": "https://agimon.ai",
6
6
  "bugs": {
@@ -29,17 +29,17 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@agimon-ai/po-core": "0.0.0-alpha.133",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.13",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.80",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.133",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.5",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.133",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.133",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.133",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.133",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.133",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.133",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.135",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.15",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.82",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.135",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.7",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.135",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.135",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.135",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.135",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.135",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.135",
43
43
  "@better-auth/expo": "1.7.12",
44
44
  "@config-plugins/react-native-webrtc": "15.0.2",
45
45
  "@earendil-works/chord": "1.5.0",
package/src/app/App.tsx CHANGED
@@ -71,6 +71,10 @@ import {
71
71
  useRailEntries,
72
72
  useRailEntry,
73
73
  railSessionStatus,
74
+ liveSessionOptions,
75
+ mentionableSessions,
76
+ type MentionableSession,
77
+ resolveSessionReference,
74
78
  activityWaitingCount,
75
79
  sessionStoreFor,
76
80
  sessionMinorModes,
@@ -417,6 +421,14 @@ function useOpenSession(): (sessionId: string) => void {
417
421
  );
418
422
  }
419
423
 
424
+ /** Sessions an `@session:` mention in `sessionId` can name: those on its computer, by that computer's ids. */
425
+ function mentionSessionsOn(sessionId: string): MentionableSession[] {
426
+ const hostId = splitHostId(sessionId)?.hostId;
427
+ return mentionableSessions(sessionsStore.state, sessionId, Date.now()).flatMap((session) => {
428
+ const owner = splitHostId(session.id);
429
+ return owner?.hostId === hostId ? [{ ...session, id: owner?.localId ?? session.id }] : [];
430
+ });
431
+ }
420
432
  function useOpenWorkspace(hostId?: string): (workspaceId: string) => void {
421
433
  const navigation = useNavigation<NativeStackNavigationProp<Routes>>();
422
434
  return useCallback(
@@ -761,6 +773,12 @@ function SessionRoute({
761
773
  () => ({
762
774
  loadImage: (path: string) => loadSessionImage(sessionId, path),
763
775
  onFileLink: (label: string, explicit = false) => {
776
+ // `@session:<token>` opens that session, found among the ones on this session's computer.
777
+ const mentioned = explicit ? undefined : resolveSessionReference(label, mentionSessionsOn(sessionId));
778
+ if (mentioned !== undefined) {
779
+ const hostId = splitHostId(sessionId)?.hostId;
780
+ return () => openSession(hostId === undefined ? mentioned.id : qualifyHostId(hostId, mentioned.id));
781
+ }
764
782
  const tab = explicit ? fileTabForPath(sessionId, label) : resolveFileLink(label);
765
783
  if (tab === undefined) return undefined;
766
784
  return () => {
@@ -770,7 +788,7 @@ function SessionRoute({
770
788
  };
771
789
  },
772
790
  }),
773
- [sessionId, ownerSessionId, resolveFileLink],
791
+ [sessionId, ownerSessionId, resolveFileLink, openSession],
774
792
  );
775
793
  const openTab = (tabId: string | null) => {
776
794
  setActivityOpen(false);
@@ -834,6 +852,20 @@ function SessionRoute({
834
852
  },
835
853
  },
836
854
  nativeRealtime: nativeRealtime.factory,
855
+ takeComposerDraft: () => {
856
+ const text = drafts.state[sessionId] ?? '';
857
+ setDrafts((current) => ({ ...current, [sessionId]: '' }));
858
+ return text;
859
+ },
860
+ // Sessions on this session's own computer: a global server method reaches only those.
861
+ listSessions: () =>
862
+ liveSessionOptions(
863
+ sessionsStore.state,
864
+ workspacesStore.state.byId,
865
+ sessionId,
866
+ splitHostId(sessionId)?.hostId,
867
+ Date.now(),
868
+ ),
837
869
  ...nativeHost?.(sessionId),
838
870
  // Only the sections this app has a screen for; others are ignored, as the slot contract allows.
839
871
  // A session's Settings request opens its own computer, however many are paired.
@@ -949,6 +981,7 @@ function SessionRoute({
949
981
  composer={{
950
982
  live: true,
951
983
  searchFiles: (query: string) => searchFiles(sessionId, query),
984
+ mentionSessions: () => mentionSessionsOn(sessionId),
952
985
  uploadAttachment: uploadSessionAttachment,
953
986
  onAbort: () => whenConnected(sessionId, () => abortRun(sessionId)),
954
987
  onOpenOptions: () => setOptionsOpen(true),
@@ -2,7 +2,7 @@ import { PoNativeProvider, Sheet, SheetContent } from '@agimon-ai/po-native-comp
2
2
  import { useState } from 'react';
3
3
  import { UnistylesRuntime } from 'react-native-unistyles';
4
4
 
5
- import { CoordinatorProfileSheetView } from './SessionSheets';
5
+ import { CoordinatorNewProfileView, CoordinatorProfileSheetView } from './SessionSheets';
6
6
 
7
7
  export const meta = {
8
8
  title: 'Native/Design/Coordinator profile',
@@ -46,6 +46,7 @@ function Preview({
46
46
  }}
47
47
  error={state === 'error' ? 'This computer is unavailable. Your profile choice is kept.' : ''}
48
48
  onReload={() => {}}
49
+ onNewProfile={() => {}}
49
50
  onCreate={() => {}}
50
51
  onClose={() => {}}
51
52
  />
@@ -61,3 +62,32 @@ export const Dark = () => <Preview scheme="dark" />;
61
62
  export const Loading = () => <Preview state="loading" />;
62
63
  export const Empty = () => <Preview state="empty" />;
63
64
  export const Failure = () => <Preview state="error" />;
65
+
66
+ function NewProfilePreview({ scheme = 'light' }: { scheme?: 'light' | 'dark' }) {
67
+ UnistylesRuntime.setAdaptiveThemes(false);
68
+ UnistylesRuntime.setTheme(scheme);
69
+ const [value, setValue] = useState<Parameters<typeof CoordinatorNewProfileView>[0]['value']>({
70
+ displayName: 'Calm planner',
71
+ alias: 'calm-planner',
72
+ preset: 'focused',
73
+ });
74
+ return (
75
+ <PoNativeProvider>
76
+ <Sheet open>
77
+ <SheetContent>
78
+ <CoordinatorNewProfileView
79
+ value={value}
80
+ busy={false}
81
+ error=""
82
+ onChange={setValue}
83
+ onBack={() => {}}
84
+ onSave={() => {}}
85
+ />
86
+ </SheetContent>
87
+ </Sheet>
88
+ </PoNativeProvider>
89
+ );
90
+ }
91
+
92
+ export const NewProfile = () => <NewProfilePreview />;
93
+ export const NewProfileDark = () => <NewProfilePreview scheme="dark" />;
@@ -15,7 +15,14 @@ import type { PiSessionHistoryItem } from '@agimon-ai/po-web-dashboard/types';
15
15
  import { createElement, useEffect, useState } from 'react';
16
16
  import { Text, View } from 'react-native';
17
17
 
18
- import { coordinatorProfiles, listHistory, type ResumeSource, resumeThread } from '../services/hostActions';
18
+ import {
19
+ coordinatorProfiles,
20
+ createProfile,
21
+ type CreateProfileInput,
22
+ listHistory,
23
+ type ResumeSource,
24
+ resumeThread,
25
+ } from '../services/hostActions';
19
26
  import { ResumeSheetView, resumeSheetStyles as styles } from './ResumeSheetView';
20
27
 
21
28
  export { ResumeSheetView } from './ResumeSheetView';
@@ -152,6 +159,7 @@ function CoordinatorProfileForm({
152
159
  const [revision, setRevision] = useState(0);
153
160
  const [profile, setProfile] = useState<string>();
154
161
  const [error, setError] = useState('');
162
+ const [draft, setDraft] = useState<CreateProfileInput>();
155
163
  useEffect(() => {
156
164
  const controller = new AbortController();
157
165
  setLoading(true);
@@ -176,7 +184,34 @@ function CoordinatorProfileForm({
176
184
  setBusy(false);
177
185
  }
178
186
  };
179
- return (
187
+ const save = async () => {
188
+ if (busy || !draft) return;
189
+ setBusy(true);
190
+ setError('');
191
+ try {
192
+ const result = await createProfile(draft, target.hostId);
193
+ if ('error' in result) return setError(result.error);
194
+ // Reload so the picker confirms the saved profile can launch on this computer.
195
+ setDraft(undefined);
196
+ setProfile(result.name);
197
+ setRevision((value) => value + 1);
198
+ } finally {
199
+ setBusy(false);
200
+ }
201
+ };
202
+ return draft ? (
203
+ <CoordinatorNewProfileView
204
+ value={draft}
205
+ busy={busy}
206
+ error={error}
207
+ onChange={setDraft}
208
+ onBack={() => {
209
+ setDraft(undefined);
210
+ setError('');
211
+ }}
212
+ onSave={() => void save()}
213
+ />
214
+ ) : (
180
215
  <CoordinatorProfileSheetView
181
216
  catalog={catalog}
182
217
  loading={loading}
@@ -185,12 +220,100 @@ function CoordinatorProfileForm({
185
220
  error={error}
186
221
  onProfile={setProfile}
187
222
  onReload={() => setRevision((value) => value + 1)}
223
+ onNewProfile={() => {
224
+ setDraft({ displayName: '', alias: '', preset: 'focused' });
225
+ setError('');
226
+ }}
188
227
  onCreate={() => void create()}
189
228
  onClose={onClose}
190
229
  />
191
230
  );
192
231
  }
193
232
 
233
+ // The profile API's persona presets; the server owns their personality text.
234
+ const PERSONALITIES = [
235
+ { value: 'focused', label: 'Focused' },
236
+ { value: 'friendly', label: 'Friendly' },
237
+ { value: 'creative', label: 'Creative' },
238
+ { value: 'persuasive', label: 'Persuasive' },
239
+ ] as const;
240
+
241
+ /** Names a new personal profile on the coordinator's computer. Its default profile stays unchanged. */
242
+ export function CoordinatorNewProfileView({
243
+ value,
244
+ busy,
245
+ error,
246
+ onChange,
247
+ onBack,
248
+ onSave,
249
+ }: {
250
+ value: CreateProfileInput;
251
+ busy: boolean;
252
+ error: string;
253
+ onChange: (value: CreateProfileInput) => void;
254
+ onBack: () => void;
255
+ onSave: () => void;
256
+ }) {
257
+ return (
258
+ <>
259
+ <SheetHeader>
260
+ <SheetTitle>Create profile</SheetTitle>
261
+ </SheetHeader>
262
+ <SheetBody style={styles.body}>
263
+ <Text style={styles.root}>Choose a name and how Po works with you.</Text>
264
+ <View style={styles.field}>
265
+ <Label>Name</Label>
266
+ <Input
267
+ value={value.displayName}
268
+ onChangeText={(displayName) => onChange({ ...value, displayName })}
269
+ accessibilityLabel="Profile name"
270
+ disabled={busy}
271
+ />
272
+ </View>
273
+ <View style={styles.field}>
274
+ <Label>Profile ID</Label>
275
+ <Input
276
+ value={value.alias}
277
+ onChangeText={(alias) => onChange({ ...value, alias })}
278
+ placeholder="Lowercase letters, numbers, and hyphens"
279
+ accessibilityLabel="Profile ID"
280
+ autoCapitalize="none"
281
+ autoCorrect={false}
282
+ disabled={busy}
283
+ />
284
+ </View>
285
+ <Select
286
+ title="Personality"
287
+ value={value.preset}
288
+ onValueChange={(preset) => {
289
+ const choice = PERSONALITIES.find((item) => item.value === preset);
290
+ if (choice) onChange({ ...value, preset: choice.value });
291
+ }}
292
+ disabled={busy}
293
+ options={[...PERSONALITIES]}
294
+ />
295
+ {error ? (
296
+ <Text style={styles.error} accessibilityRole="alert">
297
+ {error}
298
+ </Text>
299
+ ) : null}
300
+ <Button
301
+ variant="primary"
302
+ loading={busy}
303
+ loadingLabel="Saving"
304
+ disabled={!value.displayName.trim() || !value.alias.trim()}
305
+ onPress={onSave}
306
+ >
307
+ Save profile
308
+ </Button>
309
+ <Button variant="ghost" disabled={busy} onPress={onBack}>
310
+ Back
311
+ </Button>
312
+ </SheetBody>
313
+ </>
314
+ );
315
+ }
316
+
194
317
  /** Deterministic composition shared by the recovery flow and its unapproved design stories. */
195
318
  export function CoordinatorProfileSheetView({
196
319
  catalog,
@@ -200,6 +323,7 @@ export function CoordinatorProfileSheetView({
200
323
  error,
201
324
  onProfile,
202
325
  onReload,
326
+ onNewProfile,
203
327
  onCreate,
204
328
  onClose,
205
329
  }: {
@@ -210,6 +334,7 @@ export function CoordinatorProfileSheetView({
210
334
  error: string;
211
335
  onProfile: (profile: string) => void;
212
336
  onReload: () => void;
337
+ onNewProfile: () => void;
213
338
  onCreate: () => void;
214
339
  onClose: () => void;
215
340
  }) {
@@ -243,6 +368,9 @@ export function CoordinatorProfileSheetView({
243
368
  Reload profiles
244
369
  </Button>
245
370
  ) : null}
371
+ <Button variant="outline" disabled={busy} onPress={onNewProfile}>
372
+ New profile
373
+ </Button>
246
374
  {error ? (
247
375
  <Text style={styles.error} accessibilityRole="alert">
248
376
  {error}
@@ -256,6 +256,26 @@ export async function coordinatorProfiles(hostId: string, workspaceId: string |
256
256
  return ok ? parseProfileCatalog(body) : undefined;
257
257
  }
258
258
 
259
+ export interface CreateProfileInput {
260
+ alias: string;
261
+ displayName: string;
262
+ preset: 'focused' | 'friendly' | 'creative' | 'persuasive';
263
+ }
264
+
265
+ /** Saves a personal profile on the coordinator's captured computer, without changing its default. */
266
+ export async function createProfile(
267
+ input: CreateProfileInput,
268
+ hostId: string,
269
+ ): Promise<{ name: string } | { error: string }> {
270
+ const { ok, body, status } = await rootRequest(
271
+ '/api/plugins/profile/profiles',
272
+ { method: 'POST', headers: JSON_BODY, body: JSON.stringify(input) },
273
+ hostId,
274
+ );
275
+ if (!ok || !isRecord(body) || body.name !== input.alias) return errorOf(body, status);
276
+ return { name: input.alias };
277
+ }
278
+
259
279
  /** Changes the role on the session's owning computer. Busy sessions are refused by the host. */
260
280
  export async function setSessionRole(sessionId: string, coordinator: boolean): Promise<{ error: string } | undefined> {
261
281
  return failureOf(await host.session(sessionId).role({ body: { coordinator } }));