@moldea.ai/adapter-claude-agent-sdk 1.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/cover.png +0 -0
  4. package/dist/adapter/index.d.ts +3 -0
  5. package/dist/adapter/index.d.ts.map +1 -0
  6. package/dist/constants/index.d.ts +7 -0
  7. package/dist/constants/index.d.ts.map +1 -0
  8. package/dist/contracts/index.d.ts +176 -0
  9. package/dist/contracts/index.d.ts.map +1 -0
  10. package/dist/diagnostics/index.d.ts +31 -0
  11. package/dist/diagnostics/index.d.ts.map +1 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +2435 -0
  15. package/dist/inspection/common.d.ts +36 -0
  16. package/dist/inspection/common.d.ts.map +1 -0
  17. package/dist/inspection/handoffs.d.ts +7 -0
  18. package/dist/inspection/handoffs.d.ts.map +1 -0
  19. package/dist/inspection/index.d.ts +2 -0
  20. package/dist/inspection/index.d.ts.map +1 -0
  21. package/dist/inspection/inspection.d.ts +18 -0
  22. package/dist/inspection/inspection.d.ts.map +1 -0
  23. package/dist/inspection/package-inspection.d.ts +7 -0
  24. package/dist/inspection/package-inspection.d.ts.map +1 -0
  25. package/dist/inspection/relationships.d.ts +7 -0
  26. package/dist/inspection/relationships.d.ts.map +1 -0
  27. package/dist/inspection/resolution.d.ts +23 -0
  28. package/dist/inspection/resolution.d.ts.map +1 -0
  29. package/dist/inspection/session.d.ts +5 -0
  30. package/dist/inspection/session.d.ts.map +1 -0
  31. package/dist/inspection/tools.d.ts +7 -0
  32. package/dist/inspection/tools.d.ts.map +1 -0
  33. package/dist/inspection/types.d.ts +16 -0
  34. package/dist/inspection/types.d.ts.map +1 -0
  35. package/dist/package-discovery/index.d.ts +27 -0
  36. package/dist/package-discovery/index.d.ts.map +1 -0
  37. package/dist/source-analysis/agent-definitions.d.ts +24 -0
  38. package/dist/source-analysis/agent-definitions.d.ts.map +1 -0
  39. package/dist/source-analysis/bindings.d.ts +11 -0
  40. package/dist/source-analysis/bindings.d.ts.map +1 -0
  41. package/dist/source-analysis/collections.d.ts +28 -0
  42. package/dist/source-analysis/collections.d.ts.map +1 -0
  43. package/dist/source-analysis/index.d.ts +14 -0
  44. package/dist/source-analysis/index.d.ts.map +1 -0
  45. package/dist/source-analysis/instruction-loaders.d.ts +12 -0
  46. package/dist/source-analysis/instruction-loaders.d.ts.map +1 -0
  47. package/dist/source-analysis/mcp-servers.d.ts +16 -0
  48. package/dist/source-analysis/mcp-servers.d.ts.map +1 -0
  49. package/dist/source-analysis/mutations.d.ts +15 -0
  50. package/dist/source-analysis/mutations.d.ts.map +1 -0
  51. package/dist/source-analysis/query-wrappers.d.ts +19 -0
  52. package/dist/source-analysis/query-wrappers.d.ts.map +1 -0
  53. package/dist/source-analysis/sdk-tools.d.ts +9 -0
  54. package/dist/source-analysis/sdk-tools.d.ts.map +1 -0
  55. package/dist/source-analysis/source-analysis.d.ts +11 -0
  56. package/dist/source-analysis/source-analysis.d.ts.map +1 -0
  57. package/dist/source-analysis/static-strings.d.ts +11 -0
  58. package/dist/source-analysis/static-strings.d.ts.map +1 -0
  59. package/dist/source-analysis/tool-availability.d.ts +41 -0
  60. package/dist/source-analysis/tool-availability.d.ts.map +1 -0
  61. package/package.json +60 -0
package/dist/index.js ADDED
@@ -0,0 +1,2435 @@
1
+ import { posix } from "node:path";
2
+ import { intersects, subset, validRange } from "semver";
3
+ import ts from "typescript";
4
+ import { parseRepositoryPath } from "@moldea.ai/repository";
5
+ //#region src/constants/index.ts
6
+ var CLAUDE_AGENT_SDK_ADAPTER_ID = "claude-agent-sdk";
7
+ var CLAUDE_AGENT_SDK_PACKAGE_NAME = "@anthropic-ai/claude-agent-sdk";
8
+ var CLAUDE_AGENT_SDK_SUPPORTED_RANGE = ">=0.3.234 <0.4.0";
9
+ var CLAUDE_AGENT_SDK_SUPPORTED_REPOSITORY_FORMAT_VERSIONS = Object.freeze([1]);
10
+ var CLAUDE_AGENT_SDK_MCP_SERVER_KEY_PATTERN = /^[A-Za-z0-9_-]+$/;
11
+ //#endregion
12
+ //#region ../../packages/adapter-static-analysis/dist/index.js
13
+ /**
14
+ * Creates an operation-local inspection session with deterministic promise caches.
15
+ * @param options Provider callbacks and the optional operation signal.
16
+ * @returns Cached source, package, and entry inspection functions.
17
+ * @throws If the inspection is aborted.
18
+ */
19
+ var createInspectionSession = (options) => {
20
+ const sourceCache = /* @__PURE__ */ new Map();
21
+ const packageCache = /* @__PURE__ */ new Map();
22
+ const entryCache = /* @__PURE__ */ new Map();
23
+ const analyzeSource = (path) => {
24
+ options.signal?.throwIfAborted();
25
+ const existing = sourceCache.get(path);
26
+ if (existing !== void 0) return existing;
27
+ const analysis = (async () => {
28
+ options.signal?.throwIfAborted();
29
+ const bytes = await options.readFile(path, options.signal);
30
+ options.signal?.throwIfAborted();
31
+ const result = await options.analyzeSource(path, bytes, options.signal);
32
+ options.signal?.throwIfAborted();
33
+ return result;
34
+ })();
35
+ sourceCache.set(path, analysis);
36
+ return analysis;
37
+ };
38
+ const discoverPackage = (path) => {
39
+ options.signal?.throwIfAborted();
40
+ const existing = packageCache.get(path);
41
+ if (existing !== void 0) return existing;
42
+ const discovery = options.discoverPackage(path, options.signal);
43
+ packageCache.set(path, discovery);
44
+ return discovery;
45
+ };
46
+ const getEntry = (path) => {
47
+ options.signal?.throwIfAborted();
48
+ const existing = entryCache.get(path);
49
+ if (existing !== void 0) return existing;
50
+ const entry = options.getEntry(path, options.signal);
51
+ entryCache.set(path, entry);
52
+ return entry;
53
+ };
54
+ return Object.freeze({
55
+ analyzeSource,
56
+ discoverPackage,
57
+ getEntry,
58
+ ...options.signal === void 0 ? {} : { signal: options.signal }
59
+ });
60
+ };
61
+ var decoder = new TextDecoder("utf-8", {
62
+ fatal: true,
63
+ ignoreBOM: true
64
+ });
65
+ var findLineIndex = (lineStarts, offset) => {
66
+ let lower = 0;
67
+ let upper = lineStarts.length - 1;
68
+ while (lower < upper) {
69
+ const middle = Math.ceil((lower + upper) / 2);
70
+ if ((lineStarts[middle] ?? 0) <= offset) lower = middle;
71
+ else upper = middle - 1;
72
+ }
73
+ return lower;
74
+ };
75
+ /**
76
+ * Creates a TypeScript UTF-16-offset to Unicode-scalar source locator.
77
+ * @param value The normalized valid Unicode-scalar text.
78
+ * @returns The scalar-aware source locator.
79
+ */
80
+ var createSourceLocator = (value) => {
81
+ const scalarOffsets = new Uint32Array(value.length + 1);
82
+ const lineStarts = [0];
83
+ let scalarOffset = 0;
84
+ for (let codeUnitOffset = 0; codeUnitOffset < value.length;) {
85
+ const codePoint = value.codePointAt(codeUnitOffset);
86
+ const width = codePoint !== void 0 && codePoint > 65535 ? 2 : 1;
87
+ scalarOffsets[codeUnitOffset] = scalarOffset;
88
+ for (let interiorOffset = 1; interiorOffset < width; interiorOffset += 1) scalarOffsets[codeUnitOffset + interiorOffset] = scalarOffset;
89
+ codeUnitOffset += width;
90
+ scalarOffset += 1;
91
+ scalarOffsets[codeUnitOffset] = scalarOffset;
92
+ if (codePoint === 10) lineStarts.push(codeUnitOffset);
93
+ }
94
+ const locatePosition = (candidateOffset) => {
95
+ const codeUnitOffset = Math.max(0, Math.min(value.length, candidateOffset));
96
+ const lineIndex = findLineIndex(lineStarts, codeUnitOffset);
97
+ const lineStart = lineStarts[lineIndex] ?? 0;
98
+ const positionScalarOffset = scalarOffsets[codeUnitOffset] ?? 0;
99
+ return {
100
+ column: positionScalarOffset - (scalarOffsets[lineStart] ?? 0) + 1,
101
+ line: lineIndex + 1,
102
+ offset: positionScalarOffset
103
+ };
104
+ };
105
+ return Object.freeze({ locateRange: (startOffset, endOffset) => ({
106
+ end: locatePosition(endOffset),
107
+ start: locatePosition(startOffset)
108
+ }) });
109
+ };
110
+ /**
111
+ * Decodes and normalizes source bytes through the runtime-adapter text contract.
112
+ * @param bytes The exact reader-owned source bytes.
113
+ * @returns The normalized text and locator or an invalid-text result.
114
+ */
115
+ var normalizeText = (bytes) => {
116
+ let decoded;
117
+ try {
118
+ decoded = decoder.decode(bytes);
119
+ } catch {
120
+ return Object.freeze({ valid: false });
121
+ }
122
+ const value = (decoded.startsWith("") ? decoded.slice(1) : decoded).replace(/\r\n?/gu, "\n");
123
+ if (value.includes("\0")) return Object.freeze({ valid: false });
124
+ return Object.freeze({
125
+ locator: createSourceLocator(value),
126
+ valid: true,
127
+ value
128
+ });
129
+ };
130
+ var PACKAGE_DEPENDENCY_FIELDS = Object.freeze([
131
+ "dependencies",
132
+ "optionalDependencies",
133
+ "peerDependencies",
134
+ "devDependencies"
135
+ ]);
136
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
137
+ /**
138
+ * Creates nearest-to-root package-manifest candidates for one source path.
139
+ * @param sourcePath The normalized source path.
140
+ * @returns Deterministically ordered manifest paths.
141
+ */
142
+ var createPackageManifestCandidatePaths = (sourcePath) => {
143
+ const candidates = [];
144
+ let directory = posix.dirname(sourcePath);
145
+ while (true) {
146
+ candidates.push(posix.join(directory, "package.json"));
147
+ if (directory === "/") break;
148
+ directory = posix.dirname(directory);
149
+ }
150
+ return Object.freeze(candidates);
151
+ };
152
+ var extractPackageDeclarations = (manifest, packageName) => {
153
+ const declarations = [];
154
+ for (const field of PACKAGE_DEPENDENCY_FIELDS) {
155
+ const dependencies = manifest[field];
156
+ if (dependencies === void 0) continue;
157
+ if (!isRecord(dependencies)) return null;
158
+ const declaration = dependencies[packageName];
159
+ if (declaration === void 0) continue;
160
+ if (typeof declaration !== "string" || declaration.trim().length === 0) return null;
161
+ declarations.push(Object.freeze({
162
+ declaredRange: declaration,
163
+ dependencyKind: field
164
+ }));
165
+ }
166
+ return declarations;
167
+ };
168
+ var classifyPackageDeclarations = (declarations, supportedRange) => {
169
+ const classifications = declarations.map(({ declaredRange }) => {
170
+ const normalizedRange = validRange(declaredRange, {
171
+ loose: false,
172
+ includePrerelease: false
173
+ });
174
+ if (normalizedRange === null) return "ambiguous";
175
+ if (subset(normalizedRange, supportedRange, {
176
+ loose: false,
177
+ includePrerelease: false
178
+ })) return "supported";
179
+ if (!intersects(normalizedRange, supportedRange, {
180
+ loose: false,
181
+ includePrerelease: false
182
+ })) return "unsupported";
183
+ return "ambiguous";
184
+ });
185
+ if (classifications.every((classification) => classification === "supported")) return "supported";
186
+ if (classifications.every((classification) => classification === "unsupported")) return "unsupported";
187
+ return "ambiguous";
188
+ };
189
+ /**
190
+ * Discovers the nearest package declaration without repository enumeration.
191
+ * @param options The package target, repository callbacks, path, range, and signal.
192
+ * @returns The first observed declaration, invalid manifest, or absence result.
193
+ * @throws If repository reading or the active inspection is aborted.
194
+ */
195
+ var discoverPackage = async (options) => {
196
+ const { packageName, reader, signal, sourcePath, supportedRange } = options;
197
+ for (const manifestPath of createPackageManifestCandidatePaths(sourcePath)) {
198
+ signal?.throwIfAborted();
199
+ const entry = await reader.getEntry(manifestPath);
200
+ signal?.throwIfAborted();
201
+ if (entry === null) continue;
202
+ if (entry.type !== "file") return Object.freeze({
203
+ kind: "invalid",
204
+ path: manifestPath
205
+ });
206
+ const bytes = await reader.readFile(manifestPath);
207
+ signal?.throwIfAborted();
208
+ const text = normalizeText(bytes);
209
+ signal?.throwIfAborted();
210
+ if (!text.valid) return Object.freeze({
211
+ kind: "invalid",
212
+ path: manifestPath
213
+ });
214
+ let parsed;
215
+ try {
216
+ parsed = JSON.parse(text.value);
217
+ } catch {
218
+ return Object.freeze({
219
+ kind: "invalid",
220
+ path: manifestPath
221
+ });
222
+ }
223
+ signal?.throwIfAborted();
224
+ if (!isRecord(parsed)) return Object.freeze({
225
+ kind: "invalid",
226
+ path: manifestPath
227
+ });
228
+ const declarations = extractPackageDeclarations(parsed, packageName);
229
+ if (declarations === null) return Object.freeze({
230
+ kind: "invalid",
231
+ path: manifestPath
232
+ });
233
+ if (declarations.length === 0) return Object.freeze({ kind: "absent" });
234
+ return Object.freeze({
235
+ kind: "observed",
236
+ observation: Object.freeze({
237
+ compatibility: classifyPackageDeclarations(declarations, supportedRange),
238
+ declarations: Object.freeze(declarations),
239
+ path: manifestPath
240
+ })
241
+ });
242
+ }
243
+ return Object.freeze({ kind: "absent" });
244
+ };
245
+ /**
246
+ * Removes the transparent expression wrappers supported by runtime adapters.
247
+ * @param expression The expression to normalize.
248
+ * @returns The underlying expression used by static matching.
249
+ */
250
+ var unwrapExpression = (expression) => {
251
+ let current = expression;
252
+ while (ts.isAsExpression(current) || ts.isParenthesizedExpression(current) || ts.isSatisfiesExpression(current)) current = current.expression;
253
+ return current;
254
+ };
255
+ /**
256
+ * Resolves one direct call with an optional outer `await` wrapper.
257
+ * @param expression The candidate call expression.
258
+ * @returns The direct call or `null` when the form is unsupported.
259
+ */
260
+ var getDirectCall = (expression) => {
261
+ const unwrapped = unwrapExpression(expression);
262
+ const candidate = ts.isAwaitExpression(unwrapped) ? unwrapExpression(unwrapped.expression) : unwrapped;
263
+ return ts.isCallExpression(candidate) ? candidate : null;
264
+ };
265
+ var getStaticPropertyName = (name) => {
266
+ if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text;
267
+ return null;
268
+ };
269
+ /**
270
+ * Indexes a closed object literal with exact identifier or string-literal keys.
271
+ * @param objectLiteral The candidate closed object.
272
+ * @returns Exact property expressions or `null` for dynamic or duplicate members.
273
+ */
274
+ var getClosedObjectProperties = (objectLiteral) => {
275
+ const properties = /* @__PURE__ */ new Map();
276
+ for (const property of objectLiteral.properties) {
277
+ if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) return null;
278
+ const propertyName = getStaticPropertyName(property.name);
279
+ if (propertyName === null || properties.has(propertyName)) return null;
280
+ properties.set(propertyName, unwrapExpression(ts.isPropertyAssignment(property) ? property.initializer : property.name));
281
+ }
282
+ return properties;
283
+ };
284
+ /**
285
+ * Reads an exact static string literal from one expression.
286
+ * @param expression The candidate string expression.
287
+ * @returns Its exact value or `null` when dynamic.
288
+ */
289
+ var getStaticString = (expression) => {
290
+ if (expression === null || expression === void 0) return null;
291
+ const candidate = unwrapExpression(expression);
292
+ return ts.isStringLiteral(candidate) || ts.isNoSubstitutionTemplateLiteral(candidate) ? candidate.text : null;
293
+ };
294
+ var hasModifier = (node, kind) => ts.canHaveModifiers(node) && (ts.getModifiers(node)?.some((modifier) => modifier.kind === kind) ?? false);
295
+ var isConstDeclarationList = (declarationList) => (declarationList.flags & ts.NodeFlags.Const) !== 0;
296
+ /**
297
+ * Indexes static value imports and supported SDK constructor imports.
298
+ * @param sourceFile The parsed TypeScript source.
299
+ * @param config The provider package and constructor import forms.
300
+ * @returns Module-owned import bindings needed by static checks.
301
+ */
302
+ var indexImports = (sourceFile, config) => {
303
+ const constructorNames = /* @__PURE__ */ new Set();
304
+ const namedImports = /* @__PURE__ */ new Map();
305
+ const supportedNamedImports = new Set(config.namedConstructorImports);
306
+ for (const statement of sourceFile.statements) {
307
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;
308
+ const importClause = statement.importClause;
309
+ if (importClause?.isTypeOnly === true) continue;
310
+ const moduleSpecifier = statement.moduleSpecifier.text;
311
+ if (moduleSpecifier === config.packageName && config.supportsDefaultConstructorImport && importClause?.name !== void 0) constructorNames.add(importClause.name.text);
312
+ if (moduleSpecifier === config.packageName && importClause?.namedBindings !== void 0 && ts.isNamedImports(importClause.namedBindings)) for (const element of importClause.namedBindings.elements) {
313
+ const importedName = element.propertyName?.text ?? element.name.text;
314
+ if (!element.isTypeOnly && supportedNamedImports.has(importedName)) constructorNames.add(element.name.text);
315
+ }
316
+ if (!moduleSpecifier.startsWith(".") || importClause?.namedBindings === void 0 || !ts.isNamedImports(importClause.namedBindings)) continue;
317
+ for (const element of importClause.namedBindings.elements) {
318
+ if (element.isTypeOnly) continue;
319
+ namedImports.set(element.name.text, Object.freeze({
320
+ importedName: element.propertyName?.text ?? element.name.text,
321
+ moduleSpecifier
322
+ }));
323
+ }
324
+ }
325
+ return {
326
+ constructorNames,
327
+ namedImports
328
+ };
329
+ };
330
+ /**
331
+ * Indexes direct exports, module-level SDK clients, and constant arrays.
332
+ * @param sourceFile The parsed TypeScript source.
333
+ * @param constructorNames The supported constructor bindings.
334
+ * @returns Static module declarations used by adapter inspection.
335
+ */
336
+ var indexModuleDeclarations = (sourceFile, constructorNames) => {
337
+ const clientNames = /* @__PURE__ */ new Set();
338
+ const exports = /* @__PURE__ */ new Map();
339
+ const moduleArrays = /* @__PURE__ */ new Map();
340
+ const moduleConstDeclarations = /* @__PURE__ */ new Map();
341
+ for (const statement of sourceFile.statements) {
342
+ if (ts.isFunctionDeclaration(statement) && statement.name !== void 0) {
343
+ if (hasModifier(statement, ts.SyntaxKind.ExportKeyword)) exports.set(statement.name.text, Object.freeze({
344
+ declaration: statement,
345
+ kind: statement.body === void 0 || hasModifier(statement, ts.SyntaxKind.DefaultKeyword) ? "present-unsupported" : "present-supported"
346
+ }));
347
+ continue;
348
+ }
349
+ if (ts.isExportDeclaration(statement) && statement.exportClause !== void 0) {
350
+ if (!ts.isNamedExports(statement.exportClause) || statement.isTypeOnly) continue;
351
+ for (const element of statement.exportClause.elements) if (!element.isTypeOnly) exports.set(element.name.text, Object.freeze({
352
+ declaration: element,
353
+ kind: "present-unsupported"
354
+ }));
355
+ continue;
356
+ }
357
+ if (!ts.isVariableStatement(statement)) {
358
+ if (hasModifier(statement, ts.SyntaxKind.ExportKeyword) && (ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement)) && statement.name !== void 0 && ts.isIdentifier(statement.name)) exports.set(statement.name.text, Object.freeze({
359
+ declaration: statement,
360
+ kind: "present-unsupported"
361
+ }));
362
+ continue;
363
+ }
364
+ const isConst = isConstDeclarationList(statement.declarationList);
365
+ const isExported = hasModifier(statement, ts.SyntaxKind.ExportKeyword);
366
+ for (const declaration of statement.declarationList.declarations) {
367
+ if (!ts.isIdentifier(declaration.name)) continue;
368
+ if (isExported) exports.set(declaration.name.text, Object.freeze({
369
+ declaration,
370
+ kind: isConst && declaration.initializer !== void 0 ? "present-supported" : "present-unsupported"
371
+ }));
372
+ if (!isConst || declaration.initializer === void 0) continue;
373
+ moduleConstDeclarations.set(declaration.name.text, declaration);
374
+ const initializer = unwrapExpression(declaration.initializer);
375
+ if (ts.isNewExpression(initializer)) {
376
+ const constructor = unwrapExpression(initializer.expression);
377
+ if (ts.isIdentifier(constructor) && constructorNames.has(constructor.text)) clientNames.add(declaration.name.text);
378
+ }
379
+ if (ts.isArrayLiteralExpression(initializer)) moduleArrays.set(declaration.name.text, Object.freeze({
380
+ declaration,
381
+ expression: initializer
382
+ }));
383
+ }
384
+ }
385
+ return {
386
+ clientNames,
387
+ exports,
388
+ moduleArrays,
389
+ moduleConstDeclarations
390
+ };
391
+ };
392
+ var addBindingNames = (names, bindingName) => {
393
+ if (ts.isIdentifier(bindingName)) {
394
+ names.add(bindingName.text);
395
+ return;
396
+ }
397
+ for (const element of bindingName.elements) if (!ts.isOmittedExpression(element)) addBindingNames(names, element.name);
398
+ };
399
+ var addVariableDeclarationListBindings = (names, declarationList) => {
400
+ for (const declaration of declarationList.declarations) addBindingNames(names, declaration.name);
401
+ };
402
+ var addStatementBindings = (names, statement) => {
403
+ if (ts.isVariableStatement(statement)) {
404
+ addVariableDeclarationListBindings(names, statement.declarationList);
405
+ return;
406
+ }
407
+ if (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement)) {
408
+ if (statement.name !== void 0 && ts.isIdentifier(statement.name)) names.add(statement.name.text);
409
+ }
410
+ };
411
+ var isFunctionScope = (node) => ts.isArrowFunction(node) || ts.isConstructorDeclaration(node) || ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isGetAccessorDeclaration(node) || ts.isMethodDeclaration(node) || ts.isSetAccessorDeclaration(node);
412
+ var getLocalBindingNames = (bindings, scope) => {
413
+ const existingNames = bindings.get(scope);
414
+ if (existingNames !== void 0) return existingNames;
415
+ const names = /* @__PURE__ */ new Set();
416
+ bindings.set(scope, names);
417
+ return names;
418
+ };
419
+ /**
420
+ * Indexes local runtime bindings that can shadow module-owned identifiers.
421
+ * @param sourceFile The parsed TypeScript source.
422
+ * @returns Local binding names keyed by lexical or function scope.
423
+ */
424
+ var indexLocalBindingNames = (sourceFile) => {
425
+ const bindings = /* @__PURE__ */ new Map();
426
+ const visit = (node, functionScope) => {
427
+ let childFunctionScope = functionScope;
428
+ if (isFunctionScope(node)) {
429
+ const names = getLocalBindingNames(bindings, node);
430
+ for (const parameter of node.parameters) addBindingNames(names, parameter.name);
431
+ if (node.name !== void 0 && ts.isIdentifier(node.name)) names.add(node.name.text);
432
+ childFunctionScope = node;
433
+ }
434
+ if (ts.isBlock(node) || ts.isModuleBlock(node)) {
435
+ const names = getLocalBindingNames(bindings, node);
436
+ for (const statement of node.statements) addStatementBindings(names, statement);
437
+ } else if (ts.isCaseBlock(node)) {
438
+ const names = getLocalBindingNames(bindings, node);
439
+ for (const clause of node.clauses) for (const statement of clause.statements) addStatementBindings(names, statement);
440
+ } else if (ts.isCatchClause(node) && node.variableDeclaration !== void 0) addBindingNames(getLocalBindingNames(bindings, node), node.variableDeclaration.name);
441
+ else if ((ts.isForStatement(node) || ts.isForInStatement(node) || ts.isForOfStatement(node)) && node.initializer !== void 0 && ts.isVariableDeclarationList(node.initializer)) addVariableDeclarationListBindings(getLocalBindingNames(bindings, node), node.initializer);
442
+ else if (ts.isClassExpression(node) && node.name !== void 0) getLocalBindingNames(bindings, node).add(node.name.text);
443
+ if (childFunctionScope !== null && ts.isVariableDeclarationList(node) && (node.flags & ts.NodeFlags.BlockScoped) === 0) addVariableDeclarationListBindings(getLocalBindingNames(bindings, childFunctionScope), node);
444
+ ts.forEachChild(node, (child) => visit(child, childFunctionScope));
445
+ };
446
+ visit(sourceFile, null);
447
+ return bindings;
448
+ };
449
+ /**
450
+ * Indexes identifier occurrences once for binding-specific safety analysis.
451
+ * @param sourceFile The parsed TypeScript source.
452
+ * @returns Identifier occurrences grouped by exact source spelling.
453
+ */
454
+ var indexIdentifierUses = (sourceFile) => {
455
+ const identifierUses = /* @__PURE__ */ new Map();
456
+ const visit = (node) => {
457
+ if (ts.isIdentifier(node)) {
458
+ const uses = identifierUses.get(node.text) ?? [];
459
+ uses.push(node);
460
+ identifierUses.set(node.text, uses);
461
+ }
462
+ ts.forEachChild(node, visit);
463
+ };
464
+ visit(sourceFile);
465
+ return new Map([...identifierUses].map(([name, uses]) => [name, Object.freeze(uses)]));
466
+ };
467
+ /**
468
+ * Determines whether a module-bound name is visible at one identifier use.
469
+ * @param identifier The identifier whose lexical environment is inspected.
470
+ * @param analysis The indexed source containing the identifier.
471
+ * @returns Whether no parameter or local declaration shadows the module binding.
472
+ */
473
+ var isModuleBindingVisible = (identifier, analysis) => {
474
+ let current = identifier.parent;
475
+ while (current !== void 0 && !ts.isSourceFile(current)) {
476
+ if (analysis.localBindingNames.get(current)?.has(identifier.text) === true) return false;
477
+ current = current.parent;
478
+ }
479
+ return true;
480
+ };
481
+ /**
482
+ * Resolves TypeScript source candidates for a supported relative ESM specifier.
483
+ * @param containingPath The importing source path.
484
+ * @param moduleSpecifier The exact relative ESM specifier.
485
+ * @returns Supported logical source candidates in deterministic order.
486
+ */
487
+ var resolveImportCandidatePaths = (containingPath, moduleSpecifier) => {
488
+ const resolved = posix.resolve(posix.dirname(containingPath), moduleSpecifier);
489
+ if (resolved.endsWith(".js")) return [`${resolved.slice(0, -3)}.ts`, `${resolved.slice(0, -3)}.tsx`];
490
+ if (resolved.endsWith(".mjs")) return [`${resolved.slice(0, -4)}.mts`];
491
+ return [
492
+ ".ts",
493
+ ".tsx",
494
+ ".mts"
495
+ ].some((extension) => resolved.endsWith(extension)) ? [resolved] : [];
496
+ };
497
+ /**
498
+ * Resolves the explicit module references an identifier can denote.
499
+ * @param identifier The local source identifier.
500
+ * @param analysis The source containing that identifier.
501
+ * @returns Same-file or relative-import candidates in deterministic order.
502
+ */
503
+ var resolveBindingReferences = (identifier, analysis) => {
504
+ if (!isModuleBindingVisible(identifier, analysis)) return [];
505
+ const references = [];
506
+ if (analysis.exports.has(identifier.text)) references.push(Object.freeze({
507
+ path: analysis.path,
508
+ symbol: identifier.text
509
+ }));
510
+ const namedImport = analysis.namedImports.get(identifier.text);
511
+ if (namedImport !== void 0) references.push(...resolveImportCandidatePaths(analysis.path, namedImport.moduleSpecifier).map((path) => Object.freeze({
512
+ path,
513
+ symbol: namedImport.importedName
514
+ })));
515
+ return references;
516
+ };
517
+ /**
518
+ * Checks whether an identifier resolves directly to an explicit bound reference.
519
+ * @param identifier The local source identifier.
520
+ * @param analysis The source containing that identifier.
521
+ * @param reference The explicit source binding to match.
522
+ * @returns Whether local or named-import identity proves the relationship.
523
+ */
524
+ var isBoundIdentifier = (identifier, analysis, reference) => {
525
+ if (reference.symbol === void 0) return false;
526
+ return resolveBindingReferences(identifier, analysis).some((candidate) => candidate.path === reference.path && candidate.symbol === reference.symbol);
527
+ };
528
+ var getDirectPropertyName$1 = (name) => {
529
+ if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text;
530
+ return null;
531
+ };
532
+ var getPotentialRelationshipNames = (name, relationshipNames) => {
533
+ const directName = getDirectPropertyName$1(name);
534
+ if (directName !== null) return relationshipNames.includes(directName) ? [directName] : [];
535
+ if (!ts.isComputedPropertyName(name)) return [];
536
+ const expression = unwrapExpression(name.expression);
537
+ if (ts.isStringLiteral(expression) || ts.isNoSubstitutionTemplateLiteral(expression)) return relationshipNames.includes(expression.text) ? [expression.text] : [];
538
+ if (ts.isNumericLiteral(expression) || expression.kind === ts.SyntaxKind.TrueKeyword || expression.kind === ts.SyntaxKind.FalseKeyword || expression.kind === ts.SyntaxKind.NullKeyword) return [];
539
+ return relationshipNames;
540
+ };
541
+ /**
542
+ * Classifies selected properties on one object literal without interpreting unrelated values.
543
+ * @param object The object literal whose direct properties are inspected.
544
+ * @param relationshipNames The exact properties owned by the caller.
545
+ * @returns Independent closed, absent, or unresolved relationship observations.
546
+ */
547
+ var analyzeObjectRelationships = (object, relationshipNames) => {
548
+ const states = new Map(relationshipNames.map((name) => [name, {
549
+ directPropertyCount: 0,
550
+ relationship: { kind: "absent" }
551
+ }]));
552
+ const markUnresolved = (names) => {
553
+ for (const name of names) {
554
+ const state = states.get(name);
555
+ if (state !== void 0) state.relationship = { kind: "unresolved" };
556
+ }
557
+ };
558
+ for (const property of object.properties) {
559
+ if (ts.isSpreadAssignment(property)) {
560
+ markUnresolved(relationshipNames);
561
+ continue;
562
+ }
563
+ const potentialNames = getPotentialRelationshipNames(property.name, relationshipNames);
564
+ const relationshipExpression = ts.isPropertyAssignment(property) ? property.initializer : ts.isShorthandPropertyAssignment(property) ? property.name : null;
565
+ if (relationshipExpression === null) {
566
+ markUnresolved(potentialNames);
567
+ continue;
568
+ }
569
+ const directName = getDirectPropertyName$1(property.name);
570
+ if (directName === null || !relationshipNames.includes(directName)) {
571
+ markUnresolved(potentialNames);
572
+ continue;
573
+ }
574
+ const state = states.get(directName);
575
+ if (state === void 0) continue;
576
+ state.directPropertyCount += 1;
577
+ state.relationship = state.directPropertyCount === 1 ? {
578
+ expression: unwrapExpression(relationshipExpression),
579
+ kind: "present"
580
+ } : { kind: "unresolved" };
581
+ }
582
+ return Object.freeze({
583
+ object,
584
+ relationships: new Map([...states].map(([name, state]) => [name, Object.freeze(state.relationship)]))
585
+ });
586
+ };
587
+ var READONLY_ARRAY_METHODS = /* @__PURE__ */ new Set([
588
+ "at",
589
+ "concat",
590
+ "entries",
591
+ "flat",
592
+ "includes",
593
+ "indexOf",
594
+ "join",
595
+ "keys",
596
+ "lastIndexOf",
597
+ "slice",
598
+ "toLocaleString",
599
+ "toReversed",
600
+ "toSpliced",
601
+ "toString",
602
+ "values",
603
+ "with"
604
+ ]);
605
+ var skipTransparentParents$1 = (node) => {
606
+ let current = node;
607
+ while (ts.isAsExpression(current.parent) || ts.isParenthesizedExpression(current.parent) || ts.isSatisfiesExpression(current.parent)) current = current.parent;
608
+ return current;
609
+ };
610
+ var isAssignmentOperator$1 = (kind) => kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
611
+ var isAssignmentTarget = (expression) => {
612
+ let current = skipTransparentParents$1(expression);
613
+ while (true) {
614
+ const parent = current.parent;
615
+ if (ts.isBinaryExpression(parent) && isAssignmentOperator$1(parent.operatorToken.kind)) return parent.left === current;
616
+ if ((ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) && parent.operand === current && (parent.operator === ts.SyntaxKind.PlusPlusToken || parent.operator === ts.SyntaxKind.MinusMinusToken)) return true;
617
+ if (ts.isDeleteExpression(parent) && parent.expression === current) return true;
618
+ if ((ts.isForInStatement(parent) || ts.isForOfStatement(parent)) && parent.initializer === current) return true;
619
+ if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent) || ts.isPropertyAssignment(parent) || ts.isSpreadAssignment(parent) || ts.isSpreadElement(parent) || ts.isArrayLiteralExpression(parent) || ts.isObjectLiteralExpression(parent)) {
620
+ current = skipTransparentParents$1(parent);
621
+ continue;
622
+ }
623
+ return false;
624
+ }
625
+ };
626
+ var getStaticMemberName$1 = (member) => {
627
+ if (ts.isPropertyAccessExpression(member)) return member.name.text;
628
+ const argument = member.argumentExpression;
629
+ return argument !== void 0 && (ts.isStringLiteral(argument) || ts.isNoSubstitutionTemplateLiteral(argument)) ? argument.text : null;
630
+ };
631
+ var isSafeArrayMemberUse = (member) => {
632
+ if (isAssignmentTarget(member)) return false;
633
+ const candidate = skipTransparentParents$1(member);
634
+ const parent = candidate.parent;
635
+ if (!ts.isCallExpression(parent) || parent.expression !== candidate) return ts.isPropertyAccessExpression(member) && member.name.text === "length";
636
+ const memberName = getStaticMemberName$1(member);
637
+ const call = skipTransparentParents$1(parent);
638
+ return memberName !== null && READONLY_ARRAY_METHODS.has(memberName) && ts.isExpressionStatement(call.parent);
639
+ };
640
+ var isIgnoredIdentifierPosition = (identifier, declarationName) => identifier === declarationName || ts.isImportSpecifier(identifier.parent) || ts.isPropertyAssignment(identifier.parent) && identifier.parent.name === identifier || ts.isPropertyAccessExpression(identifier.parent) && identifier.parent.name === identifier;
641
+ /**
642
+ * Determines whether a module value binding has only explicitly allowed value uses.
643
+ * @param analysis The indexed source containing the binding references.
644
+ * @param bindingName The exact lexically visible module binding name.
645
+ * @param declarationName The optional local declaration identifier to exclude.
646
+ * @param allowedReferences Exact bare identifier occurrences owned by supported relationships.
647
+ * @param kind Whether array read-only member access is permitted for the value.
648
+ * @returns Whether the binding cannot be aliased, escaped, reassigned, or mutated.
649
+ */
650
+ var isModuleValueBindingSafe = (analysis, bindingName, declarationName, allowedReferences, kind) => {
651
+ const identifierUses = analysis.identifierUses.get(bindingName) ?? [];
652
+ for (const identifier of identifierUses) {
653
+ if (isIgnoredIdentifierPosition(identifier, declarationName) || !isModuleBindingVisible(identifier, analysis)) continue;
654
+ if (allowedReferences.has(identifier)) continue;
655
+ const expression = skipTransparentParents$1(identifier);
656
+ const parent = expression.parent;
657
+ const member = (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === expression ? parent : null;
658
+ if (kind !== "array" || member === null || !isSafeArrayMemberUse(member)) return false;
659
+ }
660
+ return true;
661
+ };
662
+ /**
663
+ * Determines whether a module-local constant literal has only explicitly allowed value uses.
664
+ * @param analysis The indexed source containing the declaration and its references.
665
+ * @param declaration The module-local constant declaration to inspect.
666
+ * @param allowedReferences Exact bare identifier occurrences owned by supported relationships.
667
+ * @param kind Whether array read-only member access is permitted for the value.
668
+ * @returns Whether the binding cannot be aliased, escaped, reassigned, or mutated.
669
+ */
670
+ var isModuleConstValueSafe = (analysis, declaration, allowedReferences, kind) => {
671
+ if (!ts.isIdentifier(declaration.name)) return false;
672
+ return isModuleValueBindingSafe(analysis, declaration.name.text, declaration.name, allowedReferences, kind);
673
+ };
674
+ function getSafeModuleConstLiteral(expression, analysis, allowedReferences, kind) {
675
+ const candidate = unwrapExpression(expression);
676
+ if (!ts.isIdentifier(candidate) || !isModuleBindingVisible(candidate, analysis)) return null;
677
+ const declaration = analysis.moduleConstDeclarations.get(candidate.text);
678
+ const initializer = declaration?.initializer === void 0 ? null : unwrapExpression(declaration.initializer);
679
+ const isExpectedLiteral = initializer !== null && (kind === "array" ? ts.isArrayLiteralExpression(initializer) : ts.isObjectLiteralExpression(initializer));
680
+ if (declaration === void 0 || !isExpectedLiteral || !isModuleConstValueSafe(analysis, declaration, allowedReferences, kind)) return null;
681
+ return Object.freeze({
682
+ declaration,
683
+ expression: initializer
684
+ });
685
+ }
686
+ var skipTransparentParents = (node) => {
687
+ let current = node;
688
+ while (ts.isAsExpression(current.parent) || ts.isParenthesizedExpression(current.parent) || ts.isSatisfiesExpression(current.parent)) current = current.parent;
689
+ return current;
690
+ };
691
+ var isAssignmentOperator = (kind) => kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
692
+ var isMutatingTarget = (expression) => {
693
+ const candidate = skipTransparentParents(expression);
694
+ const parent = candidate.parent;
695
+ return ts.isBinaryExpression(parent) && parent.left === candidate && isAssignmentOperator(parent.operatorToken.kind) || (ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) && parent.operand === candidate && (parent.operator === ts.SyntaxKind.PlusPlusToken || parent.operator === ts.SyntaxKind.MinusMinusToken) || ts.isDeleteExpression(parent) && parent.expression === candidate || (ts.isForInStatement(parent) || ts.isForOfStatement(parent)) && parent.initializer === candidate;
696
+ };
697
+ var getStaticMemberName = (member) => {
698
+ if (ts.isPropertyAccessExpression(member)) return member.name.text;
699
+ const argument = member.argumentExpression;
700
+ return argument !== void 0 && (ts.isStringLiteral(argument) || ts.isNoSubstitutionTemplateLiteral(argument)) ? argument.text : null;
701
+ };
702
+ var isIgnoredIdentifier = (identifier, declarationName) => identifier === declarationName || ts.isImportSpecifier(identifier.parent) || ts.isPropertyAccessExpression(identifier.parent) && identifier.parent.name === identifier || ts.isPropertyAssignment(identifier.parent) && identifier.parent.name === identifier;
703
+ var addObjectAssignmentMembers = (object, mutatedMembers) => {
704
+ let hasUnknownMutation = false;
705
+ for (const property of object.properties) {
706
+ if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) {
707
+ hasUnknownMutation = true;
708
+ continue;
709
+ }
710
+ const propertyName = ts.isIdentifier(property.name) || ts.isStringLiteral(property.name) ? property.name.text : null;
711
+ if (propertyName === null) hasUnknownMutation = true;
712
+ else mutatedMembers.add(propertyName);
713
+ }
714
+ return hasUnknownMutation;
715
+ };
716
+ var analyzeMutationCall = (identifier, mutatedMembers) => {
717
+ const candidate = skipTransparentParents(identifier);
718
+ const parent = candidate.parent;
719
+ if (!ts.isCallExpression(parent)) return null;
720
+ const callee = unwrapExpression(parent.expression);
721
+ if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "Object" && callee.name.text === "assign" && parent.arguments[0] === candidate) {
722
+ let hasUnknownMutation = parent.arguments.length < 2;
723
+ for (const source of parent.arguments.slice(1)) {
724
+ const assignmentSource = unwrapExpression(source);
725
+ if (!ts.isObjectLiteralExpression(assignmentSource)) hasUnknownMutation = true;
726
+ else if (addObjectAssignmentMembers(assignmentSource, mutatedMembers)) hasUnknownMutation = true;
727
+ }
728
+ return hasUnknownMutation;
729
+ }
730
+ if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "Reflect" && callee.name.text === "set" && parent.arguments[0] === candidate) {
731
+ const member = parent.arguments[1];
732
+ if (member !== void 0 && (ts.isStringLiteral(member) || ts.isNoSubstitutionTemplateLiteral(member))) {
733
+ mutatedMembers.add(member.text);
734
+ return false;
735
+ }
736
+ return true;
737
+ }
738
+ return true;
739
+ };
740
+ /**
741
+ * Classifies module-local mutations and escapes for one returned object value.
742
+ * @param analysis The indexed source containing the binding.
743
+ * @param declaration The module-local constant declaration.
744
+ * @param allowedReferences Bare identifier uses proven to be supported registrations or targets.
745
+ * @returns Member-specific mutations and whether an unknown use can affect every relationship.
746
+ */
747
+ var analyzeModuleValueMutations = (analysis, declaration, allowedReferences) => {
748
+ if (!ts.isIdentifier(declaration.name)) return Object.freeze({
749
+ hasUnknownMutation: true,
750
+ mutatedMembers: /* @__PURE__ */ new Set()
751
+ });
752
+ const mutatedMembers = /* @__PURE__ */ new Set();
753
+ let hasUnknownMutation = false;
754
+ for (const identifier of analysis.identifierUses.get(declaration.name.text) ?? []) {
755
+ if (isIgnoredIdentifier(identifier, declaration.name) || !isModuleBindingVisible(identifier, analysis) || allowedReferences.has(identifier)) continue;
756
+ const expression = skipTransparentParents(identifier);
757
+ const parent = expression.parent;
758
+ const member = (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === expression ? parent : null;
759
+ if (member !== null) {
760
+ const memberName = getStaticMemberName(member);
761
+ if (memberName === null) hasUnknownMutation = true;
762
+ else if (isMutatingTarget(member)) mutatedMembers.add(memberName);
763
+ else {
764
+ const memberExpression = skipTransparentParents(member);
765
+ const memberParent = memberExpression.parent;
766
+ if ((ts.isPropertyAccessExpression(memberParent) || ts.isElementAccessExpression(memberParent)) && memberParent.expression === memberExpression && ts.isCallExpression(skipTransparentParents(memberParent).parent)) mutatedMembers.add(memberName);
767
+ else if (ts.isCallExpression(memberParent) && memberParent.expression === memberExpression) mutatedMembers.add(memberName);
768
+ }
769
+ continue;
770
+ }
771
+ if (isMutatingTarget(identifier)) {
772
+ hasUnknownMutation = true;
773
+ continue;
774
+ }
775
+ const mutationCall = analyzeMutationCall(identifier, mutatedMembers);
776
+ hasUnknownMutation ||= mutationCall ?? true;
777
+ }
778
+ return Object.freeze({
779
+ hasUnknownMutation,
780
+ mutatedMembers: new Set(mutatedMembers)
781
+ });
782
+ };
783
+ var getScriptKind = (path) => path.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
784
+ var createSyntaxProgram = (sourceFile, text) => {
785
+ return ts.createProgram({
786
+ host: {
787
+ fileExists: (fileName) => fileName === sourceFile.fileName,
788
+ getCanonicalFileName: (fileName) => fileName,
789
+ getCurrentDirectory: () => "/",
790
+ getDefaultLibFileName: () => "/lib.d.ts",
791
+ getDirectories: () => [],
792
+ getNewLine: () => "\n",
793
+ getSourceFile: (fileName) => fileName === sourceFile.fileName ? sourceFile : void 0,
794
+ readFile: (fileName) => fileName === sourceFile.fileName ? text : void 0,
795
+ useCaseSensitiveFileNames: () => true,
796
+ writeFile: () => void 0
797
+ },
798
+ options: {
799
+ jsx: ts.JsxEmit.Preserve,
800
+ module: ts.ModuleKind.ESNext,
801
+ noLib: true,
802
+ noResolve: true,
803
+ target: ts.ScriptTarget.ES2023
804
+ },
805
+ rootNames: [sourceFile.fileName]
806
+ });
807
+ };
808
+ /**
809
+ * Parses and indexes one TypeScript module without provider request assumptions.
810
+ * @param path The normalized logical source path.
811
+ * @param bytes The exact source bytes returned by the adapter reader.
812
+ * @param importConfig The provider constructor-import contract.
813
+ * @param signal The active inspection signal.
814
+ * @returns A source analysis or stable invalid-text or invalid-syntax result.
815
+ * @throws If source analysis is aborted.
816
+ */
817
+ var analyzeTypeScriptModule = (path, bytes, importConfig, signal) => {
818
+ signal?.throwIfAborted();
819
+ const text = normalizeText(bytes);
820
+ if (!text.valid) return Object.freeze({ kind: "invalid-text" });
821
+ signal?.throwIfAborted();
822
+ const sourceFile = ts.createSourceFile(path, text.value, ts.ScriptTarget.ES2023, true, getScriptKind(path));
823
+ const syntaxDiagnostic = createSyntaxProgram(sourceFile, text.value).getSyntacticDiagnostics(sourceFile).filter(({ category }) => category === ts.DiagnosticCategory.Error).sort((left, right) => (left.start ?? 0) - (right.start ?? 0))[0];
824
+ signal?.throwIfAborted();
825
+ if (syntaxDiagnostic !== void 0) {
826
+ const start = syntaxDiagnostic.start;
827
+ return Object.freeze({
828
+ kind: "invalid-syntax",
829
+ range: start === void 0 ? null : text.locator.locateRange(start, start + (syntaxDiagnostic.length ?? 0))
830
+ });
831
+ }
832
+ const { constructorNames, namedImports } = indexImports(sourceFile, importConfig);
833
+ signal?.throwIfAborted();
834
+ const { clientNames, exports, moduleArrays, moduleConstDeclarations } = indexModuleDeclarations(sourceFile, constructorNames);
835
+ signal?.throwIfAborted();
836
+ const identifierUses = indexIdentifierUses(sourceFile);
837
+ signal?.throwIfAborted();
838
+ const localBindingNames = indexLocalBindingNames(sourceFile);
839
+ signal?.throwIfAborted();
840
+ const analysis = Object.freeze({
841
+ clientNames,
842
+ constructorNames,
843
+ exports,
844
+ identifierUses,
845
+ localBindingNames,
846
+ moduleArrays,
847
+ moduleConstDeclarations,
848
+ namedImports,
849
+ path,
850
+ safeModuleArrayNames: /* @__PURE__ */ new Set(),
851
+ sourceFile,
852
+ text
853
+ });
854
+ signal?.throwIfAborted();
855
+ return Object.freeze({
856
+ analysis,
857
+ kind: "valid"
858
+ });
859
+ };
860
+ /**
861
+ * Determines whether a path uses a supported TypeScript source extension.
862
+ * @param path The bound source path.
863
+ * @returns Whether its extension is supported.
864
+ */
865
+ var isSupportedTypeScriptSourcePath = (path) => [
866
+ ".ts",
867
+ ".tsx",
868
+ ".mts"
869
+ ].some((extension) => path.endsWith(extension));
870
+ /**
871
+ * Classifies a direct exported runtime-agent function and exposes its body.
872
+ * @param analysis The indexed runtime source.
873
+ * @param symbol The bound runtime-agent symbol.
874
+ * @returns The symbol state and supported body when available.
875
+ */
876
+ var getRuntimeExport = (analysis, symbol) => {
877
+ const exported = analysis.exports.get(symbol);
878
+ if (exported === void 0) return Object.freeze({ kind: "absent" });
879
+ if (exported.kind === "present-unsupported") return exported;
880
+ const { declaration } = exported;
881
+ if (ts.isFunctionDeclaration(declaration) && declaration.body !== void 0) return Object.freeze({
882
+ body: declaration.body,
883
+ declaration,
884
+ kind: "present-supported"
885
+ });
886
+ if (ts.isVariableDeclaration(declaration) && declaration.initializer !== void 0) {
887
+ const initializer = unwrapExpression(declaration.initializer);
888
+ if (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) return Object.freeze({
889
+ body: initializer.body,
890
+ declaration,
891
+ kind: "present-supported"
892
+ });
893
+ }
894
+ return Object.freeze({
895
+ declaration,
896
+ kind: "present-unsupported"
897
+ });
898
+ };
899
+ /**
900
+ * Classifies a directly exported callable value such as an instruction loader.
901
+ * @param analysis The indexed source.
902
+ * @param symbol The exact bound symbol.
903
+ * @returns The symbol state for conservative call matching.
904
+ */
905
+ var getCallableExportState = (analysis, symbol) => {
906
+ const runtimeExport = getRuntimeExport(analysis, symbol);
907
+ return runtimeExport.kind === "present-supported" ? Object.freeze({
908
+ declaration: runtimeExport.declaration,
909
+ kind: "present-supported"
910
+ }) : runtimeExport;
911
+ };
912
+ /**
913
+ * Classifies a directly exported constant and returns its static initializer.
914
+ * @param analysis The indexed source.
915
+ * @param symbol The exact bound symbol.
916
+ * @returns The symbol state and initializer when supported.
917
+ */
918
+ var getConstExport = (analysis, symbol) => {
919
+ const exported = analysis.exports.get(symbol);
920
+ if (exported === void 0) return Object.freeze({ kind: "absent" });
921
+ if (exported.kind === "present-supported" && ts.isVariableDeclaration(exported.declaration) && exported.declaration.initializer !== void 0) return Object.freeze({
922
+ declaration: exported.declaration,
923
+ expression: unwrapExpression(exported.declaration.initializer),
924
+ kind: "present-supported"
925
+ });
926
+ return Object.freeze({
927
+ declaration: exported.declaration,
928
+ kind: "present-unsupported"
929
+ });
930
+ };
931
+ var resolveCandidatePath = async (options, containingPath, moduleSpecifier) => {
932
+ const matchingPaths = [];
933
+ for (const candidate of resolveImportCandidatePaths(containingPath, moduleSpecifier)) {
934
+ const path = options.parsePath(candidate);
935
+ if ((await options.getEntry(path))?.type === "file") matchingPaths.push(path);
936
+ }
937
+ return matchingPaths.length === 1 ? matchingPaths[0] : null;
938
+ };
939
+ var resolveStaticStringExpression = async (options, analysis, expression, visited) => {
940
+ options.signal?.throwIfAborted();
941
+ const candidate = unwrapExpression(expression);
942
+ const literal = getStaticString(candidate);
943
+ if (literal !== null) return Object.freeze({
944
+ expression: candidate,
945
+ kind: "supported",
946
+ value: literal
947
+ });
948
+ if (!ts.isIdentifier(candidate) || !isModuleBindingVisible(candidate, analysis)) return Object.freeze({ kind: "unsupported" });
949
+ const localDeclaration = analysis.moduleConstDeclarations.get(candidate.text);
950
+ if (localDeclaration?.initializer !== void 0) {
951
+ const key = `${analysis.path}\0local\0${candidate.text}`;
952
+ if (visited.has(key)) return Object.freeze({ kind: "unsupported" });
953
+ visited.add(key);
954
+ const result = await resolveStaticStringExpression(options, analysis, localDeclaration.initializer, visited);
955
+ visited.delete(key);
956
+ return result;
957
+ }
958
+ const namedImport = analysis.namedImports.get(candidate.text);
959
+ if (namedImport === void 0) return Object.freeze({ kind: "unsupported" });
960
+ const importedPath = await resolveCandidatePath(options, analysis.path, namedImport.moduleSpecifier);
961
+ if (importedPath === null) return Object.freeze({ kind: "unsupported" });
962
+ const key = `${importedPath}\0export\0${namedImport.importedName}`;
963
+ if (visited.has(key)) return Object.freeze({ kind: "unsupported" });
964
+ visited.add(key);
965
+ const importedResult = await options.analyzeSource(importedPath);
966
+ if (importedResult.kind !== "valid") {
967
+ visited.delete(key);
968
+ return Object.freeze({ kind: "unsupported" });
969
+ }
970
+ const exported = getConstExport(importedResult.analysis, namedImport.importedName);
971
+ if (exported.kind !== "present-supported" || exported.expression === void 0) {
972
+ visited.delete(key);
973
+ return Object.freeze({ kind: "unsupported" });
974
+ }
975
+ const result = await resolveStaticStringExpression(options, importedResult.analysis, exported.expression, visited);
976
+ visited.delete(key);
977
+ return result;
978
+ };
979
+ /**
980
+ * Resolves one exact supported static string without normalization or execution.
981
+ * @param options The source, expression, repository callbacks, and parser for the relationship.
982
+ * @returns The exact compiler-parsed string or an unsupported state.
983
+ */
984
+ var resolveStaticString = (options) => resolveStaticStringExpression(options, options.analysis, options.expression, /* @__PURE__ */ new Set());
985
+ //#endregion
986
+ //#region src/source-analysis/collections.ts
987
+ /**
988
+ * Resolves a closed inline or immutable module-local array relationship.
989
+ * @param relationship The relationship containing the array.
990
+ * @param analysis The source containing the relationship.
991
+ * @param allowedReferences Direct supported uses of the module array.
992
+ * @returns Exact elements, `null` when unresolved, or an empty array when absent.
993
+ */
994
+ var getClaudeAgentSdkClosedArray = (relationship, analysis, allowedReferences) => {
995
+ if (relationship.kind === "absent") return [];
996
+ if (relationship.kind !== "present") return null;
997
+ const candidate = unwrapExpression(relationship.expression);
998
+ const moduleArray = ts.isArrayLiteralExpression(candidate) ? null : getSafeModuleConstLiteral(candidate, analysis, allowedReferences, "array");
999
+ const array = ts.isArrayLiteralExpression(candidate) ? candidate : moduleArray?.expression;
1000
+ if (array === void 0 || array.elements.some((element) => ts.isOmittedExpression(element) || ts.isSpreadElement(element))) return null;
1001
+ return Object.freeze(array.elements.map((element) => unwrapExpression(element)));
1002
+ };
1003
+ /**
1004
+ * Resolves a closed inline or immutable module-local object relationship.
1005
+ * @param relationship The relationship containing the map.
1006
+ * @param analysis The source containing the relationship.
1007
+ * @param allowedReferences Direct supported uses of the module object.
1008
+ * @returns Static direct entries, `null` when unresolved, or an empty array when absent.
1009
+ */
1010
+ var getClaudeAgentSdkClosedMapEntries = (relationship, analysis, allowedReferences) => {
1011
+ if (relationship.kind === "absent") return [];
1012
+ if (relationship.kind !== "present") return null;
1013
+ const candidate = unwrapExpression(relationship.expression);
1014
+ const moduleObject = ts.isObjectLiteralExpression(candidate) ? null : getSafeModuleConstLiteral(candidate, analysis, allowedReferences, "object");
1015
+ const object = ts.isObjectLiteralExpression(candidate) ? candidate : moduleObject?.expression;
1016
+ if (object === void 0) return null;
1017
+ const entries = [];
1018
+ const names = /* @__PURE__ */ new Set();
1019
+ for (const property of object.properties) {
1020
+ if (!ts.isPropertyAssignment(property)) return null;
1021
+ const name = ts.isIdentifier(property.name) || ts.isStringLiteral(property.name) ? property.name.text : ts.isComputedPropertyName(property.name) ? null : void 0;
1022
+ if (name === void 0 || name !== null && names.has(name)) return null;
1023
+ if (name !== null) names.add(name);
1024
+ entries.push(Object.freeze({
1025
+ keyExpression: ts.isComputedPropertyName(property.name) ? property.name.expression : property.name,
1026
+ name,
1027
+ value: unwrapExpression(property.initializer)
1028
+ }));
1029
+ }
1030
+ return Object.freeze(entries);
1031
+ };
1032
+ //#endregion
1033
+ //#region src/source-analysis/mutations.ts
1034
+ /**
1035
+ * Classifies module-local mutations and escapes for one returned SDK object.
1036
+ * @param analysis The indexed source containing the binding.
1037
+ * @param declaration The module-local constant declaration.
1038
+ * @param allowedReferences Bare identifier uses proven to be supported registrations or targets.
1039
+ * @returns Member-specific mutations and whether an unknown use can affect every relationship.
1040
+ */
1041
+ var analyzeClaudeAgentSdkMutations = (analysis, declaration, allowedReferences) => analyzeModuleValueMutations(analysis, declaration, allowedReferences);
1042
+ //#endregion
1043
+ //#region src/source-analysis/query-wrappers.ts
1044
+ var OPTION_RELATIONSHIP_NAMES = [
1045
+ "agent",
1046
+ "agents",
1047
+ "disallowedTools",
1048
+ "mcpServers",
1049
+ "outputFormat",
1050
+ "systemPrompt",
1051
+ "toolAliases",
1052
+ "tools"
1053
+ ];
1054
+ var createRelationships = (relationship) => new Map(OPTION_RELATIONSHIP_NAMES.map((name) => [name, relationship]));
1055
+ var getQueryContext = (call) => {
1056
+ if (call.arguments.length !== 1) return null;
1057
+ const input = unwrapExpression(call.arguments[0]);
1058
+ if (!ts.isObjectLiteralExpression(input)) return null;
1059
+ const optionsRelationship = analyzeObjectRelationships(input, ["options"]).relationships.get("options");
1060
+ let relationships;
1061
+ if (optionsRelationship?.kind === "absent") relationships = createRelationships({ kind: "absent" });
1062
+ else if (optionsRelationship?.kind !== "present") relationships = createRelationships({ kind: "unresolved" });
1063
+ else {
1064
+ const options = unwrapExpression(optionsRelationship.expression);
1065
+ relationships = ts.isObjectLiteralExpression(options) ? analyzeObjectRelationships(options, OPTION_RELATIONSHIP_NAMES).relationships : createRelationships({ kind: "unresolved" });
1066
+ }
1067
+ const relationship = (name) => relationships.get(name) ?? { kind: "unresolved" };
1068
+ return Object.freeze({
1069
+ agents: relationship("agents"),
1070
+ agentSelection: relationship("agent"),
1071
+ call,
1072
+ disallowedTools: relationship("disallowedTools"),
1073
+ mcpServers: relationship("mcpServers"),
1074
+ outputFormat: relationship("outputFormat"),
1075
+ systemPrompt: relationship("systemPrompt"),
1076
+ toolAliases: relationship("toolAliases"),
1077
+ tools: relationship("tools")
1078
+ });
1079
+ };
1080
+ var isNestedBoundary = (node) => ts.isFunctionLike(node) || ts.isClassLike(node) || ts.isClassStaticBlockDeclaration(node);
1081
+ /**
1082
+ * Classifies one directly exported query wrapper and its complete direct-call set.
1083
+ * @param analysis The indexed runtime source.
1084
+ * @param symbol The exact bound runtime-agent symbol.
1085
+ * @returns The absent, unsupported, or supported query-wrapper state.
1086
+ */
1087
+ var getClaudeAgentSdkQueryWrapper = (analysis, symbol) => {
1088
+ const runtimeExport = getRuntimeExport(analysis, symbol);
1089
+ if (runtimeExport.kind === "absent") return Object.freeze({ kind: "absent" });
1090
+ if (runtimeExport.kind !== "present-supported" || runtimeExport.body === void 0) return Object.freeze({
1091
+ declaration: runtimeExport.declaration,
1092
+ kind: "present-unsupported"
1093
+ });
1094
+ const contexts = [];
1095
+ let hasAmbiguousCandidate = false;
1096
+ const visit = (node, isNested) => {
1097
+ if (ts.isCallExpression(node)) {
1098
+ const callee = unwrapExpression(node.expression);
1099
+ if (ts.isIdentifier(callee) && analysis.imports.queryNames.has(callee.text) && isModuleBindingVisible(callee, analysis)) {
1100
+ if (isNested || node.questionDotToken !== void 0) hasAmbiguousCandidate = true;
1101
+ else {
1102
+ const context = getQueryContext(node);
1103
+ if (context === null) hasAmbiguousCandidate = true;
1104
+ else contexts.push(context);
1105
+ }
1106
+ }
1107
+ }
1108
+ const childIsNested = isNested || node !== runtimeExport.body && isNestedBoundary(node);
1109
+ node.forEachChild((child) => visit(child, childIsNested));
1110
+ };
1111
+ visit(runtimeExport.body, false);
1112
+ if (contexts.length === 0) return Object.freeze({
1113
+ declaration: runtimeExport.declaration,
1114
+ kind: "present-unsupported"
1115
+ });
1116
+ return Object.freeze({
1117
+ kind: "present-supported",
1118
+ wrapper: Object.freeze({
1119
+ contexts: Object.freeze(contexts),
1120
+ declaration: runtimeExport.declaration,
1121
+ hasAmbiguousCandidate
1122
+ })
1123
+ });
1124
+ };
1125
+ //#endregion
1126
+ //#region src/source-analysis/tool-availability.ts
1127
+ var hasUnsupportedGlobSyntax = (pattern) => /[?[\]{}\\]/u.test(pattern);
1128
+ var isScopedPermission = (value) => /^[^()]+\(.*\)$/u.test(value);
1129
+ /**
1130
+ * Matches a complete runtime tool name against the supported bare `*` glob model.
1131
+ * @param pattern The exact compiler-parsed deny pattern.
1132
+ * @param runtimeName The complete runtime-visible tool name.
1133
+ * @returns Whether the complete name matches.
1134
+ */
1135
+ var matchesClaudeAgentSdkBarePattern = (pattern, runtimeName) => {
1136
+ const patternScalars = Array.from(pattern);
1137
+ const nameScalars = Array.from(runtimeName);
1138
+ let patternIndex = 0;
1139
+ let nameIndex = 0;
1140
+ let wildcardIndex = -1;
1141
+ let wildcardNameIndex = -1;
1142
+ while (nameIndex < nameScalars.length) if (patternIndex < patternScalars.length && patternScalars[patternIndex] !== "*" && patternScalars[patternIndex] === nameScalars[nameIndex]) {
1143
+ patternIndex += 1;
1144
+ nameIndex += 1;
1145
+ } else if (patternScalars[patternIndex] === "*") {
1146
+ wildcardIndex = patternIndex;
1147
+ wildcardNameIndex = nameIndex;
1148
+ patternIndex += 1;
1149
+ } else if (wildcardIndex >= 0) {
1150
+ patternIndex = wildcardIndex + 1;
1151
+ wildcardNameIndex += 1;
1152
+ nameIndex = wildcardNameIndex;
1153
+ } else return false;
1154
+ while (patternScalars[patternIndex] === "*") patternIndex += 1;
1155
+ return patternIndex === patternScalars.length;
1156
+ };
1157
+ var resolveList = async (relationship, analysis, allowedReferences, resolveStaticString) => {
1158
+ const elements = getClaudeAgentSdkClosedArray(relationship, analysis, allowedReferences);
1159
+ if (elements === null) return null;
1160
+ const names = [];
1161
+ for (const element of elements) {
1162
+ const result = await resolveStaticString(analysis, element);
1163
+ if (result.kind !== "supported") return null;
1164
+ names.push(result.value);
1165
+ }
1166
+ return Object.freeze(names);
1167
+ };
1168
+ var applyDenyList = async (current, relationship, analysis, allowedReferences, runtimeName, resolveStaticString, legacyRuntimeName, serverSelector) => {
1169
+ if (relationship.kind === "absent") return current;
1170
+ const entries = await resolveList(relationship, analysis, allowedReferences, resolveStaticString);
1171
+ if (entries === null) return current === "unavailable" ? current : "unresolved";
1172
+ let hasUnresolvedEntry = false;
1173
+ for (const entry of entries) {
1174
+ if (serverSelector !== void 0 && entry === serverSelector) return "unavailable";
1175
+ if (!hasUnsupportedGlobSyntax(entry) && !isScopedPermission(entry)) {
1176
+ if (matchesClaudeAgentSdkBarePattern(entry, runtimeName)) return "unavailable";
1177
+ if (legacyRuntimeName !== void 0 && matchesClaudeAgentSdkBarePattern(entry, legacyRuntimeName)) hasUnresolvedEntry = true;
1178
+ continue;
1179
+ }
1180
+ if (entry.startsWith(runtimeName) || legacyRuntimeName !== void 0 && entry.startsWith(legacyRuntimeName) || entry.includes("*")) hasUnresolvedEntry = true;
1181
+ }
1182
+ return current === "unavailable" ? current : hasUnresolvedEntry ? "unresolved" : current;
1183
+ };
1184
+ /**
1185
+ * Derives query-configured availability of the built-in Agent delegation tool.
1186
+ * @param analysis The query source analysis.
1187
+ * @param tools The query-level tools relationship.
1188
+ * @param disallowedTools The query-level deny relationship.
1189
+ * @param agentSelection The unsupported main-thread selection relationship.
1190
+ * @param toolAliases The unsupported tool-alias relationship.
1191
+ * @param allowedReferences Supported references to shared list constants.
1192
+ * @param resolveStaticString The operation-local exact string resolver.
1193
+ * @returns The relationship-local availability state.
1194
+ */
1195
+ var classifyClaudeAgentSdkAgentAvailability = async (analysis, tools, disallowedTools, agentSelection, toolAliases, allowedReferences, resolveStaticString) => {
1196
+ let availability;
1197
+ if (tools.kind === "absent") availability = "available";
1198
+ else {
1199
+ const entries = await resolveList(tools, analysis, allowedReferences, resolveStaticString);
1200
+ if (entries === null) availability = "unresolved";
1201
+ else if (entries.includes("Agent")) availability = "available";
1202
+ else if (entries.some((entry) => entry === "Task" || entry.includes("*") || entry.startsWith("Agent(") || entry.startsWith("Task("))) availability = "unresolved";
1203
+ else availability = "unavailable";
1204
+ }
1205
+ availability = await applyDenyList(availability, disallowedTools, analysis, allowedReferences, "Agent", resolveStaticString, "Task");
1206
+ return availability === "available" && (agentSelection.kind !== "absent" || toolAliases.kind !== "absent") ? "unresolved" : availability;
1207
+ };
1208
+ /**
1209
+ * Derives query- or subagent-level availability of one exact SDK MCP tool.
1210
+ * @param analysis The source containing the availability relationships.
1211
+ * @param current The inherited availability state.
1212
+ * @param tools The optional explicit allow-list relationship.
1213
+ * @param disallowedTools The deny relationship.
1214
+ * @param agentSelection The unsupported main-thread selection relationship when query-level.
1215
+ * @param toolAliases The unsupported alias relationship when query-level.
1216
+ * @param allowedReferences Supported references to shared list constants.
1217
+ * @param runtimeName The exact fully qualified runtime tool name.
1218
+ * @param serverKey The canonical query-level server key.
1219
+ * @param resolveStaticString The operation-local exact string resolver.
1220
+ * @returns The refined availability state.
1221
+ */
1222
+ var classifyClaudeAgentSdkMcpToolAvailability = async (analysis, current, tools, disallowedTools, agentSelection, toolAliases, allowedReferences, runtimeName, serverKey, resolveStaticString) => {
1223
+ let availability = current;
1224
+ if (availability !== "unavailable" && tools !== null && tools.kind !== "absent") {
1225
+ const entries = await resolveList(tools, analysis, allowedReferences, resolveStaticString);
1226
+ if (entries === null || entries.some((entry) => entry.includes("*") || isScopedPermission(entry))) availability = "unresolved";
1227
+ else availability = entries.includes(runtimeName) ? availability : "unavailable";
1228
+ }
1229
+ availability = await applyDenyList(availability, disallowedTools, analysis, allowedReferences, runtimeName, resolveStaticString, void 0, `mcp__${serverKey}`);
1230
+ return availability === "available" && (agentSelection !== null && agentSelection.kind !== "absent" || toolAliases !== null && toolAliases.kind !== "absent") ? "unresolved" : availability;
1231
+ };
1232
+ /** Collects direct identifier relationships allowed to share immutable module collections. */
1233
+ var collectClaudeAgentSdkRelationshipIdentifiers = (relationships) => new Set(relationships.flatMap((relationship) => {
1234
+ if (relationship.kind !== "present") return [];
1235
+ const candidate = unwrapExpression(relationship.expression);
1236
+ return ts.isIdentifier(candidate) ? [candidate] : [];
1237
+ }));
1238
+ //#endregion
1239
+ //#region src/source-analysis/agent-definitions.ts
1240
+ var RELATIONSHIP_NAMES = [
1241
+ "description",
1242
+ "disallowedTools",
1243
+ "mcpServers",
1244
+ "prompt",
1245
+ "tools"
1246
+ ];
1247
+ var KNOWN_PROPERTIES = /* @__PURE__ */ new Set([
1248
+ ...RELATIONSHIP_NAMES,
1249
+ "background",
1250
+ "criticalSystemReminder_EXPERIMENTAL",
1251
+ "effort",
1252
+ "initialPrompt",
1253
+ "maxTurns",
1254
+ "memory",
1255
+ "model",
1256
+ "observer",
1257
+ "observerMessage",
1258
+ "permissionMode",
1259
+ "skills"
1260
+ ]);
1261
+ /**
1262
+ * Collects every supported direct agents-map use of definitions in one source module.
1263
+ * @param analysis The definition source analysis.
1264
+ * @returns Identifier occurrences that are registrations rather than mutable escapes.
1265
+ */
1266
+ var collectClaudeAgentSdkAgentDefinitionReferences = (analysis) => {
1267
+ const agentRelationships = [...analysis.exports.keys()].flatMap((symbol) => {
1268
+ const result = getClaudeAgentSdkQueryWrapper(analysis, symbol);
1269
+ return result.kind === "present-supported" ? result.wrapper.contexts.map(({ agents }) => agents) : [];
1270
+ });
1271
+ const collectionReferences = collectClaudeAgentSdkRelationshipIdentifiers(agentRelationships);
1272
+ return new Set(agentRelationships.flatMap((relationship) => (getClaudeAgentSdkClosedMapEntries(relationship, analysis, collectionReferences) ?? []).map(({ value }) => unwrapExpression(value)).filter((value) => ts.isIdentifier(value))));
1273
+ };
1274
+ var getDirectPropertyName = (property) => "name" in property && property.name !== void 0 && (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) ? property.name.text : null;
1275
+ var hasUnknownProperty$1 = (config) => config.properties.some((property) => {
1276
+ if (ts.isSpreadAssignment(property)) return false;
1277
+ const name = getDirectPropertyName(property);
1278
+ return name !== null && !KNOWN_PROPERTIES.has(name);
1279
+ });
1280
+ /**
1281
+ * Classifies one directly exported immutable AgentDefinition object.
1282
+ * @param analysis The indexed source module.
1283
+ * @param symbol The exact exported definition symbol.
1284
+ * @returns The absent, unsupported, or supported definition state.
1285
+ */
1286
+ var getClaudeAgentSdkAgentDefinition = (analysis, symbol) => {
1287
+ const exported = analysis.exports.get(symbol);
1288
+ if (exported === void 0) return Object.freeze({ kind: "absent" });
1289
+ if (exported.kind !== "present-supported" || !ts.isVariableDeclaration(exported.declaration) || exported.declaration.initializer === void 0) return Object.freeze({
1290
+ declaration: exported.declaration,
1291
+ kind: "present-unsupported"
1292
+ });
1293
+ const config = unwrapExpression(exported.declaration.initializer);
1294
+ if (!ts.isObjectLiteralExpression(config) || hasUnknownProperty$1(config)) return Object.freeze({
1295
+ declaration: exported.declaration,
1296
+ kind: "present-unsupported"
1297
+ });
1298
+ const observation = analyzeObjectRelationships(config, RELATIONSHIP_NAMES);
1299
+ const relationship = (name) => observation.relationships.get(name) ?? { kind: "unresolved" };
1300
+ const definition = Object.freeze({
1301
+ config,
1302
+ declaration: exported.declaration,
1303
+ description: relationship("description"),
1304
+ disallowedTools: relationship("disallowedTools"),
1305
+ mcpServers: relationship("mcpServers"),
1306
+ prompt: relationship("prompt"),
1307
+ tools: relationship("tools")
1308
+ });
1309
+ return Object.freeze({
1310
+ definition,
1311
+ kind: "present-supported"
1312
+ });
1313
+ };
1314
+ /**
1315
+ * Applies relationship-specific post-declaration mutation uncertainty.
1316
+ * @param analysis The definition source analysis.
1317
+ * @param definition The supported initial definition.
1318
+ * @param allowedReferences Direct uses in supported agents maps.
1319
+ * @returns The definition with only affected relationships unresolved.
1320
+ */
1321
+ var applyClaudeAgentSdkAgentMutations = (analysis, definition, allowedReferences) => {
1322
+ const mutations = analyzeClaudeAgentSdkMutations(analysis, definition.declaration, allowedReferences);
1323
+ if (!mutations.hasUnknownMutation && mutations.mutatedMembers.size === 0) return definition;
1324
+ const relationship = (name) => mutations.hasUnknownMutation || mutations.mutatedMembers.has(name) ? { kind: "unresolved" } : definition[name];
1325
+ return Object.freeze({
1326
+ ...definition,
1327
+ description: relationship("description"),
1328
+ disallowedTools: relationship("disallowedTools"),
1329
+ mcpServers: relationship("mcpServers"),
1330
+ prompt: relationship("prompt"),
1331
+ tools: relationship("tools")
1332
+ });
1333
+ };
1334
+ //#endregion
1335
+ //#region src/source-analysis/bindings.ts
1336
+ /**
1337
+ * Classifies a direct relationship to one explicitly bound runtime symbol.
1338
+ * @param relationship The supported configuration relationship.
1339
+ * @param analysis The source containing the relationship.
1340
+ * @param reference The exact manifest binding.
1341
+ * @returns `true` for a match, `false` for proved absence, or `null` when unresolved.
1342
+ */
1343
+ var classifyClaudeAgentSdkDirectBinding = (relationship, analysis, reference) => {
1344
+ if (relationship.kind === "absent") return false;
1345
+ if (relationship.kind === "unresolved" || reference.symbol === void 0) return null;
1346
+ const candidate = unwrapExpression(relationship.expression);
1347
+ if (!ts.isIdentifier(candidate) || !isModuleBindingVisible(candidate, analysis)) return ts.isStringLiteral(candidate) || ts.isNoSubstitutionTemplateLiteral(candidate) || ts.isNumericLiteral(candidate) || ts.isObjectLiteralExpression(candidate) || ts.isArrayLiteralExpression(candidate) || ts.isArrowFunction(candidate) || ts.isFunctionExpression(candidate) || ts.isClassExpression(candidate) || candidate.kind === ts.SyntaxKind.NullKeyword || candidate.kind === ts.SyntaxKind.TrueKeyword || candidate.kind === ts.SyntaxKind.FalseKeyword ? false : null;
1348
+ if (isBoundIdentifier(candidate, analysis, reference)) return true;
1349
+ return resolveBindingReferences(candidate, analysis).length > 0 ? false : null;
1350
+ };
1351
+ //#endregion
1352
+ //#region src/source-analysis/instruction-loaders.ts
1353
+ var classifyCall = (expression, analysis, reference) => {
1354
+ const call = getDirectCall(expression);
1355
+ if (call === null) return null;
1356
+ const callee = unwrapExpression(call.expression);
1357
+ if (!ts.isIdentifier(callee) || !isModuleBindingVisible(callee, analysis)) return null;
1358
+ if (isBoundIdentifier(callee, analysis, reference)) return true;
1359
+ return resolveBindingReferences(callee, analysis).length > 0 ? false : null;
1360
+ };
1361
+ var classifyPreset = (expression, analysis, reference) => {
1362
+ const candidate = unwrapExpression(expression);
1363
+ if (!ts.isObjectLiteralExpression(candidate)) return null;
1364
+ const properties = getClosedObjectProperties(candidate);
1365
+ if (properties === null || [...properties.keys()].some((name) => ![
1366
+ "append",
1367
+ "excludeDynamicSections",
1368
+ "preset",
1369
+ "type"
1370
+ ].includes(name)) || getStaticString(properties.get("type") ?? candidate) !== "preset" || getStaticString(properties.get("preset") ?? candidate) !== "claude_code") return null;
1371
+ const append = properties.get("append");
1372
+ return append === void 0 ? false : classifyCall(append, analysis, reference);
1373
+ };
1374
+ /**
1375
+ * Classifies a direct loader call used by a canonical Claude prompt relationship.
1376
+ * @param relationship The systemPrompt or AgentDefinition.prompt relationship.
1377
+ * @param analysis The source containing the relationship.
1378
+ * @param reference The exact declared instruction-loader binding.
1379
+ * @param supportsPreset Whether the query-level claude_code preset is allowed.
1380
+ * @returns `true` for wired, `false` for provably unwired, or `null` when unresolved.
1381
+ */
1382
+ var classifyClaudeAgentSdkInstructionLoader = (relationship, analysis, reference, supportsPreset) => {
1383
+ if (relationship.kind === "absent") return false;
1384
+ if (relationship.kind === "unresolved" || reference.symbol === void 0) return null;
1385
+ const candidate = unwrapExpression(relationship.expression);
1386
+ if (ts.isArrayLiteralExpression(candidate)) return null;
1387
+ const directCall = classifyCall(candidate, analysis, reference);
1388
+ if (directCall !== null) return directCall;
1389
+ if (supportsPreset) {
1390
+ const preset = classifyPreset(candidate, analysis, reference);
1391
+ if (preset !== null) return preset;
1392
+ }
1393
+ return ts.isStringLiteral(candidate) || ts.isNoSubstitutionTemplateLiteral(candidate) || ts.isNumericLiteral(candidate) || candidate.kind === ts.SyntaxKind.NullKeyword || candidate.kind === ts.SyntaxKind.TrueKeyword || candidate.kind === ts.SyntaxKind.FalseKeyword ? false : null;
1394
+ };
1395
+ //#endregion
1396
+ //#region src/source-analysis/mcp-servers.ts
1397
+ var SUPPORTED_PROPERTIES = /* @__PURE__ */ new Set([
1398
+ "alwaysLoad",
1399
+ "instructions",
1400
+ "name",
1401
+ "tools",
1402
+ "version"
1403
+ ]);
1404
+ var hasUnknownProperty = (config) => {
1405
+ const properties = getClosedObjectProperties(config);
1406
+ return properties === null || [...properties.keys()].some((name) => !SUPPORTED_PROPERTIES.has(name));
1407
+ };
1408
+ /**
1409
+ * Classifies one module-local createSdkMcpServer(...) declaration.
1410
+ * @param analysis The indexed server source.
1411
+ * @param symbol The exact module-local binding name.
1412
+ * @returns The supported server definition or `null`.
1413
+ */
1414
+ var getClaudeAgentSdkMcpServerDefinition = (analysis, symbol) => {
1415
+ const declaration = analysis.moduleConstDeclarations.get(symbol);
1416
+ if (declaration?.initializer === void 0) return null;
1417
+ const initializer = unwrapExpression(declaration.initializer);
1418
+ if (!ts.isCallExpression(initializer) || initializer.arguments.length !== 1) return null;
1419
+ const helper = unwrapExpression(initializer.expression);
1420
+ if (!ts.isIdentifier(helper) || !analysis.imports.createSdkMcpServerNames.has(helper.text) || !isModuleBindingVisible(helper, analysis)) return null;
1421
+ const config = unwrapExpression(initializer.arguments[0]);
1422
+ if (!ts.isObjectLiteralExpression(config) || hasUnknownProperty(config)) return null;
1423
+ const observation = analyzeObjectRelationships(config, [
1424
+ "name",
1425
+ "tools",
1426
+ "version"
1427
+ ]);
1428
+ const name = observation.relationships.get("name");
1429
+ const tools = observation.relationships.get("tools") ?? { kind: "unresolved" };
1430
+ const version = observation.relationships.get("version") ?? { kind: "unresolved" };
1431
+ if (name?.kind !== "present" || tools.kind === "absent") return null;
1432
+ return Object.freeze({
1433
+ config,
1434
+ declaration,
1435
+ name: name.expression,
1436
+ tools,
1437
+ version
1438
+ });
1439
+ };
1440
+ /**
1441
+ * Collects direct tool identifiers used by supported module-local SDK MCP servers.
1442
+ * @param analysis The source containing tool and server declarations.
1443
+ * @returns Identifier occurrences that are registrations rather than value escapes.
1444
+ */
1445
+ var collectClaudeAgentSdkMcpToolReferences = (analysis) => {
1446
+ const definitions = [...analysis.moduleConstDeclarations.keys()].flatMap((symbol) => {
1447
+ const definition = getClaudeAgentSdkMcpServerDefinition(analysis, symbol);
1448
+ return definition === null ? [] : [definition];
1449
+ });
1450
+ const collectionReferences = new Set(definitions.flatMap(({ tools }) => {
1451
+ if (tools.kind !== "present") return [];
1452
+ const candidate = unwrapExpression(tools.expression);
1453
+ return ts.isIdentifier(candidate) ? [candidate] : [];
1454
+ }));
1455
+ return new Set(definitions.flatMap(({ tools }) => (getClaudeAgentSdkClosedArray(tools, analysis, collectionReferences) ?? []).filter((element) => ts.isIdentifier(element))));
1456
+ };
1457
+ //#endregion
1458
+ //#region src/source-analysis/sdk-tools.ts
1459
+ /**
1460
+ * Classifies one directly exported root tool(...) declaration.
1461
+ * @param analysis The indexed tool source.
1462
+ * @param symbol The exact exported tool registration symbol.
1463
+ * @returns The absent, unsupported, or structurally supported tool state.
1464
+ */
1465
+ var getClaudeAgentSdkToolDefinition = (analysis, symbol) => {
1466
+ const exported = analysis.exports.get(symbol);
1467
+ if (exported === void 0) return Object.freeze({ kind: "absent" });
1468
+ if (exported.kind !== "present-supported" || !ts.isVariableDeclaration(exported.declaration) || exported.declaration.initializer === void 0) return Object.freeze({
1469
+ declaration: exported.declaration,
1470
+ kind: "present-unsupported"
1471
+ });
1472
+ const initializer = unwrapExpression(exported.declaration.initializer);
1473
+ if (!ts.isCallExpression(initializer) || initializer.arguments.length !== 4 && initializer.arguments.length !== 5) return Object.freeze({
1474
+ declaration: exported.declaration,
1475
+ kind: "present-unsupported"
1476
+ });
1477
+ const helper = unwrapExpression(initializer.expression);
1478
+ if (!ts.isIdentifier(helper) || !analysis.imports.toolNames.has(helper.text) || !isModuleBindingVisible(helper, analysis)) return Object.freeze({
1479
+ declaration: exported.declaration,
1480
+ kind: "present-unsupported"
1481
+ });
1482
+ const tool = Object.freeze({
1483
+ call: initializer,
1484
+ declaration: exported.declaration,
1485
+ implementation: unwrapExpression(initializer.arguments[3]),
1486
+ inputSchema: unwrapExpression(initializer.arguments[2]),
1487
+ name: unwrapExpression(initializer.arguments[0])
1488
+ });
1489
+ return Object.freeze({
1490
+ kind: "present-supported",
1491
+ tool
1492
+ });
1493
+ };
1494
+ //#endregion
1495
+ //#region src/source-analysis/source-analysis.ts
1496
+ var CLAUDE_AGENT_SDK_IMPORT_CONFIG = Object.freeze({
1497
+ namedConstructorImports: [],
1498
+ packageName: CLAUDE_AGENT_SDK_PACKAGE_NAME,
1499
+ supportsDefaultConstructorImport: false
1500
+ });
1501
+ var indexClaudeAgentSdkImports = (sourceFile) => {
1502
+ const createSdkMcpServerNames = /* @__PURE__ */ new Set();
1503
+ const queryNames = /* @__PURE__ */ new Set();
1504
+ const toolNames = /* @__PURE__ */ new Set();
1505
+ for (const statement of sourceFile.statements) {
1506
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "@anthropic-ai/claude-agent-sdk" || statement.importClause?.isTypeOnly === true || statement.importClause?.namedBindings === void 0 || !ts.isNamedImports(statement.importClause.namedBindings)) continue;
1507
+ for (const element of statement.importClause.namedBindings.elements) {
1508
+ if (element.isTypeOnly) continue;
1509
+ const importedName = element.propertyName?.text ?? element.name.text;
1510
+ if (importedName === "createSdkMcpServer") createSdkMcpServerNames.add(element.name.text);
1511
+ else if (importedName === "query") queryNames.add(element.name.text);
1512
+ else if (importedName === "tool") toolNames.add(element.name.text);
1513
+ }
1514
+ }
1515
+ return Object.freeze({
1516
+ createSdkMcpServerNames,
1517
+ queryNames,
1518
+ toolNames
1519
+ });
1520
+ };
1521
+ /**
1522
+ * Parses and indexes one Claude Agent SDK TypeScript module without executing it.
1523
+ * @param path The normalized repository source path.
1524
+ * @param bytes The exact repository bytes.
1525
+ * @param signal The active inspection signal.
1526
+ * @returns The source analysis or a stable invalid source result.
1527
+ */
1528
+ var analyzeClaudeAgentSdkSource = (path, bytes, signal) => {
1529
+ const result = analyzeTypeScriptModule(path, bytes, CLAUDE_AGENT_SDK_IMPORT_CONFIG, signal);
1530
+ if (result.kind !== "valid") return result;
1531
+ const analysis = Object.freeze({
1532
+ ...result.analysis,
1533
+ imports: indexClaudeAgentSdkImports(result.analysis.sourceFile),
1534
+ path
1535
+ });
1536
+ return Object.freeze({
1537
+ analysis,
1538
+ kind: "valid"
1539
+ });
1540
+ };
1541
+ //#endregion
1542
+ //#region src/source-analysis/static-strings.ts
1543
+ /**
1544
+ * Resolves one exact supported static string without normalization or execution.
1545
+ * @param session The operation-local source session.
1546
+ * @param analysis The source containing the expression.
1547
+ * @param expression The candidate static string expression.
1548
+ * @returns The exact compiler-parsed string or an unsupported state.
1549
+ */
1550
+ var resolveClaudeAgentSdkStaticString = (session, analysis, expression) => resolveStaticString({
1551
+ analysis,
1552
+ analyzeSource: (path) => session.analyzeSource(path),
1553
+ expression,
1554
+ getEntry: (path) => session.getEntry(path),
1555
+ parsePath: parseRepositoryPath,
1556
+ ...session.signal === void 0 ? {} : { signal: session.signal }
1557
+ });
1558
+ //#endregion
1559
+ //#region src/diagnostics/index.ts
1560
+ var CLAUDE_AGENT_SDK_ADAPTER_DIAGNOSTICS = Object.freeze({
1561
+ CLAUDE_AGENT_SDK_AGENT_OUTPUT_SCHEMA_NOT_WIRED: "The declared agent output schema is not wired to the detected Claude Agent SDK query output format.",
1562
+ CLAUDE_AGENT_SDK_AGENT_OUTPUT_SCHEMA_SYMBOL_NOT_FOUND: "The declared agent output-schema symbol was not found.",
1563
+ CLAUDE_AGENT_SDK_HANDOFF_ROUTING_DESCRIPTION_MISSING: "The detected Claude Agent SDK subagent registration has no supported routing description.",
1564
+ CLAUDE_AGENT_SDK_HANDOFF_ROUTING_DESCRIPTION_NOT_WIRED: "The detected Claude Agent SDK subagent routing description does not use the target agent's effective routing description.",
1565
+ CLAUDE_AGENT_SDK_HANDOFF_TARGET_AMBIGUOUS: "The detected Claude Agent SDK subagent target matches more than one registered moldea agent.",
1566
+ CLAUDE_AGENT_SDK_INSTRUCTION_LOADER_NOT_WIRED: "The declared instruction loader is not wired to the detected Claude Agent SDK agent.",
1567
+ CLAUDE_AGENT_SDK_INSTRUCTION_LOADER_SYMBOL_NOT_FOUND: "The declared instruction-loader symbol was not found.",
1568
+ CLAUDE_AGENT_SDK_PACKAGE_MANIFEST_INVALID: "The owning package manifest is invalid for Claude Agent SDK dependency detection.",
1569
+ CLAUDE_AGENT_SDK_RUNTIME_AGENT_SYMBOL_NOT_FOUND: "The declared runtime-agent symbol was not found.",
1570
+ CLAUDE_AGENT_SDK_SOURCE_SYNTAX_INVALID: "The referenced Claude Agent SDK source file contains invalid TypeScript syntax.",
1571
+ CLAUDE_AGENT_SDK_SOURCE_TEXT_INVALID: "The referenced Claude Agent SDK source file is not valid normalized text.",
1572
+ CLAUDE_AGENT_SDK_TOOL_IMPLEMENTATION_NOT_WIRED: "The declared tool implementation is not wired to the detected Claude Agent SDK custom tool.",
1573
+ CLAUDE_AGENT_SDK_TOOL_IMPLEMENTATION_SYMBOL_NOT_FOUND: "The declared tool-implementation symbol was not found.",
1574
+ CLAUDE_AGENT_SDK_TOOL_INPUT_SCHEMA_NOT_WIRED: "The declared tool input schema is not wired to the detected Claude Agent SDK custom tool.",
1575
+ CLAUDE_AGENT_SDK_TOOL_INPUT_SCHEMA_SYMBOL_NOT_FOUND: "The declared tool input-schema symbol was not found.",
1576
+ CLAUDE_AGENT_SDK_TOOL_NAME_MISMATCH: "The declared tool name does not match the detected Claude Agent SDK MCP tool name.",
1577
+ CLAUDE_AGENT_SDK_MCP_SERVER_KEY_UNSUPPORTED: "The detected Claude Agent SDK MCP server key cannot establish a canonical runtime-name segment.",
1578
+ CLAUDE_AGENT_SDK_TOOL_REGISTRATION_NOT_WIRED: "The declared tool registration is not available to the detected Claude Agent SDK agent.",
1579
+ CLAUDE_AGENT_SDK_TOOL_REGISTRATION_SYMBOL_NOT_FOUND: "The declared tool-registration symbol was not found.",
1580
+ CLAUDE_AGENT_SDK_VERSION_UNSUPPORTED: "The observed Claude Agent SDK dependency range is disjoint from the supported range."
1581
+ });
1582
+ /**
1583
+ * Creates one frozen, safely namespaced Claude Agent SDK adapter diagnostic.
1584
+ * @param input The complete code, location, entity, and safe scalar details.
1585
+ * @returns The immutable adapter diagnostic.
1586
+ */
1587
+ var createClaudeAgentSdkDiagnostic = (input) => Object.freeze({
1588
+ ...input,
1589
+ details: Object.freeze({ ...input.details }),
1590
+ entity: input.entity === null ? null : Object.freeze({ ...input.entity }),
1591
+ message: CLAUDE_AGENT_SDK_ADAPTER_DIAGNOSTICS[input.code],
1592
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
1593
+ });
1594
+ //#endregion
1595
+ //#region src/inspection/common.ts
1596
+ var LINE_BREAK_CODE_POINTS = /* @__PURE__ */ new Set([
1597
+ 10,
1598
+ 13,
1599
+ 133,
1600
+ 8232,
1601
+ 8233
1602
+ ]);
1603
+ var isUnicodeWhiteSpace = (codePoint) => 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;
1604
+ /** Compares exact strings without locale-dependent behavior. */
1605
+ var compareClaudeAgentSdkStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
1606
+ /** Determines whether a runtime-visible value satisfies Core's machine-string contract. */
1607
+ var isClaudeAgentSdkMachineString = (value) => {
1608
+ const codePoints = [...value].map((character) => character.codePointAt(0));
1609
+ return codePoints.length > 0 && codePoints.every((codePoint) => codePoint < 55296 || codePoint > 57343) && !codePoints.includes(0) && !codePoints.some((codePoint) => LINE_BREAK_CODE_POINTS.has(codePoint)) && !isUnicodeWhiteSpace(codePoints[0]) && !isUnicodeWhiteSpace(codePoints.at(-1));
1610
+ };
1611
+ var freezeReference = (reference) => Object.freeze({
1612
+ path: reference.path,
1613
+ ...reference.symbol === void 0 ? {} : { symbol: reference.symbol }
1614
+ });
1615
+ /** Creates one deeply immutable Claude Agent SDK evidence record. */
1616
+ var createClaudeAgentSdkEvidence = (evidence) => Object.freeze({
1617
+ ...evidence,
1618
+ details: Object.freeze({ ...evidence.details }),
1619
+ references: Object.freeze(evidence.references.map(freezeReference))
1620
+ });
1621
+ var createEntity = (agentId, capabilityId) => Object.freeze({
1622
+ adapterId: CLAUDE_AGENT_SDK_ADAPTER_ID,
1623
+ agentId,
1624
+ ...capabilityId === void 0 ? {} : {
1625
+ capabilityId,
1626
+ capabilityKind: "tool"
1627
+ }
1628
+ });
1629
+ /**
1630
+ * Appends one stable package-owned diagnostic.
1631
+ * @param diagnostics The operation result collection.
1632
+ * @param code The stable diagnostic code.
1633
+ * @param path The exact affected path.
1634
+ * @param agentId The owning source-agent identifier.
1635
+ * @param range The optional scalar source range.
1636
+ * @param capabilityId The optional owning tool capability.
1637
+ * @param details Safe scalar diagnostic details.
1638
+ */
1639
+ var addClaudeAgentSdkDiagnostic = (diagnostics, code, path, agentId, range = null, capabilityId, details = {}) => {
1640
+ diagnostics.push(createClaudeAgentSdkDiagnostic({
1641
+ code,
1642
+ details,
1643
+ entity: createEntity(agentId, capabilityId),
1644
+ path,
1645
+ pointer: null,
1646
+ range
1647
+ }));
1648
+ };
1649
+ /** Returns the Core scalar range for one node in its analyzed source. */
1650
+ var locateClaudeAgentSdkNode = (analysis, node) => analysis.text.locator.locateRange(node.getStart(analysis.sourceFile), node.getEnd());
1651
+ /**
1652
+ * Loads and validates one supported bound TypeScript source.
1653
+ * @param session The operation-local inspection session.
1654
+ * @param reference The exact manifest reference.
1655
+ * @param diagnostics The operation result collection.
1656
+ * @param agentId The owning agent identifier.
1657
+ * @param capabilityId The optional owning tool capability.
1658
+ * @returns The indexed source or `null` after unsupported or invalid input.
1659
+ */
1660
+ var analyzeClaudeAgentSdkBoundReference = async (session, reference, diagnostics, agentId, capabilityId) => {
1661
+ if (!isSupportedTypeScriptSourcePath(reference.path)) return null;
1662
+ const result = await session.analyzeSource(reference.path);
1663
+ if (result.kind === "invalid-text") {
1664
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_SOURCE_TEXT_INVALID", reference.path, agentId, null, capabilityId);
1665
+ return null;
1666
+ }
1667
+ if (result.kind === "invalid-syntax") {
1668
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_SOURCE_SYNTAX_INVALID", reference.path, agentId, result.range, capabilityId);
1669
+ return null;
1670
+ }
1671
+ return result.analysis;
1672
+ };
1673
+ //#endregion
1674
+ //#region src/inspection/resolution.ts
1675
+ var getReferenceCandidates = (analysis, expression, includeLocalConst) => {
1676
+ const candidate = unwrapExpression(expression);
1677
+ if (!ts.isIdentifier(candidate) || !isModuleBindingVisible(candidate, analysis)) return [];
1678
+ const references = [...resolveBindingReferences(candidate, analysis)];
1679
+ if (includeLocalConst && analysis.moduleConstDeclarations.has(candidate.text) && !references.some((reference) => reference.path === analysis.path && reference.symbol === candidate.text)) references.unshift(Object.freeze({
1680
+ path: analysis.path,
1681
+ symbol: candidate.text
1682
+ }));
1683
+ return references;
1684
+ };
1685
+ var loadCandidateSource = async (session, path) => {
1686
+ const parsedPath = parseRepositoryPath(path);
1687
+ if ((await session.getEntry(parsedPath))?.type !== "file") return null;
1688
+ const source = await session.analyzeSource(parsedPath);
1689
+ return source.kind === "valid" ? Object.freeze({
1690
+ analysis: source.analysis,
1691
+ path: parsedPath
1692
+ }) : null;
1693
+ };
1694
+ /** Resolves one exact supported programmatic definition through local or relative binding identity. */
1695
+ var resolveClaudeAgentSdkAgentDefinition = async (session, analysis, expression) => {
1696
+ const resolved = [];
1697
+ for (const reference of getReferenceCandidates(analysis, expression, false)) {
1698
+ const source = await loadCandidateSource(session, reference.path);
1699
+ if (source === null) continue;
1700
+ const result = getClaudeAgentSdkAgentDefinition(source.analysis, reference.symbol);
1701
+ if (result.kind === "present-supported") resolved.push(Object.freeze({
1702
+ analysis: source.analysis,
1703
+ definition: result.definition,
1704
+ path: source.path,
1705
+ symbol: reference.symbol
1706
+ }));
1707
+ }
1708
+ return resolved.length === 1 ? resolved[0] : null;
1709
+ };
1710
+ /** Resolves one exact supported SDK MCP server through local or relative binding identity. */
1711
+ var resolveClaudeAgentSdkMcpServer = async (session, analysis, expression) => {
1712
+ const resolved = [];
1713
+ for (const reference of getReferenceCandidates(analysis, expression, true)) {
1714
+ const source = await loadCandidateSource(session, reference.path);
1715
+ if (source === null) continue;
1716
+ const definition = getClaudeAgentSdkMcpServerDefinition(source.analysis, reference.symbol);
1717
+ if (definition !== null) resolved.push(Object.freeze({
1718
+ analysis: source.analysis,
1719
+ definition,
1720
+ path: source.path,
1721
+ symbol: reference.symbol
1722
+ }));
1723
+ }
1724
+ return resolved.length === 1 ? resolved[0] : null;
1725
+ };
1726
+ /** Resolves one exact supported exported SDK tool through local or relative binding identity. */
1727
+ var resolveClaudeAgentSdkTool = async (session, analysis, expression) => {
1728
+ const resolved = [];
1729
+ for (const reference of getReferenceCandidates(analysis, expression, false)) {
1730
+ const source = await loadCandidateSource(session, reference.path);
1731
+ if (source === null) continue;
1732
+ const result = getClaudeAgentSdkToolDefinition(source.analysis, reference.symbol);
1733
+ if (result.kind === "present-supported") resolved.push(Object.freeze({
1734
+ analysis: source.analysis,
1735
+ definition: result.tool,
1736
+ path: source.path,
1737
+ symbol: reference.symbol
1738
+ }));
1739
+ }
1740
+ return resolved.length === 1 ? resolved[0] : null;
1741
+ };
1742
+ //#endregion
1743
+ //#region src/inspection/handoffs.ts
1744
+ var resolveMapEntryName = async (session, inspected, entry) => {
1745
+ if (entry.name !== null) return entry.name;
1746
+ const keyExpression = entry.keyExpression;
1747
+ if (!ts.isExpression(keyExpression)) return null;
1748
+ const result = await resolveClaudeAgentSdkStaticString(session, inspected.analysis, keyExpression);
1749
+ return result.kind === "supported" ? result.value : null;
1750
+ };
1751
+ var getMappedAgents = (context, target) => context.project.agents.filter(({ declaration }) => {
1752
+ const runtimeAgent = declaration.bindings?.runtimeAgent;
1753
+ return runtimeAgent?.path === target.path && runtimeAgent.symbol === target.symbol;
1754
+ });
1755
+ var inspectRoutingDescription = async (session, sourceAgentId, target, targetAgent, runtimeName, diagnostics) => {
1756
+ const canonicalDescription = targetAgent.handoffDescription?.value ?? targetAgent.description.value;
1757
+ const relationship = target.definition.description;
1758
+ const safeDetails = {
1759
+ targetAgentId: targetAgent.id,
1760
+ ...isClaudeAgentSdkMachineString(runtimeName) ? { targetRuntimeName: runtimeName } : {}
1761
+ };
1762
+ if (relationship.kind === "unresolved") return;
1763
+ if (relationship.kind === "absent") {
1764
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_HANDOFF_ROUTING_DESCRIPTION_MISSING", target.path, sourceAgentId, locateClaudeAgentSdkNode(target.analysis, target.definition.declaration), void 0, safeDetails);
1765
+ return;
1766
+ }
1767
+ const result = await resolveClaudeAgentSdkStaticString(session, target.analysis, relationship.expression);
1768
+ if (result.kind !== "supported") return;
1769
+ const code = result.value.length === 0 ? "CLAUDE_AGENT_SDK_HANDOFF_ROUTING_DESCRIPTION_MISSING" : result.value !== canonicalDescription ? "CLAUDE_AGENT_SDK_HANDOFF_ROUTING_DESCRIPTION_NOT_WIRED" : null;
1770
+ if (code !== null) addClaudeAgentSdkDiagnostic(diagnostics, code, target.path, sourceAgentId, locateClaudeAgentSdkNode(target.analysis, relationship.expression), void 0, safeDetails);
1771
+ };
1772
+ /** Inspects active query-configured programmatic subagent registrations and routing metadata. */
1773
+ var inspectClaudeAgentSdkHandoffs = async (context, session, inspected, evidence, diagnostics) => {
1774
+ const collectionReferences = collectClaudeAgentSdkRelationshipIdentifiers(inspected.wrapper.contexts.flatMap((queryContext) => [
1775
+ queryContext.tools,
1776
+ queryContext.disallowedTools,
1777
+ queryContext.agents
1778
+ ]));
1779
+ for (const queryContext of inspected.wrapper.contexts) {
1780
+ session.signal?.throwIfAborted();
1781
+ if (await classifyClaudeAgentSdkAgentAvailability(inspected.analysis, queryContext.tools, queryContext.disallowedTools, queryContext.agentSelection, queryContext.toolAliases, collectionReferences, (analysis, expression) => resolveClaudeAgentSdkStaticString(session, analysis, expression)) !== "available") continue;
1782
+ const entries = getClaudeAgentSdkClosedMapEntries(queryContext.agents, inspected.analysis, collectionReferences);
1783
+ if (entries === null) continue;
1784
+ const resolvedNames = await Promise.all(entries.map((entry) => resolveMapEntryName(session, inspected, entry)));
1785
+ const supportedNames = resolvedNames.filter((name) => name !== null);
1786
+ if (supportedNames.length !== entries.length || new Set(supportedNames).size !== supportedNames.length) continue;
1787
+ for (const [entryIndex, entry] of entries.entries()) {
1788
+ session.signal?.throwIfAborted();
1789
+ const runtimeName = resolvedNames[entryIndex];
1790
+ if (runtimeName === void 0 || runtimeName === null) continue;
1791
+ const unresolvedTarget = await resolveClaudeAgentSdkAgentDefinition(session, inspected.analysis, entry.value);
1792
+ if (unresolvedTarget === null) continue;
1793
+ const target = Object.freeze({
1794
+ ...unresolvedTarget,
1795
+ definition: applyClaudeAgentSdkAgentMutations(unresolvedTarget.analysis, unresolvedTarget.definition, collectClaudeAgentSdkAgentDefinitionReferences(unresolvedTarget.analysis))
1796
+ });
1797
+ const mappedAgents = getMappedAgents(context, target);
1798
+ const mappedAgent = mappedAgents.length === 1 ? mappedAgents[0] : void 0;
1799
+ const safeRuntimeName = isClaudeAgentSdkMachineString(runtimeName) ? runtimeName : null;
1800
+ const details = {
1801
+ delegationAvailabilitySource: queryContext.tools.kind === "absent" ? "default-built-in-tools" : "explicit-built-in-tools",
1802
+ delegationTool: "Agent",
1803
+ registrationKind: "programmatic-subagent",
1804
+ registrationScope: "query-session",
1805
+ ...mappedAgent === void 0 ? {} : { targetAgentId: mappedAgent.id },
1806
+ ...safeRuntimeName === null ? {} : { targetRuntimeName: safeRuntimeName }
1807
+ };
1808
+ if (mappedAgents.length > 1) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_HANDOFF_TARGET_AMBIGUOUS", inspected.analysis.path, inspected.agent.id, locateClaudeAgentSdkNode(inspected.analysis, entry.value), void 0, safeRuntimeName === null ? {} : { targetRuntimeName: safeRuntimeName });
1809
+ else if (mappedAgent !== void 0) await inspectRoutingDescription(session, inspected.agent.id, target, mappedAgent, runtimeName, diagnostics);
1810
+ evidence.push(createClaudeAgentSdkEvidence({
1811
+ agentId: inspected.agent.id,
1812
+ capabilityId: null,
1813
+ capabilityKind: null,
1814
+ details,
1815
+ kind: "handoff-registration",
1816
+ references: [{ path: inspected.analysis.path }, {
1817
+ path: target.path,
1818
+ symbol: target.symbol
1819
+ }],
1820
+ runtimeName: safeRuntimeName,
1821
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
1822
+ }));
1823
+ }
1824
+ }
1825
+ };
1826
+ //#endregion
1827
+ //#region src/inspection/package-inspection.ts
1828
+ /** Inspects the nearest owning package manifest for one runtime source. */
1829
+ var inspectClaudeAgentSdkPackage = async (session, sourcePath, evidence, diagnostics, agentId) => {
1830
+ const discovery = await session.discoverPackage(sourcePath);
1831
+ if (discovery.kind === "absent") return;
1832
+ if (discovery.kind === "invalid") {
1833
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_PACKAGE_MANIFEST_INVALID", discovery.path, agentId);
1834
+ return;
1835
+ }
1836
+ const { observation } = discovery;
1837
+ if (observation.compatibility === "unsupported") {
1838
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_VERSION_UNSUPPORTED", observation.path, agentId);
1839
+ return;
1840
+ }
1841
+ for (const declaration of observation.declarations) evidence.push(createClaudeAgentSdkEvidence({
1842
+ agentId,
1843
+ capabilityId: null,
1844
+ capabilityKind: null,
1845
+ details: {
1846
+ compatibility: observation.compatibility,
1847
+ declaredRange: declaration.declaredRange,
1848
+ dependencyKind: declaration.dependencyKind
1849
+ },
1850
+ kind: "runtime-package",
1851
+ references: [{ path: observation.path }],
1852
+ runtimeName: CLAUDE_AGENT_SDK_PACKAGE_NAME,
1853
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
1854
+ }));
1855
+ };
1856
+ //#endregion
1857
+ //#region src/inspection/relationships.ts
1858
+ var inspectCallableSymbol$1 = async (session, reference, agentId, diagnostics) => {
1859
+ if (reference.symbol === void 0) return null;
1860
+ const analysis = await analyzeClaudeAgentSdkBoundReference(session, reference, diagnostics, agentId);
1861
+ if (analysis === null) return null;
1862
+ const state = getCallableExportState(analysis, reference.symbol);
1863
+ if (state.kind === "absent") {
1864
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_INSTRUCTION_LOADER_SYMBOL_NOT_FOUND", reference.path, agentId);
1865
+ return false;
1866
+ }
1867
+ return state.kind === "present-supported" ? true : null;
1868
+ };
1869
+ var getInstructionRole = (relationship) => {
1870
+ if (relationship.kind !== "present") return "query-system-prompt";
1871
+ const candidate = unwrapExpression(relationship.expression);
1872
+ if (!ts.isObjectLiteralExpression(candidate)) return "query-system-prompt";
1873
+ const properties = getClosedObjectProperties(candidate);
1874
+ return properties !== null && getStaticString(properties.get("type") ?? candidate) === "preset" && getStaticString(properties.get("preset") ?? candidate) === "claude_code" ? "query-preset-append" : "query-system-prompt";
1875
+ };
1876
+ var inspectQueryInstructionLoader = async (session, inspected, evidence, diagnostics) => {
1877
+ const reference = inspected.agent.declaration.bindings?.instructionLoader;
1878
+ if (reference?.symbol === void 0) return;
1879
+ if (await inspectCallableSymbol$1(session, reference, inspected.agent.id, diagnostics) !== true) return;
1880
+ const results = inspected.wrapper.contexts.map((context) => context.agentSelection.kind === "absent" ? classifyClaudeAgentSdkInstructionLoader(context.systemPrompt, inspected.analysis, reference, true) : null);
1881
+ const wiredIndex = results.findIndex((result) => result === true);
1882
+ if (wiredIndex >= 0) {
1883
+ const context = inspected.wrapper.contexts[wiredIndex];
1884
+ if (context !== void 0) evidence.push(createClaudeAgentSdkEvidence({
1885
+ agentId: inspected.agent.id,
1886
+ capabilityId: null,
1887
+ capabilityKind: null,
1888
+ details: { role: getInstructionRole(context.systemPrompt) },
1889
+ kind: "instruction-loader",
1890
+ references: [{ path: inspected.analysis.path }, {
1891
+ path: reference.path,
1892
+ symbol: reference.symbol
1893
+ }],
1894
+ runtimeName: reference.symbol,
1895
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
1896
+ }));
1897
+ } else if (!inspected.wrapper.hasAmbiguousCandidate && results.every((result) => result === false)) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_INSTRUCTION_LOADER_NOT_WIRED", inspected.analysis.path, inspected.agent.id);
1898
+ };
1899
+ var inspectDefinitionInstructionLoader = async (session, inspected, evidence, diagnostics) => {
1900
+ const reference = inspected.agent.declaration.bindings?.instructionLoader;
1901
+ if (reference?.symbol === void 0) return;
1902
+ if (await inspectCallableSymbol$1(session, reference, inspected.agent.id, diagnostics) !== true) return;
1903
+ const relationship = classifyClaudeAgentSdkInstructionLoader(inspected.definition.prompt, inspected.analysis, reference, false);
1904
+ if (relationship === true) evidence.push(createClaudeAgentSdkEvidence({
1905
+ agentId: inspected.agent.id,
1906
+ capabilityId: null,
1907
+ capabilityKind: null,
1908
+ details: { role: "subagent-prompt" },
1909
+ kind: "instruction-loader",
1910
+ references: [{ path: inspected.analysis.path }, {
1911
+ path: reference.path,
1912
+ symbol: reference.symbol
1913
+ }],
1914
+ runtimeName: reference.symbol,
1915
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
1916
+ }));
1917
+ else if (relationship === false) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_INSTRUCTION_LOADER_NOT_WIRED", inspected.analysis.path, inspected.agent.id, inspected.definition.prompt.kind === "present" ? locateClaudeAgentSdkNode(inspected.analysis, inspected.definition.prompt.expression) : null);
1918
+ };
1919
+ var getOutputSchemaRelationship = (relationship) => {
1920
+ if (relationship.kind !== "present") return relationship;
1921
+ const candidate = unwrapExpression(relationship.expression);
1922
+ if (!ts.isObjectLiteralExpression(candidate)) return { kind: "unresolved" };
1923
+ const properties = getClosedObjectProperties(candidate);
1924
+ if (properties === null || properties.size !== 2 || getStaticString(properties.get("type") ?? candidate) !== "json_schema") return properties !== null ? {
1925
+ expression: candidate,
1926
+ kind: "present"
1927
+ } : { kind: "unresolved" };
1928
+ const schema = properties.get("schema");
1929
+ return schema === void 0 ? {
1930
+ expression: candidate,
1931
+ kind: "present"
1932
+ } : {
1933
+ expression: schema,
1934
+ kind: "present"
1935
+ };
1936
+ };
1937
+ var inspectQueryOutputSchema = async (session, inspected, evidence, diagnostics) => {
1938
+ const reference = inspected.agent.declaration.bindings?.outputSchema;
1939
+ if (reference?.symbol === void 0) return;
1940
+ const schemaAnalysis = await analyzeClaudeAgentSdkBoundReference(session, reference, diagnostics, inspected.agent.id);
1941
+ if (schemaAnalysis === null) return;
1942
+ const schema = getConstExport(schemaAnalysis, reference.symbol);
1943
+ if (schema.kind === "absent") {
1944
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_AGENT_OUTPUT_SCHEMA_SYMBOL_NOT_FOUND", reference.path, inspected.agent.id);
1945
+ return;
1946
+ }
1947
+ if (schema.kind !== "present-supported") return;
1948
+ const results = inspected.wrapper.contexts.map((context) => classifyClaudeAgentSdkDirectBinding(getOutputSchemaRelationship(context.outputFormat), inspected.analysis, reference));
1949
+ if (results.includes(true)) evidence.push(createClaudeAgentSdkEvidence({
1950
+ agentId: inspected.agent.id,
1951
+ capabilityId: null,
1952
+ capabilityKind: null,
1953
+ details: {
1954
+ role: "agent-output",
1955
+ schemaKind: "json-schema"
1956
+ },
1957
+ kind: "schema",
1958
+ references: [{ path: inspected.analysis.path }, {
1959
+ path: reference.path,
1960
+ symbol: reference.symbol
1961
+ }],
1962
+ runtimeName: reference.symbol,
1963
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
1964
+ }));
1965
+ else if (!inspected.wrapper.hasAmbiguousCandidate && results.every((result) => result === false)) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_AGENT_OUTPUT_SCHEMA_NOT_WIRED", inspected.analysis.path, inspected.agent.id);
1966
+ };
1967
+ /** Inspects canonical instruction and query-output-schema relationships. */
1968
+ var inspectClaudeAgentSdkRelationships = async (session, inspected, evidence, diagnostics) => {
1969
+ if (inspected.kind === "query-wrapper") {
1970
+ await inspectQueryInstructionLoader(session, inspected, evidence, diagnostics);
1971
+ await inspectQueryOutputSchema(session, inspected, evidence, diagnostics);
1972
+ } else await inspectDefinitionInstructionLoader(session, inspected, evidence, diagnostics);
1973
+ };
1974
+ //#endregion
1975
+ //#region src/package-discovery/index.ts
1976
+ /**
1977
+ * Discovers the nearest relevant Claude Agent SDK package declaration.
1978
+ * @param repository The Core-owned budget-aware repository reader.
1979
+ * @param sourcePath The bound source whose package scope is inspected.
1980
+ * @param signal The active inspection signal.
1981
+ * @returns The first observed declaration, invalid manifest, or absence result.
1982
+ * @throws
1983
+ * - INVALID_REPOSITORY_PATH: The repository path is invalid.
1984
+ * - ENTRY_NOT_FOUND: The requested repository entry was not found.
1985
+ * - ENTRY_NOT_FILE: The requested repository entry is not a file.
1986
+ * - ACCESS_DENIED: Access to the repository source was denied.
1987
+ * - SOURCE_UNAVAILABLE: The repository source is unavailable.
1988
+ * - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.
1989
+ * - INVALID_SOURCE_DATA: The repository source returned invalid data.
1990
+ * - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
1991
+ * - ABORTED: The repository operation was aborted.
1992
+ */
1993
+ var discoverClaudeAgentSdkPackage = async (repository, sourcePath, signal) => {
1994
+ const repositoryOptions = signal === void 0 ? void 0 : { signal };
1995
+ const result = await discoverPackage({
1996
+ packageName: CLAUDE_AGENT_SDK_PACKAGE_NAME,
1997
+ reader: {
1998
+ getEntry: (path) => repository.getEntry(parseRepositoryPath(path), repositoryOptions),
1999
+ readFile: (path) => repository.readFile(parseRepositoryPath(path), repositoryOptions)
2000
+ },
2001
+ ...signal === void 0 ? {} : { signal },
2002
+ sourcePath,
2003
+ supportedRange: CLAUDE_AGENT_SDK_SUPPORTED_RANGE
2004
+ });
2005
+ if (result.kind === "invalid") return Object.freeze({
2006
+ kind: "invalid",
2007
+ path: parseRepositoryPath(result.path)
2008
+ });
2009
+ if (result.kind === "observed") return Object.freeze({
2010
+ kind: "observed",
2011
+ observation: Object.freeze({
2012
+ ...result.observation,
2013
+ path: parseRepositoryPath(result.observation.path)
2014
+ })
2015
+ });
2016
+ return result;
2017
+ };
2018
+ //#endregion
2019
+ //#region src/inspection/session.ts
2020
+ /** Creates one operation-local Claude Agent SDK inspection session. */
2021
+ var createClaudeAgentSdkInspectionSession = (context) => createInspectionSession({
2022
+ analyzeSource: analyzeClaudeAgentSdkSource,
2023
+ discoverPackage: (path, signal) => discoverClaudeAgentSdkPackage(context.repository, path, signal),
2024
+ getEntry: (path, signal) => context.repository.getEntry(path, signal === void 0 ? void 0 : { signal }),
2025
+ readFile: (path, signal) => context.repository.readFile(path, signal === void 0 ? void 0 : { signal }),
2026
+ ...context.signal === void 0 ? {} : { signal: context.signal }
2027
+ });
2028
+ //#endregion
2029
+ //#region src/inspection/tools.ts
2030
+ var collectMcpServerReferences = (analysis) => {
2031
+ const serverRelationships = [...analysis.exports.keys()].flatMap((symbol) => {
2032
+ const result = getClaudeAgentSdkQueryWrapper(analysis, symbol);
2033
+ return result.kind === "present-supported" ? result.wrapper.contexts.map(({ mcpServers }) => mcpServers) : [];
2034
+ });
2035
+ const collectionReferences = collectClaudeAgentSdkRelationshipIdentifiers(serverRelationships);
2036
+ return new Set(serverRelationships.flatMap((relationship) => (getClaudeAgentSdkClosedMapEntries(relationship, analysis, collectionReferences) ?? []).map(({ value }) => value).filter((value) => ts.isIdentifier(value))));
2037
+ };
2038
+ var resolveEntryName = async (session, analysis, entry) => {
2039
+ if (entry.name !== null) return entry.name;
2040
+ const result = await resolveClaudeAgentSdkStaticString(session, analysis, entry.keyExpression);
2041
+ return result.kind === "supported" ? result.value : null;
2042
+ };
2043
+ var inspectCallableSymbol = async (session, reference, agentId, capabilityId, diagnostics) => {
2044
+ if (reference.symbol === void 0) return null;
2045
+ const analysis = await analyzeClaudeAgentSdkBoundReference(session, reference, diagnostics, agentId, capabilityId);
2046
+ if (analysis === null) return null;
2047
+ const state = getCallableExportState(analysis, reference.symbol);
2048
+ if (state.kind === "absent") {
2049
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_IMPLEMENTATION_SYMBOL_NOT_FOUND", reference.path, agentId, null, capabilityId);
2050
+ return false;
2051
+ }
2052
+ return state.kind === "present-supported" ? true : null;
2053
+ };
2054
+ var inspectConstSymbol = async (session, reference, agentId, capabilityId, diagnostics) => {
2055
+ if (reference.symbol === void 0) return null;
2056
+ const analysis = await analyzeClaudeAgentSdkBoundReference(session, reference, diagnostics, agentId, capabilityId);
2057
+ if (analysis === null) return null;
2058
+ const state = getConstExport(analysis, reference.symbol);
2059
+ if (state.kind === "absent") {
2060
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_INPUT_SCHEMA_SYMBOL_NOT_FOUND", reference.path, agentId, null, capabilityId);
2061
+ return false;
2062
+ }
2063
+ return state.kind === "present-supported" ? true : null;
2064
+ };
2065
+ var inspectManifestTool = async (session, agentId, capabilityId, declaration, evidence, diagnostics) => {
2066
+ const reference = declaration.registration;
2067
+ if (reference?.symbol === void 0) return null;
2068
+ const analysis = await analyzeClaudeAgentSdkBoundReference(session, reference, diagnostics, agentId, capabilityId);
2069
+ if (analysis === null) return null;
2070
+ const result = getClaudeAgentSdkToolDefinition(analysis, reference.symbol);
2071
+ if (result.kind === "absent") {
2072
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_REGISTRATION_SYMBOL_NOT_FOUND", reference.path, agentId, null, capabilityId);
2073
+ return null;
2074
+ }
2075
+ if (result.kind !== "present-supported") return null;
2076
+ const allowedReferences = collectClaudeAgentSdkMcpToolReferences(analysis);
2077
+ const mutations = analyzeClaudeAgentSdkMutations(analysis, result.tool.declaration, allowedReferences);
2078
+ const implementationRelationship = mutations.hasUnknownMutation || mutations.mutatedMembers.has("handler") ? null : classifyClaudeAgentSdkDirectBinding({
2079
+ expression: result.tool.implementation,
2080
+ kind: "present"
2081
+ }, analysis, declaration.implementation);
2082
+ if (await inspectCallableSymbol(session, declaration.implementation, agentId, capabilityId, diagnostics) === true && implementationRelationship === false) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_IMPLEMENTATION_NOT_WIRED", analysis.path, agentId, locateClaudeAgentSdkNode(analysis, result.tool.implementation), capabilityId);
2083
+ if (declaration.inputSchema?.symbol !== void 0) {
2084
+ const schemaState = await inspectConstSymbol(session, declaration.inputSchema, agentId, capabilityId, diagnostics);
2085
+ const schemaRelationship = mutations.hasUnknownMutation || mutations.mutatedMembers.has("inputSchema") ? null : classifyClaudeAgentSdkDirectBinding({
2086
+ expression: result.tool.inputSchema,
2087
+ kind: "present"
2088
+ }, analysis, declaration.inputSchema);
2089
+ if (schemaState === true && schemaRelationship === true) evidence.push(createClaudeAgentSdkEvidence({
2090
+ agentId,
2091
+ capabilityId,
2092
+ capabilityKind: "tool",
2093
+ details: {
2094
+ role: "tool-input",
2095
+ schemaKind: "sdk-tool-input"
2096
+ },
2097
+ kind: "schema",
2098
+ references: [{ path: analysis.path }, {
2099
+ path: declaration.inputSchema.path,
2100
+ symbol: declaration.inputSchema.symbol
2101
+ }],
2102
+ runtimeName: declaration.inputSchema.symbol,
2103
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
2104
+ }));
2105
+ else if (schemaState === true && schemaRelationship === false) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_INPUT_SCHEMA_NOT_WIRED", analysis.path, agentId, locateClaudeAgentSdkNode(analysis, result.tool.inputSchema), capabilityId);
2106
+ }
2107
+ return Object.freeze({
2108
+ analysis,
2109
+ definition: result.tool,
2110
+ reference: Object.freeze({
2111
+ path: reference.path,
2112
+ symbol: reference.symbol
2113
+ })
2114
+ });
2115
+ };
2116
+ var collectQueryMounts = async (session, queryAgent, diagnostics) => {
2117
+ const mounts = [];
2118
+ let hasUnresolvedCandidate = queryAgent.wrapper.hasAmbiguousCandidate;
2119
+ const queryCollectionReferences = collectClaudeAgentSdkRelationshipIdentifiers(queryAgent.wrapper.contexts.flatMap((queryContext) => [queryContext.mcpServers, queryContext.disallowedTools]));
2120
+ for (const queryContext of queryAgent.wrapper.contexts) {
2121
+ const entries = getClaudeAgentSdkClosedMapEntries(queryContext.mcpServers, queryAgent.analysis, queryCollectionReferences);
2122
+ if (entries === null) {
2123
+ hasUnresolvedCandidate = true;
2124
+ continue;
2125
+ }
2126
+ const resolvedNames = await Promise.all(entries.map((entry) => resolveEntryName(session, queryAgent.analysis, entry)));
2127
+ const supportedNames = resolvedNames.filter((name) => name !== null);
2128
+ if (supportedNames.length !== entries.length || new Set(supportedNames).size !== supportedNames.length) {
2129
+ hasUnresolvedCandidate = true;
2130
+ continue;
2131
+ }
2132
+ for (const [entryIndex, entry] of entries.entries()) {
2133
+ const serverKey = resolvedNames[entryIndex];
2134
+ if (serverKey === void 0 || serverKey === null) {
2135
+ hasUnresolvedCandidate = true;
2136
+ continue;
2137
+ }
2138
+ const server = await resolveClaudeAgentSdkMcpServer(session, queryAgent.analysis, entry.value);
2139
+ if (server === null) {
2140
+ hasUnresolvedCandidate = true;
2141
+ continue;
2142
+ }
2143
+ const serverMutations = analyzeClaudeAgentSdkMutations(server.analysis, server.definition.declaration, collectMcpServerReferences(server.analysis));
2144
+ if (serverMutations.hasUnknownMutation || serverMutations.mutatedMembers.has("tools")) {
2145
+ hasUnresolvedCandidate = true;
2146
+ continue;
2147
+ }
2148
+ if (!CLAUDE_AGENT_SDK_MCP_SERVER_KEY_PATTERN.test(serverKey)) {
2149
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_MCP_SERVER_KEY_UNSUPPORTED", queryAgent.analysis.path, queryAgent.agent.id, locateClaudeAgentSdkNode(queryAgent.analysis, entry.keyExpression));
2150
+ hasUnresolvedCandidate = true;
2151
+ continue;
2152
+ }
2153
+ const serverName = await resolveClaudeAgentSdkStaticString(session, server.analysis, server.definition.name);
2154
+ const serverVersion = server.definition.version.kind === "present" ? await resolveClaudeAgentSdkStaticString(session, server.analysis, server.definition.version.expression) : {
2155
+ kind: "supported",
2156
+ value: "",
2157
+ expression: server.definition.name
2158
+ };
2159
+ if (serverName.kind !== "supported" || serverVersion.kind !== "supported") {
2160
+ hasUnresolvedCandidate = true;
2161
+ continue;
2162
+ }
2163
+ const serverCollectionReferences = collectClaudeAgentSdkRelationshipIdentifiers([server.definition.tools]);
2164
+ const toolElements = getClaudeAgentSdkClosedArray(server.definition.tools, server.analysis, serverCollectionReferences);
2165
+ if (toolElements === null) {
2166
+ hasUnresolvedCandidate = true;
2167
+ continue;
2168
+ }
2169
+ for (const toolElement of toolElements) {
2170
+ const resolvedTool = await resolveClaudeAgentSdkTool(session, server.analysis, toolElement);
2171
+ if (resolvedTool === null) {
2172
+ hasUnresolvedCandidate = true;
2173
+ continue;
2174
+ }
2175
+ const toolMutations = analyzeClaudeAgentSdkMutations(resolvedTool.analysis, resolvedTool.definition.declaration, collectClaudeAgentSdkMcpToolReferences(resolvedTool.analysis));
2176
+ if (toolMutations.hasUnknownMutation || toolMutations.mutatedMembers.has("name")) {
2177
+ hasUnresolvedCandidate = true;
2178
+ continue;
2179
+ }
2180
+ const name = await resolveClaudeAgentSdkStaticString(session, resolvedTool.analysis, resolvedTool.definition.name);
2181
+ if (name.kind !== "supported") {
2182
+ hasUnresolvedCandidate = true;
2183
+ continue;
2184
+ }
2185
+ const runtimeName = `mcp__${serverKey}__${name.value}`;
2186
+ const availability = await classifyClaudeAgentSdkMcpToolAvailability(queryAgent.analysis, "available", null, queryContext.disallowedTools, queryContext.agentSelection, queryContext.toolAliases, queryCollectionReferences, runtimeName, serverKey, (analysis, expression) => resolveClaudeAgentSdkStaticString(session, analysis, expression));
2187
+ mounts.push(Object.freeze({
2188
+ availability,
2189
+ queryAgent,
2190
+ queryContext,
2191
+ runtimeName,
2192
+ serverKey,
2193
+ tool: Object.freeze({
2194
+ analysis: resolvedTool.analysis,
2195
+ definition: resolvedTool.definition,
2196
+ path: resolvedTool.path,
2197
+ symbol: resolvedTool.symbol,
2198
+ underlyingName: name.value
2199
+ })
2200
+ }));
2201
+ }
2202
+ }
2203
+ }
2204
+ return Object.freeze({
2205
+ hasUnresolvedCandidate,
2206
+ mounts: Object.freeze(mounts),
2207
+ queryAgent
2208
+ });
2209
+ };
2210
+ var isActiveDefinitionContext = async (session, mount, inspected) => {
2211
+ const queryAgent = mount.queryAgent;
2212
+ const references = collectClaudeAgentSdkRelationshipIdentifiers([
2213
+ mount.queryContext.tools,
2214
+ mount.queryContext.disallowedTools,
2215
+ mount.queryContext.agents
2216
+ ]);
2217
+ const agentAvailability = await classifyClaudeAgentSdkAgentAvailability(queryAgent.analysis, mount.queryContext.tools, mount.queryContext.disallowedTools, mount.queryContext.agentSelection, mount.queryContext.toolAliases, references, (analysis, expression) => resolveClaudeAgentSdkStaticString(session, analysis, expression));
2218
+ if (agentAvailability !== "available") return agentAvailability === "unavailable" ? false : null;
2219
+ const entries = getClaudeAgentSdkClosedMapEntries(mount.queryContext.agents, queryAgent.analysis, references);
2220
+ if (entries === null) return null;
2221
+ const targetReference = inspected.agent.declaration.bindings?.runtimeAgent;
2222
+ if (targetReference?.symbol === void 0) return false;
2223
+ for (const entry of entries) {
2224
+ const target = await resolveClaudeAgentSdkAgentDefinition(session, queryAgent.analysis, entry.value);
2225
+ if (target?.path === targetReference.path && target.symbol === targetReference.symbol) return true;
2226
+ }
2227
+ return false;
2228
+ };
2229
+ var getEligibleMounts = async (session, inspected, collections) => {
2230
+ if (inspected.kind === "query-wrapper") {
2231
+ const matchingCollection = collections.find(({ queryAgent }) => queryAgent.agent.id === inspected.agent.id);
2232
+ const directMounts = collections.flatMap(({ mounts }) => mounts.filter((mount) => mount.queryAgent.agent.id === inspected.agent.id));
2233
+ return Object.freeze({
2234
+ hasUnresolvedCandidate: matchingCollection?.hasUnresolvedCandidate ?? false,
2235
+ mounts: Object.freeze(directMounts)
2236
+ });
2237
+ }
2238
+ const mounts = [];
2239
+ let hasUnresolvedCandidate = false;
2240
+ for (const collection of collections) for (const mount of collection.mounts) {
2241
+ const active = await isActiveDefinitionContext(session, mount, inspected);
2242
+ if (active === null) hasUnresolvedCandidate = true;
2243
+ else if (active) {
2244
+ if (inspected.definition.mcpServers.kind !== "absent") hasUnresolvedCandidate = true;
2245
+ const references = collectClaudeAgentSdkRelationshipIdentifiers([inspected.definition.tools, inspected.definition.disallowedTools]);
2246
+ const availability = await classifyClaudeAgentSdkMcpToolAvailability(inspected.analysis, mount.availability, inspected.definition.tools, inspected.definition.disallowedTools, null, null, references, mount.runtimeName, mount.serverKey, (analysis, expression) => resolveClaudeAgentSdkStaticString(session, analysis, expression));
2247
+ mounts.push(Object.freeze({
2248
+ ...mount,
2249
+ availability
2250
+ }));
2251
+ }
2252
+ }
2253
+ return Object.freeze({
2254
+ hasUnresolvedCandidate,
2255
+ mounts: Object.freeze(mounts)
2256
+ });
2257
+ };
2258
+ /** Inspects custom tool declarations, schemas, implementations, mounts, and availability. */
2259
+ var inspectClaudeAgentSdkTools = async (session, inspectedAgents, evidence, diagnostics) => {
2260
+ const queryAgents = inspectedAgents.filter((inspected) => inspected.kind === "query-wrapper");
2261
+ const mountCollections = await Promise.all(queryAgents.map((queryAgent) => collectQueryMounts(session, queryAgent, diagnostics)));
2262
+ for (const inspected of inspectedAgents) {
2263
+ const eligible = await getEligibleMounts(session, inspected, mountCollections);
2264
+ for (const capabilityId of Object.keys(inspected.agent.declaration.tools ?? {}).sort(compareClaudeAgentSdkStrings)) {
2265
+ const declaration = inspected.agent.declaration.tools?.[capabilityId];
2266
+ if (declaration === void 0) continue;
2267
+ const registration = await inspectManifestTool(session, inspected.agent.id, capabilityId, declaration, evidence, diagnostics);
2268
+ if (registration === null) continue;
2269
+ const exactMounts = eligible.mounts.filter((mount) => mount.tool.path === registration.reference.path && mount.tool.symbol === registration.reference.symbol);
2270
+ const matchingMount = exactMounts.find((mount) => mount.availability === "available" && mount.runtimeName === declaration.name);
2271
+ if (matchingMount !== void 0 && isClaudeAgentSdkMachineString(matchingMount.runtimeName)) {
2272
+ evidence.push(createClaudeAgentSdkEvidence({
2273
+ agentId: inspected.agent.id,
2274
+ capabilityId,
2275
+ capabilityKind: "tool",
2276
+ details: {
2277
+ availabilitySource: inspected.kind === "query-wrapper" ? "query" : inspected.definition.tools.kind === "absent" ? "inherited-subagent-tools" : "explicit-subagent-tools",
2278
+ registrationKind: "sdk-mcp-tool",
2279
+ serverKey: matchingMount.serverKey,
2280
+ underlyingToolName: matchingMount.tool.underlyingName
2281
+ },
2282
+ kind: "tool-registration",
2283
+ references: [
2284
+ { path: matchingMount.queryAgent.analysis.path },
2285
+ {
2286
+ path: registration.reference.path,
2287
+ symbol: registration.reference.symbol
2288
+ },
2289
+ {
2290
+ path: declaration.implementation.path,
2291
+ ...declaration.implementation.symbol === void 0 ? {} : { symbol: declaration.implementation.symbol }
2292
+ }
2293
+ ],
2294
+ runtimeName: matchingMount.runtimeName,
2295
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
2296
+ }));
2297
+ continue;
2298
+ }
2299
+ const hasUnresolvedMount = eligible.hasUnresolvedCandidate || exactMounts.some(({ availability }) => availability === "unresolved");
2300
+ const closedMounts = exactMounts.filter(({ availability }) => availability !== "unresolved");
2301
+ const hasDeclaredRuntimeName = closedMounts.some(({ runtimeName }) => runtimeName === declaration.name);
2302
+ if (hasUnresolvedMount) continue;
2303
+ if (closedMounts.length > 0 && !hasDeclaredRuntimeName) {
2304
+ const observedRuntimeName = closedMounts.length === 1 ? closedMounts[0]?.runtimeName : void 0;
2305
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_NAME_MISMATCH", registration.analysis.path, inspected.agent.id, locateClaudeAgentSdkNode(registration.analysis, registration.definition.name), capabilityId, {
2306
+ expectedRuntimeName: declaration.name,
2307
+ ...observedRuntimeName !== void 0 && isClaudeAgentSdkMachineString(observedRuntimeName) ? { observedRuntimeName } : {}
2308
+ });
2309
+ } else if (inspected.kind === "query-wrapper" || eligible.mounts.length > 0) addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_TOOL_REGISTRATION_NOT_WIRED", inspected.analysis.path, inspected.agent.id, null, capabilityId);
2310
+ }
2311
+ }
2312
+ };
2313
+ //#endregion
2314
+ //#region src/inspection/inspection.ts
2315
+ var inspectAgent = async (session, agent, evidence, diagnostics) => {
2316
+ const runtimeAgent = agent.declaration.bindings?.runtimeAgent;
2317
+ if (runtimeAgent === void 0) return null;
2318
+ await inspectClaudeAgentSdkPackage(session, runtimeAgent.path, evidence, diagnostics, agent.id);
2319
+ if (!isSupportedTypeScriptSourcePath(runtimeAgent.path)) return null;
2320
+ evidence.push(createClaudeAgentSdkEvidence({
2321
+ agentId: agent.id,
2322
+ capabilityId: null,
2323
+ capabilityKind: null,
2324
+ details: { language: "typescript" },
2325
+ kind: "language",
2326
+ references: [runtimeAgent.symbol === void 0 ? { path: runtimeAgent.path } : {
2327
+ path: runtimeAgent.path,
2328
+ symbol: runtimeAgent.symbol
2329
+ }],
2330
+ runtimeName: null,
2331
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
2332
+ }));
2333
+ if (runtimeAgent.symbol === void 0) return null;
2334
+ const analysis = await analyzeClaudeAgentSdkBoundReference(session, runtimeAgent, diagnostics, agent.id);
2335
+ if (analysis === null) return null;
2336
+ if (!analysis.exports.has(runtimeAgent.symbol)) {
2337
+ addClaudeAgentSdkDiagnostic(diagnostics, "CLAUDE_AGENT_SDK_RUNTIME_AGENT_SYMBOL_NOT_FOUND", runtimeAgent.path, agent.id);
2338
+ return null;
2339
+ }
2340
+ const queryResult = getClaudeAgentSdkQueryWrapper(analysis, runtimeAgent.symbol);
2341
+ if (queryResult.kind === "present-supported") {
2342
+ evidence.push(createClaudeAgentSdkEvidence({
2343
+ agentId: agent.id,
2344
+ capabilityId: null,
2345
+ capabilityKind: null,
2346
+ details: {
2347
+ call: "query",
2348
+ patternId: "direct-query-wrapper"
2349
+ },
2350
+ kind: "runtime-pattern",
2351
+ references: [{
2352
+ path: runtimeAgent.path,
2353
+ symbol: runtimeAgent.symbol
2354
+ }],
2355
+ runtimeName: isClaudeAgentSdkMachineString(runtimeAgent.symbol) ? runtimeAgent.symbol : null,
2356
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
2357
+ }));
2358
+ return Object.freeze({
2359
+ agent,
2360
+ analysis,
2361
+ kind: "query-wrapper",
2362
+ wrapper: queryResult.wrapper
2363
+ });
2364
+ }
2365
+ const definitionResult = getClaudeAgentSdkAgentDefinition(analysis, runtimeAgent.symbol);
2366
+ if (definitionResult.kind !== "present-supported") return null;
2367
+ const definition = applyClaudeAgentSdkAgentMutations(analysis, definitionResult.definition, collectClaudeAgentSdkAgentDefinitionReferences(analysis));
2368
+ evidence.push(createClaudeAgentSdkEvidence({
2369
+ agentId: agent.id,
2370
+ capabilityId: null,
2371
+ capabilityKind: null,
2372
+ details: { patternId: "programmatic-agent-definition" },
2373
+ kind: "agent-definition",
2374
+ references: [{
2375
+ path: runtimeAgent.path,
2376
+ symbol: runtimeAgent.symbol
2377
+ }],
2378
+ runtimeName: isClaudeAgentSdkMachineString(runtimeAgent.symbol) ? runtimeAgent.symbol : null,
2379
+ source: CLAUDE_AGENT_SDK_ADAPTER_ID
2380
+ }));
2381
+ return Object.freeze({
2382
+ agent,
2383
+ analysis,
2384
+ definition,
2385
+ kind: "programmatic-agent-definition"
2386
+ });
2387
+ };
2388
+ /**
2389
+ * Inspects all scoped Claude Agent SDK agents through one deterministic session.
2390
+ * @param context The Core-provided immutable adapter context.
2391
+ * @returns A promise resolving to source-grounded evidence and diagnostics.
2392
+ * @throws
2393
+ * - INVALID_REPOSITORY_PATH: The repository path is invalid.
2394
+ * - ENTRY_NOT_FOUND: The requested repository entry was not found.
2395
+ * - ENTRY_NOT_FILE: The requested repository entry is not a file.
2396
+ * - ACCESS_DENIED: Access to the repository source was denied.
2397
+ * - SOURCE_UNAVAILABLE: The repository source is unavailable.
2398
+ * - SNAPSHOT_CHANGED: The repository snapshot changed during the operation.
2399
+ * - INVALID_SOURCE_DATA: The repository source returned invalid data.
2400
+ * - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
2401
+ * - ABORTED: The repository operation or inspection signal was aborted.
2402
+ */
2403
+ var inspectClaudeAgentSdk = async (context) => {
2404
+ context.signal?.throwIfAborted();
2405
+ const session = createClaudeAgentSdkInspectionSession(context);
2406
+ const evidence = [];
2407
+ const diagnostics = [];
2408
+ const agents = [...context.agents].sort((left, right) => compareClaudeAgentSdkStrings(left.id, right.id));
2409
+ const inspectedAgents = [];
2410
+ for (const agent of agents) {
2411
+ context.signal?.throwIfAborted();
2412
+ const inspected = await inspectAgent(session, agent, evidence, diagnostics);
2413
+ if (inspected !== null) inspectedAgents.push(inspected);
2414
+ }
2415
+ for (const inspected of inspectedAgents) {
2416
+ context.signal?.throwIfAborted();
2417
+ await inspectClaudeAgentSdkRelationships(session, inspected, evidence, diagnostics);
2418
+ if (inspected.kind === "query-wrapper") await inspectClaudeAgentSdkHandoffs(context, session, inspected, evidence, diagnostics);
2419
+ }
2420
+ await inspectClaudeAgentSdkTools(session, inspectedAgents, evidence, diagnostics);
2421
+ context.signal?.throwIfAborted();
2422
+ return Object.freeze({
2423
+ diagnostics: Object.freeze(diagnostics),
2424
+ evidence: Object.freeze(evidence)
2425
+ });
2426
+ };
2427
+ //#endregion
2428
+ //#region src/adapter/index.ts
2429
+ var claudeAgentSdkAdapter = Object.freeze({
2430
+ id: CLAUDE_AGENT_SDK_ADAPTER_ID,
2431
+ inspect: inspectClaudeAgentSdk,
2432
+ supportedRepositoryFormatVersions: CLAUDE_AGENT_SDK_SUPPORTED_REPOSITORY_FORMAT_VERSIONS
2433
+ });
2434
+ //#endregion
2435
+ export { claudeAgentSdkAdapter };