@moldea.ai/adapter-claude-agent-sdk 1.0.0 → 1.0.2

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +54 -29
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ The package implements the official `claude-agent-sdk` runtime adapter for `@mol
8
8
 
9
9
  ## Supported target
10
10
 
11
- Version `1.0.0` experimentally supports:
11
+ Version `1.0.2` supports:
12
12
 
13
13
  - Repository Format version `1`
14
14
  - `@moldea.ai/core ^2.0.0`
@@ -26,7 +26,7 @@ Version `1.0.0` experimentally supports:
26
26
 
27
27
  Named root-package imports and aliases of `query`, `tool`, and `createSdkMcpServer` are supported. Relative ESM named imports resolve exact paths plus `.js` to `.ts` or `.tsx` and `.mjs` to `.mts` substitutions. Relationship closure is independent: a dynamic relationship does not erase other relationships proved from the same query or definition.
28
28
 
29
- The Runtime Compatibility Matrix is authoritative for current target maturity, exact versions, evidence, binding support, patterns, and known limitations.
29
+ The Runtime Compatibility Matrix is authoritative for exact versions, evidence, binding support, patterns, and known limitations.
30
30
 
31
31
  ## Usage
32
32
 
package/dist/index.js CHANGED
@@ -186,14 +186,8 @@ var classifyPackageDeclarations = (declarations, supportedRange) => {
186
186
  if (classifications.every((classification) => classification === "unsupported")) return "unsupported";
187
187
  return "ambiguous";
188
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;
189
+ var readOwningManifest = async (options) => {
190
+ const { reader, signal, sourcePath } = options;
197
191
  for (const manifestPath of createPackageManifestCandidatePaths(sourcePath)) {
198
192
  signal?.throwIfAborted();
199
193
  const entry = await reader.getEntry(manifestPath);
@@ -221,28 +215,48 @@ var discoverPackage = async (options) => {
221
215
  });
222
216
  }
223
217
  signal?.throwIfAborted();
224
- if (!isRecord(parsed)) return Object.freeze({
225
- kind: "invalid",
218
+ return isRecord(parsed) ? Object.freeze({
219
+ kind: "present",
220
+ manifest: parsed,
226
221
  path: manifestPath
227
- });
228
- const declarations = extractPackageDeclarations(parsed, packageName);
229
- if (declarations === null) return Object.freeze({
222
+ }) : Object.freeze({
230
223
  kind: "invalid",
231
224
  path: manifestPath
232
225
  });
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
226
  }
243
227
  return Object.freeze({ kind: "absent" });
244
228
  };
245
229
  /**
230
+ * Discovers the nearest package declaration without repository enumeration.
231
+ * @param options The package target, repository callbacks, path, range, and signal.
232
+ * @returns The first observed declaration, invalid manifest, or absence result.
233
+ * @throws If repository reading or the active inspection is aborted.
234
+ */
235
+ var discoverPackage = async (options) => {
236
+ const { includeManifestPackageName, packageName, reader, signal, sourcePath, supportedRange } = options;
237
+ const owningManifest = await readOwningManifest({
238
+ reader,
239
+ ...signal === void 0 ? {} : { signal },
240
+ sourcePath
241
+ });
242
+ if (owningManifest.kind !== "present") return owningManifest;
243
+ const declarations = extractPackageDeclarations(owningManifest.manifest, packageName);
244
+ if (declarations === null) return Object.freeze({
245
+ kind: "invalid",
246
+ path: owningManifest.path
247
+ });
248
+ if (declarations.length === 0) return Object.freeze({ kind: "absent" });
249
+ return Object.freeze({
250
+ kind: "observed",
251
+ observation: Object.freeze({
252
+ compatibility: classifyPackageDeclarations(declarations, supportedRange),
253
+ declarations: Object.freeze(declarations),
254
+ ...includeManifestPackageName === true ? { manifestPackageName: typeof owningManifest.manifest["name"] === "string" ? owningManifest.manifest["name"] : null } : {},
255
+ path: owningManifest.path
256
+ })
257
+ });
258
+ };
259
+ /**
246
260
  * Removes the transparent expression wrappers supported by runtime adapters.
247
261
  * @param expression The expression to normalize.
248
262
  * @returns The underlying expression used by static matching.
@@ -742,9 +756,10 @@ var analyzeMutationCall = (identifier, mutatedMembers) => {
742
756
  * @param analysis The indexed source containing the binding.
743
757
  * @param declaration The module-local constant declaration.
744
758
  * @param allowedReferences Bare identifier uses proven to be supported registrations or targets.
759
+ * @param safeMethodCalls Read-only method calls that preserve the value's runtime configuration.
745
760
  * @returns Member-specific mutations and whether an unknown use can affect every relationship.
746
761
  */
747
- var analyzeModuleValueMutations = (analysis, declaration, allowedReferences) => {
762
+ var analyzeModuleValueMutations = (analysis, declaration, allowedReferences, safeMethodCalls = /* @__PURE__ */ new Set()) => {
748
763
  if (!ts.isIdentifier(declaration.name)) return Object.freeze({
749
764
  hasUnknownMutation: true,
750
765
  mutatedMembers: /* @__PURE__ */ new Set()
@@ -764,7 +779,9 @@ var analyzeModuleValueMutations = (analysis, declaration, allowedReferences) =>
764
779
  const memberExpression = skipTransparentParents(member);
765
780
  const memberParent = memberExpression.parent;
766
781
  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);
782
+ else if (ts.isCallExpression(memberParent) && memberParent.expression === memberExpression) {
783
+ if (!safeMethodCalls.has(memberName)) mutatedMembers.add(memberName);
784
+ }
768
785
  }
769
786
  continue;
770
787
  }
@@ -780,6 +797,17 @@ var analyzeModuleValueMutations = (analysis, declaration, allowedReferences) =>
780
797
  mutatedMembers: new Set(mutatedMembers)
781
798
  });
782
799
  };
800
+ var TYPESCRIPT_DECLARATION_EXTENSIONS = [
801
+ ".d.ts",
802
+ ".d.tsx",
803
+ ".d.mts",
804
+ ".d.cts"
805
+ ];
806
+ var TYPESCRIPT_SOURCE_EXTENSIONS = [
807
+ ".ts",
808
+ ".tsx",
809
+ ".mts"
810
+ ];
783
811
  var getScriptKind = (path) => path.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
784
812
  var createSyntaxProgram = (sourceFile, text) => {
785
813
  return ts.createProgram({
@@ -862,11 +890,7 @@ var analyzeTypeScriptModule = (path, bytes, importConfig, signal) => {
862
890
  * @param path The bound source path.
863
891
  * @returns Whether its extension is supported.
864
892
  */
865
- var isSupportedTypeScriptSourcePath = (path) => [
866
- ".ts",
867
- ".tsx",
868
- ".mts"
869
- ].some((extension) => path.endsWith(extension));
893
+ var isSupportedTypeScriptSourcePath = (path) => !TYPESCRIPT_DECLARATION_EXTENSIONS.some((extension) => path.endsWith(extension)) && TYPESCRIPT_SOURCE_EXTENSIONS.some((extension) => path.endsWith(extension));
870
894
  /**
871
895
  * Classifies a direct exported runtime-agent function and exposes its body.
872
896
  * @param analysis The indexed runtime source.
@@ -964,6 +988,7 @@ var resolveStaticStringExpression = async (options, analysis, expression, visite
964
988
  visited.add(key);
965
989
  const importedResult = await options.analyzeSource(importedPath);
966
990
  if (importedResult.kind !== "valid") {
991
+ options.onSourceFailure?.(importedPath, importedResult);
967
992
  visited.delete(key);
968
993
  return Object.freeze({ kind: "unsupported" });
969
994
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moldea.ai/adapter-claude-agent-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Deterministic runtime evidence and diagnostics for Claude Agent SDK query and subagent integrations.",
5
5
  "homepage": "https://github.com/moldea-ai/packages/tree/main/projects/adapter-claude-agent-sdk#readme",
6
6
  "bugs": {