@cortexkit/aft-opencode 0.51.1 → 0.51.2

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 +57 -17
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -8532,6 +8532,13 @@ class BridgeTransportUnavailableError extends Error {
8532
8532
  this.name = "BridgeTransportUnavailableError";
8533
8533
  }
8534
8534
  }
8535
+
8536
+ class BridgeTransportUnknownOutcomeError extends BridgeTransportUnavailableError {
8537
+ constructor(message, options) {
8538
+ super(message, options);
8539
+ this.name = "BridgeTransportUnknownOutcomeError";
8540
+ }
8541
+ }
8535
8542
  function isBridgeTransportTimeout(err) {
8536
8543
  return err instanceof Error && err.code === "transport_timeout";
8537
8544
  }
@@ -8685,7 +8692,7 @@ class BinaryBridge {
8685
8692
  this.clearRestartResetTimer();
8686
8693
  this.configured = false;
8687
8694
  this.outstandingBackgroundTaskIds.clear();
8688
- this.rejectAllPending(error2);
8695
+ this.rejectAllPending(error2 instanceof BridgeTransportUnknownOutcomeError ? error2 : new BridgeTransportUnknownOutcomeError(error2.message, { cause: error2 }));
8689
8696
  }
8690
8697
  hasPendingRequests() {
8691
8698
  return this.pending.size > 0;
@@ -8808,6 +8815,12 @@ class BinaryBridge {
8808
8815
  if (!this.configured) {
8809
8816
  if (command !== "configure" && command !== "version") {
8810
8817
  if (!this._configurePromise) {
8818
+ const configuringChild = this.process;
8819
+ const requireConfiguringChild = () => {
8820
+ if (this.process !== configuringChild) {
8821
+ throw new BridgeTransportUnavailableError(`${this.errorPrefix} Bridge process changed during configure; retry on replacement`);
8822
+ }
8823
+ };
8811
8824
  const sessionIdForConfigure = typeof params.session_id === "string" ? params.session_id : undefined;
8812
8825
  this._configurePromise = (async () => {
8813
8826
  try {
@@ -8816,11 +8829,14 @@ class BinaryBridge {
8816
8829
  ...this.configOverrides,
8817
8830
  ...sessionIdForConfigure ? { session_id: sessionIdForConfigure } : {}
8818
8831
  }, implicitTransportOptions);
8832
+ requireConfiguringChild();
8819
8833
  if (configResult.success === false) {
8820
8834
  throw new Error(`${this.errorPrefix} Configure failed: ${configResult.message ?? "unknown error"}`);
8821
8835
  }
8822
8836
  await this.deliverConfigureWarnings(configResult, params, options);
8837
+ requireConfiguringChild();
8823
8838
  await this.checkVersion(implicitTransportOptions);
8839
+ requireConfiguringChild();
8824
8840
  if (!this.isAlive()) {
8825
8841
  throw new BridgeTransportUnavailableError(`${this.errorPrefix} Bridge died during version check. Check logs: ${this.getLogFilePathVia()}`);
8826
8842
  }
@@ -8899,19 +8915,26 @@ class BinaryBridge {
8899
8915
  return;
8900
8916
  }
8901
8917
  requestSentAt = Date.now();
8902
- child.stdin.write(line, (err) => {
8903
- if (err) {
8904
- const error2 = new BridgeTransportUnavailableError(`${this.errorPrefix} Failed to write to stdin: ${err.message}`, { cause: err });
8905
- const entry = this.pending.get(id);
8906
- if (entry) {
8907
- this.pending.delete(id);
8908
- clearTimeout(entry.timer);
8909
- entry.reject(error2);
8910
- }
8911
- if (this.process === child)
8912
- this.invalidateTransportProcess(error2);
8918
+ const handleWriteFailure = (cause) => {
8919
+ const writeError = cause instanceof Error ? cause : new Error(String(cause));
8920
+ const error2 = new BridgeTransportUnknownOutcomeError(`${this.errorPrefix} Failed to write to stdin: ${writeError.message}`, { cause: writeError });
8921
+ const entry = this.pending.get(id);
8922
+ if (entry) {
8923
+ this.pending.delete(id);
8924
+ clearTimeout(entry.timer);
8925
+ entry.reject(error2);
8913
8926
  }
8914
- });
8927
+ if (this.process === child)
8928
+ this.invalidateTransportProcess(error2);
8929
+ };
8930
+ try {
8931
+ child.stdin.write(line, (err) => {
8932
+ if (err)
8933
+ handleWriteFailure(err);
8934
+ });
8935
+ } catch (err) {
8936
+ handleWriteFailure(err);
8937
+ }
8915
8938
  });
8916
8939
  if (command === "configure" && response.success === true && options?.markConfiguredOnSuccess !== false) {
8917
8940
  this.configured = true;
@@ -9126,9 +9149,13 @@ class BinaryBridge {
9126
9149
  const currentChild = child;
9127
9150
  const stdoutDecoder = new StringDecoder("utf8");
9128
9151
  child.stdout?.on("data", (chunk) => {
9152
+ if (this.process !== currentChild)
9153
+ return;
9129
9154
  this.onStdoutData(stdoutDecoder.write(chunk));
9130
9155
  });
9131
9156
  child.stdout?.on("end", () => {
9157
+ if (this.process !== currentChild)
9158
+ return;
9132
9159
  const remaining = stdoutDecoder.end();
9133
9160
  if (remaining)
9134
9161
  this.onStdoutData(remaining);
@@ -9136,9 +9163,13 @@ class BinaryBridge {
9136
9163
  });
9137
9164
  const stderrDecoder = new StringDecoder("utf8");
9138
9165
  child.stderr?.on("data", (chunk) => {
9166
+ if (this.process !== currentChild)
9167
+ return;
9139
9168
  this.onStderrData(stderrDecoder.write(chunk));
9140
9169
  });
9141
9170
  child.stderr?.on("end", () => {
9171
+ if (this.process !== currentChild)
9172
+ return;
9142
9173
  const remaining = stderrDecoder.end();
9143
9174
  if (remaining)
9144
9175
  this.onStderrData(remaining);
@@ -9161,7 +9192,7 @@ class BinaryBridge {
9161
9192
  this.process = null;
9162
9193
  this.configured = false;
9163
9194
  this.clearRestartResetTimer();
9164
- this.rejectAllPending(new BridgeTransportUnavailableError(`${this.errorPrefix} Binary killed by ${signal}`));
9195
+ this.rejectAllPending(new BridgeTransportUnknownOutcomeError(`${this.errorPrefix} Binary killed by ${signal}`));
9165
9196
  return;
9166
9197
  }
9167
9198
  this.handleCrash();
@@ -9339,7 +9370,7 @@ class BinaryBridge {
9339
9370
  handleTimeout(triggeringSessionId) {
9340
9371
  this.consecutiveRequestTimeouts = 0;
9341
9372
  this.spawnedBinaryFingerprint = null;
9342
- this.rejectAllPending(new Error(`${this.errorPrefix} bridge killed during sibling timeout — request aborted`));
9373
+ this.rejectAllPending(new BridgeTransportUnknownOutcomeError(`${this.errorPrefix} bridge killed during sibling timeout — request aborted`));
9343
9374
  this.outstandingBackgroundTaskIds.clear();
9344
9375
  if (this.process) {
9345
9376
  this.process.kill("SIGKILL");
@@ -9376,7 +9407,7 @@ class BinaryBridge {
9376
9407
  if (tail) {
9377
9408
  this.errorVia(`Binary crashed (restarts: ${this._restartCount})${cause ? `: ${cause.message}` : ""}.${tail}`);
9378
9409
  }
9379
- this.rejectAllPending(new BridgeTransportUnavailableError(`${this.errorPrefix} Binary crashed (restarts: ${this._restartCount})${cause ? `: ${cause.message}` : ""} (see ${this.getLogFilePathVia()})`, { cause }));
9410
+ this.rejectAllPending(new BridgeTransportUnknownOutcomeError(`${this.errorPrefix} Binary crashed (restarts: ${this._restartCount})${cause ? `: ${cause.message}` : ""} (see ${this.getLogFilePathVia()})`, { cause }));
9380
9411
  if (this._retiringDueToBinaryChange) {
9381
9412
  this.logVia("Binary exited while retiring after an on-disk update; skipping auto-restart");
9382
9413
  return;
@@ -13969,6 +14000,7 @@ function toolErrorFromResponse(command, response) {
13969
14000
  }
13970
14001
  var BASH_TRANSPORT_DISPOSITION = "The transport to the AFT daemon was interrupted; no background task was created for this command and no task ID exists. Re-run the command. Do not poll bash_status for it.";
13971
14002
  var SUBC_MODULE_RESTART_DISPOSITION = "The AFT daemon module restarted while this call was in flight, so its outcome is UNKNOWN: it may or may not have executed. Verify actual state before re-running, and never blind-retry a mutation.";
14003
+ var BRIDGE_TRANSPORT_UNKNOWN_OUTCOME_DISPOSITION = "The standalone AFT transport failed after this call may have been sent, so its outcome is UNKNOWN: it may or may not have executed. Verify actual state before re-running, and never blind-retry a mutation.";
13972
14004
  function isRouteGoodbyeError(error2) {
13973
14005
  if (!(error2 instanceof SubcError))
13974
14006
  return false;
@@ -13991,6 +14023,8 @@ function isBashTransportDeadError(error2) {
13991
14023
  if (!(error2 instanceof Error) || hasEngineResponse(error2) || isRouteGoodbyeError(error2)) {
13992
14024
  return false;
13993
14025
  }
14026
+ if (error2 instanceof BridgeTransportUnknownOutcomeError)
14027
+ return false;
13994
14028
  return error2 instanceof BridgeTransportUnavailableError || error2 instanceof SubcTransportShuttingDownError || isConsumerReconnectTransient(error2) || error2 instanceof StaleRouteHandleError || error2 instanceof SubcRootGenerationExpiredError || error2 instanceof SubcRootReapedError;
13995
14029
  }
13996
14030
  function isTransportClassError(error2) {
@@ -13999,6 +14033,12 @@ function isTransportClassError(error2) {
13999
14033
  function adaptToolError(command, error2) {
14000
14034
  if (!(error2 instanceof Error))
14001
14035
  return error2;
14036
+ if (error2 instanceof BridgeTransportUnknownOutcomeError) {
14037
+ if (error2.message.includes(BRIDGE_TRANSPORT_UNKNOWN_OUTCOME_DISPOSITION))
14038
+ return error2;
14039
+ error2.message = error2.message ? `${error2.message} ${BRIDGE_TRANSPORT_UNKNOWN_OUTCOME_DISPOSITION}` : BRIDGE_TRANSPORT_UNKNOWN_OUTCOME_DISPOSITION;
14040
+ return error2;
14041
+ }
14002
14042
  if (isRouteGoodbyeError(error2)) {
14003
14043
  if (error2.message.includes(SUBC_MODULE_RESTART_DISPOSITION))
14004
14044
  return error2;
@@ -40206,7 +40246,7 @@ var PLUGIN_VERSION = (() => {
40206
40246
  return "0.0.0";
40207
40247
  }
40208
40248
  })();
40209
- var ANNOUNCEMENT_VERSION = "0.51.1";
40249
+ var ANNOUNCEMENT_VERSION = "0.51.2";
40210
40250
  var ANNOUNCEMENT_FEATURES = [
40211
40251
  "Callgraph stays consistent under load: edits arriving mid-rebuild can no longer be silently lost from navigation results.",
40212
40252
  "aft_zoom handles real-world .jsonc: files with comment banners above the opening brace now resolve, and not-found errors point at the segment that actually failed (thanks @iceteaSA).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft-opencode",
3
- "version": "0.51.1",
3
+ "version": "0.51.2",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Agent File Tools (AFT) — tree-sitter and lsp powered code analysis",
6
6
  "main": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@clack/prompts": "^1.6.0",
37
- "@cortexkit/aft-bridge": "0.51.1",
37
+ "@cortexkit/aft-bridge": "0.51.2",
38
38
  "@opentui/core": "0.4.3",
39
39
  "@opentui/solid": "0.4.3",
40
40
  "comment-json": "^4.6.2",
@@ -43,12 +43,12 @@
43
43
  "zod": "^4.4.3"
44
44
  },
45
45
  "optionalDependencies": {
46
- "@cortexkit/aft-darwin-arm64": "0.51.1",
47
- "@cortexkit/aft-darwin-x64": "0.51.1",
48
- "@cortexkit/aft-linux-arm64": "0.51.1",
49
- "@cortexkit/aft-linux-x64": "0.51.1",
50
- "@cortexkit/aft-win32-arm64": "0.51.1",
51
- "@cortexkit/aft-win32-x64": "0.51.1"
46
+ "@cortexkit/aft-darwin-arm64": "0.51.2",
47
+ "@cortexkit/aft-darwin-x64": "0.51.2",
48
+ "@cortexkit/aft-linux-arm64": "0.51.2",
49
+ "@cortexkit/aft-linux-x64": "0.51.2",
50
+ "@cortexkit/aft-win32-arm64": "0.51.2",
51
+ "@cortexkit/aft-win32-x64": "0.51.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@opencode-ai/plugin": "^1.17.11",