replicas-engine 0.1.579 → 0.1.580

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/src/index.js CHANGED
@@ -10896,7 +10896,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
10896
10896
  var MIN_CODEX_CLI_VERSION = "0.144.6";
10897
10897
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
10898
10898
  var codexCliVersionEnsured = null;
10899
- var ENGINE_PACKAGE_VERSION = "0.1.579";
10899
+ var ENGINE_PACKAGE_VERSION = "0.1.580";
10900
10900
  var INITIALIZE_METHOD = "initialize";
10901
10901
  var INITIALIZED_NOTIFICATION = "initialized";
10902
10902
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -13822,6 +13822,7 @@ var OpencodeManager = class extends CodingAgentManager {
13822
13822
  nonAssistantMessageIds = /* @__PURE__ */ new Set();
13823
13823
  activeLinearForwarder = null;
13824
13824
  forwardedLinearPartKeys = /* @__PURE__ */ new Set();
13825
+ handledAccountRateLimit = false;
13825
13826
  modelVariants = /* @__PURE__ */ new Map();
13826
13827
  handledPermissionRequestIds = /* @__PURE__ */ new Set();
13827
13828
  pendingPermissionRequestIds = /* @__PURE__ */ new Set();
@@ -13844,18 +13845,20 @@ var OpencodeManager = class extends CodingAgentManager {
13844
13845
  return this.historyFile;
13845
13846
  }
13846
13847
  async interruptActiveTurn() {
13847
- this.activeAbortController?.abort();
13848
- if (this.client && this.sessionId) {
13849
- try {
13850
- await this.client.session.abort(
13851
- { sessionID: this.sessionId, directory: this.workingDirectory },
13852
- { throwOnError: true }
13853
- );
13854
- } catch (error) {
13855
- console.error("[OpencodeManager] Failed to abort Opencode session:", error);
13856
- }
13848
+ try {
13849
+ await this.abortActiveTurn();
13850
+ } catch (error) {
13851
+ console.error("[OpencodeManager] Failed to abort Opencode session:", error);
13857
13852
  }
13858
13853
  }
13854
+ async abortActiveTurn() {
13855
+ this.activeAbortController?.abort();
13856
+ if (!this.client || !this.sessionId) return;
13857
+ await this.client.session.abort(
13858
+ { sessionID: this.sessionId, directory: this.workingDirectory },
13859
+ { throwOnError: true }
13860
+ );
13861
+ }
13859
13862
  async getHistory() {
13860
13863
  await this.historyFile.flush();
13861
13864
  const history = await this.historyFile.load();
@@ -14017,6 +14020,7 @@ var OpencodeManager = class extends CodingAgentManager {
14017
14020
  const controller = new AbortController();
14018
14021
  const linearSessionId = ENGINE_ENV.REPLICAS_LINEAR_SESSION_ID;
14019
14022
  const linearForwarder = new LinearEventForwarder(linearSessionId);
14023
+ this.handledAccountRateLimit = false;
14020
14024
  this.activeAbortController = controller;
14021
14025
  this.activeLinearForwarder = linearForwarder;
14022
14026
  this.forwardedLinearPartKeys.clear();
@@ -14104,6 +14108,11 @@ var OpencodeManager = class extends CodingAgentManager {
14104
14108
  return;
14105
14109
  }
14106
14110
  if (event.type === "message.updated") this.recordOpencodeMessageRole(payload);
14111
+ if (event.type === "session.status") {
14112
+ this.handleAccountRateLimit(payload).catch((error) => {
14113
+ console.error("[OpencodeManager] Failed to stop account-rate-limited turn:", error);
14114
+ });
14115
+ }
14107
14116
  if (event.type === "session.next.tool.input.ended") {
14108
14117
  const callId = typeof payload.callID === "string" ? payload.callID : void 0;
14109
14118
  if (callId && typeof payload.text === "string") {
@@ -14123,6 +14132,15 @@ var OpencodeManager = class extends CodingAgentManager {
14123
14132
  if (this.recordOpencodeNextPart(event.type, payload)) return;
14124
14133
  this.recordHistoryEvent(`opencode-${event.type}`, payload, this.historyFile);
14125
14134
  }
14135
+ async handleAccountRateLimit(payload) {
14136
+ const status = isRecord4(payload.status) ? payload.status : null;
14137
+ const action = isRecord4(status?.action) ? status.action : null;
14138
+ if (status?.type !== "retry" || action?.reason !== "account_rate_limit" || this.handledAccountRateLimit) return;
14139
+ this.handledAccountRateLimit = true;
14140
+ const message = typeof status.message === "string" ? status.message : typeof action.message === "string" ? action.message : "OpenCode Go usage limit reached.";
14141
+ this.recordHistoryEvent("opencode-error", { message, code: "account_rate_limit" }, this.historyFile);
14142
+ await this.abortActiveTurn();
14143
+ }
14126
14144
  async respondToOpencodePermission(type, payload) {
14127
14145
  if (!this.client) return;
14128
14146
  const requestId = typeof payload.id === "string" ? payload.id : void 0;
@@ -14221,13 +14239,7 @@ var OpencodeManager = class extends CodingAgentManager {
14221
14239
  historyFile: this.historyFile,
14222
14240
  recordHistoryEvent: this.recordHistoryEvent.bind(this)
14223
14241
  });
14224
- this.activeAbortController?.abort();
14225
- if (this.client && this.sessionId) {
14226
- await this.client.session.abort(
14227
- { sessionID: this.sessionId, directory: this.workingDirectory },
14228
- { throwOnError: true }
14229
- );
14230
- }
14242
+ await this.abortActiveTurn();
14231
14243
  this.handledToolCallIds.add(toolUseId);
14232
14244
  } finally {
14233
14245
  this.pendingToolCallIds.delete(toolUseId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.579",
3
+ "version": "0.1.580",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",