@lih-x-x/kmr 1.0.21 → 1.0.23

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -497,7 +497,7 @@ ${prompt}
497
497
  documentUrl: "",
498
498
  extractedAt: (/* @__PURE__ */ new Date()).toISOString(),
499
499
  summary: parsed.summary,
500
- todos: parsed.todos || [],
500
+ todos: (parsed.todos || []).map((t) => ({ ...t, status: "invalid_cause_no_task" })),
501
501
  risks: parsed.risks || [],
502
502
  projectRelations: parsed.projectRelations || [],
503
503
  commitments: parsed.commitments || [],
@@ -1078,7 +1078,8 @@ var TaskCreator = class {
1078
1078
  if (!task) return null;
1079
1079
  const completedAt = task.completed_at || "";
1080
1080
  const status = completedAt ? "completed" : "open";
1081
- return { status, completedAt: completedAt || void 0 };
1081
+ const completedAtISO = completedAt ? new Date(parseInt(completedAt, 10)).toISOString() : void 0;
1082
+ return { status, completedAt: completedAtISO };
1082
1083
  } catch (err) {
1083
1084
  console.error(`[task-sync] \u67E5\u8BE2\u4EFB\u52A1\u72B6\u6001\u5931\u8D25: taskId=${taskId}`, err.message);
1084
1085
  return null;
@@ -1258,7 +1259,7 @@ async function main() {
1258
1259
  break;
1259
1260
  }
1260
1261
  clearTimeout(pending.timer);
1261
- const selectedTodos = parsed.confirmIds === "all" ? pending.todos : pending.todos.filter((_, i) => parsed.confirmIds.includes(i + 1));
1262
+ const selectedTodos = parsed.confirmIds === "all" ? pending.todos.map((t, i) => ({ todo: t, index: i })) : pending.todos.map((t, i) => ({ todo: t, index: i })).filter((_, i) => parsed.confirmIds.includes(i + 1));
1262
1263
  if (selectedTodos.length === 0) {
1263
1264
  await messenger.replyText(messageId, "\u672A\u9009\u4E2D\u6709\u6548\u7684\u5F85\u529E\u7F16\u53F7\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u8BD5\u3002");
1264
1265
  break;
@@ -1266,7 +1267,7 @@ async function main() {
1266
1267
  console.log(`[process] \u521B\u5EFA\u98DE\u4E66\u4EFB\u52A1: ${selectedTodos.length} \u6761`);
1267
1268
  await messenger.replyText(messageId, `\u6B63\u5728\u521B\u5EFA ${selectedTodos.length} \u6761\u98DE\u4E66\u4EFB\u52A1...`);
1268
1269
  const results = [];
1269
- for (const todo of selectedTodos) {
1270
+ for (const { todo, index } of selectedTodos) {
1270
1271
  try {
1271
1272
  const ownerOpenId = userResolver.resolve(todo.owner) || senderId;
1272
1273
  if (ownerOpenId !== senderId) {
@@ -1279,10 +1280,10 @@ async function main() {
1279
1280
  \u8D1F\u8D23\u4EBA: ${todo.owner}`,
1280
1281
  assigneeOpenId: ownerOpenId
1281
1282
  });
1282
- results.push({ summary: todo.content, success: true, taskId: result.taskId, url: result.url });
1283
+ results.push({ summary: todo.content, success: true, taskId: result.taskId, url: result.url, todoIndex: index });
1283
1284
  console.log(`\u2705 \u4EFB\u52A1\u521B\u5EFA\u6210\u529F: ${todo.content}`);
1284
1285
  } catch (err) {
1285
- results.push({ summary: todo.content, success: false, error: err.message });
1286
+ results.push({ summary: todo.content, success: false, error: err.message, todoIndex: index });
1286
1287
  console.error(`\u274C \u4EFB\u52A1\u521B\u5EFA\u5931\u8D25: ${todo.content}`, err.message);
1287
1288
  }
1288
1289
  }
@@ -1291,12 +1292,18 @@ async function main() {
1291
1292
  summary: r.summary,
1292
1293
  taskId: r.taskId || "",
1293
1294
  url: r.url || "",
1294
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
1295
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1296
+ todoIndex: r.todoIndex
1295
1297
  }));
1296
1298
  if (createdTasks.length > 0) {
1297
1299
  const record = await store.load(pending.meetingId);
1298
1300
  if (record) {
1299
1301
  record.createdTasks = [...record.createdTasks || [], ...createdTasks];
1302
+ for (const ct of createdTasks) {
1303
+ if (ct.todoIndex != null && record.todos[ct.todoIndex]) {
1304
+ record.todos[ct.todoIndex].status = "pending";
1305
+ }
1306
+ }
1300
1307
  await store.save(record);
1301
1308
  console.log(`[task] \u5DF2\u5C06 ${createdTasks.length} \u6761\u4EFB\u52A1\u5173\u8054\u5230\u4F1A\u8BAE ${pending.meetingId}`);
1302
1309
  }
@@ -1361,6 +1368,9 @@ async function main() {
1361
1368
  task.status = result.status;
1362
1369
  task.completedAt = result.completedAt;
1363
1370
  changed = true;
1371
+ if (task.todoIndex != null && meeting.todos[task.todoIndex]) {
1372
+ meeting.todos[task.todoIndex].status = result.status;
1373
+ }
1364
1374
  }
1365
1375
  }
1366
1376
  if (changed) {
@@ -1375,5 +1385,22 @@ async function main() {
1375
1385
  }
1376
1386
  syncTaskStatuses();
1377
1387
  setInterval(syncTaskStatuses, 60 * 60 * 1e3);
1388
+ if (config.lark.adminOpenId) {
1389
+ const adminId = config.lark.adminOpenId;
1390
+ let exiting = false;
1391
+ const onExit = async (signal) => {
1392
+ if (exiting) return;
1393
+ exiting = true;
1394
+ console.log(`[exit] \u6536\u5230 ${signal}\uFF0C\u6B63\u5728\u9000\u51FA...`);
1395
+ try {
1396
+ await messenger.sendToUser(adminId, `\u26D4 KMR \u670D\u52A1\u5DF2\u505C\u6B62\uFF08${signal}\uFF09`);
1397
+ } catch (err) {
1398
+ console.error("[notify] \u63A8\u9001\u505C\u6B62\u901A\u77E5\u5931\u8D25:", err.message);
1399
+ }
1400
+ process.exit(0);
1401
+ };
1402
+ process.on("SIGINT", () => onExit("SIGINT"));
1403
+ process.on("SIGTERM", () => onExit("SIGTERM"));
1404
+ }
1378
1405
  }
1379
1406
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lih-x-x/kmr",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {