opencara 0.23.14 → 0.24.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.
Files changed (2) hide show
  1. package/dist/index.js +38 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4829,6 +4829,7 @@ var MAX_TASK_ERROR_ATTEMPTS = 3;
4829
4829
  var WEIGHT_PENALTY_FACTOR = 0.5;
4830
4830
  var MIN_DISPATCH_WEIGHT = 0.1;
4831
4831
  var WEIGHT_RECOVERY = 0.25;
4832
+ var WEIGHT_RECOVERY_DURATION_MS = 30 * 60 * 1e3;
4832
4833
  async function pollLoop(client, agentId, reviewDeps, consumptionDeps, agentInfo, logger, agentSession, options) {
4833
4834
  const {
4834
4835
  pollIntervalMs,
@@ -5700,7 +5701,7 @@ function sleep2(ms, signal) {
5700
5701
  async function startAgent(agentId, platformUrl, agentInfo, reviewDeps, consumptionDeps, options) {
5701
5702
  const client = new ApiClient(platformUrl, {
5702
5703
  authToken: options?.authToken,
5703
- cliVersion: "0.23.14",
5704
+ cliVersion: "0.24.0",
5704
5705
  versionOverride: options?.versionOverride,
5705
5706
  onTokenRefresh: options?.onTokenRefresh
5706
5707
  });
@@ -5875,13 +5876,31 @@ async function batchPollLoop(client, agentStates, options) {
5875
5876
  const response = await client.post("/api/tasks/poll/batch", request);
5876
5877
  consecutiveAuthErrors = 0;
5877
5878
  consecutiveErrors = 0;
5879
+ const now = Date.now();
5880
+ for (const s of availableStates) {
5881
+ if (s.weight < 1) {
5882
+ const elapsed = now - s.lastWeightUpdateAt;
5883
+ const recovered = Math.min(1, s.weight + elapsed / WEIGHT_RECOVERY_DURATION_MS);
5884
+ if (recovered > s.weight) {
5885
+ s.weight = recovered;
5886
+ if (s.weight >= MIN_DISPATCH_WEIGHT && s.pausedLogged) {
5887
+ s.logger.log(
5888
+ `${icons.info} Agent resumed (weight ${s.weight.toFixed(2)} \u2265 ${MIN_DISPATCH_WEIGHT})`
5889
+ );
5890
+ s.pausedLogged = false;
5891
+ }
5892
+ }
5893
+ }
5894
+ s.lastWeightUpdateAt = now;
5895
+ }
5878
5896
  const eligibleStates = availableStates.filter((s) => s.weight >= MIN_DISPATCH_WEIGHT);
5879
5897
  const dispatchOrder = eligibleStates.map((s) => ({ state: s, score: s.weight * Math.random() })).sort((a, b) => b.score - a.score).map((e) => e.state);
5880
5898
  for (const s of availableStates) {
5881
- if (s.weight < MIN_DISPATCH_WEIGHT) {
5899
+ if (s.weight < MIN_DISPATCH_WEIGHT && !s.pausedLogged) {
5882
5900
  s.logger.logWarn(
5883
- `${icons.warn} Agent paused (weight ${s.weight.toFixed(2)} < ${MIN_DISPATCH_WEIGHT})`
5901
+ `${icons.warn} Agent paused (weight ${s.weight.toFixed(2)} < ${MIN_DISPATCH_WEIGHT}), recovering over ${WEIGHT_RECOVERY_DURATION_MS / 6e4}m`
5884
5902
  );
5903
+ s.pausedLogged = true;
5885
5904
  }
5886
5905
  }
5887
5906
  for (const state of dispatchOrder) {
@@ -5932,6 +5951,7 @@ async function batchPollLoop(client, agentStates, options) {
5932
5951
  );
5933
5952
  }
5934
5953
  state.weight = Math.max(0, state.weight * WEIGHT_PENALTY_FACTOR);
5954
+ state.lastWeightUpdateAt = Date.now();
5935
5955
  state.logger.logWarn(
5936
5956
  `${icons.warn} Weight reduced to ${state.weight.toFixed(2)} after diff fetch failure`
5937
5957
  );
@@ -5944,11 +5964,19 @@ async function batchPollLoop(client, agentStates, options) {
5944
5964
  );
5945
5965
  }
5946
5966
  state.weight = Math.max(0, state.weight * WEIGHT_PENALTY_FACTOR);
5967
+ state.lastWeightUpdateAt = Date.now();
5947
5968
  state.logger.logWarn(
5948
5969
  `${icons.warn} Weight reduced to ${state.weight.toFixed(2)} after tool error`
5949
5970
  );
5950
5971
  } else {
5951
5972
  state.weight = Math.min(1, state.weight + WEIGHT_RECOVERY);
5973
+ state.lastWeightUpdateAt = Date.now();
5974
+ if (state.weight >= MIN_DISPATCH_WEIGHT && state.pausedLogged) {
5975
+ state.logger.log(
5976
+ `${icons.info} Agent resumed (weight ${state.weight.toFixed(2)} \u2265 ${MIN_DISPATCH_WEIGHT})`
5977
+ );
5978
+ state.pausedLogged = false;
5979
+ }
5952
5980
  }
5953
5981
  } catch (err) {
5954
5982
  logError(`${icons.error} Task handler failed: ${err.message}`);
@@ -5961,6 +5989,7 @@ async function batchPollLoop(client, agentStates, options) {
5961
5989
  );
5962
5990
  }
5963
5991
  state.weight = Math.max(0, state.weight * WEIGHT_PENALTY_FACTOR);
5992
+ state.lastWeightUpdateAt = Date.now();
5964
5993
  state.logger.logWarn(
5965
5994
  `${icons.warn} Weight reduced to ${state.weight.toFixed(2)} after task error`
5966
5995
  );
@@ -6037,7 +6066,7 @@ async function startBatchAgents(config, agents, pollIntervalMs, oauthToken, opti
6037
6066
  const { versionOverride, verbose, instancesOverride, agentOwner, userOrgs } = options;
6038
6067
  const client = new ApiClient(config.platformUrl, {
6039
6068
  authToken: oauthToken,
6040
- cliVersion: "0.23.14",
6069
+ cliVersion: "0.24.0",
6041
6070
  versionOverride,
6042
6071
  onTokenRefresh: () => getValidToken(config.platformUrl, { configPath: config.authFile })
6043
6072
  });
@@ -6118,7 +6147,9 @@ async function startBatchAgents(config, agents, pollIntervalMs, oauthToken, opti
6118
6147
  verbose,
6119
6148
  diffFailCounts: /* @__PURE__ */ new Map(),
6120
6149
  taskErrorCounts: /* @__PURE__ */ new Map(),
6121
- weight: 1
6150
+ weight: 1,
6151
+ lastWeightUpdateAt: Date.now(),
6152
+ pausedLogged: false
6122
6153
  });
6123
6154
  }
6124
6155
  }
@@ -6384,7 +6415,7 @@ agentCommand.command("start").description("Start agents in polling mode").option
6384
6415
  }
6385
6416
  config = loadConfig();
6386
6417
  }
6387
- console.log(formatVersionBanner("0.23.14", "7dead21"));
6418
+ console.log(formatVersionBanner("0.24.0", "974f6d8"));
6388
6419
  if (config.agents && config.agents.length > 0) {
6389
6420
  const toolEntries = config.agents.map((a) => ({
6390
6421
  tool: a.tool,
@@ -7206,7 +7237,7 @@ var statusCommand = new Command4("status").description("Show agent config, conne
7206
7237
  });
7207
7238
 
7208
7239
  // src/index.ts
7209
- var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.23.14"} (${"7dead21"})`);
7240
+ var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.24.0"} (${"974f6d8"})`);
7210
7241
  program.addCommand(agentCommand);
7211
7242
  program.addCommand(authCommand());
7212
7243
  program.addCommand(dedupCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencara",
3
- "version": "0.23.14",
3
+ "version": "0.24.0",
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",