@cortexkit/aft 0.51.0 → 0.51.1

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 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -942,6 +942,20 @@ var init_bridge = __esm(() => {
942
942
  isAlive() {
943
943
  return this.process !== null && this.process.exitCode === null && !this.process.killed;
944
944
  }
945
+ invalidateTransportProcess(error2) {
946
+ const proc = this.process;
947
+ if (!proc)
948
+ return;
949
+ this.process = null;
950
+ this.spawnedBinaryFingerprint = null;
951
+ if (proc.exitCode === null && !proc.killed) {
952
+ proc.kill("SIGKILL");
953
+ }
954
+ this.clearRestartResetTimer();
955
+ this.configured = false;
956
+ this.outstandingBackgroundTaskIds.clear();
957
+ this.rejectAllPending(error2);
958
+ }
945
959
  hasPendingRequests() {
946
960
  return this.pending.size > 0;
947
961
  }
@@ -1107,6 +1121,7 @@ var init_bridge = __esm(() => {
1107
1121
  `;
1108
1122
  const keepBridgeOnTimeout = passive || options?.keepBridgeOnTimeout === true;
1109
1123
  let requestSentAt = Date.now();
1124
+ const child = this.process;
1110
1125
  const response = await new Promise((resolve2, reject) => {
1111
1126
  const timer = setTimeout(() => {
1112
1127
  const entry = this.pending.get(id);
@@ -1143,21 +1158,27 @@ var init_bridge = __esm(() => {
1143
1158
  this.handleTimeout(requestSessionId);
1144
1159
  }, effectiveTimeoutMs);
1145
1160
  this.pending.set(id, { resolve: resolve2, reject, timer, onProgress: options?.onProgress, command });
1146
- if (!this.process?.stdin?.writable) {
1161
+ if (!child?.stdin?.writable) {
1147
1162
  this.pending.delete(id);
1148
1163
  clearTimeout(timer);
1149
- reject(new BridgeTransportUnavailableError(`${this.errorPrefix} stdin not writable for command "${command}"`));
1164
+ const error2 = new BridgeTransportUnavailableError(`${this.errorPrefix} stdin not writable for command "${command}"`);
1165
+ reject(error2);
1166
+ if (this.process === child)
1167
+ this.invalidateTransportProcess(error2);
1150
1168
  return;
1151
1169
  }
1152
1170
  requestSentAt = Date.now();
1153
- this.process.stdin.write(line, (err) => {
1171
+ child.stdin.write(line, (err) => {
1154
1172
  if (err) {
1173
+ const error2 = new BridgeTransportUnavailableError(`${this.errorPrefix} Failed to write to stdin: ${err.message}`, { cause: err });
1155
1174
  const entry = this.pending.get(id);
1156
1175
  if (entry) {
1157
1176
  this.pending.delete(id);
1158
1177
  clearTimeout(entry.timer);
1159
- entry.reject(new BridgeTransportUnavailableError(`${this.errorPrefix} Failed to write to stdin: ${err.message}`, { cause: err }));
1178
+ entry.reject(error2);
1160
1179
  }
1180
+ if (this.process === child)
1181
+ this.invalidateTransportProcess(error2);
1161
1182
  }
1162
1183
  });
1163
1184
  });
@@ -1317,8 +1338,11 @@ var init_bridge = __esm(() => {
1317
1338
  });
1318
1339
  }
1319
1340
  ensureSpawned(triggeringSessionId) {
1320
- if (this.isAlive())
1341
+ if (this.isAlive() && this.process?.stdin?.writable)
1321
1342
  return;
1343
+ if (this.process !== null) {
1344
+ this.invalidateTransportProcess(new BridgeTransportUnavailableError(`${this.errorPrefix} Child stdin is not writable`));
1345
+ }
1322
1346
  this.spawnProcess(triggeringSessionId);
1323
1347
  }
1324
1348
  spawnProcess(triggeringSessionId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft",
3
- "version": "0.51.0",
3
+ "version": "0.51.1",
4
4
  "type": "module",
5
5
  "description": "Unified CLI for Agent File Tools (AFT) — setup, doctor, and diagnostics across supported agent harnesses (OpenCode, Pi)",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@clack/prompts": "^1.6.0",
27
- "@cortexkit/aft-bridge": "0.51.0",
27
+ "@cortexkit/aft-bridge": "0.51.1",
28
28
  "comment-json": "^4.6.2"
29
29
  },
30
30
  "devDependencies": {