opencara 0.23.12 → 0.23.13

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 +29 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4825,6 +4825,9 @@ function concatUint8Arrays(chunks, totalLength) {
4825
4825
  return result;
4826
4826
  }
4827
4827
  var MAX_DIFF_FETCH_ATTEMPTS = 3;
4828
+ var WEIGHT_PENALTY_FACTOR = 0.5;
4829
+ var MIN_DISPATCH_WEIGHT = 0.1;
4830
+ var WEIGHT_RECOVERY = 0.25;
4828
4831
  async function pollLoop(client, agentId, reviewDeps, consumptionDeps, agentInfo, logger, agentSession, options) {
4829
4832
  const {
4830
4833
  pollIntervalMs,
@@ -5695,7 +5698,7 @@ function sleep2(ms, signal) {
5695
5698
  async function startAgent(agentId, platformUrl, agentInfo, reviewDeps, consumptionDeps, options) {
5696
5699
  const client = new ApiClient(platformUrl, {
5697
5700
  authToken: options?.authToken,
5698
- cliVersion: "0.23.12",
5701
+ cliVersion: "0.23.13",
5699
5702
  versionOverride: options?.versionOverride,
5700
5703
  onTokenRefresh: options?.onTokenRefresh
5701
5704
  });
@@ -5870,7 +5873,16 @@ async function batchPollLoop(client, agentStates, options) {
5870
5873
  const response = await client.post("/api/tasks/poll/batch", request);
5871
5874
  consecutiveAuthErrors = 0;
5872
5875
  consecutiveErrors = 0;
5873
- for (const state of availableStates) {
5876
+ const eligibleStates = availableStates.filter((s) => s.weight >= MIN_DISPATCH_WEIGHT);
5877
+ const dispatchOrder = eligibleStates.map((s) => ({ state: s, score: s.weight * Math.random() })).sort((a, b) => b.score - a.score).map((e) => e.state);
5878
+ for (const s of availableStates) {
5879
+ if (s.weight < MIN_DISPATCH_WEIGHT) {
5880
+ s.logger.logWarn(
5881
+ `${icons.warn} Agent paused (weight ${s.weight.toFixed(2)} < ${MIN_DISPATCH_WEIGHT})`
5882
+ );
5883
+ }
5884
+ }
5885
+ for (const state of dispatchOrder) {
5874
5886
  const agentName = state.descriptor.name;
5875
5887
  const pollResponse = response.assignments[agentName];
5876
5888
  if (!pollResponse || pollResponse.tasks.length === 0) continue;
@@ -5915,10 +5927,20 @@ async function batchPollLoop(client, agentStates, options) {
5915
5927
  ` Skipping task ${task.task_id} after ${count} diff fetch failures`
5916
5928
  );
5917
5929
  }
5930
+ state.weight = Math.max(0, state.weight * WEIGHT_PENALTY_FACTOR);
5931
+ state.logger.logWarn(
5932
+ `${icons.warn} Weight reduced to ${state.weight.toFixed(2)} after diff fetch failure`
5933
+ );
5934
+ } else {
5935
+ state.weight = Math.min(1, state.weight + WEIGHT_RECOVERY);
5918
5936
  }
5919
5937
  } catch (err) {
5920
5938
  logError(`${icons.error} Task handler failed: ${err.message}`);
5921
5939
  consecutiveErrors++;
5940
+ state.weight = Math.max(0, state.weight * WEIGHT_PENALTY_FACTOR);
5941
+ state.logger.logWarn(
5942
+ `${icons.warn} Weight reduced to ${state.weight.toFixed(2)} after task error`
5943
+ );
5922
5944
  } finally {
5923
5945
  busyAgents.delete(state);
5924
5946
  if (state.cleanupTracker) {
@@ -5992,7 +6014,7 @@ async function startBatchAgents(config, agents, pollIntervalMs, oauthToken, opti
5992
6014
  const { versionOverride, verbose, instancesOverride, agentOwner, userOrgs } = options;
5993
6015
  const client = new ApiClient(config.platformUrl, {
5994
6016
  authToken: oauthToken,
5995
- cliVersion: "0.23.12",
6017
+ cliVersion: "0.23.13",
5996
6018
  versionOverride,
5997
6019
  onTokenRefresh: () => getValidToken(config.platformUrl, { configPath: config.authFile })
5998
6020
  });
@@ -6071,7 +6093,8 @@ async function startBatchAgents(config, agents, pollIntervalMs, oauthToken, opti
6071
6093
  routerRelay,
6072
6094
  cleanupTracker,
6073
6095
  verbose,
6074
- diffFailCounts: /* @__PURE__ */ new Map()
6096
+ diffFailCounts: /* @__PURE__ */ new Map(),
6097
+ weight: 1
6075
6098
  });
6076
6099
  }
6077
6100
  }
@@ -6337,7 +6360,7 @@ agentCommand.command("start").description("Start agents in polling mode").option
6337
6360
  }
6338
6361
  config = loadConfig();
6339
6362
  }
6340
- console.log(formatVersionBanner("0.23.12", "d2879c9"));
6363
+ console.log(formatVersionBanner("0.23.13", "791981e"));
6341
6364
  if (config.agents && config.agents.length > 0) {
6342
6365
  const toolEntries = config.agents.map((a) => ({
6343
6366
  tool: a.tool,
@@ -7159,7 +7182,7 @@ var statusCommand = new Command4("status").description("Show agent config, conne
7159
7182
  });
7160
7183
 
7161
7184
  // src/index.ts
7162
- var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.23.12"} (${"d2879c9"})`);
7185
+ var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.23.13"} (${"791981e"})`);
7163
7186
  program.addCommand(agentCommand);
7164
7187
  program.addCommand(authCommand());
7165
7188
  program.addCommand(dedupCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencara",
3
- "version": "0.23.12",
3
+ "version": "0.23.13",
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",