@controlvector/cv-agent 1.0.0 → 1.1.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.
package/dist/bundle.cjs CHANGED
@@ -3922,7 +3922,7 @@ function capturePostTaskState(cwd, preState) {
3922
3922
  pushRemote
3923
3923
  };
3924
3924
  }
3925
- function buildCompletionPayload(exitCode, preState, postState, startTime) {
3925
+ function buildCompletionPayload(exitCode, preState, postState, startTime, output = "") {
3926
3926
  const durationSec = Math.floor((Date.now() - startTime) / 1e3);
3927
3927
  const durationStr = durationSec >= 60 ? `${Math.floor(durationSec / 60)}m ${durationSec % 60}s` : `${durationSec}s`;
3928
3928
  const totalChanged = postState.filesAdded.length + postState.filesModified.length + postState.filesDeleted.length;
@@ -3944,6 +3944,7 @@ function buildCompletionPayload(exitCode, preState, postState, startTime) {
3944
3944
  }
3945
3945
  return {
3946
3946
  summary: parts.join(" "),
3947
+ output,
3947
3948
  commit: {
3948
3949
  sha: postState.headSha,
3949
3950
  branch: postState.branch,
@@ -4204,9 +4205,13 @@ var PERMISSION_PATTERNS = [
4204
4205
  /Do you want to proceed\? \(y\/n\)/,
4205
4206
  /\? \(y\/n\)/
4206
4207
  ];
4208
+ var MAX_OUTPUT_BYTES = 200 * 1024;
4209
+ var OUTPUT_PROGRESS_INTERVAL = 4096;
4207
4210
  async function launchAutoApproveMode(prompt, options) {
4208
4211
  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;
4209
4212
  const pendingQuestionIds = [];
4213
+ let fullOutput = "";
4214
+ let lastProgressBytes = 0;
4210
4215
  const runOnce = (inputPrompt, isContinue) => {
4211
4216
  return new Promise((resolve, reject) => {
4212
4217
  const args = isContinue ? ["-p", inputPrompt, "--continue", "--allowedTools", ...ALLOWED_TOOLS] : ["-p", inputPrompt, "--allowedTools", ...ALLOWED_TOOLS];
@@ -4224,6 +4229,10 @@ async function launchAutoApproveMode(prompt, options) {
4224
4229
  child.stdout?.on("data", (data) => {
4225
4230
  const text = data.toString();
4226
4231
  process.stdout.write(data);
4232
+ fullOutput += text;
4233
+ if (fullOutput.length > MAX_OUTPUT_BYTES) {
4234
+ fullOutput = fullOutput.slice(-MAX_OUTPUT_BYTES);
4235
+ }
4227
4236
  if (options.creds && options.taskId) {
4228
4237
  lineBuffer += text;
4229
4238
  const lines = lineBuffer.split("\n");
@@ -4243,6 +4252,21 @@ async function launchAutoApproveMode(prompt, options) {
4243
4252
  });
4244
4253
  }
4245
4254
  }
4255
+ if (fullOutput.length - lastProgressBytes >= OUTPUT_PROGRESS_INTERVAL) {
4256
+ const chunk = fullOutput.slice(lastProgressBytes).slice(-OUTPUT_PROGRESS_INTERVAL);
4257
+ lastProgressBytes = fullOutput.length;
4258
+ if (options.executorId) {
4259
+ sendTaskLog(
4260
+ options.creds,
4261
+ options.executorId,
4262
+ options.taskId,
4263
+ "progress",
4264
+ "Claude Code output",
4265
+ { output_chunk: chunk }
4266
+ ).catch(() => {
4267
+ });
4268
+ }
4269
+ }
4246
4270
  }
4247
4271
  });
4248
4272
  child.stderr?.on("data", (data) => {
@@ -4251,7 +4275,7 @@ async function launchAutoApproveMode(prompt, options) {
4251
4275
  });
4252
4276
  child.on("close", (code, signal) => {
4253
4277
  _activeChild = null;
4254
- resolve({ exitCode: signal === "SIGKILL" ? 137 : code ?? 1, stderr });
4278
+ resolve({ exitCode: signal === "SIGKILL" ? 137 : code ?? 1, stderr, output: fullOutput });
4255
4279
  });
4256
4280
  child.on("error", (err) => {
4257
4281
  _activeChild = null;
@@ -4294,6 +4318,8 @@ async function launchRelayMode(prompt, options) {
4294
4318
  _activeChild = child;
4295
4319
  let stderr = "";
4296
4320
  let stdoutBuffer = "";
4321
+ let fullOutput = "";
4322
+ let lastProgressBytes = 0;
4297
4323
  child.stdin?.write(prompt + "\n");
4298
4324
  let lastRedirectCheck = Date.now();
4299
4325
  let lineBuffer = "";
@@ -4301,6 +4327,10 @@ async function launchRelayMode(prompt, options) {
4301
4327
  const text = data.toString();
4302
4328
  process.stdout.write(data);
4303
4329
  stdoutBuffer += text;
4330
+ fullOutput += text;
4331
+ if (fullOutput.length > MAX_OUTPUT_BYTES) {
4332
+ fullOutput = fullOutput.slice(-MAX_OUTPUT_BYTES);
4333
+ }
4304
4334
  lineBuffer += text;
4305
4335
  const lines = lineBuffer.split("\n");
4306
4336
  lineBuffer = lines.pop() ?? "";
@@ -4334,6 +4364,19 @@ async function launchRelayMode(prompt, options) {
4334
4364
  }
4335
4365
  }
4336
4366
  }
4367
+ if (fullOutput.length - lastProgressBytes >= OUTPUT_PROGRESS_INTERVAL) {
4368
+ const chunk = fullOutput.slice(lastProgressBytes).slice(-OUTPUT_PROGRESS_INTERVAL);
4369
+ lastProgressBytes = fullOutput.length;
4370
+ sendTaskLog(
4371
+ options.creds,
4372
+ options.executorId,
4373
+ options.taskId,
4374
+ "progress",
4375
+ "Claude Code output",
4376
+ { output_chunk: chunk }
4377
+ ).catch(() => {
4378
+ });
4379
+ }
4337
4380
  if (Date.now() - lastRedirectCheck > 1e4) {
4338
4381
  try {
4339
4382
  const redirects = await getRedirects(
@@ -4427,9 +4470,9 @@ async function launchRelayMode(prompt, options) {
4427
4470
  child.on("close", (code, signal) => {
4428
4471
  _activeChild = null;
4429
4472
  if (signal === "SIGKILL") {
4430
- resolve({ exitCode: 137, stderr });
4473
+ resolve({ exitCode: 137, stderr, output: fullOutput });
4431
4474
  } else {
4432
- resolve({ exitCode: code ?? 1, stderr });
4475
+ resolve({ exitCode: code ?? 1, stderr, output: fullOutput });
4433
4476
  }
4434
4477
  });
4435
4478
  child.on("error", (err) => {
@@ -4557,6 +4600,7 @@ async function executeTask(task, state, creds, options) {
4557
4600
  const startTime = Date.now();
4558
4601
  state.currentTaskId = task.id;
4559
4602
  process.stdout.write("\r\x1B[K");
4603
+ console.log(`\u{1F4E5} ${source_default.bold.cyan("RECEIVED")} \u2014 Task: ${task.title} (${task.priority})`);
4560
4604
  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"));
4561
4605
  console.log(source_default.bold(`\u2502 Task: ${(task.title || "").substring(0, 53).padEnd(53)}\u2502`));
4562
4606
  console.log(source_default.bold(`\u2502 ID: ${task.id.padEnd(55)}\u2502`));
@@ -4599,7 +4643,7 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
4599
4643
  const prompt = buildClaudePrompt(task);
4600
4644
  try {
4601
4645
  const mode = options.autoApprove ? "auto-approve" : "relay";
4602
- console.log(source_default.cyan("Launching Claude Code") + ` (${mode} mode)...`);
4646
+ console.log(`\u{1F680} ${source_default.bold.green("RUNNING")} \u2014 Launching Claude Code (${mode})...`);
4603
4647
  if (options.autoApprove) {
4604
4648
  console.log(source_default.gray(" Allowed tools: ") + ALLOWED_TOOLS.join(", "));
4605
4649
  }
@@ -4609,7 +4653,8 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
4609
4653
  result = await launchAutoApproveMode(prompt, {
4610
4654
  cwd: options.workingDir,
4611
4655
  creds,
4612
- taskId: task.id
4656
+ taskId: task.id,
4657
+ executorId: state.executorId
4613
4658
  });
4614
4659
  } else {
4615
4660
  result = await launchRelayMode(prompt, {
@@ -4621,7 +4666,7 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
4621
4666
  }
4622
4667
  console.log(source_default.gray("\n" + "-".repeat(60)));
4623
4668
  const postGitState = capturePostTaskState(options.workingDir, preGitState);
4624
- const payload = buildCompletionPayload(result.exitCode, preGitState, postGitState, startTime);
4669
+ const payload = buildCompletionPayload(result.exitCode, preGitState, postGitState, startTime, result.output);
4625
4670
  const elapsed = formatDuration(Date.now() - startTime);
4626
4671
  const allChangedFiles = [
4627
4672
  ...postGitState.filesAdded,
@@ -4658,6 +4703,7 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
4658
4703
  100
4659
4704
  );
4660
4705
  console.log();
4706
+ console.log(`\u2705 ${source_default.bold.green("COMPLETED")} \u2014 Duration: ${elapsed}`);
4661
4707
  printBanner("COMPLETED", elapsed, allChangedFiles, postGitState.headSha);
4662
4708
  await withRetry(
4663
4709
  () => completeTask(creds, state.executorId, task.id, payload),
@@ -4674,6 +4720,7 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
4674
4720
  "Task aborted by user (Ctrl+C)"
4675
4721
  );
4676
4722
  console.log();
4723
+ console.log(`\u23F9 ${source_default.bold.yellow("ABORTED")} \u2014 Duration: ${elapsed}`);
4677
4724
  printBanner("ABORTED", elapsed, [], null);
4678
4725
  try {
4679
4726
  await failTask(creds, state.executorId, task.id, "Aborted by user (Ctrl+C)");
@@ -4691,6 +4738,7 @@ ${source_default.red("Timeout")} Task timed out after ${formatDuration(timeoutMs
4691
4738
  stderrTail ? { stderr_tail: stderrTail } : void 0
4692
4739
  );
4693
4740
  console.log();
4741
+ console.log(`\u274C ${source_default.bold.red("FAILED")} \u2014 Duration: ${elapsed} (exit code ${result.exitCode})`);
4694
4742
  printBanner("FAILED", elapsed, allChangedFiles, postGitState.headSha);
4695
4743
  const errorDetail = result.stderr.trim() ? `${result.stderr.trim().slice(-1500)}
4696
4744
 
@@ -5033,7 +5081,7 @@ function statusCommand() {
5033
5081
 
5034
5082
  // src/index.ts
5035
5083
  var program2 = new Command();
5036
- program2.name("cva").description("CV-Hub Agent \u2014 bridges Claude Code with CV-Hub task dispatch").version("1.0.0");
5084
+ program2.name("cva").description("CV-Hub Agent \u2014 bridges Claude Code with CV-Hub task dispatch").version(true ? "1.1.1" : "1.1.0");
5037
5085
  program2.addCommand(agentCommand());
5038
5086
  program2.addCommand(authCommand());
5039
5087
  program2.addCommand(remoteCommand());