dsh-im-lark 0.1.1 → 0.1.3

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
@@ -17,7 +17,7 @@
17
17
  - **入站**:文本、富文本、图片、文件;语音/视频/表情包等给一句明确提示,不静默丢弃
18
18
  - **出站**:Markdown 卡片、图片;长回答按字符与卡片体积双上限切段
19
19
  - **引用回复**:回答引用触发它的那条消息,单聊与群里都成立
20
- - **处理反馈**:收到消息先打 `Typing` 表情,处理完换成 `DONE`;失败只撤 `Typing`,不留「已完成」的假信号。飞书没有官方「正在输入」接口
20
+ - **处理反馈**:收到消息先打 `Get`(收到)表情,处理完**追加** `DONE`,两个标记并排保留;失败保留 `Get`、不追加 `DONE`,不留「已完成」的假信号。飞书没有官方「正在输入」接口
21
21
  - **卡片更新**:流式回答原地更新同一张卡片;超过平台限制(14 天、单卡 5 QPS)后改发新卡
22
22
  - **交互卡片**:核心模式的**单问题**单选题与多选题在飞书里勾选后提交,结果交回核心;
23
23
  独立模式的单题提问同样发卡片(单选/多选都是勾选器,靠文案区分,必须点提交),其余仍走
@@ -31,7 +31,7 @@
31
31
  > 单选/多选靠卡片文案区分,提交后回传勾选项与「其他」输入。两种模式的作答被拒都有可见
32
32
  > 反馈:还能答的卡会**整卡重画**并写上原因(飞书的表单提交是一次性的,只发一句提示
33
33
  > 会让卡片点不动),可以重新勾选提交;已经不能再答的卡直接改成失效态、去掉勾选框。
34
- > `Typing` 表情与卡片排版随租户配置略有差异,以实际表现为准。
34
+ > `Get` / `DONE` 表情与卡片排版随租户配置略有差异,以实际表现为准。
35
35
 
36
36
  ## 安装
37
37
 
@@ -98,7 +98,7 @@ dsh plugin --profile web add file:/绝对路径/dsh-im-lark
98
98
  config:
99
99
  domain: feishu # feishu(默认)或 lark(国际版)
100
100
  maxText: 2000 # 单条消息字符上限,超出自动切段
101
- typingIndicator: true # 收到打 Typing,处理完换成 DONE
101
+ typingIndicator: true # 收到打 Get,处理完追加 DONE(Get 不撤)
102
102
  replyStatus: false # 回答末尾附加模型、耗时、token
103
103
  directBusyMode: steer # 独立会话里回合进行中又来消息:steer 插话 / queue 排队(旧值 interrupt 会迁移成 steer)
104
104
  directWorkspaceId: '' # 独立会话的工作区 id;留空用自动创建的默认工作区
@@ -109,7 +109,7 @@ dsh plugin --profile web add file:/绝对路径/dsh-im-lark
109
109
  failureReminders: true # 独立模式:回合失败或被外部中止时立刻提醒
110
110
  ```
111
111
 
112
- 面板能改的项会落到 `$DSH_HOME/.dsh-im-lark/config.json`,卸载重装后沿用。凭据单独存 `credentials.json`,目录 0700、文件 0600,日志与面板快照里只出现 App ID 尾号。
112
+ 面板能改的项会落到 `$DSH_HOME/.dsh-im-lark/config.json`,卸载重装后沿用。凭据单独存 `credentials.json`,目录 0700、文件 0600,日志与错误信息里只出现 App ID 尾号;面板显示完整 App ID 与绑定时间,Secret 不回显。
113
113
 
114
114
  ## 独立会话命令
115
115
 
package/lib/client.js CHANGED
@@ -74,7 +74,6 @@ var en_default = {
74
74
  "panel.refresh": "Refresh",
75
75
  "panel.retry": "Retry",
76
76
  "status.title": "Connection",
77
- "status.connection": "Long connection",
78
77
  "status.appId": "App ID",
79
78
  "status.domain": "Platform",
80
79
  "status.enabled": "Connect Lark",
@@ -91,7 +90,8 @@ var en_default = {
91
90
  "state.failed": "Failed",
92
91
  "credentials.title": "App credentials",
93
92
  "credentials.hint": "From the Lark developer console. Stored locally; the secret is never echoed.",
94
- "credentials.configured": "App ID ends with {appId} \xB7 {domain}",
93
+ "credentials.configured": "Bound to {appId} \xB7 {domain}",
94
+ "credentials.boundAt": "Bound since {boundAt}",
95
95
  "credentials.manual": "Enter credentials manually",
96
96
  "credentials.appId": "App ID",
97
97
  "credentials.appSecret": "App Secret",
@@ -105,7 +105,7 @@ var en_default = {
105
105
  "credentials.probing": "Testing\u2026",
106
106
  "credentials.clear": "Clear credentials",
107
107
  "credentials.clearTitle": "Clear credentials?",
108
- "credentials.clearHint": "This removes the credentials for the app whose ID ends with {appId} (App ID and App Secret).",
108
+ "credentials.clearHint": "This removes the credentials for {appId} (App ID and App Secret).",
109
109
  "credentials.clearWarning": "The long connection closes immediately; reconnecting requires entering them again.",
110
110
  "credentials.clearConfirm": "Clear",
111
111
  "credentials.cleared": "Credentials cleared",
@@ -131,7 +131,7 @@ var en_default = {
131
131
  "register.failed": "Failed to create the app. Please retry.",
132
132
  "behavior.title": "Message behavior",
133
133
  "behavior.typing": "Working / done reaction",
134
- "behavior.typingHint": "Marks the message Typing while handling, then DONE when finished. Lark has no official typing API.",
134
+ "behavior.typingHint": "Adds a Get (received) reaction on arrival, then appends DONE when finished; both stay on the message. Lark has no official typing API.",
135
135
  "behavior.replyStatus": "Status line in replies",
136
136
  "behavior.replyStatusHint": "Model, reasoning effort and duration.",
137
137
  "common.save": "Save",
@@ -186,7 +186,6 @@ var zh_default = {
186
186
  "panel.refresh": "\u5237\u65B0",
187
187
  "panel.retry": "\u91CD\u8BD5",
188
188
  "status.title": "\u8FDE\u63A5\u72B6\u6001",
189
- "status.connection": "\u957F\u8FDE\u63A5",
190
189
  "status.appId": "App ID",
191
190
  "status.domain": "\u5E73\u53F0",
192
191
  "status.enabled": "\u63A5\u5165\u98DE\u4E66",
@@ -203,7 +202,8 @@ var zh_default = {
203
202
  "state.failed": "\u8FDE\u63A5\u5931\u8D25",
204
203
  "credentials.title": "\u5E94\u7528\u51ED\u636E",
205
204
  "credentials.hint": "\u5728\u98DE\u4E66\u5F00\u653E\u5E73\u53F0\u300C\u51ED\u8BC1\u4E0E\u57FA\u7840\u4FE1\u606F\u300D\u91CC\u83B7\u53D6\u3002\u53EA\u4FDD\u5B58\u5728\u672C\u673A\uFF0C\u9762\u677F\u4E0D\u4F1A\u56DE\u663E Secret\u3002",
206
- "credentials.configured": "\u5DF2\u914D\u7F6E App ID \u5C3E\u53F7 {appId} \xB7 {domain}",
205
+ "credentials.configured": "\u5DF2\u7ED1\u5B9A {appId} \xB7 {domain}",
206
+ "credentials.boundAt": "\u7ED1\u5B9A\u4E8E {boundAt}",
207
207
  "credentials.manual": "\u624B\u52A8\u586B\u5199\u51ED\u636E",
208
208
  "credentials.appId": "App ID",
209
209
  "credentials.appSecret": "App Secret",
@@ -217,7 +217,7 @@ var zh_default = {
217
217
  "credentials.probing": "\u6B63\u5728\u81EA\u68C0\u2026",
218
218
  "credentials.clear": "\u6E05\u9664\u51ED\u636E",
219
219
  "credentials.clearTitle": "\u6E05\u9664\u51ED\u636E\uFF1F",
220
- "credentials.clearHint": "\u5C06\u6E05\u9664\u5C3E\u53F7 {appId} \u7684\u5E94\u7528\u51ED\u636E\uFF08App ID \u4E0E App Secret\uFF09\u3002",
220
+ "credentials.clearHint": "\u5C06\u6E05\u9664 {appId} \u7684\u5E94\u7528\u51ED\u636E\uFF08App ID \u4E0E App Secret\uFF09\u3002",
221
221
  "credentials.clearWarning": "\u6E05\u9664\u540E\u957F\u8FDE\u63A5\u7ACB\u5373\u65AD\u5F00\uFF0C\u91CD\u65B0\u63A5\u5165\u9700\u8981\u518D\u586B\u4E00\u6B21\u51ED\u636E\u3002",
222
222
  "credentials.clearConfirm": "\u6E05\u9664",
223
223
  "credentials.cleared": "\u51ED\u636E\u5DF2\u6E05\u9664",
@@ -243,7 +243,7 @@ var zh_default = {
243
243
  "register.failed": "\u521B\u5EFA\u5E94\u7528\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
244
244
  "behavior.title": "\u6D88\u606F\u884C\u4E3A",
245
245
  "behavior.typing": "\u5904\u7406\u72B6\u6001\u8868\u60C5",
246
- "behavior.typingHint": "\u6536\u5230\u6D88\u606F\u5148\u6253 Typing\uFF0C\u5904\u7406\u5B8C\u6362\u6210 DONE\u3002\u98DE\u4E66\u6CA1\u6709\u5B98\u65B9\u8F93\u5165\u72B6\u6001\u63A5\u53E3\u3002",
246
+ "behavior.typingHint": "\u6536\u5230\u6D88\u606F\u5148\u6253\u300C\u6536\u5230\u300D(Get)\uFF0C\u5904\u7406\u5B8C\u8FFD\u52A0 DONE\uFF0C\u4E24\u4E2A\u90FD\u4FDD\u7559\u3002\u98DE\u4E66\u6CA1\u6709\u5B98\u65B9\u8F93\u5165\u72B6\u6001\u63A5\u53E3\u3002",
247
247
  "behavior.replyStatus": "\u56DE\u590D\u672B\u5C3E\u663E\u793A\u72B6\u6001",
248
248
  "behavior.replyStatusHint": "\u9644\u52A0\u6A21\u578B\u3001\u63A8\u7406\u7B49\u7EA7\u4E0E\u8017\u65F6\u3002",
249
249
  "common.save": "\u4FDD\u5B58",
@@ -744,6 +744,7 @@ function LarkSettingsPanel(props) {
744
744
  const [error, setError] = useState("");
745
745
  const [notice, setNotice] = useState("");
746
746
  const [appId, setAppId] = useState("");
747
+ const appIdPrefilled = useRef(false);
747
748
  const [appSecret, setAppSecret] = useState("");
748
749
  const [domain, setDomain] = useState("feishu");
749
750
  const [registration, setRegistration] = useState(null);
@@ -758,6 +759,11 @@ function LarkSettingsPanel(props) {
758
759
  const applySnapshot = useCallback((next) => {
759
760
  setSnapshot(next);
760
761
  setDomain((current) => current === "" ? next.status.domain : current);
762
+ const bound = next.status.appId;
763
+ if (!appIdPrefilled.current && bound !== null && bound !== "") {
764
+ appIdPrefilled.current = true;
765
+ setAppId((current) => current === "" ? bound : current);
766
+ }
761
767
  }, []);
762
768
  const refresh = useCallback(async (quiet = false) => {
763
769
  try {
@@ -1014,8 +1020,10 @@ function LarkSettingsPanel(props) {
1014
1020
  h(
1015
1021
  "div",
1016
1022
  { className: "lark-rows" },
1017
- row(t("status.connection"), h(Pill, { tone: toneOf(state), dot: true }, t(stateKey(state)))),
1018
- row(t("status.appId"), h("span", { className: "lark-mono" }, status?.appIdTail === null ? t("status.notConfigured") : `\u2026${status?.appIdTail ?? ""}`)),
1023
+ row(
1024
+ t("status.appId"),
1025
+ status?.appId === null || status?.appId === void 0 ? t("status.notConfigured") : h("span", { className: "lark-mono" }, status.appId)
1026
+ ),
1019
1027
  row(t("status.domain"), domainLabel)
1020
1028
  ),
1021
1029
  toggleRow(h(Switch, { checked: settings?.enabled === true, onChange: (value) => toggle("enabled", value), label: t("status.enabled") }), t("status.enabled"), t("status.enabledHint")),
@@ -1040,7 +1048,8 @@ function LarkSettingsPanel(props) {
1040
1048
  "div",
1041
1049
  { className: "lark-card-heading" },
1042
1050
  h("div", { className: "lark-card-title" }, t("credentials.title")),
1043
- !credentialsOpen && credentialsConfigured ? h("div", { className: "lark-card-hint" }, t("credentials.configured", { appId: status?.appIdTail ?? "", domain: domainLabel })) : null
1051
+ !credentialsOpen && credentialsConfigured ? h("div", { className: "lark-card-hint" }, t("credentials.configured", { appId: status?.appId ?? "", domain: domainLabel })) : null,
1052
+ !credentialsOpen && credentialsConfigured ? h("div", { className: "lark-card-hint" }, t("credentials.boundAt", { boundAt: formatBoundAt(status?.boundAt) })) : null
1044
1053
  ),
1045
1054
  h(
1046
1055
  Button,
@@ -1067,7 +1076,7 @@ function LarkSettingsPanel(props) {
1067
1076
  h(ConfirmDialog, {
1068
1077
  open: clearOpen,
1069
1078
  title: t("credentials.clearTitle"),
1070
- lines: [t("credentials.clearHint", { appId: status?.appIdTail ?? "" }), t("credentials.clearWarning")],
1079
+ lines: [t("credentials.clearHint", { appId: status?.appId ?? "" }), t("credentials.clearWarning")],
1071
1080
  cancelLabel: t("common.cancel"),
1072
1081
  confirmLabel: t("credentials.clearConfirm"),
1073
1082
  closeLabel: t("common.close"),
@@ -1077,6 +1086,8 @@ function LarkSettingsPanel(props) {
1077
1086
  credentialsOpen ? h(
1078
1087
  "div",
1079
1088
  { id: "lark-credentials-body", className: "lark-card-body" },
1089
+ credentialsConfigured ? h("div", { className: "lark-card-hint" }, t("credentials.configured", { appId: status?.appId ?? "", domain: domainLabel })) : null,
1090
+ credentialsConfigured ? h("div", { className: "lark-card-hint" }, t("credentials.boundAt", { boundAt: formatBoundAt(status?.boundAt) })) : null,
1080
1091
  h("div", { className: "lark-card-hint" }, t("credentials.hint")),
1081
1092
  h(
1082
1093
  "div",
@@ -1322,6 +1333,12 @@ function workspaceOptions(catalog, current, t) {
1322
1333
  function row(label, value) {
1323
1334
  return h("div", { className: "lark-row" }, h("span", { className: "lark-row-label" }, label), h("span", { className: "lark-row-value" }, value));
1324
1335
  }
1336
+ function formatBoundAt(boundAt) {
1337
+ if (boundAt === void 0 || boundAt === null) return "\u2014";
1338
+ const at = new Date(boundAt);
1339
+ const pad = (value) => String(value).padStart(2, "0");
1340
+ return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())} ${pad(at.getHours())}:${pad(at.getMinutes())}:${pad(at.getSeconds())}`;
1341
+ }
1325
1342
  function fieldRow(label, control) {
1326
1343
  return h(
1327
1344
  "div",
@@ -15,12 +15,13 @@ const TEXT_MAX = 20_000;
15
15
  /**
16
16
  * 消息上的处理状态标记,走官方「添加消息表情回复」接口的 `emoji_type`。
17
17
  *
18
- * - `Typing`:收到就开始处理;
19
- * - `DONE`:处理完成,覆盖 `Typing`,让主人一眼看出这条已经答完了。
18
+ * - `Get`:收到消息就打上(官方表情表里「已收到/已受理」语义的那个);
19
+ * - `DONE`:处理完成后**追加**,`Get` 不撤,两个标记并排留在消息上。
20
20
  *
21
- * 只有成功处理完才盖 `DONE`:失败时不该给出「已完成」的假信号。
21
+ * 第一个标记永不撤销——它只表示「收到过」,失败时也成立;只有成功处理完
22
+ * 才追加 `DONE`,失败不给「已完成」的假信号。
22
23
  */
23
- const REACTION_TYPING = 'Typing';
24
+ const REACTION_ACK = 'Get';
24
25
  const REACTION_DONE = 'DONE';
25
26
  const KNOWN_IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif']);
26
27
  /** 卡片回调的重推窗口:没有 `event_id` 时用它兜住平台重推,窗口之外允许同一张卡再提交。 */
@@ -135,8 +136,9 @@ export class InboundPipeline {
135
136
  });
136
137
  }
137
138
  async #processMessage(message, body) {
138
- const typingId = this.#typing ? await this.#addReaction(message.messageId, REACTION_TYPING) : undefined;
139
- // 只有走到最后才算处理完:中途抛错时不盖 DONE。
139
+ if (this.#typing)
140
+ await this.#addReaction(message.messageId, REACTION_ACK);
141
+ // 只有走到最后才算处理完:中途抛错时不追加 DONE。
140
142
  let settled = false;
141
143
  try {
142
144
  const draft = await this.#toDraft(message, body);
@@ -160,8 +162,7 @@ export class InboundPipeline {
160
162
  settled = true;
161
163
  }
162
164
  finally {
163
- if (typingId !== undefined)
164
- await this.#removeReaction(message.messageId, typingId);
165
+ // 「收到」标记不撤:它只表示消息已受理,成功与失败都留着。
165
166
  if (settled && this.#typing)
166
167
  await this.#addReaction(message.messageId, REACTION_DONE);
167
168
  }
@@ -177,14 +178,6 @@ export class InboundPipeline {
177
178
  return undefined;
178
179
  }
179
180
  }
180
- async #removeReaction(messageId, reactionId) {
181
- try {
182
- await this.#api.removeReaction({ messageId, reactionId });
183
- }
184
- catch {
185
- // 移除失败不影响交付;消息上的表情会随消息留存。
186
- }
187
- }
188
181
  /** 事件 → 协议草稿;媒体下载失败时降级成文字说明,不让整条消息丢掉。 */
189
182
  async #toDraft(message, body) {
190
183
  const notes = [];
@@ -9,7 +9,7 @@
9
9
  * 出来就回 `invalid-config`。浏览器发来的 JSON 是不可信输入,不把它直接塞进
10
10
  * 运行期,也不把内部错误原文透给页面(可能带本机路径)。
11
11
  *
12
- * 凭据只在保存时经过这里;读取只回 App ID 尾号(`RuntimeStatus.appIdTail`)。
12
+ * 凭据只在保存时经过这里;读取回完整 App ID 与绑定时间(Secret 不出边界)。
13
13
  */
14
14
  import { PANEL_CONTRACT, PLUGIN_VERSION, RPC_CHANNEL, RPC_ENDPOINT, RPC_PREFIX } from "../shared/version.js";
15
15
  import { normalizeQuestionDelayMinutes } from "./config.js";
@@ -74,7 +74,9 @@ export function snapshotOf(deps) {
74
74
  maxText: deps.config.maxText,
75
75
  rpcChannel: RPC_CHANNEL,
76
76
  },
77
+ appId: status.appId,
77
78
  appIdTail: status.appIdTail,
79
+ boundAt: status.boundAt,
78
80
  };
79
81
  }
80
82
  export async function handleEndpoint(deps, endpoint, payload) {
@@ -83,7 +83,9 @@ export class LarkRuntime {
83
83
  status() {
84
84
  const connection = this.#connection?.status() ?? { state: 'idle', since: Date.now(), reconnectAttempts: 0 };
85
85
  return {
86
+ appId: this.#credentials === null ? null : this.#credentials.appId,
86
87
  appIdTail: this.#credentials === null ? null : tailOf(this.#credentials.appId),
88
+ boundAt: this.#credentials?.boundAt ?? null,
87
89
  domain: this.#credentials?.domain ?? this.#deps.config.domain,
88
90
  enabled: this.#settings?.enabled ?? this.#deps.config.enabled,
89
91
  superagent: this.#settings?.superagent ?? this.#deps.config.superagent,
@@ -198,7 +200,7 @@ export class LarkRuntime {
198
200
  }
199
201
  }
200
202
  }
201
- /** App ID 尾号:面板只显示它。 */
203
+ /** App ID 尾号:日志与错误信息用(面板显示完整 App ID)。 */
202
204
  function tailOf(appId) {
203
205
  return appId.length > 6 ? appId.slice(-6) : appId;
204
206
  }
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * 凭据存储与自检。
3
3
  *
4
- * 凭据只落本机状态文件(`0700` 目录、`0600` 文件、原子写),**不进日志、不进面板
5
- * 快照、不随包发布**。面板能看到的只有 App ID 与尾号。
4
+ * 凭据只落本机状态文件(`0700` 目录、`0600` 文件、原子写),**不进日志、不随包
5
+ * 发布**。面板可以显示完整 App ID 与绑定时间(App ID 不是密钥),App Secret 永远
6
+ * 不出这个边界。
6
7
  *
7
8
  * 自检走两条独立的最小请求:先换 `tenant_access_token`(验 app_id/app_secret),
8
9
  * 再查机器人信息(验机器人能力是否开启)。两件事分开报错,面板才能给出
9
10
  * 「密钥不对」和「机器人能力没开」两种不同的提示。
10
11
  */
12
+ import { stat } from 'node:fs/promises';
11
13
  import { join } from 'node:path';
12
14
  import { baseUrlOf } from "../lark/api.js";
13
15
  import { readJsonIfPresent, writePrivateFile } from "./files.js";
@@ -16,9 +18,9 @@ const CREDENTIALS_FILE = 'credentials.json';
16
18
  /** App ID 尾号长度:面板只显示这么多,够区分不同应用就够了。 */
17
19
  const TAIL_LENGTH = 6;
18
20
  /** 面板能看到的凭据摘要。 */
19
- export function summarize(appId, domain) {
21
+ export function summarize(appId, domain, boundAt) {
20
22
  const tail = appId.length > TAIL_LENGTH ? appId.slice(-TAIL_LENGTH) : appId;
21
- return { appIdTail: tail, domain };
23
+ return { appId, appIdTail: tail, domain, ...(boundAt === undefined ? {} : { boundAt }) };
22
24
  }
23
25
  /** 收窄磁盘上的凭据:形状不对就当没配置。 */
24
26
  function normalizeStored(raw) {
@@ -30,15 +32,20 @@ function normalizeStored(raw) {
30
32
  const domain = input.domain === 'lark' ? 'lark' : 'feishu';
31
33
  if (appId === '' || appSecret === '')
32
34
  return undefined;
33
- return { appId, appSecret, domain };
35
+ const boundAt = typeof input.boundAt === 'number' && Number.isFinite(input.boundAt) && input.boundAt > 0
36
+ ? input.boundAt
37
+ : undefined;
38
+ return { appId, appSecret, domain, ...(boundAt === undefined ? {} : { boundAt }) };
34
39
  }
35
40
  export class CredentialStore {
36
41
  #path;
37
42
  #logger;
43
+ #now;
38
44
  #cached;
39
45
  constructor(options) {
40
46
  this.#path = join(options.dataDir, CREDENTIALS_FILE);
41
47
  this.#logger = options.logger ?? {};
48
+ this.#now = options.now ?? Date.now;
42
49
  }
43
50
  /** 读凭据;没有或损坏返回 null。 */
44
51
  async load() {
@@ -49,9 +56,25 @@ export class CredentialStore {
49
56
  if (raw !== undefined && parsed === undefined) {
50
57
  this.#logger.warn?.('凭据文件存在但内容不完整,按未配置处理');
51
58
  }
52
- this.#cached = parsed ?? null;
59
+ this.#cached = parsed === undefined ? null : await this.#withFileTime(parsed);
53
60
  return this.#cached;
54
61
  }
62
+ /**
63
+ * 老凭据没有绑定时间:用文件修改时间兜底(≈ 上次保存凭据的时间)。
64
+ *
65
+ * 只补在内存里,不写盘——写盘会把「猜出来的时间」固化成事实。
66
+ */
67
+ async #withFileTime(app) {
68
+ if (app.boundAt !== undefined)
69
+ return app;
70
+ try {
71
+ const info = await stat(this.#path);
72
+ return { ...app, boundAt: Math.round(info.mtimeMs) };
73
+ }
74
+ catch {
75
+ return app;
76
+ }
77
+ }
55
78
  /** 覆盖保存;返回可以展示的摘要。 */
56
79
  async save(input) {
57
80
  const appId = input.appId.trim();
@@ -60,10 +83,13 @@ export class CredentialStore {
60
83
  throw new Error('App ID 不能为空');
61
84
  if (appSecret === '')
62
85
  throw new Error('App Secret 不能为空');
63
- const payload = { appId, appSecret, domain: input.domain };
86
+ // 绑定时间跟着 App ID 走:同一个应用重复保存(哪怕换了 Secret)保留首次时间。
87
+ const previous = await this.load();
88
+ const boundAt = previous !== null && previous.appId === appId && previous.boundAt !== undefined ? previous.boundAt : this.#now();
89
+ const payload = { appId, appSecret, domain: input.domain, boundAt };
64
90
  await writePrivateFile(this.#path, `${JSON.stringify(payload, null, 2)}\n`);
65
91
  this.#cached = payload;
66
- return summarize(appId, input.domain);
92
+ return summarize(appId, input.domain, boundAt);
67
93
  }
68
94
  /** 清空凭据(卸载应用或换应用时用)。 */
69
95
  async clear() {
@@ -73,7 +99,7 @@ export class CredentialStore {
73
99
  /** 已配置时的摘要;未配置返回 null。 */
74
100
  async summary() {
75
101
  const app = await this.load();
76
- return app ? summarize(app.appId, app.domain) : null;
102
+ return app ? summarize(app.appId, app.domain, app.boundAt) : null;
77
103
  }
78
104
  }
79
105
  /**
@@ -5,7 +5,7 @@
5
5
  * 发布时三处同步——package.json、锁文件(`npm version --no-git-tag-version`)、
6
6
  * 这里。
7
7
  */
8
- export const PLUGIN_VERSION = '0.1.1';
8
+ export const PLUGIN_VERSION = '0.1.3';
9
9
  /** 传输层实现版本:协议客户端行为变化时递增,与插件版本解耦。 */
10
10
  export const CHANNEL_VERSION = '1';
11
11
  /**
package/locale/en.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "panel.refresh": "Refresh",
6
6
  "panel.retry": "Retry",
7
7
  "status.title": "Connection",
8
- "status.connection": "Long connection",
9
8
  "status.appId": "App ID",
10
9
  "status.domain": "Platform",
11
10
  "status.enabled": "Connect Lark",
@@ -22,7 +21,8 @@
22
21
  "state.failed": "Failed",
23
22
  "credentials.title": "App credentials",
24
23
  "credentials.hint": "From the Lark developer console. Stored locally; the secret is never echoed.",
25
- "credentials.configured": "App ID ends with {appId} · {domain}",
24
+ "credentials.configured": "Bound to {appId} · {domain}",
25
+ "credentials.boundAt": "Bound since {boundAt}",
26
26
  "credentials.manual": "Enter credentials manually",
27
27
  "credentials.appId": "App ID",
28
28
  "credentials.appSecret": "App Secret",
@@ -36,7 +36,7 @@
36
36
  "credentials.probing": "Testing…",
37
37
  "credentials.clear": "Clear credentials",
38
38
  "credentials.clearTitle": "Clear credentials?",
39
- "credentials.clearHint": "This removes the credentials for the app whose ID ends with {appId} (App ID and App Secret).",
39
+ "credentials.clearHint": "This removes the credentials for {appId} (App ID and App Secret).",
40
40
  "credentials.clearWarning": "The long connection closes immediately; reconnecting requires entering them again.",
41
41
  "credentials.clearConfirm": "Clear",
42
42
  "credentials.cleared": "Credentials cleared",
@@ -62,7 +62,7 @@
62
62
  "register.failed": "Failed to create the app. Please retry.",
63
63
  "behavior.title": "Message behavior",
64
64
  "behavior.typing": "Working / done reaction",
65
- "behavior.typingHint": "Marks the message Typing while handling, then DONE when finished. Lark has no official typing API.",
65
+ "behavior.typingHint": "Adds a Get (received) reaction on arrival, then appends DONE when finished; both stay on the message. Lark has no official typing API.",
66
66
  "behavior.replyStatus": "Status line in replies",
67
67
  "behavior.replyStatusHint": "Model, reasoning effort and duration.",
68
68
  "common.save": "Save",
package/locale/zh.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "panel.refresh": "刷新",
6
6
  "panel.retry": "重试",
7
7
  "status.title": "连接状态",
8
- "status.connection": "长连接",
9
8
  "status.appId": "App ID",
10
9
  "status.domain": "平台",
11
10
  "status.enabled": "接入飞书",
@@ -22,7 +21,8 @@
22
21
  "state.failed": "连接失败",
23
22
  "credentials.title": "应用凭据",
24
23
  "credentials.hint": "在飞书开放平台「凭证与基础信息」里获取。只保存在本机,面板不会回显 Secret。",
25
- "credentials.configured": "已配置 App ID 尾号 {appId} · {domain}",
24
+ "credentials.configured": "已绑定 {appId} · {domain}",
25
+ "credentials.boundAt": "绑定于 {boundAt}",
26
26
  "credentials.manual": "手动填写凭据",
27
27
  "credentials.appId": "App ID",
28
28
  "credentials.appSecret": "App Secret",
@@ -36,7 +36,7 @@
36
36
  "credentials.probing": "正在自检…",
37
37
  "credentials.clear": "清除凭据",
38
38
  "credentials.clearTitle": "清除凭据?",
39
- "credentials.clearHint": "将清除尾号 {appId} 的应用凭据(App ID 与 App Secret)。",
39
+ "credentials.clearHint": "将清除 {appId} 的应用凭据(App ID 与 App Secret)。",
40
40
  "credentials.clearWarning": "清除后长连接立即断开,重新接入需要再填一次凭据。",
41
41
  "credentials.clearConfirm": "清除",
42
42
  "credentials.cleared": "凭据已清除",
@@ -62,7 +62,7 @@
62
62
  "register.failed": "创建应用失败,请重试",
63
63
  "behavior.title": "消息行为",
64
64
  "behavior.typing": "处理状态表情",
65
- "behavior.typingHint": "收到消息先打 Typing,处理完换成 DONE。飞书没有官方输入状态接口。",
65
+ "behavior.typingHint": "收到消息先打「收到」(Get),处理完追加 DONE,两个都保留。飞书没有官方输入状态接口。",
66
66
  "behavior.replyStatus": "回复末尾显示状态",
67
67
  "behavior.replyStatusHint": "附加模型、推理等级与耗时。",
68
68
  "common.save": "保存",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-im-lark",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "把飞书(Lark)接入 DeepSeek Harness 的 IM 桥插件",
6
6
  "license": "MIT",