@ateam-ai-mobile/core 0.1.28 → 0.1.30

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": "@ateam-ai-mobile/core",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Headless ADAS SDK core — auth bridge, API client, chat/job streaming, MCP calls, theme tokens. No UI, no Expo dependencies.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/chat/store.ts CHANGED
@@ -14,6 +14,7 @@
14
14
  import { create } from 'zustand';
15
15
  import { getCoreApiUrl, openCoreWs, getToken, getTenant, getUser, getConfig } from '../config';
16
16
  import { pluginCommandEmitter } from '../utils/emitter';
17
+ import { focusPlugin } from '../utils/hostIntents';
17
18
  import type { OutgoingAttachment } from '../storage/types';
18
19
  import type { Message, MessageAttachment, JobProgress, UIAction } from './types';
19
20
 
@@ -717,7 +718,7 @@ function dispatchPluginCommands(cmds: any[]) {
717
718
  const pluginId = cmd?.pluginId || cmd?.plugin_id || cmd?.args?.plugin_id;
718
719
  if (pluginId) {
719
720
  const props = cmd?.props ?? cmd?.args?.props ?? undefined;
720
- pluginCommandEmitter.emit('focus-plugin', { pluginId, props });
721
+ focusPlugin(pluginId, props);
721
722
  }
722
723
  }
723
724
  }
package/src/index.ts CHANGED
@@ -167,6 +167,7 @@ export type {
167
167
 
168
168
  // Plugin command bus
169
169
  export { pluginCommandEmitter, PluginCommandEmitter } from './utils/emitter';
170
+ export { registerHostIntent, focusPlugin } from './utils/hostIntents';
170
171
  export type { BufferedCommand } from './utils/emitter';
171
172
 
172
173
  // Theme tokens
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Host intents: a focus request whose plugin id the host handles itself (a "platform:" surface that is an
3
+ * action, not a widget), e.g. platform:workspace {workspace}. ONE function serves both who can ask:
4
+ * - the agent, with sys.focusUiPlugin(plugin_id, props), which arrives down the chat stream;
5
+ * - a widget on screen, with the focus-plugin message (usePluginBridge).
6
+ * Both call `focusPlugin`. An id with a registered intent runs it, silently and locally (no server call of
7
+ * its own); any other id is emitted as 'focus-plugin' for the host to open as a widget, as before.
8
+ */
9
+ import { pluginCommandEmitter } from './emitter';
10
+
11
+ type Intent = (props: any) => void;
12
+ const intents = new Map<string, Intent>();
13
+
14
+ export function registerHostIntent(pluginId: string, fn: Intent): void {
15
+ intents.set(pluginId, fn);
16
+ }
17
+
18
+ export function focusPlugin(pluginId: string, props?: any): void {
19
+ const intent = intents.get(pluginId);
20
+ if (intent) {
21
+ try { intent(props && typeof props === 'object' ? props : {}); } catch (e: any) {
22
+ console.warn(`[hostIntent] ${pluginId} failed:`, e?.message || e);
23
+ }
24
+ return;
25
+ }
26
+ pluginCommandEmitter.emit('focus-plugin', { pluginId, props });
27
+ }