aipctl 2026.10.6 → 2026.10.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.
package/build/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var childProcess = require('node:child_process');
4
+ var ChildProcess = require('node:child_process');
5
5
  require('node:stream');
6
6
  var crypto = require('node:crypto');
7
7
  var fs = require('node:fs');
@@ -31,10 +31,7 @@ var require$$0$6 = require('path');
31
31
  var require$$0$5 = require('fs');
32
32
  var require$$0$4 = require('constants');
33
33
  var require$$5 = require('assert');
34
- var process$1 = require('node:process');
35
- var node_buffer = require('node:buffer');
36
- var node_util = require('node:util');
37
- var fs$1 = require('node:fs/promises');
34
+ var promises$1 = require('node:fs/promises');
38
35
 
39
36
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
40
37
  function _interopNamespaceDefault(e) {
@@ -54,7 +51,7 @@ function _interopNamespaceDefault(e) {
54
51
  return Object.freeze(n);
55
52
  }
56
53
 
57
- var childProcess__namespace = /*#__PURE__*/_interopNamespaceDefault(childProcess);
54
+ var ChildProcess__namespace = /*#__PURE__*/_interopNamespaceDefault(ChildProcess);
58
55
  var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
59
56
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
60
57
  var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
@@ -46340,7 +46337,7 @@ const runCommand$1 = fileSystem => command => {
46340
46337
  case "StandardCommand":
46341
46338
  {
46342
46339
  const spawn = flatMap$5(make$m(), exitCode => async(resume => {
46343
- const handle = childProcess__namespace.spawn(command.command, command.args, {
46340
+ const handle = ChildProcess__namespace.spawn(command.command, command.args, {
46344
46341
  stdio: [inputToStdioOption(command.stdin), outputToStdioOption(command.stdout), outputToStdioOption(command.stderr)],
46345
46342
  cwd: getOrElse(command.cwd, constUndefined),
46346
46343
  shell: command.shell,
@@ -46539,7 +46536,7 @@ const openFactory = method => {
46539
46536
  const nodeClose = effectify(fs__namespace.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
46540
46537
  return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), fd => orDie(nodeClose(fd))), map$9(fd => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
46541
46538
  };
46542
- const open$1 = /*#__PURE__*/openFactory("open");
46539
+ const open = /*#__PURE__*/openFactory("open");
46543
46540
  const makeFile = /*#__PURE__*/(() => {
46544
46541
  const nodeReadFactory = method => effectify(fs__namespace.read, handleErrnoException("FileSystem", method), handleBadArgument(method));
46545
46542
  const nodeRead = /*#__PURE__*/nodeReadFactory("read");
@@ -46809,7 +46806,7 @@ const makeFileSystem = /*#__PURE__*/map$9( /*#__PURE__*/serviceOption(WatchBacke
46809
46806
  makeTempDirectoryScoped,
46810
46807
  makeTempFile,
46811
46808
  makeTempFileScoped,
46812
- open: open$1,
46809
+ open,
46813
46810
  readDirectory,
46814
46811
  readFile,
46815
46812
  readLink,
@@ -92122,617 +92119,20 @@ function makeCredentialService(directory) {
92122
92119
  const CredentialServiceLive = succeed$2(CredentialServiceTag, makeCredentialService(CONFIG_DIR$1));
92123
92120
  const CredentialService = CredentialServiceTag;
92124
92121
 
92125
- let isDockerCached;
92126
-
92127
- function hasDockerEnv() {
92128
- try {
92129
- fs.statSync('/.dockerenv');
92130
- return true;
92131
- } catch {
92132
- return false;
92133
- }
92134
- }
92135
-
92136
- function hasDockerCGroup() {
92137
- try {
92138
- return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
92139
- } catch {
92140
- return false;
92141
- }
92142
- }
92143
-
92144
- function isDocker() {
92145
- // TODO: Use `??=` when targeting Node.js 16.
92146
- if (isDockerCached === undefined) {
92147
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
92148
- }
92149
-
92150
- return isDockerCached;
92151
- }
92152
-
92153
- let cachedResult;
92154
-
92155
- // Podman detection
92156
- const hasContainerEnv = () => {
92157
- try {
92158
- fs.statSync('/run/.containerenv');
92159
- return true;
92160
- } catch {
92161
- return false;
92162
- }
92163
- };
92164
-
92165
- function isInsideContainer() {
92166
- // TODO: Use `??=` when targeting Node.js 16.
92167
- if (cachedResult === undefined) {
92168
- cachedResult = hasContainerEnv() || isDocker();
92169
- }
92170
-
92171
- return cachedResult;
92172
- }
92173
-
92174
- const isWsl = () => {
92175
- if (process$1.platform !== 'linux') {
92176
- return false;
92177
- }
92178
-
92179
- if (os.release().toLowerCase().includes('microsoft')) {
92180
- if (isInsideContainer()) {
92181
- return false;
92182
- }
92183
-
92184
- return true;
92185
- }
92186
-
92187
- try {
92188
- if (fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft')) {
92189
- return !isInsideContainer();
92190
- }
92191
- } catch {}
92192
-
92193
- // Fallback for custom kernels: check WSL-specific paths.
92194
- if (
92195
- fs.existsSync('/proc/sys/fs/binfmt_misc/WSLInterop')
92196
- || fs.existsSync('/run/WSL')
92197
- ) {
92198
- return !isInsideContainer();
92199
- }
92200
-
92201
- return false;
92202
- };
92203
-
92204
- var isWsl$1 = process$1.env.__IS_WSL_TEST__ ? isWsl : isWsl();
92205
-
92206
- const wslDrivesMountPoint = (() => {
92207
- // Default value for "root" param
92208
- // according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
92209
- const defaultMountPoint = '/mnt/';
92210
-
92211
- let mountPoint;
92212
-
92213
- return async function () {
92214
- if (mountPoint) {
92215
- // Return memoized mount point value
92216
- return mountPoint;
92217
- }
92218
-
92219
- const configFilePath = '/etc/wsl.conf';
92220
-
92221
- let isConfigFileExists = false;
92222
- try {
92223
- await fs$1.access(configFilePath, fs$1.constants.F_OK);
92224
- isConfigFileExists = true;
92225
- } catch {}
92226
-
92227
- if (!isConfigFileExists) {
92228
- return defaultMountPoint;
92229
- }
92230
-
92231
- const configContent = await fs$1.readFile(configFilePath, {encoding: 'utf8'});
92232
- const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
92233
-
92234
- if (!configMountPoint) {
92235
- return defaultMountPoint;
92236
- }
92237
-
92238
- mountPoint = configMountPoint.groups.mountPoint.trim();
92239
- mountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;
92240
-
92241
- return mountPoint;
92242
- };
92243
- })();
92244
-
92245
- const powerShellPathFromWsl = async () => {
92246
- const mountPoint = await wslDrivesMountPoint();
92247
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
92248
- };
92249
-
92250
- const powerShellPath = async () => {
92251
- if (isWsl$1) {
92252
- return powerShellPathFromWsl();
92253
- }
92254
-
92255
- return `${process$1.env.SYSTEMROOT || process$1.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
92256
- };
92257
-
92258
- function defineLazyProperty(object, propertyName, valueGetter) {
92259
- const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
92260
-
92261
- Object.defineProperty(object, propertyName, {
92262
- configurable: true,
92263
- enumerable: true,
92264
- get() {
92265
- const result = valueGetter();
92266
- define(result);
92267
- return result;
92268
- },
92269
- set(value) {
92270
- define(value);
92271
- }
92272
- });
92273
-
92274
- return object;
92275
- }
92276
-
92277
- const execFileAsync$3 = node_util.promisify(childProcess.execFile);
92278
-
92279
- async function defaultBrowserId() {
92280
- if (process$1.platform !== 'darwin') {
92281
- throw new Error('macOS only');
92282
- }
92283
-
92284
- const {stdout} = await execFileAsync$3('defaults', ['read', 'com.apple.LaunchServices/com.apple.launchservices.secure', 'LSHandlers']);
92285
-
92286
- // `(?!-)` is to prevent matching `LSHandlerRoleAll = "-";`.
92287
- const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
92288
-
92289
- const browserId = match?.groups.id ?? 'com.apple.Safari';
92290
-
92291
- // Correct the case for Safari's bundle identifier
92292
- if (browserId === 'com.apple.safari') {
92293
- return 'com.apple.Safari';
92294
- }
92295
-
92296
- return browserId;
92297
- }
92298
-
92299
- const execFileAsync$2 = node_util.promisify(childProcess.execFile);
92300
-
92301
- async function runAppleScript(script, {humanReadableOutput = true, signal} = {}) {
92302
- if (process$1.platform !== 'darwin') {
92303
- throw new Error('macOS only');
92304
- }
92305
-
92306
- const outputArguments = humanReadableOutput ? [] : ['-ss'];
92307
-
92308
- const execOptions = {};
92309
- if (signal) {
92310
- execOptions.signal = signal;
92311
- }
92312
-
92313
- const {stdout} = await execFileAsync$2('osascript', ['-e', script, outputArguments], execOptions);
92314
- return stdout.trim();
92315
- }
92316
-
92317
- async function bundleName(bundleId) {
92318
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
92319
- }
92320
-
92321
- const execFileAsync$1 = node_util.promisify(childProcess.execFile);
92322
-
92323
- // TODO: Fix the casing of bundle identifiers in the next major version.
92324
-
92325
- // Windows doesn't have browser IDs in the same way macOS/Linux does so we give fake
92326
- // ones that look real and match the macOS/Linux versions for cross-platform apps.
92327
- const windowsBrowserProgIds = {
92328
- MSEdgeHTM: {name: 'Edge', id: 'com.microsoft.edge'}, // The missing `L` is correct.
92329
- MSEdgeBHTML: {name: 'Edge Beta', id: 'com.microsoft.edge.beta'},
92330
- MSEdgeDHTML: {name: 'Edge Dev', id: 'com.microsoft.edge.dev'},
92331
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {name: 'Edge', id: 'com.microsoft.edge.old'},
92332
- ChromeHTML: {name: 'Chrome', id: 'com.google.chrome'},
92333
- ChromeBHTML: {name: 'Chrome Beta', id: 'com.google.chrome.beta'},
92334
- ChromeDHTML: {name: 'Chrome Dev', id: 'com.google.chrome.dev'},
92335
- ChromiumHTM: {name: 'Chromium', id: 'org.chromium.Chromium'},
92336
- BraveHTML: {name: 'Brave', id: 'com.brave.Browser'},
92337
- BraveBHTML: {name: 'Brave Beta', id: 'com.brave.Browser.beta'},
92338
- BraveDHTML: {name: 'Brave Dev', id: 'com.brave.Browser.dev'},
92339
- BraveSSHTM: {name: 'Brave Nightly', id: 'com.brave.Browser.nightly'},
92340
- FirefoxURL: {name: 'Firefox', id: 'org.mozilla.firefox'},
92341
- OperaStable: {name: 'Opera', id: 'com.operasoftware.Opera'},
92342
- VivaldiHTM: {name: 'Vivaldi', id: 'com.vivaldi.Vivaldi'},
92343
- 'IE.HTTP': {name: 'Internet Explorer', id: 'com.microsoft.ie'},
92344
- };
92345
-
92346
- new Map(Object.entries(windowsBrowserProgIds));
92347
-
92348
- class UnknownBrowserError extends Error {}
92349
-
92350
- async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
92351
- const {stdout} = await _execFileAsync('reg', [
92352
- 'QUERY',
92353
- ' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
92354
- '/v',
92355
- 'ProgId',
92356
- ]);
92357
-
92358
- const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
92359
- if (!match) {
92360
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
92361
- }
92362
-
92363
- const {id} = match.groups;
92364
-
92365
- // Windows can append a hash suffix to ProgIds using a dot or hyphen
92366
- // (e.g., `ChromeHTML.ABC123`, `FirefoxURL-6F193CCC56814779`).
92367
- // Try exact match first, then try without the suffix.
92368
- const dotIndex = id.lastIndexOf('.');
92369
- const hyphenIndex = id.lastIndexOf('-');
92370
- const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
92371
- const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
92372
-
92373
- return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {name: id, id};
92374
- }
92375
-
92376
- const execFileAsync = node_util.promisify(childProcess.execFile);
92377
-
92378
- // Inlined: https://github.com/sindresorhus/titleize/blob/main/index.js
92379
- const titleize = string => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, x => x.toUpperCase());
92380
-
92381
- async function defaultBrowser() {
92382
- if (process$1.platform === 'darwin') {
92383
- const id = await defaultBrowserId();
92384
- const name = await bundleName(id);
92385
- return {name, id};
92386
- }
92387
-
92388
- if (process$1.platform === 'linux') {
92389
- const {stdout} = await execFileAsync('xdg-mime', ['query', 'default', 'x-scheme-handler/http']);
92390
- const id = stdout.trim();
92391
- const name = titleize(id.replace(/.desktop$/, '').replace('-', ' '));
92392
- return {name, id};
92393
- }
92394
-
92395
- if (process$1.platform === 'win32') {
92396
- return defaultBrowser$1();
92397
- }
92398
-
92399
- throw new Error('Only macOS, Linux, and Windows are supported');
92400
- }
92401
-
92402
- const execFile = node_util.promisify(childProcess.execFile);
92403
-
92404
- // Path to included `xdg-open`.
92405
- const __dirname$1 = path$1.dirname(NodeUrl.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
92406
- const localXdgOpenPath = path$1.join(__dirname$1, 'xdg-open');
92407
-
92408
- const {platform, arch} = process$1;
92409
-
92410
- /**
92411
- Get the default browser name in Windows from WSL.
92412
-
92413
- @returns {Promise<string>} Browser name.
92414
- */
92415
- async function getWindowsDefaultBrowserFromWsl() {
92416
- const powershellPath = await powerShellPath();
92417
- const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
92418
- const encodedCommand = node_buffer.Buffer.from(rawCommand, 'utf16le').toString('base64');
92419
-
92420
- const {stdout} = await execFile(
92421
- powershellPath,
92422
- [
92423
- '-NoProfile',
92424
- '-NonInteractive',
92425
- '-ExecutionPolicy',
92426
- 'Bypass',
92427
- '-EncodedCommand',
92428
- encodedCommand,
92429
- ],
92430
- {encoding: 'utf8'},
92431
- );
92432
-
92433
- const progId = stdout.trim();
92434
-
92435
- // Map ProgId to browser IDs
92436
- const browserMap = {
92437
- ChromeHTML: 'com.google.chrome',
92438
- BraveHTML: 'com.brave.Browser',
92439
- MSEdgeHTM: 'com.microsoft.edge',
92440
- FirefoxURL: 'org.mozilla.firefox',
92441
- };
92442
-
92443
- return browserMap[progId] ? {id: browserMap[progId]} : {};
92444
- }
92445
-
92446
- const pTryEach = async (array, mapper) => {
92447
- let latestError;
92448
-
92449
- for (const item of array) {
92450
- try {
92451
- return await mapper(item); // eslint-disable-line no-await-in-loop
92452
- } catch (error) {
92453
- latestError = error;
92454
- }
92455
- }
92456
-
92457
- throw latestError;
92458
- };
92459
-
92460
- // eslint-disable-next-line complexity
92461
- const baseOpen = async options => {
92462
- options = {
92463
- wait: false,
92464
- background: false,
92465
- newInstance: false,
92466
- allowNonzeroExitCode: false,
92467
- ...options,
92468
- };
92469
-
92470
- if (Array.isArray(options.app)) {
92471
- return pTryEach(options.app, singleApp => baseOpen({
92472
- ...options,
92473
- app: singleApp,
92474
- }));
92475
- }
92476
-
92477
- let {name: app, arguments: appArguments = []} = options.app ?? {};
92478
- appArguments = [...appArguments];
92479
-
92480
- if (Array.isArray(app)) {
92481
- return pTryEach(app, appName => baseOpen({
92482
- ...options,
92483
- app: {
92484
- name: appName,
92485
- arguments: appArguments,
92486
- },
92487
- }));
92488
- }
92489
-
92490
- if (app === 'browser' || app === 'browserPrivate') {
92491
- // IDs from default-browser for macOS and windows are the same
92492
- const ids = {
92493
- 'com.google.chrome': 'chrome',
92494
- 'google-chrome.desktop': 'chrome',
92495
- 'com.brave.Browser': 'brave',
92496
- 'org.mozilla.firefox': 'firefox',
92497
- 'firefox.desktop': 'firefox',
92498
- 'com.microsoft.msedge': 'edge',
92499
- 'com.microsoft.edge': 'edge',
92500
- 'com.microsoft.edgemac': 'edge',
92501
- 'microsoft-edge.desktop': 'edge',
92502
- };
92503
-
92504
- // Incognito flags for each browser in `apps`.
92505
- const flags = {
92506
- chrome: '--incognito',
92507
- brave: '--incognito',
92508
- firefox: '--private-window',
92509
- edge: '--inPrivate',
92510
- };
92511
-
92512
- const browser = isWsl$1 ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser();
92513
- if (browser.id in ids) {
92514
- const browserName = ids[browser.id];
92515
-
92516
- if (app === 'browserPrivate') {
92517
- appArguments.push(flags[browserName]);
92518
- }
92519
-
92520
- return baseOpen({
92521
- ...options,
92522
- app: {
92523
- name: apps[browserName],
92524
- arguments: appArguments,
92525
- },
92526
- });
92527
- }
92528
-
92529
- throw new Error(`${browser.name} is not supported as a default browser`);
92530
- }
92531
-
92532
- let command;
92533
- const cliArguments = [];
92534
- const childProcessOptions = {};
92535
-
92536
- if (platform === 'darwin') {
92537
- command = 'open';
92538
-
92539
- if (options.wait) {
92540
- cliArguments.push('--wait-apps');
92541
- }
92542
-
92543
- if (options.background) {
92544
- cliArguments.push('--background');
92545
- }
92546
-
92547
- if (options.newInstance) {
92548
- cliArguments.push('--new');
92549
- }
92550
-
92551
- if (app) {
92552
- cliArguments.push('-a', app);
92553
- }
92554
- } else if (platform === 'win32' || (isWsl$1 && !isInsideContainer() && !app)) {
92555
- command = await powerShellPath();
92556
-
92557
- cliArguments.push(
92558
- '-NoProfile',
92559
- '-NonInteractive',
92560
- '-ExecutionPolicy',
92561
- 'Bypass',
92562
- '-EncodedCommand',
92563
- );
92564
-
92565
- if (!isWsl$1) {
92566
- childProcessOptions.windowsVerbatimArguments = true;
92567
- }
92568
-
92569
- const encodedArguments = ['Start'];
92570
-
92571
- if (options.wait) {
92572
- encodedArguments.push('-Wait');
92573
- }
92574
-
92575
- if (app) {
92576
- // Double quote with double quotes to ensure the inner quotes are passed through.
92577
- // Inner quotes are delimited for PowerShell interpretation with backticks.
92578
- encodedArguments.push(`"\`"${app}\`""`);
92579
- if (options.target) {
92580
- appArguments.push(options.target);
92581
- }
92582
- } else if (options.target) {
92583
- encodedArguments.push(`"${options.target}"`);
92584
- }
92585
-
92586
- if (appArguments.length > 0) {
92587
- appArguments = appArguments.map(argument => `"\`"${argument}\`""`);
92588
- encodedArguments.push('-ArgumentList', appArguments.join(','));
92589
- }
92590
-
92591
- // Using Base64-encoded command, accepted by PowerShell, to allow special characters.
92592
- options.target = node_buffer.Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
92593
- } else {
92594
- if (app) {
92595
- command = app;
92596
- } else {
92597
- // When bundled by Webpack, there's no actual package file path and no local `xdg-open`.
92598
- const isBundled = !__dirname$1 || __dirname$1 === '/';
92599
-
92600
- // Check if local `xdg-open` exists and is executable.
92601
- let exeLocalXdgOpen = false;
92602
- try {
92603
- await fs$1.access(localXdgOpenPath, fs$1.constants.X_OK);
92604
- exeLocalXdgOpen = true;
92605
- } catch {}
92606
-
92607
- const useSystemXdgOpen = process$1.versions.electron
92608
- ?? (platform === 'android' || isBundled || !exeLocalXdgOpen);
92609
- command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
92610
- }
92611
-
92612
- if (appArguments.length > 0) {
92613
- cliArguments.push(...appArguments);
92614
- }
92615
-
92616
- if (!options.wait) {
92617
- // `xdg-open` will block the process unless stdio is ignored
92618
- // and it's detached from the parent even if it's unref'd.
92619
- childProcessOptions.stdio = 'ignore';
92620
- childProcessOptions.detached = true;
92621
- }
92622
- }
92623
-
92624
- if (platform === 'darwin' && appArguments.length > 0) {
92625
- cliArguments.push('--args', ...appArguments);
92626
- }
92627
-
92628
- // This has to come after `--args`.
92629
- if (options.target) {
92630
- cliArguments.push(options.target);
92631
- }
92632
-
92633
- const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
92634
-
92635
- if (options.wait) {
92636
- return new Promise((resolve, reject) => {
92637
- subprocess.once('error', reject);
92638
-
92639
- subprocess.once('close', exitCode => {
92640
- if (!options.allowNonzeroExitCode && exitCode > 0) {
92641
- reject(new Error(`Exited with code ${exitCode}`));
92642
- return;
92643
- }
92644
-
92645
- resolve(subprocess);
92646
- });
92647
- });
92648
- }
92649
-
92650
- subprocess.unref();
92651
-
92652
- return subprocess;
92653
- };
92654
-
92655
- const open = (target, options) => {
92656
- if (typeof target !== 'string') {
92657
- throw new TypeError('Expected a `target`');
92658
- }
92659
-
92660
- return baseOpen({
92661
- ...options,
92662
- target,
92663
- });
92664
- };
92665
-
92666
- function detectArchBinary(binary) {
92667
- if (typeof binary === 'string' || Array.isArray(binary)) {
92668
- return binary;
92669
- }
92670
-
92671
- const {[arch]: archBinary} = binary;
92672
-
92673
- if (!archBinary) {
92674
- throw new Error(`${arch} is not supported`);
92675
- }
92676
-
92677
- return archBinary;
92678
- }
92679
-
92680
- function detectPlatformBinary({[platform]: platformBinary}, {wsl}) {
92681
- if (wsl && isWsl$1) {
92682
- return detectArchBinary(wsl);
92683
- }
92684
-
92685
- if (!platformBinary) {
92686
- throw new Error(`${platform} is not supported`);
92687
- }
92688
-
92689
- return detectArchBinary(platformBinary);
92122
+ function openBrowser(url) {
92123
+ try {
92124
+ const os$1 = os.platform();
92125
+ const windows = os$1 === "win32" || os$1 === "linux" && Boolean(process.env["WSL_INTEROP"]);
92126
+ const script = `Start-Process -FilePath '${url.replaceAll("'", "''")}'`;
92127
+ const command = windows ? "powershell.exe" : os$1 === "darwin" ? "/usr/bin/open" : "xdg-open";
92128
+ const args = windows ? ["-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")] : [url];
92129
+ const child = ChildProcess.spawn(command, args, { stdio: "ignore", detached: true });
92130
+ child.on("error", () => void 0);
92131
+ child.unref();
92132
+ } catch {
92133
+ }
92690
92134
  }
92691
92135
 
92692
- const apps = {};
92693
-
92694
- defineLazyProperty(apps, 'chrome', () => detectPlatformBinary({
92695
- darwin: 'google chrome',
92696
- win32: 'chrome',
92697
- linux: ['google-chrome', 'google-chrome-stable', 'chromium'],
92698
- }, {
92699
- wsl: {
92700
- ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
92701
- x64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'],
92702
- },
92703
- }));
92704
-
92705
- defineLazyProperty(apps, 'brave', () => detectPlatformBinary({
92706
- darwin: 'brave browser',
92707
- win32: 'brave',
92708
- linux: ['brave-browser', 'brave'],
92709
- }, {
92710
- wsl: {
92711
- ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
92712
- x64: ['/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe', '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'],
92713
- },
92714
- }));
92715
-
92716
- defineLazyProperty(apps, 'firefox', () => detectPlatformBinary({
92717
- darwin: 'firefox',
92718
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
92719
- linux: 'firefox',
92720
- }, {
92721
- wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe',
92722
- }));
92723
-
92724
- defineLazyProperty(apps, 'edge', () => detectPlatformBinary({
92725
- darwin: 'microsoft edge',
92726
- win32: 'msedge',
92727
- linux: ['microsoft-edge', 'microsoft-edge-dev'],
92728
- }, {
92729
- wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',
92730
- }));
92731
-
92732
- defineLazyProperty(apps, 'browser', () => 'browser');
92733
-
92734
- defineLazyProperty(apps, 'browserPrivate', () => 'browserPrivate');
92735
-
92736
92136
  const REDACTED_VALUE = "[REDACTED]";
92737
92137
  const FULLY_REDACTED_KEYS = /* @__PURE__ */ new Set([
92738
92138
  "token",
@@ -93735,7 +93135,7 @@ const startOAuthFlow = gen(function* () {
93735
93135
  yield* sync$1(() => {
93736
93136
  console.log("Opening browser for login...");
93737
93137
  console.log(`If browser doesn't open, visit: ${sanitizeOAuthAuthorizeUrlForDisplay(authorizeUrl)}`);
93738
- void open(authorizeUrl).catch(() => void 0);
93138
+ void openBrowser(authorizeUrl);
93739
93139
  });
93740
93140
  const callback = yield* raceFirst(
93741
93141
  _await(deferred),
@@ -93775,11 +93175,11 @@ const startOAuthFlow = gen(function* () {
93775
93175
  const BUILD_ENVS = ["local", "dev", "qa", "stage", "prod", "test"];
93776
93176
  const isBuildEnv = (value) => BUILD_ENVS.includes(value);
93777
93177
 
93778
- const injectedBuildEnv = "qa".length > 0 ? "qa" : "local";
93178
+ const injectedBuildEnv = "dev".length > 0 ? "dev" : "local";
93779
93179
  if (!isBuildEnv(injectedBuildEnv)) {
93780
93180
  throw new Error(`Invalid AIPCTL_BUILD_ENV: ${injectedBuildEnv}`);
93781
93181
  }
93782
- const VERSION = "2026.10.6".length > 0 ? "2026.10.6" : "0.0.0";
93182
+ const VERSION = "2026.10.7".length > 0 ? "2026.10.7" : "0.0.0";
93783
93183
  const BUILD_ENV = injectedBuildEnv;
93784
93184
  const INCLUDE_NATIVE_LOGS = BUILD_ENV !== "prod";
93785
93185
 
@@ -94769,9 +94169,9 @@ function apiErrorFromUnknown(error, fallbackMessage) {
94769
94169
  });
94770
94170
  }
94771
94171
  class AgentChatStreamIncompleteError extends Error {
94772
- constructor(sawOnlyTerminalEnvelope) {
94172
+ constructor(canResubscribe) {
94773
94173
  super("Agent chat stream ended without a complete event");
94774
- this.sawOnlyTerminalEnvelope = sawOnlyTerminalEnvelope;
94174
+ this.canResubscribe = canResubscribe;
94775
94175
  this.name = "AgentChatStreamIncompleteError";
94776
94176
  }
94777
94177
  _tag = "AgentChatStreamIncompleteError";
@@ -95011,7 +94411,12 @@ const extractFinalAgentChatResult = (parsed) => {
95011
94411
  return null;
95012
94412
  }
95013
94413
  const text = getResponseMessageText(parsed["responseMessage"]);
95014
- return text === void 0 ? null : { text, conversationId };
94414
+ const requestMessage = parseStreamEnvelopeData(parsed["requestMessage"]);
94415
+ return text === void 0 ? null : {
94416
+ text,
94417
+ conversationId,
94418
+ ...typeof requestMessage?.["messageId"] === "string" ? { requestMessageId: requestMessage["messageId"] } : {}
94419
+ };
95015
94420
  };
95016
94421
  const parseStreamEnvelopeData = (data) => {
95017
94422
  if (typeof data === "string") {
@@ -95056,12 +94461,63 @@ const isTerminalStreamEnvelope = (data) => {
95056
94461
  return false;
95057
94462
  }
95058
94463
  };
95059
- const parseSseStream = async (body) => {
94464
+ const parseSseStream = async (body, execution) => {
94465
+ const { conversationId, runId: expectedRunId, requestMessageId } = execution;
95060
94466
  const reader = body.getReader();
95061
94467
  const decoder = new TextDecoder();
95062
94468
  let buffer = "";
95063
94469
  let hasDataEvent = false;
95064
- let sawOnlyTerminalEnvelope = false;
94470
+ let hasNonTerminalData = false;
94471
+ let uiStarted = false;
94472
+ let uiFinished = false;
94473
+ const textBlocks = /* @__PURE__ */ new Map();
94474
+ const invalidStream = () => createApiError({
94475
+ message: "The chat response was incomplete. Check the conversation before sending the message again.",
94476
+ code: "CLI_RESPONSE_INVALID",
94477
+ outcome: "unknown"
94478
+ });
94479
+ const consumeUiEnvelope = (payload) => {
94480
+ const chunk = parseStreamEnvelopeData(payload["chunk"]);
94481
+ if (!chunk || payload["conversationId"] !== conversationId || typeof payload["runId"] !== "string" || !payload["runId"]) {
94482
+ throw invalidStream();
94483
+ }
94484
+ if (!expectedRunId || payload["runId"] !== expectedRunId) throw invalidStream();
94485
+ if (uiFinished) throw invalidStream();
94486
+ if (chunk["type"] === "start") {
94487
+ if (uiStarted) throw invalidStream();
94488
+ uiStarted = true;
94489
+ return;
94490
+ }
94491
+ if (!uiStarted || typeof chunk["type"] !== "string") throw invalidStream();
94492
+ switch (chunk["type"]) {
94493
+ case "text-start": {
94494
+ const id = chunk["id"];
94495
+ if (typeof id !== "string" || !id || textBlocks.has(id)) throw invalidStream();
94496
+ textBlocks.set(id, { text: "", closed: false });
94497
+ break;
94498
+ }
94499
+ case "text-delta":
94500
+ case "text-end": {
94501
+ const block = typeof chunk["id"] === "string" ? textBlocks.get(chunk["id"]) : void 0;
94502
+ if (!block || block.closed) throw invalidStream();
94503
+ if (chunk["type"] === "text-end") block.closed = true;
94504
+ else {
94505
+ if (typeof chunk["delta"] !== "string") throw invalidStream();
94506
+ block.text += chunk["delta"];
94507
+ }
94508
+ break;
94509
+ }
94510
+ case "finish": {
94511
+ const blocks = [...textBlocks.values()];
94512
+ if (!blocks.some((block) => block.text.length > 0) || blocks.some((block) => !block.closed)) throw invalidStream();
94513
+ uiFinished = true;
94514
+ break;
94515
+ }
94516
+ case "error":
94517
+ case "abort":
94518
+ throw invalidStream();
94519
+ }
94520
+ };
95065
94521
  try {
95066
94522
  while (true) {
95067
94523
  const { done, value } = await reader.read();
@@ -95076,20 +94532,40 @@ const parseSseStream = async (body) => {
95076
94532
  }
95077
94533
  hasDataEvent = true;
95078
94534
  if (isTerminalStreamEnvelope(data)) {
95079
- sawOnlyTerminalEnvelope = true;
94535
+ const terminal = JSON.parse(data);
94536
+ if (uiStarted) {
94537
+ if (terminal["type"] !== "end" || !uiFinished || terminal["status"] !== "completed") throw invalidStream();
94538
+ if (terminal["runId"] !== expectedRunId) throw invalidStream();
94539
+ if ("conversationId" in terminal && terminal["conversationId"] !== conversationId) throw invalidStream();
94540
+ return { conversationId, text: [...textBlocks.values()].map((block) => block.text).join("") };
94541
+ }
94542
+ if (expectedRunId) {
94543
+ if (terminal["runId"] === expectedRunId || hasNonTerminalData) throw invalidStream();
94544
+ throw new AgentChatStreamIncompleteError(true);
94545
+ }
94546
+ if (terminal["type"] === "abort" || terminal["status"] === "failed") throw invalidStream();
94547
+ continue;
94548
+ }
94549
+ const envelope = parseStreamEnvelopeData(data);
94550
+ const payload = envelope?.["type"] === "event" ? parseStreamEnvelopeData(envelope["data"]) : envelope;
94551
+ if (payload && "chunk" in payload) {
94552
+ if (expectedRunId && !uiStarted && payload["conversationId"] === conversationId && typeof payload["runId"] === "string" && payload["runId"] && payload["runId"] !== expectedRunId) continue;
94553
+ hasNonTerminalData = true;
94554
+ consumeUiEnvelope(payload);
95080
94555
  continue;
95081
94556
  }
95082
- sawOnlyTerminalEnvelope = false;
94557
+ hasNonTerminalData = true;
95083
94558
  const result = parseAgentChatEvent(data);
95084
94559
  if (result) {
95085
- return result;
94560
+ if (expectedRunId || uiStarted || result.conversationId !== conversationId || requestMessageId !== void 0 && result.requestMessageId !== requestMessageId) throw invalidStream();
94561
+ return { conversationId: result.conversationId, text: result.text };
95086
94562
  }
95087
94563
  }
95088
94564
  }
95089
94565
  } finally {
95090
94566
  reader.releaseLock();
95091
94567
  }
95092
- throw new AgentChatStreamIncompleteError(hasDataEvent && sawOnlyTerminalEnvelope);
94568
+ throw new AgentChatStreamIncompleteError(hasDataEvent && !hasNonTerminalData);
95093
94569
  };
95094
94570
  const makeApiServiceLive = (buildEnv) => effect$1(
95095
94571
  ApiServiceTag,
@@ -95274,8 +94750,9 @@ const makeApiServiceLive = (buildEnv) => effect$1(
95274
94750
  }
95275
94751
  return _void;
95276
94752
  };
95277
- const subscribeAgentChatStream = (orgSlug, conversationId, token) => gen(function* () {
94753
+ const subscribeAgentChatStream = (orgSlug, execution, token) => gen(function* () {
95278
94754
  const resolvedChatBaseUrl = yield* requireChatBaseUrlEffect();
94755
+ const { conversationId, requestMessageId } = execution;
95279
94756
  const path = `/api/${encodeURIComponent(orgSlug)}/conversations/${encodeURIComponent(conversationId)}/stream`;
95280
94757
  return yield* tryPromise({
95281
94758
  try: async (signal) => {
@@ -95287,7 +94764,7 @@ const makeApiServiceLive = (buildEnv) => effect$1(
95287
94764
  {
95288
94765
  method: "POST",
95289
94766
  headers: jsonBearerHeaders(token),
95290
- body: JSON.stringify({})
94767
+ body: JSON.stringify(requestMessageId === void 0 ? {} : { requestMessageId })
95291
94768
  },
95292
94769
  async (response) => {
95293
94770
  if (!response.ok) {
@@ -95298,7 +94775,7 @@ const makeApiServiceLive = (buildEnv) => effect$1(
95298
94775
  message: "No response body from agent chat stream endpoint"
95299
94776
  });
95300
94777
  }
95301
- return await parseSseStream(response.body);
94778
+ return await parseSseStream(response.body, execution);
95302
94779
  },
95303
94780
  {
95304
94781
  signal,
@@ -95307,7 +94784,7 @@ const makeApiServiceLive = (buildEnv) => effect$1(
95307
94784
  }
95308
94785
  );
95309
94786
  } catch (error) {
95310
- if (error instanceof AgentChatStreamIncompleteError && error.sawOnlyTerminalEnvelope && attempt < AGENT_CHAT_STREAM_MAX_ATTEMPTS) {
94787
+ if (error instanceof AgentChatStreamIncompleteError && error.canResubscribe && attempt < AGENT_CHAT_STREAM_MAX_ATTEMPTS) {
95311
94788
  await sleep(AGENT_CHAT_STREAM_RETRY_DELAY_MS);
95312
94789
  continue;
95313
94790
  }
@@ -95336,7 +94813,14 @@ const makeApiServiceLive = (buildEnv) => effect$1(
95336
94813
  method: "POST",
95337
94814
  body
95338
94815
  });
95339
- return yield* subscribeAgentChatStream(orgSlug, startResponse.conversationId, token);
94816
+ if (!startResponse || typeof startResponse.conversationId !== "string" || !startResponse.conversationId || body.conversationId !== void 0 && body.conversationId !== startResponse.conversationId || "runId" in startResponse && (typeof startResponse.runId !== "string" || !startResponse.runId) || "requestMessageId" in startResponse && (typeof startResponse.requestMessageId !== "string" || !startResponse.requestMessageId) || body.conversationId !== void 0 && !startResponse.runId && !startResponse.requestMessageId) {
94817
+ return yield* fail$3(createApiError({
94818
+ message: "The chat start response did not identify this execution. Check the conversation before sending the message again.",
94819
+ code: "CLI_RESPONSE_INVALID",
94820
+ outcome: "unknown"
94821
+ }));
94822
+ }
94823
+ return yield* subscribeAgentChatStream(orgSlug, startResponse, token);
95340
94824
  });
95341
94825
  const resolveAgentInstallationId = (orgSlug, conversationId, token) => gen(function* () {
95342
94826
  const conversation = yield* makeRequest(
@@ -96417,7 +95901,7 @@ const resolveNativeBinary = (options = {}) => {
96417
95901
  };
96418
95902
  const runNativeCommand = (args, options = {}) => new Promise((resolve) => {
96419
95903
  const env = options.env ?? process.env;
96420
- const spawn = options.spawn ?? childProcess.spawn;
95904
+ const spawn = options.spawn ?? ChildProcess.spawn;
96421
95905
  const binaryPath = resolveNativeBinary(options);
96422
95906
  const child = spawn(binaryPath, [...args], {
96423
95907
  stdio: "inherit",
@@ -98616,8 +98100,11 @@ const uploadCommand$2 = make$4(
98616
98100
  const api = yield* ApiService;
98617
98101
  const ext = path__namespace.extname(file).toLowerCase();
98618
98102
  if (ext !== ".zip" && ext !== ".skill") {
98619
- yield* error$1("Invalid file type. Only .zip and .skill files are supported.");
98620
- return;
98103
+ return yield* fail$3(new ApiError({
98104
+ message: "Invalid file type. Only .zip and .skill files are supported.",
98105
+ code: "CLI_INVALID_ARGUMENT",
98106
+ outcome: "not-dispatched"
98107
+ }));
98621
98108
  }
98622
98109
  const stats = yield* try_({
98623
98110
  try: () => fs__namespace.statSync(file),
@@ -98789,7 +98276,7 @@ const configCommand$1 = make$4(
98789
98276
  yield* log(
98790
98277
  `Command: ${formatSensitiveDisplayValue(config.command, {
98791
98278
  revealSensitive: showSensitive,
98792
- mode: "sanitized"
98279
+ mode: "redacted"
98793
98280
  })}`
98794
98281
  );
98795
98282
  if (!showSensitive) {
@@ -99697,7 +99184,7 @@ const startOrganizationSelectionBrowserFlow = (knownOrganizations, initialSessio
99697
99184
  return yield* gen(function* () {
99698
99185
  yield* sync$1(() => {
99699
99186
  console.log(`If browser doesn't open, visit: ${selectionUrl}`);
99700
- void open(selectionUrl).catch(() => void 0);
99187
+ void openBrowser(selectionUrl);
99701
99188
  });
99702
99189
  const callback = yield* raceFirst(
99703
99190
  _await(deferred),
@@ -100693,14 +100180,14 @@ const buildModelExecImageGenerationRequest = (model, input) => ({
100693
100180
  ...input.options ? { options: input.options } : {}
100694
100181
  });
100695
100182
  const readJsonInputFile = (path) => tryPromise({
100696
- try: async () => JSON.parse(await fs$1.readFile(path, "utf8")),
100183
+ try: async () => JSON.parse(await promises$1.readFile(path, "utf8")),
100697
100184
  catch: (error) => new ApiError({
100698
100185
  message: `Failed to read JSON input "${path}": ${error instanceof Error ? error.message : String(error)}`
100699
100186
  })
100700
100187
  });
100701
100188
  const saveJsonFile = (path, value) => tryPromise({
100702
100189
  try: async () => {
100703
- await fs$1.writeFile(path, `${JSON.stringify(value, null, 2)}
100190
+ await promises$1.writeFile(path, `${JSON.stringify(value, null, 2)}
100704
100191
  `, "utf8");
100705
100192
  },
100706
100193
  catch: (error) => new ApiError({
@@ -101339,13 +100826,14 @@ const testConnectionCommand = make$4(
101339
100826
  if (result.success) {
101340
100827
  yield* log(`\u2713 Connection test passed!`);
101341
100828
  } else {
101342
- yield* log(`\u2717 Connection test failed.`);
101343
- if (result.error) {
101344
- yield* log(` Error: ${formatIntegrationTestMessage(result.error)}`);
101345
- }
101346
- if (result.errorDescription) {
101347
- yield* log(` Message: ${formatIntegrationTestMessage(result.errorDescription)}`);
101348
- }
100829
+ return yield* fail$3(new ApiError({
100830
+ code: "CLI_INTEGRATION_TEST_FAILED",
100831
+ message: formatIntegrationTestMessage([
100832
+ "Connection test failed.",
100833
+ ...result.error ? [`Error: ${result.error}`] : [],
100834
+ ...result.errorDescription ? [`Message: ${result.errorDescription}`] : []
100835
+ ].join(" "))
100836
+ }));
101349
100837
  }
101350
100838
  })
101351
100839
  ).pipe(withDescription("Test an integration connection"));
@@ -101628,7 +101116,7 @@ const resolveImageRequest = (model, prompt, input) => gen(function* () {
101628
101116
  });
101629
101117
  const writeImageFile = (path, buffer) => tryPromise({
101630
101118
  try: async () => {
101631
- await fs$1.writeFile(path, buffer);
101119
+ await promises$1.writeFile(path, buffer);
101632
101120
  },
101633
101121
  catch: (error) => new ApiError({
101634
101122
  message: `Failed to write image "${path}": ${error instanceof Error ? error.message : String(error)}`
@@ -102313,8 +101801,11 @@ const uploadCommand = make$4(
102313
101801
  const api = yield* ApiService;
102314
101802
  const ext = path__namespace.extname(file).toLowerCase();
102315
101803
  if (ext !== ".zip" && ext !== ".skill") {
102316
- yield* error$1("Invalid file type. Only .zip and .skill files are supported.");
102317
- return;
101804
+ return yield* fail$3(new ApiError({
101805
+ message: "Invalid file type. Only .zip and .skill files are supported.",
101806
+ code: "CLI_INVALID_ARGUMENT",
101807
+ outcome: "not-dispatched"
101808
+ }));
102318
101809
  }
102319
101810
  const stats = yield* try_({
102320
101811
  try: () => fs__namespace.statSync(file),
@@ -102583,7 +102074,7 @@ const runNativeHelpIfRequested = (args, options = {}) => {
102583
102074
  return;
102584
102075
  }
102585
102076
  const binaryPath = resolveNativeBinary(options);
102586
- const spawnSync = options.spawnSync ?? childProcess.spawnSync;
102077
+ const spawnSync = options.spawnSync ?? ChildProcess.spawnSync;
102587
102078
  const result = spawnSync(binaryPath, [...nativeArgs], {
102588
102079
  stdio: "inherit",
102589
102080
  env: options.env ?? process.env
@@ -52,9 +52,9 @@
52
52
  | P0-AGENT-01 | agent-user | `aipctl agent list`, `aipctl agent get` | `listInstalledAgents`, `getInstalledAgent` | api | `GET`, `GET` | `/api/cli/v1/organizations/{organizationSlug}/agents`; `/{installedAgentId}` | preserves user read semantics and maps `list`/`installedAgentId` to local `data`/`id` | local `ListInstalledAgentsResponse`, `{ data: InstalledAgentDetail }` | `resource/oas/modules/backend/cli/openapi.yaml`; shared DTO refs from `resource/oas/duplo.yaml` | `backend/api/.../cli/generated/api/CliAgentApi.kt` | `generated-ready` | `P0` | `migrate` | none; dedicated adapter delegates to the working `AgentsApiController` bean | `AI-6344` | `src/core/api.test.ts`, `CliAgentApiControllerTest`, Gateway registry/admission parity; real local production CLI list/get JSON |
53
53
  | P0-AGENT-02 | agent-admin | `aipctl admin agent create`, `update`, `delete`, `share`, `templates`; `aipctl agent enable`, `disable` | `createInstalledAgent`, `updateInstalledAgent`, `deleteInstalledAgent`, `getInstalledAgentShare`, `listAgentTemplates`, `updateInstalledAgentStatus` | api | `POST`, `PATCH`, `DELETE`, `GET`, `GET`, `PATCH` | `/api/cli/v1/organizations/{organizationSlug}/agents`; `/{installedAgentId}`; `/{installedAgentId}/share`; `/templates`; `/{installedAgentId}/status` | existing create/update/status bodies; templates collect bounded pages and retain the full catalog; share is read-only | create/update `{ id }`, void mutation responses, existing CLI template/share mapping | `resource/oas/modules/backend/cli/openapi.yaml`; shared legacy DTO refs | `backend/api/.../cli/generated/api/CliAgentApi.kt` | `generated-ready` | `P0` | `migrate` | none; AI operator/workflow/audit policy stays in existing domain owner | `AI-6344` | all eight operations capability/path tests, mutation non-replay, template paging, real CLI lifecycle/DB/audit and metadata 429 verification |
54
54
  | P0-AGENT-03 | agent-export | `aipctl admin agent export` (GA-CANDIDATE, production gated) | `exportInstalledAgent` | api | `GET` | `/web/admin/organizations/slug/{organizationSlug}/installed-agents/{installedAgentId}/export` | existing direct controller request | YAML `Buffer` | `backend/api/.../app/controller/AgentExportController.kt`; intentionally OAS-codegen excluded | none | `legacy-generated` | `P0` | `legacy-exception` | owner=`AgentExportController`; dedicated transfer contract, size/timeout/partial-file/authorization/audit gates remain | `AI-6380` | existing direct export path/Buffer/404 tests; production help remains hidden |
55
- | P1-CHAT-01 | agent-chat | `aipctl agent chat` | `agentNewChat`, `agentChat`, local `parseSseStream` | chat | `POST` + SSE | `/librechat/api/{orgSlug}/agent/new-chat`; `/librechat/api/{orgSlug}/agent/chat` | request body `{ agentInstallationId or conversationId, text, files: [] }` | local `AgentChatResult { text, conversationId }` parsed from SSE event fields `final`, `conversation.conversationId`, `responseMessage` | path source: `resource/oas/chat.yaml` | `frontend/packages/api/src/out/chat-types.ts#paths["/librechat/api/{orgSlug}/agent/new-chat"]`, `#paths["/librechat/api/{orgSlug}/agent/chat"]` | `stream-exception` | `P1` | `legacy-exception` | owner=`chat backend agent SSE stream contract`; rationale=`path exists in OpenAPI but final SSE event payload is still out-of-band`; removal condition=`official SSE event schema or versioned fixture is published with the chat contract`; incorporation plan=`bind CLI parser/tests to the published SSE fixture and drop local-only stream assumptions` | N/A | updated `src/core/api.test.ts`; covers content[] text, fallback text, malformed event skip, and no-final-event failure |
55
+ | P1-CHAT-01 | agent-chat | `aipctl agent chat` | `agentNewChat`, `agentChat`, local `parseSseStream` | chat | `POST` start + `POST` SSE; continuation lookup `GET` | `/api/{orgSlug}/conversations/agent-chat`; `/api/{orgSlug}/conversations/{conversationId}/stream`; continuation lookup `/librechat/api/{orgSlug}/convos/{conversationId}` | start `{ agentInstallationId, conversationId?, text, files: [] }`; stream `{ requestMessageId? }` from the accepted start response | start `{ conversationId,requestMessageId?,runId? }`; Mastra returns both identifiers; `AgentChatResult { text, conversationId }`; UI event.data `{ seq,conversationId,runId,chunk }` and completed end must match the start-issued runId; legacy final requestMessage.messageId must match requestMessageId when provided; an uncorrelated continuation fails unknown | `lib/chat-rest/packages/schema/src/conversation/chat-start.schema.ts`; `lib/chat-rest/packages/schema/src/chat/chat-v2-stream.schema.ts` | `lib/chat-rest/packages/contract/src/chat.ts`; package-local parser fixture (no frontend runtime dependency) | `stream-exception` | `P1` | `legacy-exception` | owner=`Chat conversation/Agent stream`; rationale=`development Agent execution retains its existing conversation transport and candidate gates`; removal condition=`dedicated execution contract and quota/cancel/recovery gates pass`; incorporation plan=`bind the subscription to the accepted request/run; retry only a subscription containing no current-run data, at most 4 times; never replay the paid start` | `AI-6380` | `src/core/api.test.ts` covers prior completed continuation, bounded stale-run retries, start/terminal identifiers, incomplete/failed/abort and legacy request correlation; built CLI local HTTP fixture returns only current reply (start 1/subscription 2); earlier QA success predates run correlation, which requires updated Chat deployment and QA rerun |
56
56
  | P1-AUTO-01 | automation | `aipctl automation list`, `get`, `create`, `update`, `delete`, `enable`, `disable`, `history`, `triggers` | `listAutomations`, `getAutomation`, `createAutomation`, `updateAutomation`, `deleteAutomation`, `updateAutomationStatus`, `listAutomationHistories`, `getTriggerProviderMetadata` | api | `GET`, `POST`, `PUT`, `DELETE`, `PATCH` | `/api/cli/v1/organizations/{organizationSlug}/automations`; `/{automationId}`; `/{automationId}/status`; `/{automationId}/history`; `/triggers?type=...` | one-based pageNumber/pageSize (1..100); status `{ status }`; exactly one matching trigger branch; metadata retains required accountId/folderId/serviceType input | existing list/history domain DTOs; dedicated `GetCliAutomationResponse` and ID DTO; webhook detail only serviceType/boolean secretConfigured | `resource/oas/modules/backend/cli/openapi.yaml` → `v1_automations*.yaml`; request/list/history aliases reuse Automation user schemas | `backend/api/.../cli/generated/api/CliAutomationApi.kt` | `generated-ready` | `P1` | `migrate` | owner=`CLI Automation adapter`; Schedule/Webhook/My Drive management enabled; external account provider metadata/mutations return 403 before provider side effects; stored external detail never enriches remotely or fabricates account/folder validity | `AI-6344`; external lifecycle gate `AI-6380`; large pagination gate `AI-6413` | `src/core/automation-contract.test.ts`, `src/core/api.test.ts`, Automation command tests, `redaction.test.ts`, Backend safe-read/controller/audit tests, Gateway parity; real mise servers + production CLI CRUD/ownership/pagination/quota/DB/audit |
57
- | P1-AUTO-02 | automation-execution | `aipctl automation run`, `cancel`, `webhook-regen` (GA-CANDIDATE, production gated) | `runAutomation`, `cancelAutomationHistory`, `regenerateWebhookUrl` | api | `POST`, `DELETE`, `POST` | legacy `/api/web/organizations/slug/{organizationSlug}/automations/{automationId}/run`; `/histories/{seq}`; `/webhook-url/regen` | existing domain input | existing execution/history/webhook URL DTO | `resource/oas/modules/backend/automation/user/openapi.yaml` | `frontend/packages/api/src/out/modules/automation-user-types.ts#paths[...]` | `generated-ready` | `P1` | `legacy-exception` | owner=`Automation execution domain`; requires execution quota, idempotency/cancel lifetime, webhook secret rotation and safe output verification before customer enablement | `AI-6380` | existing legacy path/command tests; production availability keeps all three hidden |
57
+ | P1-AUTO-02 | automation-execution | `aipctl automation run`, `cancel`, `webhook-regen` (GA-CANDIDATE, production gated) | `runAutomation`, `cancelAutomationHistory`, `regenerateWebhookUrl` | api | `POST`, `POST`, `POST` | legacy `/api/web/organizations/slug/{organizationSlug}/automations/{automationId}/run`; `/histories/{seq}/cancel`; `/webhook/regenerate-url` | existing domain input | existing execution/history/webhook URL DTO | `resource/oas/modules/backend/automation/user/openapi.yaml` | `frontend/packages/api/src/out/modules/automation-user-types.ts#paths[...]` | `generated-ready` | `P1` | `legacy-exception` | owner=`Automation execution domain`; requires execution quota, idempotency/cancel lifetime, webhook secret rotation and safe output verification before customer enablement | `AI-6380` | existing legacy path/command tests; actual QA SUCCESS/result and PENDING→CANCELED, completed cancellation rejection and masked webhook regeneration; production availability keeps all three hidden |
58
58
  | CHAT-01 | chat-readonly | `aipctl chat list`, `aipctl chat get`, `aipctl chat messages` | `listConversations`, `getConversation`, `listMessages` | chat | `GET` | `/api/cli/v1/organizations/{orgSlug}/chats`; `/chats/{conversationId}`; `/chats/{conversationId}/messages` | list sends optional cursor; server fixes bounded `updatedAt desc` page size; detail/messages preserve organization and user ownership | local `ListConversationsResponse`, `ConversationDetail`, `ChatMessage[]` | `chat/packages/chat/src/modules/cli-chat/interface/cli-chat-read-v1.interface.controller.ts` | code-first controller contract with `operationId`/quota/capability extensions; no generated backend artifact | `oas-source-only` | `P0` | `migrate` | none; `CliChatReadInterfaceService` reuses the existing conversation/message ownership services and returns CLI-safe fields only | `AI-6344` | updated `src/core/api.test.ts`, Chat read service spec, Gateway registry/contract parity; local CLI/Chat verification covers cursor and no legacy fallback |
59
59
  | P0-DRIVE-01 | drive | `aipctl drive list`, `download`, `delete`, `mkdir`, `rename`, `usage` | `listDriveEntries`, `getDriveDownloadUrl`, `deleteDriveEntries`, `createDriveFolder`, `renameDriveEntry`, `getDriveUsage`, `downloadFromUrl` | api + external | `GET`, `POST`, `POST`, `POST`, `PATCH`, `GET`, external `GET` | CLI-managed basic CRUD: `/api/cli/v1/organizations/{organizationSlug}/drive/entries` with optional count/cursor/parentId (default count200), `/drive/entries/delete`, `/drive/folders`, `/drive/entries/{entryId}`, `/drive/usage`; download/upload remain Web/presigned | official list `{ path, hasNext, nextCursor, items }`; delete body `{ entryIds[] }`; mkdir optional `parentId`; rename body `{ newName }`; download body `{ entryIds: [id] }` | official drive list/download DTOs + external file buffer | `resource/oas/modules/backend/cli/openapi.yaml` → `v1_drive_*.yaml` (DTO aliases to organization Storage OAS); download/upload remain `resource/oas/modules/backend/organization/storage/openapi.yaml` | `backend/api/.../cli/generated/api/CliDriveApi.kt`; domain DTOs remain `com.querypie.duplo.api.drive.controller.generated.model.*` | `generated-ready` | `P0` | `migrate` | none; `CliDriveApiController` delegates membership, capacity and audit owner | `AI-6344` | `src/core/api.test.ts`, `CliSkillDriveApiControllerTest`, Gateway registry/contract parity; production CRUD/usage and local 403/404 checks (401/429 remain common gates) |
60
60
  | P0-DRIVE-02 | drive | `aipctl drive upload` | `createDriveUploadUrl` → `uploadToS3` → `completeDriveUpload` | api + external | `POST` → `PUT` → `POST` | `/drive/entries/upload-url`; external presigned `uploadUrl`; `/drive/entries/{entryId}/complete` | official upload request `{ parentId: null, filename, fileSize, mimeType }` | official `CreateDriveUploadUrlResponse { id, filename, uploadUrl, headers }` then `void` | `resource/oas/modules/backend/organization/storage/openapi.yaml` | `frontend/packages/api/src/out/modules/organization-storage-types.ts#paths["/api/web/organizations/slug/{organizationSlug}/drive/entries/upload-url"]`, `#paths["/api/web/organizations/slug/{organizationSlug}/drive/entries/{entryId}/complete"]` | `generated-ready` | `P0` | `migrate` | none | `AIP-PUB-05` | updated `src/core/api.test.ts`, `commands/drive/drive.test.ts`; covers `parentId: null` request and response `id`/`filename` usage |
@@ -128,6 +128,25 @@ OAuth registration·authorization-code·refresh POST의 timeout/invalid JSON/잘
128
128
  `unknown`과 safe request ID를 로그인·갱신의 최종 오류 경계까지 전달한다. 인증 상태를 확인한 뒤
129
129
  재시도하도록 안내하며 자동 재전송 또는 결과가 불명인 응답으로 자격 증명 저장/삭제를 하지 않는다.
130
130
  확인된 `invalid_grant`/401 응답은 기존 session-expired 처리로 구분한다.
131
+
132
+ ## QA 후보 기능에서 확인한 결과 경계
133
+
134
+ 개발 Agent SSE의 UI chunk는 같은 conversation/run에 속해야 하며 열린 text block을 모두 닫고
135
+ 비어 있지 않은 text payload, `finish`와 `end(status=completed)`를 확인한 뒤 성공한다. terminal에 scope/run이 있으면 그것도
136
+ 일치해야 한다. UI stream의 일부 뒤 legacy final이 섞이면 성공으로 처리하지 않는다.
137
+ 오류·abort·미완료 결과는 `CLI_RESPONSE_INVALID/outcome=unknown`이며 provider start를 재실행하지
138
+ 않는다. legacy final-only stream의 content/text 호환은 유지한다.
139
+
140
+ Skill 일반/admin upload의 잘못된 확장자는 upload URL 요청 전에
141
+ `CLI_INVALID_ARGUMENT/outcome=not-dispatched/exit1`이다. Integration test가 HTTP 성공 body의
142
+ `success:false`를 반환해도 CLI는 `CLI_INTEGRATION_TEST_FAILED/exit1`로 실패한다. 진단은 마스킹하고
143
+ 연결 테스트를 재호출하지 않는다. Tunnel config의 positional token을 포함한 전체 command는
144
+ 기본 `[REDACTED]`이고 명시적 `--show-sensitive`에만 표시한다.
145
+
146
+ OAuth와 조직 선택의 자동 browser launcher 실패는 출력한 URL을 통한 수동 흐름을 유지한다.
147
+ 플랫폼 launcher를 shell 없이 spawn하고 같은 동기 호출에서 child-process `error`를 등록한 뒤
148
+ unref한다. next-tick ENOENT와 browser 수명 때문에 CLI가 종료/대기하지 않으며 Windows/WSL은
149
+ single-quoted URL을 encoded PowerShell argument로 전달한다. 인증 성공을 대신하지 않는다.
131
150
  Ctrl+C는 보수적인 `CLI_COMMAND_INTERRUPTED`, `outcome=unknown`, exit 130을 출력하며 remote
132
151
  rollback을 의미하지 않는다. API/auth/org 실패는 exit 1이고 `--json` stderr에 한 건만 기록한다.
133
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aipctl",
3
- "version": "2026.10.6",
3
+ "version": "2026.10.7",
4
4
  "description": "QueryPie AIP and MCP CLI tool",
5
5
  "author": "QueryPie",
6
6
  "license": "UNLICENSED",
@@ -22,16 +22,16 @@
22
22
  "node": ">=24.18.0"
23
23
  },
24
24
  "metadata": {
25
- "contentHash": "9e0908fda7681ccbf1975fe655cbeedd188e32463087c4b3e6aecac3dac8b40b",
26
- "wrapperHash": "b9be71e63fca834ac778c87a1ee12ce076837729b9d00b24d1344aa364d45037",
27
- "nativeHash": "29be9c7354a141aabac5073152f9398eae045da471b18aa089176236c7341552"
25
+ "contentHash": "0c61f13b85564aea40fbf7791f8b143c9cebff23bbc155c433b812d2e7470f76",
26
+ "wrapperHash": "acaef65f9385a791a1d261d6f54232be5b0c56c44d2d9a1d4f2fedcb5dac5e01",
27
+ "nativeHash": "006b08c3e391f4571d9b7c0f12d684fe2448106259e7e0581b10f9be362452e9"
28
28
  },
29
29
  "optionalDependencies": {
30
- "aipctl-darwin-x64": "2026.9.2",
31
- "aipctl-darwin-arm64": "2026.9.2",
32
- "aipctl-linux-x64": "2026.9.2",
33
- "aipctl-linux-arm64": "2026.9.2",
34
- "aipctl-windows-x64": "2026.9.2",
35
- "aipctl-windows-arm64": "2026.9.2"
30
+ "aipctl-darwin-x64": "2026.9.1",
31
+ "aipctl-darwin-arm64": "2026.9.1",
32
+ "aipctl-linux-x64": "2026.9.1",
33
+ "aipctl-linux-arm64": "2026.9.1",
34
+ "aipctl-windows-x64": "2026.9.1",
35
+ "aipctl-windows-arm64": "2026.9.1"
36
36
  }
37
37
  }