openclaw-quiubo 2.6.58 → 2.6.60

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/index.js CHANGED
@@ -15163,7 +15163,9 @@ function registerGroupContextHook(api) {
15163
15163
  // src/activity-hook.ts
15164
15164
  var activeToolCounts = /* @__PURE__ */ new Map();
15165
15165
  var lastSentAt = /* @__PURE__ */ new Map();
15166
+ var pendingIdle = /* @__PURE__ */ new Map();
15166
15167
  var DEBOUNCE_MS = 2e3;
15168
+ var IDLE_DELAY_MS = 5e3;
15167
15169
  function generateLabel(toolName, params) {
15168
15170
  switch (toolName) {
15169
15171
  case "exec":
@@ -15206,13 +15208,17 @@ function registerActivityHook(api) {
15206
15208
  "before_tool_call",
15207
15209
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15208
15210
  (_event, ctx) => {
15209
- if (ctx.channelId !== "quiubo") return;
15210
15211
  const sessionKey = ctx.sessionKey;
15211
15212
  const groupId = extractGroupIdFromSessionKey(sessionKey);
15212
15213
  if (!groupId) return;
15213
15214
  const key = sessionKey;
15214
15215
  const prev = activeToolCounts.get(key) ?? 0;
15215
15216
  activeToolCounts.set(key, prev + 1);
15217
+ const pendingTimer = pendingIdle.get(key);
15218
+ if (pendingTimer) {
15219
+ clearTimeout(pendingTimer);
15220
+ pendingIdle.delete(key);
15221
+ }
15216
15222
  if (prev === 0) {
15217
15223
  const now = Date.now();
15218
15224
  const last = lastSentAt.get(key) ?? 0;
@@ -15242,7 +15248,6 @@ function registerActivityHook(api) {
15242
15248
  "after_tool_call",
15243
15249
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15244
15250
  (_event, ctx) => {
15245
- if (ctx.channelId !== "quiubo") return;
15246
15251
  const sessionKey = ctx.sessionKey;
15247
15252
  const groupId = extractGroupIdFromSessionKey(sessionKey);
15248
15253
  if (!groupId) return;
@@ -15251,19 +15256,24 @@ function registerActivityHook(api) {
15251
15256
  const next = Math.max(0, prev - 1);
15252
15257
  activeToolCounts.set(key, next);
15253
15258
  if (next === 0) {
15254
- lastSentAt.delete(key);
15255
- const config = api.runtime?.config ?? api.config;
15256
- const agentId = extractAgentIdFromSessionKey(sessionKey);
15257
- const accountId = resolveAccountId(config, agentId);
15258
- const client = clients.get(accountId);
15259
- const accountCfg = accounts.get(accountId);
15260
- if (!client || !accountCfg?.botIdentityId) return;
15261
- client.sendActivity(groupId, {
15262
- identityId: accountCfg.botIdentityId,
15263
- state: "idle"
15264
- }).catch((err) => {
15265
- console.warn(`[quiubo] activity-hook idle failed: ${err}`);
15266
- });
15259
+ const idleTimer = setTimeout(() => {
15260
+ pendingIdle.delete(key);
15261
+ lastSentAt.delete(key);
15262
+ if ((activeToolCounts.get(key) ?? 0) > 0) return;
15263
+ const config = api.runtime?.config ?? api.config;
15264
+ const agentId = extractAgentIdFromSessionKey(sessionKey);
15265
+ const accountId = resolveAccountId(config, agentId);
15266
+ const client = clients.get(accountId);
15267
+ const accountCfg = accounts.get(accountId);
15268
+ if (!client || !accountCfg?.botIdentityId) return;
15269
+ client.sendActivity(groupId, {
15270
+ identityId: accountCfg.botIdentityId,
15271
+ state: "idle"
15272
+ }).catch((err) => {
15273
+ console.warn(`[quiubo] activity-hook idle failed: ${err}`);
15274
+ });
15275
+ }, IDLE_DELAY_MS);
15276
+ pendingIdle.set(key, idleTimer);
15267
15277
  }
15268
15278
  },
15269
15279
  { name: "quiubo-activity-after" }