maclat 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.js +60 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/index.js +15 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/daemon/executor.d.ts +9 -11
- package/dist/daemon/executor.js +1 -212
- package/dist/daemon/executor.js.map +1 -1
- package/dist/daemon/executors/claude-code.d.ts +9 -0
- package/dist/daemon/executors/claude-code.js +165 -0
- package/dist/daemon/executors/claude-code.js.map +1 -0
- package/dist/daemon/executors/claude-sdk.d.ts +10 -0
- package/dist/daemon/executors/claude-sdk.js +147 -0
- package/dist/daemon/executors/claude-sdk.js.map +1 -0
- package/dist/daemon/executors/codex.d.ts +8 -0
- package/dist/daemon/executors/codex.js +82 -0
- package/dist/daemon/executors/codex.js.map +1 -0
- package/dist/daemon/executors/file-collector.d.ts +4 -0
- package/dist/daemon/executors/file-collector.js +32 -0
- package/dist/daemon/executors/file-collector.js.map +1 -0
- package/dist/daemon/executors/index.d.ts +3 -0
- package/dist/daemon/executors/index.js +33 -0
- package/dist/daemon/executors/index.js.map +1 -0
- package/dist/daemon/executors/prompt.d.ts +2 -0
- package/dist/daemon/executors/prompt.js +20 -0
- package/dist/daemon/executors/prompt.js.map +1 -0
- package/dist/daemon/format.d.ts +16 -0
- package/dist/daemon/format.js +45 -0
- package/dist/daemon/format.js.map +1 -0
- package/dist/daemon/index.js +15 -9
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/poller.d.ts +4 -0
- package/dist/daemon/poller.js +93 -20
- package/dist/daemon/poller.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/shared/types.d.ts +5 -0
- package/package.json +2 -1
package/dist/cli/commands.d.ts
CHANGED
package/dist/cli/commands.js
CHANGED
|
@@ -56,6 +56,66 @@ export async function myinfo() {
|
|
|
56
56
|
console.log(` Balance: ${result.balance_usdc} USDC`);
|
|
57
57
|
console.log(` ──────────────────────────\n`);
|
|
58
58
|
}
|
|
59
|
+
// --- Use (set executor) ---
|
|
60
|
+
const VALID_EXECUTORS = ['claude-code', 'anthropic', 'openrouter', 'codex'];
|
|
61
|
+
export function useExecutor(args) {
|
|
62
|
+
const executor = args[0];
|
|
63
|
+
if (!executor || !VALID_EXECUTORS.includes(executor)) {
|
|
64
|
+
console.log(`\n Usage: maclat use <provider> [api-key] [--model <model>]`);
|
|
65
|
+
console.log(`\n Providers:`);
|
|
66
|
+
console.log(` claude-code Claude Code subscription (no API key needed)`);
|
|
67
|
+
console.log(` anthropic Anthropic API (requires API key)`);
|
|
68
|
+
console.log(` openrouter OpenRouter (requires API key, 400+ models)`);
|
|
69
|
+
console.log(` codex OpenAI Codex CLI (no API key needed)`);
|
|
70
|
+
console.log(`\n Examples:`);
|
|
71
|
+
console.log(` maclat use claude-code`);
|
|
72
|
+
console.log(` maclat use anthropic sk-ant-xxx`);
|
|
73
|
+
console.log(` maclat use openrouter sk-or-xxx --model openai/gpt-4o`);
|
|
74
|
+
console.log(` maclat use codex\n`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const config = loadConfig();
|
|
78
|
+
config.executor = executor;
|
|
79
|
+
// API key is the second positional arg (not a flag)
|
|
80
|
+
const apiKey = args[1] && !args[1].startsWith('--') ? args[1] : undefined;
|
|
81
|
+
if (apiKey) {
|
|
82
|
+
config.api_key = apiKey;
|
|
83
|
+
}
|
|
84
|
+
const model = getFlag(args, '--model');
|
|
85
|
+
if (model) {
|
|
86
|
+
config.model = model;
|
|
87
|
+
}
|
|
88
|
+
const maxTurns = getFlag(args, '--max-turns');
|
|
89
|
+
if (maxTurns) {
|
|
90
|
+
config.max_turns = parseInt(maxTurns, 10);
|
|
91
|
+
}
|
|
92
|
+
// Validate API key requirement
|
|
93
|
+
if ((executor === 'anthropic' || executor === 'openrouter') && !config.api_key) {
|
|
94
|
+
console.log(`\n Warning: ${executor} requires an API key.`);
|
|
95
|
+
console.log(` Run: maclat use ${executor} <your-api-key>\n`);
|
|
96
|
+
}
|
|
97
|
+
saveConfig(config);
|
|
98
|
+
console.log(`\n Executor set: ${executor}`);
|
|
99
|
+
if (config.api_key)
|
|
100
|
+
console.log(` API Key: ***${config.api_key.slice(-4)}`);
|
|
101
|
+
if (config.model)
|
|
102
|
+
console.log(` Model: ${config.model}`);
|
|
103
|
+
console.log('');
|
|
104
|
+
}
|
|
105
|
+
// --- Config (show) ---
|
|
106
|
+
export function showConfig() {
|
|
107
|
+
const config = loadConfig();
|
|
108
|
+
console.log(`\n Maclat Config`);
|
|
109
|
+
console.log(` ──────────────────────────`);
|
|
110
|
+
console.log(` Agent ID: ${config.agent_id || 'not registered'}`);
|
|
111
|
+
console.log(` Agent Name: ${config.agent_name || '-'}`);
|
|
112
|
+
console.log(` Gateway: ${config.gateway_url}`);
|
|
113
|
+
console.log(` Executor: ${config.executor || 'claude-code (default)'}`);
|
|
114
|
+
console.log(` API Key: ${config.api_key ? '***' + config.api_key.slice(-4) : 'not set'}`);
|
|
115
|
+
console.log(` Model: ${config.model || 'default'}`);
|
|
116
|
+
console.log(` Max Turns: ${config.max_turns || '50 (default)'}`);
|
|
117
|
+
console.log(` ──────────────────────────\n`);
|
|
118
|
+
}
|
|
59
119
|
// --- Helpers ---
|
|
60
120
|
function getFlag(args, flag) {
|
|
61
121
|
const idx = args.indexOf(flag);
|
package/dist/cli/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW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C,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { register, myinfo } from './commands.js';
|
|
1
|
+
import { register, myinfo, useExecutor, showConfig } from './commands.js';
|
|
2
2
|
export async function runCli(args) {
|
|
3
3
|
const command = args[0];
|
|
4
4
|
const rest = args.slice(1);
|
|
@@ -9,6 +9,12 @@ export async function runCli(args) {
|
|
|
9
9
|
case 'myinfo':
|
|
10
10
|
await myinfo();
|
|
11
11
|
break;
|
|
12
|
+
case 'use':
|
|
13
|
+
useExecutor(rest);
|
|
14
|
+
break;
|
|
15
|
+
case 'config':
|
|
16
|
+
showConfig();
|
|
17
|
+
break;
|
|
12
18
|
default:
|
|
13
19
|
printHelp();
|
|
14
20
|
}
|
|
@@ -22,6 +28,14 @@ function printHelp() {
|
|
|
22
28
|
maclat register --name "..." Register as an agent
|
|
23
29
|
maclat start Start the agent daemon
|
|
24
30
|
maclat myinfo Show your agent profile
|
|
31
|
+
maclat use <provider> [key] Set executor backend
|
|
32
|
+
maclat config Show current config
|
|
33
|
+
|
|
34
|
+
Providers:
|
|
35
|
+
claude-code Claude Code subscription (default)
|
|
36
|
+
anthropic Anthropic API
|
|
37
|
+
openrouter OpenRouter (400+ models)
|
|
38
|
+
codex OpenAI Codex CLI
|
|
25
39
|
|
|
26
40
|
Config stored at: ~/.maclat/config.json
|
|
27
41
|
`);
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3B,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,UAAU;YACb,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrB,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,MAAM,EAAE,CAAC;YACf,MAAM;QACR,KAAK,KAAK;YACR,WAAW,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,QAAQ;YACX,UAAU,EAAE,CAAC;YACb,MAAM;QACR;YACE,SAAS,EAAE,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;CAkBb,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -7,16 +7,14 @@ export interface ExecutionResult {
|
|
|
7
7
|
}>;
|
|
8
8
|
summary: string;
|
|
9
9
|
}
|
|
10
|
-
export type OnUpdate = (type: 'text' | 'terminal', content: string) => void;
|
|
11
|
-
export interface
|
|
12
|
-
|
|
10
|
+
export type OnUpdate = (type: 'text' | 'terminal' | 'file_write', content: string) => void;
|
|
11
|
+
export interface Interactivity {
|
|
12
|
+
getInstructions: () => Promise<Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}>>;
|
|
16
|
+
markDelivered: (id: string) => Promise<void>;
|
|
13
17
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
private claudePath;
|
|
17
|
-
constructor(maxTurns?: number);
|
|
18
|
-
execute(job: Job, workDir: string, onUpdate: OnUpdate): Promise<ExecutionResult>;
|
|
19
|
-
private handleStreamEvent;
|
|
20
|
-
private buildPrompt;
|
|
21
|
-
private collectFiles;
|
|
18
|
+
export interface JobExecutor {
|
|
19
|
+
execute(job: Job, workDir: string, onUpdate: OnUpdate, interactivity?: Interactivity): Promise<ExecutionResult>;
|
|
22
20
|
}
|
package/dist/daemon/executor.js
CHANGED
|
@@ -1,213 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { mkdirSync, readdirSync, readFileSync, statSync, existsSync } from 'fs';
|
|
3
|
-
import { join, relative } from 'path';
|
|
4
|
-
import { homedir } from 'os';
|
|
5
|
-
function findClaudeBinary() {
|
|
6
|
-
// Check PATH first
|
|
7
|
-
try {
|
|
8
|
-
const path = execSync('which claude 2>/dev/null', { encoding: 'utf-8' }).trim();
|
|
9
|
-
if (path)
|
|
10
|
-
return path;
|
|
11
|
-
}
|
|
12
|
-
catch { /* not in PATH */ }
|
|
13
|
-
// Check known macOS location
|
|
14
|
-
const appSupport = join(homedir(), 'Library', 'Application Support', 'Claude', 'claude-code');
|
|
15
|
-
if (existsSync(appSupport)) {
|
|
16
|
-
const versions = readdirSync(appSupport).sort().reverse(); // latest first
|
|
17
|
-
for (const v of versions) {
|
|
18
|
-
const bin = join(appSupport, v, 'claude');
|
|
19
|
-
if (existsSync(bin))
|
|
20
|
-
return bin;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
// Fallback
|
|
24
|
-
return 'claude';
|
|
25
|
-
}
|
|
26
|
-
function ts() {
|
|
27
|
-
return new Date().toLocaleTimeString('en-US', { hour12: false });
|
|
28
|
-
}
|
|
29
|
-
const GATEWAY_UPDATE_INTERVAL_MS = 60_000; // push to gateway every 60s
|
|
30
|
-
export class ClaudeCodeExecutor {
|
|
31
|
-
maxTurns;
|
|
32
|
-
claudePath;
|
|
33
|
-
constructor(maxTurns = 50) {
|
|
34
|
-
this.maxTurns = maxTurns;
|
|
35
|
-
this.claudePath = findClaudeBinary();
|
|
36
|
-
}
|
|
37
|
-
async execute(job, workDir, onUpdate) {
|
|
38
|
-
mkdirSync(workDir, { recursive: true });
|
|
39
|
-
const prompt = this.buildPrompt(job, workDir);
|
|
40
|
-
console.log(` Using claude binary: ${this.claudePath}`);
|
|
41
|
-
return new Promise((resolve) => {
|
|
42
|
-
const claude = spawn(this.claudePath, [
|
|
43
|
-
'-p', prompt,
|
|
44
|
-
'--output-format', 'stream-json',
|
|
45
|
-
'--verbose',
|
|
46
|
-
'--max-turns', String(this.maxTurns),
|
|
47
|
-
'--dangerously-skip-permissions',
|
|
48
|
-
], {
|
|
49
|
-
cwd: workDir,
|
|
50
|
-
stdio: ['ignore', 'pipe', 'inherit'],
|
|
51
|
-
env: { ...process.env, CLAUDECODE: undefined },
|
|
52
|
-
});
|
|
53
|
-
let outputBuffer = '';
|
|
54
|
-
let lastGatewayUpdate = 0;
|
|
55
|
-
const pendingActions = [];
|
|
56
|
-
const stripPath = (s) => s.replace(new RegExp(workDir + '/?', 'g'), '');
|
|
57
|
-
claude.stdout?.on('data', (chunk) => {
|
|
58
|
-
const text = chunk.toString();
|
|
59
|
-
outputBuffer += text;
|
|
60
|
-
const lines = outputBuffer.split('\n');
|
|
61
|
-
outputBuffer = lines.pop() || '';
|
|
62
|
-
for (const line of lines) {
|
|
63
|
-
if (!line.trim())
|
|
64
|
-
continue;
|
|
65
|
-
try {
|
|
66
|
-
const event = JSON.parse(line);
|
|
67
|
-
this.handleStreamEvent(event, onUpdate, pendingActions, stripPath, () => {
|
|
68
|
-
const now = Date.now();
|
|
69
|
-
if (now - lastGatewayUpdate >= GATEWAY_UPDATE_INTERVAL_MS && pendingActions.length > 0) {
|
|
70
|
-
lastGatewayUpdate = now;
|
|
71
|
-
const summary = pendingActions.splice(0).join(' → ');
|
|
72
|
-
onUpdate('text', summary.slice(0, 500));
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
if (line.trim()) {
|
|
78
|
-
process.stdout.write(line + '\n');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
claude.on('close', (code) => {
|
|
84
|
-
const files = this.collectFiles(workDir);
|
|
85
|
-
const summary = code === 0
|
|
86
|
-
? `Job completed successfully. ${files.length} file(s) created.`
|
|
87
|
-
: `Job finished with exit code ${code}. ${files.length} file(s) in working directory.`;
|
|
88
|
-
if (pendingActions.length > 0) {
|
|
89
|
-
onUpdate('text', pendingActions.join(' → ').slice(0, 500));
|
|
90
|
-
pendingActions.length = 0;
|
|
91
|
-
}
|
|
92
|
-
onUpdate('text', summary);
|
|
93
|
-
resolve({
|
|
94
|
-
success: code === 0,
|
|
95
|
-
files,
|
|
96
|
-
summary,
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
claude.on('error', (err) => {
|
|
100
|
-
console.log(` [${ts()}] ERROR: Failed to spawn claude: ${err.message}`);
|
|
101
|
-
onUpdate('text', `Error spawning claude: ${err.message}`);
|
|
102
|
-
resolve({
|
|
103
|
-
success: false,
|
|
104
|
-
files: [],
|
|
105
|
-
summary: `Failed to spawn claude: ${err.message}`,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
handleStreamEvent(event, onUpdate, pendingActions, stripPath, maybeFlush) {
|
|
111
|
-
switch (event.type) {
|
|
112
|
-
case 'system': {
|
|
113
|
-
console.log(` [${ts()}] Agent started`);
|
|
114
|
-
onUpdate('text', 'Agent started working');
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
case 'assistant': {
|
|
118
|
-
const msg = event.message;
|
|
119
|
-
if (msg?.content && Array.isArray(msg.content)) {
|
|
120
|
-
for (const block of msg.content) {
|
|
121
|
-
if (block.type === 'text' && typeof block.text === 'string') {
|
|
122
|
-
const text = stripPath(block.text).slice(0, 500);
|
|
123
|
-
console.log(` [${ts()}] ${text}`);
|
|
124
|
-
pendingActions.push(text.slice(0, 80));
|
|
125
|
-
}
|
|
126
|
-
else if (block.type === 'tool_use') {
|
|
127
|
-
const toolName = block.name || 'tool';
|
|
128
|
-
const input = (block.input || {});
|
|
129
|
-
const rawTarget = String(input.file_path || input.path || input.command || input.pattern || '');
|
|
130
|
-
const target = stripPath(rawTarget);
|
|
131
|
-
const label = target ? `${toolName}: ${target}` : String(toolName);
|
|
132
|
-
console.log(` [${ts()}] > ${label}`);
|
|
133
|
-
pendingActions.push(label.slice(0, 80));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
maybeFlush();
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case 'tool_result': {
|
|
141
|
-
const output = stripPath(String(event.output || event.content || '')).slice(0, 200);
|
|
142
|
-
if (output) {
|
|
143
|
-
console.log(` [${ts()}] → ${output.split('\n')[0]}`);
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case 'result': {
|
|
148
|
-
const result = event.result;
|
|
149
|
-
if (typeof result === 'string') {
|
|
150
|
-
const clean = stripPath(result);
|
|
151
|
-
console.log(`\n [${ts()}] DONE: ${clean.slice(0, 500)}`);
|
|
152
|
-
onUpdate('text', clean.slice(0, 200));
|
|
153
|
-
}
|
|
154
|
-
const cost = event.total_cost_usd;
|
|
155
|
-
const turns = event.num_turns;
|
|
156
|
-
if (cost)
|
|
157
|
-
console.log(` [${ts()}] Cost: $${cost}`);
|
|
158
|
-
if (turns)
|
|
159
|
-
console.log(` [${ts()}] Turns: ${turns}`);
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
buildPrompt(job, workDir) {
|
|
165
|
-
return [
|
|
166
|
-
`You are an autonomous agent executing a job from the Maclat marketplace.`,
|
|
167
|
-
``,
|
|
168
|
-
`## Job Details`,
|
|
169
|
-
`- Title: ${job.title}`,
|
|
170
|
-
`- Description: ${job.description}`,
|
|
171
|
-
`- Budget: ${job.budget_usdc} USDC`,
|
|
172
|
-
``,
|
|
173
|
-
`## Instructions`,
|
|
174
|
-
`1. Work in the current directory: ${workDir}`,
|
|
175
|
-
`2. Complete the job as described above`,
|
|
176
|
-
`3. Create all necessary files in the current directory`,
|
|
177
|
-
`4. Make sure everything works and is complete`,
|
|
178
|
-
`5. When done, provide a brief summary of what you built`,
|
|
179
|
-
``,
|
|
180
|
-
`Do your best work. The job poster will review your deliverables.`,
|
|
181
|
-
].join('\n');
|
|
182
|
-
}
|
|
183
|
-
collectFiles(dir, base) {
|
|
184
|
-
const files = [];
|
|
185
|
-
const root = base || dir;
|
|
186
|
-
try {
|
|
187
|
-
const entries = readdirSync(dir);
|
|
188
|
-
for (const entry of entries) {
|
|
189
|
-
if (entry.startsWith('.') || entry === 'node_modules')
|
|
190
|
-
continue;
|
|
191
|
-
const fullPath = join(dir, entry);
|
|
192
|
-
const stat = statSync(fullPath);
|
|
193
|
-
if (stat.isDirectory()) {
|
|
194
|
-
files.push(...this.collectFiles(fullPath, root));
|
|
195
|
-
}
|
|
196
|
-
else if (stat.isFile() && stat.size < 100_000) {
|
|
197
|
-
try {
|
|
198
|
-
const content = readFileSync(fullPath, 'utf-8');
|
|
199
|
-
files.push({ path: relative(root, fullPath), content });
|
|
200
|
-
}
|
|
201
|
-
catch {
|
|
202
|
-
// Binary file or unreadable, skip
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
// Directory doesn't exist or not readable
|
|
209
|
-
}
|
|
210
|
-
return files;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
1
|
+
export {};
|
|
213
2
|
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/daemon/executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/daemon/executor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Job } from '../../shared/types.js';
|
|
2
|
+
import type { JobExecutor, ExecutionResult, OnUpdate } from '../executor.js';
|
|
3
|
+
export declare class ClaudeCodeExecutor implements JobExecutor {
|
|
4
|
+
private maxTurns;
|
|
5
|
+
private claudePath;
|
|
6
|
+
constructor(maxTurns?: number);
|
|
7
|
+
execute(job: Job, workDir: string, onUpdate: OnUpdate): Promise<ExecutionResult>;
|
|
8
|
+
private handleStreamEvent;
|
|
9
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { spawn, execSync } from 'child_process';
|
|
2
|
+
import { mkdirSync, readdirSync, existsSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
import { buildPrompt } from './prompt.js';
|
|
6
|
+
import { collectFiles } from './file-collector.js';
|
|
7
|
+
import { bold, dim, gray, toolPill, fileWrite as fmtFileWrite, agentText, jobDone, jobError, costLine } from '../format.js';
|
|
8
|
+
function findClaudeBinary() {
|
|
9
|
+
try {
|
|
10
|
+
const path = execSync('which claude 2>/dev/null', { encoding: 'utf-8' }).trim();
|
|
11
|
+
if (path)
|
|
12
|
+
return path;
|
|
13
|
+
}
|
|
14
|
+
catch { /* not in PATH */ }
|
|
15
|
+
const appSupport = join(homedir(), 'Library', 'Application Support', 'Claude', 'claude-code');
|
|
16
|
+
if (existsSync(appSupport)) {
|
|
17
|
+
const versions = readdirSync(appSupport).sort().reverse();
|
|
18
|
+
for (const v of versions) {
|
|
19
|
+
const bin = join(appSupport, v, 'claude');
|
|
20
|
+
if (existsSync(bin))
|
|
21
|
+
return bin;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return 'claude';
|
|
25
|
+
}
|
|
26
|
+
const GATEWAY_UPDATE_INTERVAL_MS = 60_000;
|
|
27
|
+
export class ClaudeCodeExecutor {
|
|
28
|
+
maxTurns;
|
|
29
|
+
claudePath;
|
|
30
|
+
constructor(maxTurns = 50) {
|
|
31
|
+
this.maxTurns = maxTurns;
|
|
32
|
+
this.claudePath = findClaudeBinary();
|
|
33
|
+
}
|
|
34
|
+
async execute(job, workDir, onUpdate) {
|
|
35
|
+
mkdirSync(workDir, { recursive: true });
|
|
36
|
+
const prompt = buildPrompt(job, workDir);
|
|
37
|
+
console.log(` ${dim('Using')} ${bold('Claude Code')} ${gray(`(${this.claudePath})`)}`);
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const claude = spawn(this.claudePath, [
|
|
40
|
+
'-p', prompt,
|
|
41
|
+
'--output-format', 'stream-json',
|
|
42
|
+
'--verbose',
|
|
43
|
+
'--max-turns', String(this.maxTurns),
|
|
44
|
+
'--dangerously-skip-permissions',
|
|
45
|
+
], {
|
|
46
|
+
cwd: workDir,
|
|
47
|
+
stdio: ['ignore', 'pipe', 'inherit'],
|
|
48
|
+
env: { ...process.env, CLAUDECODE: undefined },
|
|
49
|
+
});
|
|
50
|
+
let outputBuffer = '';
|
|
51
|
+
let lastGatewayUpdate = 0;
|
|
52
|
+
const pendingActions = [];
|
|
53
|
+
const stripPath = (s) => s.replace(new RegExp(workDir + '/?', 'g'), '');
|
|
54
|
+
claude.stdout?.on('data', (chunk) => {
|
|
55
|
+
const text = chunk.toString();
|
|
56
|
+
outputBuffer += text;
|
|
57
|
+
const lines = outputBuffer.split('\n');
|
|
58
|
+
outputBuffer = lines.pop() || '';
|
|
59
|
+
for (const line of lines) {
|
|
60
|
+
if (!line.trim())
|
|
61
|
+
continue;
|
|
62
|
+
try {
|
|
63
|
+
const event = JSON.parse(line);
|
|
64
|
+
this.handleStreamEvent(event, onUpdate, pendingActions, stripPath, () => {
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
if (now - lastGatewayUpdate >= GATEWAY_UPDATE_INTERVAL_MS && pendingActions.length > 0) {
|
|
67
|
+
lastGatewayUpdate = now;
|
|
68
|
+
const summary = pendingActions.splice(0).join(' → ');
|
|
69
|
+
onUpdate('text', summary.slice(0, 500));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
if (line.trim())
|
|
75
|
+
process.stdout.write(line + '\n');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
claude.on('close', (code) => {
|
|
80
|
+
const files = collectFiles(workDir);
|
|
81
|
+
const summary = code === 0
|
|
82
|
+
? `Job completed successfully. ${files.length} file(s) created.`
|
|
83
|
+
: `Job finished with exit code ${code}. ${files.length} file(s) in working directory.`;
|
|
84
|
+
if (pendingActions.length > 0) {
|
|
85
|
+
onUpdate('text', pendingActions.join(' → ').slice(0, 500));
|
|
86
|
+
pendingActions.length = 0;
|
|
87
|
+
}
|
|
88
|
+
onUpdate('text', summary);
|
|
89
|
+
console.log('');
|
|
90
|
+
console.log(jobDone(`${files.length} files created`));
|
|
91
|
+
resolve({ success: code === 0, files, summary });
|
|
92
|
+
});
|
|
93
|
+
claude.on('error', (err) => {
|
|
94
|
+
console.log(jobError(`Failed to spawn claude: ${err.message}`));
|
|
95
|
+
onUpdate('text', `Error spawning claude: ${err.message}`);
|
|
96
|
+
resolve({ success: false, files: [], summary: `Failed to spawn claude: ${err.message}` });
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
handleStreamEvent(event, onUpdate, pendingActions, stripPath, maybeFlush) {
|
|
101
|
+
switch (event.type) {
|
|
102
|
+
case 'system': {
|
|
103
|
+
console.log(agentText('Agent started'));
|
|
104
|
+
onUpdate('text', 'Agent started working');
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'assistant': {
|
|
108
|
+
const msg = event.message;
|
|
109
|
+
if (msg?.content && Array.isArray(msg.content)) {
|
|
110
|
+
for (const block of msg.content) {
|
|
111
|
+
if (block.type === 'text' && typeof block.text === 'string') {
|
|
112
|
+
const text = stripPath(block.text).slice(0, 500);
|
|
113
|
+
console.log(agentText(text.split('\n')[0].slice(0, 120)));
|
|
114
|
+
pendingActions.push(text.slice(0, 80));
|
|
115
|
+
}
|
|
116
|
+
else if (block.type === 'tool_use') {
|
|
117
|
+
const toolName = String(block.name || 'tool');
|
|
118
|
+
const input = (block.input || {});
|
|
119
|
+
const rawTarget = String(input.file_path || input.path || input.command || input.pattern || '');
|
|
120
|
+
const target = stripPath(rawTarget).slice(0, 60);
|
|
121
|
+
const label = target ? `${toolName}: ${target}` : String(toolName);
|
|
122
|
+
// Pretty terminal output
|
|
123
|
+
console.log(toolPill(toolName, target));
|
|
124
|
+
pendingActions.push(label.slice(0, 80));
|
|
125
|
+
onUpdate('terminal', label);
|
|
126
|
+
// Emit file_write for Write/Edit tool uses
|
|
127
|
+
if (toolName === 'Write' && typeof input.file_path === 'string' && typeof input.content === 'string') {
|
|
128
|
+
const relPath = stripPath(String(input.file_path));
|
|
129
|
+
console.log(fmtFileWrite(relPath));
|
|
130
|
+
onUpdate('file_write', JSON.stringify({ path: relPath, content: input.content }));
|
|
131
|
+
}
|
|
132
|
+
else if (toolName === 'Edit' && typeof input.file_path === 'string') {
|
|
133
|
+
const relPath = stripPath(String(input.file_path));
|
|
134
|
+
onUpdate('file_write', JSON.stringify({ path: relPath, edit: { old_string: input.old_string, new_string: input.new_string } }));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
maybeFlush();
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case 'tool_result': {
|
|
143
|
+
const output = stripPath(String(event.output || event.content || '')).slice(0, 200);
|
|
144
|
+
if (output)
|
|
145
|
+
console.log(` ${gray('→')} ${dim(output.split('\n')[0])}`);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case 'result': {
|
|
149
|
+
const result = event.result;
|
|
150
|
+
if (typeof result === 'string') {
|
|
151
|
+
const clean = stripPath(result);
|
|
152
|
+
console.log('');
|
|
153
|
+
console.log(jobDone(clean.slice(0, 200)));
|
|
154
|
+
onUpdate('text', clean.slice(0, 200));
|
|
155
|
+
}
|
|
156
|
+
const cost = event.total_cost_usd;
|
|
157
|
+
const turns = event.num_turns;
|
|
158
|
+
if (cost)
|
|
159
|
+
console.log(costLine(cost, turns));
|
|
160
|
+
break;
|
|
161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;oBAChC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBAChB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC1C,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;gBACxC,CAAC;gBACD,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC;gBAClC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;gBAC9B,IAAI,IAAI;oBAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAc,EAAE,KAA2B,CAAC,CAAC,CAAC;gBAC7E,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Job } from '../../shared/types.js';
|
|
2
|
+
import type { JobExecutor, ExecutionResult, OnUpdate, Interactivity } from '../executor.js';
|
|
3
|
+
export declare class ClaudeSdkExecutor implements JobExecutor {
|
|
4
|
+
private apiKey;
|
|
5
|
+
private model;
|
|
6
|
+
private maxTurns;
|
|
7
|
+
private baseUrl?;
|
|
8
|
+
constructor(apiKey: string, model?: string, maxTurns?: number, baseUrl?: string);
|
|
9
|
+
execute(job: Job, workDir: string, onUpdate: OnUpdate, interactivity?: Interactivity): Promise<ExecutionResult>;
|
|
10
|
+
}
|