@moldea.ai/core 6.0.0 → 7.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.
Files changed (138) hide show
  1. package/README.md +13 -19
  2. package/dist/analysis-worker.js +14 -24
  3. package/dist/analysis-worker.js.map +1 -1
  4. package/dist/binding-coverage/index.d.ts +26 -0
  5. package/dist/binding-coverage/index.d.ts.map +1 -0
  6. package/dist/chunks/{core-DchheNDz.js → core-Cdeiu6xG.js} +743 -2684
  7. package/dist/chunks/core-Cdeiu6xG.js.map +1 -0
  8. package/dist/chunks/{errors-BQI1DEqf.js → errors-BE4DS3Ak.js} +27 -38
  9. package/dist/chunks/errors-BE4DS3Ak.js.map +1 -0
  10. package/dist/chunks/{exceptions-lzD3buFw.js → exceptions-IXsorE8t.js} +4 -16
  11. package/dist/chunks/exceptions-IXsorE8t.js.map +1 -0
  12. package/dist/chunks/{lifecycle-4EkWgEHm.js → lifecycle-D_RvxhDC.js} +2 -2
  13. package/dist/chunks/{lifecycle-4EkWgEHm.js.map → lifecycle-D_RvxhDC.js.map} +1 -1
  14. package/dist/chunks/{options-CxCT3dZU.js → options-5x9gu2Qb.js} +139 -152
  15. package/dist/chunks/options-5x9gu2Qb.js.map +1 -0
  16. package/dist/chunks/{repository-rpc-BWi6X1la.js → repository-rpc-B_y0Kspf.js} +2 -2
  17. package/dist/chunks/{repository-rpc-BWi6X1la.js.map → repository-rpc-B_y0Kspf.js.map} +1 -1
  18. package/dist/chunks/scope-AGMcHUE_.js +1827 -0
  19. package/dist/chunks/scope-AGMcHUE_.js.map +1 -0
  20. package/dist/chunks/syntax-CVvExx4R.js +137 -0
  21. package/dist/chunks/syntax-CVvExx4R.js.map +1 -0
  22. package/dist/constants/index.d.ts +2 -1
  23. package/dist/constants/index.d.ts.map +1 -1
  24. package/dist/contracts/index.d.ts +15 -15
  25. package/dist/contracts/index.d.ts.map +1 -1
  26. package/dist/core/index.d.ts +1 -4
  27. package/dist/core/index.d.ts.map +1 -1
  28. package/dist/decision/index.d.ts +1 -1
  29. package/dist/decision-graph/index.d.ts +9 -7
  30. package/dist/decision-graph/index.d.ts.map +1 -1
  31. package/dist/diagnostic-utilities/index.d.ts +6 -2
  32. package/dist/diagnostic-utilities/index.d.ts.map +1 -1
  33. package/dist/diagnostics/index.d.ts +21 -33
  34. package/dist/diagnostics/index.d.ts.map +1 -1
  35. package/dist/exceptions/index.d.ts +4 -8
  36. package/dist/exceptions/index.d.ts.map +1 -1
  37. package/dist/export-inventory/index.d.ts +3 -0
  38. package/dist/export-inventory/index.d.ts.map +1 -0
  39. package/dist/export-inventory/inventory.d.ts +22 -0
  40. package/dist/export-inventory/inventory.d.ts.map +1 -0
  41. package/dist/export-inventory/syntax.d.ts +4 -0
  42. package/dist/export-inventory/syntax.d.ts.map +1 -0
  43. package/dist/export-inventory/types.d.ts +9 -0
  44. package/dist/export-inventory/types.d.ts.map +1 -0
  45. package/dist/format/index.d.ts +8 -0
  46. package/dist/format/index.d.ts.map +1 -1
  47. package/dist/impact-pattern-validation/index.d.ts +2 -0
  48. package/dist/impact-pattern-validation/index.d.ts.map +1 -0
  49. package/dist/impact-pattern-validation/inspection.d.ts +24 -0
  50. package/dist/impact-pattern-validation/inspection.d.ts.map +1 -0
  51. package/dist/index.d.ts +6 -4
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +4 -4
  54. package/dist/integration-validation/index.d.ts +4 -0
  55. package/dist/integration-validation/index.d.ts.map +1 -0
  56. package/dist/integration-validation/inspection.d.ts +18 -0
  57. package/dist/integration-validation/inspection.d.ts.map +1 -0
  58. package/dist/integration-validation/parser.d.ts +9 -0
  59. package/dist/integration-validation/parser.d.ts.map +1 -0
  60. package/dist/integration-validation/types.d.ts +13 -0
  61. package/dist/integration-validation/types.d.ts.map +1 -0
  62. package/dist/manifest/index.d.ts +2 -4
  63. package/dist/manifest/index.d.ts.map +1 -1
  64. package/dist/manifest-validation/index.d.ts +7 -10
  65. package/dist/manifest-validation/index.d.ts.map +1 -1
  66. package/dist/node/index.d.ts +1 -1
  67. package/dist/node/index.d.ts.map +1 -1
  68. package/dist/node-inspection/client.d.ts +0 -4
  69. package/dist/node-inspection/client.d.ts.map +1 -1
  70. package/dist/node-inspection/errors.d.ts.map +1 -1
  71. package/dist/node-inspection/protocol.d.ts.map +1 -1
  72. package/dist/node-inspection/types.d.ts +4 -8
  73. package/dist/node-inspection/types.d.ts.map +1 -1
  74. package/dist/node-runner.js +4 -4
  75. package/dist/node-runner.js.map +1 -1
  76. package/dist/node.js +23 -13
  77. package/dist/node.js.map +1 -1
  78. package/dist/options/index.d.ts +2 -14
  79. package/dist/options/index.d.ts.map +1 -1
  80. package/dist/project-inspection/index.d.ts +1 -2
  81. package/dist/project-inspection/index.d.ts.map +1 -1
  82. package/dist/project-validation/index.d.ts +2 -4
  83. package/dist/project-validation/index.d.ts.map +1 -1
  84. package/dist/repository-inspection-session/index.d.ts +2 -4
  85. package/dist/repository-inspection-session/index.d.ts.map +1 -1
  86. package/dist/repository-reference-validation/index.d.ts +12 -6
  87. package/dist/repository-reference-validation/index.d.ts.map +1 -1
  88. package/dist/retained-memory/index.d.ts +18 -0
  89. package/dist/retained-memory/index.d.ts.map +1 -0
  90. package/dist/scope/index.d.ts +3 -0
  91. package/dist/scope/index.d.ts.map +1 -0
  92. package/dist/scope/scope.d.ts +13 -0
  93. package/dist/scope/scope.d.ts.map +1 -0
  94. package/dist/scope-matching/index.d.ts +2 -1
  95. package/dist/scope-matching/index.d.ts.map +1 -1
  96. package/dist/scope-matching/matching.d.ts +11 -2
  97. package/dist/scope-matching/matching.d.ts.map +1 -1
  98. package/dist/scope-matching/patterns.d.ts +4 -0
  99. package/dist/scope-matching/patterns.d.ts.map +1 -0
  100. package/dist/scope.js +17 -0
  101. package/dist/scope.js.map +1 -0
  102. package/dist/universal-project-inspection/index.d.ts +13 -11
  103. package/dist/universal-project-inspection/index.d.ts.map +1 -1
  104. package/dist/warning-acceptance/acceptance.d.ts +11 -0
  105. package/dist/warning-acceptance/acceptance.d.ts.map +1 -0
  106. package/dist/warning-acceptance/index.d.ts +2 -0
  107. package/dist/warning-acceptance/index.d.ts.map +1 -0
  108. package/package.json +6 -6
  109. package/dist/adapter/index.d.ts +0 -143
  110. package/dist/adapter/index.d.ts.map +0 -1
  111. package/dist/adapter-availability/index.d.ts +0 -15
  112. package/dist/adapter-availability/index.d.ts.map +0 -1
  113. package/dist/adapter-execution/index.d.ts +0 -34
  114. package/dist/adapter-execution/index.d.ts.map +0 -1
  115. package/dist/adapter-repository/index.d.ts +0 -27
  116. package/dist/adapter-repository/index.d.ts.map +0 -1
  117. package/dist/adapter-result-collection/collection.d.ts +0 -13
  118. package/dist/adapter-result-collection/collection.d.ts.map +0 -1
  119. package/dist/adapter-result-collection/index.d.ts +0 -3
  120. package/dist/adapter-result-collection/index.d.ts.map +0 -1
  121. package/dist/adapter-result-collection/types.d.ts +0 -31
  122. package/dist/adapter-result-collection/types.d.ts.map +0 -1
  123. package/dist/adapter-retained-memory/index.d.ts +0 -8
  124. package/dist/adapter-retained-memory/index.d.ts.map +0 -1
  125. package/dist/adapter-validation/index.d.ts +0 -43
  126. package/dist/adapter-validation/index.d.ts.map +0 -1
  127. package/dist/adapter.js +0 -116
  128. package/dist/adapter.js.map +0 -1
  129. package/dist/chunks/collection-CvbjjLf2.js +0 -73
  130. package/dist/chunks/collection-CvbjjLf2.js.map +0 -1
  131. package/dist/chunks/core-DchheNDz.js.map +0 -1
  132. package/dist/chunks/errors-BQI1DEqf.js.map +0 -1
  133. package/dist/chunks/exceptions-lzD3buFw.js.map +0 -1
  134. package/dist/chunks/options-CxCT3dZU.js.map +0 -1
  135. package/dist/custom-runtime-inspection/index.d.ts +0 -2
  136. package/dist/custom-runtime-inspection/index.d.ts.map +0 -1
  137. package/dist/custom-runtime-inspection/inspection.d.ts +0 -11
  138. package/dist/custom-runtime-inspection/inspection.d.ts.map +0 -1
@@ -1,59 +1,66 @@
1
- import { n as CoreOperationException, t as CoreConfigurationException } from "./exceptions-lzD3buFw.js";
1
+ import { n as CoreOperationException, t as CoreConfigurationException } from "./exceptions-IXsorE8t.js";
2
2
  import { isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
3
3
  //#region src/constants/index.ts
4
- var RECOGNIZED_RUNTIME_ADAPTER_IDS = Object.freeze([
4
+ var ACCEPTABLE_WARNING_CODES = Object.freeze([
5
+ "MOLDEA_IMPACT_PATTERN_UNMATCHED",
6
+ "MOLDEA_INTEGRATION_BLOCK_MISSING",
7
+ "MOLDEA_INTEGRATION_SKILL_MISSING",
8
+ "MOLDEA_INTEGRATION_BLOCK_STALE"
9
+ ]);
10
+ var RECOGNIZED_RUNTIME_IDS = Object.freeze([
11
+ "amazon-bedrock",
5
12
  "anthropic",
13
+ "cerebras",
6
14
  "claude-agent-sdk",
7
15
  "cloudflare-agents",
16
+ "cohere",
17
+ "convex-agent",
18
+ "cursor-sdk",
8
19
  "custom",
20
+ "deep-agents",
9
21
  "eve",
22
+ "genkit",
23
+ "github-copilot-sdk",
24
+ "google-adk",
10
25
  "google-genai",
26
+ "groq",
27
+ "hugging-face",
28
+ "ibm-watsonx-ai",
11
29
  "langchain",
12
30
  "langgraph",
31
+ "livekit-agents",
32
+ "mastra",
33
+ "microsoft-foundry",
34
+ "mistral",
35
+ "node-llama-cpp",
36
+ "ollama",
13
37
  "openai",
14
38
  "openai-agents-sdk",
15
- "vercel-ai-sdk"
39
+ "openai-codex",
40
+ "opencode-sdk",
41
+ "openrouter",
42
+ "pi-agent",
43
+ "strands-agents",
44
+ "tanstack-ai",
45
+ "vercel-ai-sdk",
46
+ "voltagent"
16
47
  ]);
17
48
  var SUPPORTED_REPOSITORY_FORMAT_VERSIONS = Object.freeze([1]);
18
49
  var DEFAULT_CORE_RESOURCE_LIMITS = Object.freeze({
19
50
  maxDiagnostics: 1e4,
20
51
  maxEntries: 1e5,
21
- maxEvidence: 1e4,
52
+ maxCoverage: 1e4,
53
+ maxAcceptedWarnings: 256,
22
54
  maxFileBytes: 8388608,
23
55
  maxManifestBytes: 2097152,
24
56
  maxRetainedBytes: 536870912,
25
57
  maxTotalBytesRead: 134217728
26
58
  });
27
59
  //#endregion
28
- //#region src/immutable/index.ts
29
- /**
30
- * Recursively freezes a Core-owned value without cloning it.
31
- * @param value The detached acyclic value whose already-frozen objects are deeply frozen.
32
- * @returns The same value with every mutable reachable object frozen.
33
- */
34
- var freezeRecursively = (value) => {
35
- if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
36
- for (const key of Reflect.ownKeys(value)) {
37
- const child = value[key];
38
- freezeRecursively(child);
39
- }
40
- return Object.freeze(value);
41
- };
42
- /**
43
- * Creates a record that cannot collide with prototype-chain properties.
44
- * @param entries The own string-keyed entries to assign.
45
- * @returns A mutable null-prototype record for later normalization and freezing.
46
- */
47
- var createNullPrototypeRecord = (entries) => {
48
- const record = Object.create(null);
49
- for (const [key, value] of entries) record[key] = value;
50
- return record;
51
- };
52
- //#endregion
53
60
  //#region src/format-validation/index.ts
54
- var STABLE_ID_PATTERN$1 = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
61
+ var STABLE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
55
62
  var VARIABLE_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
56
- var WINDOWS_RESERVED_ID_PATTERN$1 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u;
63
+ var WINDOWS_RESERVED_ID_PATTERN = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u;
57
64
  var LINE_BREAK_CHARACTERS = [
58
65
  "\n",
59
66
  "\r",
@@ -90,21 +97,6 @@ var countUnicodeScalars = (value) => {
90
97
  while (scalars.next().done !== true) count += 1;
91
98
  return count;
92
99
  };
93
- /** Determines whether a JavaScript string contains only Unicode scalar values. */
94
- var isUnicodeScalarText = (value) => {
95
- for (let index = 0; index < value.length; index += 1) {
96
- const codeUnit = value.charCodeAt(index);
97
- if (codeUnit >= 55296 && codeUnit <= 56319) {
98
- if (index + 1 >= value.length) return false;
99
- const nextCodeUnit = value.charCodeAt(index + 1);
100
- if (nextCodeUnit < 56320 || nextCodeUnit > 57343) return false;
101
- index += 1;
102
- continue;
103
- }
104
- if (codeUnit >= 56320 && codeUnit <= 57343) return false;
105
- }
106
- return true;
107
- };
108
100
  /** Determines whether a value contains at least one non-whitespace scalar. */
109
101
  var hasNonWhitespace = (value) => {
110
102
  for (const scalar of value) if (!isRepositoryFormatWhitespace(scalar.codePointAt(0) ?? 0)) return true;
@@ -137,11 +129,11 @@ var isNonEmptySingleLine = (value) => {
137
129
  return value.length > 0 && !hasLineBreak(value);
138
130
  };
139
131
  /** Determines whether a value satisfies stable moldea ID syntax. */
140
- var isStableId$1 = (value) => {
141
- return value.length <= 64 && STABLE_ID_PATTERN$1.test(value);
132
+ var isStableId = (value) => {
133
+ return value.length <= 64 && STABLE_ID_PATTERN.test(value);
142
134
  };
143
135
  /** Determines whether an otherwise valid stable ID is filesystem-reserved. */
144
- var isReservedId = (value) => WINDOWS_RESERVED_ID_PATTERN$1.test(value);
136
+ var isReservedId = (value) => WINDOWS_RESERVED_ID_PATTERN.test(value);
145
137
  /** Determines whether a value satisfies runtime-variable ID syntax. */
146
138
  var isVariableId = (value) => {
147
139
  return value.length <= 64 && VARIABLE_ID_PATTERN.test(value);
@@ -164,7 +156,7 @@ var parseDecisionIdFromPath = (path) => {
164
156
  const match = /^\/moldea\/decisions\/(\d{13})-([a-z0-9]+(?:-[a-z0-9]+)*)\.md$/u.exec(path);
165
157
  const id = match?.[1];
166
158
  const slug = match?.[2];
167
- return id !== void 0 && slug !== void 0 && isStableId$1(slug) ? id : null;
159
+ return id !== void 0 && slug !== void 0 && isStableId(slug) ? id : null;
168
160
  };
169
161
  /** Determines whether a path is an allowed focused-context relationship key. */
170
162
  var isContextPath = (path, allowProject) => {
@@ -208,6 +200,31 @@ var sortRepositoryReferences = (references) => {
208
200
  });
209
201
  };
210
202
  //#endregion
203
+ //#region src/immutable/index.ts
204
+ /**
205
+ * Recursively freezes a Core-owned value without cloning it.
206
+ * @param value The detached acyclic value whose already-frozen objects are deeply frozen.
207
+ * @returns The same value with every mutable reachable object frozen.
208
+ */
209
+ var freezeRecursively = (value) => {
210
+ if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
211
+ for (const key of Reflect.ownKeys(value)) {
212
+ const child = value[key];
213
+ freezeRecursively(child);
214
+ }
215
+ return Object.freeze(value);
216
+ };
217
+ /**
218
+ * Creates a record that cannot collide with prototype-chain properties.
219
+ * @param entries The own string-keyed entries to assign.
220
+ * @returns A mutable null-prototype record for later normalization and freezing.
221
+ */
222
+ var createNullPrototypeRecord = (entries) => {
223
+ const record = Object.create(null);
224
+ for (const [key, value] of entries) record[key] = value;
225
+ return record;
226
+ };
227
+ //#endregion
211
228
  //#region src/diagnostic-utilities/index.ts
212
229
  var CORE_DIAGNOSTIC_MESSAGES = {
213
230
  MOLDEA_AGENT_DESCRIPTION_INVALID: "The agent description is invalid.",
@@ -241,9 +258,7 @@ var CORE_DIAGNOSTIC_MESSAGES = {
241
258
  MOLDEA_DECISION_SUPERSESSION_STATUS_INVALID: "The decision supersession relationship has inconsistent statuses.",
242
259
  MOLDEA_DECISION_TIMESTAMP_MISMATCH: "The decision filename timestamp and createdAt value do not match.",
243
260
  MOLDEA_ENTRY_TYPE_INVALID: "The repository entry type is invalid.",
244
- MOLDEA_RUNTIME_ADAPTER_FORMAT_UNSUPPORTED: "The configured runtime adapter does not support the repository format version.",
245
- MOLDEA_RUNTIME_ADAPTER_UNAVAILABLE: "The declared runtime adapter is unavailable.",
246
- MOLDEA_RUNTIME_ID_INVALID: "The runtime adapter ID is invalid.",
261
+ MOLDEA_RUNTIME_ID_INVALID: "The runtime ID is invalid.",
247
262
  MOLDEA_GLOB_INVALID: "The impact pattern is invalid.",
248
263
  MOLDEA_ID_DUPLICATE: "An ID is duplicated within its required scope.",
249
264
  MOLDEA_ID_INVALID: "The ID is invalid.",
@@ -270,6 +285,12 @@ var CORE_DIAGNOSTIC_MESSAGES = {
270
285
  MOLDEA_PATTERN_DUPLICATE: "The impact pattern is duplicated.",
271
286
  MOLDEA_PROJECT_FILE_EMPTY: "The project file is empty.",
272
287
  MOLDEA_PROJECT_FILE_MISSING: "The project file is missing.",
288
+ MOLDEA_INTEGRATION_BLOCK_MISSING: "The AGENTS.md moldea block is missing.",
289
+ MOLDEA_INTEGRATION_SKILL_MISSING: "The skill installation referenced by the AGENTS.md moldea block was not found.",
290
+ MOLDEA_INTEGRATION_BLOCK_STALE: "The AGENTS.md moldea block differs from its skill installation.",
291
+ MOLDEA_IMPACT_PATTERN_UNMATCHED: "The impact pattern matches no files.",
292
+ MOLDEA_ACCEPTANCE_UNMATCHED: "The warning acceptance matches no reported warning.",
293
+ MOLDEA_REFERENCE_EXPORT_MISSING: "The referenced export is missing.",
273
294
  MOLDEA_REFERENCE_MISSING: "The referenced repository path does not exist.",
274
295
  MOLDEA_REFERENCE_NOT_FILE: "The referenced repository path is not a regular file.",
275
296
  MOLDEA_REFERENCE_SYMLINK: "The referenced repository path is a symlink.",
@@ -299,7 +320,8 @@ var ENTITY_KEYS = [
299
320
  "capabilityId",
300
321
  "decisionId",
301
322
  "variableId",
302
- "adapterId"
323
+ "contextPath",
324
+ "integrationPath"
303
325
  ];
304
326
  var CORE_DIAGNOSTIC_BUDGET = Symbol("core-diagnostic-budget");
305
327
  /** Creates a detached limits view with one diagnostic budget for a complete Core operation. */
@@ -311,11 +333,10 @@ var createCoreOperationResourceLimits = (limits) => {
311
333
  });
312
334
  };
313
335
  /** Registers raw diagnostics against the shared operation budget before normalization. */
314
- var registerCoreDiagnosticCandidates = (limits, amount, operation, fallbackCount = 0, adapterId) => {
336
+ var registerCoreDiagnosticCandidates = (limits, amount, operation, fallbackCount = 0) => {
315
337
  const budget = limits[CORE_DIAGNOSTIC_BUDGET];
316
338
  const currentCount = budget?.count ?? fallbackCount;
317
339
  if (amount > limits.maxDiagnostics - currentCount) throw new CoreOperationException({
318
- ...adapterId === void 0 ? {} : { adapterId },
319
340
  code: "RESOURCE_LIMIT_EXCEEDED",
320
341
  limit: "maxDiagnostics",
321
342
  limitMaximum: limits.maxDiagnostics,
@@ -368,6 +389,12 @@ var serializeDiagnostic = (diagnostic) => {
368
389
  return JSON.stringify([
369
390
  diagnostic.code,
370
391
  diagnostic.severity,
392
+ diagnostic.severity === "warning" ? [
393
+ diagnostic.subject,
394
+ diagnostic.qualifier,
395
+ diagnostic.accepted ?? false,
396
+ diagnostic.reason ?? null
397
+ ] : null,
371
398
  serializeDiagnosticDetails(diagnostic.details),
372
399
  entity,
373
400
  diagnostic.message,
@@ -386,7 +413,27 @@ var readEntityValue = (entity, key) => {
386
413
  return entity?.[key] ?? "";
387
414
  };
388
415
  var compareDiagnostics = (left, right) => {
389
- return compareNullableStrings(left.path, right.path) || compareRanges(left.range, right.range) || compareNullableStrings(left.pointer, right.pointer) || compareExactStrings(left.source, right.source) || compareExactStrings(left.code, right.code) || compareExactStrings(left.severity, right.severity) || compareExactStrings(readEntityValue(left.entity, "agentId"), readEntityValue(right.entity, "agentId")) || compareExactStrings(readEntityValue(left.entity, "capabilityKind"), readEntityValue(right.entity, "capabilityKind")) || compareExactStrings(readEntityValue(left.entity, "capabilityId"), readEntityValue(right.entity, "capabilityId")) || compareExactStrings(readEntityValue(left.entity, "decisionId"), readEntityValue(right.entity, "decisionId")) || compareExactStrings(readEntityValue(left.entity, "variableId"), readEntityValue(right.entity, "variableId")) || compareExactStrings(readEntityValue(left.entity, "adapterId"), readEntityValue(right.entity, "adapterId")) || compareExactStrings(serializeDiagnosticDetails(left.details), serializeDiagnosticDetails(right.details)) || compareExactStrings(left.message, right.message);
416
+ return compareNullableStrings(left.path, right.path) || compareRanges(left.range, right.range) || compareNullableStrings(left.pointer, right.pointer) || compareExactStrings(left.source, right.source) || compareExactStrings(left.code, right.code) || compareExactStrings(left.severity, right.severity) || compareExactStrings(left.severity === "warning" ? JSON.stringify([
417
+ left.subject,
418
+ left.qualifier,
419
+ left.accepted ?? false,
420
+ left.reason ?? null
421
+ ]) : "", right.severity === "warning" ? JSON.stringify([
422
+ right.subject,
423
+ right.qualifier,
424
+ right.accepted ?? false,
425
+ right.reason ?? null
426
+ ]) : "") || compareExactStrings(readEntityValue(left.entity, "agentId"), readEntityValue(right.entity, "agentId")) || compareExactStrings(readEntityValue(left.entity, "capabilityKind"), readEntityValue(right.entity, "capabilityKind")) || compareExactStrings(readEntityValue(left.entity, "capabilityId"), readEntityValue(right.entity, "capabilityId")) || compareExactStrings(readEntityValue(left.entity, "decisionId"), readEntityValue(right.entity, "decisionId")) || compareExactStrings(readEntityValue(left.entity, "variableId"), readEntityValue(right.entity, "variableId")) || compareExactStrings(readEntityValue(left.entity, "contextPath"), readEntityValue(right.entity, "contextPath")) || compareExactStrings(readEntityValue(left.entity, "integrationPath"), readEntityValue(right.entity, "integrationPath")) || compareExactStrings(serializeDiagnosticDetails(left.details), serializeDiagnosticDetails(right.details)) || compareExactStrings(left.message, right.message);
427
+ };
428
+ /** Classifies every catalog code by its documented validation responsibility. */
429
+ var getDiagnosticGroup = (code) => {
430
+ if (code.startsWith("MOLDEA_INTEGRATION_")) return "integration";
431
+ if (code.startsWith("MOLDEA_MIRROR_")) return "mirrors";
432
+ if (/^MOLDEA_(REFERENCE|IMPACT|SYMBOL|CONTEXT|DECISION|RUNTIME_GUIDANCE)_/.test(code)) return "references";
433
+ if (code === "MOLDEA_VARIABLE_ID_INVALID") return "manifest";
434
+ if (/^MOLDEA_(AGENT|VARIABLE|CAPABILITY|TOOL|SKILL|RUNTIME)_/.test(code)) return "agents";
435
+ if (/^MOLDEA_(MANIFEST_MISSING|PROJECT_FILE|ENTRY_TYPE|CANONICAL|TEXT)_/.test(code)) return "discovery";
436
+ return "manifest";
390
437
  };
391
438
  /**
392
439
  * Creates one normalized, immutable Core diagnostic.
@@ -396,7 +443,7 @@ var compareDiagnostics = (left, right) => {
396
443
  var createCoreDiagnostic = (input) => {
397
444
  const message = CORE_DIAGNOSTIC_MESSAGES[input.code];
398
445
  if (message === void 0) throw new TypeError("The requested Core diagnostic is not implemented.");
399
- return freezeRecursively({
446
+ const base = {
400
447
  code: input.code,
401
448
  details: normalizeDiagnosticDetails(input.details),
402
449
  entity: normalizeDiagnosticEntity(input.entity),
@@ -404,12 +451,28 @@ var createCoreDiagnostic = (input) => {
404
451
  path: input.path,
405
452
  pointer: input.pointer ?? null,
406
453
  range: input.range ?? null,
407
- severity: "error",
454
+ group: getDiagnosticGroup(input.code),
408
455
  source: "core"
456
+ };
457
+ if (input.code === "MOLDEA_IMPACT_PATTERN_UNMATCHED" || input.code === "MOLDEA_ACCEPTANCE_UNMATCHED" || input.code === "MOLDEA_INTEGRATION_BLOCK_MISSING" || input.code === "MOLDEA_INTEGRATION_SKILL_MISSING" || input.code === "MOLDEA_INTEGRATION_BLOCK_STALE") {
458
+ if (input.subject === void 0) throw new TypeError("A warning subject is required.");
459
+ return freezeRecursively({
460
+ ...base,
461
+ code: input.code,
462
+ severity: "warning",
463
+ subject: input.subject,
464
+ qualifier: input.qualifier ?? null,
465
+ acceptable: ACCEPTABLE_WARNING_CODES.some((code) => code === input.code)
466
+ });
467
+ }
468
+ return freezeRecursively({
469
+ ...base,
470
+ code: input.code,
471
+ severity: "error"
409
472
  });
410
473
  };
411
474
  /**
412
- * Deduplicates and sorts already-normalized Core and adapter diagnostics.
475
+ * Deduplicates and sorts already-normalized Core diagnostics.
413
476
  * @param candidates The immutable diagnostics to combine.
414
477
  * @returns A frozen deterministic diagnostic collection.
415
478
  */
@@ -426,11 +489,15 @@ var normalizeDiagnostics = (candidates) => {
426
489
  var countDiagnosticsBySeverity = (diagnostics) => {
427
490
  let errorCount = 0;
428
491
  let warningCount = 0;
492
+ let acceptedWarningCount = 0;
429
493
  for (const diagnostic of diagnostics) if (diagnostic.severity === "error") errorCount += 1;
494
+ else if (diagnostic.accepted === true) acceptedWarningCount += 1;
430
495
  else warningCount += 1;
431
496
  return {
432
497
  errorCount,
433
- warningCount
498
+ warningCount,
499
+ acceptedWarningCount,
500
+ diagnosticCount: diagnostics.length
434
501
  };
435
502
  };
436
503
  /**
@@ -473,10 +540,7 @@ var escapeJsonPointerSegment = (value) => {
473
540
  //#region src/options/index.ts
474
541
  /** Creates an operation-local options view with one shared raw-diagnostic budget. */
475
542
  var createCoreOperationOptionsSnapshot = (options) => {
476
- return Object.freeze({
477
- adapters: options.adapters,
478
- limits: createCoreOperationResourceLimits(options.limits)
479
- });
543
+ return Object.freeze({ limits: createCoreOperationResourceLimits(options.limits) });
480
544
  };
481
545
  var RESOURCE_LIMIT_KEYS = [
482
546
  "maxEntries",
@@ -485,28 +549,12 @@ var RESOURCE_LIMIT_KEYS = [
485
549
  "maxManifestBytes",
486
550
  "maxRetainedBytes",
487
551
  "maxDiagnostics",
488
- "maxEvidence"
552
+ "maxCoverage",
553
+ "maxAcceptedWarnings"
489
554
  ];
490
- var STABLE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
491
- var WINDOWS_RESERVED_ID_PATTERN = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u;
492
- var compareStrings = (left, right) => {
493
- if (left < right) return -1;
494
- if (left > right) return 1;
495
- return 0;
496
- };
497
- var invalidAdapter = (adapterId) => {
498
- throw new CoreConfigurationException({
499
- ...adapterId === void 0 ? {} : { adapterId },
500
- code: "INVALID_ADAPTER_DEFINITION",
501
- operation: "create-core"
502
- });
503
- };
504
555
  var isRecord = (value) => {
505
556
  return typeof value === "object" && value !== null && !Array.isArray(value);
506
557
  };
507
- var isStableId = (value) => {
508
- return value.length >= 1 && value.length <= 64 && STABLE_ID_PATTERN.test(value);
509
- };
510
558
  /**
511
559
  * Validates, copies, fills, and freezes all configured resource limits.
512
560
  * @param candidate The untrusted optional limit overrides.
@@ -538,80 +586,19 @@ var normalizeLimits = (candidate) => {
538
586
  return freezeRecursively(normalized);
539
587
  };
540
588
  /**
541
- * Snapshots one adapter definition without freezing caller-owned state.
542
- * @param candidate The untrusted adapter definition.
543
- * @returns A frozen detached adapter snapshot.
544
- * @throws
545
- * - RESERVED_ADAPTER_ID: A reserved runtime adapter ID was supplied.
546
- * - INVALID_ADAPTER_DEFINITION: A runtime adapter definition is invalid.
547
- */
548
- var normalizeAdapter = (candidate) => {
549
- if (!isRecord(candidate)) return invalidAdapter();
550
- const id = candidate["id"];
551
- if (typeof id !== "string" || !isStableId(id) || WINDOWS_RESERVED_ID_PATTERN.test(id)) return invalidAdapter();
552
- if (id === "custom") throw new CoreConfigurationException({
553
- adapterId: id,
554
- code: "RESERVED_ADAPTER_ID",
555
- operation: "create-core"
556
- });
557
- if (!RECOGNIZED_RUNTIME_ADAPTER_IDS.includes(id)) return invalidAdapter(id);
558
- const versions = candidate["supportedRepositoryFormatVersions"];
559
- const inspect = candidate["inspect"];
560
- if (!Array.isArray(versions) || versions.length === 0 || typeof inspect !== "function") return invalidAdapter(id);
561
- const supportedVersions = /* @__PURE__ */ new Set();
562
- for (const version of versions) {
563
- if (!SUPPORTED_REPOSITORY_FORMAT_VERSIONS.includes(version) || supportedVersions.has(version)) return invalidAdapter(id);
564
- supportedVersions.add(version);
565
- }
566
- const inspectReference = inspect;
567
- return freezeRecursively({
568
- id,
569
- inspect: async (context) => inspectReference.call(candidate, context),
570
- supportedRepositoryFormatVersions: [...supportedVersions].sort((left, right) => left - right)
571
- });
572
- };
573
- /**
574
- * Validates, snapshots, and deterministically sorts the configured adapter registry.
575
- * @param candidate The untrusted optional adapter definitions.
576
- * @returns The frozen adapter snapshots in canonical ID order.
589
+ * Validates and snapshots caller-owned Core resource limits.
590
+ * @returns A deeply frozen configuration snapshot.
577
591
  * @throws
578
- * - DUPLICATE_ADAPTER_ID: A runtime adapter ID is registered more than once.
579
- * - RESERVED_ADAPTER_ID: A reserved runtime adapter ID was supplied.
580
- * - INVALID_ADAPTER_DEFINITION: A runtime adapter definition is invalid.
581
- */
582
- var normalizeAdapters = (candidate) => {
583
- if (candidate === void 0) return Object.freeze([]);
584
- if (!Array.isArray(candidate)) return invalidAdapter();
585
- const adapters = Array.from(candidate, (adapter) => normalizeAdapter(adapter));
586
- const ids = /* @__PURE__ */ new Set();
587
- for (const adapter of adapters) {
588
- if (ids.has(adapter.id)) throw new CoreConfigurationException({
589
- adapterId: adapter.id,
590
- code: "DUPLICATE_ADAPTER_ID",
591
- operation: "create-core"
592
- });
593
- ids.add(adapter.id);
594
- }
595
- return freezeRecursively(adapters.sort((left, right) => compareStrings(left.id, right.id)));
596
- };
597
- /**
598
- * Validates and snapshots caller-owned Core construction options.
599
- * @param options The optional adapters and resource-limit overrides.
600
- * @returns A deeply frozen, deterministically ordered configuration snapshot.
601
- * @throws
602
- * - DUPLICATE_ADAPTER_ID: A runtime adapter ID is registered more than once.
603
- * - RESERVED_ADAPTER_ID: A reserved runtime adapter ID was supplied.
604
- * - INVALID_ADAPTER_DEFINITION: A runtime adapter definition is invalid.
605
592
  * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.
606
593
  */
607
594
  var normalizeCoreOptions = (options) => {
608
- if (options !== void 0 && !isRecord(options)) return invalidAdapter();
609
- return freezeRecursively({
610
- adapters: normalizeAdapters(options?.["adapters"]),
611
- limits: normalizeLimits(options?.["limits"])
595
+ if (options !== void 0 && (!isRecord(options) || Reflect.ownKeys(options).some((key) => key !== "limits"))) throw new CoreConfigurationException({
596
+ code: "INVALID_RESOURCE_LIMIT",
597
+ operation: "create-core"
612
598
  });
599
+ return freezeRecursively({ limits: normalizeLimits(options?.["limits"]) });
613
600
  };
614
601
  //#endregion
615
- export { parseDecisionIdFromPath as A, isRepositorySymbol as C, isStableId$1 as D, isSimpleGlob as E, freezeRecursively as F, DEFAULT_CORE_RESOURCE_LIMITS as I, RECOGNIZED_RUNTIME_ADAPTER_IDS as L, sortRepositoryReferences as M, trimRepositoryFormatWhitespace as N, isUnicodeScalarText as O, createNullPrototypeRecord as P, SUPPORTED_REPOSITORY_FORMAT_VERSIONS as R, isNonEmptySingleLine as S, isRuntimeGuidancePath as T, isCanonicalMoldeaPath as _, escapeJsonPointerSegment as a, isDecisionPath as b, normalizeDiagnostics as c, compareExactStrings as d, countUnicodeScalars as f, isCanonicalManifestPath as g, hasUnsupportedGlobMetacharacter as h, createCoreDiagnosticCollector as i, parseManifestPath as j, isVariableId as k, registerCoreDiagnosticCandidates as l, hasSurroundingWhitespace as m, normalizeCoreOptions as n, normalizeDiagnosticDetails as o, hasNonWhitespace as p, countDiagnosticsBySeverity as r, normalizeDiagnosticEntity as s, createCoreOperationOptionsSnapshot as t, serializeDiagnosticDetails as u, isCapabilityDescription as v, isReservedId as w, isMirrorPath as x, isContextPath as y };
602
+ export { ACCEPTABLE_WARNING_CODES as A, isSimpleGlob as C, parseManifestPath as D, parseDecisionIdFromPath as E, RECOGNIZED_RUNTIME_IDS as M, SUPPORTED_REPOSITORY_FORMAT_VERSIONS as N, sortRepositoryReferences as O, isRuntimeGuidancePath as S, isVariableId as T, isDecisionPath as _, escapeJsonPointerSegment as a, isRepositorySymbol as b, freezeRecursively as c, hasNonWhitespace as d, hasUnsupportedGlobMetacharacter as f, isContextPath as g, isCapabilityDescription as h, createCoreDiagnosticCollector as i, DEFAULT_CORE_RESOURCE_LIMITS as j, trimRepositoryFormatWhitespace as k, compareExactStrings as l, isCanonicalMoldeaPath as m, normalizeCoreOptions as n, normalizeDiagnostics as o, isCanonicalManifestPath as p, countDiagnosticsBySeverity as r, createNullPrototypeRecord as s, createCoreOperationOptionsSnapshot as t, countUnicodeScalars as u, isMirrorPath as v, isStableId as w, isReservedId as x, isNonEmptySingleLine as y };
616
603
 
617
- //# sourceMappingURL=options-CxCT3dZU.js.map
604
+ //# sourceMappingURL=options-5x9gu2Qb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-5x9gu2Qb.js","names":[],"sources":["../../src/constants/index.ts","../../src/format-validation/index.ts","../../src/immutable/index.ts","../../src/diagnostic-utilities/index.ts","../../src/options/index.ts"],"sourcesContent":["import type { ICoreResourceLimits } from '../contracts/index.js';\nimport type { IRepositoryFormatVersion } from '../format/index.js';\n\n// warning codes whose findings may be explicitly accepted in the manifest\nexport const ACCEPTABLE_WARNING_CODES = Object.freeze([\n 'MOLDEA_IMPACT_PATTERN_UNMATCHED',\n 'MOLDEA_INTEGRATION_BLOCK_MISSING',\n 'MOLDEA_INTEGRATION_SKILL_MISSING',\n 'MOLDEA_INTEGRATION_BLOCK_STALE',\n] as const);\n\n// runtime labels selecting guidance without asserting SDK compatibility\nexport const RECOGNIZED_RUNTIME_IDS = Object.freeze([\n 'amazon-bedrock',\n 'anthropic',\n 'cerebras',\n 'claude-agent-sdk',\n 'cloudflare-agents',\n 'cohere',\n 'convex-agent',\n 'cursor-sdk',\n 'custom',\n 'deep-agents',\n 'eve',\n 'genkit',\n 'github-copilot-sdk',\n 'google-adk',\n 'google-genai',\n 'groq',\n 'hugging-face',\n 'ibm-watsonx-ai',\n 'langchain',\n 'langgraph',\n 'livekit-agents',\n 'mastra',\n 'microsoft-foundry',\n 'mistral',\n 'node-llama-cpp',\n 'ollama',\n 'openai',\n 'openai-agents-sdk',\n 'openai-codex',\n 'opencode-sdk',\n 'openrouter',\n 'pi-agent',\n 'strands-agents',\n 'tanstack-ai',\n 'vercel-ai-sdk',\n 'voltagent',\n] as const);\n\n// repository-format major versions interpreted by this Core release\nexport const SUPPORTED_REPOSITORY_FORMAT_VERSIONS: readonly IRepositoryFormatVersion[] =\n Object.freeze([1]);\n\n// default safety budgets applied independently to each Core operation\nexport const DEFAULT_CORE_RESOURCE_LIMITS: ICoreResourceLimits = Object.freeze({\n maxDiagnostics: 10_000,\n maxEntries: 100_000,\n maxCoverage: 10_000,\n maxAcceptedWarnings: 256,\n maxFileBytes: 8_388_608,\n maxManifestBytes: 2_097_152,\n maxRetainedBytes: 536_870_912,\n maxTotalBytesRead: 134_217_728,\n});\n","import { isRepositoryPath, parseRepositoryPath, type IRepositoryPath } from '@moldea.ai/repository';\n\nimport type { IRepositoryReference } from '../format/index.js';\n\nconst STABLE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;\nconst VARIABLE_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;\nconst WINDOWS_RESERVED_ID_PATTERN = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u;\nconst LINE_BREAK_CHARACTERS = ['\\n', '\\r', '\\u0085', '\\u2028', '\\u2029'] as const;\nconst UNSUPPORTED_GLOB_PATTERN = /[!?[\\]{}]/u;\n\nconst hasLineBreak = (value: string): boolean => {\n return LINE_BREAK_CHARACTERS.some((lineBreak) => value.includes(lineBreak));\n};\n\n/** Determines whether a code point belongs to the Repository Format version 1 whitespace set. */\nexport const isRepositoryFormatWhitespace = (codePoint: number): boolean => {\n return (\n (codePoint >= 0x0009 && codePoint <= 0x000d) ||\n codePoint === 0x0020 ||\n codePoint === 0x0085 ||\n codePoint === 0x00a0 ||\n codePoint === 0x1680 ||\n (codePoint >= 0x2000 && codePoint <= 0x200a) ||\n codePoint === 0x2028 ||\n codePoint === 0x2029 ||\n codePoint === 0x202f ||\n codePoint === 0x205f ||\n codePoint === 0x3000\n );\n};\n\n/** Compares strings by exact Unicode code-point order without locale behavior. */\nexport const compareExactStrings = (left: string, right: string): number => {\n const leftScalars = left[Symbol.iterator]();\n const rightScalars = right[Symbol.iterator]();\n\n while (true) {\n const leftScalar = leftScalars.next();\n const rightScalar = rightScalars.next();\n\n if (leftScalar.done === true) {\n return rightScalar.done === true ? 0 : -1;\n }\n\n if (rightScalar.done === true) {\n return 1;\n }\n\n const leftCodePoint = leftScalar.value.codePointAt(0) ?? 0;\n const rightCodePoint = rightScalar.value.codePointAt(0) ?? 0;\n\n if (leftCodePoint !== rightCodePoint) {\n return leftCodePoint < rightCodePoint ? -1 : 1;\n }\n }\n};\n\n/** Counts Unicode scalar values in valid JavaScript text. */\nexport const countUnicodeScalars = (value: string): number => {\n const scalars = value[Symbol.iterator]();\n let count = 0;\n\n while (scalars.next().done !== true) {\n count += 1;\n }\n\n return count;\n};\n\n/** Determines whether a JavaScript string contains only Unicode scalar values. */\nexport const isUnicodeScalarText = (value: string): boolean => {\n for (let index = 0; index < value.length; index += 1) {\n const codeUnit = value.charCodeAt(index);\n\n if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {\n if (index + 1 >= value.length) {\n return false;\n }\n\n const nextCodeUnit = value.charCodeAt(index + 1);\n\n if (nextCodeUnit < 0xdc00 || nextCodeUnit > 0xdfff) {\n return false;\n }\n\n index += 1;\n continue;\n }\n\n if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {\n return false;\n }\n }\n\n return true;\n};\n\n/** Determines whether a value contains at least one non-whitespace scalar. */\nexport const hasNonWhitespace = (value: string): boolean => {\n for (const scalar of value) {\n if (!isRepositoryFormatWhitespace(scalar.codePointAt(0) ?? 0)) {\n return true;\n }\n }\n\n return false;\n};\n\n/** Determines whether a value begins or ends with version 1 whitespace. */\nexport const hasSurroundingWhitespace = (value: string): boolean => {\n const firstCodePoint = value.codePointAt(0);\n const lastCodePoint = value.codePointAt(value.length - 1);\n\n return (\n (firstCodePoint !== undefined && isRepositoryFormatWhitespace(firstCodePoint)) ||\n (lastCodePoint !== undefined && isRepositoryFormatWhitespace(lastCodePoint))\n );\n};\n\n/** Removes only Repository Format version 1 whitespace from both edges. */\nexport const trimRepositoryFormatWhitespace = (value: string): string => {\n let start = 0;\n let end = value.length;\n\n while (start < end) {\n const codePoint = value.codePointAt(start);\n\n if (codePoint === undefined || !isRepositoryFormatWhitespace(codePoint)) {\n break;\n }\n\n start += codePoint > 0xffff ? 2 : 1;\n }\n\n while (end > start) {\n const codePoint = value.codePointAt(end - 1);\n\n if (codePoint === undefined || !isRepositoryFormatWhitespace(codePoint)) {\n break;\n }\n\n end -= 1;\n }\n\n return value.slice(start, end);\n};\n\n/** Determines whether a string is non-empty and contains no line break. */\nexport const isNonEmptySingleLine = (value: string): boolean => {\n return value.length > 0 && !hasLineBreak(value);\n};\n\n/** Determines whether a value satisfies stable moldea ID syntax. */\nexport const isStableId = (value: string): boolean => {\n return value.length <= 64 && STABLE_ID_PATTERN.test(value);\n};\n\n/** Determines whether an otherwise valid stable ID is filesystem-reserved. */\nexport const isReservedId = (value: string): boolean => WINDOWS_RESERVED_ID_PATTERN.test(value);\n\n/** Determines whether a value satisfies runtime-variable ID syntax. */\nexport const isVariableId = (value: string): boolean => {\n return value.length <= 64 && VARIABLE_ID_PATTERN.test(value);\n};\n\n/** Determines whether a parsed capability description satisfies version 1 limits. */\nexport const isCapabilityDescription = (value: string): boolean => {\n const scalarLength = countUnicodeScalars(value);\n\n return (\n scalarLength >= 1 &&\n scalarLength <= 1_000 &&\n !hasSurroundingWhitespace(value) &&\n !hasLineBreak(value) &&\n !value.includes('\\0') &&\n !value.includes('{{') &&\n !value.includes('}}')\n );\n};\n\n/** Parses a non-root repository-format logical path without throwing. */\nexport const parseManifestPath = (value: string): IRepositoryPath | null => {\n return value !== '/' && isRepositoryPath(value) ? parseRepositoryPath(value) : null;\n};\n\n/** Determines whether a path is the canonical manifest path. */\nexport const isCanonicalManifestPath = (path: IRepositoryPath): boolean => {\n return path === '/moldea/moldea.yaml';\n};\n\n/** Extracts the stable millisecond ID from one canonical immediate decision path. */\nexport const parseDecisionIdFromPath = (path: IRepositoryPath): string | null => {\n const match = /^\\/moldea\\/decisions\\/(\\d{13})-([a-z0-9]+(?:-[a-z0-9]+)*)\\.md$/u.exec(path);\n const id = match?.[1];\n const slug = match?.[2];\n\n return id !== undefined && slug !== undefined && isStableId(slug) ? id : null;\n};\n\n/** Determines whether a path is an allowed focused-context relationship key. */\nexport const isContextPath = (path: IRepositoryPath, allowProject: boolean): boolean => {\n if (allowProject && path === '/moldea/project.md') {\n return true;\n }\n\n return path.startsWith('/moldea/context/') && path.endsWith('.md');\n};\n\n/** Determines whether a path has the canonical immediate decision filename shape. */\nexport const isDecisionPath = (path: IRepositoryPath): boolean => {\n return parseDecisionIdFromPath(path) !== null;\n};\n\n/** Determines whether a path is canonical runtime guidance. */\nexport const isRuntimeGuidancePath = (path: IRepositoryPath): boolean => {\n return path.startsWith('/moldea/runtimes/') && path.endsWith('.md');\n};\n\n/** Determines whether a mirror path is outside canonical moldea content. */\nexport const isMirrorPath = (path: IRepositoryPath): boolean => {\n return path !== '/moldea' && !path.startsWith('/moldea/');\n};\n\n/** Determines whether an impact path contains prohibited glob metacharacters. */\nexport const hasUnsupportedGlobMetacharacter = (value: string): boolean => {\n return UNSUPPORTED_GLOB_PATTERN.test(value);\n};\n\n/** Determines whether a string satisfies the version 1 simple-glob grammar. */\nexport const isSimpleGlob = (value: string): boolean => {\n if (hasUnsupportedGlobMetacharacter(value) || value.includes('***')) {\n return false;\n }\n\n const segments = value.slice(1).split('/');\n\n if (segments.some((segment) => segment.includes('**') && segment !== '**')) {\n return false;\n }\n\n return value.includes('*') && isRepositoryPath(value.replaceAll('*', 'x'));\n};\n\n/** Determines whether a repository-reference symbol has the common safe shape. */\nexport const isRepositorySymbol = (value: string): boolean => {\n return isNonEmptySingleLine(value) && !value.includes('\\0');\n};\n\n/** Determines whether a canonical moldea reference incorrectly carries a symbol. */\nexport const isCanonicalMoldeaPath = (path: IRepositoryPath): boolean => {\n return path === '/moldea' || path.startsWith('/moldea/');\n};\n\n/** Sorts repository references by path and then optional symbol. */\nexport const sortRepositoryReferences = (\n references: readonly IRepositoryReference[],\n): IRepositoryReference[] => {\n return [...references].sort((left, right) => {\n return (\n compareExactStrings(left.path, right.path) ||\n compareExactStrings(left.symbol ?? '', right.symbol ?? '')\n );\n });\n};\n","/**\n * Recursively freezes a Core-owned value without cloning it.\n * @param value The detached acyclic value whose already-frozen objects are deeply frozen.\n * @returns The same value with every mutable reachable object frozen.\n */\nexport const freezeRecursively = <Value>(value: Value): Readonly<Value> => {\n if (typeof value !== 'object' || value === null || Object.isFrozen(value)) {\n return value;\n }\n\n for (const key of Reflect.ownKeys(value)) {\n const child = (value as Readonly<Record<PropertyKey, unknown>>)[key];\n freezeRecursively(child);\n }\n\n return Object.freeze(value);\n};\n\n/**\n * Creates a record that cannot collide with prototype-chain properties.\n * @param entries The own string-keyed entries to assign.\n * @returns A mutable null-prototype record for later normalization and freezing.\n */\nexport const createNullPrototypeRecord = <Value>(\n entries: Iterable<readonly [string, Value]>,\n): Record<string, Value> => {\n const record = Object.create(null) as Record<string, Value>;\n\n for (const [key, value] of entries) {\n record[key] = value;\n }\n\n return record;\n};\n","import type { IRepositoryPath } from '@moldea.ai/repository';\n\nimport { ACCEPTABLE_WARNING_CODES } from '../constants/index.js';\nimport type { ICoreResourceLimits } from '../contracts/index.js';\nimport type {\n ICoreDiagnostic,\n ICoreDiagnosticCode,\n IDiagnostic,\n IDiagnosticDetails,\n IDiagnosticEntity,\n ISourceRange,\n} from '../diagnostics/index.js';\nimport { CoreOperationException, type ICoreOperation } from '../exceptions/index.js';\nimport { compareExactStrings } from '../format-validation/index.js';\nimport { createNullPrototypeRecord, freezeRecursively } from '../immutable/index.js';\n\nconst CORE_DIAGNOSTIC_MESSAGES: Record<ICoreDiagnosticCode, string> = {\n MOLDEA_AGENT_DESCRIPTION_INVALID: 'The agent description is invalid.',\n MOLDEA_AGENT_DESCRIPTION_MISSING: 'The agent description is missing.',\n MOLDEA_AGENT_DIRECTORY_MISSING: 'The registered agent directory is missing.',\n MOLDEA_AGENT_DIRECTORY_UNREGISTERED: 'The agent directory is not registered.',\n MOLDEA_AGENT_HANDOFF_DESCRIPTION_INVALID: 'The agent handoff description is invalid.',\n MOLDEA_AGENT_IDENTITY_INVALID: 'The agent instruction identity is invalid.',\n MOLDEA_AGENT_INSTRUCTION_EMPTY: 'The agent instruction is empty.',\n MOLDEA_AGENT_INSTRUCTION_MISSING: 'The agent instruction is missing.',\n MOLDEA_CANONICAL_ASSET_SYMLINK: 'The canonical asset is a symlink.',\n MOLDEA_CANONICAL_PATH_UNRECOGNIZED: 'The canonical path is unrecognized.',\n MOLDEA_CAPABILITY_DESCRIPTION_INVALID: 'The capability description is invalid.',\n MOLDEA_CAPABILITY_DESCRIPTION_MISSING: 'The capability description is missing.',\n MOLDEA_CONTEXT_FILE_EMPTY: 'The focused context file is empty.',\n MOLDEA_CONTEXT_PATH_INVALID: 'The context relationship path is invalid.',\n MOLDEA_CONTEXT_RELATIONSHIP_EMPTY: 'The declared relationship has no bindings or impact paths.',\n MOLDEA_DECISION_BODY_EMPTY: 'The decision Markdown body is empty.',\n MOLDEA_DECISION_CREATED_AT_INVALID: 'The decision createdAt value is invalid.',\n MOLDEA_DECISION_FILENAME_INVALID: 'The decision path or filename is invalid.',\n MOLDEA_DECISION_FRONTMATTER_INVALID: 'The decision frontmatter is invalid.',\n MOLDEA_DECISION_FRONTMATTER_MISSING: 'The decision frontmatter or its delimiters are missing.',\n MOLDEA_DECISION_ID_DUPLICATE: 'The decision ID is duplicated.',\n MOLDEA_DECISION_PROPERTY_UNKNOWN: 'The decision frontmatter contains an unknown property.',\n MOLDEA_DECISION_REFERENCE_MISSING: 'The referenced decision does not exist.',\n MOLDEA_DECISION_RELATIONSHIP_INACTIVE: 'The referenced decision is not accepted.',\n MOLDEA_DECISION_SELF_SUPERSESSION: 'The decision supersedes itself.',\n MOLDEA_DECISION_STATUS_INVALID: 'The decision status is invalid.',\n MOLDEA_DECISION_SUPERSEDED_ORPHAN:\n 'The superseded decision has no active supersession relationship.',\n MOLDEA_DECISION_SUPERSESSION_CYCLE: 'The decision supersession graph contains a cycle.',\n MOLDEA_DECISION_SUPERSESSION_STATUS_INVALID:\n 'The decision supersession relationship has inconsistent statuses.',\n MOLDEA_DECISION_TIMESTAMP_MISMATCH:\n 'The decision filename timestamp and createdAt value do not match.',\n MOLDEA_ENTRY_TYPE_INVALID: 'The repository entry type is invalid.',\n MOLDEA_RUNTIME_ID_INVALID: 'The runtime ID is invalid.',\n MOLDEA_GLOB_INVALID: 'The impact pattern is invalid.',\n MOLDEA_ID_DUPLICATE: 'An ID is duplicated within its required scope.',\n MOLDEA_ID_INVALID: 'The ID is invalid.',\n MOLDEA_ID_RESERVED: 'The ID uses a reserved filesystem name.',\n MOLDEA_IMPACT_PATH_MISSING: 'The exact impact path does not exist.',\n MOLDEA_IMPACT_PATH_NOT_FILE: 'The exact impact path is not a regular file.',\n MOLDEA_MANIFEST_MISSING: 'The project manifest is missing.',\n MOLDEA_MANIFEST_PATH_INVALID: 'The manifest path is not the canonical manifest path.',\n MOLDEA_MANIFEST_PROPERTY_UNKNOWN: 'The manifest contains an unknown property.',\n MOLDEA_MANIFEST_ROOT_INVALID: 'The manifest root is not a mapping.',\n MOLDEA_MANIFEST_VALUE_INVALID: 'The manifest value is invalid.',\n MOLDEA_MANIFEST_VERSION_INVALID: 'The manifest version is not a valid integer major version.',\n MOLDEA_MANIFEST_VERSION_MISSING: 'The manifest version is missing.',\n MOLDEA_MANIFEST_VERSION_UNSUPPORTED: 'The manifest version is unsupported.',\n MOLDEA_MIRROR_PATH_DUPLICATE: 'The mirror path is assigned more than once.',\n MOLDEA_MIRROR_PATH_INSIDE_MOLDEA: 'The mirror path is inside /moldea.',\n MOLDEA_MIRROR_PATH_INVALID: 'The mirror path is invalid.',\n MOLDEA_MIRROR_MISSING: 'The declared mirror does not exist.',\n MOLDEA_MIRROR_NOT_FILE: 'The declared mirror is not a regular file.',\n MOLDEA_MIRROR_STALE: 'The declared mirror differs from its canonical instruction.',\n MOLDEA_MIRROR_SYMLINK: 'The declared mirror is a symlink.',\n MOLDEA_PATH_DUPLICATE: 'The path is duplicated.',\n MOLDEA_PATH_INVALID: 'The manifest logical path is invalid.',\n MOLDEA_PATTERN_DUPLICATE: 'The impact pattern is duplicated.',\n MOLDEA_PROJECT_FILE_EMPTY: 'The project file is empty.',\n MOLDEA_PROJECT_FILE_MISSING: 'The project file is missing.',\n MOLDEA_INTEGRATION_BLOCK_MISSING: 'The AGENTS.md moldea block is missing.',\n MOLDEA_INTEGRATION_SKILL_MISSING:\n 'The skill installation referenced by the AGENTS.md moldea block was not found.',\n MOLDEA_INTEGRATION_BLOCK_STALE: 'The AGENTS.md moldea block differs from its skill installation.',\n MOLDEA_IMPACT_PATTERN_UNMATCHED: 'The impact pattern matches no files.',\n MOLDEA_ACCEPTANCE_UNMATCHED: 'The warning acceptance matches no reported warning.',\n MOLDEA_REFERENCE_EXPORT_MISSING: 'The referenced export is missing.',\n MOLDEA_REFERENCE_MISSING: 'The referenced repository path does not exist.',\n MOLDEA_REFERENCE_NOT_FILE: 'The referenced repository path is not a regular file.',\n MOLDEA_REFERENCE_SYMLINK: 'The referenced repository path is a symlink.',\n MOLDEA_RUNTIME_GUIDANCE_EMPTY: 'The runtime guidance is empty.',\n MOLDEA_RUNTIME_GUIDANCE_MISSING: 'The referenced runtime guidance does not exist.',\n MOLDEA_SKILL_IMPLEMENTATION_MISSING: 'The registered skill implementation is missing.',\n MOLDEA_SYMBOL_FORBIDDEN: 'A canonical moldea reference must not include a symbol.',\n MOLDEA_SYMBOL_INVALID: 'The repository-reference symbol is invalid.',\n MOLDEA_TEXT_EMPTY: 'The required text document is empty.',\n MOLDEA_TEXT_INVALID_UNICODE:\n 'The text document contains an invalid Unicode scalar representation.',\n MOLDEA_TEXT_INVALID_UTF8: 'The text document is not valid UTF-8.',\n MOLDEA_TEXT_NUL_FORBIDDEN: 'The text document contains a forbidden NUL character.',\n MOLDEA_TOOL_IMPLEMENTATION_MISSING: 'The registered tool implementation is missing.',\n MOLDEA_VARIABLE_ID_INVALID: 'The runtime-variable ID is invalid.',\n MOLDEA_VARIABLE_PLACEHOLDER_MALFORMED:\n 'The agent instruction contains a malformed runtime-variable placeholder.',\n MOLDEA_VARIABLE_PROVIDER_UNDECLARED:\n 'A variable-provider binding exists for an undeclared variable.',\n MOLDEA_VARIABLE_UNDECLARED: 'The agent instruction references an undeclared runtime variable.',\n MOLDEA_VARIABLE_UNUSED: 'The declared runtime variable is unused by the agent instruction.',\n MOLDEA_YAML_DUPLICATE_KEY: 'The YAML document contains a duplicate mapping key.',\n MOLDEA_YAML_FEATURE_UNSUPPORTED: 'The YAML document uses an unsupported feature.',\n MOLDEA_YAML_MALFORMED: 'The YAML document is malformed.',\n MOLDEA_YAML_MULTIPLE_DOCUMENTS: 'The YAML stream contains more than one document.',\n};\n\nconst ENTITY_KEYS = [\n 'agentId',\n 'capabilityKind',\n 'capabilityId',\n 'decisionId',\n 'variableId',\n 'contextPath',\n 'integrationPath',\n] as const satisfies readonly (keyof IDiagnosticEntity)[];\n\n// private normalized diagnostic construction contracts\nexport interface ICoreDiagnosticInput {\n readonly code: ICoreDiagnosticCode;\n readonly details?: Readonly<Record<string, string | number | boolean | null>>;\n readonly entity?: IDiagnosticEntity | null;\n readonly path: IRepositoryPath | null;\n readonly pointer?: string | null;\n readonly range?: ISourceRange | null;\n readonly subject?: IRepositoryPath;\n readonly qualifier?: string | null;\n}\n\nexport interface ICoreDiagnosticCollector {\n add(input: ICoreDiagnosticInput): void;\n merge(input: ICoreDiagnosticInput): void;\n finalize(): readonly ICoreDiagnostic[];\n readonly size: number;\n}\n\ninterface ICoreDiagnosticBudget {\n count: number;\n}\n\nconst CORE_DIAGNOSTIC_BUDGET = Symbol('core-diagnostic-budget');\n\ntype ICoreOperationResourceLimits = ICoreResourceLimits & {\n readonly [CORE_DIAGNOSTIC_BUDGET]?: ICoreDiagnosticBudget;\n};\n\n/** Creates a detached limits view with one diagnostic budget for a complete Core operation. */\nexport const createCoreOperationResourceLimits = (\n limits: ICoreResourceLimits,\n): ICoreResourceLimits => {\n const operationLimits = limits as ICoreOperationResourceLimits;\n\n if (operationLimits[CORE_DIAGNOSTIC_BUDGET] !== undefined) {\n return limits;\n }\n\n return Object.freeze({\n ...limits,\n [CORE_DIAGNOSTIC_BUDGET]: { count: 0 },\n });\n};\n\n/** Registers raw diagnostics against the shared operation budget before normalization. */\nexport const registerCoreDiagnosticCandidates = (\n limits: ICoreResourceLimits,\n amount: number,\n operation: ICoreOperation,\n fallbackCount = 0,\n): number => {\n const budget = (limits as ICoreOperationResourceLimits)[CORE_DIAGNOSTIC_BUDGET];\n const currentCount = budget?.count ?? fallbackCount;\n\n if (amount > limits.maxDiagnostics - currentCount) {\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: 'maxDiagnostics',\n limitMaximum: limits.maxDiagnostics,\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage: currentCount + amount,\n operation,\n });\n }\n\n if (budget !== undefined) {\n budget.count += amount;\n }\n\n return fallbackCount + amount;\n};\n\nconst compareNullableStrings = (left: string | null, right: string | null): number => {\n if (left === null) {\n return right === null ? 0 : -1;\n }\n\n return right === null ? 1 : compareExactStrings(left, right);\n};\n\n/**\n * Normalizes trusted JSON-scalar diagnostic metadata.\n * @param details The optional detached metadata record.\n * @returns A frozen null-prototype record with canonical key order.\n */\nexport const normalizeDiagnosticDetails = (\n details: Readonly<Record<string, string | number | boolean | null>> | undefined,\n): IDiagnosticDetails => {\n const entries = Object.entries(details ?? {})\n .sort(([left], [right]) => compareExactStrings(left, right))\n .map(\n ([key, value]) =>\n [key, typeof value === 'number' && Object.is(value, -0) ? 0 : value] as const,\n );\n\n return freezeRecursively(createNullPrototypeRecord(entries));\n};\n\n/**\n * Normalizes a trusted diagnostic entity into canonical key order.\n * @param entity The optional diagnostic entity.\n * @returns The frozen normalized entity or `null`.\n */\nexport const normalizeDiagnosticEntity = (\n entity: IDiagnosticEntity | null | undefined,\n): IDiagnosticEntity | null => {\n if (entity === undefined || entity === null) {\n return null;\n }\n\n const entries = ENTITY_KEYS.flatMap((key) => {\n const value = entity[key];\n return value === undefined ? [] : ([[key, value]] as const);\n });\n\n return freezeRecursively(createNullPrototypeRecord(entries) as IDiagnosticEntity);\n};\n\n/** Serializes unordered diagnostic details with explicit exact-code-point key ordering. */\nexport const serializeDiagnosticDetails = (details: IDiagnosticDetails): string => {\n const entries = Object.entries(details).sort(([left], [right]) =>\n compareExactStrings(left, right),\n );\n\n return JSON.stringify(entries);\n};\n\nconst serializeDiagnostic = (diagnostic: IDiagnostic): string => {\n const entity =\n diagnostic.entity === null\n ? null\n : ENTITY_KEYS.map((key) => [key, diagnostic.entity?.[key] ?? null]);\n const range =\n diagnostic.range === null\n ? null\n : [\n diagnostic.range.start.line,\n diagnostic.range.start.column,\n diagnostic.range.start.offset,\n diagnostic.range.end.line,\n diagnostic.range.end.column,\n diagnostic.range.end.offset,\n ];\n\n return JSON.stringify([\n diagnostic.code,\n diagnostic.severity,\n diagnostic.severity === 'warning'\n ? [\n diagnostic.subject,\n diagnostic.qualifier,\n diagnostic.accepted ?? false,\n diagnostic.reason ?? null,\n ]\n : null,\n serializeDiagnosticDetails(diagnostic.details),\n entity,\n diagnostic.message,\n diagnostic.path,\n diagnostic.pointer,\n range,\n diagnostic.source,\n ]);\n};\n\nconst compareRanges = (left: ISourceRange | null, right: ISourceRange | null): number => {\n if (left === null) {\n return right === null ? 0 : -1;\n }\n\n if (right === null) {\n return 1;\n }\n\n return (\n left.start.line - right.start.line ||\n left.start.column - right.start.column ||\n left.start.offset - right.start.offset ||\n left.end.line - right.end.line ||\n left.end.column - right.end.column ||\n left.end.offset - right.end.offset\n );\n};\n\nconst readEntityValue = (\n entity: IDiagnosticEntity | null,\n key: keyof IDiagnosticEntity,\n): string => {\n return entity?.[key] ?? '';\n};\n\nconst compareDiagnostics = (left: IDiagnostic, right: IDiagnostic): number => {\n return (\n compareNullableStrings(left.path, right.path) ||\n compareRanges(left.range, right.range) ||\n compareNullableStrings(left.pointer, right.pointer) ||\n compareExactStrings(left.source, right.source) ||\n compareExactStrings(left.code, right.code) ||\n compareExactStrings(left.severity, right.severity) ||\n compareExactStrings(\n left.severity === 'warning'\n ? JSON.stringify([\n left.subject,\n left.qualifier,\n left.accepted ?? false,\n left.reason ?? null,\n ])\n : '',\n right.severity === 'warning'\n ? JSON.stringify([\n right.subject,\n right.qualifier,\n right.accepted ?? false,\n right.reason ?? null,\n ])\n : '',\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'agentId'),\n readEntityValue(right.entity, 'agentId'),\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'capabilityKind'),\n readEntityValue(right.entity, 'capabilityKind'),\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'capabilityId'),\n readEntityValue(right.entity, 'capabilityId'),\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'decisionId'),\n readEntityValue(right.entity, 'decisionId'),\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'variableId'),\n readEntityValue(right.entity, 'variableId'),\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'contextPath'),\n readEntityValue(right.entity, 'contextPath'),\n ) ||\n compareExactStrings(\n readEntityValue(left.entity, 'integrationPath'),\n readEntityValue(right.entity, 'integrationPath'),\n ) ||\n compareExactStrings(\n serializeDiagnosticDetails(left.details),\n serializeDiagnosticDetails(right.details),\n ) ||\n compareExactStrings(left.message, right.message)\n );\n};\n\n/** Classifies every catalog code by its documented validation responsibility. */\nconst getDiagnosticGroup = (code: ICoreDiagnosticCode): ICoreDiagnostic['group'] => {\n if (code.startsWith('MOLDEA_INTEGRATION_')) return 'integration';\n if (code.startsWith('MOLDEA_MIRROR_')) return 'mirrors';\n if (/^MOLDEA_(REFERENCE|IMPACT|SYMBOL|CONTEXT|DECISION|RUNTIME_GUIDANCE)_/.test(code))\n return 'references';\n if (code === 'MOLDEA_VARIABLE_ID_INVALID') return 'manifest';\n if (/^MOLDEA_(AGENT|VARIABLE|CAPABILITY|TOOL|SKILL|RUNTIME)_/.test(code)) return 'agents';\n if (/^MOLDEA_(MANIFEST_MISSING|PROJECT_FILE|ENTRY_TYPE|CANONICAL|TEXT)_/.test(code))\n return 'discovery';\n return 'manifest';\n};\n\n/**\n * Creates one normalized, immutable Core diagnostic.\n * @param input The trusted Core-owned diagnostic fields to normalize.\n * @returns A deeply immutable public diagnostic value.\n */\nexport const createCoreDiagnostic = (input: ICoreDiagnosticInput): ICoreDiagnostic => {\n const message = CORE_DIAGNOSTIC_MESSAGES[input.code];\n\n if (message === undefined) {\n throw new TypeError('The requested Core diagnostic is not implemented.');\n }\n\n const base = {\n code: input.code,\n details: normalizeDiagnosticDetails(input.details),\n entity: normalizeDiagnosticEntity(input.entity),\n message,\n path: input.path,\n pointer: input.pointer ?? null,\n range: input.range ?? null,\n group: getDiagnosticGroup(input.code),\n source: 'core' as const,\n };\n if (\n input.code === 'MOLDEA_IMPACT_PATTERN_UNMATCHED' ||\n input.code === 'MOLDEA_ACCEPTANCE_UNMATCHED' ||\n input.code === 'MOLDEA_INTEGRATION_BLOCK_MISSING' ||\n input.code === 'MOLDEA_INTEGRATION_SKILL_MISSING' ||\n input.code === 'MOLDEA_INTEGRATION_BLOCK_STALE'\n ) {\n if (input.subject === undefined) throw new TypeError('A warning subject is required.');\n return freezeRecursively({\n ...base,\n code: input.code,\n severity: 'warning' as const,\n subject: input.subject,\n qualifier: input.qualifier ?? null,\n acceptable: ACCEPTABLE_WARNING_CODES.some((code) => code === input.code),\n });\n }\n return freezeRecursively({ ...base, code: input.code, severity: 'error' as const });\n};\n\n/**\n * Deduplicates and sorts already-normalized Core diagnostics.\n * @param candidates The immutable diagnostics to combine.\n * @returns A frozen deterministic diagnostic collection.\n */\nexport const normalizeDiagnostics = (\n candidates: readonly IDiagnostic[],\n): readonly IDiagnostic[] => {\n const diagnostics = new Map<string, IDiagnostic>();\n\n for (const diagnostic of candidates) {\n const key = serializeDiagnostic(diagnostic);\n\n if (diagnostics.has(key)) {\n continue;\n }\n\n diagnostics.set(key, diagnostic);\n }\n\n return freezeRecursively([...diagnostics.values()].sort(compareDiagnostics));\n};\n\n/** Counts the complete normalized diagnostic result by severity once. */\nexport const countDiagnosticsBySeverity = (\n diagnostics: readonly IDiagnostic[],\n): {\n readonly errorCount: number;\n readonly warningCount: number;\n readonly acceptedWarningCount: number;\n readonly diagnosticCount: number;\n} => {\n let errorCount = 0;\n let warningCount = 0;\n let acceptedWarningCount = 0;\n\n for (const diagnostic of diagnostics) {\n if (diagnostic.severity === 'error') {\n errorCount += 1;\n } else if (diagnostic.accepted === true) {\n acceptedWarningCount += 1;\n } else {\n warningCount += 1;\n }\n }\n\n return { errorCount, warningCount, acceptedWarningCount, diagnosticCount: diagnostics.length };\n};\n\n/**\n * Creates a deterministic, deduplicating diagnostic collector for one operation.\n * @param limits The Core resource limits governing diagnostic output.\n * @param operation The operation reported by resource failures.\n * @returns A collector that freezes and sorts its final diagnostic array.\n */\nexport const createCoreDiagnosticCollector = (\n limits: ICoreResourceLimits,\n operation: ICoreOperation,\n): ICoreDiagnosticCollector => {\n const diagnostics = new Map<string, ICoreDiagnostic>();\n let proposalCount = 0;\n let fallbackRawCount = 0;\n\n const retain = (input: ICoreDiagnosticInput): void => {\n const diagnostic = createCoreDiagnostic(input);\n const key = serializeDiagnostic(diagnostic);\n\n proposalCount += 1;\n\n if (!diagnostics.has(key)) {\n diagnostics.set(key, diagnostic);\n }\n };\n\n return {\n add: (input): void => {\n fallbackRawCount = registerCoreDiagnosticCandidates(limits, 1, operation, fallbackRawCount);\n retain(input);\n },\n merge: retain,\n finalize: (): readonly ICoreDiagnostic[] => normalizeDiagnostics([...diagnostics.values()]),\n get size(): number {\n return proposalCount;\n },\n };\n};\n\n/**\n * Escapes one JSON Pointer reference token.\n * @param value The decoded mapping key or array index token.\n * @returns The RFC 6901 escaped token.\n */\nexport const escapeJsonPointerSegment = (value: string): string => {\n return value.replaceAll('~', '~0').replaceAll('/', '~1');\n};\n","import { DEFAULT_CORE_RESOURCE_LIMITS } from '../constants/index.js';\nimport type { ICoreOptions, ICoreResourceLimits } from '../contracts/index.js';\nimport { createCoreOperationResourceLimits } from '../diagnostic-utilities/index.js';\nimport { CoreConfigurationException } from '../exceptions/index.js';\nimport { freezeRecursively } from '../immutable/index.js';\n\n// complete immutable Core configuration\nexport interface ICoreOptionsSnapshot {\n readonly limits: ICoreResourceLimits;\n}\n\n/** Creates an operation-local options view with one shared raw-diagnostic budget. */\nexport const createCoreOperationOptionsSnapshot = (\n options: ICoreOptionsSnapshot,\n): ICoreOptionsSnapshot => {\n return Object.freeze({\n limits: createCoreOperationResourceLimits(options.limits),\n });\n};\n\nconst RESOURCE_LIMIT_KEYS = [\n 'maxEntries',\n 'maxTotalBytesRead',\n 'maxFileBytes',\n 'maxManifestBytes',\n 'maxRetainedBytes',\n 'maxDiagnostics',\n 'maxCoverage',\n 'maxAcceptedWarnings',\n] as const satisfies readonly (keyof ICoreResourceLimits)[];\n\nconst isRecord = (value: unknown): value is Readonly<Record<string, unknown>> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n/**\n * Validates, copies, fills, and freezes all configured resource limits.\n * @param candidate The untrusted optional limit overrides.\n * @returns The complete frozen resource limits.\n * @throws\n * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.\n */\nconst normalizeLimits = (candidate: unknown): ICoreResourceLimits => {\n if (candidate === undefined) {\n return DEFAULT_CORE_RESOURCE_LIMITS;\n }\n\n if (!isRecord(candidate)) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n\n const knownKeys = new Set<string>(RESOURCE_LIMIT_KEYS);\n\n if (Object.keys(candidate).some((key) => !knownKeys.has(key))) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n\n const normalized: ICoreResourceLimits = {\n ...DEFAULT_CORE_RESOURCE_LIMITS,\n };\n\n for (const key of RESOURCE_LIMIT_KEYS) {\n const value = candidate[key];\n\n if (value === undefined) {\n continue;\n }\n\n if (!Number.isSafeInteger(value) || (value as number) <= 0) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n\n (normalized as Record<keyof ICoreResourceLimits, number>)[key] = value as number;\n }\n\n return freezeRecursively(normalized);\n};\n\n/**\n * Validates and snapshots caller-owned Core resource limits.\n * @returns A deeply frozen configuration snapshot.\n * @throws\n * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.\n */\nexport const normalizeCoreOptions = (options: ICoreOptions | undefined): ICoreOptionsSnapshot => {\n if (\n options !== undefined &&\n (!isRecord(options) || Reflect.ownKeys(options).some((key) => key !== 'limits'))\n ) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n return freezeRecursively({ limits: normalizeLimits(options?.['limits']) });\n};\n"],"mappings":";;;AAIA,IAAa,2BAA2B,OAAO,OAAO;CACpD;CACA;CACA;CACA;AACF,CAAU;AAGV,IAAa,yBAAyB,OAAO,OAAO;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAU;AAGV,IAAa,uCACX,OAAO,OAAO,CAAC,CAAC,CAAC;AAGnB,IAAa,+BAAoD,OAAO,OAAO;CAC7E,gBAAgB;CAChB,YAAY;CACZ,aAAa;CACb,qBAAqB;CACrB,cAAc;CACd,kBAAkB;CAClB,kBAAkB;CAClB,mBAAmB;AACrB,CAAC;;;AC7DD,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,8BAA8B;AACpC,IAAM,wBAAwB;CAAC;CAAM;CAAM;CAAU;CAAU;AAAQ;AACvE,IAAM,2BAA2B;AAEjC,IAAM,gBAAgB,UAA2B;CAC/C,OAAO,sBAAsB,MAAM,cAAc,MAAM,SAAS,SAAS,CAAC;AAC5E;;AAGA,IAAa,gCAAgC,cAA+B;CAC1E,OACG,aAAa,KAAU,aAAa,MACrC,cAAc,MACd,cAAc,OACd,cAAc,OACd,cAAc,QACb,aAAa,QAAU,aAAa,QACrC,cAAc,QACd,cAAc,QACd,cAAc,QACd,cAAc,QACd,cAAc;AAElB;;AAGA,IAAa,uBAAuB,MAAc,UAA0B;CAC1E,MAAM,cAAc,KAAK,OAAO,SAAS,CAAC;CAC1C,MAAM,eAAe,MAAM,OAAO,S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;;AASA,IAAM,mBAAmB,cAA4C;CACnE,IAAI,cAAc,KAAA,GAChB,OAAO;CAGT,IAAI,CAAC,SAAS,SAAS,GACrB,MAAM,IAAI,2BAA2B;EACnC,MAAM;EACN,WAAW;CACb,CAAC;CAGH,MAAM,YAAY,IAAI,IAAY,mBAAmB;CAErD,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,IAAI,GAAG,CAAC,GAC1D,MAAM,IAAI,2BAA2B;EACnC,MAAM;EACN,WAAW;CACb,CAAC;CAGH,MAAM,aAAkC,EACtC,GAAG,6BACL;CAEA,KAAK,MAAM,OAAO,qBAAqB;EACrC,MAAM,QAAQ,UAAU;EAExB,IAAI,UAAU,KAAA,GACZ;EAGF,IAAI,CAAC,OAAO,cAAc,KAAK,KAAM,SAAoB,GACvD,MAAM,IAAI,2BAA2B;GACnC,MAAM;GACN,WAAW;EACb,CAAC;EAGH,WAA0D,OAAO;CACnE;CAEA,OAAO,kBAAkB,UAAU;AACrC;;;;;;;AAQA,IAAa,wBAAwB,YAA4D;CAC/F,IACE,YAAY,KAAA,MACX,CAAC,SAAS,OAAO,KAAK,QAAQ,QAAQ,OAAO,CAAC,CAAC,MAAM,QAAQ,QAAQ,QAAQ,IAE9E,MAAM,IAAI,2BAA2B;EACnC,MAAM;EACN,WAAW;CACb,CAAC;CAEH,OAAO,kBAAkB,EAAE,QAAQ,gBAAgB,UAAU,SAAS,EAAE,CAAC;AAC3E"}
@@ -1,4 +1,4 @@
1
- import "./errors-BQI1DEqf.js";
1
+ import "./errors-BE4DS3Ak.js";
2
2
  import { RepositorySourceException, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
3
3
  import { Buffer } from "node:buffer";
4
4
  //#region src/node-inspection/repository-rpc.ts
@@ -121,4 +121,4 @@ var executeRepositoryRpc = async (reader, request, signal) => {
121
121
  //#endregion
122
122
  export { parseRpcFilePage as i, parseRpcEntry as n, parseRpcEntryPage as r, executeRepositoryRpc as t };
123
123
 
124
- //# sourceMappingURL=repository-rpc-BWi6X1la.js.map
124
+ //# sourceMappingURL=repository-rpc-B_y0Kspf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository-rpc-BWi6X1la.js","names":[],"sources":["../../src/node-inspection/repository-rpc.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nimport {\n isRepositoryPath,\n parseRepositoryPath,\n RepositorySourceException,\n type IRepositoryEntry,\n type IRepositoryEntryPage,\n type IRepositoryFilePage,\n type IRepositoryReader,\n type IRepositorySnapshot,\n} from '@moldea.ai/repository';\n\nimport { NODE_INSPECTION_FILE_PAGE_BYTES } from './constants.js';\nimport type { INodeReaderRequest } from './types.js';\n\nconst invalidSource = (): never => {\n throw new RepositorySourceException({\n code: 'INVALID_SOURCE_DATA',\n operation: 'create-reader',\n path: null,\n retryable: false,\n });\n};\nconst isRecord = (input: unknown): input is Record<string, unknown> =>\n input !== null && typeof input === 'object' && !Array.isArray(input);\nconst isInteger = (input: unknown): input is number =>\n typeof input === 'number' && Number.isSafeInteger(input) && input >= 0;\nconst keysMatch = (input: Record<string, unknown>, keys: string[]): boolean =>\n Object.keys(input).length === keys.length && keys.every((key) => Object.hasOwn(input, key));\n\n/** Validates the immutable source identity without coercing unknown boundary fields. */\nconst parseSnapshot = (input: unknown): IRepositorySnapshot => {\n if (\n !isRecord(input) ||\n !keysMatch(input, ['id', 'sourceKind']) ||\n typeof input['id'] !== 'string' ||\n input['id'].length === 0 ||\n typeof input['sourceKind'] !== 'string' ||\n input['sourceKind'].length === 0\n )\n return invalidSource();\n return { id: input['id'], sourceKind: input['sourceKind'] };\n};\n\n/** Converts one validated metadata-only repository entry. */\nexport const parseRpcEntry = (input: unknown): IRepositoryEntry | null => {\n if (input === null) return null;\n if (\n !isRecord(input) ||\n !keysMatch(input, ['path', 'type', 'byteLength', 'contentIdentity']) ||\n !isRepositoryPath(input['path']) ||\n (input['type'] !== 'file' && input['type'] !== 'directory' && input['type'] !== 'symlink') ||\n (input['byteLength'] !== null && !isInteger(input['byteLength'])) ||\n (input['contentIdentity'] !== null && typeof input['contentIdentity'] !== 'string')\n )\n return invalidSource();\n return {\n path: input['path'],\n type: input['type'],\n byteLength: input['byteLength'],\n contentIdentity: input['contentIdentity'],\n };\n};\n\n/** Converts a bounded listing page while retaining snapshot and continuation contracts. */\nexport const parseRpcEntryPage = (input: unknown): IRepositoryEntryPage => {\n if (\n !isRecord(input) ||\n !keysMatch(input, ['entries', 'isComplete', 'nextCursor', 'snapshot']) ||\n !Array.isArray(input['entries']) ||\n input['entries'].length > 128 ||\n typeof input['isComplete'] !== 'boolean' ||\n (input['nextCursor'] !== null && typeof input['nextCursor'] !== 'string')\n )\n return invalidSource();\n const entries: IRepositoryEntry[] = [];\n for (const candidate of input['entries']) {\n const entry = parseRpcEntry(candidate);\n if (entry === null) return invalidSource();\n entries.push(entry);\n }\n return {\n entries,\n isComplete: input['isComplete'],\n nextCursor: input['nextCursor'],\n snapshot: parseSnapshot(input['snapshot']),\n };\n};\n\n/** Decodes only an admitted 64 KiB binary page, never a complete repository file. */\nexport const parseRpcFilePage = (input: unknown): IRepositoryFilePage => {\n if (\n !isRecord(input) ||\n !keysMatch(input, ['bytes', 'isComplete', 'nextOffset', 'offset', 'snapshot', 'totalBytes']) ||\n typeof input['bytes'] !== 'string' ||\n input['bytes'].length > Math.ceil(NODE_INSPECTION_FILE_PAGE_BYTES / 3) * 4 ||\n !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input['bytes']) ||\n typeof input['isComplete'] !== 'boolean' ||\n !isInteger(input['offset']) ||\n !isInteger(input['totalBytes']) ||\n (input['nextOffset'] !== null && !isInteger(input['nextOffset']))\n )\n return invalidSource();\n const bytes = Buffer.from(input['bytes'], 'base64');\n if (\n bytes.byteLength > NODE_INSPECTION_FILE_PAGE_BYTES ||\n bytes.toString('base64') !== input['bytes']\n )\n return invalidSource();\n return {\n bytes,\n isComplete: input['isComplete'],\n nextOffset: input['nextOffset'],\n offset: input['offset'],\n snapshot: parseSnapshot(input['snapshot']),\n totalBytes: input['totalBytes'],\n };\n};\n\n/**\n * Calls the real reader with inspection cancellation and returns a bounded transport value.\n * Reader failures propagate unchanged to the parent inspection owner.\n * @returns A metadata value or encoded byte page after actual reader settlement.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - ENTRY_NOT_FOUND: The requested repository entry was not found.\n * - ENTRY_NOT_FILE: The requested repository entry is not a file.\n * - ENTRY_NOT_DIRECTORY: The requested repository entry is not a directory.\n * - INVALID_PAGE_REQUEST: The repository page request is invalid.\n * - ACCESS_DENIED: Access to the repository source was denied.\n * - SOURCE_UNAVAILABLE: The repository source is unavailable.\n * - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.\n * - PROVIDER_INCOMPLETE: The repository provider cannot expose a complete result.\n * - INVALID_SOURCE_DATA: The repository source returned invalid data.\n * - RESOURCE_LIMIT_EXCEEDED: A named repository resource limit was exceeded.\n * - ABORTED: The repository operation was aborted.\n */\nexport const executeRepositoryRpc = async (\n reader: IRepositoryReader,\n request: INodeReaderRequest,\n signal: AbortSignal,\n): Promise<unknown> => {\n if (request.method === 'getEntry')\n return parseRpcEntry(await reader.getEntry(parseRepositoryPath(request.path), { signal }));\n if (request.method === 'listEntriesPage')\n return parseRpcEntryPage(\n await reader.listEntriesPage({\n maxEntries: request.maxEntries,\n signal,\n ...(request.prefix === undefined ? {} : { prefix: parseRepositoryPath(request.prefix) }),\n ...(request.cursor === undefined ? {} : { cursor: request.cursor }),\n }),\n );\n const page = await reader.readFilePage(parseRepositoryPath(request.path), {\n maxBytes: request.maxBytes,\n offset: request.offset,\n signal,\n });\n if (!(page.bytes instanceof Uint8Array) || page.bytes.byteLength > request.maxBytes)\n return invalidSource();\n const result = {\n ...page,\n bytes: Buffer.from(page.bytes.buffer, page.bytes.byteOffset, page.bytes.byteLength).toString(\n 'base64',\n ),\n };\n parseRpc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I,QAAQ,WAAW,YACrB,OAAO,cAAc,MAAM,OAAO,SAAS,oBAAoB,QAAQ,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3F,IAAI,QAAQ,WAAW,mBACrB,OAAO,kBACL,MAAM,OAAO,gBAAgB;EAC3B,YAAY,QAAQ;EACpB;EACA,GAAI,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,oBAAoB,QAAQ,MAAM,EAAE;EACtF,GAAI,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;CACnE,CAAC,CACH;CACF,MAAM,OAAO,MAAM,OAAO,aAAa,oBAAoB,QAAQ,IAAI,GAAG;EACxE,UAAU,QAAQ;EAClB,QAAQ,QAAQ;EAChB;CACF,CAAC;CACD,IAAI,EAAE,KAAK,iBAAiB,eAAe,KAAK,MAAM,aAAa,QAAQ,UACzE,OAAO,cAAc;CACvB,MAAM,SAAS;EACb,GAAG;EACH,OAAO,OAAO,KAAK,KAAK,MAAM,QAAQ,KAAK,MAAM,YAAY,KAAK,MAAM,UAAU,CAAC,CAAC,SAClF,QACF;CACF;CACA,iBAAiB,MAAM;CACvB,OAAO;AACT"}
1
+ {"version":3,"file":"repository-rpc-B_y0Kspf.js","names":[],"sources":["../../src/node-inspection/repository-rpc.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nimport {\n isRepositoryPath,\n parseRepositoryPath,\n RepositorySourceException,\n type IRepositoryEntry,\n type IRepositoryEntryPage,\n type IRepositoryFilePage,\n type IRepositoryReader,\n type IRepositorySnapshot,\n} from '@moldea.ai/repository';\n\nimport { NODE_INSPECTION_FILE_PAGE_BYTES } from './constants.js';\nimport type { INodeReaderRequest } from './types.js';\n\nconst invalidSource = (): never => {\n throw new RepositorySourceException({\n code: 'INVALID_SOURCE_DATA',\n operation: 'create-reader',\n path: null,\n retryable: false,\n });\n};\nconst isRecord = (input: unknown): input is Record<string, unknown> =>\n input !== null && typeof input === 'object' && !Array.isArray(input);\nconst isInteger = (input: unknown): input is number =>\n typeof input === 'number' && Number.isSafeInteger(input) && input >= 0;\nconst keysMatch = (input: Record<string, unknown>, keys: string[]): boolean =>\n Object.keys(input).length === keys.length && keys.every((key) => Object.hasOwn(input, key));\n\n/** Validates the immutable source identity without coercing unknown boundary fields. */\nconst parseSnapshot = (input: unknown): IRepositorySnapshot => {\n if (\n !isRecord(input) ||\n !keysMatch(input, ['id', 'sourceKind']) ||\n typeof input['id'] !== 'string' ||\n input['id'].length === 0 ||\n typeof input['sourceKind'] !== 'string' ||\n input['sourceKind'].length === 0\n )\n return invalidSource();\n return { id: input['id'], sourceKind: input['sourceKind'] };\n};\n\n/** Converts one validated metadata-only repository entry. */\nexport const parseRpcEntry = (input: unknown): IRepositoryEntry | null => {\n if (input === null) return null;\n if (\n !isRecord(input) ||\n !keysMatch(input, ['path', 'type', 'byteLength', 'contentIdentity']) ||\n !isRepositoryPath(input['path']) ||\n (input['type'] !== 'file' && input['type'] !== 'directory' && input['type'] !== 'symlink') ||\n (input['byteLength'] !== null && !isInteger(input['byteLength'])) ||\n (input['contentIdentity'] !== null && typeof input['contentIdentity'] !== 'string')\n )\n return invalidSource();\n return {\n path: input['path'],\n type: input['type'],\n byteLength: input['byteLength'],\n contentIdentity: input['contentIdentity'],\n };\n};\n\n/** Converts a bounded listing page while retaining snapshot and continuation contracts. */\nexport const parseRpcEntryPage = (input: unknown): IRepositoryEntryPage => {\n if (\n !isRecord(input) ||\n !keysMatch(input, ['entries', 'isComplete', 'nextCursor', 'snapshot']) ||\n !Array.isArray(input['entries']) ||\n input['entries'].length > 128 ||\n typeof input['isComplete'] !== 'boolean' ||\n (input['nextCursor'] !== null && typeof input['nextCursor'] !== 'string')\n )\n return invalidSource();\n const entries: IRepositoryEntry[] = [];\n for (const candidate of input['entries']) {\n const entry = parseRpcEntry(candidate);\n if (entry === null) return invalidSource();\n entries.push(entry);\n }\n return {\n entries,\n isComplete: input['isComplete'],\n nextCursor: input['nextCursor'],\n snapshot: parseSnapshot(input['snapshot']),\n };\n};\n\n/** Decodes only an admitted 64 KiB binary page, never a complete repository file. */\nexport const parseRpcFilePage = (input: unknown): IRepositoryFilePage => {\n if (\n !isRecord(input) ||\n !keysMatch(input, ['bytes', 'isComplete', 'nextOffset', 'offset', 'snapshot', 'totalBytes']) ||\n typeof input['bytes'] !== 'string' ||\n input['bytes'].length > Math.ceil(NODE_INSPECTION_FILE_PAGE_BYTES / 3) * 4 ||\n !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input['bytes']) ||\n typeof input['isComplete'] !== 'boolean' ||\n !isInteger(input['offset']) ||\n !isInteger(input['totalBytes']) ||\n (input['nextOffset'] !== null && !isInteger(input['nextOffset']))\n )\n return invalidSource();\n const bytes = Buffer.from(input['bytes'], 'base64');\n if (\n bytes.byteLength > NODE_INSPECTION_FILE_PAGE_BYTES ||\n bytes.toString('base64') !== input['bytes']\n )\n return invalidSource();\n return {\n bytes,\n isComplete: input['isComplete'],\n nextOffset: input['nextOffset'],\n offset: input['offset'],\n snapshot: parseSnapshot(input['snapshot']),\n totalBytes: input['totalBytes'],\n };\n};\n\n/**\n * Calls the real reader with inspection cancellation and returns a bounded transport value.\n * Reader failures propagate unchanged to the parent inspection owner.\n * @returns A metadata value or encoded byte page after actual reader settlement.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - ENTRY_NOT_FOUND: The requested repository entry was not found.\n * - ENTRY_NOT_FILE: The requested repository entry is not a file.\n * - ENTRY_NOT_DIRECTORY: The requested repository entry is not a directory.\n * - INVALID_PAGE_REQUEST: The repository page request is invalid.\n * - ACCESS_DENIED: Access to the repository source was denied.\n * - SOURCE_UNAVAILABLE: The repository source is unavailable.\n * - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.\n * - PROVIDER_INCOMPLETE: The repository provider cannot expose a complete result.\n * - INVALID_SOURCE_DATA: The repository source returned invalid data.\n * - RESOURCE_LIMIT_EXCEEDED: A named repository resource limit was exceeded.\n * - ABORTED: The repository operation was aborted.\n */\nexport const executeRepositoryRpc = async (\n reader: IRepositoryReader,\n request: INodeReaderRequest,\n signal: AbortSignal,\n): Promise<unknown> => {\n if (request.method === 'getEntry')\n return parseRpcEntry(await reader.getEntry(parseRepositoryPath(request.path), { signal }));\n if (request.method === 'listEntriesPage')\n return parseRpcEntryPage(\n await reader.listEntriesPage({\n maxEntries: request.maxEntries,\n signal,\n ...(request.prefix === undefined ? {} : { prefix: parseRepositoryPath(request.prefix) }),\n ...(request.cursor === undefined ? {} : { cursor: request.cursor }),\n }),\n );\n const page = await reader.readFilePage(parseRepositoryPath(request.path), {\n maxBytes: request.maxBytes,\n offset: request.offset,\n signal,\n });\n if (!(page.bytes instanceof Uint8Array) || page.bytes.byteLength > request.maxBytes)\n return invalidSource();\n const result = {\n ...page,\n bytes: Buffer.from(page.bytes.buffer, page.bytes.byteOffset, page.bytes.byteLength).toString(\n 'base64',\n ),\n };\n parseRpcFilePage(result);\n return result;\n};\n"],"mappings":";;;;AAgBA,IAAM,sBAA6B;CACjC,MAAM,IAAI,0BAA0B;EAClC,MAAM;EACN,WAAW;EACX,MAAM;EACN,WAAW;CACb,CAAC;AACH;AACA,IAAM,YAAY,UAChB,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE,IAAM,aAAa,UACjB,OAAO,UAAU,YAAY,OAAO,cAAc,KAAK,KAAK,SAAS;AACvE,IAAM,aAAa,OAAgC,SACjD,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW,KAAK,UAAU,KAAK,OAAO,QAAQ,OAAO,OAAO,OAAO,GAAG,CAAC;;AAG5F,IAAM,iBAAiB,UAAwC;CAC7D,IACE,CAAC,SAAS,KAAK,KACf,CAAC,UAAU,OAAO,CAAC,MAAM,YAAY,CAAC,KACtC,OAAO,MAAM,UAAU,YACvB,MAAM,KAAK,CAAC,WAAW,KACv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