aisnitch 0.2.21 → 0.2.22

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.
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
9
12
  var __export = (target, all) => {
10
13
  for (var name in all)
11
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -28,6 +31,733 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
31
  ));
29
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
33
 
34
+ // node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
35
+ function hasDockerEnv() {
36
+ try {
37
+ import_node_fs4.default.statSync("/.dockerenv");
38
+ return true;
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ function hasDockerCGroup() {
44
+ try {
45
+ return import_node_fs4.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
46
+ } catch {
47
+ return false;
48
+ }
49
+ }
50
+ function isDocker() {
51
+ if (isDockerCached === void 0) {
52
+ isDockerCached = hasDockerEnv() || hasDockerCGroup();
53
+ }
54
+ return isDockerCached;
55
+ }
56
+ var import_node_fs4, isDockerCached;
57
+ var init_is_docker = __esm({
58
+ "node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js"() {
59
+ "use strict";
60
+ import_node_fs4 = __toESM(require("fs"), 1);
61
+ }
62
+ });
63
+
64
+ // node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
65
+ function isInsideContainer() {
66
+ if (cachedResult === void 0) {
67
+ cachedResult = hasContainerEnv() || isDocker();
68
+ }
69
+ return cachedResult;
70
+ }
71
+ var import_node_fs5, cachedResult, hasContainerEnv;
72
+ var init_is_inside_container = __esm({
73
+ "node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js"() {
74
+ "use strict";
75
+ import_node_fs5 = __toESM(require("fs"), 1);
76
+ init_is_docker();
77
+ hasContainerEnv = () => {
78
+ try {
79
+ import_node_fs5.default.statSync("/run/.containerenv");
80
+ return true;
81
+ } catch {
82
+ return false;
83
+ }
84
+ };
85
+ }
86
+ });
87
+
88
+ // node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
89
+ var import_node_process, import_node_os5, import_node_fs6, isWsl, is_wsl_default;
90
+ var init_is_wsl = __esm({
91
+ "node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js"() {
92
+ "use strict";
93
+ import_node_process = __toESM(require("process"), 1);
94
+ import_node_os5 = __toESM(require("os"), 1);
95
+ import_node_fs6 = __toESM(require("fs"), 1);
96
+ init_is_inside_container();
97
+ isWsl = () => {
98
+ if (import_node_process.default.platform !== "linux") {
99
+ return false;
100
+ }
101
+ if (import_node_os5.default.release().toLowerCase().includes("microsoft")) {
102
+ if (isInsideContainer()) {
103
+ return false;
104
+ }
105
+ return true;
106
+ }
107
+ try {
108
+ if (import_node_fs6.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
109
+ return !isInsideContainer();
110
+ }
111
+ } catch {
112
+ }
113
+ if (import_node_fs6.default.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || import_node_fs6.default.existsSync("/run/WSL")) {
114
+ return !isInsideContainer();
115
+ }
116
+ return false;
117
+ };
118
+ is_wsl_default = import_node_process.default.env.__IS_WSL_TEST__ ? isWsl : isWsl();
119
+ }
120
+ });
121
+
122
+ // node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
123
+ var import_node_process2, import_node_buffer, import_node_util15, import_node_child_process16, import_promises19, execFile15, powerShellPath, executePowerShell;
124
+ var init_powershell_utils = __esm({
125
+ "node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js"() {
126
+ "use strict";
127
+ import_node_process2 = __toESM(require("process"), 1);
128
+ import_node_buffer = require("buffer");
129
+ import_node_util15 = require("util");
130
+ import_node_child_process16 = __toESM(require("child_process"), 1);
131
+ import_promises19 = __toESM(require("fs/promises"), 1);
132
+ execFile15 = (0, import_node_util15.promisify)(import_node_child_process16.default.execFile);
133
+ powerShellPath = () => `${import_node_process2.default.env.SYSTEMROOT || import_node_process2.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
134
+ executePowerShell = async (command, options = {}) => {
135
+ const {
136
+ powerShellPath: psPath,
137
+ ...execFileOptions
138
+ } = options;
139
+ const encodedCommand = executePowerShell.encodeCommand(command);
140
+ return execFile15(
141
+ psPath ?? powerShellPath(),
142
+ [
143
+ ...executePowerShell.argumentsPrefix,
144
+ encodedCommand
145
+ ],
146
+ {
147
+ encoding: "utf8",
148
+ ...execFileOptions
149
+ }
150
+ );
151
+ };
152
+ executePowerShell.argumentsPrefix = [
153
+ "-NoProfile",
154
+ "-NonInteractive",
155
+ "-ExecutionPolicy",
156
+ "Bypass",
157
+ "-EncodedCommand"
158
+ ];
159
+ executePowerShell.encodeCommand = (command) => import_node_buffer.Buffer.from(command, "utf16le").toString("base64");
160
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
161
+ }
162
+ });
163
+
164
+ // node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
165
+ function parseMountPointFromConfig(content) {
166
+ for (const line of content.split("\n")) {
167
+ if (/^\s*#/.test(line)) {
168
+ continue;
169
+ }
170
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
171
+ if (!match) {
172
+ continue;
173
+ }
174
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
175
+ }
176
+ }
177
+ var init_utilities = __esm({
178
+ "node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js"() {
179
+ "use strict";
180
+ }
181
+ });
182
+
183
+ // node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
184
+ var import_node_util16, import_node_child_process17, import_promises20, execFile16, wslDrivesMountPoint, powerShellPathFromWsl, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell, wslDefaultBrowser, convertWslPathToWindows;
185
+ var init_wsl_utils = __esm({
186
+ "node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js"() {
187
+ "use strict";
188
+ import_node_util16 = require("util");
189
+ import_node_child_process17 = __toESM(require("child_process"), 1);
190
+ import_promises20 = __toESM(require("fs/promises"), 1);
191
+ init_is_wsl();
192
+ init_powershell_utils();
193
+ init_utilities();
194
+ init_is_wsl();
195
+ execFile16 = (0, import_node_util16.promisify)(import_node_child_process17.default.execFile);
196
+ wslDrivesMountPoint = /* @__PURE__ */ (() => {
197
+ const defaultMountPoint = "/mnt/";
198
+ let mountPoint;
199
+ return async function() {
200
+ if (mountPoint) {
201
+ return mountPoint;
202
+ }
203
+ const configFilePath = "/etc/wsl.conf";
204
+ let isConfigFileExists = false;
205
+ try {
206
+ await import_promises20.default.access(configFilePath, import_promises20.constants.F_OK);
207
+ isConfigFileExists = true;
208
+ } catch {
209
+ }
210
+ if (!isConfigFileExists) {
211
+ return defaultMountPoint;
212
+ }
213
+ const configContent = await import_promises20.default.readFile(configFilePath, { encoding: "utf8" });
214
+ const parsedMountPoint = parseMountPointFromConfig(configContent);
215
+ if (parsedMountPoint === void 0) {
216
+ return defaultMountPoint;
217
+ }
218
+ mountPoint = parsedMountPoint;
219
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
220
+ return mountPoint;
221
+ };
222
+ })();
223
+ powerShellPathFromWsl = async () => {
224
+ const mountPoint = await wslDrivesMountPoint();
225
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
226
+ };
227
+ powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
228
+ canAccessPowerShell = async () => {
229
+ canAccessPowerShellPromise ??= (async () => {
230
+ try {
231
+ const psPath = await powerShellPath2();
232
+ await import_promises20.default.access(psPath, import_promises20.constants.X_OK);
233
+ return true;
234
+ } catch {
235
+ return false;
236
+ }
237
+ })();
238
+ return canAccessPowerShellPromise;
239
+ };
240
+ wslDefaultBrowser = async () => {
241
+ const psPath = await powerShellPath2();
242
+ const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
243
+ const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
244
+ return stdout.trim();
245
+ };
246
+ convertWslPathToWindows = async (path2) => {
247
+ if (/^[a-z]+:\/\//i.test(path2)) {
248
+ return path2;
249
+ }
250
+ try {
251
+ const { stdout } = await execFile16("wslpath", ["-aw", path2], { encoding: "utf8" });
252
+ return stdout.trim();
253
+ } catch {
254
+ return path2;
255
+ }
256
+ };
257
+ }
258
+ });
259
+
260
+ // node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
261
+ function defineLazyProperty(object, propertyName, valueGetter) {
262
+ const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
263
+ Object.defineProperty(object, propertyName, {
264
+ configurable: true,
265
+ enumerable: true,
266
+ get() {
267
+ const result = valueGetter();
268
+ define(result);
269
+ return result;
270
+ },
271
+ set(value) {
272
+ define(value);
273
+ }
274
+ });
275
+ return object;
276
+ }
277
+ var init_define_lazy_prop = __esm({
278
+ "node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js"() {
279
+ "use strict";
280
+ }
281
+ });
282
+
283
+ // node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
284
+ async function defaultBrowserId() {
285
+ if (import_node_process3.default.platform !== "darwin") {
286
+ throw new Error("macOS only");
287
+ }
288
+ const { stdout } = await execFileAsync2("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
289
+ const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
290
+ const browserId = match?.groups.id ?? "com.apple.Safari";
291
+ if (browserId === "com.apple.safari") {
292
+ return "com.apple.Safari";
293
+ }
294
+ return browserId;
295
+ }
296
+ var import_node_util17, import_node_process3, import_node_child_process18, execFileAsync2;
297
+ var init_default_browser_id = __esm({
298
+ "node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js"() {
299
+ "use strict";
300
+ import_node_util17 = require("util");
301
+ import_node_process3 = __toESM(require("process"), 1);
302
+ import_node_child_process18 = require("child_process");
303
+ execFileAsync2 = (0, import_node_util17.promisify)(import_node_child_process18.execFile);
304
+ }
305
+ });
306
+
307
+ // node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
308
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
309
+ if (import_node_process4.default.platform !== "darwin") {
310
+ throw new Error("macOS only");
311
+ }
312
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
313
+ const execOptions = {};
314
+ if (signal) {
315
+ execOptions.signal = signal;
316
+ }
317
+ const { stdout } = await execFileAsync3("osascript", ["-e", script, outputArguments], execOptions);
318
+ return stdout.trim();
319
+ }
320
+ var import_node_process4, import_node_util18, import_node_child_process19, execFileAsync3;
321
+ var init_run_applescript = __esm({
322
+ "node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js"() {
323
+ "use strict";
324
+ import_node_process4 = __toESM(require("process"), 1);
325
+ import_node_util18 = require("util");
326
+ import_node_child_process19 = require("child_process");
327
+ execFileAsync3 = (0, import_node_util18.promisify)(import_node_child_process19.execFile);
328
+ }
329
+ });
330
+
331
+ // node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
332
+ async function bundleName(bundleId) {
333
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
334
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
335
+ }
336
+ var init_bundle_name = __esm({
337
+ "node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js"() {
338
+ "use strict";
339
+ init_run_applescript();
340
+ }
341
+ });
342
+
343
+ // node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
344
+ async function defaultBrowser(_execFileAsync = execFileAsync4) {
345
+ const { stdout } = await _execFileAsync("reg", [
346
+ "QUERY",
347
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
348
+ "/v",
349
+ "ProgId"
350
+ ]);
351
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
352
+ if (!match) {
353
+ throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
354
+ }
355
+ const { id } = match.groups;
356
+ const dotIndex = id.lastIndexOf(".");
357
+ const hyphenIndex = id.lastIndexOf("-");
358
+ const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
359
+ const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
360
+ return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
361
+ }
362
+ var import_node_util19, import_node_child_process20, execFileAsync4, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
363
+ var init_windows = __esm({
364
+ "node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js"() {
365
+ "use strict";
366
+ import_node_util19 = require("util");
367
+ import_node_child_process20 = require("child_process");
368
+ execFileAsync4 = (0, import_node_util19.promisify)(import_node_child_process20.execFile);
369
+ windowsBrowserProgIds = {
370
+ MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
371
+ // The missing `L` is correct.
372
+ MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
373
+ MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
374
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
375
+ ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
376
+ ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
377
+ ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
378
+ ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
379
+ BraveHTML: { name: "Brave", id: "com.brave.Browser" },
380
+ BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
381
+ BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
382
+ BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
383
+ FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
384
+ OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
385
+ VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
386
+ "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
387
+ };
388
+ _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
389
+ UnknownBrowserError = class extends Error {
390
+ };
391
+ }
392
+ });
393
+
394
+ // node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
395
+ async function defaultBrowser2() {
396
+ if (import_node_process5.default.platform === "darwin") {
397
+ const id = await defaultBrowserId();
398
+ const name = await bundleName(id);
399
+ return { name, id };
400
+ }
401
+ if (import_node_process5.default.platform === "linux") {
402
+ const { stdout } = await execFileAsync5("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
403
+ const id = stdout.trim();
404
+ const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
405
+ return { name, id };
406
+ }
407
+ if (import_node_process5.default.platform === "win32") {
408
+ return defaultBrowser();
409
+ }
410
+ throw new Error("Only macOS, Linux, and Windows are supported");
411
+ }
412
+ var import_node_util20, import_node_process5, import_node_child_process21, execFileAsync5, titleize;
413
+ var init_default_browser = __esm({
414
+ "node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js"() {
415
+ "use strict";
416
+ import_node_util20 = require("util");
417
+ import_node_process5 = __toESM(require("process"), 1);
418
+ import_node_child_process21 = require("child_process");
419
+ init_default_browser_id();
420
+ init_bundle_name();
421
+ init_windows();
422
+ init_windows();
423
+ execFileAsync5 = (0, import_node_util20.promisify)(import_node_child_process21.execFile);
424
+ titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
425
+ }
426
+ });
427
+
428
+ // node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
429
+ var import_node_process6, isInSsh, is_in_ssh_default;
430
+ var init_is_in_ssh = __esm({
431
+ "node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js"() {
432
+ "use strict";
433
+ import_node_process6 = __toESM(require("process"), 1);
434
+ isInSsh = Boolean(import_node_process6.default.env.SSH_CONNECTION || import_node_process6.default.env.SSH_CLIENT || import_node_process6.default.env.SSH_TTY);
435
+ is_in_ssh_default = isInSsh;
436
+ }
437
+ });
438
+
439
+ // node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
440
+ var open_exports = {};
441
+ __export(open_exports, {
442
+ apps: () => apps,
443
+ default: () => open_default,
444
+ openApp: () => openApp
445
+ });
446
+ function detectArchBinary(binary) {
447
+ if (typeof binary === "string" || Array.isArray(binary)) {
448
+ return binary;
449
+ }
450
+ const { [arch]: archBinary } = binary;
451
+ if (!archBinary) {
452
+ throw new Error(`${arch} is not supported`);
453
+ }
454
+ return archBinary;
455
+ }
456
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
457
+ if (wsl && is_wsl_default) {
458
+ return detectArchBinary(wsl);
459
+ }
460
+ if (!platformBinary) {
461
+ throw new Error(`${platform} is not supported`);
462
+ }
463
+ return detectArchBinary(platformBinary);
464
+ }
465
+ var import_node_process7, import_node_path21, import_node_url, import_node_child_process22, import_promises21, import_meta, fallbackAttemptSymbol, __dirname, localXdgOpenPath, platform, arch, tryEachApp, baseOpen, open, openApp, apps, open_default;
466
+ var init_open = __esm({
467
+ "node_modules/.pnpm/open@11.0.0/node_modules/open/index.js"() {
468
+ "use strict";
469
+ import_node_process7 = __toESM(require("process"), 1);
470
+ import_node_path21 = __toESM(require("path"), 1);
471
+ import_node_url = require("url");
472
+ import_node_child_process22 = __toESM(require("child_process"), 1);
473
+ import_promises21 = __toESM(require("fs/promises"), 1);
474
+ init_wsl_utils();
475
+ init_powershell_utils();
476
+ init_define_lazy_prop();
477
+ init_default_browser();
478
+ init_is_inside_container();
479
+ init_is_in_ssh();
480
+ import_meta = {};
481
+ fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
482
+ __dirname = import_meta.url ? import_node_path21.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)) : "";
483
+ localXdgOpenPath = import_node_path21.default.join(__dirname, "xdg-open");
484
+ ({ platform, arch } = import_node_process7.default);
485
+ tryEachApp = async (apps2, opener) => {
486
+ if (apps2.length === 0) {
487
+ return;
488
+ }
489
+ const errors = [];
490
+ for (const app of apps2) {
491
+ try {
492
+ return await opener(app);
493
+ } catch (error) {
494
+ errors.push(error);
495
+ }
496
+ }
497
+ throw new AggregateError(errors, "Failed to open in all supported apps");
498
+ };
499
+ baseOpen = async (options) => {
500
+ options = {
501
+ wait: false,
502
+ background: false,
503
+ newInstance: false,
504
+ allowNonzeroExitCode: false,
505
+ ...options
506
+ };
507
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
508
+ delete options[fallbackAttemptSymbol];
509
+ if (Array.isArray(options.app)) {
510
+ return tryEachApp(options.app, (singleApp) => baseOpen({
511
+ ...options,
512
+ app: singleApp,
513
+ [fallbackAttemptSymbol]: true
514
+ }));
515
+ }
516
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
517
+ appArguments = [...appArguments];
518
+ if (Array.isArray(app)) {
519
+ return tryEachApp(app, (appName) => baseOpen({
520
+ ...options,
521
+ app: {
522
+ name: appName,
523
+ arguments: appArguments
524
+ },
525
+ [fallbackAttemptSymbol]: true
526
+ }));
527
+ }
528
+ if (app === "browser" || app === "browserPrivate") {
529
+ const ids = {
530
+ "com.google.chrome": "chrome",
531
+ "google-chrome.desktop": "chrome",
532
+ "com.brave.browser": "brave",
533
+ "org.mozilla.firefox": "firefox",
534
+ "firefox.desktop": "firefox",
535
+ "com.microsoft.msedge": "edge",
536
+ "com.microsoft.edge": "edge",
537
+ "com.microsoft.edgemac": "edge",
538
+ "microsoft-edge.desktop": "edge",
539
+ "com.apple.safari": "safari"
540
+ };
541
+ const flags = {
542
+ chrome: "--incognito",
543
+ brave: "--incognito",
544
+ firefox: "--private-window",
545
+ edge: "--inPrivate"
546
+ // Safari doesn't support private mode via command line
547
+ };
548
+ let browser;
549
+ if (is_wsl_default) {
550
+ const progId = await wslDefaultBrowser();
551
+ const browserInfo = _windowsBrowserProgIdMap.get(progId);
552
+ browser = browserInfo ?? {};
553
+ } else {
554
+ browser = await defaultBrowser2();
555
+ }
556
+ if (browser.id in ids) {
557
+ const browserName = ids[browser.id.toLowerCase()];
558
+ if (app === "browserPrivate") {
559
+ if (browserName === "safari") {
560
+ throw new Error("Safari doesn't support opening in private mode via command line");
561
+ }
562
+ appArguments.push(flags[browserName]);
563
+ }
564
+ return baseOpen({
565
+ ...options,
566
+ app: {
567
+ name: apps[browserName],
568
+ arguments: appArguments
569
+ }
570
+ });
571
+ }
572
+ throw new Error(`${browser.name} is not supported as a default browser`);
573
+ }
574
+ let command;
575
+ const cliArguments = [];
576
+ const childProcessOptions = {};
577
+ let shouldUseWindowsInWsl = false;
578
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
579
+ shouldUseWindowsInWsl = await canAccessPowerShell();
580
+ }
581
+ if (platform === "darwin") {
582
+ command = "open";
583
+ if (options.wait) {
584
+ cliArguments.push("--wait-apps");
585
+ }
586
+ if (options.background) {
587
+ cliArguments.push("--background");
588
+ }
589
+ if (options.newInstance) {
590
+ cliArguments.push("--new");
591
+ }
592
+ if (app) {
593
+ cliArguments.push("-a", app);
594
+ }
595
+ } else if (platform === "win32" || shouldUseWindowsInWsl) {
596
+ command = await powerShellPath2();
597
+ cliArguments.push(...executePowerShell.argumentsPrefix);
598
+ if (!is_wsl_default) {
599
+ childProcessOptions.windowsVerbatimArguments = true;
600
+ }
601
+ if (is_wsl_default && options.target) {
602
+ options.target = await convertWslPathToWindows(options.target);
603
+ }
604
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
605
+ if (options.wait) {
606
+ encodedArguments.push("-Wait");
607
+ }
608
+ if (app) {
609
+ encodedArguments.push(executePowerShell.escapeArgument(app));
610
+ if (options.target) {
611
+ appArguments.push(options.target);
612
+ }
613
+ } else if (options.target) {
614
+ encodedArguments.push(executePowerShell.escapeArgument(options.target));
615
+ }
616
+ if (appArguments.length > 0) {
617
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
618
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
619
+ }
620
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
621
+ if (!options.wait) {
622
+ childProcessOptions.stdio = "ignore";
623
+ }
624
+ } else {
625
+ if (app) {
626
+ command = app;
627
+ } else {
628
+ const isBundled = !__dirname || __dirname === "/";
629
+ let exeLocalXdgOpen = false;
630
+ try {
631
+ await import_promises21.default.access(localXdgOpenPath, import_promises21.constants.X_OK);
632
+ exeLocalXdgOpen = true;
633
+ } catch {
634
+ }
635
+ const useSystemXdgOpen = import_node_process7.default.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
636
+ command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
637
+ }
638
+ if (appArguments.length > 0) {
639
+ cliArguments.push(...appArguments);
640
+ }
641
+ if (!options.wait) {
642
+ childProcessOptions.stdio = "ignore";
643
+ childProcessOptions.detached = true;
644
+ }
645
+ }
646
+ if (platform === "darwin" && appArguments.length > 0) {
647
+ cliArguments.push("--args", ...appArguments);
648
+ }
649
+ if (options.target) {
650
+ cliArguments.push(options.target);
651
+ }
652
+ const subprocess = import_node_child_process22.default.spawn(command, cliArguments, childProcessOptions);
653
+ if (options.wait) {
654
+ return new Promise((resolve2, reject) => {
655
+ subprocess.once("error", reject);
656
+ subprocess.once("close", (exitCode) => {
657
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
658
+ reject(new Error(`Exited with code ${exitCode}`));
659
+ return;
660
+ }
661
+ resolve2(subprocess);
662
+ });
663
+ });
664
+ }
665
+ if (isFallbackAttempt) {
666
+ return new Promise((resolve2, reject) => {
667
+ subprocess.once("error", reject);
668
+ subprocess.once("spawn", () => {
669
+ subprocess.once("close", (exitCode) => {
670
+ subprocess.off("error", reject);
671
+ if (exitCode !== 0) {
672
+ reject(new Error(`Exited with code ${exitCode}`));
673
+ return;
674
+ }
675
+ subprocess.unref();
676
+ resolve2(subprocess);
677
+ });
678
+ });
679
+ });
680
+ }
681
+ subprocess.unref();
682
+ return new Promise((resolve2, reject) => {
683
+ subprocess.once("error", reject);
684
+ subprocess.once("spawn", () => {
685
+ subprocess.off("error", reject);
686
+ resolve2(subprocess);
687
+ });
688
+ });
689
+ };
690
+ open = (target, options) => {
691
+ if (typeof target !== "string") {
692
+ throw new TypeError("Expected a `target`");
693
+ }
694
+ return baseOpen({
695
+ ...options,
696
+ target
697
+ });
698
+ };
699
+ openApp = (name, options) => {
700
+ if (typeof name !== "string" && !Array.isArray(name)) {
701
+ throw new TypeError("Expected a valid `name`");
702
+ }
703
+ const { arguments: appArguments = [] } = options ?? {};
704
+ if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {
705
+ throw new TypeError("Expected `appArguments` as Array type");
706
+ }
707
+ return baseOpen({
708
+ ...options,
709
+ app: {
710
+ name,
711
+ arguments: appArguments
712
+ }
713
+ });
714
+ };
715
+ apps = {
716
+ browser: "browser",
717
+ browserPrivate: "browserPrivate"
718
+ };
719
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
720
+ darwin: "google chrome",
721
+ win32: "chrome",
722
+ // `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
723
+ linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
724
+ }, {
725
+ wsl: {
726
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
727
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
728
+ }
729
+ }));
730
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
731
+ darwin: "brave browser",
732
+ win32: "brave",
733
+ linux: ["brave-browser", "brave"]
734
+ }, {
735
+ wsl: {
736
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
737
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
738
+ }
739
+ }));
740
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
741
+ darwin: "firefox",
742
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
743
+ linux: "firefox"
744
+ }, {
745
+ wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
746
+ }));
747
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
748
+ darwin: "microsoft edge",
749
+ win32: "msedge",
750
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
751
+ }, {
752
+ wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
753
+ }));
754
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({
755
+ darwin: "Safari"
756
+ }));
757
+ open_default = open;
758
+ }
759
+ });
760
+
31
761
  // src/cli/index.ts
32
762
  var cli_exports = {};
33
763
  __export(cli_exports, {
@@ -41,7 +771,7 @@ var import_commander = require("commander");
41
771
 
42
772
  // src/package-info.ts
43
773
  var AISNITCH_PACKAGE_NAME = "aisnitch";
44
- var AISNITCH_VERSION = "0.2.21";
774
+ var AISNITCH_VERSION = "0.2.22";
45
775
  var AISNITCH_DESCRIPTION = "Universal bridge for AI coding tool activity \u2014 capture, normalize, stream.";
46
776
 
47
777
  // src/core/events/schema.ts
@@ -150,6 +880,9 @@ var EventDataSchema = import_zod.z.strictObject({
150
880
  activeFile: import_zod.z.string().min(1).max(4096).optional(),
151
881
  model: import_zod.z.string().min(1).max(200).optional(),
152
882
  tokensUsed: import_zod.z.number().int().min(0).optional(),
883
+ inputTokens: import_zod.z.number().int().min(0).optional(),
884
+ outputTokens: import_zod.z.number().int().min(0).optional(),
885
+ cachedTokens: import_zod.z.number().int().min(0).optional(),
153
886
  errorMessage: import_zod.z.string().min(1).max(1e4).optional(),
154
887
  errorType: ErrorTypeSchema.optional(),
155
888
  raw: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
@@ -969,8 +1702,8 @@ var ClaudeCodeSetup = class extends FileToolSetupBase {
969
1702
  return `${JSON.stringify(nextSettings, null, 2)}
970
1703
  `;
971
1704
  }
972
- getFileBackupPath(path) {
973
- return `${path}.bak`;
1705
+ getFileBackupPath(path2) {
1706
+ return `${path2}.bak`;
974
1707
  }
975
1708
  };
976
1709
  var OpenCodeSetup = class extends FileToolSetupBase {
@@ -1210,8 +1943,8 @@ var CopilotCLISetup = class {
1210
1943
  return `${JSON.stringify(nextConfig, null, 2)}
1211
1944
  `;
1212
1945
  }
1213
- getBackupPath(path) {
1214
- return `${path}.bak`;
1946
+ getBackupPath(path2) {
1947
+ return `${path2}.bak`;
1215
1948
  }
1216
1949
  };
1217
1950
  var OpenClawSetup = class {
@@ -1336,8 +2069,8 @@ var OpenClawSetup = class {
1336
2069
  return `${JSON.stringify(nextConfig, null, 2)}
1337
2070
  `;
1338
2071
  }
1339
- getBackupPath(path) {
1340
- return `${path}.bak`;
2072
+ getBackupPath(path2) {
2073
+ return `${path2}.bak`;
1341
2074
  }
1342
2075
  };
1343
2076
  async function createToolSetup(toolName, options = {}, dependencies = {}) {
@@ -2380,17 +3113,17 @@ async function isBinaryAvailable(binaryName) {
2380
3113
  return false;
2381
3114
  }
2382
3115
  }
2383
- async function fileExists(path) {
3116
+ async function fileExists(path2) {
2384
3117
  try {
2385
- await (0, import_promises2.access)(path, import_node_fs.constants.F_OK);
3118
+ await (0, import_promises2.access)(path2, import_node_fs.constants.F_OK);
2386
3119
  return true;
2387
3120
  } catch {
2388
3121
  return false;
2389
3122
  }
2390
3123
  }
2391
- async function readOptionalFile(path) {
3124
+ async function readOptionalFile(path2) {
2392
3125
  try {
2393
- return await (0, import_promises2.readFile)(path, "utf8");
3126
+ return await (0, import_promises2.readFile)(path2, "utf8");
2394
3127
  } catch (error) {
2395
3128
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
2396
3129
  return null;
@@ -2401,14 +3134,14 @@ async function readOptionalFile(path) {
2401
3134
  function shellEscapeSingle(value) {
2402
3135
  return `'${value.replaceAll("'", `'"'"'`)}'`;
2403
3136
  }
2404
- async function restoreBackupOrRemove(path) {
2405
- const backupPath = `${path}.bak`;
3137
+ async function restoreBackupOrRemove(path2) {
3138
+ const backupPath = `${path2}.bak`;
2406
3139
  if (await fileExists(backupPath)) {
2407
- await (0, import_promises2.copyFile)(backupPath, path);
3140
+ await (0, import_promises2.copyFile)(backupPath, path2);
2408
3141
  await (0, import_promises2.rm)(backupPath, { force: true });
2409
3142
  return;
2410
3143
  }
2411
- await (0, import_promises2.rm)(path, { force: true });
3144
+ await (0, import_promises2.rm)(path2, { force: true });
2412
3145
  }
2413
3146
  function buildAiderNotificationCommand(options) {
2414
3147
  const cliArgs = [process.execPath, resolveCurrentCliEntryPath(), "aider-notify"];
@@ -2476,13 +3209,13 @@ function toConfigPathOptions(options) {
2476
3209
  }
2477
3210
 
2478
3211
  // src/cli/runtime.ts
2479
- var import_node_child_process16 = require("child_process");
2480
- var import_node_fs4 = require("fs");
2481
- var import_promises19 = require("fs/promises");
3212
+ var import_node_child_process23 = require("child_process");
3213
+ var import_node_fs7 = require("fs");
3214
+ var import_promises22 = require("fs/promises");
2482
3215
  var import_node_net4 = require("net");
2483
- var import_node_os5 = require("os");
2484
- var import_node_path21 = require("path");
2485
- var import_node_util15 = require("util");
3216
+ var import_node_os6 = require("os");
3217
+ var import_node_path22 = require("path");
3218
+ var import_node_util21 = require("util");
2486
3219
 
2487
3220
  // src/adapters/generic-pty.ts
2488
3221
  var import_node_path5 = require("path");
@@ -5780,7 +6513,7 @@ function extractClaudeTranscriptObservations(payload, transcriptPath) {
5780
6513
  });
5781
6514
  const contentParts = extractClaudeContentParts(payload);
5782
6515
  const model = getString(payload, "model") ?? getString(getRecord(payload.message), "model");
5783
- const tokensUsed = extractTokenUsage(payload);
6516
+ const tokens = extractTokenUsageDetailed(payload);
5784
6517
  const rawPayload = payload;
5785
6518
  const sharedContext = {
5786
6519
  // 📖 Pass process.env so terminal detection works from transcript path too
@@ -5793,7 +6526,10 @@ function extractClaudeTranscriptObservations(payload, transcriptPath) {
5793
6526
  const sharedData = {
5794
6527
  model,
5795
6528
  raw: rawPayload,
5796
- tokensUsed
6529
+ tokensUsed: tokens.total,
6530
+ inputTokens: tokens.input,
6531
+ outputTokens: tokens.output,
6532
+ cachedTokens: tokens.cached
5797
6533
  };
5798
6534
  const observations = [];
5799
6535
  if (contentParts.some((part) => part.type === "thinking")) {
@@ -5851,23 +6587,28 @@ function extractClaudeContentParts(payload) {
5851
6587
  }
5852
6588
  return content.filter(isRecord2);
5853
6589
  }
5854
- function extractTokenUsage(payload) {
6590
+ function extractTokenUsageDetailed(payload) {
5855
6591
  const tokens = getNumber(payload, "tokens");
5856
6592
  if (tokens !== void 0) {
5857
- return tokens;
6593
+ return { total: tokens };
5858
6594
  }
5859
6595
  const usage = getRecord(payload.usage);
5860
6596
  if (!usage) {
5861
- return void 0;
6597
+ return {};
5862
6598
  }
5863
6599
  const totalTokens = getNumber(usage, "total_tokens");
5864
6600
  if (totalTokens !== void 0) {
5865
- return totalTokens;
6601
+ return {
6602
+ total: totalTokens,
6603
+ input: getNumber(usage, "input_tokens"),
6604
+ output: getNumber(usage, "output_tokens"),
6605
+ cached: getNumber(usage, "cached_tokens")
6606
+ };
5866
6607
  }
5867
6608
  const inputTokens = getNumber(usage, "input_tokens") ?? 0;
5868
6609
  const outputTokens = getNumber(usage, "output_tokens") ?? 0;
5869
6610
  const usageSum = inputTokens + outputTokens;
5870
- return usageSum > 0 ? usageSum : void 0;
6611
+ return usageSum > 0 ? { total: usageSum, input: inputTokens, output: outputTokens } : {};
5871
6612
  }
5872
6613
  function extractClaudeToolInput(payload) {
5873
6614
  const toolInput = getRecord(payload.tool_input) ?? getRecord(payload.toolInput);
@@ -10971,7 +11712,17 @@ var OpenCodeAdapter = class extends BaseAdapter {
10971
11712
  project: extractOpenCodeProject(payload),
10972
11713
  raw: payload,
10973
11714
  toolInput: extractOpenCodeToolInput(payload),
10974
- toolName: extractOpenCodeToolName(payload)
11715
+ toolName: extractOpenCodeToolName(payload),
11716
+ // 📖 Extract token usage from payload (with input/output/cached breakdown)
11717
+ ...(() => {
11718
+ const tokens = extractOpenCodeTokens(payload);
11719
+ return {
11720
+ tokensUsed: tokens.total,
11721
+ inputTokens: tokens.inputTokens,
11722
+ outputTokens: tokens.outputTokens,
11723
+ cachedTokens: tokens.cachedTokens
11724
+ };
11725
+ })()
10975
11726
  };
10976
11727
  switch (eventType) {
10977
11728
  case "session.created": {
@@ -11000,9 +11751,21 @@ var OpenCodeAdapter = class extends BaseAdapter {
11000
11751
  await this.emitStateChange("agent.compact", sharedData, context);
11001
11752
  return;
11002
11753
  }
11754
+ case "thinking": {
11755
+ const thinkingContent = extractOpenCodeThinkingContent(payload);
11756
+ await this.emitStateChange("agent.thinking", {
11757
+ ...sharedData,
11758
+ thinkingContent
11759
+ }, context);
11760
+ return;
11761
+ }
11003
11762
  case "message.updated":
11004
11763
  case "message.part.updated": {
11005
- await this.emitStateChange("agent.streaming", sharedData, context);
11764
+ const messageContent = extractOpenCodeMessageContent(payload);
11765
+ await this.emitStateChange("agent.streaming", {
11766
+ ...sharedData,
11767
+ messageContent
11768
+ }, context);
11006
11769
  return;
11007
11770
  }
11008
11771
  case "permission.asked": {
@@ -11221,6 +11984,67 @@ function extractOpenCodeToolResult(payload) {
11221
11984
  }
11222
11985
  return void 0;
11223
11986
  }
11987
+ function extractOpenCodeMessageContent(payload) {
11988
+ const directMessage = getString10(payload, "text") ?? getString10(payload, "message") ?? getString10(payload, "content") ?? getString10(payload, "output");
11989
+ if (directMessage) {
11990
+ return directMessage;
11991
+ }
11992
+ const part = getRecord9(payload.part) ?? getRecord9(getRecord9(payload.properties)?.part);
11993
+ if (part) {
11994
+ return getString10(part, "text") ?? getString10(part, "content");
11995
+ }
11996
+ const props = getRecord9(payload.properties);
11997
+ if (props) {
11998
+ const message = getRecord9(props.message) ?? getRecord9(props.info);
11999
+ if (message) {
12000
+ return getString10(message, "text") ?? getString10(message, "content");
12001
+ }
12002
+ return getString10(props, "text") ?? getString10(props, "message");
12003
+ }
12004
+ return void 0;
12005
+ }
12006
+ function extractOpenCodeThinkingContent(payload) {
12007
+ const directThinking = getString10(payload, "thinking") ?? getString10(payload, "thinkingContent") ?? getString10(payload, "reasoning") ?? getString10(payload, "thought");
12008
+ if (directThinking) {
12009
+ return directThinking;
12010
+ }
12011
+ const props = getRecord9(payload.properties);
12012
+ if (props) {
12013
+ return getString10(props, "thinking") ?? getString10(props, "reasoning") ?? getString10(props, "thought");
12014
+ }
12015
+ return void 0;
12016
+ }
12017
+ function extractOpenCodeTokens(payload) {
12018
+ const directTokens = getNumber8(payload, "tokensUsed") ?? getNumber8(payload, "tokens");
12019
+ if (directTokens !== void 0) {
12020
+ return { total: directTokens };
12021
+ }
12022
+ const props = getRecord9(payload.properties);
12023
+ if (props) {
12024
+ const info = getRecord9(props.info);
12025
+ if (info) {
12026
+ const tokens = getRecord9(info.tokens);
12027
+ if (tokens) {
12028
+ const inputTokens = getNumber8(tokens, "input") ?? 0;
12029
+ const outputTokens = getNumber8(tokens, "output") ?? 0;
12030
+ const reasoningTokens = getNumber8(tokens, "reasoning") ?? 0;
12031
+ const total = inputTokens + outputTokens + reasoningTokens;
12032
+ return total > 0 ? {
12033
+ total,
12034
+ inputTokens,
12035
+ outputTokens,
12036
+ // reasoning tokens are often billed as cached on some providers
12037
+ cachedTokens: reasoningTokens
12038
+ } : {};
12039
+ }
12040
+ }
12041
+ const fallbackTokens = getNumber8(props, "tokensUsed") ?? getNumber8(props, "tokens");
12042
+ if (fallbackTokens !== void 0) {
12043
+ return { total: fallbackTokens };
12044
+ }
12045
+ }
12046
+ return {};
12047
+ }
11224
12048
 
11225
12049
  // src/adapters/pi.ts
11226
12050
  var import_node_child_process14 = require("child_process");
@@ -14723,9 +15547,9 @@ function flattenValue(lines, currentPath, value) {
14723
15547
  }
14724
15548
  lines.push(formatLoggerField(currentPath, value, inferValueKind(value)));
14725
15549
  }
14726
- function formatLoggerField(path, value, kind) {
15550
+ function formatLoggerField(path2, value, kind) {
14727
15551
  const renderedValue = typeof value === "string" ? JSON.stringify(value) : value === null ? "null" : typeof value === "undefined" ? "undefined" : JSON.stringify(value);
14728
- return `${colorize(path, TUI_THEME.warning)} ${colorize("=", TUI_THEME.muted)} ${colorize(
15552
+ return `${colorize(path2, TUI_THEME.warning)} ${colorize("=", TUI_THEME.muted)} ${colorize(
14729
15553
  renderedValue,
14730
15554
  getValueColor(kind)
14731
15555
  )}`;
@@ -14800,7 +15624,8 @@ function isRecord13(value) {
14800
15624
  }
14801
15625
 
14802
15626
  // src/cli/runtime.ts
14803
- var execFile15 = (0, import_node_util15.promisify)(import_node_child_process16.execFile);
15627
+ var openPromise = Promise.resolve().then(() => (init_open(), open_exports));
15628
+ var execFile21 = (0, import_node_util21.promisify)(import_node_child_process23.execFile);
14804
15629
  var DAEMON_READY_TIMEOUT_MS = 4e3;
14805
15630
  var DAEMON_READY_POLL_INTERVAL_MS = 100;
14806
15631
  var DAEMON_STOP_TIMEOUT_MS = 4e3;
@@ -14810,13 +15635,13 @@ function createCliRuntime(dependencies = {}) {
14810
15635
  const output = dependencies.output ?? createProcessOutput();
14811
15636
  const fetchImplementation = dependencies.fetch ?? globalThis.fetch;
14812
15637
  const renderManagedTuiImplementation = dependencies.renderManagedTui ?? renderManagedTui;
14813
- const spawnImplementation = dependencies.spawn ?? import_node_child_process16.spawn;
15638
+ const spawnImplementation = dependencies.spawn ?? import_node_child_process23.spawn;
14814
15639
  const autoUpdateController = createAutoUpdateController({
14815
15640
  fetch: fetchImplementation,
14816
15641
  spawn: spawnImplementation
14817
15642
  });
14818
15643
  const execFileImplementation = dependencies.execFile ?? (async (file, args) => {
14819
- return await execFile15(file, [...args], {
15644
+ return await execFile21(file, [...args], {
14820
15645
  encoding: "utf8"
14821
15646
  });
14822
15647
  });
@@ -14869,8 +15694,8 @@ function createCliRuntime(dependencies = {}) {
14869
15694
  await ensureConfigDir(daemonPathOptions);
14870
15695
  await rotateDaemonLogIfNeeded(daemonPathOptions);
14871
15696
  const daemonLogPath = getDaemonLogPath(daemonPathOptions);
14872
- const stdoutFd = (0, import_node_fs4.openSync)(daemonLogPath, "w");
14873
- const stderrFd = (0, import_node_fs4.openSync)(daemonLogPath, "a");
15697
+ const stdoutFd = (0, import_node_fs7.openSync)(daemonLogPath, "w");
15698
+ const stderrFd = (0, import_node_fs7.openSync)(daemonLogPath, "a");
14874
15699
  const cliEntryPath = resolveCliEntryPath();
14875
15700
  const daemonArgs = [cliEntryPath, "daemon-run", ...toDaemonArgv(options)];
14876
15701
  const child = spawnImplementation(process.execPath, daemonArgs, {
@@ -14882,8 +15707,8 @@ function createCliRuntime(dependencies = {}) {
14882
15707
  stdio: ["ignore", stdoutFd, stderrFd]
14883
15708
  });
14884
15709
  child.unref();
14885
- (0, import_node_fs4.closeSync)(stdoutFd);
14886
- (0, import_node_fs4.closeSync)(stderrFd);
15710
+ (0, import_node_fs7.closeSync)(stdoutFd);
15711
+ (0, import_node_fs7.closeSync)(stderrFd);
14887
15712
  if (child.pid === void 0) {
14888
15713
  throw new Error("Failed to obtain the AISnitch daemon PID.");
14889
15714
  }
@@ -14955,8 +15780,8 @@ function createCliRuntime(dependencies = {}) {
14955
15780
  if (logSize < DAEMON_LOG_MAX_BYTES) {
14956
15781
  return;
14957
15782
  }
14958
- await (0, import_promises19.rm)(backupPath, { force: true });
14959
- await (0, import_promises19.rename)(logFilePath, backupPath);
15783
+ await (0, import_promises22.rm)(backupPath, { force: true });
15784
+ await (0, import_promises22.rename)(logFilePath, backupPath);
14960
15785
  }
14961
15786
  async function waitForDaemonReady(pathOptions) {
14962
15787
  const deadline = Date.now() + DAEMON_READY_TIMEOUT_MS;
@@ -14991,7 +15816,7 @@ function createCliRuntime(dependencies = {}) {
14991
15816
  }
14992
15817
  async function readDaemonStartupFailure(pathOptions) {
14993
15818
  try {
14994
- const daemonLog = await (0, import_promises19.readFile)(getDaemonLogPath(pathOptions), "utf8");
15819
+ const daemonLog = await (0, import_promises22.readFile)(getDaemonLogPath(pathOptions), "utf8");
14995
15820
  const logLines = daemonLog.split(/\r?\n/u).map((line) => line.trim()).filter((line) => line.length > 0);
14996
15821
  const lastLine = logLines.at(-1);
14997
15822
  if (!lastLine) {
@@ -15303,6 +16128,113 @@ function createCliRuntime(dependencies = {}) {
15303
16128
  }
15304
16129
  });
15305
16130
  }
16131
+ async function fullscreen(options) {
16132
+ const snapshot = await getStatusSnapshot(options);
16133
+ if (!snapshot.running && options.daemonMode) {
16134
+ output.stdout("Starting daemon...\n");
16135
+ await startDetachedDaemon(options);
16136
+ }
16137
+ if (!snapshot.running && !options.daemonMode) {
16138
+ throw new Error(
16139
+ "AISnitch daemon is not running. Start one with `aisnitch start --daemon` or use `aisnitch fs --daemon` to start and open the dashboard."
16140
+ );
16141
+ }
16142
+ for (let i = 0; i < 20; i++) {
16143
+ const health = await fetchHealth(snapshot.httpPort);
16144
+ if (health) break;
16145
+ await new Promise((resolve2) => setTimeout(resolve2, 200).unref());
16146
+ }
16147
+ const dashboardPort = options.dashboardPort ?? 5174;
16148
+ const dashboardUrl = `http://127.0.0.1:${dashboardPort}`;
16149
+ const distPath = (0, import_node_path22.join)(process.cwd(), "examples", "fullscreen-dashboard", "dist");
16150
+ output.stdout(`Starting dashboard server on port ${dashboardPort}...
16151
+ `);
16152
+ const viteProcess = spawnImplementation(process.execPath, [
16153
+ "-e",
16154
+ `
16155
+ import { createServer } from 'vite';
16156
+ import path from 'path';
16157
+
16158
+ const distPath = '${distPath}';
16159
+ const port = ${dashboardPort};
16160
+
16161
+ const server = await createServer({
16162
+ root: distPath,
16163
+ server: {
16164
+ port,
16165
+ strictPort: true,
16166
+ allowedHosts: true,
16167
+ },
16168
+ preview: {
16169
+ port,
16170
+ strictPort: true,
16171
+ },
16172
+ });
16173
+
16174
+ await server.listen();
16175
+ console.log('READY');
16176
+
16177
+ process.stdin.resume();
16178
+ `
16179
+ ], {
16180
+ cwd: distPath,
16181
+ stdio: ["pipe", "pipe", "pipe"]
16182
+ });
16183
+ let serverOutput = "";
16184
+ viteProcess.stdout?.on("data", (data) => {
16185
+ serverOutput += data.toString();
16186
+ });
16187
+ viteProcess.stderr?.on("data", (data) => {
16188
+ serverOutput += data.toString();
16189
+ });
16190
+ let serverReady = false;
16191
+ for (let i = 0; i < 100; i++) {
16192
+ await new Promise((resolve2) => setTimeout(resolve2, 100).unref());
16193
+ try {
16194
+ const response = await fetchImplementation(dashboardUrl);
16195
+ if (response.ok) {
16196
+ serverReady = true;
16197
+ break;
16198
+ }
16199
+ } catch {
16200
+ }
16201
+ if (!viteProcess.pid) break;
16202
+ }
16203
+ if (!serverReady) {
16204
+ output.stdout(`Server output: ${serverOutput}
16205
+ `);
16206
+ throw new Error("Failed to start dashboard server");
16207
+ }
16208
+ output.stdout(`Dashboard ready at ${dashboardUrl}
16209
+ `);
16210
+ if (!options.noBrowser) {
16211
+ output.stdout("Opening browser...\n");
16212
+ const openModule = await openPromise;
16213
+ await openModule.default(dashboardUrl);
16214
+ }
16215
+ output.stdout("Press Ctrl+C to stop\n");
16216
+ await new Promise((resolve2) => {
16217
+ const shutdown = () => {
16218
+ process.off("SIGINT", handleSigint);
16219
+ process.off("SIGTERM", handleSigterm);
16220
+ if (viteProcess.pid !== void 0) {
16221
+ try {
16222
+ process.kill(viteProcess.pid, "SIGTERM");
16223
+ } catch {
16224
+ }
16225
+ }
16226
+ resolve2();
16227
+ };
16228
+ const handleSigint = () => {
16229
+ shutdown();
16230
+ };
16231
+ const handleSigterm = () => {
16232
+ shutdown();
16233
+ };
16234
+ process.once("SIGINT", handleSigint);
16235
+ process.once("SIGTERM", handleSigterm);
16236
+ });
16237
+ }
15306
16238
  async function logger2(options) {
15307
16239
  const snapshot = await getStatusSnapshot(options);
15308
16240
  if (!snapshot.running) {
@@ -15374,7 +16306,7 @@ function createCliRuntime(dependencies = {}) {
15374
16306
  }
15375
16307
  const { config } = await loadEffectiveConfig(options);
15376
16308
  setLoggerLevel(getForegroundSafeLogLevel(config.logLevel, false));
15377
- const ephemeralHomeDirectory = await (0, import_promises19.mkdtemp)((0, import_node_path21.join)((0, import_node_os5.tmpdir)(), "aisnitch-mock-"));
16309
+ const ephemeralHomeDirectory = await (0, import_promises22.mkdtemp)((0, import_node_path22.join)((0, import_node_os6.tmpdir)(), "aisnitch-mock-"));
15378
16310
  const ephemeralPipeline = new Pipeline();
15379
16311
  const status2 = await ephemeralPipeline.start({
15380
16312
  config: {
@@ -15413,7 +16345,7 @@ function createCliRuntime(dependencies = {}) {
15413
16345
  } finally {
15414
16346
  await Promise.resolve(monitorClose());
15415
16347
  await ephemeralPipeline.stop();
15416
- await (0, import_promises19.rm)(ephemeralHomeDirectory, { force: true, recursive: true });
16348
+ await (0, import_promises22.rm)(ephemeralHomeDirectory, { force: true, recursive: true });
15417
16349
  }
15418
16350
  }
15419
16351
  async function install(options) {
@@ -15435,7 +16367,7 @@ function createCliRuntime(dependencies = {}) {
15435
16367
  await execFileImplementation("launchctl", ["bootout", domainTarget, launchAgentPath]);
15436
16368
  } catch {
15437
16369
  }
15438
- await (0, import_promises19.writeFile)(launchAgentPath, plistContents, "utf8");
16370
+ await (0, import_promises22.writeFile)(launchAgentPath, plistContents, "utf8");
15439
16371
  await execFileImplementation("launchctl", ["bootstrap", domainTarget, launchAgentPath]);
15440
16372
  output.stdout(`AISnitch LaunchAgent installed at ${launchAgentPath}
15441
16373
  `);
@@ -15458,7 +16390,7 @@ function createCliRuntime(dependencies = {}) {
15458
16390
  } else {
15459
16391
  const { config } = await loadEffectiveConfig(options);
15460
16392
  setLoggerLevel(getForegroundSafeLogLevel(config.logLevel, false));
15461
- ephemeralHomeDirectory = await (0, import_promises19.mkdtemp)((0, import_node_path21.join)((0, import_node_os5.tmpdir)(), "aisnitch-wrap-"));
16393
+ ephemeralHomeDirectory = await (0, import_promises22.mkdtemp)((0, import_node_path22.join)((0, import_node_os6.tmpdir)(), "aisnitch-wrap-"));
15462
16394
  ephemeralPipeline = new Pipeline();
15463
16395
  await ephemeralPipeline.start({
15464
16396
  config: {
@@ -15513,7 +16445,7 @@ function createCliRuntime(dependencies = {}) {
15513
16445
  await ephemeralPipeline.stop();
15514
16446
  }
15515
16447
  if (ephemeralHomeDirectory !== null) {
15516
- await (0, import_promises19.rm)(ephemeralHomeDirectory, { force: true, recursive: true });
16448
+ await (0, import_promises22.rm)(ephemeralHomeDirectory, { force: true, recursive: true });
15517
16449
  }
15518
16450
  }
15519
16451
  process.exit(wrappedExitCode);
@@ -15533,7 +16465,7 @@ function createCliRuntime(dependencies = {}) {
15533
16465
  },
15534
16466
  pid: process.ppid > 1 ? process.ppid : void 0,
15535
16467
  source: "aisnitch://adapters/aider/notifications-command",
15536
- transcriptPath: (0, import_node_path21.join)(process.cwd(), ".aider.chat.history.md"),
16468
+ transcriptPath: (0, import_node_path22.join)(process.cwd(), ".aider.chat.history.md"),
15537
16469
  type: "agent.idle"
15538
16470
  }),
15539
16471
  headers: {
@@ -15555,7 +16487,7 @@ function createCliRuntime(dependencies = {}) {
15555
16487
  await execFileImplementation("launchctl", ["bootout", domainTarget, launchAgentPath]);
15556
16488
  } catch {
15557
16489
  }
15558
- await (0, import_promises19.rm)(launchAgentPath, { force: true });
16490
+ await (0, import_promises22.rm)(launchAgentPath, { force: true });
15559
16491
  output.stdout(`AISnitch LaunchAgent removed from ${launchAgentPath}
15560
16492
  `);
15561
16493
  }
@@ -15594,6 +16526,7 @@ function createCliRuntime(dependencies = {}) {
15594
16526
  adapters,
15595
16527
  aiderNotify,
15596
16528
  attach,
16529
+ fullscreen,
15597
16530
  install,
15598
16531
  logger: logger2,
15599
16532
  mock,
@@ -15734,7 +16667,7 @@ function joinSocketPath(pathOptions) {
15734
16667
  }
15735
16668
  function resolveCliEntryPath() {
15736
16669
  const cliEntryPath = process.argv[1];
15737
- if (!cliEntryPath || (0, import_node_path21.basename)(cliEntryPath).length === 0) {
16670
+ if (!cliEntryPath || (0, import_node_path22.basename)(cliEntryPath).length === 0) {
15738
16671
  throw new Error("Unable to resolve the AISnitch CLI entry path.");
15739
16672
  }
15740
16673
  return cliEntryPath;
@@ -15805,6 +16738,9 @@ Examples:
15805
16738
  aisnitch start --daemon
15806
16739
  aisnitch start --view full-data
15807
16740
  aisnitch start --mock
16741
+ aisnitch fs
16742
+ aisnitch fs --daemon
16743
+ aisnitch fs --dashboard-port 8080
15808
16744
  aisnitch status
15809
16745
  aisnitch attach
15810
16746
  aisnitch attach --view full-data
@@ -15828,6 +16764,7 @@ Examples:
15828
16764
  addAdaptersCommand(program, runtime);
15829
16765
  addSetupCommand(program, runtime);
15830
16766
  addAttachCommand(program, runtime);
16767
+ addFullscreenCommand(program, runtime);
15831
16768
  addLoggerCommand(program, runtime);
15832
16769
  addMockCommand(program, runtime);
15833
16770
  addWrapCommand(program, runtime);
@@ -15960,6 +16897,23 @@ function addAttachCommand(program, runtime) {
15960
16897
  await runtime.attach(options);
15961
16898
  });
15962
16899
  }
16900
+ function addFullscreenCommand(program, runtime) {
16901
+ addCommonOptions(
16902
+ program.command("fs").description("Open the fullscreen web dashboard in browser (starts daemon if needed with --daemon)").alias("fullscreen").option(
16903
+ "--daemon",
16904
+ "Start the daemon automatically if not running"
16905
+ ).option(
16906
+ "--dashboard-port <port>",
16907
+ "Port for the dashboard server (default: 5174)",
16908
+ wrapOptionParser(parsePortOption)
16909
+ ).option(
16910
+ "--no-browser",
16911
+ "Start server without opening browser"
16912
+ )
16913
+ ).action(async (options) => {
16914
+ await runtime.fullscreen(options);
16915
+ });
16916
+ }
15963
16917
  function addWrapCommand(program, runtime) {
15964
16918
  addCommonOptions(
15965
16919
  program.command("wrap").description("Run a command inside a PTY while AISnitch observes its terminal activity").allowUnknownOption(true).argument("<command>", "Command to wrap").argument("[args...]", "Arguments forwarded to the wrapped command").option("--cwd <path>", "Run the wrapped command from a specific working directory")