opencara 0.23.6 → 0.23.7

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 (2) hide show
  1. package/dist/index.js +38 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5663,7 +5663,7 @@ function sleep2(ms, signal) {
5663
5663
  async function startAgent(agentId, platformUrl, agentInfo, reviewDeps, consumptionDeps, options) {
5664
5664
  const client = new ApiClient(platformUrl, {
5665
5665
  authToken: options?.authToken,
5666
- cliVersion: "0.23.6",
5666
+ cliVersion: "0.23.7",
5667
5667
  versionOverride: options?.versionOverride,
5668
5668
  onTokenRefresh: options?.onTokenRefresh
5669
5669
  });
@@ -5770,6 +5770,8 @@ async function batchPollLoop(client, agentStates, options) {
5770
5770
  let consecutiveAuthErrors = 0;
5771
5771
  let consecutiveErrors = 0;
5772
5772
  let pollCycleCount = 0;
5773
+ const busyAgents = /* @__PURE__ */ new Set();
5774
+ const inflightPromises = /* @__PURE__ */ new Set();
5773
5775
  while (!signal?.aborted) {
5774
5776
  if (accessibleRepos && githubToken && recheckInterval > 0 && pollCycleCount > 0 && pollCycleCount % recheckInterval === 0) {
5775
5777
  const allRepos = extractRepoUrls(
@@ -5826,13 +5828,17 @@ async function batchPollLoop(client, agentStates, options) {
5826
5828
  break;
5827
5829
  }
5828
5830
  try {
5829
- const descriptors = agentStates.map((s) => s.descriptor);
5831
+ const availableStates = agentStates.filter((s) => !busyAgents.has(s));
5832
+ if (availableStates.length === 0) {
5833
+ await sleep2(pollIntervalMs, signal);
5834
+ continue;
5835
+ }
5836
+ const descriptors = availableStates.map((s) => s.descriptor);
5830
5837
  const request = buildBatchPollRequest(descriptors);
5831
5838
  const response = await client.post("/api/tasks/poll/batch", request);
5832
5839
  consecutiveAuthErrors = 0;
5833
5840
  consecutiveErrors = 0;
5834
- const handlePromises = [];
5835
- for (const state of agentStates) {
5841
+ for (const state of availableStates) {
5836
5842
  const agentName = state.descriptor.name;
5837
5843
  const pollResponse = response.assignments[agentName];
5838
5844
  if (!pollResponse || pollResponse.tasks.length === 0) continue;
@@ -5846,8 +5852,9 @@ async function batchPollLoop(client, agentStates, options) {
5846
5852
  );
5847
5853
  const task = eligible[0];
5848
5854
  if (!task) continue;
5849
- handlePromises.push(
5850
- (async () => {
5855
+ busyAgents.add(state);
5856
+ const p = (async () => {
5857
+ try {
5851
5858
  const result = await handleTask(
5852
5859
  client,
5853
5860
  state.descriptor.agentId,
@@ -5876,28 +5883,27 @@ async function batchPollLoop(client, agentStates, options) {
5876
5883
  );
5877
5884
  }
5878
5885
  }
5879
- })()
5880
- );
5881
- }
5882
- if (handlePromises.length > 0) {
5883
- const results = await Promise.allSettled(handlePromises);
5884
- for (const r of results) {
5885
- if (r.status === "rejected") {
5886
- logError(`${icons.error} Task handler failed: ${r.reason}`);
5886
+ } catch (err) {
5887
+ logError(`${icons.error} Task handler failed: ${err.message}`);
5887
5888
  consecutiveErrors++;
5889
+ } finally {
5890
+ busyAgents.delete(state);
5891
+ if (state.cleanupTracker) {
5892
+ try {
5893
+ const swept = await state.cleanupTracker.sweep(cleanupWorktree);
5894
+ if (swept > 0) {
5895
+ state.logger.log(
5896
+ `${icons.info} Cleaned up ${swept} stale codebase director${swept === 1 ? "y" : "ies"}`
5897
+ );
5898
+ }
5899
+ } catch {
5900
+ }
5901
+ }
5888
5902
  }
5889
- }
5903
+ })();
5904
+ inflightPromises.add(p);
5905
+ void p.finally(() => inflightPromises.delete(p));
5890
5906
  }
5891
- await Promise.allSettled(
5892
- agentStates.filter((state) => state.cleanupTracker).map(async (state) => {
5893
- const swept = await state.cleanupTracker.sweep(cleanupWorktree);
5894
- if (swept > 0) {
5895
- state.logger.log(
5896
- `${icons.info} Cleaned up ${swept} stale codebase director${swept === 1 ? "y" : "ies"}`
5897
- );
5898
- }
5899
- })
5900
- );
5901
5907
  } catch (err) {
5902
5908
  if (signal?.aborted) break;
5903
5909
  if (err instanceof UpgradeRequiredError) {
@@ -5944,12 +5950,16 @@ async function batchPollLoop(client, agentStates, options) {
5944
5950
  }
5945
5951
  await sleep2(pollIntervalMs, signal);
5946
5952
  }
5953
+ if (inflightPromises.size > 0) {
5954
+ log(`${icons.info} Waiting for ${inflightPromises.size} in-flight task(s) to complete...`);
5955
+ await Promise.allSettled([...inflightPromises]);
5956
+ }
5947
5957
  }
5948
5958
  async function startBatchAgents(config, agents, pollIntervalMs, oauthToken, options) {
5949
5959
  const { versionOverride, verbose, instancesOverride, agentOwner, userOrgs } = options;
5950
5960
  const client = new ApiClient(config.platformUrl, {
5951
5961
  authToken: oauthToken,
5952
- cliVersion: "0.23.6",
5962
+ cliVersion: "0.23.7",
5953
5963
  versionOverride,
5954
5964
  onTokenRefresh: () => getValidToken(config.platformUrl, { configPath: config.authFile })
5955
5965
  });
@@ -6292,7 +6302,7 @@ agentCommand.command("start").description("Start agents in polling mode").option
6292
6302
  }
6293
6303
  config = loadConfig();
6294
6304
  }
6295
- console.log(formatVersionBanner("0.23.6", "9696efa"));
6305
+ console.log(formatVersionBanner("0.23.7", "eb8ff83"));
6296
6306
  if (config.agents && config.agents.length > 0) {
6297
6307
  const toolEntries = config.agents.map((a) => ({
6298
6308
  tool: a.tool,
@@ -7115,7 +7125,7 @@ var statusCommand = new Command4("status").description("Show agent config, conne
7115
7125
  });
7116
7126
 
7117
7127
  // src/index.ts
7118
- var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.23.6"} (${"9696efa"})`);
7128
+ var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.23.7"} (${"eb8ff83"})`);
7119
7129
  program.addCommand(agentCommand);
7120
7130
  program.addCommand(authCommand());
7121
7131
  program.addCommand(dedupCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencara",
3
- "version": "0.23.6",
3
+ "version": "0.23.7",
4
4
  "description": "Distributed AI code review agent — poll, review, and submit PR reviews using your own AI tools",
5
5
  "type": "module",
6
6
  "license": "MIT",