@sisense/sdk-ai-core 0.17.0 → 0.60.1

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 (167) hide show
  1. package/dist/__vite-browser-external-l0sNRNKZ.js +1 -0
  2. package/dist/constants.d.ts +35 -0
  3. package/dist/engines/atomic-handle-args.d.ts +45 -0
  4. package/dist/engines/atomic-tool-requirements.d.ts +38 -0
  5. package/dist/engines/author-pulse/actions/create.d.ts +9 -0
  6. package/dist/engines/author-pulse/actions/define.d.ts +9 -0
  7. package/dist/engines/author-pulse/actions/load-existing.d.ts +9 -0
  8. package/dist/engines/author-pulse/actions/redefine.d.ts +9 -0
  9. package/dist/engines/author-pulse/actions/set-receive-notifications.d.ts +8 -0
  10. package/dist/engines/author-pulse/actions/update-spec.d.ts +11 -0
  11. package/dist/engines/author-pulse/actions/update-workflow.d.ts +9 -0
  12. package/dist/engines/author-pulse/atomic-adapter.d.ts +10 -0
  13. package/dist/engines/author-pulse/atomic-tools.d.ts +362 -0
  14. package/dist/engines/author-pulse/author-pulse-engine.d.ts +21 -0
  15. package/dist/engines/author-pulse/index.d.ts +9 -0
  16. package/dist/engines/author-pulse/shared/adjustment-error.d.ts +15 -0
  17. package/dist/engines/author-pulse/shared/assemble-create-workflow-payload.d.ts +36 -0
  18. package/dist/engines/author-pulse/shared/assert-agentic-workflow.d.ts +12 -0
  19. package/dist/engines/author-pulse/shared/compile-query-from-prompt.d.ts +95 -0
  20. package/dist/engines/author-pulse/shared/decision-spec-validation.d.ts +84 -0
  21. package/dist/engines/author-pulse/shared/notification-urls.d.ts +52 -0
  22. package/dist/engines/author-pulse/shared/pulse-knowledge.d.ts +36 -0
  23. package/dist/engines/author-pulse/shared/pulse-signature.d.ts +39 -0
  24. package/dist/engines/author-pulse/shared/resolve-frequency.d.ts +18 -0
  25. package/dist/engines/author-pulse/shared/staging.d.ts +65 -0
  26. package/dist/engines/author-pulse/shared/workflow-ownership.d.ts +14 -0
  27. package/dist/engines/author-pulse/types.d.ts +1385 -0
  28. package/dist/engines/build-chart/atomic-adapter.d.ts +20 -0
  29. package/dist/engines/build-chart/atomic-tools.d.ts +214 -0
  30. package/dist/engines/build-chart/build-chart-engine.d.ts +1 -1
  31. package/dist/engines/build-chart/chart-tool-name.d.ts +3 -0
  32. package/dist/engines/build-chart/create-chart/assemble-chart-widget.d.ts +1 -1
  33. package/dist/engines/build-chart/create-chart/chart-json-axes-mapping.d.ts +1 -1
  34. package/dist/engines/build-chart/create-chart/create-chart.d.ts +1 -1
  35. package/dist/engines/build-chart/create-chart/derive-chart-title.d.ts +7 -0
  36. package/dist/engines/build-chart/create-chart/generate-chart-recommendations.d.ts +2 -2
  37. package/dist/engines/build-chart/create-chart/resolve-chart-query.d.ts +4 -0
  38. package/dist/engines/build-chart/shared/normalize-cartesian-axes-mapping.d.ts +1 -1
  39. package/dist/engines/build-chart/shared/sync-chart-state-measure-flags.d.ts +3 -0
  40. package/dist/engines/build-chart/types.d.ts +38 -19
  41. package/dist/engines/build-chart/update-chart/apply-prior-chart-style.d.ts +8 -5
  42. package/dist/engines/build-chart/update-chart/chart-options-schemas.d.ts +18 -18
  43. package/dist/engines/build-chart/update-chart/schemas.d.ts +2 -2
  44. package/dist/engines/build-chart/update-chart/update-chart-data-options.d.ts +7 -2
  45. package/dist/engines/build-chart/update-chart/update-chart-query.d.ts +1 -1
  46. package/dist/engines/build-chart/update-chart/update-chart-style-options.d.ts +7 -2
  47. package/dist/engines/build-chart/update-chart/update-chart-title.d.ts +1 -1
  48. package/dist/engines/build-chart/update-chart/update-chart-type.d.ts +7 -2
  49. package/dist/engines/build-csv-model/build-csv-model-engine.d.ts +1 -1
  50. package/dist/engines/build-csv-model/types.d.ts +1 -1
  51. package/dist/engines/build-dashboard/add-dashboard-narration.d.ts +50 -0
  52. package/dist/engines/build-dashboard/add-dashboard-widgets.d.ts +1 -1
  53. package/dist/engines/build-dashboard/atomic-adapter.d.ts +21 -0
  54. package/dist/engines/build-dashboard/atomic-tools.d.ts +231 -0
  55. package/dist/engines/build-dashboard/build-dashboard-engine.d.ts +1 -1
  56. package/dist/engines/build-dashboard/build-dashboard-service.d.ts +2 -1
  57. package/dist/engines/build-dashboard/create-dashboard.d.ts +3 -4
  58. package/dist/engines/build-dashboard/dashboard-filters/manipulate-dashboard-filters.d.ts +2 -1
  59. package/dist/engines/build-dashboard/dashboard-filters/translate-filters.d.ts +17 -1
  60. package/dist/engines/build-dashboard/index.d.ts +2 -0
  61. package/dist/engines/build-dashboard/layout/place-widget.d.ts +53 -0
  62. package/dist/engines/build-dashboard/load-existing-fusion-dashboard.d.ts +1 -1
  63. package/dist/engines/build-dashboard/remove-dashboard-widgets.d.ts +4 -0
  64. package/dist/engines/build-dashboard/resolve-chart-widgets.d.ts +16 -0
  65. package/dist/engines/build-dashboard/types.d.ts +180 -18
  66. package/dist/engines/build-data-model/build-data-model-engine.d.ts +1 -1
  67. package/dist/engines/build-data-model/types.d.ts +1 -1
  68. package/dist/engines/build-query/build-query-engine.d.ts +33 -5
  69. package/dist/engines/build-query/index.d.ts +1 -1
  70. package/dist/engines/build-query/types.d.ts +216 -3
  71. package/dist/engines/build-status/build-status-engine.d.ts +8 -0
  72. package/dist/engines/build-status/builds-client.d.ts +44 -0
  73. package/dist/engines/build-status/index.d.ts +2 -0
  74. package/dist/engines/build-status/types.d.ts +177 -0
  75. package/dist/engines/datamodel-graph/data-model-map-text.d.ts +28 -0
  76. package/dist/engines/datamodel-graph/datamodel-graph-engine.d.ts +31 -0
  77. package/dist/engines/datamodel-graph/index.d.ts +4 -0
  78. package/dist/engines/datamodel-graph/summaries.d.ts +97 -0
  79. package/dist/engines/datamodel-graph/test-fixtures.d.ts +42 -0
  80. package/dist/engines/datamodel-graph/types.d.ts +190 -0
  81. package/dist/engines/evaluate-pulse/evaluate-pulse-engine.d.ts +10 -0
  82. package/dist/engines/evaluate-pulse/index.d.ts +2 -0
  83. package/dist/engines/evaluate-pulse/types.d.ts +85 -0
  84. package/dist/engines/get-dashboard-narration/get-dashboard-narration-engine.d.ts +23 -0
  85. package/dist/engines/get-dashboard-narration/index.d.ts +2 -0
  86. package/dist/engines/get-dashboard-narration/types.d.ts +64 -0
  87. package/dist/engines/get-dashboards/get-dashboards-engine.d.ts +1 -1
  88. package/dist/engines/get-dashboards/types.d.ts +16 -4
  89. package/dist/engines/get-data-preview/get-data-preview-engine.d.ts +18 -0
  90. package/dist/engines/get-data-preview/index.d.ts +2 -0
  91. package/dist/engines/get-data-preview/types.d.ts +35 -0
  92. package/dist/engines/get-data-source-fields/get-data-source-fields-engine.d.ts +12 -6
  93. package/dist/engines/get-data-source-fields/index.d.ts +1 -0
  94. package/dist/engines/get-data-source-fields/model-relations.d.ts +38 -0
  95. package/dist/engines/get-data-source-fields/types.d.ts +49 -3
  96. package/dist/engines/get-data-sources/get-data-sources-engine.d.ts +1 -1
  97. package/dist/engines/get-data-sources/types.d.ts +2 -2
  98. package/dist/engines/index.d.ts +17 -0
  99. package/dist/engines/inspect-pulse/atomic-adapter.d.ts +8 -0
  100. package/dist/engines/inspect-pulse/atomic-tools.d.ts +60 -0
  101. package/dist/engines/inspect-pulse/index.d.ts +4 -0
  102. package/dist/engines/inspect-pulse/inspect-pulse-engine.d.ts +7 -0
  103. package/dist/engines/inspect-pulse/types.d.ts +209 -0
  104. package/dist/engines/manage-perspectives/manage-perspectives-engine.d.ts +5 -1
  105. package/dist/engines/manage-perspectives/types.d.ts +13 -8
  106. package/dist/engines/pulse-tool-words.d.ts +62 -0
  107. package/dist/engines/recommend-queries/recommend-queries-engine.d.ts +1 -1
  108. package/dist/engines/recommend-queries/types.d.ts +1 -1
  109. package/dist/engines/shared/existing-answer-cascade.d.ts +52 -0
  110. package/dist/engines/shared/get-filters-json-for-llm-summary.d.ts +2 -2
  111. package/dist/engines/shared/nlq-query-helpers.d.ts +2 -2
  112. package/dist/engines/shared/project-dashboard-json.d.ts +151 -0
  113. package/dist/engines/shared/project-widget-json.d.ts +67 -0
  114. package/dist/engines/shared/projection-helpers.d.ts +19 -0
  115. package/dist/engines/shared/redact-data-models-closed-to-ai.d.ts +55 -0
  116. package/dist/engines/shared/redact-hidden-columns-from-ai.d.ts +55 -0
  117. package/dist/index.d.ts +20 -0
  118. package/dist/index.js +57916 -30543
  119. package/dist/services/ai-access/ai-access-service.d.ts +68 -0
  120. package/dist/services/dashboards/dashboards-service.d.ts +9 -3
  121. package/dist/services/dashboards/fusion-dashboards-service.d.ts +34 -4
  122. package/dist/services/data-sources/data-sources-service.d.ts +131 -2
  123. package/dist/services/data-sources/find-data-source-by-title.d.ts +8 -0
  124. package/dist/services/datamodel-graph/datamodel-graph-service.d.ts +457 -0
  125. package/dist/services/existing-answer/existing-answer-query-service.d.ts +31 -0
  126. package/dist/services/formulas/formulas-service.d.ts +19 -0
  127. package/dist/services/hide-from-ai/hide-from-ai.d.ts +31 -0
  128. package/dist/services/knowledge-graph/knowledge-graph-service.d.ts +96 -0
  129. package/dist/services/llm/llm-consumption-service.d.ts +7 -2
  130. package/dist/services/llm/llm-settings-service.d.ts +49 -5
  131. package/dist/services/nlq/nlq-preview-dataset.d.ts +34 -0
  132. package/dist/services/nlq/nlq-service.d.ts +138 -3
  133. package/dist/services/pulse/evaluate-pulse-client.d.ts +78 -0
  134. package/dist/services/pulse/pulse-alerts-service.d.ts +264 -0
  135. package/dist/services/pulse/pulse-events-service.d.ts +217 -0
  136. package/dist/services/semantic-search/semantic-search-service.d.ts +43 -0
  137. package/dist/services/tool-store/tool-store-service.d.ts +32 -0
  138. package/dist/services/users-groups-service.d.ts +37 -0
  139. package/dist/skills/index.d.ts +127 -0
  140. package/dist/tool-availability/controlled-tools.d.ts +56 -0
  141. package/dist/tool-availability/index.d.ts +4 -0
  142. package/dist/tool-availability/offer-tools.d.ts +44 -0
  143. package/dist/tool-availability/resolve-tool-availability.d.ts +68 -0
  144. package/dist/tool-availability/withdrawn-text.d.ts +33 -0
  145. package/dist/tool-catalog/catalog.d.ts +387 -0
  146. package/dist/tool-catalog/index.d.ts +3 -0
  147. package/dist/tool-catalog/manifest.d.ts +5 -0
  148. package/dist/tool-catalog/prototype-lookup.d.ts +10 -0
  149. package/dist/tool-catalog/types.d.ts +67 -0
  150. package/dist/tools.manifest.json +826 -0
  151. package/dist/utils/chat-stream-errors.d.ts +42 -0
  152. package/dist/utils/create-custom-fetch.d.ts +19 -1
  153. package/dist/utils/create-stream-completion.d.ts +84 -6
  154. package/dist/utils/create-structured-completion.d.ts +29 -2
  155. package/dist/utils/create-tools-completion.d.ts +9 -0
  156. package/dist/utils/deferred-tools.d.ts +45 -0
  157. package/dist/utils/dev-debug.d.ts +5 -0
  158. package/dist/utils/generate-suggestions.d.ts +32 -0
  159. package/dist/utils/http-client.d.ts +3 -1
  160. package/dist/utils/llm-call-observer.d.ts +83 -0
  161. package/dist/utils/llm-client.d.ts +11 -1
  162. package/dist/utils/quoted-text.d.ts +6 -0
  163. package/dist/utils/server-error-body.d.ts +23 -0
  164. package/dist/utils/text-tokens.d.ts +35 -0
  165. package/dist/utils/user-action-tracking.d.ts +48 -5
  166. package/dist/utils/zod-utils.d.ts +9 -1
  167. package/package.json +28 -19
@@ -1,30 +1,151 @@
1
- import { z } from 'zod/v4';
1
+ import { z } from 'zod';
2
2
  import { HttpClient } from '@sisense/sdk-rest-client';
3
- import { Dataset, QueryExecutionResult, QueryState } from '../../services/nlq/nlq-service';
3
+ import { DataSchemaContext } from '@sisense/sdk-ui/analytics-composer';
4
+ import { ColumnValuesResolvedEntry, Dataset, QueryExecutionResult, QueryState } from '../../services/nlq/nlq-service';
5
+ import { WidgetSearchResultPermission } from '../../services/semantic-search/semantic-search-service';
4
6
  export interface QueryResult {
5
7
  queryId: string;
6
8
  title: string;
7
9
  nlqResult: QueryExecutionResult;
8
10
  }
11
+ /**
12
+ * A real, existing widget found by the existing-answer cascade (KG similar-question match, or
13
+ * direct widget semantic search) that already answers a new question — returned instead of
14
+ * generating a fresh NLQ query. See engines/shared/existing-answer-cascade.ts.
15
+ */
16
+ export interface ExistingAnswerMatch {
17
+ source: 'kg' | 'widget-search';
18
+ /**
19
+ * KG's `question_id` for the question this match came from — present only on a `kg` match
20
+ * (widget-search hits have no `Question` node). Lets the caller count the ask against that
21
+ * question (SNS-132590), which capture cannot do because a cascade hit never reaches
22
+ * generation.
23
+ */
24
+ questionId?: string;
25
+ /** Real cosine similarity (kg: question-embedding match; widget-search: title/description match). Not comparable across sources. */
26
+ confidence: number;
27
+ widgetId: string;
28
+ dashboardId: string;
29
+ title: string;
30
+ description?: string;
31
+ dashboardTitle?: string;
32
+ url?: string;
33
+ permission?: WidgetSearchResultPermission;
34
+ /**
35
+ * The captured CSDK query (QueryJSON-shaped), present only on a feedback-verified `kg` match
36
+ * with no backing widget (`widgetId` empty) — see `findKgMatch`. Lets `buildQueryEngine`
37
+ * reconstruct a real chart directly from the captured query instead of only a link-only card.
38
+ */
39
+ csdkJson?: string;
40
+ }
41
+ /**
42
+ * Verified-match provenance, attachable to an already-resolved `nlq` result (Tier 1 post-generation
43
+ * matching — see `buildQueryEngine`). Deliberately omits `title`/`description` from
44
+ * {@link ExistingAnswerMatch}: those describe the *matched widget*, and would collide confusingly
45
+ * with `QueryResult`'s own `title` (the resolved query's title) if merged in.
46
+ */
47
+ export type VerifiedMatchProvenance = Pick<ExistingAnswerMatch, 'source' | 'confidence' | 'widgetId' | 'dashboardId' | 'dashboardTitle' | 'url' | 'permission'>;
48
+ /**
49
+ * Why a `verifiedAnswerId` could not be rerun (SNS-131459): `unavailable` — unknown, withdrawn,
50
+ * unreadable or the read failed; `stale` — the answer no longer matches its data model;
51
+ * `invalid` — its saved query is not a usable query state, the schema read failed, or the saved
52
+ * query returned no dataset.
53
+ */
54
+ export type VerifiedAnswerFallback = 'unavailable' | 'stale' | 'invalid';
55
+ /**
56
+ * An admin-approved query, read by its id to be run as saved instead of generated (SNS-131459).
57
+ * Like `existing-chart`, the engine returns the query state and schema without executing it; the
58
+ * host reads its dataset.
59
+ */
60
+ export interface VerifiedAnswerRerun {
61
+ verifiedAnswerId: string;
62
+ /** KG's question id, to count the ask once the rerun is served. */
63
+ questionId: string;
64
+ question: string;
65
+ title: string;
66
+ queryState: QueryState;
67
+ dataSchema: DataSchemaContext;
68
+ }
69
+ /**
70
+ * `buildQueryEngine`'s result: an existing widget reconstructed into a real, buildChart-ready
71
+ * query (fast path, no LLM generation, renders like a normal chart); the same existing-answer
72
+ * match but only as a link/preview, when reconstruction failed for that widget's JAQL; or a
73
+ * freshly generated NLQ result — same discriminant the tool/renderer branch on. A freshly generated
74
+ * result may optionally carry {@link VerifiedMatchProvenance} when Tier 1's post-generation widget
75
+ * match found a hit (revision, or a first-turn question the pre-generation cascade missed).
76
+ */
77
+ export type BuildQueryOutcome = ({
78
+ kind: 'existing-answer';
79
+ } & ExistingAnswerMatch) | ({
80
+ kind: 'existing-chart';
81
+ } & ExistingAnswerMatch & {
82
+ queryState: QueryState;
83
+ dataSchema: DataSchemaContext;
84
+ chartType?: string;
85
+ }) | ({
86
+ kind: 'verified-answer';
87
+ } & VerifiedAnswerRerun) | ({
88
+ kind: 'nlq';
89
+ } & QueryResult & Partial<VerifiedMatchProvenance> & {
90
+ /**
91
+ * Set when `verifiedAnswerId` was given but the verified answer could not be used,
92
+ * so this query was generated from `queryPrompt` instead (SNS-131459).
93
+ */
94
+ verifiedAnswerFallback?: VerifiedAnswerFallback;
95
+ });
9
96
  /**
10
97
  * Canonical tool description for buildQuery — reusable by any host (sdk-assistant, MCP server, custom integrations).
11
98
  * Hosts may append host-specific notes but should not duplicate or contradict this text.
12
99
  */
13
- export declare const buildQueryToolDescription = "Runs an analytics query from a natural language prompt and returns the results as structured data (tabular exploration, no chart).\n\n**New query** \u2014 Only for the first query in a chain, or when the user clearly abandons the prior result and starts unrelated analysis. Omit `priorQueryId` (or null). Put the full natural-language intent in `queryPrompt`.\n\n**Revise an existing query** \u2014 Use for same-thread follow-ups that adjust the *same* analysis: different breakdown (e.g. by year, by category), added or removed filters, sort order, measure swaps, limits (Top N), trend/forecast, etc. Treat these as revisions, not separate unrelated queries.\n\nFor revisions: \n- Set `priorQueryId` to the exact string in the `queryId` field from the **latest successful** tool result of this tool in the conversation (that value is the same id you pass as `queryId` when wiring a prior tabular result into the chart tool). \n- In `queryPrompt`, pass only the delta vs. that prior query \u2014 do not repeat the full prior specification.\n\nReturn value includes queryId, queryState, and dataset rows. If the dataset includes a \"sample\" key, the full result was size-limited \u2014 call the chart tool with that queryId so the user can explore the complete result in the chart widget.";
100
+ export declare const buildQueryToolDescription = "Runs the analytics query described in `queryPrompt` and returns structured data (tabular exploration, no chart): queryId, queryState and dataset rows. A \"sample\" key means the result was size-limited \u2014 call the chart tool with that queryId so the user can explore all of it.\n\n**Filter values are taken literally.** A filter on a text column (category, type, status, tier, segment\u2026) uses the exact strings in `queryPrompt`: \"except refunds\" filters on \"refunds\" even when the column stores \"Ret - Customer Refund\", and the total still looks correct. Before filtering such a column, read its values with getDataPreview and write the stored spellings into `queryPrompt`. Only an explicit contains / starts with / ends with predicate passes through unchanged; a quoted value name is not one.\n\n**New query** \u2014 the first query in a chain, or when the user abandons the prior result for unrelated analysis. Omit `priorQueryId`; put the full intent in `queryPrompt`.\n\n**Revision** \u2014 same-thread follow-ups on the *same* analysis (breakdown, filters, sort, measure swap, Top N, trend/forecast). Set `priorQueryId` to the `queryId` of this tool's **latest successful** result (the id you also pass to the chart tool), and put only the delta in `queryPrompt`.\n\nA new question may instead match an existing human-built widget (the result has `matchConfidence` \u2014 mention it, e.g. \"~72% match\"). Usually it is reconstructed into a real query: treat it like any result above. If it cannot be, the tool returns a title/description/link with no queryId \u2014 present that as the answer and do not call the chart tool. Neither case is a failure.\n\n**Escaping a bad match** \u2014 if the user rejects the returned widget and asks for a fresh query, or a remembered preference says to always build fresh, re-call with the same `queryPrompt` and `forceNewQuery: true`. A bare re-call without it returns the identical match again.";
14
101
  /**
15
102
  * Schema for buildQuery engine parameters
16
103
  */
104
+ export declare const USER_QUESTION_DESCRIPTION = "The question the user is asking, kept as a record of what was asked. It does not affect the query. Write it in the user's language and vocabulary, as one complete question that makes sense on its own, to a reader who has not seen the conversation. When the user's latest message is a complete question that stands on its own, copy it unchanged, typos included, even when it follows an earlier question. Only when it does not stand on its own (a reply such as \"yes\", or a fragment such as \"top 5 only\"), rewrite it: take the question it builds on, apply the change, and write the single full question the user now means. In a rewrite, never copy the fragment itself, never append it to the earlier question, and leave out words that point at the conversation (\"instead\", \"same\", \"it\", \"that\", \"now\", \"too\", \"also\", \"only\" without its subject). Examples: after \"how many units did we sell per age range\", the follow-up \"same but for revenue\" becomes \"how much revenue did we make per age range\", and then \"sort it from lowest to highest\" becomes \"how much revenue did we make per age range, from lowest to highest\"; after \"top 5 countries by revenue\", \"make it the bottom 5 instead\" becomes \"bottom 5 countries by revenue\". Use no table, column or formula names the user did not use, and include only the question itself: no context blocks, data values or tool results.";
17
105
  export declare const buildQuerySchema: z.ZodObject<{
18
106
  dataSourceTitle: z.ZodString;
19
107
  queryPrompt: z.ZodString;
20
108
  priorQueryId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
109
+ forceNewQuery: z.ZodOptional<z.ZodBoolean>;
110
+ userQuestion: z.ZodOptional<z.ZodString>;
111
+ }, z.core.$strip>;
112
+ /**
113
+ * `buildQuerySchema` plus the subject area the data model map chose (SNS-131459 routing).
114
+ * Only hosts that register the map tools use it, so with the map off the LLM-visible
115
+ * schema is exactly `buildQuerySchema`.
116
+ */
117
+ export declare const buildQueryWithSubjectAreaSchema: z.ZodObject<{
118
+ dataSourceTitle: z.ZodString;
119
+ queryPrompt: z.ZodString;
120
+ priorQueryId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
121
+ forceNewQuery: z.ZodOptional<z.ZodBoolean>;
122
+ userQuestion: z.ZodOptional<z.ZodString>;
123
+ subjectAreaId: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ export declare const VERIFIED_ANSWER_ID_DESCRIPTION = "The id of a verified answer, exactly as printed inside [verified \u2026], when findSubjectAreas marked it \"SAME question\" or it asks the same measures and breakdowns as the user's question (only worded differently). Reruns that admin-approved query instead of generating one. Omit it when the question differs, and always on a revision (priorQueryId).";
126
+ /**
127
+ * The schema with the data model map on: the routed subject area plus a verified answer to
128
+ * rerun (SNS-131459). Only map hosts register it, so with the map off the LLM-visible schema is
129
+ * exactly `buildQuerySchema`.
130
+ */
131
+ export declare const buildQueryWithMapSchema: z.ZodObject<{
132
+ dataSourceTitle: z.ZodString;
133
+ queryPrompt: z.ZodString;
134
+ priorQueryId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
+ forceNewQuery: z.ZodOptional<z.ZodBoolean>;
136
+ userQuestion: z.ZodOptional<z.ZodString>;
137
+ subjectAreaId: z.ZodOptional<z.ZodString>;
138
+ verifiedAnswerId: z.ZodOptional<z.ZodString>;
21
139
  }, z.core.$strip>;
140
+ export type BuildQueryParams = z.infer<typeof buildQueryWithMapSchema>;
22
141
  /**
23
142
  * Context interface for buildQueryEngine
24
143
  */
25
144
  export interface BuildQueryContext {
26
145
  /** Tool call ID for tracking */
27
146
  toolCallId: string;
147
+ /** `x-tool-name` for this run's calls when another tool runs the engine. Default `buildQuery`. */
148
+ toolName?: string;
28
149
  /** HTTP client for API calls (optional, uses singleton if not provided) */
29
150
  httpClient?: HttpClient;
30
151
  /** Common filters (e.g., from dashboard filters) to be applied to the query. */
@@ -40,6 +161,25 @@ export interface BuildQueryContext {
40
161
  * When false, prior state is inlined into `text` instead (instances without wire delta support).
41
162
  */
42
163
  isNlqDeltaEnabled?: boolean;
164
+ /** Original verbatim user question, for Knowledge Graph capture. */
165
+ userQuery?: string;
166
+ /** Columns whose values this turn already read, forwarded so smart query does not read them again. */
167
+ columnValuesResolved?: ColumnValuesResolvedEntry[];
168
+ /**
169
+ * Whether the existing-answer cascade (KG similar-question + widget semantic-search) may run
170
+ * for a new (non-revision) question. Defaults to enabled when omitted, so hosts/tests that
171
+ * don't thread this keep today's behavior — set to `false` to respect an admin's
172
+ * `ai.experiments.existingAnswerCascade` toggle being off.
173
+ */
174
+ cascadeEnabled?: boolean;
175
+ /**
176
+ * Score a KG match must reach for the cascade to serve it, from
177
+ * `ai.experiments.existingAnswerCascade.assistantSimilarityThreshold` in ZooKeeper. Omitted
178
+ * when the environment configures none, in which case
179
+ * {@link KG_SIMILARITY_SCORE_THRESHOLD} applies — so hosts and tests that don't thread this
180
+ * keep today's behaviour.
181
+ */
182
+ assistantSimilarityThreshold?: number;
43
183
  }
44
184
  /** Summary of a query for LLM consumption (tool response and prompt context). */
45
185
  export interface QuerySummary {
@@ -47,10 +187,83 @@ export interface QuerySummary {
47
187
  title: string;
48
188
  queryState: QueryState;
49
189
  dataset: Dataset;
190
+ /**
191
+ * The query's full row count, when the dataset reports one — set even when `dataset` is capped
192
+ * to a `sample` or omitted, so a caller can check it against a row budget (SNS-134141: a Pulse
193
+ * trend/forecast query must fit in 300 rows).
194
+ */
195
+ rowCount?: number;
196
+ /**
197
+ * buildChart-compatible chart family (e.g. `'bar'`, `'indicator'`, `'scatter'`) the LLM should
198
+ * pass as `action.chartType` — only set for a reconstructed existing-chart result, where the
199
+ * original widget's own chart type is a real, free signal. Without it, buildChart's chartType
200
+ * is guessed purely from query shape, which fails for e.g. a single aggregate measure with no
201
+ * dimensions (guessed as `bar`, then rejected client-side: "Incorrect data options" — confirmed
202
+ * live on a reconstructed indicator widget).
203
+ */
204
+ suggestedChartType?: string;
205
+ /**
206
+ * Rounded 0-100 confidence, only set for a reconstructed existing-chart result — mirrors
207
+ * {@link ExistingAnswerSummary.matchConfidence} so the LLM can mention it here too, per
208
+ * {@link buildQueryToolDescription}'s instruction (not comparable across `source`).
209
+ */
210
+ matchConfidence?: number;
211
+ /** Set on a verified answer rerun: the question the admin approved this query for. */
212
+ verifiedAnswer?: {
213
+ question: string;
214
+ };
215
+ /** What to tell the user about a verified answer, or about one that could not be used. */
216
+ verifiedAnswerNote?: string;
50
217
  }
218
+ /** Added to a query generated because the requested verified answer could not be used. */
219
+ export declare const VERIFIED_ANSWER_FALLBACK_NOTE = "The verified answer could not be used (withdrawn, changed or unreadable), so this query was generated from queryPrompt. Do not present it as a verified answer.";
220
+ /**
221
+ * Labels a rerun verified answer's summary (SNS-131459). The summary is a normal
222
+ * {@link toQuerySummary} result (dataset included when `includeDataset`, so the model can answer from
223
+ * the rows; otherwise the note points it to buildChart). `dashboardFiltered` adds that the dashboard's
224
+ * filters were applied; `dashboardFilterColumns` (column names only, never values) names them so the
225
+ * model does not describe the numbers as unfiltered.
226
+ */
227
+ export declare function withVerifiedAnswerLabel(summary: QuerySummary, question: string, includeDataset: boolean, dashboardFiltered?: boolean, dashboardFilterColumns?: readonly string[]): QuerySummary;
228
+ /**
229
+ * Caps the dataset handed to the LLM at `maxRows` rows (SNS-132836). Non-mutating: returns a shallow
230
+ * copy with the over-cap rows dropped, never touching the caller's object — the UI renderer reads the
231
+ * full dataset off the untouched `QueryResult`, not this summary. When it truncates, the kept rows are
232
+ * emitted under a `sample` key: the same size-limiting signal the NLQ backend already uses, which
233
+ * {@link buildQueryToolDescription} already tells the model to read as "call buildChart with this
234
+ * queryId to see the full result". Left untouched: strings, a dataset already within the cap, and a
235
+ * dataset the backend already size-limited (its own `sample` key stands).
236
+ */
237
+ export declare function capDatasetForSummary(dataset: Dataset, maxRows?: number): Dataset;
51
238
  /**
52
239
  * Converts a QueryResult into a summary for LLM consumption.
53
240
  * @param result - The query result
54
241
  * @param includeDataset - Whether to include the full dataset (enables natural response). When false, returns a directive to build a chart instead.
55
242
  */
56
243
  export declare function toQuerySummary(result: QueryResult, includeDataset?: boolean): QuerySummary;
244
+ /** Summary of an existing-answer match for LLM consumption. */
245
+ export interface ExistingAnswerSummary {
246
+ title: string;
247
+ description?: string;
248
+ dashboardTitle?: string;
249
+ url?: string;
250
+ /** Rounded 0-100 confidence, for display (e.g. "~72% match"). Not comparable across `source`. */
251
+ matchConfidence: number;
252
+ message: string;
253
+ }
254
+ /**
255
+ * Converts an ExistingAnswerMatch into a summary for LLM consumption — no dataset/queryState,
256
+ * since this points at an existing widget rather than a freshly generated query.
257
+ */
258
+ export declare function toExistingAnswerSummary(match: ExistingAnswerMatch): ExistingAnswerSummary;
259
+ /**
260
+ * Converts a reconstructed existing-widget query into the same {@link QuerySummary} shape a
261
+ * fresh NLQ result would produce — same "call buildChart with this queryId" convention
262
+ * (`toQuerySummary`'s `dataset` directive string), so the LLM treats it identically to a normal
263
+ * query result rather than needing separate handling for the "existing-chart" outcome.
264
+ * @param queryId - The queryId to pass to buildChart
265
+ * @param title - The reconstructed widget's title
266
+ * @param queryState - The reconstructed CSDK query state
267
+ * @param chartType - The widget's buildChart-compatible chart family, if resolved server-side
268
+ */
269
+ export declare function toExistingChartSummary(queryId: string, title: string, queryState: QueryState, chartType?: string, confidence?: number): QuerySummary;
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { BuildStatusEngineContext, ExplainBuildFailureResult, explainBuildFailureSchema, GetBuildStatusResult, getBuildStatusSchema, ListBuildsResult, listBuildsSchema } from './types';
3
+ /** The status of one build, or of a data model's latest build. */
4
+ export declare function getBuildStatusEngine(params: z.infer<typeof getBuildStatusSchema>, context: BuildStatusEngineContext): Promise<GetBuildStatusResult>;
5
+ /** A data model's recent builds, newest first. */
6
+ export declare function listBuildsEngine(params: z.infer<typeof listBuildsSchema>, context: BuildStatusEngineContext): Promise<ListBuildsResult>;
7
+ /** Why a build failed: a data model's latest failed build, or one build. */
8
+ export declare function explainBuildFailureEngine(params: z.infer<typeof explainBuildFailureSchema>, context: BuildStatusEngineContext): Promise<ExplainBuildFailureResult>;
@@ -0,0 +1,44 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ import { BuildError, BuildRunStatus, BuildSummary } from './types';
3
+ /**
4
+ * A build as the public build API returns it (be-services `BuildInfoDTO`). `error` is present only
5
+ * on a failed build, and only for a user who can edit the data model (SNS-136461).
6
+ */
7
+ export interface BuildRecord {
8
+ oid?: string | null;
9
+ datamodelId?: string | null;
10
+ datamodelTitle?: string | null;
11
+ buildType?: string | null;
12
+ status?: string | null;
13
+ created?: string | number | null;
14
+ started?: string | number | null;
15
+ completed?: string | number | null;
16
+ error?: BuildError | null;
17
+ }
18
+ /** Why a read of the build API did not return builds. */
19
+ export type BuildsReadFailure = 'notFound' | 'unavailable';
20
+ export type BuildsRead<T> = {
21
+ ok: true;
22
+ value: T;
23
+ } | {
24
+ ok: false;
25
+ failure: BuildsReadFailure;
26
+ };
27
+ /**
28
+ * One build. The build API leaves a build's error out unless asked (`includeError=true`, here and
29
+ * on the list), so that no other consumer of the API sees the field; it is filled only for a user
30
+ * who can edit the data model.
31
+ */
32
+ export declare function fetchBuild(buildOid: string, httpClient: HttpClient, options?: {
33
+ includeError?: boolean;
34
+ }): Promise<BuildsRead<BuildRecord>>;
35
+ /**
36
+ * Every build of one data model the user may view, newest first. The list merges the legacy and
37
+ * the new build architecture's builds in no set order, so the order is ours.
38
+ */
39
+ export declare function fetchModelBuilds(datamodelOid: string, httpClient: HttpClient, options?: {
40
+ includeError?: boolean;
41
+ }): Promise<BuildsRead<BuildRecord[]>>;
42
+ /** dimTablesValidationFailed is a failed build too; its error says what failed. */
43
+ export declare function normalizeStatus(status: string | null | undefined): BuildRunStatus;
44
+ export declare function toBuildSummary(build: BuildRecord, now: number): BuildSummary;
@@ -0,0 +1,2 @@
1
+ export { explainBuildFailureEngine, getBuildStatusEngine, listBuildsEngine, } from './build-status-engine';
2
+ export * from './types';
@@ -0,0 +1,177 @@
1
+ import { z } from 'zod';
2
+ import { HttpClient } from '@sisense/sdk-rest-client';
3
+ /**
4
+ * How long the build service keeps builds (be-services `BuildLogData` retention). The period is a
5
+ * configuration setting, so the text gives the defaults only as defaults. The tools say it when a
6
+ * data model has no builds, so the model does not read "none kept" as "never built".
7
+ */
8
+ export declare const BUILD_RETENTION_TEXT = "Sisense keeps builds for a limited time that an administrator can configure (by default 7 days, up to 250 builds per tenant).";
9
+ /**
10
+ * Canonical tool descriptions for the build read tools (PR-1519, SNS-136533). One question per
11
+ * tool: the status of one build, the history of a data model, and why a build failed.
12
+ */
13
+ export declare const getBuildStatusToolDescription = "Get the status of an ElastiCube data model build: one build by its buildOid, or the latest build of a data model by its datamodelOid (the data model's oid from the data sources list). Returns the status (building, done, failed or cancelled; unknown for a status the build service reports that this tool does not recognize), the build type, when it started and ended, and how long it ran or has been running. Progress is reported as the status and the elapsed time only. For earlier builds use listBuilds; for why a build failed use explainBuildFailure.";
14
+ export declare const listBuildsToolDescription = "List the recent builds of an ElastiCube data model, newest first, by its datamodelOid (the data model's oid from the data sources list). For each build: its buildOid, status, build type, start and end time and duration. Sisense keeps builds for a limited time that an administrator can configure (by default 7 days, up to 250 builds per tenant). Older builds are not listed. For only the latest build use getBuildStatus.";
15
+ export declare const explainBuildFailureToolDescription = "Explain why an ElastiCube data model build failed, by buildOid or by datamodelOid (the data model's oid from the data sources list). With buildOid, it explains that build. With datamodelOid, it explains the data model's most recent failed build, which may be older than its latest build (getBuildStatus reports the latest build). Returns the error code, a short title, the suggested fix (mitigation) and the error message, so the user can act on it. Only users who can edit the data model can see the error details.";
16
+ export declare const getBuildStatusSchema: z.ZodObject<{
17
+ datamodelOid: z.ZodOptional<z.ZodString>;
18
+ buildOid: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ export declare const listBuildsSchema: z.ZodObject<{
21
+ datamodelOid: z.ZodString;
22
+ limit: z.ZodOptional<z.ZodNumber>;
23
+ }, z.core.$strip>;
24
+ export declare const explainBuildFailureSchema: z.ZodObject<{
25
+ datamodelOid: z.ZodOptional<z.ZodString>;
26
+ buildOid: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>;
28
+ export declare const BUILD_RUN_STATUSES: readonly ["building", "done", "failed", "cancelled", "unknown"];
29
+ export type BuildRunStatus = (typeof BUILD_RUN_STATUSES)[number];
30
+ export declare const BUILD_OUTCOMES: readonly ["ok", "partial", "refused", "failed"];
31
+ export type BuildOutcome = (typeof BUILD_OUTCOMES)[number];
32
+ /**
33
+ * One fact about the call, per the tool outcome contract: `message` is a fixed sentence about
34
+ * "the user", written here (never upstream error text), with the same facts as `data`.
35
+ */
36
+ export declare const buildToolNoteSchema: z.ZodObject<{
37
+ code: z.ZodString;
38
+ subject: z.ZodString;
39
+ data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
40
+ recoverable: z.ZodString;
41
+ message: z.ZodString;
42
+ }, z.core.$strip>;
43
+ export type BuildToolNote = z.infer<typeof buildToolNoteSchema>;
44
+ export declare const buildSummarySchema: z.ZodObject<{
45
+ buildOid: z.ZodString;
46
+ datamodelOid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ datamodelTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ status: z.ZodEnum<{
49
+ unknown: "unknown";
50
+ done: "done";
51
+ building: "building";
52
+ failed: "failed";
53
+ cancelled: "cancelled";
54
+ }>;
55
+ buildType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ startedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ durationSeconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
59
+ }, z.core.$strip>;
60
+ export type BuildSummary = z.infer<typeof buildSummarySchema>;
61
+ export declare const buildErrorSchema: z.ZodObject<{
62
+ code: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
63
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
+ mitigation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
+ message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ }, z.core.$strip>;
67
+ export type BuildError = z.infer<typeof buildErrorSchema>;
68
+ export declare const getBuildStatusResultSchema: z.ZodObject<{
69
+ build: z.ZodOptional<z.ZodNullable<z.ZodObject<{
70
+ buildOid: z.ZodString;
71
+ datamodelOid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ datamodelTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ status: z.ZodEnum<{
74
+ unknown: "unknown";
75
+ done: "done";
76
+ building: "building";
77
+ failed: "failed";
78
+ cancelled: "cancelled";
79
+ }>;
80
+ buildType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ startedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ durationSeconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
84
+ }, z.core.$strip>>>;
85
+ outcome: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
86
+ ok: "ok";
87
+ failed: "failed";
88
+ partial: "partial";
89
+ refused: "refused";
90
+ }>>>;
91
+ notes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
92
+ code: z.ZodString;
93
+ subject: z.ZodString;
94
+ data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
95
+ recoverable: z.ZodString;
96
+ message: z.ZodString;
97
+ }, z.core.$strip>>>>;
98
+ }, z.core.$strip>;
99
+ export declare const listBuildsResultSchema: z.ZodObject<{
100
+ builds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
101
+ buildOid: z.ZodString;
102
+ datamodelOid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
+ datamodelTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
+ status: z.ZodEnum<{
105
+ unknown: "unknown";
106
+ done: "done";
107
+ building: "building";
108
+ failed: "failed";
109
+ cancelled: "cancelled";
110
+ }>;
111
+ buildType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
112
+ startedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
113
+ completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
+ durationSeconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
115
+ }, z.core.$strip>>>>;
116
+ totalBuilds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
117
+ truncated: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
118
+ outcome: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
119
+ ok: "ok";
120
+ failed: "failed";
121
+ partial: "partial";
122
+ refused: "refused";
123
+ }>>>;
124
+ notes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
125
+ code: z.ZodString;
126
+ subject: z.ZodString;
127
+ data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
128
+ recoverable: z.ZodString;
129
+ message: z.ZodString;
130
+ }, z.core.$strip>>>>;
131
+ }, z.core.$strip>;
132
+ export declare const explainBuildFailureResultSchema: z.ZodObject<{
133
+ build: z.ZodOptional<z.ZodNullable<z.ZodObject<{
134
+ buildOid: z.ZodString;
135
+ datamodelOid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
136
+ datamodelTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
137
+ status: z.ZodEnum<{
138
+ unknown: "unknown";
139
+ done: "done";
140
+ building: "building";
141
+ failed: "failed";
142
+ cancelled: "cancelled";
143
+ }>;
144
+ buildType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
145
+ startedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
146
+ completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
147
+ durationSeconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
148
+ }, z.core.$strip>>>;
149
+ error: z.ZodOptional<z.ZodNullable<z.ZodObject<{
150
+ code: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
151
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
152
+ mitigation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
153
+ message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
+ }, z.core.$strip>>>;
155
+ outcome: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
156
+ ok: "ok";
157
+ failed: "failed";
158
+ partial: "partial";
159
+ refused: "refused";
160
+ }>>>;
161
+ notes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
162
+ code: z.ZodString;
163
+ subject: z.ZodString;
164
+ data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
165
+ recoverable: z.ZodString;
166
+ message: z.ZodString;
167
+ }, z.core.$strip>>>>;
168
+ }, z.core.$strip>;
169
+ export type GetBuildStatusResult = z.infer<typeof getBuildStatusResultSchema>;
170
+ export type ListBuildsResult = z.infer<typeof listBuildsResultSchema>;
171
+ export type ExplainBuildFailureResult = z.infer<typeof explainBuildFailureResultSchema>;
172
+ export interface BuildStatusEngineContext {
173
+ toolCallId: string;
174
+ httpClient?: HttpClient;
175
+ /** For tests: the clock the running duration is measured against. */
176
+ now?: () => number;
177
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The tools the data model map replaces (SNS-134426). With the map on they are not
3
+ * registered at all: findSubjectAreas / getSubjectAreas / getSubjectArea / exploreDataModel
4
+ * are the only way to choose data and read fields, and the map engines read the data source
5
+ * list or the plain fields themselves when the map cannot answer.
6
+ */
7
+ export declare const TOOLS_REPLACED_BY_DATA_MODEL_MAP: readonly ["getDataSources", "getDataSourceFields"];
8
+ /**
9
+ * Sentences that name a replaced tool, rewritten for a session with the map on. Applied in
10
+ * order, before the name rule below, so each reads as a map instruction rather than a
11
+ * renamed one. Every `from` is taken verbatim from a prompt, skill, tool description or tool
12
+ * result that a map session can show the model (data-model-map-text.test.ts checks that each
13
+ * still matches, so a reworded source fails loudly instead of silently skipping its edit).
14
+ */
15
+ export declare const DATA_MODEL_MAP_TEXT_EDITS: readonly (readonly [
16
+ from: string,
17
+ to: string
18
+ ])[];
19
+ /** True when `text` names a tool the data model map replaces. */
20
+ export declare function mentionsToolsReplacedByDataModelMap(text: string): boolean;
21
+ /**
22
+ * `text` as a session with the data model map on must read it: every instruction that names
23
+ * getDataSources or getDataSourceFields points at the map tools instead. The one rewrite for
24
+ * every surface — system prompt, skills, tool descriptions and parameter descriptions, and
25
+ * tool error text — so the wording lives in one place. Only map sessions call it; the
26
+ * map-off text is never passed through it.
27
+ */
28
+ export declare function rewriteForDataModelMap(text: string): string;
@@ -0,0 +1,31 @@
1
+ import { DatamodelGraphEngineContext, ExploreDataModelParams, ExploreDataModelResult, FindSubjectAreasContext, FindSubjectAreasParams, FindSubjectAreasResult, GetSubjectAreaParams, GetSubjectAreasParams, GetWidgetPatternParams, SubjectAreaResult, SubjectAreasResult, WidgetPatternResult } from './types';
2
+ /** Message of the `not_ready` outcome a failed map read is turned into. */
3
+ export declare const MAP_READ_FAILED_MESSAGE = "the map could not be read";
4
+ /**
5
+ * When the map lists no usable subject area, the result also carries the data source's plain
6
+ * fields ({@link PlainFieldsFallback}). A 403 propagates (see {@link readMap}).
7
+ */
8
+ export declare function getSubjectAreasEngine({ dataSourceTitle }: GetSubjectAreasParams, context?: DatamodelGraphEngineContext): Promise<SubjectAreasResult>;
9
+ /** A map that is not ready (or failed) answers with the plain fields; an unknown id does not. */
10
+ export declare function getSubjectAreaEngine({ dataSourceTitle, subjectAreaId }: GetSubjectAreaParams, context?: DatamodelGraphEngineContext): Promise<SubjectAreaResult>;
11
+ /** A blank id is answered locally as not found; the server is never asked for `widgets/`. */
12
+ export declare function getWidgetPatternEngine({ dataSourceTitle, widgetOid }: GetWidgetPatternParams, { httpClient, abortSignal }?: DatamodelGraphEngineContext): Promise<WidgetPatternResult>;
13
+ /**
14
+ * One operation per call; a missing argument is answered locally so the model can retry. A
15
+ * map that is not ready (or failed) answers with the plain fields, like getSubjectAreas.
16
+ */
17
+ export declare function exploreDataModelEngine(params: ExploreDataModelParams, context?: DatamodelGraphEngineContext): Promise<ExploreDataModelResult>;
18
+ /** Candidates asked of the route: the assistant chooses among them. */
19
+ export declare const FIND_SUBJECT_AREAS_ROUTE_LIMIT = 10;
20
+ /**
21
+ * `listDataSources: true` answers with every data source the user can access (the
22
+ * getDataSources service, read here because the map tools replace that tool). A named data
23
+ * model is not searched: the answer is its full subject-area list, the same as
24
+ * getSubjectAreas (a 403 propagates the same way, and a model with no usable map carries its
25
+ * plain fields). Otherwise the concepts go to the route, which ranks up to 10 areas across
26
+ * every model the user can access; the open dashboard's models (trimmed, de-duplicated) are
27
+ * ranked first. The route never throws: the service turns every failure into `unavailable`.
28
+ * When it cannot choose (`unavailable`, or no candidates) the result also carries the data
29
+ * source list, so the model can still pick one or offer them.
30
+ */
31
+ export declare function findSubjectAreasEngine({ concepts, question, datamodel, listDataSources }: FindSubjectAreasParams, { httpClient, abortSignal, preferredDatamodels, plainFields, userQuestion, }?: FindSubjectAreasContext): Promise<FindSubjectAreasResult>;
@@ -0,0 +1,4 @@
1
+ export { exploreDataModelEngine, FIND_SUBJECT_AREAS_ROUTE_LIMIT, findSubjectAreasEngine, MAP_READ_FAILED_MESSAGE, getSubjectAreaEngine, getSubjectAreasEngine, getWidgetPatternEngine, } from './datamodel-graph-engine';
2
+ export { BUSINESS_NAMES_NOTE, businessNames, capSummary, DATA_SOURCES_LIST_HEADING, dataSourceLine, exploreDataModelSummary, findSubjectAreasSummary, getSubjectAreaSummary, getSubjectAreasSummary, getWidgetPatternSummary, BASIC_MAP_NOTE, LEARNED_ENTITY_CLOSING, LEARNED_TERMS_NOTE, learnedSourceText, PLAIN_FIELDS_MARKER, PLAIN_FIELDS_VALUES_NOTE, querySummaryText, rankedNoResultText, rankedRoutePrefix, rankedSelectionText, ROUTE_NO_AREA_VERIFIED_TEXT, ROUTE_NO_MATCH_OPTIONS_TEXT, ROUTE_NO_MATCH_TEXT, ROUTE_PICK_NEXT, ROUTE_UNAVAILABLE_NO_LIST_TEXT, ROUTE_UNAVAILABLE_TEXT, ROUTE_VERIFIED_OPTIONS_TEXT, VERIFIED_AREA_HEADING, VERIFIED_FORMULA_ONLY_TEXT, VERIFIED_MATCHES_HEADING, VERIFIED_SIMILAR_NEXT, verifiedRefText, verifiedSameNext, } from './summaries';
3
+ export * from './data-model-map-text';
4
+ export * from './types';