@2en/clawly-plugins 1.1.2 → 1.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/index.ts +19 -0
- package/notification.ts +2 -0
- package/package.json +2 -1
- package/tools.ts +2 -0
package/index.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* - clawly.agent.send — send a message to the agent (+ optional push)
|
|
10
10
|
* - clawly.agent.echo — echo-wrapped agent message (bypasses LLM)
|
|
11
11
|
*
|
|
12
|
+
* Agent tools:
|
|
13
|
+
* - clawly_is_user_online — check if user's device is connected
|
|
14
|
+
* - clawly_send_app_push — send a push notification to user's device
|
|
15
|
+
*
|
|
12
16
|
* Commands:
|
|
13
17
|
* - /clawly_echo — echo text back without LLM
|
|
14
18
|
*
|
|
@@ -17,6 +21,7 @@
|
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
23
|
import {registerAgentSend} from './agent-send'
|
|
24
|
+
import {registerIsUserOnlineTool, registerSendAppPushTool} from './tools'
|
|
20
25
|
import {registerEchoCommand} from './echo'
|
|
21
26
|
import {registerNotification} from './notification'
|
|
22
27
|
import {registerOutboundHook, registerOutboundMethods} from './outbound'
|
|
@@ -53,6 +58,18 @@ export type PluginApi = {
|
|
|
53
58
|
requireAuth?: boolean
|
|
54
59
|
handler: (ctx: {args?: string}) => Promise<{text: string}> | {text: string}
|
|
55
60
|
}) => void
|
|
61
|
+
registerTool: (
|
|
62
|
+
tool: {
|
|
63
|
+
name: string
|
|
64
|
+
description: string
|
|
65
|
+
parameters: Record<string, unknown>
|
|
66
|
+
execute: (
|
|
67
|
+
toolCallId: string,
|
|
68
|
+
params: Record<string, unknown>,
|
|
69
|
+
) => Promise<{content: Array<{type: string; text: string}>; details?: unknown}>
|
|
70
|
+
},
|
|
71
|
+
opts?: {optional?: boolean},
|
|
72
|
+
) => void
|
|
56
73
|
}
|
|
57
74
|
|
|
58
75
|
export default {
|
|
@@ -66,6 +83,8 @@ export default {
|
|
|
66
83
|
registerPresence(api)
|
|
67
84
|
registerNotification(api)
|
|
68
85
|
registerAgentSend(api)
|
|
86
|
+
registerIsUserOnlineTool(api)
|
|
87
|
+
registerSendAppPushTool(api)
|
|
69
88
|
api.logger.info(`Loaded ${api.id} plugin.`)
|
|
70
89
|
},
|
|
71
90
|
}
|
package/notification.ts
CHANGED
|
@@ -45,6 +45,7 @@ export function getPushToken(): string | null {
|
|
|
45
45
|
export async function sendPushNotification(
|
|
46
46
|
opts: {body: string; title?: string; data?: Record<string, unknown>},
|
|
47
47
|
api: PluginApi,
|
|
48
|
+
extras?: Record<string, unknown>,
|
|
48
49
|
): Promise<boolean> {
|
|
49
50
|
const token = getPushToken()
|
|
50
51
|
if (!token) {
|
|
@@ -62,6 +63,7 @@ export async function sendPushNotification(
|
|
|
62
63
|
title: opts.title ?? 'Clawly',
|
|
63
64
|
body: opts.body,
|
|
64
65
|
data: opts.data,
|
|
66
|
+
...extras,
|
|
65
67
|
}),
|
|
66
68
|
})
|
|
67
69
|
const json = await res.json()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2en/clawly-plugins",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"presence.ts",
|
|
19
19
|
"notification.ts",
|
|
20
20
|
"agent-send.ts",
|
|
21
|
+
"tools.ts",
|
|
21
22
|
"openclaw.plugin.json"
|
|
22
23
|
],
|
|
23
24
|
"publishConfig": {
|
package/tools.ts
ADDED