@2en/clawly-plugins 1.7.1 → 1.7.2
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/channel.ts +8 -43
- package/cron-hook.ts +3 -9
- package/package.json +1 -1
package/channel.ts
CHANGED
|
@@ -1,39 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Clawly cron delivery channel —
|
|
3
|
-
* cron jobs using `delivery: { channel: "clawly-cron" }` have a valid target.
|
|
2
|
+
* Clawly cron delivery channel — minimal no-op channel registration.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* client is offline.
|
|
4
|
+
* With delivery.mode = "none", OpenClaw does not call sendText. This
|
|
5
|
+
* registration exists so that any existing cron jobs referencing
|
|
6
|
+
* channel "clawly-cron" still have a valid target and don't error out.
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
|
-
import {$} from 'zx'
|
|
12
9
|
import type {PluginApi} from './index'
|
|
13
|
-
import {sendPushNotification} from './gateway/notification'
|
|
14
|
-
import {isClientOnline} from './gateway/presence'
|
|
15
|
-
|
|
16
|
-
$.verbose = false
|
|
17
|
-
|
|
18
|
-
async function deliverAndNotify(text: string, api: PluginApi): Promise<void> {
|
|
19
|
-
try {
|
|
20
|
-
const config = api.pluginConfig as Record<string, unknown> | undefined
|
|
21
|
-
const agentId = typeof config?.agentId === 'string' ? config.agentId : 'clawly'
|
|
22
|
-
|
|
23
|
-
await $`openclaw agent --agent ${agentId} --message ${text}`
|
|
24
|
-
api.logger.info(`clawly-cron: delivered message (${text.length} chars) to agent ${agentId}`)
|
|
25
|
-
|
|
26
|
-
// Push notification if client is offline
|
|
27
|
-
const online = await isClientOnline()
|
|
28
|
-
if (!online) {
|
|
29
|
-
const pushSent = await sendPushNotification({body: text}, api)
|
|
30
|
-
api.logger.info(`clawly-cron: push notification sent=${pushSent}`)
|
|
31
|
-
}
|
|
32
|
-
} catch (err) {
|
|
33
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
34
|
-
api.logger.error(`clawly-cron: failed to deliver message — ${msg}`)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
10
|
|
|
38
11
|
export function registerClawlyCronChannel(api: PluginApi) {
|
|
39
12
|
const channelRegistration = {
|
|
@@ -44,7 +17,7 @@ export function registerClawlyCronChannel(api: PluginApi) {
|
|
|
44
17
|
label: 'Clawly Cron',
|
|
45
18
|
selectionLabel: 'Clawly Cron (webchat)',
|
|
46
19
|
docsPath: '',
|
|
47
|
-
blurb: '
|
|
20
|
+
blurb: 'No-op cron delivery channel (delivery.mode = none)',
|
|
48
21
|
},
|
|
49
22
|
capabilities: {chatTypes: ['dm'] as const},
|
|
50
23
|
config: {
|
|
@@ -68,18 +41,10 @@ export function registerClawlyCronChannel(api: PluginApi) {
|
|
|
68
41
|
},
|
|
69
42
|
outbound: {
|
|
70
43
|
deliveryMode: 'direct' as const,
|
|
71
|
-
sendText: async (
|
|
72
|
-
const firstArg = args[0] as Record<string, unknown> | undefined
|
|
73
|
-
const text = typeof firstArg?.text === 'string' ? firstArg.text : ''
|
|
74
|
-
api.logger.info(`clawly-cron sendText: text=${text.length} chars`)
|
|
75
|
-
if (text) {
|
|
76
|
-
// Fire-and-forget — delivery system may not await sendText
|
|
77
|
-
deliverAndNotify(text, api).catch(() => {})
|
|
78
|
-
}
|
|
44
|
+
sendText: async () => {
|
|
79
45
|
return {channel: 'clawly-cron', messageId: crypto.randomUUID()}
|
|
80
46
|
},
|
|
81
|
-
sendMedia: async (
|
|
82
|
-
api.logger.info(`clawly-cron sendMedia: ${JSON.stringify(args)}`)
|
|
47
|
+
sendMedia: async () => {
|
|
83
48
|
return {channel: 'clawly-cron', messageId: crypto.randomUUID()}
|
|
84
49
|
},
|
|
85
50
|
},
|
|
@@ -87,5 +52,5 @@ export function registerClawlyCronChannel(api: PluginApi) {
|
|
|
87
52
|
}
|
|
88
53
|
|
|
89
54
|
api.registerChannel(channelRegistration)
|
|
90
|
-
api.logger.info('channel: registered clawly-cron delivery channel')
|
|
55
|
+
api.logger.info('channel: registered clawly-cron delivery channel (no-op)')
|
|
91
56
|
}
|
package/cron-hook.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* before_tool_call hook for cron (action=add) — ensures delivery fields are
|
|
3
3
|
* always set correctly, even when the LLM omits them.
|
|
4
4
|
*
|
|
5
|
-
* Forces: delivery.
|
|
5
|
+
* Forces: delivery.mode = "none" (agent uses message/push tools explicitly)
|
|
6
6
|
* Patches: payload.kind "systemEvent" → "agentTurn"
|
|
7
7
|
*
|
|
8
8
|
* The cron tool name is "cron" (not "cron.create"). The LLM passes
|
|
@@ -21,14 +21,8 @@ function isRecord(v: unknown): v is UnknownRecord {
|
|
|
21
21
|
function patchJob(job: UnknownRecord): UnknownRecord {
|
|
22
22
|
const patched: UnknownRecord = {...job}
|
|
23
23
|
|
|
24
|
-
// Force delivery
|
|
25
|
-
|
|
26
|
-
patched.delivery = {
|
|
27
|
-
...delivery,
|
|
28
|
-
mode: 'announce',
|
|
29
|
-
channel: 'clawly-cron',
|
|
30
|
-
to: 'self',
|
|
31
|
-
}
|
|
24
|
+
// Force delivery.mode = "none" — agent reports via message/push tools explicitly
|
|
25
|
+
patched.delivery = {mode: 'none'}
|
|
32
26
|
|
|
33
27
|
// Patch payload.kind: systemEvent → agentTurn
|
|
34
28
|
if (isRecord(job.payload) && job.payload.kind === 'systemEvent') {
|