@ai-setting/roy-agent-core 1.5.13-test → 1.5.15-test

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 (141) hide show
  1. package/package.json +1 -1
  2. package/dist/config/index.d.ts +0 -1250
  3. package/dist/config/index.js +0 -32
  4. package/dist/env/agent/index.d.ts +0 -2279
  5. package/dist/env/agent/index.js +0 -24
  6. package/dist/env/commands/index.d.ts +0 -1131
  7. package/dist/env/commands/index.js +0 -14
  8. package/dist/env/debug/formatters/index.d.ts +0 -236
  9. package/dist/env/debug/formatters/index.js +0 -11
  10. package/dist/env/debug/index.d.ts +0 -1652
  11. package/dist/env/debug/index.js +0 -26
  12. package/dist/env/hook/index.d.ts +0 -279
  13. package/dist/env/hook/index.js +0 -29
  14. package/dist/env/index.d.ts +0 -3481
  15. package/dist/env/index.js +0 -82
  16. package/dist/env/llm/index.d.ts +0 -1760
  17. package/dist/env/llm/index.js +0 -40
  18. package/dist/env/log-trace/index.d.ts +0 -1574
  19. package/dist/env/log-trace/index.js +0 -83
  20. package/dist/env/mcp/index.d.ts +0 -1331
  21. package/dist/env/mcp/index.js +0 -39
  22. package/dist/env/mcp/tool/index.d.ts +0 -183
  23. package/dist/env/mcp/tool/index.js +0 -14
  24. package/dist/env/memory/built-in/index.d.ts +0 -232
  25. package/dist/env/memory/built-in/index.js +0 -11
  26. package/dist/env/memory/index.d.ts +0 -1799
  27. package/dist/env/memory/index.js +0 -56
  28. package/dist/env/memory/plugin/index.d.ts +0 -747
  29. package/dist/env/memory/plugin/index.js +0 -36
  30. package/dist/env/prompt/index.d.ts +0 -1164
  31. package/dist/env/prompt/index.js +0 -20
  32. package/dist/env/session/index.d.ts +0 -1908
  33. package/dist/env/session/index.js +0 -25
  34. package/dist/env/session/storage/index.d.ts +0 -564
  35. package/dist/env/session/storage/index.js +0 -18
  36. package/dist/env/skill/index.d.ts +0 -1266
  37. package/dist/env/skill/index.js +0 -34
  38. package/dist/env/skill/tool/index.d.ts +0 -193
  39. package/dist/env/skill/tool/index.js +0 -9
  40. package/dist/env/task/delegate/index.d.ts +0 -1612
  41. package/dist/env/task/delegate/index.js +0 -18
  42. package/dist/env/task/events/index.d.ts +0 -171
  43. package/dist/env/task/events/index.js +0 -7
  44. package/dist/env/task/hooks/index.d.ts +0 -624
  45. package/dist/env/task/hooks/index.js +0 -7
  46. package/dist/env/task/index.d.ts +0 -1553
  47. package/dist/env/task/index.js +0 -34
  48. package/dist/env/task/plugins/index.d.ts +0 -466
  49. package/dist/env/task/plugins/index.js +0 -23
  50. package/dist/env/task/storage/index.d.ts +0 -241
  51. package/dist/env/task/storage/index.js +0 -14
  52. package/dist/env/task/tools/index.d.ts +0 -1485
  53. package/dist/env/task/tools/index.js +0 -17
  54. package/dist/env/task/tools/operation/index.d.ts +0 -1484
  55. package/dist/env/task/tools/operation/index.js +0 -15
  56. package/dist/env/tool/built-in/index.d.ts +0 -218
  57. package/dist/env/tool/built-in/index.js +0 -25
  58. package/dist/env/tool/index.d.ts +0 -1396
  59. package/dist/env/tool/index.js +0 -39
  60. package/dist/env/workflow/decorators/index.d.ts +0 -2161
  61. package/dist/env/workflow/decorators/index.js +0 -27
  62. package/dist/env/workflow/engine/index.d.ts +0 -3453
  63. package/dist/env/workflow/engine/index.js +0 -28
  64. package/dist/env/workflow/index.d.ts +0 -3546
  65. package/dist/env/workflow/index.js +0 -136
  66. package/dist/env/workflow/nodes/index.d.ts +0 -2092
  67. package/dist/env/workflow/nodes/index.js +0 -19
  68. package/dist/env/workflow/service/index.d.ts +0 -227
  69. package/dist/env/workflow/service/index.js +0 -13
  70. package/dist/env/workflow/storage/index.d.ts +0 -165
  71. package/dist/env/workflow/storage/index.js +0 -27
  72. package/dist/env/workflow/tools/index.d.ts +0 -416
  73. package/dist/env/workflow/tools/index.js +0 -159
  74. package/dist/env/workflow/types/index.d.ts +0 -2255
  75. package/dist/env/workflow/types/index.js +0 -98
  76. package/dist/env/workflow/utils/index.d.ts +0 -2031
  77. package/dist/env/workflow/utils/index.js +0 -637
  78. package/dist/index.d.ts +0 -7858
  79. package/dist/index.js +0 -399
  80. package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
  81. package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
  82. package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
  83. package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
  84. package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
  85. package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
  86. package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
  87. package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
  88. package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
  89. package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
  90. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  91. package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
  92. package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
  93. package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
  94. package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
  95. package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
  96. package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
  97. package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
  98. package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
  99. package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
  100. package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
  101. package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
  102. package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
  103. package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
  104. package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
  105. package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
  106. package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
  107. package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
  108. package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
  109. package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
  110. package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
  111. package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
  112. package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
  113. package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
  114. package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
  115. package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
  116. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  117. package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
  118. package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
  119. package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
  120. package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
  121. package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
  122. package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
  123. package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
  124. package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
  125. package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
  126. package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
  127. package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
  128. package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
  129. package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
  130. package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
  131. package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
  132. package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
  133. package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
  134. package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
  135. package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
  136. package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
  137. package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
  138. package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
  139. package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
  140. package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
  141. package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
@@ -1,11 +0,0 @@
1
- import {
2
- AgentComponentAdapter,
3
- init_agent_component_adapter
4
- } from "./roy-agent-core-69jskqjg.js";
5
- import"./roy-agent-core-e25xkv53.js";
6
- import"./roy-agent-core-fs0mn2jk.js";
7
- init_agent_component_adapter();
8
-
9
- export {
10
- AgentComponentAdapter
11
- };
@@ -1,64 +0,0 @@
1
- import {
2
- __esm
3
- } from "./roy-agent-core-fs0mn2jk.js";
4
-
5
- // src/env/workflow/types/workflow-hil.ts
6
- function createNodeInterruptEvent(runId, nodeId, nodeType, query, agentSessionId) {
7
- return {
8
- type: "node.interrupt",
9
- run_id: runId,
10
- timestamp: Date.now(),
11
- node_id: nodeId,
12
- node_type: nodeType,
13
- query,
14
- ...agentSessionId ? { agent_session_id: agentSessionId } : {}
15
- };
16
- }
17
- function createWorkflowAskUserEvent(runId, sessionId, nodeId, nodeType, query) {
18
- return {
19
- type: "workflow.ask-user",
20
- run_id: runId,
21
- timestamp: Date.now(),
22
- session_id: sessionId,
23
- node_id: nodeId,
24
- node_type: nodeType,
25
- query
26
- };
27
- }
28
- var AskUserError;
29
- var init_workflow_hil = __esm(() => {
30
- AskUserError = class AskUserError extends Error {
31
- runId;
32
- sessionId;
33
- nodeId;
34
- nodeType;
35
- query;
36
- agentSessionId;
37
- timestamp;
38
- type = "ask-user";
39
- name = "AskUserError";
40
- constructor(runId, sessionId, nodeId, nodeType, query, agentSessionId, timestamp = Date.now()) {
41
- super(`[${nodeType}:${nodeId}] Ask user: ${query}`);
42
- this.runId = runId;
43
- this.sessionId = sessionId;
44
- this.nodeId = nodeId;
45
- this.nodeType = nodeType;
46
- this.query = query;
47
- this.agentSessionId = agentSessionId;
48
- this.timestamp = timestamp;
49
- }
50
- toEvent() {
51
- return {
52
- type: "workflow.ask-user",
53
- run_id: this.runId,
54
- timestamp: this.timestamp,
55
- session_id: this.sessionId,
56
- node_id: this.nodeId,
57
- node_type: this.nodeType,
58
- query: this.query
59
- };
60
- }
61
- };
62
- });
63
-
64
- export { createNodeInterruptEvent, createWorkflowAskUserEvent, AskUserError, init_workflow_hil };
@@ -1,378 +0,0 @@
1
- import {
2
- TracedAs,
3
- init_decorator
4
- } from "./roy-agent-core-zgypchmt.js";
5
- import {
6
- createLogger,
7
- init_logger
8
- } from "./roy-agent-core-44hnfb02.js";
9
- import {
10
- __legacyDecorateClassTS
11
- } from "./roy-agent-core-fs0mn2jk.js";
12
-
13
- // 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 };