@ateam-ai-mobile/core 0.1.33 → 0.1.37
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 +202 -20
- package/dist/index.d.ts +202 -20
- package/dist/index.js +343 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/blockText.ts +459 -0
- package/src/chat/store.ts +1 -70
- package/src/index.ts +42 -1
package/dist/index.d.mts
CHANGED
|
@@ -868,25 +868,6 @@ interface ChatState {
|
|
|
868
868
|
/** Start a fresh empty chat without re-fetching history */
|
|
869
869
|
newChat: () => void;
|
|
870
870
|
}
|
|
871
|
-
/**
|
|
872
|
-
* Sentinel delimiters used to embed structured table data inside a flat
|
|
873
|
-
* message string. UI layers split on these and render the contents with a
|
|
874
|
-
* native table component instead of markdown tables — markdown tables look
|
|
875
|
-
* terrible on narrow phone screens.
|
|
876
|
-
*
|
|
877
|
-
* Unicode Private Use Area chars (U+E100/U+E101) so they never collide with
|
|
878
|
-
* anything the model could legitimately emit.
|
|
879
|
-
*/
|
|
880
|
-
declare const TABLE_BLOCK_OPEN = "\uE100";
|
|
881
|
-
declare const TABLE_BLOCK_CLOSE = "\uE101";
|
|
882
|
-
/**
|
|
883
|
-
* Extract display text from a conversation turn's assistant blocks.
|
|
884
|
-
* Handles multiple block kinds (text, code, json, markdown, table, html).
|
|
885
|
-
*/
|
|
886
|
-
declare function blocksToText(blocks?: Array<{
|
|
887
|
-
kind: string;
|
|
888
|
-
content: any;
|
|
889
|
-
}>): string;
|
|
890
871
|
declare const useChatStore: zustand.UseBoundStore<zustand.StoreApi<ChatState>>;
|
|
891
872
|
/** What this client can execute, supplied by the host (see setClientDeclarationProvider). */
|
|
892
873
|
type ClientDeclaration = {
|
|
@@ -905,6 +886,207 @@ declare function setClientDeclarationProvider(fn: (() => ClientDeclaration | nul
|
|
|
905
886
|
/** Tear down the live connection (env/auth switch, SDK unmount). */
|
|
906
887
|
declare function closeChatStream(): void;
|
|
907
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
|
+
/** The same for the other visual kinds (the registry `VISUALS` below says which is which): chart, comparison, timeline. */
|
|
920
|
+
declare const CHART_BLOCK_OPEN = "\uE106";
|
|
921
|
+
declare const CHART_BLOCK_CLOSE = "\uE107";
|
|
922
|
+
declare const COMPARISON_BLOCK_OPEN = "\uE108";
|
|
923
|
+
declare const COMPARISON_BLOCK_CLOSE = "\uE109";
|
|
924
|
+
declare const TIMELINE_BLOCK_OPEN = "\uE10A";
|
|
925
|
+
declare const TIMELINE_BLOCK_CLOSE = "\uE10B";
|
|
926
|
+
/** A block of a conversation turn, as /api/conversation serves it. */
|
|
927
|
+
interface ConversationBlock {
|
|
928
|
+
kind: string;
|
|
929
|
+
content?: any;
|
|
930
|
+
language?: string;
|
|
931
|
+
meta?: {
|
|
932
|
+
display?: string;
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* The status words a diagram step or badge may carry; none is neutral. The same four as Core's `DIAGRAM_STATUSES` (backend
|
|
937
|
+
* utils/blockShape.js) and the web's (apps/frontend chat/blocks/diagramView.js): a test on each side holds the list. Colours are
|
|
938
|
+
* this app's own; Core never sends one.
|
|
939
|
+
*/
|
|
940
|
+
declare const DIAGRAM_STATUSES: readonly ["ok", "bad", "warn", "info"];
|
|
941
|
+
type DiagramStatus = (typeof DIAGRAM_STATUSES)[number];
|
|
942
|
+
interface DiagramStep {
|
|
943
|
+
title: string;
|
|
944
|
+
text: string;
|
|
945
|
+
status: DiagramStatus | '';
|
|
946
|
+
badges: Array<{
|
|
947
|
+
text: string;
|
|
948
|
+
status: DiagramStatus | '';
|
|
949
|
+
}>;
|
|
950
|
+
/** A decision (a gate): drawn as a dashed card with a diamond number. */
|
|
951
|
+
decision: boolean;
|
|
952
|
+
/**
|
|
953
|
+
* The ways out of this step, `to` a 1-based step number. null = the natural arrow to the following step (a straight list is all
|
|
954
|
+
* null). [] = an end. Core settles them (backend `diagramOf`); this is the phone's net.
|
|
955
|
+
*/
|
|
956
|
+
next: Array<{
|
|
957
|
+
to: number;
|
|
958
|
+
label: string;
|
|
959
|
+
}> | null;
|
|
960
|
+
}
|
|
961
|
+
interface DiagramView {
|
|
962
|
+
title: string;
|
|
963
|
+
steps: DiagramStep[];
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* 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
|
|
967
|
+
* clean (`diagramOf`); this is the phone's own net, so a field of the wrong type can never reach a native <Text>, and a way out that
|
|
968
|
+
* points at a step that is not there is dropped (the numbers follow the steps that remain).
|
|
969
|
+
*/
|
|
970
|
+
declare function diagramView(content: any): DiagramView | null;
|
|
971
|
+
/** Where each arrow of a step is drawn: the arrow down to the next step, the jumps ahead, the loops back. */
|
|
972
|
+
interface DiagramFlow {
|
|
973
|
+
/** The arrow to the following step, with its label ('' = none); null = no arrow (this step does not flow into the next). */
|
|
974
|
+
arrow: {
|
|
975
|
+
label: string;
|
|
976
|
+
} | null;
|
|
977
|
+
/** Ways out that skip ahead: drawn as a "Go to step N" pill under the step. */
|
|
978
|
+
jumps: Array<{
|
|
979
|
+
to: number;
|
|
980
|
+
label: string;
|
|
981
|
+
}>;
|
|
982
|
+
/** Ways out that go back to an earlier step: drawn as a loop in the margin. */
|
|
983
|
+
loops: Array<{
|
|
984
|
+
to: number;
|
|
985
|
+
label: string;
|
|
986
|
+
}>;
|
|
987
|
+
}
|
|
988
|
+
/** The ONE layout rule for the phone and the web: natural arrow, forward jumps, back loops. */
|
|
989
|
+
declare function diagramFlow(view: DiagramView): DiagramFlow[];
|
|
990
|
+
/** A diagram as readable text, the same list Core gives other channels (backend `diagramToText`). */
|
|
991
|
+
declare function diagramAsText(d: DiagramView): string;
|
|
992
|
+
/** How a number is written on a chart and in its text form: at most 2 decimals (0.1 + 0.2 is 0.3), the same as Core's text form. */
|
|
993
|
+
declare const numText: (n: number) => string;
|
|
994
|
+
interface ChartSeries {
|
|
995
|
+
name: string;
|
|
996
|
+
values: number[];
|
|
997
|
+
}
|
|
998
|
+
interface ChartView {
|
|
999
|
+
title: string;
|
|
1000
|
+
type: 'bar' | 'line';
|
|
1001
|
+
labels: string[];
|
|
1002
|
+
series: ChartSeries[];
|
|
1003
|
+
unit: string;
|
|
1004
|
+
/** One of the labels, or ''. */
|
|
1005
|
+
highlight: string;
|
|
1006
|
+
}
|
|
1007
|
+
/** The chart a block holds, ready to draw; null when there is nothing to draw (fewer than 2 points, or no readable series). */
|
|
1008
|
+
declare function chartView(content: any): ChartView | null;
|
|
1009
|
+
/** Where values sit between the baseline and the top: always spans zero, so a bar grows from a zero line; a flat chart still has a span. */
|
|
1010
|
+
declare function chartScale(view: ChartView): {
|
|
1011
|
+
lo: number;
|
|
1012
|
+
hi: number;
|
|
1013
|
+
};
|
|
1014
|
+
declare function chartAsText(view: ChartView): string;
|
|
1015
|
+
interface ComparisonRow {
|
|
1016
|
+
text: string;
|
|
1017
|
+
ok: boolean | null;
|
|
1018
|
+
}
|
|
1019
|
+
interface ComparisonOption {
|
|
1020
|
+
name: string;
|
|
1021
|
+
price: string;
|
|
1022
|
+
badge: string;
|
|
1023
|
+
best: boolean;
|
|
1024
|
+
rows: ComparisonRow[];
|
|
1025
|
+
}
|
|
1026
|
+
interface ComparisonView {
|
|
1027
|
+
title: string;
|
|
1028
|
+
options: ComparisonOption[];
|
|
1029
|
+
}
|
|
1030
|
+
/** The comparison a block holds (2 or 3 options, at most one best); null when there is nothing to draw. */
|
|
1031
|
+
declare function comparisonView(content: any): ComparisonView | null;
|
|
1032
|
+
declare function comparisonAsText(view: ComparisonView): string;
|
|
1033
|
+
interface TimelineEvent {
|
|
1034
|
+
time: string;
|
|
1035
|
+
text: string;
|
|
1036
|
+
}
|
|
1037
|
+
interface TimelineDay {
|
|
1038
|
+
title: string;
|
|
1039
|
+
events: TimelineEvent[];
|
|
1040
|
+
}
|
|
1041
|
+
interface TimelineView {
|
|
1042
|
+
title: string;
|
|
1043
|
+
subtitle: string;
|
|
1044
|
+
days: TimelineDay[];
|
|
1045
|
+
}
|
|
1046
|
+
/** The timeline a block holds; null when there is nothing to draw (fewer than 2 events in all). */
|
|
1047
|
+
declare function timelineView(content: any): TimelineView | null;
|
|
1048
|
+
declare function timelineAsText(view: TimelineView): string;
|
|
1049
|
+
/** The visual block kinds the phone draws, each between its own pair of sentinels. Same four as Core's `VISUALS` (backend utils/blockShape.js). */
|
|
1050
|
+
type VisualKind = 'diagram' | 'chart' | 'comparison' | 'timeline';
|
|
1051
|
+
/**
|
|
1052
|
+
* THE REGISTRY of visual kinds on the phone: for each, its sentinels, the net that reads the content into a clean view (null when
|
|
1053
|
+
* there is nothing to draw), and the view's text form (what copy and a screen reader are given). A new kind is one more entry here,
|
|
1054
|
+
* one component in the UI package (`VISUAL_BLOCKS`), and one in Core; nothing else names a visual.
|
|
1055
|
+
*/
|
|
1056
|
+
declare const VISUALS: Record<VisualKind, {
|
|
1057
|
+
open: string;
|
|
1058
|
+
close: string;
|
|
1059
|
+
view: (content: any) => any | null;
|
|
1060
|
+
asText: (view: any) => string;
|
|
1061
|
+
}>;
|
|
1062
|
+
/** Whether a block kind is a visual the phone knows. */
|
|
1063
|
+
declare const isVisualKind: (kind: any) => kind is VisualKind;
|
|
1064
|
+
/** The clean view inside a visual segment's payload (still percent-encoded, as `splitBlockSegments` gives it), or null when it cannot be read. */
|
|
1065
|
+
declare function visualViewOf(kind: VisualKind, payload: string): any | null;
|
|
1066
|
+
/**
|
|
1067
|
+
* Extract display text from a conversation turn's blocks. Handles multiple block kinds (text, code, json, markdown, table, html).
|
|
1068
|
+
* Every block that holds something is in the result, in order; a block Core marked `meta.display: "folded"` is wrapped in the
|
|
1069
|
+
* DETAILS sentinels so the bubble draws it closed.
|
|
1070
|
+
*/
|
|
1071
|
+
declare function blocksToText(blocks?: ConversationBlock[]): string;
|
|
1072
|
+
/** One piece of a flat message string, as the bubble draws it: markdown, a table payload, a visual payload, or a closed "Details" payload. */
|
|
1073
|
+
interface BlockSegment {
|
|
1074
|
+
kind: 'md' | 'table' | 'details' | VisualKind;
|
|
1075
|
+
/** md: the markdown. table / details / a visual: the still percent-encoded payload between the sentinels. */
|
|
1076
|
+
content: string;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Split a flat message string on the table, details and visual sentinels, in order. A string with none is one markdown segment. An
|
|
1080
|
+
* unterminated marker is kept as markdown from the marker on, so nothing is lost.
|
|
1081
|
+
*/
|
|
1082
|
+
declare function splitBlockSegments(content: string): BlockSegment[];
|
|
1083
|
+
/**
|
|
1084
|
+
* 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
|
|
1085
|
+
* its text. What long-press copy and a screen reader are given; the raw string holds percent-encoded payloads between private-use
|
|
1086
|
+
* characters, which nobody should hear or paste.
|
|
1087
|
+
*/
|
|
1088
|
+
declare function plainTextOf(content: string): string;
|
|
1089
|
+
|
|
908
1090
|
/** One attachment as `/api/chat` takes it: a stored file by hash, or small inline base64. */
|
|
909
1091
|
type WireAttachment = {
|
|
910
1092
|
hash: string;
|
|
@@ -1358,4 +1540,4 @@ interface AcsKvStorage {
|
|
|
1358
1540
|
}
|
|
1359
1541
|
declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
|
|
1360
1542
|
|
|
1361
|
-
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 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, 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, 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, switchTenant, tenantFromToken, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
|
|
1543
|
+
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, CHART_BLOCK_CLOSE, CHART_BLOCK_OPEN, COMPARISON_BLOCK_CLOSE, COMPARISON_BLOCK_OPEN, type ChannelPrefs, type ChartSeries, type ChartView, type ComparisonOption, type ComparisonRow, type ComparisonView, 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 DiagramFlow, type DiagramStatus, type DiagramStep, 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, TIMELINE_BLOCK_CLOSE, TIMELINE_BLOCK_OPEN, type TelegramBotInfo, type TenantMembership, type TenantRow, type TimelineDay, type TimelineEvent, type TimelineView, type TokenProvider, type ToolCall, type UIAction, type UploadedArtifact, VISUALS, type VisualKind, type WireAttachment, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, chartAsText, chartScale, chartView, closeChatStream, colors, comparisonAsText, comparisonView, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, devModeFromCatalog, diagramAsText, diagramFlow, diagramView, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, focusPlugin, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getPrefs as getNotifPrefs, getTelegramBotInfo as getNotifTelegramBotInfo, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, isVisualKind, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, linkTelegram as linkNotifTelegram, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, nestByMaster, notifyAcsWsForeground, notifyAppForeground, numText, 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, timelineAsText, timelineView, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt, visualViewOf };
|
package/dist/index.d.ts
CHANGED
|
@@ -868,25 +868,6 @@ interface ChatState {
|
|
|
868
868
|
/** Start a fresh empty chat without re-fetching history */
|
|
869
869
|
newChat: () => void;
|
|
870
870
|
}
|
|
871
|
-
/**
|
|
872
|
-
* Sentinel delimiters used to embed structured table data inside a flat
|
|
873
|
-
* message string. UI layers split on these and render the contents with a
|
|
874
|
-
* native table component instead of markdown tables — markdown tables look
|
|
875
|
-
* terrible on narrow phone screens.
|
|
876
|
-
*
|
|
877
|
-
* Unicode Private Use Area chars (U+E100/U+E101) so they never collide with
|
|
878
|
-
* anything the model could legitimately emit.
|
|
879
|
-
*/
|
|
880
|
-
declare const TABLE_BLOCK_OPEN = "\uE100";
|
|
881
|
-
declare const TABLE_BLOCK_CLOSE = "\uE101";
|
|
882
|
-
/**
|
|
883
|
-
* Extract display text from a conversation turn's assistant blocks.
|
|
884
|
-
* Handles multiple block kinds (text, code, json, markdown, table, html).
|
|
885
|
-
*/
|
|
886
|
-
declare function blocksToText(blocks?: Array<{
|
|
887
|
-
kind: string;
|
|
888
|
-
content: any;
|
|
889
|
-
}>): string;
|
|
890
871
|
declare const useChatStore: zustand.UseBoundStore<zustand.StoreApi<ChatState>>;
|
|
891
872
|
/** What this client can execute, supplied by the host (see setClientDeclarationProvider). */
|
|
892
873
|
type ClientDeclaration = {
|
|
@@ -905,6 +886,207 @@ declare function setClientDeclarationProvider(fn: (() => ClientDeclaration | nul
|
|
|
905
886
|
/** Tear down the live connection (env/auth switch, SDK unmount). */
|
|
906
887
|
declare function closeChatStream(): void;
|
|
907
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
|
+
/** The same for the other visual kinds (the registry `VISUALS` below says which is which): chart, comparison, timeline. */
|
|
920
|
+
declare const CHART_BLOCK_OPEN = "\uE106";
|
|
921
|
+
declare const CHART_BLOCK_CLOSE = "\uE107";
|
|
922
|
+
declare const COMPARISON_BLOCK_OPEN = "\uE108";
|
|
923
|
+
declare const COMPARISON_BLOCK_CLOSE = "\uE109";
|
|
924
|
+
declare const TIMELINE_BLOCK_OPEN = "\uE10A";
|
|
925
|
+
declare const TIMELINE_BLOCK_CLOSE = "\uE10B";
|
|
926
|
+
/** A block of a conversation turn, as /api/conversation serves it. */
|
|
927
|
+
interface ConversationBlock {
|
|
928
|
+
kind: string;
|
|
929
|
+
content?: any;
|
|
930
|
+
language?: string;
|
|
931
|
+
meta?: {
|
|
932
|
+
display?: string;
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* The status words a diagram step or badge may carry; none is neutral. The same four as Core's `DIAGRAM_STATUSES` (backend
|
|
937
|
+
* utils/blockShape.js) and the web's (apps/frontend chat/blocks/diagramView.js): a test on each side holds the list. Colours are
|
|
938
|
+
* this app's own; Core never sends one.
|
|
939
|
+
*/
|
|
940
|
+
declare const DIAGRAM_STATUSES: readonly ["ok", "bad", "warn", "info"];
|
|
941
|
+
type DiagramStatus = (typeof DIAGRAM_STATUSES)[number];
|
|
942
|
+
interface DiagramStep {
|
|
943
|
+
title: string;
|
|
944
|
+
text: string;
|
|
945
|
+
status: DiagramStatus | '';
|
|
946
|
+
badges: Array<{
|
|
947
|
+
text: string;
|
|
948
|
+
status: DiagramStatus | '';
|
|
949
|
+
}>;
|
|
950
|
+
/** A decision (a gate): drawn as a dashed card with a diamond number. */
|
|
951
|
+
decision: boolean;
|
|
952
|
+
/**
|
|
953
|
+
* The ways out of this step, `to` a 1-based step number. null = the natural arrow to the following step (a straight list is all
|
|
954
|
+
* null). [] = an end. Core settles them (backend `diagramOf`); this is the phone's net.
|
|
955
|
+
*/
|
|
956
|
+
next: Array<{
|
|
957
|
+
to: number;
|
|
958
|
+
label: string;
|
|
959
|
+
}> | null;
|
|
960
|
+
}
|
|
961
|
+
interface DiagramView {
|
|
962
|
+
title: string;
|
|
963
|
+
steps: DiagramStep[];
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* 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
|
|
967
|
+
* clean (`diagramOf`); this is the phone's own net, so a field of the wrong type can never reach a native <Text>, and a way out that
|
|
968
|
+
* points at a step that is not there is dropped (the numbers follow the steps that remain).
|
|
969
|
+
*/
|
|
970
|
+
declare function diagramView(content: any): DiagramView | null;
|
|
971
|
+
/** Where each arrow of a step is drawn: the arrow down to the next step, the jumps ahead, the loops back. */
|
|
972
|
+
interface DiagramFlow {
|
|
973
|
+
/** The arrow to the following step, with its label ('' = none); null = no arrow (this step does not flow into the next). */
|
|
974
|
+
arrow: {
|
|
975
|
+
label: string;
|
|
976
|
+
} | null;
|
|
977
|
+
/** Ways out that skip ahead: drawn as a "Go to step N" pill under the step. */
|
|
978
|
+
jumps: Array<{
|
|
979
|
+
to: number;
|
|
980
|
+
label: string;
|
|
981
|
+
}>;
|
|
982
|
+
/** Ways out that go back to an earlier step: drawn as a loop in the margin. */
|
|
983
|
+
loops: Array<{
|
|
984
|
+
to: number;
|
|
985
|
+
label: string;
|
|
986
|
+
}>;
|
|
987
|
+
}
|
|
988
|
+
/** The ONE layout rule for the phone and the web: natural arrow, forward jumps, back loops. */
|
|
989
|
+
declare function diagramFlow(view: DiagramView): DiagramFlow[];
|
|
990
|
+
/** A diagram as readable text, the same list Core gives other channels (backend `diagramToText`). */
|
|
991
|
+
declare function diagramAsText(d: DiagramView): string;
|
|
992
|
+
/** How a number is written on a chart and in its text form: at most 2 decimals (0.1 + 0.2 is 0.3), the same as Core's text form. */
|
|
993
|
+
declare const numText: (n: number) => string;
|
|
994
|
+
interface ChartSeries {
|
|
995
|
+
name: string;
|
|
996
|
+
values: number[];
|
|
997
|
+
}
|
|
998
|
+
interface ChartView {
|
|
999
|
+
title: string;
|
|
1000
|
+
type: 'bar' | 'line';
|
|
1001
|
+
labels: string[];
|
|
1002
|
+
series: ChartSeries[];
|
|
1003
|
+
unit: string;
|
|
1004
|
+
/** One of the labels, or ''. */
|
|
1005
|
+
highlight: string;
|
|
1006
|
+
}
|
|
1007
|
+
/** The chart a block holds, ready to draw; null when there is nothing to draw (fewer than 2 points, or no readable series). */
|
|
1008
|
+
declare function chartView(content: any): ChartView | null;
|
|
1009
|
+
/** Where values sit between the baseline and the top: always spans zero, so a bar grows from a zero line; a flat chart still has a span. */
|
|
1010
|
+
declare function chartScale(view: ChartView): {
|
|
1011
|
+
lo: number;
|
|
1012
|
+
hi: number;
|
|
1013
|
+
};
|
|
1014
|
+
declare function chartAsText(view: ChartView): string;
|
|
1015
|
+
interface ComparisonRow {
|
|
1016
|
+
text: string;
|
|
1017
|
+
ok: boolean | null;
|
|
1018
|
+
}
|
|
1019
|
+
interface ComparisonOption {
|
|
1020
|
+
name: string;
|
|
1021
|
+
price: string;
|
|
1022
|
+
badge: string;
|
|
1023
|
+
best: boolean;
|
|
1024
|
+
rows: ComparisonRow[];
|
|
1025
|
+
}
|
|
1026
|
+
interface ComparisonView {
|
|
1027
|
+
title: string;
|
|
1028
|
+
options: ComparisonOption[];
|
|
1029
|
+
}
|
|
1030
|
+
/** The comparison a block holds (2 or 3 options, at most one best); null when there is nothing to draw. */
|
|
1031
|
+
declare function comparisonView(content: any): ComparisonView | null;
|
|
1032
|
+
declare function comparisonAsText(view: ComparisonView): string;
|
|
1033
|
+
interface TimelineEvent {
|
|
1034
|
+
time: string;
|
|
1035
|
+
text: string;
|
|
1036
|
+
}
|
|
1037
|
+
interface TimelineDay {
|
|
1038
|
+
title: string;
|
|
1039
|
+
events: TimelineEvent[];
|
|
1040
|
+
}
|
|
1041
|
+
interface TimelineView {
|
|
1042
|
+
title: string;
|
|
1043
|
+
subtitle: string;
|
|
1044
|
+
days: TimelineDay[];
|
|
1045
|
+
}
|
|
1046
|
+
/** The timeline a block holds; null when there is nothing to draw (fewer than 2 events in all). */
|
|
1047
|
+
declare function timelineView(content: any): TimelineView | null;
|
|
1048
|
+
declare function timelineAsText(view: TimelineView): string;
|
|
1049
|
+
/** The visual block kinds the phone draws, each between its own pair of sentinels. Same four as Core's `VISUALS` (backend utils/blockShape.js). */
|
|
1050
|
+
type VisualKind = 'diagram' | 'chart' | 'comparison' | 'timeline';
|
|
1051
|
+
/**
|
|
1052
|
+
* THE REGISTRY of visual kinds on the phone: for each, its sentinels, the net that reads the content into a clean view (null when
|
|
1053
|
+
* there is nothing to draw), and the view's text form (what copy and a screen reader are given). A new kind is one more entry here,
|
|
1054
|
+
* one component in the UI package (`VISUAL_BLOCKS`), and one in Core; nothing else names a visual.
|
|
1055
|
+
*/
|
|
1056
|
+
declare const VISUALS: Record<VisualKind, {
|
|
1057
|
+
open: string;
|
|
1058
|
+
close: string;
|
|
1059
|
+
view: (content: any) => any | null;
|
|
1060
|
+
asText: (view: any) => string;
|
|
1061
|
+
}>;
|
|
1062
|
+
/** Whether a block kind is a visual the phone knows. */
|
|
1063
|
+
declare const isVisualKind: (kind: any) => kind is VisualKind;
|
|
1064
|
+
/** The clean view inside a visual segment's payload (still percent-encoded, as `splitBlockSegments` gives it), or null when it cannot be read. */
|
|
1065
|
+
declare function visualViewOf(kind: VisualKind, payload: string): any | null;
|
|
1066
|
+
/**
|
|
1067
|
+
* Extract display text from a conversation turn's blocks. Handles multiple block kinds (text, code, json, markdown, table, html).
|
|
1068
|
+
* Every block that holds something is in the result, in order; a block Core marked `meta.display: "folded"` is wrapped in the
|
|
1069
|
+
* DETAILS sentinels so the bubble draws it closed.
|
|
1070
|
+
*/
|
|
1071
|
+
declare function blocksToText(blocks?: ConversationBlock[]): string;
|
|
1072
|
+
/** One piece of a flat message string, as the bubble draws it: markdown, a table payload, a visual payload, or a closed "Details" payload. */
|
|
1073
|
+
interface BlockSegment {
|
|
1074
|
+
kind: 'md' | 'table' | 'details' | VisualKind;
|
|
1075
|
+
/** md: the markdown. table / details / a visual: the still percent-encoded payload between the sentinels. */
|
|
1076
|
+
content: string;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Split a flat message string on the table, details and visual sentinels, in order. A string with none is one markdown segment. An
|
|
1080
|
+
* unterminated marker is kept as markdown from the marker on, so nothing is lost.
|
|
1081
|
+
*/
|
|
1082
|
+
declare function splitBlockSegments(content: string): BlockSegment[];
|
|
1083
|
+
/**
|
|
1084
|
+
* 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
|
|
1085
|
+
* its text. What long-press copy and a screen reader are given; the raw string holds percent-encoded payloads between private-use
|
|
1086
|
+
* characters, which nobody should hear or paste.
|
|
1087
|
+
*/
|
|
1088
|
+
declare function plainTextOf(content: string): string;
|
|
1089
|
+
|
|
908
1090
|
/** One attachment as `/api/chat` takes it: a stored file by hash, or small inline base64. */
|
|
909
1091
|
type WireAttachment = {
|
|
910
1092
|
hash: string;
|
|
@@ -1358,4 +1540,4 @@ interface AcsKvStorage {
|
|
|
1358
1540
|
}
|
|
1359
1541
|
declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
|
|
1360
1542
|
|
|
1361
|
-
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 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, 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, 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, switchTenant, tenantFromToken, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
|
|
1543
|
+
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, CHART_BLOCK_CLOSE, CHART_BLOCK_OPEN, COMPARISON_BLOCK_CLOSE, COMPARISON_BLOCK_OPEN, type ChannelPrefs, type ChartSeries, type ChartView, type ComparisonOption, type ComparisonRow, type ComparisonView, 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 DiagramFlow, type DiagramStatus, type DiagramStep, 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, TIMELINE_BLOCK_CLOSE, TIMELINE_BLOCK_OPEN, type TelegramBotInfo, type TenantMembership, type TenantRow, type TimelineDay, type TimelineEvent, type TimelineView, type TokenProvider, type ToolCall, type UIAction, type UploadedArtifact, VISUALS, type VisualKind, type WireAttachment, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, chartAsText, chartScale, chartView, closeChatStream, colors, comparisonAsText, comparisonView, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, devModeFromCatalog, diagramAsText, diagramFlow, diagramView, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, focusPlugin, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getPrefs as getNotifPrefs, getTelegramBotInfo as getNotifTelegramBotInfo, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, isVisualKind, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, linkTelegram as linkNotifTelegram, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, nestByMaster, notifyAcsWsForeground, notifyAppForeground, numText, 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, timelineAsText, timelineView, unlinkChannel as unlinkNotifChannel, unregisterDevice as unregisterPushDevice, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt, visualViewOf };
|