@ai-setting/roy-agent-core 1.7.57 → 1.7.58

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.
@@ -57,9 +57,10 @@
57
57
  * 都不得向上抛,绝不污染原始错误传播链
58
58
  * - **有硬超时**:兜底 reply 在 5s 内一定 settle(超时 kill 子进程)。
59
59
  * 否则 lark-cli 卡住会把 `QueryExecutor` 的 rethrow 拖死 → 事件队列堵死
60
- * - **复用现有机制**:spawn 参数形态与 `LarkCliNotificationChannel` /
61
- * `event-source-handlers.sendLarkMessage` 保持一致(`--profile` 前置、
62
- * messageId → `+messages-reply`、chatId → `+messages-send`)
60
+ * - **复用现有机制**:spawn 参数形态与 `event-source-handlers.sendLarkMessage`
61
+ * / `lark-card-patch-notifier.buildSendCardArgs` / `telemetry-notice.buildLarkSendArgs`
62
+ * 保持一致(`--profile` 前置、messageId → `+messages-reply`、
63
+ * chatId → `+messages-send`、**两支都显式 `--as bot`**)
63
64
  * - **去重**:同一 triggerEvent(messageId)只回一次;chat-only 通道走
64
65
  * 5 分钟窗口,**不会**把整个群永久封锁;发送失败回滚去重标记
65
66
  * - **无 channel 不崩但也不静默**:本地 REPL / `act` 没有飞书上下文 → debug;
@@ -11,7 +11,7 @@ import {
11
11
  larkCliHandler,
12
12
  resolveBountyIMSystemPrompt,
13
13
  timerHandler
14
- } from "../../shared/@ai-setting/roy-agent-core-jw5ar4p0.js";
14
+ } from "../../shared/@ai-setting/roy-agent-core-fy4mcj6x.js";
15
15
  import {
16
16
  BUILT_IN_EVENT_SOURCE_TYPES,
17
17
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
package/dist/env/index.js CHANGED
@@ -3,19 +3,19 @@ import {
3
3
  } from "../shared/@ai-setting/roy-agent-core-84rs0c8d.js";
4
4
  import {
5
5
  TaskComponent
6
- } from "../shared/@ai-setting/roy-agent-core-ewcc5qdt.js";
6
+ } from "../shared/@ai-setting/roy-agent-core-991pk4ss.js";
7
7
  import"../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
8
8
  import"../shared/@ai-setting/roy-agent-core-7q4wdze2.js";
9
9
  import"../shared/@ai-setting/roy-agent-core-vh0qzb24.js";
10
10
  import"../shared/@ai-setting/roy-agent-core-rn57psp0.js";
11
11
  import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
12
- import"../shared/@ai-setting/roy-agent-core-1sfbs57v.js";
12
+ import"../shared/@ai-setting/roy-agent-core-6bradb0j.js";
13
13
  import"../shared/@ai-setting/roy-agent-core-14bq77wr.js";
14
14
  import {
15
15
  EventSourceComponent,
16
16
  builtInHandlers,
17
17
  larkCliHandler
18
- } from "../shared/@ai-setting/roy-agent-core-jw5ar4p0.js";
18
+ } from "../shared/@ai-setting/roy-agent-core-fy4mcj6x.js";
19
19
  import {
20
20
  EventSourceInitHooks,
21
21
  getDefaultConfigForType,
@@ -86,7 +86,9 @@ ${options.content}`;
86
86
  "--chat-id",
87
87
  chatId,
88
88
  "--markdown",
89
- normalizedContent
89
+ normalizedContent,
90
+ "--as",
91
+ "bot"
90
92
  ];
91
93
  }
92
94
  if (profile) {
@@ -19,10 +19,19 @@
19
19
  *
20
20
  * ## spawn lark-cli
21
21
  *
22
- * - messageId 走 `lark-cli im +messages-reply --message-id <id> --markdown <md>`
23
- * - chatId 走 `lark-cli im +messages-send --chat-id <id> --markdown <md>`
22
+ * - messageId 走 `lark-cli im +messages-reply --message-id <id> --markdown <md> --as bot`
23
+ * - chatId 走 `lark-cli im +messages-send --chat-id <id> --markdown <md> --as bot`
24
24
  * - profile 不为 undefined 时在 args 头部插入 `--profile <name>`
25
25
  *
26
+ * ⚠️ **两支都必须显式 `--as bot`**(Task #4557)。chatId 分支历史上漏了,
27
+ * 不带 flag 时 lark-cli 用默认身份 = **user(真人账号)** 发出 →
28
+ * `lark-cli event consume im.message.receive_v1` 只看「是不是 user 发的」→
29
+ * 自己的通知被同一个 consumer 回灌成「用户消息」→ 又跑一次完整 agent run。
30
+ * Task #4552 在同类路径实测回灌率 **5/11 = 45%**,补 flag 后 **0/5 = 0%**
31
+ * (证据:本机 E2E 报告 `reports/4552-a1-real-e2e.md` §6(`reports/` 被 .gitignore 忽略,未入库))。
32
+ * 本 channel 虽 `@deprecated` 但仍是 opt-in 可启用实现,所以同样必须修。
33
+ * 失败即 reject → 由 `send()` 层 swallow + warn,**绝不降级成 user**。
34
+ *
26
35
  * ## 失败处理
27
36
  *
28
37
  * - spawn 失败 / exit code != 0 → swallow(log warn,notification 失败不污染 Plugin 主流程)
@@ -49,6 +49,20 @@ export interface BackgroundTaskStartedPayload {
49
49
  parentSessionId: string;
50
50
  description: string;
51
51
  subagentType: string;
52
+ /**
53
+ * ★ Task #4552 (A1):任务启动时刻(epoch ms)。
54
+ *
55
+ * 消费端(CLI EventHandler)把 telemetry 降级成一条纯 IM 进展提示后,
56
+ * 文案要回答「跑了多久」,只能从这里读。缺失时文案降级(不渲染「已跑」)。
57
+ */
58
+ startedAt?: number;
59
+ /**
60
+ * ★ Task #4552 (A1):本任务被允许的运行时长(毫秒)。
61
+ *
62
+ * 让用户看到「预计 17:23 超时(timeout 5h)」,避免以为「早该有结论了」——
63
+ * 这正是 Task #4552 报障的认知错位(用户 16:40 以为超时,实际 17:23 才超)。
64
+ */
65
+ timeoutMs?: number;
52
66
  }
53
67
  export interface BackgroundTaskProgressPayload {
54
68
  backgroundTaskId: string;
@@ -58,6 +72,10 @@ export interface BackgroundTaskProgressPayload {
58
72
  progress?: number;
59
73
  description?: string;
60
74
  associatedTaskId?: number;
75
+ /** ★ Task #4552 (A1):见 BackgroundTaskStartedPayload.startedAt */
76
+ startedAt?: number;
77
+ /** ★ Task #4552 (A1):见 BackgroundTaskStartedPayload.timeoutMs */
78
+ timeoutMs?: number;
61
79
  }
62
80
  export interface BackgroundTaskCompletedPayload {
63
81
  backgroundTaskId: string;
@@ -191,6 +209,14 @@ export interface BackgroundTask {
191
209
  /** Timestamp of the latest lifecycle state change or progress notification. */
192
210
  lastUpdatedAt?: number;
193
211
  startedAt?: number;
212
+ /**
213
+ * ★ Task #4552 (A1):本任务被允许的运行时长(毫秒,createTask 时确定)。
214
+ *
215
+ * 存到 task 上而不是每次重算:progress 心跳发生在 20 分钟后,那时
216
+ * `timeout` 参数已不在作用域内,只能靠这里。同时保证 started / progress
217
+ * 两条通知给出同一个超时时刻。
218
+ */
219
+ timeoutMs?: number;
194
220
  completedAt?: number;
195
221
  result?: string;
196
222
  error?: string;
@@ -3,7 +3,7 @@ import {
3
3
  BackgroundTaskManager,
4
4
  createDelegateTool,
5
5
  createStopTool
6
- } from "../../../shared/@ai-setting/roy-agent-core-1sfbs57v.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-6bradb0j.js";
7
7
  import"../../../shared/@ai-setting/roy-agent-core-14bq77wr.js";
8
8
  import"../../../shared/@ai-setting/roy-agent-core-2ctyjy62.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
@@ -5,7 +5,7 @@ import {
5
5
  TaskPriorityEnum,
6
6
  TaskStatusEnum,
7
7
  TaskTypeEnum
8
- } from "../../shared/@ai-setting/roy-agent-core-ewcc5qdt.js";
8
+ } from "../../shared/@ai-setting/roy-agent-core-991pk4ss.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-7q4wdze2.js";
11
11
  import"../../shared/@ai-setting/roy-agent-core-vh0qzb24.js";
@@ -13,7 +13,7 @@ import"../../shared/@ai-setting/roy-agent-core-rn57psp0.js";
13
13
  import {
14
14
  TaskEntityEventTypes
15
15
  } from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
16
- import"../../shared/@ai-setting/roy-agent-core-1sfbs57v.js";
16
+ import"../../shared/@ai-setting/roy-agent-core-6bradb0j.js";
17
17
  import"../../shared/@ai-setting/roy-agent-core-14bq77wr.js";
18
18
  import {
19
19
  SQLiteTaskStore,
package/dist/index.js CHANGED
@@ -63,13 +63,13 @@ import {
63
63
  } from "./shared/@ai-setting/roy-agent-core-84rs0c8d.js";
64
64
  import {
65
65
  TaskComponent
66
- } from "./shared/@ai-setting/roy-agent-core-ewcc5qdt.js";
66
+ } from "./shared/@ai-setting/roy-agent-core-991pk4ss.js";
67
67
  import"./shared/@ai-setting/roy-agent-core-amkqnyzy.js";
68
68
  import"./shared/@ai-setting/roy-agent-core-7q4wdze2.js";
69
69
  import"./shared/@ai-setting/roy-agent-core-vh0qzb24.js";
70
70
  import"./shared/@ai-setting/roy-agent-core-rn57psp0.js";
71
71
  import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
72
- import"./shared/@ai-setting/roy-agent-core-1sfbs57v.js";
72
+ import"./shared/@ai-setting/roy-agent-core-6bradb0j.js";
73
73
  import"./shared/@ai-setting/roy-agent-core-14bq77wr.js";
74
74
  import {
75
75
  BountyIMInstance,
@@ -83,7 +83,7 @@ import {
83
83
  larkCliHandler,
84
84
  resolveBountyIMSystemPrompt,
85
85
  timerHandler
86
- } from "./shared/@ai-setting/roy-agent-core-jw5ar4p0.js";
86
+ } from "./shared/@ai-setting/roy-agent-core-fy4mcj6x.js";
87
87
  import {
88
88
  BUILT_IN_EVENT_SOURCE_TYPES,
89
89
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -1207,6 +1207,7 @@ class BackgroundTaskManager {
1207
1207
  status: "pending",
1208
1208
  createdAt,
1209
1209
  lastUpdatedAt: createdAt,
1210
+ timeoutMs: timeout || DEFAULT_TIMEOUT,
1210
1211
  abortController,
1211
1212
  similarTaskIds,
1212
1213
  triggerEventId,
@@ -1219,7 +1220,9 @@ class BackgroundTaskManager {
1219
1220
  subSessionId: subSession.id,
1220
1221
  parentSessionId,
1221
1222
  description,
1222
- subagentType
1223
+ subagentType,
1224
+ startedAt: createdAt,
1225
+ timeoutMs: timeout || DEFAULT_TIMEOUT
1223
1226
  };
1224
1227
  this.publishBackgroundEvent(BackgroundTaskEventTypes.STARTED, startedPayload, parentSessionId, triggerEventId, replyChannelSnapshot);
1225
1228
  this.executeTask(taskIdGen, prompt, timeout, parentSessionId).catch((err) => {
@@ -1403,7 +1406,9 @@ class BackgroundTaskManager {
1403
1406
  parentSessionId,
1404
1407
  description: task.description,
1405
1408
  status: task.status,
1406
- associatedTaskId: task.associatedTaskId
1409
+ associatedTaskId: task.associatedTaskId,
1410
+ startedAt: task.createdAt,
1411
+ timeoutMs: task.timeoutMs
1407
1412
  };
1408
1413
  this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId, task.triggerEventId, task.replyChannel);
1409
1414
  }, PROGRESS_INTERVAL);
@@ -27,7 +27,7 @@ import {
27
27
  BackgroundTaskManager,
28
28
  createDelegateTool,
29
29
  createStopTool
30
- } from "./roy-agent-core-1sfbs57v.js";
30
+ } from "./roy-agent-core-6bradb0j.js";
31
31
  import {
32
32
  SQLiteTaskStore,
33
33
  getDefaultTaskDbPath
@@ -1402,7 +1402,9 @@ function spawnLarkReply(options) {
1402
1402
  "--chat-id",
1403
1403
  chatId,
1404
1404
  "--markdown",
1405
- normalizedContent
1405
+ normalizedContent,
1406
+ "--as",
1407
+ "bot"
1406
1408
  ];
1407
1409
  } else {
1408
1410
  finish(new Error("No target specified for failure reply"));
@@ -2501,7 +2503,6 @@ class LarkCliInstance {
2501
2503
  chatId: replyChannel.chatId,
2502
2504
  userId: replyChannel.params?.userId,
2503
2505
  content: text,
2504
- as: "bot",
2505
2506
  profile
2506
2507
  });
2507
2508
  },
@@ -2510,7 +2511,6 @@ class LarkCliInstance {
2510
2511
  chatId: replyChannel.chatId,
2511
2512
  userId: replyChannel.params?.userId,
2512
2513
  content: markdown,
2513
- as: "bot",
2514
2514
  format: "markdown",
2515
2515
  profile
2516
2516
  });
@@ -2520,7 +2520,6 @@ class LarkCliInstance {
2520
2520
  chatId: replyChannel.chatId,
2521
2521
  userId: replyChannel.params?.userId,
2522
2522
  content: JSON.stringify(content),
2523
- as: "bot",
2524
2523
  profile
2525
2524
  });
2526
2525
  },
@@ -2529,7 +2528,6 @@ class LarkCliInstance {
2529
2528
  await this.sendLarkMessage({
2530
2529
  messageId: replyChannel.messageId,
2531
2530
  content: JSON.stringify(content),
2532
- as: "bot",
2533
2531
  profile
2534
2532
  });
2535
2533
  }
@@ -2538,16 +2536,16 @@ class LarkCliInstance {
2538
2536
  }
2539
2537
  async sendLarkMessage(options) {
2540
2538
  return new Promise((resolve, reject) => {
2541
- const { chatId, userId, messageId, content, as: identity, format = "text", profile } = options;
2539
+ const { chatId, userId, messageId, content, format = "text", profile } = options;
2542
2540
  const normalizedContent = normalizeLarkAtMentions(content);
2543
2541
  const contentFlag = format === "markdown" ? "--markdown" : "--text";
2544
2542
  const args = ["im"];
2545
2543
  if (messageId) {
2546
- args.push("+messages-reply", "--message-id", messageId, "--as", identity, contentFlag, normalizedContent);
2544
+ args.push("+messages-reply", "--message-id", messageId, "--as", "bot", contentFlag, normalizedContent);
2547
2545
  } else if (chatId) {
2548
- args.push("+messages-send", "--chat-id", chatId, "--as", identity, contentFlag, normalizedContent);
2546
+ args.push("+messages-send", "--chat-id", chatId, "--as", "bot", contentFlag, normalizedContent);
2549
2547
  } else if (userId) {
2550
- args.push("+messages-send", "--user-id", userId, "--as", identity, contentFlag, normalizedContent);
2548
+ args.push("+messages-send", "--user-id", userId, "--as", "bot", contentFlag, normalizedContent);
2551
2549
  } else {
2552
2550
  reject(new Error("No target specified for sending message"));
2553
2551
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.7.57",
3
+ "version": "1.7.58",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",