@jupiterone/jupiterone-mcp 2.1.0 → 2.2.0
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/client/graphql/queries.d.ts +1 -1
- package/dist/client/graphql/queries.d.ts.map +1 -1
- package/dist/client/graphql/queries.js +4 -0
- package/dist/client/graphql/queries.js.map +1 -1
- package/dist/generated/description-map.d.ts.map +1 -1
- package/dist/generated/description-map.js +410 -15
- package/dist/generated/description-map.js.map +1 -1
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +35 -1
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tools/alerts.d.ts.map +1 -1
- package/dist/server/tools/alerts.js +2 -5
- package/dist/server/tools/alerts.js.map +1 -1
- package/dist/server/tools/dashboard-layout.d.ts +80 -3
- package/dist/server/tools/dashboard-layout.d.ts.map +1 -1
- package/dist/server/tools/dashboard-layout.js +220 -15
- package/dist/server/tools/dashboard-layout.js.map +1 -1
- package/dist/server/tools/dashboards.d.ts.map +1 -1
- package/dist/server/tools/dashboards.js +379 -10
- package/dist/server/tools/dashboards.js.map +1 -1
- package/dist/server/tools/errors.d.ts +56 -10
- package/dist/server/tools/errors.d.ts.map +1 -1
- package/dist/server/tools/errors.js +194 -10
- package/dist/server/tools/errors.js.map +1 -1
- package/dist/server/tools/integrations.d.ts.map +1 -1
- package/dist/server/tools/integrations.js +15 -4
- package/dist/server/tools/integrations.js.map +1 -1
- package/dist/server/tools/j1ql.d.ts.map +1 -1
- package/dist/server/tools/j1ql.js +72 -4
- package/dist/server/tools/j1ql.js.map +1 -1
- package/dist/server/tools/rules.d.ts.map +1 -1
- package/dist/server/tools/rules.js +57 -6
- package/dist/server/tools/rules.js.map +1 -1
- package/dist/server/tools/telemetry.d.ts +6 -0
- package/dist/server/tools/telemetry.d.ts.map +1 -1
- package/dist/server/tools/telemetry.js.map +1 -1
- package/dist/server/tools/types.d.ts.map +1 -1
- package/dist/server/tools/types.js +7 -1
- package/dist/server/tools/types.js.map +1 -1
- package/dist/server/tools/usage.d.ts +13 -3
- package/dist/server/tools/usage.d.ts.map +1 -1
- package/dist/server/tools/usage.js +140 -4
- package/dist/server/tools/usage.js.map +1 -1
- package/dist/server/tools/value-probe.d.ts +85 -0
- package/dist/server/tools/value-probe.d.ts.map +1 -0
- package/dist/server/tools/value-probe.js +473 -0
- package/dist/server/tools/value-probe.js.map +1 -0
- package/dist/server/tools/widget-config-lint.d.ts +39 -0
- package/dist/server/tools/widget-config-lint.d.ts.map +1 -0
- package/dist/server/tools/widget-config-lint.js +290 -0
- package/dist/server/tools/widget-config-lint.js.map +1 -0
- package/dist/server/tools/widget-preflight.d.ts +63 -0
- package/dist/server/tools/widget-preflight.d.ts.map +1 -0
- package/dist/server/tools/widget-preflight.js +238 -0
- package/dist/server/tools/widget-preflight.js.map +1 -0
- package/dist/server/tools/widget-render-contract.d.ts +134 -0
- package/dist/server/tools/widget-render-contract.d.ts.map +1 -0
- package/dist/server/tools/widget-render-contract.js +421 -0
- package/dist/server/tools/widget-render-contract.js.map +1 -0
- package/dist/server/tools/widget-settings-keys.d.ts +51 -0
- package/dist/server/tools/widget-settings-keys.d.ts.map +1 -0
- package/dist/server/tools/widget-settings-keys.js +152 -0
- package/dist/server/tools/widget-settings-keys.js.map +1 -0
- package/dist/types/jupiterone.d.ts +7 -0
- package/dist/types/jupiterone.d.ts.map +1 -1
- package/dist/utils/j1ql-filters.d.ts +48 -0
- package/dist/utils/j1ql-filters.d.ts.map +1 -0
- package/dist/utils/j1ql-filters.js +184 -0
- package/dist/utils/j1ql-filters.js.map +1 -0
- package/dist/utils/j1ql-validator.d.ts +0 -5
- package/dist/utils/j1ql-validator.d.ts.map +1 -1
- package/dist/utils/j1ql-validator.js +27 -6
- package/dist/utils/j1ql-validator.js.map +1 -1
- package/node_modules/dtrace-provider/build/Makefile +1 -1
- package/package.json +1 -1
- package/dist/utils/description-loader.d.ts +0 -2
- package/dist/utils/description-loader.d.ts.map +0 -1
- package/dist/utils/description-loader.js +0 -17
- package/dist/utils/description-loader.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Query } from '../../types/jupiterone.js';
|
|
2
2
|
import { type J1QLValidator } from '../../utils/j1ql-validator.js';
|
|
3
3
|
import type { ToolResult } from './types.js';
|
|
4
|
+
import { type WidgetContractCheck } from './widget-render-contract.js';
|
|
4
5
|
/**
|
|
5
6
|
* The HTTP status of an upstream authentication/authorization rejection, or `null` for any other
|
|
6
7
|
* error. An account can stay in `list-accounts` (membership) yet fail live authorization — revoked,
|
|
@@ -32,15 +33,21 @@ export declare function accessDeniedResult(statusCode: number, context: AccessDe
|
|
|
32
33
|
* errors are framed by the registration chokepoint before this is reached.
|
|
33
34
|
*/
|
|
34
35
|
export declare function toErrorResponse(error: unknown, context: string): ToolResult;
|
|
36
|
+
/** One query the static parse gate refused, named as the caller labelled it. */
|
|
37
|
+
export interface QueryValidationFailure {
|
|
38
|
+
queryName: string;
|
|
39
|
+
error: string;
|
|
40
|
+
suggestion: string;
|
|
41
|
+
}
|
|
35
42
|
/**
|
|
36
43
|
* Statically validate each J1QL query in a rule/widget definition before the create/update call.
|
|
37
44
|
* Local parse only (see J1QLValidator.validateQuery) — instant, no backend round-trips.
|
|
45
|
+
*
|
|
46
|
+
* A query object can carry a second query: `drilldownQuery` is J1QL the widget stores and runs when
|
|
47
|
+
* a reader clicks a data point. An invalid one fails at that click, days later, with nothing in the
|
|
48
|
+
* create response to point at it — and the parse is already loaded here, so it costs nothing.
|
|
38
49
|
*/
|
|
39
|
-
export declare function validateQueries(queries: Query[] | undefined, validator: J1QLValidator):
|
|
40
|
-
queryName: string;
|
|
41
|
-
error: string;
|
|
42
|
-
suggestion: string;
|
|
43
|
-
}>;
|
|
50
|
+
export declare function validateQueries(queries: Query[] | undefined, validator: J1QLValidator): QueryValidationFailure[];
|
|
44
51
|
/**
|
|
45
52
|
* Tool result for an execute-j1ql-query call rejected by the static parse gate. States plainly
|
|
46
53
|
* that nothing ran — retrying with a fixed query is free and instant.
|
|
@@ -50,11 +57,50 @@ export declare function invalidQueryResponse(validation: {
|
|
|
50
57
|
suggestion?: string;
|
|
51
58
|
}): ToolResult;
|
|
52
59
|
/** Tool result returned (as a non-throwing outcome) when pre-create query validation fails. */
|
|
53
|
-
export declare function createValidationErrorResponse(validationResults:
|
|
54
|
-
queryName: string;
|
|
55
|
-
error: string;
|
|
56
|
-
suggestion: string;
|
|
57
|
-
}>): ToolResult;
|
|
60
|
+
export declare function createValidationErrorResponse(validationResults: QueryValidationFailure[]): ToolResult;
|
|
58
61
|
/** Validator-aware error for execute-j1ql-query: maps execution errors to actionable suggestions. */
|
|
59
62
|
export declare function createQueryErrorResponse(error: unknown, query: string, validator: J1QLValidator): ToolResult;
|
|
63
|
+
/** A widget query whose RETURN columns cannot render in the chosen chart type. */
|
|
64
|
+
export interface WidgetContractViolation {
|
|
65
|
+
queryName: string;
|
|
66
|
+
check: WidgetContractCheck;
|
|
67
|
+
/**
|
|
68
|
+
* Set when the widget carries no runnable query at all, so there is no RETURN clause to fix.
|
|
69
|
+
* `markdown` is the only widget type that renders without one.
|
|
70
|
+
*/
|
|
71
|
+
queryless?: true;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check each widget query against its chart type's column contract, before the create/update call.
|
|
75
|
+
*
|
|
76
|
+
* The sibling of `validateQueries`: that one catches queries the parser rejects, this one catches
|
|
77
|
+
* queries the parser accepts but the renderer cannot draw. Both are local — no backend round-trip.
|
|
78
|
+
* Returns only violations; advisory gaps (`missingRecommended`) are reported by the post-create
|
|
79
|
+
* render preflight instead, because they never justify refusing the widget.
|
|
80
|
+
*
|
|
81
|
+
* The whole array is what decides some of the contract, not each query in isolation: a pie's `name`
|
|
82
|
+
* column is required on a lone query and irrelevant on several, since a multi-query chart labels
|
|
83
|
+
* its slices by query name. Passing the count keeps that decision here, where the widget's shape is
|
|
84
|
+
* known, rather than at every call site.
|
|
85
|
+
*/
|
|
86
|
+
export declare function checkWidgetQueries(chartType: string | undefined, queries: Query[] | undefined): WidgetContractViolation[];
|
|
87
|
+
/**
|
|
88
|
+
* Advisory notes for widget queries that pass the gate but are shaped oddly for their chart type.
|
|
89
|
+
*
|
|
90
|
+
* EACH query on a `number` widget is documented to return a single `value`, and the field report
|
|
91
|
+
* behind TD-9016 was that extras "can break" it — but nothing has confirmed what the current
|
|
92
|
+
* renderer does with them, so this warns and does not block.
|
|
93
|
+
*
|
|
94
|
+
* The count of queries is not what is being judged. A number widget legitimately carries several —
|
|
95
|
+
* that is how percentage mode divides one query's total by another's — so the note has to say
|
|
96
|
+
* "columns" where it means columns, or it teaches an agent to collapse a correct widget.
|
|
97
|
+
*/
|
|
98
|
+
export declare function widgetAdvisoryNotes(chartType: string | undefined, queries: Query[] | undefined): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Tool result for a widget rejected by the column-contract gate.
|
|
101
|
+
*
|
|
102
|
+
* Recovery stays in-band: the widget was not created, and the response carries a ready-to-run
|
|
103
|
+
* corrected query wherever one could be derived and re-verified — retrying is free and instant.
|
|
104
|
+
*/
|
|
105
|
+
export declare function widgetContractErrorResponse(chartType: string, violations: WidgetContractViolation[], operation?: 'create' | 'update'): ToolResult;
|
|
60
106
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,O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GAAqG;AACrG,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,aAAa,GACvB,UAAU,CAiBZ;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,mBAAmB,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AA0BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,GAC3B,uBAAuB,EAAE,CAuB3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,GAC3B,MAAM,EAAE,CAoBV;AAuCD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,uBAAuB,EAAE,EACrC,SAAS,GAAE,QAAQ,GAAG,QAAmB,GACxC,UAAU,CA0CZ"}
|
|
@@ -8,8 +8,12 @@ exports.validateQueries = validateQueries;
|
|
|
8
8
|
exports.invalidQueryResponse = invalidQueryResponse;
|
|
9
9
|
exports.createValidationErrorResponse = createValidationErrorResponse;
|
|
10
10
|
exports.createQueryErrorResponse = createQueryErrorResponse;
|
|
11
|
+
exports.checkWidgetQueries = checkWidgetQueries;
|
|
12
|
+
exports.widgetAdvisoryNotes = widgetAdvisoryNotes;
|
|
13
|
+
exports.widgetContractErrorResponse = widgetContractErrorResponse;
|
|
11
14
|
const sanitize_error_js_1 = require("../../client/sanitize-error.js");
|
|
12
15
|
const j1ql_validator_js_1 = require("../../utils/j1ql-validator.js");
|
|
16
|
+
const widget_render_contract_js_1 = require("./widget-render-contract.js");
|
|
13
17
|
const ACCESS_DENIED_STATUS = new Set([401, 403]);
|
|
14
18
|
// GraphQL `extensions.code` values that mean authorization failed, mapped to the HTTP status they
|
|
15
19
|
// correspond to. The upstream frequently returns these inside an HTTP 200 (see JupiterOneApiError.code),
|
|
@@ -91,25 +95,38 @@ function toErrorResponse(error, context) {
|
|
|
91
95
|
isError: true,
|
|
92
96
|
};
|
|
93
97
|
}
|
|
98
|
+
/** Parse one J1QL string, or return null when there is nothing to parse and nothing wrong. */
|
|
99
|
+
function validateOne(queryName, query, validator) {
|
|
100
|
+
if (!query)
|
|
101
|
+
return null;
|
|
102
|
+
const validation = validator.validateQuery(query);
|
|
103
|
+
if (validation.isValid)
|
|
104
|
+
return null;
|
|
105
|
+
return {
|
|
106
|
+
queryName,
|
|
107
|
+
error: validation.error || 'Query validation failed',
|
|
108
|
+
suggestion: validation.suggestion || 'Please check the query syntax and try again',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
94
111
|
/**
|
|
95
112
|
* Statically validate each J1QL query in a rule/widget definition before the create/update call.
|
|
96
113
|
* Local parse only (see J1QLValidator.validateQuery) — instant, no backend round-trips.
|
|
114
|
+
*
|
|
115
|
+
* A query object can carry a second query: `drilldownQuery` is J1QL the widget stores and runs when
|
|
116
|
+
* a reader clicks a data point. An invalid one fails at that click, days later, with nothing in the
|
|
117
|
+
* create response to point at it — and the parse is already loaded here, so it costs nothing.
|
|
97
118
|
*/
|
|
98
119
|
function validateQueries(queries, validator) {
|
|
99
120
|
if (!queries || !Array.isArray(queries))
|
|
100
121
|
return [];
|
|
101
122
|
const validationResults = [];
|
|
102
123
|
for (const queryObj of queries) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
suggestion: validation.suggestion || 'Please check the query syntax and try again',
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
124
|
+
const queryName = queryObj.name || 'Unnamed query';
|
|
125
|
+
const failures = [
|
|
126
|
+
validateOne(queryName, queryObj.query, validator),
|
|
127
|
+
validateOne(`${queryName} (drilldownQuery)`, queryObj.drilldownQuery, validator),
|
|
128
|
+
];
|
|
129
|
+
validationResults.push(...failures.filter((failure) => failure !== null));
|
|
113
130
|
}
|
|
114
131
|
return validationResults;
|
|
115
132
|
}
|
|
@@ -160,4 +177,171 @@ function createQueryErrorResponse(error, query, validator) {
|
|
|
160
177
|
isError: true,
|
|
161
178
|
};
|
|
162
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* The queries on a widget that can draw anything: the ones carrying J1QL.
|
|
182
|
+
*
|
|
183
|
+
* An entry whose `query` is an empty string is accepted by the input schema and by the parse gate
|
|
184
|
+
* (there is nothing to parse and so nothing wrong), and it renders nothing. It must not count
|
|
185
|
+
* towards the widget's shape either: an empty second entry inflated `queryCount` to two, and a lone
|
|
186
|
+
* pie carrying one dodged the single-query `name` requirement — the undefined-donut, built through
|
|
187
|
+
* the gate that exists to stop it.
|
|
188
|
+
*/
|
|
189
|
+
function runnableQueries(queries) {
|
|
190
|
+
return queries.filter((queryObj) => typeof queryObj?.query === 'string' && queryObj.query.trim());
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Whether this chart type draws its queries' results, so a widget without one is a blank tile.
|
|
194
|
+
*
|
|
195
|
+
* `markdown` is the exception the whole check exists around: it renders its text and carries
|
|
196
|
+
* `queries: []` legitimately. `table` has no column contract to look up — it renders whatever
|
|
197
|
+
* columns it is given — but it still has nothing to render without a query.
|
|
198
|
+
*/
|
|
199
|
+
function needsAQuery(chartType) {
|
|
200
|
+
return chartType === 'table' || chartType in widget_render_contract_js_1.WIDGET_COLUMN_CONTRACT;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Check each widget query against its chart type's column contract, before the create/update call.
|
|
204
|
+
*
|
|
205
|
+
* The sibling of `validateQueries`: that one catches queries the parser rejects, this one catches
|
|
206
|
+
* queries the parser accepts but the renderer cannot draw. Both are local — no backend round-trip.
|
|
207
|
+
* Returns only violations; advisory gaps (`missingRecommended`) are reported by the post-create
|
|
208
|
+
* render preflight instead, because they never justify refusing the widget.
|
|
209
|
+
*
|
|
210
|
+
* The whole array is what decides some of the contract, not each query in isolation: a pie's `name`
|
|
211
|
+
* column is required on a lone query and irrelevant on several, since a multi-query chart labels
|
|
212
|
+
* its slices by query name. Passing the count keeps that decision here, where the widget's shape is
|
|
213
|
+
* known, rather than at every call site.
|
|
214
|
+
*/
|
|
215
|
+
function checkWidgetQueries(chartType, queries) {
|
|
216
|
+
if (!chartType || !Array.isArray(queries))
|
|
217
|
+
return [];
|
|
218
|
+
const runnable = runnableQueries(queries);
|
|
219
|
+
if (runnable.length === 0) {
|
|
220
|
+
if (!needsAQuery(chartType))
|
|
221
|
+
return [];
|
|
222
|
+
return [
|
|
223
|
+
{
|
|
224
|
+
queryName: '(none)',
|
|
225
|
+
check: { aliases: [], missingRequired: [], missingRecommended: [] },
|
|
226
|
+
queryless: true,
|
|
227
|
+
},
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
const violations = [];
|
|
231
|
+
for (const queryObj of runnable) {
|
|
232
|
+
const check = (0, widget_render_contract_js_1.checkWidgetContract)(chartType, queryObj.query, { queryCount: runnable.length });
|
|
233
|
+
if (check.missingRequired.length > 0) {
|
|
234
|
+
violations.push({ queryName: queryObj.name || 'Unnamed query', check });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return violations;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Advisory notes for widget queries that pass the gate but are shaped oddly for their chart type.
|
|
241
|
+
*
|
|
242
|
+
* EACH query on a `number` widget is documented to return a single `value`, and the field report
|
|
243
|
+
* behind TD-9016 was that extras "can break" it — but nothing has confirmed what the current
|
|
244
|
+
* renderer does with them, so this warns and does not block.
|
|
245
|
+
*
|
|
246
|
+
* The count of queries is not what is being judged. A number widget legitimately carries several —
|
|
247
|
+
* that is how percentage mode divides one query's total by another's — so the note has to say
|
|
248
|
+
* "columns" where it means columns, or it teaches an agent to collapse a correct widget.
|
|
249
|
+
*/
|
|
250
|
+
function widgetAdvisoryNotes(chartType, queries) {
|
|
251
|
+
if (!chartType || !Array.isArray(queries))
|
|
252
|
+
return [];
|
|
253
|
+
const notes = [];
|
|
254
|
+
const runnable = runnableQueries(queries);
|
|
255
|
+
for (const queryObj of runnable) {
|
|
256
|
+
const check = (0, widget_render_contract_js_1.checkWidgetContract)(chartType, queryObj.query, { queryCount: runnable.length });
|
|
257
|
+
const extras = check.extraColumns ?? [];
|
|
258
|
+
if (extras.length > 0) {
|
|
259
|
+
notes.push(`Query "${queryObj.name || 'unnamed'}" returns ${extras
|
|
260
|
+
.map((column) => `\`${column}\``)
|
|
261
|
+
.join(', ')} alongside the column a \`${chartType}\` widget reads. Each query on this ` +
|
|
262
|
+
'type is documented to return exactly one column; extras have been reported to break ' +
|
|
263
|
+
'the render. Drop the extra columns from this query — carrying SEVERAL queries is fine ' +
|
|
264
|
+
'and is how a percentage widget is built, but each one still returns only the column ' +
|
|
265
|
+
'the chart reads.');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return notes;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* `RETURN <expression> AS x, <expression> AS y` — the shape to aim for, when no rewrite is safe.
|
|
272
|
+
*
|
|
273
|
+
* Built from the columns THIS widget needs, not the chart type's unconditional list: a column can be
|
|
274
|
+
* required for one widget and not another (`name` on a single-query pie), and a hint that omits the
|
|
275
|
+
* column the widget was just rejected for advises the shape that was rejected.
|
|
276
|
+
*/
|
|
277
|
+
function shapeHint(chartType, missingRequired) {
|
|
278
|
+
const contracted = widget_render_contract_js_1.WIDGET_COLUMN_CONTRACT[chartType]?.required ?? [];
|
|
279
|
+
const columns = [...new Set([...contracted, ...missingRequired])];
|
|
280
|
+
return `RETURN ${columns.map((column) => `<expression> AS ${column}`).join(', ')}`;
|
|
281
|
+
}
|
|
282
|
+
/** What one rejected query was asked for, what it declares, and the fix. */
|
|
283
|
+
function violationDetail(chartType, violation) {
|
|
284
|
+
const { queryName, check, queryless } = violation;
|
|
285
|
+
if (queryless) {
|
|
286
|
+
return (`A \`${chartType}\` widget draws what its queries return, and this one carries none that ` +
|
|
287
|
+
'hold any J1QL — either an empty `queries` array or entries whose `query` is an empty ' +
|
|
288
|
+
'string. It would be created as a blank tile. `markdown` is the only widget type that ' +
|
|
289
|
+
'renders without a query; every other type needs one in `config.queries`.');
|
|
290
|
+
}
|
|
291
|
+
const declared = check.aliases.map((alias) => alias ?? '(no alias)').join(', ') || '(none)';
|
|
292
|
+
const missing = check.missingRequired.map((column) => `\`${column}\``).join(', ');
|
|
293
|
+
const fix = check.correctedQuery
|
|
294
|
+
? `Use this query instead:\n${check.correctedQuery}`
|
|
295
|
+
: `Alias the columns the chart reads: ${shapeHint(chartType, check.missingRequired)}`;
|
|
296
|
+
return (`Query: ${queryName}\n` +
|
|
297
|
+
`A \`${chartType}\` widget renders ${missing}; this query returns ${declared}, ` +
|
|
298
|
+
`so the widget would draw nothing.\n${fix}`);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Tool result for a widget rejected by the column-contract gate.
|
|
302
|
+
*
|
|
303
|
+
* Recovery stays in-band: the widget was not created, and the response carries a ready-to-run
|
|
304
|
+
* corrected query wherever one could be derived and re-verified — retrying is free and instant.
|
|
305
|
+
*/
|
|
306
|
+
function widgetContractErrorResponse(chartType, violations, operation = 'create') {
|
|
307
|
+
const details = violations.map((violation) => violationDetail(chartType, violation));
|
|
308
|
+
// Naming the operation matters on the update path: telling a caller the widget "was not created"
|
|
309
|
+
// invites it to create one instead of retrying the update, which is how you get a duplicate.
|
|
310
|
+
const outcome = operation === 'update' ? 'Widget not updated' : 'Widget not created';
|
|
311
|
+
const anyCorrected = violations.some(({ check }) => check.correctedQuery);
|
|
312
|
+
// A widget with nothing to draw is a different instruction: there is no alias to rewrite, so
|
|
313
|
+
// telling the caller to fix its aliases would send it looking for a column that has no query.
|
|
314
|
+
const allQueryless = violations.every((violation) => violation.queryless);
|
|
315
|
+
const headline = allQueryless
|
|
316
|
+
? `a \`${chartType}\` widget cannot render without a query`
|
|
317
|
+
: `the ${violations.length > 1 ? 'queries' : 'query'} cannot render in a \`${chartType}\` widget`;
|
|
318
|
+
const closing = allQueryless
|
|
319
|
+
? 'Add the query this widget is meant to draw, confirm it returns rows with ' +
|
|
320
|
+
'execute-j1ql-query, then retry.'
|
|
321
|
+
: anyCorrected
|
|
322
|
+
? 'Run the corrected query through execute-j1ql-query to confirm it returns rows, then retry.'
|
|
323
|
+
: 'Rewrite the query with those aliases, confirm it returns rows with execute-j1ql-query, ' +
|
|
324
|
+
'then retry.';
|
|
325
|
+
return {
|
|
326
|
+
content: [
|
|
327
|
+
{
|
|
328
|
+
type: 'text',
|
|
329
|
+
text: `${outcome} — ${headline}:\n\n${details.join('\n\n')}\n\n${closing}`,
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
// Carried so the telemetry chokepoint can count rejections by chart type and missing column,
|
|
333
|
+
// rather than string-matching the message. Error results are exempt from output-schema
|
|
334
|
+
// validation, so this never reaches a client validator.
|
|
335
|
+
structuredContent: {
|
|
336
|
+
contractOk: false,
|
|
337
|
+
chartType,
|
|
338
|
+
missingRequired: [...new Set(violations.flatMap(({ check }) => check.missingRequired))],
|
|
339
|
+
// A rejection that ships a ready-to-run query and one that only names the shape are different
|
|
340
|
+
// events: the first should be followed by a successful retry, and whether it is is the only
|
|
341
|
+
// measure of whether the corrector is worth its complexity. Undistinguishable in the message.
|
|
342
|
+
correctionOffered: anyCorrected,
|
|
343
|
+
},
|
|
344
|
+
isError: true,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
163
347
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":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YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,YAAY;QAC3B,CAAC,CAAC,OAAO,SAAS,yCAAyC;QAC3D,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,yBAAyB,SAAS,WAAW,CAAC;IACpG,MAAM,OAAO,GAAG,YAAY;QAC1B,CAAC,CAAC,2EAA2E;YAC3E,iCAAiC;QACnC,CAAC,CAAC,YAAY;YACZ,CAAC,CAAC,4FAA4F;YAC9F,CAAC,CAAC,yFAAyF;gBACzF,aAAa,CAAC;IAEpB,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,GAAG,OAAO,MAAM,QAAQ,QAAQ,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,OAAO,EAAE;aAC3E;SACF;QACD,6FAA6F;QAC7F,uFAAuF;QACvF,wDAAwD;QACxD,iBAAiB,EAAE;YACjB,UAAU,EAAE,KAAK;YACjB,SAAS;YACT,eAAe,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;YACvF,8FAA8F;YAC9F,4FAA4F;YAC5F,8FAA8F;YAC9F,iBAAiB,EAAE,YAAY;SAChC;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/server/tools/integrations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/server/tools/integrations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AA8BxE,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAyO5C,CAAC"}
|
|
@@ -8,8 +8,16 @@ const types_js_1 = require("./types.js");
|
|
|
8
8
|
// Items vary by integration provider, so rows stay open records; the top-level + pageInfo are
|
|
9
9
|
// documented. Permissive enough to never false-reject real data.
|
|
10
10
|
const pageInfo = zod_1.z.any().optional();
|
|
11
|
-
const definitionsOutput = {
|
|
12
|
-
|
|
11
|
+
const definitionsOutput = {
|
|
12
|
+
total: zod_1.z.number(),
|
|
13
|
+
definitions: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())),
|
|
14
|
+
pageInfo,
|
|
15
|
+
};
|
|
16
|
+
const instancesOutput = {
|
|
17
|
+
total: zod_1.z.number(),
|
|
18
|
+
instances: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())),
|
|
19
|
+
pageInfo,
|
|
20
|
+
};
|
|
13
21
|
const jobsOutput = { total: zod_1.z.number(), jobs: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())), pageInfo };
|
|
14
22
|
const eventsOutput = { events: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())), pageInfo };
|
|
15
23
|
const jobOutput = {
|
|
@@ -130,7 +138,10 @@ exports.integrationTools = [
|
|
|
130
138
|
.enum(['PENDING', 'RUNNING', 'COMPLETED', 'FAILED', 'CANCELLED'])
|
|
131
139
|
.optional()
|
|
132
140
|
.describe('Optional status to filter jobs'),
|
|
133
|
-
integrationInstanceId: zod_1.z
|
|
141
|
+
integrationInstanceId: zod_1.z
|
|
142
|
+
.string()
|
|
143
|
+
.optional()
|
|
144
|
+
.describe('Optional ID to filter jobs by instance'),
|
|
134
145
|
integrationDefinitionId: zod_1.z
|
|
135
146
|
.string()
|
|
136
147
|
.optional()
|
|
@@ -153,7 +164,7 @@ exports.integrationTools = [
|
|
|
153
164
|
outputSchema: jobsOutput,
|
|
154
165
|
annotations: types_js_1.READ_ONLY,
|
|
155
166
|
errorContext: 'Error getting integration jobs',
|
|
156
|
-
handler: async ({ status, integrationInstanceId, integrationDefinitionId, integrationInstanceIds, size, cursor }, client) => {
|
|
167
|
+
handler: async ({ status, integrationInstanceId, integrationDefinitionId, integrationInstanceIds, size, cursor, }, client) => {
|
|
157
168
|
const jobs = await client.getIntegrationJobs(status, integrationInstanceId, integrationDefinitionId, integrationInstanceIds, cursor, size);
|
|
158
169
|
return (0, result_js_1.structuredResult)({
|
|
159
170
|
total: jobs.jobs.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/tools/integrations.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,yEAAkE;AAClE,2CAA+C;AAC/C,yCAAwE;AAExE,8FAA8F;AAC9F,iEAAiE;AACjE,MAAM,QAAQ,GAAG,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AACpC,MAAM,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/tools/integrations.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,yEAAkE;AAClE,2CAA+C;AAC/C,yCAAwE;AAExE,8FAA8F;AAC9F,iEAAiE;AACjE,MAAM,QAAQ,GAAG,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AACpC,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,QAAQ;CACT,CAAC;AACF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,OAAC,CAAC,MA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AAE,KAAK,CAAC,EAAE;oBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B,CAAC,CAAC;gBACH,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B,CAAC,CAAC;QACL,CAAC;KACF,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"j1ql.d.ts","sourceRoot":"","sources":["../../../src/server/tools/j1ql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"j1ql.d.ts","sourceRoot":"","sources":["../../../src/server/tools/j1ql.ts"],"names":[],"mappings":"AAYA,OAAO,EAAyB,KAAK,cAAc,EAAmB,MAAM,YAAY,CAAC;AA0SzF,eAAO,MAAM,SAAS,EAAE,cAAc,EAkJrC,CAAC"}
|
|
@@ -7,6 +7,7 @@ const j1ql_service_js_1 = require("../../client/services/j1ql-service.js");
|
|
|
7
7
|
const j1ql_validator_js_1 = require("../../utils/j1ql-validator.js");
|
|
8
8
|
const load_description_js_1 = require("../../utils/load-description.js");
|
|
9
9
|
const errors_js_1 = require("./errors.js");
|
|
10
|
+
const value_probe_js_1 = require("./value-probe.js");
|
|
10
11
|
const result_js_1 = require("./result.js");
|
|
11
12
|
const types_js_1 = require("./types.js");
|
|
12
13
|
// J1QL tools return one of two envelopes, typed as a JSON Schema 2020-12 union (SEP-2106):
|
|
@@ -40,6 +41,13 @@ const executeJ1qlOutput = (0, server_1.fromJsonSchema)({
|
|
|
40
41
|
},
|
|
41
42
|
cursor: { type: ['string', 'null'] },
|
|
42
43
|
hasMore: { type: 'boolean' },
|
|
44
|
+
emptyResultDiagnosis: {
|
|
45
|
+
type: 'array',
|
|
46
|
+
description: 'Why this result is empty, when the server could establish it — e.g. a filter on a ' +
|
|
47
|
+
'value stored under a different casing. Absent when the result is non-empty or ' +
|
|
48
|
+
'nothing could be established.',
|
|
49
|
+
items: { type: 'object' },
|
|
50
|
+
},
|
|
43
51
|
messages: { type: 'array' },
|
|
44
52
|
},
|
|
45
53
|
},
|
|
@@ -122,6 +130,19 @@ function livenessNote(elapsedMs) {
|
|
|
122
130
|
* handle ~35s sooner than the previous full-window wait.
|
|
123
131
|
*/
|
|
124
132
|
const FIRST_RESPONSE_MAX_POLL_ATTEMPTS = 10;
|
|
133
|
+
/**
|
|
134
|
+
* Wall-clock ceiling for the whole execute-j1ql-query call, anchored at request start, past which
|
|
135
|
+
* no advisory probe is admitted.
|
|
136
|
+
*
|
|
137
|
+
* The result is already in hand when the diagnosis runs, so every second it takes is spent on a
|
|
138
|
+
* request that has already succeeded — and the remote host abandons the response at ~55s. The
|
|
139
|
+
* arithmetic that has to hold is the worst case: a deadline check passes at 40s−ε, the probe it
|
|
140
|
+
* admits polls PROBE_POLL_ATTEMPTS (6) more seconds, and every later literal is refused at its own
|
|
141
|
+
* check, so the response lands by ~46s. Anchoring is the whole point: an unanchored budget starts
|
|
142
|
+
* counting after the query, and a slow-but-empty query plus a full diagnosis reaches ~70s, at
|
|
143
|
+
* which point the agent sees a failure for a query that worked and loses the result it was given.
|
|
144
|
+
*/
|
|
145
|
+
const REQUEST_BUDGET_MS = 40_000;
|
|
125
146
|
/**
|
|
126
147
|
* Non-error envelope returned when the first-response budget expires while the backend is still
|
|
127
148
|
* executing (it runs to completion regardless — typically within ~4 minutes — and retains results
|
|
@@ -134,7 +155,9 @@ function queryStillRunningResult(error) {
|
|
|
134
155
|
const startedAtMs = error.startedAt ?? handleStartedAtMs(error.resultsUrl);
|
|
135
156
|
// Clamped at 0: the handle's timestamp is unverified and clocks can skew, so a future
|
|
136
157
|
// startedAt must not produce negative elapsed values in the liveness text or envelope.
|
|
137
|
-
const elapsedMs = startedAtMs === null || startedAtMs === undefined
|
|
158
|
+
const elapsedMs = startedAtMs === null || startedAtMs === undefined
|
|
159
|
+
? null
|
|
160
|
+
: Math.max(0, Date.now() - startedAtMs);
|
|
138
161
|
const liveness = livenessNote(elapsedMs);
|
|
139
162
|
const output = (0, result_js_1.structuredResult)({
|
|
140
163
|
status: 'IN_PROGRESS',
|
|
@@ -174,17 +197,48 @@ function buildJ1qlQueryArgs({ query, variables, cursor, includeDeleted, flags, s
|
|
|
174
197
|
flags: Object.keys(queryFlags).length > 0 ? queryFlags : undefined,
|
|
175
198
|
};
|
|
176
199
|
}
|
|
200
|
+
/** Whether a completed envelope carries no rows at all. */
|
|
201
|
+
function isEmptyResult(result) {
|
|
202
|
+
const data = result?.data;
|
|
203
|
+
if (Array.isArray(data))
|
|
204
|
+
return data.length === 0;
|
|
205
|
+
return data === null || data === undefined;
|
|
206
|
+
}
|
|
207
|
+
/** Appended to an empty result that the value probes could explain. */
|
|
208
|
+
function diagnosisNote(diagnosis) {
|
|
209
|
+
const lines = diagnosis
|
|
210
|
+
.filter((entry) => entry.verdict !== 'literal-ok' && entry.note)
|
|
211
|
+
.map((entry) => `- ${entry.note}${entry.correctedQuery ? `\n ${entry.correctedQuery}` : ''}`);
|
|
212
|
+
if (lines.length === 0)
|
|
213
|
+
return '';
|
|
214
|
+
return (`\nThis result is empty for a reason the server could check:\n${lines.join('\n')}\n\n` +
|
|
215
|
+
'Stored value casing varies by integration and changes between syncs. Before filtering on a ' +
|
|
216
|
+
'string literal, check what is stored with:\n' +
|
|
217
|
+
'FIND <type> AS e RETURN e.<property> AS value, count(e) AS n ORDER BY n DESC LIMIT 250');
|
|
218
|
+
}
|
|
177
219
|
/**
|
|
178
220
|
* Standard success envelope for a query result: surfaces `hasMore` (the backend signals more
|
|
179
221
|
* pages by returning a cursor) and, when true, appends the cursor-paging note as a separate text
|
|
180
222
|
* block so content[0] stays pure payload JSON. Shared by execute-j1ql-query and get-query-results.
|
|
223
|
+
*
|
|
224
|
+
* The diagnosis is its own parameter rather than an `extras` key: it is renamed on the way out
|
|
225
|
+
* (`emptyResultDiagnosis`) and drives a second text block, so it is not an extra field at all.
|
|
181
226
|
*/
|
|
182
|
-
function formatQueryResult(result, extras = {}) {
|
|
227
|
+
function formatQueryResult(result, extras = {}, diagnosis = []) {
|
|
183
228
|
const hasMore = typeof result.cursor === 'string' && result.cursor.length > 0;
|
|
184
|
-
const output = (0, result_js_1.structuredResult)({
|
|
229
|
+
const output = (0, result_js_1.structuredResult)({
|
|
230
|
+
...result,
|
|
231
|
+
...extras,
|
|
232
|
+
...(diagnosis.length > 0 ? { emptyResultDiagnosis: diagnosis } : {}),
|
|
233
|
+
hasMore,
|
|
234
|
+
});
|
|
185
235
|
if (hasMore) {
|
|
186
236
|
output.content.push({ type: 'text', text: PAGINATION_NOTE });
|
|
187
237
|
}
|
|
238
|
+
const explanation = diagnosisNote(diagnosis);
|
|
239
|
+
if (explanation) {
|
|
240
|
+
output.content.push({ type: 'text', text: explanation });
|
|
241
|
+
}
|
|
188
242
|
return output;
|
|
189
243
|
}
|
|
190
244
|
// The handle URL is fetched server-side, so an agent-supplied value is an SSRF vector (e.g. the
|
|
@@ -244,6 +298,7 @@ exports.j1qlTools = [
|
|
|
244
298
|
errorContext: 'Error executing J1QL query',
|
|
245
299
|
formatError: (error, { query }, validator) => (0, errors_js_1.createQueryErrorResponse)(error, query, validator),
|
|
246
300
|
handler: async (params, client, validator) => {
|
|
301
|
+
const startedAt = Date.now();
|
|
247
302
|
// Static parse gate: syntax errors fail here in milliseconds, with the same parser (and
|
|
248
303
|
// message) the backend would use, instead of costing a query-service round-trip. Thrown
|
|
249
304
|
// (not returned) so the rejection carries errorClass/errorMessage through the telemetry
|
|
@@ -270,7 +325,20 @@ exports.j1qlTools = [
|
|
|
270
325
|
}
|
|
271
326
|
const accountInfo = await client.getAccountInfo();
|
|
272
327
|
const queryUrl = client.j1qlService.constructQueryUrl(params.query, accountInfo.subdomain);
|
|
273
|
-
|
|
328
|
+
// An empty result is the moment the agent decides what a zero means, and the moment it is
|
|
329
|
+
// most likely to guess wrong: a filter on the wrong casing of a stored value succeeds and
|
|
330
|
+
// returns nothing, indistinguishable from an honest absence. Diagnose it here, before the
|
|
331
|
+
// zero is built into a widget or a rule. Probed only when the result is actually empty, so
|
|
332
|
+
// ordinary queries pay nothing.
|
|
333
|
+
const diagnosis = isEmptyResult(result)
|
|
334
|
+
? await (0, value_probe_js_1.diagnoseQueryLiterals)(client, params.query, {
|
|
335
|
+
maxProbes: 3,
|
|
336
|
+
// Whichever expires first: the diagnosis never runs longer than its own budget, and
|
|
337
|
+
// never runs at all once the query has spent the request's.
|
|
338
|
+
deadlineAt: Math.min(startedAt + REQUEST_BUDGET_MS, Date.now() + value_probe_js_1.DIAGNOSIS_BUDGET_MS),
|
|
339
|
+
})
|
|
340
|
+
: [];
|
|
341
|
+
return formatQueryResult(result, { url: queryUrl }, diagnosis);
|
|
274
342
|
},
|
|
275
343
|
}),
|
|
276
344
|
(0, types_js_1.defineTool)({
|