@ai-setting/roy-agent-core 1.7.72 → 1.7.76

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 (91) hide show
  1. package/dist/env/agent/agent-component.js +6 -6
  2. package/dist/env/agent/agent-registry.d.ts +4 -1
  3. package/dist/env/agent/index.js +6 -6
  4. package/dist/env/error-reply.d.ts +46 -0
  5. package/dist/env/error-reply.js +3 -1
  6. package/dist/env/event-source/event-source-handlers.js +13 -12
  7. package/dist/env/event-source/index.js +14 -13
  8. package/dist/env/index.js +31 -30
  9. package/dist/env/llm/index.js +2 -2
  10. package/dist/env/llm/orphan-toolcall.d.ts +107 -0
  11. package/dist/env/plugin/index.js +3 -3
  12. package/dist/env/prompt/index.js +4 -3
  13. package/dist/env/prompt/prompts-index.d.ts +27 -3
  14. package/dist/env/session/index.js +4 -4
  15. package/dist/env/session/storage/index.js +3 -3
  16. package/dist/env/task/backend/index.js +9 -1
  17. package/dist/env/task/delegate/delegate-tool.d.ts +8 -0
  18. package/dist/env/task/delegate/delegate-tool.js +5 -4
  19. package/dist/env/task/delegate/index.js +5 -4
  20. package/dist/env/task/hooks/contexts.d.ts +12 -1
  21. package/dist/env/task/hooks/task-hook-points.d.ts +8 -3
  22. package/dist/env/task/index.d.ts +1 -0
  23. package/dist/env/task/index.js +17 -7
  24. package/dist/env/task/mcp/index.js +3 -2
  25. package/dist/env/task/plugins/index.d.ts +3 -0
  26. package/dist/env/task/plugins/index.js +33 -9
  27. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +61 -0
  28. package/dist/env/task/plugins/lark-card-patch-notifier.js +6 -2
  29. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +42 -0
  30. package/dist/env/task/prompt/index.js +2 -1
  31. package/dist/env/task/prompt/task-discipline.d.ts +9 -3
  32. package/dist/env/task/task-component.d.ts +79 -0
  33. package/dist/env/task/tools/cancel-tool.d.ts +36 -0
  34. package/dist/env/task/tools/completion-copy.d.ts +92 -0
  35. package/dist/env/task/tools/index.d.ts +2 -0
  36. package/dist/env/task/tools/index.js +7 -2
  37. package/dist/env/task/tools/pre-complete-tool.d.ts +32 -0
  38. package/dist/env/task/tools/task-types.d.ts +71 -17
  39. package/dist/env/task/types.d.ts +13 -1
  40. package/dist/env/tool/built-in/compact-session-tool.d.ts +120 -0
  41. package/dist/env/tool/built-in/index.d.ts +2 -0
  42. package/dist/env/tool/built-in/index.js +6 -2
  43. package/dist/env/tool/index.js +4 -4
  44. package/dist/env/workflow/engine/index.js +6 -6
  45. package/dist/env/workflow/index.js +15 -13
  46. package/dist/env/workflow/plugins/index.js +2 -2
  47. package/dist/env/workflow/tools/ask-user-tool.d.ts +88 -0
  48. package/dist/env/workflow/tools/index.js +11 -9
  49. package/dist/env/workflow/tools/run-workflow.d.ts +2 -2
  50. package/dist/env/workflow/types/index.js +2 -2
  51. package/dist/env/workflow/types/workflow-hil.d.ts +25 -1
  52. package/dist/env/workflow/utils/index.js +5 -5
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.js +43 -33
  55. package/dist/shared/@ai-setting/{roy-agent-core-sm0sf6sb.js → roy-agent-core-0qyrk5k0.js} +2 -2
  56. package/dist/shared/@ai-setting/{roy-agent-core-kmbct9yg.js → roy-agent-core-0snm5hc5.js} +1 -1
  57. package/dist/shared/@ai-setting/{roy-agent-core-yr1mryb8.js → roy-agent-core-1v4g0d4x.js} +1 -1
  58. package/dist/shared/@ai-setting/{roy-agent-core-rxb00gjm.js → roy-agent-core-264qexac.js} +1 -1
  59. package/dist/shared/@ai-setting/roy-agent-core-2akfd64z.js +374 -0
  60. package/dist/shared/@ai-setting/{roy-agent-core-skyc30qx.js → roy-agent-core-3fh1f7s7.js} +2 -2
  61. package/dist/shared/@ai-setting/roy-agent-core-4rtg69cn.js +26 -0
  62. package/dist/shared/@ai-setting/{roy-agent-core-add1zqsh.js → roy-agent-core-6cy43nss.js} +22 -1
  63. package/dist/shared/@ai-setting/{roy-agent-core-vah6g5yx.js → roy-agent-core-6rh8k6ba.js} +5 -5
  64. package/dist/shared/@ai-setting/{roy-agent-core-kpg25s2q.js → roy-agent-core-8ez6mccb.js} +4 -2
  65. package/dist/shared/@ai-setting/{roy-agent-core-yhwxpj12.js → roy-agent-core-9vxh6f8h.js} +233 -16
  66. package/dist/shared/@ai-setting/{roy-agent-core-7qvw65jt.js → roy-agent-core-aa2j7bk9.js} +11 -8
  67. package/dist/shared/@ai-setting/{roy-agent-core-sjr1kmfz.js → roy-agent-core-acj8ag08.js} +1 -1
  68. package/dist/shared/@ai-setting/{roy-agent-core-mds8tqd0.js → roy-agent-core-cgtq6427.js} +1 -1
  69. package/dist/shared/@ai-setting/{roy-agent-core-34jz9mgh.js → roy-agent-core-cmprygrp.js} +1 -1
  70. package/dist/shared/@ai-setting/{roy-agent-core-wr7mv7k3.js → roy-agent-core-cxy143m4.js} +1 -1
  71. package/dist/shared/@ai-setting/{roy-agent-core-pakhchy7.js → roy-agent-core-ddyk1rc0.js} +1 -1
  72. package/dist/shared/@ai-setting/{roy-agent-core-attpry6g.js → roy-agent-core-dqxec05w.js} +4 -3
  73. package/dist/shared/@ai-setting/{roy-agent-core-vm8h5zyj.js → roy-agent-core-ed233k5z.js} +1 -1
  74. package/dist/shared/@ai-setting/{roy-agent-core-jrj30vq3.js → roy-agent-core-er070zjq.js} +1 -1
  75. package/dist/shared/@ai-setting/{roy-agent-core-40rv283c.js → roy-agent-core-fghc2m8z.js} +152 -2
  76. package/dist/shared/@ai-setting/{roy-agent-core-5gw0qa8m.js → roy-agent-core-ghnagzrh.js} +557 -92
  77. package/dist/shared/@ai-setting/{roy-agent-core-4jjwewvw.js → roy-agent-core-m46fe3x4.js} +41 -30
  78. package/dist/shared/@ai-setting/{roy-agent-core-e25xkv53.js → roy-agent-core-mkc3zshb.js} +3 -1
  79. package/dist/shared/@ai-setting/{roy-agent-core-hfyfavp3.js → roy-agent-core-mww0mnd9.js} +231 -27
  80. package/dist/shared/@ai-setting/{roy-agent-core-46rv4d7d.js → roy-agent-core-nmx9934r.js} +92 -2
  81. package/dist/shared/@ai-setting/{roy-agent-core-1w9y7mxj.js → roy-agent-core-p3zv1mx5.js} +1 -1
  82. package/dist/shared/@ai-setting/{roy-agent-core-jgb3bb42.js → roy-agent-core-q5r75vev.js} +17 -8
  83. package/dist/shared/@ai-setting/{roy-agent-core-y12kyxwa.js → roy-agent-core-t3rrb959.js} +33 -9
  84. package/dist/shared/@ai-setting/{roy-agent-core-dt104qa1.js → roy-agent-core-v85n42ve.js} +1 -1
  85. package/dist/shared/@ai-setting/{roy-agent-core-gr48c89p.js → roy-agent-core-v87njmq7.js} +3 -3
  86. package/dist/shared/@ai-setting/{roy-agent-core-7sj9xs9c.js → roy-agent-core-vffccgf6.js} +252 -25
  87. package/dist/shared/@ai-setting/{roy-agent-core-2gzt2q8c.js → roy-agent-core-z43aj03k.js} +134 -29
  88. package/dist/shared/@ai-setting/roy-agent-core-zycadbpx.js +662 -0
  89. package/package.json +1 -1
  90. package/dist/shared/@ai-setting/roy-agent-core-1p6syv85.js +0 -1083
  91. package/dist/shared/@ai-setting/roy-agent-core-58804s3j.js +0 -155
@@ -63,6 +63,75 @@ function sanitizeInlineText(text, maxLen = 300) {
63
63
  `).replace(/^#{1,6}\s+/gm, "").replace(/^\s*[-*+]\s+/gm, "· ").replace(/^\s*\d+\.\s+/gm, "· ").replace(/\*\*/g, "").replace(/`/g, "").replace(/\n+/g, " · ").replace(/\s{2,}/g, " ").replace(/(?:\s*·\s*){2,}/g, " · ").replace(/^(\s*·\s*)+/, "").replace(/(\s*·\s*)+$/, "").trim();
64
64
  return flat.length <= maxLen ? flat : `${flat.slice(0, maxLen)}…`;
65
65
  }
66
+ var HEAD_TITLE_MAX_WIDTH = 40;
67
+ function isWideChar(cp) {
68
+ return cp >= 4352 && cp <= 4447 || cp >= 11904 && cp <= 12350 || cp >= 12353 && cp <= 13311 || cp >= 13312 && cp <= 19903 || cp >= 19968 && cp <= 40959 || cp >= 40960 && cp <= 42191 || cp >= 44032 && cp <= 55203 || cp >= 63744 && cp <= 64255 || cp >= 65072 && cp <= 65135 || cp >= 65280 && cp <= 65376 || cp >= 65504 && cp <= 65510 || cp >= 127744 && cp <= 129791 || cp >= 131072 && cp <= 262141;
69
+ }
70
+ function charWidth(cp) {
71
+ return isWideChar(cp) ? 2 : 1;
72
+ }
73
+ function isTitleSeparator(ch) {
74
+ return ch === " " || ch === "·" || ch === "-" || ch === "_" || ch === "/" || ch === "、" || ch === "+" || ch === "=" || ch === "|" || ch === "|" || ch === "," || ch === "," || ch === ":" || ch === ":";
75
+ }
76
+ function truncateHeadTitle(text, maxWidth = HEAD_TITLE_MAX_WIDTH) {
77
+ if (!text)
78
+ return "";
79
+ const flat = text.replace(/\s+/g, " ").trim();
80
+ if (!flat)
81
+ return "";
82
+ if (!Number.isFinite(maxWidth) || maxWidth <= 0)
83
+ return flat;
84
+ const points = Array.from(flat);
85
+ const budget = Math.max(1, maxWidth - 1);
86
+ let width = 0;
87
+ let endIndex = points.length;
88
+ for (let i = 0;i < points.length; i++) {
89
+ const w = charWidth(points[i].codePointAt(0));
90
+ if (width + w > budget) {
91
+ endIndex = i;
92
+ break;
93
+ }
94
+ width += w;
95
+ }
96
+ if (endIndex >= points.length)
97
+ return flat;
98
+ let cut = endIndex;
99
+ let cutAtBoundary = false;
100
+ const minCut = Math.max(0, endIndex - 12);
101
+ for (let i = endIndex - 1;i >= minCut; i--) {
102
+ if (isTitleSeparator(points[i])) {
103
+ cut = i;
104
+ cutAtBoundary = true;
105
+ break;
106
+ }
107
+ }
108
+ let cutWidth = 0;
109
+ for (let i = 0;i < cut; i++)
110
+ cutWidth += charWidth(points[i].codePointAt(0));
111
+ if (cutAtBoundary && cutWidth < budget / 2) {
112
+ cut = endIndex;
113
+ cutAtBoundary = false;
114
+ }
115
+ let sliced = points.slice(0, cut).join("").trimEnd();
116
+ sliced = sliced.replace(/[+=||]+$/, "").trimEnd();
117
+ if (!cutAtBoundary) {
118
+ let wordStart = sliced.length;
119
+ for (let i = sliced.length - 1;i >= 0; i--) {
120
+ const ch = sliced[i];
121
+ if (ch === " " || ch === "·" || ch === "-" || ch === "_" || ch === "/") {
122
+ wordStart = i + 1;
123
+ break;
124
+ }
125
+ if (wordStart === sliced.length)
126
+ wordStart = i;
127
+ }
128
+ const fragment = sliced.slice(wordStart);
129
+ if (fragment.length > 0 && /^[A-Za-z]+$/.test(fragment) && wordStart > 0) {
130
+ sliced = sliced.slice(0, wordStart).trimEnd();
131
+ }
132
+ }
133
+ return sliced + "…";
134
+ }
66
135
  function formatDateTimeForDisplay(value) {
67
136
  const d = new Date(value);
68
137
  if (isNaN(d.getTime()))
@@ -391,7 +460,9 @@ function buildTaskCard(opts) {
391
460
  tag: "markdown",
392
461
  content: effectiveProgress !== undefined ? `**\uD83D\uDCCA 进度**:${renderProgressBar(effectiveProgress)}` : isTerminalStatus ? `**\uD83D\uDCCA 进度**:${terminalProgressText}` : `**\uD83D\uDCCA 进度**:进行中(第 ${updateCount} 次更新,尚未上报百分比)`
393
462
  });
394
- const taskLabel = opts.meta.id !== undefined ? `#${opts.meta.id}` : "任务";
463
+ const taskIdLabel = opts.meta.id !== undefined ? `#${opts.meta.id}` : "任务";
464
+ const taskTitleText = truncateHeadTitle(opts.meta.title);
465
+ const taskLabel = taskTitleText && taskTitleText !== taskIdLabel ? `${taskIdLabel} ${taskTitleText}` : taskIdLabel;
395
466
  return {
396
467
  schema: "2.0",
397
468
  header: {
@@ -612,6 +683,10 @@ class LarkCardPatchNotifier {
612
683
  }
613
684
  async updateTask(opts) {
614
685
  await this.mutexFor(opts.messageId).run(async () => {
686
+ if (this.finalisedCards.has(opts.messageId)) {
687
+ logger.debug(`updateTask: message ${opts.messageId} 已是终态卡片,忽略迟到的更新`);
688
+ return;
689
+ }
615
690
  const state = this.states.get(opts.messageId) ?? {
616
691
  chatId: opts.chatId ?? "",
617
692
  profile: opts.profile,
@@ -684,6 +759,14 @@ class LarkCardPatchNotifier {
684
759
  progress: snapshot.progress
685
760
  });
686
761
  }
762
+ mergeTimelineState(messageId, milestones = [], processSteps = []) {
763
+ const state = this.states.get(messageId);
764
+ if (!state)
765
+ return false;
766
+ state.milestones = mergeUnique(state.milestones, milestones, milestoneKey);
767
+ state.processSteps = mergeUnique(state.processSteps, processSteps, processStepKey);
768
+ return true;
769
+ }
687
770
  async pauseTask(opts) {
688
771
  await this.mutexFor(opts.messageId).run(async () => {
689
772
  const state = this.states.get(opts.messageId);
@@ -766,6 +849,7 @@ class LarkCardPatchNotifier {
766
849
  profile: opts.profile ?? state?.profile,
767
850
  card
768
851
  }), "patch");
852
+ this.finalisedCards.add(opts.messageId);
769
853
  });
770
854
  if (this.options.unpinOnFinish) {
771
855
  const state = this.states.get(opts.messageId);
@@ -800,6 +884,7 @@ class LarkCardPatchNotifier {
800
884
  spinner: SPINNER_EMOJIS[state.spinnerIndex] ?? SPINNER_EMOJIS[0]
801
885
  });
802
886
  }
887
+ finalisedCards = new Set;
803
888
  trackedCardCount() {
804
889
  return this.states.size;
805
890
  }
@@ -854,6 +939,10 @@ class LarkCardPatchNotifier {
854
939
  }
855
940
  async updateWorkflow(opts) {
856
941
  await this.mutexFor(opts.messageId).run(async () => {
942
+ if (this.finalisedCards.has(opts.messageId)) {
943
+ logger.debug(`updateWorkflow: message ${opts.messageId} 已是终态卡片,忽略迟到的更新`);
944
+ return;
945
+ }
857
946
  const state = this.workflowStates.get(opts.messageId) ?? {
858
947
  chatId: opts.chatId ?? "",
859
948
  profile: opts.profile,
@@ -946,6 +1035,7 @@ class LarkCardPatchNotifier {
946
1035
  profile: opts.profile ?? state?.profile,
947
1036
  card
948
1037
  }), "patch");
1038
+ this.finalisedCards.add(opts.messageId);
949
1039
  });
950
1040
  if (this.options.unpinOnFinish) {
951
1041
  const state = this.workflowStates.get(opts.messageId);
@@ -1273,4 +1363,4 @@ function sanitize(text) {
1273
1363
  return `${trimmed.slice(0, 500)}…`;
1274
1364
  }
1275
1365
 
1276
- export { formatTimestampForDisplay, sanitizeInlineText, formatDateTimeForDisplay, renderProgressBar, resolveTaskTitleForDisplay, humanizeValue, isTerminalStatusForTimeline, isTerminalStatusForWorkflowTimeline, buildCollapsiblePanel, renderTaskInfoLines, renderContextAsLines, renderMilestones, renderProcessSteps, partitionProcessSteps, buildTaskCard, buildChatAppLink, DEFAULT_APP_LINK_BASE, formatDurationMs, renderWorkflowInfoLines, buildWorkflowCard, LarkCardPatchNotifier };
1366
+ export { formatTimestampForDisplay, sanitizeInlineText, HEAD_TITLE_MAX_WIDTH, truncateHeadTitle, formatDateTimeForDisplay, renderProgressBar, resolveTaskTitleForDisplay, humanizeValue, isTerminalStatusForTimeline, isTerminalStatusForWorkflowTimeline, buildCollapsiblePanel, renderTaskInfoLines, renderContextAsLines, renderMilestones, renderProcessSteps, partitionProcessSteps, buildTaskCard, buildChatAppLink, DEFAULT_APP_LINK_BASE, formatDurationMs, renderWorkflowInfoLines, buildWorkflowCard, LarkCardPatchNotifier };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LarkCardPatchNotifier,
3
3
  formatDurationMs
4
- } from "./roy-agent-core-46rv4d7d.js";
4
+ } from "./roy-agent-core-nmx9934r.js";
5
5
  import {
6
6
  WorkflowHookPoints,
7
7
  init_workflow_hook_points
@@ -1,28 +1,28 @@
1
1
  import {
2
2
  isToolUnavailableError,
3
3
  truncateOutputInline
4
- } from "./roy-agent-core-dt104qa1.js";
4
+ } from "./roy-agent-core-v85n42ve.js";
5
5
  import {
6
6
  AgentRegistry
7
- } from "./roy-agent-core-vm8h5zyj.js";
7
+ } from "./roy-agent-core-ed233k5z.js";
8
8
  import {
9
9
  enqueueToAddFakeUserMessage
10
10
  } from "./roy-agent-core-f77k3gqt.js";
11
11
  import {
12
12
  SessionMessageConverter
13
- } from "./roy-agent-core-kmbct9yg.js";
13
+ } from "./roy-agent-core-0snm5hc5.js";
14
14
  import {
15
15
  parseToolArgsStrict,
16
16
  safeParseToolArgs,
17
17
  withTimeout
18
- } from "./roy-agent-core-40rv283c.js";
18
+ } from "./roy-agent-core-fghc2m8z.js";
19
19
  import {
20
20
  getCurrentBgTaskId
21
21
  } from "./roy-agent-core-c1v263jn.js";
22
22
  import {
23
23
  AskUserError,
24
24
  init_workflow_hil
25
- } from "./roy-agent-core-e25xkv53.js";
25
+ } from "./roy-agent-core-mkc3zshb.js";
26
26
  import {
27
27
  ContextError
28
28
  } from "./roy-agent-core-ctdhjv68.js";
@@ -1393,6 +1393,7 @@ class AgentComponent extends BaseComponent {
1393
1393
  role: "assistant",
1394
1394
  content: assistantParts
1395
1395
  });
1396
+ this.addRemainingToolResults(hookCtx, llmOutput.toolCalls, 0, "[Tool result missing: run interrupted] ContextError");
1396
1397
  } else if (llmOutput.content) {
1397
1398
  const assistantParts = [];
1398
1399
  if (llmOutput.content) {
@@ -1438,7 +1439,9 @@ class AgentComponent extends BaseComponent {
1438
1439
  query: error.query,
1439
1440
  sessionId: error.sessionId,
1440
1441
  nodeId: error.nodeId,
1441
- nodeType: error.nodeType
1442
+ nodeType: error.nodeType,
1443
+ agentSessionId: error.agentSessionId,
1444
+ delivered: error.delivered === true
1442
1445
  };
1443
1446
  result.error = `__ASK_USER_ERROR__:${JSON.stringify(errorInfo)}`;
1444
1447
  } else {
@@ -1979,7 +1982,13 @@ class AgentComponent extends BaseComponent {
1979
1982
  fallbackModel: ctx.context.fallbackModel,
1980
1983
  ...effectiveFallbackModels.length > 0 ? { fallbackModels: effectiveFallbackModels } : fallbackExplicitlySet ? { fallbackModels: [] } : {},
1981
1984
  workdir: ctx.context.metadata?.workdir,
1982
- metadata: ctx.context.metadata
1985
+ metadata: {
1986
+ ...ctx.context.metadata ?? {},
1987
+ ...ctx._runId ? { runId: ctx._runId } : {},
1988
+ ...ctx.context.sessionId ? { sessionId: ctx.context.sessionId } : {},
1989
+ ...ctx.context.agentType ? { agentType: ctx.context.agentType } : {},
1990
+ ...ctx.agent?.name ? { agentName: ctx.agent.name } : {}
1991
+ }
1983
1992
  };
1984
1993
  const request = {
1985
1994
  name: toolName,
@@ -1987,7 +1996,7 @@ class AgentComponent extends BaseComponent {
1987
1996
  context: toolContext
1988
1997
  };
1989
1998
  let result;
1990
- const isLongRunningTool = toolName === "delegate_task" || toolName === "stop_task" || toolName === "bash" || toolName === "workflow_run" || toolName === "run-workflow";
1999
+ const isLongRunningTool = toolName === "delegate_task" || toolName === "stop_task" || toolName === "bash" || toolName === "workflow_run" || toolName === "run-workflow" || toolName === "compact_session";
1991
2000
  const isExtraTool = this.toolComponent?.getTool ? !this.toolComponent.getTool(toolName) : false;
1992
2001
  if (isExtraTool) {
1993
2002
  logger2.debug(`[executeTool] Tool "${toolName}" is an extraTool, executing directly`);
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  defaultLarkCliRunner
3
3
  } from "./roy-agent-core-bxkjk7zx.js";
4
- import {
5
- notifyReactFailure
6
- } from "./roy-agent-core-add1zqsh.js";
7
4
  import {
8
5
  cliCommandHandler
9
6
  } from "./roy-agent-core-v0hf14bj.js";
@@ -13,17 +10,20 @@ import {
13
10
  createPerTaskGroupChatPlugin,
14
11
  extractPerTaskChatId,
15
12
  extractPerTaskChatName
16
- } from "./roy-agent-core-5gw0qa8m.js";
13
+ } from "./roy-agent-core-ghnagzrh.js";
17
14
  import {
18
15
  getSharedEventStore
19
16
  } from "./roy-agent-core-na18zwj0.js";
20
17
  import {
21
18
  createLarkCliWorkflowNotifyHook
22
- } from "./roy-agent-core-1w9y7mxj.js";
19
+ } from "./roy-agent-core-p3zv1mx5.js";
23
20
  import {
24
21
  LarkCardPatchNotifier,
25
22
  buildTaskCard
26
- } from "./roy-agent-core-46rv4d7d.js";
23
+ } from "./roy-agent-core-nmx9934r.js";
24
+ import {
25
+ notifyReactFailure
26
+ } from "./roy-agent-core-6cy43nss.js";
27
27
  import {
28
28
  normalizeLarkAtMentions
29
29
  } from "./roy-agent-core-m880qz3y.js";
@@ -3327,6 +3327,32 @@ function renderRuleNoticeSection(ruleNotice, headline) {
3327
3327
  return `❌ **回执未送达**(原因:${ruleNotice.error ?? "unknown"})
3328
3328
  ` + `→ 用户目前**还不知道**「${headline}」这件事,必须由你在回复里讲清楚,` + `并且不要假装系统已经通知过。`;
3329
3329
  }
3330
+ function renderActionSection(notifyType, taskId, scopeWord) {
3331
+ const completeCall = taskId !== "?" ? `task_complete(task_id=${taskId})` : `task_complete(task_id=<用 task_search 找回的任务号>)`;
3332
+ if (notifyType === "task.background.completed") {
3333
+ return `**第一步 —— 验收(⚠️ 不可跳过)**:Task #${taskId} 的最终验收由**你**(default agent)负责 —— sub-agent 只负责干完活并调 task_pre_complete 提交待验证(status=to_validate),**判定权在你**(Task #5073 两阶段验收)。
3334
+ 1. \`task_get(task_id=${taskId})\` **核对实际产出**:读 goal / delivery / 操作记录链(交付物在 \`context.deliverable_storage_path\` 和 operation 的 Deliverable 行里),再对照真实产出(文件是否存在、测试是否通过、review 结论是什么)。⚠️ **不接受 sub-agent 的自述作为验收依据** —— 它说"做完了"不算,产出在才算。
3335
+ 2. **逐条对照 goals 的编号子项**(文件断言 / 进程断言 / 测试断言 / 状态断言),一条一条核。
3336
+ 3. 全部达成 → **必须实际调用** \`${completeCall}\` 把任务落终态(completed)。
3337
+ ⚠️ **只回消息不算完成** —— 任务会一直挂在 \`to_validate\`,下游(任务卡片 / goal 检查 / 进度统计)都读不到最终状态。
3338
+ ⚠️ 本工具**不带**交付物参数(交付物通道 = task_pre_complete)—— 若发现交付物缺失,重新委托补做,不要在这一步补传。
3339
+ 4. 有差距 → 用 \`delegate_task(sub_session_id=...)\` 续跑或重新委托;**不要**因为"验收不通过"就 \`task_cancel\`(\`task_cancel\` 仅限**用户明令**)。
3340
+
3341
+ **第二步 —— 汇报**
3342
+ 5. 用 2~5 行总结:这次完成了什么 / 卡在哪(依据上面的输出与子 session)
3343
+ 6. 给出 1~3 个下一步选项(继续推进 / 拆小 / 放弃),并**问用户选哪个**
3344
+ 7. 用 lark-cli 把回复发到上面的${scopeWord}(见下)`;
3345
+ }
3346
+ return `**第一步 —— 找根因 → 继续推进(不要甩尾放弃)**
3347
+ 1. **先找根因**:读上面的输出与子 session,判断这次失败/超时/停止的真实原因(sub-agent 没做完?环境问题?指令不清?超时其实是工具撞硬超时但后台仍在跑?)。
3348
+ 2. **继续推进**:能用 \`delegate_task(sub_session_id=...)\` 续跑就续跑(继承子 session 历史,不必从零重来);不能续跑就按根因重新委托。
3349
+ 3. ⚠️ **不要**用 \`task_cancel\` 结束这个任务 —— \`task_cancel\` 仅限**用户明令**。确实推不动(外部依赖挂了 / 用户另有安排)就如实告诉用户「卡在哪 + 需要用户做什么决定」,等用户决定。
3350
+
3351
+ **第二步 —— 汇报**
3352
+ 4. 用 2~5 行总结:这次完成了什么 / 卡在哪(依据上面的输出与子 session)
3353
+ 5. 给出 1~3 个下一步选项(继续推进 / 拆小 / 放弃),并**问用户选哪个**
3354
+ 6. 用 lark-cli 把回复发到上面的${scopeWord}(见下)`;
3355
+ }
3330
3356
  function extractCommandText(rawEvent) {
3331
3357
  const event = rawEvent;
3332
3358
  const innerEvent = event.event;
@@ -3454,9 +3480,7 @@ ${receiptSection}
3454
3480
  ${result}
3455
3481
 
3456
3482
  ### \uD83D\uDC49 你要做什么
3457
- 1. 用 2~5 行总结:这次完成了什么 / 卡在哪(依据上面的输出与子 session)
3458
- 2. 给出 1~3 个下一步选项(继续推进 / 拆小 / 放弃),并**问用户选哪个**
3459
- 3. 用 lark-cli 把回复发到上面的${scopeWord}(见下)
3483
+ ${renderActionSection(notifyType, taskId, scopeWord)}
3460
3484
 
3461
3485
  ### 发送方式(渠道 = lark-cli)
3462
3486
  ${canReply ? ` ${replyCommand}` : `⚠️ 没有可用的 chatId —— 无法投递到触发会话。请在会话内汇报,并说明「未投递」的原因。`}
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  AskUserError,
6
6
  init_workflow_hil
7
- } from "./roy-agent-core-e25xkv53.js";
7
+ } from "./roy-agent-core-mkc3zshb.js";
8
8
  import {
9
9
  envKeyToConfigKey,
10
10
  toEnvKey
@@ -13,7 +13,7 @@ import {
13
13
  createWorkflowSearchTool,
14
14
  createWorkflowTagListTool,
15
15
  createWorkflowValidateTool
16
- } from "./roy-agent-core-hfyfavp3.js";
16
+ } from "./roy-agent-core-mww0mnd9.js";
17
17
  import {
18
18
  WorkflowService
19
19
  } from "./roy-agent-core-12n08pg5.js";
@@ -21,7 +21,7 @@ import {
21
21
  WorkflowEngine,
22
22
  exports_engine,
23
23
  init_engine
24
- } from "./roy-agent-core-vah6g5yx.js";
24
+ } from "./roy-agent-core-6rh8k6ba.js";
25
25
  import {
26
26
  BaseComponent
27
27
  } from "./roy-agent-core-pgvcf91v.js";
@@ -141,7 +141,7 @@ class WorkflowComponent extends BaseComponent {
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-skyc30qx.js");
144
+ const { AgentComponentAdapter } = await import("./roy-agent-core-3fh1f7s7.js");
145
145
  agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
146
146
  }
147
147
  }