rivet-design 0.5.4 → 0.5.7
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.
- package/README.md +18 -18
- package/README.npm.md +18 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -14
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +2 -67
- package/dist/mcp/server.js.map +1 -1
- package/dist/services/TelemetryService.d.ts.map +1 -1
- package/dist/services/TelemetryService.js +5 -0
- package/dist/services/TelemetryService.js.map +1 -1
- package/package.json +3 -3
- package/src/ui/dist/assets/main-DAIpACRO.js +491 -0
- package/src/ui/dist/index.html +1 -1
- package/dist/routes/agent.d.ts +0 -8
- package/dist/routes/agent.d.ts.map +0 -1
- package/dist/routes/agent.js +0 -79
- package/dist/routes/agent.js.map +0 -1
- package/dist/routes/comments.d.ts +0 -2
- package/dist/routes/comments.d.ts.map +0 -1
- package/dist/routes/comments.js +0 -92
- package/dist/routes/comments.js.map +0 -1
- package/dist/routes/onboarding.d.ts +0 -6
- package/dist/routes/onboarding.d.ts.map +0 -1
- package/dist/routes/onboarding.js +0 -206
- package/dist/routes/onboarding.js.map +0 -1
- package/dist/routes/selection.d.ts +0 -2
- package/dist/routes/selection.d.ts.map +0 -1
- package/dist/routes/selection.js +0 -38
- package/dist/routes/selection.js.map +0 -1
- package/dist/scripts/react-instrumentation.js +0 -300
- package/dist/services/AgentBridgeService.d.ts +0 -89
- package/dist/services/AgentBridgeService.d.ts.map +0 -1
- package/dist/services/AgentBridgeService.js +0 -413
- package/dist/services/AgentBridgeService.js.map +0 -1
- package/dist/services/AgentModService.d.ts +0 -76
- package/dist/services/AgentModService.d.ts.map +0 -1
- package/dist/services/AgentModService.js +0 -494
- package/dist/services/AgentModService.js.map +0 -1
- package/dist/services/CommentSessionManager.d.ts +0 -94
- package/dist/services/CommentSessionManager.d.ts.map +0 -1
- package/dist/services/CommentSessionManager.js +0 -260
- package/dist/services/CommentSessionManager.js.map +0 -1
- package/dist/services/ImportResolverService.d.ts +0 -30
- package/dist/services/ImportResolverService.d.ts.map +0 -1
- package/dist/services/ImportResolverService.js +0 -136
- package/dist/services/ImportResolverService.js.map +0 -1
- package/dist/services/ReactComponentPlugin.d.ts +0 -44
- package/dist/services/ReactComponentPlugin.d.ts.map +0 -1
- package/dist/services/ReactComponentPlugin.js +0 -100
- package/dist/services/ReactComponentPlugin.js.map +0 -1
- package/dist/types/agent-protocol.d.ts +0 -55
- package/dist/types/agent-protocol.d.ts.map +0 -1
- package/dist/types/agent-protocol.js +0 -6
- package/dist/types/agent-protocol.js.map +0 -1
- package/dist/types/agent-tools.d.ts +0 -78
- package/dist/types/agent-tools.d.ts.map +0 -1
- package/dist/types/agent-tools.js +0 -7
- package/dist/types/agent-tools.js.map +0 -1
- package/dist/types/types.d.ts +0 -15
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -3
- package/dist/types/types.js.map +0 -1
- package/src/ui/dist/assets/main-BXXN24hn.js +0 -505
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommentSessionManager = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const logger_1 = require("../utils/logger");
|
|
6
|
-
const AgentCore_1 = require("./agent/AgentCore");
|
|
7
|
-
const log = (0, logger_1.createLogger)('CommentSessionManager');
|
|
8
|
-
const ORPHAN_CLEANUP_DELAY_MS = 30_000;
|
|
9
|
-
/**
|
|
10
|
-
* Manages concurrent agent sessions spawned by element comments.
|
|
11
|
-
* Each comment gets its own AgentCore subprocess.
|
|
12
|
-
* Emits SSE events for frontend consumption via a multiplexed stream.
|
|
13
|
-
*/
|
|
14
|
-
class CommentSessionManager extends events_1.EventEmitter {
|
|
15
|
-
sessions = new Map();
|
|
16
|
-
core;
|
|
17
|
-
projectPath;
|
|
18
|
-
orphanCleanupTimer = null;
|
|
19
|
-
connectedClients = 0;
|
|
20
|
-
constructor(projectPath) {
|
|
21
|
-
super();
|
|
22
|
-
this.core = new AgentCore_1.AgentCore();
|
|
23
|
-
this.projectPath = projectPath;
|
|
24
|
-
this.registerShutdownHandlers();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Start an agent session for a comment.
|
|
28
|
-
* Spawns a new AgentCore subprocess and streams progress events.
|
|
29
|
-
*
|
|
30
|
-
* @effect Spawns a child process, emits SSE events
|
|
31
|
-
*/
|
|
32
|
-
startSession(commentId, instruction, elementContext) {
|
|
33
|
-
const abortController = new AbortController();
|
|
34
|
-
const session = {
|
|
35
|
-
commentId,
|
|
36
|
-
instruction,
|
|
37
|
-
elementContext,
|
|
38
|
-
status: 'running',
|
|
39
|
-
abortController,
|
|
40
|
-
sessionId: null,
|
|
41
|
-
messages: [],
|
|
42
|
-
};
|
|
43
|
-
this.sessions.set(commentId, session);
|
|
44
|
-
log.info(`Starting session for comment ${commentId}: "${instruction}"`);
|
|
45
|
-
this.emitSSE({
|
|
46
|
-
type: 'comment:status',
|
|
47
|
-
commentId,
|
|
48
|
-
status: 'running',
|
|
49
|
-
});
|
|
50
|
-
// Run agent in background — don't await
|
|
51
|
-
this.runAgent(session).catch((error) => {
|
|
52
|
-
log.error(`Session ${commentId} failed unexpectedly:`, error);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Abort and remove a single session
|
|
57
|
-
*/
|
|
58
|
-
abortSession(commentId) {
|
|
59
|
-
const session = this.sessions.get(commentId);
|
|
60
|
-
if (!session)
|
|
61
|
-
return false;
|
|
62
|
-
log.info(`Aborting session ${commentId}`);
|
|
63
|
-
if (session.status === 'running') {
|
|
64
|
-
session.abortController.abort();
|
|
65
|
-
}
|
|
66
|
-
this.sessions.delete(commentId);
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Abort all running sessions and clear the map
|
|
71
|
-
*/
|
|
72
|
-
abortAll() {
|
|
73
|
-
log.info(`Aborting all ${this.sessions.size} sessions`);
|
|
74
|
-
for (const [commentId, session] of this.sessions) {
|
|
75
|
-
if (session.status === 'running') {
|
|
76
|
-
session.abortController.abort();
|
|
77
|
-
log.info(`Aborted session ${commentId}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
this.sessions.clear();
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Check if a session exists
|
|
84
|
-
*/
|
|
85
|
-
hasSession(commentId) {
|
|
86
|
-
return this.sessions.has(commentId);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get current session count
|
|
90
|
-
*/
|
|
91
|
-
getSessionCount() {
|
|
92
|
-
return this.sessions.size;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Track SSE client connections for orphan cleanup
|
|
96
|
-
*/
|
|
97
|
-
clientConnected() {
|
|
98
|
-
this.connectedClients++;
|
|
99
|
-
if (this.orphanCleanupTimer) {
|
|
100
|
-
clearTimeout(this.orphanCleanupTimer);
|
|
101
|
-
this.orphanCleanupTimer = null;
|
|
102
|
-
log.info('Client reconnected, cancelled orphan cleanup');
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Track SSE client disconnections.
|
|
107
|
-
* Starts orphan cleanup timer if no clients remain.
|
|
108
|
-
*/
|
|
109
|
-
clientDisconnected() {
|
|
110
|
-
this.connectedClients = Math.max(0, this.connectedClients - 1);
|
|
111
|
-
if (this.connectedClients === 0 && this.sessions.size > 0) {
|
|
112
|
-
log.info(`No SSE clients remaining. Starting ${ORPHAN_CLEANUP_DELAY_MS}ms orphan cleanup timer`);
|
|
113
|
-
this.orphanCleanupTimer = setTimeout(() => {
|
|
114
|
-
if (this.connectedClients === 0) {
|
|
115
|
-
log.info('Orphan cleanup: aborting all sessions');
|
|
116
|
-
this.abortAll();
|
|
117
|
-
}
|
|
118
|
-
this.orphanCleanupTimer = null;
|
|
119
|
-
}, ORPHAN_CLEANUP_DELAY_MS);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Execute the agent for a comment session and emit progress events.
|
|
124
|
-
*
|
|
125
|
-
* @effect Streams AgentProgressEvents via SSE, updates session status
|
|
126
|
-
*/
|
|
127
|
-
async runAgent(session) {
|
|
128
|
-
const { commentId, instruction, elementContext, abortController } = session;
|
|
129
|
-
const systemPrompt = this.buildSystemPrompt(elementContext);
|
|
130
|
-
const userPrompt = this.buildUserPrompt(instruction, elementContext);
|
|
131
|
-
try {
|
|
132
|
-
const result = await this.core.execute({
|
|
133
|
-
systemPrompt,
|
|
134
|
-
userPrompt,
|
|
135
|
-
allowedTools: ['Glob', 'Grep', 'Read', 'Edit', 'Bash'],
|
|
136
|
-
permissionMode: 'acceptEdits',
|
|
137
|
-
cwd: this.projectPath,
|
|
138
|
-
abortController,
|
|
139
|
-
onProgress: (event) => {
|
|
140
|
-
// Skip emitting if session was already removed (dismissed while running)
|
|
141
|
-
if (!this.sessions.has(commentId))
|
|
142
|
-
return;
|
|
143
|
-
session.messages.push(event);
|
|
144
|
-
this.emitSSE({
|
|
145
|
-
type: 'comment:step',
|
|
146
|
-
commentId,
|
|
147
|
-
step: event,
|
|
148
|
-
});
|
|
149
|
-
// Emit reasoning text as message events for frontend display
|
|
150
|
-
if (event.type === 'step' &&
|
|
151
|
-
event.step?.type === 'reasoning' &&
|
|
152
|
-
event.step.data) {
|
|
153
|
-
const text = event.step.data.text;
|
|
154
|
-
if (text) {
|
|
155
|
-
this.emitSSE({
|
|
156
|
-
type: 'comment:message',
|
|
157
|
-
commentId,
|
|
158
|
-
content: text,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
// Session may have been dismissed during execution
|
|
165
|
-
if (!this.sessions.has(commentId))
|
|
166
|
-
return;
|
|
167
|
-
session.sessionId = result.sessionId ?? null;
|
|
168
|
-
session.status = 'complete';
|
|
169
|
-
log.info(`Session ${commentId} complete. Modified ${result.filesModified.length} files`);
|
|
170
|
-
this.emitSSE({
|
|
171
|
-
type: 'comment:status',
|
|
172
|
-
commentId,
|
|
173
|
-
status: 'complete',
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
// Session may have been dismissed during execution
|
|
178
|
-
if (!this.sessions.has(commentId))
|
|
179
|
-
return;
|
|
180
|
-
// Aborted sessions are expected — don't log as error
|
|
181
|
-
if (abortController.signal.aborted) {
|
|
182
|
-
log.info(`Session ${commentId} was aborted`);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
session.status = 'error';
|
|
186
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
187
|
-
log.error(`Session ${commentId} error:`, errorMessage);
|
|
188
|
-
this.emitSSE({
|
|
189
|
-
type: 'comment:status',
|
|
190
|
-
commentId,
|
|
191
|
-
status: 'error',
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Emit an SSE event to all connected clients
|
|
197
|
-
*/
|
|
198
|
-
emitSSE(event) {
|
|
199
|
-
this.emit('sse', event);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Build system prompt for the comment agent
|
|
203
|
-
*/
|
|
204
|
-
buildSystemPrompt(elementContext) {
|
|
205
|
-
return `You are an expert software engineer modifying a web application's code.
|
|
206
|
-
A user has left a comment on a specific UI element. Your job is to implement their request.
|
|
207
|
-
|
|
208
|
-
TARGET ELEMENT:
|
|
209
|
-
- Tag: <${elementContext.tagName}>
|
|
210
|
-
- XPath: ${elementContext.xpath}
|
|
211
|
-
${elementContext.className ? `- Classes: ${elementContext.className}` : ''}
|
|
212
|
-
${elementContext.id ? `- ID: ${elementContext.id}` : ''}
|
|
213
|
-
${elementContext.textContent ? `- Text: ${elementContext.textContent.slice(0, 100)}` : ''}
|
|
214
|
-
${elementContext.filePaths?.[0] ? `- Source file: ${elementContext.filePaths[0].filePath}` : ''}
|
|
215
|
-
|
|
216
|
-
TOOLS AVAILABLE:
|
|
217
|
-
- Glob: Find files by pattern
|
|
218
|
-
- Grep: Search file contents
|
|
219
|
-
- Read: Read file contents
|
|
220
|
-
- Edit: Make search/replace edits (preferred for modifications)
|
|
221
|
-
- Bash: Run terminal commands (use sparingly)
|
|
222
|
-
|
|
223
|
-
WORKFLOW:
|
|
224
|
-
1. Read the source file for the target element
|
|
225
|
-
2. Understand the current code and surrounding context
|
|
226
|
-
3. Make the requested modifications using Edit
|
|
227
|
-
4. Check for side effects in related files
|
|
228
|
-
|
|
229
|
-
RULES:
|
|
230
|
-
- Make MINIMAL changes to achieve the goal
|
|
231
|
-
- Preserve existing code style
|
|
232
|
-
- Each Edit search string must be unique in the file
|
|
233
|
-
- Include 2-3 lines of context for unique Edit matches`;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Build the user prompt for the comment agent
|
|
237
|
-
*/
|
|
238
|
-
buildUserPrompt(instruction, elementContext) {
|
|
239
|
-
const filePath = elementContext.filePaths?.[0]?.filePath;
|
|
240
|
-
const fileHint = filePath
|
|
241
|
-
? `\n\nStart by reading the source file: ${filePath}`
|
|
242
|
-
: '\n\nStart by using Grep/Glob to find the relevant source file.';
|
|
243
|
-
return `${instruction}${fileHint}`;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Register process shutdown handlers to abort all sessions
|
|
247
|
-
*/
|
|
248
|
-
registerShutdownHandlers() {
|
|
249
|
-
const cleanup = () => {
|
|
250
|
-
if (this.sessions.size > 0) {
|
|
251
|
-
log.info('Server shutting down, aborting all comment sessions');
|
|
252
|
-
this.abortAll();
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
process.on('SIGTERM', cleanup);
|
|
256
|
-
process.on('SIGINT', cleanup);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
exports.CommentSessionManager = CommentSessionManager;
|
|
260
|
-
//# sourceMappingURL=CommentSessionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommentSessionManager.js","sourceRoot":"","sources":["../../src/services/CommentSessionManager.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,4CAA+C;AAC/C,iDAAkE;AAGlE,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC,uBAAuB,CAAC,CAAC;AAmBlD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,qBAAY;IAC7C,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC7C,IAAI,CAAY;IAChB,WAAW,CAAS;IACpB,kBAAkB,GAAyC,IAAI,CAAC;IAChE,gBAAgB,GAAG,CAAC,CAAC;IAE7B,YAAY,WAAmB;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,qBAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACH,YAAY,CACV,SAAiB,EACjB,WAAmB,EACnB,cAA8B;QAE9B,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAE9C,MAAM,OAAO,GAAmB;YAC9B,SAAS;YACT,WAAW;YACX,cAAc;YACd,MAAM,EAAE,SAAS;YACjB,eAAe;YACf,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtC,GAAG,CAAC,IAAI,CAAC,gCAAgC,SAAS,MAAM,WAAW,GAAG,CAAC,CAAC;QAExE,IAAI,CAAC,OAAO,CAAC;YACX,IAAI,EAAE,gBAAgB;YACtB,SAAS;YACT,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;QAEH,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
-
};
|
|
6
|
-
export declare class ImportResolverService {
|
|
7
|
-
/**
|
|
8
|
-
* Extract all import statements from a file
|
|
9
|
-
* Handles: import X from 'Y', import { X } from 'Y', import * as X from 'Y'
|
|
10
|
-
*/
|
|
11
|
-
extractImports(fileContent: string): string[];
|
|
12
|
-
/**
|
|
13
|
-
* Resolve an import path to an absolute file path
|
|
14
|
-
* Handles: .ts, .tsx, .js, .jsx extensions and index files
|
|
15
|
-
*/
|
|
16
|
-
resolveImportPath(importPath: string, currentFilePath: string): string | null;
|
|
17
|
-
/**
|
|
18
|
-
* Get all related files for a component (imports and their imports)
|
|
19
|
-
* @param filePath - The component file to analyze
|
|
20
|
-
* @param maxDepth - How many levels deep to traverse imports (default: 1)
|
|
21
|
-
* @param maxFiles - Maximum number of files to collect (default: 10)
|
|
22
|
-
*/
|
|
23
|
-
getRelatedFiles(filePath: string, maxDepth?: number, maxFiles?: number): ImportInfo[];
|
|
24
|
-
/**
|
|
25
|
-
* Get related files for multiple component files
|
|
26
|
-
* Returns unique set of all related files across all components
|
|
27
|
-
*/
|
|
28
|
-
getRelatedFilesForMultiple(filePaths: string[], maxDepth?: number, maxFiles?: number): ImportInfo[];
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=ImportResolverService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImportResolverService.d.ts","sourceRoot":"","sources":["../../src/services/ImportResolverService.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,qBAAa,qBAAqB;IAChC;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAuB7C;;;OAGG;IACH,iBAAiB,CACf,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,GACtB,MAAM,GAAG,IAAI;IA4BhB;;;;;OAKG;IACH,eAAe,CACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAU,EACpB,QAAQ,GAAE,MAAW,GACpB,UAAU,EAAE;IAuDf;;;OAGG;IACH,0BAA0B,CACxB,SAAS,EAAE,MAAM,EAAE,EACnB,QAAQ,GAAE,MAAU,EACpB,QAAQ,GAAE,MAAW,GACpB,UAAU,EAAE;CAwBhB"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ImportResolverService = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const logger_1 = require("../utils/logger");
|
|
10
|
-
const log = (0, logger_1.createLogger)('ImportResolverService');
|
|
11
|
-
class ImportResolverService {
|
|
12
|
-
/**
|
|
13
|
-
* Extract all import statements from a file
|
|
14
|
-
* Handles: import X from 'Y', import { X } from 'Y', import * as X from 'Y'
|
|
15
|
-
*/
|
|
16
|
-
extractImports(fileContent) {
|
|
17
|
-
const imports = [];
|
|
18
|
-
// Match ES6 import statements
|
|
19
|
-
// Handles: import X from 'path', import { X } from 'path', import * as X from 'path'
|
|
20
|
-
const importRegex = /import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
21
|
-
let match;
|
|
22
|
-
while ((match = importRegex.exec(fileContent)) !== null) {
|
|
23
|
-
const importPath = match[1];
|
|
24
|
-
// Filter out node_modules and built-in modules
|
|
25
|
-
if (!importPath.startsWith('.') && !importPath.startsWith('/')) {
|
|
26
|
-
// This is a package import (e.g., 'react', '@radix-ui/react-select')
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
imports.push(importPath);
|
|
30
|
-
}
|
|
31
|
-
return imports;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Resolve an import path to an absolute file path
|
|
35
|
-
* Handles: .ts, .tsx, .js, .jsx extensions and index files
|
|
36
|
-
*/
|
|
37
|
-
resolveImportPath(importPath, currentFilePath) {
|
|
38
|
-
const currentDir = path_1.default.dirname(currentFilePath);
|
|
39
|
-
// Resolve relative to current file
|
|
40
|
-
const resolvedPath = path_1.default.resolve(currentDir, importPath);
|
|
41
|
-
// Try different file extensions and index files
|
|
42
|
-
const candidates = [
|
|
43
|
-
resolvedPath,
|
|
44
|
-
`${resolvedPath}.ts`,
|
|
45
|
-
`${resolvedPath}.tsx`,
|
|
46
|
-
`${resolvedPath}.js`,
|
|
47
|
-
`${resolvedPath}.jsx`,
|
|
48
|
-
path_1.default.join(resolvedPath, 'index.ts'),
|
|
49
|
-
path_1.default.join(resolvedPath, 'index.tsx'),
|
|
50
|
-
path_1.default.join(resolvedPath, 'index.js'),
|
|
51
|
-
path_1.default.join(resolvedPath, 'index.jsx'),
|
|
52
|
-
];
|
|
53
|
-
for (const candidate of candidates) {
|
|
54
|
-
if (fs_1.default.existsSync(candidate) && fs_1.default.statSync(candidate).isFile()) {
|
|
55
|
-
return candidate;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get all related files for a component (imports and their imports)
|
|
62
|
-
* @param filePath - The component file to analyze
|
|
63
|
-
* @param maxDepth - How many levels deep to traverse imports (default: 1)
|
|
64
|
-
* @param maxFiles - Maximum number of files to collect (default: 10)
|
|
65
|
-
*/
|
|
66
|
-
getRelatedFiles(filePath, maxDepth = 1, maxFiles = 10) {
|
|
67
|
-
const visited = new Set();
|
|
68
|
-
const relatedFiles = [];
|
|
69
|
-
const traverse = (currentPath, depth) => {
|
|
70
|
-
// Stop if we've reached max depth or max files
|
|
71
|
-
if (depth > maxDepth || relatedFiles.length >= maxFiles) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
// Skip if already visited
|
|
75
|
-
if (visited.has(currentPath)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
visited.add(currentPath);
|
|
79
|
-
try {
|
|
80
|
-
const content = fs_1.default.readFileSync(currentPath, 'utf8');
|
|
81
|
-
const imports = this.extractImports(content);
|
|
82
|
-
for (const importPath of imports) {
|
|
83
|
-
const absolutePath = this.resolveImportPath(importPath, currentPath);
|
|
84
|
-
if (absolutePath) {
|
|
85
|
-
relatedFiles.push({
|
|
86
|
-
importPath,
|
|
87
|
-
absolutePath,
|
|
88
|
-
isRelative: importPath.startsWith('.'),
|
|
89
|
-
});
|
|
90
|
-
// Recursively traverse if we haven't hit depth limit
|
|
91
|
-
if (depth < maxDepth) {
|
|
92
|
-
traverse(absolutePath, depth + 1);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
log.debug(`Could not resolve import: ${importPath} from ${currentPath}`);
|
|
97
|
-
}
|
|
98
|
-
// Stop if we've collected enough files
|
|
99
|
-
if (relatedFiles.length >= maxFiles) {
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
log.error(`Error reading file ${currentPath}:`, error);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
traverse(filePath, 0);
|
|
109
|
-
return relatedFiles;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get related files for multiple component files
|
|
113
|
-
* Returns unique set of all related files across all components
|
|
114
|
-
*/
|
|
115
|
-
getRelatedFilesForMultiple(filePaths, maxDepth = 1, maxFiles = 10) {
|
|
116
|
-
const allRelated = new Map();
|
|
117
|
-
for (const filePath of filePaths) {
|
|
118
|
-
const related = this.getRelatedFiles(filePath, maxDepth, maxFiles);
|
|
119
|
-
for (const info of related) {
|
|
120
|
-
if (info.absolutePath && !allRelated.has(info.absolutePath)) {
|
|
121
|
-
allRelated.set(info.absolutePath, info);
|
|
122
|
-
}
|
|
123
|
-
// Stop if we've hit the max file limit
|
|
124
|
-
if (allRelated.size >= maxFiles) {
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (allRelated.size >= maxFiles) {
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return Array.from(allRelated.values());
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.ImportResolverService = ImportResolverService;
|
|
136
|
-
//# sourceMappingURL=ImportResolverService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImportResolverService.js","sourceRoot":"","sources":["../../src/services/ImportResolverService.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,4CAA+C;AAE/C,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC,uBAAuB,CAAC,CAAC;AAQlD,MAAa,qBAAqB;IAChC;;;OAGG;IACH,cAAc,CAAC,WAAmB;QAChC,MAAM,OAAO,GAAa,EAAE,CAAC;QAE7B,8BAA8B;QAC9B,qFAAqF;QACrF,MAAM,WAAW,GAAG,sDAAsD,CAAC;QAE3E,IAAI,KAAK,CAAC;QACV,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACxD,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAE5B,+CAA+C;YAC/C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/D,qEAAqE;gBACrE,SAAS;YACX,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,iBAAiB,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,GAAG,EAAsB,CAAC;QAEjD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAEnE,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC3B,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC5D,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;gBAC1C,CAAC;gBAED,uCAAuC;gBACvC,IAAI,UAAU,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAChC,MAAM;gBACR,CAAC;YACH,CAAC;YAED,IAAI,UAAU,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;gBAChC,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAhKD,sDAgKC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ComponentMatch } from '../routes/components';
|
|
2
|
-
export type ReactComponentInfo = {
|
|
3
|
-
components: Array<{
|
|
4
|
-
filePath: string;
|
|
5
|
-
line?: number;
|
|
6
|
-
column?: number;
|
|
7
|
-
componentName?: string;
|
|
8
|
-
}>;
|
|
9
|
-
primaryComponent: {
|
|
10
|
-
filePath: string;
|
|
11
|
-
line?: number;
|
|
12
|
-
column?: number;
|
|
13
|
-
componentName?: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare class ReactComponentPlugin {
|
|
17
|
-
/**
|
|
18
|
-
* Resolve a single file path relative to project
|
|
19
|
-
*/
|
|
20
|
-
private resolveFilePath;
|
|
21
|
-
/**
|
|
22
|
-
* Extract all component file paths from React-instrumented element data
|
|
23
|
-
* Returns array of all components in the tree hierarchy
|
|
24
|
-
*/
|
|
25
|
-
findAllComponentFiles(projectPath: string, element: {
|
|
26
|
-
_reactComponentInfo?: ReactComponentInfo;
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}): ComponentMatch[];
|
|
29
|
-
/**
|
|
30
|
-
* Extract primary component file path (closest to selected element)
|
|
31
|
-
* Returns exact filepath if React instrumentation provided it, otherwise null
|
|
32
|
-
*/
|
|
33
|
-
findComponentFile(projectPath: string, element: {
|
|
34
|
-
_reactComponentInfo?: ReactComponentInfo;
|
|
35
|
-
[key: string]: unknown;
|
|
36
|
-
}): ComponentMatch | null;
|
|
37
|
-
/**
|
|
38
|
-
* Check if element has React component info attached
|
|
39
|
-
*/
|
|
40
|
-
hasReactInfo(element: {
|
|
41
|
-
_reactComponentInfo?: ReactComponentInfo;
|
|
42
|
-
}): boolean;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=ReactComponentPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactComponentPlugin.d.ts","sourceRoot":"","sources":["../../src/services/ReactComponentPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,KAAK,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC,CAAC;IACH,gBAAgB,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,qBAAa,oBAAoB;IAC/B;;OAEG;IACH,OAAO,CAAC,eAAe;IA4BvB;;;OAGG;IACH,qBAAqB,CACnB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;QACP,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;QACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GACA,cAAc,EAAE;IAqCnB;;;OAGG;IACH,iBAAiB,CACf,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;QACP,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;QACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GACA,cAAc,GAAG,IAAI;IAmCxB;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE;QAAE,mBAAmB,CAAC,EAAE,kBAAkB,CAAA;KAAE,GAAG,OAAO;CAM7E"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ReactComponentPlugin = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const logger_1 = require("../utils/logger");
|
|
10
|
-
const log = (0, logger_1.createLogger)('ReactComponentPlugin');
|
|
11
|
-
class ReactComponentPlugin {
|
|
12
|
-
/**
|
|
13
|
-
* Resolve a single file path relative to project
|
|
14
|
-
*/
|
|
15
|
-
resolveFilePath(projectPath, filePath) {
|
|
16
|
-
// If already absolute, just verify it exists
|
|
17
|
-
if (path_1.default.isAbsolute(filePath)) {
|
|
18
|
-
return fs_1.default.existsSync(filePath) ? filePath : null;
|
|
19
|
-
}
|
|
20
|
-
// Try different path resolution strategies
|
|
21
|
-
const candidates = [
|
|
22
|
-
// Try with 'src/' prefix
|
|
23
|
-
path_1.default.join(projectPath, 'src', filePath.replace(/^src\//, '')),
|
|
24
|
-
// Try without 'src/' prefix
|
|
25
|
-
path_1.default.join(projectPath, filePath.replace(/^src\//, '')),
|
|
26
|
-
// Try as-is from project root
|
|
27
|
-
path_1.default.join(projectPath, filePath),
|
|
28
|
-
];
|
|
29
|
-
for (const candidate of candidates) {
|
|
30
|
-
if (fs_1.default.existsSync(candidate)) {
|
|
31
|
-
return candidate;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Extract all component file paths from React-instrumented element data
|
|
38
|
-
* Returns array of all components in the tree hierarchy
|
|
39
|
-
*/
|
|
40
|
-
findAllComponentFiles(projectPath, element) {
|
|
41
|
-
if (!element._reactComponentInfo) {
|
|
42
|
-
log.debug('No React component info found on element');
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
const { components } = element._reactComponentInfo;
|
|
46
|
-
if (!components || components.length === 0) {
|
|
47
|
-
log.warn('React component info present but no components found');
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
const matches = [];
|
|
51
|
-
for (const component of components) {
|
|
52
|
-
const absolutePath = this.resolveFilePath(projectPath, component.filePath);
|
|
53
|
-
if (absolutePath) {
|
|
54
|
-
log.info(`Found React component: ${absolutePath} (${component.componentName || 'unknown'})`);
|
|
55
|
-
matches.push({
|
|
56
|
-
filePath: absolutePath,
|
|
57
|
-
confidence: 100, // Highest confidence - direct from React
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
log.warn(`React component file not found: ${component.filePath}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return matches;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Extract primary component file path (closest to selected element)
|
|
68
|
-
* Returns exact filepath if React instrumentation provided it, otherwise null
|
|
69
|
-
*/
|
|
70
|
-
findComponentFile(projectPath, element) {
|
|
71
|
-
if (!element._reactComponentInfo) {
|
|
72
|
-
log.debug('No React component info found on element');
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const { primaryComponent } = element._reactComponentInfo;
|
|
76
|
-
if (!primaryComponent || !primaryComponent.filePath) {
|
|
77
|
-
log.warn('React component info present but missing primaryComponent');
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const absolutePath = this.resolveFilePath(projectPath, primaryComponent.filePath);
|
|
81
|
-
if (!absolutePath) {
|
|
82
|
-
log.warn(`React primary component file not found: ${primaryComponent.filePath}`);
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
log.info(`Found React primary component: ${absolutePath} (${primaryComponent.componentName || 'unknown component'})`);
|
|
86
|
-
return {
|
|
87
|
-
filePath: absolutePath,
|
|
88
|
-
confidence: 100, // Highest confidence - direct from React
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Check if element has React component info attached
|
|
93
|
-
*/
|
|
94
|
-
hasReactInfo(element) {
|
|
95
|
-
return (!!element._reactComponentInfo?.components &&
|
|
96
|
-
element._reactComponentInfo.components.length > 0);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.ReactComponentPlugin = ReactComponentPlugin;
|
|
100
|
-
//# sourceMappingURL=ReactComponentPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactComponentPlugin.js","sourceRoot":"","sources":["../../src/services/ReactComponentPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,4CAA+C;AAG/C,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC,sBAAsB,CAAC,CAAC;AAiBjD,MAAa,oBAAoB;IAC/B;;OAEG;IACK,eAAe,CACrB,WAAmB,EACnB,QAAgB;QAEhB,6CAA6C;QAC7C,IAAI,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC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AAC,OAAqD;QAChE,OAAO,CACL,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU;YACzC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAClD,CAAC;IACJ,CAAC;CACF;AArID,oDAqIC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocket message types for communication between Rivet CLI and hosted Agent SDK server
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Messages sent from server to CLI
|
|
6
|
-
*/
|
|
7
|
-
export type ServerToClientMessage = {
|
|
8
|
-
type: 'auth_success';
|
|
9
|
-
sessionId: string;
|
|
10
|
-
} | {
|
|
11
|
-
type: 'auth_error';
|
|
12
|
-
error: string;
|
|
13
|
-
} | {
|
|
14
|
-
type: 'tool_execution';
|
|
15
|
-
requestId: string;
|
|
16
|
-
tool: string;
|
|
17
|
-
params: any;
|
|
18
|
-
} | {
|
|
19
|
-
type: 'agent_chunk';
|
|
20
|
-
chunk: any;
|
|
21
|
-
} | {
|
|
22
|
-
type: 'agent_complete';
|
|
23
|
-
result?: any;
|
|
24
|
-
} | {
|
|
25
|
-
type: 'agent_error';
|
|
26
|
-
error: string;
|
|
27
|
-
} | {
|
|
28
|
-
type: 'ping';
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Messages sent from CLI to server
|
|
32
|
-
*/
|
|
33
|
-
export type ClientToServerMessage = {
|
|
34
|
-
type: 'auth';
|
|
35
|
-
token: string;
|
|
36
|
-
clientInfo: {
|
|
37
|
-
platform: string;
|
|
38
|
-
version: string;
|
|
39
|
-
};
|
|
40
|
-
} | {
|
|
41
|
-
type: 'tool_result';
|
|
42
|
-
requestId: string;
|
|
43
|
-
result: any;
|
|
44
|
-
} | {
|
|
45
|
-
type: 'tool_error';
|
|
46
|
-
requestId: string;
|
|
47
|
-
error: string;
|
|
48
|
-
} | {
|
|
49
|
-
type: 'execute_task';
|
|
50
|
-
instruction: string;
|
|
51
|
-
context?: any;
|
|
52
|
-
} | {
|
|
53
|
-
type: 'pong';
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=agent-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-protocol.d.ts","sourceRoot":"","sources":["../../src/types/agent-protocol.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD,GACD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CA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