aai-lark-bridge 0.2.7 → 0.2.8

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/cli.js CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "aai-lark-bridge",
7
- version: "0.2.7",
7
+ version: "0.2.8",
8
8
  description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
9
9
  type: "module",
10
10
  main: "./dist/index.js",
@@ -7167,6 +7167,7 @@ function budgetStopReply(title, spentUsd, budgetUsd) {
7167
7167
  return `\u4EFB\u52A1\u300A${title}\u300B\u7684\u5BF9\u8BDD\u5DF2\u82B1 ${usd(spentUsd)} \u7F8E\u5143\uFF0C\u5230\u4E0A\u9650 ${usd(budgetUsd)} \u7F8E\u5143\uFF0C\u5148\u505C\u4E0B\uFF1B\u8BF7\u770B\u9884\u7B97\u5361\u7247`;
7168
7168
  }
7169
7169
  function taskFooterLine(binding) {
7170
+ if (binding.viaThread) return `\u672C\u8BDD\u9898\u4EFB\u52A1\uFF1A\u300A${binding.task.title}\u300B`;
7170
7171
  return `\u5F53\u524D\u4EFB\u52A1\uFF1A\u300A${binding.task.title}\u300B\uFF0C\u6392\u961F ${binding.queued} \u6761`;
7171
7172
  }
7172
7173
  var SAFE_NAME = /^[A-Za-z0-9_.:@+-]{1,200}$/;
@@ -7191,7 +7192,7 @@ function isTaskItem(v) {
7191
7192
  const t = v;
7192
7193
  return typeof t.task_id === "string" && t.task_id !== "" && typeof t.title === "string" && typeof t.cwd === "string" && isAbsolute2(t.cwd) && typeof t.system_prompt_file === "string" && isAbsolute2(t.system_prompt_file) && (t.first_context === void 0 || typeof t.first_context === "string") && typeof t.ledger_key === "string" && safeName(t.ledger_key);
7193
7194
  }
7194
- function resolveBinding(rawConfig, chatId, senderOpenId) {
7195
+ function resolveBinding(rawConfig, chatId, senderOpenId, opts = {}) {
7195
7196
  const cfg = taskBindingsConfig(rawConfig);
7196
7197
  if (!cfg || !safeName(chatId)) return { kind: "none" };
7197
7198
  const file = join19(cfg.dir, "chats", `${chatId}.json`);
@@ -7206,9 +7207,13 @@ function resolveBinding(rawConfig, chatId, senderOpenId) {
7206
7207
  const doc = parsed;
7207
7208
  if (doc.version !== BINDING_VERSION) return { kind: "invalid", reason: "version" };
7208
7209
  if (doc.chat_id !== chatId) return { kind: "invalid", reason: "chat-id" };
7209
- if (doc.active === null || doc.active === void 0) return { kind: "none" };
7210
+ const threadTask = opts.threadRootId ? taskOfMessage(cfg.dir, opts.threadRootId) : void 0;
7211
+ const queue = Array.isArray(doc.queue) ? doc.queue : [];
7212
+ const inThread = threadTask ? [doc.active, ...queue].find((x) => x && typeof x === "object" && x.task_id === threadTask) : void 0;
7213
+ if (threadTask && !inThread) return { kind: "none" };
7214
+ if (!inThread && (doc.active === null || doc.active === void 0)) return { kind: "none" };
7210
7215
  if (doc.user_open_id !== senderOpenId) return { kind: "invalid", reason: "user" };
7211
- const task = doc.active;
7216
+ const task = inThread ?? doc.active;
7212
7217
  if (!isTaskItem(task)) return { kind: "invalid", reason: "task-shape" };
7213
7218
  if (typeof task.budget_usd !== "number" || !Number.isFinite(task.budget_usd) || task.budget_usd <= 0) {
7214
7219
  return { kind: "invalid", reason: "budget" };
@@ -7242,7 +7247,8 @@ function resolveBinding(rawConfig, chatId, senderOpenId) {
7242
7247
  cwdRealpath: cwdReal,
7243
7248
  settingsFile,
7244
7249
  systemPromptFile: promptReal,
7245
- queued: Array.isArray(doc.queue) ? doc.queue.length : 0
7250
+ queued: queue.length,
7251
+ ...inThread ? { viaThread: true } : {}
7246
7252
  }
7247
7253
  };
7248
7254
  }
@@ -15256,7 +15262,8 @@ async function intakeMessage(deps) {
15256
15262
  function dmBinding(controls, msg, scope, opts = {}) {
15257
15263
  const cfg = controls.profileConfig.preferences.taskBindings;
15258
15264
  if (!cfg) return void 0;
15259
- if (opts.switchByReply) {
15265
+ const threadRootId = msg.threadId ? msg.rootId : void 0;
15266
+ if (opts.switchByReply && !threadRootId) {
15260
15267
  try {
15261
15268
  const moved = switchByReply(cfg, msg.chatId, msg.senderId, [msg.replyToMessageId, msg.rootId]);
15262
15269
  if (moved) log.info("binding", "switched-by-reply", { scope, from: moved.from, to: moved.to, eventWritten: moved.eventWritten });
@@ -15266,7 +15273,7 @@ function dmBinding(controls, msg, scope, opts = {}) {
15266
15273
  }
15267
15274
  let result;
15268
15275
  try {
15269
- result = resolveBinding(cfg, msg.chatId, msg.senderId);
15276
+ result = resolveBinding(cfg, msg.chatId, msg.senderId, { threadRootId });
15270
15277
  } catch (err) {
15271
15278
  result = { kind: "invalid", reason: err instanceof Error ? err.message : String(err) };
15272
15279
  }