@flink-app/flink 2.0.0-alpha.69 → 2.0.0-alpha.71
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/CHANGELOG.md
CHANGED
|
@@ -1260,7 +1260,7 @@ var TypeScriptCompiler = /** @class */ (function () {
|
|
|
1260
1260
|
*/
|
|
1261
1261
|
TypeScriptCompiler.prototype.extractSchemasFromHandlerFast = function (filePath) {
|
|
1262
1262
|
return __awaiter(this, void 0, void 0, function () {
|
|
1263
|
-
var fileText, typeArgs, baseName, reqTypeName, resTypeName, paramsTypeName, queryTypeName, reqSchemaType, resSchemaType, baseName, baseName, paramsMetadata, queryMetadata, metadata, metadata;
|
|
1263
|
+
var fileText, typeArgs, baseName, reqTypeName, resTypeName, paramsTypeName, queryTypeName, reqSchemaType, resSchemaType, isSkipValidation, baseName, baseName, paramsMetadata, queryMetadata, metadata, metadata;
|
|
1264
1264
|
return __generator(this, function (_a) {
|
|
1265
1265
|
fileText = fs_1.default.readFileSync(filePath, "utf8");
|
|
1266
1266
|
typeArgs = schema_extraction_1.TypeScriptSourceParser.parseHandlerTypeArgs(fileText);
|
|
@@ -1280,16 +1280,17 @@ var TypeScriptCompiler = /** @class */ (function () {
|
|
|
1280
1280
|
queryTypeName = typeArgs.queryType;
|
|
1281
1281
|
reqSchemaType = undefined;
|
|
1282
1282
|
resSchemaType = undefined;
|
|
1283
|
+
isSkipValidation = /ValidationMode\.SkipValidation/.test(fileText);
|
|
1283
1284
|
if (reqTypeName && schema_extraction_1.TypeScriptSourceParser.shouldGenerateSchema(reqTypeName)) {
|
|
1284
1285
|
reqSchemaType = this.resolveTypeNameToSchemaId(fileText, reqTypeName, filePath);
|
|
1285
|
-
if (!reqSchemaType) {
|
|
1286
|
+
if (!reqSchemaType && !isSkipValidation) {
|
|
1286
1287
|
baseName = require("path").basename(filePath);
|
|
1287
1288
|
perfLog.warn("Handler ".concat(baseName, ": Could not resolve request type \"").concat(reqTypeName, "\" to schema $id. Make sure it's exported from src/schemas/"));
|
|
1288
1289
|
}
|
|
1289
1290
|
}
|
|
1290
1291
|
if (resTypeName && schema_extraction_1.TypeScriptSourceParser.shouldGenerateSchema(resTypeName)) {
|
|
1291
1292
|
resSchemaType = this.resolveTypeNameToSchemaId(fileText, resTypeName, filePath);
|
|
1292
|
-
if (!resSchemaType) {
|
|
1293
|
+
if (!resSchemaType && !isSkipValidation) {
|
|
1293
1294
|
baseName = require("path").basename(filePath);
|
|
1294
1295
|
perfLog.warn("Handler ".concat(baseName, ": Could not resolve response type \"").concat(resTypeName, "\" to schema $id. Make sure it's exported from src/schemas/"));
|
|
1295
1296
|
}
|
|
@@ -41,6 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.ToolExecutor = void 0;
|
|
43
43
|
var ajv_1 = __importDefault(require("ajv"));
|
|
44
|
+
var ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
44
45
|
var FlinkErrors_1 = require("../FlinkErrors");
|
|
45
46
|
var FlinkLogFactory_1 = require("../FlinkLogFactory");
|
|
46
47
|
var FlinkRequestContext_1 = require("../FlinkRequestContext");
|
|
@@ -53,6 +54,7 @@ var ToolExecutor = /** @class */ (function () {
|
|
|
53
54
|
this.autoSchemas = autoSchemas;
|
|
54
55
|
this.allSchemas = allSchemas;
|
|
55
56
|
this.ajv = new ajv_1.default({ allErrors: true });
|
|
57
|
+
(0, ajv_formats_1.default)(this.ajv);
|
|
56
58
|
// Pre-populate AJV with all schemas so $ref references resolve across schema boundaries
|
|
57
59
|
if (allSchemas) {
|
|
58
60
|
for (var _i = 0, _a = Object.values(allSchemas); _i < _a.length; _i++) {
|
package/package.json
CHANGED
|
@@ -1327,9 +1327,12 @@ export default {}; // Export an empty object to make it a module
|
|
|
1327
1327
|
let reqSchemaType: string | undefined = undefined;
|
|
1328
1328
|
let resSchemaType: string | undefined = undefined;
|
|
1329
1329
|
|
|
1330
|
+
// Check if handler skips validation — no need to warn about unresolved schema types
|
|
1331
|
+
const isSkipValidation = /ValidationMode\.SkipValidation/.test(fileText);
|
|
1332
|
+
|
|
1330
1333
|
if (reqTypeName && TypeScriptSourceParser.shouldGenerateSchema(reqTypeName)) {
|
|
1331
1334
|
reqSchemaType = this.resolveTypeNameToSchemaId(fileText, reqTypeName, filePath);
|
|
1332
|
-
if (!reqSchemaType) {
|
|
1335
|
+
if (!reqSchemaType && !isSkipValidation) {
|
|
1333
1336
|
const baseName = require("path").basename(filePath);
|
|
1334
1337
|
perfLog.warn(`Handler ${baseName}: Could not resolve request type "${reqTypeName}" to schema $id. Make sure it's exported from src/schemas/`);
|
|
1335
1338
|
}
|
|
@@ -1337,7 +1340,7 @@ export default {}; // Export an empty object to make it a module
|
|
|
1337
1340
|
|
|
1338
1341
|
if (resTypeName && TypeScriptSourceParser.shouldGenerateSchema(resTypeName)) {
|
|
1339
1342
|
resSchemaType = this.resolveTypeNameToSchemaId(fileText, resTypeName, filePath);
|
|
1340
|
-
if (!resSchemaType) {
|
|
1343
|
+
if (!resSchemaType && !isSkipValidation) {
|
|
1341
1344
|
const baseName = require("path").basename(filePath);
|
|
1342
1345
|
perfLog.warn(`Handler ${baseName}: Could not resolve response type "${resTypeName}" to schema $id. Make sure it's exported from src/schemas/`);
|
|
1343
1346
|
}
|
package/src/ai/ToolExecutor.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Ajv from "ajv";
|
|
2
|
+
import addFormats from "ajv-formats";
|
|
2
3
|
import { FlinkContext } from "../FlinkContext";
|
|
3
4
|
import { forbidden } from "../FlinkErrors";
|
|
4
5
|
import { FlinkLogFactory } from "../FlinkLogFactory";
|
|
@@ -9,7 +10,7 @@ import { FlinkToolSchema } from "./LLMAdapter";
|
|
|
9
10
|
const toolLog = FlinkLogFactory.createLogger("flink.ai.tool");
|
|
10
11
|
|
|
11
12
|
export class ToolExecutor<Ctx extends FlinkContext> {
|
|
12
|
-
private ajv
|
|
13
|
+
private ajv: Ajv;
|
|
13
14
|
private compiledInputValidator?: ReturnType<Ajv["compile"]>;
|
|
14
15
|
private compiledOutputValidator?: ReturnType<Ajv["compile"]>;
|
|
15
16
|
|
|
@@ -25,6 +26,9 @@ export class ToolExecutor<Ctx extends FlinkContext> {
|
|
|
25
26
|
},
|
|
26
27
|
private allSchemas?: Record<string, any>
|
|
27
28
|
) {
|
|
29
|
+
this.ajv = new Ajv({ allErrors: true });
|
|
30
|
+
addFormats(this.ajv);
|
|
31
|
+
|
|
28
32
|
// Pre-populate AJV with all schemas so $ref references resolve across schema boundaries
|
|
29
33
|
if (allSchemas) {
|
|
30
34
|
for (const schema of Object.values(allSchemas)) {
|