tmux-ide 2.9.24 → 2.9.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1689 -393
- package/package.json +5 -2
- package/packages/contracts/src/pane-stream.ts +72 -0
- package/packages/contracts/src/terminal-delivery.ts +8 -2
- package/packages/contracts/src/terminal-runtime-inventory.ts +61 -1
- package/packages/contracts/src/tmux-server-scope.ts +18 -0
- package/packages/daemon/dist/command-center/discovery.js +24 -5
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
- package/packages/daemon/dist/command-center/server.js +81 -75
- package/packages/daemon/dist/command-center/tmux-servers.js +17 -7
- package/packages/daemon/dist/doctor.js +46 -10
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +20 -2
- package/packages/daemon/dist/lib/daemon-crash-snapshot.js +118 -0
- package/packages/daemon/dist/lib/daemon-embed.js +6 -0
- package/packages/daemon/dist/lib/headless-daemon.js +63 -6
- package/packages/daemon/dist/lib/invocation-directory.js +20 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +22 -6
- package/packages/daemon/dist/lib/tmux-client-execution.js +12 -3
- package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
- package/packages/daemon/dist/lib/update-check.js +18 -0
- package/packages/daemon/dist/lib/update-daemon-outcome.js +31 -0
- package/packages/daemon/dist/lib/update.js +39 -14
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/terminal/graphics/kitty-graphics.js +16 -4
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +26 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +31 -2
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +831 -222
- package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
- package/packages/daemon/dist/terminal/session-runtime/registry.js +25 -2
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +121 -6
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +79 -2
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +24 -2
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +38 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
- package/packages/daemon/dist/tui/chrome/snapshot.js +36 -1
- package/packages/daemon/dist/tui/chrome/statusline.js +8 -5
- package/packages/daemon/dist/tui/chrome/updater.js +2 -0
- package/packages/daemon/src/command-center/discovery.ts +24 -4
- package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
- package/packages/daemon/src/command-center/server.ts +67 -67
- package/packages/daemon/src/command-center/tmux-servers.ts +19 -6
- package/packages/daemon/src/doctor.ts +50 -9
- package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +31 -5
- package/packages/daemon/src/lib/daemon-crash-snapshot.ts +175 -0
- package/packages/daemon/src/lib/daemon-embed.ts +22 -0
- package/packages/daemon/src/lib/headless-daemon.ts +88 -7
- package/packages/daemon/src/lib/invocation-directory.ts +21 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +25 -7
- package/packages/daemon/src/lib/tmux-client-execution.ts +14 -5
- package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
- package/packages/daemon/src/lib/update-check.ts +34 -0
- package/packages/daemon/src/lib/update-daemon-outcome.ts +42 -0
- package/packages/daemon/src/lib/update.ts +58 -16
- package/packages/daemon/src/terminal/graphics/kitty-graphics.ts +22 -6
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +27 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +38 -2
- package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +915 -236
- package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
- package/packages/daemon/src/terminal/session-runtime/registry.ts +36 -2
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +136 -6
- package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +76 -2
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +21 -1
- package/packages/daemon/src/terminal/session-runtime/transport-binding.ts +42 -2
- package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
- package/packages/daemon/src/tui/chrome/snapshot.ts +47 -1
- package/packages/daemon/src/tui/chrome/statusline.ts +7 -4
- package/packages/daemon/src/tui/chrome/updater.ts +3 -0
- package/packages/daemon-client/src/pane-stream-client.ts +47 -5
package/bin/cli.js
CHANGED
|
@@ -758,7 +758,7 @@ function nonEmpty(env, key2) {
|
|
|
758
758
|
return value ? value : void 0;
|
|
759
759
|
}
|
|
760
760
|
function absolutePath(value, cwd, key2) {
|
|
761
|
-
const path2 = isAbsolute3(value) ? value : resolve3(cwd, value);
|
|
761
|
+
const path2 = isAbsolute3(value) ? value : resolve3(cwd(), value);
|
|
762
762
|
if (!isAbsolute3(path2)) throw new TypeError(`${key2} must resolve to an absolute path`);
|
|
763
763
|
return path2;
|
|
764
764
|
}
|
|
@@ -811,7 +811,16 @@ function resolveRuntimeNamespace(options = {}) {
|
|
|
811
811
|
const within = (path2, parent) => isInsideOrEqual(path2, parent, identity4);
|
|
812
812
|
const env = options.env ?? process.env;
|
|
813
813
|
const userHome = options.userHome ?? homedir2();
|
|
814
|
-
const cwd =
|
|
814
|
+
const cwd = (key2) => () => {
|
|
815
|
+
if (options.cwd !== void 0) return options.cwd;
|
|
816
|
+
try {
|
|
817
|
+
return process.cwd();
|
|
818
|
+
} catch (error) {
|
|
819
|
+
throw new TypeError(`${key2} is relative and the current directory no longer exists`, {
|
|
820
|
+
cause: error
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
};
|
|
815
824
|
const mode = runtimeMode(env);
|
|
816
825
|
const isolated = ISOLATED_MODES.has(mode);
|
|
817
826
|
const canonicalHome = join3(userHome, ".tmux-ide");
|
|
@@ -844,10 +853,14 @@ function resolveRuntimeNamespace(options = {}) {
|
|
|
844
853
|
if (isolated && !configuredHome) {
|
|
845
854
|
throw new TypeError(`${mode} runtime requires an explicit ${STATE_HOME_ENV}`);
|
|
846
855
|
}
|
|
847
|
-
const stateHome2 = absolutePath(
|
|
856
|
+
const stateHome2 = absolutePath(
|
|
857
|
+
configuredHome ?? canonicalHome,
|
|
858
|
+
cwd(STATE_HOME_ENV),
|
|
859
|
+
STATE_HOME_ENV
|
|
860
|
+
);
|
|
848
861
|
const registryDir2 = absolutePath(
|
|
849
862
|
nonEmpty(env, REGISTRY_DIR_ENV) ?? stateHome2,
|
|
850
|
-
cwd,
|
|
863
|
+
cwd(REGISTRY_DIR_ENV),
|
|
851
864
|
REGISTRY_DIR_ENV
|
|
852
865
|
);
|
|
853
866
|
const daemonInfoDir = absolutePath(
|
|
@@ -856,7 +869,7 @@ function resolveRuntimeNamespace(options = {}) {
|
|
|
856
869
|
// This also keeps an explicitly empty DAEMON_INFO_DIR equivalent to
|
|
857
870
|
// "unset" instead of silently escaping a caller's isolated registry.
|
|
858
871
|
nonEmpty(env, DAEMON_INFO_DIR_ENV) ?? registryDir2,
|
|
859
|
-
cwd,
|
|
872
|
+
cwd(DAEMON_INFO_DIR_ENV),
|
|
860
873
|
DAEMON_INFO_DIR_ENV
|
|
861
874
|
);
|
|
862
875
|
const tmuxSocketName = nonEmpty(env, TMUX_SOCKET_NAME_ENV);
|
|
@@ -870,7 +883,10 @@ function resolveRuntimeNamespace(options = {}) {
|
|
|
870
883
|
if (tmuxSocketName && !SAFE_SOCKET_NAME.test(tmuxSocketName)) {
|
|
871
884
|
throw new TypeError(`${TMUX_SOCKET_NAME_ENV} is invalid`);
|
|
872
885
|
}
|
|
873
|
-
const tmuxSocket = tmuxSocketPath ? {
|
|
886
|
+
const tmuxSocket = tmuxSocketPath ? {
|
|
887
|
+
kind: "path",
|
|
888
|
+
path: absolutePath(tmuxSocketPath, cwd(TMUX_SOCKET_PATH_ENV), TMUX_SOCKET_PATH_ENV)
|
|
889
|
+
} : { kind: "name", name: tmuxSocketName ?? "default" };
|
|
874
890
|
if (isolated && tmuxSocket.kind === "name" && tmuxSocket.name === "default") {
|
|
875
891
|
throw new TypeError(`${mode} runtime requires a non-default ${TMUX_SOCKET_NAME_ENV}`);
|
|
876
892
|
}
|
|
@@ -1464,9 +1480,18 @@ function resolveOrdinaryTmuxClient(environment, cwd, options = {}) {
|
|
|
1464
1480
|
return { executable: starter, environment: withBundledTmuxResources(starter, environment) };
|
|
1465
1481
|
}
|
|
1466
1482
|
}
|
|
1467
|
-
const candidates = configured ? [configured] : (environment.PATH ?? "/usr/bin:/bin").split(delimiter).map(
|
|
1468
|
-
(entry)
|
|
1469
|
-
|
|
1483
|
+
const candidates = configured ? [configured] : (environment.PATH ?? "/usr/bin:/bin").split(delimiter).map((entry) => {
|
|
1484
|
+
if (isAbsolute5(entry)) return resolve6(entry, "tmux");
|
|
1485
|
+
try {
|
|
1486
|
+
return resolve6(
|
|
1487
|
+
cwd instanceof URL ? fileURLToPath2(cwd) : cwd ?? process.cwd(),
|
|
1488
|
+
entry,
|
|
1489
|
+
"tmux"
|
|
1490
|
+
);
|
|
1491
|
+
} catch {
|
|
1492
|
+
return "";
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1470
1495
|
let executable;
|
|
1471
1496
|
for (const candidate of candidates) {
|
|
1472
1497
|
try {
|
|
@@ -7370,7 +7395,7 @@ var init_causal_cell = __esm({
|
|
|
7370
7395
|
|
|
7371
7396
|
// packages/contracts/src/terminal-delivery.ts
|
|
7372
7397
|
import { z as z48 } from "zod";
|
|
7373
|
-
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;
|
|
7398
|
+
var STOCK_CAPTURE_TAB_UNAVAILABLE, TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION, TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION, TERMINAL_DELIVERY_PROTOCOL_VERSION, TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS, 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;
|
|
7374
7399
|
var init_terminal_delivery = __esm({
|
|
7375
7400
|
"packages/contracts/src/terminal-delivery.ts"() {
|
|
7376
7401
|
"use strict";
|
|
@@ -7383,6 +7408,7 @@ var init_terminal_delivery = __esm({
|
|
|
7383
7408
|
TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION = /* @__PURE__ */ (() => 109)();
|
|
7384
7409
|
TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION = /* @__PURE__ */ (() => 110)();
|
|
7385
7410
|
TERMINAL_DELIVERY_PROTOCOL_VERSION = /* @__PURE__ */ (() => 1)();
|
|
7411
|
+
TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS = /* @__PURE__ */ (() => 16)();
|
|
7386
7412
|
TERMINAL_DELIVERY_CHUNK_BYTES = /* @__PURE__ */ (() => 256 * 1024)();
|
|
7387
7413
|
TERMINAL_DELIVERY_PATCH_TO_SEED_BYTES = /* @__PURE__ */ (() => 512 * 1024)();
|
|
7388
7414
|
TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES = /* @__PURE__ */ (() => 16 * 1024 * 1024)();
|
|
@@ -7394,8 +7420,9 @@ var init_terminal_delivery = __esm({
|
|
|
7394
7420
|
"ansi-raw-v1"
|
|
7395
7421
|
]))();
|
|
7396
7422
|
TerminalDeliveryOfferSchemaZ = /* @__PURE__ */ (() => z48.object({
|
|
7397
|
-
//
|
|
7398
|
-
|
|
7423
|
+
// Released daemons before 2.9.26 refuse more than nine numbers, so a client
|
|
7424
|
+
// offers a tenth only to a daemon whose productVersion is 2.9.26 or later.
|
|
7425
|
+
protocolVersions: z48.array(z48.number().int().positive()).min(1).max(TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS),
|
|
7399
7426
|
encodings: z48.array(TerminalDeliveryEncodingSchemaZ).min(1).max(4),
|
|
7400
7427
|
richPlacements: z48.boolean()
|
|
7401
7428
|
}).strict().superRefine((value, context) => {
|
|
@@ -7675,6 +7702,7 @@ __export(tmux_server_scope_exports, {
|
|
|
7675
7702
|
TmuxServerSessionTargetSchemaZ: () => TmuxServerSessionTargetSchemaZ,
|
|
7676
7703
|
TmuxServerSessionsResourceSchemaZ: () => TmuxServerSessionsResourceSchemaZ,
|
|
7677
7704
|
TmuxServerSessionsResourceV2SchemaZ: () => TmuxServerSessionsResourceV2SchemaZ,
|
|
7705
|
+
TmuxServerSessionsResourceV3SchemaZ: () => TmuxServerSessionsResourceV3SchemaZ,
|
|
7678
7706
|
TmuxServerWindowTargetSchemaZ: () => TmuxServerWindowTargetSchemaZ,
|
|
7679
7707
|
TmuxServersResourceSchemaZ: () => TmuxServersResourceSchemaZ,
|
|
7680
7708
|
isTmuxServerPaneStreamPath: () => isTmuxServerPaneStreamPath,
|
|
@@ -7713,7 +7741,7 @@ function base64DecodedLength(data) {
|
|
|
7713
7741
|
const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
|
|
7714
7742
|
return data.length / 4 * 3 - padding;
|
|
7715
7743
|
}
|
|
7716
|
-
var descriptorShape, TmuxServerDescriptorSchemaZ, TMUX_SERVERS_API_PATH, TmuxServersResourceSchemaZ, TmuxServerSessionTargetSchemaZ, TmuxServerWindowTargetSchemaZ, TmuxServerPaneTargetSchemaZ, TmuxServerSessionsResourceSchemaZ, TMUX_SERVER_SESSION_FAVICON_MAX_BYTES, TmuxServerSessionFaviconMimeSchemaZ, TmuxServerSessionFaviconSchemaZ, TmuxServerSessionsResourceV2SchemaZ, TmuxServerRegistrationRequestSchemaZ;
|
|
7744
|
+
var descriptorShape, TmuxServerDescriptorSchemaZ, TMUX_SERVERS_API_PATH, TmuxServersResourceSchemaZ, TmuxServerSessionTargetSchemaZ, TmuxServerWindowTargetSchemaZ, TmuxServerPaneTargetSchemaZ, TmuxServerSessionsResourceSchemaZ, TMUX_SERVER_SESSION_FAVICON_MAX_BYTES, TmuxServerSessionFaviconMimeSchemaZ, TmuxServerSessionFaviconSchemaZ, TmuxServerSessionsResourceV2SchemaZ, TmuxServerSessionsResourceV3SchemaZ, TmuxServerRegistrationRequestSchemaZ;
|
|
7717
7745
|
var init_tmux_server_scope = __esm({
|
|
7718
7746
|
"packages/contracts/src/tmux-server-scope.ts"() {
|
|
7719
7747
|
"use strict";
|
|
@@ -7807,6 +7835,13 @@ var init_tmux_server_scope = __esm({
|
|
|
7807
7835
|
}).strict()
|
|
7808
7836
|
)
|
|
7809
7837
|
}).strict())();
|
|
7838
|
+
TmuxServerSessionsResourceV3SchemaZ = /* @__PURE__ */ (() => z50.object({
|
|
7839
|
+
version: z50.literal(3),
|
|
7840
|
+
server: TmuxServerScopeSchemaZ,
|
|
7841
|
+
sessions: z50.array(
|
|
7842
|
+
TmuxServerSessionsResourceV2SchemaZ.shape.sessions.element.extend({ largestWindowPaneCount: z50.number().int().min(1) }).strict()
|
|
7843
|
+
)
|
|
7844
|
+
}).strict())();
|
|
7810
7845
|
TmuxServerRegistrationRequestSchemaZ = /* @__PURE__ */ (() => z50.object({
|
|
7811
7846
|
label: descriptorShape.label.max(128),
|
|
7812
7847
|
selector: z50.discriminatedUnion("kind", [
|
|
@@ -7915,7 +7950,7 @@ var init_terminal_graphics = __esm({
|
|
|
7915
7950
|
|
|
7916
7951
|
// packages/contracts/src/pane-stream.ts
|
|
7917
7952
|
import { z as z52 } from "zod";
|
|
7918
|
-
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, 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, PaneStreamClosedFrameSchemaZ, PaneStreamInputAckFrameSchemaZ, PaneStreamClockProbeAckFrameSchemaZ, PaneStreamCausalCellProofFrameSchemaZ, PaneStreamCausalCellFailureFrameSchemaZ, PaneStreamTerminalDeliveryReadyFrameSchemaZ, PaneStreamTerminalDeliveryEnvelopeFrameSchemaZ, PaneStreamTerminalProjectionEnvelopeFrameSchemaZ, PaneStreamTerminalDeliveryChunkFrameSchemaZ, PaneStreamTerminalDeliveryFaultFrameSchemaZ, PaneStreamTerminalGraphicsFrameSchemaZ, PaneStreamTerminalGraphicsBlobFrameSchemaZ, PaneStreamTerminalGraphicsLocalFrameSchemaZ, PaneStreamSemanticIntentAckFrameSchemaZ, PaneStreamViewportAckFrameSchemaZ, PaneStreamAuthoritySnapshotFrameSchemaZ, PaneStreamAuthorityReceiptFrameSchemaZ, PaneStreamErrorFrameCodeSchemaZ, PaneStreamErrorFrameSchemaZ, PaneStreamServerFrameSchemaZ;
|
|
7953
|
+
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, 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;
|
|
7919
7954
|
var init_pane_stream = __esm({
|
|
7920
7955
|
"packages/contracts/src/pane-stream.ts"() {
|
|
7921
7956
|
"use strict";
|
|
@@ -7961,7 +7996,15 @@ var init_pane_stream = __esm({
|
|
|
7961
7996
|
panes: PaneSetSchemaZ,
|
|
7962
7997
|
viewerMode: PaneStreamViewerModeSchemaZ,
|
|
7963
7998
|
/** Explicit semantic-v2 content/authority mode. Omission retains raw v1. */
|
|
7964
|
-
terminalDelivery: TerminalDeliveryOfferSchemaZ.optional()
|
|
7999
|
+
terminalDelivery: TerminalDeliveryOfferSchemaZ.optional(),
|
|
8000
|
+
/**
|
|
8001
|
+
* #806: a stream for one window. `panes` must be exactly that window's
|
|
8002
|
+
* panes (at most PANE_STREAM_MAX_PANES), so a session with more panes in
|
|
8003
|
+
* all can be viewed window by window. Under capability 119/120 the stream
|
|
8004
|
+
* follows that window's pane set in place; other windows never enter.
|
|
8005
|
+
* Released daemons refuse the field: send it only to a daemon that has it.
|
|
8006
|
+
*/
|
|
8007
|
+
semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ.optional()
|
|
7965
8008
|
}).strict())();
|
|
7966
8009
|
PaneStreamRedemptionTicketSchemaZ = /* @__PURE__ */ (() => z52.string().regex(/^ps2_[A-Za-z0-9_-]{43}$/u))();
|
|
7967
8010
|
PaneStreamLoopbackWebSocketUrlSchemaZ = /* @__PURE__ */ (() => z52.url().max(2048).refine((value) => {
|
|
@@ -8008,6 +8051,9 @@ var init_pane_stream = __esm({
|
|
|
8008
8051
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION = /* @__PURE__ */ (() => 106)();
|
|
8009
8052
|
PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION = /* @__PURE__ */ (() => 117)();
|
|
8010
8053
|
PANE_STREAM_READER_CAPABILITY_VERSION = /* @__PURE__ */ (() => 118)();
|
|
8054
|
+
PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION = /* @__PURE__ */ (() => 123)();
|
|
8055
|
+
PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION = /* @__PURE__ */ (() => 119)();
|
|
8056
|
+
PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION = /* @__PURE__ */ (() => 120)();
|
|
8011
8057
|
PaneStreamInputLifetimeSchemaZ = /* @__PURE__ */ (() => z52.object({
|
|
8012
8058
|
generation: z52.string().min(1).max(256),
|
|
8013
8059
|
incarnation: z52.string().min(1).max(256)
|
|
@@ -8157,6 +8203,8 @@ var init_pane_stream = __esm({
|
|
|
8157
8203
|
type: z52.literal("ready"),
|
|
8158
8204
|
inputLifetime: z52.literal(true).optional(),
|
|
8159
8205
|
inputBytes: z52.literal(true).optional(),
|
|
8206
|
+
/** Only to a client that offered capability 119: `topology` frames may follow. */
|
|
8207
|
+
topologyInPlace: z52.literal(true).optional(),
|
|
8160
8208
|
protocolVersion: z52.literal(PANE_STREAM_PROTOCOL_VERSION),
|
|
8161
8209
|
daemonInstanceId: BoundedIdentitySchemaZ,
|
|
8162
8210
|
requestId: z52.uuid(),
|
|
@@ -8218,6 +8266,11 @@ var init_pane_stream = __esm({
|
|
|
8218
8266
|
displayName: BoundedDisplayNameSchemaZ.nullable().optional(),
|
|
8219
8267
|
displayNameSource: PaneDisplayNameSourceSchemaZ.nullable().optional(),
|
|
8220
8268
|
browserIcon: z52.string().regex(/^(?:[0-9a-f]{2048})?$/u).nullable().optional(),
|
|
8269
|
+
/**
|
|
8270
|
+
* Only with capability 123: a terminal browser with tmux-ide's
|
|
8271
|
+
* native controls, a plain one without them, or null.
|
|
8272
|
+
*/
|
|
8273
|
+
browserKind: z52.enum(["native", "plain"]).nullable().optional(),
|
|
8221
8274
|
/** Only with capability 118: the Markdown reader's file name, never its path. */
|
|
8222
8275
|
reader: z52.object({
|
|
8223
8276
|
name: z52.string().min(1).max(255).refine((value) => !hasControlCharacter(value) && !value.includes("/"))
|
|
@@ -8321,6 +8374,22 @@ var init_pane_stream = __esm({
|
|
|
8321
8374
|
state: z52.enum(["paused", "resumed"]),
|
|
8322
8375
|
reason: z52.enum(["backpressure", "requested"])
|
|
8323
8376
|
}).strict())();
|
|
8377
|
+
PaneStreamTopologyFrameSchemaZ = /* @__PURE__ */ (() => z52.object({
|
|
8378
|
+
type: z52.literal("topology"),
|
|
8379
|
+
topologyEpoch: z52.number().int().nonnegative(),
|
|
8380
|
+
panes: PaneSetSchemaZ,
|
|
8381
|
+
removed: z52.array(PaneStreamSemanticPaneIdSchemaZ).max(PANE_STREAM_MAX_PANES),
|
|
8382
|
+
added: z52.array(PaneStreamSemanticPaneIdSchemaZ).max(PANE_STREAM_MAX_PANES)
|
|
8383
|
+
}).strict().superRefine((frame, context) => {
|
|
8384
|
+
const panes = new Set(frame.panes);
|
|
8385
|
+
const removed = new Set(frame.removed);
|
|
8386
|
+
const added = new Set(frame.added);
|
|
8387
|
+
if (removed.size !== frame.removed.length || added.size !== frame.added.length || frame.added.some((pane) => !panes.has(pane) || removed.has(pane)) || frame.removed.some((pane) => panes.has(pane)))
|
|
8388
|
+
context.addIssue({
|
|
8389
|
+
code: z52.ZodIssueCode.custom,
|
|
8390
|
+
message: "added panes must be in the set, removed panes must not, and neither may repeat"
|
|
8391
|
+
});
|
|
8392
|
+
}))();
|
|
8324
8393
|
PaneStreamClosedFrameSchemaZ = /* @__PURE__ */ (() => z52.object({
|
|
8325
8394
|
type: z52.literal("closed"),
|
|
8326
8395
|
pane: PaneStreamSemanticPaneIdSchemaZ,
|
|
@@ -8466,6 +8535,7 @@ var init_pane_stream = __esm({
|
|
|
8466
8535
|
PaneStreamCursorFrameSchemaZ,
|
|
8467
8536
|
PaneStreamLayoutFrameSchemaZ,
|
|
8468
8537
|
PaneStreamLayoutSnapshotFrameSchemaZ,
|
|
8538
|
+
PaneStreamTopologyFrameSchemaZ,
|
|
8469
8539
|
PaneStreamFlowFrameSchemaZ,
|
|
8470
8540
|
PaneStreamClosedFrameSchemaZ,
|
|
8471
8541
|
PaneStreamInputAckFrameSchemaZ,
|
|
@@ -10658,7 +10728,7 @@ var init_terminal_graphics_compressed = __esm({
|
|
|
10658
10728
|
|
|
10659
10729
|
// packages/contracts/src/terminal-runtime-inventory.ts
|
|
10660
10730
|
import { z as z72 } from "zod";
|
|
10661
|
-
var TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION, TerminalRuntimeInventoryProjectionV1SchemaZ;
|
|
10731
|
+
var TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION, TerminalRuntimeInventoryProjectionV1SchemaZ, TerminalRuntimeInventoryWindowSchemaZ, TerminalRuntimeInventoryProjectionV2SchemaZ;
|
|
10662
10732
|
var init_terminal_runtime_inventory = __esm({
|
|
10663
10733
|
"packages/contracts/src/terminal-runtime-inventory.ts"() {
|
|
10664
10734
|
"use strict";
|
|
@@ -10678,6 +10748,42 @@ var init_terminal_runtime_inventory = __esm({
|
|
|
10678
10748
|
"pane ids must be sorted"
|
|
10679
10749
|
)
|
|
10680
10750
|
}).strict())();
|
|
10751
|
+
TerminalRuntimeInventoryWindowSchemaZ = /* @__PURE__ */ (() => z72.object({
|
|
10752
|
+
semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ,
|
|
10753
|
+
/** tmux's current window of the session. */
|
|
10754
|
+
active: z72.boolean(),
|
|
10755
|
+
semanticPaneIds: z72.array(TerminalAttachmentSemanticPaneIdSchemaZ).min(1).max(256).refine((values2) => new Set(values2).size === values2.length, "pane ids must be unique")
|
|
10756
|
+
}).strict())();
|
|
10757
|
+
TerminalRuntimeInventoryProjectionV2SchemaZ = /* @__PURE__ */ (() => TerminalRuntimeInventoryProjectionV1SchemaZ.extend({
|
|
10758
|
+
/** In tmux window order. */
|
|
10759
|
+
windows: z72.array(TerminalRuntimeInventoryWindowSchemaZ).max(256)
|
|
10760
|
+
}).strict().superRefine((value, ctx) => {
|
|
10761
|
+
const listed = new Set(value.semanticPaneIds);
|
|
10762
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10763
|
+
const windows = /* @__PURE__ */ new Set();
|
|
10764
|
+
let active3 = 0;
|
|
10765
|
+
for (const window2 of value.windows) {
|
|
10766
|
+
if (windows.has(window2.semanticWindowId))
|
|
10767
|
+
ctx.addIssue({ code: "custom", message: "a window is listed twice", path: ["windows"] });
|
|
10768
|
+
windows.add(window2.semanticWindowId);
|
|
10769
|
+
if (window2.active) active3 += 1;
|
|
10770
|
+
for (const pane of window2.semanticPaneIds) {
|
|
10771
|
+
if (!listed.has(pane) || seen.has(pane))
|
|
10772
|
+
ctx.addIssue({
|
|
10773
|
+
code: "custom",
|
|
10774
|
+
message: "a window pane must be listed once and in the inventory",
|
|
10775
|
+
path: ["windows"]
|
|
10776
|
+
});
|
|
10777
|
+
seen.add(pane);
|
|
10778
|
+
}
|
|
10779
|
+
}
|
|
10780
|
+
if (active3 > 1)
|
|
10781
|
+
ctx.addIssue({
|
|
10782
|
+
code: "custom",
|
|
10783
|
+
message: "at most one window is active",
|
|
10784
|
+
path: ["windows"]
|
|
10785
|
+
});
|
|
10786
|
+
}))();
|
|
10681
10787
|
}
|
|
10682
10788
|
});
|
|
10683
10789
|
|
|
@@ -12560,6 +12666,7 @@ __export(update_check_exports, {
|
|
|
12560
12666
|
maybeCheckForUpdate: () => maybeCheckForUpdate,
|
|
12561
12667
|
parseRegistryResponse: () => parseRegistryResponse,
|
|
12562
12668
|
readUpdateCache: () => readUpdateCache,
|
|
12669
|
+
refreshUpdateStatus: () => refreshUpdateStatus,
|
|
12563
12670
|
runUpdateCheck: () => runUpdateCheck,
|
|
12564
12671
|
shouldCheck: () => shouldCheck,
|
|
12565
12672
|
updateCachePath: () => updateCachePath,
|
|
@@ -12666,6 +12773,26 @@ function getUpdateStatus({
|
|
|
12666
12773
|
const cache3 = readUpdateCache({ currentVersion });
|
|
12667
12774
|
return deriveStatus(cache3?.latest ?? null, currentVersion);
|
|
12668
12775
|
}
|
|
12776
|
+
async function refreshUpdateStatus({
|
|
12777
|
+
currentVersion = getCurrentVersion(),
|
|
12778
|
+
now = Date.now(),
|
|
12779
|
+
timeoutMs = 3e3,
|
|
12780
|
+
fetchLatest = fetchLatestVersion
|
|
12781
|
+
} = {}) {
|
|
12782
|
+
const fetched = await fetchLatest(timeoutMs, updateChannel(currentVersion));
|
|
12783
|
+
const cache3 = readUpdateCache({ currentVersion });
|
|
12784
|
+
if (fetched === null)
|
|
12785
|
+
return { ...deriveStatus(cache3?.latest ?? null, currentVersion), source: "cache" };
|
|
12786
|
+
writeUpdateCache(
|
|
12787
|
+
{
|
|
12788
|
+
lastCheckedAt: now,
|
|
12789
|
+
latest: fetched,
|
|
12790
|
+
...cache3?.notified ? { notified: cache3.notified } : {}
|
|
12791
|
+
},
|
|
12792
|
+
{ currentVersion }
|
|
12793
|
+
);
|
|
12794
|
+
return { ...deriveStatus(fetched, currentVersion), source: "registry" };
|
|
12795
|
+
}
|
|
12669
12796
|
async function runUpdateCheck({
|
|
12670
12797
|
now = Date.now(),
|
|
12671
12798
|
...scope2
|
|
@@ -13368,6 +13495,25 @@ var init_state_home = __esm({
|
|
|
13368
13495
|
}
|
|
13369
13496
|
});
|
|
13370
13497
|
|
|
13498
|
+
// packages/daemon/src/lib/invocation-directory.ts
|
|
13499
|
+
import { homedir as homedir4 } from "node:os";
|
|
13500
|
+
function invocationDirectory(io = {
|
|
13501
|
+
cwd: () => process.cwd(),
|
|
13502
|
+
home: homedir4
|
|
13503
|
+
}) {
|
|
13504
|
+
try {
|
|
13505
|
+
return io.cwd();
|
|
13506
|
+
} catch (error) {
|
|
13507
|
+
if (error?.code !== "ENOENT") throw error;
|
|
13508
|
+
return io.home();
|
|
13509
|
+
}
|
|
13510
|
+
}
|
|
13511
|
+
var init_invocation_directory = __esm({
|
|
13512
|
+
"packages/daemon/src/lib/invocation-directory.ts"() {
|
|
13513
|
+
"use strict";
|
|
13514
|
+
}
|
|
13515
|
+
});
|
|
13516
|
+
|
|
13371
13517
|
// packages/daemon/src/tui/mirror/hosted.ts
|
|
13372
13518
|
function wantsHostedApp(input) {
|
|
13373
13519
|
if (input.hostedEnv) return false;
|
|
@@ -15290,7 +15436,7 @@ var require_package = __commonJS({
|
|
|
15290
15436
|
"package.json"(exports, module) {
|
|
15291
15437
|
module.exports = {
|
|
15292
15438
|
name: "tmux-ide",
|
|
15293
|
-
version: "2.9.
|
|
15439
|
+
version: "2.9.26",
|
|
15294
15440
|
description: "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
|
|
15295
15441
|
type: "module",
|
|
15296
15442
|
bin: {
|
|
@@ -15329,6 +15475,7 @@ var require_package = __commonJS({
|
|
|
15329
15475
|
"test:tmux-boundary": "node scripts/test-tmux-boundary.mjs",
|
|
15330
15476
|
build: "pnpm build:cli",
|
|
15331
15477
|
"build:cli": "node scripts/build-cli.mjs",
|
|
15478
|
+
"check:cli-bundle": "node scripts/check-cli-bundle.mjs",
|
|
15332
15479
|
"build:macos-notifier": "node scripts/build-macos-notifier.mjs",
|
|
15333
15480
|
"build:tui": "bun scripts/build-tui.mjs",
|
|
15334
15481
|
prepack: "pnpm build:cli",
|
|
@@ -15352,7 +15499,8 @@ var require_package = __commonJS({
|
|
|
15352
15499
|
"test:pane-frame-package": "pnpm --filter @tmux-ide/presentation run test",
|
|
15353
15500
|
"typecheck:workspace": "turbo run typecheck",
|
|
15354
15501
|
"docs:build": "turbo run build --filter=@tmux-ide/docs",
|
|
15355
|
-
"pack:check": "pnpm test:installer &&
|
|
15502
|
+
"pack:check": "pnpm test:installer && pnpm test:workflow-contracts && node scripts/pack-tui-check.mjs",
|
|
15503
|
+
"test:workflow-contracts": "node --test scripts/lib/npm-release-tag.test.mjs scripts/lib/tap-bump-gate.test.mjs scripts/lib/macos-ssh-account.test.mjs scripts/lib/apt-dns-fallback.test.mjs scripts/lib/usvg-pin.test.mjs",
|
|
15356
15504
|
"test:pack-installed": "node scripts/pack-check-run.mjs",
|
|
15357
15505
|
"release:opentui:check": "node scripts/opentui-release-check.mjs",
|
|
15358
15506
|
"check:native-deps": "node packages/daemon/scripts/check-native-deps.mjs",
|
|
@@ -15397,6 +15545,7 @@ var require_package = __commonJS({
|
|
|
15397
15545
|
"typecheck:tui-gallery": "tsc --noEmit -p scripts/tsconfig.tui-gallery.json",
|
|
15398
15546
|
"test:spark-qualification": "node --import tsx --test scripts/lib/spark-*.test.ts scripts/lib/spark-*.test.mjs",
|
|
15399
15547
|
"test:installer": "node --test scripts/install.test.mjs scripts/lib/installer-service-qualification.test.mjs",
|
|
15548
|
+
"test:installer-native": "node --test scripts/install-native-alpha.test.mjs scripts/install-native-dispatch.test.mjs",
|
|
15400
15549
|
"qualify:styled-ssh": "node scripts/qualify-styled-ssh.mjs"
|
|
15401
15550
|
},
|
|
15402
15551
|
keywords: [
|
|
@@ -17760,7 +17909,7 @@ var init_front_door = __esm({
|
|
|
17760
17909
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
17761
17910
|
import { createHash as createHash7 } from "node:crypto";
|
|
17762
17911
|
import { readdirSync as readdirSync5, readFileSync as readFileSync13, readlinkSync as readlinkSync3, statSync as statSync7 } from "node:fs";
|
|
17763
|
-
import { homedir as
|
|
17912
|
+
import { homedir as homedir5 } from "node:os";
|
|
17764
17913
|
import { join as join19 } from "node:path";
|
|
17765
17914
|
function codexIdFromOpenFiles(paths) {
|
|
17766
17915
|
for (const path2 of paths) {
|
|
@@ -17959,8 +18108,8 @@ function liveProbeIo() {
|
|
|
17959
18108
|
openFiles: readOpenFiles,
|
|
17960
18109
|
processStartMs: (pid) => processStartMs(pid),
|
|
17961
18110
|
stateDir: liveStateDirIo,
|
|
17962
|
-
codexSessionsRoot: () => process.env.TMUX_IDE_CODEX_SESSIONS ?? join19(
|
|
17963
|
-
cursorChatsRoot: () => process.env.TMUX_IDE_CURSOR_CHATS ?? join19(
|
|
18111
|
+
codexSessionsRoot: () => process.env.TMUX_IDE_CODEX_SESSIONS ?? join19(homedir5(), ".codex", "sessions"),
|
|
18112
|
+
cursorChatsRoot: () => process.env.TMUX_IDE_CURSOR_CHATS ?? join19(homedir5(), ".cursor", "chats"),
|
|
17964
18113
|
now: () => Date.now()
|
|
17965
18114
|
};
|
|
17966
18115
|
}
|
|
@@ -19182,6 +19331,7 @@ function adoptSession(session, switcherCmd = "tmux-ide switcher") {
|
|
|
19182
19331
|
function unadoptSession(session) {
|
|
19183
19332
|
clearPaneChromeWindows([session]);
|
|
19184
19333
|
for (const argv of unadoptOptionCommands(session)) runTmux(argv);
|
|
19334
|
+
if (listAdoptedSessions().length > 0) return;
|
|
19185
19335
|
const keys = getAppConfig().keys;
|
|
19186
19336
|
for (const undo of [
|
|
19187
19337
|
statusClickUnbindCommand(),
|
|
@@ -19214,7 +19364,7 @@ function unadoptSession(session) {
|
|
|
19214
19364
|
} catch {
|
|
19215
19365
|
}
|
|
19216
19366
|
}
|
|
19217
|
-
|
|
19367
|
+
stopUpdater();
|
|
19218
19368
|
}
|
|
19219
19369
|
var POPUP_KEY, HOME_KEY, MENU_KEY, MENU_STATUS_KEY, MENU_PANE_KEY, STATUS_CLICK_KEY, PREFIX_TAKEN, PREFIX_REMAP, LEGACY_BINDS;
|
|
19220
19370
|
var init_statusline = __esm({
|
|
@@ -19757,7 +19907,109 @@ var init_notify_state = __esm({
|
|
|
19757
19907
|
}
|
|
19758
19908
|
});
|
|
19759
19909
|
|
|
19910
|
+
// packages/daemon/src/lib/daemon-crash-snapshot.ts
|
|
19911
|
+
function snapshotIsRestorePoint(existing, live) {
|
|
19912
|
+
if (!existing || !(live.serverStartMs > Date.parse(existing.savedAt))) return false;
|
|
19913
|
+
const running = new Set(live.sessions);
|
|
19914
|
+
return existing.sessions.some((session) => !running.has(session.name));
|
|
19915
|
+
}
|
|
19916
|
+
function createDaemonCrashSnapshot(deps2) {
|
|
19917
|
+
const { source } = deps2;
|
|
19918
|
+
let seen = null;
|
|
19919
|
+
return {
|
|
19920
|
+
async pulse() {
|
|
19921
|
+
let sessions;
|
|
19922
|
+
let panes;
|
|
19923
|
+
let existing;
|
|
19924
|
+
let serverStartMs = Number.NaN;
|
|
19925
|
+
try {
|
|
19926
|
+
sessions = await deps2.run(["list-sessions", "-F", source.sessionFormat]);
|
|
19927
|
+
if (sessions.split("\n").some((line) => line.split(" ")[0] === UPDATER_SESSION)) {
|
|
19928
|
+
seen = null;
|
|
19929
|
+
return "updater-writes";
|
|
19930
|
+
}
|
|
19931
|
+
panes = await deps2.run(["list-panes", "-a", "-F", source.paneFormat]);
|
|
19932
|
+
if (`${sessions}
|
|
19933
|
+
|
|
19934
|
+
${panes}` === seen) return "unchanged";
|
|
19935
|
+
existing = source.read();
|
|
19936
|
+
if (existing)
|
|
19937
|
+
serverStartMs = Number((await deps2.run(["display-message", "-p", "#{start_time}"])).trim()) * 1e3;
|
|
19938
|
+
} catch {
|
|
19939
|
+
return "tmux-unavailable";
|
|
19940
|
+
}
|
|
19941
|
+
const running = sessions.split("\n").map((line) => line.split(" ")[0]);
|
|
19942
|
+
if (snapshotIsRestorePoint(existing, { serverStartMs, sessions: running })) {
|
|
19943
|
+
seen = null;
|
|
19944
|
+
return "restore-point-kept";
|
|
19945
|
+
}
|
|
19946
|
+
const snapshot3 = await source.build(
|
|
19947
|
+
panes.split("\n").filter(Boolean),
|
|
19948
|
+
sessions.split("\n").filter(Boolean)
|
|
19949
|
+
);
|
|
19950
|
+
seen = `${sessions}
|
|
19951
|
+
|
|
19952
|
+
${panes}`;
|
|
19953
|
+
if (existing && source.fingerprint(existing) === source.fingerprint(snapshot3))
|
|
19954
|
+
return "unchanged";
|
|
19955
|
+
source.write(snapshot3);
|
|
19956
|
+
return "written";
|
|
19957
|
+
}
|
|
19958
|
+
};
|
|
19959
|
+
}
|
|
19960
|
+
function daemonCrashSnapshotStart(opts, run, retired) {
|
|
19961
|
+
return {
|
|
19962
|
+
launcher: opts.launcher ?? "embedded",
|
|
19963
|
+
source: opts.crashSnapshotSource,
|
|
19964
|
+
run,
|
|
19965
|
+
retired
|
|
19966
|
+
};
|
|
19967
|
+
}
|
|
19968
|
+
function startDaemonCrashSnapshot(deps2) {
|
|
19969
|
+
if (deps2.launcher !== "headless" || !deps2.source) return null;
|
|
19970
|
+
const snapshot3 = createDaemonCrashSnapshot({ run: deps2.run, source: deps2.source });
|
|
19971
|
+
let busy = false;
|
|
19972
|
+
const timer = setInterval(() => {
|
|
19973
|
+
if (deps2.retired()) {
|
|
19974
|
+
clearInterval(timer);
|
|
19975
|
+
return;
|
|
19976
|
+
}
|
|
19977
|
+
if (busy) return;
|
|
19978
|
+
busy = true;
|
|
19979
|
+
void snapshot3.pulse().catch(() => void 0).finally(() => {
|
|
19980
|
+
busy = false;
|
|
19981
|
+
});
|
|
19982
|
+
}, DAEMON_CRASH_SNAPSHOT_INTERVAL_MS);
|
|
19983
|
+
timer.unref?.();
|
|
19984
|
+
return () => clearInterval(timer);
|
|
19985
|
+
}
|
|
19986
|
+
var DAEMON_CRASH_SNAPSHOT_INTERVAL_MS;
|
|
19987
|
+
var init_daemon_crash_snapshot = __esm({
|
|
19988
|
+
"packages/daemon/src/lib/daemon-crash-snapshot.ts"() {
|
|
19989
|
+
"use strict";
|
|
19990
|
+
init_chrome_front_door();
|
|
19991
|
+
DAEMON_CRASH_SNAPSHOT_INTERVAL_MS = 3e4;
|
|
19992
|
+
}
|
|
19993
|
+
});
|
|
19994
|
+
|
|
19760
19995
|
// packages/daemon/src/tui/chrome/snapshot.ts
|
|
19996
|
+
var snapshot_exports = {};
|
|
19997
|
+
__export(snapshot_exports, {
|
|
19998
|
+
SNAPSHOT_EVERY: () => SNAPSHOT_EVERY,
|
|
19999
|
+
SNAPSHOT_PANE_FORMAT: () => SNAPSHOT_PANE_FORMAT,
|
|
20000
|
+
SNAPSHOT_SESSION_FORMAT: () => SNAPSHOT_SESSION_FORMAT,
|
|
20001
|
+
buildSnapshot: () => buildSnapshot,
|
|
20002
|
+
collectFleetSnapshot: () => collectFleetSnapshot,
|
|
20003
|
+
createSnapshotter: () => createSnapshotter,
|
|
20004
|
+
fleetCrashSnapshotSource: () => fleetCrashSnapshotSource,
|
|
20005
|
+
readSnapshot: () => readSnapshot,
|
|
20006
|
+
resolvePaneCommand: () => resolvePaneCommand,
|
|
20007
|
+
snapshotEvery: () => snapshotEvery,
|
|
20008
|
+
snapshotFingerprint: () => snapshotFingerprint,
|
|
20009
|
+
snapshotIsRestorePoint: () => snapshotIsRestorePoint,
|
|
20010
|
+
snapshotPath: () => snapshotPath,
|
|
20011
|
+
writeSnapshot: () => writeSnapshot
|
|
20012
|
+
});
|
|
19761
20013
|
import { existsSync as existsSync17, mkdirSync as mkdirSync15, readFileSync as readFileSync18, renameSync as renameSync9, writeFileSync as writeFileSync13 } from "node:fs";
|
|
19762
20014
|
import { dirname as dirname20, join as join24 } from "node:path";
|
|
19763
20015
|
import { z as z95 } from "zod";
|
|
@@ -19903,10 +20155,16 @@ function readSnapshot(path2 = snapshotPath()) {
|
|
|
19903
20155
|
return null;
|
|
19904
20156
|
}
|
|
19905
20157
|
}
|
|
20158
|
+
function snapshotEvery() {
|
|
20159
|
+
const raw = process.env.TMUX_IDE_SNAPSHOT_EVERY;
|
|
20160
|
+
const n = raw ? Number(raw) : NaN;
|
|
20161
|
+
return Number.isInteger(n) && n > 0 ? n : SNAPSHOT_EVERY;
|
|
20162
|
+
}
|
|
19906
20163
|
function createSnapshotter(deps2) {
|
|
19907
20164
|
let ticks = 0;
|
|
19908
20165
|
let seeded = false;
|
|
19909
20166
|
let lastFingerprint = null;
|
|
20167
|
+
let held = false;
|
|
19910
20168
|
return {
|
|
19911
20169
|
onTick() {
|
|
19912
20170
|
ticks++;
|
|
@@ -19917,6 +20175,23 @@ function createSnapshotter(deps2) {
|
|
|
19917
20175
|
seeded = true;
|
|
19918
20176
|
}
|
|
19919
20177
|
const snapshot3 = deps2.collect();
|
|
20178
|
+
if (deps2.serverStartMs) {
|
|
20179
|
+
const existing = deps2.read();
|
|
20180
|
+
let serverStartMs = Number.NaN;
|
|
20181
|
+
try {
|
|
20182
|
+
serverStartMs = deps2.serverStartMs();
|
|
20183
|
+
} catch {
|
|
20184
|
+
}
|
|
20185
|
+
const sessions = snapshot3.sessions.map((session) => session.name);
|
|
20186
|
+
if (snapshotIsRestorePoint(existing, { serverStartMs, sessions })) {
|
|
20187
|
+
held = true;
|
|
20188
|
+
return;
|
|
20189
|
+
}
|
|
20190
|
+
if (held) {
|
|
20191
|
+
held = false;
|
|
20192
|
+
lastFingerprint = existing ? snapshotFingerprint(existing) : null;
|
|
20193
|
+
}
|
|
20194
|
+
}
|
|
19920
20195
|
const fingerprint2 = snapshotFingerprint(snapshot3);
|
|
19921
20196
|
if (fingerprint2 === lastFingerprint) return;
|
|
19922
20197
|
lastFingerprint = fingerprint2;
|
|
@@ -19924,7 +20199,7 @@ function createSnapshotter(deps2) {
|
|
|
19924
20199
|
}
|
|
19925
20200
|
};
|
|
19926
20201
|
}
|
|
19927
|
-
var PaneSnapshotSchemaZ, WindowSnapshotSchemaZ, SessionSnapshotSchemaZ, FleetSnapshotSchemaZ, SNAPSHOT_PANE_FORMAT, SNAPSHOT_SESSION_FORMAT, defaultIo;
|
|
20202
|
+
var PaneSnapshotSchemaZ, WindowSnapshotSchemaZ, SessionSnapshotSchemaZ, FleetSnapshotSchemaZ, SNAPSHOT_PANE_FORMAT, SNAPSHOT_SESSION_FORMAT, defaultIo, SNAPSHOT_EVERY, fleetCrashSnapshotSource;
|
|
19928
20203
|
var init_snapshot2 = __esm({
|
|
19929
20204
|
"packages/daemon/src/tui/chrome/snapshot.ts"() {
|
|
19930
20205
|
"use strict";
|
|
@@ -19932,6 +20207,7 @@ var init_snapshot2 = __esm({
|
|
|
19932
20207
|
init_runtime_namespace();
|
|
19933
20208
|
init_src();
|
|
19934
20209
|
init_process_tree();
|
|
20210
|
+
init_daemon_crash_snapshot();
|
|
19935
20211
|
init_sessions2();
|
|
19936
20212
|
PaneSnapshotSchemaZ = z95.object({
|
|
19937
20213
|
index: z95.number(),
|
|
@@ -19981,6 +20257,15 @@ var init_snapshot2 = __esm({
|
|
|
19981
20257
|
listSessions: () => runTmux(["list-sessions", "-F", SNAPSHOT_SESSION_FORMAT]).toString(),
|
|
19982
20258
|
processTable: () => readProcessTable()
|
|
19983
20259
|
};
|
|
20260
|
+
SNAPSHOT_EVERY = 15;
|
|
20261
|
+
fleetCrashSnapshotSource = {
|
|
20262
|
+
sessionFormat: SNAPSHOT_SESSION_FORMAT,
|
|
20263
|
+
paneFormat: SNAPSHOT_PANE_FORMAT,
|
|
20264
|
+
build: async (panes, sessions) => buildSnapshot(panes, sessions, await readProcessTableAsync()),
|
|
20265
|
+
read: () => readSnapshot(),
|
|
20266
|
+
write: writeSnapshot,
|
|
20267
|
+
fingerprint: snapshotFingerprint
|
|
20268
|
+
};
|
|
19984
20269
|
}
|
|
19985
20270
|
});
|
|
19986
20271
|
|
|
@@ -20332,7 +20617,9 @@ function runUpdaterLoop() {
|
|
|
20332
20617
|
collect: () => collectFleetSnapshot(),
|
|
20333
20618
|
read: readSnapshot,
|
|
20334
20619
|
write: writeSnapshot,
|
|
20335
|
-
every: config2.updater.snapshotEvery
|
|
20620
|
+
every: config2.updater.snapshotEvery,
|
|
20621
|
+
// A dead server's snapshot is kept until its sessions are restored (#783).
|
|
20622
|
+
serverStartMs: () => Number(runTmux(["display-message", "-p", "#{start_time}"]).toString().trim()) * 1e3
|
|
20336
20623
|
});
|
|
20337
20624
|
const shouldGiveUp = createUnreachableCounter();
|
|
20338
20625
|
const tick = () => {
|
|
@@ -25998,6 +26285,7 @@ var canonical_daemon_bootstrap_exports = {};
|
|
|
25998
26285
|
__export(canonical_daemon_bootstrap_exports, {
|
|
25999
26286
|
assertCanonicalDaemonServerIntent: () => assertCanonicalDaemonServerIntent,
|
|
26000
26287
|
createCanonicalDaemonBootstrapCoordinator: () => createCanonicalDaemonBootstrapCoordinator,
|
|
26288
|
+
daemonServerProofPending: () => daemonServerProofPending,
|
|
26001
26289
|
ensureCanonicalDaemon: () => ensureCanonicalDaemon,
|
|
26002
26290
|
retireOutdatedCanonicalDaemon: () => retireOutdatedCanonicalDaemon
|
|
26003
26291
|
});
|
|
@@ -26128,6 +26416,9 @@ async function replaceOlderCanonicalDaemon(deps2, info, timeoutMs, expectedProdu
|
|
|
26128
26416
|
{ reason: "protocol-mismatch" }
|
|
26129
26417
|
);
|
|
26130
26418
|
}
|
|
26419
|
+
function daemonServerProofPending(error) {
|
|
26420
|
+
return error instanceof DaemonBootstrapError && error[DAEMON_PROOF_PENDING] === true;
|
|
26421
|
+
}
|
|
26131
26422
|
async function assertServerIntent(deps2, info, identity4, intent) {
|
|
26132
26423
|
if (!intent) return;
|
|
26133
26424
|
let proof = deps2.serverProof(intent);
|
|
@@ -26148,10 +26439,17 @@ async function assertServerIntent(deps2, info, identity4, intent) {
|
|
|
26148
26439
|
}
|
|
26149
26440
|
}
|
|
26150
26441
|
if (info.tmuxServerProofVersion !== 1 || !identity4.tmuxServerProof || !proof)
|
|
26151
|
-
throw
|
|
26152
|
-
|
|
26153
|
-
|
|
26154
|
-
|
|
26442
|
+
throw Object.assign(
|
|
26443
|
+
new DaemonBootstrapError(
|
|
26444
|
+
"incompatible",
|
|
26445
|
+
`Cannot prove the requested tmux server for this daemon. Its server identity is unavailable or unsupported; the existing daemon was left running. Proof availability: capability=${info.tmuxServerProofVersion === 1}, daemon=${Boolean(identity4.tmuxServerProof)}, client=${Boolean(proof)}.`,
|
|
26446
|
+
{ reason: "tmux-server-unproven" }
|
|
26447
|
+
),
|
|
26448
|
+
{
|
|
26449
|
+
// Either side's proof can be late (a slow tmux answer); only a daemon
|
|
26450
|
+
// without the capability can never prove it.
|
|
26451
|
+
[DAEMON_PROOF_PENDING]: info.tmuxServerProofVersion === 1
|
|
26452
|
+
}
|
|
26155
26453
|
);
|
|
26156
26454
|
if (identity4.tmuxServerProof.kind !== proof.kind || identity4.tmuxServerProof.digest !== proof.digest)
|
|
26157
26455
|
throw new DaemonBootstrapError(
|
|
@@ -26239,7 +26537,8 @@ function createCanonicalDaemonBootstrapCoordinator(options, dependencies = {}) {
|
|
|
26239
26537
|
options.expectedProductVersion,
|
|
26240
26538
|
options.tmuxServerIntent === void 0 ? resolveTmuxServerIntent() : options.tmuxServerIntent
|
|
26241
26539
|
),
|
|
26242
|
-
|
|
26540
|
+
// A deleted current directory starts the daemon from home (#585).
|
|
26541
|
+
spawn: () => deps2.spawnOwner(resolve18(options.entryPath), resolve18(options.cwd ?? invocationDirectory())),
|
|
26243
26542
|
timeoutMs: options.timeoutMs,
|
|
26244
26543
|
onPhaseChanged: options.onPhaseChanged,
|
|
26245
26544
|
now: deps2.now,
|
|
@@ -26337,11 +26636,12 @@ async function assertCanonicalDaemonServerIntent(info, intent = resolveTmuxServe
|
|
|
26337
26636
|
);
|
|
26338
26637
|
await assertServerIntent(deps2, info, identity4, intent);
|
|
26339
26638
|
}
|
|
26340
|
-
var ShutdownTransportError, defaultDependencies;
|
|
26639
|
+
var ShutdownTransportError, defaultDependencies, DAEMON_PROOF_PENDING;
|
|
26341
26640
|
var init_canonical_daemon_bootstrap = __esm({
|
|
26342
26641
|
"packages/daemon/src/lib/canonical-daemon-bootstrap.ts"() {
|
|
26343
26642
|
"use strict";
|
|
26344
26643
|
init_tmux_server_proof();
|
|
26644
|
+
init_invocation_directory();
|
|
26345
26645
|
init_workspace_pane_creation2();
|
|
26346
26646
|
init_runtime_namespace();
|
|
26347
26647
|
init_semver();
|
|
@@ -26378,6 +26678,7 @@ var init_canonical_daemon_bootstrap = __esm({
|
|
|
26378
26678
|
setTimeout(resolveSleep, milliseconds);
|
|
26379
26679
|
})
|
|
26380
26680
|
};
|
|
26681
|
+
DAEMON_PROOF_PENDING = /* @__PURE__ */ Symbol("daemon-server-proof-pending");
|
|
26381
26682
|
}
|
|
26382
26683
|
});
|
|
26383
26684
|
|
|
@@ -28115,7 +28416,7 @@ function parseSessionPaneDescriptorReply(lines) {
|
|
|
28115
28416
|
continue;
|
|
28116
28417
|
}
|
|
28117
28418
|
const encoded = utf8Line.split(" ");
|
|
28118
|
-
if (encoded.length < 21 || encoded.length >
|
|
28419
|
+
if (encoded.length < 21 || encoded.length > 26) continue;
|
|
28119
28420
|
const [
|
|
28120
28421
|
runtimePaneId = "",
|
|
28121
28422
|
semanticPaneId3 = "",
|
|
@@ -28141,7 +28442,8 @@ function parseSessionPaneDescriptorReply(lines) {
|
|
|
28141
28442
|
nameSource2 = "",
|
|
28142
28443
|
browserIconRaw = "",
|
|
28143
28444
|
readerRaw = "",
|
|
28144
|
-
panePidRaw = ""
|
|
28445
|
+
panePidRaw = "",
|
|
28446
|
+
browserControl = ""
|
|
28145
28447
|
] = encoded.map(decodeTmuxArgument);
|
|
28146
28448
|
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32) continue;
|
|
28147
28449
|
if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32) continue;
|
|
@@ -28160,6 +28462,7 @@ function parseSessionPaneDescriptorReply(lines) {
|
|
|
28160
28462
|
}
|
|
28161
28463
|
descriptors.push({
|
|
28162
28464
|
browserIcon: browserIcon(browserIconRaw),
|
|
28465
|
+
browserKind: terminalBrowserKind(browserControl, currentCommand),
|
|
28163
28466
|
reader: readerOption(readerRaw, panePidRaw),
|
|
28164
28467
|
sessionName,
|
|
28165
28468
|
runtimePaneId,
|
|
@@ -28202,6 +28505,17 @@ function decodeControlReplyUtf8(value) {
|
|
|
28202
28505
|
function positiveInteger(value, fallback) {
|
|
28203
28506
|
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
28204
28507
|
}
|
|
28508
|
+
function terminalBrowserKind(control, currentCommand, alive = processAlive) {
|
|
28509
|
+
if (control.length > 0 && control.length <= 4096) {
|
|
28510
|
+
try {
|
|
28511
|
+
const pid = JSON.parse(control)?.pid;
|
|
28512
|
+
if (typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && alive(pid))
|
|
28513
|
+
return "native";
|
|
28514
|
+
} catch {
|
|
28515
|
+
}
|
|
28516
|
+
}
|
|
28517
|
+
return /^terminal-browser?$/u.test(currentCommand) ? "plain" : null;
|
|
28518
|
+
}
|
|
28205
28519
|
var SESSION_PANE_DESCRIPTOR_FORMAT, VOLATILE_DESCRIPTOR_FIELDS, SessionDescriptorDiscovery, STRICT_UTF8_DECODER;
|
|
28206
28520
|
var init_session_descriptor_discovery = __esm({
|
|
28207
28521
|
"packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts"() {
|
|
@@ -28234,7 +28548,9 @@ var init_session_descriptor_discovery = __esm({
|
|
|
28234
28548
|
"#{qa:@tmux_ide_browser_icon}",
|
|
28235
28549
|
"#{qa:@tmux_ide_reader}",
|
|
28236
28550
|
// The reader option belongs to the pane only when its own process set it.
|
|
28237
|
-
"#{pane_pid}"
|
|
28551
|
+
"#{pane_pid}",
|
|
28552
|
+
// Set only by a terminal browser that has tmux-ide's native controls (#718).
|
|
28553
|
+
"#{qa:@tmux_ide_browser_control}"
|
|
28238
28554
|
].join(" ");
|
|
28239
28555
|
VOLATILE_DESCRIPTOR_FIELDS = /* @__PURE__ */ new Set([
|
|
28240
28556
|
4,
|
|
@@ -29644,9 +29960,13 @@ function semanticPaneIds(session) {
|
|
|
29644
29960
|
}
|
|
29645
29961
|
return result2;
|
|
29646
29962
|
}
|
|
29647
|
-
function
|
|
29648
|
-
|
|
29649
|
-
|
|
29963
|
+
function readTmuxSessions() {
|
|
29964
|
+
let raw;
|
|
29965
|
+
try {
|
|
29966
|
+
raw = _tmuxRunner(["list-sessions", "-F", "#{session_name}"]);
|
|
29967
|
+
} catch (error) {
|
|
29968
|
+
return serverNotRunning(error) ? [] : null;
|
|
29969
|
+
}
|
|
29650
29970
|
return raw.split("\n").filter(Boolean);
|
|
29651
29971
|
}
|
|
29652
29972
|
function discoverLiveSessionSummaries(runTmux2 = _tmuxRunner) {
|
|
@@ -29823,7 +30143,11 @@ function assembleAdoptedFleet(adopted, panesRaw, registry, nativeEpoch, resolveI
|
|
|
29823
30143
|
});
|
|
29824
30144
|
}
|
|
29825
30145
|
function discoverSessions() {
|
|
29826
|
-
|
|
30146
|
+
return readSessions() ?? [];
|
|
30147
|
+
}
|
|
30148
|
+
function readSessions() {
|
|
30149
|
+
const sessionNames = readTmuxSessions();
|
|
30150
|
+
if (sessionNames === null) return null;
|
|
29827
30151
|
const results = [];
|
|
29828
30152
|
const registry = getDefaultWorkspaceRegistry();
|
|
29829
30153
|
const enforceRegistry = registry._isLoaded();
|
|
@@ -29873,7 +30197,9 @@ var init_discovery = __esm({
|
|
|
29873
30197
|
_tmuxRunner = (args) => execFileSync16("tmux", ["-u", ...runtimeTmuxArgs(args)], {
|
|
29874
30198
|
encoding: "utf-8",
|
|
29875
30199
|
maxBuffer: 1024 * 1024,
|
|
29876
|
-
|
|
30200
|
+
// Keep stderr on the error: it is how a caller tells "no server running"
|
|
30201
|
+
// from a server it could not reach. Nothing is printed either way.
|
|
30202
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
29877
30203
|
}).trim();
|
|
29878
30204
|
ADOPTED_SESSIONS_ARGS = ["list-sessions", "-F", `#{session_name} #{${ADOPTED_OPTION}}`];
|
|
29879
30205
|
FLEET_FIELD_SEPARATOR = "|tmux-ide-fleet-field-v1|";
|
|
@@ -34399,6 +34725,9 @@ var init_session_channel = __esm({
|
|
|
34399
34725
|
await this.captureAttachedSessionIdentity();
|
|
34400
34726
|
this.io.send("refresh-client -B 'tmux-ide-browser-icon:%*:#{@tmux_ide_browser_icon}'");
|
|
34401
34727
|
this.io.send("refresh-client -B 'tmux-ide-reader:%*:#{@tmux_ide_reader}'");
|
|
34728
|
+
this.io.send(
|
|
34729
|
+
"refresh-client -B 'tmux-ide-browser-kind:%*:#{@tmux_ide_browser_control}#{m:terminal-browse*,#{pane_current_command}}'"
|
|
34730
|
+
);
|
|
34402
34731
|
this.io.send("refresh-client -B 'tmux-ide-pane-borders:@*:#{pane-border-status}'");
|
|
34403
34732
|
this.io.send("refresh-client -B 'tmux-ide-copy-keys:@*:#{mode-keys}'");
|
|
34404
34733
|
this.io.send("refresh-client -B 'tmux-ide-pane-history:%*:#{history_size}'");
|
|
@@ -34828,10 +35157,35 @@ var init_session_channel = __esm({
|
|
|
34828
35157
|
}
|
|
34829
35158
|
this.input.flush();
|
|
34830
35159
|
this.clearWindowViewports();
|
|
34831
|
-
this.
|
|
35160
|
+
const target = this.attachedIdentity?.runtimeSessionId ?? `=${this.opts.session}`;
|
|
35161
|
+
this.restoreWindowSizing(target);
|
|
34832
35162
|
this.io.send(`refresh-client -C ${cols}x${rows}${this.cellPixelSuffix()}`);
|
|
35163
|
+
this.reclaimWindowSize(target);
|
|
34833
35164
|
this.clientViewport = { cols, rows };
|
|
34834
35165
|
}
|
|
35166
|
+
/**
|
|
35167
|
+
* Under `window-size latest` a second tmux client on the session (a terminal
|
|
35168
|
+
* the user also attached) takes the window, and nothing this control client
|
|
35169
|
+
* sends makes it tmux's latest client again: input and refresh-client are not
|
|
35170
|
+
* client activity. Output then prints at the other client's width and tmux
|
|
35171
|
+
* re-wraps it mid-word when that width goes away (#695). A fit is the app
|
|
35172
|
+
* being used (it fits on focus and on a change of its canvas), so after one,
|
|
35173
|
+
* when the window is not this client's size, switch to the same session:
|
|
35174
|
+
* that makes this client the latest one. Only here, never on a timer or a
|
|
35175
|
+
* notification, so two clients never fight; whichever the user used last
|
|
35176
|
+
* wins, as between two terminals. Other window-size policies are the user's.
|
|
35177
|
+
*/
|
|
35178
|
+
reclaimWindowSize(target) {
|
|
35179
|
+
if (!this.geometryParticipating) return;
|
|
35180
|
+
const quoted = tmuxSingleQuote(target);
|
|
35181
|
+
this.io.commandListInline(
|
|
35182
|
+
`if-shell -F -t ${quoted} '#{&&:#{==:#{window-size},latest},#{||:#{!=:#{window_width},#{client_width}},#{!=:#{window_height},#{client_height}}}}' ` + tmuxSingleQuote(`switch-client -t ${quoted}`) + " " + tmuxSingleQuote(`display-message -p -t ${quoted} ''`),
|
|
35183
|
+
2,
|
|
35184
|
+
1,
|
|
35185
|
+
() => {
|
|
35186
|
+
}
|
|
35187
|
+
);
|
|
35188
|
+
}
|
|
34835
35189
|
clientViewport = null;
|
|
34836
35190
|
cellPixels = null;
|
|
34837
35191
|
/** "/WxH" for tmux's refresh-client -C (patched tmux; stock ignores it). */
|
|
@@ -36075,7 +36429,7 @@ var init_session_channel = __esm({
|
|
|
36075
36429
|
onNotify(name, rest) {
|
|
36076
36430
|
if (name === "window-add" || name === "window-close" || name === "unlinked-window-add" || name === "unlinked-window-close" || name === "session-renamed" || name === "sessions-changed")
|
|
36077
36431
|
this.opts.onWindowTopologyChanged?.();
|
|
36078
|
-
if (name === "subscription-changed" && (rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader "))) {
|
|
36432
|
+
if (name === "subscription-changed" && (rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader ") || rest.startsWith("tmux-ide-browser-kind "))) {
|
|
36079
36433
|
this.scheduleSync();
|
|
36080
36434
|
return;
|
|
36081
36435
|
}
|
|
@@ -36396,6 +36750,7 @@ var init_session_channel = __esm({
|
|
|
36396
36750
|
displayName: display?.name ?? null,
|
|
36397
36751
|
displayNameSource: display?.source ?? null,
|
|
36398
36752
|
browserIcon: pane?.descriptor?.browserIcon ?? null,
|
|
36753
|
+
browserKind: pane?.descriptor?.browserKind ?? null,
|
|
36399
36754
|
reader: pane?.descriptor?.reader ?? null,
|
|
36400
36755
|
left: leaf.left,
|
|
36401
36756
|
top: leaf.top,
|
|
@@ -44536,6 +44891,28 @@ var init_mirror_service = __esm({
|
|
|
44536
44891
|
wasPending: this.registeredWindows?.pending() ?? null
|
|
44537
44892
|
});
|
|
44538
44893
|
this.registeredWindows?.invalidate();
|
|
44894
|
+
this.scheduleOwnershipVerify();
|
|
44895
|
+
}
|
|
44896
|
+
/**
|
|
44897
|
+
* Until a read proves ownership again, every retained session refuses input
|
|
44898
|
+
* and geometry. A workspace added or removed (another session created or
|
|
44899
|
+
* killed) invalidates without any channel resyncing, and nothing else read
|
|
44900
|
+
* again until the next stream was issued: the next keystroke closed the
|
|
44901
|
+
* stream. Read again at once (coalesced) while a channel is retained; a
|
|
44902
|
+
* failed read takes the #764 retry path.
|
|
44903
|
+
*/
|
|
44904
|
+
ownershipVerifyScheduled = false;
|
|
44905
|
+
scheduleOwnershipVerify() {
|
|
44906
|
+
if (this.ownershipVerifyScheduled || this.disposed) return;
|
|
44907
|
+
this.ownershipVerifyScheduled = true;
|
|
44908
|
+
const timer = setTimeout(() => {
|
|
44909
|
+
this.ownershipVerifyScheduled = false;
|
|
44910
|
+
if (this.disposed || this.channelSessions.size === 0 || !this.registeredWindows?.pending())
|
|
44911
|
+
return;
|
|
44912
|
+
void this.verifyRegisteredWindows().catch(() => {
|
|
44913
|
+
});
|
|
44914
|
+
}, 0);
|
|
44915
|
+
timer.unref?.();
|
|
44539
44916
|
}
|
|
44540
44917
|
/**
|
|
44541
44918
|
* #764: a failed re-read must not leave every session "being verified"
|
|
@@ -44868,6 +45245,10 @@ var init_mirror_service = __esm({
|
|
|
44868
45245
|
const message = this.windowOwnershipMessage(session);
|
|
44869
45246
|
if (message) throw new Error(message);
|
|
44870
45247
|
}
|
|
45248
|
+
/** Registered-window ownership is being read again; input waits for it. */
|
|
45249
|
+
windowOwnershipPending() {
|
|
45250
|
+
return this.registeredWindows?.pending() ?? false;
|
|
45251
|
+
}
|
|
44871
45252
|
windowOwnershipMessage(session) {
|
|
44872
45253
|
if (this.registeredWindows?.pending())
|
|
44873
45254
|
return "Window ownership is being verified. Retry after session discovery completes.";
|
|
@@ -62690,6 +63071,9 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
62690
63071
|
#terminal;
|
|
62691
63072
|
#rowCache = /* @__PURE__ */ new WeakMap();
|
|
62692
63073
|
#scrollEpoch = 0;
|
|
63074
|
+
#historyLimit;
|
|
63075
|
+
#collecting = false;
|
|
63076
|
+
#lastYbase = null;
|
|
62693
63077
|
#lastScrollEpoch = 0;
|
|
62694
63078
|
#lastViewportY = 0;
|
|
62695
63079
|
#lastBufferType = "normal";
|
|
@@ -62702,11 +63086,16 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
62702
63086
|
#historyProjectionInvalidated = false;
|
|
62703
63087
|
#scrollOnClear;
|
|
62704
63088
|
constructor(options) {
|
|
63089
|
+
const historyLimit = options.historyLimit ?? options.scrollback;
|
|
63090
|
+
this.#historyLimit = historyLimit;
|
|
62705
63091
|
this.#terminal = new Terminal2({
|
|
62706
63092
|
cols: options.cols,
|
|
62707
63093
|
rows: options.rows,
|
|
62708
|
-
|
|
62709
|
-
|
|
63094
|
+
// One row of headroom over what the replica may hold (the limit, or a
|
|
63095
|
+
// larger captured history): xterm must not recycle the row a scroll
|
|
63096
|
+
// adds before #collectHistory sees it.
|
|
63097
|
+
scrollback: historyLimit > 0 ? Math.max(options.scrollback, historyLimit) + 1 : options.scrollback,
|
|
63098
|
+
tmuxHistoryLimit: historyLimit,
|
|
62710
63099
|
allowProposedApi: true
|
|
62711
63100
|
});
|
|
62712
63101
|
this.#terminal.loadAddon(new import_addon_unicode11.Unicode11Addon());
|
|
@@ -62736,7 +63125,9 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
62736
63125
|
return false;
|
|
62737
63126
|
});
|
|
62738
63127
|
this.#terminal.onScroll(() => {
|
|
62739
|
-
if (this.#terminal.buffer.active.type
|
|
63128
|
+
if (this.#terminal.buffer.active.type !== "normal") return;
|
|
63129
|
+
this.#scrollEpoch += 1;
|
|
63130
|
+
this.#collectHistory();
|
|
62740
63131
|
});
|
|
62741
63132
|
const core = this.#terminal._core;
|
|
62742
63133
|
if (!core?.coreService) {
|
|
@@ -62744,6 +63135,34 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
62744
63135
|
throw new Error("Unsupported @tmux-ide/xterm-headless private API shape");
|
|
62745
63136
|
}
|
|
62746
63137
|
}
|
|
63138
|
+
/**
|
|
63139
|
+
* tmux at its history-limit collects the oldest tenth of history before a
|
|
63140
|
+
* scroll would pass it (grid_collect_history), so its history_size moves
|
|
63141
|
+
* between 0.9 and 1.0 of the limit. Recycling one row at a time instead kept
|
|
63142
|
+
* the replica at the limit, and the owner's history-size check then reseeded
|
|
63143
|
+
* the whole pane each time its output paused. The projection reports the
|
|
63144
|
+
* collection as an ordinary history trim.
|
|
63145
|
+
*/
|
|
63146
|
+
startHistoryCollection() {
|
|
63147
|
+
this.#collecting = true;
|
|
63148
|
+
this.#lastYbase = this.#normalBuffer()?.ybase ?? null;
|
|
63149
|
+
}
|
|
63150
|
+
#normalBuffer() {
|
|
63151
|
+
return this.#terminal._core?.buffers?.normal;
|
|
63152
|
+
}
|
|
63153
|
+
#collectHistory() {
|
|
63154
|
+
const buffer = this.#normalBuffer();
|
|
63155
|
+
if (!buffer) return;
|
|
63156
|
+
const before = this.#lastYbase;
|
|
63157
|
+
const limit = this.#historyLimit;
|
|
63158
|
+
if (this.#collecting && limit > 0 && before !== null && before >= limit && buffer.ybase === before + 1) {
|
|
63159
|
+
const trim = Math.min(buffer.ybase, Math.max(1, Math.floor(limit / 10)));
|
|
63160
|
+
buffer.lines.trimStart(trim);
|
|
63161
|
+
buffer.ybase -= trim;
|
|
63162
|
+
buffer.ydisp = Math.max(0, buffer.ydisp - trim);
|
|
63163
|
+
}
|
|
63164
|
+
this.#lastYbase = buffer.ybase;
|
|
63165
|
+
}
|
|
62747
63166
|
get cols() {
|
|
62748
63167
|
return this.#terminal.cols;
|
|
62749
63168
|
}
|
|
@@ -63521,16 +63940,27 @@ var init_kitty_graphics = __esm({
|
|
|
63521
63940
|
#pending = null;
|
|
63522
63941
|
#nextAnonymous = 2130706432;
|
|
63523
63942
|
#bytes = 0;
|
|
63943
|
+
/** Cell size in thousandths of a device pixel. */
|
|
63524
63944
|
#cellWidth;
|
|
63525
63945
|
#cellHeight;
|
|
63526
63946
|
#budget;
|
|
63527
63947
|
#revision = 0;
|
|
63528
63948
|
constructor(options = {}) {
|
|
63529
|
-
this.#cellWidth = options.cellWidthPx ?? 10;
|
|
63530
|
-
this.#cellHeight = options.cellHeightPx ?? 20;
|
|
63949
|
+
this.#cellWidth = (options.cellWidthPx ?? 10) * 1e3;
|
|
63950
|
+
this.#cellHeight = (options.cellHeightPx ?? 20) * 1e3;
|
|
63531
63951
|
this.#budget = options.budget ?? DEFAULT_KITTY_IMAGE_BUDGET;
|
|
63532
63952
|
this.#budget.register(this);
|
|
63533
63953
|
}
|
|
63954
|
+
/**
|
|
63955
|
+
* The renderer's cell size in device pixels, with thousandths when it reports
|
|
63956
|
+
* them (capability 103/104). Placements made from now on that give no `c`/`r`
|
|
63957
|
+
* cover the image at this size; earlier ones keep their grid.
|
|
63958
|
+
*/
|
|
63959
|
+
setCellPixels(width, height, precise) {
|
|
63960
|
+
if (!(width > 0 && height > 0)) return;
|
|
63961
|
+
this.#cellWidth = precise && precise.width > 0 ? precise.width : width * 1e3;
|
|
63962
|
+
this.#cellHeight = precise && precise.height > 0 ? precise.height : height * 1e3;
|
|
63963
|
+
}
|
|
63534
63964
|
/** Bumps whenever images or placements change. */
|
|
63535
63965
|
get revision() {
|
|
63536
63966
|
return this.#revision;
|
|
@@ -63646,8 +64076,12 @@ var init_kitty_graphics = __esm({
|
|
|
63646
64076
|
const image = this.#images.get(imageId);
|
|
63647
64077
|
if (!image) return;
|
|
63648
64078
|
this.#used.set(imageId, this.#budget.nextTick());
|
|
63649
|
-
const columns = clampCells(
|
|
63650
|
-
|
|
64079
|
+
const columns = clampCells(
|
|
64080
|
+
int(control, "c") || Math.ceil(image.width * 1e3 / this.#cellWidth)
|
|
64081
|
+
);
|
|
64082
|
+
const rows = clampCells(
|
|
64083
|
+
int(control, "r") || Math.ceil(image.height * 1e3 / this.#cellHeight)
|
|
64084
|
+
);
|
|
63651
64085
|
const placementId = int(control, "p");
|
|
63652
64086
|
if (control.get("U") === "1") {
|
|
63653
64087
|
const placements = this.#virtual.get(imageId) ?? /* @__PURE__ */ new Map();
|
|
@@ -63874,6 +64308,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63874
64308
|
"packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts"() {
|
|
63875
64309
|
"use strict";
|
|
63876
64310
|
init_stock_capture_fidelity();
|
|
64311
|
+
init_log();
|
|
63877
64312
|
init_native_seed_backing();
|
|
63878
64313
|
init_src2();
|
|
63879
64314
|
init_src3();
|
|
@@ -63890,6 +64325,9 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63890
64325
|
#nativeSeedBackingCandidate;
|
|
63891
64326
|
#generation;
|
|
63892
64327
|
#workspaceName;
|
|
64328
|
+
#stockTabsNoted = false;
|
|
64329
|
+
#seedOrdinal = 0;
|
|
64330
|
+
#reconstructedSeed = null;
|
|
63893
64331
|
#semanticPaneId;
|
|
63894
64332
|
#incarnation;
|
|
63895
64333
|
#scrollback;
|
|
@@ -63969,6 +64407,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63969
64407
|
rows: options.rows,
|
|
63970
64408
|
scrollback: this.#scrollback
|
|
63971
64409
|
});
|
|
64410
|
+
this.#backend.startHistoryCollection?.();
|
|
63972
64411
|
this.#kitty = new KittyImageStore(
|
|
63973
64412
|
options.kittyImageBudget ? { budget: options.kittyImageBudget } : {}
|
|
63974
64413
|
);
|
|
@@ -64026,6 +64465,14 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64026
64465
|
currentSeed() {
|
|
64027
64466
|
return this.#needsSeed ? null : this.#seed();
|
|
64028
64467
|
}
|
|
64468
|
+
/**
|
|
64469
|
+
* Names the current seed when its tab cells were reconstructed from a stock
|
|
64470
|
+
* capture; null otherwise. Such a seed can wrap a reflowed line at other
|
|
64471
|
+
* places than tmux does, so its history can differ from tmux's in length.
|
|
64472
|
+
*/
|
|
64473
|
+
reconstructedSeed() {
|
|
64474
|
+
return this.#reconstructedSeed;
|
|
64475
|
+
}
|
|
64029
64476
|
/** Prioritize one future parser admission, independent of diagnostic tracing. */
|
|
64030
64477
|
prioritizeNextWrite() {
|
|
64031
64478
|
if (!this.#closed) this.#prioritizeNextWrite = true;
|
|
@@ -64086,7 +64533,9 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64086
64533
|
async #apply(operation) {
|
|
64087
64534
|
if (this.#closed) return;
|
|
64088
64535
|
if (operation.type === "reseed") {
|
|
64089
|
-
|
|
64536
|
+
const paintCapturedTabs = operation.bootstrap === "painted-capture" && !operation.native;
|
|
64537
|
+
let seedReconstructed;
|
|
64538
|
+
if (paintCapturedTabs && !this.#backend.graphicsCursor)
|
|
64090
64539
|
assertStockCaptureRepresentable(operation.captureChunks ?? operation.chunks);
|
|
64091
64540
|
this.#causalCell?.fail("reseeded");
|
|
64092
64541
|
const nativeCols = operation.nativeCols ?? operation.cols;
|
|
@@ -64105,9 +64554,18 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64105
64554
|
try {
|
|
64106
64555
|
if (operation.native && !replacement.importNativeGrid?.(operation.native))
|
|
64107
64556
|
throw new Error("Native bootstrap requires a compatible interpreter");
|
|
64557
|
+
const captured = operation.captureChunks ?? operation.chunks;
|
|
64558
|
+
let nextCaptured = 0;
|
|
64559
|
+
let reconstructed = false;
|
|
64108
64560
|
for (const chunk of operation.chunks) {
|
|
64109
|
-
|
|
64561
|
+
const fromCapture = paintCapturedTabs && nextCaptured < captured.length && Buffer.compare(chunk, captured[nextCaptured]) === 0;
|
|
64562
|
+
if (fromCapture) nextCaptured += 1;
|
|
64563
|
+
if (fromCapture && chunk.includes(9)) {
|
|
64564
|
+
reconstructed = true;
|
|
64565
|
+
await this.#writeStockCapture(replacement, chunk);
|
|
64566
|
+
} else await this.#writeToBackend(replacement, chunk);
|
|
64110
64567
|
}
|
|
64568
|
+
seedReconstructed = reconstructed;
|
|
64111
64569
|
if (operation.wraparound !== void 0)
|
|
64112
64570
|
replacement.setAuthoritativeWraparound(operation.wraparound);
|
|
64113
64571
|
if (operation.observedModes) replacement.setAuthoritativeModes(operation.observedModes);
|
|
@@ -64127,12 +64585,15 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64127
64585
|
this.#admitRaw(chunk);
|
|
64128
64586
|
this.#observeMarkerBytes(chunk);
|
|
64129
64587
|
}
|
|
64588
|
+
replacement.startHistoryCollection?.();
|
|
64130
64589
|
const previous = this.#backend;
|
|
64131
64590
|
this.#backend = replacement;
|
|
64132
64591
|
this.#attachKitty(replacement);
|
|
64133
64592
|
const sameGraphicsBasis = operation.bootstrap === "painted-capture" && previous.cols === replacement.cols && previous.rows === replacement.rows && previous.graphicsViewportTop?.() !== void 0 && previous.graphicsViewportTop?.() === replacement.graphicsViewportTop?.() && previous.modes().alternateScreen === replacement.modes().alternateScreen;
|
|
64134
64593
|
if (!sameGraphicsBasis) this.#kitty.dropCursorPlacements();
|
|
64135
64594
|
this.#nativeReseedRequested = false;
|
|
64595
|
+
this.#seedOrdinal += 1;
|
|
64596
|
+
this.#reconstructedSeed = seedReconstructed ? this.#seedOrdinal : null;
|
|
64136
64597
|
this.#scrollback = scrollback;
|
|
64137
64598
|
this.#bootstrap = {
|
|
64138
64599
|
kind: operation.bootstrap,
|
|
@@ -64272,6 +64733,42 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64272
64733
|
this.#tail = run.catch(() => void 0);
|
|
64273
64734
|
}, 250);
|
|
64274
64735
|
}
|
|
64736
|
+
/**
|
|
64737
|
+
* Replay one stock `capture-pane -e` chunk. tmux stores a tab as one wide
|
|
64738
|
+
* cell and prints it as a single HT, without its width. Blank the cells up
|
|
64739
|
+
* to the next default tab stop instead (ECH, then CUF): that is the cell tmux
|
|
64740
|
+
* made when the tab was written at this column, and erased cells take the
|
|
64741
|
+
* rendition the capture set for it, as tmux's blank tab cell does. tmux never
|
|
64742
|
+
* tabs into the last column (`input_c0_dispatch`).
|
|
64743
|
+
* Where this differs from tmux: a row edited after its tab was written
|
|
64744
|
+
* (insert or delete character) or written under custom tab stops is columns
|
|
64745
|
+
* off in that row. A line reflowed by a resize is worse: tmux keeps the tab
|
|
64746
|
+
* cell's width, this measures it again from the new column, so the line can
|
|
64747
|
+
* wrap at other places and the pane can hold other rows than tmux shows,
|
|
64748
|
+
* until that output scrolls away or is redrawn. The owner accepts the
|
|
64749
|
+
* resulting difference in history length (`reconstructedSeed`).
|
|
64750
|
+
*/
|
|
64751
|
+
async #writeStockCapture(backend2, chunk) {
|
|
64752
|
+
let start3 = 0;
|
|
64753
|
+
for (; ; ) {
|
|
64754
|
+
const tab = chunk.indexOf(9, start3);
|
|
64755
|
+
if (tab < 0) break;
|
|
64756
|
+
if (tab > start3) await this.#writeToBackend(backend2, chunk.subarray(start3, tab));
|
|
64757
|
+
const column = backend2.graphicsCursor().x;
|
|
64758
|
+
const stop3 = Math.min(backend2.cols - 1, (Math.floor(column / 8) + 1) * 8);
|
|
64759
|
+
if (stop3 > column)
|
|
64760
|
+
await this.#writeToBackend(backend2, `\x1B[${stop3 - column}X\x1B[${stop3 - column}C`);
|
|
64761
|
+
start3 = tab + 1;
|
|
64762
|
+
}
|
|
64763
|
+
if (!this.#stockTabsNoted) {
|
|
64764
|
+
this.#stockTabsNoted = true;
|
|
64765
|
+
logger.info("terminal-replica", "stock capture: tab positions reconstructed", {
|
|
64766
|
+
pane: this.#semanticPaneId,
|
|
64767
|
+
workspace: this.#workspaceName
|
|
64768
|
+
});
|
|
64769
|
+
}
|
|
64770
|
+
if (start3 < chunk.length) await this.#writeToBackend(backend2, chunk.subarray(start3));
|
|
64771
|
+
}
|
|
64275
64772
|
#writeToBackend(backend2, data) {
|
|
64276
64773
|
if (this.#prioritizeNextWrite) {
|
|
64277
64774
|
this.#prioritizeNextWrite = false;
|
|
@@ -64730,6 +65227,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
64730
65227
|
#historyTimer = null;
|
|
64731
65228
|
#historyChecking = false;
|
|
64732
65229
|
#historyDirty = false;
|
|
65230
|
+
#reconstructedHistoryGap = null;
|
|
64733
65231
|
installOutputTraceReader(reader) {
|
|
64734
65232
|
this.#takeOutputTrace ??= reader;
|
|
64735
65233
|
}
|
|
@@ -64893,6 +65391,10 @@ var init_terminal_replica_owner = __esm({
|
|
|
64893
65391
|
if (current) listener(current);
|
|
64894
65392
|
return this.#interpreter.onGraphics(listener);
|
|
64895
65393
|
}
|
|
65394
|
+
/** The renderer's cell size, for image placements that give no `c`/`r` (group H). */
|
|
65395
|
+
setCellPixels(width, height, precise) {
|
|
65396
|
+
this.#interpreter.kittyImages().setCellPixels(width, height, precise);
|
|
65397
|
+
}
|
|
64896
65398
|
/** Image bytes by content digest, while the pane's store still holds them. */
|
|
64897
65399
|
graphicsImage(digest3) {
|
|
64898
65400
|
return this.#interpreter.kittyImages().imageByDigest(digest3) ?? null;
|
|
@@ -64951,7 +65453,17 @@ var init_terminal_replica_owner = __esm({
|
|
|
64951
65453
|
this.#historyDirty || this.#stale || this.#reseed || this.#waitingForGeometryCapture || size === null)
|
|
64952
65454
|
return;
|
|
64953
65455
|
const seed = this.#interpreter.currentSeed();
|
|
64954
|
-
if (seed
|
|
65456
|
+
if (!seed) return;
|
|
65457
|
+
const gap = size - seed.snapshot.history.length;
|
|
65458
|
+
const reconstructed = this.#interpreter.reconstructedSeed();
|
|
65459
|
+
if (reconstructed !== null) {
|
|
65460
|
+
if (this.#reconstructedHistoryGap?.seed !== reconstructed) {
|
|
65461
|
+
this.#reconstructedHistoryGap = { seed: reconstructed, gap };
|
|
65462
|
+
return;
|
|
65463
|
+
}
|
|
65464
|
+
if (this.#reconstructedHistoryGap.gap === gap) return;
|
|
65465
|
+
} else if (gap === 0) return;
|
|
65466
|
+
upstream.reseed();
|
|
64955
65467
|
} catch {
|
|
64956
65468
|
} finally {
|
|
64957
65469
|
this.#historyChecking = false;
|
|
@@ -65451,15 +65963,16 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
65451
65963
|
patch: update.patch
|
|
65452
65964
|
};
|
|
65453
65965
|
const snapshot3 = target.state.snapshot;
|
|
65454
|
-
|
|
65966
|
+
const trim = baseline ? historyTrim(baseline.history, snapshot3.history) : 0;
|
|
65967
|
+
if (baseline && baselineIncarnation === update.incarnation && baseline.cols === snapshot3.cols && baseline.rows === snapshot3.rows && baseline.history.length - trim <= snapshot3.history.length) {
|
|
65455
65968
|
let comparisonCells = 0;
|
|
65456
65969
|
const equal = (left, right) => {
|
|
65457
65970
|
if (left === right) return true;
|
|
65458
65971
|
comparisonCells += right.cells.length;
|
|
65459
65972
|
return comparisonCells <= TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS ? terminalReplicaRowsEqual(left, right) : null;
|
|
65460
65973
|
};
|
|
65461
|
-
for (let index =
|
|
65462
|
-
if (equal(baseline.history[index], snapshot3.history[index]) !== true)
|
|
65974
|
+
for (let index = trim; index < baseline.history.length; index++)
|
|
65975
|
+
if (equal(baseline.history[index], snapshot3.history[index - trim]) !== true)
|
|
65463
65976
|
return semanticSeed(target);
|
|
65464
65977
|
const rows = [];
|
|
65465
65978
|
for (let index = 0; index < snapshot3.grid.length; index++) {
|
|
@@ -65467,17 +65980,18 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
65467
65980
|
if (same7 === null) return semanticSeed(target);
|
|
65468
65981
|
if (!same7) rows.push({ index, row: snapshot3.grid[index] });
|
|
65469
65982
|
}
|
|
65470
|
-
const
|
|
65983
|
+
const retained = baseline.history.length - trim;
|
|
65984
|
+
const appendedRows = snapshot3.history.length - retained;
|
|
65471
65985
|
if ((rows.length + appendedRows) * snapshot3.cols >= TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS)
|
|
65472
65986
|
return semanticSeed(target);
|
|
65473
|
-
const append = snapshot3.history.slice(
|
|
65987
|
+
const append = snapshot3.history.slice(retained);
|
|
65474
65988
|
return {
|
|
65475
65989
|
frame: "patch",
|
|
65476
65990
|
baseRevision: baselineRevision,
|
|
65477
65991
|
revision: update.revision,
|
|
65478
65992
|
patch: {
|
|
65479
65993
|
rows,
|
|
65480
|
-
...append.length ? { historyDelta: { trim
|
|
65994
|
+
...append.length || trim ? { historyDelta: { trim, append } } : {},
|
|
65481
65995
|
cursor: snapshot3.cursor,
|
|
65482
65996
|
modes: snapshot3.modes,
|
|
65483
65997
|
placements: snapshot3.placements,
|
|
@@ -65487,6 +66001,25 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
65487
66001
|
}
|
|
65488
66002
|
return semanticSeed(target);
|
|
65489
66003
|
}
|
|
66004
|
+
function historyTrim(baseline, target) {
|
|
66005
|
+
const first = target[0];
|
|
66006
|
+
if (first === void 0 || baseline[0] === first) return 0;
|
|
66007
|
+
let candidates = 0;
|
|
66008
|
+
for (let trim = 1; trim < baseline.length; trim++) {
|
|
66009
|
+
if (baseline[trim] !== first) continue;
|
|
66010
|
+
if (++candidates > 4) return 0;
|
|
66011
|
+
const retained = baseline.length - trim;
|
|
66012
|
+
if (retained > target.length) continue;
|
|
66013
|
+
let same7 = true;
|
|
66014
|
+
for (let index = 0; index < retained; index++)
|
|
66015
|
+
if (baseline[trim + index] !== target[index]) {
|
|
66016
|
+
same7 = false;
|
|
66017
|
+
break;
|
|
66018
|
+
}
|
|
66019
|
+
if (same7) return trim;
|
|
66020
|
+
}
|
|
66021
|
+
return 0;
|
|
66022
|
+
}
|
|
65490
66023
|
function canonicalUpdateCellCost(update) {
|
|
65491
66024
|
if (update.type === "terminal.tombstone") return 0;
|
|
65492
66025
|
if (update.type === "terminal.seed")
|
|
@@ -65549,7 +66082,7 @@ function logDeliveryFault(client, reason, cause) {
|
|
|
65549
66082
|
workspace: client.deliveryWorkspaceName
|
|
65550
66083
|
});
|
|
65551
66084
|
}
|
|
65552
|
-
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;
|
|
66085
|
+
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, TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES, TERMINAL_DELIVERY_CONNECTION_HOLD_MS, TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS, DeferredProjectionEncoding, DeferredSeedEncoding, ExactSemanticRepresentationSelectionError, TerminalDeliveryRepresentationSelectionError, TerminalDeliveryPreaccountLimitError, SessionRuntimeTerminalDeliveryHub;
|
|
65553
66086
|
var init_terminal_delivery_hub = __esm({
|
|
65554
66087
|
"packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts"() {
|
|
65555
66088
|
"use strict";
|
|
@@ -65573,6 +66106,9 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65573
66106
|
MAX_PENDING_CANONICAL_CELLS = 1e6;
|
|
65574
66107
|
MAX_CONNECTIONS = MAX_CLIENTS * MAX_PANES;
|
|
65575
66108
|
BACKGROUND_CADENCE_MS = 100;
|
|
66109
|
+
TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES = 256 * 1024;
|
|
66110
|
+
TERMINAL_DELIVERY_CONNECTION_HOLD_MS = 250;
|
|
66111
|
+
TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS = 30;
|
|
65576
66112
|
DeferredProjectionEncoding = class extends Error {
|
|
65577
66113
|
constructor(payload) {
|
|
65578
66114
|
super("Deferred projection encoding");
|
|
@@ -65624,6 +66160,8 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65624
66160
|
this.generation = generation;
|
|
65625
66161
|
this.workspaceName = workspaceName;
|
|
65626
66162
|
this.#ownerForPane = ownerForPane;
|
|
66163
|
+
this.#holdMs = options.connectionHoldMs ?? TERMINAL_DELIVERY_CONNECTION_HOLD_MS;
|
|
66164
|
+
this.#congestedMs = options.connectionCongestedMs ?? TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS;
|
|
65627
66165
|
this.#scheduler = options.scheduler ?? SYSTEM_SESSION_RUNTIME_SCHEDULER;
|
|
65628
66166
|
this.#observability = options.observability ?? DISABLED_SESSION_RUNTIME_OBSERVABILITY;
|
|
65629
66167
|
}
|
|
@@ -65634,6 +66172,8 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65634
66172
|
#observability;
|
|
65635
66173
|
#panes = /* @__PURE__ */ new Map();
|
|
65636
66174
|
#clients = /* @__PURE__ */ new Map();
|
|
66175
|
+
/** Per connection: the pane it last typed into. */
|
|
66176
|
+
#priority = /* @__PURE__ */ new Map();
|
|
65637
66177
|
#sourceCloseFailures = 0;
|
|
65638
66178
|
#pendingSourceCloses = 0;
|
|
65639
66179
|
/** Synchronous reservations held while an async pane source is starting. */
|
|
@@ -65651,6 +66191,8 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65651
66191
|
#deliveryLifecycleOrdinal = 0;
|
|
65652
66192
|
#deliveryStatusOrdinal = 0;
|
|
65653
66193
|
#closed = false;
|
|
66194
|
+
#holdMs;
|
|
66195
|
+
#congestedMs;
|
|
65654
66196
|
async open(clientId, semanticPaneId3, offerInput, accept, diagnosticIdentity = Object.freeze({ clientId, surface: "direct", laneId: clientId }), deliveryWorkspaceName = this.workspaceName) {
|
|
65655
66197
|
if (this.#closed) throw new Error("Terminal delivery hub is closed");
|
|
65656
66198
|
const address = WorkspaceIdSchemaZ.parse(deliveryWorkspaceName);
|
|
@@ -65712,7 +66254,10 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65712
66254
|
captureUnavailable: false,
|
|
65713
66255
|
lastAck: null,
|
|
65714
66256
|
sourceClosedFlight: null,
|
|
65715
|
-
backgroundTimer: null
|
|
66257
|
+
backgroundTimer: null,
|
|
66258
|
+
budgetHeld: false,
|
|
66259
|
+
budgetHeldSince: null,
|
|
66260
|
+
budgetTimer: null
|
|
65716
66261
|
};
|
|
65717
66262
|
this.#clients.set(key2, client);
|
|
65718
66263
|
client.lifecycleOpenRecorded = this.#recordDeliveryLifecycle(client, pane, "open");
|
|
@@ -65725,6 +66270,11 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65725
66270
|
projectionReceipt: (receipt) => this.#projectionReceipt(client, receipt),
|
|
65726
66271
|
materialize: (request3) => this.#materialize(client, request3),
|
|
65727
66272
|
nack: (nack) => this.#nack(client, nack),
|
|
66273
|
+
prioritize: () => {
|
|
66274
|
+
if (client.closed) return;
|
|
66275
|
+
this.#priority.set(client.clientId, client.paneId);
|
|
66276
|
+
this.#releaseBudget(client.clientId);
|
|
66277
|
+
},
|
|
65728
66278
|
setVisibility: (visibilityInput) => {
|
|
65729
66279
|
if (client.closed) return;
|
|
65730
66280
|
client.visibility = TerminalDeliveryVisibilitySchemaZ.parse(visibilityInput);
|
|
@@ -65902,6 +66452,7 @@ var init_terminal_delivery_hub = __esm({
|
|
|
65902
66452
|
this.#cancelEncoding(client);
|
|
65903
66453
|
client.outgoing.length = 0;
|
|
65904
66454
|
client.inFlight = null;
|
|
66455
|
+
client.budgetHeld = false;
|
|
65905
66456
|
logDeliveryFault(client, "source-closed", "source-restarted");
|
|
65906
66457
|
this.#enqueue(client, {
|
|
65907
66458
|
type: "terminal.delivery.fault",
|
|
@@ -66186,6 +66737,32 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66186
66737
|
pane.rawFloorRevision = Math.max(pane.rawFloorRevision, first[0] + 1);
|
|
66187
66738
|
}
|
|
66188
66739
|
}
|
|
66740
|
+
#overBudget(client) {
|
|
66741
|
+
if (this.#priority.get(client.clientId) === client.paneId) return false;
|
|
66742
|
+
if (client.budgetHeldSince !== null && this.#scheduler.nowMs() - client.budgetHeldSince >= this.#holdMs)
|
|
66743
|
+
return false;
|
|
66744
|
+
const now = this.#scheduler.nowMs();
|
|
66745
|
+
let bytes = 0;
|
|
66746
|
+
let oldest = now;
|
|
66747
|
+
for (const other of this.#clients.values())
|
|
66748
|
+
if (other !== client && other.clientId === client.clientId && other.inFlight) {
|
|
66749
|
+
bytes += other.inFlight.envelope.representationBytes;
|
|
66750
|
+
oldest = Math.min(oldest, other.inFlight.sentAt);
|
|
66751
|
+
}
|
|
66752
|
+
return bytes >= TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES && now - oldest >= this.#congestedMs;
|
|
66753
|
+
}
|
|
66754
|
+
/** A pane's delivery settled or left: held panes of its connection try again, typed-into pane first. */
|
|
66755
|
+
#releaseBudget(clientId) {
|
|
66756
|
+
const held = [...this.#clients.values()].filter(
|
|
66757
|
+
(other) => other.clientId === clientId && other.budgetHeld
|
|
66758
|
+
);
|
|
66759
|
+
const priority = this.#priority.get(clientId);
|
|
66760
|
+
held.sort((a, b) => Number(b.paneId === priority) - Number(a.paneId === priority));
|
|
66761
|
+
for (const other of held) {
|
|
66762
|
+
other.budgetHeld = false;
|
|
66763
|
+
this.#schedule(other);
|
|
66764
|
+
}
|
|
66765
|
+
}
|
|
66189
66766
|
#schedule(client) {
|
|
66190
66767
|
if (client.closed || client.captureUnavailable || client.inFlight || client.encoding || client.latestRevision === null || client.latestRevision === client.baselineRevision || client.visibility === "hidden" || client.visibility === "frozen")
|
|
66191
66768
|
return;
|
|
@@ -66211,6 +66788,20 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66211
66788
|
const target = completed?.target ?? pane?.latest;
|
|
66212
66789
|
if (!pane || !target || client.closed || client.captureUnavailable || client.inFlight || client.encoding || client.visibility === "hidden" || client.visibility === "frozen" || !completed && target.update.revision !== client.latestRevision)
|
|
66213
66790
|
return;
|
|
66791
|
+
if (!completed && this.#overBudget(client)) {
|
|
66792
|
+
client.budgetHeld = true;
|
|
66793
|
+
client.budgetHeldSince ??= this.#scheduler.nowMs();
|
|
66794
|
+
client.budgetTimer ??= this.#scheduler.timer(() => {
|
|
66795
|
+
client.budgetTimer = null;
|
|
66796
|
+
if (client.closed || !client.budgetHeld) return;
|
|
66797
|
+
client.budgetHeld = false;
|
|
66798
|
+
this.#schedule(client);
|
|
66799
|
+
}, this.#holdMs);
|
|
66800
|
+
return;
|
|
66801
|
+
}
|
|
66802
|
+
client.budgetHeldSince = null;
|
|
66803
|
+
client.budgetTimer?.cancel();
|
|
66804
|
+
client.budgetTimer = null;
|
|
66214
66805
|
const traceStarted = completed?.traceStarted ?? (this.#observability.enabled ? this.#observability.nowMicros() : 0);
|
|
66215
66806
|
let deferred = false;
|
|
66216
66807
|
let encodedRepresentation = null;
|
|
@@ -66779,6 +67370,7 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66779
67370
|
client.baselineHash = ack.canonicalStateHash;
|
|
66780
67371
|
client.reseedRequired = false;
|
|
66781
67372
|
client.inFlight = null;
|
|
67373
|
+
this.#releaseBudget(client.clientId);
|
|
66782
67374
|
client.lastAck = ack;
|
|
66783
67375
|
if (client.latestRevision === ack.canonicalRevision) client.latestRevision = null;
|
|
66784
67376
|
this.#pruneAckSupersededCache(client.paneId);
|
|
@@ -66846,6 +67438,7 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66846
67438
|
client.lastProjectionReceipt = receipt;
|
|
66847
67439
|
client.reseedRequired = false;
|
|
66848
67440
|
client.inFlight = null;
|
|
67441
|
+
this.#releaseBudget(client.clientId);
|
|
66849
67442
|
if (client.latestRevision === receipt.canonicalRevision) client.latestRevision = null;
|
|
66850
67443
|
if (client.materializeRequested)
|
|
66851
67444
|
client.latestRevision = this.#panes.get(client.paneId)?.latest?.update.revision ?? null;
|
|
@@ -66885,6 +67478,7 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66885
67478
|
this.#nacks += 1;
|
|
66886
67479
|
client.reseedRequired = true;
|
|
66887
67480
|
client.inFlight = null;
|
|
67481
|
+
this.#releaseBudget(client.clientId);
|
|
66888
67482
|
this.#pruneCanonicalRevisions(client.paneId);
|
|
66889
67483
|
this.#schedule(client);
|
|
66890
67484
|
this.#recordDeliveryStatus(client, this.#panes.get(client.paneId));
|
|
@@ -66930,6 +67524,7 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66930
67524
|
client.outgoing.length = 0;
|
|
66931
67525
|
if (reason === "source-closed") client.sourceClosedFlight = client.inFlight?.envelope ?? null;
|
|
66932
67526
|
client.inFlight = null;
|
|
67527
|
+
this.#releaseBudget(client.clientId);
|
|
66933
67528
|
const fault = {
|
|
66934
67529
|
type: "terminal.delivery.fault",
|
|
66935
67530
|
reason,
|
|
@@ -66998,8 +67593,13 @@ var init_terminal_delivery_hub = __esm({
|
|
|
66998
67593
|
if (client.lifecycleOpenRecorded)
|
|
66999
67594
|
this.#recordDeliveryLifecycle(client, this.#panes.get(client.paneId), "close");
|
|
67000
67595
|
client.backgroundTimer?.cancel();
|
|
67596
|
+
client.budgetTimer?.cancel();
|
|
67597
|
+
client.budgetTimer = null;
|
|
67001
67598
|
client.outgoing.length = 0;
|
|
67002
67599
|
this.#clients.delete(client.key);
|
|
67600
|
+
if (![...this.#clients.values()].some((other) => other.clientId === client.clientId))
|
|
67601
|
+
this.#priority.delete(client.clientId);
|
|
67602
|
+
else this.#releaseBudget(client.clientId);
|
|
67003
67603
|
this.#pruneCanonicalRevisions(client.paneId);
|
|
67004
67604
|
if ([...this.#clients.values()].some((candidate) => candidate.paneId === client.paneId)) return;
|
|
67005
67605
|
const pane = this.#panes.get(client.paneId);
|
|
@@ -67457,7 +68057,7 @@ function authoredOriginForSurface(surface) {
|
|
|
67457
68057
|
if (surface === "cli") return "cli";
|
|
67458
68058
|
return "gui";
|
|
67459
68059
|
}
|
|
67460
|
-
var emptyListenerDisposal, SessionRuntimeControllerLeaseError, SessionRuntimeRegistry, SessionRuntime, SessionRuntimeConsumerImpl;
|
|
68060
|
+
var emptyListenerDisposal, SessionRuntimeControllerLeaseError, SessionRuntimeInputLifetimeEndedError, SessionRuntimeRegistry, SessionRuntime, SessionRuntimeConsumerImpl;
|
|
67461
68061
|
var init_registry2 = __esm({
|
|
67462
68062
|
"packages/daemon/src/terminal/session-runtime/registry.ts"() {
|
|
67463
68063
|
"use strict";
|
|
@@ -67494,6 +68094,12 @@ var init_registry2 = __esm({
|
|
|
67494
68094
|
}
|
|
67495
68095
|
code;
|
|
67496
68096
|
};
|
|
68097
|
+
SessionRuntimeInputLifetimeEndedError = class extends Error {
|
|
68098
|
+
constructor(message) {
|
|
68099
|
+
super(message);
|
|
68100
|
+
this.name = "SessionRuntimeInputLifetimeEndedError";
|
|
68101
|
+
}
|
|
68102
|
+
};
|
|
67497
68103
|
SessionRuntimeRegistry = class {
|
|
67498
68104
|
generation;
|
|
67499
68105
|
#mirror;
|
|
@@ -67783,6 +68389,10 @@ var init_registry2 = __esm({
|
|
|
67783
68389
|
async verifyWindowOwnership() {
|
|
67784
68390
|
await this.#mirror.verifyRegisteredWindows();
|
|
67785
68391
|
}
|
|
68392
|
+
/** Ownership is being read again: input and geometry wait, they are not refused for good. */
|
|
68393
|
+
windowOwnershipPending() {
|
|
68394
|
+
return !this.#disposed && this.#mirror.windowOwnershipPending();
|
|
68395
|
+
}
|
|
67786
68396
|
/** Install the bounded registered-session membership reader. */
|
|
67787
68397
|
setRegisteredWindowReader(reader) {
|
|
67788
68398
|
return this.#mirror.setRegisteredWindowReader(reader);
|
|
@@ -68254,6 +68864,8 @@ var init_registry2 = __esm({
|
|
|
68254
68864
|
#consumersByClientId = /* @__PURE__ */ new Map();
|
|
68255
68865
|
#terminalReplicas = /* @__PURE__ */ new Map();
|
|
68256
68866
|
#terminalReplicaClocks = /* @__PURE__ */ new Map();
|
|
68867
|
+
/** The renderer's last reported cell size; every pane's image placements use it. */
|
|
68868
|
+
#cellPixels = null;
|
|
68257
68869
|
#outputTraces;
|
|
68258
68870
|
#outputObservations = /* @__PURE__ */ new Map();
|
|
68259
68871
|
#createTraceCorrelator;
|
|
@@ -68511,7 +69123,8 @@ var init_registry2 = __esm({
|
|
|
68511
69123
|
}) : null;
|
|
68512
69124
|
const started = this.#observability.enabled ? this.#observability.nowMicros() : 0;
|
|
68513
69125
|
const replicaOwner = expectedLifetime ? this.#terminalReplicas.get(semanticPaneId3) : this.#terminalReplicaOwner(semanticPaneId3);
|
|
68514
|
-
if (!replicaOwner)
|
|
69126
|
+
if (!replicaOwner)
|
|
69127
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime unavailable");
|
|
68515
69128
|
if (causalProbe) {
|
|
68516
69129
|
this.#activeCausalCellProbes += 1;
|
|
68517
69130
|
let settled = false;
|
|
@@ -68535,7 +69148,7 @@ var init_registry2 = __esm({
|
|
|
68535
69148
|
}
|
|
68536
69149
|
try {
|
|
68537
69150
|
if (expectedLifetime && (expectedLifetime.generation !== this.generation || this.#terminalReplicas.get(semanticPaneId3) !== replicaOwner || replicaOwner.inputAdmissionIncarnation() !== expectedLifetime.incarnation))
|
|
68538
|
-
throw new
|
|
69151
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime changed");
|
|
68539
69152
|
if (input.kind === "text")
|
|
68540
69153
|
this.#mirror.sendText(
|
|
68541
69154
|
this.session,
|
|
@@ -68635,6 +69248,9 @@ var init_registry2 = __esm({
|
|
|
68635
69248
|
setCellPixels(clientId, width, height, precise) {
|
|
68636
69249
|
this.#assertConnected(clientId);
|
|
68637
69250
|
this.#mirror.setCellPixels?.(this.session, width, height, precise);
|
|
69251
|
+
this.#cellPixels = { width, height, ...precise ? { precise } : {} };
|
|
69252
|
+
for (const owner of this.#terminalReplicas.values())
|
|
69253
|
+
owner.setCellPixels(width, height, precise);
|
|
68638
69254
|
}
|
|
68639
69255
|
fitViewportWithAuthority(clientId, lease, cols, rows, semanticWindowId) {
|
|
68640
69256
|
this.assertGeometryAuthority(clientId, lease);
|
|
@@ -68804,6 +69420,12 @@ var init_registry2 = __esm({
|
|
|
68804
69420
|
}
|
|
68805
69421
|
);
|
|
68806
69422
|
owner = candidate;
|
|
69423
|
+
if (this.#cellPixels)
|
|
69424
|
+
owner.setCellPixels(
|
|
69425
|
+
this.#cellPixels.width,
|
|
69426
|
+
this.#cellPixels.height,
|
|
69427
|
+
this.#cellPixels.precise
|
|
69428
|
+
);
|
|
68807
69429
|
this.#terminalReplicas.set(semanticPaneId3, owner);
|
|
68808
69430
|
}
|
|
68809
69431
|
return owner;
|
|
@@ -69165,6 +69787,7 @@ var init_registry2 = __esm({
|
|
|
69165
69787
|
ack: (ack) => upstream.ack(ack),
|
|
69166
69788
|
...upstream.projectionReceipt ? { projectionReceipt: upstream.projectionReceipt } : {},
|
|
69167
69789
|
...upstream.materialize ? { materialize: upstream.materialize } : {},
|
|
69790
|
+
...upstream.prioritize ? { prioritize: upstream.prioritize } : {},
|
|
69168
69791
|
nack: (nack) => upstream.nack(nack),
|
|
69169
69792
|
setVisibility: (visibility) => upstream.setVisibility(visibility),
|
|
69170
69793
|
close: async () => {
|
|
@@ -69415,6 +70038,40 @@ var init_transport_binding = __esm({
|
|
|
69415
70038
|
);
|
|
69416
70039
|
this.#binder.registry.assertExecutionHandle(this.#baseHandle, semanticPaneId3);
|
|
69417
70040
|
}
|
|
70041
|
+
/**
|
|
70042
|
+
* The session's pane set changed under this live transport (#723). The
|
|
70043
|
+
* caller is the daemon's own stream boundary, and the panes come from its
|
|
70044
|
+
* trusted inventory of this binding's session: a client can never name a
|
|
70045
|
+
* pane here. The grant stays exact: added panes join it, removed panes leave
|
|
70046
|
+
* it, and every execution handle is rebuilt from the amended set.
|
|
70047
|
+
* All-or-nothing: an invalid pane id changes nothing.
|
|
70048
|
+
*/
|
|
70049
|
+
amendPaneGrant(change) {
|
|
70050
|
+
this.#assertOpen();
|
|
70051
|
+
const added = change.added.map(
|
|
70052
|
+
(paneId) => TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId)
|
|
70053
|
+
);
|
|
70054
|
+
const removed = change.removed.map(
|
|
70055
|
+
(paneId) => TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId)
|
|
70056
|
+
);
|
|
70057
|
+
for (const paneId of removed) {
|
|
70058
|
+
if (!this.#allowedSourcePaneIds.delete(paneId)) continue;
|
|
70059
|
+
if (!this.#contributedSourcePaneIds.delete(paneId)) continue;
|
|
70060
|
+
const next = (this.#shared.grantRefs.get(paneId) ?? 0) - 1;
|
|
70061
|
+
if (next > 0) this.#shared.grantRefs.set(paneId, next);
|
|
70062
|
+
else this.#shared.grantRefs.delete(paneId);
|
|
70063
|
+
}
|
|
70064
|
+
for (const paneId of added) {
|
|
70065
|
+
if (this.#allowedSourcePaneIds.has(paneId)) continue;
|
|
70066
|
+
this.#allowedSourcePaneIds.add(paneId);
|
|
70067
|
+
if (!this.#interactive) continue;
|
|
70068
|
+
this.#contributedSourcePaneIds.add(paneId);
|
|
70069
|
+
this.#shared.grantRefs.set(paneId, (this.#shared.grantRefs.get(paneId) ?? 0) + 1);
|
|
70070
|
+
}
|
|
70071
|
+
this.#baseHandle = null;
|
|
70072
|
+
this.#baseHandleLease = null;
|
|
70073
|
+
this.#intentHandles.clear();
|
|
70074
|
+
}
|
|
69418
70075
|
openTerminalDelivery(semanticPaneId3, offer, onMessage, deliveryWorkspaceName) {
|
|
69419
70076
|
const address = WorkspaceIdSchemaZ.parse(deliveryWorkspaceName ?? this.session);
|
|
69420
70077
|
this.#assertOpen();
|
|
@@ -75644,6 +76301,7 @@ var init_lease_manager2 = __esm({
|
|
|
75644
76301
|
sessionName: state.sessionName,
|
|
75645
76302
|
runtimeSessionId: state.runtimeSessionId,
|
|
75646
76303
|
panes: [...state.request.panes],
|
|
76304
|
+
semanticWindowId: state.request.semanticWindowId ?? null,
|
|
75647
76305
|
viewerMode: state.request.viewerMode,
|
|
75648
76306
|
terminalDelivery: state.request.terminalDelivery ?? null,
|
|
75649
76307
|
status: state.status,
|
|
@@ -76017,6 +76675,26 @@ function rawGraphicsState(state) {
|
|
|
76017
76675
|
placements: state.placements.filter((placement) => kept.has(placement.digest))
|
|
76018
76676
|
};
|
|
76019
76677
|
}
|
|
76678
|
+
function newPaneChannel(pane) {
|
|
76679
|
+
return {
|
|
76680
|
+
semanticPaneId: pane,
|
|
76681
|
+
sub: null,
|
|
76682
|
+
delivery: null,
|
|
76683
|
+
deliveryAddress: null,
|
|
76684
|
+
serverSeq: 0,
|
|
76685
|
+
sentPaneFrames: 0,
|
|
76686
|
+
consumedSeq: 0,
|
|
76687
|
+
nextInputSeq: 1,
|
|
76688
|
+
frozenByWire: false,
|
|
76689
|
+
closed: false,
|
|
76690
|
+
batch: null,
|
|
76691
|
+
graphicsAnnounced: false,
|
|
76692
|
+
graphicsQueue: [],
|
|
76693
|
+
graphicsSending: false,
|
|
76694
|
+
graphicsServed: /* @__PURE__ */ new Map(),
|
|
76695
|
+
graphicsState: null
|
|
76696
|
+
};
|
|
76697
|
+
}
|
|
76020
76698
|
function concatBytes(chunks) {
|
|
76021
76699
|
if (chunks.length === 0) return new Uint8Array(0);
|
|
76022
76700
|
if (chunks.length === 1) return chunks[0];
|
|
@@ -76039,7 +76717,7 @@ function chunkBytes(data, maxChunk) {
|
|
|
76039
76717
|
}
|
|
76040
76718
|
return chunks;
|
|
76041
76719
|
}
|
|
76042
|
-
var PANE_STREAM_MAX_REDEMPTION_BYTES, PANE_STREAM_MAX_CONTROL_BYTES, PANE_STREAM_DAEMON_SHUTDOWN_CLOSE, PANE_STREAM_OWNER_RETIRED_CLOSE, PANE_STREAM_DAEMON_RESTARTING_CLOSE, PANE_STREAM_MAX_REDEMPTION_MS, WS_OPEN3, CANONICAL_KEY_INPUT_FRAME_PREFIX, CANONICAL_TEXT_INPUT_FRAME_PREFIX, SEMANTIC_BACKEND_REFUSALS, TYPE_FIRST_INPUT_FRAME_PREFIX, TicketPattern3, BindingIdSchemaZ4, PaneStreamAdmissionError, PaneStreamAdmissionCoordinator, PreAuthAdmission2, GRAPHICS_MAX_QUEUED_DIGESTS, GRAPHICS_SEND_WINDOW_BYTES, PaneStreamLiveConnection;
|
|
76720
|
+
var PANE_STREAM_MAX_REDEMPTION_BYTES, PANE_STREAM_MAX_CONTROL_BYTES, PANE_STREAM_DAEMON_SHUTDOWN_CLOSE, PANE_STREAM_OWNER_RETIRED_CLOSE, PANE_STREAM_DAEMON_RESTARTING_CLOSE, PANE_STREAM_MAX_REDEMPTION_MS, WS_OPEN3, CANONICAL_KEY_INPUT_FRAME_PREFIX, CANONICAL_TEXT_INPUT_FRAME_PREFIX, SEMANTIC_BACKEND_REFUSALS, TYPE_FIRST_INPUT_FRAME_PREFIX, TicketPattern3, BindingIdSchemaZ4, PaneStreamAdmissionError, PaneStreamAdmissionCoordinator, PreAuthAdmission2, PANE_STREAM_TOPOLOGY_SETTLE_MS, PANE_STREAM_OPEN_RETRY_DELAYS_MS, PANE_STREAM_OWNERSHIP_WAIT_MS, PANE_STREAM_OWNERSHIP_HELD_FRAMES, GRAPHICS_MAX_QUEUED_DIGESTS, GRAPHICS_SEND_WINDOW_BYTES, PaneStreamLiveConnection;
|
|
76043
76721
|
var init_pane_stream_websocket = __esm({
|
|
76044
76722
|
"packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts"() {
|
|
76045
76723
|
"use strict";
|
|
@@ -76104,6 +76782,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76104
76782
|
#redemptionTimeoutMs;
|
|
76105
76783
|
#flowBudgets;
|
|
76106
76784
|
#drainTickMs;
|
|
76785
|
+
#openRetryDelaysMs;
|
|
76786
|
+
#ownershipWaitMs;
|
|
76107
76787
|
#maxSocketBufferedBytes;
|
|
76108
76788
|
#maxInputFrames;
|
|
76109
76789
|
#maxInputBytes;
|
|
@@ -76143,6 +76823,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76143
76823
|
this.#flowBudgets = options.flowBudgets ?? DEFAULT_PANE_STREAM_FLOW_BUDGETS;
|
|
76144
76824
|
this.#ledger = new PaneStreamWireLedger(this.#flowBudgets);
|
|
76145
76825
|
this.#drainTickMs = boundedInteger2(options.drainTickMs, 15, 1e3);
|
|
76826
|
+
this.#openRetryDelaysMs = options.openRetryDelaysMs ?? PANE_STREAM_OPEN_RETRY_DELAYS_MS;
|
|
76827
|
+
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
76146
76828
|
this.#maxSocketBufferedBytes = boundedInteger2(
|
|
76147
76829
|
options.maxSocketBufferedBytes,
|
|
76148
76830
|
32 << 20,
|
|
@@ -76229,6 +76911,16 @@ var init_pane_stream_websocket = __esm({
|
|
|
76229
76911
|
);
|
|
76230
76912
|
}
|
|
76231
76913
|
}
|
|
76914
|
+
if (request3.semanticWindowId !== void 0) {
|
|
76915
|
+
const windowPanes = new Set(
|
|
76916
|
+
described.panes.filter((pane) => pane.semanticWindowId === request3.semanticWindowId).map((pane) => pane.semanticPaneId)
|
|
76917
|
+
);
|
|
76918
|
+
if (windowPanes.size !== request3.panes.length || request3.panes.some((pane) => !windowPanes.has(pane)))
|
|
76919
|
+
throw new PaneStreamAdmissionError(
|
|
76920
|
+
"pane-not-found",
|
|
76921
|
+
"The panes are not exactly the panes of that window of the workspace session."
|
|
76922
|
+
);
|
|
76923
|
+
}
|
|
76232
76924
|
const issued = await this.#leaseManager.issue(request3, {
|
|
76233
76925
|
requestId,
|
|
76234
76926
|
projectIdentity,
|
|
@@ -76467,6 +77159,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76467
77159
|
leaseManager: this.#leaseManager,
|
|
76468
77160
|
ledger: this.#ledger,
|
|
76469
77161
|
drainTickMs: this.#drainTickMs,
|
|
77162
|
+
openRetryDelaysMs: this.#openRetryDelaysMs,
|
|
77163
|
+
ownershipWaitMs: this.#ownershipWaitMs,
|
|
76470
77164
|
maxSocketBufferedBytes: this.#maxSocketBufferedBytes,
|
|
76471
77165
|
maxInputFrames: this.#maxInputFrames,
|
|
76472
77166
|
maxInputBytes: this.#maxInputBytes,
|
|
@@ -76640,6 +77334,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76640
77334
|
socket.off("error", this.#onClose);
|
|
76641
77335
|
}
|
|
76642
77336
|
};
|
|
77337
|
+
PANE_STREAM_TOPOLOGY_SETTLE_MS = 500;
|
|
77338
|
+
PANE_STREAM_OPEN_RETRY_DELAYS_MS = [150, 400];
|
|
77339
|
+
PANE_STREAM_OWNERSHIP_WAIT_MS = 2e3;
|
|
77340
|
+
PANE_STREAM_OWNERSHIP_HELD_FRAMES = 256;
|
|
76643
77341
|
GRAPHICS_MAX_QUEUED_DIGESTS = 256;
|
|
76644
77342
|
GRAPHICS_SEND_WINDOW_BYTES = 2 * 1024 * 1024;
|
|
76645
77343
|
PaneStreamLiveConnection = class {
|
|
@@ -76664,6 +77362,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76664
77362
|
#leaseManager;
|
|
76665
77363
|
#ledger;
|
|
76666
77364
|
#drainTickMs;
|
|
77365
|
+
#openRetryDelaysMs;
|
|
77366
|
+
#ownershipWaitMs;
|
|
76667
77367
|
#maxSocketBufferedBytes;
|
|
76668
77368
|
#maxInputFrames;
|
|
76669
77369
|
#maxInputBytes;
|
|
@@ -76677,6 +77377,13 @@ var init_pane_stream_websocket = __esm({
|
|
|
76677
77377
|
#panes = /* @__PURE__ */ new Map();
|
|
76678
77378
|
#semanticLayouts = /* @__PURE__ */ new Map();
|
|
76679
77379
|
#semanticExpectedPaneIds = null;
|
|
77380
|
+
/** Capability 119 (#723): a changed pane set is announced, not a reason to close. */
|
|
77381
|
+
#topologyInPlace;
|
|
77382
|
+
/** The stream was issued for every pane of its session: new panes join it. */
|
|
77383
|
+
#leasesWholeSession = false;
|
|
77384
|
+
#topologyReconciling = false;
|
|
77385
|
+
#topologyPending = null;
|
|
77386
|
+
#topologyWaiter = null;
|
|
76680
77387
|
#semanticRuntimeSessionId = null;
|
|
76681
77388
|
#semanticWindowLinks = null;
|
|
76682
77389
|
#semanticTopologyEpoch = -1;
|
|
@@ -76767,6 +77474,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76767
77474
|
this.#leaseManager = options.leaseManager;
|
|
76768
77475
|
this.#ledger = options.ledger;
|
|
76769
77476
|
this.#drainTickMs = options.drainTickMs;
|
|
77477
|
+
this.#openRetryDelaysMs = options.openRetryDelaysMs;
|
|
77478
|
+
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
76770
77479
|
this.#maxSocketBufferedBytes = options.maxSocketBufferedBytes;
|
|
76771
77480
|
this.#maxInputFrames = options.maxInputFrames;
|
|
76772
77481
|
this.#maxInputBytes = options.maxInputBytes;
|
|
@@ -76779,26 +77488,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76779
77488
|
this.#diagnosticSharedRawMicros = this.#diagnosticCapabilities.includes("clock-bounds-v1") ? options.diagnosticSharedNowMicros ?? sharedMonotonicMicros : void 0;
|
|
76780
77489
|
this.#diagnosticAfterFrameParse = options.diagnosticAfterFrameParse;
|
|
76781
77490
|
this.#onRetire = options.onRetire;
|
|
76782
|
-
|
|
76783
|
-
|
|
76784
|
-
|
|
76785
|
-
|
|
76786
|
-
delivery: null,
|
|
76787
|
-
deliveryAddress: null,
|
|
76788
|
-
serverSeq: 0,
|
|
76789
|
-
sentPaneFrames: 0,
|
|
76790
|
-
consumedSeq: 0,
|
|
76791
|
-
nextInputSeq: 1,
|
|
76792
|
-
frozenByWire: false,
|
|
76793
|
-
closed: false,
|
|
76794
|
-
batch: null,
|
|
76795
|
-
graphicsAnnounced: false,
|
|
76796
|
-
graphicsQueue: [],
|
|
76797
|
-
graphicsSending: false,
|
|
76798
|
-
graphicsServed: /* @__PURE__ */ new Map(),
|
|
76799
|
-
graphicsState: null
|
|
76800
|
-
});
|
|
76801
|
-
}
|
|
77491
|
+
this.#topologyInPlace = options.descriptor.terminalDelivery?.protocolVersions.some(
|
|
77492
|
+
(version) => version === PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION || version === PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION
|
|
77493
|
+
) === true;
|
|
77494
|
+
for (const pane of options.descriptor.panes) this.#panes.set(pane, newPaneChannel(pane));
|
|
76802
77495
|
}
|
|
76803
77496
|
get clientId() {
|
|
76804
77497
|
return this.#clientId;
|
|
@@ -76820,6 +77513,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
76820
77513
|
...this.#sessionRuntimeBinding && this.#descriptor.terminalDelivery?.protocolVersions.includes(
|
|
76821
77514
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION
|
|
76822
77515
|
) ? { inputBytes: true } : {},
|
|
77516
|
+
...this.#topologyInPlace ? { topologyInPlace: true } : {},
|
|
76823
77517
|
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
76824
77518
|
daemonInstanceId: this.#binding.daemonInstanceId,
|
|
76825
77519
|
requestId: this.#binding.requestId,
|
|
@@ -76829,7 +77523,11 @@ var init_pane_stream_websocket = __esm({
|
|
|
76829
77523
|
...this.#diagnosticCapabilities.length > 0 ? { diagnosticCapabilities: [...this.#diagnosticCapabilities] } : {}
|
|
76830
77524
|
});
|
|
76831
77525
|
this.#recordDiagnosticLifecycle("pane-stream-server-ready");
|
|
76832
|
-
} catch {
|
|
77526
|
+
} catch (error) {
|
|
77527
|
+
this.#closeCause = {
|
|
77528
|
+
cause: "ready-frame-failed",
|
|
77529
|
+
error: (error instanceof Error ? error.message : String(error)).slice(0, 300)
|
|
77530
|
+
};
|
|
76833
77531
|
this.close(1011, "stream-unavailable-describe");
|
|
76834
77532
|
return;
|
|
76835
77533
|
}
|
|
@@ -76863,9 +77561,13 @@ var init_pane_stream_websocket = __esm({
|
|
|
76863
77561
|
clientId: this.#clientId,
|
|
76864
77562
|
// Whether this connection held input when it went: the next stream of
|
|
76865
77563
|
// the same client can only be granted input once that is released.
|
|
76866
|
-
...this.#heldInput === null ? {} : { heldInput: this.#heldInput }
|
|
77564
|
+
...this.#heldInput === null ? {} : { heldInput: this.#heldInput },
|
|
77565
|
+
// Keys not delivered because their pane lifetime had ended (#397).
|
|
77566
|
+
...this.#inputLifetimeEndedDropped > 0 ? { droppedEndedLifetimeInputs: this.#inputLifetimeEndedDropped } : {}
|
|
76867
77567
|
});
|
|
76868
77568
|
this.#closed = true;
|
|
77569
|
+
this.#ownershipHeld.length = 0;
|
|
77570
|
+
this.#ownershipWake?.();
|
|
76869
77571
|
for (const demand of this.#surfaceDemands.values()) demand.close();
|
|
76870
77572
|
this.#surfaceDemands.clear();
|
|
76871
77573
|
this.#surfaceViewer?.close();
|
|
@@ -76925,7 +77627,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76925
77627
|
async #subscribeAll() {
|
|
76926
77628
|
let described;
|
|
76927
77629
|
try {
|
|
76928
|
-
described = await this.#
|
|
77630
|
+
described = await this.#retryOpenStep(
|
|
77631
|
+
"describe-session",
|
|
77632
|
+
() => this.#mirror.describeSession(this.#descriptor.sessionName)
|
|
77633
|
+
);
|
|
76929
77634
|
} catch (error) {
|
|
76930
77635
|
this.#fail("describe-session-failed", error);
|
|
76931
77636
|
return;
|
|
@@ -76979,6 +77684,32 @@ var init_pane_stream_websocket = __esm({
|
|
|
76979
77684
|
}
|
|
76980
77685
|
this.#closeIfAllPanesGone();
|
|
76981
77686
|
}
|
|
77687
|
+
/**
|
|
77688
|
+
* One step of a stream's opening, tried again after a failure (#585): on a
|
|
77689
|
+
* loaded host one slow tmux answer failed the step, the step closed the whole
|
|
77690
|
+
* stream with 1011, and nothing was tried twice. A refusal of authority is a
|
|
77691
|
+
* decision, not a failure, and is never repeated. Each repeat is logged.
|
|
77692
|
+
*/
|
|
77693
|
+
async #retryOpenStep(step, run, final = () => false) {
|
|
77694
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
77695
|
+
try {
|
|
77696
|
+
return await run();
|
|
77697
|
+
} catch (error) {
|
|
77698
|
+
const delayMs = this.#openRetryDelaysMs[attempt];
|
|
77699
|
+
if (delayMs === void 0 || this.#closed || error instanceof SessionRuntimeControllerLeaseError || final(error))
|
|
77700
|
+
throw error;
|
|
77701
|
+
logger.info("pane-stream", "stream open step failed; trying again", {
|
|
77702
|
+
session: this.#descriptor.sessionName,
|
|
77703
|
+
clientId: this.#clientId,
|
|
77704
|
+
step,
|
|
77705
|
+
attempt: attempt + 1,
|
|
77706
|
+
error: (error instanceof Error ? error.message : String(error)).slice(0, 300)
|
|
77707
|
+
});
|
|
77708
|
+
await new Promise((resolve47) => setTimeout(resolve47, delayMs));
|
|
77709
|
+
if (this.#closed) throw error;
|
|
77710
|
+
}
|
|
77711
|
+
}
|
|
77712
|
+
}
|
|
76982
77713
|
async #subscribeSemantic(known) {
|
|
76983
77714
|
const binding = this.#sessionRuntimeBinding;
|
|
76984
77715
|
const offer = this.#descriptor.terminalDelivery;
|
|
@@ -76996,21 +77727,29 @@ var init_pane_stream_websocket = __esm({
|
|
|
76996
77727
|
let stagedAuthority = null;
|
|
76997
77728
|
let authorityMalformed = false;
|
|
76998
77729
|
let layoutActivated = false;
|
|
77730
|
+
let layoutAttempt = 0;
|
|
76999
77731
|
try {
|
|
77000
|
-
|
|
77001
|
-
|
|
77002
|
-
|
|
77003
|
-
|
|
77004
|
-
{
|
|
77005
|
-
|
|
77006
|
-
|
|
77007
|
-
|
|
77008
|
-
|
|
77009
|
-
|
|
77010
|
-
|
|
77011
|
-
|
|
77012
|
-
|
|
77013
|
-
|
|
77732
|
+
const subscribeLayout = this.#mirror.subscribeLayout?.bind(this.#mirror);
|
|
77733
|
+
if (!subscribeLayout) throw new Error("authoritative layout is unavailable");
|
|
77734
|
+
const subscription = await this.#retryOpenStep(
|
|
77735
|
+
"semantic-layout-subscribe",
|
|
77736
|
+
() => {
|
|
77737
|
+
const attempt = ++layoutAttempt;
|
|
77738
|
+
stagedAuthority = null;
|
|
77739
|
+
authorityMalformed = false;
|
|
77740
|
+
return subscribeLayout(this.#descriptor.sessionName, () => void 0, {
|
|
77741
|
+
expectedSemanticPaneIds: expectedPaneIds,
|
|
77742
|
+
expectedRuntimeSessionId: this.#descriptor.runtimeSessionId,
|
|
77743
|
+
onAuthority: (snapshot3) => {
|
|
77744
|
+
if (attempt !== layoutAttempt) return;
|
|
77745
|
+
this.#recordDiagnosticLifecycle("pane-stream-layout-staged");
|
|
77746
|
+
if (snapshot3.layouts.length > PANE_STREAM_MAX_PANES) authorityMalformed = true;
|
|
77747
|
+
else if (!layoutActivated) stagedAuthority = snapshot3;
|
|
77748
|
+
else this.#onLayoutAuthority(snapshot3);
|
|
77749
|
+
}
|
|
77750
|
+
});
|
|
77751
|
+
},
|
|
77752
|
+
(error) => error instanceof Error && error.name === "MirrorTopologyChangedError"
|
|
77014
77753
|
);
|
|
77015
77754
|
if (this.#closed) {
|
|
77016
77755
|
await subscription.close().catch(() => void 0);
|
|
@@ -77045,32 +77784,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77045
77784
|
channels.sort(
|
|
77046
77785
|
(left, right) => Number(visibleAtOpen.has(right.semanticPaneId)) - Number(visibleAtOpen.has(left.semanticPaneId))
|
|
77047
77786
|
);
|
|
77048
|
-
const openings = channels.map(
|
|
77049
|
-
const pending = [];
|
|
77050
|
-
let ready = false;
|
|
77051
|
-
let negotiated = false;
|
|
77052
|
-
const delivery = await binding.openTerminalDelivery(
|
|
77053
|
-
channel.semanticPaneId,
|
|
77054
|
-
offer,
|
|
77055
|
-
(message) => {
|
|
77056
|
-
if (!ready && !(negotiated && message.type === "terminal.delivery.fault"))
|
|
77057
|
-
pending.push(message);
|
|
77058
|
-
else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
77059
|
-
},
|
|
77060
|
-
this.#descriptor.workspaceName
|
|
77061
|
-
);
|
|
77062
|
-
return {
|
|
77063
|
-
channel,
|
|
77064
|
-
delivery,
|
|
77065
|
-
pending,
|
|
77066
|
-
markNegotiated: () => {
|
|
77067
|
-
negotiated = true;
|
|
77068
|
-
},
|
|
77069
|
-
markReady: () => {
|
|
77070
|
-
ready = true;
|
|
77071
|
-
}
|
|
77072
|
-
};
|
|
77073
|
-
});
|
|
77787
|
+
const openings = channels.map((channel) => this.#openPaneDelivery(binding, offer, channel));
|
|
77074
77788
|
const settled = await Promise.allSettled(openings);
|
|
77075
77789
|
const opened = settled.flatMap(
|
|
77076
77790
|
(result2) => result2.status === "fulfilled" ? [result2.value] : []
|
|
@@ -77088,21 +77802,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77088
77802
|
}
|
|
77089
77803
|
return;
|
|
77090
77804
|
}
|
|
77091
|
-
|
|
77092
|
-
if (!delivery.negotiation.accepted) return true;
|
|
77093
|
-
const negotiated = delivery.negotiation.negotiated;
|
|
77094
|
-
if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
|
|
77095
|
-
let incarnation = null;
|
|
77096
|
-
for (const message of pending) {
|
|
77097
|
-
if (message.type !== "terminal.delivery" && message.type !== "terminal.projection")
|
|
77098
|
-
continue;
|
|
77099
|
-
if (message.workspaceName !== this.#descriptor.workspaceName || message.semanticPaneId !== channel.semanticPaneId || message.generation !== negotiated.generation || message.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message.incarnation !== incarnation)
|
|
77100
|
-
return true;
|
|
77101
|
-
incarnation = message.incarnation;
|
|
77102
|
-
}
|
|
77103
|
-
return false;
|
|
77104
|
-
});
|
|
77105
|
-
if (deliveryIdentityChanged) {
|
|
77805
|
+
if (opened.some((entry) => this.#deliveryIdentityChanged(entry))) {
|
|
77106
77806
|
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => void 0)));
|
|
77107
77807
|
this.#failTopologyChanged();
|
|
77108
77808
|
return;
|
|
@@ -77121,6 +77821,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77121
77821
|
}
|
|
77122
77822
|
this.#recordDiagnosticLifecycle("pane-stream-layout-validated");
|
|
77123
77823
|
this.#semanticExpectedPaneIds = expectedPaneIds;
|
|
77824
|
+
this.#leasesWholeSession = expectedPaneIds.every((pane) => this.#panes.has(pane));
|
|
77124
77825
|
this.#semanticRuntimeSessionId = authority2.runtimeSessionId;
|
|
77125
77826
|
this.#semanticWindowLinks = authority2.windowLinks;
|
|
77126
77827
|
this.#semanticTopologyEpoch = authority2.topologyEpoch;
|
|
@@ -77143,6 +77844,54 @@ var init_pane_stream_websocket = __esm({
|
|
|
77143
77844
|
opened.sort(
|
|
77144
77845
|
(left, right) => Number(visibleAtDelivery.has(right.channel.semanticPaneId)) - Number(visibleAtDelivery.has(left.channel.semanticPaneId))
|
|
77145
77846
|
);
|
|
77847
|
+
await this.#publishOpenedDeliveries(opened);
|
|
77848
|
+
this.#closeIfAllPanesGone();
|
|
77849
|
+
}
|
|
77850
|
+
/** Open one pane's delivery; its messages wait until the pane is announced. */
|
|
77851
|
+
async #openPaneDelivery(binding, offer, channel) {
|
|
77852
|
+
const pending = [];
|
|
77853
|
+
let ready = false;
|
|
77854
|
+
let negotiated = false;
|
|
77855
|
+
const delivery = await this.#retryOpenStep("pane-delivery-open", () => {
|
|
77856
|
+
pending.length = 0;
|
|
77857
|
+
return binding.openTerminalDelivery(
|
|
77858
|
+
channel.semanticPaneId,
|
|
77859
|
+
offer,
|
|
77860
|
+
(message) => {
|
|
77861
|
+
if (!ready && !(negotiated && message.type === "terminal.delivery.fault"))
|
|
77862
|
+
pending.push(message);
|
|
77863
|
+
else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
77864
|
+
},
|
|
77865
|
+
this.#descriptor.workspaceName
|
|
77866
|
+
);
|
|
77867
|
+
});
|
|
77868
|
+
return {
|
|
77869
|
+
channel,
|
|
77870
|
+
delivery,
|
|
77871
|
+
pending,
|
|
77872
|
+
markNegotiated: () => {
|
|
77873
|
+
negotiated = true;
|
|
77874
|
+
},
|
|
77875
|
+
markReady: () => {
|
|
77876
|
+
ready = true;
|
|
77877
|
+
}
|
|
77878
|
+
};
|
|
77879
|
+
}
|
|
77880
|
+
#deliveryIdentityChanged({ channel, delivery, pending }) {
|
|
77881
|
+
if (!delivery.negotiation.accepted) return true;
|
|
77882
|
+
const negotiated = delivery.negotiation.negotiated;
|
|
77883
|
+
if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
|
|
77884
|
+
let incarnation = null;
|
|
77885
|
+
for (const message of pending) {
|
|
77886
|
+
if (message.type !== "terminal.delivery" && message.type !== "terminal.projection") continue;
|
|
77887
|
+
if (message.workspaceName !== this.#descriptor.workspaceName || message.semanticPaneId !== channel.semanticPaneId || message.generation !== negotiated.generation || message.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message.incarnation !== incarnation)
|
|
77888
|
+
return true;
|
|
77889
|
+
incarnation = message.incarnation;
|
|
77890
|
+
}
|
|
77891
|
+
return false;
|
|
77892
|
+
}
|
|
77893
|
+
/** Announce validated deliveries, then replay what each collected meanwhile. */
|
|
77894
|
+
async #publishOpenedDeliveries(opened) {
|
|
77146
77895
|
for (const { channel, delivery, markNegotiated } of opened) {
|
|
77147
77896
|
if (this.#closed || channel.closed) {
|
|
77148
77897
|
await delivery.close();
|
|
@@ -77175,9 +77924,37 @@ var init_pane_stream_websocket = __esm({
|
|
|
77175
77924
|
markReady();
|
|
77176
77925
|
this.#startGraphics(channel);
|
|
77177
77926
|
}
|
|
77178
|
-
this.#closeIfAllPanesGone();
|
|
77179
77927
|
}
|
|
77928
|
+
/**
|
|
77929
|
+
* A tombstone ends a pane's delivery for good: the hub drops the pane and
|
|
77930
|
+
* sends nothing more. Without capability 119 the pane's removal closes the
|
|
77931
|
+
* stream anyway. With it, the removal arrives as a `topology` frame within
|
|
77932
|
+
* moments; if none comes, the pane is still in the session and would stay
|
|
77933
|
+
* blank for ever, so the stream closes as it would without the capability
|
|
77934
|
+
* and the client takes a new one.
|
|
77935
|
+
*/
|
|
77936
|
+
#watchTombstone(pane) {
|
|
77937
|
+
const channel = this.#panes.get(pane);
|
|
77938
|
+
if (!this.#topologyInPlace || !channel || channel.closed) return;
|
|
77939
|
+
const timer = setTimeout(() => {
|
|
77940
|
+
if (this.#closed || channel.retiredInPlace || this.#panes.get(pane) !== channel) return;
|
|
77941
|
+
if (this.#topologyReconciling) {
|
|
77942
|
+
this.#tombstonesAfterChange.add(channel);
|
|
77943
|
+
return;
|
|
77944
|
+
}
|
|
77945
|
+
this.#failTopologyChanged("a pane that stays lost its source");
|
|
77946
|
+
}, PANE_STREAM_TOPOLOGY_SETTLE_MS);
|
|
77947
|
+
timer.unref?.();
|
|
77948
|
+
}
|
|
77949
|
+
/**
|
|
77950
|
+
* Tombstoned channels whose guard came due while a change was being applied.
|
|
77951
|
+
* The channel, not the pane id: a pane that left and came back within the
|
|
77952
|
+
* change has a fresh channel, which this tombstone is not about.
|
|
77953
|
+
*/
|
|
77954
|
+
#tombstonesAfterChange = /* @__PURE__ */ new Set();
|
|
77180
77955
|
async #sendTerminalDelivery(pane, message) {
|
|
77956
|
+
if ((message.type === "terminal.delivery" || message.type === "terminal.projection") && message.frame === "tombstone")
|
|
77957
|
+
this.#watchTombstone(pane);
|
|
77181
77958
|
if (message.type === "terminal.projection") {
|
|
77182
77959
|
const channel = this.#panes.get(pane);
|
|
77183
77960
|
if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message.incarnation;
|
|
@@ -77306,7 +78083,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77306
78083
|
if (!graphics) return;
|
|
77307
78084
|
this.#observeSurfaceDemand([channel.semanticPaneId]);
|
|
77308
78085
|
const zlib = this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
77309
|
-
(version) => version === TERMINAL_GRAPHICS_ZLIB_CAPABILITY_VERSION || version === PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION || version === PANE_STREAM_READER_CAPABILITY_VERSION
|
|
78086
|
+
(version) => version === TERMINAL_GRAPHICS_ZLIB_CAPABILITY_VERSION || version === PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION || version === PANE_STREAM_READER_CAPABILITY_VERSION || version === PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION
|
|
77310
78087
|
) === true;
|
|
77311
78088
|
channel.graphicsZlib = zlib;
|
|
77312
78089
|
channel.graphicsLocal = !!this.#localImages && this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
@@ -77662,12 +78439,22 @@ var init_pane_stream_websocket = __esm({
|
|
|
77662
78439
|
}
|
|
77663
78440
|
#onLayoutAuthority(snapshot3) {
|
|
77664
78441
|
if (this.#closed || !this.#semanticExpectedPaneIds || !this.#semanticRuntimeSessionId) return;
|
|
77665
|
-
if (
|
|
78442
|
+
if (this.#topologyReconciling) {
|
|
78443
|
+
this.#topologyPending = snapshot3;
|
|
78444
|
+
this.#topologyWaiter?.();
|
|
78445
|
+
return;
|
|
78446
|
+
}
|
|
78447
|
+
if (!this.#layoutAuthorityAdmissible(snapshot3)) {
|
|
77666
78448
|
this.#failTopologyChanged();
|
|
77667
78449
|
return;
|
|
77668
78450
|
}
|
|
77669
78451
|
const frames = this.#validateInitialLayout(snapshot3.layouts, this.#semanticExpectedPaneIds);
|
|
77670
|
-
|
|
78452
|
+
const windowChanged = frames !== null && this.#windowPaneSetChanged(snapshot3);
|
|
78453
|
+
if ((!frames || windowChanged) && this.#topologyInPlace) {
|
|
78454
|
+
void this.#reconcileTopology(snapshot3);
|
|
78455
|
+
return;
|
|
78456
|
+
}
|
|
78457
|
+
if (!frames || windowChanged || !PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
|
|
77671
78458
|
type: "layout-snapshot",
|
|
77672
78459
|
topologyEpoch: snapshot3.topologyEpoch,
|
|
77673
78460
|
layouts: frames,
|
|
@@ -77676,10 +78463,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77676
78463
|
this.#failTopologyChanged();
|
|
77677
78464
|
return;
|
|
77678
78465
|
}
|
|
77679
|
-
|
|
77680
|
-
if (!previousLinks || snapshot3.windowLinks.liveSessionId !== previousLinks.liveSessionId || snapshot3.windowLinks.linkRevision < previousLinks.linkRevision || snapshot3.windowLinks.linkRevision === previousLinks.linkRevision && JSON.stringify(
|
|
77681
|
-
[...snapshot3.windowLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))
|
|
77682
|
-
) !== JSON.stringify([...previousLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId)))) {
|
|
78466
|
+
if (!this.#windowLinksAdmissible(snapshot3)) {
|
|
77683
78467
|
this.#failTopologyChanged();
|
|
77684
78468
|
return;
|
|
77685
78469
|
}
|
|
@@ -77695,6 +78479,222 @@ var init_pane_stream_websocket = __esm({
|
|
|
77695
78479
|
windowLinks: snapshot3.windowLinks
|
|
77696
78480
|
});
|
|
77697
78481
|
}
|
|
78482
|
+
/** #806: the layout no longer shows this stream's window with exactly its panes. */
|
|
78483
|
+
#windowPaneSetChanged(snapshot3) {
|
|
78484
|
+
const window2 = this.#descriptor.semanticWindowId;
|
|
78485
|
+
if (window2 === null) return false;
|
|
78486
|
+
const live = [...this.#panes.values()].filter((channel) => !channel.closed).map((channel) => channel.semanticPaneId);
|
|
78487
|
+
const shown = snapshot3.layouts.find((event) => event.semanticWindowId === window2);
|
|
78488
|
+
if (!shown) return true;
|
|
78489
|
+
const panes = shown.panes.map((pane) => pane.semanticPaneId ?? "");
|
|
78490
|
+
if (shown.zoomed) return panes.length !== 1 || !live.includes(panes[0]);
|
|
78491
|
+
return panes.length !== live.length || panes.some((pane) => !live.includes(pane));
|
|
78492
|
+
}
|
|
78493
|
+
/** The same session and runtime, a newer epoch, a layout a stream can carry. */
|
|
78494
|
+
#layoutAuthorityAdmissible(snapshot3) {
|
|
78495
|
+
return snapshot3.session === this.#descriptor.sessionName && snapshot3.runtimeSessionId === this.#semanticRuntimeSessionId && snapshot3.topologyEpoch > this.#semanticTopologyEpoch && snapshot3.layouts.length <= PANE_STREAM_MAX_PANES;
|
|
78496
|
+
}
|
|
78497
|
+
#windowLinksAdmissible(snapshot3) {
|
|
78498
|
+
const previousLinks = this.#semanticWindowLinks;
|
|
78499
|
+
return !(!previousLinks || snapshot3.windowLinks.liveSessionId !== previousLinks.liveSessionId || snapshot3.windowLinks.linkRevision < previousLinks.linkRevision || snapshot3.windowLinks.linkRevision === previousLinks.linkRevision && JSON.stringify(
|
|
78500
|
+
[...snapshot3.windowLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))
|
|
78501
|
+
) !== JSON.stringify([...previousLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))));
|
|
78502
|
+
}
|
|
78503
|
+
/**
|
|
78504
|
+
* Capability 119 (#723). Follow a changed pane set without closing: one
|
|
78505
|
+
* change at a time, newest state only. Every doubt ends where a stream
|
|
78506
|
+
* without the capability ends, in `#failTopologyChanged()`.
|
|
78507
|
+
*/
|
|
78508
|
+
async #reconcileTopology(first) {
|
|
78509
|
+
this.#topologyReconciling = true;
|
|
78510
|
+
let snapshot3 = first;
|
|
78511
|
+
try {
|
|
78512
|
+
for (; ; ) {
|
|
78513
|
+
this.#topologyPending = null;
|
|
78514
|
+
const outcome = await this.#applyTopology(snapshot3);
|
|
78515
|
+
if (this.#closed) return;
|
|
78516
|
+
if (outcome === "failed") return this.#failTopologyChanged(this.#topologyFailure);
|
|
78517
|
+
let next = this.#topologyPending;
|
|
78518
|
+
if (outcome === "stale" && !next) {
|
|
78519
|
+
next = await this.#nextTopologySnapshot();
|
|
78520
|
+
if (this.#closed) return;
|
|
78521
|
+
if (!next) return this.#failTopologyChanged();
|
|
78522
|
+
}
|
|
78523
|
+
if (!next) return;
|
|
78524
|
+
if (!this.#layoutAuthorityAdmissible(next)) return this.#failTopologyChanged();
|
|
78525
|
+
snapshot3 = next;
|
|
78526
|
+
}
|
|
78527
|
+
} finally {
|
|
78528
|
+
this.#topologyReconciling = false;
|
|
78529
|
+
this.#topologyPending = null;
|
|
78530
|
+
const tombstoned = [...this.#tombstonesAfterChange];
|
|
78531
|
+
this.#tombstonesAfterChange.clear();
|
|
78532
|
+
for (const channel of tombstoned)
|
|
78533
|
+
if (this.#panes.get(channel.semanticPaneId) === channel)
|
|
78534
|
+
this.#watchTombstone(channel.semanticPaneId);
|
|
78535
|
+
}
|
|
78536
|
+
}
|
|
78537
|
+
#nextTopologySnapshot() {
|
|
78538
|
+
if (this.#topologyPending) return Promise.resolve(this.#topologyPending);
|
|
78539
|
+
return new Promise((resolve47) => {
|
|
78540
|
+
const finish = () => {
|
|
78541
|
+
clearTimeout(timer);
|
|
78542
|
+
this.#topologyWaiter = null;
|
|
78543
|
+
resolve47(this.#topologyPending);
|
|
78544
|
+
};
|
|
78545
|
+
const timer = setTimeout(finish, PANE_STREAM_TOPOLOGY_SETTLE_MS);
|
|
78546
|
+
timer.unref?.();
|
|
78547
|
+
this.#topologyWaiter = finish;
|
|
78548
|
+
});
|
|
78549
|
+
}
|
|
78550
|
+
/**
|
|
78551
|
+
* "applied": the client was told and the stream goes on. "stale": this
|
|
78552
|
+
* layout does not fit the session's inventory as read now; a newer layout
|
|
78553
|
+
* decides. "failed": close.
|
|
78554
|
+
*/
|
|
78555
|
+
async #applyTopology(snapshot3) {
|
|
78556
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78557
|
+
const offer = this.#descriptor.terminalDelivery;
|
|
78558
|
+
if (!binding || !offer || !this.#semanticExpectedPaneIds || !this.#windowLinksAdmissible(snapshot3))
|
|
78559
|
+
return this.#topologyFailed("not a semantic stream, or its window links changed");
|
|
78560
|
+
let described;
|
|
78561
|
+
let inventoryIsThisSession = false;
|
|
78562
|
+
try {
|
|
78563
|
+
if (this.#mirror.describeSessionAuthority) {
|
|
78564
|
+
const authority2 = await this.#mirror.describeSessionAuthority(this.#descriptor.sessionName);
|
|
78565
|
+
if (authority2.runtimeSessionId !== this.#semanticRuntimeSessionId)
|
|
78566
|
+
return this.#topologyFailed("inventory is of another runtime session");
|
|
78567
|
+
described = authority2.description;
|
|
78568
|
+
inventoryIsThisSession = true;
|
|
78569
|
+
} else {
|
|
78570
|
+
described = await this.#mirror.describeSession(this.#descriptor.sessionName);
|
|
78571
|
+
}
|
|
78572
|
+
} catch (error) {
|
|
78573
|
+
return this.#topologyFailed("session inventory unavailable", error);
|
|
78574
|
+
}
|
|
78575
|
+
if (this.#closed) return this.#topologyFailed("closed");
|
|
78576
|
+
const next = [...new Set(described.panes.map((pane) => pane.semanticPaneId))].sort();
|
|
78577
|
+
if (next.length === 0) return this.#topologyFailed("session has no panes");
|
|
78578
|
+
const frames = this.#validateInitialLayout(snapshot3.layouts, next);
|
|
78579
|
+
if (!frames) return "stale";
|
|
78580
|
+
if (!PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
|
|
78581
|
+
type: "layout-snapshot",
|
|
78582
|
+
topologyEpoch: snapshot3.topologyEpoch,
|
|
78583
|
+
layouts: frames,
|
|
78584
|
+
windowLinks: snapshot3.windowLinks
|
|
78585
|
+
}).success)
|
|
78586
|
+
return this.#topologyFailed("layout snapshot invalid");
|
|
78587
|
+
const window2 = this.#descriptor.semanticWindowId;
|
|
78588
|
+
let windowPanes = null;
|
|
78589
|
+
if (window2 !== null) {
|
|
78590
|
+
windowPanes = [
|
|
78591
|
+
...new Set(
|
|
78592
|
+
described.panes.filter((pane) => pane.semanticWindowId === window2).map((pane) => pane.semanticPaneId)
|
|
78593
|
+
)
|
|
78594
|
+
].sort();
|
|
78595
|
+
if (windowPanes.length === 0) return this.#topologyFailed("the stream's window is gone");
|
|
78596
|
+
const shown = snapshot3.layouts.find((event) => event.semanticWindowId === window2);
|
|
78597
|
+
const shownPanes = (shown?.panes ?? []).map((pane) => pane.semanticPaneId ?? "");
|
|
78598
|
+
if (!shown || (shown.zoomed ? shownPanes.length !== 1 || !windowPanes.includes(shownPanes[0]) : shownPanes.length !== windowPanes.length || shownPanes.some((pane) => !windowPanes.includes(pane))))
|
|
78599
|
+
return "stale";
|
|
78600
|
+
}
|
|
78601
|
+
const followed = windowPanes ?? next;
|
|
78602
|
+
const live = [...this.#panes.values()].filter((channel) => !channel.closed);
|
|
78603
|
+
const removed = live.filter((channel) => !followed.includes(channel.semanticPaneId));
|
|
78604
|
+
const liveIds = new Set(live.map((channel) => channel.semanticPaneId));
|
|
78605
|
+
const added = windowPanes !== null || this.#leasesWholeSession ? followed.filter((pane) => !liveIds.has(pane)) : [];
|
|
78606
|
+
if (added.length > 0 && !inventoryIsThisSession)
|
|
78607
|
+
return this.#topologyFailed("inventory cannot prove the runtime session");
|
|
78608
|
+
const remaining = live.length - removed.length + added.length;
|
|
78609
|
+
if (remaining === 0 || remaining > PANE_STREAM_MAX_PANES)
|
|
78610
|
+
return this.#topologyFailed("pane count outside the stream limit");
|
|
78611
|
+
if (added.length > 0) {
|
|
78612
|
+
try {
|
|
78613
|
+
if (!binding.amendPaneGrant)
|
|
78614
|
+
return this.#topologyFailed("transport cannot amend its grant");
|
|
78615
|
+
binding.amendPaneGrant({ added, removed: [] });
|
|
78616
|
+
} catch (error) {
|
|
78617
|
+
return this.#topologyFailed("pane grant refused", error);
|
|
78618
|
+
}
|
|
78619
|
+
}
|
|
78620
|
+
const channels = added.map(newPaneChannel);
|
|
78621
|
+
const settled = await Promise.allSettled(
|
|
78622
|
+
channels.map((channel) => this.#openPaneDelivery(binding, offer, channel))
|
|
78623
|
+
);
|
|
78624
|
+
const opened = settled.flatMap(
|
|
78625
|
+
(result2) => result2.status === "fulfilled" ? [result2.value] : []
|
|
78626
|
+
);
|
|
78627
|
+
if (this.#closed || opened.length !== channels.length || opened.some((entry) => this.#deliveryIdentityChanged(entry))) {
|
|
78628
|
+
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => void 0)));
|
|
78629
|
+
if (added.length > 0) {
|
|
78630
|
+
try {
|
|
78631
|
+
binding.amendPaneGrant?.({ added: [], removed: added });
|
|
78632
|
+
} catch {
|
|
78633
|
+
}
|
|
78634
|
+
}
|
|
78635
|
+
const rejected = settled.find((result2) => result2.status === "rejected");
|
|
78636
|
+
return this.#topologyFailed(
|
|
78637
|
+
this.#closed ? "closed while opening" : rejected ? "delivery open rejected" : opened.some((entry) => !entry.delivery.negotiation.accepted) ? "delivery negotiation refused" : "delivery identity changed",
|
|
78638
|
+
rejected?.status === "rejected" ? rejected.reason : void 0
|
|
78639
|
+
);
|
|
78640
|
+
}
|
|
78641
|
+
if (removed.length > 0) {
|
|
78642
|
+
try {
|
|
78643
|
+
binding.amendPaneGrant?.({
|
|
78644
|
+
added: [],
|
|
78645
|
+
removed: removed.map((channel) => channel.semanticPaneId)
|
|
78646
|
+
});
|
|
78647
|
+
} catch {
|
|
78648
|
+
}
|
|
78649
|
+
}
|
|
78650
|
+
for (const channel of removed) this.#retirePaneInPlace(channel);
|
|
78651
|
+
for (const channel of channels) this.#panes.set(channel.semanticPaneId, channel);
|
|
78652
|
+
this.#semanticExpectedPaneIds = next;
|
|
78653
|
+
this.#semanticWindowLinks = snapshot3.windowLinks;
|
|
78654
|
+
this.#semanticTopologyEpoch = snapshot3.topologyEpoch;
|
|
78655
|
+
this.#semanticLayouts.clear();
|
|
78656
|
+
for (const event of snapshot3.layouts)
|
|
78657
|
+
this.#semanticLayouts.set(event.semanticWindowId, event);
|
|
78658
|
+
this.#sendFrame(null, {
|
|
78659
|
+
type: "topology",
|
|
78660
|
+
topologyEpoch: snapshot3.topologyEpoch,
|
|
78661
|
+
panes: [...this.#panes.values()].filter((channel) => !channel.closed).map((channel) => channel.semanticPaneId),
|
|
78662
|
+
removed: removed.map((channel) => channel.semanticPaneId),
|
|
78663
|
+
added
|
|
78664
|
+
});
|
|
78665
|
+
this.#sendFrame(null, {
|
|
78666
|
+
type: "layout-snapshot",
|
|
78667
|
+
topologyEpoch: snapshot3.topologyEpoch,
|
|
78668
|
+
layouts: frames,
|
|
78669
|
+
windowLinks: snapshot3.windowLinks
|
|
78670
|
+
});
|
|
78671
|
+
await this.#publishOpenedDeliveries(opened);
|
|
78672
|
+
return "applied";
|
|
78673
|
+
}
|
|
78674
|
+
#topologyFailure = "";
|
|
78675
|
+
#topologyFailed(why, error) {
|
|
78676
|
+
this.#topologyFailure = error === void 0 ? why : `${why}: ${String(error).slice(0, 200)}`;
|
|
78677
|
+
return "failed";
|
|
78678
|
+
}
|
|
78679
|
+
/** A pane that left the session: its delivery ends, the stream does not. */
|
|
78680
|
+
#retirePaneInPlace(channel) {
|
|
78681
|
+
const sub = channel.sub;
|
|
78682
|
+
const delivery = channel.delivery;
|
|
78683
|
+
channel.sub = null;
|
|
78684
|
+
channel.delivery = null;
|
|
78685
|
+
channel.closed = true;
|
|
78686
|
+
channel.retiredInPlace = true;
|
|
78687
|
+
channel.deliveryAddress = null;
|
|
78688
|
+
channel.batch = null;
|
|
78689
|
+
channel.graphicsQueue = [];
|
|
78690
|
+
channel.graphicsServed = /* @__PURE__ */ new Map();
|
|
78691
|
+
channel.graphicsState = null;
|
|
78692
|
+
this.#surfaceDemands.get(channel.semanticPaneId)?.close();
|
|
78693
|
+
this.#surfaceDemands.delete(channel.semanticPaneId);
|
|
78694
|
+
if (sub) void sub.close().catch(() => void 0);
|
|
78695
|
+
if (delivery) void delivery.close().catch(() => void 0);
|
|
78696
|
+
this.#ledger.forgetPane(this.#clientId, channel.semanticPaneId);
|
|
78697
|
+
}
|
|
77698
78698
|
#onLayout(event) {
|
|
77699
78699
|
if (this.#closed) return;
|
|
77700
78700
|
const frame = this.#layoutFrame(event);
|
|
@@ -77705,7 +78705,9 @@ var init_pane_stream_websocket = __esm({
|
|
|
77705
78705
|
this.#sendFrame(null, frame);
|
|
77706
78706
|
}
|
|
77707
78707
|
#offers(version) {
|
|
77708
|
-
|
|
78708
|
+
const offered = this.#descriptor.terminalDelivery?.protocolVersions;
|
|
78709
|
+
if (!offered) return false;
|
|
78710
|
+
return offered.includes(version) || (version === PANE_STREAM_READER_CAPABILITY_VERSION || version === PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION) && offered.includes(PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION);
|
|
77709
78711
|
}
|
|
77710
78712
|
#layoutFrame(event) {
|
|
77711
78713
|
const frame = {
|
|
@@ -77724,6 +78726,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77724
78726
|
displayNameSource: pane.displayNameSource,
|
|
77725
78727
|
...this.#offers(PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION) || this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION) ? { browserIcon: pane.browserIcon ?? null } : {},
|
|
77726
78728
|
...this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION) ? { reader: pane.reader ? { name: pane.reader.name } : null } : {},
|
|
78729
|
+
...this.#offers(PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION) ? { browserKind: pane.browserKind ?? null } : {},
|
|
77727
78730
|
left: pane.left,
|
|
77728
78731
|
top: pane.top,
|
|
77729
78732
|
width: pane.width,
|
|
@@ -77758,8 +78761,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
77758
78761
|
return null;
|
|
77759
78762
|
return frames;
|
|
77760
78763
|
}
|
|
77761
|
-
|
|
78764
|
+
/** `inPlaceFailure`: why a capability-119 stream could not follow the change. */
|
|
78765
|
+
#failTopologyChanged(inPlaceFailure) {
|
|
77762
78766
|
if (this.#closed) return;
|
|
78767
|
+
if (inPlaceFailure) this.#closeCause = { cause: `topology-in-place: ${inPlaceFailure}` };
|
|
77763
78768
|
this.#sendFrame(null, {
|
|
77764
78769
|
type: "error",
|
|
77765
78770
|
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
@@ -77930,17 +78935,23 @@ var init_pane_stream_websocket = __esm({
|
|
|
77930
78935
|
if (frame.type === "presence") {
|
|
77931
78936
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77932
78937
|
this.#usesExplicitAuthority = true;
|
|
77933
|
-
|
|
77934
|
-
|
|
77935
|
-
|
|
78938
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78939
|
+
if (!binding?.updatePresence) return this.#failProtocol("protocol-error");
|
|
78940
|
+
this.#afterHeldFrames(() => {
|
|
78941
|
+
const snapshot3 = binding.updatePresence(frame.state);
|
|
78942
|
+
if (!binding.onAuthoritySnapshot) this.#sendAuthoritySnapshot(snapshot3);
|
|
78943
|
+
});
|
|
77936
78944
|
return;
|
|
77937
78945
|
}
|
|
77938
78946
|
if (frame.type === "activity") {
|
|
77939
78947
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77940
78948
|
this.#usesExplicitAuthority = true;
|
|
77941
|
-
|
|
77942
|
-
|
|
77943
|
-
|
|
78949
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78950
|
+
if (!binding?.noteActivity) return this.#failProtocol("protocol-error");
|
|
78951
|
+
this.#afterHeldFrames(() => {
|
|
78952
|
+
const snapshot3 = binding.noteActivity(frame.activity);
|
|
78953
|
+
if (!binding.onAuthoritySnapshot) this.#sendAuthoritySnapshot(snapshot3);
|
|
78954
|
+
});
|
|
77944
78955
|
return;
|
|
77945
78956
|
}
|
|
77946
78957
|
if (frame.type === "authority-request") {
|
|
@@ -77948,38 +78959,45 @@ var init_pane_stream_websocket = __esm({
|
|
|
77948
78959
|
this.#usesExplicitAuthority = true;
|
|
77949
78960
|
if (!this.#sessionRuntimeBinding?.requestAuthority || !this.#sessionRuntimeBinding.authoritySnapshot)
|
|
77950
78961
|
return this.#failProtocol("protocol-error");
|
|
77951
|
-
|
|
77952
|
-
|
|
77953
|
-
lease =
|
|
77954
|
-
|
|
77955
|
-
|
|
77956
|
-
|
|
77957
|
-
|
|
77958
|
-
|
|
77959
|
-
|
|
77960
|
-
|
|
77961
|
-
|
|
77962
|
-
|
|
77963
|
-
|
|
77964
|
-
|
|
77965
|
-
|
|
77966
|
-
|
|
78962
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78963
|
+
const request3 = () => {
|
|
78964
|
+
let lease = null;
|
|
78965
|
+
try {
|
|
78966
|
+
lease = binding.requestAuthority(frame.authority);
|
|
78967
|
+
} catch (error) {
|
|
78968
|
+
if (this.#holdForWindowOwnership(error, request3)) return;
|
|
78969
|
+
if (!(error instanceof SessionRuntimeControllerLeaseError) || error.code !== "controller-conflict")
|
|
78970
|
+
return this.#failProtocol("input-rejected");
|
|
78971
|
+
}
|
|
78972
|
+
if (lease) this.#requestedAuthorities.add(frame.authority);
|
|
78973
|
+
this.#sendFrame(null, {
|
|
78974
|
+
type: "authority-receipt",
|
|
78975
|
+
requestId: frame.requestId,
|
|
78976
|
+
authority: frame.authority,
|
|
78977
|
+
status: lease ? "granted" : "rejected",
|
|
78978
|
+
lease,
|
|
78979
|
+
snapshot: binding.authoritySnapshot()
|
|
78980
|
+
});
|
|
78981
|
+
};
|
|
78982
|
+
this.#afterWindowOwnership(request3);
|
|
77967
78983
|
return;
|
|
77968
78984
|
}
|
|
77969
78985
|
if (frame.type === "authority-release") {
|
|
77970
78986
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77971
78987
|
this.#usesExplicitAuthority = true;
|
|
77972
|
-
this.#
|
|
77973
|
-
if (!
|
|
77974
|
-
|
|
77975
|
-
|
|
77976
|
-
|
|
77977
|
-
|
|
77978
|
-
|
|
77979
|
-
|
|
77980
|
-
|
|
77981
|
-
|
|
77982
|
-
|
|
78988
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78989
|
+
if (!binding?.releaseAuthority) return this.#failProtocol("protocol-error");
|
|
78990
|
+
this.#afterHeldFrames(() => {
|
|
78991
|
+
this.#requestedAuthorities.delete(frame.authority);
|
|
78992
|
+
const snapshot3 = binding.releaseAuthority(frame.authority);
|
|
78993
|
+
this.#sendFrame(null, {
|
|
78994
|
+
type: "authority-receipt",
|
|
78995
|
+
requestId: frame.requestId,
|
|
78996
|
+
authority: frame.authority,
|
|
78997
|
+
status: "released",
|
|
78998
|
+
lease: null,
|
|
78999
|
+
snapshot: snapshot3
|
|
79000
|
+
});
|
|
77983
79001
|
});
|
|
77984
79002
|
return;
|
|
77985
79003
|
}
|
|
@@ -78022,7 +79040,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78022
79040
|
return;
|
|
78023
79041
|
}
|
|
78024
79042
|
if (frame.type === "semantic-intent") {
|
|
78025
|
-
this.#acceptSemanticIntent(frame.operationId, frame.intent);
|
|
79043
|
+
this.#afterHeldFrames(() => this.#acceptSemanticIntent(frame.operationId, frame.intent));
|
|
78026
79044
|
return;
|
|
78027
79045
|
}
|
|
78028
79046
|
if (frame.type === "terminal-surface-watch") {
|
|
@@ -78154,38 +79172,42 @@ var init_pane_stream_websocket = __esm({
|
|
|
78154
79172
|
}
|
|
78155
79173
|
if (!this.#prepareInputAuthority(true)) return;
|
|
78156
79174
|
this.#nextViewportSeq += 1;
|
|
78157
|
-
|
|
78158
|
-
|
|
78159
|
-
|
|
78160
|
-
|
|
78161
|
-
|
|
78162
|
-
|
|
78163
|
-
|
|
78164
|
-
|
|
78165
|
-
|
|
78166
|
-
|
|
78167
|
-
|
|
78168
|
-
type: "viewport-ack",
|
|
78169
|
-
seq: frame.seq,
|
|
78170
|
-
cols: frame.cols,
|
|
78171
|
-
rows: frame.rows,
|
|
78172
|
-
outcome: "ok",
|
|
78173
|
-
authorityLease: frame.authorityLease
|
|
78174
|
-
});
|
|
78175
|
-
} catch (error) {
|
|
78176
|
-
if (error instanceof SessionRuntimeControllerLeaseError && (error.code === "invalid-client-capability" || error.code === "stale-controller-lease")) {
|
|
79175
|
+
const fit = () => {
|
|
79176
|
+
try {
|
|
79177
|
+
if (frame.semanticWindowId === void 0)
|
|
79178
|
+
this.#sessionRuntimeBinding.fitViewport(frame.authorityLease, frame.cols, frame.rows);
|
|
79179
|
+
else
|
|
79180
|
+
this.#sessionRuntimeBinding.fitViewport(
|
|
79181
|
+
frame.authorityLease,
|
|
79182
|
+
frame.cols,
|
|
79183
|
+
frame.rows,
|
|
79184
|
+
frame.semanticWindowId
|
|
79185
|
+
);
|
|
78177
79186
|
this.#sendFrame(null, {
|
|
78178
79187
|
type: "viewport-ack",
|
|
78179
79188
|
seq: frame.seq,
|
|
78180
79189
|
cols: frame.cols,
|
|
78181
79190
|
rows: frame.rows,
|
|
78182
|
-
outcome: "
|
|
79191
|
+
outcome: "ok",
|
|
78183
79192
|
authorityLease: frame.authorityLease
|
|
78184
79193
|
});
|
|
78185
|
-
|
|
79194
|
+
} catch (error) {
|
|
79195
|
+
if (error instanceof SessionRuntimeControllerLeaseError && (error.code === "invalid-client-capability" || error.code === "stale-controller-lease")) {
|
|
79196
|
+
this.#sendFrame(null, {
|
|
79197
|
+
type: "viewport-ack",
|
|
79198
|
+
seq: frame.seq,
|
|
79199
|
+
cols: frame.cols,
|
|
79200
|
+
rows: frame.rows,
|
|
79201
|
+
outcome: "geometry-authority-conflict",
|
|
79202
|
+
authorityLease: frame.authorityLease
|
|
79203
|
+
});
|
|
79204
|
+
return;
|
|
79205
|
+
}
|
|
79206
|
+
if (this.#holdForWindowOwnership(error, fit)) return;
|
|
79207
|
+
this.#failProtocol("input-rejected");
|
|
78186
79208
|
}
|
|
78187
|
-
|
|
78188
|
-
|
|
79209
|
+
};
|
|
79210
|
+
this.#afterWindowOwnership(fit);
|
|
78189
79211
|
return;
|
|
78190
79212
|
}
|
|
78191
79213
|
this.#acceptInput(
|
|
@@ -78248,6 +79270,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78248
79270
|
}
|
|
78249
79271
|
#deliveryChannel(address) {
|
|
78250
79272
|
const channel = this.#panes.get(address.semanticPaneId);
|
|
79273
|
+
if (channel?.retiredInPlace) return null;
|
|
78251
79274
|
const expected = channel?.deliveryAddress;
|
|
78252
79275
|
if (!channel?.delivery || !expected || expected.workspaceName !== address.workspaceName || expected.generation !== address.generation || expected.deliveryNonce !== address.deliveryNonce || expected.incarnation === null) {
|
|
78253
79276
|
this.#failProtocol("protocol-error");
|
|
@@ -78303,6 +79326,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78303
79326
|
}
|
|
78304
79327
|
#acceptConsumed(pane, seq) {
|
|
78305
79328
|
const channel = this.#panes.get(pane);
|
|
79329
|
+
if (channel?.retiredInPlace) return;
|
|
78306
79330
|
if (!this.#deliveryAcks || !channel || seq <= channel.consumedSeq || seq > channel.sentPaneFrames) {
|
|
78307
79331
|
this.#failProtocol("protocol-error");
|
|
78308
79332
|
return;
|
|
@@ -78330,6 +79354,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78330
79354
|
return;
|
|
78331
79355
|
}
|
|
78332
79356
|
const channel = this.#panes.get(pane);
|
|
79357
|
+
if (channel?.retiredInPlace) return;
|
|
78333
79358
|
const semanticDelivery = this.#descriptor.terminalDelivery !== null;
|
|
78334
79359
|
if (!channel || channel.closed || (semanticDelivery ? !channel.delivery : !channel.sub) || seq !== channel.nextInputSeq) {
|
|
78335
79360
|
this.#failProtocol("input-rejected");
|
|
@@ -78392,85 +79417,198 @@ var init_pane_stream_websocket = __esm({
|
|
|
78392
79417
|
this.#inputWindowFrames += 1;
|
|
78393
79418
|
this.#inputWindowBytes += frameBytes;
|
|
78394
79419
|
channel.nextInputSeq += 1;
|
|
78395
|
-
|
|
78396
|
-
|
|
78397
|
-
|
|
78398
|
-
this.#sessionRuntimeBinding.
|
|
78399
|
-
|
|
78400
|
-
|
|
78401
|
-
|
|
78402
|
-
|
|
78403
|
-
|
|
78404
|
-
|
|
78405
|
-
|
|
78406
|
-
this.#
|
|
78407
|
-
|
|
78408
|
-
|
|
78409
|
-
|
|
78410
|
-
|
|
78411
|
-
|
|
78412
|
-
|
|
78413
|
-
|
|
78414
|
-
|
|
78415
|
-
|
|
78416
|
-
|
|
78417
|
-
|
|
78418
|
-
|
|
78419
|
-
|
|
78420
|
-
|
|
78421
|
-
|
|
78422
|
-
|
|
78423
|
-
|
|
78424
|
-
|
|
78425
|
-
|
|
78426
|
-
|
|
78427
|
-
|
|
78428
|
-
|
|
78429
|
-
|
|
78430
|
-
|
|
78431
|
-
}
|
|
78432
|
-
if (this.#diagnosticSharedRawMicros) {
|
|
79420
|
+
const deliver = () => {
|
|
79421
|
+
if (channel.retiredInPlace) return;
|
|
79422
|
+
try {
|
|
79423
|
+
this.#sessionRuntimeBinding.assertController(pane);
|
|
79424
|
+
if (semanticDelivery)
|
|
79425
|
+
this.#sessionRuntimeBinding.sendInput(
|
|
79426
|
+
pane,
|
|
79427
|
+
{ kind, data },
|
|
79428
|
+
performanceTraceId,
|
|
79429
|
+
causalProbe,
|
|
79430
|
+
causalProbe ? (result2) => {
|
|
79431
|
+
if (this.#closed) return;
|
|
79432
|
+
if (result2.status === "proved") {
|
|
79433
|
+
this.#sendFrame(null, { type: "causal-cell-proof", proof: result2.proof });
|
|
79434
|
+
} else {
|
|
79435
|
+
this.#sendFrame(null, {
|
|
79436
|
+
type: "causal-cell-failure",
|
|
79437
|
+
failure: {
|
|
79438
|
+
version: 1,
|
|
79439
|
+
capability: "causal-cell-v1",
|
|
79440
|
+
traceId: result2.traceId,
|
|
79441
|
+
reason: result2.reason,
|
|
79442
|
+
...result2.diagnostic ? { diagnostic: result2.diagnostic } : {}
|
|
79443
|
+
}
|
|
79444
|
+
});
|
|
79445
|
+
}
|
|
79446
|
+
} : void 0,
|
|
79447
|
+
expectedLifetime
|
|
79448
|
+
);
|
|
79449
|
+
else if (kind === "text") channel.sub.sendText(data);
|
|
79450
|
+
else if (kind === "key") channel.sub.sendKey(data);
|
|
79451
|
+
else throw new Error("Byte input requires semantic runtime");
|
|
79452
|
+
channel.delivery?.prioritize?.();
|
|
79453
|
+
let ackStartedAtMicros = null;
|
|
79454
|
+
let ackStartedAtSharedMicros = null;
|
|
79455
|
+
if (trace) {
|
|
78433
79456
|
try {
|
|
78434
|
-
|
|
79457
|
+
ackStartedAtMicros = this.#observability.nowMicros();
|
|
78435
79458
|
} catch {
|
|
78436
79459
|
}
|
|
78437
|
-
|
|
78438
|
-
|
|
78439
|
-
|
|
78440
|
-
|
|
78441
|
-
|
|
78442
|
-
try {
|
|
78443
|
-
ackEndedAtMicros = this.#observability.nowMicros();
|
|
78444
|
-
} catch {
|
|
78445
|
-
}
|
|
78446
|
-
let ackEndedAtSharedMicros = null;
|
|
78447
|
-
if (ackStartedAtSharedMicros !== null) {
|
|
78448
|
-
try {
|
|
78449
|
-
ackEndedAtSharedMicros = this.#sharedMicros();
|
|
78450
|
-
} catch {
|
|
79460
|
+
if (this.#diagnosticSharedRawMicros) {
|
|
79461
|
+
try {
|
|
79462
|
+
ackStartedAtSharedMicros = this.#sharedMicros();
|
|
79463
|
+
} catch {
|
|
79464
|
+
}
|
|
78451
79465
|
}
|
|
78452
79466
|
}
|
|
78453
|
-
|
|
79467
|
+
sendControl2(this.#socket, { type: "input-ack", pane, seq });
|
|
79468
|
+
if (trace && ackStartedAtMicros !== null) {
|
|
79469
|
+
let ackEndedAtMicros = null;
|
|
78454
79470
|
try {
|
|
78455
|
-
this.#observability.
|
|
78456
|
-
"transport",
|
|
78457
|
-
"pane-stream-input-ack-socket-send",
|
|
78458
|
-
ackStartedAtMicros,
|
|
78459
|
-
ackEndedAtMicros,
|
|
78460
|
-
trace,
|
|
78461
|
-
ackStartedAtSharedMicros === null || ackEndedAtSharedMicros === null ? void 0 : {
|
|
78462
|
-
startedAtMicros: ackStartedAtSharedMicros,
|
|
78463
|
-
endedAtMicros: ackEndedAtSharedMicros
|
|
78464
|
-
}
|
|
78465
|
-
);
|
|
79471
|
+
ackEndedAtMicros = this.#observability.nowMicros();
|
|
78466
79472
|
} catch {
|
|
78467
79473
|
}
|
|
79474
|
+
let ackEndedAtSharedMicros = null;
|
|
79475
|
+
if (ackStartedAtSharedMicros !== null) {
|
|
79476
|
+
try {
|
|
79477
|
+
ackEndedAtSharedMicros = this.#sharedMicros();
|
|
79478
|
+
} catch {
|
|
79479
|
+
}
|
|
79480
|
+
}
|
|
79481
|
+
if (ackEndedAtMicros !== null) {
|
|
79482
|
+
try {
|
|
79483
|
+
this.#observability.recordSpan(
|
|
79484
|
+
"transport",
|
|
79485
|
+
"pane-stream-input-ack-socket-send",
|
|
79486
|
+
ackStartedAtMicros,
|
|
79487
|
+
ackEndedAtMicros,
|
|
79488
|
+
trace,
|
|
79489
|
+
ackStartedAtSharedMicros === null || ackEndedAtSharedMicros === null ? void 0 : {
|
|
79490
|
+
startedAtMicros: ackStartedAtSharedMicros,
|
|
79491
|
+
endedAtMicros: ackEndedAtSharedMicros
|
|
79492
|
+
}
|
|
79493
|
+
);
|
|
79494
|
+
} catch {
|
|
79495
|
+
}
|
|
79496
|
+
}
|
|
79497
|
+
}
|
|
79498
|
+
} catch (error) {
|
|
79499
|
+
if (this.#holdForWindowOwnership(error, deliver)) return;
|
|
79500
|
+
if (error instanceof SessionRuntimeInputLifetimeEndedError) {
|
|
79501
|
+
this.#noteInputLifetimeEnded(pane, error);
|
|
79502
|
+
return;
|
|
78468
79503
|
}
|
|
79504
|
+
this.#fail("control-frame-handler-failed", error);
|
|
78469
79505
|
}
|
|
78470
|
-
}
|
|
78471
|
-
|
|
79506
|
+
};
|
|
79507
|
+
this.#afterWindowOwnership(deliver);
|
|
79508
|
+
}
|
|
79509
|
+
/**
|
|
79510
|
+
* Input and geometry frames that arrive while registered-window ownership is
|
|
79511
|
+
* being read again (another session was created or killed) wait for that
|
|
79512
|
+
* read, in arrival order, instead of closing the stream. The mirror refuses
|
|
79513
|
+
* them meanwhile; before, the stream closed with 1011 and the client had to
|
|
79514
|
+
* reconnect. Bounded: a read that does not settle in time closes as before.
|
|
79515
|
+
*/
|
|
79516
|
+
#ownershipHeld = [];
|
|
79517
|
+
#ownershipDraining = false;
|
|
79518
|
+
/** Ends the drain's wait when the stream closes. */
|
|
79519
|
+
#ownershipWake = null;
|
|
79520
|
+
#afterWindowOwnership(run) {
|
|
79521
|
+
if (this.#ownershipHeld.length === 0 && !this.#mirror.windowOwnershipPending?.()) {
|
|
79522
|
+
run();
|
|
79523
|
+
return;
|
|
79524
|
+
}
|
|
79525
|
+
this.#holdUntilWindowOwnership(run);
|
|
79526
|
+
}
|
|
79527
|
+
/**
|
|
79528
|
+
* Frames whose effect depends on authority order (release, presence,
|
|
79529
|
+
* activity, intents) are not held for the read themselves, but must not
|
|
79530
|
+
* overtake frames that are.
|
|
79531
|
+
*/
|
|
79532
|
+
#afterHeldFrames(run) {
|
|
79533
|
+
if (this.#ownershipHeld.length === 0) {
|
|
79534
|
+
run();
|
|
79535
|
+
return;
|
|
79536
|
+
}
|
|
79537
|
+
this.#holdUntilWindowOwnership(run);
|
|
79538
|
+
}
|
|
79539
|
+
/** A refusal while ownership is pending holds the frame; anything else is the caller's. */
|
|
79540
|
+
#holdForWindowOwnership(error, run) {
|
|
79541
|
+
if (!(error instanceof SessionRuntimeControllerLeaseError) || error.code !== "controller-conflict" || !this.#mirror.windowOwnershipPending?.())
|
|
79542
|
+
return false;
|
|
79543
|
+
this.#ownershipHeld.unshift(run);
|
|
79544
|
+
if (!this.#ownershipDraining) void this.#drainWindowOwnership();
|
|
79545
|
+
return true;
|
|
79546
|
+
}
|
|
79547
|
+
#holdUntilWindowOwnership(run) {
|
|
79548
|
+
if (this.#ownershipHeld.length >= PANE_STREAM_OWNERSHIP_HELD_FRAMES) {
|
|
79549
|
+
this.#ownershipHeld.length = 0;
|
|
79550
|
+
this.#fail("window-ownership-held-overflow");
|
|
79551
|
+
return;
|
|
79552
|
+
}
|
|
79553
|
+
this.#ownershipHeld.push(run);
|
|
79554
|
+
if (!this.#ownershipDraining) void this.#drainWindowOwnership();
|
|
79555
|
+
}
|
|
79556
|
+
async #drainWindowOwnership() {
|
|
79557
|
+
this.#ownershipDraining = true;
|
|
79558
|
+
try {
|
|
79559
|
+
await this.#drainWindowOwnershipOnce();
|
|
79560
|
+
} finally {
|
|
79561
|
+
this.#ownershipDraining = false;
|
|
79562
|
+
}
|
|
79563
|
+
}
|
|
79564
|
+
async #drainWindowOwnershipOnce() {
|
|
79565
|
+
const deadline = Date.now() + this.#ownershipWaitMs;
|
|
79566
|
+
while (!this.#closed && this.#ownershipHeld.length > 0) {
|
|
79567
|
+
if (this.#mirror.windowOwnershipPending?.()) {
|
|
79568
|
+
const left = deadline - Date.now();
|
|
79569
|
+
if (left <= 0) {
|
|
79570
|
+
this.#ownershipHeld.length = 0;
|
|
79571
|
+
this.#fail("window-ownership-unverified");
|
|
79572
|
+
return;
|
|
79573
|
+
}
|
|
79574
|
+
const timers = [];
|
|
79575
|
+
const wait = (ms) => new Promise((resolve47) => {
|
|
79576
|
+
const timer = setTimeout(resolve47, ms);
|
|
79577
|
+
timer.unref?.();
|
|
79578
|
+
timers.push(timer);
|
|
79579
|
+
});
|
|
79580
|
+
const read = this.#mirror.verifyWindowOwnership?.();
|
|
79581
|
+
await Promise.race([
|
|
79582
|
+
// Without a read to wait on, poll instead of spinning.
|
|
79583
|
+
read ? read.catch(() => wait(25)) : wait(25),
|
|
79584
|
+
wait(left),
|
|
79585
|
+
new Promise((resolve47) => {
|
|
79586
|
+
this.#ownershipWake = resolve47;
|
|
79587
|
+
})
|
|
79588
|
+
]);
|
|
79589
|
+
this.#ownershipWake = null;
|
|
79590
|
+
for (const timer of timers) clearTimeout(timer);
|
|
79591
|
+
continue;
|
|
79592
|
+
}
|
|
79593
|
+
const run = this.#ownershipHeld.shift();
|
|
79594
|
+
const before = this.#ownershipHeld.length;
|
|
79595
|
+
run();
|
|
79596
|
+
if (this.#ownershipHeld.length > before) continue;
|
|
78472
79597
|
}
|
|
78473
79598
|
}
|
|
79599
|
+
#inputLifetimeEndedLogged = /* @__PURE__ */ new Set();
|
|
79600
|
+
#inputLifetimeEndedDropped = 0;
|
|
79601
|
+
#noteInputLifetimeEnded(pane, error) {
|
|
79602
|
+
this.#inputLifetimeEndedDropped += 1;
|
|
79603
|
+
if (this.#inputLifetimeEndedLogged.has(pane)) return;
|
|
79604
|
+
this.#inputLifetimeEndedLogged.add(pane);
|
|
79605
|
+
logger.info("pane-stream", "input for an ended pane lifetime not delivered", {
|
|
79606
|
+
session: this.#descriptor.sessionName,
|
|
79607
|
+
clientId: this.#clientId,
|
|
79608
|
+
pane,
|
|
79609
|
+
error: error.message.slice(0, 200)
|
|
79610
|
+
});
|
|
79611
|
+
}
|
|
78474
79612
|
#failProtocol(code2) {
|
|
78475
79613
|
try {
|
|
78476
79614
|
sendControl2(this.#socket, {
|
|
@@ -79381,12 +80519,12 @@ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () =
|
|
|
79381
80519
|
const row = rows.get(liveSessionId) ?? {
|
|
79382
80520
|
summary: { liveSessionId, sessionName: name, paneCount: 0 },
|
|
79383
80521
|
panes: /* @__PURE__ */ new Set(),
|
|
79384
|
-
windows: /* @__PURE__ */ new
|
|
80522
|
+
windows: /* @__PURE__ */ new Map(),
|
|
79385
80523
|
dir,
|
|
79386
80524
|
activity: activity && /^\d+$/.test(activity) ? Number(activity) : null
|
|
79387
80525
|
};
|
|
80526
|
+
if (!row.panes.has(pane)) row.windows.set(window2, (row.windows.get(window2) ?? 0) + 1);
|
|
79388
80527
|
row.panes.add(pane);
|
|
79389
|
-
row.windows.add(window2);
|
|
79390
80528
|
rows.set(liveSessionId, row);
|
|
79391
80529
|
}
|
|
79392
80530
|
const names = new Set([...rows.values()].map(({ summary }) => summary.sessionName));
|
|
@@ -79405,6 +80543,7 @@ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () =
|
|
|
79405
80543
|
...summary,
|
|
79406
80544
|
paneCount: panes.size,
|
|
79407
80545
|
windowCount: windows.size,
|
|
80546
|
+
largestWindowPaneCount: Math.max(...windows.values()),
|
|
79408
80547
|
lastActivity: activity,
|
|
79409
80548
|
sessionPath: dir
|
|
79410
80549
|
}));
|
|
@@ -81096,7 +82235,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
81096
82235
|
const snapshot3 = async (liveSessionId, signal, windowId, paneId) => {
|
|
81097
82236
|
const nativeEpoch = native2?.serverEpoch() ?? null;
|
|
81098
82237
|
let sessionGuard;
|
|
81099
|
-
const
|
|
82238
|
+
const readSessions2 = async () => {
|
|
81100
82239
|
const raw = await run(
|
|
81101
82240
|
["list-panes", "-a", "-F", "#{pid} #{session_id} #{session_created} #{session_name}"],
|
|
81102
82241
|
signal
|
|
@@ -81109,7 +82248,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
81109
82248
|
}
|
|
81110
82249
|
return discoverLiveSessionSummaries(() => raw);
|
|
81111
82250
|
};
|
|
81112
|
-
const session = (await
|
|
82251
|
+
const session = (await readSessions2()).find((s) => s.liveSessionId === liveSessionId);
|
|
81113
82252
|
if (!session) return null;
|
|
81114
82253
|
const readPanes = async () => (await run(
|
|
81115
82254
|
[
|
|
@@ -81186,7 +82325,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
81186
82325
|
signal
|
|
81187
82326
|
) : null;
|
|
81188
82327
|
const captured = owned ? owned.output : await run(["capture-pane", "-p", "-t", pane, "-S", "-24"], signal);
|
|
81189
|
-
const [currentSessions, currentPanes] = await Promise.all([
|
|
82328
|
+
const [currentSessions, currentPanes] = await Promise.all([readSessions2(), readPanes()]);
|
|
81190
82329
|
if (!currentSessions.some((s) => s.liveSessionId === liveSessionId)) return null;
|
|
81191
82330
|
if (selectedWindowId && !currentPanes.some((r) => r[3] === selectedWindowId && r[0] === pane))
|
|
81192
82331
|
return null;
|
|
@@ -88993,7 +90132,7 @@ var init_plugin_store = __esm({
|
|
|
88993
90132
|
|
|
88994
90133
|
// packages/daemon/src/plugins/worktree-calls.ts
|
|
88995
90134
|
import { spawn as spawn9 } from "node:child_process";
|
|
88996
|
-
import { homedir as
|
|
90135
|
+
import { homedir as homedir6 } from "node:os";
|
|
88997
90136
|
import { z as z130 } from "zod";
|
|
88998
90137
|
function fail3(message) {
|
|
88999
90138
|
throw new WorktreeCallError(message);
|
|
@@ -89054,7 +90193,7 @@ function cliRunner(command3, timeoutMs = 6e4) {
|
|
|
89054
90193
|
return (args, env) => new Promise((resolve47, reject) => {
|
|
89055
90194
|
const [file, ...prefix] = command3;
|
|
89056
90195
|
const child = spawn9(file, [...prefix, ...args], {
|
|
89057
|
-
cwd:
|
|
90196
|
+
cwd: homedir6(),
|
|
89058
90197
|
env,
|
|
89059
90198
|
stdio: ["ignore", "pipe", "pipe"]
|
|
89060
90199
|
});
|
|
@@ -91490,6 +92629,37 @@ function projectTerminalRuntimeInventory(session, resourceRevision) {
|
|
|
91490
92629
|
].sort()
|
|
91491
92630
|
});
|
|
91492
92631
|
}
|
|
92632
|
+
function projectTerminalRuntimeInventoryV2(session, resourceRevision) {
|
|
92633
|
+
const identities = paneIdentities(session);
|
|
92634
|
+
const windows = /* @__PURE__ */ new Map();
|
|
92635
|
+
session.panes.forEach((pane, index) => {
|
|
92636
|
+
if (pane.windowId === void 0) return;
|
|
92637
|
+
const stamp = pane.windowStamp ?? null;
|
|
92638
|
+
const entry = windows.get(pane.windowId) ?? {
|
|
92639
|
+
semanticWindowId: stamp,
|
|
92640
|
+
active: false,
|
|
92641
|
+
panes: [],
|
|
92642
|
+
complete: true
|
|
92643
|
+
};
|
|
92644
|
+
windows.set(pane.windowId, entry);
|
|
92645
|
+
const attachability = identities[index].attachability;
|
|
92646
|
+
if (attachability.status === "available") entry.panes.push(attachability.semanticPaneId);
|
|
92647
|
+
else entry.complete = false;
|
|
92648
|
+
if (pane.active) entry.active = true;
|
|
92649
|
+
});
|
|
92650
|
+
return TerminalRuntimeInventoryProjectionV2SchemaZ.parse({
|
|
92651
|
+
...projectTerminalRuntimeInventory(session, resourceRevision),
|
|
92652
|
+
windows: [...windows.values()].flatMap(
|
|
92653
|
+
(window2) => window2.complete && window2.semanticWindowId !== null && window2.panes.length > 0 ? [
|
|
92654
|
+
{
|
|
92655
|
+
semanticWindowId: window2.semanticWindowId,
|
|
92656
|
+
active: window2.active,
|
|
92657
|
+
semanticPaneIds: [...window2.panes].sort()
|
|
92658
|
+
}
|
|
92659
|
+
] : []
|
|
92660
|
+
)
|
|
92661
|
+
});
|
|
92662
|
+
}
|
|
91493
92663
|
function terminalRuntimeInventoryEnvelope(daemon, session, resourceRevision) {
|
|
91494
92664
|
return {
|
|
91495
92665
|
version: TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION,
|
|
@@ -91740,7 +92910,8 @@ function mountTmuxServerRoutes(app, options) {
|
|
|
91740
92910
|
`${scoped}/sessions`,
|
|
91741
92911
|
route(async (c) => {
|
|
91742
92912
|
const server = scope2(c);
|
|
91743
|
-
const
|
|
92913
|
+
const v3 = c.req.query("version") === "3";
|
|
92914
|
+
const v2 = v3 || c.req.query("version") === "2";
|
|
91744
92915
|
const { rows, favicons } = await options.owners.withOwner(server, async (owner) => {
|
|
91745
92916
|
const sessions = await owner.catalog();
|
|
91746
92917
|
const workspaces = owner.workspaceRegistry.list();
|
|
@@ -91771,9 +92942,10 @@ function mountTmuxServerRoutes(app, options) {
|
|
|
91771
92942
|
})
|
|
91772
92943
|
);
|
|
91773
92944
|
let budget2 = SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES;
|
|
92945
|
+
const schema = v3 ? TmuxServerSessionsResourceV3SchemaZ : TmuxServerSessionsResourceV2SchemaZ;
|
|
91774
92946
|
return c.json(
|
|
91775
|
-
|
|
91776
|
-
version: 2,
|
|
92947
|
+
schema.parse({
|
|
92948
|
+
version: v3 ? 3 : 2,
|
|
91777
92949
|
server,
|
|
91778
92950
|
sessions: rows.map(({ session, workspaceName }, index) => {
|
|
91779
92951
|
const found = favicons[index] ?? null;
|
|
@@ -91785,6 +92957,7 @@ function mountTmuxServerRoutes(app, options) {
|
|
|
91785
92957
|
workspaceName,
|
|
91786
92958
|
paneCount: session.paneCount,
|
|
91787
92959
|
windowCount: session.windowCount,
|
|
92960
|
+
...v3 ? { largestWindowPaneCount: session.largestWindowPaneCount } : {},
|
|
91788
92961
|
lastActivity: session.lastActivity,
|
|
91789
92962
|
favicon: favicon ? { mime: favicon.mime, data: favicon.data } : null
|
|
91790
92963
|
};
|
|
@@ -91812,6 +92985,7 @@ function mountTmuxServerRoutes(app, options) {
|
|
|
91812
92985
|
route(async (c) => {
|
|
91813
92986
|
const server = scope2(c);
|
|
91814
92987
|
const workspaceName = workspaceSchema.parse(c.req.param("workspaceName"));
|
|
92988
|
+
const v2 = c.req.query("version") === "2";
|
|
91815
92989
|
const resource3 = await options.owners.withOwner(server, async (owner) => {
|
|
91816
92990
|
const sessions = await owner.catalog();
|
|
91817
92991
|
const workspace = owner.workspaceRegistry.get(workspaceName);
|
|
@@ -91825,9 +92999,10 @@ function mountTmuxServerRoutes(app, options) {
|
|
|
91825
92999
|
workspace.sessionName,
|
|
91826
93000
|
c.req.raw.signal
|
|
91827
93001
|
);
|
|
91828
|
-
|
|
93002
|
+
if (!snapshot3) return null;
|
|
93003
|
+
return v2 ? projectTerminalRuntimeInventoryV2(snapshot3, 0) : projectTerminalRuntimeInventory(snapshot3, 0);
|
|
91829
93004
|
});
|
|
91830
|
-
return resource3 ? c.json({ version: 1, server, resource: resource3 }) : c.json({ error: { code: "workspace-not-found" } }, 404);
|
|
93005
|
+
return resource3 ? c.json({ version: v2 ? 2 : 1, server, resource: resource3 }) : c.json({ error: { code: "workspace-not-found" } }, 404);
|
|
91831
93006
|
})
|
|
91832
93007
|
);
|
|
91833
93008
|
app.get(
|
|
@@ -92908,7 +94083,7 @@ __export(auth_service_exports, {
|
|
|
92908
94083
|
import * as crypto2 from "node:crypto";
|
|
92909
94084
|
import { readFileSync as readFileSync35, existsSync as existsSync33 } from "node:fs";
|
|
92910
94085
|
import { join as join56 } from "node:path";
|
|
92911
|
-
import { homedir as
|
|
94086
|
+
import { homedir as homedir7 } from "node:os";
|
|
92912
94087
|
function base64url(buf) {
|
|
92913
94088
|
const b = typeof buf === "string" ? Buffer.from(buf) : buf;
|
|
92914
94089
|
return b.toString("base64url");
|
|
@@ -93052,7 +94227,7 @@ var init_auth_service = __esm({
|
|
|
93052
94227
|
checkSSHKeyAuthorization(userId, publicKey) {
|
|
93053
94228
|
if (resolveRuntimeNamespace().development) return false;
|
|
93054
94229
|
try {
|
|
93055
|
-
const home = userId === process.env.USER ?
|
|
94230
|
+
const home = userId === process.env.USER ? homedir7() : `/home/${userId}`;
|
|
93056
94231
|
const authKeysPath = join56(home, ".ssh", "authorized_keys");
|
|
93057
94232
|
if (!existsSync33(authKeysPath)) return false;
|
|
93058
94233
|
const authorizedKeys = readFileSync35(authKeysPath, "utf-8");
|
|
@@ -96078,7 +97253,7 @@ var init_inspect = __esm({
|
|
|
96078
97253
|
|
|
96079
97254
|
// packages/daemon/src/lib/filesystem-browser.ts
|
|
96080
97255
|
import { realpathSync as realpathSync26, readdirSync as readdirSync9, statSync as statSync27 } from "node:fs";
|
|
96081
|
-
import { homedir as
|
|
97256
|
+
import { homedir as homedir8 } from "node:os";
|
|
96082
97257
|
import { isAbsolute as isAbsolute31, join as join57, resolve as resolve33, sep as sep13 } from "node:path";
|
|
96083
97258
|
function isUnderRoot(canonical, root) {
|
|
96084
97259
|
if (canonical === root) return true;
|
|
@@ -99776,7 +100951,7 @@ import { cors } from "hono/cors";
|
|
|
99776
100951
|
import { zValidator } from "@hono/zod-validator";
|
|
99777
100952
|
import { z as z142 } from "zod";
|
|
99778
100953
|
import { realpathSync as realpathSync29 } from "node:fs";
|
|
99779
|
-
import { homedir as
|
|
100954
|
+
import { homedir as homedir9 } from "node:os";
|
|
99780
100955
|
import { isAbsolute as isAbsolute34, resolve as pathResolve } from "node:path";
|
|
99781
100956
|
import { randomUUID as randomUUID51 } from "node:crypto";
|
|
99782
100957
|
import { WebSocketServer as WebSocketServer4 } from "ws";
|
|
@@ -99878,7 +101053,7 @@ function sandboxResolveDir(rawDir) {
|
|
|
99878
101053
|
if (trimmed.includes("\0")) {
|
|
99879
101054
|
return { error: "invalid-path", message: "Path contains a null byte", status: 400 };
|
|
99880
101055
|
}
|
|
99881
|
-
const home = process.env.TMUX_IDE_HOME_OVERRIDE && process.env.TMUX_IDE_HOME_OVERRIDE.trim().length > 0 ? process.env.TMUX_IDE_HOME_OVERRIDE :
|
|
101056
|
+
const home = process.env.TMUX_IDE_HOME_OVERRIDE && process.env.TMUX_IDE_HOME_OVERRIDE.trim().length > 0 ? process.env.TMUX_IDE_HOME_OVERRIDE : homedir9();
|
|
99882
101057
|
let candidate = trimmed;
|
|
99883
101058
|
if (candidate === "~") {
|
|
99884
101059
|
candidate = home;
|
|
@@ -99914,6 +101089,12 @@ function sandboxResolveDir(rawDir) {
|
|
|
99914
101089
|
return { canonical };
|
|
99915
101090
|
}
|
|
99916
101091
|
function createApp(options = {}) {
|
|
101092
|
+
const lookupSession = (name) => {
|
|
101093
|
+
const sessions = readSessions();
|
|
101094
|
+
if (sessions === null) return "unavailable";
|
|
101095
|
+
return sessions.find((session) => session.name === name) ?? "not-found";
|
|
101096
|
+
};
|
|
101097
|
+
const sessionMissing = (c, missing) => missing === "unavailable" ? c.json({ error: "Tmux session discovery is unavailable", code: "tmux-unavailable" }, 503) : c.json({ error: "Session not found" }, 404);
|
|
99917
101098
|
const authConfig = options.authConfig ?? { method: "none", token_expiry: 86400 };
|
|
99918
101099
|
const authService = options.authService ?? new AuthService();
|
|
99919
101100
|
const daemonIdentity = options.daemonIdentity ?? {
|
|
@@ -100140,7 +101321,12 @@ function createApp(options = {}) {
|
|
|
100140
101321
|
});
|
|
100141
101322
|
});
|
|
100142
101323
|
app.get("/api/sessions", (c) => {
|
|
100143
|
-
const sessions =
|
|
101324
|
+
const sessions = readSessions();
|
|
101325
|
+
if (sessions === null)
|
|
101326
|
+
return c.json(
|
|
101327
|
+
{ error: "Tmux session discovery is unavailable", code: "tmux-unavailable" },
|
|
101328
|
+
503
|
|
101329
|
+
);
|
|
100144
101330
|
const overviews = buildOverviews(sessions);
|
|
100145
101331
|
return c.json({ sessions: overviews });
|
|
100146
101332
|
});
|
|
@@ -100256,11 +101442,8 @@ function createApp(options = {}) {
|
|
|
100256
101442
|
});
|
|
100257
101443
|
app.get("/api/project/:name", (c) => {
|
|
100258
101444
|
const name = c.req.param("name");
|
|
100259
|
-
const
|
|
100260
|
-
|
|
100261
|
-
if (!session) {
|
|
100262
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100263
|
-
}
|
|
101445
|
+
const session = lookupSession(name);
|
|
101446
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100264
101447
|
const detail = buildProjectDetail(session);
|
|
100265
101448
|
return c.json({ ...detail });
|
|
100266
101449
|
});
|
|
@@ -100368,8 +101551,8 @@ function createApp(options = {}) {
|
|
|
100368
101551
|
const backend2 = options.applicationShellInventoryBackend;
|
|
100369
101552
|
if (!backend2) {
|
|
100370
101553
|
if (requestedVersion === String(APPLICATION_SHELL_RESOURCE_V1_VERSION)) {
|
|
100371
|
-
const standaloneSession =
|
|
100372
|
-
if (
|
|
101554
|
+
const standaloneSession = lookupSession(name);
|
|
101555
|
+
if (typeof standaloneSession === "string") return sessionMissing(c, standaloneSession);
|
|
100373
101556
|
markV1Compatibility();
|
|
100374
101557
|
return c.json({
|
|
100375
101558
|
version: APPLICATION_SHELL_RESOURCE_V1_VERSION,
|
|
@@ -100438,13 +101621,12 @@ function createApp(options = {}) {
|
|
|
100438
101621
|
try {
|
|
100439
101622
|
panes = listSessionPanes(name);
|
|
100440
101623
|
} catch {
|
|
100441
|
-
|
|
101624
|
+
const session = lookupSession(name);
|
|
101625
|
+
return sessionMissing(c, typeof session === "string" ? session : "not-found");
|
|
100442
101626
|
}
|
|
100443
101627
|
if (panes.length === 0) {
|
|
100444
|
-
const
|
|
100445
|
-
if (
|
|
100446
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100447
|
-
}
|
|
101628
|
+
const session = lookupSession(name);
|
|
101629
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100448
101630
|
}
|
|
100449
101631
|
return c.json({
|
|
100450
101632
|
panes: panes.map((p) => ({
|
|
@@ -100463,9 +101645,8 @@ function createApp(options = {}) {
|
|
|
100463
101645
|
});
|
|
100464
101646
|
app.get("/api/project/:name/terminals", async (c) => {
|
|
100465
101647
|
const name = c.req.param("name");
|
|
100466
|
-
const
|
|
100467
|
-
|
|
100468
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101648
|
+
const session = lookupSession(name);
|
|
101649
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100469
101650
|
const records = loadTerminals(session.dir);
|
|
100470
101651
|
const terminals = records.map((t) => {
|
|
100471
101652
|
const bridge = defaultPtyBridgeRegistry.peek(t.id);
|
|
@@ -100490,9 +101671,8 @@ function createApp(options = {}) {
|
|
|
100490
101671
|
zValidator("json", terminalCreateRequestSchema),
|
|
100491
101672
|
async (c) => {
|
|
100492
101673
|
const name = c.req.param("name");
|
|
100493
|
-
const
|
|
100494
|
-
|
|
100495
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101674
|
+
const session = lookupSession(name);
|
|
101675
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100496
101676
|
const body = c.req.valid("json");
|
|
100497
101677
|
let id2 = body.id;
|
|
100498
101678
|
let scripted = false;
|
|
@@ -100530,9 +101710,8 @@ function createApp(options = {}) {
|
|
|
100530
101710
|
async (c) => {
|
|
100531
101711
|
const name = c.req.param("name");
|
|
100532
101712
|
const id2 = c.req.param("id");
|
|
100533
|
-
const
|
|
100534
|
-
|
|
100535
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101713
|
+
const session = lookupSession(name);
|
|
101714
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100536
101715
|
try {
|
|
100537
101716
|
const record2 = renameTerminal(session.dir, id2, c.req.valid("json").name);
|
|
100538
101717
|
if (!record2) return c.json({ error: "Terminal not found" }, 404);
|
|
@@ -100546,9 +101725,8 @@ function createApp(options = {}) {
|
|
|
100546
101725
|
app.delete("/api/project/:name/terminals/:id", async (c) => {
|
|
100547
101726
|
const name = c.req.param("name");
|
|
100548
101727
|
const id2 = c.req.param("id");
|
|
100549
|
-
const
|
|
100550
|
-
|
|
100551
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101728
|
+
const session = lookupSession(name);
|
|
101729
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100552
101730
|
const removedRecord = deleteTerminal(session.dir, id2);
|
|
100553
101731
|
const killed = defaultPtyBridgeRegistry.delete(id2);
|
|
100554
101732
|
if (!removedRecord && !killed) {
|
|
@@ -100559,18 +101737,14 @@ function createApp(options = {}) {
|
|
|
100559
101737
|
});
|
|
100560
101738
|
app.get("/api/project/:name/events", (c) => {
|
|
100561
101739
|
const name = c.req.param("name");
|
|
100562
|
-
const session =
|
|
100563
|
-
if (
|
|
100564
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100565
|
-
}
|
|
101740
|
+
const session = lookupSession(name);
|
|
101741
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100566
101742
|
return c.json({ events: [] });
|
|
100567
101743
|
});
|
|
100568
101744
|
app.get("/api/project/:name/stream", (c) => {
|
|
100569
101745
|
const name = c.req.param("name");
|
|
100570
|
-
const session =
|
|
100571
|
-
if (
|
|
100572
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100573
|
-
}
|
|
101746
|
+
const session = lookupSession(name);
|
|
101747
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100574
101748
|
return streamSSE3(c, async (stream) => {
|
|
100575
101749
|
projectStreamConnections += 1;
|
|
100576
101750
|
sseMetrics.connections = projectStreamConnections;
|
|
@@ -100596,9 +101770,9 @@ function createApp(options = {}) {
|
|
|
100596
101770
|
writeChanges(session);
|
|
100597
101771
|
while (!closed) {
|
|
100598
101772
|
await stream.sleep(250);
|
|
100599
|
-
const current =
|
|
100600
|
-
if (
|
|
100601
|
-
writeChanges(current);
|
|
101773
|
+
const current = lookupSession(name);
|
|
101774
|
+
if (current === "not-found") break;
|
|
101775
|
+
if (current !== "unavailable") writeChanges(current);
|
|
100602
101776
|
const now = Date.now();
|
|
100603
101777
|
if (now - lastPing >= 25e3) {
|
|
100604
101778
|
writeSse("ping", { at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
@@ -100613,11 +101787,8 @@ function createApp(options = {}) {
|
|
|
100613
101787
|
});
|
|
100614
101788
|
app.post("/api/project/:name/inject", async (c) => {
|
|
100615
101789
|
const name = c.req.param("name");
|
|
100616
|
-
const
|
|
100617
|
-
|
|
100618
|
-
if (!session) {
|
|
100619
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100620
|
-
}
|
|
101790
|
+
const session = lookupSession(name);
|
|
101791
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100621
101792
|
let body;
|
|
100622
101793
|
try {
|
|
100623
101794
|
body = await c.req.json();
|
|
@@ -100650,11 +101821,8 @@ function createApp(options = {}) {
|
|
|
100650
101821
|
});
|
|
100651
101822
|
app.post("/api/project/:name/send", zValidator("json", sendCommandSchema), async (c) => {
|
|
100652
101823
|
const name = c.req.param("name");
|
|
100653
|
-
const
|
|
100654
|
-
|
|
100655
|
-
if (!session) {
|
|
100656
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100657
|
-
}
|
|
101824
|
+
const session = lookupSession(name);
|
|
101825
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100658
101826
|
const { target, message, noEnter } = c.req.valid("json");
|
|
100659
101827
|
const panes = listSessionPanes(name);
|
|
100660
101828
|
const pane = resolvePane(panes, target);
|
|
@@ -100688,9 +101856,8 @@ function createApp(options = {}) {
|
|
|
100688
101856
|
});
|
|
100689
101857
|
app.get("/api/project/:name/config", async (c) => {
|
|
100690
101858
|
const name = c.req.param("name");
|
|
100691
|
-
const
|
|
100692
|
-
|
|
100693
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101859
|
+
const session = lookupSession(name);
|
|
101860
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100694
101861
|
try {
|
|
100695
101862
|
const resolved2 = await resolveConfig(session.dir);
|
|
100696
101863
|
if (!resolved2.launchConfig || !resolved2.path) {
|
|
@@ -100712,9 +101879,8 @@ function createApp(options = {}) {
|
|
|
100712
101879
|
});
|
|
100713
101880
|
app.post("/api/project/:name/config", async (c) => {
|
|
100714
101881
|
const name = c.req.param("name");
|
|
100715
|
-
const
|
|
100716
|
-
|
|
100717
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101882
|
+
const session = lookupSession(name);
|
|
101883
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100718
101884
|
let body;
|
|
100719
101885
|
try {
|
|
100720
101886
|
body = await c.req.json();
|
|
@@ -100746,9 +101912,8 @@ function createApp(options = {}) {
|
|
|
100746
101912
|
const execFileAsync2 = promisify4(execFile15);
|
|
100747
101913
|
app.post("/api/project/:name/restart", async (c) => {
|
|
100748
101914
|
const name = c.req.param("name");
|
|
100749
|
-
const
|
|
100750
|
-
|
|
100751
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101915
|
+
const session = lookupSession(name);
|
|
101916
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100752
101917
|
try {
|
|
100753
101918
|
await execFileAsync2("tmux-ide", ["restart", "--json"], {
|
|
100754
101919
|
cwd: session.dir,
|
|
@@ -100763,11 +101928,8 @@ function createApp(options = {}) {
|
|
|
100763
101928
|
});
|
|
100764
101929
|
app.post("/api/project/:name/launch", async (c) => {
|
|
100765
101930
|
const name = c.req.param("name");
|
|
100766
|
-
const
|
|
100767
|
-
|
|
100768
|
-
if (!session) {
|
|
100769
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100770
|
-
}
|
|
101931
|
+
const session = lookupSession(name);
|
|
101932
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100771
101933
|
const state = getSessionState(name);
|
|
100772
101934
|
if (state.running) {
|
|
100773
101935
|
return c.json({ ok: true, session: name, status: "already_running" });
|
|
@@ -100787,11 +101949,8 @@ function createApp(options = {}) {
|
|
|
100787
101949
|
});
|
|
100788
101950
|
app.post("/api/project/:name/stop", async (c) => {
|
|
100789
101951
|
const name = c.req.param("name");
|
|
100790
|
-
const
|
|
100791
|
-
|
|
100792
|
-
if (!session) {
|
|
100793
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100794
|
-
}
|
|
101952
|
+
const session = lookupSession(name);
|
|
101953
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100795
101954
|
const state = getSessionState(name);
|
|
100796
101955
|
if (!state.running) {
|
|
100797
101956
|
return c.json({ ok: true, session: name, status: "not_running" });
|
|
@@ -100807,7 +101966,8 @@ function createApp(options = {}) {
|
|
|
100807
101966
|
return streamSSE3(c, async (stream) => {
|
|
100808
101967
|
let prevOverviews = [];
|
|
100809
101968
|
const poll = () => {
|
|
100810
|
-
const sessions =
|
|
101969
|
+
const sessions = readSessions();
|
|
101970
|
+
if (sessions === null) return;
|
|
100811
101971
|
const overviews = buildOverviews(sessions);
|
|
100812
101972
|
const prevNames = new Set(prevOverviews.map((s) => s.name));
|
|
100813
101973
|
const currNames = new Set(overviews.map((s) => s.name));
|
|
@@ -102432,6 +103592,14 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102432
103592
|
};
|
|
102433
103593
|
terminalInventoryRuntime = new WorkspaceTerminalInventoryRuntime(terminalRuntimeOptions);
|
|
102434
103594
|
await terminalInventoryRuntime.whenReady();
|
|
103595
|
+
const snapshotInventory = terminalInventoryRuntime;
|
|
103596
|
+
startDaemonCrashSnapshot(
|
|
103597
|
+
daemonCrashSnapshotStart(
|
|
103598
|
+
opts,
|
|
103599
|
+
(args) => fleetFactsTmuxRunner(args),
|
|
103600
|
+
() => ["disposed", "failed"].includes(snapshotInventory.lifecycleState())
|
|
103601
|
+
)
|
|
103602
|
+
);
|
|
102435
103603
|
const getTerminalAttachmentRuntime = () => {
|
|
102436
103604
|
if (terminalAttachmentRuntime) return terminalAttachmentRuntime;
|
|
102437
103605
|
terminalAttachmentRuntime = createNativeTerminalAttachmentRuntime({
|
|
@@ -103270,6 +104438,7 @@ var init_daemon_embed = __esm({
|
|
|
103270
104438
|
"use strict";
|
|
103271
104439
|
init_tmux_pane_reader();
|
|
103272
104440
|
init_tmux_native_browser();
|
|
104441
|
+
init_daemon_crash_snapshot();
|
|
103273
104442
|
init_native_surface_context();
|
|
103274
104443
|
init_native_surface_provider();
|
|
103275
104444
|
init_src2();
|
|
@@ -103365,9 +104534,11 @@ var init_daemon_embed = __esm({
|
|
|
103365
104534
|
// packages/daemon/src/lib/headless-daemon.ts
|
|
103366
104535
|
var headless_daemon_exports = {};
|
|
103367
104536
|
__export(headless_daemon_exports, {
|
|
104537
|
+
OWN_SERVER_PROOF_RESTARTS: () => OWN_SERVER_PROOF_RESTARTS,
|
|
103368
104538
|
SIGNAL_STOP_DEADLINE_MS: () => SIGNAL_STOP_DEADLINE_MS,
|
|
103369
104539
|
SIGNAL_STOP_MAX_MS: () => SIGNAL_STOP_MAX_MS,
|
|
103370
104540
|
SIGNAL_STOP_TIMEOUT_EXIT_CODE: () => SIGNAL_STOP_TIMEOUT_EXIT_CODE,
|
|
104541
|
+
ownServerProofRetry: () => ownServerProofRetry,
|
|
103371
104542
|
runHeadlessDaemon: () => runHeadlessDaemon
|
|
103372
104543
|
});
|
|
103373
104544
|
function activeResourceCounts() {
|
|
@@ -103441,8 +104612,16 @@ async function assertAttachableDaemon(deps2, info, options) {
|
|
|
103441
104612
|
);
|
|
103442
104613
|
}
|
|
103443
104614
|
assertIdentityMatches(info, identity4);
|
|
104615
|
+
let first = true;
|
|
103444
104616
|
await assertCanonicalDaemonServerIntent(info, options.tmuxServerIntent ?? null, {
|
|
103445
|
-
|
|
104617
|
+
...deps2.serverProof ? { serverProof: deps2.serverProof } : {},
|
|
104618
|
+
identity: async () => {
|
|
104619
|
+
if (first) {
|
|
104620
|
+
first = false;
|
|
104621
|
+
return identity4;
|
|
104622
|
+
}
|
|
104623
|
+
return deps2.probeCanonicalDaemonIdentity(info, void 0, true);
|
|
104624
|
+
}
|
|
103446
104625
|
});
|
|
103447
104626
|
const health = await deps2.probeCanonicalDaemonHealth(info);
|
|
103448
104627
|
if (!health) {
|
|
@@ -103490,8 +104669,15 @@ async function findLiveCanonicalDaemon(deps2, options, predecessor) {
|
|
|
103490
104669
|
function delay3(ms) {
|
|
103491
104670
|
return new Promise((resolve47) => setTimeout(resolve47, ms));
|
|
103492
104671
|
}
|
|
104672
|
+
function ownServerProofRetry(error, state) {
|
|
104673
|
+
if (!(error instanceof DaemonBootstrapError) || error.reason !== "tmux-server-unproven" || state.restarts >= OWN_SERVER_PROOF_RESTARTS)
|
|
104674
|
+
return null;
|
|
104675
|
+
return { delayMs: 250 * (state.restarts + 1) };
|
|
104676
|
+
}
|
|
103493
104677
|
function isTransientAttachabilityError(error) {
|
|
103494
|
-
return error instanceof IdeError && (error.code === "DAEMON_IDENTITY_UNAVAILABLE" || error.code === "DAEMON_UNHEALTHY")
|
|
104678
|
+
return error instanceof IdeError && (error.code === "DAEMON_IDENTITY_UNAVAILABLE" || error.code === "DAEMON_UNHEALTHY") || // A generation started on a replaced tmux server proves it a moment
|
|
104679
|
+
// later (soak o3: the daemon exited at startup instead of waiting).
|
|
104680
|
+
daemonServerProofPending(error);
|
|
103495
104681
|
}
|
|
103496
104682
|
async function waitForAttachableDaemon(deps2, info, options, timeoutMs = DAEMON_ATTACHABILITY_TIMEOUT_MS, shouldAbort = () => false) {
|
|
103497
104683
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -103659,6 +104845,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103659
104845
|
handle = await deps2.startEmbeddedDaemon({
|
|
103660
104846
|
launcher: "headless",
|
|
103661
104847
|
plugins: true,
|
|
104848
|
+
...options.crashSnapshotSource ? { crashSnapshotSource: options.crashSnapshotSource } : {},
|
|
103662
104849
|
...options.supervisionId ? { supervisionId: options.supervisionId, predecessor: lifecycle.predecessor } : {},
|
|
103663
104850
|
...restoreTmuxWorkspaces ? { restoreTmuxWorkspaces: true } : {},
|
|
103664
104851
|
port,
|
|
@@ -103779,7 +104966,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103779
104966
|
deps2,
|
|
103780
104967
|
info,
|
|
103781
104968
|
options,
|
|
103782
|
-
DAEMON_ATTACHABILITY_TIMEOUT_MS,
|
|
104969
|
+
deps2.attachabilityTimeoutMs ?? DAEMON_ATTACHABILITY_TIMEOUT_MS,
|
|
103783
104970
|
() => signalRequested
|
|
103784
104971
|
);
|
|
103785
104972
|
options.onOwnedReady?.(info);
|
|
@@ -103789,8 +104976,29 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103789
104976
|
if (stopFailure) throw stopFailure;
|
|
103790
104977
|
return "stopped";
|
|
103791
104978
|
}
|
|
103792
|
-
|
|
104979
|
+
const retry = ownServerProofRetry(error, {
|
|
104980
|
+
startReason,
|
|
104981
|
+
restarts: lifecycle.ownServerProofRestarts ?? 0
|
|
104982
|
+
});
|
|
104983
|
+
if (!retry) throw error;
|
|
104984
|
+
lifecycle.ownServerProofRestarts = (lifecycle.ownServerProofRestarts ?? 0) + 1;
|
|
104985
|
+
logger.warn(
|
|
104986
|
+
"daemon-lifecycle",
|
|
104987
|
+
"generation could not prove its own tmux server; starting it again",
|
|
104988
|
+
{
|
|
104989
|
+
generation,
|
|
104990
|
+
startReason,
|
|
104991
|
+
reason: error.reason,
|
|
104992
|
+
restart: lifecycle.ownServerProofRestarts,
|
|
104993
|
+
delayMs: retry.delayMs
|
|
104994
|
+
}
|
|
104995
|
+
);
|
|
104996
|
+
await (deps2.delay ?? delay3)(retry.delayMs);
|
|
104997
|
+
if (signalRequested) return "stopped";
|
|
104998
|
+
lifecycle.startReason = "tmux-server-unproven";
|
|
104999
|
+
return "restart";
|
|
103793
105000
|
}
|
|
105001
|
+
lifecycle.ownServerProofRestarts = 0;
|
|
103794
105002
|
lifecycle.lastPort = info.port;
|
|
103795
105003
|
emitStatus(deps2, options.json === true, "ready", info);
|
|
103796
105004
|
logger[generation > 1 ? "info" : "debug"]("daemon-lifecycle", "generation ready", {
|
|
@@ -103833,7 +105041,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103833
105041
|
deps2.offSignal("SIGTERM", onSigterm);
|
|
103834
105042
|
}
|
|
103835
105043
|
}
|
|
103836
|
-
var SIGNAL_STOP_DEADLINE_MS, SIGNAL_STOP_MAX_MS, SIGNAL_STOP_TIMEOUT_EXIT_CODE, defaultDependencies2, DAEMON_ATTACHABILITY_TIMEOUT_MS, DAEMON_ATTACHABILITY_POLL_MS;
|
|
105044
|
+
var SIGNAL_STOP_DEADLINE_MS, SIGNAL_STOP_MAX_MS, SIGNAL_STOP_TIMEOUT_EXIT_CODE, defaultDependencies2, OWN_SERVER_PROOF_RESTARTS, DAEMON_ATTACHABILITY_TIMEOUT_MS, DAEMON_ATTACHABILITY_POLL_MS;
|
|
103837
105045
|
var init_headless_daemon = __esm({
|
|
103838
105046
|
"packages/daemon/src/lib/headless-daemon.ts"() {
|
|
103839
105047
|
"use strict";
|
|
@@ -103842,6 +105050,7 @@ var init_headless_daemon = __esm({
|
|
|
103842
105050
|
init_canonical_daemon();
|
|
103843
105051
|
init_src2();
|
|
103844
105052
|
init_daemon_embed();
|
|
105053
|
+
init_bootstrap_coordinator();
|
|
103845
105054
|
init_errors2();
|
|
103846
105055
|
init_log();
|
|
103847
105056
|
init_auth_token();
|
|
@@ -103860,6 +105069,7 @@ var init_headless_daemon = __esm({
|
|
|
103860
105069
|
onSignal: (signal, listener) => process.on(signal, listener),
|
|
103861
105070
|
offSignal: (signal, listener) => process.off(signal, listener)
|
|
103862
105071
|
};
|
|
105072
|
+
OWN_SERVER_PROOF_RESTARTS = 4;
|
|
103863
105073
|
DAEMON_ATTACHABILITY_TIMEOUT_MS = 15e3;
|
|
103864
105074
|
DAEMON_ATTACHABILITY_POLL_MS = 25;
|
|
103865
105075
|
}
|
|
@@ -104200,10 +105410,10 @@ __export(open_browser_exports, {
|
|
|
104200
105410
|
});
|
|
104201
105411
|
import { accessSync as accessSync11, constants as constants20, realpathSync as realpathSync31, statSync as statSync29 } from "node:fs";
|
|
104202
105412
|
import { delimiter as delimiter5, isAbsolute as isAbsolute35, join as join63, resolve as resolve38 } from "node:path";
|
|
104203
|
-
import { homedir as
|
|
105413
|
+
import { homedir as homedir10 } from "node:os";
|
|
104204
105414
|
function resolveTerminalBrowser(environment = process.env, platform2 = process.platform) {
|
|
104205
105415
|
const configured = environment.TMUX_IDE_TERMINAL_BROWSER_BIN;
|
|
104206
|
-
const home = environment.HOME ??
|
|
105416
|
+
const home = environment.HOME ?? homedir10();
|
|
104207
105417
|
const bundled = platform2 === "darwin" && isAbsolute35(home) ? [
|
|
104208
105418
|
join63(
|
|
104209
105419
|
home,
|
|
@@ -104830,7 +106040,7 @@ import {
|
|
|
104830
106040
|
} from "node:fs";
|
|
104831
106041
|
import { randomUUID as randomUUID53 } from "node:crypto";
|
|
104832
106042
|
import { dirname as dirname49, join as join65 } from "node:path";
|
|
104833
|
-
import { homedir as
|
|
106043
|
+
import { homedir as homedir11 } from "node:os";
|
|
104834
106044
|
import { z as z143 } from "zod";
|
|
104835
106045
|
function defaults() {
|
|
104836
106046
|
const namespace = resolveRuntimeNamespace();
|
|
@@ -104838,7 +106048,7 @@ function defaults() {
|
|
|
104838
106048
|
plan: (executable) => planDaemonService({
|
|
104839
106049
|
platform: process.platform,
|
|
104840
106050
|
uid: process.getuid?.() ?? 0,
|
|
104841
|
-
home:
|
|
106051
|
+
home: homedir11(),
|
|
104842
106052
|
configHome: process.env.XDG_CONFIG_HOME || void 0,
|
|
104843
106053
|
executable,
|
|
104844
106054
|
path: process.env.PATH || "/usr/bin:/bin",
|
|
@@ -105818,7 +107028,7 @@ function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
|
105818
107028
|
const upgrade = running ? "; run `tmux-ide servers upgrade` to move it to tmux-ide's own tmux" : "";
|
|
105819
107029
|
const details = {
|
|
105820
107030
|
full: "bundled tmux: full features",
|
|
105821
|
-
stock: `stock tmux: reduced features${upgrade}`,
|
|
107031
|
+
stock: `stock tmux: reduced features (tab positions in saved output are reconstructed)${upgrade}`,
|
|
105822
107032
|
older: `older tmux-ide tmux: reduced features${upgrade}`,
|
|
105823
107033
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
105824
107034
|
"no-server": "could not read the tmux server's features",
|
|
@@ -105849,14 +107059,23 @@ function plainTmuxRow(pathTmux, bundled) {
|
|
|
105849
107059
|
optional: true
|
|
105850
107060
|
};
|
|
105851
107061
|
}
|
|
105852
|
-
function snapshotRow(snapshot3, liveSessions2, nowMs) {
|
|
107062
|
+
function snapshotRow(snapshot3, liveSessions2, nowMs, serverStartMs = null) {
|
|
105853
107063
|
const label4 = "crash snapshot (restore)";
|
|
105854
|
-
const hint = "
|
|
107064
|
+
const hint = "The background service writes it within a minute while it runs; without the service, `tmux-ide adopt --all` starts a writer";
|
|
105855
107065
|
if (!snapshot3) {
|
|
105856
107066
|
return liveSessions2?.length ? { label: label4, pass: false, detail: `none yet. ${hint}`, optional: true } : { label: label4, pass: true, detail: "none yet (no sessions running)", optional: true };
|
|
105857
107067
|
}
|
|
105858
107068
|
const ageMs = nowMs - Date.parse(snapshot3.savedAt);
|
|
105859
107069
|
const age = ageMs >= DAY_MS ? `${Math.floor(ageMs / DAY_MS)} days old` : `${Math.max(0, Math.round(ageMs / 6e4))} min old`;
|
|
107070
|
+
if (liveSessions2 && serverStartMs !== null && snapshotIsRestorePoint(snapshot3, { serverStartMs, sessions: liveSessions2 })) {
|
|
107071
|
+
const gone = snapshot3.sessions.map((session) => session.name).filter((name) => !liveSessions2.includes(name));
|
|
107072
|
+
return {
|
|
107073
|
+
label: label4,
|
|
107074
|
+
pass: false,
|
|
107075
|
+
detail: `restore point kept: saved ${age}, before this tmux server started; ${gone.length} of its sessions ${gone.length === 1 ? "is" : "are"} not running (${gone.slice(0, 5).join(", ")}${gone.length > 5 ? ", \u2026" : ""}). \`tmux-ide restore\` brings them back; delete snapshot.json to let a new snapshot replace it`,
|
|
107076
|
+
optional: true
|
|
107077
|
+
};
|
|
107078
|
+
}
|
|
105860
107079
|
const saved = new Set(snapshot3.sessions.map((session) => session.name));
|
|
105861
107080
|
const missing = (liveSessions2 ?? []).filter((name) => !saved.has(name));
|
|
105862
107081
|
if (missing.length)
|
|
@@ -105888,11 +107107,29 @@ function safeBundledTmux() {
|
|
|
105888
107107
|
return null;
|
|
105889
107108
|
}
|
|
105890
107109
|
}
|
|
107110
|
+
function doctorTmuxServer() {
|
|
107111
|
+
const socketPath = process.env[TMUX_SOCKET_PATH_ENV];
|
|
107112
|
+
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
107113
|
+
return socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
107114
|
+
}
|
|
107115
|
+
function liveServerStartMs() {
|
|
107116
|
+
try {
|
|
107117
|
+
const server = doctorTmuxServer();
|
|
107118
|
+
const seconds = Number(
|
|
107119
|
+
execFileSync23(resolveTmuxExecutable(), [...server, "display-message", "-p", "#{start_time}"], {
|
|
107120
|
+
encoding: "utf8",
|
|
107121
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
107122
|
+
timeout: 3e3
|
|
107123
|
+
}).trim()
|
|
107124
|
+
);
|
|
107125
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds * 1e3 : null;
|
|
107126
|
+
} catch {
|
|
107127
|
+
return null;
|
|
107128
|
+
}
|
|
107129
|
+
}
|
|
105891
107130
|
function liveListableSessions() {
|
|
105892
107131
|
try {
|
|
105893
|
-
const
|
|
105894
|
-
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
105895
|
-
const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
107132
|
+
const server = doctorTmuxServer();
|
|
105896
107133
|
return execFileSync23(
|
|
105897
107134
|
resolveTmuxExecutable(),
|
|
105898
107135
|
[...server, "list-sessions", "-F", "#{session_name}"],
|
|
@@ -106006,7 +107243,7 @@ async function doctor({
|
|
|
106006
107243
|
} catch {
|
|
106007
107244
|
}
|
|
106008
107245
|
checks.push(plainTmuxRow(firstOnPath("tmux"), safeBundledTmux()));
|
|
106009
|
-
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now()));
|
|
107246
|
+
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now(), liveServerStartMs()));
|
|
106010
107247
|
checks.push(nodeVersionRow(process.versions.node));
|
|
106011
107248
|
checks.push(
|
|
106012
107249
|
check(
|
|
@@ -111438,6 +112675,27 @@ var init_worktree = __esm({
|
|
|
111438
112675
|
}
|
|
111439
112676
|
});
|
|
111440
112677
|
|
|
112678
|
+
// packages/daemon/src/lib/update-daemon-outcome.ts
|
|
112679
|
+
var update_daemon_outcome_exports = {};
|
|
112680
|
+
__export(update_daemon_outcome_exports, {
|
|
112681
|
+
daemonUpdateOutcome: () => daemonUpdateOutcome
|
|
112682
|
+
});
|
|
112683
|
+
function daemonUpdateOutcome(running, cliVersion) {
|
|
112684
|
+
if (compareProductVersions(running.productVersion, cliVersion) !== 1)
|
|
112685
|
+
return { status: "ready", message: `Daemon ready: ${running.productVersion}` };
|
|
112686
|
+
const how = running.supervised ? `restart its service with tmux-ide daemon service restart; the service starts the installation it was set up with, so if that is not v${cliVersion}, set the service up from this installation first` : running.embedded ? `quit what it runs in: it runs inside another tmux-ide process (pid ${running.pid}), such as an open app, then run tmux-ide update --daemon again` : `stop it (pid ${running.pid}), then run tmux-ide update --daemon again`;
|
|
112687
|
+
return {
|
|
112688
|
+
status: "kept-newer",
|
|
112689
|
+
message: `The running daemon is v${running.productVersion}, newer than this CLI (v${cliVersion}). It was left running: a CLI never replaces a newer daemon. To run v${cliVersion}'s daemon instead, ${how}.`
|
|
112690
|
+
};
|
|
112691
|
+
}
|
|
112692
|
+
var init_update_daemon_outcome = __esm({
|
|
112693
|
+
"packages/daemon/src/lib/update-daemon-outcome.ts"() {
|
|
112694
|
+
"use strict";
|
|
112695
|
+
init_semver();
|
|
112696
|
+
}
|
|
112697
|
+
});
|
|
112698
|
+
|
|
111441
112699
|
// packages/daemon/src/lib/managed-installer-update.ts
|
|
111442
112700
|
import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync48, realpathSync as realpathSync37, rmSync as rmSync10 } from "node:fs";
|
|
111443
112701
|
import { dirname as dirname57, join as join73 } from "node:path";
|
|
@@ -111629,8 +112887,13 @@ function planUpdate(input) {
|
|
|
111629
112887
|
guidance: guidance[method]
|
|
111630
112888
|
};
|
|
111631
112889
|
}
|
|
111632
|
-
function renderPlan2(plan, {
|
|
111633
|
-
|
|
112890
|
+
function renderPlan2(plan, {
|
|
112891
|
+
current,
|
|
112892
|
+
latest,
|
|
112893
|
+
dryRun,
|
|
112894
|
+
source = "registry"
|
|
112895
|
+
}) {
|
|
112896
|
+
const status2 = latest && deriveStatus(latest, current).updateAvailable ? `tmux-ide v${current} \u2192 v${latest} available` : source === "cache" ? `tmux-ide v${current}: could not reach the npm registry (last known release: ${latest ? `v${latest}` : "unknown"})` : latest ? `tmux-ide v${current} is up to date (registry: v${latest})` : `tmux-ide v${current} (latest version unknown)`;
|
|
111634
112897
|
return [
|
|
111635
112898
|
status2,
|
|
111636
112899
|
"",
|
|
@@ -111640,11 +112903,19 @@ function renderPlan2(plan, { current, latest, dryRun }) {
|
|
|
111640
112903
|
"After updating, relaunch the app. Use tmux-ide update --daemon to replace a running daemon with installed code."
|
|
111641
112904
|
].join("\n");
|
|
111642
112905
|
}
|
|
111643
|
-
function
|
|
112906
|
+
function updateFailure(what, error) {
|
|
112907
|
+
const { status: status2, signal, message } = error;
|
|
112908
|
+
const how = typeof status2 === "number" ? `exited with status ${status2}` : typeof signal === "string" ? `was stopped by ${signal}` : `could not run (${String(message).split("\n")[0]})`;
|
|
112909
|
+
return new IdeError(
|
|
112910
|
+
`The update did not finish: ${what} ${how}. Its own message is above. Retry with: tmux-ide update`,
|
|
112911
|
+
{ code: "UPDATE_FAILED", cause: error instanceof Error ? error : void 0 }
|
|
112912
|
+
);
|
|
112913
|
+
}
|
|
112914
|
+
async function runUpdate({ cliDir, dryRun, json: json3 = false }, dependencies = {}) {
|
|
111644
112915
|
if (resolveRuntimeNamespace().development)
|
|
111645
112916
|
throw new Error("Development instances rebuild exact artifacts; package updates are disabled");
|
|
111646
112917
|
const current = (dependencies.currentVersion ?? getCurrentVersion)();
|
|
111647
|
-
const { latest } = (dependencies.status ??
|
|
112918
|
+
const { latest, source: latestSource = "registry" } = await (dependencies.status ?? ((scope2) => refreshUpdateStatus({ ...scope2, fetchLatest: dependencies.fetchLatest })))({ currentVersion: current });
|
|
111648
112919
|
const source = installOrigin(cliDir);
|
|
111649
112920
|
let plan = source.origin === "unknown" ? {
|
|
111650
112921
|
method: "unknown",
|
|
@@ -111680,19 +112951,27 @@ function runUpdate({ cliDir, dryRun, json: json3 = false }, dependencies = {}) {
|
|
|
111680
112951
|
}
|
|
111681
112952
|
}
|
|
111682
112953
|
const output = dependencies.output ?? console.log;
|
|
111683
|
-
if (!json3) output(renderPlan2(plan, { current, latest, dryRun }));
|
|
112954
|
+
if (!json3) output(renderPlan2(plan, { current, latest, dryRun, source: latestSource }));
|
|
111684
112955
|
let executed = false;
|
|
111685
112956
|
if (!dryRun && plan.executable && plan.args) {
|
|
111686
|
-
|
|
111687
|
-
|
|
111688
|
-
|
|
112957
|
+
try {
|
|
112958
|
+
(dependencies.execute ?? execFileSync31)(plan.executable, plan.args, {
|
|
112959
|
+
stdio: json3 ? ["ignore", 2, 2] : "inherit"
|
|
112960
|
+
});
|
|
112961
|
+
} catch (error) {
|
|
112962
|
+
throw updateFailure([plan.executable, ...plan.args].join(" "), error);
|
|
112963
|
+
}
|
|
111689
112964
|
executed = true;
|
|
111690
112965
|
}
|
|
111691
112966
|
if (!dryRun && plan.installerPrefix && plan.channel) {
|
|
111692
|
-
|
|
112967
|
+
try {
|
|
112968
|
+
runManagedInstallerUpdate(plan.installerPrefix, plan.channel, json3, dependencies.execute);
|
|
112969
|
+
} catch (error) {
|
|
112970
|
+
throw updateFailure("the installer", error);
|
|
112971
|
+
}
|
|
111693
112972
|
executed = true;
|
|
111694
112973
|
}
|
|
111695
|
-
if (json3) output(JSON.stringify({ ...plan, current, latest, dryRun, executed }));
|
|
112974
|
+
if (json3) output(JSON.stringify({ ...plan, current, latest, latestSource, dryRun, executed }));
|
|
111696
112975
|
return plan;
|
|
111697
112976
|
}
|
|
111698
112977
|
var UPDATE_COMMANDS;
|
|
@@ -111703,6 +112982,7 @@ var init_update = __esm({
|
|
|
111703
112982
|
init_runtime_namespace();
|
|
111704
112983
|
init_semver();
|
|
111705
112984
|
init_update_check();
|
|
112985
|
+
init_errors2();
|
|
111706
112986
|
init_install_origin();
|
|
111707
112987
|
UPDATE_COMMANDS = {
|
|
111708
112988
|
npm: "npm install -g tmux-ide@latest",
|
|
@@ -111962,6 +113242,7 @@ init_compiled();
|
|
|
111962
113242
|
init_errors2();
|
|
111963
113243
|
init_output();
|
|
111964
113244
|
init_state_home();
|
|
113245
|
+
init_invocation_directory();
|
|
111965
113246
|
init_hosted();
|
|
111966
113247
|
configureTmuxClientResolver(resolveOrdinaryTmuxClient);
|
|
111967
113248
|
if (process.argv[2] === "__plugin-host") {
|
|
@@ -112334,7 +113615,7 @@ Install bun (https://bun.sh) \u2014 the TUI surfaces run on it. Sources ship wit
|
|
|
112334
113615
|
}
|
|
112335
113616
|
}
|
|
112336
113617
|
const env = openTuiLaunchEnvironment(process.env, {
|
|
112337
|
-
TMUX_IDE_CWD:
|
|
113618
|
+
TMUX_IDE_CWD: invocationDirectory(),
|
|
112338
113619
|
TMUX_IDE_CLI: nodeCliPath,
|
|
112339
113620
|
...automaticDiagnosticLog ? {
|
|
112340
113621
|
TMUX_IDE_TUI_LOG: automaticDiagnosticLog,
|
|
@@ -112425,7 +113706,7 @@ Install bun (https://bun.sh) \u2014 the TUI surfaces run on it. Sources ship wit
|
|
|
112425
113706
|
launch2.bin,
|
|
112426
113707
|
launch2.argv,
|
|
112427
113708
|
hostedEnvVars({
|
|
112428
|
-
cwd:
|
|
113709
|
+
cwd: invocationDirectory(),
|
|
112429
113710
|
cli: nodeCliPath,
|
|
112430
113711
|
path: process.env.PATH,
|
|
112431
113712
|
home: process.env.TMUX_IDE_HOME,
|
|
@@ -112620,7 +113901,10 @@ try {
|
|
|
112620
113901
|
port: values.port,
|
|
112621
113902
|
json: json2,
|
|
112622
113903
|
expectedVersion: pkg.version,
|
|
112623
|
-
supervisionId: values.supervised
|
|
113904
|
+
supervisionId: values.supervised,
|
|
113905
|
+
// The crash snapshot's file and builder live in the chrome adapter,
|
|
113906
|
+
// which the daemon engine may not import (#783).
|
|
113907
|
+
crashSnapshotSource: (await Promise.resolve().then(() => (init_snapshot2(), snapshot_exports))).fleetCrashSnapshotSource
|
|
112624
113908
|
});
|
|
112625
113909
|
await new Promise((resolveFlush) => process.stdout.write("", resolveFlush));
|
|
112626
113910
|
process.exit(0);
|
|
@@ -113306,8 +114590,8 @@ try {
|
|
|
113306
114590
|
process.exit(1);
|
|
113307
114591
|
}
|
|
113308
114592
|
const teams = await Promise.resolve().then(() => (init_claude_agent_teams(), claude_agent_teams_exports));
|
|
113309
|
-
const { homedir:
|
|
113310
|
-
const tilde = (text2) => text2.replaceAll(`${
|
|
114593
|
+
const { homedir: homedir12 } = await import("node:os");
|
|
114594
|
+
const tilde = (text2) => text2.replaceAll(`${homedir12()}/`, "~/");
|
|
113311
114595
|
if (action === "status") {
|
|
113312
114596
|
const status2 = teams.claudeAgentTeamsStatus();
|
|
113313
114597
|
if (json2) console.log(JSON.stringify(status2, null, 2));
|
|
@@ -113864,13 +115148,25 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
|
|
|
113864
115148
|
const current = inspectCanonicalDaemonInfo2();
|
|
113865
115149
|
if (current.status !== "valid")
|
|
113866
115150
|
throw new IdeError("Daemon upgrade did not publish a current owner");
|
|
115151
|
+
const cliVersion = (await Promise.resolve().then(() => __toESM(require_package(), 1))).version;
|
|
115152
|
+
const outcome = (await Promise.resolve().then(() => (init_update_daemon_outcome(), update_daemon_outcome_exports))).daemonUpdateOutcome(
|
|
115153
|
+
{
|
|
115154
|
+
productVersion: current.info.productVersion,
|
|
115155
|
+
pid: current.info.pid,
|
|
115156
|
+
supervised: Boolean(current.info.supervisionId),
|
|
115157
|
+
embedded: current.info.provenance?.launcher === "embedded"
|
|
115158
|
+
},
|
|
115159
|
+
cliVersion
|
|
115160
|
+
);
|
|
113867
115161
|
console.log(
|
|
113868
115162
|
json2 ? JSON.stringify({
|
|
113869
115163
|
ok: true,
|
|
113870
|
-
status:
|
|
115164
|
+
status: outcome.status,
|
|
113871
115165
|
productVersion: current.info.productVersion,
|
|
113872
|
-
instanceId: current.info.instanceId
|
|
113873
|
-
|
|
115166
|
+
instanceId: current.info.instanceId,
|
|
115167
|
+
// The installer prints the guidance when it updates the daemon.
|
|
115168
|
+
...outcome.status === "kept-newer" ? { cliVersion, message: outcome.message } : {}
|
|
115169
|
+
}) : outcome.message
|
|
113874
115170
|
);
|
|
113875
115171
|
break;
|
|
113876
115172
|
}
|
|
@@ -113908,7 +115204,7 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
|
|
|
113908
115204
|
}
|
|
113909
115205
|
const { runUpdate: runUpdate2 } = await Promise.resolve().then(() => (init_update(), update_exports));
|
|
113910
115206
|
const dryRun = values["dry-run"] === true;
|
|
113911
|
-
runUpdate2({ cliDir: __dirname5, dryRun, json: json2 });
|
|
115207
|
+
await runUpdate2({ cliDir: __dirname5, dryRun, json: json2 });
|
|
113912
115208
|
break;
|
|
113913
115209
|
}
|
|
113914
115210
|
case "skill-sync": {
|