@sisense/sdk-ai-core 0.15.1 → 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 +36 -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 +49 -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 +53 -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 +21 -0
- package/dist/index.js +56879 -27530
- 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 +149 -5
- 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-models-service.d.ts +10 -2
- package/dist/services/llm/llm-settings-service.d.ts +73 -0
- 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/llm-model-override.d.ts +41 -0
- 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 -18
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
2
|
+
/** POST api/v2/ai/llm/models body. */
|
|
2
3
|
export interface LlmModelPayload {
|
|
3
4
|
name: string;
|
|
4
5
|
provider: string;
|
|
@@ -6,9 +7,16 @@ export interface LlmModelPayload {
|
|
|
6
7
|
region?: string;
|
|
7
8
|
config: Record<string, unknown>;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
/** Item of GET api/v2/ai/llm/models — no config (write-only). */
|
|
11
|
+
export interface LlmModel {
|
|
10
12
|
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
model: string;
|
|
15
|
+
provider: string;
|
|
16
|
+
scope?: string;
|
|
11
17
|
}
|
|
12
18
|
export declare function getActiveLlmModels(httpClient?: HttpClient): Promise<LlmModel[]>;
|
|
13
19
|
export declare function deleteLlmModel(id: string, httpClient?: HttpClient): Promise<void>;
|
|
14
|
-
export declare function registerLlmModel(payload: LlmModelPayload, testConnection?: boolean, httpClient?: HttpClient): Promise<
|
|
20
|
+
export declare function registerLlmModel(payload: LlmModelPayload, testConnection?: boolean, httpClient?: HttpClient): Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
@@ -13,5 +13,78 @@ export interface LlmSettings {
|
|
|
13
13
|
model: string;
|
|
14
14
|
apiKey?: string;
|
|
15
15
|
}
|
|
16
|
+
/** AI terms & conditions accepted status (`api/v2/settings/ai/terms`). */
|
|
17
|
+
export interface AiTerms {
|
|
18
|
+
accepted: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* AI settings slice (`api/v2/settings/ai`) — the tenant-level AI configuration that is
|
|
22
|
+
* separate from the LLM provider config (`.../ai/llm`). Forward-compatible: only the
|
|
23
|
+
* fields we consume are typed; the endpoint returns more (narration, etc.).
|
|
24
|
+
*
|
|
25
|
+
* Note: unlike {@link LlmSettings}, this slice carries NO provider credentials, so
|
|
26
|
+
* reading/writing it never touches the LLM `apiKey`.
|
|
27
|
+
*/
|
|
28
|
+
export interface AiSettings {
|
|
29
|
+
/**
|
|
30
|
+
* Cloud-Linked Features — the AI-services master toggle. Writable via
|
|
31
|
+
* {@link setAiServicesEnabled}.
|
|
32
|
+
*/
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
aiAssistant?: {
|
|
35
|
+
/**
|
|
36
|
+
* Read-only: whether the calling user has the assistant, as resolved by
|
|
37
|
+
* configuration-service's feature access (tenant entitled AND a group granted).
|
|
38
|
+
* Reads `false` while {@link AiSettings.enabled} is off. Writing it is rejected
|
|
39
|
+
* with 422 since SNS-133658.
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Which LLM scope the tenant is configured to ask for — `'customer_byok'` when the
|
|
45
|
+
* tenant supplies its own model, `'sisense_managed'` for Sisense-hosted ones.
|
|
46
|
+
*
|
|
47
|
+
* A configured intent, not an entitlement: the Sisense-managed entitlement rides on
|
|
48
|
+
* the control-plane attach and its license, and the two are not mutually exclusive —
|
|
49
|
+
* one deployment can hold a BYOK model and a managed catalog at once. Read it as
|
|
50
|
+
* "what is asked for", never as "what is granted".
|
|
51
|
+
*/
|
|
52
|
+
featureModelType?: string;
|
|
53
|
+
}
|
|
16
54
|
export declare function getLlmSettings(): Promise<LlmSettings>;
|
|
55
|
+
export declare function getAiTerms(): Promise<AiTerms>;
|
|
56
|
+
/** Updates the AI terms & conditions accepted status (admins only). */
|
|
57
|
+
export declare function setAiTerms(accepted: boolean): Promise<void>;
|
|
58
|
+
/** Reads the AI settings slice (`api/v2/settings/ai`) — no LLM credentials involved. */
|
|
59
|
+
export declare function getAiSettings(): Promise<AiSettings>;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the tenant's LLM scope on the AI settings slice (`api/v2/settings/ai`).
|
|
62
|
+
*
|
|
63
|
+
* Sent as a partial PATCH alongside nothing else, so it never touches the LLM provider
|
|
64
|
+
* config (`.../ai/llm`) and never carries credentials.
|
|
65
|
+
*
|
|
66
|
+
* Like every write to this slice, it has a side effect on the `experiments` flags: see
|
|
67
|
+
* {@link setAiServicesEnabled}.
|
|
68
|
+
*/
|
|
69
|
+
export declare function setAiFeatureModelType(featureModelType: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Switches Cloud-Linked Features — the AI-services master toggle, the top-level
|
|
72
|
+
* `enabled` of the AI settings slice — on or off via a partial PATCH (admins only).
|
|
73
|
+
* Sends nothing else, so it never touches the LLM provider config or credentials.
|
|
74
|
+
*
|
|
75
|
+
* This is the only enablement this slice still accepts. Per-feature access (the
|
|
76
|
+
* assistant, narration, semantic enrichment, semantic search) is owned by
|
|
77
|
+
* configuration-service's feature-access API: since SNS-133658 ai-integration rejects
|
|
78
|
+
* any write carrying one of their `enabled` fields with 422 `readOnlyFeatureFields`.
|
|
79
|
+
* With this toggle off, every feature reads as disabled regardless of its grants.
|
|
80
|
+
*
|
|
81
|
+
* Side effect shared by every write to this slice, this one included: ai-integration
|
|
82
|
+
* computes `enabled = servicesEnabled && llmConfigured` on each PATCH, where
|
|
83
|
+
* `llmConfigured` is true for the Sisense-managed scope and otherwise requires a BYOK
|
|
84
|
+
* LLM. When it is false — AI services off, or BYOK with no LLM — the `experiments`
|
|
85
|
+
* flags (`assistantMemory`, `knowledgeGraphCapture`, `existingAnswerCascade`) are
|
|
86
|
+
* switched off. A later write that finds `enabled` true leaves them as they are, so
|
|
87
|
+
* nothing turns them back on unless the request sends them.
|
|
88
|
+
*/
|
|
89
|
+
export declare function setAiServicesEnabled(enabled: boolean): Promise<void>;
|
|
17
90
|
export declare function updateLlmSettings(settings: LlmSettings): Promise<LlmSettings>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Attribute, Measure, QueryResultData } from '@sisense/sdk-data';
|
|
2
|
+
import { Dataset } from './nlq-service';
|
|
3
|
+
/** Presentational cap shared with sdk-assistant preview renderers. */
|
|
4
|
+
export declare const NLQ_PREVIEW_DISPLAY_LIMIT = 30;
|
|
5
|
+
export type ExtractedDatasetPreview = {
|
|
6
|
+
rows: Array<Record<string, unknown>>;
|
|
7
|
+
isServerTruncated: boolean;
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
type QueryDescriptionForPreview = {
|
|
11
|
+
dimensions?: Attribute[];
|
|
12
|
+
measures?: Measure[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Normalizes the NLQ backend's own `dataset` field (`object | string`) into flat rows
|
|
16
|
+
* the preview renderer can show.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractDatasetPreview(dataset: Dataset | undefined | null): ExtractedDatasetPreview;
|
|
19
|
+
/**
|
|
20
|
+
* The full row count of an NLQ dataset, including a server-truncated one: its `sample` is only a
|
|
21
|
+
* preview, but its per-column `statistics` still carry a `count`. Whether that count skips nulls
|
|
22
|
+
* is unconfirmed, so this takes the largest: the statistics include the grouping dimension (a
|
|
23
|
+
* trend's date), which has a value on every row, so the max is the true row count (checked on the
|
|
24
|
+
* bug-bash VM: 50 monthly and 400 daily rows, date and measure counts equal).
|
|
25
|
+
* @param dataset - the NLQ backend's `dataset` field
|
|
26
|
+
* @returns the row count, or `undefined` when the dataset doesn't say
|
|
27
|
+
*/
|
|
28
|
+
export declare function countDatasetRows(dataset: Dataset | undefined | null): number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Converts an NLQ preview dataset into CSDK {@link QueryResultData} for `Chart chartType="table"`.
|
|
31
|
+
* Mirrors the output shape of sdk-query-client's `prepareResultAsColsAndRows`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function nlqPreviewDatasetToQueryResultData(dataset: Dataset | undefined | null, queryDescription?: QueryDescriptionForPreview): QueryResultData;
|
|
34
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NlqResultChartType, QueryRecommendationResponse } from '@sisense/sdk-ui/ai';
|
|
2
2
|
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
3
3
|
import { ChartJSON, DataSchemaContext, QueryJSON } from '@sisense/sdk-ui/analytics-composer';
|
|
4
|
+
import { Attribute, DataSource, Filter, FilterRelations, Measure, QueryResultData } from '@sisense/sdk-data';
|
|
4
5
|
export interface GetNlqV3ResultRequest {
|
|
5
6
|
text: string;
|
|
6
7
|
timezone?: string;
|
|
@@ -15,6 +16,40 @@ export interface GetNlqV3ResultRequest {
|
|
|
15
16
|
* not chart styling.
|
|
16
17
|
*/
|
|
17
18
|
chartState?: NlqState;
|
|
19
|
+
/** Original verbatim user question, for Knowledge Graph capture. Separate from `text` which may be an LLM-reformulated instruction. */
|
|
20
|
+
user_query?: string;
|
|
21
|
+
/** The user's question in their own phrasing, written by the assistant. Stored with the KG capture; NLQ does not use it. */
|
|
22
|
+
user_question?: string;
|
|
23
|
+
/** Client-side per-tool-call id (toolCallId), for correlating a KG capture with a specific instance — separate from userActionId (per-turn, used for feedback). */
|
|
24
|
+
query_id?: string;
|
|
25
|
+
/** The prior query's query_id, when this is a delta/revision. Lets the KG synthesize a question_text for title-less deltas from the prior question + this refinement. */
|
|
26
|
+
prior_query_id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Columns whose values this turn already read, so smart query need not read them again.
|
|
29
|
+
*
|
|
30
|
+
* camelCase is deliberate and is the wire contract, not a local style choice — this request
|
|
31
|
+
* is mixed-cased (`user_query`, `query_id`, `prior_query_id` are snake; `chartState`,
|
|
32
|
+
* `commonFilters` are camel), so the casing here is worth stating rather than guessing.
|
|
33
|
+
* ai-integration forwards the key verbatim and documents `columnValuesResolvedEntry` in its
|
|
34
|
+
* swagger; llm-services binds it with `Field(alias="columnValuesResolved")` on a
|
|
35
|
+
* `populate_by_name` model, so its snake_case `column_values_resolved` is the Python
|
|
36
|
+
* attribute, not the wire name. Renaming this to snake would silently stop binding.
|
|
37
|
+
*/
|
|
38
|
+
columnValuesResolved?: ColumnValuesResolvedEntry[];
|
|
39
|
+
/**
|
|
40
|
+
* The subject area the data model map chose (SNS-131459 routing). ai-integration reads
|
|
41
|
+
* that area and sends its tables and formulas to smart query as the preferred scope.
|
|
42
|
+
* camelCase on the wire, like `columnValuesResolved`. Sent only when non-blank.
|
|
43
|
+
*/
|
|
44
|
+
subjectAreaId?: string;
|
|
45
|
+
}
|
|
46
|
+
/** One column the caller already read, in the shape smart query expects. */
|
|
47
|
+
export interface ColumnValuesResolvedEntry {
|
|
48
|
+
table: string;
|
|
49
|
+
column: string;
|
|
50
|
+
values: unknown[];
|
|
51
|
+
/** Whether `values` is every value the column holds. */
|
|
52
|
+
complete: boolean;
|
|
18
53
|
}
|
|
19
54
|
export type Dataset = object | string;
|
|
20
55
|
/**
|
|
@@ -54,6 +89,106 @@ export interface QueryRecommendationConfig {
|
|
|
54
89
|
numOfRecommendations: number;
|
|
55
90
|
userPrompt?: string;
|
|
56
91
|
}
|
|
57
|
-
export declare function getNlqV3Result(contextTitle: string, request: GetNlqV3ResultRequest, httpClient?: HttpClient
|
|
58
|
-
|
|
59
|
-
|
|
92
|
+
export declare function getNlqV3Result(contextTitle: string, request: GetNlqV3ResultRequest, httpClient?: HttpClient,
|
|
93
|
+
/** Sent as `x-tool-name`: the tool this call is made for. */
|
|
94
|
+
toolName?: string): Promise<NlqV3Result | null>;
|
|
95
|
+
/**
|
|
96
|
+
* How a column's values are read. `all` returns every value; the rest narrow to those matching a
|
|
97
|
+
* term. Literal matching — never semantic.
|
|
98
|
+
*
|
|
99
|
+
* `all` is a stated option rather than an omitted field: a model reading the schema sees the
|
|
100
|
+
* list-everything choice instead of having to infer it from leaving `mode` out.
|
|
101
|
+
*/
|
|
102
|
+
export type ColumnValuesMode = 'all' | 'contains' | 'startsWith' | 'like';
|
|
103
|
+
/** The column being read. Shared by both request shapes below. */
|
|
104
|
+
interface ColumnValuesTarget {
|
|
105
|
+
table: string;
|
|
106
|
+
column: string;
|
|
107
|
+
/** Column data type; only text columns hold enumerable values. Defaults to text server-side. */
|
|
108
|
+
type?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Reads a column's values, either all of them or only those matching a term.
|
|
112
|
+
*
|
|
113
|
+
* A union rather than two optional fields, because `mode` and `term` are not independent: the
|
|
114
|
+
* service rejects a narrowing mode with no term, and rejects a term with `all`. Modelling that here
|
|
115
|
+
* turns a 400 into a compile error for the callers of this package's public API.
|
|
116
|
+
*/
|
|
117
|
+
export type GetColumnValuesRequest = (ColumnValuesTarget & {
|
|
118
|
+
/**
|
|
119
|
+
* Lists every value. Optional — `all` is the server-side default — but state it:
|
|
120
|
+
* a model reading the schema sees the list-everything choice instead of inferring
|
|
121
|
+
* it from an absent field, which is why `getDataPreviewEngine` sends it.
|
|
122
|
+
*/
|
|
123
|
+
mode?: 'all';
|
|
124
|
+
/** Rejected with `all`: there is nothing to match it against. */
|
|
125
|
+
term?: never;
|
|
126
|
+
}) | (ColumnValuesTarget & {
|
|
127
|
+
/** A narrowing mode returns only the values matching `term`. */
|
|
128
|
+
mode: Exclude<ColumnValuesMode, 'all'>;
|
|
129
|
+
/** Required with a narrowing mode. */
|
|
130
|
+
term: string;
|
|
131
|
+
});
|
|
132
|
+
export interface ColumnValuesResult {
|
|
133
|
+
table: string;
|
|
134
|
+
column: string;
|
|
135
|
+
mode?: ColumnValuesMode | null;
|
|
136
|
+
term?: string | null;
|
|
137
|
+
values: string[];
|
|
138
|
+
/**
|
|
139
|
+
* Whether `values` is every distinct value in the column.
|
|
140
|
+
*
|
|
141
|
+
* Decided server-side, where the row that proves truncation is visible. A raw query result
|
|
142
|
+
* carries no truncation marker, so this cannot be re-derived here — and it is the flag that
|
|
143
|
+
* determines whether an excluding filter is sound.
|
|
144
|
+
*/
|
|
145
|
+
complete: boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Reads one column's distinct values.
|
|
149
|
+
*
|
|
150
|
+
* The query, the limit and the completeness verdict are all owned server-side — this is
|
|
151
|
+
* deliberately a thin call so all three live in exactly one place.
|
|
152
|
+
*/
|
|
153
|
+
export declare function getColumnValues(contextTitle: string, request: GetColumnValuesRequest, httpClient?: HttpClient,
|
|
154
|
+
/** Sent as `x-tool-name`: the tool this call is made for. */
|
|
155
|
+
toolName?: string): Promise<ColumnValuesResult>;
|
|
156
|
+
export interface GetQueryDatasetRequest {
|
|
157
|
+
/** The saved query to run, as smart query's `chartState` holds it. */
|
|
158
|
+
queryState: QueryState;
|
|
159
|
+
/** Dashboard filters, in the shape smart query's `commonFilters` takes. */
|
|
160
|
+
commonFilters?: unknown;
|
|
161
|
+
}
|
|
162
|
+
/** What a rerun of a saved query answers: its dataset and the schema the query was run with. */
|
|
163
|
+
export interface QueryDatasetAnswer {
|
|
164
|
+
dataset: Dataset;
|
|
165
|
+
dataSchema?: DataSchemaContext;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Runs a saved query state with no generation and returns the dataset in exactly smart query's
|
|
169
|
+
* shape (`{data}`, `{sample, statistics}`, `{data: []}` or `{error}`) — the verified answer rerun
|
|
170
|
+
* (SNS-131459) — with the `dataSchema` the query was run with (smart query's own schema, which
|
|
171
|
+
* names columns as the saved query does; absent from an older backend). `null` means there is no dataset to serve: a `not_ready` answer (model closed to
|
|
172
|
+
* AI, unresolved title), a body without `dataset`, or a null dataset. A 403 throws
|
|
173
|
+
* `DatamodelGraphAccessError`; any other failure is rethrown.
|
|
174
|
+
*/
|
|
175
|
+
export declare function getQueryDataset(contextTitle: string, request: GetQueryDatasetRequest, httpClient?: HttpClient,
|
|
176
|
+
/** Sent as `x-tool-name`: the tool this call is made for. */
|
|
177
|
+
toolName?: string): Promise<QueryDatasetAnswer | null>;
|
|
178
|
+
/** Executes a translated NLQ query with client-owned filters. */
|
|
179
|
+
export declare function executeTranslatedNlqQuery(query: {
|
|
180
|
+
dimensions?: Attribute[];
|
|
181
|
+
measures?: Measure[];
|
|
182
|
+
filters?: Filter[] | FilterRelations;
|
|
183
|
+
highlights?: Filter[];
|
|
184
|
+
count?: number;
|
|
185
|
+
offset?: number;
|
|
186
|
+
ungroup?: boolean;
|
|
187
|
+
}, dataSource: DataSource, httpClient?: HttpClient): Promise<QueryResultData>;
|
|
188
|
+
export declare function getQueryRecommendations(contextTitle: string, config: QueryRecommendationConfig, httpClient?: HttpClient,
|
|
189
|
+
/** Sent as `x-tool-name`: the tool this call is made for. */
|
|
190
|
+
toolName?: string): Promise<QueryRecommendationResponse | null>;
|
|
191
|
+
export declare function getQueryRecommendationsLight(contextTitle: string, config: QueryRecommendationConfig, httpClient?: HttpClient,
|
|
192
|
+
/** Sent as `x-tool-name`: the tool this call is made for. */
|
|
193
|
+
toolName?: string): Promise<QueryRecommendationResponse | null>;
|
|
194
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
3
|
+
import { EvaluatePulseResult, EvaluatePulseStep } from '../../engines/evaluate-pulse/types';
|
|
4
|
+
import { AgenticDiffSignal } from './pulse-alerts-service';
|
|
5
|
+
/**
|
|
6
|
+
* Validates one raw SSE `step` (both the `event: step` frame in `consumeEvaluateSse` and each
|
|
7
|
+
* entry of the final `result` event's `steps[]`) before it reaches
|
|
8
|
+
* `mapAgenticLoopStepToEvaluateStep`, which assumes `kind`/`message` are present strings — its
|
|
9
|
+
* `toolResult` branch indexes into `message` with no optional chaining, so a `null` entry or a
|
|
10
|
+
* missing `message` throws uncaught otherwise. `.passthrough()` keeps any other fields
|
|
11
|
+
* ai-integration sends.
|
|
12
|
+
*/
|
|
13
|
+
declare const agenticLoopSseStepSchema: z.ZodObject<{
|
|
14
|
+
kind: z.ZodString;
|
|
15
|
+
message: z.ZodString;
|
|
16
|
+
}, z.core.$loose>;
|
|
17
|
+
/** Raw step shape from ai-integration's evaluate endpoint's SSE (`event: step`). */
|
|
18
|
+
export type AgenticLoopSseStep = z.infer<typeof agenticLoopSseStepSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Maps one ai-integration `toolResult` SSE step into the Studio EvalTrace vocabulary
|
|
21
|
+
* (`runResult` / `diffResult` / …). Skips every other step kind (`toolCall` noise).
|
|
22
|
+
*/
|
|
23
|
+
export declare function mapAgenticLoopStepToEvaluateStep(step: AgenticLoopSseStep): EvaluatePulseStep | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Validates the shape `mapApiResultToEvaluateResult` relies on — both the streamed `result`
|
|
26
|
+
* event and the non-streaming JSON fallback come straight from ai-integration with no other check
|
|
27
|
+
* in between. Each step is validated via `agenticLoopSseStepSchema`, since a `null` entry or a
|
|
28
|
+
* non-string `message` otherwise throws inside `mapAgenticLoopStepToEvaluateStep`.
|
|
29
|
+
*/
|
|
30
|
+
declare const evaluatePulseApiResultSchema: z.ZodObject<{
|
|
31
|
+
alertId: z.ZodString;
|
|
32
|
+
alertName: z.ZodString;
|
|
33
|
+
perQuery: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
|
+
queryName: z.ZodString;
|
|
35
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
36
|
+
hasPriorData: z.ZodBoolean;
|
|
37
|
+
signals: z.ZodArray<z.ZodCustom<AgenticDiffSignal, AgenticDiffSignal>>;
|
|
38
|
+
}, z.core.$loose>>>;
|
|
39
|
+
fired: z.ZodBoolean;
|
|
40
|
+
narrative: z.ZodOptional<z.ZodString>;
|
|
41
|
+
eventId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
outcome: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
met: "met";
|
|
44
|
+
notMet: "notMet";
|
|
45
|
+
noData: "noData";
|
|
46
|
+
}>>>;
|
|
47
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
48
|
+
kind: z.ZodString;
|
|
49
|
+
message: z.ZodString;
|
|
50
|
+
}, z.core.$loose>>;
|
|
51
|
+
finalText: z.ZodOptional<z.ZodString>;
|
|
52
|
+
isError: z.ZodBoolean;
|
|
53
|
+
durationMs: z.ZodNumber;
|
|
54
|
+
stepCount: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$loose>;
|
|
56
|
+
/** Wire result from `POST .../evaluate` (streaming final `result` event or sync JSON). */
|
|
57
|
+
export type EvaluatePulseApiResult = z.infer<typeof evaluatePulseApiResultSchema>;
|
|
58
|
+
export declare function mapApiResultToEvaluateResult(api: EvaluatePulseApiResult): EvaluatePulseResult;
|
|
59
|
+
/**
|
|
60
|
+
* Calls ai-integration `POST /api/v2/ai/pulse/agentic-alerts/{alertId}/evaluate?stream=true`,
|
|
61
|
+
* forwards mapped EvalTrace steps via `onStep`, and returns the Studio result shape.
|
|
62
|
+
*/
|
|
63
|
+
export declare function evaluatePulseViaApi(alertId: string, options?: {
|
|
64
|
+
httpClient?: HttpClient;
|
|
65
|
+
onStep?: (step: EvaluatePulseStep) => void;
|
|
66
|
+
/**
|
|
67
|
+
* What caused this call — defaults to ai-integration's own `'onDemand'` default when
|
|
68
|
+
* omitted. Pass `'create'` only for the one chained evaluation that runs immediately
|
|
69
|
+
* after `authorPulseEngine`'s `create` action persists a brand-new alert, so the history
|
|
70
|
+
* shows it as the creation check. Every trigger's cycle is equally a diff baseline.
|
|
71
|
+
*/
|
|
72
|
+
trigger?: 'onDemand' | 'create';
|
|
73
|
+
/** Optional cancellation for the evaluate fetch / SSE read. */
|
|
74
|
+
abortSignal?: AbortSignal;
|
|
75
|
+
/** The calling tool, sent as `x-tool-name`; defaults to `evaluatePulse`. */
|
|
76
|
+
toolName?: string;
|
|
77
|
+
}): Promise<EvaluatePulseResult>;
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
2
|
+
import { AgenticQuery, CrossQueryTransform } from '../../engines/author-pulse/types';
|
|
3
|
+
/**
|
|
4
|
+
* vnext scopes every alert PATCH to `{_id, owner}` and answers a miss with a bare 404, so a
|
|
5
|
+
* non-owner's edit looks exactly like a deleted alert server-side — this message covers both.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ALERT_NOT_FOUND_OR_NOT_OWNER_MESSAGE = "Alert not found, or you aren't its owner \u2014 only the alert's owner can update it. It may also have been deleted.";
|
|
8
|
+
/** `condition.approvedBy`/`approvedAt` — set by vnext when an agent authored/applied a change on the user's behalf. */
|
|
9
|
+
export interface AgenticApprovedBy {
|
|
10
|
+
type: 'user' | 'agent';
|
|
11
|
+
id?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The `agentic` alert's own context fields — mirrors vnext's schema for it.
|
|
16
|
+
* Flat on `context`, no nested `condition` wrapper — the alert's top-level
|
|
17
|
+
* `type: 'agentic'` is the discriminator, so this interface doesn't repeat
|
|
18
|
+
* it. Hand-rolled, no shared type package exists across vnext/sisense-client
|
|
19
|
+
* for this domain.
|
|
20
|
+
*
|
|
21
|
+
* Eval history is read via vnext's separate eval-history endpoints, not
|
|
22
|
+
* embedded on the alert document — there is no `evaluationHistory` field
|
|
23
|
+
* here to mirror.
|
|
24
|
+
*/
|
|
25
|
+
export interface AgenticAlertContext {
|
|
26
|
+
queries: AgenticQuery[];
|
|
27
|
+
queryVersion?: number;
|
|
28
|
+
skill: string;
|
|
29
|
+
/** Required on create (see `PulseAlertCreateDto`). Optional on PATCH. */
|
|
30
|
+
evalMode?: 'conditional';
|
|
31
|
+
/** A json-rules-engine `conditions` tree, evaluated only when `evalMode === 'conditional'` — or the literal `{ always: true }` sentinel. */
|
|
32
|
+
decisionSpec?: Record<string, unknown>;
|
|
33
|
+
/** Cross-query transforms (arithmetic/rankCompare/valueCompare) a single `decisionSpec` leaf can't express alone (e.g. "actual exceeds budget by 10%", or "top 10 by A differ from top 10 by B") — code-recomputed at evaluation time, never LLM-supplied. Replaces the retired scalar-only `derived` field. */
|
|
34
|
+
crossQueryTransforms?: CrossQueryTransform[];
|
|
35
|
+
approvedBy?: AgenticApprovedBy;
|
|
36
|
+
approvedAt?: string;
|
|
37
|
+
/**
|
|
38
|
+
* System-managed summary of the most recent evaluation cycle in the reader's own data scope.
|
|
39
|
+
* Each cycle ai-integration records writes its scope's row in vnext's `alertScopeSummaries`,
|
|
40
|
+
* and every alert read fills these fields from the reader's row. Lets `inspectPulse`'s
|
|
41
|
+
* `get-workflow`/`list-workflows` answer "did it fire?" without a separate `list-evals` call.
|
|
42
|
+
* Absent until the reader's scope has had a cycle.
|
|
43
|
+
*/
|
|
44
|
+
lastEvaluatedAt?: string;
|
|
45
|
+
lastEvalFired?: boolean;
|
|
46
|
+
lastEvalNarrative?: string;
|
|
47
|
+
/** `'error'` when that cycle failed or was not evaluated; it then has no narrative. */
|
|
48
|
+
lastEvalStatus?: 'ok' | 'error';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One column of a `runQuery`/`diff` table result — self-describing, no
|
|
52
|
+
* separate `kind: 'scalar' | 'set'` discriminator (zero `key`-role columns +
|
|
53
|
+
* one row is the scalar case). See Phase 0 doc §2.2.
|
|
54
|
+
*/
|
|
55
|
+
export interface AgenticTableColumn {
|
|
56
|
+
name: string;
|
|
57
|
+
role: 'key' | 'value';
|
|
58
|
+
datatype: string;
|
|
59
|
+
}
|
|
60
|
+
/** Unified table shape every `agentic` query's result normalizes to. */
|
|
61
|
+
export interface AgenticTableResult {
|
|
62
|
+
columns: AgenticTableColumn[];
|
|
63
|
+
rows: Array<Record<string, unknown>>;
|
|
64
|
+
}
|
|
65
|
+
/** JAQL's `{data, text}` cell convention — the raw and display-formatted value. */
|
|
66
|
+
export interface AgenticCell {
|
|
67
|
+
data: unknown;
|
|
68
|
+
text: string;
|
|
69
|
+
}
|
|
70
|
+
export type AgenticChangeType = 'entered' | 'exited' | 'increased' | 'decreased' | 'changed' | 'unchanged';
|
|
71
|
+
/** One per-row-per-column diff result. */
|
|
72
|
+
export interface AgenticDiffSignal {
|
|
73
|
+
keyValues: Record<string, unknown>;
|
|
74
|
+
column: string;
|
|
75
|
+
changeType: AgenticChangeType;
|
|
76
|
+
previousValue?: AgenticCell;
|
|
77
|
+
currentValue?: AgenticCell;
|
|
78
|
+
delta?: number;
|
|
79
|
+
percentChange?: number | null;
|
|
80
|
+
}
|
|
81
|
+
export interface AgenticDiffResult {
|
|
82
|
+
hasPriorData: boolean;
|
|
83
|
+
signals: AgenticDiffSignal[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A source entry never carries `oid` — vnext's real Joi validator
|
|
87
|
+
* sets `oid: Joi.forbidden()` for both `cube` and `live` sources.
|
|
88
|
+
*/
|
|
89
|
+
export interface PulseAlertSource {
|
|
90
|
+
name?: string;
|
|
91
|
+
server?: string;
|
|
92
|
+
type: 'cube' | 'server' | 'live';
|
|
93
|
+
}
|
|
94
|
+
export interface PulseAlertParty {
|
|
95
|
+
type: 'group' | 'user' | 'adgroup';
|
|
96
|
+
id?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Notification channel settings — vnext's `addAlertAction`/`updateAlertAction` swagger shapes.
|
|
100
|
+
* `slack`/`zapier` must be sent as a WHOLE object on update: vnext's `updateAlertAction` marks
|
|
101
|
+
* their sub-keys `required` once the object is present, so a partial `{active: true}` 400s —
|
|
102
|
+
* always read-merge-send the full sub-object, never a partial one (SNS-132805).
|
|
103
|
+
*/
|
|
104
|
+
export interface PulseAlertAction {
|
|
105
|
+
feed?: boolean;
|
|
106
|
+
email?: boolean;
|
|
107
|
+
mobile?: boolean;
|
|
108
|
+
slack?: {
|
|
109
|
+
active: boolean;
|
|
110
|
+
url: string;
|
|
111
|
+
channels: string;
|
|
112
|
+
};
|
|
113
|
+
zapier?: {
|
|
114
|
+
active: boolean;
|
|
115
|
+
url: string;
|
|
116
|
+
};
|
|
117
|
+
webhooks?: Array<{
|
|
118
|
+
name: string;
|
|
119
|
+
url: string;
|
|
120
|
+
active: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* How often a live-scheduled alert re-evaluates. Top-level on the alert document (a sibling of
|
|
125
|
+
* `context`, matching vnext's shared `addAlert` swagger schema) — NOT nested under `context`,
|
|
126
|
+
* since vnext's per-type `context` Joi schemas reject unknown keys and would 400 a
|
|
127
|
+
* `context.scheduler`. `periodMode`/`periodValue` vocabulary matches vnext's
|
|
128
|
+
* `alerts.dal.js`/`alerts.service.js` (`updateLiveAlertsMinFrequency`, `shouldTriggerLiveAlert`).
|
|
129
|
+
* Two shapes, discriminated on `periodMode`: interval or cron — for cron the server owns the
|
|
130
|
+
* anchors, so a client never sends `startTime`/`lastExecutedTime`.
|
|
131
|
+
*/
|
|
132
|
+
export interface PulseAlertIntervalScheduler {
|
|
133
|
+
periodMode: 'minutes' | 'hours' | 'days';
|
|
134
|
+
periodValue: number;
|
|
135
|
+
startTime?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Stamped equal to `startTime` on create for live-scheduled alerts — vnext's due-math
|
|
138
|
+
* (`shouldTriggerLiveAlert`) treats an absent value as "now", which would make a
|
|
139
|
+
* freshly-created alert due on the very next `livePulse` tick regardless of its
|
|
140
|
+
* configured period.
|
|
141
|
+
*/
|
|
142
|
+
lastExecutedTime?: string;
|
|
143
|
+
/** Stored but never read for an interval alert (legacy field the KPI dialog also writes). */
|
|
144
|
+
timeZone?: string;
|
|
145
|
+
}
|
|
146
|
+
/** Cron-based scheduler variant: plain 5-field cron (`*` `,` `-` `/` only, numeric fields) with an IANA `timeZone`. */
|
|
147
|
+
export interface PulseAlertCronScheduler {
|
|
148
|
+
periodMode: 'cron';
|
|
149
|
+
cron: string;
|
|
150
|
+
timeZone: string;
|
|
151
|
+
/** Read-only on the wire: vnext stamps and re-anchors these for a cron alert. */
|
|
152
|
+
startTime?: string;
|
|
153
|
+
lastExecutedTime?: string;
|
|
154
|
+
}
|
|
155
|
+
export type PulseAlertScheduler = PulseAlertIntervalScheduler | PulseAlertCronScheduler;
|
|
156
|
+
export declare function isCronScheduler(scheduler: PulseAlertScheduler | undefined): scheduler is PulseAlertCronScheduler;
|
|
157
|
+
/** Verdict from `previewSchedule` — `cron` comes back normalised; `nextRun` is an ISO instant. */
|
|
158
|
+
export type SchedulePreviewDto = {
|
|
159
|
+
valid: true;
|
|
160
|
+
cron: string;
|
|
161
|
+
timeZone: string;
|
|
162
|
+
nextRun: string;
|
|
163
|
+
} | {
|
|
164
|
+
valid: false;
|
|
165
|
+
cron?: string;
|
|
166
|
+
timeZone?: string;
|
|
167
|
+
error: {
|
|
168
|
+
code: number;
|
|
169
|
+
message: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Body for `POST /api/v1/alerts` when creating a new `agentic` alert. `category`/
|
|
174
|
+
* `type` are narrowed to the literal `agentic`/`judgment` values (rather than the
|
|
175
|
+
* fuller unions `PulseAlertDto` uses) since this DTO only ever creates agentic
|
|
176
|
+
* alerts — no `context.kpi`/`dashboard` needed, unlike the legacy `type: 'kpi'`
|
|
177
|
+
* shape agentic alerts used before being promoted to their own top-level type.
|
|
178
|
+
*/
|
|
179
|
+
export interface PulseAlertCreateDto {
|
|
180
|
+
name: string;
|
|
181
|
+
message?: string;
|
|
182
|
+
enabled?: boolean;
|
|
183
|
+
category: 'judgment';
|
|
184
|
+
type: 'agentic';
|
|
185
|
+
parties: PulseAlertParty[];
|
|
186
|
+
action: Record<string, unknown>;
|
|
187
|
+
scheduler?: PulseAlertScheduler;
|
|
188
|
+
context: AgenticAlertContext & {
|
|
189
|
+
sources: PulseAlertSource[];
|
|
190
|
+
locale?: string;
|
|
191
|
+
/**
|
|
192
|
+
* Required on create — Galaxy rejects agentic alerts without it.
|
|
193
|
+
*/
|
|
194
|
+
evalMode: 'conditional';
|
|
195
|
+
decisionSpec: Record<string, unknown>;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export interface PulseAlertCreatedDto {
|
|
199
|
+
_id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Create a new Pulse alert (used for a brand-new `agentic` alert once its
|
|
204
|
+
* queries[]/skill have been authored and reviewed).
|
|
205
|
+
*/
|
|
206
|
+
export declare function createAlert(alert: PulseAlertCreateDto, httpClient?: HttpClient): Promise<PulseAlertCreatedDto>;
|
|
207
|
+
/** vnext's live-alert floor when the tenant has none configured (its `DEFAULT_MIN_FREQUENCY_MINUTES`). */
|
|
208
|
+
export declare const DEFAULT_LIVE_ALERT_MIN_FREQUENCY_MINUTES = 60;
|
|
209
|
+
/**
|
|
210
|
+
* The administrator's "Live (Highest Frequency)" floor in minutes — `pulseLive.minFrequency` of the
|
|
211
|
+
* system settings (readable by any user), the same value PrismWebClient's Pulse dialog enforces and
|
|
212
|
+
* vnext checks on save. Anything but a positive whole number of minutes (the setting is typed
|
|
213
|
+
* `number`) means vnext's own fallback — a fractional floor couldn't be offered back as an interval.
|
|
214
|
+
*/
|
|
215
|
+
export declare function getLiveAlertMinFrequency(httpClient?: HttpClient): Promise<number>;
|
|
216
|
+
/**
|
|
217
|
+
* Validates a cron schedule the way a save would (always HTTP 200; rejection is `valid: false`).
|
|
218
|
+
* An older server 404s here — surfaced as an "unsupported" message rather than a retry.
|
|
219
|
+
*/
|
|
220
|
+
export declare function previewSchedule(cron: string, timeZone: string, httpClient?: HttpClient): Promise<SchedulePreviewDto>;
|
|
221
|
+
/**
|
|
222
|
+
* Apply a redefinition (queries/queryVersion/skill) to an existing `agentic`
|
|
223
|
+
* alert's `context`, flat — no `condition` wrapper.
|
|
224
|
+
*/
|
|
225
|
+
export declare function updateAlertCondition(alertId: string, condition: Pick<AgenticAlertContext, 'queries' | 'queryVersion' | 'skill' | 'evalMode' | 'decisionSpec' | 'crossQueryTransforms'>, httpClient?: HttpClient): Promise<PulseAlertCreatedDto>;
|
|
226
|
+
/**
|
|
227
|
+
* Top-level fields `updateAlert` (recipients/channels/settings) can patch — everything
|
|
228
|
+
* `updateUserAlertById` accepts outside `context` (SNS-132805). Every field is a genuine partial:
|
|
229
|
+
* an omitted field keeps its stored value. `action.slack`/`.zapier`/`.webhooks` must each be sent
|
|
230
|
+
* whole (see `PulseAlertAction`) — read the current alert, merge, then send the full sub-object.
|
|
231
|
+
* `parties` is a full-array replace exactly like `context.queries` on `updateAlertCondition` — the
|
|
232
|
+
* owner is auto-injected server-side and cannot be removed by omitting them here.
|
|
233
|
+
*/
|
|
234
|
+
export type PulseAlertUpdatePatch = Partial<{
|
|
235
|
+
name: string;
|
|
236
|
+
message: string;
|
|
237
|
+
enabled: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* vnext replaces this subdocument wholesale on PATCH — `startTime`/`lastExecutedTime` are
|
|
240
|
+
* optional here (not required, unlike `periodMode`/`periodValue`) only so a caller with no
|
|
241
|
+
* prior scheduler to preserve (a brand-new live alert being scheduled for the first time)
|
|
242
|
+
* can still send a bare `{periodMode, periodValue}`. An UPDATE to an alert that already has a
|
|
243
|
+
* scheduler must carry its current `startTime`/`lastExecutedTime` through, or vnext's
|
|
244
|
+
* due-math treats their absence as "now" and the alert goes silently overdue-never again.
|
|
245
|
+
*/
|
|
246
|
+
scheduler: (Pick<PulseAlertIntervalScheduler, 'periodMode' | 'periodValue'> & Partial<Pick<PulseAlertIntervalScheduler, 'startTime' | 'lastExecutedTime' | 'timeZone'>>) | Pick<PulseAlertCronScheduler, 'periodMode' | 'cron' | 'timeZone'>;
|
|
247
|
+
parties: PulseAlertParty[];
|
|
248
|
+
disabledUsers: string[];
|
|
249
|
+
action: PulseAlertAction;
|
|
250
|
+
}>;
|
|
251
|
+
/**
|
|
252
|
+
* Apply a top-level patch (name/message/enabled/scheduler/parties/disabledUsers/action) to an
|
|
253
|
+
* existing alert — the counterpart to `updateAlertCondition`, which only ever touches `context`.
|
|
254
|
+
* Owner-only, like `updateAlertCondition` — see `ALERT_NOT_FOUND_OR_NOT_OWNER_MESSAGE`.
|
|
255
|
+
*/
|
|
256
|
+
export declare function updateAlert(alertId: string, patch: PulseAlertUpdatePatch, httpClient?: HttpClient): Promise<PulseAlertCreatedDto>;
|
|
257
|
+
/**
|
|
258
|
+
* Mute or unmute an alert's notifications for the CALLING user only — adds/removes them in the
|
|
259
|
+
* alert's `disabledUsers`. Unlike `updateAlert`, vnext doesn't scope this to the owner, so any
|
|
260
|
+
* recipient can call it; the alert itself keeps running for everyone else. vnext answers a caller
|
|
261
|
+
* who isn't one of the alert's users with the same bare 404 as a deleted alert
|
|
262
|
+
* (`validateUserOfAlert`), so the message covers both.
|
|
263
|
+
*/
|
|
264
|
+
export declare function setAlertReceiveNotification(alertId: string, receiveNotification: boolean, httpClient?: HttpClient): Promise<void>;
|