@agimon-ai/po-native 0.0.1-alpha.26 → 0.0.1-alpha.27

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/README.md CHANGED
@@ -9,7 +9,7 @@ The app pairs with one Po host over its remote-access tunnel, lists that host's
9
9
  - **Pairing.** Scan the host's pairing QR with the camera, or paste the URL. The host approves the request on its own screen. The app then registers device keys (see the trust model) and keeps the host record.
10
10
  - **Connection.** Remote HTTP with the device cookie, three sealed channels (session, protocol, HTTP), the Pi `Client` over the protocol socket, and the hub socket. A dropped hub signs in again with the device key and rebuilds the connection.
11
11
  - **Session state.** `@agimon-ai/po-web-dashboard/core` supplies the session, transcript, and plugin registry stores, the same ones the browser cockpit uses, without any DOM dependency.
12
- - **Plugins.** The host advertises native compositions through `nativeGlobal` and `workspaces[].nativeComposition` on `/api/compositions` and `nativeComposition` on a session summary. For each mount the app loads the composition through its verified cache, evaluates it, keeps only the plugin ids the descriptor admits, installs them in the plugin registry, and starts them. Channel frames reach plugins through `dispatchChannelFrame`. A newer load for a mount makes older ones stale.
12
+ - **Plugins.** The host advertises native compositions through `nativeHost` and `workspaces[].nativeComposition` on `/api/compositions` and `nativeComposition` on a session summary. For each mount the app loads the composition through its verified cache, evaluates it, keeps only the plugin ids the descriptor admits, installs them in the plugin registry, and starts them. Channel frames reach plugins through `dispatchChannelFrame`. A newer load for a mount makes older ones stale.
13
13
  - **Navigation.** `App` registers screens by phase (reconnecting, pairing, ready) in a React Navigation native stack, inside `SafeAreaProvider > PoNativeProvider > KeyboardProvider > NavigationContainer`. Native headers own back navigation and swipe back; Sessions has a large title and a Settings action. A session opens in the live runtime on focus and closes on blur; Settings reloads trusted devices on focus.
14
14
  - **Lists and content.** Sessions and transcripts use the component library's FlashList-backed `List`; the transcript uses `startAtBottom`. Assistant text uses `Markdown`; tool entries use the plugin `sessionToolRenderer`, falling back to `MessageItem` and `CodeBlock`.
15
15
  - **Sheets.** `PoNativeProvider` supplies the shared gesture root and bottom sheet host for plugin detail sheets and action menus. The composer's decision prompts stay inline as gentle rose panels, not modal sheets. `SettingsScreen` lists trusted devices, revokes one through biometric step-up, and forgets the host.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-native",
3
- "version": "0.0.1-alpha.26",
3
+ "version": "0.0.1-alpha.27",
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.146",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.26",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.93",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.146",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.18",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.146",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.146",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.146",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.146",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.146",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.146",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.147",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.27",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.94",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.147",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.19",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.147",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.147",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.147",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.147",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.147",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.147",
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.1",
package/src/app/App.tsx CHANGED
@@ -88,9 +88,9 @@ import {
88
88
  webPluginRegistryForHost,
89
89
  parseDashboardTileData,
90
90
  HOST_SLOTS,
91
- globalSlotFills,
91
+ hostSlotFills,
92
92
  webPluginRegistryRevision,
93
- globalPluginProviders,
93
+ hostPluginProviders,
94
94
  setUiTraceSink,
95
95
  traceStore,
96
96
  useRenderTrace,
@@ -2183,7 +2183,7 @@ const HomeAttentionFills = memo(function HomeAttentionFills({
2183
2183
  const seen = new Set<string>();
2184
2184
  const fills = hostStates.flatMap(({ host }) =>
2185
2185
  webPluginRegistryForHost(host.id)
2186
- .globalSlotFills(HOST_SLOTS.homeAttention)
2186
+ .hostSlotFills(HOST_SLOTS.homeAttention)
2187
2187
  .filter((fill) => {
2188
2188
  const key = JSON.stringify([splitHostId(fill.pluginId)?.localId ?? fill.pluginId, fill.id]);
2189
2189
  if (fill.component === undefined || seen.has(key)) return false;
@@ -2295,7 +2295,7 @@ function WorkspaceRoute({ workspaceId, hostStates }: { workspaceId: string; host
2295
2295
  const fills = (slot: string) =>
2296
2296
  [
2297
2297
  ...new Map(
2298
- [...registry.globalSlotFills(slot), ...registry.workspaceSlotFills(workspaceId, slot)].map((fill) => [
2298
+ [...registry.hostSlotFills(slot), ...registry.workspaceSlotFills(workspaceId, slot)].map((fill) => [
2299
2299
  JSON.stringify([fill.pluginId, fill.id]),
2300
2300
  fill,
2301
2301
  ]),
@@ -2394,7 +2394,7 @@ function PluginPageRoute({
2394
2394
  const fill = scopeMatches
2395
2395
  ? [
2396
2396
  ...(registry && workspaceId ? registry.workspaceSlotFills(workspaceId, HOST_SLOTS.page) : []),
2397
- ...(registry?.globalSlotFills(HOST_SLOTS.page) ?? globalSlotFills(HOST_SLOTS.page)),
2397
+ ...(registry?.hostSlotFills(HOST_SLOTS.page) ?? hostSlotFills(HOST_SLOTS.page)),
2398
2398
  ].find((fill) => fill.id === (owner?.localId ?? pageId))
2399
2399
  : undefined;
2400
2400
  const Page = fill?.component;
@@ -2490,7 +2490,7 @@ function useHomeApps(
2490
2490
  const target = data.open;
2491
2491
  const canOpen =
2492
2492
  target?.kind === 'page'
2493
- ? registry.globalSlotFills(HOST_SLOTS.page).some((candidate) => candidate.id === target.id)
2493
+ ? registry.hostSlotFills(HOST_SLOTS.page).some((candidate) => candidate.id === target.id)
2494
2494
  : target?.kind === 'settings' &&
2495
2495
  (['providers', 'mcp', 'workspaces'].includes(target.id) ||
2496
2496
  registry.pluginSettingsPanels().some((candidate) => candidate.id === target.id));
@@ -2589,11 +2589,11 @@ function ConnectFirst({ restore }: { restore?: { onRestore: () => void; busy: bo
2589
2589
  );
2590
2590
  }
2591
2591
 
2592
- type GlobalProviders = ReturnType<typeof globalPluginProviders>;
2593
- let providerList: GlobalProviders = [];
2592
+ type HostProviders = ReturnType<typeof hostPluginProviders>;
2593
+ let providerList: HostProviders = [];
2594
2594
  /** The same list until a provider really changes, so unrelated registry changes never re-render the app root. */
2595
- function currentGlobalProviders(): GlobalProviders {
2596
- const next = globalPluginProviders();
2595
+ function currentHostProviders(): HostProviders {
2596
+ const next = hostPluginProviders();
2597
2597
  const same =
2598
2598
  next.length === providerList.length &&
2599
2599
  next.every(
@@ -2608,8 +2608,8 @@ function currentGlobalProviders(): GlobalProviders {
2608
2608
  * Plugin providers sit above the sheet host so sheet content sees them, and below the navigation and keyboard
2609
2609
  * containers so a provider arriving re-mounts the navigators without losing navigation state or keyboard tracking.
2610
2610
  */
2611
- function GlobalPluginProviders({ children }: { children: ReactNode }) {
2612
- const providers = useSyncExternalStore(subscribeWebPluginRegistry, currentGlobalProviders);
2611
+ function HostPluginProviders({ children }: { children: ReactNode }) {
2612
+ const providers = useSyncExternalStore(subscribeWebPluginRegistry, currentHostProviders);
2613
2613
  return providers.reduceRight<ReactNode>(
2614
2614
  (content, { pluginId, provider: Provider }) => <Provider key={pluginId}>{content}</Provider>,
2615
2615
  <PoNativeProvider>{children}</PoNativeProvider>,
@@ -2982,7 +2982,7 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
2982
2982
  // A pushed or switched screen has no field for the keyboard left open on the one behind.
2983
2983
  onStateChange={() => Keyboard.dismiss()}
2984
2984
  >
2985
- <GlobalPluginProviders>
2985
+ <HostPluginProviders>
2986
2986
  <Stack.Navigator screenOptions={stackOptions}>
2987
2987
  <Stack.Screen name="Tabs" options={{ headerShown: false }}>
2988
2988
  {() => (
@@ -3329,7 +3329,7 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
3329
3329
  onAdd={() => navigation.navigate('AddHost')}
3330
3330
  onManage={() => navigation.navigate('Hosts')}
3331
3331
  />
3332
- </GlobalPluginProviders>
3332
+ </HostPluginProviders>
3333
3333
  </NavigationContainer>
3334
3334
  </KeyboardProvider>
3335
3335
  ) : null}
@@ -12,7 +12,7 @@ import { StyleSheet, View } from 'react-native';
12
12
 
13
13
  import type { HostRuntimeState } from './hostRuntimes';
14
14
 
15
- type BackdropFill = ReturnType<ReturnType<typeof webPluginRegistryForHost>['globalSlotFills']>[number];
15
+ type BackdropFill = ReturnType<ReturnType<typeof webPluginRegistryForHost>['hostSlotFills']>[number];
16
16
 
17
17
  /**
18
18
  * The `backdrop` fills of the person's computers, once per plugin fill: the same plugin on two
@@ -23,7 +23,7 @@ export function useBackdropFills(hostStates: readonly HostRuntimeState[]): reado
23
23
  const seen = new Set<string>();
24
24
  return hostStates.flatMap(({ host }) =>
25
25
  webPluginRegistryForHost(host.id)
26
- .globalSlotFills(HOST_SLOTS.backdrop)
26
+ .hostSlotFills(HOST_SLOTS.backdrop)
27
27
  .filter((fill) => {
28
28
  const key = JSON.stringify([splitHostId(fill.pluginId)?.localId ?? fill.pluginId, fill.id]);
29
29
  if (fill.component === undefined || seen.has(key)) return false;
@@ -137,7 +137,7 @@ export function createHostRuntimes(
137
137
  reported = next;
138
138
  options.changed?.(next);
139
139
  };
140
- const stopEntry = (entry: HostRuntimeEntry, preserveGlobal = false) => {
140
+ const stopEntry = (entry: HostRuntimeEntry, preserveHost = false) => {
141
141
  entry.controller.abort();
142
142
  for (const [key, operation] of repairs)
143
143
  if (operation.left === entry || operation.right === entry) {
@@ -145,7 +145,7 @@ export function createHostRuntimes(
145
145
  repairs.delete(key);
146
146
  }
147
147
  entry.push?.stop();
148
- entry.runtime?.close({ preserveGlobal });
148
+ entry.runtime?.close({ preserveHost });
149
149
  };
150
150
 
151
151
  /** Cloud hosts poll and focus over cookie admission, and enroll push with the person's account. */
@@ -228,7 +228,7 @@ export interface LiveRuntime {
228
228
  searchFiles(sessionId: string, query: string): Promise<string[]>;
229
229
  retryActivity(sessionId: string): void;
230
230
  readonly hasVoiceSession: boolean;
231
- close(options?: { preserveGlobal?: boolean }): void;
231
+ close(options?: { preserveHost?: boolean }): void;
232
232
  }
233
233
 
234
234
  function isRecord(value: unknown): value is Record<string, unknown> {
@@ -572,7 +572,7 @@ export function startLiveRuntime(
572
572
 
573
573
  const applyCatalog = async (catalog: NativeBundleCatalog) => {
574
574
  if (closed) return;
575
- await mount({ scope: 'host' }, catalog.nativeGlobal);
575
+ await mount({ scope: 'host' }, catalog.nativeHost);
576
576
  if (closed) return;
577
577
  const present = new Set(
578
578
  catalog.workspaces.map((w) => (host.id === undefined ? w.id : qualifyHostId(host.id, w.id))),
@@ -813,11 +813,11 @@ export function startLiveRuntime(
813
813
  return []; // Completion is a convenience; a failed lookup just shows nothing, as in the cockpit.
814
814
  }
815
815
  },
816
- close({ preserveGlobal = false } = {}) {
816
+ close({ preserveHost = false } = {}) {
817
817
  if (closed) return;
818
818
  closed = true;
819
819
  // A reconnect keeps the computer's plugins mounted for the next connection; anything else stops them.
820
- const keep = preserveGlobal && host.id !== undefined && keptPlugins.get(host.id) === kept;
820
+ const keep = preserveHost && host.id !== undefined && keptPlugins.get(host.id) === kept;
821
821
  if (kept.link?.request === request) kept.link = undefined;
822
822
  clearVoiceReconnect();
823
823
  stopHeldChannels.unsubscribe();
@@ -26,7 +26,7 @@ interface NativeTemplateChoice {
26
26
  mount: WebPluginMount;
27
27
  }
28
28
 
29
- const GLOBAL: NativeTemplateChoice = { mount: { scope: 'host' } };
29
+ const HOST_DEFAULT: NativeTemplateChoice = { mount: { scope: 'host' } };
30
30
 
31
31
  const workspaceOf = (mount: WebPluginMount) => (mount.scope === 'workspace' ? mount.workspaceId : undefined);
32
32
  const sameChoice = (left: NativeTemplateChoice, right: NativeTemplateChoice) =>
@@ -52,14 +52,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {
52
52
 
53
53
  function mountOf(value: unknown): WebPluginMount | undefined {
54
54
  if (!isRecord(value)) return undefined;
55
- // The po.hub@1 wire spells the host mount 'global'; 'host' is accepted for hosts that already send it.
56
- if (value.scope === 'global' || value.scope === 'host') return { scope: 'host' };
55
+ if (value.scope === 'global') throw new Error("The 'global' scope was renamed to 'host'. Update this client.");
56
+ if (value.scope === 'host') return { scope: 'host' };
57
57
  if (value.scope === 'workspace' && typeof value.workspaceId === 'string')
58
58
  return { scope: 'workspace', workspaceId: value.workspaceId };
59
59
  return undefined;
60
60
  }
61
61
 
62
- /** Reads `nativeTemplate` from `/api/compositions`; anything malformed keeps the global default. */
62
+ /** Reads `nativeTemplate` from `/api/compositions`; anything malformed keeps the host default. */
63
63
  export function setNativeTemplateChoice(value: unknown, hostId?: string): void {
64
64
  const parsed = isRecord(value) ? mountOf(value.mount) : undefined;
65
65
  const mount =
@@ -67,7 +67,7 @@ export function setNativeTemplateChoice(value: unknown, hostId?: string): void {
67
67
  ? { ...parsed, workspaceId: qualifyHostId(hostId, parsed.workspaceId) }
68
68
  : parsed;
69
69
  const id = isRecord(value) && typeof value.id === 'string' ? value.id : undefined;
70
- const choice = mount === undefined ? GLOBAL : { ...(id === undefined ? {} : { id }), mount };
70
+ const choice = mount === undefined ? HOST_DEFAULT : { ...(id === undefined ? {} : { id }), mount };
71
71
  // A compositions reload repeats the choice; an unchanged one must not re-render every template screen.
72
72
  choiceStore.setState((state) => {
73
73
  const previous = state.choices[hostId ?? ''];
@@ -114,12 +114,12 @@ export function useNativeTemplateScreen<Name extends keyof NativeTemplateScreens
114
114
  choiceStore,
115
115
  (value) => {
116
116
  const host = scopedHostId ?? value.hostId;
117
- return { managed: value.managed, hostId: host, choice: value.choices[host ?? ''] ?? GLOBAL };
117
+ return { managed: value.managed, hostId: host, choice: value.choices[host ?? ''] ?? HOST_DEFAULT };
118
118
  },
119
119
  (left, right) => left.managed === right.managed && left.hostId === right.hostId && left.choice === right.choice,
120
120
  );
121
121
  const snapshot = useCallback(() => {
122
- // The global list belongs to the phone, never to a downloaded host template or registry.
122
+ // The host list belongs to the phone, never to a downloaded host template or registry.
123
123
  if (bundled || (name === 'sessions' && managed && hostId === undefined)) {
124
124
  return bundledNativeTemplateScreen(name);
125
125
  }
@@ -1,4 +1,4 @@
1
- import { globalRevisionTopic, subscribeHubRevision, type HomeRequest } from '@agimon-ai/po-core/native';
1
+ import { hostRevisionTopic, subscribeHubRevision, type HomeRequest } from '@agimon-ai/po-core/native';
2
2
  import {
3
3
  pluginHomeContributions,
4
4
  qualifyHostId,
@@ -28,7 +28,7 @@ export function useHome(
28
28
  hostId?: string,
29
29
  attention = false,
30
30
  ) {
31
- const revisionTopic = globalRevisionTopic('home', hostId);
31
+ const revisionTopic = hostRevisionTopic('home', hostId);
32
32
  const reader = attention ? (runtime?.attentionHome ?? runtime?.home) : runtime?.home;
33
33
  const current = useStore(reader?.store ?? disconnected, (value) => value);
34
34
  const matches = current.query === JSON.stringify([filter.source, filter.workspaceId]);
@@ -164,7 +164,7 @@ export function useHomes(
164
164
  };
165
165
  update();
166
166
  const offs = readers.map(({ hostId, reader }) =>
167
- subscribeHubRevision(globalRevisionTopic('home', hostId), () => {
167
+ subscribeHubRevision(hostRevisionTopic('home', hostId), () => {
168
168
  if (AppState.currentState === 'active') void reader?.refresh({ limit: 50 });
169
169
  }),
170
170
  );
@@ -18,7 +18,7 @@ import { ErrorLine, Group, SectionPage } from './SettingsScreen';
18
18
  */
19
19
 
20
20
  const TEMPLATE_KEY = 'native.template';
21
- const GLOBAL = 'global';
21
+ const HOST = 'host';
22
22
 
23
23
  /** Follow the phone, then each shipped theme under the scheme the app registers it as. */
24
24
  const THEMES: readonly { id: Appearance; title: string; detail?: string }[] = [
@@ -45,7 +45,7 @@ export interface AppearanceTemplate {
45
45
  export interface AppearanceScreenProps {
46
46
  theme: Appearance;
47
47
  onTheme: (theme: Appearance) => void;
48
- /** `global`, or the workspace id whose layout this page edits. */
48
+ /** `host`, or the workspace id whose layout this page edits. */
49
49
  target: string;
50
50
  repositories: readonly SettingsRepository[];
51
51
  templates: readonly AppearanceTemplate[];
@@ -89,7 +89,7 @@ function PluginThemes({ theme, onTheme }: Pick<AppearanceScreenProps, 'theme' |
89
89
  export function AppearanceScreen(props: AppearanceScreenProps) {
90
90
  const { theme, target, templates, choice, busy, loaded } = props;
91
91
  const targets: SelectOption[] = [
92
- { value: GLOBAL, label: 'Global default' },
92
+ { value: HOST, label: 'Host default' },
93
93
  ...props.repositories.map((repository) => ({
94
94
  value: repository.id,
95
95
  label: repository.name,
@@ -160,7 +160,7 @@ export function AppearanceScreen(props: AppearanceScreenProps) {
160
160
  Set as default
161
161
  </Button>
162
162
  <Button variant="ghost" size="sm" disabled={busy || !loaded} onPress={props.onFallback}>
163
- {target === GLOBAL ? 'Use automatic fallback' : 'Inherit global default'}
163
+ {target === HOST ? 'Use automatic fallback' : 'Inherit host default'}
164
164
  </Button>
165
165
  </View>
166
166
  <Note>
@@ -182,11 +182,11 @@ export function useAppearance(
182
182
  onSaved: () => void,
183
183
  hostId?: string,
184
184
  ): Model {
185
- const [target, setTarget] = useState(GLOBAL);
185
+ const [target, setTarget] = useState(HOST);
186
186
  const [draft, setDraft] = useState<string>();
187
187
  const [busy, setBusy] = useState(false);
188
188
  const [saveError, setSaveError] = useState<string>();
189
- const workspaceId = target === GLOBAL ? undefined : target;
189
+ const workspaceId = target === HOST ? undefined : target;
190
190
  const repoRoot = repositories.find((repository) => repository.id === workspaceId)?.path ?? '';
191
191
  // Without a host the calls take their two-argument form, which the phone-wide transport answers.
192
192
  const host = hostId === undefined ? ([] as const) : ([hostId] as const);
@@ -1,4 +1,4 @@
1
- import { globalRevisionTopic, hubRevision, subscribeHubRevision } from '@agimon-ai/po-core/native';
1
+ import { hostRevisionTopic, hubRevision, subscribeHubRevision } from '@agimon-ai/po-core/native';
2
2
  import {
3
3
  Button,
4
4
  Dot,
@@ -76,7 +76,7 @@ export interface ProvidersModel {
76
76
  /** The web page's state machine over the sealed channel: one call at a time, the flow fetched on pushed changes. */
77
77
  export function useProviders(hostId?: string): ProvidersModel {
78
78
  // With several computers Settings names one; this screen then reads and writes only that computer.
79
- const revisionTopic = globalRevisionTopic('providers', hostId ?? currentSession()?.hostId);
79
+ const revisionTopic = hostRevisionTopic('providers', hostId ?? currentSession()?.hostId);
80
80
  const revision = useSyncExternalStore(
81
81
  (listener) => subscribeHubRevision(revisionTopic, listener),
82
82
  () => hubRevision(revisionTopic),
@@ -520,7 +520,7 @@ function WorkspaceDefaults({ scheme }: { scheme?: DesignScheme }) {
520
520
  footer={<SaveBar count={1} />}
521
521
  >
522
522
  <Group label="Major mode">
523
- <CardOption title="Inherit" detail="From global: build" />
523
+ <CardOption title="Inherit" detail="From host: build" />
524
524
  <CardOption title="build" detail="Layers: core, source-control, task" selected />
525
525
  <CardOption title="review" detail="Layers: core, source-control" last />
526
526
  </Group>
@@ -16,7 +16,7 @@ export interface NativeBundleUpdateChoice {
16
16
 
17
17
  type Composition = NativeCompositionDescriptor & { manifestUrl: string; rawAssetBaseUrl: string };
18
18
  export interface NativeBundleCatalog {
19
- nativeGlobal?: Composition;
19
+ nativeHost?: Composition;
20
20
  workspaces: { id: string; nativeComposition?: Composition }[];
21
21
  }
22
22
  interface StoredModule {
@@ -138,8 +138,9 @@ function compositionOf(value: unknown): Composition | undefined {
138
138
  }
139
139
  function catalogOf(value: unknown): NativeBundleCatalog {
140
140
  if (!record(value)) throw new Error('Invalid native catalog.');
141
+ if ('nativeGlobal' in value) throw new Error("The 'global' scope was renamed to 'host'. Update this client.");
141
142
  return {
142
- nativeGlobal: compositionOf(value.nativeGlobal),
143
+ nativeHost: compositionOf(value.nativeHost),
143
144
  workspaces: Array.isArray(value.workspaces)
144
145
  ? value.workspaces
145
146
  .map((workspace: unknown) => {
@@ -151,7 +152,7 @@ function catalogOf(value: unknown): NativeBundleCatalog {
151
152
  };
152
153
  }
153
154
  const descriptors = (catalog: NativeBundleCatalog) =>
154
- [catalog.nativeGlobal, ...catalog.workspaces.map((w) => w.nativeComposition)].filter(
155
+ [catalog.nativeHost, ...catalog.workspaces.map((w) => w.nativeComposition)].filter(
155
156
  (d): d is Composition => d !== undefined,
156
157
  );
157
158
  const paths = (descriptor: NativeCompositionDescriptor) => [
@@ -243,7 +244,7 @@ export function createNativeBundleUpdates(options: {
243
244
  );
244
245
  }
245
246
  return JSON.stringify([
246
- generation.catalog.nativeGlobal ? identities.get(generation.catalog.nativeGlobal) : null,
247
+ generation.catalog.nativeHost ? identities.get(generation.catalog.nativeHost) : null,
247
248
  [...new Set(identities.values())].sort(),
248
249
  ]);
249
250
  };
@@ -323,6 +324,13 @@ export function createNativeBundleUpdates(options: {
323
324
  records.sort((a, b) => b.sequence - a.sequence);
324
325
  sequences.set(key, records[0]?.sequence ?? 0);
325
326
  for (const stored of records) {
327
+ let migrated = false;
328
+ for (const generation of [stored.installed, stored.pending]) {
329
+ if (!generation || !record(generation.catalog) || !('nativeGlobal' in generation.catalog)) continue;
330
+ const { nativeGlobal, ...catalog } = generation.catalog;
331
+ generation.catalog = { ...catalog, nativeHost: catalog.nativeHost ?? nativeGlobal } as NativeBundleCatalog;
332
+ migrated = true;
333
+ }
326
334
  if (stored.installed) {
327
335
  try {
328
336
  state.identity = await identity(stored.installed);
@@ -341,7 +349,10 @@ export function createNativeBundleUpdates(options: {
341
349
  options.onError(error);
342
350
  }
343
351
  }
344
- if (state.generation) return state;
352
+ if (state.generation) {
353
+ if (migrated) await save(state);
354
+ return state;
355
+ }
345
356
  }
346
357
  return state;
347
358
  })();
@@ -429,7 +440,7 @@ export function createNativeBundleUpdates(options: {
429
440
  if (JSON.stringify(previousIds) === JSON.stringify(nextIds)) return {};
430
441
  const refreshed: Generation = {
431
442
  catalog: {
432
- nativeGlobal: installed.catalog.nativeGlobal,
443
+ nativeHost: installed.catalog.nativeHost,
433
444
  workspaces: candidate.catalog.workspaces.map(
434
445
  (workspace) => installed.catalog.workspaces.find((old) => old.id === workspace.id) ?? workspace,
435
446
  ),
@@ -496,7 +507,7 @@ export function createNativeBundleUpdates(options: {
496
507
  if (!state.generation) return undefined;
497
508
  // A new scope may use only modules already selected by this generation. In particular,
498
509
  // a pending UI entry must never be fetched or evaluated through the session path.
499
- if (descriptor.uiEntry !== state.generation.catalog.nativeGlobal?.uiEntry) return undefined;
510
+ if (descriptor.uiEntry !== state.generation.catalog.nativeHost?.uiEntry) return undefined;
500
511
  const admitted = paths(descriptor);
501
512
  for (const module of state.generation.modules) {
502
513
  const loaded = await verify(module);
@@ -91,7 +91,7 @@ export function hostModulesForHost(hostId: string, signerPublicKey: string): Hos
91
91
  nativeApiTransport: apiTransportForHost(hostId),
92
92
  transportForHost,
93
93
  calendarTargetsForSession,
94
- globalRevisionTopic: (name: string, host: string = hostId) => nativeCore.globalRevisionTopic(name, host),
94
+ hostRevisionTopic: (name: string, host: string = hostId) => nativeCore.hostRevisionTopic(name, host),
95
95
  },
96
96
  }),
97
97
  );
@@ -1,13 +1,8 @@
1
- import {
2
- normalizeLegacyWebPluginDefinition,
3
- type WebPluginDefinition,
4
- type WebPluginMount,
5
- type WebPluginRuntime,
6
- } from '@agimon-ai/po-core/web';
1
+ import { type WebPluginDefinition, type WebPluginMount, type WebPluginRuntime } from '@agimon-ai/po-core/web';
7
2
  import {
8
3
  bindSessionWebWorkspace,
9
4
  dispatchChannelFrame,
10
- installGlobalWebPlugins,
5
+ installHostWebPlugins,
11
6
  installSessionWebPlugins,
12
7
  installWorkspaceWebPlugins,
13
8
  pluginsAtScope,
@@ -142,8 +137,8 @@ function exportedPlugins(
142
137
  const exports = evaluate(bundle.source, hostModules) as { nativePlugin?: unknown } | null;
143
138
  const plugin = typeof exports === 'object' && exports !== null ? exports.nativePlugin : undefined;
144
139
  if (typeof plugin !== 'object' || plugin === null) throw new Error('The module exported no nativePlugin.');
145
- // A bundle built before the rename keys its host contributions 'global'.
146
- return [normalizeLegacyWebPluginDefinition(plugin as WebPluginDefinition)];
140
+ if ('global' in plugin) throw new Error("The 'global' scope was renamed to 'host'. Update this client.");
141
+ return [plugin as WebPluginDefinition];
147
142
  } catch (error) {
148
143
  console.warn(`native plugin '${pluginId}' failed to load`, error);
149
144
  onFailure(pluginId, error);
@@ -173,7 +168,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
173
168
  ? {
174
169
  bindSessionWebWorkspace,
175
170
  dispatchChannelFrame,
176
- installGlobalWebPlugins,
171
+ installHostWebPlugins,
177
172
  installSessionWebPlugins,
178
173
  installWorkspaceWebPlugins,
179
174
  removeSessionWebPlugins,
@@ -188,7 +183,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
188
183
  const issuesByMount = new Map<string, PluginCompatibility[]>();
189
184
  let activeUi: UiGeneration | undefined;
190
185
  let runtimeEpoch = 0;
191
- // A plugin owns one context/store instance across its global, workspace and session mounts.
186
+ // A plugin owns one context/store instance across its host, workspace and session mounts.
192
187
  const evaluate: typeof evaluateComposition = (source, modules) => {
193
188
  let hosts = evaluations.get(modules);
194
189
  if (!hosts) evaluations.set(modules, (hosts = new Map()));
@@ -246,7 +241,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
246
241
  return pendingUi;
247
242
  };
248
243
 
249
- const stopMount = (owner: string, preserveGlobal = false) => {
244
+ const stopMount = (owner: string, preserveHost = false) => {
250
245
  const entry = loaded.get(owner);
251
246
  if (entry === undefined) return;
252
247
  loaded.delete(owner);
@@ -254,7 +249,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
254
249
  entry.stop();
255
250
  } finally {
256
251
  if (entry.mount.scope === 'host') {
257
- if (!preserveGlobal) registry.installGlobalWebPlugins([]);
252
+ if (!preserveHost) registry.installHostWebPlugins([]);
258
253
  } else if (entry.mount.scope === 'workspace') registry.removeWorkspaceWebPlugins(entry.mount.workspaceId);
259
254
  else registry.removeSessionWebPlugins(entry.mount.sessionId);
260
255
  }
@@ -297,7 +292,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
297
292
  return;
298
293
  }
299
294
  stopMount(owner);
300
- if (mount.scope === 'host') registry.installGlobalWebPlugins(definitions);
295
+ if (mount.scope === 'host') registry.installHostWebPlugins(definitions);
301
296
  else if (mount.scope === 'workspace') registry.installWorkspaceWebPlugins(mount.workspaceId, definitions);
302
297
  else {
303
298
  registry.bindSessionWebWorkspace(mount.sessionId, mount.workspaceId);
@@ -386,7 +381,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
386
381
  dispatch(frame: Record<string, unknown>): boolean {
387
382
  return registry.dispatchChannelFrame(frame);
388
383
  },
389
- stop(preserveGlobal = false): void {
384
+ stop(preserveHost = false): void {
390
385
  runtimeEpoch += 1;
391
386
  pending.clear();
392
387
  uiLoads.clear();
@@ -396,7 +391,7 @@ export function createPluginRuntime(options: PluginRuntimeOptions) {
396
391
  const errors: unknown[] = [];
397
392
  for (const owner of loaded.keys()) {
398
393
  try {
399
- stopMount(owner, preserveGlobal);
394
+ stopMount(owner, preserveHost);
400
395
  } catch (error) {
401
396
  errors.push(error);
402
397
  }
@@ -347,7 +347,7 @@ export type McpServerEntry = { type: 'http'; url: string } | { command: string;
347
347
 
348
348
  export function listMcpServers(hostId?: string): Promise<Result<{ servers: McpConfiguredServer[] }>> {
349
349
  return request(
350
- `${MCP_SERVERS_ROUTE}/global`,
350
+ `${MCP_SERVERS_ROUTE}/host`,
351
351
  undefined,
352
352
  (body) => (Array.isArray(body.servers) ? { servers: body.servers as McpConfiguredServer[] } : undefined),
353
353
  hostId,
@@ -7,6 +7,11 @@ import type {
7
7
  import type { createAccountGrants } from '../accountGrants';
8
8
  import type { AccountRecord, createAccountTrust } from '../accountTrust';
9
9
 
10
+ function providerScope(value: string): boolean {
11
+ if (value === 'global') throw new Error("The 'global' scope was renamed to 'host'. Update this client.");
12
+ return ['host', 'workspace', 'session'].includes(value);
13
+ }
14
+
10
15
  function record(value: unknown): value is Record<string, unknown> {
11
16
  return value !== null && typeof value === 'object' && !Array.isArray(value);
12
17
  }
@@ -30,12 +35,7 @@ function provider(value: unknown): value is FederationProvider {
30
35
  (value.expiresAt === undefined || (typeof value.expiresAt === 'number' && Number.isFinite(value.expiresAt))) &&
31
36
  Array.isArray(value.operations) &&
32
37
  value.operations.every(
33
- (op) =>
34
- record(op) &&
35
- typeof op.scope === 'string' &&
36
- // The hub sends the wire value 'global' for host operations; 'host' is the plugin-scope name.
37
- ['host', 'global', 'workspace', 'session'].includes(op.scope) &&
38
- names(op.names),
38
+ (op) => record(op) && typeof op.scope === 'string' && providerScope(op.scope) && names(op.names),
39
39
  )
40
40
  );
41
41
  }
@@ -49,7 +49,7 @@ export function parseWorkspaceProviders(body: unknown, workspaceId: string): Fed
49
49
  ...item,
50
50
  operations: item.operations.map((op) => ({
51
51
  ...op,
52
- scope: (op.scope as string) === 'global' ? 'host' : op.scope,
52
+ scope: op.scope,
53
53
  })),
54
54
  }))
55
55
  : undefined;