rlm-analyzer 1.1.0
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 +226 -0
- package/dist/analyzer.d.ts +58 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +203 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/cli.d.ts +28 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +442 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +118 -0
- package/dist/config.js.map +1 -0
- package/dist/executor.d.ts +71 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +315 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +142 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +19 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +336 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/models.d.ts +101 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +202 -0
- package/dist/models.js.map +1 -0
- package/dist/orchestrator.d.ts +61 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +325 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/prompts.d.ts +48 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +220 -0
- package/dist/prompts.js.map +1 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +87 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RLM REPL Executor
|
|
3
|
+
* Executes Python-like code in a sandboxed JavaScript environment
|
|
4
|
+
* with support for sub-LLM calls
|
|
5
|
+
*/
|
|
6
|
+
import type { ExecutorResult } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* REPL Executor with sandboxed execution
|
|
9
|
+
*/
|
|
10
|
+
export declare class RLMExecutor {
|
|
11
|
+
private variables;
|
|
12
|
+
private output;
|
|
13
|
+
private subCallCount;
|
|
14
|
+
private maxSubCalls;
|
|
15
|
+
private finalAnswer;
|
|
16
|
+
private subLLMCallback;
|
|
17
|
+
constructor(maxSubCalls?: number);
|
|
18
|
+
/**
|
|
19
|
+
* Initialize the execution context with files
|
|
20
|
+
*/
|
|
21
|
+
initialize(files: Record<string, string>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Set the sub-LLM callback
|
|
24
|
+
*/
|
|
25
|
+
setSubLLMCallback(callback: (query: string) => Promise<string>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Execute code and return result
|
|
28
|
+
*/
|
|
29
|
+
execute(code: string): Promise<ExecutorResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Extract code from markdown code blocks
|
|
32
|
+
*/
|
|
33
|
+
private extractCode;
|
|
34
|
+
/**
|
|
35
|
+
* Validate code for security issues
|
|
36
|
+
*/
|
|
37
|
+
private validateSecurity;
|
|
38
|
+
/**
|
|
39
|
+
* Convert Python-like syntax to JavaScript and execute
|
|
40
|
+
*/
|
|
41
|
+
private executeInSandbox;
|
|
42
|
+
/**
|
|
43
|
+
* Convert Python indentation to JavaScript blocks
|
|
44
|
+
*/
|
|
45
|
+
private convertIndentationToBlocks;
|
|
46
|
+
/**
|
|
47
|
+
* Check if final answer was set
|
|
48
|
+
*/
|
|
49
|
+
hasFinalAnswer(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Get the final answer
|
|
52
|
+
*/
|
|
53
|
+
getFinalAnswer(): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Get all output
|
|
56
|
+
*/
|
|
57
|
+
getOutput(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Get sub-call count
|
|
60
|
+
*/
|
|
61
|
+
getSubCallCount(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Reset state for new execution
|
|
64
|
+
*/
|
|
65
|
+
reset(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Clear just the final answer (used when rejecting insufficient analysis)
|
|
68
|
+
*/
|
|
69
|
+
clearFinalAnswer(): void;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAwBjD;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,cAAc,CAAqD;gBAE/D,WAAW,SAAK;IAI5B;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAK/C;;OAEG;IACH,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI;IAIrE;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA+BpD;;OAEG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;YACW,gBAAgB;IAgL9B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAwClC;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;OAEG;IACH,gBAAgB,IAAI,IAAI;CAGzB"}
|
package/dist/executor.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RLM REPL Executor
|
|
3
|
+
* Executes Python-like code in a sandboxed JavaScript environment
|
|
4
|
+
* with support for sub-LLM calls
|
|
5
|
+
*/
|
|
6
|
+
/** Dangerous patterns to block */
|
|
7
|
+
const DANGEROUS_PATTERNS = [
|
|
8
|
+
/\beval\s*\(/,
|
|
9
|
+
/\bFunction\s*\(/,
|
|
10
|
+
/\bexec\s*\(/,
|
|
11
|
+
/\bcompile\s*\(/,
|
|
12
|
+
/\b__import__\s*\(/,
|
|
13
|
+
/\bprocess\s*\./,
|
|
14
|
+
/\brequire\s*\(/,
|
|
15
|
+
/\bimport\s*\(/,
|
|
16
|
+
/\bfs\s*\./,
|
|
17
|
+
/\bchild_process/,
|
|
18
|
+
/\bspawn\s*\(/,
|
|
19
|
+
/\bexecSync\s*\(/,
|
|
20
|
+
/\bwriteFile/,
|
|
21
|
+
/\bunlink\s*\(/,
|
|
22
|
+
/\brmdir\s*\(/,
|
|
23
|
+
/\bfetch\s*\(/,
|
|
24
|
+
/\bXMLHttpRequest/,
|
|
25
|
+
/\bWebSocket/,
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* REPL Executor with sandboxed execution
|
|
29
|
+
*/
|
|
30
|
+
export class RLMExecutor {
|
|
31
|
+
variables = new Map();
|
|
32
|
+
output = [];
|
|
33
|
+
subCallCount = 0;
|
|
34
|
+
maxSubCalls;
|
|
35
|
+
finalAnswer = null;
|
|
36
|
+
subLLMCallback = null;
|
|
37
|
+
constructor(maxSubCalls = 15) {
|
|
38
|
+
this.maxSubCalls = maxSubCalls;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the execution context with files
|
|
42
|
+
*/
|
|
43
|
+
initialize(files) {
|
|
44
|
+
this.variables.set('file_index', files);
|
|
45
|
+
this.variables.set('files', Object.keys(files));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set the sub-LLM callback
|
|
49
|
+
*/
|
|
50
|
+
setSubLLMCallback(callback) {
|
|
51
|
+
this.subLLMCallback = callback;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Execute code and return result
|
|
55
|
+
*/
|
|
56
|
+
async execute(code) {
|
|
57
|
+
// Extract code from markdown blocks
|
|
58
|
+
const cleanCode = this.extractCode(code);
|
|
59
|
+
// Check if this is just a FINAL call (no dangerous operations needed)
|
|
60
|
+
const isFinalOnly = /^\s*FINAL\s*\([\s\S]*?\)\s*;?\s*$/.test(cleanCode.trim());
|
|
61
|
+
// Security validation (skip for FINAL-only calls which just set output)
|
|
62
|
+
if (!isFinalOnly) {
|
|
63
|
+
const securityCheck = this.validateSecurity(cleanCode);
|
|
64
|
+
if (!securityCheck.safe) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
output: '',
|
|
68
|
+
error: `Security violation: ${securityCheck.reason}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const result = await this.executeInSandbox(cleanCode);
|
|
74
|
+
return { success: true, output: result };
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
output: this.output.join('\n'),
|
|
80
|
+
error: error instanceof Error ? error.message : String(error),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Extract code from markdown code blocks
|
|
86
|
+
*/
|
|
87
|
+
extractCode(text) {
|
|
88
|
+
const match = text.match(/```(?:python|javascript|tool_code|js|ts)?\n([\s\S]*?)```/);
|
|
89
|
+
return match ? match[1] : text;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate code for security issues
|
|
93
|
+
*/
|
|
94
|
+
validateSecurity(code) {
|
|
95
|
+
for (const pattern of DANGEROUS_PATTERNS) {
|
|
96
|
+
if (pattern.test(code)) {
|
|
97
|
+
return { safe: false, reason: `Blocked pattern: ${pattern.source}` };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { safe: true };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Convert Python-like syntax to JavaScript and execute
|
|
104
|
+
*/
|
|
105
|
+
async executeInSandbox(pythonCode) {
|
|
106
|
+
const outputBuffer = [];
|
|
107
|
+
const fileIndex = this.variables.get('file_index');
|
|
108
|
+
const files = this.variables.get('files');
|
|
109
|
+
// Python to JavaScript conversion
|
|
110
|
+
let js = pythonCode;
|
|
111
|
+
// Convert Python comments to JavaScript comments
|
|
112
|
+
js = js.replace(/^(\s*)#(.*)$/gm, '$1//$2');
|
|
113
|
+
// Remove Python imports
|
|
114
|
+
js = js.replace(/^import\s+\w+.*$/gm, '// import removed');
|
|
115
|
+
js = js.replace(/^from\s+\w+.*$/gm, '// from import removed');
|
|
116
|
+
// Convert list comprehension [expr for x in list if cond]
|
|
117
|
+
js = js.replace(/\[\s*([^\[\]]+?)\s+for\s+(\w+)\s+in\s+([^\[\]]+?)\s+if\s+([^\[\]]+?)\s*\]/g, '$3.filter($2 => $4).map($2 => $1)');
|
|
118
|
+
// Convert list comprehension [expr for x in list]
|
|
119
|
+
js = js.replace(/\[\s*([^\[\]]+?)\s+for\s+(\w+)\s+in\s+([^\[\]]+?)\s*\]/g, '$3.map($2 => $1)');
|
|
120
|
+
// Convert f-strings
|
|
121
|
+
js = js.replace(/f"([^"]*)"/g, (_, s) => '`' + s.replace(/\{([^}]+)\}/g, '${$1}') + '`');
|
|
122
|
+
js = js.replace(/f'([^']*)'/g, (_, s) => '`' + s.replace(/\{([^}]+)\}/g, '${$1}') + '`');
|
|
123
|
+
// Convert for loops with tuple unpacking
|
|
124
|
+
js = js.replace(/for\s+(\w+)\s*,\s*(\w+)\s+in\s+(\w+)\.items\(\)\s*:/g, 'for (const [$1, $2] of Object.entries($3)) {');
|
|
125
|
+
// Convert simple for loops
|
|
126
|
+
js = js.replace(/for\s+(\w+)\s+in\s+(\w+)\s*:/g, 'for (const $1 of $2) {');
|
|
127
|
+
// Convert if statements
|
|
128
|
+
js = js.replace(/^(\s*)if\s+(.+?)\s*:\s*$/gm, '$1if ($2) {');
|
|
129
|
+
js = js.replace(/^(\s*)elif\s+(.+?)\s*:\s*$/gm, '$1} else if ($2) {');
|
|
130
|
+
js = js.replace(/^(\s*)else\s*:\s*$/gm, '$1} else {');
|
|
131
|
+
// Handle indentation-based blocks
|
|
132
|
+
js = this.convertIndentationToBlocks(js);
|
|
133
|
+
// Python built-ins
|
|
134
|
+
js = js.replace(/\blen\((\w+)\)/g, '$1.length');
|
|
135
|
+
js = js.replace(/\bTrue\b/g, 'true');
|
|
136
|
+
js = js.replace(/\bFalse\b/g, 'false');
|
|
137
|
+
js = js.replace(/\bNone\b/g, 'null');
|
|
138
|
+
// Only convert and/or/not when clearly in boolean context (after if/while/elif or between parens)
|
|
139
|
+
// Avoid converting inside strings which would corrupt text output
|
|
140
|
+
js = js.replace(/\bif\s*\(([^)]*)\band\b([^)]*)\)/g, 'if ($1&&$2)');
|
|
141
|
+
js = js.replace(/\bif\s*\(([^)]*)\bor\b([^)]*)\)/g, 'if ($1||$2)');
|
|
142
|
+
js = js.replace(/\bwhile\s*\(([^)]*)\band\b([^)]*)\)/g, 'while ($1&&$2)');
|
|
143
|
+
js = js.replace(/\bwhile\s*\(([^)]*)\bor\b([^)]*)\)/g, 'while ($1||$2)');
|
|
144
|
+
js = js.replace(/\bnot\s+(\w)/g, '!$1');
|
|
145
|
+
// Dict methods - convert .get(key) and .get(key, default)
|
|
146
|
+
js = js.replace(/\.get\(([^,)]+),\s*([^)]+)\)/g, '?.[$1] ?? $2');
|
|
147
|
+
js = js.replace(/\.get\(([^)]+)\)/g, '?.[$1]');
|
|
148
|
+
// Dict methods - .keys(), .values()
|
|
149
|
+
js = js.replace(/(\w+)\.keys\(\)/g, 'Object.keys($1)');
|
|
150
|
+
js = js.replace(/(\w+)\.values\(\)/g, 'Object.values($1)');
|
|
151
|
+
// .items() is already handled in the for loop conversion
|
|
152
|
+
// String methods
|
|
153
|
+
js = js.replace(/\.lower\(\)/g, '.toLowerCase()');
|
|
154
|
+
js = js.replace(/\.upper\(\)/g, '.toUpperCase()');
|
|
155
|
+
js = js.replace(/\.strip\(\)/g, '.trim()');
|
|
156
|
+
js = js.replace(/\.split\(\)/g, '.split(" ")');
|
|
157
|
+
js = js.replace(/\.endswith\(/g, '.endsWith(');
|
|
158
|
+
js = js.replace(/\.startswith\(/g, '.startsWith(');
|
|
159
|
+
// Slicing - handle both simple vars and complex accessors like dict["key"][:n]
|
|
160
|
+
// First handle complex accessor patterns (dict["key"][:n])
|
|
161
|
+
js = js.replace(/(\]\s*)\[:(\d+)\]/g, '$1.slice(0, $2)');
|
|
162
|
+
js = js.replace(/(\]\s*)\[(\d+):\]/g, '$1.slice($2)');
|
|
163
|
+
js = js.replace(/(\]\s*)\[(-?\d+):(-?\d+)\]/g, '$1.slice($2, $3)');
|
|
164
|
+
// Then handle simple variable slicing
|
|
165
|
+
js = js.replace(/(\w+)\[:(\d+)\]/g, '$1.slice(0, $2)');
|
|
166
|
+
js = js.replace(/(\w+)\[(\d+):\]/g, '$1.slice($2)');
|
|
167
|
+
js = js.replace(/(\w+)\[(-?\d+):(-?\d+)\]/g, '$1.slice($2, $3)');
|
|
168
|
+
// String containment: "x" in str -> str.includes("x")
|
|
169
|
+
js = js.replace(/"([^"]+)"\s+in\s+(\w+)/g, '$2.includes("$1")');
|
|
170
|
+
js = js.replace(/'([^']+)'\s+in\s+(\w+)/g, "$2.includes('$1')");
|
|
171
|
+
// Convert Python triple-quoted strings to JS template literals
|
|
172
|
+
js = js.replace(/"""([\s\S]*?)"""/g, '`$1`');
|
|
173
|
+
js = js.replace(/'''([\s\S]*?)'''/g, '`$1`');
|
|
174
|
+
// Function mappings
|
|
175
|
+
js = js.replace(/\bprint\(/g, '_print(');
|
|
176
|
+
js = js.replace(/\bllm_query\(/g, 'await _llmQuery(');
|
|
177
|
+
js = js.replace(/\bFINAL\((['"`][\s\S]*?['"`])\)/g, '_setFinal($1)');
|
|
178
|
+
// Create sandbox with limited scope
|
|
179
|
+
const sandbox = {
|
|
180
|
+
file_index: fileIndex,
|
|
181
|
+
files: files,
|
|
182
|
+
_print: (...args) => {
|
|
183
|
+
const str = args.map(a => typeof a === 'string' ? a : JSON.stringify(a, null, 2)).join(' ');
|
|
184
|
+
outputBuffer.push(str);
|
|
185
|
+
this.output.push(str);
|
|
186
|
+
return str;
|
|
187
|
+
},
|
|
188
|
+
_llmQuery: async (query) => {
|
|
189
|
+
if (this.subCallCount >= this.maxSubCalls) {
|
|
190
|
+
throw new Error(`Maximum sub-LLM calls (${this.maxSubCalls}) exceeded`);
|
|
191
|
+
}
|
|
192
|
+
if (!this.subLLMCallback) {
|
|
193
|
+
throw new Error('Sub-LLM callback not configured');
|
|
194
|
+
}
|
|
195
|
+
this.subCallCount++;
|
|
196
|
+
return this.subLLMCallback(query);
|
|
197
|
+
},
|
|
198
|
+
_setFinal: (answer) => {
|
|
199
|
+
const str = typeof answer === 'string' ? answer : JSON.stringify(answer, null, 2);
|
|
200
|
+
this.finalAnswer = str;
|
|
201
|
+
return str;
|
|
202
|
+
},
|
|
203
|
+
// FINAL function (also available directly without conversion)
|
|
204
|
+
FINAL: (answer) => {
|
|
205
|
+
const str = typeof answer === 'string' ? answer : JSON.stringify(answer, null, 2);
|
|
206
|
+
this.finalAnswer = str;
|
|
207
|
+
return str;
|
|
208
|
+
},
|
|
209
|
+
// llm_query function (also available directly)
|
|
210
|
+
llm_query: async (query) => {
|
|
211
|
+
if (this.subCallCount >= this.maxSubCalls) {
|
|
212
|
+
throw new Error(`Maximum sub-LLM calls (${this.maxSubCalls}) exceeded`);
|
|
213
|
+
}
|
|
214
|
+
if (!this.subLLMCallback) {
|
|
215
|
+
throw new Error('Sub-LLM callback not configured');
|
|
216
|
+
}
|
|
217
|
+
this.subCallCount++;
|
|
218
|
+
return this.subLLMCallback(query);
|
|
219
|
+
},
|
|
220
|
+
// Safe built-ins
|
|
221
|
+
Object, Array, Math, JSON, String, Number, RegExp, Date,
|
|
222
|
+
parseInt, parseFloat, isNaN, isFinite,
|
|
223
|
+
encodeURIComponent, decodeURIComponent,
|
|
224
|
+
console: {
|
|
225
|
+
log: (...args) => outputBuffer.push(args.map(String).join(' ')),
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
// Execute in async context
|
|
229
|
+
const asyncFn = new Function('sandbox', `
|
|
230
|
+
with (sandbox) {
|
|
231
|
+
return (async () => {
|
|
232
|
+
${js}
|
|
233
|
+
})();
|
|
234
|
+
}
|
|
235
|
+
`);
|
|
236
|
+
await asyncFn(sandbox);
|
|
237
|
+
return outputBuffer.join('\n');
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Convert Python indentation to JavaScript blocks
|
|
241
|
+
*/
|
|
242
|
+
convertIndentationToBlocks(code) {
|
|
243
|
+
const lines = code.split('\n');
|
|
244
|
+
const processed = [];
|
|
245
|
+
const indentStack = [0];
|
|
246
|
+
for (let i = 0; i < lines.length; i++) {
|
|
247
|
+
const line = lines[i];
|
|
248
|
+
const trimmed = line.trimStart();
|
|
249
|
+
const indent = line.length - trimmed.length;
|
|
250
|
+
// Skip empty lines
|
|
251
|
+
if (!trimmed) {
|
|
252
|
+
processed.push(line);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
// Close braces for dedented lines
|
|
256
|
+
while (indentStack.length > 1 && indent < indentStack[indentStack.length - 1]) {
|
|
257
|
+
indentStack.pop();
|
|
258
|
+
processed.push(' '.repeat(indentStack[indentStack.length - 1]) + '}');
|
|
259
|
+
}
|
|
260
|
+
// Track new indentation after opening braces
|
|
261
|
+
if (trimmed.endsWith('{')) {
|
|
262
|
+
processed.push(line);
|
|
263
|
+
indentStack.push(indent + 4);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
processed.push(line);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Close remaining blocks
|
|
270
|
+
while (indentStack.length > 1) {
|
|
271
|
+
indentStack.pop();
|
|
272
|
+
processed.push('}');
|
|
273
|
+
}
|
|
274
|
+
return processed.join('\n');
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Check if final answer was set
|
|
278
|
+
*/
|
|
279
|
+
hasFinalAnswer() {
|
|
280
|
+
return this.finalAnswer !== null;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get the final answer
|
|
284
|
+
*/
|
|
285
|
+
getFinalAnswer() {
|
|
286
|
+
return this.finalAnswer;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Get all output
|
|
290
|
+
*/
|
|
291
|
+
getOutput() {
|
|
292
|
+
return this.output.join('\n');
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Get sub-call count
|
|
296
|
+
*/
|
|
297
|
+
getSubCallCount() {
|
|
298
|
+
return this.subCallCount;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Reset state for new execution
|
|
302
|
+
*/
|
|
303
|
+
reset() {
|
|
304
|
+
this.output = [];
|
|
305
|
+
this.subCallCount = 0;
|
|
306
|
+
this.finalAnswer = null;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Clear just the final answer (used when rejecting insufficient analysis)
|
|
310
|
+
*/
|
|
311
|
+
clearFinalAnswer() {
|
|
312
|
+
this.finalAnswer = null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,kCAAkC;AAClC,MAAM,kBAAkB,GAAG;IACzB,aAAa;IACb,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,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AC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RLM Analyzer
|
|
3
|
+
* Recursive Language Model code analysis tool
|
|
4
|
+
*
|
|
5
|
+
* Based on MIT CSAIL research: arXiv:2512.24601v1
|
|
6
|
+
* "Recursive Language Models: A Paradigm for Processing Arbitrarily Long Inputs"
|
|
7
|
+
*/
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
export { getApiKey, getAIClient, initConfig, hasApiKey } from './config.js';
|
|
10
|
+
export { resolveModelConfig, getDefaultModel, getFallbackModel, resolveModelAlias, isModelAlias, getModelConfigDisplay, getAliasesDisplay, MODEL_ALIASES, AVAILABLE_MODELS, DEFAULT_MODEL, FALLBACK_MODEL, type ModelConfigOptions, type ResolvedModelConfig, } from './models.js';
|
|
11
|
+
export { RLMExecutor } from './executor.js';
|
|
12
|
+
export { RLMOrchestrator } from './orchestrator.js';
|
|
13
|
+
export { loadFiles, analyzeCodebase, analyzeArchitecture, analyzeDependencies, analyzeSecurity, analyzePerformance, analyzeRefactoring, summarizeCodebase, findUsages, explainFile, askQuestion, } from './analyzer.js';
|
|
14
|
+
export { CODE_ANALYSIS_PROMPT, ARCHITECTURE_PROMPT, DEPENDENCY_PROMPT, SECURITY_PROMPT, PERFORMANCE_PROMPT, REFACTOR_PROMPT, SUMMARY_PROMPT, getSystemPrompt, getAnalysisPrompt, buildContextMessage, } from './prompts.js';
|
|
15
|
+
import { RLMOrchestrator } from './orchestrator.js';
|
|
16
|
+
import type { RLMConfig, CodeAnalysisOptions, CodeAnalysisResult } from './types.js';
|
|
17
|
+
import type { ResolvedModelConfig, ModelConfigOptions } from './models.js';
|
|
18
|
+
/**
|
|
19
|
+
* Options for creating an analyzer instance
|
|
20
|
+
*/
|
|
21
|
+
export interface CreateAnalyzerOptions {
|
|
22
|
+
/** Model to use (can be alias like 'fast' or 'smart') */
|
|
23
|
+
model?: string;
|
|
24
|
+
/** Fallback model to use */
|
|
25
|
+
fallbackModel?: string;
|
|
26
|
+
/** Enable verbose output */
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
/** RLM configuration overrides */
|
|
29
|
+
config?: Partial<RLMConfig>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Analyzer instance returned by createAnalyzer()
|
|
33
|
+
*/
|
|
34
|
+
export interface AnalyzerInstance {
|
|
35
|
+
/** Analyze a directory */
|
|
36
|
+
analyze: (directory: string, options?: Partial<CodeAnalysisOptions>) => Promise<CodeAnalysisResult>;
|
|
37
|
+
/** The underlying orchestrator */
|
|
38
|
+
orchestrator: RLMOrchestrator;
|
|
39
|
+
/** The resolved configuration */
|
|
40
|
+
config: RLMConfig;
|
|
41
|
+
/** The resolved model configuration */
|
|
42
|
+
modelConfig: ResolvedModelConfig;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create an analyzer instance for IDE integration
|
|
46
|
+
*
|
|
47
|
+
* This is the recommended way to use RLM Analyzer programmatically.
|
|
48
|
+
* It handles model resolution using the priority chain and returns
|
|
49
|
+
* a configured analyzer ready for use.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { createAnalyzer } from 'rlm-analyzer';
|
|
54
|
+
*
|
|
55
|
+
* // Use default configuration
|
|
56
|
+
* const analyzer = createAnalyzer();
|
|
57
|
+
* const result = await analyzer.analyze('./my-project');
|
|
58
|
+
*
|
|
59
|
+
* // Use specific model
|
|
60
|
+
* const fastAnalyzer = createAnalyzer({ model: 'fast' });
|
|
61
|
+
* const result = await fastAnalyzer.analyze('./my-project');
|
|
62
|
+
*
|
|
63
|
+
* // Access the orchestrator directly
|
|
64
|
+
* const orchestrator = analyzer.orchestrator;
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @param options - Configuration options
|
|
68
|
+
* @returns Analyzer instance with analyze function and orchestrator
|
|
69
|
+
*/
|
|
70
|
+
export declare function createAnalyzer(options?: CreateAnalyzerOptions): AnalyzerInstance;
|
|
71
|
+
/**
|
|
72
|
+
* Options for creating an orchestrator instance
|
|
73
|
+
*/
|
|
74
|
+
export interface CreateOrchestratorOptions {
|
|
75
|
+
/** Model to use (can be alias like 'fast' or 'smart') */
|
|
76
|
+
model?: string;
|
|
77
|
+
/** Enable verbose output */
|
|
78
|
+
verbose?: boolean;
|
|
79
|
+
/** RLM configuration overrides */
|
|
80
|
+
config?: Partial<RLMConfig>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a configured RLMOrchestrator instance
|
|
84
|
+
*
|
|
85
|
+
* Use this when you need direct access to the orchestrator
|
|
86
|
+
* for custom workflows or advanced use cases.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import { createOrchestrator, loadFiles } from 'rlm-analyzer';
|
|
91
|
+
*
|
|
92
|
+
* const orchestrator = createOrchestrator({ model: 'smart' });
|
|
93
|
+
* const files = await loadFiles('./src');
|
|
94
|
+
* const result = await orchestrator.processQuery(
|
|
95
|
+
* 'Explain this codebase',
|
|
96
|
+
* { files, variables: {}, mode: 'code-analysis' }
|
|
97
|
+
* );
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param options - Configuration options
|
|
101
|
+
* @returns Configured RLMOrchestrator instance
|
|
102
|
+
*/
|
|
103
|
+
export declare function createOrchestrator(options?: CreateOrchestratorOptions): RLMOrchestrator;
|
|
104
|
+
/**
|
|
105
|
+
* Get resolved model configuration
|
|
106
|
+
*
|
|
107
|
+
* Use this to check what models will be used based on
|
|
108
|
+
* the current environment, config file, and any overrides.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { getModelConfig } from 'rlm-analyzer';
|
|
113
|
+
*
|
|
114
|
+
* const config = getModelConfig();
|
|
115
|
+
* console.log(`Default model: ${config.defaultModel}`);
|
|
116
|
+
* console.log(`Source: ${config.defaultSource}`);
|
|
117
|
+
*
|
|
118
|
+
* // With override
|
|
119
|
+
* const custom = getModelConfig({ model: 'fast' });
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @param options - Optional model overrides
|
|
123
|
+
* @returns Resolved model configuration with source information
|
|
124
|
+
*/
|
|
125
|
+
export declare function getModelConfig(options?: ModelConfigOptions): ResolvedModelConfig;
|
|
126
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG5E,OAAO,EAEL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EAGZ,qBAAqB,EACrB,iBAAiB,EAGjB,aAAa,EACb,gBAAgB,EAGhB,aAAa,EACb,cAAc,EAGd,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EACL,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,eAAe,EAAE,MAAM,m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