@workclaw/openclaw-workclaw 1.0.17 → 1.0.19
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 +364 -325
- package/dist/api.d.ts +3 -0
- package/dist/api.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +263 -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 +28 -0
- package/dist/src/channel.d.ts +11 -0
- package/dist/src/channel.js +198 -0
- 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/dist/src/gateway/agent-handlers.js +433 -0
- package/dist/src/gateway/config-writer.d.ts +71 -0
- package/dist/src/gateway/config-writer.js +312 -0
- package/dist/src/gateway/message-context.d.ts +76 -0
- package/dist/src/gateway/message-context.js +499 -0
- package/dist/src/gateway/message-dispatcher.d.ts +19 -0
- package/dist/src/gateway/message-dispatcher.js +512 -0
- package/dist/src/gateway/reconnect.d.ts +27 -0
- package/dist/src/gateway/reconnect.js +206 -0
- package/dist/src/gateway/skills-handler.d.ts +29 -0
- package/dist/src/gateway/skills-handler.js +576 -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 +223 -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/dist/src/outbound/workclaw-sender.js +95 -0
- 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/dist/src/send.d.ts +1 -0
- 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/dist/src/types.d.ts +39 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils/content.d.ts +15 -0
- package/dist/src/utils/content.js +38 -0
- package/openclaw.plugin.json +1 -0
- package/package.json +62 -42
- package/skills/openclaw-workclaw-cron/SKILL.md +45 -28
- package/index.ts +0 -302
- package/src/accounts.ts +0 -287
- package/src/api/accounts-api.ts +0 -157
- package/src/api/prompts-api.ts +0 -123
- package/src/api/session-api.ts +0 -247
- package/src/api/skills-api.ts +0 -74
- package/src/api/workspace.ts +0 -43
- package/src/channel.ts +0 -227
- package/src/config-schema.ts +0 -110
- package/src/connection/workclaw-client.ts +0 -656
- package/src/gateway/agent-handlers.ts +0 -557
- package/src/gateway/config-writer.ts +0 -311
- package/src/gateway/message-context.ts +0 -422
- package/src/gateway/message-dispatcher.ts +0 -601
- package/src/gateway/reconnect.ts +0 -149
- 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 -162
- package/src/gateway/workclaw-gateway.ts +0 -525
- package/src/media/upload.ts +0 -168
- package/src/outbound/index.ts +0 -183
- package/src/outbound/workclaw-sender.ts +0 -157
- package/src/runtime.ts +0 -400
- package/src/send.ts +0 -1
- package/src/tools/openclaw-workclaw-cron/api/index.ts +0 -326
- package/src/tools/openclaw-workclaw-cron/src/add/params.ts +0 -176
- 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 -197
- 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/src/types.ts +0 -60
- package/src/utils/content.ts +0 -40
- package/tsconfig.json +0 -11
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
let runtime = null;
|
|
2
|
+
// WebSocket 连接存储: key 为 appKey
|
|
3
|
+
const wsByKey = new Map();
|
|
4
|
+
// 额外需要的映射
|
|
5
|
+
const accountIdsByAppKey = new Map();
|
|
6
|
+
const appKeyByAccountId = new Map();
|
|
7
|
+
const reconnectSchedulers = new Map();
|
|
8
|
+
const dispatchersByAppKey = new Map();
|
|
9
|
+
// 正在连接中的 appKey → Promise<ws>(成功后 resolve(ws),失败 resolve(null))
|
|
10
|
+
const connectingPromises = new Map();
|
|
11
|
+
const lastMessageAtByKey = new Map(); // 上次消息时间,key 为 accountId 或 appKey
|
|
12
|
+
export function setWorkclawRuntime(next) {
|
|
13
|
+
runtime = next;
|
|
14
|
+
}
|
|
15
|
+
export function getWorkclawRuntime() {
|
|
16
|
+
if (!runtime) {
|
|
17
|
+
throw new Error("Workclaw runtime not initialized");
|
|
18
|
+
}
|
|
19
|
+
return runtime;
|
|
20
|
+
}
|
|
21
|
+
let _logger = null;
|
|
22
|
+
const _noop = () => { };
|
|
23
|
+
function _fallbackLogger() {
|
|
24
|
+
return {
|
|
25
|
+
info: console.log.bind(console),
|
|
26
|
+
warn: console.warn.bind(console),
|
|
27
|
+
error: console.error.bind(console),
|
|
28
|
+
debug: _noop,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Store the gateway's log into runtime. Called from startAccount. */
|
|
32
|
+
export function setWorkclawLoggerFromContext(log) {
|
|
33
|
+
_logger = log;
|
|
34
|
+
}
|
|
35
|
+
/** Get the shared logger. Returns ctx.log from gateway if set, otherwise a console fallback. */
|
|
36
|
+
export function getWorkclawLogger() {
|
|
37
|
+
if (!_logger) {
|
|
38
|
+
return _fallbackLogger();
|
|
39
|
+
}
|
|
40
|
+
// If the stored logger's info is a noop, fall back to console
|
|
41
|
+
const l = _logger;
|
|
42
|
+
if (l.info === _noop) {
|
|
43
|
+
return _fallbackLogger();
|
|
44
|
+
}
|
|
45
|
+
return _logger;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Wrap a logger with a prefix automatically prepended to every message.
|
|
49
|
+
* All messages logged via the returned logger will have the prefix attached.
|
|
50
|
+
*/
|
|
51
|
+
export function createLogger(prefix, log) {
|
|
52
|
+
const fallback = _fallbackLogger();
|
|
53
|
+
return {
|
|
54
|
+
info: log?.info ? (msg, ...args) => log.info(`${prefix} ${msg}`, ...args) : fallback.info,
|
|
55
|
+
warn: log?.warn ? (msg, ...args) => log.warn(`${prefix} ${msg}`, ...args) : fallback.warn,
|
|
56
|
+
error: log?.error ? (msg, ...args) => log.error(`${prefix} ${msg}`, ...args) : fallback.error,
|
|
57
|
+
debug: log?.debug ? (msg, ...args) => log.debug(`${prefix} ${msg}`, ...args) : fallback.debug,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function setWorkclawWsConnection(key, ws) {
|
|
61
|
+
wsByKey.set(key, ws);
|
|
62
|
+
}
|
|
63
|
+
export function clearWorkclawWsConnection(key) {
|
|
64
|
+
wsByKey.delete(key);
|
|
65
|
+
}
|
|
66
|
+
export function getWorkclawWsConnection(key) {
|
|
67
|
+
return wsByKey.get(key);
|
|
68
|
+
}
|
|
69
|
+
export function setLastInboundAt(key, timestamp) {
|
|
70
|
+
lastMessageAtByKey.set(key, timestamp);
|
|
71
|
+
}
|
|
72
|
+
export function getLastInboundAt(key) {
|
|
73
|
+
return lastMessageAtByKey.get(key);
|
|
74
|
+
}
|
|
75
|
+
const lastOutboundAtByKey = new Map();
|
|
76
|
+
// Cached connection config: accountId -> connection config with stable appKey/appSecret
|
|
77
|
+
// This prevents re-resolving from cfg which may have been mutated
|
|
78
|
+
const connectionConfigCache = new Map();
|
|
79
|
+
export function setWorkclawConnectionConfig(accountId, config) {
|
|
80
|
+
connectionConfigCache.set(accountId, {
|
|
81
|
+
appKey: config.appKey,
|
|
82
|
+
appSecret: config.appSecret,
|
|
83
|
+
baseUrl: config.baseUrl ?? "",
|
|
84
|
+
websocketUrl: config.websocketUrl,
|
|
85
|
+
localIp: config.localIp,
|
|
86
|
+
allowInsecureTls: config.allowInsecureTls,
|
|
87
|
+
requestTimeout: config.requestTimeout,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export function getWorkclawConnectionConfig(accountId) {
|
|
91
|
+
return connectionConfigCache.get(accountId);
|
|
92
|
+
}
|
|
93
|
+
export function clearWorkclawConnectionConfig(accountId) {
|
|
94
|
+
connectionConfigCache.delete(accountId);
|
|
95
|
+
}
|
|
96
|
+
export function setLastOutboundAt(key, timestamp) {
|
|
97
|
+
lastOutboundAtByKey.set(key, timestamp);
|
|
98
|
+
}
|
|
99
|
+
export function getLastOutboundAt(key) {
|
|
100
|
+
return lastOutboundAtByKey.get(key);
|
|
101
|
+
}
|
|
102
|
+
// 注册账号上下文
|
|
103
|
+
export function registerAccountContext(appKey, accountId, ctx) {
|
|
104
|
+
if (!accountIdsByAppKey.has(appKey)) {
|
|
105
|
+
accountIdsByAppKey.set(appKey, new Set());
|
|
106
|
+
}
|
|
107
|
+
accountIdsByAppKey.get(appKey).add(accountId);
|
|
108
|
+
appKeyByAccountId.set(accountId, appKey);
|
|
109
|
+
if (!dispatchersByAppKey.has(appKey)) {
|
|
110
|
+
dispatchersByAppKey.set(appKey, new Map());
|
|
111
|
+
}
|
|
112
|
+
dispatchersByAppKey.get(appKey).set(accountId, { ctx });
|
|
113
|
+
}
|
|
114
|
+
export function unregisterAccountContext(appKey, accountId) {
|
|
115
|
+
accountIdsByAppKey.get(appKey)?.delete(accountId);
|
|
116
|
+
appKeyByAccountId.delete(accountId);
|
|
117
|
+
dispatchersByAppKey.get(appKey)?.delete(accountId);
|
|
118
|
+
}
|
|
119
|
+
export function getAccountIdsByAppKey(appKey) {
|
|
120
|
+
return Array.from(accountIdsByAppKey.get(appKey) ?? []);
|
|
121
|
+
}
|
|
122
|
+
export function getAppKeyByAccountId(accountId) {
|
|
123
|
+
return appKeyByAccountId.get(accountId);
|
|
124
|
+
}
|
|
125
|
+
export function getDispatcherByAppKeyAndAccountId(appKey, accountId) {
|
|
126
|
+
return dispatchersByAppKey.get(appKey)?.get(accountId);
|
|
127
|
+
}
|
|
128
|
+
export function getAllDispatchersByAppKey(appKey) {
|
|
129
|
+
return dispatchersByAppKey.get(appKey);
|
|
130
|
+
}
|
|
131
|
+
export function setReconnectScheduler(appKey, scheduler) {
|
|
132
|
+
reconnectSchedulers.set(appKey, scheduler);
|
|
133
|
+
}
|
|
134
|
+
export function getReconnectScheduler(appKey) {
|
|
135
|
+
return reconnectSchedulers.get(appKey);
|
|
136
|
+
}
|
|
137
|
+
export function clearReconnectScheduler(appKey) {
|
|
138
|
+
reconnectSchedulers.delete(appKey);
|
|
139
|
+
}
|
|
140
|
+
// 尝试开始连接
|
|
141
|
+
// 关键:所有并发调用者必须共享同一个 Promise,而不是各自创建新的导致重复建连
|
|
142
|
+
export function tryStartConnecting(appKey) {
|
|
143
|
+
// 优先查 connectingPromises,确保所有并发调用者共享同一个 Promise
|
|
144
|
+
const existingPromise = connectingPromises.get(appKey);
|
|
145
|
+
if (existingPromise !== undefined) {
|
|
146
|
+
// 已有并发账号在连接,等待同一个 Promise
|
|
147
|
+
return {
|
|
148
|
+
isConnector: false,
|
|
149
|
+
existingWs: wsByKey.get(appKey),
|
|
150
|
+
connectingPromise: existingPromise,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// Map 里没有 entry,自己是新 connector
|
|
154
|
+
let resolvePromise;
|
|
155
|
+
const promise = new Promise((resolve) => { resolvePromise = resolve; });
|
|
156
|
+
promise._resolve = resolvePromise;
|
|
157
|
+
connectingPromises.set(appKey, promise);
|
|
158
|
+
return { isConnector: true, existingWs: undefined, connectingPromise: promise };
|
|
159
|
+
}
|
|
160
|
+
// 标记连接完成(成功或失败都需要调用)
|
|
161
|
+
// ws 不传或传 undefined 表示失败
|
|
162
|
+
export function finishConnecting(appKey, ws) {
|
|
163
|
+
const promise = connectingPromises.get(appKey);
|
|
164
|
+
if (promise) {
|
|
165
|
+
promise._resolve?.(ws ?? null);
|
|
166
|
+
connectingPromises.delete(appKey);
|
|
167
|
+
}
|
|
168
|
+
// ws 已建立成功时存入 wsByKey,供后续 tryStartConnecting 返回 existingWs
|
|
169
|
+
if (ws) {
|
|
170
|
+
wsByKey.set(appKey, ws);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// runId -> ToolContext 映射表
|
|
174
|
+
const runIdToToolContext = new Map();
|
|
175
|
+
// toolCallId -> runId 映射表(用于 tool_result_persist 通过 toolCallId 找到 runId,再找到 ctx)
|
|
176
|
+
const toolCallIdToRunId = new Map();
|
|
177
|
+
// 获取工具上下文(通过 runId)
|
|
178
|
+
export function getToolContext(runId) {
|
|
179
|
+
return runIdToToolContext.get(runId);
|
|
180
|
+
}
|
|
181
|
+
// 设置工具上下文(仅通过 runId)
|
|
182
|
+
export function setToolContext(runId, ctx) {
|
|
183
|
+
runIdToToolContext.set(runId, ctx);
|
|
184
|
+
}
|
|
185
|
+
// 建立 toolCallId -> runId 的映射(用于 after_tool_call 中)
|
|
186
|
+
export function setToolCallIdToRunIdMapping(toolCallId, runId) {
|
|
187
|
+
toolCallIdToRunId.set(toolCallId, runId);
|
|
188
|
+
}
|
|
189
|
+
// 通过 toolCallId 获取 runId
|
|
190
|
+
export function getRunIdByToolCallId(toolCallId) {
|
|
191
|
+
return toolCallIdToRunId.get(toolCallId);
|
|
192
|
+
}
|
|
193
|
+
// 删除工具上下文
|
|
194
|
+
export function deleteToolContext(runId) {
|
|
195
|
+
runIdToToolContext.delete(runId);
|
|
196
|
+
}
|
|
197
|
+
// 清空所有工具上下文(用于清理)
|
|
198
|
+
export function clearAllToolContexts() {
|
|
199
|
+
runIdToToolContext.clear();
|
|
200
|
+
toolCallIdToRunId.clear();
|
|
201
|
+
}
|
|
202
|
+
// 调用sub-agent进行协作
|
|
203
|
+
export async function spawnSubAgent(params) {
|
|
204
|
+
if (!runtime) {
|
|
205
|
+
throw new Error("Workclaw runtime not initialized");
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
// 通过runtime调用sessions_spawn
|
|
209
|
+
const sessionsSpawn = runtime?.sessions_spawn;
|
|
210
|
+
if (!sessionsSpawn || typeof sessionsSpawn !== "function") {
|
|
211
|
+
// 如果runtime没有提供sessions_spawn,返回模拟数据
|
|
212
|
+
getWorkclawLogger().warn(`Runtime does not provide sessions_spawn, returning mock response for agent ${params.agentId}`);
|
|
213
|
+
return {
|
|
214
|
+
ok: true,
|
|
215
|
+
summary: `[模拟] Agent ${params.agentId} 完成任务: ${params.task.substring(0, 50)}...`
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const result = await sessionsSpawn({
|
|
219
|
+
agentId: params.agentId,
|
|
220
|
+
task: params.task,
|
|
221
|
+
label: params.label,
|
|
222
|
+
model: params.model
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
ok: true,
|
|
226
|
+
sessionKey: result.sessionKey,
|
|
227
|
+
summary: result.summary
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
getWorkclawLogger().error(`Failed to spawn sub-agent: ${error.message}`);
|
|
232
|
+
return {
|
|
233
|
+
ok: false,
|
|
234
|
+
error: error.message
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
export const __openclaw_workclaw_runtime_emitted = true;
|
|
239
|
+
/**
|
|
240
|
+
* 获取工具执行开始的提示(用于 onToolStart)
|
|
241
|
+
*/
|
|
242
|
+
export function getToolStartHint(toolName) {
|
|
243
|
+
if (!toolName)
|
|
244
|
+
return "🔄 正在执行工具...";
|
|
245
|
+
const normalizedToolName = toolName.toLowerCase().trim();
|
|
246
|
+
const toolMap = {
|
|
247
|
+
// 📁 文件操作
|
|
248
|
+
read: { emoji: "📖", title: "读取文件", hint: "正在读取文件", aliases: ["file_read", "read_file"] },
|
|
249
|
+
write: { emoji: "✍️", title: "写入文件", hint: "正在写入文件", aliases: ["file_write", "write_file"] },
|
|
250
|
+
edit: { emoji: "✏️", title: "编辑文件", hint: "正在编辑文件", aliases: ["file_edit", "modify"] },
|
|
251
|
+
// 💻 系统命令
|
|
252
|
+
exec: { emoji: "⚡", title: "执行命令", hint: "正在执行命令", aliases: ["bash", "shell", "cmd", "command"] },
|
|
253
|
+
process: { emoji: "🔄", title: "进程管理", hint: "正在处理进程", aliases: ["process_manager"] },
|
|
254
|
+
// 🌐 网络/浏览器
|
|
255
|
+
web_fetch: { emoji: "🕸️", title: "获取网页", hint: "正在获取网页内容", aliases: ["fetch", "http_get", "http_request", "curl"] },
|
|
256
|
+
web_search: { emoji: "🔍", title: "搜索网页", hint: "正在搜索网页", aliases: ["search", "google_search", "brave_search"] },
|
|
257
|
+
browser: { emoji: "🌐", title: "浏览器控制", hint: "正在控制浏览器", aliases: ["browser_control", "playwright"] },
|
|
258
|
+
// 💬 消息/通信
|
|
259
|
+
message: { emoji: "💌", title: "发送消息", hint: "正在发送消息", aliases: ["send_message", "mcp_deliver", "deliver", "notify"] },
|
|
260
|
+
tts: { emoji: "🔊", title: "文字转语音", hint: "正在转换语音", aliases: ["text_to_speech", "speak"] },
|
|
261
|
+
// 🎭 会话管理
|
|
262
|
+
sessions_spawn: { emoji: "🧬", title: "创建子代理", hint: "正在创建子代理", aliases: ["spawn", "create_agent", "new_session"] },
|
|
263
|
+
sessions_send: { emoji: "📤", title: "跨会话发消息", hint: "正在发送跨会话消息", aliases: ["send_to_session", "forward"] },
|
|
264
|
+
sessions_list: { emoji: "📋", title: "列出会话", hint: "正在列出会话", aliases: ["list_sessions"] },
|
|
265
|
+
sessions_history: { emoji: "📜", title: "获取历史", hint: "正在获取历史消息", aliases: ["get_history", "history"] },
|
|
266
|
+
sessions_yield: { emoji: "⏸️", title: "暂停让出", hint: "正在暂停等待", aliases: ["yield", "pause"] },
|
|
267
|
+
subagents: { emoji: "🐛", title: "子代理管理", hint: "正在管理子代理", aliases: ["subagent_manager"] },
|
|
268
|
+
agents_list: { emoji: "🤖", title: "列出代理", hint: "正在列出可用代理", aliases: ["list_agents"] },
|
|
269
|
+
// 🧠 记忆/知识
|
|
270
|
+
memory_search: { emoji: "🔎", title: "搜索记忆", hint: "正在搜索记忆", aliases: ["search_memory", "recall"] },
|
|
271
|
+
memory_get: { emoji: "📝", title: "读取记忆", hint: "正在读取记忆片段", aliases: ["get_memory", "read_memory"] },
|
|
272
|
+
// ⏰ 定时任务
|
|
273
|
+
"openclaw-workclaw-cron-add-params": { emoji: "⏱️", title: "创建定时任务", hint: "正在创建定时任务", aliases: ["cron_add", "add_timer"] },
|
|
274
|
+
"openclaw-workclaw-cron-update-params": { emoji: "🔧", title: "修改定时任务", hint: "正在修改定时任务", aliases: ["cron_update", "update_timer"] },
|
|
275
|
+
"openclaw-workclaw-cron-remove-params": { emoji: "🗑️", title: "删除定时任务", hint: "正在删除定时任务", aliases: ["cron_remove", "remove_timer"] },
|
|
276
|
+
"openclaw-workclaw-cron-notify-sync": { emoji: "🔔", title: "定时触发通知", hint: "定时任务已触发", aliases: ["cron_trigger", "notify"] },
|
|
277
|
+
"openclaw-workclaw-cron-add-sync": { emoji: "✅", title: "同步定时任务", hint: "正在同步到后端", aliases: [] },
|
|
278
|
+
"openclaw-workclaw-cron-update-sync": { emoji: "✅", title: "同步定时更新", hint: "正在同步更新", aliases: [] },
|
|
279
|
+
"openclaw-workclaw-cron-remove-sync": { emoji: "✅", title: "同步定时删除", hint: "正在同步删除", aliases: [] },
|
|
280
|
+
"openclaw-workclaw-cron-disable-params": { emoji: "⏸️", title: "禁用定时任务", hint: "正在禁用定时任务", aliases: ["cron_disable"] },
|
|
281
|
+
"openclaw-workclaw-cron-enable-params": { emoji: "▶️", title: "启用定时任务", hint: "正在启用定时任务", aliases: ["cron_enable"] },
|
|
282
|
+
// 📊 其他
|
|
283
|
+
session_status: { emoji: "📊", title: "会话状态", hint: "正在获取会话状态", aliases: ["status", "get_status"] },
|
|
284
|
+
canvas: { emoji: "🎨", title: "画布控制", hint: "正在控制画布", aliases: ["canvas_control", "draw"] },
|
|
285
|
+
};
|
|
286
|
+
// 精确匹配
|
|
287
|
+
if (toolMap[normalizedToolName]) {
|
|
288
|
+
const tool = toolMap[normalizedToolName];
|
|
289
|
+
return `${tool.emoji} ${tool.hint}...`;
|
|
290
|
+
}
|
|
291
|
+
// 别名匹配
|
|
292
|
+
for (const [key, tool] of Object.entries(toolMap)) {
|
|
293
|
+
if (tool.aliases.includes(normalizedToolName)) {
|
|
294
|
+
return `${tool.emoji} ${tool.hint}...`;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// 默认
|
|
298
|
+
return `🔄 正在执行 ${toolName}...`;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* 获取工具执行完成的提示(用于 after_tool_call)
|
|
302
|
+
*/
|
|
303
|
+
export function getToolResultHint(toolName) {
|
|
304
|
+
if (!toolName)
|
|
305
|
+
return "✅ 工具执行完成";
|
|
306
|
+
const normalizedToolName = toolName.toLowerCase().trim();
|
|
307
|
+
const toolMap = {
|
|
308
|
+
// 📁 文件操作
|
|
309
|
+
read: { emoji: "📖", title: "读取文件", hint: "已读取文件", aliases: ["file_read", "read_file"] },
|
|
310
|
+
write: { emoji: "✍️", title: "写入文件", hint: "已写入文件", aliases: ["file_write", "write_file"] },
|
|
311
|
+
edit: { emoji: "✏️", title: "编辑文件", hint: "已编辑文件", aliases: ["file_edit", "modify"] },
|
|
312
|
+
// 💻 系统命令
|
|
313
|
+
exec: { emoji: "⚡", title: "执行命令", hint: "已执行命令", aliases: ["bash", "shell", "cmd", "command"] },
|
|
314
|
+
process: { emoji: "🔄", title: "进程管理", hint: "已处理进程", aliases: ["process_manager"] },
|
|
315
|
+
// 🌐 网络/浏览器
|
|
316
|
+
web_fetch: { emoji: "🕸️", title: "获取网页", hint: "已获取网页", aliases: ["fetch", "http_get", "http_request", "curl"] },
|
|
317
|
+
web_search: { emoji: "🔍", title: "搜索网页", hint: "已搜索网页", aliases: ["search", "google_search", "brave_search"] },
|
|
318
|
+
browser: { emoji: "🌐", title: "浏览器控制", hint: "已控制浏览器", aliases: ["browser_control", "playwright"] },
|
|
319
|
+
// 💬 消息/通信
|
|
320
|
+
message: { emoji: "💌", title: "发送消息", hint: "已发送消息", aliases: ["send_message", "mcp_deliver", "deliver", "notify"] },
|
|
321
|
+
tts: { emoji: "🔊", title: "文字转语音", hint: "已转换语音", aliases: ["text_to_speech", "speak"] },
|
|
322
|
+
// 🎭 会话管理
|
|
323
|
+
sessions_spawn: { emoji: "🧬", title: "创建子代理", hint: "已创建子代理", aliases: ["spawn", "create_agent", "new_session"] },
|
|
324
|
+
sessions_send: { emoji: "📤", title: "跨会话发消息", hint: "已发送跨会话消息", aliases: ["send_to_session", "forward"] },
|
|
325
|
+
sessions_list: { emoji: "📋", title: "列出会话", hint: "已列出会话", aliases: ["list_sessions"] },
|
|
326
|
+
sessions_history: { emoji: "📜", title: "获取历史", hint: "已获取历史消息", aliases: ["get_history", "history"] },
|
|
327
|
+
sessions_yield: { emoji: "⏸️", title: "暂停让出", hint: "已暂停等待", aliases: ["yield", "pause"] },
|
|
328
|
+
subagents: { emoji: "🐛", title: "子代理管理", hint: "已管理子代理", aliases: ["subagent_manager"] },
|
|
329
|
+
agents_list: { emoji: "🤖", title: "列出代理", hint: "已列出代理", aliases: ["list_agents"] },
|
|
330
|
+
// 🧠 记忆/知识
|
|
331
|
+
memory_search: { emoji: "🔎", title: "搜索记忆", hint: "已搜索记忆", aliases: ["search_memory", "recall"] },
|
|
332
|
+
memory_get: { emoji: "📝", title: "读取记忆", hint: "已读取记忆", aliases: ["get_memory", "read_memory"] },
|
|
333
|
+
// ⏰ 定时任务
|
|
334
|
+
"openclaw-workclaw-cron-add-params": { emoji: "⏱️", title: "创建定时任务", hint: "已创建定时任务", aliases: ["cron_add", "add_timer"] },
|
|
335
|
+
"openclaw-workclaw-cron-update-params": { emoji: "🔧", title: "修改定时任务", hint: "已修改定时任务", aliases: ["cron_update", "update_timer"] },
|
|
336
|
+
"openclaw-workclaw-cron-remove-params": { emoji: "🗑️", title: "删除定时任务", hint: "已删除定时任务", aliases: ["cron_remove", "remove_timer"] },
|
|
337
|
+
"openclaw-workclaw-cron-notify-sync": { emoji: "🔔", title: "定时触发通知", hint: "定时任务已触发", aliases: ["cron_trigger", "notify"] },
|
|
338
|
+
"openclaw-workclaw-cron-add-sync": { emoji: "✅", title: "同步定时任务", hint: "已同步定时任务", aliases: [] },
|
|
339
|
+
"openclaw-workclaw-cron-update-sync": { emoji: "✅", title: "同步定时更新", hint: "已同步更新", aliases: [] },
|
|
340
|
+
"openclaw-workclaw-cron-remove-sync": { emoji: "✅", title: "同步定时删除", hint: "已同步删除", aliases: [] },
|
|
341
|
+
"openclaw-workclaw-cron-disable-params": { emoji: "⏸️", title: "禁用定时任务", hint: "已禁用定时任务", aliases: ["cron_disable"] },
|
|
342
|
+
"openclaw-workclaw-cron-enable-params": { emoji: "▶️", title: "启用定时任务", hint: "已启用定时任务", aliases: ["cron_enable"] },
|
|
343
|
+
// 📊 其他
|
|
344
|
+
session_status: { emoji: "📊", title: "会话状态", hint: "已获取会话状态", aliases: ["status", "get_status"] },
|
|
345
|
+
canvas: { emoji: "🎨", title: "画布控制", hint: "已控制画布", aliases: ["canvas_control", "draw"] },
|
|
346
|
+
};
|
|
347
|
+
// 精确匹配
|
|
348
|
+
if (toolMap[normalizedToolName]) {
|
|
349
|
+
const tool = toolMap[normalizedToolName];
|
|
350
|
+
return `${tool.emoji} ${tool.hint}`;
|
|
351
|
+
}
|
|
352
|
+
// 别名匹配
|
|
353
|
+
for (const [key, tool] of Object.entries(toolMap)) {
|
|
354
|
+
if (tool.aliases.includes(normalizedToolName)) {
|
|
355
|
+
return `${tool.emoji} ${tool.hint}`;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// 默认
|
|
359
|
+
return `✅ 已执行 ${toolName}`;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 获取 Workclaw 渠道密钥
|
|
363
|
+
* 这是 setup 向导必需的接口
|
|
364
|
+
*/
|
|
365
|
+
export async function getWorkclawSecrets(params) {
|
|
366
|
+
const secrets = {};
|
|
367
|
+
if (params.appKey) {
|
|
368
|
+
secrets.appKey = params.appKey;
|
|
369
|
+
}
|
|
370
|
+
if (params.appSecret) {
|
|
371
|
+
secrets.appSecret = params.appSecret;
|
|
372
|
+
}
|
|
373
|
+
return secrets;
|
|
374
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sendMessageWorkclaw, getMessageWorkclaw } from "./outbound/index.js";
|
package/dist/src/send.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sendMessageWorkclaw, getMessageWorkclaw } from "./outbound/index.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ChannelSetupAdapter, type OpenClawConfig } from "openclaw/plugin-sdk/setup";
|
|
2
|
+
export declare function setWorkclawNamedAccountEnabled(cfg: OpenClawConfig, accountId: string, enabled: boolean): OpenClawConfig;
|
|
3
|
+
export declare const workclawSetupAdapter: ChannelSetupAdapter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DEFAULT_ACCOUNT_ID, } from "openclaw/plugin-sdk/setup";
|
|
2
|
+
import { resolveDefaultWorkclawAccountId } from "./accounts.js";
|
|
3
|
+
import { patchWorkclawConfig } from "./setup-surface.js";
|
|
4
|
+
export function setWorkclawNamedAccountEnabled(cfg, accountId, enabled) {
|
|
5
|
+
return patchWorkclawConfig(cfg, accountId, { enabled });
|
|
6
|
+
}
|
|
7
|
+
export const workclawSetupAdapter = {
|
|
8
|
+
resolveAccountId: ({ cfg, accountId }) => accountId?.trim() || resolveDefaultWorkclawAccountId(cfg),
|
|
9
|
+
applyAccountConfig: ({ cfg, accountId }) => {
|
|
10
|
+
const isDefault = !accountId || accountId === DEFAULT_ACCOUNT_ID;
|
|
11
|
+
return patchWorkclawConfig(cfg, isDefault ? DEFAULT_ACCOUNT_ID : accountId, { enabled: true });
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ChannelSetupWizard, type OpenClawConfig } from "openclaw/plugin-sdk/setup";
|
|
2
|
+
/**
|
|
3
|
+
* 修补 Workclaw 配置
|
|
4
|
+
*/
|
|
5
|
+
export declare function patchWorkclawConfig(cfg: OpenClawConfig, accountId: string, patch: Record<string, unknown>): OpenClawConfig;
|
|
6
|
+
export { workclawSetupAdapter } from "./setup-core.js";
|
|
7
|
+
export declare const workclawSetupWizard: ChannelSetupWizard;
|