@castlemilk/omega 0.6.14 → 0.6.16
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/cli.js +803 -38
- package/dist/server/dist/app.js +2 -2
- package/dist/server/dist/app.js.map +1 -1
- package/dist/server/dist/routes/benchmarks.d.ts +4 -0
- package/dist/server/dist/routes/benchmarks.d.ts.map +1 -0
- package/dist/server/dist/routes/benchmarks.js +131 -0
- package/dist/server/dist/routes/benchmarks.js.map +1 -0
- package/dist/server/dist/routes/prompt-versions.d.ts.map +1 -1
- package/dist/server/dist/routes/prompt-versions.js +15 -19
- package/dist/server/dist/routes/prompt-versions.js.map +1 -1
- package/dist/server/node_modules/@grpc/proto-loader/build/bin/proto-loader-gen-types.js +0 -0
- package/dist/server/node_modules/@omega/agent/dist/index.d.ts +1 -1
- package/dist/server/node_modules/@omega/agent/dist/index.d.ts.map +1 -1
- package/dist/server/node_modules/@omega/agent/dist/index.js +1 -1
- package/dist/server/node_modules/@omega/agent/dist/index.js.map +1 -1
- package/dist/server/node_modules/@omega/agent/dist/prompts.d.ts +1 -1
- package/dist/server/node_modules/@omega/agent/dist/prompts.d.ts.map +1 -1
- package/dist/server/node_modules/@omega/agent/dist/prompts.js +23 -13
- package/dist/server/node_modules/@omega/agent/dist/prompts.js.map +1 -1
- package/dist/server/node_modules/@omega/db/generated/client/libquery_engine-darwin-arm64.dylib.node +0 -0
- package/dist/server/node_modules/mime/cli.js +0 -0
- package/dist/server/node_modules/mime/src/build.js +0 -0
- package/dist/server/node_modules/wrap-ansi/index.js +0 -0
- package/dist/server/pglite-data/base/5/1247 +0 -0
- package/dist/server/pglite-data/base/5/1249 +0 -0
- package/dist/server/pglite-data/base/5/1259 +0 -0
- package/dist/server/pglite-data/base/5/16394 +0 -0
- package/dist/server/pglite-data/base/5/16404 +0 -0
- package/dist/server/pglite-data/base/5/16406 +0 -0
- package/dist/server/pglite-data/base/5/16421 +0 -0
- package/dist/server/pglite-data/base/5/16510 +0 -0
- package/dist/server/pglite-data/base/5/2604 +0 -0
- package/dist/server/pglite-data/base/5/2606 +0 -0
- package/dist/server/pglite-data/base/5/2610 +0 -0
- package/dist/server/pglite-data/base/5/2620 +0 -0
- package/dist/server/pglite-data/base/5/2662 +0 -0
- package/dist/server/pglite-data/base/5/2663 +0 -0
- package/dist/server/pglite-data/base/5/pg_internal.init +0 -0
- package/dist/server/pglite-data/global/pg_control +0 -0
- package/dist/server/pglite-data/global/pg_internal.init +0 -0
- package/dist/server/pglite-data/pg_wal/000000010000000000000001 +0 -0
- package/dist/server/pglite-data/pg_xact/0000 +0 -0
- package/dist/server/pglite-data/postmaster.pid +1 -1
- package/dist/server/src/app.ts +2 -2
- package/dist/server/src/routes/benchmarks.ts +152 -0
- package/dist/server/src/routes/prompt-versions.ts +15 -20
- package/dist/web/dist/assets/index-B_XBuJZF.js +40 -0
- package/dist/web/dist/assets/index-CL9S3Jj5.js +40 -0
- package/dist/web/dist/assets/index-bU-GzLxD.css +1 -0
- package/dist/web/dist/index.html +2 -2
- package/package.json +14 -13
package/dist/server/dist/app.js
CHANGED
|
@@ -7,7 +7,7 @@ import { providerRoutes } from './routes/providers.js';
|
|
|
7
7
|
import { routerRoutes } from './routes/router.js';
|
|
8
8
|
import { metricsRoutes } from './routes/metrics.js';
|
|
9
9
|
import { promptVersionRoutes } from './routes/prompt-versions.js';
|
|
10
|
-
import {
|
|
10
|
+
import { benchmarkRoutes } from './routes/benchmarks.js';
|
|
11
11
|
export const app = express();
|
|
12
12
|
app.use(cors());
|
|
13
13
|
app.use(express.json());
|
|
@@ -17,7 +17,7 @@ app.use('/providers', providerRoutes(prisma));
|
|
|
17
17
|
app.use('/router', routerRoutes(prisma));
|
|
18
18
|
app.use('/metrics', metricsRoutes(prisma));
|
|
19
19
|
app.use('/prompt-versions', promptVersionRoutes(prisma));
|
|
20
|
-
app.use('/
|
|
20
|
+
app.use('/benchmarks', benchmarkRoutes(prisma));
|
|
21
21
|
app.use((err, _req, res, _next) => {
|
|
22
22
|
console.error(err);
|
|
23
23
|
const message = err instanceof Error ? err.message : 'Internal error';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,GAAG,GAAoB,OAAO,EAAE,CAAC;AAE9C,GAA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E,YAAY,EAAE,MAAM,WAAW,CAAC;AAyD9C,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CA6F7D"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { asyncHandler } from '../lib/async-handler.js';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const root = path.resolve(__filename, '..', '..', '..', '..');
|
|
10
|
+
const reportsDir = path.join(root, '.omega', 'reports');
|
|
11
|
+
const statusFile = path.join(root, '.omega', 'bench-run-status.json');
|
|
12
|
+
const runSchema = z.object({
|
|
13
|
+
suite: z.enum(['synthetic', 'deep-swe']).optional(),
|
|
14
|
+
nTasks: z.number().int().positive().optional(),
|
|
15
|
+
provider: z.string().optional(),
|
|
16
|
+
model: z.string().optional(),
|
|
17
|
+
timeout: z.number().int().positive().optional(),
|
|
18
|
+
});
|
|
19
|
+
async function readStatus() {
|
|
20
|
+
try {
|
|
21
|
+
const raw = await fs.readFile(statusFile, 'utf-8');
|
|
22
|
+
return JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return { running: false };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function writeStatus(status) {
|
|
29
|
+
await fs.mkdir(path.dirname(statusFile), { recursive: true });
|
|
30
|
+
await fs.writeFile(statusFile, JSON.stringify(status, null, 2), 'utf-8');
|
|
31
|
+
}
|
|
32
|
+
function isReportFile(name, prefix) {
|
|
33
|
+
return name.startsWith(prefix) && name.endsWith('.json');
|
|
34
|
+
}
|
|
35
|
+
async function listReports(prefix) {
|
|
36
|
+
try {
|
|
37
|
+
const files = await fs.readdir(reportsDir);
|
|
38
|
+
return files
|
|
39
|
+
.filter((f) => isReportFile(f, prefix))
|
|
40
|
+
.sort()
|
|
41
|
+
.reverse();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function benchmarkRoutes(_prisma) {
|
|
48
|
+
const r = Router();
|
|
49
|
+
r.get('/reports', asyncHandler(async (_req, res) => {
|
|
50
|
+
const [benchmark, ab] = await Promise.all([
|
|
51
|
+
listReports('benchmark-'),
|
|
52
|
+
listReports('ab-'),
|
|
53
|
+
]);
|
|
54
|
+
res.json({ benchmark, ab });
|
|
55
|
+
}));
|
|
56
|
+
r.get('/reports/:file', asyncHandler(async (req, res) => {
|
|
57
|
+
const file = req.params.file;
|
|
58
|
+
if (!isReportFile(file, 'benchmark-') && !isReportFile(file, 'ab-')) {
|
|
59
|
+
res.status(400).json({ error: 'Invalid report file' });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const filePath = path.join(reportsDir, file);
|
|
63
|
+
const resolved = path.resolve(filePath);
|
|
64
|
+
const resolvedReportsDir = path.resolve(reportsDir);
|
|
65
|
+
if (!resolved.startsWith(resolvedReportsDir + path.sep) && resolved !== resolvedReportsDir) {
|
|
66
|
+
res.status(400).json({ error: 'Invalid report path' });
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const raw = await fs.readFile(filePath, 'utf-8');
|
|
71
|
+
const data = JSON.parse(raw);
|
|
72
|
+
res.json(data);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
res.status(404).json({ error: 'Report not found' });
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
r.post('/run', asyncHandler(async (req, res) => {
|
|
79
|
+
const body = runSchema.parse(req.body);
|
|
80
|
+
const status = await readStatus();
|
|
81
|
+
if (status.running) {
|
|
82
|
+
res.status(409).json({ error: 'Benchmark run already in progress', pid: status.pid });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const args = ['apps/cli/dist/index.js', 'bench', 'run'];
|
|
86
|
+
if (body.suite) {
|
|
87
|
+
args.push('--suite', body.suite);
|
|
88
|
+
}
|
|
89
|
+
if (body.nTasks) {
|
|
90
|
+
args.push('--n-tasks', String(body.nTasks));
|
|
91
|
+
}
|
|
92
|
+
if (body.timeout) {
|
|
93
|
+
args.push('--timeout', String(body.timeout));
|
|
94
|
+
}
|
|
95
|
+
if (body.provider) {
|
|
96
|
+
args.push('--provider', body.provider);
|
|
97
|
+
}
|
|
98
|
+
if (body.model) {
|
|
99
|
+
args.push('--model', body.model);
|
|
100
|
+
}
|
|
101
|
+
const child = spawn('node', args, {
|
|
102
|
+
cwd: root,
|
|
103
|
+
detached: true,
|
|
104
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
105
|
+
});
|
|
106
|
+
let output = '';
|
|
107
|
+
child.stdout.on('data', (chunk) => {
|
|
108
|
+
output += chunk.toString();
|
|
109
|
+
});
|
|
110
|
+
child.stderr.on('data', (chunk) => {
|
|
111
|
+
output += chunk.toString();
|
|
112
|
+
});
|
|
113
|
+
child.on('exit', () => {
|
|
114
|
+
void (async () => {
|
|
115
|
+
const current = await readStatus();
|
|
116
|
+
if (current.pid === child.pid) {
|
|
117
|
+
await writeStatus({ running: false, output });
|
|
118
|
+
}
|
|
119
|
+
})();
|
|
120
|
+
});
|
|
121
|
+
child.unref();
|
|
122
|
+
await writeStatus({ running: true, pid: child.pid, output: '' });
|
|
123
|
+
res.status(202).json({ pid: child.pid, status: 'started' });
|
|
124
|
+
}));
|
|
125
|
+
r.get('/run-status', asyncHandler(async (_req, res) => {
|
|
126
|
+
const status = await readStatus();
|
|
127
|
+
res.json(status);
|
|
128
|
+
}));
|
|
129
|
+
return r;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=benchmarks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benchmarks.js","sourceRoot":"","sources":["../../src/routes/benchmarks.ts"],"names":[],"m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AE,EAAE,EAAE,CAAC,CAAC;QACjE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC,CAAC;IAEJ,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACpD,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;QAClC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-versions.d.ts","sourceRoot":"","sources":["../../src/routes/prompt-versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-versions.d.ts","sourceRoot":"","sources":["../../src/routes/prompt-versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAa9C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CA0BhE"}
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { asyncHandler } from '../lib/async-handler.js';
|
|
4
|
-
import { createPromptVersionRepository } from '@omega/db';
|
|
5
4
|
const createSchema = z.object({
|
|
6
5
|
name: z.string().min(1),
|
|
7
6
|
sourcePath: z.string().min(1),
|
|
8
|
-
systemPrompt: z.string(),
|
|
9
|
-
textToolsPrompt: z.string(),
|
|
7
|
+
systemPrompt: z.string().min(1),
|
|
8
|
+
textToolsPrompt: z.string().min(1),
|
|
10
9
|
hash: z.string().min(1),
|
|
11
10
|
metadata: z.record(z.unknown()).optional(),
|
|
12
11
|
});
|
|
13
12
|
export function promptVersionRoutes(prisma) {
|
|
14
|
-
const repo = createPromptVersionRepository(prisma);
|
|
15
13
|
const r = Router();
|
|
16
14
|
r.get('/', asyncHandler(async (_req, res) => {
|
|
17
|
-
const versions = await
|
|
15
|
+
const versions = await prisma.promptVersion.findMany({
|
|
16
|
+
orderBy: { createdAt: 'desc' },
|
|
17
|
+
});
|
|
18
18
|
res.json(versions);
|
|
19
19
|
}));
|
|
20
|
-
r.get('/:id', asyncHandler(async (req, res) => {
|
|
21
|
-
const version = await repo.findById(req.params.id);
|
|
22
|
-
if (!version) {
|
|
23
|
-
res.status(404).json({ error: 'Prompt version not found' });
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
res.json(version);
|
|
27
|
-
}));
|
|
28
20
|
r.post('/', asyncHandler(async (req, res) => {
|
|
29
21
|
const body = createSchema.parse(req.body);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const version = await prisma.promptVersion.create({
|
|
23
|
+
data: {
|
|
24
|
+
name: body.name,
|
|
25
|
+
sourcePath: body.sourcePath,
|
|
26
|
+
systemPrompt: body.systemPrompt,
|
|
27
|
+
textToolsPrompt: body.textToolsPrompt,
|
|
28
|
+
hash: body.hash,
|
|
29
|
+
metadata: body.metadata ? JSON.stringify(body.metadata) : null,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
36
32
|
res.status(201).json(version);
|
|
37
33
|
}));
|
|
38
34
|
return r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-versions.js","sourceRoot":"","sources":["../../src/routes/prompt-versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CA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B,CAAC,CAAC,CAAC,CAAC;IAEJ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;YAChD,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;aAC/D;SACF,CAAC,CAAC;QACH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ export { runAgentTask, type AgentResult } from './executor.js';
|
|
|
2
2
|
export { createPlan, type PlanStep, type PlannerResult } from './planner.js';
|
|
3
3
|
export { validateProject, type ValidationSummary } from './validator.js';
|
|
4
4
|
export { publishOmega, type PublishResult } from './publisher.js';
|
|
5
|
-
export
|
|
5
|
+
export { loadCurrentPrompts, saveCurrentPrompts, readPromptsSource, hashPrompts, envForPrompts, type PromptVersionInput, } from './prompt-versioning.js';
|
|
6
6
|
export * from './git.js';
|
|
7
7
|
export * from './tools.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAClE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wBAAwB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -2,7 +2,7 @@ export { runAgentTask } from './executor.js';
|
|
|
2
2
|
export { createPlan } from './planner.js';
|
|
3
3
|
export { validateProject } from './validator.js';
|
|
4
4
|
export { publishOmega } from './publisher.js';
|
|
5
|
-
export
|
|
5
|
+
export { loadCurrentPrompts, saveCurrentPrompts, readPromptsSource, hashPrompts, envForPrompts, } from './prompt-versioning.js';
|
|
6
6
|
export * from './git.js';
|
|
7
7
|
export * from './tools.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAqC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAA0B,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAqC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAA0B,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,aAAa,GAEd,MAAM,wBAAwB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const AGENT_SYSTEM_PROMPT: string;
|
|
2
|
-
export declare const FORCE_ACTION_PROMPT = "You have been thinking without taking action. Stop describing plans and execute the next concrete step using a tool. Use edit_file or run_command.";
|
|
2
|
+
export declare const FORCE_ACTION_PROMPT = "You have been thinking without taking action. Stop describing plans and execute the next concrete step using a tool. Use edit_file, publish, or run_command.";
|
|
3
3
|
export declare const TEXT_TOOLS_SYSTEM_PROMPT: string;
|
|
4
4
|
export declare function buildSystemPrompt(context?: string): string;
|
|
5
5
|
export declare function buildTextToolsSystemPrompt(context?: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,QAyC+D,CAAC;AAEhG,eAAO,MAAM,mBAAmB,iKAAiK,CAAC;AAElM,eAAO,MAAM,wBAAwB,QAmCjC,CAAC;AAEL,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,0BAA0B,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3E;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,GAChD,MAAM,CAOR"}
|
|
@@ -28,26 +28,35 @@ Available tools:
|
|
|
28
28
|
- run_command: Run a single simple command. No pipes (|), &&, ;, redirects, or globs. Prefer pnpm/npm/node. Arguments: { "command": "pnpm lint" }
|
|
29
29
|
- think: Record a reasoning step. Arguments: { "thought": "..." }
|
|
30
30
|
- finish: Mark the task complete. Arguments: { "summary": "what was done", "success": true }. Use summary, not message.
|
|
31
|
-
- publish: Run
|
|
31
|
+
- publish: Run lint/test/build validation in one step. This is the preferred validation tool. Arguments: { "version": "optional" }
|
|
32
32
|
|
|
33
33
|
Rules:
|
|
34
34
|
1. Read the task, then use think to plan.
|
|
35
35
|
2. Use edit_file for small changes; write_file only when creating a file or rewriting most of it.
|
|
36
36
|
3. ALWAYS read a file with read_file before using edit_file on it. Do NOT read a file before write_file when creating a new file.
|
|
37
37
|
4. Before creating JavaScript files, read package.json to check whether "type" is "module" and use ESM (export) or CommonJS (module.exports) accordingly.
|
|
38
|
-
5.
|
|
39
|
-
6.
|
|
40
|
-
7. Do
|
|
41
|
-
8.
|
|
42
|
-
9.
|
|
43
|
-
10. Do not
|
|
38
|
+
5. Immediately after making any edit, call publish to run validation. Do not read more files, do not think, and do not call finish before validating.
|
|
39
|
+
6. If validation fails, fix the issue and call publish again. Repeat until validation passes.
|
|
40
|
+
7. Do NOT call finish until validation passes. If you call finish without validation, the task will fail.
|
|
41
|
+
8. Do not expose secrets or run destructive commands.
|
|
42
|
+
9. Finish only when the task is done. Always include summary and success.
|
|
43
|
+
10. Do not repeat the same tool call with the same arguments. If something fails, change your approach.
|
|
44
|
+
11. Do not ask the user for clarification. Do not say "No task was provided". Use the Task and Description above to proceed.
|
|
45
|
+
12. You have a limited number of steps. If you spend too many steps reading or planning without validating, the task will fail.
|
|
44
46
|
|
|
45
47
|
Example tool call sequence for "Add a greet function":
|
|
46
48
|
1. think: { "thought": "I need to create greet.js and export a greet function." }
|
|
47
|
-
2. write_file: { "path": "greet.js", "content": "export function greet(name) { return 'Hello, ' + name + '!'; }
|
|
49
|
+
2. write_file: { "path": "greet.js", "content": "export function greet(name) { return 'Hello, ' + name + '!'; }\\n" }
|
|
48
50
|
3. publish: { }
|
|
49
|
-
4. finish: { "summary": "Created greet.js with greet(name) function and verified it passes tests.", "success": true }
|
|
50
|
-
|
|
51
|
+
4. finish: { "summary": "Created greet.js with greet(name) function and verified it passes tests.", "success": true }
|
|
52
|
+
|
|
53
|
+
Example tool call sequence for "Fix a lint warning":
|
|
54
|
+
1. think: { "thought": "The linter flags var. I need to read src/index.js and replace var with const or let." }
|
|
55
|
+
2. read_file: { "path": "src/index.js" }
|
|
56
|
+
3. edit_file: { "path": "src/index.js", "old_string": "var greeting = 'Hello';", "new_string": "const greeting = 'Hello';" }
|
|
57
|
+
4. publish: { }
|
|
58
|
+
5. finish: { "summary": "Replaced var with const and verified lint passes.", "success": true }`;
|
|
59
|
+
export const FORCE_ACTION_PROMPT = `You have been thinking without taking action. Stop describing plans and execute the next concrete step using a tool. Use edit_file, publish, or run_command.`;
|
|
51
60
|
export const TEXT_TOOLS_SYSTEM_PROMPT = loadPromptFromEnv('OMEGA_TEXT_TOOLS_PROMPT') ??
|
|
52
61
|
`You are Omega, an autonomous software engineering agent running inside a project repository.
|
|
53
62
|
|
|
@@ -68,8 +77,9 @@ Rules:
|
|
|
68
77
|
- Use edit_file for small changes; write_file only for new files or large rewrites.
|
|
69
78
|
- ALWAYS read a file with read_file before using edit_file on it. Do NOT read a file before write_file when creating a new file.
|
|
70
79
|
- Before creating JavaScript files, read package.json to check whether "type" is "module" and use ESM (export) or CommonJS (module.exports) accordingly.
|
|
71
|
-
-
|
|
72
|
-
-
|
|
80
|
+
- Immediately after making any edit, call publish to run validation. Do not read more files or call finish before validating.
|
|
81
|
+
- If validation fails, fix the issue and call publish again.
|
|
82
|
+
- Do NOT call finish until validation passes.
|
|
73
83
|
- Do not expose secrets or run destructive commands.
|
|
74
84
|
- Finish only when done. Use summary, not message.
|
|
75
85
|
- Do not repeat the same tool call with the same arguments.
|
|
@@ -78,7 +88,7 @@ Rules:
|
|
|
78
88
|
Example response for "Add a greet function":
|
|
79
89
|
{ "tool_calls": [
|
|
80
90
|
{ "id": "1", "name": "think", "arguments": { "thought": "Create greet.js with greet(name)." } },
|
|
81
|
-
{ "id": "2", "name": "write_file", "arguments": { "path": "greet.js", "content": "export function greet(name) { return 'Hello, ' + name + '!'; }
|
|
91
|
+
{ "id": "2", "name": "write_file", "arguments": { "path": "greet.js", "content": "export function greet(name) { return 'Hello, ' + name + '!'; }\\n" } },
|
|
82
92
|
{ "id": "3", "name": "publish", "arguments": {} },
|
|
83
93
|
{ "id": "4", "name": "finish", "arguments": { "summary": "Created greet.js and verified tests pass.", "success": true } }
|
|
84
94
|
] }`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,SAAS,iBAAiB,CAAC,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,IAAI,CAAC,IAAI,CAAC,sBAAsB,OAAO;SAC3D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;SAC5C,IAAI,CAAC,MAAM,CAAC,mCAAmC,CAAC;AACrD,CAAC"}
|
package/dist/server/node_modules/@omega/db/generated/client/libquery_engine-darwin-arm64.dylib.node
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/server/src/app.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { providerRoutes } from './routes/providers.js';
|
|
|
7
7
|
import { routerRoutes } from './routes/router.js';
|
|
8
8
|
import { metricsRoutes } from './routes/metrics.js';
|
|
9
9
|
import { promptVersionRoutes } from './routes/prompt-versions.js';
|
|
10
|
-
import {
|
|
10
|
+
import { benchmarkRoutes } from './routes/benchmarks.js';
|
|
11
11
|
|
|
12
12
|
export const app: express.Express = express();
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ app.use('/providers', providerRoutes(prisma));
|
|
|
20
20
|
app.use('/router', routerRoutes(prisma));
|
|
21
21
|
app.use('/metrics', metricsRoutes(prisma));
|
|
22
22
|
app.use('/prompt-versions', promptVersionRoutes(prisma));
|
|
23
|
-
app.use('/
|
|
23
|
+
app.use('/benchmarks', benchmarkRoutes(prisma));
|
|
24
24
|
|
|
25
25
|
app.use((err: unknown, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
|
|
26
26
|
console.error(err);
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import type { PrismaClient } from '@omega/db';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { asyncHandler } from '../lib/async-handler.js';
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const root = path.resolve(__filename, '..', '..', '..', '..');
|
|
12
|
+
const reportsDir = path.join(root, '.omega', 'reports');
|
|
13
|
+
const statusFile = path.join(root, '.omega', 'bench-run-status.json');
|
|
14
|
+
|
|
15
|
+
const runSchema = z.object({
|
|
16
|
+
suite: z.enum(['synthetic', 'deep-swe']).optional(),
|
|
17
|
+
nTasks: z.number().int().positive().optional(),
|
|
18
|
+
provider: z.string().optional(),
|
|
19
|
+
model: z.string().optional(),
|
|
20
|
+
timeout: z.number().int().positive().optional(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
interface RunStatus {
|
|
24
|
+
running: boolean;
|
|
25
|
+
pid?: number;
|
|
26
|
+
output?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function readStatus(): Promise<RunStatus> {
|
|
30
|
+
try {
|
|
31
|
+
const raw = await fs.readFile(statusFile, 'utf-8');
|
|
32
|
+
return JSON.parse(raw) as RunStatus;
|
|
33
|
+
} catch {
|
|
34
|
+
return { running: false };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function writeStatus(status: RunStatus): Promise<void> {
|
|
39
|
+
await fs.mkdir(path.dirname(statusFile), { recursive: true });
|
|
40
|
+
await fs.writeFile(statusFile, JSON.stringify(status, null, 2), 'utf-8');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isReportFile(name: string, prefix: string): boolean {
|
|
44
|
+
return name.startsWith(prefix) && name.endsWith('.json');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function listReports(prefix: string): Promise<string[]> {
|
|
48
|
+
try {
|
|
49
|
+
const files = await fs.readdir(reportsDir);
|
|
50
|
+
return files
|
|
51
|
+
.filter((f) => isReportFile(f, prefix))
|
|
52
|
+
.sort()
|
|
53
|
+
.reverse();
|
|
54
|
+
} catch {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function benchmarkRoutes(_prisma: PrismaClient): Router {
|
|
60
|
+
const r = Router();
|
|
61
|
+
|
|
62
|
+
r.get('/reports', asyncHandler(async (_req, res) => {
|
|
63
|
+
const [benchmark, ab] = await Promise.all([
|
|
64
|
+
listReports('benchmark-'),
|
|
65
|
+
listReports('ab-'),
|
|
66
|
+
]);
|
|
67
|
+
res.json({ benchmark, ab });
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
r.get('/reports/:file', asyncHandler(async (req, res) => {
|
|
71
|
+
const file = req.params.file;
|
|
72
|
+
if (!isReportFile(file, 'benchmark-') && !isReportFile(file, 'ab-')) {
|
|
73
|
+
res.status(400).json({ error: 'Invalid report file' });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const filePath = path.join(reportsDir, file);
|
|
77
|
+
const resolved = path.resolve(filePath);
|
|
78
|
+
const resolvedReportsDir = path.resolve(reportsDir);
|
|
79
|
+
if (!resolved.startsWith(resolvedReportsDir + path.sep) && resolved !== resolvedReportsDir) {
|
|
80
|
+
res.status(400).json({ error: 'Invalid report path' });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const raw = await fs.readFile(filePath, 'utf-8');
|
|
85
|
+
const data = JSON.parse(raw) as unknown;
|
|
86
|
+
res.json(data);
|
|
87
|
+
} catch {
|
|
88
|
+
res.status(404).json({ error: 'Report not found' });
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
r.post('/run', asyncHandler(async (req, res) => {
|
|
93
|
+
const body = runSchema.parse(req.body);
|
|
94
|
+
const status = await readStatus();
|
|
95
|
+
if (status.running) {
|
|
96
|
+
res.status(409).json({ error: 'Benchmark run already in progress', pid: status.pid });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const args = ['apps/cli/dist/index.js', 'bench', 'run'];
|
|
101
|
+
if (body.suite) {
|
|
102
|
+
args.push('--suite', body.suite);
|
|
103
|
+
}
|
|
104
|
+
if (body.nTasks) {
|
|
105
|
+
args.push('--n-tasks', String(body.nTasks));
|
|
106
|
+
}
|
|
107
|
+
if (body.timeout) {
|
|
108
|
+
args.push('--timeout', String(body.timeout));
|
|
109
|
+
}
|
|
110
|
+
if (body.provider) {
|
|
111
|
+
args.push('--provider', body.provider);
|
|
112
|
+
}
|
|
113
|
+
if (body.model) {
|
|
114
|
+
args.push('--model', body.model);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const child = spawn('node', args, {
|
|
118
|
+
cwd: root,
|
|
119
|
+
detached: true,
|
|
120
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
let output = '';
|
|
124
|
+
child.stdout.on('data', (chunk: Buffer) => {
|
|
125
|
+
output += chunk.toString();
|
|
126
|
+
});
|
|
127
|
+
child.stderr.on('data', (chunk: Buffer) => {
|
|
128
|
+
output += chunk.toString();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
child.on('exit', () => {
|
|
132
|
+
void (async () => {
|
|
133
|
+
const current = await readStatus();
|
|
134
|
+
if (current.pid === child.pid) {
|
|
135
|
+
await writeStatus({ running: false, output });
|
|
136
|
+
}
|
|
137
|
+
})();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
child.unref();
|
|
141
|
+
|
|
142
|
+
await writeStatus({ running: true, pid: child.pid, output: '' });
|
|
143
|
+
res.status(202).json({ pid: child.pid, status: 'started' });
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
r.get('/run-status', asyncHandler(async (_req, res) => {
|
|
147
|
+
const status = await readStatus();
|
|
148
|
+
res.json(status);
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
return r;
|
|
152
|
+
}
|