@lih-x-x/kmr 1.0.20 → 1.0.22
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 +63 -6
- package/dist/public/app.js +4 -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 || [],
|
|
@@ -1066,6 +1066,25 @@ var TaskCreator = class {
|
|
|
1066
1066
|
console.log(`[task] \u4EFB\u52A1\u521B\u5EFA\u6210\u529F: taskId=${taskId}`);
|
|
1067
1067
|
return { taskId, url };
|
|
1068
1068
|
}
|
|
1069
|
+
/**
|
|
1070
|
+
* 查询飞书任务的最新状态
|
|
1071
|
+
*/
|
|
1072
|
+
async getTaskStatus(taskId) {
|
|
1073
|
+
try {
|
|
1074
|
+
const response = await this.client.task.v2.task.get({
|
|
1075
|
+
path: { task_guid: taskId }
|
|
1076
|
+
});
|
|
1077
|
+
const task = response.data?.task;
|
|
1078
|
+
if (!task) return null;
|
|
1079
|
+
const completedAt = task.completed_at || "";
|
|
1080
|
+
const status = completedAt ? "completed" : "open";
|
|
1081
|
+
const completedAtISO = completedAt ? new Date(parseInt(completedAt, 10)).toISOString() : void 0;
|
|
1082
|
+
return { status, completedAt: completedAtISO };
|
|
1083
|
+
} catch (err) {
|
|
1084
|
+
console.error(`[task-sync] \u67E5\u8BE2\u4EFB\u52A1\u72B6\u6001\u5931\u8D25: taskId=${taskId}`, err.message);
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1069
1088
|
};
|
|
1070
1089
|
|
|
1071
1090
|
// src/lark/userResolver.ts
|
|
@@ -1240,7 +1259,7 @@ async function main() {
|
|
|
1240
1259
|
break;
|
|
1241
1260
|
}
|
|
1242
1261
|
clearTimeout(pending.timer);
|
|
1243
|
-
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));
|
|
1244
1263
|
if (selectedTodos.length === 0) {
|
|
1245
1264
|
await messenger.replyText(messageId, "\u672A\u9009\u4E2D\u6709\u6548\u7684\u5F85\u529E\u7F16\u53F7\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u8BD5\u3002");
|
|
1246
1265
|
break;
|
|
@@ -1248,7 +1267,7 @@ async function main() {
|
|
|
1248
1267
|
console.log(`[process] \u521B\u5EFA\u98DE\u4E66\u4EFB\u52A1: ${selectedTodos.length} \u6761`);
|
|
1249
1268
|
await messenger.replyText(messageId, `\u6B63\u5728\u521B\u5EFA ${selectedTodos.length} \u6761\u98DE\u4E66\u4EFB\u52A1...`);
|
|
1250
1269
|
const results = [];
|
|
1251
|
-
for (const todo of selectedTodos) {
|
|
1270
|
+
for (const { todo, index } of selectedTodos) {
|
|
1252
1271
|
try {
|
|
1253
1272
|
const ownerOpenId = userResolver.resolve(todo.owner) || senderId;
|
|
1254
1273
|
if (ownerOpenId !== senderId) {
|
|
@@ -1261,10 +1280,10 @@ async function main() {
|
|
|
1261
1280
|
\u8D1F\u8D23\u4EBA: ${todo.owner}`,
|
|
1262
1281
|
assigneeOpenId: ownerOpenId
|
|
1263
1282
|
});
|
|
1264
|
-
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 });
|
|
1265
1284
|
console.log(`\u2705 \u4EFB\u52A1\u521B\u5EFA\u6210\u529F: ${todo.content}`);
|
|
1266
1285
|
} catch (err) {
|
|
1267
|
-
results.push({ summary: todo.content, success: false, error: err.message });
|
|
1286
|
+
results.push({ summary: todo.content, success: false, error: err.message, todoIndex: index });
|
|
1268
1287
|
console.error(`\u274C \u4EFB\u52A1\u521B\u5EFA\u5931\u8D25: ${todo.content}`, err.message);
|
|
1269
1288
|
}
|
|
1270
1289
|
}
|
|
@@ -1273,12 +1292,18 @@ async function main() {
|
|
|
1273
1292
|
summary: r.summary,
|
|
1274
1293
|
taskId: r.taskId || "",
|
|
1275
1294
|
url: r.url || "",
|
|
1276
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1295
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1296
|
+
todoIndex: r.todoIndex
|
|
1277
1297
|
}));
|
|
1278
1298
|
if (createdTasks.length > 0) {
|
|
1279
1299
|
const record = await store.load(pending.meetingId);
|
|
1280
1300
|
if (record) {
|
|
1281
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
|
+
}
|
|
1282
1307
|
await store.save(record);
|
|
1283
1308
|
console.log(`[task] \u5DF2\u5C06 ${createdTasks.length} \u6761\u4EFB\u52A1\u5173\u8054\u5230\u4F1A\u8BAE ${pending.meetingId}`);
|
|
1284
1309
|
}
|
|
@@ -1328,5 +1353,37 @@ async function main() {
|
|
|
1328
1353
|
console.error("[notify] \u5411\u7BA1\u7406\u5458\u63A8\u9001\u542F\u52A8\u901A\u77E5\u5931\u8D25:", err.message);
|
|
1329
1354
|
});
|
|
1330
1355
|
}
|
|
1356
|
+
async function syncTaskStatuses() {
|
|
1357
|
+
console.log("[task-sync] \u5F00\u59CB\u540C\u6B65\u98DE\u4E66\u4EFB\u52A1\u72B6\u6001...");
|
|
1358
|
+
try {
|
|
1359
|
+
const meetings = await store.list();
|
|
1360
|
+
let updatedCount = 0;
|
|
1361
|
+
for (const meeting of meetings) {
|
|
1362
|
+
if (!meeting.createdTasks || meeting.createdTasks.length === 0) continue;
|
|
1363
|
+
let changed = false;
|
|
1364
|
+
for (const task of meeting.createdTasks) {
|
|
1365
|
+
if (!task.taskId || task.status === "completed") continue;
|
|
1366
|
+
const result = await taskCreator.getTaskStatus(task.taskId);
|
|
1367
|
+
if (result && result.status !== (task.status || "open")) {
|
|
1368
|
+
task.status = result.status;
|
|
1369
|
+
task.completedAt = result.completedAt;
|
|
1370
|
+
changed = true;
|
|
1371
|
+
if (task.todoIndex != null && meeting.todos[task.todoIndex]) {
|
|
1372
|
+
meeting.todos[task.todoIndex].status = result.status;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
if (changed) {
|
|
1377
|
+
await store.save(meeting);
|
|
1378
|
+
updatedCount++;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
console.log(`[task-sync] \u540C\u6B65\u5B8C\u6210, \u66F4\u65B0\u4E86 ${updatedCount} \u6761\u4F1A\u8BAE\u8BB0\u5F55`);
|
|
1382
|
+
} catch (err) {
|
|
1383
|
+
console.error("[task-sync] \u540C\u6B65\u5931\u8D25:", err.message);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
syncTaskStatuses();
|
|
1387
|
+
setInterval(syncTaskStatuses, 60 * 60 * 1e3);
|
|
1331
1388
|
}
|
|
1332
1389
|
main().catch(console.error);
|
package/dist/public/app.js
CHANGED
|
@@ -129,9 +129,11 @@ async function renderMeetings() {
|
|
|
129
129
|
if (m.createdTasks && m.createdTasks.length > 0) {
|
|
130
130
|
detail += '<div class="detail-section"><h4>📋 已创建任务</h4><ul>' +
|
|
131
131
|
m.createdTasks.map(function (t) {
|
|
132
|
-
|
|
132
|
+
var statusIcon = t.status === 'completed' ? '✅' : '⏳';
|
|
133
|
+
return '<li>' + statusIcon + ' ' + escapeHtml(t.summary) +
|
|
133
134
|
(t.url ? ' <a class="detail-link" href="' + escapeAttr(t.url) + '" target="_blank">查看 →</a>' : '') +
|
|
134
|
-
'<br><span class="insight-source">创建于 ' + escapeHtml(t.createdAt) +
|
|
135
|
+
'<br><span class="insight-source">创建于 ' + escapeHtml(t.createdAt) +
|
|
136
|
+
(t.completedAt ? ' | 完成于 ' + escapeHtml(t.completedAt) : '') + '</span></li>';
|
|
135
137
|
}).join('') + '</ul></div>';
|
|
136
138
|
}
|
|
137
139
|
|