weifuwu 0.5.0 → 0.6.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 +118 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +11392 -4
- package/dist/postgres/types.d.ts +1 -1
- package/dist/queue/index.d.ts +2 -0
- package/dist/queue/types.d.ts +32 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/types.d.ts +16 -0
- package/dist/user/client.d.ts +2 -0
- package/dist/user/index.d.ts +2 -0
- package/dist/user/migrate.d.ts +6 -0
- package/dist/user/oauth2.d.ts +20 -0
- package/dist/user/types.d.ts +54 -0
- package/dist/workflow/engine.d.ts +1 -1
- package/dist/workflow/llm.d.ts +1 -1
- package/dist/workflow/route.d.ts +1 -1
- package/dist/workflow/types.d.ts +2 -2
- package/package.json +5 -2
package/dist/postgres/types.d.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { Context, Handler } from '../types.ts';
|
|
3
|
+
declare module '../types.ts' {
|
|
4
|
+
interface Context {
|
|
5
|
+
queue: Queue;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export interface QueueJob<T = unknown> {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
payload: T;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
runAt: number;
|
|
14
|
+
schedule?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface QueueOptions {
|
|
17
|
+
redis?: Redis;
|
|
18
|
+
url?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
pollInterval?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface Queue {
|
|
23
|
+
(req: Request, ctx: Context, next: Handler): Response | Promise<Response>;
|
|
24
|
+
add<T>(type: string, payload: T, opts?: {
|
|
25
|
+
delay?: number;
|
|
26
|
+
schedule?: string;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
process<T>(type: string, handler: (job: QueueJob<T>) => Promise<void>): void;
|
|
29
|
+
run(): Promise<void>;
|
|
30
|
+
stop(): void;
|
|
31
|
+
close(): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Redis, RedisOptions as IORedisOptions } from 'ioredis';
|
|
2
|
+
import type { Context, Handler } from '../types.ts';
|
|
3
|
+
declare module '../types.ts' {
|
|
4
|
+
interface Context {
|
|
5
|
+
redis: Redis;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export type { Redis };
|
|
9
|
+
export type RedisOptions = IORedisOptions & {
|
|
10
|
+
url?: string;
|
|
11
|
+
};
|
|
12
|
+
export interface RedisClient {
|
|
13
|
+
(req: Request, ctx: Context, next: Handler): Response | Promise<Response>;
|
|
14
|
+
redis: Redis;
|
|
15
|
+
close: () => Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Context } from '../types.ts';
|
|
2
|
+
import type { OAuth2Client } from './types.ts';
|
|
3
|
+
interface OAuth2Deps {
|
|
4
|
+
pg: any;
|
|
5
|
+
usersTable: string;
|
|
6
|
+
jwtSecret: string;
|
|
7
|
+
expiresIn: string | number;
|
|
8
|
+
}
|
|
9
|
+
export declare function createOAuth2Server(deps: OAuth2Deps): {
|
|
10
|
+
authorizeHandler: (req: Request, _ctx: Context) => Promise<Response>;
|
|
11
|
+
consentHandler: (req: Request) => Promise<Response>;
|
|
12
|
+
tokenHandler: (req: Request) => Promise<Response>;
|
|
13
|
+
registerClient: (data: {
|
|
14
|
+
name: string;
|
|
15
|
+
redirectUris: string[];
|
|
16
|
+
}) => Promise<OAuth2Client>;
|
|
17
|
+
getClient: (clientId: string) => Promise<OAuth2Client | null>;
|
|
18
|
+
revokeClient: (clientId: string) => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Middleware } from '../types.ts';
|
|
2
|
+
import type { Router } from '../router.ts';
|
|
3
|
+
export interface UserData {
|
|
4
|
+
id: number;
|
|
5
|
+
email: string;
|
|
6
|
+
name: string;
|
|
7
|
+
role: string;
|
|
8
|
+
created_at: Date;
|
|
9
|
+
updated_at: Date;
|
|
10
|
+
}
|
|
11
|
+
export interface AuthResult {
|
|
12
|
+
user: Omit<UserData, 'password'>;
|
|
13
|
+
token: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OAuth2Client {
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
clientId: string;
|
|
19
|
+
clientSecret: string;
|
|
20
|
+
redirectUris: string[];
|
|
21
|
+
scopes: string;
|
|
22
|
+
}
|
|
23
|
+
export interface OAuth2ServerOptions {
|
|
24
|
+
server: true;
|
|
25
|
+
}
|
|
26
|
+
export interface UserOptions {
|
|
27
|
+
pg: any;
|
|
28
|
+
jwtSecret: string;
|
|
29
|
+
table?: string;
|
|
30
|
+
expiresIn?: string | number;
|
|
31
|
+
oauth2?: OAuth2ServerOptions;
|
|
32
|
+
}
|
|
33
|
+
export interface UserModule {
|
|
34
|
+
router: () => Router;
|
|
35
|
+
middleware: () => Middleware;
|
|
36
|
+
migrate: () => Promise<void>;
|
|
37
|
+
register: (data: {
|
|
38
|
+
email: string;
|
|
39
|
+
password: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}) => Promise<AuthResult>;
|
|
42
|
+
login: (data: {
|
|
43
|
+
email: string;
|
|
44
|
+
password: string;
|
|
45
|
+
}) => Promise<AuthResult>;
|
|
46
|
+
verify: (token: string) => Promise<Omit<UserData, 'password'> | null>;
|
|
47
|
+
registerClient: (data: {
|
|
48
|
+
name: string;
|
|
49
|
+
redirectUris: string[];
|
|
50
|
+
}) => Promise<OAuth2Client>;
|
|
51
|
+
getClient: (clientId: string) => Promise<OAuth2Client | null>;
|
|
52
|
+
revokeClient: (clientId: string) => Promise<void>;
|
|
53
|
+
close: () => Promise<void>;
|
|
54
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Tool, WorkflowEngine, SSEManager } from './types.ts';
|
|
2
2
|
import { type LanguageModel } from 'ai';
|
|
3
3
|
export declare function createWorkflowEngine(options: {
|
|
4
|
-
tools: Record<string, Tool
|
|
4
|
+
tools: Record<string, Tool<any, any>>;
|
|
5
5
|
sseManager?: SSEManager;
|
|
6
6
|
model?: LanguageModel;
|
|
7
7
|
}): WorkflowEngine;
|
package/dist/workflow/llm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Tool, Workflow } from './types.ts';
|
|
2
|
-
export declare function generateWorkflow(goal: string, tools: Record<string, Tool
|
|
2
|
+
export declare function generateWorkflow(goal: string, tools: Record<string, Tool<any, any>>, generateFn: (prompt: {
|
|
3
3
|
system: string;
|
|
4
4
|
messages: {
|
|
5
5
|
role: string;
|
package/dist/workflow/route.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Router } from '../router.ts';
|
|
|
2
2
|
import type { Tool as WfTool } from './types.ts';
|
|
3
3
|
import type { generateText } from 'ai';
|
|
4
4
|
export interface WorkflowOptions {
|
|
5
|
-
tools: Record<string, WfTool
|
|
5
|
+
tools: Record<string, WfTool<any, any>>;
|
|
6
6
|
model?: Parameters<typeof generateText>[0]['model'];
|
|
7
7
|
stream?: boolean;
|
|
8
8
|
}
|
package/dist/workflow/types.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface WorkflowContext {
|
|
|
63
63
|
stepCount: number;
|
|
64
64
|
maxSteps: number;
|
|
65
65
|
input: Record<string, unknown>;
|
|
66
|
-
toolRegistry: Map<string, Tool
|
|
66
|
+
toolRegistry: Map<string, Tool<any, any>>;
|
|
67
67
|
sseManager?: SSEManager;
|
|
68
68
|
workflowId?: string;
|
|
69
69
|
onNodeEvent?: (event: SSEEvent) => void;
|
|
@@ -74,7 +74,7 @@ export interface SSEManager {
|
|
|
74
74
|
close: (workflowId: string) => void;
|
|
75
75
|
}
|
|
76
76
|
export interface EngineOptions {
|
|
77
|
-
tools: Record<string, Tool
|
|
77
|
+
tools: Record<string, Tool<any, any>>;
|
|
78
78
|
model?: unknown;
|
|
79
79
|
sseManager?: SSEManager;
|
|
80
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weifuwu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Web-standard HTTP framework for Node.js — (req, ctx) => Response",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"LICENSE"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "esbuild index.ts --bundle --format=esm --platform=node --outfile=dist/index.js --external:react --external:react-dom --external:esbuild --external:graphql --external:ws --external:zod --external:@graphql-tools/schema --external:ai --external:postgres",
|
|
17
|
+
"build": "esbuild index.ts --bundle --format=esm --platform=node --outfile=dist/index.js --external:react --external:react-dom --external:esbuild --external:graphql --external:ws --external:zod --external:@graphql-tools/schema --external:ai --external:postgres --external:jsonwebtoken",
|
|
18
18
|
"prepublishOnly": "npm run build && tsc --emitDeclarationOnly --outdir dist",
|
|
19
19
|
"test": "node --test 'test/**/*.test.ts'"
|
|
20
20
|
},
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"ai": "^6",
|
|
24
24
|
"esbuild": "^0.28.0",
|
|
25
25
|
"graphql": "^16",
|
|
26
|
+
"ioredis": "^5.11.0",
|
|
27
|
+
"jsonwebtoken": "^9.0.3",
|
|
26
28
|
"postgres": "^3.4.9",
|
|
27
29
|
"react": "^19",
|
|
28
30
|
"react-dom": "^19",
|
|
@@ -32,6 +34,7 @@
|
|
|
32
34
|
"type": "module",
|
|
33
35
|
"license": "MIT",
|
|
34
36
|
"devDependencies": {
|
|
37
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
35
38
|
"@types/react": "^19",
|
|
36
39
|
"@types/react-dom": "^19",
|
|
37
40
|
"@types/ws": "^8.18.1",
|