@ateam-ai-mobile/core 0.1.32 → 0.1.35

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
@@ -4,11 +4,63 @@ import * as zustand from 'zustand';
4
4
  * Storage adapter contracts. The core is platform-agnostic (no Expo, no
5
5
  * AsyncStorage imports) — hosts or @ateam-ai-mobile/ui plug in concrete implementations.
6
6
  */
7
- /** Outgoing attachment as sent to /api/chat (base64 payload). */
7
+ /** The most Core stores for one file (Core's MAX_ARTIFACT_BYTES, 90 MiB: Cloudflare allows 100 MB a request). */
8
+ declare const MAX_ATTACHMENT_BYTES: number;
9
+ /**
10
+ * What the old base64-in-JSON path may carry in ONE chat message, in raw bytes (all inline attachments together). Core's
11
+ * express.json limit is 10 MB for the WHOLE /api/chat body and base64 adds a third (7 MiB becomes ~9.3 MiB), which leaves
12
+ * headroom for the text and the rest of the JSON.
13
+ */
14
+ declare const MAX_INLINE_ATTACHMENT_BYTES: number;
15
+ /**
16
+ * An attachment the user staged, as handed to `sendMessage`.
17
+ *
18
+ * A file on the phone is given by `uri` (+ `size`): it is uploaded as the raw request body to `POST /api/artifacts`, and
19
+ * `/api/chat` then names it by hash, so a 90 MB file never rides inside JSON. `data` (base64) is the older shape, kept for
20
+ * small inline attachments and as the fallback when the server is too old to take a raw upload (it answers 400).
21
+ */
8
22
  interface OutgoingAttachment {
9
- data: string;
10
23
  mimeType: string;
11
24
  name: string;
25
+ /** Base64 payload (inline path). Absent when the file is given by `uri`. */
26
+ data?: string;
27
+ /** Local file URI the host's `fileUploader` can read (e.g. a file:// path). */
28
+ uri?: string;
29
+ /** Size in bytes of the file at `uri`; used to refuse an oversize file early and to decide the old-server fallback. */
30
+ size?: number;
31
+ }
32
+ /** What `POST /api/artifacts` answers for a stored file. */
33
+ interface UploadedArtifact {
34
+ hash: string;
35
+ size: number;
36
+ mimeType: string;
37
+ }
38
+ /** One raw upload the host's `FileUploader` performs. The SDK builds the URL and the headers; the host only moves the bytes. */
39
+ interface FileUploadRequest {
40
+ /** Absolute `POST` URL, query included. */
41
+ url: string;
42
+ /** Headers to send as given (bearer + `Content-Type: application/octet-stream`). */
43
+ headers: Record<string, string>;
44
+ /** The local file to send as the request BODY (not multipart). */
45
+ uri: string;
46
+ /** 0..1 as the bytes go out. */
47
+ onProgress?: (fraction: number) => void;
48
+ }
49
+ /**
50
+ * The host's file I/O for attachments: streaming a local file as a request body and reading a small one as base64. Core has
51
+ * no filesystem or native imports, so `@ateam-ai-mobile/expo` supplies the Expo implementation (`expoFileUploader`).
52
+ */
53
+ interface FileUploader {
54
+ /** Send the file at `req.uri` as the raw body; resolve with the HTTP status and body text (any status). Reject only on a transport failure. */
55
+ upload(req: FileUploadRequest): Promise<{
56
+ status: number;
57
+ body: string;
58
+ }>;
59
+ /** Read a local file as base64 (the old-server fallback, files within MAX_INLINE_ATTACHMENT_BYTES). */
60
+ readBase64(uri: string): Promise<string>;
61
+ /** Size in bytes of a local file, or undefined when it cannot be told. Used only when an attachment came without `size`,
62
+ * before any fallback read: without it a file of unknown size is refused rather than read whole. */
63
+ fileSize?(uri: string): Promise<number | undefined>;
12
64
  }
13
65
  /** Attachment as rendered in a message bubble (local or remote preview URI). */
14
66
  interface AttachmentPreview {
@@ -23,6 +75,7 @@ interface AttachmentPreview {
23
75
  interface AttachmentCache {
24
76
  /** Resolve once the index is loaded — get() before this may return undefined. */
25
77
  ready(): Promise<void>;
78
+ /** Keep a preview of each attachment (the bytes come from `data` or are copied from `uri`). */
26
79
  save(jobId: string, attachments: OutgoingAttachment[]): Promise<void>;
27
80
  get(jobId: string): AttachmentPreview[] | undefined;
28
81
  }
@@ -96,6 +149,9 @@ interface AdasConfig {
96
149
  * survive app restarts. No-op when omitted (previews live in memory for
97
150
  * the session only). @ateam-ai-mobile/ui ships an Expo/RN implementation. */
98
151
  attachmentCache?: AttachmentCache;
152
+ /** Moves an attachment's bytes for `sendMessage` (raw upload of a file `uri`). Required to attach a file by `uri`;
153
+ * without it only base64 `data` attachments can be sent. `@ateam-ai-mobile/expo` ships `expoFileUploader`. */
154
+ fileUploader?: FileUploader;
99
155
  /** Called by `switchTenant()` with the freshly-minted session for the
100
156
  * target tenant. The host MUST persist it here (store the new JWT so
101
157
  * tokenProvider.getToken() returns it, and update the active tenant) —
@@ -782,6 +838,8 @@ interface Message {
782
838
  skillSlug?: string;
783
839
  /** Attached images/files */
784
840
  attachments?: MessageAttachment[];
841
+ /** 0..1 while this message's files are still uploading; absent once they are stored and the message is posted. */
842
+ uploadProgress?: number;
785
843
  /** UI Action chips beneath assistant bubbles */
786
844
  actions?: UIAction[];
787
845
  /** Chain id from /api/conversation — used to attach live progress to the
@@ -810,25 +868,6 @@ interface ChatState {
810
868
  /** Start a fresh empty chat without re-fetching history */
811
869
  newChat: () => void;
812
870
  }
813
- /**
814
- * Sentinel delimiters used to embed structured table data inside a flat
815
- * message string. UI layers split on these and render the contents with a
816
- * native table component instead of markdown tables — markdown tables look
817
- * terrible on narrow phone screens.
818
- *
819
- * Unicode Private Use Area chars (U+E100/U+E101) so they never collide with
820
- * anything the model could legitimately emit.
821
- */
822
- declare const TABLE_BLOCK_OPEN = "\uE100";
823
- declare const TABLE_BLOCK_CLOSE = "\uE101";
824
- /**
825
- * Extract display text from a conversation turn's assistant blocks.
826
- * Handles multiple block kinds (text, code, json, markdown, table, html).
827
- */
828
- declare function blocksToText(blocks?: Array<{
829
- kind: string;
830
- content: any;
831
- }>): string;
832
871
  declare const useChatStore: zustand.UseBoundStore<zustand.StoreApi<ChatState>>;
833
872
  /** What this client can execute, supplied by the host (see setClientDeclarationProvider). */
834
873
  type ClientDeclaration = {
@@ -847,6 +886,111 @@ declare function setClientDeclarationProvider(fn: (() => ClientDeclaration | nul
847
886
  /** Tear down the live connection (env/auth switch, SDK unmount). */
848
887
  declare function closeChatStream(): void;
849
888
 
889
+ /**
890
+ * What the phone's chat bubble is handed for a reply: the blocks of a conversation turn as ONE flat string, and that string
891
+ * split back into what the bubble draws. Pure and import-free, so a test runs it in node (it used to sit in store.ts).
892
+ *
893
+ * Nothing a reply holds is dropped. This file used to throw away every json and code block that sat beside a text block (a copy of
894
+ * the web chat's March rule), so a script, a command or a diagram under the answer never reached the person. Which raw data is
895
+ * shown CLOSED is Core's call, made once, at read (backend utils/blockDisplay.js marks it `meta.display: "folded"`); this file only
896
+ * carries that mark to the bubble: a marked block's text is wrapped in the DETAILS sentinels, and the bubble draws that segment as
897
+ * a closed "Details" row. It never decides what folds.
898
+ */
899
+ /**
900
+ * Sentinel delimiters used to embed structured table data inside a flat message string. UI layers split on these and render the
901
+ * contents with a native table component instead of markdown tables, which look terrible on narrow phone screens.
902
+ *
903
+ * Unicode Private Use Area chars so they never collide with anything the model could legitimately emit.
904
+ */
905
+ declare const TABLE_BLOCK_OPEN = "\uE100";
906
+ declare const TABLE_BLOCK_CLOSE = "\uE101";
907
+ /**
908
+ * The same, for a block Core marked folded: its text (already rendered to markdown) travels between these, percent-encoded so it
909
+ * can never hold a newline or a sentinel, and the bubble draws it closed under "Details".
910
+ */
911
+ declare const DETAILS_BLOCK_OPEN = "\uE102";
912
+ declare const DETAILS_BLOCK_CLOSE = "\uE103";
913
+ /**
914
+ * The same, for a `diagram` block: a straight list of numbered steps with arrows and a colour per status word. Its payload is the
915
+ * clean `DiagramView` (below) as percent-encoded JSON, and the bubble draws it with a native component.
916
+ */
917
+ declare const DIAGRAM_BLOCK_OPEN = "\uE104";
918
+ declare const DIAGRAM_BLOCK_CLOSE = "\uE105";
919
+ /** A block of a conversation turn, as /api/conversation serves it. */
920
+ interface ConversationBlock {
921
+ kind: string;
922
+ content?: any;
923
+ language?: string;
924
+ meta?: {
925
+ display?: string;
926
+ };
927
+ }
928
+ /**
929
+ * The status words a diagram step or badge may carry; none is neutral. The same four as Core's `DIAGRAM_STATUSES` (backend
930
+ * utils/blockShape.js) and the web's (apps/frontend chat/blocks/diagramView.js): a test on each side holds the list. Colours are
931
+ * this app's own; Core never sends one.
932
+ */
933
+ declare const DIAGRAM_STATUSES: readonly ["ok", "bad", "warn", "info"];
934
+ type DiagramStatus = (typeof DIAGRAM_STATUSES)[number];
935
+ interface DiagramView {
936
+ title: string;
937
+ steps: Array<{
938
+ title: string;
939
+ text: string;
940
+ status: DiagramStatus | '';
941
+ badges: Array<{
942
+ text: string;
943
+ status: DiagramStatus | '';
944
+ }>;
945
+ }>;
946
+ }
947
+ /**
948
+ * The diagram a block holds, ready to draw, every field text; null when there is nothing to draw (fewer than 2 steps). Core sends it
949
+ * clean (`diagramOf`); this is the phone's own net, so a field of the wrong type can never reach a native <Text>.
950
+ */
951
+ declare function diagramView(content: any): DiagramView | null;
952
+ /** A diagram as readable text, the same numbered list Core gives other channels (backend `diagramToText`). */
953
+ declare function diagramAsText(d: DiagramView): string;
954
+ /**
955
+ * Extract display text from a conversation turn's blocks. Handles multiple block kinds (text, code, json, markdown, table, html).
956
+ * Every block that holds something is in the result, in order; a block Core marked `meta.display: "folded"` is wrapped in the
957
+ * DETAILS sentinels so the bubble draws it closed.
958
+ */
959
+ declare function blocksToText(blocks?: ConversationBlock[]): string;
960
+ /** One piece of a flat message string, as the bubble draws it: markdown, a table payload, a diagram payload, or a closed "Details" payload. */
961
+ interface BlockSegment {
962
+ kind: 'md' | 'table' | 'details' | 'diagram';
963
+ /** md: the markdown. table / details / diagram: the still percent-encoded payload between the sentinels. */
964
+ content: string;
965
+ }
966
+ /**
967
+ * Split a flat message string on the table, details and diagram sentinels, in order. A string with none is one markdown segment. An
968
+ * unterminated marker is kept as markdown from the marker on, so nothing is lost.
969
+ */
970
+ declare function splitBlockSegments(content: string): BlockSegment[];
971
+ /**
972
+ * The flat content of a message as the person would read it: a table is its columns and rows as lines, and a "Details" payload is
973
+ * its text. What long-press copy and a screen reader are given; the raw string holds percent-encoded payloads between private-use
974
+ * characters, which nobody should hear or paste.
975
+ */
976
+ declare function plainTextOf(content: string): string;
977
+
978
+ /** One attachment as `/api/chat` takes it: a stored file by hash, or small inline base64. */
979
+ type WireAttachment = {
980
+ hash: string;
981
+ name: string;
982
+ mimeType: string;
983
+ } | {
984
+ data: string;
985
+ mimeType: string;
986
+ name: string;
987
+ };
988
+ /**
989
+ * Upload what needs uploading and return the attachments as `/api/chat` takes them, in order.
990
+ * `onProgress` is the overall fraction 0..1 across all attachments.
991
+ */
992
+ declare function prepareAttachments(attachments: OutgoingAttachment[], onProgress?: (fraction: number) => void): Promise<WireAttachment[]>;
993
+
850
994
  /**
851
995
  * Lightweight event emitter bridging the chat job stream → plugin bridges
852
996
  * (React Native has no Node 'events' module).
@@ -1284,4 +1428,4 @@ interface AcsKvStorage {
1284
1428
  }
1285
1429
  declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
1286
1430
 
1287
- export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BufferedCommand, type ChannelPrefs, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type DeleteResult, type DevModeState, type DevicePlatform, type DispatchRow, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, type Message, type MessageAttachment, type NotifChannel, type NotifPrefs, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type QuietHoursPrefs, type RefreshOutcome, type RegisterDeviceResponse, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TelegramBotInfo, type TenantMembership, type TenantRow, type TokenProvider, type ToolCall, type UIAction, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, devModeFromCatalog, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, focusPlugin, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getPrefs as getNotifPrefs, getTelegramBotInfo as getNotifTelegramBotInfo, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, linkTelegram as linkNotifTelegram, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, nestByMaster, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, previewInvite, readDevMode, recentDispatches as recentNotifDispatches, recordEvent, refreshToken, registerHostIntent, registerDevice as registerPushDevice, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setDevMode, setHomeActionOrder, setPrefs as setNotifPrefs, setOrder, signInWithApple, signInWithGoogle, spacing, switchTenant, tenantFromToken, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
1431
+ export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BlockSegment, type BufferedCommand, type ChannelPrefs, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type ConversationBlock, DETAILS_BLOCK_CLOSE, DETAILS_BLOCK_OPEN, DIAGRAM_BLOCK_CLOSE, DIAGRAM_BLOCK_OPEN, DIAGRAM_STATUSES, type DeleteResult, type DevModeState, type DevicePlatform, type DiagramStatus, type DiagramView, type DispatchRow, type FileUploadRequest, type FileUploader, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, MAX_ATTACHMENT_BYTES, MAX_INLINE_ATTACHMENT_BYTES, type Message, type MessageAttachment, type NotifChannel, type NotifPrefs, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type QuietHoursPrefs, type RefreshOutcome, type RegisterDeviceResponse, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TelegramBotInfo, type TenantMembership, type TenantRow, type TokenProvider, type ToolCall, type UIAction, type UploadedArtifact, type WireAttachment, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, devModeFromCatalog, diagramAsText, diagramView, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, focusPlugin, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getPrefs as getNotifPrefs, getTelegramBotInfo as getNotifTelegramBotInfo, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, linkTelegram as linkNotifTelegram, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, nestByMaster, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, plainTextOf, pluginCommandEmitter, postCommandResult, prepareAttachments, previewInvite, readDevMode, recentDispatches as recentNotifDispatches, recordEvent, refreshToken, registerHostIntent, registerDevice as registerPushDevice, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setDevMode, setHomeActionOrder, setPrefs as setNotifPrefs, setOrder, signInWithApple, signInWithGoogle, spacing, splitBlockSegments, switchTenant, tenantFromToken, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
package/dist/index.d.ts CHANGED
@@ -4,11 +4,63 @@ import * as zustand from 'zustand';
4
4
  * Storage adapter contracts. The core is platform-agnostic (no Expo, no
5
5
  * AsyncStorage imports) — hosts or @ateam-ai-mobile/ui plug in concrete implementations.
6
6
  */
7
- /** Outgoing attachment as sent to /api/chat (base64 payload). */
7
+ /** The most Core stores for one file (Core's MAX_ARTIFACT_BYTES, 90 MiB: Cloudflare allows 100 MB a request). */
8
+ declare const MAX_ATTACHMENT_BYTES: number;
9
+ /**
10
+ * What the old base64-in-JSON path may carry in ONE chat message, in raw bytes (all inline attachments together). Core's
11
+ * express.json limit is 10 MB for the WHOLE /api/chat body and base64 adds a third (7 MiB becomes ~9.3 MiB), which leaves
12
+ * headroom for the text and the rest of the JSON.
13
+ */
14
+ declare const MAX_INLINE_ATTACHMENT_BYTES: number;
15
+ /**
16
+ * An attachment the user staged, as handed to `sendMessage`.
17
+ *
18
+ * A file on the phone is given by `uri` (+ `size`): it is uploaded as the raw request body to `POST /api/artifacts`, and
19
+ * `/api/chat` then names it by hash, so a 90 MB file never rides inside JSON. `data` (base64) is the older shape, kept for
20
+ * small inline attachments and as the fallback when the server is too old to take a raw upload (it answers 400).
21
+ */
8
22
  interface OutgoingAttachment {
9
- data: string;
10
23
  mimeType: string;
11
24
  name: string;
25
+ /** Base64 payload (inline path). Absent when the file is given by `uri`. */
26
+ data?: string;
27
+ /** Local file URI the host's `fileUploader` can read (e.g. a file:// path). */
28
+ uri?: string;
29
+ /** Size in bytes of the file at `uri`; used to refuse an oversize file early and to decide the old-server fallback. */
30
+ size?: number;
31
+ }
32
+ /** What `POST /api/artifacts` answers for a stored file. */
33
+ interface UploadedArtifact {
34
+ hash: string;
35
+ size: number;
36
+ mimeType: string;
37
+ }
38
+ /** One raw upload the host's `FileUploader` performs. The SDK builds the URL and the headers; the host only moves the bytes. */
39
+ interface FileUploadRequest {
40
+ /** Absolute `POST` URL, query included. */
41
+ url: string;
42
+ /** Headers to send as given (bearer + `Content-Type: application/octet-stream`). */
43
+ headers: Record<string, string>;
44
+ /** The local file to send as the request BODY (not multipart). */
45
+ uri: string;
46
+ /** 0..1 as the bytes go out. */
47
+ onProgress?: (fraction: number) => void;
48
+ }
49
+ /**
50
+ * The host's file I/O for attachments: streaming a local file as a request body and reading a small one as base64. Core has
51
+ * no filesystem or native imports, so `@ateam-ai-mobile/expo` supplies the Expo implementation (`expoFileUploader`).
52
+ */
53
+ interface FileUploader {
54
+ /** Send the file at `req.uri` as the raw body; resolve with the HTTP status and body text (any status). Reject only on a transport failure. */
55
+ upload(req: FileUploadRequest): Promise<{
56
+ status: number;
57
+ body: string;
58
+ }>;
59
+ /** Read a local file as base64 (the old-server fallback, files within MAX_INLINE_ATTACHMENT_BYTES). */
60
+ readBase64(uri: string): Promise<string>;
61
+ /** Size in bytes of a local file, or undefined when it cannot be told. Used only when an attachment came without `size`,
62
+ * before any fallback read: without it a file of unknown size is refused rather than read whole. */
63
+ fileSize?(uri: string): Promise<number | undefined>;
12
64
  }
13
65
  /** Attachment as rendered in a message bubble (local or remote preview URI). */
14
66
  interface AttachmentPreview {
@@ -23,6 +75,7 @@ interface AttachmentPreview {
23
75
  interface AttachmentCache {
24
76
  /** Resolve once the index is loaded — get() before this may return undefined. */
25
77
  ready(): Promise<void>;
78
+ /** Keep a preview of each attachment (the bytes come from `data` or are copied from `uri`). */
26
79
  save(jobId: string, attachments: OutgoingAttachment[]): Promise<void>;
27
80
  get(jobId: string): AttachmentPreview[] | undefined;
28
81
  }
@@ -96,6 +149,9 @@ interface AdasConfig {
96
149
  * survive app restarts. No-op when omitted (previews live in memory for
97
150
  * the session only). @ateam-ai-mobile/ui ships an Expo/RN implementation. */
98
151
  attachmentCache?: AttachmentCache;
152
+ /** Moves an attachment's bytes for `sendMessage` (raw upload of a file `uri`). Required to attach a file by `uri`;
153
+ * without it only base64 `data` attachments can be sent. `@ateam-ai-mobile/expo` ships `expoFileUploader`. */
154
+ fileUploader?: FileUploader;
99
155
  /** Called by `switchTenant()` with the freshly-minted session for the
100
156
  * target tenant. The host MUST persist it here (store the new JWT so
101
157
  * tokenProvider.getToken() returns it, and update the active tenant) —
@@ -782,6 +838,8 @@ interface Message {
782
838
  skillSlug?: string;
783
839
  /** Attached images/files */
784
840
  attachments?: MessageAttachment[];
841
+ /** 0..1 while this message's files are still uploading; absent once they are stored and the message is posted. */
842
+ uploadProgress?: number;
785
843
  /** UI Action chips beneath assistant bubbles */
786
844
  actions?: UIAction[];
787
845
  /** Chain id from /api/conversation — used to attach live progress to the
@@ -810,25 +868,6 @@ interface ChatState {
810
868
  /** Start a fresh empty chat without re-fetching history */
811
869
  newChat: () => void;
812
870
  }
813
- /**
814
- * Sentinel delimiters used to embed structured table data inside a flat
815
- * message string. UI layers split on these and render the contents with a
816
- * native table component instead of markdown tables — markdown tables look
817
- * terrible on narrow phone screens.
818
- *
819
- * Unicode Private Use Area chars (U+E100/U+E101) so they never collide with
820
- * anything the model could legitimately emit.
821
- */
822
- declare const TABLE_BLOCK_OPEN = "\uE100";
823
- declare const TABLE_BLOCK_CLOSE = "\uE101";
824
- /**
825
- * Extract display text from a conversation turn's assistant blocks.
826
- * Handles multiple block kinds (text, code, json, markdown, table, html).
827
- */
828
- declare function blocksToText(blocks?: Array<{
829
- kind: string;
830
- content: any;
831
- }>): string;
832
871
  declare const useChatStore: zustand.UseBoundStore<zustand.StoreApi<ChatState>>;
833
872
  /** What this client can execute, supplied by the host (see setClientDeclarationProvider). */
834
873
  type ClientDeclaration = {
@@ -847,6 +886,111 @@ declare function setClientDeclarationProvider(fn: (() => ClientDeclaration | nul
847
886
  /** Tear down the live connection (env/auth switch, SDK unmount). */
848
887
  declare function closeChatStream(): void;
849
888
 
889
+ /**
890
+ * What the phone's chat bubble is handed for a reply: the blocks of a conversation turn as ONE flat string, and that string
891
+ * split back into what the bubble draws. Pure and import-free, so a test runs it in node (it used to sit in store.ts).
892
+ *
893
+ * Nothing a reply holds is dropped. This file used to throw away every json and code block that sat beside a text block (a copy of
894
+ * the web chat's March rule), so a script, a command or a diagram under the answer never reached the person. Which raw data is
895
+ * shown CLOSED is Core's call, made once, at read (backend utils/blockDisplay.js marks it `meta.display: "folded"`); this file only
896
+ * carries that mark to the bubble: a marked block's text is wrapped in the DETAILS sentinels, and the bubble draws that segment as
897
+ * a closed "Details" row. It never decides what folds.
898
+ */
899
+ /**
900
+ * Sentinel delimiters used to embed structured table data inside a flat message string. UI layers split on these and render the
901
+ * contents with a native table component instead of markdown tables, which look terrible on narrow phone screens.
902
+ *
903
+ * Unicode Private Use Area chars so they never collide with anything the model could legitimately emit.
904
+ */
905
+ declare const TABLE_BLOCK_OPEN = "\uE100";
906
+ declare const TABLE_BLOCK_CLOSE = "\uE101";
907
+ /**
908
+ * The same, for a block Core marked folded: its text (already rendered to markdown) travels between these, percent-encoded so it
909
+ * can never hold a newline or a sentinel, and the bubble draws it closed under "Details".
910
+ */
911
+ declare const DETAILS_BLOCK_OPEN = "\uE102";
912
+ declare const DETAILS_BLOCK_CLOSE = "\uE103";
913
+ /**
914
+ * The same, for a `diagram` block: a straight list of numbered steps with arrows and a colour per status word. Its payload is the
915
+ * clean `DiagramView` (below) as percent-encoded JSON, and the bubble draws it with a native component.
916
+ */
917
+ declare const DIAGRAM_BLOCK_OPEN = "\uE104";
918
+ declare const DIAGRAM_BLOCK_CLOSE = "\uE105";
919
+ /** A block of a conversation turn, as /api/conversation serves it. */
920
+ interface ConversationBlock {
921
+ kind: string;
922
+ content?: any;
923
+ language?: string;
924
+ meta?: {
925
+ display?: string;
926
+ };
927
+ }
928
+ /**
929
+ * The status words a diagram step or badge may carry; none is neutral. The same four as Core's `DIAGRAM_STATUSES` (backend
930
+ * utils/blockShape.js) and the web's (apps/frontend chat/blocks/diagramView.js): a test on each side holds the list. Colours are
931
+ * this app's own; Core never sends one.
932
+ */
933
+ declare const DIAGRAM_STATUSES: readonly ["ok", "bad", "warn", "info"];
934
+ type DiagramStatus = (typeof DIAGRAM_STATUSES)[number];
935
+ interface DiagramView {
936
+ title: string;
937
+ steps: Array<{
938
+ title: string;
939
+ text: string;
940
+ status: DiagramStatus | '';
941
+ badges: Array<{
942
+ text: string;
943
+ status: DiagramStatus | '';
944
+ }>;
945
+ }>;
946
+ }
947
+ /**
948
+ * The diagram a block holds, ready to draw, every field text; null when there is nothing to draw (fewer than 2 steps). Core sends it
949
+ * clean (`diagramOf`); this is the phone's own net, so a field of the wrong type can never reach a native <Text>.
950
+ */
951
+ declare function diagramView(content: any): DiagramView | null;
952
+ /** A diagram as readable text, the same numbered list Core gives other channels (backend `diagramToText`). */
953
+ declare function diagramAsText(d: DiagramView): string;
954
+ /**
955
+ * Extract display text from a conversation turn's blocks. Handles multiple block kinds (text, code, json, markdown, table, html).
956
+ * Every block that holds something is in the result, in order; a block Core marked `meta.display: "folded"` is wrapped in the
957
+ * DETAILS sentinels so the bubble draws it closed.
958
+ */
959
+ declare function blocksToText(blocks?: ConversationBlock[]): string;
960
+ /** One piece of a flat message string, as the bubble draws it: markdown, a table payload, a diagram payload, or a closed "Details" payload. */
961
+ interface BlockSegment {
962
+ kind: 'md' | 'table' | 'details' | 'diagram';
963
+ /** md: the markdown. table / details / diagram: the still percent-encoded payload between the sentinels. */
964
+ content: string;
965
+ }
966
+ /**
967
+ * Split a flat message string on the table, details and diagram sentinels, in order. A string with none is one markdown segment. An
968
+ * unterminated marker is kept as markdown from the marker on, so nothing is lost.
969
+ */
970
+ declare function splitBlockSegments(content: string): BlockSegment[];
971
+ /**
972
+ * The flat content of a message as the person would read it: a table is its columns and rows as lines, and a "Details" payload is
973
+ * its text. What long-press copy and a screen reader are given; the raw string holds percent-encoded payloads between private-use
974
+ * characters, which nobody should hear or paste.
975
+ */
976
+ declare function plainTextOf(content: string): string;
977
+
978
+ /** One attachment as `/api/chat` takes it: a stored file by hash, or small inline base64. */
979
+ type WireAttachment = {
980
+ hash: string;
981
+ name: string;
982
+ mimeType: string;
983
+ } | {
984
+ data: string;
985
+ mimeType: string;
986
+ name: string;
987
+ };
988
+ /**
989
+ * Upload what needs uploading and return the attachments as `/api/chat` takes them, in order.
990
+ * `onProgress` is the overall fraction 0..1 across all attachments.
991
+ */
992
+ declare function prepareAttachments(attachments: OutgoingAttachment[], onProgress?: (fraction: number) => void): Promise<WireAttachment[]>;
993
+
850
994
  /**
851
995
  * Lightweight event emitter bridging the chat job stream → plugin bridges
852
996
  * (React Native has no Node 'events' module).
@@ -1284,4 +1428,4 @@ interface AcsKvStorage {
1284
1428
  }
1285
1429
  declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
1286
1430
 
1287
- export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BufferedCommand, type ChannelPrefs, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type DeleteResult, type DevModeState, type DevicePlatform, type DispatchRow, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, type Message, type MessageAttachment, type NotifChannel, type NotifPrefs, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type QuietHoursPrefs, type RefreshOutcome, type RegisterDeviceResponse, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TelegramBotInfo, type TenantMembership, type TenantRow, type TokenProvider, type ToolCall, type UIAction, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, devModeFromCatalog, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, focusPlugin, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getPrefs as getNotifPrefs, getTelegramBotInfo as getNotifTelegramBotInfo, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, linkTelegram as linkNotifTelegram, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, nestByMaster, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, previewInvite, readDevMode, recentDispatches as recentNotifDispatches, recordEvent, refreshToken, registerHostIntent, registerDevice as registerPushDevice, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setDevMode, setHomeActionOrder, setPrefs as setNotifPrefs, setOrder, signInWithApple, signInWithGoogle, spacing, switchTenant, tenantFromToken, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
1431
+ export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BlockSegment, type BufferedCommand, type ChannelPrefs, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type ConversationBlock, DETAILS_BLOCK_CLOSE, DETAILS_BLOCK_OPEN, DIAGRAM_BLOCK_CLOSE, DIAGRAM_BLOCK_OPEN, DIAGRAM_STATUSES, type DeleteResult, type DevModeState, type DevicePlatform, type DiagramStatus, type DiagramView, type DispatchRow, type FileUploadRequest, type FileUploader, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, MAX_ATTACHMENT_BYTES, MAX_INLINE_ATTACHMENT_BYTES, type Message, type MessageAttachment, type NotifChannel, type NotifPrefs, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type QuietHoursPrefs, type RefreshOutcome, type RegisterDeviceResponse, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TelegramBotInfo, type TenantMembership, type TenantRow, type TokenProvider, type ToolCall, type UIAction, type UploadedArtifact, type WireAttachment, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, devModeFromCatalog, diagramAsText, diagramView, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, focusPlugin, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getPrefs as getNotifPrefs, getTelegramBotInfo as getNotifTelegramBotInfo, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, linkTelegram as linkNotifTelegram, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, nestByMaster, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, plainTextOf, pluginCommandEmitter, postCommandResult, prepareAttachments, previewInvite, readDevMode, recentDispatches as recentNotifDispatches, recordEvent, refreshToken, registerHostIntent, registerDevice as registerPushDevice, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setDevMode, setHomeActionOrder, setPrefs as setNotifPrefs, setOrder, signInWithApple, signInWithGoogle, spacing, splitBlockSegments, switchTenant, tenantFromToken, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };