@moldea.ai/adapter-openai-agents-sdk 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +209 -163
- package/dist/source-analysis/mutations.d.ts +1 -1
- package/dist/source-analysis/mutations.d.ts.map +1 -1
- package/dist/source-analysis/static-strings.d.ts +1 -1
- package/dist/source-analysis/static-strings.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
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
|
-
|
|
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
|
-
|
|
225
|
-
kind: "
|
|
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.
|
|
@@ -605,6 +619,117 @@ function getSafeModuleConstLiteral(expression, analysis, allowedReferences, kind
|
|
|
605
619
|
expression: initializer
|
|
606
620
|
});
|
|
607
621
|
}
|
|
622
|
+
var skipTransparentParents = (node) => {
|
|
623
|
+
let current = node;
|
|
624
|
+
while (ts.isAsExpression(current.parent) || ts.isParenthesizedExpression(current.parent) || ts.isSatisfiesExpression(current.parent)) current = current.parent;
|
|
625
|
+
return current;
|
|
626
|
+
};
|
|
627
|
+
var isAssignmentOperator = (kind) => kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
|
|
628
|
+
var isMutatingTarget = (expression) => {
|
|
629
|
+
const candidate = skipTransparentParents(expression);
|
|
630
|
+
const parent = candidate.parent;
|
|
631
|
+
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;
|
|
632
|
+
};
|
|
633
|
+
var getStaticMemberName = (member) => {
|
|
634
|
+
if (ts.isPropertyAccessExpression(member)) return member.name.text;
|
|
635
|
+
const argument = member.argumentExpression;
|
|
636
|
+
return argument !== void 0 && (ts.isStringLiteral(argument) || ts.isNoSubstitutionTemplateLiteral(argument)) ? argument.text : null;
|
|
637
|
+
};
|
|
638
|
+
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;
|
|
639
|
+
var addObjectAssignmentMembers = (object, mutatedMembers) => {
|
|
640
|
+
let hasUnknownMutation = false;
|
|
641
|
+
for (const property of object.properties) {
|
|
642
|
+
if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) {
|
|
643
|
+
hasUnknownMutation = true;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const propertyName = ts.isIdentifier(property.name) || ts.isStringLiteral(property.name) ? property.name.text : null;
|
|
647
|
+
if (propertyName === null) hasUnknownMutation = true;
|
|
648
|
+
else mutatedMembers.add(propertyName);
|
|
649
|
+
}
|
|
650
|
+
return hasUnknownMutation;
|
|
651
|
+
};
|
|
652
|
+
var analyzeMutationCall = (identifier, mutatedMembers) => {
|
|
653
|
+
const candidate = skipTransparentParents(identifier);
|
|
654
|
+
const parent = candidate.parent;
|
|
655
|
+
if (!ts.isCallExpression(parent)) return null;
|
|
656
|
+
const callee = unwrapExpression(parent.expression);
|
|
657
|
+
if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "Object" && callee.name.text === "assign" && parent.arguments[0] === candidate) {
|
|
658
|
+
let hasUnknownMutation = parent.arguments.length < 2;
|
|
659
|
+
for (const source of parent.arguments.slice(1)) {
|
|
660
|
+
const assignmentSource = unwrapExpression(source);
|
|
661
|
+
if (!ts.isObjectLiteralExpression(assignmentSource)) hasUnknownMutation = true;
|
|
662
|
+
else if (addObjectAssignmentMembers(assignmentSource, mutatedMembers)) hasUnknownMutation = true;
|
|
663
|
+
}
|
|
664
|
+
return hasUnknownMutation;
|
|
665
|
+
}
|
|
666
|
+
if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "Reflect" && callee.name.text === "set" && parent.arguments[0] === candidate) {
|
|
667
|
+
const member = parent.arguments[1];
|
|
668
|
+
if (member !== void 0 && (ts.isStringLiteral(member) || ts.isNoSubstitutionTemplateLiteral(member))) {
|
|
669
|
+
mutatedMembers.add(member.text);
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
return true;
|
|
673
|
+
}
|
|
674
|
+
return true;
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* Classifies module-local mutations and escapes for one returned object value.
|
|
678
|
+
* @param analysis The indexed source containing the binding.
|
|
679
|
+
* @param declaration The module-local constant declaration.
|
|
680
|
+
* @param allowedReferences Bare identifier uses proven to be supported registrations or targets.
|
|
681
|
+
* @param safeMethodCalls Read-only method calls that preserve the value's runtime configuration.
|
|
682
|
+
* @returns Member-specific mutations and whether an unknown use can affect every relationship.
|
|
683
|
+
*/
|
|
684
|
+
var analyzeModuleValueMutations = (analysis, declaration, allowedReferences, safeMethodCalls = /* @__PURE__ */ new Set()) => {
|
|
685
|
+
if (!ts.isIdentifier(declaration.name)) return Object.freeze({
|
|
686
|
+
hasUnknownMutation: true,
|
|
687
|
+
mutatedMembers: /* @__PURE__ */ new Set()
|
|
688
|
+
});
|
|
689
|
+
const mutatedMembers = /* @__PURE__ */ new Set();
|
|
690
|
+
let hasUnknownMutation = false;
|
|
691
|
+
for (const identifier of analysis.identifierUses.get(declaration.name.text) ?? []) {
|
|
692
|
+
if (isIgnoredIdentifier(identifier, declaration.name) || !isModuleBindingVisible(identifier, analysis) || allowedReferences.has(identifier)) continue;
|
|
693
|
+
const expression = skipTransparentParents(identifier);
|
|
694
|
+
const parent = expression.parent;
|
|
695
|
+
const member = (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === expression ? parent : null;
|
|
696
|
+
if (member !== null) {
|
|
697
|
+
const memberName = getStaticMemberName(member);
|
|
698
|
+
if (memberName === null) hasUnknownMutation = true;
|
|
699
|
+
else if (isMutatingTarget(member)) mutatedMembers.add(memberName);
|
|
700
|
+
else {
|
|
701
|
+
const memberExpression = skipTransparentParents(member);
|
|
702
|
+
const memberParent = memberExpression.parent;
|
|
703
|
+
if ((ts.isPropertyAccessExpression(memberParent) || ts.isElementAccessExpression(memberParent)) && memberParent.expression === memberExpression && ts.isCallExpression(skipTransparentParents(memberParent).parent)) mutatedMembers.add(memberName);
|
|
704
|
+
else if (ts.isCallExpression(memberParent) && memberParent.expression === memberExpression) {
|
|
705
|
+
if (!safeMethodCalls.has(memberName)) mutatedMembers.add(memberName);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if (isMutatingTarget(identifier)) {
|
|
711
|
+
hasUnknownMutation = true;
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const mutationCall = analyzeMutationCall(identifier, mutatedMembers);
|
|
715
|
+
hasUnknownMutation ||= mutationCall ?? true;
|
|
716
|
+
}
|
|
717
|
+
return Object.freeze({
|
|
718
|
+
hasUnknownMutation,
|
|
719
|
+
mutatedMembers: new Set(mutatedMembers)
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
var TYPESCRIPT_DECLARATION_EXTENSIONS = [
|
|
723
|
+
".d.ts",
|
|
724
|
+
".d.tsx",
|
|
725
|
+
".d.mts",
|
|
726
|
+
".d.cts"
|
|
727
|
+
];
|
|
728
|
+
var TYPESCRIPT_SOURCE_EXTENSIONS = [
|
|
729
|
+
".ts",
|
|
730
|
+
".tsx",
|
|
731
|
+
".mts"
|
|
732
|
+
];
|
|
608
733
|
var getScriptKind = (path) => path.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
609
734
|
var createSyntaxProgram = (sourceFile, text) => {
|
|
610
735
|
return ts.createProgram({
|
|
@@ -687,11 +812,7 @@ var analyzeTypeScriptModule = (path, bytes, importConfig, signal) => {
|
|
|
687
812
|
* @param path The bound source path.
|
|
688
813
|
* @returns Whether its extension is supported.
|
|
689
814
|
*/
|
|
690
|
-
var isSupportedTypeScriptSourcePath = (path) =>
|
|
691
|
-
".ts",
|
|
692
|
-
".tsx",
|
|
693
|
-
".mts"
|
|
694
|
-
].some((extension) => path.endsWith(extension));
|
|
815
|
+
var isSupportedTypeScriptSourcePath = (path) => !TYPESCRIPT_DECLARATION_EXTENSIONS.some((extension) => path.endsWith(extension)) && TYPESCRIPT_SOURCE_EXTENSIONS.some((extension) => path.endsWith(extension));
|
|
695
816
|
/**
|
|
696
817
|
* Classifies a direct exported runtime-agent function and exposes its body.
|
|
697
818
|
* @param analysis The indexed runtime source.
|
|
@@ -753,105 +874,71 @@ var getConstExport = (analysis, symbol) => {
|
|
|
753
874
|
kind: "present-unsupported"
|
|
754
875
|
});
|
|
755
876
|
};
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
return current;
|
|
762
|
-
};
|
|
763
|
-
var isAssignmentOperator = (kind) => kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
|
|
764
|
-
var isMutatingTarget = (expression) => {
|
|
765
|
-
const candidate = skipTransparentParents(expression);
|
|
766
|
-
const parent = candidate.parent;
|
|
767
|
-
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;
|
|
768
|
-
};
|
|
769
|
-
var getStaticMemberName = (member) => {
|
|
770
|
-
if (ts.isPropertyAccessExpression(member)) return member.name.text;
|
|
771
|
-
const argument = member.argumentExpression;
|
|
772
|
-
return argument !== void 0 && (ts.isStringLiteral(argument) || ts.isNoSubstitutionTemplateLiteral(argument)) ? argument.text : null;
|
|
773
|
-
};
|
|
774
|
-
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;
|
|
775
|
-
var addObjectAssignmentMembers = (object, mutatedMembers) => {
|
|
776
|
-
let hasUnknownMutation = false;
|
|
777
|
-
for (const property of object.properties) {
|
|
778
|
-
if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) {
|
|
779
|
-
hasUnknownMutation = true;
|
|
780
|
-
continue;
|
|
781
|
-
}
|
|
782
|
-
const propertyName = ts.isIdentifier(property.name) || ts.isStringLiteral(property.name) ? property.name.text : null;
|
|
783
|
-
if (propertyName === null) hasUnknownMutation = true;
|
|
784
|
-
else mutatedMembers.add(propertyName);
|
|
877
|
+
var resolveCandidatePath = async (options, containingPath, moduleSpecifier) => {
|
|
878
|
+
const matchingPaths = [];
|
|
879
|
+
for (const candidate of resolveImportCandidatePaths(containingPath, moduleSpecifier)) {
|
|
880
|
+
const path = options.parsePath(candidate);
|
|
881
|
+
if ((await options.getEntry(path))?.type === "file") matchingPaths.push(path);
|
|
785
882
|
}
|
|
786
|
-
return
|
|
883
|
+
return matchingPaths.length === 1 ? matchingPaths[0] : null;
|
|
787
884
|
};
|
|
788
|
-
var
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
885
|
+
var resolveStaticStringExpression = async (options, analysis, expression, visited) => {
|
|
886
|
+
options.signal?.throwIfAborted();
|
|
887
|
+
const candidate = unwrapExpression(expression);
|
|
888
|
+
const literal = getStaticString(candidate);
|
|
889
|
+
if (literal !== null) return Object.freeze({
|
|
890
|
+
expression: candidate,
|
|
891
|
+
kind: "supported",
|
|
892
|
+
value: literal
|
|
893
|
+
});
|
|
894
|
+
if (!ts.isIdentifier(candidate) || !isModuleBindingVisible(candidate, analysis)) return Object.freeze({ kind: "unsupported" });
|
|
895
|
+
const localDeclaration = analysis.moduleConstDeclarations.get(candidate.text);
|
|
896
|
+
if (localDeclaration?.initializer !== void 0) {
|
|
897
|
+
const key = `${analysis.path}\0local\0${candidate.text}`;
|
|
898
|
+
if (visited.has(key)) return Object.freeze({ kind: "unsupported" });
|
|
899
|
+
visited.add(key);
|
|
900
|
+
const result = await resolveStaticStringExpression(options, analysis, localDeclaration.initializer, visited);
|
|
901
|
+
visited.delete(key);
|
|
902
|
+
return result;
|
|
801
903
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
904
|
+
const namedImport = analysis.namedImports.get(candidate.text);
|
|
905
|
+
if (namedImport === void 0) return Object.freeze({ kind: "unsupported" });
|
|
906
|
+
const importedPath = await resolveCandidatePath(options, analysis.path, namedImport.moduleSpecifier);
|
|
907
|
+
if (importedPath === null) return Object.freeze({ kind: "unsupported" });
|
|
908
|
+
const key = `${importedPath}\0export\0${namedImport.importedName}`;
|
|
909
|
+
if (visited.has(key)) return Object.freeze({ kind: "unsupported" });
|
|
910
|
+
visited.add(key);
|
|
911
|
+
const importedResult = await options.analyzeSource(importedPath);
|
|
912
|
+
if (importedResult.kind !== "valid") {
|
|
913
|
+
options.onSourceFailure?.(importedPath, importedResult);
|
|
914
|
+
visited.delete(key);
|
|
915
|
+
return Object.freeze({ kind: "unsupported" });
|
|
809
916
|
}
|
|
810
|
-
|
|
917
|
+
const exported = getConstExport(importedResult.analysis, namedImport.importedName);
|
|
918
|
+
if (exported.kind !== "present-supported" || exported.expression === void 0) {
|
|
919
|
+
visited.delete(key);
|
|
920
|
+
return Object.freeze({ kind: "unsupported" });
|
|
921
|
+
}
|
|
922
|
+
const result = await resolveStaticStringExpression(options, importedResult.analysis, exported.expression, visited);
|
|
923
|
+
visited.delete(key);
|
|
924
|
+
return result;
|
|
811
925
|
};
|
|
812
926
|
/**
|
|
927
|
+
* Resolves one exact supported static string without normalization or execution.
|
|
928
|
+
* @param options The source, expression, repository callbacks, and parser for the relationship.
|
|
929
|
+
* @returns The exact compiler-parsed string or an unsupported state.
|
|
930
|
+
*/
|
|
931
|
+
var resolveStaticString = (options) => resolveStaticStringExpression(options, options.analysis, options.expression, /* @__PURE__ */ new Set());
|
|
932
|
+
//#endregion
|
|
933
|
+
//#region src/source-analysis/mutations.ts
|
|
934
|
+
/**
|
|
813
935
|
* Classifies module-local mutations and escapes for one returned SDK object.
|
|
814
936
|
* @param analysis The indexed source containing the binding.
|
|
815
937
|
* @param declaration The module-local constant declaration.
|
|
816
938
|
* @param allowedReferences Bare identifier uses proven to be supported registrations or targets.
|
|
817
939
|
* @returns Member-specific mutations and whether an unknown use can affect every relationship.
|
|
818
940
|
*/
|
|
819
|
-
var analyzeOpenAiAgentsSdkMutations = (analysis, declaration, allowedReferences) =>
|
|
820
|
-
if (!ts.isIdentifier(declaration.name)) return Object.freeze({
|
|
821
|
-
hasUnknownMutation: true,
|
|
822
|
-
mutatedMembers: /* @__PURE__ */ new Set()
|
|
823
|
-
});
|
|
824
|
-
const mutatedMembers = /* @__PURE__ */ new Set();
|
|
825
|
-
let hasUnknownMutation = false;
|
|
826
|
-
for (const identifier of analysis.identifierUses.get(declaration.name.text) ?? []) {
|
|
827
|
-
if (isIgnoredIdentifier(identifier, declaration.name) || !isModuleBindingVisible(identifier, analysis) || allowedReferences.has(identifier)) continue;
|
|
828
|
-
const expression = skipTransparentParents(identifier);
|
|
829
|
-
const parent = expression.parent;
|
|
830
|
-
const member = (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === expression ? parent : null;
|
|
831
|
-
if (member !== null) {
|
|
832
|
-
const memberName = getStaticMemberName(member);
|
|
833
|
-
if (memberName === null) hasUnknownMutation = true;
|
|
834
|
-
else if (isMutatingTarget(member)) mutatedMembers.add(memberName);
|
|
835
|
-
else {
|
|
836
|
-
const memberExpression = skipTransparentParents(member);
|
|
837
|
-
const memberParent = memberExpression.parent;
|
|
838
|
-
if ((ts.isPropertyAccessExpression(memberParent) || ts.isElementAccessExpression(memberParent)) && memberParent.expression === memberExpression && ts.isCallExpression(skipTransparentParents(memberParent).parent)) mutatedMembers.add(memberName);
|
|
839
|
-
else if (ts.isCallExpression(memberParent) && memberParent.expression === memberExpression) mutatedMembers.add(memberName);
|
|
840
|
-
}
|
|
841
|
-
continue;
|
|
842
|
-
}
|
|
843
|
-
if (isMutatingTarget(identifier)) {
|
|
844
|
-
hasUnknownMutation = true;
|
|
845
|
-
continue;
|
|
846
|
-
}
|
|
847
|
-
const mutationCall = analyzeMutationCall(identifier, mutatedMembers);
|
|
848
|
-
hasUnknownMutation ||= mutationCall ?? true;
|
|
849
|
-
}
|
|
850
|
-
return Object.freeze({
|
|
851
|
-
hasUnknownMutation,
|
|
852
|
-
mutatedMembers: new Set(mutatedMembers)
|
|
853
|
-
});
|
|
854
|
-
};
|
|
941
|
+
var analyzeOpenAiAgentsSdkMutations = (analysis, declaration, allowedReferences) => analyzeModuleValueMutations(analysis, declaration, allowedReferences);
|
|
855
942
|
//#endregion
|
|
856
943
|
//#region src/source-analysis/agent-definitions.ts
|
|
857
944
|
var RELATIONSHIP_NAMES = [
|
|
@@ -1307,54 +1394,6 @@ var analyzeOpenAiAgentsSdkSource = (path, bytes, signal) => {
|
|
|
1307
1394
|
};
|
|
1308
1395
|
//#endregion
|
|
1309
1396
|
//#region src/source-analysis/static-strings.ts
|
|
1310
|
-
var resolveCandidatePath = async (session, containingPath, moduleSpecifier) => {
|
|
1311
|
-
const matchingPaths = [];
|
|
1312
|
-
for (const candidate of resolveImportCandidatePaths(containingPath, moduleSpecifier)) {
|
|
1313
|
-
const path = parseRepositoryPath(candidate);
|
|
1314
|
-
if ((await session.getEntry(path))?.type === "file") matchingPaths.push(path);
|
|
1315
|
-
}
|
|
1316
|
-
return matchingPaths.length === 1 ? matchingPaths[0] : null;
|
|
1317
|
-
};
|
|
1318
|
-
var resolveStaticString = async (session, analysis, expression, visited) => {
|
|
1319
|
-
session.signal?.throwIfAborted();
|
|
1320
|
-
const candidate = unwrapExpression(expression);
|
|
1321
|
-
const literal = getStaticString(candidate);
|
|
1322
|
-
if (literal !== null) return Object.freeze({
|
|
1323
|
-
expression: candidate,
|
|
1324
|
-
kind: "supported",
|
|
1325
|
-
value: literal
|
|
1326
|
-
});
|
|
1327
|
-
if (!ts.isIdentifier(candidate) || !isModuleBindingVisible(candidate, analysis)) return Object.freeze({ kind: "unsupported" });
|
|
1328
|
-
const localDeclaration = analysis.moduleConstDeclarations.get(candidate.text);
|
|
1329
|
-
if (localDeclaration?.initializer !== void 0) {
|
|
1330
|
-
const key = `${analysis.path}\0local\0${candidate.text}`;
|
|
1331
|
-
if (visited.has(key)) return Object.freeze({ kind: "unsupported" });
|
|
1332
|
-
visited.add(key);
|
|
1333
|
-
const result = await resolveStaticString(session, analysis, localDeclaration.initializer, visited);
|
|
1334
|
-
visited.delete(key);
|
|
1335
|
-
return result;
|
|
1336
|
-
}
|
|
1337
|
-
const namedImport = analysis.namedImports.get(candidate.text);
|
|
1338
|
-
if (namedImport === void 0) return Object.freeze({ kind: "unsupported" });
|
|
1339
|
-
const importedPath = await resolveCandidatePath(session, analysis.path, namedImport.moduleSpecifier);
|
|
1340
|
-
if (importedPath === null) return Object.freeze({ kind: "unsupported" });
|
|
1341
|
-
const key = `${importedPath}\0export\0${namedImport.importedName}`;
|
|
1342
|
-
if (visited.has(key)) return Object.freeze({ kind: "unsupported" });
|
|
1343
|
-
visited.add(key);
|
|
1344
|
-
const importedResult = await session.analyzeSource(importedPath);
|
|
1345
|
-
if (importedResult.kind !== "valid") {
|
|
1346
|
-
visited.delete(key);
|
|
1347
|
-
return Object.freeze({ kind: "unsupported" });
|
|
1348
|
-
}
|
|
1349
|
-
const exported = getConstExport(importedResult.analysis, namedImport.importedName);
|
|
1350
|
-
if (exported.kind !== "present-supported" || exported.expression === void 0) {
|
|
1351
|
-
visited.delete(key);
|
|
1352
|
-
return Object.freeze({ kind: "unsupported" });
|
|
1353
|
-
}
|
|
1354
|
-
const result = await resolveStaticString(session, importedResult.analysis, exported.expression, visited);
|
|
1355
|
-
visited.delete(key);
|
|
1356
|
-
return result;
|
|
1357
|
-
};
|
|
1358
1397
|
/**
|
|
1359
1398
|
* Resolves one exact supported static string without normalization or execution.
|
|
1360
1399
|
* @param session The operation-local source session.
|
|
@@ -1362,7 +1401,14 @@ var resolveStaticString = async (session, analysis, expression, visited) => {
|
|
|
1362
1401
|
* @param expression The candidate static string expression.
|
|
1363
1402
|
* @returns The exact compiler-parsed string or an unsupported state.
|
|
1364
1403
|
*/
|
|
1365
|
-
var resolveOpenAiAgentsSdkStaticString = (session, analysis, expression) => resolveStaticString(
|
|
1404
|
+
var resolveOpenAiAgentsSdkStaticString = (session, analysis, expression) => resolveStaticString({
|
|
1405
|
+
analysis,
|
|
1406
|
+
analyzeSource: (path) => session.analyzeSource(path),
|
|
1407
|
+
expression,
|
|
1408
|
+
getEntry: (path) => session.getEntry(path),
|
|
1409
|
+
parsePath: parseRepositoryPath,
|
|
1410
|
+
...session.signal === void 0 ? {} : { signal: session.signal }
|
|
1411
|
+
});
|
|
1366
1412
|
//#endregion
|
|
1367
1413
|
//#region src/source-analysis/tool-collections.ts
|
|
1368
1414
|
var getClosedToolArray = (relationship, analysis, allowedCollectionReferences) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/source-analysis/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/source-analysis/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE5E,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,GAC1C,UAAU,8BAA8B,EACxC,aAAa,EAAE,CAAC,mBAAmB,EACnC,mBAAmB,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,KAC5C,gCACoE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import type ts from 'typescript';
|
|
2
2
|
import type { IOpenAiAgentsSdkInspectionSession, IOpenAiAgentsSdkSourceAnalysis, IOpenAiAgentsSdkStaticStringResult } from '../contracts/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves one exact supported static string without normalization or execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-strings.d.ts","sourceRoot":"","sources":["../../src/source-analysis/static-strings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"static-strings.d.ts","sourceRoot":"","sources":["../../src/source-analysis/static-strings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAKjC,OAAO,KAAK,EACV,iCAAiC,EACjC,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,uBAAuB,CAAC;AAE/B;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC,GAC7C,SAAS,iCAAiC,EAC1C,UAAU,8BAA8B,EACxC,YAAY,EAAE,CAAC,UAAU,KACxB,OAAO,CAAC,kCAAkC,CAQzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moldea.ai/adapter-openai-agents-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Deterministic runtime evidence and diagnostics for direct OpenAI Agents SDK integrations.",
|
|
5
5
|
"homepage": "https://github.com/moldea-ai/packages/tree/main/projects/adapter-openai-agents-sdk#readme",
|
|
6
6
|
"bugs": {
|