@controlvector/cv-agent 1.2.0 → 1.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/bundle.cjs CHANGED
@@ -3643,9 +3643,8 @@ async function apiCall(creds, method, path, body) {
3643
3643
  body: body ? JSON.stringify(body) : void 0
3644
3644
  });
3645
3645
  }
3646
- async function registerExecutor(creds, machineName, workingDir) {
3647
- const hostname2 = (await import("node:os")).hostname();
3648
- const res = await apiCall(creds, "POST", "/api/v1/executors", {
3646
+ async function registerExecutor(creds, machineName, workingDir, repositoryId) {
3647
+ const body = {
3649
3648
  name: `cva:${machineName}`,
3650
3649
  machine_name: machineName,
3651
3650
  type: "claude_code",
@@ -3654,7 +3653,11 @@ async function registerExecutor(creds, machineName, workingDir) {
3654
3653
  tools: ["bash", "read", "write", "edit", "glob", "grep"],
3655
3654
  maxConcurrentTasks: 1
3656
3655
  }
3657
- });
3656
+ };
3657
+ if (repositoryId) {
3658
+ body.repository_id = repositoryId;
3659
+ }
3660
+ const res = await apiCall(creds, "POST", "/api/v1/executors", body);
3658
3661
  if (!res.ok) {
3659
3662
  const err = await res.text();
3660
3663
  throw new Error(`Failed to register executor: ${res.status} ${err}`);
@@ -3662,6 +3665,16 @@ async function registerExecutor(creds, machineName, workingDir) {
3662
3665
  const data = await res.json();
3663
3666
  return { id: data.executor.id, name: data.executor.name };
3664
3667
  }
3668
+ async function resolveRepoId(creds, owner, repo) {
3669
+ try {
3670
+ const res = await apiCall(creds, "GET", `/api/v1/repos/${owner}/${repo}`);
3671
+ if (!res.ok) return null;
3672
+ const data = await res.json();
3673
+ return data.repository ? { id: data.repository.id, slug: data.repository.slug } : null;
3674
+ } catch {
3675
+ return null;
3676
+ }
3677
+ }
3665
3678
  async function markOffline(creds, executorId) {
3666
3679
  await apiCall(creds, "POST", `/api/v1/executors/${executorId}/offline`).catch(() => {
3667
3680
  });
@@ -4612,8 +4625,31 @@ async function runAgent(options) {
4612
4625
  console.log();
4613
4626
  }
4614
4627
  }
4628
+ let detectedRepoId;
4629
+ try {
4630
+ const remoteUrl = (0, import_node_child_process2.execSync)("git remote get-url origin 2>/dev/null", {
4631
+ cwd: workingDir,
4632
+ encoding: "utf8",
4633
+ timeout: 5e3
4634
+ }).trim();
4635
+ const cvHubMatch = remoteUrl.match(
4636
+ /git\.hub\.controlvector\.io[:/]([^/]+)\/([^/.]+)/
4637
+ );
4638
+ if (cvHubMatch) {
4639
+ const [, repoOwner, repoSlug] = cvHubMatch;
4640
+ try {
4641
+ const repoData = await resolveRepoId(creds, repoOwner, repoSlug);
4642
+ if (repoData?.id) {
4643
+ detectedRepoId = repoData.id;
4644
+ console.log(source_default.gray(` Repo: ${repoOwner}/${repoSlug}`));
4645
+ }
4646
+ } catch {
4647
+ }
4648
+ }
4649
+ } catch {
4650
+ }
4615
4651
  const executor = await withRetry(
4616
- () => registerExecutor(creds, machineName, workingDir),
4652
+ () => registerExecutor(creds, machineName, workingDir, detectedRepoId),
4617
4653
  "Executor registration"
4618
4654
  );
4619
4655
  const mode = options.autoApprove ? "auto-approve" : "relay";
@@ -5167,7 +5203,7 @@ function statusCommand() {
5167
5203
 
5168
5204
  // src/index.ts
5169
5205
  var program2 = new Command();
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");
5206
+ program2.name("cva").description("CV-Hub Agent \u2014 bridges Claude Code with CV-Hub task dispatch").version(true ? "1.3.0" : "1.1.0");
5171
5207
  program2.addCommand(agentCommand());
5172
5208
  program2.addCommand(authCommand());
5173
5209
  program2.addCommand(remoteCommand());