@songsid/agend 2.3.5-alpha.5 → 2.3.5-alpha.6
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/THIRD_PARTY_NOTICES.md +0 -1
- package/dist/accounts-profiles.d.ts +96 -0
- package/dist/accounts-profiles.js +178 -0
- package/dist/accounts-profiles.js.map +1 -0
- package/dist/accounts-signout.d.ts +59 -0
- package/dist/accounts-signout.js +184 -0
- package/dist/accounts-signout.js.map +1 -0
- package/dist/accounts-view.d.ts +54 -0
- package/dist/accounts-view.js +55 -11
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-workspace.d.ts +11 -0
- package/dist/agent-workspace.js +28 -0
- package/dist/agent-workspace.js.map +1 -1
- package/dist/auth-api.js +27 -5
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/session-authorizations.d.ts +2 -0
- package/dist/authority/session-authorizations.js +7 -1
- package/dist/authority/session-authorizations.js.map +1 -1
- package/dist/backend/codex.js +1 -0
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/types.d.ts +2 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/bundled-tmux-guard.d.ts +19 -0
- package/dist/bundled-tmux-guard.js +83 -0
- package/dist/bundled-tmux-guard.js.map +1 -0
- package/dist/classic-bindings.d.ts +13 -0
- package/dist/classic-bindings.js +28 -2
- package/dist/classic-bindings.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +2 -0
- package/dist/classic-channel-manager.js +5 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +116 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +11 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +27 -2
- package/dist/daemon.js +107 -6
- package/dist/daemon.js.map +1 -1
- package/dist/doctor.js +3 -4
- package/dist/doctor.js.map +1 -1
- package/dist/e2e-isolation.js +5 -2
- package/dist/e2e-isolation.js.map +1 -1
- package/dist/fleet-control-audit.d.ts +1 -1
- package/dist/fleet-manager.d.ts +129 -0
- package/dist/fleet-manager.js +725 -53
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +10 -0
- package/dist/hub/compose/server.js +1 -0
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +1 -1
- package/dist/hub/directory/directory.js +115 -3
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/groups.d.ts +29 -0
- package/dist/hub/directory/groups.js +29 -0
- package/dist/hub/directory/groups.js.map +1 -0
- package/dist/hub/directory/index.d.ts +1 -0
- package/dist/hub/directory/types.d.ts +4 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/model.d.ts +56 -0
- package/dist/hub/group-policy/model.js +46 -0
- package/dist/hub/group-policy/model.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +52 -0
- package/dist/hub/group-policy/resources.js +166 -0
- package/dist/hub/group-policy/resources.js.map +1 -0
- package/dist/hub/group-policy/store.d.ts +52 -0
- package/dist/hub/group-policy/store.js +149 -0
- package/dist/hub/group-policy/store.js.map +1 -0
- package/dist/hub/http/compose.js +4 -3
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/pairing.d.ts +3 -1
- package/dist/hub/pairing.js +6 -3
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/server.d.ts +2 -0
- package/dist/hub/server.js +12 -2
- package/dist/hub/server.js.map +1 -1
- package/dist/instance-config-impact.js +4 -3
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +17 -0
- package/dist/instance-lifecycle.js +38 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +21 -0
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +5 -0
- package/dist/login-controller.js +11 -0
- package/dist/login-controller.js.map +1 -1
- package/dist/login-window-lock.d.ts +2 -1
- package/dist/login-window-lock.js.map +1 -1
- package/dist/ls-rows.d.ts +1 -1
- package/dist/ls-rows.js +1 -1
- package/dist/ls-rows.js.map +1 -1
- package/dist/machine-accounts.d.ts +110 -0
- package/dist/machine-accounts.js +229 -0
- package/dist/machine-accounts.js.map +1 -0
- package/dist/machine-signins.d.ts +89 -0
- package/dist/machine-signins.js +182 -0
- package/dist/machine-signins.js.map +1 -0
- package/dist/muse-usage-relay.d.ts +2 -0
- package/dist/muse-usage-relay.js +5 -3
- package/dist/muse-usage-relay.js.map +1 -1
- package/dist/needs-you-hub.d.ts +3 -0
- package/dist/needs-you-hub.js +13 -3
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +35 -2
- package/dist/needs-you.js +19 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/quickstart.js +7 -18
- package/dist/quickstart.js.map +1 -1
- package/dist/quiet-run.d.ts +31 -0
- package/dist/quiet-run.js +50 -0
- package/dist/quiet-run.js.map +1 -0
- package/dist/quota-notice-config.d.ts +22 -0
- package/dist/quota-notice-config.js +41 -0
- package/dist/quota-notice-config.js.map +1 -0
- package/dist/runtime-api.d.ts +13 -0
- package/dist/runtime-api.js +125 -1
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-build-info.d.ts +2 -1
- package/dist/runtime-build-info.js +7 -3
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-install.d.ts +153 -0
- package/dist/runtime-cli-install.js +675 -0
- package/dist/runtime-cli-install.js.map +1 -0
- package/dist/runtime-cli.js +157 -12
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client.d.ts +64 -2
- package/dist/runtime-client.js +277 -20
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +10 -1
- package/dist/runtime-coordinator.js +93 -2
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-credential-profiles.d.ts +11 -2
- package/dist/runtime-credential-profiles.js +28 -4
- package/dist/runtime-credential-profiles.js.map +1 -1
- package/dist/runtime-install.js +9 -6
- package/dist/runtime-install.js.map +1 -1
- package/dist/runtime-pane-link.js +2 -1
- package/dist/runtime-pane-link.js.map +1 -1
- package/dist/runtime-pane-service.js +2 -2
- package/dist/runtime-pane-service.js.map +1 -1
- package/dist/runtime-pane-store.d.ts +10 -0
- package/dist/runtime-pane-store.js +13 -1
- package/dist/runtime-pane-store.js.map +1 -1
- package/dist/runtime-profile-ownership.d.ts +66 -0
- package/dist/runtime-profile-ownership.js +391 -0
- package/dist/runtime-profile-ownership.js.map +1 -0
- package/dist/runtime-protocol.d.ts +88 -2
- package/dist/runtime-protocol.js +40 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +197 -0
- package/dist/runtime-remote-accounts.js +663 -0
- package/dist/runtime-remote-accounts.js.map +1 -0
- package/dist/runtime-remote-setup.d.ts +105 -0
- package/dist/runtime-remote-setup.js +529 -0
- package/dist/runtime-remote-setup.js.map +1 -0
- package/dist/runtime-signin-transport.d.ts +39 -0
- package/dist/runtime-signin-transport.js +110 -0
- package/dist/runtime-signin-transport.js.map +1 -0
- package/dist/runtime-signin.d.ts +132 -0
- package/dist/runtime-signin.js +289 -0
- package/dist/runtime-signin.js.map +1 -0
- package/dist/runtime-update-attention.d.ts +4 -0
- package/dist/runtime-update-attention.js +11 -0
- package/dist/runtime-update-attention.js.map +1 -0
- package/dist/runtime-update-controller.d.ts +75 -0
- package/dist/runtime-update-controller.js +691 -0
- package/dist/runtime-update-controller.js.map +1 -0
- package/dist/runtime-update-ipc.d.ts +42 -0
- package/dist/runtime-update-ipc.js +144 -0
- package/dist/runtime-update-ipc.js.map +1 -0
- package/dist/runtime-update-journal.d.ts +5 -0
- package/dist/runtime-update-journal.js +7 -0
- package/dist/runtime-update-journal.js.map +1 -1
- package/dist/runtime-update-lock.js +17 -2
- package/dist/runtime-update-lock.js.map +1 -1
- package/dist/runtime-update-status.d.ts +30 -0
- package/dist/runtime-update-status.js +31 -0
- package/dist/runtime-update-status.js.map +1 -0
- package/dist/settings-api.js +3 -0
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +8 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-instance-patch.js +1 -1
- package/dist/settings-instance-patch.js.map +1 -1
- package/dist/setup-wizard.js +3 -5
- package/dist/setup-wizard.js.map +1 -1
- package/dist/signin-keepalive.d.ts +203 -0
- package/dist/signin-keepalive.js +652 -0
- package/dist/signin-keepalive.js.map +1 -0
- package/dist/structured-signin-transport.js +4 -0
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/structured-signin.d.ts +7 -0
- package/dist/structured-signin.js +1 -1
- package/dist/structured-signin.js.map +1 -1
- package/dist/tmux-binary.d.ts +23 -23
- package/dist/tmux-binary.js +35 -46
- package/dist/tmux-binary.js.map +1 -1
- package/dist/tmux-exec-helper.js +3 -3
- package/dist/tmux-exec-helper.js.map +1 -1
- package/dist/tmux-legacy.d.ts +94 -0
- package/dist/tmux-legacy.js +309 -0
- package/dist/tmux-legacy.js.map +1 -0
- package/dist/tmux-manager.d.ts +7 -1
- package/dist/tmux-manager.js +21 -11
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tmux-rollback.d.ts +31 -0
- package/dist/tmux-rollback.js +72 -0
- package/dist/tmux-rollback.js.map +1 -0
- package/dist/tmux-server.d.ts +102 -0
- package/dist/tmux-server.js +248 -0
- package/dist/tmux-server.js.map +1 -0
- package/dist/transcript-monitor.js +43 -5
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-records.d.ts +2 -1
- package/dist/transcript-records.js +3 -0
- package/dist/transcript-records.js.map +1 -1
- package/dist/transcript-sources.js +3 -0
- package/dist/transcript-sources.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/ui/accounts-keepalive.js +112 -0
- package/dist/ui/accounts-manage.js +237 -0
- package/dist/ui/accounts-view.js +175 -31
- package/dist/ui/agent-runtime-settings.js +2 -1
- package/dist/ui/app.html +8 -1
- package/dist/ui/hub-attachments.js +90 -0
- package/dist/ui/hub-chat-store.js +9 -4
- package/dist/ui/hub-client.js +20 -1
- package/dist/ui/hub-preview.js +101 -0
- package/dist/ui/machine-signin.js +56 -0
- package/dist/ui/panel-fleet.js +1 -1
- package/dist/ui/panel-hub.js +126 -31
- package/dist/ui/panel-needs.js +14 -8
- package/dist/ui/panel-notices.js +4 -3
- package/dist/ui/panel-runtimes.js +19 -6
- package/dist/ui/panel-settings.js +12 -6
- package/dist/ui/panel-windows-agent.js +2 -1
- package/dist/ui/preview-pages.js +3 -41
- package/dist/ui/preview-panel-actions.js +3 -161
- package/dist/ui/preview-panel.js +10 -557
- package/dist/ui/preview-versions.js +3 -155
- package/dist/ui/runtime-cli-install.js +114 -0
- package/dist/ui/runtime-update-commands.d.ts +2 -0
- package/dist/ui/runtime-update-commands.js +11 -0
- package/dist/ui/runtime-update-status.js +53 -0
- package/dist/ui/search-dialog.js +3 -2
- package/dist/ui/settings-guests.js +3 -2
- package/dist/ui/settings-hub-browser-certificate.js +2 -0
- package/dist/ui/settings-hub-membership.js +12 -6
- package/dist/ui/settings-hub-retention.js +2 -0
- package/dist/ui/settings-hub.js +11 -3
- package/dist/ui/settings-quota-notice.js +100 -0
- package/dist/ui/settings-registry.js +1 -0
- package/dist/ui/settings-strings.js +2 -2
- package/dist/ui/settings-web-authority.js +2 -1
- package/dist/ui/shared/accounts-keepalive.css +7 -0
- package/dist/ui/shared/accounts.css +13 -0
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app-shell.js +9 -3
- package/dist/ui/shared/app-store.js +2 -2
- package/dist/ui/shared/app.css +13 -0
- package/dist/ui/shared/app.js +2 -1
- package/dist/ui/shared/hub-chat.css +1 -0
- package/dist/ui/shared/hub-owner.css +1 -1
- package/dist/ui/shared/loading.css +37 -0
- package/dist/ui/shared/preview-pages.js +41 -0
- package/dist/ui/shared/preview-panel-actions.js +168 -0
- package/dist/ui/shared/preview-panel.js +565 -0
- package/dist/ui/shared/preview-versions.js +155 -0
- package/dist/ui/shared/runtime-install.css +4 -0
- package/dist/ui/shared/signin.js +68 -6
- package/dist/ui/shared/ui-states.js +14 -3
- package/dist/ui/shared/workspace-follow.css +19 -0
- package/dist/ui/signin.html +7 -3
- package/dist/ui/structured-signin.js +31 -7
- package/dist/ui/workspace-follow-strings.js +28 -0
- package/dist/ui/workspace-panel.js +225 -36
- package/dist/update-install.d.ts +7 -0
- package/dist/update-install.js +23 -0
- package/dist/update-install.js.map +1 -1
- package/dist/usage/providers.d.ts +5 -0
- package/dist/usage/providers.js +5 -0
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/quota-notices.d.ts +38 -0
- package/dist/usage/quota-notices.js +160 -0
- package/dist/usage/quota-notices.js.map +1 -0
- package/dist/usage/usage-api.d.ts +1 -0
- package/dist/usage/usage-api.js +16 -0
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +33 -0
- package/dist/web-api.js +342 -8
- package/dist/web-api.js.map +1 -1
- package/dist/web-login.d.ts +35 -1
- package/dist/web-login.js +51 -5
- package/dist/web-login.js.map +1 -1
- package/dist/web-session.d.ts +11 -0
- package/dist/web-session.js +38 -1
- package/dist/web-session.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +1 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-signin-link.d.ts +42 -0
- package/dist/web-signin-link.js +110 -0
- package/dist/web-signin-link.js.map +1 -0
- package/dist/windows-cli-api.d.ts +6 -0
- package/dist/windows-cli-api.js +11 -0
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +3 -1
- package/dist/windows-cli-worker.js +18 -3
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/workspace-follow-parse.d.ts +36 -0
- package/dist/workspace-follow-parse.js +208 -0
- package/dist/workspace-follow-parse.js.map +1 -0
- package/dist/workspace-follow-records.d.ts +17 -0
- package/dist/workspace-follow-records.js +88 -0
- package/dist/workspace-follow-records.js.map +1 -0
- package/dist/workspace-follow.d.ts +41 -0
- package/dist/workspace-follow.js +143 -0
- package/dist/workspace-follow.js.map +1 -0
- package/dist/wsl-detect.d.ts +1 -0
- package/dist/wsl-detect.js +20 -0
- package/dist/wsl-detect.js.map +1 -0
- package/launcher/tmux-bundle.cjs +26 -10
- package/package.json +6 -2
- package/templates/runtime-install/install.ps1 +154 -13
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const WINDOW_SOCKET_TAG = "window-id.socket";
|
|
2
|
+
export declare const MIGRATION_JOURNAL = "tmux-migration.json";
|
|
3
|
+
export declare class LegacyWindowHoldError extends Error {
|
|
4
|
+
readonly instance: string;
|
|
5
|
+
readonly why: string;
|
|
6
|
+
constructor(instance: string, why: string);
|
|
7
|
+
}
|
|
8
|
+
export interface LegacyWindow {
|
|
9
|
+
session: string;
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
panePid: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Incarnation {
|
|
15
|
+
pid: number;
|
|
16
|
+
start: number;
|
|
17
|
+
}
|
|
18
|
+
export type Step = "checkpointed" | "killed" | "confirmed";
|
|
19
|
+
export interface Journal {
|
|
20
|
+
server: Incarnation | null;
|
|
21
|
+
windows: Record<string, {
|
|
22
|
+
windowId: string;
|
|
23
|
+
step: Step;
|
|
24
|
+
}>;
|
|
25
|
+
/** Instances the user released with `agend tmux-migrate --release`: their untagged window is left alone. */
|
|
26
|
+
released: Record<string, string>;
|
|
27
|
+
/** 2.3 window ids taken out of `window-id` and not settled yet (migrated, gone or released): the instance is checked. */
|
|
28
|
+
pending: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export declare function readJournal(agendHome: string): Journal;
|
|
31
|
+
export declare function writeJournal(agendHome: string, j: Journal): void;
|
|
32
|
+
/** The window-id file's state: no file, tagged with a socket (written with the bundled tmux on), or untagged (2.3). */
|
|
33
|
+
export declare function windowIdState(instanceDir: string, currentSocket?: string): {
|
|
34
|
+
kind: "none";
|
|
35
|
+
} | {
|
|
36
|
+
kind: "tagged";
|
|
37
|
+
id: string;
|
|
38
|
+
socket: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "untagged";
|
|
41
|
+
id: string;
|
|
42
|
+
};
|
|
43
|
+
/** Written beside window-id whenever the bundled tmux is on: the file is then known not to be 2.3's. */
|
|
44
|
+
export declare function tagWindowId(instanceDir: string, socket: string, windowId: string): void;
|
|
45
|
+
export declare function dropWindowId(instanceDir: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Move every untagged (2.3) window id into the journal's `pending` and remove its window-id file. Run at fleet start
|
|
48
|
+
* before any instance does anything, and per instance by migrateLegacyWindow. The journal is written before a file is
|
|
49
|
+
* removed, so a crash in between leaves the id in both places, never in neither. Returns the instances moved.
|
|
50
|
+
*/
|
|
51
|
+
export declare function sweepLegacyWindowIds(agendHome: string, instances: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
dir: string;
|
|
54
|
+
}>, currentSocket?: string): string[];
|
|
55
|
+
/** Whether a process tree (pid → [ppid, command line]) under `root` runs `binary` (its basename, as the command or argv[0..1]). */
|
|
56
|
+
export declare function treeRuns(procs: Map<number, {
|
|
57
|
+
ppid: number;
|
|
58
|
+
args: string;
|
|
59
|
+
}>, root: number, binary: string): boolean;
|
|
60
|
+
export interface LegacyProbes {
|
|
61
|
+
/** The system tmux on PATH (never the bundled one), or null. */
|
|
62
|
+
systemTmux(): Promise<string | null>;
|
|
63
|
+
/** Run the system tmux (args carry `-L <legacy socket>` for another home; none: the default socket): stdout, or a
|
|
64
|
+
* rejection whose message is tmux's stderr. */
|
|
65
|
+
tmux(bin: string, args: string[]): Promise<string>;
|
|
66
|
+
processes(): Promise<Map<number, {
|
|
67
|
+
ppid: number;
|
|
68
|
+
args: string;
|
|
69
|
+
}>>;
|
|
70
|
+
alive(pid: number): boolean;
|
|
71
|
+
sleep(ms: number): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
export interface MigrateArgs {
|
|
74
|
+
agendHome: string;
|
|
75
|
+
instance: string;
|
|
76
|
+
instanceDir: string;
|
|
77
|
+
session: string;
|
|
78
|
+
/** 2.3's socket for this home: null for the real home (tmux's default socket), else its hashed name. */
|
|
79
|
+
legacySocket: string | null;
|
|
80
|
+
/** The socket AgEnD runs now (tmuxSocket()): a window-id tagged for any other socket is not one of its windows. */
|
|
81
|
+
currentSocket?: string;
|
|
82
|
+
backendBinary: string;
|
|
83
|
+
checkpoint: () => Promise<void> | void;
|
|
84
|
+
probes?: LegacyProbes;
|
|
85
|
+
log?: (msg: string, data?: Record<string, unknown>) => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolves when this instance may start (nothing legacy, or its old window positively gone, or released); throws
|
|
89
|
+
* LegacyWindowHoldError when it must not.
|
|
90
|
+
*/
|
|
91
|
+
export declare function migrateLegacyWindow(a: MigrateArgs): Promise<"none" | "tagged" | "stale" | "migrated" | "released">;
|
|
92
|
+
/** `agend tmux-migrate --release <name>`: leave that instance's untagged window to the user; its next start goes ahead. */
|
|
93
|
+
export declare function releaseLegacyWindow(agendHome: string, instance: string, instanceDir: string, currentSocket?: string): string | null;
|
|
94
|
+
export declare const realLegacyProbes: LegacyProbes;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M-2457 PR C §6 rule 3: the 2.3.x → bundled-tmux hop. 2.3.x ran each agent in a window of the SYSTEM tmux on the
|
|
3
|
+
* DEFAULT socket (the real home) or on the home's hashed socket `agend-<hash6>` (another home); the bundled tmux runs
|
|
4
|
+
* its own server on another socket (`agend`, or `agend-<hash6>-b`: never 2.3's). Where the old server survived
|
|
5
|
+
* (launchd, a foreground fleet; also after a rollback to 2.3 and a second upgrade) its windows may still run agents,
|
|
6
|
+
* and a new window for the same instance would resume the same conversation twice. "The legacy server" below is the
|
|
7
|
+
* system tmux on 2.3's socket for this home (`legacySocket`: null = the default socket).
|
|
8
|
+
*
|
|
9
|
+
* Per instance, before it starts (the daemon calls migrateLegacyWindow):
|
|
10
|
+
* - The trigger: a window-id file without its socket tag (`window-id.socket`, written beside it while the bundled tmux
|
|
11
|
+
* is on) was written by 2.3 and names a window on the legacy server. Its id is moved into the journal (`pending`)
|
|
12
|
+
* and the file removed before anything else can read it — at fleet start for every instance (sweepLegacyWindowIds),
|
|
13
|
+
* and again here — so no reader of `window-id` ever acts on a 2.3 id on the new server, and a hold survives the
|
|
14
|
+
* instance's retries and restarts until the window is gone or released.
|
|
15
|
+
* - Prove the window ours: its #{window_id} is the file's, its name is the instance's, and its pane's process tree runs
|
|
16
|
+
* the instance's backend binary.
|
|
17
|
+
* - Checkpoint the instance's session id (the daemon's own checkpoint), kill-window it with the system tmux, and confirm
|
|
18
|
+
* it gone (the window no longer listed, its pane pid exited). Never kill-server: the default server may hold the
|
|
19
|
+
* user's own sessions; it exits by itself once empty.
|
|
20
|
+
* - Anything unprovable — a window that is not provably ours, no system tmux to ask about an untagged file, a default
|
|
21
|
+
* server that answers but can't be queried, a window that won't go — holds THAT instance (LegacyWindowHoldError);
|
|
22
|
+
* the rest of the fleet starts. `agend tmux-migrate --release <name>` lets the user take it from there.
|
|
23
|
+
* - The journal (`<AGEND_HOME>/tmux-migration.json`) records each window's step against the default server's
|
|
24
|
+
* incarnation (#{pid} + #{start_time}), so an interrupted migration resumes on the same server without checkpointing
|
|
25
|
+
* twice; another incarnation starts afresh.
|
|
26
|
+
* - Afterwards the untagged window-id file is removed: its window id means nothing on the new server (whose ids start
|
|
27
|
+
* again from @0) and must never be used there.
|
|
28
|
+
*
|
|
29
|
+
* Divergence from the design note, flagged in the PR: the tag is a sidecar file (`window-id.socket`) instead of a
|
|
30
|
+
* prefix inside `window-id` (`agend:@12`), so the many readers of `window-id` keep reading a bare window id.
|
|
31
|
+
*/
|
|
32
|
+
import { execFile } from "./child-process.js";
|
|
33
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
34
|
+
import { dirname, join } from "node:path";
|
|
35
|
+
export const WINDOW_SOCKET_TAG = "window-id.socket";
|
|
36
|
+
export const MIGRATION_JOURNAL = "tmux-migration.json";
|
|
37
|
+
export class LegacyWindowHoldError extends Error {
|
|
38
|
+
instance;
|
|
39
|
+
why;
|
|
40
|
+
constructor(instance, why) {
|
|
41
|
+
super(`An old tmux window for ${instance} may still be running (system tmux): ${why}. Close it, or run \`agend tmux-migrate --release ${instance}\`.`);
|
|
42
|
+
this.instance = instance;
|
|
43
|
+
this.why = why;
|
|
44
|
+
this.name = "LegacyWindowHoldError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const emptyJournal = () => ({ server: null, windows: {}, released: {}, pending: {} });
|
|
48
|
+
export function readJournal(agendHome) {
|
|
49
|
+
try {
|
|
50
|
+
const j = JSON.parse(readFileSync(join(agendHome, MIGRATION_JOURNAL), "utf8"));
|
|
51
|
+
if (!j || typeof j !== "object")
|
|
52
|
+
return emptyJournal();
|
|
53
|
+
const server = j.server && Number.isSafeInteger(j.server.pid) && Number.isSafeInteger(j.server.start) ? { pid: j.server.pid, start: j.server.start } : null;
|
|
54
|
+
const windows = {};
|
|
55
|
+
for (const [k, v] of Object.entries(j.windows ?? {})) {
|
|
56
|
+
const w = v;
|
|
57
|
+
if (w && typeof w.windowId === "string" && ["checkpointed", "killed", "confirmed"].includes(w.step))
|
|
58
|
+
windows[k] = { windowId: w.windowId, step: w.step };
|
|
59
|
+
}
|
|
60
|
+
const released = {};
|
|
61
|
+
for (const [k, v] of Object.entries(j.released ?? {}))
|
|
62
|
+
if (typeof v === "string")
|
|
63
|
+
released[k] = v;
|
|
64
|
+
const pending = {};
|
|
65
|
+
for (const [k, v] of Object.entries(j.pending ?? {}))
|
|
66
|
+
if (typeof v === "string" && /^@\d+$/.test(v))
|
|
67
|
+
pending[k] = v;
|
|
68
|
+
return { server, windows, released, pending };
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return emptyJournal();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function writeJournal(agendHome, j) {
|
|
75
|
+
const file = join(agendHome, MIGRATION_JOURNAL);
|
|
76
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
77
|
+
writeFileSync(`${file}.${process.pid}.tmp`, JSON.stringify(j, null, 2) + "\n");
|
|
78
|
+
renameSync(`${file}.${process.pid}.tmp`, file);
|
|
79
|
+
}
|
|
80
|
+
/** The window-id file's state: no file, tagged with a socket (written with the bundled tmux on), or untagged (2.3). */
|
|
81
|
+
export function windowIdState(instanceDir, currentSocket) {
|
|
82
|
+
let id = "";
|
|
83
|
+
try {
|
|
84
|
+
id = readFileSync(join(instanceDir, "window-id"), "utf8").trim();
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return { kind: "none" };
|
|
88
|
+
}
|
|
89
|
+
if (!id)
|
|
90
|
+
return { kind: "none" };
|
|
91
|
+
// The tag names the window id it was written for: after a rollback, 2.3 rewrites window-id and leaves a stale tag
|
|
92
|
+
// behind — a tag for another id is no tag.
|
|
93
|
+
try {
|
|
94
|
+
const [socket, taggedId] = readFileSync(join(instanceDir, WINDOW_SOCKET_TAG), "utf8").split("\n").map(x => x.trim());
|
|
95
|
+
// Fable #3312 N1: only a tag for the socket AgEnD runs now is ours. A tag naming another socket (an isolated home
|
|
96
|
+
// that ran the dark switch tagged `agend-<hash6>`, now 2.3's legacy name) is a window AgEnD's server doesn't hold.
|
|
97
|
+
if (socket && taggedId === id && (currentSocket === undefined || socket === currentSocket))
|
|
98
|
+
return { kind: "tagged", id, socket };
|
|
99
|
+
}
|
|
100
|
+
catch { /* untagged */ }
|
|
101
|
+
return { kind: "untagged", id };
|
|
102
|
+
}
|
|
103
|
+
/** Written beside window-id whenever the bundled tmux is on: the file is then known not to be 2.3's. */
|
|
104
|
+
export function tagWindowId(instanceDir, socket, windowId) {
|
|
105
|
+
writeFileSync(join(instanceDir, WINDOW_SOCKET_TAG), `${socket}\n${windowId}\n`);
|
|
106
|
+
}
|
|
107
|
+
export function dropWindowId(instanceDir) {
|
|
108
|
+
for (const f of ["window-id", WINDOW_SOCKET_TAG]) {
|
|
109
|
+
try {
|
|
110
|
+
unlinkSync(join(instanceDir, f));
|
|
111
|
+
}
|
|
112
|
+
catch { /* gone */ }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Move every untagged (2.3) window id into the journal's `pending` and remove its window-id file. Run at fleet start
|
|
117
|
+
* before any instance does anything, and per instance by migrateLegacyWindow. The journal is written before a file is
|
|
118
|
+
* removed, so a crash in between leaves the id in both places, never in neither. Returns the instances moved.
|
|
119
|
+
*/
|
|
120
|
+
export function sweepLegacyWindowIds(agendHome, instances, currentSocket) {
|
|
121
|
+
const moved = [];
|
|
122
|
+
const j = readJournal(agendHome);
|
|
123
|
+
for (const i of instances) {
|
|
124
|
+
const state = windowIdState(i.dir, currentSocket);
|
|
125
|
+
if (state.kind !== "untagged" || !/^@\d+$/.test(state.id))
|
|
126
|
+
continue;
|
|
127
|
+
j.pending[i.name] = state.id;
|
|
128
|
+
moved.push(i);
|
|
129
|
+
}
|
|
130
|
+
if (!moved.length)
|
|
131
|
+
return [];
|
|
132
|
+
writeJournal(agendHome, j);
|
|
133
|
+
for (const i of moved)
|
|
134
|
+
dropWindowId(i.dir);
|
|
135
|
+
return moved.map(i => i.name);
|
|
136
|
+
}
|
|
137
|
+
function settle(agendHome, instance) {
|
|
138
|
+
const j = readJournal(agendHome);
|
|
139
|
+
if (!(instance in j.pending))
|
|
140
|
+
return;
|
|
141
|
+
delete j.pending[instance];
|
|
142
|
+
writeJournal(agendHome, j);
|
|
143
|
+
}
|
|
144
|
+
/** Whether a process tree (pid → [ppid, command line]) under `root` runs `binary` (its basename, as the command or argv[0..1]). */
|
|
145
|
+
export function treeRuns(procs, root, binary) {
|
|
146
|
+
const want = binary.split("/").pop();
|
|
147
|
+
const runs = (args) => args.split(/\s+/).slice(0, 2).some(w => w.split("/").pop() === want);
|
|
148
|
+
const seen = new Set();
|
|
149
|
+
const queue = [root];
|
|
150
|
+
while (queue.length) {
|
|
151
|
+
const pid = queue.shift();
|
|
152
|
+
if (seen.has(pid))
|
|
153
|
+
continue;
|
|
154
|
+
seen.add(pid);
|
|
155
|
+
const p = procs.get(pid);
|
|
156
|
+
if (p && runs(p.args))
|
|
157
|
+
return true;
|
|
158
|
+
for (const [child, c] of procs)
|
|
159
|
+
if (c.ppid === pid)
|
|
160
|
+
queue.push(child);
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
const NO_SERVER = /no server running|error connecting|No such file or directory|server exited/i;
|
|
165
|
+
/** An answer AgEnD could not read. Typed, so its text (window names, the user's own) is never matched as NO_SERVER. */
|
|
166
|
+
class UnreadableAnswer extends Error {
|
|
167
|
+
}
|
|
168
|
+
/** A field separator tmux prints as is: without a UTF-8 locale tmux prints a TAB in -F output as `_` (Fable #3276). */
|
|
169
|
+
const SEP = "|||";
|
|
170
|
+
const WINDOW_LINE = /^(.*)\|\|\|(@\d+)\|\|\|(.*)\|\|\|(\d+)$/;
|
|
171
|
+
/**
|
|
172
|
+
* Resolves when this instance may start (nothing legacy, or its old window positively gone, or released); throws
|
|
173
|
+
* LegacyWindowHoldError when it must not.
|
|
174
|
+
*/
|
|
175
|
+
export async function migrateLegacyWindow(a) {
|
|
176
|
+
const p = a.probes ?? realLegacyProbes;
|
|
177
|
+
const before = windowIdState(a.instanceDir, a.currentSocket);
|
|
178
|
+
sweepLegacyWindowIds(a.agendHome, [{ name: a.instance, dir: a.instanceDir }], a.currentSocket);
|
|
179
|
+
const journal = readJournal(a.agendHome);
|
|
180
|
+
const legacyId = journal.pending[a.instance];
|
|
181
|
+
if (!legacyId)
|
|
182
|
+
return before.kind === "tagged" ? "tagged" : "none";
|
|
183
|
+
const state = { id: legacyId };
|
|
184
|
+
const hold = (why) => { a.log?.("legacy tmux window held", { instance: a.instance, why }); return new LegacyWindowHoldError(a.instance, why); };
|
|
185
|
+
if (journal.released[a.instance] === state.id) {
|
|
186
|
+
settle(a.agendHome, a.instance);
|
|
187
|
+
return "released";
|
|
188
|
+
}
|
|
189
|
+
const tmux = (bin, args) => p.tmux(bin, a.legacySocket ? ["-L", a.legacySocket, ...args] : args);
|
|
190
|
+
const bin = await p.systemTmux();
|
|
191
|
+
if (!bin)
|
|
192
|
+
throw hold("its window id was written by AgEnD 2.3, and there is no system tmux to ask whether that window still runs");
|
|
193
|
+
let incarnation;
|
|
194
|
+
let windows;
|
|
195
|
+
try {
|
|
196
|
+
const [pid, start] = (await tmux(bin, ["display-message", "-p", "#{pid} #{start_time}"])).trim().split(/\s+/).map(Number);
|
|
197
|
+
if (!Number.isSafeInteger(pid) || !Number.isSafeInteger(start))
|
|
198
|
+
throw new UnreadableAnswer("unexpected answer");
|
|
199
|
+
incarnation = { pid: pid, start: start };
|
|
200
|
+
const out = await tmux(bin, ["list-windows", "-a", "-F", ["#{session_name}", "#{window_id}", "#{window_name}", "#{pane_pid}"].join(SEP)]);
|
|
201
|
+
windows = [];
|
|
202
|
+
for (const line of out.split("\n").filter(Boolean)) {
|
|
203
|
+
// An answer AgEnD can't read is never taken for "the window is gone": that would drop the id while the 2.3 window
|
|
204
|
+
// still runs its agent. Only a well-formed list without the id (or no server at all) may.
|
|
205
|
+
const m = WINDOW_LINE.exec(line);
|
|
206
|
+
if (!m)
|
|
207
|
+
throw new UnreadableAnswer(`unexpected list-windows answer "${line.slice(0, 80)}"`);
|
|
208
|
+
windows.push({ session: m[1], id: m[2], name: m[3], panePid: Number(m[4]) });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
const msg = String(e.message ?? e);
|
|
213
|
+
// Only tmux's own failure (its stderr) may say "no server"; an answer AgEnD couldn't read never does (Fable #3276).
|
|
214
|
+
if (!(e instanceof UnreadableAnswer) && NO_SERVER.test(msg)) {
|
|
215
|
+
settle(a.agendHome, a.instance);
|
|
216
|
+
return "stale";
|
|
217
|
+
} // no legacy server: the window is gone
|
|
218
|
+
throw hold(`the old tmux server answers but can't be queried (${msg.split("\n")[0].slice(0, 160)})`);
|
|
219
|
+
}
|
|
220
|
+
// By id only: ids are unique per server, and a window the user moved to another session still runs the agent.
|
|
221
|
+
const w = windows.find(x => x.id === state.id);
|
|
222
|
+
if (!w) {
|
|
223
|
+
settle(a.agendHome, a.instance);
|
|
224
|
+
return "stale";
|
|
225
|
+
}
|
|
226
|
+
if (w.name !== a.instance)
|
|
227
|
+
throw hold(`window ${w.id} is named "${w.name}", not "${a.instance}"`);
|
|
228
|
+
if (!treeRuns(await p.processes(), w.panePid, a.backendBinary))
|
|
229
|
+
throw hold(`window ${w.id} does not run ${a.backendBinary}`);
|
|
230
|
+
// A journal for another server incarnation is stale: start a fresh pass on this one.
|
|
231
|
+
const j = journal.server && journal.server.pid === incarnation.pid && journal.server.start === incarnation.start
|
|
232
|
+
? journal : { server: incarnation, windows: {}, released: journal.released, pending: journal.pending };
|
|
233
|
+
const step = j.windows[a.instance]?.windowId === w.id ? j.windows[a.instance].step : null;
|
|
234
|
+
if (!step) {
|
|
235
|
+
await a.checkpoint();
|
|
236
|
+
j.windows[a.instance] = { windowId: w.id, step: "checkpointed" };
|
|
237
|
+
writeJournal(a.agendHome, j);
|
|
238
|
+
}
|
|
239
|
+
if (step !== "killed" && step !== "confirmed") {
|
|
240
|
+
try {
|
|
241
|
+
await tmux(bin, ["kill-window", "-t", w.id]);
|
|
242
|
+
}
|
|
243
|
+
catch { /* confirmed below */ }
|
|
244
|
+
j.windows[a.instance] = { windowId: w.id, step: "killed" };
|
|
245
|
+
writeJournal(a.agendHome, j);
|
|
246
|
+
}
|
|
247
|
+
for (let i = 0; i < 50; i++) {
|
|
248
|
+
let listed = false;
|
|
249
|
+
try {
|
|
250
|
+
listed = (await tmux(bin, ["list-windows", "-a", "-F", "#{window_id}"])).split("\n").includes(w.id);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
if (!NO_SERVER.test(String(e.message ?? e)))
|
|
254
|
+
listed = true;
|
|
255
|
+
}
|
|
256
|
+
if (!listed && !p.alive(w.panePid)) {
|
|
257
|
+
j.windows[a.instance] = { windowId: w.id, step: "confirmed" };
|
|
258
|
+
delete j.pending[a.instance];
|
|
259
|
+
writeJournal(a.agendHome, j);
|
|
260
|
+
a.log?.("legacy tmux window migrated", { instance: a.instance, window: w.id });
|
|
261
|
+
return "migrated";
|
|
262
|
+
}
|
|
263
|
+
await p.sleep(100);
|
|
264
|
+
}
|
|
265
|
+
throw hold(`window ${w.id} did not close`);
|
|
266
|
+
}
|
|
267
|
+
/** `agend tmux-migrate --release <name>`: leave that instance's untagged window to the user; its next start goes ahead. */
|
|
268
|
+
export function releaseLegacyWindow(agendHome, instance, instanceDir, currentSocket) {
|
|
269
|
+
sweepLegacyWindowIds(agendHome, [{ name: instance, dir: instanceDir }], currentSocket);
|
|
270
|
+
const j = readJournal(agendHome);
|
|
271
|
+
const id = j.pending[instance];
|
|
272
|
+
if (!id)
|
|
273
|
+
return null;
|
|
274
|
+
j.released[instance] = id; // the next start sees it released, settles it and goes ahead
|
|
275
|
+
writeJournal(agendHome, j);
|
|
276
|
+
return id;
|
|
277
|
+
}
|
|
278
|
+
const run = (file, args, env) => new Promise((resolve, reject) => execFile(file, args, { timeout: 5000, encoding: "utf8", ...(env ? { env } : {}) }, (err, stdout, stderr) => err ? reject(new Error((stderr || err.message).trim())) : resolve(stdout)));
|
|
279
|
+
export const realLegacyProbes = {
|
|
280
|
+
async systemTmux() {
|
|
281
|
+
for (const dir of (process.env.PATH ?? "").split(":").filter(Boolean)) {
|
|
282
|
+
const f = join(dir, "tmux");
|
|
283
|
+
if (existsSync(f))
|
|
284
|
+
return f;
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
},
|
|
288
|
+
// The default socket: no -L/-S; never a caller's $TMUX (a client inside another server would talk to that one).
|
|
289
|
+
tmux: (bin, args) => { const env = { ...process.env }; delete env.TMUX; delete env.TMUX_PANE; return run(bin, args, env); },
|
|
290
|
+
async processes() {
|
|
291
|
+
const out = await run("ps", ["-A", "-o", "pid=", "-o", "ppid=", "-o", "args="]);
|
|
292
|
+
const m = new Map();
|
|
293
|
+
for (const line of out.split("\n")) {
|
|
294
|
+
const r = /^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(line);
|
|
295
|
+
if (r)
|
|
296
|
+
m.set(Number(r[1]), { ppid: Number(r[2]), args: r[3] });
|
|
297
|
+
}
|
|
298
|
+
return m;
|
|
299
|
+
},
|
|
300
|
+
alive(pid) { try {
|
|
301
|
+
process.kill(pid, 0);
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
catch (e) {
|
|
305
|
+
return e.code === "EPERM";
|
|
306
|
+
} },
|
|
307
|
+
sleep: (ms) => new Promise(r => setTimeout(r, ms)),
|
|
308
|
+
};
|
|
309
|
+
//# sourceMappingURL=tmux-legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmux-legacy.js","sourceRoot":"","sources":["../src/tmux-legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AACpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACzB,QAAQ;IAAmB,GAAG;IAAnD,YAAqB,QAAgB,EAAW,GAAW;QACzD,KAAK,CAAC,0BAA0B,QAAQ,wCAAwC,GAAG,qDAAqD,QAAQ,K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AC,CAAC;IAC3H,KAAK,CAAC,SAAS;QACb,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAChF,MAAM,CAAC,GAAG,IAAI,GAAG,EAA0C,CAAC;QAC5D,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,MAAM,CAAC,GAAG,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC;gBAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;QAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAAC,OAAQ,CAA2B,CAAC,IAAI,KAAK,OAAO,CAAC;IAAC,CAAC,CAAC,CAAC;IAC7H,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;CACnD,CAAC"}
|
package/dist/tmux-manager.d.ts
CHANGED
|
@@ -20,9 +20,15 @@ export declare class TmuxManager implements Pane {
|
|
|
20
20
|
private lastPasteFailureRecoverable;
|
|
21
21
|
private static socketName;
|
|
22
22
|
static setSocketName(name: string | null): void;
|
|
23
|
-
/** Prefix tmux args with -L
|
|
23
|
+
/** Prefix tmux args with -L (the socket set by the fleet, else this home's: never tmux's default) and the -f config. */
|
|
24
24
|
private static tmuxArgs;
|
|
25
25
|
constructor(sessionName: string, windowId: string, logicalSize?: TmuxLogicalSize, readPort?: TmuxReadPort | undefined);
|
|
26
|
+
/** M-2457 §6: while set, no session is created (an old tmux server AgEnD could not prove its own may hold the socket). */
|
|
27
|
+
private static heldReason;
|
|
28
|
+
static setHold(reason: string | null): void;
|
|
29
|
+
/** M-2457 §6 rule 2: called after ensureSession created the session — after a server crash, that is a new server. */
|
|
30
|
+
private static sessionCreated;
|
|
31
|
+
static onSessionCreated(fn: ((name: string) => Promise<void>) | null): void;
|
|
26
32
|
static ensureSession(name: string): Promise<void>;
|
|
27
33
|
/** PID identifies a concrete tmux server generation. */
|
|
28
34
|
static getServerPid(sessionName: string): Promise<number | null>;
|
package/dist/tmux-manager.js
CHANGED
|
@@ -3,7 +3,7 @@ import { promisify } from "node:util";
|
|
|
3
3
|
import { tmuxWindowTarget, tmuxReadArgs } from "./tmux-read.js";
|
|
4
4
|
import { tmuxExecHelper } from "./tmux-exec-helper.js";
|
|
5
5
|
import { measureSyncWork } from "./sync-work-attribution.js";
|
|
6
|
-
import {
|
|
6
|
+
import { tmuxBinary, tmuxConfArgs, tmuxEnv, tmuxSocket } from "./tmux-binary.js";
|
|
7
7
|
const execAsync = promisify(execFile);
|
|
8
8
|
/**
|
|
9
9
|
* Every `tmux` (and `stty`) call here. Starting a child process is synchronous on the fleet's loop — a fork whose cost
|
|
@@ -11,12 +11,12 @@ const execAsync = promisify(execFile);
|
|
|
11
11
|
* is the direct call, attributed as "tmux.spawn" as before. Either way: the same command, once; the same result.
|
|
12
12
|
*/
|
|
13
13
|
const exec = ((file, args, given) => {
|
|
14
|
-
// M-2457: the bundled tmux runs with its own environment (tmux-binary.ts)
|
|
15
|
-
const opts =
|
|
16
|
-
return tmuxExecHelper.exec(file, args, opts
|
|
14
|
+
// M-2457: the bundled tmux runs with its own environment (tmux-binary.ts).
|
|
15
|
+
const opts = { ...(given ?? {}), env: tmuxEnv() };
|
|
16
|
+
return tmuxExecHelper.exec(file, args, opts, () => measureSyncWork("tmux.spawn", () => execAsync(file, args, opts)));
|
|
17
17
|
});
|
|
18
|
-
/** The bundled tmux's environment for a call
|
|
19
|
-
const bundledEnv = () => (
|
|
18
|
+
/** The bundled tmux's environment for a call: spread into the options. */
|
|
19
|
+
const bundledEnv = () => ({ env: tmuxEnv() });
|
|
20
20
|
/** `exec`, bounded when a timeout is given — and in exactly the old (file, args) form when it is not. */
|
|
21
21
|
const execBounded = (args, timeoutMs) => timeoutMs ? exec(tmuxBinary(), args, { timeout: timeoutMs }) : exec(tmuxBinary(), args);
|
|
22
22
|
/** Keys sendKeySequence may send: cursor moves and deletions inside an input line. */
|
|
@@ -109,12 +109,9 @@ export class TmuxManager {
|
|
|
109
109
|
static setSocketName(name) {
|
|
110
110
|
TmuxManager.socketName = name;
|
|
111
111
|
}
|
|
112
|
-
/** Prefix tmux args with -L
|
|
112
|
+
/** Prefix tmux args with -L (the socket set by the fleet, else this home's: never tmux's default) and the -f config. */
|
|
113
113
|
static tmuxArgs(args) {
|
|
114
|
-
|
|
115
|
-
if (!TmuxManager.socketName)
|
|
116
|
-
return conf.length ? [...conf, ...args] : args;
|
|
117
|
-
return ["-L", TmuxManager.socketName, ...conf, ...args];
|
|
114
|
+
return ["-L", TmuxManager.socketName ?? tmuxSocket(), ...tmuxConfArgs(), ...args];
|
|
118
115
|
}
|
|
119
116
|
constructor(sessionName, windowId, logicalSize = { ...DEFAULT_TMUX_LOGICAL_SIZE }, readPort) {
|
|
120
117
|
this.sessionName = sessionName;
|
|
@@ -123,16 +120,26 @@ export class TmuxManager {
|
|
|
123
120
|
this.windowId = windowId;
|
|
124
121
|
}
|
|
125
122
|
// === Static session-level methods ===
|
|
123
|
+
/** M-2457 §6: while set, no session is created (an old tmux server AgEnD could not prove its own may hold the socket). */
|
|
124
|
+
static heldReason = null;
|
|
125
|
+
static setHold(reason) { TmuxManager.heldReason = reason; }
|
|
126
|
+
/** M-2457 §6 rule 2: called after ensureSession created the session — after a server crash, that is a new server. */
|
|
127
|
+
static sessionCreated = null;
|
|
128
|
+
static onSessionCreated(fn) { TmuxManager.sessionCreated = fn; }
|
|
126
129
|
static async ensureSession(name) {
|
|
130
|
+
if (TmuxManager.heldReason)
|
|
131
|
+
throw new Error(TmuxManager.heldReason);
|
|
127
132
|
const existing = TmuxManager.ensureSessionInFlight.get(name);
|
|
128
133
|
if (existing)
|
|
129
134
|
return existing;
|
|
130
135
|
const operation = (async () => {
|
|
136
|
+
let created = false;
|
|
131
137
|
// Strict: only a POSITIVE "no such session" leads to creating one. A
|
|
132
138
|
// timeout or spawn failure rejects instead of being read as "absent".
|
|
133
139
|
if (!(await TmuxManager.sessionExistsStrict(name))) {
|
|
134
140
|
try {
|
|
135
141
|
await exec(tmuxBinary(), TmuxManager.tmuxArgs(["new-session", "-d", "-s", name]), { timeout: LOGIN_TMUX_OP_TIMEOUT_MS });
|
|
142
|
+
created = true;
|
|
136
143
|
}
|
|
137
144
|
catch (err) {
|
|
138
145
|
if (!String(err).includes("duplicate session"))
|
|
@@ -144,6 +151,9 @@ export class TmuxManager {
|
|
|
144
151
|
await exec(tmuxBinary(), TmuxManager.tmuxArgs([
|
|
145
152
|
"set-option", "-t", name, "mouse", "on",
|
|
146
153
|
]), { timeout: LOGIN_TMUX_OP_TIMEOUT_MS });
|
|
154
|
+
// The fleet records the server it now runs on (server.json): a rollback or a handover must know it.
|
|
155
|
+
if (created && TmuxManager.sessionCreated)
|
|
156
|
+
await TmuxManager.sessionCreated(name).catch(() => { });
|
|
147
157
|
})().finally(() => {
|
|
148
158
|
if (TmuxManager.ensureSessionInFlight.get(name) === operation) {
|
|
149
159
|
TmuxManager.ensureSessionInFlight.delete(name);
|