weifuwu 0.25.2 → 0.27.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 +291 -2489
- package/ai/provider.ts +129 -0
- package/ai/stream.ts +63 -0
- package/cli.ts +55 -257
- package/core/cookie.ts +114 -0
- package/core/env.ts +142 -0
- package/core/logger.ts +72 -0
- package/core/router.ts +795 -0
- package/core/serve.ts +294 -0
- package/core/sse.ts +85 -0
- package/core/trace.ts +146 -0
- package/graphql.ts +267 -0
- package/hub.ts +133 -0
- package/index.ts +71 -0
- package/mailer.ts +81 -0
- package/middleware/compress.ts +103 -0
- package/middleware/cors.ts +81 -0
- package/middleware/csrf.ts +112 -0
- package/middleware/flash.ts +144 -0
- package/middleware/health.ts +44 -0
- package/middleware/helmet.ts +98 -0
- package/middleware/i18n.ts +175 -0
- package/middleware/rate-limit.ts +167 -0
- package/middleware/request-id.ts +60 -0
- package/middleware/static.ts +149 -0
- package/middleware/theme.ts +84 -0
- package/middleware/upload.ts +168 -0
- package/middleware/validate.ts +186 -0
- package/package.json +14 -36
- package/postgres/client.ts +132 -0
- package/postgres/index.ts +4 -0
- package/postgres/module.ts +37 -0
- package/postgres/schema/columns.ts +186 -0
- package/postgres/schema/index.ts +36 -0
- package/postgres/schema/sql.ts +39 -0
- package/postgres/schema/table.ts +548 -0
- package/postgres/schema/where.ts +99 -0
- package/postgres/types.ts +48 -0
- package/queue/cron.ts +90 -0
- package/queue/index.ts +654 -0
- package/queue/types.ts +60 -0
- package/redis/client.ts +24 -0
- package/{dist/redis/index.d.ts → redis/index.ts} +2 -2
- package/redis/types.ts +28 -0
- package/types.ts +78 -0
- package/cli/template/app.ts +0 -22
- package/cli/template/index.ts +0 -10
- package/cli/template/locales/en.json +0 -13
- package/cli/template/locales/zh-CN.json +0 -13
- package/cli/template/locales/zh-TW.json +0 -13
- package/cli/template/locales/zh.json +0 -13
- package/cli/template/ui/app/globals.css +0 -2
- package/cli/template/ui/app/layout.tsx +0 -15
- package/cli/template/ui/app/page.tsx +0 -124
- package/cli/template/ui/components/Greeting.tsx +0 -3
- package/dist/agent/client.d.ts +0 -2
- package/dist/agent/index.d.ts +0 -2
- package/dist/agent/rest.d.ts +0 -14
- package/dist/agent/run.d.ts +0 -19
- package/dist/agent/types.d.ts +0 -55
- package/dist/ai/provider.d.ts +0 -45
- package/dist/ai/utils.d.ts +0 -5
- package/dist/ai/workflow.d.ts +0 -17
- package/dist/ai-sdk.d.ts +0 -2
- package/dist/ai.d.ts +0 -13
- package/dist/analytics.d.ts +0 -45
- package/dist/auth.d.ts +0 -22
- package/dist/cache.d.ts +0 -74
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -302
- package/dist/client-locale.d.ts +0 -25
- package/dist/client-pref.d.ts +0 -3
- package/dist/client-router.d.ts +0 -300
- package/dist/client-state.d.ts +0 -22
- package/dist/client-theme.d.ts +0 -36
- package/dist/compile.d.ts +0 -15
- package/dist/compress.d.ts +0 -20
- package/dist/cookie.d.ts +0 -36
- package/dist/cors.d.ts +0 -25
- package/dist/cron-utils.d.ts +0 -73
- package/dist/csrf.d.ts +0 -47
- package/dist/deploy/config.d.ts +0 -2
- package/dist/deploy/gateway.d.ts +0 -2
- package/dist/deploy/index.d.ts +0 -4
- package/dist/deploy/manager.d.ts +0 -16
- package/dist/deploy/process.d.ts +0 -14
- package/dist/deploy/types.d.ts +0 -53
- package/dist/env.d.ts +0 -69
- package/dist/error-boundary.d.ts +0 -2
- package/dist/flash.d.ts +0 -90
- package/dist/fts.d.ts +0 -36
- package/dist/graphql.d.ts +0 -16
- package/dist/head.d.ts +0 -6
- package/dist/health.d.ts +0 -24
- package/dist/helmet.d.ts +0 -33
- package/dist/html-shell.d.ts +0 -1
- package/dist/hub.d.ts +0 -37
- package/dist/i18n.d.ts +0 -39
- package/dist/iii/client.d.ts +0 -2
- package/dist/iii/index.d.ts +0 -4
- package/dist/iii/register-worker.d.ts +0 -9
- package/dist/iii/rest.d.ts +0 -3
- package/dist/iii/stream.d.ts +0 -82
- package/dist/iii/types.d.ts +0 -121
- package/dist/iii/worker.d.ts +0 -2
- package/dist/iii/ws.d.ts +0 -22
- package/dist/index.d.ts +0 -101
- package/dist/index.js +0 -12752
- package/dist/kb/index.d.ts +0 -3
- package/dist/kb/types.d.ts +0 -72
- package/dist/layout.d.ts +0 -2
- package/dist/live.d.ts +0 -7
- package/dist/logdb/client.d.ts +0 -2
- package/dist/logdb/index.d.ts +0 -2
- package/dist/logdb/rest.d.ts +0 -5
- package/dist/logdb/types.d.ts +0 -27
- package/dist/logger.d.ts +0 -16
- package/dist/mailer.d.ts +0 -51
- package/dist/mcp.d.ts +0 -34
- package/dist/messager/agent.d.ts +0 -11
- package/dist/messager/client.d.ts +0 -2
- package/dist/messager/index.d.ts +0 -2
- package/dist/messager/rest.d.ts +0 -15
- package/dist/messager/types.d.ts +0 -57
- package/dist/messager/ws.d.ts +0 -14
- package/dist/module-server.d.ts +0 -9
- package/dist/not-found.d.ts +0 -2
- package/dist/notifier/client.d.ts +0 -2
- package/dist/notifier/index.d.ts +0 -2
- package/dist/notifier/types.d.ts +0 -105
- package/dist/opencode/client.d.ts +0 -2
- package/dist/opencode/index.d.ts +0 -2
- package/dist/opencode/permissions.d.ts +0 -5
- package/dist/opencode/prompt.d.ts +0 -8
- package/dist/opencode/rest.d.ts +0 -16
- package/dist/opencode/run.d.ts +0 -13
- package/dist/opencode/session.d.ts +0 -26
- package/dist/opencode/skills.d.ts +0 -4
- package/dist/opencode/tools/bash.d.ts +0 -6
- package/dist/opencode/tools/edit.d.ts +0 -19
- package/dist/opencode/tools/glob.d.ts +0 -9
- package/dist/opencode/tools/grep.d.ts +0 -17
- package/dist/opencode/tools/index.d.ts +0 -12
- package/dist/opencode/tools/question.d.ts +0 -5
- package/dist/opencode/tools/read.d.ts +0 -16
- package/dist/opencode/tools/skill.d.ts +0 -18
- package/dist/opencode/tools/web.d.ts +0 -18
- package/dist/opencode/tools/write.d.ts +0 -13
- package/dist/opencode/types.d.ts +0 -90
- package/dist/opencode/ws.d.ts +0 -21
- package/dist/permissions.d.ts +0 -51
- package/dist/postgres/client.d.ts +0 -4
- package/dist/postgres/index.d.ts +0 -4
- package/dist/postgres/module.d.ts +0 -17
- package/dist/postgres/schema/columns.d.ts +0 -99
- package/dist/postgres/schema/index.d.ts +0 -6
- package/dist/postgres/schema/sql.d.ts +0 -22
- package/dist/postgres/schema/table.d.ts +0 -141
- package/dist/postgres/schema/where.d.ts +0 -29
- package/dist/postgres/types.d.ts +0 -50
- package/dist/queue/index.d.ts +0 -2
- package/dist/queue/types.d.ts +0 -62
- package/dist/rate-limit.d.ts +0 -45
- package/dist/react.d.ts +0 -14
- package/dist/react.js +0 -751
- package/dist/redis/client.d.ts +0 -2
- package/dist/redis/types.d.ts +0 -18
- package/dist/request-id.d.ts +0 -40
- package/dist/router.d.ts +0 -73
- package/dist/s3.d.ts +0 -68
- package/dist/seo.d.ts +0 -104
- package/dist/serve.d.ts +0 -38
- package/dist/server-registry.d.ts +0 -10
- package/dist/session.d.ts +0 -117
- package/dist/sse.d.ts +0 -47
- package/dist/ssr-entries.d.ts +0 -4
- package/dist/ssr.d.ts +0 -11
- package/dist/static.d.ts +0 -23
- package/dist/stream.d.ts +0 -24
- package/dist/tailwind.d.ts +0 -15
- package/dist/tenant/client.d.ts +0 -2
- package/dist/tenant/graphql.d.ts +0 -3
- package/dist/tenant/index.d.ts +0 -2
- package/dist/tenant/rest.d.ts +0 -3
- package/dist/tenant/schema.d.ts +0 -5
- package/dist/tenant/types.d.ts +0 -48
- package/dist/tenant/utils.d.ts +0 -9
- package/dist/test-utils.d.ts +0 -194
- package/dist/theme.d.ts +0 -31
- package/dist/trace.d.ts +0 -95
- package/dist/tsx-context.d.ts +0 -32
- package/dist/types.d.ts +0 -47
- package/dist/upload.d.ts +0 -55
- package/dist/use-action.d.ts +0 -42
- package/dist/use-agent-stream.d.ts +0 -49
- package/dist/use-flash-message.d.ts +0 -17
- package/dist/use-websocket.d.ts +0 -42
- package/dist/user/client.d.ts +0 -30
- package/dist/user/index.d.ts +0 -2
- package/dist/user/oauth-login.d.ts +0 -21
- package/dist/user/oauth2.d.ts +0 -31
- package/dist/user/types.d.ts +0 -178
- package/dist/validate.d.ts +0 -32
- package/dist/vendor.d.ts +0 -7
- package/dist/webhook.d.ts +0 -79
- package/opencode/ui/app/globals.css +0 -1
- package/opencode/ui/app/layout.tsx +0 -13
- package/opencode/ui/app/page.tsx +0 -523
package/dist/kb/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { KBOptions, KBModule, KBIngestOptions, KBSearchOptions, KBSearchResult, KBListEntry } from './types.ts';
|
|
2
|
-
export type { KBOptions, KBIngestOptions, KBSearchResult, KBSearchOptions, KBListEntry, KBModule };
|
|
3
|
-
export declare function knowledgeBase(options: KBOptions): KBModule;
|
package/dist/kb/types.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Middleware } from '../types.ts';
|
|
2
|
-
import type { AIProvider } from '../ai/provider.ts';
|
|
3
|
-
import type { PostgresClient } from '../postgres/types.ts';
|
|
4
|
-
export interface KBOptions {
|
|
5
|
-
/** Postgres client instance. */
|
|
6
|
-
pg: PostgresClient;
|
|
7
|
-
/** AI provider for embedding. */
|
|
8
|
-
provider: AIProvider;
|
|
9
|
-
/** Table name (default: '_kb_docs'). */
|
|
10
|
-
table?: string;
|
|
11
|
-
/** Default chunk size in characters (default: 512). */
|
|
12
|
-
chunkSize?: number;
|
|
13
|
-
/** Default chunk overlap in characters (default: 64). */
|
|
14
|
-
chunkOverlap?: number;
|
|
15
|
-
/** Default search limit (default: 5). */
|
|
16
|
-
searchLimit?: number;
|
|
17
|
-
/** Minimum similarity score threshold (0–1, default: 0). Set higher for stricter matches. */
|
|
18
|
-
searchThreshold?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface KBIngestOptions {
|
|
21
|
-
title?: string;
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
chunkSize?: number;
|
|
24
|
-
chunkOverlap?: number;
|
|
25
|
-
}
|
|
26
|
-
export interface KBSearchResult {
|
|
27
|
-
id: number;
|
|
28
|
-
key: string;
|
|
29
|
-
title: string;
|
|
30
|
-
content: string;
|
|
31
|
-
score: number;
|
|
32
|
-
metadata: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
export interface KBSearchOptions {
|
|
35
|
-
limit?: number;
|
|
36
|
-
/** Minimum cosine similarity score (0–1). Results below this are excluded. */
|
|
37
|
-
threshold?: number;
|
|
38
|
-
}
|
|
39
|
-
export interface KBListEntry {
|
|
40
|
-
key: string;
|
|
41
|
-
title: string;
|
|
42
|
-
chunks: number;
|
|
43
|
-
}
|
|
44
|
-
export interface KBInjected {
|
|
45
|
-
search(query: string, searchOptions?: KBSearchOptions): Promise<KBSearchResult[]>;
|
|
46
|
-
}
|
|
47
|
-
declare module '../types.ts' {
|
|
48
|
-
interface Context {
|
|
49
|
-
kb?: KBInjected;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export interface KBModule {
|
|
53
|
-
/**
|
|
54
|
-
* Ingest a document: chunk → embed → store.
|
|
55
|
-
* If a document with the same key exists, it is replaced (delete + re-insert).
|
|
56
|
-
* Returns the number of chunks created.
|
|
57
|
-
*/
|
|
58
|
-
ingest(key: string, content: string, options?: KBIngestOptions): Promise<number>;
|
|
59
|
-
/**
|
|
60
|
-
* Search the knowledge base by semantic similarity.
|
|
61
|
-
* Query is embedded, then vector similarity search returns top results.
|
|
62
|
-
*/
|
|
63
|
-
search(query: string, searchOptions?: KBSearchOptions): Promise<KBSearchResult[]>;
|
|
64
|
-
/** Delete all chunks for a document key. */
|
|
65
|
-
delete(key: string): Promise<void>;
|
|
66
|
-
/** List all document keys with title and chunk count. */
|
|
67
|
-
list(): Promise<KBListEntry[]>;
|
|
68
|
-
/** Create the table and HNSW index. Safe to call multiple times. */
|
|
69
|
-
migrate(): Promise<void>;
|
|
70
|
-
/** Middleware that injects `ctx.kb` with `.search()` method. */
|
|
71
|
-
middleware(): Middleware;
|
|
72
|
-
}
|
package/dist/layout.d.ts
DELETED
package/dist/live.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Router, type WebSocketHandler } from './router.ts';
|
|
2
|
-
export declare function broadcastReload(): void;
|
|
3
|
-
export declare function liveWs(): WebSocketHandler;
|
|
4
|
-
export declare function liveRouter(_dir: string): Router;
|
|
5
|
-
export declare function liveWatcher(dir: string): {
|
|
6
|
-
close: () => void;
|
|
7
|
-
};
|
package/dist/logdb/client.d.ts
DELETED
package/dist/logdb/index.d.ts
DELETED
package/dist/logdb/rest.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type BoundTable } from '../postgres/schema/index.ts';
|
|
2
|
-
import type { Context } from '../types.ts';
|
|
3
|
-
export declare function createHandler(entries: BoundTable<any>): (req: Request, ctx: Context) => Promise<Response>;
|
|
4
|
-
export declare function listHandler(entries: BoundTable<any>): (req: Request) => Promise<Response>;
|
|
5
|
-
export declare function getHandler(entries: BoundTable<any>): (_req: Request, ctx: any) => Promise<Response>;
|
package/dist/logdb/types.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PostgresClient } from '../postgres/types.ts';
|
|
2
|
-
import type { Router } from '../router.ts';
|
|
3
|
-
import type { Closeable } from '../types.ts';
|
|
4
|
-
export interface LogdbOptions {
|
|
5
|
-
pg: PostgresClient;
|
|
6
|
-
table?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface LogEntry {
|
|
9
|
-
id: number;
|
|
10
|
-
level: string;
|
|
11
|
-
source: string;
|
|
12
|
-
message: string;
|
|
13
|
-
metadata: Record<string, unknown>;
|
|
14
|
-
created_at: string;
|
|
15
|
-
}
|
|
16
|
-
export interface LogEntryInput {
|
|
17
|
-
level: string;
|
|
18
|
-
source: string;
|
|
19
|
-
message: string;
|
|
20
|
-
metadata?: Record<string, unknown>;
|
|
21
|
-
}
|
|
22
|
-
export interface LogdbModule extends Router, Closeable {
|
|
23
|
-
log(input: LogEntryInput): Promise<LogEntry>;
|
|
24
|
-
migrate(): Promise<void>;
|
|
25
|
-
clean(retentionMonths: number): Promise<number>;
|
|
26
|
-
close(): Promise<void>;
|
|
27
|
-
}
|
package/dist/logger.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Middleware, Context } from './types.ts';
|
|
2
|
-
export interface LoggerOptions {
|
|
3
|
-
/** 'short' = method + path + status + ms, 'combined' = short + query string, 'json' = structured stderr JSON */
|
|
4
|
-
format?: 'short' | 'combined' | 'json';
|
|
5
|
-
}
|
|
6
|
-
export interface LogEvent {
|
|
7
|
-
level: 'info' | 'warn' | 'error';
|
|
8
|
-
message: string;
|
|
9
|
-
method?: string;
|
|
10
|
-
path?: string;
|
|
11
|
-
status?: number;
|
|
12
|
-
elapsed_ms?: number;
|
|
13
|
-
traceId?: string;
|
|
14
|
-
timestamp?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare function logger(options?: LoggerOptions): Middleware<Context, Context>;
|
package/dist/mailer.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { type Transporter } from 'nodemailer';
|
|
2
|
-
import type { Closeable } from './types.ts';
|
|
3
|
-
/** Options for sending an email. */
|
|
4
|
-
export interface MailOptions {
|
|
5
|
-
/** Recipient address(es). */
|
|
6
|
-
to: string | string[];
|
|
7
|
-
/** Email subject. */
|
|
8
|
-
subject: string;
|
|
9
|
-
/** Plain text body. */
|
|
10
|
-
text?: string;
|
|
11
|
-
/** HTML body. */
|
|
12
|
-
html?: string;
|
|
13
|
-
/** Sender address (overrides `MailerOptions.from`). */
|
|
14
|
-
from?: string;
|
|
15
|
-
/** CC recipient(s). */
|
|
16
|
-
cc?: string | string[];
|
|
17
|
-
/** BCC recipient(s). */
|
|
18
|
-
bcc?: string | string[];
|
|
19
|
-
}
|
|
20
|
-
/** Options for {@link mailer}. */
|
|
21
|
-
export interface MailerOptions {
|
|
22
|
-
/** Nodemailer transport string or pre-built transporter object. */
|
|
23
|
-
transport?: string | Transporter;
|
|
24
|
-
/** Default sender address. */
|
|
25
|
-
from?: string;
|
|
26
|
-
/** Custom send function (bypasses nodemailer). */
|
|
27
|
-
send?: (opts: MailOptions) => Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
/** Mailer instance returned by {@link mailer}. */
|
|
30
|
-
export interface Mailer extends Closeable {
|
|
31
|
-
/** Send an email. */
|
|
32
|
-
send: (opts: MailOptions) => Promise<void>;
|
|
33
|
-
/** Close the nodemailer transport. */
|
|
34
|
-
close: () => Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a mailer instance.
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { mailer } from 'weifuwu'
|
|
41
|
-
*
|
|
42
|
-
* const email = mailer({ transport: 'smtp://user:pass@smtp.example.com' })
|
|
43
|
-
* await email.send({
|
|
44
|
-
* to: 'user@example.com',
|
|
45
|
-
* subject: 'Hello',
|
|
46
|
-
* text: 'Hello from weifuwu!',
|
|
47
|
-
* })
|
|
48
|
-
* await email.close()
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare function mailer(options: MailerOptions): Mailer;
|
package/dist/mcp.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export interface MCPClientOptions {
|
|
2
|
-
/** Command to spawn (e.g. 'npx', 'node', 'uvx'). */
|
|
3
|
-
command: string;
|
|
4
|
-
/** Arguments passed to the command. */
|
|
5
|
-
args?: string[];
|
|
6
|
-
/** Environment variables (merged with process.env). */
|
|
7
|
-
env?: Record<string, string>;
|
|
8
|
-
/** How long to wait for handshake/response (ms). Default: 15_000. */
|
|
9
|
-
timeout?: number;
|
|
10
|
-
/** Max tool response body size in bytes. Default: 10MB. */
|
|
11
|
-
maxResponseSize?: number;
|
|
12
|
-
}
|
|
13
|
-
/** A tool definition from an MCP server. */
|
|
14
|
-
export interface MCPToolDef {
|
|
15
|
-
name: string;
|
|
16
|
-
description?: string;
|
|
17
|
-
inputSchema?: {
|
|
18
|
-
type: 'object';
|
|
19
|
-
properties?: Record<string, unknown>;
|
|
20
|
-
required?: string[];
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/** MCP client — spawns and manages a single MCP server subprocess. */
|
|
24
|
-
export interface MCPClient {
|
|
25
|
-
/** Fetch tool definitions from the server and return AI SDK Tool objects. */
|
|
26
|
-
getTools(): Promise<Record<string, unknown>>;
|
|
27
|
-
/** Refresh tool definitions (re-call tools/list). */
|
|
28
|
-
refresh(): Promise<void>;
|
|
29
|
-
/** Call a tool by name. Returns the raw result from the MCP server. */
|
|
30
|
-
callTool(name: string, args: unknown): Promise<unknown>;
|
|
31
|
-
/** Shutdown the MCP server and release resources. */
|
|
32
|
-
close(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export declare function mcpClient(options: MCPClientOptions): MCPClient;
|
package/dist/messager/agent.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SqlClient } from '../vendor.ts';
|
|
2
|
-
import type { AgentModule } from '../agent/types.ts';
|
|
3
|
-
import type { Hub } from '../hub.ts';
|
|
4
|
-
/**
|
|
5
|
-
* Route a user message to all agent members in a channel.
|
|
6
|
-
* - Streaming: broadcasts SSE text tokens in real-time
|
|
7
|
-
* - Multi-round: passes recent channel history as conversation context
|
|
8
|
-
*/
|
|
9
|
-
export declare function runAgentRouting(sql: SqlClient, messages: {
|
|
10
|
-
insert: (data: any) => Promise<any>;
|
|
11
|
-
}, agents: AgentModule | undefined, hub: Hub, channelId: number, content: string, stream?: boolean, contextMessages?: number): Promise<void>;
|
package/dist/messager/index.d.ts
DELETED
package/dist/messager/rest.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { SqlClient } from '../vendor.ts';
|
|
2
|
-
import { Router } from '../router.ts';
|
|
3
|
-
import type { AgentModule } from '../agent/types.ts';
|
|
4
|
-
import type { Hub } from '../hub.ts';
|
|
5
|
-
import { type BoundTable } from '../postgres/schema/index.ts';
|
|
6
|
-
interface RestDeps {
|
|
7
|
-
sql: SqlClient;
|
|
8
|
-
channels: BoundTable<any>;
|
|
9
|
-
members: BoundTable<any>;
|
|
10
|
-
messages: BoundTable<any>;
|
|
11
|
-
agents?: AgentModule;
|
|
12
|
-
hub: Hub;
|
|
13
|
-
}
|
|
14
|
-
export declare function buildRouter(deps: RestDeps): Router;
|
|
15
|
-
export {};
|
package/dist/messager/types.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Router } from '../router.ts';
|
|
2
|
-
import type { AgentModule } from '../agent/types.ts';
|
|
3
|
-
import type { PostgresClient } from '../postgres/types.ts';
|
|
4
|
-
import type { Redis } from '../vendor.ts';
|
|
5
|
-
import type { Closeable } from '../types.ts';
|
|
6
|
-
export interface MessagerOptions {
|
|
7
|
-
pg: PostgresClient;
|
|
8
|
-
agents?: AgentModule;
|
|
9
|
-
webhookTimeout?: number;
|
|
10
|
-
redis?: Redis;
|
|
11
|
-
}
|
|
12
|
-
export interface Channel {
|
|
13
|
-
id: number;
|
|
14
|
-
tenant_id: string | null;
|
|
15
|
-
name: string;
|
|
16
|
-
type: 'channel' | 'dm';
|
|
17
|
-
created_by: number;
|
|
18
|
-
created_at: string;
|
|
19
|
-
}
|
|
20
|
-
export interface ChannelMember {
|
|
21
|
-
id: number;
|
|
22
|
-
channel_id: number;
|
|
23
|
-
member_id: number;
|
|
24
|
-
member_type: 'user' | 'agent' | 'webhook';
|
|
25
|
-
role: 'admin' | 'member';
|
|
26
|
-
last_read_id: number | null;
|
|
27
|
-
}
|
|
28
|
-
export interface Message {
|
|
29
|
-
id: number;
|
|
30
|
-
channel_id: number;
|
|
31
|
-
sender_id: number;
|
|
32
|
-
sender_type: 'user' | 'agent' | 'webhook';
|
|
33
|
-
type: 'text' | 'image' | 'file' | 'system';
|
|
34
|
-
content: string;
|
|
35
|
-
file_url: string | null;
|
|
36
|
-
file_name: string | null;
|
|
37
|
-
file_size: number | null;
|
|
38
|
-
mime_type: string | null;
|
|
39
|
-
created_at: string;
|
|
40
|
-
}
|
|
41
|
-
export interface MessagerModule extends Router, Closeable {
|
|
42
|
-
migrate: () => Promise<void>;
|
|
43
|
-
wsHandler: () => any;
|
|
44
|
-
send: (channelId: number, content: string, opts?: {
|
|
45
|
-
sender_type?: string;
|
|
46
|
-
sender_id?: number;
|
|
47
|
-
type?: string;
|
|
48
|
-
}) => Promise<Message>;
|
|
49
|
-
close: () => Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
export interface WSMessage {
|
|
52
|
-
type: 'message' | 'typing' | 'read';
|
|
53
|
-
channel_id: number;
|
|
54
|
-
content?: string;
|
|
55
|
-
is_typing?: boolean;
|
|
56
|
-
last_message_id?: number;
|
|
57
|
-
}
|
package/dist/messager/ws.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { SqlClient } from '../vendor.ts';
|
|
2
|
-
import type { AgentModule } from '../agent/types.ts';
|
|
3
|
-
import { type Hub } from '../hub.ts';
|
|
4
|
-
interface WSDeps {
|
|
5
|
-
sql: SqlClient;
|
|
6
|
-
agents?: AgentModule;
|
|
7
|
-
redis?: import('../vendor.ts').Redis;
|
|
8
|
-
}
|
|
9
|
-
export declare function broadcastToChannel(hub: Hub | undefined, channelId: number, data: any): void;
|
|
10
|
-
export declare function createWSHandler(deps: WSDeps): {
|
|
11
|
-
handler: any;
|
|
12
|
-
hub: Hub;
|
|
13
|
-
};
|
|
14
|
-
export {};
|
package/dist/module-server.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Router } from './router.ts';
|
|
2
|
-
export declare function clearModuleCache(filePath?: string): void;
|
|
3
|
-
export declare function transformModule(absPath: string, root: string, mountPath?: string): Promise<{
|
|
4
|
-
url: string;
|
|
5
|
-
code: string;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function moduleServer(opts: {
|
|
8
|
-
root: string | string[];
|
|
9
|
-
}): Router;
|
package/dist/not-found.d.ts
DELETED
package/dist/notifier/index.d.ts
DELETED
package/dist/notifier/types.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { Context, Middleware, Closeable } from '../types.ts';
|
|
2
|
-
import type { Mailer } from '../mailer.ts';
|
|
3
|
-
import type { Hub } from '../hub.ts';
|
|
4
|
-
import type { SqlClient } from '../vendor.ts';
|
|
5
|
-
declare module '../types.ts' {
|
|
6
|
-
interface Context {
|
|
7
|
-
notifier: Notifier;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
/** Shape injected into ctx when notifier middleware is active. */
|
|
11
|
-
export interface NotifierInjected {
|
|
12
|
-
notifier: Notifier;
|
|
13
|
-
}
|
|
14
|
-
/** Configuration for the notifier module. */
|
|
15
|
-
export interface NotifierOptions {
|
|
16
|
-
/** SQL client (PostgreSQL) for persistent notifications. */
|
|
17
|
-
sql: SqlClient;
|
|
18
|
-
/** Optional mailer for email channel. */
|
|
19
|
-
mailer?: Mailer;
|
|
20
|
-
/** Optional hub for WebSocket push channel. */
|
|
21
|
-
hub?: Hub;
|
|
22
|
-
/** Default sender name for email (default: system name). */
|
|
23
|
-
fromName?: string;
|
|
24
|
-
/** Table name for notifications (default: '_notifications'). */
|
|
25
|
-
table?: string;
|
|
26
|
-
/** Max notification list page size (default: 50). */
|
|
27
|
-
pageSize?: number;
|
|
28
|
-
}
|
|
29
|
-
/** A notification message. */
|
|
30
|
-
export interface NotifyMessage {
|
|
31
|
-
/** Notification title. */
|
|
32
|
-
title: string;
|
|
33
|
-
/** Notification body text. */
|
|
34
|
-
body?: string;
|
|
35
|
-
/** Optional action URL. */
|
|
36
|
-
actionUrl?: string;
|
|
37
|
-
/** Optional action button text. */
|
|
38
|
-
actionText?: string;
|
|
39
|
-
/** Notification type for categorization (default: 'default'). */
|
|
40
|
-
type?: string;
|
|
41
|
-
/** Arbitrary metadata (JSON object). */
|
|
42
|
-
metadata?: Record<string, unknown>;
|
|
43
|
-
}
|
|
44
|
-
/** A notification record from the database. */
|
|
45
|
-
export interface Notification {
|
|
46
|
-
id: number;
|
|
47
|
-
user_id: number;
|
|
48
|
-
title: string;
|
|
49
|
-
body: string;
|
|
50
|
-
action_url: string | null;
|
|
51
|
-
action_text: string | null;
|
|
52
|
-
type: string;
|
|
53
|
-
metadata: Record<string, unknown>;
|
|
54
|
-
read_at: string | null;
|
|
55
|
-
created_at: string;
|
|
56
|
-
}
|
|
57
|
-
/** Supported notification channels. */
|
|
58
|
-
export type NotifyChannel = 'inbox' | 'email' | 'ws';
|
|
59
|
-
/** User's channel preferences for a notification type. */
|
|
60
|
-
export interface NotifyPreferences {
|
|
61
|
-
/** Which channels are enabled. Default: ['inbox']. */
|
|
62
|
-
channels: NotifyChannel[];
|
|
63
|
-
}
|
|
64
|
-
/** The notifier API injected into ctx. */
|
|
65
|
-
export interface Notifier extends Closeable {
|
|
66
|
-
/**
|
|
67
|
-
* Send a notification to a specific user.
|
|
68
|
-
* Routes through the user's channel preferences automatically.
|
|
69
|
-
*/
|
|
70
|
-
send(to: {
|
|
71
|
-
userId: number;
|
|
72
|
-
email?: string;
|
|
73
|
-
}, message: NotifyMessage): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Send a system-wide notification to all users.
|
|
76
|
-
* Useful for announcements.
|
|
77
|
-
*/
|
|
78
|
-
broadcast(message: NotifyMessage): Promise<void>;
|
|
79
|
-
/** Get user's unread notification count. */
|
|
80
|
-
unreadCount(userId: number): Promise<number>;
|
|
81
|
-
/** Mark specific notifications as read. If no ids given, mark all as read. */
|
|
82
|
-
markRead(userId: number, notificationIds?: number[]): Promise<void>;
|
|
83
|
-
/** List notifications for a user, newest first. */
|
|
84
|
-
list(userId: number, opts?: {
|
|
85
|
-
limit?: number;
|
|
86
|
-
offset?: number;
|
|
87
|
-
unreadOnly?: boolean;
|
|
88
|
-
}): Promise<Notification[]>;
|
|
89
|
-
/** Get or set user's notification channel preferences. */
|
|
90
|
-
getPreferences(userId: number): Promise<NotifyPreferences>;
|
|
91
|
-
setPreferences(userId: number, prefs: NotifyPreferences): Promise<void>;
|
|
92
|
-
/** Count total notifications for a user. */
|
|
93
|
-
count(userId: number, unreadOnly?: boolean): Promise<number>;
|
|
94
|
-
/** Clean up old notifications (older than days). */
|
|
95
|
-
clean(days: number): Promise<number>;
|
|
96
|
-
/** Create the notifications and preferences tables. Safe to call multiple times. */
|
|
97
|
-
migrate(): Promise<void>;
|
|
98
|
-
/** Release resources. */
|
|
99
|
-
close(): Promise<void>;
|
|
100
|
-
}
|
|
101
|
-
/** Notifier middleware type. */
|
|
102
|
-
export interface NotifierMiddleware extends Middleware<Context, Context & NotifierInjected>, Notifier {
|
|
103
|
-
/** Alias for backward compatibility. */
|
|
104
|
-
middleware: () => Middleware<Context, Context & NotifierInjected>;
|
|
105
|
-
}
|
package/dist/opencode/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { OpencodePermissions } from './types.ts';
|
|
2
|
-
export declare function isCommandAllowed(command: string): boolean;
|
|
3
|
-
export declare function isPathAllowed(resolvedPath: string, workspace: string, _perms?: OpencodePermissions): boolean;
|
|
4
|
-
export declare function isToolEnabled(name: string, perms?: OpencodePermissions): boolean;
|
|
5
|
-
export declare function isSkillAllowed(name: string, perms?: OpencodePermissions): boolean;
|
package/dist/opencode/rest.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Router } from '../router.ts';
|
|
2
|
-
import type { LanguageModel } from 'ai';
|
|
3
|
-
import type { SqlClient } from '../vendor.ts';
|
|
4
|
-
import type { SkillDef, SkillRegistry, OpencodePermissions, PendingQuestion } from './types.ts';
|
|
5
|
-
interface RestDeps {
|
|
6
|
-
sql: SqlClient;
|
|
7
|
-
model: LanguageModel;
|
|
8
|
-
workspace: string;
|
|
9
|
-
systemPrompt?: string;
|
|
10
|
-
skills: SkillDef[];
|
|
11
|
-
skillsRegistry: SkillRegistry;
|
|
12
|
-
permissions?: OpencodePermissions;
|
|
13
|
-
pendingQuestions: Map<string, PendingQuestion>;
|
|
14
|
-
}
|
|
15
|
-
export declare function buildRouter(deps: RestDeps): Promise<Router>;
|
|
16
|
-
export {};
|
package/dist/opencode/run.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type LanguageModel, type Tool } from 'ai';
|
|
2
|
-
import { type SessionMessage } from './session.ts';
|
|
3
|
-
export interface ExecuteOptions {
|
|
4
|
-
sessionId: string;
|
|
5
|
-
input: string;
|
|
6
|
-
model: LanguageModel;
|
|
7
|
-
tools: Record<string, Tool>;
|
|
8
|
-
systemPrompt: string;
|
|
9
|
-
messages: SessionMessage[];
|
|
10
|
-
sql: any;
|
|
11
|
-
abortSignal?: AbortSignal;
|
|
12
|
-
}
|
|
13
|
-
export declare function executeGenerator(opts: ExecuteOptions): AsyncGenerator<any, void, unknown>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { SqlClient } from '../vendor.ts';
|
|
2
|
-
import type { Session, Message } from './types.ts';
|
|
3
|
-
export declare function createSession(sql: SqlClient, opts: {
|
|
4
|
-
userId?: number;
|
|
5
|
-
title?: string;
|
|
6
|
-
model?: string;
|
|
7
|
-
systemPrompt?: string;
|
|
8
|
-
}, cwd: string, mountPath: string): Promise<Session>;
|
|
9
|
-
export declare function getSession(sql: SqlClient, id: string): Promise<Session | null>;
|
|
10
|
-
export declare function listSessions(sql: SqlClient, userId?: number): Promise<Session[]>;
|
|
11
|
-
export declare function deleteSession(sql: SqlClient, id: string): Promise<void>;
|
|
12
|
-
export declare function getHistory(sql: SqlClient, sessionId: string, limit?: number): Promise<SessionMessage[]>;
|
|
13
|
-
export interface SessionMessage {
|
|
14
|
-
id: number;
|
|
15
|
-
session_id: string;
|
|
16
|
-
role: 'user' | 'assistant' | 'tool';
|
|
17
|
-
content: string | null;
|
|
18
|
-
tool_calls: unknown[] | null;
|
|
19
|
-
tool_results: unknown[] | null;
|
|
20
|
-
tokens_in: number;
|
|
21
|
-
tokens_out: number;
|
|
22
|
-
created_at: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function addTextMessage(sql: SqlClient, sessionId: string, role: 'user' | 'assistant', content: string, tokensIn?: number, tokensOut?: number): Promise<Message>;
|
|
25
|
-
export declare function addToolMessages(sql: SqlClient, sessionId: string, toolCalls: unknown[], toolResults: unknown[]): Promise<Message>;
|
|
26
|
-
export declare function updateSessionTitle(sql: SqlClient, id: string, title: string): Promise<void>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { SkillDef, SkillRegistry } from './types.ts';
|
|
2
|
-
export declare function parseSkillFile(filePath: string): Promise<SkillDef | null>;
|
|
3
|
-
export declare function discoverSkills(workspace: string): Promise<SkillDef[]>;
|
|
4
|
-
export declare function buildSkillRegistry(discovered: SkillDef[], manual: SkillDef[]): SkillRegistry;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ToolContext } from './index.ts';
|
|
2
|
-
export declare function createEditTool(ctx: ToolContext): import("ai").Tool<{
|
|
3
|
-
path: string;
|
|
4
|
-
oldString: string;
|
|
5
|
-
newString: string;
|
|
6
|
-
replaceAll: boolean;
|
|
7
|
-
}, {
|
|
8
|
-
error: string;
|
|
9
|
-
replaced?: undefined;
|
|
10
|
-
path?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
error: string;
|
|
13
|
-
replaced: number;
|
|
14
|
-
path?: undefined;
|
|
15
|
-
} | {
|
|
16
|
-
path: string;
|
|
17
|
-
replaced: number;
|
|
18
|
-
error?: undefined;
|
|
19
|
-
}>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ToolContext } from './index.ts';
|
|
2
|
-
export declare function createGrepTool(ctx: ToolContext): import("ai").Tool<{
|
|
3
|
-
pattern: string;
|
|
4
|
-
context: number;
|
|
5
|
-
include?: string | undefined;
|
|
6
|
-
path?: string | undefined;
|
|
7
|
-
}, {
|
|
8
|
-
matches: number;
|
|
9
|
-
results: string[];
|
|
10
|
-
truncated: boolean;
|
|
11
|
-
error?: undefined;
|
|
12
|
-
} | {
|
|
13
|
-
error: any;
|
|
14
|
-
matches: number;
|
|
15
|
-
results: never[];
|
|
16
|
-
truncated?: undefined;
|
|
17
|
-
}>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Tool } from 'ai';
|
|
2
|
-
import type { OpencodePermissions, SkillRegistry } from '../types.ts';
|
|
3
|
-
export interface ToolContext {
|
|
4
|
-
workspace: string;
|
|
5
|
-
permissions?: OpencodePermissions;
|
|
6
|
-
pendingQuestions: Map<string, {
|
|
7
|
-
resolve: (answer: string) => void;
|
|
8
|
-
reject: (err: Error) => void;
|
|
9
|
-
}>;
|
|
10
|
-
skillsRegistry: SkillRegistry;
|
|
11
|
-
}
|
|
12
|
-
export declare function createTools(ctx: ToolContext): Record<string, Tool>;
|