@agimon-ai/po-native 0.0.1-alpha.79 → 0.0.1-alpha.80

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.79",
3
+ "version": "0.0.1-alpha.80",
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.199",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.79",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.146",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.199",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.71",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.199",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.199",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.199",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.199",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.199",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.199",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.200",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.80",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.147",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.200",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.72",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.200",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.200",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.200",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.200",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.200",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.200",
43
43
  "@better-auth/expo": "1.7.12",
44
44
  "@config-plugins/react-native-webrtc": "15.0.2",
45
45
  "@earendil-works/chord": "1.6.1",
package/src/app/App.tsx CHANGED
@@ -261,6 +261,7 @@ import {
261
261
  stopSession,
262
262
  uploadSessionAttachment,
263
263
  } from '../services/hostActions';
264
+ import { hostOwnerKey } from '../services/hostModules';
264
265
  import { calendarSnapshots } from '../services/hostSnapshots';
265
266
  import { useSessionActivity } from '../services/liveActivity';
266
267
  import { recordNativeLog } from '../services/logExport';
@@ -2943,8 +2944,9 @@ const HomeTiles = memo(function HomeTiles({ hostStates }: { hostStates: readonly
2943
2944
  });
2944
2945
 
2945
2946
  /**
2946
- * Plugin `home-attention` fills, drawn once per plugin fill rather than once per computer: the plugin
2947
- * module and its store are shared, and its cards already carry host-qualified session ids.
2947
+ * Plugin `home-attention` fills, drawn once per plugin for each owner's computers rather than once per
2948
+ * computer: a fill gathers its owner's computers itself (approvals read every one into one queue), and
2949
+ * another person's linked computer keeps its own.
2948
2950
  */
2949
2951
  const HomeAttentionFills = memo(function HomeAttentionFills({
2950
2952
  hostStates,
@@ -2959,11 +2961,16 @@ const HomeAttentionFills = memo(function HomeAttentionFills({
2959
2961
  webPluginRegistryForHost(host.id)
2960
2962
  .hostSlotFills(HOST_SLOTS.homeAttention)
2961
2963
  .filter((fill) => {
2962
- const key = JSON.stringify([splitHostId(fill.pluginId)?.localId ?? fill.pluginId, fill.id]);
2964
+ const key = JSON.stringify([
2965
+ splitHostId(fill.pluginId)?.localId ?? fill.pluginId,
2966
+ fill.id,
2967
+ host.id === undefined ? '' : hostOwnerKey(host.id),
2968
+ ]);
2963
2969
  if (fill.component === undefined || seen.has(key)) return false;
2964
2970
  seen.add(key);
2965
2971
  return true;
2966
- }),
2972
+ })
2973
+ .map((fill) => ({ fill, key: `${fill.pluginId}:${fill.id}` })),
2967
2974
  );
2968
2975
  if (fills.length === 0) return null;
2969
2976
  const props = {
@@ -2972,10 +2979,10 @@ const HomeAttentionFills = memo(function HomeAttentionFills({
2972
2979
  };
2973
2980
  return (
2974
2981
  <>
2975
- {fills.map((fill) => {
2982
+ {fills.map(({ fill, key }) => {
2976
2983
  const Card = fill.component as ComponentType<typeof props>;
2977
2984
  return (
2978
- <ToolRendererBoundary key={`${fill.pluginId}:${fill.id}`} toolName={fill.id}>
2985
+ <ToolRendererBoundary key={key} toolName={fill.id}>
2979
2986
  {(failed) => (failed ? null : <Card {...props} />)}
2980
2987
  </ToolRendererBoundary>
2981
2988
  );
@@ -74,7 +74,7 @@ import {
74
74
  } from '../services/bundleUpdates';
75
75
  import { type Connection, createConnection } from '../services/connection';
76
76
  import { fetchWithStepUp, type HostRecord, type TrustedSession } from '../services/deviceTrust';
77
- import { hostModules, hostModulesForHost } from '../services/hostModules';
77
+ import { hostModules, hostModulesForHost, noteHostOwner } from '../services/hostModules';
78
78
  import { hostSnapshots, type HostSnapshot } from '../services/hostSnapshots';
79
79
  import { bindNativeLogSend } from '../services/logExport';
80
80
  import { createPluginRuntime, type PluginCompatibility } from '../services/pluginRuntime';
@@ -222,6 +222,8 @@ function createHostPlugins(host: HostRecord): HostPlugins {
222
222
  /** The kept plugins of a paired computer, replaced when its signer changed. A legacy record keeps none. */
223
223
  function hostPluginsFor(host: HostRecord): HostPlugins {
224
224
  if (host.id === undefined) return createHostPlugins(host);
225
+ // Every start, so a computer linked to an account after pairing joins that person's computers.
226
+ noteHostOwner(host.id, host.person);
225
227
  const previous = keptPlugins.get(host.id);
226
228
  if (previous?.signer === host.signer.publicKey) return previous;
227
229
  if (previous) stopHostPlugins(previous);
@@ -1,4 +1,6 @@
1
1
  import * as nativeCore from '@agimon-ai/po-core/native';
2
+ import type { WebPluginRuntime } from '@agimon-ai/po-core/native';
3
+ import { localHostId, qualifyHostId, transportForHost as hubTransportForHost } from '@agimon-ai/po-web-dashboard/core';
2
4
 
3
5
  // Binds po-core's nativeApiTransport before the map below can hand po-core/native to a composition.
4
6
  import { apiTransportForHost, transportForHost } from '../apiTransport';
@@ -70,9 +72,50 @@ export const hostModules: HostModules = Object.freeze(
70
72
  );
71
73
 
72
74
  const hostMaps = new Map<string, Map<string, HostModules>>();
75
+ /** Who owns each paired computer, as its pairing record says; undefined for an unlinked computer. */
76
+ const hostOwners = new Map<string, { issuer: string; subject: string } | undefined>();
73
77
 
74
78
  export function forgetHostModules(hostId: string): void {
75
79
  hostMaps.delete(hostId);
80
+ hostOwners.delete(hostId);
81
+ }
82
+
83
+ export function noteHostOwner(hostId: string, person: { issuer: string; subject: string } | undefined): void {
84
+ hostOwners.set(hostId, person);
85
+ }
86
+
87
+ /**
88
+ * Space's owner rule (computersOfOwner): linked computers group by person; unlinked ones join the
89
+ * phone's one account, or each other when the phone holds several.
90
+ */
91
+ export function hostOwnerKey(hostId: string): string {
92
+ const person = hostOwners.get(hostId);
93
+ if (person) return JSON.stringify(person);
94
+ const people = new Set([...hostOwners.values()].flatMap((entry) => (entry ? [JSON.stringify(entry)] : [])));
95
+ return people.size === 1 ? [...people][0]! : 'unlinked';
96
+ }
97
+
98
+ /**
99
+ * Hub method access to every computer with the same owner as `hostId`, itself included, so one Home card
100
+ * can gather and answer that person's requests. Another person's computer is never offered.
101
+ */
102
+ function ownComputerRuntimes(hostId: string) {
103
+ const owner = hostOwnerKey(hostId);
104
+ return [...hostOwners.keys()]
105
+ .filter((id) => hostOwnerKey(id) === owner)
106
+ .map((id) => ({
107
+ hostId: id,
108
+ runtime: {
109
+ // Checked again per call: a computer linked to someone else since this list was read is refused.
110
+ invokeServerMethod: (call: Parameters<WebPluginRuntime['invokeServerMethod']>[0]) =>
111
+ hostOwnerKey(id) === hostOwnerKey(hostId)
112
+ ? hubTransportForHost(id).invokeServerMethod(call)
113
+ : Promise.reject(new Error('This computer belongs to another person.')),
114
+ onHubConnected: (listener: () => void) => hubTransportForHost(id).onHubConnected(listener),
115
+ qualifySessionId: (sessionId: string) => qualifyHostId(id, localHostId(id, sessionId)),
116
+ localSessionId: (sessionId: string) => localHostId(id, sessionId),
117
+ },
118
+ }));
76
119
  }
77
120
 
78
121
  /**
@@ -92,6 +135,8 @@ export function hostModulesForHost(hostId: string, signerPublicKey: string): Hos
92
135
  transportForHost,
93
136
  calendarTargetsForSession,
94
137
  hostRevisionTopic: (name: string, host: string = hostId) => nativeCore.hostRevisionTopic(name, host),
138
+ // Read at call time: the owner list changes as computers pair, link and leave.
139
+ ownComputerRuntimes: () => ownComputerRuntimes(hostId),
95
140
  },
96
141
  }),
97
142
  );