@jupiterone/jupiterone-mcp 2.7.0 → 2.9.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.
Files changed (143) hide show
  1. package/README.md +26 -10
  2. package/dist/client/graphql/mutations.d.ts +6 -0
  3. package/dist/client/graphql/mutations.d.ts.map +1 -1
  4. package/dist/client/graphql/mutations.js +37 -1
  5. package/dist/client/graphql/mutations.js.map +1 -1
  6. package/dist/client/graphql/queries.d.ts +16 -1
  7. package/dist/client/graphql/queries.d.ts.map +1 -1
  8. package/dist/client/graphql/queries.js +62 -1
  9. package/dist/client/graphql/queries.js.map +1 -1
  10. package/dist/client/jupiterone-client.d.ts +7 -0
  11. package/dist/client/jupiterone-client.d.ts.map +1 -1
  12. package/dist/client/jupiterone-client.js +19 -0
  13. package/dist/client/jupiterone-client.js.map +1 -1
  14. package/dist/client/services/criticality-service.d.ts +16 -0
  15. package/dist/client/services/criticality-service.d.ts.map +1 -0
  16. package/dist/client/services/criticality-service.js +72 -0
  17. package/dist/client/services/criticality-service.js.map +1 -0
  18. package/dist/client/services/rule-service.d.ts +11 -1
  19. package/dist/client/services/rule-service.d.ts.map +1 -1
  20. package/dist/client/services/rule-service.js +17 -0
  21. package/dist/client/services/rule-service.js.map +1 -1
  22. package/dist/generated/description-map.d.ts.map +1 -1
  23. package/dist/generated/description-map.js +428 -39
  24. package/dist/generated/description-map.js.map +1 -1
  25. package/dist/server/mcp-server.d.ts +10 -0
  26. package/dist/server/mcp-server.d.ts.map +1 -1
  27. package/dist/server/mcp-server.js +64 -1
  28. package/dist/server/mcp-server.js.map +1 -1
  29. package/dist/server/tools/compliance/attestations.d.ts.map +1 -1
  30. package/dist/server/tools/compliance/attestations.js +11 -10
  31. package/dist/server/tools/compliance/attestations.js.map +1 -1
  32. package/dist/server/tools/compliance/authoring.d.ts.map +1 -1
  33. package/dist/server/tools/compliance/authoring.js +36 -35
  34. package/dist/server/tools/compliance/authoring.js.map +1 -1
  35. package/dist/server/tools/compliance/controls.d.ts.map +1 -1
  36. package/dist/server/tools/compliance/controls.js +12 -11
  37. package/dist/server/tools/compliance/controls.js.map +1 -1
  38. package/dist/server/tools/compliance/exemptions.d.ts.map +1 -1
  39. package/dist/server/tools/compliance/exemptions.js +16 -15
  40. package/dist/server/tools/compliance/exemptions.js.map +1 -1
  41. package/dist/server/tools/compliance/framework.d.ts.map +1 -1
  42. package/dist/server/tools/compliance/framework.js +24 -23
  43. package/dist/server/tools/compliance/framework.js.map +1 -1
  44. package/dist/server/tools/compliance/graph.js +1 -1
  45. package/dist/server/tools/compliance/graph.js.map +1 -1
  46. package/dist/server/tools/compliance/requirements.d.ts.map +1 -1
  47. package/dist/server/tools/compliance/requirements.js +11 -10
  48. package/dist/server/tools/compliance/requirements.js.map +1 -1
  49. package/dist/server/tools/compliance/shared.d.ts +4 -32
  50. package/dist/server/tools/compliance/shared.d.ts.map +1 -1
  51. package/dist/server/tools/compliance/shared.js +11 -76
  52. package/dist/server/tools/compliance/shared.js.map +1 -1
  53. package/dist/server/tools/compliance/summary.d.ts.map +1 -1
  54. package/dist/server/tools/compliance/summary.js +16 -15
  55. package/dist/server/tools/compliance/summary.js.map +1 -1
  56. package/dist/server/tools/compliance/tests.d.ts.map +1 -1
  57. package/dist/server/tools/compliance/tests.js +26 -25
  58. package/dist/server/tools/compliance/tests.js.map +1 -1
  59. package/dist/server/tools/compliance/transitions.d.ts.map +1 -1
  60. package/dist/server/tools/compliance/transitions.js +15 -14
  61. package/dist/server/tools/compliance/transitions.js.map +1 -1
  62. package/dist/server/tools/criticality/context.d.ts +48 -0
  63. package/dist/server/tools/criticality/context.d.ts.map +1 -0
  64. package/dist/server/tools/criticality/context.js +90 -0
  65. package/dist/server/tools/criticality/context.js.map +1 -0
  66. package/dist/server/tools/criticality/index.d.ts +11 -0
  67. package/dist/server/tools/criticality/index.d.ts.map +1 -0
  68. package/dist/server/tools/criticality/index.js +15 -0
  69. package/dist/server/tools/criticality/index.js.map +1 -0
  70. package/dist/server/tools/criticality/ladder-delta.d.ts +86 -0
  71. package/dist/server/tools/criticality/ladder-delta.d.ts.map +1 -0
  72. package/dist/server/tools/criticality/ladder-delta.js +475 -0
  73. package/dist/server/tools/criticality/ladder-delta.js.map +1 -0
  74. package/dist/server/tools/criticality/levels-read.d.ts +43 -0
  75. package/dist/server/tools/criticality/levels-read.d.ts.map +1 -0
  76. package/dist/server/tools/criticality/levels-read.js +101 -0
  77. package/dist/server/tools/criticality/levels-read.js.map +1 -0
  78. package/dist/server/tools/criticality/read.d.ts +13 -0
  79. package/dist/server/tools/criticality/read.d.ts.map +1 -0
  80. package/dist/server/tools/criticality/read.js +214 -0
  81. package/dist/server/tools/criticality/read.js.map +1 -0
  82. package/dist/server/tools/criticality/resource.d.ts +35 -0
  83. package/dist/server/tools/criticality/resource.d.ts.map +1 -0
  84. package/dist/server/tools/criticality/resource.js +84 -0
  85. package/dist/server/tools/criticality/resource.js.map +1 -0
  86. package/dist/server/tools/criticality/schemas.d.ts +114 -0
  87. package/dist/server/tools/criticality/schemas.d.ts.map +1 -0
  88. package/dist/server/tools/criticality/schemas.js +99 -0
  89. package/dist/server/tools/criticality/schemas.js.map +1 -0
  90. package/dist/server/tools/criticality/update.d.ts +5 -0
  91. package/dist/server/tools/criticality/update.d.ts.map +1 -0
  92. package/dist/server/tools/criticality/update.js +243 -0
  93. package/dist/server/tools/criticality/update.js.map +1 -0
  94. package/dist/server/tools/index.d.ts.map +1 -1
  95. package/dist/server/tools/index.js +2 -0
  96. package/dist/server/tools/index.js.map +1 -1
  97. package/dist/server/tools/j1ql.d.ts.map +1 -1
  98. package/dist/server/tools/j1ql.js +69 -18
  99. package/dist/server/tools/j1ql.js.map +1 -1
  100. package/dist/server/tools/reference.d.ts +1 -1
  101. package/dist/server/tools/reference.d.ts.map +1 -1
  102. package/dist/server/tools/reference.js +2 -0
  103. package/dist/server/tools/reference.js.map +1 -1
  104. package/dist/server/tools/rule-preview-checks.d.ts +95 -0
  105. package/dist/server/tools/rule-preview-checks.d.ts.map +1 -0
  106. package/dist/server/tools/rule-preview-checks.js +380 -0
  107. package/dist/server/tools/rule-preview-checks.js.map +1 -0
  108. package/dist/server/tools/rule-preview.d.ts +98 -0
  109. package/dist/server/tools/rule-preview.d.ts.map +1 -0
  110. package/dist/server/tools/rule-preview.js +490 -0
  111. package/dist/server/tools/rule-preview.js.map +1 -0
  112. package/dist/server/tools/rules.d.ts +1 -1
  113. package/dist/server/tools/rules.d.ts.map +1 -1
  114. package/dist/server/tools/rules.js +245 -30
  115. package/dist/server/tools/rules.js.map +1 -1
  116. package/dist/server/tools/shared.d.ts +44 -0
  117. package/dist/server/tools/shared.d.ts.map +1 -0
  118. package/dist/server/tools/shared.js +95 -0
  119. package/dist/server/tools/shared.js.map +1 -0
  120. package/dist/server/tools/usage.d.ts +8 -1
  121. package/dist/server/tools/usage.d.ts.map +1 -1
  122. package/dist/server/tools/usage.js +170 -2
  123. package/dist/server/tools/usage.js.map +1 -1
  124. package/dist/server/tools/value-probe.d.ts +12 -1
  125. package/dist/server/tools/value-probe.d.ts.map +1 -1
  126. package/dist/server/tools/value-probe.js +39 -13
  127. package/dist/server/tools/value-probe.js.map +1 -1
  128. package/dist/types/jupiterone.d.ts +123 -5
  129. package/dist/types/jupiterone.d.ts.map +1 -1
  130. package/dist/utils/criticality-query.d.ts +97 -0
  131. package/dist/utils/criticality-query.d.ts.map +1 -0
  132. package/dist/utils/criticality-query.js +319 -0
  133. package/dist/utils/criticality-query.js.map +1 -0
  134. package/dist/utils/j1ql-filters.d.ts +3 -1
  135. package/dist/utils/j1ql-filters.d.ts.map +1 -1
  136. package/dist/utils/j1ql-filters.js +19 -7
  137. package/dist/utils/j1ql-filters.js.map +1 -1
  138. package/dist/utils/j1ql-validator.d.ts +2 -0
  139. package/dist/utils/j1ql-validator.d.ts.map +1 -1
  140. package/dist/utils/j1ql-validator.js +9 -2
  141. package/dist/utils/j1ql-validator.js.map +1 -1
  142. package/node_modules/dtrace-provider/build/Makefile +1 -1
  143. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ import type { JupiterOneClient } from '../../../client/jupiterone-client.js';
2
+ import type { CriticalityLevel } from '../../../types/jupiterone.js';
3
+ import { type CriticalityRef } from '../../../utils/criticality-query.js';
4
+ import type { ToolResult } from '../types.js';
5
+ import { type LiteralDiagnosis } from '../value-probe.js';
6
+ import { type CriticalityContext } from './context.js';
7
+ /**
8
+ * The account's levels read beside another call, so tools that are not about criticality can still
9
+ * carry it: get-graph-context, a J1QL query that reads criticality, and the resource.
10
+ *
11
+ * The read needs only graph read and is fast (query-engine, 7 days to 2026-10-31: prod-us p50
12
+ * 11 ms, p95 55 ms over 445 reads; prod-eu max 154 ms). Its one slow episode was a burst of reads
13
+ * on prod-us answered after 8.6-17.8 minutes (2026-10-28 14:18 UTC), so it is bounded: past the
14
+ * budget the block reads `unavailable`, and the call it rides on never waits longer.
15
+ */
16
+ export declare const LEVELS_READ_BUDGET_MS = 1500;
17
+ export interface LevelsRead {
18
+ /** Undefined when the read failed or missed its budget. */
19
+ levels?: CriticalityLevel[];
20
+ readMs?: number;
21
+ }
22
+ /**
23
+ * Start the read now; settle it later by a deadline anchored to the caller's request start.
24
+ *
25
+ * The budget bounds how long the call waits for the levels, not how long the read may take. A
26
+ * read that finished while a slower primary call ran is used even past the budget, because it
27
+ * cost no wait; the deferred J1QL handle relies on this. `readMs` is the read's own time, so
28
+ * telemetry still shows a read slower than the budget (PR #62 review).
29
+ */
30
+ export declare function startLevelsRead(client: JupiterOneClient): (deadlineAt: number) => Promise<LevelsRead>;
31
+ export declare function criticalityBlock(read: LevelsRead, ref?: CriticalityRef): CriticalityContext | 'unavailable';
32
+ /** Records the read on the result's `_meta` for telemetry; the model never needs it. */
33
+ export declare function withCriticalityMeta(result: ToolResult, read: LevelsRead, slugCorrected?: boolean): ToolResult;
34
+ /**
35
+ * An empty result filtering `j1.criticality` on a value that is not one of the account's levels:
36
+ * `'critical'` where the levels are `crown-jewels`, `high-value`, … Answered from the levels, not a
37
+ * probe; the corrected query is offered only when the value plainly names one level (its name, or
38
+ * what its name reduces to). The levels do not prove the value is on no asset: assets keep a
39
+ * renamed or removed level's value until a run applies the change (26 minutes for one run on j1dev,
40
+ * 2026-11-02), so the count is unknown and the note says why (PR #62 review).
41
+ */
42
+ export declare function diagnoseCriticalityLiterals(query: string, levels: CriticalityLevel[]): LiteralDiagnosis[];
43
+ //# sourceMappingURL=levels-read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"levels-read.d.ts","sourceRoot":"","sources":["../../../../src/server/tools/criticality/levels-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE3E;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,GACvB,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAkB7C;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,GAAG,CAAC,EAAE,cAAc,GACnB,kBAAkB,GAAG,aAAa,CAEpC;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAChB,aAAa,CAAC,EAAE,OAAO,GACtB,UAAU,CAYZ;AAID;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,gBAAgB,EAAE,GACzB,gBAAgB,EAAE,CAgCpB"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LEVELS_READ_BUDGET_MS = void 0;
4
+ exports.startLevelsRead = startLevelsRead;
5
+ exports.criticalityBlock = criticalityBlock;
6
+ exports.withCriticalityMeta = withCriticalityMeta;
7
+ exports.diagnoseCriticalityLiterals = diagnoseCriticalityLiterals;
8
+ const criticality_query_js_1 = require("../../../utils/criticality-query.js");
9
+ const j1ql_filters_js_1 = require("../../../utils/j1ql-filters.js");
10
+ const shared_js_1 = require("../shared.js");
11
+ const usage_js_1 = require("../usage.js");
12
+ const value_probe_js_1 = require("../value-probe.js");
13
+ const context_js_1 = require("./context.js");
14
+ /**
15
+ * The account's levels read beside another call, so tools that are not about criticality can still
16
+ * carry it: get-graph-context, a J1QL query that reads criticality, and the resource.
17
+ *
18
+ * The read needs only graph read and is fast (query-engine, 7 days to 2026-10-31: prod-us p50
19
+ * 11 ms, p95 55 ms over 445 reads; prod-eu max 154 ms). Its one slow episode was a burst of reads
20
+ * on prod-us answered after 8.6-17.8 minutes (2026-10-28 14:18 UTC), so it is bounded: past the
21
+ * budget the block reads `unavailable`, and the call it rides on never waits longer.
22
+ */
23
+ exports.LEVELS_READ_BUDGET_MS = 1_500;
24
+ /**
25
+ * Start the read now; settle it later by a deadline anchored to the caller's request start.
26
+ *
27
+ * The budget bounds how long the call waits for the levels, not how long the read may take. A
28
+ * read that finished while a slower primary call ran is used even past the budget, because it
29
+ * cost no wait; the deferred J1QL handle relies on this. `readMs` is the read's own time, so
30
+ * telemetry still shows a read slower than the budget (PR #62 review).
31
+ */
32
+ function startLevelsRead(client) {
33
+ const startedAt = Date.now();
34
+ let readMs;
35
+ // Through a resolved promise, so even a synchronous throw degrades to `unavailable` rather than
36
+ // failing the call this read rides on.
37
+ const pending = Promise.resolve()
38
+ .then(() => client.getCriticalityLevels())
39
+ .then((levels) => {
40
+ readMs = Date.now() - startedAt;
41
+ return levels;
42
+ }, () => undefined);
43
+ return async (deadlineAt) => {
44
+ const settled = await (0, shared_js_1.withDeadline)(pending, deadlineAt);
45
+ return { levels: settled === shared_js_1.DEADLINE_PASSED ? undefined : settled, readMs };
46
+ };
47
+ }
48
+ function criticalityBlock(read, ref) {
49
+ return read.levels ? (0, context_js_1.criticalityContext)(read.levels, ref) : 'unavailable';
50
+ }
51
+ /** Records the read on the result's `_meta` for telemetry; the model never needs it. */
52
+ function withCriticalityMeta(result, read, slugCorrected) {
53
+ return {
54
+ ...result,
55
+ _meta: {
56
+ ...result._meta,
57
+ [usage_js_1.CRITICALITY_META_KEY]: {
58
+ levels: read.levels ? read.levels.length : -1,
59
+ ...(read.readMs !== undefined ? { readMs: read.readMs } : {}),
60
+ ...(slugCorrected !== undefined ? { slugCorrected } : {}),
61
+ },
62
+ },
63
+ };
64
+ }
65
+ const fold = (text) => text.trim().toLowerCase();
66
+ /**
67
+ * An empty result filtering `j1.criticality` on a value that is not one of the account's levels:
68
+ * `'critical'` where the levels are `crown-jewels`, `high-value`, … Answered from the levels, not a
69
+ * probe; the corrected query is offered only when the value plainly names one level (its name, or
70
+ * what its name reduces to). The levels do not prove the value is on no asset: assets keep a
71
+ * renamed or removed level's value until a run applies the change (26 minutes for one run on j1dev,
72
+ * 2026-11-02), so the count is unknown and the note says why (PR #62 review).
73
+ */
74
+ function diagnoseCriticalityLiterals(query, levels) {
75
+ if (levels.length === 0)
76
+ return [];
77
+ const slugs = new Set(levels.map((level) => level.slug));
78
+ const listed = levels
79
+ .map((level) => `'${level.slug}' (${(0, criticality_query_js_1.levelDisplayName)(level)}, rank ${level.normalized})`)
80
+ .join(', ');
81
+ return (0, j1ql_filters_js_1.extractStringEqualityFilters)(query, { includeWildcard: true })
82
+ .filter((filter) => filter.field === 'j1.criticality' && filter.operator === '=' && !slugs.has(filter.literal))
83
+ .map((filter) => {
84
+ const meant = levels.find((level) => level.slug === (0, criticality_query_js_1.slugifyLevelName)(filter.literal) ||
85
+ fold((0, criticality_query_js_1.levelDisplayName)(level)) === fold(filter.literal));
86
+ const correctedQuery = meant
87
+ ? ((0, value_probe_js_1.rewriteLiteral)(query, filter, `'${meant.slug}'`) ?? undefined)
88
+ : undefined;
89
+ return {
90
+ ...filter,
91
+ verdict: 'value-not-found',
92
+ exactCount: null,
93
+ correctedQuery,
94
+ note: `'${filter.literal}' is not one of this account's asset criticality levels; the levels ` +
95
+ `are ${listed}. A level renamed or removed since the last run leaves its old value on its ` +
96
+ 'assets until the next run applies the change.' +
97
+ (correctedQuery ? ` '${filter.literal}' names '${meant.slug}':` : ''),
98
+ };
99
+ });
100
+ }
101
+ //# sourceMappingURL=levels-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"levels-read.js","sourceRoot":"","sources":["../../../../src/server/tools/criticality/levels-read.ts"],"names":[],"mappings":";;;AAuCA,0CAoBC;AAED,4CAKC;AAGD,kDAgBC;AAYD,kEAmCC;AAlID,8EAI6C;AAC7C,oEAA8E;AAC9E,4CAA6D;AAE7D,0CAAmD;AACnD,sDAA0E;AAC1E,6CAA2E;AAE3E;;;;;;;;GAQG;AACU,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAQ3C;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC7B,MAAwB;IAExB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,MAA0B,CAAC;IAC/B,gGAAgG;IAChG,uCAAuC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE;SAC9B,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;SACzC,IAAI,CACH,CAAC,MAAM,EAAE,E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AAI,SAAS,CAAC;YACjE,CAAC,CAAC,SAAS,CAAC;QACd,OAAO;YACL,GAAG,MAAM;YACT,OAAO,EAAE,iBAA0B;YACnC,UAAU,EAAE,IAAI;YAChB,cAAc;YACd,IAAI,EACF,IAAI,MAAM,CAAC,OAAO,sEAAsE;gBACxF,OAAO,MAAM,8EAA8E;gBAC3F,+CAA+C;gBAC/C,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,YAAY,KAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;SACzE,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * How long every read may run, from request start: the ladder, the run history, the asset counts
3
+ * and the account subdomain. The ladder is the answer, so missing it is `read_failed`; each of the
4
+ * others degrades on its own. query-engine answers the ladder in milliseconds (prod-us p95 55 ms),
5
+ * but on dev 2026-10-31 a Neo4j cluster with no write server held it past the remote's 55 s abort,
6
+ * which reached the agent as advice to narrow a J1QL query.
7
+ */
8
+ export declare const READ_DEADLINE_MS = 20000;
9
+ export declare const ACCESS_DENIED_HINT: string;
10
+ export declare const readCriticalityTool: import("../types.js").ToolDefinition<Readonly<{
11
+ [k: string]: import("zod/v4/core").$ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
12
+ }>>;
13
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../src/server/tools/criticality/read.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAMvC,eAAO,MAAM,kBAAkB,QAG4C,CAAC;AAoL5E,eAAO,MAAM,mBAAmB;;GAiD9B,CAAC"}
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCriticalityTool = exports.ACCESS_DENIED_HINT = exports.READ_DEADLINE_MS = void 0;
4
+ const j1ql_service_js_1 = require("../../../client/services/j1ql-service.js");
5
+ const appUrl_js_1 = require("../../../utils/appUrl.js");
6
+ const criticality_query_js_1 = require("../../../utils/criticality-query.js");
7
+ const load_description_js_1 = require("../../../utils/load-description.js");
8
+ const result_js_1 = require("../result.js");
9
+ const errors_js_1 = require("../errors.js");
10
+ const shared_js_1 = require("../shared.js");
11
+ const types_js_1 = require("../types.js");
12
+ const context_js_1 = require("./context.js");
13
+ const schemas_js_1 = require("./schemas.js");
14
+ /**
15
+ * How long every read may run, from request start: the ladder, the run history, the asset counts
16
+ * and the account subdomain. The ladder is the answer, so missing it is `read_failed`; each of the
17
+ * others degrades on its own. query-engine answers the ladder in milliseconds (prod-us p95 55 ms),
18
+ * but on dev 2026-10-31 a Neo4j cluster with no write server held it past the remote's 55 s abort,
19
+ * which reached the agent as advice to narrow a J1QL query.
20
+ */
21
+ exports.READ_DEADLINE_MS = 20_000;
22
+ /** The latest runs the read reports; the history holds up to 500. */
23
+ const RUN_LIMIT = 5;
24
+ /** Poll budget for the asset-count query, in seconds, inside the read deadline. */
25
+ const COUNT_POLL_ATTEMPTS = 15;
26
+ exports.ACCESS_DENIED_HINT = 'Reading the asset criticality config needs Assets: Admin, Vulnerabilities: Admin or full ' +
27
+ 'admin; changing it needs Assets: Admin (with Shared: Graph Data: Read) or full admin. The ' +
28
+ 'levels themselves need only graph read: get-graph-context returns them.';
29
+ /**
30
+ * The run history is context beside the config, so no failure of it fails the read: dev's history
31
+ * endpoint answered 500 in bursts on 2026-10-28 and 2026-10-31 while the config read worked.
32
+ */
33
+ async function runHistory(client, deadlineAt) {
34
+ const read = client
35
+ .getCriticalityRunHistory(RUN_LIMIT)
36
+ .catch((error) => ((0, errors_js_1.accessDeniedStatus)(error) !== null ? 'unavailable' : 'failed'));
37
+ const settled = await (0, shared_js_1.withDeadline)(read, deadlineAt);
38
+ return settled === shared_js_1.DEADLINE_PASSED ? 'failed' : settled;
39
+ }
40
+ /**
41
+ * The grouped rows as a map. A level holding no assets has no row, so a level missing from the
42
+ * map counts 0; for that to hold, a response with no rows array or a row of another shape is an
43
+ * error, never a map missing levels (PR #62 review).
44
+ */
45
+ function countsByLevel(result) {
46
+ if (!Array.isArray(result?.data)) {
47
+ throw new Error('Invalid response structure from JupiterOne API: the asset count has no rows');
48
+ }
49
+ const counts = new Map();
50
+ for (const row of result.data) {
51
+ if (typeof row?.level !== 'string' || typeof row.total !== 'number') {
52
+ throw new Error('Invalid response structure from JupiterOne API: an asset count row has no level or total');
53
+ }
54
+ counts.set(row.level, row.total);
55
+ }
56
+ return counts;
57
+ }
58
+ /**
59
+ * Assets per level, from the value written on each asset; one grouped read, as the app does.
60
+ * Uncached: query-service answers an identical query from a 5-minute cache, so a read soon after a
61
+ * run completed would print the counts from before it beside its COMPLETE status (PR #62 review).
62
+ */
63
+ async function levelCounts(client, deadlineAt) {
64
+ const read = client
65
+ .executeJ1qlQuery({
66
+ query: context_js_1.COUNT_BY_LEVEL_QUERY,
67
+ maxPollAttempts: COUNT_POLL_ATTEMPTS,
68
+ ignoreCachedResult: true,
69
+ })
70
+ .then(countsByLevel)
71
+ .catch((error) => error instanceof j1ql_service_js_1.J1qlQueryTimeoutError ? 'pending' : 'unavailable');
72
+ const settled = await (0, shared_js_1.withDeadline)(read, deadlineAt);
73
+ return settled === shared_js_1.DEADLINE_PASSED ? 'pending' : settled;
74
+ }
75
+ /** The latest run's statuses after which the next run still has changes to apply. */
76
+ const UNFINISHED_RUN_STATUSES = new Set(['APPLYING', 'PARTIAL', 'FAILED']);
77
+ /**
78
+ * Whether the values on assets may trail the saved config: a run is requested, running or still
79
+ * writing, or the latest one was capped or failed. Null when the history could not be read. A
80
+ * save is followed by a run that waits for one in progress and is held 15 minutes after the last
81
+ * started (query-engine `requestHeldUntil`); until it applies, `assetCount` is the classification
82
+ * before the save (independent review of PR #62). Every run takes the same lock, so an hourly run
83
+ * with no save outstanding sets it too: it says "may trail", never "a change is pending", and a
84
+ * save is applied once a COMPLETE run started after it.
85
+ */
86
+ function runPending(history, now) {
87
+ if (typeof history === 'string')
88
+ return null;
89
+ const latest = history.runs[0]?.status;
90
+ return (history.pendingRequest !== null ||
91
+ history.inProgressSince !== null ||
92
+ (history.applyPendingUntil !== null && Date.parse(history.applyPendingUntil) > now) ||
93
+ (latest !== undefined && UNFINISHED_RUN_STATUSES.has(latest)));
94
+ }
95
+ /** Counted values no current level has: a renamed or removed level's, until a run replaces them. */
96
+ function valuesOutsideLevels(counts, slugs) {
97
+ if (!(counts instanceof Map))
98
+ return null;
99
+ return [...counts]
100
+ .filter(([value]) => !slugs.has(value))
101
+ .map(([value, assetCount]) => ({ value, assetCount }));
102
+ }
103
+ const RUN_PENDING_NOTE = ' A run is requested, running or still applying, or the last one was capped or failed (runs ' +
104
+ 'says which), so assetCount may trail the levels and queries read here: report it as the last ' +
105
+ 'applied state rather than waiting. A save is applied once runs.latest holds a COMPLETE run ' +
106
+ 'started after it.';
107
+ const VALUES_OUTSIDE_NOTE = ' valuesOutsideLevels counts assets still carrying a value no current level has, such as a ' +
108
+ "renamed or removed level's old one, until a run applies the change.";
109
+ function projectQuery(query) {
110
+ return {
111
+ id: query._id,
112
+ name: query.name,
113
+ j1ql: query.j1ql,
114
+ enabled: query.enabled,
115
+ createdAt: query.createdAt,
116
+ updatedAt: query.updatedAt,
117
+ };
118
+ }
119
+ function projectRuns(history) {
120
+ return {
121
+ latest: history.runs.map((run) => ({
122
+ startedAt: run.startedAt,
123
+ finishedAt: run.finishedAt,
124
+ appliedAt: run.appliedAt,
125
+ trigger: run.trigger,
126
+ status: run.status,
127
+ error: run.error,
128
+ performedBy: run.performedBy,
129
+ viaAgent: run.viaAgent,
130
+ levels: run.levels,
131
+ })),
132
+ lastRunAt: history.lastRunAt,
133
+ inProgressSince: history.inProgressSince,
134
+ pendingRequest: history.pendingRequest,
135
+ levelChange7d: history.levelChange7d,
136
+ applyPendingUntil: history.applyPendingUntil,
137
+ };
138
+ }
139
+ function configuredResult(ladder, counts, history, url) {
140
+ const context = (0, context_js_1.criticalityContext)(ladder.levels);
141
+ const slugs = new Set(ladder.levels.map((level) => level.slug));
142
+ const pending = runPending(history, Date.now());
143
+ const outside = valuesOutsideLevels(counts, slugs);
144
+ return (0, result_js_1.structuredResult)({
145
+ outcome: 'configured',
146
+ version: ladder.version,
147
+ url,
148
+ // An enabled query on no current level tags nothing; it is listed in unplacedQueries.
149
+ taggingNothing: !ladder.queries.some((query) => query.enabled && query.levelSlug !== null && slugs.has(query.levelSlug)),
150
+ levels: ladder.levels.map((level) => ({
151
+ ...(0, context_js_1.levelContext)(level),
152
+ multiplier: level.multiplier,
153
+ assetCount: counts instanceof Map ? (counts.get(level.slug) ?? 0) : null,
154
+ queries: ladder.queries.filter((query) => query.levelSlug === level.slug).map(projectQuery),
155
+ })),
156
+ unplacedQueries: ladder.queries
157
+ .filter((query) => query.levelSlug === null || !slugs.has(query.levelSlug))
158
+ .map(projectQuery),
159
+ queryCount: ladder.queries.length,
160
+ maxQueries: criticality_query_js_1.CRITICALITY_LIMITS.maxQueries,
161
+ assetCountsStatus: counts instanceof Map ? 'complete' : counts,
162
+ valuesOutsideLevels: outside,
163
+ runPending: pending,
164
+ suggestedQueries: context.configured ? context.suggestedQueries : undefined,
165
+ note: context.note +
166
+ (pending ? RUN_PENDING_NOTE : '') +
167
+ (outside && outside.length > 0 ? VALUES_OUTSIDE_NOTE : ''),
168
+ runsStatus: typeof history === 'string' ? history : 'complete',
169
+ runs: typeof history === 'string' ? null : projectRuns(history),
170
+ nextStep: 'Change levels or queries with update-asset-criticality. Filter assets by level with a ' +
171
+ "level's appliedAs in J1QL, rules and widgets.",
172
+ });
173
+ }
174
+ exports.readCriticalityTool = (0, types_js_1.defineTool)({
175
+ name: 'get-asset-criticality',
176
+ title: 'Get Asset Criticality',
177
+ description: (0, load_description_js_1.loadDescription)('get-asset-criticality.md'),
178
+ inputSchema: {},
179
+ outputSchema: schemas_js_1.getAssetCriticalityOutput,
180
+ annotations: types_js_1.READ_ONLY,
181
+ accessDeniedHint: exports.ACCESS_DENIED_HINT,
182
+ errorContext: 'Error reading asset criticality',
183
+ handler: async (_params, client) => {
184
+ const deadlineAt = Date.now() + exports.READ_DEADLINE_MS;
185
+ // Started before the ladder so they run beside it; each settles to a value, never a throw.
186
+ const history = runHistory(client, deadlineAt);
187
+ const counts = levelCounts(client, deadlineAt);
188
+ const subdomain = (0, shared_js_1.withDeadline)(client
189
+ .getAccountInfo()
190
+ .then((info) => info.subdomain)
191
+ .catch(() => undefined), deadlineAt);
192
+ const ladder = await (0, shared_js_1.withDeadline)(client.getCriticalityLadder(), deadlineAt);
193
+ if (ladder === shared_js_1.DEADLINE_PASSED) {
194
+ return (0, shared_js_1.refusal)('read_failed', `The asset criticality config could not be read within ${exports.READ_DEADLINE_MS / 1000} ` +
195
+ 'seconds. Call again.');
196
+ }
197
+ const account = await subdomain;
198
+ const url = (0, appUrl_js_1.constructAppUrl)('assets/criticality', account === shared_js_1.DEADLINE_PASSED ? undefined : account);
199
+ if (ladder.levels.length === 0) {
200
+ const context = (0, context_js_1.criticalityContext)([]);
201
+ return (0, result_js_1.structuredResult)({
202
+ outcome: 'not_configured',
203
+ version: ladder.version,
204
+ url,
205
+ note: context.note,
206
+ maxQueries: criticality_query_js_1.CRITICALITY_LIMITS.maxQueries,
207
+ nextStep: 'Set it up with one update-asset-criticality call: 2-6 levels, most critical first, ' +
208
+ 'and the queries that fill them. Full reference: get-reference topic asset-criticality',
209
+ });
210
+ }
211
+ return configuredResult(ladder, await counts, await history, url);
212
+ },
213
+ });
214
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../src/server/tools/criticality/read.ts"],"names":[],"mappings":";;;AACA,8EAAiF;AAMjF,wDAA2D;AAC3D,8EAAyE;AACzE,4EAAqE;AACrE,4CAAgD;AAChD,4CAAkD;AAClD,4CAAsE;AACtE,0CAAoD;AACpD,6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AM,SAAS,CAAC;QAChC,MAAM,GAAG,GAAG,IAAA,2BAAe,EACzB,oBAAoB,EACpB,OAAO,KAAK,2BAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAClD,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,IAAA,+BAAkB,EAAC,EAAE,CAAC,CAAC;YACvC,OAAO,IAAA,4BAAgB,EAAC;gBACtB,OAAO,EAAE,gBAAgB;gBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,GAAG;gBACH,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,UAAU,EAAE,yCAAkB,CAAC,UAAU;gBACzC,QAAQ,EACN,qFAAqF;oBACrF,uFAAuF;aAC1F,CAAC,CAAC;QACL,CAAC;QACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { JupiterOneClient } from '../../../client/jupiterone-client.js';
2
+ import type { AccountResolver } from '../types.js';
3
+ /**
4
+ * The account's asset criticality levels as an MCP resource, for hosts that pull resources into
5
+ * context: Claude Code's resource tools and @-mentions, claude.ai's and Desktop's attachment menu.
6
+ * No host loads a resource on its own (spec 2026-07-28: resources are application-driven), so this
7
+ * is the pull channel beside the levels on get-graph-context and on criticality J1QL responses.
8
+ *
9
+ * One fixed URI for every connection; the content is built on each read from the caller's token,
10
+ * so nothing is stored and nothing goes stale. `resources/list` is therefore identical for every
11
+ * caller of an endpoint, as the spec requires, while a read depends on who asks, which it allows.
12
+ */
13
+ export declare const CRITICALITY_RESOURCE_URI = "jupiterone://asset-criticality";
14
+ /** One account's levels, for a multi-tenant connection that wants a single account. */
15
+ export declare const CRITICALITY_RESOURCE_TEMPLATE = "jupiterone://accounts/{accountId}/asset-criticality";
16
+ export interface CriticalityResourceRead {
17
+ text: string;
18
+ /** Accounts whose levels were read, or attempted. */
19
+ accountsRead: number;
20
+ /** Of those, the ones whose read failed or missed the budget. */
21
+ unavailable: number;
22
+ }
23
+ /** One account's levels: the pinned account, or the one a template URI names. */
24
+ export declare function readAccountCriticality(client: JupiterOneClient, accountId: string): Promise<CriticalityResourceRead>;
25
+ /**
26
+ * The fixed URI. A pinned connection reads its account; a multi-tenant one reads each account the
27
+ * caller can access, up to MAX_ACCOUNTS, from the host's resolver. A multi-tenant connection with
28
+ * no resolver (an API token) has no account to read and says how to name one.
29
+ */
30
+ export declare function readConnectionCriticality(options: {
31
+ client: JupiterOneClient;
32
+ pinnedAccountId?: string;
33
+ resolveAccounts?: AccountResolver;
34
+ }): Promise<CriticalityResourceRead>;
35
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../../src/server/tools/criticality/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,mCAAmC,CAAC;AACzE,uFAAuF;AACvF,eAAO,MAAM,6BAA6B,wDAAwD,CAAC;AAYnG,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;CACrB;AA6BD,iFAAiF;AACjF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,uBAAuB,CAAC,CAGlC;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE;IACvD,MAAM,EAAE,gBAAgB,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAwCnC"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRITICALITY_RESOURCE_TEMPLATE = exports.CRITICALITY_RESOURCE_URI = void 0;
4
+ exports.readAccountCriticality = readAccountCriticality;
5
+ exports.readConnectionCriticality = readConnectionCriticality;
6
+ const shared_js_1 = require("../shared.js");
7
+ const context_js_1 = require("./context.js");
8
+ const levels_read_js_1 = require("./levels-read.js");
9
+ /**
10
+ * The account's asset criticality levels as an MCP resource, for hosts that pull resources into
11
+ * context: Claude Code's resource tools and @-mentions, claude.ai's and Desktop's attachment menu.
12
+ * No host loads a resource on its own (spec 2026-07-28: resources are application-driven), so this
13
+ * is the pull channel beside the levels on get-graph-context and on criticality J1QL responses.
14
+ *
15
+ * One fixed URI for every connection; the content is built on each read from the caller's token,
16
+ * so nothing is stored and nothing goes stale. `resources/list` is therefore identical for every
17
+ * caller of an endpoint, as the spec requires, while a read depends on who asks, which it allows.
18
+ */
19
+ exports.CRITICALITY_RESOURCE_URI = 'jupiterone://asset-criticality';
20
+ /** One account's levels, for a multi-tenant connection that wants a single account. */
21
+ exports.CRITICALITY_RESOURCE_TEMPLATE = 'jupiterone://accounts/{accountId}/asset-criticality';
22
+ /** Accounts one read covers on a multi-tenant connection; the rest are named, not read. */
23
+ const MAX_ACCOUNTS = 10;
24
+ /** The whole read, from its start: the account list and every levels read run inside it. */
25
+ const RESOURCE_READ_BUDGET_MS = 10_000;
26
+ const INTRO = "# Asset criticality\n\nThe account's asset criticality levels, generated from its live config " +
27
+ 'when this resource is read. `get-asset-criticality` returns the queries that fill each level ' +
28
+ 'and the assets per level; `update-asset-criticality` changes them.';
29
+ async function accountSection(client, heading, deadlineAt) {
30
+ const read = await (0, levels_read_js_1.startLevelsRead)(client)(deadlineAt);
31
+ if (!read.levels) {
32
+ return {
33
+ text: `## ${heading}\n\nThe levels could not be read in time; get-graph-context or ` +
34
+ 'get-asset-criticality returns them.',
35
+ ok: false,
36
+ };
37
+ }
38
+ return { text: (0, context_js_1.criticalityContextMarkdown)((0, context_js_1.criticalityContext)(read.levels), heading), ok: true };
39
+ }
40
+ function assemble(sections, trailer) {
41
+ return {
42
+ text: [INTRO, ...sections.map((section) => section.text), ...(trailer ? [trailer] : [])].join('\n\n'),
43
+ accountsRead: sections.length,
44
+ unavailable: sections.filter((section) => !section.ok).length,
45
+ };
46
+ }
47
+ /** One account's levels: the pinned account, or the one a template URI names. */
48
+ async function readAccountCriticality(client, accountId) {
49
+ const deadlineAt = Date.now() + RESOURCE_READ_BUDGET_MS;
50
+ return assemble([await accountSection(client, `Account ${accountId}`, deadlineAt)]);
51
+ }
52
+ /**
53
+ * The fixed URI. A pinned connection reads its account; a multi-tenant one reads each account the
54
+ * caller can access, up to MAX_ACCOUNTS, from the host's resolver. A multi-tenant connection with
55
+ * no resolver (an API token) has no account to read and says how to name one.
56
+ */
57
+ async function readConnectionCriticality(options) {
58
+ const { client, pinnedAccountId, resolveAccounts } = options;
59
+ if (pinnedAccountId)
60
+ return readAccountCriticality(client, pinnedAccountId);
61
+ const how = `Read ${exports.CRITICALITY_RESOURCE_TEMPLATE} with an account id from list-accounts, or call ` +
62
+ 'get-graph-context with that accountId.';
63
+ if (!resolveAccounts) {
64
+ return {
65
+ text: `${INTRO}\n\nThis connection is not pinned to one account. ${how}`,
66
+ accountsRead: 0,
67
+ unavailable: 0,
68
+ };
69
+ }
70
+ const deadlineAt = Date.now() + RESOURCE_READ_BUDGET_MS;
71
+ const accounts = await (0, shared_js_1.withDeadline)(resolveAccounts().catch(() => null), deadlineAt);
72
+ if (accounts === shared_js_1.DEADLINE_PASSED || accounts === null) {
73
+ return {
74
+ text: `${INTRO}\n\nThe accounts could not be listed in time. ${how}`,
75
+ accountsRead: 0,
76
+ unavailable: 0,
77
+ };
78
+ }
79
+ const read = accounts.slice(0, MAX_ACCOUNTS);
80
+ const sections = await Promise.all(read.map((account) => accountSection(client.cloneWithAccountId(account.accountId), `${account.displayName} (${account.accountId})`, deadlineAt)));
81
+ const rest = accounts.length - read.length;
82
+ return assemble(sections, rest > 0 ? `${rest} more accounts are not shown here. ${how}` : undefined);
83
+ }
84
+ //# sourceMappingURL=resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../../src/server/tools/criticality/resource.ts"],"names":[],"mappings":";;;AAkEA,wDAMC;AAOD,8DA4CC;AA1HD,4CAA6D;AAE7D,6CAA8E;AAC9E,qDAAmD;AAEnD;;;;;;;;;GASG;AACU,QAAA,wBAAwB,GAAG,gCAAgC,CAAC;AACzE,uFAAuF;AAC1E,QAAA,6BAA6B,GAAG,qDAAqD,CAAC;AAEnG,2FAA2F;AAC3F,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,4FAA4F;AAC5F,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,MAAM,KAAK,GACT,gGAAgG;IAChG,+FAA+F;IAC/F,oEAAoE,CAAC;AAUvE,KAAK,UAAU,cAAc,CAC3B,MAAwB,EACxB,OAAe,EACf,UAAkB;IAElB,MAAM,IAAI,GAAG,MAAM,IAAA,gCAAe,EAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO;YACL,IAAI,EACF,MAAM,OAAO,iEAAiE;gBAC9E,qCAAqC;YACvC,EAAE,EAAE,KAAK;SACV,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAA,uCAA0B,EAAC,IAAA,+BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AAClG,CAAC;AAED,SAAS,QAAQ,CAAC,QAA8C,EAAE,OAAgB;IAChF,OAAO;QACL,IA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