@ai-setting/roy-agent-core 1.4.12 → 1.4.14

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 (127) hide show
  1. package/dist/packages/core/src/config/index.js +32 -0
  2. package/dist/packages/core/src/env/agent/index.js +24 -0
  3. package/dist/packages/core/src/env/commands/index.js +14 -0
  4. package/dist/packages/core/src/env/debug/formatters/index.js +11 -0
  5. package/dist/packages/core/src/env/debug/index.js +26 -0
  6. package/dist/packages/core/src/env/hook/index.js +29 -0
  7. package/dist/packages/core/src/env/index.js +81 -0
  8. package/dist/packages/core/src/env/llm/index.js +40 -0
  9. package/dist/packages/core/src/env/log-trace/index.js +83 -0
  10. package/dist/packages/core/src/env/mcp/index.js +39 -0
  11. package/dist/packages/core/src/env/mcp/tool/index.js +14 -0
  12. package/dist/packages/core/src/env/memory/built-in/index.js +11 -0
  13. package/dist/packages/core/src/env/memory/index.js +56 -0
  14. package/dist/packages/core/src/env/memory/plugin/index.js +36 -0
  15. package/dist/packages/core/src/env/prompt/index.js +20 -0
  16. package/dist/packages/core/src/env/session/index.js +25 -0
  17. package/dist/packages/core/src/env/session/storage/index.js +18 -0
  18. package/dist/packages/core/src/env/skill/index.js +34 -0
  19. package/dist/packages/core/src/env/skill/tool/index.js +9 -0
  20. package/dist/packages/core/src/env/task/delegate/index.js +18 -0
  21. package/dist/packages/core/src/env/task/hooks/index.js +7 -0
  22. package/dist/packages/core/src/env/task/index.js +30 -0
  23. package/dist/packages/core/src/env/task/plugins/index.js +23 -0
  24. package/dist/packages/core/src/env/task/storage/index.js +14 -0
  25. package/dist/packages/core/src/env/task/tools/index.js +17 -0
  26. package/dist/packages/core/src/env/task/tools/operation/index.js +15 -0
  27. package/dist/packages/core/src/env/tool/built-in/index.js +25 -0
  28. package/dist/packages/core/src/env/tool/index.js +39 -0
  29. package/dist/packages/core/src/env/workflow/decorators/index.js +27 -0
  30. package/dist/packages/core/src/env/workflow/engine/index.js +28 -0
  31. package/dist/packages/core/src/env/workflow/index.js +132 -0
  32. package/dist/packages/core/src/env/workflow/nodes/index.js +19 -0
  33. package/dist/packages/core/src/env/workflow/service/index.js +13 -0
  34. package/dist/packages/core/src/env/workflow/storage/index.js +27 -0
  35. package/dist/packages/core/src/env/workflow/tools/index.js +159 -0
  36. package/dist/packages/core/src/env/workflow/types/index.js +94 -0
  37. package/dist/packages/core/src/env/workflow/utils/index.js +637 -0
  38. package/dist/packages/core/src/index.js +398 -0
  39. package/dist/shared/@ai-setting/roy-agent-core-04fm8177.js +393 -0
  40. package/dist/shared/@ai-setting/roy-agent-core-04qgbjbe.js +172 -0
  41. package/dist/shared/@ai-setting/roy-agent-core-084qqd7t.js +11 -0
  42. package/dist/shared/@ai-setting/roy-agent-core-0gekht4e.js +1130 -0
  43. package/dist/shared/@ai-setting/roy-agent-core-0hdry23r.js +419 -0
  44. package/dist/shared/@ai-setting/roy-agent-core-0sgn3de4.js +102 -0
  45. package/dist/{env/task/tools/index.js → shared/@ai-setting/roy-agent-core-12x57kf1.js} +1 -59
  46. package/dist/shared/@ai-setting/roy-agent-core-1f3xrrm6.js +393 -0
  47. package/dist/shared/@ai-setting/roy-agent-core-1k28kg7h.js +368 -0
  48. package/dist/shared/@ai-setting/roy-agent-core-1z1zv5g8.js +258 -0
  49. package/dist/shared/@ai-setting/roy-agent-core-2hqxnaf3.js +851 -0
  50. package/dist/shared/@ai-setting/roy-agent-core-3dfq8awb.js +587 -0
  51. package/dist/shared/@ai-setting/roy-agent-core-3takar0s.js +93 -0
  52. package/dist/shared/@ai-setting/roy-agent-core-3tnb2005.js +117 -0
  53. package/dist/shared/@ai-setting/roy-agent-core-4vmcvkav.js +14 -0
  54. package/dist/shared/@ai-setting/roy-agent-core-4ws8atva.js +107 -0
  55. package/dist/{env/workflow/nodes/index.js → shared/@ai-setting/roy-agent-core-5fbp24se.js} +8 -55
  56. package/dist/shared/@ai-setting/roy-agent-core-5my94ywp.js +66 -0
  57. package/dist/shared/@ai-setting/roy-agent-core-6j0zcmwk.js +2146 -0
  58. package/dist/shared/@ai-setting/roy-agent-core-6w4pmxc7.js +266 -0
  59. package/dist/shared/@ai-setting/roy-agent-core-7vrk3add.js +10 -0
  60. package/dist/shared/@ai-setting/roy-agent-core-8dvbn7tw.js +64 -0
  61. package/dist/{env/memory/built-in/index.js → shared/@ai-setting/roy-agent-core-8mbmrwzs.js} +22 -76
  62. package/dist/shared/@ai-setting/roy-agent-core-8wzz66qe.js +620 -0
  63. package/dist/shared/@ai-setting/roy-agent-core-9ykq91jc.js +762 -0
  64. package/dist/shared/@ai-setting/roy-agent-core-dde19zke.js +1305 -0
  65. package/dist/shared/@ai-setting/roy-agent-core-f7g67gce.js +913 -0
  66. package/dist/{env/workflow/types/index.js → shared/@ai-setting/roy-agent-core-fq5mtxsy.js} +16 -154
  67. package/dist/{env/task/hooks/index.js → shared/@ai-setting/roy-agent-core-fs0mn2jk.js} +3 -18
  68. package/dist/{config/index.js → shared/@ai-setting/roy-agent-core-fvd9g6k8.js} +140 -605
  69. package/dist/shared/@ai-setting/roy-agent-core-gv1hrn3x.js +378 -0
  70. package/dist/{env/task/tools/operation/index.js → shared/@ai-setting/roy-agent-core-gy0wp5h7.js} +1 -58
  71. package/dist/shared/@ai-setting/roy-agent-core-hyza1gm7.js +15 -0
  72. package/dist/shared/@ai-setting/roy-agent-core-j8zx62zr.js +154 -0
  73. package/dist/shared/@ai-setting/roy-agent-core-jb2exr0d.js +442 -0
  74. package/dist/shared/@ai-setting/roy-agent-core-jv3b7v9w.js +57 -0
  75. package/dist/shared/@ai-setting/roy-agent-core-k1rxf9ya.js +513 -0
  76. package/dist/shared/@ai-setting/roy-agent-core-kydc9nwb.js +60 -0
  77. package/dist/shared/@ai-setting/roy-agent-core-m2x48hw6.js +97 -0
  78. package/dist/shared/@ai-setting/roy-agent-core-m6y668cc.js +377 -0
  79. package/dist/shared/@ai-setting/roy-agent-core-nczzf0ms.js +15 -0
  80. package/dist/shared/@ai-setting/roy-agent-core-nfj6knp5.js +36 -0
  81. package/dist/shared/@ai-setting/roy-agent-core-ntrp979d.js +204 -0
  82. package/dist/shared/@ai-setting/roy-agent-core-pd7g8z5v.js +1387 -0
  83. package/dist/shared/@ai-setting/roy-agent-core-pzk1syce.js +14 -0
  84. package/dist/shared/@ai-setting/roy-agent-core-q50tg9m2.js +862 -0
  85. package/dist/shared/@ai-setting/roy-agent-core-qg9tcaph.js +11 -0
  86. package/dist/shared/@ai-setting/roy-agent-core-qhyerewk.js +20 -0
  87. package/dist/shared/@ai-setting/roy-agent-core-qxybm159.js +82 -0
  88. package/dist/shared/@ai-setting/roy-agent-core-rh9dpkpw.js +549 -0
  89. package/dist/shared/@ai-setting/roy-agent-core-rr9p1g43.js +205 -0
  90. package/dist/{env/workflow/decorators/index.js → shared/@ai-setting/roy-agent-core-sbzvpfn7.js} +8 -173
  91. package/dist/shared/@ai-setting/roy-agent-core-t22nqt4d.js +788 -0
  92. package/dist/shared/@ai-setting/roy-agent-core-tkr5ynkh.js +200 -0
  93. package/dist/shared/@ai-setting/roy-agent-core-v4aabsf0.js +303 -0
  94. package/dist/{env/hook/index.js → shared/@ai-setting/roy-agent-core-w75rafhy.js} +3 -74
  95. package/dist/{env/debug/formatters/index.js → shared/@ai-setting/roy-agent-core-w76hqkmg.js} +11 -66
  96. package/dist/shared/@ai-setting/roy-agent-core-yfbgwes2.js +408 -0
  97. package/dist/shared/@ai-setting/roy-agent-core-yn761yve.js +299 -0
  98. package/dist/shared/@ai-setting/roy-agent-core-yrzmn4m1.js +492 -0
  99. package/dist/{env/workflow/service/index.js → shared/@ai-setting/roy-agent-core-yt8wdh2w.js} +1 -57
  100. package/package.json +3 -2
  101. package/dist/env/agent/index.js +0 -3035
  102. package/dist/env/commands/index.js +0 -1685
  103. package/dist/env/debug/index.js +0 -2300
  104. package/dist/env/index.js +0 -12591
  105. package/dist/env/llm/index.js +0 -2736
  106. package/dist/env/log-trace/index.js +0 -1779
  107. package/dist/env/mcp/index.js +0 -2173
  108. package/dist/env/mcp/tool/index.js +0 -1149
  109. package/dist/env/memory/index.js +0 -2171
  110. package/dist/env/memory/plugin/index.js +0 -1263
  111. package/dist/env/prompt/index.js +0 -2107
  112. package/dist/env/session/index.js +0 -3594
  113. package/dist/env/session/storage/index.js +0 -2049
  114. package/dist/env/skill/index.js +0 -1635
  115. package/dist/env/skill/tool/index.js +0 -114
  116. package/dist/env/task/delegate/index.js +0 -1844
  117. package/dist/env/task/index.js +0 -3578
  118. package/dist/env/task/plugins/index.js +0 -1626
  119. package/dist/env/task/storage/index.js +0 -1464
  120. package/dist/env/tool/built-in/index.js +0 -1151
  121. package/dist/env/tool/index.js +0 -2284
  122. package/dist/env/workflow/engine/index.js +0 -4391
  123. package/dist/env/workflow/index.js +0 -6214
  124. package/dist/env/workflow/storage/index.js +0 -1236
  125. package/dist/env/workflow/tools/index.js +0 -1081
  126. package/dist/env/workflow/utils/index.js +0 -1631
  127. package/dist/index.js +0 -22778
@@ -0,0 +1,378 @@
1
+ import {
2
+ TracedAs,
3
+ init_decorator
4
+ } from "./roy-agent-core-04qgbjbe.js";
5
+ import {
6
+ createLogger,
7
+ init_logger
8
+ } from "./roy-agent-core-yn761yve.js";
9
+ import {
10
+ __legacyDecorateClassTS
11
+ } from "./roy-agent-core-fs0mn2jk.js";
12
+
13
+ // packages/core/src/env/agent/summary-agent.ts
14
+ init_logger();
15
+ init_decorator();
16
+ var logger = createLogger("agent:summary");
17
+
18
+ class SummaryAgent {
19
+ promptComponent;
20
+ llmComponent;
21
+ config;
22
+ constructor(promptComponent, llmComponent, config) {
23
+ this.promptComponent = promptComponent;
24
+ this.llmComponent = llmComponent;
25
+ this.config = {
26
+ type: "summary",
27
+ promptName: "session/compact",
28
+ maxIterations: 1,
29
+ model: undefined,
30
+ ...config
31
+ };
32
+ }
33
+ async generateCompactHint(options) {
34
+ const { messages, sessionContext } = options;
35
+ logger.info("[SummaryAgent] Generating compact hint for session");
36
+ const formattedMessages = this.formatMessages(messages);
37
+ const systemPrompt = this.getHintGenerationSystemPrompt();
38
+ const userPrompt = this.buildHintGenerationUserPrompt(formattedMessages, sessionContext);
39
+ let response;
40
+ try {
41
+ response = await this.llmComponent.invoke({
42
+ messages: [
43
+ { role: "system", content: systemPrompt },
44
+ { role: "user", content: userPrompt }
45
+ ],
46
+ skipThresholdCheck: true
47
+ });
48
+ } catch (error) {
49
+ logger.error(`[SummaryAgent] Hint generation LLM invoke failed: ${error}`);
50
+ throw new Error(`LLM invoke failed: ${error}`);
51
+ }
52
+ const responseContent = response.output?.content || response.content || "";
53
+ const hint = this.parseHintResponse(responseContent);
54
+ logger.info("[SummaryAgent] Compact hint generated", { hint: hint.substring(0, 100) });
55
+ return {
56
+ hint,
57
+ rawResponse: responseContent
58
+ };
59
+ }
60
+ async run(options) {
61
+ const { messages, userContext, outputFormat, scenarioHint } = options;
62
+ logger.info("[SummaryAgent] Starting checkpoint generation", {
63
+ hasScenarioHint: !!scenarioHint
64
+ });
65
+ const formattedMessages = this.formatMessages(messages);
66
+ const systemPrompt = this.getSystemPrompt(scenarioHint);
67
+ const userPrompt = this.buildUserPrompt(formattedMessages, userContext);
68
+ let response;
69
+ try {
70
+ response = await this.llmComponent.invoke({
71
+ messages: [
72
+ { role: "system", content: systemPrompt },
73
+ { role: "user", content: userPrompt }
74
+ ],
75
+ model: this.config.model,
76
+ skipThresholdCheck: true
77
+ });
78
+ } catch (error) {
79
+ logger.error(`[SummaryAgent] LLM invoke failed: ${error}`);
80
+ throw new Error(`LLM invoke failed: ${error}`);
81
+ }
82
+ const responseContent = response.output?.content || response.content || "";
83
+ if (outputFormat === "json") {
84
+ const result = this.parseJsonResponse(responseContent);
85
+ logger.info(`[SummaryAgent] Checkpoint generated: "${result.title}"`);
86
+ return {
87
+ title: result.title || "Untitled Checkpoint",
88
+ processKeyPoints: result.processKeyPoints || [],
89
+ currentState: result.currentState || "",
90
+ nextSteps: result.nextSteps || [],
91
+ userIntents: result.userIntents || [],
92
+ rawResponse: responseContent
93
+ };
94
+ }
95
+ throw new Error(`Unsupported output format: ${outputFormat}`);
96
+ }
97
+ getSystemPrompt(scenarioHint) {
98
+ let prompt = `You are a professional session analyst assistant. Your task is to extract key information from a conversation and generate a structured checkpoint.
99
+
100
+ A checkpoint captures the progress and state of a session at a point in time. It should contain:
101
+
102
+ 1. **Process Key Points**: The key steps, discoveries, or decisions made during this part of the conversation
103
+ 2. **Current State**: The current progress and status at the end of the conversation
104
+ 3. **Next Steps**: Follow-up items and what needs to be done next
105
+ 4. **User Intents**: The underlying goals and intentions of the user (what they want to accomplish)
106
+
107
+ Be concise and accurate. Avoid redundancy. Each section should be appropriately sized - not too long.`;
108
+ if (scenarioHint && scenarioHint.trim()) {
109
+ prompt += `
110
+
111
+ ## Scenario Context
112
+
113
+ ${scenarioHint.trim()}`;
114
+ }
115
+ return prompt;
116
+ }
117
+ getHintGenerationSystemPrompt() {
118
+ return `You are a compact guidance prompt engineer. Your task is to analyze a conversation and generate a "compact guidance prompt" that will instruct the checkpoint generator on what information to extract and preserve during session compression.
119
+
120
+ **Purpose**: The guidance prompt will be used by the checkpoint generator to understand:
121
+ 1. What work is currently in progress
122
+ 2. What progress has been made
123
+ 3. What information MUST be preserved during compression (this is critical for task continuation)
124
+ 4. What information should be the focus of extraction
125
+
126
+ **Key Principle**: The preserved information should enable seamless task continuation. If critical details are lost during compression, the user will have to re-explain context when continuing this work later.
127
+
128
+ **Output Format**: A structured guidance prompt (3-4 sentences) covering:
129
+ 1. Current work type and what the user is trying to accomplish
130
+ 2. Current progress and key achievements
131
+ 3. CRITICAL information that MUST be preserved (decisions, findings, remaining issues)
132
+ 4. What the checkpoint generator should focus on when extracting information
133
+
134
+ **Example good outputs**:
135
+ 1. "Bug investigation: User is debugging LSP diagnostics not updating after file edits. Progress: identified root cause (getDiagnostics needs to read latest file content and trigger didChange notification), implemented fix, CI verified. CRITICAL to preserve: the fix implementation details (file path, code changes), that 2 agent-node-integration tests still fail due to test assertion timing issue (expects 'running' but completes in ~78ms) - this is unrelated to LSP work. Focus extraction on: root cause analysis, fix implementation, known remaining test issues."
136
+ 2. "Feature development: User is implementing JWT authentication for auth-service. Progress: designed auth flow, implemented token refresh logic, middleware partially done. CRITICAL to preserve: auth flow decisions (token storage, refresh strategy), completed middleware components, modules pending implementation. Focus extraction on: architectural decisions, completed components, pending work."
137
+ 3. "Refactoring: User is migrating data layer to repository pattern. Progress: migrated UserRepository and OrderRepository, 3 more pending. CRITICAL to preserve: pattern decisions (interface definitions, dependency injection approach), completed repositories, modules pending migration. Focus extraction on: pattern implementation details, completed vs pending modules."`;
138
+ }
139
+ buildHintGenerationUserPrompt(messages, sessionContext) {
140
+ let prompt = `Analyze the following conversation and generate a compact guidance prompt for checkpoint generation.
141
+
142
+ ## Your Task
143
+ Generate a structured guidance prompt (3-4 sentences) that will help the checkpoint generator understand:
144
+ 1. What work is currently in progress
145
+ 2. What progress has been made
146
+ 3. What information MUST be preserved during compression (critical for task continuation)
147
+ 4. What the checkpoint generator should focus on when extracting information
148
+
149
+ `;
150
+ if (sessionContext) {
151
+ const ctxLines = ["## Session Context"];
152
+ if (sessionContext.activeTaskTitle) {
153
+ ctxLines.push(`- Active Task: ${sessionContext.activeTaskTitle}`);
154
+ }
155
+ if (sessionContext.workingDirectory) {
156
+ ctxLines.push(`- Working Directory: ${sessionContext.workingDirectory}`);
157
+ }
158
+ if (sessionContext.recentActions && sessionContext.recentActions.length > 0) {
159
+ ctxLines.push(`- Recent Actions: ${sessionContext.recentActions.slice(-3).join(" → ")}`);
160
+ }
161
+ if (ctxLines.length > 1) {
162
+ prompt += ctxLines.join(`
163
+ `) + `
164
+
165
+ `;
166
+ }
167
+ }
168
+ prompt += `## Conversation to Analyze
169
+
170
+ ${messages}
171
+
172
+ `;
173
+ prompt += `---
174
+
175
+ `;
176
+ prompt += `## Output Format
177
+
178
+ `;
179
+ prompt += `Generate a structured guidance prompt covering:
180
+ `;
181
+ prompt += `1. Current work type and what the user is trying to accomplish
182
+ `;
183
+ prompt += `2. Current progress and key achievements
184
+ `;
185
+ prompt += `3. CRITICAL information that MUST be preserved (decisions, findings, remaining issues)
186
+ `;
187
+ prompt += `4. What to focus on during extraction
188
+
189
+ `;
190
+ prompt += `Wrap the output in a JSON object with a \`guidance_prompt\` key:
191
+
192
+ `;
193
+ prompt += `\`\`\`json
194
+ `;
195
+ prompt += `{
196
+ `;
197
+ prompt += ` "guidance_prompt": "Work type: ... Progress: ... CRITICAL to preserve: ... Focus extraction on: ..."
198
+ `;
199
+ prompt += `}
200
+ `;
201
+ prompt += `\`\`\`
202
+
203
+ `;
204
+ prompt += `IMPORTANT: The preserved information should enable seamless task continuation. If critical details are lost, the user will need to re-explain context when continuing this work.`;
205
+ return prompt;
206
+ }
207
+ buildUserPrompt(messages, userContext) {
208
+ let prompt = `Please analyze the following conversation and generate a checkpoint:
209
+
210
+ `;
211
+ if (userContext && userContext !== "无额外上下文") {
212
+ prompt += `## Context
213
+ ${userContext}
214
+
215
+ `;
216
+ }
217
+ prompt += `## Conversation Content
218
+
219
+ ${messages}
220
+
221
+ `;
222
+ prompt += `---
223
+
224
+ `;
225
+ prompt += `## Output Format
226
+
227
+ Please output in the following JSON format:
228
+
229
+ \`\`\`json
230
+ {
231
+ "title": "Brief checkpoint title (max 30 characters)",
232
+ "processKeyPoints": [
233
+ "Point 1: Description of key discovery or decision",
234
+ "Point 2: Description of important step or conclusion",
235
+ "Point 3: ..."
236
+ ],
237
+ "currentState": "Current state description explaining progress and status (50-100 characters)",
238
+ "nextSteps": [
239
+ "Next follow-up item 1",
240
+ "Next follow-up item 2"
241
+ ],
242
+ "userIntents": [
243
+ "User intent 1: what the user wants to accomplish",
244
+ "User intent 2: another goal or request",
245
+ "User intent 3: ..."
246
+ ]
247
+ }
248
+ \`\`\`
249
+
250
+ `;
251
+ prompt += `## Intent Extraction Guidelines
252
+
253
+ `;
254
+ prompt += `- Extract user intents from the ENTIRE conversation flow (both user and assistant messages)
255
+ `;
256
+ prompt += `- Focus on what the user WANTS to accomplish, not just what was discussed
257
+ `;
258
+ prompt += `- Include both explicit requests and inferred goals
259
+ `;
260
+ prompt += `- Aim for 2-5 intents, prioritize the most important ones
261
+ `;
262
+ prompt += `- Be concise and specific in intent descriptions
263
+ `;
264
+ prompt += `- Examples: "Fix authentication bug", "Optimize database performance", "Add unit tests for auth module"
265
+
266
+ `;
267
+ prompt += `Make sure the JSON output is valid and can be parsed.`;
268
+ return prompt;
269
+ }
270
+ formatMessages(messages) {
271
+ return messages.map((m, i) => `[${i}] ${m.role}: ${m.content}`).join(`
272
+
273
+ `);
274
+ }
275
+ parseJsonResponse(content) {
276
+ const jsonMatch = content.match(/```json\s*([\s\S]*?)\s*```/) || content.match(/```\s*([\s\S]*?)\s*```/) || [null, content];
277
+ const jsonStr = jsonMatch[1] || content;
278
+ try {
279
+ return JSON.parse(jsonStr.trim());
280
+ } catch {
281
+ const fixed = jsonStr.replace(/,\s*}/g, "}").replace(/,\s*]/g, "]").replace(/'/g, '"').trim();
282
+ try {
283
+ return JSON.parse(fixed);
284
+ } catch (e) {
285
+ logger.error(`[SummaryAgent] Failed to parse JSON: ${content}`);
286
+ throw new Error(`Failed to parse checkpoint JSON: ${e}`);
287
+ }
288
+ }
289
+ }
290
+ parseHintResponse(content) {
291
+ return parseCompactHintResponse(content);
292
+ }
293
+ }
294
+ __legacyDecorateClassTS([
295
+ TracedAs("summary-agent.generateCompactHint")
296
+ ], SummaryAgent.prototype, "generateCompactHint", null);
297
+ __legacyDecorateClassTS([
298
+ TracedAs("summary-agent.run", { recordParams: true, recordResult: true })
299
+ ], SummaryAgent.prototype, "run", null);
300
+ __legacyDecorateClassTS([
301
+ TracedAs("summary-agent.getHintGenerationSystemPrompt")
302
+ ], SummaryAgent.prototype, "getHintGenerationSystemPrompt", null);
303
+ __legacyDecorateClassTS([
304
+ TracedAs("summary-agent.buildHintGenerationUserPrompt")
305
+ ], SummaryAgent.prototype, "buildHintGenerationUserPrompt", null);
306
+ __legacyDecorateClassTS([
307
+ TracedAs("summary-agent.parseHintResponse")
308
+ ], SummaryAgent.prototype, "parseHintResponse", null);
309
+ function parseCompactHintResponse(content) {
310
+ const jsonResult = extractGuidanceFromJson(content);
311
+ if (jsonResult !== null) {
312
+ const trimmed = jsonResult.trim();
313
+ if (!trimmed) {
314
+ return "[Hint extraction failed]";
315
+ }
316
+ if (trimmed.length > 500) {
317
+ return trimmed.substring(0, 500) + "...";
318
+ }
319
+ return trimmed;
320
+ }
321
+ let text = content.replace(/```json\s*([\s\S]*?)\s*```/g, "$1").replace(/```markdown\s*([\s\S]*?)\s*```/g, "$1").replace(/```\s*([\s\S]*?)\s*```/g, "$1").trim();
322
+ if (!text) {
323
+ return "[Hint extraction failed]";
324
+ }
325
+ if (text.length > 500) {
326
+ return text.substring(0, 500) + "...";
327
+ }
328
+ return text;
329
+ }
330
+ function extractGuidanceFromJson(content) {
331
+ const jsonBlockMatch = content.match(/```json\s*([\s\S]*?)\s*```/);
332
+ if (jsonBlockMatch) {
333
+ const parsed2 = tryParseJson(jsonBlockMatch[1]);
334
+ const guidancePrompt2 = parsed2?.guidance_prompt;
335
+ if (typeof guidancePrompt2 === "string") {
336
+ return guidancePrompt2;
337
+ }
338
+ }
339
+ const plainBlockMatch = content.match(/```\s*([\s\S]*?)\s*```/);
340
+ if (plainBlockMatch) {
341
+ const parsed2 = tryParseJson(plainBlockMatch[1]);
342
+ const guidancePrompt2 = parsed2?.guidance_prompt;
343
+ if (typeof guidancePrompt2 === "string") {
344
+ return guidancePrompt2;
345
+ }
346
+ }
347
+ const jsonMatch = content.match(/\{[\s\S]*"guidance_prompt"[\s\S]*\}/);
348
+ if (jsonMatch) {
349
+ const parsed2 = tryParseJson(jsonMatch[0]);
350
+ const guidancePrompt2 = parsed2?.guidance_prompt;
351
+ if (typeof guidancePrompt2 === "string") {
352
+ return guidancePrompt2;
353
+ }
354
+ }
355
+ const parsed = tryParseJson(content.trim());
356
+ const guidancePrompt = parsed?.guidance_prompt;
357
+ if (typeof guidancePrompt === "string") {
358
+ return guidancePrompt;
359
+ }
360
+ return null;
361
+ }
362
+ function tryParseJson(str) {
363
+ if (!str || !str.trim()) {
364
+ return null;
365
+ }
366
+ try {
367
+ return JSON.parse(str.trim());
368
+ } catch {
369
+ try {
370
+ const fixed = str.replace(/,\s*}/g, "}").replace(/,\s*]/g, "]").trim();
371
+ return JSON.parse(fixed);
372
+ } catch {
373
+ return null;
374
+ }
375
+ }
376
+ }
377
+
378
+ export { SummaryAgent };
@@ -1,54 +1,3 @@
1
- // @bun
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toCommonJS = (from) => {
10
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
- if (entry)
12
- return entry;
13
- entry = __defProp({}, "__esModule", { value: true });
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (var key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(entry, key))
17
- __defProp(entry, key, {
18
- get: __accessProp.bind(from, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- __moduleCache.set(from, entry);
23
- return entry;
24
- };
25
- var __moduleCache;
26
- var __returnValue = (v) => v;
27
- function __exportSetter(name, newValue) {
28
- this[name] = __returnValue.bind(null, newValue);
29
- }
30
- var __export = (target, all) => {
31
- for (var name in all)
32
- __defProp(target, name, {
33
- get: all[name],
34
- enumerable: true,
35
- configurable: true,
36
- set: __exportSetter.bind(all, name)
37
- });
38
- };
39
- var __legacyDecorateClassTS = function(decorators, target, key, desc) {
40
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
41
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
42
- r = Reflect.decorate(decorators, target, key, desc);
43
- else
44
- for (var i = decorators.length - 1;i >= 0; i--)
45
- if (d = decorators[i])
46
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
47
- return c > 3 && r && Object.defineProperty(target, key, r), r;
48
- };
49
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
50
- var __require = import.meta.require;
51
-
52
1
  // packages/core/src/env/task/tools/operation/operation-types.ts
53
2
  import { z } from "zod";
54
3
  var ActionTypeEnum = z.enum([
@@ -261,10 +210,4 @@ function deleteOperationTool(taskComponent) {
261
210
  }
262
211
  };
263
212
  }
264
- export {
265
- updateOperationTool,
266
- listOperationsTool,
267
- getOperationTool,
268
- deleteOperationTool,
269
- createOperationTool
270
- };
213
+ export { createOperationTool, getOperationTool, listOperationsTool, updateOperationTool, deleteOperationTool };
@@ -0,0 +1,15 @@
1
+ import {
2
+ getDecoratorNodes,
3
+ hasDecoratorNodes,
4
+ init_node_registry_helper,
5
+ registerDecoratorNodeType
6
+ } from "./roy-agent-core-1z1zv5g8.js";
7
+ import"./roy-agent-core-3tnb2005.js";
8
+ import"./roy-agent-core-fs0mn2jk.js";
9
+ init_node_registry_helper();
10
+
11
+ export {
12
+ registerDecoratorNodeType,
13
+ hasDecoratorNodes,
14
+ getDecoratorNodes
15
+ };
@@ -0,0 +1,154 @@
1
+ import {
2
+ __esm,
3
+ __require
4
+ } from "./roy-agent-core-fs0mn2jk.js";
5
+
6
+ // packages/core/src/env/log-trace/span-storage.ts
7
+ class SQLiteSpanStorage {
8
+ db = null;
9
+ dbPath;
10
+ initialized = false;
11
+ constructor(dbPath) {
12
+ if (!dbPath) {
13
+ throw new Error("SQLiteSpanStorage requires a valid dbPath parameter");
14
+ }
15
+ if (dbPath === ":memory:") {
16
+ throw new Error("SQLiteSpanStorage does not support :memory: mode. Use a file path instead.");
17
+ }
18
+ this.dbPath = dbPath;
19
+ }
20
+ async initialize() {
21
+ if (this.initialized)
22
+ return;
23
+ const { Database } = __require("bun:sqlite");
24
+ const fs = __require("fs");
25
+ const path = __require("path");
26
+ const dir = path.dirname(this.dbPath);
27
+ if (!fs.existsSync(dir)) {
28
+ fs.mkdirSync(dir, { recursive: true });
29
+ }
30
+ this.db = new Database(this.dbPath);
31
+ this.db.run("PRAGMA journal_mode=WAL");
32
+ this.db.run("PRAGMA busy_timeout=5000");
33
+ this.db.run("PRAGMA synchronous=NORMAL");
34
+ this.db.run(`
35
+ CREATE TABLE IF NOT EXISTS span (
36
+ span_id TEXT PRIMARY KEY,
37
+ trace_id TEXT NOT NULL,
38
+ parent_span_id TEXT,
39
+ name TEXT NOT NULL,
40
+ kind TEXT NOT NULL,
41
+ status TEXT NOT NULL,
42
+ start_time INTEGER NOT NULL,
43
+ end_time INTEGER,
44
+ attributes TEXT,
45
+ result TEXT,
46
+ error TEXT,
47
+ time_created INTEGER NOT NULL
48
+ )
49
+ `);
50
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_span_trace ON span(trace_id)");
51
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_span_parent ON span(parent_span_id)");
52
+ this.initialized = true;
53
+ }
54
+ save(span) {
55
+ if (!this.db)
56
+ return;
57
+ const stmt = this.db.prepare(`
58
+ INSERT OR REPLACE INTO span
59
+ (span_id, trace_id, parent_span_id, name, kind, status, start_time, end_time, attributes, result, error, time_created)
60
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
61
+ `);
62
+ const resultValue = span.result !== undefined && span.result !== null ? typeof span.result === "string" ? span.result : JSON.stringify(span.result) : null;
63
+ stmt.run(span.spanId, span.traceId, span.parentSpanId || null, span.name, span.kind, span.status, span.startTime, span.endTime || null, JSON.stringify(span.attributes), resultValue, span.error || null, Date.now());
64
+ }
65
+ saveBatch(spans) {
66
+ for (const span of spans) {
67
+ this.save(span);
68
+ }
69
+ }
70
+ findByTraceId(traceId) {
71
+ if (!this.db)
72
+ return [];
73
+ const rows = this.db.prepare("SELECT * FROM span WHERE trace_id = ?").all(traceId);
74
+ return this.buildTree(rows.map(this.rowToSpan));
75
+ }
76
+ findBySpanId(spanId) {
77
+ if (!this.db)
78
+ return;
79
+ const row = this.db.prepare("SELECT * FROM span WHERE span_id = ?").get(spanId);
80
+ return row ? this.rowToSpan(row) : undefined;
81
+ }
82
+ listTraces(limit = 10) {
83
+ if (!this.db)
84
+ return [];
85
+ const rows = this.db.prepare(`
86
+ SELECT trace_id,
87
+ MIN(start_time) as start_time,
88
+ MAX(end_time) as end_time,
89
+ COUNT(*) as span_count
90
+ FROM span
91
+ GROUP BY trace_id
92
+ ORDER BY start_time DESC
93
+ LIMIT ?
94
+ `).all(limit);
95
+ return rows.map((row) => ({
96
+ traceId: row.trace_id,
97
+ rootSpanName: "unknown",
98
+ startTime: row.start_time,
99
+ endTime: row.end_time,
100
+ duration: row.end_time - row.start_time,
101
+ spanCount: row.span_count,
102
+ status: "ok"
103
+ }));
104
+ }
105
+ deleteByTraceId(traceId) {
106
+ if (this.db) {
107
+ this.db.prepare("DELETE FROM span WHERE trace_id = ?").run(traceId);
108
+ }
109
+ }
110
+ close() {
111
+ if (this.db) {
112
+ this.db.close();
113
+ this.db = null;
114
+ }
115
+ }
116
+ rowToSpan(row) {
117
+ return {
118
+ traceId: row.trace_id,
119
+ spanId: row.span_id,
120
+ parentSpanId: row.parent_span_id,
121
+ name: row.name,
122
+ kind: row.kind,
123
+ status: row.status,
124
+ startTime: row.start_time,
125
+ endTime: row.end_time,
126
+ attributes: row.attributes ? JSON.parse(row.attributes) : {},
127
+ result: row.result || undefined,
128
+ error: row.error || undefined
129
+ };
130
+ }
131
+ buildTree(spans) {
132
+ const spanMap = new Map;
133
+ const roots = [];
134
+ for (const span of spans) {
135
+ spanMap.set(span.spanId, { ...span, children: [] });
136
+ }
137
+ for (const span of spanMap.values()) {
138
+ if (span.parentSpanId) {
139
+ const parent = spanMap.get(span.parentSpanId);
140
+ if (parent) {
141
+ parent.children.push(span);
142
+ } else {
143
+ roots.push(span);
144
+ }
145
+ } else {
146
+ roots.push(span);
147
+ }
148
+ }
149
+ return roots;
150
+ }
151
+ }
152
+ var init_span_storage = () => {};
153
+
154
+ export { SQLiteSpanStorage, init_span_storage };