weifuwu 0.18.0 → 0.18.2
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 +232 -122
- package/cli.ts +7 -6
- package/dist/agent/types.d.ts +2 -2
- package/dist/ai.d.ts +1 -3
- package/dist/analytics.d.ts +1 -2
- package/dist/cli.js +7 -6
- package/dist/graphql.d.ts +1 -3
- package/dist/iii/types.d.ts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +766 -1244
- package/dist/logdb/types.d.ts +1 -2
- package/dist/messager/types.d.ts +2 -2
- package/dist/opencode/types.d.ts +1 -2
- package/dist/router.d.ts +1 -0
- package/dist/ssr/compile.d.ts +2 -0
- package/dist/ssr/error-boundary.d.ts +2 -0
- package/dist/ssr/index.d.ts +7 -0
- package/dist/ssr/index.js +936 -0
- package/dist/ssr/layout.d.ts +2 -0
- package/dist/ssr/live.d.ts +6 -0
- package/dist/ssr/not-found.d.ts +2 -0
- package/dist/ssr/ssr.d.ts +3 -0
- package/dist/ssr/stream.d.ts +14 -0
- package/dist/ssr/tailwind.d.ts +2 -0
- package/dist/tenant/types.d.ts +2 -2
- package/dist/types.d.ts +5 -0
- package/dist/user/types.d.ts +1 -2
- package/package.json +4 -3
package/cli.ts
CHANGED
|
@@ -94,14 +94,15 @@ async function cmdInit(name: string) {
|
|
|
94
94
|
].join('\n'))
|
|
95
95
|
|
|
96
96
|
await writeFile(join(targetDir, 'app.ts'), [
|
|
97
|
-
"import { serve, Router, loadEnv
|
|
97
|
+
"import { serve, Router, loadEnv } from 'weifuwu'",
|
|
98
|
+
"import { ssr, layout } from 'weifuwu/ssr'",
|
|
98
99
|
'',
|
|
99
100
|
"loadEnv()",
|
|
100
101
|
"const port = Number(process.env.PORT) || 3000",
|
|
101
102
|
'',
|
|
102
103
|
"const app = new Router()",
|
|
103
|
-
"
|
|
104
|
-
"app.
|
|
104
|
+
"app.use(layout('./ui/layout.tsx'))",
|
|
105
|
+
"app.get('/', ssr('./ui/page.tsx'))",
|
|
105
106
|
'',
|
|
106
107
|
"app.get('/api/ping', () => Response.json({ pong: true, time: new Date().toISOString() }))",
|
|
107
108
|
'',
|
|
@@ -113,11 +114,11 @@ async function cmdInit(name: string) {
|
|
|
113
114
|
'',
|
|
114
115
|
].join('\n'))
|
|
115
116
|
|
|
116
|
-
await mkdir(join(targetDir, 'ui'
|
|
117
|
+
await mkdir(join(targetDir, 'ui'), { recursive: true })
|
|
117
118
|
|
|
118
119
|
await writeFile(join(targetDir, 'ui', 'app.css'), '@import "tailwindcss";\n')
|
|
119
120
|
|
|
120
|
-
await writeFile(join(targetDir, 'ui', '
|
|
121
|
+
await writeFile(join(targetDir, 'ui', 'layout.tsx'), [
|
|
121
122
|
"import { ReactNode } from 'react'",
|
|
122
123
|
'',
|
|
123
124
|
'export default function RootLayout({ children }: { children: ReactNode }) {',
|
|
@@ -136,7 +137,7 @@ async function cmdInit(name: string) {
|
|
|
136
137
|
'',
|
|
137
138
|
].join('\n'))
|
|
138
139
|
|
|
139
|
-
await writeFile(join(targetDir, 'ui', '
|
|
140
|
+
await writeFile(join(targetDir, 'ui', 'page.tsx'), [
|
|
140
141
|
"import { useState } from 'react'",
|
|
141
142
|
"import { useWebsocket } from 'weifuwu/react'",
|
|
142
143
|
'',
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Router } from '../router.ts';
|
|
1
2
|
import type { LanguageModel, EmbeddingModel, Tool } from 'ai';
|
|
2
3
|
export interface AgentConfig {
|
|
3
4
|
id: number;
|
|
@@ -42,9 +43,8 @@ export interface AgentOptions {
|
|
|
42
43
|
embeddingDimension?: number;
|
|
43
44
|
tools?: Record<string, Tool>;
|
|
44
45
|
}
|
|
45
|
-
export interface AgentModule {
|
|
46
|
+
export interface AgentModule extends Router {
|
|
46
47
|
migrate: () => Promise<void>;
|
|
47
|
-
router: () => any;
|
|
48
48
|
run: (agentId: number, params: RunParams) => Promise<RunResult>;
|
|
49
49
|
addKnowledge: (agentId: number, title: string, content: string) => Promise<KnowledgeDoc>;
|
|
50
50
|
close: () => Promise<void>;
|
package/dist/ai.d.ts
CHANGED
|
@@ -2,6 +2,4 @@ import type { Context } from './types.ts';
|
|
|
2
2
|
import { Router } from './router.ts';
|
|
3
3
|
export type AIHandler = (req: Request, ctx: Context) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
4
4
|
export declare const _ai: Record<string, any>;
|
|
5
|
-
export declare function aiStream(handler: AIHandler): Promise<
|
|
6
|
-
router(): Router;
|
|
7
|
-
}>;
|
|
5
|
+
export declare function aiStream(handler: AIHandler): Promise<Router>;
|
package/dist/analytics.d.ts
CHANGED
|
@@ -7,9 +7,8 @@ export interface AnalyticsOptions {
|
|
|
7
7
|
table: (name: string, cols: any) => any;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export interface AnalyticsModule {
|
|
10
|
+
export interface AnalyticsModule extends Router {
|
|
11
11
|
middleware: () => Middleware;
|
|
12
|
-
router: () => Router;
|
|
13
12
|
migrate: () => Promise<void>;
|
|
14
13
|
close: () => Promise<void>;
|
|
15
14
|
}
|
package/dist/cli.js
CHANGED
|
@@ -84,14 +84,15 @@ async function cmdInit(name) {
|
|
|
84
84
|
""
|
|
85
85
|
].join("\n"));
|
|
86
86
|
await writeFile(join(targetDir, "app.ts"), [
|
|
87
|
-
"import { serve, Router, loadEnv
|
|
87
|
+
"import { serve, Router, loadEnv } from 'weifuwu'",
|
|
88
|
+
"import { ssr, layout } from 'weifuwu/ssr'",
|
|
88
89
|
"",
|
|
89
90
|
"loadEnv()",
|
|
90
91
|
"const port = Number(process.env.PORT) || 3000",
|
|
91
92
|
"",
|
|
92
93
|
"const app = new Router()",
|
|
93
|
-
"
|
|
94
|
-
"app.
|
|
94
|
+
"app.use(layout('./ui/layout.tsx'))",
|
|
95
|
+
"app.get('/', ssr('./ui/page.tsx'))",
|
|
95
96
|
"",
|
|
96
97
|
"app.get('/api/ping', () => Response.json({ pong: true, time: new Date().toISOString() }))",
|
|
97
98
|
"",
|
|
@@ -102,9 +103,9 @@ async function cmdInit(name) {
|
|
|
102
103
|
"console.log(`Listening on http://localhost:${server.port}`)",
|
|
103
104
|
""
|
|
104
105
|
].join("\n"));
|
|
105
|
-
await mkdir(join(targetDir, "ui"
|
|
106
|
+
await mkdir(join(targetDir, "ui"), { recursive: true });
|
|
106
107
|
await writeFile(join(targetDir, "ui", "app.css"), '@import "tailwindcss";\n');
|
|
107
|
-
await writeFile(join(targetDir, "ui", "
|
|
108
|
+
await writeFile(join(targetDir, "ui", "layout.tsx"), [
|
|
108
109
|
"import { ReactNode } from 'react'",
|
|
109
110
|
"",
|
|
110
111
|
"export default function RootLayout({ children }: { children: ReactNode }) {",
|
|
@@ -122,7 +123,7 @@ async function cmdInit(name) {
|
|
|
122
123
|
"}",
|
|
123
124
|
""
|
|
124
125
|
].join("\n"));
|
|
125
|
-
await writeFile(join(targetDir, "ui", "
|
|
126
|
+
await writeFile(join(targetDir, "ui", "page.tsx"), [
|
|
126
127
|
"import { useState } from 'react'",
|
|
127
128
|
"import { useWebsocket } from 'weifuwu/react'",
|
|
128
129
|
"",
|
package/dist/graphql.d.ts
CHANGED
|
@@ -9,6 +9,4 @@ export interface GraphQLOptions {
|
|
|
9
9
|
graphiql?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export type GraphQLHandler = (req: Request, ctx: Context) => GraphQLOptions | Promise<GraphQLOptions>;
|
|
12
|
-
export declare function graphql(handler: GraphQLHandler):
|
|
13
|
-
router(): Router;
|
|
14
|
-
};
|
|
12
|
+
export declare function graphql(handler: GraphQLHandler): Router;
|
package/dist/iii/types.d.ts
CHANGED
|
@@ -30,8 +30,7 @@ export interface TriggerOptions {
|
|
|
30
30
|
action?: 'sync' | 'void';
|
|
31
31
|
timeout_ms?: number;
|
|
32
32
|
}
|
|
33
|
-
export interface IIIModule {
|
|
34
|
-
router: () => Router;
|
|
33
|
+
export interface IIIModule extends Router {
|
|
35
34
|
wsHandler: () => any;
|
|
36
35
|
addWorker: (worker: Worker) => void;
|
|
37
36
|
trigger: (request: TriggerRequest) => Promise<unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ export { serve, createTestServer } from './serve.ts';
|
|
|
4
4
|
export type { ServeOptions, Server } from './serve.ts';
|
|
5
5
|
export { Router } from './router.ts';
|
|
6
6
|
export type { WebSocketHandler } from './router.ts';
|
|
7
|
-
export {
|
|
8
|
-
export type { TsxOptions } from './tsx.ts';
|
|
7
|
+
export { TsxContext } from './tsx-context.ts';
|
|
9
8
|
export { auth, cors, logger } from './middleware.ts';
|
|
10
9
|
export type { AuthOptions, CORSOptions, LoggerOptions } from './middleware.ts';
|
|
11
10
|
export { serveStatic } from './static.ts';
|