@2en/clawly-plugins 1.24.2 → 1.24.3
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/command/clawly_echo.ts +1 -1
- package/command/index.ts +1 -1
- package/gateway/agent.ts +1 -1
- package/gateway/clawhub2gateway.ts +1 -1
- package/gateway/config-repair.ts +1 -1
- package/gateway/index.ts +1 -1
- package/gateway/inject.ts +1 -1
- package/gateway/memory.ts +1 -1
- package/gateway/notification.ts +1 -1
- package/gateway/offline-push.test.ts +1 -1
- package/gateway/offline-push.ts +1 -1
- package/gateway/pairing.ts +1 -1
- package/gateway/plugins.ts +1 -1
- package/gateway/presence.ts +1 -1
- package/gateway/version.ts +9 -1
- package/index.ts +8 -129
- package/internal/hooks/auto-update.ts +1 -1
- package/package.json +3 -1
- package/tools/clawly-is-user-online.ts +1 -1
- package/tools/clawly-send-app-push.ts +1 -1
- package/tools/clawly-send-message.ts +1 -1
- package/tools/index.ts +1 -1
- package/types/openclaw.ts +963 -0
- package/types.ts +131 -0
package/types.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Types aligned with OpenClaw plugin API (openclaw/src/plugins/types.ts)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type {OpenClawConfig} from './types/openclaw'
|
|
6
|
+
|
|
7
|
+
export type PluginLogger = {
|
|
8
|
+
debug?: (message: string) => void
|
|
9
|
+
info: (message: string) => void
|
|
10
|
+
warn: (message: string) => void
|
|
11
|
+
error: (message: string) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type PluginRuntime = {
|
|
15
|
+
version?: string
|
|
16
|
+
config?: {
|
|
17
|
+
loadConfig?: (...args: unknown[]) => unknown
|
|
18
|
+
writeConfigFile?: (...args: unknown[]) => unknown
|
|
19
|
+
}
|
|
20
|
+
system?: {
|
|
21
|
+
runCommandWithTimeout?: (
|
|
22
|
+
argv: string[],
|
|
23
|
+
opts: {timeoutMs: number; cwd?: string; env?: Record<string, string | undefined>},
|
|
24
|
+
) => Promise<{
|
|
25
|
+
stdout: string
|
|
26
|
+
stderr: string
|
|
27
|
+
code: number | null
|
|
28
|
+
signal: string | null
|
|
29
|
+
killed: boolean
|
|
30
|
+
}>
|
|
31
|
+
}
|
|
32
|
+
state?: {
|
|
33
|
+
resolveStateDir?: (env?: NodeJS.ProcessEnv) => string
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type GatewayRequestHandler = (opts: {
|
|
38
|
+
params: Record<string, unknown>
|
|
39
|
+
respond: (ok: boolean, payload?: unknown, error?: {code?: string; message?: string}) => void
|
|
40
|
+
}) => Promise<void> | void
|
|
41
|
+
|
|
42
|
+
export type PluginHookName =
|
|
43
|
+
| 'before_agent_start'
|
|
44
|
+
| 'agent_end'
|
|
45
|
+
| 'before_compaction'
|
|
46
|
+
| 'after_compaction'
|
|
47
|
+
| 'before_reset'
|
|
48
|
+
| 'message_received'
|
|
49
|
+
| 'message_sending'
|
|
50
|
+
| 'message_sent'
|
|
51
|
+
| 'before_tool_call'
|
|
52
|
+
| 'after_tool_call'
|
|
53
|
+
| 'tool_result_persist'
|
|
54
|
+
| 'session_start'
|
|
55
|
+
| 'session_end'
|
|
56
|
+
| 'gateway_start'
|
|
57
|
+
| 'gateway_stop'
|
|
58
|
+
|
|
59
|
+
export type PluginApi = {
|
|
60
|
+
/** id from openclaw.plugin.json */
|
|
61
|
+
id: string
|
|
62
|
+
/** name from openclaw.plugin.json */
|
|
63
|
+
name: string
|
|
64
|
+
/** version from openclaw.plugin.json */
|
|
65
|
+
version?: string
|
|
66
|
+
/** description from openclaw.plugin.json */
|
|
67
|
+
description?: string
|
|
68
|
+
source?: string
|
|
69
|
+
config?: OpenClawConfig
|
|
70
|
+
pluginConfig?: Record<string, unknown>
|
|
71
|
+
runtime: PluginRuntime
|
|
72
|
+
logger: PluginLogger
|
|
73
|
+
registerGatewayMethod: (method: string, handler: GatewayRequestHandler) => void
|
|
74
|
+
registerTool: (
|
|
75
|
+
tool: {
|
|
76
|
+
name: string
|
|
77
|
+
description: string
|
|
78
|
+
parameters: Record<string, unknown>
|
|
79
|
+
execute: (
|
|
80
|
+
toolCallId: string,
|
|
81
|
+
params: Record<string, unknown>,
|
|
82
|
+
) => Promise<{content: Array<{type: string; text: string}>; details?: unknown}>
|
|
83
|
+
},
|
|
84
|
+
opts?: {optional?: boolean},
|
|
85
|
+
) => void
|
|
86
|
+
registerHook?: (
|
|
87
|
+
events: string | string[],
|
|
88
|
+
handler: (...args: unknown[]) => unknown,
|
|
89
|
+
opts?: {name?: string; description?: string; register?: boolean},
|
|
90
|
+
) => void
|
|
91
|
+
registerCommand: (cmd: {
|
|
92
|
+
name: string
|
|
93
|
+
description?: string
|
|
94
|
+
acceptsArgs?: boolean
|
|
95
|
+
requireAuth?: boolean
|
|
96
|
+
handler: (ctx: {
|
|
97
|
+
args?: string
|
|
98
|
+
[key: string]: unknown
|
|
99
|
+
}) => Promise<{text: string}> | {text: string}
|
|
100
|
+
}) => void
|
|
101
|
+
registerChannel: (registration: {plugin: unknown; dock?: unknown}) => void
|
|
102
|
+
registerHttpHandler?: (
|
|
103
|
+
handler: (
|
|
104
|
+
req: import('node:http').IncomingMessage,
|
|
105
|
+
res: import('node:http').ServerResponse,
|
|
106
|
+
) => Promise<boolean> | boolean,
|
|
107
|
+
) => void
|
|
108
|
+
registerHttpRoute: (params: {
|
|
109
|
+
path: string
|
|
110
|
+
handler: (
|
|
111
|
+
req: import('node:http').IncomingMessage,
|
|
112
|
+
res: import('node:http').ServerResponse,
|
|
113
|
+
) => Promise<void> | void
|
|
114
|
+
}) => void
|
|
115
|
+
registerCli?: (
|
|
116
|
+
registrar: (...args: unknown[]) => void | Promise<void>,
|
|
117
|
+
opts?: {commands?: string[]},
|
|
118
|
+
) => void
|
|
119
|
+
registerService?: (service: {
|
|
120
|
+
id: string
|
|
121
|
+
start: (...args: unknown[]) => void | Promise<void>
|
|
122
|
+
stop?: (...args: unknown[]) => void | Promise<void>
|
|
123
|
+
}) => void
|
|
124
|
+
registerProvider?: (provider: Record<string, unknown>) => void
|
|
125
|
+
resolvePath?: (input: string) => string
|
|
126
|
+
on: (
|
|
127
|
+
hookName: PluginHookName | (string & {}),
|
|
128
|
+
handler: (...args: any[]) => any,
|
|
129
|
+
opts?: {priority?: number},
|
|
130
|
+
) => void
|
|
131
|
+
}
|