@ai-setting/roy-agent-core 1.4.13 → 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 (103) 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/{shared/chunk-1d4rwms4.js → packages/core/src/env/tool/built-in/index.js} +4 -4
  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/{chunk-ze20rksg.js → @ai-setting/roy-agent-core-0sgn3de4.js} +2 -2
  45. package/dist/shared/@ai-setting/roy-agent-core-12x57kf1.js +286 -0
  46. package/dist/shared/@ai-setting/roy-agent-core-1f3xrrm6.js +393 -0
  47. package/dist/shared/{chunk-q9j99fsm.js → @ai-setting/roy-agent-core-1k28kg7h.js} +6 -6
  48. package/dist/shared/{chunk-2b5kbhx3.js → @ai-setting/roy-agent-core-1z1zv5g8.js} +9 -117
  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/{chunk-25x2pdtp.js → @ai-setting/roy-agent-core-4ws8atva.js} +2 -2
  55. package/dist/shared/@ai-setting/roy-agent-core-5fbp24se.js +603 -0
  56. package/dist/shared/@ai-setting/roy-agent-core-5my94ywp.js +66 -0
  57. package/dist/shared/{chunk-rncy3rtd.js → @ai-setting/roy-agent-core-6j0zcmwk.js} +128 -1122
  58. package/dist/shared/@ai-setting/roy-agent-core-6w4pmxc7.js +266 -0
  59. package/dist/shared/{chunk-yqmx37vm.js → @ai-setting/roy-agent-core-7vrk3add.js} +2 -2
  60. package/dist/shared/@ai-setting/roy-agent-core-8dvbn7tw.js +64 -0
  61. package/dist/shared/@ai-setting/roy-agent-core-8mbmrwzs.js +171 -0
  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/shared/@ai-setting/roy-agent-core-fq5mtxsy.js +341 -0
  67. package/dist/shared/@ai-setting/roy-agent-core-fvd9g6k8.js +1205 -0
  68. package/dist/shared/@ai-setting/roy-agent-core-gv1hrn3x.js +378 -0
  69. package/dist/shared/@ai-setting/roy-agent-core-gy0wp5h7.js +213 -0
  70. package/dist/shared/{chunk-mf5xqbdh.js → @ai-setting/roy-agent-core-hyza1gm7.js} +3 -2
  71. package/dist/shared/{chunk-1qwabsm0.js → @ai-setting/roy-agent-core-j8zx62zr.js} +2 -2
  72. package/dist/shared/@ai-setting/roy-agent-core-jb2exr0d.js +442 -0
  73. package/dist/shared/@ai-setting/roy-agent-core-jv3b7v9w.js +57 -0
  74. package/dist/shared/@ai-setting/roy-agent-core-k1rxf9ya.js +513 -0
  75. package/dist/shared/@ai-setting/roy-agent-core-kydc9nwb.js +60 -0
  76. package/dist/shared/@ai-setting/roy-agent-core-m2x48hw6.js +97 -0
  77. package/dist/shared/@ai-setting/roy-agent-core-m6y668cc.js +377 -0
  78. package/dist/shared/{chunk-1aakcfp1.js → @ai-setting/roy-agent-core-nczzf0ms.js} +3 -3
  79. package/dist/shared/@ai-setting/roy-agent-core-nfj6knp5.js +36 -0
  80. package/dist/shared/@ai-setting/roy-agent-core-ntrp979d.js +204 -0
  81. package/dist/shared/@ai-setting/roy-agent-core-pd7g8z5v.js +1387 -0
  82. package/dist/shared/@ai-setting/roy-agent-core-pzk1syce.js +14 -0
  83. package/dist/shared/@ai-setting/roy-agent-core-q50tg9m2.js +862 -0
  84. package/dist/shared/{chunk-9qzt1v1p.js → @ai-setting/roy-agent-core-qg9tcaph.js} +3 -2
  85. package/dist/shared/{chunk-91bas8w5.js → @ai-setting/roy-agent-core-qhyerewk.js} +5 -5
  86. package/dist/shared/{chunk-1pf5mfgd.js → @ai-setting/roy-agent-core-qxybm159.js} +3 -3
  87. package/dist/shared/{chunk-g6j5n3gv.js → @ai-setting/roy-agent-core-rh9dpkpw.js} +10 -10
  88. package/dist/shared/{chunk-0q6s9wm6.js → @ai-setting/roy-agent-core-rr9p1g43.js} +7 -51
  89. package/dist/shared/@ai-setting/roy-agent-core-sbzvpfn7.js +284 -0
  90. package/dist/shared/@ai-setting/roy-agent-core-t22nqt4d.js +788 -0
  91. package/dist/shared/{chunk-t1rh6jtm.js → @ai-setting/roy-agent-core-tkr5ynkh.js} +8 -13
  92. package/dist/shared/@ai-setting/roy-agent-core-v4aabsf0.js +303 -0
  93. package/dist/shared/@ai-setting/roy-agent-core-w75rafhy.js +202 -0
  94. package/dist/shared/@ai-setting/roy-agent-core-w76hqkmg.js +584 -0
  95. package/dist/shared/@ai-setting/roy-agent-core-yfbgwes2.js +408 -0
  96. package/dist/shared/{chunk-a9qmy3sc.js → @ai-setting/roy-agent-core-yn761yve.js} +7 -4
  97. package/dist/shared/@ai-setting/roy-agent-core-yrzmn4m1.js +492 -0
  98. package/dist/shared/@ai-setting/roy-agent-core-yt8wdh2w.js +206 -0
  99. package/package.json +8 -7
  100. package/dist/index.d.ts +0 -7825
  101. package/dist/index.js +0 -16551
  102. package/dist/shared/chunk-hs7tbmje.js +0 -24
  103. /package/dist/shared/{chunk-wbkh7wat.js → @ai-setting/roy-agent-core-fs0mn2jk.js} +0 -0
@@ -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 };
@@ -0,0 +1,213 @@
1
+ // packages/core/src/env/task/tools/operation/operation-types.ts
2
+ import { z } from "zod";
3
+ var ActionTypeEnum = z.enum([
4
+ "create",
5
+ "progress",
6
+ "milestone",
7
+ "problem",
8
+ "solution",
9
+ "decision",
10
+ "review",
11
+ "completed"
12
+ ]);
13
+ var CreateOperationToolSchema = z.object({
14
+ task_id: z.number().describe("Task ID"),
15
+ action_type: ActionTypeEnum.describe("Type of action"),
16
+ action_title: z.string().describe("Title of the action"),
17
+ action_description: z.string().optional().describe("Detailed description"),
18
+ md_path: z.string().optional().describe("Path to detailed markdown documentation")
19
+ });
20
+ var GetOperationToolSchema = z.object({
21
+ operation_id: z.number().describe("Operation ID")
22
+ });
23
+ var ListOperationsToolSchema = z.object({
24
+ task_id: z.number().describe("Task ID"),
25
+ action_type: ActionTypeEnum.optional(),
26
+ limit: z.number().optional().default(20),
27
+ offset: z.number().optional().default(0)
28
+ });
29
+ var UpdateOperationToolSchema = z.object({
30
+ operation_id: z.number().describe("Operation ID"),
31
+ action_title: z.string().optional(),
32
+ action_description: z.string().optional()
33
+ });
34
+ var DeleteOperationToolSchema = z.object({
35
+ operation_id: z.number().describe("Operation ID")
36
+ });
37
+
38
+ // packages/core/src/env/task/tools/operation/create-tool.ts
39
+ function createOperationTool(taskComponent) {
40
+ return {
41
+ name: "task_operation_create",
42
+ description: "Create an operation record for a task. Tracks progress, milestones, problems, etc.",
43
+ parameters: CreateOperationToolSchema,
44
+ execute: async (args, ctx) => {
45
+ const params = CreateOperationToolSchema.parse(args);
46
+ const sessionId = ctx.session_id || "unknown";
47
+ try {
48
+ const operation = await taskComponent.createOperation({
49
+ taskId: params.task_id,
50
+ sessionId,
51
+ actionType: params.action_type,
52
+ actionTitle: params.action_title,
53
+ actionDescription: params.action_description,
54
+ mdPath: params.md_path
55
+ });
56
+ return {
57
+ success: true,
58
+ output: `Operation created: #${operation.id} for task #${operation.taskId}`,
59
+ metadata: {
60
+ execution_time_ms: 0,
61
+ operation_id: operation.id,
62
+ task_id: operation.taskId,
63
+ session_id: operation.sessionId
64
+ }
65
+ };
66
+ } catch (error) {
67
+ return {
68
+ success: false,
69
+ output: "",
70
+ error: error instanceof Error ? error.message : String(error),
71
+ metadata: { execution_time_ms: 0 }
72
+ };
73
+ }
74
+ }
75
+ };
76
+ }
77
+ // packages/core/src/env/task/tools/operation/get-tool.ts
78
+ function getOperationTool(taskComponent) {
79
+ return {
80
+ name: "task_operation_get",
81
+ description: "Get a single operation record by ID.",
82
+ parameters: GetOperationToolSchema,
83
+ execute: async (args, ctx) => {
84
+ const params = GetOperationToolSchema.parse(args);
85
+ try {
86
+ const operation = await taskComponent.getOperation(params.operation_id);
87
+ if (!operation) {
88
+ return {
89
+ success: false,
90
+ output: "",
91
+ error: `Operation not found: ${params.operation_id}`,
92
+ metadata: { execution_time_ms: 0 }
93
+ };
94
+ }
95
+ return {
96
+ success: true,
97
+ output: JSON.stringify(operation, null, 2),
98
+ metadata: { execution_time_ms: 0 }
99
+ };
100
+ } catch (error) {
101
+ return {
102
+ success: false,
103
+ output: "",
104
+ error: error instanceof Error ? error.message : String(error),
105
+ metadata: { execution_time_ms: 0 }
106
+ };
107
+ }
108
+ }
109
+ };
110
+ }
111
+ // packages/core/src/env/task/tools/operation/list-tool.ts
112
+ function listOperationsTool(taskComponent) {
113
+ return {
114
+ name: "task_operation_list",
115
+ description: "List operation records for a task with optional filters.",
116
+ parameters: ListOperationsToolSchema,
117
+ execute: async (args, ctx) => {
118
+ const params = ListOperationsToolSchema.parse(args);
119
+ try {
120
+ const operations = await taskComponent.listOperations({
121
+ taskId: params.task_id,
122
+ actionType: params.action_type,
123
+ limit: params.limit,
124
+ offset: params.offset
125
+ });
126
+ return {
127
+ success: true,
128
+ output: JSON.stringify({ operations, count: operations.length }),
129
+ metadata: { execution_time_ms: 0 }
130
+ };
131
+ } catch (error) {
132
+ return {
133
+ success: false,
134
+ output: "",
135
+ error: error instanceof Error ? error.message : String(error),
136
+ metadata: { execution_time_ms: 0 }
137
+ };
138
+ }
139
+ }
140
+ };
141
+ }
142
+ // packages/core/src/env/task/tools/operation/update-tool.ts
143
+ function updateOperationTool(taskComponent) {
144
+ return {
145
+ name: "task_operation_update",
146
+ description: "Update an operation record's title or description.",
147
+ parameters: UpdateOperationToolSchema,
148
+ execute: async (args, ctx) => {
149
+ const params = UpdateOperationToolSchema.parse(args);
150
+ try {
151
+ const operation = await taskComponent.updateOperation(params.operation_id, {
152
+ actionTitle: params.action_title,
153
+ actionDescription: params.action_description
154
+ });
155
+ if (!operation) {
156
+ return {
157
+ success: false,
158
+ output: "",
159
+ error: `Operation not found: ${params.operation_id}`,
160
+ metadata: { execution_time_ms: 0 }
161
+ };
162
+ }
163
+ return {
164
+ success: true,
165
+ output: `Operation updated: #${operation.id}`,
166
+ metadata: { execution_time_ms: 0, operation }
167
+ };
168
+ } catch (error) {
169
+ return {
170
+ success: false,
171
+ output: "",
172
+ error: error instanceof Error ? error.message : String(error),
173
+ metadata: { execution_time_ms: 0 }
174
+ };
175
+ }
176
+ }
177
+ };
178
+ }
179
+ // packages/core/src/env/task/tools/operation/delete-tool.ts
180
+ function deleteOperationTool(taskComponent) {
181
+ return {
182
+ name: "task_operation_delete",
183
+ description: "Delete an operation record.",
184
+ parameters: DeleteOperationToolSchema,
185
+ execute: async (args, ctx) => {
186
+ const params = DeleteOperationToolSchema.parse(args);
187
+ try {
188
+ const deleted = await taskComponent.deleteOperation(params.operation_id);
189
+ if (!deleted) {
190
+ return {
191
+ success: false,
192
+ output: "",
193
+ error: `Operation not found: ${params.operation_id}`,
194
+ metadata: { execution_time_ms: 0 }
195
+ };
196
+ }
197
+ return {
198
+ success: true,
199
+ output: `Operation deleted: #${params.operation_id}`,
200
+ metadata: { execution_time_ms: 0 }
201
+ };
202
+ } catch (error) {
203
+ return {
204
+ success: false,
205
+ output: "",
206
+ error: error instanceof Error ? error.message : String(error),
207
+ metadata: { execution_time_ms: 0 }
208
+ };
209
+ }
210
+ }
211
+ };
212
+ }
213
+ export { createOperationTool, getOperationTool, listOperationsTool, updateOperationTool, deleteOperationTool };
@@ -3,8 +3,9 @@ import {
3
3
  hasDecoratorNodes,
4
4
  init_node_registry_helper,
5
5
  registerDecoratorNodeType
6
- } from "./chunk-2b5kbhx3.js";
7
- import"./chunk-wbkh7wat.js";
6
+ } from "./roy-agent-core-1z1zv5g8.js";
7
+ import"./roy-agent-core-3tnb2005.js";
8
+ import"./roy-agent-core-fs0mn2jk.js";
8
9
  init_node_registry_helper();
9
10
 
10
11
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  __esm,
3
3
  __require
4
- } from "./chunk-wbkh7wat.js";
4
+ } from "./roy-agent-core-fs0mn2jk.js";
5
5
 
6
- // src/env/log-trace/span-storage.ts
6
+ // packages/core/src/env/log-trace/span-storage.ts
7
7
  class SQLiteSpanStorage {
8
8
  db = null;
9
9
  dbPath;