@cortexkit/aft 0.59.0 → 0.60.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 +129 -15
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -609,7 +609,7 @@ var init_command_timeouts = __esm(() => {
609
609
  });
610
610
 
611
611
  // ../aft-bridge/dist/transport.js
612
- var WORKER_SESSION_FIELD = "worker_session";
612
+ var WORKER_SESSION_FIELD = "worker_session", HOST_TOOL_NAMES_FIELD = "host_tool_names";
613
613
 
614
614
  // ../aft-bridge/dist/bridge.js
615
615
  import { homedir as homedir4 } from "node:os";
@@ -761,6 +761,8 @@ var init_bridge = __esm(() => {
761
761
  lastBinaryFingerprintCheckAt = 0;
762
762
  _retiringDueToBinaryChange = false;
763
763
  pending = new Map;
764
+ activeSendCalls = 0;
765
+ processLoopReferenced = true;
764
766
  outstandingBackgroundTaskIds = new Set;
765
767
  nextId = 1;
766
768
  processGeneration = 0;
@@ -992,6 +994,32 @@ var init_bridge = __esm(() => {
992
994
  this.sessionLogVia(sessionId, `hashline registration carrier transport=ndjson phase=${phase} edit_slot_survives=${editSlotSurvives}${repeated}`);
993
995
  }
994
996
  async send(command, params = {}, options) {
997
+ this.activeSendCalls += 1;
998
+ this.syncEventLoopHold();
999
+ try {
1000
+ return await this.dispatchSend(command, params, options);
1001
+ } finally {
1002
+ this.activeSendCalls -= 1;
1003
+ this.syncEventLoopHold();
1004
+ }
1005
+ }
1006
+ syncEventLoopHold() {
1007
+ const child = this.process;
1008
+ if (!child)
1009
+ return;
1010
+ const hold = this.activeSendCalls > 0 || this.outstandingBackgroundTaskIds.size > 0;
1011
+ if (hold === this.processLoopReferenced)
1012
+ return;
1013
+ this.processLoopReferenced = hold;
1014
+ const handles = [child, child.stdin, child.stdout, child.stderr];
1015
+ for (const handle of handles) {
1016
+ if (hold)
1017
+ handle?.ref?.();
1018
+ else
1019
+ handle?.unref?.();
1020
+ }
1021
+ }
1022
+ async dispatchSend(command, params, options) {
995
1023
  let dispatchParams = params;
996
1024
  if (command === "configure") {
997
1025
  dispatchParams = { ...params };
@@ -1029,11 +1057,13 @@ var init_bridge = __esm(() => {
1029
1057
  params.edit_slot_survives = editSlotSurvives;
1030
1058
  this.logHashlineRegistrationCarrier("tool_call", sessionId, editSlotSurvives);
1031
1059
  }
1032
- const { preview, workerSession, ...sendOptions } = options ?? {};
1060
+ const { preview, workerSession, hostToolNames, ...sendOptions } = options ?? {};
1033
1061
  if (preview === true)
1034
1062
  params.preview = true;
1035
1063
  if (workerSession === true)
1036
1064
  params[WORKER_SESSION_FIELD] = true;
1065
+ if (hostToolNames)
1066
+ params[HOST_TOOL_NAMES_FIELD] = hostToolNames;
1037
1067
  return await this.send("tool_call", params, Object.keys(sendOptions).length > 0 ? sendOptions : undefined);
1038
1068
  }
1039
1069
  async sendWithVersionMismatchRetry(command, params, options, canRetryAfterVersionSwap) {
@@ -1102,7 +1132,12 @@ var init_bridge = __esm(() => {
1102
1132
  if (command === "cancel_request" || Object.hasOwn(params, "command") || Object.hasOwn(params, "method")) {
1103
1133
  const nested = { ...params };
1104
1134
  const reserved = {};
1105
- for (const key of ["session_id", "lsp_hints", WORKER_SESSION_FIELD]) {
1135
+ for (const key of [
1136
+ "session_id",
1137
+ "lsp_hints",
1138
+ WORKER_SESSION_FIELD,
1139
+ HOST_TOOL_NAMES_FIELD
1140
+ ]) {
1106
1141
  if (Object.hasOwn(nested, key)) {
1107
1142
  reserved[key] = nested[key];
1108
1143
  delete nested[key];
@@ -1477,6 +1512,8 @@ var init_bridge = __esm(() => {
1477
1512
  this.lastChildActivityAt = 0;
1478
1513
  this.consecutiveRequestTimeouts = 0;
1479
1514
  this.stderrTail = [];
1515
+ this.processLoopReferenced = true;
1516
+ this.syncEventLoopHold();
1480
1517
  }
1481
1518
  pushStderrLine(line) {
1482
1519
  this.stderrTail.push(line);
@@ -1603,6 +1640,7 @@ var init_bridge = __esm(() => {
1603
1640
  const taskId = bashTaskIdFrom(response);
1604
1641
  if (taskId)
1605
1642
  this.outstandingBackgroundTaskIds.delete(taskId);
1643
+ this.syncEventLoopHold();
1606
1644
  this.onBashCompletion?.(response, this);
1607
1645
  return;
1608
1646
  }
@@ -1716,7 +1754,7 @@ var init_bridge = __esm(() => {
1716
1754
  const delay = 100 * 2 ** this._restartCount;
1717
1755
  this._restartCount++;
1718
1756
  this.logVia(`Auto-restart #${this._restartCount} in ${delay}ms`);
1719
- setTimeout(() => {
1757
+ const restartTimer = setTimeout(() => {
1720
1758
  if (!this._shuttingDown && !this.isAlive()) {
1721
1759
  try {
1722
1760
  this.spawnProcess();
@@ -1725,6 +1763,7 @@ var init_bridge = __esm(() => {
1725
1763
  }
1726
1764
  }
1727
1765
  }, delay);
1766
+ restartTimer.unref?.();
1728
1767
  this.scheduleRestartCountReset();
1729
1768
  } else {
1730
1769
  this.errorVia(`Max restarts (${this.maxRestarts}) reached, giving up. Logs: ${this.getLogFilePathVia()}${tail}`);
@@ -1745,6 +1784,7 @@ var init_bridge = __esm(() => {
1745
1784
  this._restartCount = 0;
1746
1785
  this.restartResetTimer = null;
1747
1786
  }, BinaryBridge.RESTART_RESET_MS);
1787
+ this.restartResetTimer.unref?.();
1748
1788
  }
1749
1789
  clearRestartResetTimer() {
1750
1790
  if (this.restartResetTimer) {
@@ -2396,7 +2436,7 @@ var init_durable_log = __esm(() => {
2396
2436
  init_storage_paths();
2397
2437
  DEFAULT_LOG_BYTES = 32 * 1024 * 1024;
2398
2438
  });
2399
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/envelope.js
2439
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/envelope.js
2400
2440
  var MAX_FRAME_BODY_LEN, FrameType, FRAME_TYPE_MAX, Priority, AdmissionClass;
2401
2441
  var init_envelope = __esm(() => {
2402
2442
  MAX_FRAME_BODY_LEN = 64 * 1024 * 1024;
@@ -2427,7 +2467,7 @@ var init_envelope = __esm(() => {
2427
2467
  })(AdmissionClass || (AdmissionClass = {}));
2428
2468
  });
2429
2469
 
2430
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/socket.js
2470
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/socket.js
2431
2471
  var WRITE_BORROWED, WRITE_TRACKED_BORROWED;
2432
2472
  var init_socket = __esm(() => {
2433
2473
  init_envelope();
@@ -2435,17 +2475,17 @@ var init_socket = __esm(() => {
2435
2475
  WRITE_TRACKED_BORROWED = Symbol("subc.socket.writeTrackedBorrowed");
2436
2476
  });
2437
2477
 
2438
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/auth.js
2478
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/auth.js
2439
2479
  var init_auth = __esm(() => {
2440
2480
  init_socket();
2441
2481
  });
2442
2482
 
2443
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/connection-file.js
2483
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/connection-file.js
2444
2484
  var init_connection_file = __esm(() => {
2445
2485
  init_envelope();
2446
2486
  });
2447
2487
 
2448
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/launch-nonce.js
2488
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/launch-nonce.js
2449
2489
  var PROCESS_CELL_KEY, U64_MAX, I32_MAX, RedactedLaunchNonce;
2450
2490
  var init_launch_nonce = __esm(() => {
2451
2491
  PROCESS_CELL_KEY = Symbol.for("@cortexkit/subc-client/launch-nonce/v1");
@@ -2471,16 +2511,16 @@ var init_launch_nonce = __esm(() => {
2471
2511
  };
2472
2512
  });
2473
2513
 
2474
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/route-handle.js
2514
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/route-handle.js
2475
2515
  var connectionToken, reverseRequests;
2476
2516
  var init_route_handle = __esm(() => {
2477
2517
  connectionToken = new WeakMap;
2478
2518
  reverseRequests = new WeakMap;
2479
2519
  });
2480
2520
 
2481
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/client.js
2521
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/client.js
2482
2522
  import { debuglog } from "node:util";
2483
- var debug, EMPTY_BODY, errorFrameFlags, ROUTE_OPEN_ADMISSION_PRESSURE_REASONS;
2523
+ var debug, EMPTY_BODY, errorFrameFlags, SCOPE_ROUTE_CLOSE_REASONS, ROUTE_OPEN_ADMISSION_PRESSURE_REASONS;
2484
2524
  var init_client = __esm(() => {
2485
2525
  init_auth();
2486
2526
  init_connection_file();
@@ -2492,10 +2532,16 @@ var init_client = __esm(() => {
2492
2532
  debug = debuglog("subc-client");
2493
2533
  EMPTY_BODY = new Uint8Array(0);
2494
2534
  errorFrameFlags = new WeakMap;
2535
+ SCOPE_ROUTE_CLOSE_REASONS = new Set([
2536
+ "scope_ended",
2537
+ "scope_carrier_removed",
2538
+ "scope_delegation_changed",
2539
+ "scope_parent_ended"
2540
+ ]);
2495
2541
  ROUTE_OPEN_ADMISSION_PRESSURE_REASONS = new Set(["open_admission_full", "target_binds_full"]);
2496
2542
  });
2497
2543
 
2498
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/provider.js
2544
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/provider.js
2499
2545
  var init_provider = __esm(() => {
2500
2546
  init_auth();
2501
2547
  init_client();
@@ -2506,7 +2552,7 @@ var init_provider = __esm(() => {
2506
2552
  init_socket();
2507
2553
  });
2508
2554
 
2509
- // ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/index.js
2555
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.21.2/node_modules/@cortexkit/subc-client/dist/index.js
2510
2556
  var init_dist = __esm(() => {
2511
2557
  init_client();
2512
2558
  init_route_handle();
@@ -3081,10 +3127,68 @@ function translateInspectLspPaths(map, prefix, out) {
3081
3127
  recordRetired(out, prefix, `inspect.${leaf}`);
3082
3128
  }
3083
3129
  }
3130
+ function translateExperimentalPaths(map, prefix, out) {
3131
+ for (const [oldKey, leaf] of [
3132
+ ["experimental_lsp_ty", "lsp_ty"],
3133
+ ["experimental_bash_rewrite", "rewrite"],
3134
+ ["experimental_bash_compress", "compress"],
3135
+ ["experimental_bash_background", "background"]
3136
+ ]) {
3137
+ if (!Object.hasOwn(map, oldKey))
3138
+ continue;
3139
+ recordRetired(out, prefix, oldKey);
3140
+ const value = map[oldKey];
3141
+ delete map[oldKey];
3142
+ if (!isRecord(map.experimental))
3143
+ map.experimental = {};
3144
+ const experimental = map.experimental;
3145
+ let destination = experimental;
3146
+ if (leaf !== "lsp_ty") {
3147
+ if (!isRecord(experimental.bash))
3148
+ experimental.bash = {};
3149
+ destination = experimental.bash;
3150
+ }
3151
+ if (Object.hasOwn(destination, leaf)) {
3152
+ superseded(out, oldKey, `${oldKey} is ignored because experimental.${leaf === "lsp_ty" ? leaf : `bash.${leaf}`} is already set`);
3153
+ } else {
3154
+ destination[leaf] = value;
3155
+ }
3156
+ }
3157
+ if (!isRecord(map.experimental) || !Object.hasOwn(map.experimental, "bash"))
3158
+ return;
3159
+ const experimental = map.experimental;
3160
+ const legacy = experimental.bash;
3161
+ if (isRecord(legacy)) {
3162
+ if (!["rewrite", "compress", "background"].some((leaf) => Object.hasOwn(legacy, leaf)))
3163
+ return;
3164
+ for (const leaf of Object.keys(legacy))
3165
+ recordRetired(out, prefix, `experimental.bash.${leaf}`);
3166
+ if (Object.hasOwn(map, "bash")) {
3167
+ superseded(out, "experimental.bash", 'experimental.bash is ignored because top-level "bash" is already set');
3168
+ } else {
3169
+ const bash = {
3170
+ rewrite: legacy.rewrite === true,
3171
+ compress: legacy.compress === true,
3172
+ background: legacy.background === true
3173
+ };
3174
+ for (const leaf of ["long_running_reminder_enabled", "long_running_reminder_interval_ms"]) {
3175
+ if (Object.hasOwn(legacy, leaf))
3176
+ bash[leaf] = legacy[leaf];
3177
+ }
3178
+ map.bash = bash;
3179
+ }
3180
+ } else {
3181
+ recordRetired(out, prefix, "experimental.bash");
3182
+ }
3183
+ delete experimental.bash;
3184
+ if (Object.keys(experimental).length === 0)
3185
+ delete map.experimental;
3186
+ }
3084
3187
  function translateBlock(map, userBase, blockLabel, out) {
3085
3188
  const prefix = blockLabel === "base" ? "" : `${blockLabel}.`;
3086
3189
  translateGithubAliases(map, prefix, out);
3087
3190
  translateInspectLspPaths(map, prefix, out);
3191
+ translateExperimentalPaths(map, prefix, out);
3088
3192
  let explicitList;
3089
3193
  const rawList = map.disabled_tools;
3090
3194
  if (Array.isArray(rawList) && rawList.every((entry) => typeof entry === "string")) {
@@ -3097,6 +3201,8 @@ function translateBlock(map, userBase, blockLabel, out) {
3097
3201
  });
3098
3202
  }
3099
3203
  for (const [path] of RETIRED_PATHS) {
3204
+ if (path === "experimental.bash")
3205
+ continue;
3100
3206
  if (hasPath(map, path))
3101
3207
  recordRetired(out, prefix, path);
3102
3208
  }
@@ -3320,7 +3426,12 @@ var init_feature_config = __esm(() => {
3320
3426
  ["semantic_search", "indexes.semantic"],
3321
3427
  ["experimental_semantic_search", "indexes.semantic"],
3322
3428
  ["callgraph_store", "indexes.callgraph"],
3323
- ["github.enabled", "github.read,github.write,github.shim"]
3429
+ ["github.enabled", "github.read,github.write,github.shim"],
3430
+ ["experimental_lsp_ty", "experimental.lsp_ty"],
3431
+ ["experimental_bash_rewrite", "bash.rewrite"],
3432
+ ["experimental_bash_compress", "bash.compress"],
3433
+ ["experimental_bash_background", "bash.background"],
3434
+ ["experimental.bash", "bash"]
3324
3435
  ];
3325
3436
  INDEX_INPUTS = [
3326
3437
  ["trigram", "search_index", "experimental_search_index"],
@@ -3334,6 +3445,7 @@ var DEFAULT_IDLE_TIMEOUT_MS, CLEANUP_INTERVAL_MS;
3334
3445
  var init_pool = __esm(() => {
3335
3446
  init_active_logger();
3336
3447
  init_bridge();
3448
+ init_lifecycle_registry();
3337
3449
  init_project_identity();
3338
3450
  DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
3339
3451
  CLEANUP_INTERVAL_MS = 60 * 1000;
@@ -3342,6 +3454,7 @@ var init_pool = __esm(() => {
3342
3454
  // ../aft-bridge/dist/revivable-transport.js
3343
3455
  var init_revivable_transport = __esm(() => {
3344
3456
  init_active_logger();
3457
+ init_lifecycle_registry();
3345
3458
  init_project_identity();
3346
3459
  });
3347
3460
 
@@ -4856,6 +4969,7 @@ var init_dist2 = __esm(() => {
4856
4969
  init_downloader();
4857
4970
  init_durable_log();
4858
4971
  init_error_contract();
4972
+ init_lifecycle_registry();
4859
4973
  init_location_lifecycle();
4860
4974
  init_message_detach();
4861
4975
  init_migration();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft",
3
- "version": "0.59.0",
3
+ "version": "0.60.0",
4
4
  "type": "module",
5
5
  "description": "Unified CLI for Agent File Tools (AFT) — setup, one-shot index snapshots, doctor, and diagnostics across supported agent harnesses (OpenCode, Pi)",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@clack/core": "^1.4.2",
27
27
  "@clack/prompts": "^1.6.0",
28
- "@cortexkit/aft-bridge": "0.59.0",
28
+ "@cortexkit/aft-bridge": "0.60.0",
29
29
  "comment-json": "^4.6.2"
30
30
  },
31
31
  "devDependencies": {