@nextclaw/openclaw-compat 0.1.1

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +462 -0
  2. package/dist/index.js +1835 -0
  3. package/package.json +41 -0
@@ -0,0 +1,462 @@
1
+ import { Config } from '@nextclaw/core';
2
+
3
+ type PluginConfigUiHint = {
4
+ label?: string;
5
+ help?: string;
6
+ advanced?: boolean;
7
+ sensitive?: boolean;
8
+ placeholder?: string;
9
+ };
10
+ type PluginKind = string;
11
+ type PluginManifest = {
12
+ id: string;
13
+ configSchema: Record<string, unknown>;
14
+ kind?: PluginKind;
15
+ channels?: string[];
16
+ providers?: string[];
17
+ skills?: string[];
18
+ name?: string;
19
+ description?: string;
20
+ version?: string;
21
+ uiHints?: Record<string, PluginConfigUiHint>;
22
+ };
23
+ type PluginManifestLoadResult = {
24
+ ok: true;
25
+ manifest: PluginManifest;
26
+ manifestPath: string;
27
+ } | {
28
+ ok: false;
29
+ error: string;
30
+ manifestPath: string;
31
+ };
32
+ type OpenClawPluginTool = {
33
+ label?: string;
34
+ name: string;
35
+ description?: string;
36
+ parameters: Record<string, unknown>;
37
+ execute: ((toolCallId: string, params: Record<string, unknown>) => Promise<unknown> | unknown) | ((params: Record<string, unknown>) => Promise<unknown> | unknown);
38
+ };
39
+ type OpenClawPluginToolContext = {
40
+ config?: Config;
41
+ workspaceDir?: string;
42
+ sessionKey?: string;
43
+ channel?: string;
44
+ chatId?: string;
45
+ sandboxed?: boolean;
46
+ };
47
+ type OpenClawPluginToolFactory = (ctx: OpenClawPluginToolContext) => OpenClawPluginTool | OpenClawPluginTool[] | null | undefined;
48
+ type OpenClawPluginToolOptions = {
49
+ name?: string;
50
+ names?: string[];
51
+ optional?: boolean;
52
+ };
53
+ type OpenClawProviderPlugin = {
54
+ id: string;
55
+ label?: string;
56
+ docsPath?: string;
57
+ aliases?: string[];
58
+ envVars?: string[];
59
+ models?: Record<string, unknown>;
60
+ auth?: Array<Record<string, unknown>>;
61
+ };
62
+ type OpenClawChannelPlugin = {
63
+ id: string;
64
+ meta?: Record<string, unknown>;
65
+ capabilities?: Record<string, unknown>;
66
+ outbound?: {
67
+ sendText?: (ctx: {
68
+ cfg: Config;
69
+ to: string;
70
+ text: string;
71
+ accountId?: string | null;
72
+ }) => Promise<unknown> | unknown;
73
+ sendPayload?: (ctx: {
74
+ cfg: Config;
75
+ to: string;
76
+ text: string;
77
+ payload: unknown;
78
+ accountId?: string | null;
79
+ }) => Promise<unknown> | unknown;
80
+ };
81
+ };
82
+ type OpenClawPluginChannelRegistration = OpenClawChannelPlugin | {
83
+ plugin: OpenClawChannelPlugin;
84
+ };
85
+ type OpenClawPluginDefinition = {
86
+ id?: string;
87
+ name?: string;
88
+ description?: string;
89
+ version?: string;
90
+ kind?: PluginKind;
91
+ register?: (api: OpenClawPluginApi) => void | Promise<void>;
92
+ activate?: (api: OpenClawPluginApi) => void | Promise<void>;
93
+ };
94
+ type OpenClawPluginModule = OpenClawPluginDefinition | ((api: OpenClawPluginApi) => void | Promise<void>);
95
+ type PluginLogger = {
96
+ debug?: (message: string) => void;
97
+ info: (message: string) => void;
98
+ warn: (message: string) => void;
99
+ error: (message: string) => void;
100
+ };
101
+ type PluginOrigin = "bundled" | "global" | "workspace" | "config";
102
+ type PluginDiagnostic = {
103
+ level: "warn" | "error";
104
+ message: string;
105
+ pluginId?: string;
106
+ source?: string;
107
+ };
108
+ type PluginRecord = {
109
+ id: string;
110
+ name: string;
111
+ version?: string;
112
+ description?: string;
113
+ kind?: PluginKind;
114
+ source: string;
115
+ origin: PluginOrigin;
116
+ workspaceDir?: string;
117
+ enabled: boolean;
118
+ status: "loaded" | "disabled" | "error";
119
+ error?: string;
120
+ toolNames: string[];
121
+ channelIds: string[];
122
+ providerIds: string[];
123
+ configSchema: boolean;
124
+ configUiHints?: Record<string, PluginConfigUiHint>;
125
+ configJsonSchema?: Record<string, unknown>;
126
+ };
127
+ type PluginToolRegistration = {
128
+ pluginId: string;
129
+ factory: OpenClawPluginToolFactory;
130
+ names: string[];
131
+ optional: boolean;
132
+ source: string;
133
+ };
134
+ type PluginChannelRegistration = {
135
+ pluginId: string;
136
+ channel: OpenClawChannelPlugin;
137
+ source: string;
138
+ };
139
+ type PluginProviderRegistration = {
140
+ pluginId: string;
141
+ provider: OpenClawProviderPlugin;
142
+ source: string;
143
+ };
144
+ type PluginRuntime = {
145
+ version: string;
146
+ tools: {
147
+ createMemorySearchTool: (params: {
148
+ config?: Config;
149
+ agentSessionKey?: string;
150
+ }) => OpenClawPluginTool | null;
151
+ createMemoryGetTool: (params: {
152
+ config?: Config;
153
+ agentSessionKey?: string;
154
+ }) => OpenClawPluginTool | null;
155
+ };
156
+ };
157
+ type OpenClawPluginApi = {
158
+ id: string;
159
+ name: string;
160
+ version?: string;
161
+ description?: string;
162
+ source: string;
163
+ config: Config;
164
+ pluginConfig?: Record<string, unknown>;
165
+ runtime: PluginRuntime;
166
+ logger: PluginLogger;
167
+ registerTool: (tool: OpenClawPluginTool | OpenClawPluginToolFactory, opts?: OpenClawPluginToolOptions) => void;
168
+ registerChannel: (registration: OpenClawPluginChannelRegistration) => void;
169
+ registerProvider: (provider: OpenClawProviderPlugin) => void;
170
+ registerHook: (_events: string | string[], _handler: unknown, _opts?: unknown) => void;
171
+ registerGatewayMethod: (_method: string, _handler: unknown) => void;
172
+ registerCli: (_registrar: unknown, _opts?: unknown) => void;
173
+ registerService: (_service: unknown) => void;
174
+ registerCommand: (_command: unknown) => void;
175
+ registerHttpHandler: (_handler: unknown) => void;
176
+ registerHttpRoute: (_params: {
177
+ path: string;
178
+ handler: unknown;
179
+ }) => void;
180
+ resolvePath: (input: string) => string;
181
+ };
182
+ type PluginRegistry = {
183
+ plugins: PluginRecord[];
184
+ tools: PluginToolRegistration[];
185
+ channels: PluginChannelRegistration[];
186
+ providers: PluginProviderRegistration[];
187
+ diagnostics: PluginDiagnostic[];
188
+ resolvedTools: OpenClawPluginTool[];
189
+ };
190
+ type PluginUiMetadata = {
191
+ id: string;
192
+ configSchema?: Record<string, unknown>;
193
+ configUiHints?: Record<string, PluginConfigUiHint>;
194
+ };
195
+
196
+ type OpenClawPluginConfigSchema = {
197
+ type: "object";
198
+ additionalProperties: boolean;
199
+ properties: Record<string, unknown>;
200
+ };
201
+ declare function emptyPluginConfigSchema(): OpenClawPluginConfigSchema;
202
+ declare function buildChannelConfigSchema(schema: Record<string, unknown>): Record<string, unknown>;
203
+ declare function buildOauthProviderAuthResult(params: {
204
+ providerId: string;
205
+ defaultModel?: string;
206
+ access: string;
207
+ refresh?: string;
208
+ expires?: string | number;
209
+ email?: string;
210
+ credentialExtra?: Record<string, unknown>;
211
+ notes?: string[];
212
+ }): {
213
+ profiles: Array<{
214
+ profileId: string;
215
+ credential: Record<string, unknown>;
216
+ }>;
217
+ defaultModel?: string;
218
+ notes?: string[];
219
+ };
220
+ declare function sleep(ms: number): Promise<void>;
221
+ declare function normalizePluginHttpPath(rawPath: string): string;
222
+ declare const DEFAULT_ACCOUNT_ID = "default";
223
+ declare function normalizeAccountId(accountId?: string | null): string;
224
+ declare const __nextclawPluginSdkCompat = true;
225
+ type _CompatOnly = OpenClawPluginApi;
226
+
227
+ type NormalizedPluginsConfig = {
228
+ enabled: boolean;
229
+ allow: string[];
230
+ deny: string[];
231
+ loadPaths: string[];
232
+ entries: Record<string, {
233
+ enabled?: boolean;
234
+ config?: unknown;
235
+ }>;
236
+ };
237
+ declare function normalizePluginsConfig(plugins: Config["plugins"] | undefined): NormalizedPluginsConfig;
238
+ declare function resolveEnableState(id: string, config: NormalizedPluginsConfig): {
239
+ enabled: boolean;
240
+ reason?: string;
241
+ };
242
+ type PluginInstallSource = "npm" | "archive" | "path";
243
+ type PluginInstallUpdate = {
244
+ pluginId: string;
245
+ source: PluginInstallSource;
246
+ spec?: string;
247
+ sourcePath?: string;
248
+ installPath?: string;
249
+ version?: string;
250
+ installedAt?: string;
251
+ };
252
+ declare function recordPluginInstall(config: Config, update: PluginInstallUpdate): Config;
253
+ declare function enablePluginInConfig(config: Config, pluginId: string): Config;
254
+ declare function disablePluginInConfig(config: Config, pluginId: string): Config;
255
+ declare function addPluginLoadPath(config: Config, loadPath: string): Config;
256
+
257
+ type PluginCandidate = {
258
+ idHint: string;
259
+ source: string;
260
+ rootDir: string;
261
+ origin: PluginOrigin;
262
+ workspaceDir?: string;
263
+ packageName?: string;
264
+ packageVersion?: string;
265
+ packageDescription?: string;
266
+ packageDir?: string;
267
+ };
268
+ type PluginDiscoveryResult = {
269
+ candidates: PluginCandidate[];
270
+ diagnostics: PluginDiagnostic[];
271
+ };
272
+ declare function discoverOpenClawPlugins(params: {
273
+ config?: Config;
274
+ workspaceDir?: string;
275
+ extraPaths?: string[];
276
+ }): PluginDiscoveryResult;
277
+
278
+ type PluginInstallLogger = {
279
+ info?: (message: string) => void;
280
+ warn?: (message: string) => void;
281
+ };
282
+ type InstallPluginResult = {
283
+ ok: true;
284
+ pluginId: string;
285
+ targetDir: string;
286
+ manifestName?: string;
287
+ version?: string;
288
+ extensions: string[];
289
+ } | {
290
+ ok: false;
291
+ error: string;
292
+ };
293
+ declare function resolvePluginInstallDir(pluginId: string, extensionsDir?: string): string;
294
+ declare function installPluginFromArchive(params: {
295
+ archivePath: string;
296
+ extensionsDir?: string;
297
+ logger?: PluginInstallLogger;
298
+ mode?: "install" | "update";
299
+ dryRun?: boolean;
300
+ expectedPluginId?: string;
301
+ }): Promise<InstallPluginResult>;
302
+ declare function installPluginFromDir(params: {
303
+ dirPath: string;
304
+ extensionsDir?: string;
305
+ logger?: PluginInstallLogger;
306
+ mode?: "install" | "update";
307
+ dryRun?: boolean;
308
+ expectedPluginId?: string;
309
+ }): Promise<InstallPluginResult>;
310
+ declare function installPluginFromFile(params: {
311
+ filePath: string;
312
+ extensionsDir?: string;
313
+ logger?: PluginInstallLogger;
314
+ mode?: "install" | "update";
315
+ dryRun?: boolean;
316
+ }): Promise<InstallPluginResult>;
317
+ declare function installPluginFromNpmSpec(params: {
318
+ spec: string;
319
+ extensionsDir?: string;
320
+ logger?: PluginInstallLogger;
321
+ mode?: "install" | "update";
322
+ dryRun?: boolean;
323
+ expectedPluginId?: string;
324
+ }): Promise<InstallPluginResult>;
325
+ declare function installPluginFromPath(params: {
326
+ path: string;
327
+ extensionsDir?: string;
328
+ logger?: PluginInstallLogger;
329
+ mode?: "install" | "update";
330
+ dryRun?: boolean;
331
+ expectedPluginId?: string;
332
+ }): Promise<InstallPluginResult>;
333
+
334
+ type PluginLoadOptions = {
335
+ config: Config;
336
+ workspaceDir?: string;
337
+ logger?: PluginLogger;
338
+ mode?: "full" | "validate";
339
+ reservedToolNames?: string[];
340
+ reservedChannelIds?: string[];
341
+ reservedProviderIds?: string[];
342
+ };
343
+ declare function loadOpenClawPlugins(options: PluginLoadOptions): PluginRegistry;
344
+
345
+ type PluginManifestRecord = {
346
+ id: string;
347
+ name?: string;
348
+ description?: string;
349
+ version?: string;
350
+ kind?: PluginKind;
351
+ channels: string[];
352
+ providers: string[];
353
+ skills: string[];
354
+ origin: PluginOrigin;
355
+ workspaceDir?: string;
356
+ rootDir: string;
357
+ source: string;
358
+ manifestPath: string;
359
+ schemaCacheKey?: string;
360
+ configSchema?: Record<string, unknown>;
361
+ configUiHints?: Record<string, PluginConfigUiHint>;
362
+ };
363
+ type PluginManifestRegistry = {
364
+ plugins: PluginManifestRecord[];
365
+ diagnostics: PluginDiagnostic[];
366
+ };
367
+ declare function loadPluginManifestRegistry(params: {
368
+ config?: Config;
369
+ workspaceDir?: string;
370
+ candidates?: PluginCandidate[];
371
+ diagnostics?: PluginDiagnostic[];
372
+ }): PluginManifestRegistry;
373
+ declare function toPluginUiMetadata(records: PluginManifestRecord[]): PluginUiMetadata[];
374
+ declare function loadPluginUiMetadata(params: {
375
+ config?: Config;
376
+ workspaceDir?: string;
377
+ }): PluginUiMetadata[];
378
+
379
+ declare const PLUGIN_MANIFEST_FILENAME = "openclaw.plugin.json";
380
+ declare const PLUGIN_MANIFEST_FILENAMES: readonly ["openclaw.plugin.json"];
381
+ declare function resolvePluginManifestPath(rootDir: string): string;
382
+ declare function loadPluginManifest(rootDir: string): PluginManifestLoadResult;
383
+ type OpenClawPackageManifest = {
384
+ extensions?: string[];
385
+ install?: {
386
+ npmSpec?: string;
387
+ localPath?: string;
388
+ defaultChoice?: "npm" | "local";
389
+ };
390
+ };
391
+ type PackageManifest = {
392
+ name?: string;
393
+ version?: string;
394
+ description?: string;
395
+ openclaw?: OpenClawPackageManifest;
396
+ };
397
+ declare function getPackageManifestMetadata(manifest: PackageManifest | undefined): OpenClawPackageManifest | undefined;
398
+
399
+ declare function createPluginRuntime(params: {
400
+ workspace: string;
401
+ config?: Config;
402
+ }): PluginRuntime;
403
+
404
+ declare function validateJsonSchemaValue(params: {
405
+ schema: Record<string, unknown>;
406
+ cacheKey: string;
407
+ value: unknown;
408
+ }): {
409
+ ok: true;
410
+ } | {
411
+ ok: false;
412
+ errors: string[];
413
+ };
414
+
415
+ type PluginStatusReport = PluginRegistry & {
416
+ workspaceDir: string;
417
+ };
418
+ declare function buildPluginStatusReport(params: {
419
+ config: Config;
420
+ workspaceDir?: string;
421
+ logger?: PluginLogger;
422
+ reservedToolNames?: string[];
423
+ reservedChannelIds?: string[];
424
+ reservedProviderIds?: string[];
425
+ }): PluginStatusReport;
426
+
427
+ type UninstallActions = {
428
+ entry: boolean;
429
+ install: boolean;
430
+ allowlist: boolean;
431
+ loadPath: boolean;
432
+ directory: boolean;
433
+ };
434
+ type PluginInstallRecord = NonNullable<Config["plugins"]["installs"]>[string];
435
+ type UninstallPluginResult = {
436
+ ok: true;
437
+ config: Config;
438
+ pluginId: string;
439
+ actions: UninstallActions;
440
+ warnings: string[];
441
+ } | {
442
+ ok: false;
443
+ error: string;
444
+ };
445
+ declare function resolveUninstallDirectoryTarget(params: {
446
+ pluginId: string;
447
+ hasInstall: boolean;
448
+ installRecord?: PluginInstallRecord;
449
+ extensionsDir?: string;
450
+ }): string | null;
451
+ declare function removePluginFromConfig(config: Config, pluginId: string): {
452
+ config: Config;
453
+ actions: Omit<UninstallActions, "directory">;
454
+ };
455
+ declare function uninstallPlugin(params: {
456
+ config: Config;
457
+ pluginId: string;
458
+ deleteFiles?: boolean;
459
+ extensionsDir?: string;
460
+ }): Promise<UninstallPluginResult>;
461
+
462
+ export { DEFAULT_ACCOUNT_ID, type InstallPluginResult, type NormalizedPluginsConfig, type OpenClawChannelPlugin, type OpenClawPluginApi, type OpenClawPluginChannelRegistration, type OpenClawPluginConfigSchema, type OpenClawPluginDefinition, type OpenClawPluginModule, type OpenClawPluginTool, type OpenClawPluginToolContext, type OpenClawPluginToolFactory, type OpenClawPluginToolOptions, type OpenClawProviderPlugin, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PackageManifest, type PluginCandidate, type PluginChannelRegistration, type PluginConfigUiHint, type PluginDiagnostic, type PluginDiscoveryResult, type PluginInstallLogger, type PluginInstallSource, type PluginInstallUpdate, type PluginKind, type PluginLoadOptions, type PluginLogger, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRecord, type PluginManifestRegistry, type PluginOrigin, type PluginProviderRegistration, type PluginRecord, type PluginRegistry, type PluginRuntime, type PluginStatusReport, type PluginToolRegistration, type PluginUiMetadata, type UninstallActions, type UninstallPluginResult, type _CompatOnly, __nextclawPluginSdkCompat, addPluginLoadPath, buildChannelConfigSchema, buildOauthProviderAuthResult, buildPluginStatusReport, createPluginRuntime, disablePluginInConfig, discoverOpenClawPlugins, emptyPluginConfigSchema, enablePluginInConfig, getPackageManifestMetadata, installPluginFromArchive, installPluginFromDir, installPluginFromFile, installPluginFromNpmSpec, installPluginFromPath, loadOpenClawPlugins, loadPluginManifest, loadPluginManifestRegistry, loadPluginUiMetadata, normalizeAccountId, normalizePluginHttpPath, normalizePluginsConfig, recordPluginInstall, removePluginFromConfig, resolveEnableState, resolvePluginInstallDir, resolvePluginManifestPath, resolveUninstallDirectoryTarget, sleep, toPluginUiMetadata, uninstallPlugin, validateJsonSchemaValue };