@ateam-ai-mobile/core 0.1.13 → 0.1.15

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.13",
3
+ "version": "0.1.15",
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/devMode.ts CHANGED
@@ -1,23 +1,41 @@
1
1
  /**
2
2
  * Read and switch dev mode — the same calls the web chat's chip makes
3
3
  * (cp.fe_api listCommands / setMode). Eligibility and storage stay in Core.
4
+ *
5
+ * Through apiFetch, not mcpToolCall: the chip polls for as long as a screen is
6
+ * open, and apiFetch refreshes an expired token on a 401 (mcpFetch does not),
7
+ * so the chip neither freezes on a stale state nor fails a tap after the token
8
+ * runs out.
4
9
  */
5
10
 
6
- import { mcpToolCall, unwrapMcpResult } from './api/mcp';
11
+ import { apiFetch } from './api/client';
12
+ import { unwrapMcpResult } from './api/mcp';
7
13
  import { devModeFromCatalog, type DevModeState } from './devModeState';
8
14
 
9
15
  const SOLUTION_DEV_MODE = 'SOLUTION_DEV_MODE';
10
16
  const NORMAL_USER_MODE = 'NORMAL_USER_MODE';
11
17
 
18
+ function feApi(method: string, params: Record<string, any>): Promise<any> {
19
+ return apiFetch('/mcp', {
20
+ method: 'POST',
21
+ body: JSON.stringify({
22
+ jsonrpc: '2.0',
23
+ id: Date.now(),
24
+ method: 'tools/call',
25
+ params: { name: 'cp.fe_api', arguments: { method, params } },
26
+ }),
27
+ });
28
+ }
29
+
12
30
  /** The person's dev mode now, or null when Core offers them no mode switch. */
13
31
  export async function readDevMode(): Promise<DevModeState | null> {
14
- const resp = await mcpToolCall('cp.fe_api', { method: 'listCommands', params: {} });
32
+ const resp = await feApi('listCommands', {});
15
33
  return devModeFromCatalog(unwrapMcpResult(resp?.result));
16
34
  }
17
35
 
18
36
  /** Turn dev mode on (for the longest time Core allows) or off; answers the new state. */
19
37
  export async function setDevMode(on: boolean): Promise<DevModeState | null> {
20
- const resp = await mcpToolCall('cp.fe_api', { method: 'setMode', params: { mode: on ? SOLUTION_DEV_MODE : NORMAL_USER_MODE } });
38
+ const resp = await feApi('setMode', { mode: on ? SOLUTION_DEV_MODE : NORMAL_USER_MODE });
21
39
  const out = unwrapMcpResult(resp?.result);
22
40
  if (out?.ok === false) throw new Error(out.error || 'Could not change the mode');
23
41
  if (resp?.error) throw new Error(resp.error.message || 'Could not change the mode');