@moldea.ai/adapter-google-genai 3.0.2 → 4.1.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.
- package/README.md +7 -3
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +8 -5
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/diagnostics/index.d.ts +60 -14
- package/dist/diagnostics/index.d.ts.map +1 -1
- package/dist/index.js +368 -280
- package/dist/inspection/common.d.ts +1 -1
- package/dist/inspection/common.d.ts.map +1 -1
- package/dist/inspection/inspection.d.ts.map +1 -1
- package/dist/source-analysis/generate-content.d.ts.map +1 -1
- package/dist/source-analysis/source-analysis.d.ts +1 -1
- package/docs/evidence-and-diagnostics.md +3 -0
- package/docs/index.md +1 -1
- package/docs/limitations.md +1 -1
- package/docs/verified-target.md +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,14 +8,14 @@ The package implements the official `google-genai` runtime adapter for `@moldea.
|
|
|
8
8
|
|
|
9
9
|
## Supported target
|
|
10
10
|
|
|
11
|
-
Version `
|
|
11
|
+
Version `4.1.0` supports:
|
|
12
12
|
|
|
13
13
|
- Repository Format version `1`
|
|
14
|
-
- `@moldea.ai/core ^
|
|
14
|
+
- `@moldea.ai/core ^5.0.0`
|
|
15
15
|
- TypeScript ESM source
|
|
16
16
|
- npm `@google/genai >=2.17.1`
|
|
17
17
|
- a named runtime value import of `GoogleGenAI` and a module-local `const` client
|
|
18
|
-
- a bound exported runtime-agent function containing direct `client.models.generateContent({ ... })` calls
|
|
18
|
+
- a bound exported runtime-agent function containing direct `client.models.generateContent({ ... })` or `generateContentStream({ ... })` calls
|
|
19
19
|
- direct instruction-loader wiring through `config.systemInstruction`
|
|
20
20
|
- closed inline or immutable module-local tool, tool-container, function-declaration, and registration values through `config.tools[].functionDeclarations`
|
|
21
21
|
- direct input-schema wiring through `parametersJsonSchema`
|
|
@@ -44,6 +44,10 @@ The package exports only `googleGenAiAdapter`. It has no default export, mutable
|
|
|
44
44
|
|
|
45
45
|
## Evidence and diagnostics
|
|
46
46
|
|
|
47
|
+
`GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED` has severity `warning` only when the adapter identifies a declared relationship affected by a recognized but unresolved source candidate. Its safe details identify the relationship and reason; known version-behavior boundaries additionally carry normalized dependency context. Missing local evidence or a newer eligible dependency version alone does not produce this warning. Confirmed diagnostic codes remain errors.
|
|
48
|
+
|
|
49
|
+
`GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED`: The declared runtime relationship could not be verified.
|
|
50
|
+
|
|
47
51
|
The verified target may emit `runtime-package`, `language`, `runtime-pattern`, `instruction-loader`, `tool-registration`, and `schema` evidence. Evidence is source-grounded and never contains repository source, instructions, schemas, credentials, client configuration, provider payloads, or model output.
|
|
48
52
|
|
|
49
53
|
See [Evidence and diagnostics](docs/evidence-and-diagnostics.md) for the complete stable catalog and cascade behavior.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const GOOGLE_GENAI_ADAPTER_ID = "google-genai";
|
|
2
|
-
export declare const GOOGLE_GENAI_GENERATE_CONTENT_RUNTIME_NAME = "models.generateContent";
|
|
3
2
|
export declare const GOOGLE_GENAI_SDK_PACKAGE_NAME = "@google/genai";
|
|
4
3
|
export declare const GOOGLE_GENAI_SDK_SUPPORTED_RANGE = ">=2.17.1";
|
|
5
4
|
export declare const GOOGLE_GENAI_SUPPORTED_REPOSITORY_FORMAT_VERSIONS: readonly 1[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,gCAAgC,aAAa,CAAC;AAC3D,eAAO,MAAM,iDAAiD,cAEd,CAAC;AAGjD,eAAO,MAAM,uCAAuC,MAAM,CAAC;AAC3D,eAAO,MAAM,gCAAgC,MAAM,CAAC;AACpD,eAAO,MAAM,kCAAkC,QAAgC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
2
|
import type { ISourceRange } from '@moldea.ai/core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IAdapterErrorDiagnostic, IAdapterWarningDiagnostic } from '@moldea.ai/core/adapter';
|
|
4
4
|
import type { IRepositoryEntry, IRepositoryPath } from '@moldea.ai/repository';
|
|
5
|
-
export type IGoogleGenAiAdapterDiagnosticCode = 'GOOGLE_GENAI_PACKAGE_MANIFEST_INVALID' | 'GOOGLE_GENAI_SDK_VERSION_UNSUPPORTED' | 'GOOGLE_GENAI_SOURCE_TEXT_INVALID' | 'GOOGLE_GENAI_SOURCE_SYNTAX_INVALID' | 'GOOGLE_GENAI_RUNTIME_AGENT_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_INSTRUCTION_LOADER_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_TOOL_REGISTRATION_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_TOOL_INPUT_SCHEMA_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_INSTRUCTION_LOADER_NOT_WIRED' | 'GOOGLE_GENAI_TOOL_REGISTRATION_NOT_WIRED' | 'GOOGLE_GENAI_TOOL_NAME_MISMATCH' | 'GOOGLE_GENAI_TOOL_NAME_INVALID' | 'GOOGLE_GENAI_TOOL_INPUT_SCHEMA_NOT_WIRED' | 'GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED';
|
|
5
|
+
export type IGoogleGenAiAdapterDiagnosticCode = 'GOOGLE_GENAI_PACKAGE_MANIFEST_INVALID' | 'GOOGLE_GENAI_SDK_VERSION_UNSUPPORTED' | 'GOOGLE_GENAI_SOURCE_TEXT_INVALID' | 'GOOGLE_GENAI_SOURCE_SYNTAX_INVALID' | 'GOOGLE_GENAI_RUNTIME_AGENT_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_INSTRUCTION_LOADER_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_TOOL_REGISTRATION_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_TOOL_INPUT_SCHEMA_SYMBOL_NOT_FOUND' | 'GOOGLE_GENAI_INSTRUCTION_LOADER_NOT_WIRED' | 'GOOGLE_GENAI_TOOL_REGISTRATION_NOT_WIRED' | 'GOOGLE_GENAI_TOOL_NAME_MISMATCH' | 'GOOGLE_GENAI_TOOL_NAME_INVALID' | 'GOOGLE_GENAI_TOOL_INPUT_SCHEMA_NOT_WIRED' | 'GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED' | 'GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED';
|
|
6
6
|
export interface IGoogleGenAiSourceLocator {
|
|
7
7
|
locateRange(startOffset: number, endOffset: number): ISourceRange;
|
|
8
8
|
}
|
|
@@ -88,6 +88,7 @@ export type IGoogleGenAiRequestRelationship = {
|
|
|
88
88
|
};
|
|
89
89
|
export interface IGoogleGenAiGenerateContentRequest {
|
|
90
90
|
readonly config: IGoogleGenAiRequestRelationship;
|
|
91
|
+
readonly methodName: string;
|
|
91
92
|
readonly object: ts.ObjectLiteralExpression;
|
|
92
93
|
readonly systemInstruction: IGoogleGenAiRequestRelationship;
|
|
93
94
|
readonly tools: IGoogleGenAiRequestRelationship;
|
|
@@ -102,7 +103,9 @@ export interface IGoogleGenAiInspectionSession {
|
|
|
102
103
|
discoverPackage(path: IRepositoryPath): Promise<IGoogleGenAiPackageDiscoveryResult>;
|
|
103
104
|
getEntry(path: IRepositoryPath): Promise<IRepositoryEntry | null>;
|
|
104
105
|
}
|
|
105
|
-
export type IGoogleGenAiDiagnosticInput = Omit<
|
|
106
|
-
readonly code: IGoogleGenAiAdapterDiagnosticCode
|
|
107
|
-
}
|
|
106
|
+
export type IGoogleGenAiDiagnosticInput = (Omit<IAdapterErrorDiagnostic, 'message' | 'source' | 'severity' | 'code'> & {
|
|
107
|
+
readonly code: Exclude<IGoogleGenAiAdapterDiagnosticCode, 'GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED'>;
|
|
108
|
+
}) | (Omit<IAdapterWarningDiagnostic, 'message' | 'source' | 'severity' | 'code'> & {
|
|
109
|
+
readonly code: 'GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED';
|
|
110
|
+
});
|
|
108
111
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,20 +1,66 @@
|
|
|
1
1
|
import type { IAdapterDiagnostic } from '@moldea.ai/core/adapter';
|
|
2
2
|
import type { IGoogleGenAiDiagnosticInput } from '../contracts/index.js';
|
|
3
3
|
export declare const GOOGLE_GENAI_ADAPTER_DIAGNOSTICS: Readonly<{
|
|
4
|
-
readonly GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly
|
|
17
|
-
|
|
4
|
+
readonly GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED: {
|
|
5
|
+
readonly message: "The detected Google Gen AI function-declaration collection exceeds the supported SDK declaration limit.";
|
|
6
|
+
readonly severity: "error";
|
|
7
|
+
};
|
|
8
|
+
readonly GOOGLE_GENAI_INSTRUCTION_LOADER_NOT_WIRED: {
|
|
9
|
+
readonly message: "The declared instruction loader is not wired to the detected Google Gen AI generate-content configuration.";
|
|
10
|
+
readonly severity: "error";
|
|
11
|
+
};
|
|
12
|
+
readonly GOOGLE_GENAI_INSTRUCTION_LOADER_SYMBOL_NOT_FOUND: {
|
|
13
|
+
readonly message: "The declared instruction-loader symbol was not found.";
|
|
14
|
+
readonly severity: "error";
|
|
15
|
+
};
|
|
16
|
+
readonly GOOGLE_GENAI_PACKAGE_MANIFEST_INVALID: {
|
|
17
|
+
readonly message: "The owning package manifest is invalid for Google Gen AI dependency detection.";
|
|
18
|
+
readonly severity: "error";
|
|
19
|
+
};
|
|
20
|
+
readonly GOOGLE_GENAI_RUNTIME_AGENT_SYMBOL_NOT_FOUND: {
|
|
21
|
+
readonly message: "The declared runtime-agent symbol was not found.";
|
|
22
|
+
readonly severity: "error";
|
|
23
|
+
};
|
|
24
|
+
readonly GOOGLE_GENAI_SDK_VERSION_UNSUPPORTED: {
|
|
25
|
+
readonly message: "The observed Google Gen AI SDK dependency range is disjoint from the supported range.";
|
|
26
|
+
readonly severity: "error";
|
|
27
|
+
};
|
|
28
|
+
readonly GOOGLE_GENAI_SOURCE_SYNTAX_INVALID: {
|
|
29
|
+
readonly message: "The referenced Google Gen AI source file contains invalid TypeScript syntax.";
|
|
30
|
+
readonly severity: "error";
|
|
31
|
+
};
|
|
32
|
+
readonly GOOGLE_GENAI_SOURCE_TEXT_INVALID: {
|
|
33
|
+
readonly message: "The referenced Google Gen AI source file is not valid normalized text.";
|
|
34
|
+
readonly severity: "error";
|
|
35
|
+
};
|
|
36
|
+
readonly GOOGLE_GENAI_TOOL_INPUT_SCHEMA_NOT_WIRED: {
|
|
37
|
+
readonly message: "The declared tool input schema is not wired to the detected function declaration's parameters JSON schema.";
|
|
38
|
+
readonly severity: "error";
|
|
39
|
+
};
|
|
40
|
+
readonly GOOGLE_GENAI_TOOL_INPUT_SCHEMA_SYMBOL_NOT_FOUND: {
|
|
41
|
+
readonly message: "The declared tool input-schema symbol was not found.";
|
|
42
|
+
readonly severity: "error";
|
|
43
|
+
};
|
|
44
|
+
readonly GOOGLE_GENAI_TOOL_NAME_INVALID: {
|
|
45
|
+
readonly message: "The detected Google Gen AI function name violates the supported SDK declaration limit.";
|
|
46
|
+
readonly severity: "error";
|
|
47
|
+
};
|
|
48
|
+
readonly GOOGLE_GENAI_TOOL_NAME_MISMATCH: {
|
|
49
|
+
readonly message: "The declared tool name does not match the detected Google Gen AI function name.";
|
|
50
|
+
readonly severity: "error";
|
|
51
|
+
};
|
|
52
|
+
readonly GOOGLE_GENAI_TOOL_REGISTRATION_NOT_WIRED: {
|
|
53
|
+
readonly message: "The declared tool registration is not wired to the detected Google Gen AI function-declaration collection.";
|
|
54
|
+
readonly severity: "error";
|
|
55
|
+
};
|
|
56
|
+
readonly GOOGLE_GENAI_TOOL_REGISTRATION_SYMBOL_NOT_FOUND: {
|
|
57
|
+
readonly message: "The declared tool-registration symbol was not found.";
|
|
58
|
+
readonly severity: "error";
|
|
59
|
+
};
|
|
60
|
+
readonly GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED: {
|
|
61
|
+
readonly message: "The declared runtime relationship could not be verified.";
|
|
62
|
+
readonly severity: "warning";
|
|
63
|
+
};
|
|
18
64
|
}>;
|
|
19
65
|
/**
|
|
20
66
|
* Creates one frozen, safely namespaced Google Gen AI adapter diagnostic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAEV,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,gCAAgC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAEV,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwE3C,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,OAAO,2BAA2B,KACjC,kBA4BF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
1
2
|
import { posix } from "node:path";
|
|
2
3
|
import { intersects, subset, validRange } from "semver";
|
|
3
|
-
import ts from "typescript";
|
|
4
4
|
import { parseRepositoryPath } from "@moldea.ai/repository";
|
|
5
5
|
import { readRuntimeAdapterFile } from "@moldea.ai/core/adapter";
|
|
6
6
|
//#region src/constants/index.ts
|
|
7
7
|
var GOOGLE_GENAI_ADAPTER_ID = "google-genai";
|
|
8
|
-
var GOOGLE_GENAI_GENERATE_CONTENT_RUNTIME_NAME = "models.generateContent";
|
|
9
8
|
var GOOGLE_GENAI_SDK_PACKAGE_NAME = "@google/genai";
|
|
10
9
|
var GOOGLE_GENAI_SDK_SUPPORTED_RANGE = ">=2.17.1";
|
|
11
10
|
var GOOGLE_GENAI_SUPPORTED_REPOSITORY_FORMAT_VERSIONS = Object.freeze([1]);
|
|
@@ -60,204 +59,6 @@ var createInspectionSession = (options) => {
|
|
|
60
59
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
61
60
|
});
|
|
62
61
|
};
|
|
63
|
-
var decoder = new TextDecoder("utf-8", {
|
|
64
|
-
fatal: true,
|
|
65
|
-
ignoreBOM: true
|
|
66
|
-
});
|
|
67
|
-
var findLineIndex = (lineStarts, offset) => {
|
|
68
|
-
let lower = 0;
|
|
69
|
-
let upper = lineStarts.length - 1;
|
|
70
|
-
while (lower < upper) {
|
|
71
|
-
const middle = Math.ceil((lower + upper) / 2);
|
|
72
|
-
if ((lineStarts[middle] ?? 0) <= offset) lower = middle;
|
|
73
|
-
else upper = middle - 1;
|
|
74
|
-
}
|
|
75
|
-
return lower;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Creates a TypeScript UTF-16-offset to Unicode-scalar source locator.
|
|
79
|
-
* @param value The normalized valid Unicode-scalar text.
|
|
80
|
-
* @returns The scalar-aware source locator.
|
|
81
|
-
*/
|
|
82
|
-
var createSourceLocator = (value) => {
|
|
83
|
-
const scalarOffsets = new Uint32Array(value.length + 1);
|
|
84
|
-
const lineStarts = [0];
|
|
85
|
-
let scalarOffset = 0;
|
|
86
|
-
for (let codeUnitOffset = 0; codeUnitOffset < value.length;) {
|
|
87
|
-
const codePoint = value.codePointAt(codeUnitOffset);
|
|
88
|
-
const width = codePoint !== void 0 && codePoint > 65535 ? 2 : 1;
|
|
89
|
-
scalarOffsets[codeUnitOffset] = scalarOffset;
|
|
90
|
-
for (let interiorOffset = 1; interiorOffset < width; interiorOffset += 1) scalarOffsets[codeUnitOffset + interiorOffset] = scalarOffset;
|
|
91
|
-
codeUnitOffset += width;
|
|
92
|
-
scalarOffset += 1;
|
|
93
|
-
scalarOffsets[codeUnitOffset] = scalarOffset;
|
|
94
|
-
if (codePoint === 10) lineStarts.push(codeUnitOffset);
|
|
95
|
-
}
|
|
96
|
-
const locatePosition = (candidateOffset) => {
|
|
97
|
-
const codeUnitOffset = Math.max(0, Math.min(value.length, candidateOffset));
|
|
98
|
-
const lineIndex = findLineIndex(lineStarts, codeUnitOffset);
|
|
99
|
-
const lineStart = lineStarts[lineIndex] ?? 0;
|
|
100
|
-
const positionScalarOffset = scalarOffsets[codeUnitOffset] ?? 0;
|
|
101
|
-
return {
|
|
102
|
-
column: positionScalarOffset - (scalarOffsets[lineStart] ?? 0) + 1,
|
|
103
|
-
line: lineIndex + 1,
|
|
104
|
-
offset: positionScalarOffset
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
return Object.freeze({ locateRange: (startOffset, endOffset) => ({
|
|
108
|
-
end: locatePosition(endOffset),
|
|
109
|
-
start: locatePosition(startOffset)
|
|
110
|
-
}) });
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Decodes and normalizes source bytes through the runtime-adapter text contract.
|
|
114
|
-
* @param bytes The exact reader-owned source bytes.
|
|
115
|
-
* @returns The normalized text and locator or an invalid-text result.
|
|
116
|
-
*/
|
|
117
|
-
var normalizeText = (bytes) => {
|
|
118
|
-
let decoded;
|
|
119
|
-
try {
|
|
120
|
-
decoded = decoder.decode(bytes);
|
|
121
|
-
} catch {
|
|
122
|
-
return Object.freeze({ valid: false });
|
|
123
|
-
}
|
|
124
|
-
const value = (decoded.startsWith("") ? decoded.slice(1) : decoded).replace(/\r\n?/gu, "\n");
|
|
125
|
-
if (value.includes("\0")) return Object.freeze({ valid: false });
|
|
126
|
-
return Object.freeze({
|
|
127
|
-
locator: createSourceLocator(value),
|
|
128
|
-
valid: true,
|
|
129
|
-
value
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
var PACKAGE_DEPENDENCY_FIELDS = Object.freeze([
|
|
133
|
-
"dependencies",
|
|
134
|
-
"optionalDependencies",
|
|
135
|
-
"peerDependencies",
|
|
136
|
-
"devDependencies"
|
|
137
|
-
]);
|
|
138
|
-
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
139
|
-
/**
|
|
140
|
-
* Creates nearest-to-root package-manifest candidates for one source path.
|
|
141
|
-
* @param sourcePath The normalized source path.
|
|
142
|
-
* @returns Deterministically ordered manifest paths.
|
|
143
|
-
*/
|
|
144
|
-
var createPackageManifestCandidatePaths = (sourcePath) => {
|
|
145
|
-
const candidates = [];
|
|
146
|
-
let directory = posix.dirname(sourcePath);
|
|
147
|
-
while (true) {
|
|
148
|
-
candidates.push(posix.join(directory, "package.json"));
|
|
149
|
-
if (directory === "/") break;
|
|
150
|
-
directory = posix.dirname(directory);
|
|
151
|
-
}
|
|
152
|
-
return Object.freeze(candidates);
|
|
153
|
-
};
|
|
154
|
-
var extractPackageDeclarations = (manifest, packageName) => {
|
|
155
|
-
const declarations = [];
|
|
156
|
-
for (const field of PACKAGE_DEPENDENCY_FIELDS) {
|
|
157
|
-
const dependencies = manifest[field];
|
|
158
|
-
if (dependencies === void 0) continue;
|
|
159
|
-
if (!isRecord(dependencies)) return null;
|
|
160
|
-
const declaration = dependencies[packageName];
|
|
161
|
-
if (declaration === void 0) continue;
|
|
162
|
-
if (typeof declaration !== "string" || declaration.trim().length === 0) return null;
|
|
163
|
-
declarations.push(Object.freeze({
|
|
164
|
-
declaredRange: declaration,
|
|
165
|
-
dependencyKind: field
|
|
166
|
-
}));
|
|
167
|
-
}
|
|
168
|
-
return declarations;
|
|
169
|
-
};
|
|
170
|
-
var classifyPackageDeclarations = (declarations, supportedRange) => {
|
|
171
|
-
const classifications = declarations.map(({ declaredRange }) => {
|
|
172
|
-
const normalizedRange = validRange(declaredRange, {
|
|
173
|
-
loose: false,
|
|
174
|
-
includePrerelease: false
|
|
175
|
-
});
|
|
176
|
-
if (normalizedRange === null) return "ambiguous";
|
|
177
|
-
if (subset(normalizedRange, supportedRange, {
|
|
178
|
-
loose: false,
|
|
179
|
-
includePrerelease: false
|
|
180
|
-
})) return "supported";
|
|
181
|
-
if (!intersects(normalizedRange, supportedRange, {
|
|
182
|
-
loose: false,
|
|
183
|
-
includePrerelease: false
|
|
184
|
-
})) return "unsupported";
|
|
185
|
-
return "ambiguous";
|
|
186
|
-
});
|
|
187
|
-
if (classifications.every((classification) => classification === "supported")) return "supported";
|
|
188
|
-
if (classifications.every((classification) => classification === "unsupported")) return "unsupported";
|
|
189
|
-
return "ambiguous";
|
|
190
|
-
};
|
|
191
|
-
var readOwningManifest = async (options) => {
|
|
192
|
-
const { reader, signal, sourcePath } = options;
|
|
193
|
-
for (const manifestPath of createPackageManifestCandidatePaths(sourcePath)) {
|
|
194
|
-
signal?.throwIfAborted();
|
|
195
|
-
const entry = await reader.getEntry(manifestPath);
|
|
196
|
-
signal?.throwIfAborted();
|
|
197
|
-
if (entry === null) continue;
|
|
198
|
-
if (entry.type !== "file") return Object.freeze({
|
|
199
|
-
kind: "invalid",
|
|
200
|
-
path: manifestPath
|
|
201
|
-
});
|
|
202
|
-
const bytes = await reader.readFile(manifestPath);
|
|
203
|
-
signal?.throwIfAborted();
|
|
204
|
-
const text = normalizeText(bytes);
|
|
205
|
-
signal?.throwIfAborted();
|
|
206
|
-
if (!text.valid) return Object.freeze({
|
|
207
|
-
kind: "invalid",
|
|
208
|
-
path: manifestPath
|
|
209
|
-
});
|
|
210
|
-
let parsed;
|
|
211
|
-
try {
|
|
212
|
-
parsed = JSON.parse(text.value);
|
|
213
|
-
} catch {
|
|
214
|
-
return Object.freeze({
|
|
215
|
-
kind: "invalid",
|
|
216
|
-
path: manifestPath
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
signal?.throwIfAborted();
|
|
220
|
-
return isRecord(parsed) ? Object.freeze({
|
|
221
|
-
kind: "present",
|
|
222
|
-
manifest: parsed,
|
|
223
|
-
path: manifestPath
|
|
224
|
-
}) : Object.freeze({
|
|
225
|
-
kind: "invalid",
|
|
226
|
-
path: manifestPath
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
return Object.freeze({ kind: "absent" });
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Discovers the nearest package declaration without repository enumeration.
|
|
233
|
-
* @param options The package target, repository callbacks, path, range, and signal.
|
|
234
|
-
* @returns The first observed declaration, invalid manifest, or absence result.
|
|
235
|
-
* @throws If repository reading or the active inspection is aborted.
|
|
236
|
-
*/
|
|
237
|
-
var discoverPackage = async (options) => {
|
|
238
|
-
const { includeManifestPackageName, packageName, reader, signal, sourcePath, supportedRange } = options;
|
|
239
|
-
const owningManifest = await readOwningManifest({
|
|
240
|
-
reader,
|
|
241
|
-
...signal === void 0 ? {} : { signal },
|
|
242
|
-
sourcePath
|
|
243
|
-
});
|
|
244
|
-
if (owningManifest.kind !== "present") return owningManifest;
|
|
245
|
-
const declarations = extractPackageDeclarations(owningManifest.manifest, packageName);
|
|
246
|
-
if (declarations === null) return Object.freeze({
|
|
247
|
-
kind: "invalid",
|
|
248
|
-
path: owningManifest.path
|
|
249
|
-
});
|
|
250
|
-
if (declarations.length === 0) return Object.freeze({ kind: "absent" });
|
|
251
|
-
return Object.freeze({
|
|
252
|
-
kind: "observed",
|
|
253
|
-
observation: Object.freeze({
|
|
254
|
-
compatibility: classifyPackageDeclarations(declarations, supportedRange),
|
|
255
|
-
declarations: Object.freeze(declarations),
|
|
256
|
-
...includeManifestPackageName === true ? { manifestPackageName: typeof owningManifest.manifest["name"] === "string" ? owningManifest.manifest["name"] : null } : {},
|
|
257
|
-
path: owningManifest.path
|
|
258
|
-
})
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
62
|
/**
|
|
262
63
|
* Removes the transparent expression wrappers supported by runtime adapters.
|
|
263
64
|
* @param expression The expression to normalize.
|
|
@@ -349,7 +150,7 @@ var indexImports = (sourceFile, config) => {
|
|
|
349
150
|
const importedName = element.propertyName?.text ?? element.name.text;
|
|
350
151
|
if (!element.isTypeOnly && supportedNamedImports.has(importedName)) constructorNames.add(element.name.text);
|
|
351
152
|
}
|
|
352
|
-
if (!moduleSpecifier.startsWith(".") || importClause?.namedBindings === void 0 || !ts.isNamedImports(importClause.namedBindings)) continue;
|
|
153
|
+
if (!moduleSpecifier.startsWith(".") && !config.namedHelperModuleSpecifiers?.includes(moduleSpecifier) || importClause?.namedBindings === void 0 || !ts.isNamedImports(importClause.namedBindings)) continue;
|
|
353
154
|
for (const element of importClause.namedBindings.elements) {
|
|
354
155
|
if (element.isTypeOnly) continue;
|
|
355
156
|
namedImports.set(element.name.text, Object.freeze({
|
|
@@ -587,7 +388,7 @@ var classifyKnownClientResourceAccess = (expression, analysis, config) => {
|
|
|
587
388
|
};
|
|
588
389
|
var classifyCreateAccess = (expression, analysis, config) => {
|
|
589
390
|
const methodAccess = getAccessSegment(expression);
|
|
590
|
-
if (methodAccess === null || methodAccess.name !== null && methodAccess.name
|
|
391
|
+
if (methodAccess === null || methodAccess.name !== null && !config.methodNames.includes(methodAccess.name)) return null;
|
|
591
392
|
const resourceAccess = getAccessSegment(methodAccess.target);
|
|
592
393
|
if (resourceAccess === null || resourceAccess.name !== null && resourceAccess.name !== config.resourceName) return null;
|
|
593
394
|
const knownAccess = classifyKnownClientResourceAccess(methodAccess.target, analysis, config);
|
|
@@ -724,7 +525,19 @@ var analyzeClientRequests = (analysis, body, config, signal) => {
|
|
|
724
525
|
if (classification === "ambiguous") hasAmbiguousCandidate = true;
|
|
725
526
|
else if (classification === "recognized") {
|
|
726
527
|
const request = unwrapExpression(node.arguments[0]);
|
|
727
|
-
|
|
528
|
+
const methodName = getAccessSegment(node.expression)?.name;
|
|
529
|
+
if (methodName === null || methodName === void 0) {
|
|
530
|
+
hasAmbiguousCandidate = true;
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const relationships = analyzeObjectRelationships(request, config.relationshipNames);
|
|
534
|
+
requests.push(Object.freeze({
|
|
535
|
+
call: node,
|
|
536
|
+
methodName,
|
|
537
|
+
object: relationships.object,
|
|
538
|
+
options: node.arguments[1] ?? null,
|
|
539
|
+
relationships: relationships.relationships
|
|
540
|
+
}));
|
|
728
541
|
}
|
|
729
542
|
}
|
|
730
543
|
if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
|
|
@@ -771,8 +584,19 @@ var isDirectToolRequestPropertyUse = (identifier, analysis, config) => {
|
|
|
771
584
|
const property = expression.parent;
|
|
772
585
|
if (!(ts.isShorthandPropertyAssignment(property) && property.name.text === config.toolRelationshipName || ts.isPropertyAssignment(property) && (ts.isIdentifier(property.name) && property.name.text === config.toolRelationshipName || ts.isStringLiteral(property.name) && property.name.text === config.toolRelationshipName) && skipTransparentParents$2(property.initializer) === expression) || !ts.isObjectLiteralExpression(property.parent)) return false;
|
|
773
586
|
const request = skipTransparentParents$2(property.parent);
|
|
774
|
-
|
|
775
|
-
|
|
587
|
+
let call = request.parent;
|
|
588
|
+
let argumentIndex = 0;
|
|
589
|
+
let requestArgument = request;
|
|
590
|
+
if (ts.isPropertyAssignment(call) && getDirectPropertyName(call.name) === "body") {
|
|
591
|
+
const options = skipTransparentParents$2(call.parent);
|
|
592
|
+
if (ts.isObjectLiteralExpression(options)) {
|
|
593
|
+
call = options.parent;
|
|
594
|
+
argumentIndex = 1;
|
|
595
|
+
requestArgument = options;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const callArgument = ts.isCallExpression(call) ? call.arguments[argumentIndex] : void 0;
|
|
599
|
+
if (!ts.isCallExpression(call) || !config.acceptedArgumentCounts.includes(call.arguments.length) || callArgument === void 0 || skipTransparentParents$2(callArgument) !== requestArgument) return false;
|
|
776
600
|
return classifyCreateAccess(call.expression, analysis, config) === "direct";
|
|
777
601
|
};
|
|
778
602
|
var isArrayMemberAssignmentTarget = (member) => {
|
|
@@ -827,56 +651,6 @@ var indexSafeModuleArrayNames = (analysis, config) => {
|
|
|
827
651
|
visit(analysis.sourceFile);
|
|
828
652
|
return new Set([...analysis.moduleArrays.keys()].filter((name) => !unsafeNames.has(name)));
|
|
829
653
|
};
|
|
830
|
-
/**
|
|
831
|
-
* Classifies direct calls to one explicit instruction-loader binding.
|
|
832
|
-
* @param analysis The runtime source containing request relationships.
|
|
833
|
-
* @param relationships The provider request properties to inspect.
|
|
834
|
-
* @param hasAmbiguousCandidate Whether request discovery found an unresolved provider call.
|
|
835
|
-
* @param reference The declared instruction-loader reference.
|
|
836
|
-
* @returns The provider-neutral relationship classification.
|
|
837
|
-
*/
|
|
838
|
-
var classifyDirectCallRelationship = (analysis, relationships, hasAmbiguousCandidate, reference) => {
|
|
839
|
-
let absentExpression = null;
|
|
840
|
-
let hasAmbiguousRelationship = hasAmbiguousCandidate;
|
|
841
|
-
for (const relationship of relationships) {
|
|
842
|
-
if (relationship.kind === "unresolved") {
|
|
843
|
-
hasAmbiguousRelationship = true;
|
|
844
|
-
continue;
|
|
845
|
-
}
|
|
846
|
-
if (relationship.kind === "absent") continue;
|
|
847
|
-
const expression = relationship.expression;
|
|
848
|
-
const call = getDirectCall(expression);
|
|
849
|
-
if (call !== null) {
|
|
850
|
-
const callee = unwrapExpression(call.expression);
|
|
851
|
-
if (ts.isIdentifier(callee) && isBoundIdentifier(callee, analysis, reference)) return { kind: "present" };
|
|
852
|
-
if (ts.isIdentifier(callee)) {
|
|
853
|
-
absentExpression ??= expression;
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
if (isStaticLiteralValue(expression)) absentExpression ??= expression;
|
|
858
|
-
else hasAmbiguousRelationship = true;
|
|
859
|
-
}
|
|
860
|
-
return hasAmbiguousRelationship ? { kind: "ambiguous" } : {
|
|
861
|
-
expression: absentExpression,
|
|
862
|
-
kind: "absent"
|
|
863
|
-
};
|
|
864
|
-
};
|
|
865
|
-
/**
|
|
866
|
-
* Classifies one registration schema expression against an explicit schema binding.
|
|
867
|
-
* @param analysis The registration source containing the schema expression.
|
|
868
|
-
* @param expression The registration schema expression.
|
|
869
|
-
* @param reference The declared schema reference.
|
|
870
|
-
* @returns The provider-neutral relationship classification.
|
|
871
|
-
*/
|
|
872
|
-
var classifySchemaRelationship = (analysis, expression, reference) => {
|
|
873
|
-
const candidate = unwrapExpression(expression);
|
|
874
|
-
if (ts.isIdentifier(candidate) && isBoundIdentifier(candidate, analysis, reference)) return { kind: "present" };
|
|
875
|
-
return isNullLiteral(candidate) || ts.isObjectLiteralExpression(candidate) && isStaticLiteralValue(candidate) ? {
|
|
876
|
-
expression: candidate,
|
|
877
|
-
kind: "absent"
|
|
878
|
-
} : { kind: "ambiguous" };
|
|
879
|
-
};
|
|
880
654
|
var READONLY_ARRAY_METHODS = /* @__PURE__ */ new Set([
|
|
881
655
|
"at",
|
|
882
656
|
"concat",
|
|
@@ -976,6 +750,75 @@ function getSafeModuleConstLiteral(expression, analysis, allowedReferences, kind
|
|
|
976
750
|
expression: initializer
|
|
977
751
|
});
|
|
978
752
|
}
|
|
753
|
+
var decoder = new TextDecoder("utf-8", {
|
|
754
|
+
fatal: true,
|
|
755
|
+
ignoreBOM: true
|
|
756
|
+
});
|
|
757
|
+
var findLineIndex = (lineStarts, offset) => {
|
|
758
|
+
let lower = 0;
|
|
759
|
+
let upper = lineStarts.length - 1;
|
|
760
|
+
while (lower < upper) {
|
|
761
|
+
const middle = Math.ceil((lower + upper) / 2);
|
|
762
|
+
if ((lineStarts[middle] ?? 0) <= offset) lower = middle;
|
|
763
|
+
else upper = middle - 1;
|
|
764
|
+
}
|
|
765
|
+
return lower;
|
|
766
|
+
};
|
|
767
|
+
/**
|
|
768
|
+
* Creates a TypeScript UTF-16-offset to Unicode-scalar source locator.
|
|
769
|
+
* @param value The normalized valid Unicode-scalar text.
|
|
770
|
+
* @returns The scalar-aware source locator.
|
|
771
|
+
*/
|
|
772
|
+
var createSourceLocator = (value) => {
|
|
773
|
+
const scalarOffsets = new Uint32Array(value.length + 1);
|
|
774
|
+
const lineStarts = [0];
|
|
775
|
+
let scalarOffset = 0;
|
|
776
|
+
for (let codeUnitOffset = 0; codeUnitOffset < value.length;) {
|
|
777
|
+
const codePoint = value.codePointAt(codeUnitOffset);
|
|
778
|
+
const width = codePoint !== void 0 && codePoint > 65535 ? 2 : 1;
|
|
779
|
+
scalarOffsets[codeUnitOffset] = scalarOffset;
|
|
780
|
+
for (let interiorOffset = 1; interiorOffset < width; interiorOffset += 1) scalarOffsets[codeUnitOffset + interiorOffset] = scalarOffset;
|
|
781
|
+
codeUnitOffset += width;
|
|
782
|
+
scalarOffset += 1;
|
|
783
|
+
scalarOffsets[codeUnitOffset] = scalarOffset;
|
|
784
|
+
if (codePoint === 10) lineStarts.push(codeUnitOffset);
|
|
785
|
+
}
|
|
786
|
+
const locatePosition = (candidateOffset) => {
|
|
787
|
+
const codeUnitOffset = Math.max(0, Math.min(value.length, candidateOffset));
|
|
788
|
+
const lineIndex = findLineIndex(lineStarts, codeUnitOffset);
|
|
789
|
+
const lineStart = lineStarts[lineIndex] ?? 0;
|
|
790
|
+
const positionScalarOffset = scalarOffsets[codeUnitOffset] ?? 0;
|
|
791
|
+
return {
|
|
792
|
+
column: positionScalarOffset - (scalarOffsets[lineStart] ?? 0) + 1,
|
|
793
|
+
line: lineIndex + 1,
|
|
794
|
+
offset: positionScalarOffset
|
|
795
|
+
};
|
|
796
|
+
};
|
|
797
|
+
return Object.freeze({ locateRange: (startOffset, endOffset) => ({
|
|
798
|
+
end: locatePosition(endOffset),
|
|
799
|
+
start: locatePosition(startOffset)
|
|
800
|
+
}) });
|
|
801
|
+
};
|
|
802
|
+
/**
|
|
803
|
+
* Decodes and normalizes source bytes through the runtime-adapter text contract.
|
|
804
|
+
* @param bytes The exact reader-owned source bytes.
|
|
805
|
+
* @returns The normalized text and locator or an invalid-text result.
|
|
806
|
+
*/
|
|
807
|
+
var normalizeText = (bytes) => {
|
|
808
|
+
let decoded;
|
|
809
|
+
try {
|
|
810
|
+
decoded = decoder.decode(bytes);
|
|
811
|
+
} catch {
|
|
812
|
+
return Object.freeze({ valid: false });
|
|
813
|
+
}
|
|
814
|
+
const value = (decoded.startsWith("") ? decoded.slice(1) : decoded).replace(/\r\n?/gu, "\n");
|
|
815
|
+
if (value.includes("\0")) return Object.freeze({ valid: false });
|
|
816
|
+
return Object.freeze({
|
|
817
|
+
locator: createSourceLocator(value),
|
|
818
|
+
valid: true,
|
|
819
|
+
value
|
|
820
|
+
});
|
|
821
|
+
};
|
|
979
822
|
var TYPESCRIPT_DECLARATION_EXTENSIONS = [
|
|
980
823
|
".d.ts",
|
|
981
824
|
".d.tsx",
|
|
@@ -1153,6 +996,185 @@ var getConstExport = (analysis, symbol) => {
|
|
|
1153
996
|
kind: "present-unsupported"
|
|
1154
997
|
});
|
|
1155
998
|
};
|
|
999
|
+
var PACKAGE_DEPENDENCY_FIELDS = Object.freeze([
|
|
1000
|
+
"dependencies",
|
|
1001
|
+
"optionalDependencies",
|
|
1002
|
+
"peerDependencies",
|
|
1003
|
+
"devDependencies"
|
|
1004
|
+
]);
|
|
1005
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1006
|
+
/**
|
|
1007
|
+
* Creates nearest-to-root package-manifest candidates for one source path.
|
|
1008
|
+
* @param sourcePath The normalized source path.
|
|
1009
|
+
* @returns Deterministically ordered manifest paths.
|
|
1010
|
+
*/
|
|
1011
|
+
var createPackageManifestCandidatePaths = (sourcePath) => {
|
|
1012
|
+
const candidates = [];
|
|
1013
|
+
let directory = posix.dirname(sourcePath);
|
|
1014
|
+
while (true) {
|
|
1015
|
+
candidates.push(posix.join(directory, "package.json"));
|
|
1016
|
+
if (directory === "/") break;
|
|
1017
|
+
directory = posix.dirname(directory);
|
|
1018
|
+
}
|
|
1019
|
+
return Object.freeze(candidates);
|
|
1020
|
+
};
|
|
1021
|
+
var extractPackageDeclarations = (manifest, packageName) => {
|
|
1022
|
+
const declarations = [];
|
|
1023
|
+
for (const field of PACKAGE_DEPENDENCY_FIELDS) {
|
|
1024
|
+
const dependencies = manifest[field];
|
|
1025
|
+
if (dependencies === void 0) continue;
|
|
1026
|
+
if (!isRecord(dependencies)) return null;
|
|
1027
|
+
const declaration = dependencies[packageName];
|
|
1028
|
+
if (declaration === void 0) continue;
|
|
1029
|
+
if (typeof declaration !== "string" || declaration.trim().length === 0) return null;
|
|
1030
|
+
declarations.push(Object.freeze({
|
|
1031
|
+
declaredRange: declaration,
|
|
1032
|
+
dependencyKind: field
|
|
1033
|
+
}));
|
|
1034
|
+
}
|
|
1035
|
+
return declarations;
|
|
1036
|
+
};
|
|
1037
|
+
var classifyPackageDeclarations = (declarations, supportedRange) => {
|
|
1038
|
+
const classifications = declarations.map(({ declaredRange }) => {
|
|
1039
|
+
const normalizedRange = validRange(declaredRange, {
|
|
1040
|
+
loose: false,
|
|
1041
|
+
includePrerelease: false
|
|
1042
|
+
});
|
|
1043
|
+
if (normalizedRange === null) return "ambiguous";
|
|
1044
|
+
if (subset(normalizedRange, supportedRange, {
|
|
1045
|
+
loose: false,
|
|
1046
|
+
includePrerelease: false
|
|
1047
|
+
})) return "supported";
|
|
1048
|
+
if (!intersects(normalizedRange, supportedRange, {
|
|
1049
|
+
loose: false,
|
|
1050
|
+
includePrerelease: false
|
|
1051
|
+
})) return "unsupported";
|
|
1052
|
+
return "ambiguous";
|
|
1053
|
+
});
|
|
1054
|
+
if (classifications.every((classification) => classification === "supported")) return "supported";
|
|
1055
|
+
if (classifications.every((classification) => classification === "unsupported")) return "unsupported";
|
|
1056
|
+
return "ambiguous";
|
|
1057
|
+
};
|
|
1058
|
+
var readOwningManifest = async (options) => {
|
|
1059
|
+
const { reader, signal, sourcePath } = options;
|
|
1060
|
+
for (const manifestPath of createPackageManifestCandidatePaths(sourcePath)) {
|
|
1061
|
+
signal?.throwIfAborted();
|
|
1062
|
+
const entry = await reader.getEntry(manifestPath);
|
|
1063
|
+
signal?.throwIfAborted();
|
|
1064
|
+
if (entry === null) continue;
|
|
1065
|
+
if (entry.type !== "file") return Object.freeze({
|
|
1066
|
+
kind: "invalid",
|
|
1067
|
+
path: manifestPath
|
|
1068
|
+
});
|
|
1069
|
+
const bytes = await reader.readFile(manifestPath);
|
|
1070
|
+
signal?.throwIfAborted();
|
|
1071
|
+
const text = normalizeText(bytes);
|
|
1072
|
+
signal?.throwIfAborted();
|
|
1073
|
+
if (!text.valid) return Object.freeze({
|
|
1074
|
+
kind: "invalid",
|
|
1075
|
+
path: manifestPath
|
|
1076
|
+
});
|
|
1077
|
+
let parsed;
|
|
1078
|
+
try {
|
|
1079
|
+
parsed = JSON.parse(text.value);
|
|
1080
|
+
} catch {
|
|
1081
|
+
return Object.freeze({
|
|
1082
|
+
kind: "invalid",
|
|
1083
|
+
path: manifestPath
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
signal?.throwIfAborted();
|
|
1087
|
+
return isRecord(parsed) ? Object.freeze({
|
|
1088
|
+
kind: "present",
|
|
1089
|
+
manifest: parsed,
|
|
1090
|
+
path: manifestPath
|
|
1091
|
+
}) : Object.freeze({
|
|
1092
|
+
kind: "invalid",
|
|
1093
|
+
path: manifestPath
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
return Object.freeze({ kind: "absent" });
|
|
1097
|
+
};
|
|
1098
|
+
/**
|
|
1099
|
+
* Discovers the nearest package declaration without repository enumeration.
|
|
1100
|
+
* @param options The package target, repository callbacks, path, range, and signal.
|
|
1101
|
+
* @returns The first observed declaration, invalid manifest, or absence result.
|
|
1102
|
+
* @throws If repository reading or the active inspection is aborted.
|
|
1103
|
+
*/
|
|
1104
|
+
var discoverPackage = async (options) => {
|
|
1105
|
+
const { includeManifestPackageName, packageName, reader, signal, sourcePath, supportedRange } = options;
|
|
1106
|
+
const owningManifest = await readOwningManifest({
|
|
1107
|
+
reader,
|
|
1108
|
+
...signal === void 0 ? {} : { signal },
|
|
1109
|
+
sourcePath
|
|
1110
|
+
});
|
|
1111
|
+
if (owningManifest.kind !== "present") return owningManifest;
|
|
1112
|
+
const declarations = extractPackageDeclarations(owningManifest.manifest, packageName);
|
|
1113
|
+
if (declarations === null) return Object.freeze({
|
|
1114
|
+
kind: "invalid",
|
|
1115
|
+
path: owningManifest.path
|
|
1116
|
+
});
|
|
1117
|
+
if (declarations.length === 0) return Object.freeze({ kind: "absent" });
|
|
1118
|
+
return Object.freeze({
|
|
1119
|
+
kind: "observed",
|
|
1120
|
+
observation: Object.freeze({
|
|
1121
|
+
compatibility: classifyPackageDeclarations(declarations, supportedRange),
|
|
1122
|
+
declarations: Object.freeze(declarations),
|
|
1123
|
+
...includeManifestPackageName === true ? { manifestPackageName: typeof owningManifest.manifest["name"] === "string" ? owningManifest.manifest["name"] : null } : {},
|
|
1124
|
+
path: owningManifest.path
|
|
1125
|
+
})
|
|
1126
|
+
});
|
|
1127
|
+
};
|
|
1128
|
+
/**
|
|
1129
|
+
* Classifies direct calls to one explicit instruction-loader binding.
|
|
1130
|
+
* @param analysis The runtime source containing request relationships.
|
|
1131
|
+
* @param relationships The provider request properties to inspect.
|
|
1132
|
+
* @param hasAmbiguousCandidate Whether request discovery found an unresolved provider call.
|
|
1133
|
+
* @param reference The declared instruction-loader reference.
|
|
1134
|
+
* @returns The provider-neutral relationship classification.
|
|
1135
|
+
*/
|
|
1136
|
+
var classifyDirectCallRelationship = (analysis, relationships, hasAmbiguousCandidate, reference) => {
|
|
1137
|
+
let absentExpression = null;
|
|
1138
|
+
let hasAmbiguousRelationship = hasAmbiguousCandidate;
|
|
1139
|
+
for (const relationship of relationships) {
|
|
1140
|
+
if (relationship.kind === "unresolved") {
|
|
1141
|
+
hasAmbiguousRelationship = true;
|
|
1142
|
+
continue;
|
|
1143
|
+
}
|
|
1144
|
+
if (relationship.kind === "absent") continue;
|
|
1145
|
+
const expression = relationship.expression;
|
|
1146
|
+
const call = getDirectCall(expression);
|
|
1147
|
+
if (call !== null) {
|
|
1148
|
+
const callee = unwrapExpression(call.expression);
|
|
1149
|
+
if (ts.isIdentifier(callee) && isBoundIdentifier(callee, analysis, reference)) return { kind: "present" };
|
|
1150
|
+
if (ts.isIdentifier(callee)) {
|
|
1151
|
+
absentExpression ??= expression;
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
if (isStaticLiteralValue(expression)) absentExpression ??= expression;
|
|
1156
|
+
else hasAmbiguousRelationship = true;
|
|
1157
|
+
}
|
|
1158
|
+
return hasAmbiguousRelationship ? { kind: "ambiguous" } : {
|
|
1159
|
+
expression: absentExpression,
|
|
1160
|
+
kind: "absent"
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
/**
|
|
1164
|
+
* Classifies one registration schema expression against an explicit schema binding.
|
|
1165
|
+
* @param analysis The registration source containing the schema expression.
|
|
1166
|
+
* @param expression The registration schema expression.
|
|
1167
|
+
* @param reference The declared schema reference.
|
|
1168
|
+
* @returns The provider-neutral relationship classification.
|
|
1169
|
+
*/
|
|
1170
|
+
var classifySchemaRelationship = (analysis, expression, reference) => {
|
|
1171
|
+
const candidate = unwrapExpression(expression);
|
|
1172
|
+
if (ts.isIdentifier(candidate) && isBoundIdentifier(candidate, analysis, reference)) return { kind: "present" };
|
|
1173
|
+
return isNullLiteral(candidate) || ts.isObjectLiteralExpression(candidate) && isStaticLiteralValue(candidate) ? {
|
|
1174
|
+
expression: candidate,
|
|
1175
|
+
kind: "absent"
|
|
1176
|
+
} : { kind: "ambiguous" };
|
|
1177
|
+
};
|
|
1156
1178
|
//#endregion
|
|
1157
1179
|
//#region src/source-analysis/source-analysis.ts
|
|
1158
1180
|
var GOOGLE_GENAI_SOURCE_CONFIG = Object.freeze({
|
|
@@ -1163,7 +1185,7 @@ var GOOGLE_GENAI_SOURCE_CONFIG = Object.freeze({
|
|
|
1163
1185
|
}),
|
|
1164
1186
|
requestConfig: Object.freeze({
|
|
1165
1187
|
acceptedArgumentCounts: Object.freeze([1]),
|
|
1166
|
-
|
|
1188
|
+
methodNames: Object.freeze(["generateContent", "generateContentStream"]),
|
|
1167
1189
|
relationshipNames: Object.freeze(["config"]),
|
|
1168
1190
|
resourceName: "models"
|
|
1169
1191
|
})
|
|
@@ -1222,11 +1244,12 @@ var analyzeConfig = (config) => {
|
|
|
1222
1244
|
*/
|
|
1223
1245
|
var analyzeGoogleGenAiGenerateContent = (analysis, body, signal) => {
|
|
1224
1246
|
const result = analyzeClientRequests(analysis, body, GOOGLE_GENAI_SOURCE_CONFIG.requestConfig, signal);
|
|
1225
|
-
const requests = result.requests.map(({ object, relationships }) => {
|
|
1247
|
+
const requests = result.requests.map(({ methodName, object, relationships }) => {
|
|
1226
1248
|
const config = relationships.get("config") ?? ABSENT_RELATIONSHIP;
|
|
1227
1249
|
const nested = analyzeConfig(config);
|
|
1228
1250
|
return Object.freeze({
|
|
1229
1251
|
config,
|
|
1252
|
+
methodName,
|
|
1230
1253
|
object,
|
|
1231
1254
|
systemInstruction: nested.systemInstruction,
|
|
1232
1255
|
tools: nested.tools
|
|
@@ -1540,33 +1563,98 @@ var analyzeGoogleGenAiToolCollections = async (analysis, relationships, registra
|
|
|
1540
1563
|
//#endregion
|
|
1541
1564
|
//#region src/diagnostics/index.ts
|
|
1542
1565
|
var GOOGLE_GENAI_ADAPTER_DIAGNOSTICS = Object.freeze({
|
|
1543
|
-
GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED:
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1566
|
+
GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED: {
|
|
1567
|
+
message: "The detected Google Gen AI function-declaration collection exceeds the supported SDK declaration limit.",
|
|
1568
|
+
severity: "error"
|
|
1569
|
+
},
|
|
1570
|
+
GOOGLE_GENAI_INSTRUCTION_LOADER_NOT_WIRED: {
|
|
1571
|
+
message: "The declared instruction loader is not wired to the detected Google Gen AI generate-content configuration.",
|
|
1572
|
+
severity: "error"
|
|
1573
|
+
},
|
|
1574
|
+
GOOGLE_GENAI_INSTRUCTION_LOADER_SYMBOL_NOT_FOUND: {
|
|
1575
|
+
message: "The declared instruction-loader symbol was not found.",
|
|
1576
|
+
severity: "error"
|
|
1577
|
+
},
|
|
1578
|
+
GOOGLE_GENAI_PACKAGE_MANIFEST_INVALID: {
|
|
1579
|
+
message: "The owning package manifest is invalid for Google Gen AI dependency detection.",
|
|
1580
|
+
severity: "error"
|
|
1581
|
+
},
|
|
1582
|
+
GOOGLE_GENAI_RUNTIME_AGENT_SYMBOL_NOT_FOUND: {
|
|
1583
|
+
message: "The declared runtime-agent symbol was not found.",
|
|
1584
|
+
severity: "error"
|
|
1585
|
+
},
|
|
1586
|
+
GOOGLE_GENAI_SDK_VERSION_UNSUPPORTED: {
|
|
1587
|
+
message: "The observed Google Gen AI SDK dependency range is disjoint from the supported range.",
|
|
1588
|
+
severity: "error"
|
|
1589
|
+
},
|
|
1590
|
+
GOOGLE_GENAI_SOURCE_SYNTAX_INVALID: {
|
|
1591
|
+
message: "The referenced Google Gen AI source file contains invalid TypeScript syntax.",
|
|
1592
|
+
severity: "error"
|
|
1593
|
+
},
|
|
1594
|
+
GOOGLE_GENAI_SOURCE_TEXT_INVALID: {
|
|
1595
|
+
message: "The referenced Google Gen AI source file is not valid normalized text.",
|
|
1596
|
+
severity: "error"
|
|
1597
|
+
},
|
|
1598
|
+
GOOGLE_GENAI_TOOL_INPUT_SCHEMA_NOT_WIRED: {
|
|
1599
|
+
message: "The declared tool input schema is not wired to the detected function declaration's parameters JSON schema.",
|
|
1600
|
+
severity: "error"
|
|
1601
|
+
},
|
|
1602
|
+
GOOGLE_GENAI_TOOL_INPUT_SCHEMA_SYMBOL_NOT_FOUND: {
|
|
1603
|
+
message: "The declared tool input-schema symbol was not found.",
|
|
1604
|
+
severity: "error"
|
|
1605
|
+
},
|
|
1606
|
+
GOOGLE_GENAI_TOOL_NAME_INVALID: {
|
|
1607
|
+
message: "The detected Google Gen AI function name violates the supported SDK declaration limit.",
|
|
1608
|
+
severity: "error"
|
|
1609
|
+
},
|
|
1610
|
+
GOOGLE_GENAI_TOOL_NAME_MISMATCH: {
|
|
1611
|
+
message: "The declared tool name does not match the detected Google Gen AI function name.",
|
|
1612
|
+
severity: "error"
|
|
1613
|
+
},
|
|
1614
|
+
GOOGLE_GENAI_TOOL_REGISTRATION_NOT_WIRED: {
|
|
1615
|
+
message: "The declared tool registration is not wired to the detected Google Gen AI function-declaration collection.",
|
|
1616
|
+
severity: "error"
|
|
1617
|
+
},
|
|
1618
|
+
GOOGLE_GENAI_TOOL_REGISTRATION_SYMBOL_NOT_FOUND: {
|
|
1619
|
+
message: "The declared tool-registration symbol was not found.",
|
|
1620
|
+
severity: "error"
|
|
1621
|
+
},
|
|
1622
|
+
GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED: {
|
|
1623
|
+
message: "The declared runtime relationship could not be verified.",
|
|
1624
|
+
severity: "warning"
|
|
1625
|
+
}
|
|
1557
1626
|
});
|
|
1558
1627
|
/**
|
|
1559
1628
|
* Creates one frozen, safely namespaced Google Gen AI adapter diagnostic.
|
|
1560
1629
|
* @param input The complete code, location, entity, and safe scalar details.
|
|
1561
1630
|
* @returns The immutable adapter diagnostic.
|
|
1562
1631
|
*/
|
|
1563
|
-
var createGoogleGenAiDiagnostic = (input) =>
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1632
|
+
var createGoogleGenAiDiagnostic = (input) => {
|
|
1633
|
+
if (input.code === "GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED") {
|
|
1634
|
+
const definition = GOOGLE_GENAI_ADAPTER_DIAGNOSTICS[input.code];
|
|
1635
|
+
const details = Object.freeze({ ...input.details });
|
|
1636
|
+
const entity = input.entity === null ? null : Object.freeze({ ...input.entity });
|
|
1637
|
+
return Object.freeze({
|
|
1638
|
+
...input,
|
|
1639
|
+
details,
|
|
1640
|
+
entity,
|
|
1641
|
+
message: definition.message,
|
|
1642
|
+
severity: definition.severity,
|
|
1643
|
+
source: GOOGLE_GENAI_ADAPTER_ID
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
const definition = GOOGLE_GENAI_ADAPTER_DIAGNOSTICS[input.code];
|
|
1647
|
+
const details = Object.freeze({ ...input.details });
|
|
1648
|
+
const entity = input.entity === null ? null : Object.freeze({ ...input.entity });
|
|
1649
|
+
return Object.freeze({
|
|
1650
|
+
...input,
|
|
1651
|
+
details,
|
|
1652
|
+
entity,
|
|
1653
|
+
message: definition.message,
|
|
1654
|
+
severity: definition.severity,
|
|
1655
|
+
source: GOOGLE_GENAI_ADAPTER_ID
|
|
1656
|
+
});
|
|
1657
|
+
};
|
|
1570
1658
|
//#endregion
|
|
1571
1659
|
//#region src/inspection/common.ts
|
|
1572
1660
|
/** Compares exact strings without locale-dependent behavior. */
|
|
@@ -1908,7 +1996,7 @@ var inspectAgent = async (session, agent, evidence, diagnostics) => {
|
|
|
1908
1996
|
if (runtimeExport.kind === "present-unsupported" || runtimeExport.body === void 0) return;
|
|
1909
1997
|
const generateContent = analyzeGoogleGenAiGenerateContent(analysis, runtimeExport.body, session.signal);
|
|
1910
1998
|
if (generateContent.requests.length === 0) return;
|
|
1911
|
-
evidence.push(createGoogleGenAiEvidence({
|
|
1999
|
+
for (const methodName of [...new Set(generateContent.requests.map((request) => request.methodName))].sort()) evidence.push(createGoogleGenAiEvidence({
|
|
1912
2000
|
agentId: agent.id,
|
|
1913
2001
|
capabilityId: null,
|
|
1914
2002
|
capabilityKind: null,
|
|
@@ -1918,7 +2006,7 @@ var inspectAgent = async (session, agent, evidence, diagnostics) => {
|
|
|
1918
2006
|
path: runtimeAgent.path,
|
|
1919
2007
|
symbol: runtimeAgent.symbol
|
|
1920
2008
|
}],
|
|
1921
|
-
runtimeName:
|
|
2009
|
+
runtimeName: `models.${methodName}`,
|
|
1922
2010
|
source: GOOGLE_GENAI_ADAPTER_ID
|
|
1923
2011
|
}));
|
|
1924
2012
|
await inspectGoogleGenAiRelationships(session, agent, analysis, generateContent, evidence, diagnostics);
|
|
@@ -20,7 +20,7 @@ export declare const createGoogleGenAiEvidence: (evidence: IRuntimeAdapterEviden
|
|
|
20
20
|
* @param range The optional scalar source range.
|
|
21
21
|
* @param capabilityId The optional owning tool capability.
|
|
22
22
|
*/
|
|
23
|
-
export declare const addGoogleGenAiDiagnostic: (diagnostics: IAdapterDiagnostic[], code: IGoogleGenAiAdapterDiagnosticCode, path: IRepositoryPath | null, agentId: string, range?: ISourceRange | null, capabilityId?: string) => void;
|
|
23
|
+
export declare const addGoogleGenAiDiagnostic: (diagnostics: IAdapterDiagnostic[], code: Exclude<IGoogleGenAiAdapterDiagnosticCode, "GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED">, path: IRepositoryPath | null, agentId: string, range?: ISourceRange | null, capabilityId?: string) => void;
|
|
24
24
|
/**
|
|
25
25
|
* Loads and validates one supported bound TypeScript source.
|
|
26
26
|
* @param session The operation-local inspection session.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/inspection/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EACV,iCAAiC,EACjC,6BAA6B,EAC7B,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAG/B,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAC9B,CAAC;AAQ3C;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,uBAAuB,KAChC,uBAKC,CAAC;AASL;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,kBAAkB,EAAE,EACjC,MAAM,iCAAiC,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/inspection/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EACV,iCAAiC,EACjC,6BAA6B,EAC7B,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAG/B,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAC9B,CAAC;AAQ3C;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,uBAAuB,KAChC,uBAKC,CAAC;AASL;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,kBAAkB,EAAE,EACjC,MAAM,OAAO,CAAC,iCAAiC,EAAE,8CAA8C,CAAC,EAChG,MAAM,eAAe,GAAG,IAAI,EAC5B,SAAS,MAAM,EACf,QAAO,YAAY,GAAG,IAAW,EACjC,eAAe,MAAM,KACpB,IAWF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,GAC3C,SAAS,6BAA6B,EACtC,WAAW,oBAAoB,EAC/B,aAAa,kBAAkB,EAAE,EACjC,SAAS,MAAM,EACf,eAAe,MAAM,KACpB,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAgC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspection.d.ts","sourceRoot":"","sources":["../../src/inspection/inspection.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"inspection.d.ts","sourceRoot":"","sources":["../../src/inspection/inspection.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAqHjC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,sBAAsB,KAC9B,OAAO,CAAC,qBAAqB,CAiB/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-content.d.ts","sourceRoot":"","sources":["../../src/source-analysis/generate-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B,OAAO,KAAK,EACV,mCAAmC,EAGnC,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AA2C/B;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,0BAA0B,EACpC,MAAM,EAAE,CAAC,WAAW,EACpB,SAAS,WAAW,KACnB,
|
|
1
|
+
{"version":3,"file":"generate-content.d.ts","sourceRoot":"","sources":["../../src/source-analysis/generate-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B,OAAO,KAAK,EACV,mCAAmC,EAGnC,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AA2C/B;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,0BAA0B,EACpC,MAAM,EAAE,CAAC,WAAW,EACpB,SAAS,WAAW,KACnB,mCA0BF,CAAC"}
|
|
@@ -8,7 +8,7 @@ export declare const GOOGLE_GENAI_SOURCE_CONFIG: Readonly<{
|
|
|
8
8
|
}>;
|
|
9
9
|
requestConfig: Readonly<{
|
|
10
10
|
acceptedArgumentCounts: readonly number[];
|
|
11
|
-
|
|
11
|
+
methodNames: readonly string[];
|
|
12
12
|
relationshipNames: readonly string[];
|
|
13
13
|
resourceName: "models";
|
|
14
14
|
}>;
|
|
@@ -26,5 +26,8 @@ The target may emit `runtime-package`, `language`, `runtime-pattern`, `instructi
|
|
|
26
26
|
| `GOOGLE_GENAI_TOOL_NAME_INVALID` | The detected Google Gen AI function name violates the supported SDK declaration limit. |
|
|
27
27
|
| `GOOGLE_GENAI_TOOL_INPUT_SCHEMA_NOT_WIRED` | The declared tool input schema is not wired to the detected function declaration's parameters JSON schema. |
|
|
28
28
|
| `GOOGLE_GENAI_FUNCTION_DECLARATION_LIMIT_EXCEEDED` | The detected Google Gen AI function-declaration collection exceeds the supported SDK declaration limit. |
|
|
29
|
+
| `GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED` | The declared runtime relationship could not be verified. |
|
|
29
30
|
|
|
30
31
|
Invalid text or syntax suppresses derived symbol and relationship diagnostics for that source. Missing symbols suppress their derived wiring diagnostics. Unsupported or dynamic requests, configurations, collections, containers, registrations, or schema values suppress negative relationship diagnostics when they could contain the declared relationship. Independently proved package, name, and collection-limit diagnostics remain observable.
|
|
32
|
+
|
|
33
|
+
`GOOGLE_GENAI_RUNTIME_RELATIONSHIP_UNVERIFIED` has severity `warning` only when the adapter identifies a declared relationship affected by a recognized but unresolved source candidate. Its safe details identify the relationship and reason; known version-behavior boundaries additionally carry normalized dependency context. Missing local evidence or a newer eligible dependency version alone does not produce this warning. Confirmed diagnostic codes remain errors.
|
package/docs/index.md
CHANGED
|
@@ -16,7 +16,7 @@ import { createCore } from '@moldea.ai/core';
|
|
|
16
16
|
const core = createCore({ adapters: [googleGenAiAdapter] });
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
The package is available with one technical target covering TypeScript ESM using direct `models.generateContent` calls with npm `@google/genai >=2.17.1`, Repository Format version `1`, and Core `^
|
|
19
|
+
The package is available with one technical target covering TypeScript ESM using direct `models.generateContent` and `generateContentStream` calls with npm `@google/genai >=2.17.1`, Repository Format version `1`, and Core `^5.0.0`.
|
|
20
20
|
|
|
21
21
|
The adapter never imports or calls the Google Gen AI SDK, executes no repository code, requires no credentials, and makes no network request. Its only public export is the immutable `googleGenAiAdapter` singleton.
|
|
22
22
|
|
package/docs/limitations.md
CHANGED
|
@@ -10,7 +10,7 @@ The current target does not claim support for:
|
|
|
10
10
|
|
|
11
11
|
- JavaScript, Python, CommonJS, or non-ESM source
|
|
12
12
|
- legacy `@google/generative-ai`
|
|
13
|
-
-
|
|
13
|
+
- chats, live sessions, or the Interactions API; direct `generateContentStream` source calls do not validate streaming lifecycle behavior
|
|
14
14
|
- callable tools, MCP conversion, automatic function execution, or provider/server tool relationships
|
|
15
15
|
- configuration or clients returned by factories
|
|
16
16
|
- arbitrary compiler resolution, path aliases, package exports, directory indexes, or re-export graphs
|
package/docs/verified-target.md
CHANGED
|
@@ -14,7 +14,7 @@ The canonical Runtime Compatibility Matrix defines technical target `typescript-
|
|
|
14
14
|
- named runtime value imports of `GoogleGenAI` from `@google/genai`
|
|
15
15
|
- the nearest owning manifest declaring `@google/genai >=2.17.1`
|
|
16
16
|
- a module-local `const` client constructed directly with `new GoogleGenAI(...)`
|
|
17
|
-
- a directly exported runtime-agent function containing exact non-computed `client.models.generateContent({ ... })` calls
|
|
17
|
+
- a directly exported runtime-agent function containing exact non-computed `client.models.generateContent({ ... })` or `generateContentStream({ ... })` calls
|
|
18
18
|
- one exact object-literal request argument
|
|
19
19
|
|
|
20
20
|
`config` is resolved only as a direct object literal. `systemInstruction` and `tools` are classified independently inside it. Positive evidence is existential across supported calls; a negative wiring diagnostic requires every candidate to prove the relationship absent with no dynamic or unsupported candidate that could contain it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moldea.ai/adapter-google-genai",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Deterministic runtime evidence and diagnostics for direct Google Gen AI SDK integrations.",
|
|
5
5
|
"homepage": "https://github.com/moldea-ai/packages/tree/main/projects/adapter-google-genai#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": ">=22.11.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@moldea.ai/core": "^
|
|
37
|
+
"@moldea.ai/core": "^5.0.0",
|
|
38
38
|
"@moldea.ai/repository": "^2.0.0",
|
|
39
39
|
"semver": "7.8.5",
|
|
40
40
|
"typescript": "6.0.3"
|