@pixelbyte-software/pixcode 1.55.0 → 1.55.1

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.
Files changed (171) hide show
  1. package/dist/api-automation.html +110 -0
  2. package/dist/api-docs.html +548 -0
  3. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  4. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  5. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  6. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  7. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  8. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  9. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  10. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  11. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  12. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  13. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  14. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  15. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  16. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  17. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  18. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  19. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  20. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  21. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  22. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  23. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  24. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  25. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  26. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  27. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  28. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  29. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  30. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  31. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  32. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  33. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  34. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  35. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  36. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  37. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  38. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  39. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  40. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  41. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  42. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  43. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  44. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  45. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  46. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  47. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  48. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  49. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  50. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  51. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  52. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  53. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  54. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  55. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  56. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  57. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  58. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  59. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  60. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  61. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  62. package/dist/assets/index-B-ySsQqi.js +877 -0
  63. package/dist/assets/index-CWO38aJI.css +32 -0
  64. package/dist/assets/index-ak1p_4ew.js +11 -0
  65. package/dist/assets/localMonaco-DFIbtDNp.js +1 -0
  66. package/dist/assets/vendor-codemirror-CIYNS698.js +41 -0
  67. package/dist/assets/vendor-react-DB6V5Fl1.js +59 -0
  68. package/dist/assets/vendor-xterm-C7tpxJl7.js +9 -0
  69. package/dist/clear-cache.html +85 -0
  70. package/dist/convert-icons.md +53 -0
  71. package/dist/docs.html +308 -0
  72. package/dist/favicon.png +0 -0
  73. package/dist/favicon.svg +8 -0
  74. package/dist/features.html +133 -0
  75. package/dist/generate-icons.js +49 -0
  76. package/dist/humans.txt +15 -0
  77. package/dist/icons/claude-ai-icon.svg +1 -0
  78. package/dist/icons/codex-white.svg +3 -0
  79. package/dist/icons/codex.svg +3 -0
  80. package/dist/icons/cursor-white.svg +12 -0
  81. package/dist/icons/cursor.svg +1 -0
  82. package/dist/icons/gemini-ai-icon.svg +1 -0
  83. package/dist/icons/icon-128x128.png +0 -0
  84. package/dist/icons/icon-128x128.svg +9 -0
  85. package/dist/icons/icon-144x144.png +0 -0
  86. package/dist/icons/icon-144x144.svg +9 -0
  87. package/dist/icons/icon-152x152.png +0 -0
  88. package/dist/icons/icon-152x152.svg +9 -0
  89. package/dist/icons/icon-192x192.png +0 -0
  90. package/dist/icons/icon-192x192.svg +9 -0
  91. package/dist/icons/icon-384x384.png +0 -0
  92. package/dist/icons/icon-384x384.svg +9 -0
  93. package/dist/icons/icon-512x512.png +0 -0
  94. package/dist/icons/icon-512x512.svg +9 -0
  95. package/dist/icons/icon-72x72.png +0 -0
  96. package/dist/icons/icon-72x72.svg +9 -0
  97. package/dist/icons/icon-96x96.png +0 -0
  98. package/dist/icons/icon-96x96.svg +9 -0
  99. package/dist/icons/icon-template.svg +9 -0
  100. package/dist/icons/opencode-logo-dark.svg +1 -0
  101. package/dist/icons/opencode-logo-light.svg +1 -0
  102. package/dist/icons/qwen-ai-icon.png +0 -0
  103. package/dist/icons/qwen-logo.svg +15 -0
  104. package/dist/index.html +62 -0
  105. package/dist/landing.html +268 -0
  106. package/dist/llms-full.txt +119 -0
  107. package/dist/llms.txt +53 -0
  108. package/dist/logo-128.png +0 -0
  109. package/dist/logo-256.png +0 -0
  110. package/dist/logo-32.png +0 -0
  111. package/dist/logo-512.png +0 -0
  112. package/dist/logo-64.png +0 -0
  113. package/dist/logo.png +0 -0
  114. package/dist/logo.svg +12 -0
  115. package/dist/manifest.json +61 -0
  116. package/dist/openapi.yaml +1696 -0
  117. package/dist/orchestration.html +125 -0
  118. package/dist/robots.txt +4 -0
  119. package/dist/screenshots/cli-selection.png +0 -0
  120. package/dist/screenshots/desktop-main.png +0 -0
  121. package/dist/screenshots/mobile-chat.png +0 -0
  122. package/dist/screenshots/tools-modal.png +0 -0
  123. package/dist/site.css +692 -0
  124. package/dist/sitemap.xml +51 -0
  125. package/dist/sw.js +132 -0
  126. package/package.json +1 -1
  127. package/dist-server/server/modules/tasks/git-worktree.js +0 -98
  128. package/dist-server/server/modules/tasks/git-worktree.js.map +0 -1
  129. package/dist-server/server/modules/tasks/index.js +0 -8
  130. package/dist-server/server/modules/tasks/index.js.map +0 -1
  131. package/dist-server/server/modules/tasks/prompt-builder.js +0 -85
  132. package/dist-server/server/modules/tasks/prompt-builder.js.map +0 -1
  133. package/dist-server/server/modules/tasks/role-presets.js +0 -94
  134. package/dist-server/server/modules/tasks/role-presets.js.map +0 -1
  135. package/dist-server/server/modules/tasks/runners/claude-runner.js +0 -109
  136. package/dist-server/server/modules/tasks/runners/claude-runner.js.map +0 -1
  137. package/dist-server/server/modules/tasks/runners/codex-runner.js +0 -67
  138. package/dist-server/server/modules/tasks/runners/codex-runner.js.map +0 -1
  139. package/dist-server/server/modules/tasks/runners/spawn-runner.js +0 -111
  140. package/dist-server/server/modules/tasks/runners/spawn-runner.js.map +0 -1
  141. package/dist-server/server/modules/tasks/runners/types.js +0 -5
  142. package/dist-server/server/modules/tasks/runners/types.js.map +0 -1
  143. package/dist-server/server/modules/tasks/scheduler.js +0 -69
  144. package/dist-server/server/modules/tasks/scheduler.js.map +0 -1
  145. package/dist-server/server/modules/tasks/task-queue.js +0 -81
  146. package/dist-server/server/modules/tasks/task-queue.js.map +0 -1
  147. package/dist-server/server/modules/tasks/task-routes.js +0 -195
  148. package/dist-server/server/modules/tasks/task-routes.js.map +0 -1
  149. package/dist-server/server/modules/tasks/task-runner.js +0 -187
  150. package/dist-server/server/modules/tasks/task-runner.js.map +0 -1
  151. package/dist-server/server/modules/tasks/task-store.js +0 -196
  152. package/dist-server/server/modules/tasks/task-store.js.map +0 -1
  153. package/dist-server/server/modules/tasks/task-types.js +0 -5
  154. package/dist-server/server/modules/tasks/task-types.js.map +0 -1
  155. package/dist-server/server/modules/tasks/user-interaction.js +0 -73
  156. package/dist-server/server/modules/tasks/user-interaction.js.map +0 -1
  157. package/server/modules/tasks/git-worktree.ts +0 -102
  158. package/server/modules/tasks/index.ts +0 -9
  159. package/server/modules/tasks/prompt-builder.ts +0 -98
  160. package/server/modules/tasks/role-presets.ts +0 -113
  161. package/server/modules/tasks/runners/claude-runner.ts +0 -120
  162. package/server/modules/tasks/runners/codex-runner.ts +0 -80
  163. package/server/modules/tasks/runners/spawn-runner.ts +0 -122
  164. package/server/modules/tasks/runners/types.ts +0 -25
  165. package/server/modules/tasks/scheduler.ts +0 -75
  166. package/server/modules/tasks/task-queue.ts +0 -91
  167. package/server/modules/tasks/task-routes.ts +0 -245
  168. package/server/modules/tasks/task-runner.ts +0 -219
  169. package/server/modules/tasks/task-store.ts +0 -223
  170. package/server/modules/tasks/task-types.ts +0 -100
  171. package/server/modules/tasks/user-interaction.ts +0 -93
@@ -1,98 +0,0 @@
1
- // ============================================================
2
- // Prompt Builder — Constructs prompts for agents
3
- // ============================================================
4
-
5
- import type { Task } from './task-types.js';
6
- import { getRolePromptAppend } from './role-presets.js';
7
-
8
- export function buildPrompt(task: Task, projectPath: string): string {
9
- const roleAppend = getRolePromptAppend(task.role);
10
- const parts: string[] = [];
11
-
12
- parts.push(`## Task: ${task.title}`);
13
- parts.push('');
14
- parts.push(task.prompt);
15
- parts.push('');
16
-
17
- if (roleAppend) {
18
- parts.push('---');
19
- parts.push('');
20
- parts.push(roleAppend);
21
- parts.push('');
22
- }
23
-
24
- parts.push('---');
25
- parts.push('');
26
- parts.push(`## Context`);
27
- parts.push(`- Working directory: ${projectPath}`);
28
- parts.push(`- Agent: ${task.agentType}`);
29
- if (task.model) {
30
- parts.push(`- Model: ${task.model}`);
31
- }
32
- if (task.maxBudgetUsd) {
33
- parts.push(`- Budget limit: $${task.maxBudgetUsd}`);
34
- }
35
- parts.push('');
36
- parts.push('## Instructions');
37
- parts.push('1. Analyze the codebase before making changes');
38
- parts.push('2. Make focused, minimal changes');
39
- parts.push('3. Run existing tests if available');
40
- parts.push('4. Provide a summary of what you changed and why');
41
- if (task.permissionMode !== 'plan') {
42
- parts.push('5. Commit your changes with a descriptive message');
43
- }
44
- parts.push('');
45
-
46
- return parts.join('\n');
47
- }
48
-
49
- export function buildContinuePrompt(task: Task): string {
50
- const roleAppend = getRolePromptAppend(task.role);
51
- const parts: string[] = [];
52
-
53
- parts.push(`## Continuing Task: ${task.title}`);
54
- parts.push('');
55
- parts.push('You are continuing from a previous session. Review the work done so far and proceed.');
56
- parts.push('');
57
- parts.push('### Original request:');
58
- parts.push(task.prompt);
59
- parts.push('');
60
-
61
- if (roleAppend) {
62
- parts.push('---');
63
- parts.push('');
64
- parts.push(roleAppend);
65
- parts.push('');
66
- }
67
-
68
- parts.push('## Instructions');
69
- parts.push('1. Check git log and recent changes to see what was already done');
70
- parts.push('2. Continue from where the previous session left off');
71
- parts.push('3. Do NOT redo work that is already complete');
72
- parts.push('4. Run tests to verify existing work');
73
- parts.push('5. Complete the remaining work and commit');
74
- parts.push('');
75
-
76
- return parts.join('\n');
77
- }
78
-
79
- export function buildBranchName(task: Task): string {
80
- const slug = task.title
81
- .toLowerCase()
82
- .replace(/[^a-z0-9]+/g, '-')
83
- .replace(/^-+|-+$/g, '')
84
- .slice(0, 40);
85
- return `task/${task.id.slice(0, 8)}-${slug}`;
86
- }
87
-
88
- export function buildSummaryPrompt(task: Task): string {
89
- return `Summarize the work completed for this task in 3-5 bullet points:
90
- - Task: ${task.title}
91
- - Agent: ${task.agentType}
92
- - What was the original request: ${task.prompt.slice(0, 200)}
93
- - What files were changed (check git diff)
94
- - Were tests run? Did they pass?
95
- - Any issues or follow-up needed?
96
-
97
- Provide only the summary, no preamble.`;
98
- }
@@ -1,113 +0,0 @@
1
- // ============================================================
2
- // Role Presets — Default system prompts per role type
3
- // Inspired by VibeHQ's team model
4
- // ============================================================
5
-
6
- import type { TaskRole, AgentType } from './task-types.js';
7
-
8
- export interface RolePreset {
9
- role: TaskRole;
10
- label: string;
11
- description: string;
12
- defaultAgent: AgentType;
13
- systemPromptAppend: string;
14
- }
15
-
16
- export const ROLE_PRESETS: Record<TaskRole, RolePreset> = {
17
- backend: {
18
- role: 'backend',
19
- label: 'Backend Engineer',
20
- description: 'API routes, database, server logic, authentication',
21
- defaultAgent: 'claude-code',
22
- systemPromptAppend: `You are a backend engineer. Focus on:
23
- - API design and implementation (REST/GraphQL)
24
- - Database schema, migrations, queries
25
- - Server-side logic, middleware, authentication
26
- - Error handling, validation, security
27
- - Performance optimization (caching, indexing)
28
- Write clean, well-tested backend code. Add inline comments for complex logic.`,
29
- },
30
-
31
- frontend: {
32
- role: 'frontend',
33
- label: 'Frontend Engineer',
34
- description: 'UI components, styles, user experience, client logic',
35
- defaultAgent: 'codex',
36
- systemPromptAppend: `You are a frontend engineer. Focus on:
37
- - React/Vue/Svelte components and pages
38
- - CSS/Tailwind/styled-components styling
39
- - Client-side state management
40
- - Form handling, validation, UX flows
41
- - Accessibility (ARIA, semantic HTML)
42
- - Responsive design
43
- Write clean, accessible, well-styled frontend code. Test in the browser when possible.`,
44
- },
45
-
46
- fullstack: {
47
- role: 'fullstack',
48
- label: 'Full-Stack Engineer',
49
- description: 'End-to-end features across frontend and backend',
50
- defaultAgent: 'claude-code',
51
- systemPromptAppend: `You are a full-stack engineer. Handle both frontend and backend.
52
- - Design and implement end-to-end features
53
- - Keep API contracts consistent between frontend and backend
54
- - Write tests for both layers
55
- - Consider deployment and infrastructure implications`,
56
- },
57
-
58
- reviewer: {
59
- role: 'reviewer',
60
- label: 'Code Reviewer',
61
- description: 'Review changes for bugs, security, performance, style',
62
- defaultAgent: 'gemini',
63
- systemPromptAppend: `You are a code reviewer. Analyze the changes for:
64
- - Logic errors and edge cases
65
- - Security vulnerabilities (OWASP top 10)
66
- - Performance issues
67
- - Code style and maintainability
68
- - Missing tests or documentation
69
- Provide a prioritized list of findings. Be specific about file:line.`,
70
- },
71
-
72
- tester: {
73
- role: 'tester',
74
- label: 'Test Engineer',
75
- description: 'Write and run tests, ensure coverage',
76
- defaultAgent: 'codex',
77
- systemPromptAppend: `You are a test engineer. Focus on:
78
- - Unit tests for individual functions/modules
79
- - Integration tests for API endpoints
80
- - Edge cases and error scenarios
81
- - Test coverage gaps
82
- Use the project's existing test framework. Run tests after writing them.`,
83
- },
84
-
85
- custom: {
86
- role: 'custom',
87
- label: 'Custom',
88
- description: 'No role-specific prompt — use the raw prompt',
89
- defaultAgent: 'claude-code',
90
- systemPromptAppend: '',
91
- },
92
- };
93
-
94
- export function getRolePreset(role: TaskRole): RolePreset {
95
- return ROLE_PRESETS[role] || ROLE_PRESETS.custom;
96
- }
97
-
98
- export function getRolePromptAppend(role: TaskRole): string {
99
- return getRolePreset(role).systemPromptAppend;
100
- }
101
-
102
- export function getDefaultAgentForRole(role: TaskRole): AgentType {
103
- return getRolePreset(role).defaultAgent;
104
- }
105
-
106
- export function listRoles(): { value: TaskRole; label: string; description: string; defaultAgent: AgentType }[] {
107
- return Object.values(ROLE_PRESETS).map((p) => ({
108
- value: p.role,
109
- label: p.label,
110
- description: p.description,
111
- defaultAgent: p.defaultAgent,
112
- }));
113
- }
@@ -1,120 +0,0 @@
1
- // ============================================================
2
- // Claude Runner — Uses @anthropic-ai/claude-agent-sdk
3
- // ============================================================
4
-
5
- import { query } from '@anthropic-ai/claude-agent-sdk';
6
-
7
- import { buildPrompt, buildContinuePrompt } from '../prompt-builder.js';
8
- import type { AgentRunner, RunContext, RunResult } from './types.js';
9
-
10
- export const claudeRunner: AgentRunner = {
11
- async run(ctx: RunContext): Promise<RunResult> {
12
- const { task, projectPath, abortController } = ctx;
13
- const workdir = task.worktreePath || projectPath;
14
-
15
- // Build prompt — continue or fresh
16
- const prompt = task.continueSession && task.predecessorTaskId
17
- ? buildContinuePrompt(task)
18
- : buildPrompt(task, workdir);
19
-
20
- // Build clean env
21
- const cleanEnv: Record<string, string | undefined> = { ...process.env };
22
- delete cleanEnv.CLAUDECODE;
23
-
24
- // Permission mode
25
- const permissionMode = task.permissionMode || 'auto_edit';
26
-
27
- await ctx.logTask('info', `Starting Claude Code agent. Model: ${task.model || 'default'}, Permission: ${permissionMode}`);
28
-
29
- let resultText = '';
30
- let costUsd = 0;
31
- let tokenInput = 0;
32
- let tokenOutput = 0;
33
- let sessionId: string | undefined;
34
-
35
- try {
36
- const response = query({
37
- prompt,
38
- options: {
39
- cwd: workdir,
40
- model: task.model,
41
- permissionMode: permissionMode as any,
42
- maxTurns: 150,
43
- env: cleanEnv,
44
- abortController,
45
- ...(task.continueSession && task.sessionId
46
- ? { resume: task.sessionId }
47
- : {}),
48
- },
49
- });
50
-
51
- for await (const message of response) {
52
- if (abortController.signal.aborted) break;
53
-
54
- switch (message.type) {
55
- case 'assistant': {
56
- if (message.message?.content) {
57
- for (const block of message.message.content) {
58
- if (block.type === 'text') {
59
- resultText += block.text + '\n';
60
- await ctx.logTask('info', `[Claude] ${block.text.slice(0, 200)}`);
61
- }
62
- }
63
- }
64
- // Extract token usage
65
- if (message.message?.usage) {
66
- tokenInput += message.message.usage.input_tokens || 0;
67
- tokenOutput += message.message.usage.output_tokens || 0;
68
- costUsd += ((message.message.usage.input_tokens || 0) * 0.000003) +
69
- ((message.message.usage.output_tokens || 0) * 0.000015);
70
- }
71
- break;
72
- }
73
-
74
- case 'result': {
75
- // SDKResultMessage is a union — check subtype before accessing fields
76
- if (message.subtype === 'success') {
77
- const success = message as any;
78
- if (success.result) resultText = success.result;
79
- if (success.session_id) sessionId = success.session_id;
80
- if (success.total_cost_usd) costUsd = success.total_cost_usd;
81
- if (success.usage) {
82
- tokenInput = success.usage.input_tokens || tokenInput;
83
- tokenOutput = success.usage.output_tokens || tokenOutput;
84
- }
85
- }
86
- break;
87
- }
88
-
89
- case 'system': {
90
- if (message.subtype === 'init' && message.session_id) {
91
- sessionId = message.session_id;
92
- await ctx.logTask('info', `Claude session: ${sessionId}`);
93
- }
94
- break;
95
- }
96
- }
97
- }
98
-
99
- // Check budget
100
- if (task.maxBudgetUsd && costUsd > task.maxBudgetUsd) {
101
- await ctx.logTask('warn', `Budget exceeded: $${costUsd.toFixed(4)} > $${task.maxBudgetUsd}`);
102
- }
103
-
104
- await ctx.logTask('info', `Claude completed. Tokens: ${tokenInput} in / ${tokenOutput} out. Cost: $${costUsd.toFixed(4)}`);
105
-
106
- return {
107
- result: resultText.slice(0, 10000),
108
- costUsd,
109
- tokenCount: { input: tokenInput, output: tokenOutput },
110
- sessionId,
111
- };
112
- } catch (err: any) {
113
- if (err?.name === 'AbortError' || abortController.signal.aborted) {
114
- await ctx.logTask('info', 'Claude task was cancelled');
115
- return { result: 'Task cancelled by user', sessionId };
116
- }
117
- throw err;
118
- }
119
- },
120
- };
@@ -1,80 +0,0 @@
1
- // ============================================================
2
- // Codex Runner — Uses @openai/codex-sdk
3
- // ============================================================
4
-
5
- import { Codex } from '@openai/codex-sdk';
6
-
7
- import { buildPrompt, buildContinuePrompt } from '../prompt-builder.js';
8
- import type { AgentRunner, RunContext, RunResult } from './types.js';
9
-
10
- export const codexRunner: AgentRunner = {
11
- async run(ctx: RunContext): Promise<RunResult> {
12
- const { task, projectPath, abortController } = ctx;
13
- const workdir = task.worktreePath || projectPath;
14
-
15
- const prompt = task.continueSession && task.predecessorTaskId
16
- ? buildContinuePrompt(task)
17
- : buildPrompt(task, workdir);
18
-
19
- // Clean env
20
- const cleanEnv: Record<string, string> = {};
21
- for (const [k, v] of Object.entries(process.env)) {
22
- if (v !== undefined && k !== 'CLAUDECODE') {
23
- cleanEnv[k] = v;
24
- }
25
- }
26
-
27
- await ctx.logTask('info', `Starting Codex agent. Model: ${task.model || 'o4-mini'}, Thinking: ${task.thinkingEnabled}`);
28
-
29
- const codex = new Codex({
30
- env: cleanEnv,
31
- config: {
32
- model: task.model || 'o4-mini',
33
- approval_policy: 'never',
34
- ...(task.thinkingEnabled ? { reasoning_effort: 'high' as const } : {}),
35
- },
36
- });
37
-
38
- let resultText = '';
39
- let costUsd = 0;
40
- let tokenInput = 0;
41
- let tokenOutput = 0;
42
- let sessionId: string | undefined;
43
-
44
- try {
45
- // Use startThread() — the correct Codex SDK API
46
- const thread = codex.startThread();
47
-
48
- // Use run() for non-streaming — returns a Turn with finalResponse and usage
49
- const turn = await thread.run(prompt, {
50
- signal: abortController.signal,
51
- });
52
-
53
- // Extract results from the completed turn
54
- resultText = turn.finalResponse || '';
55
- sessionId = thread.id || undefined;
56
-
57
- if (turn.usage) {
58
- tokenInput = turn.usage.input_tokens || 0;
59
- tokenOutput = turn.usage.output_tokens || 0;
60
- costUsd = (tokenInput * 0.0000025) + (tokenOutput * 0.00001);
61
- }
62
-
63
- await ctx.logTask('info', `[Codex] ${resultText.slice(0, 200)}`);
64
- await ctx.logTask('info', `Codex completed. Tokens: ${tokenInput} in / ${tokenOutput} out. Cost: $${costUsd.toFixed(4)}`);
65
-
66
- return {
67
- result: resultText.slice(0, 10000),
68
- costUsd,
69
- tokenCount: { input: tokenInput, output: tokenOutput },
70
- sessionId,
71
- };
72
- } catch (err: any) {
73
- if (err?.name === 'AbortError' || abortController.signal.aborted) {
74
- await ctx.logTask('info', 'Codex task was cancelled');
75
- return { result: 'Task cancelled by user', sessionId };
76
- }
77
- throw err;
78
- }
79
- },
80
- };
@@ -1,122 +0,0 @@
1
- // ============================================================
2
- // Spawn Runner — Generic CLI spawn runner for Gemini, Qwen, OpenCode
3
- // Uses child_process spawn with real-time output streaming
4
- // ============================================================
5
-
6
- import { spawn } from 'node:child_process';
7
-
8
- import { buildPrompt, buildContinuePrompt } from '../prompt-builder.js';
9
- import type { AgentRunner, RunContext, RunResult } from './types.js';
10
-
11
- // CLI command mapping
12
- const CLI_COMMANDS: Record<string, { bin: string; args: string[]; promptFlag: string }> = {
13
- gemini: {
14
- bin: 'gemini',
15
- args: ['--yolo'],
16
- promptFlag: '-p',
17
- },
18
- qwen: {
19
- bin: 'qwen',
20
- args: [],
21
- promptFlag: '-p',
22
- },
23
- opencode: {
24
- bin: 'opencode',
25
- args: ['run'],
26
- promptFlag: '',
27
- },
28
- };
29
-
30
- function getCliCommand(agentType: string, model?: string): { bin: string; args: string[]; promptFlag: string } {
31
- const config = CLI_COMMANDS[agentType];
32
- if (!config) throw new Error(`Unknown CLI agent: ${agentType}`);
33
- const args = [...config.args];
34
- if (model && agentType === 'gemini') args.push('--model', model);
35
- if (model && agentType === 'qwen') args.push('--model', model);
36
- return { ...config, args };
37
- }
38
-
39
- export function createSpawnRunner(agentType: string): AgentRunner {
40
- return {
41
- async run(ctx: RunContext): Promise<RunResult> {
42
- const { task, projectPath, abortController } = ctx;
43
- const workdir = task.worktreePath || projectPath;
44
-
45
- const prompt = task.continueSession && task.predecessorTaskId
46
- ? buildContinuePrompt(task)
47
- : buildPrompt(task, workdir);
48
-
49
- const { bin, args, promptFlag } = getCliCommand(agentType, task.model);
50
-
51
- const fullArgs = promptFlag
52
- ? [...args, promptFlag, prompt]
53
- : [...args, prompt];
54
-
55
- await ctx.logTask('info', `Starting ${agentType} agent. Bin: ${bin}, Model: ${task.model || 'default'}`);
56
-
57
- return new Promise<RunResult>((resolve, reject) => {
58
- const child = spawn(bin, fullArgs, {
59
- cwd: workdir,
60
- env: { ...process.env },
61
- stdio: ['pipe', 'pipe', 'pipe'],
62
- shell: false,
63
- });
64
-
65
- let stdout = '';
66
- let stderr = '';
67
-
68
- child.stdout?.on('data', (data: Buffer) => {
69
- const text = data.toString('utf-8');
70
- stdout += text;
71
- // Log chunks
72
- const lines = text.split('\n').filter(Boolean);
73
- for (const line of lines) {
74
- ctx.logTask('info', `[${agentType}] ${line.slice(0, 200)}`);
75
- }
76
- });
77
-
78
- child.stderr?.on('data', (data: Buffer) => {
79
- const text = data.toString('utf-8');
80
- stderr += text;
81
- const lines = text.split('\n').filter(Boolean);
82
- for (const line of lines) {
83
- ctx.logTask('warn', `[${agentType}] ${line.slice(0, 200)}`);
84
- }
85
- });
86
-
87
- // Handle abort
88
- const abortHandler = () => {
89
- try {
90
- child.kill('SIGTERM');
91
- setTimeout(() => {
92
- if (!child.killed) child.kill('SIGKILL');
93
- }, 5000);
94
- } catch {}
95
- };
96
- abortController.signal.addEventListener('abort', abortHandler, { once: true });
97
-
98
- child.on('close', (code: number) => {
99
- abortController.signal.removeEventListener('abort', abortHandler);
100
-
101
- if (code === 0 || abortController.signal.aborted) {
102
- ctx.logTask('info', `${agentType} completed. Exit code: ${code}`);
103
- resolve({
104
- result: stdout.slice(0, 10000),
105
- costUsd: 0, // CLI doesn't report cost directly
106
- tokenCount: { input: 0, output: 0 },
107
- });
108
- } else {
109
- ctx.logTask('error', `${agentType} failed. Exit code: ${code}. stderr: ${stderr.slice(0, 500)}`);
110
- reject(new Error(`${agentType} exited with code ${code}: ${stderr.slice(0, 500)}`));
111
- }
112
- });
113
-
114
- child.on('error', (err: Error) => {
115
- abortController.signal.removeEventListener('abort', abortHandler);
116
- ctx.logTask('error', `${agentType} spawn error: ${err.message}`);
117
- reject(err);
118
- });
119
- });
120
- },
121
- };
122
- }
@@ -1,25 +0,0 @@
1
- // ============================================================
2
- // Runner Types — Interface for agent runners
3
- // ============================================================
4
-
5
- import type { Task } from '../task-types.js';
6
-
7
- export interface RunContext {
8
- task: Task;
9
- projectPath: string;
10
- abortController: AbortController;
11
- logTask: (level: 'info' | 'warn' | 'error' | 'debug', message: string) => void;
12
- broadcastStatus: (status: string) => void;
13
- askUser: (question: string, options?: string[]) => Promise<string>;
14
- }
15
-
16
- export interface RunResult {
17
- result?: string;
18
- costUsd?: number;
19
- tokenCount?: { input: number; output: number };
20
- sessionId?: string;
21
- }
22
-
23
- export interface AgentRunner {
24
- run(ctx: RunContext): Promise<RunResult>;
25
- }
@@ -1,75 +0,0 @@
1
- // ============================================================
2
- // Scheduler — Polls the queue every 2 seconds and runs ready tasks
3
- // ============================================================
4
-
5
- import { taskEvents } from './task-runner.js';
6
- import { getTasksToRun, onTaskTerminated, enqueue } from './task-queue.js';
7
- import { getTask, updateTask } from './task-store.js';
8
- import { runTask } from './task-runner.js';
9
- import { resolveProjectPath } from './task-runner.js';
10
-
11
- export class TaskScheduler {
12
- private intervalId: NodeJS.Timeout | null = null;
13
- private running = false;
14
-
15
- start(): void {
16
- if (this.intervalId) return;
17
-
18
- // Poll every 2 seconds
19
- this.intervalId = setInterval(() => this.processQueue(), 2000);
20
-
21
- // Listen for events to trigger immediate processing
22
- taskEvents.on('task:completed', (taskId: string) => this.onTaskTerminated(taskId));
23
- taskEvents.on('task:failed', (taskId: string) => this.onTaskTerminated(taskId));
24
- taskEvents.on('task:cancelled', (taskId: string) => this.onTaskTerminated(taskId));
25
-
26
- // Listen for enqueue events
27
- taskEvents.on('task:enqueued', () => this.processQueue());
28
-
29
- console.log('[scheduler] Task scheduler started (poll interval: 2s)');
30
- }
31
-
32
- stop(): void {
33
- if (this.intervalId) {
34
- clearInterval(this.intervalId);
35
- this.intervalId = null;
36
- }
37
- taskEvents.removeAllListeners('task:completed');
38
- taskEvents.removeAllListeners('task:failed');
39
- taskEvents.removeAllListeners('task:cancelled');
40
- taskEvents.removeAllListeners('task:enqueued');
41
- console.log('[scheduler] Task scheduler stopped');
42
- }
43
-
44
- private async processQueue(): Promise<void> {
45
- if (this.running) return; // prevent re-entrant
46
- this.running = true;
47
- try {
48
- const tasksToRun = getTasksToRun();
49
- for (const task of tasksToRun) {
50
- // Fire and forget — don't await runTask
51
- const projectPath = await resolveProjectPath(task.projectId);
52
- runTask(task, projectPath).catch((err) => {
53
- console.error(`[scheduler] Task ${task.id} failed:`, err);
54
- });
55
- }
56
- } catch (err) {
57
- console.error('[scheduler] Error processing queue:', err);
58
- } finally {
59
- this.running = false;
60
- }
61
- }
62
-
63
- private async onTaskTerminated(taskId: string): Promise<void> {
64
- try {
65
- await onTaskTerminated(taskId);
66
- // Immediately check if dependent tasks can run
67
- this.processQueue();
68
- } catch (err) {
69
- console.error('[scheduler] Error handling task termination:', err);
70
- }
71
- }
72
- }
73
-
74
- // Singleton
75
- export const taskScheduler = new TaskScheduler();