@agimon-ai/po-native 0.0.1-alpha.61 → 0.0.1-alpha.63

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.61",
3
+ "version": "0.0.1-alpha.63",
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.181",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.61",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.128",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.181",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.53",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.181",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.181",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.181",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.181",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.181",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.181",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.183",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.63",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.130",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.183",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.55",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.183",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.183",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.183",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.183",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.183",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.183",
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.2",
package/src/app/App.tsx CHANGED
@@ -1447,7 +1447,7 @@ function SettingsPanelRoute({ route }: NativeStackScreenProps<Routes, 'SettingsP
1447
1447
  const navigation = useNavigation<NativeStackNavigationProp<Routes>>();
1448
1448
  const { hostId } = route.params;
1449
1449
  const panel = useSettingsPanels(hostId).find((candidate) => candidate.id === route.params.id);
1450
- const request = hostId === undefined ? requestWithStepUp : apiTransportForHost(hostId);
1450
+ const request = useMemo(() => (hostId === undefined ? requestWithStepUp : apiTransportForHost(hostId)), [hostId]);
1451
1451
  if (!panel) return <EmptyState title="This page is not installed" description="Go back to Settings." />;
1452
1452
  const Panel = panel.component;
1453
1453
  return (
@@ -2379,10 +2379,10 @@ function SessionsRoute({
2379
2379
  if (!canMutate(target.owner)) return unavailable.error;
2380
2380
  const hostId = splitHostId(target.owner)?.hostId;
2381
2381
  const result = actAsCoordinator
2382
- ? await addCoordinator(target.workspaceId, target.hostId, profile)
2382
+ ? await addCoordinator(target.workspaceId, target.hostId, profile, true)
2383
2383
  : target.workspaceId === undefined
2384
- ? await createGeneralSession(target.hostId, undefined, profile)
2385
- : await createWorkspaceSession(target.workspaceId, undefined, profile);
2384
+ ? await createGeneralSession(target.hostId, undefined, profile, true)
2385
+ : await createWorkspaceSession(target.workspaceId, undefined, profile, true);
2386
2386
  if ('error' in result) return result.error;
2387
2387
  if ('workspace' in result && result.workspace) applyWorkspaceUpsert({ workspace: result.workspace }, hostId);
2388
2388
  if ('session' in result && result.session) applySessionUpsert({ session: result.session }, hostId);
@@ -2669,6 +2669,11 @@ function WorkspaceRoute({ workspaceId, hostStates }: { workspaceId: string; host
2669
2669
  const owner = splitHostId(workspaceId);
2670
2670
  const host = hostStates.find((state) => state.host.id === owner?.hostId);
2671
2671
  const calendarHost = useCalendarHostProps(host ? [host] : [], owner?.hostId);
2672
+ const dashboardApi = useMemo(
2673
+ () =>
2674
+ owner ? { key: owner.hostId, workspaceId: owner.localId, request: apiTransportForHost(owner.hostId) } : undefined,
2675
+ [workspaceId],
2676
+ );
2672
2677
  const openWorkspace = useOpenWorkspace(owner?.hostId);
2673
2678
  const { loading, error } = useActivityLoad(owner?.hostId, ['catalog', 'host', `workspace:${workspaceId}`]);
2674
2679
  const state = workspacePageState({ hostStatus: host?.status, workspace, loading, error });
@@ -2690,6 +2695,7 @@ function WorkspaceRoute({ workspaceId, hostStates }: { workspaceId: string; host
2690
2695
  ...nativeSlotProps('', {}, () => undefined),
2691
2696
  sessionId: null,
2692
2697
  workspaceId,
2698
+ dashboardApi,
2693
2699
  ...calendarHost,
2694
2700
  openWorkspace,
2695
2701
  openPage: (pageId) => navigation.navigate('Page', { ...homePageRoute(owner.hostId, pageId), workspaceId }),
@@ -2781,6 +2787,7 @@ function PluginPageRoute({
2781
2787
  : undefined;
2782
2788
  const Page = fill?.component;
2783
2789
  const pageHostId = owner?.hostId ?? (fill ? splitHostId(fill.pluginId)?.hostId : undefined);
2790
+ const request = useMemo(() => (pageHostId === undefined ? undefined : apiTransportForHost(pageHostId)), [pageHostId]);
2784
2791
  const calendarHost = useCalendarHostProps(hostStates, pageHostId);
2785
2792
  const openWorkspace = useOpenWorkspace(pageHostId);
2786
2793
  const richRenderers = useMemo(createRichActivityRenderers, []);
@@ -2789,6 +2796,14 @@ function PluginPageRoute({
2789
2796
  ...nativeSlotProps('', {}, () => undefined, undefined, { ...richRenderers, nativeSaveFile }),
2790
2797
  sessionId: null,
2791
2798
  workspaceId,
2799
+ dashboardApi:
2800
+ pageHostId !== undefined && request
2801
+ ? {
2802
+ key: pageHostId,
2803
+ workspaceId: workspaceId === undefined ? undefined : splitHostId(workspaceId)?.localId,
2804
+ request,
2805
+ }
2806
+ : undefined,
2792
2807
  ...calendarHost,
2793
2808
  openWorkspace,
2794
2809
  detailEventId,
@@ -2815,6 +2830,10 @@ function useHomeApps(
2815
2830
  useSyncExternalStore(subscribeWebPluginRegistry, webPluginRegistryRevision);
2816
2831
  const calendarHost = useCalendarHostProps(hostStates, undefined);
2817
2832
  const openWorkspace = useOpenWorkspace();
2833
+ const dashboardApis = useMemo(
2834
+ () => new Map(hostStates.map(({ host }) => [host.id, { key: host.id, request: apiTransportForHost(host.id) }])),
2835
+ [hostStates],
2836
+ );
2818
2837
  return homeAppEntries(
2819
2838
  hostStates.map(({ host, status }) => ({ ...host, connected: status === 'connected' })),
2820
2839
  (hostId) => {
@@ -2843,6 +2862,7 @@ function useHomeApps(
2843
2862
  const props = {
2844
2863
  ...nativeSlotProps('', {}, () => undefined),
2845
2864
  sessionId: null,
2865
+ dashboardApi: dashboardApis.get(hostId),
2846
2866
  // The card reads the same computers as the page it opens.
2847
2867
  ...calendarHost,
2848
2868
  // A global tile reads a shared backend: give it only its serving computer so it calls once.
@@ -105,7 +105,7 @@ export function createHostRuntimes(
105
105
  options: {
106
106
  changed?: (states: readonly HostRuntimeState[]) => void;
107
107
  activity?: (hostId: string, owner: string, state: ActivityLoadState) => void;
108
- onBundleUpdate?: (host: HostRecord, choice: NativeBundleUpdateChoice) => void;
108
+ onBundleUpdate?: (host: HostRecord | CloudHostRecord, choice: NativeBundleUpdateChoice) => void;
109
109
  } = {},
110
110
  ) {
111
111
  const entries = new Map<string, HostRuntimeEntry>();
@@ -181,6 +181,13 @@ export function createHostRuntimes(
181
181
  reported = next;
182
182
  options.changed?.(next);
183
183
  };
184
+ const offerBundleUpdate = (entry: HostRuntimeEntry, active: () => boolean) => {
185
+ const notify = options.onBundleUpdate;
186
+ if (!notify) return;
187
+ return (choice: NativeBundleUpdateChoice) => {
188
+ if (active()) notify(entry.host, choice);
189
+ };
190
+ };
184
191
  const stopEntry = (entry: HostRuntimeEntry, preserveHost = false) => {
185
192
  entry.controller.abort();
186
193
  for (const [key, operation] of repairs)
@@ -279,6 +286,7 @@ export function createHostRuntimes(
279
286
  entry.pluginCompatibility = issues;
280
287
  changed();
281
288
  },
289
+ onBundleUpdate: offerBundleUpdate(entry, active),
282
290
  onUpdateRequired() {
283
291
  if (!active()) return;
284
292
  entry.status = 'update_required';
@@ -330,7 +338,8 @@ export function createHostRuntimes(
330
338
  changed();
331
339
  return runtime;
332
340
  }
333
- const active = () => !closed && entries.get(host.id) === entry && !forgetting.has(host.id);
341
+ const active = () =>
342
+ !closed && entries.get(host.id) === entry && !entry.controller.signal.aborted && !forgetting.has(host.id);
334
343
  let discovering = false;
335
344
  const discoverComputers = async () => {
336
345
  discovering = true;
@@ -406,6 +415,7 @@ export function createHostRuntimes(
406
415
  entry.pluginCompatibility = issues;
407
416
  changed();
408
417
  },
418
+ onBundleUpdate: offerBundleUpdate(entry, active),
409
419
  onUpdateRequired() {
410
420
  if (!active()) return;
411
421
  entry.status = 'update_required';
@@ -534,9 +544,7 @@ export function createHostRuntimes(
534
544
  entry.pluginCompatibility = issues;
535
545
  changed();
536
546
  },
537
- onBundleUpdate(choice) {
538
- if (active()) options.onBundleUpdate?.(host, choice);
539
- },
547
+ onBundleUpdate: offerBundleUpdate(entry, active),
540
548
  onUpdateRequired() {
541
549
  if (!active()) return;
542
550
  entry.status = 'update_required';
@@ -1,4 +1,5 @@
1
1
  import { PO_VOICE_AUTO_MODE_ID } from '@agimon-ai/po-core/voiceTools';
2
+ import { nativeApiTransport } from '@agimon-ai/po-core/web';
2
3
  import { Button, Input, Sheet, Spinner } from '@agimon-ai/po-native-components';
3
4
  import {
4
5
  answerDialogValue,
@@ -13,6 +14,7 @@ import {
13
14
  selectModel,
14
15
  selectThinkingLevel,
15
16
  sessionStoreFor,
17
+ useBotWake,
16
18
  setPendingMenu,
17
19
  } from '@agimon-ai/po-web-dashboard/core';
18
20
  import { useStore } from '@tanstack/react-store';
@@ -28,13 +30,21 @@ import {
28
30
  SessionOptionRow,
29
31
  sessionChoicesStyles as styles,
30
32
  } from './SessionChoicesView';
33
+ import { WakePeriodView } from './WakePeriodView';
31
34
 
32
35
  export { type SessionChoice, SessionChoicesView, SessionOptionRow } from './SessionChoicesView';
33
36
 
34
37
  /** A domains reply the session accepts as one set, the same payload the cockpit sends. */
35
38
  const DOMAIN_SELECTION = { kind: 'po-domains-selection', version: 1 } as const;
36
39
 
37
- type Page = 'menu' | 'modes' | 'model' | 'thinking' | 'profile' | { axis: string; command: string; multi: boolean };
40
+ type Page =
41
+ | 'menu'
42
+ | 'wake'
43
+ | 'modes'
44
+ | 'model'
45
+ | 'thinking'
46
+ | 'profile'
47
+ | { axis: string; command: string; multi: boolean };
38
48
 
39
49
  export interface SessionOptionsSheetProps {
40
50
  sessionId: string;
@@ -66,6 +76,7 @@ function OpenSessionOptionsSheet({ sessionId, open, onOpenChange }: SessionOptio
66
76
  const claimed = useStore(menuStore, (state) => state.claimed);
67
77
  const [page, setPage] = useState<Page>('menu');
68
78
  const [query, setQuery] = useState('');
79
+ const wake = useBotWake(nativeApiTransport, sessionId, statuses['po-profile']);
69
80
  const matchingModels = useMemo(
70
81
  () =>
71
82
  models.filter((model) =>
@@ -159,6 +170,13 @@ function OpenSessionOptionsSheet({ sessionId, open, onOpenChange }: SessionOptio
159
170
  onPress={() => ask(axis.name, axis.command, axis.multi)}
160
171
  />
161
172
  ))}
173
+ {wake.settings ? (
174
+ <SessionOptionRow
175
+ label="Wake period"
176
+ value={wake.settings ? wake.summary : wake.error || 'Loading…'}
177
+ onPress={wake.settings ? () => setPage('wake') : undefined}
178
+ />
179
+ ) : null}
162
180
  <SessionOptionRow
163
181
  label="Modes"
164
182
  value={`${String(modes.filter((mode) => mode.availability === 'on').length)} on`}
@@ -230,6 +248,33 @@ function OpenSessionOptionsSheet({ sessionId, open, onOpenChange }: SessionOptio
230
248
  if (whenConnected(sessionId, () => selectThinkingLevel(level, sessionId))) onOpenChange(false);
231
249
  else setPage('menu');
232
250
  };
251
+ } else if (page === 'wake') {
252
+ return (
253
+ <Sheet open={open} onOpenChange={close}>
254
+ {wake.settings ? (
255
+ <WakePeriodView
256
+ summary={wake.summary}
257
+ help={
258
+ wake.inheritedLabel && wake.inheritedSource === 'Profile'
259
+ ? `15 minutes to 7 days. Your profile uses ${wake.inheritedLabel}.`
260
+ : '15 minutes to 7 days.'
261
+ }
262
+ minutes={wake.minutes}
263
+ override={wake.settings.overrideMs !== undefined}
264
+ busy={wake.busy}
265
+ error={wake.error}
266
+ save={wake.save}
267
+ onBack={back}
268
+ />
269
+ ) : (
270
+ <SessionChoicesView
271
+ title="Wake period"
272
+ onBack={back}
273
+ header={<Text style={styles.meta}>{wake.error || 'Loading wake period…'}</Text>}
274
+ />
275
+ )}
276
+ </Sheet>
277
+ );
233
278
  } else if (claimedDialog === null) {
234
279
  body = (
235
280
  <View style={styles.waiting}>
@@ -0,0 +1,85 @@
1
+ import { Button, Input, Label, fontOf } from '@agimon-ai/po-native-components';
2
+ import { parseWakeMinutes } from '@agimon-ai/po-web-dashboard/core';
3
+ import { useState } from 'react';
4
+ import { Text, View } from 'react-native';
5
+ import { StyleSheet } from 'react-native-unistyles';
6
+
7
+ import { SessionChoicesView, sessionChoicesStyles } from './SessionChoicesView';
8
+
9
+ export function WakePeriodView({
10
+ summary,
11
+ help,
12
+ minutes,
13
+ override,
14
+ busy = false,
15
+ error,
16
+ save,
17
+ onBack,
18
+ }: {
19
+ summary: string;
20
+ help: string;
21
+ minutes: number;
22
+ override: boolean;
23
+ busy?: boolean;
24
+ error?: string;
25
+ save: (ms: number | null) => Promise<boolean>;
26
+ onBack: () => void;
27
+ }) {
28
+ const [draft, setDraft] = useState(String(minutes));
29
+ const value = parseWakeMinutes(draft);
30
+ const message = value === undefined ? 'Enter a whole number from 15 to 10,080.' : error;
31
+ const apply = async (ms: number | null) => {
32
+ if (await save(ms)) onBack();
33
+ };
34
+ return (
35
+ <SessionChoicesView
36
+ title="Wake period"
37
+ onBack={busy ? undefined : onBack}
38
+ header={
39
+ <View style={styles.stack}>
40
+ <Text style={sessionChoicesStyles.meta}>{summary}</Text>
41
+ <Text style={sessionChoicesStyles.meta}>
42
+ How far ahead Po looks for scheduled work. This does not change when events run.
43
+ </Text>
44
+ <Label>Period (minutes)</Label>
45
+ <Input
46
+ accessibilityLabel="Period (minutes)"
47
+ keyboardType="number-pad"
48
+ value={draft}
49
+ onChangeText={setDraft}
50
+ disabled={busy}
51
+ />
52
+ <Text style={sessionChoicesStyles.meta}>{help}</Text>
53
+ {message ? (
54
+ <Text style={styles.error} accessibilityRole="alert">
55
+ {message}
56
+ </Text>
57
+ ) : null}
58
+ </View>
59
+ }
60
+ footer={
61
+ <View style={styles.stack}>
62
+ <Button
63
+ variant="primary"
64
+ disabled={busy || value === undefined}
65
+ onPress={() => {
66
+ if (value !== undefined) void apply(value);
67
+ }}
68
+ >
69
+ Save
70
+ </Button>
71
+ {override ? (
72
+ <Button variant="ghost" disabled={busy} onPress={() => void apply(null)}>
73
+ Reset to profile
74
+ </Button>
75
+ ) : null}
76
+ </View>
77
+ }
78
+ />
79
+ );
80
+ }
81
+
82
+ const styles = StyleSheet.create((theme) => ({
83
+ stack: { gap: theme.spacing(3) },
84
+ error: { color: theme.colors.red, fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm },
85
+ }));
@@ -29,6 +29,7 @@ import {
29
29
  sessionChoicesStyles,
30
30
  SessionOptionRow,
31
31
  } from '../components/SessionChoicesView';
32
+ import { WakePeriodView } from '../components/WakePeriodView';
32
33
  import { type DesignScheme, PhoneFrame } from './designFrame';
33
34
 
34
35
  const noop = () => undefined;
@@ -633,6 +634,58 @@ export const ModelLongLabels = { render: () => <ModelTarget long /> };
633
634
  export const Options = { render: () => <ModelTarget menu /> };
634
635
  export const OptionsLight = { render: () => <ModelTarget scheme="light" menu /> };
635
636
  export const ProfileReady = { render: () => <ProfileTarget /> };
637
+
638
+ function WakePeriodTarget({
639
+ scheme = 'dark',
640
+ editing = false,
641
+ failed = false,
642
+ }: {
643
+ scheme?: DesignScheme;
644
+ editing?: boolean;
645
+ failed?: boolean;
646
+ }) {
647
+ const [open, setOpen] = useState(editing);
648
+ const [override, setOverride] = useState<number | undefined>(editing ? 360 : undefined);
649
+ return (
650
+ <SheetStage scheme={scheme} list>
651
+ {open ? (
652
+ <WakePeriodView
653
+ summary={override === undefined ? '2 hours · Profile' : `${override / 60} hours · Session override`}
654
+ help="15 minutes to 7 days. Your profile uses 2 hours."
655
+ minutes={override ?? 120}
656
+ override={override !== undefined}
657
+ error={failed ? 'The period was not saved. Try again.' : undefined}
658
+ save={async (ms) => {
659
+ if (failed) return false;
660
+ setOverride(ms === null ? undefined : ms / 60_000);
661
+ return true;
662
+ }}
663
+ onBack={() => setOpen(false)}
664
+ />
665
+ ) : (
666
+ <SessionChoicesView
667
+ title="Session options"
668
+ header={
669
+ <View style={sessionChoicesStyles.list}>
670
+ <SessionOptionRow first label="Preset" value="Copilot" />
671
+ <SessionOptionRow label="Profile" value="Account manager" />
672
+ <SessionOptionRow
673
+ label="Wake period"
674
+ value={override === undefined ? '2 hours · Profile' : `${override} min · Override`}
675
+ onPress={() => setOpen(true)}
676
+ />
677
+ </View>
678
+ }
679
+ />
680
+ )}
681
+ </SheetStage>
682
+ );
683
+ }
684
+
685
+ export const WakePeriod = { render: () => <WakePeriodTarget /> };
686
+ export const WakePeriodEdit = { render: () => <WakePeriodTarget editing /> };
687
+ export const WakePeriodEditLight = { render: () => <WakePeriodTarget editing scheme="light" /> };
688
+ export const WakePeriodError = { render: () => <WakePeriodTarget editing failed /> };
636
689
  export const ProfileLight = { render: () => <ProfileTarget scheme="light" /> };
637
690
  export const ProfileLoading = { render: () => <ProfileTarget state="loading" /> };
638
691
  export const ProfilePartial = { render: () => <ProfileTarget state="partial" /> };
@@ -84,10 +84,11 @@ export async function createWorkspaceSession(
84
84
  workspaceId: string,
85
85
  name?: string,
86
86
  profile?: string,
87
+ bot?: true,
87
88
  ): Promise<Result<{ sessionId: string; session?: SessionSummary }>> {
88
- const result = await host
89
- .workspace(workspaceId)
90
- .createSession({ body: { name, ...(profile === undefined ? {} : { selection: { profile } }) } });
89
+ const result = await host.workspace(workspaceId).createSession({
90
+ body: { name, ...(profile === undefined ? {} : { selection: { profile } }), ...(bot === undefined ? {} : { bot }) },
91
+ });
91
92
  const body = result.data;
92
93
  if (!result.ok || !isRecord(body) || typeof body.sessionId !== 'string') return errorOf(body, result.status);
93
94
  const session = await sessionDetail(workspaceId, body.sessionId);
@@ -141,13 +142,18 @@ export async function createGeneralSession(
141
142
  hostId: string,
142
143
  name?: string,
143
144
  profile?: string,
145
+ bot?: true,
144
146
  ): Promise<Result<{ sessionId: string; session?: SessionSummary; workspace?: WorkspaceSummary }>> {
145
147
  const { ok, body, status } = await rootRequest(
146
148
  '/api/sessions',
147
149
  {
148
150
  method: 'POST',
149
151
  headers: { 'content-type': 'application/json' },
150
- body: JSON.stringify({ name, ...(profile === undefined ? {} : { selection: { profile } }) }),
152
+ body: JSON.stringify({
153
+ name,
154
+ ...(profile === undefined ? {} : { selection: { profile } }),
155
+ ...(bot === undefined ? {} : { bot }),
156
+ }),
151
157
  },
152
158
  hostId,
153
159
  );
@@ -234,6 +240,7 @@ export async function addCoordinator(
234
240
  workspaceId?: string,
235
241
  hostId?: string,
236
242
  profile?: string,
243
+ bot?: true,
237
244
  ): Promise<{ sessionId: string; created: boolean } | { error: string; profileRequired?: true }> {
238
245
  const owner = workspaceId === undefined ? undefined : splitHostId(workspaceId);
239
246
  if (owner && hostId !== undefined && owner.hostId !== hostId)
@@ -246,6 +253,7 @@ export async function addCoordinator(
246
253
  body: JSON.stringify({
247
254
  ...(workspaceId === undefined ? {} : { workspaceId: owner?.localId ?? workspaceId }),
248
255
  ...(profile === undefined ? {} : { profile }),
256
+ ...(bot === undefined ? {} : { bot }),
249
257
  }),
250
258
  },
251
259
  owner?.hostId ?? hostId,