@controlvector/cv-agent 1.1.1 → 1.2.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/bundle.cjs +87 -1
- package/dist/bundle.cjs.map +2 -2
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +88 -0
- package/dist/commands/agent.js.map +1 -1
- package/package.json +7 -2
package/dist/bundle.cjs
CHANGED
|
@@ -4206,6 +4206,7 @@ var PERMISSION_PATTERNS = [
|
|
|
4206
4206
|
/\? \(y\/n\)/
|
|
4207
4207
|
];
|
|
4208
4208
|
var MAX_OUTPUT_BYTES = 200 * 1024;
|
|
4209
|
+
var MAX_OUTPUT_FINAL_BYTES = 50 * 1024;
|
|
4209
4210
|
var OUTPUT_PROGRESS_INTERVAL = 4096;
|
|
4210
4211
|
async function launchAutoApproveMode(prompt, options) {
|
|
4211
4212
|
const sessionId = options.taskId ? options.taskId.replace(/-/g, "").slice(0, 32).padEnd(32, "0").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5") : void 0;
|
|
@@ -4266,6 +4267,11 @@ async function launchAutoApproveMode(prompt, options) {
|
|
|
4266
4267
|
).catch(() => {
|
|
4267
4268
|
});
|
|
4268
4269
|
}
|
|
4270
|
+
postTaskEvent(options.creds, options.taskId, {
|
|
4271
|
+
event_type: "output",
|
|
4272
|
+
content: { chunk, byte_offset: lastProgressBytes }
|
|
4273
|
+
}).catch(() => {
|
|
4274
|
+
});
|
|
4269
4275
|
}
|
|
4270
4276
|
}
|
|
4271
4277
|
});
|
|
@@ -4376,6 +4382,11 @@ async function launchRelayMode(prompt, options) {
|
|
|
4376
4382
|
{ output_chunk: chunk }
|
|
4377
4383
|
).catch(() => {
|
|
4378
4384
|
});
|
|
4385
|
+
postTaskEvent(options.creds, options.taskId, {
|
|
4386
|
+
event_type: "output",
|
|
4387
|
+
content: { chunk, byte_offset: lastProgressBytes }
|
|
4388
|
+
}).catch(() => {
|
|
4389
|
+
});
|
|
4379
4390
|
}
|
|
4380
4391
|
if (Date.now() - lastRedirectCheck > 1e4) {
|
|
4381
4392
|
try {
|
|
@@ -4495,6 +4506,68 @@ async function pollForEventResponse(creds, taskId, eventId, timeoutMs) {
|
|
|
4495
4506
|
}
|
|
4496
4507
|
return null;
|
|
4497
4508
|
}
|
|
4509
|
+
async function handleSelfUpdate(task, state, creds) {
|
|
4510
|
+
const startTime = Date.now();
|
|
4511
|
+
try {
|
|
4512
|
+
await startTask(creds, state.executorId, task.id);
|
|
4513
|
+
sendTaskLog(creds, state.executorId, task.id, "lifecycle", "Self-update started");
|
|
4514
|
+
const source = (task.input?.description || task.description || "npm").trim();
|
|
4515
|
+
let output = "";
|
|
4516
|
+
if (source === "npm" || source.startsWith("npm:")) {
|
|
4517
|
+
const pkg = source === "npm" ? "@controlvector/cv-agent@latest" : source.replace("npm:", "");
|
|
4518
|
+
output = (0, import_node_child_process2.execSync)(`npm install -g ${pkg} 2>&1`, { encoding: "utf8", timeout: 12e4 });
|
|
4519
|
+
} else if (source.startsWith("git:")) {
|
|
4520
|
+
const repoPath = source.replace("git:", "");
|
|
4521
|
+
output = (0, import_node_child_process2.execSync)(`cd ${repoPath} && git pull && npm install && npm run build && npm link 2>&1`, {
|
|
4522
|
+
encoding: "utf8",
|
|
4523
|
+
timeout: 3e5
|
|
4524
|
+
});
|
|
4525
|
+
} else {
|
|
4526
|
+
output = (0, import_node_child_process2.execSync)(`npm install -g @controlvector/cv-agent@latest 2>&1`, { encoding: "utf8", timeout: 12e4 });
|
|
4527
|
+
}
|
|
4528
|
+
let newVersion = "unknown";
|
|
4529
|
+
try {
|
|
4530
|
+
newVersion = (0, import_node_child_process2.execSync)("cva --version 2>/dev/null || echo unknown", { encoding: "utf8" }).trim();
|
|
4531
|
+
} catch {
|
|
4532
|
+
}
|
|
4533
|
+
postTaskEvent(creds, task.id, {
|
|
4534
|
+
event_type: "output_final",
|
|
4535
|
+
content: { output: output.slice(-1e4), new_version: newVersion }
|
|
4536
|
+
}).catch(() => {
|
|
4537
|
+
});
|
|
4538
|
+
sendTaskLog(
|
|
4539
|
+
creds,
|
|
4540
|
+
state.executorId,
|
|
4541
|
+
task.id,
|
|
4542
|
+
"lifecycle",
|
|
4543
|
+
`Self-update completed. New version: ${newVersion}`,
|
|
4544
|
+
{ output: output.slice(-5e3) },
|
|
4545
|
+
100
|
|
4546
|
+
);
|
|
4547
|
+
await completeTask(creds, state.executorId, task.id, {
|
|
4548
|
+
summary: `Updated to ${newVersion}`,
|
|
4549
|
+
exit_code: 0,
|
|
4550
|
+
stats: { duration_seconds: Math.round((Date.now() - startTime) / 1e3) }
|
|
4551
|
+
});
|
|
4552
|
+
state.completedCount++;
|
|
4553
|
+
if (task.input?.constraints?.includes("restart")) {
|
|
4554
|
+
console.log(source_default.yellow("Restarting agent with updated binary..."));
|
|
4555
|
+
const args = process.argv.slice(1).join(" ");
|
|
4556
|
+
(0, import_node_child_process2.execSync)(`nohup cva ${args} > /tmp/cva-restart.log 2>&1 &`, { stdio: "ignore" });
|
|
4557
|
+
process.exit(0);
|
|
4558
|
+
}
|
|
4559
|
+
} catch (err) {
|
|
4560
|
+
sendTaskLog(creds, state.executorId, task.id, "error", `Self-update failed: ${err.message}`);
|
|
4561
|
+
try {
|
|
4562
|
+
await failTask(creds, state.executorId, task.id, err.message);
|
|
4563
|
+
} catch {
|
|
4564
|
+
}
|
|
4565
|
+
state.failedCount++;
|
|
4566
|
+
} finally {
|
|
4567
|
+
state.currentTaskId = null;
|
|
4568
|
+
state.lastTaskEnd = Date.now();
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4498
4571
|
async function runAgent(options) {
|
|
4499
4572
|
const creds = await readCredentials();
|
|
4500
4573
|
if (!creds.CV_HUB_API) {
|
|
@@ -4599,6 +4672,10 @@ ${source_default.red("!")} Error: ${err.message}`);
|
|
|
4599
4672
|
async function executeTask(task, state, creds, options) {
|
|
4600
4673
|
const startTime = Date.now();
|
|
4601
4674
|
state.currentTaskId = task.id;
|
|
4675
|
+
if (task.task_type === "_system_update") {
|
|
4676
|
+
await handleSelfUpdate(task, state, creds);
|
|
4677
|
+
return;
|
|
4678
|
+
}
|
|
4602
4679
|
process.stdout.write("\r\x1B[K");
|
|
4603
4680
|
console.log(`\u{1F4E5} ${source_default.bold.cyan("RECEIVED")} \u2014 Task: ${task.title} (${task.priority})`);
|
|
4604
4681
|
console.log(source_default.bold("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
@@ -4705,6 +4782,15 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
|
|
|
4705
4782
|
console.log();
|
|
4706
4783
|
console.log(`\u2705 ${source_default.bold.green("COMPLETED")} \u2014 Duration: ${elapsed}`);
|
|
4707
4784
|
printBanner("COMPLETED", elapsed, allChangedFiles, postGitState.headSha);
|
|
4785
|
+
postTaskEvent(creds, task.id, {
|
|
4786
|
+
event_type: "output_final",
|
|
4787
|
+
content: {
|
|
4788
|
+
output: result.output.slice(-MAX_OUTPUT_FINAL_BYTES),
|
|
4789
|
+
exit_code: result.exitCode,
|
|
4790
|
+
duration_seconds: Math.round((Date.now() - startTime) / 1e3)
|
|
4791
|
+
}
|
|
4792
|
+
}).catch(() => {
|
|
4793
|
+
});
|
|
4708
4794
|
await withRetry(
|
|
4709
4795
|
() => completeTask(creds, state.executorId, task.id, payload),
|
|
4710
4796
|
"Report completion"
|
|
@@ -5081,7 +5167,7 @@ function statusCommand() {
|
|
|
5081
5167
|
|
|
5082
5168
|
// src/index.ts
|
|
5083
5169
|
var program2 = new Command();
|
|
5084
|
-
program2.name("cva").description("CV-Hub Agent \u2014 bridges Claude Code with CV-Hub task dispatch").version(true ? "1.
|
|
5170
|
+
program2.name("cva").description("CV-Hub Agent \u2014 bridges Claude Code with CV-Hub task dispatch").version(true ? "1.2.0" : "1.1.0");
|
|
5085
5171
|
program2.addCommand(agentCommand());
|
|
5086
5172
|
program2.addCommand(authCommand());
|
|
5087
5173
|
program2.addCommand(remoteCommand());
|