@indianic/dialout 1.1.1 → 1.2.0
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/README.md +429 -16
- package/bin/AGENTS.md +44 -0
- package/bin/devdash-agent.js +2 -0
- package/dist/ai-adapters/claude.d.ts +3 -0
- package/dist/ai-adapters/claude.d.ts.map +1 -0
- package/dist/ai-adapters/claude.js +98 -0
- package/dist/ai-adapters/claude.js.map +1 -0
- package/dist/ai-adapters/codex.d.ts +3 -0
- package/dist/ai-adapters/codex.d.ts.map +1 -0
- package/dist/ai-adapters/codex.js +147 -0
- package/dist/ai-adapters/codex.js.map +1 -0
- package/dist/ai-adapters/grok.d.ts +3 -0
- package/dist/ai-adapters/grok.d.ts.map +1 -0
- package/dist/ai-adapters/grok.js +164 -0
- package/dist/ai-adapters/grok.js.map +1 -0
- package/dist/ai-adapters/index.d.ts +5 -0
- package/dist/ai-adapters/index.d.ts.map +1 -0
- package/dist/ai-adapters/index.js +30 -0
- package/dist/ai-adapters/index.js.map +1 -0
- package/dist/ai-adapters/types.d.ts +3 -0
- package/dist/ai-adapters/types.d.ts.map +1 -0
- package/dist/ai-adapters/types.js +7 -0
- package/dist/ai-adapters/types.js.map +1 -0
- package/dist/ai-capabilities/claude.d.ts +4 -0
- package/dist/ai-capabilities/claude.d.ts.map +1 -0
- package/dist/ai-capabilities/claude.js +174 -0
- package/dist/ai-capabilities/claude.js.map +1 -0
- package/dist/ai-capabilities/describe.d.ts +2 -0
- package/dist/ai-capabilities/describe.d.ts.map +1 -0
- package/dist/ai-capabilities/describe.js +31 -0
- package/dist/ai-capabilities/describe.js.map +1 -0
- package/dist/ai-capabilities/fsdeps.d.ts +3 -0
- package/dist/ai-capabilities/fsdeps.d.ts.map +1 -0
- package/dist/ai-capabilities/fsdeps.js +71 -0
- package/dist/ai-capabilities/fsdeps.js.map +1 -0
- package/dist/ai-capabilities/grok.d.ts +5 -0
- package/dist/ai-capabilities/grok.d.ts.map +1 -0
- package/dist/ai-capabilities/grok.js +145 -0
- package/dist/ai-capabilities/grok.js.map +1 -0
- package/dist/ai-capabilities/index.d.ts +4 -0
- package/dist/ai-capabilities/index.d.ts.map +1 -0
- package/dist/ai-capabilities/index.js +94 -0
- package/dist/ai-capabilities/index.js.map +1 -0
- package/dist/ai-capabilities/redact.d.ts +2 -0
- package/dist/ai-capabilities/redact.d.ts.map +1 -0
- package/dist/ai-capabilities/redact.js +27 -0
- package/dist/ai-capabilities/redact.js.map +1 -0
- package/dist/ai-capabilities/types.d.ts +11 -0
- package/dist/ai-capabilities/types.d.ts.map +1 -0
- package/dist/ai-capabilities/types.js +3 -0
- package/dist/ai-capabilities/types.js.map +1 -0
- package/dist/ai-launch.d.ts +35 -0
- package/dist/ai-launch.d.ts.map +1 -0
- package/dist/ai-launch.js +211 -0
- package/dist/ai-launch.js.map +1 -0
- package/dist/ai-session-detector.d.ts +19 -0
- package/dist/ai-session-detector.d.ts.map +1 -0
- package/dist/ai-session-detector.js +79 -0
- package/dist/ai-session-detector.js.map +1 -0
- package/dist/ai-sessions.d.ts +36 -0
- package/dist/ai-sessions.d.ts.map +1 -0
- package/dist/ai-sessions.js +309 -0
- package/dist/ai-sessions.js.map +1 -0
- package/dist/ai-status.d.ts +6 -0
- package/dist/ai-status.d.ts.map +1 -0
- package/dist/ai-status.js +40 -0
- package/dist/ai-status.js.map +1 -0
- package/dist/ai-transcript-locator.d.ts +35 -0
- package/dist/ai-transcript-locator.d.ts.map +1 -0
- package/dist/ai-transcript-locator.js +268 -0
- package/dist/ai-transcript-locator.js.map +1 -0
- package/dist/ai-transcript-tail.d.ts +17 -0
- package/dist/ai-transcript-tail.d.ts.map +1 -0
- package/dist/ai-transcript-tail.js +120 -0
- package/dist/ai-transcript-tail.js.map +1 -0
- package/dist/checklist.d.ts +20 -0
- package/dist/checklist.d.ts.map +1 -0
- package/dist/checklist.js +51 -0
- package/dist/checklist.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1427 -0
- package/dist/cli.js.map +1 -0
- package/dist/command-runner.d.ts +15 -0
- package/dist/command-runner.d.ts.map +1 -0
- package/dist/command-runner.js +84 -0
- package/dist/command-runner.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +152 -0
- package/dist/config.js.map +1 -0
- package/dist/cowork.d.ts +26 -0
- package/dist/cowork.d.ts.map +1 -0
- package/dist/cowork.js +370 -0
- package/dist/cowork.js.map +1 -0
- package/dist/fs-browser.d.ts +6 -0
- package/dist/fs-browser.d.ts.map +1 -0
- package/dist/fs-browser.js +61 -0
- package/dist/fs-browser.js.map +1 -0
- package/dist/has-command.d.ts +12 -0
- package/dist/has-command.d.ts.map +1 -0
- package/dist/has-command.js +24 -0
- package/dist/has-command.js.map +1 -0
- package/dist/heartbeat.d.ts +7 -0
- package/dist/heartbeat.d.ts.map +1 -0
- package/dist/heartbeat.js +50 -0
- package/dist/heartbeat.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/port-scanner.d.ts +4 -0
- package/dist/port-scanner.d.ts.map +1 -0
- package/dist/port-scanner.js +75 -0
- package/dist/port-scanner.js.map +1 -0
- package/dist/project-scanner.d.ts +15 -0
- package/dist/project-scanner.d.ts.map +1 -0
- package/dist/project-scanner.js +333 -0
- package/dist/project-scanner.js.map +1 -0
- package/dist/pty-manager.d.ts +28 -0
- package/dist/pty-manager.d.ts.map +1 -0
- package/dist/pty-manager.js +506 -0
- package/dist/pty-manager.js.map +1 -0
- package/dist/service-installer.d.ts +95 -0
- package/dist/service-installer.d.ts.map +1 -0
- package/dist/service-installer.js +911 -0
- package/dist/service-installer.js.map +1 -0
- package/dist/single-instance.d.ts +20 -0
- package/dist/single-instance.d.ts.map +1 -0
- package/dist/single-instance.js +151 -0
- package/dist/single-instance.js.map +1 -0
- package/dist/ssh-local-network.d.ts +26 -0
- package/dist/ssh-local-network.d.ts.map +1 -0
- package/dist/ssh-local-network.js +169 -0
- package/dist/ssh-local-network.js.map +1 -0
- package/dist/terminal-detect.d.ts +52 -0
- package/dist/terminal-detect.d.ts.map +1 -0
- package/dist/terminal-detect.js +147 -0
- package/dist/terminal-detect.js.map +1 -0
- package/dist/terminal-markers.d.ts +52 -0
- package/dist/terminal-markers.d.ts.map +1 -0
- package/dist/terminal-markers.js +174 -0
- package/dist/terminal-markers.js.map +1 -0
- package/dist/tmux-manager.d.ts +35 -0
- package/dist/tmux-manager.d.ts.map +1 -0
- package/dist/tmux-manager.js +274 -0
- package/dist/tmux-manager.js.map +1 -0
- package/dist/update-check.d.ts +3 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +202 -0
- package/dist/update-check.js.map +1 -0
- package/dist/websocket.d.ts +8 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +472 -0
- package/dist/websocket.js.map +1 -0
- package/node_modules/@dialout/shared/README.md +16 -0
- package/node_modules/@dialout/shared/dist/ai-chat-prefs.d.ts +8 -0
- package/node_modules/@dialout/shared/dist/ai-chat-prefs.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/ai-chat-prefs.js +41 -0
- package/node_modules/@dialout/shared/dist/capabilities.d.ts +25 -0
- package/node_modules/@dialout/shared/dist/capabilities.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/capabilities.js +2 -0
- package/node_modules/@dialout/shared/dist/chat-blocks.d.ts +33 -0
- package/node_modules/@dialout/shared/dist/chat-blocks.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/chat-blocks.js +61 -0
- package/node_modules/@dialout/shared/dist/command-filter.d.ts +4 -0
- package/node_modules/@dialout/shared/dist/command-filter.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/command-filter.js +49 -0
- package/node_modules/@dialout/shared/dist/composer-behaviour.d.ts +6 -0
- package/node_modules/@dialout/shared/dist/composer-behaviour.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/composer-behaviour.js +24 -0
- package/node_modules/@dialout/shared/dist/events.d.ts +37 -0
- package/node_modules/@dialout/shared/dist/events.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/events.js +13 -0
- package/node_modules/@dialout/shared/dist/index.d.ts +21 -0
- package/node_modules/@dialout/shared/dist/index.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/index.js +37 -0
- package/node_modules/@dialout/shared/dist/kinds.d.ts +2 -0
- package/node_modules/@dialout/shared/dist/kinds.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/kinds.js +2 -0
- package/node_modules/@dialout/shared/dist/notify.d.ts +3 -0
- package/node_modules/@dialout/shared/dist/notify.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/notify.js +31 -0
- package/node_modules/@dialout/shared/dist/permission.d.ts +4 -0
- package/node_modules/@dialout/shared/dist/permission.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/permission.js +8 -0
- package/node_modules/@dialout/shared/dist/scroll-pin.d.ts +3 -0
- package/node_modules/@dialout/shared/dist/scroll-pin.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/scroll-pin.js +11 -0
- package/node_modules/@dialout/shared/dist/session.d.ts +19 -0
- package/node_modules/@dialout/shared/dist/session.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/session.js +6 -0
- package/node_modules/@dialout/shared/dist/terminal-name.d.ts +25 -0
- package/node_modules/@dialout/shared/dist/terminal-name.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/terminal-name.js +63 -0
- package/node_modules/@dialout/shared/dist/tool-appearance.d.ts +9 -0
- package/node_modules/@dialout/shared/dist/tool-appearance.d.ts.map +1 -0
- package/node_modules/@dialout/shared/dist/tool-appearance.js +30 -0
- package/node_modules/@dialout/shared/package.json +37 -0
- package/node_modules/@dialout/shared/src/ai-chat-prefs.test.ts +40 -0
- package/node_modules/@dialout/shared/src/ai-chat-prefs.ts +39 -0
- package/node_modules/@dialout/shared/src/capabilities.ts +30 -0
- package/node_modules/@dialout/shared/src/chat-blocks.test.ts +65 -0
- package/node_modules/@dialout/shared/src/chat-blocks.ts +79 -0
- package/node_modules/@dialout/shared/src/command-filter.test.ts +76 -0
- package/node_modules/@dialout/shared/src/command-filter.ts +45 -0
- package/node_modules/@dialout/shared/src/composer-behaviour.test.ts +31 -0
- package/node_modules/@dialout/shared/src/composer-behaviour.ts +22 -0
- package/node_modules/@dialout/shared/src/events.ts +27 -0
- package/node_modules/@dialout/shared/src/index.ts +32 -0
- package/node_modules/@dialout/shared/src/kinds.ts +5 -0
- package/node_modules/@dialout/shared/src/notify.test.ts +49 -0
- package/node_modules/@dialout/shared/src/notify.ts +30 -0
- package/node_modules/@dialout/shared/src/permission.ts +10 -0
- package/node_modules/@dialout/shared/src/scroll-pin.test.ts +23 -0
- package/node_modules/@dialout/shared/src/scroll-pin.ts +13 -0
- package/node_modules/@dialout/shared/src/session.ts +25 -0
- package/node_modules/@dialout/shared/src/terminal-name.ts +82 -0
- package/node_modules/@dialout/shared/src/tool-appearance.test.ts +41 -0
- package/node_modules/@dialout/shared/src/tool-appearance.ts +39 -0
- package/package.json +54 -14
- package/scripts/postinstall.js +79 -0
- package/scripts/prepack.js +45 -0
- package/bin/dialout.js +0 -13
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.currentTerminalToken = currentTerminalToken;
|
|
37
|
+
exports.detectTerminals = detectTerminals;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const os = __importStar(require("os"));
|
|
41
|
+
const has_command_1 = require("./has-command");
|
|
42
|
+
const terminal_markers_1 = require("./terminal-markers");
|
|
43
|
+
// token = TERM_PROGRAM value unless noted; runtime marker fallbacks handled in
|
|
44
|
+
// currentTerminalToken(). Order here is the checklist's base order.
|
|
45
|
+
const KNOWN_TERMINALS = [
|
|
46
|
+
{ name: 'Hyper', token: 'Hyper', appBundles: ['Hyper.app'], linuxBins: ['hyper'] },
|
|
47
|
+
{ name: 'iTerm', token: 'iTerm.app', appBundles: ['iTerm.app'], linuxBins: [] },
|
|
48
|
+
{ name: 'Apple Terminal', token: 'Apple_Terminal', appBundles: ['Terminal.app'], linuxBins: [] },
|
|
49
|
+
{ name: 'VS Code', token: 'vscode', appBundles: ['Visual Studio Code.app', 'Code.app'], linuxBins: ['code'] },
|
|
50
|
+
{ name: 'Ghostty', token: 'ghostty', appBundles: ['Ghostty.app'], linuxBins: ['ghostty'] },
|
|
51
|
+
{ name: 'WezTerm', token: 'WezTerm', appBundles: ['WezTerm.app'], linuxBins: ['wezterm'] },
|
|
52
|
+
{ name: 'Kitty', token: 'kitty', appBundles: ['kitty.app'], linuxBins: ['kitty'] },
|
|
53
|
+
{ name: 'Alacritty', token: 'alacritty', appBundles: ['Alacritty.app'], linuxBins: ['alacritty'] },
|
|
54
|
+
{ name: 'GNOME Terminal', token: 'gnome-terminal', appBundles: [], linuxBins: ['gnome-terminal'] },
|
|
55
|
+
{ name: 'Konsole', token: 'konsole', appBundles: [], linuxBins: ['konsole'] },
|
|
56
|
+
// Newly-detectable via the /proc process-tree fallback (terminal-markers.ts)
|
|
57
|
+
// — appended after Konsole so the existing macOS checklist order is untouched.
|
|
58
|
+
{ name: 'Tilix', token: 'tilix', appBundles: [], linuxBins: ['tilix'] },
|
|
59
|
+
{ name: 'Terminator', token: 'terminator', appBundles: [], linuxBins: ['terminator'] },
|
|
60
|
+
{ name: 'XFCE Terminal', token: 'xfce4-terminal', appBundles: [], linuxBins: ['xfce4-terminal'] },
|
|
61
|
+
{ name: 'Foot', token: 'foot', appBundles: [], linuxBins: ['foot'] },
|
|
62
|
+
{ name: 'urxvt', token: 'urxvt', appBundles: [], linuxBins: ['urxvt'] },
|
|
63
|
+
{ name: 'xterm', token: 'xterm', appBundles: [], linuxBins: ['xterm'] },
|
|
64
|
+
];
|
|
65
|
+
const APP_DIRS = [
|
|
66
|
+
'/Applications',
|
|
67
|
+
path.join(os.homedir(), 'Applications'),
|
|
68
|
+
'/System/Applications',
|
|
69
|
+
'/System/Applications/Utilities',
|
|
70
|
+
];
|
|
71
|
+
function defaultAppExists(bundle) {
|
|
72
|
+
for (const dir of APP_DIRS) {
|
|
73
|
+
try {
|
|
74
|
+
if (fs.existsSync(path.join(dir, bundle)))
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
/* FS error → treat as not present, keep checking */
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Canonical token for the terminal setup is running in, or "" if unknown.
|
|
85
|
+
* Delegates to the shared terminal-markers.ts table so this can never drift
|
|
86
|
+
* from the generated shell gate (cowork.ts): tokenFromEnv() first (handles
|
|
87
|
+
* the TMUX guard, TERM_PROGRAM, and ENV_MARKERS), then — only on linux, where
|
|
88
|
+
* /proc exists — tokenFromProcTree() walks up from the ppid for the emulators
|
|
89
|
+
* that set no distinguishing env var at all (xfce4-terminal, foot, urxvt,
|
|
90
|
+
* xterm, st, ...). macOS never reaches the /proc fallback: behavior there is
|
|
91
|
+
* unchanged.
|
|
92
|
+
*
|
|
93
|
+
* The generic GENERIC_ENV_TOKEN ("vte") result is PROVISIONAL: every VTE-based
|
|
94
|
+
* terminal exports VTE_VERSION, so treating it as final shadowed every
|
|
95
|
+
* PROC_NAMES entry that is also VTE-based (xfce4-terminal today; guake,
|
|
96
|
+
* mate-terminal tomorrow) and made their checklist rows unreachable. So the
|
|
97
|
+
* walk still runs for it and a specific token wins, with "vte" restored when
|
|
98
|
+
* the walk finds nothing. The emitted shell walk guard does exactly the same
|
|
99
|
+
* (renderProcWalk in cowork.ts) — that is the invariant.
|
|
100
|
+
*/
|
|
101
|
+
function currentTerminalToken(env = process.env, deps = {}) {
|
|
102
|
+
const token = (0, terminal_markers_1.tokenFromEnv)(env);
|
|
103
|
+
if (token !== '' && token !== terminal_markers_1.GENERIC_ENV_TOKEN)
|
|
104
|
+
return token;
|
|
105
|
+
const platform = deps.platform ?? process.platform;
|
|
106
|
+
// Non-linux has no /proc: keep whatever env gave us (including "vte").
|
|
107
|
+
if (platform !== 'linux')
|
|
108
|
+
return token;
|
|
109
|
+
const ppid = deps.ppid ?? process.ppid;
|
|
110
|
+
return (0, terminal_markers_1.tokenFromProcTree)(ppid, deps.procDeps) || token;
|
|
111
|
+
}
|
|
112
|
+
function detectTerminals(deps = {}) {
|
|
113
|
+
const env = deps.env ?? process.env;
|
|
114
|
+
const platform = deps.platform ?? process.platform;
|
|
115
|
+
const appExists = deps.appExists ?? defaultAppExists;
|
|
116
|
+
const hasCommand = deps.hasCommand ?? has_command_1.hasCommand;
|
|
117
|
+
const currentToken = currentTerminalToken(env, {
|
|
118
|
+
platform,
|
|
119
|
+
ppid: deps.ppid,
|
|
120
|
+
procDeps: deps.procDeps,
|
|
121
|
+
});
|
|
122
|
+
const rows = KNOWN_TERMINALS.map((e) => {
|
|
123
|
+
const installed = platform === 'darwin'
|
|
124
|
+
? e.appBundles.some(appExists)
|
|
125
|
+
: e.linuxBins.some(hasCommand);
|
|
126
|
+
return {
|
|
127
|
+
name: e.name,
|
|
128
|
+
token: e.token,
|
|
129
|
+
appBundles: e.appBundles,
|
|
130
|
+
installed,
|
|
131
|
+
current: currentToken !== '' && e.token === currentToken,
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
// Always-include rule: current terminal isn't in the known table → append it
|
|
135
|
+
// so the user can always pick "this terminal."
|
|
136
|
+
if (currentToken !== '' && !rows.some((r) => r.token === currentToken)) {
|
|
137
|
+
rows.push({
|
|
138
|
+
name: currentToken,
|
|
139
|
+
token: currentToken,
|
|
140
|
+
appBundles: [],
|
|
141
|
+
installed: true,
|
|
142
|
+
current: true,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return rows;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=terminal-detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-detect.js","sourceRoot":"","sources":["../src/terminal-detect.ts"],"names":[],"mappings":";;;;;;;;;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,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAoB,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACtD,MAAM,SAAS,GAAG,QAAQ,KAAK,QAAQ;YACrC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;YAC9B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjC,OAAO;YACL,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,SAAS;YACT,OAAO,EAAE,YAAY,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,YAAY;SACzD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,6EAA6E;IAC7E,+CAA+C;IAC/C,IAAI,YAAY,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,YAAY,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,YAAY;YACnB,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface EnvMarker {
|
|
2
|
+
/** Env var whose non-empty presence identifies the terminal. */
|
|
3
|
+
envVar: string;
|
|
4
|
+
/** Canonical token, must satisfy /^[A-Za-z0-9._-]+$/. */
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The generic VTE catch-all token (ENV_MARKERS' last entry).
|
|
9
|
+
*
|
|
10
|
+
* PROVISIONAL, not final. Every VTE-based terminal exports VTE_VERSION, so a
|
|
11
|
+
* bare `vte` result only means "some VTE terminal" — it does NOT mean env
|
|
12
|
+
* resolution identified the emulator. Terminals like xfce4-terminal set no
|
|
13
|
+
* specific env marker but ARE in PROC_NAMES, so a `vte` result must not stop
|
|
14
|
+
* resolution: the /proc walk still runs and a specific token from it wins,
|
|
15
|
+
* with `vte` restored when the walk finds nothing. Both sides implement this —
|
|
16
|
+
* currentTerminalToken() in terminal-detect.ts and the walk guard emitted by
|
|
17
|
+
* renderProcWalk() in cowork.ts — so they resolve identically (Constraint 5).
|
|
18
|
+
*
|
|
19
|
+
* Without it, the "XFCE Terminal" checklist row could never be `current` and
|
|
20
|
+
* selecting it was a silent no-op: the exact bug this branch exists to fix.
|
|
21
|
+
*/
|
|
22
|
+
export declare const GENERIC_ENV_TOKEN = "vte";
|
|
23
|
+
export declare const ENV_MARKERS: EnvMarker[];
|
|
24
|
+
/** Resolve a token from env: TERM_PROGRAM first, then ENV_MARKERS in order. */
|
|
25
|
+
export declare function tokenFromEnv(env: NodeJS.ProcessEnv): string;
|
|
26
|
+
/** Linux emulator process names (from /proc/<pid>/comm) → canonical token. */
|
|
27
|
+
export declare const PROC_NAMES: Record<string, string>;
|
|
28
|
+
export interface ProcDeps {
|
|
29
|
+
/** Returns the trimmed contents of /proc/<pid>/comm. */
|
|
30
|
+
readComm?: (pid: number) => string;
|
|
31
|
+
/** Returns the ppid parsed from /proc/<pid>/stat. */
|
|
32
|
+
readPPid?: (pid: number) => number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses the ppid out of raw /proc/<pid>/stat contents. Must parse from the
|
|
36
|
+
* LAST ")" forward: the process name (2nd field, in parens) can itself
|
|
37
|
+
* contain spaces and parentheses, so a naive whitespace split would grab the
|
|
38
|
+
* wrong field. After the last ")" the remaining fields are: state, ppid, ...
|
|
39
|
+
*/
|
|
40
|
+
export declare function ppidFromStat(stat: string): number;
|
|
41
|
+
/**
|
|
42
|
+
* Walks up the process tree from startPid, at most 10 levels, looking for a
|
|
43
|
+
* comm that matches PROC_NAMES. Returns the first matching token, or '' if
|
|
44
|
+
* nothing matched, the bound was hit, or any read failed.
|
|
45
|
+
*
|
|
46
|
+
* This runs on every interactive shell start (via the generated rc block's
|
|
47
|
+
* shell-equivalent walk), so the 10-level bound is a hard requirement, and a
|
|
48
|
+
* read failure (e.g. no /proc on macOS) must end the walk silently rather
|
|
49
|
+
* than throw.
|
|
50
|
+
*/
|
|
51
|
+
export declare function tokenFromProcTree(startPid: number, deps?: ProcDeps): string;
|
|
52
|
+
//# sourceMappingURL=terminal-markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-markers.d.ts","sourceRoot":"","sources":["../src/terminal-markers.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS;IACxB,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AAOvC,eAAO,MAAM,WAAW,EAAE,SAAS,EAUlC,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAQ3D;AASD,8EAA8E;AAC9E,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgB7C,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAUD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,QAAa,GAAG,MAAM,CAkC/E"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Single source of truth for "which env var proves which terminal". Both the
|
|
3
|
+
// generated shell gate (cowork.ts) and Node-side detection (terminal-detect.ts)
|
|
4
|
+
// are rewired onto this table so they can no longer drift apart.
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PROC_NAMES = exports.ENV_MARKERS = exports.GENERIC_ENV_TOKEN = void 0;
|
|
40
|
+
exports.tokenFromEnv = tokenFromEnv;
|
|
41
|
+
exports.ppidFromStat = ppidFromStat;
|
|
42
|
+
exports.tokenFromProcTree = tokenFromProcTree;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
/**
|
|
45
|
+
* The generic VTE catch-all token (ENV_MARKERS' last entry).
|
|
46
|
+
*
|
|
47
|
+
* PROVISIONAL, not final. Every VTE-based terminal exports VTE_VERSION, so a
|
|
48
|
+
* bare `vte` result only means "some VTE terminal" — it does NOT mean env
|
|
49
|
+
* resolution identified the emulator. Terminals like xfce4-terminal set no
|
|
50
|
+
* specific env marker but ARE in PROC_NAMES, so a `vte` result must not stop
|
|
51
|
+
* resolution: the /proc walk still runs and a specific token from it wins,
|
|
52
|
+
* with `vte` restored when the walk finds nothing. Both sides implement this —
|
|
53
|
+
* currentTerminalToken() in terminal-detect.ts and the walk guard emitted by
|
|
54
|
+
* renderProcWalk() in cowork.ts — so they resolve identically (Constraint 5).
|
|
55
|
+
*
|
|
56
|
+
* Without it, the "XFCE Terminal" checklist row could never be `current` and
|
|
57
|
+
* selecting it was a silent no-op: the exact bug this branch exists to fix.
|
|
58
|
+
*/
|
|
59
|
+
exports.GENERIC_ENV_TOKEN = 'vte';
|
|
60
|
+
// Order matters: more specific markers first, VTE_VERSION last as the generic
|
|
61
|
+
// catch-all — every VTE-based terminal (gnome-terminal, tilix, terminator,
|
|
62
|
+
// xfce4-terminal, guake) sets it, so it's only reached when nothing more
|
|
63
|
+
// specific matched. See GENERIC_ENV_TOKEN: matching it is provisional, and the
|
|
64
|
+
// /proc walk still gets a chance to name the emulator exactly.
|
|
65
|
+
exports.ENV_MARKERS = [
|
|
66
|
+
{ envVar: 'KITTY_WINDOW_ID', token: 'kitty' },
|
|
67
|
+
{ envVar: 'ALACRITTY_WINDOW_ID', token: 'alacritty' },
|
|
68
|
+
{ envVar: 'WEZTERM_PANE', token: 'WezTerm' },
|
|
69
|
+
{ envVar: 'KONSOLE_VERSION', token: 'konsole' },
|
|
70
|
+
{ envVar: 'TILIX_ID', token: 'tilix' },
|
|
71
|
+
{ envVar: 'TERMINATOR_UUID', token: 'terminator' },
|
|
72
|
+
{ envVar: 'GNOME_TERMINAL_SCREEN', token: 'gnome-terminal' },
|
|
73
|
+
{ envVar: 'GNOME_TERMINAL_SERVICE', token: 'gnome-terminal' },
|
|
74
|
+
{ envVar: 'VTE_VERSION', token: exports.GENERIC_ENV_TOKEN },
|
|
75
|
+
];
|
|
76
|
+
/** Resolve a token from env: TERM_PROGRAM first, then ENV_MARKERS in order. */
|
|
77
|
+
function tokenFromEnv(env) {
|
|
78
|
+
// Inside tmux the real outer app is unknowable → report unknown.
|
|
79
|
+
if (env.TMUX || env.TERM_PROGRAM === 'tmux')
|
|
80
|
+
return '';
|
|
81
|
+
if (env.TERM_PROGRAM)
|
|
82
|
+
return env.TERM_PROGRAM;
|
|
83
|
+
for (const { envVar, token } of exports.ENV_MARKERS) {
|
|
84
|
+
if (env[envVar])
|
|
85
|
+
return token;
|
|
86
|
+
}
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
// --- /proc process-tree fallback ---
|
|
90
|
+
//
|
|
91
|
+
// Some Linux terminals (xfce4-terminal, foot, urxvt, xterm, st, ...) set no
|
|
92
|
+
// distinguishing env var at all, so tokenFromEnv() returns '' for them. These
|
|
93
|
+
// can still be identified by walking up the process tree (via /proc) and
|
|
94
|
+
// matching the emulator's process name.
|
|
95
|
+
/** Linux emulator process names (from /proc/<pid>/comm) → canonical token. */
|
|
96
|
+
exports.PROC_NAMES = {
|
|
97
|
+
'xfce4-terminal': 'xfce4-terminal',
|
|
98
|
+
foot: 'foot',
|
|
99
|
+
urxvt: 'urxvt',
|
|
100
|
+
'rxvt-unicode': 'urxvt',
|
|
101
|
+
xterm: 'xterm',
|
|
102
|
+
st: 'st',
|
|
103
|
+
konsole: 'konsole',
|
|
104
|
+
// The kernel truncates /proc/<pid>/comm to 15 chars, so
|
|
105
|
+
// "gnome-terminal-server" is stored (and looked up) as "gnome-terminal-".
|
|
106
|
+
'gnome-terminal-': 'gnome-terminal',
|
|
107
|
+
tilix: 'tilix',
|
|
108
|
+
terminator: 'terminator',
|
|
109
|
+
alacritty: 'alacritty',
|
|
110
|
+
kitty: 'kitty',
|
|
111
|
+
'wezterm-gui': 'WezTerm',
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Parses the ppid out of raw /proc/<pid>/stat contents. Must parse from the
|
|
115
|
+
* LAST ")" forward: the process name (2nd field, in parens) can itself
|
|
116
|
+
* contain spaces and parentheses, so a naive whitespace split would grab the
|
|
117
|
+
* wrong field. After the last ")" the remaining fields are: state, ppid, ...
|
|
118
|
+
*/
|
|
119
|
+
function ppidFromStat(stat) {
|
|
120
|
+
const rest = stat.slice(stat.lastIndexOf(')') + 1).trim().split(/\s+/);
|
|
121
|
+
return parseInt(rest[1], 10);
|
|
122
|
+
}
|
|
123
|
+
function defaultReadComm(pid) {
|
|
124
|
+
return fs.readFileSync(`/proc/${pid}/comm`, 'utf8').trim();
|
|
125
|
+
}
|
|
126
|
+
function defaultReadPPid(pid) {
|
|
127
|
+
return ppidFromStat(fs.readFileSync(`/proc/${pid}/stat`, 'utf8'));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Walks up the process tree from startPid, at most 10 levels, looking for a
|
|
131
|
+
* comm that matches PROC_NAMES. Returns the first matching token, or '' if
|
|
132
|
+
* nothing matched, the bound was hit, or any read failed.
|
|
133
|
+
*
|
|
134
|
+
* This runs on every interactive shell start (via the generated rc block's
|
|
135
|
+
* shell-equivalent walk), so the 10-level bound is a hard requirement, and a
|
|
136
|
+
* read failure (e.g. no /proc on macOS) must end the walk silently rather
|
|
137
|
+
* than throw.
|
|
138
|
+
*/
|
|
139
|
+
function tokenFromProcTree(startPid, deps = {}) {
|
|
140
|
+
const readComm = deps.readComm ?? defaultReadComm;
|
|
141
|
+
const readPPid = deps.readPPid ?? defaultReadPPid;
|
|
142
|
+
let pid = startPid;
|
|
143
|
+
for (let level = 0; level < 10; level++) {
|
|
144
|
+
if (pid <= 1)
|
|
145
|
+
return '';
|
|
146
|
+
let comm;
|
|
147
|
+
try {
|
|
148
|
+
comm = readComm(pid);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return '';
|
|
152
|
+
}
|
|
153
|
+
// Guard against prototype-chain collisions: a comm of e.g. "constructor"
|
|
154
|
+
// or "toString" is a valid (if adversarial) 15-char-or-shorter process
|
|
155
|
+
// name, and PROC_NAMES is a plain object literal, so an unguarded
|
|
156
|
+
// PROC_NAMES[comm] lookup would resolve to an inherited Object.prototype
|
|
157
|
+
// member (a function, always truthy) instead of undefined.
|
|
158
|
+
if (Object.prototype.hasOwnProperty.call(exports.PROC_NAMES, comm)) {
|
|
159
|
+
return exports.PROC_NAMES[comm];
|
|
160
|
+
}
|
|
161
|
+
let ppid;
|
|
162
|
+
try {
|
|
163
|
+
ppid = readPPid(pid);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
if (!Number.isFinite(ppid))
|
|
169
|
+
return '';
|
|
170
|
+
pid = ppid;
|
|
171
|
+
}
|
|
172
|
+
return '';
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=terminal-markers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-markers.js","sourceRoot":"","sources":["../src/terminal-markers.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAI,GAAG,GAAG,QAAQ,CAAC;IACnB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,IAAI,GAAG,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QAExB,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,yEAAyE;QACzE,uEAAuE;QACvE,kEAAkE;QAClE,yEAAyE;QACzE,2DAA2D;QAC3D,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAU,EAAE,IAAI,CAAC,EAAE,CAAC;YAC3D,OAAO,kBAAU,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QACtC,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface TmuxSessionInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
createdAt: number;
|
|
4
|
+
attached: number;
|
|
5
|
+
lastActivity: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
termProgram: string;
|
|
9
|
+
origin: 'native' | 'browser';
|
|
10
|
+
folder: string;
|
|
11
|
+
folderPath: string;
|
|
12
|
+
createdLocal: string;
|
|
13
|
+
gitBranch: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const SEP = "\u001F";
|
|
16
|
+
export declare function tmuxLocaleEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
17
|
+
export declare function tmuxAvailable(now?: () => number): Promise<boolean>;
|
|
18
|
+
/** Test seam: forget the cached probe result. */
|
|
19
|
+
export declare function resetTmuxAvailableCache(): void;
|
|
20
|
+
export declare function parseSessionLine(line: string): Omit<TmuxSessionInfo, 'termProgram' | 'origin'> | null;
|
|
21
|
+
export declare function getSessionOption(name: string, option: string): Promise<string>;
|
|
22
|
+
export declare function listSessions(): Promise<TmuxSessionInfo[]>;
|
|
23
|
+
export declare function tmuxSessionName(id: string): string;
|
|
24
|
+
export interface KillDeps {
|
|
25
|
+
run?: (args: string[]) => Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
export interface KillResult {
|
|
28
|
+
ok: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function killTmuxSession(name: string, deps?: KillDeps): Promise<KillResult>;
|
|
32
|
+
export declare function countClients(name: string): Promise<number>;
|
|
33
|
+
export declare function tailLines(text: string, lines: number): string;
|
|
34
|
+
export declare function capturePane(name: string, lines: number): Promise<string>;
|
|
35
|
+
//# sourceMappingURL=tmux-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmux-manager.d.ts","sourceRoot":"","sources":["../src/tmux-manager.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,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