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

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.60",
3
+ "version": "0.0.1-alpha.61",
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.180",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.60",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.127",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.180",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.52",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.180",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.180",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.180",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.180",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.180",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.180",
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",
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
@@ -484,11 +484,12 @@ function HostDrawerRoute({
484
484
  <HostDrawer
485
485
  {...props}
486
486
  {...(menu ? { menu } : {})}
487
- hosts={hostStates.map(({ host, status }) => ({
487
+ hosts={hostStates.map(({ host, status, closedAtLimit }) => ({
488
488
  id: host.id,
489
489
  label: hostDisplayName(host),
490
490
  address: new URL(host.origin).host,
491
491
  online: status === 'connected' || status === 'update_required',
492
+ ...(closedAtLimit ? { closedAtLimit: true } : {}),
492
493
  waiting: owners.filter((owner) => owner === host.id).length,
493
494
  }))}
494
495
  />
@@ -75,6 +75,8 @@ export interface HostRuntimeState {
75
75
  pluginCompatibility?: readonly PluginCompatibility[];
76
76
  /** A paired computer its own connection cannot reach, running through Po Cloud for now. */
77
77
  via?: 'cloud';
78
+ /** ISO 8601, while offline: the computer closed remote access at its own time limit, as Cloud last heard. */
79
+ closedAtLimit?: string;
78
80
  }
79
81
 
80
82
  interface HostRuntimeEntry extends HostRuntimeState {
@@ -93,7 +95,8 @@ function sameHostState(left: HostRuntimeState, right: HostRuntimeState): boolean
93
95
  left.error === right.error &&
94
96
  left.linkError === right.linkError &&
95
97
  left.pluginCompatibility === right.pluginCompatibility &&
96
- left.via === right.via
98
+ left.via === right.via &&
99
+ left.closedAtLimit === right.closedAtLimit
97
100
  );
98
101
  }
99
102
 
@@ -147,7 +150,23 @@ export function createHostRuntimes(
147
150
  const next = [...entries.values()]
148
151
  .filter((entry) => !entry.standby)
149
152
  .map(({ host, status, runtime, error, linkError, pluginCompatibility, via }) => {
150
- const state = { host, status, runtime, error, linkError, pluginCompatibility, ...(via ? { via } : {}) };
153
+ // A paired computer's reason comes from its own Cloud listing, which stands by behind it.
154
+ const closedAtLimit =
155
+ status === 'connected'
156
+ ? undefined
157
+ : isCloudHost(host)
158
+ ? host.closedAtLimit
159
+ : cloudTwin(host.signer.publicKey)?.host.closedAtLimit;
160
+ const state = {
161
+ host,
162
+ status,
163
+ runtime,
164
+ error,
165
+ linkError,
166
+ pluginCompatibility,
167
+ ...(via ? { via } : {}),
168
+ ...(closedAtLimit ? { closedAtLimit } : {}),
169
+ };
151
170
  const previous = reported.find((candidate) => candidate.host.id === host.id);
152
171
  return previous && sameHostState(previous, state) ? previous : state;
153
172
  });
@@ -278,6 +297,8 @@ export function createHostRuntimes(
278
297
  const trusted = await reconnect(host.origin, transport?.fetch ?? nativeFetch, {
279
298
  hostId: host.id,
280
299
  signal: entry.controller.signal,
300
+ // One try per tick, so a slow computer never stacks retries while Cloud carries it.
301
+ giveUp: () => true,
281
302
  });
282
303
  if (!active()) throw new Error('The host connection was replaced.');
283
304
  if (transport) trusted.lanTransport = transport;
@@ -328,7 +349,11 @@ export function createHostRuntimes(
328
349
  continue;
329
350
  const latest = computers.find(({ id }) => id === existing.id);
330
351
  if (!latest || latest.computer?.generation !== existing.computer.generation) dropCloudEntry(candidate);
331
- else if (latest.label !== existing.label || latest.computer?.publicKey !== existing.computer.publicKey) {
352
+ else if (
353
+ latest.label !== existing.label ||
354
+ latest.closedAtLimit !== existing.closedAtLimit ||
355
+ latest.computer?.publicKey !== existing.computer.publicKey
356
+ ) {
332
357
  // A newly listed bundle signer moves the computer onto the full runtime.
333
358
  if (latest.computer?.publicKey !== existing.computer.publicKey) connectCloud(latest, false);
334
359
  else {
@@ -468,6 +493,8 @@ export function createHostRuntimes(
468
493
  reconnect(host.origin, transport?.fetch ?? nativeFetch, {
469
494
  hostId: host.id,
470
495
  signal: entry.controller.signal,
496
+ // With the same computer listed in Cloud, one failed try is enough: Cloud carries it at once.
497
+ giveUp: () => cloudTwin(host.signer.publicKey) !== undefined,
471
498
  }).then((trusted) => {
472
499
  if (!active()) throw new Error('The host connection was replaced.');
473
500
  if (transport) trusted.lanTransport = transport;
@@ -19,6 +19,8 @@ export interface DrawerHost {
19
19
  label: string;
20
20
  address: string;
21
21
  online: boolean;
22
+ /** Offline because remote access reached its time limit on the computer: its owner's setting, not a failure. */
23
+ closedAtLimit?: boolean;
22
24
  /** Sessions on this host waiting for the person. */
23
25
  waiting: number;
24
26
  }
@@ -102,7 +104,7 @@ export function HostDrawer({ open, onClose, hosts, scope, onScope, onAdd, onMana
102
104
  </View>
103
105
  }
104
106
  title={host.label}
105
- detail={`${host.address} · ${host.online ? 'Connected' : 'Offline'}`}
107
+ detail={`${host.address} · ${host.online ? 'Connected' : host.closedAtLimit ? 'Turned off at its time limit' : 'Offline'}`}
106
108
  count={host.waiting}
107
109
  onPress={() => choose(host.id)}
108
110
  />
@@ -31,6 +31,8 @@ export interface CloudHostRecord {
31
31
  * lists one, lets the phone check that computer's plugins and run it as it runs a paired computer.
32
32
  */
33
33
  computer?: { hostId: string; generation: number; publicKey?: string };
34
+ /** ISO 8601, when Cloud last heard this computer close remote access at its own time limit. Only while it is offline. */
35
+ closedAtLimit?: string;
34
36
  }
35
37
 
36
38
  export function isCloudHost(host: object): host is CloudHostRecord {
@@ -110,10 +112,15 @@ function cloudHostOf(value: unknown): CloudHostRecord | undefined {
110
112
  ...(isRecord(value.hosted) && typeof value.hosted.apiPrefix === 'string' && API_PREFIX.test(value.hosted.apiPrefix)
111
113
  ? { hosted: { apiPrefix: value.hosted.apiPrefix } }
112
114
  : {}),
113
- ...(computer ? { computer } : {}),
115
+ ...(computer ? { computer, ...closedAtLimitOf(value) } : {}),
114
116
  };
115
117
  }
116
118
 
119
+ const closedAtLimitOf = (value: Record<string, unknown>): { closedAtLimit?: string } =>
120
+ typeof value.closedAtLimit === 'string' && Number.isFinite(Date.parse(value.closedAtLimit))
121
+ ? { closedAtLimit: value.closedAtLimit }
122
+ : {};
123
+
117
124
  let writes: Promise<unknown> = Promise.resolve();
118
125
  function serialize<T>(run: () => Promise<T>): Promise<T> {
119
126
  const next = writes.then(run);
@@ -228,6 +235,7 @@ export function syncCloudComputers(cloud: CloudHostRecord, listing: unknown): Pr
228
235
  networkId: cloud.networkId,
229
236
  hosted: cloud.hosted,
230
237
  computer,
238
+ ...closedAtLimitOf(item),
231
239
  };
232
240
  });
233
241
  if (JSON.stringify(records) !== JSON.stringify(previous))
@@ -485,7 +485,10 @@ export async function register(input: {
485
485
  */
486
486
  class DeviceSignInError extends Error {}
487
487
 
488
- /** Five fresh challenges over about a minute, including an eight-second final attempt budget. */
488
+ /**
489
+ * Five fresh challenges over about a minute, including an eight-second final attempt budget. `giveUp` is asked after
490
+ * each failed attempt: true ends the retries there, for a caller with another way to reach the same computer.
491
+ */
489
492
  export async function reconnect(
490
493
  origin: string,
491
494
  fetcher: typeof fetch,
@@ -496,6 +499,7 @@ export async function reconnect(
496
499
  relay?: boolean;
497
500
  retain?: false;
498
501
  signal?: AbortSignal;
502
+ giveUp?: () => boolean;
499
503
  } = {},
500
504
  ): Promise<TrustedSession> {
501
505
  const started = Date.now();
@@ -531,6 +535,7 @@ export async function reconnect(
531
535
  isRelayTrustError(error) ||
532
536
  error instanceof DeviceSignInError ||
533
537
  options.signal?.aborted ||
538
+ options.giveUp?.() === true ||
534
539
  attempt === attemptsAt.length - 1
535
540
  )
536
541
  throw error;