@cortexkit/aft 0.29.0 → 0.30.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 +45 -14
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -11475,6 +11475,7 @@ var init_bridge = __esm(() => {
11475
11475
  onConfigureWarnings;
11476
11476
  onBashCompletion;
11477
11477
  onBashLongRunning;
11478
+ onBashPatternMatch;
11478
11479
  cachedStatus = null;
11479
11480
  statusListeners = new Set;
11480
11481
  configureWarningClients = new Map;
@@ -11492,6 +11493,7 @@ var init_bridge = __esm(() => {
11492
11493
  this.onConfigureWarnings = options?.onConfigureWarnings;
11493
11494
  this.onBashCompletion = options?.onBashCompletion;
11494
11495
  this.onBashLongRunning = options?.onBashLongRunning;
11496
+ this.onBashPatternMatch = options?.onBashPatternMatch;
11495
11497
  this.errorPrefix = options?.errorPrefix ?? "[aft-bridge]";
11496
11498
  this.logger = options?.logger;
11497
11499
  }
@@ -11984,6 +11986,10 @@ var init_bridge = __esm(() => {
11984
11986
  this.onBashLongRunning?.(response, this);
11985
11987
  continue;
11986
11988
  }
11989
+ if (response.type === "bash_pattern_match") {
11990
+ this.onBashPatternMatch?.(response, this);
11991
+ continue;
11992
+ }
11987
11993
  if (response.type === "configure_warnings") {
11988
11994
  this.handleConfigureWarningsFrame(response).catch((err) => {
11989
11995
  this.warnVia(`configure warning delivery failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -12505,7 +12511,7 @@ async function findBinary(expectedVersion) {
12505
12511
  return syncResult;
12506
12512
  }
12507
12513
  log("Binary not found locally, attempting auto-download...");
12508
- const downloaded = await ensureBinary(expectedVersion);
12514
+ const downloaded = await ensureBinaryForResolver(expectedVersion);
12509
12515
  if (downloaded)
12510
12516
  return downloaded;
12511
12517
  throw new Error([
@@ -12527,10 +12533,12 @@ async function findBinary(expectedVersion) {
12527
12533
  ].join(`
12528
12534
  `));
12529
12535
  }
12536
+ var ensureBinaryForResolver;
12530
12537
  var init_resolver = __esm(() => {
12531
12538
  init_active_logger();
12532
12539
  init_downloader();
12533
12540
  init_platform();
12541
+ ensureBinaryForResolver = ensureBinary;
12534
12542
  });
12535
12543
 
12536
12544
  // ../aft-bridge/dist/migration.js
@@ -12607,7 +12615,7 @@ async function ensureStorageMigrated(opts) {
12607
12615
 
12608
12616
  `);
12609
12617
  } catch {}
12610
- const result = spawnSync5(binaryPath, [
12618
+ const result = spawnSyncForMigration(binaryPath, [
12611
12619
  "migrate-storage",
12612
12620
  "--from",
12613
12621
  legacyRoot,
@@ -12640,7 +12648,7 @@ async function ensureStorageMigrated(opts) {
12640
12648
  async function getMigrationStatus(opts) {
12641
12649
  const newRoot = resolveCortexKitStorageRoot();
12642
12650
  const binaryPath = opts.binaryPath ?? await findBinary();
12643
- const result = spawnSync5(binaryPath, ["migrate-storage", "--status", "--to", newRoot, "--harness", opts.harness], {
12651
+ const result = spawnSyncForMigration(binaryPath, ["migrate-storage", "--status", "--to", newRoot, "--harness", opts.harness], {
12644
12652
  encoding: "utf8",
12645
12653
  stdio: ["ignore", "pipe", "pipe"],
12646
12654
  timeout: DEFAULT_TIMEOUT_MS
@@ -12657,9 +12665,10 @@ async function getMigrationStatus(opts) {
12657
12665
  throw new Error(`AFT storage migration status returned invalid JSON: ${err instanceof Error ? err.message : String(err)}`);
12658
12666
  }
12659
12667
  }
12660
- var TARGET_MARKER = ".migrated_from_legacy", DEFAULT_TIMEOUT_MS;
12668
+ var spawnSyncForMigration, TARGET_MARKER = ".migrated_from_legacy", DEFAULT_TIMEOUT_MS;
12661
12669
  var init_migration = __esm(() => {
12662
12670
  init_resolver();
12671
+ spawnSyncForMigration = spawnSync5;
12663
12672
  DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
12664
12673
  });
12665
12674
 
@@ -35977,18 +35986,40 @@ async function fetchUrlToTempFile(url, storageDir, options = {}) {
35977
35986
  }
35978
35987
  const chunks = [];
35979
35988
  let total = 0;
35980
- while (true) {
35981
- const { done, value } = await reader.read();
35982
- if (done)
35983
- break;
35984
- if (value) {
35985
- total += value.length;
35986
- if (total > MAX_RESPONSE_BYTES) {
35989
+ try {
35990
+ while (true) {
35991
+ let chunkTimer;
35992
+ const stallSymbol = Symbol("body-stall");
35993
+ const stallPromise = new Promise((resolve5) => {
35994
+ chunkTimer = setTimeout(() => resolve5(stallSymbol), BODY_CHUNK_TIMEOUT_MS);
35995
+ });
35996
+ let result;
35997
+ try {
35998
+ result = await Promise.race([reader.read(), stallPromise]);
35999
+ } finally {
36000
+ if (chunkTimer)
36001
+ clearTimeout(chunkTimer);
36002
+ }
36003
+ if (result === stallSymbol) {
35987
36004
  reader.cancel().catch(() => {});
35988
- throw new Error(`Response exceeded ${MAX_RESPONSE_BYTES} bytes, aborted`);
36005
+ throw new Error(`Body read stalled (no data for ${BODY_CHUNK_TIMEOUT_MS}ms) fetching ${url}`);
36006
+ }
36007
+ const { done, value } = result;
36008
+ if (done)
36009
+ break;
36010
+ if (value) {
36011
+ total += value.length;
36012
+ if (total > MAX_RESPONSE_BYTES) {
36013
+ reader.cancel().catch(() => {});
36014
+ throw new Error(`Response exceeded ${MAX_RESPONSE_BYTES} bytes, aborted`);
36015
+ }
36016
+ chunks.push(value);
35989
36017
  }
35990
- chunks.push(value);
35991
36018
  }
36019
+ } finally {
36020
+ try {
36021
+ reader.releaseLock();
36022
+ } catch {}
35992
36023
  }
35993
36024
  const body = Buffer.concat(chunks);
35994
36025
  const contentFile = contentPath(storageDir, hash, extension);
@@ -36044,7 +36075,7 @@ function cleanupUrlCache(storageDir) {
36044
36075
  log(`URL cache cleanup: removed ${removed} stale entries`);
36045
36076
  }
36046
36077
  }
36047
- var MAX_RESPONSE_BYTES, CACHE_TTL_MS, FETCH_TIMEOUT_MS = 30000, MAX_REDIRECTS = 5;
36078
+ var MAX_RESPONSE_BYTES, CACHE_TTL_MS, FETCH_TIMEOUT_MS = 30000, BODY_CHUNK_TIMEOUT_MS = 15000, MAX_REDIRECTS = 5;
36048
36079
  var init_url_fetch = __esm(() => {
36049
36080
  init_undici();
36050
36081
  init_active_logger();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
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",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@clack/prompts": "^1.2.0",
26
- "@cortexkit/aft-bridge": "0.29.0",
26
+ "@cortexkit/aft-bridge": "0.30.0",
27
27
  "comment-json": "^4.6.2"
28
28
  },
29
29
  "devDependencies": {