chatroom-cli 1.97.0 → 1.97.3

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/index.js CHANGED
@@ -31649,7 +31649,8 @@ function waitForResumeOrAbort3(session2) {
31649
31649
  function buildLocalAgentOptions(cwd) {
31650
31650
  return {
31651
31651
  cwd,
31652
- settingSources: []
31652
+ settingSources: [],
31653
+ enableAgentRetries: true
31653
31654
  };
31654
31655
  }
31655
31656
  function writeSpawnError3(logPrefix, err, emitLogLine) {
@@ -31662,8 +31663,8 @@ function writeSpawnError3(logPrefix, err, emitLogLine) {
31662
31663
  var NO_SUBAGENT_DIRECTIVE2 = "NEVER spawn subagents. Follow the chatroom instructions strictly.", _sdkCache3, _sdkLoadError3, CURSOR_SDK_COMMAND = "cursor-sdk", AGENT_CREATE_TIMEOUT_MS = 60000, SEND_TIMEOUT_MS = 60000, RUN_WAIT_TIMEOUT_MS = 3600000, RUN_CANCEL_TIMEOUT_MS = 5000, cachedSdkPackageVersion3, CursorSdkAgentService;
31663
31664
  var init_cursor_sdk_agent_service = __esm(() => {
31664
31665
  init_esm();
31665
- init_cursor_sdk_model_catalog();
31666
31666
  init_cursor_models();
31667
+ init_cursor_sdk_model_catalog();
31667
31668
  init_cursor_sdk_package();
31668
31669
  init_cursor_sdk_stream_adapter();
31669
31670
  init_base_cli_agent_service();
@@ -81826,12 +81827,84 @@ var init_skill = __esm(() => {
81826
81827
  init_convex_error();
81827
81828
  });
81828
81829
 
81830
+ // src/infrastructure/services/workspace/normalize-working-dir.ts
81831
+ function normalizeWorkingDirForLookup(workingDir) {
81832
+ return workingDir.trim().replace(/[/\\]+$/, "");
81833
+ }
81834
+
81835
+ // src/commands/workspace/file-tree.ts
81836
+ async function createDefaultDeps16() {
81837
+ const client4 = await getConvexClient();
81838
+ return {
81839
+ backend: {
81840
+ mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
81841
+ query: (endpoint, args2) => client4.query(endpoint, args2)
81842
+ },
81843
+ session: { getSessionId }
81844
+ };
81845
+ }
81846
+ async function requireSession3(deps) {
81847
+ const sessionId = await deps.session.getSessionId();
81848
+ if (!sessionId)
81849
+ throw new Error("Not authenticated. Please run: chatroom auth login");
81850
+ return sessionId;
81851
+ }
81852
+ async function requestWorkspaceFileTreeFromCli(machineId, workingDir, options, deps) {
81853
+ const d = deps ?? await createDefaultDeps16();
81854
+ const sessionId = await requireSession3(d);
81855
+ const result = await d.backend.mutation(api.workspaceFiles.requestFileTree, {
81856
+ sessionId,
81857
+ machineId,
81858
+ workingDir,
81859
+ ...options.force ? { force: true } : {}
81860
+ });
81861
+ return result;
81862
+ }
81863
+ async function getWorkspaceFileTreeStatusFromCli(machineId, workingDir, deps) {
81864
+ const d = deps ?? await createDefaultDeps16();
81865
+ const sessionId = await requireSession3(d);
81866
+ const [checkpoint, manifest, pendingRequests] = await Promise.all([
81867
+ d.backend.query(api.workspaceFiles.getFileTreeCheckpoint, {
81868
+ sessionId,
81869
+ machineId,
81870
+ workingDir
81871
+ }),
81872
+ d.backend.query(api.workspaceFiles.getFileTreeManifestV3, {
81873
+ sessionId,
81874
+ machineId,
81875
+ workingDir
81876
+ }),
81877
+ d.backend.query(api.workspaceFiles.getPendingFileTreeRequests, {
81878
+ sessionId,
81879
+ machineId
81880
+ })
81881
+ ]);
81882
+ const normalized = normalizeWorkingDirForLookup(workingDir);
81883
+ const filtered = Array.isArray(pendingRequests) ? pendingRequests.filter((r) => r && typeof r === "object" && ("workingDir" in r) && normalizeWorkingDirForLookup(String(r.workingDir)) === normalized) : pendingRequests;
81884
+ return { checkpoint, manifest, pendingRequests: filtered };
81885
+ }
81886
+ var init_file_tree = __esm(() => {
81887
+ init_api3();
81888
+ init_storage();
81889
+ init_client2();
81890
+ });
81891
+
81892
+ // src/commands/workspace/index.ts
81893
+ var exports_workspace = {};
81894
+ __export(exports_workspace, {
81895
+ requestWorkspaceFileTreeFromCli: () => requestWorkspaceFileTreeFromCli,
81896
+ getWorkspaceFileTreeStatusFromCli: () => getWorkspaceFileTreeStatusFromCli
81897
+ });
81898
+ var init_workspace = __esm(() => {
81899
+ init_file_tree();
81900
+ });
81901
+
81829
81902
  // src/commands/messages/send.ts
81830
81903
  var exports_send = {};
81831
81904
  __export(exports_send, {
81832
81905
  sendUserMessage: () => sendUserMessage
81833
81906
  });
81834
- async function createDefaultDeps16() {
81907
+ async function createDefaultDeps17() {
81835
81908
  const client4 = await getConvexClient();
81836
81909
  return {
81837
81910
  backend: {
@@ -81841,7 +81914,7 @@ async function createDefaultDeps16() {
81841
81914
  session: { getSessionId }
81842
81915
  };
81843
81916
  }
81844
- async function requireSession3(deps) {
81917
+ async function requireSession4(deps) {
81845
81918
  const sessionId = await deps.session.getSessionId();
81846
81919
  if (!sessionId)
81847
81920
  throw new Error("Not authenticated. Please run: chatroom auth login");
@@ -81850,8 +81923,8 @@ async function requireSession3(deps) {
81850
81923
  async function sendUserMessage(chatroomId, options, deps) {
81851
81924
  if (!options.content.trim())
81852
81925
  throw new Error("Message content cannot be empty");
81853
- const d = deps ?? await createDefaultDeps16();
81854
- const sessionId = await requireSession3(d);
81926
+ const d = deps ?? await createDefaultDeps17();
81927
+ const sessionId = await requireSession4(d);
81855
81928
  const chatroom = await d.backend.query(api.chatrooms.get, {
81856
81929
  sessionId,
81857
81930
  chatroomId
@@ -82349,7 +82422,7 @@ __export(exports_messages, {
82349
82422
  anchorMessagesEffect: () => anchorMessagesEffect,
82350
82423
  anchorMessages: () => anchorMessages
82351
82424
  });
82352
- async function createDefaultDeps17() {
82425
+ async function createDefaultDeps18() {
82353
82426
  const client4 = await getConvexClient();
82354
82427
  return {
82355
82428
  backend: {
@@ -82409,12 +82482,12 @@ function handleMessagesError(err) {
82409
82482
  });
82410
82483
  }
82411
82484
  async function listBySenderRole(chatroomId, options, deps) {
82412
- const d = deps ?? await createDefaultDeps17();
82485
+ const d = deps ?? await createDefaultDeps18();
82413
82486
  const layer = commandServicesLayerFromDeps(d);
82414
82487
  await exports_Effect.runPromise(listBySenderRoleEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
82415
82488
  }
82416
82489
  async function listSinceMessage(chatroomId, options, deps) {
82417
- const d = deps ?? await createDefaultDeps17();
82490
+ const d = deps ?? await createDefaultDeps18();
82418
82491
  const layer = commandServicesLayerFromDeps(d);
82419
82492
  await exports_Effect.runPromise(listSinceMessageEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
82420
82493
  }
@@ -82540,7 +82613,7 @@ __export(exports_context2, {
82540
82613
  inspectContextEffect: () => inspectContextEffect,
82541
82614
  inspectContext: () => inspectContext
82542
82615
  });
82543
- async function createDefaultDeps18() {
82616
+ async function createDefaultDeps19() {
82544
82617
  return createConvexCommandDeps();
82545
82618
  }
82546
82619
  function requireAuthenticatedChatroom(chatroomId) {
@@ -82582,17 +82655,17 @@ function handleContextError(err) {
82582
82655
  });
82583
82656
  }
82584
82657
  async function readContext(chatroomId, options, deps) {
82585
- const d = deps ?? await createDefaultDeps18();
82658
+ const d = deps ?? await createDefaultDeps19();
82586
82659
  const layer = commandServicesLayerFromDeps(d);
82587
82660
  await exports_Effect.runPromise(readContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
82588
82661
  }
82589
82662
  async function newContext(chatroomId, options, deps) {
82590
- const d = deps ?? await createDefaultDeps18();
82663
+ const d = deps ?? await createDefaultDeps19();
82591
82664
  const layer = commandServicesLayerFromDeps(d);
82592
82665
  await exports_Effect.runPromise(newContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
82593
82666
  }
82594
82667
  async function listContexts(chatroomId, options, deps) {
82595
- const d = deps ?? await createDefaultDeps18();
82668
+ const d = deps ?? await createDefaultDeps19();
82596
82669
  const layer = commandServicesLayerFromDeps(d);
82597
82670
  await exports_Effect.runPromise(listContextsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
82598
82671
  }
@@ -82600,7 +82673,7 @@ function viewTemplate() {
82600
82673
  return getContextViewTemplate();
82601
82674
  }
82602
82675
  async function inspectContext(chatroomId, options, deps) {
82603
- const d = deps ?? await createDefaultDeps18();
82676
+ const d = deps ?? await createDefaultDeps19();
82604
82677
  const layer = commandServicesLayerFromDeps(d);
82605
82678
  await exports_Effect.runPromise(inspectContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
82606
82679
  }
@@ -82793,7 +82866,7 @@ __export(exports_guidelines, {
82793
82866
  listGuidelineTypesEffect: () => listGuidelineTypesEffect,
82794
82867
  listGuidelineTypes: () => listGuidelineTypes
82795
82868
  });
82796
- async function createDefaultDeps19() {
82869
+ async function createDefaultDeps20() {
82797
82870
  const client4 = await getConvexClient();
82798
82871
  return {
82799
82872
  backend: {
@@ -82834,12 +82907,12 @@ function handleListGuidelineTypesError(err) {
82834
82907
  });
82835
82908
  }
82836
82909
  async function viewGuidelines(options, deps) {
82837
- const d = deps ?? await createDefaultDeps19();
82910
+ const d = deps ?? await createDefaultDeps20();
82838
82911
  const layer = layerFromDeps7(d);
82839
82912
  await exports_Effect.runPromise(viewGuidelinesEffect(options).pipe(exports_Effect.catchAll((err) => handleViewGuidelinesError(err)), exports_Effect.provide(layer)));
82840
82913
  }
82841
82914
  async function listGuidelineTypes(deps) {
82842
- const d = deps ?? await createDefaultDeps19();
82915
+ const d = deps ?? await createDefaultDeps20();
82843
82916
  const layer = layerFromDeps7(d);
82844
82917
  await exports_Effect.runPromise(listGuidelineTypesEffect().pipe(exports_Effect.catchAll((err) => handleListGuidelineTypesError(err)), exports_Effect.provide(layer)));
82845
82918
  }
@@ -82909,7 +82982,7 @@ __export(exports_artifact, {
82909
82982
  createArtifactEffect: () => createArtifactEffect,
82910
82983
  createArtifact: () => createArtifact
82911
82984
  });
82912
- async function createDefaultDeps20() {
82985
+ async function createDefaultDeps21() {
82913
82986
  return createConvexCommandDeps();
82914
82987
  }
82915
82988
  function handleArtifactError(err) {
@@ -82920,19 +82993,19 @@ function handleArtifactError(err) {
82920
82993
  });
82921
82994
  }
82922
82995
  async function createArtifact(chatroomId, options, deps) {
82923
- const d = deps ?? await createDefaultDeps20();
82996
+ const d = deps ?? await createDefaultDeps21();
82924
82997
  const layer = commandServicesLayerFromDeps(d);
82925
82998
  return exports_Effect.runPromise(createArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err).pipe(exports_Effect.map(() => {
82926
82999
  return;
82927
83000
  }))), exports_Effect.provide(layer)));
82928
83001
  }
82929
83002
  async function viewArtifact(chatroomId, options, deps) {
82930
- const d = deps ?? await createDefaultDeps20();
83003
+ const d = deps ?? await createDefaultDeps21();
82931
83004
  const layer = commandServicesLayerFromDeps(d);
82932
83005
  await exports_Effect.runPromise(viewArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
82933
83006
  }
82934
83007
  async function viewManyArtifacts(chatroomId, options, deps) {
82935
- const d = deps ?? await createDefaultDeps20();
83008
+ const d = deps ?? await createDefaultDeps21();
82936
83009
  const layer = commandServicesLayerFromDeps(d);
82937
83010
  await exports_Effect.runPromise(viewManyArtifactsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
82938
83011
  }
@@ -83281,7 +83354,7 @@ __export(exports_telegram, {
83281
83354
  sendMessageEffect: () => sendMessageEffect,
83282
83355
  sendMessage: () => sendMessage
83283
83356
  });
83284
- async function createDefaultDeps21() {
83357
+ async function createDefaultDeps22() {
83285
83358
  const client4 = await getConvexClient();
83286
83359
  return {
83287
83360
  backend: {
@@ -83363,7 +83436,7 @@ ${err.cause.message}`);
83363
83436
  });
83364
83437
  }
83365
83438
  async function sendMessage(options, deps) {
83366
- const d = deps ?? await createDefaultDeps21();
83439
+ const d = deps ?? await createDefaultDeps22();
83367
83440
  const layer = layerFromDeps8(d);
83368
83441
  await exports_Effect.runPromise(sendMessageEffect(options).pipe(exports_Effect.catchAll((err) => handleSendMessageError(err)), exports_Effect.provide(layer)));
83369
83442
  }
@@ -102318,7 +102391,7 @@ async function discoverModelsForHarness(harness, service3) {
102318
102391
  async function discoverModels(agentServices) {
102319
102392
  return exports_Effect.runPromise(discoverModelsEffect(agentServices));
102320
102393
  }
102321
- function createDefaultDeps22() {
102394
+ function createDefaultDeps23() {
102322
102395
  return {
102323
102396
  backend: {
102324
102397
  mutation: async () => {
@@ -102664,7 +102737,7 @@ var init_init_daemon = __esm(() => {
102664
102737
  convexUrl,
102665
102738
  agentServices,
102666
102739
  cachedModels,
102667
- deps: createDefaultDeps22()
102740
+ deps: createDefaultDeps23()
102668
102741
  });
102669
102742
  yield* registerEventListenersEffect().pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
102670
102743
  yield* logStartupEffect(cachedModels).pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
@@ -106590,7 +106663,7 @@ class CursorSdkHarness {
106590
106663
  const agent = await withTimeout(Agent.create({
106591
106664
  apiKey,
106592
106665
  model: modelSelection,
106593
- local: { cwd: this.cwd, settingSources: [] }
106666
+ local: { cwd: this.cwd, settingSources: [], enableAgentRetries: true }
106594
106667
  }), AGENT_CREATE_TIMEOUT_MS2, "Agent.create");
106595
106668
  const session2 = new CursorSdkSession({
106596
106669
  agent,
@@ -106614,7 +106687,7 @@ class CursorSdkHarness {
106614
106687
  const agent = await withTimeout(Agent.resume(sessionId, {
106615
106688
  apiKey,
106616
106689
  model: resolveCursorSdkSpawnModelSelection(DEFAULT_MODEL2),
106617
- local: { cwd: this.cwd, settingSources: [] }
106690
+ local: { cwd: this.cwd, settingSources: [], enableAgentRetries: true }
106618
106691
  }), AGENT_CREATE_TIMEOUT_MS2, "Agent.resume");
106619
106692
  const session2 = new CursorSdkSession({
106620
106693
  agent,
@@ -106653,8 +106726,8 @@ var DEFAULT_MODEL2 = "composer-2.5", AGENT_CREATE_TIMEOUT_MS2 = 60000, _sdkCache
106653
106726
  };
106654
106727
  var init_cursor_harness = __esm(() => {
106655
106728
  init_cursor_session();
106656
- init_cursor_sdk_model_catalog();
106657
106729
  init_cursor_models();
106730
+ init_cursor_sdk_model_catalog();
106658
106731
  init_cursor_sdk_package();
106659
106732
  });
106660
106733
 
@@ -109101,11 +109174,6 @@ var init_file_content_classifier = __esm(() => {
109101
109174
  ]);
109102
109175
  });
109103
109176
 
109104
- // src/infrastructure/services/workspace/normalize-working-dir.ts
109105
- function normalizeWorkingDirForLookup(workingDir) {
109106
- return workingDir.trim().replace(/[/\\]+$/, "");
109107
- }
109108
-
109109
109177
  // src/infrastructure/services/workspace/assert-registered-working-dir.ts
109110
109178
  async function assertRegisteredWorkingDir(session2, workingDir) {
109111
109179
  const workspaces = await getWorkspacesForMachine({
@@ -109435,6 +109503,49 @@ var init_file_content_subscription = __esm(() => {
109435
109503
  init_daemon_services();
109436
109504
  });
109437
109505
 
109506
+ // ../../services/backend/src/domain/workspace-file-tree/types.ts
109507
+ var MAX_TREE_JSON_BYTES;
109508
+ var init_types2 = __esm(() => {
109509
+ MAX_TREE_JSON_BYTES = 900 * 1024;
109510
+ });
109511
+ // ../../services/backend/src/domain/workspace-file-tree/select-strategy.ts
109512
+ function treeJsonByteLength(tree) {
109513
+ return Buffer.byteLength(JSON.stringify(tree), "utf8");
109514
+ }
109515
+ function selectFileTreeSnapshotStrategyId(tree) {
109516
+ return treeJsonByteLength(tree) > MAX_TREE_JSON_BYTES ? "sharded" : "blob";
109517
+ }
109518
+ var init_select_strategy = __esm(() => {
109519
+ init_types2();
109520
+ });
109521
+
109522
+ // ../../services/backend/src/domain/workspace-file-tree/registry.ts
109523
+ var init_registry5 = __esm(() => {
109524
+ init_select_strategy();
109525
+ });
109526
+ // ../../services/backend/src/domain/workspace-file-tree/transport/blob-snapshot.ts
109527
+ function toLegacyBlobSyncArgs(payload) {
109528
+ return { data: payload.data, dataHash: payload.dataHash, scannedAt: payload.scannedAt };
109529
+ }
109530
+
109531
+ // ../../services/backend/src/domain/workspace-file-tree/transport/sharded-snapshot.ts
109532
+ function toLegacyShardBatchItem(shard) {
109533
+ return { ...shard };
109534
+ }
109535
+ function toLegacyManifestSyncArgs(manifest) {
109536
+ return { ...manifest };
109537
+ }
109538
+ // ../../services/backend/src/domain/workspace-file-tree/transport/index.ts
109539
+ var init_transport = () => {};
109540
+
109541
+ // ../../services/backend/src/domain/workspace-file-tree/index.ts
109542
+ var init_workspace_file_tree = __esm(() => {
109543
+ init_types2();
109544
+ init_select_strategy();
109545
+ init_registry5();
109546
+ init_transport();
109547
+ });
109548
+
109438
109549
  // src/infrastructure/services/workspace/file-tree-data-hash.ts
109439
109550
  import { createHash as createHash6 } from "node:crypto";
109440
109551
  function computeFileTreeDataHash(tree) {
@@ -109442,9 +109553,37 @@ function computeFileTreeDataHash(tree) {
109442
109553
  }
109443
109554
  var init_file_tree_data_hash = () => {};
109444
109555
 
109556
+ // src/infrastructure/services/workspace/transport/blob-snapshot-publish.ts
109557
+ import { gzipSync as gzipSync2 } from "node:zlib";
109558
+ function buildBlobSnapshotPayload(tree, dataHash) {
109559
+ const compressed = gzipSync2(Buffer.from(JSON.stringify(tree))).toString("base64");
109560
+ return {
109561
+ data: { compression: "gzip", content: compressed },
109562
+ dataHash,
109563
+ scannedAt: tree.scannedAt
109564
+ };
109565
+ }
109566
+ async function publishBlobSnapshot(session2, workingDir, payload) {
109567
+ await session2.backend.mutation(api.workspaceFiles.syncFileTreeV2, {
109568
+ sessionId: session2.sessionId,
109569
+ machineId: session2.machineId,
109570
+ workingDir,
109571
+ ...toLegacyBlobSyncArgs(payload)
109572
+ });
109573
+ return {
109574
+ strategyId: "blob",
109575
+ snapshotId: payload.dataHash,
109576
+ scannedAt: payload.scannedAt,
109577
+ entryCount: 0
109578
+ };
109579
+ }
109580
+ var init_blob_snapshot_publish = __esm(() => {
109581
+ init_api3();
109582
+ });
109583
+
109445
109584
  // src/infrastructure/services/workspace/file-tree-partition.ts
109446
109585
  import { createHash as createHash7 } from "node:crypto";
109447
- import { gzipSync as gzipSync2 } from "node:zlib";
109586
+ import { gzipSync as gzipSync3 } from "node:zlib";
109448
109587
  function computeShardDataHash(payload) {
109449
109588
  return createHash7("md5").update(JSON.stringify(payload)).digest("hex");
109450
109589
  }
@@ -109452,9 +109591,6 @@ function shardIdForPath(path3) {
109452
109591
  const slash = path3.indexOf("/");
109453
109592
  return slash === -1 ? "__root__" : path3.slice(0, slash);
109454
109593
  }
109455
- function shouldUseV3Upload(tree) {
109456
- return Buffer.byteLength(JSON.stringify(tree), "utf8") > MAX_TREE_JSON_BYTES;
109457
- }
109458
109594
  function childShardId(path3, parentShardId) {
109459
109595
  if (parentShardId === "__root__") {
109460
109596
  return shardIdForPath(path3);
@@ -109481,7 +109617,7 @@ function groupEntriesByShardId(entries2, parentShardId) {
109481
109617
  return groups;
109482
109618
  }
109483
109619
  function buildPreparedShard(shardId, payload) {
109484
- const compressed = gzipSync2(Buffer.from(JSON.stringify(payload))).toString("base64");
109620
+ const compressed = gzipSync3(Buffer.from(JSON.stringify(payload))).toString("base64");
109485
109621
  return {
109486
109622
  shardId,
109487
109623
  payload,
@@ -109496,7 +109632,7 @@ function prepareShardGroup(entries2, shardId, tree) {
109496
109632
  scannedAt: tree.scannedAt,
109497
109633
  rootDir: tree.rootDir
109498
109634
  };
109499
- const compressed = gzipSync2(Buffer.from(JSON.stringify(payload))).toString("base64");
109635
+ const compressed = gzipSync3(Buffer.from(JSON.stringify(payload))).toString("base64");
109500
109636
  if (Buffer.byteLength(compressed, "utf8") <= MAX_SHARD_JSON_BYTES) {
109501
109637
  return [buildPreparedShard(shardId, payload)];
109502
109638
  }
@@ -109518,49 +109654,59 @@ function partitionFileTree(tree) {
109518
109654
  }
109519
109655
  return shards;
109520
109656
  }
109521
- var MAX_TREE_JSON_BYTES, MAX_SHARD_JSON_BYTES, MAX_SHARD_BATCH_SIZE = 8;
109657
+ var MAX_TREE_JSON_BYTES2, MAX_SHARD_JSON_BYTES, MAX_SHARD_BATCH_SIZE = 8;
109522
109658
  var init_file_tree_partition = __esm(() => {
109523
- MAX_TREE_JSON_BYTES = 900 * 1024;
109659
+ init_workspace_file_tree();
109660
+ MAX_TREE_JSON_BYTES2 = 900 * 1024;
109524
109661
  MAX_SHARD_JSON_BYTES = 800 * 1024;
109525
109662
  });
109526
109663
 
109527
- // src/infrastructure/services/workspace/file-tree-v3-upload.ts
109528
- async function uploadFileTreeV3(session2, workingDir, tree, syncGeneration) {
109664
+ // src/infrastructure/services/workspace/transport/sharded-snapshot-publish.ts
109665
+ async function publishShardedSnapshot(session2, workingDir, tree, syncGeneration) {
109529
109666
  const shards = partitionFileTree(tree);
109530
109667
  const shardIds = [];
109531
109668
  for (let i2 = 0;i2 < shards.length; i2 += MAX_SHARD_BATCH_SIZE) {
109532
109669
  const batch = shards.slice(i2, i2 + MAX_SHARD_BATCH_SIZE);
109670
+ const items = batch.map((s) => ({
109671
+ shardId: s.shardId,
109672
+ data: s.data,
109673
+ dataHash: s.dataHash,
109674
+ scannedAt: tree.scannedAt,
109675
+ entryCount: s.entryCount
109676
+ }));
109533
109677
  await session2.backend.mutation(api.workspaceFiles.syncFileTreeShardV3Batch, {
109534
109678
  sessionId: session2.sessionId,
109535
109679
  machineId: session2.machineId,
109536
109680
  workingDir,
109537
109681
  syncGeneration,
109538
- items: batch.map((s) => ({
109539
- shardId: s.shardId,
109540
- data: s.data,
109541
- dataHash: s.dataHash,
109542
- scannedAt: tree.scannedAt,
109543
- entryCount: s.entryCount
109544
- }))
109682
+ items: items.map(toLegacyShardBatchItem)
109545
109683
  });
109546
109684
  for (const s of batch)
109547
109685
  shardIds.push(s.shardId);
109548
109686
  }
109549
- await session2.backend.mutation(api.workspaceFiles.syncFileTreeManifestV3, {
109550
- sessionId: session2.sessionId,
109551
- machineId: session2.machineId,
109552
- workingDir,
109687
+ const manifest = {
109553
109688
  syncGeneration,
109554
109689
  shardIds,
109555
109690
  totalEntryCount: tree.entries.length,
109556
109691
  complete: true,
109557
109692
  scannedAt: tree.scannedAt
109693
+ };
109694
+ await session2.backend.mutation(api.workspaceFiles.syncFileTreeManifestV3, {
109695
+ sessionId: session2.sessionId,
109696
+ machineId: session2.machineId,
109697
+ workingDir,
109698
+ ...toLegacyManifestSyncArgs(manifest)
109558
109699
  });
109559
- return { shardIds, totalEntryCount: tree.entries.length };
109700
+ return {
109701
+ strategyId: "sharded",
109702
+ snapshotId: syncGeneration,
109703
+ scannedAt: tree.scannedAt,
109704
+ entryCount: tree.entries.length
109705
+ };
109560
109706
  }
109561
- var init_file_tree_v3_upload = __esm(() => {
109562
- init_file_tree_partition();
109707
+ var init_sharded_snapshot_publish = __esm(() => {
109563
109708
  init_api3();
109709
+ init_file_tree_partition();
109564
109710
  });
109565
109711
 
109566
109712
  // ../../node_modules/.pnpm/ignore@7.0.5/node_modules/ignore/index.js
@@ -112796,10 +112942,41 @@ var init_workspace_file_tree_coordinator = __esm(() => {
112796
112942
 
112797
112943
  // src/daemon/entry/files/file-tree-subscription.ts
112798
112944
  import { randomUUID as randomUUID11 } from "node:crypto";
112799
- import { gzipSync as gzipSync3 } from "node:zlib";
112800
112945
  function logSubscriptionWarn(label, err) {
112801
112946
  console.warn(`[${formatTimestamp()}] ⚠️ ${label}: ${getErrorMessage(err)}`);
112802
112947
  }
112948
+ async function stopCoordinatorForWorkingDir(coordinators, normalized) {
112949
+ const coordinatorPromise = coordinators.get(normalized);
112950
+ if (!coordinatorPromise)
112951
+ return;
112952
+ coordinators.delete(normalized);
112953
+ await coordinatorPromise.then((coordinator2) => coordinator2.stop()).catch(() => {
112954
+ return;
112955
+ });
112956
+ }
112957
+ async function drainPendingFileTreeReleaseRequests(session2, coordinators) {
112958
+ const releases = await session2.backend.query(api.workspaceFiles.getPendingFileTreeReleaseRequests, {
112959
+ sessionId: session2.sessionId,
112960
+ machineId: session2.machineId
112961
+ });
112962
+ if (!releases?.length)
112963
+ return;
112964
+ const releasesByDir = new Set;
112965
+ for (const release of releases) {
112966
+ releasesByDir.add(normalizeWorkingDirForLookup(release.workingDir));
112967
+ }
112968
+ for (const normalized of releasesByDir) {
112969
+ await stopCoordinatorForWorkingDir(coordinators, normalized).then(() => session2.backend.mutation(api.workspaceFiles.fulfillFileTreeReleaseRequest, {
112970
+ sessionId: session2.sessionId,
112971
+ machineId: session2.machineId,
112972
+ workingDir: normalized
112973
+ })).then(() => {
112974
+ console.log(`[${formatTimestamp()}] \uD83C\uDF33 File tree coordinator stopped: ${normalized}`);
112975
+ }).catch((err) => {
112976
+ logSubscriptionWarn(`File tree release failed for ${normalized}`, err);
112977
+ });
112978
+ }
112979
+ }
112803
112980
  async function processPendingFileTreeRequests(session2, coordinators, ensureCoordinator, requests) {
112804
112981
  if (!requests?.length)
112805
112982
  return;
@@ -112829,21 +113006,12 @@ async function drainPendingFileTreeRequests(session2, coordinators, ensureCoordi
112829
113006
  await processPendingFileTreeRequests(session2, coordinators, ensureCoordinator, requests);
112830
113007
  }
112831
113008
  async function syncScannedFileTree(session2, normalizedWorkingDir, tree, dataHash, syncGeneration) {
112832
- if (shouldUseV3Upload(tree)) {
112833
- await uploadFileTreeV3(session2, normalizedWorkingDir, tree, syncGeneration);
112834
- return { snapshotKind: "v3", snapshotId: syncGeneration };
113009
+ if (selectFileTreeSnapshotStrategyId(tree) === "sharded") {
113010
+ const ref2 = await publishShardedSnapshot(session2, normalizedWorkingDir, tree, syncGeneration);
113011
+ return { strategyId: ref2.strategyId, snapshotId: ref2.snapshotId };
112835
113012
  }
112836
- const treeJson = JSON.stringify(tree);
112837
- const compressed = gzipSync3(Buffer.from(treeJson)).toString("base64");
112838
- await session2.backend.mutation(api.workspaceFiles.syncFileTreeV2, {
112839
- sessionId: session2.sessionId,
112840
- machineId: session2.machineId,
112841
- workingDir: normalizedWorkingDir,
112842
- data: { compression: "gzip", content: compressed },
112843
- dataHash,
112844
- scannedAt: tree.scannedAt
112845
- });
112846
- return { snapshotKind: "v2", snapshotId: dataHash };
113013
+ const ref = await publishBlobSnapshot(session2, normalizedWorkingDir, buildBlobSnapshotPayload(tree, dataHash));
113014
+ return { strategyId: ref.strategyId, snapshotId: ref.snapshotId };
112847
113015
  }
112848
113016
  function toDeltaOperations(delta) {
112849
113017
  return [
@@ -112929,12 +113097,12 @@ var startFileTreeSubscriptionEffect = () => exports_Effect.gen(function* () {
112929
113097
  coordinators.set(normalized, coordinatorPromise);
112930
113098
  }
112931
113099
  return coordinatorPromise.then(async (coordinator2) => {
112932
- const checkpoint = await session2.backend.query(api.workspaceFiles.getFileTreeCheckpoint, {
113100
+ const checkpoint2 = await session2.backend.query(api.workspaceFiles.getFileTreeCheckpoint, {
112933
113101
  sessionId: session2.sessionId,
112934
113102
  machineId: session2.machineId,
112935
113103
  workingDir: normalized
112936
113104
  });
112937
- if (checkpoint === null)
113105
+ if (checkpoint2 === null)
112938
113106
  await coordinator2.checkpoint();
112939
113107
  if (forceReconcile)
112940
113108
  await coordinator2.reconcile();
@@ -112943,6 +113111,7 @@ var startFileTreeSubscriptionEffect = () => exports_Effect.gen(function* () {
112943
113111
  };
112944
113112
  return {
112945
113113
  drainPendingFileTreeRequests: () => drainPendingFileTreeRequests(session2, coordinators, ensureCoordinator),
113114
+ drainPendingFileTreeReleaseRequests: () => drainPendingFileTreeReleaseRequests(session2, coordinators),
112946
113115
  stop: () => {
112947
113116
  Promise.all([...coordinators.values()].map((coordinator2) => coordinator2.then((handle) => handle.stop()).catch(() => {
112948
113117
  return;
@@ -112952,11 +113121,12 @@ var startFileTreeSubscriptionEffect = () => exports_Effect.gen(function* () {
112952
113121
  };
112953
113122
  });
112954
113123
  var init_file_tree_subscription = __esm(() => {
113124
+ init_workspace_file_tree();
112955
113125
  init_esm();
112956
113126
  init_api3();
112957
113127
  init_file_tree_data_hash();
112958
- init_file_tree_partition();
112959
- init_file_tree_v3_upload();
113128
+ init_blob_snapshot_publish();
113129
+ init_sharded_snapshot_publish();
112960
113130
  init_workspace_file_tree_coordinator();
112961
113131
  init_convex_error();
112962
113132
  init_daemon_services();
@@ -115250,6 +115420,10 @@ function createDaemonRuntime(deps) {
115250
115420
  if (fileTreeHandle)
115251
115421
  await fileTreeHandle.drainPendingFileTreeRequests();
115252
115422
  break;
115423
+ case "file-tree.release":
115424
+ if (fileTreeHandle)
115425
+ await fileTreeHandle.drainPendingFileTreeReleaseRequests();
115426
+ break;
115253
115427
  case "file-content.request":
115254
115428
  await drainPendingFileContentRequests(session2);
115255
115429
  break;
@@ -115448,6 +115622,7 @@ function createFileRouterDeps() {
115448
115622
  deliverInbound: async (event) => {
115449
115623
  switch (event.type) {
115450
115624
  case "file-tree.request":
115625
+ case "file-tree.release":
115451
115626
  await fulfillFileTreeRequest({ dispatchInbound: dispatchFileInboundEvent }, event);
115452
115627
  break;
115453
115628
  case "file-content.request":
@@ -115955,6 +116130,7 @@ async function routeInboundEvent(deps, event) {
115955
116130
  await handleWorkspaceGitInbound(deps.workspaceGit, event);
115956
116131
  break;
115957
116132
  case "file-tree.request":
116133
+ case "file-tree.release":
115958
116134
  case "file-content.request":
115959
116135
  case "file-write.request":
115960
116136
  await handleFileInbound(deps.file, event);
@@ -116622,24 +116798,51 @@ var init_enhancer_job = __esm(() => {
116622
116798
  init_api3();
116623
116799
  });
116624
116800
 
116625
- // src/daemon/infrastructure/convex/subscribers/file-content-request.ts
116626
- function requestId(req) {
116801
+ // src/daemon/infrastructure/convex/subscribers/pending-file-request-dedup.ts
116802
+ function pendingConvexId(req) {
116803
+ if (req._id == null)
116804
+ return "unknown";
116627
116805
  return typeof req._id === "string" ? req._id : req._id.toString();
116628
116806
  }
116807
+ function isPendingRowWithId(req) {
116808
+ return req != null && typeof req === "object" && "_id" in req;
116809
+ }
116810
+ function pruneStaleSnapshotIds(last2, requests) {
116811
+ const active2 = new Set(requests.filter(isPendingRowWithId).map((req) => pendingConvexId(req)));
116812
+ for (const id3 of last2.keys()) {
116813
+ if (!active2.has(id3))
116814
+ last2.delete(id3);
116815
+ }
116816
+ }
116817
+ function drainPendingRequestSnapshotDedup(requests, last2, getSnapshot) {
116818
+ if (!requests?.length) {
116819
+ last2.clear();
116820
+ return [];
116821
+ }
116822
+ const emitted = [];
116823
+ for (const req of requests) {
116824
+ if (!isPendingRowWithId(req))
116825
+ continue;
116826
+ const id3 = pendingConvexId(req);
116827
+ const snapshot = getSnapshot(req);
116828
+ if (last2.get(id3) === snapshot)
116829
+ continue;
116830
+ last2.set(id3, snapshot);
116831
+ emitted.push(id3);
116832
+ }
116833
+ pruneStaleSnapshotIds(last2, requests);
116834
+ return emitted;
116835
+ }
116836
+
116837
+ // src/daemon/infrastructure/convex/subscribers/file-content-request.ts
116838
+ function contentRequestSnapshot(req) {
116839
+ return `${pendingConvexId(req)}:${req.workingDir ?? ""}:${req.filePath ?? ""}:${req.updatedAt ?? 0}`;
116840
+ }
116629
116841
  function startFileContentRequestSubscriber(deps, onEvent) {
116630
- const seen = new Set;
116842
+ const last2 = new Map;
116631
116843
  const unsub = deps.wsClient.onUpdate(api.workspaceFiles.getPendingFileContentRequests, { sessionId: deps.sessionId, machineId: deps.machineId }, (requests) => {
116632
- if (!requests?.length)
116633
- return;
116634
- for (const req of requests) {
116635
- if (req == null || typeof req !== "object" || !("_id" in req))
116636
- continue;
116637
- const id3 = requestId(req);
116638
- if (seen.has(id3))
116639
- continue;
116640
- seen.add(id3);
116844
+ for (const id3 of drainPendingRequestSnapshotDedup(requests, last2, contentRequestSnapshot))
116641
116845
  onEvent({ type: "file-content.request", requestId: id3 });
116642
- }
116643
116846
  }, (err) => {
116644
116847
  console.warn(`[daemon] file-content-request subscriber error: ${err instanceof Error ? err.message : String(err)}`);
116645
116848
  });
@@ -116653,24 +116856,67 @@ var init_file_content_request = __esm(() => {
116653
116856
  init_api3();
116654
116857
  });
116655
116858
 
116859
+ // src/daemon/infrastructure/convex/subscribers/file-tree-release-request.ts
116860
+ function requestId(req) {
116861
+ if (req._id == null)
116862
+ return "unknown";
116863
+ return typeof req._id === "string" ? req._id : req._id.toString();
116864
+ }
116865
+ function pendingReleasesSnapshot(requests) {
116866
+ return requests.filter((req) => req != null && typeof req === "object").map((req) => `${requestId(req)}:${req.workingDir ?? ""}:${req.updatedAt ?? 0}`).sort().join("|");
116867
+ }
116868
+ function startFileTreeReleaseRequestSubscriber(deps, onEvent) {
116869
+ let lastSnapshot = "";
116870
+ const unsub = deps.wsClient.onUpdate(api.workspaceFiles.getPendingFileTreeReleaseRequests, { sessionId: deps.sessionId, machineId: deps.machineId }, (requests) => {
116871
+ if (!requests?.length) {
116872
+ lastSnapshot = "";
116873
+ return;
116874
+ }
116875
+ const snapshot = pendingReleasesSnapshot(requests);
116876
+ if (!snapshot || snapshot === lastSnapshot)
116877
+ return;
116878
+ lastSnapshot = snapshot;
116879
+ const first = requests.find((req) => req != null && typeof req === "object");
116880
+ if (!first)
116881
+ return;
116882
+ onEvent({ type: "file-tree.release", requestId: requestId(first) });
116883
+ }, (err) => {
116884
+ console.warn(`[daemon] file-tree-release subscriber error: ${err instanceof Error ? err.message : String(err)}`);
116885
+ });
116886
+ return {
116887
+ async stop() {
116888
+ unsub();
116889
+ }
116890
+ };
116891
+ }
116892
+ var init_file_tree_release_request = __esm(() => {
116893
+ init_api3();
116894
+ });
116895
+
116656
116896
  // src/daemon/infrastructure/convex/subscribers/file-tree-request.ts
116657
116897
  function requestId2(req) {
116898
+ if (req._id == null)
116899
+ return "unknown";
116658
116900
  return typeof req._id === "string" ? req._id : req._id.toString();
116659
116901
  }
116902
+ function pendingRequestsSnapshot(requests) {
116903
+ return requests.filter((req) => req != null && typeof req === "object").map((req) => `${requestId2(req)}:${req.workingDir ?? ""}:${req.force ? "1" : "0"}:${req.updatedAt ?? 0}`).sort().join("|");
116904
+ }
116660
116905
  function startFileTreeRequestSubscriber(deps, onEvent) {
116661
- const seen = new Set;
116906
+ let lastSnapshot = "";
116662
116907
  const unsub = deps.wsClient.onUpdate(api.workspaceFiles.getPendingFileTreeRequests, { sessionId: deps.sessionId, machineId: deps.machineId }, (requests) => {
116663
- if (!requests?.length)
116908
+ if (!requests?.length) {
116909
+ lastSnapshot = "";
116664
116910
  return;
116665
- for (const req of requests) {
116666
- if (req == null || typeof req !== "object" || !("_id" in req))
116667
- continue;
116668
- const id3 = requestId2(req);
116669
- if (seen.has(id3))
116670
- continue;
116671
- seen.add(id3);
116672
- onEvent({ type: "file-tree.request", requestId: id3 });
116673
116911
  }
116912
+ const snapshot = pendingRequestsSnapshot(requests);
116913
+ if (!snapshot || snapshot === lastSnapshot)
116914
+ return;
116915
+ lastSnapshot = snapshot;
116916
+ const first = requests.find((req) => req != null && typeof req === "object");
116917
+ if (!first)
116918
+ return;
116919
+ onEvent({ type: "file-tree.request", requestId: requestId2(first) });
116674
116920
  }, (err) => {
116675
116921
  console.warn(`[daemon] file-tree-request subscriber error: ${err instanceof Error ? err.message : String(err)}`);
116676
116922
  });
@@ -116685,23 +116931,14 @@ var init_file_tree_request = __esm(() => {
116685
116931
  });
116686
116932
 
116687
116933
  // src/daemon/infrastructure/convex/subscribers/file-write-request.ts
116688
- function requestId3(req) {
116689
- return typeof req._id === "string" ? req._id : req._id.toString();
116934
+ function writeRequestSnapshot(req) {
116935
+ return `${pendingConvexId(req)}:${req.workingDir ?? ""}:${req.filePath ?? ""}:${req.revision ?? 0}:${req.updatedAt ?? 0}`;
116690
116936
  }
116691
116937
  function startFileWriteRequestSubscriber(deps, onEvent) {
116692
- const seen = new Set;
116938
+ const last2 = new Map;
116693
116939
  const unsub = deps.wsClient.onUpdate(api.workspaceFiles.getPendingFileWriteRequests, { sessionId: deps.sessionId, machineId: deps.machineId }, (requests) => {
116694
- if (!requests?.length)
116695
- return;
116696
- for (const req of requests) {
116697
- if (req == null || typeof req !== "object" || !("_id" in req))
116698
- continue;
116699
- const id3 = requestId3(req);
116700
- if (seen.has(id3))
116701
- continue;
116702
- seen.add(id3);
116940
+ for (const id3 of drainPendingRequestSnapshotDedup(requests, last2, writeRequestSnapshot))
116703
116941
  onEvent({ type: "file-write.request", requestId: id3 });
116704
- }
116705
116942
  }, (err) => {
116706
116943
  console.warn(`[daemon] file-write-request subscriber error: ${err instanceof Error ? err.message : String(err)}`);
116707
116944
  });
@@ -116716,7 +116953,7 @@ var init_file_write_request = __esm(() => {
116716
116953
  });
116717
116954
 
116718
116955
  // src/daemon/infrastructure/convex/subscribers/git-request.ts
116719
- function requestId4(req) {
116956
+ function requestId3(req) {
116720
116957
  return typeof req._id === "string" ? req._id : req._id.toString();
116721
116958
  }
116722
116959
  function startGitRequestSubscriber(deps, onEvent) {
@@ -116727,7 +116964,7 @@ function startGitRequestSubscriber(deps, onEvent) {
116727
116964
  for (const req of requests) {
116728
116965
  if (req == null || typeof req !== "object" || !("_id" in req))
116729
116966
  continue;
116730
- const id3 = requestId4(req);
116967
+ const id3 = requestId3(req);
116731
116968
  if (seen.has(id3))
116732
116969
  continue;
116733
116970
  seen.add(id3);
@@ -116791,6 +117028,7 @@ function startAllSubscribers(deps) {
116791
117028
  const workspaceList = startWorkspaceListSubscriber(deps, onEvent);
116792
117029
  const gitRequest = startGitRequestSubscriber(deps, onEvent);
116793
117030
  const fileTree = startFileTreeRequestSubscriber(deps, onEvent);
117031
+ const fileTreeRelease = startFileTreeReleaseRequestSubscriber(deps, onEvent);
116794
117032
  const fileContent = startFileContentRequestSubscriber(deps, onEvent);
116795
117033
  const fileWrite = startFileWriteRequestSubscriber(deps, onEvent);
116796
117034
  const agenticQuerySession = startAgenticQuerySessionSubscriber(deps, onEvent);
@@ -116809,6 +117047,7 @@ function startAllSubscribers(deps) {
116809
117047
  workspaceList.stop(),
116810
117048
  gitRequest.stop(),
116811
117049
  fileTree.stop(),
117050
+ fileTreeRelease.stop(),
116812
117051
  fileContent.stop(),
116813
117052
  fileWrite.stop(),
116814
117053
  agenticQuerySession.stop(),
@@ -116831,6 +117070,7 @@ var init_subscriber_registry = __esm(() => {
116831
117070
  init_direct_harness_session();
116832
117071
  init_enhancer_job();
116833
117072
  init_file_content_request();
117073
+ init_file_tree_release_request();
116834
117074
  init_file_tree_request();
116835
117075
  init_file_write_request();
116836
117076
  init_git_request();
@@ -117676,23 +117916,23 @@ var require_accepts = __commonJS((exports, module) => {
117676
117916
  this.negotiator = new Negotiator(req);
117677
117917
  }
117678
117918
  Accepts.prototype.type = Accepts.prototype.types = function(types_) {
117679
- var types2 = types_;
117680
- if (types2 && !Array.isArray(types2)) {
117681
- types2 = new Array(arguments.length);
117682
- for (var i2 = 0;i2 < types2.length; i2++) {
117683
- types2[i2] = arguments[i2];
117919
+ var types3 = types_;
117920
+ if (types3 && !Array.isArray(types3)) {
117921
+ types3 = new Array(arguments.length);
117922
+ for (var i2 = 0;i2 < types3.length; i2++) {
117923
+ types3[i2] = arguments[i2];
117684
117924
  }
117685
117925
  }
117686
- if (!types2 || types2.length === 0) {
117926
+ if (!types3 || types3.length === 0) {
117687
117927
  return this.negotiator.mediaTypes();
117688
117928
  }
117689
117929
  if (!this.headers.accept) {
117690
- return types2[0];
117930
+ return types3[0];
117691
117931
  }
117692
- var mimes = types2.map(extToMime);
117932
+ var mimes = types3.map(extToMime);
117693
117933
  var accepts = this.negotiator.mediaTypes(mimes.filter(validMime));
117694
117934
  var first = accepts[0];
117695
- return first ? types2[mimes.indexOf(first)] : false;
117935
+ return first ? types3[mimes.indexOf(first)] : false;
117696
117936
  };
117697
117937
  Accepts.prototype.encoding = Accepts.prototype.encodings = function(encodings_) {
117698
117938
  var encodings = encodings_;
@@ -119050,7 +119290,7 @@ var require_socket = __commonJS((exports) => {
119050
119290
  debug2("readyState updated from %s to %s", this._readyState, state);
119051
119291
  this._readyState = state;
119052
119292
  }
119053
- constructor(id3, server2, transport, req, protocol) {
119293
+ constructor(id3, server2, transport2, req, protocol) {
119054
119294
  super();
119055
119295
  this._readyState = "opening";
119056
119296
  this.upgrading = false;
@@ -119072,7 +119312,7 @@ var require_socket = __commonJS((exports) => {
119072
119312
  }
119073
119313
  this.pingTimeoutTimer = null;
119074
119314
  this.pingIntervalTimer = null;
119075
- this.setTransport(transport);
119315
+ this.setTransport(transport2);
119076
119316
  this.onOpen();
119077
119317
  }
119078
119318
  onOpen() {
@@ -119150,24 +119390,24 @@ var require_socket = __commonJS((exports) => {
119150
119390
  this.onClose("ping timeout");
119151
119391
  }, this.protocol === 3 ? this.server.opts.pingInterval + this.server.opts.pingTimeout : this.server.opts.pingTimeout);
119152
119392
  }
119153
- setTransport(transport) {
119393
+ setTransport(transport2) {
119154
119394
  const onError3 = this.onError.bind(this);
119155
119395
  const onReady = () => this.flush();
119156
119396
  const onPacket = this.onPacket.bind(this);
119157
119397
  const onDrain = this.onDrain.bind(this);
119158
119398
  const onClose = this.onClose.bind(this, "transport close");
119159
- this.transport = transport;
119399
+ this.transport = transport2;
119160
119400
  this.transport.once("error", onError3);
119161
119401
  this.transport.on("ready", onReady);
119162
119402
  this.transport.on("packet", onPacket);
119163
119403
  this.transport.on("drain", onDrain);
119164
119404
  this.transport.once("close", onClose);
119165
119405
  this.cleanupFn.push(function() {
119166
- transport.removeListener("error", onError3);
119167
- transport.removeListener("ready", onReady);
119168
- transport.removeListener("packet", onPacket);
119169
- transport.removeListener("drain", onDrain);
119170
- transport.removeListener("close", onClose);
119406
+ transport2.removeListener("error", onError3);
119407
+ transport2.removeListener("ready", onReady);
119408
+ transport2.removeListener("packet", onPacket);
119409
+ transport2.removeListener("drain", onDrain);
119410
+ transport2.removeListener("close", onClose);
119171
119411
  });
119172
119412
  }
119173
119413
  onDrain() {
@@ -119181,22 +119421,22 @@ var require_socket = __commonJS((exports) => {
119181
119421
  }
119182
119422
  }
119183
119423
  }
119184
- _maybeUpgrade(transport) {
119185
- debug2('might upgrade socket transport from "%s" to "%s"', this.transport.name, transport.name);
119424
+ _maybeUpgrade(transport2) {
119425
+ debug2('might upgrade socket transport from "%s" to "%s"', this.transport.name, transport2.name);
119186
119426
  this.upgrading = true;
119187
119427
  const upgradeTimeoutTimer = (0, timers_1.setTimeout)(() => {
119188
119428
  debug2("client did not complete upgrade - closing transport");
119189
119429
  cleanup();
119190
- if (transport.readyState === "open") {
119191
- transport.close();
119430
+ if (transport2.readyState === "open") {
119431
+ transport2.close();
119192
119432
  }
119193
119433
  }, this.server.opts.upgradeTimeout);
119194
119434
  let checkIntervalTimer;
119195
119435
  const onPacket = (packet) => {
119196
119436
  if (packet.type === "ping" && packet.data === "probe") {
119197
119437
  debug2("got probe ping packet, sending pong");
119198
- transport.send([{ type: "pong", data: "probe" }]);
119199
- this.emit("upgrading", transport);
119438
+ transport2.send([{ type: "pong", data: "probe" }]);
119439
+ this.emit("upgrading", transport2);
119200
119440
  clearInterval(checkIntervalTimer);
119201
119441
  checkIntervalTimer = setInterval(check4, 100);
119202
119442
  } else if (packet.type === "upgrade" && this.readyState !== "closed") {
@@ -119205,17 +119445,17 @@ var require_socket = __commonJS((exports) => {
119205
119445
  this.transport.discard();
119206
119446
  this.upgraded = true;
119207
119447
  this.clearTransport();
119208
- this.setTransport(transport);
119209
- this.emit("upgrade", transport);
119448
+ this.setTransport(transport2);
119449
+ this.emit("upgrade", transport2);
119210
119450
  this.flush();
119211
119451
  if (this.readyState === "closing") {
119212
- transport.close(() => {
119452
+ transport2.close(() => {
119213
119453
  this.onClose("forced close");
119214
119454
  });
119215
119455
  }
119216
119456
  } else {
119217
119457
  cleanup();
119218
- transport.close();
119458
+ transport2.close();
119219
119459
  }
119220
119460
  };
119221
119461
  const check4 = () => {
@@ -119228,16 +119468,16 @@ var require_socket = __commonJS((exports) => {
119228
119468
  this.upgrading = false;
119229
119469
  clearInterval(checkIntervalTimer);
119230
119470
  (0, timers_1.clearTimeout)(upgradeTimeoutTimer);
119231
- transport.removeListener("packet", onPacket);
119232
- transport.removeListener("close", onTransportClose);
119233
- transport.removeListener("error", onError3);
119471
+ transport2.removeListener("packet", onPacket);
119472
+ transport2.removeListener("close", onTransportClose);
119473
+ transport2.removeListener("error", onError3);
119234
119474
  this.removeListener("close", onClose);
119235
119475
  };
119236
119476
  const onError3 = (err) => {
119237
119477
  debug2("client did not complete upgrade - %s", err);
119238
119478
  cleanup();
119239
- transport.close();
119240
- transport = null;
119479
+ transport2.close();
119480
+ transport2 = null;
119241
119481
  };
119242
119482
  const onTransportClose = () => {
119243
119483
  onError3("transport closed");
@@ -119245,9 +119485,9 @@ var require_socket = __commonJS((exports) => {
119245
119485
  const onClose = () => {
119246
119486
  onError3("socket closed");
119247
119487
  };
119248
- transport.on("packet", onPacket);
119249
- transport.once("close", onTransportClose);
119250
- transport.once("error", onError3);
119488
+ transport2.on("packet", onPacket);
119489
+ transport2.once("close", onTransportClose);
119490
+ transport2.once("error", onError3);
119251
119491
  this.once("close", onClose);
119252
119492
  }
119253
119493
  clearTransport() {
@@ -122861,16 +123101,16 @@ var require_server = __commonJS((exports) => {
122861
123101
  }
122862
123102
  return path8;
122863
123103
  }
122864
- upgrades(transport) {
123104
+ upgrades(transport2) {
122865
123105
  if (!this.opts.allowUpgrades)
122866
123106
  return [];
122867
- return transports_1.default[transport].upgradesTo || [];
123107
+ return transports_1.default[transport2].upgradesTo || [];
122868
123108
  }
122869
123109
  verify(req, upgrade, fn2) {
122870
- const transport = req._query.transport;
122871
- if (!~this.opts.transports.indexOf(transport) || transport === "webtransport") {
122872
- debug2('unknown transport "%s"', transport);
122873
- return fn2(Server.errors.UNKNOWN_TRANSPORT, { transport });
123110
+ const transport2 = req._query.transport;
123111
+ if (!~this.opts.transports.indexOf(transport2) || transport2 === "webtransport") {
123112
+ debug2('unknown transport "%s"', transport2);
123113
+ return fn2(Server.errors.UNKNOWN_TRANSPORT, { transport: transport2 });
122874
123114
  }
122875
123115
  const isOriginInvalid = checkInvalidHeaderChar(req.headers.origin);
122876
123116
  if (isOriginInvalid) {
@@ -122891,11 +123131,11 @@ var require_server = __commonJS((exports) => {
122891
123131
  });
122892
123132
  }
122893
123133
  const previousTransport = this.clients[sid].transport.name;
122894
- if (!upgrade && previousTransport !== transport) {
123134
+ if (!upgrade && previousTransport !== transport2) {
122895
123135
  debug2("bad request: unexpected transport without upgrade");
122896
123136
  return fn2(Server.errors.BAD_REQUEST, {
122897
123137
  name: "TRANSPORT_MISMATCH",
122898
- transport,
123138
+ transport: transport2,
122899
123139
  previousTransport
122900
123140
  });
122901
123141
  }
@@ -122905,7 +123145,7 @@ var require_server = __commonJS((exports) => {
122905
123145
  method: req.method
122906
123146
  });
122907
123147
  }
122908
- if (transport === "websocket" && !upgrade) {
123148
+ if (transport2 === "websocket" && !upgrade) {
122909
123149
  debug2("invalid transport upgrade");
122910
123150
  return fn2(Server.errors.BAD_REQUEST, {
122911
123151
  name: "TRANSPORT_HANDSHAKE_ERROR"
@@ -122994,12 +123234,12 @@ var require_server = __commonJS((exports) => {
122994
123234
  }
122995
123235
  debug2('handshaking client "%s"', id3);
122996
123236
  try {
122997
- var transport = this.createTransport(transportName, req);
123237
+ var transport2 = this.createTransport(transportName, req);
122998
123238
  if (transportName === "polling") {
122999
- transport.maxHttpBufferSize = this.opts.maxHttpBufferSize;
123000
- transport.httpCompression = this.opts.httpCompression;
123239
+ transport2.maxHttpBufferSize = this.opts.maxHttpBufferSize;
123240
+ transport2.httpCompression = this.opts.httpCompression;
123001
123241
  } else if (transportName === "websocket") {
123002
- transport.perMessageDeflate = this.opts.perMessageDeflate;
123242
+ transport2.perMessageDeflate = this.opts.perMessageDeflate;
123003
123243
  }
123004
123244
  } catch (e) {
123005
123245
  debug2('error handshaking to transport "%s"', transportName);
@@ -123015,8 +123255,8 @@ var require_server = __commonJS((exports) => {
123015
123255
  closeConnection(Server.errors.BAD_REQUEST);
123016
123256
  return;
123017
123257
  }
123018
- const socket = new socket_1.Socket(id3, this, transport, req, protocol);
123019
- transport.on("headers", (headers, req2) => {
123258
+ const socket = new socket_1.Socket(id3, this, transport2, req, protocol);
123259
+ transport2.on("headers", (headers, req2) => {
123020
123260
  const isInitialRequest = !req2._query.sid;
123021
123261
  if (isInitialRequest) {
123022
123262
  if (this.opts.cookie) {
@@ -123028,7 +123268,7 @@ var require_server = __commonJS((exports) => {
123028
123268
  }
123029
123269
  this.emit("headers", headers, req2);
123030
123270
  });
123031
- transport.onRequest(req);
123271
+ transport2.onRequest(req);
123032
123272
  this.clients[id3] = socket;
123033
123273
  this.clientsCount++;
123034
123274
  socket.once("close", () => {
@@ -123036,7 +123276,7 @@ var require_server = __commonJS((exports) => {
123036
123276
  this.clientsCount--;
123037
123277
  });
123038
123278
  this.emit("connection", socket);
123039
- return transport;
123279
+ return transport2;
123040
123280
  }
123041
123281
  async onWebTransportSession(session2) {
123042
123282
  if (this.middlewares.length > 0) {
@@ -123078,10 +123318,10 @@ var require_server = __commonJS((exports) => {
123078
123318
  return closeSession2();
123079
123319
  }
123080
123320
  if (value.data === undefined) {
123081
- const transport = new webtransport_1.WebTransport(session2, stream4, reader);
123321
+ const transport2 = new webtransport_1.WebTransport(session2, stream4, reader);
123082
123322
  const id3 = base64id.generateId();
123083
123323
  debug2('handshaking client "%s" (WebTransport)', id3);
123084
- const socket = new socket_1.Socket(id3, this, transport, null, 4);
123324
+ const socket = new socket_1.Socket(id3, this, transport2, null, 4);
123085
123325
  this.clients[id3] = socket;
123086
123326
  this.clientsCount++;
123087
123327
  socket.once("close", () => {
@@ -123108,8 +123348,8 @@ var require_server = __commonJS((exports) => {
123108
123348
  return closeSession2();
123109
123349
  } else {
123110
123350
  debug2("upgrading existing transport");
123111
- const transport = new webtransport_1.WebTransport(session2, stream4, reader);
123112
- client4._maybeUpgrade(transport);
123351
+ const transport2 = new webtransport_1.WebTransport(session2, stream4, reader);
123352
+ client4._maybeUpgrade(transport2);
123113
123353
  }
123114
123354
  }
123115
123355
  }
@@ -123281,9 +123521,9 @@ var require_server = __commonJS((exports) => {
123281
123521
  } else {
123282
123522
  debug2("upgrading existing transport");
123283
123523
  websocket.removeListener("error", onUpgradeError);
123284
- const transport = this.createTransport(req._query.transport, req);
123285
- transport.perMessageDeflate = this.opts.perMessageDeflate;
123286
- client4._maybeUpgrade(transport);
123524
+ const transport2 = this.createTransport(req._query.transport, req);
123525
+ transport2.perMessageDeflate = this.opts.perMessageDeflate;
123526
+ client4._maybeUpgrade(transport2);
123287
123527
  }
123288
123528
  } else {
123289
123529
  const closeConnection = (errorCode, errorContext) => abortUpgrade(socket, errorCode, errorContext);
@@ -124029,10 +124269,10 @@ var require_userver = __commonJS((exports) => {
124029
124269
  maxPayloadLength: this.opts.maxHttpBufferSize,
124030
124270
  upgrade: this.handleUpgrade.bind(this),
124031
124271
  open: (ws) => {
124032
- const transport = ws.getUserData().transport;
124033
- transport.socket = ws;
124034
- transport.writable = true;
124035
- transport.emit("ready");
124272
+ const transport2 = ws.getUserData().transport;
124273
+ transport2.socket = ws;
124274
+ transport2.writable = true;
124275
+ transport2.emit("ready");
124036
124276
  },
124037
124277
  message: (ws, message, isBinary) => {
124038
124278
  ws.getUserData().transport.onData(isBinary ? message : Buffer.from(message).toString());
@@ -124099,7 +124339,7 @@ var require_userver = __commonJS((exports) => {
124099
124339
  return;
124100
124340
  }
124101
124341
  const id3 = req._query.sid;
124102
- let transport;
124342
+ let transport2;
124103
124343
  if (id3) {
124104
124344
  const client4 = this.clients[id3];
124105
124345
  if (!client4) {
@@ -124113,12 +124353,12 @@ var require_userver = __commonJS((exports) => {
124113
124353
  return res.close();
124114
124354
  } else {
124115
124355
  debug2("upgrading existing transport");
124116
- transport = this.createTransport(req._query.transport, req);
124117
- client4._maybeUpgrade(transport);
124356
+ transport2 = this.createTransport(req._query.transport, req);
124357
+ client4._maybeUpgrade(transport2);
124118
124358
  }
124119
124359
  } else {
124120
- transport = await this.handshake(req._query.transport, req, (errorCode2, errorContext2) => this.abortRequest(res, errorCode2, errorContext2));
124121
- if (!transport) {
124360
+ transport2 = await this.handshake(req._query.transport, req, (errorCode2, errorContext2) => this.abortRequest(res, errorCode2, errorContext2));
124361
+ if (!transport2) {
124122
124362
  return;
124123
124363
  }
124124
124364
  }
@@ -124133,7 +124373,7 @@ var require_userver = __commonJS((exports) => {
124133
124373
  req.res.writeHeader(key, additionalHeaders[key]);
124134
124374
  });
124135
124375
  res.upgrade({
124136
- transport
124376
+ transport: transport2
124137
124377
  }, req.getHeader("sec-websocket-key"), req.getHeader("sec-websocket-protocol"), req.getHeader("sec-websocket-extensions"), context5);
124138
124378
  };
124139
124379
  this._applyMiddlewares(req, res, (err) => {
@@ -126253,19 +126493,19 @@ var require_cluster_adapter = __commonJS((exports) => {
126253
126493
  }
126254
126494
  onResponse(response) {
126255
126495
  var _a4, _b2;
126256
- const requestId5 = response.data.requestId;
126257
- debug2("[%s] received response %s to request %s", this.uid, response.type, requestId5);
126496
+ const requestId4 = response.data.requestId;
126497
+ debug2("[%s] received response %s to request %s", this.uid, response.type, requestId4);
126258
126498
  switch (response.type) {
126259
126499
  case MessageType.BROADCAST_CLIENT_COUNT: {
126260
- (_a4 = this.ackRequests.get(requestId5)) === null || _a4 === undefined || _a4.clientCountCallback(response.data.clientCount);
126500
+ (_a4 = this.ackRequests.get(requestId4)) === null || _a4 === undefined || _a4.clientCountCallback(response.data.clientCount);
126261
126501
  break;
126262
126502
  }
126263
126503
  case MessageType.BROADCAST_ACK: {
126264
- (_b2 = this.ackRequests.get(requestId5)) === null || _b2 === undefined || _b2.ack(response.data.packet);
126504
+ (_b2 = this.ackRequests.get(requestId4)) === null || _b2 === undefined || _b2.ack(response.data.packet);
126265
126505
  break;
126266
126506
  }
126267
126507
  case MessageType.FETCH_SOCKETS_RESPONSE: {
126268
- const request2 = this.requests.get(requestId5);
126508
+ const request2 = this.requests.get(requestId4);
126269
126509
  if (!request2) {
126270
126510
  return;
126271
126511
  }
@@ -126274,12 +126514,12 @@ var require_cluster_adapter = __commonJS((exports) => {
126274
126514
  if (request2.current === request2.expected) {
126275
126515
  clearTimeout(request2.timeout);
126276
126516
  request2.resolve(request2.responses);
126277
- this.requests.delete(requestId5);
126517
+ this.requests.delete(requestId4);
126278
126518
  }
126279
126519
  break;
126280
126520
  }
126281
126521
  case MessageType.SERVER_SIDE_EMIT_RESPONSE: {
126282
- const request2 = this.requests.get(requestId5);
126522
+ const request2 = this.requests.get(requestId4);
126283
126523
  if (!request2) {
126284
126524
  return;
126285
126525
  }
@@ -126288,7 +126528,7 @@ var require_cluster_adapter = __commonJS((exports) => {
126288
126528
  if (request2.current === request2.expected) {
126289
126529
  clearTimeout(request2.timeout);
126290
126530
  request2.resolve(null, request2.responses);
126291
- this.requests.delete(requestId5);
126531
+ this.requests.delete(requestId4);
126292
126532
  }
126293
126533
  break;
126294
126534
  }
@@ -126331,8 +126571,8 @@ var require_cluster_adapter = __commonJS((exports) => {
126331
126571
  var _a4;
126332
126572
  const onlyLocal = (_a4 = opts === null || opts === undefined ? undefined : opts.flags) === null || _a4 === undefined ? undefined : _a4.local;
126333
126573
  if (!onlyLocal) {
126334
- const requestId5 = randomId();
126335
- this.ackRequests.set(requestId5, {
126574
+ const requestId4 = randomId();
126575
+ this.ackRequests.set(requestId4, {
126336
126576
  clientCountCallback,
126337
126577
  ack
126338
126578
  });
@@ -126340,12 +126580,12 @@ var require_cluster_adapter = __commonJS((exports) => {
126340
126580
  type: MessageType.BROADCAST,
126341
126581
  data: {
126342
126582
  packet,
126343
- requestId: requestId5,
126583
+ requestId: requestId4,
126344
126584
  opts: encodeOptions(opts)
126345
126585
  }
126346
126586
  });
126347
126587
  setTimeout(() => {
126348
- this.ackRequests.delete(requestId5);
126588
+ this.ackRequests.delete(requestId4);
126349
126589
  }, opts.flags.timeout);
126350
126590
  }
126351
126591
  super.broadcastWithAck(packet, opts, clientCountCallback, ack);
@@ -126414,13 +126654,13 @@ var require_cluster_adapter = __commonJS((exports) => {
126414
126654
  if (((_a4 = opts.flags) === null || _a4 === undefined ? undefined : _a4.local) || expectedResponseCount <= 0) {
126415
126655
  return localSockets;
126416
126656
  }
126417
- const requestId5 = randomId();
126657
+ const requestId4 = randomId();
126418
126658
  return new Promise((resolve8, reject) => {
126419
126659
  const timeout3 = setTimeout(() => {
126420
- const storedRequest2 = this.requests.get(requestId5);
126660
+ const storedRequest2 = this.requests.get(requestId4);
126421
126661
  if (storedRequest2) {
126422
126662
  reject(new Error(`timeout reached: only ${storedRequest2.current} responses received out of ${storedRequest2.expected}`));
126423
- this.requests.delete(requestId5);
126663
+ this.requests.delete(requestId4);
126424
126664
  }
126425
126665
  }, opts.flags.timeout || DEFAULT_TIMEOUT);
126426
126666
  const storedRequest = {
@@ -126431,12 +126671,12 @@ var require_cluster_adapter = __commonJS((exports) => {
126431
126671
  expected: expectedResponseCount,
126432
126672
  responses: localSockets
126433
126673
  };
126434
- this.requests.set(requestId5, storedRequest);
126674
+ this.requests.set(requestId4, storedRequest);
126435
126675
  this.publish({
126436
126676
  type: MessageType.FETCH_SOCKETS,
126437
126677
  data: {
126438
126678
  opts: encodeOptions(opts),
126439
- requestId: requestId5
126679
+ requestId: requestId4
126440
126680
  }
126441
126681
  });
126442
126682
  });
@@ -126457,12 +126697,12 @@ var require_cluster_adapter = __commonJS((exports) => {
126457
126697
  if (expectedResponseCount <= 0) {
126458
126698
  return ack(null, []);
126459
126699
  }
126460
- const requestId5 = randomId();
126700
+ const requestId4 = randomId();
126461
126701
  const timeout3 = setTimeout(() => {
126462
- const storedRequest2 = this.requests.get(requestId5);
126702
+ const storedRequest2 = this.requests.get(requestId4);
126463
126703
  if (storedRequest2) {
126464
126704
  ack(new Error(`timeout reached: only ${storedRequest2.current} responses received out of ${storedRequest2.expected}`), storedRequest2.responses);
126465
- this.requests.delete(requestId5);
126705
+ this.requests.delete(requestId4);
126466
126706
  }
126467
126707
  }, DEFAULT_TIMEOUT);
126468
126708
  const storedRequest = {
@@ -126473,11 +126713,11 @@ var require_cluster_adapter = __commonJS((exports) => {
126473
126713
  expected: expectedResponseCount,
126474
126714
  responses: []
126475
126715
  };
126476
- this.requests.set(requestId5, storedRequest);
126716
+ this.requests.set(requestId4, storedRequest);
126477
126717
  this.publish({
126478
126718
  type: MessageType.SERVER_SIDE_EMIT,
126479
126719
  data: {
126480
- requestId: requestId5,
126720
+ requestId: requestId4,
126481
126721
  packet
126482
126722
  }
126483
126723
  });
@@ -126594,12 +126834,12 @@ var require_cluster_adapter = __commonJS((exports) => {
126594
126834
  if (expectedResponseCount <= 0) {
126595
126835
  return ack(null, []);
126596
126836
  }
126597
- const requestId5 = randomId();
126837
+ const requestId4 = randomId();
126598
126838
  const timeout3 = setTimeout(() => {
126599
- const storedRequest2 = this.customRequests.get(requestId5);
126839
+ const storedRequest2 = this.customRequests.get(requestId4);
126600
126840
  if (storedRequest2) {
126601
126841
  ack(new Error(`timeout reached: missing ${storedRequest2.missingUids.size} responses`), storedRequest2.responses);
126602
- this.customRequests.delete(requestId5);
126842
+ this.customRequests.delete(requestId4);
126603
126843
  }
126604
126844
  }, DEFAULT_TIMEOUT);
126605
126845
  const storedRequest = {
@@ -126609,11 +126849,11 @@ var require_cluster_adapter = __commonJS((exports) => {
126609
126849
  missingUids: new Set([...this.nodesMap.keys()]),
126610
126850
  responses: []
126611
126851
  };
126612
- this.customRequests.set(requestId5, storedRequest);
126852
+ this.customRequests.set(requestId4, storedRequest);
126613
126853
  this.publish({
126614
126854
  type: MessageType.SERVER_SIDE_EMIT,
126615
126855
  data: {
126616
- requestId: requestId5,
126856
+ requestId: requestId4,
126617
126857
  packet
126618
126858
  }
126619
126859
  });
@@ -126634,13 +126874,13 @@ var require_cluster_adapter = __commonJS((exports) => {
126634
126874
  if (((_a4 = opts.flags) === null || _a4 === undefined ? undefined : _a4.local) || expectedResponseCount <= 0) {
126635
126875
  return localSockets;
126636
126876
  }
126637
- const requestId5 = randomId();
126877
+ const requestId4 = randomId();
126638
126878
  return new Promise((resolve8, reject) => {
126639
126879
  const timeout3 = setTimeout(() => {
126640
- const storedRequest2 = this.customRequests.get(requestId5);
126880
+ const storedRequest2 = this.customRequests.get(requestId4);
126641
126881
  if (storedRequest2) {
126642
126882
  reject(new Error(`timeout reached: missing ${storedRequest2.missingUids.size} responses`));
126643
- this.customRequests.delete(requestId5);
126883
+ this.customRequests.delete(requestId4);
126644
126884
  }
126645
126885
  }, opts.flags.timeout || DEFAULT_TIMEOUT);
126646
126886
  const storedRequest = {
@@ -126650,22 +126890,22 @@ var require_cluster_adapter = __commonJS((exports) => {
126650
126890
  missingUids: new Set([...this.nodesMap.keys()]),
126651
126891
  responses: localSockets
126652
126892
  };
126653
- this.customRequests.set(requestId5, storedRequest);
126893
+ this.customRequests.set(requestId4, storedRequest);
126654
126894
  this.publish({
126655
126895
  type: MessageType.FETCH_SOCKETS,
126656
126896
  data: {
126657
126897
  opts: encodeOptions(opts),
126658
- requestId: requestId5
126898
+ requestId: requestId4
126659
126899
  }
126660
126900
  });
126661
126901
  });
126662
126902
  }
126663
126903
  onResponse(response) {
126664
- const requestId5 = response.data.requestId;
126665
- debug2("[%s] received response %s to request %s", this.uid, response.type, requestId5);
126904
+ const requestId4 = response.data.requestId;
126905
+ debug2("[%s] received response %s to request %s", this.uid, response.type, requestId4);
126666
126906
  switch (response.type) {
126667
126907
  case MessageType.FETCH_SOCKETS_RESPONSE: {
126668
- const request2 = this.customRequests.get(requestId5);
126908
+ const request2 = this.customRequests.get(requestId4);
126669
126909
  if (!request2) {
126670
126910
  return;
126671
126911
  }
@@ -126674,12 +126914,12 @@ var require_cluster_adapter = __commonJS((exports) => {
126674
126914
  if (request2.missingUids.size === 0) {
126675
126915
  clearTimeout(request2.timeout);
126676
126916
  request2.resolve(request2.responses);
126677
- this.customRequests.delete(requestId5);
126917
+ this.customRequests.delete(requestId4);
126678
126918
  }
126679
126919
  break;
126680
126920
  }
126681
126921
  case MessageType.SERVER_SIDE_EMIT_RESPONSE: {
126682
- const request2 = this.customRequests.get(requestId5);
126922
+ const request2 = this.customRequests.get(requestId4);
126683
126923
  if (!request2) {
126684
126924
  return;
126685
126925
  }
@@ -126688,7 +126928,7 @@ var require_cluster_adapter = __commonJS((exports) => {
126688
126928
  if (request2.missingUids.size === 0) {
126689
126929
  clearTimeout(request2.timeout);
126690
126930
  request2.resolve(null, request2.responses);
126691
- this.customRequests.delete(requestId5);
126931
+ this.customRequests.delete(requestId4);
126692
126932
  }
126693
126933
  break;
126694
126934
  }
@@ -126697,7 +126937,7 @@ var require_cluster_adapter = __commonJS((exports) => {
126697
126937
  }
126698
126938
  }
126699
126939
  removeNode(uid) {
126700
- this.customRequests.forEach((request2, requestId5) => {
126940
+ this.customRequests.forEach((request2, requestId4) => {
126701
126941
  request2.missingUids.delete(uid);
126702
126942
  if (request2.missingUids.size === 0) {
126703
126943
  clearTimeout(request2.timeout);
@@ -126706,7 +126946,7 @@ var require_cluster_adapter = __commonJS((exports) => {
126706
126946
  } else if (request2.type === MessageType.SERVER_SIDE_EMIT) {
126707
126947
  request2.resolve(null, request2.responses);
126708
126948
  }
126709
- this.customRequests.delete(requestId5);
126949
+ this.customRequests.delete(requestId4);
126710
126950
  }
126711
126951
  });
126712
126952
  this.nodesMap.delete(uid);
@@ -128098,7 +128338,7 @@ async function isChatroomInstalledDefault() {
128098
128338
  return false;
128099
128339
  }
128100
128340
  }
128101
- async function createDefaultDeps23() {
128341
+ async function createDefaultDeps24() {
128102
128342
  const client4 = await getConvexClient();
128103
128343
  const fs12 = await import("fs/promises");
128104
128344
  return {
@@ -128173,7 +128413,7 @@ After installation, run this command again.`;
128173
128413
  });
128174
128414
  }
128175
128415
  async function installTool(options = {}, deps) {
128176
- const d = deps ?? await createDefaultDeps23();
128416
+ const d = deps ?? await createDefaultDeps24();
128177
128417
  const layer = layerFromDeps9(d);
128178
128418
  return exports_Effect.runPromise(installToolEffect(options).pipe(exports_Effect.catchAll((err) => handleInstallError(err)), exports_Effect.provide(layer)));
128179
128419
  }
@@ -128933,6 +129173,22 @@ skillCommand.command("activate <skill-name>").description("Activate a named skil
128933
129173
  const { activateSkill: activateSkill2 } = await Promise.resolve().then(() => (init_skill(), exports_skill));
128934
129174
  await activateSkill2(options.chatroomId, skillName, { role: options.role });
128935
129175
  });
129176
+ var workspaceCommand = program2.command("workspace").description("Workspace file tree debugging and maintenance");
129177
+ var workspaceFileTreeCommand = workspaceCommand.command("file-tree").description("Workspace file tree daemon sync");
129178
+ workspaceFileTreeCommand.command("request").description("Request daemon file tree sync (same mutation as webapp refresh)").requiredOption("--machine-id <id>", "Machine identifier").requiredOption("--working-dir <path>", "Workspace working directory").option("--force", "Force reconciliation walk (explicit recovery)").action(async (options) => {
129179
+ await maybeRequireAuth();
129180
+ const { requestWorkspaceFileTreeFromCli: requestWorkspaceFileTreeFromCli2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
129181
+ const result = await requestWorkspaceFileTreeFromCli2(options.machineId, options.workingDir, {
129182
+ force: options.force
129183
+ });
129184
+ console.log(`✅ File tree request: ${result.status}`);
129185
+ });
129186
+ workspaceFileTreeCommand.command("status").description("Show checkpoint, manifest, and pending daemon requests for debugging").requiredOption("--machine-id <id>", "Machine identifier").requiredOption("--working-dir <path>", "Workspace working directory").action(async (options) => {
129187
+ await maybeRequireAuth();
129188
+ const { getWorkspaceFileTreeStatusFromCli: getWorkspaceFileTreeStatusFromCli2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
129189
+ const status3 = await getWorkspaceFileTreeStatusFromCli2(options.machineId, options.workingDir);
129190
+ console.log(JSON.stringify(status3, null, 2));
129191
+ });
128936
129192
  var messagesCommand = program2.command("messages").description("List and filter chatroom messages");
128937
129193
  var messageCommand = program2.command("message").description("Send chatroom messages");
128938
129194
  messageCommand.command("send").description("Send a user message to a chatroom").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--content <text>", "Message content").option("--target-role <role>", "Target role (defaults to team entry point)").action(async (options) => {
@@ -129153,4 +129409,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
129153
129409
  });
129154
129410
  program2.parse();
129155
129411
 
129156
- //# debugId=8169BF8DA0BD25A464756E2164756E21
129412
+ //# debugId=104EE59D5601863F64756E2164756E21