@moldea.ai/core 5.0.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +12 -11
  2. package/dist/analysis-worker.js +180 -0
  3. package/dist/analysis-worker.js.map +1 -0
  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-Cdeiu6xG.js +3364 -0
  7. package/dist/chunks/core-Cdeiu6xG.js.map +1 -0
  8. package/dist/chunks/errors-BE4DS3Ak.js +435 -0
  9. package/dist/chunks/errors-BE4DS3Ak.js.map +1 -0
  10. package/dist/chunks/{exceptions-HS9ofVy2.js → exceptions-IXsorE8t.js} +27 -28
  11. package/dist/chunks/exceptions-IXsorE8t.js.map +1 -0
  12. package/dist/chunks/lifecycle-D_RvxhDC.js +67 -0
  13. package/dist/chunks/lifecycle-D_RvxhDC.js.map +1 -0
  14. package/dist/chunks/options-5x9gu2Qb.js +604 -0
  15. package/dist/chunks/options-5x9gu2Qb.js.map +1 -0
  16. package/dist/chunks/repository-rpc-B_y0Kspf.js +124 -0
  17. package/dist/chunks/repository-rpc-B_y0Kspf.js.map +1 -0
  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 +37 -27
  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 +25 -10
  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 +5 -3
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +4 -5776
  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 +4 -0
  67. package/dist/node/index.d.ts.map +1 -0
  68. package/dist/node-inspection/analysis-worker.d.ts +2 -0
  69. package/dist/node-inspection/analysis-worker.d.ts.map +1 -0
  70. package/dist/node-inspection/client.d.ts +28 -0
  71. package/dist/node-inspection/client.d.ts.map +1 -0
  72. package/dist/node-inspection/constants.d.ts +21 -0
  73. package/dist/node-inspection/constants.d.ts.map +1 -0
  74. package/dist/node-inspection/errors.d.ts +11 -0
  75. package/dist/node-inspection/errors.d.ts.map +1 -0
  76. package/dist/node-inspection/lifecycle.d.ts +15 -0
  77. package/dist/node-inspection/lifecycle.d.ts.map +1 -0
  78. package/dist/node-inspection/protocol.d.ts +20 -0
  79. package/dist/node-inspection/protocol.d.ts.map +1 -0
  80. package/dist/node-inspection/repository-rpc.d.ts +28 -0
  81. package/dist/node-inspection/repository-rpc.d.ts.map +1 -0
  82. package/dist/node-inspection/runner.d.ts +2 -0
  83. package/dist/node-inspection/runner.d.ts.map +1 -0
  84. package/dist/node-inspection/types.d.ts +95 -0
  85. package/dist/node-inspection/types.d.ts.map +1 -0
  86. package/dist/node-runner.js +149 -0
  87. package/dist/node-runner.js.map +1 -0
  88. package/dist/node.js +335 -0
  89. package/dist/node.js.map +1 -0
  90. package/dist/options/index.d.ts +2 -14
  91. package/dist/options/index.d.ts.map +1 -1
  92. package/dist/project-inspection/index.d.ts +21 -1
  93. package/dist/project-inspection/index.d.ts.map +1 -1
  94. package/dist/project-validation/index.d.ts +33 -11
  95. package/dist/project-validation/index.d.ts.map +1 -1
  96. package/dist/repository-inspection-session/index.d.ts +2 -4
  97. package/dist/repository-inspection-session/index.d.ts.map +1 -1
  98. package/dist/repository-reference-validation/index.d.ts +12 -6
  99. package/dist/repository-reference-validation/index.d.ts.map +1 -1
  100. package/dist/retained-memory/index.d.ts +18 -0
  101. package/dist/retained-memory/index.d.ts.map +1 -0
  102. package/dist/scope/index.d.ts +3 -0
  103. package/dist/scope/index.d.ts.map +1 -0
  104. package/dist/scope/scope.d.ts +13 -0
  105. package/dist/scope/scope.d.ts.map +1 -0
  106. package/dist/scope-matching/index.d.ts +2 -1
  107. package/dist/scope-matching/index.d.ts.map +1 -1
  108. package/dist/scope-matching/matching.d.ts +11 -2
  109. package/dist/scope-matching/matching.d.ts.map +1 -1
  110. package/dist/scope-matching/patterns.d.ts +4 -0
  111. package/dist/scope-matching/patterns.d.ts.map +1 -0
  112. package/dist/scope.js +17 -0
  113. package/dist/scope.js.map +1 -0
  114. package/dist/universal-project-inspection/index.d.ts +13 -11
  115. package/dist/universal-project-inspection/index.d.ts.map +1 -1
  116. package/dist/warning-acceptance/acceptance.d.ts +11 -0
  117. package/dist/warning-acceptance/acceptance.d.ts.map +1 -0
  118. package/dist/warning-acceptance/index.d.ts +2 -0
  119. package/dist/warning-acceptance/index.d.ts.map +1 -0
  120. package/package.json +14 -6
  121. package/dist/adapter/index.d.ts +0 -131
  122. package/dist/adapter/index.d.ts.map +0 -1
  123. package/dist/adapter-availability/index.d.ts +0 -15
  124. package/dist/adapter-availability/index.d.ts.map +0 -1
  125. package/dist/adapter-execution/index.d.ts +0 -31
  126. package/dist/adapter-execution/index.d.ts.map +0 -1
  127. package/dist/adapter-repository/index.d.ts +0 -27
  128. package/dist/adapter-repository/index.d.ts.map +0 -1
  129. package/dist/adapter-retained-memory/index.d.ts +0 -8
  130. package/dist/adapter-retained-memory/index.d.ts.map +0 -1
  131. package/dist/adapter-validation/index.d.ts +0 -43
  132. package/dist/adapter-validation/index.d.ts.map +0 -1
  133. package/dist/adapter.js +0 -115
  134. package/dist/adapter.js.map +0 -1
  135. package/dist/chunks/exceptions-HS9ofVy2.js.map +0 -1
  136. package/dist/index.js.map +0 -1
@@ -0,0 +1,67 @@
1
+ import { a as encodeInspectionMessage, r as createInspectionProcessFailure, u as NODE_INSPECTION_TERMINATION_GRACE_MS } from "./errors-BE4DS3Ak.js";
2
+ import process from "node:process";
3
+ //#region src/node-inspection/lifecycle.ts
4
+ /** Serializes bounded IPC sends and waits for Node's send callback before admitting the next. */
5
+ var createInspectionSender = (send) => {
6
+ let queued = 0;
7
+ let tail = Promise.resolve();
8
+ return async (message) => {
9
+ if (queued >= 4) throw createInspectionProcessFailure();
10
+ queued++;
11
+ const operation = tail.then(() => new Promise((resolve, reject) => {
12
+ try {
13
+ send(encodeInspectionMessage(message), (error) => {
14
+ if (error !== null) reject(createInspectionProcessFailure(error));
15
+ else resolve();
16
+ });
17
+ } catch (cause) {
18
+ reject(cause instanceof Error ? cause : createInspectionProcessFailure(cause));
19
+ }
20
+ }));
21
+ tail = operation.catch(() => {});
22
+ try {
23
+ await operation;
24
+ } finally {
25
+ queued--;
26
+ }
27
+ };
28
+ };
29
+ /** Keeps only operating-system bootstrap variables; no credentials or Node overrides cross. */
30
+ var createInspectionEnvironment = () => {
31
+ const names = /* @__PURE__ */ new Set([
32
+ "systemroot",
33
+ "windir",
34
+ "temp",
35
+ "tmp",
36
+ "tmpdir"
37
+ ]);
38
+ return Object.fromEntries(Object.entries(process.env).filter(([name]) => names.has(name.toLowerCase())));
39
+ };
40
+ /**
41
+ * Supervises one owned child without PID polling, shell commands, or process-group killing.
42
+ * @returns Idempotent termination and actual close notification.
43
+ */
44
+ var superviseInspectionChild = (child, requestStop) => {
45
+ let hasClosed = false;
46
+ let forceTimer;
47
+ return {
48
+ closed: new Promise((resolve) => {
49
+ child.once("close", () => {
50
+ hasClosed = true;
51
+ clearTimeout(forceTimer);
52
+ resolve();
53
+ });
54
+ }),
55
+ terminate: () => {
56
+ if (hasClosed || forceTimer !== void 0) return;
57
+ forceTimer = setTimeout(() => {
58
+ if (!hasClosed) child.kill("SIGKILL");
59
+ }, NODE_INSPECTION_TERMINATION_GRACE_MS);
60
+ requestStop();
61
+ }
62
+ };
63
+ };
64
+ //#endregion
65
+ export { createInspectionSender as n, superviseInspectionChild as r, createInspectionEnvironment as t };
66
+
67
+ //# sourceMappingURL=lifecycle-D_RvxhDC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-D_RvxhDC.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"}
@@ -0,0 +1,604 @@
1
+ import { n as CoreOperationException, t as CoreConfigurationException } from "./exceptions-IXsorE8t.js";
2
+ import { isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
3
+ //#region src/constants/index.ts
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",
12
+ "anthropic",
13
+ "cerebras",
14
+ "claude-agent-sdk",
15
+ "cloudflare-agents",
16
+ "cohere",
17
+ "convex-agent",
18
+ "cursor-sdk",
19
+ "custom",
20
+ "deep-agents",
21
+ "eve",
22
+ "genkit",
23
+ "github-copilot-sdk",
24
+ "google-adk",
25
+ "google-genai",
26
+ "groq",
27
+ "hugging-face",
28
+ "ibm-watsonx-ai",
29
+ "langchain",
30
+ "langgraph",
31
+ "livekit-agents",
32
+ "mastra",
33
+ "microsoft-foundry",
34
+ "mistral",
35
+ "node-llama-cpp",
36
+ "ollama",
37
+ "openai",
38
+ "openai-agents-sdk",
39
+ "openai-codex",
40
+ "opencode-sdk",
41
+ "openrouter",
42
+ "pi-agent",
43
+ "strands-agents",
44
+ "tanstack-ai",
45
+ "vercel-ai-sdk",
46
+ "voltagent"
47
+ ]);
48
+ var SUPPORTED_REPOSITORY_FORMAT_VERSIONS = Object.freeze([1]);
49
+ var DEFAULT_CORE_RESOURCE_LIMITS = Object.freeze({
50
+ maxDiagnostics: 1e4,
51
+ maxEntries: 1e5,
52
+ maxCoverage: 1e4,
53
+ maxAcceptedWarnings: 256,
54
+ maxFileBytes: 8388608,
55
+ maxManifestBytes: 2097152,
56
+ maxRetainedBytes: 536870912,
57
+ maxTotalBytesRead: 134217728
58
+ });
59
+ //#endregion
60
+ //#region src/format-validation/index.ts
61
+ var STABLE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
62
+ var VARIABLE_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
63
+ var WINDOWS_RESERVED_ID_PATTERN = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u;
64
+ var LINE_BREAK_CHARACTERS = [
65
+ "\n",
66
+ "\r",
67
+ "…",
68
+ "\u2028",
69
+ "\u2029"
70
+ ];
71
+ var UNSUPPORTED_GLOB_PATTERN = /[!?[\]{}]/u;
72
+ var hasLineBreak = (value) => {
73
+ return LINE_BREAK_CHARACTERS.some((lineBreak) => value.includes(lineBreak));
74
+ };
75
+ /** Determines whether a code point belongs to the Repository Format version 1 whitespace set. */
76
+ var isRepositoryFormatWhitespace = (codePoint) => {
77
+ return codePoint >= 9 && codePoint <= 13 || codePoint === 32 || codePoint === 133 || codePoint === 160 || codePoint === 5760 || codePoint >= 8192 && codePoint <= 8202 || codePoint === 8232 || codePoint === 8233 || codePoint === 8239 || codePoint === 8287 || codePoint === 12288;
78
+ };
79
+ /** Compares strings by exact Unicode code-point order without locale behavior. */
80
+ var compareExactStrings = (left, right) => {
81
+ const leftScalars = left[Symbol.iterator]();
82
+ const rightScalars = right[Symbol.iterator]();
83
+ while (true) {
84
+ const leftScalar = leftScalars.next();
85
+ const rightScalar = rightScalars.next();
86
+ if (leftScalar.done === true) return rightScalar.done === true ? 0 : -1;
87
+ if (rightScalar.done === true) return 1;
88
+ const leftCodePoint = leftScalar.value.codePointAt(0) ?? 0;
89
+ const rightCodePoint = rightScalar.value.codePointAt(0) ?? 0;
90
+ if (leftCodePoint !== rightCodePoint) return leftCodePoint < rightCodePoint ? -1 : 1;
91
+ }
92
+ };
93
+ /** Counts Unicode scalar values in valid JavaScript text. */
94
+ var countUnicodeScalars = (value) => {
95
+ const scalars = value[Symbol.iterator]();
96
+ let count = 0;
97
+ while (scalars.next().done !== true) count += 1;
98
+ return count;
99
+ };
100
+ /** Determines whether a value contains at least one non-whitespace scalar. */
101
+ var hasNonWhitespace = (value) => {
102
+ for (const scalar of value) if (!isRepositoryFormatWhitespace(scalar.codePointAt(0) ?? 0)) return true;
103
+ return false;
104
+ };
105
+ /** Determines whether a value begins or ends with version 1 whitespace. */
106
+ var hasSurroundingWhitespace = (value) => {
107
+ const firstCodePoint = value.codePointAt(0);
108
+ const lastCodePoint = value.codePointAt(value.length - 1);
109
+ return firstCodePoint !== void 0 && isRepositoryFormatWhitespace(firstCodePoint) || lastCodePoint !== void 0 && isRepositoryFormatWhitespace(lastCodePoint);
110
+ };
111
+ /** Removes only Repository Format version 1 whitespace from both edges. */
112
+ var trimRepositoryFormatWhitespace = (value) => {
113
+ let start = 0;
114
+ let end = value.length;
115
+ while (start < end) {
116
+ const codePoint = value.codePointAt(start);
117
+ if (codePoint === void 0 || !isRepositoryFormatWhitespace(codePoint)) break;
118
+ start += codePoint > 65535 ? 2 : 1;
119
+ }
120
+ while (end > start) {
121
+ const codePoint = value.codePointAt(end - 1);
122
+ if (codePoint === void 0 || !isRepositoryFormatWhitespace(codePoint)) break;
123
+ end -= 1;
124
+ }
125
+ return value.slice(start, end);
126
+ };
127
+ /** Determines whether a string is non-empty and contains no line break. */
128
+ var isNonEmptySingleLine = (value) => {
129
+ return value.length > 0 && !hasLineBreak(value);
130
+ };
131
+ /** Determines whether a value satisfies stable moldea ID syntax. */
132
+ var isStableId = (value) => {
133
+ return value.length <= 64 && STABLE_ID_PATTERN.test(value);
134
+ };
135
+ /** Determines whether an otherwise valid stable ID is filesystem-reserved. */
136
+ var isReservedId = (value) => WINDOWS_RESERVED_ID_PATTERN.test(value);
137
+ /** Determines whether a value satisfies runtime-variable ID syntax. */
138
+ var isVariableId = (value) => {
139
+ return value.length <= 64 && VARIABLE_ID_PATTERN.test(value);
140
+ };
141
+ /** Determines whether a parsed capability description satisfies version 1 limits. */
142
+ var isCapabilityDescription = (value) => {
143
+ const scalarLength = countUnicodeScalars(value);
144
+ return scalarLength >= 1 && scalarLength <= 1e3 && !hasSurroundingWhitespace(value) && !hasLineBreak(value) && !value.includes("\0") && !value.includes("{{") && !value.includes("}}");
145
+ };
146
+ /** Parses a non-root repository-format logical path without throwing. */
147
+ var parseManifestPath = (value) => {
148
+ return value !== "/" && isRepositoryPath(value) ? parseRepositoryPath(value) : null;
149
+ };
150
+ /** Determines whether a path is the canonical manifest path. */
151
+ var isCanonicalManifestPath = (path) => {
152
+ return path === "/moldea/moldea.yaml";
153
+ };
154
+ /** Extracts the stable millisecond ID from one canonical immediate decision path. */
155
+ var parseDecisionIdFromPath = (path) => {
156
+ const match = /^\/moldea\/decisions\/(\d{13})-([a-z0-9]+(?:-[a-z0-9]+)*)\.md$/u.exec(path);
157
+ const id = match?.[1];
158
+ const slug = match?.[2];
159
+ return id !== void 0 && slug !== void 0 && isStableId(slug) ? id : null;
160
+ };
161
+ /** Determines whether a path is an allowed focused-context relationship key. */
162
+ var isContextPath = (path, allowProject) => {
163
+ if (allowProject && path === "/moldea/project.md") return true;
164
+ return path.startsWith("/moldea/context/") && path.endsWith(".md");
165
+ };
166
+ /** Determines whether a path has the canonical immediate decision filename shape. */
167
+ var isDecisionPath = (path) => {
168
+ return parseDecisionIdFromPath(path) !== null;
169
+ };
170
+ /** Determines whether a path is canonical runtime guidance. */
171
+ var isRuntimeGuidancePath = (path) => {
172
+ return path.startsWith("/moldea/runtimes/") && path.endsWith(".md");
173
+ };
174
+ /** Determines whether a mirror path is outside canonical moldea content. */
175
+ var isMirrorPath = (path) => {
176
+ return path !== "/moldea" && !path.startsWith("/moldea/");
177
+ };
178
+ /** Determines whether an impact path contains prohibited glob metacharacters. */
179
+ var hasUnsupportedGlobMetacharacter = (value) => {
180
+ return UNSUPPORTED_GLOB_PATTERN.test(value);
181
+ };
182
+ /** Determines whether a string satisfies the version 1 simple-glob grammar. */
183
+ var isSimpleGlob = (value) => {
184
+ if (hasUnsupportedGlobMetacharacter(value) || value.includes("***")) return false;
185
+ if (value.slice(1).split("/").some((segment) => segment.includes("**") && segment !== "**")) return false;
186
+ return value.includes("*") && isRepositoryPath(value.replaceAll("*", "x"));
187
+ };
188
+ /** Determines whether a repository-reference symbol has the common safe shape. */
189
+ var isRepositorySymbol = (value) => {
190
+ return isNonEmptySingleLine(value) && !value.includes("\0");
191
+ };
192
+ /** Determines whether a canonical moldea reference incorrectly carries a symbol. */
193
+ var isCanonicalMoldeaPath = (path) => {
194
+ return path === "/moldea" || path.startsWith("/moldea/");
195
+ };
196
+ /** Sorts repository references by path and then optional symbol. */
197
+ var sortRepositoryReferences = (references) => {
198
+ return [...references].sort((left, right) => {
199
+ return compareExactStrings(left.path, right.path) || compareExactStrings(left.symbol ?? "", right.symbol ?? "");
200
+ });
201
+ };
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
228
+ //#region src/diagnostic-utilities/index.ts
229
+ var CORE_DIAGNOSTIC_MESSAGES = {
230
+ MOLDEA_AGENT_DESCRIPTION_INVALID: "The agent description is invalid.",
231
+ MOLDEA_AGENT_DESCRIPTION_MISSING: "The agent description is missing.",
232
+ MOLDEA_AGENT_DIRECTORY_MISSING: "The registered agent directory is missing.",
233
+ MOLDEA_AGENT_DIRECTORY_UNREGISTERED: "The agent directory is not registered.",
234
+ MOLDEA_AGENT_HANDOFF_DESCRIPTION_INVALID: "The agent handoff description is invalid.",
235
+ MOLDEA_AGENT_IDENTITY_INVALID: "The agent instruction identity is invalid.",
236
+ MOLDEA_AGENT_INSTRUCTION_EMPTY: "The agent instruction is empty.",
237
+ MOLDEA_AGENT_INSTRUCTION_MISSING: "The agent instruction is missing.",
238
+ MOLDEA_CANONICAL_ASSET_SYMLINK: "The canonical asset is a symlink.",
239
+ MOLDEA_CANONICAL_PATH_UNRECOGNIZED: "The canonical path is unrecognized.",
240
+ MOLDEA_CAPABILITY_DESCRIPTION_INVALID: "The capability description is invalid.",
241
+ MOLDEA_CAPABILITY_DESCRIPTION_MISSING: "The capability description is missing.",
242
+ MOLDEA_CONTEXT_FILE_EMPTY: "The focused context file is empty.",
243
+ MOLDEA_CONTEXT_PATH_INVALID: "The context relationship path is invalid.",
244
+ MOLDEA_CONTEXT_RELATIONSHIP_EMPTY: "The declared relationship has no bindings or impact paths.",
245
+ MOLDEA_DECISION_BODY_EMPTY: "The decision Markdown body is empty.",
246
+ MOLDEA_DECISION_CREATED_AT_INVALID: "The decision createdAt value is invalid.",
247
+ MOLDEA_DECISION_FILENAME_INVALID: "The decision path or filename is invalid.",
248
+ MOLDEA_DECISION_FRONTMATTER_INVALID: "The decision frontmatter is invalid.",
249
+ MOLDEA_DECISION_FRONTMATTER_MISSING: "The decision frontmatter or its delimiters are missing.",
250
+ MOLDEA_DECISION_ID_DUPLICATE: "The decision ID is duplicated.",
251
+ MOLDEA_DECISION_PROPERTY_UNKNOWN: "The decision frontmatter contains an unknown property.",
252
+ MOLDEA_DECISION_REFERENCE_MISSING: "The referenced decision does not exist.",
253
+ MOLDEA_DECISION_RELATIONSHIP_INACTIVE: "The referenced decision is not accepted.",
254
+ MOLDEA_DECISION_SELF_SUPERSESSION: "The decision supersedes itself.",
255
+ MOLDEA_DECISION_STATUS_INVALID: "The decision status is invalid.",
256
+ MOLDEA_DECISION_SUPERSEDED_ORPHAN: "The superseded decision has no active supersession relationship.",
257
+ MOLDEA_DECISION_SUPERSESSION_CYCLE: "The decision supersession graph contains a cycle.",
258
+ MOLDEA_DECISION_SUPERSESSION_STATUS_INVALID: "The decision supersession relationship has inconsistent statuses.",
259
+ MOLDEA_DECISION_TIMESTAMP_MISMATCH: "The decision filename timestamp and createdAt value do not match.",
260
+ MOLDEA_ENTRY_TYPE_INVALID: "The repository entry type is invalid.",
261
+ MOLDEA_RUNTIME_ID_INVALID: "The runtime ID is invalid.",
262
+ MOLDEA_GLOB_INVALID: "The impact pattern is invalid.",
263
+ MOLDEA_ID_DUPLICATE: "An ID is duplicated within its required scope.",
264
+ MOLDEA_ID_INVALID: "The ID is invalid.",
265
+ MOLDEA_ID_RESERVED: "The ID uses a reserved filesystem name.",
266
+ MOLDEA_IMPACT_PATH_MISSING: "The exact impact path does not exist.",
267
+ MOLDEA_IMPACT_PATH_NOT_FILE: "The exact impact path is not a regular file.",
268
+ MOLDEA_MANIFEST_MISSING: "The project manifest is missing.",
269
+ MOLDEA_MANIFEST_PATH_INVALID: "The manifest path is not the canonical manifest path.",
270
+ MOLDEA_MANIFEST_PROPERTY_UNKNOWN: "The manifest contains an unknown property.",
271
+ MOLDEA_MANIFEST_ROOT_INVALID: "The manifest root is not a mapping.",
272
+ MOLDEA_MANIFEST_VALUE_INVALID: "The manifest value is invalid.",
273
+ MOLDEA_MANIFEST_VERSION_INVALID: "The manifest version is not a valid integer major version.",
274
+ MOLDEA_MANIFEST_VERSION_MISSING: "The manifest version is missing.",
275
+ MOLDEA_MANIFEST_VERSION_UNSUPPORTED: "The manifest version is unsupported.",
276
+ MOLDEA_MIRROR_PATH_DUPLICATE: "The mirror path is assigned more than once.",
277
+ MOLDEA_MIRROR_PATH_INSIDE_MOLDEA: "The mirror path is inside /moldea.",
278
+ MOLDEA_MIRROR_PATH_INVALID: "The mirror path is invalid.",
279
+ MOLDEA_MIRROR_MISSING: "The declared mirror does not exist.",
280
+ MOLDEA_MIRROR_NOT_FILE: "The declared mirror is not a regular file.",
281
+ MOLDEA_MIRROR_STALE: "The declared mirror differs from its canonical instruction.",
282
+ MOLDEA_MIRROR_SYMLINK: "The declared mirror is a symlink.",
283
+ MOLDEA_PATH_DUPLICATE: "The path is duplicated.",
284
+ MOLDEA_PATH_INVALID: "The manifest logical path is invalid.",
285
+ MOLDEA_PATTERN_DUPLICATE: "The impact pattern is duplicated.",
286
+ MOLDEA_PROJECT_FILE_EMPTY: "The project file is empty.",
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.",
294
+ MOLDEA_REFERENCE_MISSING: "The referenced repository path does not exist.",
295
+ MOLDEA_REFERENCE_NOT_FILE: "The referenced repository path is not a regular file.",
296
+ MOLDEA_REFERENCE_SYMLINK: "The referenced repository path is a symlink.",
297
+ MOLDEA_RUNTIME_GUIDANCE_EMPTY: "The runtime guidance is empty.",
298
+ MOLDEA_RUNTIME_GUIDANCE_MISSING: "The referenced runtime guidance does not exist.",
299
+ MOLDEA_SKILL_IMPLEMENTATION_MISSING: "The registered skill implementation is missing.",
300
+ MOLDEA_SYMBOL_FORBIDDEN: "A canonical moldea reference must not include a symbol.",
301
+ MOLDEA_SYMBOL_INVALID: "The repository-reference symbol is invalid.",
302
+ MOLDEA_TEXT_EMPTY: "The required text document is empty.",
303
+ MOLDEA_TEXT_INVALID_UNICODE: "The text document contains an invalid Unicode scalar representation.",
304
+ MOLDEA_TEXT_INVALID_UTF8: "The text document is not valid UTF-8.",
305
+ MOLDEA_TEXT_NUL_FORBIDDEN: "The text document contains a forbidden NUL character.",
306
+ MOLDEA_TOOL_IMPLEMENTATION_MISSING: "The registered tool implementation is missing.",
307
+ MOLDEA_VARIABLE_ID_INVALID: "The runtime-variable ID is invalid.",
308
+ MOLDEA_VARIABLE_PLACEHOLDER_MALFORMED: "The agent instruction contains a malformed runtime-variable placeholder.",
309
+ MOLDEA_VARIABLE_PROVIDER_UNDECLARED: "A variable-provider binding exists for an undeclared variable.",
310
+ MOLDEA_VARIABLE_UNDECLARED: "The agent instruction references an undeclared runtime variable.",
311
+ MOLDEA_VARIABLE_UNUSED: "The declared runtime variable is unused by the agent instruction.",
312
+ MOLDEA_YAML_DUPLICATE_KEY: "The YAML document contains a duplicate mapping key.",
313
+ MOLDEA_YAML_FEATURE_UNSUPPORTED: "The YAML document uses an unsupported feature.",
314
+ MOLDEA_YAML_MALFORMED: "The YAML document is malformed.",
315
+ MOLDEA_YAML_MULTIPLE_DOCUMENTS: "The YAML stream contains more than one document."
316
+ };
317
+ var ENTITY_KEYS = [
318
+ "agentId",
319
+ "capabilityKind",
320
+ "capabilityId",
321
+ "decisionId",
322
+ "variableId",
323
+ "contextPath",
324
+ "integrationPath"
325
+ ];
326
+ var CORE_DIAGNOSTIC_BUDGET = Symbol("core-diagnostic-budget");
327
+ /** Creates a detached limits view with one diagnostic budget for a complete Core operation. */
328
+ var createCoreOperationResourceLimits = (limits) => {
329
+ if (limits[CORE_DIAGNOSTIC_BUDGET] !== void 0) return limits;
330
+ return Object.freeze({
331
+ ...limits,
332
+ [CORE_DIAGNOSTIC_BUDGET]: { count: 0 }
333
+ });
334
+ };
335
+ /** Registers raw diagnostics against the shared operation budget before normalization. */
336
+ var registerCoreDiagnosticCandidates = (limits, amount, operation, fallbackCount = 0) => {
337
+ const budget = limits[CORE_DIAGNOSTIC_BUDGET];
338
+ const currentCount = budget?.count ?? fallbackCount;
339
+ if (amount > limits.maxDiagnostics - currentCount) throw new CoreOperationException({
340
+ code: "RESOURCE_LIMIT_EXCEEDED",
341
+ limit: "maxDiagnostics",
342
+ limitMaximum: limits.maxDiagnostics,
343
+ nextAction: "reduce-input-or-increase-limit",
344
+ observedUsage: currentCount + amount,
345
+ operation
346
+ });
347
+ if (budget !== void 0) budget.count += amount;
348
+ return fallbackCount + amount;
349
+ };
350
+ var compareNullableStrings = (left, right) => {
351
+ if (left === null) return right === null ? 0 : -1;
352
+ return right === null ? 1 : compareExactStrings(left, right);
353
+ };
354
+ /**
355
+ * Normalizes trusted JSON-scalar diagnostic metadata.
356
+ * @param details The optional detached metadata record.
357
+ * @returns A frozen null-prototype record with canonical key order.
358
+ */
359
+ var normalizeDiagnosticDetails = (details) => {
360
+ return freezeRecursively(createNullPrototypeRecord(Object.entries(details ?? {}).sort(([left], [right]) => compareExactStrings(left, right)).map(([key, value]) => [key, typeof value === "number" && Object.is(value, -0) ? 0 : value])));
361
+ };
362
+ /**
363
+ * Normalizes a trusted diagnostic entity into canonical key order.
364
+ * @param entity The optional diagnostic entity.
365
+ * @returns The frozen normalized entity or `null`.
366
+ */
367
+ var normalizeDiagnosticEntity = (entity) => {
368
+ if (entity === void 0 || entity === null) return null;
369
+ return freezeRecursively(createNullPrototypeRecord(ENTITY_KEYS.flatMap((key) => {
370
+ const value = entity[key];
371
+ return value === void 0 ? [] : [[key, value]];
372
+ })));
373
+ };
374
+ /** Serializes unordered diagnostic details with explicit exact-code-point key ordering. */
375
+ var serializeDiagnosticDetails = (details) => {
376
+ const entries = Object.entries(details).sort(([left], [right]) => compareExactStrings(left, right));
377
+ return JSON.stringify(entries);
378
+ };
379
+ var serializeDiagnostic = (diagnostic) => {
380
+ const entity = diagnostic.entity === null ? null : ENTITY_KEYS.map((key) => [key, diagnostic.entity?.[key] ?? null]);
381
+ const range = diagnostic.range === null ? null : [
382
+ diagnostic.range.start.line,
383
+ diagnostic.range.start.column,
384
+ diagnostic.range.start.offset,
385
+ diagnostic.range.end.line,
386
+ diagnostic.range.end.column,
387
+ diagnostic.range.end.offset
388
+ ];
389
+ return JSON.stringify([
390
+ diagnostic.code,
391
+ diagnostic.severity,
392
+ diagnostic.severity === "warning" ? [
393
+ diagnostic.subject,
394
+ diagnostic.qualifier,
395
+ diagnostic.accepted ?? false,
396
+ diagnostic.reason ?? null
397
+ ] : null,
398
+ serializeDiagnosticDetails(diagnostic.details),
399
+ entity,
400
+ diagnostic.message,
401
+ diagnostic.path,
402
+ diagnostic.pointer,
403
+ range,
404
+ diagnostic.source
405
+ ]);
406
+ };
407
+ var compareRanges = (left, right) => {
408
+ if (left === null) return right === null ? 0 : -1;
409
+ if (right === null) return 1;
410
+ return left.start.line - right.start.line || left.start.column - right.start.column || left.start.offset - right.start.offset || left.end.line - right.end.line || left.end.column - right.end.column || left.end.offset - right.end.offset;
411
+ };
412
+ var readEntityValue = (entity, key) => {
413
+ return entity?.[key] ?? "";
414
+ };
415
+ var compareDiagnostics = (left, right) => {
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";
437
+ };
438
+ /**
439
+ * Creates one normalized, immutable Core diagnostic.
440
+ * @param input The trusted Core-owned diagnostic fields to normalize.
441
+ * @returns A deeply immutable public diagnostic value.
442
+ */
443
+ var createCoreDiagnostic = (input) => {
444
+ const message = CORE_DIAGNOSTIC_MESSAGES[input.code];
445
+ if (message === void 0) throw new TypeError("The requested Core diagnostic is not implemented.");
446
+ const base = {
447
+ code: input.code,
448
+ details: normalizeDiagnosticDetails(input.details),
449
+ entity: normalizeDiagnosticEntity(input.entity),
450
+ message,
451
+ path: input.path,
452
+ pointer: input.pointer ?? null,
453
+ range: input.range ?? null,
454
+ group: getDiagnosticGroup(input.code),
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"
472
+ });
473
+ };
474
+ /**
475
+ * Deduplicates and sorts already-normalized Core diagnostics.
476
+ * @param candidates The immutable diagnostics to combine.
477
+ * @returns A frozen deterministic diagnostic collection.
478
+ */
479
+ var normalizeDiagnostics = (candidates) => {
480
+ const diagnostics = /* @__PURE__ */ new Map();
481
+ for (const diagnostic of candidates) {
482
+ const key = serializeDiagnostic(diagnostic);
483
+ if (diagnostics.has(key)) continue;
484
+ diagnostics.set(key, diagnostic);
485
+ }
486
+ return freezeRecursively([...diagnostics.values()].sort(compareDiagnostics));
487
+ };
488
+ /** Counts the complete normalized diagnostic result by severity once. */
489
+ var countDiagnosticsBySeverity = (diagnostics) => {
490
+ let errorCount = 0;
491
+ let warningCount = 0;
492
+ let acceptedWarningCount = 0;
493
+ for (const diagnostic of diagnostics) if (diagnostic.severity === "error") errorCount += 1;
494
+ else if (diagnostic.accepted === true) acceptedWarningCount += 1;
495
+ else warningCount += 1;
496
+ return {
497
+ errorCount,
498
+ warningCount,
499
+ acceptedWarningCount,
500
+ diagnosticCount: diagnostics.length
501
+ };
502
+ };
503
+ /**
504
+ * Creates a deterministic, deduplicating diagnostic collector for one operation.
505
+ * @param limits The Core resource limits governing diagnostic output.
506
+ * @param operation The operation reported by resource failures.
507
+ * @returns A collector that freezes and sorts its final diagnostic array.
508
+ */
509
+ var createCoreDiagnosticCollector = (limits, operation) => {
510
+ const diagnostics = /* @__PURE__ */ new Map();
511
+ let proposalCount = 0;
512
+ let fallbackRawCount = 0;
513
+ const retain = (input) => {
514
+ const diagnostic = createCoreDiagnostic(input);
515
+ const key = serializeDiagnostic(diagnostic);
516
+ proposalCount += 1;
517
+ if (!diagnostics.has(key)) diagnostics.set(key, diagnostic);
518
+ };
519
+ return {
520
+ add: (input) => {
521
+ fallbackRawCount = registerCoreDiagnosticCandidates(limits, 1, operation, fallbackRawCount);
522
+ retain(input);
523
+ },
524
+ merge: retain,
525
+ finalize: () => normalizeDiagnostics([...diagnostics.values()]),
526
+ get size() {
527
+ return proposalCount;
528
+ }
529
+ };
530
+ };
531
+ /**
532
+ * Escapes one JSON Pointer reference token.
533
+ * @param value The decoded mapping key or array index token.
534
+ * @returns The RFC 6901 escaped token.
535
+ */
536
+ var escapeJsonPointerSegment = (value) => {
537
+ return value.replaceAll("~", "~0").replaceAll("/", "~1");
538
+ };
539
+ //#endregion
540
+ //#region src/options/index.ts
541
+ /** Creates an operation-local options view with one shared raw-diagnostic budget. */
542
+ var createCoreOperationOptionsSnapshot = (options) => {
543
+ return Object.freeze({ limits: createCoreOperationResourceLimits(options.limits) });
544
+ };
545
+ var RESOURCE_LIMIT_KEYS = [
546
+ "maxEntries",
547
+ "maxTotalBytesRead",
548
+ "maxFileBytes",
549
+ "maxManifestBytes",
550
+ "maxRetainedBytes",
551
+ "maxDiagnostics",
552
+ "maxCoverage",
553
+ "maxAcceptedWarnings"
554
+ ];
555
+ var isRecord = (value) => {
556
+ return typeof value === "object" && value !== null && !Array.isArray(value);
557
+ };
558
+ /**
559
+ * Validates, copies, fills, and freezes all configured resource limits.
560
+ * @param candidate The untrusted optional limit overrides.
561
+ * @returns The complete frozen resource limits.
562
+ * @throws
563
+ * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.
564
+ */
565
+ var normalizeLimits = (candidate) => {
566
+ if (candidate === void 0) return DEFAULT_CORE_RESOURCE_LIMITS;
567
+ if (!isRecord(candidate)) throw new CoreConfigurationException({
568
+ code: "INVALID_RESOURCE_LIMIT",
569
+ operation: "create-core"
570
+ });
571
+ const knownKeys = new Set(RESOURCE_LIMIT_KEYS);
572
+ if (Object.keys(candidate).some((key) => !knownKeys.has(key))) throw new CoreConfigurationException({
573
+ code: "INVALID_RESOURCE_LIMIT",
574
+ operation: "create-core"
575
+ });
576
+ const normalized = { ...DEFAULT_CORE_RESOURCE_LIMITS };
577
+ for (const key of RESOURCE_LIMIT_KEYS) {
578
+ const value = candidate[key];
579
+ if (value === void 0) continue;
580
+ if (!Number.isSafeInteger(value) || value <= 0) throw new CoreConfigurationException({
581
+ code: "INVALID_RESOURCE_LIMIT",
582
+ operation: "create-core"
583
+ });
584
+ normalized[key] = value;
585
+ }
586
+ return freezeRecursively(normalized);
587
+ };
588
+ /**
589
+ * Validates and snapshots caller-owned Core resource limits.
590
+ * @returns A deeply frozen configuration snapshot.
591
+ * @throws
592
+ * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.
593
+ */
594
+ var normalizeCoreOptions = (options) => {
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"
598
+ });
599
+ return freezeRecursively({ limits: normalizeLimits(options?.["limits"]) });
600
+ };
601
+ //#endregion
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 };
603
+
604
+ //# sourceMappingURL=options-5x9gu2Qb.js.map