react-semaphor 0.1.537 → 0.1.539

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.
Files changed (174) hide show
  1. package/dist/analytics-protocol/index.js +352 -341
  2. package/dist/assistant-context/index.js +10 -0
  3. package/dist/assistant-protocol/index.js +104 -0
  4. package/dist/brand-studio/index.js +35 -31
  5. package/dist/briefings/index.js +46 -45
  6. package/dist/chunks/_commonjsHelpers-BkfeUUK-.js +28 -0
  7. package/dist/chunks/add-to-dashboard-CxtTfISD.js +56 -0
  8. package/dist/chunks/aggregate-table-row-presentation-BjK9YfMI.js +979 -0
  9. package/dist/chunks/analytics-base-schemas-BFAoRlkU.js +472 -0
  10. package/dist/chunks/apply-dashboard-operations-C-iahGka.js +402 -0
  11. package/dist/chunks/assistant-chat-DgiSuFT4.js +8083 -0
  12. package/dist/chunks/availability-Bp5Gfu1I.js +44 -0
  13. package/dist/chunks/{bookmark-state-B-I9BDD0.js → bookmark-state-k7y5SNGf.js} +9 -9
  14. package/dist/chunks/{braces-8TRlDwDw.js → braces-o9UiRQes.js} +1 -1
  15. package/dist/chunks/calculated-field-identity-DcBS2NPP.js +2161 -0
  16. package/dist/chunks/calendar-day-equality-Bpl15IBo.js +487 -0
  17. package/dist/chunks/class-utils-Df1OVOT1.js +2315 -0
  18. package/dist/chunks/{field-dependencies-CpRUwr9J.js → common-types-CUf03Htv.js} +65 -58
  19. package/dist/chunks/context-HD9usB1P.js +349 -0
  20. package/dist/chunks/conversation-sQiWYUOb.js +16 -0
  21. package/dist/chunks/csv-utils-GUfKyT1J.js +56 -0
  22. package/dist/chunks/custom-visual-inputs-BrUOIwln.js +3288 -0
  23. package/dist/chunks/{dashboard-briefing-launcher-A2uVpHCp.js → dashboard-briefing-launcher-Bl3gCeBR.js} +580 -556
  24. package/dist/chunks/{dashboard-controls-DxTuVis_.js → dashboard-controls-0EX0HiJt.js} +683 -686
  25. package/dist/chunks/{common-types-g7yS12Cg.js → dashboard-filter-value-compatibility-D95O4nd7.js} +18 -24
  26. package/dist/chunks/dashboard-json-6X_2BDiL.js +69 -0
  27. package/dist/chunks/{dashboard-BPJo-Fnd.js → dashboard-y5BwcvzT.js} +1 -1
  28. package/dist/chunks/document-dashboard-inputs-BrYYlRVo.js +10678 -0
  29. package/dist/chunks/document-sheet-utils-C1eEldxs.js +1076 -0
  30. package/dist/chunks/{edit-dashboard-visual-ByV0OwSp.js → edit-dashboard-visual-Bzchfgga.js} +4744 -4746
  31. package/dist/chunks/editor-draft-sync-BN5qYHPF.js +15 -0
  32. package/dist/chunks/filter-value-text-BhWugPWE.js +163 -0
  33. package/dist/chunks/index-CqMiAkay.js +3164 -0
  34. package/dist/chunks/index-CuHybtft.js +51 -0
  35. package/dist/chunks/layout-grid-Bgzth8vd.js +16 -0
  36. package/dist/chunks/{matrix-analytical-definition-CgBTD6H8.js → matrix-analytical-definition-bcprSe4u.js} +1 -1
  37. package/dist/chunks/{matrix-card-CAdizkUl.js → matrix-card-CJn1hB5V.js} +13 -12
  38. package/dist/chunks/matrix-definition-DQDI2okF.js +206 -0
  39. package/dist/chunks/{matrix-formatter-DJCk8Znf.js → matrix-formatter-DQ8avoIQ.js} +648 -457
  40. package/dist/chunks/matrix-member-presentation-BNPSDKBG.js +105 -0
  41. package/dist/chunks/{matrix-operation-contract-BKupLHXL.js → matrix-operation-contract-B8PBF1Gd.js} +134 -133
  42. package/dist/chunks/{metric-comparison-BKHyvnAy.js → metric-comparison-CojWeLqx.js} +1 -1
  43. package/dist/chunks/{palette-Cp1hqZtm.js → palette-D10o_yYX.js} +1 -1
  44. package/dist/chunks/pivot-header-presentation-MkcKnjn3.js +42 -0
  45. package/dist/chunks/{pivot-result-identity-Bs4tLtLo.js → pivot-result-identity-D6hhcRXi.js} +1 -1
  46. package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +804 -0
  47. package/dist/chunks/raw-temporal-D61lr48Y.js +1464 -0
  48. package/dist/chunks/{raw-temporal-contract-mLFS-9wk.js → raw-temporal-contract-C51YG48G.js} +1 -1
  49. package/dist/chunks/report-preferences-dialog-CWhSbc5_.js +1808 -0
  50. package/dist/chunks/{report-runtime-context-CG_I0PPW.js → report-runtime-context-B984Nq1E.js} +8 -7
  51. package/dist/chunks/save-CfJpQQ68.js +21 -0
  52. package/dist/chunks/saved-dashboard-context-Dqve2jlB.js +566 -0
  53. package/dist/chunks/{selection-reducer-CiDEtmAq.js → selection-reducer-vKIb_jS6.js} +2 -2
  54. package/dist/chunks/{semaphor-ready-indicator-CHu1L-lo.js → semaphor-ready-indicator-ldcwmLoY.js} +65803 -62954
  55. package/dist/chunks/{shelf-drop-preview-context-i-H6DFyU.js → shelf-drop-preview-context-BWxunXTq.js} +199 -196
  56. package/dist/chunks/{source-entity-resolution-C-oNyYMp.js → source-entity-resolution-CVA1a85c.js} +8 -8
  57. package/dist/chunks/switch-CvItuC1Q.js +8199 -0
  58. package/dist/chunks/{temporal-bucket-DlFuhCnT.js → temporal-bucket-D8JF7zKz.js} +86 -71
  59. package/dist/chunks/{temporal-bucket-contract-D2OuaVZ7.js → temporal-bucket-contract-DaOajRC7.js} +1 -1
  60. package/dist/chunks/{token-types-DtSJOUjh.js → token-types-bxUxXDX2.js} +1 -1
  61. package/dist/chunks/{upload-CAIpsti1.js → upload-BFX7apKV.js} +1 -1
  62. package/dist/chunks/{use-create-flow-overlay-state-Bj63WwHc.js → use-create-flow-overlay-state-RHgzVfcz.js} +331 -339
  63. package/dist/chunks/{validators-DMSH81OM.js → validators-Ej1DdCXa.js} +1050 -1510
  64. package/dist/chunks/visual-choice-JiJ-_3bi.js +204 -0
  65. package/dist/chunks/x-4f5U2XwU.js +100 -0
  66. package/dist/chunks/{zoned-wall-clock-1qlWCE20.js → zoned-wall-clock-MulfA26h.js} +2 -2
  67. package/dist/dashboard/index.js +2 -2
  68. package/dist/dashboard-authoring/index.js +823 -661
  69. package/dist/data-app-sdk/index.js +32 -30
  70. package/dist/data-app-sdk-adapters/index.js +23 -22
  71. package/dist/data-app-sdk-validation/index.js +23 -22
  72. package/dist/format-utils/index.js +173 -168
  73. package/dist/index.js +267 -258
  74. package/dist/layouts/index.js +236 -24
  75. package/dist/report-runtime-context/index.js +2 -2
  76. package/dist/style.css +1 -1
  77. package/dist/surfboard/index.js +2 -2
  78. package/dist/types/assistant-context.d.ts +2 -0
  79. package/dist/types/assistant-protocol.d.ts +2 -0
  80. package/dist/types/components/assistant/assistant-entry-points.d.ts +18 -0
  81. package/dist/types/components/assistant/assistant-provider.d.ts +19 -0
  82. package/dist/types/components/assistant/assistant-store.d.ts +52 -0
  83. package/dist/types/components/assistant/use-assistant.d.ts +38 -0
  84. package/dist/types/components/index.d.ts +5 -1
  85. package/dist/types/components/surfboard/filter/types.d.ts +5 -2
  86. package/dist/types/index.js +50 -51
  87. package/dist/types/lib/api/invalidate-token.d.ts +7 -0
  88. package/dist/types/lib/charts/cartesian-fields.d.ts +64 -0
  89. package/dist/types/lib/charts/types.d.ts +7 -0
  90. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +14 -2
  91. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +5 -6
  92. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +8 -3
  93. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +11 -6
  94. package/dist/types/lib/dashboard-pagination/dashboard-card-pagination.d.ts +7 -0
  95. package/dist/types/lib/dashboard-viewer/compatibility-input-storage.d.ts +79 -0
  96. package/dist/types/lib/dashboard-viewer/viewer-state.d.ts +3 -2
  97. package/dist/types/lib/document/document-table-data-policy.d.ts +15 -0
  98. package/dist/types/lib/filter-values/filter-mode.d.ts +22 -0
  99. package/dist/types/lib/hooks/use-calendar-context.d.ts +5 -0
  100. package/dist/types/lib/hooks/use-filter-option-browse.d.ts +5 -0
  101. package/dist/types/lib/hooks/use-text-filter.d.ts +9 -0
  102. package/dist/types/lib/print/print-inputs.d.ts +4 -2
  103. package/dist/types/lib/query-context/build-card-query-context.d.ts +12 -4
  104. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +93 -0
  105. package/dist/types/lib/query-context/card-server-request.d.ts +72 -0
  106. package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +7 -0
  107. package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +56 -0
  108. package/dist/types/lib/query-context/document-section-card-query.d.ts +45 -0
  109. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +17 -2
  110. package/dist/types/lib/stores/dashboard-store.d.ts +34 -11
  111. package/dist/types/lib/stores/editor-store.d.ts +4 -2
  112. package/dist/types/lib/types/token-types.d.ts +11 -0
  113. package/dist/types/lib/utils/card-type-change.d.ts +30 -0
  114. package/dist/types/lib/utils/comparison-window-caption.d.ts +12 -0
  115. package/dist/types/lib/utils/filter-default-value-utils.d.ts +13 -2
  116. package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +74 -0
  117. package/dist/types/shared/analytics-protocol/contracts.d.ts +3 -0
  118. package/dist/types/shared/analytics-protocol/filter-field-ownership.d.ts +43 -0
  119. package/dist/types/shared/analytics-protocol/index.d.ts +3 -0
  120. package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +1 -1
  121. package/dist/types/shared/analytics-protocol/visual-choice.d.ts +75 -0
  122. package/dist/types/shared/assistant-context/index.d.ts +9 -0
  123. package/dist/types/shared/assistant-context/project-context.d.ts +55 -0
  124. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +130 -0
  125. package/dist/types/shared/assistant-protocol/add-to-dashboard.d.ts +17 -0
  126. package/dist/types/shared/assistant-protocol/artifact.d.ts +63 -0
  127. package/dist/types/shared/assistant-protocol/availability.d.ts +39 -0
  128. package/dist/types/shared/assistant-protocol/context.d.ts +952 -0
  129. package/dist/types/shared/assistant-protocol/conversation.d.ts +38 -0
  130. package/dist/types/shared/assistant-protocol/index.d.ts +16 -0
  131. package/dist/types/shared/assistant-protocol/limits.d.ts +53 -0
  132. package/dist/types/shared/assistant-protocol/parts.d.ts +140 -0
  133. package/dist/types/shared/assistant-protocol/request.d.ts +77 -0
  134. package/dist/types/shared/assistant-protocol/sources.d.ts +27 -0
  135. package/dist/types/shared/assistant-protocol/token-config.d.ts +32 -0
  136. package/dist/types/shared/assistant-protocol/transcript.d.ts +40 -0
  137. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +112 -0
  138. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +1794 -0
  139. package/dist/types/shared/dashboard-authoring/index.d.ts +5 -0
  140. package/dist/types/shared/dashboard-authoring/new-card.d.ts +10 -0
  141. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +40 -0
  142. package/dist/types/shared/dashboard-authoring/resolved-primary-date-field-validation.d.ts +16 -0
  143. package/dist/types/shared/format-utils/filter-detail.d.ts +70 -0
  144. package/dist/types/shared/format-utils/filter-value-text.d.ts +15 -0
  145. package/dist/types/shared/format-utils/index.d.ts +3 -0
  146. package/dist/types/shared/format-utils/raw-temporal.d.ts +7 -0
  147. package/dist/types/shared/format-utils/temporal-bucket.d.ts +7 -0
  148. package/dist/types/shared/layouts/frame-layouts.d.ts +23 -0
  149. package/dist/types/shared/layouts/index.d.ts +1 -0
  150. package/package.json +12 -2
  151. package/dist/chunks/calculated-field-identity-BptYhyOP.js +0 -1326
  152. package/dist/chunks/calendar-day-equality-BRjN1S9h.js +0 -383
  153. package/dist/chunks/card-config-utils-BOM1dxCk.js +0 -1150
  154. package/dist/chunks/constants-DNWVy8Y3.js +0 -9
  155. package/dist/chunks/dashboard-json-B1dEQu98.js +0 -65
  156. package/dist/chunks/field-aggregations-CoLzYHeL.js +0 -1229
  157. package/dist/chunks/index-DTcTAGGM.js +0 -4101
  158. package/dist/chunks/matrix-continuation-C4sRcjZU.js +0 -72
  159. package/dist/chunks/matrix-control-sources-DTqcA2_L.js +0 -636
  160. package/dist/chunks/matrix-definition-D9iShKZI.js +0 -87
  161. package/dist/chunks/matrix-member-presentation-Ct8GuxHt.js +0 -209
  162. package/dist/chunks/numeric-presentation-CWu3gunq.js +0 -537
  163. package/dist/chunks/pivot-header-presentation-CHs2GFrM.js +0 -753
  164. package/dist/chunks/pivot-result-lifecycle-DQz_gjGu.js +0 -789
  165. package/dist/chunks/raw-temporal-iMXRK-Qz.js +0 -930
  166. package/dist/chunks/report-preferences-dialog-DXPjteCU.js +0 -1623
  167. package/dist/chunks/save-kO6cIaob.js +0 -34
  168. package/dist/chunks/semantic-format-DiqYeKwU.js +0 -192
  169. package/dist/chunks/switch-DO8a0EfJ.js +0 -25004
  170. package/dist/chunks/temporal-input-presentation-BD7YNUzu.js +0 -195
  171. package/dist/chunks/x-CXDkqdur.js +0 -149
  172. package/dist/types/lib/class-utils.d.ts +0 -2
  173. package/dist/types/lib/document/document-input-runtime.d.ts +0 -26
  174. package/dist/types/lib/utils.d.ts +0 -51
@@ -0,0 +1,38 @@
1
+ import { SemaphorSourceRef } from '../analytics-protocol/contracts.js';
2
+ import { AssistantPart } from './parts.js';
3
+ /** How a stored turn ended; `running` while it is answering, `interrupted` when its process died. */
4
+ export type TurnOutcome = 'running' | 'completed' | 'stopped' | 'failed' | 'refused' | 'interrupted';
5
+ /** For the full page: one of the caller's conversations from the last 24 hours. */
6
+ export type AssistantConversationSummary = {
7
+ conversationId: string;
8
+ /** The first message, trimmed to 80 characters. */
9
+ title: string;
10
+ dashboardId?: string;
11
+ lastActivityAt: string;
12
+ expiresAt: string;
13
+ turnCount: number;
14
+ };
15
+ /**
16
+ * What opening a conversation returns (Phase 3c, D3c-5): the turns as the
17
+ * transcript shows them. Never the context, tool calls, card request,
18
+ * executed queries or provider replay (AG-INV-5).
19
+ */
20
+ export type AssistantConversationDetail = {
21
+ conversationId: string;
22
+ addedSources: SemaphorSourceRef[];
23
+ turns: Array<{
24
+ turnId: string;
25
+ startedAt: string;
26
+ message: string;
27
+ /** Shown through the one stored-part mapping the stream uses (D3c-6, `transcript.ts`). */
28
+ parts: AssistantPart[];
29
+ outcome: TurnOutcome;
30
+ }>;
31
+ };
32
+ export declare const ASSISTANT_LAYOUTS: readonly ["docked-right", "docked-left", "centered", "full-page"];
33
+ /** Where the assistant opens. Token config `assistant.layout` sets the embed default (AG-D21). */
34
+ export type AssistantLayout = (typeof ASSISTANT_LAYOUTS)[number];
35
+ export declare function isAssistantLayout(value: unknown): value is AssistantLayout;
36
+ /** Default name in customer-facing text; token config `assistant.name` overrides it (AG-D19). */
37
+ export declare const DEFAULT_ASSISTANT_NAME = "Assistant";
38
+ export declare const ASSISTANT_NAME_MAX_CHARS = 40;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `react-semaphor/assistant-protocol`: the shapes and pure rules the
3
+ * assistant's browser and server share (analytics agent Plan 1, spec 2).
4
+ * Defined once here and imported by semaphor-app; nothing is copied.
5
+ */
6
+ export * from './request.js';
7
+ export { assistantJsonBytes, fitAssistantText, AssistantContextTooLargeError, } from './limits.js';
8
+ export * from './context.js';
9
+ export * from './availability.js';
10
+ export * from './parts.js';
11
+ export * from './conversation.js';
12
+ export * from './transcript.js';
13
+ export * from './sources.js';
14
+ export * from './token-config.js';
15
+ export * from './artifact.js';
16
+ export * from './add-to-dashboard.js';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Every cap of the assistant's request and context, in one place (analytics
3
+ * agent Plan 1, spec 2.1, ledger D3a-7). The server's schema and the browser's
4
+ * projection read these. Past a list cap the projection counts what it left
5
+ * out (`omitted`); past a text cap it says so in the text. Nothing is cut
6
+ * silently.
7
+ */
8
+ export declare const ASSISTANT_LIMITS: {
9
+ readonly messageChars: 4000;
10
+ /** The whole serialized AssistantContext, in UTF-8 bytes. */
11
+ readonly contextBytes: number;
12
+ /** The whole request body (context, message, added sources), in UTF-8 bytes. */
13
+ readonly requestBytes: number;
14
+ readonly summaryCards: 30;
15
+ readonly otherSheets: 50;
16
+ readonly activeInputs: 50;
17
+ /** Values listed for one input, or in one filter's text. */
18
+ readonly inputValues: 50;
19
+ readonly addedSources: 50;
20
+ readonly cardFields: 60;
21
+ readonly cardFilters: 40;
22
+ readonly cardControls: 40;
23
+ readonly drillSteps: 10;
24
+ readonly sqlChars: 20000;
25
+ readonly sqlParameters: 40;
26
+ readonly idChars: 200;
27
+ readonly labelChars: 500;
28
+ /** One filter, control or SQL parameter description. */
29
+ readonly textChars: 4000;
30
+ readonly turnsPerConversation: 40;
31
+ readonly conversationBytes: number;
32
+ readonly toolCallsPerTurn: 12;
33
+ readonly secondsPerTurn: 120;
34
+ readonly artifactRecords: 200;
35
+ readonly conversationTtlSeconds: number;
36
+ };
37
+ /** UTF-8 bytes of a value's JSON, the measure both the browser and the server use. */
38
+ export declare function assistantJsonBytes(value: unknown): number;
39
+ /**
40
+ * Text within `max` characters. Longer text keeps its start and says how much
41
+ * was left out, so a reader never takes a cut text for the whole.
42
+ */
43
+ export declare function fitAssistantText(text: string, max: number): string;
44
+ /**
45
+ * The context the browser built is larger than `contextBytes`: nothing is
46
+ * sent, and the draft stays where it is. The server answers the same case
47
+ * with the `context_too_large` refusal.
48
+ */
49
+ export declare class AssistantContextTooLargeError extends Error {
50
+ readonly bytes: number;
51
+ readonly code: "context_too_large";
52
+ constructor(bytes: number);
53
+ }
@@ -0,0 +1,140 @@
1
+ import { SemaphorDialect, SemaphorSourceRef } from '../analytics-protocol/contracts.js';
2
+ import { AssistantArtifact } from './artifact.js';
3
+ /**
4
+ * The parts of an answer (analytics agent Plan 1, spec 2.4). Streamed as AI
5
+ * SDK `data-${kind}` parts (text uses the SDK's own text parts) and stored on
6
+ * the turn as they are. Never a card config (AG-INV-5). Artifacts from
7
+ * Phase 4; proposals in Phase 7.
8
+ */
9
+ export declare const ASSISTANT_PARTS_VERSION: 1;
10
+ export type AssistantPart = {
11
+ kind: 'conversation';
12
+ conversationId: string;
13
+ expiresAt: string;
14
+ } | {
15
+ kind: 'text';
16
+ text: string;
17
+ } | AssistantStagePart | {
18
+ kind: 'using';
19
+ items: AssistantUsingItem[];
20
+ notes: string[];
21
+ } | AssistantClarifyPart | {
22
+ kind: 'artifact';
23
+ artifact: AssistantArtifact;
24
+ } | {
25
+ kind: 'refusal';
26
+ code: AssistantRefusalCode;
27
+ message: string;
28
+ } | AssistantTracePart;
29
+ /**
30
+ * A question the person answers with a click, ending the answer (ledger
31
+ * D3d-1): the model's alternatives as data, never parsed from its text. Each
32
+ * option is a complete request the assistant can run as written, so a pick is
33
+ * sent as the person's next message, words unchanged. Only the latest
34
+ * answer's options can be picked.
35
+ */
36
+ export type AssistantClarifyPart = {
37
+ kind: 'clarify';
38
+ question: string;
39
+ options: Array<{
40
+ optionId: string;
41
+ label: string;
42
+ description?: string;
43
+ }>;
44
+ };
45
+ export type AssistantStagePart = {
46
+ kind: 'stage';
47
+ stageId: string;
48
+ label: string;
49
+ state: 'live' | 'done' | 'skipped';
50
+ };
51
+ /**
52
+ * Where one answer's time and tokens went (spec 3.9, AG-D25). The server
53
+ * sends it only to people who may see it (a development server, a super
54
+ * admin); the transcript shows it inside the answer's steps. Times are
55
+ * milliseconds from the message arriving.
56
+ */
57
+ export type AssistantTracePart = {
58
+ kind: 'trace';
59
+ totalMs: number;
60
+ /** `provider/modelId`, as the turn's log line names it. */
61
+ model: string;
62
+ instructionsVersion: string;
63
+ tokens: AssistantTraceTokens;
64
+ /** In the order they started. */
65
+ spans: AssistantTraceSpan[];
66
+ };
67
+ export type AssistantTraceTokens = {
68
+ input: number;
69
+ cachedInput: number;
70
+ output: number;
71
+ };
72
+ export type AssistantTraceSpan = {
73
+ kind: 'check';
74
+ label: string;
75
+ startMs: number;
76
+ durationMs: number;
77
+ } | {
78
+ kind: 'model';
79
+ startMs: number;
80
+ durationMs: number;
81
+ /** Until the model's first output. */
82
+ firstOutputMs?: number;
83
+ tokens: AssistantTraceTokens;
84
+ }
85
+ /** A step: its words are the stage part with this id. */
86
+ | {
87
+ kind: 'step';
88
+ stageId: string;
89
+ startMs: number;
90
+ durationMs: number;
91
+ };
92
+ /** What an answer used, shown as chips at its top. `notes` carry caveats ("Region is not applied: this card does not use it"). */
93
+ export type AssistantUsingItem = {
94
+ kind: 'card';
95
+ cardId: string;
96
+ title: string;
97
+ change?: string;
98
+ } | {
99
+ kind: 'draft';
100
+ title: string;
101
+ } | {
102
+ kind: 'source';
103
+ source: SemaphorSourceRef;
104
+ added: boolean;
105
+ } | {
106
+ kind: 'sql';
107
+ connectionLabel: string;
108
+ dialect?: SemaphorDialect;
109
+ } | {
110
+ kind: 'input';
111
+ label: string;
112
+ value: string;
113
+ } | {
114
+ kind: 'period';
115
+ label: string;
116
+ from: string;
117
+ to: string;
118
+ };
119
+ export type AssistantRefusalCode = 'assistant_unavailable' | 'context_invalid' | 'context_too_large' | 'conversation_not_found' | 'conversation_full' | 'turn_in_progress' | 'daily_limit_reached' | 'budget_exhausted' | 'not_permitted' | 'no_data_found' | 'model_unavailable';
120
+ /**
121
+ * The data parts of the AI SDK UI message stream, by name: `data-${kind}`
122
+ * with the part (minus `kind`) as its data. Text is the SDK's own part. For
123
+ * `UIMessage<unknown, AssistantDataParts>` in the browser.
124
+ */
125
+ export type AssistantDataParts = {
126
+ [Kind in Exclude<AssistantPart['kind'], 'text'>]: Omit<Extract<AssistantPart, {
127
+ kind: Kind;
128
+ }>, 'kind'>;
129
+ };
130
+ /**
131
+ * The words past the daily question limit (spec 3.8, AG-D24), with the
132
+ * deployment's limit when the refusal carried it.
133
+ */
134
+ export declare function dailyLimitMessage(limit?: number): string;
135
+ /** What a refusal says: its code's words, with the details the server sent for that code. */
136
+ export declare function assistantRefusalMessage(code: AssistantRefusalCode, details?: {
137
+ dailyLimit?: number;
138
+ }): string;
139
+ /** Plain words for each refusal; never a tool name and never the product name (AG-INV-10). */
140
+ export declare const ASSISTANT_REFUSAL_MESSAGES: Record<AssistantRefusalCode, string>;
@@ -0,0 +1,77 @@
1
+ import { SemaphorSourceRef } from '../analytics-protocol/contracts.js';
2
+ import { CardQueryRequestExtras, DashboardCardQueryRequestPayloadBase } from '../dashboard-authoring/card-query-request.js';
3
+ import { DataSource } from '../../lib/types/explorer-types.js';
4
+ import { AssistantContext } from './context.js';
5
+ export { ASSISTANT_LIMITS } from './limits.js';
6
+ /**
7
+ * The assistant's turn request (analytics agent Plan 1, spec 2.1). The browser
8
+ * sends one new message and the context; never history.
9
+ */
10
+ /** Body of POST /api/v1/assistant/turns. One new message; never history. */
11
+ export type AssistantTurnRequest = {
12
+ /** Idempotency key, new per send (`crypto.randomUUID()`); a retry reuses it. */
13
+ turnId: string;
14
+ /** Omitted to start a conversation; the stream's first part carries the new id. */
15
+ conversationId?: string;
16
+ /** Plain text, 1 to ASSISTANT_LIMITS.messageChars characters. */
17
+ message: string;
18
+ /** What the user is looking at (spec 2.2). */
19
+ context: AssistantContext;
20
+ /** Sources added with Add source (spec 2.7). Kept on the conversation until removed. */
21
+ addedSources: SemaphorSourceRef[];
22
+ /**
23
+ * The asked-about card's request, as the card posts it to /api/v1/query
24
+ * (Phase 3b, D3b-2): the server replays it with `fromCard`. Outside the
25
+ * context, so the model's text and change detection never read it.
26
+ */
27
+ selectedCardRequest?: AssistantCardRequest;
28
+ /**
29
+ * Why the asked-about card has no request (ledger P3-92). With a selected
30
+ * card the browser sends exactly one of `selectedCardRequest` and this, so
31
+ * the server never works out from a missing request which card was asked
32
+ * about or why it cannot run.
33
+ */
34
+ selectedCardUnavailable?: AssistantCardUnavailable;
35
+ };
36
+ /**
37
+ * Why a card has no request to replay: the reasons the external path's saved
38
+ * card refuses with (`buildSavedCardRequest`), and `pending` (the browser has
39
+ * not built the card's snapshot yet).
40
+ */
41
+ export declare const ASSISTANT_CARD_UNAVAILABLE_REASONS: readonly ["matrix", "no_query", "document_section", "blocked", "pending"];
42
+ export type AssistantCardUnavailableReason = (typeof ASSISTANT_CARD_UNAVAILABLE_REASONS)[number];
43
+ export type AssistantCardUnavailable = {
44
+ cardId: string;
45
+ reason: AssistantCardUnavailableReason;
46
+ /** The card's own words, for a blocked filter mapping. */
47
+ message?: string;
48
+ };
49
+ /** A card's request for a server replay: its connection and the payload the card query assembly builds. */
50
+ export type AssistantCardRequest = {
51
+ cardId: string;
52
+ connectionId: string;
53
+ /**
54
+ * The card query assembly's request with its extras (the first page of a
55
+ * server-paginated table, table totals) and the card's data source
56
+ * (`buildCardServerRequest`); the server checks it with the shared
57
+ * `parseCardQueryRequest` and `parseCardQueryRequestExtras` before it runs.
58
+ */
59
+ payload: DashboardCardQueryRequestPayloadBase & CardQueryRequestExtras & {
60
+ cardDataSource: DataSource;
61
+ };
62
+ };
63
+ export type AssistantTurnRequestParseResult = {
64
+ ok: true;
65
+ value: AssistantTurnRequest;
66
+ } | {
67
+ ok: false;
68
+ code: 'context_too_large' | 'context_invalid';
69
+ issues: string[];
70
+ };
71
+ /**
72
+ * Parses a turn request body as received (text). Size first, before any
73
+ * parsing: a body over `requestBytes` or a context over `contextBytes` is
74
+ * `context_too_large`. Then the schema (strict) and the context version: a
75
+ * failure is `context_invalid`.
76
+ */
77
+ export declare function parseAssistantTurnRequest(bodyText: string): AssistantTurnRequestParseResult;
@@ -0,0 +1,27 @@
1
+ import { SemaphorSourceRef } from '../analytics-protocol/contracts.js';
2
+ /**
3
+ * Adding a source to a conversation (analytics agent Plan 1, spec 2.7,
4
+ * D3c-10). The server's `listAddableSources` is the one owner of what a
5
+ * caller may add; the menu shows it and every turn is checked against it.
6
+ */
7
+ export type AddableSourceGroup = 'semantic_datasets' | 'connections';
8
+ export type AddableSource = {
9
+ /** A semantic dataset (`kind: 'semantic'`), or a connection for its direct tables (`kind: 'sql'`). */
10
+ source: SemaphorSourceRef;
11
+ label: string;
12
+ /** For a semantic dataset: its domain's label, which the menu groups by. */
13
+ domainLabel?: string;
14
+ group: AddableSourceGroup;
15
+ };
16
+ /** Body of `GET /api/v1/assistant/sources`. */
17
+ export type AddableSourcesResponse = {
18
+ sources: AddableSource[];
19
+ };
20
+ /**
21
+ * Which source a reference names, for comparing an added source with the
22
+ * catalog: a dataset by its domain and name, a connection by its id. Labels
23
+ * and optional ids never decide. Undefined for a kind that cannot be added.
24
+ */
25
+ export declare function addableSourceKey(source: SemaphorSourceRef): string | undefined;
26
+ /** A source's name for the viewer: its label, else what it names. */
27
+ export declare function sourceRefLabel(source: SemaphorSourceRef): string;
@@ -0,0 +1,32 @@
1
+ import { AssistantLayout } from './conversation.js';
2
+ /**
3
+ * The assistant's token options (analytics agent Plan 1, spec 4, Phase 6):
4
+ * `config.assistant` on a token request. One owner for reading them (the
5
+ * server's availability and name, the browser's availability, name and
6
+ * layout) and for validating them (the token route). The deleted assistant's
7
+ * flat `showDashboardAssistant`, which customers still send, stands in for
8
+ * `enabled` when `enabled` is absent.
9
+ */
10
+ export type AssistantTokenConfig = {
11
+ /** Shows the assistant on this token. The project's switches can still turn it off; a user identity is required. */
12
+ enabled?: boolean;
13
+ /** The assistant's name in what viewers read; 1 to 40 characters. Default "Assistant". */
14
+ name?: string;
15
+ /** The layout before the viewer chooses one. Default 'docked-right'. */
16
+ layout?: AssistantLayout;
17
+ };
18
+ export type ResolvedAssistantTokenConfig = {
19
+ enabled: boolean | undefined;
20
+ name: string;
21
+ layout: AssistantLayout | undefined;
22
+ };
23
+ /** A token's assistant options, as every reader uses them. Anything malformed reads as absent. */
24
+ export declare function readAssistantTokenConfig(config: unknown): ResolvedAssistantTokenConfig;
25
+ /** For the token route: `config.assistant` checked and its name trimmed, or the issues in plain words. */
26
+ export declare function parseAssistantTokenConfig(value: unknown): {
27
+ ok: true;
28
+ value: AssistantTokenConfig;
29
+ } | {
30
+ ok: false;
31
+ issues: string[];
32
+ };
@@ -0,0 +1,40 @@
1
+ import { AssistantDataParts, AssistantPart } from './parts.js';
2
+ import { TurnOutcome } from './conversation.js';
3
+ /**
4
+ * One mapping from a stored part to what the transcript shows (analytics
5
+ * agent Plan 1, Phase 3c, D3c-6). The turn's stream writes these, live and
6
+ * when a retried turn is answered again, and opening a stored conversation
7
+ * shows them, so history reads exactly as it streamed. A data part is the
8
+ * same object as a stream chunk and as a message part (AI SDK
9
+ * `data-${kind}`); text is one message part and three chunks on the wire.
10
+ */
11
+ export type AssistantTranscriptDataPart = {
12
+ [Kind in keyof AssistantDataParts]: {
13
+ type: `data-${Kind}`;
14
+ /** A stage's id: later states replace the earlier one. */
15
+ id?: string;
16
+ data: AssistantDataParts[Kind];
17
+ };
18
+ }[keyof AssistantDataParts];
19
+ export type AssistantTranscriptPart = {
20
+ type: 'text';
21
+ text: string;
22
+ } | AssistantTranscriptDataPart;
23
+ export type AssistantTranscriptChunk = AssistantTranscriptDataPart | {
24
+ type: 'text-start' | 'text-end';
25
+ id: string;
26
+ } | {
27
+ type: 'text-delta';
28
+ id: string;
29
+ delta: string;
30
+ };
31
+ export declare function toTranscriptPart(part: AssistantPart): AssistantTranscriptPart;
32
+ /** A stored part as stream chunks; `textId` names a text part's chunks. */
33
+ export declare function toTranscriptChunks(part: AssistantPart, textId: string): AssistantTranscriptChunk[];
34
+ /**
35
+ * How history shows a turn that did not end with its answer: the words its
36
+ * stream ended with. A failed or interrupted turn ends with "could not
37
+ * answer" (its stream ended with that error); a turn still running says so.
38
+ * Other turns end with their own parts.
39
+ */
40
+ export declare function storedTurnEnding(outcome: TurnOutcome): AssistantPart | undefined;
@@ -0,0 +1,112 @@
1
+ import { TFilterValue } from '../../components/surfboard/filter/types.js';
2
+ import { ControlBinding, ControlDefinition, TCard, TDashboard } from '../../lib/types/common-types.js';
3
+ import { CardConfig, DataSource, TableTotalsRequest } from '../../lib/types/explorer-types.js';
4
+ import { TableConfig } from '../../lib/types/query-types.js';
5
+ import { ResolvedPrimaryDateField } from '../analytics-protocol/contracts.js';
6
+ import { GlobalDateComparisonContext } from '../analytics-protocol/metric-comparison.js';
7
+ import { CalendarContext } from '../report-runtime-context/report-runtime-context.js';
8
+ import { TemporalResultOwner } from './temporal-result-owner.js';
9
+ /**
10
+ * A card's query request: what the card posts to `/api/v1/query`, and what
11
+ * the server reads back. One owner for both sides (analytics agent Plan 1,
12
+ * ledger P3-78): the card query assembly builds `DashboardCardQueryRequestPayloadBase`,
13
+ * `buildCardServerRequest` adds the connection and data source, and every
14
+ * server reader (the query route, CSV export, a stored export's run, the
15
+ * analytics agent's card replay) checks it with `parseCardQueryRequest` or,
16
+ * for a body that may not be a card's, `parseCardQueryRequestContext`.
17
+ */
18
+ /** The request the card query assembly builds for one card. */
19
+ export type DashboardCardQueryRequestPayloadBase = {
20
+ cardId: string;
21
+ sql: string;
22
+ python: string;
23
+ resultOwner: TemporalResultOwner;
24
+ active_filters: TFilterValue[];
25
+ controlValues: Record<string, unknown>;
26
+ controlDefinitions: ControlDefinition[];
27
+ cardControlDefinitions: ControlDefinition[];
28
+ controlBindings: ControlBinding[];
29
+ cache_config: TDashboard['globalCacheConfig'];
30
+ queryConfig: TCard['queryConfig'];
31
+ tableConfig: TableConfig;
32
+ cardType: TCard['type'];
33
+ cardTitle: string;
34
+ cardConfig: CardConfig;
35
+ cardDataSource: TCard['dataSource'];
36
+ resolvedPrimaryDateField?: ResolvedPrimaryDateField;
37
+ globalDateComparison?: GlobalDateComparisonContext;
38
+ calendarContext: CalendarContext;
39
+ };
40
+ /** The fields the server runs a card with. */
41
+ export declare const CARD_QUERY_REQUEST_EXECUTED_FIELDS: readonly ["cardType", "sql", "python", "resultOwner", "cardConfig", "cardDataSource", "active_filters", "controlValues", "controlDefinitions", "cardControlDefinitions", "controlBindings", "resolvedPrimaryDateField", "globalDateComparison", "calendarContext"];
42
+ /**
43
+ * The fields that describe the card for its own view and logs; the server
44
+ * does not run with them (the result cache `cache_config` names is off).
45
+ */
46
+ export declare const CARD_QUERY_REQUEST_DESCRIPTIVE_FIELDS: readonly ["cardId", "cardTitle", "cache_config", "queryConfig", "tableConfig"];
47
+ type DecidedField = (typeof CARD_QUERY_REQUEST_EXECUTED_FIELDS)[number] | (typeof CARD_QUERY_REQUEST_DESCRIPTIVE_FIELDS)[number];
48
+ type AssertNever<T extends never> = T;
49
+ /**
50
+ * Every field the assembly builds is decided: run or descriptive. A new field
51
+ * fails the type check here until the parser reads it or it is listed as
52
+ * descriptive, so a reader never drops it silently.
53
+ */
54
+ export type CardQueryRequestFieldsDecided = AssertNever<Exclude<keyof DashboardCardQueryRequestPayloadBase, DecidedField>>;
55
+ /** A card's request as the server runs it. */
56
+ export type CardQueryRequest = Omit<Pick<DashboardCardQueryRequestPayloadBase, (typeof CARD_QUERY_REQUEST_EXECUTED_FIELDS)[number]>, 'calendarContext' | 'cardDataSource'> & {
57
+ connection_id: string;
58
+ cardDataSource: DataSource;
59
+ /** Absent when the caller runs with a calendar of its own (a CSV export's report context). */
60
+ calendarContext?: CalendarContext;
61
+ };
62
+ /**
63
+ * What a card's query runs with beyond the assembly's request: the page a
64
+ * server-paginated table runs, and a flat table's totals request. Built by
65
+ * `resolveCardRequestExtras` for the live query and a captured request alike.
66
+ */
67
+ export type CardQueryRequestExtras = {
68
+ pagination?: {
69
+ page: number;
70
+ pageSize: number;
71
+ };
72
+ tableTotalsRequest?: TableTotalsRequest;
73
+ };
74
+ /** The context fields any query body may carry, checked the same way for every reader. */
75
+ export type CardQueryRequestContext = Pick<CardQueryRequest, 'calendarContext' | 'resolvedPrimaryDateField' | 'globalDateComparison'>;
76
+ /**
77
+ * A request a reader refuses: `message` names the first problem; `details`
78
+ * carries the field validator's own issues, for readers that answer with them.
79
+ */
80
+ export declare class CardQueryRequestError extends Error {
81
+ readonly field: string;
82
+ readonly details: unknown;
83
+ constructor(message: string, field: string, details?: unknown);
84
+ }
85
+ type ReadOptions = {
86
+ /** Prefixes every message, as a stored rule's reader names where the request sits. */
87
+ label?: string;
88
+ };
89
+ /**
90
+ * The context fields of any query body: the calendar, the resolved primary
91
+ * date field and the dashboard date comparison (without the legacy clock; an
92
+ * execution pins its own instant). Throws `CardQueryRequestError`.
93
+ */
94
+ export declare function parseCardQueryRequestContext(input: unknown, options?: ReadOptions): CardQueryRequestContext;
95
+ /**
96
+ * The extras of a card's request (`CardQueryRequestExtras`). The totals
97
+ * request is checked where it runs (`executeQuery`), as for every query.
98
+ * Throws `CardQueryRequestError`.
99
+ */
100
+ export declare function parseCardQueryRequestExtras(input: unknown, options?: ReadOptions): CardQueryRequestExtras;
101
+ /**
102
+ * A card's request, checked before it runs: connection, card type, the result
103
+ * owner (which of config, SQL or Python owns the rows), the config and data
104
+ * source, filters, the control contract and the context fields. Throws
105
+ * `CardQueryRequestError` (controls: `ExecutionControlContractError`) with the
106
+ * first problem. Callers add only their own rules.
107
+ */
108
+ export declare function parseCardQueryRequest(input: unknown, options?: ReadOptions & {
109
+ /** A Matrix export continuation carries its configuration in its acquisition. */
110
+ configOptional?: boolean;
111
+ }): CardQueryRequest;
112
+ export {};