tmux-ide 2.9.24 → 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 +1352 -350
- 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/doctor.js +46 -10
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +20 -2
- package/packages/daemon/dist/lib/daemon-crash-snapshot.js +118 -0
- package/packages/daemon/dist/lib/daemon-embed.js +6 -0
- package/packages/daemon/dist/lib/headless-daemon.js +63 -6
- package/packages/daemon/dist/lib/invocation-directory.js +20 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +22 -6
- package/packages/daemon/dist/lib/tmux-client-execution.js +12 -3
- package/packages/daemon/dist/lib/update-check.js +18 -0
- package/packages/daemon/dist/lib/update-daemon-outcome.js +31 -0
- package/packages/daemon/dist/lib/update.js +39 -14
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/terminal/graphics/kitty-graphics.js +16 -4
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +26 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +25 -1
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +741 -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/src/command-center/discovery.ts +24 -4
- package/packages/daemon/src/command-center/server.ts +67 -67
- package/packages/daemon/src/doctor.ts +50 -9
- package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +31 -5
- package/packages/daemon/src/lib/daemon-crash-snapshot.ts +175 -0
- package/packages/daemon/src/lib/daemon-embed.ts +22 -0
- package/packages/daemon/src/lib/headless-daemon.ts +88 -7
- package/packages/daemon/src/lib/invocation-directory.ts +21 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +25 -7
- package/packages/daemon/src/lib/tmux-client-execution.ts +14 -5
- package/packages/daemon/src/lib/update-check.ts +34 -0
- package/packages/daemon/src/lib/update-daemon-outcome.ts +42 -0
- package/packages/daemon/src/lib/update.ts +58 -16
- package/packages/daemon/src/terminal/graphics/kitty-graphics.ts +22 -6
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +27 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +30 -1
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +811 -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-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|";
|
|
@@ -34828,10 +35078,35 @@ var init_session_channel = __esm({
|
|
|
34828
35078
|
}
|
|
34829
35079
|
this.input.flush();
|
|
34830
35080
|
this.clearWindowViewports();
|
|
34831
|
-
this.
|
|
35081
|
+
const target = this.attachedIdentity?.runtimeSessionId ?? `=${this.opts.session}`;
|
|
35082
|
+
this.restoreWindowSizing(target);
|
|
34832
35083
|
this.io.send(`refresh-client -C ${cols}x${rows}${this.cellPixelSuffix()}`);
|
|
35084
|
+
this.reclaimWindowSize(target);
|
|
34833
35085
|
this.clientViewport = { cols, rows };
|
|
34834
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
|
+
}
|
|
34835
35110
|
clientViewport = null;
|
|
34836
35111
|
cellPixels = null;
|
|
34837
35112
|
/** "/WxH" for tmux's refresh-client -C (patched tmux; stock ignores it). */
|
|
@@ -44536,6 +44811,28 @@ var init_mirror_service = __esm({
|
|
|
44536
44811
|
wasPending: this.registeredWindows?.pending() ?? null
|
|
44537
44812
|
});
|
|
44538
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?.();
|
|
44539
44836
|
}
|
|
44540
44837
|
/**
|
|
44541
44838
|
* #764: a failed re-read must not leave every session "being verified"
|
|
@@ -44868,6 +45165,10 @@ var init_mirror_service = __esm({
|
|
|
44868
45165
|
const message = this.windowOwnershipMessage(session);
|
|
44869
45166
|
if (message) throw new Error(message);
|
|
44870
45167
|
}
|
|
45168
|
+
/** Registered-window ownership is being read again; input waits for it. */
|
|
45169
|
+
windowOwnershipPending() {
|
|
45170
|
+
return this.registeredWindows?.pending() ?? false;
|
|
45171
|
+
}
|
|
44871
45172
|
windowOwnershipMessage(session) {
|
|
44872
45173
|
if (this.registeredWindows?.pending())
|
|
44873
45174
|
return "Window ownership is being verified. Retry after session discovery completes.";
|
|
@@ -63521,16 +63822,27 @@ var init_kitty_graphics = __esm({
|
|
|
63521
63822
|
#pending = null;
|
|
63522
63823
|
#nextAnonymous = 2130706432;
|
|
63523
63824
|
#bytes = 0;
|
|
63825
|
+
/** Cell size in thousandths of a device pixel. */
|
|
63524
63826
|
#cellWidth;
|
|
63525
63827
|
#cellHeight;
|
|
63526
63828
|
#budget;
|
|
63527
63829
|
#revision = 0;
|
|
63528
63830
|
constructor(options = {}) {
|
|
63529
|
-
this.#cellWidth = options.cellWidthPx ?? 10;
|
|
63530
|
-
this.#cellHeight = options.cellHeightPx ?? 20;
|
|
63831
|
+
this.#cellWidth = (options.cellWidthPx ?? 10) * 1e3;
|
|
63832
|
+
this.#cellHeight = (options.cellHeightPx ?? 20) * 1e3;
|
|
63531
63833
|
this.#budget = options.budget ?? DEFAULT_KITTY_IMAGE_BUDGET;
|
|
63532
63834
|
this.#budget.register(this);
|
|
63533
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
|
+
}
|
|
63534
63846
|
/** Bumps whenever images or placements change. */
|
|
63535
63847
|
get revision() {
|
|
63536
63848
|
return this.#revision;
|
|
@@ -63646,8 +63958,12 @@ var init_kitty_graphics = __esm({
|
|
|
63646
63958
|
const image = this.#images.get(imageId);
|
|
63647
63959
|
if (!image) return;
|
|
63648
63960
|
this.#used.set(imageId, this.#budget.nextTick());
|
|
63649
|
-
const columns = clampCells(
|
|
63650
|
-
|
|
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
|
+
);
|
|
63651
63967
|
const placementId = int(control, "p");
|
|
63652
63968
|
if (control.get("U") === "1") {
|
|
63653
63969
|
const placements = this.#virtual.get(imageId) ?? /* @__PURE__ */ new Map();
|
|
@@ -63874,6 +64190,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63874
64190
|
"packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts"() {
|
|
63875
64191
|
"use strict";
|
|
63876
64192
|
init_stock_capture_fidelity();
|
|
64193
|
+
init_log();
|
|
63877
64194
|
init_native_seed_backing();
|
|
63878
64195
|
init_src2();
|
|
63879
64196
|
init_src3();
|
|
@@ -63890,6 +64207,9 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
63890
64207
|
#nativeSeedBackingCandidate;
|
|
63891
64208
|
#generation;
|
|
63892
64209
|
#workspaceName;
|
|
64210
|
+
#stockTabsNoted = false;
|
|
64211
|
+
#seedOrdinal = 0;
|
|
64212
|
+
#reconstructedSeed = null;
|
|
63893
64213
|
#semanticPaneId;
|
|
63894
64214
|
#incarnation;
|
|
63895
64215
|
#scrollback;
|
|
@@ -64026,6 +64346,14 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64026
64346
|
currentSeed() {
|
|
64027
64347
|
return this.#needsSeed ? null : this.#seed();
|
|
64028
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
|
+
}
|
|
64029
64357
|
/** Prioritize one future parser admission, independent of diagnostic tracing. */
|
|
64030
64358
|
prioritizeNextWrite() {
|
|
64031
64359
|
if (!this.#closed) this.#prioritizeNextWrite = true;
|
|
@@ -64086,7 +64414,9 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64086
64414
|
async #apply(operation) {
|
|
64087
64415
|
if (this.#closed) return;
|
|
64088
64416
|
if (operation.type === "reseed") {
|
|
64089
|
-
|
|
64417
|
+
const paintCapturedTabs = operation.bootstrap === "painted-capture" && !operation.native;
|
|
64418
|
+
let seedReconstructed;
|
|
64419
|
+
if (paintCapturedTabs && !this.#backend.graphicsCursor)
|
|
64090
64420
|
assertStockCaptureRepresentable(operation.captureChunks ?? operation.chunks);
|
|
64091
64421
|
this.#causalCell?.fail("reseeded");
|
|
64092
64422
|
const nativeCols = operation.nativeCols ?? operation.cols;
|
|
@@ -64105,9 +64435,18 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64105
64435
|
try {
|
|
64106
64436
|
if (operation.native && !replacement.importNativeGrid?.(operation.native))
|
|
64107
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;
|
|
64108
64441
|
for (const chunk of operation.chunks) {
|
|
64109
|
-
|
|
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);
|
|
64110
64448
|
}
|
|
64449
|
+
seedReconstructed = reconstructed;
|
|
64111
64450
|
if (operation.wraparound !== void 0)
|
|
64112
64451
|
replacement.setAuthoritativeWraparound(operation.wraparound);
|
|
64113
64452
|
if (operation.observedModes) replacement.setAuthoritativeModes(operation.observedModes);
|
|
@@ -64133,6 +64472,8 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64133
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;
|
|
64134
64473
|
if (!sameGraphicsBasis) this.#kitty.dropCursorPlacements();
|
|
64135
64474
|
this.#nativeReseedRequested = false;
|
|
64475
|
+
this.#seedOrdinal += 1;
|
|
64476
|
+
this.#reconstructedSeed = seedReconstructed ? this.#seedOrdinal : null;
|
|
64136
64477
|
this.#scrollback = scrollback;
|
|
64137
64478
|
this.#bootstrap = {
|
|
64138
64479
|
kind: operation.bootstrap,
|
|
@@ -64272,6 +64613,42 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64272
64613
|
this.#tail = run.catch(() => void 0);
|
|
64273
64614
|
}, 250);
|
|
64274
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
|
+
}
|
|
64275
64652
|
#writeToBackend(backend2, data) {
|
|
64276
64653
|
if (this.#prioritizeNextWrite) {
|
|
64277
64654
|
this.#prioritizeNextWrite = false;
|
|
@@ -64730,6 +65107,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
64730
65107
|
#historyTimer = null;
|
|
64731
65108
|
#historyChecking = false;
|
|
64732
65109
|
#historyDirty = false;
|
|
65110
|
+
#reconstructedHistoryGap = null;
|
|
64733
65111
|
installOutputTraceReader(reader) {
|
|
64734
65112
|
this.#takeOutputTrace ??= reader;
|
|
64735
65113
|
}
|
|
@@ -64893,6 +65271,10 @@ var init_terminal_replica_owner = __esm({
|
|
|
64893
65271
|
if (current) listener(current);
|
|
64894
65272
|
return this.#interpreter.onGraphics(listener);
|
|
64895
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
|
+
}
|
|
64896
65278
|
/** Image bytes by content digest, while the pane's store still holds them. */
|
|
64897
65279
|
graphicsImage(digest3) {
|
|
64898
65280
|
return this.#interpreter.kittyImages().imageByDigest(digest3) ?? null;
|
|
@@ -64951,7 +65333,17 @@ var init_terminal_replica_owner = __esm({
|
|
|
64951
65333
|
this.#historyDirty || this.#stale || this.#reseed || this.#waitingForGeometryCapture || size === null)
|
|
64952
65334
|
return;
|
|
64953
65335
|
const seed = this.#interpreter.currentSeed();
|
|
64954
|
-
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();
|
|
64955
65347
|
} catch {
|
|
64956
65348
|
} finally {
|
|
64957
65349
|
this.#historyChecking = false;
|
|
@@ -67457,7 +67849,7 @@ function authoredOriginForSurface(surface) {
|
|
|
67457
67849
|
if (surface === "cli") return "cli";
|
|
67458
67850
|
return "gui";
|
|
67459
67851
|
}
|
|
67460
|
-
var emptyListenerDisposal, SessionRuntimeControllerLeaseError, SessionRuntimeRegistry, SessionRuntime, SessionRuntimeConsumerImpl;
|
|
67852
|
+
var emptyListenerDisposal, SessionRuntimeControllerLeaseError, SessionRuntimeInputLifetimeEndedError, SessionRuntimeRegistry, SessionRuntime, SessionRuntimeConsumerImpl;
|
|
67461
67853
|
var init_registry2 = __esm({
|
|
67462
67854
|
"packages/daemon/src/terminal/session-runtime/registry.ts"() {
|
|
67463
67855
|
"use strict";
|
|
@@ -67494,6 +67886,12 @@ var init_registry2 = __esm({
|
|
|
67494
67886
|
}
|
|
67495
67887
|
code;
|
|
67496
67888
|
};
|
|
67889
|
+
SessionRuntimeInputLifetimeEndedError = class extends Error {
|
|
67890
|
+
constructor(message) {
|
|
67891
|
+
super(message);
|
|
67892
|
+
this.name = "SessionRuntimeInputLifetimeEndedError";
|
|
67893
|
+
}
|
|
67894
|
+
};
|
|
67497
67895
|
SessionRuntimeRegistry = class {
|
|
67498
67896
|
generation;
|
|
67499
67897
|
#mirror;
|
|
@@ -67783,6 +68181,10 @@ var init_registry2 = __esm({
|
|
|
67783
68181
|
async verifyWindowOwnership() {
|
|
67784
68182
|
await this.#mirror.verifyRegisteredWindows();
|
|
67785
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
|
+
}
|
|
67786
68188
|
/** Install the bounded registered-session membership reader. */
|
|
67787
68189
|
setRegisteredWindowReader(reader) {
|
|
67788
68190
|
return this.#mirror.setRegisteredWindowReader(reader);
|
|
@@ -68254,6 +68656,8 @@ var init_registry2 = __esm({
|
|
|
68254
68656
|
#consumersByClientId = /* @__PURE__ */ new Map();
|
|
68255
68657
|
#terminalReplicas = /* @__PURE__ */ new Map();
|
|
68256
68658
|
#terminalReplicaClocks = /* @__PURE__ */ new Map();
|
|
68659
|
+
/** The renderer's last reported cell size; every pane's image placements use it. */
|
|
68660
|
+
#cellPixels = null;
|
|
68257
68661
|
#outputTraces;
|
|
68258
68662
|
#outputObservations = /* @__PURE__ */ new Map();
|
|
68259
68663
|
#createTraceCorrelator;
|
|
@@ -68511,7 +68915,8 @@ var init_registry2 = __esm({
|
|
|
68511
68915
|
}) : null;
|
|
68512
68916
|
const started = this.#observability.enabled ? this.#observability.nowMicros() : 0;
|
|
68513
68917
|
const replicaOwner = expectedLifetime ? this.#terminalReplicas.get(semanticPaneId3) : this.#terminalReplicaOwner(semanticPaneId3);
|
|
68514
|
-
if (!replicaOwner)
|
|
68918
|
+
if (!replicaOwner)
|
|
68919
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime unavailable");
|
|
68515
68920
|
if (causalProbe) {
|
|
68516
68921
|
this.#activeCausalCellProbes += 1;
|
|
68517
68922
|
let settled = false;
|
|
@@ -68535,7 +68940,7 @@ var init_registry2 = __esm({
|
|
|
68535
68940
|
}
|
|
68536
68941
|
try {
|
|
68537
68942
|
if (expectedLifetime && (expectedLifetime.generation !== this.generation || this.#terminalReplicas.get(semanticPaneId3) !== replicaOwner || replicaOwner.inputAdmissionIncarnation() !== expectedLifetime.incarnation))
|
|
68538
|
-
throw new
|
|
68943
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime changed");
|
|
68539
68944
|
if (input.kind === "text")
|
|
68540
68945
|
this.#mirror.sendText(
|
|
68541
68946
|
this.session,
|
|
@@ -68635,6 +69040,9 @@ var init_registry2 = __esm({
|
|
|
68635
69040
|
setCellPixels(clientId, width, height, precise) {
|
|
68636
69041
|
this.#assertConnected(clientId);
|
|
68637
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);
|
|
68638
69046
|
}
|
|
68639
69047
|
fitViewportWithAuthority(clientId, lease, cols, rows, semanticWindowId) {
|
|
68640
69048
|
this.assertGeometryAuthority(clientId, lease);
|
|
@@ -68804,6 +69212,12 @@ var init_registry2 = __esm({
|
|
|
68804
69212
|
}
|
|
68805
69213
|
);
|
|
68806
69214
|
owner = candidate;
|
|
69215
|
+
if (this.#cellPixels)
|
|
69216
|
+
owner.setCellPixels(
|
|
69217
|
+
this.#cellPixels.width,
|
|
69218
|
+
this.#cellPixels.height,
|
|
69219
|
+
this.#cellPixels.precise
|
|
69220
|
+
);
|
|
68807
69221
|
this.#terminalReplicas.set(semanticPaneId3, owner);
|
|
68808
69222
|
}
|
|
68809
69223
|
return owner;
|
|
@@ -69415,6 +69829,40 @@ var init_transport_binding = __esm({
|
|
|
69415
69829
|
);
|
|
69416
69830
|
this.#binder.registry.assertExecutionHandle(this.#baseHandle, semanticPaneId3);
|
|
69417
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
|
+
}
|
|
69418
69866
|
openTerminalDelivery(semanticPaneId3, offer, onMessage, deliveryWorkspaceName) {
|
|
69419
69867
|
const address = WorkspaceIdSchemaZ.parse(deliveryWorkspaceName ?? this.session);
|
|
69420
69868
|
this.#assertOpen();
|
|
@@ -76017,6 +76465,26 @@ function rawGraphicsState(state) {
|
|
|
76017
76465
|
placements: state.placements.filter((placement) => kept.has(placement.digest))
|
|
76018
76466
|
};
|
|
76019
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
|
+
}
|
|
76020
76488
|
function concatBytes(chunks) {
|
|
76021
76489
|
if (chunks.length === 0) return new Uint8Array(0);
|
|
76022
76490
|
if (chunks.length === 1) return chunks[0];
|
|
@@ -76039,7 +76507,7 @@ function chunkBytes(data, maxChunk) {
|
|
|
76039
76507
|
}
|
|
76040
76508
|
return chunks;
|
|
76041
76509
|
}
|
|
76042
|
-
var PANE_STREAM_MAX_REDEMPTION_BYTES, PANE_STREAM_MAX_CONTROL_BYTES, PANE_STREAM_DAEMON_SHUTDOWN_CLOSE, PANE_STREAM_OWNER_RETIRED_CLOSE, PANE_STREAM_DAEMON_RESTARTING_CLOSE, PANE_STREAM_MAX_REDEMPTION_MS, WS_OPEN3, CANONICAL_KEY_INPUT_FRAME_PREFIX, CANONICAL_TEXT_INPUT_FRAME_PREFIX, SEMANTIC_BACKEND_REFUSALS, TYPE_FIRST_INPUT_FRAME_PREFIX, TicketPattern3, BindingIdSchemaZ4, PaneStreamAdmissionError, PaneStreamAdmissionCoordinator, PreAuthAdmission2, GRAPHICS_MAX_QUEUED_DIGESTS, GRAPHICS_SEND_WINDOW_BYTES, PaneStreamLiveConnection;
|
|
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;
|
|
76043
76511
|
var init_pane_stream_websocket = __esm({
|
|
76044
76512
|
"packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts"() {
|
|
76045
76513
|
"use strict";
|
|
@@ -76104,6 +76572,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76104
76572
|
#redemptionTimeoutMs;
|
|
76105
76573
|
#flowBudgets;
|
|
76106
76574
|
#drainTickMs;
|
|
76575
|
+
#openRetryDelaysMs;
|
|
76576
|
+
#ownershipWaitMs;
|
|
76107
76577
|
#maxSocketBufferedBytes;
|
|
76108
76578
|
#maxInputFrames;
|
|
76109
76579
|
#maxInputBytes;
|
|
@@ -76143,6 +76613,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76143
76613
|
this.#flowBudgets = options.flowBudgets ?? DEFAULT_PANE_STREAM_FLOW_BUDGETS;
|
|
76144
76614
|
this.#ledger = new PaneStreamWireLedger(this.#flowBudgets);
|
|
76145
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;
|
|
76146
76618
|
this.#maxSocketBufferedBytes = boundedInteger2(
|
|
76147
76619
|
options.maxSocketBufferedBytes,
|
|
76148
76620
|
32 << 20,
|
|
@@ -76467,6 +76939,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76467
76939
|
leaseManager: this.#leaseManager,
|
|
76468
76940
|
ledger: this.#ledger,
|
|
76469
76941
|
drainTickMs: this.#drainTickMs,
|
|
76942
|
+
openRetryDelaysMs: this.#openRetryDelaysMs,
|
|
76943
|
+
ownershipWaitMs: this.#ownershipWaitMs,
|
|
76470
76944
|
maxSocketBufferedBytes: this.#maxSocketBufferedBytes,
|
|
76471
76945
|
maxInputFrames: this.#maxInputFrames,
|
|
76472
76946
|
maxInputBytes: this.#maxInputBytes,
|
|
@@ -76640,6 +77114,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76640
77114
|
socket.off("error", this.#onClose);
|
|
76641
77115
|
}
|
|
76642
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;
|
|
76643
77121
|
GRAPHICS_MAX_QUEUED_DIGESTS = 256;
|
|
76644
77122
|
GRAPHICS_SEND_WINDOW_BYTES = 2 * 1024 * 1024;
|
|
76645
77123
|
PaneStreamLiveConnection = class {
|
|
@@ -76664,6 +77142,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76664
77142
|
#leaseManager;
|
|
76665
77143
|
#ledger;
|
|
76666
77144
|
#drainTickMs;
|
|
77145
|
+
#openRetryDelaysMs;
|
|
77146
|
+
#ownershipWaitMs;
|
|
76667
77147
|
#maxSocketBufferedBytes;
|
|
76668
77148
|
#maxInputFrames;
|
|
76669
77149
|
#maxInputBytes;
|
|
@@ -76677,6 +77157,13 @@ var init_pane_stream_websocket = __esm({
|
|
|
76677
77157
|
#panes = /* @__PURE__ */ new Map();
|
|
76678
77158
|
#semanticLayouts = /* @__PURE__ */ new Map();
|
|
76679
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;
|
|
76680
77167
|
#semanticRuntimeSessionId = null;
|
|
76681
77168
|
#semanticWindowLinks = null;
|
|
76682
77169
|
#semanticTopologyEpoch = -1;
|
|
@@ -76767,6 +77254,8 @@ var init_pane_stream_websocket = __esm({
|
|
|
76767
77254
|
this.#leaseManager = options.leaseManager;
|
|
76768
77255
|
this.#ledger = options.ledger;
|
|
76769
77256
|
this.#drainTickMs = options.drainTickMs;
|
|
77257
|
+
this.#openRetryDelaysMs = options.openRetryDelaysMs;
|
|
77258
|
+
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
76770
77259
|
this.#maxSocketBufferedBytes = options.maxSocketBufferedBytes;
|
|
76771
77260
|
this.#maxInputFrames = options.maxInputFrames;
|
|
76772
77261
|
this.#maxInputBytes = options.maxInputBytes;
|
|
@@ -76779,26 +77268,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76779
77268
|
this.#diagnosticSharedRawMicros = this.#diagnosticCapabilities.includes("clock-bounds-v1") ? options.diagnosticSharedNowMicros ?? sharedMonotonicMicros : void 0;
|
|
76780
77269
|
this.#diagnosticAfterFrameParse = options.diagnosticAfterFrameParse;
|
|
76781
77270
|
this.#onRetire = options.onRetire;
|
|
76782
|
-
|
|
76783
|
-
|
|
76784
|
-
|
|
76785
|
-
|
|
76786
|
-
delivery: null,
|
|
76787
|
-
deliveryAddress: null,
|
|
76788
|
-
serverSeq: 0,
|
|
76789
|
-
sentPaneFrames: 0,
|
|
76790
|
-
consumedSeq: 0,
|
|
76791
|
-
nextInputSeq: 1,
|
|
76792
|
-
frozenByWire: false,
|
|
76793
|
-
closed: false,
|
|
76794
|
-
batch: null,
|
|
76795
|
-
graphicsAnnounced: false,
|
|
76796
|
-
graphicsQueue: [],
|
|
76797
|
-
graphicsSending: false,
|
|
76798
|
-
graphicsServed: /* @__PURE__ */ new Map(),
|
|
76799
|
-
graphicsState: null
|
|
76800
|
-
});
|
|
76801
|
-
}
|
|
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));
|
|
76802
77275
|
}
|
|
76803
77276
|
get clientId() {
|
|
76804
77277
|
return this.#clientId;
|
|
@@ -76820,6 +77293,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
76820
77293
|
...this.#sessionRuntimeBinding && this.#descriptor.terminalDelivery?.protocolVersions.includes(
|
|
76821
77294
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION
|
|
76822
77295
|
) ? { inputBytes: true } : {},
|
|
77296
|
+
...this.#topologyInPlace ? { topologyInPlace: true } : {},
|
|
76823
77297
|
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
76824
77298
|
daemonInstanceId: this.#binding.daemonInstanceId,
|
|
76825
77299
|
requestId: this.#binding.requestId,
|
|
@@ -76829,7 +77303,11 @@ var init_pane_stream_websocket = __esm({
|
|
|
76829
77303
|
...this.#diagnosticCapabilities.length > 0 ? { diagnosticCapabilities: [...this.#diagnosticCapabilities] } : {}
|
|
76830
77304
|
});
|
|
76831
77305
|
this.#recordDiagnosticLifecycle("pane-stream-server-ready");
|
|
76832
|
-
} 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
|
+
};
|
|
76833
77311
|
this.close(1011, "stream-unavailable-describe");
|
|
76834
77312
|
return;
|
|
76835
77313
|
}
|
|
@@ -76863,9 +77341,13 @@ var init_pane_stream_websocket = __esm({
|
|
|
76863
77341
|
clientId: this.#clientId,
|
|
76864
77342
|
// Whether this connection held input when it went: the next stream of
|
|
76865
77343
|
// the same client can only be granted input once that is released.
|
|
76866
|
-
...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 } : {}
|
|
76867
77347
|
});
|
|
76868
77348
|
this.#closed = true;
|
|
77349
|
+
this.#ownershipHeld.length = 0;
|
|
77350
|
+
this.#ownershipWake?.();
|
|
76869
77351
|
for (const demand of this.#surfaceDemands.values()) demand.close();
|
|
76870
77352
|
this.#surfaceDemands.clear();
|
|
76871
77353
|
this.#surfaceViewer?.close();
|
|
@@ -76925,7 +77407,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
76925
77407
|
async #subscribeAll() {
|
|
76926
77408
|
let described;
|
|
76927
77409
|
try {
|
|
76928
|
-
described = await this.#
|
|
77410
|
+
described = await this.#retryOpenStep(
|
|
77411
|
+
"describe-session",
|
|
77412
|
+
() => this.#mirror.describeSession(this.#descriptor.sessionName)
|
|
77413
|
+
);
|
|
76929
77414
|
} catch (error) {
|
|
76930
77415
|
this.#fail("describe-session-failed", error);
|
|
76931
77416
|
return;
|
|
@@ -76979,6 +77464,32 @@ var init_pane_stream_websocket = __esm({
|
|
|
76979
77464
|
}
|
|
76980
77465
|
this.#closeIfAllPanesGone();
|
|
76981
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
|
+
}
|
|
76982
77493
|
async #subscribeSemantic(known) {
|
|
76983
77494
|
const binding = this.#sessionRuntimeBinding;
|
|
76984
77495
|
const offer = this.#descriptor.terminalDelivery;
|
|
@@ -77045,32 +77556,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77045
77556
|
channels.sort(
|
|
77046
77557
|
(left, right) => Number(visibleAtOpen.has(right.semanticPaneId)) - Number(visibleAtOpen.has(left.semanticPaneId))
|
|
77047
77558
|
);
|
|
77048
|
-
const openings = channels.map(
|
|
77049
|
-
const pending = [];
|
|
77050
|
-
let ready = false;
|
|
77051
|
-
let negotiated = false;
|
|
77052
|
-
const delivery = await binding.openTerminalDelivery(
|
|
77053
|
-
channel.semanticPaneId,
|
|
77054
|
-
offer,
|
|
77055
|
-
(message) => {
|
|
77056
|
-
if (!ready && !(negotiated && message.type === "terminal.delivery.fault"))
|
|
77057
|
-
pending.push(message);
|
|
77058
|
-
else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
77059
|
-
},
|
|
77060
|
-
this.#descriptor.workspaceName
|
|
77061
|
-
);
|
|
77062
|
-
return {
|
|
77063
|
-
channel,
|
|
77064
|
-
delivery,
|
|
77065
|
-
pending,
|
|
77066
|
-
markNegotiated: () => {
|
|
77067
|
-
negotiated = true;
|
|
77068
|
-
},
|
|
77069
|
-
markReady: () => {
|
|
77070
|
-
ready = true;
|
|
77071
|
-
}
|
|
77072
|
-
};
|
|
77073
|
-
});
|
|
77559
|
+
const openings = channels.map((channel) => this.#openPaneDelivery(binding, offer, channel));
|
|
77074
77560
|
const settled = await Promise.allSettled(openings);
|
|
77075
77561
|
const opened = settled.flatMap(
|
|
77076
77562
|
(result2) => result2.status === "fulfilled" ? [result2.value] : []
|
|
@@ -77088,21 +77574,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77088
77574
|
}
|
|
77089
77575
|
return;
|
|
77090
77576
|
}
|
|
77091
|
-
|
|
77092
|
-
if (!delivery.negotiation.accepted) return true;
|
|
77093
|
-
const negotiated = delivery.negotiation.negotiated;
|
|
77094
|
-
if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
|
|
77095
|
-
let incarnation = null;
|
|
77096
|
-
for (const message of pending) {
|
|
77097
|
-
if (message.type !== "terminal.delivery" && message.type !== "terminal.projection")
|
|
77098
|
-
continue;
|
|
77099
|
-
if (message.workspaceName !== this.#descriptor.workspaceName || message.semanticPaneId !== channel.semanticPaneId || message.generation !== negotiated.generation || message.deliveryNonce !== negotiated.deliveryNonce || incarnation !== null && message.incarnation !== incarnation)
|
|
77100
|
-
return true;
|
|
77101
|
-
incarnation = message.incarnation;
|
|
77102
|
-
}
|
|
77103
|
-
return false;
|
|
77104
|
-
});
|
|
77105
|
-
if (deliveryIdentityChanged) {
|
|
77577
|
+
if (opened.some((entry) => this.#deliveryIdentityChanged(entry))) {
|
|
77106
77578
|
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => void 0)));
|
|
77107
77579
|
this.#failTopologyChanged();
|
|
77108
77580
|
return;
|
|
@@ -77121,6 +77593,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77121
77593
|
}
|
|
77122
77594
|
this.#recordDiagnosticLifecycle("pane-stream-layout-validated");
|
|
77123
77595
|
this.#semanticExpectedPaneIds = expectedPaneIds;
|
|
77596
|
+
this.#leasesWholeSession = expectedPaneIds.every((pane) => this.#panes.has(pane));
|
|
77124
77597
|
this.#semanticRuntimeSessionId = authority2.runtimeSessionId;
|
|
77125
77598
|
this.#semanticWindowLinks = authority2.windowLinks;
|
|
77126
77599
|
this.#semanticTopologyEpoch = authority2.topologyEpoch;
|
|
@@ -77143,6 +77616,54 @@ var init_pane_stream_websocket = __esm({
|
|
|
77143
77616
|
opened.sort(
|
|
77144
77617
|
(left, right) => Number(visibleAtDelivery.has(right.channel.semanticPaneId)) - Number(visibleAtDelivery.has(left.channel.semanticPaneId))
|
|
77145
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) {
|
|
77146
77667
|
for (const { channel, delivery, markNegotiated } of opened) {
|
|
77147
77668
|
if (this.#closed || channel.closed) {
|
|
77148
77669
|
await delivery.close();
|
|
@@ -77175,9 +77696,37 @@ var init_pane_stream_websocket = __esm({
|
|
|
77175
77696
|
markReady();
|
|
77176
77697
|
this.#startGraphics(channel);
|
|
77177
77698
|
}
|
|
77178
|
-
this.#closeIfAllPanesGone();
|
|
77179
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();
|
|
77180
77727
|
async #sendTerminalDelivery(pane, message) {
|
|
77728
|
+
if ((message.type === "terminal.delivery" || message.type === "terminal.projection") && message.frame === "tombstone")
|
|
77729
|
+
this.#watchTombstone(pane);
|
|
77181
77730
|
if (message.type === "terminal.projection") {
|
|
77182
77731
|
const channel = this.#panes.get(pane);
|
|
77183
77732
|
if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message.incarnation;
|
|
@@ -77306,7 +77855,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77306
77855
|
if (!graphics) return;
|
|
77307
77856
|
this.#observeSurfaceDemand([channel.semanticPaneId]);
|
|
77308
77857
|
const zlib = this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
77309
|
-
(version) => version === TERMINAL_GRAPHICS_ZLIB_CAPABILITY_VERSION || version === PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION || version === PANE_STREAM_READER_CAPABILITY_VERSION
|
|
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
|
|
77310
77859
|
) === true;
|
|
77311
77860
|
channel.graphicsZlib = zlib;
|
|
77312
77861
|
channel.graphicsLocal = !!this.#localImages && this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
@@ -77662,11 +78211,20 @@ var init_pane_stream_websocket = __esm({
|
|
|
77662
78211
|
}
|
|
77663
78212
|
#onLayoutAuthority(snapshot3) {
|
|
77664
78213
|
if (this.#closed || !this.#semanticExpectedPaneIds || !this.#semanticRuntimeSessionId) return;
|
|
77665
|
-
if (
|
|
78214
|
+
if (this.#topologyReconciling) {
|
|
78215
|
+
this.#topologyPending = snapshot3;
|
|
78216
|
+
this.#topologyWaiter?.();
|
|
78217
|
+
return;
|
|
78218
|
+
}
|
|
78219
|
+
if (!this.#layoutAuthorityAdmissible(snapshot3)) {
|
|
77666
78220
|
this.#failTopologyChanged();
|
|
77667
78221
|
return;
|
|
77668
78222
|
}
|
|
77669
78223
|
const frames = this.#validateInitialLayout(snapshot3.layouts, this.#semanticExpectedPaneIds);
|
|
78224
|
+
if (!frames && this.#topologyInPlace) {
|
|
78225
|
+
void this.#reconcileTopology(snapshot3);
|
|
78226
|
+
return;
|
|
78227
|
+
}
|
|
77670
78228
|
if (!frames || !PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
|
|
77671
78229
|
type: "layout-snapshot",
|
|
77672
78230
|
topologyEpoch: snapshot3.topologyEpoch,
|
|
@@ -77676,10 +78234,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77676
78234
|
this.#failTopologyChanged();
|
|
77677
78235
|
return;
|
|
77678
78236
|
}
|
|
77679
|
-
|
|
77680
|
-
if (!previousLinks || snapshot3.windowLinks.liveSessionId !== previousLinks.liveSessionId || snapshot3.windowLinks.linkRevision < previousLinks.linkRevision || snapshot3.windowLinks.linkRevision === previousLinks.linkRevision && JSON.stringify(
|
|
77681
|
-
[...snapshot3.windowLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId))
|
|
77682
|
-
) !== JSON.stringify([...previousLinks.links].sort((a, b) => a.linkId.localeCompare(b.linkId)))) {
|
|
78237
|
+
if (!this.#windowLinksAdmissible(snapshot3)) {
|
|
77683
78238
|
this.#failTopologyChanged();
|
|
77684
78239
|
return;
|
|
77685
78240
|
}
|
|
@@ -77695,6 +78250,196 @@ var init_pane_stream_websocket = __esm({
|
|
|
77695
78250
|
windowLinks: snapshot3.windowLinks
|
|
77696
78251
|
});
|
|
77697
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
|
+
}
|
|
77698
78443
|
#onLayout(event) {
|
|
77699
78444
|
if (this.#closed) return;
|
|
77700
78445
|
const frame = this.#layoutFrame(event);
|
|
@@ -77705,7 +78450,9 @@ var init_pane_stream_websocket = __esm({
|
|
|
77705
78450
|
this.#sendFrame(null, frame);
|
|
77706
78451
|
}
|
|
77707
78452
|
#offers(version) {
|
|
77708
|
-
|
|
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);
|
|
77709
78456
|
}
|
|
77710
78457
|
#layoutFrame(event) {
|
|
77711
78458
|
const frame = {
|
|
@@ -77758,8 +78505,10 @@ var init_pane_stream_websocket = __esm({
|
|
|
77758
78505
|
return null;
|
|
77759
78506
|
return frames;
|
|
77760
78507
|
}
|
|
77761
|
-
|
|
78508
|
+
/** `inPlaceFailure`: why a capability-119 stream could not follow the change. */
|
|
78509
|
+
#failTopologyChanged(inPlaceFailure) {
|
|
77762
78510
|
if (this.#closed) return;
|
|
78511
|
+
if (inPlaceFailure) this.#closeCause = { cause: `topology-in-place: ${inPlaceFailure}` };
|
|
77763
78512
|
this.#sendFrame(null, {
|
|
77764
78513
|
type: "error",
|
|
77765
78514
|
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
@@ -77930,17 +78679,23 @@ var init_pane_stream_websocket = __esm({
|
|
|
77930
78679
|
if (frame.type === "presence") {
|
|
77931
78680
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77932
78681
|
this.#usesExplicitAuthority = true;
|
|
77933
|
-
|
|
77934
|
-
|
|
77935
|
-
|
|
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
|
+
});
|
|
77936
78688
|
return;
|
|
77937
78689
|
}
|
|
77938
78690
|
if (frame.type === "activity") {
|
|
77939
78691
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77940
78692
|
this.#usesExplicitAuthority = true;
|
|
77941
|
-
|
|
77942
|
-
|
|
77943
|
-
|
|
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
|
+
});
|
|
77944
78699
|
return;
|
|
77945
78700
|
}
|
|
77946
78701
|
if (frame.type === "authority-request") {
|
|
@@ -77948,38 +78703,45 @@ var init_pane_stream_websocket = __esm({
|
|
|
77948
78703
|
this.#usesExplicitAuthority = true;
|
|
77949
78704
|
if (!this.#sessionRuntimeBinding?.requestAuthority || !this.#sessionRuntimeBinding.authoritySnapshot)
|
|
77950
78705
|
return this.#failProtocol("protocol-error");
|
|
77951
|
-
|
|
77952
|
-
|
|
77953
|
-
lease =
|
|
77954
|
-
|
|
77955
|
-
|
|
77956
|
-
|
|
77957
|
-
|
|
77958
|
-
|
|
77959
|
-
|
|
77960
|
-
|
|
77961
|
-
|
|
77962
|
-
|
|
77963
|
-
|
|
77964
|
-
|
|
77965
|
-
|
|
77966
|
-
|
|
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);
|
|
77967
78727
|
return;
|
|
77968
78728
|
}
|
|
77969
78729
|
if (frame.type === "authority-release") {
|
|
77970
78730
|
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
77971
78731
|
this.#usesExplicitAuthority = true;
|
|
77972
|
-
this.#
|
|
77973
|
-
if (!
|
|
77974
|
-
|
|
77975
|
-
|
|
77976
|
-
|
|
77977
|
-
|
|
77978
|
-
|
|
77979
|
-
|
|
77980
|
-
|
|
77981
|
-
|
|
77982
|
-
|
|
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
|
+
});
|
|
77983
78745
|
});
|
|
77984
78746
|
return;
|
|
77985
78747
|
}
|
|
@@ -78022,7 +78784,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78022
78784
|
return;
|
|
78023
78785
|
}
|
|
78024
78786
|
if (frame.type === "semantic-intent") {
|
|
78025
|
-
this.#acceptSemanticIntent(frame.operationId, frame.intent);
|
|
78787
|
+
this.#afterHeldFrames(() => this.#acceptSemanticIntent(frame.operationId, frame.intent));
|
|
78026
78788
|
return;
|
|
78027
78789
|
}
|
|
78028
78790
|
if (frame.type === "terminal-surface-watch") {
|
|
@@ -78154,38 +78916,42 @@ var init_pane_stream_websocket = __esm({
|
|
|
78154
78916
|
}
|
|
78155
78917
|
if (!this.#prepareInputAuthority(true)) return;
|
|
78156
78918
|
this.#nextViewportSeq += 1;
|
|
78157
|
-
|
|
78158
|
-
|
|
78159
|
-
|
|
78160
|
-
|
|
78161
|
-
|
|
78162
|
-
|
|
78163
|
-
|
|
78164
|
-
|
|
78165
|
-
|
|
78166
|
-
|
|
78167
|
-
|
|
78168
|
-
type: "viewport-ack",
|
|
78169
|
-
seq: frame.seq,
|
|
78170
|
-
cols: frame.cols,
|
|
78171
|
-
rows: frame.rows,
|
|
78172
|
-
outcome: "ok",
|
|
78173
|
-
authorityLease: frame.authorityLease
|
|
78174
|
-
});
|
|
78175
|
-
} catch (error) {
|
|
78176
|
-
if (error instanceof SessionRuntimeControllerLeaseError && (error.code === "invalid-client-capability" || error.code === "stale-controller-lease")) {
|
|
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
|
+
);
|
|
78177
78930
|
this.#sendFrame(null, {
|
|
78178
78931
|
type: "viewport-ack",
|
|
78179
78932
|
seq: frame.seq,
|
|
78180
78933
|
cols: frame.cols,
|
|
78181
78934
|
rows: frame.rows,
|
|
78182
|
-
outcome: "
|
|
78935
|
+
outcome: "ok",
|
|
78183
78936
|
authorityLease: frame.authorityLease
|
|
78184
78937
|
});
|
|
78185
|
-
|
|
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");
|
|
78186
78952
|
}
|
|
78187
|
-
|
|
78188
|
-
|
|
78953
|
+
};
|
|
78954
|
+
this.#afterWindowOwnership(fit);
|
|
78189
78955
|
return;
|
|
78190
78956
|
}
|
|
78191
78957
|
this.#acceptInput(
|
|
@@ -78248,6 +79014,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78248
79014
|
}
|
|
78249
79015
|
#deliveryChannel(address) {
|
|
78250
79016
|
const channel = this.#panes.get(address.semanticPaneId);
|
|
79017
|
+
if (channel?.retiredInPlace) return null;
|
|
78251
79018
|
const expected = channel?.deliveryAddress;
|
|
78252
79019
|
if (!channel?.delivery || !expected || expected.workspaceName !== address.workspaceName || expected.generation !== address.generation || expected.deliveryNonce !== address.deliveryNonce || expected.incarnation === null) {
|
|
78253
79020
|
this.#failProtocol("protocol-error");
|
|
@@ -78303,6 +79070,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78303
79070
|
}
|
|
78304
79071
|
#acceptConsumed(pane, seq) {
|
|
78305
79072
|
const channel = this.#panes.get(pane);
|
|
79073
|
+
if (channel?.retiredInPlace) return;
|
|
78306
79074
|
if (!this.#deliveryAcks || !channel || seq <= channel.consumedSeq || seq > channel.sentPaneFrames) {
|
|
78307
79075
|
this.#failProtocol("protocol-error");
|
|
78308
79076
|
return;
|
|
@@ -78330,6 +79098,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78330
79098
|
return;
|
|
78331
79099
|
}
|
|
78332
79100
|
const channel = this.#panes.get(pane);
|
|
79101
|
+
if (channel?.retiredInPlace) return;
|
|
78333
79102
|
const semanticDelivery = this.#descriptor.terminalDelivery !== null;
|
|
78334
79103
|
if (!channel || channel.closed || (semanticDelivery ? !channel.delivery : !channel.sub) || seq !== channel.nextInputSeq) {
|
|
78335
79104
|
this.#failProtocol("input-rejected");
|
|
@@ -78392,84 +79161,196 @@ var init_pane_stream_websocket = __esm({
|
|
|
78392
79161
|
this.#inputWindowFrames += 1;
|
|
78393
79162
|
this.#inputWindowBytes += frameBytes;
|
|
78394
79163
|
channel.nextInputSeq += 1;
|
|
78395
|
-
|
|
78396
|
-
|
|
78397
|
-
|
|
78398
|
-
this.#sessionRuntimeBinding.
|
|
78399
|
-
|
|
78400
|
-
|
|
78401
|
-
|
|
78402
|
-
|
|
78403
|
-
|
|
78404
|
-
|
|
78405
|
-
|
|
78406
|
-
this.#
|
|
78407
|
-
|
|
78408
|
-
|
|
78409
|
-
|
|
78410
|
-
|
|
78411
|
-
|
|
78412
|
-
|
|
78413
|
-
|
|
78414
|
-
|
|
78415
|
-
|
|
78416
|
-
|
|
78417
|
-
|
|
78418
|
-
|
|
78419
|
-
|
|
78420
|
-
|
|
78421
|
-
|
|
78422
|
-
|
|
78423
|
-
|
|
78424
|
-
|
|
78425
|
-
|
|
78426
|
-
|
|
78427
|
-
|
|
78428
|
-
|
|
78429
|
-
|
|
78430
|
-
} catch {
|
|
78431
|
-
}
|
|
78432
|
-
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) {
|
|
78433
79199
|
try {
|
|
78434
|
-
|
|
79200
|
+
ackStartedAtMicros = this.#observability.nowMicros();
|
|
78435
79201
|
} catch {
|
|
78436
79202
|
}
|
|
78437
|
-
|
|
78438
|
-
|
|
78439
|
-
|
|
78440
|
-
|
|
78441
|
-
|
|
78442
|
-
try {
|
|
78443
|
-
ackEndedAtMicros = this.#observability.nowMicros();
|
|
78444
|
-
} catch {
|
|
78445
|
-
}
|
|
78446
|
-
let ackEndedAtSharedMicros = null;
|
|
78447
|
-
if (ackStartedAtSharedMicros !== null) {
|
|
78448
|
-
try {
|
|
78449
|
-
ackEndedAtSharedMicros = this.#sharedMicros();
|
|
78450
|
-
} catch {
|
|
79203
|
+
if (this.#diagnosticSharedRawMicros) {
|
|
79204
|
+
try {
|
|
79205
|
+
ackStartedAtSharedMicros = this.#sharedMicros();
|
|
79206
|
+
} catch {
|
|
79207
|
+
}
|
|
78451
79208
|
}
|
|
78452
79209
|
}
|
|
78453
|
-
|
|
79210
|
+
sendControl2(this.#socket, { type: "input-ack", pane, seq });
|
|
79211
|
+
if (trace && ackStartedAtMicros !== null) {
|
|
79212
|
+
let ackEndedAtMicros = null;
|
|
78454
79213
|
try {
|
|
78455
|
-
this.#observability.
|
|
78456
|
-
"transport",
|
|
78457
|
-
"pane-stream-input-ack-socket-send",
|
|
78458
|
-
ackStartedAtMicros,
|
|
78459
|
-
ackEndedAtMicros,
|
|
78460
|
-
trace,
|
|
78461
|
-
ackStartedAtSharedMicros === null || ackEndedAtSharedMicros === null ? void 0 : {
|
|
78462
|
-
startedAtMicros: ackStartedAtSharedMicros,
|
|
78463
|
-
endedAtMicros: ackEndedAtSharedMicros
|
|
78464
|
-
}
|
|
78465
|
-
);
|
|
79214
|
+
ackEndedAtMicros = this.#observability.nowMicros();
|
|
78466
79215
|
} catch {
|
|
78467
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
|
+
}
|
|
78468
79240
|
}
|
|
79241
|
+
} catch (error) {
|
|
79242
|
+
if (this.#holdForWindowOwnership(error, deliver)) return;
|
|
79243
|
+
if (error instanceof SessionRuntimeInputLifetimeEndedError) {
|
|
79244
|
+
this.#noteInputLifetimeEnded(pane, error);
|
|
79245
|
+
return;
|
|
79246
|
+
}
|
|
79247
|
+
this.#fail("control-frame-handler-failed", error);
|
|
78469
79248
|
}
|
|
78470
|
-
}
|
|
78471
|
-
|
|
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;
|
|
78472
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;
|
|
79340
|
+
}
|
|
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
|
+
});
|
|
78473
79354
|
}
|
|
78474
79355
|
#failProtocol(code2) {
|
|
78475
79356
|
try {
|
|
@@ -81096,7 +81977,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
81096
81977
|
const snapshot3 = async (liveSessionId, signal, windowId, paneId) => {
|
|
81097
81978
|
const nativeEpoch = native2?.serverEpoch() ?? null;
|
|
81098
81979
|
let sessionGuard;
|
|
81099
|
-
const
|
|
81980
|
+
const readSessions2 = async () => {
|
|
81100
81981
|
const raw = await run(
|
|
81101
81982
|
["list-panes", "-a", "-F", "#{pid} #{session_id} #{session_created} #{session_name}"],
|
|
81102
81983
|
signal
|
|
@@ -81109,7 +81990,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
81109
81990
|
}
|
|
81110
81991
|
return discoverLiveSessionSummaries(() => raw);
|
|
81111
81992
|
};
|
|
81112
|
-
const session = (await
|
|
81993
|
+
const session = (await readSessions2()).find((s) => s.liveSessionId === liveSessionId);
|
|
81113
81994
|
if (!session) return null;
|
|
81114
81995
|
const readPanes = async () => (await run(
|
|
81115
81996
|
[
|
|
@@ -81186,7 +82067,7 @@ function createFleetPreviewCapture(run, native2) {
|
|
|
81186
82067
|
signal
|
|
81187
82068
|
) : null;
|
|
81188
82069
|
const captured = owned ? owned.output : await run(["capture-pane", "-p", "-t", pane, "-S", "-24"], signal);
|
|
81189
|
-
const [currentSessions, currentPanes] = await Promise.all([
|
|
82070
|
+
const [currentSessions, currentPanes] = await Promise.all([readSessions2(), readPanes()]);
|
|
81190
82071
|
if (!currentSessions.some((s) => s.liveSessionId === liveSessionId)) return null;
|
|
81191
82072
|
if (selectedWindowId && !currentPanes.some((r) => r[3] === selectedWindowId && r[0] === pane))
|
|
81192
82073
|
return null;
|
|
@@ -88993,7 +89874,7 @@ var init_plugin_store = __esm({
|
|
|
88993
89874
|
|
|
88994
89875
|
// packages/daemon/src/plugins/worktree-calls.ts
|
|
88995
89876
|
import { spawn as spawn9 } from "node:child_process";
|
|
88996
|
-
import { homedir as
|
|
89877
|
+
import { homedir as homedir6 } from "node:os";
|
|
88997
89878
|
import { z as z130 } from "zod";
|
|
88998
89879
|
function fail3(message) {
|
|
88999
89880
|
throw new WorktreeCallError(message);
|
|
@@ -89054,7 +89935,7 @@ function cliRunner(command3, timeoutMs = 6e4) {
|
|
|
89054
89935
|
return (args, env) => new Promise((resolve47, reject) => {
|
|
89055
89936
|
const [file, ...prefix] = command3;
|
|
89056
89937
|
const child = spawn9(file, [...prefix, ...args], {
|
|
89057
|
-
cwd:
|
|
89938
|
+
cwd: homedir6(),
|
|
89058
89939
|
env,
|
|
89059
89940
|
stdio: ["ignore", "pipe", "pipe"]
|
|
89060
89941
|
});
|
|
@@ -92908,7 +93789,7 @@ __export(auth_service_exports, {
|
|
|
92908
93789
|
import * as crypto2 from "node:crypto";
|
|
92909
93790
|
import { readFileSync as readFileSync35, existsSync as existsSync33 } from "node:fs";
|
|
92910
93791
|
import { join as join56 } from "node:path";
|
|
92911
|
-
import { homedir as
|
|
93792
|
+
import { homedir as homedir7 } from "node:os";
|
|
92912
93793
|
function base64url(buf) {
|
|
92913
93794
|
const b = typeof buf === "string" ? Buffer.from(buf) : buf;
|
|
92914
93795
|
return b.toString("base64url");
|
|
@@ -93052,7 +93933,7 @@ var init_auth_service = __esm({
|
|
|
93052
93933
|
checkSSHKeyAuthorization(userId, publicKey) {
|
|
93053
93934
|
if (resolveRuntimeNamespace().development) return false;
|
|
93054
93935
|
try {
|
|
93055
|
-
const home = userId === process.env.USER ?
|
|
93936
|
+
const home = userId === process.env.USER ? homedir7() : `/home/${userId}`;
|
|
93056
93937
|
const authKeysPath = join56(home, ".ssh", "authorized_keys");
|
|
93057
93938
|
if (!existsSync33(authKeysPath)) return false;
|
|
93058
93939
|
const authorizedKeys = readFileSync35(authKeysPath, "utf-8");
|
|
@@ -96078,7 +96959,7 @@ var init_inspect = __esm({
|
|
|
96078
96959
|
|
|
96079
96960
|
// packages/daemon/src/lib/filesystem-browser.ts
|
|
96080
96961
|
import { realpathSync as realpathSync26, readdirSync as readdirSync9, statSync as statSync27 } from "node:fs";
|
|
96081
|
-
import { homedir as
|
|
96962
|
+
import { homedir as homedir8 } from "node:os";
|
|
96082
96963
|
import { isAbsolute as isAbsolute31, join as join57, resolve as resolve33, sep as sep13 } from "node:path";
|
|
96083
96964
|
function isUnderRoot(canonical, root) {
|
|
96084
96965
|
if (canonical === root) return true;
|
|
@@ -99776,7 +100657,7 @@ import { cors } from "hono/cors";
|
|
|
99776
100657
|
import { zValidator } from "@hono/zod-validator";
|
|
99777
100658
|
import { z as z142 } from "zod";
|
|
99778
100659
|
import { realpathSync as realpathSync29 } from "node:fs";
|
|
99779
|
-
import { homedir as
|
|
100660
|
+
import { homedir as homedir9 } from "node:os";
|
|
99780
100661
|
import { isAbsolute as isAbsolute34, resolve as pathResolve } from "node:path";
|
|
99781
100662
|
import { randomUUID as randomUUID51 } from "node:crypto";
|
|
99782
100663
|
import { WebSocketServer as WebSocketServer4 } from "ws";
|
|
@@ -99878,7 +100759,7 @@ function sandboxResolveDir(rawDir) {
|
|
|
99878
100759
|
if (trimmed.includes("\0")) {
|
|
99879
100760
|
return { error: "invalid-path", message: "Path contains a null byte", status: 400 };
|
|
99880
100761
|
}
|
|
99881
|
-
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();
|
|
99882
100763
|
let candidate = trimmed;
|
|
99883
100764
|
if (candidate === "~") {
|
|
99884
100765
|
candidate = home;
|
|
@@ -99914,6 +100795,12 @@ function sandboxResolveDir(rawDir) {
|
|
|
99914
100795
|
return { canonical };
|
|
99915
100796
|
}
|
|
99916
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);
|
|
99917
100804
|
const authConfig = options.authConfig ?? { method: "none", token_expiry: 86400 };
|
|
99918
100805
|
const authService = options.authService ?? new AuthService();
|
|
99919
100806
|
const daemonIdentity = options.daemonIdentity ?? {
|
|
@@ -100140,7 +101027,12 @@ function createApp(options = {}) {
|
|
|
100140
101027
|
});
|
|
100141
101028
|
});
|
|
100142
101029
|
app.get("/api/sessions", (c) => {
|
|
100143
|
-
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
|
+
);
|
|
100144
101036
|
const overviews = buildOverviews(sessions);
|
|
100145
101037
|
return c.json({ sessions: overviews });
|
|
100146
101038
|
});
|
|
@@ -100256,11 +101148,8 @@ function createApp(options = {}) {
|
|
|
100256
101148
|
});
|
|
100257
101149
|
app.get("/api/project/:name", (c) => {
|
|
100258
101150
|
const name = c.req.param("name");
|
|
100259
|
-
const
|
|
100260
|
-
|
|
100261
|
-
if (!session) {
|
|
100262
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100263
|
-
}
|
|
101151
|
+
const session = lookupSession(name);
|
|
101152
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100264
101153
|
const detail = buildProjectDetail(session);
|
|
100265
101154
|
return c.json({ ...detail });
|
|
100266
101155
|
});
|
|
@@ -100368,8 +101257,8 @@ function createApp(options = {}) {
|
|
|
100368
101257
|
const backend2 = options.applicationShellInventoryBackend;
|
|
100369
101258
|
if (!backend2) {
|
|
100370
101259
|
if (requestedVersion === String(APPLICATION_SHELL_RESOURCE_V1_VERSION)) {
|
|
100371
|
-
const standaloneSession =
|
|
100372
|
-
if (
|
|
101260
|
+
const standaloneSession = lookupSession(name);
|
|
101261
|
+
if (typeof standaloneSession === "string") return sessionMissing(c, standaloneSession);
|
|
100373
101262
|
markV1Compatibility();
|
|
100374
101263
|
return c.json({
|
|
100375
101264
|
version: APPLICATION_SHELL_RESOURCE_V1_VERSION,
|
|
@@ -100438,13 +101327,12 @@ function createApp(options = {}) {
|
|
|
100438
101327
|
try {
|
|
100439
101328
|
panes = listSessionPanes(name);
|
|
100440
101329
|
} catch {
|
|
100441
|
-
|
|
101330
|
+
const session = lookupSession(name);
|
|
101331
|
+
return sessionMissing(c, typeof session === "string" ? session : "not-found");
|
|
100442
101332
|
}
|
|
100443
101333
|
if (panes.length === 0) {
|
|
100444
|
-
const
|
|
100445
|
-
if (
|
|
100446
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100447
|
-
}
|
|
101334
|
+
const session = lookupSession(name);
|
|
101335
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100448
101336
|
}
|
|
100449
101337
|
return c.json({
|
|
100450
101338
|
panes: panes.map((p) => ({
|
|
@@ -100463,9 +101351,8 @@ function createApp(options = {}) {
|
|
|
100463
101351
|
});
|
|
100464
101352
|
app.get("/api/project/:name/terminals", async (c) => {
|
|
100465
101353
|
const name = c.req.param("name");
|
|
100466
|
-
const
|
|
100467
|
-
|
|
100468
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101354
|
+
const session = lookupSession(name);
|
|
101355
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100469
101356
|
const records = loadTerminals(session.dir);
|
|
100470
101357
|
const terminals = records.map((t) => {
|
|
100471
101358
|
const bridge = defaultPtyBridgeRegistry.peek(t.id);
|
|
@@ -100490,9 +101377,8 @@ function createApp(options = {}) {
|
|
|
100490
101377
|
zValidator("json", terminalCreateRequestSchema),
|
|
100491
101378
|
async (c) => {
|
|
100492
101379
|
const name = c.req.param("name");
|
|
100493
|
-
const
|
|
100494
|
-
|
|
100495
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101380
|
+
const session = lookupSession(name);
|
|
101381
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100496
101382
|
const body = c.req.valid("json");
|
|
100497
101383
|
let id2 = body.id;
|
|
100498
101384
|
let scripted = false;
|
|
@@ -100530,9 +101416,8 @@ function createApp(options = {}) {
|
|
|
100530
101416
|
async (c) => {
|
|
100531
101417
|
const name = c.req.param("name");
|
|
100532
101418
|
const id2 = c.req.param("id");
|
|
100533
|
-
const
|
|
100534
|
-
|
|
100535
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101419
|
+
const session = lookupSession(name);
|
|
101420
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100536
101421
|
try {
|
|
100537
101422
|
const record2 = renameTerminal(session.dir, id2, c.req.valid("json").name);
|
|
100538
101423
|
if (!record2) return c.json({ error: "Terminal not found" }, 404);
|
|
@@ -100546,9 +101431,8 @@ function createApp(options = {}) {
|
|
|
100546
101431
|
app.delete("/api/project/:name/terminals/:id", async (c) => {
|
|
100547
101432
|
const name = c.req.param("name");
|
|
100548
101433
|
const id2 = c.req.param("id");
|
|
100549
|
-
const
|
|
100550
|
-
|
|
100551
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101434
|
+
const session = lookupSession(name);
|
|
101435
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100552
101436
|
const removedRecord = deleteTerminal(session.dir, id2);
|
|
100553
101437
|
const killed = defaultPtyBridgeRegistry.delete(id2);
|
|
100554
101438
|
if (!removedRecord && !killed) {
|
|
@@ -100559,18 +101443,14 @@ function createApp(options = {}) {
|
|
|
100559
101443
|
});
|
|
100560
101444
|
app.get("/api/project/:name/events", (c) => {
|
|
100561
101445
|
const name = c.req.param("name");
|
|
100562
|
-
const session =
|
|
100563
|
-
if (
|
|
100564
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100565
|
-
}
|
|
101446
|
+
const session = lookupSession(name);
|
|
101447
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100566
101448
|
return c.json({ events: [] });
|
|
100567
101449
|
});
|
|
100568
101450
|
app.get("/api/project/:name/stream", (c) => {
|
|
100569
101451
|
const name = c.req.param("name");
|
|
100570
|
-
const session =
|
|
100571
|
-
if (
|
|
100572
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100573
|
-
}
|
|
101452
|
+
const session = lookupSession(name);
|
|
101453
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100574
101454
|
return streamSSE3(c, async (stream) => {
|
|
100575
101455
|
projectStreamConnections += 1;
|
|
100576
101456
|
sseMetrics.connections = projectStreamConnections;
|
|
@@ -100596,9 +101476,9 @@ function createApp(options = {}) {
|
|
|
100596
101476
|
writeChanges(session);
|
|
100597
101477
|
while (!closed) {
|
|
100598
101478
|
await stream.sleep(250);
|
|
100599
|
-
const current =
|
|
100600
|
-
if (
|
|
100601
|
-
writeChanges(current);
|
|
101479
|
+
const current = lookupSession(name);
|
|
101480
|
+
if (current === "not-found") break;
|
|
101481
|
+
if (current !== "unavailable") writeChanges(current);
|
|
100602
101482
|
const now = Date.now();
|
|
100603
101483
|
if (now - lastPing >= 25e3) {
|
|
100604
101484
|
writeSse("ping", { at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
@@ -100613,11 +101493,8 @@ function createApp(options = {}) {
|
|
|
100613
101493
|
});
|
|
100614
101494
|
app.post("/api/project/:name/inject", async (c) => {
|
|
100615
101495
|
const name = c.req.param("name");
|
|
100616
|
-
const
|
|
100617
|
-
|
|
100618
|
-
if (!session) {
|
|
100619
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100620
|
-
}
|
|
101496
|
+
const session = lookupSession(name);
|
|
101497
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100621
101498
|
let body;
|
|
100622
101499
|
try {
|
|
100623
101500
|
body = await c.req.json();
|
|
@@ -100650,11 +101527,8 @@ function createApp(options = {}) {
|
|
|
100650
101527
|
});
|
|
100651
101528
|
app.post("/api/project/:name/send", zValidator("json", sendCommandSchema), async (c) => {
|
|
100652
101529
|
const name = c.req.param("name");
|
|
100653
|
-
const
|
|
100654
|
-
|
|
100655
|
-
if (!session) {
|
|
100656
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100657
|
-
}
|
|
101530
|
+
const session = lookupSession(name);
|
|
101531
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100658
101532
|
const { target, message, noEnter } = c.req.valid("json");
|
|
100659
101533
|
const panes = listSessionPanes(name);
|
|
100660
101534
|
const pane = resolvePane(panes, target);
|
|
@@ -100688,9 +101562,8 @@ function createApp(options = {}) {
|
|
|
100688
101562
|
});
|
|
100689
101563
|
app.get("/api/project/:name/config", async (c) => {
|
|
100690
101564
|
const name = c.req.param("name");
|
|
100691
|
-
const
|
|
100692
|
-
|
|
100693
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101565
|
+
const session = lookupSession(name);
|
|
101566
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100694
101567
|
try {
|
|
100695
101568
|
const resolved2 = await resolveConfig(session.dir);
|
|
100696
101569
|
if (!resolved2.launchConfig || !resolved2.path) {
|
|
@@ -100712,9 +101585,8 @@ function createApp(options = {}) {
|
|
|
100712
101585
|
});
|
|
100713
101586
|
app.post("/api/project/:name/config", async (c) => {
|
|
100714
101587
|
const name = c.req.param("name");
|
|
100715
|
-
const
|
|
100716
|
-
|
|
100717
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101588
|
+
const session = lookupSession(name);
|
|
101589
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100718
101590
|
let body;
|
|
100719
101591
|
try {
|
|
100720
101592
|
body = await c.req.json();
|
|
@@ -100746,9 +101618,8 @@ function createApp(options = {}) {
|
|
|
100746
101618
|
const execFileAsync2 = promisify4(execFile15);
|
|
100747
101619
|
app.post("/api/project/:name/restart", async (c) => {
|
|
100748
101620
|
const name = c.req.param("name");
|
|
100749
|
-
const
|
|
100750
|
-
|
|
100751
|
-
if (!session) return c.json({ error: "Session not found" }, 404);
|
|
101621
|
+
const session = lookupSession(name);
|
|
101622
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100752
101623
|
try {
|
|
100753
101624
|
await execFileAsync2("tmux-ide", ["restart", "--json"], {
|
|
100754
101625
|
cwd: session.dir,
|
|
@@ -100763,11 +101634,8 @@ function createApp(options = {}) {
|
|
|
100763
101634
|
});
|
|
100764
101635
|
app.post("/api/project/:name/launch", async (c) => {
|
|
100765
101636
|
const name = c.req.param("name");
|
|
100766
|
-
const
|
|
100767
|
-
|
|
100768
|
-
if (!session) {
|
|
100769
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100770
|
-
}
|
|
101637
|
+
const session = lookupSession(name);
|
|
101638
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100771
101639
|
const state = getSessionState(name);
|
|
100772
101640
|
if (state.running) {
|
|
100773
101641
|
return c.json({ ok: true, session: name, status: "already_running" });
|
|
@@ -100787,11 +101655,8 @@ function createApp(options = {}) {
|
|
|
100787
101655
|
});
|
|
100788
101656
|
app.post("/api/project/:name/stop", async (c) => {
|
|
100789
101657
|
const name = c.req.param("name");
|
|
100790
|
-
const
|
|
100791
|
-
|
|
100792
|
-
if (!session) {
|
|
100793
|
-
return c.json({ error: "Session not found" }, 404);
|
|
100794
|
-
}
|
|
101658
|
+
const session = lookupSession(name);
|
|
101659
|
+
if (typeof session === "string") return sessionMissing(c, session);
|
|
100795
101660
|
const state = getSessionState(name);
|
|
100796
101661
|
if (!state.running) {
|
|
100797
101662
|
return c.json({ ok: true, session: name, status: "not_running" });
|
|
@@ -100807,7 +101672,8 @@ function createApp(options = {}) {
|
|
|
100807
101672
|
return streamSSE3(c, async (stream) => {
|
|
100808
101673
|
let prevOverviews = [];
|
|
100809
101674
|
const poll = () => {
|
|
100810
|
-
const sessions =
|
|
101675
|
+
const sessions = readSessions();
|
|
101676
|
+
if (sessions === null) return;
|
|
100811
101677
|
const overviews = buildOverviews(sessions);
|
|
100812
101678
|
const prevNames = new Set(prevOverviews.map((s) => s.name));
|
|
100813
101679
|
const currNames = new Set(overviews.map((s) => s.name));
|
|
@@ -102432,6 +103298,14 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
102432
103298
|
};
|
|
102433
103299
|
terminalInventoryRuntime = new WorkspaceTerminalInventoryRuntime(terminalRuntimeOptions);
|
|
102434
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
|
+
);
|
|
102435
103309
|
const getTerminalAttachmentRuntime = () => {
|
|
102436
103310
|
if (terminalAttachmentRuntime) return terminalAttachmentRuntime;
|
|
102437
103311
|
terminalAttachmentRuntime = createNativeTerminalAttachmentRuntime({
|
|
@@ -103270,6 +104144,7 @@ var init_daemon_embed = __esm({
|
|
|
103270
104144
|
"use strict";
|
|
103271
104145
|
init_tmux_pane_reader();
|
|
103272
104146
|
init_tmux_native_browser();
|
|
104147
|
+
init_daemon_crash_snapshot();
|
|
103273
104148
|
init_native_surface_context();
|
|
103274
104149
|
init_native_surface_provider();
|
|
103275
104150
|
init_src2();
|
|
@@ -103365,9 +104240,11 @@ var init_daemon_embed = __esm({
|
|
|
103365
104240
|
// packages/daemon/src/lib/headless-daemon.ts
|
|
103366
104241
|
var headless_daemon_exports = {};
|
|
103367
104242
|
__export(headless_daemon_exports, {
|
|
104243
|
+
OWN_SERVER_PROOF_RESTARTS: () => OWN_SERVER_PROOF_RESTARTS,
|
|
103368
104244
|
SIGNAL_STOP_DEADLINE_MS: () => SIGNAL_STOP_DEADLINE_MS,
|
|
103369
104245
|
SIGNAL_STOP_MAX_MS: () => SIGNAL_STOP_MAX_MS,
|
|
103370
104246
|
SIGNAL_STOP_TIMEOUT_EXIT_CODE: () => SIGNAL_STOP_TIMEOUT_EXIT_CODE,
|
|
104247
|
+
ownServerProofRetry: () => ownServerProofRetry,
|
|
103371
104248
|
runHeadlessDaemon: () => runHeadlessDaemon
|
|
103372
104249
|
});
|
|
103373
104250
|
function activeResourceCounts() {
|
|
@@ -103441,8 +104318,16 @@ async function assertAttachableDaemon(deps2, info, options) {
|
|
|
103441
104318
|
);
|
|
103442
104319
|
}
|
|
103443
104320
|
assertIdentityMatches(info, identity4);
|
|
104321
|
+
let first = true;
|
|
103444
104322
|
await assertCanonicalDaemonServerIntent(info, options.tmuxServerIntent ?? null, {
|
|
103445
|
-
|
|
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
|
+
}
|
|
103446
104331
|
});
|
|
103447
104332
|
const health = await deps2.probeCanonicalDaemonHealth(info);
|
|
103448
104333
|
if (!health) {
|
|
@@ -103490,8 +104375,15 @@ async function findLiveCanonicalDaemon(deps2, options, predecessor) {
|
|
|
103490
104375
|
function delay3(ms) {
|
|
103491
104376
|
return new Promise((resolve47) => setTimeout(resolve47, ms));
|
|
103492
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
|
+
}
|
|
103493
104383
|
function isTransientAttachabilityError(error) {
|
|
103494
|
-
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);
|
|
103495
104387
|
}
|
|
103496
104388
|
async function waitForAttachableDaemon(deps2, info, options, timeoutMs = DAEMON_ATTACHABILITY_TIMEOUT_MS, shouldAbort = () => false) {
|
|
103497
104389
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -103659,6 +104551,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103659
104551
|
handle = await deps2.startEmbeddedDaemon({
|
|
103660
104552
|
launcher: "headless",
|
|
103661
104553
|
plugins: true,
|
|
104554
|
+
...options.crashSnapshotSource ? { crashSnapshotSource: options.crashSnapshotSource } : {},
|
|
103662
104555
|
...options.supervisionId ? { supervisionId: options.supervisionId, predecessor: lifecycle.predecessor } : {},
|
|
103663
104556
|
...restoreTmuxWorkspaces ? { restoreTmuxWorkspaces: true } : {},
|
|
103664
104557
|
port,
|
|
@@ -103779,7 +104672,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103779
104672
|
deps2,
|
|
103780
104673
|
info,
|
|
103781
104674
|
options,
|
|
103782
|
-
DAEMON_ATTACHABILITY_TIMEOUT_MS,
|
|
104675
|
+
deps2.attachabilityTimeoutMs ?? DAEMON_ATTACHABILITY_TIMEOUT_MS,
|
|
103783
104676
|
() => signalRequested
|
|
103784
104677
|
);
|
|
103785
104678
|
options.onOwnedReady?.(info);
|
|
@@ -103789,8 +104682,29 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103789
104682
|
if (stopFailure) throw stopFailure;
|
|
103790
104683
|
return "stopped";
|
|
103791
104684
|
}
|
|
103792
|
-
|
|
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";
|
|
103793
104706
|
}
|
|
104707
|
+
lifecycle.ownServerProofRestarts = 0;
|
|
103794
104708
|
lifecycle.lastPort = info.port;
|
|
103795
104709
|
emitStatus(deps2, options.json === true, "ready", info);
|
|
103796
104710
|
logger[generation > 1 ? "info" : "debug"]("daemon-lifecycle", "generation ready", {
|
|
@@ -103833,7 +104747,7 @@ async function runHeadlessDaemonGeneration(options, deps2, restoreTmuxWorkspaces
|
|
|
103833
104747
|
deps2.offSignal("SIGTERM", onSigterm);
|
|
103834
104748
|
}
|
|
103835
104749
|
}
|
|
103836
|
-
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;
|
|
103837
104751
|
var init_headless_daemon = __esm({
|
|
103838
104752
|
"packages/daemon/src/lib/headless-daemon.ts"() {
|
|
103839
104753
|
"use strict";
|
|
@@ -103842,6 +104756,7 @@ var init_headless_daemon = __esm({
|
|
|
103842
104756
|
init_canonical_daemon();
|
|
103843
104757
|
init_src2();
|
|
103844
104758
|
init_daemon_embed();
|
|
104759
|
+
init_bootstrap_coordinator();
|
|
103845
104760
|
init_errors2();
|
|
103846
104761
|
init_log();
|
|
103847
104762
|
init_auth_token();
|
|
@@ -103860,6 +104775,7 @@ var init_headless_daemon = __esm({
|
|
|
103860
104775
|
onSignal: (signal, listener) => process.on(signal, listener),
|
|
103861
104776
|
offSignal: (signal, listener) => process.off(signal, listener)
|
|
103862
104777
|
};
|
|
104778
|
+
OWN_SERVER_PROOF_RESTARTS = 4;
|
|
103863
104779
|
DAEMON_ATTACHABILITY_TIMEOUT_MS = 15e3;
|
|
103864
104780
|
DAEMON_ATTACHABILITY_POLL_MS = 25;
|
|
103865
104781
|
}
|
|
@@ -104200,10 +105116,10 @@ __export(open_browser_exports, {
|
|
|
104200
105116
|
});
|
|
104201
105117
|
import { accessSync as accessSync11, constants as constants20, realpathSync as realpathSync31, statSync as statSync29 } from "node:fs";
|
|
104202
105118
|
import { delimiter as delimiter5, isAbsolute as isAbsolute35, join as join63, resolve as resolve38 } from "node:path";
|
|
104203
|
-
import { homedir as
|
|
105119
|
+
import { homedir as homedir10 } from "node:os";
|
|
104204
105120
|
function resolveTerminalBrowser(environment = process.env, platform2 = process.platform) {
|
|
104205
105121
|
const configured = environment.TMUX_IDE_TERMINAL_BROWSER_BIN;
|
|
104206
|
-
const home = environment.HOME ??
|
|
105122
|
+
const home = environment.HOME ?? homedir10();
|
|
104207
105123
|
const bundled = platform2 === "darwin" && isAbsolute35(home) ? [
|
|
104208
105124
|
join63(
|
|
104209
105125
|
home,
|
|
@@ -104830,7 +105746,7 @@ import {
|
|
|
104830
105746
|
} from "node:fs";
|
|
104831
105747
|
import { randomUUID as randomUUID53 } from "node:crypto";
|
|
104832
105748
|
import { dirname as dirname49, join as join65 } from "node:path";
|
|
104833
|
-
import { homedir as
|
|
105749
|
+
import { homedir as homedir11 } from "node:os";
|
|
104834
105750
|
import { z as z143 } from "zod";
|
|
104835
105751
|
function defaults() {
|
|
104836
105752
|
const namespace = resolveRuntimeNamespace();
|
|
@@ -104838,7 +105754,7 @@ function defaults() {
|
|
|
104838
105754
|
plan: (executable) => planDaemonService({
|
|
104839
105755
|
platform: process.platform,
|
|
104840
105756
|
uid: process.getuid?.() ?? 0,
|
|
104841
|
-
home:
|
|
105757
|
+
home: homedir11(),
|
|
104842
105758
|
configHome: process.env.XDG_CONFIG_HOME || void 0,
|
|
104843
105759
|
executable,
|
|
104844
105760
|
path: process.env.PATH || "/usr/bin:/bin",
|
|
@@ -105818,7 +106734,7 @@ function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
|
105818
106734
|
const upgrade = running ? "; run `tmux-ide servers upgrade` to move it to tmux-ide's own tmux" : "";
|
|
105819
106735
|
const details = {
|
|
105820
106736
|
full: "bundled tmux: full features",
|
|
105821
|
-
stock: `stock tmux: reduced features${upgrade}`,
|
|
106737
|
+
stock: `stock tmux: reduced features (tab positions in saved output are reconstructed)${upgrade}`,
|
|
105822
106738
|
older: `older tmux-ide tmux: reduced features${upgrade}`,
|
|
105823
106739
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
105824
106740
|
"no-server": "could not read the tmux server's features",
|
|
@@ -105849,14 +106765,23 @@ function plainTmuxRow(pathTmux, bundled) {
|
|
|
105849
106765
|
optional: true
|
|
105850
106766
|
};
|
|
105851
106767
|
}
|
|
105852
|
-
function snapshotRow(snapshot3, liveSessions2, nowMs) {
|
|
106768
|
+
function snapshotRow(snapshot3, liveSessions2, nowMs, serverStartMs = null) {
|
|
105853
106769
|
const label4 = "crash snapshot (restore)";
|
|
105854
|
-
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";
|
|
105855
106771
|
if (!snapshot3) {
|
|
105856
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 };
|
|
105857
106773
|
}
|
|
105858
106774
|
const ageMs = nowMs - Date.parse(snapshot3.savedAt);
|
|
105859
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
|
+
}
|
|
105860
106785
|
const saved = new Set(snapshot3.sessions.map((session) => session.name));
|
|
105861
106786
|
const missing = (liveSessions2 ?? []).filter((name) => !saved.has(name));
|
|
105862
106787
|
if (missing.length)
|
|
@@ -105888,11 +106813,29 @@ function safeBundledTmux() {
|
|
|
105888
106813
|
return null;
|
|
105889
106814
|
}
|
|
105890
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
|
+
}
|
|
105891
106836
|
function liveListableSessions() {
|
|
105892
106837
|
try {
|
|
105893
|
-
const
|
|
105894
|
-
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
105895
|
-
const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
106838
|
+
const server = doctorTmuxServer();
|
|
105896
106839
|
return execFileSync23(
|
|
105897
106840
|
resolveTmuxExecutable(),
|
|
105898
106841
|
[...server, "list-sessions", "-F", "#{session_name}"],
|
|
@@ -106006,7 +106949,7 @@ async function doctor({
|
|
|
106006
106949
|
} catch {
|
|
106007
106950
|
}
|
|
106008
106951
|
checks.push(plainTmuxRow(firstOnPath("tmux"), safeBundledTmux()));
|
|
106009
|
-
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now()));
|
|
106952
|
+
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now(), liveServerStartMs()));
|
|
106010
106953
|
checks.push(nodeVersionRow(process.versions.node));
|
|
106011
106954
|
checks.push(
|
|
106012
106955
|
check(
|
|
@@ -111438,6 +112381,27 @@ var init_worktree = __esm({
|
|
|
111438
112381
|
}
|
|
111439
112382
|
});
|
|
111440
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
|
+
|
|
111441
112405
|
// packages/daemon/src/lib/managed-installer-update.ts
|
|
111442
112406
|
import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync48, realpathSync as realpathSync37, rmSync as rmSync10 } from "node:fs";
|
|
111443
112407
|
import { dirname as dirname57, join as join73 } from "node:path";
|
|
@@ -111629,8 +112593,13 @@ function planUpdate(input) {
|
|
|
111629
112593
|
guidance: guidance[method]
|
|
111630
112594
|
};
|
|
111631
112595
|
}
|
|
111632
|
-
function renderPlan2(plan, {
|
|
111633
|
-
|
|
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)`;
|
|
111634
112603
|
return [
|
|
111635
112604
|
status2,
|
|
111636
112605
|
"",
|
|
@@ -111640,11 +112609,19 @@ function renderPlan2(plan, { current, latest, dryRun }) {
|
|
|
111640
112609
|
"After updating, relaunch the app. Use tmux-ide update --daemon to replace a running daemon with installed code."
|
|
111641
112610
|
].join("\n");
|
|
111642
112611
|
}
|
|
111643
|
-
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 = {}) {
|
|
111644
112621
|
if (resolveRuntimeNamespace().development)
|
|
111645
112622
|
throw new Error("Development instances rebuild exact artifacts; package updates are disabled");
|
|
111646
112623
|
const current = (dependencies.currentVersion ?? getCurrentVersion)();
|
|
111647
|
-
const { latest } = (dependencies.status ??
|
|
112624
|
+
const { latest, source: latestSource = "registry" } = await (dependencies.status ?? ((scope2) => refreshUpdateStatus({ ...scope2, fetchLatest: dependencies.fetchLatest })))({ currentVersion: current });
|
|
111648
112625
|
const source = installOrigin(cliDir);
|
|
111649
112626
|
let plan = source.origin === "unknown" ? {
|
|
111650
112627
|
method: "unknown",
|
|
@@ -111680,19 +112657,27 @@ function runUpdate({ cliDir, dryRun, json: json3 = false }, dependencies = {}) {
|
|
|
111680
112657
|
}
|
|
111681
112658
|
}
|
|
111682
112659
|
const output = dependencies.output ?? console.log;
|
|
111683
|
-
if (!json3) output(renderPlan2(plan, { current, latest, dryRun }));
|
|
112660
|
+
if (!json3) output(renderPlan2(plan, { current, latest, dryRun, source: latestSource }));
|
|
111684
112661
|
let executed = false;
|
|
111685
112662
|
if (!dryRun && plan.executable && plan.args) {
|
|
111686
|
-
|
|
111687
|
-
|
|
111688
|
-
|
|
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
|
+
}
|
|
111689
112670
|
executed = true;
|
|
111690
112671
|
}
|
|
111691
112672
|
if (!dryRun && plan.installerPrefix && plan.channel) {
|
|
111692
|
-
|
|
112673
|
+
try {
|
|
112674
|
+
runManagedInstallerUpdate(plan.installerPrefix, plan.channel, json3, dependencies.execute);
|
|
112675
|
+
} catch (error) {
|
|
112676
|
+
throw updateFailure("the installer", error);
|
|
112677
|
+
}
|
|
111693
112678
|
executed = true;
|
|
111694
112679
|
}
|
|
111695
|
-
if (json3) output(JSON.stringify({ ...plan, current, latest, dryRun, executed }));
|
|
112680
|
+
if (json3) output(JSON.stringify({ ...plan, current, latest, latestSource, dryRun, executed }));
|
|
111696
112681
|
return plan;
|
|
111697
112682
|
}
|
|
111698
112683
|
var UPDATE_COMMANDS;
|
|
@@ -111703,6 +112688,7 @@ var init_update = __esm({
|
|
|
111703
112688
|
init_runtime_namespace();
|
|
111704
112689
|
init_semver();
|
|
111705
112690
|
init_update_check();
|
|
112691
|
+
init_errors2();
|
|
111706
112692
|
init_install_origin();
|
|
111707
112693
|
UPDATE_COMMANDS = {
|
|
111708
112694
|
npm: "npm install -g tmux-ide@latest",
|
|
@@ -111962,6 +112948,7 @@ init_compiled();
|
|
|
111962
112948
|
init_errors2();
|
|
111963
112949
|
init_output();
|
|
111964
112950
|
init_state_home();
|
|
112951
|
+
init_invocation_directory();
|
|
111965
112952
|
init_hosted();
|
|
111966
112953
|
configureTmuxClientResolver(resolveOrdinaryTmuxClient);
|
|
111967
112954
|
if (process.argv[2] === "__plugin-host") {
|
|
@@ -112334,7 +113321,7 @@ Install bun (https://bun.sh) \u2014 the TUI surfaces run on it. Sources ship wit
|
|
|
112334
113321
|
}
|
|
112335
113322
|
}
|
|
112336
113323
|
const env = openTuiLaunchEnvironment(process.env, {
|
|
112337
|
-
TMUX_IDE_CWD:
|
|
113324
|
+
TMUX_IDE_CWD: invocationDirectory(),
|
|
112338
113325
|
TMUX_IDE_CLI: nodeCliPath,
|
|
112339
113326
|
...automaticDiagnosticLog ? {
|
|
112340
113327
|
TMUX_IDE_TUI_LOG: automaticDiagnosticLog,
|
|
@@ -112425,7 +113412,7 @@ Install bun (https://bun.sh) \u2014 the TUI surfaces run on it. Sources ship wit
|
|
|
112425
113412
|
launch2.bin,
|
|
112426
113413
|
launch2.argv,
|
|
112427
113414
|
hostedEnvVars({
|
|
112428
|
-
cwd:
|
|
113415
|
+
cwd: invocationDirectory(),
|
|
112429
113416
|
cli: nodeCliPath,
|
|
112430
113417
|
path: process.env.PATH,
|
|
112431
113418
|
home: process.env.TMUX_IDE_HOME,
|
|
@@ -112620,7 +113607,10 @@ try {
|
|
|
112620
113607
|
port: values.port,
|
|
112621
113608
|
json: json2,
|
|
112622
113609
|
expectedVersion: pkg.version,
|
|
112623
|
-
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
|
|
112624
113614
|
});
|
|
112625
113615
|
await new Promise((resolveFlush) => process.stdout.write("", resolveFlush));
|
|
112626
113616
|
process.exit(0);
|
|
@@ -113306,8 +114296,8 @@ try {
|
|
|
113306
114296
|
process.exit(1);
|
|
113307
114297
|
}
|
|
113308
114298
|
const teams = await Promise.resolve().then(() => (init_claude_agent_teams(), claude_agent_teams_exports));
|
|
113309
|
-
const { homedir:
|
|
113310
|
-
const tilde = (text2) => text2.replaceAll(`${
|
|
114299
|
+
const { homedir: homedir12 } = await import("node:os");
|
|
114300
|
+
const tilde = (text2) => text2.replaceAll(`${homedir12()}/`, "~/");
|
|
113311
114301
|
if (action === "status") {
|
|
113312
114302
|
const status2 = teams.claudeAgentTeamsStatus();
|
|
113313
114303
|
if (json2) console.log(JSON.stringify(status2, null, 2));
|
|
@@ -113864,13 +114854,25 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
|
|
|
113864
114854
|
const current = inspectCanonicalDaemonInfo2();
|
|
113865
114855
|
if (current.status !== "valid")
|
|
113866
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
|
+
);
|
|
113867
114867
|
console.log(
|
|
113868
114868
|
json2 ? JSON.stringify({
|
|
113869
114869
|
ok: true,
|
|
113870
|
-
status:
|
|
114870
|
+
status: outcome.status,
|
|
113871
114871
|
productVersion: current.info.productVersion,
|
|
113872
|
-
instanceId: current.info.instanceId
|
|
113873
|
-
|
|
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
|
|
113874
114876
|
);
|
|
113875
114877
|
break;
|
|
113876
114878
|
}
|
|
@@ -113908,7 +114910,7 @@ Known panels: ${POPUP_WIDGETS2.join(", ")}.`,
|
|
|
113908
114910
|
}
|
|
113909
114911
|
const { runUpdate: runUpdate2 } = await Promise.resolve().then(() => (init_update(), update_exports));
|
|
113910
114912
|
const dryRun = values["dry-run"] === true;
|
|
113911
|
-
runUpdate2({ cliDir: __dirname5, dryRun, json: json2 });
|
|
114913
|
+
await runUpdate2({ cliDir: __dirname5, dryRun, json: json2 });
|
|
113912
114914
|
break;
|
|
113913
114915
|
}
|
|
113914
114916
|
case "skill-sync": {
|