@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.
- package/dist/__vite-browser-external-l0sNRNKZ.js +1 -0
- package/dist/constants.d.ts +35 -0
- package/dist/engines/atomic-handle-args.d.ts +45 -0
- package/dist/engines/atomic-tool-requirements.d.ts +38 -0
- package/dist/engines/author-pulse/actions/create.d.ts +9 -0
- package/dist/engines/author-pulse/actions/define.d.ts +9 -0
- package/dist/engines/author-pulse/actions/load-existing.d.ts +9 -0
- package/dist/engines/author-pulse/actions/redefine.d.ts +9 -0
- package/dist/engines/author-pulse/actions/set-receive-notifications.d.ts +8 -0
- package/dist/engines/author-pulse/actions/update-spec.d.ts +11 -0
- package/dist/engines/author-pulse/actions/update-workflow.d.ts +9 -0
- package/dist/engines/author-pulse/atomic-adapter.d.ts +10 -0
- package/dist/engines/author-pulse/atomic-tools.d.ts +362 -0
- package/dist/engines/author-pulse/author-pulse-engine.d.ts +21 -0
- package/dist/engines/author-pulse/index.d.ts +9 -0
- package/dist/engines/author-pulse/shared/adjustment-error.d.ts +15 -0
- package/dist/engines/author-pulse/shared/assemble-create-workflow-payload.d.ts +36 -0
- package/dist/engines/author-pulse/shared/assert-agentic-workflow.d.ts +12 -0
- package/dist/engines/author-pulse/shared/compile-query-from-prompt.d.ts +95 -0
- package/dist/engines/author-pulse/shared/decision-spec-validation.d.ts +84 -0
- package/dist/engines/author-pulse/shared/notification-urls.d.ts +52 -0
- package/dist/engines/author-pulse/shared/pulse-knowledge.d.ts +36 -0
- package/dist/engines/author-pulse/shared/pulse-signature.d.ts +39 -0
- package/dist/engines/author-pulse/shared/resolve-frequency.d.ts +18 -0
- package/dist/engines/author-pulse/shared/staging.d.ts +65 -0
- package/dist/engines/author-pulse/shared/workflow-ownership.d.ts +14 -0
- package/dist/engines/author-pulse/types.d.ts +1385 -0
- package/dist/engines/build-chart/atomic-adapter.d.ts +20 -0
- package/dist/engines/build-chart/atomic-tools.d.ts +214 -0
- package/dist/engines/build-chart/build-chart-engine.d.ts +1 -1
- package/dist/engines/build-chart/chart-tool-name.d.ts +3 -0
- package/dist/engines/build-chart/create-chart/assemble-chart-widget.d.ts +1 -1
- package/dist/engines/build-chart/create-chart/chart-json-axes-mapping.d.ts +1 -1
- package/dist/engines/build-chart/create-chart/create-chart.d.ts +1 -1
- package/dist/engines/build-chart/create-chart/derive-chart-title.d.ts +7 -0
- package/dist/engines/build-chart/create-chart/generate-chart-recommendations.d.ts +2 -2
- package/dist/engines/build-chart/create-chart/resolve-chart-query.d.ts +4 -0
- package/dist/engines/build-chart/shared/normalize-cartesian-axes-mapping.d.ts +1 -1
- package/dist/engines/build-chart/shared/sync-chart-state-measure-flags.d.ts +3 -0
- package/dist/engines/build-chart/types.d.ts +38 -19
- package/dist/engines/build-chart/update-chart/apply-prior-chart-style.d.ts +8 -5
- package/dist/engines/build-chart/update-chart/chart-options-schemas.d.ts +18 -18
- package/dist/engines/build-chart/update-chart/schemas.d.ts +2 -2
- package/dist/engines/build-chart/update-chart/update-chart-data-options.d.ts +7 -2
- package/dist/engines/build-chart/update-chart/update-chart-query.d.ts +1 -1
- package/dist/engines/build-chart/update-chart/update-chart-style-options.d.ts +7 -2
- package/dist/engines/build-chart/update-chart/update-chart-title.d.ts +1 -1
- package/dist/engines/build-chart/update-chart/update-chart-type.d.ts +7 -2
- package/dist/engines/build-csv-model/build-csv-model-engine.d.ts +1 -1
- package/dist/engines/build-csv-model/types.d.ts +1 -1
- package/dist/engines/build-dashboard/add-dashboard-narration.d.ts +50 -0
- package/dist/engines/build-dashboard/add-dashboard-widgets.d.ts +1 -1
- package/dist/engines/build-dashboard/atomic-adapter.d.ts +21 -0
- package/dist/engines/build-dashboard/atomic-tools.d.ts +231 -0
- package/dist/engines/build-dashboard/build-dashboard-engine.d.ts +1 -1
- package/dist/engines/build-dashboard/build-dashboard-service.d.ts +2 -1
- package/dist/engines/build-dashboard/create-dashboard.d.ts +3 -4
- package/dist/engines/build-dashboard/dashboard-filters/manipulate-dashboard-filters.d.ts +2 -1
- package/dist/engines/build-dashboard/dashboard-filters/translate-filters.d.ts +17 -1
- package/dist/engines/build-dashboard/index.d.ts +2 -0
- package/dist/engines/build-dashboard/layout/place-widget.d.ts +53 -0
- package/dist/engines/build-dashboard/load-existing-fusion-dashboard.d.ts +1 -1
- package/dist/engines/build-dashboard/remove-dashboard-widgets.d.ts +4 -0
- package/dist/engines/build-dashboard/resolve-chart-widgets.d.ts +16 -0
- package/dist/engines/build-dashboard/types.d.ts +180 -18
- package/dist/engines/build-data-model/build-data-model-engine.d.ts +1 -1
- package/dist/engines/build-data-model/types.d.ts +1 -1
- package/dist/engines/build-query/build-query-engine.d.ts +33 -5
- package/dist/engines/build-query/index.d.ts +1 -1
- package/dist/engines/build-query/types.d.ts +216 -3
- package/dist/engines/build-status/build-status-engine.d.ts +8 -0
- package/dist/engines/build-status/builds-client.d.ts +44 -0
- package/dist/engines/build-status/index.d.ts +2 -0
- package/dist/engines/build-status/types.d.ts +177 -0
- package/dist/engines/datamodel-graph/data-model-map-text.d.ts +28 -0
- package/dist/engines/datamodel-graph/datamodel-graph-engine.d.ts +31 -0
- package/dist/engines/datamodel-graph/index.d.ts +4 -0
- package/dist/engines/datamodel-graph/summaries.d.ts +97 -0
- package/dist/engines/datamodel-graph/test-fixtures.d.ts +42 -0
- package/dist/engines/datamodel-graph/types.d.ts +190 -0
- package/dist/engines/evaluate-pulse/evaluate-pulse-engine.d.ts +10 -0
- package/dist/engines/evaluate-pulse/index.d.ts +2 -0
- package/dist/engines/evaluate-pulse/types.d.ts +85 -0
- package/dist/engines/get-dashboard-narration/get-dashboard-narration-engine.d.ts +23 -0
- package/dist/engines/get-dashboard-narration/index.d.ts +2 -0
- package/dist/engines/get-dashboard-narration/types.d.ts +64 -0
- package/dist/engines/get-dashboards/get-dashboards-engine.d.ts +1 -1
- package/dist/engines/get-dashboards/types.d.ts +16 -4
- package/dist/engines/get-data-preview/get-data-preview-engine.d.ts +18 -0
- package/dist/engines/get-data-preview/index.d.ts +2 -0
- package/dist/engines/get-data-preview/types.d.ts +35 -0
- package/dist/engines/get-data-source-fields/get-data-source-fields-engine.d.ts +12 -6
- package/dist/engines/get-data-source-fields/index.d.ts +1 -0
- package/dist/engines/get-data-source-fields/model-relations.d.ts +38 -0
- package/dist/engines/get-data-source-fields/types.d.ts +49 -3
- package/dist/engines/get-data-sources/get-data-sources-engine.d.ts +1 -1
- package/dist/engines/get-data-sources/types.d.ts +2 -2
- package/dist/engines/index.d.ts +17 -0
- package/dist/engines/inspect-pulse/atomic-adapter.d.ts +8 -0
- package/dist/engines/inspect-pulse/atomic-tools.d.ts +60 -0
- package/dist/engines/inspect-pulse/index.d.ts +4 -0
- package/dist/engines/inspect-pulse/inspect-pulse-engine.d.ts +7 -0
- package/dist/engines/inspect-pulse/types.d.ts +209 -0
- package/dist/engines/manage-perspectives/manage-perspectives-engine.d.ts +5 -1
- package/dist/engines/manage-perspectives/types.d.ts +13 -8
- package/dist/engines/pulse-tool-words.d.ts +62 -0
- package/dist/engines/recommend-queries/recommend-queries-engine.d.ts +1 -1
- package/dist/engines/recommend-queries/types.d.ts +1 -1
- package/dist/engines/shared/existing-answer-cascade.d.ts +52 -0
- package/dist/engines/shared/get-filters-json-for-llm-summary.d.ts +2 -2
- package/dist/engines/shared/nlq-query-helpers.d.ts +2 -2
- package/dist/engines/shared/project-dashboard-json.d.ts +151 -0
- package/dist/engines/shared/project-widget-json.d.ts +67 -0
- package/dist/engines/shared/projection-helpers.d.ts +19 -0
- package/dist/engines/shared/redact-data-models-closed-to-ai.d.ts +55 -0
- package/dist/engines/shared/redact-hidden-columns-from-ai.d.ts +55 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +57916 -30543
- package/dist/services/ai-access/ai-access-service.d.ts +68 -0
- package/dist/services/dashboards/dashboards-service.d.ts +9 -3
- package/dist/services/dashboards/fusion-dashboards-service.d.ts +34 -4
- package/dist/services/data-sources/data-sources-service.d.ts +131 -2
- package/dist/services/data-sources/find-data-source-by-title.d.ts +8 -0
- package/dist/services/datamodel-graph/datamodel-graph-service.d.ts +457 -0
- package/dist/services/existing-answer/existing-answer-query-service.d.ts +31 -0
- package/dist/services/formulas/formulas-service.d.ts +19 -0
- package/dist/services/hide-from-ai/hide-from-ai.d.ts +31 -0
- package/dist/services/knowledge-graph/knowledge-graph-service.d.ts +96 -0
- package/dist/services/llm/llm-consumption-service.d.ts +7 -2
- package/dist/services/llm/llm-settings-service.d.ts +49 -5
- package/dist/services/nlq/nlq-preview-dataset.d.ts +34 -0
- package/dist/services/nlq/nlq-service.d.ts +138 -3
- package/dist/services/pulse/evaluate-pulse-client.d.ts +78 -0
- package/dist/services/pulse/pulse-alerts-service.d.ts +264 -0
- package/dist/services/pulse/pulse-events-service.d.ts +217 -0
- package/dist/services/semantic-search/semantic-search-service.d.ts +43 -0
- package/dist/services/tool-store/tool-store-service.d.ts +32 -0
- package/dist/services/users-groups-service.d.ts +37 -0
- package/dist/skills/index.d.ts +127 -0
- package/dist/tool-availability/controlled-tools.d.ts +56 -0
- package/dist/tool-availability/index.d.ts +4 -0
- package/dist/tool-availability/offer-tools.d.ts +44 -0
- package/dist/tool-availability/resolve-tool-availability.d.ts +68 -0
- package/dist/tool-availability/withdrawn-text.d.ts +33 -0
- package/dist/tool-catalog/catalog.d.ts +387 -0
- package/dist/tool-catalog/index.d.ts +3 -0
- package/dist/tool-catalog/manifest.d.ts +5 -0
- package/dist/tool-catalog/prototype-lookup.d.ts +10 -0
- package/dist/tool-catalog/types.d.ts +67 -0
- package/dist/tools.manifest.json +826 -0
- package/dist/utils/chat-stream-errors.d.ts +42 -0
- package/dist/utils/create-custom-fetch.d.ts +19 -1
- package/dist/utils/create-stream-completion.d.ts +84 -6
- package/dist/utils/create-structured-completion.d.ts +29 -2
- package/dist/utils/create-tools-completion.d.ts +9 -0
- package/dist/utils/deferred-tools.d.ts +45 -0
- package/dist/utils/dev-debug.d.ts +5 -0
- package/dist/utils/generate-suggestions.d.ts +32 -0
- package/dist/utils/http-client.d.ts +3 -1
- package/dist/utils/llm-call-observer.d.ts +83 -0
- package/dist/utils/llm-client.d.ts +11 -1
- package/dist/utils/quoted-text.d.ts +6 -0
- package/dist/utils/server-error-body.d.ts +23 -0
- package/dist/utils/text-tokens.d.ts +35 -0
- package/dist/utils/user-action-tracking.d.ts +48 -5
- package/dist/utils/zod-utils.d.ts +9 -1
- package/package.json +28 -19
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DmKpi, DmLearnedSource, DmQuerySummary, DmTableBusinessUsage, DmVerifiedAnswer, DmWatch, DmWatched, DmWidgetRef } from '../../services/datamodel-graph/datamodel-graph-service';
|
|
2
|
+
import { DataSourceWithStatus } from '../../services/data-sources/data-sources-service';
|
|
3
|
+
import { ExploreDataModelResult, FindSubjectAreasResult, SubjectAreaResult, SubjectAreasResult, WidgetPatternResult } from './types';
|
|
4
|
+
export declare const SUBJECT_AREAS_SUMMARY_MAX_CHARS = 6000;
|
|
5
|
+
export declare const SUBJECT_AREA_SUMMARY_MAX_CHARS = 12000;
|
|
6
|
+
export declare const EXPLORE_SUMMARY_MAX_CHARS = 4000;
|
|
7
|
+
/** Meaning-only hits below this cosine similarity are flagged as weak. */
|
|
8
|
+
export declare const WEAK_MEANING_SIMILARITY = 0.3;
|
|
9
|
+
export declare const MAX_LIST_ITEMS = 12;
|
|
10
|
+
export declare const MAX_COLUMNS_PER_TABLE = 60;
|
|
11
|
+
export declare const TRUNCATION_NOTE = "[truncated: use exploreDataModel with operation \"search\" to find anything not listed]";
|
|
12
|
+
/** Longest summary an area keeps on its one-line short form in the subject-area list. */
|
|
13
|
+
export declare const AREA_SHORT_SUMMARY_MAX_CHARS = 120;
|
|
14
|
+
export declare const SHORTENED_AREAS_NOTE = "Some areas are shortened to fit: call getSubjectArea with an id for its full details.";
|
|
15
|
+
/** Hard cap; cuts at the last line break that fits and says how to find the rest. */
|
|
16
|
+
export declare function capSummary(text: string, maxChars: number): string;
|
|
17
|
+
/** `business_names` then `synonyms`, de-duplicated case-insensitively; first spelling and order kept. */
|
|
18
|
+
export declare function businessNames(t: DmTableBusinessUsage): string[];
|
|
19
|
+
export declare const BUSINESS_NAMES_NOTE = "A business name listed for a table (\"also called\" / \"business names\") is that table, not a separate entity: map the user's word to the table and its columns.";
|
|
20
|
+
export declare const learnedSourceText: (source: DmLearnedSource) => string;
|
|
21
|
+
export declare const LEARNED_TERMS_NOTE = "A learned term is not defined in the data model: it was learned from how the data is used. Before using one, look it up with exploreDataModel operation \"entity\" and build it from what it is grounded in.";
|
|
22
|
+
export declare const LEARNED_ENTITY_CLOSING = "Build it from the formulas, columns and conditions it is grounded in; it is not a field or a shared formula title, so do not put its name in queryPrompt as one.";
|
|
23
|
+
export declare const REPEAT_ROWS_MARK = "[can repeat rows]";
|
|
24
|
+
export declare const REPEAT_ROWS_NOTE = "A join marked [can repeat rows] repeats the rows on both sides: aggregate each side's measures separately, then combine the results; never sum a measure across it.";
|
|
25
|
+
/** How every widget is named to the LLM: title, type, dashboard, and the id getWidgetPattern takes. */
|
|
26
|
+
export declare function widgetRefText(w: DmWidgetRef): string;
|
|
27
|
+
export declare const WIDGET_REUSE_NOTE = "If one of these widgets answers the question, tell the user its title and dashboard. To build a new query, call getWidgetPattern when you need its exact measure, breakdowns or filters, and reuse them as hints, not constraints.";
|
|
28
|
+
export declare const WIDGET_HITS_NOTE = "Widget hits may already answer a simple lookup question. If one does, tell the user its title and dashboard; read how it is built with getWidgetPattern before reusing its measure and breakdowns (hints, not constraints).";
|
|
29
|
+
export declare const WATCHED_NOTE = "Say \"N Pulse alerts watch this metric\" or \"teams monitor this metric\"; never name a person, a role or an alert. Compare a returned value only with an unfiltered level watch of the same period, and only when your query has no non-date filters; for the current, unfinished period say \"so far\". Otherwise do not compare.";
|
|
30
|
+
export declare const KPI_HITS_NOTE = "Hits marked KPI are metrics teams monitor with Pulse alerts: prefer them when they match the question. For a formula, read it with exploreDataModel operation \"formula\" for its watched range; for a column, the subject area's KPI list shows the watched aggregate and range.";
|
|
31
|
+
export declare function watchLine(w: DmWatch, indent?: string): string;
|
|
32
|
+
/** The Pulse block of a formula: heading, one line per watch, the wording note; `[]` when nothing is watched. */
|
|
33
|
+
export declare function watchedLines(w: DmWatched | undefined): string[];
|
|
34
|
+
/** `<agg> of <column>` for a plain-aggregate (column) KPI, else null. */
|
|
35
|
+
export declare function kpiMetricText(k: DmKpi): string | null;
|
|
36
|
+
/** Watched KPIs under a heading, each with its watches indented, the wording note once; `[]` when none. */
|
|
37
|
+
export declare function kpiSection(heading: string, kpis: DmKpi[] | undefined): string[];
|
|
38
|
+
/** How every verified answer is named to the LLM: the question and the id buildQuery takes. */
|
|
39
|
+
export declare function verifiedRefText(a: Pick<DmVerifiedAnswer, 'id' | 'question'>): string;
|
|
40
|
+
/** The readable query of a verified answer: only the non-empty parts, never a filter value. */
|
|
41
|
+
export declare function querySummaryText(q: DmQuerySummary): string;
|
|
42
|
+
export declare const VERIFIED_MATCHES_HEADING = "Verified answers (an admin reviewed and saved each query):";
|
|
43
|
+
export declare const verifiedSameNext: (title: string, id: string) => string;
|
|
44
|
+
export declare const VERIFIED_SIMILAR_NEXT = "When it asks the same measures and breakdowns as the user's question (only worded differently), rerun it: call buildQuery with its verifiedAnswerId. Otherwise use it as a strong example: build your own query, preferring its formulas, columns, breakdowns and filters.";
|
|
45
|
+
export declare const VERIFIED_AREA_HEADING = "Verified answers (admin-approved questions and their queries; rerun one that asks the same, else a strong example):";
|
|
46
|
+
export declare const VERIFIED_FORMULA_ONLY_TEXT = "It exists only in verified answers, not as a shared formula: do not refer to it by title in queryPrompt; rebuild it from the columns it uses.";
|
|
47
|
+
/** At most this many verified matches are printed: the list summary adds them after its own cap. */
|
|
48
|
+
export declare const MAX_VERIFIED_MATCH_LINES = 5;
|
|
49
|
+
/** Marks the plain-fields fallback, in the summary and in the tool descriptions. */
|
|
50
|
+
export declare const PLAIN_FIELDS_MARKER = "no map yet: plain fields";
|
|
51
|
+
/** Follows the plain fields: they name columns, not the values stored in them. */
|
|
52
|
+
export declare const PLAIN_FIELDS_VALUES_NOTE = "This listing gives column names, not the values stored in them. Before filtering a query on a labelled text column (category, status, type, band, segment), read its values with getDataPreview.";
|
|
53
|
+
/**
|
|
54
|
+
* A named unrefined model with too many subject areas to list: its areas can only be picked
|
|
55
|
+
* by ranking. Never the plain fields, never the full list.
|
|
56
|
+
*/
|
|
57
|
+
export declare const rankedSelectionText: (title: string) => string;
|
|
58
|
+
/** Ranking ran and gave no areas: do not send the model back to the same call. */
|
|
59
|
+
export declare const rankedNoResultText: (title: string) => string;
|
|
60
|
+
/** Follows the header of a subject-area list whose map is basic (`refined: false`). */
|
|
61
|
+
export declare const BASIC_MAP_NOTE = "Basic map: one subject area per fact table, with no business terms or synonyms. Match the user's words to the table, column, and shared formula names; when they match nothing here, call exploreDataModel with operation \"search\" first.";
|
|
62
|
+
/** First line of a route restricted to one named basic model. */
|
|
63
|
+
export declare const rankedRoutePrefix: (title: string) => string;
|
|
64
|
+
/**
|
|
65
|
+
* The text the getSubjectAreas tool returns: the model's subject areas, each with its id in
|
|
66
|
+
* brackets. Over SUBJECT_AREAS_SUMMARY_MAX_CHARS every area is still listed, some in a shorter
|
|
67
|
+
* form; without a usable map it answers with the plain fields instead.
|
|
68
|
+
* @param result - the data source title, the map outcome and the plain fields fallback
|
|
69
|
+
* @returns the summary text
|
|
70
|
+
*/
|
|
71
|
+
export declare function getSubjectAreasSummary({ dataSourceTitle: title, outcome, plainFields, }: SubjectAreasResult): string;
|
|
72
|
+
export declare function getSubjectAreaSummary({ dataSourceTitle: title, subjectAreaId, outcome, plainFields, }: SubjectAreaResult): string;
|
|
73
|
+
export declare function exploreDataModelSummary(result: ExploreDataModelResult): string;
|
|
74
|
+
export declare const WIDGET_PATTERN_CLOSING = "If this widget answers the question, tell the user its title and dashboard. To build a new query, reuse its measures and breakdowns in queryPrompt with the names from getSubjectArea. They are hints, not constraints: follow the question when it asks for something else.";
|
|
75
|
+
export declare function getWidgetPatternSummary({ dataSourceTitle: title, widgetOid, outcome, }: WidgetPatternResult): string;
|
|
76
|
+
/** Reasons shown per candidate; `list()` adds "(+N more)". */
|
|
77
|
+
export declare const ROUTE_MAX_REASONS = 6;
|
|
78
|
+
export declare const ROUTE_UNAVAILABLE_TEXT = "Choosing the data automatically is unavailable right now. Use the data source the question or the conversation names, and ask the user which one to use only when several fit; then call getSubjectAreas with its title. Do not call findSubjectAreas again in this turn.";
|
|
79
|
+
/** After {@link ROUTE_UNAVAILABLE_TEXT} when the data source list could not be read either. */
|
|
80
|
+
export declare const ROUTE_UNAVAILABLE_NO_LIST_TEXT = "The list of data sources could not be read either: when the question or the conversation names no data source, ask the user which one to use.";
|
|
81
|
+
export declare const ROUTE_NO_MATCH_TEXT = "No data model the user can access matches this question. Tell the user nothing matched and ask what data they mean.";
|
|
82
|
+
/** Leads a route answer that has no subject area but does have verified matches. */
|
|
83
|
+
export declare const ROUTE_NO_AREA_VERIFIED_TEXT = "No subject area matched, but a verified answer did:";
|
|
84
|
+
/** After {@link ROUTE_NO_MATCH_TEXT}, before the titles of the data sources the user can access. */
|
|
85
|
+
export declare const ROUTE_NO_MATCH_OPTIONS_TEXT = "If they want to see the options, offer these data sources (by label when one is shown):";
|
|
86
|
+
/** Same, after a verified match instead of {@link ROUTE_NO_MATCH_TEXT}: "they" has no antecedent there. */
|
|
87
|
+
export declare const ROUTE_VERIFIED_OPTIONS_TEXT = "If the user wants to see the options, offer these data sources (by label when one is shown):";
|
|
88
|
+
/** Heading of the `listDataSources: true` answer. */
|
|
89
|
+
export declare const DATA_SOURCES_LIST_HEADING = "Data sources the user can access. Pass a title (never a label) as dataSourceTitle; mention a source by its label when it has one. A draft is not built yet and cannot be queried; a live connection has no oid. To answer a data question on one of them, call getSubjectAreas with its title.";
|
|
90
|
+
/** The data source lines kept in one summary; the rest are counted. */
|
|
91
|
+
export declare const DATA_SOURCES_SUMMARY_MAX_CHARS = 8000;
|
|
92
|
+
/** `"title" (label: "…") — ready|draft (not built yet), elasticube oid …|live connection`. */
|
|
93
|
+
export declare function dataSourceLine(ds: DataSourceWithStatus): string;
|
|
94
|
+
export declare const ROUTE_PICK_NEXT = "Pick the area that fits; ask the user only when the plausible options are in different data models; for options in one data model take the best and mention the other.";
|
|
95
|
+
/** Candidates shown: the route is asked for this many, and a longer answer is cut here. */
|
|
96
|
+
export declare const ROUTE_MAX_CANDIDATES = 10;
|
|
97
|
+
export declare function findSubjectAreasSummary(result: FindSubjectAreasResult): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DmEntity, DmFormula, DmJoinPath, DmJoinStep, DmKpi, DmRouteCandidate, DmSearchHit, DmSubjectArea, DmSubjectAreaCard, DmSubjectAreaList, DmTable, DmVerifiedAnswer, DmVerifiedMatch, DmWatch, DmWatched, DmWidgetDetail, DmWidgetRef } from '../../services/datamodel-graph/datamodel-graph-service';
|
|
2
|
+
import { ExploreDataModelResult, SubjectAreaResult, SubjectAreasResult } from './types';
|
|
3
|
+
/** Neutral shapes of the knowledge-graph navigation responses. Not any real model. */
|
|
4
|
+
export declare const subjectAreaList: (overrides?: Partial<DmSubjectAreaList>) => DmSubjectAreaList;
|
|
5
|
+
export declare const subjectArea: (overrides?: Partial<DmSubjectArea>) => DmSubjectArea;
|
|
6
|
+
export declare const entityWithComparison: () => DmEntity;
|
|
7
|
+
export declare const formula: () => DmFormula;
|
|
8
|
+
export declare const fanOutJoinPath: () => DmJoinPath;
|
|
9
|
+
export declare const safeJoinPath: () => DmJoinPath;
|
|
10
|
+
export declare const widgetRef: (overrides?: Partial<DmWidgetRef>) => DmWidgetRef;
|
|
11
|
+
export declare const entityWithWidgets: () => DmEntity;
|
|
12
|
+
export declare const widgetFormula: () => DmFormula;
|
|
13
|
+
export declare const subjectAreaWithPatterns: () => DmSubjectArea;
|
|
14
|
+
export declare const widgetDetail: () => DmWidgetDetail;
|
|
15
|
+
/**
|
|
16
|
+
* Generality rule (SNS-131459): the procedure must read the same for any customer
|
|
17
|
+
* model. These are the fixture names this suite uses plus terms from the sample
|
|
18
|
+
* models the feature was demoed on; none may leak into LLM-facing text.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MODEL_SPECIFIC_TERMS: string[];
|
|
21
|
+
/** One routing candidate; neutral names, override per test. */
|
|
22
|
+
export declare function routeCandidate(over?: Partial<DmRouteCandidate>): DmRouteCandidate;
|
|
23
|
+
/** One verified-answer match from the route; neutral names, override per test. */
|
|
24
|
+
export declare function match(over?: Partial<DmVerifiedMatch>): DmVerifiedMatch;
|
|
25
|
+
/** Pulse layer: one watch signature (level, below, per month, unfiltered, 3 alerts). */
|
|
26
|
+
export declare const watch: (over?: Partial<DmWatch>) => DmWatch;
|
|
27
|
+
/** Pulse layer: the watched block; `alert_count` is the sum of the watches' counts. */
|
|
28
|
+
export declare const watched: (watches?: DmWatch[]) => DmWatched;
|
|
29
|
+
/** Pulse layer: a watched shared formula with one level watch (3 alerts). */
|
|
30
|
+
export declare const kpi: (over?: Partial<DmKpi>) => DmKpi;
|
|
31
|
+
/** Pulse layer: a plain-aggregate (column) KPI with one level watch (1 alert). */
|
|
32
|
+
export declare const columnKpi: (over?: Partial<DmKpi>) => DmKpi;
|
|
33
|
+
/** One verified answer as the area detail and the formula read return it. */
|
|
34
|
+
export declare const verifiedAnswer: (over?: Partial<DmVerifiedAnswer>) => DmVerifiedAnswer;
|
|
35
|
+
export declare const areasWith: (over?: Partial<DmSubjectAreaCard>) => SubjectAreasResult;
|
|
36
|
+
export declare const areaWith: (over?: Partial<DmSubjectArea>) => SubjectAreaResult;
|
|
37
|
+
export declare const formulaResult: (over?: Partial<DmFormula>) => ExploreDataModelResult;
|
|
38
|
+
export declare const searchResult: (hits: DmSearchHit[]) => ExploreDataModelResult;
|
|
39
|
+
/** The first table and first join of `subjectArea()`. */
|
|
40
|
+
export declare const ordersTable: () => DmTable;
|
|
41
|
+
export declare const ordersJoin: () => DmJoinStep;
|
|
42
|
+
export declare const entityResult: (over?: Partial<DmEntity>) => ExploreDataModelResult;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
3
|
+
import { DataSourceWithStatus, DisplayNameConfig } from '../../services/data-sources/data-sources-service';
|
|
4
|
+
import { DataSourceFieldsResult } from '../get-data-source-fields/types';
|
|
5
|
+
import { DatamodelGraphOutcome, DmEntity, DmFormula, DmJoinPath, DmRouteAnswer, DmSearchResult, DmSubjectArea, DmSubjectAreaList, DmWidgetDetail, DmVerifiedMatch } from '../../services/datamodel-graph/datamodel-graph-service';
|
|
6
|
+
/**
|
|
7
|
+
* Canonical descriptions for the data model map tools (SNS-131459). They teach a
|
|
8
|
+
* general procedure — subject areas first, one area as the schema, targeted lookups for
|
|
9
|
+
* terms, entity relations, formulas and join safety — and must stay free of any one
|
|
10
|
+
* model's vocabulary (enforced by tool-descriptions.test.ts). They are not gated on the
|
|
11
|
+
* server: the BASIC MAP guidance (SNS-131459 tiers) reaches every session with the map on,
|
|
12
|
+
* also against a server that sends no `refined` key; only the summaries depend on that key.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getSubjectAreasToolDescription = "Map-first schema discovery. Lists the SUBJECT AREAS of a data model: groups of tables that really join to each other, each with its fact tables and, when the map has them, business entities, shared formulas, and analysis hints. Pass the data source / model identity title (never its display label).\n\nWHEN: before the first query on a data source in this conversation \u2014 the map is small and tells you which tables belong together.\n\nTHEN: pick the ONE subject area whose entities, tables, formulas, or summary match the user's question, and call getSubjectArea with its id. If the question needs two subject areas, call exploreDataModel (operation \"joinPath\" or \"entity\") to learn whether and how they connect before querying across them. If the user's words match nothing in the cards, call exploreDataModel with operation \"search\".\n\nNO MAP YET: when the map is not ready or unavailable, or a refined map has too many subject areas, the result says so and lists the data source's plain fields instead (\"no map yet: plain fields\"). Write the buildQuery queryPrompt with only the table, column, and shared formula names listed there, and do not call the map tools again for that data source in the same turn.\n\nBASIC MAP: a map that has not been refined has one subject area per fact table and no business terms or synonyms, and the result has a \"Basic map\" line after its header. Match the user's words to table, column, and shared formula names, and call exploreDataModel with operation \"search\" first when they match nothing. When a basic map has too many subject areas to list, the result says so: call findSubjectAreas with datamodel and the question's concepts instead.";
|
|
15
|
+
export declare const getSubjectAreaToolDescription = "Returns the schema of ONE subject area from getSubjectAreas: its tables (role such as fact or dimension, row count, description), their columns with types and descriptions, the real joins among those tables with cardinality, business entities with their synonyms (a basic map has none), shared formulas with designer context, and analysis hints. Pass dataSourceTitle and the subject area id exactly as getSubjectAreas printed it.\n\nUse this result as the schema: write the buildQuery queryPrompt with only table, column, and shared formula names that appear here, and map the user's words to them through entity names and synonyms when the area lists them, otherwise through table and column names (call exploreDataModel with operation \"search\" when nothing matches). Prefer a shared formula over re-deriving a measure it already defines.\n\nJOINS: only the joins listed exist. Never assume a join from matching column names. A table outside this subject area may not be joinable \u2014 check with exploreDataModel (operation \"joinPath\") before combining it.\n\nANALYSIS HINTS are facts derived from the model; apply each one that touches the question:\n- currency: amounts exist in more than one currency \u2014 use one currency column consistently and say which.\n- snapshot: values are period snapshots \u2014 do not sum them across periods; use the latest period or an average.\n- plan: a plan or target to compare against lives in another subject area \u2014 aggregate each side separately at the shared level, then compare.\n- segment: low-cardinality columns that make good breakdowns.\n- drivers: the dimensions that can explain a change in a measure \u2014 when the user asks why something moved or whether it is a problem, break the change down by them and find the members that account for most of it.\n- freshness: the latest periods may be provisional or incomplete \u2014 compare like-for-like periods (never a partial period against a full one) and say so when the result includes them.\n\nIf you need a term or table that is not here, call exploreDataModel with operation \"search\". When the map is not ready, the result lists the data source's plain fields instead (\"no map yet: plain fields\"): use those names.";
|
|
16
|
+
export declare const exploreDataModelToolDescription = "Targeted lookups in a data model's map, one operation per call. Pass dataSourceTitle and operation:\n- \"search\" (query): find where the user's term lives \u2014 entities, synonyms, shared formulas, tables, and columns, with the subject areas they belong to. Use it when the user's vocabulary does not match names you have seen. On a basic map (no business terms), search before guessing a table or column name.\n- \"entity\" (name): an entity's definition, synonyms, tables, and related entities. A related entity of kind \"join\" comes with its join path. A related entity of kind \"comparison\" is NOT a join: aggregate each side separately to the shared table it names, then compare the two results.\n- \"formula\" (name = the shared formula title): what a shared formula measures, the columns it uses, and its designer context. Use it to decide whether a formula already answers the question; refer to it by its exact title in queryPrompt.\n- \"joinPath\" (from, to = table or entity names): whether two tables or entities connect through real joins, and how. When the result reports a FAN-OUT RISK, do not aggregate a measure across that path in a single query, because it would double count: aggregate each fact separately (at the comparable level when one is given) and combine the results, or explain the limitation to the user. When they are not connected, they cannot be combined in one query.\n\nAn unknown name returns the closest names \u2014 retry with one of them, or use \"search\". When the map is not ready, the result lists the data source's plain fields instead (\"no map yet: plain fields\"): use those names.";
|
|
17
|
+
export declare const getWidgetPatternToolDescription = "Returns how ONE existing dashboard widget built on this data model answers its question: its measures (formulas and aggregations), breakdowns, filters with their values, the business entities it describes, and its subject areas. Pass dataSourceTitle and the widget id exactly as a data model map result printed it inside \"[widget \u2026]\". Never guess an id.\n\nWHEN: getSubjectArea (analysis patterns), exploreDataModel (an entity's or formula's widgets, or a widget search hit) listed a widget that may already answer the user's question, or whose measure and breakdowns you want to reuse.\n\nTHEN: if the widget answers the question, tell the user its title and dashboard. To build a new query, reuse its measures and breakdowns in queryPrompt with the table, column, and shared formula names from getSubjectArea. Widget patterns are hints, not constraints: follow the question when it asks for something else. A formula of kind \"widget\" is not a shared formula: rebuild it from the columns it uses.\n\nIf the result says widget details are not available, continue with the subject area and search results. An unknown id returns no widget \u2014 use exploreDataModel with operation \"search\" instead.";
|
|
18
|
+
export declare const getSubjectAreasSchema: z.ZodObject<{
|
|
19
|
+
dataSourceTitle: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const getSubjectAreaSchema: z.ZodObject<{
|
|
22
|
+
dataSourceTitle: z.ZodString;
|
|
23
|
+
subjectAreaId: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const findSubjectAreasToolDescription = "Finds which data model and subject area a data question belongs to, across every data model the user can access. Pass concepts: the short business terms the question is about (its measures, dimensions, entities and filter values, such as a metric, a region or a product), one phrase each \u2014 NOT the full sentence. For a follow-up, include the concepts it carries over from earlier turns.\n\nWHEN: a new data question and no data model is settled in this conversation yet \u2014 call this FIRST, before listing data sources or asking the user which data to use. When the user names a data model, call getSubjectAreas for it directly instead (or this tool with datamodel and concepts when getSubjectAreas says its basic map has too many subject areas to list). On a follow-up, call this again only when the question may need different data.\n\nTHEN: the result lists the candidate subject areas, best first, each with the concepts it matched (concept \u2192 the business term, synonym, formula, table or column it matched). Pick the area that fits. Ask the user one short question (data model and subject area names, never ids or scores) only when the plausible options are in different data models; for options in one data model, take the best and mention the other in one line. Say in one line which data you are using, call getSubjectArea with its data model and id, and pass the same id to buildQuery as subjectAreaId.\n\nA candidate marked \"no map yet\" matched only on its title: call getSubjectAreas for it. A candidate marked \"map not refined yet\" has a basic map with no business terms: after getSubjectArea, use exploreDataModel with operation \"search\" for words that match no name there. When the area you pick is outside this dashboard's data models, say so before using it. When the result starts with \"No data model named\", tell the user that in one line before continuing. When no data model matches, ask the user what data they mean (the result names the data sources you may offer). When choosing the data is unavailable, the result lists the data sources the user can access: use the one the question or the conversation names, ask the user only when several fit, then call getSubjectAreas with its title.\n\nLIST: pass listDataSources: true (and no concepts) when the user asks which data sources or data models exist, or when you need a data source's exact title, its status (a draft cannot be queried), whether it is a live connection, or its oid. The result lists every data source the user can access.";
|
|
26
|
+
export declare const getWidgetPatternSchema: z.ZodObject<{
|
|
27
|
+
dataSourceTitle: z.ZodString;
|
|
28
|
+
widgetOid: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
/** At most this many concepts are sent to the route; the engine drops the rest (the schema does not reject them). */
|
|
31
|
+
export declare const FIND_SUBJECT_AREAS_MAX_CONCEPTS = 12;
|
|
32
|
+
/** The route's own cut: ai-integration and knowledge-graph accept at most 80 characters per concept. */
|
|
33
|
+
export declare const CONCEPT_MAX_CHARS = 80;
|
|
34
|
+
export declare const findSubjectAreasSchema: z.ZodObject<{
|
|
35
|
+
concepts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
question: z.ZodOptional<z.ZodString>;
|
|
37
|
+
datamodel: z.ZodOptional<z.ZodString>;
|
|
38
|
+
listDataSources: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const EXPLORE_OPERATIONS: readonly ["search", "entity", "formula", "joinPath"];
|
|
41
|
+
export type ExploreOperation = (typeof EXPLORE_OPERATIONS)[number];
|
|
42
|
+
export declare const exploreDataModelSchema: z.ZodObject<{
|
|
43
|
+
dataSourceTitle: z.ZodString;
|
|
44
|
+
operation: z.ZodEnum<{
|
|
45
|
+
search: "search";
|
|
46
|
+
entity: "entity";
|
|
47
|
+
formula: "formula";
|
|
48
|
+
joinPath: "joinPath";
|
|
49
|
+
}>;
|
|
50
|
+
query: z.ZodOptional<z.ZodString>;
|
|
51
|
+
name: z.ZodOptional<z.ZodString>;
|
|
52
|
+
from: z.ZodOptional<z.ZodString>;
|
|
53
|
+
to: z.ZodOptional<z.ZodString>;
|
|
54
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export type GetSubjectAreasParams = z.infer<typeof getSubjectAreasSchema>;
|
|
57
|
+
export type GetSubjectAreaParams = z.infer<typeof getSubjectAreaSchema>;
|
|
58
|
+
export type ExploreDataModelParams = z.infer<typeof exploreDataModelSchema>;
|
|
59
|
+
export type GetWidgetPatternParams = z.infer<typeof getWidgetPatternSchema>;
|
|
60
|
+
export type FindSubjectAreasParams = z.infer<typeof findSubjectAreasSchema>;
|
|
61
|
+
/**
|
|
62
|
+
* How the plain-fields fallback reads a data source when it has no usable map: the same
|
|
63
|
+
* options the getDataSourceFields tool passes to its engine.
|
|
64
|
+
*/
|
|
65
|
+
export interface PlainFieldsOptions {
|
|
66
|
+
/** From host AppSettings; omit → fields/search (viewer-safe). */
|
|
67
|
+
displayNameConfig?: DisplayNameConfig;
|
|
68
|
+
/**
|
|
69
|
+
* false drops designer AI context from the fields (host flag `aiContextEnabled` off), exactly
|
|
70
|
+
* as the getDataSourceFields summary omits it. Default: kept.
|
|
71
|
+
*/
|
|
72
|
+
aiContext?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface DatamodelGraphEngineContext {
|
|
75
|
+
httpClient?: HttpClient;
|
|
76
|
+
abortSignal?: AbortSignal;
|
|
77
|
+
/** Options for the plain-fields fallback; see {@link PlainFieldsFallback}. */
|
|
78
|
+
plainFields?: PlainFieldsOptions;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The data source's plain field list, read by the engine itself when the map cannot answer
|
|
82
|
+
* (not ready, unavailable, too many subject areas, no subject areas, or a failed read). The
|
|
83
|
+
* map tools replace getDataSourceFields, so this is how the model still gets a schema for
|
|
84
|
+
* buildQuery. `failed` = the field list could not be read either.
|
|
85
|
+
*/
|
|
86
|
+
export type PlainFieldsFallback = {
|
|
87
|
+
status: 'ok';
|
|
88
|
+
result: DataSourceFieldsResult;
|
|
89
|
+
} | {
|
|
90
|
+
status: 'failed';
|
|
91
|
+
};
|
|
92
|
+
export interface FindSubjectAreasContext extends DatamodelGraphEngineContext {
|
|
93
|
+
/** The open dashboard's data model titles; ranked first. Not chosen by the LLM. */
|
|
94
|
+
preferredDatamodels?: readonly string[];
|
|
95
|
+
/** The user's exact message, forwarded so the route can match verified answers. Not chosen by the LLM. */
|
|
96
|
+
userQuestion?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface SubjectAreasResult {
|
|
99
|
+
/** Identity title the tools resolve by. */
|
|
100
|
+
dataSourceTitle: string;
|
|
101
|
+
outcome: DatamodelGraphOutcome<DmSubjectAreaList>;
|
|
102
|
+
/** Present only when the map cannot answer: the plain fields instead. */
|
|
103
|
+
plainFields?: PlainFieldsFallback;
|
|
104
|
+
}
|
|
105
|
+
export interface SubjectAreaResult {
|
|
106
|
+
dataSourceTitle: string;
|
|
107
|
+
subjectAreaId: string;
|
|
108
|
+
outcome: DatamodelGraphOutcome<DmSubjectArea>;
|
|
109
|
+
/** Present only when the map is not ready or could not be read. */
|
|
110
|
+
plainFields?: PlainFieldsFallback;
|
|
111
|
+
}
|
|
112
|
+
export interface WidgetPatternResult {
|
|
113
|
+
dataSourceTitle: string;
|
|
114
|
+
/** The id the model asked for (trimmed), for not-found and card text. */
|
|
115
|
+
widgetOid: string;
|
|
116
|
+
outcome: DatamodelGraphOutcome<DmWidgetDetail>;
|
|
117
|
+
}
|
|
118
|
+
/** findSubjectAreas without a named data model: the route's ranked candidates. */
|
|
119
|
+
export interface FindSubjectAreasRouteResult {
|
|
120
|
+
kind: 'route';
|
|
121
|
+
/** The concepts as sent (trimmed, de-duplicated, at most 12). */
|
|
122
|
+
concepts: string[];
|
|
123
|
+
/** The question as sent (trimmed), when one was given. */
|
|
124
|
+
question?: string;
|
|
125
|
+
/** The preferred titles as sent (trimmed, de-duplicated); empty off a dashboard. */
|
|
126
|
+
preferredDatamodels: string[];
|
|
127
|
+
/**
|
|
128
|
+
* The named data model the route was restricted to, because its basic map has too many
|
|
129
|
+
* subject areas to list. Absent for a route across every model.
|
|
130
|
+
*/
|
|
131
|
+
datamodel?: string;
|
|
132
|
+
answer: DmRouteAnswer;
|
|
133
|
+
/**
|
|
134
|
+
* The data sources the user can access, read by the engine when the route cannot choose
|
|
135
|
+
* (`unavailable`, or no candidates) so the model can still pick one or offer them. Absent
|
|
136
|
+
* when the route answered with candidates, or when the list could not be read.
|
|
137
|
+
*/
|
|
138
|
+
dataSources?: DataSourceWithStatus[];
|
|
139
|
+
}
|
|
140
|
+
/** findSubjectAreas with `listDataSources: true`: every data source the user can access. */
|
|
141
|
+
export interface FindSubjectAreasSourcesResult {
|
|
142
|
+
kind: 'sources';
|
|
143
|
+
dataSources: DataSourceWithStatus[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* findSubjectAreas with a named data model: that model's full subject-area list, unranked unless `ranking` is set.
|
|
147
|
+
* Also the answer for a named unrefined model over the limit when ranking found nothing.
|
|
148
|
+
*/
|
|
149
|
+
export interface FindSubjectAreasListResult {
|
|
150
|
+
kind: 'list';
|
|
151
|
+
/** The data model the user named (trimmed). */
|
|
152
|
+
datamodel: string;
|
|
153
|
+
subjectAreas: SubjectAreasResult;
|
|
154
|
+
/** Verified answers matching the user's question in this model; set only when non-empty. */
|
|
155
|
+
verifiedMatches?: DmVerifiedMatch[];
|
|
156
|
+
/**
|
|
157
|
+
* Set only for a named unrefined model over the subject-area limit (ranked selection):
|
|
158
|
+
* why no ranked candidates are shown. `not_attempted`: no concepts and no question;
|
|
159
|
+
* `no_match`: the route found no candidates; `unavailable`: the route could not answer
|
|
160
|
+
* (`subjectAreas.plainFields` then carries the plain fields).
|
|
161
|
+
*/
|
|
162
|
+
ranking?: 'not_attempted' | 'no_match' | 'unavailable';
|
|
163
|
+
}
|
|
164
|
+
export type FindSubjectAreasResult = FindSubjectAreasRouteResult | FindSubjectAreasListResult | FindSubjectAreasSourcesResult;
|
|
165
|
+
/** An explore call that was missing the argument its operation needs never reaches the server. */
|
|
166
|
+
export type ExploreOutcome<T> = DatamodelGraphOutcome<T> | {
|
|
167
|
+
status: 'invalid_arguments';
|
|
168
|
+
message: string;
|
|
169
|
+
};
|
|
170
|
+
interface ExploreBase {
|
|
171
|
+
dataSourceTitle: string;
|
|
172
|
+
/** What the model asked for (query, name, or `from -> to`), for not-found and card text. */
|
|
173
|
+
requested: string;
|
|
174
|
+
/** Present only when the map is not ready or could not be read. */
|
|
175
|
+
plainFields?: PlainFieldsFallback;
|
|
176
|
+
}
|
|
177
|
+
export type ExploreDataModelResult = (ExploreBase & {
|
|
178
|
+
operation: 'search';
|
|
179
|
+
outcome: ExploreOutcome<DmSearchResult>;
|
|
180
|
+
}) | (ExploreBase & {
|
|
181
|
+
operation: 'entity';
|
|
182
|
+
outcome: ExploreOutcome<DmEntity>;
|
|
183
|
+
}) | (ExploreBase & {
|
|
184
|
+
operation: 'formula';
|
|
185
|
+
outcome: ExploreOutcome<DmFormula>;
|
|
186
|
+
}) | (ExploreBase & {
|
|
187
|
+
operation: 'joinPath';
|
|
188
|
+
outcome: ExploreOutcome<DmJoinPath>;
|
|
189
|
+
});
|
|
190
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EvaluatePulseContext, EvaluatePulseResult, evaluatePulseSchema } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Runs a new evaluation cycle for one existing `agentic` Pulse workflow by calling
|
|
5
|
+
* ai-integration's evaluate endpoint (`POST .../evaluate?stream=true`). Gather,
|
|
6
|
+
* transforms, rules decide, narrate on fire, record, and
|
|
7
|
+
* auto-fire createEvent all run server-side; this engine is a thin authenticated
|
|
8
|
+
* SSE client that maps steps into the Studio EvalTrace vocabulary.
|
|
9
|
+
*/
|
|
10
|
+
export declare function evaluatePulseEngine(params: z.infer<typeof evaluatePulseSchema>, context: EvaluatePulseContext): Promise<EvaluatePulseResult>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
3
|
+
import { AgenticDiffSignal } from '../../services/pulse/pulse-alerts-service';
|
|
4
|
+
/**
|
|
5
|
+
* Canonical tool description for evaluatePulse — reusable by any host (sdk-assistant, MCP server, custom integrations).
|
|
6
|
+
* Hosts may append host-specific notes but should not duplicate or contradict this text.
|
|
7
|
+
*/
|
|
8
|
+
export declare const evaluatePulseToolDescription = "Runs a BRAND-NEW evaluation cycle for one existing `agentic` Pulse workflow right now: fetches it, runs its stored queries as the user (under their data security) and declared transforms, then decides whether to fire via the workflow's stored `decisionSpec` (json-rules-engine \u2014 chat-authored workflows are `'conditional'`). Creates a Pulse notification with a narrative when the condition fires, sent to the recipients who share the user's data scope, plus the workflow's Slack, Zapier or webhook destinations when that scope includes the owner (stored as an event in the API; the narrative is written server-side when the workflow fires). Every query's fresh result is always recorded to history, whether or not the workflow fires \u2014 this is a WRITE, not a read.\n\nROUTING \u2014 read this before calling: \"did it fire\", \"check if it fired\", \"any events\", \"any notifications\", \"what happened last night\", \"why did it fire\" are all INSPECT questions \u2014 call inspectPulse instead, never this tool. This tool cannot answer a question about a cycle that already ran; it can only start a new one. If a build or a scheduled cycle just happened, its evaluation has already run and is already recorded \u2014 inspect it, do not re-run it. Call this tool only when the user explicitly asks for a fresh check right now (e.g. \"evaluate it now\", \"run the check again\", \"test the workflow\") \u2014 never proactively after merely listing workflows, and never on a timer. Requires workflowId (the workflow's _id, e.g. from a prior list-workflows lookup).\n\nNever modifies what the workflow monitors \u2014 `queries`/`skill`/`decisionSpec`/`queryVersion` stay untouched; redefining those is a separate, human-confirmed flow. This tool only records evaluation history and, when warranted, creates a notification \u2014 both automatic, no confirmation step, since neither changes what the workflow watches (API: event record) \u2014 but the new record it writes will appear in every eval-history listing of the users who share that data scope, alongside the cycles that ran on their own.";
|
|
9
|
+
export declare const evaluatePulseSchema: z.ZodObject<{
|
|
10
|
+
workflowId: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export interface EvaluatePulseContext {
|
|
13
|
+
toolCallId: string;
|
|
14
|
+
httpClient?: HttpClient;
|
|
15
|
+
/**
|
|
16
|
+
* Fires once per mapped evaluation step DURING the run — live side-channel for
|
|
17
|
+
* EvalTrace while ai-integration streams SSE `step` events.
|
|
18
|
+
*/
|
|
19
|
+
onStep?: (step: EvaluatePulseStep) => void;
|
|
20
|
+
/**
|
|
21
|
+
* What caused this evaluation — omit for a genuine on-demand chat check (the default). Set
|
|
22
|
+
* only by `authorPulseEngine`'s `create` action for the one chained evaluation that runs
|
|
23
|
+
* immediately after a brand-new workflow is persisted, so its history shows it as the creation
|
|
24
|
+
* check. Every trigger's cycle is equally a diff baseline server-side.
|
|
25
|
+
*/
|
|
26
|
+
trigger?: 'onDemand' | 'create';
|
|
27
|
+
/**
|
|
28
|
+
* Aborts the underlying SSE fetch when the caller's session/turn is stopped — forwarded
|
|
29
|
+
* straight to `fetch`'s own `signal`. Without this, stopping the session leaves the request
|
|
30
|
+
* running server-side with nothing left listening to its stream.
|
|
31
|
+
*/
|
|
32
|
+
abortSignal?: AbortSignal;
|
|
33
|
+
/** The calling tool, when another tool runs this engine; defaults to `evaluatePulse`. */
|
|
34
|
+
toolName?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Per-query outcome of one evaluation run. */
|
|
37
|
+
export interface EvaluatePulseQueryResult {
|
|
38
|
+
queryName: string;
|
|
39
|
+
/** The query's authored purpose — sent by ai-integration since SNS-134366; absent from older servers. */
|
|
40
|
+
purpose?: string;
|
|
41
|
+
hasPriorData: boolean;
|
|
42
|
+
signals: AgenticDiffSignal[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Closed vocabulary of `EvaluatePulseStep.kind` values. `runResult`/`diffResult`/
|
|
46
|
+
* the other transform-result kinds and `recordResult`/`eventResult`
|
|
47
|
+
* come from ai-integration's `toolResult` `data.kind` (see `mapAgenticLoopStepToEvaluateStep`
|
|
48
|
+
* in `evaluate-pulse-client.ts`); `unknown` is the narrowed fallback for anything ai-integration
|
|
49
|
+
* sends that doesn't match one of the above (unparsable JSON, or a step kind this client
|
|
50
|
+
* doesn't know about yet) — never pass an unrecognized raw string through as `kind`.
|
|
51
|
+
*/
|
|
52
|
+
export declare const EVALUATE_PULSE_STEP_KINDS: readonly ["runResult", "diffResult", "forecastResult", "trendResult", "topNResult", "anomalyResult", "crossQueryArithmeticResult", "crossQueryRankCompareResult", "crossQueryValueCompareResult", "recordResult", "eventResult", "unknown"];
|
|
53
|
+
export type EvaluatePulseStepKind = (typeof EVALUATE_PULSE_STEP_KINDS)[number];
|
|
54
|
+
/**
|
|
55
|
+
* One entry in the evaluation run's chronological trace — mapped from ai-integration
|
|
56
|
+
* `toolResult` SSE steps into the Studio EvalTrace vocabulary (`runResult`, `diffResult`,
|
|
57
|
+
* transform results, `recordResult`, or `eventResult`).
|
|
58
|
+
*/
|
|
59
|
+
export interface EvaluatePulseStep {
|
|
60
|
+
kind: EvaluatePulseStepKind;
|
|
61
|
+
queryName?: string;
|
|
62
|
+
message: string;
|
|
63
|
+
}
|
|
64
|
+
export interface EvaluatePulseResult {
|
|
65
|
+
workflowId: string;
|
|
66
|
+
workflowName: string;
|
|
67
|
+
perQuery: EvaluatePulseQueryResult[];
|
|
68
|
+
/** True only once an event actually exists. */
|
|
69
|
+
fired: boolean;
|
|
70
|
+
narrative?: string;
|
|
71
|
+
notifyId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* This cycle's evaluation outcome — `'noData'` means a declared transform didn't have enough
|
|
74
|
+
* history to compute anything (e.g. a brand-new workflow, or a `trendCheck` under its 30-point
|
|
75
|
+
* floor); `'notMet'` means it did and the condition genuinely wasn't met. Without this, both
|
|
76
|
+
* looked identical to the caller (`fired: false`), with no way to tell "didn't fire (yet)"
|
|
77
|
+
* apart from "can never fire". Same union `pulse-events-service.ts#AgenticEvalRecord.outcome`
|
|
78
|
+
* already uses.
|
|
79
|
+
*/
|
|
80
|
+
outcome?: 'met' | 'notMet' | 'noData';
|
|
81
|
+
steps: EvaluatePulseStep[];
|
|
82
|
+
/** Raw final assistant text from the evaluate API (`finalText`), for the raw-trace fallback. */
|
|
83
|
+
combinedMessage: string;
|
|
84
|
+
durationMs: number;
|
|
85
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
2
|
+
import { DashboardNarrationResult, GetDashboardNarrationContext, GetDashboardNarrationParams } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates the narrative of a saved dashboard by its id, so that the narrative widget on it —
|
|
5
|
+
* which on open only looks the narrative up in the service's cache — shows it right away. The
|
|
6
|
+
* cache is keyed by dashboard id, so a narrative generated for the same widgets elsewhere (on the
|
|
7
|
+
* canvas, from their queries) is not found there. Never throws: a failure only leaves the widget
|
|
8
|
+
* showing its generate action.
|
|
9
|
+
* @param dashboardId - Id of the saved dashboard.
|
|
10
|
+
* @param httpClient - HttpClient; the shared one when omitted.
|
|
11
|
+
* @param toolName - The calling tool, sent as `x-tool-name`.
|
|
12
|
+
* @returns Whether a narrative is now cached for the dashboard.
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateSavedDashboardNarrative(dashboardId: string, httpClient?: HttpClient, toolName?: string): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Generates the Dashboard Narrative of a saved dashboard (by its id, through the service's
|
|
17
|
+
* dashboards route) or of a dashboard built or opened in the conversation (from its widgets'
|
|
18
|
+
* queries, unsaved changes included).
|
|
19
|
+
* @param params - Engine parameters
|
|
20
|
+
* @param context - Engine context
|
|
21
|
+
* @returns The narrative and what it was generated for
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDashboardNarrationEngine(params: GetDashboardNarrationParams, context: GetDashboardNarrationContext): Promise<DashboardNarrationResult>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
2
|
+
import { NarrativeData } from '@sisense/sdk-ui/sisense-internal';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ExtendedDashboardProps } from '../build-dashboard/types';
|
|
5
|
+
/**
|
|
6
|
+
* Canonical tool description for getDashboardNarration — reusable by any host (sdk-assistant, MCP
|
|
7
|
+
* server, custom integrations). Hosts may append host-specific notes but should not duplicate or
|
|
8
|
+
* contradict this text.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getDashboardNarrationToolDescription = "Generates the Dashboard Narrative: an AI-written summary of what the data on a dashboard shows right now \u2014 an overview paragraph and up to three key insights, each marked positive, negative or neutral \u2014 and shows it to the user as text in the conversation.\n\nUse it when the user asks for insights, highlights, key findings, takeaways, a narrative or a summary of what a dashboard's numbers say. Do not use it to explain what a dashboard or widget is or how it is built \u2014 that is a description, not a narrative. It adds nothing to a dashboard: when the user asks for a dashboard with a narrative or narration, or for one on a dashboard built in this conversation, add the Dashboard Narrative widget instead: buildDashboard's add-narration action, or addDashboardNarration where the dashboard tools are separate.\n\nIdentify the dashboard with exactly one of:\n- `priorDashboardId` \u2014 a dashboard built or opened in this conversation: the dashboardId of the latest successful buildDashboard result for it. The narrative describes it as it is in the conversation, unsaved changes included.\n- `dashboardId` \u2014 the Fusion id (oid) of a saved dashboard, such as the id the conversation context gives for the dashboard on screen, or one returned by getDashboards. The narrative describes its saved state. Never a dashboardId returned by buildDashboard: that one goes in `priorDashboardId`.\n\n`includeFilters` (default true) applies the dashboard filters; pass false only when the user asks for the narrative without them.\n\nThe narrative is already shown to the user: do not repeat or rephrase it. Follow the tool result's message on whether to offer adding it to the dashboard as a widget. The narrative is generated from at most 50 widgets; `excludedWidgetCount` counts the ones that could not be narrated.";
|
|
11
|
+
/**
|
|
12
|
+
* Schema for getDashboardNarration engine parameters
|
|
13
|
+
*/
|
|
14
|
+
export declare const getDashboardNarrationSchema: z.ZodObject<{
|
|
15
|
+
priorDashboardId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
dashboardId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
includeFilters: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type GetDashboardNarrationParams = z.infer<typeof getDashboardNarrationSchema>;
|
|
20
|
+
/**
|
|
21
|
+
* Context interface for getDashboardNarrationEngine
|
|
22
|
+
*/
|
|
23
|
+
export interface GetDashboardNarrationContext {
|
|
24
|
+
/**
|
|
25
|
+
* Tool call ID
|
|
26
|
+
*/
|
|
27
|
+
toolCallId: string;
|
|
28
|
+
httpClient?: HttpClient;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves a dashboard built or opened in the conversation by its buildDashboard result id.
|
|
31
|
+
* Required for `priorDashboardId`.
|
|
32
|
+
*/
|
|
33
|
+
retrieveDashboard?: (dashboardId: string) => ExtendedDashboardProps | null;
|
|
34
|
+
/**
|
|
35
|
+
* Dashboard the session is opened on — the default when the params name none. Optional: a host
|
|
36
|
+
* that tells the model which dashboard is on screen through the conversation context (the
|
|
37
|
+
* Assistant, since SNS-135397) passes none.
|
|
38
|
+
*/
|
|
39
|
+
defaultDashboardId?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The dashboard a narrative was generated for.
|
|
43
|
+
* - `conversation` — built or opened in the conversation; `dashboardId` is the buildDashboard
|
|
44
|
+
* result id.
|
|
45
|
+
* - `saved` — a saved Fusion dashboard; `dashboardId` is its oid.
|
|
46
|
+
*/
|
|
47
|
+
export type DashboardNarrationSource = {
|
|
48
|
+
type: 'conversation';
|
|
49
|
+
dashboardId: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'saved';
|
|
52
|
+
dashboardId: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Result from getDashboardNarrationEngine
|
|
56
|
+
*/
|
|
57
|
+
export interface DashboardNarrationResult {
|
|
58
|
+
source: DashboardNarrationSource;
|
|
59
|
+
includeFilters: boolean;
|
|
60
|
+
/** Narrative as the CSDK narrative view renders it. */
|
|
61
|
+
narrative: Pick<NarrativeData, 'overview' | 'insights'>;
|
|
62
|
+
/** Widgets the service, or the query builder, could not narrate. */
|
|
63
|
+
excludedWidgetCount: number;
|
|
64
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import { Dashboard } from '../../services/dashboards/fusion-dashboards-service';
|
|
3
3
|
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
4
4
|
/**
|
|
5
5
|
* Canonical tool description for getDashboards — reusable by any host (sdk-assistant, MCP server, custom integrations).
|
|
6
6
|
* Hosts may append host-specific notes but should not duplicate or contradict this text.
|
|
7
7
|
*/
|
|
8
|
-
export declare const getDashboardsToolDescription = "Get
|
|
8
|
+
export declare const getDashboardsToolDescription = "Get the Fusion dashboards the current user can access. Returns every dashboard visible to them in the product, not only ones the assistant created.\n\nPass `searchByTitle` to narrow by a word in the title \u2014 instances commonly have hundreds of dashboards, and the result is capped. When `truncated` is true you are seeing only part of the set: narrow with `searchByTitle` rather than assuming the rest do not exist.\n\nDo not read the raw tool result as a list to the user. Use it internally, then suggest one or two concrete follow-ups (e.g. which dashboard to open or extend) instead of dumping every title.";
|
|
9
9
|
/**
|
|
10
10
|
* Schema for getDashboards engine parameters
|
|
11
11
|
*/
|
|
12
|
-
export declare const getDashboardsSchema: z.ZodObject<{
|
|
12
|
+
export declare const getDashboardsSchema: z.ZodObject<{
|
|
13
|
+
searchByTitle: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
13
15
|
/**
|
|
14
16
|
* Context interface for getDashboardsEngine
|
|
15
17
|
*/
|
|
@@ -25,7 +27,17 @@ export interface GetDashboardsContext {
|
|
|
25
27
|
*/
|
|
26
28
|
export interface DashboardsResult {
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* Dashboards the user can access, after any `searchByTitle` filter, capped at
|
|
31
|
+
* `MAX_DASHBOARDS_SUMMARY`.
|
|
29
32
|
*/
|
|
30
33
|
dashboards: Dashboard[];
|
|
34
|
+
/**
|
|
35
|
+
* How many dashboards matched before the cap — so the model can tell "there are 3" from
|
|
36
|
+
* "there are 126 and you are looking at 50".
|
|
37
|
+
*/
|
|
38
|
+
totalMatching: number;
|
|
39
|
+
/**
|
|
40
|
+
* True when `dashboards` is a capped subset of `totalMatching`.
|
|
41
|
+
*/
|
|
42
|
+
truncated: boolean;
|
|
31
43
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GetDataPreviewContext, GetDataPreviewParams, DataPreviewResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the distinct values of one text column.
|
|
4
|
+
*
|
|
5
|
+
* A thin call by design. The JAQL, the row limit, and the completeness verdict all live server-side
|
|
6
|
+
* — the same code path NLQ itself uses — so the Assistant and NLQ can never disagree about whether
|
|
7
|
+
* a value list is complete. Resolving the column expression, its data type, and the limit here would
|
|
8
|
+
* mean a second implementation of a correctness-bearing rule.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDataPreviewEngine({ dataSourceTitle, table, column }: GetDataPreviewParams, context?: GetDataPreviewContext): Promise<DataPreviewResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Renders a preview for the LLM.
|
|
13
|
+
*
|
|
14
|
+
* The completeness claim leads, because it decides which filters the values may legitimately
|
|
15
|
+
* support: an exhaustive list licenses exclusions, a truncated one licenses nothing beyond
|
|
16
|
+
* spelling. Stating it after the values would invite reading the list first and the caveat never.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDataPreviewSummary(result: DataPreviewResult): string;
|