@workclaw/openclaw-workclaw 1.0.30 → 1.0.32

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.js CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DEFAULT_ACCOUNT_ID, k as inspectWorkclawCredentials, l as resolveDefaultWorkclawAccountId, d as doFetchJson } from "./channel-DSvR6Irx.js";
2
- import { w } from "./channel-DSvR6Irx.js";
1
+ import { D as DEFAULT_ACCOUNT_ID, i as inspectWorkclawCredentials, b as resolveDefaultWorkclawAccountId, d as doFetchJson } from "./channel-RYqEIK50.js";
2
+ import { w } from "./channel-RYqEIK50.js";
3
3
  import "node:path";
4
4
  import "./jiti-4i2h0FGP.js";
5
5
  import "node:fs/promises";
@@ -16,6 +16,7 @@ import I from "fs";
16
16
  import path$2 from "path";
17
17
  import require$$3$1 from "os";
18
18
  import require$$3 from "crypto";
19
+ import { getWorkclawConnectionConfig, getWorkclawLogger, getWorkclawRuntime, setLastOutboundAt, setToolContext, getWorkclawWsConnection, setWorkclawWsConnection, clearWorkclawWsConnection, getAppKeyByAccountId, unregisterAccountContext, getAllDispatchersByAppKey, getReconnectScheduler, clearReconnectScheduler, clearWorkclawConnectionConfig, createLogger, registerAccountContext, tryStartConnecting, setReconnectScheduler, finishConnecting, setWorkclawConnectionConfig, setWorkclawLoggerFromContext, getDispatcherByAppKeyAndAccountId, getLastInboundAt, getLastOutboundAt } from "./src/runtime.js";
19
20
  import http from "node:http";
20
21
  import https from "node:https";
21
22
  import "node:timers";
@@ -3002,14 +3003,14 @@ function normalizeChannelConfigs(value) {
3002
3003
  const schema = isRecord(rawEntry.schema) ? rawEntry.schema : null;
3003
3004
  if (!schema) continue;
3004
3005
  const uiHints = isRecord(rawEntry.uiHints) ? rawEntry.uiHints : void 0;
3005
- const runtime2 = isRecord(rawEntry.runtime) && typeof rawEntry.runtime.safeParse === "function" ? rawEntry.runtime : void 0;
3006
+ const runtime = isRecord(rawEntry.runtime) && typeof rawEntry.runtime.safeParse === "function" ? rawEntry.runtime : void 0;
3006
3007
  const label = normalizeOptionalString(rawEntry.label) ?? "";
3007
3008
  const description = normalizeOptionalString(rawEntry.description) ?? "";
3008
3009
  const preferOver = normalizeTrimmedStringList(rawEntry.preferOver);
3009
3010
  normalized[channelId] = {
3010
3011
  schema,
3011
3012
  ...uiHints ? { uiHints } : {},
3012
- ...runtime2 ? { runtime: runtime2 } : {},
3013
+ ...runtime ? { runtime } : {},
3013
3014
  ...label ? { label } : {},
3014
3015
  ...description ? { description } : {},
3015
3016
  ...preferOver.length > 0 ? { preferOver } : {}
@@ -26743,224 +26744,6 @@ const PLUGIN_REGISTRY_STATE$1 = Symbol.for("openclaw.pluginRegistryState");
26743
26744
  }
26744
26745
  return registryState;
26745
26746
  })();
26746
- let runtime = null;
26747
- const wsByKey = /* @__PURE__ */ new Map();
26748
- const accountIdsByAppKey = /* @__PURE__ */ new Map();
26749
- const appKeyByAccountId = /* @__PURE__ */ new Map();
26750
- const reconnectSchedulers = /* @__PURE__ */ new Map();
26751
- const dispatchersByAppKey = /* @__PURE__ */ new Map();
26752
- const connectingPromises = /* @__PURE__ */ new Map();
26753
- const lastMessageAtByKey = /* @__PURE__ */ new Map();
26754
- function setWorkclawRuntime(next) {
26755
- runtime = next;
26756
- }
26757
- function getWorkclawRuntime() {
26758
- if (!runtime) {
26759
- throw new Error("Workclaw runtime not initialized");
26760
- }
26761
- return runtime;
26762
- }
26763
- let _logger = null;
26764
- function _noop() {
26765
- }
26766
- function _fallbackLogger() {
26767
- return {
26768
- info: console.log.bind(console),
26769
- warn: console.warn.bind(console),
26770
- error: console.error.bind(console),
26771
- debug: _noop
26772
- };
26773
- }
26774
- function setWorkclawLoggerFromContext(log) {
26775
- _logger = log;
26776
- }
26777
- function getWorkclawLogger() {
26778
- if (!_logger) {
26779
- return _fallbackLogger();
26780
- }
26781
- const l = _logger;
26782
- if (l.info === _noop) {
26783
- return _fallbackLogger();
26784
- }
26785
- return _logger;
26786
- }
26787
- function createLogger(prefix, log) {
26788
- const fallback = _fallbackLogger();
26789
- return {
26790
- info: log?.info ? (msg, ...args) => log.info(`${prefix} ${msg}`, ...args) : fallback.info,
26791
- warn: log?.warn ? (msg, ...args) => log.warn(`${prefix} ${msg}`, ...args) : fallback.warn,
26792
- error: log?.error ? (msg, ...args) => log.error(`${prefix} ${msg}`, ...args) : fallback.error,
26793
- debug: log?.debug ? (msg, ...args) => log.debug(`${prefix} ${msg}`, ...args) : fallback.debug
26794
- };
26795
- }
26796
- function setWorkclawWsConnection(key2, ws) {
26797
- wsByKey.set(key2, ws);
26798
- }
26799
- function clearWorkclawWsConnection(key2) {
26800
- wsByKey.delete(key2);
26801
- }
26802
- function getWorkclawWsConnection(key2) {
26803
- return wsByKey.get(key2);
26804
- }
26805
- function getLastInboundAt(key2) {
26806
- return lastMessageAtByKey.get(key2);
26807
- }
26808
- const lastOutboundAtByKey = /* @__PURE__ */ new Map();
26809
- const connectionConfigCache = /* @__PURE__ */ new Map();
26810
- function setWorkclawConnectionConfig(accountId, config2) {
26811
- connectionConfigCache.set(accountId, {
26812
- appKey: config2.appKey,
26813
- appSecret: config2.appSecret,
26814
- baseUrl: config2.baseUrl ?? "",
26815
- websocketUrl: config2.websocketUrl,
26816
- localIp: config2.localIp,
26817
- allowInsecureTls: config2.allowInsecureTls,
26818
- requestTimeout: config2.requestTimeout
26819
- });
26820
- }
26821
- function getWorkclawConnectionConfig(accountId) {
26822
- return connectionConfigCache.get(accountId);
26823
- }
26824
- function clearWorkclawConnectionConfig(accountId) {
26825
- connectionConfigCache.delete(accountId);
26826
- }
26827
- function setLastOutboundAt(key2, timestamp) {
26828
- lastOutboundAtByKey.set(key2, timestamp);
26829
- }
26830
- function getLastOutboundAt(key2) {
26831
- return lastOutboundAtByKey.get(key2);
26832
- }
26833
- function registerAccountContext(appKey, accountId, ctx) {
26834
- if (!accountIdsByAppKey.has(appKey)) {
26835
- accountIdsByAppKey.set(appKey, /* @__PURE__ */ new Set());
26836
- }
26837
- accountIdsByAppKey.get(appKey).add(accountId);
26838
- appKeyByAccountId.set(accountId, appKey);
26839
- if (!dispatchersByAppKey.has(appKey)) {
26840
- dispatchersByAppKey.set(appKey, /* @__PURE__ */ new Map());
26841
- }
26842
- dispatchersByAppKey.get(appKey).set(accountId, { ctx });
26843
- }
26844
- function unregisterAccountContext(appKey, accountId) {
26845
- accountIdsByAppKey.get(appKey)?.delete(accountId);
26846
- appKeyByAccountId.delete(accountId);
26847
- dispatchersByAppKey.get(appKey)?.delete(accountId);
26848
- }
26849
- function getAppKeyByAccountId(accountId) {
26850
- return appKeyByAccountId.get(accountId);
26851
- }
26852
- function getDispatcherByAppKeyAndAccountId(appKey, accountId) {
26853
- return dispatchersByAppKey.get(appKey)?.get(accountId);
26854
- }
26855
- function getAllDispatchersByAppKey(appKey) {
26856
- return dispatchersByAppKey.get(appKey);
26857
- }
26858
- function setReconnectScheduler(appKey, scheduler) {
26859
- reconnectSchedulers.set(appKey, scheduler);
26860
- }
26861
- function getReconnectScheduler(appKey) {
26862
- return reconnectSchedulers.get(appKey);
26863
- }
26864
- function clearReconnectScheduler(appKey) {
26865
- reconnectSchedulers.delete(appKey);
26866
- }
26867
- function tryStartConnecting(appKey) {
26868
- const existingPromise = connectingPromises.get(appKey);
26869
- if (existingPromise !== void 0) {
26870
- return {
26871
- isConnector: false,
26872
- existingWs: wsByKey.get(appKey),
26873
- connectingPromise: existingPromise
26874
- };
26875
- }
26876
- let resolvePromise = () => {
26877
- };
26878
- const promise = new Promise((resolve) => {
26879
- resolvePromise = resolve;
26880
- });
26881
- promise._resolve = resolvePromise;
26882
- connectingPromises.set(appKey, promise);
26883
- return { isConnector: true, existingWs: void 0, connectingPromise: promise };
26884
- }
26885
- function finishConnecting(appKey, ws) {
26886
- const promise = connectingPromises.get(appKey);
26887
- if (promise) {
26888
- promise._resolve?.(ws ?? null);
26889
- connectingPromises.delete(appKey);
26890
- }
26891
- if (ws) {
26892
- wsByKey.set(appKey, ws);
26893
- }
26894
- }
26895
- const runIdToToolContext = /* @__PURE__ */ new Map();
26896
- const toolCallIdToRunId = /* @__PURE__ */ new Map();
26897
- function getToolContext(runId) {
26898
- return runIdToToolContext.get(runId);
26899
- }
26900
- function setToolContext(runId, ctx) {
26901
- runIdToToolContext.set(runId, ctx);
26902
- }
26903
- function setToolCallIdToRunIdMapping(toolCallId, runId) {
26904
- toolCallIdToRunId.set(toolCallId, runId);
26905
- }
26906
- function deleteToolContext(runId) {
26907
- runIdToToolContext.delete(runId);
26908
- }
26909
- function getToolResultHint(toolName) {
26910
- if (!toolName)
26911
- return "✅ 工具执行完成";
26912
- const normalizedToolName = toolName.toLowerCase().trim();
26913
- const toolMap = {
26914
- // 📁 文件操作
26915
- "read": { emoji: "📖", title: "读取文件", hint: "已读取文件", aliases: ["file_read", "read_file"] },
26916
- "write": { emoji: "✍️", title: "写入文件", hint: "已写入文件", aliases: ["file_write", "write_file"] },
26917
- "edit": { emoji: "✏️", title: "编辑文件", hint: "已编辑文件", aliases: ["file_edit", "modify"] },
26918
- // 💻 系统命令
26919
- "exec": { emoji: "⚡", title: "执行命令", hint: "已执行命令", aliases: ["bash", "shell", "cmd", "command"] },
26920
- "process": { emoji: "🔄", title: "进程管理", hint: "已处理进程", aliases: ["process_manager"] },
26921
- // 🌐 网络/浏览器
26922
- "web_fetch": { emoji: "🕸️", title: "获取网页", hint: "已获取网页", aliases: ["fetch", "http_get", "http_request", "curl"] },
26923
- "web_search": { emoji: "🔍", title: "搜索网页", hint: "已搜索网页", aliases: ["search", "google_search", "brave_search"] },
26924
- "browser": { emoji: "🌐", title: "浏览器控制", hint: "已控制浏览器", aliases: ["browser_control", "playwright"] },
26925
- // 💬 消息/通信
26926
- "message": { emoji: "💌", title: "发送消息", hint: "已发送消息", aliases: ["send_message", "mcp_deliver", "deliver", "notify"] },
26927
- "tts": { emoji: "🔊", title: "文字转语音", hint: "已转换语音", aliases: ["text_to_speech", "speak"] },
26928
- // 🎭 会话管理
26929
- "sessions_spawn": { emoji: "🧬", title: "创建子代理", hint: "已创建子代理", aliases: ["spawn", "create_agent", "new_session"] },
26930
- "sessions_send": { emoji: "📤", title: "跨会话发消息", hint: "已发送跨会话消息", aliases: ["send_to_session", "forward"] },
26931
- "sessions_list": { emoji: "📋", title: "列出会话", hint: "已列出会话", aliases: ["list_sessions"] },
26932
- "sessions_history": { emoji: "📜", title: "获取历史", hint: "已获取历史消息", aliases: ["get_history", "history"] },
26933
- "sessions_yield": { emoji: "⏸️", title: "暂停让出", hint: "已暂停等待", aliases: ["yield", "pause"] },
26934
- "subagents": { emoji: "🐛", title: "子代理管理", hint: "已管理子代理", aliases: ["subagent_manager"] },
26935
- "agents_list": { emoji: "🤖", title: "列出代理", hint: "已列出代理", aliases: ["list_agents"] },
26936
- // 🧠 记忆/知识
26937
- "memory_search": { emoji: "🔎", title: "搜索记忆", hint: "已搜索记忆", aliases: ["search_memory", "recall"] },
26938
- "memory_get": { emoji: "📝", title: "读取记忆", hint: "已读取记忆", aliases: ["get_memory", "read_memory"] },
26939
- // ⏰ 定时任务
26940
- "openclaw-workclaw-cron-add-params": { emoji: "⏱️", title: "创建定时任务", hint: "已创建定时任务", aliases: ["cron_add", "add_timer"] },
26941
- "openclaw-workclaw-cron-update-params": { emoji: "🔧", title: "修改定时任务", hint: "已修改定时任务", aliases: ["cron_update", "update_timer"] },
26942
- "openclaw-workclaw-cron-remove-params": { emoji: "🗑️", title: "删除定时任务", hint: "已删除定时任务", aliases: ["cron_remove", "remove_timer"] },
26943
- "openclaw-workclaw-cron-notify-sync": { emoji: "🔔", title: "定时触发通知", hint: "定时任务已触发", aliases: ["cron_trigger", "notify"] },
26944
- "openclaw-workclaw-cron-add-sync": { emoji: "✅", title: "同步定时任务", hint: "已同步定时任务", aliases: [] },
26945
- "openclaw-workclaw-cron-update-sync": { emoji: "✅", title: "同步定时更新", hint: "已同步更新", aliases: [] },
26946
- "openclaw-workclaw-cron-remove-sync": { emoji: "✅", title: "同步定时删除", hint: "已同步删除", aliases: [] },
26947
- "openclaw-workclaw-cron-disable-params": { emoji: "⏸️", title: "禁用定时任务", hint: "已禁用定时任务", aliases: ["cron_disable"] },
26948
- "openclaw-workclaw-cron-enable-params": { emoji: "▶️", title: "启用定时任务", hint: "已启用定时任务", aliases: ["cron_enable"] },
26949
- // 📊 其他
26950
- "session_status": { emoji: "📊", title: "会话状态", hint: "已获取会话状态", aliases: ["status", "get_status"] },
26951
- "canvas": { emoji: "🎨", title: "画布控制", hint: "已控制画布", aliases: ["canvas_control", "draw"] }
26952
- };
26953
- if (toolMap[normalizedToolName]) {
26954
- const tool = toolMap[normalizedToolName];
26955
- return `${tool.emoji} ${tool.hint}`;
26956
- }
26957
- for (const [_key, tool] of Object.entries(toolMap)) {
26958
- if (tool.aliases.includes(normalizedToolName)) {
26959
- return `${tool.emoji} ${tool.hint}`;
26960
- }
26961
- }
26962
- return `✅ 已执行 ${toolName}`;
26963
- }
26964
26747
  function normalizeAccountId(accountId) {
26965
26748
  return String(accountId ?? "").trim();
26966
26749
  }
@@ -47480,8 +47263,8 @@ function getStateFilePath() {
47480
47263
  }
47481
47264
  async function writeConfigFile(newConfig, cfg, log) {
47482
47265
  try {
47483
- const runtime2 = getWorkclawRuntime();
47484
- const configApi = runtime2.config;
47266
+ const runtime = getWorkclawRuntime();
47267
+ const configApi = runtime.config;
47485
47268
  await configApi.writeConfigFile(newConfig);
47486
47269
  log?.info?.(`[WriteConfig] Config written via runtime.config.writeConfigFile`);
47487
47270
  Object.assign(cfg, newConfig);
@@ -49998,20 +49781,13 @@ const workclawPlugin = {
49998
49781
  };
49999
49782
  export {
50000
49783
  DEFAULT_ACCOUNT_ID as D,
50001
- getWorkclawRuntime as a,
50002
- normalizeBaseUrl as b,
50003
- getWorkclawAccessToken as c,
49784
+ normalizeBaseUrl as a,
49785
+ resolveDefaultWorkclawAccountId as b,
50004
49786
  doFetchJson as d,
50005
- deleteToolContext as e,
50006
- getToolContext as f,
50007
- getWorkclawLogger as g,
50008
- getToolResultHint as h,
50009
- sendMessageWorkclaw as i,
50010
- setToolCallIdToRunIdMapping as j,
50011
- inspectWorkclawCredentials as k,
50012
- resolveDefaultWorkclawAccountId as l,
49787
+ getWorkclawAccessToken as g,
49788
+ inspectWorkclawCredentials as i,
50013
49789
  normalizeAccountId as n,
50014
49790
  resolveWorkclawAccountWithCache as r,
50015
- setWorkclawRuntime as s,
49791
+ sendMessageWorkclaw as s,
50016
49792
  workclawPlugin as w
50017
49793
  };
package/dist/index.js CHANGED
@@ -2,12 +2,14 @@ import { readFile, stat, mkdir, writeFile, unlink } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import process$1 from "node:process";
4
4
  import { fileURLToPath } from "node:url";
5
- import { n as normalizeAccountId, g as getWorkclawLogger, a as getWorkclawRuntime, r as resolveWorkclawAccountWithCache, b as normalizeBaseUrl, c as getWorkclawAccessToken, d as doFetchJson, w as workclawPlugin, s as setWorkclawRuntime, e as deleteToolContext, f as getToolContext, h as getToolResultHint, i as sendMessageWorkclaw, j as setToolCallIdToRunIdMapping } from "./channel-DSvR6Irx.js";
5
+ import { n as normalizeAccountId, r as resolveWorkclawAccountWithCache, a as normalizeBaseUrl, g as getWorkclawAccessToken, d as doFetchJson, w as workclawPlugin, s as sendMessageWorkclaw } from "./channel-RYqEIK50.js";
6
6
  import { e as emptyChannelConfigSchema } from "./jiti-4i2h0FGP.js";
7
7
  import os from "node:os";
8
8
  import "node:fs";
9
9
  import "node:net";
10
10
  import "node:crypto";
11
+ import { Buffer as Buffer$1 } from "node:buffer";
12
+ import { getWorkclawLogger, getWorkclawRuntime, setWorkclawRuntime, deleteToolContext, getToolContext, getToolResultHint, setToolCallIdToRunIdMapping } from "./src/runtime.js";
11
13
  import { exec } from "node:child_process";
12
14
  import { promisify } from "node:util";
13
15
  function error(message) {
@@ -70,12 +72,12 @@ async function readRequestBody$2(req) {
70
72
  const chunks = [];
71
73
  await new Promise((resolve, reject) => {
72
74
  req.on("data", (chunk) => {
73
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
75
+ chunks.push(Buffer$1.isBuffer(chunk) ? chunk : Buffer$1.from(chunk));
74
76
  });
75
77
  req.on("end", () => resolve());
76
78
  req.on("error", (err) => reject(err));
77
79
  });
78
- return Buffer.concat(chunks).toString("utf-8");
80
+ return Buffer$1.concat(chunks).toString("utf-8");
79
81
  }
80
82
  async function loadRuntimeConfig(api) {
81
83
  const runtimeConfig = api.runtime?.config;
@@ -196,7 +198,8 @@ function resolveWorkspaceDir(api) {
196
198
  getWorkclawLogger().info(`workspaceRaw: ${workspaceRaw}`);
197
199
  if (workspaceRaw) {
198
200
  const resolved = api.resolvePath(workspaceRaw);
199
- if (resolved) return resolved;
201
+ if (resolved)
202
+ return resolved;
200
203
  }
201
204
  const profile = process.env.OPENCLAW_PROFILE?.trim();
202
205
  const suffix = profile && profile.toLowerCase() !== "default" ? `workspace-${profile}` : "workspace";
@@ -240,7 +243,7 @@ function createPromptsApiHandler(api) {
240
243
  const content = await readFile(filePath, "utf-8");
241
244
  sendJson$2(res, 200, { ok: true, name, content });
242
245
  return;
243
- } catch (error2) {
246
+ } catch {
244
247
  sendJson$2(res, 404, { ok: false, error: "Not Found" });
245
248
  return;
246
249
  }
@@ -302,12 +305,12 @@ async function readRequestBody$1(req) {
302
305
  const chunks = [];
303
306
  await new Promise((resolve, reject) => {
304
307
  req.on("data", (chunk) => {
305
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
308
+ chunks.push(Buffer$1.isBuffer(chunk) ? chunk : Buffer$1.from(chunk));
306
309
  });
307
310
  req.on("end", () => resolve());
308
311
  req.on("error", (err) => reject(err));
309
312
  });
310
- return Buffer.concat(chunks).toString("utf-8");
313
+ return Buffer$1.concat(chunks).toString("utf-8");
311
314
  }
312
315
  function sendJson$1(res, statusCode, payload) {
313
316
  res.statusCode = statusCode;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-api.d.ts","sourceRoot":"","sources":["../../../src/api/accounts-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AA+D5D,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,iBAAiB,IAC/C,KAAK,GAAG,EAAE,KAAK,GAAG,mBA2FjC"}
1
+ {"version":3,"file":"accounts-api.d.ts","sourceRoot":"","sources":["../../../src/api/accounts-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAgE5D,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,iBAAiB,IAC/C,KAAK,GAAG,EAAE,KAAK,GAAG,mBA2FjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prompts-api.d.ts","sourceRoot":"","sources":["../../../src/api/prompts-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AA2B5D,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,iBAAiB,IAC9C,KAAK,GAAG,EAAE,KAAK,GAAG,mBAiFjC"}
1
+ {"version":3,"file":"prompts-api.d.ts","sourceRoot":"","sources":["../../../src/api/prompts-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AA4B5D,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,iBAAiB,IAC9C,KAAK,GAAG,EAAE,KAAK,GAAG,mBAiFjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/api/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAK5D,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAsBlE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAgBlE"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/api/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAK5D,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAuBlE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAgBlE"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAgBvC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAE5D;AAED,wBAAgB,kBAAkB,IAAI,aAAa,CAKlD;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC3C,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC3C,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC5C,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAC7C;AAED,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAe3D,sEAAsE;AACtE,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAEtE;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,IAAI,cAAc,CAUlD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM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CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqClF;AAED,eAAO,MAAM,mCAAmC,OAAO,CAAA;AAEvD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAqErE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAqEtE;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYlC"}
@@ -0,0 +1,368 @@
1
+ let runtime = null;
2
+ const wsByKey = /* @__PURE__ */ new Map();
3
+ const accountIdsByAppKey = /* @__PURE__ */ new Map();
4
+ const appKeyByAccountId = /* @__PURE__ */ new Map();
5
+ const reconnectSchedulers = /* @__PURE__ */ new Map();
6
+ const dispatchersByAppKey = /* @__PURE__ */ new Map();
7
+ const connectingPromises = /* @__PURE__ */ new Map();
8
+ const lastMessageAtByKey = /* @__PURE__ */ new Map();
9
+ function setWorkclawRuntime(next) {
10
+ runtime = next;
11
+ }
12
+ function getWorkclawRuntime() {
13
+ if (!runtime) {
14
+ throw new Error("Workclaw runtime not initialized");
15
+ }
16
+ return runtime;
17
+ }
18
+ let _logger = null;
19
+ function _noop() {
20
+ }
21
+ function _fallbackLogger() {
22
+ return {
23
+ info: console.log.bind(console),
24
+ warn: console.warn.bind(console),
25
+ error: console.error.bind(console),
26
+ debug: _noop
27
+ };
28
+ }
29
+ function setWorkclawLoggerFromContext(log) {
30
+ _logger = log;
31
+ }
32
+ function getWorkclawLogger() {
33
+ if (!_logger) {
34
+ return _fallbackLogger();
35
+ }
36
+ const l = _logger;
37
+ if (l.info === _noop) {
38
+ return _fallbackLogger();
39
+ }
40
+ return _logger;
41
+ }
42
+ function createLogger(prefix, log) {
43
+ const fallback = _fallbackLogger();
44
+ return {
45
+ info: log?.info ? (msg, ...args) => log.info(`${prefix} ${msg}`, ...args) : fallback.info,
46
+ warn: log?.warn ? (msg, ...args) => log.warn(`${prefix} ${msg}`, ...args) : fallback.warn,
47
+ error: log?.error ? (msg, ...args) => log.error(`${prefix} ${msg}`, ...args) : fallback.error,
48
+ debug: log?.debug ? (msg, ...args) => log.debug(`${prefix} ${msg}`, ...args) : fallback.debug
49
+ };
50
+ }
51
+ function setWorkclawWsConnection(key, ws) {
52
+ wsByKey.set(key, ws);
53
+ }
54
+ function clearWorkclawWsConnection(key) {
55
+ wsByKey.delete(key);
56
+ }
57
+ function getWorkclawWsConnection(key) {
58
+ return wsByKey.get(key);
59
+ }
60
+ function setLastInboundAt(key, timestamp) {
61
+ lastMessageAtByKey.set(key, timestamp);
62
+ }
63
+ function getLastInboundAt(key) {
64
+ return lastMessageAtByKey.get(key);
65
+ }
66
+ const lastOutboundAtByKey = /* @__PURE__ */ new Map();
67
+ const connectionConfigCache = /* @__PURE__ */ new Map();
68
+ function setWorkclawConnectionConfig(accountId, config) {
69
+ connectionConfigCache.set(accountId, {
70
+ appKey: config.appKey,
71
+ appSecret: config.appSecret,
72
+ baseUrl: config.baseUrl ?? "",
73
+ websocketUrl: config.websocketUrl,
74
+ localIp: config.localIp,
75
+ allowInsecureTls: config.allowInsecureTls,
76
+ requestTimeout: config.requestTimeout
77
+ });
78
+ }
79
+ function getWorkclawConnectionConfig(accountId) {
80
+ return connectionConfigCache.get(accountId);
81
+ }
82
+ function clearWorkclawConnectionConfig(accountId) {
83
+ connectionConfigCache.delete(accountId);
84
+ }
85
+ function setLastOutboundAt(key, timestamp) {
86
+ lastOutboundAtByKey.set(key, timestamp);
87
+ }
88
+ function getLastOutboundAt(key) {
89
+ return lastOutboundAtByKey.get(key);
90
+ }
91
+ function registerAccountContext(appKey, accountId, ctx) {
92
+ if (!accountIdsByAppKey.has(appKey)) {
93
+ accountIdsByAppKey.set(appKey, /* @__PURE__ */ new Set());
94
+ }
95
+ accountIdsByAppKey.get(appKey).add(accountId);
96
+ appKeyByAccountId.set(accountId, appKey);
97
+ if (!dispatchersByAppKey.has(appKey)) {
98
+ dispatchersByAppKey.set(appKey, /* @__PURE__ */ new Map());
99
+ }
100
+ dispatchersByAppKey.get(appKey).set(accountId, { ctx });
101
+ }
102
+ function unregisterAccountContext(appKey, accountId) {
103
+ accountIdsByAppKey.get(appKey)?.delete(accountId);
104
+ appKeyByAccountId.delete(accountId);
105
+ dispatchersByAppKey.get(appKey)?.delete(accountId);
106
+ }
107
+ function getAccountIdsByAppKey(appKey) {
108
+ return Array.from(accountIdsByAppKey.get(appKey) ?? []);
109
+ }
110
+ function getAppKeyByAccountId(accountId) {
111
+ return appKeyByAccountId.get(accountId);
112
+ }
113
+ function getDispatcherByAppKeyAndAccountId(appKey, accountId) {
114
+ return dispatchersByAppKey.get(appKey)?.get(accountId);
115
+ }
116
+ function getAllDispatchersByAppKey(appKey) {
117
+ return dispatchersByAppKey.get(appKey);
118
+ }
119
+ function setReconnectScheduler(appKey, scheduler) {
120
+ reconnectSchedulers.set(appKey, scheduler);
121
+ }
122
+ function getReconnectScheduler(appKey) {
123
+ return reconnectSchedulers.get(appKey);
124
+ }
125
+ function clearReconnectScheduler(appKey) {
126
+ reconnectSchedulers.delete(appKey);
127
+ }
128
+ function tryStartConnecting(appKey) {
129
+ const existingPromise = connectingPromises.get(appKey);
130
+ if (existingPromise !== void 0) {
131
+ return {
132
+ isConnector: false,
133
+ existingWs: wsByKey.get(appKey),
134
+ connectingPromise: existingPromise
135
+ };
136
+ }
137
+ let resolvePromise = () => {
138
+ };
139
+ const promise = new Promise((resolve) => {
140
+ resolvePromise = resolve;
141
+ });
142
+ promise._resolve = resolvePromise;
143
+ connectingPromises.set(appKey, promise);
144
+ return { isConnector: true, existingWs: void 0, connectingPromise: promise };
145
+ }
146
+ function finishConnecting(appKey, ws) {
147
+ const promise = connectingPromises.get(appKey);
148
+ if (promise) {
149
+ promise._resolve?.(ws ?? null);
150
+ connectingPromises.delete(appKey);
151
+ }
152
+ if (ws) {
153
+ wsByKey.set(appKey, ws);
154
+ }
155
+ }
156
+ const runIdToToolContext = /* @__PURE__ */ new Map();
157
+ const toolCallIdToRunId = /* @__PURE__ */ new Map();
158
+ function getToolContext(runId) {
159
+ return runIdToToolContext.get(runId);
160
+ }
161
+ function setToolContext(runId, ctx) {
162
+ runIdToToolContext.set(runId, ctx);
163
+ }
164
+ function setToolCallIdToRunIdMapping(toolCallId, runId) {
165
+ toolCallIdToRunId.set(toolCallId, runId);
166
+ }
167
+ function getRunIdByToolCallId(toolCallId) {
168
+ return toolCallIdToRunId.get(toolCallId);
169
+ }
170
+ function deleteToolContext(runId) {
171
+ runIdToToolContext.delete(runId);
172
+ }
173
+ function clearAllToolContexts() {
174
+ runIdToToolContext.clear();
175
+ toolCallIdToRunId.clear();
176
+ }
177
+ async function spawnSubAgent(params) {
178
+ if (!runtime) {
179
+ throw new Error("Workclaw runtime not initialized");
180
+ }
181
+ try {
182
+ const sessionsSpawn = runtime?.sessions_spawn;
183
+ if (!sessionsSpawn || typeof sessionsSpawn !== "function") {
184
+ getWorkclawLogger().warn(`Runtime does not provide sessions_spawn, returning mock response for agent ${params.agentId}`);
185
+ return {
186
+ ok: true,
187
+ summary: `[模拟] Agent ${params.agentId} 完成任务: ${params.task.substring(0, 50)}...`
188
+ };
189
+ }
190
+ const result = await sessionsSpawn({
191
+ agentId: params.agentId,
192
+ task: params.task,
193
+ label: params.label,
194
+ model: params.model
195
+ });
196
+ return {
197
+ ok: true,
198
+ sessionKey: result.sessionKey,
199
+ summary: result.summary
200
+ };
201
+ } catch (error) {
202
+ getWorkclawLogger().error(`Failed to spawn sub-agent: ${error.message}`);
203
+ return {
204
+ ok: false,
205
+ error: error.message
206
+ };
207
+ }
208
+ }
209
+ const __openclaw_workclaw_runtime_emitted = true;
210
+ function getToolStartHint(toolName) {
211
+ if (!toolName)
212
+ return "🔄 正在执行工具...";
213
+ const normalizedToolName = toolName.toLowerCase().trim();
214
+ const toolMap = {
215
+ // 📁 文件操作
216
+ "read": { emoji: "📖", title: "读取文件", hint: "正在读取文件", aliases: ["file_read", "read_file"] },
217
+ "write": { emoji: "✍️", title: "写入文件", hint: "正在写入文件", aliases: ["file_write", "write_file"] },
218
+ "edit": { emoji: "✏️", title: "编辑文件", hint: "正在编辑文件", aliases: ["file_edit", "modify"] },
219
+ // 💻 系统命令
220
+ "exec": { emoji: "⚡", title: "执行命令", hint: "正在执行命令", aliases: ["bash", "shell", "cmd", "command"] },
221
+ "process": { emoji: "🔄", title: "进程管理", hint: "正在处理进程", aliases: ["process_manager"] },
222
+ // 🌐 网络/浏览器
223
+ "web_fetch": { emoji: "🕸️", title: "获取网页", hint: "正在获取网页内容", aliases: ["fetch", "http_get", "http_request", "curl"] },
224
+ "web_search": { emoji: "🔍", title: "搜索网页", hint: "正在搜索网页", aliases: ["search", "google_search", "brave_search"] },
225
+ "browser": { emoji: "🌐", title: "浏览器控制", hint: "正在控制浏览器", aliases: ["browser_control", "playwright"] },
226
+ // 💬 消息/通信
227
+ "message": { emoji: "💌", title: "发送消息", hint: "正在发送消息", aliases: ["send_message", "mcp_deliver", "deliver", "notify"] },
228
+ "tts": { emoji: "🔊", title: "文字转语音", hint: "正在转换语音", aliases: ["text_to_speech", "speak"] },
229
+ // 🎭 会话管理
230
+ "sessions_spawn": { emoji: "🧬", title: "创建子代理", hint: "正在创建子代理", aliases: ["spawn", "create_agent", "new_session"] },
231
+ "sessions_send": { emoji: "📤", title: "跨会话发消息", hint: "正在发送跨会话消息", aliases: ["send_to_session", "forward"] },
232
+ "sessions_list": { emoji: "📋", title: "列出会话", hint: "正在列出会话", aliases: ["list_sessions"] },
233
+ "sessions_history": { emoji: "📜", title: "获取历史", hint: "正在获取历史消息", aliases: ["get_history", "history"] },
234
+ "sessions_yield": { emoji: "⏸️", title: "暂停让出", hint: "正在暂停等待", aliases: ["yield", "pause"] },
235
+ "subagents": { emoji: "🐛", title: "子代理管理", hint: "正在管理子代理", aliases: ["subagent_manager"] },
236
+ "agents_list": { emoji: "🤖", title: "列出代理", hint: "正在列出可用代理", aliases: ["list_agents"] },
237
+ // 🧠 记忆/知识
238
+ "memory_search": { emoji: "🔎", title: "搜索记忆", hint: "正在搜索记忆", aliases: ["search_memory", "recall"] },
239
+ "memory_get": { emoji: "📝", title: "读取记忆", hint: "正在读取记忆片段", aliases: ["get_memory", "read_memory"] },
240
+ // ⏰ 定时任务
241
+ "openclaw-workclaw-cron-add-params": { emoji: "⏱️", title: "创建定时任务", hint: "正在创建定时任务", aliases: ["cron_add", "add_timer"] },
242
+ "openclaw-workclaw-cron-update-params": { emoji: "🔧", title: "修改定时任务", hint: "正在修改定时任务", aliases: ["cron_update", "update_timer"] },
243
+ "openclaw-workclaw-cron-remove-params": { emoji: "🗑️", title: "删除定时任务", hint: "正在删除定时任务", aliases: ["cron_remove", "remove_timer"] },
244
+ "openclaw-workclaw-cron-notify-sync": { emoji: "🔔", title: "定时触发通知", hint: "定时任务已触发", aliases: ["cron_trigger", "notify"] },
245
+ "openclaw-workclaw-cron-add-sync": { emoji: "✅", title: "同步定时任务", hint: "正在同步到后端", aliases: [] },
246
+ "openclaw-workclaw-cron-update-sync": { emoji: "✅", title: "同步定时更新", hint: "正在同步更新", aliases: [] },
247
+ "openclaw-workclaw-cron-remove-sync": { emoji: "✅", title: "同步定时删除", hint: "正在同步删除", aliases: [] },
248
+ "openclaw-workclaw-cron-disable-params": { emoji: "⏸️", title: "禁用定时任务", hint: "正在禁用定时任务", aliases: ["cron_disable"] },
249
+ "openclaw-workclaw-cron-enable-params": { emoji: "▶️", title: "启用定时任务", hint: "正在启用定时任务", aliases: ["cron_enable"] },
250
+ // 📊 其他
251
+ "session_status": { emoji: "📊", title: "会话状态", hint: "正在获取会话状态", aliases: ["status", "get_status"] },
252
+ "canvas": { emoji: "🎨", title: "画布控制", hint: "正在控制画布", aliases: ["canvas_control", "draw"] }
253
+ };
254
+ if (toolMap[normalizedToolName]) {
255
+ const tool = toolMap[normalizedToolName];
256
+ return `${tool.emoji} ${tool.hint}...`;
257
+ }
258
+ for (const [_key, tool] of Object.entries(toolMap)) {
259
+ if (tool.aliases.includes(normalizedToolName)) {
260
+ return `${tool.emoji} ${tool.hint}...`;
261
+ }
262
+ }
263
+ return `🔄 正在执行 ${toolName}...`;
264
+ }
265
+ function getToolResultHint(toolName) {
266
+ if (!toolName)
267
+ return "✅ 工具执行完成";
268
+ const normalizedToolName = toolName.toLowerCase().trim();
269
+ const toolMap = {
270
+ // 📁 文件操作
271
+ "read": { emoji: "📖", title: "读取文件", hint: "已读取文件", aliases: ["file_read", "read_file"] },
272
+ "write": { emoji: "✍️", title: "写入文件", hint: "已写入文件", aliases: ["file_write", "write_file"] },
273
+ "edit": { emoji: "✏️", title: "编辑文件", hint: "已编辑文件", aliases: ["file_edit", "modify"] },
274
+ // 💻 系统命令
275
+ "exec": { emoji: "⚡", title: "执行命令", hint: "已执行命令", aliases: ["bash", "shell", "cmd", "command"] },
276
+ "process": { emoji: "🔄", title: "进程管理", hint: "已处理进程", aliases: ["process_manager"] },
277
+ // 🌐 网络/浏览器
278
+ "web_fetch": { emoji: "🕸️", title: "获取网页", hint: "已获取网页", aliases: ["fetch", "http_get", "http_request", "curl"] },
279
+ "web_search": { emoji: "🔍", title: "搜索网页", hint: "已搜索网页", aliases: ["search", "google_search", "brave_search"] },
280
+ "browser": { emoji: "🌐", title: "浏览器控制", hint: "已控制浏览器", aliases: ["browser_control", "playwright"] },
281
+ // 💬 消息/通信
282
+ "message": { emoji: "💌", title: "发送消息", hint: "已发送消息", aliases: ["send_message", "mcp_deliver", "deliver", "notify"] },
283
+ "tts": { emoji: "🔊", title: "文字转语音", hint: "已转换语音", aliases: ["text_to_speech", "speak"] },
284
+ // 🎭 会话管理
285
+ "sessions_spawn": { emoji: "🧬", title: "创建子代理", hint: "已创建子代理", aliases: ["spawn", "create_agent", "new_session"] },
286
+ "sessions_send": { emoji: "📤", title: "跨会话发消息", hint: "已发送跨会话消息", aliases: ["send_to_session", "forward"] },
287
+ "sessions_list": { emoji: "📋", title: "列出会话", hint: "已列出会话", aliases: ["list_sessions"] },
288
+ "sessions_history": { emoji: "📜", title: "获取历史", hint: "已获取历史消息", aliases: ["get_history", "history"] },
289
+ "sessions_yield": { emoji: "⏸️", title: "暂停让出", hint: "已暂停等待", aliases: ["yield", "pause"] },
290
+ "subagents": { emoji: "🐛", title: "子代理管理", hint: "已管理子代理", aliases: ["subagent_manager"] },
291
+ "agents_list": { emoji: "🤖", title: "列出代理", hint: "已列出代理", aliases: ["list_agents"] },
292
+ // 🧠 记忆/知识
293
+ "memory_search": { emoji: "🔎", title: "搜索记忆", hint: "已搜索记忆", aliases: ["search_memory", "recall"] },
294
+ "memory_get": { emoji: "📝", title: "读取记忆", hint: "已读取记忆", aliases: ["get_memory", "read_memory"] },
295
+ // ⏰ 定时任务
296
+ "openclaw-workclaw-cron-add-params": { emoji: "⏱️", title: "创建定时任务", hint: "已创建定时任务", aliases: ["cron_add", "add_timer"] },
297
+ "openclaw-workclaw-cron-update-params": { emoji: "🔧", title: "修改定时任务", hint: "已修改定时任务", aliases: ["cron_update", "update_timer"] },
298
+ "openclaw-workclaw-cron-remove-params": { emoji: "🗑️", title: "删除定时任务", hint: "已删除定时任务", aliases: ["cron_remove", "remove_timer"] },
299
+ "openclaw-workclaw-cron-notify-sync": { emoji: "🔔", title: "定时触发通知", hint: "定时任务已触发", aliases: ["cron_trigger", "notify"] },
300
+ "openclaw-workclaw-cron-add-sync": { emoji: "✅", title: "同步定时任务", hint: "已同步定时任务", aliases: [] },
301
+ "openclaw-workclaw-cron-update-sync": { emoji: "✅", title: "同步定时更新", hint: "已同步更新", aliases: [] },
302
+ "openclaw-workclaw-cron-remove-sync": { emoji: "✅", title: "同步定时删除", hint: "已同步删除", aliases: [] },
303
+ "openclaw-workclaw-cron-disable-params": { emoji: "⏸️", title: "禁用定时任务", hint: "已禁用定时任务", aliases: ["cron_disable"] },
304
+ "openclaw-workclaw-cron-enable-params": { emoji: "▶️", title: "启用定时任务", hint: "已启用定时任务", aliases: ["cron_enable"] },
305
+ // 📊 其他
306
+ "session_status": { emoji: "📊", title: "会话状态", hint: "已获取会话状态", aliases: ["status", "get_status"] },
307
+ "canvas": { emoji: "🎨", title: "画布控制", hint: "已控制画布", aliases: ["canvas_control", "draw"] }
308
+ };
309
+ if (toolMap[normalizedToolName]) {
310
+ const tool = toolMap[normalizedToolName];
311
+ return `${tool.emoji} ${tool.hint}`;
312
+ }
313
+ for (const [_key, tool] of Object.entries(toolMap)) {
314
+ if (tool.aliases.includes(normalizedToolName)) {
315
+ return `${tool.emoji} ${tool.hint}`;
316
+ }
317
+ }
318
+ return `✅ 已执行 ${toolName}`;
319
+ }
320
+ async function getWorkclawSecrets(params) {
321
+ const secrets = {};
322
+ if (params.appKey) {
323
+ secrets.appKey = params.appKey;
324
+ }
325
+ if (params.appSecret) {
326
+ secrets.appSecret = params.appSecret;
327
+ }
328
+ return secrets;
329
+ }
330
+ export {
331
+ __openclaw_workclaw_runtime_emitted,
332
+ clearAllToolContexts,
333
+ clearReconnectScheduler,
334
+ clearWorkclawConnectionConfig,
335
+ clearWorkclawWsConnection,
336
+ createLogger,
337
+ deleteToolContext,
338
+ finishConnecting,
339
+ getAccountIdsByAppKey,
340
+ getAllDispatchersByAppKey,
341
+ getAppKeyByAccountId,
342
+ getDispatcherByAppKeyAndAccountId,
343
+ getLastInboundAt,
344
+ getLastOutboundAt,
345
+ getReconnectScheduler,
346
+ getRunIdByToolCallId,
347
+ getToolContext,
348
+ getToolResultHint,
349
+ getToolStartHint,
350
+ getWorkclawConnectionConfig,
351
+ getWorkclawLogger,
352
+ getWorkclawRuntime,
353
+ getWorkclawSecrets,
354
+ getWorkclawWsConnection,
355
+ registerAccountContext,
356
+ setLastInboundAt,
357
+ setLastOutboundAt,
358
+ setReconnectScheduler,
359
+ setToolCallIdToRunIdMapping,
360
+ setToolContext,
361
+ setWorkclawConnectionConfig,
362
+ setWorkclawLoggerFromContext,
363
+ setWorkclawRuntime,
364
+ setWorkclawWsConnection,
365
+ spawnSubAgent,
366
+ tryStartConnecting,
367
+ unregisterAccountContext
368
+ };
@@ -0,0 +1,7 @@
1
+ const channelSecrets = {
2
+ specifier: "./runtime.js",
3
+ exportName: "getWorkclawSecrets"
4
+ };
5
+ export {
6
+ channelSecrets
7
+ };
@@ -36,7 +36,19 @@
36
36
  "schema": {
37
37
  "type": "object",
38
38
  "additionalProperties": true,
39
- "properties": {}
39
+ "required": ["appKey", "appSecret"],
40
+ "properties": {
41
+ "appKey": {
42
+ "type": "string",
43
+ "description": "智小途应用 Key",
44
+ "title": "应用 Key"
45
+ },
46
+ "appSecret": {
47
+ "type": "string",
48
+ "description": "智小途应用 Secret",
49
+ "title": "应用 Secret"
50
+ }
51
+ }
40
52
  },
41
53
  "setupEntry": "./dist/setup-entry.js"
42
54
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workclaw/openclaw-workclaw",
3
3
  "type": "module",
4
- "version": "1.0.30",
4
+ "version": "1.0.32",
5
5
  "description": "智小途企业通讯平台 OpenClaw 渠道插件",
6
6
  "license": "MIT",
7
7
  "keywords": [