@ateam-ai-mobile/core 0.1.11 → 0.1.13
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/dist/index.d.mts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/devMode.ts +25 -0
- package/src/devModeState.ts +32 -0
- package/src/index.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ateam-ai-mobile/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read and switch dev mode — the same calls the web chat's chip makes
|
|
3
|
+
* (cp.fe_api listCommands / setMode). Eligibility and storage stay in Core.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { mcpToolCall, unwrapMcpResult } from './api/mcp';
|
|
7
|
+
import { devModeFromCatalog, type DevModeState } from './devModeState';
|
|
8
|
+
|
|
9
|
+
const SOLUTION_DEV_MODE = 'SOLUTION_DEV_MODE';
|
|
10
|
+
const NORMAL_USER_MODE = 'NORMAL_USER_MODE';
|
|
11
|
+
|
|
12
|
+
/** The person's dev mode now, or null when Core offers them no mode switch. */
|
|
13
|
+
export async function readDevMode(): Promise<DevModeState | null> {
|
|
14
|
+
const resp = await mcpToolCall('cp.fe_api', { method: 'listCommands', params: {} });
|
|
15
|
+
return devModeFromCatalog(unwrapMcpResult(resp?.result));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Turn dev mode on (for the longest time Core allows) or off; answers the new state. */
|
|
19
|
+
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 } });
|
|
21
|
+
const out = unwrapMcpResult(resp?.result);
|
|
22
|
+
if (out?.ok === false) throw new Error(out.error || 'Could not change the mode');
|
|
23
|
+
if (resp?.error) throw new Error(resp.error.message || 'Could not change the mode');
|
|
24
|
+
return devModeFromCatalog(out);
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev mode, as the server's command catalog states it — pure, no I/O.
|
|
3
|
+
*
|
|
4
|
+
* Dev mode (SOLUTION_DEV_MODE) is ONE per-person switch kept by Core: the web
|
|
5
|
+
* chat's chip, `/mode dev` in any chat and this SDK's chip all set the same
|
|
6
|
+
* row, and voice routes by it too. The app never stores it: it reads the
|
|
7
|
+
* catalog Core serves (cp.fe_api listCommands / setMode), the same one the
|
|
8
|
+
* "/" menu reads, so the chip and the menu cannot disagree.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface DevModeState {
|
|
12
|
+
/** The person may switch it (tenant admins and owners); else the chip is not shown. */
|
|
13
|
+
available: boolean;
|
|
14
|
+
/** Dev mode is on now. */
|
|
15
|
+
active: boolean;
|
|
16
|
+
/** When it ends (ISO), while on. */
|
|
17
|
+
expiresAt: string | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The "mode" entry of a command catalog, or null when the catalog offers none. */
|
|
21
|
+
export function devModeFromCatalog(catalog: any): DevModeState | null {
|
|
22
|
+
const entry = Array.isArray(catalog?.commands)
|
|
23
|
+
? catalog.commands.find((c: any) => c?.command === 'mode')
|
|
24
|
+
: null;
|
|
25
|
+
if (!entry) return null;
|
|
26
|
+
const active = entry.state?.active === true;
|
|
27
|
+
return {
|
|
28
|
+
available: entry.available !== false,
|
|
29
|
+
active,
|
|
30
|
+
expiresAt: active && typeof entry.state?.expires_at === 'string' ? entry.state.expires_at : null,
|
|
31
|
+
};
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,11 @@ export {
|
|
|
43
43
|
unwrapMcpResult,
|
|
44
44
|
} from './api/mcp';
|
|
45
45
|
|
|
46
|
+
// Dev mode — the one per-person switch the chat chip, `/mode dev` and voice share
|
|
47
|
+
export { readDevMode, setDevMode } from './devMode';
|
|
48
|
+
export { devModeFromCatalog } from './devModeState';
|
|
49
|
+
export type { DevModeState } from './devModeState';
|
|
50
|
+
|
|
46
51
|
// Tenant memberships
|
|
47
52
|
export { getSession, isDevHost } from './session';
|
|
48
53
|
export type { Session, SessionEnv } from './session';
|