tmux-ide 2.9.23 → 2.9.25
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 +1636 -385
- package/package.json +4 -2
- package/packages/contracts/src/pane-stream.ts +53 -0
- package/packages/daemon/dist/command-center/discovery.js +24 -5
- package/packages/daemon/dist/command-center/server.js +81 -75
- package/packages/daemon/dist/command-center/tmux-servers.js +11 -0
- 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 +22 -8
- package/packages/daemon/dist/lib/headless-daemon.js +63 -6
- package/packages/daemon/dist/lib/home-agent-observer.js +50 -0
- package/packages/daemon/dist/lib/invocation-directory.js +20 -0
- package/packages/daemon/dist/lib/machine-agents.js +18 -1
- package/packages/daemon/dist/lib/orphaned-control-clients.js +162 -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-external-interaction-observer.js +32 -9
- package/packages/daemon/dist/lib/tmux-server-owner.js +26 -4
- 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/lib/workspace-promotion.js +24 -3
- 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/attachments/native-runtime.js +17 -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 +27 -2
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +749 -208
- package/packages/daemon/dist/terminal/session-runtime/registry.js +24 -2
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +77 -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/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/dist/tui/mirror/runtime/application-home-agent-navigation.js +57 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +18 -7
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +4 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +55 -14
- package/packages/daemon/src/command-center/discovery.ts +24 -4
- package/packages/daemon/src/command-center/server.ts +67 -67
- package/packages/daemon/src/command-center/tmux-servers.ts +11 -0
- 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 +74 -7
- package/packages/daemon/src/lib/headless-daemon.ts +88 -7
- package/packages/daemon/src/lib/home-agent-observer.ts +53 -0
- package/packages/daemon/src/lib/invocation-directory.ts +21 -0
- package/packages/daemon/src/lib/machine-agents.ts +25 -1
- package/packages/daemon/src/lib/orphaned-control-clients.ts +215 -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-external-interaction-observer.ts +32 -8
- package/packages/daemon/src/lib/tmux-server-owner.ts +28 -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/lib/workspace-promotion.ts +26 -3
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +21 -2
- package/packages/daemon/src/terminal/graphics/kitty-graphics.ts +22 -6
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +27 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +32 -2
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +819 -223
- package/packages/daemon/src/terminal/session-runtime/registry.ts +35 -2
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +74 -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/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/src/tui/mirror/runtime/application-home-agent-navigation.ts +69 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +30 -13
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +38 -1
- package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +7 -2
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +4 -4
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +71 -17
- 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 {
|
|
@@ -7915,7 +7940,7 @@ var init_terminal_graphics = __esm({
|
|
|
7915
7940
|
|
|
7916
7941
|
// packages/contracts/src/pane-stream.ts
|
|
7917
7942
|
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;
|
|
7943
|
+
var PANE_STREAM_CLOCK_BOUNDS_CAPABILITY_V1, PaneStreamDiagnosticCapabilitySchemaZ, PANE_STREAM_PROTOCOL_VERSION, PANE_STREAM_ISSUE_PATH, PANE_STREAM_REDEEM_PATH, PANE_STREAM_WEBSOCKET_SUBPROTOCOL, PANE_STREAM_MAX_PANES, PANE_STREAM_MAX_OUTPUT_BYTES, PANE_STREAM_MAX_OUTPUT_BASE64_CHARS, PANE_STREAM_MAX_SEED_BYTES, PANE_STREAM_MAX_SEED_BASE64_CHARS, PANE_STREAM_MAX_HELD_DELTAS, PANE_STREAM_MAX_LAYOUT_PANES, PANE_STREAM_MAX_GRID_CELLS, PANE_STREAM_MAX_INPUT_SEQUENCE, PaneStreamSemanticPaneIdSchemaZ, PaneStreamViewerModeSchemaZ, PaneSetSchemaZ, PaneStreamLeaseRequestSchemaZ, PaneStreamRedemptionTicketSchemaZ, PaneStreamLoopbackWebSocketUrlSchemaZ, PaneStreamIssueDescriptorSchemaZ, PaneStreamIssueErrorSchemaZ, PaneStreamIssueResultSchemaZ, PaneStreamIssueMutationRequestSchemaZ, BoundedIdentitySchemaZ, PaneStreamRedeemFrameSchemaZ, PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PaneStreamInputLifetimeSchemaZ, PaneStreamInputFrameMetadataShape, PaneStreamInputFrameSchemaZ, PaneStreamConsumedFrameSchemaZ, PaneStreamTerminalDeliveryAckFrameSchemaZ, PaneStreamTerminalProjectionReceiptFrameSchemaZ, PaneStreamTerminalProjectionMaterializeFrameSchemaZ, PaneStreamTerminalDeliveryNackFrameSchemaZ, PaneStreamTerminalDeliveryVisibilityFrameSchemaZ, PaneStreamSemanticIntentFrameSchemaZ, PaneStreamViewportFrameSchemaZ, PaneStreamAuthorityRequestIdSchemaZ, PaneStreamAuthorityGenerationSchemaZ, PaneStreamPresenceFrameSchemaZ, PaneStreamActivityFrameSchemaZ, PaneStreamAuthorityRequestFrameSchemaZ, PaneStreamAuthorityReleaseFrameSchemaZ, SharedMonotonicMicrosSchemaZ, PaneStreamClockProbeFrameSchemaZ, PaneStreamTerminalGraphicsRequestFrameSchemaZ, PaneStreamTerminalGraphicsLocalReleaseFrameSchemaZ, PaneStreamTerminalCellPixelsFrameSchemaZ, PaneStreamClientFrameSchemaZ, Base64SchemaZ, ServerSeqSchemaZ, GridCellSchemaZ, CellCoordinateSchemaZ, PaneStreamReadyFrameSchemaZ, PaneStreamSeedBatchFrameSchemaZ, PaneStreamOutputFrameSchemaZ, PaneStreamCursorFrameSchemaZ, BoundedDisplayNameSchemaZ, PaneDisplayNameSourceSchemaZ, PaneStreamLayoutFrameSchemaZ, PaneStreamLayoutSnapshotV1FrameSchemaZ, PaneStreamLayoutSnapshotV2FrameSchemaZ, PaneStreamLayoutSnapshotFrameSchemaZ, PaneStreamFlowFrameSchemaZ, PaneStreamTopologyFrameSchemaZ, PaneStreamClosedFrameSchemaZ, PaneStreamInputAckFrameSchemaZ, PaneStreamClockProbeAckFrameSchemaZ, PaneStreamCausalCellProofFrameSchemaZ, PaneStreamCausalCellFailureFrameSchemaZ, PaneStreamTerminalDeliveryReadyFrameSchemaZ, PaneStreamTerminalDeliveryEnvelopeFrameSchemaZ, PaneStreamTerminalProjectionEnvelopeFrameSchemaZ, PaneStreamTerminalDeliveryChunkFrameSchemaZ, PaneStreamTerminalDeliveryFaultFrameSchemaZ, PaneStreamTerminalGraphicsFrameSchemaZ, PaneStreamTerminalGraphicsBlobFrameSchemaZ, PaneStreamTerminalGraphicsLocalFrameSchemaZ, PaneStreamSemanticIntentAckFrameSchemaZ, PaneStreamViewportAckFrameSchemaZ, PaneStreamAuthoritySnapshotFrameSchemaZ, PaneStreamAuthorityReceiptFrameSchemaZ, PaneStreamErrorFrameCodeSchemaZ, PaneStreamErrorFrameSchemaZ, PaneStreamServerFrameSchemaZ;
|
|
7919
7944
|
var init_pane_stream = __esm({
|
|
7920
7945
|
"packages/contracts/src/pane-stream.ts"() {
|
|
7921
7946
|
"use strict";
|
|
@@ -8008,6 +8033,8 @@ var init_pane_stream = __esm({
|
|
|
8008
8033
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION = /* @__PURE__ */ (() => 106)();
|
|
8009
8034
|
PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION = /* @__PURE__ */ (() => 117)();
|
|
8010
8035
|
PANE_STREAM_READER_CAPABILITY_VERSION = /* @__PURE__ */ (() => 118)();
|
|
8036
|
+
PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION = /* @__PURE__ */ (() => 119)();
|
|
8037
|
+
PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION = /* @__PURE__ */ (() => 120)();
|
|
8011
8038
|
PaneStreamInputLifetimeSchemaZ = /* @__PURE__ */ (() => z52.object({
|
|
8012
8039
|
generation: z52.string().min(1).max(256),
|
|
8013
8040
|
incarnation: z52.string().min(1).max(256)
|
|
@@ -8157,6 +8184,8 @@ var init_pane_stream = __esm({
|
|
|
8157
8184
|
type: z52.literal("ready"),
|
|
8158
8185
|
inputLifetime: z52.literal(true).optional(),
|
|
8159
8186
|
inputBytes: z52.literal(true).optional(),
|
|
8187
|
+
/** Only to a client that offered capability 119: `topology` frames may follow. */
|
|
8188
|
+
topologyInPlace: z52.literal(true).optional(),
|
|
8160
8189
|
protocolVersion: z52.literal(PANE_STREAM_PROTOCOL_VERSION),
|
|
8161
8190
|
daemonInstanceId: BoundedIdentitySchemaZ,
|
|
8162
8191
|
requestId: z52.uuid(),
|
|
@@ -8321,6 +8350,22 @@ var init_pane_stream = __esm({
|
|
|
8321
8350
|
state: z52.enum(["paused", "resumed"]),
|
|
8322
8351
|
reason: z52.enum(["backpressure", "requested"])
|
|
8323
8352
|
}).strict())();
|
|
8353
|
+
PaneStreamTopologyFrameSchemaZ = /* @__PURE__ */ (() => z52.object({
|
|
8354
|
+
type: z52.literal("topology"),
|
|
8355
|
+
topologyEpoch: z52.number().int().nonnegative(),
|
|
8356
|
+
panes: PaneSetSchemaZ,
|
|
8357
|
+
removed: z52.array(PaneStreamSemanticPaneIdSchemaZ).max(PANE_STREAM_MAX_PANES),
|
|
8358
|
+
added: z52.array(PaneStreamSemanticPaneIdSchemaZ).max(PANE_STREAM_MAX_PANES)
|
|
8359
|
+
}).strict().superRefine((frame, context) => {
|
|
8360
|
+
const panes = new Set(frame.panes);
|
|
8361
|
+
const removed = new Set(frame.removed);
|
|
8362
|
+
const added = new Set(frame.added);
|
|
8363
|
+
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)))
|
|
8364
|
+
context.addIssue({
|
|
8365
|
+
code: z52.ZodIssueCode.custom,
|
|
8366
|
+
message: "added panes must be in the set, removed panes must not, and neither may repeat"
|
|
8367
|
+
});
|
|
8368
|
+
}))();
|
|
8324
8369
|
PaneStreamClosedFrameSchemaZ = /* @__PURE__ */ (() => z52.object({
|
|
8325
8370
|
type: z52.literal("closed"),
|
|
8326
8371
|
pane: PaneStreamSemanticPaneIdSchemaZ,
|
|
@@ -8466,6 +8511,7 @@ var init_pane_stream = __esm({
|
|
|
8466
8511
|
PaneStreamCursorFrameSchemaZ,
|
|
8467
8512
|
PaneStreamLayoutFrameSchemaZ,
|
|
8468
8513
|
PaneStreamLayoutSnapshotFrameSchemaZ,
|
|
8514
|
+
PaneStreamTopologyFrameSchemaZ,
|
|
8469
8515
|
PaneStreamFlowFrameSchemaZ,
|
|
8470
8516
|
PaneStreamClosedFrameSchemaZ,
|
|
8471
8517
|
PaneStreamInputAckFrameSchemaZ,
|
|
@@ -12560,6 +12606,7 @@ __export(update_check_exports, {
|
|
|
12560
12606
|
maybeCheckForUpdate: () => maybeCheckForUpdate,
|
|
12561
12607
|
parseRegistryResponse: () => parseRegistryResponse,
|
|
12562
12608
|
readUpdateCache: () => readUpdateCache,
|
|
12609
|
+
refreshUpdateStatus: () => refreshUpdateStatus,
|
|
12563
12610
|
runUpdateCheck: () => runUpdateCheck,
|
|
12564
12611
|
shouldCheck: () => shouldCheck,
|
|
12565
12612
|
updateCachePath: () => updateCachePath,
|
|
@@ -12666,6 +12713,26 @@ function getUpdateStatus({
|
|
|
12666
12713
|
const cache3 = readUpdateCache({ currentVersion });
|
|
12667
12714
|
return deriveStatus(cache3?.latest ?? null, currentVersion);
|
|
12668
12715
|
}
|
|
12716
|
+
async function refreshUpdateStatus({
|
|
12717
|
+
currentVersion = getCurrentVersion(),
|
|
12718
|
+
now = Date.now(),
|
|
12719
|
+
timeoutMs = 3e3,
|
|
12720
|
+
fetchLatest = fetchLatestVersion
|
|
12721
|
+
} = {}) {
|
|
12722
|
+
const fetched = await fetchLatest(timeoutMs, updateChannel(currentVersion));
|
|
12723
|
+
const cache3 = readUpdateCache({ currentVersion });
|
|
12724
|
+
if (fetched === null)
|
|
12725
|
+
return { ...deriveStatus(cache3?.latest ?? null, currentVersion), source: "cache" };
|
|
12726
|
+
writeUpdateCache(
|
|
12727
|
+
{
|
|
12728
|
+
lastCheckedAt: now,
|
|
12729
|
+
latest: fetched,
|
|
12730
|
+
...cache3?.notified ? { notified: cache3.notified } : {}
|
|
12731
|
+
},
|
|
12732
|
+
{ currentVersion }
|
|
12733
|
+
);
|
|
12734
|
+
return { ...deriveStatus(fetched, currentVersion), source: "registry" };
|
|
12735
|
+
}
|
|
12669
12736
|
async function runUpdateCheck({
|
|
12670
12737
|
now = Date.now(),
|
|
12671
12738
|
...scope2
|
|
@@ -13368,6 +13435,25 @@ var init_state_home = __esm({
|
|
|
13368
13435
|
}
|
|
13369
13436
|
});
|
|
13370
13437
|
|
|
13438
|
+
// packages/daemon/src/lib/invocation-directory.ts
|
|
13439
|
+
import { homedir as homedir4 } from "node:os";
|
|
13440
|
+
function invocationDirectory(io = {
|
|
13441
|
+
cwd: () => process.cwd(),
|
|
13442
|
+
home: homedir4
|
|
13443
|
+
}) {
|
|
13444
|
+
try {
|
|
13445
|
+
return io.cwd();
|
|
13446
|
+
} catch (error) {
|
|
13447
|
+
if (error?.code !== "ENOENT") throw error;
|
|
13448
|
+
return io.home();
|
|
13449
|
+
}
|
|
13450
|
+
}
|
|
13451
|
+
var init_invocation_directory = __esm({
|
|
13452
|
+
"packages/daemon/src/lib/invocation-directory.ts"() {
|
|
13453
|
+
"use strict";
|
|
13454
|
+
}
|
|
13455
|
+
});
|
|
13456
|
+
|
|
13371
13457
|
// packages/daemon/src/tui/mirror/hosted.ts
|
|
13372
13458
|
function wantsHostedApp(input) {
|
|
13373
13459
|
if (input.hostedEnv) return false;
|
|
@@ -15290,7 +15376,7 @@ var require_package = __commonJS({
|
|
|
15290
15376
|
"package.json"(exports, module) {
|
|
15291
15377
|
module.exports = {
|
|
15292
15378
|
name: "tmux-ide",
|
|
15293
|
-
version: "2.9.
|
|
15379
|
+
version: "2.9.25",
|
|
15294
15380
|
description: "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
|
|
15295
15381
|
type: "module",
|
|
15296
15382
|
bin: {
|
|
@@ -15352,7 +15438,8 @@ var require_package = __commonJS({
|
|
|
15352
15438
|
"test:pane-frame-package": "pnpm --filter @tmux-ide/presentation run test",
|
|
15353
15439
|
"typecheck:workspace": "turbo run typecheck",
|
|
15354
15440
|
"docs:build": "turbo run build --filter=@tmux-ide/docs",
|
|
15355
|
-
"pack:check": "pnpm test:installer &&
|
|
15441
|
+
"pack:check": "pnpm test:installer && pnpm test:workflow-contracts && node scripts/pack-tui-check.mjs",
|
|
15442
|
+
"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
15443
|
"test:pack-installed": "node scripts/pack-check-run.mjs",
|
|
15357
15444
|
"release:opentui:check": "node scripts/opentui-release-check.mjs",
|
|
15358
15445
|
"check:native-deps": "node packages/daemon/scripts/check-native-deps.mjs",
|
|
@@ -15397,6 +15484,7 @@ var require_package = __commonJS({
|
|
|
15397
15484
|
"typecheck:tui-gallery": "tsc --noEmit -p scripts/tsconfig.tui-gallery.json",
|
|
15398
15485
|
"test:spark-qualification": "node --import tsx --test scripts/lib/spark-*.test.ts scripts/lib/spark-*.test.mjs",
|
|
15399
15486
|
"test:installer": "node --test scripts/install.test.mjs scripts/lib/installer-service-qualification.test.mjs",
|
|
15487
|
+
"test:installer-native": "node --test scripts/install-native-alpha.test.mjs scripts/install-native-dispatch.test.mjs",
|
|
15400
15488
|
"qualify:styled-ssh": "node scripts/qualify-styled-ssh.mjs"
|
|
15401
15489
|
},
|
|
15402
15490
|
keywords: [
|
|
@@ -17760,7 +17848,7 @@ var init_front_door = __esm({
|
|
|
17760
17848
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
17761
17849
|
import { createHash as createHash7 } from "node:crypto";
|
|
17762
17850
|
import { readdirSync as readdirSync5, readFileSync as readFileSync13, readlinkSync as readlinkSync3, statSync as statSync7 } from "node:fs";
|
|
17763
|
-
import { homedir as
|
|
17851
|
+
import { homedir as homedir5 } from "node:os";
|
|
17764
17852
|
import { join as join19 } from "node:path";
|
|
17765
17853
|
function codexIdFromOpenFiles(paths) {
|
|
17766
17854
|
for (const path2 of paths) {
|
|
@@ -17959,8 +18047,8 @@ function liveProbeIo() {
|
|
|
17959
18047
|
openFiles: readOpenFiles,
|
|
17960
18048
|
processStartMs: (pid) => processStartMs(pid),
|
|
17961
18049
|
stateDir: liveStateDirIo,
|
|
17962
|
-
codexSessionsRoot: () => process.env.TMUX_IDE_CODEX_SESSIONS ?? join19(
|
|
17963
|
-
cursorChatsRoot: () => process.env.TMUX_IDE_CURSOR_CHATS ?? join19(
|
|
18050
|
+
codexSessionsRoot: () => process.env.TMUX_IDE_CODEX_SESSIONS ?? join19(homedir5(), ".codex", "sessions"),
|
|
18051
|
+
cursorChatsRoot: () => process.env.TMUX_IDE_CURSOR_CHATS ?? join19(homedir5(), ".cursor", "chats"),
|
|
17964
18052
|
now: () => Date.now()
|
|
17965
18053
|
};
|
|
17966
18054
|
}
|
|
@@ -19182,6 +19270,7 @@ function adoptSession(session, switcherCmd = "tmux-ide switcher") {
|
|
|
19182
19270
|
function unadoptSession(session) {
|
|
19183
19271
|
clearPaneChromeWindows([session]);
|
|
19184
19272
|
for (const argv of unadoptOptionCommands(session)) runTmux(argv);
|
|
19273
|
+
if (listAdoptedSessions().length > 0) return;
|
|
19185
19274
|
const keys = getAppConfig().keys;
|
|
19186
19275
|
for (const undo of [
|
|
19187
19276
|
statusClickUnbindCommand(),
|
|
@@ -19214,7 +19303,7 @@ function unadoptSession(session) {
|
|
|
19214
19303
|
} catch {
|
|
19215
19304
|
}
|
|
19216
19305
|
}
|
|
19217
|
-
|
|
19306
|
+
stopUpdater();
|
|
19218
19307
|
}
|
|
19219
19308
|
var POPUP_KEY, HOME_KEY, MENU_KEY, MENU_STATUS_KEY, MENU_PANE_KEY, STATUS_CLICK_KEY, PREFIX_TAKEN, PREFIX_REMAP, LEGACY_BINDS;
|
|
19220
19309
|
var init_statusline = __esm({
|
|
@@ -19757,7 +19846,109 @@ var init_notify_state = __esm({
|
|
|
19757
19846
|
}
|
|
19758
19847
|
});
|
|
19759
19848
|
|
|
19849
|
+
// packages/daemon/src/lib/daemon-crash-snapshot.ts
|
|
19850
|
+
function snapshotIsRestorePoint(existing, live) {
|
|
19851
|
+
if (!existing || !(live.serverStartMs > Date.parse(existing.savedAt))) return false;
|
|
19852
|
+
const running = new Set(live.sessions);
|
|
19853
|
+
return existing.sessions.some((session) => !running.has(session.name));
|
|
19854
|
+
}
|
|
19855
|
+
function createDaemonCrashSnapshot(deps2) {
|
|
19856
|
+
const { source } = deps2;
|
|
19857
|
+
let seen = null;
|
|
19858
|
+
return {
|
|
19859
|
+
async pulse() {
|
|
19860
|
+
let sessions;
|
|
19861
|
+
let panes;
|
|
19862
|
+
let existing;
|
|
19863
|
+
let serverStartMs = Number.NaN;
|
|
19864
|
+
try {
|
|
19865
|
+
sessions = await deps2.run(["list-sessions", "-F", source.sessionFormat]);
|
|
19866
|
+
if (sessions.split("\n").some((line) => line.split(" ")[0] === UPDATER_SESSION)) {
|
|
19867
|
+
seen = null;
|
|
19868
|
+
return "updater-writes";
|
|
19869
|
+
}
|
|
19870
|
+
panes = await deps2.run(["list-panes", "-a", "-F", source.paneFormat]);
|
|
19871
|
+
if (`${sessions}
|
|
19872
|
+
|
|
19873
|
+
${panes}` === seen) return "unchanged";
|
|
19874
|
+
existing = source.read();
|
|
19875
|
+
if (existing)
|
|
19876
|
+
serverStartMs = Number((await deps2.run(["display-message", "-p", "#{start_time}"])).trim()) * 1e3;
|
|
19877
|
+
} catch {
|
|
19878
|
+
return "tmux-unavailable";
|
|
19879
|
+
}
|
|
19880
|
+
const running = sessions.split("\n").map((line) => line.split(" ")[0]);
|
|
19881
|
+
if (snapshotIsRestorePoint(existing, { serverStartMs, sessions: running })) {
|
|
19882
|
+
seen = null;
|
|
19883
|
+
return "restore-point-kept";
|
|
19884
|
+
}
|
|
19885
|
+
const snapshot3 = await source.build(
|
|
19886
|
+
panes.split("\n").filter(Boolean),
|
|
19887
|
+
sessions.split("\n").filter(Boolean)
|
|
19888
|
+
);
|
|
19889
|
+
seen = `${sessions}
|
|
19890
|
+
|
|
19891
|
+
${panes}`;
|
|
19892
|
+
if (existing && source.fingerprint(existing) === source.fingerprint(snapshot3))
|
|
19893
|
+
return "unchanged";
|
|
19894
|
+
source.write(snapshot3);
|
|
19895
|
+
return "written";
|
|
19896
|
+
}
|
|
19897
|
+
};
|
|
19898
|
+
}
|
|
19899
|
+
function daemonCrashSnapshotStart(opts, run, retired) {
|
|
19900
|
+
return {
|
|
19901
|
+
launcher: opts.launcher ?? "embedded",
|
|
19902
|
+
source: opts.crashSnapshotSource,
|
|
19903
|
+
run,
|
|
19904
|
+
retired
|
|
19905
|
+
};
|
|
19906
|
+
}
|
|
19907
|
+
function startDaemonCrashSnapshot(deps2) {
|
|
19908
|
+
if (deps2.launcher !== "headless" || !deps2.source) return null;
|
|
19909
|
+
const snapshot3 = createDaemonCrashSnapshot({ run: deps2.run, source: deps2.source });
|
|
19910
|
+
let busy = false;
|
|
19911
|
+
const timer = setInterval(() => {
|
|
19912
|
+
if (deps2.retired()) {
|
|
19913
|
+
clearInterval(timer);
|
|
19914
|
+
return;
|
|
19915
|
+
}
|
|
19916
|
+
if (busy) return;
|
|
19917
|
+
busy = true;
|
|
19918
|
+
void snapshot3.pulse().catch(() => void 0).finally(() => {
|
|
19919
|
+
busy = false;
|
|
19920
|
+
});
|
|
19921
|
+
}, DAEMON_CRASH_SNAPSHOT_INTERVAL_MS);
|
|
19922
|
+
timer.unref?.();
|
|
19923
|
+
return () => clearInterval(timer);
|
|
19924
|
+
}
|
|
19925
|
+
var DAEMON_CRASH_SNAPSHOT_INTERVAL_MS;
|
|
19926
|
+
var init_daemon_crash_snapshot = __esm({
|
|
19927
|
+
"packages/daemon/src/lib/daemon-crash-snapshot.ts"() {
|
|
19928
|
+
"use strict";
|
|
19929
|
+
init_chrome_front_door();
|
|
19930
|
+
DAEMON_CRASH_SNAPSHOT_INTERVAL_MS = 3e4;
|
|
19931
|
+
}
|
|
19932
|
+
});
|
|
19933
|
+
|
|
19760
19934
|
// packages/daemon/src/tui/chrome/snapshot.ts
|
|
19935
|
+
var snapshot_exports = {};
|
|
19936
|
+
__export(snapshot_exports, {
|
|
19937
|
+
SNAPSHOT_EVERY: () => SNAPSHOT_EVERY,
|
|
19938
|
+
SNAPSHOT_PANE_FORMAT: () => SNAPSHOT_PANE_FORMAT,
|
|
19939
|
+
SNAPSHOT_SESSION_FORMAT: () => SNAPSHOT_SESSION_FORMAT,
|
|
19940
|
+
buildSnapshot: () => buildSnapshot,
|
|
19941
|
+
collectFleetSnapshot: () => collectFleetSnapshot,
|
|
19942
|
+
createSnapshotter: () => createSnapshotter,
|
|
19943
|
+
fleetCrashSnapshotSource: () => fleetCrashSnapshotSource,
|
|
19944
|
+
readSnapshot: () => readSnapshot,
|
|
19945
|
+
resolvePaneCommand: () => resolvePaneCommand,
|
|
19946
|
+
snapshotEvery: () => snapshotEvery,
|
|
19947
|
+
snapshotFingerprint: () => snapshotFingerprint,
|
|
19948
|
+
snapshotIsRestorePoint: () => snapshotIsRestorePoint,
|
|
19949
|
+
snapshotPath: () => snapshotPath,
|
|
19950
|
+
writeSnapshot: () => writeSnapshot
|
|
19951
|
+
});
|
|
19761
19952
|
import { existsSync as existsSync17, mkdirSync as mkdirSync15, readFileSync as readFileSync18, renameSync as renameSync9, writeFileSync as writeFileSync13 } from "node:fs";
|
|
19762
19953
|
import { dirname as dirname20, join as join24 } from "node:path";
|
|
19763
19954
|
import { z as z95 } from "zod";
|
|
@@ -19903,10 +20094,16 @@ function readSnapshot(path2 = snapshotPath()) {
|
|
|
19903
20094
|
return null;
|
|
19904
20095
|
}
|
|
19905
20096
|
}
|
|
20097
|
+
function snapshotEvery() {
|
|
20098
|
+
const raw = process.env.TMUX_IDE_SNAPSHOT_EVERY;
|
|
20099
|
+
const n = raw ? Number(raw) : NaN;
|
|
20100
|
+
return Number.isInteger(n) && n > 0 ? n : SNAPSHOT_EVERY;
|
|
20101
|
+
}
|
|
19906
20102
|
function createSnapshotter(deps2) {
|
|
19907
20103
|
let ticks = 0;
|
|
19908
20104
|
let seeded = false;
|
|
19909
20105
|
let lastFingerprint = null;
|
|
20106
|
+
let held = false;
|
|
19910
20107
|
return {
|
|
19911
20108
|
onTick() {
|
|
19912
20109
|
ticks++;
|
|
@@ -19917,6 +20114,23 @@ function createSnapshotter(deps2) {
|
|
|
19917
20114
|
seeded = true;
|
|
19918
20115
|
}
|
|
19919
20116
|
const snapshot3 = deps2.collect();
|
|
20117
|
+
if (deps2.serverStartMs) {
|
|
20118
|
+
const existing = deps2.read();
|
|
20119
|
+
let serverStartMs = Number.NaN;
|
|
20120
|
+
try {
|
|
20121
|
+
serverStartMs = deps2.serverStartMs();
|
|
20122
|
+
} catch {
|
|
20123
|
+
}
|
|
20124
|
+
const sessions = snapshot3.sessions.map((session) => session.name);
|
|
20125
|
+
if (snapshotIsRestorePoint(existing, { serverStartMs, sessions })) {
|
|
20126
|
+
held = true;
|
|
20127
|
+
return;
|
|
20128
|
+
}
|
|
20129
|
+
if (held) {
|
|
20130
|
+
held = false;
|
|
20131
|
+
lastFingerprint = existing ? snapshotFingerprint(existing) : null;
|
|
20132
|
+
}
|
|
20133
|
+
}
|
|
19920
20134
|
const fingerprint2 = snapshotFingerprint(snapshot3);
|
|
19921
20135
|
if (fingerprint2 === lastFingerprint) return;
|
|
19922
20136
|
lastFingerprint = fingerprint2;
|
|
@@ -19924,7 +20138,7 @@ function createSnapshotter(deps2) {
|
|
|
19924
20138
|
}
|
|
19925
20139
|
};
|
|
19926
20140
|
}
|
|
19927
|
-
var PaneSnapshotSchemaZ, WindowSnapshotSchemaZ, SessionSnapshotSchemaZ, FleetSnapshotSchemaZ, SNAPSHOT_PANE_FORMAT, SNAPSHOT_SESSION_FORMAT, defaultIo;
|
|
20141
|
+
var PaneSnapshotSchemaZ, WindowSnapshotSchemaZ, SessionSnapshotSchemaZ, FleetSnapshotSchemaZ, SNAPSHOT_PANE_FORMAT, SNAPSHOT_SESSION_FORMAT, defaultIo, SNAPSHOT_EVERY, fleetCrashSnapshotSource;
|
|
19928
20142
|
var init_snapshot2 = __esm({
|
|
19929
20143
|
"packages/daemon/src/tui/chrome/snapshot.ts"() {
|
|
19930
20144
|
"use strict";
|
|
@@ -19932,6 +20146,7 @@ var init_snapshot2 = __esm({
|
|
|
19932
20146
|
init_runtime_namespace();
|
|
19933
20147
|
init_src();
|
|
19934
20148
|
init_process_tree();
|
|
20149
|
+
init_daemon_crash_snapshot();
|
|
19935
20150
|
init_sessions2();
|
|
19936
20151
|
PaneSnapshotSchemaZ = z95.object({
|
|
19937
20152
|
index: z95.number(),
|
|
@@ -19981,6 +20196,15 @@ var init_snapshot2 = __esm({
|
|
|
19981
20196
|
listSessions: () => runTmux(["list-sessions", "-F", SNAPSHOT_SESSION_FORMAT]).toString(),
|
|
19982
20197
|
processTable: () => readProcessTable()
|
|
19983
20198
|
};
|
|
20199
|
+
SNAPSHOT_EVERY = 15;
|
|
20200
|
+
fleetCrashSnapshotSource = {
|
|
20201
|
+
sessionFormat: SNAPSHOT_SESSION_FORMAT,
|
|
20202
|
+
paneFormat: SNAPSHOT_PANE_FORMAT,
|
|
20203
|
+
build: async (panes, sessions) => buildSnapshot(panes, sessions, await readProcessTableAsync()),
|
|
20204
|
+
read: () => readSnapshot(),
|
|
20205
|
+
write: writeSnapshot,
|
|
20206
|
+
fingerprint: snapshotFingerprint
|
|
20207
|
+
};
|
|
19984
20208
|
}
|
|
19985
20209
|
});
|
|
19986
20210
|
|
|
@@ -20332,7 +20556,9 @@ function runUpdaterLoop() {
|
|
|
20332
20556
|
collect: () => collectFleetSnapshot(),
|
|
20333
20557
|
read: readSnapshot,
|
|
20334
20558
|
write: writeSnapshot,
|
|
20335
|
-
every: config2.updater.snapshotEvery
|
|
20559
|
+
every: config2.updater.snapshotEvery,
|
|
20560
|
+
// A dead server's snapshot is kept until its sessions are restored (#783).
|
|
20561
|
+
serverStartMs: () => Number(runTmux(["display-message", "-p", "#{start_time}"]).toString().trim()) * 1e3
|
|
20336
20562
|
});
|
|
20337
20563
|
const shouldGiveUp = createUnreachableCounter();
|
|
20338
20564
|
const tick = () => {
|
|
@@ -25998,6 +26224,7 @@ var canonical_daemon_bootstrap_exports = {};
|
|
|
25998
26224
|
__export(canonical_daemon_bootstrap_exports, {
|
|
25999
26225
|
assertCanonicalDaemonServerIntent: () => assertCanonicalDaemonServerIntent,
|
|
26000
26226
|
createCanonicalDaemonBootstrapCoordinator: () => createCanonicalDaemonBootstrapCoordinator,
|
|
26227
|
+
daemonServerProofPending: () => daemonServerProofPending,
|
|
26001
26228
|
ensureCanonicalDaemon: () => ensureCanonicalDaemon,
|
|
26002
26229
|
retireOutdatedCanonicalDaemon: () => retireOutdatedCanonicalDaemon
|
|
26003
26230
|
});
|
|
@@ -26128,6 +26355,9 @@ async function replaceOlderCanonicalDaemon(deps2, info, timeoutMs, expectedProdu
|
|
|
26128
26355
|
{ reason: "protocol-mismatch" }
|
|
26129
26356
|
);
|
|
26130
26357
|
}
|
|
26358
|
+
function daemonServerProofPending(error) {
|
|
26359
|
+
return error instanceof DaemonBootstrapError && error[DAEMON_PROOF_PENDING] === true;
|
|
26360
|
+
}
|
|
26131
26361
|
async function assertServerIntent(deps2, info, identity4, intent) {
|
|
26132
26362
|
if (!intent) return;
|
|
26133
26363
|
let proof = deps2.serverProof(intent);
|
|
@@ -26148,10 +26378,17 @@ async function assertServerIntent(deps2, info, identity4, intent) {
|
|
|
26148
26378
|
}
|
|
26149
26379
|
}
|
|
26150
26380
|
if (info.tmuxServerProofVersion !== 1 || !identity4.tmuxServerProof || !proof)
|
|
26151
|
-
throw
|
|
26152
|
-
|
|
26153
|
-
|
|
26154
|
-
|
|
26381
|
+
throw Object.assign(
|
|
26382
|
+
new DaemonBootstrapError(
|
|
26383
|
+
"incompatible",
|
|
26384
|
+
`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)}.`,
|
|
26385
|
+
{ reason: "tmux-server-unproven" }
|
|
26386
|
+
),
|
|
26387
|
+
{
|
|
26388
|
+
// Either side's proof can be late (a slow tmux answer); only a daemon
|
|
26389
|
+
// without the capability can never prove it.
|
|
26390
|
+
[DAEMON_PROOF_PENDING]: info.tmuxServerProofVersion === 1
|
|
26391
|
+
}
|
|
26155
26392
|
);
|
|
26156
26393
|
if (identity4.tmuxServerProof.kind !== proof.kind || identity4.tmuxServerProof.digest !== proof.digest)
|
|
26157
26394
|
throw new DaemonBootstrapError(
|
|
@@ -26239,7 +26476,8 @@ function createCanonicalDaemonBootstrapCoordinator(options, dependencies = {}) {
|
|
|
26239
26476
|
options.expectedProductVersion,
|
|
26240
26477
|
options.tmuxServerIntent === void 0 ? resolveTmuxServerIntent() : options.tmuxServerIntent
|
|
26241
26478
|
),
|
|
26242
|
-
|
|
26479
|
+
// A deleted current directory starts the daemon from home (#585).
|
|
26480
|
+
spawn: () => deps2.spawnOwner(resolve18(options.entryPath), resolve18(options.cwd ?? invocationDirectory())),
|
|
26243
26481
|
timeoutMs: options.timeoutMs,
|
|
26244
26482
|
onPhaseChanged: options.onPhaseChanged,
|
|
26245
26483
|
now: deps2.now,
|
|
@@ -26337,11 +26575,12 @@ async function assertCanonicalDaemonServerIntent(info, intent = resolveTmuxServe
|
|
|
26337
26575
|
);
|
|
26338
26576
|
await assertServerIntent(deps2, info, identity4, intent);
|
|
26339
26577
|
}
|
|
26340
|
-
var ShutdownTransportError, defaultDependencies;
|
|
26578
|
+
var ShutdownTransportError, defaultDependencies, DAEMON_PROOF_PENDING;
|
|
26341
26579
|
var init_canonical_daemon_bootstrap = __esm({
|
|
26342
26580
|
"packages/daemon/src/lib/canonical-daemon-bootstrap.ts"() {
|
|
26343
26581
|
"use strict";
|
|
26344
26582
|
init_tmux_server_proof();
|
|
26583
|
+
init_invocation_directory();
|
|
26345
26584
|
init_workspace_pane_creation2();
|
|
26346
26585
|
init_runtime_namespace();
|
|
26347
26586
|
init_semver();
|
|
@@ -26378,6 +26617,7 @@ var init_canonical_daemon_bootstrap = __esm({
|
|
|
26378
26617
|
setTimeout(resolveSleep, milliseconds);
|
|
26379
26618
|
})
|
|
26380
26619
|
};
|
|
26620
|
+
DAEMON_PROOF_PENDING = /* @__PURE__ */ Symbol("daemon-server-proof-pending");
|
|
26381
26621
|
}
|
|
26382
26622
|
});
|
|
26383
26623
|
|
|
@@ -29644,9 +29884,13 @@ function semanticPaneIds(session) {
|
|
|
29644
29884
|
}
|
|
29645
29885
|
return result2;
|
|
29646
29886
|
}
|
|
29647
|
-
function
|
|
29648
|
-
|
|
29649
|
-
|
|
29887
|
+
function readTmuxSessions() {
|
|
29888
|
+
let raw;
|
|
29889
|
+
try {
|
|
29890
|
+
raw = _tmuxRunner(["list-sessions", "-F", "#{session_name}"]);
|
|
29891
|
+
} catch (error) {
|
|
29892
|
+
return serverNotRunning(error) ? [] : null;
|
|
29893
|
+
}
|
|
29650
29894
|
return raw.split("\n").filter(Boolean);
|
|
29651
29895
|
}
|
|
29652
29896
|
function discoverLiveSessionSummaries(runTmux2 = _tmuxRunner) {
|
|
@@ -29823,7 +30067,11 @@ function assembleAdoptedFleet(adopted, panesRaw, registry, nativeEpoch, resolveI
|
|
|
29823
30067
|
});
|
|
29824
30068
|
}
|
|
29825
30069
|
function discoverSessions() {
|
|
29826
|
-
|
|
30070
|
+
return readSessions() ?? [];
|
|
30071
|
+
}
|
|
30072
|
+
function readSessions() {
|
|
30073
|
+
const sessionNames = readTmuxSessions();
|
|
30074
|
+
if (sessionNames === null) return null;
|
|
29827
30075
|
const results = [];
|
|
29828
30076
|
const registry = getDefaultWorkspaceRegistry();
|
|
29829
30077
|
const enforceRegistry = registry._isLoaded();
|
|
@@ -29873,7 +30121,9 @@ var init_discovery = __esm({
|
|
|
29873
30121
|
_tmuxRunner = (args) => execFileSync16("tmux", ["-u", ...runtimeTmuxArgs(args)], {
|
|
29874
30122
|
encoding: "utf-8",
|
|
29875
30123
|
maxBuffer: 1024 * 1024,
|
|
29876
|
-
|
|
30124
|
+
// Keep stderr on the error: it is how a caller tells "no server running"
|
|
30125
|
+
// from a server it could not reach. Nothing is printed either way.
|
|
30126
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
29877
30127
|
}).trim();
|
|
29878
30128
|
ADOPTED_SESSIONS_ARGS = ["list-sessions", "-F", `#{session_name} #{${ADOPTED_OPTION}}`];
|
|
29879
30129
|
FLEET_FIELD_SEPARATOR = "|tmux-ide-fleet-field-v1|";
|
|
@@ -30208,10 +30458,13 @@ function processIsAlive(pid) {
|
|
|
30208
30458
|
return error.code !== "ESRCH";
|
|
30209
30459
|
}
|
|
30210
30460
|
}
|
|
30211
|
-
function nextHookHealthcheckDelay(previousMs, outcome, schedule = DEFAULT_HOOK_HEALTHCHECK_SCHEDULE) {
|
|
30461
|
+
function nextHookHealthcheckDelay(previousMs, outcome, schedule = DEFAULT_HOOK_HEALTHCHECK_SCHEDULE, consecutiveUnhealthy = 1) {
|
|
30212
30462
|
const base2 = Math.max(1, Math.floor(schedule.baseMs));
|
|
30213
30463
|
const max = Math.max(base2, Math.floor(schedule.maxMs));
|
|
30214
|
-
if (outcome !== "healthy")
|
|
30464
|
+
if (outcome !== "healthy") {
|
|
30465
|
+
const streak = Math.max(1, Math.min(32, Math.floor(consecutiveUnhealthy) || 1));
|
|
30466
|
+
return Math.min(base2 * 2 ** (streak - 1), max);
|
|
30467
|
+
}
|
|
30215
30468
|
const previous = Number.isFinite(previousMs) ? Math.max(base2, Math.floor(previousMs)) : base2;
|
|
30216
30469
|
return Math.min(previous * 2, max);
|
|
30217
30470
|
}
|
|
@@ -30398,6 +30651,8 @@ var init_tmux_external_interaction_observer = __esm({
|
|
|
30398
30651
|
#healthcheckSchedule;
|
|
30399
30652
|
#healthcheckDelayMs;
|
|
30400
30653
|
#lastHealthcheckOutcome = "failed";
|
|
30654
|
+
/** Scheduled checks in a row that did not find the hooks intact. */
|
|
30655
|
+
#unhealthyChecks = 0;
|
|
30401
30656
|
#onAvailability;
|
|
30402
30657
|
#onGap;
|
|
30403
30658
|
#tmuxWork = Promise.resolve();
|
|
@@ -30509,11 +30764,13 @@ var init_tmux_external_interaction_observer = __esm({
|
|
|
30509
30764
|
if (!this.#abort.signal.aborted) this.#reportGap("hook-repair-failed");
|
|
30510
30765
|
outcome = "failed";
|
|
30511
30766
|
}
|
|
30767
|
+
this.#unhealthyChecks = outcome === "healthy" ? 0 : this.#unhealthyChecks + 1;
|
|
30512
30768
|
if (this.#healthcheckDelayMs === delayBefore) {
|
|
30513
30769
|
this.#healthcheckDelayMs = nextHookHealthcheckDelay(
|
|
30514
30770
|
delayBefore,
|
|
30515
30771
|
outcome,
|
|
30516
|
-
this.#healthcheckSchedule
|
|
30772
|
+
this.#healthcheckSchedule,
|
|
30773
|
+
this.#unhealthyChecks
|
|
30517
30774
|
);
|
|
30518
30775
|
}
|
|
30519
30776
|
if (this.#hookHealthcheck === null) this.#scheduleHealthcheck();
|
|
@@ -30607,11 +30864,17 @@ var init_tmux_external_interaction_observer = __esm({
|
|
|
30607
30864
|
const work = this.#serializeTmux(async () => {
|
|
30608
30865
|
const finish = this.#beginDiagnostic("healthcheck");
|
|
30609
30866
|
try {
|
|
30610
|
-
|
|
30867
|
+
const hooks = await this.#ownedHooksPresent(this.#abort.signal);
|
|
30868
|
+
if (hooks === "present") {
|
|
30611
30869
|
this.#lastHealthcheckOutcome = "healthy";
|
|
30612
30870
|
finish(true);
|
|
30613
30871
|
return;
|
|
30614
30872
|
}
|
|
30873
|
+
if (hooks === "unknown") {
|
|
30874
|
+
this.#lastHealthcheckOutcome = "failed";
|
|
30875
|
+
finish(false);
|
|
30876
|
+
return;
|
|
30877
|
+
}
|
|
30615
30878
|
if (this.#installed) this.#reportGap("hooks-replaced");
|
|
30616
30879
|
this.#setInstalled(false);
|
|
30617
30880
|
try {
|
|
@@ -30843,9 +31106,9 @@ var init_tmux_external_interaction_observer = __esm({
|
|
|
30843
31106
|
signal
|
|
30844
31107
|
);
|
|
30845
31108
|
} catch {
|
|
30846
|
-
return
|
|
31109
|
+
return "unknown";
|
|
30847
31110
|
}
|
|
30848
|
-
return ownedHookInstalled(output, "after-send-keys", this.#bufferName) && ownedHookInstalled(output, "after-capture-pane", this.#bufferName);
|
|
31111
|
+
return ownedHookInstalled(output, "after-send-keys", this.#bufferName) && ownedHookInstalled(output, "after-capture-pane", this.#bufferName) ? "present" : "missing";
|
|
30849
31112
|
}
|
|
30850
31113
|
get available() {
|
|
30851
31114
|
return this.#installed;
|
|
@@ -34815,10 +35078,35 @@ var init_session_channel = __esm({
|
|
|
34815
35078
|
}
|
|
34816
35079
|
this.input.flush();
|
|
34817
35080
|
this.clearWindowViewports();
|
|
34818
|
-
this.
|
|
35081
|
+
const target = this.attachedIdentity?.runtimeSessionId ?? `=${this.opts.session}`;
|
|
35082
|
+
this.restoreWindowSizing(target);
|
|
34819
35083
|
this.io.send(`refresh-client -C ${cols}x${rows}${this.cellPixelSuffix()}`);
|
|
35084
|
+
this.reclaimWindowSize(target);
|
|
34820
35085
|
this.clientViewport = { cols, rows };
|
|
34821
35086
|
}
|
|
35087
|
+
/**
|
|
35088
|
+
* Under `window-size latest` a second tmux client on the session (a terminal
|
|
35089
|
+
* the user also attached) takes the window, and nothing this control client
|
|
35090
|
+
* sends makes it tmux's latest client again: input and refresh-client are not
|
|
35091
|
+
* client activity. Output then prints at the other client's width and tmux
|
|
35092
|
+
* re-wraps it mid-word when that width goes away (#695). A fit is the app
|
|
35093
|
+
* being used (it fits on focus and on a change of its canvas), so after one,
|
|
35094
|
+
* when the window is not this client's size, switch to the same session:
|
|
35095
|
+
* that makes this client the latest one. Only here, never on a timer or a
|
|
35096
|
+
* notification, so two clients never fight; whichever the user used last
|
|
35097
|
+
* wins, as between two terminals. Other window-size policies are the user's.
|
|
35098
|
+
*/
|
|
35099
|
+
reclaimWindowSize(target) {
|
|
35100
|
+
if (!this.geometryParticipating) return;
|
|
35101
|
+
const quoted = tmuxSingleQuote(target);
|
|
35102
|
+
this.io.commandListInline(
|
|
35103
|
+
`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} ''`),
|
|
35104
|
+
2,
|
|
35105
|
+
1,
|
|
35106
|
+
() => {
|
|
35107
|
+
}
|
|
35108
|
+
);
|
|
35109
|
+
}
|
|
34822
35110
|
clientViewport = null;
|
|
34823
35111
|
cellPixels = null;
|
|
34824
35112
|
/** "/WxH" for tmux's refresh-client -C (patched tmux; stock ignores it). */
|
|
@@ -36743,7 +37031,9 @@ var init_session_channel = __esm({
|
|
|
36743
37031
|
const rightWindow = right.windows.get(runtimeId);
|
|
36744
37032
|
const leftLayout = left.layouts.get(runtimeId);
|
|
36745
37033
|
const rightLayout = right.layouts.get(runtimeId);
|
|
36746
|
-
if (!rightWindow || !leftLayout || !rightLayout || leftWindow.semanticId !== rightWindow.semanticId ||
|
|
37034
|
+
if (!rightWindow || !leftLayout || !rightLayout || leftWindow.semanticId !== rightWindow.semanticId || // Not the name: tmux derives it from the running command, and the
|
|
37035
|
+
// pane rows' own check ignores it too (sameSessionPaneInventory, #730).
|
|
37036
|
+
leftWindow.paneBorderStatus !== rightWindow.paneBorderStatus || leftWindow.modeKeys !== rightWindow.modeKeys || !layoutIdentitiesEqual(leftLayout, rightLayout)) {
|
|
36747
37037
|
return false;
|
|
36748
37038
|
}
|
|
36749
37039
|
}
|
|
@@ -42170,7 +42460,7 @@ function classifiedAsyncRunner(tmuxAuthority) {
|
|
|
42170
42460
|
function digest2(value) {
|
|
42171
42461
|
return createHash19("sha256").update(value).digest("hex").slice(0, 20);
|
|
42172
42462
|
}
|
|
42173
|
-
var MAX_OPERATIONS, MAX_REPLAYABLE_FAILURES2, MAX_TMUX_OUTPUT_BYTES, ADOPTED_OPTION2, SESSION_PROMOTED_MARKER_OPTION, SESSION_WORKSPACE_OPTION, SESSION_OPERATION_OPTION, SEMANTIC_PANE_OPTION3, SEMANTIC_WINDOW_OPTION2, FIELD, SENTINEL, SESSION_FORMAT, PANE_SCAN_FORMAT, PANE_VERIFY_FORMAT, ERROR_MESSAGES3, WorkspacePromotionError, VALID_SEMANTIC_PANE_ID, RESERVED_DISCOVERED_PREFIX, DEFAULT_IO3, WorkspacePromotionAuthority;
|
|
42463
|
+
var MAX_OPERATIONS, MAX_REPLAYABLE_FAILURES2, MAX_TMUX_OUTPUT_BYTES, ADOPTED_OPTION2, SESSION_PROMOTED_MARKER_OPTION, SESSION_WORKSPACE_OPTION, SESSION_OPERATION_OPTION, SEMANTIC_PANE_OPTION3, SEMANTIC_WINDOW_OPTION2, FIELD, SENTINEL, SESSION_FORMAT, PANE_SCAN_FORMAT, PANE_VERIFY_FORMAT, ERROR_MESSAGES3, PROMOTION_PROOF_ATTEMPTS, WorkspacePromotionError, VALID_SEMANTIC_PANE_ID, RESERVED_DISCOVERED_PREFIX, DEFAULT_IO3, WorkspacePromotionAuthority;
|
|
42174
42464
|
var init_workspace_promotion2 = __esm({
|
|
42175
42465
|
"packages/daemon/src/lib/workspace-promotion.ts"() {
|
|
42176
42466
|
"use strict";
|
|
@@ -42243,6 +42533,7 @@ var init_workspace_promotion2 = __esm({
|
|
|
42243
42533
|
operation_conflict: "The operation id was already used for another promotion intent.",
|
|
42244
42534
|
operation_capacity: "The daemon has reached its bounded workspace-promote operation capacity."
|
|
42245
42535
|
};
|
|
42536
|
+
PROMOTION_PROOF_ATTEMPTS = 3;
|
|
42246
42537
|
WorkspacePromotionError = class extends Error {
|
|
42247
42538
|
code;
|
|
42248
42539
|
context;
|
|
@@ -42362,9 +42653,19 @@ var init_workspace_promotion2 = __esm({
|
|
|
42362
42653
|
}
|
|
42363
42654
|
const identity4 = alreadyRegistered ? { workspaceName: alreadyRegistered.name, sessionName: session.sessionName } : derivePromotionIdentity(session.sessionName);
|
|
42364
42655
|
this.#assertConflictFreeIdentity(identity4);
|
|
42365
|
-
|
|
42366
|
-
|
|
42367
|
-
|
|
42656
|
+
let canonicalRoot;
|
|
42657
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
42658
|
+
canonicalRoot = await this.#stampSession(request3, session, identity4);
|
|
42659
|
+
this.#assertActive(request3.operationId);
|
|
42660
|
+
try {
|
|
42661
|
+
await this.#verifyPromotedInventory(session.sessionId, identity4);
|
|
42662
|
+
break;
|
|
42663
|
+
} catch (error) {
|
|
42664
|
+
if (attempt >= PROMOTION_PROOF_ATTEMPTS || !(error instanceof WorkspacePromotionError) || error.context.reason !== "inventory_changed_during_proof")
|
|
42665
|
+
throw error;
|
|
42666
|
+
this.#assertActive(request3.operationId);
|
|
42667
|
+
}
|
|
42668
|
+
}
|
|
42368
42669
|
await this.#publishFleetEnrollment(request3, session, identity4);
|
|
42369
42670
|
const discovered = this.#registeredSession(session.sessionName);
|
|
42370
42671
|
if (discovered) {
|
|
@@ -44510,6 +44811,28 @@ var init_mirror_service = __esm({
|
|
|
44510
44811
|
wasPending: this.registeredWindows?.pending() ?? null
|
|
44511
44812
|
});
|
|
44512
44813
|
this.registeredWindows?.invalidate();
|
|
44814
|
+
this.scheduleOwnershipVerify();
|
|
44815
|
+
}
|
|
44816
|
+
/**
|
|
44817
|
+
* Until a read proves ownership again, every retained session refuses input
|
|
44818
|
+
* and geometry. A workspace added or removed (another session created or
|
|
44819
|
+
* killed) invalidates without any channel resyncing, and nothing else read
|
|
44820
|
+
* again until the next stream was issued: the next keystroke closed the
|
|
44821
|
+
* stream. Read again at once (coalesced) while a channel is retained; a
|
|
44822
|
+
* failed read takes the #764 retry path.
|
|
44823
|
+
*/
|
|
44824
|
+
ownershipVerifyScheduled = false;
|
|
44825
|
+
scheduleOwnershipVerify() {
|
|
44826
|
+
if (this.ownershipVerifyScheduled || this.disposed) return;
|
|
44827
|
+
this.ownershipVerifyScheduled = true;
|
|
44828
|
+
const timer = setTimeout(() => {
|
|
44829
|
+
this.ownershipVerifyScheduled = false;
|
|
44830
|
+
if (this.disposed || this.channelSessions.size === 0 || !this.registeredWindows?.pending())
|
|
44831
|
+
return;
|
|
44832
|
+
void this.verifyRegisteredWindows().catch(() => {
|
|
44833
|
+
});
|
|
44834
|
+
}, 0);
|
|
44835
|
+
timer.unref?.();
|
|
44513
44836
|
}
|
|
44514
44837
|
/**
|
|
44515
44838
|
* #764: a failed re-read must not leave every session "being verified"
|
|
@@ -44842,6 +45165,10 @@ var init_mirror_service = __esm({
|
|
|
44842
45165
|
const message = this.windowOwnershipMessage(session);
|
|
44843
45166
|
if (message) throw new Error(message);
|
|
44844
45167
|
}
|
|
45168
|
+
/** Registered-window ownership is being read again; input waits for it. */
|
|
45169
|
+
windowOwnershipPending() {
|
|
45170
|
+
return this.registeredWindows?.pending() ?? false;
|
|
45171
|
+
}
|
|
44845
45172
|
windowOwnershipMessage(session) {
|
|
44846
45173
|
if (this.registeredWindows?.pending())
|
|
44847
45174
|
return "Window ownership is being verified. Retry after session discovery completes.";
|
|
@@ -63495,16 +63822,27 @@ var init_kitty_graphics = __esm({
|
|
|
63495
63822
|
#pending = null;
|
|
63496
63823
|
#nextAnonymous = 2130706432;
|
|
63497
63824
|
#bytes = 0;
|
|
63825
|
+
/** Cell size in thousandths of a device pixel. */
|
|
63498
63826
|
#cellWidth;
|
|
63499
63827
|
#cellHeight;
|
|
63500
63828
|
#budget;
|
|
63501
63829
|
#revision = 0;
|
|
63502
63830
|
constructor(options = {}) {
|
|
63503
|
-
this.#cellWidth = options.cellWidthPx ?? 10;
|
|
63504
|
-
this.#cellHeight = options.cellHeightPx ?? 20;
|
|
63831
|
+
this.#cellWidth = (options.cellWidthPx ?? 10) * 1e3;
|
|
63832
|
+
this.#cellHeight = (options.cellHeightPx ?? 20) * 1e3;
|
|
63505
63833
|
this.#budget = options.budget ?? DEFAULT_KITTY_IMAGE_BUDGET;
|
|
63506
63834
|
this.#budget.register(this);
|
|
63507
63835
|
}
|
|
63836
|
+
/**
|
|
63837
|
+
* The renderer's cell size in device pixels, with thousandths when it reports
|
|
63838
|
+
* them (capability 103/104). Placements made from now on that give no `c`/`r`
|
|
63839
|
+
* cover the image at this size; earlier ones keep their grid.
|
|
63840
|
+
*/
|
|
63841
|
+
setCellPixels(width, height, precise) {
|
|
63842
|
+
if (!(width > 0 && height > 0)) return;
|
|
63843
|
+
this.#cellWidth = precise && precise.width > 0 ? precise.width : width * 1e3;
|
|
63844
|
+
this.#cellHeight = precise && precise.height > 0 ? precise.height : height * 1e3;
|
|
63845
|
+
}
|
|
63508
63846
|
/** Bumps whenever images or placements change. */
|
|
63509
63847
|
get revision() {
|
|
63510
63848
|
return this.#revision;
|
|
@@ -63620,8 +63958,12 @@ var init_kitty_graphics = __esm({
|
|
|
63620
63958
|
const image = this.#images.get(imageId);
|
|
63621
63959
|
if (!image) return;
|
|
63622
63960
|
this.#used.set(imageId, this.#budget.nextTick());
|
|
63623
|
-
const columns = clampCells(
|
|
63624
|
-
|
|
63961
|
+
const columns = clampCells(
|
|
63962
|
+
int(control, "c") || Math.ceil(image.width * 1e3 / this.#cellWidth)
|
|
63963
|
+
);
|
|
63964
|
+
const rows = clampCells(
|
|
63965
|
+
int(control, "r") || Math.ceil(image.height * 1e3 / this.#cellHeight)
|
|
63966
|
+
);
|
|
63625
63967
|
const placementId = int(control, "p");
|
|
63626
63968
|
if (control.get("U") === "1") {
|
|
63627
63969
|
const placements = this.#virtual.get(imageId) ?? /* @__PURE__ */ new Map();
|
|
@@ -63848,6 +64190,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63848
64190
|
"packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts"() {
|
|
63849
64191
|
"use strict";
|
|
63850
64192
|
init_stock_capture_fidelity();
|
|
64193
|
+
init_log();
|
|
63851
64194
|
init_native_seed_backing();
|
|
63852
64195
|
init_src2();
|
|
63853
64196
|
init_src3();
|
|
@@ -63864,6 +64207,9 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63864
64207
|
#nativeSeedBackingCandidate;
|
|
63865
64208
|
#generation;
|
|
63866
64209
|
#workspaceName;
|
|
64210
|
+
#stockTabsNoted = false;
|
|
64211
|
+
#seedOrdinal = 0;
|
|
64212
|
+
#reconstructedSeed = null;
|
|
63867
64213
|
#semanticPaneId;
|
|
63868
64214
|
#incarnation;
|
|
63869
64215
|
#scrollback;
|
|
@@ -64000,6 +64346,14 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64000
64346
|
currentSeed() {
|
|
64001
64347
|
return this.#needsSeed ? null : this.#seed();
|
|
64002
64348
|
}
|
|
64349
|
+
/**
|
|
64350
|
+
* Names the current seed when its tab cells were reconstructed from a stock
|
|
64351
|
+
* capture; null otherwise. Such a seed can wrap a reflowed line at other
|
|
64352
|
+
* places than tmux does, so its history can differ from tmux's in length.
|
|
64353
|
+
*/
|
|
64354
|
+
reconstructedSeed() {
|
|
64355
|
+
return this.#reconstructedSeed;
|
|
64356
|
+
}
|
|
64003
64357
|
/** Prioritize one future parser admission, independent of diagnostic tracing. */
|
|
64004
64358
|
prioritizeNextWrite() {
|
|
64005
64359
|
if (!this.#closed) this.#prioritizeNextWrite = true;
|
|
@@ -64060,7 +64414,9 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64060
64414
|
async #apply(operation) {
|
|
64061
64415
|
if (this.#closed) return;
|
|
64062
64416
|
if (operation.type === "reseed") {
|
|
64063
|
-
|
|
64417
|
+
const paintCapturedTabs = operation.bootstrap === "painted-capture" && !operation.native;
|
|
64418
|
+
let seedReconstructed;
|
|
64419
|
+
if (paintCapturedTabs && !this.#backend.graphicsCursor)
|
|
64064
64420
|
assertStockCaptureRepresentable(operation.captureChunks ?? operation.chunks);
|
|
64065
64421
|
this.#causalCell?.fail("reseeded");
|
|
64066
64422
|
const nativeCols = operation.nativeCols ?? operation.cols;
|
|
@@ -64079,9 +64435,18 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64079
64435
|
try {
|
|
64080
64436
|
if (operation.native && !replacement.importNativeGrid?.(operation.native))
|
|
64081
64437
|
throw new Error("Native bootstrap requires a compatible interpreter");
|
|
64438
|
+
const captured = operation.captureChunks ?? operation.chunks;
|
|
64439
|
+
let nextCaptured = 0;
|
|
64440
|
+
let reconstructed = false;
|
|
64082
64441
|
for (const chunk of operation.chunks) {
|
|
64083
|
-
|
|
64442
|
+
const fromCapture = paintCapturedTabs && nextCaptured < captured.length && Buffer.compare(chunk, captured[nextCaptured]) === 0;
|
|
64443
|
+
if (fromCapture) nextCaptured += 1;
|
|
64444
|
+
if (fromCapture && chunk.includes(9)) {
|
|
64445
|
+
reconstructed = true;
|
|
64446
|
+
await this.#writeStockCapture(replacement, chunk);
|
|
64447
|
+
} else await this.#writeToBackend(replacement, chunk);
|
|
64084
64448
|
}
|
|
64449
|
+
seedReconstructed = reconstructed;
|
|
64085
64450
|
if (operation.wraparound !== void 0)
|
|
64086
64451
|
replacement.setAuthoritativeWraparound(operation.wraparound);
|
|
64087
64452
|
if (operation.observedModes) replacement.setAuthoritativeModes(operation.observedModes);
|
|
@@ -64107,6 +64472,8 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64107
64472
|
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;
|
|
64108
64473
|
if (!sameGraphicsBasis) this.#kitty.dropCursorPlacements();
|
|
64109
64474
|
this.#nativeReseedRequested = false;
|
|
64475
|
+
this.#seedOrdinal += 1;
|
|
64476
|
+
this.#reconstructedSeed = seedReconstructed ? this.#seedOrdinal : null;
|
|
64110
64477
|
this.#scrollback = scrollback;
|
|
64111
64478
|
this.#bootstrap = {
|
|
64112
64479
|
kind: operation.bootstrap,
|
|
@@ -64246,6 +64613,42 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64246
64613
|
this.#tail = run.catch(() => void 0);
|
|
64247
64614
|
}, 250);
|
|
64248
64615
|
}
|
|
64616
|
+
/**
|
|
64617
|
+
* Replay one stock `capture-pane -e` chunk. tmux stores a tab as one wide
|
|
64618
|
+
* cell and prints it as a single HT, without its width. Blank the cells up
|
|
64619
|
+
* to the next default tab stop instead (ECH, then CUF): that is the cell tmux
|
|
64620
|
+
* made when the tab was written at this column, and erased cells take the
|
|
64621
|
+
* rendition the capture set for it, as tmux's blank tab cell does. tmux never
|
|
64622
|
+
* tabs into the last column (`input_c0_dispatch`).
|
|
64623
|
+
* Where this differs from tmux: a row edited after its tab was written
|
|
64624
|
+
* (insert or delete character) or written under custom tab stops is columns
|
|
64625
|
+
* off in that row. A line reflowed by a resize is worse: tmux keeps the tab
|
|
64626
|
+
* cell's width, this measures it again from the new column, so the line can
|
|
64627
|
+
* wrap at other places and the pane can hold other rows than tmux shows,
|
|
64628
|
+
* until that output scrolls away or is redrawn. The owner accepts the
|
|
64629
|
+
* resulting difference in history length (`reconstructedSeed`).
|
|
64630
|
+
*/
|
|
64631
|
+
async #writeStockCapture(backend2, chunk) {
|
|
64632
|
+
let start3 = 0;
|
|
64633
|
+
for (; ; ) {
|
|
64634
|
+
const tab = chunk.indexOf(9, start3);
|
|
64635
|
+
if (tab < 0) break;
|
|
64636
|
+
if (tab > start3) await this.#writeToBackend(backend2, chunk.subarray(start3, tab));
|
|
64637
|
+
const column = backend2.graphicsCursor().x;
|
|
64638
|
+
const stop3 = Math.min(backend2.cols - 1, (Math.floor(column / 8) + 1) * 8);
|
|
64639
|
+
if (stop3 > column)
|
|
64640
|
+
await this.#writeToBackend(backend2, `\x1B[${stop3 - column}X\x1B[${stop3 - column}C`);
|
|
64641
|
+
start3 = tab + 1;
|
|
64642
|
+
}
|
|
64643
|
+
if (!this.#stockTabsNoted) {
|
|
64644
|
+
this.#stockTabsNoted = true;
|
|
64645
|
+
logger.info("terminal-replica", "stock capture: tab positions reconstructed", {
|
|
64646
|
+
pane: this.#semanticPaneId,
|
|
64647
|
+
workspace: this.#workspaceName
|
|
64648
|
+
});
|
|
64649
|
+
}
|
|
64650
|
+
if (start3 < chunk.length) await this.#writeToBackend(backend2, chunk.subarray(start3));
|
|
64651
|
+
}
|
|
64249
64652
|
#writeToBackend(backend2, data) {
|
|
64250
64653
|
if (this.#prioritizeNextWrite) {
|
|
64251
64654
|
this.#prioritizeNextWrite = false;
|
|
@@ -64704,6 +65107,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
64704
65107
|
#historyTimer = null;
|
|
64705
65108
|
#historyChecking = false;
|
|
64706
65109
|
#historyDirty = false;
|
|
65110
|
+
#reconstructedHistoryGap = null;
|
|
64707
65111
|
installOutputTraceReader(reader) {
|
|
64708
65112
|
this.#takeOutputTrace ??= reader;
|
|
64709
65113
|
}
|
|
@@ -64867,6 +65271,10 @@ var init_terminal_replica_owner = __esm({
|
|
|
64867
65271
|
if (current) listener(current);
|
|
64868
65272
|
return this.#interpreter.onGraphics(listener);
|
|
64869
65273
|
}
|
|
65274
|
+
/** The renderer's cell size, for image placements that give no `c`/`r` (group H). */
|
|
65275
|
+
setCellPixels(width, height, precise) {
|
|
65276
|
+
this.#interpreter.kittyImages().setCellPixels(width, height, precise);
|
|
65277
|
+
}
|
|
64870
65278
|
/** Image bytes by content digest, while the pane's store still holds them. */
|
|
64871
65279
|
graphicsImage(digest3) {
|
|
64872
65280
|
return this.#interpreter.kittyImages().imageByDigest(digest3) ?? null;
|
|
@@ -64925,7 +65333,17 @@ var init_terminal_replica_owner = __esm({
|
|
|
64925
65333
|
this.#historyDirty || this.#stale || this.#reseed || this.#waitingForGeometryCapture || size === null)
|
|
64926
65334
|
return;
|
|
64927
65335
|
const seed = this.#interpreter.currentSeed();
|
|
64928
|
-
if (seed
|
|
65336
|
+
if (!seed) return;
|
|
65337
|
+
const gap = size - seed.snapshot.history.length;
|
|
65338
|
+
const reconstructed = this.#interpreter.reconstructedSeed();
|
|
65339
|
+
if (reconstructed !== null) {
|
|
65340
|
+
if (this.#reconstructedHistoryGap?.seed !== reconstructed) {
|
|
65341
|
+
this.#reconstructedHistoryGap = { seed: reconstructed, gap };
|
|
65342
|
+
return;
|
|
65343
|
+
}
|
|
65344
|
+
if (this.#reconstructedHistoryGap.gap === gap) return;
|
|
65345
|
+
} else if (gap === 0) return;
|
|
65346
|
+
upstream.reseed();
|
|
64929
65347
|
} catch {
|
|
64930
65348
|
} finally {
|
|
64931
65349
|
this.#historyChecking = false;
|
|
@@ -67431,7 +67849,7 @@ function authoredOriginForSurface(surface) {
|
|
|
67431
67849
|
if (surface === "cli") return "cli";
|
|
67432
67850
|
return "gui";
|
|
67433
67851
|
}
|
|
67434
|
-
var emptyListenerDisposal, SessionRuntimeControllerLeaseError, SessionRuntimeRegistry, SessionRuntime, SessionRuntimeConsumerImpl;
|
|
67852
|
+
var emptyListenerDisposal, SessionRuntimeControllerLeaseError, SessionRuntimeInputLifetimeEndedError, SessionRuntimeRegistry, SessionRuntime, SessionRuntimeConsumerImpl;
|
|
67435
67853
|
var init_registry2 = __esm({
|
|
67436
67854
|
"packages/daemon/src/terminal/session-runtime/registry.ts"() {
|
|
67437
67855
|
"use strict";
|
|
@@ -67468,6 +67886,12 @@ var init_registry2 = __esm({
|
|
|
67468
67886
|
}
|
|
67469
67887
|
code;
|
|
67470
67888
|
};
|
|
67889
|
+
SessionRuntimeInputLifetimeEndedError = class extends Error {
|
|
67890
|
+
constructor(message) {
|
|
67891
|
+
super(message);
|
|
67892
|
+
this.name = "SessionRuntimeInputLifetimeEndedError";
|
|
67893
|
+
}
|
|
67894
|
+
};
|
|
67471
67895
|
SessionRuntimeRegistry = class {
|
|
67472
67896
|
generation;
|
|
67473
67897
|
#mirror;
|
|
@@ -67757,6 +68181,10 @@ var init_registry2 = __esm({
|
|
|
67757
68181
|
async verifyWindowOwnership() {
|
|
67758
68182
|
await this.#mirror.verifyRegisteredWindows();
|
|
67759
68183
|
}
|
|
68184
|
+
/** Ownership is being read again: input and geometry wait, they are not refused for good. */
|
|
68185
|
+
windowOwnershipPending() {
|
|
68186
|
+
return !this.#disposed && this.#mirror.windowOwnershipPending();
|
|
68187
|
+
}
|
|
67760
68188
|
/** Install the bounded registered-session membership reader. */
|
|
67761
68189
|
setRegisteredWindowReader(reader) {
|
|
67762
68190
|
return this.#mirror.setRegisteredWindowReader(reader);
|
|
@@ -68228,6 +68656,8 @@ var init_registry2 = __esm({
|
|
|
68228
68656
|
#consumersByClientId = /* @__PURE__ */ new Map();
|
|
68229
68657
|
#terminalReplicas = /* @__PURE__ */ new Map();
|
|
68230
68658
|
#terminalReplicaClocks = /* @__PURE__ */ new Map();
|
|
68659
|
+
/** The renderer's last reported cell size; every pane's image placements use it. */
|
|
68660
|
+
#cellPixels = null;
|
|
68231
68661
|
#outputTraces;
|
|
68232
68662
|
#outputObservations = /* @__PURE__ */ new Map();
|
|
68233
68663
|
#createTraceCorrelator;
|
|
@@ -68485,7 +68915,8 @@ var init_registry2 = __esm({
|
|
|
68485
68915
|
}) : null;
|
|
68486
68916
|
const started = this.#observability.enabled ? this.#observability.nowMicros() : 0;
|
|
68487
68917
|
const replicaOwner = expectedLifetime ? this.#terminalReplicas.get(semanticPaneId3) : this.#terminalReplicaOwner(semanticPaneId3);
|
|
68488
|
-
if (!replicaOwner)
|
|
68918
|
+
if (!replicaOwner)
|
|
68919
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime unavailable");
|
|
68489
68920
|
if (causalProbe) {
|
|
68490
68921
|
this.#activeCausalCellProbes += 1;
|
|
68491
68922
|
let settled = false;
|
|
@@ -68509,7 +68940,7 @@ var init_registry2 = __esm({
|
|
|
68509
68940
|
}
|
|
68510
68941
|
try {
|
|
68511
68942
|
if (expectedLifetime && (expectedLifetime.generation !== this.generation || this.#terminalReplicas.get(semanticPaneId3) !== replicaOwner || replicaOwner.inputAdmissionIncarnation() !== expectedLifetime.incarnation))
|
|
68512
|
-
throw new
|
|
68943
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime changed");
|
|
68513
68944
|
if (input.kind === "text")
|
|
68514
68945
|
this.#mirror.sendText(
|
|
68515
68946
|
this.session,
|
|
@@ -68609,6 +69040,9 @@ var init_registry2 = __esm({
|
|
|
68609
69040
|
setCellPixels(clientId, width, height, precise) {
|
|
68610
69041
|
this.#assertConnected(clientId);
|
|
68611
69042
|
this.#mirror.setCellPixels?.(this.session, width, height, precise);
|
|
69043
|
+
this.#cellPixels = { width, height, ...precise ? { precise } : {} };
|
|
69044
|
+
for (const owner of this.#terminalReplicas.values())
|
|
69045
|
+
owner.setCellPixels(width, height, precise);
|
|
68612
69046
|
}
|
|
68613
69047
|
fitViewportWithAuthority(clientId, lease, cols, rows, semanticWindowId) {
|
|
68614
69048
|
this.assertGeometryAuthority(clientId, lease);
|
|
@@ -68778,6 +69212,12 @@ var init_registry2 = __esm({
|
|
|
68778
69212
|
}
|
|
68779
69213
|
);
|
|
68780
69214
|
owner = candidate;
|
|
69215
|
+
if (this.#cellPixels)
|
|
69216
|
+
owner.setCellPixels(
|
|
69217
|
+
this.#cellPixels.width,
|
|
69218
|
+
this.#cellPixels.height,
|
|
69219
|
+
this.#cellPixels.precise
|
|
69220
|
+
);
|
|
68781
69221
|
this.#terminalReplicas.set(semanticPaneId3, owner);
|
|
68782
69222
|
}
|
|
68783
69223
|
return owner;
|
|
@@ -69389,6 +69829,40 @@ var init_transport_binding = __esm({
|
|
|
69389
69829
|
);
|
|
69390
69830
|
this.#binder.registry.assertExecutionHandle(this.#baseHandle, semanticPaneId3);
|
|
69391
69831
|
}
|
|
69832
|
+
/**
|
|
69833
|
+
* The session's pane set changed under this live transport (#723). The
|
|
69834
|
+
* caller is the daemon's own stream boundary, and the panes come from its
|
|
69835
|
+
* trusted inventory of this binding's session: a client can never name a
|
|
69836
|
+
* pane here. The grant stays exact: added panes join it, removed panes leave
|
|
69837
|
+
* it, and every execution handle is rebuilt from the amended set.
|
|
69838
|
+
* All-or-nothing: an invalid pane id changes nothing.
|
|
69839
|
+
*/
|
|
69840
|
+
amendPaneGrant(change) {
|
|
69841
|
+
this.#assertOpen();
|
|
69842
|
+
const added = change.added.map(
|
|
69843
|
+
(paneId) => TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId)
|
|
69844
|
+
);
|
|
69845
|
+
const removed = change.removed.map(
|
|
69846
|
+
(paneId) => TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId)
|
|
69847
|
+
);
|
|
69848
|
+
for (const paneId of removed) {
|
|
69849
|
+
if (!this.#allowedSourcePaneIds.delete(paneId)) continue;
|
|
69850
|
+
if (!this.#contributedSourcePaneIds.delete(paneId)) continue;
|
|
69851
|
+
const next = (this.#shared.grantRefs.get(paneId) ?? 0) - 1;
|
|
69852
|
+
if (next > 0) this.#shared.grantRefs.set(paneId, next);
|
|
69853
|
+
else this.#shared.grantRefs.delete(paneId);
|
|
69854
|
+
}
|
|
69855
|
+
for (const paneId of added) {
|
|
69856
|
+
if (this.#allowedSourcePaneIds.has(paneId)) continue;
|
|
69857
|
+
this.#allowedSourcePaneIds.add(paneId);
|
|
69858
|
+
if (!this.#interactive) continue;
|
|
69859
|
+
this.#contributedSourcePaneIds.add(paneId);
|
|
69860
|
+
this.#shared.grantRefs.set(paneId, (this.#shared.grantRefs.get(paneId) ?? 0) + 1);
|
|
69861
|
+
}
|
|
69862
|
+
this.#baseHandle = null;
|
|
69863
|
+
this.#baseHandleLease = null;
|
|
69864
|
+
this.#intentHandles.clear();
|
|
69865
|
+
}
|
|
69392
69866
|
openTerminalDelivery(semanticPaneId3, offer, onMessage, deliveryWorkspaceName) {
|
|
69393
69867
|
const address = WorkspaceIdSchemaZ.parse(deliveryWorkspaceName ?? this.session);
|
|
69394
69868
|
this.#assertOpen();
|
|
@@ -74365,6 +74839,19 @@ var init_native_runtime = __esm({
|
|
|
74365
74839
|
if (this.#disposed) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
74366
74840
|
const epoch = this.#inventoryEpoch;
|
|
74367
74841
|
const nativeEpoch = this.#nativeServerEpoch?.() ?? null;
|
|
74842
|
+
const publish = async (value, publicationSignal) => {
|
|
74843
|
+
try {
|
|
74844
|
+
return await this.#publishInventory(value, nativeEpoch, publicationSignal, epoch);
|
|
74845
|
+
} catch (error) {
|
|
74846
|
+
if (this.#disposed || signal?.aborted || this.#inventoryEpoch === epoch) throw error;
|
|
74847
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
74848
|
+
return this.#readInventory(signal, staleRetry + 1);
|
|
74849
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
74850
|
+
"discovery-failed",
|
|
74851
|
+
"overtaken-by-invalidations"
|
|
74852
|
+
);
|
|
74853
|
+
}
|
|
74854
|
+
};
|
|
74368
74855
|
if (signal) {
|
|
74369
74856
|
if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
74370
74857
|
let snapshot3;
|
|
@@ -74390,7 +74877,7 @@ var init_native_runtime = __esm({
|
|
|
74390
74877
|
"overtaken-by-invalidations"
|
|
74391
74878
|
);
|
|
74392
74879
|
}
|
|
74393
|
-
return
|
|
74880
|
+
return publish(snapshot3, signal);
|
|
74394
74881
|
}
|
|
74395
74882
|
if (this.#inventoryRead?.epoch === epoch) return this.#inventoryRead.promise;
|
|
74396
74883
|
const abort = new AbortController();
|
|
@@ -74417,7 +74904,7 @@ var init_native_runtime = __esm({
|
|
|
74417
74904
|
"overtaken-by-invalidations"
|
|
74418
74905
|
);
|
|
74419
74906
|
}
|
|
74420
|
-
return
|
|
74907
|
+
return publish(value, abort.signal);
|
|
74421
74908
|
})().finally(() => {
|
|
74422
74909
|
if (this.#inventoryRead?.promise === promise) this.#inventoryRead = null;
|
|
74423
74910
|
});
|
|
@@ -75978,6 +76465,26 @@ function rawGraphicsState(state) {
|
|
|
75978
76465
|
placements: state.placements.filter((placement) => kept.has(placement.digest))
|
|
75979
76466
|
};
|
|
75980
76467
|
}
|
|
76468
|
+
function newPaneChannel(pane) {
|
|
76469
|
+
return {
|
|
76470
|
+
semanticPaneId: pane,
|
|
76471
|
+
sub: null,
|
|
76472
|
+
delivery: null,
|
|
76473
|
+
deliveryAddress: null,
|
|
76474
|
+
serverSeq: 0,
|
|
76475
|
+
sentPaneFrames: 0,
|
|
76476
|
+
consumedSeq: 0,
|
|
76477
|
+
nextInputSeq: 1,
|
|
76478
|
+
frozenByWire: false,
|
|
76479
|
+
closed: false,
|
|
76480
|
+
batch: null,
|
|
76481
|
+
graphicsAnnounced: false,
|
|
76482
|
+
graphicsQueue: [],
|
|
76483
|
+
graphicsSending: false,
|
|
76484
|
+
graphicsServed: /* @__PURE__ */ new Map(),
|
|
76485
|
+
graphicsState: null
|
|
76486
|
+
};
|
|
76487
|
+
}
|
|
75981
76488
|
function concatBytes(chunks) {
|
|
75982
76489
|
if (chunks.length === 0) return new Uint8Array(0);
|
|
75983
76490
|
if (chunks.length === 1) return chunks[0];
|
|
@@ -76000,7 +76507,7 @@ function chunkBytes(data, maxChunk) {
|
|
|
76000
76507
|
}
|
|
76001
76508
|
return chunks;
|
|
76002
76509
|
}
|
|
76003
|
-
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;
|
|
76510
|
+
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;
|
|
76004
76511
|
var init_pane_stream_websocket = __esm({
|
|
76005
76512
|
"packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts"() {
|
|
76006
76513
|
"use strict";
|
|
@@ -76065,6 +76572,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76065
76572
|
#redemptionTimeoutMs;
|
|
76066
76573
|
#flowBudgets;
|
|
76067
76574
|
#drainTickMs;
|
|
76575
|
+
#openRetryDelaysMs;
|
|
76576
|
+
#ownershipWaitMs;
|
|
76068
76577
|
#maxSocketBufferedBytes;
|
|
76069
76578
|
#maxInputFrames;
|
|
76070
76579
|
#maxInputBytes;
|
|
@@ -76104,6 +76613,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76104
76613
|
this.#flowBudgets = options.flowBudgets ?? DEFAULT_PANE_STREAM_FLOW_BUDGETS;
|
|
76105
76614
|
this.#ledger = new PaneStreamWireLedger(this.#flowBudgets);
|
|
76106
76615
|
this.#drainTickMs = boundedInteger2(options.drainTickMs, 15, 1e3);
|
|
76616
|
+
this.#openRetryDelaysMs = options.openRetryDelaysMs ?? PANE_STREAM_OPEN_RETRY_DELAYS_MS;
|
|
76617
|
+
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
76107
76618
|
this.#maxSocketBufferedBytes = boundedInteger2(
|
|
76108
76619
|
options.maxSocketBufferedBytes,
|
|
76109
76620
|
32 << 20,
|
|
@@ -76428,6 +76939,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76428
76939
|
leaseManager: this.#leaseManager,
|
|
76429
76940
|
ledger: this.#ledger,
|
|
76430
76941
|
drainTickMs: this.#drainTickMs,
|
|
76942
|
+
openRetryDelaysMs: this.#openRetryDelaysMs,
|
|
76943
|
+
ownershipWaitMs: this.#ownershipWaitMs,
|
|
76431
76944
|
maxSocketBufferedBytes: this.#maxSocketBufferedBytes,
|
|
76432
76945
|
maxInputFrames: this.#maxInputFrames,
|
|
76433
76946
|
maxInputBytes: this.#maxInputBytes,
|
|
@@ -76601,6 +77114,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76601
77114
|
socket.off("error", this.#onClose);
|
|
76602
77115
|
}
|
|
76603
77116
|
};
|
|
77117
|
+
PANE_STREAM_TOPOLOGY_SETTLE_MS = 500;
|
|
77118
|
+
PANE_STREAM_OPEN_RETRY_DELAYS_MS = [150, 400];
|
|
77119
|
+
PANE_STREAM_OWNERSHIP_WAIT_MS = 2e3;
|
|
77120
|
+
PANE_STREAM_OWNERSHIP_HELD_FRAMES = 256;
|
|
76604
77121
|
GRAPHICS_MAX_QUEUED_DIGESTS = 256;
|
|
76605
77122
|
GRAPHICS_SEND_WINDOW_BYTES = 2 * 1024 * 1024;
|
|
76606
77123
|
PaneStreamLiveConnection = class {
|
|
@@ -76625,6 +77142,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76625
77142
|
#leaseManager;
|
|
76626
77143
|
#ledger;
|
|
76627
77144
|
#drainTickMs;
|
|
77145
|
+
#openRetryDelaysMs;
|
|
77146
|
+
#ownershipWaitMs;
|
|
76628
77147
|
#maxSocketBufferedBytes;
|
|
76629
77148
|
#maxInputFrames;
|
|
76630
77149
|
#maxInputBytes;
|
|
@@ -76638,6 +77157,13 @@ var init_pane_stream_websocket = __esm({
|
|
|
76638
77157
|
#panes = /* @__PURE__ */ new Map();
|
|
76639
77158
|
#semanticLayouts = /* @__PURE__ */ new Map();
|
|
76640
77159
|
#semanticExpectedPaneIds = null;
|
|
77160
|
+
/** Capability 119 (#723): a changed pane set is announced, not a reason to close. */
|
|
77161
|
+
#topologyInPlace;
|
|
77162
|
+
/** The stream was issued for every pane of its session: new panes join it. */
|
|
77163
|
+
#leasesWholeSession = false;
|
|
77164
|
+
#topologyReconciling = false;
|
|
77165
|
+
#topologyPending = null;
|
|
77166
|
+
#topologyWaiter = null;
|
|
76641
77167
|
#semanticRuntimeSessionId = null;
|
|
76642
77168
|
#semanticWindowLinks = null;
|
|
76643
77169
|
#semanticTopologyEpoch = -1;
|
|
@@ -76728,6 +77254,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76728
77254
|
this.#leaseManager = options.leaseManager;
|
|
76729
77255
|
this.#ledger = options.ledger;
|
|
76730
77256
|
this.#drainTickMs = options.drainTickMs;
|
|
77257
|
+
this.#openRetryDelaysMs = options.openRetryDelaysMs;
|
|
77258
|
+
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
76731
77259
|
this.#maxSocketBufferedBytes = options.maxSocketBufferedBytes;
|
|
76732
77260
|
this.#maxInputFrames = options.maxInputFrames;
|
|
76733
77261
|
this.#maxInputBytes = options.maxInputBytes;
|
|
@@ -76740,26 +77268,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76740
77268
|
this.#diagnosticSharedRawMicros = this.#diagnosticCapabilities.includes("clock-bounds-v1") ? options.diagnosticSharedNowMicros ?? sharedMonotonicMicros : void 0;
|
|
76741
77269
|
this.#diagnosticAfterFrameParse = options.diagnosticAfterFrameParse;
|
|
76742
77270
|
this.#onRetire = options.onRetire;
|
|
76743
|
-
|
|
76744
|
-
|
|
76745
|
-
|
|
76746
|
-
|
|
76747
|
-
delivery: null,
|
|
76748
|
-
deliveryAddress: null,
|
|
76749
|
-
serverSeq: 0,
|
|
76750
|
-
sentPaneFrames: 0,
|
|
76751
|
-
consumedSeq: 0,
|
|
76752
|
-
nextInputSeq: 1,
|
|
76753
|
-
frozenByWire: false,
|
|
76754
|
-
closed: false,
|
|
76755
|
-
batch: null,
|
|
76756
|
-
graphicsAnnounced: false,
|
|
76757
|
-
graphicsQueue: [],
|
|
76758
|
-
graphicsSending: false,
|
|
76759
|
-
graphicsServed: /* @__PURE__ */ new Map(),
|
|
76760
|
-
graphicsState: null
|
|
76761
|
-
});
|
|
76762
|
-
}
|
|
77271
|
+
this.#topologyInPlace = options.descriptor.terminalDelivery?.protocolVersions.some(
|
|
77272
|
+
(version) => version === PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION || version === PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION
|
|
77273
|
+
) === true;
|
|
77274
|
+
for (const pane of options.descriptor.panes) this.#panes.set(pane, newPaneChannel(pane));
|
|
76763
77275
|
}
|
|
76764
77276
|
get clientId() {
|
|
76765
77277
|
return this.#clientId;
|
|
@@ -76781,6 +77293,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
76781
77293
|
...this.#sessionRuntimeBinding && this.#descriptor.terminalDelivery?.protocolVersions.includes(
|
|
76782
77294
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION
|
|
76783
77295
|
) ? { inputBytes: true } : {},
|
|
77296
|
+
...this.#topologyInPlace ? { topologyInPlace: true } : {},
|
|
76784
77297
|
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
76785
77298
|
daemonInstanceId: this.#binding.daemonInstanceId,
|
|
76786
77299
|
requestId: this.#binding.requestId,
|
|
@@ -76790,7 +77303,11 @@ var init_pane_stream_websocket = __esm({
|
|
|
76790
77303
|
...this.#diagnosticCapabilities.length > 0 ? { diagnosticCapabilities: [...this.#diagnosticCapabilities] } : {}
|
|
76791
77304
|
});
|
|
76792
77305
|
this.#recordDiagnosticLifecycle("pane-stream-server-ready");
|
|
76793
|
-
} catch {
|
|
77306
|
+
} catch (error) {
|
|
77307
|
+
this.#closeCause = {
|
|
77308
|
+
cause: "ready-frame-failed",
|
|
77309
|
+
error: (error instanceof Error ? error.message : String(error)).slice(0, 300)
|
|
77310
|
+
};
|
|
76794
77311
|
this.close(1011, "stream-unavailable-describe");
|
|
76795
77312
|
return;
|
|
76796
77313
|
}
|
|
@@ -76824,9 +77341,13 @@ var init_pane_stream_websocket = __esm({
|
|
|
76824
77341
|
clientId: this.#clientId,
|
|
76825
77342
|
// Whether this connection held input when it went: the next stream of
|
|
76826
77343
|
// the same client can only be granted input once that is released.
|
|
76827
|
-
...this.#heldInput === null ? {} : { heldInput: this.#heldInput }
|
|
77344
|
+
...this.#heldInput === null ? {} : { heldInput: this.#heldInput },
|
|
77345
|
+
// Keys not delivered because their pane lifetime had ended (#397).
|
|
77346
|
+
...this.#inputLifetimeEndedDropped > 0 ? { droppedEndedLifetimeInputs: this.#inputLifetimeEndedDropped } : {}
|
|
76828
77347
|
});
|
|
76829
77348
|
this.#closed = true;
|
|
77349
|
+
this.#ownershipHeld.length = 0;
|
|
77350
|
+
this.#ownershipWake?.();
|
|
76830
77351
|
for (const demand of this.#surfaceDemands.values()) demand.close();
|
|
76831
77352
|
this.#surfaceDemands.clear();
|
|
76832
77353
|
this.#surfaceViewer?.close();
|
|
@@ -76886,7 +77407,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76886
77407
|
async #subscribeAll() {
|
|
76887
77408
|
let described;
|
|
76888
77409
|
try {
|
|
76889
|
-
described = await this.#
|
|
77410
|
+
described = await this.#retryOpenStep(
|
|
77411
|
+
"describe-session",
|
|
77412
|
+
() => this.#mirror.describeSession(this.#descriptor.sessionName)
|
|
77413
|
+
);
|
|
76890
77414
|
} catch (error) {
|
|
76891
77415
|
this.#fail("describe-session-failed", error);
|
|
76892
77416
|
return;
|
|
@@ -76940,6 +77464,32 @@ var init_pane_stream_websocket = __esm({
|
|
|
76940
77464
|
}
|
|
76941
77465
|
this.#closeIfAllPanesGone();
|
|
76942
77466
|
}
|
|
77467
|
+
/**
|
|
77468
|
+
* One step of a stream's opening, tried again after a failure (#585): on a
|
|
77469
|
+
* loaded host one slow tmux answer failed the step, the step closed the whole
|
|
77470
|
+
* stream with 1011, and nothing was tried twice. A refusal of authority is a
|
|
77471
|
+
* decision, not a failure, and is never repeated. Each repeat is logged.
|
|
77472
|
+
*/
|
|
77473
|
+
async #retryOpenStep(step, run) {
|
|
77474
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
77475
|
+
try {
|
|
77476
|
+
return await run();
|
|
77477
|
+
} catch (error) {
|
|
77478
|
+
const delayMs = this.#openRetryDelaysMs[attempt];
|
|
77479
|
+
if (delayMs === void 0 || this.#closed || error instanceof SessionRuntimeControllerLeaseError)
|
|
77480
|
+
throw error;
|
|
77481
|
+
logger.info("pane-stream", "stream open step failed; trying again", {
|
|
77482
|
+
session: this.#descriptor.sessionName,
|
|
77483
|
+
clientId: this.#clientId,
|
|
77484
|
+
step,
|
|
77485
|
+
attempt: attempt + 1,
|
|
77486
|
+
error: (error instanceof Error ? error.message : String(error)).slice(0, 300)
|
|
77487
|
+
});
|
|
77488
|
+
await new Promise((resolve47) => setTimeout(resolve47, delayMs));
|
|
77489
|
+
if (this.#closed) throw error;
|
|
77490
|
+
}
|
|
77491
|
+
}
|
|
77492
|
+
}
|
|
76943
77493
|
async #subscribeSemantic(known) {
|
|
76944
77494
|
const binding = this.#sessionRuntimeBinding;
|
|
76945
77495
|
const offer = this.#descriptor.terminalDelivery;
|
|
@@ -77006,32 +77556,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77006
77556
|
channels.sort(
|
|
77007
77557
|
(left, right) => Number(visibleAtOpen.has(right.semanticPaneId)) - Number(visibleAtOpen.has(left.semanticPaneId))
|
|
77008
77558
|
);
|
|
77009
|
-
const openings = channels.map(
|
|
77010
|
-
const pending = [];
|
|
77011
|
-
let ready = false;
|
|
77012
|
-
let negotiated = false;
|
|
77013
|
-
const delivery = await binding.openTerminalDelivery(
|
|
77014
|
-
channel.semanticPaneId,
|
|
77015
|
-
offer,
|
|
77016
|
-
(message) => {
|
|
77017
|
-
if (!ready && !(negotiated && message.type === "terminal.delivery.fault"))
|
|
77018
|
-
pending.push(message);
|
|
77019
|
-
else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
77020
|
-
},
|
|
77021
|
-
this.#descriptor.workspaceName
|
|
77022
|
-
);
|
|
77023
|
-
return {
|
|
77024
|
-
channel,
|
|
77025
|
-
delivery,
|
|
77026
|
-
pending,
|
|
77027
|
-
markNegotiated: () => {
|
|
77028
|
-
negotiated = true;
|
|
77029
|
-
},
|
|
77030
|
-
markReady: () => {
|
|
77031
|
-
ready = true;
|
|
77032
|
-
}
|
|
77033
|
-
};
|
|
77034
|
-
});
|
|
77559
|
+
const openings = channels.map((channel) => this.#openPaneDelivery(binding, offer, channel));
|
|
77035
77560
|
const settled = await Promise.allSettled(openings);
|
|
77036
77561
|
const opened = settled.flatMap(
|
|
77037
77562
|
(result2) => result2.status === "fulfilled" ? [result2.value] : []
|
|
@@ -77049,21 +77574,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77049
77574
|
}
|
|
77050
77575
|
return;
|
|
77051
77576
|
}
|
|
77052
|
-
|
|
77053
|
-
if (!delivery.negotiation.accepted) return true;
|
|
77054
|
-
const negotiated = delivery.negotiation.negotiated;
|
|
77055
|
-
if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
|
|
77056
|
-
let incarnation = null;
|
|
77057
|
-
for (const message of pending) {
|
|
77058
|
-
if (message.type !== "terminal.delivery" && message.type !== "terminal.projection")
|
|
77059
|
-
continue;
|
|
77060
|
-
if (message.workspaceName !== this.#descriptor.workspaceName || message.semanticPaneId !== channel.semanticPaneId || message.generation !== negotiated.generation || message.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message.incarnation !== incarnation)
|
|
77061
|
-
return true;
|
|
77062
|
-
incarnation = message.incarnation;
|
|
77063
|
-
}
|
|
77064
|
-
return false;
|
|
77065
|
-
});
|
|
77066
|
-
if (deliveryIdentityChanged) {
|
|
77577
|
+
if (opened.some((entry) => this.#deliveryIdentityChanged(entry))) {
|
|
77067
77578
|
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => void 0)));
|
|
77068
77579
|
this.#failTopologyChanged();
|
|
77069
77580
|
return;
|
|
@@ -77082,6 +77593,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77082
77593
|
}
|
|
77083
77594
|
this.#recordDiagnosticLifecycle("pane-stream-layout-validated");
|
|
77084
77595
|
this.#semanticExpectedPaneIds = expectedPaneIds;
|
|
77596
|
+
this.#leasesWholeSession = expectedPaneIds.every((pane) => this.#panes.has(pane));
|
|
77085
77597
|
this.#semanticRuntimeSessionId = authority2.runtimeSessionId;
|
|
77086
77598
|
this.#semanticWindowLinks = authority2.windowLinks;
|
|
77087
77599
|
this.#semanticTopologyEpoch = authority2.topologyEpoch;
|
|
@@ -77104,6 +77616,54 @@ var init_pane_stream_websocket = __esm({
|
|
|
77104
77616
|
opened.sort(
|
|
77105
77617
|
(left, right) => Number(visibleAtDelivery.has(right.channel.semanticPaneId)) - Number(visibleAtDelivery.has(left.channel.semanticPaneId))
|
|
77106
77618
|
);
|
|
77619
|
+
await this.#publishOpenedDeliveries(opened);
|
|
77620
|
+
this.#closeIfAllPanesGone();
|
|
77621
|
+
}
|
|
77622
|
+
/** Open one pane's delivery; its messages wait until the pane is announced. */
|
|
77623
|
+
async #openPaneDelivery(binding, offer, channel) {
|
|
77624
|
+
const pending = [];
|
|
77625
|
+
let ready = false;
|
|
77626
|
+
let negotiated = false;
|
|
77627
|
+
const delivery = await this.#retryOpenStep("pane-delivery-open", () => {
|
|
77628
|
+
pending.length = 0;
|
|
77629
|
+
return binding.openTerminalDelivery(
|
|
77630
|
+
channel.semanticPaneId,
|
|
77631
|
+
offer,
|
|
77632
|
+
(message) => {
|
|
77633
|
+
if (!ready && !(negotiated && message.type === "terminal.delivery.fault"))
|
|
77634
|
+
pending.push(message);
|
|
77635
|
+
else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
77636
|
+
},
|
|
77637
|
+
this.#descriptor.workspaceName
|
|
77638
|
+
);
|
|
77639
|
+
});
|
|
77640
|
+
return {
|
|
77641
|
+
channel,
|
|
77642
|
+
delivery,
|
|
77643
|
+
pending,
|
|
77644
|
+
markNegotiated: () => {
|
|
77645
|
+
negotiated = true;
|
|
77646
|
+
},
|
|
77647
|
+
markReady: () => {
|
|
77648
|
+
ready = true;
|
|
77649
|
+
}
|
|
77650
|
+
};
|
|
77651
|
+
}
|
|
77652
|
+
#deliveryIdentityChanged({ channel, delivery, pending }) {
|
|
77653
|
+
if (!delivery.negotiation.accepted) return true;
|
|
77654
|
+
const negotiated = delivery.negotiation.negotiated;
|
|
77655
|
+
if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
|
|
77656
|
+
let incarnation = null;
|
|
77657
|
+
for (const message of pending) {
|
|
77658
|
+
if (message.type !== "terminal.delivery" && message.type !== "terminal.projection") continue;
|
|
77659
|
+
if (message.workspaceName !== this.#descriptor.workspaceName || message.semanticPaneId !== channel.semanticPaneId || message.generation !== negotiated.generation || message.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message.incarnation !== incarnation)
|
|
77660
|
+
return true;
|
|
77661
|
+
incarnation = message.incarnation;
|
|
77662
|
+
}
|
|
77663
|
+
return false;
|
|
77664
|
+
}
|
|
77665
|
+
/** Announce validated deliveries, then replay what each collected meanwhile. */
|
|
77666
|
+
async #publishOpenedDeliveries(opened) {
|
|
77107
77667
|
for (const { channel, delivery, markNegotiated } of opened) {
|
|
77108
77668
|
if (this.#closed || channel.closed) {
|
|
77109
77669
|
await delivery.close();
|
|
@@ -77136,9 +77696,37 @@ var init_pane_stream_websocket = __esm({
|
|
|
77136
77696
|
markReady();
|
|
77137
77697
|
this.#startGraphics(channel);
|
|
77138
77698
|
}
|
|
77139
|
-
this.#closeIfAllPanesGone();
|
|
77140
77699
|
}
|
|
77700
|
+
/**
|
|
77701
|
+
* A tombstone ends a pane's delivery for good: the hub drops the pane and
|
|
77702
|
+
* sends nothing more. Without capability 119 the pane's removal closes the
|
|
77703
|
+
* stream anyway. With it, the removal arrives as a `topology` frame within
|
|
77704
|
+
* moments; if none comes, the pane is still in the session and would stay
|
|
77705
|
+
* blank for ever, so the stream closes as it would without the capability
|
|
77706
|
+
* and the client takes a new one.
|
|
77707
|
+
*/
|
|
77708
|
+
#watchTombstone(pane) {
|
|
77709
|
+
const channel = this.#panes.get(pane);
|
|
77710
|
+
if (!this.#topologyInPlace || !channel || channel.closed) return;
|
|
77711
|
+
const timer = setTimeout(() => {
|
|
77712
|
+
if (this.#closed || channel.retiredInPlace || this.#panes.get(pane) !== channel) return;
|
|
77713
|
+
if (this.#topologyReconciling) {
|
|
77714
|
+
this.#tombstonesAfterChange.add(channel);
|
|
77715
|
+
return;
|
|
77716
|
+
}
|
|
77717
|
+
this.#failTopologyChanged("a pane that stays lost its source");
|
|
77718
|
+
}, PANE_STREAM_TOPOLOGY_SETTLE_MS);
|
|
77719
|
+
timer.unref?.();
|
|
77720
|
+
}
|
|
77721
|
+
/**
|
|
77722
|
+
* Tombstoned channels whose guard came due while a change was being applied.
|
|
77723
|
+
* The channel, not the pane id: a pane that left and came back within the
|
|
77724
|
+
* change has a fresh channel, which this tombstone is not about.
|
|
77725
|
+
*/
|
|
77726
|
+
#tombstonesAfterChange = /* @__PURE__ */ new Set();
|
|
77141
77727
|
async #sendTerminalDelivery(pane, message) {
|
|
77728
|
+
if ((message.type === "terminal.delivery" || message.type === "terminal.projection") && message.frame === "tombstone")
|
|
77729
|
+
this.#watchTombstone(pane);
|
|
77142
77730
|
if (message.type === "terminal.projection") {
|
|
77143
77731
|
const channel = this.#panes.get(pane);
|
|
77144
77732
|
if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message.incarnation;
|
|
@@ -77267,7 +77855,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77267
77855
|
if (!graphics) return;
|
|
77268
77856
|
this.#observeSurfaceDemand([channel.semanticPaneId]);
|
|
77269
77857
|
const zlib = this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
77270
|
-
(version) => version === TERMINAL_GRAPHICS_ZLIB_CAPABILITY_VERSION || version === PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION || version === PANE_STREAM_READER_CAPABILITY_VERSION
|
|
77858
|
+
(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
|
|
77271
77859
|
) === true;
|
|
77272
77860
|
channel.graphicsZlib = zlib;
|
|
77273
77861
|
channel.graphicsLocal = !!this.#localImages && this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
@@ -77623,11 +78211,20 @@ var init_pane_stream_websocket = __esm({
|
|
|
77623
78211
|
}
|
|
77624
78212
|
#onLayoutAuthority(snapshot3) {
|
|
77625
78213
|
if (this.#closed || !this.#semanticExpectedPaneIds || !this.#semanticRuntimeSessionId) return;
|
|
77626
|
-
if (
|
|
78214
|
+
if (this.#topologyReconciling) {
|
|
78215
|
+
this.#topologyPending = snapshot3;
|
|
78216
|
+
this.#topologyWaiter?.();
|
|
78217
|
+
return;
|
|
78218
|
+
}
|
|
78219
|
+
if (!this.#layoutAuthorityAdmissible(snapshot3)) {
|
|
77627
78220
|
this.#failTopologyChanged();
|
|
77628
78221
|
return;
|
|
77629
78222
|
}
|
|
77630
78223
|
const frames = this.#validateInitialLayout(snapshot3.layouts, this.#semanticExpectedPaneIds);
|
|
78224
|
+
if (!frames && this.#topologyInPlace) {
|
|
78225
|
+
void this.#reconcileTopology(snapshot3);
|
|
78226
|
+
return;
|
|
78227
|
+
}
|
|
77631
78228
|
if (!frames || !PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
|
|
77632
78229
|
type: "layout-snapshot",
|
|
77633
78230
|
topologyEpoch: snapshot3.topologyEpoch,
|
|
@@ -77637,10 +78234,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77637
78234
|
this.#failTopologyChanged();
|
|
77638
78235
|
return;
|
|
77639
78236
|
}
|
|
77640
|
-
|
|
77641
|
-
if (!previousLinks || snapshot3.windowLinks.liveSessionId !== previousLinks.liveSessionId || snapshot3.windowLinks.linkRevision < previousLinks.linkRevision || snapshot3.windowLinks.linkRevision === previousLinks.linkRevision && JSON.stringify(
|
|
77642
|
-
[...snapshot3.windowLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))
|
|
77643
|
-
) !== JSON.stringify([...previousLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId)))) {
|
|
78237
|
+
if (!this.#windowLinksAdmissible(snapshot3)) {
|
|
77644
78238
|
this.#failTopologyChanged();
|
|
77645
78239
|
return;
|
|
77646
78240
|
}
|
|
@@ -77656,6 +78250,196 @@ var init_pane_stream_websocket = __esm({
|
|
|
77656
78250
|
windowLinks: snapshot3.windowLinks
|
|
77657
78251
|
});
|
|
77658
78252
|
}
|
|
78253
|
+
/** The same session and runtime, a newer epoch, a layout a stream can carry. */
|
|
78254
|
+
#layoutAuthorityAdmissible(snapshot3) {
|
|
78255
|
+
return snapshot3.session === this.#descriptor.sessionName && snapshot3.runtimeSessionId === this.#semanticRuntimeSessionId && snapshot3.topologyEpoch > this.#semanticTopologyEpoch && snapshot3.layouts.length <= PANE_STREAM_MAX_PANES;
|
|
78256
|
+
}
|
|
78257
|
+
#windowLinksAdmissible(snapshot3) {
|
|
78258
|
+
const previousLinks = this.#semanticWindowLinks;
|
|
78259
|
+
return !(!previousLinks || snapshot3.windowLinks.liveSessionId !== previousLinks.liveSessionId || snapshot3.windowLinks.linkRevision < previousLinks.linkRevision || snapshot3.windowLinks.linkRevision === previousLinks.linkRevision && JSON.stringify(
|
|
78260
|
+
[...snapshot3.windowLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))
|
|
78261
|
+
) !== JSON.stringify([...previousLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))));
|
|
78262
|
+
}
|
|
78263
|
+
/**
|
|
78264
|
+
* Capability 119 (#723). Follow a changed pane set without closing: one
|
|
78265
|
+
* change at a time, newest state only. Every doubt ends where a stream
|
|
78266
|
+
* without the capability ends, in `#failTopologyChanged()`.
|
|
78267
|
+
*/
|
|
78268
|
+
async #reconcileTopology(first) {
|
|
78269
|
+
this.#topologyReconciling = true;
|
|
78270
|
+
let snapshot3 = first;
|
|
78271
|
+
try {
|
|
78272
|
+
for (; ; ) {
|
|
78273
|
+
this.#topologyPending = null;
|
|
78274
|
+
const outcome = await this.#applyTopology(snapshot3);
|
|
78275
|
+
if (this.#closed) return;
|
|
78276
|
+
if (outcome === "failed") return this.#failTopologyChanged(this.#topologyFailure);
|
|
78277
|
+
let next = this.#topologyPending;
|
|
78278
|
+
if (outcome === "stale" && !next) {
|
|
78279
|
+
next = await this.#nextTopologySnapshot();
|
|
78280
|
+
if (this.#closed) return;
|
|
78281
|
+
if (!next) return this.#failTopologyChanged();
|
|
78282
|
+
}
|
|
78283
|
+
if (!next) return;
|
|
78284
|
+
if (!this.#layoutAuthorityAdmissible(next)) return this.#failTopologyChanged();
|
|
78285
|
+
snapshot3 = next;
|
|
78286
|
+
}
|
|
78287
|
+
} finally {
|
|
78288
|
+
this.#topologyReconciling = false;
|
|
78289
|
+
this.#topologyPending = null;
|
|
78290
|
+
const tombstoned = [...this.#tombstonesAfterChange];
|
|
78291
|
+
this.#tombstonesAfterChange.clear();
|
|
78292
|
+
for (const channel of tombstoned)
|
|
78293
|
+
if (this.#panes.get(channel.semanticPaneId) === channel)
|
|
78294
|
+
this.#watchTombstone(channel.semanticPaneId);
|
|
78295
|
+
}
|
|
78296
|
+
}
|
|
78297
|
+
#nextTopologySnapshot() {
|
|
78298
|
+
if (this.#topologyPending) return Promise.resolve(this.#topologyPending);
|
|
78299
|
+
return new Promise((resolve47) => {
|
|
78300
|
+
const finish = () => {
|
|
78301
|
+
clearTimeout(timer);
|
|
78302
|
+
this.#topologyWaiter = null;
|
|
78303
|
+
resolve47(this.#topologyPending);
|
|
78304
|
+
};
|
|
78305
|
+
const timer = setTimeout(finish, PANE_STREAM_TOPOLOGY_SETTLE_MS);
|
|
78306
|
+
timer.unref?.();
|
|
78307
|
+
this.#topologyWaiter = finish;
|
|
78308
|
+
});
|
|
78309
|
+
}
|
|
78310
|
+
/**
|
|
78311
|
+
* "applied": the client was told and the stream goes on. "stale": this
|
|
78312
|
+
* layout does not fit the session's inventory as read now; a newer layout
|
|
78313
|
+
* decides. "failed": close.
|
|
78314
|
+
*/
|
|
78315
|
+
async #applyTopology(snapshot3) {
|
|
78316
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78317
|
+
const offer = this.#descriptor.terminalDelivery;
|
|
78318
|
+
if (!binding || !offer || !this.#semanticExpectedPaneIds || !this.#windowLinksAdmissible(snapshot3))
|
|
78319
|
+
return this.#topologyFailed("not a semantic stream, or its window links changed");
|
|
78320
|
+
let described;
|
|
78321
|
+
let inventoryIsThisSession = false;
|
|
78322
|
+
try {
|
|
78323
|
+
if (this.#mirror.describeSessionAuthority) {
|
|
78324
|
+
const authority2 = await this.#mirror.describeSessionAuthority(this.#descriptor.sessionName);
|
|
78325
|
+
if (authority2.runtimeSessionId !== this.#semanticRuntimeSessionId)
|
|
78326
|
+
return this.#topologyFailed("inventory is of another runtime session");
|
|
78327
|
+
described = authority2.description;
|
|
78328
|
+
inventoryIsThisSession = true;
|
|
78329
|
+
} else {
|
|
78330
|
+
described = await this.#mirror.describeSession(this.#descriptor.sessionName);
|
|
78331
|
+
}
|
|
78332
|
+
} catch (error) {
|
|
78333
|
+
return this.#topologyFailed("session inventory unavailable", error);
|
|
78334
|
+
}
|
|
78335
|
+
if (this.#closed) return this.#topologyFailed("closed");
|
|
78336
|
+
const next = [...new Set(described.panes.map((pane) => pane.semanticPaneId))].sort();
|
|
78337
|
+
if (next.length === 0) return this.#topologyFailed("session has no panes");
|
|
78338
|
+
const frames = this.#validateInitialLayout(snapshot3.layouts, next);
|
|
78339
|
+
if (!frames) return "stale";
|
|
78340
|
+
if (!PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
|
|
78341
|
+
type: "layout-snapshot",
|
|
78342
|
+
topologyEpoch: snapshot3.topologyEpoch,
|
|
78343
|
+
layouts: frames,
|
|
78344
|
+
windowLinks: snapshot3.windowLinks
|
|
78345
|
+
}).success)
|
|
78346
|
+
return this.#topologyFailed("layout snapshot invalid");
|
|
78347
|
+
const live = [...this.#panes.values()].filter((channel) => !channel.closed);
|
|
78348
|
+
const removed = live.filter((channel) => !next.includes(channel.semanticPaneId));
|
|
78349
|
+
const liveIds = new Set(live.map((channel) => channel.semanticPaneId));
|
|
78350
|
+
const added = this.#leasesWholeSession ? next.filter((pane) => !liveIds.has(pane)) : [];
|
|
78351
|
+
if (added.length > 0 && !inventoryIsThisSession)
|
|
78352
|
+
return this.#topologyFailed("inventory cannot prove the runtime session");
|
|
78353
|
+
const remaining = live.length - removed.length + added.length;
|
|
78354
|
+
if (remaining === 0 || remaining > PANE_STREAM_MAX_PANES)
|
|
78355
|
+
return this.#topologyFailed("pane count outside the stream limit");
|
|
78356
|
+
if (added.length > 0) {
|
|
78357
|
+
try {
|
|
78358
|
+
if (!binding.amendPaneGrant)
|
|
78359
|
+
return this.#topologyFailed("transport cannot amend its grant");
|
|
78360
|
+
binding.amendPaneGrant({ added, removed: [] });
|
|
78361
|
+
} catch (error) {
|
|
78362
|
+
return this.#topologyFailed("pane grant refused", error);
|
|
78363
|
+
}
|
|
78364
|
+
}
|
|
78365
|
+
const channels = added.map(newPaneChannel);
|
|
78366
|
+
const settled = await Promise.allSettled(
|
|
78367
|
+
channels.map((channel) => this.#openPaneDelivery(binding, offer, channel))
|
|
78368
|
+
);
|
|
78369
|
+
const opened = settled.flatMap(
|
|
78370
|
+
(result2) => result2.status === "fulfilled" ? [result2.value] : []
|
|
78371
|
+
);
|
|
78372
|
+
if (this.#closed || opened.length !== channels.length || opened.some((entry) => this.#deliveryIdentityChanged(entry))) {
|
|
78373
|
+
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => void 0)));
|
|
78374
|
+
if (added.length > 0) {
|
|
78375
|
+
try {
|
|
78376
|
+
binding.amendPaneGrant?.({ added: [], removed: added });
|
|
78377
|
+
} catch {
|
|
78378
|
+
}
|
|
78379
|
+
}
|
|
78380
|
+
const rejected = settled.find((result2) => result2.status === "rejected");
|
|
78381
|
+
return this.#topologyFailed(
|
|
78382
|
+
this.#closed ? "closed while opening" : rejected ? "delivery open rejected" : opened.some((entry) => !entry.delivery.negotiation.accepted) ? "delivery negotiation refused" : "delivery identity changed",
|
|
78383
|
+
rejected?.status === "rejected" ? rejected.reason : void 0
|
|
78384
|
+
);
|
|
78385
|
+
}
|
|
78386
|
+
if (removed.length > 0) {
|
|
78387
|
+
try {
|
|
78388
|
+
binding.amendPaneGrant?.({
|
|
78389
|
+
added: [],
|
|
78390
|
+
removed: removed.map((channel) => channel.semanticPaneId)
|
|
78391
|
+
});
|
|
78392
|
+
} catch {
|
|
78393
|
+
}
|
|
78394
|
+
}
|
|
78395
|
+
for (const channel of removed) this.#retirePaneInPlace(channel);
|
|
78396
|
+
for (const channel of channels) this.#panes.set(channel.semanticPaneId, channel);
|
|
78397
|
+
this.#semanticExpectedPaneIds = next;
|
|
78398
|
+
this.#semanticWindowLinks = snapshot3.windowLinks;
|
|
78399
|
+
this.#semanticTopologyEpoch = snapshot3.topologyEpoch;
|
|
78400
|
+
this.#semanticLayouts.clear();
|
|
78401
|
+
for (const event of snapshot3.layouts)
|
|
78402
|
+
this.#semanticLayouts.set(event.semanticWindowId, event);
|
|
78403
|
+
this.#sendFrame(null, {
|
|
78404
|
+
type: "topology",
|
|
78405
|
+
topologyEpoch: snapshot3.topologyEpoch,
|
|
78406
|
+
panes: [...this.#panes.values()].filter((channel) => !channel.closed).map((channel) => channel.semanticPaneId),
|
|
78407
|
+
removed: removed.map((channel) => channel.semanticPaneId),
|
|
78408
|
+
added
|
|
78409
|
+
});
|
|
78410
|
+
this.#sendFrame(null, {
|
|
78411
|
+
type: "layout-snapshot",
|
|
78412
|
+
topologyEpoch: snapshot3.topologyEpoch,
|
|
78413
|
+
layouts: frames,
|
|
78414
|
+
windowLinks: snapshot3.windowLinks
|
|
78415
|
+
});
|
|
78416
|
+
await this.#publishOpenedDeliveries(opened);
|
|
78417
|
+
return "applied";
|
|
78418
|
+
}
|
|
78419
|
+
#topologyFailure = "";
|
|
78420
|
+
#topologyFailed(why, error) {
|
|
78421
|
+
this.#topologyFailure = error === void 0 ? why : `${why}: ${String(error).slice(0, 200)}`;
|
|
78422
|
+
return "failed";
|
|
78423
|
+
}
|
|
78424
|
+
/** A pane that left the session: its delivery ends, the stream does not. */
|
|
78425
|
+
#retirePaneInPlace(channel) {
|
|
78426
|
+
const sub = channel.sub;
|
|
78427
|
+
const delivery = channel.delivery;
|
|
78428
|
+
channel.sub = null;
|
|
78429
|
+
channel.delivery = null;
|
|
78430
|
+
channel.closed = true;
|
|
78431
|
+
channel.retiredInPlace = true;
|
|
78432
|
+
channel.deliveryAddress = null;
|
|
78433
|
+
channel.batch = null;
|
|
78434
|
+
channel.graphicsQueue = [];
|
|
78435
|
+
channel.graphicsServed = /* @__PURE__ */ new Map();
|
|
78436
|
+
channel.graphicsState = null;
|
|
78437
|
+
this.#surfaceDemands.get(channel.semanticPaneId)?.close();
|
|
78438
|
+
this.#surfaceDemands.delete(channel.semanticPaneId);
|
|
78439
|
+
if (sub) void sub.close().catch(() => void 0);
|
|
78440
|
+
if (delivery) void delivery.close().catch(() => void 0);
|
|
78441
|
+
this.#ledger.forgetPane(this.#clientId, channel.semanticPaneId);
|
|
78442
|
+
}
|
|
77659
78443
|
#onLayout(event) {
|
|
77660
78444
|
if (this.#closed) return;
|
|
77661
78445
|
const frame = this.#layoutFrame(event);
|
|
@@ -77666,7 +78450,9 @@ var init_pane_stream_websocket = __esm({
|
|
|
77666
78450
|
this.#sendFrame(null, frame);
|
|
77667
78451
|
}
|
|
77668
78452
|
#offers(version) {
|
|
77669
|
-
|
|
78453
|
+
const offered = this.#descriptor.terminalDelivery?.protocolVersions;
|
|
78454
|
+
if (!offered) return false;
|
|
78455
|
+
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);
|
|
77670
78456
|
}
|
|
77671
78457
|
#layoutFrame(event) {
|
|
77672
78458
|
const frame = {
|
|
@@ -77719,8 +78505,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
77719
78505
|
return null;
|
|
77720
78506
|
return frames;
|
|
77721
78507
|
}
|
|
77722
|
-
|
|
78508
|
+
/** `inPlaceFailure`: why a capability-119 stream could not follow the change. */
|
|
78509
|
+
#failTopologyChanged(inPlaceFailure) {
|
|
77723
78510
|
if (this.#closed) return;
|
|
78511
|
+
if (inPlaceFailure) this.#closeCause = { cause: `topology-in-place: ${inPlaceFailure}` };
|
|
77724
78512
|
this.#sendFrame(null, {
|
|
77725
78513
|
type: "error",
|
|
77726
78514
|
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
@@ -77891,17 +78679,23 @@ var init_pane_stream_websocket = __esm({
|
|
|
77891
78679
|
if (frame.type === "presence") {
|
|
77892
78680
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77893
78681
|
this.#usesExplicitAuthority = true;
|
|
77894
|
-
|
|
77895
|
-
|
|
77896
|
-
|
|
78682
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78683
|
+
if (!binding?.updatePresence) return this.#failProtocol("protocol-error");
|
|
78684
|
+
this.#afterHeldFrames(() => {
|
|
78685
|
+
const snapshot3 = binding.updatePresence(frame.state);
|
|
78686
|
+
if (!binding.onAuthoritySnapshot) this.#sendAuthoritySnapshot(snapshot3);
|
|
78687
|
+
});
|
|
77897
78688
|
return;
|
|
77898
78689
|
}
|
|
77899
78690
|
if (frame.type === "activity") {
|
|
77900
78691
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77901
78692
|
this.#usesExplicitAuthority = true;
|
|
77902
|
-
|
|
77903
|
-
|
|
77904
|
-
|
|
78693
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78694
|
+
if (!binding?.noteActivity) return this.#failProtocol("protocol-error");
|
|
78695
|
+
this.#afterHeldFrames(() => {
|
|
78696
|
+
const snapshot3 = binding.noteActivity(frame.activity);
|
|
78697
|
+
if (!binding.onAuthoritySnapshot) this.#sendAuthoritySnapshot(snapshot3);
|
|
78698
|
+
});
|
|
77905
78699
|
return;
|
|
77906
78700
|
}
|
|
77907
78701
|
if (frame.type === "authority-request") {
|
|
@@ -77909,38 +78703,45 @@ var init_pane_stream_websocket = __esm({
|
|
|
77909
78703
|
this.#usesExplicitAuthority = true;
|
|
77910
78704
|
if (!this.#sessionRuntimeBinding?.requestAuthority || !this.#sessionRuntimeBinding.authoritySnapshot)
|
|
77911
78705
|
return this.#failProtocol("protocol-error");
|
|
77912
|
-
|
|
77913
|
-
|
|
77914
|
-
lease =
|
|
77915
|
-
|
|
77916
|
-
|
|
77917
|
-
|
|
77918
|
-
|
|
77919
|
-
|
|
77920
|
-
|
|
77921
|
-
|
|
77922
|
-
|
|
77923
|
-
|
|
77924
|
-
|
|
77925
|
-
|
|
77926
|
-
|
|
77927
|
-
|
|
78706
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78707
|
+
const request3 = () => {
|
|
78708
|
+
let lease = null;
|
|
78709
|
+
try {
|
|
78710
|
+
lease = binding.requestAuthority(frame.authority);
|
|
78711
|
+
} catch (error) {
|
|
78712
|
+
if (this.#holdForWindowOwnership(error, request3)) return;
|
|
78713
|
+
if (!(error instanceof SessionRuntimeControllerLeaseError) || error.code !== "controller-conflict")
|
|
78714
|
+
return this.#failProtocol("input-rejected");
|
|
78715
|
+
}
|
|
78716
|
+
if (lease) this.#requestedAuthorities.add(frame.authority);
|
|
78717
|
+
this.#sendFrame(null, {
|
|
78718
|
+
type: "authority-receipt",
|
|
78719
|
+
requestId: frame.requestId,
|
|
78720
|
+
authority: frame.authority,
|
|
78721
|
+
status: lease ? "granted" : "rejected",
|
|
78722
|
+
lease,
|
|
78723
|
+
snapshot: binding.authoritySnapshot()
|
|
78724
|
+
});
|
|
78725
|
+
};
|
|
78726
|
+
this.#afterWindowOwnership(request3);
|
|
77928
78727
|
return;
|
|
77929
78728
|
}
|
|
77930
78729
|
if (frame.type === "authority-release") {
|
|
77931
78730
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77932
78731
|
this.#usesExplicitAuthority = true;
|
|
77933
|
-
this.#
|
|
77934
|
-
if (!
|
|
77935
|
-
|
|
77936
|
-
|
|
77937
|
-
|
|
77938
|
-
|
|
77939
|
-
|
|
77940
|
-
|
|
77941
|
-
|
|
77942
|
-
|
|
77943
|
-
|
|
78732
|
+
const binding = this.#sessionRuntimeBinding;
|
|
78733
|
+
if (!binding?.releaseAuthority) return this.#failProtocol("protocol-error");
|
|
78734
|
+
this.#afterHeldFrames(() => {
|
|
78735
|
+
this.#requestedAuthorities.delete(frame.authority);
|
|
78736
|
+
const snapshot3 = binding.releaseAuthority(frame.authority);
|
|
78737
|
+
this.#sendFrame(null, {
|
|
78738
|
+
type: "authority-receipt",
|
|
78739
|
+
requestId: frame.requestId,
|
|
78740
|
+
authority: frame.authority,
|
|
78741
|
+
status: "released",
|
|
78742
|
+
lease: null,
|
|
78743
|
+
snapshot: snapshot3
|
|
78744
|
+
});
|
|
77944
78745
|
});
|
|
77945
78746
|
return;
|
|
77946
78747
|
}
|
|
@@ -77983,7 +78784,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77983
78784
|
return;
|
|
77984
78785
|
}
|
|
77985
78786
|
if (frame.type === "semantic-intent") {
|
|
77986
|
-
this.#acceptSemanticIntent(frame.operationId, frame.intent);
|
|
78787
|
+
this.#afterHeldFrames(() => this.#acceptSemanticIntent(frame.operationId, frame.intent));
|
|
77987
78788
|
return;
|
|
77988
78789
|
}
|
|
77989
78790
|
if (frame.type === "terminal-surface-watch") {
|
|
@@ -78115,38 +78916,42 @@ var init_pane_stream_websocket = __esm({
|
|
|
78115
78916
|
}
|
|
78116
78917
|
if (!this.#prepareInputAuthority(true)) return;
|
|
78117
78918
|
this.#nextViewportSeq += 1;
|
|
78118
|
-
|
|
78119
|
-
|
|
78120
|
-
|
|
78121
|
-
|
|
78122
|
-
|
|
78123
|
-
|
|
78124
|
-
|
|
78125
|
-
|
|
78126
|
-
|
|
78127
|
-
|
|
78128
|
-
|
|
78129
|
-
type: "viewport-ack",
|
|
78130
|
-
seq: frame.seq,
|
|
78131
|
-
cols: frame.cols,
|
|
78132
|
-
rows: frame.rows,
|
|
78133
|
-
outcome: "ok",
|
|
78134
|
-
authorityLease: frame.authorityLease
|
|
78135
|
-
});
|
|
78136
|
-
} catch (error) {
|
|
78137
|
-
if (error instanceof SessionRuntimeControllerLeaseError && (error.code === "invalid-client-capability" || error.code === "stale-controller-lease")) {
|
|
78919
|
+
const fit = () => {
|
|
78920
|
+
try {
|
|
78921
|
+
if (frame.semanticWindowId === void 0)
|
|
78922
|
+
this.#sessionRuntimeBinding.fitViewport(frame.authorityLease, frame.cols, frame.rows);
|
|
78923
|
+
else
|
|
78924
|
+
this.#sessionRuntimeBinding.fitViewport(
|
|
78925
|
+
frame.authorityLease,
|
|
78926
|
+
frame.cols,
|
|
78927
|
+
frame.rows,
|
|
78928
|
+
frame.semanticWindowId
|
|
78929
|
+
);
|
|
78138
78930
|
this.#sendFrame(null, {
|
|
78139
78931
|
type: "viewport-ack",
|
|
78140
78932
|
seq: frame.seq,
|
|
78141
78933
|
cols: frame.cols,
|
|
78142
78934
|
rows: frame.rows,
|
|
78143
|
-
outcome: "
|
|
78935
|
+
outcome: "ok",
|
|
78144
78936
|
authorityLease: frame.authorityLease
|
|
78145
78937
|
});
|
|
78146
|
-
|
|
78938
|
+
} catch (error) {
|
|
78939
|
+
if (error instanceof SessionRuntimeControllerLeaseError && (error.code === "invalid-client-capability" || error.code === "stale-controller-lease")) {
|
|
78940
|
+
this.#sendFrame(null, {
|
|
78941
|
+
type: "viewport-ack",
|
|
78942
|
+
seq: frame.seq,
|
|
78943
|
+
cols: frame.cols,
|
|
78944
|
+
rows: frame.rows,
|
|
78945
|
+
outcome: "geometry-authority-conflict",
|
|
78946
|
+
authorityLease: frame.authorityLease
|
|
78947
|
+
});
|
|
78948
|
+
return;
|
|
78949
|
+
}
|
|
78950
|
+
if (this.#holdForWindowOwnership(error, fit)) return;
|
|
78951
|
+
this.#failProtocol("input-rejected");
|
|
78147
78952
|
}
|
|
78148
|
-
|
|
78149
|
-
|
|
78953
|
+
};
|
|
78954
|
+
this.#afterWindowOwnership(fit);
|
|
78150
78955
|
return;
|
|
78151
78956
|
}
|
|
78152
78957
|
this.#acceptInput(
|
|
@@ -78209,6 +79014,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78209
79014
|
}
|
|
78210
79015
|
#deliveryChannel(address) {
|
|
78211
79016
|
const channel = this.#panes.get(address.semanticPaneId);
|
|
79017
|
+
if (channel?.retiredInPlace) return null;
|
|
78212
79018
|
const expected = channel?.deliveryAddress;
|
|
78213
79019
|
if (!channel?.delivery || !expected || expected.workspaceName !== address.workspaceName || expected.generation !== address.generation || expected.deliveryNonce !== address.deliveryNonce || expected.incarnation === null) {
|
|
78214
79020
|
this.#failProtocol("protocol-error");
|
|
@@ -78245,6 +79051,12 @@ var init_pane_stream_websocket = __esm({
|
|
|
78245
79051
|
"pane_not_active",
|
|
78246
79052
|
"mutation_unverified"
|
|
78247
79053
|
].includes(rawCode) ? rawCode : "stream-unavailable";
|
|
79054
|
+
logger.info("pane-stream", "intent rejected", {
|
|
79055
|
+
session: this.#descriptor.sessionName,
|
|
79056
|
+
clientId: this.#clientId,
|
|
79057
|
+
verb: intent.verb,
|
|
79058
|
+
code: code2
|
|
79059
|
+
});
|
|
78248
79060
|
this.#sendFrame(null, {
|
|
78249
79061
|
type: "semantic-intent-ack",
|
|
78250
79062
|
operationId,
|
|
@@ -78258,6 +79070,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78258
79070
|
}
|
|
78259
79071
|
#acceptConsumed(pane, seq) {
|
|
78260
79072
|
const channel = this.#panes.get(pane);
|
|
79073
|
+
if (channel?.retiredInPlace) return;
|
|
78261
79074
|
if (!this.#deliveryAcks || !channel || seq <= channel.consumedSeq || seq > channel.sentPaneFrames) {
|
|
78262
79075
|
this.#failProtocol("protocol-error");
|
|
78263
79076
|
return;
|
|
@@ -78285,6 +79098,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78285
79098
|
return;
|
|
78286
79099
|
}
|
|
78287
79100
|
const channel = this.#panes.get(pane);
|
|
79101
|
+
if (channel?.retiredInPlace) return;
|
|
78288
79102
|
const semanticDelivery = this.#descriptor.terminalDelivery !== null;
|
|
78289
79103
|
if (!channel || channel.closed || (semanticDelivery ? !channel.delivery : !channel.sub) || seq !== channel.nextInputSeq) {
|
|
78290
79104
|
this.#failProtocol("input-rejected");
|
|
@@ -78347,85 +79161,197 @@ var init_pane_stream_websocket = __esm({
|
|
|
78347
79161
|
this.#inputWindowFrames += 1;
|
|
78348
79162
|
this.#inputWindowBytes += frameBytes;
|
|
78349
79163
|
channel.nextInputSeq += 1;
|
|
78350
|
-
|
|
78351
|
-
|
|
78352
|
-
|
|
78353
|
-
this.#sessionRuntimeBinding.
|
|
78354
|
-
|
|
78355
|
-
|
|
78356
|
-
|
|
78357
|
-
|
|
78358
|
-
|
|
78359
|
-
|
|
78360
|
-
|
|
78361
|
-
this.#
|
|
78362
|
-
|
|
78363
|
-
|
|
78364
|
-
|
|
78365
|
-
|
|
78366
|
-
|
|
78367
|
-
|
|
78368
|
-
|
|
78369
|
-
|
|
78370
|
-
|
|
78371
|
-
|
|
78372
|
-
|
|
78373
|
-
|
|
78374
|
-
|
|
78375
|
-
|
|
78376
|
-
|
|
78377
|
-
|
|
78378
|
-
|
|
78379
|
-
|
|
78380
|
-
|
|
78381
|
-
|
|
78382
|
-
|
|
78383
|
-
|
|
78384
|
-
|
|
78385
|
-
} catch {
|
|
78386
|
-
}
|
|
78387
|
-
if (this.#diagnosticSharedRawMicros) {
|
|
79164
|
+
const deliver = () => {
|
|
79165
|
+
if (channel.retiredInPlace) return;
|
|
79166
|
+
try {
|
|
79167
|
+
this.#sessionRuntimeBinding.assertController(pane);
|
|
79168
|
+
if (semanticDelivery)
|
|
79169
|
+
this.#sessionRuntimeBinding.sendInput(
|
|
79170
|
+
pane,
|
|
79171
|
+
{ kind, data },
|
|
79172
|
+
performanceTraceId,
|
|
79173
|
+
causalProbe,
|
|
79174
|
+
causalProbe ? (result2) => {
|
|
79175
|
+
if (this.#closed) return;
|
|
79176
|
+
if (result2.status === "proved") {
|
|
79177
|
+
this.#sendFrame(null, { type: "causal-cell-proof", proof: result2.proof });
|
|
79178
|
+
} else {
|
|
79179
|
+
this.#sendFrame(null, {
|
|
79180
|
+
type: "causal-cell-failure",
|
|
79181
|
+
failure: {
|
|
79182
|
+
version: 1,
|
|
79183
|
+
capability: "causal-cell-v1",
|
|
79184
|
+
traceId: result2.traceId,
|
|
79185
|
+
reason: result2.reason,
|
|
79186
|
+
...result2.diagnostic ? { diagnostic: result2.diagnostic } : {}
|
|
79187
|
+
}
|
|
79188
|
+
});
|
|
79189
|
+
}
|
|
79190
|
+
} : void 0,
|
|
79191
|
+
expectedLifetime
|
|
79192
|
+
);
|
|
79193
|
+
else if (kind === "text") channel.sub.sendText(data);
|
|
79194
|
+
else if (kind === "key") channel.sub.sendKey(data);
|
|
79195
|
+
else throw new Error("Byte input requires semantic runtime");
|
|
79196
|
+
let ackStartedAtMicros = null;
|
|
79197
|
+
let ackStartedAtSharedMicros = null;
|
|
79198
|
+
if (trace) {
|
|
78388
79199
|
try {
|
|
78389
|
-
|
|
79200
|
+
ackStartedAtMicros = this.#observability.nowMicros();
|
|
78390
79201
|
} catch {
|
|
78391
79202
|
}
|
|
78392
|
-
|
|
78393
|
-
|
|
78394
|
-
|
|
78395
|
-
|
|
78396
|
-
|
|
78397
|
-
try {
|
|
78398
|
-
ackEndedAtMicros = this.#observability.nowMicros();
|
|
78399
|
-
} catch {
|
|
78400
|
-
}
|
|
78401
|
-
let ackEndedAtSharedMicros = null;
|
|
78402
|
-
if (ackStartedAtSharedMicros !== null) {
|
|
78403
|
-
try {
|
|
78404
|
-
ackEndedAtSharedMicros = this.#sharedMicros();
|
|
78405
|
-
} catch {
|
|
79203
|
+
if (this.#diagnosticSharedRawMicros) {
|
|
79204
|
+
try {
|
|
79205
|
+
ackStartedAtSharedMicros = this.#sharedMicros();
|
|
79206
|
+
} catch {
|
|
79207
|
+
}
|
|
78406
79208
|
}
|
|
78407
79209
|
}
|
|
78408
|
-
|
|
79210
|
+
sendControl2(this.#socket, { type: "input-ack", pane, seq });
|
|
79211
|
+
if (trace && ackStartedAtMicros !== null) {
|
|
79212
|
+
let ackEndedAtMicros = null;
|
|
78409
79213
|
try {
|
|
78410
|
-
this.#observability.
|
|
78411
|
-
"transport",
|
|
78412
|
-
"pane-stream-input-ack-socket-send",
|
|
78413
|
-
ackStartedAtMicros,
|
|
78414
|
-
ackEndedAtMicros,
|
|
78415
|
-
trace,
|
|
78416
|
-
ackStartedAtSharedMicros === null || ackEndedAtSharedMicros === null ? void 0 : {
|
|
78417
|
-
startedAtMicros: ackStartedAtSharedMicros,
|
|
78418
|
-
endedAtMicros: ackEndedAtSharedMicros
|
|
78419
|
-
}
|
|
78420
|
-
);
|
|
79214
|
+
ackEndedAtMicros = this.#observability.nowMicros();
|
|
78421
79215
|
} catch {
|
|
78422
79216
|
}
|
|
79217
|
+
let ackEndedAtSharedMicros = null;
|
|
79218
|
+
if (ackStartedAtSharedMicros !== null) {
|
|
79219
|
+
try {
|
|
79220
|
+
ackEndedAtSharedMicros = this.#sharedMicros();
|
|
79221
|
+
} catch {
|
|
79222
|
+
}
|
|
79223
|
+
}
|
|
79224
|
+
if (ackEndedAtMicros !== null) {
|
|
79225
|
+
try {
|
|
79226
|
+
this.#observability.recordSpan(
|
|
79227
|
+
"transport",
|
|
79228
|
+
"pane-stream-input-ack-socket-send",
|
|
79229
|
+
ackStartedAtMicros,
|
|
79230
|
+
ackEndedAtMicros,
|
|
79231
|
+
trace,
|
|
79232
|
+
ackStartedAtSharedMicros === null || ackEndedAtSharedMicros === null ? void 0 : {
|
|
79233
|
+
startedAtMicros: ackStartedAtSharedMicros,
|
|
79234
|
+
endedAtMicros: ackEndedAtSharedMicros
|
|
79235
|
+
}
|
|
79236
|
+
);
|
|
79237
|
+
} catch {
|
|
79238
|
+
}
|
|
79239
|
+
}
|
|
79240
|
+
}
|
|
79241
|
+
} catch (error) {
|
|
79242
|
+
if (this.#holdForWindowOwnership(error, deliver)) return;
|
|
79243
|
+
if (error instanceof SessionRuntimeInputLifetimeEndedError) {
|
|
79244
|
+
this.#noteInputLifetimeEnded(pane, error);
|
|
79245
|
+
return;
|
|
78423
79246
|
}
|
|
79247
|
+
this.#fail("control-frame-handler-failed", error);
|
|
78424
79248
|
}
|
|
78425
|
-
}
|
|
78426
|
-
|
|
79249
|
+
};
|
|
79250
|
+
this.#afterWindowOwnership(deliver);
|
|
79251
|
+
}
|
|
79252
|
+
/**
|
|
79253
|
+
* Input and geometry frames that arrive while registered-window ownership is
|
|
79254
|
+
* being read again (another session was created or killed) wait for that
|
|
79255
|
+
* read, in arrival order, instead of closing the stream. The mirror refuses
|
|
79256
|
+
* them meanwhile; before, the stream closed with 1011 and the client had to
|
|
79257
|
+
* reconnect. Bounded: a read that does not settle in time closes as before.
|
|
79258
|
+
*/
|
|
79259
|
+
#ownershipHeld = [];
|
|
79260
|
+
#ownershipDraining = false;
|
|
79261
|
+
/** Ends the drain's wait when the stream closes. */
|
|
79262
|
+
#ownershipWake = null;
|
|
79263
|
+
#afterWindowOwnership(run) {
|
|
79264
|
+
if (this.#ownershipHeld.length === 0 && !this.#mirror.windowOwnershipPending?.()) {
|
|
79265
|
+
run();
|
|
79266
|
+
return;
|
|
79267
|
+
}
|
|
79268
|
+
this.#holdUntilWindowOwnership(run);
|
|
79269
|
+
}
|
|
79270
|
+
/**
|
|
79271
|
+
* Frames whose effect depends on authority order (release, presence,
|
|
79272
|
+
* activity, intents) are not held for the read themselves, but must not
|
|
79273
|
+
* overtake frames that are.
|
|
79274
|
+
*/
|
|
79275
|
+
#afterHeldFrames(run) {
|
|
79276
|
+
if (this.#ownershipHeld.length === 0) {
|
|
79277
|
+
run();
|
|
79278
|
+
return;
|
|
79279
|
+
}
|
|
79280
|
+
this.#holdUntilWindowOwnership(run);
|
|
79281
|
+
}
|
|
79282
|
+
/** A refusal while ownership is pending holds the frame; anything else is the caller's. */
|
|
79283
|
+
#holdForWindowOwnership(error, run) {
|
|
79284
|
+
if (!(error instanceof SessionRuntimeControllerLeaseError) || error.code !== "controller-conflict" || !this.#mirror.windowOwnershipPending?.())
|
|
79285
|
+
return false;
|
|
79286
|
+
this.#ownershipHeld.unshift(run);
|
|
79287
|
+
if (!this.#ownershipDraining) void this.#drainWindowOwnership();
|
|
79288
|
+
return true;
|
|
79289
|
+
}
|
|
79290
|
+
#holdUntilWindowOwnership(run) {
|
|
79291
|
+
if (this.#ownershipHeld.length >= PANE_STREAM_OWNERSHIP_HELD_FRAMES) {
|
|
79292
|
+
this.#ownershipHeld.length = 0;
|
|
79293
|
+
this.#fail("window-ownership-held-overflow");
|
|
79294
|
+
return;
|
|
79295
|
+
}
|
|
79296
|
+
this.#ownershipHeld.push(run);
|
|
79297
|
+
if (!this.#ownershipDraining) void this.#drainWindowOwnership();
|
|
79298
|
+
}
|
|
79299
|
+
async #drainWindowOwnership() {
|
|
79300
|
+
this.#ownershipDraining = true;
|
|
79301
|
+
try {
|
|
79302
|
+
await this.#drainWindowOwnershipOnce();
|
|
79303
|
+
} finally {
|
|
79304
|
+
this.#ownershipDraining = false;
|
|
79305
|
+
}
|
|
79306
|
+
}
|
|
79307
|
+
async #drainWindowOwnershipOnce() {
|
|
79308
|
+
const deadline = Date.now() + this.#ownershipWaitMs;
|
|
79309
|
+
while (!this.#closed && this.#ownershipHeld.length > 0) {
|
|
79310
|
+
if (this.#mirror.windowOwnershipPending?.()) {
|
|
79311
|
+
const left = deadline - Date.now();
|
|
79312
|
+
if (left <= 0) {
|
|
79313
|
+
this.#ownershipHeld.length = 0;
|
|
79314
|
+
this.#fail("window-ownership-unverified");
|
|
79315
|
+
return;
|
|
79316
|
+
}
|
|
79317
|
+
const timers = [];
|
|
79318
|
+
const wait = (ms) => new Promise((resolve47) => {
|
|
79319
|
+
const timer = setTimeout(resolve47, ms);
|
|
79320
|
+
timer.unref?.();
|
|
79321
|
+
timers.push(timer);
|
|
79322
|
+
});
|
|
79323
|
+
const read = this.#mirror.verifyWindowOwnership?.();
|
|
79324
|
+
await Promise.race([
|
|
79325
|
+
// Without a read to wait on, poll instead of spinning.
|
|
79326
|
+
read ? read.catch(() => wait(25)) : wait(25),
|
|
79327
|
+
wait(left),
|
|
79328
|
+
new Promise((resolve47) => {
|
|
79329
|
+
this.#ownershipWake = resolve47;
|
|
79330
|
+
})
|
|
79331
|
+
]);
|
|
79332
|
+
this.#ownershipWake = null;
|
|
79333
|
+
for (const timer of timers) clearTimeout(timer);
|
|
79334
|
+
continue;
|
|
79335
|
+
}
|
|
79336
|
+
const run = this.#ownershipHeld.shift();
|
|
79337
|
+
const before = this.#ownershipHeld.length;
|
|
79338
|
+
run();
|
|
79339
|
+
if (this.#ownershipHeld.length > before) continue;
|
|
78427
79340
|
}
|
|
78428
79341
|
}
|
|
79342
|
+
#inputLifetimeEndedLogged = /* @__PURE__ */ new Set();
|
|
79343
|
+
#inputLifetimeEndedDropped = 0;
|
|
79344
|
+
#noteInputLifetimeEnded(pane, error) {
|
|
79345
|
+
this.#inputLifetimeEndedDropped += 1;
|
|
79346
|
+
if (this.#inputLifetimeEndedLogged.has(pane)) return;
|
|
79347
|
+
this.#inputLifetimeEndedLogged.add(pane);
|
|
79348
|
+
logger.info("pane-stream", "input for an ended pane lifetime not delivered", {
|
|
79349
|
+
session: this.#descriptor.sessionName,
|
|
79350
|
+
clientId: this.#clientId,
|
|
79351
|
+
pane,
|
|
79352
|
+
error: error.message.slice(0, 200)
|
|
79353
|
+
});
|
|
79354
|
+
}
|
|
78429
79355
|
#failProtocol(code2) {
|
|
78430
79356
|
try {
|
|
78431
79357
|
sendControl2(this.#socket, {
|
|
@@ -78700,6 +79626,136 @@ var init_multiplexer_backend = __esm({
|
|
|
78700
79626
|
}
|
|
78701
79627
|
});
|
|
78702
79628
|
|
|
79629
|
+
// packages/daemon/src/lib/orphaned-control-clients.ts
|
|
79630
|
+
import { execFile as execFile11 } from "node:child_process";
|
|
79631
|
+
function parseProcessTable(text2) {
|
|
79632
|
+
const rows = [];
|
|
79633
|
+
for (const line of text2.split("\n")) {
|
|
79634
|
+
const match = /^\s*([0-9]+)\s+([0-9]+)\s+(.+)$/u.exec(line);
|
|
79635
|
+
if (match) rows.push({ pid: Number(match[1]), ppid: Number(match[2]), command: match[3] });
|
|
79636
|
+
}
|
|
79637
|
+
return rows;
|
|
79638
|
+
}
|
|
79639
|
+
function isTmuxIdeControlClientCommand(command3) {
|
|
79640
|
+
return /(?:^|\s)-C(?:\s|$)/u.test(command3) && /ignore-size,pause-after=[0-9]+,active-pane/u.test(command3);
|
|
79641
|
+
}
|
|
79642
|
+
function commandTargetsServer(command3, selector) {
|
|
79643
|
+
const words = command3.split(/\s+/u);
|
|
79644
|
+
for (let index = 0; index < words.length; index += 1) {
|
|
79645
|
+
const word = words[index];
|
|
79646
|
+
if (word === "-C") return false;
|
|
79647
|
+
const flag = selector.kind === "path" ? "-S" : "-L";
|
|
79648
|
+
const value = word === flag ? words[index + 1] : word.startsWith(flag) ? word.slice(2) : null;
|
|
79649
|
+
if (value === null || value === void 0 || value === "") continue;
|
|
79650
|
+
return selector.kind === "path" ? withoutPrivate(value) === withoutPrivate(selector.path) : value === selector.name;
|
|
79651
|
+
}
|
|
79652
|
+
return false;
|
|
79653
|
+
}
|
|
79654
|
+
function adoptsOrphans(pid, command3) {
|
|
79655
|
+
if (pid === 1) return true;
|
|
79656
|
+
return command3 !== null && /^(?:\S*\/)?(?:systemd|launchd|init)(?:\s|$)/u.test(command3);
|
|
79657
|
+
}
|
|
79658
|
+
async function evictOrphanedControlClients(io, ownPid, selector) {
|
|
79659
|
+
let processes;
|
|
79660
|
+
try {
|
|
79661
|
+
processes = await io.listProcesses();
|
|
79662
|
+
} catch {
|
|
79663
|
+
return [];
|
|
79664
|
+
}
|
|
79665
|
+
const byPid = new Map(processes.map((row) => [row.pid, row]));
|
|
79666
|
+
const evicted = [];
|
|
79667
|
+
for (const client of processes) {
|
|
79668
|
+
if (client.pid <= 1 || client.pid === ownPid || client.ppid === ownPid || !isTmuxIdeControlClientCommand(client.command) || !commandTargetsServer(client.command, selector) || !adoptsOrphans(client.ppid, byPid.get(client.ppid)?.command ?? null))
|
|
79669
|
+
continue;
|
|
79670
|
+
try {
|
|
79671
|
+
io.kill(client.pid, "SIGTERM");
|
|
79672
|
+
await io.delay(ORPHAN_KILL_GRACE_MS);
|
|
79673
|
+
if (io.isAlive(client.pid)) io.kill(client.pid, "SIGKILL");
|
|
79674
|
+
evicted.push(client.pid);
|
|
79675
|
+
} catch {
|
|
79676
|
+
}
|
|
79677
|
+
}
|
|
79678
|
+
return evicted;
|
|
79679
|
+
}
|
|
79680
|
+
function orphanedControlClientIo() {
|
|
79681
|
+
return {
|
|
79682
|
+
listProcesses: () => new Promise((resolve47, reject) => {
|
|
79683
|
+
execFile11(
|
|
79684
|
+
"/bin/ps",
|
|
79685
|
+
["-xww", "-o", "pid=,ppid=,command="],
|
|
79686
|
+
{
|
|
79687
|
+
encoding: "utf8",
|
|
79688
|
+
timeout: 3e3,
|
|
79689
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
79690
|
+
env: { LC_ALL: "C", PATH: "/usr/bin:/bin" }
|
|
79691
|
+
},
|
|
79692
|
+
(error, stdout) => error ? reject(error) : resolve47(parseProcessTable(stdout))
|
|
79693
|
+
);
|
|
79694
|
+
}),
|
|
79695
|
+
kill: (pid, signal) => {
|
|
79696
|
+
process.kill(pid, signal);
|
|
79697
|
+
},
|
|
79698
|
+
isAlive: (pid) => {
|
|
79699
|
+
try {
|
|
79700
|
+
process.kill(pid, 0);
|
|
79701
|
+
return true;
|
|
79702
|
+
} catch (error) {
|
|
79703
|
+
return error.code === "EPERM";
|
|
79704
|
+
}
|
|
79705
|
+
},
|
|
79706
|
+
delay: (ms) => new Promise((resolve47) => setTimeout(resolve47, ms))
|
|
79707
|
+
};
|
|
79708
|
+
}
|
|
79709
|
+
function createOrphanedControlClientWatch(options) {
|
|
79710
|
+
const io = options.io ?? orphanedControlClientIo();
|
|
79711
|
+
const now = options.now ?? Date.now;
|
|
79712
|
+
const fields = options.serverId ? { serverId: options.serverId } : {};
|
|
79713
|
+
let lastPassAt = Number.NEGATIVE_INFINITY;
|
|
79714
|
+
let lastLogAt = Number.NEGATIVE_INFINITY;
|
|
79715
|
+
let running = null;
|
|
79716
|
+
const pass = () => {
|
|
79717
|
+
if (running) return running;
|
|
79718
|
+
lastPassAt = now();
|
|
79719
|
+
const current = evictOrphanedControlClients(io, process.pid, options.selector).catch(() => []).then((pids) => {
|
|
79720
|
+
if (pids.length > 0)
|
|
79721
|
+
logger.warn("tmux-server-owners", "ended control clients a dead daemon left attached", {
|
|
79722
|
+
...fields,
|
|
79723
|
+
pids
|
|
79724
|
+
});
|
|
79725
|
+
return pids;
|
|
79726
|
+
}).finally(() => {
|
|
79727
|
+
if (running === current) running = null;
|
|
79728
|
+
});
|
|
79729
|
+
running = current;
|
|
79730
|
+
return current;
|
|
79731
|
+
};
|
|
79732
|
+
return {
|
|
79733
|
+
onOwnership: () => pass().then(() => void 0),
|
|
79734
|
+
async onTrouble(kind) {
|
|
79735
|
+
if (now() - lastPassAt < EMPTY_SERVER_PASS_INTERVAL_MS) return;
|
|
79736
|
+
const pids = await pass();
|
|
79737
|
+
if (now() - lastLogAt < EMPTY_SERVER_LOG_INTERVAL_MS) return;
|
|
79738
|
+
lastLogAt = now();
|
|
79739
|
+
logger.warn(
|
|
79740
|
+
"tmux-server-owners",
|
|
79741
|
+
kind === "no-sessions" ? "tmux server answers with no sessions" : "tmux server does not answer its catalog",
|
|
79742
|
+
{ ...fields, endedControlClients: pids.length }
|
|
79743
|
+
);
|
|
79744
|
+
}
|
|
79745
|
+
};
|
|
79746
|
+
}
|
|
79747
|
+
var ORPHAN_KILL_GRACE_MS, withoutPrivate, EMPTY_SERVER_PASS_INTERVAL_MS, EMPTY_SERVER_LOG_INTERVAL_MS;
|
|
79748
|
+
var init_orphaned_control_clients = __esm({
|
|
79749
|
+
"packages/daemon/src/lib/orphaned-control-clients.ts"() {
|
|
79750
|
+
"use strict";
|
|
79751
|
+
init_log();
|
|
79752
|
+
ORPHAN_KILL_GRACE_MS = 500;
|
|
79753
|
+
withoutPrivate = (path2) => path2.replace(/^\/private(?=\/)/u, "");
|
|
79754
|
+
EMPTY_SERVER_PASS_INTERVAL_MS = 1e4;
|
|
79755
|
+
EMPTY_SERVER_LOG_INTERVAL_MS = 6e4;
|
|
79756
|
+
}
|
|
79757
|
+
});
|
|
79758
|
+
|
|
78703
79759
|
// packages/daemon/src/lib/interaction-receipt-journal.ts
|
|
78704
79760
|
var InteractionReceiptJournal;
|
|
78705
79761
|
var init_interaction_receipt_journal = __esm({
|
|
@@ -79162,9 +80218,15 @@ function discoveredWorkspaceName(registry, sessionName) {
|
|
|
79162
80218
|
}
|
|
79163
80219
|
throw new Error("Unable to allocate discovered workspace identity");
|
|
79164
80220
|
}
|
|
79165
|
-
function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () => void 0) {
|
|
80221
|
+
function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () => void 0, onTrouble) {
|
|
79166
80222
|
return async () => {
|
|
79167
80223
|
assertOpen();
|
|
80224
|
+
const tell = (kind) => {
|
|
80225
|
+
try {
|
|
80226
|
+
void Promise.resolve(onTrouble?.(kind)).catch(() => void 0);
|
|
80227
|
+
} catch {
|
|
80228
|
+
}
|
|
80229
|
+
};
|
|
79168
80230
|
const raw = await run(
|
|
79169
80231
|
[
|
|
79170
80232
|
"-N",
|
|
@@ -79181,10 +80243,15 @@ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () =
|
|
|
79181
80243
|
].map(shellEscape).join(" ")
|
|
79182
80244
|
],
|
|
79183
80245
|
AbortSignal.timeout(2e3)
|
|
79184
|
-
)
|
|
80246
|
+
).catch((error) => {
|
|
80247
|
+
tell("unanswered");
|
|
80248
|
+
throw error;
|
|
80249
|
+
});
|
|
79185
80250
|
assertOpen();
|
|
79186
80251
|
const rows = /* @__PURE__ */ new Map();
|
|
79187
|
-
const
|
|
80252
|
+
const empty2 = raw.trim() === "tmux-ide-empty-catalog-v1";
|
|
80253
|
+
if (empty2) tell("no-sessions");
|
|
80254
|
+
const lines = empty2 ? [] : raw.trim().split("\n");
|
|
79188
80255
|
for (const line of lines) {
|
|
79189
80256
|
const [pid, id2, created, name, pane, window2, activity, ...pathParts] = line.split(" ");
|
|
79190
80257
|
const dir = pathParts.join(" ");
|
|
@@ -79255,6 +80322,11 @@ async function createNativeTmuxServerOwner(options) {
|
|
|
79255
80322
|
authority2,
|
|
79256
80323
|
nativeServerIdentity
|
|
79257
80324
|
);
|
|
80325
|
+
const orphanWatch = createOrphanedControlClientWatch({
|
|
80326
|
+
selector: authority2.socketSelector,
|
|
80327
|
+
serverId: options.serverId
|
|
80328
|
+
});
|
|
80329
|
+
void orphanWatch.onOwnership();
|
|
79258
80330
|
const multiplexer = new WorkspaceMultiplexerAuthority({
|
|
79259
80331
|
daemonInstanceId: generation,
|
|
79260
80332
|
registry: workspaceRegistry,
|
|
@@ -79530,7 +80602,12 @@ async function createNativeTmuxServerOwner(options) {
|
|
|
79530
80602
|
registry: sessionRuntimeRegistry,
|
|
79531
80603
|
resolveSession: (name) => workspaceRegistry.get(name)?.sessionName ?? null
|
|
79532
80604
|
});
|
|
79533
|
-
const catalog = createNativeTmuxServerCatalog(
|
|
80605
|
+
const catalog = createNativeTmuxServerCatalog(
|
|
80606
|
+
workspaceRegistry,
|
|
80607
|
+
generationRunAsync,
|
|
80608
|
+
assertOpen,
|
|
80609
|
+
orphanWatch.onTrouble
|
|
80610
|
+
);
|
|
79534
80611
|
const sessionCreator = createNativeTmuxSessionCreator({
|
|
79535
80612
|
generation,
|
|
79536
80613
|
registry: workspaceRegistry,
|
|
@@ -79766,6 +80843,7 @@ var init_tmux_server_owner = __esm({
|
|
|
79766
80843
|
init_registry2();
|
|
79767
80844
|
init_multiplexer_backend();
|
|
79768
80845
|
init_tmux_external_interaction_observer();
|
|
80846
|
+
init_orphaned_control_clients();
|
|
79769
80847
|
init_interaction_receipt_journal();
|
|
79770
80848
|
init_interaction_observation_status();
|
|
79771
80849
|
init_interaction_evidence_authority();
|
|
@@ -80221,7 +81299,7 @@ var init_tmux_server_owners = __esm({
|
|
|
80221
81299
|
});
|
|
80222
81300
|
|
|
80223
81301
|
// packages/daemon/src/lib/tmux-server-registration.ts
|
|
80224
|
-
import { execFile as
|
|
81302
|
+
import { execFile as execFile12 } from "node:child_process";
|
|
80225
81303
|
import { promisify as promisify2 } from "node:util";
|
|
80226
81304
|
import { createHash as createHash26, randomUUID as randomUUID39 } from "node:crypto";
|
|
80227
81305
|
import {
|
|
@@ -80380,7 +81458,7 @@ var init_tmux_server_registration = __esm({
|
|
|
80380
81458
|
init_tmux_client_execution();
|
|
80381
81459
|
init_unix_socket_authority();
|
|
80382
81460
|
init_tmux_server_owners();
|
|
80383
|
-
exec = promisify2(
|
|
81461
|
+
exec = promisify2(execFile12);
|
|
80384
81462
|
FileSchema2 = z125.object({
|
|
80385
81463
|
version: z125.literal(1),
|
|
80386
81464
|
servers: z125.array(TmuxServerRegistrationSchemaZ).max(MAX_TMUX_SERVER_OWNERS)
|
|
@@ -80899,7 +81977,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
80899
81977
|
const snapshot3 = async (liveSessionId, signal, windowId, paneId) => {
|
|
80900
81978
|
const nativeEpoch = native2?.serverEpoch() ?? null;
|
|
80901
81979
|
let sessionGuard;
|
|
80902
|
-
const
|
|
81980
|
+
const readSessions2 = async () => {
|
|
80903
81981
|
const raw = await run(
|
|
80904
81982
|
["list-panes", "-a", "-F", "#{pid} #{session_id} #{session_created} #{session_name}"],
|
|
80905
81983
|
signal
|
|
@@ -80912,7 +81990,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
80912
81990
|
}
|
|
80913
81991
|
return discoverLiveSessionSummaries(() => raw);
|
|
80914
81992
|
};
|
|
80915
|
-
const session = (await
|
|
81993
|
+
const session = (await readSessions2()).find((s) => s.liveSessionId === liveSessionId);
|
|
80916
81994
|
if (!session) return null;
|
|
80917
81995
|
const readPanes = async () => (await run(
|
|
80918
81996
|
[
|
|
@@ -80989,7 +82067,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
80989
82067
|
signal
|
|
80990
82068
|
) : null;
|
|
80991
82069
|
const captured = owned ? owned.output : await run(["capture-pane", "-p", "-t", pane, "-S", "-24"], signal);
|
|
80992
|
-
const [currentSessions, currentPanes] = await Promise.all([
|
|
82070
|
+
const [currentSessions, currentPanes] = await Promise.all([readSessions2(), readPanes()]);
|
|
80993
82071
|
if (!currentSessions.some((s) => s.liveSessionId === liveSessionId)) return null;
|
|
80994
82072
|
if (selectedWindowId && !currentPanes.some((r) => r[3] === selectedWindowId && r[0] === pane))
|
|
80995
82073
|
return null;
|
|
@@ -81402,7 +82480,7 @@ var init_runtime_trace_writer = __esm({
|
|
|
81402
82480
|
});
|
|
81403
82481
|
|
|
81404
82482
|
// packages/daemon/src/lib/tmux-authority-replacement.ts
|
|
81405
|
-
import { execFile as
|
|
82483
|
+
import { execFile as execFile13 } from "node:child_process";
|
|
81406
82484
|
import { lstatSync as lstatSync13 } from "node:fs";
|
|
81407
82485
|
import { dirname as dirname33 } from "node:path";
|
|
81408
82486
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -81491,7 +82569,7 @@ var init_tmux_authority_replacement = __esm({
|
|
|
81491
82569
|
"use strict";
|
|
81492
82570
|
init_unix_socket_authority();
|
|
81493
82571
|
init_tmux_named_socket_fence();
|
|
81494
|
-
execFileAsync = promisify3(
|
|
82572
|
+
execFileAsync = promisify3(execFile13);
|
|
81495
82573
|
SERVER_FORMAT = "#{socket_path}|#{pid}";
|
|
81496
82574
|
}
|
|
81497
82575
|
});
|
|
@@ -81590,7 +82668,7 @@ var init_session_monitor = __esm({
|
|
|
81590
82668
|
});
|
|
81591
82669
|
|
|
81592
82670
|
// packages/daemon/src/lib/daemon-session-monitor.ts
|
|
81593
|
-
import { execFile as
|
|
82671
|
+
import { execFile as execFile14 } from "node:child_process";
|
|
81594
82672
|
function parseDaemonMonitorPanes(raw) {
|
|
81595
82673
|
if (!raw) return [];
|
|
81596
82674
|
return raw.split("\n").map((line) => {
|
|
@@ -81608,7 +82686,7 @@ function parseDaemonMonitorPanes(raw) {
|
|
|
81608
82686
|
}
|
|
81609
82687
|
function execMonitorCommandAsync(executable, args, signal) {
|
|
81610
82688
|
return new Promise((resolve47, reject) => {
|
|
81611
|
-
|
|
82689
|
+
execFile14(
|
|
81612
82690
|
executable,
|
|
81613
82691
|
[...args],
|
|
81614
82692
|
{ encoding: "utf8", maxBuffer: 1024 * 1024, signal },
|
|
@@ -88796,7 +89874,7 @@ var init_plugin_store = __esm({
|
|
|
88796
89874
|
|
|
88797
89875
|
// packages/daemon/src/plugins/worktree-calls.ts
|
|
88798
89876
|
import { spawn as spawn9 } from "node:child_process";
|
|
88799
|
-
import { homedir as
|
|
89877
|
+
import { homedir as homedir6 } from "node:os";
|
|
88800
89878
|
import { z as z130 } from "zod";
|
|
88801
89879
|
function fail3(message) {
|
|
88802
89880
|
throw new WorktreeCallError(message);
|
|
@@ -88857,7 +89935,7 @@ function cliRunner(command3, timeoutMs = 6e4) {
|
|
|
88857
89935
|
return (args, env) => new Promise((resolve47, reject) => {
|
|
88858
89936
|
const [file, ...prefix] = command3;
|
|
88859
89937
|
const child = spawn9(file, [...prefix, ...args], {
|
|
88860
|
-
cwd:
|
|
89938
|
+
cwd: homedir6(),
|
|
88861
89939
|
env,
|
|
88862
89940
|
stdio: ["ignore", "pipe", "pipe"]
|
|
88863
89941
|
});
|
|
@@ -91353,6 +92431,14 @@ function failure(c, error) {
|
|
|
91353
92431
|
return c.json({ error: { code: error.code } }, 409);
|
|
91354
92432
|
if (error instanceof z136.ZodError || error instanceof SyntaxError || error instanceof TypeError)
|
|
91355
92433
|
return c.json({ error: { code: "invalid-request" } }, 400);
|
|
92434
|
+
const code2 = error?.code;
|
|
92435
|
+
logger.warn("tmux-server-routes", "request failed as server-unavailable", {
|
|
92436
|
+
method: c.req.method,
|
|
92437
|
+
route: c.req.routePath,
|
|
92438
|
+
errorName: error instanceof Error ? error.name : typeof error,
|
|
92439
|
+
...typeof code2 === "string" ? { errorCode: code2.slice(0, 80) } : {},
|
|
92440
|
+
error: (error instanceof Error ? error.message : String(error)).slice(0, 300)
|
|
92441
|
+
});
|
|
91356
92442
|
return c.json({ error: { code: "server-unavailable" } }, 503);
|
|
91357
92443
|
}
|
|
91358
92444
|
function mountTmuxServerRoutes(app, options) {
|
|
@@ -91868,6 +92954,7 @@ var init_tmux_servers = __esm({
|
|
|
91868
92954
|
init_workspace_multiplexer_verbs();
|
|
91869
92955
|
init_workspace_pane_creation2();
|
|
91870
92956
|
init_owner_authority();
|
|
92957
|
+
init_log();
|
|
91871
92958
|
init_pane_stream_issue();
|
|
91872
92959
|
init_terminal_runtime_inventory2();
|
|
91873
92960
|
SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES = 512 * 1024;
|
|
@@ -92702,7 +93789,7 @@ __export(auth_service_exports, {
|
|
|
92702
93789
|
import * as crypto2 from "node:crypto";
|
|
92703
93790
|
import { readFileSync as readFileSync35, existsSync as existsSync33 } from "node:fs";
|
|
92704
93791
|
import { join as join56 } from "node:path";
|
|
92705
|
-
import { homedir as
|
|
93792
|
+
import { homedir as homedir7 } from "node:os";
|
|
92706
93793
|
function base64url(buf) {
|
|
92707
93794
|
const b = typeof buf === "string" ? Buffer.from(buf) : buf;
|
|
92708
93795
|
return b.toString("base64url");
|
|
@@ -92846,7 +93933,7 @@ var init_auth_service = __esm({
|
|
|
92846
93933
|
checkSSHKeyAuthorization(userId, publicKey) {
|
|
92847
93934
|
if (resolveRuntimeNamespace().development) return false;
|
|
92848
93935
|
try {
|
|
92849
|
-
const home = userId === process.env.USER ?
|
|
93936
|
+
const home = userId === process.env.USER ? homedir7() : `/home/${userId}`;
|
|
92850
93937
|
const authKeysPath = join56(home, ".ssh", "authorized_keys");
|
|
92851
93938
|
if (!existsSync33(authKeysPath)) return false;
|
|
92852
93939
|
const authorizedKeys = readFileSync35(authKeysPath, "utf-8");
|
|
@@ -95872,7 +96959,7 @@ var init_inspect = __esm({
|
|
|
95872
96959
|
|
|
95873
96960
|
// packages/daemon/src/lib/filesystem-browser.ts
|
|
95874
96961
|
import { realpathSync as realpathSync26, readdirSync as readdirSync9, statSync as statSync27 } from "node:fs";
|
|
95875
|
-
import { homedir as
|
|
96962
|
+
import { homedir as homedir8 } from "node:os";
|
|
95876
96963
|
import { isAbsolute as isAbsolute31, join as join57, resolve as resolve33, sep as sep13 } from "node:path";
|
|
95877
96964
|
function isUnderRoot(canonical, root) {
|
|
95878
96965
|
if (canonical === root) return true;
|
|
@@ -99559,7 +100646,7 @@ __export(server_exports2, {
|
|
|
99559
100646
|
getCompatibilityMetrics: () => getCompatibilityMetrics,
|
|
99560
100647
|
getSseMetrics: () => getSseMetrics
|
|
99561
100648
|
});
|
|
99562
|
-
import { execFile as
|
|
100649
|
+
import { execFile as execFile15 } from "node:child_process";
|
|
99563
100650
|
import { promisify as promisify4 } from "node:util";
|
|
99564
100651
|
import { existsSync as existsSync38, readdirSync as readdirSync12 } from "node:fs";
|
|
99565
100652
|
import { join as join59, dirname as dirname46, basename as basename24 } from "node:path";
|
|
@@ -99570,7 +100657,7 @@ import { cors } from "hono/cors";
|
|
|
99570
100657
|
import { zValidator } from "@hono/zod-validator";
|
|
99571
100658
|
import { z as z142 } from "zod";
|
|
99572
100659
|
import { realpathSync as realpathSync29 } from "node:fs";
|
|
99573
|
-
import { homedir as
|
|
100660
|
+
import { homedir as homedir9 } from "node:os";
|
|
99574
100661
|
import { isAbsolute as isAbsolute34, resolve as pathResolve } from "node:path";
|
|
99575
100662
|
import { randomUUID as randomUUID51 } from "node:crypto";
|
|
99576
100663
|
import { WebSocketServer as WebSocketServer4 } from "ws";
|
|
@@ -99672,7 +100759,7 @@ function sandboxResolveDir(rawDir) {
|
|
|
99672
100759
|
if (trimmed.includes("\0")) {
|
|
99673
100760
|
return { error: "invalid-path", message: "Path contains a null byte", status: 400 };
|
|
99674
100761
|
}
|
|
99675
|
-
const home = process.env.TMUX_IDE_HOME_OVERRIDE && process.env.TMUX_IDE_HOME_OVERRIDE.trim().length > 0 ? process.env.TMUX_IDE_HOME_OVERRIDE :
|
|
100762
|
+
const home = process.env.TMUX_IDE_HOME_OVERRIDE && process.env.TMUX_IDE_HOME_OVERRIDE.trim().length > 0 ? process.env.TMUX_IDE_HOME_OVERRIDE : homedir9();
|
|
99676
100763
|
let candidate = trimmed;
|
|
99677
100764
|
if (candidate === "~") {
|
|
99678
100765
|
candidate = home;
|
|
@@ -99708,6 +100795,12 @@ function sandboxResolveDir(rawDir) {
|
|
|
99708
100795
|
return { canonical };
|
|
99709
100796
|
}
|
|
99710
100797
|
function createApp(options = {}) {
|
|
100798
|
+
const lookupSession = (name) => {
|
|
100799
|
+
const sessions = readSessions();
|
|
100800
|
+
if (sessions === null) return "unavailable";
|
|
100801
|
+
return sessions.find((session) => session.name === name) ?? "not-found";
|
|
100802
|
+
};
|
|
100803
|
+
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);
|
|
99711
100804
|
const authConfig = options.authConfig ?? { method: "none", token_expiry: 86400 };
|
|
99712
100805
|
const authService = options.authService ?? new AuthService();
|
|
99713
100806
|
const daemonIdentity = options.daemonIdentity ?? {
|
|
@@ -99934,7 +101027,12 @@ function createApp(options = {}) {
|
|
|
99934
101027
|
});
|
|
99935
101028
|
});
|
|
99936
101029
|
app.get("/api/sessions", (c) => {
|
|
99937
|
-
const sessions =
|
|
101030
|
+
const sessions = readSessions();
|
|
101031
|
+
if (sessions === null)
|
|
101032
|
+
return c.json(
|
|
101033
|
+
{ error: "Tmux session discovery is unavailable", code: "tmux-unavailable" },
|
|
101034
|
+
503
|
|
101035
|
+
);
|
|
99938
101036
|
const overviews = buildOverviews(sessions);
|
|
99939
101037
|
return c.json({ sessions: overviews });
|
|
99940
101038
|
});
|
|
@@ -100050,11 +101148,8 @@ function createApp(options = {}) {
|
|
|
100050
101148
|
});
|
|
100051
101149
|
app.get("/api/project/:name", (c) => {
|
|
100052
101150
|
const name = c.req.param("name");
|
|
100053
|
-
const
|
|
100054
|
-
|
|
100055
|
-
if (!session) {
|
|
100056
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100057
|
-
}
|
|
101151
|
+
const session = lookupSession(name);
|
|
101152
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100058
101153
|
const detail = buildProjectDetail(session);
|
|
100059
101154
|
return c.json({ ...detail });
|
|
100060
101155
|
});
|
|
@@ -100162,8 +101257,8 @@ function createApp(options = {}) {
|
|
|
100162
101257
|
const backend2 = options.applicationShellInventoryBackend;
|
|
100163
101258
|
if (!backend2) {
|
|
100164
101259
|
if (requestedVersion === String(APPLICATION_SHELL_RESOURCE_V1_VERSION)) {
|
|
100165
|
-
const standaloneSession =
|
|
100166
|
-
if (
|
|
101260
|
+
const standaloneSession = lookupSession(name);
|
|
101261
|
+
if (typeof standaloneSession === "string") return sessionMissing(c, standaloneSession);
|
|
100167
101262
|
markV1Compatibility();
|
|
100168
101263
|
return c.json({
|
|
100169
101264
|
version: APPLICATION_SHELL_RESOURCE_V1_VERSION,
|
|
@@ -100232,13 +101327,12 @@ function createApp(options = {}) {
|
|
|
100232
101327
|
try {
|
|
100233
101328
|
panes = listSessionPanes(name);
|
|
100234
101329
|
} catch {
|
|
100235
|
-
|
|
101330
|
+
const session = lookupSession(name);
|
|
101331
|
+
return sessionMissing(c, typeof session === "string" ? session : "not-found");
|
|
100236
101332
|
}
|
|
100237
101333
|
if (panes.length === 0) {
|
|
100238
|
-
const
|
|
100239
|
-
if (
|
|
100240
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100241
|
-
}
|
|
101334
|
+
const session = lookupSession(name);
|
|
101335
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100242
101336
|
}
|
|
100243
101337
|
return c.json({
|
|
100244
101338
|
panes: panes.map((p) => ({
|
|
@@ -100257,9 +101351,8 @@ function createApp(options = {}) {
|
|
|
100257
101351
|
});
|
|
100258
101352
|
app.get("/api/project/:name/terminals", async (c) => {
|
|
100259
101353
|
const name = c.req.param("name");
|
|
100260
|
-
const
|
|
100261
|
-
|
|
100262
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101354
|
+
const session = lookupSession(name);
|
|
101355
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100263
101356
|
const records = loadTerminals(session.dir);
|
|
100264
101357
|
const terminals = records.map((t) => {
|
|
100265
101358
|
const bridge = defaultPtyBridgeRegistry.peek(t.id);
|
|
@@ -100284,9 +101377,8 @@ function createApp(options = {}) {
|
|
|
100284
101377
|
zValidator("json", terminalCreateRequestSchema),
|
|
100285
101378
|
async (c) => {
|
|
100286
101379
|
const name = c.req.param("name");
|
|
100287
|
-
const
|
|
100288
|
-
|
|
100289
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101380
|
+
const session = lookupSession(name);
|
|
101381
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100290
101382
|
const body = c.req.valid("json");
|
|
100291
101383
|
let id2 = body.id;
|
|
100292
101384
|
let scripted = false;
|
|
@@ -100324,9 +101416,8 @@ function createApp(options = {}) {
|
|
|
100324
101416
|
async (c) => {
|
|
100325
101417
|
const name = c.req.param("name");
|
|
100326
101418
|
const id2 = c.req.param("id");
|
|
100327
|
-
const
|
|
100328
|
-
|
|
100329
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101419
|
+
const session = lookupSession(name);
|
|
101420
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100330
101421
|
try {
|
|
100331
101422
|
const record2 = renameTerminal(session.dir, id2, c.req.valid("json").name);
|
|
100332
101423
|
if (!record2) return c.json({ error: "Terminal not found" }, 404);
|
|
@@ -100340,9 +101431,8 @@ function createApp(options = {}) {
|
|
|
100340
101431
|
app.delete("/api/project/:name/terminals/:id", async (c) => {
|
|
100341
101432
|
const name = c.req.param("name");
|
|
100342
101433
|
const id2 = c.req.param("id");
|
|
100343
|
-
const
|
|
100344
|
-
|
|
100345
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101434
|
+
const session = lookupSession(name);
|
|
101435
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100346
101436
|
const removedRecord = deleteTerminal(session.dir, id2);
|
|
100347
101437
|
const killed = defaultPtyBridgeRegistry.delete(id2);
|
|
100348
101438
|
if (!removedRecord && !killed) {
|
|
@@ -100353,18 +101443,14 @@ function createApp(options = {}) {
|
|
|
100353
101443
|
});
|
|
100354
101444
|
app.get("/api/project/:name/events", (c) => {
|
|
100355
101445
|
const name = c.req.param("name");
|
|
100356
|
-
const session =
|
|
100357
|
-
if (
|
|
100358
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100359
|
-
}
|
|
101446
|
+
const session = lookupSession(name);
|
|
101447
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100360
101448
|
return c.json({ events: [] });
|
|
100361
101449
|
});
|
|
100362
101450
|
app.get("/api/project/:name/stream", (c) => {
|
|
100363
101451
|
const name = c.req.param("name");
|
|
100364
|
-
const session =
|
|
100365
|
-
if (
|
|
100366
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100367
|
-
}
|
|
101452
|
+
const session = lookupSession(name);
|
|
101453
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100368
101454
|
return streamSSE3(c, async (stream) => {
|
|
100369
101455
|
projectStreamConnections += 1;
|
|
100370
101456
|
sseMetrics.connections = projectStreamConnections;
|
|
@@ -100390,9 +101476,9 @@ function createApp(options = {}) {
|
|
|
100390
101476
|
writeChanges(session);
|
|
100391
101477
|
while (!closed) {
|
|
100392
101478
|
await stream.sleep(250);
|
|
100393
|
-
const current =
|
|
100394
|
-
if (
|
|
100395
|
-
writeChanges(current);
|
|
101479
|
+
const current = lookupSession(name);
|
|
101480
|
+
if (current === "not-found") break;
|
|
101481
|
+
if (current !== "unavailable") writeChanges(current);
|
|
100396
101482
|
const now = Date.now();
|
|
100397
101483
|
if (now - lastPing >= 25e3) {
|
|
100398
101484
|
writeSse("ping", { at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
@@ -100407,11 +101493,8 @@ function createApp(options = {}) {
|
|
|
100407
101493
|
});
|
|
100408
101494
|
app.post("/api/project/:name/inject", async (c) => {
|
|
100409
101495
|
const name = c.req.param("name");
|
|
100410
|
-
const
|
|
100411
|
-
|
|
100412
|
-
if (!session) {
|
|
100413
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100414
|
-
}
|
|
101496
|
+
const session = lookupSession(name);
|
|
101497
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100415
101498
|
let body;
|
|
100416
101499
|
try {
|
|
100417
101500
|
body = await c.req.json();
|
|
@@ -100444,11 +101527,8 @@ function createApp(options = {}) {
|
|
|
100444
101527
|
});
|
|
100445
101528
|
app.post("/api/project/:name/send", zValidator("json", sendCommandSchema), async (c) => {
|
|
100446
101529
|
const name = c.req.param("name");
|
|
100447
|
-
const
|
|
100448
|
-
|
|
100449
|
-
if (!session) {
|
|
100450
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100451
|
-
}
|
|
101530
|
+
const session = lookupSession(name);
|
|
101531
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100452
101532
|
const { target, message, noEnter } = c.req.valid("json");
|
|
100453
101533
|
const panes = listSessionPanes(name);
|
|
100454
101534
|
const pane = resolvePane(panes, target);
|
|
@@ -100482,9 +101562,8 @@ function createApp(options = {}) {
|
|
|
100482
101562
|
});
|
|
100483
101563
|
app.get("/api/project/:name/config", async (c) => {
|
|
100484
101564
|
const name = c.req.param("name");
|
|
100485
|
-
const
|
|
100486
|
-
|
|
100487
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101565
|
+
const session = lookupSession(name);
|
|
101566
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100488
101567
|
try {
|
|
100489
101568
|
const resolved2 = await resolveConfig(session.dir);
|
|
100490
101569
|
if (!resolved2.launchConfig || !resolved2.path) {
|
|
@@ -100506,9 +101585,8 @@ function createApp(options = {}) {
|
|
|
100506
101585
|
});
|
|
100507
101586
|
app.post("/api/project/:name/config", async (c) => {
|
|
100508
101587
|
const name = c.req.param("name");
|
|
100509
|
-
const
|
|
100510
|
-
|
|
100511
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101588
|
+
const session = lookupSession(name);
|
|
101589
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100512
101590
|
let body;
|
|
100513
101591
|
try {
|
|
100514
101592
|
body = await c.req.json();
|
|
@@ -100537,12 +101615,11 @@ function createApp(options = {}) {
|
|
|
100537
101615
|
return c.json({ error: "Failed to write workspace config", detail: message }, 500);
|
|
100538
101616
|
}
|
|
100539
101617
|
});
|
|
100540
|
-
const execFileAsync2 = promisify4(
|
|
101618
|
+
const execFileAsync2 = promisify4(execFile15);
|
|
100541
101619
|
app.post("/api/project/:name/restart", async (c) => {
|
|
100542
101620
|
const name = c.req.param("name");
|
|
100543
|
-
const
|
|
100544
|
-
|
|
100545
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101621
|
+
const session = lookupSession(name);
|
|
101622
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100546
101623
|
try {
|
|
100547
101624
|
await execFileAsync2("tmux-ide", ["restart", "--json"], {
|
|
100548
101625
|
cwd: session.dir,
|
|
@@ -100557,11 +101634,8 @@ function createApp(options = {}) {
|
|
|
100557
101634
|
});
|
|
100558
101635
|
app.post("/api/project/:name/launch", async (c) => {
|
|
100559
101636
|
const name = c.req.param("name");
|
|
100560
|
-
const
|
|
100561
|
-
|
|
100562
|
-
if (!session) {
|
|
100563
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100564
|
-
}
|
|
101637
|
+
const session = lookupSession(name);
|
|
101638
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100565
101639
|
const state = getSessionState(name);
|
|
100566
101640
|
if (state.running) {
|
|
100567
101641
|
return c.json({ ok: true, session: name, status: "already_running" });
|
|
@@ -100581,11 +101655,8 @@ function createApp(options = {}) {
|
|
|
100581
101655
|
});
|
|
100582
101656
|
app.post("/api/project/:name/stop", async (c) => {
|
|
100583
101657
|
const name = c.req.param("name");
|
|
100584
|
-
const
|
|
100585
|
-
|
|
100586
|
-
if (!session) {
|
|
100587
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100588
|
-
}
|
|
101658
|
+
const session = lookupSession(name);
|
|
101659
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100589
101660
|
const state = getSessionState(name);
|
|
100590
101661
|
if (!state.running) {
|
|
100591
101662
|
return c.json({ ok: true, session: name, status: "not_running" });
|
|
@@ -100601,7 +101672,8 @@ function createApp(options = {}) {
|
|
|
100601
101672
|
return streamSSE3(c, async (stream) => {
|
|
100602
101673
|
let prevOverviews = [];
|
|
100603
101674
|
const poll = () => {
|
|
100604
|
-
const sessions =
|
|
101675
|
+
const sessions = readSessions();
|
|
101676
|
+
if (sessions === null) return;
|
|
100605
101677
|
const overviews = buildOverviews(sessions);
|
|
100606
101678
|
const prevNames = new Set(prevOverviews.map((s) => s.name));
|
|
100607
101679
|
const currNames = new Set(overviews.map((s) => s.name));
|
|
@@ -101723,6 +102795,11 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
101723
102795
|
initialNativeServerIdentity ? createServerGenerationFencedTmuxRunner(tmuxAuthority, initialNativeServerIdentity) : catalogTmuxRunner
|
|
101724
102796
|
);
|
|
101725
102797
|
const fleetFactsTmuxRunner = initialNativeServerIdentity ? createServerGenerationFencedTmuxAsyncRunner(tmuxAuthority, initialNativeServerIdentity) : createPinnedWorkspaceTmuxAsyncRunner(tmuxAuthority);
|
|
102798
|
+
const defaultServerOrphanWatch = createOrphanedControlClientWatch({
|
|
102799
|
+
selector: tmuxAuthority.socketSelector,
|
|
102800
|
+
serverId: null
|
|
102801
|
+
});
|
|
102802
|
+
void defaultServerOrphanWatch.onOwnership();
|
|
101726
102803
|
const tmuxAuthorityReplaced = createTmuxAuthorityReplacementProbe(
|
|
101727
102804
|
tmuxAuthority,
|
|
101728
102805
|
catalogTmuxRunner
|
|
@@ -102221,6 +103298,14 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102221
103298
|
};
|
|
102222
103299
|
terminalInventoryRuntime = new WorkspaceTerminalInventoryRuntime(terminalRuntimeOptions);
|
|
102223
103300
|
await terminalInventoryRuntime.whenReady();
|
|
103301
|
+
const snapshotInventory = terminalInventoryRuntime;
|
|
103302
|
+
startDaemonCrashSnapshot(
|
|
103303
|
+
daemonCrashSnapshotStart(
|
|
103304
|
+
opts,
|
|
103305
|
+
(args) => fleetFactsTmuxRunner(args),
|
|
103306
|
+
() => ["disposed", "failed"].includes(snapshotInventory.lifecycleState())
|
|
103307
|
+
)
|
|
103308
|
+
);
|
|
102224
103309
|
const getTerminalAttachmentRuntime = () => {
|
|
102225
103310
|
if (terminalAttachmentRuntime) return terminalAttachmentRuntime;
|
|
102226
103311
|
terminalAttachmentRuntime = createNativeTerminalAttachmentRuntime({
|
|
@@ -102381,7 +103466,12 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102381
103466
|
resolveNativeSurfaceContext: createNativeSurfaceContextResolver({
|
|
102382
103467
|
generation: instanceId,
|
|
102383
103468
|
registry: workspaceRegistry,
|
|
102384
|
-
catalog: createNativeTmuxServerCatalog(
|
|
103469
|
+
catalog: createNativeTmuxServerCatalog(
|
|
103470
|
+
workspaceRegistry,
|
|
103471
|
+
fleetFactsTmuxRunner,
|
|
103472
|
+
void 0,
|
|
103473
|
+
defaultServerOrphanWatch.onTrouble
|
|
103474
|
+
),
|
|
102385
103475
|
inventory: terminalInventoryRuntime,
|
|
102386
103476
|
run: (args, signal) => fleetFactsTmuxRunner(args, signal),
|
|
102387
103477
|
assertOpen: () => {
|
|
@@ -102392,7 +103482,12 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102392
103482
|
resolvePaneEditorContext: createPaneEditorContextResolver({
|
|
102393
103483
|
generation: instanceId,
|
|
102394
103484
|
registry: workspaceRegistry,
|
|
102395
|
-
catalog: createNativeTmuxServerCatalog(
|
|
103485
|
+
catalog: createNativeTmuxServerCatalog(
|
|
103486
|
+
workspaceRegistry,
|
|
103487
|
+
fleetFactsTmuxRunner,
|
|
103488
|
+
void 0,
|
|
103489
|
+
defaultServerOrphanWatch.onTrouble
|
|
103490
|
+
),
|
|
102396
103491
|
inventory: terminalInventoryRuntime,
|
|
102397
103492
|
assertOpen: () => {
|
|
102398
103493
|
if (defaultEditorContextRetired || serverOwners?.defaultRetired || !initialNativeServerIdentity || terminalInventoryRuntime?.lifecycleState() !== "ready")
|
|
@@ -102403,7 +103498,12 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102403
103498
|
generation: instanceId,
|
|
102404
103499
|
run: fleetFactsTmuxRunner,
|
|
102405
103500
|
registry: workspaceRegistry,
|
|
102406
|
-
catalog: createNativeTmuxServerCatalog(
|
|
103501
|
+
catalog: createNativeTmuxServerCatalog(
|
|
103502
|
+
workspaceRegistry,
|
|
103503
|
+
fleetFactsTmuxRunner,
|
|
103504
|
+
void 0,
|
|
103505
|
+
defaultServerOrphanWatch.onTrouble
|
|
103506
|
+
),
|
|
102407
103507
|
inventory: terminalInventoryRuntime,
|
|
102408
103508
|
assertOpen: () => {
|
|
102409
103509
|
if (defaultEditorContextRetired || serverOwners?.defaultRetired || !initialNativeServerIdentity || terminalInventoryRuntime?.lifecycleState() !== "ready")
|
|
@@ -102414,19 +103514,31 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102414
103514
|
generation: instanceId,
|
|
102415
103515
|
run: fleetFactsTmuxRunner,
|
|
102416
103516
|
registry: workspaceRegistry,
|
|
102417
|
-
catalog: createNativeTmuxServerCatalog(
|
|
103517
|
+
catalog: createNativeTmuxServerCatalog(
|
|
103518
|
+
workspaceRegistry,
|
|
103519
|
+
fleetFactsTmuxRunner,
|
|
103520
|
+
void 0,
|
|
103521
|
+
defaultServerOrphanWatch.onTrouble
|
|
103522
|
+
),
|
|
102418
103523
|
inventory: terminalInventoryRuntime,
|
|
102419
103524
|
assertOpen: () => {
|
|
102420
103525
|
if (defaultEditorContextRetired || serverOwners?.defaultRetired || !initialNativeServerIdentity || terminalInventoryRuntime?.lifecycleState() !== "ready")
|
|
102421
103526
|
throw new Error("Default reader owner is unavailable");
|
|
102422
103527
|
}
|
|
102423
103528
|
}),
|
|
102424
|
-
catalog: createNativeTmuxServerCatalog(
|
|
103529
|
+
catalog: createNativeTmuxServerCatalog(
|
|
103530
|
+
workspaceRegistry,
|
|
103531
|
+
fleetFactsTmuxRunner,
|
|
103532
|
+
void 0,
|
|
103533
|
+
defaultServerOrphanWatch.onTrouble
|
|
103534
|
+
),
|
|
102425
103535
|
readWindowSplitLayout: async (workspaceName, input) => {
|
|
102426
103536
|
const target = WindowLinkTargetSchemaZ.parse(input);
|
|
102427
103537
|
const sessions = await createNativeTmuxServerCatalog(
|
|
102428
103538
|
workspaceRegistry,
|
|
102429
|
-
fleetFactsTmuxRunner
|
|
103539
|
+
fleetFactsTmuxRunner,
|
|
103540
|
+
void 0,
|
|
103541
|
+
defaultServerOrphanWatch.onTrouble
|
|
102430
103542
|
)();
|
|
102431
103543
|
const sessionName2 = workspaceRegistry.get(workspaceName)?.sessionName;
|
|
102432
103544
|
if (!sessionName2 || !sessions.some(
|
|
@@ -102438,7 +103550,12 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102438
103550
|
},
|
|
102439
103551
|
openAgent: async (liveSessionId, observed) => {
|
|
102440
103552
|
const target = observedAgentSchema.parse(observed);
|
|
102441
|
-
await createNativeTmuxServerCatalog(
|
|
103553
|
+
await createNativeTmuxServerCatalog(
|
|
103554
|
+
workspaceRegistry,
|
|
103555
|
+
fleetFactsTmuxRunner,
|
|
103556
|
+
void 0,
|
|
103557
|
+
defaultServerOrphanWatch.onTrouble
|
|
103558
|
+
)();
|
|
102442
103559
|
try {
|
|
102443
103560
|
return await defaultSessionOpener.openAgent(liveSessionId, target);
|
|
102444
103561
|
} finally {
|
|
@@ -102446,7 +103563,12 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102446
103563
|
}
|
|
102447
103564
|
},
|
|
102448
103565
|
openSession: async (liveSessionId) => {
|
|
102449
|
-
await createNativeTmuxServerCatalog(
|
|
103566
|
+
await createNativeTmuxServerCatalog(
|
|
103567
|
+
workspaceRegistry,
|
|
103568
|
+
fleetFactsTmuxRunner,
|
|
103569
|
+
void 0,
|
|
103570
|
+
defaultServerOrphanWatch.onTrouble
|
|
103571
|
+
)();
|
|
102450
103572
|
const result2 = await defaultSessionOpener.openSession(liveSessionId);
|
|
102451
103573
|
terminalInventoryRuntime.invalidate();
|
|
102452
103574
|
return result2;
|
|
@@ -103022,6 +104144,7 @@ var init_daemon_embed = __esm({
|
|
|
103022
104144
|
"use strict";
|
|
103023
104145
|
init_tmux_pane_reader();
|
|
103024
104146
|
init_tmux_native_browser();
|
|
104147
|
+
init_daemon_crash_snapshot();
|
|
103025
104148
|
init_native_surface_context();
|
|
103026
104149
|
init_native_surface_provider();
|
|
103027
104150
|
init_src2();
|
|
@@ -103079,6 +104202,7 @@ var init_daemon_embed = __esm({
|
|
|
103079
104202
|
init_app_window_mutation2();
|
|
103080
104203
|
init_workspace_multiplexer_verbs();
|
|
103081
104204
|
init_tmux_external_interaction_observer();
|
|
104205
|
+
init_orphaned_control_clients();
|
|
103082
104206
|
init_tmux_interaction_observation_handler();
|
|
103083
104207
|
init_interaction_receipt_journal();
|
|
103084
104208
|
init_interaction_observation_status();
|
|
@@ -103116,9 +104240,11 @@ var init_daemon_embed = __esm({
|
|
|
103116
104240
|
// packages/daemon/src/lib/headless-daemon.ts
|
|
103117
104241
|
var headless_daemon_exports = {};
|
|
103118
104242
|
__export(headless_daemon_exports, {
|
|
104243
|
+
OWN_SERVER_PROOF_RESTARTS: () => OWN_SERVER_PROOF_RESTARTS,
|
|
103119
104244
|
SIGNAL_STOP_DEADLINE_MS: () => SIGNAL_STOP_DEADLINE_MS,
|
|
103120
104245
|
SIGNAL_STOP_MAX_MS: () => SIGNAL_STOP_MAX_MS,
|
|
103121
104246
|
SIGNAL_STOP_TIMEOUT_EXIT_CODE: () => SIGNAL_STOP_TIMEOUT_EXIT_CODE,
|
|
104247
|
+
ownServerProofRetry: () => ownServerProofRetry,
|
|
103122
104248
|
runHeadlessDaemon: () => runHeadlessDaemon
|
|
103123
104249
|
});
|
|
103124
104250
|
function activeResourceCounts() {
|
|
@@ -103192,8 +104318,16 @@ async function assertAttachableDaemon(deps2, info, options) {
|
|
|
103192
104318
|
);
|
|
103193
104319
|
}
|
|
103194
104320
|
assertIdentityMatches(info, identity4);
|
|
104321
|
+
let first = true;
|
|
103195
104322
|
await assertCanonicalDaemonServerIntent(info, options.tmuxServerIntent ?? null, {
|
|
103196
|
-
|
|
104323
|
+
...deps2.serverProof ? { serverProof: deps2.serverProof } : {},
|
|
104324
|
+
identity: async () => {
|
|
104325
|
+
if (first) {
|
|
104326
|
+
first = false;
|
|
104327
|
+
return identity4;
|
|
104328
|
+
}
|
|
104329
|
+
return deps2.probeCanonicalDaemonIdentity(info, void 0, true);
|
|
104330
|
+
}
|
|
103197
104331
|
});
|
|
103198
104332
|
const health = await deps2.probeCanonicalDaemonHealth(info);
|
|
103199
104333
|
if (!health) {
|
|
@@ -103241,8 +104375,15 @@ async function findLiveCanonicalDaemon(deps2, options, predecessor) {
|
|
|
103241
104375
|
function delay3(ms) {
|
|
103242
104376
|
return new Promise((resolve47) => setTimeout(resolve47, ms));
|
|
103243
104377
|
}
|
|
104378
|
+
function ownServerProofRetry(error, state) {
|
|
104379
|
+
if (!(error instanceof DaemonBootstrapError) || error.reason !== "tmux-server-unproven" || state.restarts >= OWN_SERVER_PROOF_RESTARTS)
|
|
104380
|
+
return null;
|
|
104381
|
+
return { delayMs: 250 * (state.restarts + 1) };
|
|
104382
|
+
}
|
|
103244
104383
|
function isTransientAttachabilityError(error) {
|
|
103245
|
-
return error instanceof IdeError && (error.code === "DAEMON_IDENTITY_UNAVAILABLE" || error.code === "DAEMON_UNHEALTHY")
|
|
104384
|
+
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
|
|
104385
|
+
// later (soak o3: the daemon exited at startup instead of waiting).
|
|
104386
|
+
daemonServerProofPending(error);
|
|
103246
104387
|
}
|
|
103247
104388
|
async function waitForAttachableDaemon(deps2, info, options, timeoutMs = DAEMON_ATTACHABILITY_TIMEOUT_MS, shouldAbort = () => false) {
|
|
103248
104389
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -103410,6 +104551,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103410
104551
|
handle = await deps2.startEmbeddedDaemon({
|
|
103411
104552
|
launcher: "headless",
|
|
103412
104553
|
plugins: true,
|
|
104554
|
+
...options.crashSnapshotSource ? { crashSnapshotSource: options.crashSnapshotSource } : {},
|
|
103413
104555
|
...options.supervisionId ? { supervisionId: options.supervisionId, predecessor: lifecycle.predecessor } : {},
|
|
103414
104556
|
...restoreTmuxWorkspaces ? { restoreTmuxWorkspaces: true } : {},
|
|
103415
104557
|
port,
|
|
@@ -103530,7 +104672,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103530
104672
|
deps2,
|
|
103531
104673
|
info,
|
|
103532
104674
|
options,
|
|
103533
|
-
DAEMON_ATTACHABILITY_TIMEOUT_MS,
|
|
104675
|
+
deps2.attachabilityTimeoutMs ?? DAEMON_ATTACHABILITY_TIMEOUT_MS,
|
|
103534
104676
|
() => signalRequested
|
|
103535
104677
|
);
|
|
103536
104678
|
options.onOwnedReady?.(info);
|
|
@@ -103540,8 +104682,29 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103540
104682
|
if (stopFailure) throw stopFailure;
|
|
103541
104683
|
return "stopped";
|
|
103542
104684
|
}
|
|
103543
|
-
|
|
104685
|
+
const retry = ownServerProofRetry(error, {
|
|
104686
|
+
startReason,
|
|
104687
|
+
restarts: lifecycle.ownServerProofRestarts ?? 0
|
|
104688
|
+
});
|
|
104689
|
+
if (!retry) throw error;
|
|
104690
|
+
lifecycle.ownServerProofRestarts = (lifecycle.ownServerProofRestarts ?? 0) + 1;
|
|
104691
|
+
logger.warn(
|
|
104692
|
+
"daemon-lifecycle",
|
|
104693
|
+
"generation could not prove its own tmux server; starting it again",
|
|
104694
|
+
{
|
|
104695
|
+
generation,
|
|
104696
|
+
startReason,
|
|
104697
|
+
reason: error.reason,
|
|
104698
|
+
restart: lifecycle.ownServerProofRestarts,
|
|
104699
|
+
delayMs: retry.delayMs
|
|
104700
|
+
}
|
|
104701
|
+
);
|
|
104702
|
+
await (deps2.delay ?? delay3)(retry.delayMs);
|
|
104703
|
+
if (signalRequested) return "stopped";
|
|
104704
|
+
lifecycle.startReason = "tmux-server-unproven";
|
|
104705
|
+
return "restart";
|
|
103544
104706
|
}
|
|
104707
|
+
lifecycle.ownServerProofRestarts = 0;
|
|
103545
104708
|
lifecycle.lastPort = info.port;
|
|
103546
104709
|
emitStatus(deps2, options.json === true, "ready", info);
|
|
103547
104710
|
logger[generation > 1 ? "info" : "debug"]("daemon-lifecycle", "generation ready", {
|
|
@@ -103584,7 +104747,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103584
104747
|
deps2.offSignal("SIGTERM", onSigterm);
|
|
103585
104748
|
}
|
|
103586
104749
|
}
|
|
103587
|
-
var SIGNAL_STOP_DEADLINE_MS, SIGNAL_STOP_MAX_MS, SIGNAL_STOP_TIMEOUT_EXIT_CODE, defaultDependencies2, DAEMON_ATTACHABILITY_TIMEOUT_MS, DAEMON_ATTACHABILITY_POLL_MS;
|
|
104750
|
+
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;
|
|
103588
104751
|
var init_headless_daemon = __esm({
|
|
103589
104752
|
"packages/daemon/src/lib/headless-daemon.ts"() {
|
|
103590
104753
|
"use strict";
|
|
@@ -103593,6 +104756,7 @@ var init_headless_daemon = __esm({
|
|
|
103593
104756
|
init_canonical_daemon();
|
|
103594
104757
|
init_src2();
|
|
103595
104758
|
init_daemon_embed();
|
|
104759
|
+
init_bootstrap_coordinator();
|
|
103596
104760
|
init_errors2();
|
|
103597
104761
|
init_log();
|
|
103598
104762
|
init_auth_token();
|
|
@@ -103611,6 +104775,7 @@ var init_headless_daemon = __esm({
|
|
|
103611
104775
|
onSignal: (signal, listener) => process.on(signal, listener),
|
|
103612
104776
|
offSignal: (signal, listener) => process.off(signal, listener)
|
|
103613
104777
|
};
|
|
104778
|
+
OWN_SERVER_PROOF_RESTARTS = 4;
|
|
103614
104779
|
DAEMON_ATTACHABILITY_TIMEOUT_MS = 15e3;
|
|
103615
104780
|
DAEMON_ATTACHABILITY_POLL_MS = 25;
|
|
103616
104781
|
}
|
|
@@ -103951,10 +105116,10 @@ __export(open_browser_exports, {
|
|
|
103951
105116
|
});
|
|
103952
105117
|
import { accessSync as accessSync11, constants as constants20, realpathSync as realpathSync31, statSync as statSync29 } from "node:fs";
|
|
103953
105118
|
import { delimiter as delimiter5, isAbsolute as isAbsolute35, join as join63, resolve as resolve38 } from "node:path";
|
|
103954
|
-
import { homedir as
|
|
105119
|
+
import { homedir as homedir10 } from "node:os";
|
|
103955
105120
|
function resolveTerminalBrowser(environment = process.env, platform2 = process.platform) {
|
|
103956
105121
|
const configured = environment.TMUX_IDE_TERMINAL_BROWSER_BIN;
|
|
103957
|
-
const home = environment.HOME ??
|
|
105122
|
+
const home = environment.HOME ?? homedir10();
|
|
103958
105123
|
const bundled = platform2 === "darwin" && isAbsolute35(home) ? [
|
|
103959
105124
|
join63(
|
|
103960
105125
|
home,
|
|
@@ -104312,7 +105477,7 @@ var init_attach = __esm({
|
|
|
104312
105477
|
});
|
|
104313
105478
|
|
|
104314
105479
|
// packages/daemon/src/lib/daemon-service-manager.ts
|
|
104315
|
-
import { execFile as
|
|
105480
|
+
import { execFile as execFile16 } from "node:child_process";
|
|
104316
105481
|
function createDaemonServiceManager(plan, run = runCommand) {
|
|
104317
105482
|
const launchd = plan.manager === "launchd";
|
|
104318
105483
|
const file = launchd ? "/bin/launchctl" : "systemctl";
|
|
@@ -104409,7 +105574,7 @@ var init_daemon_service_manager = __esm({
|
|
|
104409
105574
|
"packages/daemon/src/lib/daemon-service-manager.ts"() {
|
|
104410
105575
|
"use strict";
|
|
104411
105576
|
runCommand = (file, args) => new Promise((resolve47) => {
|
|
104412
|
-
|
|
105577
|
+
execFile16(
|
|
104413
105578
|
file,
|
|
104414
105579
|
[...args],
|
|
104415
105580
|
{
|
|
@@ -104581,7 +105746,7 @@ import {
|
|
|
104581
105746
|
} from "node:fs";
|
|
104582
105747
|
import { randomUUID as randomUUID53 } from "node:crypto";
|
|
104583
105748
|
import { dirname as dirname49, join as join65 } from "node:path";
|
|
104584
|
-
import { homedir as
|
|
105749
|
+
import { homedir as homedir11 } from "node:os";
|
|
104585
105750
|
import { z as z143 } from "zod";
|
|
104586
105751
|
function defaults() {
|
|
104587
105752
|
const namespace = resolveRuntimeNamespace();
|
|
@@ -104589,7 +105754,7 @@ function defaults() {
|
|
|
104589
105754
|
plan: (executable) => planDaemonService({
|
|
104590
105755
|
platform: process.platform,
|
|
104591
105756
|
uid: process.getuid?.() ?? 0,
|
|
104592
|
-
home:
|
|
105757
|
+
home: homedir11(),
|
|
104593
105758
|
configHome: process.env.XDG_CONFIG_HOME || void 0,
|
|
104594
105759
|
executable,
|
|
104595
105760
|
path: process.env.PATH || "/usr/bin:/bin",
|
|
@@ -105569,7 +106734,7 @@ function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
|
105569
106734
|
const upgrade = running ? "; run `tmux-ide servers upgrade` to move it to tmux-ide's own tmux" : "";
|
|
105570
106735
|
const details = {
|
|
105571
106736
|
full: "bundled tmux: full features",
|
|
105572
|
-
stock: `stock tmux: reduced features${upgrade}`,
|
|
106737
|
+
stock: `stock tmux: reduced features (tab positions in saved output are reconstructed)${upgrade}`,
|
|
105573
106738
|
older: `older tmux-ide tmux: reduced features${upgrade}`,
|
|
105574
106739
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
105575
106740
|
"no-server": "could not read the tmux server's features",
|
|
@@ -105600,14 +106765,23 @@ function plainTmuxRow(pathTmux, bundled) {
|
|
|
105600
106765
|
optional: true
|
|
105601
106766
|
};
|
|
105602
106767
|
}
|
|
105603
|
-
function snapshotRow(snapshot3, liveSessions2, nowMs) {
|
|
106768
|
+
function snapshotRow(snapshot3, liveSessions2, nowMs, serverStartMs = null) {
|
|
105604
106769
|
const label4 = "crash snapshot (restore)";
|
|
105605
|
-
const hint = "
|
|
106770
|
+
const hint = "The background service writes it within a minute while it runs; without the service, `tmux-ide adopt --all` starts a writer";
|
|
105606
106771
|
if (!snapshot3) {
|
|
105607
106772
|
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 };
|
|
105608
106773
|
}
|
|
105609
106774
|
const ageMs = nowMs - Date.parse(snapshot3.savedAt);
|
|
105610
106775
|
const age = ageMs >= DAY_MS ? `${Math.floor(ageMs / DAY_MS)} days old` : `${Math.max(0, Math.round(ageMs / 6e4))} min old`;
|
|
106776
|
+
if (liveSessions2 && serverStartMs !== null && snapshotIsRestorePoint(snapshot3, { serverStartMs, sessions: liveSessions2 })) {
|
|
106777
|
+
const gone = snapshot3.sessions.map((session) => session.name).filter((name) => !liveSessions2.includes(name));
|
|
106778
|
+
return {
|
|
106779
|
+
label: label4,
|
|
106780
|
+
pass: false,
|
|
106781
|
+
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`,
|
|
106782
|
+
optional: true
|
|
106783
|
+
};
|
|
106784
|
+
}
|
|
105611
106785
|
const saved = new Set(snapshot3.sessions.map((session) => session.name));
|
|
105612
106786
|
const missing = (liveSessions2 ?? []).filter((name) => !saved.has(name));
|
|
105613
106787
|
if (missing.length)
|
|
@@ -105639,11 +106813,29 @@ function safeBundledTmux() {
|
|
|
105639
106813
|
return null;
|
|
105640
106814
|
}
|
|
105641
106815
|
}
|
|
106816
|
+
function doctorTmuxServer() {
|
|
106817
|
+
const socketPath = process.env[TMUX_SOCKET_PATH_ENV];
|
|
106818
|
+
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
106819
|
+
return socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
106820
|
+
}
|
|
106821
|
+
function liveServerStartMs() {
|
|
106822
|
+
try {
|
|
106823
|
+
const server = doctorTmuxServer();
|
|
106824
|
+
const seconds = Number(
|
|
106825
|
+
execFileSync23(resolveTmuxExecutable(), [...server, "display-message", "-p", "#{start_time}"], {
|
|
106826
|
+
encoding: "utf8",
|
|
106827
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
106828
|
+
timeout: 3e3
|
|
106829
|
+
}).trim()
|
|
106830
|
+
);
|
|
106831
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds * 1e3 : null;
|
|
106832
|
+
} catch {
|
|
106833
|
+
return null;
|
|
106834
|
+
}
|
|
106835
|
+
}
|
|
105642
106836
|
function liveListableSessions() {
|
|
105643
106837
|
try {
|
|
105644
|
-
const
|
|
105645
|
-
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
105646
|
-
const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
106838
|
+
const server = doctorTmuxServer();
|
|
105647
106839
|
return execFileSync23(
|
|
105648
106840
|
resolveTmuxExecutable(),
|
|
105649
106841
|
[...server, "list-sessions", "-F", "#{session_name}"],
|
|
@@ -105757,7 +106949,7 @@ async function doctor({
|
|
|
105757
106949
|
} catch {
|
|
105758
106950
|
}
|
|
105759
106951
|
checks.push(plainTmuxRow(firstOnPath("tmux"), safeBundledTmux()));
|
|
105760
|
-
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now()));
|
|
106952
|
+
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now(), liveServerStartMs()));
|
|
105761
106953
|
checks.push(nodeVersionRow(process.versions.node));
|
|
105762
106954
|
checks.push(
|
|
105763
106955
|
check(
|
|
@@ -111189,6 +112381,27 @@ var init_worktree = __esm({
|
|
|
111189
112381
|
}
|
|
111190
112382
|
});
|
|
111191
112383
|
|
|
112384
|
+
// packages/daemon/src/lib/update-daemon-outcome.ts
|
|
112385
|
+
var update_daemon_outcome_exports = {};
|
|
112386
|
+
__export(update_daemon_outcome_exports, {
|
|
112387
|
+
daemonUpdateOutcome: () => daemonUpdateOutcome
|
|
112388
|
+
});
|
|
112389
|
+
function daemonUpdateOutcome(running, cliVersion) {
|
|
112390
|
+
if (compareProductVersions(running.productVersion, cliVersion) !== 1)
|
|
112391
|
+
return { status: "ready", message: `Daemon ready: ${running.productVersion}` };
|
|
112392
|
+
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`;
|
|
112393
|
+
return {
|
|
112394
|
+
status: "kept-newer",
|
|
112395
|
+
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}.`
|
|
112396
|
+
};
|
|
112397
|
+
}
|
|
112398
|
+
var init_update_daemon_outcome = __esm({
|
|
112399
|
+
"packages/daemon/src/lib/update-daemon-outcome.ts"() {
|
|
112400
|
+
"use strict";
|
|
112401
|
+
init_semver();
|
|
112402
|
+
}
|
|
112403
|
+
});
|
|
112404
|
+
|
|
111192
112405
|
// packages/daemon/src/lib/managed-installer-update.ts
|
|
111193
112406
|
import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync48, realpathSync as realpathSync37, rmSync as rmSync10 } from "node:fs";
|
|
111194
112407
|
import { dirname as dirname57, join as join73 } from "node:path";
|
|
@@ -111380,8 +112593,13 @@ function planUpdate(input) {
|
|
|
111380
112593
|
guidance: guidance[method]
|
|
111381
112594
|
};
|
|
111382
112595
|
}
|
|
111383
|
-
function renderPlan2(plan, {
|
|
111384
|
-
|
|
112596
|
+
function renderPlan2(plan, {
|
|
112597
|
+
current,
|
|
112598
|
+
latest,
|
|
112599
|
+
dryRun,
|
|
112600
|
+
source = "registry"
|
|
112601
|
+
}) {
|
|
112602
|
+
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)`;
|
|
111385
112603
|
return [
|
|
111386
112604
|
status2,
|
|
111387
112605
|
"",
|
|
@@ -111391,11 +112609,19 @@ function renderPlan2(plan, { current, latest, dryRun }) {
|
|
|
111391
112609
|
"After updating, relaunch the app. Use tmux-ide update --daemon to replace a running daemon with installed code."
|
|
111392
112610
|
].join("\n");
|
|
111393
112611
|
}
|
|
111394
|
-
function
|
|
112612
|
+
function updateFailure(what, error) {
|
|
112613
|
+
const { status: status2, signal, message } = error;
|
|
112614
|
+
const how = typeof status2 === "number" ? `exited with status ${status2}` : typeof signal === "string" ? `was stopped by ${signal}` : `could not run (${String(message).split("\n")[0]})`;
|
|
112615
|
+
return new IdeError(
|
|
112616
|
+
`The update did not finish: ${what} ${how}. Its own message is above. Retry with: tmux-ide update`,
|
|
112617
|
+
{ code: "UPDATE_FAILED", cause: error instanceof Error ? error : void 0 }
|
|
112618
|
+
);
|
|
112619
|
+
}
|
|
112620
|
+
async function runUpdate({ cliDir, dryRun, json: json3 = false }, dependencies = {}) {
|
|
111395
112621
|
if (resolveRuntimeNamespace().development)
|
|
111396
112622
|
throw new Error("Development instances rebuild exact artifacts; package updates are disabled");
|
|
111397
112623
|
const current = (dependencies.currentVersion ?? getCurrentVersion)();
|
|
111398
|
-
const { latest } = (dependencies.status ??
|
|
112624
|
+
const { latest, source: latestSource = "registry" } = await (dependencies.status ?? ((scope2) => refreshUpdateStatus({ ...scope2, fetchLatest: dependencies.fetchLatest })))({ currentVersion: current });
|
|
111399
112625
|
const source = installOrigin(cliDir);
|
|
111400
112626
|
let plan = source.origin === "unknown" ? {
|
|
111401
112627
|
method: "unknown",
|
|
@@ -111431,19 +112657,27 @@ function runUpdate({ cliDir, dryRun, json: json3 = false }, dependencies = {}) {
|
|
|
111431
112657
|
}
|
|
111432
112658
|
}
|
|
111433
112659
|
const output = dependencies.output ?? console.log;
|
|
111434
|
-
if (!json3) output(renderPlan2(plan, { current, latest, dryRun }));
|
|
112660
|
+
if (!json3) output(renderPlan2(plan, { current, latest, dryRun, source: latestSource }));
|
|
111435
112661
|
let executed = false;
|
|
111436
112662
|
if (!dryRun && plan.executable && plan.args) {
|
|
111437
|
-
|
|
111438
|
-
|
|
111439
|
-
|
|
112663
|
+
try {
|
|
112664
|
+
(dependencies.execute ?? execFileSync31)(plan.executable, plan.args, {
|
|
112665
|
+
stdio: json3 ? ["ignore", 2, 2] : "inherit"
|
|
112666
|
+
});
|
|
112667
|
+
} catch (error) {
|
|
112668
|
+
throw updateFailure([plan.executable, ...plan.args].join(" "), error);
|
|
112669
|
+
}
|
|
111440
112670
|
executed = true;
|
|
111441
112671
|
}
|
|
111442
112672
|
if (!dryRun && plan.installerPrefix && plan.channel) {
|
|
111443
|
-
|
|
112673
|
+
try {
|
|
112674
|
+
runManagedInstallerUpdate(plan.installerPrefix, plan.channel, json3, dependencies.execute);
|
|
112675
|
+
} catch (error) {
|
|
112676
|
+
throw updateFailure("the installer", error);
|
|
112677
|
+
}
|
|
111444
112678
|
executed = true;
|
|
111445
112679
|
}
|
|
111446
|
-
if (json3) output(JSON.stringify({ ...plan, current, latest, dryRun, executed }));
|
|
112680
|
+
if (json3) output(JSON.stringify({ ...plan, current, latest, latestSource, dryRun, executed }));
|
|
111447
112681
|
return plan;
|
|
111448
112682
|
}
|
|
111449
112683
|
var UPDATE_COMMANDS;
|
|
@@ -111454,6 +112688,7 @@ var init_update = __esm({
|
|
|
111454
112688
|
init_runtime_namespace();
|
|
111455
112689
|
init_semver();
|
|
111456
112690
|
init_update_check();
|
|
112691
|
+
init_errors2();
|
|
111457
112692
|
init_install_origin();
|
|
111458
112693
|
UPDATE_COMMANDS = {
|
|
111459
112694
|
npm: "npm install -g tmux-ide@latest",
|
|
@@ -111713,6 +112948,7 @@ init_compiled();
|
|
|
111713
112948
|
init_errors2();
|
|
111714
112949
|
init_output();
|
|
111715
112950
|
init_state_home();
|
|
112951
|
+
init_invocation_directory();
|
|
111716
112952
|
init_hosted();
|
|
111717
112953
|
configureTmuxClientResolver(resolveOrdinaryTmuxClient);
|
|
111718
112954
|
if (process.argv[2] === "__plugin-host") {
|
|
@@ -112085,7 +113321,7 @@ Install bun (https://bun.sh) \u2014 the TUI surfaces run on it. Sources ship wit
|
|
|
112085
113321
|
}
|
|
112086
113322
|
}
|
|
112087
113323
|
const env = openTuiLaunchEnvironment(process.env, {
|
|
112088
|
-
TMUX_IDE_CWD:
|
|
113324
|
+
TMUX_IDE_CWD: invocationDirectory(),
|
|
112089
113325
|
TMUX_IDE_CLI: nodeCliPath,
|
|
112090
113326
|
...automaticDiagnosticLog ? {
|
|
112091
113327
|
TMUX_IDE_TUI_LOG: automaticDiagnosticLog,
|
|
@@ -112176,7 +113412,7 @@ Install bun (https://bun.sh) \u2014 the TUI surfaces run on it. Sources ship wit
|
|
|
112176
113412
|
launch2.bin,
|
|
112177
113413
|
launch2.argv,
|
|
112178
113414
|
hostedEnvVars({
|
|
112179
|
-
cwd:
|
|
113415
|
+
cwd: invocationDirectory(),
|
|
112180
113416
|
cli: nodeCliPath,
|
|
112181
113417
|
path: process.env.PATH,
|
|
112182
113418
|
home: process.env.TMUX_IDE_HOME,
|
|
@@ -112371,7 +113607,10 @@ try {
|
|
|
112371
113607
|
port: values.port,
|
|
112372
113608
|
json: json2,
|
|
112373
113609
|
expectedVersion: pkg.version,
|
|
112374
|
-
supervisionId: values.supervised
|
|
113610
|
+
supervisionId: values.supervised,
|
|
113611
|
+
// The crash snapshot's file and builder live in the chrome adapter,
|
|
113612
|
+
// which the daemon engine may not import (#783).
|
|
113613
|
+
crashSnapshotSource: (await Promise.resolve().then(() => (init_snapshot2(), snapshot_exports))).fleetCrashSnapshotSource
|
|
112375
113614
|
});
|
|
112376
113615
|
await new Promise((resolveFlush) => process.stdout.write("", resolveFlush));
|
|
112377
113616
|
process.exit(0);
|
|
@@ -113057,8 +114296,8 @@ try {
|
|
|
113057
114296
|
process.exit(1);
|
|
113058
114297
|
}
|
|
113059
114298
|
const teams = await Promise.resolve().then(() => (init_claude_agent_teams(), claude_agent_teams_exports));
|
|
113060
|
-
const { homedir:
|
|
113061
|
-
const tilde = (text2) => text2.replaceAll(`${
|
|
114299
|
+
const { homedir: homedir12 } = await import("node:os");
|
|
114300
|
+
const tilde = (text2) => text2.replaceAll(`${homedir12()}/`, "~/");
|
|
113062
114301
|
if (action === "status") {
|
|
113063
114302
|
const status2 = teams.claudeAgentTeamsStatus();
|
|
113064
114303
|
if (json2) console.log(JSON.stringify(status2, null, 2));
|
|
@@ -113615,13 +114854,25 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
|
|
|
113615
114854
|
const current = inspectCanonicalDaemonInfo2();
|
|
113616
114855
|
if (current.status !== "valid")
|
|
113617
114856
|
throw new IdeError("Daemon upgrade did not publish a current owner");
|
|
114857
|
+
const cliVersion = (await Promise.resolve().then(() => __toESM(require_package(), 1))).version;
|
|
114858
|
+
const outcome = (await Promise.resolve().then(() => (init_update_daemon_outcome(), update_daemon_outcome_exports))).daemonUpdateOutcome(
|
|
114859
|
+
{
|
|
114860
|
+
productVersion: current.info.productVersion,
|
|
114861
|
+
pid: current.info.pid,
|
|
114862
|
+
supervised: Boolean(current.info.supervisionId),
|
|
114863
|
+
embedded: current.info.provenance?.launcher === "embedded"
|
|
114864
|
+
},
|
|
114865
|
+
cliVersion
|
|
114866
|
+
);
|
|
113618
114867
|
console.log(
|
|
113619
114868
|
json2 ? JSON.stringify({
|
|
113620
114869
|
ok: true,
|
|
113621
|
-
status:
|
|
114870
|
+
status: outcome.status,
|
|
113622
114871
|
productVersion: current.info.productVersion,
|
|
113623
|
-
instanceId: current.info.instanceId
|
|
113624
|
-
|
|
114872
|
+
instanceId: current.info.instanceId,
|
|
114873
|
+
// The installer prints the guidance when it updates the daemon.
|
|
114874
|
+
...outcome.status === "kept-newer" ? { cliVersion, message: outcome.message } : {}
|
|
114875
|
+
}) : outcome.message
|
|
113625
114876
|
);
|
|
113626
114877
|
break;
|
|
113627
114878
|
}
|
|
@@ -113659,7 +114910,7 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
|
|
|
113659
114910
|
}
|
|
113660
114911
|
const { runUpdate: runUpdate2 } = await Promise.resolve().then(() => (init_update(), update_exports));
|
|
113661
114912
|
const dryRun = values["dry-run"] === true;
|
|
113662
|
-
runUpdate2({ cliDir: __dirname5, dryRun, json: json2 });
|
|
114913
|
+
await runUpdate2({ cliDir: __dirname5, dryRun, json: json2 });
|
|
113663
114914
|
break;
|
|
113664
114915
|
}
|
|
113665
114916
|
case "skill-sync": {
|