@moldea.ai/core 8.0.0 → 9.0.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/README.md +2 -2
- package/dist/agent-asset-validation/index.d.ts.map +1 -1
- package/dist/agent-assets/index.d.ts.map +1 -1
- package/dist/analysis-worker.js +5 -5
- package/dist/canonical-content-page/index.d.ts.map +1 -1
- package/dist/canonical-discovery/index.d.ts.map +1 -1
- package/dist/chunks/{core-BCMf-ig9.js → core-CFmT3SRC.js} +90 -94
- package/dist/chunks/core-CFmT3SRC.js.map +1 -0
- package/dist/chunks/{errors-CvWn6gr2.js → errors-Uvb-9X1u.js} +27 -67
- package/dist/chunks/errors-Uvb-9X1u.js.map +1 -0
- package/dist/chunks/{exceptions-CYf1pCKf.js → exceptions-AT654xUL.js} +10 -15
- package/dist/chunks/exceptions-AT654xUL.js.map +1 -0
- package/dist/chunks/{lifecycle-DwuevNoO.js → lifecycle-DuAHgnYH.js} +2 -2
- package/dist/chunks/{lifecycle-DwuevNoO.js.map → lifecycle-DuAHgnYH.js.map} +1 -1
- package/dist/chunks/{options-l3kVfA-K.js → options-C5360E_N.js} +20 -171
- package/dist/chunks/options-C5360E_N.js.map +1 -0
- package/dist/chunks/{repository-rpc-DgYwMaGv.js → repository-rpc-B9YaeLba.js} +31 -25
- package/dist/chunks/repository-rpc-B9YaeLba.js.map +1 -0
- package/dist/chunks/{scope-D9BYchNI.js → scope-CNg6Gnpi.js} +214 -151
- package/dist/chunks/scope-CNg6Gnpi.js.map +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/decision/index.d.ts.map +1 -1
- package/dist/decision-graph/index.d.ts.map +1 -1
- package/dist/decision-graph-validation/index.d.ts.map +1 -1
- package/dist/decision-validation/index.d.ts.map +1 -1
- package/dist/diagnostic-utilities/index.d.ts.map +1 -1
- package/dist/exceptions/index.d.ts +1 -1
- package/dist/exceptions/index.d.ts.map +1 -1
- package/dist/format-validation/index.d.ts +0 -4
- package/dist/format-validation/index.d.ts.map +1 -1
- package/dist/immutable/index.d.ts +0 -6
- package/dist/immutable/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/integration-validation/agents-inspection.d.ts.map +1 -1
- package/dist/integration-validation/parser.d.ts +9 -3
- package/dist/integration-validation/parser.d.ts.map +1 -1
- package/dist/integration-validation/types.d.ts +0 -5
- package/dist/integration-validation/types.d.ts.map +1 -1
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/manifest-relationship-validation/index.d.ts.map +1 -1
- package/dist/manifest-validation/index.d.ts.map +1 -1
- package/dist/mirrors/index.d.ts.map +1 -1
- package/dist/node-inspection/client.d.ts.map +1 -1
- package/dist/node-inspection/protocol.d.ts.map +1 -1
- package/dist/node-inspection/repository-rpc.d.ts.map +1 -1
- package/dist/node-runner.js +3 -3
- package/dist/node.js +13 -22
- package/dist/node.js.map +1 -1
- package/dist/options/index.d.ts.map +1 -1
- package/dist/project-assets/index.d.ts.map +1 -1
- package/dist/project-index/index.d.ts.map +1 -1
- package/dist/project-inspection/index.d.ts.map +1 -1
- package/dist/project-validation/index.d.ts.map +1 -1
- package/dist/repository-reference-validation/index.d.ts.map +1 -1
- package/dist/repository-text/index.d.ts.map +1 -1
- package/dist/runtime-guidance/index.d.ts.map +1 -1
- package/dist/runtime-placeholder-validation/index.d.ts.map +1 -1
- package/dist/scope-matching/matching.d.ts.map +1 -1
- package/dist/scope-matching/scope.d.ts.map +1 -1
- package/dist/scope-matching/validations.d.ts +0 -2
- package/dist/scope-matching/validations.d.ts.map +1 -1
- package/dist/scope.js +2 -2
- package/dist/text/index.d.ts.map +1 -1
- package/dist/universal-project-inspection/index.d.ts.map +1 -1
- package/dist/warning-acceptance/acceptance.d.ts.map +1 -1
- package/dist/yaml/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/chunks/core-BCMf-ig9.js.map +0 -1
- package/dist/chunks/errors-CvWn6gr2.js.map +0 -1
- package/dist/chunks/exceptions-CYf1pCKf.js.map +0 -1
- package/dist/chunks/options-l3kVfA-K.js.map +0 -1
- package/dist/chunks/repository-rpc-DgYwMaGv.js.map +0 -1
- package/dist/chunks/scope-D9BYchNI.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as isCoreOperationErrorCode, i as isCoreOperation, n as CoreOperationException, r as isCoreConfigurationErrorCode, t as CoreConfigurationException } from "./exceptions-
|
|
1
|
+
import { a as isCoreOperationErrorCode, i as isCoreOperation, n as CoreOperationException, r as isCoreConfigurationErrorCode, t as CoreConfigurationException } from "./exceptions-AT654xUL.js";
|
|
2
|
+
import { isObjectValid, measureJsonBytes } from "jg-utilities";
|
|
2
3
|
import { RepositoryPathException, RepositorySourceException, isRepositoryPath } from "@moldea.ai/repository";
|
|
3
4
|
import { Buffer } from "node:buffer";
|
|
4
5
|
//#region src/node-inspection/constants.ts
|
|
@@ -27,25 +28,17 @@ var createInspectionProcessFailure = (cause) => new CoreOperationException({
|
|
|
27
28
|
operation: "create-project-inspection",
|
|
28
29
|
...cause === void 0 ? {} : { cause }
|
|
29
30
|
});
|
|
30
|
-
var isRecord = (input) => input !== null && typeof input === "object" && !Array.isArray(input);
|
|
31
|
-
var JSON_SHORT_ESCAPES = /* @__PURE__ */ new Set([
|
|
32
|
-
8,
|
|
33
|
-
9,
|
|
34
|
-
10,
|
|
35
|
-
12,
|
|
36
|
-
13
|
|
37
|
-
]);
|
|
38
31
|
var isInteger = (input) => typeof input === "number" && Number.isSafeInteger(input) && input >= 0;
|
|
39
32
|
var hasKeys = (input, required, optional = []) => required.every((key) => Object.hasOwn(input, key)) && Object.keys(input).every((key) => required.includes(key) || optional.includes(key));
|
|
40
|
-
var isSnapshot = (input) =>
|
|
33
|
+
var isSnapshot = (input) => isObjectValid(input, true) && hasKeys(input, ["id", "sourceKind"]) && typeof input["id"] === "string" && input["id"].length > 0 && typeof input["sourceKind"] === "string" && input["sourceKind"].length > 0;
|
|
41
34
|
var isOptionalString = (input, key) => !Object.hasOwn(input, key) || typeof input[key] === "string";
|
|
42
|
-
var isPageInput = (input) =>
|
|
35
|
+
var isPageInput = (input) => isObjectValid(input, true) && hasKeys(input, ["maxItems", "view"], ["cursor"]) && isInteger(input["maxItems"]) && input["maxItems"] > 0 && [
|
|
43
36
|
"all",
|
|
44
37
|
"diagnostics",
|
|
45
38
|
"coverage",
|
|
46
39
|
"metadata"
|
|
47
40
|
].includes(String(input["view"])) && isOptionalString(input, "cursor");
|
|
48
|
-
var isLimits = (input) =>
|
|
41
|
+
var isLimits = (input) => isObjectValid(input, true) && hasKeys(input, [
|
|
49
42
|
"maxEntries",
|
|
50
43
|
"maxTotalBytesRead",
|
|
51
44
|
"maxFileBytes",
|
|
@@ -55,7 +48,7 @@ var isLimits = (input) => isRecord(input) && hasKeys(input, [
|
|
|
55
48
|
"maxCoverage",
|
|
56
49
|
"maxAcceptedWarnings"
|
|
57
50
|
]) && Object.values(input).every((limit) => isInteger(limit) && limit > 0);
|
|
58
|
-
var isCounts = (input) =>
|
|
51
|
+
var isCounts = (input) => isObjectValid(input, true) && hasKeys(input, [
|
|
59
52
|
"agents",
|
|
60
53
|
"context",
|
|
61
54
|
"decisions",
|
|
@@ -69,13 +62,13 @@ var isCounts = (input) => isRecord(input) && hasKeys(input, [
|
|
|
69
62
|
"coverage",
|
|
70
63
|
"metadata"
|
|
71
64
|
]) && Object.values(input).every(isInteger);
|
|
72
|
-
var isSummary = (input) => input === null ||
|
|
65
|
+
var isSummary = (input) => input === null || isObjectValid(input, true) && hasKeys(input, [
|
|
73
66
|
"counts",
|
|
74
67
|
"manifestDigest",
|
|
75
68
|
"manifestPath",
|
|
76
69
|
"projectDigest",
|
|
77
70
|
"projectPath"
|
|
78
|
-
]) &&
|
|
71
|
+
]) && isObjectValid(input["counts"], true) && hasKeys(input["counts"], [
|
|
79
72
|
"agents",
|
|
80
73
|
"context",
|
|
81
74
|
"decisions",
|
|
@@ -83,7 +76,7 @@ var isSummary = (input) => input === null || isRecord(input) && hasKeys(input, [
|
|
|
83
76
|
"runtimes",
|
|
84
77
|
"unresolved"
|
|
85
78
|
]) && Object.values(input["counts"]).every(isInteger) && typeof input["manifestDigest"] === "string" && typeof input["projectDigest"] === "string" && isRepositoryPath(input["manifestPath"]) && isRepositoryPath(input["projectPath"]);
|
|
86
|
-
var isInspectionBase = (input) => isCounts(input["counts"]) &&
|
|
79
|
+
var isInspectionBase = (input) => isCounts(input["counts"]) && isObjectValid(input["coverageCounts"], true) && hasKeys(input["coverageCounts"], [
|
|
87
80
|
"bindings",
|
|
88
81
|
"exportsPassed",
|
|
89
82
|
"exportsFailed",
|
|
@@ -98,18 +91,18 @@ var INSPECTION_KEYS = [
|
|
|
98
91
|
"source",
|
|
99
92
|
"summary"
|
|
100
93
|
];
|
|
101
|
-
var isMetadata = (input) =>
|
|
94
|
+
var isMetadata = (input) => isObjectValid(input, true) && hasKeys(input, [
|
|
102
95
|
...INSPECTION_KEYS,
|
|
103
96
|
"resourceUsage",
|
|
104
97
|
"maxAnalysisHeapBytes"
|
|
105
|
-
]) && isInspectionBase(input) && isInteger(input["maxAnalysisHeapBytes"]) && input["maxAnalysisHeapBytes"] > 0 &&
|
|
98
|
+
]) && isInspectionBase(input) && isInteger(input["maxAnalysisHeapBytes"]) && input["maxAnalysisHeapBytes"] > 0 && isObjectValid(input["resourceUsage"], true) && hasKeys(input["resourceUsage"], [
|
|
106
99
|
"canonicalBytes",
|
|
107
100
|
"peakRetainedBytes",
|
|
108
101
|
"preparedBytes",
|
|
109
102
|
"retainedBytes",
|
|
110
103
|
"totalBytesRead"
|
|
111
104
|
]) && Object.values(input["resourceUsage"]).every(isInteger);
|
|
112
|
-
var isPage = (input) =>
|
|
105
|
+
var isPage = (input) => isObjectValid(input, true) && hasKeys(input, [
|
|
113
106
|
...INSPECTION_KEYS,
|
|
114
107
|
"page",
|
|
115
108
|
"view"
|
|
@@ -118,22 +111,22 @@ var isPage = (input) => isRecord(input) && hasKeys(input, [
|
|
|
118
111
|
"diagnostics",
|
|
119
112
|
"coverage",
|
|
120
113
|
"metadata"
|
|
121
|
-
].includes(String(input["view"])) &&
|
|
114
|
+
].includes(String(input["view"])) && isObjectValid(input["page"], true) && hasKeys(input["page"], [
|
|
122
115
|
"isComplete",
|
|
123
116
|
"records",
|
|
124
117
|
"nextCursor",
|
|
125
118
|
"totalItems"
|
|
126
|
-
]) && typeof input["page"]["isComplete"] === "boolean" && isInteger(input["page"]["totalItems"]) && (input["page"]["nextCursor"] === null || typeof input["page"]["nextCursor"] === "string") && Array.isArray(input["page"]["records"]) && input["page"]["records"].every((record) =>
|
|
119
|
+
]) && typeof input["page"]["isComplete"] === "boolean" && isInteger(input["page"]["totalItems"]) && (input["page"]["nextCursor"] === null || typeof input["page"]["nextCursor"] === "string") && Array.isArray(input["page"]["records"]) && input["page"]["records"].every((record) => isObjectValid(record, true) && hasKeys(record, ["item", "nextCursor"]) && (record["nextCursor"] === null || typeof record["nextCursor"] === "string") && isObjectValid(record["item"], true) && typeof record["item"]["kind"] === "string" && [
|
|
127
120
|
"agent",
|
|
128
121
|
"diagnostic",
|
|
129
122
|
"coverage",
|
|
130
123
|
"metadata"
|
|
131
|
-
].includes(record["item"]["kind"]) && hasKeys(record["item"], ["kind", record["item"]["kind"]]) &&
|
|
124
|
+
].includes(record["item"]["kind"]) && hasKeys(record["item"], ["kind", record["item"]["kind"]]) && isObjectValid(record["item"][record["item"]["kind"]], true));
|
|
132
125
|
var isSource = (input) => input === "instructions" || input === "repository";
|
|
133
126
|
var isFilePageRequest = (input) => isRepositoryPath(input["path"]) && isInteger(input["offset"]) && isInteger(input["maxBytes"]) && input["maxBytes"] > 0 && input["maxBytes"] <= 65536;
|
|
134
|
-
var isInstructionSource = (input) => input === null ||
|
|
127
|
+
var isInstructionSource = (input) => input === null || isObjectValid(input, true) && hasKeys(input, ["snapshot"]) && isSnapshot(input["snapshot"]);
|
|
135
128
|
var isRequest = (input) => {
|
|
136
|
-
if (!
|
|
129
|
+
if (!isObjectValid(input, true)) return false;
|
|
137
130
|
switch (input["method"]) {
|
|
138
131
|
case "getEntry":
|
|
139
132
|
case "readLinkText": return hasKeys(input, [
|
|
@@ -154,7 +147,7 @@ var isRequest = (input) => {
|
|
|
154
147
|
};
|
|
155
148
|
/** Validates closed control envelopes and their typed operation payloads on both bridges. */
|
|
156
149
|
var isMessage = (input) => {
|
|
157
|
-
if (!
|
|
150
|
+
if (!isObjectValid(input, true) || typeof input["attemptId"] !== "string" || !/^[a-f0-9]{32}$/.test(input["attemptId"])) return false;
|
|
158
151
|
const keys = ["attemptId", "kind"];
|
|
159
152
|
switch (input["kind"]) {
|
|
160
153
|
case "start": return hasKeys(input, [
|
|
@@ -193,53 +186,15 @@ var isMessage = (input) => {
|
|
|
193
186
|
...keys,
|
|
194
187
|
"failure",
|
|
195
188
|
...input["kind"] === "reader-failure" ? ["requestId"] : []
|
|
196
|
-
]) && (input["kind"] !== "reader-failure" || isInteger(input["requestId"])) &&
|
|
189
|
+
]) && (input["kind"] !== "reader-failure" || isInteger(input["requestId"])) && isObjectValid(input["failure"], true) && hasKeys(input["failure"], ["family", "options"]) && [
|
|
197
190
|
"configuration",
|
|
198
191
|
"operation",
|
|
199
192
|
"repository",
|
|
200
193
|
"path"
|
|
201
|
-
].includes(String(input["failure"]["family"])) &&
|
|
194
|
+
].includes(String(input["failure"]["family"])) && isObjectValid(input["failure"]["options"], true);
|
|
202
195
|
default: return false;
|
|
203
196
|
}
|
|
204
197
|
};
|
|
205
|
-
/** Counts escaped JSON bytes without first allocating a serialized oversized message. */
|
|
206
|
-
var countJsonBytes = (input, ancestors, depth) => {
|
|
207
|
-
if (depth > 64) throw createInspectionProcessFailure();
|
|
208
|
-
if (input === null) return 4;
|
|
209
|
-
if (typeof input === "boolean") return input ? 4 : 5;
|
|
210
|
-
if (typeof input === "number" && Number.isFinite(input)) return String(input).length;
|
|
211
|
-
if (typeof input === "string") {
|
|
212
|
-
let bytes = 2;
|
|
213
|
-
for (let index = 0; index < input.length; index++) {
|
|
214
|
-
const code = input.charCodeAt(index);
|
|
215
|
-
if (code === 34 || code === 92 || JSON_SHORT_ESCAPES.has(code)) bytes += 2;
|
|
216
|
-
else if (code < 32) bytes += 6;
|
|
217
|
-
else if (code < 128) bytes++;
|
|
218
|
-
else if (code < 2048) bytes += 2;
|
|
219
|
-
else if (code >= 55296 && code <= 56319 && index + 1 < input.length && input.charCodeAt(index + 1) >= 56320 && input.charCodeAt(index + 1) <= 57343) {
|
|
220
|
-
bytes += 4;
|
|
221
|
-
index++;
|
|
222
|
-
} else bytes += code >= 55296 && code <= 57343 ? 6 : 3;
|
|
223
|
-
if (bytes > 1048576) return bytes;
|
|
224
|
-
}
|
|
225
|
-
return bytes;
|
|
226
|
-
}
|
|
227
|
-
if (typeof input !== "object" || ancestors.has(input)) throw createInspectionProcessFailure();
|
|
228
|
-
ancestors.add(input);
|
|
229
|
-
let bytes = 2;
|
|
230
|
-
let count = 0;
|
|
231
|
-
if (Array.isArray(input)) for (const element of input) {
|
|
232
|
-
bytes += (count++ === 0 ? 0 : 1) + countJsonBytes(element, ancestors, depth + 1);
|
|
233
|
-
if (bytes > 1048576) break;
|
|
234
|
-
}
|
|
235
|
-
else for (const key in input) {
|
|
236
|
-
if (!Object.hasOwn(input, key)) continue;
|
|
237
|
-
bytes += (count++ === 0 ? 0 : 1) + countJsonBytes(key, ancestors, depth + 1) + 1 + countJsonBytes(input[key], ancestors, depth + 1);
|
|
238
|
-
if (bytes > 1048576) break;
|
|
239
|
-
}
|
|
240
|
-
ancestors.delete(input);
|
|
241
|
-
return bytes;
|
|
242
|
-
};
|
|
243
198
|
/**
|
|
244
199
|
* Admits a complete bounded record before serialization; no record is truncated.
|
|
245
200
|
* @returns One private JSON frame.
|
|
@@ -248,7 +203,12 @@ var countJsonBytes = (input, ancestors, depth) => {
|
|
|
248
203
|
* - INSPECTION_PROCESS_FAILED: The isolated project inspection failed.
|
|
249
204
|
*/
|
|
250
205
|
var encodeInspectionMessage = (message) => {
|
|
251
|
-
|
|
206
|
+
let bytes;
|
|
207
|
+
try {
|
|
208
|
+
bytes = measureJsonBytes(message, NODE_INSPECTION_MESSAGE_BYTES);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
throw createInspectionProcessFailure(error);
|
|
211
|
+
}
|
|
252
212
|
if (bytes > 1048576) throw new CoreOperationException({
|
|
253
213
|
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
254
214
|
limit: "maxInspectionMessageBytes",
|
|
@@ -437,4 +397,4 @@ var deserializeInspectionFailure = (failure) => {
|
|
|
437
397
|
//#endregion
|
|
438
398
|
export { encodeInspectionMessage as a, NODE_INSPECTION_PROFILE as c, NODE_INSPECTION_TRANSPORT_BYTES as d, decodeInspectionMessage as i, NODE_INSPECTION_STDIO_BYTES as l, serializeInspectionFailure as n, NODE_INSPECTION_FILE_PAGE_BYTES as o, createInspectionProcessFailure as r, NODE_INSPECTION_LIFETIME_MS as s, deserializeInspectionFailure as t, NODE_INSPECTION_TERMINATION_GRACE_MS as u };
|
|
439
399
|
|
|
440
|
-
//# sourceMappingURL=errors-
|
|
400
|
+
//# sourceMappingURL=errors-Uvb-9X1u.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-Uvb-9X1u.js","names":[],"sources":["../../src/node-inspection/constants.ts","../../src/node-inspection/protocol.ts","../../src/node-inspection/errors.ts"],"sourcesContent":["// whole-attempt lifetime and bounded bridge ownership, independent of source file size\nexport const NODE_INSPECTION_LIFETIME_MS = 120_000;\nexport const NODE_INSPECTION_TERMINATION_GRACE_MS = 1_000;\nexport const NODE_INSPECTION_MAX_REQUESTS = 4;\nexport const NODE_INSPECTION_FILE_PAGE_BYTES = 65_536;\nexport const NODE_INSPECTION_MESSAGE_BYTES = 1_048_576;\nexport const NODE_INSPECTION_STDIO_BYTES = 32_768;\n\n// two UTF-16 bytes per serialized byte, two copies at each owner, for every RPC credit\nexport const NODE_INSPECTION_TRANSPORT_BYTES =\n NODE_INSPECTION_MAX_REQUESTS * NODE_INSPECTION_MESSAGE_BYTES * 2 * 2 * 3;\n\n// fixed profile qualified in the constrained CLI and actual-worker lanes\nexport const NODE_INSPECTION_OLD_GENERATION_MIB = 512;\nexport const NODE_INSPECTION_YOUNG_GENERATION_MIB = 24;\n\n// immutable execution identity for consumers that authenticate prepared inspection state\nexport const NODE_INSPECTION_PROFILE = Object.freeze({\n lifetimeMs: NODE_INSPECTION_LIFETIME_MS,\n terminationGraceMs: NODE_INSPECTION_TERMINATION_GRACE_MS,\n maxReaderRequests: NODE_INSPECTION_MAX_REQUESTS,\n maxFilePageBytes: NODE_INSPECTION_FILE_PAGE_BYTES,\n maxMessageBytes: NODE_INSPECTION_MESSAGE_BYTES,\n maxStdioBytes: NODE_INSPECTION_STDIO_BYTES,\n transportBytes: NODE_INSPECTION_TRANSPORT_BYTES,\n oldGenerationMiB: NODE_INSPECTION_OLD_GENERATION_MIB,\n youngGenerationMiB: NODE_INSPECTION_YOUNG_GENERATION_MIB,\n});\n","import { Buffer } from 'node:buffer';\nimport { isObjectValid, measureJsonBytes } from 'jg-utilities';\n\nimport { isRepositoryPath } from '@moldea.ai/repository';\n\nimport type { ICoreResourceLimits } from '../contracts/index.js';\nimport { CoreOperationException } from '../exceptions/index.js';\n\nimport { NODE_INSPECTION_FILE_PAGE_BYTES, NODE_INSPECTION_MESSAGE_BYTES } from './constants.js';\nimport type { INodeInspectionMessage } from './types.js';\n\n/** Creates the safe failure for an untrusted or inconsistent private protocol record. */\nexport const createInspectionProcessFailure = (cause?: unknown): CoreOperationException =>\n new CoreOperationException({\n code: 'INSPECTION_PROCESS_FAILED',\n operation: 'create-project-inspection',\n ...(cause === undefined ? {} : { cause }),\n });\n\nconst isInteger = (input: unknown): input is number =>\n typeof input === 'number' && Number.isSafeInteger(input) && input >= 0;\nconst hasKeys = (\n input: Record<string, unknown>,\n required: string[],\n optional: string[] = [],\n): boolean =>\n required.every((key) => Object.hasOwn(input, key)) &&\n Object.keys(input).every((key) => required.includes(key) || optional.includes(key));\nconst isSnapshot = (input: unknown): boolean =>\n isObjectValid(input, true) &&\n hasKeys(input, ['id', 'sourceKind']) &&\n typeof input['id'] === 'string' &&\n input['id'].length > 0 &&\n typeof input['sourceKind'] === 'string' &&\n input['sourceKind'].length > 0;\nconst isOptionalString = (input: Record<string, unknown>, key: string): boolean =>\n !Object.hasOwn(input, key) || typeof input[key] === 'string';\nconst isPageInput = (input: unknown): boolean =>\n isObjectValid(input, true) &&\n hasKeys(input, ['maxItems', 'view'], ['cursor']) &&\n isInteger(input['maxItems']) &&\n input['maxItems'] > 0 &&\n ['all', 'diagnostics', 'coverage', 'metadata'].includes(String(input['view'])) &&\n isOptionalString(input, 'cursor');\nconst isLimits = (input: unknown): input is ICoreResourceLimits =>\n isObjectValid(input, true) &&\n hasKeys(input, [\n 'maxEntries',\n 'maxTotalBytesRead',\n 'maxFileBytes',\n 'maxManifestBytes',\n 'maxRetainedBytes',\n 'maxDiagnostics',\n 'maxCoverage',\n 'maxAcceptedWarnings',\n ]) &&\n Object.values(input).every((limit) => isInteger(limit) && limit > 0);\nconst isCounts = (input: unknown): boolean =>\n isObjectValid(input, true) &&\n hasKeys(input, [\n 'agents',\n 'context',\n 'decisions',\n 'mirrors',\n 'runtimes',\n 'unresolved',\n 'diagnostics',\n 'errors',\n 'warnings',\n 'acceptedWarnings',\n 'coverage',\n 'metadata',\n ]) &&\n Object.values(input).every(isInteger);\nconst isSummary = (input: unknown): boolean =>\n input === null ||\n (isObjectValid(input, true) &&\n hasKeys(input, ['counts', 'manifestDigest', 'manifestPath', 'projectDigest', 'projectPath']) &&\n isObjectValid(input['counts'], true) &&\n hasKeys(input['counts'], [\n 'agents',\n 'context',\n 'decisions',\n 'mirrors',\n 'runtimes',\n 'unresolved',\n ]) &&\n Object.values(input['counts']).every(isInteger) &&\n typeof input['manifestDigest'] === 'string' &&\n typeof input['projectDigest'] === 'string' &&\n isRepositoryPath(input['manifestPath']) &&\n isRepositoryPath(input['projectPath']));\nconst isInspectionBase = (input: Record<string, unknown>): boolean =>\n isCounts(input['counts']) &&\n isObjectValid(input['coverageCounts'], true) &&\n hasKeys(input['coverageCounts'], [\n 'bindings',\n 'exportsPassed',\n 'exportsFailed',\n 'exportsNotChecked',\n ]) &&\n Object.values(input['coverageCounts']).every(isInteger) &&\n typeof input['valid'] === 'boolean' &&\n (input['formatVersion'] === null || input['formatVersion'] === 1) &&\n typeof input['inspectionDigest'] === 'string' &&\n isSnapshot(input['source']) &&\n isSummary(input['summary']);\nconst INSPECTION_KEYS = [\n 'counts',\n 'coverageCounts',\n 'valid',\n 'formatVersion',\n 'inspectionDigest',\n 'source',\n 'summary',\n];\nconst isMetadata = (input: unknown): boolean =>\n isObjectValid(input, true) &&\n hasKeys(input, [...INSPECTION_KEYS, 'resourceUsage', 'maxAnalysisHeapBytes']) &&\n isInspectionBase(input) &&\n isInteger(input['maxAnalysisHeapBytes']) &&\n input['maxAnalysisHeapBytes'] > 0 &&\n isObjectValid(input['resourceUsage'], true) &&\n hasKeys(input['resourceUsage'], [\n 'canonicalBytes',\n 'peakRetainedBytes',\n 'preparedBytes',\n 'retainedBytes',\n 'totalBytesRead',\n ]) &&\n Object.values(input['resourceUsage']).every(isInteger);\nconst isPage = (input: unknown): boolean =>\n isObjectValid(input, true) &&\n hasKeys(input, [...INSPECTION_KEYS, 'page', 'view']) &&\n isInspectionBase(input) &&\n ['all', 'diagnostics', 'coverage', 'metadata'].includes(String(input['view'])) &&\n isObjectValid(input['page'], true) &&\n hasKeys(input['page'], ['isComplete', 'records', 'nextCursor', 'totalItems']) &&\n typeof input['page']['isComplete'] === 'boolean' &&\n isInteger(input['page']['totalItems']) &&\n (input['page']['nextCursor'] === null || typeof input['page']['nextCursor'] === 'string') &&\n Array.isArray(input['page']['records']) &&\n input['page']['records'].every(\n (record: unknown) =>\n isObjectValid(record, true) &&\n hasKeys(record, ['item', 'nextCursor']) &&\n (record['nextCursor'] === null || typeof record['nextCursor'] === 'string') &&\n isObjectValid(record['item'], true) &&\n typeof record['item']['kind'] === 'string' &&\n ['agent', 'diagnostic', 'coverage', 'metadata'].includes(record['item']['kind']) &&\n hasKeys(record['item'], ['kind', record['item']['kind']]) &&\n isObjectValid(record['item'][record['item']['kind']], true),\n );\nconst isSource = (input: unknown): boolean => input === 'instructions' || input === 'repository';\nconst isFilePageRequest = (input: Record<string, unknown>): boolean =>\n isRepositoryPath(input['path']) &&\n isInteger(input['offset']) &&\n isInteger(input['maxBytes']) &&\n input['maxBytes'] > 0 &&\n input['maxBytes'] <= NODE_INSPECTION_FILE_PAGE_BYTES;\nconst isInstructionSource = (input: unknown): boolean =>\n input === null ||\n (isObjectValid(input, true) && hasKeys(input, ['snapshot']) && isSnapshot(input['snapshot']));\nconst isRequest = (input: unknown): boolean => {\n if (!isObjectValid(input, true)) return false;\n switch (input['method']) {\n case 'getEntry':\n case 'readLinkText':\n return (\n hasKeys(input, ['method', 'path', 'source']) &&\n isRepositoryPath(input['path']) &&\n isSource(input['source'])\n );\n case 'listEntriesPage':\n return (\n hasKeys(input, ['method', 'maxEntries'], ['cursor', 'prefix']) &&\n isInteger(input['maxEntries']) &&\n input['maxEntries'] > 0 &&\n input['maxEntries'] <= 128 &&\n isOptionalString(input, 'cursor') &&\n (!Object.hasOwn(input, 'prefix') || isRepositoryPath(input['prefix']))\n );\n case 'readFilePage':\n return (\n hasKeys(input, ['method', 'path', 'maxBytes', 'offset', 'source']) &&\n isSource(input['source']) &&\n isFilePageRequest(input)\n );\n default:\n return false;\n }\n};\n\n/** Validates closed control envelopes and their typed operation payloads on both bridges. */\nconst isMessage = (input: unknown): input is INodeInspectionMessage => {\n if (\n !isObjectValid(input, true) ||\n typeof input['attemptId'] !== 'string' ||\n !/^[a-f0-9]{32}$/.test(input['attemptId'])\n )\n return false;\n const keys = ['attemptId', 'kind'];\n switch (input['kind']) {\n case 'start':\n return (\n hasKeys(input, [...keys, 'snapshot', 'instructions', 'limits', 'deadline']) &&\n isSnapshot(input['snapshot']) &&\n isInstructionSource(input['instructions']) &&\n isLimits(input['limits']) &&\n isInteger(input['deadline'])\n );\n case 'ready':\n return (\n hasKeys(input, [...keys, 'maxAnalysisHeapBytes']) &&\n isInteger(input['maxAnalysisHeapBytes']) &&\n input['maxAnalysisHeapBytes'] > 0\n );\n case 'run':\n case 'dispose':\n return hasKeys(input, keys);\n case 'prepared':\n return hasKeys(input, [...keys, 'inspection']) && isMetadata(input['inspection']);\n case 'read-page':\n return (\n hasKeys(input, [...keys, 'requestId', 'input']) &&\n isInteger(input['requestId']) &&\n isPageInput(input['input'])\n );\n case 'page':\n return (\n hasKeys(input, [...keys, 'requestId', 'result']) &&\n isInteger(input['requestId']) &&\n isPage(input['result'])\n );\n case 'reader-request':\n return (\n hasKeys(input, [...keys, 'requestId', 'request']) &&\n isInteger(input['requestId']) &&\n isRequest(input['request'])\n );\n case 'reader-response':\n return hasKeys(input, [...keys, 'requestId', 'result']) && isInteger(input['requestId']);\n case 'reader-failure':\n case 'failure':\n return (\n hasKeys(input, [\n ...keys,\n 'failure',\n ...(input['kind'] === 'reader-failure' ? ['requestId'] : []),\n ]) &&\n (input['kind'] !== 'reader-failure' || isInteger(input['requestId'])) &&\n isObjectValid(input['failure'], true) &&\n hasKeys(input['failure'], ['family', 'options']) &&\n ['configuration', 'operation', 'repository', 'path'].includes(\n String(input['failure']['family']),\n ) &&\n isObjectValid(input['failure']['options'], true)\n );\n default:\n return false;\n }\n};\n\n/**\n * Admits a complete bounded record before serialization; no record is truncated.\n * @returns One private JSON frame.\n * @throws\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n * - INSPECTION_PROCESS_FAILED: The isolated project inspection failed.\n */\nexport const encodeInspectionMessage = (message: INodeInspectionMessage): string => {\n let bytes: number;\n try {\n bytes = measureJsonBytes(message, NODE_INSPECTION_MESSAGE_BYTES);\n } catch (error) {\n throw createInspectionProcessFailure(error);\n }\n if (bytes > NODE_INSPECTION_MESSAGE_BYTES)\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: 'maxInspectionMessageBytes',\n limitMaximum: NODE_INSPECTION_MESSAGE_BYTES,\n observedUsage: bytes,\n nextAction: null,\n operation: 'create-project-inspection',\n });\n if (!isMessage(message)) throw createInspectionProcessFailure();\n return JSON.stringify(message);\n};\n\n/**\n * Checks frame size before parsing and validates the closed message contract.\n * @returns A validated private message.\n * @throws\n * - INSPECTION_PROCESS_FAILED: The isolated project inspection failed.\n */\nexport const decodeInspectionMessage = (frame: unknown): INodeInspectionMessage => {\n if (typeof frame !== 'string' || Buffer.byteLength(frame) > NODE_INSPECTION_MESSAGE_BYTES)\n throw createInspectionProcessFailure();\n let message: unknown;\n try {\n message = JSON.parse(frame);\n } catch (cause) {\n throw createInspectionProcessFailure(cause);\n }\n if (!isMessage(message)) throw createInspectionProcessFailure();\n return message;\n};\n","import {\n RepositoryPathException,\n RepositorySourceException,\n isRepositoryPath,\n type IRepositoryOperation,\n type IRepositorySourceErrorCode,\n} from '@moldea.ai/repository';\n\nimport {\n CoreConfigurationException,\n CoreOperationException,\n isCoreConfigurationErrorCode,\n isCoreOperation,\n isCoreOperationErrorCode,\n} from '../exceptions/index.js';\n\nimport { createInspectionProcessFailure } from './protocol.js';\nimport type { INodeInspectionFailure } from './types.js';\n\n/** Serializes only documented exception fields, excluding native messages, causes and stacks. */\nexport const serializeInspectionFailure = (error: unknown): INodeInspectionFailure => {\n if (error instanceof CoreConfigurationException)\n return {\n family: 'configuration',\n options: {\n code: error.code,\n operation: error.operation,\n },\n };\n if (error instanceof CoreOperationException)\n return {\n family: 'operation',\n options: {\n code: error.code,\n operation: error.operation,\n ...(error.code !== 'RESOURCE_LIMIT_EXCEEDED'\n ? {}\n : {\n limit: error.limit,\n limitMaximum: error.limitMaximum,\n nextAction: error.nextAction,\n observedUsage: error.observedUsage,\n }),\n },\n };\n if (error instanceof RepositoryPathException) return { family: 'path', options: {} };\n if (error instanceof RepositorySourceException)\n return {\n family: 'repository',\n options: {\n code: error.code,\n operation: error.operation,\n path: error.path,\n retryable: error.retryable,\n ...(error.resource === null ? {} : { resource: error.resource }),\n },\n };\n return {\n family: 'operation',\n options: {\n code: 'INSPECTION_PROCESS_FAILED',\n operation: 'create-project-inspection',\n },\n };\n};\nconst REPOSITORY_CODES: IRepositorySourceErrorCode[] = [\n 'ENTRY_NOT_FOUND',\n 'ENTRY_NOT_FILE',\n 'ENTRY_NOT_DIRECTORY',\n 'INVALID_PAGE_REQUEST',\n 'ACCESS_DENIED',\n 'SOURCE_UNAVAILABLE',\n 'SNAPSHOT_CHANGED',\n 'PROVIDER_INCOMPLETE',\n 'INVALID_SOURCE_DATA',\n 'RESOURCE_LIMIT_EXCEEDED',\n 'ABORTED',\n];\nconst REPOSITORY_OPERATIONS: IRepositoryOperation[] = [\n 'create-reader',\n 'create-comparison',\n 'get-entry',\n 'read-file-page',\n 'list-entries-page',\n 'list-changes-page',\n];\nconst isNumber = (input: unknown): input is number =>\n typeof input === 'number' && Number.isSafeInteger(input) && input >= 0;\n\n/**\n * Reconstructs a documented typed failure after checking its safe transport fields.\n * @returns A package exception without a remote native cause or stack.\n * @throws\n * - INSPECTION_PROCESS_FAILED: The isolated project inspection failed.\n */\nexport const deserializeInspectionFailure = (failure: INodeInspectionFailure): Error => {\n const options = failure.options;\n const allowed =\n failure.family === 'configuration'\n ? ['code', 'operation']\n : failure.family === 'operation'\n ? ['code', 'operation', 'limit', 'limitMaximum', 'nextAction', 'observedUsage']\n : failure.family === 'repository'\n ? ['code', 'operation', 'path', 'retryable', 'resource']\n : [];\n if (Object.keys(options).some((key) => !allowed.includes(key)))\n throw createInspectionProcessFailure();\n if (\n (failure.family === 'operation' || failure.family === 'configuration') &&\n !isCoreOperation(options['operation'])\n )\n throw createInspectionProcessFailure();\n const scope = {\n operation: isCoreOperation(options['operation'])\n ? options['operation']\n : ('create-project-inspection' as const),\n };\n if (failure.family === 'path' && Object.keys(options).length === 0)\n return new RepositoryPathException();\n if (failure.family === 'configuration') {\n const code = options['code'];\n if (isCoreConfigurationErrorCode(code))\n return new CoreConfigurationException({ ...scope, code });\n }\n if (failure.family === 'operation') {\n const code = options['code'];\n if (\n isCoreOperationErrorCode(code) &&\n code !== 'RESOURCE_LIMIT_EXCEEDED' &&\n !['limit', 'limitMaximum', 'nextAction', 'observedUsage'].some((key) =>\n Object.hasOwn(options, key),\n )\n )\n return new CoreOperationException({ ...scope, code });\n if (\n options['code'] === 'RESOURCE_LIMIT_EXCEEDED' &&\n isNumber(options['limitMaximum']) &&\n options['limitMaximum'] > 0\n ) {\n if (\n options['limit'] === 'maxAnalysisHeapBytes' &&\n options['nextAction'] === 'review-inspection-capacity' &&\n options['observedUsage'] === null\n )\n return new CoreOperationException({\n ...scope,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: 'maxAnalysisHeapBytes',\n limitMaximum: options['limitMaximum'],\n observedUsage: null,\n nextAction: 'review-inspection-capacity',\n });\n if (\n (options['limit'] === 'maxInspectionMessageBytes' ||\n options['limit'] === 'maxReaderRequests') &&\n options['nextAction'] === null &&\n isNumber(options['observedUsage'])\n )\n return new CoreOperationException({\n ...scope,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: options['limit'],\n limitMaximum: options['limitMaximum'],\n nextAction: null,\n observedUsage: options['observedUsage'],\n });\n if (\n typeof options['limit'] === 'string' &&\n !['maxAnalysisHeapBytes', 'maxInspectionMessageBytes', 'maxReaderRequests'].includes(\n options['limit'],\n ) &&\n options['nextAction'] === 'reduce-input-or-increase-limit' &&\n isNumber(options['observedUsage'])\n )\n return new CoreOperationException({\n ...scope,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: options['limit'],\n limitMaximum: options['limitMaximum'],\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage: options['observedUsage'],\n });\n }\n }\n if (failure.family === 'repository') {\n const code = REPOSITORY_CODES.find((candidate) => candidate === options['code']);\n const operation = REPOSITORY_OPERATIONS.find((candidate) => candidate === options['operation']);\n const resource = options['resource'];\n if (\n code !== undefined &&\n operation !== undefined &&\n typeof options['retryable'] === 'boolean' &&\n (options['path'] === null || isRepositoryPath(options['path'])) &&\n (resource === undefined ||\n (resource !== null &&\n typeof resource === 'object' &&\n Object.keys(resource).length === 3 &&\n 'dimension' in resource &&\n typeof resource.dimension === 'string' &&\n 'limit' in resource &&\n isNumber(resource.limit) &&\n 'observed' in resource &&\n isNumber(resource.observed)))\n ) {\n return new RepositorySourceException({\n code,\n operation,\n path: options['path'],\n retryable: options['retryable'],\n ...(resource === undefined\n ? {}\n : {\n resource: resource as {\n dimension: string;\n limit: number;\n observed: number;\n },\n }),\n });\n }\n }\n throw createInspectionProcessFailure();\n};\n"],"mappings":";;;;;AACA,IAAa,8BAA8B;AAC3C,IAAa,uCAAuC;AAEpD,IAAa,kCAAkC;AAC/C,IAAa,gCAAgC;AAC7C,IAAa,8BAA8B;AAG3C,IAAa,kCAAA,IACoB,gCAAgC,IAAI,IAAI;AAOzE,IAAa,0BAA0B,OAAO,OAAO;CACnD,YAAY;CACZ,oBAAoB;CACpB,mBAAA;CACA,kBAAkB;CAClB,iBAAiB;CACjB,eAAe;CACf,gBAAgB;CAChB,kBAAA;CACA,oBAAA;AACF,CAAC;;;;ACfD,IAAa,kCAAkC,UAC7C,IAAI,uBAAuB;CACzB,MAAM;CACN,WAAW;CACX,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;AACzC,CAAC;AAEH,IAAM,aAAa,UACjB,OAAO,UAAU,YAAY,OAAO,cAAc,KAAK,KAAK,SAAS;AACvE,IAAM,WACJ,OACA,UACA,WAAqB,CAAC,MAEtB,SAAS,OAAO,QAAQ,OAAO,OAAO,OAAO,GAAG,CAAC,KACjD,OAAO,KAAK,KAAK,CAAC,CAAC,OAAO,QAAQ,SAAS,SAAS,GAAG,KAAK,SAAS,SAAS,GAAG,CAAC;AACpF,IAAM,cAAc,UAClB,cAAc,OAAO,IAAI,KACzB,QAAQ,OAAO,CAAC,MAAM,YAAY,CAAC,KACnC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AAQ;GACzB,CAAC;EACL;CACF;CACA,IAAI,QAAQ,WAAW,cAAc;EACnC,MAAM,OAAO,iBAAiB,MAAM,cAAc,cAAc,QAAQ,OAAO;EAC/E,MAAM,YAAY,sBAAsB,MAAM,cAAc,cAAc,QAAQ,YAAY;EAC9F,MAAM,WAAW,QAAQ;EACzB,IACE,SAAS,KAAA,KACT,cAAc,KAAA,KACd,OAAO,QAAQ,iBAAiB,cAC/B,QAAQ,YAAY,QAAQ,iBAAiB,QAAQ,OAAO,OAC5D,aAAa,KAAA,KACX,aAAa,QACZ,OAAO,aAAa,YACpB,OAAO,KAAK,QAAQ,CAAC,CAAC,WAAW,KACjC,eAAe,YACf,OAAO,SAAS,cAAc,YAC9B,WAAW,YACX,SAAS,SAAS,KAAK,KACvB,cAAc,YACd,SAAS,SAAS,QAAQ,IAE9B,OAAO,IAAI,0BAA0B;GACnC;GACA;GACA,MAAM,QAAQ;GACd,WAAW,QAAQ;GACnB,GAAI,aAAa,KAAA,IACb,CAAC,IACD,EACY,SAKZ;EACN,CAAC;CAEL;CACA,MAAM,+BAA+B;AACvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Exception } from "
|
|
1
|
+
import { Exception } from "jg-exception";
|
|
2
2
|
//#region src/exceptions/index.ts
|
|
3
3
|
var CORE_OPERATIONS = [
|
|
4
4
|
"create-core",
|
|
@@ -36,26 +36,19 @@ var isCoreOperation = (input) => CORE_OPERATIONS.some((operation) => operation =
|
|
|
36
36
|
var isCoreConfigurationErrorCode = (input) => typeof input === "string" && Object.hasOwn(CONFIGURATION_ERROR_MESSAGES, input);
|
|
37
37
|
/** Checks a transported operation code against the authoritative message registry. */
|
|
38
38
|
var isCoreOperationErrorCode = (input) => typeof input === "string" && Object.hasOwn(OPERATION_ERROR_MESSAGES, input);
|
|
39
|
-
var attachCause = (exception, cause) => {
|
|
40
|
-
if (cause === void 0) return;
|
|
41
|
-
Object.defineProperty(exception, "cause", {
|
|
42
|
-
configurable: true,
|
|
43
|
-
enumerable: false,
|
|
44
|
-
value: cause,
|
|
45
|
-
writable: false
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
39
|
/** Represents invalid immutable Core configuration. */
|
|
49
40
|
var CoreConfigurationException = class extends Exception {
|
|
50
41
|
code;
|
|
51
42
|
operation;
|
|
52
43
|
/** Creates a configuration exception with safe operation metadata. */
|
|
53
44
|
constructor(options) {
|
|
54
|
-
super(CONFIGURATION_ERROR_MESSAGES[options.code],
|
|
45
|
+
super(CONFIGURATION_ERROR_MESSAGES[options.code], {
|
|
46
|
+
code: options.code,
|
|
47
|
+
cause: options.cause
|
|
48
|
+
});
|
|
55
49
|
this.code = options.code;
|
|
56
50
|
this.name = "CoreConfigurationException";
|
|
57
51
|
this.operation = options.operation;
|
|
58
|
-
attachCause(this, options.cause);
|
|
59
52
|
}
|
|
60
53
|
};
|
|
61
54
|
/** Represents an operational failure that prevented Core from completing. */
|
|
@@ -69,7 +62,10 @@ var CoreOperationException = class extends Exception {
|
|
|
69
62
|
observedUsage;
|
|
70
63
|
/** Creates an operation exception with derived retry and safe scope metadata. */
|
|
71
64
|
constructor(options) {
|
|
72
|
-
super(OPERATION_ERROR_MESSAGES[options.code],
|
|
65
|
+
super(OPERATION_ERROR_MESSAGES[options.code], {
|
|
66
|
+
code: options.code,
|
|
67
|
+
cause: options.cause
|
|
68
|
+
});
|
|
73
69
|
this.code = options.code;
|
|
74
70
|
this.name = "CoreOperationException";
|
|
75
71
|
this.operation = options.operation;
|
|
@@ -78,10 +74,9 @@ var CoreOperationException = class extends Exception {
|
|
|
78
74
|
this.limitMaximum = options.limitMaximum ?? null;
|
|
79
75
|
this.nextAction = options.nextAction ?? null;
|
|
80
76
|
this.observedUsage = options.observedUsage ?? null;
|
|
81
|
-
attachCause(this, options.cause);
|
|
82
77
|
}
|
|
83
78
|
};
|
|
84
79
|
//#endregion
|
|
85
80
|
export { isCoreOperationErrorCode as a, isCoreOperation as i, CoreOperationException as n, isCoreConfigurationErrorCode as r, CoreConfigurationException as t };
|
|
86
81
|
|
|
87
|
-
//# sourceMappingURL=exceptions-
|
|
82
|
+
//# sourceMappingURL=exceptions-AT654xUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions-AT654xUL.js","names":[],"sources":["../../src/exceptions/index.ts"],"sourcesContent":["import { Exception } from 'jg-exception';\n\n// stable configuration and operation failure codes\nexport type ICoreConfigurationErrorCode = 'INVALID_RESOURCE_LIMIT';\n\nexport type ICoreOperationErrorCode =\n | 'INVALID_ARGUMENT'\n | 'ABORTED'\n | 'RESOURCE_LIMIT_EXCEEDED'\n | 'INSPECTION_BUSY'\n | 'INSPECTION_TIMEOUT'\n | 'INSPECTION_PROCESS_FAILED'\n | 'CONTENT_INVALID';\n\nconst CORE_OPERATIONS = [\n 'create-core',\n 'normalize-text',\n 'calculate-content-digest',\n 'parse-manifest',\n 'match-manifest-scope',\n 'parse-decision',\n 'create-project-inspection',\n 'read-canonical-content-page',\n 'validate-project',\n] as const;\n\nexport type ICoreOperation = (typeof CORE_OPERATIONS)[number];\n\n// safe construction options for exported Core exceptions\nexport interface ICoreConfigurationExceptionOptions {\n readonly code: ICoreConfigurationErrorCode;\n readonly operation: ICoreOperation;\n readonly cause?: unknown;\n}\n\ninterface ICoreOperationExceptionOptionsBase {\n readonly operation: ICoreOperation;\n readonly cause?: unknown;\n}\n\n// logical budget refusals and verified isolated-worker heap exhaustion\nexport type ICoreResourceLimitNextAction =\n 'reduce-input-or-increase-limit' | 'review-inspection-capacity';\n\nexport type ICoreOperationExceptionOptions = ICoreOperationExceptionOptionsBase &\n (\n | {\n readonly code: 'RESOURCE_LIMIT_EXCEEDED';\n readonly limit: string;\n readonly limitMaximum: number;\n readonly nextAction: 'reduce-input-or-increase-limit';\n readonly observedUsage: number;\n }\n | {\n readonly code: 'RESOURCE_LIMIT_EXCEEDED';\n readonly limit: 'maxAnalysisHeapBytes';\n readonly limitMaximum: number;\n readonly nextAction: 'review-inspection-capacity';\n readonly observedUsage: null;\n }\n | {\n readonly code: 'RESOURCE_LIMIT_EXCEEDED';\n readonly limit: 'maxInspectionMessageBytes' | 'maxReaderRequests';\n readonly limitMaximum: number;\n readonly nextAction: null;\n readonly observedUsage: number;\n }\n | {\n readonly code: Exclude<ICoreOperationErrorCode, 'RESOURCE_LIMIT_EXCEEDED'>;\n readonly limit?: never;\n readonly limitMaximum?: never;\n readonly nextAction?: never;\n readonly observedUsage?: never;\n }\n );\n\nconst CONFIGURATION_ERROR_MESSAGES = {\n INVALID_RESOURCE_LIMIT: 'A Core resource limit is invalid.',\n} as const satisfies Readonly<Record<ICoreConfigurationErrorCode, string>>;\n\nconst OPERATION_ERROR_MESSAGES = {\n ABORTED: 'The Core operation was aborted.',\n CONTENT_INVALID: 'The canonical content is not valid UTF-8 text.',\n INVALID_ARGUMENT: 'The Core operation received an invalid argument.',\n INSPECTION_BUSY: 'Project inspection capacity is busy. Try again shortly.',\n INSPECTION_TIMEOUT: 'The isolated project inspection timed out.',\n INSPECTION_PROCESS_FAILED: 'The isolated project inspection failed.',\n RESOURCE_LIMIT_EXCEEDED: 'A Core resource limit was exceeded.',\n} as const satisfies Readonly<Record<ICoreOperationErrorCode, string>>;\n\nconst OPERATION_ERROR_RETRYABILITY = {\n ABORTED: true,\n CONTENT_INVALID: false,\n INVALID_ARGUMENT: false,\n INSPECTION_BUSY: true,\n INSPECTION_TIMEOUT: true,\n INSPECTION_PROCESS_FAILED: false,\n RESOURCE_LIMIT_EXCEEDED: false,\n} as const satisfies Readonly<Record<ICoreOperationErrorCode, boolean>>;\n\n/** Checks a transported operation against the authoritative Core operation set. */\nexport const isCoreOperation = (input: unknown): input is ICoreOperation =>\n CORE_OPERATIONS.some((operation) => operation === input);\n\n/** Checks a transported configuration code against the authoritative message registry. */\nexport const isCoreConfigurationErrorCode = (\n input: unknown,\n): input is ICoreConfigurationErrorCode =>\n typeof input === 'string' && Object.hasOwn(CONFIGURATION_ERROR_MESSAGES, input);\n\n/** Checks a transported operation code against the authoritative message registry. */\nexport const isCoreOperationErrorCode = (input: unknown): input is ICoreOperationErrorCode =>\n typeof input === 'string' && Object.hasOwn(OPERATION_ERROR_MESSAGES, input);\n\n/** Represents invalid immutable Core configuration. */\nexport class CoreConfigurationException extends Exception {\n public override readonly code: ICoreConfigurationErrorCode;\n\n public readonly operation: ICoreOperation;\n\n /** Creates a configuration exception with safe operation metadata. */\n public constructor(options: ICoreConfigurationExceptionOptions) {\n super(CONFIGURATION_ERROR_MESSAGES[options.code], {\n code: options.code,\n cause: options.cause,\n });\n this.code = options.code;\n this.name = 'CoreConfigurationException';\n this.operation = options.operation;\n }\n}\n\n/** Represents an operational failure that prevented Core from completing. */\nexport class CoreOperationException extends Exception {\n public override readonly code: ICoreOperationErrorCode;\n\n public readonly operation: ICoreOperation;\n\n public readonly retryable: boolean;\n\n public readonly limit: string | null;\n\n public readonly limitMaximum: number | null;\n\n public readonly nextAction: ICoreResourceLimitNextAction | null;\n\n public readonly observedUsage: number | null;\n\n /** Creates an operation exception with derived retry and safe scope metadata. */\n public constructor(options: ICoreOperationExceptionOptions) {\n super(OPERATION_ERROR_MESSAGES[options.code], {\n code: options.code,\n cause: options.cause,\n });\n this.code = options.code;\n this.name = 'CoreOperationException';\n this.operation = options.operation;\n this.retryable = OPERATION_ERROR_RETRYABILITY[options.code];\n this.limit = options.limit ?? null;\n this.limitMaximum = options.limitMaximum ?? null;\n this.nextAction = options.nextAction ?? null;\n this.observedUsage = options.observedUsage ?? null;\n }\n}\n"],"mappings":";;AAcA,IAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAoDA,IAAM,+BAA+B,EACnC,wBAAwB,oCAC1B;AAEA,IAAM,2BAA2B;CAC/B,SAAS;CACT,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;CACjB,oBAAoB;CACpB,2BAA2B;CAC3B,yBAAyB;AAC3B;AAEA,IAAM,+BAA+B;CACnC,SAAS;CACT,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;CACjB,oBAAoB;CACpB,2BAA2B;CAC3B,yBAAyB;AAC3B;;AAGA,IAAa,mBAAmB,UAC9B,gBAAgB,MAAM,cAAc,cAAc,KAAK;;AAGzD,IAAa,gCACX,UAEA,OAAO,UAAU,YAAY,OAAO,OAAO,8BAA8B,KAAK;;AAGhF,IAAa,4BAA4B,UACvC,OAAO,UAAU,YAAY,OAAO,OAAO,0BAA0B,KAAK;;AAG5E,IAAa,6BAAb,cAAgD,UAAU;CACxD;CAEA;;CAGA,YAAmB,SAA6C;EAC9D,MAAM,6BAA6B,QAAQ,OAAO;GAChD,MAAM,QAAQ;GACd,OAAO,QAAQ;EACjB,CAAC;EACD,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO;EACZ,KAAK,YAAY,QAAQ;CAC3B;AACF;;AAGA,IAAa,yBAAb,cAA4C,UAAU;CACpD;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;;CAGA,YAAmB,SAAyC;EAC1D,MAAM,yBAAyB,QAAQ,OAAO;GAC5C,MAAM,QAAQ;GACd,OAAO,QAAQ;EACjB,CAAC;EACD,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO;EACZ,KAAK,YAAY,QAAQ;EACzB,KAAK,YAAY,6BAA6B,QAAQ;EACtD,KAAK,QAAQ,QAAQ,SAAS;EAC9B,KAAK,eAAe,QAAQ,gBAAgB;EAC5C,KAAK,aAAa,QAAQ,cAAc;EACxC,KAAK,gBAAgB,QAAQ,iBAAiB;CAChD;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as encodeInspectionMessage, r as createInspectionProcessFailure, u as NODE_INSPECTION_TERMINATION_GRACE_MS } from "./errors-
|
|
1
|
+
import { a as encodeInspectionMessage, r as createInspectionProcessFailure, u as NODE_INSPECTION_TERMINATION_GRACE_MS } from "./errors-Uvb-9X1u.js";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
//#region src/node-inspection/lifecycle.ts
|
|
4
4
|
/** Serializes bounded IPC sends and waits for Node's send callback before admitting the next. */
|
|
@@ -64,4 +64,4 @@ var superviseInspectionChild = (child, requestStop) => {
|
|
|
64
64
|
//#endregion
|
|
65
65
|
export { createInspectionSender as n, superviseInspectionChild as r, createInspectionEnvironment as t };
|
|
66
66
|
|
|
67
|
-
//# sourceMappingURL=lifecycle-
|
|
67
|
+
//# sourceMappingURL=lifecycle-DuAHgnYH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-
|
|
1
|
+
{"version":3,"file":"lifecycle-DuAHgnYH.js","names":[],"sources":["../../src/node-inspection/lifecycle.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport process from 'node:process';\n\nimport { NODE_INSPECTION_TERMINATION_GRACE_MS } from './constants.js';\nimport { NODE_INSPECTION_MAX_REQUESTS } from './constants.js';\nimport { createInspectionProcessFailure, encodeInspectionMessage } from './protocol.js';\nimport type { INodeInspectionMessage } from './types.js';\n\n/** Serializes bounded IPC sends and waits for Node's send callback before admitting the next. */\nexport const createInspectionSender = (\n send: (frame: string, callback: (error: Error | null) => void) => void,\n): ((message: INodeInspectionMessage) => Promise<void>) => {\n let queued = 0;\n let tail = Promise.resolve();\n return async (message) => {\n if (queued >= NODE_INSPECTION_MAX_REQUESTS) throw createInspectionProcessFailure();\n queued++;\n const operation = tail.then(\n () =>\n new Promise<void>((resolve, reject) => {\n try {\n send(encodeInspectionMessage(message), (error) => {\n if (error !== null) reject(createInspectionProcessFailure(error));\n else resolve();\n });\n } catch (cause) {\n reject(cause instanceof Error ? cause : createInspectionProcessFailure(cause));\n }\n }),\n );\n tail = operation.catch(() => {});\n try {\n await operation;\n } finally {\n queued--;\n }\n };\n};\n\n/** Keeps only operating-system bootstrap variables; no credentials or Node overrides cross. */\nexport const createInspectionEnvironment = (): NodeJS.ProcessEnv => {\n const names = new Set(['systemroot', 'windir', 'temp', 'tmp', 'tmpdir']);\n return Object.fromEntries(\n Object.entries(process.env).filter(([name]) => names.has(name.toLowerCase())),\n );\n};\n\n/**\n * Supervises one owned child without PID polling, shell commands, or process-group killing.\n * @returns Idempotent termination and actual close notification.\n */\nexport const superviseInspectionChild = (\n child: ChildProcess,\n requestStop: () => void,\n): {\n closed: Promise<void>;\n terminate: () => void;\n} => {\n let hasClosed = false;\n let forceTimer: NodeJS.Timeout | undefined;\n const closed = new Promise<void>((resolve) => {\n child.once('close', () => {\n hasClosed = true;\n clearTimeout(forceTimer);\n resolve();\n });\n });\n return {\n closed,\n terminate: (): void => {\n if (hasClosed || forceTimer !== undefined) return;\n // Let the child close IPC. Local disconnect can suppress ChildProcess's close event.\n forceTimer = setTimeout(() => {\n if (!hasClosed) child.kill('SIGKILL');\n }, NODE_INSPECTION_TERMINATION_GRACE_MS);\n requestStop();\n },\n };\n};\n"],"mappings":";;;;AASA,IAAa,0BACX,SACyD;CACzD,IAAI,SAAS;CACb,IAAI,OAAO,QAAQ,QAAQ;CAC3B,OAAO,OAAO,YAAY;EACxB,IAAI,UAAA,GAAwC,MAAM,+BAA+B;EACjF;EACA,MAAM,YAAY,KAAK,WAEnB,IAAI,SAAe,SAAS,WAAW;GACrC,IAAI;IACF,KAAK,wBAAwB,OAAO,IAAI,UAAU;KAChD,IAAI,UAAU,MAAM,OAAO,+BAA+B,KAAK,CAAC;UAC3D,QAAQ;IACf,CAAC;GACH,SAAS,OAAO;IACd,OAAO,iBAAiB,QAAQ,QAAQ,+BAA+B,KAAK,CAAC;GAC/E;EACF,CAAC,CACL;EACA,OAAO,UAAU,YAAY,CAAC,CAAC;EAC/B,IAAI;GACF,MAAM;EACR,UAAU;GACR;EACF;CACF;AACF;;AAGA,IAAa,oCAAuD;CAClE,MAAM,wBAAQ,IAAI,IAAI;EAAC;EAAc;EAAU;EAAQ;EAAO;CAAQ,CAAC;CACvE,OAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,MAAM,IAAI,KAAK,YAAY,CAAC,CAAC,CAC9E;AACF;;;;;AAMA,IAAa,4BACX,OACA,gBAIG;CACH,IAAI,YAAY;CAChB,IAAI;CAQJ,OAAO;EACL,QAAA,IARiB,SAAe,YAAY;GAC5C,MAAM,KAAK,eAAe;IACxB,YAAY;IACZ,aAAa,UAAU;IACvB,QAAQ;GACV,CAAC;EACH,CAEE;EACA,iBAAuB;GACrB,IAAI,aAAa,eAAe,KAAA,GAAW;GAE3C,aAAa,iBAAiB;IAC5B,IAAI,CAAC,WAAW,MAAM,KAAK,SAAS;GACtC,GAAG,oCAAoC;GACvC,YAAY;EACd;CACF;AACF"}
|