@cored-im/openclaw-plugin 0.1.3 → 0.1.5
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/index.cjs +196 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -60
- package/dist/index.d.ts +11 -60
- package/dist/index.js +201 -54
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +311 -36
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.d.cts +9 -1
- package/dist/setup-entry.d.ts +9 -1
- package/dist/setup-entry.js +314 -36
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +2 -3
- package/package.json +3 -3
- package/src/channel.ts +152 -4
- package/src/index.test.ts +52 -26
- package/src/index.ts +56 -44
- package/src/messaging/inbound.ts +43 -11
- package/src/setup-entry.ts +2 -46
- package/src/types.ts +3 -33
- package/src/typings/openclaw-plugin-sdk.d.ts +152 -19
package/src/types.ts
CHANGED
|
@@ -79,37 +79,7 @@ export type ConnectionState =
|
|
|
79
79
|
| "connected"
|
|
80
80
|
| "disconnecting";
|
|
81
81
|
|
|
82
|
-
// --- OpenClaw Plugin API (
|
|
82
|
+
// --- OpenClaw Plugin API (re-export from SDK) ---
|
|
83
83
|
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
registerService(opts: {
|
|
87
|
-
id: string;
|
|
88
|
-
start: () => Promise<void>;
|
|
89
|
-
stop: () => Promise<void>;
|
|
90
|
-
}): void;
|
|
91
|
-
config: { channels?: { cored?: CoredChannelConfig } } & Record<
|
|
92
|
-
string,
|
|
93
|
-
unknown
|
|
94
|
-
>;
|
|
95
|
-
runtime: {
|
|
96
|
-
channel: {
|
|
97
|
-
reply: {
|
|
98
|
-
dispatchReplyWithBufferedBlockDispatcher: (opts: unknown) => Promise<void>;
|
|
99
|
-
};
|
|
100
|
-
session: {
|
|
101
|
-
recordInboundSession: (opts: unknown) => Promise<void>;
|
|
102
|
-
resolveStorePath?: (store: unknown, opts: unknown) => string;
|
|
103
|
-
};
|
|
104
|
-
routing: {
|
|
105
|
-
resolveAgentRoute: (opts: unknown) => unknown;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
logger?: {
|
|
110
|
-
info: (msg: string) => void;
|
|
111
|
-
warn: (msg: string) => void;
|
|
112
|
-
error: (msg: string) => void;
|
|
113
|
-
debug: (msg: string) => void;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
84
|
+
// Re-export PluginApi from SDK for convenience
|
|
85
|
+
export type { PluginApi } from "openclaw/plugin-sdk/core";
|
|
@@ -2,28 +2,161 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Type declarations for openclaw/plugin-sdk
|
|
5
|
+
* Type declarations for openclaw/plugin-sdk.
|
|
6
6
|
*
|
|
7
|
-
* These types provide the minimal interface needed for the
|
|
7
|
+
* These types provide the minimal interface needed for the channel plugin.
|
|
8
8
|
* The actual implementation is provided by the OpenClaw runtime at plugin load time.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
declare module "openclaw/plugin-sdk/core" {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export interface OpenClawConfig {
|
|
13
|
+
channels?: Record<string, unknown>;
|
|
14
|
+
plugins?: {
|
|
15
|
+
entries?: Record<string, { enabled?: boolean; config?: unknown }>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ChannelPluginMeta {
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
selectionLabel?: string;
|
|
23
|
+
docsPath?: string;
|
|
24
|
+
blurb?: string;
|
|
25
|
+
aliases?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ChannelPluginCapabilities {
|
|
29
|
+
chatTypes?: readonly ("direct" | "group")[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ResolvedAccountResult {
|
|
33
|
+
ok: true;
|
|
34
|
+
to: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ResolvedAccountError {
|
|
38
|
+
ok: false;
|
|
39
|
+
error: Error;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ResolvedAccount = ResolvedAccountResult | ResolvedAccountError;
|
|
43
|
+
|
|
44
|
+
export interface OutboundAdapter {
|
|
45
|
+
deliveryMode?: "direct" | "queue";
|
|
46
|
+
resolveTarget?: (params: { to?: string }) => ResolvedAccount;
|
|
47
|
+
sendText?: (params: {
|
|
48
|
+
to: string;
|
|
49
|
+
text: string;
|
|
50
|
+
accountId?: string;
|
|
51
|
+
}) => Promise<{ ok: boolean; error?: Error }>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AccountInspection {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
configured: boolean;
|
|
57
|
+
tokenStatus: "available" | "missing" | "invalid";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ChannelSetup {
|
|
61
|
+
resolveAccount: (
|
|
62
|
+
cfg: OpenClawConfig,
|
|
63
|
+
accountId?: string | null,
|
|
64
|
+
) => unknown;
|
|
65
|
+
inspectAccount?: (
|
|
66
|
+
cfg: OpenClawConfig,
|
|
67
|
+
accountId?: string | null,
|
|
68
|
+
) => AccountInspection;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ChannelPluginBase {
|
|
72
|
+
id: string;
|
|
73
|
+
setup?: ChannelSetup;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ChatChannelPlugin<TResolved = unknown> {
|
|
77
|
+
base: ChannelPluginBase;
|
|
78
|
+
meta?: ChannelPluginMeta;
|
|
79
|
+
capabilities?: ChannelPluginCapabilities;
|
|
80
|
+
config?: {
|
|
81
|
+
listAccountIds?: (cfg: unknown) => string[];
|
|
82
|
+
resolveAccount?: (cfg: unknown, accountId?: string) => unknown;
|
|
83
|
+
};
|
|
84
|
+
outbound?: OutboundAdapter;
|
|
85
|
+
setupWizard?: unknown;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface PluginLogger {
|
|
89
|
+
debug?: (msg: string) => void;
|
|
90
|
+
info?: (msg: string) => void;
|
|
91
|
+
warn?: (msg: string) => void;
|
|
92
|
+
error?: (msg: string) => void;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface PluginApi {
|
|
96
|
+
config: OpenClawConfig;
|
|
97
|
+
logger?: PluginLogger;
|
|
98
|
+
pluginConfig?: unknown;
|
|
99
|
+
registrationMode: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
|
|
100
|
+
runtime?: unknown;
|
|
101
|
+
registerChannel(options: { plugin: unknown }): void;
|
|
102
|
+
registerService(service: {
|
|
103
|
+
id: string;
|
|
104
|
+
start: () => Promise<void>;
|
|
105
|
+
stop: () => Promise<void>;
|
|
106
|
+
}): void;
|
|
107
|
+
registerTool(options: unknown): void;
|
|
108
|
+
registerHook(events: string[], handler: unknown): void;
|
|
109
|
+
registerHttpRoute(options: unknown): void;
|
|
110
|
+
registerGatewayMethod(name: string, handler: unknown): void;
|
|
111
|
+
registerCli(registrar: unknown, options?: unknown): void;
|
|
112
|
+
registerCommand(options: unknown): void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type { PluginApi };
|
|
116
|
+
|
|
117
|
+
export interface DefineChannelPluginEntryOptions<TPlugin> {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
description: string;
|
|
121
|
+
plugin: TPlugin;
|
|
122
|
+
configSchema?: unknown;
|
|
123
|
+
setRuntime?: (runtime: unknown) => void;
|
|
124
|
+
registerCliMetadata?: (api: PluginApi) => void;
|
|
125
|
+
registerFull?: (api: PluginApi) => void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface DefinedChannelPluginEntry<TPlugin> {
|
|
129
|
+
plugin: TPlugin;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface DefineSetupPluginEntry<TPlugin> {
|
|
133
|
+
plugin: TPlugin;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function createChannelPluginBase(options: {
|
|
137
|
+
id: string;
|
|
138
|
+
setup: ChannelSetup;
|
|
139
|
+
}): ChannelPluginBase;
|
|
140
|
+
|
|
141
|
+
export function createChatChannelPlugin<TResolved>(options: {
|
|
142
|
+
base: ChannelPluginBase;
|
|
143
|
+
meta?: ChannelPluginMeta;
|
|
144
|
+
capabilities?: ChannelPluginCapabilities;
|
|
145
|
+
config?: {
|
|
146
|
+
listAccountIds?: (cfg: unknown) => string[];
|
|
147
|
+
resolveAccount?: (cfg: unknown, accountId?: string) => unknown;
|
|
148
|
+
};
|
|
149
|
+
outbound?: OutboundAdapter;
|
|
150
|
+
setupWizard?: unknown;
|
|
151
|
+
}): ChatChannelPlugin<TResolved>;
|
|
152
|
+
|
|
153
|
+
export function defineChannelPluginEntry<TPlugin>(
|
|
154
|
+
options: DefineChannelPluginEntryOptions<TPlugin>,
|
|
155
|
+
): DefinedChannelPluginEntry<TPlugin>;
|
|
156
|
+
|
|
157
|
+
export function defineSetupPluginEntry<TPlugin>(
|
|
158
|
+
plugin: TPlugin,
|
|
159
|
+
): DefineSetupPluginEntry<TPlugin>;
|
|
160
|
+
|
|
161
|
+
export function buildChannelConfigSchema(schema: unknown): unknown;
|
|
29
162
|
}
|