@workclaw/openclaw-workclaw 1.0.18 → 1.0.20
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/README.md +30 -11
- package/dist/api.d.ts +3 -0
- package/dist/api.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +264 -0
- package/dist/setup-entry.d.ts +2 -0
- package/dist/setup-entry.js +12 -0
- package/dist/src/accounts.d.ts +66 -0
- package/dist/src/accounts.js +279 -0
- package/dist/src/api/accounts-api.d.ts +2 -0
- package/dist/src/api/accounts-api.js +130 -0
- package/dist/src/api/prompts-api.d.ts +2 -0
- package/dist/src/api/prompts-api.js +103 -0
- package/dist/src/api/session-api.d.ts +2 -0
- package/dist/src/api/session-api.js +207 -0
- package/dist/src/api/skills-api.d.ts +2 -0
- package/dist/src/api/skills-api.js +64 -0
- package/dist/src/api/workspace.d.ts +3 -0
- package/dist/src/api/workspace.js +30 -0
- package/dist/src/channel.d.ts +11 -0
- package/{src/channel.ts → dist/src/channel.js} +199 -225
- package/dist/src/config-schema.d.ts +93 -0
- package/dist/src/config-schema.js +56 -0
- package/dist/src/connection/workclaw-client.d.ts +147 -0
- package/dist/src/connection/workclaw-client.js +351 -0
- package/dist/src/gateway/agent-handlers.d.ts +12 -0
- package/{src/gateway/agent-handlers.ts → dist/src/gateway/agent-handlers.js} +372 -462
- package/dist/src/gateway/config-writer.d.ts +71 -0
- package/dist/src/gateway/config-writer.js +302 -0
- package/dist/src/gateway/cron-tasks-handler.d.ts +19 -0
- package/dist/src/gateway/cron-tasks-handler.js +188 -0
- package/dist/src/gateway/message-context.d.ts +80 -0
- package/{src/gateway/message-context.ts → dist/src/gateway/message-context.js} +509 -594
- package/dist/src/gateway/message-dispatcher.d.ts +18 -0
- package/dist/src/gateway/message-dispatcher.js +572 -0
- package/dist/src/gateway/reconnect.d.ts +27 -0
- package/{src/gateway/reconnect.ts → dist/src/gateway/reconnect.js} +210 -253
- package/dist/src/gateway/skills-handler.d.ts +29 -0
- package/dist/src/gateway/skills-handler.js +615 -0
- package/dist/src/gateway/skills-list-handler.d.ts +27 -0
- package/dist/src/gateway/skills-list-handler.js +233 -0
- package/dist/src/gateway/tools-list-handler.d.ts +30 -0
- package/dist/src/gateway/tools-list-handler.js +101 -0
- package/dist/src/gateway/workclaw-gateway.d.ts +14 -0
- package/dist/src/gateway/workclaw-gateway.js +237 -0
- package/dist/src/media/upload.d.ts +13 -0
- package/dist/src/media/upload.js +125 -0
- package/dist/src/outbound/index.d.ts +36 -0
- package/dist/src/outbound/index.js +123 -0
- package/dist/src/outbound/workclaw-sender.d.ts +36 -0
- package/{src/outbound/workclaw-sender.ts → dist/src/outbound/workclaw-sender.js} +95 -158
- package/dist/src/runtime.d.ts +116 -0
- package/dist/src/runtime.js +374 -0
- package/dist/src/secret-contract-api.d.ts +4 -0
- package/dist/src/secret-contract-api.js +4 -0
- package/{src/send.ts → dist/src/send.d.ts} +1 -1
- package/dist/src/send.js +1 -0
- package/dist/src/setup-api.d.ts +3 -0
- package/dist/src/setup-api.js +3 -0
- package/dist/src/setup-core.d.ts +3 -0
- package/dist/src/setup-core.js +13 -0
- package/dist/src/setup-surface.d.ts +7 -0
- package/dist/src/setup-surface.js +363 -0
- package/dist/src/tools/openclaw-workclaw-cron/api/index.d.ts +93 -0
- package/dist/src/tools/openclaw-workclaw-cron/api/index.js +209 -0
- package/dist/src/tools/openclaw-workclaw-cron/index.d.ts +10 -0
- package/{src/tools/openclaw-workclaw-cron/index.ts → dist/src/tools/openclaw-workclaw-cron/index.js} +33 -39
- package/dist/src/tools/openclaw-workclaw-cron/src/add/params.d.ts +16 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/params.js +152 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.d.ts +18 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.js +162 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.js +80 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.js +107 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.js +80 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.js +107 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.d.ts +17 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.js +127 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.js +87 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.js +107 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/params.d.ts +17 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/params.js +164 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.d.ts +18 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.js +135 -0
- package/dist/src/tools/openclaw-workclaw-cron/types/index.d.ts +52 -0
- package/dist/src/tools/openclaw-workclaw-cron/types/index.js +4 -0
- package/dist/src/tools/openclaw-workclaw-cron/utils/index.d.ts +40 -0
- package/dist/src/tools/openclaw-workclaw-cron/utils/index.js +122 -0
- package/dist/src/tools/openclaw-workclaw-system/index.d.ts +10 -0
- package/{src/tools/openclaw-workclaw-system/index.ts → dist/src/tools/openclaw-workclaw-system/index.js} +15 -17
- package/dist/src/tools/openclaw-workclaw-system/src/get/index.d.ts +8 -0
- package/dist/src/tools/openclaw-workclaw-system/src/get/index.js +64 -0
- package/dist/src/tools/openclaw-workclaw-system/src/token/index.d.ts +8 -0
- package/dist/src/tools/openclaw-workclaw-system/src/token/index.js +78 -0
- package/{src/types.ts → dist/src/types.d.ts} +39 -58
- package/dist/src/types.js +1 -0
- package/dist/src/utils/content.d.ts +15 -0
- package/{src/utils/content.ts → dist/src/utils/content.js} +38 -35
- package/package.json +13 -9
- package/index.ts +0 -302
- package/setup-entry.ts +0 -6
- package/src/accounts.ts +0 -312
- package/src/api/accounts-api.ts +0 -156
- package/src/api/prompts-api.ts +0 -116
- package/src/api/session-api.ts +0 -238
- package/src/api/skills-api.ts +0 -72
- package/src/api/workspace.ts +0 -41
- package/src/config-schema.ts +0 -110
- package/src/connection/workclaw-client.ts +0 -643
- package/src/gateway/config-writer.ts +0 -296
- package/src/gateway/message-dispatcher.ts +0 -641
- package/src/gateway/skills-handler.ts +0 -741
- package/src/gateway/skills-list-handler.ts +0 -332
- package/src/gateway/tools-list-handler.ts +0 -160
- package/src/gateway/workclaw-gateway.ts +0 -367
- package/src/media/upload.ts +0 -157
- package/src/outbound/index.ts +0 -185
- package/src/runtime.ts +0 -497
- package/src/tools/openclaw-workclaw-cron/api/index.ts +0 -326
- package/src/tools/openclaw-workclaw-cron/src/add/params.ts +0 -177
- package/src/tools/openclaw-workclaw-cron/src/add/sync.ts +0 -188
- package/src/tools/openclaw-workclaw-cron/src/disable/params.ts +0 -100
- package/src/tools/openclaw-workclaw-cron/src/disable/sync.ts +0 -127
- package/src/tools/openclaw-workclaw-cron/src/enable/params.ts +0 -100
- package/src/tools/openclaw-workclaw-cron/src/enable/sync.ts +0 -127
- package/src/tools/openclaw-workclaw-cron/src/notify/sync.ts +0 -148
- package/src/tools/openclaw-workclaw-cron/src/remove/params.ts +0 -109
- package/src/tools/openclaw-workclaw-cron/src/remove/sync.ts +0 -127
- package/src/tools/openclaw-workclaw-cron/src/update/params.ts +0 -195
- package/src/tools/openclaw-workclaw-cron/src/update/sync.ts +0 -161
- package/src/tools/openclaw-workclaw-cron/types/index.ts +0 -55
- package/src/tools/openclaw-workclaw-cron/utils/index.ts +0 -141
- package/src/tools/openclaw-workclaw-system/src/get/index.ts +0 -77
- package/src/tools/openclaw-workclaw-system/src/token/index.ts +0 -93
- package/tests/accounts.test.ts +0 -285
- package/tests/message-context.test.ts +0 -313
- package/tests/reconnect.test.ts +0 -257
- package/tests/workclaw-client.test.ts +0 -112
- package/tsconfig.json +0 -14
- package/vitest.config.ts +0 -8
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 智小途定时任务工具 - 生成禁用定时任务参数
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 生成禁用定时任务参数
|
|
9
|
-
*/
|
|
10
|
-
export interface DisableParamsParams {
|
|
11
|
-
jobId: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 参数 Schema 定义
|
|
16
|
-
*/
|
|
17
|
-
const DisableParamsSchema = {
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
jobId: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
description: `OpenClaw 任务 ID(必须是数字或字符串,不是 cron 表达式)`,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
required: ['jobId'],
|
|
26
|
-
} as const
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 构造工具返回结果
|
|
30
|
-
*/
|
|
31
|
-
function json(data: unknown): any {
|
|
32
|
-
return {
|
|
33
|
-
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
34
|
-
details: data,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 获取生成禁用定时任务参数工具
|
|
40
|
-
*/
|
|
41
|
-
function getOpenclawWorkclawCronDisableParamsTool(api: OpenClawPluginApi) {
|
|
42
|
-
return (ctx: any) => {
|
|
43
|
-
return {
|
|
44
|
-
name: 'openclaw-workclaw-cron-disable-params',
|
|
45
|
-
label: '智小途生成禁用提醒参数',
|
|
46
|
-
description: `生成禁用提醒的 CLI 命令参数。
|
|
47
|
-
|
|
48
|
-
📋 工作流程:
|
|
49
|
-
1. 调用此工具获取 CLI 命令参数
|
|
50
|
-
2. 使用返回的 cronParams 调用 OpenClaw 的 cron 工具
|
|
51
|
-
3. 调用 openclaw-workclaw-cron-disable-sync 同步到后端`,
|
|
52
|
-
parameters: DisableParamsSchema,
|
|
53
|
-
execute: async (_toolCallId: string, params: DisableParamsParams) => {
|
|
54
|
-
const p = params as DisableParamsParams
|
|
55
|
-
|
|
56
|
-
api.logger.info(`[智小途-生成禁用参数] 开始处理 jobId=${p.jobId}`)
|
|
57
|
-
|
|
58
|
-
// 参数校验
|
|
59
|
-
if (!p.jobId) {
|
|
60
|
-
api.logger.warn('[智小途-生成禁用参数] 缺少 jobId 参数')
|
|
61
|
-
return json({ error: 'jobId 为必填参数' })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 从 ctx 获取必要参数
|
|
65
|
-
const accountId = ctx?.agentAccountId
|
|
66
|
-
if (!accountId) {
|
|
67
|
-
api.logger.warn('[智小途-生成禁用参数] 无法获取账户 ID')
|
|
68
|
-
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
api.logger.info(`[智小途-生成禁用参数] accountId=${accountId} jobId=${p.jobId}`)
|
|
72
|
-
|
|
73
|
-
const cronParams = {
|
|
74
|
-
action: 'disable' as const,
|
|
75
|
-
jobId: p.jobId,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
api.logger.info(`[智小途-生成禁用参数] 构建 cron 参数 cronParams=${JSON.stringify(cronParams)}`)
|
|
79
|
-
|
|
80
|
-
return json({
|
|
81
|
-
cronParams,
|
|
82
|
-
meta: {
|
|
83
|
-
accountId,
|
|
84
|
-
jobId: p.jobId,
|
|
85
|
-
},
|
|
86
|
-
summary: `⏸️ 提醒已禁用: jobId=${p.jobId}`,
|
|
87
|
-
})
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 注册生成禁用定时任务参数工具
|
|
95
|
-
*/
|
|
96
|
-
export function registerOpenclawWorkclawCronDisableParamsTool(api: OpenClawPluginApi): void {
|
|
97
|
-
(api.registerTool as any)(getOpenclawWorkclawCronDisableParamsTool(api), {
|
|
98
|
-
name: 'openclaw-workclaw-cron-disable-params',
|
|
99
|
-
})
|
|
100
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 智小途定时任务工具 - 同步禁用定时任务到后端
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
6
|
-
import { resolveWorkclawAccountWithCache } from '../../../../accounts.js'
|
|
7
|
-
import { callCronJobDisabled } from '../../api/index.js'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 同步禁用定时任务参数
|
|
11
|
-
*/
|
|
12
|
-
export interface DisableSyncParams {
|
|
13
|
-
jobId: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 参数 Schema 定义
|
|
18
|
-
*/
|
|
19
|
-
const DisableSyncSchema = {
|
|
20
|
-
type: 'object',
|
|
21
|
-
properties: {
|
|
22
|
-
jobId: {
|
|
23
|
-
type: 'string',
|
|
24
|
-
description: `OpenClaw 任务 ID(必须是数字或字符串,不是 cron 表达式)`,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
required: ['jobId'],
|
|
28
|
-
} as const
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 构造工具返回结果
|
|
32
|
-
*/
|
|
33
|
-
function json(data: unknown): any {
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
36
|
-
details: data,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 获取同步禁用定时任务到后端工具
|
|
42
|
-
*/
|
|
43
|
-
function getOpenclawWorkclawCronDisableSyncTool(api: OpenClawPluginApi) {
|
|
44
|
-
return (ctx: any) => {
|
|
45
|
-
return {
|
|
46
|
-
name: 'openclaw-workclaw-cron-disable-sync',
|
|
47
|
-
label: '智小途同步禁用提醒',
|
|
48
|
-
description: '将禁用定时任务同步到后端。在 cron 工具禁用任务后调用此工具同步后端。',
|
|
49
|
-
parameters: DisableSyncSchema,
|
|
50
|
-
execute: async (_toolCallId: string, params: DisableSyncParams) => {
|
|
51
|
-
const p = params as DisableSyncParams
|
|
52
|
-
|
|
53
|
-
api.logger.info(`[智小途-同步禁用] 开始同步 jobId=${p.jobId}`)
|
|
54
|
-
|
|
55
|
-
// 参数校验
|
|
56
|
-
if (!p.jobId) {
|
|
57
|
-
api.logger.warn('[智小途-同步禁用] 缺少 jobId 参数')
|
|
58
|
-
return json({ error: 'jobId 为必填参数' })
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 从 ctx 获取必要参数
|
|
62
|
-
const accountId = ctx?.agentAccountId
|
|
63
|
-
if (!accountId) {
|
|
64
|
-
api.logger.warn('[智小途-同步禁用] 无法获取账户 ID')
|
|
65
|
-
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const accountConfig = resolveWorkclawAccountWithCache({
|
|
69
|
-
cfg: ctx.config,
|
|
70
|
-
accountId,
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
if (accountConfig.configured) {
|
|
74
|
-
try {
|
|
75
|
-
const channelAgentId = String(accountConfig.config.agentId)
|
|
76
|
-
api.logger.info(`[智小途-同步禁用] accountId=${accountId} channelAgentId=${channelAgentId}`)
|
|
77
|
-
|
|
78
|
-
const result = await callCronJobDisabled(api, accountId, {
|
|
79
|
-
jobId: p.jobId,
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
if (result.success) {
|
|
83
|
-
api.logger.info(`[智小途-同步禁用] 后端同步成功 jobId=${p.jobId}`)
|
|
84
|
-
return json({
|
|
85
|
-
code: 0,
|
|
86
|
-
message: '定时任务已禁用并同步到后端',
|
|
87
|
-
data: {
|
|
88
|
-
jobId: p.jobId,
|
|
89
|
-
backendSynced: true,
|
|
90
|
-
},
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
api.logger.error(`[智小途-同步禁用] 后端同步失败 ${result.error}`)
|
|
95
|
-
return json({
|
|
96
|
-
code: -1,
|
|
97
|
-
error: result.error || '后端同步失败',
|
|
98
|
-
data: { jobId: p.jobId },
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (error: any) {
|
|
103
|
-
api.logger.error(`[智小途-同步禁用] 后端同步异常 ${error.message}`)
|
|
104
|
-
return json({
|
|
105
|
-
code: -1,
|
|
106
|
-
error: error.message,
|
|
107
|
-
data: { jobId: p.jobId },
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
api.logger.error(`[智小途-同步禁用] 无法获取渠道配置,accountId=${accountId}`)
|
|
113
|
-
return json({ error: '无法获取渠道配置,请检查账户配置' })
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* 注册同步禁用定时任务到后端工具
|
|
122
|
-
*/
|
|
123
|
-
export function registerOpenclawWorkclawCronDisableSyncTool(api: OpenClawPluginApi): void {
|
|
124
|
-
(api.registerTool as any)(getOpenclawWorkclawCronDisableSyncTool(api), {
|
|
125
|
-
name: 'openclaw-workclaw-cron-disable-sync',
|
|
126
|
-
})
|
|
127
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 智小途定时任务工具 - 生成启用定时任务参数
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 生成启用定时任务参数
|
|
9
|
-
*/
|
|
10
|
-
export interface EnableParamsParams {
|
|
11
|
-
jobId: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 参数 Schema 定义
|
|
16
|
-
*/
|
|
17
|
-
const EnableParamsSchema = {
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
jobId: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
description: `OpenClaw 任务 ID(必须是数字或字符串,不是 cron 表达式)`,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
required: ['jobId'],
|
|
26
|
-
} as const
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 构造工具返回结果
|
|
30
|
-
*/
|
|
31
|
-
function json(data: unknown): any {
|
|
32
|
-
return {
|
|
33
|
-
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
34
|
-
details: data,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 获取生成启用定时任务参数工具
|
|
40
|
-
*/
|
|
41
|
-
function getOpenclawWorkclawCronEnableParamsTool(api: OpenClawPluginApi) {
|
|
42
|
-
return (ctx: any) => {
|
|
43
|
-
return {
|
|
44
|
-
name: 'openclaw-workclaw-cron-enable-params',
|
|
45
|
-
label: '智小途生成启用提醒参数',
|
|
46
|
-
description: `生成启用提醒的 CLI 命令参数。
|
|
47
|
-
|
|
48
|
-
📋 工作流程:
|
|
49
|
-
1. 调用此工具获取 CLI 命令参数
|
|
50
|
-
2. 使用返回的 cronParams 调用 OpenClaw 的 cron 工具
|
|
51
|
-
3. 调用 openclaw-workclaw-cron-enable-sync 同步到后端`,
|
|
52
|
-
parameters: EnableParamsSchema,
|
|
53
|
-
execute: async (_toolCallId: string, params: EnableParamsParams) => {
|
|
54
|
-
const p = params as EnableParamsParams
|
|
55
|
-
|
|
56
|
-
api.logger.info(`[智小途-生成启用参数] 开始处理 jobId=${p.jobId}`)
|
|
57
|
-
|
|
58
|
-
// 参数校验
|
|
59
|
-
if (!p.jobId) {
|
|
60
|
-
api.logger.warn('[智小途-生成启用参数] 缺少 jobId 参数')
|
|
61
|
-
return json({ error: 'jobId 为必填参数' })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 从 ctx 获取必要参数
|
|
65
|
-
const accountId = ctx?.agentAccountId
|
|
66
|
-
if (!accountId) {
|
|
67
|
-
api.logger.warn('[智小途-生成启用参数] 无法获取账户 ID')
|
|
68
|
-
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
api.logger.info(`[智小途-生成启用参数] accountId=${accountId} jobId=${p.jobId}`)
|
|
72
|
-
|
|
73
|
-
const cronParams = {
|
|
74
|
-
action: 'enable' as const,
|
|
75
|
-
jobId: p.jobId,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
api.logger.info(`[智小途-生成启用参数] 构建 cron 参数 cronParams=${JSON.stringify(cronParams)}`)
|
|
79
|
-
|
|
80
|
-
return json({
|
|
81
|
-
cronParams,
|
|
82
|
-
meta: {
|
|
83
|
-
accountId,
|
|
84
|
-
jobId: p.jobId,
|
|
85
|
-
},
|
|
86
|
-
summary: `✅ 提醒已启用: jobId=${p.jobId}`,
|
|
87
|
-
})
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 注册生成启用定时任务参数工具
|
|
95
|
-
*/
|
|
96
|
-
export function registerOpenclawWorkclawCronEnableParamsTool(api: OpenClawPluginApi): void {
|
|
97
|
-
(api.registerTool as any)(getOpenclawWorkclawCronEnableParamsTool(api), {
|
|
98
|
-
name: 'openclaw-workclaw-cron-enable-params',
|
|
99
|
-
})
|
|
100
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 智小途定时任务工具 - 同步启用定时任务到后端
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
6
|
-
import { resolveWorkclawAccountWithCache } from '../../../../accounts.js'
|
|
7
|
-
import { callCronJobEnabled } from '../../api/index.js'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 同步启用定时任务参数
|
|
11
|
-
*/
|
|
12
|
-
export interface EnableSyncParams {
|
|
13
|
-
jobId: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 参数 Schema 定义
|
|
18
|
-
*/
|
|
19
|
-
const EnableSyncSchema = {
|
|
20
|
-
type: 'object',
|
|
21
|
-
properties: {
|
|
22
|
-
jobId: {
|
|
23
|
-
type: 'string',
|
|
24
|
-
description: `OpenClaw 任务 ID(必须是数字或字符串,不是 cron 表达式)`,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
required: ['jobId'],
|
|
28
|
-
} as const
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 构造工具返回结果
|
|
32
|
-
*/
|
|
33
|
-
function json(data: unknown): any {
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
36
|
-
details: data,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 获取同步启用定时任务到后端工具
|
|
42
|
-
*/
|
|
43
|
-
function getOpenclawWorkclawCronEnableSyncTool(api: OpenClawPluginApi) {
|
|
44
|
-
return (ctx: any) => {
|
|
45
|
-
return {
|
|
46
|
-
name: 'openclaw-workclaw-cron-enable-sync',
|
|
47
|
-
label: '智小途同步启用提醒',
|
|
48
|
-
description: '将启用定时任务同步到后端。在 cron 工具启用任务后调用此工具同步后端。',
|
|
49
|
-
parameters: EnableSyncSchema,
|
|
50
|
-
execute: async (_toolCallId: string, params: EnableSyncParams) => {
|
|
51
|
-
const p = params as EnableSyncParams
|
|
52
|
-
|
|
53
|
-
api.logger.info(`[智小途-同步启用] 开始同步 jobId=${p.jobId}`)
|
|
54
|
-
|
|
55
|
-
// 参数校验
|
|
56
|
-
if (!p.jobId) {
|
|
57
|
-
api.logger.warn('[智小途-同步启用] 缺少 jobId 参数')
|
|
58
|
-
return json({ error: 'jobId 为必填参数' })
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 从 ctx 获取必要参数
|
|
62
|
-
const accountId = ctx?.agentAccountId
|
|
63
|
-
if (!accountId) {
|
|
64
|
-
api.logger.warn('[智小途-同步启用] 无法获取账户 ID')
|
|
65
|
-
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const accountConfig = resolveWorkclawAccountWithCache({
|
|
69
|
-
cfg: ctx.config,
|
|
70
|
-
accountId,
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
if (accountConfig.configured) {
|
|
74
|
-
try {
|
|
75
|
-
const channelAgentId = String(accountConfig.config.agentId)
|
|
76
|
-
api.logger.info(`[智小途-同步启用] accountId=${accountId} channelAgentId=${channelAgentId}`)
|
|
77
|
-
|
|
78
|
-
const result = await callCronJobEnabled(api, accountId, {
|
|
79
|
-
jobId: p.jobId,
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
if (result.success) {
|
|
83
|
-
api.logger.info(`[智小途-同步启用] 后端同步成功 jobId=${p.jobId}`)
|
|
84
|
-
return json({
|
|
85
|
-
code: 0,
|
|
86
|
-
message: '定时任务已启用并同步到后端',
|
|
87
|
-
data: {
|
|
88
|
-
jobId: p.jobId,
|
|
89
|
-
backendSynced: true,
|
|
90
|
-
},
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
api.logger.error(`[智小途-同步启用] 后端同步失败 ${result.error}`)
|
|
95
|
-
return json({
|
|
96
|
-
code: -1,
|
|
97
|
-
error: result.error || '后端同步失败',
|
|
98
|
-
data: { jobId: p.jobId },
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (error: any) {
|
|
103
|
-
api.logger.error(`[智小途-同步启用] 后端同步异常 ${error.message}`)
|
|
104
|
-
return json({
|
|
105
|
-
code: -1,
|
|
106
|
-
error: error.message,
|
|
107
|
-
data: { jobId: p.jobId },
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
api.logger.error(`[智小途-同步启用] 无法获取渠道配置,accountId=${accountId}`)
|
|
113
|
-
return json({ error: '无法获取渠道配置,请检查账户配置' })
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* 注册同步启用定时任务到后端工具
|
|
122
|
-
*/
|
|
123
|
-
export function registerOpenclawWorkclawCronEnableSyncTool(api: OpenClawPluginApi): void {
|
|
124
|
-
(api.registerTool as any)(getOpenclawWorkclawCronEnableSyncTool(api), {
|
|
125
|
-
name: 'openclaw-workclaw-cron-enable-sync',
|
|
126
|
-
})
|
|
127
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 智小途定时任务工具 - 定时任务触发通知
|
|
3
|
-
*
|
|
4
|
-
* 当 OpenClaw 定时任务触发时,调用此工具通知后端
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
8
|
-
import { resolveWorkclawAccountWithCache } from '../../../../accounts.js'
|
|
9
|
-
import { callCronJobMessage } from '../../api/index.js'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 定时任务触发通知参数
|
|
13
|
-
*/
|
|
14
|
-
export interface NotifyParams {
|
|
15
|
-
jobId: string
|
|
16
|
-
message: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 参数 Schema 定义
|
|
21
|
-
*/
|
|
22
|
-
const NotifySchema = {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
jobId: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
description: 'OpenClaw 任务 ID(从上下文获取)',
|
|
28
|
-
},
|
|
29
|
-
message: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
description: '要发送的提醒内容',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
required: ['jobId', 'message'],
|
|
35
|
-
} as const
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 构造工具返回结果
|
|
39
|
-
*/
|
|
40
|
-
function json(data: unknown): any {
|
|
41
|
-
return {
|
|
42
|
-
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
43
|
-
details: data,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 获取定时任务触发通知工具
|
|
49
|
-
*/
|
|
50
|
-
function getOpenclawWorkclawCronNotifySyncTool(api: OpenClawPluginApi) {
|
|
51
|
-
return (ctx: any) => {
|
|
52
|
-
return {
|
|
53
|
-
name: 'openclaw-workclaw-cron-notify-sync',
|
|
54
|
-
label: '智小途定时任务触发通知',
|
|
55
|
-
description: `【系统最高优先级核心指令】当定时器时间到达时,必须立即调用此工具通知后端。`,
|
|
56
|
-
parameters: NotifySchema,
|
|
57
|
-
execute: async (_toolCallId: string, params: NotifyParams) => {
|
|
58
|
-
const p = params as NotifyParams
|
|
59
|
-
|
|
60
|
-
api.logger.info(`[智小途-定时触发] 开始处理 jobId=${p.jobId} message=${p.message}`)
|
|
61
|
-
|
|
62
|
-
// 参数校验
|
|
63
|
-
if (!p.jobId) {
|
|
64
|
-
api.logger.warn('[智小途-定时触发] 缺少 jobId 参数')
|
|
65
|
-
return json({ error: 'jobId 为必填参数' })
|
|
66
|
-
}
|
|
67
|
-
if (!p.message) {
|
|
68
|
-
api.logger.warn('[智小途-定时触发] 缺少 message 参数')
|
|
69
|
-
return json({ error: 'message 为必填参数' })
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 从 ctx 获取必要参数
|
|
73
|
-
const accountId = ctx?.agentAccountId
|
|
74
|
-
if (!accountId) {
|
|
75
|
-
api.logger.warn('[智小途-定时触发] 无法获取账户 ID')
|
|
76
|
-
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const accountConfig = resolveWorkclawAccountWithCache({
|
|
80
|
-
cfg: ctx.config,
|
|
81
|
-
accountId,
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
if (accountConfig.configured) {
|
|
85
|
-
const channelAgentId = String(accountConfig.config.agentId)
|
|
86
|
-
api.logger.info(`[智小途-定时触发] accountId=${accountId} channelAgentId=${channelAgentId}`)
|
|
87
|
-
|
|
88
|
-
// 调用后端接口通知定时任务触发
|
|
89
|
-
try {
|
|
90
|
-
const result = await callCronJobMessage(api, accountId, {
|
|
91
|
-
jobId: p.jobId,
|
|
92
|
-
message: p.message,
|
|
93
|
-
agentId: channelAgentId,
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
if (result.success) {
|
|
97
|
-
api.logger.info(`[智小途-定时触发] 通知后端成功`)
|
|
98
|
-
return json({
|
|
99
|
-
code: 0,
|
|
100
|
-
message: '定时任务触发通知已发送',
|
|
101
|
-
data: {
|
|
102
|
-
jobId: p.jobId,
|
|
103
|
-
message: p.message,
|
|
104
|
-
backendNotified: true,
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
api.logger.error(`[智小途-定时触发] 通知后端失败 ${result.error}`)
|
|
110
|
-
return json({
|
|
111
|
-
code: -1,
|
|
112
|
-
error: result.error || '通知后端失败',
|
|
113
|
-
data: {
|
|
114
|
-
jobId: p.jobId,
|
|
115
|
-
message: p.message,
|
|
116
|
-
},
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
catch (error: any) {
|
|
121
|
-
api.logger.error(`[智小途-定时触发] 通知后端异常 ${error.message}`)
|
|
122
|
-
return json({
|
|
123
|
-
code: -1,
|
|
124
|
-
error: error.message || '通知后端异常',
|
|
125
|
-
data: {
|
|
126
|
-
jobId: p.jobId,
|
|
127
|
-
message: p.message,
|
|
128
|
-
},
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
api.logger.error(`[智小途-定时触发] 无法获取渠道配置,accountId=${accountId}`)
|
|
134
|
-
return json({ error: '无法获取渠道配置,请检查账户配置' })
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 注册定时任务触发通知工具
|
|
143
|
-
*/
|
|
144
|
-
export function registerOpenclawWorkclawCronNotifySyncTool(api: OpenClawPluginApi): void {
|
|
145
|
-
(api.registerTool as any)(getOpenclawWorkclawCronNotifySyncTool(api), {
|
|
146
|
-
name: 'openclaw-workclaw-cron-notify-sync',
|
|
147
|
-
})
|
|
148
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 智小途定时任务工具 - 生成删除定时任务参数
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 生成删除定时任务参数
|
|
9
|
-
*/
|
|
10
|
-
export interface RemoveParamsParams {
|
|
11
|
-
jobId: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 参数 Schema 定义
|
|
16
|
-
*/
|
|
17
|
-
const RemoveParamsSchema = {
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
jobId: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
description: `OpenClaw 任务 ID(必须是数字或字符串,不是 cron 表达式)`,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
required: ['jobId'],
|
|
26
|
-
} as const
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 构造工具返回结果
|
|
30
|
-
*/
|
|
31
|
-
function json(data: unknown): any {
|
|
32
|
-
return {
|
|
33
|
-
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
34
|
-
details: data,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 获取生成删除定时任务参数工具
|
|
40
|
-
*/
|
|
41
|
-
function getOpenclawWorkclawCronRemoveParamsTool(api: OpenClawPluginApi) {
|
|
42
|
-
return (ctx: any) => {
|
|
43
|
-
return {
|
|
44
|
-
name: 'openclaw-workclaw-cron-remove-params',
|
|
45
|
-
label: '智小途生成删除提醒参数',
|
|
46
|
-
description: `生成删除提醒的 CLI 命令。
|
|
47
|
-
**必须**严格按照以下格式执行:
|
|
48
|
-
openclaw cron remove <jobId>
|
|
49
|
-
|
|
50
|
-
示例:openclaw cron remove 123456
|
|
51
|
-
`,
|
|
52
|
-
parameters: RemoveParamsSchema,
|
|
53
|
-
execute: async (_toolCallId: string, params: RemoveParamsParams) => {
|
|
54
|
-
const p = params as RemoveParamsParams
|
|
55
|
-
|
|
56
|
-
api.logger.info(`[智小途-生成删除参数] 开始处理 jobId=${p.jobId}`)
|
|
57
|
-
|
|
58
|
-
// 参数校验
|
|
59
|
-
if (!p.jobId) {
|
|
60
|
-
api.logger.warn('[智小途-生成删除参数] 缺少 jobId 参数')
|
|
61
|
-
return json({ error: 'jobId 为必填参数' })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 从 ctx 获取必要参数
|
|
65
|
-
const accountId = ctx?.agentAccountId
|
|
66
|
-
const agentId = ctx?.agentId
|
|
67
|
-
|
|
68
|
-
// 校验必要参数
|
|
69
|
-
if (!accountId) {
|
|
70
|
-
api.logger.warn('[智小途-生成删除参数] 无法获取账户 ID')
|
|
71
|
-
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!agentId) {
|
|
75
|
-
api.logger.warn('[智小途-生成删除参数] 无法获取智能体 ID')
|
|
76
|
-
return json({ error: '无法获取智能体 ID(agentId),请确保已配置智能体' })
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
api.logger.info(`[智小途-生成删除参数] accountId=${accountId} agentId=${agentId} jobId=${p.jobId}`)
|
|
80
|
-
|
|
81
|
-
const cronParams = {
|
|
82
|
-
action: 'remove' as const,
|
|
83
|
-
jobId: p.jobId,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
api.logger.info(`[智小途-生成删除参数] 构建 cron 参数 cronParams=${JSON.stringify(cronParams)}`)
|
|
87
|
-
|
|
88
|
-
return json({
|
|
89
|
-
cronParams,
|
|
90
|
-
meta: {
|
|
91
|
-
accountId,
|
|
92
|
-
agentId,
|
|
93
|
-
jobId: p.jobId,
|
|
94
|
-
},
|
|
95
|
-
summary: `🗑️ 提醒已删除: jobId=${p.jobId}`,
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 注册生成删除定时任务参数工具
|
|
104
|
-
*/
|
|
105
|
-
export function registerOpenclawWorkclawCronRemoveParamsTool(api: OpenClawPluginApi): void {
|
|
106
|
-
(api.registerTool as any)(getOpenclawWorkclawCronRemoveParamsTool(api), {
|
|
107
|
-
name: 'openclaw-workclaw-cron-remove-params',
|
|
108
|
-
})
|
|
109
|
-
}
|