@ai-setting/roy-agent-core 1.7.85 → 1.7.88

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 (135) hide show
  1. package/dist/config/index.js +7 -7
  2. package/dist/env/agent/agent-component.d.ts +1 -1
  3. package/dist/env/agent/agent-component.js +13 -12
  4. package/dist/env/agent/index.js +13 -12
  5. package/dist/env/agent/types.d.ts +14 -0
  6. package/dist/env/commands/index.js +7 -7
  7. package/dist/env/context/index.js +3 -3
  8. package/dist/env/debug/index.js +7 -7
  9. package/dist/env/error-reply.js +1 -1
  10. package/dist/env/event-source/event-source-handlers.d.ts +18 -2
  11. package/dist/env/event-source/event-source-handlers.js +26 -21
  12. package/dist/env/event-source/event-store.js +2 -2
  13. package/dist/env/event-source/index.js +25 -22
  14. package/dist/env/event-source/timer-handler.d.ts +98 -0
  15. package/dist/env/event-source/types.d.ts +53 -1
  16. package/dist/env/event-source/wecom-card-action-handler.d.ts +235 -3
  17. package/dist/env/event-source/wecom-card-builder.d.ts +207 -1
  18. package/dist/env/event-source/wecom-cli-handler.d.ts +25 -0
  19. package/dist/{shared/@ai-setting/roy-agent-core-vyr6svt6.js → env/event-source/wecom-respond-registry.js} +8 -6
  20. package/dist/env/event-source/wecom-session-card-sender.d.ts +135 -0
  21. package/dist/env/event-source/wecom-session-card-sender.js +153 -0
  22. package/dist/env/hook/index.js +5 -5
  23. package/dist/env/index.js +49 -45
  24. package/dist/env/llm/index.js +9 -8
  25. package/dist/env/log-trace/index.js +7 -7
  26. package/dist/env/log-trace/trace-filters.d.ts +6 -1
  27. package/dist/env/mcp/index.js +7 -7
  28. package/dist/env/memory/index.js +7 -7
  29. package/dist/env/plugin/index.js +7 -7
  30. package/dist/env/prompt/index.js +8 -8
  31. package/dist/env/prompt/prompts-index.d.ts +1 -1
  32. package/dist/env/session/group-session-link.d.ts +99 -0
  33. package/dist/env/session/index.js +11 -10
  34. package/dist/env/session/session-component.d.ts +89 -0
  35. package/dist/env/session/storage/index.js +5 -4
  36. package/dist/env/session/types.d.ts +10 -0
  37. package/dist/env/skill/index.js +7 -7
  38. package/dist/env/task/delegate/delegate-channel-hint.d.ts +39 -0
  39. package/dist/env/task/delegate/delegate-tool.d.ts +71 -6
  40. package/dist/env/task/delegate/delegate-tool.js +11 -9
  41. package/dist/env/task/delegate/index.js +8 -8
  42. package/dist/env/task/index.js +18 -18
  43. package/dist/env/task/mcp/index.js +4 -4
  44. package/dist/env/task/plugins/card-subject.d.ts +117 -0
  45. package/dist/env/task/plugins/index.js +19 -17
  46. package/dist/env/task/plugins/lark-card-action-handler.d.ts +261 -6
  47. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +501 -0
  48. package/dist/env/task/plugins/lark-card-patch-notifier.js +12 -2
  49. package/dist/env/task/plugins/lark-card-state-store.d.ts +60 -0
  50. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +45 -0
  51. package/dist/env/task/plugins/sub-session-activity.d.ts +415 -0
  52. package/dist/env/task/plugins/wecom-session-card-store.d.ts +134 -0
  53. package/dist/env/task/plugins/wecom-session-card-store.js +23 -0
  54. package/dist/env/task/plugins/wecom-task-notify-plugin.d.ts +40 -0
  55. package/dist/env/task/storage/index.js +3 -3
  56. package/dist/env/task/tools/index.js +4 -4
  57. package/dist/env/tool/built-in/index.js +6 -4
  58. package/dist/env/tool/index.js +14 -10
  59. package/dist/env/tool/types.d.ts +25 -0
  60. package/dist/env/tool/validator.d.ts +8 -0
  61. package/dist/env/workflow/engine/index.js +12 -12
  62. package/dist/env/workflow/hooks/index.js +7 -7
  63. package/dist/env/workflow/index.js +24 -23
  64. package/dist/env/workflow/nodes/index.js +2 -2
  65. package/dist/env/workflow/plugins/index.js +10 -8
  66. package/dist/env/workflow/service/index.js +2 -2
  67. package/dist/env/workflow/storage/index.js +3 -3
  68. package/dist/env/workflow/tools/index.js +16 -15
  69. package/dist/env/workflow/utils/index.js +4 -4
  70. package/dist/index.js +65 -60
  71. package/dist/shared/@ai-setting/{roy-agent-core-dc9zq75z.js → roy-agent-core-0crmsc12.js} +3 -3
  72. package/dist/shared/@ai-setting/{roy-agent-core-cha0jc7n.js → roy-agent-core-0sbmdz8d.js} +137 -16
  73. package/dist/shared/@ai-setting/{roy-agent-core-87942bw4.js → roy-agent-core-1mhyh4c5.js} +1 -1
  74. package/dist/shared/@ai-setting/{roy-agent-core-v6vr6za7.js → roy-agent-core-1vv4fx15.js} +4 -4
  75. package/dist/shared/@ai-setting/{roy-agent-core-nwbfepba.js → roy-agent-core-3e040tc5.js} +1 -1
  76. package/dist/shared/@ai-setting/roy-agent-core-418zc9ha.js +288 -0
  77. package/dist/shared/@ai-setting/{roy-agent-core-r5wt1h3c.js → roy-agent-core-4fkxy2gv.js} +1 -1
  78. package/dist/shared/@ai-setting/{roy-agent-core-na18zwj0.js → roy-agent-core-4t3yskp8.js} +1 -1
  79. package/dist/shared/@ai-setting/{roy-agent-core-5pr4zp88.js → roy-agent-core-5kzhaap1.js} +1 -1
  80. package/dist/shared/@ai-setting/{roy-agent-core-qq96p0tj.js → roy-agent-core-5s2t8z00.js} +22 -1
  81. package/dist/shared/@ai-setting/{roy-agent-core-6rh8k6ba.js → roy-agent-core-6gj1hc5z.js} +7 -7
  82. package/dist/shared/@ai-setting/{roy-agent-core-ezvpreqz.js → roy-agent-core-6k8mb7zx.js} +1 -1
  83. package/dist/shared/@ai-setting/{roy-agent-core-g8htfwxj.js → roy-agent-core-7f10p7m2.js} +1 -1
  84. package/dist/shared/@ai-setting/roy-agent-core-7kvpc0w5.js +177 -0
  85. package/dist/shared/@ai-setting/{roy-agent-core-h21gngxf.js → roy-agent-core-7yh5wps0.js} +1 -1
  86. package/dist/shared/@ai-setting/{roy-agent-core-efkjyh69.js → roy-agent-core-9710zwwz.js} +1 -1
  87. package/dist/shared/@ai-setting/{roy-agent-core-rykf7c04.js → roy-agent-core-9c565frx.js} +1 -1
  88. package/dist/shared/@ai-setting/{roy-agent-core-fghc2m8z.js → roy-agent-core-aa8kv18f.js} +34 -2
  89. package/dist/shared/@ai-setting/{roy-agent-core-p6ks90tb.js → roy-agent-core-an35dzbf.js} +6 -6
  90. package/dist/shared/@ai-setting/{roy-agent-core-7bpj859q.js → roy-agent-core-azyz78ky.js} +7 -7
  91. package/dist/shared/@ai-setting/{roy-agent-core-264qexac.js → roy-agent-core-b7h39vrc.js} +4 -4
  92. package/dist/shared/@ai-setting/{roy-agent-core-dqxec05w.js → roy-agent-core-bjtc9d35.js} +2 -2
  93. package/dist/shared/@ai-setting/roy-agent-core-c4ec7k0p.js +426 -0
  94. package/dist/shared/@ai-setting/{roy-agent-core-ddyk1rc0.js → roy-agent-core-cre2y2ct.js} +160 -4
  95. package/dist/shared/@ai-setting/{roy-agent-core-tr3ep81v.js → roy-agent-core-d6zdbgtc.js} +1 -1
  96. package/dist/shared/@ai-setting/{roy-agent-core-0qyrk5k0.js → roy-agent-core-ds6qzmf8.js} +14 -5
  97. package/dist/shared/@ai-setting/{roy-agent-core-cgtq6427.js → roy-agent-core-e08bvpaq.js} +1 -1
  98. package/dist/shared/@ai-setting/{roy-agent-core-12n08pg5.js → roy-agent-core-e69qxdyy.js} +1 -1
  99. package/dist/shared/@ai-setting/{roy-agent-core-qk9hd89p.js → roy-agent-core-fan8g0z1.js} +10 -10
  100. package/dist/shared/@ai-setting/{roy-agent-core-xcp8vwax.js → roy-agent-core-fepm835e.js} +2 -2
  101. package/dist/shared/@ai-setting/{roy-agent-core-6j02sbee.js → roy-agent-core-fhg03v43.js} +1 -1
  102. package/dist/shared/@ai-setting/{roy-agent-core-dvtg4sn0.js → roy-agent-core-g8yr733d.js} +1 -1
  103. package/dist/shared/@ai-setting/{roy-agent-core-xf6z96qy.js → roy-agent-core-gr5h1dyr.js} +818 -346
  104. package/dist/shared/@ai-setting/{roy-agent-core-m3vjepzz.js → roy-agent-core-h1e1fm9b.js} +38 -202
  105. package/dist/shared/@ai-setting/{roy-agent-core-c2gbt68e.js → roy-agent-core-h83zdsrq.js} +2 -2
  106. package/dist/shared/@ai-setting/{roy-agent-core-tk98f92b.js → roy-agent-core-k3gcvybs.js} +2 -2
  107. package/dist/shared/@ai-setting/{roy-agent-core-pgvcf91v.js → roy-agent-core-m39v7qpx.js} +2 -2
  108. package/dist/shared/@ai-setting/{roy-agent-core-tm1mxttk.js → roy-agent-core-mf5p38yf.js} +2 -2
  109. package/dist/shared/@ai-setting/{roy-agent-core-83bewqx8.js → roy-agent-core-mvh0td7p.js} +2 -2
  110. package/dist/shared/@ai-setting/{roy-agent-core-ze5cqpf2.js → roy-agent-core-mx855td4.js} +17 -38
  111. package/dist/shared/@ai-setting/{roy-agent-core-0dh8npnz.js → roy-agent-core-n197medr.js} +13 -13
  112. package/dist/shared/@ai-setting/{roy-agent-core-cmprygrp.js → roy-agent-core-nqkfkpf4.js} +4 -4
  113. package/dist/shared/@ai-setting/{roy-agent-core-7cbpmk4q.js → roy-agent-core-p31ftgq9.js} +1 -1
  114. package/dist/shared/@ai-setting/{roy-agent-core-vffccgf6.js → roy-agent-core-qwd2dq5q.js} +10 -3
  115. package/dist/shared/@ai-setting/{roy-agent-core-b31v3qpv.js → roy-agent-core-ra66sf50.js} +990 -211
  116. package/dist/shared/@ai-setting/{roy-agent-core-1v4g0d4x.js → roy-agent-core-rm7seqwb.js} +1 -1
  117. package/dist/shared/@ai-setting/{roy-agent-core-7dd0s3xb.js → roy-agent-core-shb1qsyg.js} +1027 -14
  118. package/dist/shared/@ai-setting/{roy-agent-core-ax9e9szb.js → roy-agent-core-smf94h73.js} +1 -1
  119. package/dist/shared/@ai-setting/{roy-agent-core-acj8ag08.js → roy-agent-core-tjnabyvq.js} +1 -1
  120. package/dist/shared/@ai-setting/{roy-agent-core-qqaak24r.js → roy-agent-core-tkpp1ba0.js} +1 -1
  121. package/dist/shared/@ai-setting/{roy-agent-core-dkrvmjsh.js → roy-agent-core-tpm1dd1g.js} +23 -15
  122. package/dist/shared/@ai-setting/{roy-agent-core-ed233k5z.js → roy-agent-core-v1n0106v.js} +1 -1
  123. package/dist/shared/@ai-setting/{roy-agent-core-zxz5fkwj.js → roy-agent-core-v6yshv0z.js} +1 -1
  124. package/dist/shared/@ai-setting/{roy-agent-core-mcy5apay.js → roy-agent-core-vf9sp6s3.js} +1 -1
  125. package/dist/shared/@ai-setting/{roy-agent-core-q813vafd.js → roy-agent-core-vpcxv1ty.js} +1 -1
  126. package/dist/shared/@ai-setting/{roy-agent-core-xvt7kf7p.js → roy-agent-core-w9ryeg2p.js} +3 -3
  127. package/dist/shared/@ai-setting/{roy-agent-core-es203w7p.js → roy-agent-core-wqs6yypq.js} +1 -1
  128. package/dist/shared/@ai-setting/{roy-agent-core-d1n4jbza.js → roy-agent-core-wr1qexzq.js} +5 -5
  129. package/dist/shared/@ai-setting/roy-agent-core-wxrkcb17.js +56 -0
  130. package/dist/shared/@ai-setting/{roy-agent-core-0snm5hc5.js → roy-agent-core-y6shd91r.js} +1 -1
  131. package/dist/shared/@ai-setting/{roy-agent-core-9vxh6f8h.js → roy-agent-core-y7fqtzk2.js} +7 -7
  132. package/dist/shared/@ai-setting/{roy-agent-core-cpcd24n2.js → roy-agent-core-yet36q5k.js} +2 -2
  133. package/dist/shared/@ai-setting/{roy-agent-core-3fh1f7s7.js → roy-agent-core-yfpnkc4z.js} +5 -5
  134. package/dist/shared/@ai-setting/{roy-agent-core-begm7ytz.js → roy-agent-core-yh68z1bg.js} +3 -3
  135. package/package.json +9 -1
@@ -1,7 +1,10 @@
1
+ import {
2
+ buildWecomSendCardFrame
3
+ } from "./roy-agent-core-c4ec7k0p.js";
1
4
  import {
2
5
  getEnvContextOrEmpty,
3
6
  init_env_context
4
- } from "./roy-agent-core-7cbpmk4q.js";
7
+ } from "./roy-agent-core-p31ftgq9.js";
5
8
 
6
9
  // src/env/event-source/wecom-respond-registry.ts
7
10
  init_env_context();
@@ -142,205 +145,6 @@ async function sendWecomCliMarkdown(input) {
142
145
  return { ok: false, error: `${detail} (exit=${code ?? "null"})` };
143
146
  }
144
147
 
145
- // src/env/event-source/wecom-card-builder.ts
146
- var WecomCardActionKey = {
147
- VIEW: "task_view",
148
- MARK_DONE: "task_mark_done",
149
- REOPEN: "task_reopen"
150
- };
151
- function wecomCardTaskIdForTask(taskId) {
152
- return `roy-task-${taskId}`;
153
- }
154
- var cardSeq = 0;
155
- function newWecomCardTaskId(taskId) {
156
- cardSeq = (cardSeq + 1) % 1e6;
157
- const rand = Math.random().toString(36).slice(2, 8);
158
- return `${wecomCardTaskIdForTask(taskId)}-${cardSeq}-${rand}`;
159
- }
160
- function formatTs(iso) {
161
- try {
162
- const d = new Date(iso);
163
- if (isNaN(d.getTime()))
164
- return iso;
165
- const pad = (n) => String(n).padStart(2, "0");
166
- return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ` + `${pad(d.getHours())}:${pad(d.getMinutes())}`;
167
- } catch {
168
- return iso;
169
- }
170
- }
171
- function clip(text, max) {
172
- if (!text)
173
- return "";
174
- const t = text.trim();
175
- return t.length > max ? `${t.slice(0, max)}…` : t;
176
- }
177
- function shortMilestoneValue(text) {
178
- if (!text)
179
- return "";
180
- const t = text.trim();
181
- const colonIdx = t.indexOf(":");
182
- const head = colonIdx > 0 && colonIdx <= 20 ? t.slice(0, colonIdx).trim() : t;
183
- if (head.length <= MAX_HORIZONTAL_VALUE)
184
- return head;
185
- return clipWord(head, MAX_HORIZONTAL_VALUE);
186
- }
187
- function clipWord(text, max) {
188
- if (!text)
189
- return "";
190
- const t = text.trim();
191
- if (t.length <= max)
192
- return t;
193
- let cut = t.slice(0, max - 1);
194
- const lastSpace = cut.lastIndexOf(" ");
195
- if (lastSpace > max * 0.4)
196
- return `${cut.slice(0, lastSpace).trimEnd()}…`;
197
- const cjkBoundary = findCjkAsciiBoundary(cut);
198
- if (cjkBoundary > max * 0.4)
199
- return `${cut.slice(0, cjkBoundary).trimEnd()}…`;
200
- return cut.slice(0, max - 1);
201
- }
202
- function findCjkAsciiBoundary(text) {
203
- const isCjk = (ch) => /[一-鿿぀-ヿ가-힯]/.test(ch);
204
- const isAsciiAlnum = (ch) => /[A-Za-z0-9]/.test(ch);
205
- for (let i = text.length - 1;i > 0; i--) {
206
- const prev = text[i - 1];
207
- const cur = text[i];
208
- if (isCjk(prev) !== isAsciiAlnum(cur) && isCjk(cur) !== isAsciiAlnum(prev)) {
209
- if (isCjk(prev) && isAsciiAlnum(cur) || isAsciiAlnum(prev) && isCjk(cur)) {
210
- return i;
211
- }
212
- }
213
- }
214
- return -1;
215
- }
216
- var MAX_TIMELINE_LINES = 8;
217
- var MAX_HORIZONTAL_ROWS = 6;
218
- var MAX_HORIZONTAL_VALUE = 26;
219
- function buildWecomTextNoticeCard(input) {
220
- const progressPct = `${Math.max(0, Math.min(100, Math.round(input.progress ?? 0)))}%`;
221
- const sorted = [...input.milestones].slice(-MAX_TIMELINE_LINES).reverse();
222
- const timelineRows = sorted.slice(0, MAX_HORIZONTAL_ROWS - 1).map((m) => ({
223
- keyname: formatTs(m.timestamp).slice(11),
224
- value: shortMilestoneValue(m.title)
225
- }));
226
- const horizontal = [
227
- { keyname: "状态", value: clip(input.statusLabel, MAX_HORIZONTAL_VALUE) },
228
- ...timelineRows
229
- ];
230
- const latest = sorted[0];
231
- const quoteLine = latest ? `${formatTs(latest.timestamp)} — ${clipWord(latest.title, 80)}${latest.description ? `:${clipWord(latest.description, 80)}` : ""}` : "";
232
- const latestSummary = latest && latest.title ? `${formatTs(latest.timestamp)} ${clip(latest.title, 140)}` : undefined;
233
- const subTitle = input.terminal ? `任务${input.statusLabel.replace(/^[^\u4e00-\u9fa5A-Za-z]*/, "")} · 详见会话` : latestSummary;
234
- return {
235
- card_type: "text_notice",
236
- main_title: {
237
- title: `\uD83D\uDCCB Task #${input.taskId} · ${clip(input.title, 60)}`,
238
- desc: clip(input.description, 80) || undefined
239
- },
240
- emphasis_content: {
241
- title: progressPct,
242
- desc: "进度"
243
- },
244
- sub_title_text: subTitle,
245
- horizontal_content_list: horizontal,
246
- quote_area: {
247
- type: 0,
248
- title: "最新进展",
249
- quote_text: quoteLine || "(暂无操作记录)"
250
- },
251
- card_action: { type: 0 }
252
- };
253
- }
254
- var MAX_BUTTONS = 6;
255
- var MAX_BUTTON_TEXT = 10;
256
- function buildWecomButtonInteractionCard(input) {
257
- const notice = buildWecomTextNoticeCard({
258
- taskId: input.taskId,
259
- title: input.title,
260
- statusLabel: input.statusLabel,
261
- progress: input.progress,
262
- description: input.description,
263
- changeSummary: input.changeSummary,
264
- milestones: input.milestones ?? []
265
- });
266
- const buttons = (input.buttons ?? []).slice(0, MAX_BUTTONS).map((b) => ({
267
- text: clip(b.text, MAX_BUTTON_TEXT),
268
- style: b.style ?? 1,
269
- key: b.key
270
- }));
271
- return {
272
- card_type: "button_interaction",
273
- main_title: notice.main_title,
274
- sub_title_text: notice.sub_title_text,
275
- horizontal_content_list: notice.horizontal_content_list,
276
- quote_area: notice.quote_area,
277
- button_list: buttons,
278
- card_action: { type: 0 },
279
- task_id: input.cardTaskId ?? newWecomCardTaskId(input.taskId)
280
- };
281
- }
282
- function buildWecomSendCardFrame(input) {
283
- const reqId = input.reqId && input.reqId.trim() ? input.reqId.trim() : `aibot_send_msg_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
284
- return {
285
- cmd: "aibot_send_msg",
286
- headers: { req_id: reqId },
287
- body: {
288
- chatid: input.chatId,
289
- chat_type: input.chatType === "group" ? 2 : 1,
290
- msgtype: "template_card",
291
- template_card: input.card
292
- }
293
- };
294
- }
295
- var MAX_UPDATE_TITLE = 60;
296
- function buildUpdateMainTitle(statusLabel, taskNumber, taskTitle) {
297
- const segments = [];
298
- if (taskNumber !== undefined && Number.isFinite(taskNumber)) {
299
- segments.push(`Task #${taskNumber}`);
300
- }
301
- if (taskTitle) {
302
- segments.push(clip(taskTitle, MAX_UPDATE_TITLE));
303
- }
304
- segments.push(statusLabel);
305
- return segments.length > 1 ? `\uD83D\uDCCB ${segments.join(" · ")}` : `\uD83D\uDCCB ${statusLabel}`;
306
- }
307
- function buildWecomCardUpdateFrame(input) {
308
- const reqId = (input.reqId ?? "").trim();
309
- if (!reqId) {
310
- throw new Error("buildWecomCardUpdateFrame: req_id is required " + "(update must reference the template_card_event frame)");
311
- }
312
- const buttons = (input.buttonOverrides ?? []).slice(0, MAX_BUTTONS).map((b) => ({
313
- text: clip(b.text, MAX_BUTTON_TEXT),
314
- style: b.style ?? 1,
315
- key: b.key
316
- }));
317
- const sorted = [...input.timeline ?? []].reverse();
318
- const timelineRows = sorted.slice(0, MAX_HORIZONTAL_ROWS).map((m) => ({
319
- keyname: formatTs(m.timestamp).slice(11),
320
- value: shortMilestoneValue(m.title)
321
- }));
322
- const total = sorted.length;
323
- const subTitle = total > 0 ? total > MAX_HORIZONTAL_ROWS ? `共 ${total} 条操作记录,显示最近 ${MAX_HORIZONTAL_ROWS} 条(最新在顶部)` : `共 ${total} 条操作记录(最新在顶部)` : undefined;
324
- return {
325
- cmd: "aibot_respond_update_msg",
326
- headers: { req_id: reqId },
327
- body: {
328
- response_type: "update_template_card",
329
- template_card: {
330
- card_type: "button_interaction",
331
- main_title: {
332
- title: buildUpdateMainTitle(input.statusLabel, input.taskNumber, input.taskTitle),
333
- desc: input.note ? clip(input.note, 80) : undefined
334
- },
335
- sub_title_text: subTitle,
336
- horizontal_content_list: timelineRows,
337
- button_list: buttons,
338
- task_id: String(input.taskId)
339
- }
340
- }
341
- };
342
- }
343
-
344
148
  // src/env/event-source/wecom-respond-registry.ts
345
149
  var registry = new Map;
346
150
  function registerWecomRespondTarget(sourceId, target) {
@@ -437,7 +241,8 @@ var wecomRespondTool = {
437
241
  metadata: {
438
242
  category: "messaging",
439
243
  tags: ["wecom", "reply", "im"],
440
- version: "2.0.0"
244
+ version: "2.0.0",
245
+ channelOnly: true
441
246
  },
442
247
  execute: async (args, _ctx) => {
443
248
  const { content } = args;
@@ -454,6 +259,37 @@ var wecomRespondTool = {
454
259
  const rid = meta?.reqId;
455
260
  if (typeof rid === "string" && rid.length > 0)
456
261
  eventReqId = rid;
262
+ if (!eventChatId) {
263
+ const rcChatId = ctx.replyChannel?.chatId;
264
+ if (typeof rcChatId === "string" && rcChatId.length > 0) {
265
+ eventChatId = rcChatId;
266
+ }
267
+ }
268
+ const rc = meta?.replyChannel;
269
+ if (!eventChatId && typeof rc?.chatId === "string" && rc.chatId) {
270
+ eventChatId = rc.chatId;
271
+ }
272
+ const rcParamsList = [
273
+ rc?.params,
274
+ ctx.replyChannel?.params
275
+ ];
276
+ for (const rcParams of rcParamsList) {
277
+ if (!rcParams)
278
+ continue;
279
+ if (!eventReqId) {
280
+ const prid = rcParams.reqId;
281
+ if (typeof prid === "string" && prid.length > 0)
282
+ eventReqId = prid;
283
+ }
284
+ if (!sourceId) {
285
+ const psid = rcParams.sourceId;
286
+ if (typeof psid === "string" && psid.length > 0)
287
+ sourceId = psid;
288
+ }
289
+ }
290
+ if (!sourceId && typeof ctx?.sourceId === "string" && ctx.sourceId) {
291
+ sourceId = ctx.sourceId;
292
+ }
457
293
  } catch {}
458
294
  const chatId = args.chat_id?.trim() || eventChatId;
459
295
  const reqId = args.req_id?.trim() || eventReqId;
@@ -541,4 +377,4 @@ async function autoReplyWecomTurn(envEvent, finalText) {
541
377
  return { skipped: false, ok: r.ok, channel: r.channel, error: r.error };
542
378
  }
543
379
 
544
- export { WecomCardActionKey, buildWecomTextNoticeCard, buildWecomButtonInteractionCard, buildWecomCardUpdateFrame, registerWecomRespondTarget, unregisterWecomRespondTarget, getWecomRespondTarget, __resetWecomRespondRegistryForTest, sendWecomReply, sendWecomTemplateCard, wecomRespondTool, markWecomReplySent, wasWecomReplySent, __resetWecomReplySentForTest, autoReplyWecomTurn };
380
+ export { sendWecomCliMarkdown, registerWecomRespondTarget, unregisterWecomRespondTarget, getWecomRespondTarget, __resetWecomRespondRegistryForTest, sendWecomReply, sendWecomTemplateCard, wecomRespondTool, markWecomReplySent, wasWecomReplySent, __resetWecomReplySentForTest, autoReplyWecomTurn };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  init_hook
3
- } from "./roy-agent-core-ax9e9szb.js";
3
+ } from "./roy-agent-core-smf94h73.js";
4
4
  import {
5
5
  globalHookManager
6
- } from "./roy-agent-core-cpcd24n2.js";
6
+ } from "./roy-agent-core-yet36q5k.js";
7
7
  import {
8
8
  __esm
9
9
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -11,14 +11,14 @@ import {
11
11
  } from "./roy-agent-core-fttgm52a.js";
12
12
  import {
13
13
  wecomRespondTool
14
- } from "./roy-agent-core-m3vjepzz.js";
14
+ } from "./roy-agent-core-h1e1fm9b.js";
15
15
  import {
16
16
  init_decorator,
17
17
  init_trace_filters,
18
18
  toolExecResultFilter,
19
19
  toolInvokeParamFilter,
20
20
  wrapFunction
21
- } from "./roy-agent-core-qq96p0tj.js";
21
+ } from "./roy-agent-core-5s2t8z00.js";
22
22
  import {
23
23
  createLogger,
24
24
  exports_tracer_provider,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createHook,
3
3
  init_hook
4
- } from "./roy-agent-core-ax9e9szb.js";
4
+ } from "./roy-agent-core-smf94h73.js";
5
5
  import {
6
6
  HookManager
7
- } from "./roy-agent-core-cpcd24n2.js";
7
+ } from "./roy-agent-core-yet36q5k.js";
8
8
 
9
9
  // src/env/component.ts
10
10
  init_hook();
@@ -3,11 +3,11 @@ import {
3
3
  } from "./roy-agent-core-7hh0brvs.js";
4
4
  import {
5
5
  BaseComponent
6
- } from "./roy-agent-core-pgvcf91v.js";
6
+ } from "./roy-agent-core-m39v7qpx.js";
7
7
  import {
8
8
  init_decorator,
9
9
  init_trace_filters
10
- } from "./roy-agent-core-qq96p0tj.js";
10
+ } from "./roy-agent-core-5s2t8z00.js";
11
11
  import {
12
12
  createLogger,
13
13
  getTracerProvider,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TagRepository
3
- } from "./roy-agent-core-mcy5apay.js";
4
- import"./roy-agent-core-qq96p0tj.js";
3
+ } from "./roy-agent-core-vf9sp6s3.js";
4
+ import"./roy-agent-core-5s2t8z00.js";
5
5
  import"./roy-agent-core-7f7t9wwp.js";
6
6
  import"./roy-agent-core-85xyctnb.js";
7
7
  import"./roy-agent-core-fs0mn2jk.js";
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  TempFileManager
3
3
  } from "./roy-agent-core-jvv2h3d6.js";
4
+ import {
5
+ ToolValidator,
6
+ setToolReasonConfigComponent
7
+ } from "./roy-agent-core-wxrkcb17.js";
4
8
  import {
5
9
  AskUserError,
6
10
  init_workflow_hil
@@ -11,23 +15,23 @@ import {
11
15
  } from "./roy-agent-core-7hh0brvs.js";
12
16
  import {
13
17
  BaseComponent
14
- } from "./roy-agent-core-pgvcf91v.js";
18
+ } from "./roy-agent-core-m39v7qpx.js";
15
19
  import {
16
20
  ToolHookPoints,
17
21
  globalHookManager,
18
22
  init_global_hook_manager
19
- } from "./roy-agent-core-cpcd24n2.js";
23
+ } from "./roy-agent-core-yet36q5k.js";
20
24
  import {
21
25
  getCurrentTaskId,
22
26
  init_env_context
23
- } from "./roy-agent-core-7cbpmk4q.js";
27
+ } from "./roy-agent-core-p31ftgq9.js";
24
28
  import {
25
29
  TracedAs,
26
30
  init_decorator,
27
31
  init_trace_filters,
28
32
  toolExecResultFilter,
29
33
  toolInvokeParamFilter
30
- } from "./roy-agent-core-qq96p0tj.js";
34
+ } from "./roy-agent-core-5s2t8z00.js";
31
35
  import {
32
36
  createLogger,
33
37
  init_logger
@@ -131,36 +135,6 @@ class ToolRegistry {
131
135
  }
132
136
  }
133
137
 
134
- // src/env/tool/validator.ts
135
- import { ZodError } from "zod";
136
-
137
- class ToolValidator {
138
- async validate(tool, args) {
139
- try {
140
- const parsed = await tool.parameters.parseAsync(args);
141
- return {
142
- success: true,
143
- data: parsed
144
- };
145
- } catch (error) {
146
- if (error instanceof ZodError) {
147
- const errorMessage = tool.formatValidationError ? tool.formatValidationError(error) : this.formatError(error);
148
- return {
149
- success: false,
150
- error: `Invalid arguments for tool '${tool.name}': ${errorMessage}`
151
- };
152
- }
153
- return {
154
- success: false,
155
- error: `Validation error: ${error}`
156
- };
157
- }
158
- }
159
- formatError(error) {
160
- return error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join("; ");
161
- }
162
- }
163
-
164
138
  // src/env/constants.ts
165
139
  var TOOL_UNAVAILABLE_ERROR_RE = /^Tool (?:not found|disabled):/;
166
140
  function isToolUnavailableError(message) {
@@ -183,7 +157,8 @@ var TOOL_DEFAULTS = {
183
157
  "tool.sandbox.type": "native",
184
158
  "tool.execution.timeout": 30000,
185
159
  "tool.execution.maxConcurrency": 5,
186
- "tool.execution.maxOutputSize": 5120
160
+ "tool.execution.maxOutputSize": 5120,
161
+ "tool.reason.required": true
187
162
  };
188
163
  var TOOL_CONFIG_REGISTRATION = {
189
164
  name: "tool",
@@ -198,7 +173,8 @@ var TOOL_CONFIG_REGISTRATION = {
198
173
  { key: "tool.sandbox.type", sources: ["env", "file"] },
199
174
  { key: "tool.execution.timeout", sources: ["env", "file"] },
200
175
  { key: "tool.execution.maxConcurrency", sources: ["env", "file"] },
201
- { key: "tool.execution.maxOutputSize", sources: ["env", "file"] }
176
+ { key: "tool.execution.maxOutputSize", sources: ["env", "file"] },
177
+ { key: "tool.reason.required", sources: ["env", "file"] }
202
178
  ]
203
179
  };
204
180
 
@@ -307,6 +283,7 @@ class ToolComponent extends BaseComponent {
307
283
  }
308
284
  this.configComponent = options.configComponent;
309
285
  setToolConfigComponent(options.configComponent);
286
+ setToolReasonConfigComponent(options.configComponent);
310
287
  await this.registerConfig(options);
311
288
  if (this.config?.builtInTools?.enabled !== false) {
312
289
  await this.loadBuiltInTools();
@@ -338,7 +315,8 @@ class ToolComponent extends BaseComponent {
338
315
  "tool.sandbox.type",
339
316
  "tool.sandbox.defaultConfig",
340
317
  "tool.execution.timeout",
341
- "tool.execution.maxConcurrency"
318
+ "tool.execution.maxConcurrency",
319
+ "tool.reason.required"
342
320
  ];
343
321
  for (const key of toolKeys) {
344
322
  const envKey = toEnvKey(key, prefix);
@@ -417,6 +395,7 @@ class ToolComponent extends BaseComponent {
417
395
  async onStop() {
418
396
  this.configWatcher?.();
419
397
  this.configWatcher = undefined;
398
+ setToolReasonConfigComponent(null);
420
399
  this.setStatus("stopped");
421
400
  }
422
401
  register(tool, source = "dynamic") {
@@ -614,4 +593,4 @@ var ToolComponentConfigSchema = z.object({
614
593
  }).default({})
615
594
  });
616
595
 
617
- export { ToolRegistry, ToolValidator, isToolUnavailableError, setToolConfigComponent, getMaxOutputSize, truncateOutputInline, ToolComponent };
596
+ export { ToolRegistry, isToolUnavailableError, setToolConfigComponent, getMaxOutputSize, truncateOutputInline, ToolComponent };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  exports_node_registry_helper,
3
3
  init_node_registry_helper
4
- } from "./roy-agent-core-es203w7p.js";
4
+ } from "./roy-agent-core-wqs6yypq.js";
5
5
  import {
6
6
  askUserTool,
7
7
  createRunWorkflowTool,
@@ -13,18 +13,18 @@ import {
13
13
  createWorkflowSearchTool,
14
14
  createWorkflowTagListTool,
15
15
  createWorkflowValidateTool
16
- } from "./roy-agent-core-7bpj859q.js";
16
+ } from "./roy-agent-core-azyz78ky.js";
17
17
  import {
18
18
  WorkflowService
19
- } from "./roy-agent-core-12n08pg5.js";
19
+ } from "./roy-agent-core-e69qxdyy.js";
20
20
  import {
21
21
  WorkflowEngine,
22
22
  exports_engine,
23
23
  init_engine
24
- } from "./roy-agent-core-6rh8k6ba.js";
24
+ } from "./roy-agent-core-6gj1hc5z.js";
25
25
  import {
26
26
  BaseComponent
27
- } from "./roy-agent-core-pgvcf91v.js";
27
+ } from "./roy-agent-core-m39v7qpx.js";
28
28
  import {
29
29
  createLogger,
30
30
  init_logger
@@ -104,7 +104,7 @@ class WorkflowComponent extends BaseComponent {
104
104
  return;
105
105
  try {
106
106
  const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
107
- const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-xcp8vwax.js");
107
+ const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-fepm835e.js");
108
108
  this.nodeRegistry = new NodeRegistry;
109
109
  registerDecoratorNodeType2(this.nodeRegistry);
110
110
  this.decoratorsRegistered = true;
@@ -134,14 +134,14 @@ class WorkflowComponent extends BaseComponent {
134
134
  }
135
135
  async runWorkflow(definition, input, options) {
136
136
  const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
137
- const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-xcp8vwax.js");
137
+ const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-fepm835e.js");
138
138
  const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
139
139
  const skillComponent = this._workflowEnv?.getComponent("skill");
140
140
  let agentRunner = this.agentRunner;
141
141
  if (!agentRunner && this._workflowEnv) {
142
142
  const agentComponent = this._workflowEnv.getComponent("agent");
143
143
  if (agentComponent) {
144
- const { AgentComponentAdapter } = await import("./roy-agent-core-3fh1f7s7.js");
144
+ const { AgentComponentAdapter } = await import("./roy-agent-core-yfpnkc4z.js");
145
145
  agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
146
146
  }
147
147
  }
@@ -163,7 +163,7 @@ class WorkflowComponent extends BaseComponent {
163
163
  if (this.workflowService) {
164
164
  this.workflowService = null;
165
165
  try {
166
- const { closeDatabase } = await import("./roy-agent-core-dc9zq75z.js");
166
+ const { closeDatabase } = await import("./roy-agent-core-0crmsc12.js");
167
167
  closeDatabase();
168
168
  componentLogger.info("[WorkflowComponent] SQLite database closed");
169
169
  } catch (error) {
@@ -241,9 +241,9 @@ class WorkflowComponent extends BaseComponent {
241
241
  }
242
242
  async initSqliteService() {
243
243
  try {
244
- const { getDatabase, initializeTables } = await import("./roy-agent-core-dc9zq75z.js");
245
- const { WorkflowRepository } = await import("./roy-agent-core-xvt7kf7p.js");
246
- const { TagRepository } = await import("./roy-agent-core-83bewqx8.js");
244
+ const { getDatabase, initializeTables } = await import("./roy-agent-core-0crmsc12.js");
245
+ const { WorkflowRepository } = await import("./roy-agent-core-w9ryeg2p.js");
246
+ const { TagRepository } = await import("./roy-agent-core-mvh0td7p.js");
247
247
  const db = getDatabase();
248
248
  initializeTables();
249
249
  const workflowRepository = new WorkflowRepository(db);
@@ -309,7 +309,7 @@ class WorkflowComponent extends BaseComponent {
309
309
  this.workflowService = null;
310
310
  this.nodeRegistry = null;
311
311
  try {
312
- const { closeDatabase } = await import("./roy-agent-core-dc9zq75z.js");
312
+ const { closeDatabase } = await import("./roy-agent-core-0crmsc12.js");
313
313
  closeDatabase();
314
314
  } catch {}
315
315
  this._status = "stopped";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  builtInPrompts
3
- } from "./roy-agent-core-9vxh6f8h.js";
3
+ } from "./roy-agent-core-y7fqtzk2.js";
4
4
  import {
5
5
  getXDGPath
6
6
  } from "./roy-agent-core-qxnbvgwe.js";
@@ -10,14 +10,14 @@ import {
10
10
  } from "./roy-agent-core-7hh0brvs.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-pgvcf91v.js";
13
+ } from "./roy-agent-core-m39v7qpx.js";
14
14
  import {
15
15
  createHook
16
- } from "./roy-agent-core-ax9e9szb.js";
16
+ } from "./roy-agent-core-smf94h73.js";
17
17
  import {
18
18
  globalHookManager,
19
19
  init_global_hook_manager
20
- } from "./roy-agent-core-cpcd24n2.js";
20
+ } from "./roy-agent-core-yet36q5k.js";
21
21
  import {
22
22
  createLogger,
23
23
  init_logger
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_decorator,
3
3
  wrapFunction
4
- } from "./roy-agent-core-qq96p0tj.js";
4
+ } from "./roy-agent-core-5s2t8z00.js";
5
5
  import {
6
6
  createLogger,
7
7
  init_logger
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  NEW_TASK_ID_HASH_PLACEHOLDER,
3
3
  NEW_TASK_ID_PLACEHOLDER
4
- } from "./roy-agent-core-tr3ep81v.js";
4
+ } from "./roy-agent-core-d6zdbgtc.js";
5
5
  import {
6
6
  TASK_DISCIPLINE_GOALS
7
7
  } from "./roy-agent-core-m46fe3x4.js";
@@ -17,7 +17,7 @@ import {
17
17
  getEnvContextOrEmpty,
18
18
  init_env_context,
19
19
  setCurrentTaskId
20
- } from "./roy-agent-core-7cbpmk4q.js";
20
+ } from "./roy-agent-core-p31ftgq9.js";
21
21
  import {
22
22
  createLogger,
23
23
  init_logger
@@ -138,6 +138,12 @@ import { execSync } from "child_process";
138
138
  init_logger();
139
139
  var logger = createLogger("task-child-context");
140
140
  var STRIPPED_KEYS = ["commit", "token", "secret", "password", "api_key"];
141
+ var ONE_SHOT_HINT_KEYS = [
142
+ "decision_hint",
143
+ "decision_hint_delivered_at",
144
+ "decision_hint_digest",
145
+ "completion_hint"
146
+ ];
141
147
  function stripSensitiveKeys(obj) {
142
148
  if (obj === null || obj === undefined)
143
149
  return obj;
@@ -203,7 +209,8 @@ function inheritChildContext(args) {
203
209
  "parent_branch",
204
210
  "type",
205
211
  "prior_context",
206
- "created_at"
212
+ "created_at",
213
+ ...ONE_SHOT_HINT_KEYS
207
214
  ]);
208
215
  for (const [k, v] of Object.entries(parentCtx)) {
209
216
  if (reserved.has(k))