@cogitator-ai/self-modifying 1.0.0 → 2.0.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/dist/architecture-evolution/parameter-optimizer.js +1 -1
- package/dist/architecture-evolution/parameter-optimizer.js.map +1 -1
- package/dist/architecture-evolution/prompts.js +3 -3
- package/dist/architecture-evolution/prompts.js.map +1 -1
- package/dist/constraints/modification-validator.js +5 -5
- package/dist/constraints/modification-validator.js.map +1 -1
- package/dist/events/event-emitter.js +1 -1
- package/dist/events/event-emitter.js.map +1 -1
- package/dist/meta-reasoning/meta-reasoner.js +1 -1
- package/dist/meta-reasoning/meta-reasoner.js.map +1 -1
- package/dist/meta-reasoning/prompts.js +1 -1
- package/dist/meta-reasoning/prompts.js.map +1 -1
- package/dist/self-modifying-agent.d.ts.map +1 -1
- package/dist/self-modifying-agent.js +13 -17
- package/dist/self-modifying-agent.js.map +1 -1
- package/dist/tool-generation/gap-analyzer.js +1 -1
- package/dist/tool-generation/gap-analyzer.js.map +1 -1
- package/dist/tool-generation/prompts.js +3 -3
- package/dist/tool-generation/prompts.js.map +1 -1
- package/dist/tool-generation/tool-generator.d.ts +1 -1
- package/dist/tool-generation/tool-generator.d.ts.map +1 -1
- package/dist/tool-generation/tool-generator.js +3 -2
- package/dist/tool-generation/tool-generator.js.map +1 -1
- package/dist/tool-generation/tool-sandbox.d.ts.map +1 -1
- package/dist/tool-generation/tool-sandbox.js +7 -6
- package/dist/tool-generation/tool-sandbox.js.map +1 -1
- package/dist/tool-generation/tool-validator.js +5 -5
- package/dist/tool-generation/tool-validator.js.map +1 -1
- package/package.json +4 -4
- package/src/architecture-evolution/parameter-optimizer.ts +2 -2
- package/src/architecture-evolution/prompts.ts +3 -3
- package/src/constraints/modification-validator.ts +5 -5
- package/src/events/event-emitter.ts +1 -1
- package/src/meta-reasoning/meta-reasoner.ts +1 -1
- package/src/meta-reasoning/prompts.ts +1 -1
- package/src/self-modifying-agent.ts +13 -17
- package/src/tool-generation/gap-analyzer.ts +1 -1
- package/src/tool-generation/prompts.ts +3 -3
- package/src/tool-generation/tool-generator.ts +3 -3
- package/src/tool-generation/tool-sandbox.ts +8 -8
- package/src/tool-generation/tool-validator.ts +5 -5
|
@@ -176,18 +176,16 @@ export class ToolSandbox {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
private createContext(): SandboxContext {
|
|
179
|
-
const sandbox = this;
|
|
180
|
-
|
|
181
179
|
return {
|
|
182
180
|
console: {
|
|
183
181
|
log: (...args: unknown[]) => {
|
|
184
|
-
|
|
182
|
+
this.logs.push(`[LOG] ${args.map(String).join(' ')}`);
|
|
185
183
|
},
|
|
186
184
|
warn: (...args: unknown[]) => {
|
|
187
|
-
|
|
185
|
+
this.logs.push(`[WARN] ${args.map(String).join(' ')}`);
|
|
188
186
|
},
|
|
189
187
|
error: (...args: unknown[]) => {
|
|
190
|
-
|
|
188
|
+
this.logs.push(`[ERROR] ${args.map(String).join(' ')}`);
|
|
191
189
|
},
|
|
192
190
|
},
|
|
193
191
|
Math,
|
|
@@ -236,6 +234,7 @@ export class ToolSandbox {
|
|
|
236
234
|
}, timeout);
|
|
237
235
|
|
|
238
236
|
try {
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
239
238
|
const factory = new Function(wrappedCode);
|
|
240
239
|
const executor = factory();
|
|
241
240
|
|
|
@@ -244,13 +243,13 @@ export class ToolSandbox {
|
|
|
244
243
|
clearTimeout(timer);
|
|
245
244
|
resolve(result);
|
|
246
245
|
})
|
|
247
|
-
.catch((error) => {
|
|
246
|
+
.catch((error: unknown) => {
|
|
248
247
|
clearTimeout(timer);
|
|
249
|
-
reject(error);
|
|
248
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
250
249
|
});
|
|
251
250
|
} catch (error) {
|
|
252
251
|
clearTimeout(timer);
|
|
253
|
-
reject(error);
|
|
252
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
254
253
|
}
|
|
255
254
|
});
|
|
256
255
|
}
|
|
@@ -261,6 +260,7 @@ export class ToolSandbox {
|
|
|
261
260
|
startTime: number
|
|
262
261
|
): Promise<ToolSandboxResult> {
|
|
263
262
|
try {
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
264
264
|
const factory = new Function(`
|
|
265
265
|
"use strict";
|
|
266
266
|
${tool.implementation}
|
|
@@ -56,9 +56,9 @@ const STATIC_VALIDATION_RULES: ValidationRule[] = [
|
|
|
56
56
|
name: 'No prototype pollution',
|
|
57
57
|
severity: 'error',
|
|
58
58
|
check: (code) => {
|
|
59
|
-
if (
|
|
59
|
+
if (code.includes('__proto__')) return 'Uses __proto__';
|
|
60
60
|
if (/\.prototype\s*=/.test(code)) return 'Modifies prototype';
|
|
61
|
-
if (
|
|
61
|
+
if (code.includes('Object.setPrototypeOf')) return 'Uses setPrototypeOf';
|
|
62
62
|
return null;
|
|
63
63
|
},
|
|
64
64
|
},
|
|
@@ -67,10 +67,10 @@ const STATIC_VALIDATION_RULES: ValidationRule[] = [
|
|
|
67
67
|
name: 'No obvious infinite loops',
|
|
68
68
|
severity: 'warning',
|
|
69
69
|
check: (code) => {
|
|
70
|
-
if (/while\s*\(\s*true\s*\)/.test(code) &&
|
|
70
|
+
if (/while\s*\(\s*true\s*\)/.test(code) && !code.includes('break')) {
|
|
71
71
|
return 'Contains while(true) without break';
|
|
72
72
|
}
|
|
73
|
-
if (/for\s*\(\s*;\s*;\s*\)/.test(code) &&
|
|
73
|
+
if (/for\s*\(\s*;\s*;\s*\)/.test(code) && !code.includes('break')) {
|
|
74
74
|
return 'Contains for(;;) without break';
|
|
75
75
|
}
|
|
76
76
|
return null;
|
|
@@ -107,7 +107,7 @@ const STATIC_VALIDATION_RULES: ValidationRule[] = [
|
|
|
107
107
|
name: 'No shell command execution',
|
|
108
108
|
severity: 'error',
|
|
109
109
|
check: (code) => {
|
|
110
|
-
if (
|
|
110
|
+
if (code.includes('child_process')) return 'Uses child_process';
|
|
111
111
|
if (/\bexec\s*\(/.test(code)) return 'Uses exec()';
|
|
112
112
|
if (/\bspawn\s*\(/.test(code)) return 'Uses spawn()';
|
|
113
113
|
if (/\bexecSync\s*\(/.test(code)) return 'Uses execSync()';
|