@ai-setting/roy-agent-core 1.7.63 → 1.7.65

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 (131) hide show
  1. package/dist/config/index.js +9 -9
  2. package/dist/env/agent/agent-component.js +15 -15
  3. package/dist/env/agent/index.js +15 -15
  4. package/dist/env/commands/index.js +9 -9
  5. package/dist/env/context/index.js +5 -5
  6. package/dist/env/debug/index.js +9 -9
  7. package/dist/env/environment.d.ts +27 -0
  8. package/dist/env/error-reply.js +3 -3
  9. package/dist/env/event-source/bounty-im-handler.d.ts +1 -1
  10. package/dist/env/event-source/cli-command-handler.js +3 -3
  11. package/dist/env/event-source/event-source-handlers.js +22 -21
  12. package/dist/env/event-source/event-store.js +4 -4
  13. package/dist/env/event-source/index.js +23 -22
  14. package/dist/env/hook/index.js +7 -7
  15. package/dist/env/index.js +49 -48
  16. package/dist/env/llm/index.js +10 -10
  17. package/dist/env/log-trace/index.js +9 -9
  18. package/dist/env/log-trace/logger.js +2 -2
  19. package/dist/env/mcp/index.js +10 -10
  20. package/dist/env/mcp/tool/index.js +3 -3
  21. package/dist/env/memory/index.js +10 -10
  22. package/dist/env/memory/plugin/index.js +3 -3
  23. package/dist/env/plugin/index.js +9 -9
  24. package/dist/env/prompt/index.js +9 -9
  25. package/dist/env/session/index.js +12 -12
  26. package/dist/env/session/storage/index.js +6 -6
  27. package/dist/env/skill/index.js +9 -9
  28. package/dist/env/task/delegate/delegate-tool.d.ts +2 -2
  29. package/dist/env/task/delegate/delegate-tool.js +10 -10
  30. package/dist/env/task/delegate/index.js +10 -10
  31. package/dist/env/task/hooks/contexts.d.ts +34 -0
  32. package/dist/env/task/hooks/verdict.d.ts +170 -0
  33. package/dist/env/task/index.js +17 -16
  34. package/dist/env/task/mcp/index.js +6 -5
  35. package/dist/env/task/plugins/__e2e__/laya-chain-validate.d.ts +15 -0
  36. package/dist/env/task/plugins/__e2e__/laya-decision-branches.d.ts +18 -0
  37. package/dist/env/task/plugins/__e2e__/laya-decision-e2e-live.d.ts +27 -0
  38. package/dist/env/task/plugins/__e2e__/laya-e2e-verify.d.ts +17 -0
  39. package/dist/env/task/plugins/decision-hint-plugin.d.ts +144 -0
  40. package/dist/env/task/plugins/decision-port.d.ts +119 -0
  41. package/dist/env/task/plugins/decision-renderers.d.ts +33 -0
  42. package/dist/env/task/plugins/index.d.ts +1 -0
  43. package/dist/env/task/plugins/index.js +19 -12
  44. package/dist/env/task/plugins/lark-card-patch-notifier.js +4 -4
  45. package/dist/env/task/plugins/laya-decision-plugin.d.ts +136 -0
  46. package/dist/env/task/plugins/laya-port.d.ts +143 -0
  47. package/dist/env/task/plugins/laya-render.d.ts +100 -0
  48. package/dist/env/task/storage/index.js +5 -5
  49. package/dist/env/task/tools/index.js +6 -5
  50. package/dist/env/tool/built-in/index.js +5 -5
  51. package/dist/env/tool/index.js +12 -12
  52. package/dist/env/workflow/engine/index.js +14 -14
  53. package/dist/env/workflow/hooks/index.js +9 -9
  54. package/dist/env/workflow/index.js +24 -24
  55. package/dist/env/workflow/nodes/index.js +4 -4
  56. package/dist/env/workflow/plugins/index.js +10 -10
  57. package/dist/env/workflow/service/index.js +4 -4
  58. package/dist/env/workflow/storage/index.js +5 -5
  59. package/dist/env/workflow/tools/index.js +16 -16
  60. package/dist/env/workflow/utils/index.js +6 -6
  61. package/dist/index.js +60 -59
  62. package/dist/shared/@ai-setting/{roy-agent-core-sj4y3wdm.js → roy-agent-core-002g6nfk.js} +3 -3
  63. package/dist/shared/@ai-setting/{roy-agent-core-06jakebr.js → roy-agent-core-07fvy74y.js} +2 -2
  64. package/dist/shared/@ai-setting/{roy-agent-core-60f7h284.js → roy-agent-core-0cb6w0k7.js} +5 -5
  65. package/dist/shared/@ai-setting/{roy-agent-core-cxpgd415.js → roy-agent-core-0ys85x46.js} +6 -6
  66. package/dist/shared/@ai-setting/{roy-agent-core-6wxww10t.js → roy-agent-core-12n08pg5.js} +2 -2
  67. package/dist/shared/@ai-setting/{roy-agent-core-t6nx0rsz.js → roy-agent-core-18am1h07.js} +11 -11
  68. package/dist/shared/@ai-setting/{roy-agent-core-ebws32tv.js → roy-agent-core-37tj4y6a.js} +14 -14
  69. package/dist/shared/@ai-setting/{roy-agent-core-gjsvehfs.js → roy-agent-core-3wrveh5p.js} +2 -2
  70. package/dist/shared/@ai-setting/{roy-agent-core-03k5drfp.js → roy-agent-core-40rv283c.js} +2 -2
  71. package/dist/shared/@ai-setting/{roy-agent-core-kvq4a4p6.js → roy-agent-core-5pr4zp88.js} +2 -2
  72. package/dist/shared/@ai-setting/{roy-agent-core-qmqe8ds3.js → roy-agent-core-6j02sbee.js} +3 -3
  73. package/dist/shared/@ai-setting/{roy-agent-core-b4zdm2n4.js → roy-agent-core-6z412atw.js} +45 -8
  74. package/dist/shared/@ai-setting/{roy-agent-core-hfyxv2kx.js → roy-agent-core-7cbpmk4q.js} +2 -2
  75. package/dist/shared/@ai-setting/{roy-agent-core-6awgfh3x.js → roy-agent-core-7f7t9wwp.js} +1 -1
  76. package/dist/shared/@ai-setting/roy-agent-core-83bewqx8.js +10 -0
  77. package/dist/shared/@ai-setting/{roy-agent-core-jnszp0jq.js → roy-agent-core-85xyctnb.js} +7 -2
  78. package/dist/shared/@ai-setting/{roy-agent-core-2pma868e.js → roy-agent-core-87942bw4.js} +5 -5
  79. package/dist/shared/@ai-setting/{roy-agent-core-ja4sr63d.js → roy-agent-core-8cx7cfdg.js} +7 -7
  80. package/dist/shared/@ai-setting/{roy-agent-core-th92f833.js → roy-agent-core-9bs6xrav.js} +2 -2
  81. package/dist/shared/@ai-setting/{roy-agent-core-bm3gav5d.js → roy-agent-core-9bshyqjn.js} +4 -4
  82. package/dist/shared/@ai-setting/{roy-agent-core-va4m04e8.js → roy-agent-core-add1zqsh.js} +1 -1
  83. package/dist/shared/@ai-setting/{roy-agent-core-7tce05jt.js → roy-agent-core-ax9e9szb.js} +1 -1
  84. package/dist/shared/@ai-setting/{roy-agent-core-8xv4qzx7.js → roy-agent-core-br9cdm8d.js} +1 -1
  85. package/dist/shared/@ai-setting/{roy-agent-core-zjgckbdd.js → roy-agent-core-c2gbt68e.js} +2 -2
  86. package/dist/shared/@ai-setting/{roy-agent-core-v7mwj8eq.js → roy-agent-core-cpcd24n2.js} +2 -2
  87. package/dist/shared/@ai-setting/{roy-agent-core-hczj1ryh.js → roy-agent-core-dc9zq75z.js} +5 -5
  88. package/dist/shared/@ai-setting/{roy-agent-core-zy8vkbnk.js → roy-agent-core-dvtg4sn0.js} +1 -1
  89. package/dist/shared/@ai-setting/{roy-agent-core-g6pw4esq.js → roy-agent-core-e42v9bcq.js} +4 -4
  90. package/dist/shared/@ai-setting/{roy-agent-core-hwkc0bg2.js → roy-agent-core-efkjyh69.js} +1 -1
  91. package/dist/shared/@ai-setting/{roy-agent-core-dfqhc9ey.js → roy-agent-core-es203w7p.js} +2 -2
  92. package/dist/shared/@ai-setting/{roy-agent-core-w2ev3z5q.js → roy-agent-core-es467wsz.js} +6 -6
  93. package/dist/shared/@ai-setting/{roy-agent-core-ye4bfzqg.js → roy-agent-core-f6c0nadn.js} +969 -105
  94. package/dist/shared/@ai-setting/{roy-agent-core-p8rf4z89.js → roy-agent-core-f77k3gqt.js} +1 -1
  95. package/dist/shared/@ai-setting/{roy-agent-core-jw63js86.js → roy-agent-core-fttgm52a.js} +1 -1
  96. package/dist/shared/@ai-setting/{roy-agent-core-32ck9rqt.js → roy-agent-core-g8htfwxj.js} +2 -2
  97. package/dist/shared/@ai-setting/{roy-agent-core-5mrynf9g.js → roy-agent-core-gxzxq1sf.js} +1 -1
  98. package/dist/shared/@ai-setting/{roy-agent-core-gnt23yx0.js → roy-agent-core-hjejpcg5.js} +8 -8
  99. package/dist/shared/@ai-setting/{roy-agent-core-5hq4v41q.js → roy-agent-core-hmdcz3g9.js} +10 -9
  100. package/dist/shared/@ai-setting/{roy-agent-core-1dnsk6ht.js → roy-agent-core-hy3zn2q2.js} +3 -3
  101. package/dist/shared/@ai-setting/{roy-agent-core-wzp4tbsn.js → roy-agent-core-jvv2h3d6.js} +1 -1
  102. package/dist/shared/@ai-setting/{roy-agent-core-prnry2mw.js → roy-agent-core-jz8dsypm.js} +3 -3
  103. package/dist/shared/@ai-setting/{roy-agent-core-rfhxj8v2.js → roy-agent-core-kmbct9yg.js} +1 -1
  104. package/dist/shared/@ai-setting/{roy-agent-core-gc6wcd7z.js → roy-agent-core-mcy5apay.js} +1 -1
  105. package/dist/shared/@ai-setting/{roy-agent-core-p6a4v4fq.js → roy-agent-core-mds8tqd0.js} +1 -1
  106. package/dist/shared/@ai-setting/{roy-agent-core-bpvz1dqr.js → roy-agent-core-mw2cen6s.js} +8 -8
  107. package/dist/shared/@ai-setting/{roy-agent-core-a08dpf71.js → roy-agent-core-na18zwj0.js} +1 -1
  108. package/dist/shared/@ai-setting/{roy-agent-core-2hkyp51n.js → roy-agent-core-nm4xbs1d.js} +1 -1
  109. package/dist/shared/@ai-setting/{roy-agent-core-79gyka2q.js → roy-agent-core-nwbfepba.js} +2 -2
  110. package/dist/shared/@ai-setting/{roy-agent-core-gtdtzbs7.js → roy-agent-core-pgvcf91v.js} +2 -2
  111. package/dist/shared/@ai-setting/{roy-agent-core-084zthqx.js → roy-agent-core-q96qynhb.js} +1 -1
  112. package/dist/shared/@ai-setting/{roy-agent-core-386wa4wy.js → roy-agent-core-qq96p0tj.js} +1 -1
  113. package/dist/shared/@ai-setting/{roy-agent-core-33hn1beg.js → roy-agent-core-qqaak24r.js} +1 -1
  114. package/dist/shared/@ai-setting/{roy-agent-core-vwzan9v0.js → roy-agent-core-r5wt1h3c.js} +2 -2
  115. package/dist/shared/@ai-setting/{roy-agent-core-2cw72f16.js → roy-agent-core-rjzdj0xb.js} +5 -5
  116. package/dist/shared/@ai-setting/{roy-agent-core-c57278kx.js → roy-agent-core-sjr1kmfz.js} +1 -1
  117. package/dist/shared/@ai-setting/{roy-agent-core-as0dd70m.js → roy-agent-core-t0ktaevq.js} +50 -4
  118. package/dist/shared/@ai-setting/{roy-agent-core-anb53t3v.js → roy-agent-core-tm1mxttk.js} +4 -4
  119. package/dist/shared/@ai-setting/roy-agent-core-tr3ep81v.js +397 -0
  120. package/dist/shared/@ai-setting/{roy-agent-core-p37kh0kt.js → roy-agent-core-v0hf14bj.js} +1 -1
  121. package/dist/shared/@ai-setting/{roy-agent-core-c4t4y18j.js → roy-agent-core-v6vr6za7.js} +5 -5
  122. package/dist/shared/@ai-setting/{roy-agent-core-c8xvy6hj.js → roy-agent-core-w07ymg29.js} +4 -4
  123. package/dist/shared/@ai-setting/{roy-agent-core-mbwaxqs0.js → roy-agent-core-xcp8vwax.js} +4 -4
  124. package/dist/shared/@ai-setting/{roy-agent-core-g23yp3t1.js → roy-agent-core-xhrrgfdy.js} +29 -12
  125. package/dist/shared/@ai-setting/{roy-agent-core-mkpsz128.js → roy-agent-core-xvt7kf7p.js} +5 -5
  126. package/dist/shared/@ai-setting/{roy-agent-core-kmvw6b4v.js → roy-agent-core-yr1mryb8.js} +1 -1
  127. package/dist/shared/@ai-setting/{roy-agent-core-m3w3ytxt.js → roy-agent-core-zk2jg0v7.js} +2 -2
  128. package/dist/shared/@ai-setting/{roy-agent-core-mrrv80jy.js → roy-agent-core-zxz5fkwj.js} +1 -1
  129. package/dist/utils/temp-file-manager/index.js +3 -3
  130. package/package.json +1 -1
  131. package/dist/shared/@ai-setting/roy-agent-core-a6cz4d23.js +0 -10
@@ -0,0 +1,397 @@
1
+ import {
2
+ init_decorator,
3
+ wrapFunction
4
+ } from "./roy-agent-core-qq96p0tj.js";
5
+
6
+ // src/env/task/hooks/verdict.ts
7
+ init_decorator();
8
+ var MAX_SIMILAR_TASK_IDS = 20;
9
+ var CANDIDATE_TITLE_MAX = 40;
10
+ var CANDIDATE_DESC_MAX = 45;
11
+ var CANDIDATE_TAGS_MAX = 4;
12
+ var LEAKAGE_DENY_KEYS = [
13
+ "expected_decision",
14
+ "expected_root",
15
+ "expected_",
16
+ "case_id",
17
+ "category",
18
+ "suggested_",
19
+ "recommended_",
20
+ "best_match",
21
+ "answer",
22
+ "answer_key",
23
+ "label",
24
+ "should_",
25
+ "target",
26
+ "gold",
27
+ "ground_truth",
28
+ "hint",
29
+ "solution",
30
+ "duplicate_of",
31
+ "similar_task_ids",
32
+ "candidate_order",
33
+ "verdict",
34
+ "decision"
35
+ ];
36
+ function parseSimilarTaskIdsImpl(contextJson) {
37
+ if (!contextJson)
38
+ return [];
39
+ let parsed;
40
+ try {
41
+ parsed = JSON.parse(contextJson);
42
+ } catch {
43
+ return [];
44
+ }
45
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
46
+ return [];
47
+ const raw = parsed.similar_task_ids;
48
+ if (!Array.isArray(raw))
49
+ return [];
50
+ const out = [];
51
+ const seen = new Set;
52
+ for (const item of raw) {
53
+ if (typeof item !== "number")
54
+ continue;
55
+ if (!Number.isInteger(item) || item <= 0)
56
+ continue;
57
+ if (seen.has(item))
58
+ continue;
59
+ seen.add(item);
60
+ out.push(item);
61
+ if (out.length >= MAX_SIMILAR_TASK_IDS)
62
+ break;
63
+ }
64
+ return out;
65
+ }
66
+ function deriveActionFromStatusImpl(status) {
67
+ switch (status) {
68
+ case "completed":
69
+ case "cancelled":
70
+ case "paused":
71
+ case "archived":
72
+ return "reopen";
73
+ case "todo":
74
+ case "active":
75
+ default:
76
+ return "enhance";
77
+ }
78
+ }
79
+ function deriveReopenStatus(status) {
80
+ return status === "paused" ? "active" : "todo";
81
+ }
82
+ var STATUS_LETTER = {
83
+ todo: "t",
84
+ active: "a",
85
+ completed: "c",
86
+ paused: "p",
87
+ cancelled: "x",
88
+ archived: "r"
89
+ };
90
+ var NEW_TASK_ID_PLACEHOLDER = "__NEW_TASK_ID__";
91
+ var NEW_TASK_ID_HASH_PLACEHOLDER = "#__NEW_TASK_ID__";
92
+ function buildHintTextImpl(input) {
93
+ switch (input.scenario) {
94
+ case "reuse":
95
+ return buildReuseHint(input);
96
+ case "reopen":
97
+ return buildReopenHint(input);
98
+ case "reopen_enhance":
99
+ return buildReopenEnhanceHint(input);
100
+ case "remount":
101
+ return buildRemountHint(input);
102
+ case "soft_reuse":
103
+ return buildSoftReuseHint(input);
104
+ }
105
+ }
106
+ function newTaskRef(input) {
107
+ return input.newTaskId > 0 ? String(input.newTaskId) : NEW_TASK_ID_PLACEHOLDER;
108
+ }
109
+ function newTaskHashRef(input) {
110
+ return input.newTaskId > 0 ? `#${input.newTaskId}` : NEW_TASK_ID_HASH_PLACEHOLDER;
111
+ }
112
+ function targetLine(input) {
113
+ const t = input.targetTask;
114
+ if (!t)
115
+ return "";
116
+ return `#${input.targetTaskId} [${t.type}] ${t.title}
117
+ 状态:${t.status}`;
118
+ }
119
+ function buildReuseHint(input) {
120
+ const goalsPart = input.includeGoals ? ", goals_and_expected_deliverables=<追加本次目标>" : "";
121
+ return [
122
+ "[TASK_CREATE_HINT] 检测到与已有任务高度相似,建议复用而非新建。",
123
+ "",
124
+ targetLine(input),
125
+ "状态:" + (input.targetTask?.status ?? "") + " | 建议动作:enhance(补充目标/描述)",
126
+ "",
127
+ `如需合并到 #${input.targetTaskId},可执行:`,
128
+ ` task_update(task_id=${input.targetTaskId}, description=<追加本次请求的描述>${goalsPart})`,
129
+ "",
130
+ `说明:本次已创建新任务 ${newTaskHashRef(input)}。若确认应复用 #${input.targetTaskId},请调用上述 task_update 并按需归档 ${newTaskHashRef(input)}。`,
131
+ "",
132
+ "核实要点:本次请求是否就是 #" + input.targetTaskId + " 的「同一件事」,而不是同主题下新的一步?",
133
+ " - 若只是同主题的新一步(需要独立跟踪的新子任务),建子任务不算不采纳,但需在回复中说明为何不直接合并。",
134
+ " - 若确实是同一件事,应采纳 (a) 执行复用。",
135
+ "",
136
+ `⚠️ 你必须核实本提示:先用 task_get(${input.targetTaskId}) 确认目标任务的当前状态与内容是否与本次请求实质相同。`,
137
+ "核实后二选一执行:",
138
+ `(a) 确认实质相同 → 按上面的 task_update(task_id=${input.targetTaskId}, ...) 执行复用,并归档本次新建的任务 ${newTaskHashRef(input)};`,
139
+ "(b) 确认不相似 → 在本次回复中明确说明不采纳的理由。",
140
+ "不允许无视本提示。"
141
+ ].join(`
142
+ `);
143
+ }
144
+ function buildReopenHint(input) {
145
+ const targetStatus = input.targetTask?.status ?? "completed";
146
+ const reopenTo = deriveReopenStatus(targetStatus);
147
+ const goalsPart = input.includeGoals ? ", goals_and_expected_deliverables=<追加本次目标>" : "";
148
+ return [
149
+ "[TASK_CREATE_HINT] 检测到本次请求与已有任务实质相同,建议重开该任务而不是新建。",
150
+ "",
151
+ targetLine(input),
152
+ `状态:${targetStatus} | 建议动作:reopen(恢复为 ${reopenTo})`,
153
+ "",
154
+ `如需重开并承接本次请求,可执行:`,
155
+ ` task_update(task_id=${input.targetTaskId}, status=${reopenTo}, description=<追加本次请求的描述>${goalsPart})`,
156
+ "",
157
+ `说明:本次已创建新任务 ${newTaskHashRef(input)}。若确认应复用 #${input.targetTaskId},请调用上述 task_update 并按需归档 ${newTaskHashRef(input)}。`,
158
+ "",
159
+ `核实要点:#${input.targetTaskId} 是否真的已完结(completed / cancelled),但其语义与本次请求仍然相同?`,
160
+ " - 若已完结但语义仍相同(本次请求是该任务的延续)→ 应采纳 (a) 重开。",
161
+ " - 若目标已完结且语义不同(只是主题相近)→ 应采纳 (b) 说明不采纳的理由。",
162
+ "",
163
+ `⚠️ 你必须核实本提示:先用 task_get(${input.targetTaskId}) 确认目标任务的当前状态与内容是否与本次请求实质相同。`,
164
+ "核实后二选一执行:",
165
+ `(a) 确认实质相同 → 按上面的 task_update(task_id=${input.targetTaskId}, status=${reopenTo}, ...) 执行重开,并归档本次新建的任务 ${newTaskHashRef(input)};`,
166
+ "(b) 确认不相似 → 在本次回复中明确说明不采纳的理由。",
167
+ "不允许无视本提示。"
168
+ ].join(`
169
+ `);
170
+ }
171
+ function buildReopenEnhanceHint(input) {
172
+ const targetStatus = input.targetTask?.status ?? "completed";
173
+ const reopenTo = deriveReopenStatus(targetStatus);
174
+ return [
175
+ "[TASK_CREATE_HINT] 检测到本次请求与已有任务实质相同,且本次新增了目标,建议重开并增强该任务。",
176
+ "",
177
+ targetLine(input),
178
+ `状态:${targetStatus} | 建议动作:reopen + enhance(恢复为 ${reopenTo} 并追加目标)`,
179
+ "",
180
+ "如需重开并承接本次请求,可执行:",
181
+ ` task_update(task_id=${input.targetTaskId}, status=${reopenTo}, description=<追加本次请求的描述>, goals_and_expected_deliverables=<追加本次目标>)`,
182
+ "",
183
+ `说明:本次已创建新任务 ${newTaskHashRef(input)}。若确认应复用 #${input.targetTaskId},请调用上述 task_update 并按需归档 ${newTaskHashRef(input)}。`,
184
+ "",
185
+ `核实要点:① #${input.targetTaskId} 是否真的已完结(completed / cancelled)但语义仍与本次请求相同;② 本次新增的目标是否确实属于该任务的范围内?`,
186
+ " - 两点都成立 → 应采纳 (a) 重开并增强。",
187
+ " - 新增目标超出原任务范围(是独立的新工作)→ 应采纳 (b) 说明不采纳的理由。",
188
+ "",
189
+ `⚠️ 你必须核实本提示:先用 task_get(${input.targetTaskId}) 确认目标任务的当前状态与内容是否与本次请求实质相同。`,
190
+ "核实后二选一执行:",
191
+ `(a) 确认实质相同 → 按上面的 task_update(task_id=${input.targetTaskId}, status=${reopenTo}, ..., goals_and_expected_deliverables=...) 执行重开并增强,并归档本次新建的任务 ${newTaskHashRef(input)};`,
192
+ "(b) 确认不相似 → 在本次回复中明确说明不采纳的理由。",
193
+ "不允许无视本提示。"
194
+ ].join(`
195
+ `);
196
+ }
197
+ function buildRemountHint(input) {
198
+ return [
199
+ "[TASK_CREATE_HINT] 检测到本次任务的挂载位置可能不合理。",
200
+ "",
201
+ `当前挂载:parent #${input.currentParentId} → root 祖先 #${input.currentRootAncestorId}`,
202
+ `建议归属:root #${input.recommendedRootId} ${input.recommendedRootTitle ?? ""}`.trimEnd(),
203
+ "",
204
+ "如需改挂到建议的 root 下,可执行:",
205
+ ` task_update(task_id=${newTaskRef(input)}, parent_task_id=${input.recommendedRootId})`,
206
+ "",
207
+ `说明:本次已创建新任务 ${newTaskHashRef(input)},parent 未被自动修改。`,
208
+ "",
209
+ `核实要点:当前 parent #${input.currentParentId} 的 root 祖先 #${input.currentRootAncestorId} 与建议的 root #${input.recommendedRootId},哪一条才是本次任务的正确归属线?(可参考兄弟任务的主题分布)`,
210
+ " - 建议的 root 更贴合本次任务主题 → 应采纳 (a) 执行改挂。",
211
+ " - 当前归属线已正确 → 应采纳 (b) 说明不采纳的理由。",
212
+ "",
213
+ `⚠️ 你必须核实本提示:先用 task_get(${newTaskRef(input)}) 确认本次新建任务的实际 parent,并用 task_get(${input.recommendedRootId})(必要时 task_tree)确认归属线是否真的不对。`,
214
+ "核实后二选一执行:",
215
+ `(a) 确认挂载不合理 → 执行改挂 task_update(task_id=${newTaskRef(input)}, parent_task_id=${input.recommendedRootId});`,
216
+ "(b) 确认当前挂载合理 → 在本次回复中明确说明不采纳的理由。",
217
+ "不允许无视本提示。"
218
+ ].join(`
219
+ `);
220
+ }
221
+ function buildSoftReuseHint(input) {
222
+ const goalsPart = input.includeGoals ? ", goals_and_expected_deliverables=<追加本次目标>" : "";
223
+ return [
224
+ "[TASK_CREATE_HINT] 检测到本次请求可能与已有任务有关联(置信度偏低,仅供参考)。",
225
+ "",
226
+ targetLine(input),
227
+ "",
228
+ "若确认是同一件事,可执行:",
229
+ ` task_update(task_id=${input.targetTaskId}, description=<追加本次请求的描述>${goalsPart})`,
230
+ "",
231
+ `说明:本提示基于较低置信度,可能误判。本次已创建新任务 ${newTaskHashRef(input)}。`,
232
+ "",
233
+ `核实要点:#${input.targetTaskId} 与本次请求是否确为同一件事?(本提示置信度低,核实权重相应降低,但不得跳过表态)`,
234
+ "",
235
+ `⚠️ 你必须核实本提示:先用 task_get(${input.targetTaskId}) 确认目标任务的当前状态与内容是否与本次请求实质相同。`,
236
+ "核实后二选一执行:",
237
+ `(a) 确认实质相同 → 按上面的 task_update(task_id=${input.targetTaskId}, ...) 执行复用,并归档本次新建的任务 ${newTaskHashRef(input)};`,
238
+ "(b) 确认不相似 → 在本次回复中明确说明不采纳的理由。",
239
+ "不允许无视本提示。"
240
+ ].join(`
241
+ `);
242
+ }
243
+ function isLeakingKey(key) {
244
+ const lower = key.toLowerCase();
245
+ return LEAKAGE_DENY_KEYS.some((deny) => deny.endsWith("_") || deny.endsWith("*") ? lower.startsWith(deny.slice(0, -1)) : lower === deny);
246
+ }
247
+ function assertNoLeakageImpl(state, questions) {
248
+ const walk = (node, path) => {
249
+ if (Array.isArray(node)) {
250
+ node.forEach((item, i) => walk(item, `${path}[${i}]`));
251
+ return;
252
+ }
253
+ if (!node || typeof node !== "object")
254
+ return;
255
+ for (const [key, value] of Object.entries(node)) {
256
+ const childPath = path ? `${path}.${key}` : key;
257
+ if (isLeakingKey(key)) {
258
+ throw new Error(`[assertNoLeakage] leakage key detected at ${childPath}: "${key}"`);
259
+ }
260
+ walk(value, childPath);
261
+ }
262
+ };
263
+ walk(state, "state");
264
+ walk(questions, "questions");
265
+ }
266
+ function writeDecisionHintImpl(options, hint) {
267
+ let parsed;
268
+ try {
269
+ parsed = JSON.parse(options.context);
270
+ } catch {
271
+ return false;
272
+ }
273
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
274
+ return false;
275
+ parsed.decision_hint = hint;
276
+ options.context = JSON.stringify(parsed);
277
+ return true;
278
+ }
279
+ function truncate(text, max) {
280
+ if (text.length <= max)
281
+ return text;
282
+ return text.slice(0, max) + "…";
283
+ }
284
+ function renderCandidateKey(c) {
285
+ return `#${c.id} [${c.type}] ${truncate(c.title, CANDIDATE_TITLE_MAX)}`;
286
+ }
287
+ function renderCandidateValue(c) {
288
+ const letter = STATUS_LETTER[c.status] ?? (c.status.charAt(0) || "t");
289
+ const desc = truncate(c.description, CANDIDATE_DESC_MAX);
290
+ const tags = (c.tags ?? []).slice(0, CANDIDATE_TAGS_MAX);
291
+ const tagsPart = tags.length > 0 ? ` [tags: ${tags.join(",")}]` : "";
292
+ return `${letter}|${c.ago}|${desc}${tagsPart}`;
293
+ }
294
+ function formatRelativeAge(isoTimestamp, now = Date.now()) {
295
+ const ts = Date.parse(isoTimestamp);
296
+ if (Number.isNaN(ts))
297
+ return "0m";
298
+ const diffMs = now - ts;
299
+ if (diffMs <= 0)
300
+ return "0m";
301
+ const minutes = Math.floor(diffMs / 60000);
302
+ if (minutes < 60)
303
+ return `${minutes}m`;
304
+ const hours = Math.floor(minutes / 60);
305
+ if (hours < 24)
306
+ return `${hours}h`;
307
+ const days = Math.floor(hours / 24);
308
+ return `${days}d`;
309
+ }
310
+ var parseSimilarTaskIds = wrapFunction(parseSimilarTaskIdsImpl, "task.decision.parseSimilarTaskIds", {
311
+ recordParams: true,
312
+ recordResult: true,
313
+ log: false,
314
+ paramFilter: (args) => {
315
+ const raw = args[0];
316
+ const ctx = typeof raw === "string" ? raw : "";
317
+ return {
318
+ contextLen: ctx.length,
319
+ contextPreview: ctx.length > 80 ? ctx.slice(0, 80) + "…" : ctx
320
+ };
321
+ },
322
+ resultFilter: (res) => ({ count: res.length, ids: res.join(",") })
323
+ });
324
+ var deriveActionFromStatus = wrapFunction(deriveActionFromStatusImpl, "task.decision.deriveActionFromStatus", {
325
+ recordParams: true,
326
+ recordResult: true,
327
+ log: false
328
+ });
329
+ var buildHintText = wrapFunction(buildHintTextImpl, "task.decision.buildHintText", {
330
+ recordParams: true,
331
+ recordResult: true,
332
+ log: false,
333
+ paramFilter: (args) => {
334
+ const i = args[0] ?? {};
335
+ return {
336
+ scenario: i.scenario,
337
+ newTaskId: i.newTaskId,
338
+ targetTaskId: i.targetTaskId ?? null,
339
+ recommendedRootId: i.recommendedRootId ?? null,
340
+ currentParentId: i.currentParentId ?? null,
341
+ confidence: i.confidence ?? null
342
+ };
343
+ },
344
+ resultFilter: (res) => ({
345
+ hintLen: res.length,
346
+ hintPreview: res.slice(0, 240),
347
+ hasTaskUpdate: /task_update\s*\(/.test(res),
348
+ hasTaskId: /"task_id"\s*:/.test(res),
349
+ hasParentTaskId: /"parent_task_id"\s*:/.test(res)
350
+ })
351
+ });
352
+ var assertNoLeakage = wrapFunction(assertNoLeakageImpl, "task.decision.assertNoLeakage", {
353
+ recordParams: true,
354
+ recordResult: false,
355
+ log: false,
356
+ paramFilter: (args) => ({
357
+ stateKeys: collectKeyNames(args[0]),
358
+ questionKeys: collectKeyNames(args[1])
359
+ })
360
+ });
361
+ var writeDecisionHint = wrapFunction(writeDecisionHintImpl, "task.decision.writeDecisionHint", {
362
+ recordParams: true,
363
+ recordResult: true,
364
+ log: false,
365
+ paramFilter: (args) => {
366
+ const opts = args[0] ?? {};
367
+ const hint = typeof args[1] === "string" ? args[1] : "";
368
+ return {
369
+ contextLen: typeof opts.context === "string" ? opts.context.length : 0,
370
+ hintLen: hint.length,
371
+ hintScenario: /task_update\s*\(/.test(hint) ? "actionable" : "plain"
372
+ };
373
+ },
374
+ resultFilter: (res) => ({ written: res }),
375
+ errorIf: (res) => res === false ? new Error("writeDecisionHint returned false (context not a JSON object)") : undefined
376
+ });
377
+ function collectKeyNames(node, out = [], depth = 0) {
378
+ if (out.length >= 40 || depth > 4)
379
+ return out;
380
+ if (Array.isArray(node)) {
381
+ for (const item of node.slice(0, 3))
382
+ collectKeyNames(item, out, depth + 1);
383
+ return out;
384
+ }
385
+ if (!node || typeof node !== "object")
386
+ return out;
387
+ for (const key of Object.keys(node)) {
388
+ if (out.length >= 40)
389
+ break;
390
+ if (!out.includes(key))
391
+ out.push(key);
392
+ collectKeyNames(node[key], out, depth + 1);
393
+ }
394
+ return out;
395
+ }
396
+
397
+ export { NEW_TASK_ID_PLACEHOLDER, NEW_TASK_ID_HASH_PLACEHOLDER, renderCandidateKey, renderCandidateValue, formatRelativeAge, parseSimilarTaskIds, deriveActionFromStatus, buildHintText, assertNoLeakage, writeDecisionHint };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createLogger,
3
3
  init_logger
4
- } from "./roy-agent-core-6awgfh3x.js";
4
+ } from "./roy-agent-core-7f7t9wwp.js";
5
5
 
6
6
  // src/env/event-source/cli-command-handler.ts
7
7
  init_logger();
@@ -3,21 +3,21 @@ import {
3
3
  } from "./roy-agent-core-az13yzmc.js";
4
4
  import {
5
5
  BaseComponent
6
- } from "./roy-agent-core-gtdtzbs7.js";
6
+ } from "./roy-agent-core-pgvcf91v.js";
7
7
  import {
8
8
  globalHookManager,
9
9
  init_global_hook_manager
10
- } from "./roy-agent-core-v7mwj8eq.js";
10
+ } from "./roy-agent-core-cpcd24n2.js";
11
11
  import {
12
12
  init_context
13
- } from "./roy-agent-core-33hn1beg.js";
13
+ } from "./roy-agent-core-qqaak24r.js";
14
14
  import {
15
15
  getEnvContextOrEmpty
16
- } from "./roy-agent-core-hfyxv2kx.js";
16
+ } from "./roy-agent-core-7cbpmk4q.js";
17
17
  import {
18
18
  createLogger,
19
19
  init_logger
20
- } from "./roy-agent-core-6awgfh3x.js";
20
+ } from "./roy-agent-core-7f7t9wwp.js";
21
21
  import {
22
22
  __require
23
23
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -10,18 +10,18 @@ import {
10
10
  } from "./roy-agent-core-7hh0brvs.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-gtdtzbs7.js";
13
+ } from "./roy-agent-core-pgvcf91v.js";
14
14
  import {
15
15
  createHook
16
- } from "./roy-agent-core-7tce05jt.js";
16
+ } from "./roy-agent-core-ax9e9szb.js";
17
17
  import {
18
18
  globalHookManager,
19
19
  init_global_hook_manager
20
- } from "./roy-agent-core-v7mwj8eq.js";
20
+ } from "./roy-agent-core-cpcd24n2.js";
21
21
  import {
22
22
  createLogger,
23
23
  init_logger
24
- } from "./roy-agent-core-6awgfh3x.js";
24
+ } from "./roy-agent-core-7f7t9wwp.js";
25
25
 
26
26
  // src/env/prompt/types.ts
27
27
  import { z } from "zod";
@@ -3,12 +3,12 @@ import {
3
3
  hasDecoratorNodes,
4
4
  init_node_registry_helper,
5
5
  registerDecoratorNodeType
6
- } from "./roy-agent-core-dfqhc9ey.js";
6
+ } from "./roy-agent-core-es203w7p.js";
7
7
  import"./roy-agent-core-1ce3fqrk.js";
8
8
  import"./roy-agent-core-ddwa0n6h.js";
9
- import"./roy-agent-core-386wa4wy.js";
10
- import"./roy-agent-core-6awgfh3x.js";
11
- import"./roy-agent-core-jnszp0jq.js";
9
+ import"./roy-agent-core-qq96p0tj.js";
10
+ import"./roy-agent-core-7f7t9wwp.js";
11
+ import"./roy-agent-core-85xyctnb.js";
12
12
  import"./roy-agent-core-fs0mn2jk.js";
13
13
  init_node_registry_helper();
14
14
 
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  isToolUnavailableError,
3
3
  truncateOutputInline
4
- } from "./roy-agent-core-w2ev3z5q.js";
4
+ } from "./roy-agent-core-es467wsz.js";
5
5
  import {
6
6
  AgentRegistry
7
- } from "./roy-agent-core-06jakebr.js";
7
+ } from "./roy-agent-core-07fvy74y.js";
8
8
  import {
9
9
  enqueueToAddFakeUserMessage
10
- } from "./roy-agent-core-p8rf4z89.js";
10
+ } from "./roy-agent-core-f77k3gqt.js";
11
11
  import {
12
12
  SessionMessageConverter
13
- } from "./roy-agent-core-rfhxj8v2.js";
13
+ } from "./roy-agent-core-kmbct9yg.js";
14
14
  import {
15
15
  parseToolArgsStrict,
16
16
  safeParseToolArgs,
17
17
  withTimeout
18
- } from "./roy-agent-core-03k5drfp.js";
18
+ } from "./roy-agent-core-40rv283c.js";
19
19
  import {
20
20
  getCurrentBgTaskId
21
21
  } from "./roy-agent-core-c1v263jn.js";
@@ -31,20 +31,20 @@ import {
31
31
  } from "./roy-agent-core-7hh0brvs.js";
32
32
  import {
33
33
  BaseComponent
34
- } from "./roy-agent-core-gtdtzbs7.js";
34
+ } from "./roy-agent-core-pgvcf91v.js";
35
35
  import {
36
36
  globalHookManager,
37
37
  init_global_hook_manager
38
- } from "./roy-agent-core-v7mwj8eq.js";
38
+ } from "./roy-agent-core-cpcd24n2.js";
39
39
  import {
40
40
  init_context
41
- } from "./roy-agent-core-33hn1beg.js";
41
+ } from "./roy-agent-core-qqaak24r.js";
42
42
  import {
43
43
  getCurrentTaskId,
44
44
  getEnvContext,
45
45
  resolveEnvParentTaskId,
46
46
  runWithEnvContextAsync
47
- } from "./roy-agent-core-hfyxv2kx.js";
47
+ } from "./roy-agent-core-7cbpmk4q.js";
48
48
  import {
49
49
  TracedAs,
50
50
  agentRunParamFilter,
@@ -56,11 +56,11 @@ import {
56
56
  recordSessionMessagesParamFilter,
57
57
  toolExecParamFilter,
58
58
  toolExecResultFilter
59
- } from "./roy-agent-core-386wa4wy.js";
59
+ } from "./roy-agent-core-qq96p0tj.js";
60
60
  import {
61
61
  createLogger,
62
62
  init_logger
63
- } from "./roy-agent-core-6awgfh3x.js";
63
+ } from "./roy-agent-core-7f7t9wwp.js";
64
64
  import {
65
65
  __legacyDecorateClassTS,
66
66
  __require
@@ -260,7 +260,20 @@ var RETRY_EXHAUSTED_PATTERNS = [
260
260
  /max(?:imum)? ?retries/i,
261
261
  /too many retries/i,
262
262
  /\bretryerror\b/i,
263
- /all retries? failed/i
263
+ /all retries? failed/i,
264
+ /failed after \d+ attempts(?:\. last error| with non-retryable error)/i,
265
+ /ai_?retryerror/i
266
+ ];
267
+ var GATEWAY_NO_DEPLOYMENT_PATTERNS = [
268
+ /no deployments? available/i,
269
+ /try again in \d+ seconds?/i,
270
+ /cooldown_list/i,
271
+ /pre-call-checks/i
272
+ ];
273
+ var GATEWAY_LB_STRONG_PATTERNS = [
274
+ /no deployments? available/i,
275
+ /cooldown_list/i,
276
+ /pre-call-checks/i
264
277
  ];
265
278
  var HARD_BLOCKERS = [
266
279
  /\b401\b/,
@@ -340,6 +353,8 @@ function isFallbackEligibleError(error, hasFallback = true) {
340
353
  return true;
341
354
  if (CREDIT_PATTERNS.some((re) => re.test(text)))
342
355
  return true;
356
+ if (GATEWAY_LB_STRONG_PATTERNS.some((re) => re.test(text)))
357
+ return true;
343
358
  if (HARD_BLOCKERS.some((re) => re.test(text)))
344
359
  return false;
345
360
  if (status !== undefined && NON_FALLBACKABLE_STATUS.has(status))
@@ -356,6 +371,8 @@ function isFallbackEligibleError(error, hasFallback = true) {
356
371
  return true;
357
372
  if (RETRY_EXHAUSTED_PATTERNS.some((re) => re.test(text)))
358
373
  return true;
374
+ if (GATEWAY_NO_DEPLOYMENT_PATTERNS.some((re) => re.test(text)))
375
+ return true;
359
376
  return false;
360
377
  }
361
378
  function parseFallbackModel(fallbackModel) {
@@ -2,12 +2,12 @@ import {
2
2
  WorkflowRepository,
3
3
  migrateEmptyTagsToDefault,
4
4
  rowToWorkflow
5
- } from "./roy-agent-core-vwzan9v0.js";
6
- import"./roy-agent-core-gc6wcd7z.js";
5
+ } from "./roy-agent-core-r5wt1h3c.js";
6
+ import"./roy-agent-core-mcy5apay.js";
7
7
  import"./roy-agent-core-rvxg1wps.js";
8
- import"./roy-agent-core-386wa4wy.js";
9
- import"./roy-agent-core-6awgfh3x.js";
10
- import"./roy-agent-core-jnszp0jq.js";
8
+ import"./roy-agent-core-qq96p0tj.js";
9
+ import"./roy-agent-core-7f7t9wwp.js";
10
+ import"./roy-agent-core-85xyctnb.js";
11
11
  import"./roy-agent-core-fs0mn2jk.js";
12
12
  export {
13
13
  rowToWorkflow,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DAGManager,
3
3
  init_dag_manager
4
- } from "./roy-agent-core-p6a4v4fq.js";
4
+ } from "./roy-agent-core-mds8tqd0.js";
5
5
 
6
6
  // src/env/workflow/utils/node-output-contracts.ts
7
7
  var VIRTUAL_OUTPUT_FIELD = "output";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  TracedAs,
3
3
  init_decorator
4
- } from "./roy-agent-core-386wa4wy.js";
4
+ } from "./roy-agent-core-qq96p0tj.js";
5
5
  import {
6
6
  createLogger,
7
7
  init_logger
8
- } from "./roy-agent-core-6awgfh3x.js";
8
+ } from "./roy-agent-core-7f7t9wwp.js";
9
9
  import {
10
10
  __legacyDecorateClassTS
11
11
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -8,7 +8,7 @@ import {
8
8
  } from "./roy-agent-core-qxnbvgwe.js";
9
9
  import {
10
10
  BaseComponent
11
- } from "./roy-agent-core-gtdtzbs7.js";
11
+ } from "./roy-agent-core-pgvcf91v.js";
12
12
  import {
13
13
  __require
14
14
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  TempFileManager
3
- } from "../../shared/@ai-setting/roy-agent-core-wzp4tbsn.js";
4
- import"../../shared/@ai-setting/roy-agent-core-6awgfh3x.js";
5
- import"../../shared/@ai-setting/roy-agent-core-jnszp0jq.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-jvv2h3d6.js";
4
+ import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
5
+ import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
7
7
  export {
8
8
  TempFileManager
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.7.63",
3
+ "version": "1.7.65",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -1,10 +0,0 @@
1
- import {
2
- TagRepository
3
- } from "./roy-agent-core-gc6wcd7z.js";
4
- import"./roy-agent-core-386wa4wy.js";
5
- import"./roy-agent-core-6awgfh3x.js";
6
- import"./roy-agent-core-jnszp0jq.js";
7
- import"./roy-agent-core-fs0mn2jk.js";
8
- export {
9
- TagRepository
10
- };