@ateam-ai-mobile/core 0.1.1 → 0.1.3
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 +48 -7
- package/dist/index.d.ts +48 -7
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/tenants.ts +59 -6
- package/src/chat/store.ts +4 -0
- package/src/chat/types.ts +6 -0
- package/src/config.ts +22 -0
- package/src/index.ts +3 -2
package/dist/index.mjs
CHANGED
|
@@ -26,6 +26,11 @@ function getVoiceApiUrl() {
|
|
|
26
26
|
if (!url) throw new Error("[adas] voiceUrl not configured");
|
|
27
27
|
return resolveUrl(url);
|
|
28
28
|
}
|
|
29
|
+
function getConsumerAuthApiUrl() {
|
|
30
|
+
const url = getConfig().consumerAuthUrl;
|
|
31
|
+
if (!url) throw new Error("[adas] consumerAuthUrl not configured \u2014 required for switchTenant()");
|
|
32
|
+
return resolveUrl(url);
|
|
33
|
+
}
|
|
29
34
|
function getTenant() {
|
|
30
35
|
const t = getConfig().tenant;
|
|
31
36
|
return (typeof t === "function" ? t() : t) || "";
|
|
@@ -165,12 +170,6 @@ function unwrapMcpResult(result) {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
// src/api/tenants.ts
|
|
169
|
-
async function listMyTenants() {
|
|
170
|
-
const data = await apiFetch("/api/tenants/list");
|
|
171
|
-
return data.ok && Array.isArray(data.tenants) ? data.tenants : [];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
173
|
// src/chat/store.ts
|
|
175
174
|
import { create } from "zustand";
|
|
176
175
|
|
|
@@ -292,6 +291,8 @@ function snapshotToProgress(snap, rootJobId) {
|
|
|
292
291
|
};
|
|
293
292
|
const liveProgress = extractLiveProgress(snap);
|
|
294
293
|
if (liveProgress) progress.liveProgress = liveProgress;
|
|
294
|
+
if (typeof snap?.humanStatus === "string" && snap.humanStatus) progress.humanStatus = snap.humanStatus;
|
|
295
|
+
if (snap?.humanLabels && typeof snap.humanLabels === "object") progress.humanLabels = snap.humanLabels;
|
|
295
296
|
if (pq) {
|
|
296
297
|
progress.pendingQuestion = {
|
|
297
298
|
inputId: pq.correlation_id || pq.correlationId || pq.inputId || "",
|
|
@@ -905,6 +906,41 @@ async function pollJob(jobId, token) {
|
|
|
905
906
|
});
|
|
906
907
|
}
|
|
907
908
|
|
|
909
|
+
// src/api/tenants.ts
|
|
910
|
+
async function listMyTenants() {
|
|
911
|
+
const data = await apiFetch("/api/tenants/list");
|
|
912
|
+
return data.ok && Array.isArray(data.tenants) ? data.tenants : [];
|
|
913
|
+
}
|
|
914
|
+
async function switchTenant(targetTenantId) {
|
|
915
|
+
const token = getToken();
|
|
916
|
+
if (!token) throw new Error("[adas] switchTenant: not signed in");
|
|
917
|
+
const res = await fetch(`${getConsumerAuthApiUrl()}/platform/consumer/switch-tenant`, {
|
|
918
|
+
method: "POST",
|
|
919
|
+
headers: {
|
|
920
|
+
"Content-Type": "application/json",
|
|
921
|
+
Authorization: `Bearer ${token}`
|
|
922
|
+
},
|
|
923
|
+
body: JSON.stringify({ target_tenant: targetTenantId })
|
|
924
|
+
});
|
|
925
|
+
const data = await res.json().catch(() => null);
|
|
926
|
+
if (!res.ok || !data?.ok || !data.jwt) {
|
|
927
|
+
throw new Error(data?.error || `switchTenant failed (${res.status})`);
|
|
928
|
+
}
|
|
929
|
+
const session = {
|
|
930
|
+
jwt: data.jwt,
|
|
931
|
+
tenant: data.tenant,
|
|
932
|
+
actor: data.actor
|
|
933
|
+
};
|
|
934
|
+
const onSession = getConfig().onSession;
|
|
935
|
+
if (!onSession) {
|
|
936
|
+
throw new Error("[adas] switchTenant: config.onSession is required to persist the new session");
|
|
937
|
+
}
|
|
938
|
+
await onSession(session);
|
|
939
|
+
closeChatStream();
|
|
940
|
+
useChatStore.getState().clearChat();
|
|
941
|
+
return session;
|
|
942
|
+
}
|
|
943
|
+
|
|
908
944
|
// src/theme/tokens.ts
|
|
909
945
|
var colors = {
|
|
910
946
|
dark: {
|
|
@@ -1595,6 +1631,7 @@ export {
|
|
|
1595
1631
|
disconnectAcsWs,
|
|
1596
1632
|
fontSize,
|
|
1597
1633
|
getConfig,
|
|
1634
|
+
getConsumerAuthApiUrl,
|
|
1598
1635
|
getCoreApiUrl,
|
|
1599
1636
|
getCoreWsUrl,
|
|
1600
1637
|
getTenant,
|
|
@@ -1620,6 +1657,7 @@ export {
|
|
|
1620
1657
|
setHomeActionOrder,
|
|
1621
1658
|
setOrder,
|
|
1622
1659
|
spacing,
|
|
1660
|
+
switchTenant,
|
|
1623
1661
|
unwrapMcpResult,
|
|
1624
1662
|
useChatStore,
|
|
1625
1663
|
useHomeActionsStore,
|