@ateam-ai-mobile/core 0.1.5 → 0.1.6

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 CHANGED
@@ -176,6 +176,27 @@ declare function postCommandResult(correlationId: string, result: any, error?: s
176
176
  */
177
177
  declare function unwrapMcpResult(result: any): any;
178
178
 
179
+ type SessionEnv = 'dev' | 'prod';
180
+ interface Session {
181
+ /** Tenant slug the app is actually scoped to (getTenant = signed-in tenant,
182
+ * falling back to the pre-auth choice). Null when neither is set. */
183
+ tenant: string | null;
184
+ /** Human label for the tenant — slug today; callers must not compute their own. */
185
+ tenantName: string;
186
+ /** dev | prod — derived from the resolved host, never a stored word. */
187
+ env: SessionEnv;
188
+ /** The actual backend host — a host can't be ambiguous the way a word can. */
189
+ host: string;
190
+ actorId: string | null;
191
+ email: string | null;
192
+ }
193
+ /** Is a resolved base URL a dev backend? Keyed on the hostname (dev-app…,
194
+ * dev-consumer-auth…) so it matches wherever the request goes. */
195
+ declare function isDevHost(u: string | undefined | null): boolean;
196
+ /** Compute the session from the live SDK config. Plain function — a host hook
197
+ * wraps this for reactivity; imperative code can call it directly. */
198
+ declare function getSession(): Session;
199
+
179
200
  interface TenantMembership {
180
201
  id: string;
181
202
  name: string;
@@ -761,4 +782,4 @@ interface AcsKvStorage {
761
782
  }
762
783
  declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
763
784
 
764
- export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type BufferedCommand, type DeleteResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type JobProgress, type Message, type MessageAttachment, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type RefreshOutcome, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, closeChatStream, colors, connectAcsWs, connectorCall, deleteArtifact, disconnectAcsWs, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, recordEvent, refreshToken, setAcsCacheStorage, setAcsReachabilityReporter, setHomeActionOrder, setOrder, spacing, switchTenant, unwrapMcpResult, useChatStore, useHomeActionsStore, useWidgetsStore };
785
+ export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type BufferedCommand, type DeleteResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type JobProgress, type Message, type MessageAttachment, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type RefreshOutcome, type Session, type SessionEnv, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, closeChatStream, colors, connectAcsWs, connectorCall, deleteArtifact, disconnectAcsWs, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, recordEvent, refreshToken, setAcsCacheStorage, setAcsReachabilityReporter, setHomeActionOrder, setOrder, spacing, switchTenant, unwrapMcpResult, useChatStore, useHomeActionsStore, useWidgetsStore };
package/dist/index.d.ts CHANGED
@@ -176,6 +176,27 @@ declare function postCommandResult(correlationId: string, result: any, error?: s
176
176
  */
177
177
  declare function unwrapMcpResult(result: any): any;
178
178
 
179
+ type SessionEnv = 'dev' | 'prod';
180
+ interface Session {
181
+ /** Tenant slug the app is actually scoped to (getTenant = signed-in tenant,
182
+ * falling back to the pre-auth choice). Null when neither is set. */
183
+ tenant: string | null;
184
+ /** Human label for the tenant — slug today; callers must not compute their own. */
185
+ tenantName: string;
186
+ /** dev | prod — derived from the resolved host, never a stored word. */
187
+ env: SessionEnv;
188
+ /** The actual backend host — a host can't be ambiguous the way a word can. */
189
+ host: string;
190
+ actorId: string | null;
191
+ email: string | null;
192
+ }
193
+ /** Is a resolved base URL a dev backend? Keyed on the hostname (dev-app…,
194
+ * dev-consumer-auth…) so it matches wherever the request goes. */
195
+ declare function isDevHost(u: string | undefined | null): boolean;
196
+ /** Compute the session from the live SDK config. Plain function — a host hook
197
+ * wraps this for reactivity; imperative code can call it directly. */
198
+ declare function getSession(): Session;
199
+
179
200
  interface TenantMembership {
180
201
  id: string;
181
202
  name: string;
@@ -761,4 +782,4 @@ interface AcsKvStorage {
761
782
  }
762
783
  declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
763
784
 
764
- export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type BufferedCommand, type DeleteResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type JobProgress, type Message, type MessageAttachment, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type RefreshOutcome, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, closeChatStream, colors, connectAcsWs, connectorCall, deleteArtifact, disconnectAcsWs, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, recordEvent, refreshToken, setAcsCacheStorage, setAcsReachabilityReporter, setHomeActionOrder, setOrder, spacing, switchTenant, unwrapMcpResult, useChatStore, useHomeActionsStore, useWidgetsStore };
785
+ export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type BufferedCommand, type DeleteResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type JobProgress, type Message, type MessageAttachment, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type RefreshOutcome, type Session, type SessionEnv, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, closeChatStream, colors, connectAcsWs, connectorCall, deleteArtifact, disconnectAcsWs, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, recordEvent, refreshToken, setAcsCacheStorage, setAcsReachabilityReporter, setHomeActionOrder, setOrder, spacing, switchTenant, unwrapMcpResult, useChatStore, useHomeActionsStore, useWidgetsStore };
package/dist/index.js CHANGED
@@ -39,12 +39,14 @@ __export(index_exports, {
39
39
  getConsumerAuthApiUrl: () => getConsumerAuthApiUrl,
40
40
  getCoreApiUrl: () => getCoreApiUrl,
41
41
  getCoreWsUrl: () => getCoreWsUrl,
42
+ getSession: () => getSession,
42
43
  getTenant: () => getTenant,
43
44
  getToken: () => getToken,
44
45
  getUser: () => getUser,
45
46
  getVoiceApiUrl: () => getVoiceApiUrl,
46
47
  initAdas: () => initAdas,
47
48
  isAdasInitialized: () => isAdasInitialized,
49
+ isDevHost: () => isDevHost,
48
50
  listHomeActions: () => listHomeActions,
49
51
  listMadeForYou: () => listMadeForYou,
50
52
  listMyTenants: () => listMyTenants,
@@ -243,6 +245,42 @@ function unwrapMcpResult(result) {
243
245
  }
244
246
  }
245
247
 
248
+ // src/session.ts
249
+ function hostOf(u) {
250
+ if (!u) return "";
251
+ try {
252
+ return new URL(u).host;
253
+ } catch {
254
+ return u;
255
+ }
256
+ }
257
+ function isDevHost(u) {
258
+ const h = hostOf(u);
259
+ return !!h && (h.includes("dev-") || /(^|\.)dev\./.test(h));
260
+ }
261
+ function getSession() {
262
+ let consumerUrl = "";
263
+ try {
264
+ consumerUrl = getConsumerAuthApiUrl();
265
+ } catch {
266
+ }
267
+ let coreUrl = "";
268
+ try {
269
+ coreUrl = getCoreApiUrl();
270
+ } catch {
271
+ }
272
+ const tenant = getTenant() || null;
273
+ const user = getUser();
274
+ return {
275
+ tenant,
276
+ tenantName: tenant || "\u2014",
277
+ env: isDevHost(consumerUrl) || isDevHost(coreUrl) ? "dev" : "prod",
278
+ host: hostOf(consumerUrl || coreUrl),
279
+ actorId: user?.actorId ?? null,
280
+ email: user?.email ?? null
281
+ };
282
+ }
283
+
246
284
  // src/chat/store.ts
247
285
  var import_zustand = require("zustand");
248
286
 
@@ -393,7 +431,11 @@ function renderTableShape(content) {
393
431
  }
394
432
  function blocksToText(blocks) {
395
433
  if (!blocks || blocks.length === 0) return "";
434
+ const hasTextBlock = blocks.some(
435
+ (b) => b.kind === "text" || b.kind === "markdown" || b.kind === "description"
436
+ );
396
437
  return blocks.map((b) => {
438
+ if ((b.kind === "json" || b.kind === "code") && hasTextBlock) return "";
397
439
  if (b.kind === "text" || b.kind === "markdown" || b.kind === "description") {
398
440
  return typeof b.content === "string" ? b.content : "";
399
441
  }
@@ -1734,12 +1776,14 @@ function disconnectAcsWs() {
1734
1776
  getConsumerAuthApiUrl,
1735
1777
  getCoreApiUrl,
1736
1778
  getCoreWsUrl,
1779
+ getSession,
1737
1780
  getTenant,
1738
1781
  getToken,
1739
1782
  getUser,
1740
1783
  getVoiceApiUrl,
1741
1784
  initAdas,
1742
1785
  isAdasInitialized,
1786
+ isDevHost,
1743
1787
  listHomeActions,
1744
1788
  listMadeForYou,
1745
1789
  listMyTenants,