@ai-setting/roy-agent-core 1.7.59 → 1.7.62

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 (138) hide show
  1. package/dist/config/index.js +8 -8
  2. package/dist/env/agent/agent-component.js +41 -0
  3. package/dist/env/agent/index.js +18 -16
  4. package/dist/env/commands/index.js +8 -8
  5. package/dist/env/context/index.js +4 -4
  6. package/dist/env/debug/index.js +8 -8
  7. package/dist/env/error-reply.js +18 -0
  8. package/dist/env/event-source/cli-command-handler.d.ts +90 -0
  9. package/dist/env/event-source/cli-command-handler.js +17 -0
  10. package/dist/env/event-source/event-source-handlers.d.ts +1 -0
  11. package/dist/env/event-source/event-source-handlers.js +58 -0
  12. package/dist/env/event-source/event-store.js +18 -0
  13. package/dist/env/event-source/idempotency-key.js +20 -0
  14. package/dist/env/event-source/index.d.ts +3 -1
  15. package/dist/env/event-source/index.js +37 -22
  16. package/dist/env/event-source/types.d.ts +21 -1
  17. package/dist/env/hook/index.js +6 -6
  18. package/dist/env/index.js +54 -48
  19. package/dist/env/lark-mention-utils.js +9 -0
  20. package/dist/env/llm/index.js +9 -9
  21. package/dist/env/log-trace/index.d.ts +1 -1
  22. package/dist/env/log-trace/index.js +12 -8
  23. package/dist/env/log-trace/logger.d.ts +2 -0
  24. package/dist/env/log-trace/logger.js +39 -0
  25. package/dist/env/mcp/index.js +9 -9
  26. package/dist/env/mcp/tool/index.js +2 -2
  27. package/dist/env/memory/index.js +9 -9
  28. package/dist/env/memory/plugin/index.js +2 -2
  29. package/dist/env/plugin/index.js +9 -9
  30. package/dist/env/prompt/index.js +8 -8
  31. package/dist/env/session/index.js +11 -11
  32. package/dist/env/session/storage/index.js +5 -5
  33. package/dist/env/skill/index.js +8 -8
  34. package/dist/env/task/delegate/delegate-tool.js +42 -0
  35. package/dist/env/task/delegate/index.js +13 -11
  36. package/dist/env/task/index.js +17 -16
  37. package/dist/env/task/mcp/index.d.ts +16 -0
  38. package/dist/env/task/mcp/index.js +222 -0
  39. package/dist/env/task/mcp/task-mcp-server.d.ts +142 -0
  40. package/dist/env/task/plugins/index.d.ts +1 -0
  41. package/dist/env/task/plugins/index.js +47 -12
  42. package/dist/env/task/plugins/lark-card-patch-notifier.js +42 -0
  43. package/dist/env/task/storage/index.js +4 -4
  44. package/dist/env/task/storage/migrations/log-migration.d.ts +19 -0
  45. package/dist/env/task/storage/sqlite-task-store.d.ts +29 -0
  46. package/dist/env/task/task-component.d.ts +48 -3
  47. package/dist/env/task/tools/index.js +4 -4
  48. package/dist/env/task/tools/task-types.d.ts +60 -11
  49. package/dist/env/tool/built-in/index.js +4 -4
  50. package/dist/env/tool/index.js +12 -11
  51. package/dist/env/tool/types.js +1 -0
  52. package/dist/env/workflow/engine/index.js +13 -13
  53. package/dist/env/workflow/hooks/index.js +8 -8
  54. package/dist/env/workflow/index.js +23 -23
  55. package/dist/env/workflow/nodes/index.js +3 -3
  56. package/dist/env/workflow/plugins/index.js +9 -9
  57. package/dist/env/workflow/service/index.js +3 -3
  58. package/dist/env/workflow/storage/index.js +4 -4
  59. package/dist/env/workflow/tools/index.js +15 -15
  60. package/dist/env/workflow/tools/run-workflow.d.ts +30 -0
  61. package/dist/env/workflow/utils/index.js +5 -5
  62. package/dist/env/workflow/utils/session-recovery.d.ts +27 -0
  63. package/dist/index.js +91 -73
  64. package/dist/shared/@ai-setting/{roy-agent-core-ygn5tzt1.js → roy-agent-core-06jakebr.js} +2 -2
  65. package/dist/shared/@ai-setting/{roy-agent-core-m68z3pw1.js → roy-agent-core-084zthqx.js} +1 -1
  66. package/dist/shared/@ai-setting/{roy-agent-core-cyefe8z5.js → roy-agent-core-2hkyp51n.js} +1 -1
  67. package/dist/shared/@ai-setting/{roy-agent-core-029r8kdw.js → roy-agent-core-2pma868e.js} +4 -4
  68. package/dist/shared/@ai-setting/{roy-agent-core-c7w2h47a.js → roy-agent-core-2veqhrxa.js} +3 -3
  69. package/dist/shared/@ai-setting/{roy-agent-core-t64nmayv.js → roy-agent-core-32ck9rqt.js} +2 -2
  70. package/dist/shared/@ai-setting/{roy-agent-core-m97jn2ra.js → roy-agent-core-33hn1beg.js} +1 -1
  71. package/dist/shared/@ai-setting/{roy-agent-core-8p63s836.js → roy-agent-core-386wa4wy.js} +1 -1
  72. package/dist/shared/@ai-setting/{roy-agent-core-kq9pz2a7.js → roy-agent-core-48h4zh60.js} +4 -4
  73. package/dist/shared/@ai-setting/{roy-agent-core-eanq305k.js → roy-agent-core-5bj0xfjk.js} +13 -27
  74. package/dist/shared/@ai-setting/{roy-agent-core-7q4wdze2.js → roy-agent-core-5mrynf9g.js} +1 -1
  75. package/dist/shared/@ai-setting/{roy-agent-core-rt115qfc.js → roy-agent-core-6awgfh3x.js} +14 -4
  76. package/dist/shared/@ai-setting/{roy-agent-core-9zhkdg6w.js → roy-agent-core-6wxww10t.js} +2 -2
  77. package/dist/shared/@ai-setting/{roy-agent-core-baaa4wtp.js → roy-agent-core-79gyka2q.js} +2 -2
  78. package/dist/shared/@ai-setting/{roy-agent-core-ytd5eztz.js → roy-agent-core-7tce05jt.js} +1 -1
  79. package/dist/shared/@ai-setting/{roy-agent-core-x6c45yqd.js → roy-agent-core-99nwgj84.js} +1 -1
  80. package/dist/shared/@ai-setting/roy-agent-core-9nvyffxg.js +414 -0
  81. package/dist/shared/@ai-setting/{roy-agent-core-e1w17tht.js → roy-agent-core-9qgrc9dy.js} +158 -158
  82. package/dist/shared/@ai-setting/{roy-agent-core-2ctyjy62.js → roy-agent-core-a08dpf71.js} +17 -2
  83. package/dist/shared/@ai-setting/{roy-agent-core-e250355z.js → roy-agent-core-a6cz4d23.js} +3 -3
  84. package/dist/shared/@ai-setting/{roy-agent-core-tze5596n.js → roy-agent-core-anb53t3v.js} +3 -3
  85. package/dist/shared/@ai-setting/{roy-agent-core-caevk7xd.js → roy-agent-core-arx535cs.js} +30 -8
  86. package/dist/shared/@ai-setting/{roy-agent-core-vh0qzb24.js → roy-agent-core-as0dd70m.js} +36 -15
  87. package/dist/shared/@ai-setting/{roy-agent-core-w93z6a42.js → roy-agent-core-bpvz1dqr.js} +12 -12
  88. package/dist/shared/@ai-setting/{roy-agent-core-ck60j1q9.js → roy-agent-core-bxkjk7zx.js} +2 -1
  89. package/dist/shared/@ai-setting/{roy-agent-core-hs41gx9w.js → roy-agent-core-c4t4y18j.js} +5 -5
  90. package/dist/shared/@ai-setting/{roy-agent-core-t4x089js.js → roy-agent-core-c57278kx.js} +1 -1
  91. package/dist/shared/@ai-setting/{roy-agent-core-em4hks9t.js → roy-agent-core-c8xvy6hj.js} +4 -4
  92. package/dist/shared/@ai-setting/{roy-agent-core-991pk4ss.js → roy-agent-core-cqpd41gf.js} +18 -16
  93. package/dist/shared/@ai-setting/{roy-agent-core-psg6f1v6.js → roy-agent-core-cxpgd415.js} +6 -6
  94. package/dist/shared/@ai-setting/{roy-agent-core-vgdhxbx3.js → roy-agent-core-dfqhc9ey.js} +2 -2
  95. package/dist/shared/@ai-setting/{roy-agent-core-6bradb0j.js → roy-agent-core-fqandv0a.js} +9 -107
  96. package/dist/shared/@ai-setting/{roy-agent-core-en2xqxs9.js → roy-agent-core-fr296a53.js} +39 -14
  97. package/dist/shared/@ai-setting/{roy-agent-core-rcgvmtms.js → roy-agent-core-gc6wcd7z.js} +1 -1
  98. package/dist/shared/@ai-setting/{roy-agent-core-7nb23tdd.js → roy-agent-core-gjsvehfs.js} +1 -1
  99. package/dist/shared/@ai-setting/{roy-agent-core-0kn3zt1t.js → roy-agent-core-gtdtzbs7.js} +2 -2
  100. package/dist/shared/@ai-setting/{roy-agent-core-84rs0c8d.js → roy-agent-core-gz2jnaan.js} +7 -7
  101. package/dist/shared/@ai-setting/{roy-agent-core-0yn7a78e.js → roy-agent-core-h3fwjbhp.js} +14 -14
  102. package/dist/shared/@ai-setting/{roy-agent-core-4096f575.js → roy-agent-core-hczj1ryh.js} +4 -4
  103. package/dist/shared/@ai-setting/{roy-agent-core-syyw58p9.js → roy-agent-core-hfyxv2kx.js} +2 -2
  104. package/dist/shared/@ai-setting/{roy-agent-core-d75t8gea.js → roy-agent-core-hwkc0bg2.js} +1 -1
  105. package/dist/shared/@ai-setting/{roy-agent-core-vath15kt.js → roy-agent-core-ja4sr63d.js} +6 -6
  106. package/dist/shared/@ai-setting/roy-agent-core-jagkferh.js +16 -0
  107. package/dist/shared/@ai-setting/roy-agent-core-jm136jzh.js +99 -0
  108. package/dist/shared/@ai-setting/{roy-agent-core-14bq77wr.js → roy-agent-core-jw63js86.js} +1 -1
  109. package/dist/shared/@ai-setting/{roy-agent-core-89sxsrc7.js → roy-agent-core-kmvw6b4v.js} +1 -1
  110. package/dist/shared/@ai-setting/{roy-agent-core-47s81t6g.js → roy-agent-core-kvq4a4p6.js} +2 -2
  111. package/dist/shared/@ai-setting/{roy-agent-core-c36335nw.js → roy-agent-core-m3w3ytxt.js} +15 -3
  112. package/dist/shared/@ai-setting/{roy-agent-core-64f22h1g.js → roy-agent-core-m880qz3y.js} +7 -1
  113. package/dist/shared/@ai-setting/{roy-agent-core-2fk8c9ax.js → roy-agent-core-mbwaxqs0.js} +3 -3
  114. package/dist/shared/@ai-setting/{roy-agent-core-jjhw9am6.js → roy-agent-core-mkpsz128.js} +4 -4
  115. package/dist/shared/@ai-setting/{roy-agent-core-20m8je6e.js → roy-agent-core-mrrv80jy.js} +1 -1
  116. package/dist/shared/@ai-setting/{roy-agent-core-6q5m1qk5.js → roy-agent-core-nmn853z0.js} +333 -1183
  117. package/dist/shared/@ai-setting/roy-agent-core-p37kh0kt.js +155 -0
  118. package/dist/shared/@ai-setting/{roy-agent-core-08njdcpj.js → roy-agent-core-p6a4v4fq.js} +1 -1
  119. package/dist/shared/@ai-setting/{roy-agent-core-gksw1gjb.js → roy-agent-core-p8rf4z89.js} +1 -1
  120. package/dist/shared/@ai-setting/roy-agent-core-pnj0zh25.js +0 -0
  121. package/dist/shared/@ai-setting/{roy-agent-core-q4gdfypk.js → roy-agent-core-prnry2mw.js} +3 -3
  122. package/dist/shared/@ai-setting/{roy-agent-core-84xtww7d.js → roy-agent-core-qmqe8ds3.js} +3 -3
  123. package/dist/shared/@ai-setting/{roy-agent-core-txwptxk1.js → roy-agent-core-sj4y3wdm.js} +3 -3
  124. package/dist/shared/@ai-setting/{roy-agent-core-fbjd7bt6.js → roy-agent-core-th92f833.js} +64 -29
  125. package/dist/shared/@ai-setting/{roy-agent-core-yphwdm9x.js → roy-agent-core-v7mwj8eq.js} +2 -2
  126. package/dist/shared/@ai-setting/{roy-agent-core-5f7myqnb.js → roy-agent-core-vvb4cyyy.js} +11 -5
  127. package/dist/shared/@ai-setting/{roy-agent-core-jjxdmedn.js → roy-agent-core-vwzan9v0.js} +2 -2
  128. package/dist/shared/@ai-setting/{roy-agent-core-fw6k4w1h.js → roy-agent-core-w2ev3z5q.js} +12 -14
  129. package/dist/shared/@ai-setting/roy-agent-core-w2h6xt6k.js +473 -0
  130. package/dist/shared/@ai-setting/{roy-agent-core-n0p0hwgd.js → roy-agent-core-wzp4tbsn.js} +1 -1
  131. package/dist/shared/@ai-setting/{roy-agent-core-ge87xbas.js → roy-agent-core-x1d6edkh.js} +1 -1
  132. package/dist/shared/@ai-setting/{roy-agent-core-8bngppw0.js → roy-agent-core-ye4bfzqg.js} +13 -13
  133. package/dist/shared/@ai-setting/{roy-agent-core-geh6j7bw.js → roy-agent-core-zjgckbdd.js} +2 -2
  134. package/dist/shared/@ai-setting/{roy-agent-core-hefarcp0.js → roy-agent-core-zy8vkbnk.js} +1 -1
  135. package/dist/test-utils/child-process-mock.js +23 -0
  136. package/dist/utils/temp-file-manager/index.js +2 -2
  137. package/package.json +76 -1
  138. /package/dist/shared/@ai-setting/{roy-agent-core-3ztzc83c.js → roy-agent-core-5enxfga2.js} +0 -0
@@ -0,0 +1,155 @@
1
+ import {
2
+ createLogger,
3
+ init_logger
4
+ } from "./roy-agent-core-6awgfh3x.js";
5
+
6
+ // src/env/event-source/cli-command-handler.ts
7
+ init_logger();
8
+ var logger = createLogger("cli-command:event-source");
9
+ var CLI_COMMAND_ES_TYPE = "cli-command";
10
+ var CLI_SESSION_CHAT_ID_PREFIX = "cli:";
11
+ function buildCliReplyChannel(params) {
12
+ const sid = params.sessionId?.trim() ? params.sessionId.trim() : "default";
13
+ return {
14
+ type: CLI_COMMAND_ES_TYPE,
15
+ chatId: `${CLI_SESSION_CHAT_ID_PREFIX}${sid}`,
16
+ params: { sink: "stdout", cliSessionId: sid }
17
+ };
18
+ }
19
+ function parseCliSessionChatId(chatId) {
20
+ if (!chatId || !chatId.startsWith(CLI_SESSION_CHAT_ID_PREFIX))
21
+ return;
22
+ const sid = chatId.slice(CLI_SESSION_CHAT_ID_PREFIX.length);
23
+ return sid.length > 0 ? sid : undefined;
24
+ }
25
+ function describeNotifyEvent(type, taskLabel, desc) {
26
+ const actionable = new Set([
27
+ "task.background.completed",
28
+ "task.background.failed",
29
+ "task.background.timeout",
30
+ "task.background.stopped"
31
+ ]).has(type);
32
+ switch (type) {
33
+ case "task.background.completed":
34
+ return { headline: `Sub-agent 完成了 ${taskLabel}「${desc}」。`, actionable };
35
+ case "task.background.failed":
36
+ return { headline: `Sub-agent 执行 ${taskLabel}「${desc}」失败。`, actionable };
37
+ case "task.background.timeout":
38
+ return { headline: `Sub-agent 执行 ${taskLabel}「${desc}」**超时**(未跑完)。`, actionable };
39
+ case "task.background.stopped":
40
+ return { headline: `Sub-agent 已停止 ${taskLabel}「${desc}」。`, actionable };
41
+ case "task.background.ask_user":
42
+ return { headline: `Sub-agent 在 ${taskLabel}「${desc}」中请求用户输入。`, actionable };
43
+ case "task.background.started":
44
+ return { headline: `Sub-agent 已启动 ${taskLabel}「${desc}」(后台运行中)。`, actionable };
45
+ case "task.background.progress":
46
+ return { headline: `Sub-agent 仍在执行 ${taskLabel}「${desc}」(进行中)。`, actionable };
47
+ default:
48
+ return { headline: `Sub-agent 更新了 ${taskLabel}「${desc}」。`, actionable };
49
+ }
50
+ }
51
+ function renderRuleNoticeSectionForCli(ruleNotice, headline) {
52
+ if (!ruleNotice || !ruleNotice.attempted) {
53
+ return `(本事件不直发规则回执)
54
+ ` + `→ 你的回复要把结果讲**完整**(终端用户只能从你这条输出知道结论)。`;
55
+ }
56
+ if (ruleNotice.delivered) {
57
+ const when = ruleNotice.sentAt ? new Date(ruleNotice.sentAt).toLocaleTimeString("zh-CN", {
58
+ hour12: false,
59
+ hour: "2-digit",
60
+ minute: "2-digit"
61
+ }) : "";
62
+ const sent = ruleNotice.text ? `:「${ruleNotice.text.replace(/\s*\n+\s*/g, " ")}」` : "";
63
+ return `✅ 系统已于 ${when || "刚才"} 向终端输出过下面这条${sent}
64
+ ` + `→ 你的回复**只发增量**:不要再重复「任务已结束」这类回执原文,` + `直接讲结论/交付 + 下一步选项。`;
65
+ }
66
+ return `❌ **回执未送达**(原因:${ruleNotice.error ?? "unknown"})
67
+ ` + `→ 用户目前**还不知道**「${headline}」这件事,必须由你在回复里讲清楚,` + `并且不要假装系统已经通知过。`;
68
+ }
69
+ var cliCommandHandler = {
70
+ type: CLI_COMMAND_ES_TYPE,
71
+ validateConfig(_config) {
72
+ return [];
73
+ },
74
+ createInstance(config) {
75
+ return {
76
+ config,
77
+ start: async () => {},
78
+ stop: async () => {},
79
+ isRunning: () => false,
80
+ getStatus: () => ({
81
+ id: config.id,
82
+ type: CLI_COMMAND_ES_TYPE,
83
+ running: false
84
+ })
85
+ };
86
+ },
87
+ async emitTriggerEvent(payload, store) {
88
+ const eventId = await store.insertTriggerEvent(payload, CLI_COMMAND_ES_TYPE);
89
+ logger.info(`[cliCommandHandler] emitTriggerEvent: id=${eventId}`, {
90
+ sessionId: payload.metadata?.sessionId,
91
+ cwd: payload.metadata?.cwd
92
+ });
93
+ return eventId;
94
+ },
95
+ extractReplyContext(event, profile) {
96
+ const meta = event.metadata ?? {};
97
+ return {
98
+ esType: CLI_COMMAND_ES_TYPE,
99
+ chatId: typeof meta.chatId === "string" ? meta.chatId : "",
100
+ messageId: typeof meta.messageId === "string" ? meta.messageId : "",
101
+ senderOpenId: typeof meta.senderId === "string" ? meta.senderId : "",
102
+ profile: profile ?? (typeof meta.profile === "string" ? meta.profile : undefined)
103
+ };
104
+ },
105
+ buildNotifyHandlePrompt(input) {
106
+ const { notifyEvent, triggerEvent, ruleNotice, subAgentResult, channel } = input;
107
+ const triggerMeta = triggerEvent.metadata ?? {};
108
+ const legacyPayload = notifyEvent.payload ?? {};
109
+ const rawTaskId = notifyEvent.taskId ?? legacyPayload.associatedTaskId;
110
+ const bgId = notifyEvent.backgroundTaskId ?? legacyPayload.backgroundTaskId;
111
+ const shortBgId = bgId ? bgId.split("_").pop() : undefined;
112
+ const taskLabel = rawTaskId !== undefined ? `Task #${rawTaskId}` : shortBgId ? `后台任务 ${shortBgId}` : "后台任务";
113
+ const desc = notifyEvent.description ?? legacyPayload.description ?? "后台任务";
114
+ const result = (subAgentResult?.summary && subAgentResult.summary.trim() ? subAgentResult.summary : undefined) ?? notifyEvent.result ?? notifyEvent.error ?? legacyPayload.result ?? legacyPayload.error ?? "(无结果)";
115
+ const cwd = typeof triggerMeta.cwd === "string" ? triggerMeta.cwd : "(未知)";
116
+ const cliSession = typeof triggerMeta.sessionId === "string" ? triggerMeta.sessionId : "(未知)";
117
+ const query = typeof triggerEvent.text === "string" && triggerEvent.text ? triggerEvent.text : "(未记录)";
118
+ const { headline } = describeNotifyEvent(notifyEvent.type, taskLabel, desc);
119
+ const channelLabel = channel?.esType ?? CLI_COMMAND_ES_TYPE;
120
+ return {
121
+ promptText: [
122
+ `# 后台任务通知(渠道:CLI 命令行)`,
123
+ ``,
124
+ `## 触发渠道`,
125
+ `- 渠道类型: \`${channelLabel}\`(用户在**终端**直接输入 query 触发,不是飞书消息)`,
126
+ `- 工作目录: \`${cwd}\``,
127
+ `- CLI session: \`${cliSession}\``,
128
+ `- 用户原始 query: ${query.length > 400 ? query.slice(0, 400) + "…" : query}`,
129
+ `- **回复方式: 直接输出到 stdout(终端)**。`,
130
+ ``,
131
+ `⚠️ **本渠道没有 IM 通道,不要调用 lark-cli**。`,
132
+ ` 不要尝试 \`lark-cli im +messages-send\` / \`+messages-reply\`,`,
133
+ ` 不要编造 chatId(\`cli:*\` 不是真实飞书会话,发过去必然失败),`,
134
+ ` 也不要调用任何飞书相关工具。用户就在终端前等你的文字输出。`,
135
+ ``,
136
+ `## 系统回执`,
137
+ renderRuleNoticeSectionForCli(ruleNotice, headline),
138
+ ``,
139
+ `## 事件`,
140
+ headline,
141
+ ``,
142
+ `## Sub-agent 输出`,
143
+ result,
144
+ ``,
145
+ `## 你要做什么`,
146
+ `1. 把上面 Sub-agent 的结论整理成**给终端用户直接读的一段话**。`,
147
+ `2. **直接输出这段文字**(它就是用户看到的内容),不要包 JSON、不要写文件。`,
148
+ `3. 若「系统回执」显示已送达,只讲**增量**;未送达则把结论讲完整。`
149
+ ].join(`
150
+ `)
151
+ };
152
+ }
153
+ };
154
+
155
+ export { CLI_COMMAND_ES_TYPE, CLI_SESSION_CHAT_ID_PREFIX, buildCliReplyChannel, parseCliSessionChatId, cliCommandHandler };
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  TracedAs,
7
7
  init_decorator
8
- } from "./roy-agent-core-8p63s836.js";
8
+ } from "./roy-agent-core-386wa4wy.js";
9
9
  import {
10
10
  __esm,
11
11
  __legacyDecorateClassTS
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_decorator,
3
3
  wrapFunction
4
- } from "./roy-agent-core-8p63s836.js";
4
+ } from "./roy-agent-core-386wa4wy.js";
5
5
 
6
6
  // src/env/task/plugins/fake-user-message-helper.ts
7
7
  init_decorator();
@@ -7,14 +7,14 @@ import {
7
7
  import {
8
8
  getCurrentProcessRegistry,
9
9
  killProcessTree
10
- } from "./roy-agent-core-14bq77wr.js";
10
+ } from "./roy-agent-core-jw63js86.js";
11
11
  import {
12
12
  init_decorator,
13
13
  init_trace_filters,
14
14
  toolExecResultFilter,
15
15
  toolInvokeParamFilter,
16
16
  wrapFunction
17
- } from "./roy-agent-core-8p63s836.js";
17
+ } from "./roy-agent-core-386wa4wy.js";
18
18
  import {
19
19
  createLogger,
20
20
  exports_tracer_provider,
@@ -22,7 +22,7 @@ import {
22
22
  init_propagation,
23
23
  init_tracer_provider,
24
24
  propagation
25
- } from "./roy-agent-core-rt115qfc.js";
25
+ } from "./roy-agent-core-6awgfh3x.js";
26
26
  import {
27
27
  __toCommonJS
28
28
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  adaptMcpTool
3
- } from "./roy-agent-core-m68z3pw1.js";
3
+ } from "./roy-agent-core-084zthqx.js";
4
4
  import {
5
5
  ComponentError,
6
6
  ErrorCodes
@@ -10,11 +10,11 @@ import {
10
10
  } from "./roy-agent-core-7hh0brvs.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-0kn3zt1t.js";
13
+ } from "./roy-agent-core-gtdtzbs7.js";
14
14
  import {
15
15
  createLogger,
16
16
  init_logger
17
- } from "./roy-agent-core-rt115qfc.js";
17
+ } from "./roy-agent-core-6awgfh3x.js";
18
18
  import {
19
19
  ensureFallbackNpmPrefix,
20
20
  isUsableNpmPrefix
@@ -12,16 +12,16 @@ import {
12
12
  import {
13
13
  globalHookManager,
14
14
  init_global_hook_manager
15
- } from "./roy-agent-core-yphwdm9x.js";
15
+ } from "./roy-agent-core-v7mwj8eq.js";
16
16
  import {
17
17
  TracedAs,
18
18
  init_decorator,
19
19
  wrapFunction
20
- } from "./roy-agent-core-8p63s836.js";
20
+ } from "./roy-agent-core-386wa4wy.js";
21
21
  import {
22
22
  createLogger,
23
23
  init_logger
24
- } from "./roy-agent-core-rt115qfc.js";
24
+ } from "./roy-agent-core-6awgfh3x.js";
25
25
  import {
26
26
  __esm,
27
27
  __legacyDecorateClassTS
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  TracedAs,
3
3
  init_decorator
4
- } from "./roy-agent-core-8p63s836.js";
4
+ } from "./roy-agent-core-386wa4wy.js";
5
5
  import {
6
6
  createLogger,
7
7
  init_logger
8
- } from "./roy-agent-core-rt115qfc.js";
8
+ } from "./roy-agent-core-6awgfh3x.js";
9
9
  import {
10
10
  __esm,
11
11
  __export,
@@ -14,42 +14,50 @@ import {
14
14
  __toCommonJS
15
15
  } from "./roy-agent-core-fs0mn2jk.js";
16
16
 
17
+ // src/env/task/storage/migrations/log-migration.ts
18
+ function logMigration(message) {
19
+ process.stderr.write(`${message}
20
+ `);
21
+ }
22
+ var init_log_migration = () => {};
23
+
17
24
  // src/env/task/storage/migrations/001_add_project_path_context.ts
18
25
  var exports_001_add_project_path_context = {};
19
26
  __export(exports_001_add_project_path_context, {
20
27
  runMigration: () => runMigration
21
28
  });
22
29
  function runMigration(dbPath) {
23
- console.log(`[Migration 001] Starting migration for: ${dbPath}`);
30
+ logMigration(`[Migration 001] Starting migration for: ${dbPath}`);
24
31
  const db = createCompatibleDatabase(dbPath);
25
32
  try {
26
33
  try {
27
34
  db.run(`ALTER TABLE task ADD COLUMN project_path TEXT`);
28
- console.log(`[Migration 001] Added project_path column`);
35
+ logMigration(`[Migration 001] Added project_path column`);
29
36
  } catch (e) {
30
37
  if (e.message?.includes("duplicate column name")) {
31
- console.log(`[Migration 001] project_path column already exists, skipping`);
38
+ logMigration(`[Migration 001] project_path column already exists, skipping`);
32
39
  } else {
33
40
  throw e;
34
41
  }
35
42
  }
36
43
  try {
37
44
  db.run(`ALTER TABLE task ADD COLUMN context TEXT`);
38
- console.log(`[Migration 001] Added context column`);
45
+ logMigration(`[Migration 001] Added context column`);
39
46
  } catch (e) {
40
47
  if (e.message?.includes("duplicate column name")) {
41
- console.log(`[Migration 001] context column already exists, skipping`);
48
+ logMigration(`[Migration 001] context column already exists, skipping`);
42
49
  } else {
43
50
  throw e;
44
51
  }
45
52
  }
46
- console.log(`[Migration 001] Migration completed successfully`);
53
+ logMigration(`[Migration 001] Migration completed successfully`);
47
54
  } finally {
48
55
  db.close();
49
56
  }
50
57
  }
51
58
  var init_001_add_project_path_context = __esm(() => {
52
59
  init_sqlite_task_store();
60
+ init_log_migration();
53
61
  if (false) {}
54
62
  });
55
63
 
@@ -59,26 +67,27 @@ __export(exports_002_add_task_type, {
59
67
  runMigration: () => runMigration2
60
68
  });
61
69
  function runMigration2(dbPath) {
62
- console.log(`[Migration 002] Starting migration for: ${dbPath}`);
70
+ logMigration(`[Migration 002] Starting migration for: ${dbPath}`);
63
71
  const db = createCompatibleDatabase(dbPath);
64
72
  try {
65
73
  try {
66
74
  db.run(`ALTER TABLE task ADD COLUMN type TEXT NOT NULL DEFAULT 'normal'`);
67
- console.log(`[Migration 002] Added type column`);
75
+ logMigration(`[Migration 002] Added type column`);
68
76
  } catch (e) {
69
77
  if (e.message?.includes("duplicate column name")) {
70
- console.log(`[Migration 002] type column already exists, skipping`);
78
+ logMigration(`[Migration 002] type column already exists, skipping`);
71
79
  } else {
72
80
  throw e;
73
81
  }
74
82
  }
75
- console.log(`[Migration 002] Migration completed successfully`);
83
+ logMigration(`[Migration 002] Migration completed successfully`);
76
84
  } finally {
77
85
  db.close();
78
86
  }
79
87
  }
80
88
  var init_002_add_task_type = __esm(() => {
81
89
  init_sqlite_task_store();
90
+ init_log_migration();
82
91
  if (false) {}
83
92
  });
84
93
 
@@ -88,26 +97,27 @@ __export(exports_003_add_process_description, {
88
97
  runMigration: () => runMigration3
89
98
  });
90
99
  function runMigration3(dbPath) {
91
- console.log(`[Migration 003] Starting migration for: ${dbPath}`);
100
+ logMigration(`[Migration 003] Starting migration for: ${dbPath}`);
92
101
  const db = createCompatibleDatabase(dbPath);
93
102
  try {
94
103
  try {
95
104
  db.run(`ALTER TABLE task_operation ADD COLUMN process_description TEXT NOT NULL DEFAULT ''`);
96
- console.log(`[Migration 003] Added process_description column`);
105
+ logMigration(`[Migration 003] Added process_description column`);
97
106
  } catch (e) {
98
107
  if (e.message?.includes("duplicate column name")) {
99
- console.log(`[Migration 003] process_description column already exists, skipping`);
108
+ logMigration(`[Migration 003] process_description column already exists, skipping`);
100
109
  } else {
101
110
  throw e;
102
111
  }
103
112
  }
104
- console.log(`[Migration 003] Migration completed successfully`);
113
+ logMigration(`[Migration 003] Migration completed successfully`);
105
114
  } finally {
106
115
  db.close();
107
116
  }
108
117
  }
109
118
  var init_003_add_process_description = __esm(() => {
110
119
  init_sqlite_task_store();
120
+ init_log_migration();
111
121
  if (false) {}
112
122
  });
113
123
 
@@ -117,7 +127,7 @@ __export(exports_004_rename_action_to_milestone, {
117
127
  runMigration: () => runMigration4
118
128
  });
119
129
  function runMigration4(dbPath) {
120
- console.log(`[Migration 004] Starting migration for: ${dbPath}`);
130
+ logMigration(`[Migration 004] Starting migration for: ${dbPath}`);
121
131
  const db = createCompatibleDatabase(dbPath);
122
132
  try {
123
133
  const existingColumns = new Set;
@@ -129,14 +139,14 @@ function runMigration4(dbPath) {
129
139
  const hasNew = existingColumns.has(newName);
130
140
  if (hasOld && !hasNew) {
131
141
  db.run(`ALTER TABLE task_operation RENAME COLUMN ${oldName} TO ${newName}`);
132
- console.log(`[Migration 004] Renamed ${oldName} -> ${newName}`);
142
+ logMigration(`[Migration 004] Renamed ${oldName} -> ${newName}`);
133
143
  } else if (hasNew) {
134
- console.log(`[Migration 004] ${newName} already exists, skipping rename of ${oldName}`);
144
+ logMigration(`[Migration 004] ${newName} already exists, skipping rename of ${oldName}`);
135
145
  } else {
136
- console.log(`[Migration 004] ${oldName} not present, skipping rename to ${newName}`);
146
+ logMigration(`[Migration 004] ${oldName} not present, skipping rename to ${newName}`);
137
147
  }
138
148
  }
139
- console.log(`[Migration 004] Migration completed successfully`);
149
+ logMigration(`[Migration 004] Migration completed successfully`);
140
150
  } finally {
141
151
  db.close();
142
152
  }
@@ -144,6 +154,7 @@ function runMigration4(dbPath) {
144
154
  var RENAME_MAP;
145
155
  var init_004_rename_action_to_milestone = __esm(() => {
146
156
  init_sqlite_task_store();
157
+ init_log_migration();
147
158
  RENAME_MAP = [
148
159
  { oldName: "action_type", newName: "milestone_type" },
149
160
  { oldName: "action_title", newName: "milestone_title" },
@@ -158,7 +169,7 @@ __export(exports_005_convert_blob_description_to_text, {
158
169
  runMigration: () => runMigration5
159
170
  });
160
171
  function runMigration5(dbPath) {
161
- console.log(`[Migration 005] Starting migration for: ${dbPath}`);
172
+ logMigration(`[Migration 005] Starting migration for: ${dbPath}`);
162
173
  const db = createCompatibleDatabase(dbPath);
163
174
  const result = {
164
175
  blobCountBefore: 0,
@@ -168,21 +179,21 @@ function runMigration5(dbPath) {
168
179
  try {
169
180
  const tableCheck = db.query("SELECT name FROM sqlite_master WHERE type='table' AND name='task'").all();
170
181
  if (tableCheck.length === 0) {
171
- console.log(`[Migration 005] task table does not exist, skipping`);
182
+ logMigration(`[Migration 005] task table does not exist, skipping`);
172
183
  return result;
173
184
  }
174
185
  const beforeRows = db.query("SELECT COUNT(*) as cnt FROM task WHERE typeof(description) = 'blob'").all();
175
186
  result.blobCountBefore = beforeRows[0]?.cnt ?? 0;
176
187
  if (result.blobCountBefore === 0) {
177
- console.log(`[Migration 005] No BLOB descriptions found, no action needed`);
188
+ logMigration(`[Migration 005] No BLOB descriptions found, no action needed`);
178
189
  return result;
179
190
  }
180
191
  db.run("UPDATE task SET description = CAST(description AS TEXT) WHERE typeof(description) = 'blob'");
181
192
  result.ran = true;
182
193
  const afterRows = db.query("SELECT COUNT(*) as cnt FROM task WHERE typeof(description) = 'blob'").all();
183
194
  result.blobCountAfter = afterRows[0]?.cnt ?? 0;
184
- console.log(`[Migration 005] Converted ${result.blobCountBefore - result.blobCountAfter} BLOB description(s) to TEXT`);
185
- console.log(`[Migration 005] Migration completed successfully`);
195
+ logMigration(`[Migration 005] Converted ${result.blobCountBefore - result.blobCountAfter} BLOB description(s) to TEXT`);
196
+ logMigration(`[Migration 005] Migration completed successfully`);
186
197
  } finally {
187
198
  db.close();
188
199
  }
@@ -190,6 +201,7 @@ function runMigration5(dbPath) {
190
201
  }
191
202
  var init_005_convert_blob_description_to_text = __esm(() => {
192
203
  init_sqlite_task_store();
204
+ init_log_migration();
193
205
  if (false) {}
194
206
  });
195
207
 
@@ -199,13 +211,20 @@ function getDatabaseClass() {
199
211
  if (typeof Bun !== "undefined") {
200
212
  const { Database } = __require("bun:sqlite");
201
213
  return Database;
202
- } else {
203
- return __require("better-sqlite3");
204
214
  }
215
+ try {
216
+ const { DatabaseSync } = __require("node:sqlite");
217
+ if (typeof DatabaseSync === "function") {
218
+ return DatabaseSync;
219
+ }
220
+ } catch {}
221
+ return __require("better-sqlite3");
205
222
  }
206
223
  function createCompatibleDatabase(path) {
207
224
  const Database = getDatabaseClass();
208
- const db = new Database(path);
225
+ return createCompatibleDatabaseFrom(new Database(path));
226
+ }
227
+ function createCompatibleDatabaseFrom(db) {
209
228
  if (typeof db.run !== "function") {
210
229
  db.run = function(sql, ...params) {
211
230
  if (params.length > 0) {
@@ -215,6 +234,22 @@ function createCompatibleDatabase(path) {
215
234
  }
216
235
  };
217
236
  }
237
+ db.query = function(sql, ...params) {
238
+ if (params.length === 0) {
239
+ const stmt2 = this.prepare(sql);
240
+ return {
241
+ all: () => stmt2.all(),
242
+ get: () => stmt2.get(),
243
+ run: () => stmt2.run()
244
+ };
245
+ }
246
+ const stmt = this.prepare(sql);
247
+ return {
248
+ all: (...extra) => stmt.all(...params, ...extra),
249
+ get: (...extra) => stmt.get(...params, ...extra),
250
+ run: (...extra) => stmt.run(...params, ...extra)
251
+ };
252
+ };
218
253
  return db;
219
254
  }
220
255
  function getDefaultDataDir() {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  init_context
3
- } from "./roy-agent-core-m97jn2ra.js";
3
+ } from "./roy-agent-core-33hn1beg.js";
4
4
  import {
5
5
  getEnvContext
6
- } from "./roy-agent-core-syyw58p9.js";
6
+ } from "./roy-agent-core-hfyxv2kx.js";
7
7
  import {
8
8
  __esm
9
9
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -6,7 +6,7 @@ import {
6
6
  PiAiAdapter,
7
7
  invoke,
8
8
  invokeNonStream
9
- } from "./roy-agent-core-e1w17tht.js";
9
+ } from "./roy-agent-core-9qgrc9dy.js";
10
10
  import {
11
11
  ContextError,
12
12
  ErrorCodes
@@ -17,12 +17,12 @@ import {
17
17
  } from "./roy-agent-core-7hh0brvs.js";
18
18
  import {
19
19
  BaseComponent
20
- } from "./roy-agent-core-0kn3zt1t.js";
20
+ } from "./roy-agent-core-gtdtzbs7.js";
21
21
  import {
22
22
  LLMHookPoints,
23
23
  globalHookManager,
24
24
  init_global_hook_manager
25
- } from "./roy-agent-core-yphwdm9x.js";
25
+ } from "./roy-agent-core-v7mwj8eq.js";
26
26
  import {
27
27
  TracedAs,
28
28
  embedParamFilter,
@@ -32,11 +32,11 @@ import {
32
32
  llmInvokeParamFilter,
33
33
  llmInvokeResultFilter,
34
34
  wrapFunction
35
- } from "./roy-agent-core-8p63s836.js";
35
+ } from "./roy-agent-core-386wa4wy.js";
36
36
  import {
37
37
  createLogger,
38
38
  init_logger
39
- } from "./roy-agent-core-rt115qfc.js";
39
+ } from "./roy-agent-core-6awgfh3x.js";
40
40
  import {
41
41
  __legacyDecorateClassTS,
42
42
  __require
@@ -354,6 +354,12 @@ class LLMTransform {
354
354
  const type = def.type || "";
355
355
  const isV3 = typeName.startsWith("Zod");
356
356
  const isV4 = !isV3 && type !== "";
357
+ if (typeName === "ZodEffects" || type === "pipe" || type === "transform") {
358
+ const inner = def.schema;
359
+ if (inner)
360
+ return this.extractZodSchema(inner);
361
+ return {};
362
+ }
357
363
  if (isV3 && typeName === "ZodObject" || isV4 && type === "object") {
358
364
  let shape;
359
365
  if (isV3) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TagRepository
3
- } from "./roy-agent-core-rcgvmtms.js";
3
+ } from "./roy-agent-core-gc6wcd7z.js";
4
4
  import {
5
5
  exports_search_query_parser,
6
6
  init_search_query_parser
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  createLogger,
10
10
  init_logger
11
- } from "./roy-agent-core-rt115qfc.js";
11
+ } from "./roy-agent-core-6awgfh3x.js";
12
12
  import {
13
13
  __require,
14
14
  __toCommonJS
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TempFileManager
3
- } from "./roy-agent-core-n0p0hwgd.js";
3
+ } from "./roy-agent-core-wzp4tbsn.js";
4
4
  import {
5
5
  AskUserError,
6
6
  init_workflow_hil
@@ -11,27 +11,27 @@ import {
11
11
  } from "./roy-agent-core-7hh0brvs.js";
12
12
  import {
13
13
  BaseComponent
14
- } from "./roy-agent-core-0kn3zt1t.js";
14
+ } from "./roy-agent-core-gtdtzbs7.js";
15
15
  import {
16
16
  ToolHookPoints,
17
17
  globalHookManager,
18
18
  init_global_hook_manager
19
- } from "./roy-agent-core-yphwdm9x.js";
19
+ } from "./roy-agent-core-v7mwj8eq.js";
20
20
  import {
21
21
  getCurrentTaskId,
22
22
  init_env_context
23
- } from "./roy-agent-core-syyw58p9.js";
23
+ } from "./roy-agent-core-hfyxv2kx.js";
24
24
  import {
25
25
  TracedAs,
26
26
  init_decorator,
27
27
  init_trace_filters,
28
28
  toolExecResultFilter,
29
29
  toolInvokeParamFilter
30
- } from "./roy-agent-core-8p63s836.js";
30
+ } from "./roy-agent-core-386wa4wy.js";
31
31
  import {
32
32
  createLogger,
33
33
  init_logger
34
- } from "./roy-agent-core-rt115qfc.js";
34
+ } from "./roy-agent-core-6awgfh3x.js";
35
35
  import {
36
36
  __legacyDecorateClassTS,
37
37
  __require
@@ -161,6 +161,12 @@ class ToolValidator {
161
161
  }
162
162
  }
163
163
 
164
+ // src/env/constants.ts
165
+ var TOOL_UNAVAILABLE_ERROR_RE = /^Tool (?:not found|disabled):/;
166
+ function isToolUnavailableError(message) {
167
+ return typeof message === "string" && TOOL_UNAVAILABLE_ERROR_RE.test(message);
168
+ }
169
+
164
170
  // src/env/tool/tool-component.ts
165
171
  import { z } from "zod";
166
172
  init_logger();
@@ -198,14 +204,6 @@ var TOOL_CONFIG_REGISTRATION = {
198
204
 
199
205
  // src/env/tool/tool-component.ts
200
206
  init_workflow_hil();
201
-
202
- // src/env/constants.ts
203
- var TOOL_UNAVAILABLE_ERROR_RE = /^Tool (?:not found|disabled):/;
204
- function isToolUnavailableError(message) {
205
- return typeof message === "string" && TOOL_UNAVAILABLE_ERROR_RE.test(message);
206
- }
207
-
208
- // src/env/tool/tool-component.ts
209
207
  init_env_context();
210
208
  var logger = createLogger("tool");
211
209
  var configComponentInstance = null;