tmux-ide 2.9.25 → 2.9.27

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 (67) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +1577 -559
  3. package/package.json +3 -2
  4. package/packages/contracts/src/pane-stream.ts +28 -0
  5. package/packages/contracts/src/terminal-delivery.ts +122 -5
  6. package/packages/contracts/src/terminal-runtime-inventory.ts +61 -1
  7. package/packages/contracts/src/tmux-server-scope.ts +18 -0
  8. package/packages/core/src/index.ts +1 -0
  9. package/packages/core/src/terminal-delivery-binary.ts +8 -7
  10. package/packages/core/src/terminal-delivery.ts +174 -3
  11. package/packages/core/src/terminal-partial-history.ts +152 -0
  12. package/packages/core/src/terminal-replica.ts +70 -1
  13. package/packages/daemon/dist/command-center/owner-keep-alive.js +30 -0
  14. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
  15. package/packages/daemon/dist/command-center/server.js +3 -0
  16. package/packages/daemon/dist/command-center/tmux-server-attach.js +51 -0
  17. package/packages/daemon/dist/command-center/tmux-servers.js +95 -7
  18. package/packages/daemon/dist/doctor.js +4 -4
  19. package/packages/daemon/dist/lib/app-config.js +7 -0
  20. package/packages/daemon/dist/lib/node-requirement.js +20 -0
  21. package/packages/daemon/dist/lib/require-supported-node.js +8 -0
  22. package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
  23. package/packages/daemon/dist/lib/tmux-server-session-open.js +38 -12
  24. package/packages/daemon/dist/lib/workspace-promotion.js +4 -4
  25. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  26. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  27. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  28. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  29. package/packages/daemon/dist/server/pane-stream-upgrade.js +39 -1
  30. package/packages/daemon/dist/terminal/mirror/session-channel.js +6 -1
  31. package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
  32. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +112 -22
  33. package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
  34. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
  35. package/packages/daemon/dist/terminal/session-runtime/registry.js +2 -0
  36. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +571 -33
  37. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +2 -0
  38. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
  39. package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +76 -2
  40. package/packages/daemon/dist/tui/mirror/theme.js +8 -1
  41. package/packages/daemon/src/command-center/attach-window-rule.cases.json +84 -0
  42. package/packages/daemon/src/command-center/owner-keep-alive.ts +38 -0
  43. package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
  44. package/packages/daemon/src/command-center/server.ts +3 -0
  45. package/packages/daemon/src/command-center/tmux-server-attach.ts +75 -0
  46. package/packages/daemon/src/command-center/tmux-servers.ts +103 -6
  47. package/packages/daemon/src/doctor.ts +4 -4
  48. package/packages/daemon/src/lib/app-config.ts +15 -0
  49. package/packages/daemon/src/lib/node-requirement.ts +22 -0
  50. package/packages/daemon/src/lib/require-supported-node.ts +9 -0
  51. package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
  52. package/packages/daemon/src/lib/tmux-server-session-open.ts +53 -15
  53. package/packages/daemon/src/lib/workspace-promotion.ts +4 -4
  54. package/packages/daemon/src/server/pane-stream-upgrade.ts +41 -1
  55. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  56. package/packages/daemon/src/terminal/mirror/session-channel.ts +8 -1
  57. package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
  58. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +136 -20
  59. package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
  60. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
  61. package/packages/daemon/src/terminal/session-runtime/registry.ts +2 -0
  62. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +696 -30
  63. package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
  64. package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +2 -0
  65. package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
  66. package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +82 -2
  67. package/packages/daemon/src/tui/mirror/theme.ts +13 -1
package/bin/cli.js CHANGED
@@ -47,6 +47,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
47
47
  mod
48
48
  ));
49
49
 
50
+ // packages/daemon/src/lib/node-requirement.ts
51
+ function isSupportedNodeVersion(version) {
52
+ const major = Number(version.split(".")[0]);
53
+ return Number.isInteger(major) && major >= MINIMUM_NODE_MAJOR;
54
+ }
55
+ function unsupportedNodeMessage(versions) {
56
+ if (versions.bun !== void 0 || versions.node === void 0) return null;
57
+ if (isSupportedNodeVersion(versions.node)) return null;
58
+ return `tmux-ide needs Node.js ${MINIMUM_NODE_MAJOR} or newer; this is Node.js ${versions.node}.
59
+ Upgrade Node.js, or use the installer, which brings its own runtime:
60
+ curl -fsSL https://tmux-ide.com/install.sh | sh
61
+ `;
62
+ }
63
+ var MINIMUM_NODE_MAJOR;
64
+ var init_node_requirement = __esm({
65
+ "packages/daemon/src/lib/node-requirement.ts"() {
66
+ "use strict";
67
+ MINIMUM_NODE_MAJOR = 24;
68
+ }
69
+ });
70
+
50
71
  // packages/tmux-bridge/src/errors.ts
51
72
  var TmuxError;
52
73
  var init_errors = __esm({
@@ -55,8 +76,8 @@ var init_errors = __esm({
55
76
  TmuxError = class extends Error {
56
77
  code;
57
78
  exitCode;
58
- constructor(message, code2, options = {}) {
59
- super(message, { cause: options.cause });
79
+ constructor(message2, code2, options = {}) {
80
+ super(message2, { cause: options.cause });
60
81
  this.name = "TmuxError";
61
82
  this.code = code2;
62
83
  this.exitCode = options.exitCode ?? 1;
@@ -4779,7 +4800,7 @@ var init_interaction_evidence = __esm({
4779
4800
  timeBasis: z27.enum(["daemon", "server", "unknown"]),
4780
4801
  receivedAt: time
4781
4802
  }).strict().superRefine((value, context) => {
4782
- const issue = (path2, message) => context.addIssue({ code: "custom", path: path2, message });
4803
+ const issue = (path2, message2) => context.addIssue({ code: "custom", path: path2, message: message2 });
4783
4804
  const { observation: observation2, actor, effect, endpoints: endpoints2 } = value;
4784
4805
  for (const endpoint of [endpoints2.destination, endpoints2.source]) {
4785
4806
  if (endpoint?.kind === "native-pane" && (observation2.kind !== "native-journal" || endpoint.serverEpoch !== observation2.serverEpoch))
@@ -4859,7 +4880,7 @@ var init_interaction_evidence = __esm({
4859
4880
  lastGap: InteractionObservationGapSchemaZ.nullable(),
4860
4881
  droppedCount: NativeInteractionSequenceSchemaZ.nullable()
4861
4882
  }).strict().superRefine((value, context) => {
4862
- const issue = (path2, message) => context.addIssue({ code: "custom", path: path2, message });
4883
+ const issue = (path2, message2) => context.addIssue({ code: "custom", path: path2, message: message2 });
4863
4884
  if (new Set(value.commands).size !== value.commands.length || new Set(value.effects).size !== value.effects.length)
4864
4885
  issue(["commands"], "capability lists must be unique");
4865
4886
  if (value.method !== "native-journal" && (value.cursor !== null || value.effects.length > 0))
@@ -7395,7 +7416,7 @@ var init_causal_cell = __esm({
7395
7416
 
7396
7417
  // packages/contracts/src/terminal-delivery.ts
7397
7418
  import { z as z48 } from "zod";
7398
- var STOCK_CAPTURE_TAB_UNAVAILABLE, TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION, TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION, TERMINAL_DELIVERY_PROTOCOL_VERSION, TERMINAL_DELIVERY_CHUNK_BYTES, TERMINAL_DELIVERY_PATCH_TO_SEED_BYTES, TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES, TerminalDeliveryEncodingSchemaZ, TerminalDeliveryOfferSchemaZ, TerminalDeliveryNegotiatedSchemaZ, TerminalDeliveryNegotiationResultSchemaZ, DeliveryAddressSchemaZ, TerminalDeliveryEnvelopeSchemaZ, TerminalDeliveryFaultSchemaZ, TerminalDeliveryAckSchemaZ, TerminalDeliveryNackSchemaZ, TerminalDeliveryVisibilitySchemaZ, TerminalSemanticDeliveryPayloadSchemaZ;
7419
+ var STOCK_CAPTURE_TAB_UNAVAILABLE, TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION, TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION, TERMINAL_DELIVERY_PROTOCOL_VERSION, TERMINAL_DELIVERY_PARTIAL_HISTORY_CAPABILITY_VERSION, TERMINAL_DELIVERY_HISTORY_TAIL_ROWS, TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION, TERMINAL_DELIVERY_MAX_PIPELINED, TERMINAL_DELIVERY_HISTORY_CHUNK_MAX_ROWS, TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS, TERMINAL_DELIVERY_CHUNK_BYTES, TERMINAL_DELIVERY_PATCH_TO_SEED_BYTES, TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES, TerminalDeliveryEncodingSchemaZ, TerminalDeliveryOfferSchemaZ, TerminalDeliveryNegotiatedSchemaZ, TerminalDeliveryNegotiationResultSchemaZ, TERMINAL_HISTORY_EMPTY_DIGEST, TerminalDeliveryHistoryCommitmentSchemaZ, DeliveryAddressSchemaZ, TerminalDeliveryEnvelopeSchemaZ, TerminalDeliveryFaultSchemaZ, TerminalDeliveryAckSchemaZ, TerminalDeliveryNackSchemaZ, TerminalDeliveryHistoryRequestSchemaZ, TerminalDeliveryVisibilitySchemaZ, TerminalSemanticDeliveryPayloadSchemaZ, TerminalSemanticHistoryPayloadSchemaZ;
7399
7420
  var init_terminal_delivery = __esm({
7400
7421
  "packages/contracts/src/terminal-delivery.ts"() {
7401
7422
  "use strict";
@@ -7408,6 +7429,12 @@ var init_terminal_delivery = __esm({
7408
7429
  TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION = /* @__PURE__ */ (() => 109)();
7409
7430
  TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION = /* @__PURE__ */ (() => 110)();
7410
7431
  TERMINAL_DELIVERY_PROTOCOL_VERSION = /* @__PURE__ */ (() => 1)();
7432
+ TERMINAL_DELIVERY_PARTIAL_HISTORY_CAPABILITY_VERSION = /* @__PURE__ */ (() => 122)();
7433
+ TERMINAL_DELIVERY_HISTORY_TAIL_ROWS = /* @__PURE__ */ (() => 200)();
7434
+ TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION = /* @__PURE__ */ (() => 124)();
7435
+ TERMINAL_DELIVERY_MAX_PIPELINED = /* @__PURE__ */ (() => 3)();
7436
+ TERMINAL_DELIVERY_HISTORY_CHUNK_MAX_ROWS = /* @__PURE__ */ (() => 2e3)();
7437
+ TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS = /* @__PURE__ */ (() => 16)();
7411
7438
  TERMINAL_DELIVERY_CHUNK_BYTES = /* @__PURE__ */ (() => 256 * 1024)();
7412
7439
  TERMINAL_DELIVERY_PATCH_TO_SEED_BYTES = /* @__PURE__ */ (() => 512 * 1024)();
7413
7440
  TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES = /* @__PURE__ */ (() => 16 * 1024 * 1024)();
@@ -7419,8 +7446,9 @@ var init_terminal_delivery = __esm({
7419
7446
  "ansi-raw-v1"
7420
7447
  ]))();
7421
7448
  TerminalDeliveryOfferSchemaZ = /* @__PURE__ */ (() => z48.object({
7422
- // Interactive binary/graphics offers use eight slots; native surfaces add one.
7423
- protocolVersions: z48.array(z48.number().int().positive()).min(1).max(9),
7449
+ // Released daemons before 2.9.26 refuse more than nine numbers, so a client
7450
+ // offers a tenth only to a daemon whose productVersion is 2.9.26 or later.
7451
+ protocolVersions: z48.array(z48.number().int().positive()).min(1).max(TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS),
7424
7452
  encodings: z48.array(TerminalDeliveryEncodingSchemaZ).min(1).max(4),
7425
7453
  richPlacements: z48.boolean()
7426
7454
  }).strict().superRefine((value, context) => {
@@ -7434,12 +7462,19 @@ var init_terminal_delivery = __esm({
7434
7462
  encoding: TerminalDeliveryEncodingSchemaZ,
7435
7463
  fallbackEncoding: z48.literal("semantic-v1").nullable().optional(),
7436
7464
  alternateScreenProjection: z48.literal("deferred-history-v1").optional(),
7465
+ /** Capability 122: history on demand. */
7466
+ partialHistory: z48.literal("tail-v1").optional(),
7437
7467
  richPlacements: z48.boolean(),
7438
7468
  generation: SessionRuntimeGenerationSchemaZ,
7439
7469
  deliveryNonce: z48.uuid()
7440
7470
  }).strict().superRefine((value, context) => {
7441
7471
  if (value.alternateScreenProjection && value.encoding !== "semantic-binary-v1")
7442
7472
  context.addIssue({ code: "custom", message: "projection requires binary semantic delivery" });
7473
+ if (value.partialHistory && (value.encoding !== "semantic-compact-v1" && value.encoding !== "semantic-binary-v1" || value.alternateScreenProjection))
7474
+ context.addIssue({
7475
+ code: "custom",
7476
+ message: "partial history requires compact or binary semantic delivery and no projection"
7477
+ });
7443
7478
  if (value.fallbackEncoding && value.encoding !== "semantic-compact-v1")
7444
7479
  context.addIssue({ code: "custom", message: "fallback encoding requires compact semantic" });
7445
7480
  if (value.richPlacements && value.encoding !== "semantic-v1" && value.encoding !== "semantic-compact-v1" && value.encoding !== "semantic-binary-v1")
@@ -7456,6 +7491,14 @@ var init_terminal_delivery = __esm({
7456
7491
  ])
7457
7492
  }).strict()
7458
7493
  ]))();
7494
+ TERMINAL_HISTORY_EMPTY_DIGEST = /* @__PURE__ */ (() => "0000000000000000")();
7495
+ TerminalDeliveryHistoryCommitmentSchemaZ = /* @__PURE__ */ (() => z48.object({
7496
+ rows: z48.number().int().nonnegative().max(1e6),
7497
+ digest: z48.string().regex(/^[0-9a-f]{16}$/u)
7498
+ }).strict().refine(
7499
+ (value) => value.rows > 0 || value.digest === TERMINAL_HISTORY_EMPTY_DIGEST,
7500
+ "an empty commitment has the empty digest"
7501
+ ))();
7459
7502
  DeliveryAddressSchemaZ = /* @__PURE__ */ (() => z48.object({
7460
7503
  workspaceName: WorkspaceIdSchemaZ,
7461
7504
  semanticPaneId: TerminalAttachmentSemanticPaneIdSchemaZ,
@@ -7476,7 +7519,7 @@ var init_terminal_delivery = __esm({
7476
7519
  causalCellProof: CausalCellProofV1SchemaZ.optional(),
7477
7520
  protocolVersion: z48.literal(TERMINAL_DELIVERY_PROTOCOL_VERSION),
7478
7521
  encoding: TerminalDeliveryEncodingSchemaZ,
7479
- frame: z48.enum(["seed", "patch", "tombstone"]),
7522
+ frame: z48.enum(["seed", "patch", "tombstone", "history"]),
7480
7523
  baseRevision: z48.number().int().min(-1).nullable(),
7481
7524
  canonicalRevision: z48.number().int().nonnegative(),
7482
7525
  canonicalStateHash: z48.string().regex(/^[0-9a-f]{16}$/u),
@@ -7484,7 +7527,9 @@ var init_terminal_delivery = __esm({
7484
7527
  representationBytes: z48.number().int().nonnegative().max(TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES),
7485
7528
  chunkCount: z48.number().int().positive().max(256),
7486
7529
  canonicalEquivalent: z48.boolean(),
7487
- history: z48.enum(["complete", "truncated", "not-applicable"]),
7530
+ history: z48.enum(["complete", "partial", "truncated", "not-applicable"]),
7531
+ /** Capability 122: the history rows the client does not hold, oldest first. */
7532
+ historyUnloaded: TerminalDeliveryHistoryCommitmentSchemaZ.optional(),
7488
7533
  richPlacements: z48.boolean()
7489
7534
  }).strict().superRefine((value, context) => {
7490
7535
  const semantic = value.encoding === "semantic-v1" || value.encoding === "semantic-compact-v1" || value.encoding === "semantic-binary-v1";
@@ -7499,12 +7544,27 @@ var init_terminal_delivery = __esm({
7499
7544
  });
7500
7545
  if (value.frame === "seed" && value.baseRevision !== null)
7501
7546
  context.addIssue({ code: "custom", message: "seed baseRevision must be null" });
7502
- if (value.frame !== "seed" && (value.baseRevision === null || value.canonicalRevision <= value.baseRevision))
7547
+ if (value.frame === "history" && (value.baseRevision !== value.canonicalRevision || value.history !== "partial"))
7548
+ context.addIssue({
7549
+ code: "custom",
7550
+ message: "a history frame is partial and stays at the client's revision"
7551
+ });
7552
+ if (value.frame !== "seed" && value.frame !== "history" && (value.baseRevision === null || value.canonicalRevision <= value.baseRevision))
7503
7553
  context.addIssue({
7504
7554
  code: "custom",
7505
7555
  message: "patch/tombstone requires an earlier baseRevision"
7506
7556
  });
7507
- if (semantic && (!value.canonicalEquivalent || value.frame !== "tombstone" && value.history !== "complete"))
7557
+ if (value.history === "partial" !== (value.historyUnloaded !== void 0))
7558
+ context.addIssue({
7559
+ code: "custom",
7560
+ message: "a partial history carries its unloaded commitment, and only it does"
7561
+ });
7562
+ if (value.history === "partial" && (!semantic || value.frame === "tombstone"))
7563
+ context.addIssue({
7564
+ code: "custom",
7565
+ message: "partial history is semantic and not a tombstone"
7566
+ });
7567
+ if (semantic && (!value.canonicalEquivalent || value.frame !== "tombstone" && value.history !== "complete" && value.history !== "partial"))
7508
7568
  context.addIssue({
7509
7569
  code: "custom",
7510
7570
  message: "semantic delivery must be complete canonical truth"
@@ -7545,6 +7605,12 @@ var init_terminal_delivery = __esm({
7545
7605
  ]),
7546
7606
  appliedRevision: z48.number().int().min(-1)
7547
7607
  }).strict())();
7608
+ TerminalDeliveryHistoryRequestSchemaZ = /* @__PURE__ */ (() => DeliveryAddressSchemaZ.extend({
7609
+ type: z48.literal("terminal.delivery.history-request"),
7610
+ canonicalRevision: z48.number().int().nonnegative(),
7611
+ unloadedRows: z48.number().int().nonnegative().max(1e6),
7612
+ maxRows: z48.number().int().min(1).max(TERMINAL_DELIVERY_HISTORY_CHUNK_MAX_ROWS)
7613
+ }).strict())();
7548
7614
  TerminalDeliveryVisibilitySchemaZ = /* @__PURE__ */ (() => z48.enum([
7549
7615
  "visible",
7550
7616
  "background",
@@ -7570,6 +7636,11 @@ var init_terminal_delivery = __esm({
7570
7636
  tombstone: TerminalReplicaTombstonePayloadSchemaZ
7571
7637
  }).strict().refine((value) => value.revision > value.baseRevision, "tombstone revision must advance")
7572
7638
  ]))();
7639
+ TerminalSemanticHistoryPayloadSchemaZ = /* @__PURE__ */ (() => z48.object({
7640
+ frame: z48.literal("history"),
7641
+ revision: z48.number().int().nonnegative(),
7642
+ rows: z48.array(TerminalReplicaRowSchemaZ).min(1).max(TERMINAL_DELIVERY_HISTORY_CHUNK_MAX_ROWS)
7643
+ }).strict())();
7573
7644
  }
7574
7645
  });
7575
7646
 
@@ -7700,6 +7771,7 @@ __export(tmux_server_scope_exports, {
7700
7771
  TmuxServerSessionTargetSchemaZ: () => TmuxServerSessionTargetSchemaZ,
7701
7772
  TmuxServerSessionsResourceSchemaZ: () => TmuxServerSessionsResourceSchemaZ,
7702
7773
  TmuxServerSessionsResourceV2SchemaZ: () => TmuxServerSessionsResourceV2SchemaZ,
7774
+ TmuxServerSessionsResourceV3SchemaZ: () => TmuxServerSessionsResourceV3SchemaZ,
7703
7775
  TmuxServerWindowTargetSchemaZ: () => TmuxServerWindowTargetSchemaZ,
7704
7776
  TmuxServersResourceSchemaZ: () => TmuxServersResourceSchemaZ,
7705
7777
  isTmuxServerPaneStreamPath: () => isTmuxServerPaneStreamPath,
@@ -7738,7 +7810,7 @@ function base64DecodedLength(data) {
7738
7810
  const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
7739
7811
  return data.length / 4 * 3 - padding;
7740
7812
  }
7741
- var descriptorShape, TmuxServerDescriptorSchemaZ, TMUX_SERVERS_API_PATH, TmuxServersResourceSchemaZ, TmuxServerSessionTargetSchemaZ, TmuxServerWindowTargetSchemaZ, TmuxServerPaneTargetSchemaZ, TmuxServerSessionsResourceSchemaZ, TMUX_SERVER_SESSION_FAVICON_MAX_BYTES, TmuxServerSessionFaviconMimeSchemaZ, TmuxServerSessionFaviconSchemaZ, TmuxServerSessionsResourceV2SchemaZ, TmuxServerRegistrationRequestSchemaZ;
7813
+ var descriptorShape, TmuxServerDescriptorSchemaZ, TMUX_SERVERS_API_PATH, TmuxServersResourceSchemaZ, TmuxServerSessionTargetSchemaZ, TmuxServerWindowTargetSchemaZ, TmuxServerPaneTargetSchemaZ, TmuxServerSessionsResourceSchemaZ, TMUX_SERVER_SESSION_FAVICON_MAX_BYTES, TmuxServerSessionFaviconMimeSchemaZ, TmuxServerSessionFaviconSchemaZ, TmuxServerSessionsResourceV2SchemaZ, TmuxServerSessionsResourceV3SchemaZ, TmuxServerRegistrationRequestSchemaZ;
7742
7814
  var init_tmux_server_scope = __esm({
7743
7815
  "packages/contracts/src/tmux-server-scope.ts"() {
7744
7816
  "use strict";
@@ -7832,6 +7904,13 @@ var init_tmux_server_scope = __esm({
7832
7904
  }).strict()
7833
7905
  )
7834
7906
  }).strict())();
7907
+ TmuxServerSessionsResourceV3SchemaZ = /* @__PURE__ */ (() => z50.object({
7908
+ version: z50.literal(3),
7909
+ server: TmuxServerScopeSchemaZ,
7910
+ sessions: z50.array(
7911
+ TmuxServerSessionsResourceV2SchemaZ.shape.sessions.element.extend({ largestWindowPaneCount: z50.number().int().min(1) }).strict()
7912
+ )
7913
+ }).strict())();
7835
7914
  TmuxServerRegistrationRequestSchemaZ = /* @__PURE__ */ (() => z50.object({
7836
7915
  label: descriptorShape.label.max(128),
7837
7916
  selector: z50.discriminatedUnion("kind", [
@@ -7940,7 +8019,7 @@ var init_terminal_graphics = __esm({
7940
8019
 
7941
8020
  // packages/contracts/src/pane-stream.ts
7942
8021
  import { z as z52 } from "zod";
7943
- var PANE_STREAM_CLOCK_BOUNDS_CAPABILITY_V1, PaneStreamDiagnosticCapabilitySchemaZ, PANE_STREAM_PROTOCOL_VERSION, PANE_STREAM_ISSUE_PATH, PANE_STREAM_REDEEM_PATH, PANE_STREAM_WEBSOCKET_SUBPROTOCOL, PANE_STREAM_MAX_PANES, PANE_STREAM_MAX_OUTPUT_BYTES, PANE_STREAM_MAX_OUTPUT_BASE64_CHARS, PANE_STREAM_MAX_SEED_BYTES, PANE_STREAM_MAX_SEED_BASE64_CHARS, PANE_STREAM_MAX_HELD_DELTAS, PANE_STREAM_MAX_LAYOUT_PANES, PANE_STREAM_MAX_GRID_CELLS, PANE_STREAM_MAX_INPUT_SEQUENCE, PaneStreamSemanticPaneIdSchemaZ, PaneStreamViewerModeSchemaZ, PaneSetSchemaZ, PaneStreamLeaseRequestSchemaZ, PaneStreamRedemptionTicketSchemaZ, PaneStreamLoopbackWebSocketUrlSchemaZ, PaneStreamIssueDescriptorSchemaZ, PaneStreamIssueErrorSchemaZ, PaneStreamIssueResultSchemaZ, PaneStreamIssueMutationRequestSchemaZ, BoundedIdentitySchemaZ, PaneStreamRedeemFrameSchemaZ, PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PaneStreamInputLifetimeSchemaZ, PaneStreamInputFrameMetadataShape, PaneStreamInputFrameSchemaZ, PaneStreamConsumedFrameSchemaZ, PaneStreamTerminalDeliveryAckFrameSchemaZ, PaneStreamTerminalProjectionReceiptFrameSchemaZ, PaneStreamTerminalProjectionMaterializeFrameSchemaZ, PaneStreamTerminalDeliveryNackFrameSchemaZ, PaneStreamTerminalDeliveryVisibilityFrameSchemaZ, PaneStreamSemanticIntentFrameSchemaZ, PaneStreamViewportFrameSchemaZ, PaneStreamAuthorityRequestIdSchemaZ, PaneStreamAuthorityGenerationSchemaZ, PaneStreamPresenceFrameSchemaZ, PaneStreamActivityFrameSchemaZ, PaneStreamAuthorityRequestFrameSchemaZ, PaneStreamAuthorityReleaseFrameSchemaZ, SharedMonotonicMicrosSchemaZ, PaneStreamClockProbeFrameSchemaZ, PaneStreamTerminalGraphicsRequestFrameSchemaZ, PaneStreamTerminalGraphicsLocalReleaseFrameSchemaZ, PaneStreamTerminalCellPixelsFrameSchemaZ, PaneStreamClientFrameSchemaZ, Base64SchemaZ, ServerSeqSchemaZ, GridCellSchemaZ, CellCoordinateSchemaZ, PaneStreamReadyFrameSchemaZ, PaneStreamSeedBatchFrameSchemaZ, PaneStreamOutputFrameSchemaZ, PaneStreamCursorFrameSchemaZ, BoundedDisplayNameSchemaZ, PaneDisplayNameSourceSchemaZ, PaneStreamLayoutFrameSchemaZ, PaneStreamLayoutSnapshotV1FrameSchemaZ, PaneStreamLayoutSnapshotV2FrameSchemaZ, PaneStreamLayoutSnapshotFrameSchemaZ, PaneStreamFlowFrameSchemaZ, PaneStreamTopologyFrameSchemaZ, PaneStreamClosedFrameSchemaZ, PaneStreamInputAckFrameSchemaZ, PaneStreamClockProbeAckFrameSchemaZ, PaneStreamCausalCellProofFrameSchemaZ, PaneStreamCausalCellFailureFrameSchemaZ, PaneStreamTerminalDeliveryReadyFrameSchemaZ, PaneStreamTerminalDeliveryEnvelopeFrameSchemaZ, PaneStreamTerminalProjectionEnvelopeFrameSchemaZ, PaneStreamTerminalDeliveryChunkFrameSchemaZ, PaneStreamTerminalDeliveryFaultFrameSchemaZ, PaneStreamTerminalGraphicsFrameSchemaZ, PaneStreamTerminalGraphicsBlobFrameSchemaZ, PaneStreamTerminalGraphicsLocalFrameSchemaZ, PaneStreamSemanticIntentAckFrameSchemaZ, PaneStreamViewportAckFrameSchemaZ, PaneStreamAuthoritySnapshotFrameSchemaZ, PaneStreamAuthorityReceiptFrameSchemaZ, PaneStreamErrorFrameCodeSchemaZ, PaneStreamErrorFrameSchemaZ, PaneStreamServerFrameSchemaZ;
8022
+ var PANE_STREAM_CLOCK_BOUNDS_CAPABILITY_V1, PaneStreamDiagnosticCapabilitySchemaZ, PANE_STREAM_PROTOCOL_VERSION, PANE_STREAM_ISSUE_PATH, PANE_STREAM_REDEEM_PATH, PANE_STREAM_WEBSOCKET_SUBPROTOCOL, PANE_STREAM_MAX_PANES, PANE_STREAM_MAX_OUTPUT_BYTES, PANE_STREAM_MAX_OUTPUT_BASE64_CHARS, PANE_STREAM_MAX_SEED_BYTES, PANE_STREAM_MAX_SEED_BASE64_CHARS, PANE_STREAM_MAX_HELD_DELTAS, PANE_STREAM_MAX_LAYOUT_PANES, PANE_STREAM_MAX_GRID_CELLS, PANE_STREAM_MAX_INPUT_SEQUENCE, PaneStreamSemanticPaneIdSchemaZ, PaneStreamViewerModeSchemaZ, PaneSetSchemaZ, PaneStreamLeaseRequestSchemaZ, PaneStreamRedemptionTicketSchemaZ, PaneStreamLoopbackWebSocketUrlSchemaZ, PaneStreamIssueDescriptorSchemaZ, PaneStreamIssueErrorSchemaZ, PaneStreamIssueResultSchemaZ, PaneStreamIssueMutationRequestSchemaZ, BoundedIdentitySchemaZ, PaneStreamRedeemFrameSchemaZ, PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PaneStreamInputLifetimeSchemaZ, PaneStreamInputFrameMetadataShape, PaneStreamInputFrameSchemaZ, PaneStreamConsumedFrameSchemaZ, PaneStreamTerminalDeliveryAckFrameSchemaZ, PaneStreamTerminalProjectionReceiptFrameSchemaZ, PaneStreamTerminalProjectionMaterializeFrameSchemaZ, PaneStreamTerminalDeliveryHistoryRequestFrameSchemaZ, PaneStreamTerminalDeliveryNackFrameSchemaZ, PaneStreamTerminalDeliveryVisibilityFrameSchemaZ, PaneStreamSemanticIntentFrameSchemaZ, PaneStreamViewportFrameSchemaZ, PaneStreamAuthorityRequestIdSchemaZ, PaneStreamAuthorityGenerationSchemaZ, PaneStreamPresenceFrameSchemaZ, PaneStreamActivityFrameSchemaZ, PaneStreamAuthorityRequestFrameSchemaZ, PaneStreamAuthorityReleaseFrameSchemaZ, SharedMonotonicMicrosSchemaZ, PaneStreamClockProbeFrameSchemaZ, PaneStreamTerminalGraphicsRequestFrameSchemaZ, PaneStreamTerminalGraphicsLocalReleaseFrameSchemaZ, PaneStreamTerminalCellPixelsFrameSchemaZ, PaneStreamClientFrameSchemaZ, Base64SchemaZ, ServerSeqSchemaZ, GridCellSchemaZ, CellCoordinateSchemaZ, PaneStreamReadyFrameSchemaZ, PaneStreamSeedBatchFrameSchemaZ, PaneStreamOutputFrameSchemaZ, PaneStreamCursorFrameSchemaZ, BoundedDisplayNameSchemaZ, PaneDisplayNameSourceSchemaZ, PaneStreamLayoutFrameSchemaZ, PaneStreamLayoutSnapshotV1FrameSchemaZ, PaneStreamLayoutSnapshotV2FrameSchemaZ, PaneStreamLayoutSnapshotFrameSchemaZ, PaneStreamFlowFrameSchemaZ, PaneStreamTopologyFrameSchemaZ, PaneStreamClosedFrameSchemaZ, PaneStreamInputAckFrameSchemaZ, PaneStreamClockProbeAckFrameSchemaZ, PaneStreamCausalCellProofFrameSchemaZ, PaneStreamCausalCellFailureFrameSchemaZ, PaneStreamTerminalDeliveryReadyFrameSchemaZ, PaneStreamTerminalDeliveryEnvelopeFrameSchemaZ, PaneStreamTerminalProjectionEnvelopeFrameSchemaZ, PaneStreamTerminalDeliveryChunkFrameSchemaZ, PaneStreamTerminalDeliveryFaultFrameSchemaZ, PaneStreamTerminalGraphicsFrameSchemaZ, PaneStreamTerminalGraphicsBlobFrameSchemaZ, PaneStreamTerminalGraphicsLocalFrameSchemaZ, PaneStreamSemanticIntentAckFrameSchemaZ, PaneStreamViewportAckFrameSchemaZ, PaneStreamAuthoritySnapshotFrameSchemaZ, PaneStreamAuthorityReceiptFrameSchemaZ, PaneStreamErrorFrameCodeSchemaZ, PaneStreamErrorFrameSchemaZ, PaneStreamServerFrameSchemaZ;
7944
8023
  var init_pane_stream = __esm({
7945
8024
  "packages/contracts/src/pane-stream.ts"() {
7946
8025
  "use strict";
@@ -7986,7 +8065,15 @@ var init_pane_stream = __esm({
7986
8065
  panes: PaneSetSchemaZ,
7987
8066
  viewerMode: PaneStreamViewerModeSchemaZ,
7988
8067
  /** Explicit semantic-v2 content/authority mode. Omission retains raw v1. */
7989
- terminalDelivery: TerminalDeliveryOfferSchemaZ.optional()
8068
+ terminalDelivery: TerminalDeliveryOfferSchemaZ.optional(),
8069
+ /**
8070
+ * #806: a stream for one window. `panes` must be exactly that window's
8071
+ * panes (at most PANE_STREAM_MAX_PANES), so a session with more panes in
8072
+ * all can be viewed window by window. Under capability 119/120 the stream
8073
+ * follows that window's pane set in place; other windows never enter.
8074
+ * Released daemons refuse the field: send it only to a daemon that has it.
8075
+ */
8076
+ semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ.optional()
7990
8077
  }).strict())();
7991
8078
  PaneStreamRedemptionTicketSchemaZ = /* @__PURE__ */ (() => z52.string().regex(/^ps2_[A-Za-z0-9_-]{43}$/u))();
7992
8079
  PaneStreamLoopbackWebSocketUrlSchemaZ = /* @__PURE__ */ (() => z52.url().max(2048).refine((value) => {
@@ -8033,6 +8120,7 @@ var init_pane_stream = __esm({
8033
8120
  PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION = /* @__PURE__ */ (() => 106)();
8034
8121
  PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION = /* @__PURE__ */ (() => 117)();
8035
8122
  PANE_STREAM_READER_CAPABILITY_VERSION = /* @__PURE__ */ (() => 118)();
8123
+ PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION = /* @__PURE__ */ (() => 123)();
8036
8124
  PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION = /* @__PURE__ */ (() => 119)();
8037
8125
  PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION = /* @__PURE__ */ (() => 120)();
8038
8126
  PaneStreamInputLifetimeSchemaZ = /* @__PURE__ */ (() => z52.object({
@@ -8075,6 +8163,10 @@ var init_pane_stream = __esm({
8075
8163
  type: z52.literal("terminal-projection-materialize"),
8076
8164
  request: TerminalProjectionMaterializeSchemaZ
8077
8165
  }).strict())();
8166
+ PaneStreamTerminalDeliveryHistoryRequestFrameSchemaZ = /* @__PURE__ */ (() => z52.object({
8167
+ type: z52.literal("terminal-delivery-history-request"),
8168
+ request: TerminalDeliveryHistoryRequestSchemaZ
8169
+ }).strict())();
8078
8170
  PaneStreamTerminalDeliveryNackFrameSchemaZ = /* @__PURE__ */ (() => z52.object({ type: z52.literal("terminal-delivery-nack"), nack: TerminalDeliveryNackSchemaZ }).strict())();
8079
8171
  PaneStreamTerminalDeliveryVisibilityFrameSchemaZ = /* @__PURE__ */ (() => z52.object({
8080
8172
  type: z52.literal("terminal-delivery-visibility"),
@@ -8160,6 +8252,7 @@ var init_pane_stream = __esm({
8160
8252
  PaneStreamTerminalProjectionReceiptFrameSchemaZ,
8161
8253
  PaneStreamTerminalProjectionMaterializeFrameSchemaZ,
8162
8254
  PaneStreamTerminalDeliveryNackFrameSchemaZ,
8255
+ PaneStreamTerminalDeliveryHistoryRequestFrameSchemaZ,
8163
8256
  PaneStreamTerminalDeliveryVisibilityFrameSchemaZ,
8164
8257
  PaneStreamSemanticIntentFrameSchemaZ,
8165
8258
  PaneStreamViewportFrameSchemaZ,
@@ -8247,6 +8340,11 @@ var init_pane_stream = __esm({
8247
8340
  displayName: BoundedDisplayNameSchemaZ.nullable().optional(),
8248
8341
  displayNameSource: PaneDisplayNameSourceSchemaZ.nullable().optional(),
8249
8342
  browserIcon: z52.string().regex(/^(?:[0-9a-f]{2048})?$/u).nullable().optional(),
8343
+ /**
8344
+ * Only with capability 123: a terminal browser with tmux-ide's
8345
+ * native controls, a plain one without them, or null.
8346
+ */
8347
+ browserKind: z52.enum(["native", "plain"]).nullable().optional(),
8250
8348
  /** Only with capability 118: the Markdown reader's file name, never its path. */
8251
8349
  reader: z52.object({
8252
8350
  name: z52.string().min(1).max(255).refine((value) => !hasControlCharacter(value) && !value.includes("/"))
@@ -10704,7 +10802,7 @@ var init_terminal_graphics_compressed = __esm({
10704
10802
 
10705
10803
  // packages/contracts/src/terminal-runtime-inventory.ts
10706
10804
  import { z as z72 } from "zod";
10707
- var TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION, TerminalRuntimeInventoryProjectionV1SchemaZ;
10805
+ var TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION, TerminalRuntimeInventoryProjectionV1SchemaZ, TerminalRuntimeInventoryWindowSchemaZ, TerminalRuntimeInventoryProjectionV2SchemaZ;
10708
10806
  var init_terminal_runtime_inventory = __esm({
10709
10807
  "packages/contracts/src/terminal-runtime-inventory.ts"() {
10710
10808
  "use strict";
@@ -10724,6 +10822,42 @@ var init_terminal_runtime_inventory = __esm({
10724
10822
  "pane ids must be sorted"
10725
10823
  )
10726
10824
  }).strict())();
10825
+ TerminalRuntimeInventoryWindowSchemaZ = /* @__PURE__ */ (() => z72.object({
10826
+ semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ,
10827
+ /** tmux's current window of the session. */
10828
+ active: z72.boolean(),
10829
+ semanticPaneIds: z72.array(TerminalAttachmentSemanticPaneIdSchemaZ).min(1).max(256).refine((values2) => new Set(values2).size === values2.length, "pane ids must be unique")
10830
+ }).strict())();
10831
+ TerminalRuntimeInventoryProjectionV2SchemaZ = /* @__PURE__ */ (() => TerminalRuntimeInventoryProjectionV1SchemaZ.extend({
10832
+ /** In tmux window order. */
10833
+ windows: z72.array(TerminalRuntimeInventoryWindowSchemaZ).max(256)
10834
+ }).strict().superRefine((value, ctx) => {
10835
+ const listed = new Set(value.semanticPaneIds);
10836
+ const seen = /* @__PURE__ */ new Set();
10837
+ const windows = /* @__PURE__ */ new Set();
10838
+ let active3 = 0;
10839
+ for (const window2 of value.windows) {
10840
+ if (windows.has(window2.semanticWindowId))
10841
+ ctx.addIssue({ code: "custom", message: "a window is listed twice", path: ["windows"] });
10842
+ windows.add(window2.semanticWindowId);
10843
+ if (window2.active) active3 += 1;
10844
+ for (const pane of window2.semanticPaneIds) {
10845
+ if (!listed.has(pane) || seen.has(pane))
10846
+ ctx.addIssue({
10847
+ code: "custom",
10848
+ message: "a window pane must be listed once and in the inventory",
10849
+ path: ["windows"]
10850
+ });
10851
+ seen.add(pane);
10852
+ }
10853
+ }
10854
+ if (active3 > 1)
10855
+ ctx.addIssue({
10856
+ code: "custom",
10857
+ message: "at most one window is active",
10858
+ path: ["windows"]
10859
+ });
10860
+ }))();
10727
10861
  }
10728
10862
  });
10729
10863
 
@@ -12247,6 +12381,10 @@ function appThemeOverrideProvenance(theme, status2, glyphs) {
12247
12381
  }
12248
12382
  return legacyThemeOverrideProvenance(explicit);
12249
12383
  }
12384
+ function systemSide(value, appearance) {
12385
+ const preset = findVisualThemePreset(value);
12386
+ return preset?.appearance === appearance ? { [appearance]: preset.id } : {};
12387
+ }
12250
12388
  function parseAppConfig(input) {
12251
12389
  const D = DEFAULT_APP_CONFIG;
12252
12390
  const root = asObject(input);
@@ -12284,6 +12422,8 @@ function parseAppConfig(input) {
12284
12422
  findVisualThemePreset(theme.preset)?.appearance ?? D.theme.mode
12285
12423
  ),
12286
12424
  ...findVisualThemePreset(theme.preset) ? { preset: String(theme.preset) } : {},
12425
+ ...systemSide(theme.light, "light"),
12426
+ ...systemSide(theme.dark, "dark"),
12287
12427
  accent: pickString(theme.accent, D.theme.accent),
12288
12428
  muted: pickString(theme.muted, D.theme.muted),
12289
12429
  fg: pickString(theme.fg, D.theme.fg),
@@ -12950,8 +13090,8 @@ async function readBoundedResponse(fetchImpl, url, maxBytes, policy) {
12950
13090
  const controller = new AbortController();
12951
13091
  let total = 0;
12952
13092
  let timeoutMessage = null;
12953
- const abortWith = (message) => () => {
12954
- timeoutMessage = message();
13093
+ const abortWith = (message2) => () => {
13094
+ timeoutMessage = message2();
12955
13095
  controller.abort();
12956
13096
  };
12957
13097
  const overallTimer = setTimeout(
@@ -12969,9 +13109,9 @@ async function readBoundedResponse(fetchImpl, url, maxBytes, policy) {
12969
13109
  try {
12970
13110
  const response3 = await fetchImpl(url, { signal: controller.signal });
12971
13111
  if (!response3.ok) {
12972
- const message = `HTTP ${response3.status} ${response3.statusText}`;
12973
- if (isTransientHttpStatus(response3.status)) throw new Error(message);
12974
- throw new PermanentDownloadError(message);
13112
+ const message2 = `HTTP ${response3.status} ${response3.statusText}`;
13113
+ if (isTransientHttpStatus(response3.status)) throw new Error(message2);
13114
+ throw new PermanentDownloadError(message2);
12975
13115
  }
12976
13116
  markProgress();
12977
13117
  const declaredLength = Number(response3.headers.get("content-length"));
@@ -13016,8 +13156,8 @@ async function readWithRetries(fetchImpl, url, maxBytes, policy, log) {
13016
13156
  if (error instanceof PermanentDownloadError || attempt >= policy.maxAttempts || Date.now() + delayMs >= policy.deadline) {
13017
13157
  throw error;
13018
13158
  }
13019
- const message = error instanceof Error ? error.message : String(error);
13020
- log(`download attempt ${attempt}/${policy.maxAttempts} failed (${message}); retrying`);
13159
+ const message2 = error instanceof Error ? error.message : String(error);
13160
+ log(`download attempt ${attempt}/${policy.maxAttempts} failed (${message2}); retrying`);
13021
13161
  await new Promise((resolve47) => setTimeout(resolve47, delayMs));
13022
13162
  }
13023
13163
  }
@@ -13081,10 +13221,10 @@ async function downloadTuiBinary(opts = {}) {
13081
13221
  log(`downloading ${url}`);
13082
13222
  gz = await readWithRetries(fetchImpl, url, limits.maxCompressedBytes, policy, log);
13083
13223
  } catch (error) {
13084
- const message = error instanceof Error ? error.message : String(error);
13224
+ const message2 = error instanceof Error ? error.message : String(error);
13085
13225
  const hint = error instanceof PermanentDownloadError ? "Check that the release published both exact-version assets." : "Check your network connection, then retry with `tmux-ide update --tui-binary`, or run the installer again if tmux-ide is not installed yet.";
13086
13226
  throw new Error(
13087
- `could not download the TUI binary and checksum for v${version} (${message}). ${hint}`,
13227
+ `could not download the TUI binary and checksum for v${version} (${message2}). ${hint}`,
13088
13228
  { cause: error }
13089
13229
  );
13090
13230
  }
@@ -13218,9 +13358,9 @@ async function ensureTuiLaunchAvailable(input, options = {}) {
13218
13358
  try {
13219
13359
  downloaded = await (options.download ?? downloadTuiBinary)({ log: options.log });
13220
13360
  } catch (error) {
13221
- const message = error instanceof Error ? error.message : String(error);
13361
+ const message2 = error instanceof Error ? error.message : String(error);
13222
13362
  throw new Error(
13223
- `Automatic OpenTUI runtime acquisition failed: ${message}
13363
+ `Automatic OpenTUI runtime acquisition failed: ${message2}
13224
13364
  Retry with \`tmux-ide update --tui-binary\`, then run \`tmux-ide app\` again.`,
13225
13365
  { cause: error }
13226
13366
  );
@@ -13317,8 +13457,8 @@ var init_errors2 = __esm({
13317
13457
  IdeError = class extends Error {
13318
13458
  code;
13319
13459
  exitCode;
13320
- constructor(message, { code: code2, exitCode = 1, cause } = {}) {
13321
- super(message, { cause });
13460
+ constructor(message2, { code: code2, exitCode = 1, cause } = {}) {
13461
+ super(message2, { cause });
13322
13462
  this.name = "IdeError";
13323
13463
  this.code = code2;
13324
13464
  this.exitCode = exitCode;
@@ -13333,22 +13473,22 @@ var init_errors2 = __esm({
13333
13473
  }
13334
13474
  };
13335
13475
  ConfigError = class extends IdeError {
13336
- constructor(message, code2, { cause } = {}) {
13337
- super(message, { code: code2, exitCode: 1, cause });
13476
+ constructor(message2, code2, { cause } = {}) {
13477
+ super(message2, { code: code2, exitCode: 1, cause });
13338
13478
  this.name = "ConfigError";
13339
13479
  }
13340
13480
  };
13341
13481
  DaemonStartupError = class extends IdeError {
13342
13482
  reason;
13343
- constructor(message, reason, { cause } = {}) {
13344
- super(message, { code: `DAEMON_${reason.toUpperCase()}`, exitCode: 1, cause });
13483
+ constructor(message2, reason, { cause } = {}) {
13484
+ super(message2, { code: `DAEMON_${reason.toUpperCase()}`, exitCode: 1, cause });
13345
13485
  this.name = "DaemonStartupError";
13346
13486
  this.reason = reason;
13347
13487
  }
13348
13488
  };
13349
13489
  DaemonShutdownError = class extends IdeError {
13350
- constructor(message, { cause } = {}) {
13351
- super(message, { code: "DAEMON_SHUTDOWN_FAILED", exitCode: 1, cause });
13490
+ constructor(message2, { cause } = {}) {
13491
+ super(message2, { code: "DAEMON_SHUTDOWN_FAILED", exitCode: 1, cause });
13352
13492
  this.name = "DaemonShutdownError";
13353
13493
  }
13354
13494
  };
@@ -13402,8 +13542,8 @@ function printLayout(config2) {
13402
13542
  }
13403
13543
  }
13404
13544
  }
13405
- function outputError(message, code2, { exitCode = 1 } = {}) {
13406
- throw new IdeError(message, { code: code2, exitCode });
13545
+ function outputError(message2, code2, { exitCode = 1 } = {}) {
13546
+ throw new IdeError(message2, { code: code2, exitCode });
13407
13547
  }
13408
13548
  function printCommandError(error, { json: json3 = false } = {}) {
13409
13549
  if (json3) {
@@ -14765,10 +14905,10 @@ function plainOrThrow(value) {
14765
14905
  if (!plain.ok) throw new PluginRunError(plain.error, null);
14766
14906
  return plain.value;
14767
14907
  }
14768
- function classify(message) {
14769
- if (message.includes(TIMEOUT_MESSAGE) || message.includes(WALL_CLOCK_MESSAGE)) return "timeout";
14770
- if (/not enough memory/u.test(message)) return "memory";
14771
- if (/Aborted\(|RuntimeError/u.test(message)) return "abort";
14908
+ function classify(message2) {
14909
+ if (message2.includes(TIMEOUT_MESSAGE) || message2.includes(WALL_CLOCK_MESSAGE)) return "timeout";
14910
+ if (/not enough memory/u.test(message2)) return "memory";
14911
+ if (/Aborted\(|RuntimeError/u.test(message2)) return "abort";
14772
14912
  return null;
14773
14913
  }
14774
14914
  var MAX_SOURCE_BYTES, PluginRunError, TIMER_GAP_MS, WALL_CLOCK_MESSAGE, FOREIGN_YIELD_MESSAGE, PluginLuaState;
@@ -14781,8 +14921,8 @@ var init_lua_state = __esm({
14781
14921
  MAX_SOURCE_BYTES = 1024 * 1024;
14782
14922
  PluginRunError = class extends Error {
14783
14923
  trip;
14784
- constructor(message, trip) {
14785
- super(message);
14924
+ constructor(message2, trip) {
14925
+ super(message2);
14786
14926
  this.name = "PluginRunError";
14787
14927
  this.trip = trip;
14788
14928
  }
@@ -14846,7 +14986,7 @@ var init_lua_state = __esm({
14846
14986
  const origin = runner.origin;
14847
14987
  runner.pending = Promise.resolve().then(() => fn(list, origin));
14848
14988
  });
14849
- global.set("__ide_log", (level, message, fieldsJson) => {
14989
+ global.set("__ide_log", (level, message2, fieldsJson) => {
14850
14990
  const lvl = level === "debug" || level === "warn" || level === "error" ? level : "info";
14851
14991
  let fields;
14852
14992
  if (typeof fieldsJson === "string") {
@@ -14858,7 +14998,7 @@ var init_lua_state = __esm({
14858
14998
  fields = void 0;
14859
14999
  }
14860
15000
  }
14861
- options.hooks.log(lvl, String(message), fields);
15001
+ options.hooks.log(lvl, String(message2), fields);
14862
15002
  });
14863
15003
  global.set("__ide_resolve", (kind, name) => {
14864
15004
  if (kind !== "file" && kind !== "module" || typeof name !== "string")
@@ -14968,11 +15108,11 @@ var init_lua_state = __esm({
14968
15108
  return [...thread.getStackValues()];
14969
15109
  }
14970
15110
  } catch (error) {
14971
- const message = error instanceof Error ? error.message : String(error);
14972
- const trip = classify(message);
15111
+ const message2 = error instanceof Error ? error.message : String(error);
15112
+ const trip = classify(message2);
14973
15113
  if (trip) this.#hooks.trip(trip);
14974
15114
  if (trip === "abort") this.#broken = "the Lua runtime aborted; reload the plugin";
14975
- throw new PluginRunError(message, trip);
15115
+ throw new PluginRunError(message2, trip);
14976
15116
  } finally {
14977
15117
  lua.luaL_unref(global.address, LUA_REGISTRYINDEX, ref);
14978
15118
  this.#publishActions();
@@ -15155,7 +15295,7 @@ var init_main = __esm({
15155
15295
  });
15156
15296
  return next;
15157
15297
  }
15158
- #log(plugin, level, message, fields) {
15298
+ #log(plugin, level, message2, fields) {
15159
15299
  const now = Date.now();
15160
15300
  let budget2 = this.#logBudgets.get(plugin);
15161
15301
  if (!budget2 || now - budget2.windowStart >= 1e3) {
@@ -15178,7 +15318,7 @@ var init_main = __esm({
15178
15318
  type: "log",
15179
15319
  plugin,
15180
15320
  level,
15181
- message: message.slice(0, 8192),
15321
+ message: message2.slice(0, 8192),
15182
15322
  ...fields ? { fields } : {}
15183
15323
  });
15184
15324
  }
@@ -15197,7 +15337,7 @@ var init_main = __esm({
15197
15337
  hooks: {
15198
15338
  busy: () => this.#emit({ type: "busy", plugin: spec.name }),
15199
15339
  idle: () => this.#emit({ type: "idle", plugin: spec.name }),
15200
- log: (level, message, fields) => onLog ? onLog(level, message) : this.#log(spec.name, level, message, fields),
15340
+ log: (level, message2, fields) => onLog ? onLog(level, message2) : this.#log(spec.name, level, message2, fields),
15201
15341
  trip: (kind) => this.#emit({ type: "trip", plugin: spec.name, kind }),
15202
15342
  actions: (json3) => this.#emit({ type: "actions", plugin: spec.name, actions: json3 })
15203
15343
  }
@@ -15251,10 +15391,10 @@ var init_main = __esm({
15251
15391
  });
15252
15392
  this.#emit({ type: "loaded", plugin: spec.name, ok: true, memoryBytes: state.memoryUsed() });
15253
15393
  } catch (error) {
15254
- const message = error instanceof Error ? error.message : String(error);
15255
- this.#log(spec.name, "error", `load failed: ${message}`);
15394
+ const message2 = error instanceof Error ? error.message : String(error);
15395
+ this.#log(spec.name, "error", `load failed: ${message2}`);
15256
15396
  this.#unload(spec.name);
15257
- this.#emit({ type: "loaded", plugin: spec.name, ok: false, error: message.slice(0, 4096) });
15397
+ this.#emit({ type: "loaded", plugin: spec.name, ok: false, error: message2.slice(0, 4096) });
15258
15398
  }
15259
15399
  }
15260
15400
  #unload(name) {
@@ -15277,13 +15417,13 @@ var init_main = __esm({
15277
15417
  });
15278
15418
  this.#emit({ type: "invoke-result", id: command3.id, ok: true, value });
15279
15419
  } catch (error) {
15280
- const message = error instanceof Error ? error.message : String(error);
15281
- this.#log(command3.plugin, "error", `action ${command3.action} failed: ${message}`);
15420
+ const message2 = error instanceof Error ? error.message : String(error);
15421
+ this.#log(command3.plugin, "error", `action ${command3.action} failed: ${message2}`);
15282
15422
  this.#emit({
15283
15423
  type: "invoke-result",
15284
15424
  id: command3.id,
15285
15425
  ok: false,
15286
- error: message.slice(0, 8192)
15426
+ error: message2.slice(0, 8192)
15287
15427
  });
15288
15428
  }
15289
15429
  }
@@ -15297,12 +15437,12 @@ var init_main = __esm({
15297
15437
  });
15298
15438
  this.#emit({ type: "param-options-result", id: command3.id, ok: true, options });
15299
15439
  } catch (error) {
15300
- const message = error instanceof Error ? error.message : String(error);
15440
+ const message2 = error instanceof Error ? error.message : String(error);
15301
15441
  this.#emit({
15302
15442
  type: "param-options-result",
15303
15443
  id: command3.id,
15304
15444
  ok: false,
15305
- error: message.slice(0, 8192)
15445
+ error: message2.slice(0, 8192)
15306
15446
  });
15307
15447
  }
15308
15448
  }
@@ -15312,8 +15452,8 @@ var init_main = __esm({
15312
15452
  try {
15313
15453
  state = await this.#createState(
15314
15454
  { name: RUN_STATE_NAME, includeRoots: [], moduleRoots: [], settings: {} },
15315
- (level, message) => {
15316
- if (logs.length < 1e3) logs.push({ level, message: message.slice(0, 8192) });
15455
+ (level, message2) => {
15456
+ if (logs.length < 1e3) logs.push({ level, message: message2.slice(0, 8192) });
15317
15457
  }
15318
15458
  );
15319
15459
  const values2 = await state.runSource(command3.code, command3.chunkName, {
@@ -15322,12 +15462,12 @@ var init_main = __esm({
15322
15462
  });
15323
15463
  this.#emit({ type: "run-result", id: command3.id, ok: true, values: values2, logs });
15324
15464
  } catch (error) {
15325
- const message = error instanceof PluginRunError || error instanceof Error ? error.message : String(error);
15465
+ const message2 = error instanceof PluginRunError || error instanceof Error ? error.message : String(error);
15326
15466
  this.#emit({
15327
15467
  type: "run-result",
15328
15468
  id: command3.id,
15329
15469
  ok: false,
15330
- error: message.slice(0, 8192),
15470
+ error: message2.slice(0, 8192),
15331
15471
  logs
15332
15472
  });
15333
15473
  } finally {
@@ -15376,7 +15516,7 @@ var require_package = __commonJS({
15376
15516
  "package.json"(exports, module) {
15377
15517
  module.exports = {
15378
15518
  name: "tmux-ide",
15379
- version: "2.9.25",
15519
+ version: "2.9.27",
15380
15520
  description: "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
15381
15521
  type: "module",
15382
15522
  bin: {
@@ -15415,6 +15555,7 @@ var require_package = __commonJS({
15415
15555
  "test:tmux-boundary": "node scripts/test-tmux-boundary.mjs",
15416
15556
  build: "pnpm build:cli",
15417
15557
  "build:cli": "node scripts/build-cli.mjs",
15558
+ "check:cli-bundle": "node scripts/check-cli-bundle.mjs",
15418
15559
  "build:macos-notifier": "node scripts/build-macos-notifier.mjs",
15419
15560
  "build:tui": "bun scripts/build-tui.mjs",
15420
15561
  prepack: "pnpm build:cli",
@@ -15499,7 +15640,7 @@ var require_package = __commonJS({
15499
15640
  "developer-tools"
15500
15641
  ],
15501
15642
  engines: {
15502
- node: ">=20"
15643
+ node: ">=24"
15503
15644
  },
15504
15645
  repository: {
15505
15646
  type: "git",
@@ -16204,8 +16345,8 @@ var init_project_registry = __esm({
16204
16345
  });
16205
16346
  ProjectRegistryError = class extends Error {
16206
16347
  code;
16207
- constructor(message, code2) {
16208
- super(message);
16348
+ constructor(message2, code2) {
16349
+ super(message2);
16209
16350
  this.name = "ProjectRegistryError";
16210
16351
  this.code = code2;
16211
16352
  }
@@ -17157,8 +17298,8 @@ var init_canonical_daemon = __esm({
17157
17298
  MAX_DAEMON_CLAIM_BYTES = 4 * 1024;
17158
17299
  activeClaims = /* @__PURE__ */ new Map();
17159
17300
  CanonicalDaemonReservationError = class extends Error {
17160
- constructor(message) {
17161
- super(`Supervisor reservation refused: ${message}`);
17301
+ constructor(message2) {
17302
+ super(`Supervisor reservation refused: ${message2}`);
17162
17303
  this.name = "CanonicalDaemonReservationError";
17163
17304
  }
17164
17305
  };
@@ -17716,8 +17857,8 @@ var init_report = __esm({
17716
17857
  });
17717
17858
 
17718
17859
  // packages/daemon/src/control/frames.ts
17719
- function encodeFrame(message) {
17720
- return `${JSON.stringify(message)}
17860
+ function encodeFrame(message2) {
17861
+ return `${JSON.stringify(message2)}
17721
17862
  `;
17722
17863
  }
17723
17864
  function createFrameSplitter() {
@@ -19431,13 +19572,13 @@ function decideNotifications(events, clients, lastNotified, nowMs, states2 = NOT
19431
19572
  if (last !== void 0 && nowMs - last < NOTIFY_DEBOUNCE_MS) continue;
19432
19573
  if (appFocus?.attached && ev.paneId && appFocus.panes.includes(ev.paneId)) continue;
19433
19574
  nextLastNotified.set(key2, nowMs);
19434
- const message = notifyMessage(ev);
19575
+ const message2 = notifyMessage(ev);
19435
19576
  for (const c of clients) {
19436
19577
  if (suppressToastFor(c, ev)) continue;
19437
- toasts.push({ client: c.client, message });
19578
+ toasts.push({ client: c.client, message: message2 });
19438
19579
  }
19439
19580
  system.push({
19440
- message,
19581
+ message: message2,
19441
19582
  session: ev.session,
19442
19583
  state: ev.to,
19443
19584
  paneId: ev.paneId ?? null,
@@ -19501,9 +19642,9 @@ function readAppFocus(nowMs = Date.now()) {
19501
19642
  }
19502
19643
  function sendToasts(toasts) {
19503
19644
  if (resolveRuntimeNamespace().development) return;
19504
- for (const { client, message } of toasts) {
19645
+ for (const { client, message: message2 } of toasts) {
19505
19646
  try {
19506
- runTmux(["display-message", "-c", client, "-d", "3000", message]);
19647
+ runTmux(["display-message", "-c", client, "-d", "3000", message2]);
19507
19648
  } catch {
19508
19649
  }
19509
19650
  }
@@ -20469,8 +20610,8 @@ function dispatchUpdateToast(deps2, version) {
20469
20610
  if (!mark || !listClients || !toast) return;
20470
20611
  if (prefs && !prefs.toast) return;
20471
20612
  if (!mark(version)) return;
20472
- const message = `\u2B06 tmux-ide v${version} available \u2014 run: tmux-ide update`;
20473
- toast(listClients().map((c) => ({ client: c.client, message })));
20613
+ const message2 = `\u2B06 tmux-ide v${version} available \u2014 run: tmux-ide update`;
20614
+ toast(listClients().map((c) => ({ client: c.client, message: message2 })));
20474
20615
  }
20475
20616
  function seedSessionStatus(session) {
20476
20617
  try {
@@ -20685,8 +20826,8 @@ var init_dispatch = __esm({
20685
20826
  init_errors2();
20686
20827
  ControlVerbError = class extends Error {
20687
20828
  code;
20688
- constructor(code2, message) {
20689
- super(message);
20829
+ constructor(code2, message2) {
20830
+ super(message2);
20690
20831
  this.code = code2;
20691
20832
  }
20692
20833
  };
@@ -20696,11 +20837,11 @@ var init_dispatch = __esm({
20696
20837
  ok: true,
20697
20838
  data
20698
20839
  });
20699
- fail = (id2, code2, message) => ({
20840
+ fail = (id2, code2, message2) => ({
20700
20841
  v: CONTROL_PROTOCOL_VERSION,
20701
20842
  id: id2,
20702
20843
  ok: false,
20703
- error: { code: code2, message }
20844
+ error: { code: code2, message: message2 }
20704
20845
  });
20705
20846
  }
20706
20847
  });
@@ -21202,12 +21343,12 @@ async function loadWorkspaceConfig(dir, options = {}) {
21202
21343
  });
21203
21344
  }
21204
21345
  if (resolution.config.kind !== "workspace") {
21205
- const message = resolution.config.kind === "legacy" ? `Found legacy config at ${resolution.config.path}; this loader requires .tmux-ide/workspace.yml` : `No .tmux-ide/workspace.yml config was found for ${resolution.inputDir}`;
21346
+ const message2 = resolution.config.kind === "legacy" ? `Found legacy config at ${resolution.config.path}; this loader requires .tmux-ide/workspace.yml` : `No .tmux-ide/workspace.yml config was found for ${resolution.inputDir}`;
21206
21347
  throw new WorkspaceConfigLoadError({
21207
21348
  code: "WORKSPACE_CONFIG_REQUIRED",
21208
21349
  stage: "resolution",
21209
21350
  path: resolution.config.path,
21210
- message
21351
+ message: message2
21211
21352
  });
21212
21353
  }
21213
21354
  const basePath = resolution.config.path;
@@ -21313,8 +21454,8 @@ var init_legacy_config_adapter = __esm({
21313
21454
 
21314
21455
  // packages/daemon/src/lib/legacy-config-migration.ts
21315
21456
  import yaml3 from "js-yaml";
21316
- function pushDiagnostic(diagnostics, code2, path2, message) {
21317
- diagnostics.push({ code: code2, path: path2, message });
21457
+ function pushDiagnostic(diagnostics, code2, path2, message2) {
21458
+ diagnostics.push({ code: code2, path: path2, message: message2 });
21318
21459
  }
21319
21460
  function cloneTerminalPane(pane) {
21320
21461
  const result2 = {};
@@ -21336,16 +21477,16 @@ function convertLegacyConfigToWorkspace(legacy) {
21336
21477
  const rows = legacy.rows.map((row, rowIndex) => ({
21337
21478
  ...row.size === void 0 ? {} : { size: row.size },
21338
21479
  panes: row.panes.map((pane, paneIndex) => {
21339
- for (const [key2, code2, message] of PANE_UNSUPPORTED) {
21480
+ for (const [key2, code2, message2] of PANE_UNSUPPORTED) {
21340
21481
  if (pane[key2] !== void 0) {
21341
- pushDiagnostic(diagnostics, code2, `rows.${rowIndex}.panes.${paneIndex}.${key2}`, message);
21482
+ pushDiagnostic(diagnostics, code2, `rows.${rowIndex}.panes.${paneIndex}.${key2}`, message2);
21342
21483
  }
21343
21484
  }
21344
21485
  return cloneTerminalPane(pane);
21345
21486
  })
21346
21487
  }));
21347
- for (const [key2, code2, message] of ROOT_UNSUPPORTED) {
21348
- if (legacy[key2] !== void 0) pushDiagnostic(diagnostics, code2, String(key2), message);
21488
+ for (const [key2, code2, message2] of ROOT_UNSUPPORTED) {
21489
+ if (legacy[key2] !== void 0) pushDiagnostic(diagnostics, code2, String(key2), message2);
21349
21490
  }
21350
21491
  const candidate = {
21351
21492
  version: 1,
@@ -21465,13 +21606,13 @@ function loadedWorkspaceToResolved(loaded) {
21465
21606
  migrationHint: null
21466
21607
  };
21467
21608
  }
21468
- function configReadError(message, cause) {
21469
- return new ConfigError(message, "READ_ERROR", {
21609
+ function configReadError(message2, cause) {
21610
+ return new ConfigError(message2, "READ_ERROR", {
21470
21611
  cause: cause instanceof Error ? cause : new Error(String(cause))
21471
21612
  });
21472
21613
  }
21473
- function configInvalidError(message, cause) {
21474
- return new ConfigError(message, "INVALID_CONFIG", {
21614
+ function configInvalidError(message2, cause) {
21615
+ return new ConfigError(message2, "INVALID_CONFIG", {
21475
21616
  cause: cause instanceof Error ? cause : new Error(String(cause))
21476
21617
  });
21477
21618
  }
@@ -21735,8 +21876,8 @@ var init_resolved_config = __esm({
21735
21876
  init_legacy_config_migration();
21736
21877
  WorkspaceConfigWriteError = class extends IdeError {
21737
21878
  path;
21738
- constructor(message, code2, path2, cause) {
21739
- super(message, {
21879
+ constructor(message2, code2, path2, cause) {
21880
+ super(message2, {
21740
21881
  code: code2,
21741
21882
  exitCode: 1,
21742
21883
  cause: cause instanceof Error ? cause : cause === void 0 ? void 0 : new Error(String(cause))
@@ -21746,8 +21887,8 @@ var init_resolved_config = __esm({
21746
21887
  }
21747
21888
  };
21748
21889
  UnsupportedLegacyConfigMutationError = class extends IdeError {
21749
- constructor(diagnostics, message = `Legacy ide.yml contains unsupported fields that would be dropped by config mutation. Run \`tmux-ide migrate --dry-run\` and move to .tmux-ide/workspace.yml first.`) {
21750
- super(message, { code: "LEGACY_CONFIG_MUTATION_UNSUPPORTED", exitCode: 1 });
21890
+ constructor(diagnostics, message2 = `Legacy ide.yml contains unsupported fields that would be dropped by config mutation. Run \`tmux-ide migrate --dry-run\` and move to .tmux-ide/workspace.yml first.`) {
21891
+ super(message2, { code: "LEGACY_CONFIG_MUTATION_UNSUPPORTED", exitCode: 1 });
21751
21892
  this.diagnostics = diagnostics;
21752
21893
  this.name = "UnsupportedLegacyConfigMutationError";
21753
21894
  }
@@ -23055,8 +23196,8 @@ var init_project_runtime_errors = __esm({
23055
23196
  "use strict";
23056
23197
  ProjectRuntimeRepositoryError = class extends Error {
23057
23198
  code;
23058
- constructor(code2, message) {
23059
- super(message);
23199
+ constructor(code2, message2) {
23200
+ super(message2);
23060
23201
  this.name = new.target.name;
23061
23202
  this.code = code2;
23062
23203
  }
@@ -24469,8 +24610,8 @@ var init_mission_repository = __esm({
24469
24610
  MISSIONS_STREAM = "missions";
24470
24611
  MissionRepositoryError = class extends IdeError {
24471
24612
  missionCode;
24472
- constructor(message, code2, { cause } = {}) {
24473
- super(message, { code: code2, cause });
24613
+ constructor(message2, code2, { cause } = {}) {
24614
+ super(message2, { code: code2, cause });
24474
24615
  this.name = "MissionRepositoryError";
24475
24616
  this.missionCode = code2;
24476
24617
  }
@@ -26043,8 +26184,8 @@ var init_bootstrap_coordinator = __esm({
26043
26184
  code;
26044
26185
  reason;
26045
26186
  cause;
26046
- constructor(code2, message, options = {}) {
26047
- super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
26187
+ constructor(code2, message2, options = {}) {
26188
+ super(message2, options.cause === void 0 ? void 0 : { cause: options.cause });
26048
26189
  this.name = "DaemonBootstrapError";
26049
26190
  this.code = code2;
26050
26191
  this.reason = options.reason ?? null;
@@ -27007,14 +27148,14 @@ import { randomUUID as randomUUID10 } from "node:crypto";
27007
27148
  import { execFileSync as execFileSync15 } from "node:child_process";
27008
27149
  import { resolve as resolve20, join as join30 } from "node:path";
27009
27150
  import { existsSync as existsSync24, mkdirSync as mkdirSync20, writeFileSync as writeFileSync18 } from "node:fs";
27010
- function writeDispatchFile(dir, paneId, message) {
27011
- if (message.length <= LONG_MESSAGE_THRESHOLD) return null;
27151
+ function writeDispatchFile(dir, paneId, message2) {
27152
+ if (message2.length <= LONG_MESSAGE_THRESHOLD) return null;
27012
27153
  const dispatchDir = join30(dir, ".tasks", "dispatch");
27013
27154
  if (!existsSync24(dispatchDir)) mkdirSync20(dispatchDir, { recursive: true });
27014
27155
  const paneSlug = paneId.replace("%", "");
27015
27156
  const filename = `send-${paneSlug}-${Date.now()}-${randomUUID10().slice(0, 8)}.md`;
27016
27157
  const filePath = join30(dispatchDir, filename);
27017
- writeFileSync18(filePath, message);
27158
+ writeFileSync18(filePath, message2);
27018
27159
  return { filePath, triggerCmd: `Read and execute: .tasks/dispatch/${filename}` };
27019
27160
  }
27020
27161
  function resolvePane(panes, target) {
@@ -27034,11 +27175,11 @@ function resolvePane(panes, target) {
27034
27175
  if (byPattern) return byPattern;
27035
27176
  return null;
27036
27177
  }
27037
- function prepareMessage(message, busyStatus) {
27178
+ function prepareMessage(message2, busyStatus) {
27038
27179
  if (busyStatus === "agent") {
27039
- return message.replace(/\n+/g, " ").trim();
27180
+ return message2.replace(/\n+/g, " ").trim();
27040
27181
  }
27041
- return message;
27182
+ return message2;
27042
27183
  }
27043
27184
  function deliverMessage(opts) {
27044
27185
  const { session, target, noEnter, dir } = opts;
@@ -27063,13 +27204,13 @@ ${available}`, {
27063
27204
  });
27064
27205
  }
27065
27206
  const busyStatus = getPaneBusyStatus(session, pane.id);
27066
- const message = prepareMessage(opts.message, busyStatus);
27207
+ const message2 = prepareMessage(opts.message, busyStatus);
27067
27208
  let sentViaFile = false;
27068
27209
  if (noEnter) {
27069
- sendText(session, pane.id, message);
27210
+ sendText(session, pane.id, message2);
27070
27211
  } else {
27071
- const dispatch = dir ? writeDispatchFile(dir, pane.id, message) : null;
27072
- if (!sendCommand(session, pane.id, dispatch?.triggerCmd ?? message)) {
27212
+ const dispatch = dir ? writeDispatchFile(dir, pane.id, message2) : null;
27213
+ if (!sendCommand(session, pane.id, dispatch?.triggerCmd ?? message2)) {
27073
27214
  throw new IdeError(`Could not send input to pane "${pane.id}"; delivery was not repeated.`, {
27074
27215
  code: "PANE_INPUT_FAILED"
27075
27216
  });
@@ -27085,7 +27226,7 @@ ${available}`, {
27085
27226
  title: pane.title,
27086
27227
  role: pane.role
27087
27228
  },
27088
- message,
27229
+ message: message2,
27089
27230
  busyStatus,
27090
27231
  sentViaFile,
27091
27232
  ...busyStatus === "agent" ? { warning: "agent_busy" } : {}
@@ -27207,14 +27348,14 @@ async function send(targetDir, opts) {
27207
27348
  });
27208
27349
  }
27209
27350
  const result2 = await deliverMessageThroughDaemon({ session, target, message: rawMessage, noEnter, dir }) ?? deliverMessage({ session, target, message: rawMessage, noEnter, dir });
27210
- const { message, busyStatus } = result2;
27351
+ const { message: message2, busyStatus } = result2;
27211
27352
  const pane = result2.target;
27212
27353
  if (json3) {
27213
27354
  console.log(JSON.stringify(result2, null, 2));
27214
27355
  return;
27215
27356
  }
27216
27357
  const label4 = pane.name ?? pane.title;
27217
- const preview = message.length > 60 ? message.slice(0, 60) + "..." : message;
27358
+ const preview = message2.length > 60 ? message2.slice(0, 60) + "..." : message2;
27218
27359
  console.log(`Sent to "${label4}" (${pane.paneId}): ${preview}`);
27219
27360
  if (busyStatus === "agent") {
27220
27361
  console.log("Warning: agent appears busy. Message sent anyway.");
@@ -27895,8 +28036,8 @@ var init_client = __esm({
27895
28036
  init_server();
27896
28037
  ControlRequestError = class extends Error {
27897
28038
  code;
27898
- constructor(code2, message) {
27899
- super(message);
28039
+ constructor(code2, message2) {
28040
+ super(message2);
27900
28041
  this.code = code2;
27901
28042
  }
27902
28043
  };
@@ -28044,8 +28185,8 @@ var init_development_state = __esm({
28044
28185
  "use strict";
28045
28186
  execute = promisify(execFile7);
28046
28187
  DevelopmentOperationError = class extends Error {
28047
- constructor(reason, message, receipt, diagnostic4) {
28048
- super(message);
28188
+ constructor(reason, message2, receipt, diagnostic4) {
28189
+ super(message2);
28049
28190
  this.reason = reason;
28050
28191
  this.receipt = receipt;
28051
28192
  this.diagnostic = diagnostic4;
@@ -28061,8 +28202,8 @@ var init_development_state = __esm({
28061
28202
  import { createHash as createHash10 } from "node:crypto";
28062
28203
  import { readFileSync as readFileSync26, readlinkSync as readlinkSync4, lstatSync as lstatSync11, opendirSync as opendirSync2 } from "node:fs";
28063
28204
  import { join as join32, dirname as dirname28 } from "node:path";
28064
- function suspensionRefusal(message) {
28065
- throw new DevelopmentOperationError("suspension-unverified", message);
28205
+ function suspensionRefusal(message2) {
28206
+ throw new DevelopmentOperationError("suspension-unverified", message2);
28066
28207
  }
28067
28208
  function validateContainerBinding(binding) {
28068
28209
  if (!binding || typeof binding.project !== "string" || typeof binding.containerId !== "string" || typeof binding.volumesHash !== "string" || !/^[a-z][a-z0-9-]{1,62}$/u.test(binding.project) || !HASH.test(binding.containerId) || !HASH.test(binding.volumesHash))
@@ -28355,7 +28496,7 @@ function parseSessionPaneDescriptorReply(lines) {
28355
28496
  continue;
28356
28497
  }
28357
28498
  const encoded = utf8Line.split(" ");
28358
- if (encoded.length < 21 || encoded.length > 25) continue;
28499
+ if (encoded.length < 21 || encoded.length > 26) continue;
28359
28500
  const [
28360
28501
  runtimePaneId = "",
28361
28502
  semanticPaneId3 = "",
@@ -28381,7 +28522,8 @@ function parseSessionPaneDescriptorReply(lines) {
28381
28522
  nameSource2 = "",
28382
28523
  browserIconRaw = "",
28383
28524
  readerRaw = "",
28384
- panePidRaw = ""
28525
+ panePidRaw = "",
28526
+ browserControl = ""
28385
28527
  ] = encoded.map(decodeTmuxArgument);
28386
28528
  if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32) continue;
28387
28529
  if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32) continue;
@@ -28400,6 +28542,7 @@ function parseSessionPaneDescriptorReply(lines) {
28400
28542
  }
28401
28543
  descriptors.push({
28402
28544
  browserIcon: browserIcon(browserIconRaw),
28545
+ browserKind: terminalBrowserKind(browserControl, currentCommand),
28403
28546
  reader: readerOption(readerRaw, panePidRaw),
28404
28547
  sessionName,
28405
28548
  runtimePaneId,
@@ -28442,6 +28585,17 @@ function decodeControlReplyUtf8(value) {
28442
28585
  function positiveInteger(value, fallback) {
28443
28586
  return Number.isSafeInteger(value) && value > 0 ? value : fallback;
28444
28587
  }
28588
+ function terminalBrowserKind(control, currentCommand, alive = processAlive) {
28589
+ if (control.length > 0 && control.length <= 4096) {
28590
+ try {
28591
+ const pid = JSON.parse(control)?.pid;
28592
+ if (typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && alive(pid))
28593
+ return "native";
28594
+ } catch {
28595
+ }
28596
+ }
28597
+ return /^terminal-browser?$/u.test(currentCommand) ? "plain" : null;
28598
+ }
28445
28599
  var SESSION_PANE_DESCRIPTOR_FORMAT, VOLATILE_DESCRIPTOR_FIELDS, SessionDescriptorDiscovery, STRICT_UTF8_DECODER;
28446
28600
  var init_session_descriptor_discovery = __esm({
28447
28601
  "packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts"() {
@@ -28474,7 +28628,9 @@ var init_session_descriptor_discovery = __esm({
28474
28628
  "#{qa:@tmux_ide_browser_icon}",
28475
28629
  "#{qa:@tmux_ide_reader}",
28476
28630
  // The reader option belongs to the pane only when its own process set it.
28477
- "#{pane_pid}"
28631
+ "#{pane_pid}",
28632
+ // Set only by a terminal browser that has tmux-ide's native controls (#718).
28633
+ "#{qa:@tmux_ide_browser_control}"
28478
28634
  ].join(" ");
28479
28635
  VOLATILE_DESCRIPTOR_FIELDS = /* @__PURE__ */ new Set([
28480
28636
  4,
@@ -30253,8 +30409,8 @@ function sanitizeLogPayload(data, options = {}) {
30253
30409
  bytes = byteLength(serialized);
30254
30410
  return { data: summary, bytes, truncated: true, renamedKeys };
30255
30411
  }
30256
- function sanitizeLogMessage(message, secrets2 = EMPTY, budget2 = DEFAULT_LOG_BUDGET) {
30257
- return truncateString(redactText(String(message), secrets2), budget2.maxMessageBytes);
30412
+ function sanitizeLogMessage(message2, secrets2 = EMPTY, budget2 = DEFAULT_LOG_BUDGET) {
30413
+ return truncateString(redactText(String(message2), secrets2), budget2.maxMessageBytes);
30258
30414
  }
30259
30415
  function safeStringify(value) {
30260
30416
  try {
@@ -30344,14 +30500,14 @@ function writeToStream(name, line) {
30344
30500
  markStreamFailed(name, error);
30345
30501
  }
30346
30502
  }
30347
- function writeStructuredLog(level, component, message, data) {
30503
+ function writeStructuredLog(level, component, message2, data) {
30348
30504
  if (LEVEL_RANK[level] < LEVEL_RANK[minLevel]) return;
30349
30505
  const payload = sanitizeLogPayload(data, { secrets, budget });
30350
30506
  const entry = {
30351
30507
  ts: (/* @__PURE__ */ new Date()).toISOString(),
30352
30508
  level,
30353
30509
  component: sanitizeLogMessage(String(component), secrets, budget).slice(0, 128),
30354
- msg: sanitizeLogMessage(message, secrets, budget),
30510
+ msg: sanitizeLogMessage(message2, secrets, budget),
30355
30511
  pid: process.pid,
30356
30512
  ...identity2.instanceId ? { instanceId: identity2.instanceId } : {},
30357
30513
  ...identity2.version ? { version: identity2.version } : {},
@@ -33866,8 +34022,8 @@ function previousBindingsByRuntime(bindings) {
33866
34022
  }
33867
34023
  return byRuntime;
33868
34024
  }
33869
- function diagnostic(code2, runtimePaneId, semanticPaneId3, message, degraded) {
33870
- return { code: code2, runtimePaneId, semanticPaneId: semanticPaneId3, message, degraded };
34025
+ function diagnostic(code2, runtimePaneId, semanticPaneId3, message2, degraded) {
34026
+ return { code: code2, runtimePaneId, semanticPaneId: semanticPaneId3, message: message2, degraded };
33871
34027
  }
33872
34028
  var RUNTIME_PANE_ID, DEFAULT_GENERATION_ATTEMPTS;
33873
34029
  var init_workspace_tmux_adapter = __esm({
@@ -34649,6 +34805,9 @@ var init_session_channel = __esm({
34649
34805
  await this.captureAttachedSessionIdentity();
34650
34806
  this.io.send("refresh-client -B 'tmux-ide-browser-icon:%*:#{@tmux_ide_browser_icon}'");
34651
34807
  this.io.send("refresh-client -B 'tmux-ide-reader:%*:#{@tmux_ide_reader}'");
34808
+ this.io.send(
34809
+ "refresh-client -B 'tmux-ide-browser-kind:%*:#{@tmux_ide_browser_control}#{m:terminal-browse*,#{pane_current_command}}'"
34810
+ );
34652
34811
  this.io.send("refresh-client -B 'tmux-ide-pane-borders:@*:#{pane-border-status}'");
34653
34812
  this.io.send("refresh-client -B 'tmux-ide-copy-keys:@*:#{mode-keys}'");
34654
34813
  this.io.send("refresh-client -B 'tmux-ide-pane-history:%*:#{history_size}'");
@@ -36350,7 +36509,7 @@ var init_session_channel = __esm({
36350
36509
  onNotify(name, rest) {
36351
36510
  if (name === "window-add" || name === "window-close" || name === "unlinked-window-add" || name === "unlinked-window-close" || name === "session-renamed" || name === "sessions-changed")
36352
36511
  this.opts.onWindowTopologyChanged?.();
36353
- if (name === "subscription-changed" && (rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader "))) {
36512
+ if (name === "subscription-changed" && (rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader ") || rest.startsWith("tmux-ide-browser-kind "))) {
36354
36513
  this.scheduleSync();
36355
36514
  return;
36356
36515
  }
@@ -36671,6 +36830,7 @@ var init_session_channel = __esm({
36671
36830
  displayName: display?.name ?? null,
36672
36831
  displayNameSource: display?.source ?? null,
36673
36832
  browserIcon: pane?.descriptor?.browserIcon ?? null,
36833
+ browserKind: pane?.descriptor?.browserKind ?? null,
36674
36834
  reader: pane?.descriptor?.reader ?? null,
36675
36835
  left: leaf.left,
36676
36836
  top: leaf.top,
@@ -39944,9 +40104,9 @@ var init_native_journal_control_connection = __esm({
39944
40104
  );
39945
40105
  this.#phaseTimer.unref?.();
39946
40106
  }
39947
- #fail(message) {
40107
+ #fail(message2) {
39948
40108
  this.#clearPhaseDeadline();
39949
- this.#failure ??= new Error(message);
40109
+ this.#failure ??= new Error(message2);
39950
40110
  this.#pending?.reject(this.#failure);
39951
40111
  this.#pending = null;
39952
40112
  this.#frame = null;
@@ -41496,8 +41656,8 @@ var init_fleet_lifecycle_authority = __esm({
41496
41656
  MAX_REPLAY_OPERATIONS = 128;
41497
41657
  sleep2 = (milliseconds) => new Promise((resolve47) => setTimeout(resolve47, milliseconds));
41498
41658
  FleetLifecycleAuthorityError = class extends Error {
41499
- constructor(code2, message) {
41500
- super(message);
41659
+ constructor(code2, message2) {
41660
+ super(message2);
41501
41661
  this.code = code2;
41502
41662
  }
41503
41663
  code;
@@ -42162,8 +42322,8 @@ var init_semantic_pane_catalog = __esm({
42162
42322
  SemanticPaneCatalogError = class extends Error {
42163
42323
  code;
42164
42324
  target;
42165
- constructor(code2, target, message) {
42166
- super(message);
42325
+ constructor(code2, target, message2) {
42326
+ super(message2);
42167
42327
  this.name = "SemanticPaneCatalogError";
42168
42328
  this.code = code2;
42169
42329
  this.target = target;
@@ -43152,15 +43312,35 @@ function createNativeTmuxSessionOpener(options) {
43152
43312
  const open5 = async (liveSessionId, observed) => {
43153
43313
  assertOpen();
43154
43314
  const records = await options.run([
43155
- "list-sessions",
43315
+ "list-panes",
43316
+ "-a",
43156
43317
  "-F",
43157
- "#{pid} #{session_id} #{session_created} #{session_name}"
43318
+ `#{pid} #{session_id} #{session_created} #{${ADOPTED_OPTION2}} #{${SEMANTIC_WINDOW_OPTION2}} #{${SEMANTIC_PANE_OPTION3}} #{session_name}`
43158
43319
  ]);
43159
- const matches = records.replace(/\n+$/u, "").split("\n").map((line) => line.split(" ")).filter(
43160
- ([pid, id2, created2, name2]) => pid && /^\d+$/.test(pid) && id2 && /^\$\d+$/.test(id2) && created2 && /^\d+$/.test(created2) && name2 && isVisibleFleetSession(name2) && liveSessionIdForNativeIdentity(pid, id2, created2) === liveSessionId
43320
+ const rows = records.replace(/\n+$/u, "").split("\n").map((line) => line.split(" ")).filter((fields) => fields.length >= 7).map((fields) => ({
43321
+ // A tab can only come from a window or pane stamp: such a row never
43322
+ // takes the fast path below.
43323
+ exact: fields.length === 7,
43324
+ pid: fields[0],
43325
+ id: fields[1],
43326
+ created: fields[2],
43327
+ adopted: fields[3],
43328
+ window: fields.slice(4, -2).join(" "),
43329
+ pane: fields.at(-2),
43330
+ name: fields.at(-1)
43331
+ })).filter(
43332
+ ({ pid, id: id2, created: created2, name: name2 }) => /^\d+$/.test(pid) && /^\$\d+$/.test(id2) && /^\d+$/.test(created2) && name2 && isVisibleFleetSession(name2) && liveSessionIdForNativeIdentity(pid, id2, created2) === liveSessionId
43161
43333
  );
43162
- if (matches.length !== 1) throw new Error("Selected live tmux session is no longer available");
43163
- const [, nativeSessionId, created, name] = matches[0];
43334
+ if (new Set(rows.map((row) => row.id)).size !== 1)
43335
+ throw new Error("Selected live tmux session is no longer available");
43336
+ const { id: nativeSessionId, created, name } = rows[0];
43337
+ const aliases = options.registry.list().filter((entry) => entry.sessionName === name);
43338
+ if (!observed && aliases.length === 1 && !options.registry.isVolatile(aliases[0].name) && rows.every(
43339
+ (row) => row.exact && row.adopted === "1" && row.window.length > 0 && hasValidPaneStamp(row.pane)
43340
+ )) {
43341
+ assertOpen();
43342
+ return { workspaceName: aliases[0].name, liveSessionId };
43343
+ }
43164
43344
  const run = async (args) => {
43165
43345
  assertOpen();
43166
43346
  const sentinel = `tmux-session-stale.${randomUUID25()}`;
@@ -44647,11 +44827,11 @@ var init_control_channel = __esm({
44647
44827
  owner.retiring = true;
44648
44828
  if (owner.timer) clearTimeout(owner.timer);
44649
44829
  owner.timer = null;
44650
- const abort = (message) => {
44830
+ const abort = (message2) => {
44651
44831
  if (this.atomicCollectorOwner !== owner) return;
44652
44832
  try {
44653
- this.core.fail(message);
44654
- this.noteExit(message);
44833
+ this.core.fail(message2);
44834
+ this.noteExit(message2);
44655
44835
  } finally {
44656
44836
  void this.dispose();
44657
44837
  }
@@ -45162,8 +45342,8 @@ var init_mirror_service = __esm({
45162
45342
  entry.channel.sendKey(semanticPaneId3, key2, performanceTraceId);
45163
45343
  }
45164
45344
  assertWindowOwnership(session) {
45165
- const message = this.windowOwnershipMessage(session);
45166
- if (message) throw new Error(message);
45345
+ const message2 = this.windowOwnershipMessage(session);
45346
+ if (message2) throw new Error(message2);
45167
45347
  }
45168
45348
  /** Registered-window ownership is being read again; input waits for it. */
45169
45349
  windowOwnershipPending() {
@@ -45760,8 +45940,8 @@ var init_semantic_mutation_executor = __esm({
45760
45940
  init_runtime_observability();
45761
45941
  init_semantic_mutation_resource_changes();
45762
45942
  SessionRuntimeIntentError = class extends Error {
45763
- constructor(outcome, message, options) {
45764
- super(message, options);
45943
+ constructor(outcome, message2, options) {
45944
+ super(message2, options);
45765
45945
  this.outcome = outcome;
45766
45946
  this.name = "SessionRuntimeIntentError";
45767
45947
  }
@@ -48194,14 +48374,30 @@ function terminalReplicaRowsEqualProfiled(left, right, profile) {
48194
48374
  function hashTerminalReplicaSnapshot(snapshot3) {
48195
48375
  return hashTerminalReplicaSnapshotProfiled(snapshot3);
48196
48376
  }
48197
- function hashTerminalReplicaSnapshotProfiled(snapshot3, profile, instrumentation) {
48377
+ function dropTerminalReplicaRowsDigestPrefix(digest3, prefix, remaining) {
48378
+ if (!/^[0-9a-f]{16}$/u.test(digest3)) throw new TypeError("Invalid rows digest");
48379
+ const hash = BigInt.asUintN(
48380
+ 64,
48381
+ BigInt(`0x${digest3}`) - BigInt(`0x${hashTerminalReplicaRows(prefix)}`) * pow64(ROW_SEQUENCE_BASE, remaining)
48382
+ );
48383
+ return hash.toString(16).padStart(16, "0");
48384
+ }
48385
+ function popTerminalReplicaRowsDigestSuffix(digest3, suffix) {
48386
+ if (!/^[0-9a-f]{16}$/u.test(digest3)) throw new TypeError("Invalid rows digest");
48387
+ const hash = BigInt.asUintN(
48388
+ 64,
48389
+ (BigInt(`0x${digest3}`) - BigInt(`0x${hashTerminalReplicaRows(suffix)}`)) * pow64(ROW_SEQUENCE_BASE_INVERSE, suffix.length)
48390
+ );
48391
+ return hash.toString(16).padStart(16, "0");
48392
+ }
48393
+ function hashTerminalReplicaSnapshotProfiled(snapshot3, profile, instrumentation, historyDigest) {
48198
48394
  const started = readProfileClock(instrumentation);
48199
48395
  const hash = hashStable([
48200
48396
  "terminal-replica-v1",
48201
48397
  snapshot3.cols,
48202
48398
  snapshot3.rows,
48203
48399
  hashTerminalReplicaRows(snapshot3.grid, profile, instrumentation),
48204
- hashTerminalReplicaRows(snapshot3.history, profile, instrumentation),
48400
+ historyDigest ?? hashTerminalReplicaRows(snapshot3.history, profile, instrumentation),
48205
48401
  snapshot3.cursor,
48206
48402
  snapshot3.modes,
48207
48403
  snapshot3.placements,
@@ -48496,7 +48692,7 @@ function terminalReplicaRowIsValid(row) {
48496
48692
  }
48497
48693
  return true;
48498
48694
  }
48499
- var VALIDATED_PATCH_ROWS, ROW_ARRAY_HASH_CACHE, ROW_SEQUENCE_BASE, verifiedTombstoneBases, TERMINAL_REPLICA_COOPERATIVE_SEED_CELLS;
48695
+ var VALIDATED_PATCH_ROWS, ROW_ARRAY_HASH_CACHE, ROW_SEQUENCE_BASE, ROW_SEQUENCE_BASE_INVERSE, verifiedTombstoneBases, TERMINAL_REPLICA_COOPERATIVE_SEED_CELLS;
48500
48696
  var init_terminal_replica2 = __esm({
48501
48697
  "packages/core/src/terminal-replica.ts"() {
48502
48698
  "use strict";
@@ -48507,6 +48703,12 @@ var init_terminal_replica2 = __esm({
48507
48703
  VALIDATED_PATCH_ROWS = /* @__PURE__ */ new WeakSet();
48508
48704
  ROW_ARRAY_HASH_CACHE = /* @__PURE__ */ new WeakMap();
48509
48705
  ROW_SEQUENCE_BASE = 0x100000001b3n;
48706
+ ROW_SEQUENCE_BASE_INVERSE = (() => {
48707
+ let inverse = ROW_SEQUENCE_BASE;
48708
+ for (let step = 0; step < 6; step++)
48709
+ inverse = BigInt.asUintN(64, inverse * (2n - ROW_SEQUENCE_BASE * inverse));
48710
+ return inverse;
48711
+ })();
48510
48712
  verifiedTombstoneBases = /* @__PURE__ */ new WeakMap();
48511
48713
  TERMINAL_REPLICA_COOPERATIVE_SEED_CELLS = 8192;
48512
48714
  }
@@ -48590,9 +48792,9 @@ var init_terminal_delivery_binary = __esm({
48590
48792
  }
48591
48793
  header(frame, revision, base2, magic = "TCB1") {
48592
48794
  for (const b of magic === "TCP1" ? [84, 67, 80, 49] : [84, 67, 66, 49]) this.byte(b);
48593
- this.byte(frame === "seed" ? 0 : frame === "patch" ? 1 : 2);
48795
+ this.byte(frame === "seed" ? 0 : frame === "patch" ? 1 : frame === "tombstone" ? 2 : 3);
48594
48796
  this.uint(revision);
48595
- if (frame !== "seed") this.uint(base2);
48797
+ if (frame !== "seed" && frame !== "history") this.uint(base2);
48596
48798
  }
48597
48799
  get byteLength() {
48598
48800
  return this.length;
@@ -48604,6 +48806,53 @@ var init_terminal_delivery_binary = __esm({
48604
48806
  }
48605
48807
  });
48606
48808
 
48809
+ // packages/core/src/terminal-partial-history.ts
48810
+ function terminalHistoryPrefixCommitment(history, unloadedRows) {
48811
+ if (!Number.isSafeInteger(unloadedRows) || unloadedRows < 0 || unloadedRows > history.length)
48812
+ throw new RangeError("Unloaded rows outside the history");
48813
+ const cache3 = Object.isFrozen(history) ? PREFIX_COMMITMENTS.get(history) : void 0;
48814
+ const cached2 = cache3?.get(unloadedRows);
48815
+ if (cached2) return cached2;
48816
+ const commitment = Object.freeze({
48817
+ rows: unloadedRows,
48818
+ digest: hashTerminalReplicaRows(
48819
+ unloadedRows === history.length ? history : history.slice(0, unloadedRows)
48820
+ )
48821
+ });
48822
+ if (Object.isFrozen(history)) {
48823
+ const entries = cache3 ?? /* @__PURE__ */ new Map();
48824
+ if (entries.size >= 8) entries.delete(entries.keys().next().value);
48825
+ entries.set(unloadedRows, commitment);
48826
+ PREFIX_COMMITMENTS.set(history, entries);
48827
+ }
48828
+ return commitment;
48829
+ }
48830
+ function dropTerminalHistoryCommitmentPrefix(commitment, dropped) {
48831
+ if (dropped.length > commitment.rows) throw new RangeError("Dropped rows exceed the commitment");
48832
+ const rows = commitment.rows - dropped.length;
48833
+ return Object.freeze({
48834
+ rows,
48835
+ digest: rows === 0 ? TERMINAL_HISTORY_EMPTY_DIGEST : dropTerminalReplicaRowsDigestPrefix(commitment.digest, dropped, rows)
48836
+ });
48837
+ }
48838
+ function popTerminalHistoryCommitmentSuffix(commitment, taken) {
48839
+ if (taken.length > commitment.rows) throw new RangeError("Taken rows exceed the commitment");
48840
+ const rows = commitment.rows - taken.length;
48841
+ return Object.freeze({
48842
+ rows,
48843
+ digest: rows === 0 ? TERMINAL_HISTORY_EMPTY_DIGEST : popTerminalReplicaRowsDigestSuffix(commitment.digest, taken)
48844
+ });
48845
+ }
48846
+ var PREFIX_COMMITMENTS;
48847
+ var init_terminal_partial_history = __esm({
48848
+ "packages/core/src/terminal-partial-history.ts"() {
48849
+ "use strict";
48850
+ init_src2();
48851
+ init_terminal_replica2();
48852
+ PREFIX_COMMITMENTS = /* @__PURE__ */ new WeakMap();
48853
+ }
48854
+ });
48855
+
48607
48856
  // packages/core/src/terminal-delivery.ts
48608
48857
  import { z as z111 } from "zod";
48609
48858
  function negotiateTerminalDelivery(offer, generation, deliveryNonce) {
@@ -48618,12 +48867,14 @@ function negotiateTerminalDelivery(offer, generation, deliveryNonce) {
48618
48867
  if (!encoding) return { accepted: false, reason: "encoding-mismatch" };
48619
48868
  if (offer.richPlacements && encoding !== "semantic-v1" && encoding !== "semantic-compact-v1" && encoding !== "semantic-binary-v1")
48620
48869
  return { accepted: false, reason: "unsupported-capability-combination" };
48870
+ const partialHistory = offer.protocolVersions.includes(TERMINAL_DELIVERY_PARTIAL_HISTORY_CAPABILITY_VERSION) && (encoding === "semantic-compact-v1" || encoding === "semantic-binary-v1");
48621
48871
  return {
48622
48872
  accepted: true,
48623
48873
  negotiated: {
48624
48874
  protocolVersion: TERMINAL_DELIVERY_PROTOCOL_VERSION,
48625
48875
  encoding,
48626
- ...binary && offer.protocolVersions.some(
48876
+ ...partialHistory ? { partialHistory: "tail-v1" } : {},
48877
+ ...binary && !partialHistory && offer.protocolVersions.some(
48627
48878
  (v) => v === TERMINAL_PROJECTION_CAPABILITY_VERSION || v === TERMINAL_PROJECTION_LOCAL_CAPABILITY_VERSION || v === TERMINAL_GRAPHICS_COMPRESSED_CAPABILITY_VERSION || v === TERMINAL_GRAPHICS_COMPRESSED_LOCAL_CAPABILITY_VERSION
48628
48879
  ) ? { alternateScreenProjection: "deferred-history-v1" } : {},
48629
48880
  ...encoding === "semantic-compact-v1" && offer.encodings.includes("semantic-v1") ? { fallbackEncoding: "semantic-v1" } : {},
@@ -48768,6 +49019,43 @@ function compactSemanticWire(input) {
48768
49019
  };
48769
49020
  return wire;
48770
49021
  }
49022
+ function encodeSemanticTerminalHistory(input, encoding) {
49023
+ const payload = HistoryEncodingPayloadSchema.parse(input);
49024
+ if (encoding === "semantic-v1") {
49025
+ const bytes = UTF8_ENCODER2.encode(canonicalJson(payload));
49026
+ assertRepresentationSize(bytes);
49027
+ return bytes;
49028
+ }
49029
+ const rows = compactRows(payload.rows, null, {
49030
+ rows: 0,
49031
+ runs: 0,
49032
+ cells: 0,
49033
+ placements: 0,
49034
+ maxCells: COMPACT_MAX_EXPANDED_CELLS,
49035
+ reusedRows: 0,
49036
+ allocatedCells: 0,
49037
+ canonicalUtf8Allocations: 0,
49038
+ canonicalUtf8Bytes: 0,
49039
+ validatedCellAllocations: 0
49040
+ });
49041
+ if (encoding === "semantic-compact-v1") {
49042
+ const bytes = UTF8_ENCODER2.encode(
49043
+ JSON.stringify({ f: "h", h: rows, k: COMPACT_SEMANTIC_KIND, r: payload.revision, v: 1 })
49044
+ );
49045
+ assertRepresentationSize(bytes);
49046
+ return bytes;
49047
+ }
49048
+ const writer = new BinaryTerminalWriter();
49049
+ try {
49050
+ writer.header("history", payload.revision);
49051
+ writer.value(rows);
49052
+ return writer.finish();
49053
+ } catch (error) {
49054
+ if (error instanceof BinaryTerminalLimitError)
49055
+ throw new TerminalDeliveryStateTooLargeError(TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES + 1);
49056
+ throw error;
49057
+ }
49058
+ }
48771
49059
  function encodeBinarySemanticTerminalUpdate(input) {
48772
49060
  const wire = compactSemanticWire(input);
48773
49061
  const writer = new BinaryTerminalWriter();
@@ -49432,7 +49720,7 @@ function encodeTerminalProjectionMetadataTuple(value) {
49432
49720
  compactBootstrap(value.bootstrap)
49433
49721
  ];
49434
49722
  }
49435
- var TerminalDeliveryStateTooLargeError, COMPACT_SEMANTIC_KIND, COMPACT_MAX_DIMENSION, COMPACT_MAX_ROWS, COMPACT_MAX_RUNS, COMPACT_MAX_EXPANDED_CELLS, COMPACT_MAX_EXPANSION_RATIO, COMPACT_MAX_PLACEMENTS, COMPACT_MAX_STRING_BYTES, UTF8_ENCODER2, COMPACT_DEFAULT_COLOR, validatedOwnedEncodingRows, CompactCellSliceSchema, trustedBlankCellsValidated, CompactOwnedCellSchema, CompactOwnedCellSliceSchema, CompactOwnedEncodingRowSchema, CompactEncodingRowSchema, CompactPatchRowFailure, StrictCompactPatchRowSchema, CompactPatchEncodingRowSchema, CompactPatchEncodingPayloadSchema, CompactEncodingPayloadSchema, TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS, CompactSeedHeaderSchema, CompactSeedMetadataSchema, CompactRowHeaderSchema, COOPERATIVE_JSON_WORK_CHARS, COOPERATIVE_JSON_MAX_STRING_CHARS, TerminalDeliveryRepresentationHasher;
49723
+ var TerminalDeliveryStateTooLargeError, COMPACT_SEMANTIC_KIND, COMPACT_MAX_DIMENSION, COMPACT_MAX_ROWS, COMPACT_MAX_RUNS, COMPACT_MAX_EXPANDED_CELLS, COMPACT_MAX_EXPANSION_RATIO, COMPACT_MAX_PLACEMENTS, COMPACT_MAX_STRING_BYTES, UTF8_ENCODER2, COMPACT_DEFAULT_COLOR, validatedOwnedEncodingRows, CompactCellSliceSchema, trustedBlankCellsValidated, CompactOwnedCellSchema, CompactOwnedCellSliceSchema, CompactOwnedEncodingRowSchema, CompactEncodingRowSchema, CompactPatchRowFailure, StrictCompactPatchRowSchema, CompactPatchEncodingRowSchema, CompactPatchEncodingPayloadSchema, CompactEncodingPayloadSchema, HistoryEncodingPayloadSchema, TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS, CompactSeedHeaderSchema, CompactSeedMetadataSchema, CompactRowHeaderSchema, COOPERATIVE_JSON_WORK_CHARS, COOPERATIVE_JSON_MAX_STRING_CHARS, TerminalDeliveryRepresentationHasher;
49436
49724
  var init_terminal_delivery2 = __esm({
49437
49725
  "packages/core/src/terminal-delivery.ts"() {
49438
49726
  "use strict";
@@ -49442,6 +49730,7 @@ var init_terminal_delivery2 = __esm({
49442
49730
  init_src2();
49443
49731
  init_terminal_replica2();
49444
49732
  init_terminal_compact_capability();
49733
+ init_terminal_partial_history();
49445
49734
  init_terminal_replica_hash_cache();
49446
49735
  TerminalDeliveryStateTooLargeError = class extends Error {
49447
49736
  bytes;
@@ -49544,6 +49833,9 @@ var init_terminal_delivery2 = __esm({
49544
49833
  TerminalSemanticDeliveryPayloadSchemaZ.options[1],
49545
49834
  TerminalSemanticDeliveryPayloadSchemaZ.options[2]
49546
49835
  ]);
49836
+ HistoryEncodingPayloadSchema = TerminalSemanticHistoryPayloadSchemaZ.extend({
49837
+ rows: z111.array(CompactPatchEncodingRowSchema).min(1).max(TERMINAL_DELIVERY_HISTORY_CHUNK_MAX_ROWS)
49838
+ });
49547
49839
  TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS = 8192;
49548
49840
  CompactSeedHeaderSchema = /* @__PURE__ */ TerminalSemanticDeliveryPayloadSchemaZ.options[0].omit({ snapshot: true });
49549
49841
  CompactSeedMetadataSchema = /* @__PURE__ */ TerminalReplicaSnapshotSchemaZ.omit({
@@ -50078,6 +50370,7 @@ var init_src3 = __esm({
50078
50370
  init_resize_transaction();
50079
50371
  init_kitty_placeholders();
50080
50372
  init_terminal_projection2();
50373
+ init_terminal_partial_history();
50081
50374
  }
50082
50375
  });
50083
50376
 
@@ -51736,7 +52029,7 @@ var init_xterm_headless = __esm({
51736
52029
  }
51737
52030
  }
51738
52031
  uncoveredLeakingObjs.sort(compareBy((l) => l.idx, numberComparator));
51739
- let message = "";
52032
+ let message2 = "";
51740
52033
  let i = 0;
51741
52034
  for (const leaking of uncoveredLeakingObjs.slice(0, maxReported)) {
51742
52035
  i++;
@@ -51754,7 +52047,7 @@ var init_xterm_headless = __esm({
51754
52047
  }
51755
52048
  stackTraceFormattedLines.unshift(line);
51756
52049
  }
51757
- message += `
52050
+ message2 += `
51758
52051
 
51759
52052
 
51760
52053
  ==================== Leaking disposable ${i}/${uncoveredLeakingObjs.length}: ${leaking.value.constructor.name} ====================
@@ -51764,14 +52057,14 @@ ${stackTraceFormattedLines.join("\n")}
51764
52057
  `;
51765
52058
  }
51766
52059
  if (uncoveredLeakingObjs.length > maxReported) {
51767
- message += `
52060
+ message2 += `
51768
52061
 
51769
52062
 
51770
52063
  ... and ${uncoveredLeakingObjs.length - maxReported} more leaking disposables
51771
52064
 
51772
52065
  `;
51773
52066
  }
51774
- return { leaks: uncoveredLeakingObjs, details: message };
52067
+ return { leaks: uncoveredLeakingObjs, details: message2 };
51775
52068
  }
51776
52069
  };
51777
52070
  _DisposableTracker.idx = 0;
@@ -52462,10 +52755,10 @@ ${stackTraceFormattedLines.join("\n")}
52462
52755
  if (this._warnCountdown <= 0) {
52463
52756
  this._warnCountdown = threshold * 0.5;
52464
52757
  const [topStack, topCount] = this.getMostFrequentStack();
52465
- const message = `[${this.name}] potential listener LEAK detected, having ${listenerCount} listeners already. MOST frequent listener (${topCount}):`;
52466
- console.warn(message);
52758
+ const message2 = `[${this.name}] potential listener LEAK detected, having ${listenerCount} listeners already. MOST frequent listener (${topCount}):`;
52759
+ console.warn(message2);
52467
52760
  console.warn(topStack);
52468
- const error = new ListenerLeakError(message, topStack);
52761
+ const error = new ListenerLeakError(message2, topStack);
52469
52762
  this._errorHandler(error);
52470
52763
  }
52471
52764
  return () => {
@@ -52503,15 +52796,15 @@ ${stackTraceFormattedLines.join("\n")}
52503
52796
  }
52504
52797
  };
52505
52798
  ListenerLeakError = class extends Error {
52506
- constructor(message, stack) {
52507
- super(message);
52799
+ constructor(message2, stack) {
52800
+ super(message2);
52508
52801
  this.name = "ListenerLeakError";
52509
52802
  this.stack = stack;
52510
52803
  }
52511
52804
  };
52512
52805
  ListenerRefusalError = class extends Error {
52513
- constructor(message, stack) {
52514
- super(message);
52806
+ constructor(message2, stack) {
52807
+ super(message2);
52515
52808
  this.name = "ListenerRefusalError";
52516
52809
  this.stack = stack;
52517
52810
  }
@@ -52587,10 +52880,10 @@ ${stackTraceFormattedLines.join("\n")}
52587
52880
  get event() {
52588
52881
  this._event ??= (callback, thisArgs, disposables) => {
52589
52882
  if (this._leakageMon && this._size > this._leakageMon.threshold ** 2) {
52590
- const message = `[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;
52591
- console.warn(message);
52883
+ const message2 = `[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;
52884
+ console.warn(message2);
52592
52885
  const tuple = this._leakageMon.getMostFrequentStack() ?? ["UNKNOWN stack", -1];
52593
- const error = new ListenerRefusalError(`${message}. HINT: Stack shows most frequent listener (${tuple[1]}-times)`, tuple[0]);
52886
+ const error = new ListenerRefusalError(`${message2}. HINT: Stack shows most frequent listener (${tuple[1]}-times)`, tuple[0]);
52594
52887
  const errorHandler2 = this._options?.onListenerError || onUnexpectedError;
52595
52888
  errorHandler2(error);
52596
52889
  return Disposable.None;
@@ -53464,33 +53757,33 @@ ${stackTraceFormattedLines.join("\n")}
53464
53757
  }
53465
53758
  }
53466
53759
  }
53467
- _log(type, message, optionalParams) {
53760
+ _log(type, message2, optionalParams) {
53468
53761
  this._evalLazyOptionalParams(optionalParams);
53469
- type.call(console, (this._optionsService.options.logger ? "" : LOG_PREFIX) + message, ...optionalParams);
53762
+ type.call(console, (this._optionsService.options.logger ? "" : LOG_PREFIX) + message2, ...optionalParams);
53470
53763
  }
53471
- trace(message, ...optionalParams) {
53764
+ trace(message2, ...optionalParams) {
53472
53765
  if (this._logLevel <= 0) {
53473
- this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger) ?? console.log, message, optionalParams);
53766
+ this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger) ?? console.log, message2, optionalParams);
53474
53767
  }
53475
53768
  }
53476
- debug(message, ...optionalParams) {
53769
+ debug(message2, ...optionalParams) {
53477
53770
  if (this._logLevel <= 1) {
53478
- this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger) ?? console.log, message, optionalParams);
53771
+ this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger) ?? console.log, message2, optionalParams);
53479
53772
  }
53480
53773
  }
53481
- info(message, ...optionalParams) {
53774
+ info(message2, ...optionalParams) {
53482
53775
  if (this._logLevel <= 2) {
53483
- this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger) ?? console.info, message, optionalParams);
53776
+ this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger) ?? console.info, message2, optionalParams);
53484
53777
  }
53485
53778
  }
53486
- warn(message, ...optionalParams) {
53779
+ warn(message2, ...optionalParams) {
53487
53780
  if (this._logLevel <= 3) {
53488
- this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger) ?? console.warn, message, optionalParams);
53781
+ this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger) ?? console.warn, message2, optionalParams);
53489
53782
  }
53490
53783
  }
53491
- error(message, ...optionalParams) {
53784
+ error(message2, ...optionalParams) {
53492
53785
  if (this._logLevel <= 4) {
53493
- this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger) ?? console.error, message, optionalParams);
53786
+ this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger) ?? console.error, message2, optionalParams);
53494
53787
  }
53495
53788
  }
53496
53789
  };
@@ -62991,6 +63284,9 @@ var init_xterm_terminal_interpreter_backend = __esm({
62991
63284
  #terminal;
62992
63285
  #rowCache = /* @__PURE__ */ new WeakMap();
62993
63286
  #scrollEpoch = 0;
63287
+ #historyLimit;
63288
+ #collecting = false;
63289
+ #lastYbase = null;
62994
63290
  #lastScrollEpoch = 0;
62995
63291
  #lastViewportY = 0;
62996
63292
  #lastBufferType = "normal";
@@ -63003,11 +63299,16 @@ var init_xterm_terminal_interpreter_backend = __esm({
63003
63299
  #historyProjectionInvalidated = false;
63004
63300
  #scrollOnClear;
63005
63301
  constructor(options) {
63302
+ const historyLimit = options.historyLimit ?? options.scrollback;
63303
+ this.#historyLimit = historyLimit;
63006
63304
  this.#terminal = new Terminal2({
63007
63305
  cols: options.cols,
63008
63306
  rows: options.rows,
63009
- scrollback: options.scrollback,
63010
- tmuxHistoryLimit: options.historyLimit ?? options.scrollback,
63307
+ // One row of headroom over what the replica may hold (the limit, or a
63308
+ // larger captured history): xterm must not recycle the row a scroll
63309
+ // adds before #collectHistory sees it.
63310
+ scrollback: historyLimit > 0 ? Math.max(options.scrollback, historyLimit) + 1 : options.scrollback,
63311
+ tmuxHistoryLimit: historyLimit,
63011
63312
  allowProposedApi: true
63012
63313
  });
63013
63314
  this.#terminal.loadAddon(new import_addon_unicode11.Unicode11Addon());
@@ -63037,7 +63338,9 @@ var init_xterm_terminal_interpreter_backend = __esm({
63037
63338
  return false;
63038
63339
  });
63039
63340
  this.#terminal.onScroll(() => {
63040
- if (this.#terminal.buffer.active.type === "normal") this.#scrollEpoch += 1;
63341
+ if (this.#terminal.buffer.active.type !== "normal") return;
63342
+ this.#scrollEpoch += 1;
63343
+ this.#collectHistory();
63041
63344
  });
63042
63345
  const core = this.#terminal._core;
63043
63346
  if (!core?.coreService) {
@@ -63045,6 +63348,34 @@ var init_xterm_terminal_interpreter_backend = __esm({
63045
63348
  throw new Error("Unsupported @tmux-ide/xterm-headless private API shape");
63046
63349
  }
63047
63350
  }
63351
+ /**
63352
+ * tmux at its history-limit collects the oldest tenth of history before a
63353
+ * scroll would pass it (grid_collect_history), so its history_size moves
63354
+ * between 0.9 and 1.0 of the limit. Recycling one row at a time instead kept
63355
+ * the replica at the limit, and the owner's history-size check then reseeded
63356
+ * the whole pane each time its output paused. The projection reports the
63357
+ * collection as an ordinary history trim.
63358
+ */
63359
+ startHistoryCollection() {
63360
+ this.#collecting = true;
63361
+ this.#lastYbase = this.#normalBuffer()?.ybase ?? null;
63362
+ }
63363
+ #normalBuffer() {
63364
+ return this.#terminal._core?.buffers?.normal;
63365
+ }
63366
+ #collectHistory() {
63367
+ const buffer = this.#normalBuffer();
63368
+ if (!buffer) return;
63369
+ const before = this.#lastYbase;
63370
+ const limit = this.#historyLimit;
63371
+ if (this.#collecting && limit > 0 && before !== null && before >= limit && buffer.ybase === before + 1) {
63372
+ const trim = Math.min(buffer.ybase, Math.max(1, Math.floor(limit / 10)));
63373
+ buffer.lines.trimStart(trim);
63374
+ buffer.ybase -= trim;
63375
+ buffer.ydisp = Math.max(0, buffer.ydisp - trim);
63376
+ }
63377
+ this.#lastYbase = buffer.ybase;
63378
+ }
63048
63379
  get cols() {
63049
63380
  return this.#terminal.cols;
63050
63381
  }
@@ -64289,6 +64620,7 @@ var init_terminal_replica_interpreter = __esm({
64289
64620
  rows: options.rows,
64290
64621
  scrollback: this.#scrollback
64291
64622
  });
64623
+ this.#backend.startHistoryCollection?.();
64292
64624
  this.#kitty = new KittyImageStore(
64293
64625
  options.kittyImageBudget ? { budget: options.kittyImageBudget } : {}
64294
64626
  );
@@ -64466,6 +64798,7 @@ var init_terminal_replica_interpreter = __esm({
64466
64798
  this.#admitRaw(chunk);
64467
64799
  this.#observeMarkerBytes(chunk);
64468
64800
  }
64801
+ replacement.startHistoryCollection?.();
64469
64802
  const previous = this.#backend;
64470
64803
  this.#backend = replacement;
64471
64804
  this.#attachKitty(replacement);
@@ -65523,7 +65856,7 @@ var init_terminal_replica_owner = __esm({
65523
65856
  #leaseIsCurrent(lease, subscriptionEpoch) {
65524
65857
  return !this.#disposed && subscriptionEpoch === this.#subscriptionEpoch && this.#layoutLease !== null && this.#layoutLease.epoch === lease.epoch && layoutLeaseEqual(this.#layoutLease, lease);
65525
65858
  }
65526
- #retryReseedOrFault(message, reseed, stage, reason) {
65859
+ #retryReseedOrFault(message2, reseed, stage, reason) {
65527
65860
  if (this.#disposed || this.#waitingForGeometryCapture) return;
65528
65861
  const diagnostic4 = this.#observability.enabled ? {
65529
65862
  reason,
@@ -65547,7 +65880,7 @@ var init_terminal_replica_owner = __esm({
65547
65880
  } : void 0;
65548
65881
  if (this.#reseedRetryCount >= 1) {
65549
65882
  this.#noteLifecycle("reseed-exhausted", diagnostic4);
65550
- const error = new Error(message);
65883
+ const error = new Error(message2);
65551
65884
  this.#interpreter.abort(error);
65552
65885
  this.#onFault?.(error);
65553
65886
  return;
@@ -65843,15 +66176,16 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
65843
66176
  patch: update.patch
65844
66177
  };
65845
66178
  const snapshot3 = target.state.snapshot;
65846
- if (baseline && baselineIncarnation === update.incarnation && baseline.cols === snapshot3.cols && baseline.rows === snapshot3.rows && baseline.history.length <= snapshot3.history.length) {
66179
+ const trim = baseline ? historyTrim(baseline.history, snapshot3.history) : 0;
66180
+ if (baseline && baselineIncarnation === update.incarnation && baseline.cols === snapshot3.cols && baseline.rows === snapshot3.rows && baseline.history.length - trim <= snapshot3.history.length) {
65847
66181
  let comparisonCells = 0;
65848
66182
  const equal = (left, right) => {
65849
66183
  if (left === right) return true;
65850
66184
  comparisonCells += right.cells.length;
65851
66185
  return comparisonCells <= TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS ? terminalReplicaRowsEqual(left, right) : null;
65852
66186
  };
65853
- for (let index = 0; index < baseline.history.length; index++)
65854
- if (equal(baseline.history[index], snapshot3.history[index]) !== true)
66187
+ for (let index = trim; index < baseline.history.length; index++)
66188
+ if (equal(baseline.history[index], snapshot3.history[index - trim]) !== true)
65855
66189
  return semanticSeed(target);
65856
66190
  const rows = [];
65857
66191
  for (let index = 0; index < snapshot3.grid.length; index++) {
@@ -65859,17 +66193,18 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
65859
66193
  if (same7 === null) return semanticSeed(target);
65860
66194
  if (!same7) rows.push({ index, row: snapshot3.grid[index] });
65861
66195
  }
65862
- const appendedRows = snapshot3.history.length - baseline.history.length;
66196
+ const retained = baseline.history.length - trim;
66197
+ const appendedRows = snapshot3.history.length - retained;
65863
66198
  if ((rows.length + appendedRows) * snapshot3.cols >= TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS)
65864
66199
  return semanticSeed(target);
65865
- const append = snapshot3.history.slice(baseline.history.length);
66200
+ const append = snapshot3.history.slice(retained);
65866
66201
  return {
65867
66202
  frame: "patch",
65868
66203
  baseRevision: baselineRevision,
65869
66204
  revision: update.revision,
65870
66205
  patch: {
65871
66206
  rows,
65872
- ...append.length ? { historyDelta: { trim: 0, append } } : {},
66207
+ ...append.length || trim ? { historyDelta: { trim, append } } : {},
65873
66208
  cursor: snapshot3.cursor,
65874
66209
  modes: snapshot3.modes,
65875
66210
  placements: snapshot3.placements,
@@ -65879,6 +66214,25 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
65879
66214
  }
65880
66215
  return semanticSeed(target);
65881
66216
  }
66217
+ function historyTrim(baseline, target) {
66218
+ const first = target[0];
66219
+ if (first === void 0 || baseline[0] === first) return 0;
66220
+ let candidates = 0;
66221
+ for (let trim = 1; trim < baseline.length; trim++) {
66222
+ if (baseline[trim] !== first) continue;
66223
+ if (++candidates > 4) return 0;
66224
+ const retained = baseline.length - trim;
66225
+ if (retained > target.length) continue;
66226
+ let same7 = true;
66227
+ for (let index = 0; index < retained; index++)
66228
+ if (baseline[trim + index] !== target[index]) {
66229
+ same7 = false;
66230
+ break;
66231
+ }
66232
+ if (same7) return trim;
66233
+ }
66234
+ return 0;
66235
+ }
65882
66236
  function canonicalUpdateCellCost(update) {
65883
66237
  if (update.type === "terminal.tombstone") return 0;
65884
66238
  if (update.type === "terminal.seed")
@@ -65941,7 +66295,7 @@ function logDeliveryFault(client, reason, cause) {
65941
66295
  workspace: client.deliveryWorkspaceName
65942
66296
  });
65943
66297
  }
65944
- var MAX_CANONICAL_REVISIONS, MAX_RAW_JOURNAL_BYTES, MAX_REPRESENTATION_CACHE_ENTRIES, MAX_REPRESENTATION_CACHE_BYTES, MAX_CLIENTS, MAX_PANES, MAX_PENDING_CANONICAL_CELLS, MAX_CONNECTIONS, BACKGROUND_CADENCE_MS, DeferredProjectionEncoding, DeferredSeedEncoding, ExactSemanticRepresentationSelectionError, TerminalDeliveryRepresentationSelectionError, TerminalDeliveryPreaccountLimitError, SessionRuntimeTerminalDeliveryHub;
66298
+ var MAX_CANONICAL_REVISIONS, MAX_RAW_JOURNAL_BYTES, MAX_REPRESENTATION_CACHE_ENTRIES, MAX_REPRESENTATION_CACHE_BYTES, MAX_CLIENTS, HISTORY_FRAME_MAX_BYTES, MAX_PANES, MAX_PENDING_CANONICAL_CELLS, MAX_CONNECTIONS, BACKGROUND_CADENCE_MS, TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES, TERMINAL_DELIVERY_CONNECTION_HOLD_MS, TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS, DeferredProjectionEncoding, DeferredSeedEncoding, ExactSemanticRepresentationSelectionError, TerminalDeliveryRepresentationSelectionError, TerminalDeliveryPreaccountLimitError, SessionRuntimeTerminalDeliveryHub;
65945
66299
  var init_terminal_delivery_hub = __esm({
65946
66300
  "packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts"() {
65947
66301
  "use strict";
@@ -65961,10 +66315,14 @@ var init_terminal_delivery_hub = __esm({
65961
66315
  MAX_REPRESENTATION_CACHE_ENTRIES = 8;
65962
66316
  MAX_REPRESENTATION_CACHE_BYTES = 16 * 1024 * 1024;
65963
66317
  MAX_CLIENTS = 64;
66318
+ HISTORY_FRAME_MAX_BYTES = 128 * 1024;
65964
66319
  MAX_PANES = 32;
65965
66320
  MAX_PENDING_CANONICAL_CELLS = 1e6;
65966
66321
  MAX_CONNECTIONS = MAX_CLIENTS * MAX_PANES;
65967
66322
  BACKGROUND_CADENCE_MS = 100;
66323
+ TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES = 256 * 1024;
66324
+ TERMINAL_DELIVERY_CONNECTION_HOLD_MS = 250;
66325
+ TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS = 30;
65968
66326
  DeferredProjectionEncoding = class extends Error {
65969
66327
  constructor(payload) {
65970
66328
  super("Deferred projection encoding");
@@ -65973,11 +66331,13 @@ var init_terminal_delivery_hub = __esm({
65973
66331
  payload;
65974
66332
  };
65975
66333
  DeferredSeedEncoding = class extends Error {
65976
- constructor(payload) {
66334
+ constructor(payload, variant = "complete") {
65977
66335
  super("Deferred compact seed encoding");
65978
66336
  this.payload = payload;
66337
+ this.variant = variant;
65979
66338
  }
65980
66339
  payload;
66340
+ variant;
65981
66341
  };
65982
66342
  ExactSemanticRepresentationSelectionError = class extends TerminalDeliveryStateTooLargeError {
65983
66343
  selectionObservation;
@@ -66016,6 +66376,8 @@ var init_terminal_delivery_hub = __esm({
66016
66376
  this.generation = generation;
66017
66377
  this.workspaceName = workspaceName;
66018
66378
  this.#ownerForPane = ownerForPane;
66379
+ this.#holdMs = options.connectionHoldMs ?? TERMINAL_DELIVERY_CONNECTION_HOLD_MS;
66380
+ this.#congestedMs = options.connectionCongestedMs ?? TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS;
66019
66381
  this.#scheduler = options.scheduler ?? SYSTEM_SESSION_RUNTIME_SCHEDULER;
66020
66382
  this.#observability = options.observability ?? DISABLED_SESSION_RUNTIME_OBSERVABILITY;
66021
66383
  }
@@ -66026,6 +66388,8 @@ var init_terminal_delivery_hub = __esm({
66026
66388
  #observability;
66027
66389
  #panes = /* @__PURE__ */ new Map();
66028
66390
  #clients = /* @__PURE__ */ new Map();
66391
+ /** Per connection: the pane it last typed into. */
66392
+ #priority = /* @__PURE__ */ new Map();
66029
66393
  #sourceCloseFailures = 0;
66030
66394
  #pendingSourceCloses = 0;
66031
66395
  /** Synchronous reservations held while an async pane source is starting. */
@@ -66043,6 +66407,8 @@ var init_terminal_delivery_hub = __esm({
66043
66407
  #deliveryLifecycleOrdinal = 0;
66044
66408
  #deliveryStatusOrdinal = 0;
66045
66409
  #closed = false;
66410
+ #holdMs;
66411
+ #congestedMs;
66046
66412
  async open(clientId, semanticPaneId3, offerInput, accept, diagnosticIdentity = Object.freeze({ clientId, surface: "direct", laneId: clientId }), deliveryWorkspaceName = this.workspaceName) {
66047
66413
  if (this.#closed) throw new Error("Terminal delivery hub is closed");
66048
66414
  const address = WorkspaceIdSchemaZ.parse(deliveryWorkspaceName);
@@ -66091,7 +66457,18 @@ var init_terminal_delivery_hub = __esm({
66091
66457
  lastProjectionReceipt: null,
66092
66458
  lastMaterialize: null,
66093
66459
  reseedRequired: false,
66460
+ historyUnloadedRows: 0,
66461
+ historyUnloadedDigest: TERMINAL_HISTORY_EMPTY_DIGEST,
66462
+ historyLoadedRows: 0,
66463
+ pendingHistoryRows: null,
66464
+ historyBytesPerRow: null,
66465
+ revisionSinceHistoryRequest: false,
66094
66466
  inFlight: null,
66467
+ pipelining: offer.protocolVersions.includes(
66468
+ TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION
66469
+ ),
66470
+ pipelined: [],
66471
+ droppedTransactions: /* @__PURE__ */ new Set(),
66095
66472
  latestRevision: pane.latest?.update.revision ?? null,
66096
66473
  encoding: null,
66097
66474
  scheduled: false,
@@ -66104,7 +66481,10 @@ var init_terminal_delivery_hub = __esm({
66104
66481
  captureUnavailable: false,
66105
66482
  lastAck: null,
66106
66483
  sourceClosedFlight: null,
66107
- backgroundTimer: null
66484
+ backgroundTimer: null,
66485
+ budgetHeld: false,
66486
+ budgetHeldSince: null,
66487
+ budgetTimer: null
66108
66488
  };
66109
66489
  this.#clients.set(key2, client);
66110
66490
  client.lifecycleOpenRecorded = this.#recordDeliveryLifecycle(client, pane, "open");
@@ -66117,6 +66497,12 @@ var init_terminal_delivery_hub = __esm({
66117
66497
  projectionReceipt: (receipt) => this.#projectionReceipt(client, receipt),
66118
66498
  materialize: (request3) => this.#materialize(client, request3),
66119
66499
  nack: (nack) => this.#nack(client, nack),
66500
+ historyRequest: (request3) => this.#historyRequest(client, request3),
66501
+ prioritize: () => {
66502
+ if (client.closed) return;
66503
+ this.#priority.set(client.clientId, client.paneId);
66504
+ this.#releaseBudget(client.clientId);
66505
+ },
66120
66506
  setVisibility: (visibilityInput) => {
66121
66507
  if (client.closed) return;
66122
66508
  client.visibility = TerminalDeliveryVisibilitySchemaZ.parse(visibilityInput);
@@ -66254,7 +66640,7 @@ var init_terminal_delivery_hub = __esm({
66254
66640
  ),
66255
66641
  maxQueueDepth: this.#maxQueueDepth,
66256
66642
  inFlightBytes: [...this.#clients.values()].reduce(
66257
- (sum, client) => sum + (client.inFlight?.envelope.representationBytes ?? 0),
66643
+ (sum, client) => sum + this.#unackedBytes(client),
66258
66644
  0
66259
66645
  )
66260
66646
  });
@@ -66294,6 +66680,8 @@ var init_terminal_delivery_hub = __esm({
66294
66680
  this.#cancelEncoding(client);
66295
66681
  client.outgoing.length = 0;
66296
66682
  client.inFlight = null;
66683
+ client.pipelined.length = 0;
66684
+ client.budgetHeld = false;
66297
66685
  logDeliveryFault(client, "source-closed", "source-restarted");
66298
66686
  this.#enqueue(client, {
66299
66687
  type: "terminal.delivery.fault",
@@ -66578,14 +66966,110 @@ var init_terminal_delivery_hub = __esm({
66578
66966
  pane.rawFloorRevision = Math.max(pane.rawFloorRevision, first[0] + 1);
66579
66967
  }
66580
66968
  }
66969
+ #overBudget(client) {
66970
+ if (this.#priority.get(client.clientId) === client.paneId) return false;
66971
+ if (client.budgetHeldSince !== null && this.#scheduler.nowMs() - client.budgetHeldSince >= this.#holdMs)
66972
+ return false;
66973
+ const now = this.#scheduler.nowMs();
66974
+ let bytes = 0;
66975
+ let oldest = now;
66976
+ for (const other of this.#clients.values())
66977
+ if (other !== client && other.clientId === client.clientId && other.inFlight) {
66978
+ bytes += this.#unackedBytes(other);
66979
+ oldest = Math.min(oldest, other.inFlight.sentAt);
66980
+ }
66981
+ return bytes >= TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES && now - oldest >= this.#congestedMs;
66982
+ }
66983
+ /** A pane's delivery settled or left: held panes of its connection try again, typed-into pane first. */
66984
+ #releaseBudget(clientId) {
66985
+ const held = [...this.#clients.values()].filter(
66986
+ (other) => other.clientId === clientId && other.budgetHeld
66987
+ );
66988
+ const priority = this.#priority.get(clientId);
66989
+ held.sort((a, b) => Number(b.paneId === priority) - Number(a.paneId === priority));
66990
+ for (const other of held) {
66991
+ other.budgetHeld = false;
66992
+ this.#schedule(other);
66993
+ }
66994
+ }
66995
+ /** Bytes the client has not acknowledged: every flight, pipelined ones included. */
66996
+ #unackedBytes(client) {
66997
+ let bytes = client.inFlight?.envelope.representationBytes ?? 0;
66998
+ for (const flight of client.pipelined) bytes += flight.envelope.representationBytes;
66999
+ return bytes;
67000
+ }
67001
+ /** The revision the client holds once every flight applies (its ACKed baseline if none). */
67002
+ #sentRevision(client) {
67003
+ const newest = client.pipelined.at(-1) ?? client.inFlight;
67004
+ return newest?.envelope.type === "terminal.delivery" && newest.envelope.frame !== "history" ? newest.envelope.canonicalRevision : client.baselineRevision;
67005
+ }
67006
+ /**
67007
+ * Whether another delivery may go out behind the unacknowledged ones. Only
67008
+ * for a client that offers 124, only a visible pane, only behind canonical patches whose chunks have all been
67009
+ * handed to the socket (a client takes one envelope's chunks at a time), and
67010
+ * within TERMINAL_DELIVERY_MAX_PIPELINED and the connection's unacknowledged
67011
+ * byte budget. Seeds, projections, history frames and history requests keep
67012
+ * one delivery in flight.
67013
+ */
67014
+ #canPipeline(client) {
67015
+ if (!client.pipelining || !client.inFlight || client.pipelined.length + 1 >= TERMINAL_DELIVERY_MAX_PIPELINED || client.visibility !== "visible" || client.reseedRequired || client.materializeRequested || client.pendingHistoryRows !== null || client.encoding || client.negotiated.encoding !== "semantic-v1" && client.negotiated.encoding !== "semantic-compact-v1" && client.negotiated.encoding !== "semantic-binary-v1")
67016
+ return false;
67017
+ for (const flight of [client.inFlight, ...client.pipelined])
67018
+ if (flight.envelope.type !== "terminal.delivery" || flight.projection || flight.envelope.frame !== "patch" || !flight.envelope.canonicalEquivalent || flight.nextChunk < flight.envelope.chunkCount)
67019
+ return false;
67020
+ return this.#unackedBytes(client) < TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES;
67021
+ }
67022
+ /**
67023
+ * The client as it will be once every flight applies: what its ACKs would
67024
+ * set (see #ack). Representations for a pipelined patch are based on it.
67025
+ */
67026
+ #pipelineBase(client) {
67027
+ const newest = client.pipelined.at(-1) ?? client.inFlight;
67028
+ const rows = newest.historyRows;
67029
+ return {
67030
+ ...client,
67031
+ baselineRevision: newest.envelope.canonicalRevision,
67032
+ baselineHash: newest.envelope.canonicalStateHash,
67033
+ projectionBaseline: null,
67034
+ lastProjectionReceipt: null,
67035
+ reseedRequired: false,
67036
+ ...rows ? {
67037
+ historyUnloadedRows: rows.unloaded,
67038
+ historyUnloadedDigest: rows.digest,
67039
+ historyLoadedRows: rows.loaded
67040
+ } : {}
67041
+ };
67042
+ }
67043
+ /** A patch on `base`'s projected state, or null when only a seed (or an encoding job) would do. */
67044
+ #pipelinedRepresentation(base2, pane, target) {
67045
+ if (target.update.type !== "terminal.patch" || target.update.revision <= base2.baselineRevision || pane.revisions.get(base2.baselineRevision)?.update.incarnation !== target.update.incarnation)
67046
+ return null;
67047
+ const reseeds = this.#reseeds;
67048
+ try {
67049
+ const representation = this.#representation(base2, pane, target);
67050
+ if (representation.frame === "patch" && representation.canonicalEquivalent && !representation.projection)
67051
+ return representation;
67052
+ } catch (error) {
67053
+ if (!(error instanceof DeferredSeedEncoding || error instanceof DeferredProjectionEncoding))
67054
+ throw error;
67055
+ }
67056
+ this.#reseeds = reseeds;
67057
+ return null;
67058
+ }
67059
+ /** Flights behind a NACKed or faulted one: the client gets a reseed; their feedback is inert. */
67060
+ #dropPipelined(client) {
67061
+ for (const flight of client.pipelined)
67062
+ client.droppedTransactions.add(flight.envelope.transactionId);
67063
+ client.pipelined.length = 0;
67064
+ }
66581
67065
  #schedule(client) {
66582
- if (client.closed || client.captureUnavailable || client.inFlight || client.encoding || client.latestRevision === null || client.latestRevision === client.baselineRevision || client.visibility === "hidden" || client.visibility === "frozen")
67066
+ if (client.closed || client.captureUnavailable || client.inFlight && !this.#canPipeline(client) || client.encoding || (client.latestRevision === null || client.latestRevision === this.#sentRevision(client)) && client.pendingHistoryRows === null || client.visibility === "hidden" || client.visibility === "frozen")
66583
67067
  return;
66584
67068
  if (client.visibility === "background") {
66585
67069
  if (client.backgroundTimer) return;
66586
67070
  client.backgroundTimer = this.#scheduler.timer(() => {
66587
67071
  client.backgroundTimer = null;
66588
- if (!client.closed && !client.inFlight && client.latestRevision !== null)
67072
+ if (!client.closed && !client.inFlight && (client.latestRevision !== null || client.pendingHistoryRows !== null))
66589
67073
  this.#deliver(client);
66590
67074
  }, BACKGROUND_CADENCE_MS);
66591
67075
  return;
@@ -66594,15 +67078,22 @@ var init_terminal_delivery_hub = __esm({
66594
67078
  client.scheduled = true;
66595
67079
  this.#scheduler.microtask(() => {
66596
67080
  client.scheduled = false;
66597
- if (!client.closed && client.visibility === "visible" && !client.inFlight)
67081
+ if (!client.closed && client.visibility === "visible" && (!client.inFlight || this.#canPipeline(client)))
66598
67082
  this.#deliver(client);
66599
67083
  });
66600
67084
  }
66601
67085
  #deliver(client, completed) {
66602
67086
  const pane = this.#panes.get(client.paneId);
67087
+ if (!completed && pane && this.#historyDue(client)) {
67088
+ if (this.#holdForBudget(client)) return;
67089
+ this.#deliverHistory(client, pane);
67090
+ return;
67091
+ }
66603
67092
  const target = completed?.target ?? pane?.latest;
66604
- if (!pane || !target || client.closed || client.captureUnavailable || client.inFlight || client.encoding || client.visibility === "hidden" || client.visibility === "frozen" || !completed && target.update.revision !== client.latestRevision)
67093
+ const pipelining = !completed && client.inFlight !== null;
67094
+ if (!pane || !target || client.closed || client.captureUnavailable || client.inFlight && (completed || !this.#canPipeline(client)) || client.encoding || client.visibility === "hidden" || client.visibility === "frozen" || !completed && target.update.revision !== client.latestRevision)
66605
67095
  return;
67096
+ if (!completed && this.#holdForBudget(client)) return;
66606
67097
  const traceStarted = completed?.traceStarted ?? (this.#observability.enabled ? this.#observability.nowMicros() : 0);
66607
67098
  let deferred = false;
66608
67099
  let encodedRepresentation = null;
@@ -66610,7 +67101,12 @@ var init_terminal_delivery_hub = __esm({
66610
67101
  let deliveryEnvelope = null;
66611
67102
  let deliveryOrdinal = null;
66612
67103
  try {
66613
- const representation = this.#representation(client, pane, target, completed?.outcome);
67104
+ const base2 = pipelining ? this.#pipelineBase(client) : client;
67105
+ const representation = pipelining ? this.#pipelinedRepresentation(base2, pane, target) : this.#representation(client, pane, target, completed?.outcome);
67106
+ if (!representation) {
67107
+ deferred = true;
67108
+ return;
67109
+ }
66614
67110
  encodedRepresentation = representation;
66615
67111
  const transactionId = this.#scheduler.createId();
66616
67112
  const chunkCount = Math.max(1, Math.ceil(representation.bytes.byteLength / (256 * 1024)));
@@ -66627,7 +67123,7 @@ var init_terminal_delivery_hub = __esm({
66627
67123
  protocolVersion: 1,
66628
67124
  encoding: representation.encoding ?? client.negotiated.encoding,
66629
67125
  frame: representation.frame,
66630
- baseRevision: representation.projection ? representation.projectionBaseRevision : representation.frame === "seed" ? null : Math.max(0, client.baselineRevision),
67126
+ baseRevision: representation.projection ? representation.projectionBaseRevision : representation.frame === "seed" ? null : Math.max(0, base2.baselineRevision),
66631
67127
  canonicalRevision: target.update.revision,
66632
67128
  canonicalStateHash: target.update.stateHash,
66633
67129
  representationHash: representation.representationHash ?? hashTerminalDeliveryRepresentation(representation.bytes),
@@ -66635,19 +67131,24 @@ var init_terminal_delivery_hub = __esm({
66635
67131
  chunkCount,
66636
67132
  canonicalEquivalent: representation.canonicalEquivalent,
66637
67133
  history: representation.history,
67134
+ ...representation.historyUnloaded ? { historyUnloaded: representation.historyUnloaded } : {},
66638
67135
  richPlacements: client.negotiated.richPlacements
66639
67136
  });
66640
67137
  deliveryEnvelope = envelope;
66641
67138
  deliveryOrdinal = ++this.#deliveryOrdinal;
66642
67139
  registerTerminalDeliveryObservationOrdinal(envelope, deliveryOrdinal);
66643
- client.inFlight = {
67140
+ if (client.pendingHistoryRows !== null) client.revisionSinceHistoryRequest = true;
67141
+ const flight = {
66644
67142
  envelope,
66645
67143
  projection: representation.projection ?? null,
67144
+ historyRows: representation.historyRows ?? null,
66646
67145
  deliveryOrdinal,
66647
67146
  bytes: representation.bytes,
66648
67147
  nextChunk: 0,
66649
67148
  sentAt: this.#scheduler.nowMs()
66650
67149
  };
67150
+ if (pipelining) client.pipelined.push(flight);
67151
+ else client.inFlight = flight;
66651
67152
  this.#enqueue(client, envelope);
66652
67153
  this.#recordDeliveryStatus(client, pane);
66653
67154
  if (target.trace?.traceId === pane.pendingDeliveryTrace?.traceId)
@@ -66661,7 +67162,8 @@ var init_terminal_delivery_hub = __esm({
66661
67162
  target,
66662
67163
  error.payload,
66663
67164
  traceStarted,
66664
- error instanceof DeferredProjectionEncoding
67165
+ error instanceof DeferredProjectionEncoding,
67166
+ error instanceof DeferredSeedEncoding ? error.variant : "complete"
66665
67167
  );
66666
67168
  return;
66667
67169
  }
@@ -66720,7 +67222,7 @@ var init_terminal_delivery_hub = __esm({
66720
67222
  }
66721
67223
  }
66722
67224
  }
66723
- #startEncoding(client, pane, target, payload, traceStarted, projection = false) {
67225
+ #startEncoding(client, pane, target, payload, traceStarted, projection = false, variant = "complete") {
66724
67226
  const key2 = cacheKey([
66725
67227
  target.update.workspaceName,
66726
67228
  client.paneId,
@@ -66730,7 +67232,7 @@ var init_terminal_delivery_hub = __esm({
66730
67232
  target.update.stateHash,
66731
67233
  client.negotiated.encoding,
66732
67234
  client.negotiated.richPlacements ? "rich" : "plain",
66733
- projection ? `projection:${client.projectionBaseline?.revision ?? -1}:${client.projectionBaseline?.hash ?? "none"}` : "complete"
67235
+ projection ? `projection:${client.projectionBaseline?.revision ?? -1}:${client.projectionBaseline?.hash ?? "none"}` : variant
66734
67236
  ]);
66735
67237
  let job = this.#pendingEncodings.get(key2);
66736
67238
  let created = false;
@@ -66760,6 +67262,7 @@ var init_terminal_delivery_hub = __esm({
66760
67262
  baselineRevision: client.baselineRevision,
66761
67263
  baselineHash: client.baselineHash,
66762
67264
  reseedRequired: client.reseedRequired,
67265
+ historyUnloadedRows: client.historyUnloadedRows,
66763
67266
  traceStarted
66764
67267
  };
66765
67268
  owned.clients.add(client);
@@ -66799,7 +67302,7 @@ var init_terminal_delivery_hub = __esm({
66799
67302
  const encoding = client.encoding;
66800
67303
  if (!encoding || encoding.job !== job) continue;
66801
67304
  client.encoding = null;
66802
- if (job.abort.signal.aborted || this.#closed || client.closed || this.#clients.get(client.key) !== client || this.#panes.get(client.paneId) !== job.pane || client.baselineRevision !== encoding.baselineRevision || client.baselineHash !== encoding.baselineHash || client.reseedRequired !== encoding.reseedRequired || client.inFlight || client.visibility === "hidden" || client.visibility === "frozen" || job.pane.latest?.update.incarnation !== encoding.target.update.incarnation)
67305
+ if (job.abort.signal.aborted || this.#closed || client.closed || this.#clients.get(client.key) !== client || this.#panes.get(client.paneId) !== job.pane || client.baselineRevision !== encoding.baselineRevision || client.baselineHash !== encoding.baselineHash || client.reseedRequired !== encoding.reseedRequired || client.historyUnloadedRows !== encoding.historyUnloadedRows || client.inFlight || client.visibility === "hidden" || client.visibility === "frozen" || job.pane.latest?.update.incarnation !== encoding.target.update.incarnation)
66803
67306
  continue;
66804
67307
  this.#deliver(client, {
66805
67308
  target: encoding.target,
@@ -66843,6 +67346,8 @@ var init_terminal_delivery_hub = __esm({
66843
67346
  projectionBaseRevision: payload.frame === "seed" ? null : payload.baseRevision
66844
67347
  };
66845
67348
  }
67349
+ if (client.negotiated.partialHistory === "tail-v1" && target.state.snapshot)
67350
+ return this.#partialRepresentation(client, pane, target, seedOutcome);
66846
67351
  const key2 = cacheKey([
66847
67352
  target.update.workspaceName,
66848
67353
  target.update.semanticPaneId,
@@ -67144,6 +67649,7 @@ var init_terminal_delivery_hub = __esm({
67144
67649
  #ack(client, input) {
67145
67650
  const ack = TerminalDeliveryAckSchemaZ.parse(input);
67146
67651
  const flight = client.inFlight;
67652
+ if (client.droppedTransactions.has(ack.transactionId)) return;
67147
67653
  if (!flight) {
67148
67654
  if (client.lastAck && JSON.stringify(client.lastAck) === JSON.stringify(ack)) return;
67149
67655
  const closed = client.sourceClosedFlight;
@@ -67170,7 +67676,15 @@ var init_terminal_delivery_hub = __esm({
67170
67676
  client.baselineRevision = ack.canonicalRevision;
67171
67677
  client.baselineHash = ack.canonicalStateHash;
67172
67678
  client.reseedRequired = false;
67173
- client.inFlight = null;
67679
+ if (flight.historyRows) {
67680
+ client.historyUnloadedRows = flight.historyRows.unloaded;
67681
+ client.historyUnloadedDigest = flight.historyRows.digest;
67682
+ client.historyLoadedRows = flight.historyRows.loaded;
67683
+ this.#pushHistoryTail(client);
67684
+ }
67685
+ client.inFlight = client.pipelined.shift() ?? null;
67686
+ client.droppedTransactions.clear();
67687
+ this.#releaseBudget(client.clientId);
67174
67688
  client.lastAck = ack;
67175
67689
  if (client.latestRevision === ack.canonicalRevision) client.latestRevision = null;
67176
67690
  this.#pruneAckSupersededCache(client.paneId);
@@ -67220,6 +67734,234 @@ var init_terminal_delivery_hub = __esm({
67220
67734
  this.#schedule(client);
67221
67735
  this.#recordDeliveryStatus(client, this.#panes.get(client.paneId));
67222
67736
  }
67737
+ /**
67738
+ * Capability 122: the client's partial view of `target`. Its unloaded rows
67739
+ * follow the baseline's (a trim takes unloaded rows first); a seed carries
67740
+ * the newest TERMINAL_DELIVERY_HISTORY_TAIL_ROWS rows (none on the alternate
67741
+ * screen) or, after a reseed, as many rows as the client held. The full
67742
+ * canonical hash still verifies: the commitment covers the rest.
67743
+ */
67744
+ #partialRepresentation(client, pane, target, seedOutcome) {
67745
+ const full = target.state.snapshot;
67746
+ const baselineRecord = client.reseedRequired || client.baselineRevision < 0 ? void 0 : pane.revisions.get(client.baselineRevision);
67747
+ const baselineFull = baselineRecord?.state.snapshot ?? null;
67748
+ const tail = full.modes.alternateScreen ? 0 : TERMINAL_DELIVERY_HISTORY_TAIL_ROWS;
67749
+ const loadedDepth = () => Math.max(
67750
+ 0,
67751
+ full.history.length - Math.max(tail, client.baselineRevision >= 0 ? client.historyLoadedRows : 0)
67752
+ );
67753
+ let unloadedRows;
67754
+ let unloaded = null;
67755
+ let baseline = null;
67756
+ if (baselineFull && baselineRecord.update.incarnation === target.update.incarnation) {
67757
+ baseline = client.historyUnloadedRows === 0 ? baselineFull : { ...baselineFull, history: baselineFull.history.slice(client.historyUnloadedRows) };
67758
+ const trim = historyTrim(baselineFull.history, full.history);
67759
+ const kept = Math.max(0, client.historyUnloadedRows - trim);
67760
+ let same7 = kept <= full.history.length;
67761
+ for (let index = 0; same7 && index < kept; index++)
67762
+ if (baselineFull.history[trim + index] !== full.history[index]) same7 = false;
67763
+ if (same7) {
67764
+ unloadedRows = kept;
67765
+ const before = { rows: client.historyUnloadedRows, digest: client.historyUnloadedDigest };
67766
+ unloaded = trim === 0 ? before : dropTerminalHistoryCommitmentPrefix(
67767
+ before,
67768
+ baselineFull.history.slice(0, Math.min(trim, client.historyUnloadedRows))
67769
+ );
67770
+ } else {
67771
+ unloadedRows = loadedDepth();
67772
+ baseline = null;
67773
+ }
67774
+ } else {
67775
+ unloadedRows = loadedDepth();
67776
+ }
67777
+ const partial = unloadedRows === 0 ? full : { ...full, history: full.history.slice(unloadedRows) };
67778
+ const view = unloadedRows === 0 && client.historyUnloadedRows === 0 ? target : {
67779
+ ...target,
67780
+ state: { ...target.state, snapshot: partial },
67781
+ update: { ...target.update, type: "terminal.seed" }
67782
+ };
67783
+ const payload = baseline ? semanticPayload(client.baselineRevision, baseline, view, baselineRecord.update.incarnation) : semanticSeed(view);
67784
+ const encode = (value) => {
67785
+ if (value.frame === "seed" && (client.negotiated.encoding === "semantic-binary-v1" || terminalSemanticUpdateNeedsCooperativeEncoding(value))) {
67786
+ if (!seedOutcome) throw new DeferredSeedEncoding(value, `partial:${unloadedRows}`);
67787
+ if ("error" in seedOutcome) throw seedOutcome.error;
67788
+ return seedOutcome.bytes;
67789
+ }
67790
+ return client.negotiated.encoding === "semantic-binary-v1" ? encodeBinarySemanticTerminalUpdate(value) : encodeCompactSemanticTerminalUpdate(value);
67791
+ };
67792
+ let frame = payload.frame;
67793
+ let bytes;
67794
+ try {
67795
+ bytes = encode(payload);
67796
+ } catch (error) {
67797
+ if (!(error instanceof TerminalDeliveryStateTooLargeError) || payload.frame !== "patch")
67798
+ throw error;
67799
+ frame = "seed";
67800
+ bytes = encode(semanticSeed(view));
67801
+ }
67802
+ if (frame === "seed") this.#reseeds += client.reseedRequired ? 1 : 0;
67803
+ const commitment = unloaded ?? terminalHistoryPrefixCommitment(full.history, unloadedRows);
67804
+ return {
67805
+ bytes,
67806
+ encoding: client.negotiated.encoding,
67807
+ frame,
67808
+ canonicalEquivalent: true,
67809
+ history: "partial",
67810
+ historyUnloaded: commitment,
67811
+ historyRows: {
67812
+ unloaded: unloadedRows,
67813
+ digest: commitment.digest,
67814
+ loaded: full.history.length - unloadedRows
67815
+ }
67816
+ };
67817
+ }
67818
+ /** Hold the client while its connection's other panes are congested; true if held. */
67819
+ #holdForBudget(client) {
67820
+ if (this.#overBudget(client)) {
67821
+ client.budgetHeld = true;
67822
+ client.budgetHeldSince ??= this.#scheduler.nowMs();
67823
+ client.budgetTimer ??= this.#scheduler.timer(() => {
67824
+ client.budgetTimer = null;
67825
+ if (client.closed || !client.budgetHeld) return;
67826
+ client.budgetHeld = false;
67827
+ this.#schedule(client);
67828
+ }, this.#holdMs);
67829
+ return true;
67830
+ }
67831
+ client.budgetHeldSince = null;
67832
+ client.budgetTimer?.cancel();
67833
+ client.budgetTimer = null;
67834
+ return false;
67835
+ }
67836
+ /** Capability 122: a history frame goes next if asked for and no newer output waits (or one just went). */
67837
+ #historyDue(client) {
67838
+ return client.pendingHistoryRows !== null && !client.inFlight && !client.encoding && client.baselineRevision >= 0 && !client.reseedRequired && (client.latestRevision === null || client.latestRevision === client.baselineRevision || client.revisionSinceHistoryRequest) && // Live output of another pane held by the connection's budget goes first.
67839
+ ![...this.#clients.values()].some(
67840
+ (other) => other !== client && other.clientId === client.clientId && other.budgetHeld
67841
+ );
67842
+ }
67843
+ #deliverHistory(client, pane) {
67844
+ const asked = client.pendingHistoryRows;
67845
+ client.pendingHistoryRows = null;
67846
+ client.revisionSinceHistoryRequest = false;
67847
+ const record2 = pane.revisions.get(client.baselineRevision);
67848
+ const full = record2?.state.snapshot;
67849
+ if (!record2 || !full || client.historyUnloadedRows === 0) {
67850
+ this.#schedule(client);
67851
+ return;
67852
+ }
67853
+ const encoding = client.negotiated.encoding;
67854
+ const unloadedRows = client.historyUnloadedRows;
67855
+ try {
67856
+ const limit = Math.max(1, Math.min(asked, unloadedRows));
67857
+ const encode = (count2) => {
67858
+ const rows2 = full.history.slice(unloadedRows - count2, unloadedRows);
67859
+ const bytes2 = encodeSemanticTerminalHistory(
67860
+ { frame: "history", revision: record2.update.revision, rows: rows2 },
67861
+ encoding
67862
+ );
67863
+ return { count: count2, rows: rows2, bytes: bytes2 };
67864
+ };
67865
+ const fit = (bytesPerRow) => Math.max(
67866
+ 1,
67867
+ Math.min(limit, Math.floor(HISTORY_FRAME_MAX_BYTES * 0.95 / Math.max(1, bytesPerRow)))
67868
+ );
67869
+ let frame = client.historyBytesPerRow === null ? encode(Math.min(limit, 32)) : null;
67870
+ const estimate = client.historyBytesPerRow ?? frame.bytes.byteLength / frame.count;
67871
+ if (!frame || fit(estimate) !== frame.count) frame = encode(fit(estimate));
67872
+ if (frame.count < limit && frame.bytes.byteLength < HISTORY_FRAME_MAX_BYTES * 0.6) {
67873
+ const grown = fit(frame.bytes.byteLength / frame.count);
67874
+ if (grown > frame.count) frame = encode(grown);
67875
+ }
67876
+ let { count, rows, bytes } = frame;
67877
+ while (bytes.byteLength > HISTORY_FRAME_MAX_BYTES && count > 1) {
67878
+ count = Math.max(
67879
+ 1,
67880
+ Math.min(
67881
+ count - 1,
67882
+ Math.floor(count * HISTORY_FRAME_MAX_BYTES * 0.9 / bytes.byteLength)
67883
+ )
67884
+ );
67885
+ ({ rows, bytes } = encode(count));
67886
+ }
67887
+ client.historyBytesPerRow = bytes.byteLength / count;
67888
+ const chunk = {
67889
+ rows,
67890
+ unloaded: popTerminalHistoryCommitmentSuffix(
67891
+ { rows: unloadedRows, digest: client.historyUnloadedDigest },
67892
+ rows
67893
+ )
67894
+ };
67895
+ const envelope = TerminalDeliveryEnvelopeSchemaZ.parse({
67896
+ type: "terminal.delivery",
67897
+ workspaceName: client.deliveryWorkspaceName,
67898
+ semanticPaneId: record2.update.semanticPaneId,
67899
+ generation: record2.update.generation,
67900
+ incarnation: record2.update.incarnation,
67901
+ deliveryNonce: client.negotiated.deliveryNonce,
67902
+ transactionId: this.#scheduler.createId(),
67903
+ protocolVersion: 1,
67904
+ encoding,
67905
+ frame: "history",
67906
+ baseRevision: record2.update.revision,
67907
+ canonicalRevision: record2.update.revision,
67908
+ canonicalStateHash: record2.update.stateHash,
67909
+ representationHash: hashTerminalDeliveryRepresentation(bytes),
67910
+ representationBytes: bytes.byteLength,
67911
+ chunkCount: Math.max(1, Math.ceil(bytes.byteLength / (256 * 1024))),
67912
+ canonicalEquivalent: true,
67913
+ history: "partial",
67914
+ historyUnloaded: chunk.unloaded,
67915
+ richPlacements: client.negotiated.richPlacements
67916
+ });
67917
+ const deliveryOrdinal = ++this.#deliveryOrdinal;
67918
+ registerTerminalDeliveryObservationOrdinal(envelope, deliveryOrdinal);
67919
+ client.inFlight = {
67920
+ envelope,
67921
+ projection: null,
67922
+ historyRows: {
67923
+ unloaded: chunk.unloaded.rows,
67924
+ digest: chunk.unloaded.digest,
67925
+ loaded: full.history.length - chunk.unloaded.rows
67926
+ },
67927
+ deliveryOrdinal,
67928
+ bytes,
67929
+ nextChunk: 0,
67930
+ sentAt: this.#scheduler.nowMs()
67931
+ };
67932
+ this.#enqueue(client, envelope);
67933
+ this.#recordDeliveryStatus(client, pane);
67934
+ } catch (error) {
67935
+ this.#fault(
67936
+ client,
67937
+ error instanceof TerminalDeliveryStateTooLargeError ? "state-too-large" : "protocol-violation",
67938
+ error instanceof Error ? error.message : String(error)
67939
+ );
67940
+ }
67941
+ }
67942
+ /** Back on the normal screen with less than the tail loaded: send the tail unasked. */
67943
+ #pushHistoryTail(client) {
67944
+ if (client.pendingHistoryRows !== null || client.historyUnloadedRows === 0) return;
67945
+ const full = this.#panes.get(client.paneId)?.revisions.get(client.baselineRevision)?.state.snapshot;
67946
+ if (!full || full.modes.alternateScreen) return;
67947
+ if (client.historyLoadedRows >= TERMINAL_DELIVERY_HISTORY_TAIL_ROWS) return;
67948
+ client.pendingHistoryRows = Math.min(
67949
+ client.historyUnloadedRows,
67950
+ TERMINAL_DELIVERY_HISTORY_TAIL_ROWS - client.historyLoadedRows
67951
+ );
67952
+ client.revisionSinceHistoryRequest = false;
67953
+ }
67954
+ #historyRequest(client, input) {
67955
+ if (client.closed) return;
67956
+ const parsed = TerminalDeliveryHistoryRequestSchemaZ.safeParse(input);
67957
+ if (!parsed.success || client.negotiated.partialHistory !== "tail-v1" || parsed.data.workspaceName !== client.deliveryWorkspaceName || parsed.data.semanticPaneId !== client.paneId || parsed.data.generation !== client.negotiated.generation || parsed.data.deliveryNonce !== client.negotiated.deliveryNonce) {
67958
+ this.#fault(client, "protocol-violation", "History request does not identify this delivery");
67959
+ return;
67960
+ }
67961
+ client.pendingHistoryRows = parsed.data.maxRows;
67962
+ client.revisionSinceHistoryRequest = false;
67963
+ this.#schedule(client);
67964
+ }
67223
67965
  #projectionReceipt(client, input) {
67224
67966
  const receipt = TerminalProjectionReceiptSchemaZ.parse(input);
67225
67967
  if (client.lastProjectionReceipt && JSON.stringify(client.lastProjectionReceipt) === JSON.stringify(receipt))
@@ -67238,6 +67980,7 @@ var init_terminal_delivery_hub = __esm({
67238
67980
  client.lastProjectionReceipt = receipt;
67239
67981
  client.reseedRequired = false;
67240
67982
  client.inFlight = null;
67983
+ this.#releaseBudget(client.clientId);
67241
67984
  if (client.latestRevision === receipt.canonicalRevision) client.latestRevision = null;
67242
67985
  if (client.materializeRequested)
67243
67986
  client.latestRevision = this.#panes.get(client.paneId)?.latest?.update.revision ?? null;
@@ -67269,6 +68012,7 @@ var init_terminal_delivery_hub = __esm({
67269
68012
  const closed = client.sourceClosedFlight;
67270
68013
  if (client.captureUnavailable && !client.inFlight && closed && nack.workspaceName === closed.workspaceName && nack.semanticPaneId === closed.semanticPaneId && nack.generation === closed.generation && nack.incarnation === closed.incarnation && nack.deliveryNonce === closed.deliveryNonce && nack.transactionId === closed.transactionId)
67271
68014
  return;
68015
+ if (nack.transactionId !== null && client.droppedTransactions.has(nack.transactionId)) return;
67272
68016
  const envelope = client.inFlight?.envelope;
67273
68017
  if (!envelope || nack.workspaceName !== envelope.workspaceName || nack.semanticPaneId !== envelope.semanticPaneId || nack.generation !== envelope.generation || nack.incarnation !== envelope.incarnation || nack.deliveryNonce !== envelope.deliveryNonce || nack.transactionId !== envelope.transactionId) {
67274
68018
  this.#fault(client, "protocol-violation", "NACK does not identify the in-flight delivery");
@@ -67277,11 +68021,13 @@ var init_terminal_delivery_hub = __esm({
67277
68021
  this.#nacks += 1;
67278
68022
  client.reseedRequired = true;
67279
68023
  client.inFlight = null;
68024
+ this.#dropPipelined(client);
68025
+ this.#releaseBudget(client.clientId);
67280
68026
  this.#pruneCanonicalRevisions(client.paneId);
67281
68027
  this.#schedule(client);
67282
68028
  this.#recordDeliveryStatus(client, this.#panes.get(client.paneId));
67283
68029
  }
67284
- #fault(client, reason, message, selectionObservation = null) {
68030
+ #fault(client, reason, message2, selectionObservation = null) {
67285
68031
  logDeliveryFault(client, reason);
67286
68032
  if (this.#observability.enabled)
67287
68033
  try {
@@ -67322,10 +68068,12 @@ var init_terminal_delivery_hub = __esm({
67322
68068
  client.outgoing.length = 0;
67323
68069
  if (reason === "source-closed") client.sourceClosedFlight = client.inFlight?.envelope ?? null;
67324
68070
  client.inFlight = null;
68071
+ this.#dropPipelined(client);
68072
+ this.#releaseBudget(client.clientId);
67325
68073
  const fault = {
67326
68074
  type: "terminal.delivery.fault",
67327
68075
  reason,
67328
- message: message.slice(0, 1024),
68076
+ message: message2.slice(0, 1024),
67329
68077
  deliveryNonce: client.negotiated.deliveryNonce
67330
68078
  };
67331
68079
  if (reason === "source-closed" && client.sending) {
@@ -67338,8 +68086,8 @@ var init_terminal_delivery_hub = __esm({
67338
68086
  this.#enqueue(client, fault);
67339
68087
  client.retireAfterDrain = true;
67340
68088
  }
67341
- #enqueue(client, message) {
67342
- this.#enqueueFactory(client, () => message);
68089
+ #enqueue(client, message2) {
68090
+ this.#enqueueFactory(client, () => message2);
67343
68091
  }
67344
68092
  #enqueueFactory(client, create) {
67345
68093
  if (client.closed) return;
@@ -67352,10 +68100,12 @@ var init_terminal_delivery_hub = __esm({
67352
68100
  while (!client.closed) {
67353
68101
  const queued = client.outgoing.shift();
67354
68102
  let next = queued?.();
67355
- const flight = client.inFlight;
68103
+ const flight = client.pipelined.at(-1) ?? client.inFlight;
67356
68104
  if (!next && flight && flight.nextChunk < flight.envelope.chunkCount) {
67357
68105
  const index = flight.nextChunk;
67358
68106
  flight.nextChunk += 1;
68107
+ if (flight.nextChunk === flight.envelope.chunkCount && client.latestRevision !== null)
68108
+ this.#schedule(client);
67359
68109
  next = {
67360
68110
  type: "terminal.delivery.chunk",
67361
68111
  transactionId: flight.envelope.transactionId,
@@ -67390,8 +68140,13 @@ var init_terminal_delivery_hub = __esm({
67390
68140
  if (client.lifecycleOpenRecorded)
67391
68141
  this.#recordDeliveryLifecycle(client, this.#panes.get(client.paneId), "close");
67392
68142
  client.backgroundTimer?.cancel();
68143
+ client.budgetTimer?.cancel();
68144
+ client.budgetTimer = null;
67393
68145
  client.outgoing.length = 0;
67394
68146
  this.#clients.delete(client.key);
68147
+ if (![...this.#clients.values()].some((other) => other.clientId === client.clientId))
68148
+ this.#priority.delete(client.clientId);
68149
+ else this.#releaseBudget(client.clientId);
67395
68150
  this.#pruneCanonicalRevisions(client.paneId);
67396
68151
  if ([...this.#clients.values()].some((candidate) => candidate.paneId === client.paneId)) return;
67397
68152
  const pane = this.#panes.get(client.paneId);
@@ -67526,8 +68281,9 @@ var init_terminal_delivery_hub = __esm({
67526
68281
  reachable.add(client.baselineRevision);
67527
68282
  const encoding = client.encoding?.target.update;
67528
68283
  if (encoding?.incarnation === latest.incarnation) reachable.add(encoding.revision);
67529
- const flight = client.inFlight?.envelope;
67530
- if (flight?.incarnation === latest.incarnation) reachable.add(flight.canonicalRevision);
68284
+ for (const flight of [client.inFlight, ...client.pipelined])
68285
+ if (flight?.envelope.incarnation === latest.incarnation)
68286
+ reachable.add(flight.envelope.canonicalRevision);
67531
68287
  }
67532
68288
  for (const revision of pane.revisions.keys())
67533
68289
  if (!reachable.has(revision)) {
@@ -67542,7 +68298,9 @@ var init_terminal_delivery_hub = __esm({
67542
68298
  for (const [key2, cached2] of this.#cache) {
67543
68299
  if (cached2.cachePaneId !== paneId) continue;
67544
68300
  const reachable = clients.some(
67545
- (candidate) => cached2.cacheBaseRevision === candidate.baselineRevision || Number.isSafeInteger(cached2.cacheTargetRevision) && cached2.cacheTargetRevision > candidate.baselineRevision || cached2.cacheTargetRevision === candidate.inFlight?.envelope.canonicalRevision
68301
+ (candidate) => cached2.cacheBaseRevision === candidate.baselineRevision || Number.isSafeInteger(cached2.cacheTargetRevision) && cached2.cacheTargetRevision > candidate.baselineRevision || cached2.cacheTargetRevision === candidate.inFlight?.envelope.canonicalRevision || candidate.pipelined.some(
68302
+ (flight) => cached2.cacheTargetRevision === flight.envelope.canonicalRevision
68303
+ )
67546
68304
  );
67547
68305
  if (reachable) continue;
67548
68306
  this.#cache.delete(key2);
@@ -67879,16 +68637,16 @@ var init_registry2 = __esm({
67879
68637
  pendingDeliveryClients: 0
67880
68638
  });
67881
68639
  SessionRuntimeControllerLeaseError = class extends Error {
67882
- constructor(code2, message) {
67883
- super(message);
68640
+ constructor(code2, message2) {
68641
+ super(message2);
67884
68642
  this.code = code2;
67885
68643
  this.name = "SessionRuntimeControllerLeaseError";
67886
68644
  }
67887
68645
  code;
67888
68646
  };
67889
68647
  SessionRuntimeInputLifetimeEndedError = class extends Error {
67890
- constructor(message) {
67891
- super(message);
68648
+ constructor(message2) {
68649
+ super(message2);
67892
68650
  this.name = "SessionRuntimeInputLifetimeEndedError";
67893
68651
  }
67894
68652
  };
@@ -69271,9 +70029,9 @@ var init_registry2 = __esm({
69271
70029
  this.#publishAuthority();
69272
70030
  }
69273
70031
  assertNoSharedWindow() {
69274
- const message = this.#mirror.windowOwnershipMessage(this.session);
69275
- if (message) {
69276
- throw new SessionRuntimeControllerLeaseError("controller-conflict", message);
70032
+ const message2 = this.#mirror.windowOwnershipMessage(this.session);
70033
+ if (message2) {
70034
+ throw new SessionRuntimeControllerLeaseError("controller-conflict", message2);
69277
70035
  }
69278
70036
  }
69279
70037
  invalidateSharedWindowAuthority() {
@@ -69579,6 +70337,8 @@ var init_registry2 = __esm({
69579
70337
  ack: (ack) => upstream.ack(ack),
69580
70338
  ...upstream.projectionReceipt ? { projectionReceipt: upstream.projectionReceipt } : {},
69581
70339
  ...upstream.materialize ? { materialize: upstream.materialize } : {},
70340
+ ...upstream.historyRequest ? { historyRequest: upstream.historyRequest } : {},
70341
+ ...upstream.prioritize ? { prioritize: upstream.prioritize } : {},
69582
70342
  nack: (nack) => upstream.nack(nack),
69583
70343
  setVisibility: (visibility) => upstream.setVisibility(visibility),
69584
70344
  close: async () => {
@@ -70528,8 +71288,8 @@ var init_lease_manager = __esm({
70528
71288
  MarkerPattern = /^v1:([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}):(0|[1-9][0-9]*)$/iu;
70529
71289
  AttachmentLeaseError = class extends Error {
70530
71290
  code;
70531
- constructor(code2, message) {
70532
- super(message);
71291
+ constructor(code2, message2) {
71292
+ super(message2);
70533
71293
  this.name = "AttachmentLeaseError";
70534
71294
  this.code = code2;
70535
71295
  }
@@ -71268,8 +72028,8 @@ var init_direct_websocket = __esm({
71268
72028
  GridSchemaZ = TerminalAttachmentViewportSchemaZ;
71269
72029
  TerminalAttachmentAdmissionError = class extends Error {
71270
72030
  code;
71271
- constructor(code2, message) {
71272
- super(message);
72031
+ constructor(code2, message2) {
72032
+ super(message2);
71273
72033
  this.name = "TerminalAttachmentAdmissionError";
71274
72034
  this.code = code2;
71275
72035
  }
@@ -75916,8 +76676,8 @@ var init_lease_manager2 = __esm({
75916
76676
  TicketPattern2 = /^ps2_[A-Za-z0-9_-]{43}$/u;
75917
76677
  PaneStreamLeaseError = class extends Error {
75918
76678
  code;
75919
- constructor(code2, message) {
75920
- super(message);
76679
+ constructor(code2, message2) {
76680
+ super(message2);
75921
76681
  this.name = "PaneStreamLeaseError";
75922
76682
  this.code = code2;
75923
76683
  }
@@ -76092,6 +76852,7 @@ var init_lease_manager2 = __esm({
76092
76852
  sessionName: state.sessionName,
76093
76853
  runtimeSessionId: state.runtimeSessionId,
76094
76854
  panes: [...state.request.panes],
76855
+ semanticWindowId: state.request.semanticWindowId ?? null,
76095
76856
  viewerMode: state.request.viewerMode,
76096
76857
  terminalDelivery: state.request.terminalDelivery ?? null,
76097
76858
  status: state.status,
@@ -76552,8 +77313,8 @@ var init_pane_stream_websocket = __esm({
76552
77313
  BindingIdSchemaZ4 = z123.string().min(1).max(4096).refine((value) => !value.includes("\0"));
76553
77314
  PaneStreamAdmissionError = class extends Error {
76554
77315
  code;
76555
- constructor(code2, message) {
76556
- super(message);
77316
+ constructor(code2, message2) {
77317
+ super(message2);
76557
77318
  this.name = "PaneStreamAdmissionError";
76558
77319
  this.code = code2;
76559
77320
  }
@@ -76701,6 +77462,16 @@ var init_pane_stream_websocket = __esm({
76701
77462
  );
76702
77463
  }
76703
77464
  }
77465
+ if (request3.semanticWindowId !== void 0) {
77466
+ const windowPanes = new Set(
77467
+ described.panes.filter((pane) => pane.semanticWindowId === request3.semanticWindowId).map((pane) => pane.semanticPaneId)
77468
+ );
77469
+ if (windowPanes.size !== request3.panes.length || request3.panes.some((pane) => !windowPanes.has(pane)))
77470
+ throw new PaneStreamAdmissionError(
77471
+ "pane-not-found",
77472
+ "The panes are not exactly the panes of that window of the workspace session."
77473
+ );
77474
+ }
76704
77475
  const issued = await this.#leaseManager.issue(request3, {
76705
77476
  requestId,
76706
77477
  projectIdentity,
@@ -77043,6 +77814,9 @@ var init_pane_stream_websocket = __esm({
77043
77814
  cancelBeforeBind() {
77044
77815
  this.close(1008, "upgrade-rejected");
77045
77816
  }
77817
+ redeemFromUpgrade(frame) {
77818
+ this.#onMessage(frame, false);
77819
+ }
77046
77820
  promote() {
77047
77821
  if (!this.#open) return;
77048
77822
  this.#promoted = true;
@@ -77470,13 +78244,13 @@ var init_pane_stream_websocket = __esm({
77470
78244
  * stream with 1011, and nothing was tried twice. A refusal of authority is a
77471
78245
  * decision, not a failure, and is never repeated. Each repeat is logged.
77472
78246
  */
77473
- async #retryOpenStep(step, run) {
78247
+ async #retryOpenStep(step, run, final = () => false) {
77474
78248
  for (let attempt = 0; ; attempt += 1) {
77475
78249
  try {
77476
78250
  return await run();
77477
78251
  } catch (error) {
77478
78252
  const delayMs = this.#openRetryDelaysMs[attempt];
77479
- if (delayMs === void 0 || this.#closed || error instanceof SessionRuntimeControllerLeaseError)
78253
+ if (delayMs === void 0 || this.#closed || error instanceof SessionRuntimeControllerLeaseError || final(error))
77480
78254
  throw error;
77481
78255
  logger.info("pane-stream", "stream open step failed; trying again", {
77482
78256
  session: this.#descriptor.sessionName,
@@ -77507,21 +78281,29 @@ var init_pane_stream_websocket = __esm({
77507
78281
  let stagedAuthority = null;
77508
78282
  let authorityMalformed = false;
77509
78283
  let layoutActivated = false;
78284
+ let layoutAttempt = 0;
77510
78285
  try {
77511
- if (!this.#mirror.subscribeLayout) throw new Error("authoritative layout is unavailable");
77512
- const subscription = await this.#mirror.subscribeLayout(
77513
- this.#descriptor.sessionName,
77514
- () => void 0,
77515
- {
77516
- expectedSemanticPaneIds: expectedPaneIds,
77517
- expectedRuntimeSessionId: this.#descriptor.runtimeSessionId,
77518
- onAuthority: (snapshot3) => {
77519
- this.#recordDiagnosticLifecycle("pane-stream-layout-staged");
77520
- if (snapshot3.layouts.length > PANE_STREAM_MAX_PANES) authorityMalformed = true;
77521
- else if (!layoutActivated) stagedAuthority = snapshot3;
77522
- else this.#onLayoutAuthority(snapshot3);
77523
- }
77524
- }
78286
+ const subscribeLayout = this.#mirror.subscribeLayout?.bind(this.#mirror);
78287
+ if (!subscribeLayout) throw new Error("authoritative layout is unavailable");
78288
+ const subscription = await this.#retryOpenStep(
78289
+ "semantic-layout-subscribe",
78290
+ () => {
78291
+ const attempt = ++layoutAttempt;
78292
+ stagedAuthority = null;
78293
+ authorityMalformed = false;
78294
+ return subscribeLayout(this.#descriptor.sessionName, () => void 0, {
78295
+ expectedSemanticPaneIds: expectedPaneIds,
78296
+ expectedRuntimeSessionId: this.#descriptor.runtimeSessionId,
78297
+ onAuthority: (snapshot3) => {
78298
+ if (attempt !== layoutAttempt) return;
78299
+ this.#recordDiagnosticLifecycle("pane-stream-layout-staged");
78300
+ if (snapshot3.layouts.length > PANE_STREAM_MAX_PANES) authorityMalformed = true;
78301
+ else if (!layoutActivated) stagedAuthority = snapshot3;
78302
+ else this.#onLayoutAuthority(snapshot3);
78303
+ }
78304
+ });
78305
+ },
78306
+ (error) => error instanceof Error && error.name === "MirrorTopologyChangedError"
77525
78307
  );
77526
78308
  if (this.#closed) {
77527
78309
  await subscription.close().catch(() => void 0);
@@ -77629,10 +78411,10 @@ var init_pane_stream_websocket = __esm({
77629
78411
  return binding.openTerminalDelivery(
77630
78412
  channel.semanticPaneId,
77631
78413
  offer,
77632
- (message) => {
77633
- if (!ready && !(negotiated && message.type === "terminal.delivery.fault"))
77634
- pending.push(message);
77635
- else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
78414
+ (message2) => {
78415
+ if (!ready && !(negotiated && message2.type === "terminal.delivery.fault"))
78416
+ pending.push(message2);
78417
+ else return this.#sendTerminalDelivery(channel.semanticPaneId, message2);
77636
78418
  },
77637
78419
  this.#descriptor.workspaceName
77638
78420
  );
@@ -77654,11 +78436,11 @@ var init_pane_stream_websocket = __esm({
77654
78436
  const negotiated = delivery.negotiation.negotiated;
77655
78437
  if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
77656
78438
  let incarnation = null;
77657
- for (const message of pending) {
77658
- if (message.type !== "terminal.delivery" && message.type !== "terminal.projection") continue;
77659
- if (message.workspaceName !== this.#descriptor.workspaceName || message.semanticPaneId !== channel.semanticPaneId || message.generation !== negotiated.generation || message.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message.incarnation !== incarnation)
78439
+ for (const message2 of pending) {
78440
+ if (message2.type !== "terminal.delivery" && message2.type !== "terminal.projection") continue;
78441
+ if (message2.workspaceName !== this.#descriptor.workspaceName || message2.semanticPaneId !== channel.semanticPaneId || message2.generation !== negotiated.generation || message2.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message2.incarnation !== incarnation)
77660
78442
  return true;
77661
- incarnation = message.incarnation;
78443
+ incarnation = message2.incarnation;
77662
78444
  }
77663
78445
  return false;
77664
78446
  }
@@ -77690,8 +78472,8 @@ var init_pane_stream_websocket = __esm({
77690
78472
  }
77691
78473
  for (const { channel, pending, markReady } of opened) {
77692
78474
  if (this.#closed || channel.closed) continue;
77693
- for (const message of pending)
77694
- await this.#sendTerminalDelivery(channel.semanticPaneId, message);
78475
+ for (const message2 of pending)
78476
+ await this.#sendTerminalDelivery(channel.semanticPaneId, message2);
77695
78477
  pending.length = 0;
77696
78478
  markReady();
77697
78479
  this.#startGraphics(channel);
@@ -77724,27 +78506,27 @@ var init_pane_stream_websocket = __esm({
77724
78506
  * change has a fresh channel, which this tombstone is not about.
77725
78507
  */
77726
78508
  #tombstonesAfterChange = /* @__PURE__ */ new Set();
77727
- async #sendTerminalDelivery(pane, message) {
77728
- if ((message.type === "terminal.delivery" || message.type === "terminal.projection") && message.frame === "tombstone")
78509
+ async #sendTerminalDelivery(pane, message2) {
78510
+ if ((message2.type === "terminal.delivery" || message2.type === "terminal.projection") && message2.frame === "tombstone")
77729
78511
  this.#watchTombstone(pane);
77730
- if (message.type === "terminal.projection") {
78512
+ if (message2.type === "terminal.projection") {
77731
78513
  const channel = this.#panes.get(pane);
77732
- if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message.incarnation;
78514
+ if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message2.incarnation;
77733
78515
  if (channel) channel.binaryCells = true;
77734
- this.#sendFrame(pane, { type: "terminal-projection-envelope", pane, envelope: message });
77735
- } else if (message.type === "terminal.delivery") {
78516
+ this.#sendFrame(pane, { type: "terminal-projection-envelope", pane, envelope: message2 });
78517
+ } else if (message2.type === "terminal.delivery") {
77736
78518
  if (!this.#diagnosticFirstSeedObserved) {
77737
78519
  this.#diagnosticFirstSeedObserved = true;
77738
78520
  this.#recordDiagnosticLifecycle("pane-stream-first-seed");
77739
78521
  }
77740
78522
  const channel = this.#panes.get(pane);
77741
- if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message.incarnation;
77742
- if (channel) channel.binaryCells = message.encoding === "semantic-binary-v1";
78523
+ if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message2.incarnation;
78524
+ if (channel) channel.binaryCells = message2.encoding === "semantic-binary-v1";
77743
78525
  const detailedDeliveryObservation = this.#observability?.enabled === true;
77744
- const trace = message.performanceTraceId && detailedDeliveryObservation ? this.#observability.beginTrace(
78526
+ const trace = message2.performanceTraceId && detailedDeliveryObservation ? this.#observability.beginTrace(
77745
78527
  "terminal-input-to-paint",
77746
- { generation: message.generation, incarnation: message.incarnation },
77747
- message.performanceTraceId
78528
+ { generation: message2.generation, incarnation: message2.incarnation },
78529
+ message2.performanceTraceId
77748
78530
  ) : null;
77749
78531
  let startedAtMicros = null;
77750
78532
  if (detailedDeliveryObservation)
@@ -77762,7 +78544,7 @@ var init_pane_stream_websocket = __esm({
77762
78544
  this.#sendFrame(pane, {
77763
78545
  type: "terminal-delivery-envelope",
77764
78546
  pane,
77765
- envelope: message
78547
+ envelope: message2
77766
78548
  });
77767
78549
  if (startedAtMicros !== null) {
77768
78550
  let endedAtMicros;
@@ -77790,32 +78572,32 @@ var init_pane_stream_websocket = __esm({
77790
78572
  endedAtMicros: endedAtSharedMicros
77791
78573
  },
77792
78574
  Object.freeze({
77793
- workspaceName: message.workspaceName,
77794
- semanticPaneId: message.semanticPaneId,
77795
- canonicalGeneration: message.generation,
77796
- canonicalIncarnation: message.incarnation,
77797
- canonicalRevision: message.canonicalRevision,
77798
- canonicalStateHash: message.canonicalStateHash,
77799
- transactionId: message.transactionId,
77800
- ...terminalDeliveryObservationOrdinal(message) === null ? {} : { deliveryOrdinal: terminalDeliveryObservationOrdinal(message) },
78575
+ workspaceName: message2.workspaceName,
78576
+ semanticPaneId: message2.semanticPaneId,
78577
+ canonicalGeneration: message2.generation,
78578
+ canonicalIncarnation: message2.incarnation,
78579
+ canonicalRevision: message2.canonicalRevision,
78580
+ canonicalStateHash: message2.canonicalStateHash,
78581
+ transactionId: message2.transactionId,
78582
+ ...terminalDeliveryObservationOrdinal(message2) === null ? {} : { deliveryOrdinal: terminalDeliveryObservationOrdinal(message2) },
77801
78583
  deliveryClientId: this.#sessionRuntimeBinding?.clientId ?? this.#clientId,
77802
78584
  deliverySurface: this.#sessionRuntimeBinding?.surface ?? "unknown",
77803
78585
  deliveryLaneId: this.#sessionRuntimeBinding?.deliveryLaneId ?? this.#clientId,
77804
78586
  deliveryRequestId: this.#sessionRuntimeBinding?.deliveryRequestId ?? this.#clientId,
77805
- deliveryNonce: message.deliveryNonce
78587
+ deliveryNonce: message2.deliveryNonce
77806
78588
  })
77807
78589
  );
77808
78590
  } catch {
77809
78591
  }
77810
78592
  }
77811
- } else if (message.type === "terminal.delivery.chunk") {
78593
+ } else if (message2.type === "terminal.delivery.chunk") {
77812
78594
  if (this.#panes.get(pane)?.binaryCells) {
77813
78595
  this.#sendEncoded(
77814
78596
  pane,
77815
78597
  Buffer.from(
77816
78598
  encodeTerminalDeliveryBinaryChunk(
77817
- { pane, transactionId: message.transactionId, index: message.index },
77818
- message.bytes
78599
+ { pane, transactionId: message2.transactionId, index: message2.index },
78600
+ message2.bytes
77819
78601
  )
77820
78602
  ),
77821
78603
  true
@@ -77824,13 +78606,13 @@ var init_pane_stream_websocket = __esm({
77824
78606
  this.#sendFrame(pane, {
77825
78607
  type: "terminal-delivery-chunk",
77826
78608
  pane,
77827
- transactionId: message.transactionId,
77828
- index: message.index,
77829
- data: Buffer.from(message.bytes).toString("base64")
78609
+ transactionId: message2.transactionId,
78610
+ index: message2.index,
78611
+ data: Buffer.from(message2.bytes).toString("base64")
77830
78612
  });
77831
78613
  }
77832
78614
  } else {
77833
- this.#sendFrame(pane, { type: "terminal-delivery-fault", pane, fault: message });
78615
+ this.#sendFrame(pane, { type: "terminal-delivery-fault", pane, fault: message2 });
77834
78616
  return;
77835
78617
  }
77836
78618
  await this.#awaitSemanticCredit(pane);
@@ -78221,11 +79003,12 @@ var init_pane_stream_websocket = __esm({
78221
79003
  return;
78222
79004
  }
78223
79005
  const frames = this.#validateInitialLayout(snapshot3.layouts, this.#semanticExpectedPaneIds);
78224
- if (!frames && this.#topologyInPlace) {
79006
+ const windowChanged = frames !== null && this.#windowPaneSetChanged(snapshot3);
79007
+ if ((!frames || windowChanged) && this.#topologyInPlace) {
78225
79008
  void this.#reconcileTopology(snapshot3);
78226
79009
  return;
78227
79010
  }
78228
- if (!frames || !PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
79011
+ if (!frames || windowChanged || !PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
78229
79012
  type: "layout-snapshot",
78230
79013
  topologyEpoch: snapshot3.topologyEpoch,
78231
79014
  layouts: frames,
@@ -78250,6 +79033,17 @@ var init_pane_stream_websocket = __esm({
78250
79033
  windowLinks: snapshot3.windowLinks
78251
79034
  });
78252
79035
  }
79036
+ /** #806: the layout no longer shows this stream's window with exactly its panes. */
79037
+ #windowPaneSetChanged(snapshot3) {
79038
+ const window2 = this.#descriptor.semanticWindowId;
79039
+ if (window2 === null) return false;
79040
+ const live = [...this.#panes.values()].filter((channel) => !channel.closed).map((channel) => channel.semanticPaneId);
79041
+ const shown = snapshot3.layouts.find((event) => event.semanticWindowId === window2);
79042
+ if (!shown) return true;
79043
+ const panes = shown.panes.map((pane) => pane.semanticPaneId ?? "");
79044
+ if (shown.zoomed) return panes.length !== 1 || !live.includes(panes[0]);
79045
+ return panes.length !== live.length || panes.some((pane) => !live.includes(pane));
79046
+ }
78253
79047
  /** The same session and runtime, a newer epoch, a layout a stream can carry. */
78254
79048
  #layoutAuthorityAdmissible(snapshot3) {
78255
79049
  return snapshot3.session === this.#descriptor.sessionName && snapshot3.runtimeSessionId === this.#semanticRuntimeSessionId && snapshot3.topologyEpoch > this.#semanticTopologyEpoch && snapshot3.layouts.length <= PANE_STREAM_MAX_PANES;
@@ -78344,10 +79138,25 @@ var init_pane_stream_websocket = __esm({
78344
79138
  windowLinks: snapshot3.windowLinks
78345
79139
  }).success)
78346
79140
  return this.#topologyFailed("layout snapshot invalid");
79141
+ const window2 = this.#descriptor.semanticWindowId;
79142
+ let windowPanes = null;
79143
+ if (window2 !== null) {
79144
+ windowPanes = [
79145
+ ...new Set(
79146
+ described.panes.filter((pane) => pane.semanticWindowId === window2).map((pane) => pane.semanticPaneId)
79147
+ )
79148
+ ].sort();
79149
+ if (windowPanes.length === 0) return this.#topologyFailed("the stream's window is gone");
79150
+ const shown = snapshot3.layouts.find((event) => event.semanticWindowId === window2);
79151
+ const shownPanes = (shown?.panes ?? []).map((pane) => pane.semanticPaneId ?? "");
79152
+ if (!shown || (shown.zoomed ? shownPanes.length !== 1 || !windowPanes.includes(shownPanes[0]) : shownPanes.length !== windowPanes.length || shownPanes.some((pane) => !windowPanes.includes(pane))))
79153
+ return "stale";
79154
+ }
79155
+ const followed = windowPanes ?? next;
78347
79156
  const live = [...this.#panes.values()].filter((channel) => !channel.closed);
78348
- const removed = live.filter((channel) => !next.includes(channel.semanticPaneId));
79157
+ const removed = live.filter((channel) => !followed.includes(channel.semanticPaneId));
78349
79158
  const liveIds = new Set(live.map((channel) => channel.semanticPaneId));
78350
- const added = this.#leasesWholeSession ? next.filter((pane) => !liveIds.has(pane)) : [];
79159
+ const added = windowPanes !== null || this.#leasesWholeSession ? followed.filter((pane) => !liveIds.has(pane)) : [];
78351
79160
  if (added.length > 0 && !inventoryIsThisSession)
78352
79161
  return this.#topologyFailed("inventory cannot prove the runtime session");
78353
79162
  const remaining = live.length - removed.length + added.length;
@@ -78471,6 +79280,7 @@ var init_pane_stream_websocket = __esm({
78471
79280
  displayNameSource: pane.displayNameSource,
78472
79281
  ...this.#offers(PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION) || this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION) ? { browserIcon: pane.browserIcon ?? null } : {},
78473
79282
  ...this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION) ? { reader: pane.reader ? { name: pane.reader.name } : null } : {},
79283
+ ...this.#offers(PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION) ? { browserKind: pane.browserKind ?? null } : {},
78474
79284
  left: pane.left,
78475
79285
  top: pane.top,
78476
79286
  width: pane.width,
@@ -78752,6 +79562,14 @@ var init_pane_stream_websocket = __esm({
78752
79562
  channel.delivery.projectionReceipt(frame.receipt);
78753
79563
  return;
78754
79564
  }
79565
+ if (frame.type === "terminal-delivery-history-request") {
79566
+ const channel = this.#deliveryChannel(frame.request);
79567
+ if (!channel) return;
79568
+ if (!channel.delivery?.historyRequest || !channel.delivery.negotiation.accepted || channel.delivery.negotiation.negotiated.partialHistory !== "tail-v1")
79569
+ return this.#failProtocol("protocol-error");
79570
+ channel.delivery.historyRequest(frame.request);
79571
+ return;
79572
+ }
78755
79573
  if (frame.type === "terminal-projection-materialize") {
78756
79574
  const channel = this.#deliveryChannel(frame.request);
78757
79575
  if (!channel) return;
@@ -79193,6 +80011,7 @@ var init_pane_stream_websocket = __esm({
79193
80011
  else if (kind === "text") channel.sub.sendText(data);
79194
80012
  else if (kind === "key") channel.sub.sendKey(data);
79195
80013
  else throw new Error("Byte input requires semantic runtime");
80014
+ channel.delivery?.prioritize?.();
79196
80015
  let ackStartedAtMicros = null;
79197
80016
  let ackStartedAtSharedMicros = null;
79198
80017
  if (trace) {
@@ -80262,12 +81081,12 @@ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () =
80262
81081
  const row = rows.get(liveSessionId) ?? {
80263
81082
  summary: { liveSessionId, sessionName: name, paneCount: 0 },
80264
81083
  panes: /* @__PURE__ */ new Set(),
80265
- windows: /* @__PURE__ */ new Set(),
81084
+ windows: /* @__PURE__ */ new Map(),
80266
81085
  dir,
80267
81086
  activity: activity && /^\d+$/.test(activity) ? Number(activity) : null
80268
81087
  };
81088
+ if (!row.panes.has(pane)) row.windows.set(window2, (row.windows.get(window2) ?? 0) + 1);
80269
81089
  row.panes.add(pane);
80270
- row.windows.add(window2);
80271
81090
  rows.set(liveSessionId, row);
80272
81091
  }
80273
81092
  const names = new Set([...rows.values()].map(({ summary }) => summary.sessionName));
@@ -80286,6 +81105,7 @@ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () =
80286
81105
  ...summary,
80287
81106
  paneCount: panes.size,
80288
81107
  windowCount: windows.size,
81108
+ largestWindowPaneCount: Math.max(...windows.values()),
80289
81109
  lastActivity: activity,
80290
81110
  sessionPath: dir
80291
81111
  }));
@@ -81580,6 +82400,15 @@ function rawHeaderValues(request3, expectedName) {
81580
82400
  }
81581
82401
  return values2;
81582
82402
  }
82403
+ function upgradeRedeemFrame(request3) {
82404
+ const values2 = rawHeaderValues(request3, PANE_STREAM_REDEEM_HEADER);
82405
+ if (values2.length === 0) return null;
82406
+ const value = values2[0];
82407
+ if (values2.length > 1 || value.length === 0 || value.length > Math.ceil(PANE_STREAM_MAX_REDEMPTION_BYTES * 4 / 3) || !/^[A-Za-z0-9_-]+$/u.test(value))
82408
+ return "invalid";
82409
+ const frame = Buffer.from(value, "base64url");
82410
+ return frame.byteLength === 0 || frame.byteLength > PANE_STREAM_MAX_REDEMPTION_BYTES ? "invalid" : frame;
82411
+ }
81583
82412
  function rejectUpgrade(socket, status2) {
81584
82413
  const phrase = status2 === 403 ? "Forbidden" : status2 === 404 ? "Not Found" : status2 === 410 ? "Gone" : status2 === 426 ? "Upgrade Required" : "Service Unavailable";
81585
82414
  try {
@@ -81603,7 +82432,11 @@ function attachPaneStreamWebSocket(server, coordinator, redemptionPath = PANE_ST
81603
82432
  return offered.size === 1 && offered.has(PANE_STREAM_WEBSOCKET_SUBPROTOCOL) ? PANE_STREAM_WEBSOCKET_SUBPROTOCOL : false;
81604
82433
  }
81605
82434
  });
81606
- wss.on("headers", (headers2) => heartbeat.advertise(headers2));
82435
+ const redeemed = /* @__PURE__ */ new WeakSet();
82436
+ wss.on("headers", (headers2, request3) => {
82437
+ heartbeat.advertise(headers2);
82438
+ if (redeemed.has(request3)) headers2.push("X-Tmux-Ide-Redeem: accepted");
82439
+ });
81607
82440
  const upgrade = (request3, socket, head3) => {
81608
82441
  const rawPath = request3.url ?? "";
81609
82442
  const pathname = rawPath.split("?", 1)[0] ?? "";
@@ -81638,6 +82471,11 @@ function attachPaneStreamWebSocket(server, coordinator, redemptionPath = PANE_ST
81638
82471
  rejectUpgrade(socket, 403);
81639
82472
  return;
81640
82473
  }
82474
+ const redeemFrame = upgradeRedeemFrame(request3);
82475
+ if (redeemFrame === "invalid") {
82476
+ rejectUpgrade(socket, 403);
82477
+ return;
82478
+ }
81641
82479
  if (!isCurrent()) {
81642
82480
  rejectUpgrade(socket, 410);
81643
82481
  return;
@@ -81656,12 +82494,14 @@ function attachPaneStreamWebSocket(server, coordinator, redemptionPath = PANE_ST
81656
82494
  const cancelUnbound = () => decision.admission.cancelBeforeBind();
81657
82495
  socket.once("close", cancelUnbound);
81658
82496
  socket.once("error", cancelUnbound);
82497
+ if (redeemFrame) redeemed.add(request3);
81659
82498
  try {
81660
82499
  wss.handleUpgrade(request3, socket, head3, (ws) => {
81661
82500
  socket.off("close", cancelUnbound);
81662
82501
  socket.off("error", cancelUnbound);
81663
82502
  heartbeat.watch(ws, `pane-stream ${redemptionPath}`);
81664
82503
  decision.admission.bind(ws);
82504
+ if (redeemFrame) decision.admission.redeemFromUpgrade(redeemFrame);
81665
82505
  });
81666
82506
  } catch {
81667
82507
  socket.off("close", cancelUnbound);
@@ -81679,12 +82519,14 @@ function attachPaneStreamWebSocket(server, coordinator, redemptionPath = PANE_ST
81679
82519
  }
81680
82520
  };
81681
82521
  }
82522
+ var PANE_STREAM_REDEEM_HEADER;
81682
82523
  var init_pane_stream_upgrade = __esm({
81683
82524
  "packages/daemon/src/server/pane-stream-upgrade.ts"() {
81684
82525
  "use strict";
81685
82526
  init_src2();
81686
82527
  init_websocket_heartbeat2();
81687
82528
  init_pane_stream_websocket();
82529
+ PANE_STREAM_REDEEM_HEADER = "x-tmux-ide-redeem";
81688
82530
  }
81689
82531
  });
81690
82532
 
@@ -82706,15 +83548,15 @@ async function readPortProcessFactsAsync(signal) {
82706
83548
  }
82707
83549
  function classifySessionInspectionError(error) {
82708
83550
  const candidate = error;
82709
- const message = candidate.message ?? "";
82710
- if (candidate.code === "EBADF" || candidate.code === "EAGAIN" || candidate.code === "EMFILE" || candidate.code === "ENFILE" || message.includes("EBADF") || message.includes("EAGAIN")) {
83551
+ const message2 = candidate.message ?? "";
83552
+ if (candidate.code === "EBADF" || candidate.code === "EAGAIN" || candidate.code === "EMFILE" || candidate.code === "ENFILE" || message2.includes("EBADF") || message2.includes("EAGAIN")) {
82711
83553
  return "unknown";
82712
83554
  }
82713
83555
  return "no";
82714
83556
  }
82715
83557
  function isConfirmedMissingTmuxTarget(error) {
82716
- const message = error instanceof Error ? error.message : String(error);
82717
- return /(?:can't find|no such|unknown) (?:pane|session|window|target)/iu.test(message);
83558
+ const message2 = error instanceof Error ? error.message : String(error);
83559
+ return /(?:can't find|no such|unknown) (?:pane|session|window|target)/iu.test(message2);
82718
83560
  }
82719
83561
  async function mapBounded(values2, concurrency, operation) {
82720
83562
  let cursor2 = 0;
@@ -82904,8 +83746,8 @@ var init_pty_bridge = __esm({
82904
83746
  cwd;
82905
83747
  reason;
82906
83748
  constructor(args) {
82907
- const message = _TerminalCwdError.formatMessage(args.cwd, args.reason);
82908
- super(message, args.cause !== void 0 ? { cause: args.cause } : void 0);
83749
+ const message2 = _TerminalCwdError.formatMessage(args.cwd, args.reason);
83750
+ super(message2, args.cause !== void 0 ? { cause: args.cause } : void 0);
82909
83751
  this.name = "TerminalCwdError";
82910
83752
  this.cwd = args.cwd;
82911
83753
  this.reason = args.reason;
@@ -83273,9 +84115,9 @@ function parseResizeFrame(data) {
83273
84115
  }
83274
84116
  return { type: "resize", cols: frame.cols, rows: frame.rows };
83275
84117
  }
83276
- function sendError(ws, message, extras) {
84118
+ function sendError(ws, message2, extras) {
83277
84119
  if (ws.readyState !== WS_OPEN4) return;
83278
- const frame = { type: "error", message };
84120
+ const frame = { type: "error", message: message2 };
83279
84121
  if (extras?.reason !== void 0) frame.reason = extras.reason;
83280
84122
  if (extras?.cwd !== void 0) frame.cwd = extras.cwd;
83281
84123
  ws.send(JSON.stringify(frame));
@@ -83343,8 +84185,8 @@ function handlePtyWebSocket(ws, id2, options = {}) {
83343
84185
  bridge.pause();
83344
84186
  scheduleDrainCheck();
83345
84187
  };
83346
- const closeWithError = (message) => {
83347
- sendError(socket, message);
84188
+ const closeWithError = (message2) => {
84189
+ sendError(socket, message2);
83348
84190
  closeWs(socket);
83349
84191
  };
83350
84192
  const closeWithCwdError = (err) => {
@@ -84998,8 +85840,8 @@ function acquireLegacyObservation() {
84998
85840
  function broadcastInitOutput(jobId, chunk, done) {
84999
85841
  for (const client of allClients) client.broadcastInitOutput(jobId, chunk, done);
85000
85842
  }
85001
- function broadcastInitError(jobId, message) {
85002
- for (const client of allClients) client.broadcastInitError(jobId, message);
85843
+ function broadcastInitError(jobId, message2) {
85844
+ for (const client of allClients) client.broadcastInitError(jobId, message2);
85003
85845
  }
85004
85846
  function broadcastActionComplete(name, result2) {
85005
85847
  for (const client of allClients) client.broadcastActionComplete(name, result2);
@@ -85085,9 +85927,9 @@ function handleWsEventsConnection(socket, daemonIdentity, options = {}) {
85085
85927
  const frame = done === void 0 ? { type: "init.output", jobId, chunk } : { type: "init.output", jobId, chunk, done };
85086
85928
  send2(frame);
85087
85929
  };
85088
- const broadcastInitErrorForClient = (jobId, message) => {
85930
+ const broadcastInitErrorForClient = (jobId, message2) => {
85089
85931
  if (!legacyDeliveryEnabled) return;
85090
- send2({ type: "init.error", jobId, message });
85932
+ send2({ type: "init.error", jobId, message: message2 });
85091
85933
  };
85092
85934
  const broadcastActionCompleteForClient = (name, result2) => {
85093
85935
  if (!legacyDeliveryEnabled) return;
@@ -85577,8 +86419,8 @@ function actionErrorFromCwdError(err) {
85577
86419
  function wrapInternalError(err) {
85578
86420
  if (err instanceof ActionError) return err;
85579
86421
  if (err instanceof TerminalCwdError) return actionErrorFromCwdError(err);
85580
- const message = err instanceof Error ? err.message : String(err);
85581
- return new ActionError({ code: "internal", message, cause: err });
86422
+ const message2 = err instanceof Error ? err.message : String(err);
86423
+ return new ActionError({ code: "internal", message: message2, cause: err });
85582
86424
  }
85583
86425
  var ActionError, CWD_REASON_TO_CODE;
85584
86426
  var init_errors3 = __esm({
@@ -86447,8 +87289,8 @@ var init_workspace_open_handoff2 = __esm({
86447
87289
  "use strict";
86448
87290
  WorkspaceOpenHandoffError = class extends Error {
86449
87291
  code;
86450
- constructor(code2, message) {
86451
- super(message);
87292
+ constructor(code2, message2) {
87293
+ super(message2);
86452
87294
  this.name = "WorkspaceOpenHandoffError";
86453
87295
  this.code = code2;
86454
87296
  }
@@ -87060,8 +87902,8 @@ function canonicalScene(scene) {
87060
87902
  focusedWindowId: scene.focusedWindowId
87061
87903
  };
87062
87904
  }
87063
- function diagnostic2(code2, path2, message) {
87064
- return { code: code2, path: path2, message };
87905
+ function diagnostic2(code2, path2, message2) {
87906
+ return { code: code2, path: path2, message: message2 };
87065
87907
  }
87066
87908
  function isRecord2(value) {
87067
87909
  return !!value && typeof value === "object" && !Array.isArray(value);
@@ -87582,9 +88424,9 @@ function sameScene(left, right) {
87582
88424
  focusedWindowId: right.focusedWindowId
87583
88425
  });
87584
88426
  }
87585
- function requireNonnegativeIndex(value, path2, message) {
88427
+ function requireNonnegativeIndex(value, path2, message2) {
87586
88428
  if (!Number.isInteger(value) || value < 0) {
87587
- throw new AppWindowKernelError("INVALID_INPUT", path2, message);
88429
+ throw new AppWindowKernelError("INVALID_INPUT", path2, message2);
87588
88430
  }
87589
88431
  }
87590
88432
  function boundedCoordinate(value, path2) {
@@ -87644,8 +88486,8 @@ function finalize(current, timestamp, patch) {
87644
88486
  }
87645
88487
  function translateStateError(error, path2) {
87646
88488
  if (error instanceof AppWindowKernelError) return error;
87647
- const message = error.message;
87648
- return new AppWindowKernelError("INVALID_INPUT", path2, message);
88489
+ const message2 = error.message;
88490
+ return new AppWindowKernelError("INVALID_INPUT", path2, message2);
87649
88491
  }
87650
88492
  var APP_WINDOW_FLOAT_MIN_WIDTH, APP_WINDOW_FLOAT_MIN_HEIGHT, APP_WINDOW_COORDINATE_LIMIT, AppWindowKernelError;
87651
88493
  var init_app_window_kernel = __esm({
@@ -87659,8 +88501,8 @@ var init_app_window_kernel = __esm({
87659
88501
  AppWindowKernelError = class extends Error {
87660
88502
  code;
87661
88503
  path;
87662
- constructor(code2, path2, message) {
87663
- super(message);
88504
+ constructor(code2, path2, message2) {
88505
+ super(message2);
87664
88506
  this.name = "AppWindowKernelError";
87665
88507
  this.code = code2;
87666
88508
  this.path = path2;
@@ -88032,8 +88874,8 @@ function validateExpectedRevision(value) {
88032
88874
  }
88033
88875
  return value;
88034
88876
  }
88035
- function diagnostic3(code2, path2, message) {
88036
- return { code: code2, path: path2, message };
88877
+ function diagnostic3(code2, path2, message2) {
88878
+ return { code: code2, path: path2, message: message2 };
88037
88879
  }
88038
88880
  var APP_WINDOW_DOCUMENT_PATH, LEGACY_WORKSPACE_UI_PATH, AppWindowRepositoryError, AppWindowService;
88039
88881
  var init_app_window_repository = __esm({
@@ -88049,8 +88891,8 @@ var init_app_window_repository = __esm({
88049
88891
  code;
88050
88892
  diagnostics;
88051
88893
  cause;
88052
- constructor(code2, message, diagnostics = [], cause) {
88053
- super(message);
88894
+ constructor(code2, message2, diagnostics = [], cause) {
88895
+ super(message2);
88054
88896
  this.name = "AppWindowRepositoryError";
88055
88897
  this.code = code2;
88056
88898
  this.diagnostics = diagnostics;
@@ -88556,10 +89398,10 @@ Content-Length: 0\r
88556
89398
  active3 = ws;
88557
89399
  const owner = new NativeSurfaceProviderChannel(
88558
89400
  registry,
88559
- (message) => {
88560
- if (!isCurrent() || ws.readyState !== WebSocket.OPEN || ws.bufferedAmount + Buffer.byteLength(message) > 64 * 1024)
89401
+ (message2) => {
89402
+ if (!isCurrent() || ws.readyState !== WebSocket.OPEN || ws.bufferedAmount + Buffer.byteLength(message2) > 64 * 1024)
88561
89403
  return false;
88562
- ws.send(message, (error) => {
89404
+ ws.send(message2, (error) => {
88563
89405
  if (error) owner.close();
88564
89406
  });
88565
89407
  return true;
@@ -89582,8 +90424,8 @@ import { spawn as nodeSpawn } from "node:child_process";
89582
90424
  import { existsSync as existsSync30, statSync as statSync25 } from "node:fs";
89583
90425
  import { isAbsolute as isAbsolute28 } from "node:path";
89584
90426
  import { z as z129 } from "zod";
89585
- function fail2(message) {
89586
- throw new ExecError(message);
90427
+ function fail2(message2) {
90428
+ throw new ExecError(message2);
89587
90429
  }
89588
90430
  async function prepareExec(raw, deps2) {
89589
90431
  const parsed = ExecRequestSchemaZ.safeParse(raw);
@@ -89876,8 +90718,8 @@ var init_plugin_store = __esm({
89876
90718
  import { spawn as spawn9 } from "node:child_process";
89877
90719
  import { homedir as homedir6 } from "node:os";
89878
90720
  import { z as z130 } from "zod";
89879
- function fail3(message) {
89880
- throw new WorktreeCallError(message);
90721
+ function fail3(message2) {
90722
+ throw new WorktreeCallError(message2);
89881
90723
  }
89882
90724
  async function worktreeCall(operation, raw, deps2) {
89883
90725
  if (!WORKTREE_OPERATIONS.includes(operation))
@@ -89922,8 +90764,8 @@ async function worktreeCall(operation, raw, deps2) {
89922
90764
  delete env.TMUX_PANE;
89923
90765
  const result2 = await deps2.runCli(args, env);
89924
90766
  if (result2.code !== 0) {
89925
- const message = (result2.stderr.trim() || result2.stdout.trim()).split("\n").slice(-3).join(" ");
89926
- fail3(`E_FAILED: ${message || `tmux-ide worktree ${op} failed`}`.slice(0, 2e3));
90767
+ const message2 = (result2.stderr.trim() || result2.stdout.trim()).split("\n").slice(-3).join(" ");
90768
+ fail3(`E_FAILED: ${message2 || `tmux-ide worktree ${op} failed`}`.slice(0, 2e3));
89927
90769
  }
89928
90770
  try {
89929
90771
  return JSON.parse(result2.stdout);
@@ -89992,8 +90834,8 @@ function daemonPort(endpoint) {
89992
90834
  return [];
89993
90835
  }
89994
90836
  }
89995
- function fail4(message) {
89996
- throw new HostCallError(message);
90837
+ function fail4(message2) {
90838
+ throw new HostCallError(message2);
89997
90839
  }
89998
90840
  function paneContextFromTmux(pane, line) {
89999
90841
  const [socket, pid, session, cwd] = line.replace(/\n$/u, "").split(" ");
@@ -90018,8 +90860,8 @@ function createHostCallHandler(deps2) {
90018
90860
  const body = await response3.json().catch(() => null);
90019
90861
  if (!response3.ok) {
90020
90862
  const error = body && typeof body === "object" && "error" in body ? body.error : null;
90021
- const message = typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : error && typeof error === "object" && "code" in error ? String(error.code) : `HTTP ${response3.status}`;
90022
- fail4(`E_FAILED: ${message}`);
90863
+ const message2 = typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : error && typeof error === "object" && "code" in error ? String(error.code) : `HTTP ${response3.status}`;
90864
+ fail4(`E_FAILED: ${message2}`);
90023
90865
  }
90024
90866
  return body;
90025
90867
  };
@@ -90896,13 +91738,13 @@ var init_supervisor = __esm({
90896
91738
  });
90897
91739
  }
90898
91740
  // ---------------------------------------------------------------- internals
90899
- #log(plugin, level, message, fields) {
91741
+ #log(plugin, level, message2, fields) {
90900
91742
  const secrets2 = this.#secretSet();
90901
91743
  this.#options.onLog({
90902
91744
  ts: new Date(this.#options.now()).toISOString(),
90903
91745
  plugin,
90904
91746
  level,
90905
- message: redactText(message, secrets2),
91747
+ message: redactText(message2, secrets2),
90906
91748
  ...fields ? { fields: redactLogValue(fields, secrets2) } : {}
90907
91749
  });
90908
91750
  }
@@ -91251,11 +92093,11 @@ import { basename as basename19, dirname as dirname40, extname as extname3, join
91251
92093
  import { fileURLToPath as fileURLToPath10 } from "node:url";
91252
92094
  async function notifyTmuxClients(tmux8, plugin, text2, level) {
91253
92095
  const prefix = level === "info" ? "" : `${level}: `;
91254
- const message = `${plugin}: ${prefix}${text2}`.replace(/#/gu, "##");
92096
+ const message2 = `${plugin}: ${prefix}${text2}`.replace(/#/gu, "##");
91255
92097
  const clients = (await tmux8(["list-clients", "-F", "#{client_name}"])).split("\n").map((line) => line.trim()).filter(Boolean);
91256
92098
  await Promise.all(
91257
92099
  clients.map(
91258
- (client) => tmux8(["display-message", "-c", client, "-d", "4000", message]).catch(() => "")
92100
+ (client) => tmux8(["display-message", "-c", client, "-d", "4000", message2]).catch(() => "")
91259
92101
  )
91260
92102
  );
91261
92103
  }
@@ -92354,6 +93196,41 @@ var init_pane_stream_issue = __esm({
92354
93196
  }
92355
93197
  });
92356
93198
 
93199
+ // packages/daemon/src/command-center/tmux-server-attach.ts
93200
+ import { z as z136 } from "zod";
93201
+ function chooseAttachSelection(inventory, preferredPane, maxPanes) {
93202
+ const panes = inventory.semanticPaneIds;
93203
+ if (panes.length === 0) return null;
93204
+ let semanticWindowId = null;
93205
+ let chosen = panes;
93206
+ if (panes.length > maxPanes) {
93207
+ const fits = (window3) => window3 !== void 0 && window3.semanticPaneIds.length <= maxPanes;
93208
+ const active3 = inventory.windows.find((window3) => window3.active);
93209
+ const wanted = (preferredPane !== null ? inventory.windows.find((window3) => window3.semanticPaneIds.includes(preferredPane)) : void 0) ?? active3;
93210
+ const window2 = [wanted, active3].find(fits) ?? inventory.windows.find(fits);
93211
+ if (!window2) return null;
93212
+ semanticWindowId = window2.semanticWindowId;
93213
+ chosen = window2.semanticPaneIds;
93214
+ }
93215
+ const selectedPane = preferredPane !== null && chosen.includes(preferredPane) ? preferredPane : chosen[0];
93216
+ return { semanticWindowId, panes: chosen, selectedPane };
93217
+ }
93218
+ var TmuxServerAttachRequestSchemaZ;
93219
+ var init_tmux_server_attach = __esm({
93220
+ "packages/daemon/src/command-center/tmux-server-attach.ts"() {
93221
+ "use strict";
93222
+ TmuxServerAttachRequestSchemaZ = z136.object({
93223
+ version: z136.literal(1),
93224
+ preferredPane: z136.string().min(1).max(128).nullable(),
93225
+ maxPanes: z136.number().int().min(1).max(256),
93226
+ issue: z136.object({
93227
+ expectedDaemonInstanceId: z136.uuid(),
93228
+ stream: z136.record(z136.string(), z136.unknown())
93229
+ }).catchall(z136.unknown())
93230
+ }).strict();
93231
+ }
93232
+ });
93233
+
92357
93234
  // packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts
92358
93235
  function projectTerminalRuntimeInventory(session, resourceRevision) {
92359
93236
  const shell = projectApplicationShellResource(session);
@@ -92371,6 +93248,37 @@ function projectTerminalRuntimeInventory(session, resourceRevision) {
92371
93248
  ].sort()
92372
93249
  });
92373
93250
  }
93251
+ function projectTerminalRuntimeInventoryV2(session, resourceRevision) {
93252
+ const identities = paneIdentities(session);
93253
+ const windows = /* @__PURE__ */ new Map();
93254
+ session.panes.forEach((pane, index) => {
93255
+ if (pane.windowId === void 0) return;
93256
+ const stamp = pane.windowStamp ?? null;
93257
+ const entry = windows.get(pane.windowId) ?? {
93258
+ semanticWindowId: stamp,
93259
+ active: false,
93260
+ panes: [],
93261
+ complete: true
93262
+ };
93263
+ windows.set(pane.windowId, entry);
93264
+ const attachability = identities[index].attachability;
93265
+ if (attachability.status === "available") entry.panes.push(attachability.semanticPaneId);
93266
+ else entry.complete = false;
93267
+ if (pane.active) entry.active = true;
93268
+ });
93269
+ return TerminalRuntimeInventoryProjectionV2SchemaZ.parse({
93270
+ ...projectTerminalRuntimeInventory(session, resourceRevision),
93271
+ windows: [...windows.values()].flatMap(
93272
+ (window2) => window2.complete && window2.semanticWindowId !== null && window2.panes.length > 0 ? [
93273
+ {
93274
+ semanticWindowId: window2.semanticWindowId,
93275
+ active: window2.active,
93276
+ semanticPaneIds: [...window2.panes].sort()
93277
+ }
93278
+ ] : []
93279
+ )
93280
+ });
93281
+ }
92374
93282
  function terminalRuntimeInventoryEnvelope(daemon, session, resourceRevision) {
92375
93283
  return {
92376
93284
  version: TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION,
@@ -92389,7 +93297,7 @@ var init_terminal_runtime_inventory2 = __esm({
92389
93297
  // packages/daemon/src/command-center/tmux-servers.ts
92390
93298
  import { Hono as Hono2 } from "hono";
92391
93299
  import { streamSSE as streamSSE2 } from "hono/streaming";
92392
- import { z as z136 } from "zod";
93300
+ import { z as z137 } from "zod";
92393
93301
  async function boundedJson2(request3, limit = 64 * 1024) {
92394
93302
  if (!request3.body) throw new TypeError("Missing body");
92395
93303
  const reader = request3.body.getReader();
@@ -92429,7 +93337,7 @@ function failure(c, error) {
92429
93337
  return c.json({ error: { code: "harness_unavailable" } }, 409);
92430
93338
  if (error instanceof WorkspaceMultiplexerError)
92431
93339
  return c.json({ error: { code: error.code } }, 409);
92432
- if (error instanceof z136.ZodError || error instanceof SyntaxError || error instanceof TypeError)
93340
+ if (error instanceof z137.ZodError || error instanceof SyntaxError || error instanceof TypeError)
92433
93341
  return c.json({ error: { code: "invalid-request" } }, 400);
92434
93342
  const code2 = error?.code;
92435
93343
  logger.warn("tmux-server-routes", "request failed as server-unavailable", {
@@ -92569,9 +93477,9 @@ function mountTmuxServerRoutes(app, options) {
92569
93477
  `${scoped}/sessions/create`,
92570
93478
  route(async (c) => {
92571
93479
  const server = scope2(c);
92572
- const request3 = z136.object({
92573
- operationId: z136.uuid(),
92574
- expectedDaemonInstanceId: z136.uuid(),
93480
+ const request3 = z137.object({
93481
+ operationId: z137.uuid(),
93482
+ expectedDaemonInstanceId: z137.uuid(),
92575
93483
  intent: WorkspaceSessionCreateArgumentsSchemaZ
92576
93484
  }).strict().parse(await boundedJson2(c.req.raw));
92577
93485
  if (request3.expectedDaemonInstanceId !== server.generation || request3.intent.expectedDaemonInstanceId && request3.intent.expectedDaemonInstanceId !== server.generation)
@@ -92617,11 +93525,83 @@ function mountTmuxServerRoutes(app, options) {
92617
93525
  return c.json({ version: 1, server, ...result2 });
92618
93526
  })
92619
93527
  );
93528
+ app.post(
93529
+ `${scoped}/sessions/:liveSessionId/attach`,
93530
+ route(async (c) => {
93531
+ const server = scope2(c);
93532
+ const liveSessionId = workspaceSchema.parse(c.req.param("liveSessionId"));
93533
+ const request3 = TmuxServerAttachRequestSchemaZ.parse(await boundedJson2(c.req.raw));
93534
+ if (request3.issue.expectedDaemonInstanceId !== server.generation || c.req.header("X-Tmux-Ide-Expected-Daemon-Instance-Id") !== server.generation)
93535
+ throw new TmuxServerScopeError("stale-generation");
93536
+ const result2 = await options.owners.withOwner(server, async (owner) => {
93537
+ const opened = await owner.openSession(liveSessionId);
93538
+ const workspace = owner.workspaceRegistry.get(opened.workspaceName);
93539
+ if (!workspace || opened.liveSessionId !== liveSessionId)
93540
+ throw new TmuxServerScopeError("stale-generation");
93541
+ const snapshot3 = await owner.terminalInventoryRuntime.discoverTerminalRuntimeSession(
93542
+ workspace.sessionName,
93543
+ c.req.raw.signal
93544
+ );
93545
+ if (!snapshot3) return null;
93546
+ const inventory = projectTerminalRuntimeInventoryV2(snapshot3, 0);
93547
+ const selection = chooseAttachSelection(inventory, request3.preferredPane, request3.maxPanes);
93548
+ if (!selection)
93549
+ return { kind: "attached", opened, inventory, selection, issue: null };
93550
+ const stream = { ...request3.issue.stream };
93551
+ delete stream.semanticWindowId;
93552
+ const body = {
93553
+ ...request3.issue,
93554
+ stream: {
93555
+ ...stream,
93556
+ workspaceName: opened.workspaceName,
93557
+ panes: selection.panes,
93558
+ ...selection.semanticWindowId ? { semanticWindowId: selection.semanticWindowId } : {}
93559
+ }
93560
+ };
93561
+ const issueApp = new Hono2();
93562
+ mountPaneStreamIssueRoute(issueApp, {
93563
+ daemonInstanceId: server.generation,
93564
+ ownerToken: options.ownerToken,
93565
+ workspaceRegistry: owner.workspaceRegistry,
93566
+ backend: owner.paneStreamRuntime.coordinator
93567
+ });
93568
+ const url = new URL(c.req.url);
93569
+ url.pathname = PANE_STREAM_ISSUE_PATH;
93570
+ url.search = "";
93571
+ const headers2 = new Headers(c.req.raw.headers);
93572
+ headers2.delete("Content-Length");
93573
+ headers2.set("Content-Type", "application/json");
93574
+ const issued = await issueApp.request(
93575
+ new Request(url, { method: "POST", headers: headers2, body: JSON.stringify(body) })
93576
+ );
93577
+ if (issued.status !== 200) return { kind: "refused", refused: issued };
93578
+ return {
93579
+ kind: "attached",
93580
+ opened,
93581
+ inventory,
93582
+ selection,
93583
+ issue: await issued.json()
93584
+ };
93585
+ });
93586
+ if (!result2) return c.json({ error: { code: "workspace-not-found" } }, 404);
93587
+ if (result2.kind === "refused") return result2.refused;
93588
+ return c.json({
93589
+ version: 1,
93590
+ server,
93591
+ workspaceName: result2.opened.workspaceName,
93592
+ liveSessionId,
93593
+ inventory: result2.inventory,
93594
+ selection: result2.selection,
93595
+ issue: result2.issue
93596
+ });
93597
+ })
93598
+ );
92620
93599
  app.get(
92621
93600
  `${scoped}/sessions`,
92622
93601
  route(async (c) => {
92623
93602
  const server = scope2(c);
92624
- const v2 = c.req.query("version") === "2";
93603
+ const v3 = c.req.query("version") === "3";
93604
+ const v2 = v3 || c.req.query("version") === "2";
92625
93605
  const { rows, favicons } = await options.owners.withOwner(server, async (owner) => {
92626
93606
  const sessions = await owner.catalog();
92627
93607
  const workspaces = owner.workspaceRegistry.list();
@@ -92652,9 +93632,10 @@ function mountTmuxServerRoutes(app, options) {
92652
93632
  })
92653
93633
  );
92654
93634
  let budget2 = SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES;
93635
+ const schema = v3 ? TmuxServerSessionsResourceV3SchemaZ : TmuxServerSessionsResourceV2SchemaZ;
92655
93636
  return c.json(
92656
- TmuxServerSessionsResourceV2SchemaZ.parse({
92657
- version: 2,
93637
+ schema.parse({
93638
+ version: v3 ? 3 : 2,
92658
93639
  server,
92659
93640
  sessions: rows.map(({ session, workspaceName }, index) => {
92660
93641
  const found = favicons[index] ?? null;
@@ -92666,6 +93647,7 @@ function mountTmuxServerRoutes(app, options) {
92666
93647
  workspaceName,
92667
93648
  paneCount: session.paneCount,
92668
93649
  windowCount: session.windowCount,
93650
+ ...v3 ? { largestWindowPaneCount: session.largestWindowPaneCount } : {},
92669
93651
  lastActivity: session.lastActivity,
92670
93652
  favicon: favicon ? { mime: favicon.mime, data: favicon.data } : null
92671
93653
  };
@@ -92693,6 +93675,7 @@ function mountTmuxServerRoutes(app, options) {
92693
93675
  route(async (c) => {
92694
93676
  const server = scope2(c);
92695
93677
  const workspaceName = workspaceSchema.parse(c.req.param("workspaceName"));
93678
+ const v2 = c.req.query("version") === "2";
92696
93679
  const resource3 = await options.owners.withOwner(server, async (owner) => {
92697
93680
  const sessions = await owner.catalog();
92698
93681
  const workspace = owner.workspaceRegistry.get(workspaceName);
@@ -92706,9 +93689,10 @@ function mountTmuxServerRoutes(app, options) {
92706
93689
  workspace.sessionName,
92707
93690
  c.req.raw.signal
92708
93691
  );
92709
- return snapshot3 ? projectTerminalRuntimeInventory(snapshot3, 0) : null;
93692
+ if (!snapshot3) return null;
93693
+ return v2 ? projectTerminalRuntimeInventoryV2(snapshot3, 0) : projectTerminalRuntimeInventory(snapshot3, 0);
92710
93694
  });
92711
- return resource3 ? c.json({ version: 1, server, resource: resource3 }) : c.json({ error: { code: "workspace-not-found" } }, 404);
93695
+ return resource3 ? c.json({ version: v2 ? 2 : 1, server, resource: resource3 }) : c.json({ error: { code: "workspace-not-found" } }, 404);
92712
93696
  })
92713
93697
  );
92714
93698
  app.get(
@@ -92956,10 +93940,11 @@ var init_tmux_servers = __esm({
92956
93940
  init_owner_authority();
92957
93941
  init_log();
92958
93942
  init_pane_stream_issue();
93943
+ init_tmux_server_attach();
92959
93944
  init_terminal_runtime_inventory2();
92960
93945
  SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES = 512 * 1024;
92961
93946
  registrationSchema = TmuxServerRegistrationSchemaZ.omit({ serverId: true }).strict();
92962
- workspaceSchema = z136.string().min(1).max(160).refine((value) => !/[\0\r\n]/u.test(value));
93947
+ workspaceSchema = z137.string().min(1).max(160).refine((value) => !/[\0\r\n]/u.test(value));
92963
93948
  }
92964
93949
  });
92965
93950
 
@@ -93234,7 +94219,7 @@ var init_saved_machines3 = __esm({
93234
94219
 
93235
94220
  // packages/daemon/src/command-center/resources/saved-machine-watch.ts
93236
94221
  import { createHash as createHash29 } from "node:crypto";
93237
- import { z as z137 } from "zod";
94222
+ import { z as z138 } from "zod";
93238
94223
  function snapshot2(value) {
93239
94224
  const registry = SavedMachineRegistrySchema.parse(value);
93240
94225
  return {
@@ -93340,16 +94325,16 @@ var init_saved_machine_watch = __esm({
93340
94325
  init_owner_authority();
93341
94326
  SAVED_MACHINE_WATCH_WAIT_MS = 2e4;
93342
94327
  MAX_WATCHERS = 32;
93343
- Query = z137.strictObject({
93344
- expectedInstanceId: z137.uuid(),
93345
- after: z137.string().regex(/^[a-f0-9]{64}$/u).optional()
94328
+ Query = z138.strictObject({
94329
+ expectedInstanceId: z138.uuid(),
94330
+ after: z138.string().regex(/^[a-f0-9]{64}$/u).optional()
93346
94331
  });
93347
94332
  }
93348
94333
  });
93349
94334
 
93350
94335
  // packages/daemon/src/command-center/resources/saved-machine-route.ts
93351
94336
  import { bodyLimit as bodyLimit2 } from "hono/body-limit";
93352
- import { z as z138 } from "zod";
94337
+ import { z as z139 } from "zod";
93353
94338
  function mountSavedMachineRoute(app, options) {
93354
94339
  mountSavedMachineWatch(app, options);
93355
94340
  const authorize = ownerAuthorityGate(options.ownerToken, {
@@ -93432,12 +94417,12 @@ var init_saved_machine_route = __esm({
93432
94417
  init_saved_machines();
93433
94418
  init_saved_machines3();
93434
94419
  init_owner_authority();
93435
- Request2 = z138.strictObject({
93436
- expectedInstanceId: z138.uuid(),
94420
+ Request2 = z139.strictObject({
94421
+ expectedInstanceId: z139.uuid(),
93437
94422
  registry: SavedMachineRegistrySchema
93438
94423
  });
93439
- MutationRequest = z138.strictObject({
93440
- expectedInstanceId: z138.uuid(),
94424
+ MutationRequest = z139.strictObject({
94425
+ expectedInstanceId: z139.uuid(),
93441
94426
  change: SavedMachineMutationSchema
93442
94427
  });
93443
94428
  }
@@ -93614,74 +94599,74 @@ var init_semantic_multiplexer_actions = __esm({
93614
94599
  });
93615
94600
 
93616
94601
  // packages/daemon/src/command-center/schemas.ts
93617
- import { z as z139 } from "zod";
94602
+ import { z as z140 } from "zod";
93618
94603
  var updateTaskSchema, createTaskSchema, savePlanSchema, savePlanContentSchema, sendCommandSchema, createMilestoneSchema, updateMilestoneSchema, updateAssertionSchema, triggerResearchSchema, launchSchema, stopSchema, skillNameRegex, createSkillSchema, updateSkillSchema;
93619
94604
  var init_schemas = __esm({
93620
94605
  "packages/daemon/src/command-center/schemas.ts"() {
93621
94606
  "use strict";
93622
- updateTaskSchema = z139.object({
93623
- status: z139.enum(["todo", "in-progress", "review", "done"]).optional(),
93624
- assignee: z139.string().optional(),
93625
- title: z139.string().optional(),
93626
- description: z139.string().optional(),
93627
- priority: z139.number().optional()
94607
+ updateTaskSchema = z140.object({
94608
+ status: z140.enum(["todo", "in-progress", "review", "done"]).optional(),
94609
+ assignee: z140.string().optional(),
94610
+ title: z140.string().optional(),
94611
+ description: z140.string().optional(),
94612
+ priority: z140.number().optional()
93628
94613
  });
93629
- createTaskSchema = z139.object({
93630
- title: z139.string().trim().min(1, "Title is required"),
93631
- description: z139.string().optional(),
93632
- priority: z139.number().optional(),
93633
- goal: z139.string().optional(),
93634
- tags: z139.array(z139.string()).optional()
94614
+ createTaskSchema = z140.object({
94615
+ title: z140.string().trim().min(1, "Title is required"),
94616
+ description: z140.string().optional(),
94617
+ priority: z140.number().optional(),
94618
+ goal: z140.string().optional(),
94619
+ tags: z140.array(z140.string()).optional()
93635
94620
  });
93636
- savePlanSchema = z139.object({
93637
- content: z139.string().max(1e6, "Plan content is too large")
94621
+ savePlanSchema = z140.object({
94622
+ content: z140.string().max(1e6, "Plan content is too large")
93638
94623
  });
93639
- savePlanContentSchema = z139.object({
93640
- content: z139.string().max(1e6, "Plan content is too large")
94624
+ savePlanContentSchema = z140.object({
94625
+ content: z140.string().max(1e6, "Plan content is too large")
93641
94626
  });
93642
- sendCommandSchema = z139.object({
93643
- target: z139.string().min(1, "Target pane is required"),
93644
- message: z139.string().min(1, "Message is required"),
93645
- noEnter: z139.boolean().optional()
94627
+ sendCommandSchema = z140.object({
94628
+ target: z140.string().min(1, "Target pane is required"),
94629
+ message: z140.string().min(1, "Message is required"),
94630
+ noEnter: z140.boolean().optional()
93646
94631
  });
93647
- createMilestoneSchema = z139.object({
93648
- title: z139.string().trim().min(1, "Title is required"),
93649
- sequence: z139.number().int().positive(),
93650
- description: z139.string().optional()
94632
+ createMilestoneSchema = z140.object({
94633
+ title: z140.string().trim().min(1, "Title is required"),
94634
+ sequence: z140.number().int().positive(),
94635
+ description: z140.string().optional()
93651
94636
  });
93652
- updateMilestoneSchema = z139.object({
93653
- status: z139.enum(["locked", "active", "done", "validating"]).optional(),
93654
- title: z139.string().optional(),
93655
- description: z139.string().optional()
94637
+ updateMilestoneSchema = z140.object({
94638
+ status: z140.enum(["locked", "active", "done", "validating"]).optional(),
94639
+ title: z140.string().optional(),
94640
+ description: z140.string().optional()
93656
94641
  });
93657
- updateAssertionSchema = z139.object({
93658
- status: z139.enum(["pending", "passing", "failing", "blocked"]),
93659
- evidence: z139.string().optional(),
93660
- verifiedBy: z139.string().optional()
94642
+ updateAssertionSchema = z140.object({
94643
+ status: z140.enum(["pending", "passing", "failing", "blocked"]),
94644
+ evidence: z140.string().optional(),
94645
+ verifiedBy: z140.string().optional()
93661
94646
  });
93662
- triggerResearchSchema = z139.object({
93663
- type: z139.string().trim().min(1, "Research type is required")
94647
+ triggerResearchSchema = z140.object({
94648
+ type: z140.string().trim().min(1, "Research type is required")
93664
94649
  });
93665
- launchSchema = z139.object({
93666
- attach: z139.boolean().optional()
94650
+ launchSchema = z140.object({
94651
+ attach: z140.boolean().optional()
93667
94652
  }).optional();
93668
- stopSchema = z139.object({}).optional();
94653
+ stopSchema = z140.object({}).optional();
93669
94654
  skillNameRegex = /^[A-Za-z0-9._ -]+$/;
93670
- createSkillSchema = z139.object({
93671
- name: z139.string().trim().min(1, "Skill name is required").regex(
94655
+ createSkillSchema = z140.object({
94656
+ name: z140.string().trim().min(1, "Skill name is required").regex(
93672
94657
  skillNameRegex,
93673
94658
  "Skill name may only contain letters, digits, dot, dash, underscore, or space"
93674
94659
  ),
93675
- role: z139.string().trim().optional(),
93676
- description: z139.string().optional(),
93677
- specialties: z139.array(z139.string()).optional(),
93678
- body: z139.string().optional()
94660
+ role: z140.string().trim().optional(),
94661
+ description: z140.string().optional(),
94662
+ specialties: z140.array(z140.string()).optional(),
94663
+ body: z140.string().optional()
93679
94664
  });
93680
- updateSkillSchema = z139.object({
93681
- role: z139.string().trim().optional(),
93682
- description: z139.string().optional(),
93683
- specialties: z139.array(z139.string()).optional(),
93684
- body: z139.string().optional()
94665
+ updateSkillSchema = z140.object({
94666
+ role: z140.string().trim().optional(),
94667
+ description: z140.string().optional(),
94668
+ specialties: z140.array(z140.string()).optional(),
94669
+ body: z140.string().optional()
93685
94670
  });
93686
94671
  }
93687
94672
  });
@@ -95697,10 +96682,10 @@ async function mutateConfigAction(input, deps2, fn) {
95697
96682
  cause: err
95698
96683
  });
95699
96684
  }
95700
- const message = err.message ?? String(err);
96685
+ const message2 = err.message ?? String(err);
95701
96686
  throw new ActionError({
95702
- code: message.toLowerCase().includes("path") ? "config_path_invalid" : "config_validation_failed",
95703
- message,
96687
+ code: message2.toLowerCase().includes("path") ? "config_path_invalid" : "config_validation_failed",
96688
+ message: message2,
95704
96689
  cause: err
95705
96690
  });
95706
96691
  }
@@ -96895,64 +97880,64 @@ var init_project_init_runner = __esm({
96895
97880
  });
96896
97881
 
96897
97882
  // packages/daemon/src/schemas/inspect.ts
96898
- import { z as z140 } from "zod";
97883
+ import { z as z141 } from "zod";
96899
97884
  var ProjectInspectDetectedSchemaZ, ProjectInspectSchemaZ, InspectFilesystemRequestSchemaZ, OnboardProjectRequestSchemaZ;
96900
97885
  var init_inspect = __esm({
96901
97886
  "packages/daemon/src/schemas/inspect.ts"() {
96902
97887
  "use strict";
96903
- ProjectInspectDetectedSchemaZ = z140.object({
97888
+ ProjectInspectDetectedSchemaZ = z141.object({
96904
97889
  /** Detected package manager from lockfile, or `null`. */
96905
- packageManager: z140.enum(["pnpm", "npm", "yarn", "bun"]).nullable(),
97890
+ packageManager: z141.enum(["pnpm", "npm", "yarn", "bun"]).nullable(),
96906
97891
  /** Detected frameworks (e.g. `["next", "convex"]`). Empty array when none. */
96907
- frameworks: z140.array(z140.string()),
97892
+ frameworks: z141.array(z141.string()),
96908
97893
  /** Suggested dev command (e.g. `pnpm dev`). `null` if no dev script found. */
96909
- devCommand: z140.string().nullable(),
97894
+ devCommand: z141.string().nullable(),
96910
97895
  /** Suggested test command (e.g. `pnpm test`). `null` if no test script found. */
96911
- testCommand: z140.string().nullable()
97896
+ testCommand: z141.string().nullable()
96912
97897
  });
96913
- ProjectInspectSchemaZ = z140.object({
97898
+ ProjectInspectSchemaZ = z141.object({
96914
97899
  /** Sanitized basename of the directory — safe to use as a tmux session name. */
96915
- name: z140.string(),
97900
+ name: z141.string(),
96916
97901
  /** Absolute, canonical path to the directory. */
96917
- dir: z140.string(),
97902
+ dir: z141.string(),
96918
97903
  /** Whether `<dir>/ide.yml` exists. Legacy compatibility fact. */
96919
- hasIdeYml: z140.boolean(),
97904
+ hasIdeYml: z141.boolean(),
96920
97905
  /** Whether `.tmux-ide/workspace.yml` exists or wins discovery. */
96921
- hasWorkspaceConfig: z140.boolean().optional(),
97906
+ hasWorkspaceConfig: z141.boolean().optional(),
96922
97907
  /** Generalized winning config kind. Added without replacing `hasIdeYml`. */
96923
- configKind: z140.enum(["workspace", "legacy", "none"]).optional(),
97908
+ configKind: z141.enum(["workspace", "legacy", "none"]).optional(),
96924
97909
  /** Generalized winning config path. Added without replacing legacy path facts. */
96925
- configPath: z140.string().nullable().optional(),
97910
+ configPath: z141.string().nullable().optional(),
96926
97911
  /** Legacy config path when an `ide.yml` is present. */
96927
- ideConfigPath: z140.string().nullable().optional(),
97912
+ ideConfigPath: z141.string().nullable().optional(),
96928
97913
  /** Git remote origin URL, or `null` if not a git repo / no origin / probe failed. */
96929
- gitOrigin: z140.string().nullable(),
97914
+ gitOrigin: z141.string().nullable(),
96930
97915
  /** Current git branch, or `null` if not a git repo / detached HEAD / probe failed. */
96931
- gitBranch: z140.string().nullable(),
97916
+ gitBranch: z141.string().nullable(),
96932
97917
  /** Detected stack signals (reuses `tmux-ide detect` logic). */
96933
97918
  detected: ProjectInspectDetectedSchemaZ
96934
97919
  });
96935
- InspectFilesystemRequestSchemaZ = z140.object({
96936
- dir: z140.string().min(1)
97920
+ InspectFilesystemRequestSchemaZ = z141.object({
97921
+ dir: z141.string().min(1)
96937
97922
  });
96938
- OnboardProjectRequestSchemaZ = z140.object({
96939
- dir: z140.string().min(1),
97923
+ OnboardProjectRequestSchemaZ = z141.object({
97924
+ dir: z141.string().min(1),
96940
97925
  /** Optional override for the project name — defaults to inspect.name. */
96941
- name: z140.string().min(1).optional(),
97926
+ name: z141.string().min(1).optional(),
96942
97927
  /** 1, 2, or 3 — how many Claude panes to scaffold in the top row. */
96943
- agents: z140.number().int().min(1).max(3),
97928
+ agents: z141.number().int().min(1).max(3),
96944
97929
  /**
96945
97930
  * Optional per-agent pane titles. When provided, length must equal
96946
97931
  * `agents`; the server uses these as `title:` for the Claude panes
96947
97932
  * instead of the canonical `Lead`/`Teammate N`/`Claude N` defaults.
96948
97933
  */
96949
- agentNames: z140.array(z140.string().min(1)).optional(),
97934
+ agentNames: z141.array(z141.string().min(1)).optional(),
96950
97935
  /** Dev server command (e.g. `pnpm dev`). Omit / null to skip the dev pane. */
96951
- devCommand: z140.string().min(1).nullable().optional(),
97936
+ devCommand: z141.string().min(1).nullable().optional(),
96952
97937
  /** Test command (e.g. `pnpm test`). Currently informational; stored for later. */
96953
- testCommand: z140.string().min(1).nullable().optional(),
97938
+ testCommand: z141.string().min(1).nullable().optional(),
96954
97939
  /** Lint command (e.g. `pnpm lint`). Currently informational; stored for later. */
96955
- lintCommand: z140.string().min(1).nullable().optional()
97940
+ lintCommand: z141.string().min(1).nullable().optional()
96956
97941
  });
96957
97942
  }
96958
97943
  });
@@ -97334,8 +98319,8 @@ var init_project_onboard = __esm({
97334
98319
  };
97335
98320
  OnboardInvalidInputError = class extends Error {
97336
98321
  code = "INVALID_INPUT";
97337
- constructor(message) {
97338
- super(message);
98322
+ constructor(message2) {
98323
+ super(message2);
97339
98324
  this.name = "OnboardInvalidInputError";
97340
98325
  }
97341
98326
  };
@@ -97839,23 +98824,23 @@ var init_workspace_files_authority = __esm({
97839
98824
  const parentRel = segments.join("/");
97840
98825
  return parentRel === "" ? rootId : this.ids.intern(parentRel);
97841
98826
  }
97842
- catalogUnavailable(reason, message, retryable = false) {
98827
+ catalogUnavailable(reason, message2, retryable = false) {
97843
98828
  return WorkspaceFilesCatalogResourceV1SchemaZ.parse({
97844
98829
  status: "unavailable",
97845
98830
  workspaceName: this.workspaceName,
97846
98831
  reason,
97847
- message,
98832
+ message: message2,
97848
98833
  retryable
97849
98834
  });
97850
98835
  }
97851
- previewUnavailable(fileId, reason, message, retryable = false) {
98836
+ previewUnavailable(fileId, reason, message2, retryable = false) {
97852
98837
  return WorkspaceFilePreviewResourceV1SchemaZ.parse({
97853
98838
  status: "unavailable",
97854
98839
  workspaceName: this.workspaceName,
97855
98840
  catalogRevision: filesRevision(`unavailable:${fileId}`),
97856
98841
  fileId,
97857
98842
  reason,
97858
- message,
98843
+ message: message2,
97859
98844
  retryable
97860
98845
  });
97861
98846
  }
@@ -98482,23 +99467,23 @@ var init_workspace_changes_authority = __esm({
98482
99467
  const source = raw.group === "staged" ? staged : unstaged;
98483
99468
  return source.get(raw.path) ?? { additions: 0, deletions: 0, binary: false };
98484
99469
  }
98485
- catalogUnavailable(reason, message, retryable = false) {
99470
+ catalogUnavailable(reason, message2, retryable = false) {
98486
99471
  return WorkspaceChangesCatalogResourceV1SchemaZ.parse({
98487
99472
  status: "unavailable",
98488
99473
  workspaceName: this.workspaceName,
98489
99474
  reason,
98490
- message,
99475
+ message: message2,
98491
99476
  retryable
98492
99477
  });
98493
99478
  }
98494
- diffUnavailable(changeId, reason, message, retryable = false) {
99479
+ diffUnavailable(changeId, reason, message2, retryable = false) {
98495
99480
  return WorkspaceChangeDiffResourceV1SchemaZ.parse({
98496
99481
  status: "unavailable",
98497
99482
  workspaceName: this.workspaceName,
98498
99483
  changesRevision: changesRevision(`unavailable:${changeId}`),
98499
99484
  changeId,
98500
99485
  reason,
98501
- message,
99486
+ message: message2,
98502
99487
  retryable
98503
99488
  });
98504
99489
  }
@@ -98770,7 +99755,7 @@ var init_application_shell_app_windows = __esm({
98770
99755
 
98771
99756
  // packages/daemon/src/command-center/plugin-routes.ts
98772
99757
  import { bodyLimit as bodyLimit3 } from "hono/body-limit";
98773
- import { z as z141 } from "zod";
99758
+ import { z as z142 } from "zod";
98774
99759
  function ownerOnlyNonBrowserGuard(ownerToken) {
98775
99760
  const authorize = ownerAuthorityGate(ownerToken, {
98776
99761
  whenOwnerless: "unavailable",
@@ -98834,11 +99819,11 @@ var init_plugin_routes = __esm({
98834
99819
  "packages/daemon/src/command-center/plugin-routes.ts"() {
98835
99820
  "use strict";
98836
99821
  init_owner_authority();
98837
- ReloadRequestZ = z141.strictObject({ name: z141.string().min(1).max(64).optional() });
98838
- RunRequestZ = z141.strictObject({
98839
- code: z141.string().max(1024 * 1024),
98840
- chunkName: z141.string().min(1).max(200).regex(/^[=@][^\0\n]*$/u).optional(),
98841
- budgetMs: z141.number().int().min(10).max(6e5).optional()
99822
+ ReloadRequestZ = z142.strictObject({ name: z142.string().min(1).max(64).optional() });
99823
+ RunRequestZ = z142.strictObject({
99824
+ code: z142.string().max(1024 * 1024),
99825
+ chunkName: z142.string().min(1).max(200).regex(/^[=@][^\0\n]*$/u).optional(),
99826
+ budgetMs: z142.number().int().min(10).max(6e5).optional()
98842
99827
  });
98843
99828
  }
98844
99829
  });
@@ -99413,8 +100398,8 @@ var init_mission_projections2 = __esm({
99413
100398
  init_mission_repository();
99414
100399
  MissionProjectionError = class extends IdeError {
99415
100400
  projectionCode;
99416
- constructor(message, code2, { cause } = {}) {
99417
- super(message, { code: code2, cause });
100401
+ constructor(message2, code2, { cause } = {}) {
100402
+ super(message2, { code: code2, cause });
99418
100403
  this.name = "MissionProjectionError";
99419
100404
  this.projectionCode = code2;
99420
100405
  }
@@ -100128,6 +101113,29 @@ var init_workspace_missions_route = __esm({
100128
101113
  }
100129
101114
  });
100130
101115
 
101116
+ // packages/daemon/src/command-center/owner-keep-alive.ts
101117
+ function ownerKeepAlive(ownerToken, timeoutMs = OWNER_KEEP_ALIVE_MS) {
101118
+ return async (c, next) => {
101119
+ const bindings = c.env;
101120
+ const outgoing = bindings?.outgoing;
101121
+ const socket = bindings?.incoming?.socket;
101122
+ if (outgoing && socket && ownerBearerMatches(c.req.header("Authorization"), ownerToken)) {
101123
+ outgoing.once("finish", () => {
101124
+ if (!socket.destroyed && outgoing.shouldKeepAlive) socket.setTimeout(timeoutMs);
101125
+ });
101126
+ }
101127
+ await next();
101128
+ };
101129
+ }
101130
+ var OWNER_KEEP_ALIVE_MS;
101131
+ var init_owner_keep_alive = __esm({
101132
+ "packages/daemon/src/command-center/owner-keep-alive.ts"() {
101133
+ "use strict";
101134
+ init_owner_authority();
101135
+ OWNER_KEEP_ALIVE_MS = 65e3;
101136
+ }
101137
+ });
101138
+
100131
101139
  // packages/daemon/src/command-center/diagnostics.ts
100132
101140
  import { performance as performance2 } from "node:perf_hooks";
100133
101141
  function sampleDaemonDiagnostics(daemon) {
@@ -100628,8 +101636,8 @@ var init_widget_asset_store = __esm({
100628
101636
  MAX_ASSET_FILES = 256;
100629
101637
  ASSET_DIRECTORY = "widget-assets";
100630
101638
  WidgetAssetStoreError = class extends Error {
100631
- constructor(code2, message) {
100632
- super(message);
101639
+ constructor(code2, message2) {
101640
+ super(message2);
100633
101641
  this.code = code2;
100634
101642
  this.name = "WidgetAssetStoreError";
100635
101643
  }
@@ -100655,7 +101663,7 @@ import { Hono as Hono3 } from "hono";
100655
101663
  import { streamSSE as streamSSE3 } from "hono/streaming";
100656
101664
  import { cors } from "hono/cors";
100657
101665
  import { zValidator } from "@hono/zod-validator";
100658
- import { z as z142 } from "zod";
101666
+ import { z as z143 } from "zod";
100659
101667
  import { realpathSync as realpathSync29 } from "node:fs";
100660
101668
  import { homedir as homedir9 } from "node:os";
100661
101669
  import { isAbsolute as isAbsolute34, resolve as pathResolve } from "node:path";
@@ -100705,7 +101713,7 @@ function requireHostCapability(ownerToken) {
100705
101713
  if (denied) return denied;
100706
101714
  markActionOwnerAuthorized(c);
100707
101715
  }
100708
- if (requirement === "owner-and-operation-id" && !z142.uuid().safeParse(c.req.header("X-Tmux-Ide-Operation-Id")).success) {
101716
+ if (requirement === "owner-and-operation-id" && !z143.uuid().safeParse(c.req.header("X-Tmux-Ide-Operation-Id")).success) {
100709
101717
  return c.json({ error: "A stable host operation id is required" }, 400);
100710
101718
  }
100711
101719
  return next();
@@ -100815,6 +101823,7 @@ function createApp(options = {}) {
100815
101823
  const healthBootedAt = Date.now();
100816
101824
  const app = new Hono3();
100817
101825
  app.use("/*", cors());
101826
+ app.use("/*", ownerKeepAlive(options.remoteAccess?.ownerToken ?? null));
100818
101827
  if (options.tmuxServerOwners) {
100819
101828
  mountAutomationRoutes(app, {
100820
101829
  ownerToken: options.remoteAccess?.ownerToken ?? null,
@@ -100907,7 +101916,7 @@ function createApp(options = {}) {
100907
101916
  } catch {
100908
101917
  return c.json({ error: "Invalid capability request" }, 400);
100909
101918
  }
100910
- if (!z142.object({}).strict().safeParse(body).success) {
101919
+ if (!z143.object({}).strict().safeParse(body).success) {
100911
101920
  return c.json({ error: "Invalid capability request" }, 400);
100912
101921
  }
100913
101922
  const appWindowCommandRegistered = daemonActionCommandRegistry.descriptors().some(({ id: id2 }) => id2 === "workspace.app-window.mutate");
@@ -101529,7 +102538,7 @@ function createApp(options = {}) {
101529
102538
  const name = c.req.param("name");
101530
102539
  const session = lookupSession(name);
101531
102540
  if (typeof session === "string") return sessionMissing(c, session);
101532
- const { target, message, noEnter } = c.req.valid("json");
102541
+ const { target, message: message2, noEnter } = c.req.valid("json");
101533
102542
  const panes = listSessionPanes(name);
101534
102543
  const pane = resolvePane(panes, target);
101535
102544
  if (!pane) {
@@ -101542,7 +102551,7 @@ function createApp(options = {}) {
101542
102551
  return c.json({ error: "Pane not found", target, available }, 404);
101543
102552
  }
101544
102553
  const busyStatus = getPaneBusyStatus(name, pane.id);
101545
- const prepared = busyStatus === "agent" ? message.replace(/\n+/g, " ").trim() : message;
102554
+ const prepared = busyStatus === "agent" ? message2.replace(/\n+/g, " ").trim() : message2;
101546
102555
  if (noEnter) {
101547
102556
  sendText(name, pane.id, prepared);
101548
102557
  } else {
@@ -101579,8 +102588,8 @@ function createApp(options = {}) {
101579
102588
  ideConfigPath: resolved2.resolution.legacyConfigPath
101580
102589
  });
101581
102590
  } catch (err) {
101582
- const message = err instanceof Error ? err.message : String(err);
101583
- return c.json({ error: "Failed to read workspace config", detail: message }, 500);
102591
+ const message2 = err instanceof Error ? err.message : String(err);
102592
+ return c.json({ error: "Failed to read workspace config", detail: message2 }, 500);
101584
102593
  }
101585
102594
  });
101586
102595
  app.post("/api/project/:name/config", async (c) => {
@@ -101611,8 +102620,8 @@ function createApp(options = {}) {
101611
102620
  ideConfigPath: resolved2.resolution.legacyConfigPath
101612
102621
  });
101613
102622
  } catch (err) {
101614
- const message = err instanceof Error ? err.message : String(err);
101615
- return c.json({ error: "Failed to write workspace config", detail: message }, 500);
102623
+ const message2 = err instanceof Error ? err.message : String(err);
102624
+ return c.json({ error: "Failed to write workspace config", detail: message2 }, 500);
101616
102625
  }
101617
102626
  });
101618
102627
  const execFileAsync2 = promisify4(execFile15);
@@ -101628,8 +102637,8 @@ function createApp(options = {}) {
101628
102637
  });
101629
102638
  return c.json({ ok: true, session: name, status: "restarted" });
101630
102639
  } catch (err) {
101631
- const message = err instanceof Error ? err.message : String(err);
101632
- return c.json({ error: "Restart failed", detail: message }, 500);
102640
+ const message2 = err instanceof Error ? err.message : String(err);
102641
+ return c.json({ error: "Restart failed", detail: message2 }, 500);
101633
102642
  }
101634
102643
  });
101635
102644
  app.post("/api/project/:name/launch", async (c) => {
@@ -101649,8 +102658,8 @@ function createApp(options = {}) {
101649
102658
  });
101650
102659
  return c.json({ ok: true, session: name, status: "launched" });
101651
102660
  } catch (err) {
101652
- const message = err instanceof Error ? err.message : String(err);
101653
- return c.json({ error: "Launch failed", detail: message }, 500);
102661
+ const message2 = err instanceof Error ? err.message : String(err);
102662
+ return c.json({ error: "Launch failed", detail: message2 }, 500);
101654
102663
  }
101655
102664
  });
101656
102665
  app.post("/api/project/:name/stop", async (c) => {
@@ -102025,6 +103034,7 @@ var init_server2 = __esm({
102025
103034
  init_fleet_resource_route();
102026
103035
  init_workspace_missions_route();
102027
103036
  init_owner_authority();
103037
+ init_owner_keep_alive();
102028
103038
  init_diagnostics();
102029
103039
  init_startup_readiness_route();
102030
103040
  init_widget_asset_store();
@@ -102326,11 +103336,11 @@ function takeoverTimeoutMs() {
102326
103336
  const override = globalThis[TAKEOVER_DEADLINE_TEST_OVERRIDE];
102327
103337
  return typeof override === "number" ? override : TAKEOVER_TIMEOUT_MS;
102328
103338
  }
102329
- function throwTakeoverTimeout(message) {
102330
- throw new DaemonStartupError(message, "canonical_takeover_timeout");
103339
+ function throwTakeoverTimeout(message2) {
103340
+ throw new DaemonStartupError(message2, "canonical_takeover_timeout");
102331
103341
  }
102332
- function assertTakeoverDeadline(deadline, message) {
102333
- if (deadline.signal.aborted || deadline.remainingMs() <= 0) throwTakeoverTimeout(message);
103342
+ function assertTakeoverDeadline(deadline, message2) {
103343
+ if (deadline.signal.aborted || deadline.remainingMs() <= 0) throwTakeoverTimeout(message2);
102334
103344
  }
102335
103345
  async function waitForTakeoverPoll(deadline) {
102336
103346
  assertTakeoverDeadline(deadline, "Canonical daemon did not quiesce before the takeover deadline");
@@ -105303,10 +106313,10 @@ async function openBrowser(url, options = {}, dependencies = {}) {
105303
106313
  url,
105304
106314
  options
105305
106315
  );
105306
- const message = await nativeControlsNotice(run, result2.pane, executable, dependencies.wait);
105307
- if (message)
106316
+ const message2 = await nativeControlsNotice(run, result2.pane, executable, dependencies.wait);
106317
+ if (message2)
105308
106318
  (dependencies.notice ?? ((line) => process.stderr.write(`${line}
105309
- `)))(message);
106319
+ `)))(message2);
105310
106320
  return result2;
105311
106321
  }
105312
106322
  function createPinnedBrowserPane(executable, url, options) {
@@ -105747,7 +106757,7 @@ import {
105747
106757
  import { randomUUID as randomUUID53 } from "node:crypto";
105748
106758
  import { dirname as dirname49, join as join65 } from "node:path";
105749
106759
  import { homedir as homedir11 } from "node:os";
105750
- import { z as z143 } from "zod";
106760
+ import { z as z144 } from "zod";
105751
106761
  function defaults() {
105752
106762
  const namespace = resolveRuntimeNamespace();
105753
106763
  return {
@@ -105769,8 +106779,8 @@ function defaults() {
105769
106779
  waitMs: 3e4
105770
106780
  };
105771
106781
  }
105772
- function refused(message) {
105773
- throw new IdeError(message, { code: "DAEMON_SERVICE_REFUSED" });
106782
+ function refused(message2) {
106783
+ throw new IdeError(message2, { code: "DAEMON_SERVICE_REFUSED" });
105774
106784
  }
105775
106785
  function ownedFile(path2) {
105776
106786
  let descriptor;
@@ -105957,11 +106967,11 @@ var init_daemon_service = __esm({
105957
106967
  init_runtime_namespace();
105958
106968
  init_errors2();
105959
106969
  init_private_operation_lock();
105960
- RecordSchema = z143.strictObject({
105961
- version: z143.literal(1),
105962
- removing: z143.boolean().optional(),
105963
- executable: z143.string().min(1),
105964
- contents: z143.string().min(1).max(64 * 1024)
106970
+ RecordSchema = z144.strictObject({
106971
+ version: z144.literal(1),
106972
+ removing: z144.boolean().optional(),
106973
+ executable: z144.string().min(1),
106974
+ contents: z144.string().min(1).max(64 * 1024)
105965
106975
  });
105966
106976
  }
105967
106977
  });
@@ -106105,7 +107115,7 @@ var init_restart_canonical_daemon = __esm({
106105
107115
  else signal.addEventListener("abort", abort, { once: true });
106106
107116
  })
106107
107117
  };
106108
- failure2 = (code2, message) => new IdeError(message, { code: code2 });
107118
+ failure2 = (code2, message2) => new IdeError(message2, { code: code2 });
106109
107119
  }
106110
107120
  });
106111
107121
 
@@ -106905,12 +107915,11 @@ function tmuxServerSocketRow(environment, uid) {
106905
107915
  };
106906
107916
  }
106907
107917
  function nodeVersionRow(version) {
106908
- const major = Number(version.split(".")[0]);
106909
- const pass = Number.isInteger(major) && major >= 20;
107918
+ const pass = isSupportedNodeVersion(version);
106910
107919
  return {
106911
- label: "Node.js \u2265 20",
107920
+ label: `Node.js \u2265 ${MINIMUM_NODE_MAJOR}`,
106912
107921
  pass,
106913
- detail: pass ? `v${version}` : `Node ${version} (need \u2265 20)`,
107922
+ detail: pass ? `v${version}` : `Node ${version} (need \u2265 ${MINIMUM_NODE_MAJOR})`,
106914
107923
  optional: false
106915
107924
  };
106916
107925
  }
@@ -107111,6 +108120,7 @@ var init_doctor = __esm({
107111
108120
  init_claude();
107112
108121
  init_notify();
107113
108122
  init_resolved_config();
108123
+ init_node_requirement();
107114
108124
  init_daemon_provenance();
107115
108125
  DAY_MS = 24 * 60 * 60 * 1e3;
107116
108126
  }
@@ -107527,9 +108537,9 @@ __export(ssh_daemon_transport_exports, {
107527
108537
  });
107528
108538
  import { spawn as spawn12 } from "node:child_process";
107529
108539
  import { createServer as createServer4 } from "node:net";
107530
- import { z as z144 } from "zod";
107531
- function failure3(message, code2 = "unavailable") {
107532
- return new SshConnectionError(message, code2);
108540
+ import { z as z145 } from "zod";
108541
+ function failure3(message2, code2 = "unavailable") {
108542
+ return new SshConnectionError(message2, code2);
107533
108543
  }
107534
108544
  function observeSshFailure(child) {
107535
108545
  let tail = "";
@@ -107808,20 +108818,20 @@ var init_ssh_daemon_transport = __esm({
107808
108818
  init_remote_tmux_command();
107809
108819
  init_ssh_daemon_relay();
107810
108820
  init_src2();
107811
- RemoteDaemonHandshakeSchema = z144.object({
107812
- version: z144.literal(1),
108821
+ RemoteDaemonHandshakeSchema = z145.object({
108822
+ version: z145.literal(1),
107813
108823
  daemon: CanonicalDaemonInfoSchema.strict().extend({
107814
- bindHostname: z144.enum(["127.0.0.1", "localhost", "::1", "0.0.0.0", "::"]),
107815
- authToken: z144.string().min(1).max(4096)
108824
+ bindHostname: z145.enum(["127.0.0.1", "localhost", "::1", "0.0.0.0", "::"]),
108825
+ authToken: z145.string().min(1).max(4096)
107816
108826
  })
107817
108827
  }).strict();
107818
- RemoteDaemonHandshakeFailureSchema = z144.strictObject({
107819
- version: z144.literal(1),
107820
- error: z144.strictObject({ code: z144.enum(["daemon-missing", "incompatible", "unavailable"]) })
108828
+ RemoteDaemonHandshakeFailureSchema = z145.strictObject({
108829
+ version: z145.literal(1),
108830
+ error: z145.strictObject({ code: z145.enum(["daemon-missing", "incompatible", "unavailable"]) })
107821
108831
  });
107822
108832
  SshConnectionError = class extends Error {
107823
- constructor(message, code2 = "unavailable") {
107824
- super(`SSH daemon connection: ${message}`);
108833
+ constructor(message2, code2 = "unavailable") {
108834
+ super(`SSH daemon connection: ${message2}`);
107825
108835
  this.code = code2;
107826
108836
  }
107827
108837
  code;
@@ -107891,8 +108901,8 @@ var init_remote_daemon_info = __esm({
107891
108901
  init_canonical_daemon();
107892
108902
  init_ssh_daemon_transport();
107893
108903
  RemoteDaemonInfoError = class extends Error {
107894
- constructor(message, code2) {
107895
- super(message);
108904
+ constructor(message2, code2) {
108905
+ super(message2);
107896
108906
  this.code = code2;
107897
108907
  }
107898
108908
  code;
@@ -108133,7 +109143,7 @@ import {
108133
109143
  import { hostname as hostname4, tmpdir as tmpdir2 } from "node:os";
108134
109144
  import { dirname as dirname52, join as join68 } from "node:path";
108135
109145
  import { createInterface as createInterface3 } from "node:readline/promises";
108136
- import { z as z145 } from "zod";
109146
+ import { z as z146 } from "zod";
108137
109147
  function targetSocket(target, environment = process.env) {
108138
109148
  if (target.socketPath && target.socketName)
108139
109149
  throw new IdeError("Pass --socket-path or --socket-name, not both.", {
@@ -108289,9 +109299,9 @@ function readWorkerResult(path2) {
108289
109299
  }
108290
109300
  }
108291
109301
  function writeWorkerResult(path2, result2) {
108292
- const { status: status2, message, restored, failed } = result2;
109302
+ const { status: status2, message: message2, restored, failed } = result2;
108293
109303
  const temporary = `${path2}.${process.pid}.tmp`;
108294
- writeFileSync31(temporary, JSON.stringify({ status: status2, message, restored, failed }) + "\n", {
109304
+ writeFileSync31(temporary, JSON.stringify({ status: status2, message: message2, restored, failed }) + "\n", {
108295
109305
  mode: 384
108296
109306
  });
108297
109307
  renameSync23(temporary, path2);
@@ -108565,23 +109575,23 @@ var init_io = __esm({
108565
109575
  init_plan();
108566
109576
  UPGRADE_HOLD_SESSION = "_tmux-ide-upgrade";
108567
109577
  NO_SERVER = /no server running|error connecting|failed to connect|connection refused/u;
108568
- ServerIdentitySchemaZ = z145.object({
108569
- host: z145.string(),
108570
- socketPath: z145.string().min(1),
108571
- pid: z145.number().int().positive(),
108572
- startTime: z145.number().int().nonnegative(),
108573
- version: z145.string(),
108574
- executable: z145.string(),
108575
- features: z145.enum(["full", "stock", "older", "partial", "unknown"])
109578
+ ServerIdentitySchemaZ = z146.object({
109579
+ host: z146.string(),
109580
+ socketPath: z146.string().min(1),
109581
+ pid: z146.number().int().positive(),
109582
+ startTime: z146.number().int().nonnegative(),
109583
+ version: z146.string(),
109584
+ executable: z146.string(),
109585
+ features: z146.enum(["full", "stock", "older", "partial", "unknown"])
108576
109586
  }).strict();
108577
- WorkerStateSchemaZ = z145.object({
109587
+ WorkerStateSchemaZ = z146.object({
108578
109588
  server: ServerIdentitySchemaZ,
108579
- client: z145.string().min(1),
108580
- snapshotPath: z145.string().min(1),
108581
- resumeAgents: z145.boolean()
109589
+ client: z146.string().min(1),
109590
+ snapshotPath: z146.string().min(1),
109591
+ resumeAgents: z146.boolean()
108582
109592
  }).strict();
108583
- WorkerResultSchemaZ = z145.object({
108584
- status: z145.enum([
109593
+ WorkerResultSchemaZ = z146.object({
109594
+ status: z146.enum([
108585
109595
  "already-full",
108586
109596
  "preview",
108587
109597
  "declined",
@@ -108590,9 +109600,9 @@ var init_io = __esm({
108590
109600
  "upgraded",
108591
109601
  "failed"
108592
109602
  ]),
108593
- message: z145.string(),
108594
- restored: z145.array(z145.string()).optional(),
108595
- failed: z145.array(z145.string()).optional()
109603
+ message: z146.string(),
109604
+ restored: z146.array(z146.string()).optional(),
109605
+ failed: z146.array(z146.string()).optional()
108596
109606
  });
108597
109607
  }
108598
109608
  });
@@ -108799,7 +109809,7 @@ var init_run = __esm({
108799
109809
  init_errors2();
108800
109810
  init_plan();
108801
109811
  retryCommand = (snapshotPath2, resumeAgents) => `tmux-ide restore --from ${snapshotPath2}${resumeAgents ? " --resume-agents" : ""}`;
108802
- nothingChanged = (message, code2) => new IdeError(`${message} Nothing was stopped.`, { code: code2, exitCode: 1 });
109812
+ nothingChanged = (message2, code2) => new IdeError(`${message2} Nothing was stopped.`, { code: code2, exitCode: 1 });
108803
109813
  }
108804
109814
  });
108805
109815
 
@@ -110282,7 +111292,7 @@ __export(automation_exports, {
110282
111292
  resolveAutomationIntent: () => resolveAutomationIntent,
110283
111293
  runAutomationCli: () => runAutomationCli
110284
111294
  });
110285
- import { z as z146 } from "zod";
111295
+ import { z as z147 } from "zod";
110286
111296
  import { execFileSync as execFileSync26 } from "node:child_process";
110287
111297
  import { parseArgs } from "node:util";
110288
111298
  function invokingPaneCredential(env = process.env) {
@@ -110449,7 +111459,7 @@ var init_automation2 = __esm({
110449
111459
  return { ...super.toJSON(), handle: this.handle };
110450
111460
  }
110451
111461
  };
110452
- AutomationInvocationIntentSchemaZ = z146.discriminatedUnion("kind", [
111462
+ AutomationInvocationIntentSchemaZ = z147.discriminatedUnion("kind", [
110453
111463
  AutomationOperationIntentSchemaZ.options[0].extend({
110454
111464
  source: AutomationOperationIntentSchemaZ.options[0].shape.source.optional()
110455
111465
  }),
@@ -110908,8 +111918,8 @@ async function callDaemon(io, method, path2, body) {
110908
111918
  throw new PluginCliError(`The daemon answered ${response3.status} without JSON`);
110909
111919
  }
110910
111920
  if (!response3.ok) {
110911
- const message = payload && typeof payload === "object" && "error" in payload ? String(payload.error) : `HTTP ${response3.status}`;
110912
- throw new PluginCliError(message);
111921
+ const message2 = payload && typeof payload === "object" && "error" in payload ? String(payload.error) : `HTTP ${response3.status}`;
111922
+ throw new PluginCliError(message2);
110913
111923
  }
110914
111924
  return payload;
110915
111925
  }
@@ -111347,8 +112357,8 @@ var init_cli2 = __esm({
111347
112357
  init_protocol();
111348
112358
  PluginCliError = class extends Error {
111349
112359
  exitCode;
111350
- constructor(message, exitCode = 1) {
111351
- super(message);
112360
+ constructor(message2, exitCode = 1) {
112361
+ super(message2);
111352
112362
  this.name = "PluginCliError";
111353
112363
  this.exitCode = exitCode;
111354
112364
  }
@@ -111608,7 +112618,7 @@ __export(mcp_exports, {
111608
112618
  });
111609
112619
  import { McpServer } from "@modelcontextprotocol/server";
111610
112620
  import { serveStdio, StdioServerTransport } from "@modelcontextprotocol/server/stdio";
111611
- import { z as z147 } from "zod";
112621
+ import { z as z148 } from "zod";
111612
112622
  async function call(work) {
111613
112623
  try {
111614
112624
  return result(await work());
@@ -111631,7 +112641,7 @@ function createTmuxIdeMcpServer(client) {
111631
112641
  "tmux_panes",
111632
112642
  {
111633
112643
  description: "Discover current panes across this daemon's tmux servers. Use returned endpoint objects unchanged; names and native pane numbers are not unique identities.",
111634
- inputSchema: z147.object({}).strict(),
112644
+ inputSchema: z148.object({}).strict(),
111635
112645
  annotations: { readOnlyHint: true, idempotentHint: true }
111636
112646
  },
111637
112647
  async (_args, context) => call(() => client.discover({ signal: context.mcpReq.signal }))
@@ -111640,7 +112650,7 @@ function createTmuxIdeMcpServer(client) {
111640
112650
  "tmux_prepare",
111641
112651
  {
111642
112652
  description: "Prepare a read or send and receive a generation-fenced operation handle. This does not send input. Save the handle before executing. Omit source to resolve this MCP process\u2019s verified pane automatically, or use source:null for an unbound caller. Save the returned intent unchanged with the handle.",
111643
- inputSchema: z147.object({ intent: AutomationInvocationIntentSchemaZ }).strict(),
112653
+ inputSchema: z148.object({ intent: AutomationInvocationIntentSchemaZ }).strict(),
111644
112654
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }
111645
112655
  },
111646
112656
  async ({ intent }, context) => call(async () => {
@@ -111657,7 +112667,7 @@ function createTmuxIdeMcpServer(client) {
111657
112667
  "tmux_execute",
111658
112668
  {
111659
112669
  description: "Execute a prepared read or send using its exact handle and unchanged intent. Sends may run terminal commands. On uncertainty, check status or retry this same handle; never prepare another operation. Read text is returned once; replay returns metadata only. A completed send is command completion, not proof the recipient consumed it.",
111660
- inputSchema: z147.object({
112670
+ inputSchema: z148.object({
111661
112671
  handle: AutomationOperationHandleSchemaZ,
111662
112672
  intent: AutomationOperationIntentSchemaZ
111663
112673
  }).strict(),
@@ -111669,7 +112679,7 @@ function createTmuxIdeMcpServer(client) {
111669
112679
  "tmux_operation_status",
111670
112680
  {
111671
112681
  description: "Look up a prepared operation without repeating its effect. Status contains no sent or captured text. Outcome-unknown includes expired retention and must not be interpreted as not executed.",
111672
- inputSchema: z147.object({ handle: AutomationOperationHandleSchemaZ }).strict(),
112682
+ inputSchema: z148.object({ handle: AutomationOperationHandleSchemaZ }).strict(),
111673
112683
  annotations: { readOnlyHint: true, idempotentHint: true }
111674
112684
  },
111675
112685
  async ({ handle }, context) => call(() => client.status(handle, { signal: context.mcpReq.signal }))
@@ -111678,9 +112688,9 @@ function createTmuxIdeMcpServer(client) {
111678
112688
  "tmux_interactions",
111679
112689
  {
111680
112690
  description: "Read at most one batch of scoped interaction metadata, optionally waiting for new events. Carry the returned cursor into the next call. Gaps explicitly mean missing history; these events contain no terminal contents.",
111681
- inputSchema: z147.object({
112691
+ inputSchema: z148.object({
111682
112692
  resume: TmuxInteractionCursorSchemaZ,
111683
- waitMs: z147.number().int().min(1).max(3e4).default(1e3)
112693
+ waitMs: z148.number().int().min(1).max(3e4).default(1e3)
111684
112694
  }).strict(),
111685
112695
  annotations: { readOnlyHint: true, idempotentHint: true }
111686
112696
  },
@@ -112368,8 +113378,8 @@ var init_worktree = __esm({
112368
113378
  "use strict";
112369
113379
  init_errors2();
112370
113380
  WorktreeError = class extends IdeError {
112371
- constructor(message, code2) {
112372
- super(message, { code: code2, exitCode: 1 });
113381
+ constructor(message2, code2) {
113382
+ super(message2, { code: code2, exitCode: 1 });
112373
113383
  this.name = "WorktreeError";
112374
113384
  }
112375
113385
  };
@@ -112610,8 +113620,8 @@ function renderPlan2(plan, {
112610
113620
  ].join("\n");
112611
113621
  }
112612
113622
  function updateFailure(what, error) {
112613
- const { status: status2, signal, message } = error;
112614
- const how = typeof status2 === "number" ? `exited with status ${status2}` : typeof signal === "string" ? `was stopped by ${signal}` : `could not run (${String(message).split("\n")[0]})`;
113623
+ const { status: status2, signal, message: message2 } = error;
113624
+ const how = typeof status2 === "number" ? `exited with status ${status2}` : typeof signal === "string" ? `was stopped by ${signal}` : `could not run (${String(message2).split("\n")[0]})`;
112615
113625
  return new IdeError(
112616
113626
  `The update did not finish: ${what} ${how}. Its own message is above. Retry with: tmux-ide update`,
112617
113627
  { code: "UPDATE_FAILED", cause: error instanceof Error ? error : void 0 }
@@ -112798,8 +113808,8 @@ var init_pane_widget = __esm({
112798
113808
  "use strict";
112799
113809
  init_src2();
112800
113810
  PaneWidgetRefusal = class extends Error {
112801
- constructor(reason, message) {
112802
- super(message);
113811
+ constructor(reason, message2) {
113812
+ super(message2);
112803
113813
  this.reason = reason;
112804
113814
  this.name = "PaneWidgetRefusal";
112805
113815
  }
@@ -112925,6 +113935,14 @@ var init_server3 = __esm({
112925
113935
  }
112926
113936
  });
112927
113937
 
113938
+ // packages/daemon/src/lib/require-supported-node.ts
113939
+ init_node_requirement();
113940
+ var message = unsupportedNodeMessage(process.versions);
113941
+ if (message !== null) {
113942
+ process.stderr.write(message);
113943
+ process.exit(1);
113944
+ }
113945
+
112928
113946
  // bin/cli.ts
112929
113947
  init_src();
112930
113948
  init_tmux_client_execution();
@@ -113287,7 +114305,7 @@ async function execBunWidget(surface, scriptPath, args, commandLabel, extraEnv =
113287
114305
  compiledBinary: findCompiledTui(),
113288
114306
  preferSource: process.env.TMUX_IDE_TUI_SOURCE === "1"
113289
114307
  },
113290
- { log: (message) => process.stderr.write(`[tmux-ide] ${message}
114308
+ { log: (message2) => process.stderr.write(`[tmux-ide] ${message2}
113291
114309
  `) }
113292
114310
  );
113293
114311
  if (launch2.mode === "unavailable") {
@@ -113514,7 +114532,7 @@ async function runApp(appArgs) {
113514
114532
  compiledBinary: findCompiledTui(),
113515
114533
  preferSource: process.env.TMUX_IDE_TUI_SOURCE === "1"
113516
114534
  },
113517
- { log: (message) => process.stderr.write(`[tmux-ide] ${message}
114535
+ { log: (message2) => process.stderr.write(`[tmux-ide] ${message2}
113518
114536
  `) }
113519
114537
  );
113520
114538
  try {
@@ -113948,12 +114966,12 @@ try {
113948
114966
  case "send": {
113949
114967
  const target = values.to ?? positionals[1];
113950
114968
  const messageStart = values.to ? 1 : 2;
113951
- let message = positionals.slice(messageStart).join(" ");
113952
- if (!message && !process.stdin.isTTY) {
114969
+ let message2 = positionals.slice(messageStart).join(" ");
114970
+ if (!message2 && !process.stdin.isTTY) {
113953
114971
  const { readFileSync: readFileSync50 } = await import("node:fs");
113954
- message = readFileSync50(0, "utf-8").trim();
114972
+ message2 = readFileSync50(0, "utf-8").trim();
113955
114973
  }
113956
- await (await Promise.resolve().then(() => (init_send(), send_exports))).send(null, { json: json2, to: target, message, noEnter: values["no-enter"] });
114974
+ await (await Promise.resolve().then(() => (init_send(), send_exports))).send(null, { json: json2, to: target, message: message2, noEnter: values["no-enter"] });
113957
114975
  break;
113958
114976
  }
113959
114977
  case "settings": {
@@ -114891,9 +115909,9 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
114891
115909
  );
114892
115910
  }
114893
115911
  } catch (err) {
114894
- const message = err instanceof Error ? err.message : String(err);
114895
- if (json2) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
114896
- else console.error(`manifest pack NOT installed: ${message}`);
115912
+ const message2 = err instanceof Error ? err.message : String(err);
115913
+ if (json2) console.log(JSON.stringify({ ok: false, error: message2 }, null, 2));
115914
+ else console.error(`manifest pack NOT installed: ${message2}`);
114897
115915
  process.exitCode = 1;
114898
115916
  }
114899
115917
  break;
@@ -114994,11 +116012,11 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
114994
116012
  announcement = buildCardAnnouncement2(JSON.parse(source));
114995
116013
  }
114996
116014
  } catch (error) {
114997
- const message = error instanceof PaneWidgetRefusal2 || error instanceof WidgetAssetStoreError2 ? error.message : `The widget input could not be read: ${error.message}`;
116015
+ const message2 = error instanceof PaneWidgetRefusal2 || error instanceof WidgetAssetStoreError2 ? error.message : `The widget input could not be read: ${error.message}`;
114998
116016
  if (json2) {
114999
- console.log(JSON.stringify({ ok: false, error: message }, null, 2));
116017
+ console.log(JSON.stringify({ ok: false, error: message2 }, null, 2));
115000
116018
  } else {
115001
- console.error(message);
116019
+ console.error(message2);
115002
116020
  }
115003
116021
  process.exit(1);
115004
116022
  }