@ebowwa/channel-types 0.1.0 → 0.2.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/dist/config.d.ts +13 -1
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +5 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/registry.d.ts +100 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +150 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/types.adapters.d.ts +126 -0
- package/dist/plugins/types.adapters.d.ts.map +1 -0
- package/dist/plugins/types.adapters.js +3 -0
- package/dist/plugins/types.adapters.js.map +1 -0
- package/dist/plugins/types.core.d.ts +82 -0
- package/dist/plugins/types.core.d.ts.map +1 -0
- package/dist/plugins/types.core.js +51 -0
- package/dist/plugins/types.core.js.map +1 -0
- package/dist/plugins/types.plugin.d.ts +141 -0
- package/dist/plugins/types.plugin.d.ts.map +1 -0
- package/dist/plugins/types.plugin.js +3 -0
- package/dist/plugins/types.plugin.js.map +1 -0
- package/package.json +17 -3
- package/src/config.js +270 -0
- package/src/config.ts +32 -1
- package/src/example.js +431 -0
- package/src/index.js +76 -0
- package/src/index.ts +5 -0
- package/src/plugins/index.ts +5 -0
- package/src/plugins/registry.ts +232 -0
- package/src/plugins/types.adapters.ts +183 -0
- package/src/plugins/types.core.ts +161 -0
- package/src/plugins/types.plugin.ts +227 -0
- package/tsconfig.json +0 -20
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// src/plugins/types.plugin.ts
|
|
2
|
+
|
|
3
|
+
import type { ChannelId } from "../index.js";
|
|
4
|
+
import type {
|
|
5
|
+
ChannelConfigAdapter,
|
|
6
|
+
ChannelOutboundAdapter,
|
|
7
|
+
ChannelGatewayAdapter,
|
|
8
|
+
ChannelStatusAdapter,
|
|
9
|
+
ChannelThreadingAdapter,
|
|
10
|
+
ChannelMessagingAdapter,
|
|
11
|
+
ChannelOnboardingAdapter,
|
|
12
|
+
} from "./types.adapters.js";
|
|
13
|
+
|
|
14
|
+
// ============================================================
|
|
15
|
+
// CHANNEL META
|
|
16
|
+
// ============================================================
|
|
17
|
+
|
|
18
|
+
export interface ChannelMeta {
|
|
19
|
+
/** Human-readable label */
|
|
20
|
+
label: string;
|
|
21
|
+
|
|
22
|
+
/** Short description */
|
|
23
|
+
blurb?: string;
|
|
24
|
+
|
|
25
|
+
/** Path to documentation */
|
|
26
|
+
docsPath?: string;
|
|
27
|
+
|
|
28
|
+
/** Icon (emoji or URL) */
|
|
29
|
+
icon?: string;
|
|
30
|
+
|
|
31
|
+
/** System image for UI */
|
|
32
|
+
systemImage?: string;
|
|
33
|
+
|
|
34
|
+
/** Allow quickstart from this channel */
|
|
35
|
+
quickstartAllowFrom?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ============================================================
|
|
39
|
+
// CHANNEL CAPABILITIES
|
|
40
|
+
// ============================================================
|
|
41
|
+
|
|
42
|
+
export interface ChannelCapabilities {
|
|
43
|
+
/** Supported chat types */
|
|
44
|
+
chatTypes: ("direct" | "group" | "channel" | "thread")[];
|
|
45
|
+
|
|
46
|
+
/** Feature flags */
|
|
47
|
+
supports: {
|
|
48
|
+
text: boolean;
|
|
49
|
+
media: boolean;
|
|
50
|
+
replies: boolean;
|
|
51
|
+
threads: boolean;
|
|
52
|
+
reactions: boolean;
|
|
53
|
+
editing: boolean;
|
|
54
|
+
streaming: boolean;
|
|
55
|
+
polls?: boolean;
|
|
56
|
+
buttons?: boolean;
|
|
57
|
+
cards?: boolean;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Native commands (e.g., /help) */
|
|
61
|
+
nativeCommands?: boolean;
|
|
62
|
+
|
|
63
|
+
/** Block streaming (some channels don't support it) */
|
|
64
|
+
blockStreaming?: boolean;
|
|
65
|
+
|
|
66
|
+
/** Media constraints */
|
|
67
|
+
media?: {
|
|
68
|
+
maxFileSize?: number;
|
|
69
|
+
supportedMimeTypes?: string[];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Rate limits */
|
|
73
|
+
rateLimits?: {
|
|
74
|
+
messagesPerMinute?: number;
|
|
75
|
+
charactersPerMessage?: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ============================================================
|
|
80
|
+
// CHANNEL PLUGIN (OpenClaw Pattern)
|
|
81
|
+
// ============================================================
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Channel plugin interface following OpenClaw adapter pattern.
|
|
85
|
+
* Composable adapters for different channel capabilities.
|
|
86
|
+
*/
|
|
87
|
+
export interface ChannelPlugin<ResolvedAccount = unknown> {
|
|
88
|
+
/** Unique channel identifier */
|
|
89
|
+
id: string;
|
|
90
|
+
|
|
91
|
+
/** Display metadata */
|
|
92
|
+
meta: ChannelMeta;
|
|
93
|
+
|
|
94
|
+
/** Channel capabilities */
|
|
95
|
+
capabilities: ChannelCapabilities;
|
|
96
|
+
|
|
97
|
+
// Adapters (compose only what you need)
|
|
98
|
+
|
|
99
|
+
/** Account/config management */
|
|
100
|
+
config: ChannelConfigAdapter<ResolvedAccount>;
|
|
101
|
+
|
|
102
|
+
/** Message delivery */
|
|
103
|
+
outbound?: ChannelOutboundAdapter<ResolvedAccount>;
|
|
104
|
+
|
|
105
|
+
/** Account lifecycle (start/stop monitoring) */
|
|
106
|
+
gateway?: ChannelGatewayAdapter<ResolvedAccount>;
|
|
107
|
+
|
|
108
|
+
/** Health probes and audits */
|
|
109
|
+
status?: ChannelStatusAdapter<ResolvedAccount>;
|
|
110
|
+
|
|
111
|
+
/** Threading support */
|
|
112
|
+
threading?: ChannelThreadingAdapter;
|
|
113
|
+
|
|
114
|
+
/** Target normalization */
|
|
115
|
+
messaging?: ChannelMessagingAdapter;
|
|
116
|
+
|
|
117
|
+
/** Setup wizard */
|
|
118
|
+
onboarding?: ChannelOnboardingAdapter;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ============================================================
|
|
122
|
+
// LEGACY PLUGIN TYPES (for backward compatibility)
|
|
123
|
+
// ============================================================
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated Use ChannelPlugin with adapters instead
|
|
127
|
+
*/
|
|
128
|
+
export interface LegacyChannelPlugin {
|
|
129
|
+
/** Unique plugin identifier (e.g., "telegram", "discord") */
|
|
130
|
+
id: string;
|
|
131
|
+
|
|
132
|
+
/** Human-readable name */
|
|
133
|
+
name: string;
|
|
134
|
+
|
|
135
|
+
/** Plugin description */
|
|
136
|
+
description?: string;
|
|
137
|
+
|
|
138
|
+
/** Plugin version */
|
|
139
|
+
version?: string;
|
|
140
|
+
|
|
141
|
+
/** Channel capabilities */
|
|
142
|
+
capabilities: ChannelCapabilities;
|
|
143
|
+
|
|
144
|
+
/** Supported chat types (dm, group, channel, etc.) */
|
|
145
|
+
chatTypes?: string[];
|
|
146
|
+
|
|
147
|
+
/** Create channel connector instance */
|
|
148
|
+
create: (config: unknown) => ChannelConnectorInstance;
|
|
149
|
+
|
|
150
|
+
/** Validate configuration */
|
|
151
|
+
validateConfig?: (config: unknown) => ValidationResult;
|
|
152
|
+
|
|
153
|
+
/** Default configuration template */
|
|
154
|
+
defaultConfig?: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Channel connector instance created by plugin.
|
|
159
|
+
* Minimal interface for runtime channel operations.
|
|
160
|
+
*/
|
|
161
|
+
export interface ChannelConnectorInstance {
|
|
162
|
+
/** Channel ID */
|
|
163
|
+
id: ChannelId;
|
|
164
|
+
|
|
165
|
+
/** Start the connector */
|
|
166
|
+
start(): Promise<void>;
|
|
167
|
+
|
|
168
|
+
/** Stop the connector */
|
|
169
|
+
stop(): Promise<void>;
|
|
170
|
+
|
|
171
|
+
/** Send message */
|
|
172
|
+
send(message: unknown): Promise<void>;
|
|
173
|
+
|
|
174
|
+
/** Check if connected */
|
|
175
|
+
isConnected(): boolean;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ============================================================
|
|
179
|
+
// VALIDATION TYPES
|
|
180
|
+
// ============================================================
|
|
181
|
+
|
|
182
|
+
export interface ValidationResult {
|
|
183
|
+
valid: boolean;
|
|
184
|
+
errors?: string[];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ============================================================
|
|
188
|
+
// PLUGIN LIFECYCLE TYPES
|
|
189
|
+
// ============================================================
|
|
190
|
+
|
|
191
|
+
export interface PluginLifecycle {
|
|
192
|
+
/** Called when plugin is loaded */
|
|
193
|
+
onLoad?(): Promise<void> | void;
|
|
194
|
+
|
|
195
|
+
/** Called when plugin is unloaded */
|
|
196
|
+
onUnload?(): Promise<void> | void;
|
|
197
|
+
|
|
198
|
+
/** Called before channel is created */
|
|
199
|
+
beforeCreate?(config: unknown): Promise<unknown> | unknown;
|
|
200
|
+
|
|
201
|
+
/** Called after channel is created */
|
|
202
|
+
afterCreate?(channel: ChannelConnectorInstance): Promise<void> | void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ============================================================
|
|
206
|
+
// PLUGIN METADATA
|
|
207
|
+
// ============================================================
|
|
208
|
+
|
|
209
|
+
export interface PluginMetadata {
|
|
210
|
+
/** Plugin author */
|
|
211
|
+
author?: string;
|
|
212
|
+
|
|
213
|
+
/** Plugin homepage */
|
|
214
|
+
homepage?: string;
|
|
215
|
+
|
|
216
|
+
/** Plugin repository */
|
|
217
|
+
repository?: string;
|
|
218
|
+
|
|
219
|
+
/** Plugin license */
|
|
220
|
+
license?: string;
|
|
221
|
+
|
|
222
|
+
/** Plugin tags */
|
|
223
|
+
tags?: string[];
|
|
224
|
+
|
|
225
|
+
/** Plugin dependencies */
|
|
226
|
+
dependencies?: string[];
|
|
227
|
+
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"sourceMap": true,
|
|
10
|
-
"outDir": "./dist",
|
|
11
|
-
"rootDir": "./src",
|
|
12
|
-
"strict": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"resolveJsonModule": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|