@flink-app/flink 0.14.3 → 2.0.0-alpha.48
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 +66 -0
- package/cli/build.ts +8 -1
- package/cli/run.ts +8 -1
- package/dist/cli/build.js +8 -1
- package/dist/cli/run.js +8 -1
- package/dist/src/FlinkApp.d.ts +33 -0
- package/dist/src/FlinkApp.js +279 -35
- package/dist/src/FlinkContext.d.ts +21 -0
- package/dist/src/FlinkHttpHandler.d.ts +152 -9
- package/dist/src/FlinkHttpHandler.js +37 -1
- package/dist/src/TypeScriptCompiler.d.ts +42 -0
- package/dist/src/TypeScriptCompiler.js +346 -4
- package/dist/src/TypeScriptUtils.js +4 -0
- package/dist/src/ai/AgentRunner.d.ts +39 -0
- package/dist/src/ai/AgentRunner.js +625 -0
- package/dist/src/ai/FlinkAgent.d.ts +446 -0
- package/dist/src/ai/FlinkAgent.js +633 -0
- package/dist/src/ai/FlinkTool.d.ts +37 -0
- package/dist/src/ai/FlinkTool.js +2 -0
- package/dist/src/ai/LLMAdapter.d.ts +119 -0
- package/dist/src/ai/LLMAdapter.js +2 -0
- package/dist/src/ai/SubAgentExecutor.d.ts +36 -0
- package/dist/src/ai/SubAgentExecutor.js +220 -0
- package/dist/src/ai/ToolExecutor.d.ts +35 -0
- package/dist/src/ai/ToolExecutor.js +237 -0
- package/dist/src/ai/index.d.ts +5 -0
- package/dist/src/ai/index.js +21 -0
- package/dist/src/handlers/StreamWriterFactory.d.ts +20 -0
- package/dist/src/handlers/StreamWriterFactory.js +83 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/utils.d.ts +30 -0
- package/dist/src/utils.js +52 -0
- package/package.json +16 -2
- package/readme.md +425 -0
- package/spec/AgentDuplicateDetection.spec.ts +112 -0
- package/spec/AgentRunner.spec.ts +527 -0
- package/spec/ConversationHooks.spec.ts +290 -0
- package/spec/FlinkAgent.spec.ts +310 -0
- package/spec/FlinkApp.onError.spec.ts +1 -2
- package/spec/FlinkApp.query.spec.ts +107 -0
- package/spec/FlinkApp.validationMode.spec.ts +155 -0
- package/spec/StreamingIntegration.spec.ts +138 -0
- package/spec/SubAgentSupport.spec.ts +941 -0
- package/spec/ToolExecutor.spec.ts +360 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar.js +57 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar2.js +59 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema.js +53 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema2.js +53 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema3.js +53 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema2.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile2.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler.js +53 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler2.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchCar.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOnboardingSession.js +76 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOrderWithComplexTypes.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchProductWithIntersection.js +59 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchUserWithUnion.js +59 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PostCar.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogin.js +56 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogout.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PutCar.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/index.js +83 -0
- package/spec/mock-project/dist/spec/mock-project/src/repos/CarRepo.js +26 -0
- package/spec/mock-project/dist/spec/mock-project/src/schemas/Car.js +2 -0
- package/spec/mock-project/dist/spec/mock-project/src/schemas/DefaultExportSchema.js +2 -0
- package/spec/mock-project/dist/spec/mock-project/src/schemas/FileWithTwoSchemas.js +2 -0
- package/spec/mock-project/dist/src/FlinkApp.js +1012 -0
- package/spec/mock-project/dist/src/FlinkContext.js +2 -0
- package/spec/mock-project/dist/src/FlinkErrors.js +143 -0
- package/spec/mock-project/dist/src/FlinkHttpHandler.js +47 -0
- package/spec/mock-project/dist/src/FlinkJob.js +2 -0
- package/spec/mock-project/dist/src/FlinkLog.js +26 -0
- package/spec/mock-project/dist/src/FlinkPlugin.js +2 -0
- package/spec/mock-project/dist/src/FlinkRepo.js +224 -0
- package/spec/mock-project/dist/src/FlinkResponse.js +2 -0
- package/spec/mock-project/dist/src/ai/AgentExecutor.js +279 -0
- package/spec/mock-project/dist/src/ai/AgentRunner.js +625 -0
- package/spec/mock-project/dist/src/ai/FlinkAgent.js +633 -0
- package/spec/mock-project/dist/src/ai/FlinkTool.js +2 -0
- package/spec/mock-project/dist/src/ai/LLMAdapter.js +2 -0
- package/spec/mock-project/dist/src/ai/SubAgentExecutor.js +220 -0
- package/spec/mock-project/dist/src/ai/ToolExecutor.js +237 -0
- package/spec/mock-project/dist/src/auth/FlinkAuthPlugin.js +2 -0
- package/spec/mock-project/dist/src/auth/FlinkAuthUser.js +2 -0
- package/spec/mock-project/dist/src/handlers/StreamWriterFactory.js +83 -0
- package/spec/mock-project/dist/src/index.js +17 -69
- package/spec/mock-project/dist/src/mock-data-generator.js +9 -0
- package/spec/mock-project/dist/src/utils.js +290 -0
- package/spec/mock-project/tsconfig.json +6 -1
- package/spec/testHelpers.ts +49 -0
- package/spec/utils.caseConversion.spec.ts +80 -0
- package/spec/utils.spec.ts +13 -13
- package/src/FlinkApp.ts +275 -8
- package/src/FlinkContext.ts +22 -0
- package/src/FlinkHttpHandler.ts +164 -10
- package/src/TypeScriptCompiler.ts +398 -7
- package/src/TypeScriptUtils.ts +5 -0
- package/src/ai/AgentRunner.ts +549 -0
- package/src/ai/FlinkAgent.ts +770 -0
- package/src/ai/FlinkTool.ts +40 -0
- package/src/ai/LLMAdapter.ts +96 -0
- package/src/ai/SubAgentExecutor.ts +199 -0
- package/src/ai/ToolExecutor.ts +193 -0
- package/src/ai/index.ts +5 -0
- package/src/handlers/StreamWriterFactory.ts +84 -0
- package/src/index.ts +4 -0
- package/src/utils.ts +52 -0
- package/tsconfig.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
# @flink-app/flink
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.48
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- AI features
|
|
8
|
+
|
|
9
|
+
## 1.0.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Align minor version, from now all packages in monorepo will have same version
|
|
14
|
+
- 5c2ff97: Add schema validation bypass options to RouteProps
|
|
15
|
+
|
|
16
|
+
Handlers can now control schema validation behavior via the new `validation` property in `RouteProps`:
|
|
17
|
+
|
|
18
|
+
- `ValidationMode.Validate` (default): Validate both request and response
|
|
19
|
+
- `ValidationMode.SkipValidation`: Skip both request and response validation
|
|
20
|
+
- `ValidationMode.ValidateRequest`: Validate only request, skip response validation
|
|
21
|
+
- `ValidationMode.ValidateResponse`: Validate only response, skip request validation
|
|
22
|
+
|
|
23
|
+
This is useful for handlers that need custom validation logic or want to bypass validation for performance reasons. The feature is opt-in and defaults to existing behavior.
|
|
24
|
+
|
|
25
|
+
**Security Considerations:**
|
|
26
|
+
|
|
27
|
+
⚠️ Use validation bypass options carefully:
|
|
28
|
+
|
|
29
|
+
- `SkipValidation` and `ValidateRequest: false` allow unvalidated data to reach handlers, which can introduce security risks
|
|
30
|
+
- Only skip validation when you have implemented custom validation logic or the endpoint is internal/trusted
|
|
31
|
+
- Suitable use cases include: webhook handlers with custom signature verification, performance-critical internal endpoints, or handlers using alternative validation methods
|
|
32
|
+
- When skipping response validation, ensure your code returns consistent data shapes to avoid breaking API contracts
|
|
33
|
+
|
|
34
|
+
Example usage:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Skip validation for webhook with custom verification
|
|
38
|
+
export const Route: RouteProps = {
|
|
39
|
+
path: "/webhook",
|
|
40
|
+
validation: ValidationMode.SkipValidation,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Validate request but allow flexible response during development
|
|
44
|
+
export const Route: RouteProps = {
|
|
45
|
+
path: "/api/debug",
|
|
46
|
+
validation: ValidationMode.ValidateRequest,
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- ee21c29: Normalize query parameters to predictable string types
|
|
53
|
+
|
|
54
|
+
Query parameters are now automatically normalized to `string | string[]` types before reaching handlers:
|
|
55
|
+
|
|
56
|
+
- Single values: converted to strings (e.g., `?page=1` → `{ page: "1" }`)
|
|
57
|
+
- Repeated parameters: converted to string arrays (e.g., `?tag=a&tag=b` → `{ tag: ["a", "b"] }`)
|
|
58
|
+
- All types (numbers, booleans, etc.) from Express parser are converted to strings
|
|
59
|
+
|
|
60
|
+
**Breaking Change (Minor):**
|
|
61
|
+
|
|
62
|
+
- `Query` type changed from `{ [x: string]: string | string[] | undefined }` to `Record<string, string | string[]>`
|
|
63
|
+
- `Params` type changed from `Request["params"]` to explicit `Record<string, string>`
|
|
64
|
+
- Removed `undefined` from query/param types since normalization ensures values are never undefined
|
|
65
|
+
- Updated OAuth and OIDC plugin query type definitions to satisfy new Query constraint
|
|
66
|
+
|
|
67
|
+
This ensures predictable query and path parameter handling regardless of Express parser configuration. Handlers can reliably parse string values as needed using `Number()`, `parseInt()`, boolean comparisons, etc.
|
|
68
|
+
|
|
3
69
|
## 0.14.3
|
|
4
70
|
|
|
5
71
|
### Patch Changes
|
package/cli/build.ts
CHANGED
|
@@ -40,7 +40,14 @@ module.exports = async function run(args: string[]) {
|
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
await Promise.all([
|
|
43
|
+
await Promise.all([
|
|
44
|
+
compiler.parseRepos(),
|
|
45
|
+
compiler.parseHandlers(exclude.split(",")),
|
|
46
|
+
compiler.parseTools(),
|
|
47
|
+
compiler.parseAgents(),
|
|
48
|
+
compiler.parseJobs(),
|
|
49
|
+
compiler.generateStartScript(),
|
|
50
|
+
]);
|
|
44
51
|
|
|
45
52
|
console.log(`Compilation done, took ${Date.now() - startTime}ms`);
|
|
46
53
|
|
package/cli/run.ts
CHANGED
|
@@ -63,7 +63,14 @@ module.exports = async function run(args: string[]) {
|
|
|
63
63
|
process.exit(1);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
await Promise.all([
|
|
66
|
+
await Promise.all([
|
|
67
|
+
compiler.parseRepos(),
|
|
68
|
+
compiler.parseHandlers(),
|
|
69
|
+
compiler.parseTools(),
|
|
70
|
+
compiler.parseAgents(),
|
|
71
|
+
compiler.parseJobs(),
|
|
72
|
+
compiler.generateStartScript(entry)
|
|
73
|
+
]);
|
|
67
74
|
|
|
68
75
|
console.log(`Compilation done, took ${Date.now() - startTime}ms`);
|
|
69
76
|
|
package/dist/cli/build.js
CHANGED
|
@@ -65,7 +65,14 @@ module.exports = function run(args) {
|
|
|
65
65
|
if (!compiler.getPreEmitDiagnostics()) {
|
|
66
66
|
process.exit(1);
|
|
67
67
|
}
|
|
68
|
-
return [4 /*yield*/, Promise.all([
|
|
68
|
+
return [4 /*yield*/, Promise.all([
|
|
69
|
+
compiler.parseRepos(),
|
|
70
|
+
compiler.parseHandlers(exclude.split(",")),
|
|
71
|
+
compiler.parseTools(),
|
|
72
|
+
compiler.parseAgents(),
|
|
73
|
+
compiler.parseJobs(),
|
|
74
|
+
compiler.generateStartScript(),
|
|
75
|
+
])];
|
|
69
76
|
case 2:
|
|
70
77
|
_a.sent();
|
|
71
78
|
console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
|
package/dist/cli/run.js
CHANGED
|
@@ -83,7 +83,14 @@ module.exports = function run(args) {
|
|
|
83
83
|
if (!compiler.getPreEmitDiagnostics()) {
|
|
84
84
|
process.exit(1);
|
|
85
85
|
}
|
|
86
|
-
return [4 /*yield*/, Promise.all([
|
|
86
|
+
return [4 /*yield*/, Promise.all([
|
|
87
|
+
compiler.parseRepos(),
|
|
88
|
+
compiler.parseHandlers(),
|
|
89
|
+
compiler.parseTools(),
|
|
90
|
+
compiler.parseAgents(),
|
|
91
|
+
compiler.parseJobs(),
|
|
92
|
+
compiler.generateStartScript(entry)
|
|
93
|
+
])];
|
|
87
94
|
case 2:
|
|
88
95
|
_a.sent();
|
|
89
96
|
console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
|
package/dist/src/FlinkApp.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import express, { Express } from "express";
|
|
|
3
3
|
import { JSONSchema7 } from "json-schema";
|
|
4
4
|
import { Db, MongoClient } from "mongodb";
|
|
5
5
|
import { ToadScheduler } from "toad-scheduler";
|
|
6
|
+
import { FlinkAgentFile } from "./ai/FlinkAgent";
|
|
7
|
+
import { FlinkToolFile } from "./ai/FlinkTool";
|
|
8
|
+
import { LLMAdapter } from "./ai/LLMAdapter";
|
|
6
9
|
import { FlinkAuthPlugin } from "./auth/FlinkAuthPlugin";
|
|
7
10
|
import { FlinkContext } from "./FlinkContext";
|
|
8
11
|
import { FlinkError } from "./FlinkErrors";
|
|
@@ -39,6 +42,16 @@ export declare const autoRegisteredRepos: {
|
|
|
39
42
|
* are picked up by TypeScript compiler
|
|
40
43
|
*/
|
|
41
44
|
export declare const autoRegisteredJobs: FlinkJobFile[];
|
|
45
|
+
/**
|
|
46
|
+
* This will be populated at compile time when the apps tools
|
|
47
|
+
* are picked up by TypeScript compiler
|
|
48
|
+
*/
|
|
49
|
+
export declare const autoRegisteredTools: FlinkToolFile[];
|
|
50
|
+
/**
|
|
51
|
+
* This will be populated at compile time when the apps agents
|
|
52
|
+
* are picked up by TypeScript compiler
|
|
53
|
+
*/
|
|
54
|
+
export declare const autoRegisteredAgents: FlinkAgentFile[];
|
|
42
55
|
export interface FlinkOptions {
|
|
43
56
|
/**
|
|
44
57
|
* Name of application, will only show in logs and in HTTP header.
|
|
@@ -118,6 +131,16 @@ export interface FlinkOptions {
|
|
|
118
131
|
*/
|
|
119
132
|
enabled?: boolean;
|
|
120
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* AI configuration for agents and tools
|
|
136
|
+
* Register LLM adapters with custom IDs (e.g., "anthropic", "openai", "anthropic-eu", etc.)
|
|
137
|
+
* This allows multiple adapters of the same type with different configurations
|
|
138
|
+
*/
|
|
139
|
+
ai?: {
|
|
140
|
+
llms?: {
|
|
141
|
+
[id: string]: LLMAdapter;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
121
144
|
/**
|
|
122
145
|
* If true, the HTTP server will be disabled.
|
|
123
146
|
* Only useful when starting a Flink app for testing purposes.
|
|
@@ -226,6 +249,9 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
226
249
|
private expressServer;
|
|
227
250
|
private onError?;
|
|
228
251
|
private repos;
|
|
252
|
+
private llmAdapters;
|
|
253
|
+
private tools;
|
|
254
|
+
private agents;
|
|
229
255
|
/**
|
|
230
256
|
* Internal cache used to track registered handlers and potentially any overlapping routes
|
|
231
257
|
*/
|
|
@@ -253,11 +279,18 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
253
279
|
private registerAutoRegisterableHandlers;
|
|
254
280
|
private registerAutoRegisterableJobs;
|
|
255
281
|
addRepo(instanceName: string, repoInstance: FlinkRepo<C, any>): void;
|
|
282
|
+
private registerAutoRegisterableTools;
|
|
283
|
+
private registerAutoRegisterableAgents;
|
|
256
284
|
/**
|
|
257
285
|
* Constructs the app context. Will inject context in all components
|
|
258
286
|
* except for handlers which are handled in later stage.
|
|
259
287
|
*/
|
|
260
288
|
private buildContext;
|
|
289
|
+
/**
|
|
290
|
+
* Initialize agents after they've been registered and context is ready
|
|
291
|
+
* Must be called after registerAutoRegisterableAgents()
|
|
292
|
+
*/
|
|
293
|
+
private initializeAgents;
|
|
261
294
|
/**
|
|
262
295
|
* Connects to database.
|
|
263
296
|
*/
|