@workclaw/openclaw-workclaw 1.0.25 → 1.0.26
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/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +379 -0
- package/dist/channel-DSvR6Irx.js +50017 -0
- package/dist/cron-tasks-handler-C-mP3VmV.js +152 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2088 -0
- package/dist/jiti-4i2h0FGP.js +4814 -0
- package/dist/setup-entry.d.ts +3 -0
- package/dist/setup-entry.d.ts.map +1 -0
- package/dist/setup-entry.js +182 -0
- package/dist/src/accounts.d.ts +67 -0
- package/dist/src/accounts.d.ts.map +1 -0
- package/dist/src/api/accounts-api.d.ts +3 -0
- package/dist/src/api/accounts-api.d.ts.map +1 -0
- package/dist/src/api/prompts-api.d.ts +3 -0
- package/dist/src/api/prompts-api.d.ts.map +1 -0
- package/dist/src/api/session-api.d.ts +3 -0
- package/dist/src/api/session-api.d.ts.map +1 -0
- package/dist/src/api/skills-api.d.ts +3 -0
- package/dist/src/api/skills-api.d.ts.map +1 -0
- package/dist/src/api/workspace.d.ts +4 -0
- package/dist/src/api/workspace.d.ts.map +1 -0
- package/dist/src/channel.d.ts +12 -0
- package/dist/src/channel.d.ts.map +1 -0
- package/dist/src/config-schema.d.ts +88 -0
- package/dist/src/config-schema.d.ts.map +1 -0
- package/dist/src/connection/workclaw-client.d.ts +149 -0
- package/dist/src/connection/workclaw-client.d.ts.map +1 -0
- package/dist/src/gateway/agent-handlers.d.ts +13 -0
- package/dist/src/gateway/agent-handlers.d.ts.map +1 -0
- package/dist/src/gateway/config-writer.d.ts +72 -0
- package/dist/src/gateway/config-writer.d.ts.map +1 -0
- package/dist/src/gateway/cron-tasks-handler.d.ts +20 -0
- package/dist/src/gateway/cron-tasks-handler.d.ts.map +1 -0
- package/dist/src/gateway/message-context.d.ts +81 -0
- package/dist/src/gateway/message-context.d.ts.map +1 -0
- package/dist/src/gateway/message-dispatcher.d.ts +17 -0
- package/dist/src/gateway/message-dispatcher.d.ts.map +1 -0
- package/dist/src/gateway/reconnect.d.ts +25 -0
- package/dist/src/gateway/reconnect.d.ts.map +1 -0
- package/dist/src/gateway/skills-handler.d.ts +30 -0
- package/dist/src/gateway/skills-handler.d.ts.map +1 -0
- package/dist/src/gateway/skills-list-handler.d.ts +28 -0
- package/dist/src/gateway/skills-list-handler.d.ts.map +1 -0
- package/dist/src/gateway/tools-list-handler.d.ts +31 -0
- package/dist/src/gateway/tools-list-handler.d.ts.map +1 -0
- package/dist/src/gateway/workclaw-gateway.d.ts +11 -0
- package/dist/src/gateway/workclaw-gateway.d.ts.map +1 -0
- package/dist/src/media/upload.d.ts +14 -0
- package/dist/src/media/upload.d.ts.map +1 -0
- package/dist/src/outbound/index.d.ts +39 -0
- package/dist/src/outbound/index.d.ts.map +1 -0
- package/dist/src/outbound/workclaw-sender.d.ts +38 -0
- package/dist/src/outbound/workclaw-sender.d.ts.map +1 -0
- package/dist/src/runtime.d.ts +118 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/secret-contract-api.d.ts +5 -0
- package/dist/src/secret-contract-api.d.ts.map +1 -0
- package/{src/send.ts → dist/src/send.d.ts} +2 -1
- package/dist/src/send.d.ts.map +1 -0
- package/dist/src/setup-api.d.ts +4 -0
- package/dist/src/setup-api.d.ts.map +1 -0
- package/dist/src/setup-core.d.ts +4 -0
- package/dist/src/setup-core.d.ts.map +1 -0
- package/dist/src/setup-surface.d.ts +8 -0
- package/dist/src/setup-surface.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/api/index.d.ts +91 -0
- package/dist/src/tools/openclaw-workclaw-cron/api/index.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/index.d.ts +11 -0
- package/dist/src/tools/openclaw-workclaw-cron/index.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/params.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.d.ts +16 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.d.ts +12 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.d.ts +12 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.d.ts +12 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.d.ts +12 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.d.ts +13 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.d.ts +12 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.d.ts +12 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/params.d.ts +15 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/params.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.d.ts +16 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/types/index.d.ts +53 -0
- package/dist/src/tools/openclaw-workclaw-cron/types/index.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-cron/utils/index.d.ts +41 -0
- package/dist/src/tools/openclaw-workclaw-cron/utils/index.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-system/index.d.ts +11 -0
- package/dist/src/tools/openclaw-workclaw-system/index.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-system/src/get/index.d.ts +6 -0
- package/dist/src/tools/openclaw-workclaw-system/src/get/index.d.ts.map +1 -0
- package/dist/src/tools/openclaw-workclaw-system/src/token/index.d.ts +6 -0
- package/dist/src/tools/openclaw-workclaw-system/src/token/index.d.ts.map +1 -0
- package/dist/src/types.d.ts +39 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/content.d.ts +16 -0
- package/dist/src/utils/content.d.ts.map +1 -0
- package/openclaw.plugin.json +6 -0
- package/package.json +69 -45
- package/api.ts +0 -3
- package/index.ts +0 -325
- package/setup-entry.ts +0 -13
- package/src/accounts.ts +0 -360
- package/src/api/accounts-api.ts +0 -156
- package/src/api/prompts-api.ts +0 -122
- package/src/api/session-api.ts +0 -246
- package/src/api/skills-api.ts +0 -74
- package/src/api/workspace.ts +0 -45
- package/src/channel.ts +0 -226
- package/src/config-schema.ts +0 -60
- package/src/connection/workclaw-client.ts +0 -618
- package/src/gateway/agent-handlers.ts +0 -551
- package/src/gateway/config-writer.ts +0 -378
- package/src/gateway/cron-tasks-handler.ts +0 -230
- package/src/gateway/message-context.ts +0 -645
- package/src/gateway/message-dispatcher.ts +0 -688
- package/src/gateway/reconnect.ts +0 -260
- package/src/gateway/skills-handler.ts +0 -805
- package/src/gateway/skills-list-handler.ts +0 -332
- package/src/gateway/tools-list-handler.ts +0 -161
- package/src/gateway/workclaw-gateway.ts +0 -304
- package/src/media/upload.ts +0 -168
- package/src/outbound/index.ts +0 -191
- package/src/outbound/workclaw-sender.ts +0 -161
- package/src/runtime.ts +0 -520
- package/src/secret-contract-api.ts +0 -4
- package/src/setup-api.ts +0 -3
- package/src/setup-core.ts +0 -25
- package/src/setup-surface.ts +0 -498
- package/src/tools/openclaw-workclaw-cron/api/index.ts +0 -326
- package/src/tools/openclaw-workclaw-cron/index.ts +0 -39
- 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/index.ts +0 -17
- 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/src/types.ts +0 -50
- package/src/utils/content.ts +0 -40
- package/tsconfig.json +0 -34
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execAsync = promisify(exec);
|
|
4
|
+
async function runCli(command, log, ignoreError = false) {
|
|
5
|
+
log?.info?.(`[CLI] Executing: ${command}`);
|
|
6
|
+
try {
|
|
7
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
8
|
+
timeout: 6e4,
|
|
9
|
+
maxBuffer: 10 * 1024 * 1024
|
|
10
|
+
});
|
|
11
|
+
if (stderr)
|
|
12
|
+
log?.info?.(`[CLI] stderr: ${stderr}`);
|
|
13
|
+
return { stdout: stdout.trim(), success: true };
|
|
14
|
+
} catch (error) {
|
|
15
|
+
const errorMsg = error?.stderr || error?.message || "unknown error";
|
|
16
|
+
log?.error?.(`[CLI] Command failed: ${command} -> ${errorMsg}`);
|
|
17
|
+
if (ignoreError)
|
|
18
|
+
return { stdout: errorMsg, success: false };
|
|
19
|
+
throw new Error(errorMsg);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function sendTaskResult(url, token, taskData, status, log) {
|
|
23
|
+
const { agentIds, dotype, userId, mainId, clawJobId, name, expr } = taskData;
|
|
24
|
+
const payload = {
|
|
25
|
+
appKey: "",
|
|
26
|
+
userId,
|
|
27
|
+
agentId: mainId,
|
|
28
|
+
agentIds,
|
|
29
|
+
dotype,
|
|
30
|
+
doStatus: status.success,
|
|
31
|
+
doErrorMsg: status.success ? "" : status.message,
|
|
32
|
+
dataList: status.dataListOverride || [{
|
|
33
|
+
messageId: 0,
|
|
34
|
+
clawJobId,
|
|
35
|
+
name,
|
|
36
|
+
kind: "",
|
|
37
|
+
expr,
|
|
38
|
+
message: status.success ? status.message : "",
|
|
39
|
+
agentId: mainId,
|
|
40
|
+
nextRunAtMs: 0
|
|
41
|
+
}]
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
log?.info?.(`[Callback] Sending status to ${url}`);
|
|
45
|
+
const response = await fetch(url, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}` },
|
|
48
|
+
body: JSON.stringify(payload)
|
|
49
|
+
});
|
|
50
|
+
if (!response.ok)
|
|
51
|
+
log?.error?.(`[Callback] Http error: ${response.status}`);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
log?.error?.(`[Callback] Network error: ${String(err)}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const buildCmd = (args) => args.map((a) => a && a.includes(" ") ? `"${a}"` : a).join(" ");
|
|
57
|
+
async function handleTaskCreate(taskData, token, url, log) {
|
|
58
|
+
try {
|
|
59
|
+
const cmd = buildCmd(["openclaw", "cron", "add", "--name", taskData.name, "--cron", taskData.expr, "--command", 'echo "Task executed"']);
|
|
60
|
+
const { stdout } = await runCli(cmd, log);
|
|
61
|
+
await sendTaskResult(url, token, taskData, { success: true, message: "创建成功" }, log);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
await sendTaskResult(url, token, taskData, { success: false, message: `创建失败: ${e.message}` }, log);
|
|
64
|
+
throw e;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function handleTaskUpdate(taskData, token, url, log) {
|
|
68
|
+
const taskId = taskData.clawJobId;
|
|
69
|
+
if (!taskId)
|
|
70
|
+
throw new Error("clawJobId为空无法修改");
|
|
71
|
+
try {
|
|
72
|
+
await runCli(`openclaw cron disable ${taskId}`, log, true);
|
|
73
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
74
|
+
const args = ["openclaw", "cron", "edit", taskId];
|
|
75
|
+
if (taskData.name)
|
|
76
|
+
args.push("--name", taskData.name);
|
|
77
|
+
if (taskData.expr)
|
|
78
|
+
args.push("--cron", taskData.expr);
|
|
79
|
+
await runCli(buildCmd(args), log);
|
|
80
|
+
await runCli(`openclaw cron enable ${taskId}`, log, true);
|
|
81
|
+
await sendTaskResult(url, token, taskData, { success: true, message: "更新成功" }, log);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
await sendTaskResult(url, token, taskData, { success: false, message: `更新失败: ${e.message}` }, log);
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function handleTaskDelete(taskData, token, url, log) {
|
|
88
|
+
const taskId = taskData.clawJobId;
|
|
89
|
+
if (!taskId)
|
|
90
|
+
throw new Error("clawJobId为空无法删除");
|
|
91
|
+
try {
|
|
92
|
+
await runCli(`openclaw cron disable ${taskId}`, log, true);
|
|
93
|
+
await runCli(`openclaw cron rm ${taskId}`, log);
|
|
94
|
+
await sendTaskResult(url, token, taskData, { success: true, message: "删除成功" }, log);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
const msg = e.message;
|
|
97
|
+
const isAlreadyGone = msg.includes("not found") || msg.includes("gateway timeout");
|
|
98
|
+
await sendTaskResult(url, token, taskData, {
|
|
99
|
+
success: isAlreadyGone,
|
|
100
|
+
message: isAlreadyGone ? "任务已不存在" : `删除失败: ${msg}`
|
|
101
|
+
}, log);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function handleTaskSearch(taskData, token, url, log) {
|
|
105
|
+
try {
|
|
106
|
+
const { stdout } = await runCli("openclaw cron list", log);
|
|
107
|
+
let tasks = [];
|
|
108
|
+
try {
|
|
109
|
+
tasks = JSON.parse(stdout);
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
const dataList = Array.isArray(tasks) ? tasks.map((t) => ({
|
|
113
|
+
clawJobId: t.id || t.clawJobId,
|
|
114
|
+
name: t.name,
|
|
115
|
+
expr: t.cron || t.expr,
|
|
116
|
+
agentId: t.agentId || taskData.mainId
|
|
117
|
+
})) : [];
|
|
118
|
+
await sendTaskResult(url, token, taskData, {
|
|
119
|
+
success: true,
|
|
120
|
+
message: "查询成功",
|
|
121
|
+
dataListOverride: dataList
|
|
122
|
+
}, log);
|
|
123
|
+
return tasks;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
await sendTaskResult(url, token, taskData, { success: false, message: `查询失败: ${e.message}` }, log);
|
|
126
|
+
throw e;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function handleCronTaskEvent(backendEvent, token, baseUrl, appKey, log) {
|
|
130
|
+
const taskData = backendEvent.data;
|
|
131
|
+
const callbackUrl = `${baseUrl}/open-apis/v1/claw/do/cron/result`;
|
|
132
|
+
log?.info?.(`[Event] Processing ${taskData.dotype}`);
|
|
133
|
+
switch (taskData.dotype) {
|
|
134
|
+
case "add":
|
|
135
|
+
await handleTaskCreate(taskData, token, callbackUrl, log);
|
|
136
|
+
break;
|
|
137
|
+
case "remove":
|
|
138
|
+
await handleTaskDelete(taskData, token, callbackUrl, log);
|
|
139
|
+
break;
|
|
140
|
+
case "edit":
|
|
141
|
+
await handleTaskUpdate(taskData, token, callbackUrl, log);
|
|
142
|
+
break;
|
|
143
|
+
case "search":
|
|
144
|
+
await handleTaskSearch(taskData, token, callbackUrl, log);
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
log?.warn?.(`Unknown dotype: ${taskData.dotype}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
handleCronTaskEvent
|
|
152
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
configSchema: import('openclaw/plugin-sdk').ChannelConfigSchema;
|
|
7
|
+
register: (api: OpenClawPluginApi) => void;
|
|
8
|
+
channelPlugin: import('openclaw/plugin-sdk').ChannelPlugin<import('./src/types.js').ResolvedWorkclawAccount>;
|
|
9
|
+
setChannelRuntime?: (runtime: import('openclaw/plugin-sdk').PluginRuntime) => void;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;;;;;;;;;;AAwR5D,wBA4CE"}
|