@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/src/types.ts CHANGED
@@ -79,37 +79,7 @@ export type ConnectionState =
79
79
  | "connected"
80
80
  | "disconnecting";
81
81
 
82
- // --- OpenClaw Plugin API (minimal type surface) ---
82
+ // --- OpenClaw Plugin API (re-export from SDK) ---
83
83
 
84
- export interface PluginApi {
85
- registerChannel(opts: { plugin: unknown }): void;
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/core.
5
+ * Type declarations for openclaw/plugin-sdk.
6
6
  *
7
- * These types provide the minimal interface needed for the setup entry point.
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
- export interface PromptOptions {
13
- type: "text" | "password" | "confirm" | "select";
14
- message: string;
15
- default?: string | boolean;
16
- validate?: (value: string) => boolean | string;
17
- }
18
-
19
- export interface SetupContext {
20
- prompt: (options: PromptOptions) => Promise<string>;
21
- updateConfig: (key: string, value: string | boolean | number) => Promise<void>;
22
- }
23
-
24
- export interface SetupPluginEntry {
25
- onSetup: (context: SetupContext) => Promise<void>;
26
- }
27
-
28
- export function defineSetupPluginEntry(entry: SetupPluginEntry): SetupPluginEntry;
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
  }