openclaw-bitchat 0.1.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 +156 -0
- package/dist/bridge.d.ts +90 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +232 -0
- package/dist/bridge.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +240 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +150 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/openclaw.plugin.json +58 -0
- package/package.json +64 -0
- package/src/bridge.ts +284 -0
- package/src/index.ts +288 -0
- package/src/types.ts +155 -0
- package/tsconfig.json +26 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for OpenClaw plugin API
|
|
3
|
+
*
|
|
4
|
+
* These are simplified types based on the OpenClaw plugin interface.
|
|
5
|
+
* In production, these would come from the openclaw package types.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Logger {
|
|
9
|
+
info: (...args: unknown[]) => void;
|
|
10
|
+
warn: (...args: unknown[]) => void;
|
|
11
|
+
error: (...args: unknown[]) => void;
|
|
12
|
+
debug: (...args: unknown[]) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface InjectMessageOptions {
|
|
16
|
+
channel: string;
|
|
17
|
+
senderId: string;
|
|
18
|
+
senderName?: string;
|
|
19
|
+
text: string;
|
|
20
|
+
messageId?: string;
|
|
21
|
+
chatType?: 'direct' | 'group';
|
|
22
|
+
timestamp?: number;
|
|
23
|
+
replyToId?: string;
|
|
24
|
+
media?: {
|
|
25
|
+
type: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
buffer?: Buffer;
|
|
28
|
+
filename?: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HttpHandler {
|
|
33
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
34
|
+
path: string;
|
|
35
|
+
handler: (req: HttpRequest, res: HttpResponse) => Promise<void> | void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HttpRequest {
|
|
39
|
+
body: unknown;
|
|
40
|
+
query: Record<string, string>;
|
|
41
|
+
params: Record<string, string>;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface HttpResponse {
|
|
46
|
+
status: (code: number) => HttpResponse;
|
|
47
|
+
json: (data: unknown) => void;
|
|
48
|
+
send: (data: string) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ServiceDefinition {
|
|
52
|
+
id: string;
|
|
53
|
+
start: () => Promise<void> | void;
|
|
54
|
+
stop: () => Promise<void> | void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface GatewayMethodContext {
|
|
58
|
+
respond: (success: boolean, data?: unknown) => void;
|
|
59
|
+
params?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ChannelMeta {
|
|
63
|
+
id: string;
|
|
64
|
+
label: string;
|
|
65
|
+
selectionLabel?: string;
|
|
66
|
+
docsPath?: string;
|
|
67
|
+
docsLabel?: string;
|
|
68
|
+
blurb?: string;
|
|
69
|
+
aliases?: string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ChannelCapabilities {
|
|
73
|
+
chatTypes: readonly ('direct' | 'group')[];
|
|
74
|
+
media?: boolean;
|
|
75
|
+
threads?: boolean;
|
|
76
|
+
reactions?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ChannelAccount {
|
|
80
|
+
accountId: string;
|
|
81
|
+
enabled?: boolean;
|
|
82
|
+
configured?: boolean;
|
|
83
|
+
config?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface DmPolicyResult {
|
|
87
|
+
policy: string;
|
|
88
|
+
allowFrom: string[];
|
|
89
|
+
policyPath: string;
|
|
90
|
+
allowFromPath: string;
|
|
91
|
+
approveHint: string;
|
|
92
|
+
normalizeEntry: (raw: string) => string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface NormalizeTargetResult {
|
|
96
|
+
target: string;
|
|
97
|
+
normalized: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SendResult {
|
|
101
|
+
ok: boolean;
|
|
102
|
+
error?: string;
|
|
103
|
+
messageId?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface ChannelPlugin {
|
|
107
|
+
id: string;
|
|
108
|
+
meta: ChannelMeta;
|
|
109
|
+
capabilities: ChannelCapabilities;
|
|
110
|
+
config: {
|
|
111
|
+
listAccountIds: (cfg: Record<string, unknown>) => string[];
|
|
112
|
+
resolveAccount: (cfg: Record<string, unknown>, accountId?: string) => ChannelAccount;
|
|
113
|
+
defaultAccountId?: (cfg: Record<string, unknown>) => string;
|
|
114
|
+
isConfigured?: (account: ChannelAccount) => boolean;
|
|
115
|
+
describeAccount?: (account: ChannelAccount) => Record<string, unknown>;
|
|
116
|
+
};
|
|
117
|
+
security?: {
|
|
118
|
+
resolveDmPolicy?: (ctx: { cfg: Record<string, unknown>; account: ChannelAccount }) => DmPolicyResult;
|
|
119
|
+
};
|
|
120
|
+
messaging?: {
|
|
121
|
+
normalizeTarget?: (ctx: { target: string; cfg: Record<string, unknown> }) => NormalizeTargetResult;
|
|
122
|
+
targetResolver?: {
|
|
123
|
+
looksLikeId: (target: string) => boolean;
|
|
124
|
+
hint: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
outbound?: {
|
|
128
|
+
deliveryMode: 'direct' | 'queued';
|
|
129
|
+
sendText: (ctx: {
|
|
130
|
+
text: string;
|
|
131
|
+
target: string;
|
|
132
|
+
cfg: Record<string, unknown>;
|
|
133
|
+
account: ChannelAccount;
|
|
134
|
+
}) => Promise<SendResult>;
|
|
135
|
+
sendMedia?: (ctx: {
|
|
136
|
+
media: { type: string; buffer: Buffer; filename?: string };
|
|
137
|
+
target: string;
|
|
138
|
+
cfg: Record<string, unknown>;
|
|
139
|
+
account: ChannelAccount;
|
|
140
|
+
}) => Promise<SendResult>;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface PluginApi {
|
|
145
|
+
logger: Logger;
|
|
146
|
+
config: unknown;
|
|
147
|
+
registerChannel: (opts: { plugin: ChannelPlugin }) => void;
|
|
148
|
+
registerService: (service: ServiceDefinition) => void;
|
|
149
|
+
registerHttpHandler: (handler: HttpHandler) => void;
|
|
150
|
+
registerGatewayMethod: (
|
|
151
|
+
name: string,
|
|
152
|
+
handler: (ctx: GatewayMethodContext) => Promise<void> | void
|
|
153
|
+
) => void;
|
|
154
|
+
injectMessage: (opts: InjectMessageOptions) => Promise<void>;
|
|
155
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"noImplicitAny": true,
|
|
18
|
+
"strictNullChecks": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noImplicitReturns": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true
|
|
23
|
+
},
|
|
24
|
+
"include": ["src/**/*"],
|
|
25
|
+
"exclude": ["node_modules", "dist"]
|
|
26
|
+
}
|