aai-lark-bridge 0.1.6 → 0.1.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/README.md CHANGED
@@ -35,6 +35,18 @@ lark-cli --version # 见下方说明
35
35
  **非交互环境不会自动安装**,会打印 `(non-interactive mode; skipping auto-install)`
36
36
  并给出手工安装提示。所以非交互场景请先手工装好 `lark-cli`。
37
37
 
38
+ #### Codex 会话与 shell 兼容性
39
+
40
+ - 话题历史只在本轮真正新建会话时补全,恢复已有会话不重复注入;切换 agent、目录或
41
+ 策略后按实际可恢复身份重新判断。切回旧目录时仍可恢复其 catalog 会话。
42
+ - bridge 的 Codex 调用关闭 shell snapshot 和用户 shell profile 自动加载,并在工具
43
+ shell 中清空会抢占 Lark source 的 Hermes/OpenClaw 标记。只修改本次子进程参数,
44
+ 不改全局 Codex 配置、模型、登录状态或沙箱权限。
45
+ - 若新会话可用,但恢复原会话报 `paginated_threads is not supported`,先检查实际
46
+ `codex.binaryPath` 的版本与会话格式是否兼容。已验证 0.153.4 能恢复本机的 paginated
47
+ 会话;不要通过删历史、改会话元数据或自动另开会话处理兼容问题。
48
+ - 启动失败会显示 stderr 的最后 500 字符,避免真正的终止错误被前面的插件警告盖住。
49
+
38
50
  ### 第 2 步:安装
39
51
 
40
52
  ```bash
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.1.6",
7
+ version: "0.1.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",
@@ -6017,9 +6017,9 @@ var BRIDGE_SYSTEM_PROMPT = `# aai-lark-bridge \u8FD0\u884C\u7EA6\u5B9A
6017
6017
 
6018
6018
  \u4F60\u60F3\u53D1\u4E00\u5F20\u53EF\u4EA4\u4E92\u7684\u5361\u7247\u8BA9\u7528\u6237\u70B9\u9009\u65F6\uFF1A
6019
6019
 
6020
- 1. \u7528 \`lark-cli\` \u628A\u5361\u53D1\u5230 \`bridge_context.chat_id\`\uFF1A
6021
- \`lark-cli im send-card --chat-id <chat_id> --card '<json>'\`
6022
- 2. \u5361\u7247\u7528 CardKit 2.0 schema\uFF08\`schema: "2.0"\`\uFF09\u3002
6020
+ 1. \u5148\u8BFB\u53D6\u5DF2\u5B89\u88C5\u7684 lark-im skill\uFF0C\u6309\u5176\u4E2D\u7684\u5361\u7247\u5DE5\u4F5C\u6D41\u751F\u6210 JSON\uFF0C\u518D\u7528 \`lark-cli\` \u628A\u5361\u53D1\u5230 \`bridge_context.chatId\`\uFF1A
6021
+ \`lark-cli im +messages-send --as bot --chat-id <chat_id> --msg-type interactive --content '<json>'\`
6022
+ 2. \u5361\u7247\u7528 CardKit 2.0 schema\uFF08\`schema: "2.0"\`\uFF09\uFF0C\u53D1\u9001\u540E\u6309\u8FD4\u56DE\u7684 message_id \u8BFB\u53D6\u6838\u9A8C\u3002
6023
6023
  3. **\u5982\u679C\u4F60\u5E0C\u671B\u7528\u6237\u70B9\u6309\u94AE\u540E\u56DE\u8C03\u5230\u4F60\uFF08\u8BA9\u4F60\u5728\u540C\u4E00\u4F1A\u8BDD\u91CC\u7EE7\u7EED\u5904\u7406\uFF09**\uFF1A
6024
6024
  - \u6309\u94AE\u7684 \`value\` \u5BF9\u8C61**\u5FC5\u987B**\u540C\u65F6\u5305\u542B \`__bridge_cb: true\` \u548C \`bridge_token: "<signed token>"\`\u3002
6025
6025
  - \`bridge_token\` \u5FC5\u987B\u7531 bridge-aware \u7684 lark-cli \u56DE\u8C03\u7B7E\u540D\u80FD\u529B\u751F\u6210\uFF1B\u4E0D\u8981\u731C\u6D4B\u3001\u4F2A\u9020\u3001\u590D\u7528\u6216\u624B\u5199 token\u3002
@@ -6058,8 +6058,21 @@ bridge \u4F1A\u7ED9\u4F60\u7684\u5B50\u8FDB\u7A0B\u6CE8\u5165\u5F53\u524D\u8FD0\
6058
6058
 
6059
6059
  \u5982\u679C \`lark-cli\` \u63D0\u793A \`lark-channel context detected but lark-cli is not bound to it\`,\u4E0D\u8981\u6539\u7528\u666E\u901A profile,\u4E0D\u8981\u76F4\u63A5\u8BFB\u53D6 \`config.json\` \u91CC\u7684\u8D26\u53F7\u6216\u5BC6\u94A5,\u4E5F\u4E0D\u8981\u81EA\u884C\u6267\u884C bind\u3002\u505C\u6B62\u5F53\u524D\u64CD\u4F5C\u5E76\u8BF7\u7528\u6237\u91CD\u542F bridge \u6216\u8FD0\u884C bridge doctor/preflight\u3002
6060
6060
 
6061
+ \u5982\u679C\u62A5\u7684\u662F \`hermes context detected\` \u6216 \`openclaw context detected\`\uFF0C\u8FD9\u662F\u5176\u4ED6 agent \u6807\u8BB0\u8FDB\u5165 shell \u540E\u9020\u6210\u7684\u4E0A\u4E0B\u6587\u6C61\u67D3\uFF0C\u4E0D\u662F\u5F53\u524D Lark profile \u672A\u7ED1\u5B9A\u3002\u4E0D\u8981\u5EFA\u8BAE\u91CD\u65B0 OAuth \u6216\u7ED9\u9519\u8BEF\u7684 source \u6267\u884C bind\u3002\u53EA\u68C0\u67E5\u51B2\u7A81\u53D8\u91CF\u662F\u5426\u975E\u7A7A\uFF0C\u4E0D\u8F93\u51FA\u53D8\u91CF\u503C\u6216\u51ED\u636E\uFF1B\u62A5\u544A\u5F53\u524D\u5DE5\u5177\u73AF\u5883\u4E0E bridge preflight \u7684\u5DEE\u5F02\u3002
6062
+
6061
6063
  \u914D\u7F6E\u6587\u4EF6\u53EF\u80FD\u662F\u591A profile \u7ED3\u6784,\u4E0D\u8981\u5047\u8BBE\u6839\u5C42\u4E00\u5B9A\u6709\u65E7\u7248\u5355 profile \u7684 \`accounts.app\`;\u786E\u5B9E\u9700\u8981\u8BFB\u53D6\u914D\u7F6E\u65F6\u6309\u5F53\u524D profile \u53D6\u503C,\u4E14\u4E0D\u8981\u8F93\u51FA\u5BC6\u94A5\u3002
6062
6064
 
6065
+ ## \u6545\u969C\u8BCA\u65AD\u4E0E\u5B8C\u6210\u72B6\u6001
6066
+
6067
+ - \u7528\u6237\u4ECE\u98DE\u4E66\u9605\u8BFB\u7B54\u590D\uFF0C\u65E0\u6CD5\u6253\u5F00\u672C\u673A\u7EDD\u5BF9\u8DEF\u5F84\u3001file:// \u6216\u672C\u673A\u7F16\u8F91\u5668\u94FE\u63A5\u3002\u4EE3\u7801\u4EA4\u4ED8\u63D0\u4F9B\u5DF2\u521B\u5EFA\u5E76\u6838\u5B9E\u7684 MR URL\uFF1B\u9700\u8981\u4EA4\u4ED8\u6587\u4EF6\u65F6\u6309\u4EFB\u52A1\u6388\u6743\u4E0A\u4F20\u5230\u98DE\u4E66\u5E76\u6838\u9A8C\u8FD4\u56DE\u94FE\u63A5\u6216\u9644\u4EF6\u3002\u53EA\u5199\u5165\u672C\u673A\u65F6\u660E\u786E\u201C\u4EC5\u4FDD\u5B58\u5728\u672C\u673A\uFF0C\u5C1A\u672A\u4E0A\u4F20\u201D\uFF0C\u53EF\u7528\u7EAF\u6587\u672C\u8DEF\u5F84\u4F9B\u5B9A\u4F4D\uFF0C\u4F46\u4E0D\u80FD\u5305\u88C5\u6210\u5DF2\u4EA4\u4ED8\u7684\u53EF\u70B9\u51FB\u94FE\u63A5\u3002\u51C6\u5907\u597D MR \u63CF\u8FF0\u4E0D\u7B49\u4E8E\u5DF2\u63D0\u4EA4 MR\u3002
6068
+ - \u8FDB\u5EA6\u7528\u7B80\u77ED\u52A8\u4F5C\u548C\u5B9E\u9645\u7ED3\u679C\u8BF4\u660E\uFF1B\u4E0D\u8981\u590D\u5236\u539F\u59CB shell \u547D\u4EE4\u3001\u73AF\u5883\u53D8\u91CF\u6216\u5DE5\u5177\u8F93\u51FA\u5230\u7528\u6237\u8FDB\u5EA6\u3002\u9700\u8981\u6392\u969C\u7EC6\u8282\u65F6\u53EA\u5C55\u793A\u4E0E\u95EE\u9898\u6709\u5173\u4E14\u5DF2\u8131\u654F\u7684\u5185\u5BB9\u3002
6069
+ - \u5206\u5F00\u62A5\u544A\u672C\u5730\u63D0\u4EA4\u3001\u8FDC\u7AEF\u63A8\u9001\u3001MR \u521B\u5EFA\u3001\u5408\u5E76\u3001\u53D1\u5E03\u3001\u5B89\u88C5\u3001\u91CD\u542F\u3001\u771F\u5B9E\u4E1A\u52A1\u9A8C\u6536\u3002\u6BCF\u4E00\u9879\u53EA\u6309\u672C\u8F6E\u53EF\u6838\u67E5\u8BC1\u636E\u786E\u8BA4\uFF1B\u8FDB\u7A0B\u5728\u7EBF\u6216\u6D4B\u8BD5\u901A\u8FC7\u4E0D\u80FD\u66FF\u4EE3\u7528\u6237\u8981\u6C42\u7684\u4EA4\u4ED8\u7269\u3002
6070
+ - \u7F51\u7EDC\u6216\u6743\u9650\u4E0D\u8DB3\u65F6\u8BF4\u201C\u65E0\u6CD5\u6838\u5B9E\u201D\uFF0C\u4E0D\u8981\u4ECE\u672C\u5730\u63A8\u9001\u5931\u8D25\u3001\u65E7\u5206\u652F\u6216\u65E7\u56DE\u7B54\u63A8\u65AD\u8FDC\u7AEF MR \u4E0D\u5B58\u5728\u3002\u8DE8\u65E5\u6216\u957F\u65F6\u95F4\u7EED\u804A\u5148\u6838\u5BF9\u5F53\u524D\u65F6\u95F4\u3002
6071
+ - \u591A\u6B21\u5931\u8D25\u8981\u9010\u6B21\u6838\u5BF9 scope\u3001\u6062\u590D\u7684\u4F1A\u8BDD\u3001\u8FD0\u884C\u7248\u672C\u548C\u9519\u8BEF\u53D1\u751F\u9636\u6BB5\u3002\u666E\u901A\u79C1\u804A\u7684 topicContext=0\uFF0C\u4E0D\u80FD\u7528\u8BDD\u9898\u91CD\u590D\u6CE8\u5165\u89E3\u91CA\uFF1B\u6267\u884C\u8FC7\u5DE5\u5177\u540E\u624D\u62D2\u7EDD\uFF0C\u4E5F\u4E0D\u80FD\u8BF4\u6210\u6240\u6709\u8BF7\u6C42\u90FD\u5728\u4F1A\u8BDD\u5EFA\u7ACB\u524D\u5931\u8D25\u3002
6072
+ - \u4E0A\u6E38\u62D2\u7EDD\u7684\u6839\u56E0\u672A\u590D\u73B0\u65F6\u6807\u4E3A\u5F85\u67E5\u3002\u4E0D\u8981\u5173\u95ED\u5BA1\u6838\u3001\u6539\u5199\u8BF7\u6C42\u4EE5\u89C4\u907F\u5BA1\u6838\u6216\u9759\u9ED8\u5220\u9664\u4F1A\u8BDD\u5386\u53F2\uFF1B\u4E0D\u8981\u628A\u65B0\u4F1A\u8BDD\u6210\u529F\u5F53\u6210\u539F\u4F1A\u8BDD\u5DF2\u4FEE\u590D\u3002
6073
+ - \u6C99\u7BB1\u62D2\u7EDD\u670D\u52A1\u7BA1\u7406\u65F6\u5982\u5B9E\u62A5\u544A\uFF0C\u4E0D\u6269\u5927\u6743\u9650\u6216\u53CD\u590D\u91CD\u8BD5\u3002\`/reconnect\` \u53EA\u91CD\u8FDE\u6216\u70ED\u52A0\u8F7D\uFF0C\u4E0D\u80FD\u5F53\u6210\u5B89\u88C5\u65B0\u4EE3\u7801\u540E\u7684\u5B8C\u6574\u8FDB\u7A0B\u91CD\u542F\u3002
6074
+ - \u5361\u7247\u6216\u5B9A\u65F6\u63A8\u9001\u53EA\u6709\u5728\u53D1\u9001\u6210\u529F\u5E76\u8BFB\u56DE\u5185\u5BB9\u3001\u6392\u7A0B\u88AB\u5B9E\u9645\u6CE8\u518C\u540E\u624D\u7B97\u4EA4\u4ED8\uFF1B\u5148\u524D\u7528\u6237\u5C1A\u672A\u5B8C\u6210\u7684\u8BF7\u6C42\u8981\u660E\u786E\u5217\u51FA\uFF0C\u4E0D\u80FD\u628A\u8BCA\u65AD\u56DE\u590D\u5F53\u4F5C\u5B8C\u6210\u3002
6075
+
6063
6076
  ## \u98DE\u4E66 OAuth \u6388\u6743\uFF08\`lark-cli auth login\`\uFF09
6064
6077
 
6065
6078
  \u6388\u6743\u6D41\u7A0B\u8981\u8BA9 \`lark-cli\` \u8FDB\u7A0B\u4E00\u76F4\u6D3B\u5230\u7528\u6237\u5728\u6D4F\u89C8\u5668\u91CC\u70B9\u5B8C\u4E3A\u6B62\u3002bridge \u5728\u4F60\u7684 run \u7ED3\u675F\u4E4B\u540E\u4F1A\u56DE\u6536 agent \u5B50\u8FDB\u7A0B\uFF0C**\u4F60 spawn \u7684\u4EFB\u4F55\u540E\u53F0 bash \u4E5F\u4F1A\u8DDF\u7740\u6B7B**\u2014\u2014\u6240\u4EE5\u6388\u6743\u5FC5\u987B\u7528"\u524D\u53F0\u963B\u585E"\u7684\u65B9\u5F0F\u8DD1\uFF1A
@@ -6169,11 +6182,14 @@ function* translateEvent(raw) {
6169
6182
  return;
6170
6183
  }
6171
6184
  if (evt.is_error === true) {
6172
- const apiError = evt.terminal_reason === "api_error";
6185
+ const message = errorMessage2(evt);
6186
+ const authError = isAuthFailure(message);
6187
+ const apiError = !authError && evt.terminal_reason === "api_error";
6173
6188
  yield {
6174
6189
  type: "error",
6175
- message: errorMessage2(evt),
6190
+ message,
6176
6191
  terminationReason: "failed",
6192
+ ...authError ? { authError: true } : {},
6177
6193
  ...apiError ? { apiError: true } : {}
6178
6194
  };
6179
6195
  return;
@@ -6181,6 +6197,10 @@ function* translateEvent(raw) {
6181
6197
  yield { type: "done", sessionId: evt.session_id, terminationReason: "normal" };
6182
6198
  }
6183
6199
  }
6200
+ var AUTH_FAILURE = /failed to authenticate|login expired|not logged in|invalid api key|re-authenticate/i;
6201
+ function isAuthFailure(message) {
6202
+ return AUTH_FAILURE.test(message);
6203
+ }
6184
6204
  function errorMessage2(evt) {
6185
6205
  const text = typeof evt.result === "string" ? evt.result.trim() : "";
6186
6206
  if (text) return text;
@@ -6488,6 +6508,16 @@ function buildCodexArgs(input) {
6488
6508
  'approval_policy="never"',
6489
6509
  "-c",
6490
6510
  'shell_environment_policy.inherit="all"',
6511
+ // Shell snapshots source the user's interactive rc and can restore agent
6512
+ // markers after spawn-time cleanup. Keep this scoped to bridge runs.
6513
+ "-c",
6514
+ "features.shell_snapshot=false",
6515
+ "-c",
6516
+ "shell_environment_policy.experimental_use_profile=false",
6517
+ ...COMPETING_AGENT_ENV_VARS.flatMap((key) => [
6518
+ "-c",
6519
+ `shell_environment_policy.set.${key}=""`
6520
+ ]),
6491
6521
  ...input.ignoreUserConfig === true ? ["--ignore-user-config"] : [],
6492
6522
  ...input.ignoreRules === false ? [] : ["--ignore-rules"],
6493
6523
  "--skip-git-repo-check",
@@ -6925,7 +6955,7 @@ async function* createEventStream2(child, stderrTail, getError, getStopReason) {
6925
6955
  if (exitCode !== 0 && exitCode !== null) {
6926
6956
  if (!translator.terminalEmitted()) {
6927
6957
  const stderr = stderrTail.text();
6928
- const detail = stderr ? `: ${stderr.slice(0, 500)}` : "";
6958
+ const detail = stderr ? `: ${stderr.slice(-500)}` : "";
6929
6959
  yield* translator.fail(`codex exited with code ${exitCode}${detail}`);
6930
6960
  }
6931
6961
  return;
@@ -8045,123 +8075,41 @@ function deepMaskEmails(value) {
8045
8075
  }
8046
8076
 
8047
8077
  // src/bridge/card/tool-render.ts
8048
- var HEADER_SUMMARY_MAX = 80;
8049
- var BODY_FIELD_MAX = 600;
8050
- var OUTPUT_MAX = 1200;
8051
- var BODY_TOTAL_MAX = 2500;
8052
- function toolHeaderText(tool) {
8053
- const icon = tool.status === "done" ? "\u2705" : tool.status === "error" ? "\u274C" : "\u23F3";
8054
- const summary = summarizeInput(tool.name, tool.input);
8055
- return summary ? `${icon} **${tool.name}** \u2014 ${summary}` : `${icon} **${tool.name}**`;
8056
- }
8057
- function toolBodyMd(tool) {
8058
- const parts = [];
8059
- const inputMd = renderInput(tool);
8060
- if (inputMd) parts.push(inputMd);
8061
- if (tool.output) {
8062
- const truncated = truncate2(tool.output, OUTPUT_MAX);
8063
- if (tool.status === "error") {
8064
- parts.push(`**Error**
8065
- \`\`\`
8066
- ${truncated}
8067
- \`\`\``);
8068
- } else if (tool.name === "Bash") {
8069
- parts.push(renderBashOutput(truncated));
8070
- } else {
8071
- parts.push(`**Output**
8072
- \`\`\`
8073
- ${truncated}
8074
- \`\`\``);
8075
- }
8076
- } else if (tool.status === "running") {
8077
- parts.push("_\u8FD0\u884C\u4E2D\u2026_");
8078
- }
8079
- const body = parts.join("\n\n");
8080
- if (body.length <= BODY_TOTAL_MAX) return body;
8081
- return `${body.slice(0, BODY_TOTAL_MAX)}\u2026
8082
-
8083
- _\uFF08body \u5DF2\u622A\u65AD,\u5B8C\u6574\u5185\u5BB9\u67E5 \`/doctor\` \u6216\u65E5\u5FD7\uFF09_`;
8084
- }
8085
- function summarizeInput(name, input) {
8086
- if (!input || typeof input !== "object") return "";
8087
- const rec = input;
8088
- const pick = (key, max = HEADER_SUMMARY_MAX) => {
8089
- const v = rec[key];
8090
- if (typeof v !== "string") return "";
8091
- const oneLine = v.replace(/\s+/g, " ").trim();
8092
- return oneLine.length > max ? `${oneLine.slice(0, max)}\u2026` : oneLine;
8093
- };
8078
+ function actionLabel(name) {
8094
8079
  switch (name) {
8095
8080
  case "Bash":
8096
- return pick("command");
8081
+ case "command_execution":
8082
+ case "exec_command":
8083
+ return "\u6267\u884C\u547D\u4EE4";
8097
8084
  case "Read":
8085
+ return "\u8BFB\u53D6\u6587\u4EF6";
8098
8086
  case "Edit":
8099
8087
  case "Write":
8100
8088
  case "NotebookEdit":
8101
- return shortenPath(pick("file_path"));
8102
- case "Grep": {
8103
- const pat = pick("pattern", 40);
8104
- const path = pick("path", 30);
8105
- return path ? `${pat} in ${shortenPath(path)}` : pat;
8106
- }
8089
+ case "apply_patch":
8090
+ return "\u4FEE\u6539\u6587\u4EF6";
8091
+ case "Grep":
8107
8092
  case "Glob":
8108
- return pick("pattern");
8093
+ return "\u641C\u7D22\u6587\u4EF6";
8109
8094
  case "WebFetch":
8110
- return pick("url");
8111
8095
  case "WebSearch":
8112
- return pick("query", 60);
8096
+ return "\u67E5\u8BE2\u7F51\u9875";
8113
8097
  case "Agent":
8114
8098
  case "Task":
8115
- return pick("description") || pick("subagent_type");
8099
+ return "\u6267\u884C\u5B50\u4EFB\u52A1";
8116
8100
  default:
8117
- return pick("command") || pick("file_path") || pick("path") || pick("query");
8118
- }
8119
- }
8120
- function renderInput(tool) {
8121
- const input = tool.input;
8122
- if (!input || typeof input !== "object") return "";
8123
- const rec = input;
8124
- const str2 = (k) => typeof rec[k] === "string" ? rec[k] : "";
8125
- switch (tool.name) {
8126
- case "Bash": {
8127
- const cmd = str2("command");
8128
- return cmd ? `**Command**
8129
- \`\`\`bash
8130
- ${truncate2(cmd, BODY_FIELD_MAX)}
8131
- \`\`\`` : "";
8132
- }
8133
- case "Read":
8134
- case "Edit":
8135
- case "Write":
8136
- case "NotebookEdit": {
8137
- const fp = str2("file_path");
8138
- return fp ? `**File** \`${fp}\`` : "";
8139
- }
8140
- case "Grep": {
8141
- const lines = [];
8142
- if (str2("pattern")) lines.push(`**Pattern** \`${str2("pattern")}\``);
8143
- if (str2("path")) lines.push(`**Path** \`${str2("path")}\``);
8144
- return lines.join("\n");
8145
- }
8146
- case "WebFetch":
8147
- return str2("url") ? `**URL** ${str2("url")}` : "";
8148
- case "WebSearch":
8149
- return str2("query") ? `**Query** \`${truncate2(str2("query"), BODY_FIELD_MAX)}\`` : "";
8150
- default:
8151
- return "";
8101
+ return "\u8C03\u7528\u5DE5\u5177";
8152
8102
  }
8153
8103
  }
8154
- function renderBashOutput(out) {
8155
- return `**Output**
8156
- \`\`\`
8157
- ${out}
8158
- \`\`\``;
8104
+ function toolHeaderText(tool, finalized = false) {
8105
+ const icon = tool.status === "done" ? "\u2705" : tool.status === "error" ? "\u274C" : finalized ? "\u26AA" : "\u23F3";
8106
+ const suffix = finalized && tool.status === "running" ? "\uFF08\u5DF2\u7ED3\u675F\uFF0C\u672A\u6536\u5230\u7ED3\u679C\uFF09" : "";
8107
+ return `${icon} **${actionLabel(tool.name)}**${suffix}`;
8159
8108
  }
8160
- function shortenPath(p3) {
8161
- return p3;
8162
- }
8163
- function truncate2(s, max) {
8164
- return s.length > max ? `${s.slice(0, max)}\u2026` : s;
8109
+ function toolBodyMd(tool, finalized = false) {
8110
+ if (tool.status === "done") return "\u6267\u884C\u5B8C\u6210\u3002";
8111
+ if (tool.status === "error") return "\u6267\u884C\u5931\u8D25\uFF0C\u5177\u4F53\u539F\u56E0\u8BF7\u89C1\u52A9\u624B\u8BF4\u660E\u3002";
8112
+ return finalized ? "\u672C\u8F6E\u5DF2\u7ED3\u675F\uFF0C\u672A\u6536\u5230\u6B64\u5DE5\u5177\u7684\u7ED3\u679C\u3002" : "\u6B63\u5728\u6267\u884C\u2026";
8165
8113
  }
8166
8114
 
8167
8115
  // src/bridge/card/run-renderer.ts
@@ -8187,13 +8135,7 @@ function renderCard(state, options = {}) {
8187
8135
  const mins = state.idleTimeoutMinutes ?? 0;
8188
8136
  elements.push(noteMd(`_\u23F1 ${mins} \u5206\u949F\u65E0\u54CD\u5E94,\u5DF2\u81EA\u52A8\u7EC8\u6B62_`));
8189
8137
  } else if (state.terminal === "error" && state.errorMsg) {
8190
- elements.push(
8191
- noteMd(
8192
- state.apiError ? `\u26A0\uFE0F \u4E0A\u6E38 API \u8FDE\u63A5\u4E2D\u65AD\uFF1A${state.errorMsg}
8193
-
8194
- _\u4E0D\u662F\u8FD9\u6761\u8BF7\u6C42\u7684\u95EE\u9898\uFF0C\u91CD\u53D1\u5373\u53EF\u7EE7\u7EED\uFF08\u4F1A\u8BDD\u4E0A\u4E0B\u6587\u6CA1\u4E22\uFF09\u3002_` : `\u26A0\uFE0F agent \u5931\u8D25\uFF1A${state.errorMsg}`
8195
- )
8196
- );
8138
+ elements.push(noteMd(errorNote(state, state.errorMsg)));
8197
8139
  } else if (state.terminal === "done" && elements.length === 0) {
8198
8140
  elements.push(noteMd("_\uFF08\u672A\u8FD4\u56DE\u5185\u5BB9\uFF09_"));
8199
8141
  }
@@ -8228,7 +8170,7 @@ function* groupBlocks(blocks) {
8228
8170
  function renderToolGroup(tools, finalized) {
8229
8171
  if (tools.length === 0) return [];
8230
8172
  if (tools.length < COLLAPSE_TOOL_THRESHOLD) {
8231
- return tools.map((t) => toolPanel(t, false));
8173
+ return tools.map((t) => toolPanel(t, false, finalized));
8232
8174
  }
8233
8175
  if (finalized) {
8234
8176
  return [collapsedToolSummary(tools, true)];
@@ -8246,21 +8188,21 @@ function reasoningPanel(content, active3) {
8246
8188
  title,
8247
8189
  expanded: active3,
8248
8190
  border: "grey",
8249
- body: truncate3(content, REASONING_MAX)
8191
+ body: truncate2(content, REASONING_MAX)
8250
8192
  });
8251
8193
  }
8252
- function toolPanel(tool, expanded) {
8194
+ function toolPanel(tool, expanded, finalized = false) {
8253
8195
  return collapsiblePanel({
8254
- title: toolHeaderText(tool),
8196
+ title: toolHeaderText(tool, finalized),
8255
8197
  expanded,
8256
8198
  border: tool.status === "error" ? "red" : "grey",
8257
- body: toolBodyMd(tool) || "_\u65E0\u8F93\u51FA_"
8199
+ body: toolBodyMd(tool, finalized)
8258
8200
  });
8259
8201
  }
8260
8202
  function collapsedToolSummary(tools, finalized) {
8261
8203
  const suffix = finalized ? "\uFF08\u5DF2\u7ED3\u675F\uFF09" : "";
8262
8204
  const title = `\u2615 **${tools.length} \u4E2A\u5DE5\u5177\u8C03\u7528${suffix}**`;
8263
- const headerList = tools.map((t) => `- ${toolHeaderText(t)}`).join("\n");
8205
+ const headerList = tools.map((t) => `- ${toolHeaderText(t, finalized)}`).join("\n");
8264
8206
  return {
8265
8207
  tag: "collapsible_panel",
8266
8208
  expanded: false,
@@ -8319,17 +8261,33 @@ function apiRetryText(apiRetry) {
8319
8261
  const of = apiRetry.maxRetries ? `/${apiRetry.maxRetries}` : "";
8320
8262
  return `\u{1F50C} API \u8FDE\u63A5\u4E2D\u65AD,\u6B63\u5728\u91CD\u8BD5 (${apiRetry.attempt}${of})`;
8321
8263
  }
8264
+ function errorNote(state, errorMsg) {
8265
+ if (state.authError) {
8266
+ return `\u26A0\uFE0F agent \u8BA4\u8BC1\u5931\u8D25\uFF1A${errorMsg}
8267
+
8268
+ _\u91CD\u53D1\u6CA1\u7528\u2014\u2014\u8981\u5230\u8DD1 bridge \u7684\u673A\u5668\u4E0A\u91CD\u65B0\u767B\u5F55\uFF08Claude Code \u91CC\u6267\u884C \`/login\`\uFF09\uFF0C\u767B\u5F55\u540E\u8FD9\u4E2A\u4F1A\u8BDD\u53EF\u4EE5\u63A5\u7740\u7528\u3002_`;
8269
+ }
8270
+ if (state.apiError) {
8271
+ return `\u26A0\uFE0F \u4E0A\u6E38 API \u8FDE\u63A5\u4E2D\u65AD\uFF1A${errorMsg}
8272
+
8273
+ _\u4E0D\u662F\u8FD9\u6761\u8BF7\u6C42\u7684\u95EE\u9898\uFF0C\u91CD\u53D1\u5373\u53EF\u7EE7\u7EED\uFF08\u4F1A\u8BDD\u4E0A\u4E0B\u6587\u6CA1\u4E22\uFF09\u3002_`;
8274
+ }
8275
+ return `\u26A0\uFE0F agent \u5931\u8D25\uFF1A${errorMsg}`;
8276
+ }
8322
8277
  function summaryText(state) {
8323
8278
  if (state.terminal === "interrupted") return "\u5DF2\u4E2D\u65AD";
8324
8279
  if (state.terminal === "idle_timeout") return "\u5DF2\u8D85\u65F6";
8325
- if (state.terminal === "error") return state.apiError ? "API \u8FDE\u63A5\u4E2D\u65AD" : "\u51FA\u9519";
8280
+ if (state.terminal === "error") {
8281
+ if (state.authError) return "\u8BA4\u8BC1\u5931\u8D25";
8282
+ return state.apiError ? "API \u8FDE\u63A5\u4E2D\u65AD" : "\u51FA\u9519";
8283
+ }
8326
8284
  if (state.terminal === "done") return "\u5DF2\u5B8C\u6210";
8327
8285
  if (state.footer === "api_retry") return "API \u91CD\u8BD5\u4E2D";
8328
8286
  if (state.footer === "tool_running") return "\u6B63\u5728\u8C03\u7528\u5DE5\u5177";
8329
8287
  if (state.footer === "streaming") return "\u6B63\u5728\u8F93\u51FA";
8330
8288
  return "\u601D\u8003\u4E2D";
8331
8289
  }
8332
- function truncate3(s, max) {
8290
+ function truncate2(s, max) {
8333
8291
  return s.length > max ? `${s.slice(0, max)}\u2026` : s;
8334
8292
  }
8335
8293
 
@@ -8423,6 +8381,7 @@ function reduce(state, evt) {
8423
8381
  terminal,
8424
8382
  errorMsg: terminal === "error" ? evt.message : state.errorMsg,
8425
8383
  ...terminal === "error" && evt.apiError ? { apiError: true } : {},
8384
+ ...terminal === "error" && evt.authError ? { authError: true } : {},
8426
8385
  footer: null
8427
8386
  };
8428
8387
  }
@@ -9637,18 +9596,23 @@ async function startRunFlow(input) {
9637
9596
  }
9638
9597
  }
9639
9598
  if (!resumeFrom && input.capability.agentId === "claude") {
9640
- resumeFrom = input.sessions.resumeFor(input.scopeId, workspace.cwdRealpath);
9599
+ const legacySessionId = input.sessions.resumeFor(input.scopeId, workspace.cwdRealpath);
9600
+ const catalogOwnsSession = legacySessionId && input.sessionCatalog?.entries().some(
9601
+ (entry) => entry.scopeId === input.scopeId && entry.agentId === "claude" && entry.sessionId === legacySessionId
9602
+ );
9603
+ resumeFrom = catalogOwnsSession ? void 0 : legacySessionId;
9641
9604
  sessionId = resumeFrom;
9642
9605
  const stale = input.sessions.getRaw(input.scopeId);
9643
9606
  if (!resumeFrom && stale?.cwd && stale.cwd !== workspace.cwdRealpath) {
9644
9607
  input.sessions.clear(input.scopeId);
9645
9608
  }
9646
9609
  }
9610
+ const runPolicy = !resumeFrom && input.prepareFreshPrompt ? { ...policy, prompt: await input.prepareFreshPrompt() } : policy;
9647
9611
  let execution;
9648
9612
  try {
9649
9613
  execution = await input.executor.submit({
9650
9614
  scopeId: input.scopeId,
9651
- policy,
9615
+ policy: runPolicy,
9652
9616
  sessionId,
9653
9617
  threadId,
9654
9618
  model: resolveModelArg(
@@ -9675,7 +9639,7 @@ async function startRunFlow(input) {
9675
9639
  return {
9676
9640
  ok: true,
9677
9641
  execution,
9678
- policy,
9642
+ policy: runPolicy,
9679
9643
  cwdRealpath: workspace.cwdRealpath,
9680
9644
  ...resumeFrom ? { resumeFrom } : {}
9681
9645
  };
@@ -12051,7 +12015,7 @@ function decodeEntry(value) {
12051
12015
  function renderText(state) {
12052
12016
  const parts = [];
12053
12017
  for (const block of state.blocks) {
12054
- const piece = renderBlock(block);
12018
+ const piece = renderBlock(block, state.terminal !== "running");
12055
12019
  if (piece) parts.push(piece);
12056
12020
  }
12057
12021
  if (state.terminal === "interrupted") {
@@ -12060,24 +12024,33 @@ function renderText(state) {
12060
12024
  const mins = state.idleTimeoutMinutes ?? 0;
12061
12025
  parts.push(`_\u23F1 ${mins} \u5206\u949F\u65E0\u54CD\u5E94,\u5DF2\u81EA\u52A8\u7EC8\u6B62_`);
12062
12026
  } else if (state.terminal === "error" && state.errorMsg) {
12063
- parts.push(
12064
- state.apiError ? `\u26A0\uFE0F \u4E0A\u6E38 API \u8FDE\u63A5\u4E2D\u65AD:${state.errorMsg}
12065
-
12066
- _\u4E0D\u662F\u8FD9\u6761\u8BF7\u6C42\u7684\u95EE\u9898,\u91CD\u53D1\u5373\u53EF\u7EE7\u7EED(\u4F1A\u8BDD\u4E0A\u4E0B\u6587\u6CA1\u4E22)\u3002_` : `\u26A0\uFE0F agent \u5931\u8D25:${state.errorMsg}`
12067
- );
12027
+ parts.push(errorNote2(state, state.errorMsg));
12068
12028
  } else if (state.terminal === "running" && state.footer) {
12069
12029
  parts.push(footerLine(state.footer, state.apiRetry));
12070
12030
  }
12071
12031
  return maskEmails(parts.join("\n\n"));
12072
12032
  }
12073
- function renderBlock(block) {
12033
+ function errorNote2(state, errorMsg) {
12034
+ if (state.authError) {
12035
+ return `\u26A0\uFE0F agent \u8BA4\u8BC1\u5931\u8D25:${errorMsg}
12036
+
12037
+ _\u91CD\u53D1\u6CA1\u7528\u2014\u2014\u8981\u5230\u8DD1 bridge \u7684\u673A\u5668\u4E0A\u91CD\u65B0\u767B\u5F55(Claude Code \u91CC\u6267\u884C \`/login\`),\u767B\u5F55\u540E\u8FD9\u4E2A\u4F1A\u8BDD\u53EF\u4EE5\u63A5\u7740\u7528\u3002_`;
12038
+ }
12039
+ if (state.apiError) {
12040
+ return `\u26A0\uFE0F \u4E0A\u6E38 API \u8FDE\u63A5\u4E2D\u65AD:${errorMsg}
12041
+
12042
+ _\u4E0D\u662F\u8FD9\u6761\u8BF7\u6C42\u7684\u95EE\u9898,\u91CD\u53D1\u5373\u53EF\u7EE7\u7EED(\u4F1A\u8BDD\u4E0A\u4E0B\u6587\u6CA1\u4E22)\u3002_`;
12043
+ }
12044
+ return `\u26A0\uFE0F agent \u5931\u8D25:${errorMsg}`;
12045
+ }
12046
+ function renderBlock(block, finalized) {
12074
12047
  if (block.kind === "text") {
12075
12048
  return block.content.trim();
12076
12049
  }
12077
- return toolLine(block.tool);
12050
+ return toolLine(block.tool, finalized);
12078
12051
  }
12079
- function toolLine(tool) {
12080
- return `> ${toolHeaderText(tool)}`;
12052
+ function toolLine(tool, finalized) {
12053
+ return `> ${toolHeaderText(tool, finalized)}`;
12081
12054
  }
12082
12055
  function footerLine(status, apiRetry) {
12083
12056
  if (status === "thinking") return "_\u{1F9E0} \u6B63\u5728\u601D\u8003\u2026_";
@@ -13986,7 +13959,7 @@ async function consumeCotEvents(events, publisher, opts) {
13986
13959
  toolCallId,
13987
13960
  icon: showSummary ? cotToolIcon(evt.name) : "default",
13988
13961
  title,
13989
- toolCallName: showSummary ? evt.name : "tool"
13962
+ toolCallName: detailed ? evt.name : "tool"
13990
13963
  });
13991
13964
  if (detailed && evt.input !== void 0) {
13992
13965
  publisher.enqueue("TOOL_CALL_ARGS", {
@@ -14104,7 +14077,7 @@ var STREAM_TRUSTED_LIFETIME_MS = 9 * 6e4;
14104
14077
  var BRIDGE_AGENT_INSTRUCTIONS = [
14105
14078
  "\u4F60\u5728 bridge \u8FDB\u7A0B\u4E2D\u8FD0\u884C\uFF0C\u666E\u901A lark-cli \u4F1A\u7EE7\u627F LARK_CHANNEL=1 \u5E76\u8FDB\u5165 bridge-bound \u6A21\u5F0F\u3002",
14106
14079
  "\u4E0D\u8981 unset LARK_CHANNEL / LARK_CHANNEL_HOME / LARK_CHANNEL_PROFILE / LARKSUITE_CLI_CONFIG_DIR\uFF0C\u4E5F\u4E0D\u8981\u7528 env -u LARK_CHANNEL \u7ED5\u56DE\u672C\u673A\u666E\u901A\u914D\u7F6E\u3002",
14107
- "Codex bridge \u9ED8\u8BA4\u4F7F\u7528 danger-full-access \u5BF9\u9F50 Claude bridge \u7684 bypassPermissions \u884C\u4E3A\uFF0C\u56E0\u6B64 lark-cli \u5E94\u80FD\u50CF\u7528\u6237\u672C\u673A\u7EC8\u7AEF\u4E00\u6837\u8BBF\u95EE keychain\u3002",
14080
+ "\u5B9E\u9645\u6C99\u7BB1\u4E0E keychain \u53EF\u7528\u6027\u53D6\u51B3\u4E8E\u5F53\u524D profile \u548C\u5BBF\u4E3B\u6743\u9650\uFF0C\u5E94\u4EE5\u5DE5\u5177\u68C0\u67E5\u7ED3\u679C\u4E3A\u51C6\uFF1B\u4E0D\u8981\u4E3A\u4E86\u8BBF\u95EE\u51ED\u636E\u800C\u6269\u5927\u6743\u9650\u6216\u5173\u95ED\u5BA1\u6838\u3002",
14108
14081
  "\u5982\u679C\u63D0\u793A lark-channel context detected but not bound\uFF0C\u505C\u6B62\u5F53\u524D\u64CD\u4F5C\u5E76\u8BF7\u7528\u6237\u91CD\u542F bridge \u6216\u8FD0\u884C bridge doctor/preflight\uFF1B\u4E0D\u8981\u6539\u7528\u666E\u901A profile\uFF0C\u4E0D\u8981\u81EA\u884C bind\uFF0C\u4E5F\u4E0D\u8981\u76F4\u63A5\u8BFB\u53D6 config.json \u91CC\u7684\u8D26\u53F7\u6216\u5BC6\u94A5\u3002"
14109
14082
  ];
14110
14083
  var SUPPRESSED_API_ERROR_CODES = /* @__PURE__ */ new Set([
@@ -14724,27 +14697,7 @@ async function runAgentBatch(deps) {
14724
14697
  });
14725
14698
  }
14726
14699
  }
14727
- const scopeCwd = workspaces.cwdFor(scope);
14728
- const scopeEngaged = Boolean(sessions2.getRaw(scope)) || (sessionCatalog?.hasResumableForScope({
14729
- scopeId: scope,
14730
- agentId: controls.profileConfig.agentKind,
14731
- ...scopeCwd ? { cwdRealpath: scopeCwd } : {}
14732
- }) ?? false);
14733
14700
  let topicContext = [];
14734
- if (mode === "topic" && threadId && !scopeEngaged) {
14735
- const exclude = /* @__PURE__ */ new Set([...batchIds, ...quoteTargets]);
14736
- topicContext = await fetchTopicContext(channel, threadId, {
14737
- maxMessages: 40,
14738
- excludeIds: exclude
14739
- });
14740
- if (topicContext.length > 0) {
14741
- log.info("topic", "context-fetched", {
14742
- scope,
14743
- threadId,
14744
- count: topicContext.length
14745
- });
14746
- }
14747
- }
14748
14701
  const agentKind = controls.profileConfig.agentKind;
14749
14702
  const modelPref = controls.profileConfig.preferences.model;
14750
14703
  const modelSelection = normalizeModelSelection(agentKind, modelPref);
@@ -14763,12 +14716,6 @@ async function runAgentBatch(deps) {
14763
14716
  channel.botIdentity,
14764
14717
  extraInstructions
14765
14718
  );
14766
- log.info("prompt", "built", {
14767
- promptChars: prompt.length,
14768
- quotes: quotes.length,
14769
- topicContext: topicContext.length,
14770
- ...modelSwitched ? { modelSwitchedTo: modelSelection } : {}
14771
- });
14772
14719
  const sendOpts = {
14773
14720
  replyTo: lastMsg.messageId,
14774
14721
  ...mode === "topic" && threadId ? { replyInThread: true } : {}
@@ -14793,6 +14740,17 @@ async function runAgentBatch(deps) {
14793
14740
  scopeId: scope,
14794
14741
  scope: scopeContext,
14795
14742
  prompt,
14743
+ prepareFreshPrompt: async () => {
14744
+ if (mode !== "topic" || !threadId) return prompt;
14745
+ topicContext = await fetchTopicContext(channel, threadId, {
14746
+ maxMessages: 40,
14747
+ excludeIds: /* @__PURE__ */ new Set([...batchIds, ...quoteTargets])
14748
+ });
14749
+ if (topicContext.length > 0) {
14750
+ log.info("topic", "context-fetched", { scope, threadId, count: topicContext.length });
14751
+ }
14752
+ return buildPrompt(batch, attachments, quotes, topicContext, channel.botIdentity, extraInstructions);
14753
+ },
14796
14754
  attachments: attachments.map(toPolicyAttachment),
14797
14755
  access: accessDecision,
14798
14756
  capability,
@@ -14821,6 +14779,12 @@ async function runAgentBatch(deps) {
14821
14779
  return;
14822
14780
  }
14823
14781
  const { execution, cwdRealpath: cwd } = flow;
14782
+ log.info("prompt", "built", {
14783
+ promptChars: flow.policy.prompt.length,
14784
+ quotes: quotes.length,
14785
+ topicContext: topicContext.length,
14786
+ ...modelSwitched ? { modelSwitchedTo: modelSelection } : {}
14787
+ });
14824
14788
  activePolicyFingerprints.set(scope, flow.policy.policyFingerprint);
14825
14789
  const handle2 = execution.handle;
14826
14790
  const eventStream = execution.subscribe();
@@ -14986,6 +14950,7 @@ async function runAgentBatch(deps) {
14986
14950
  log.fail("stream", err, { mode: replyMode, step: "progress-stream" });
14987
14951
  }
14988
14952
  await recallIfEmptyStreamedReply(channel, progress, filterForPrefs(latestState), scope);
14953
+ scheduleProgressTerminalUpdate(channel, progress, filterForPrefs(latestState), scope, replyMode);
14989
14954
  if (controls.profileConfig.agentKind === "codex") {
14990
14955
  await sendFinalReply({
14991
14956
  channel,
@@ -15066,6 +15031,7 @@ async function runAgentBatch(deps) {
15066
15031
  log.fail("stream", err, { mode: replyMode, step: "progress-stream" });
15067
15032
  }
15068
15033
  await recallIfEmptyStreamedReply(channel, progress, filterForPrefs(latestState), scope);
15034
+ scheduleProgressTerminalUpdate(channel, progress, filterForPrefs(latestState), scope, replyMode);
15069
15035
  if (controls.profileConfig.agentKind === "codex") {
15070
15036
  await sendFinalReply({
15071
15037
  channel,
@@ -15165,7 +15131,9 @@ function shouldOpenProgressStream(state) {
15165
15131
  return renderText({ ...state, footer: null }).trim() !== "";
15166
15132
  }
15167
15133
  function finalReplyState(progress, state) {
15168
- if (!progress.opened() || progress.abandoned()) return finalAnswerOnlyState(state);
15134
+ if (!progress.opened() || progress.abandoned() || streamOutlivedCardLifetime(progress)) {
15135
+ return finalAnswerOnlyState(state);
15136
+ }
15169
15137
  return {
15170
15138
  ...state,
15171
15139
  blocks: state.finalText ? [{ kind: "text", content: state.finalText, streaming: false }] : [],
@@ -15175,6 +15143,30 @@ function finalReplyState(progress, state) {
15175
15143
  errorMsg: void 0
15176
15144
  };
15177
15145
  }
15146
+ function scheduleProgressTerminalUpdate(channel, progress, state, scope, mode) {
15147
+ if (!streamOutlivedCardLifetime(progress) || renderText(state).trim() === "") return;
15148
+ void progress.settled.then(async (result) => {
15149
+ const messageId = result?.messageId;
15150
+ if (!messageId) return;
15151
+ try {
15152
+ const terminalState = {
15153
+ ...state,
15154
+ // Markdown never shows reasoning; a repair must preserve that boundary.
15155
+ reasoning: mode === "markdown" ? { content: "", active: false } : state.reasoning,
15156
+ blocks: state.terminal === "done" ? [...state.blocks, { kind: "text", content: "\u672C\u8F6E\u6267\u884C\u5DF2\u7ED3\u675F\u3002", streaming: false }] : state.blocks
15157
+ };
15158
+ await channel.updateCard(messageId, renderCard(terminalState));
15159
+ log.info("outbound", "progress-terminal-updated", { scope, messageId, terminal: state.terminal });
15160
+ } catch (err) {
15161
+ log.warn("outbound", "progress-terminal-update-failed", {
15162
+ scope,
15163
+ messageId,
15164
+ err: err instanceof Error ? err.message : String(err)
15165
+ });
15166
+ }
15167
+ }, () => {
15168
+ });
15169
+ }
15178
15170
  async function recallIfEmptyStreamedReply(channel, progress, finalState, scope) {
15179
15171
  if (!progress.opened()) return;
15180
15172
  if (progress.abandoned()) {
@@ -16943,24 +16935,7 @@ var SessionCatalog = class {
16943
16935
  }
16944
16936
  return { ...entry };
16945
16937
  }
16946
- /**
16947
- * Whether a run for this scope would find something to resume. Callers that
16948
- * run before the policy is resolved cannot build a full identity, but still
16949
- * need to know "has the agent already engaged here" — topic upstream
16950
- * backfill is the case: it must not re-inject the thread's history into a
16951
- * conversation that already carries it.
16952
- *
16953
- * Narrow it with everything the caller *does* know. `activeFor()` resumes
16954
- * only on an exact identity match, so a probe that answers on `scopeId`
16955
- * alone reports "engaged" for entries that will not in fact be resumed —
16956
- * and then a genuinely fresh session starts with no upstream history at all.
16957
- * `/cd` and `/ws use` create exactly that state: they reset the session but
16958
- * deliberately leave the old cwd's entry active so cd-ing back still resumes.
16959
- *
16960
- * `policyFingerprint` is the one axis that stays open: it does not exist
16961
- * until the policy resolves. A profile change that alters it still costs the
16962
- * next fresh session its backfill.
16963
- */
16938
+ /** 按已知身份探测活跃记录;未匹配策略指纹,不能代替实际 resume 或话题补全决策。 */
16964
16939
  hasResumableForScope(probe) {
16965
16940
  for (const entry of this.data.values()) {
16966
16941
  if (entry.scopeId !== probe.scopeId) continue;