vibeman 0.0.3 → 0.0.6
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/api.js +49 -0
- package/dist/cli.js +135 -0
- package/dist/ui/index-gnk6rhxs.js +9 -0
- package/dist/ui/index.html +10 -0
- package/dist/ui/index.js +2 -0
- package/package.json +10 -80
- package/README.md +0 -12
- package/dist/index.js +0 -114
- package/dist/runtime/api/.tsbuildinfo +0 -1
- package/dist/runtime/api/agent/agent-service.d.ts +0 -225
- package/dist/runtime/api/agent/agent-service.js +0 -904
- package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +0 -61
- package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +0 -362
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +0 -36
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +0 -347
- package/dist/runtime/api/agent/ai-providers/index.d.ts +0 -9
- package/dist/runtime/api/agent/ai-providers/index.js +0 -7
- package/dist/runtime/api/agent/ai-providers/types.d.ts +0 -182
- package/dist/runtime/api/agent/ai-providers/types.js +0 -5
- package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +0 -1
- package/dist/runtime/api/agent/codex-cli-provider.test.js +0 -170
- package/dist/runtime/api/agent/core-agent-service.d.ts +0 -119
- package/dist/runtime/api/agent/core-agent-service.js +0 -267
- package/dist/runtime/api/agent/parsers.d.ts +0 -16
- package/dist/runtime/api/agent/parsers.js +0 -308
- package/dist/runtime/api/agent/prompt-service.d.ts +0 -30
- package/dist/runtime/api/agent/prompt-service.js +0 -449
- package/dist/runtime/api/agent/prompt-service.test.d.ts +0 -1
- package/dist/runtime/api/agent/prompt-service.test.js +0 -230
- package/dist/runtime/api/agent/routing-policy.d.ts +0 -171
- package/dist/runtime/api/agent/routing-policy.js +0 -196
- package/dist/runtime/api/agent/routing-policy.test.d.ts +0 -1
- package/dist/runtime/api/agent/routing-policy.test.js +0 -63
- package/dist/runtime/api/api/router-helpers.d.ts +0 -32
- package/dist/runtime/api/api/router-helpers.js +0 -31
- package/dist/runtime/api/api/routers/ai.d.ts +0 -200
- package/dist/runtime/api/api/routers/ai.js +0 -396
- package/dist/runtime/api/api/routers/executions.d.ts +0 -98
- package/dist/runtime/api/api/routers/executions.js +0 -94
- package/dist/runtime/api/api/routers/git.d.ts +0 -45
- package/dist/runtime/api/api/routers/git.js +0 -35
- package/dist/runtime/api/api/routers/provider-config.d.ts +0 -165
- package/dist/runtime/api/api/routers/provider-config.js +0 -252
- package/dist/runtime/api/api/routers/settings.d.ts +0 -139
- package/dist/runtime/api/api/routers/settings.js +0 -113
- package/dist/runtime/api/api/routers/tasks.d.ts +0 -141
- package/dist/runtime/api/api/routers/tasks.js +0 -238
- package/dist/runtime/api/api/routers/workflows.d.ts +0 -275
- package/dist/runtime/api/api/routers/workflows.js +0 -311
- package/dist/runtime/api/api/routers/worktrees.d.ts +0 -101
- package/dist/runtime/api/api/routers/worktrees.js +0 -80
- package/dist/runtime/api/api/trpc.d.ts +0 -118
- package/dist/runtime/api/api/trpc.js +0 -34
- package/dist/runtime/api/index.d.ts +0 -9
- package/dist/runtime/api/index.js +0 -117
- package/dist/runtime/api/lib/id-generator.d.ts +0 -70
- package/dist/runtime/api/lib/id-generator.js +0 -123
- package/dist/runtime/api/lib/local-config.d.ts +0 -245
- package/dist/runtime/api/lib/local-config.js +0 -288
- package/dist/runtime/api/lib/logger.d.ts +0 -11
- package/dist/runtime/api/lib/logger.js +0 -188
- package/dist/runtime/api/lib/provider-detection.d.ts +0 -59
- package/dist/runtime/api/lib/provider-detection.js +0 -244
- package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +0 -6
- package/dist/runtime/api/lib/server/agent-service-singleton.js +0 -27
- package/dist/runtime/api/lib/server/bootstrap.d.ts +0 -38
- package/dist/runtime/api/lib/server/bootstrap.js +0 -197
- package/dist/runtime/api/lib/server/git-service-singleton.d.ts +0 -6
- package/dist/runtime/api/lib/server/git-service-singleton.js +0 -47
- package/dist/runtime/api/lib/server/project-root.d.ts +0 -2
- package/dist/runtime/api/lib/server/project-root.js +0 -61
- package/dist/runtime/api/lib/server/task-service-singleton.d.ts +0 -7
- package/dist/runtime/api/lib/server/task-service-singleton.js +0 -58
- package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +0 -7
- package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +0 -57
- package/dist/runtime/api/lib/trpc/client.d.ts +0 -1
- package/dist/runtime/api/lib/trpc/client.js +0 -5
- package/dist/runtime/api/lib/trpc/server.d.ts +0 -935
- package/dist/runtime/api/lib/trpc/server.js +0 -11
- package/dist/runtime/api/lib/trpc/ws-server.d.ts +0 -8
- package/dist/runtime/api/lib/trpc/ws-server.js +0 -33
- package/dist/runtime/api/persistence/database-service.d.ts +0 -14
- package/dist/runtime/api/persistence/database-service.js +0 -74
- package/dist/runtime/api/persistence/execution-log-persistence.d.ts +0 -90
- package/dist/runtime/api/persistence/execution-log-persistence.js +0 -410
- package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +0 -1
- package/dist/runtime/api/persistence/execution-log-persistence.test.js +0 -170
- package/dist/runtime/api/router.d.ts +0 -938
- package/dist/runtime/api/router.js +0 -34
- package/dist/runtime/api/settings-service.d.ts +0 -110
- package/dist/runtime/api/settings-service.js +0 -661
- package/dist/runtime/api/tasks/file-watcher.d.ts +0 -23
- package/dist/runtime/api/tasks/file-watcher.js +0 -88
- package/dist/runtime/api/tasks/task-file-parser.d.ts +0 -13
- package/dist/runtime/api/tasks/task-file-parser.js +0 -161
- package/dist/runtime/api/tasks/task-service.d.ts +0 -36
- package/dist/runtime/api/tasks/task-service.js +0 -173
- package/dist/runtime/api/types/index.d.ts +0 -186
- package/dist/runtime/api/types/index.js +0 -1
- package/dist/runtime/api/types/settings.d.ts +0 -94
- package/dist/runtime/api/types/settings.js +0 -2
- package/dist/runtime/api/types.d.ts +0 -2
- package/dist/runtime/api/types.js +0 -1
- package/dist/runtime/api/utils/env.d.ts +0 -6
- package/dist/runtime/api/utils/env.js +0 -12
- package/dist/runtime/api/utils/stripNextEnv.d.ts +0 -7
- package/dist/runtime/api/utils/stripNextEnv.js +0 -22
- package/dist/runtime/api/utils/title-slug.d.ts +0 -6
- package/dist/runtime/api/utils/title-slug.js +0 -77
- package/dist/runtime/api/utils/url.d.ts +0 -2
- package/dist/runtime/api/utils/url.js +0 -19
- package/dist/runtime/api/vcs/git-history-service.d.ts +0 -57
- package/dist/runtime/api/vcs/git-history-service.js +0 -228
- package/dist/runtime/api/vcs/git-service.d.ts +0 -127
- package/dist/runtime/api/vcs/git-service.js +0 -284
- package/dist/runtime/api/vcs/worktree-service.d.ts +0 -93
- package/dist/runtime/api/vcs/worktree-service.js +0 -506
- package/dist/runtime/api/vcs/worktree-service.test.d.ts +0 -1
- package/dist/runtime/api/vcs/worktree-service.test.js +0 -20
- package/dist/runtime/api/workflows/quality-pipeline.d.ts +0 -58
- package/dist/runtime/api/workflows/quality-pipeline.js +0 -400
- package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +0 -318
- package/dist/runtime/api/workflows/vibing-orchestrator.js +0 -1891
- package/dist/runtime/web/.next/BUILD_ID +0 -1
- package/dist/runtime/web/.next/app-build-manifest.json +0 -66
- package/dist/runtime/web/.next/app-path-routes-manifest.json +0 -8
- package/dist/runtime/web/.next/build-manifest.json +0 -33
- package/dist/runtime/web/.next/package.json +0 -1
- package/dist/runtime/web/.next/prerender-manifest.json +0 -61
- package/dist/runtime/web/.next/react-loadable-manifest.json +0 -39
- package/dist/runtime/web/.next/required-server-files.json +0 -334
- package/dist/runtime/web/.next/routes-manifest.json +0 -70
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +0 -1
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/_not-found/page.js +0 -2
- package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/_not-found.html +0 -7
- package/dist/runtime/web/.next/server/app/_not-found.meta +0 -8
- package/dist/runtime/web/.next/server/app/_not-found.rsc +0 -22
- package/dist/runtime/web/.next/server/app/api/health/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/index.html +0 -7
- package/dist/runtime/web/.next/server/app/index.meta +0 -7
- package/dist/runtime/web/.next/server/app/index.rsc +0 -27
- package/dist/runtime/web/.next/server/app/page.js +0 -147
- package/dist/runtime/web/.next/server/app/page.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app-paths-manifest.json +0 -8
- package/dist/runtime/web/.next/server/chunks/217.js +0 -1
- package/dist/runtime/web/.next/server/chunks/383.js +0 -6
- package/dist/runtime/web/.next/server/chunks/458.js +0 -1
- package/dist/runtime/web/.next/server/chunks/576.js +0 -18
- package/dist/runtime/web/.next/server/chunks/635.js +0 -22
- package/dist/runtime/web/.next/server/chunks/761.js +0 -1
- package/dist/runtime/web/.next/server/chunks/777.js +0 -3
- package/dist/runtime/web/.next/server/chunks/825.js +0 -1
- package/dist/runtime/web/.next/server/chunks/838.js +0 -1
- package/dist/runtime/web/.next/server/chunks/973.js +0 -15
- package/dist/runtime/web/.next/server/functions-config-manifest.json +0 -4
- package/dist/runtime/web/.next/server/middleware-build-manifest.js +0 -1
- package/dist/runtime/web/.next/server/middleware-manifest.json +0 -6
- package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/dist/runtime/web/.next/server/next-font-manifest.js +0 -1
- package/dist/runtime/web/.next/server/next-font-manifest.json +0 -1
- package/dist/runtime/web/.next/server/pages/404.html +0 -7
- package/dist/runtime/web/.next/server/pages/500.html +0 -1
- package/dist/runtime/web/.next/server/pages/_app.js +0 -1
- package/dist/runtime/web/.next/server/pages/_app.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages/_document.js +0 -1
- package/dist/runtime/web/.next/server/pages/_document.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages/_error.js +0 -19
- package/dist/runtime/web/.next/server/pages/_error.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages-manifest.json +0 -6
- package/dist/runtime/web/.next/server/server-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/server-reference-manifest.json +0 -1
- package/dist/runtime/web/.next/server/webpack-runtime.js +0 -1
- package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_buildManifest.js +0 -1
- package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_ssgManifest.js +0 -1
- package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +0 -1
- package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +0 -3
- package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +0 -71
- package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +0 -15
- package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +0 -1
- package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +0 -1
- package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +0 -1
- package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +0 -1
- package/dist/runtime/web/.next/static/chunks/823-6f371a6e829adbba.js +0 -63
- package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +0 -1
- package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +0 -1
- package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/health/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/upload/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/layout-8435322f09fd0975.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/page-9fe7d75095b4ccec.js +0 -1
- package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +0 -1
- package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +0 -1
- package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +0 -1
- package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +0 -3
- package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +0 -1
- package/dist/runtime/web/.next/static/css/537e22821e101b87.css +0 -1
- package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
- package/dist/runtime/web/package.json +0 -65
- package/dist/runtime/web/server.js +0 -44
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
// Toggle real CLI integration via env
|
|
3
|
-
const USE_REAL = process.env.VITEST_USE_REAL_CODEX === 'true';
|
|
4
|
-
// Note: we dynamically import the provider after (un)mocking per test block
|
|
5
|
-
describe('CodexCliProvider (mocked)', () => {
|
|
6
|
-
afterEach(() => {
|
|
7
|
-
vi.resetAllMocks();
|
|
8
|
-
});
|
|
9
|
-
it('streams stdout, passes images flag, and returns result', async () => {
|
|
10
|
-
vi.resetModules();
|
|
11
|
-
vi.doMock('child_process', () => {
|
|
12
|
-
let captured = [];
|
|
13
|
-
return {
|
|
14
|
-
__captured: () => captured,
|
|
15
|
-
spawn: (cmd, args, opts) => {
|
|
16
|
-
captured = [cmd, args, opts];
|
|
17
|
-
const { EventEmitter } = require('events');
|
|
18
|
-
const stdout = new EventEmitter();
|
|
19
|
-
const stderr = new EventEmitter();
|
|
20
|
-
const proc = new EventEmitter();
|
|
21
|
-
proc.stdout = stdout;
|
|
22
|
-
proc.stderr = stderr;
|
|
23
|
-
setTimeout(() => stdout.emit('data', Buffer.from('Hello from Codex\n')), 10);
|
|
24
|
-
setTimeout(() => proc.emit('exit', 0, null), 20);
|
|
25
|
-
return proc;
|
|
26
|
-
},
|
|
27
|
-
exec: vi.fn(),
|
|
28
|
-
execFile: vi.fn(),
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
const { CodexCliProvider } = await import('./ai-providers/codex-cli-provider.js');
|
|
32
|
-
const provider = new CodexCliProvider({ defaultTimeoutMs: 1000, codexBinPath: 'codex' });
|
|
33
|
-
const messages = [];
|
|
34
|
-
const iter = provider.execute('What is this project about?', {
|
|
35
|
-
workingDirectory: process.cwd(),
|
|
36
|
-
images: ['a.png', 'b.jpg'],
|
|
37
|
-
effort: 'minimal',
|
|
38
|
-
model: 'gpt-5',
|
|
39
|
-
});
|
|
40
|
-
for await (const m of iter)
|
|
41
|
-
messages.push(m);
|
|
42
|
-
const resultMsg = messages.find((m) => m.type === 'result');
|
|
43
|
-
expect(!!resultMsg).toBe(true);
|
|
44
|
-
const assistantMsg = messages.find((m) => m.type === 'assistant');
|
|
45
|
-
if (assistantMsg && typeof assistantMsg.content === 'string') {
|
|
46
|
-
expect(assistantMsg.content.length).toBeGreaterThan(0);
|
|
47
|
-
}
|
|
48
|
-
else if (resultMsg && typeof resultMsg.result === 'string') {
|
|
49
|
-
expect(resultMsg.result.length).toBeGreaterThan(0);
|
|
50
|
-
}
|
|
51
|
-
const mockSpawn = await import('child_process');
|
|
52
|
-
const captured = mockSpawn.__captured();
|
|
53
|
-
expect(Array.isArray(captured[1])).toBe(true);
|
|
54
|
-
expect(captured[1]).toContain('--image');
|
|
55
|
-
expect(captured[1]).toContain('a.png,b.jpg');
|
|
56
|
-
const modelIdx = captured[1].indexOf('--model');
|
|
57
|
-
expect(modelIdx).toBeGreaterThan(-1);
|
|
58
|
-
expect(captured[1][modelIdx + 1]).toBe('gpt-5');
|
|
59
|
-
const configIdx = captured[1].indexOf('-c');
|
|
60
|
-
expect(configIdx).toBeGreaterThan(-1);
|
|
61
|
-
expect(captured[1][configIdx + 1]).toBe('model_reasoning_effort=low');
|
|
62
|
-
});
|
|
63
|
-
it('maps reasoning level encoded in model name to CLI flags', async () => {
|
|
64
|
-
vi.resetModules();
|
|
65
|
-
vi.doMock('child_process', () => {
|
|
66
|
-
let captured = [];
|
|
67
|
-
return {
|
|
68
|
-
__captured: () => captured,
|
|
69
|
-
spawn: (cmd, args, opts) => {
|
|
70
|
-
captured = [cmd, args, opts];
|
|
71
|
-
const { EventEmitter } = require('events');
|
|
72
|
-
const stdout = new EventEmitter();
|
|
73
|
-
const proc = new EventEmitter();
|
|
74
|
-
proc.stdout = stdout;
|
|
75
|
-
setTimeout(() => stdout.emit('data', Buffer.from('Reasoned\n')), 10);
|
|
76
|
-
setTimeout(() => proc.emit('exit', 0, null), 20);
|
|
77
|
-
return proc;
|
|
78
|
-
},
|
|
79
|
-
exec: vi.fn(),
|
|
80
|
-
execFile: vi.fn(),
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
const { CodexCliProvider } = await import('./ai-providers/codex-cli-provider.js');
|
|
84
|
-
const provider = new CodexCliProvider({ codexBinPath: 'codex' });
|
|
85
|
-
const messages = [];
|
|
86
|
-
const iter = provider.execute('Solve with depth', {
|
|
87
|
-
workingDirectory: process.cwd(),
|
|
88
|
-
model: 'gpt-5-codex-high',
|
|
89
|
-
});
|
|
90
|
-
for await (const m of iter)
|
|
91
|
-
messages.push(m);
|
|
92
|
-
const mockSpawn = await import('child_process');
|
|
93
|
-
const captured = mockSpawn.__captured();
|
|
94
|
-
const modelIdx = captured[1].indexOf('--model');
|
|
95
|
-
expect(modelIdx).toBeGreaterThan(-1);
|
|
96
|
-
expect(captured[1][modelIdx + 1]).toBe('gpt-5-codex');
|
|
97
|
-
const configIdx = captured[1].indexOf('-c');
|
|
98
|
-
expect(configIdx).toBeGreaterThan(-1);
|
|
99
|
-
expect(captured[1][configIdx + 1]).toBe('model_reasoning_effort=high');
|
|
100
|
-
});
|
|
101
|
-
it('prepends system prompts and toggles sandbox bypass flag', async () => {
|
|
102
|
-
vi.resetModules();
|
|
103
|
-
vi.doMock('child_process', () => {
|
|
104
|
-
let captured = [];
|
|
105
|
-
return {
|
|
106
|
-
__captured: () => captured,
|
|
107
|
-
spawn: (cmd, args, opts) => {
|
|
108
|
-
captured = [cmd, args, opts];
|
|
109
|
-
const { EventEmitter } = require('events');
|
|
110
|
-
const stdout = new EventEmitter();
|
|
111
|
-
const proc = new EventEmitter();
|
|
112
|
-
proc.stdout = stdout;
|
|
113
|
-
setTimeout(() => stdout.emit('data', Buffer.from('Done\n')), 5);
|
|
114
|
-
setTimeout(() => proc.emit('exit', 0, null), 10);
|
|
115
|
-
return proc;
|
|
116
|
-
},
|
|
117
|
-
exec: vi.fn(),
|
|
118
|
-
execFile: vi.fn(),
|
|
119
|
-
};
|
|
120
|
-
});
|
|
121
|
-
const { CodexCliProvider } = await import('./ai-providers/codex-cli-provider.js');
|
|
122
|
-
const provider = new CodexCliProvider({ codexBinPath: 'codex' });
|
|
123
|
-
const iter = provider.execute('Implement feature', {
|
|
124
|
-
workingDirectory: '/tmp/project',
|
|
125
|
-
systemPrompt: 'Base system prompt',
|
|
126
|
-
appendSystemPrompt: 'Additional guidance',
|
|
127
|
-
dangerouslyBypassApprovalsAndSandbox: true,
|
|
128
|
-
});
|
|
129
|
-
for await (const _ of iter) {
|
|
130
|
-
// drain iterator
|
|
131
|
-
}
|
|
132
|
-
const mockSpawn = await import('child_process');
|
|
133
|
-
const captured = mockSpawn.__captured();
|
|
134
|
-
expect(captured[1][1]).toContain('Base system prompt');
|
|
135
|
-
expect(captured[1][1]).toContain('Additional guidance');
|
|
136
|
-
const bypassIdx = captured[1].indexOf('--dangerously-bypass-approvals-and-sandbox');
|
|
137
|
-
expect(bypassIdx).toBeGreaterThan(-1);
|
|
138
|
-
expect(captured[1][bypassIdx + 1]).toBeUndefined();
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
// Real integration (opt-in)
|
|
142
|
-
(USE_REAL ? describe : describe.skip)('CodexCliProvider (real CLI)', () => {
|
|
143
|
-
it('answers a simple model question and prints output', { timeout: 120000 }, async () => {
|
|
144
|
-
vi.resetModules();
|
|
145
|
-
vi.doUnmock('child_process');
|
|
146
|
-
const { CodexCliProvider } = await import('./ai-providers/codex-cli-provider.js');
|
|
147
|
-
const provider = new CodexCliProvider({
|
|
148
|
-
defaultWorkingDirectory: process.cwd(),
|
|
149
|
-
defaultTimeoutMs: 120000,
|
|
150
|
-
});
|
|
151
|
-
const prompt = 'Just answer 1 + 1 = ? for testing.';
|
|
152
|
-
let assistant = '';
|
|
153
|
-
let sawResult = false;
|
|
154
|
-
for await (const m of provider.execute(prompt, {
|
|
155
|
-
workingDirectory: process.cwd(),
|
|
156
|
-
timeout: 120000,
|
|
157
|
-
})) {
|
|
158
|
-
console.log('[CODEX]', m.type, typeof m.content === 'string' ? m.content : '');
|
|
159
|
-
if (m.type === 'assistant' && typeof m.content === 'string') {
|
|
160
|
-
if (!assistant)
|
|
161
|
-
assistant = m.content.trim();
|
|
162
|
-
}
|
|
163
|
-
if (m.type === 'result') {
|
|
164
|
-
sawResult = true;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
expect(sawResult).toBe(true);
|
|
168
|
-
expect(assistant.length).toBeGreaterThan(0);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Agent Service - Pure AI Execution Engine
|
|
3
|
-
* Provider-agnostic AI execution service
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from 'events';
|
|
6
|
-
import { AIProvider, ExecutionOptions, ExecutionMessage, ModelInfo, ProviderStatus } from './ai-providers/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* Execution state tracking
|
|
9
|
-
*/
|
|
10
|
-
export interface ExecutionState {
|
|
11
|
-
id: string;
|
|
12
|
-
provider: string;
|
|
13
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
14
|
-
startTime: string;
|
|
15
|
-
endTime?: string;
|
|
16
|
-
error?: string;
|
|
17
|
-
messages: ExecutionMessage[];
|
|
18
|
-
result?: string;
|
|
19
|
-
usage?: {
|
|
20
|
-
promptTokens: number;
|
|
21
|
-
completionTokens: number;
|
|
22
|
-
totalTokens: number;
|
|
23
|
-
cost?: number;
|
|
24
|
-
};
|
|
25
|
-
abortController?: AbortController;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Execution request
|
|
29
|
-
*/
|
|
30
|
-
export interface ExecutionRequest {
|
|
31
|
-
prompt: string;
|
|
32
|
-
options?: ExecutionOptions;
|
|
33
|
-
provider?: string;
|
|
34
|
-
metadata?: Record<string, any>;
|
|
35
|
-
executionId?: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Execution update event
|
|
39
|
-
*/
|
|
40
|
-
export interface ExecutionUpdate {
|
|
41
|
-
executionId: string;
|
|
42
|
-
status: ExecutionState['status'];
|
|
43
|
-
message?: ExecutionMessage;
|
|
44
|
-
error?: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Agent Service Configuration
|
|
48
|
-
*/
|
|
49
|
-
export interface AgentServiceConfig {
|
|
50
|
-
defaultProvider?: string;
|
|
51
|
-
executionTimeout?: number;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Pure AI Execution Service
|
|
55
|
-
* Manages AI providers and executions without business logic
|
|
56
|
-
*/
|
|
57
|
-
export declare class CoreAgentService extends EventEmitter {
|
|
58
|
-
private providers;
|
|
59
|
-
private defaultProvider;
|
|
60
|
-
private executions;
|
|
61
|
-
private config;
|
|
62
|
-
constructor(config?: AgentServiceConfig);
|
|
63
|
-
/**
|
|
64
|
-
* Register an AI provider
|
|
65
|
-
*/
|
|
66
|
-
registerProvider(name: string, provider: AIProvider): void;
|
|
67
|
-
/**
|
|
68
|
-
* Set default provider
|
|
69
|
-
*/
|
|
70
|
-
setDefaultProvider(name: string): void;
|
|
71
|
-
/**
|
|
72
|
-
* Get default provider name
|
|
73
|
-
*/
|
|
74
|
-
getDefaultProvider(): string | null;
|
|
75
|
-
/**
|
|
76
|
-
* Get provider by name
|
|
77
|
-
*/
|
|
78
|
-
getProvider(name: string): AIProvider | null;
|
|
79
|
-
/**
|
|
80
|
-
* Get all registered providers
|
|
81
|
-
*/
|
|
82
|
-
getProviders(): Map<string, AIProvider>;
|
|
83
|
-
/**
|
|
84
|
-
* Execute a prompt with streaming
|
|
85
|
-
*/
|
|
86
|
-
execute(request: ExecutionRequest): Promise<string>;
|
|
87
|
-
/**
|
|
88
|
-
* Get execution status
|
|
89
|
-
*/
|
|
90
|
-
getExecutionStatus(executionId: string): ExecutionState | null;
|
|
91
|
-
/**
|
|
92
|
-
* Get execution messages
|
|
93
|
-
*/
|
|
94
|
-
getExecutionMessages(executionId: string): ExecutionMessage[];
|
|
95
|
-
/**
|
|
96
|
-
* Stop an execution
|
|
97
|
-
*/
|
|
98
|
-
stopExecution(executionId: string): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* Get all executions
|
|
101
|
-
*/
|
|
102
|
-
getAllExecutions(): ExecutionState[];
|
|
103
|
-
/**
|
|
104
|
-
* Clear completed executions
|
|
105
|
-
*/
|
|
106
|
-
clearCompletedExecutions(): number;
|
|
107
|
-
/**
|
|
108
|
-
* Validate all providers
|
|
109
|
-
*/
|
|
110
|
-
validateProviders(): Promise<Map<string, ProviderStatus>>;
|
|
111
|
-
/**
|
|
112
|
-
* Get available models from all providers
|
|
113
|
-
*/
|
|
114
|
-
getAvailableModels(): Promise<ModelInfo[]>;
|
|
115
|
-
/**
|
|
116
|
-
* Generate execution ID
|
|
117
|
-
*/
|
|
118
|
-
private generateExecutionId;
|
|
119
|
-
}
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Agent Service - Pure AI Execution Engine
|
|
3
|
-
* Provider-agnostic AI execution service
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from 'events';
|
|
6
|
-
import { log } from '../lib/logger.js';
|
|
7
|
-
import { generateId } from '../lib/id-generator.js';
|
|
8
|
-
/**
|
|
9
|
-
* Pure AI Execution Service
|
|
10
|
-
* Manages AI providers and executions without business logic
|
|
11
|
-
*/
|
|
12
|
-
export class CoreAgentService extends EventEmitter {
|
|
13
|
-
constructor(config = {}) {
|
|
14
|
-
super();
|
|
15
|
-
this.providers = new Map();
|
|
16
|
-
this.defaultProvider = null;
|
|
17
|
-
this.executions = new Map();
|
|
18
|
-
this.config = {
|
|
19
|
-
executionTimeout: config.executionTimeout || 30 * 60 * 1000, // 30 minutes
|
|
20
|
-
...config,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Register an AI provider
|
|
25
|
-
*/
|
|
26
|
-
registerProvider(name, provider) {
|
|
27
|
-
this.providers.set(name, provider);
|
|
28
|
-
log.debug(`Registered AI provider: ${name}`, undefined, 'core-agent-service');
|
|
29
|
-
// Set as default if it's the first provider or matches config
|
|
30
|
-
if (!this.defaultProvider || name === this.config.defaultProvider) {
|
|
31
|
-
this.defaultProvider = name;
|
|
32
|
-
log.debug(`Set default provider: ${name}`, undefined, 'core-agent-service');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Set default provider
|
|
37
|
-
*/
|
|
38
|
-
setDefaultProvider(name) {
|
|
39
|
-
if (!this.providers.has(name)) {
|
|
40
|
-
throw new Error(`Provider ${name} not registered`);
|
|
41
|
-
}
|
|
42
|
-
this.defaultProvider = name;
|
|
43
|
-
log.debug(`Changed default provider to: ${name}`, undefined, 'core-agent-service');
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get default provider name
|
|
47
|
-
*/
|
|
48
|
-
getDefaultProvider() {
|
|
49
|
-
return this.defaultProvider;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get provider by name
|
|
53
|
-
*/
|
|
54
|
-
getProvider(name) {
|
|
55
|
-
return this.providers.get(name) || null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get all registered providers
|
|
59
|
-
*/
|
|
60
|
-
getProviders() {
|
|
61
|
-
return new Map(this.providers);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Execute a prompt with streaming
|
|
65
|
-
*/
|
|
66
|
-
async execute(request) {
|
|
67
|
-
// Determine which provider to use
|
|
68
|
-
const providerName = request.provider || this.defaultProvider;
|
|
69
|
-
if (!providerName) {
|
|
70
|
-
throw new Error('No provider specified and no default provider set');
|
|
71
|
-
}
|
|
72
|
-
const provider = this.providers.get(providerName);
|
|
73
|
-
if (!provider) {
|
|
74
|
-
throw new Error(`Provider ${providerName} not found`);
|
|
75
|
-
}
|
|
76
|
-
const executionId = request.executionId || this.generateExecutionId();
|
|
77
|
-
const abortController = new AbortController();
|
|
78
|
-
// Set timeout
|
|
79
|
-
const timeoutId = setTimeout(() => {
|
|
80
|
-
abortController.abort();
|
|
81
|
-
}, this.config.executionTimeout);
|
|
82
|
-
const execution = {
|
|
83
|
-
id: executionId,
|
|
84
|
-
provider: provider.name,
|
|
85
|
-
status: 'pending',
|
|
86
|
-
startTime: new Date().toISOString(),
|
|
87
|
-
messages: [],
|
|
88
|
-
abortController,
|
|
89
|
-
};
|
|
90
|
-
this.executions.set(executionId, execution);
|
|
91
|
-
// Emit execution created event
|
|
92
|
-
this.emit('executionCreated', { executionId, provider: execution.provider });
|
|
93
|
-
try {
|
|
94
|
-
execution.status = 'running';
|
|
95
|
-
this.emit('executionStarted', { executionId });
|
|
96
|
-
const options = {
|
|
97
|
-
...request.options,
|
|
98
|
-
abortSignal: abortController.signal,
|
|
99
|
-
};
|
|
100
|
-
let result = '';
|
|
101
|
-
const messages = [];
|
|
102
|
-
// Execute with streaming
|
|
103
|
-
for await (const message of provider.execute(request.prompt, options)) {
|
|
104
|
-
execution.messages.push(message);
|
|
105
|
-
// Emit message events
|
|
106
|
-
this.emit('executionMessage', {
|
|
107
|
-
executionId,
|
|
108
|
-
message,
|
|
109
|
-
});
|
|
110
|
-
// Collect assistant messages
|
|
111
|
-
if (message.type === 'assistant') {
|
|
112
|
-
const content = message.content;
|
|
113
|
-
messages.push(content);
|
|
114
|
-
// Emit update for UI streaming
|
|
115
|
-
this.emit('executionUpdate', {
|
|
116
|
-
executionId,
|
|
117
|
-
status: execution.status,
|
|
118
|
-
message,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// Handle result
|
|
122
|
-
if (message.type === 'result') {
|
|
123
|
-
const resultMsg = message;
|
|
124
|
-
if (resultMsg.success) {
|
|
125
|
-
result = resultMsg.result || messages.join('\n');
|
|
126
|
-
execution.result = result;
|
|
127
|
-
execution.usage = resultMsg.usage;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
throw new Error(resultMsg.error || 'Execution failed');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// Mark as completed
|
|
135
|
-
execution.status = 'completed';
|
|
136
|
-
execution.endTime = new Date().toISOString();
|
|
137
|
-
clearTimeout(timeoutId);
|
|
138
|
-
// Emit completion event
|
|
139
|
-
this.emit('executionCompleted', {
|
|
140
|
-
executionId,
|
|
141
|
-
result,
|
|
142
|
-
usage: execution.usage,
|
|
143
|
-
});
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
clearTimeout(timeoutId);
|
|
148
|
-
// Handle cancellation
|
|
149
|
-
if (abortController.signal.aborted) {
|
|
150
|
-
execution.status = 'cancelled';
|
|
151
|
-
execution.error = 'Execution cancelled';
|
|
152
|
-
this.emit('executionCancelled', { executionId });
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
execution.status = 'failed';
|
|
156
|
-
execution.error = error instanceof Error ? error.message : String(error);
|
|
157
|
-
this.emit('executionFailed', {
|
|
158
|
-
executionId,
|
|
159
|
-
error: execution.error,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
execution.endTime = new Date().toISOString();
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Get execution status
|
|
168
|
-
*/
|
|
169
|
-
getExecutionStatus(executionId) {
|
|
170
|
-
const execution = this.executions.get(executionId);
|
|
171
|
-
if (!execution)
|
|
172
|
-
return null;
|
|
173
|
-
// Return copy without internal fields
|
|
174
|
-
const { abortController, ...publicState } = execution;
|
|
175
|
-
return publicState;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get execution messages
|
|
179
|
-
*/
|
|
180
|
-
getExecutionMessages(executionId) {
|
|
181
|
-
const execution = this.executions.get(executionId);
|
|
182
|
-
return execution ? [...execution.messages] : [];
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Stop an execution
|
|
186
|
-
*/
|
|
187
|
-
async stopExecution(executionId) {
|
|
188
|
-
const execution = this.executions.get(executionId);
|
|
189
|
-
if (!execution) {
|
|
190
|
-
throw new Error(`Execution ${executionId} not found`);
|
|
191
|
-
}
|
|
192
|
-
if (execution.status !== 'running') {
|
|
193
|
-
throw new Error(`Execution ${executionId} is not running`);
|
|
194
|
-
}
|
|
195
|
-
if (execution.abortController) {
|
|
196
|
-
execution.abortController.abort();
|
|
197
|
-
execution.status = 'cancelled';
|
|
198
|
-
execution.endTime = new Date().toISOString();
|
|
199
|
-
this.emit('executionCancelled', { executionId });
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Get all executions
|
|
204
|
-
*/
|
|
205
|
-
getAllExecutions() {
|
|
206
|
-
return Array.from(this.executions.values()).map((e) => {
|
|
207
|
-
const { abortController, ...publicState } = e;
|
|
208
|
-
return publicState;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Clear completed executions
|
|
213
|
-
*/
|
|
214
|
-
clearCompletedExecutions() {
|
|
215
|
-
let cleared = 0;
|
|
216
|
-
for (const [id, execution] of this.executions) {
|
|
217
|
-
if (['completed', 'failed', 'cancelled'].includes(execution.status)) {
|
|
218
|
-
this.executions.delete(id);
|
|
219
|
-
cleared++;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return cleared;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Validate all providers
|
|
226
|
-
*/
|
|
227
|
-
async validateProviders() {
|
|
228
|
-
const results = new Map();
|
|
229
|
-
for (const [name, provider] of this.providers) {
|
|
230
|
-
try {
|
|
231
|
-
const status = await provider.validateSetup();
|
|
232
|
-
results.set(name, status);
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
results.set(name, {
|
|
236
|
-
available: false,
|
|
237
|
-
error: error instanceof Error ? error.message : String(error),
|
|
238
|
-
models: [],
|
|
239
|
-
capabilities: provider.getCapabilities(),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return results;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get available models from all providers
|
|
247
|
-
*/
|
|
248
|
-
async getAvailableModels() {
|
|
249
|
-
const models = [];
|
|
250
|
-
for (const [name, provider] of this.providers) {
|
|
251
|
-
try {
|
|
252
|
-
const providerModels = await provider.detectAvailableModels();
|
|
253
|
-
models.push(...providerModels);
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
log.warn(`Failed to get models from provider ${name}`, error, 'core-agent-service');
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return models;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Generate execution ID
|
|
263
|
-
*/
|
|
264
|
-
generateExecutionId() {
|
|
265
|
-
return generateId('exec');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare function parseImprovementResult(result: string, originalData: {
|
|
2
|
-
title: string;
|
|
3
|
-
type: string;
|
|
4
|
-
priority: string;
|
|
5
|
-
content: string;
|
|
6
|
-
}): {
|
|
7
|
-
type: string;
|
|
8
|
-
priority: string;
|
|
9
|
-
content: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function parseReviewResult(result: string): {
|
|
13
|
-
reviewSummary: string;
|
|
14
|
-
recommendations: string[];
|
|
15
|
-
qualityScore: number;
|
|
16
|
-
};
|