cssprobe-cli 0.2.5 → 0.2.7

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.
@@ -77,16 +77,29 @@ function resolveProfile(args) {
77
77
  const rc = readRcFile();
78
78
  return rc.profiles[name] || {};
79
79
  }
80
+ function parseViewport(raw) {
81
+ const match = raw.match(/^(\d+)\s*[xX*](\d+)$/);
82
+ if (!match)
83
+ return undefined;
84
+ const width = Number(match[1]);
85
+ const height = Number(match[2]);
86
+ if (width > 0 && height > 0)
87
+ return { width, height };
88
+ return undefined;
89
+ }
80
90
  function loadConfig(args) {
81
91
  const profile = resolveProfile(args);
82
92
  const browser = args.browser || process.env.CSSPROBE_BROWSER || profile.browser || 'chromium';
83
93
  const depthRaw = args.depth ?? process.env.CSSPROBE_DEPTH ?? profile.depth;
84
94
  const depth = depthRaw ? Number(depthRaw) : 6;
85
95
  const headed = !!(args.headed || process.env.CSSPROBE_HEADED === 'true' || profile.headed === 'true');
96
+ const viewportRaw = args.viewport || process.env.CSSPROBE_VIEWPORT || profile.viewport;
97
+ const viewport = viewportRaw ? parseViewport(viewportRaw) : undefined;
86
98
  return {
87
99
  browser,
88
100
  depth: Number.isNaN(depth) ? 6 : depth,
89
101
  headed,
102
+ viewport,
90
103
  output: args.json ? 'json' : 'text',
91
104
  raw: !!args.raw,
92
105
  };
@@ -96,6 +109,7 @@ function maskConfig(config) {
96
109
  browser: config.browser,
97
110
  depth: String(config.depth),
98
111
  headed: String(config.headed),
112
+ ...(config.viewport ? { viewport: `${config.viewport.width}x${config.viewport.height}` } : {}),
99
113
  };
100
114
  }
101
115
  function writeRcConfig(key, value, profileName) {
@@ -80,7 +80,9 @@ function generateCommandHelp(command) {
80
80
  return lines.join('\n');
81
81
  }
82
82
  const categories = [
83
- { name: 'core', title: 'Inspection' },
83
+ { name: 'core', title: 'Session Management' },
84
+ { name: 'cssprobe', title: 'CSS Inspection' },
85
+ { name: 'export', title: 'Export' },
84
86
  { name: 'config', title: 'Configuration' },
85
87
  { name: 'skill', title: 'Agent Skills' },
86
88
  ];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Daemon process for cssprobe-cli.
3
+ * Manages browser and executes commands via Unix socket.
4
+ * Adapted from playwright-cli.
5
+ */
6
+ import type { ClientInfo } from './session';
7
+ export interface DaemonOptions {
8
+ headed?: boolean;
9
+ browser?: string;
10
+ }
11
+ export declare function startDaemon(sessionName: string, clientInfo: ClientInfo, options: DaemonOptions): Promise<string>;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ /**
3
+ * Daemon process for cssprobe-cli.
4
+ * Manages browser and executes commands via Unix socket.
5
+ * Adapted from playwright-cli.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.startDaemon = startDaemon;
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const net_1 = __importDefault(require("net"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const socketConnection_1 = require("../utils/socketConnection");
16
+ const launcher_1 = require("../browser/launcher");
17
+ const analyzer_1 = require("../engine/analyzer");
18
+ const renderer_1 = require("../engine/renderer");
19
+ async function startDaemon(sessionName, clientInfo, options) {
20
+ const sessionConfig = createSessionConfig(clientInfo, sessionName, options);
21
+ const { socketPath } = sessionConfig;
22
+ // Clean up existing socket file on Unix
23
+ if (process.platform !== 'win32' && await socketExists(socketPath)) {
24
+ try {
25
+ await fs_1.default.promises.unlink(socketPath);
26
+ }
27
+ catch (error) {
28
+ throw error;
29
+ }
30
+ }
31
+ // Create browser launcher
32
+ const launcher = new launcher_1.BrowserLauncher({
33
+ browser: options.browser || 'chromium',
34
+ headed: options.headed !== false,
35
+ });
36
+ const server = net_1.default.createServer(socket => {
37
+ const connection = new socketConnection_1.SocketConnection(socket);
38
+ connection.onmessage = async (message) => {
39
+ const { id, method, params } = message;
40
+ try {
41
+ if (method === 'stop') {
42
+ await deleteSessionFile(sessionConfig);
43
+ await launcher.close();
44
+ connection.send({ id, result: 'ok' }).catch(() => { });
45
+ process.exit(0);
46
+ }
47
+ else if (method === 'run') {
48
+ const result = await executeCommand(launcher, params.args);
49
+ await connection.send({ id, result });
50
+ }
51
+ else {
52
+ throw new Error(`Unknown method: ${method}`);
53
+ }
54
+ }
55
+ catch (e) {
56
+ const error = e.message;
57
+ connection.send({ id, error }).catch(() => { });
58
+ }
59
+ };
60
+ });
61
+ await new Promise((resolve, reject) => {
62
+ server.on('error', reject);
63
+ server.listen(socketPath, () => resolve());
64
+ });
65
+ await saveSessionFile(clientInfo, sessionConfig);
66
+ console.log(`Daemon listening on ${socketPath}`);
67
+ return socketPath;
68
+ }
69
+ async function executeCommand(launcher, args) {
70
+ const command = args._[0];
71
+ const params = args._.slice(1);
72
+ switch (command) {
73
+ case 'goto': {
74
+ const url = params[0] || 'about:blank';
75
+ await launcher.open(url);
76
+ return { text: `Navigated to ${url}` };
77
+ }
78
+ case 'inspect': {
79
+ const selector = params[0];
80
+ if (!selector)
81
+ throw new Error('Selector is required for inspect command');
82
+ const snapshot = await launcher.collect({
83
+ rootSelector: selector,
84
+ downDepth: args.depth || 6,
85
+ maxNodes: 60,
86
+ upTo: 'html',
87
+ });
88
+ const findings = (0, analyzer_1.analyze)(snapshot);
89
+ if (args.json) {
90
+ return { text: JSON.stringify((0, renderer_1.renderJSON)(snapshot, findings, args.brief), null, 2) };
91
+ }
92
+ else {
93
+ return { text: (0, renderer_1.renderMarkdown)(snapshot, findings, args.brief, args.layout) };
94
+ }
95
+ }
96
+ case 'tree': {
97
+ const selector = params[0];
98
+ if (!selector)
99
+ throw new Error('Selector is required for tree command');
100
+ const snapshot = await launcher.collect({
101
+ rootSelector: selector,
102
+ downDepth: args.depth || 6,
103
+ maxNodes: 60,
104
+ upTo: 'html',
105
+ });
106
+ // Render tree only
107
+ const lines = [];
108
+ lines.push(`## DOM tree (${snapshot.downDepth} levels deep)`);
109
+ lines.push('```');
110
+ renderNode(snapshot.tree, lines, 0);
111
+ lines.push('```');
112
+ return { text: lines.join('\n') };
113
+ }
114
+ case 'layout': {
115
+ const selector = params[0];
116
+ if (!selector)
117
+ throw new Error('Selector is required for layout command');
118
+ const snapshot = await launcher.collect({
119
+ rootSelector: selector,
120
+ downDepth: 6,
121
+ maxNodes: 60,
122
+ upTo: 'html',
123
+ });
124
+ const findings = (0, analyzer_1.analyze)(snapshot);
125
+ return { text: (0, renderer_1.renderMarkdown)(snapshot, findings, false, true) };
126
+ }
127
+ case 'findings': {
128
+ const selector = params[0];
129
+ if (!selector)
130
+ throw new Error('Selector is required for findings command');
131
+ const snapshot = await launcher.collect({
132
+ rootSelector: selector,
133
+ downDepth: 6,
134
+ maxNodes: 60,
135
+ upTo: 'html',
136
+ });
137
+ const findings = (0, analyzer_1.analyze)(snapshot);
138
+ const important = findings.filter(f => f.level === 'warning' || f.level === 'error');
139
+ if (important.length === 0) {
140
+ return { text: 'No warnings or errors found.' };
141
+ }
142
+ const lines = important.map(f => {
143
+ const icon = f.level === 'error' ? '⚠' : '⚠';
144
+ return `- ${icon} ${f.message} [${f.confidence}]${f.location ? ` @ ${f.location}` : ''}`;
145
+ });
146
+ return { text: lines.join('\n') };
147
+ }
148
+ case 'inject-css': {
149
+ const css = params[0];
150
+ if (!css)
151
+ throw new Error('CSS is required for inject-css command');
152
+ const page = launcher.getPage();
153
+ if (!page)
154
+ throw new Error('Browser is not open. Run: cssprobe-cli open <url>');
155
+ await page.addStyleTag({ content: css });
156
+ return { text: JSON.stringify({ success: true }) };
157
+ }
158
+ case 'screenshot': {
159
+ const page = launcher.getPage();
160
+ if (!page)
161
+ throw new Error('Browser is not open. Run: cssprobe-cli open <url>');
162
+ const buffer = await page.screenshot({ fullPage: args.fullPage });
163
+ const base64 = buffer.toString('base64');
164
+ return { text: `data:image/png;base64,${base64}` };
165
+ }
166
+ case 'eval': {
167
+ const expression = params[0];
168
+ if (!expression)
169
+ throw new Error('Expression is required for eval command');
170
+ const page = launcher.getPage();
171
+ if (!page)
172
+ throw new Error('Browser is not open. Run: cssprobe-cli open <url>');
173
+ const result = await page.evaluate(expression);
174
+ return { text: JSON.stringify(result, null, 2) };
175
+ }
176
+ default:
177
+ throw new Error(`Unknown command: ${command}`);
178
+ }
179
+ }
180
+ function renderNode(node, lines, indent) {
181
+ if (!node)
182
+ return;
183
+ const cls = node.classes?.length ? `.${node.classes.join('.')}` : '';
184
+ const id = node.id ? `#${node.id}` : '';
185
+ const m = node.metrics;
186
+ const s = node.shape || {};
187
+ const shapeStr = s.role ? `[${s.role} h:${s.heightStrategy} w:${s.widthStrategy}]` : '';
188
+ const flag = [];
189
+ if (node.flags?.overflowsParent)
190
+ flag.push('⚠parent-overflow');
191
+ if (node.flags?.overflowsViewport)
192
+ flag.push('⚠viewport-overflow');
193
+ if (m?.clientHeight === 0 && m?.offsetHeight === 0)
194
+ flag.push('⚠collapsed');
195
+ lines.push(`${' '.repeat(indent)}<${node.tag}${id}${cls}> ${shapeStr} [${node.props?.position},${node.props?.display}] rect(${m?.rect?.width}×${m?.rect?.height})${flag.length ? ' ' + flag.join(' ') : ''}`);
196
+ for (const child of node.children || [])
197
+ renderNode(child, lines, indent + 1);
198
+ }
199
+ async function socketExists(socketPath) {
200
+ try {
201
+ const stat = await fs_1.default.promises.stat(socketPath);
202
+ return stat?.isSocket() || false;
203
+ }
204
+ catch {
205
+ return false;
206
+ }
207
+ }
208
+ function createSessionConfig(clientInfo, sessionName, options) {
209
+ return {
210
+ name: sessionName,
211
+ version: clientInfo.version,
212
+ timestamp: Date.now(),
213
+ socketPath: daemonSocketPath(clientInfo, sessionName),
214
+ browser: {
215
+ browserName: options.browser || 'chromium',
216
+ launchOptions: { headless: options.headed === false },
217
+ },
218
+ };
219
+ }
220
+ function daemonSocketPath(clientInfo, sessionName) {
221
+ return path_1.default.join(clientInfo.daemonProfilesDir, `${sessionName}.sock`);
222
+ }
223
+ async function saveSessionFile(clientInfo, sessionConfig) {
224
+ await fs_1.default.promises.mkdir(clientInfo.daemonProfilesDir, { recursive: true });
225
+ const sessionFile = path_1.default.join(clientInfo.daemonProfilesDir, `${sessionConfig.name}.session`);
226
+ await fs_1.default.promises.writeFile(sessionFile, JSON.stringify(sessionConfig, null, 2));
227
+ }
228
+ async function deleteSessionFile(sessionConfig) {
229
+ await fs_1.default.promises.unlink(sessionConfig.socketPath).catch(() => { });
230
+ const sessionFile = path_1.default.join(path_1.default.dirname(sessionConfig.socketPath), `${sessionConfig.name}.session`);
231
+ await fs_1.default.promises.rm(sessionFile).catch(() => { });
232
+ }
233
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Daemon entry point for cssprobe-cli.
4
+ * This file is spawned as a child process by the session.
5
+ */
6
+ export {};
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Daemon entry point for cssprobe-cli.
5
+ * This file is spawned as a child process by the session.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const daemon_1 = require("./daemon");
9
+ const session_1 = require("./session");
10
+ const args = process.argv.slice(2);
11
+ const sessionName = args[0] || 'default';
12
+ const options = {
13
+ headed: args.includes('--headed'),
14
+ browser: args.find(a => a.startsWith('--browser='))?.split('=')[1],
15
+ };
16
+ async function main() {
17
+ try {
18
+ const clientInfo = (0, session_1.createClientInfo)();
19
+ await (0, daemon_1.startDaemon)(sessionName, clientInfo, options);
20
+ }
21
+ catch (e) {
22
+ console.error('Failed to start daemon:', e.message);
23
+ process.exit(1);
24
+ }
25
+ }
26
+ main();
27
+ //# sourceMappingURL=daemonEntry.js.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Session management for cssprobe-cli.
3
+ * Simplified version of playwright-cli's session management.
4
+ * Only supports single 'default' session.
5
+ */
6
+ export interface SessionConfig {
7
+ name: string;
8
+ version: string;
9
+ timestamp: number;
10
+ socketPath: string;
11
+ browser: {
12
+ browserName: string;
13
+ launchOptions: Record<string, any>;
14
+ userDataDir?: string;
15
+ };
16
+ }
17
+ export interface SessionFile {
18
+ file: string;
19
+ daemonDir: string;
20
+ config: SessionConfig;
21
+ }
22
+ export declare class Session {
23
+ readonly name: string;
24
+ readonly config: SessionConfig;
25
+ private _sessionFile;
26
+ constructor(sessionFile: SessionFile);
27
+ run(args: Record<string, any> & {
28
+ _: string[];
29
+ }): Promise<{
30
+ text: string;
31
+ }>;
32
+ stop(): Promise<{
33
+ wasOpen: boolean;
34
+ }>;
35
+ canConnect(): Promise<boolean>;
36
+ private _connect;
37
+ private _stopDaemon;
38
+ static startDaemon(args: Record<string, any>, mode: 'open' | 'attach'): Promise<{
39
+ pid: number | undefined;
40
+ }>;
41
+ }
42
+ export interface ClientInfo {
43
+ version: string;
44
+ workspaceDirHash: string;
45
+ daemonProfilesDir: string;
46
+ workspaceDir: string | undefined;
47
+ homeDir: string;
48
+ }
49
+ export declare function createClientInfo(): ClientInfo;
50
+ export declare function loadSession(): Promise<Session | undefined>;
51
+ export declare function saveSession(config: SessionConfig): Promise<void>;
52
+ export declare function deleteSession(): Promise<void>;
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ /**
3
+ * Session management for cssprobe-cli.
4
+ * Simplified version of playwright-cli's session management.
5
+ * Only supports single 'default' session.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.Session = void 0;
12
+ exports.createClientInfo = createClientInfo;
13
+ exports.loadSession = loadSession;
14
+ exports.saveSession = saveSession;
15
+ exports.deleteSession = deleteSession;
16
+ const crypto_1 = __importDefault(require("crypto"));
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const net_1 = __importDefault(require("net"));
19
+ const os_1 = __importDefault(require("os"));
20
+ const path_1 = __importDefault(require("path"));
21
+ const socketConnection_1 = require("../utils/socketConnection");
22
+ class Session {
23
+ name;
24
+ config;
25
+ _sessionFile;
26
+ constructor(sessionFile) {
27
+ this.config = sessionFile.config;
28
+ this.name = this.config.name;
29
+ this._sessionFile = sessionFile;
30
+ }
31
+ async run(args) {
32
+ const { socket } = await this._connect();
33
+ if (!socket)
34
+ throw new Error('Browser is not open. Run:\n\n cssprobe-cli open <url>\n\nto start the browser session.');
35
+ return await SocketConnectionClient.sendAndClose(socket, 'run', { args, cwd: process.cwd() });
36
+ }
37
+ async stop() {
38
+ if (!await this.canConnect())
39
+ return { wasOpen: false };
40
+ await this._stopDaemon();
41
+ return { wasOpen: true };
42
+ }
43
+ async canConnect() {
44
+ const { socket } = await this._connect();
45
+ if (socket) {
46
+ socket.destroy();
47
+ return true;
48
+ }
49
+ return false;
50
+ }
51
+ async _connect() {
52
+ return await new Promise(resolve => {
53
+ const socket = net_1.default.createConnection(this.config.socketPath, () => {
54
+ resolve({ socket });
55
+ });
56
+ socket.on('error', error => {
57
+ if (os_1.default.platform() !== 'win32')
58
+ void fs_1.default.promises.unlink(this.config.socketPath).catch(() => { }).then(() => resolve({ error }));
59
+ else
60
+ resolve({ error });
61
+ });
62
+ });
63
+ }
64
+ async _stopDaemon() {
65
+ const { socket } = await this._connect();
66
+ if (!socket)
67
+ return;
68
+ let error;
69
+ await SocketConnectionClient.sendAndClose(socket, 'stop', {}).catch(e => error = e);
70
+ if (error && !error?.message?.includes('Session closed'))
71
+ throw error;
72
+ }
73
+ static async startDaemon(args, mode) {
74
+ const clientInfo = createClientInfo();
75
+ await fs_1.default.promises.mkdir(clientInfo.daemonProfilesDir, { recursive: true });
76
+ const sessionName = 'default';
77
+ const errLog = path_1.default.join(clientInfo.daemonProfilesDir, sessionName + '.err');
78
+ const err = fs_1.default.openSync(errLog, 'w');
79
+ const daemonArgs = [
80
+ path_1.default.join(__dirname, 'daemonEntry.js'),
81
+ sessionName,
82
+ ];
83
+ if (args.headed)
84
+ daemonArgs.push('--headed');
85
+ if (args.browser)
86
+ daemonArgs.push(`--browser=${args.browser}`);
87
+ const child = require('child_process').spawn(process.execPath, daemonArgs, {
88
+ detached: true,
89
+ stdio: ['ignore', 'pipe', err],
90
+ cwd: process.cwd(),
91
+ });
92
+ let outLog = '';
93
+ await new Promise((resolve, reject) => {
94
+ child.stdout.on('data', (data) => {
95
+ outLog += data.toString();
96
+ if (outLog.includes('Daemon listening on'))
97
+ resolve();
98
+ });
99
+ child.on('close', (code) => {
100
+ const errLogContent = fs_1.default.readFileSync(errLog, 'utf-8');
101
+ reject(new Error(`Daemon process exited with code ${code}` + (outLog ? '\n' + outLog : '') + (errLogContent ? '\n' + errLogContent : '')));
102
+ });
103
+ });
104
+ child.stdout.destroy();
105
+ child.unref();
106
+ return { pid: child.pid };
107
+ }
108
+ }
109
+ exports.Session = Session;
110
+ class SocketConnectionClient {
111
+ _connection;
112
+ _nextMessageId = 1;
113
+ _callbacks = new Map();
114
+ constructor(socket) {
115
+ this._connection = new socketConnection_1.SocketConnection(socket);
116
+ this._connection.onmessage = message => this._onMessage(message);
117
+ this._connection.onclose = () => this._rejectCallbacks();
118
+ }
119
+ async send(method, params = {}) {
120
+ const messageId = this._nextMessageId++;
121
+ const message = { id: messageId, method, params };
122
+ const responsePromise = new Promise((resolve, reject) => {
123
+ this._callbacks.set(messageId, { resolve, reject });
124
+ });
125
+ const [result] = await Promise.all([responsePromise, this._connection.send(message)]);
126
+ return result;
127
+ }
128
+ static async sendAndClose(socket, method, params = {}) {
129
+ const connection = new SocketConnectionClient(socket);
130
+ try {
131
+ return await connection.send(method, params);
132
+ }
133
+ finally {
134
+ connection.close();
135
+ }
136
+ }
137
+ close() {
138
+ this._connection.close();
139
+ }
140
+ _onMessage(object) {
141
+ if (object.id && this._callbacks.has(object.id)) {
142
+ const callback = this._callbacks.get(object.id);
143
+ this._callbacks.delete(object.id);
144
+ if (object.error)
145
+ callback.reject(new Error(object.error));
146
+ else
147
+ callback.resolve(object.result);
148
+ }
149
+ }
150
+ _rejectCallbacks() {
151
+ for (const callback of this._callbacks.values())
152
+ callback.reject(new Error('Session closed'));
153
+ this._callbacks.clear();
154
+ }
155
+ }
156
+ function createClientInfo() {
157
+ const workspaceDir = findWorkspaceDir(process.cwd());
158
+ const version = require('../../package.json').version;
159
+ const hash = crypto_1.default.createHash('sha1');
160
+ hash.update(workspaceDir || __dirname);
161
+ const workspaceDirHash = hash.digest('hex').substring(0, 16);
162
+ return {
163
+ version,
164
+ workspaceDir,
165
+ workspaceDirHash,
166
+ daemonProfilesDir: daemonProfilesDir(workspaceDirHash),
167
+ homeDir: os_1.default.homedir(),
168
+ };
169
+ }
170
+ function findWorkspaceDir(startDir) {
171
+ let dir = startDir;
172
+ for (let i = 0; i < 10; i++) {
173
+ if (fs_1.default.existsSync(path_1.default.join(dir, '.cssprobe-cli')))
174
+ return dir;
175
+ const parentDir = path_1.default.dirname(dir);
176
+ if (parentDir === dir)
177
+ break;
178
+ dir = parentDir;
179
+ }
180
+ return undefined;
181
+ }
182
+ const baseDaemonDir = (() => {
183
+ let localCacheDir;
184
+ if (process.platform === 'linux')
185
+ localCacheDir = process.env.XDG_CACHE_HOME || path_1.default.join(os_1.default.homedir(), '.cache');
186
+ if (process.platform === 'darwin')
187
+ localCacheDir = path_1.default.join(os_1.default.homedir(), 'Library', 'Caches');
188
+ if (process.platform === 'win32')
189
+ localCacheDir = process.env.LOCALAPPDATA || path_1.default.join(os_1.default.homedir(), 'AppData', 'Local');
190
+ if (!localCacheDir)
191
+ throw new Error('Unsupported platform: ' + process.platform);
192
+ return path_1.default.join(localCacheDir, 'cssprobe-cli', 'daemon');
193
+ })();
194
+ const daemonProfilesDir = (workspaceDirHash) => {
195
+ return path_1.default.join(baseDaemonDir, workspaceDirHash);
196
+ };
197
+ async function loadSession() {
198
+ const clientInfo = createClientInfo();
199
+ const sessionFile = path_1.default.join(clientInfo.daemonProfilesDir, 'default.session');
200
+ try {
201
+ const data = await fs_1.default.promises.readFile(sessionFile, 'utf-8');
202
+ const config = JSON.parse(data);
203
+ return new Session({ file: sessionFile, config, daemonDir: clientInfo.daemonProfilesDir });
204
+ }
205
+ catch {
206
+ return undefined;
207
+ }
208
+ }
209
+ async function saveSession(config) {
210
+ const clientInfo = createClientInfo();
211
+ await fs_1.default.promises.mkdir(clientInfo.daemonProfilesDir, { recursive: true });
212
+ const sessionFile = path_1.default.join(clientInfo.daemonProfilesDir, 'default.session');
213
+ await fs_1.default.promises.writeFile(sessionFile, JSON.stringify(config, null, 2));
214
+ }
215
+ async function deleteSession() {
216
+ const clientInfo = createClientInfo();
217
+ const sessionFile = path_1.default.join(clientInfo.daemonProfilesDir, 'default.session');
218
+ await fs_1.default.promises.unlink(sessionFile).catch(() => { });
219
+ }
220
+ //# sourceMappingURL=session.js.map