@ai-setting/roy-agent-core 1.7.93 → 1.7.95
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/env/event-source/event-source-handlers.js +4 -4
- package/dist/env/event-source/index.js +5 -5
- package/dist/env/index.js +7 -7
- package/dist/env/task/index.js +1 -1
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +58 -3
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +130 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.js +5 -1
- package/dist/env/task/plugins/lark-card-state-store.d.ts +8 -0
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +75 -0
- package/dist/env/task/task-component.d.ts +25 -0
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/index.js +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-px73ewzd.js → roy-agent-core-57q8a049.js} +223 -10
- package/dist/shared/@ai-setting/{roy-agent-core-33n84tf9.js → roy-agent-core-6bga36qk.js} +63 -3
- package/dist/shared/@ai-setting/{roy-agent-core-mp7sqfb5.js → roy-agent-core-83n2nvdp.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-0yzxapfa.js → roy-agent-core-ddp3n8cb.js} +150 -5
- package/dist/shared/@ai-setting/{roy-agent-core-v3wm8gyj.js → roy-agent-core-h3j1z13p.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-vz886vr8.js → roy-agent-core-pc2z7kwy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-aeh7qg1r.js → roy-agent-core-vw4gv5am.js} +21 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -62,10 +62,10 @@ import {
|
|
|
62
62
|
BaseEnvironment,
|
|
63
63
|
generateDescendingId,
|
|
64
64
|
generateId
|
|
65
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
65
|
+
} from "./shared/@ai-setting/roy-agent-core-pc2z7kwy.js";
|
|
66
66
|
import {
|
|
67
67
|
TaskComponent
|
|
68
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
68
|
+
} from "./shared/@ai-setting/roy-agent-core-vw4gv5am.js";
|
|
69
69
|
import"./shared/@ai-setting/roy-agent-core-jzmk4kdh.js";
|
|
70
70
|
import"./shared/@ai-setting/roy-agent-core-jm136jzh.js";
|
|
71
71
|
import"./shared/@ai-setting/roy-agent-core-m4x47ne9.js";
|
|
@@ -80,7 +80,7 @@ import"./shared/@ai-setting/roy-agent-core-bcv09vrt.js";
|
|
|
80
80
|
import"./shared/@ai-setting/roy-agent-core-p5cz9m8v.js";
|
|
81
81
|
import {
|
|
82
82
|
EventSourceComponent
|
|
83
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
83
|
+
} from "./shared/@ai-setting/roy-agent-core-83n2nvdp.js";
|
|
84
84
|
import {
|
|
85
85
|
BountyIMInstance,
|
|
86
86
|
COMMAND_PREFIX,
|
|
@@ -135,7 +135,7 @@ import {
|
|
|
135
135
|
translateCardActionToCommand,
|
|
136
136
|
wecomCliHandler,
|
|
137
137
|
writeFallbackModelList
|
|
138
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
138
|
+
} from "./shared/@ai-setting/roy-agent-core-6bga36qk.js";
|
|
139
139
|
import {
|
|
140
140
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
141
141
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -161,7 +161,7 @@ import"./shared/@ai-setting/roy-agent-core-2stt4rp5.js";
|
|
|
161
161
|
import {
|
|
162
162
|
TaskTagPlugin,
|
|
163
163
|
createAutoTaskPlugin
|
|
164
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
164
|
+
} from "./shared/@ai-setting/roy-agent-core-57q8a049.js";
|
|
165
165
|
import"./shared/@ai-setting/roy-agent-core-th8fq714.js";
|
|
166
166
|
import"./shared/@ai-setting/roy-agent-core-c4ec7k0p.js";
|
|
167
167
|
import {
|
|
@@ -191,8 +191,8 @@ import {
|
|
|
191
191
|
TASK_COMPLETED_STATUS_WORD,
|
|
192
192
|
TASK_DELIVERABLE_RECORDED
|
|
193
193
|
} from "./shared/@ai-setting/roy-agent-core-4rtg69cn.js";
|
|
194
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
195
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
194
|
+
import"./shared/@ai-setting/roy-agent-core-h3j1z13p.js";
|
|
195
|
+
import"./shared/@ai-setting/roy-agent-core-ddp3n8cb.js";
|
|
196
196
|
import"./shared/@ai-setting/roy-agent-core-418zc9ha.js";
|
|
197
197
|
import {
|
|
198
198
|
SQLiteTaskStore,
|
|
@@ -32,8 +32,9 @@ import {
|
|
|
32
32
|
buildTaskCard,
|
|
33
33
|
createLarkCardStateStore,
|
|
34
34
|
getSharedLarkCardNotifier,
|
|
35
|
+
getSharedLarkCardStateStore,
|
|
35
36
|
humanizeValue
|
|
36
|
-
} from "./roy-agent-core-
|
|
37
|
+
} from "./roy-agent-core-ddp3n8cb.js";
|
|
37
38
|
import {
|
|
38
39
|
RECENT_MESSAGE_LIMIT
|
|
39
40
|
} from "./roy-agent-core-418zc9ha.js";
|
|
@@ -1795,7 +1796,8 @@ var execAsync = promisify(exec);
|
|
|
1795
1796
|
var KNOWN_CARD_ACTIONS = new Set([
|
|
1796
1797
|
"create_group",
|
|
1797
1798
|
"disband_group",
|
|
1798
|
-
"refresh_activity"
|
|
1799
|
+
"refresh_activity",
|
|
1800
|
+
"select_task"
|
|
1799
1801
|
]);
|
|
1800
1802
|
function isCardActionName(v) {
|
|
1801
1803
|
return typeof v === "string" && KNOWN_CARD_ACTIONS.has(v);
|
|
@@ -1803,7 +1805,8 @@ function isCardActionName(v) {
|
|
|
1803
1805
|
var ACTION_SUBJECT_FIELD = {
|
|
1804
1806
|
create_group: "taskId or sessionId",
|
|
1805
1807
|
disband_group: "taskId or sessionId",
|
|
1806
|
-
refresh_activity: "sessionId"
|
|
1808
|
+
refresh_activity: "sessionId",
|
|
1809
|
+
select_task: "taskId or sessionId"
|
|
1807
1810
|
};
|
|
1808
1811
|
function validateCardActionValue(raw) {
|
|
1809
1812
|
const action = raw.action;
|
|
@@ -1844,6 +1847,25 @@ function validateCardActionValue(raw) {
|
|
|
1844
1847
|
error: `Missing required field: ${requiredField} (action=${action})`
|
|
1845
1848
|
};
|
|
1846
1849
|
}
|
|
1850
|
+
if (action === "select_task") {
|
|
1851
|
+
const rawTaskId = raw.taskId;
|
|
1852
|
+
const taskId = typeof rawTaskId === "number" ? rawTaskId : typeof rawTaskId === "string" ? parseInt(rawTaskId, 10) : Number.NaN;
|
|
1853
|
+
if (rawTaskId === undefined || rawTaskId === null || rawTaskId === "") {
|
|
1854
|
+
return {
|
|
1855
|
+
ok: false,
|
|
1856
|
+
action,
|
|
1857
|
+
error: `Missing required field: taskId (action=${action}; sessionId=${sessionId})`
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
if (!Number.isFinite(taskId) || Number.isNaN(taskId) || taskId <= 0) {
|
|
1861
|
+
return {
|
|
1862
|
+
ok: false,
|
|
1863
|
+
action,
|
|
1864
|
+
error: `Invalid taskId: ${String(rawTaskId)} (action=${action})`
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
return { ok: true, action, sessionId, taskId };
|
|
1868
|
+
}
|
|
1847
1869
|
return { ok: true, action, sessionId };
|
|
1848
1870
|
}
|
|
1849
1871
|
function extractTargetSessionId(context) {
|
|
@@ -1923,6 +1945,13 @@ async function handleCardAction(event, ports) {
|
|
|
1923
1945
|
if (validation.action === "refresh_activity") {
|
|
1924
1946
|
return await handleRefreshSessionCard(event, ports);
|
|
1925
1947
|
}
|
|
1948
|
+
if (validation.action === "select_task") {
|
|
1949
|
+
const sel = validation;
|
|
1950
|
+
return await handleSelectTask(event, ports, {
|
|
1951
|
+
sessionId: sel.sessionId,
|
|
1952
|
+
taskId: sel.taskId
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1926
1955
|
const groupValidation = validation;
|
|
1927
1956
|
const action = groupValidation.action;
|
|
1928
1957
|
const taskId = groupValidation.taskId;
|
|
@@ -2292,6 +2321,31 @@ function parseTaskIdLoose(raw) {
|
|
|
2292
2321
|
async function handleRefreshSessionActivity(event, ports, subject) {
|
|
2293
2322
|
const action = "refresh_activity";
|
|
2294
2323
|
const sessionId = subject.sessionId;
|
|
2324
|
+
if (subject.taskId !== undefined && ports.notifier?.isTaskCardMessage?.(event.messageId) && !ports.notifier?.isSessionCardMessage?.(event.messageId)) {
|
|
2325
|
+
logger6.info(`handleRefreshSessionActivity: messageId=${event.messageId} 是 task 卡 ` + `(task #${subject.taskId}),refresh_activity 委托 task 路径(保持卡身份)`);
|
|
2326
|
+
const taskCard = await ports.getTask?.(subject.taskId);
|
|
2327
|
+
if (taskCard) {
|
|
2328
|
+
return await handleRefreshActivity(event, ports, taskCard, subject.taskId);
|
|
2329
|
+
}
|
|
2330
|
+
logger6.warn(`handleRefreshSessionActivity: task #${subject.taskId} 读取失败,` + `refresh_activity 回落 session 路径`);
|
|
2331
|
+
}
|
|
2332
|
+
if (subject.taskId !== undefined && !ports.notifier?.isSessionCardMessage?.(event.messageId) && !ports.notifier?.isTaskCardMessage?.(event.messageId)) {
|
|
2333
|
+
let persisted;
|
|
2334
|
+
try {
|
|
2335
|
+
persisted = getSharedLarkCardStateStore().get(subject.taskId);
|
|
2336
|
+
} catch (err) {
|
|
2337
|
+
logger6.warn(`handleRefreshSessionActivity: 持久层读取失败 ` + `(task #${subject.taskId}),跳过兜底: ${err.message}`);
|
|
2338
|
+
persisted = undefined;
|
|
2339
|
+
}
|
|
2340
|
+
if (persisted?.messageId && persisted.messageId === event.messageId) {
|
|
2341
|
+
logger6.info(`handleRefreshSessionActivity: notifier 无状态但持久层确认 ` + `messageId=${event.messageId} 是 task 卡(task #${subject.taskId}),` + `refresh_activity 委托 task 路径(保持卡身份)`);
|
|
2342
|
+
const taskCard = await ports.getTask?.(subject.taskId);
|
|
2343
|
+
if (taskCard) {
|
|
2344
|
+
return await handleRefreshActivity(event, ports, taskCard, subject.taskId);
|
|
2345
|
+
}
|
|
2346
|
+
logger6.warn(`handleRefreshSessionActivity: task #${subject.taskId} 读取失败,` + `refresh_activity 回落 session 路径`);
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2295
2349
|
let probe;
|
|
2296
2350
|
try {
|
|
2297
2351
|
probe = await ports.loadSessionActivity?.(sessionId);
|
|
@@ -2310,13 +2364,16 @@ async function handleRefreshSessionActivity(event, ports, subject) {
|
|
|
2310
2364
|
logger6.warn(`handleRefreshSessionActivity: loadSessionMessages failed for ${sessionId}: ` + `${err.message}(降级为不渲染最近消息面板)`);
|
|
2311
2365
|
recentMessages = undefined;
|
|
2312
2366
|
}
|
|
2367
|
+
const sessionTaskList = await loadSessionTasksSafe(sessionId, ports);
|
|
2368
|
+
const sessionTasks = sessionTaskList.tasks;
|
|
2313
2369
|
const snapshot = probe?.activity ?? null;
|
|
2314
2370
|
const sessionAlive = probe?.activity !== undefined && !probe?.terminal;
|
|
2315
2371
|
const lifecycle = probe?.lifecycle ? probe.lifecycle : probe?.terminal ? "completed" : sessionAlive ? "running" : taskEnrichment?.lifecycle ?? "running";
|
|
2316
2372
|
const preserved = ports.notifier?.buildSessionCardWithActivity?.(event.messageId, sessionId, snapshot, {
|
|
2317
2373
|
lifecycle,
|
|
2318
2374
|
task: taskEnrichment?.info,
|
|
2319
|
-
...recentMessages !== undefined ? { recentMessages } : {}
|
|
2375
|
+
...recentMessages !== undefined ? { recentMessages } : {},
|
|
2376
|
+
sessionTasks
|
|
2320
2377
|
});
|
|
2321
2378
|
if (preserved) {
|
|
2322
2379
|
logger6.debug(`handleRefreshSessionActivity: ${sessionId} 活性已刷新 ` + `(messageCount=${snapshot?.messageCount ?? "n/a"}, task=${subject.taskId ?? "none"})`);
|
|
@@ -2331,9 +2388,118 @@ async function handleRefreshSessionActivity(event, ports, subject) {
|
|
|
2331
2388
|
sessionId,
|
|
2332
2389
|
activity: snapshot,
|
|
2333
2390
|
lifecycle,
|
|
2391
|
+
...sessionTasks.length > 0 ? { tasks: sessionTasks } : {},
|
|
2392
|
+
...sessionTaskList.total !== undefined ? { taskTotal: sessionTaskList.total } : {},
|
|
2334
2393
|
...taskEnrichment?.info ? { task: taskEnrichment.info } : {},
|
|
2335
2394
|
...groupChat?.chatId ? { perTaskChatId: groupChat.chatId } : {},
|
|
2336
|
-
...recentMessages !== undefined ? { recentMessages } : {}
|
|
2395
|
+
...recentMessages !== undefined ? { recentMessages } : {},
|
|
2396
|
+
...sessionTasks.length > 0 ? { tasks: sessionTasks } : {}
|
|
2397
|
+
})
|
|
2398
|
+
};
|
|
2399
|
+
}
|
|
2400
|
+
function toTaskSummary(raw) {
|
|
2401
|
+
if (!raw || typeof raw !== "object")
|
|
2402
|
+
return;
|
|
2403
|
+
const r = raw;
|
|
2404
|
+
const id = typeof r.id === "number" ? r.id : typeof r.id === "string" ? parseInt(r.id, 10) : Number.NaN;
|
|
2405
|
+
if (!Number.isFinite(id) || id <= 0)
|
|
2406
|
+
return;
|
|
2407
|
+
const currentStatus = typeof r.currentStatus === "string" ? r.currentStatus : typeof r.current_status === "string" ? r.current_status : undefined;
|
|
2408
|
+
const goals = typeof r.goals === "string" ? r.goals : typeof r.goals_and_expected_deliverables === "string" ? r.goals_and_expected_deliverables : undefined;
|
|
2409
|
+
const parentTaskId = typeof r.parentTaskId === "number" ? r.parentTaskId : typeof r.parent_task_id === "number" && r.parent_task_id > 0 ? r.parent_task_id : undefined;
|
|
2410
|
+
const createdAt = typeof r.createdAt === "string" ? r.createdAt : typeof r.created_at === "string" ? r.created_at : undefined;
|
|
2411
|
+
const updatedAt = typeof r.updatedAt === "string" ? r.updatedAt : typeof r.updated_at === "string" ? r.updated_at : undefined;
|
|
2412
|
+
return {
|
|
2413
|
+
id,
|
|
2414
|
+
...typeof r.title === "string" && r.title ? { title: r.title } : {},
|
|
2415
|
+
...typeof r.status === "string" && r.status ? { status: r.status } : {},
|
|
2416
|
+
...typeof r.progress === "number" ? { progress: r.progress } : {},
|
|
2417
|
+
...currentStatus ? { currentStatus } : {},
|
|
2418
|
+
...typeof r.priority === "string" && r.priority ? { priority: r.priority } : {},
|
|
2419
|
+
...parentTaskId !== undefined ? { parentTaskId } : {},
|
|
2420
|
+
...goals ? { goals } : {},
|
|
2421
|
+
...createdAt ? { createdAt } : {},
|
|
2422
|
+
...updatedAt ? { updatedAt } : {}
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
2425
|
+
async function loadSessionTasksSafe(sessionId, ports) {
|
|
2426
|
+
try {
|
|
2427
|
+
const raw = await ports.loadSessionTasks?.(sessionId);
|
|
2428
|
+
const list = Array.isArray(raw) ? raw : raw?.tasks;
|
|
2429
|
+
if (!Array.isArray(list))
|
|
2430
|
+
return { tasks: [] };
|
|
2431
|
+
const tasks = list.map((t) => toTaskSummary(t)).filter((t) => t !== undefined);
|
|
2432
|
+
const total = !Array.isArray(raw) && typeof raw?.total === "number" ? raw.total : undefined;
|
|
2433
|
+
return { tasks, ...total !== undefined ? { total } : {} };
|
|
2434
|
+
} catch (err) {
|
|
2435
|
+
logger6.warn(`loadSessionTasksSafe: ${sessionId} 读取失败(任务列表面板降级为空): ` + `${err.message}`);
|
|
2436
|
+
return { tasks: [] };
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
async function handleSelectTask(event, ports, subject) {
|
|
2440
|
+
const action = "select_task";
|
|
2441
|
+
const { sessionId, taskId } = subject;
|
|
2442
|
+
const taskListResult = await loadSessionTasksSafe(sessionId, ports);
|
|
2443
|
+
const tasks = taskListResult.tasks;
|
|
2444
|
+
if (tasks.length > 0 && !tasks.some((t) => t.id === taskId)) {
|
|
2445
|
+
logger6.warn(`handleSelectTask: task #${taskId} 不属于 ${sessionId}(列表 ${tasks.length} 个)→ 忽略本次切换`);
|
|
2446
|
+
return {
|
|
2447
|
+
ok: false,
|
|
2448
|
+
action,
|
|
2449
|
+
error: `task #${taskId} is not a member of session ${sessionId}`
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
let selectedTask;
|
|
2453
|
+
try {
|
|
2454
|
+
const raw = await ports.getTask?.(taskId);
|
|
2455
|
+
selectedTask = toTaskSummary(raw);
|
|
2456
|
+
} catch (err) {
|
|
2457
|
+
logger6.warn(`handleSelectTask: getTask(${taskId}) 失败(降级为不渲染任务详情): ` + `${err.message}`);
|
|
2458
|
+
selectedTask = undefined;
|
|
2459
|
+
}
|
|
2460
|
+
if (!selectedTask) {
|
|
2461
|
+
selectedTask = tasks.find((t) => t.id === taskId);
|
|
2462
|
+
}
|
|
2463
|
+
let milestones;
|
|
2464
|
+
try {
|
|
2465
|
+
const raw = await ports.loadTaskMilestones?.(taskId);
|
|
2466
|
+
milestones = Array.isArray(raw) ? raw : undefined;
|
|
2467
|
+
} catch (err) {
|
|
2468
|
+
logger6.warn(`handleSelectTask: loadTaskMilestones(${taskId}) 失败(里程碑区降级为空): ` + `${err.message}`);
|
|
2469
|
+
milestones = undefined;
|
|
2470
|
+
}
|
|
2471
|
+
let probe;
|
|
2472
|
+
try {
|
|
2473
|
+
probe = await ports.loadSessionActivity?.(sessionId);
|
|
2474
|
+
} catch (err) {
|
|
2475
|
+
logger6.warn(`handleSelectTask: loadSessionActivity(${sessionId}) 失败(沿用上次快照): ` + `${err.message}`);
|
|
2476
|
+
probe = undefined;
|
|
2477
|
+
}
|
|
2478
|
+
const stateActivity = ports.notifier?.getSessionCardState?.(sessionId)?.activity;
|
|
2479
|
+
const activitySnapshot = probe ? probe.activity ?? null : stateActivity ?? null;
|
|
2480
|
+
const patched = ports.notifier?.buildSessionCardWithActivity?.(event.messageId, sessionId, activitySnapshot, {
|
|
2481
|
+
...probe?.lifecycle ? { lifecycle: probe.lifecycle } : {},
|
|
2482
|
+
sessionTasks: tasks,
|
|
2483
|
+
...taskListResult.total !== undefined ? { taskTotal: taskListResult.total } : {},
|
|
2484
|
+
...selectedTask ? { selectedTask } : {},
|
|
2485
|
+
...milestones !== undefined ? { selectedTaskMilestones: milestones } : {}
|
|
2486
|
+
});
|
|
2487
|
+
if (patched) {
|
|
2488
|
+
logger6.debug(`handleSelectTask: ${sessionId} 切到 task #${taskId}(列表 ${tasks.length} 个任务)`);
|
|
2489
|
+
return { ok: true, action, cardUpdate: patched };
|
|
2490
|
+
}
|
|
2491
|
+
logger6.warn(`handleSelectTask: notifier 无 messageId=${event.messageId} 的状态,fallback 重建 session 卡`);
|
|
2492
|
+
return {
|
|
2493
|
+
ok: true,
|
|
2494
|
+
action,
|
|
2495
|
+
cardUpdate: buildSessionCard({
|
|
2496
|
+
sessionId,
|
|
2497
|
+
tasks,
|
|
2498
|
+
...taskListResult.total !== undefined ? { taskTotal: taskListResult.total } : {},
|
|
2499
|
+
...selectedTask ? { selectedTask } : {},
|
|
2500
|
+
...milestones !== undefined ? { selectedTaskMilestones: milestones } : {},
|
|
2501
|
+
...probe?.activity !== undefined ? { activity: probe.activity } : {},
|
|
2502
|
+
...probe?.lifecycle ? { lifecycle: probe.lifecycle } : {}
|
|
2337
2503
|
})
|
|
2338
2504
|
};
|
|
2339
2505
|
}
|
|
@@ -2600,6 +2766,7 @@ class LarkCliTaskNotifyHook {
|
|
|
2600
2766
|
pluginName;
|
|
2601
2767
|
sourceId;
|
|
2602
2768
|
config;
|
|
2769
|
+
cardNotifyConfigReader;
|
|
2603
2770
|
cardNotifier;
|
|
2604
2771
|
cardMessageIds = new Map;
|
|
2605
2772
|
cardStateStore;
|
|
@@ -2615,6 +2782,9 @@ class LarkCliTaskNotifyHook {
|
|
|
2615
2782
|
this.description = "LarkCli 任务通知 Hook(卡片模式)";
|
|
2616
2783
|
this.pluginName = config.pluginName;
|
|
2617
2784
|
this.sourceId = config.sourceId;
|
|
2785
|
+
if (config.cardNotifyConfigReader) {
|
|
2786
|
+
this.cardNotifyConfigReader = config.cardNotifyConfigReader;
|
|
2787
|
+
}
|
|
2618
2788
|
this.config = {
|
|
2619
2789
|
enabled: true,
|
|
2620
2790
|
priority: 5,
|
|
@@ -2639,6 +2809,17 @@ class LarkCliTaskNotifyHook {
|
|
|
2639
2809
|
hasCardRoutingPorts() {
|
|
2640
2810
|
return this.cardRoutingPorts !== undefined;
|
|
2641
2811
|
}
|
|
2812
|
+
currentEmitTaskCard() {
|
|
2813
|
+
if (this.config.emitTaskCard !== undefined) {
|
|
2814
|
+
return this.config.emitTaskCard !== false;
|
|
2815
|
+
}
|
|
2816
|
+
try {
|
|
2817
|
+
const flags = this.cardNotifyConfigReader?.();
|
|
2818
|
+
if (flags)
|
|
2819
|
+
return flags.emitTaskCard !== false;
|
|
2820
|
+
} catch {}
|
|
2821
|
+
return true;
|
|
2822
|
+
}
|
|
2642
2823
|
async execute(ctx) {
|
|
2643
2824
|
if (!this.config.enabled) {
|
|
2644
2825
|
return;
|
|
@@ -2676,6 +2857,7 @@ class LarkCliTaskNotifyHook {
|
|
|
2676
2857
|
if (!this.isCardModeEnabled())
|
|
2677
2858
|
return;
|
|
2678
2859
|
const sessionId = typeof ctxSessionId === "string" && ctxSessionId.trim() ? ctxSessionId.trim() : this.resolveSessionIdForTask(task.id);
|
|
2860
|
+
const emitTaskCard = this.currentEmitTaskCard();
|
|
2679
2861
|
if (sessionId) {
|
|
2680
2862
|
const merged = await this.patchSessionCardForTask(task, {
|
|
2681
2863
|
sessionId,
|
|
@@ -2689,8 +2871,9 @@ class LarkCliTaskNotifyHook {
|
|
|
2689
2871
|
]
|
|
2690
2872
|
});
|
|
2691
2873
|
if (merged) {
|
|
2692
|
-
logger7.debug(`onAfterCreate: task #${task.id} 已渲染进 session 卡 ${sessionId}
|
|
2693
|
-
|
|
2874
|
+
logger7.debug(`onAfterCreate: task #${task.id} 已渲染进 session 卡 ${sessionId}` + `(${emitTaskCard ? "并存:继续发任务卡片" : "单卡语义:不再发任务卡片"})`);
|
|
2875
|
+
if (!emitTaskCard)
|
|
2876
|
+
return;
|
|
2694
2877
|
}
|
|
2695
2878
|
}
|
|
2696
2879
|
await this.sendCardStart(task);
|
|
@@ -2707,6 +2890,7 @@ class LarkCliTaskNotifyHook {
|
|
|
2707
2890
|
return;
|
|
2708
2891
|
if (!this.isCardModeEnabled())
|
|
2709
2892
|
return;
|
|
2893
|
+
const emitTaskCardTerminal = this.currentEmitTaskCard();
|
|
2710
2894
|
const sessionIdTerminal = this.resolveSessionIdForTask(task.id);
|
|
2711
2895
|
if (sessionIdTerminal) {
|
|
2712
2896
|
const mergedTerminal = await this.patchSessionCardForTask(task, {
|
|
@@ -2720,7 +2904,7 @@ class LarkCliTaskNotifyHook {
|
|
|
2720
2904
|
}
|
|
2721
2905
|
]
|
|
2722
2906
|
});
|
|
2723
|
-
if (mergedTerminal)
|
|
2907
|
+
if (mergedTerminal && !emitTaskCardTerminal)
|
|
2724
2908
|
return;
|
|
2725
2909
|
}
|
|
2726
2910
|
await this.sendCardFinish(task);
|
|
@@ -2738,13 +2922,14 @@ class LarkCliTaskNotifyHook {
|
|
|
2738
2922
|
return;
|
|
2739
2923
|
if (!this.isCardModeEnabled())
|
|
2740
2924
|
return;
|
|
2925
|
+
const emitTaskCardUpdate = this.currentEmitTaskCard();
|
|
2741
2926
|
const sessionIdUpdate = this.resolveSessionIdForTask(task.id);
|
|
2742
2927
|
if (sessionIdUpdate) {
|
|
2743
2928
|
const mergedUpdate = await this.patchSessionCardForTask(task, {
|
|
2744
2929
|
sessionId: sessionIdUpdate,
|
|
2745
2930
|
lifecycle: lifecycleOfTaskStatus(String(task.status)) ?? "running"
|
|
2746
2931
|
});
|
|
2747
|
-
if (mergedUpdate)
|
|
2932
|
+
if (mergedUpdate && !emitTaskCardUpdate)
|
|
2748
2933
|
return;
|
|
2749
2934
|
}
|
|
2750
2935
|
await this.sendCardUpdate(task, changes);
|
|
@@ -2917,7 +3102,9 @@ class LarkCliTaskNotifyHook {
|
|
|
2917
3102
|
if (rec.sessionId) {
|
|
2918
3103
|
this.cardNotifier?.bindTaskToSession?.(taskId, rec.sessionId);
|
|
2919
3104
|
if (rec.messageId) {
|
|
2920
|
-
this.
|
|
3105
|
+
if (!this.currentEmitTaskCard()) {
|
|
3106
|
+
this.cardNotifier?.adoptSessionCard?.(rec.sessionId, rec.messageId);
|
|
3107
|
+
}
|
|
2921
3108
|
}
|
|
2922
3109
|
}
|
|
2923
3110
|
if (!this.restoredTaskIds.has(taskId)) {
|
|
@@ -3485,6 +3672,8 @@ class LarkCliTaskNotifyHook {
|
|
|
3485
3672
|
syncGroupCardFromOriginFn;
|
|
3486
3673
|
recordSessionCardForTask(task, sessionId, chatId, profile, messageIdIn) {
|
|
3487
3674
|
this.cardNotifier?.bindTaskToSession?.(task.id, sessionId);
|
|
3675
|
+
if (this.currentEmitTaskCard())
|
|
3676
|
+
return;
|
|
3488
3677
|
if (!this.cardStateStore)
|
|
3489
3678
|
return;
|
|
3490
3679
|
const messageId = messageIdIn ?? this.cardNotifier?.getSessionCardMessageId?.(sessionId);
|
|
@@ -3578,6 +3767,12 @@ class LarkCliTaskNotifyHook {
|
|
|
3578
3767
|
__legacyDecorateClassTS([
|
|
3579
3768
|
TracedAs("lark-cli-task-notify.execute")
|
|
3580
3769
|
], LarkCliTaskNotifyHook.prototype, "execute", null);
|
|
3770
|
+
__legacyDecorateClassTS([
|
|
3771
|
+
TracedAs("lark-card.restoreState", {
|
|
3772
|
+
recordParams: true,
|
|
3773
|
+
paramFilter: (args) => ({ taskId: args[0] })
|
|
3774
|
+
})
|
|
3775
|
+
], LarkCliTaskNotifyHook.prototype, "restoreCardState", null);
|
|
3581
3776
|
__legacyDecorateClassTS([
|
|
3582
3777
|
TracedAs("lark-cli-task-notify.resolveCardTarget", {
|
|
3583
3778
|
recordParams: true,
|
|
@@ -3595,6 +3790,24 @@ __legacyDecorateClassTS([
|
|
|
3595
3790
|
})
|
|
3596
3791
|
})
|
|
3597
3792
|
], LarkCliTaskNotifyHook.prototype, "resolveCardTarget", null);
|
|
3793
|
+
__legacyDecorateClassTS([
|
|
3794
|
+
TracedAs("lark-card.sendStart", {
|
|
3795
|
+
recordParams: false,
|
|
3796
|
+
paramFilter: (args) => ({ taskId: args[0]?.id, sessionId: args[0]?.sessionId })
|
|
3797
|
+
})
|
|
3798
|
+
], LarkCliTaskNotifyHook.prototype, "sendCardStart", null);
|
|
3799
|
+
__legacyDecorateClassTS([
|
|
3800
|
+
TracedAs("lark-card.patchForTask", {
|
|
3801
|
+
recordParams: true,
|
|
3802
|
+
flattenParamFilter: true,
|
|
3803
|
+
paramFilter: (args) => ({
|
|
3804
|
+
taskId: args[0]?.id,
|
|
3805
|
+
sessionId: args[0]?.sessionId,
|
|
3806
|
+
lifecycle: args[1]?.lifecycle,
|
|
3807
|
+
statusPhrase: args[1]?.statusPhrase
|
|
3808
|
+
})
|
|
3809
|
+
})
|
|
3810
|
+
], LarkCliTaskNotifyHook.prototype, "patchSessionCardForTask", null);
|
|
3598
3811
|
function createLarkCliTaskNotifyHook(config = {}) {
|
|
3599
3812
|
return new LarkCliTaskNotifyHook(config);
|
|
3600
3813
|
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
createWecomTaskNotifyHook,
|
|
20
20
|
deleteGroupChatViaLarkCli,
|
|
21
21
|
handleCardAction
|
|
22
|
-
} from "./roy-agent-core-
|
|
22
|
+
} from "./roy-agent-core-57q8a049.js";
|
|
23
23
|
import {
|
|
24
24
|
registerWecomRespondTarget,
|
|
25
25
|
sendWecomCliMarkdown,
|
|
@@ -37,12 +37,12 @@ import {
|
|
|
37
37
|
} from "./roy-agent-core-brw8wp2q.js";
|
|
38
38
|
import {
|
|
39
39
|
createLarkCliWorkflowNotifyHook
|
|
40
|
-
} from "./roy-agent-core-
|
|
40
|
+
} from "./roy-agent-core-h3j1z13p.js";
|
|
41
41
|
import {
|
|
42
42
|
DEFAULT_APP_LINK_BASE,
|
|
43
43
|
getSharedLarkCardNotifier,
|
|
44
44
|
getSharedLarkCardStateStore
|
|
45
|
-
} from "./roy-agent-core-
|
|
45
|
+
} from "./roy-agent-core-ddp3n8cb.js";
|
|
46
46
|
import {
|
|
47
47
|
RECENT_MESSAGE_LIMIT,
|
|
48
48
|
createActivityProbe,
|
|
@@ -4844,6 +4844,66 @@ class LarkCliInstance {
|
|
|
4844
4844
|
const calls = extractToolCallsFromMessages(tail);
|
|
4845
4845
|
return calls.slice(-n);
|
|
4846
4846
|
},
|
|
4847
|
+
loadSessionTasks: async (sessionId) => {
|
|
4848
|
+
try {
|
|
4849
|
+
const ids = await taskComponent.getTaskIdsBySessionId?.(sessionId);
|
|
4850
|
+
if (!Array.isArray(ids) || ids.length === 0)
|
|
4851
|
+
return [];
|
|
4852
|
+
const SESSION_TASK_DETAIL_LIMIT = 20;
|
|
4853
|
+
const recentIds = [...ids].sort((a, b) => b - a).slice(0, SESSION_TASK_DETAIL_LIMIT);
|
|
4854
|
+
const items = [];
|
|
4855
|
+
const ts = (v) => {
|
|
4856
|
+
if (typeof v !== "string")
|
|
4857
|
+
return 0;
|
|
4858
|
+
const n = Date.parse(v);
|
|
4859
|
+
return Number.isFinite(n) ? n : 0;
|
|
4860
|
+
};
|
|
4861
|
+
for (const id of recentIds) {
|
|
4862
|
+
try {
|
|
4863
|
+
const t = await taskComponent.getTask(id);
|
|
4864
|
+
if (!t?.id)
|
|
4865
|
+
continue;
|
|
4866
|
+
const updatedAt = t.updatedAt ?? t.updated_at;
|
|
4867
|
+
items.push({
|
|
4868
|
+
id: t.id,
|
|
4869
|
+
...t.title ? { title: t.title } : {},
|
|
4870
|
+
...t.status ? { status: String(t.status) } : {},
|
|
4871
|
+
...typeof t.progress === "number" ? { progress: t.progress } : {},
|
|
4872
|
+
_ts: ts(updatedAt)
|
|
4873
|
+
});
|
|
4874
|
+
} catch {}
|
|
4875
|
+
}
|
|
4876
|
+
items.sort((a, b) => b._ts - a._ts || b.id - a.id);
|
|
4877
|
+
return {
|
|
4878
|
+
tasks: items.map(({ _ts: _ignored, ...rest }) => rest),
|
|
4879
|
+
total: ids.length
|
|
4880
|
+
};
|
|
4881
|
+
} catch (err) {
|
|
4882
|
+
logger4.warn(`loadSessionTasks(${sessionId}) 失败(任务列表面板降级为空): ` + `${err.message}`);
|
|
4883
|
+
return [];
|
|
4884
|
+
}
|
|
4885
|
+
},
|
|
4886
|
+
loadTaskMilestones: async (taskId) => {
|
|
4887
|
+
try {
|
|
4888
|
+
const ops = await taskComponent.listOperations?.({ taskId, limit: 50 });
|
|
4889
|
+
if (!Array.isArray(ops) || ops.length === 0)
|
|
4890
|
+
return [];
|
|
4891
|
+
return ops.map((op) => {
|
|
4892
|
+
const o = op;
|
|
4893
|
+
const title = o.milestoneTitle ?? o.actionTitle;
|
|
4894
|
+
if (!title)
|
|
4895
|
+
return;
|
|
4896
|
+
return {
|
|
4897
|
+
title,
|
|
4898
|
+
timestamp: o.timestamp ?? new Date().toISOString(),
|
|
4899
|
+
...o.milestoneDescription ?? o.actionDescription ? { description: o.milestoneDescription ?? o.actionDescription } : {}
|
|
4900
|
+
};
|
|
4901
|
+
}).filter((m) => m !== undefined);
|
|
4902
|
+
} catch (err) {
|
|
4903
|
+
logger4.warn(`loadTaskMilestones(${taskId}) 失败(里程碑区降级为空): ` + `${err.message}`);
|
|
4904
|
+
return [];
|
|
4905
|
+
}
|
|
4906
|
+
},
|
|
4847
4907
|
attachGroupSession: async (args) => {
|
|
4848
4908
|
const sessionComponent = this.environment?.getComponent?.("session");
|
|
4849
4909
|
if (typeof sessionComponent?.attachGroupSession !== "function") {
|