openspecui 1.0.0 → 1.0.2

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.
Files changed (29) hide show
  1. package/dist/cli.mjs +2 -2
  2. package/dist/index.mjs +1 -1
  3. package/dist/{src-9rYAmuTz.mjs → src-CG4m4lBD.mjs} +875 -1677
  4. package/package.json +4 -3
  5. package/web/assets/{BufferResource-CVUoegR6.js → BufferResource-DMjllemV.js} +1 -1
  6. package/web/assets/{CanvasRenderer-BEIcB8i1.js → CanvasRenderer-kKbOzIca.js} +1 -1
  7. package/web/assets/{Filter-Bu_qhr6H.js → Filter-C5l7SDia.js} +1 -1
  8. package/web/assets/{RenderTargetSystem-DWouFDxU.js → RenderTargetSystem-BaFVF7ku.js} +1 -1
  9. package/web/assets/{WebGLRenderer-6FH_N1FV.js → WebGLRenderer-Ch58nD6Y.js} +1 -1
  10. package/web/assets/{WebGPURenderer-B8sJk3Sv.js → WebGPURenderer-Bpf-ane5.js} +1 -1
  11. package/web/assets/{browserAll-CLKeV1yb.js → browserAll-CiXGzqJc.js} +1 -1
  12. package/web/assets/{index-Bv7pWR8R.js → index-BQ6UeNz3.js} +1 -1
  13. package/web/assets/{index-BtNuxyw4.js → index-BTMNsWWi.js} +1 -1
  14. package/web/assets/{index-CEKSUzvw.js → index-BXWVYqbO.js} +1 -1
  15. package/web/assets/{index-BRp8MJ9v.js → index-BXqdCpuU.js} +1 -1
  16. package/web/assets/{index-BE5-y0_g.js → index-Bdb0Fpwv.js} +1 -1
  17. package/web/assets/{index-BPCTI2mG.js → index-BgHJ8w_f.js} +1 -1
  18. package/web/assets/{index-D4AU46yO.js → index-BwIIOUjO.js} +1 -1
  19. package/web/assets/{index-mWXhCp9j.js → index-CFkiyi1j.js} +1 -1
  20. package/web/assets/{index-eQZwF8qE.js → index-CLxF_OQQ.js} +1 -1
  21. package/web/assets/{index-DXRZmZm8.js → index-CckLtqno.js} +1 -1
  22. package/web/assets/{index-CEHMo0EU.js → index-CsXgfYOH.js} +252 -260
  23. package/web/assets/{index-CX13iBBs.js → index-D2Uig6TZ.js} +1 -1
  24. package/web/assets/{index-BlZ-sasH.js → index-DEWTHv2o.js} +1 -1
  25. package/web/assets/{index-Bp_dnlLF.js → index-DJZG7SGL.js} +1 -1
  26. package/web/assets/{index-CoOT7eZ9.js → index-L7IKyBGp.js} +1 -1
  27. package/web/assets/{index-Byr3HkRi.js → index-e2r1Tz_y.js} +1 -1
  28. package/web/assets/{webworkerAll-DjWoTx9g.js → webworkerAll-D0vlbEoH.js} +1 -1
  29. package/web/index.html +1 -1
@@ -15,6 +15,7 @@ import { exec, spawn } from "child_process";
15
15
  import { promisify } from "util";
16
16
  import { EventEmitter as EventEmitter$1 } from "node:events";
17
17
  import { createServer as createServer$1 } from "node:net";
18
+ import * as pty from "@lydell/node-pty";
18
19
  import { fileURLToPath } from "node:url";
19
20
 
20
21
  //#region rolldown:runtime
@@ -571,25 +572,25 @@ var handleParsingNestedValues = (form, key, value) => {
571
572
 
572
573
  //#endregion
573
574
  //#region ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/utils/url.js
574
- var splitPath = (path$2) => {
575
- const paths = path$2.split("/");
575
+ var splitPath = (path$1) => {
576
+ const paths = path$1.split("/");
576
577
  if (paths[0] === "") paths.shift();
577
578
  return paths;
578
579
  };
579
580
  var splitRoutingPath = (routePath) => {
580
- const { groups, path: path$2 } = extractGroupsFromPath(routePath);
581
- return replaceGroupMarks(splitPath(path$2), groups);
581
+ const { groups, path: path$1 } = extractGroupsFromPath(routePath);
582
+ return replaceGroupMarks(splitPath(path$1), groups);
582
583
  };
583
- var extractGroupsFromPath = (path$2) => {
584
+ var extractGroupsFromPath = (path$1) => {
584
585
  const groups = [];
585
- path$2 = path$2.replace(/\{[^}]+\}/g, (match$1, index) => {
586
+ path$1 = path$1.replace(/\{[^}]+\}/g, (match$1, index) => {
586
587
  const mark = `@${index}`;
587
588
  groups.push([mark, match$1]);
588
589
  return mark;
589
590
  });
590
591
  return {
591
592
  groups,
592
- path: path$2
593
+ path: path$1
593
594
  };
594
595
  };
595
596
  var replaceGroupMarks = (paths, groups) => {
@@ -648,8 +649,8 @@ var getPath = (request) => {
648
649
  const charCode = url.charCodeAt(i);
649
650
  if (charCode === 37) {
650
651
  const queryIndex = url.indexOf("?", i);
651
- const path$2 = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);
652
- return tryDecodeURI(path$2.includes("%25") ? path$2.replace(/%25/g, "%2525") : path$2);
652
+ const path$1 = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);
653
+ return tryDecodeURI(path$1.includes("%25") ? path$1.replace(/%25/g, "%2525") : path$1);
653
654
  } else if (charCode === 63) break;
654
655
  }
655
656
  return url.slice(start, i);
@@ -662,9 +663,9 @@ var mergePath = (base, sub, ...rest) => {
662
663
  if (rest.length) sub = mergePath(sub, ...rest);
663
664
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
664
665
  };
665
- var checkOptionalParameter = (path$2) => {
666
- if (path$2.charCodeAt(path$2.length - 1) !== 63 || !path$2.includes(":")) return null;
667
- const segments = path$2.split("/");
666
+ var checkOptionalParameter = (path$1) => {
667
+ if (path$1.charCodeAt(path$1.length - 1) !== 63 || !path$1.includes(":")) return null;
668
+ const segments = path$1.split("/");
668
669
  const results = [];
669
670
  let basePath = "";
670
671
  segments.forEach((segment) => {
@@ -742,9 +743,9 @@ var HonoRequest = class {
742
743
  routeIndex = 0;
743
744
  path;
744
745
  bodyCache = {};
745
- constructor(request, path$2 = "/", matchResult = [[]]) {
746
+ constructor(request, path$1 = "/", matchResult = [[]]) {
746
747
  this.raw = request;
747
- this.path = path$2;
748
+ this.path = path$1;
748
749
  this.#matchResult = matchResult;
749
750
  this.#validatedData = {};
750
751
  }
@@ -1059,8 +1060,8 @@ var Hono$1 = class {
1059
1060
  return this;
1060
1061
  };
1061
1062
  });
1062
- this.on = (method, path$2, ...handlers$1) => {
1063
- for (const p of [path$2].flat()) {
1063
+ this.on = (method, path$1, ...handlers$1) => {
1064
+ for (const p of [path$1].flat()) {
1064
1065
  this.#path = p;
1065
1066
  for (const m of [method].flat()) handlers$1.map((handler) => {
1066
1067
  this.#addRoute(m.toUpperCase(), this.#path, handler);
@@ -1095,8 +1096,8 @@ var Hono$1 = class {
1095
1096
  }
1096
1097
  #notFoundHandler = notFoundHandler;
1097
1098
  errorHandler = errorHandler;
1098
- route(path$2, app) {
1099
- const subApp = this.basePath(path$2);
1099
+ route(path$1, app) {
1100
+ const subApp = this.basePath(path$1);
1100
1101
  app.routes.map((r) => {
1101
1102
  let handler;
1102
1103
  if (app.errorHandler === errorHandler) handler = r.handler;
@@ -1108,9 +1109,9 @@ var Hono$1 = class {
1108
1109
  });
1109
1110
  return this;
1110
1111
  }
1111
- basePath(path$2) {
1112
+ basePath(path$1) {
1112
1113
  const subApp = this.#clone();
1113
- subApp._basePath = mergePath(this._basePath, path$2);
1114
+ subApp._basePath = mergePath(this._basePath, path$1);
1114
1115
  return subApp;
1115
1116
  }
1116
1117
  onError = (handler) => {
@@ -1121,7 +1122,7 @@ var Hono$1 = class {
1121
1122
  this.#notFoundHandler = handler;
1122
1123
  return this;
1123
1124
  };
1124
- mount(path$2, applicationHandler, options) {
1125
+ mount(path$1, applicationHandler, options) {
1125
1126
  let replaceRequest;
1126
1127
  let optionHandler;
1127
1128
  if (options) if (typeof options === "function") optionHandler = options;
@@ -1141,7 +1142,7 @@ var Hono$1 = class {
1141
1142
  return [c.env, executionContext];
1142
1143
  };
1143
1144
  replaceRequest ||= (() => {
1144
- const mergedPath = mergePath(this._basePath, path$2);
1145
+ const mergedPath = mergePath(this._basePath, path$1);
1145
1146
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
1146
1147
  return (request) => {
1147
1148
  const url = new URL(request.url);
@@ -1154,19 +1155,19 @@ var Hono$1 = class {
1154
1155
  if (res) return res;
1155
1156
  await next();
1156
1157
  };
1157
- this.#addRoute(METHOD_NAME_ALL, mergePath(path$2, "*"), handler);
1158
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path$1, "*"), handler);
1158
1159
  return this;
1159
1160
  }
1160
- #addRoute(method, path$2, handler) {
1161
+ #addRoute(method, path$1, handler) {
1161
1162
  method = method.toUpperCase();
1162
- path$2 = mergePath(this._basePath, path$2);
1163
+ path$1 = mergePath(this._basePath, path$1);
1163
1164
  const r = {
1164
1165
  basePath: this._basePath,
1165
- path: path$2,
1166
+ path: path$1,
1166
1167
  method,
1167
1168
  handler
1168
1169
  };
1169
- this.router.add(method, path$2, [handler, r]);
1170
+ this.router.add(method, path$1, [handler, r]);
1170
1171
  this.routes.push(r);
1171
1172
  }
1172
1173
  #handleError(err, c) {
@@ -1175,10 +1176,10 @@ var Hono$1 = class {
1175
1176
  }
1176
1177
  #dispatch(request, executionCtx, env, method) {
1177
1178
  if (method === "HEAD") return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
1178
- const path$2 = this.getPath(request, { env });
1179
- const matchResult = this.router.match(method, path$2);
1179
+ const path$1 = this.getPath(request, { env });
1180
+ const matchResult = this.router.match(method, path$1);
1180
1181
  const c = new Context(request, {
1181
- path: path$2,
1182
+ path: path$1,
1182
1183
  matchResult,
1183
1184
  env,
1184
1185
  executionCtx,
@@ -1224,7 +1225,7 @@ var Hono$1 = class {
1224
1225
  //#endregion
1225
1226
  //#region ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/router/reg-exp-router/matcher.js
1226
1227
  var emptyParam = [];
1227
- function match(method, path$2) {
1228
+ function match(method, path$1) {
1228
1229
  const matchers = this.buildAllMatchers();
1229
1230
  const match2 = (method2, path2) => {
1230
1231
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
@@ -1236,7 +1237,7 @@ function match(method, path$2) {
1236
1237
  return [matcher[1][index], match3];
1237
1238
  };
1238
1239
  this.match = match2;
1239
- return match2(method, path$2);
1240
+ return match2(method, path$1);
1240
1241
  }
1241
1242
 
1242
1243
  //#endregion
@@ -1324,12 +1325,12 @@ var Node$4 = class {
1324
1325
  var Trie = class {
1325
1326
  #context = { varIndex: 0 };
1326
1327
  #root = new Node$4();
1327
- insert(path$2, index, pathErrorCheckOnly) {
1328
+ insert(path$1, index, pathErrorCheckOnly) {
1328
1329
  const paramAssoc = [];
1329
1330
  const groups = [];
1330
1331
  for (let i = 0;;) {
1331
1332
  let replaced = false;
1332
- path$2 = path$2.replace(/\{[^}]+\}/g, (m) => {
1333
+ path$1 = path$1.replace(/\{[^}]+\}/g, (m) => {
1333
1334
  const mark = `@\\${i}`;
1334
1335
  groups[i] = [mark, m];
1335
1336
  i++;
@@ -1338,7 +1339,7 @@ var Trie = class {
1338
1339
  });
1339
1340
  if (!replaced) break;
1340
1341
  }
1341
- const tokens = path$2.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1342
+ const tokens = path$1.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1342
1343
  for (let i = groups.length - 1; i >= 0; i--) {
1343
1344
  const [mark] = groups[i];
1344
1345
  for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
@@ -1386,8 +1387,8 @@ var nullMatcher = [
1386
1387
  /* @__PURE__ */ Object.create(null)
1387
1388
  ];
1388
1389
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1389
- function buildWildcardRegExp(path$2) {
1390
- return wildcardRegExpCache[path$2] ??= /* @__PURE__ */ new RegExp(path$2 === "*" ? "" : `^${path$2.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
1390
+ function buildWildcardRegExp(path$1) {
1391
+ return wildcardRegExpCache[path$1] ??= /* @__PURE__ */ new RegExp(path$1 === "*" ? "" : `^${path$1.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
1391
1392
  }
1392
1393
  function clearWildcardRegExpCache() {
1393
1394
  wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
@@ -1399,14 +1400,14 @@ function buildMatcherFromPreprocessedRoutes(routes) {
1399
1400
  const routesWithStaticPathFlag = routes.map((route) => [!/\*|\/:/.test(route[0]), ...route]).sort(([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
1400
1401
  const staticMap = /* @__PURE__ */ Object.create(null);
1401
1402
  for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
1402
- const [pathErrorCheckOnly, path$2, handlers$1] = routesWithStaticPathFlag[i];
1403
- if (pathErrorCheckOnly) staticMap[path$2] = [handlers$1.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
1403
+ const [pathErrorCheckOnly, path$1, handlers$1] = routesWithStaticPathFlag[i];
1404
+ if (pathErrorCheckOnly) staticMap[path$1] = [handlers$1.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
1404
1405
  else j++;
1405
1406
  let paramAssoc;
1406
1407
  try {
1407
- paramAssoc = trie.insert(path$2, j, pathErrorCheckOnly);
1408
+ paramAssoc = trie.insert(path$1, j, pathErrorCheckOnly);
1408
1409
  } catch (e) {
1409
- throw e === PATH_ERROR ? new UnsupportedPathError(path$2) : e;
1410
+ throw e === PATH_ERROR ? new UnsupportedPathError(path$1) : e;
1410
1411
  }
1411
1412
  if (pathErrorCheckOnly) continue;
1412
1413
  handlerData[j] = handlers$1.map(([h, paramCount]) => {
@@ -1434,9 +1435,9 @@ function buildMatcherFromPreprocessedRoutes(routes) {
1434
1435
  staticMap
1435
1436
  ];
1436
1437
  }
1437
- function findMiddleware(middleware, path$2) {
1438
+ function findMiddleware(middleware, path$1) {
1438
1439
  if (!middleware) return;
1439
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path$2)) return [...middleware[k]];
1440
+ for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path$1)) return [...middleware[k]];
1440
1441
  }
1441
1442
  var RegExpRouter = class {
1442
1443
  name = "RegExpRouter";
@@ -1446,7 +1447,7 @@ var RegExpRouter = class {
1446
1447
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
1447
1448
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
1448
1449
  }
1449
- add(method, path$2, handler) {
1450
+ add(method, path$1, handler) {
1450
1451
  const middleware = this.#middleware;
1451
1452
  const routes = this.#routes;
1452
1453
  if (!middleware || !routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
@@ -1456,14 +1457,14 @@ var RegExpRouter = class {
1456
1457
  handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
1457
1458
  });
1458
1459
  });
1459
- if (path$2 === "/*") path$2 = "*";
1460
- const paramCount = (path$2.match(/\/:/g) || []).length;
1461
- if (/\*$/.test(path$2)) {
1462
- const re = buildWildcardRegExp(path$2);
1460
+ if (path$1 === "/*") path$1 = "*";
1461
+ const paramCount = (path$1.match(/\/:/g) || []).length;
1462
+ if (/\*$/.test(path$1)) {
1463
+ const re = buildWildcardRegExp(path$1);
1463
1464
  if (method === METHOD_NAME_ALL) Object.keys(middleware).forEach((m) => {
1464
- middleware[m][path$2] ||= findMiddleware(middleware[m], path$2) || findMiddleware(middleware[METHOD_NAME_ALL], path$2) || [];
1465
+ middleware[m][path$1] ||= findMiddleware(middleware[m], path$1) || findMiddleware(middleware[METHOD_NAME_ALL], path$1) || [];
1465
1466
  });
1466
- else middleware[method][path$2] ||= findMiddleware(middleware[method], path$2) || findMiddleware(middleware[METHOD_NAME_ALL], path$2) || [];
1467
+ else middleware[method][path$1] ||= findMiddleware(middleware[method], path$1) || findMiddleware(middleware[METHOD_NAME_ALL], path$1) || [];
1467
1468
  Object.keys(middleware).forEach((m) => {
1468
1469
  if (method === METHOD_NAME_ALL || method === m) Object.keys(middleware[m]).forEach((p) => {
1469
1470
  re.test(p) && middleware[m][p].push([handler, paramCount]);
@@ -1474,7 +1475,7 @@ var RegExpRouter = class {
1474
1475
  });
1475
1476
  return;
1476
1477
  }
1477
- const paths = checkOptionalParameter(path$2) || [path$2];
1478
+ const paths = checkOptionalParameter(path$1) || [path$1];
1478
1479
  for (let i = 0, len = paths.length; i < len; i++) {
1479
1480
  const path2 = paths[i];
1480
1481
  Object.keys(routes).forEach((m) => {
@@ -1499,11 +1500,11 @@ var RegExpRouter = class {
1499
1500
  const routes = [];
1500
1501
  let hasOwnRoute = method === METHOD_NAME_ALL;
1501
1502
  [this.#middleware, this.#routes].forEach((r) => {
1502
- const ownRoute = r[method] ? Object.keys(r[method]).map((path$2) => [path$2, r[method][path$2]]) : [];
1503
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path$1) => [path$1, r[method][path$1]]) : [];
1503
1504
  if (ownRoute.length !== 0) {
1504
1505
  hasOwnRoute ||= true;
1505
1506
  routes.push(...ownRoute);
1506
- } else if (method !== METHOD_NAME_ALL) routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path$2) => [path$2, r[METHOD_NAME_ALL][path$2]]));
1507
+ } else if (method !== METHOD_NAME_ALL) routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path$1) => [path$1, r[METHOD_NAME_ALL][path$1]]));
1507
1508
  });
1508
1509
  if (!hasOwnRoute) return null;
1509
1510
  else return buildMatcherFromPreprocessedRoutes(routes);
@@ -1519,15 +1520,15 @@ var SmartRouter = class {
1519
1520
  constructor(init) {
1520
1521
  this.#routers = init.routers;
1521
1522
  }
1522
- add(method, path$2, handler) {
1523
+ add(method, path$1, handler) {
1523
1524
  if (!this.#routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1524
1525
  this.#routes.push([
1525
1526
  method,
1526
- path$2,
1527
+ path$1,
1527
1528
  handler
1528
1529
  ]);
1529
1530
  }
1530
- match(method, path$2) {
1531
+ match(method, path$1) {
1531
1532
  if (!this.#routes) throw new Error("Fatal error");
1532
1533
  const routers = this.#routers;
1533
1534
  const routes = this.#routes;
@@ -1538,7 +1539,7 @@ var SmartRouter = class {
1538
1539
  const router$1 = routers[i];
1539
1540
  try {
1540
1541
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) router$1.add(...routes[i2]);
1541
- res = router$1.match(method, path$2);
1542
+ res = router$1.match(method, path$1);
1542
1543
  } catch (e) {
1543
1544
  if (e instanceof UnsupportedPathError) continue;
1544
1545
  throw e;
@@ -1581,10 +1582,10 @@ var Node$3 = class {
1581
1582
  }
1582
1583
  this.#patterns = [];
1583
1584
  }
1584
- insert(method, path$2, handler) {
1585
+ insert(method, path$1, handler) {
1585
1586
  this.#order = ++this.#order;
1586
1587
  let curNode = this;
1587
- const parts = splitRoutingPath(path$2);
1588
+ const parts = splitRoutingPath(path$1);
1588
1589
  const possibleKeys = [];
1589
1590
  for (let i = 0, len = parts.length; i < len; i++) {
1590
1591
  const p = parts[i];
@@ -1629,11 +1630,11 @@ var Node$3 = class {
1629
1630
  }
1630
1631
  return handlerSets;
1631
1632
  }
1632
- search(method, path$2) {
1633
+ search(method, path$1) {
1633
1634
  const handlerSets = [];
1634
1635
  this.#params = emptyParams;
1635
1636
  let curNodes = [this];
1636
- const parts = splitPath(path$2);
1637
+ const parts = splitPath(path$1);
1637
1638
  const curNodesQueue = [];
1638
1639
  for (let i = 0, len = parts.length; i < len; i++) {
1639
1640
  const part = parts[i];
@@ -1707,16 +1708,16 @@ var TrieRouter = class {
1707
1708
  constructor() {
1708
1709
  this.#node = new Node$3();
1709
1710
  }
1710
- add(method, path$2, handler) {
1711
- const results = checkOptionalParameter(path$2);
1711
+ add(method, path$1, handler) {
1712
+ const results = checkOptionalParameter(path$1);
1712
1713
  if (results) {
1713
1714
  for (let i = 0, len = results.length; i < len; i++) this.#node.insert(method, results[i], handler);
1714
1715
  return;
1715
1716
  }
1716
- this.#node.insert(method, path$2, handler);
1717
+ this.#node.insert(method, path$1, handler);
1717
1718
  }
1718
- match(method, path$2) {
1719
- return this.#node.search(method, path$2);
1719
+ match(method, path$1) {
1720
+ return this.#node.search(method, path$1);
1720
1721
  }
1721
1722
  };
1722
1723
 
@@ -1922,27 +1923,27 @@ const noop = () => {};
1922
1923
  const freezeIfAvailable = (obj) => {
1923
1924
  if (Object.freeze) Object.freeze(obj);
1924
1925
  };
1925
- function createInnerProxy(callback, path$2, memo$1) {
1926
+ function createInnerProxy(callback, path$1, memo$1) {
1926
1927
  var _memo$cacheKey;
1927
- const cacheKey$1 = path$2.join(".");
1928
+ const cacheKey$1 = path$1.join(".");
1928
1929
  (_memo$cacheKey = memo$1[cacheKey$1]) !== null && _memo$cacheKey !== void 0 || (memo$1[cacheKey$1] = new Proxy(noop, {
1929
1930
  get(_obj, key) {
1930
1931
  if (typeof key !== "string" || key === "then") return void 0;
1931
- return createInnerProxy(callback, [...path$2, key], memo$1);
1932
+ return createInnerProxy(callback, [...path$1, key], memo$1);
1932
1933
  },
1933
1934
  apply(_1, _2, args) {
1934
- const lastOfPath = path$2[path$2.length - 1];
1935
+ const lastOfPath = path$1[path$1.length - 1];
1935
1936
  let opts = {
1936
1937
  args,
1937
- path: path$2
1938
+ path: path$1
1938
1939
  };
1939
1940
  if (lastOfPath === "call") opts = {
1940
1941
  args: args.length >= 2 ? [args[1]] : [],
1941
- path: path$2.slice(0, -1)
1942
+ path: path$1.slice(0, -1)
1942
1943
  };
1943
1944
  else if (lastOfPath === "apply") opts = {
1944
1945
  args: args.length >= 2 ? args[1] : [],
1945
- path: path$2.slice(0, -1)
1946
+ path: path$1.slice(0, -1)
1946
1947
  };
1947
1948
  freezeIfAvailable(opts.args);
1948
1949
  freezeIfAvailable(opts.path);
@@ -2077,7 +2078,7 @@ var import_objectSpread2$6 = __toESM(require_objectSpread2(), 1);
2077
2078
  * @internal
2078
2079
  */
2079
2080
  function getErrorShape(opts) {
2080
- const { path: path$2, error, config } = opts;
2081
+ const { path: path$1, error, config } = opts;
2081
2082
  const { code } = opts.error;
2082
2083
  const shape = {
2083
2084
  message: error.message,
@@ -2088,7 +2089,7 @@ function getErrorShape(opts) {
2088
2089
  }
2089
2090
  };
2090
2091
  if (config.isDev && typeof opts.error.stack === "string") shape.data.stack = opts.error.stack;
2091
- if (typeof path$2 === "string") shape.data.path = path$2;
2092
+ if (typeof path$1 === "string") shape.data.path = path$1;
2092
2093
  return config.errorFormatter((0, import_objectSpread2$6.default)((0, import_objectSpread2$6.default)({}, opts), {}, { shape }));
2093
2094
  }
2094
2095
 
@@ -2231,12 +2232,12 @@ function createRouterFactory(config) {
2231
2232
  })
2232
2233
  };
2233
2234
  }
2234
- function step(from, path$2 = []) {
2235
+ function step(from, path$1 = []) {
2235
2236
  const aggregate = omitPrototype({});
2236
2237
  for (const [key, item] of Object.entries(from !== null && from !== void 0 ? from : {})) {
2237
2238
  if (isLazy(item)) {
2238
- lazy$1[[...path$2, key].join(".")] = createLazyLoader({
2239
- path: path$2,
2239
+ lazy$1[[...path$1, key].join(".")] = createLazyLoader({
2240
+ path: path$1,
2240
2241
  ref: item,
2241
2242
  key,
2242
2243
  aggregate
@@ -2244,14 +2245,14 @@ function createRouterFactory(config) {
2244
2245
  continue;
2245
2246
  }
2246
2247
  if (isRouter(item)) {
2247
- aggregate[key] = step(item._def.record, [...path$2, key]);
2248
+ aggregate[key] = step(item._def.record, [...path$1, key]);
2248
2249
  continue;
2249
2250
  }
2250
2251
  if (!isProcedure(item)) {
2251
- aggregate[key] = step(item, [...path$2, key]);
2252
+ aggregate[key] = step(item, [...path$1, key]);
2252
2253
  continue;
2253
2254
  }
2254
- const newPath = [...path$2, key].join(".");
2255
+ const newPath = [...path$1, key].join(".");
2255
2256
  if (procedures[newPath]) throw new Error(`Duplicate key: ${newPath}`);
2256
2257
  procedures[newPath] = item;
2257
2258
  aggregate[key] = item;
@@ -2278,14 +2279,14 @@ function isProcedure(procedureOrRouter) {
2278
2279
  /**
2279
2280
  * @internal
2280
2281
  */
2281
- async function getProcedureAtPath(router$1, path$2) {
2282
+ async function getProcedureAtPath(router$1, path$1) {
2282
2283
  const { _def } = router$1;
2283
- let procedure = _def.procedures[path$2];
2284
+ let procedure = _def.procedures[path$1];
2284
2285
  while (!procedure) {
2285
- const key = Object.keys(_def.lazy).find((key$1) => path$2.startsWith(key$1));
2286
+ const key = Object.keys(_def.lazy).find((key$1) => path$1.startsWith(key$1));
2286
2287
  if (!key) return null;
2287
2288
  await _def.lazy[key].load();
2288
- procedure = _def.procedures[path$2];
2289
+ procedure = _def.procedures[path$1];
2289
2290
  }
2290
2291
  return procedure;
2291
2292
  }
@@ -2293,11 +2294,11 @@ async function getProcedureAtPath(router$1, path$2) {
2293
2294
  * @internal
2294
2295
  */
2295
2296
  async function callProcedure(opts) {
2296
- const { type, path: path$2 } = opts;
2297
- const proc = await getProcedureAtPath(opts.router, path$2);
2297
+ const { type, path: path$1 } = opts;
2298
+ const proc = await getProcedureAtPath(opts.router, path$1);
2298
2299
  if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) throw new TRPCError({
2299
2300
  code: "NOT_FOUND",
2300
- message: `No "${type}"-procedure on path "${path$2}"`
2301
+ message: `No "${type}"-procedure on path "${path$1}"`
2301
2302
  });
2302
2303
  /* istanbul ignore if -- @preserve */
2303
2304
  if (proc._def.type !== type && opts.allowMethodOverride && proc._def.type === "subscription") throw new TRPCError({
@@ -2311,15 +2312,15 @@ function createCallerFactory() {
2311
2312
  const { _def } = router$1;
2312
2313
  return function createCaller(ctxOrCallback, opts) {
2313
2314
  return createRecursiveProxy(async (innerOpts) => {
2314
- const { path: path$2, args } = innerOpts;
2315
- const fullPath = path$2.join(".");
2316
- if (path$2.length === 1 && path$2[0] === "_def") return _def;
2315
+ const { path: path$1, args } = innerOpts;
2316
+ const fullPath = path$1.join(".");
2317
+ if (path$1.length === 1 && path$1[0] === "_def") return _def;
2317
2318
  const procedure = await getProcedureAtPath(router$1, fullPath);
2318
2319
  let ctx = void 0;
2319
2320
  try {
2320
2321
  if (!procedure) throw new TRPCError({
2321
2322
  code: "NOT_FOUND",
2322
- message: `No procedure found on path "${path$2}"`
2323
+ message: `No procedure found on path "${path$1}"`
2323
2324
  });
2324
2325
  ctx = isFunction(ctxOrCallback) ? await Promise.resolve(ctxOrCallback()) : ctxOrCallback;
2325
2326
  return await procedure({
@@ -2588,10 +2589,10 @@ const jsonContentTypeHandler = {
2588
2589
  }
2589
2590
  return acc;
2590
2591
  });
2591
- const calls = await Promise.all(paths.map(async (path$2, index) => {
2592
- const procedure = await getProcedureAtPath(opts.router, path$2);
2592
+ const calls = await Promise.all(paths.map(async (path$1, index) => {
2593
+ const procedure = await getProcedureAtPath(opts.router, path$1);
2593
2594
  return {
2594
- path: path$2,
2595
+ path: path$1,
2595
2596
  procedure,
2596
2597
  getRawInput: async () => {
2597
2598
  let input = (await getInputs.read())[index];
@@ -3505,9 +3506,9 @@ function isPromise(value) {
3505
3506
  return (isObject(value) || isFunction(value)) && typeof (value === null || value === void 0 ? void 0 : value["then"]) === "function" && typeof (value === null || value === void 0 ? void 0 : value["catch"]) === "function";
3506
3507
  }
3507
3508
  var MaxDepthError = class extends Error {
3508
- constructor(path$2) {
3509
- super("Max depth reached at path: " + path$2.join("."));
3510
- this.path = path$2;
3509
+ constructor(path$1) {
3510
+ super("Max depth reached at path: " + path$1.join("."));
3511
+ this.path = path$1;
3511
3512
  }
3512
3513
  };
3513
3514
  function createBatchStreamProducer(_x3) {
@@ -3525,16 +3526,16 @@ function _createBatchStreamProducer() {
3525
3526
  mergedIterables.add(iterable$1);
3526
3527
  return idx;
3527
3528
  }
3528
- function encodePromise(promise, path$2) {
3529
+ function encodePromise(promise, path$1) {
3529
3530
  return registerAsync(/* @__PURE__ */ function() {
3530
3531
  var _ref = (0, import_wrapAsyncGenerator$2.default)(function* (idx) {
3531
- const error = checkMaxDepth(path$2);
3532
+ const error = checkMaxDepth(path$1);
3532
3533
  if (error) {
3533
3534
  promise.catch((cause) => {
3534
3535
  var _opts$onError;
3535
3536
  (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
3536
3537
  error: cause,
3537
- path: path$2
3538
+ path: path$1
3538
3539
  });
3539
3540
  });
3540
3541
  promise = Promise.reject(error);
@@ -3543,20 +3544,20 @@ function _createBatchStreamProducer() {
3543
3544
  yield [
3544
3545
  idx,
3545
3546
  PROMISE_STATUS_FULFILLED,
3546
- encode(yield (0, import_awaitAsyncGenerator$1.default)(promise), path$2)
3547
+ encode(yield (0, import_awaitAsyncGenerator$1.default)(promise), path$1)
3547
3548
  ];
3548
3549
  } catch (cause) {
3549
3550
  var _opts$onError2, _opts$formatError;
3550
3551
  (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, {
3551
3552
  error: cause,
3552
- path: path$2
3553
+ path: path$1
3553
3554
  });
3554
3555
  yield [
3555
3556
  idx,
3556
3557
  PROMISE_STATUS_REJECTED,
3557
3558
  (_opts$formatError = opts.formatError) === null || _opts$formatError === void 0 ? void 0 : _opts$formatError.call(opts, {
3558
3559
  error: cause,
3559
- path: path$2
3560
+ path: path$1
3560
3561
  })
3561
3562
  ];
3562
3563
  }
@@ -3566,12 +3567,12 @@ function _createBatchStreamProducer() {
3566
3567
  };
3567
3568
  }());
3568
3569
  }
3569
- function encodeAsyncIterable(iterable$1, path$2) {
3570
+ function encodeAsyncIterable(iterable$1, path$1) {
3570
3571
  return registerAsync(/* @__PURE__ */ function() {
3571
3572
  var _ref2 = (0, import_wrapAsyncGenerator$2.default)(function* (idx) {
3572
3573
  try {
3573
3574
  var _usingCtx$1 = (0, import_usingCtx$1.default)();
3574
- const error = checkMaxDepth(path$2);
3575
+ const error = checkMaxDepth(path$1);
3575
3576
  if (error) throw error;
3576
3577
  const iterator = _usingCtx$1.a(iteratorResource(iterable$1));
3577
3578
  try {
@@ -3581,28 +3582,28 @@ function _createBatchStreamProducer() {
3581
3582
  yield [
3582
3583
  idx,
3583
3584
  ASYNC_ITERABLE_STATUS_RETURN,
3584
- encode(next.value, path$2)
3585
+ encode(next.value, path$1)
3585
3586
  ];
3586
3587
  break;
3587
3588
  }
3588
3589
  yield [
3589
3590
  idx,
3590
3591
  ASYNC_ITERABLE_STATUS_YIELD,
3591
- encode(next.value, path$2)
3592
+ encode(next.value, path$1)
3592
3593
  ];
3593
3594
  }
3594
3595
  } catch (cause) {
3595
3596
  var _opts$onError3, _opts$formatError2;
3596
3597
  (_opts$onError3 = opts.onError) === null || _opts$onError3 === void 0 || _opts$onError3.call(opts, {
3597
3598
  error: cause,
3598
- path: path$2
3599
+ path: path$1
3599
3600
  });
3600
3601
  yield [
3601
3602
  idx,
3602
3603
  ASYNC_ITERABLE_STATUS_ERROR,
3603
3604
  (_opts$formatError2 = opts.formatError) === null || _opts$formatError2 === void 0 ? void 0 : _opts$formatError2.call(opts, {
3604
3605
  error: cause,
3605
- path: path$2
3606
+ path: path$1
3606
3607
  })
3607
3608
  ];
3608
3609
  }
@@ -3617,27 +3618,27 @@ function _createBatchStreamProducer() {
3617
3618
  };
3618
3619
  }());
3619
3620
  }
3620
- function checkMaxDepth(path$2) {
3621
- if (opts.maxDepth && path$2.length > opts.maxDepth) return new MaxDepthError(path$2);
3621
+ function checkMaxDepth(path$1) {
3622
+ if (opts.maxDepth && path$1.length > opts.maxDepth) return new MaxDepthError(path$1);
3622
3623
  return null;
3623
3624
  }
3624
- function encodeAsync(value, path$2) {
3625
- if (isPromise(value)) return [CHUNK_VALUE_TYPE_PROMISE, encodePromise(value, path$2)];
3625
+ function encodeAsync(value, path$1) {
3626
+ if (isPromise(value)) return [CHUNK_VALUE_TYPE_PROMISE, encodePromise(value, path$1)];
3626
3627
  if (isAsyncIterable(value)) {
3627
- if (opts.maxDepth && path$2.length >= opts.maxDepth) throw new Error("Max depth reached");
3628
- return [CHUNK_VALUE_TYPE_ASYNC_ITERABLE, encodeAsyncIterable(value, path$2)];
3628
+ if (opts.maxDepth && path$1.length >= opts.maxDepth) throw new Error("Max depth reached");
3629
+ return [CHUNK_VALUE_TYPE_ASYNC_ITERABLE, encodeAsyncIterable(value, path$1)];
3629
3630
  }
3630
3631
  return null;
3631
3632
  }
3632
- function encode(value, path$2) {
3633
+ function encode(value, path$1) {
3633
3634
  if (value === void 0) return [[]];
3634
- const reg = encodeAsync(value, path$2);
3635
+ const reg = encodeAsync(value, path$1);
3635
3636
  if (reg) return [[placeholder], [null, ...reg]];
3636
3637
  if (!isPlainObject(value)) return [[value]];
3637
3638
  const newObj = {};
3638
3639
  const asyncValues = [];
3639
3640
  for (const [key, item] of Object.entries(value)) {
3640
- const transformed = encodeAsync(item, [...path$2, key]);
3641
+ const transformed = encodeAsync(item, [...path$1, key]);
3641
3642
  if (!transformed) {
3642
3643
  newObj[key] = item;
3643
3644
  continue;
@@ -4065,11 +4066,11 @@ async function resolveResponse(opts) {
4065
4066
  var _call$procedure$_def$2, _call$procedure3, _opts$onError2;
4066
4067
  const error$1 = getTRPCErrorFromUnknown(errorOpts.error);
4067
4068
  const input = call === null || call === void 0 ? void 0 : call.result();
4068
- const path$2 = call === null || call === void 0 ? void 0 : call.path;
4069
+ const path$1 = call === null || call === void 0 ? void 0 : call.path;
4069
4070
  const type = (_call$procedure$_def$2 = call === null || call === void 0 || (_call$procedure3 = call.procedure) === null || _call$procedure3 === void 0 ? void 0 : _call$procedure3._def.type) !== null && _call$procedure$_def$2 !== void 0 ? _call$procedure$_def$2 : "unknown";
4070
4071
  (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, {
4071
4072
  error: error$1,
4072
- path: path$2,
4073
+ path: path$1,
4073
4074
  input,
4074
4075
  ctx: ctxManager.valueOrUndefined(),
4075
4076
  req: opts.req,
@@ -4080,7 +4081,7 @@ async function resolveResponse(opts) {
4080
4081
  ctx: ctxManager.valueOrUndefined(),
4081
4082
  error: error$1,
4082
4083
  input,
4083
- path: path$2,
4084
+ path: path$1,
4084
4085
  type
4085
4086
  });
4086
4087
  }
@@ -4152,14 +4153,14 @@ async function resolveResponse(opts) {
4152
4153
  const call = info === null || info === void 0 ? void 0 : info.calls[errorOpts.path[0]];
4153
4154
  const error = getTRPCErrorFromUnknown(errorOpts.error);
4154
4155
  const input = call === null || call === void 0 ? void 0 : call.result();
4155
- const path$2 = call === null || call === void 0 ? void 0 : call.path;
4156
+ const path$1 = call === null || call === void 0 ? void 0 : call.path;
4156
4157
  const type = (_call$procedure$_def$3 = call === null || call === void 0 || (_call$procedure4 = call.procedure) === null || _call$procedure4 === void 0 ? void 0 : _call$procedure4._def.type) !== null && _call$procedure$_def$3 !== void 0 ? _call$procedure$_def$3 : "unknown";
4157
4158
  return getErrorShape({
4158
4159
  config,
4159
4160
  ctx: ctxManager.valueOrUndefined(),
4160
4161
  error,
4161
4162
  input,
4162
- path: path$2,
4163
+ path: path$1,
4163
4164
  type
4164
4165
  });
4165
4166
  }
@@ -4240,10 +4241,10 @@ async function resolveResponse(opts) {
4240
4241
  //#endregion
4241
4242
  //#region ../../node_modules/.pnpm/@trpc+server@11.7.2_typescript@5.9.3/node_modules/@trpc/server/dist/adapters/fetch/index.mjs
4242
4243
  var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
4243
- const trimSlashes = (path$2) => {
4244
- path$2 = path$2.startsWith("/") ? path$2.slice(1) : path$2;
4245
- path$2 = path$2.endsWith("/") ? path$2.slice(0, -1) : path$2;
4246
- return path$2;
4244
+ const trimSlashes = (path$1) => {
4245
+ path$1 = path$1.startsWith("/") ? path$1.slice(1) : path$1;
4246
+ path$1 = path$1.endsWith("/") ? path$1.slice(0, -1) : path$1;
4247
+ return path$1;
4247
4248
  };
4248
4249
  async function fetchRequestHandler(opts) {
4249
4250
  const resHeaders = new Headers();
@@ -4256,11 +4257,11 @@ async function fetchRequestHandler(opts) {
4256
4257
  };
4257
4258
  const pathname = trimSlashes(new URL(opts.req.url).pathname);
4258
4259
  const endpoint = trimSlashes(opts.endpoint);
4259
- const path$2 = trimSlashes(pathname.slice(endpoint.length));
4260
+ const path$1 = trimSlashes(pathname.slice(endpoint.length));
4260
4261
  return await resolveResponse((0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
4261
4262
  req: opts.req,
4262
4263
  createContext,
4263
- path: path$2,
4264
+ path: path$1,
4264
4265
  error: null,
4265
4266
  onError(o) {
4266
4267
  var _opts$onError;
@@ -4326,8 +4327,8 @@ function parseTRPCMessage(obj, transformer) {
4326
4327
  };
4327
4328
  assertIsProcedureType(method);
4328
4329
  assertIsObject(params);
4329
- const { input: rawInput, path: path$2, lastEventId } = params;
4330
- assertIsString(path$2);
4330
+ const { input: rawInput, path: path$1, lastEventId } = params;
4331
+ assertIsString(path$1);
4331
4332
  if (lastEventId !== void 0) assertIsString(lastEventId);
4332
4333
  return {
4333
4334
  id,
@@ -4335,7 +4336,7 @@ function parseTRPCMessage(obj, transformer) {
4335
4336
  method,
4336
4337
  params: {
4337
4338
  input: transformer.input.deserialize(rawInput),
4338
- path: path$2,
4339
+ path: path$1,
4339
4340
  lastEventId
4340
4341
  }
4341
4342
  };
@@ -4792,7 +4793,7 @@ function getWSConnectionHandler(opts) {
4792
4793
  (_clientSubscriptions$ = clientSubscriptions.get(id)) === null || _clientSubscriptions$ === void 0 || _clientSubscriptions$.abort();
4793
4794
  return;
4794
4795
  }
4795
- const { path: path$2, lastEventId } = msg.params;
4796
+ const { path: path$1, lastEventId } = msg.params;
4796
4797
  let { input } = msg.params;
4797
4798
  const type = msg.method;
4798
4799
  if (lastEventId !== void 0) if (isObject(input)) input = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, input), {}, { lastEventId });
@@ -4806,7 +4807,7 @@ function getWSConnectionHandler(opts) {
4806
4807
  const abortController$1 = new AbortController();
4807
4808
  const result = await callProcedure({
4808
4809
  router: router$1,
4809
- path: path$2,
4810
+ path: path$1,
4810
4811
  getRawInput: async () => input,
4811
4812
  ctx,
4812
4813
  type,
@@ -4829,7 +4830,7 @@ function getWSConnectionHandler(opts) {
4829
4830
  return;
4830
4831
  }
4831
4832
  if (!isIterableResult) throw new TRPCError({
4832
- message: `Subscription ${path$2} did not return an observable or a AsyncGenerator`,
4833
+ message: `Subscription ${path$1} did not return an observable or a AsyncGenerator`,
4833
4834
  code: "INTERNAL_SERVER_ERROR"
4834
4835
  });
4835
4836
  /* istanbul ignore next -- @preserve */
@@ -4861,7 +4862,7 @@ function getWSConnectionHandler(opts) {
4861
4862
  const error = getTRPCErrorFromUnknown(next);
4862
4863
  (_opts$onError3 = opts.onError) === null || _opts$onError3 === void 0 || _opts$onError3.call(opts, {
4863
4864
  error,
4864
- path: path$2,
4865
+ path: path$1,
4865
4866
  type,
4866
4867
  ctx,
4867
4868
  req,
@@ -4874,7 +4875,7 @@ function getWSConnectionHandler(opts) {
4874
4875
  config: router$1._def._config,
4875
4876
  error,
4876
4877
  type,
4877
- path: path$2,
4878
+ path: path$1,
4878
4879
  input,
4879
4880
  ctx
4880
4881
  })
@@ -4918,7 +4919,7 @@ function getWSConnectionHandler(opts) {
4918
4919
  const error = getTRPCErrorFromUnknown(cause);
4919
4920
  (_opts$onError4 = opts.onError) === null || _opts$onError4 === void 0 || _opts$onError4.call(opts, {
4920
4921
  error,
4921
- path: path$2,
4922
+ path: path$1,
4922
4923
  type,
4923
4924
  ctx,
4924
4925
  req,
@@ -4931,7 +4932,7 @@ function getWSConnectionHandler(opts) {
4931
4932
  config: router$1._def._config,
4932
4933
  error,
4933
4934
  type,
4934
- path: path$2,
4935
+ path: path$1,
4935
4936
  input,
4936
4937
  ctx
4937
4938
  })
@@ -4949,7 +4950,7 @@ function getWSConnectionHandler(opts) {
4949
4950
  const error = getTRPCErrorFromUnknown(cause);
4950
4951
  (_opts$onError5 = opts.onError) === null || _opts$onError5 === void 0 || _opts$onError5.call(opts, {
4951
4952
  error,
4952
- path: path$2,
4953
+ path: path$1,
4953
4954
  type,
4954
4955
  ctx,
4955
4956
  req,
@@ -4962,7 +4963,7 @@ function getWSConnectionHandler(opts) {
4962
4963
  config: router$1._def._config,
4963
4964
  error,
4964
4965
  type,
4965
- path: path$2,
4966
+ path: path$1,
4966
4967
  input,
4967
4968
  ctx
4968
4969
  })
@@ -9150,11 +9151,11 @@ var ReactiveContext = class {
9150
9151
  * 获取路径的真实路径(解析符号链接)
9151
9152
  * 在 macOS 上,/var 是 /private/var 的符号链接
9152
9153
  */
9153
- function getRealPath$1(path$2) {
9154
+ function getRealPath$1(path$1) {
9154
9155
  try {
9155
- return realpathSync(resolve$1(path$2));
9156
+ return realpathSync(resolve$1(path$1));
9156
9157
  } catch {
9157
- return resolve$1(path$2);
9158
+ return resolve$1(path$1);
9158
9159
  }
9159
9160
  }
9160
9161
  /** 默认防抖时间 (ms) */
@@ -9306,9 +9307,9 @@ var ProjectWatcher = class {
9306
9307
  * @param options 订阅选项
9307
9308
  * @returns 取消订阅函数
9308
9309
  */
9309
- subscribeSync(path$2, callback, options = {}) {
9310
+ subscribeSync(path$1, callback, options = {}) {
9310
9311
  if (!this.initialized) throw new Error("ProjectWatcher not initialized. Call init() first.");
9311
- const normalizedPath = getRealPath$1(path$2);
9312
+ const normalizedPath = getRealPath$1(path$1);
9312
9313
  const id = Symbol();
9313
9314
  this.pathSubscriptions.set(id, {
9314
9315
  path: normalizedPath,
@@ -9327,9 +9328,9 @@ var ProjectWatcher = class {
9327
9328
  * @param options 订阅选项
9328
9329
  * @returns 取消订阅函数
9329
9330
  */
9330
- async subscribe(path$2, callback, options = {}) {
9331
+ async subscribe(path$1, callback, options = {}) {
9331
9332
  await this.init();
9332
- return this.subscribeSync(path$2, callback, options);
9333
+ return this.subscribeSync(path$1, callback, options);
9333
9334
  }
9334
9335
  /**
9335
9336
  * 获取当前订阅数量(用于调试)
@@ -9480,11 +9481,11 @@ function getProjectWatcher(projectDir, options) {
9480
9481
  /**
9481
9482
  * 获取路径的真实路径(解析符号链接)
9482
9483
  */
9483
- function getRealPath(path$2) {
9484
+ function getRealPath(path$1) {
9484
9485
  try {
9485
- return realpathSync(resolve$1(path$2));
9486
+ return realpathSync(resolve$1(path$1));
9486
9487
  } catch {
9487
- return resolve$1(path$2);
9488
+ return resolve$1(path$1);
9488
9489
  }
9489
9490
  }
9490
9491
  /**
@@ -9530,9 +9531,9 @@ async function initWatcherPool(projectDir) {
9530
9531
  * @param options 监听选项
9531
9532
  * @returns 释放函数,调用后取消订阅
9532
9533
  */
9533
- function acquireWatcher(path$2, onChange, options = {}) {
9534
+ function acquireWatcher(path$1, onChange, options = {}) {
9534
9535
  if (!globalProjectWatcher || !globalProjectWatcher.isInitialized) return () => {};
9535
- const normalizedPath = getRealPath(path$2);
9536
+ const normalizedPath = getRealPath(path$1);
9536
9537
  const debounceMs = options.debounceMs ?? DEBOUNCE_MS;
9537
9538
  const isRecursive = options.recursive ?? false;
9538
9539
  const cacheKey$1 = `${normalizedPath}:${isRecursive}`;
@@ -9627,6 +9628,15 @@ async function reactiveReadFile(filepath) {
9627
9628
  return state.get();
9628
9629
  }
9629
9630
  /**
9631
+ * 主动更新响应式文件缓存(用于写入后立即推送订阅)
9632
+ *
9633
+ * 仅当该文件已有缓存状态时生效;不会创建新的监听器。
9634
+ */
9635
+ function updateReactiveFileCache(filepath, content) {
9636
+ const key = `file:${resolve$1(filepath)}`;
9637
+ stateCache$1.get(key)?.set(content);
9638
+ }
9639
+ /**
9630
9640
  * 响应式读取目录内容
9631
9641
  *
9632
9642
  * 特性:
@@ -9679,8 +9689,8 @@ async function reactiveReadDir(dirpath, options = {}) {
9679
9689
  * @param path 路径
9680
9690
  * @returns 是否存在
9681
9691
  */
9682
- async function reactiveExists(path$2) {
9683
- const normalizedPath = resolve$1(path$2);
9692
+ async function reactiveExists(path$1) {
9693
+ const normalizedPath = resolve$1(path$1);
9684
9694
  const key = `exists:${normalizedPath}`;
9685
9695
  const getValue = async () => {
9686
9696
  try {
@@ -9711,8 +9721,8 @@ async function reactiveExists(path$2) {
9711
9721
  * @param path 路径
9712
9722
  * @returns stat 信息,不存在时返回 null
9713
9723
  */
9714
- async function reactiveStat(path$2) {
9715
- const normalizedPath = resolve$1(path$2);
9724
+ async function reactiveStat(path$1) {
9725
+ const normalizedPath = resolve$1(path$1);
9716
9726
  const key = `stat:${normalizedPath}`;
9717
9727
  const getValue = async () => {
9718
9728
  try {
@@ -10438,8 +10448,8 @@ function getErrorMap() {
10438
10448
  //#endregion
10439
10449
  //#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
10440
10450
  const makeIssue = (params) => {
10441
- const { data, path: path$2, errorMaps, issueData } = params;
10442
- const fullPath = [...path$2, ...issueData.path || []];
10451
+ const { data, path: path$1, errorMaps, issueData } = params;
10452
+ const fullPath = [...path$1, ...issueData.path || []];
10443
10453
  const fullIssue = {
10444
10454
  ...issueData,
10445
10455
  path: fullPath
@@ -10551,11 +10561,11 @@ var errorUtil;
10551
10561
  //#endregion
10552
10562
  //#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
10553
10563
  var ParseInputLazyPath = class {
10554
- constructor(parent, value, path$2, key) {
10564
+ constructor(parent, value, path$1, key) {
10555
10565
  this._cachedPath = [];
10556
10566
  this.parent = parent;
10557
10567
  this.data = value;
10558
- this._path = path$2;
10568
+ this._path = path$1;
10559
10569
  this._key = key;
10560
10570
  }
10561
10571
  get path() {
@@ -13925,20 +13935,124 @@ var OpenSpecWatcher = class extends EventEmitter {
13925
13935
  //#endregion
13926
13936
  //#region ../core/src/config.ts
13927
13937
  const execAsync = promisify(exec);
13928
- /** 默认的 fallback CLI 命令(数组形式) */
13929
- const FALLBACK_CLI_COMMAND = ["npx", "@fission-ai/openspec"];
13930
- /** 全局 openspec 命令(数组形式) */
13931
- const GLOBAL_CLI_COMMAND = ["openspec"];
13932
- /** 缓存检测到的 CLI 命令 */
13933
- let detectedCliCommand = null;
13938
+ const CLI_PROBE_TIMEOUT_MS = 2e4;
13939
+ const THEME_VALUES = [
13940
+ "light",
13941
+ "dark",
13942
+ "system"
13943
+ ];
13944
+ const CURSOR_STYLE_VALUES = [
13945
+ "block",
13946
+ "underline",
13947
+ "bar"
13948
+ ];
13949
+ const BASE_PACKAGE_MANAGER_RUNNERS = [
13950
+ {
13951
+ id: "npx",
13952
+ source: "npx",
13953
+ commandParts: [
13954
+ "npx",
13955
+ "-y",
13956
+ "@fission-ai/openspec"
13957
+ ]
13958
+ },
13959
+ {
13960
+ id: "bunx",
13961
+ source: "bunx",
13962
+ commandParts: ["bunx", "@fission-ai/openspec"]
13963
+ },
13964
+ {
13965
+ id: "deno",
13966
+ source: "deno",
13967
+ commandParts: [
13968
+ "deno",
13969
+ "run",
13970
+ "-A",
13971
+ "npm:@fission-ai/openspec"
13972
+ ]
13973
+ },
13974
+ {
13975
+ id: "pnpm",
13976
+ source: "pnpm",
13977
+ commandParts: [
13978
+ "pnpm",
13979
+ "dlx",
13980
+ "@fission-ai/openspec"
13981
+ ]
13982
+ },
13983
+ {
13984
+ id: "yarn",
13985
+ source: "yarn",
13986
+ commandParts: [
13987
+ "yarn",
13988
+ "dlx",
13989
+ "@fission-ai/openspec"
13990
+ ]
13991
+ }
13992
+ ];
13993
+ function tokenizeCliCommand(input) {
13994
+ const tokens = [];
13995
+ let current = "";
13996
+ let quote = null;
13997
+ let tokenStarted = false;
13998
+ for (let index = 0; index < input.length; index += 1) {
13999
+ const char = input[index];
14000
+ if (quote) {
14001
+ if (char === quote) {
14002
+ quote = null;
14003
+ tokenStarted = true;
14004
+ continue;
14005
+ }
14006
+ if (char === "\\") {
14007
+ const next = input[index + 1];
14008
+ if (next && (next === quote || next === "\\")) {
14009
+ current += next;
14010
+ tokenStarted = true;
14011
+ index += 1;
14012
+ continue;
14013
+ }
14014
+ }
14015
+ current += char;
14016
+ tokenStarted = true;
14017
+ continue;
14018
+ }
14019
+ if (char === "\"" || char === "'") {
14020
+ quote = char;
14021
+ tokenStarted = true;
14022
+ continue;
14023
+ }
14024
+ if (char === "\\") {
14025
+ const next = input[index + 1];
14026
+ if (next && /[\s"'\\]/.test(next)) {
14027
+ current += next;
14028
+ tokenStarted = true;
14029
+ index += 1;
14030
+ continue;
14031
+ }
14032
+ current += char;
14033
+ tokenStarted = true;
14034
+ continue;
14035
+ }
14036
+ if (/\s/.test(char)) {
14037
+ if (tokenStarted) {
14038
+ tokens.push(current);
14039
+ current = "";
14040
+ tokenStarted = false;
14041
+ }
14042
+ continue;
14043
+ }
14044
+ current += char;
14045
+ tokenStarted = true;
14046
+ }
14047
+ if (tokenStarted) tokens.push(current);
14048
+ return tokens;
14049
+ }
13934
14050
  /**
13935
14051
  * 解析 CLI 命令字符串为数组
13936
14052
  *
13937
14053
  * 支持两种格式:
13938
14054
  * 1. JSON 数组:以 `[` 开头,如 `["npx", "@fission-ai/openspec"]`
13939
- * 2. 简单字符串:用空格分割,如 `npx @fission-ai/openspec`
13940
- *
13941
- * 注意:简单字符串解析不支持带引号的参数,如需复杂命令请使用 JSON 数组格式
14055
+ * 2. shell-like 字符串:支持引号与基础转义
13942
14056
  */
13943
14057
  function parseCliCommand(command) {
13944
14058
  const trimmed = command.trim();
@@ -13949,7 +14063,144 @@ function parseCliCommand(command) {
13949
14063
  } catch (err) {
13950
14064
  throw new Error(`Failed to parse CLI command as JSON array: ${err instanceof Error ? err.message : err}`);
13951
14065
  }
13952
- return trimmed.split(/\s+/).filter(Boolean);
14066
+ const tokens = tokenizeCliCommand(trimmed);
14067
+ if (tokens.length !== 1) return tokens;
14068
+ const firstChar = trimmed[0];
14069
+ const lastChar = trimmed[trimmed.length - 1];
14070
+ if (firstChar !== "\"" && firstChar !== "'" || firstChar !== lastChar) return tokens;
14071
+ const inner = trimmed.slice(1, -1).trim();
14072
+ if (!inner) return tokens;
14073
+ const innerTokens = tokenizeCliCommand(inner.replace(/\\(["'])/g, "$1"));
14074
+ if (innerTokens.length > 1 && innerTokens.slice(1).some((token) => token.startsWith("-"))) return innerTokens;
14075
+ return tokens;
14076
+ }
14077
+ function commandToString(commandParts) {
14078
+ const formatToken = (token) => {
14079
+ if (!token) return "\"\"";
14080
+ if (!/[\s"'\\]/.test(token)) return token;
14081
+ return JSON.stringify(token);
14082
+ };
14083
+ return commandParts.map(formatToken).join(" ").trim();
14084
+ }
14085
+ function getRunnerPriorityFromUserAgent(userAgent) {
14086
+ if (!userAgent) return null;
14087
+ if (userAgent.startsWith("bun")) return "bunx";
14088
+ if (userAgent.startsWith("npm")) return "npx";
14089
+ if (userAgent.startsWith("deno")) return "deno";
14090
+ if (userAgent.startsWith("pnpm")) return "pnpm";
14091
+ if (userAgent.startsWith("yarn")) return "yarn";
14092
+ return null;
14093
+ }
14094
+ function buildCliRunnerCandidates(options) {
14095
+ const candidates = [];
14096
+ const configuredCommandParts = options.configuredCommandParts?.filter(Boolean) ?? [];
14097
+ if (configuredCommandParts.length > 0) candidates.push({
14098
+ id: "configured",
14099
+ source: "config.cli.command",
14100
+ commandParts: configuredCommandParts
14101
+ });
14102
+ candidates.push({
14103
+ id: "openspec",
14104
+ source: "openspec",
14105
+ commandParts: ["openspec"]
14106
+ });
14107
+ const packageRunners = [...BASE_PACKAGE_MANAGER_RUNNERS];
14108
+ const preferred = getRunnerPriorityFromUserAgent(options.userAgent);
14109
+ if (preferred) {
14110
+ const index = packageRunners.findIndex((item) => item.id === preferred);
14111
+ if (index > 0) {
14112
+ const [runner] = packageRunners.splice(index, 1);
14113
+ packageRunners.unshift(runner);
14114
+ }
14115
+ }
14116
+ return [...candidates, ...packageRunners];
14117
+ }
14118
+ function createCleanCliEnv(baseEnv = process.env) {
14119
+ const env = { ...baseEnv };
14120
+ for (const key of Object.keys(env)) if (key.startsWith("npm_config_") || key.startsWith("npm_package_") || key === "npm_execpath" || key === "npm_lifecycle_event" || key === "npm_lifecycle_script") delete env[key];
14121
+ return env;
14122
+ }
14123
+ async function probeCliRunner(candidate, cwd, env) {
14124
+ const [cmd, ...cmdArgs] = candidate.commandParts;
14125
+ return new Promise((resolve$2) => {
14126
+ let stdout = "";
14127
+ let stderr = "";
14128
+ let timedOut = false;
14129
+ const timer = setTimeout(() => {
14130
+ timedOut = true;
14131
+ child.kill();
14132
+ }, CLI_PROBE_TIMEOUT_MS);
14133
+ const child = spawn(cmd, [...cmdArgs, "--version"], {
14134
+ cwd,
14135
+ shell: false,
14136
+ env
14137
+ });
14138
+ child.stdout?.on("data", (data) => {
14139
+ stdout += data.toString();
14140
+ });
14141
+ child.stderr?.on("data", (data) => {
14142
+ stderr += data.toString();
14143
+ });
14144
+ child.on("error", (err) => {
14145
+ clearTimeout(timer);
14146
+ const code = err.code;
14147
+ const suffix = code ? ` (${code})` : "";
14148
+ resolve$2({
14149
+ source: candidate.source,
14150
+ command: commandToString(candidate.commandParts),
14151
+ success: false,
14152
+ error: `${err.message}${suffix}`,
14153
+ exitCode: null
14154
+ });
14155
+ });
14156
+ child.on("close", (exitCode) => {
14157
+ clearTimeout(timer);
14158
+ if (timedOut) {
14159
+ resolve$2({
14160
+ source: candidate.source,
14161
+ command: commandToString(candidate.commandParts),
14162
+ success: false,
14163
+ error: "CLI probe timed out",
14164
+ exitCode
14165
+ });
14166
+ return;
14167
+ }
14168
+ if (exitCode === 0) {
14169
+ const version = stdout.trim().split("\n")[0] || void 0;
14170
+ resolve$2({
14171
+ source: candidate.source,
14172
+ command: commandToString(candidate.commandParts),
14173
+ success: true,
14174
+ version,
14175
+ exitCode
14176
+ });
14177
+ return;
14178
+ }
14179
+ resolve$2({
14180
+ source: candidate.source,
14181
+ command: commandToString(candidate.commandParts),
14182
+ success: false,
14183
+ error: stderr.trim() || `Exit code ${exitCode ?? "null"}`,
14184
+ exitCode
14185
+ });
14186
+ });
14187
+ });
14188
+ }
14189
+ async function resolveCliRunner(candidates, cwd, env) {
14190
+ const attempts = [];
14191
+ for (const candidate of candidates) {
14192
+ const attempt = await probeCliRunner(candidate, cwd, env);
14193
+ attempts.push(attempt);
14194
+ if (attempt.success) return {
14195
+ source: attempt.source,
14196
+ command: attempt.command,
14197
+ commandParts: candidate.commandParts,
14198
+ version: attempt.version,
14199
+ attempts
14200
+ };
14201
+ }
14202
+ const details = attempts.map((attempt) => `- ${attempt.command}: ${attempt.error ?? "failed"}`).join("\n");
14203
+ throw new Error(`No available OpenSpec CLI runner.\n${details}`);
13953
14204
  }
13954
14205
  /**
13955
14206
  * 比较两个语义化版本号
@@ -13976,7 +14227,7 @@ function compareVersions(a, b) {
13976
14227
  */
13977
14228
  async function fetchLatestVersion() {
13978
14229
  try {
13979
- const { stdout } = await execAsync("npx @fission-ai/openspec --version", { timeout: 6e4 });
14230
+ const { stdout } = await execAsync("npx -y @fission-ai/openspec --version", { timeout: 6e4 });
13980
14231
  return stdout.trim();
13981
14232
  } catch {
13982
14233
  return;
@@ -14006,7 +14257,6 @@ async function sniffGlobalCli() {
14006
14257
  };
14007
14258
  }
14008
14259
  const version = localResult.stdout.trim();
14009
- detectedCliCommand = GLOBAL_CLI_COMMAND;
14010
14260
  return {
14011
14261
  hasGlobal: true,
14012
14262
  version,
@@ -14015,53 +14265,44 @@ async function sniffGlobalCli() {
14015
14265
  };
14016
14266
  }
14017
14267
  /**
14018
- * 检测全局安装的 openspec 命令
14019
- * 优先使用全局命令,fallback 到 npx
14020
- *
14021
- * @returns CLI 命令数组
14022
- */
14023
- async function detectCliCommand() {
14024
- if (detectedCliCommand !== null) return detectedCliCommand;
14025
- try {
14026
- await execAsync(`${process.platform === "win32" ? "where" : "which"} openspec`);
14027
- detectedCliCommand = GLOBAL_CLI_COMMAND;
14028
- return detectedCliCommand;
14029
- } catch {
14030
- detectedCliCommand = FALLBACK_CLI_COMMAND;
14031
- return detectedCliCommand;
14032
- }
14033
- }
14034
- /**
14035
14268
  * 获取默认 CLI 命令(异步,带检测)
14036
14269
  *
14037
14270
  * @returns CLI 命令数组,如 `['openspec']` 或 `['npx', '@fission-ai/openspec']`
14038
14271
  */
14039
14272
  async function getDefaultCliCommand() {
14040
- return detectCliCommand();
14273
+ return (await resolveCliRunner(buildCliRunnerCandidates({ userAgent: process.env.npm_config_user_agent }).filter((candidate) => candidate.id !== "configured"), process.cwd(), createCleanCliEnv())).commandParts;
14041
14274
  }
14042
14275
  /**
14043
14276
  * 获取默认 CLI 命令的字符串形式(用于 UI 显示)
14044
14277
  */
14045
14278
  async function getDefaultCliCommandString() {
14046
- return (await detectCliCommand()).join(" ");
14279
+ return commandToString(await getDefaultCliCommand());
14047
14280
  }
14281
+ const TerminalConfigSchema = objectType({
14282
+ fontSize: numberType().min(8).max(32).default(13),
14283
+ fontFamily: stringType().default(""),
14284
+ cursorBlink: booleanType().default(true),
14285
+ cursorStyle: enumType(CURSOR_STYLE_VALUES).default("block"),
14286
+ scrollback: numberType().min(0).max(1e5).default(1e3)
14287
+ });
14048
14288
  /**
14049
14289
  * OpenSpecUI 配置 Schema
14050
14290
  *
14051
14291
  * 存储在 openspec/.openspecui.json 中,利用文件监听实现响应式更新
14052
14292
  */
14053
14293
  const OpenSpecUIConfigSchema = objectType({
14054
- cli: objectType({ command: stringType().optional() }).default({}),
14055
- ui: objectType({ theme: enumType([
14056
- "light",
14057
- "dark",
14058
- "system"
14059
- ]).default("system") }).default({})
14294
+ cli: objectType({
14295
+ command: stringType().optional(),
14296
+ args: arrayType(stringType()).optional()
14297
+ }).default({}),
14298
+ theme: enumType(THEME_VALUES).default("system"),
14299
+ terminal: TerminalConfigSchema.default(TerminalConfigSchema.parse({}))
14060
14300
  });
14061
14301
  /** 默认配置(静态,用于测试和类型) */
14062
14302
  const DEFAULT_CONFIG = {
14063
14303
  cli: {},
14064
- ui: { theme: "system" }
14304
+ theme: "system",
14305
+ terminal: TerminalConfigSchema.parse({})
14065
14306
  };
14066
14307
  /**
14067
14308
  * 配置管理器
@@ -14071,7 +14312,11 @@ const DEFAULT_CONFIG = {
14071
14312
  */
14072
14313
  var ConfigManager = class {
14073
14314
  configPath;
14315
+ projectDir;
14316
+ resolvedRunner = null;
14317
+ resolvingRunnerPromise = null;
14074
14318
  constructor(projectDir) {
14319
+ this.projectDir = projectDir;
14075
14320
  this.configPath = join(projectDir, "openspec", ".openspecui.json");
14076
14321
  }
14077
14322
  /**
@@ -14101,43 +14346,140 @@ var ConfigManager = class {
14101
14346
  */
14102
14347
  async writeConfig(config) {
14103
14348
  const current = await this.readConfig();
14349
+ const nextCli = { ...current.cli };
14350
+ if (config.cli && Object.prototype.hasOwnProperty.call(config.cli, "command")) {
14351
+ const trimmed = config.cli.command?.trim();
14352
+ if (trimmed) nextCli.command = trimmed;
14353
+ else {
14354
+ delete nextCli.command;
14355
+ delete nextCli.args;
14356
+ }
14357
+ }
14358
+ if (config.cli && Object.prototype.hasOwnProperty.call(config.cli, "args")) {
14359
+ const args = (config.cli.args ?? []).map((arg) => arg.trim()).filter(Boolean);
14360
+ if (args.length > 0) nextCli.args = args;
14361
+ else delete nextCli.args;
14362
+ }
14363
+ if (!nextCli.command) delete nextCli.args;
14104
14364
  const merged = {
14105
14365
  ...current,
14106
- ...config,
14107
- cli: {
14108
- ...current.cli,
14109
- ...config.cli
14110
- },
14111
- ui: {
14112
- ...current.ui,
14113
- ...config.ui
14366
+ cli: nextCli,
14367
+ theme: config.theme ?? current.theme,
14368
+ terminal: {
14369
+ ...current.terminal,
14370
+ ...config.terminal
14114
14371
  }
14115
14372
  };
14116
- await writeFile(this.configPath, JSON.stringify(merged, null, 2), "utf-8");
14373
+ const serialized = JSON.stringify(merged, null, 2);
14374
+ await writeFile(this.configPath, serialized, "utf-8");
14375
+ updateReactiveFileCache(this.configPath, serialized);
14376
+ this.invalidateResolvedCliRunner();
14377
+ }
14378
+ /**
14379
+ * 解析并缓存可用 CLI runner。
14380
+ */
14381
+ async resolveCliRunner() {
14382
+ if (this.resolvedRunner) return this.resolvedRunner;
14383
+ if (this.resolvingRunnerPromise) return this.resolvingRunnerPromise;
14384
+ this.resolvingRunnerPromise = this.resolveCliRunnerUncached().then((runner) => {
14385
+ this.resolvedRunner = runner;
14386
+ return runner;
14387
+ }).finally(() => {
14388
+ this.resolvingRunnerPromise = null;
14389
+ });
14390
+ return this.resolvingRunnerPromise;
14391
+ }
14392
+ async resolveCliRunnerUncached() {
14393
+ const config = await this.readConfig();
14394
+ const configuredCommandParts = this.getConfiguredCommandParts(config.cli);
14395
+ const hasConfiguredCommand = configuredCommandParts.length > 0;
14396
+ const resolved = await resolveCliRunner(hasConfiguredCommand ? [{
14397
+ id: "configured",
14398
+ source: "config.cli.command",
14399
+ commandParts: configuredCommandParts
14400
+ }] : buildCliRunnerCandidates({
14401
+ configuredCommandParts,
14402
+ userAgent: process.env.npm_config_user_agent
14403
+ }), this.projectDir, createCleanCliEnv());
14404
+ if (!hasConfiguredCommand) {
14405
+ const [resolvedCommand, ...resolvedArgs] = resolved.commandParts;
14406
+ const currentCommand = config.cli.command?.trim();
14407
+ const currentArgs = config.cli.args ?? [];
14408
+ if (currentCommand !== resolvedCommand || currentArgs.length !== resolvedArgs.length || currentArgs.some((arg, index) => arg !== resolvedArgs[index])) await this.writeConfig({ cli: {
14409
+ command: resolvedCommand,
14410
+ args: resolvedArgs
14411
+ } });
14412
+ }
14413
+ return resolved;
14117
14414
  }
14118
14415
  /**
14119
14416
  * 获取 CLI 命令(数组形式)
14120
- *
14121
- * 优先级:配置文件 > 全局 openspec 命令 > npx fallback
14122
- *
14123
- * @returns CLI 命令数组,如 `['openspec']` 或 `['npx', '@fission-ai/openspec']`
14124
14417
  */
14125
14418
  async getCliCommand() {
14126
- const config = await this.readConfig();
14127
- if (config.cli.command) return parseCliCommand(config.cli.command);
14128
- return getDefaultCliCommand();
14419
+ return (await this.resolveCliRunner()).commandParts;
14129
14420
  }
14130
14421
  /**
14131
14422
  * 获取 CLI 命令的字符串形式(用于 UI 显示)
14132
14423
  */
14133
14424
  async getCliCommandString() {
14134
- return (await this.getCliCommand()).join(" ");
14425
+ return (await this.resolveCliRunner()).command;
14426
+ }
14427
+ /**
14428
+ * 获取 CLI 解析结果(用于诊断)
14429
+ */
14430
+ async getResolvedCliRunner() {
14431
+ return this.resolveCliRunner();
14432
+ }
14433
+ /**
14434
+ * 清理 CLI 解析缓存(用于 ENOENT 自愈)
14435
+ */
14436
+ invalidateResolvedCliRunner() {
14437
+ this.resolvedRunner = null;
14438
+ this.resolvingRunnerPromise = null;
14135
14439
  }
14136
14440
  /**
14137
14441
  * 设置 CLI 命令
14138
14442
  */
14139
14443
  async setCliCommand(command) {
14140
- await this.writeConfig({ cli: { command } });
14444
+ const trimmed = command.trim();
14445
+ if (!trimmed) {
14446
+ await this.writeConfig({ cli: {
14447
+ command: null,
14448
+ args: null
14449
+ } });
14450
+ return;
14451
+ }
14452
+ const commandParts = parseCliCommand(trimmed);
14453
+ if (commandParts.length === 0) {
14454
+ await this.writeConfig({ cli: {
14455
+ command: null,
14456
+ args: null
14457
+ } });
14458
+ return;
14459
+ }
14460
+ const [resolvedCommand, ...resolvedArgs] = commandParts;
14461
+ await this.writeConfig({ cli: {
14462
+ command: resolvedCommand,
14463
+ args: resolvedArgs
14464
+ } });
14465
+ }
14466
+ getConfiguredCommandParts(cli) {
14467
+ const command = cli.command?.trim();
14468
+ if (!command) return [];
14469
+ if (Array.isArray(cli.args) && cli.args.length > 0) return [command, ...cli.args];
14470
+ return parseCliCommand(command);
14471
+ }
14472
+ /**
14473
+ * 设置主题
14474
+ */
14475
+ async setTheme(theme) {
14476
+ await this.writeConfig({ theme });
14477
+ }
14478
+ /**
14479
+ * 设置终端配置(部分更新)
14480
+ */
14481
+ async setTerminalConfig(terminal) {
14482
+ await this.writeConfig({ terminal });
14141
14483
  }
14142
14484
  };
14143
14485
 
@@ -14146,50 +14488,24 @@ var ConfigManager = class {
14146
14488
  /**
14147
14489
  * CLI 执行器
14148
14490
  *
14149
- * 负责调用外部 openspec CLI 命令。
14150
- * 命令前缀从 ConfigManager 获取,支持:
14151
- * - ['npx', '@fission-ai/openspec'] (默认)
14152
- * - ['openspec'] (全局安装)
14153
- * - 自定义数组或字符串
14154
- *
14155
- * 注意:所有命令都使用 shell: false 执行,避免 shell 注入风险
14491
+ * 负责调用外部 openspec CLI 命令,统一通过 ConfigManager 的 runner 解析结果执行。
14492
+ * 所有命令都使用 shell: false,避免 shell 注入风险。
14156
14493
  */
14157
14494
  var CliExecutor = class {
14158
14495
  constructor(configManager, projectDir) {
14159
14496
  this.configManager = configManager;
14160
14497
  this.projectDir = projectDir;
14161
14498
  }
14162
- /**
14163
- * 创建干净的环境变量,移除 pnpm 特有的配置
14164
- * 避免 pnpm 环境变量污染 npx/npm 执行
14165
- */
14166
- getCleanEnv() {
14167
- const env = { ...process.env };
14168
- for (const key of Object.keys(env)) if (key.startsWith("npm_config_") || key.startsWith("npm_package_") || key === "npm_execpath" || key === "npm_lifecycle_event" || key === "npm_lifecycle_script") delete env[key];
14169
- return env;
14170
- }
14171
- /**
14172
- * 构建完整命令数组
14173
- *
14174
- * @param args CLI 参数,如 ['init'] 或 ['archive', 'change-id']
14175
- * @returns [command, ...commandArgs, ...args]
14176
- */
14177
14499
  async buildCommandArray(args) {
14178
14500
  return [...await this.configManager.getCliCommand(), ...args];
14179
14501
  }
14180
- /**
14181
- * 执行 CLI 命令
14182
- *
14183
- * @param args CLI 参数,如 ['init'] 或 ['archive', 'change-id']
14184
- * @returns 执行结果
14185
- */
14186
- async execute(args) {
14187
- const [cmd, ...cmdArgs] = await this.buildCommandArray(args);
14502
+ runCommandOnce(fullCommand) {
14503
+ const [cmd, ...cmdArgs] = fullCommand;
14188
14504
  return new Promise((resolve$2) => {
14189
14505
  const child = spawn(cmd, cmdArgs, {
14190
14506
  cwd: this.projectDir,
14191
14507
  shell: false,
14192
- env: this.getCleanEnv()
14508
+ env: createCleanCliEnv()
14193
14509
  });
14194
14510
  let stdout = "";
14195
14511
  let stderr = "";
@@ -14208,19 +14524,50 @@ var CliExecutor = class {
14208
14524
  });
14209
14525
  });
14210
14526
  child.on("error", (err) => {
14527
+ const errorCode = err.code;
14528
+ const errorMessage = err.message + (errorCode ? ` (${errorCode})` : "");
14211
14529
  resolve$2({
14212
14530
  success: false,
14213
14531
  stdout,
14214
- stderr: stderr + "\n" + err.message,
14215
- exitCode: null
14532
+ stderr: stderr ? `${stderr}\n${errorMessage}` : errorMessage,
14533
+ exitCode: null,
14534
+ errorCode
14216
14535
  });
14217
14536
  });
14218
14537
  });
14219
14538
  }
14539
+ async executeInternal(args, allowRetry) {
14540
+ let fullCommand;
14541
+ try {
14542
+ fullCommand = await this.buildCommandArray(args);
14543
+ } catch (err) {
14544
+ return {
14545
+ success: false,
14546
+ stdout: "",
14547
+ stderr: err instanceof Error ? err.message : String(err),
14548
+ exitCode: null
14549
+ };
14550
+ }
14551
+ const result = await this.runCommandOnce(fullCommand);
14552
+ if (allowRetry && result.errorCode === "ENOENT") {
14553
+ this.configManager.invalidateResolvedCliRunner();
14554
+ return this.executeInternal(args, false);
14555
+ }
14556
+ return {
14557
+ success: result.success,
14558
+ stdout: result.stdout,
14559
+ stderr: result.stderr,
14560
+ exitCode: result.exitCode
14561
+ };
14562
+ }
14563
+ /**
14564
+ * 执行 CLI 命令
14565
+ */
14566
+ async execute(args) {
14567
+ return this.executeInternal(args, true);
14568
+ }
14220
14569
  /**
14221
14570
  * 执行 openspec init(非交互式)
14222
- *
14223
- * @param tools 工具列表,如 ['claude', 'cursor'] 或 'all' 或 'none'
14224
14571
  */
14225
14572
  async init(tools = "all") {
14226
14573
  const toolsArg = Array.isArray(tools) ? tools.join(",") : tools;
@@ -14232,9 +14579,6 @@ var CliExecutor = class {
14232
14579
  }
14233
14580
  /**
14234
14581
  * 执行 openspec archive <changeId>(非交互式)
14235
- *
14236
- * @param changeId 要归档的 change ID
14237
- * @param options 选项
14238
14582
  */
14239
14583
  async archive(changeId, options = {}) {
14240
14584
  const args = [
@@ -14291,75 +14635,108 @@ var CliExecutor = class {
14291
14635
  }
14292
14636
  /**
14293
14637
  * 检查 CLI 是否可用
14294
- * @param timeout 超时时间(毫秒),默认 10 秒
14295
14638
  */
14296
14639
  async checkAvailability(timeout = 1e4) {
14297
14640
  try {
14298
- const result = await Promise.race([this.execute(["--version"]), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("CLI check timed out")), timeout))]);
14299
- if (result.success) return {
14641
+ const resolved = await Promise.race([this.configManager.getResolvedCliRunner(), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("CLI runner resolve timed out")), timeout))]);
14642
+ const versionResult = await Promise.race([this.runCommandOnce([...resolved.commandParts, "--version"]), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("CLI check timed out")), timeout))]);
14643
+ if (versionResult.success) return {
14300
14644
  available: true,
14301
- version: result.stdout.trim()
14645
+ version: versionResult.stdout.trim() || resolved.version,
14646
+ effectiveCommand: resolved.command,
14647
+ tried: resolved.attempts.map((attempt) => attempt.command)
14302
14648
  };
14303
14649
  return {
14304
14650
  available: false,
14305
- error: result.stderr || "Unknown error"
14651
+ error: versionResult.stderr || "Unknown error",
14652
+ effectiveCommand: resolved.command,
14653
+ tried: resolved.attempts.map((attempt) => attempt.command)
14306
14654
  };
14307
14655
  } catch (err) {
14308
14656
  return {
14309
14657
  available: false,
14310
- error: err instanceof Error ? err.message : "Unknown error"
14658
+ error: err instanceof Error ? err.message : String(err)
14311
14659
  };
14312
14660
  }
14313
14661
  }
14314
14662
  /**
14315
14663
  * 流式执行 CLI 命令
14316
- *
14317
- * @param args CLI 参数
14318
- * @param onEvent 事件回调
14319
- * @returns 取消函数
14320
14664
  */
14321
14665
  async executeStream(args, onEvent) {
14322
- const fullCommand = await this.buildCommandArray(args);
14323
- const [cmd, ...cmdArgs] = fullCommand;
14324
- onEvent({
14325
- type: "command",
14326
- data: fullCommand.join(" ")
14327
- });
14328
- const child = spawn(cmd, cmdArgs, {
14329
- cwd: this.projectDir,
14330
- shell: false,
14331
- env: this.getCleanEnv()
14332
- });
14333
- child.stdout?.on("data", (data) => {
14666
+ let cancelled = false;
14667
+ let activeChild = null;
14668
+ const start = async (allowRetry) => {
14669
+ if (cancelled) return;
14670
+ let fullCommand;
14671
+ try {
14672
+ fullCommand = await this.buildCommandArray(args);
14673
+ } catch (err) {
14674
+ onEvent({
14675
+ type: "stderr",
14676
+ data: err instanceof Error ? err.message : String(err)
14677
+ });
14678
+ onEvent({
14679
+ type: "exit",
14680
+ exitCode: null
14681
+ });
14682
+ return;
14683
+ }
14334
14684
  onEvent({
14335
- type: "stdout",
14336
- data: data.toString()
14685
+ type: "command",
14686
+ data: fullCommand.join(" ")
14337
14687
  });
14338
- });
14339
- child.stderr?.on("data", (data) => {
14340
- onEvent({
14341
- type: "stderr",
14342
- data: data.toString()
14688
+ const [cmd, ...cmdArgs] = fullCommand;
14689
+ const child = spawn(cmd, cmdArgs, {
14690
+ cwd: this.projectDir,
14691
+ shell: false,
14692
+ env: createCleanCliEnv()
14343
14693
  });
14344
- });
14345
- child.on("close", (exitCode) => {
14346
- onEvent({
14347
- type: "exit",
14348
- exitCode
14694
+ activeChild = child;
14695
+ child.stdout?.on("data", (data) => {
14696
+ onEvent({
14697
+ type: "stdout",
14698
+ data: data.toString()
14699
+ });
14349
14700
  });
14350
- });
14351
- child.on("error", (err) => {
14352
- onEvent({
14353
- type: "stderr",
14354
- data: err.message
14701
+ child.stderr?.on("data", (data) => {
14702
+ onEvent({
14703
+ type: "stderr",
14704
+ data: data.toString()
14705
+ });
14355
14706
  });
14356
- onEvent({
14357
- type: "exit",
14358
- exitCode: null
14707
+ child.on("close", (exitCode) => {
14708
+ if (activeChild !== child) return;
14709
+ activeChild = null;
14710
+ onEvent({
14711
+ type: "exit",
14712
+ exitCode
14713
+ });
14359
14714
  });
14360
- });
14715
+ child.on("error", (err) => {
14716
+ if (activeChild !== child) return;
14717
+ activeChild = null;
14718
+ const code = err.code;
14719
+ const message = err.message + (code ? ` (${code})` : "");
14720
+ if (allowRetry && code === "ENOENT" && !cancelled) {
14721
+ this.configManager.invalidateResolvedCliRunner();
14722
+ start(false);
14723
+ return;
14724
+ }
14725
+ onEvent({
14726
+ type: "stderr",
14727
+ data: message
14728
+ });
14729
+ onEvent({
14730
+ type: "exit",
14731
+ exitCode: null
14732
+ });
14733
+ });
14734
+ };
14735
+ await start(true);
14361
14736
  return () => {
14362
- child.kill();
14737
+ cancelled = true;
14738
+ activeChild?.kill();
14739
+ activeChild = null;
14363
14740
  };
14364
14741
  }
14365
14742
  /**
@@ -14388,13 +14765,6 @@ var CliExecutor = class {
14388
14765
  }
14389
14766
  /**
14390
14767
  * 流式执行任意命令(数组形式)
14391
- *
14392
- * 用于执行不需要 openspec CLI 前缀的命令,如 npm install。
14393
- * 使用 shell: false 避免 shell 注入风险。
14394
- *
14395
- * @param command 命令数组,如 ['npm', 'install', '-g', '@fission-ai/openspec']
14396
- * @param onEvent 事件回调
14397
- * @returns 取消函数
14398
14768
  */
14399
14769
  executeCommandStream(command, onEvent) {
14400
14770
  const [cmd, ...cmdArgs] = command;
@@ -14405,7 +14775,7 @@ var CliExecutor = class {
14405
14775
  const child = spawn(cmd, cmdArgs, {
14406
14776
  cwd: this.projectDir,
14407
14777
  shell: false,
14408
- env: this.getCleanEnv()
14778
+ env: createCleanCliEnv()
14409
14779
  });
14410
14780
  child.stdout?.on("data", (data) => {
14411
14781
  onEvent({
@@ -14426,9 +14796,10 @@ var CliExecutor = class {
14426
14796
  });
14427
14797
  });
14428
14798
  child.on("error", (err) => {
14799
+ const code = err.code;
14429
14800
  onEvent({
14430
14801
  type: "stderr",
14431
- data: err.message
14802
+ data: err.message + (code ? ` (${code})` : "")
14432
14803
  });
14433
14804
  onEvent({
14434
14805
  type: "exit",
@@ -14922,17 +15293,17 @@ var require_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/yam
14922
15293
  visit$5.SKIP = SKIP$1;
14923
15294
  /** Remove the current node */
14924
15295
  visit$5.REMOVE = REMOVE$1;
14925
- function visit_(key, node, visitor, path$2) {
14926
- const ctrl = callVisitor(key, node, visitor, path$2);
15296
+ function visit_(key, node, visitor, path$1) {
15297
+ const ctrl = callVisitor(key, node, visitor, path$1);
14927
15298
  if (identity$32.isNode(ctrl) || identity$32.isPair(ctrl)) {
14928
- replaceNode(key, path$2, ctrl);
14929
- return visit_(key, ctrl, visitor, path$2);
15299
+ replaceNode(key, path$1, ctrl);
15300
+ return visit_(key, ctrl, visitor, path$1);
14930
15301
  }
14931
15302
  if (typeof ctrl !== "symbol") {
14932
15303
  if (identity$32.isCollection(node)) {
14933
- path$2 = Object.freeze(path$2.concat(node));
15304
+ path$1 = Object.freeze(path$1.concat(node));
14934
15305
  for (let i = 0; i < node.items.length; ++i) {
14935
- const ci = visit_(i, node.items[i], visitor, path$2);
15306
+ const ci = visit_(i, node.items[i], visitor, path$1);
14936
15307
  if (typeof ci === "number") i = ci - 1;
14937
15308
  else if (ci === BREAK$1) return BREAK$1;
14938
15309
  else if (ci === REMOVE$1) {
@@ -14941,11 +15312,11 @@ var require_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/yam
14941
15312
  }
14942
15313
  }
14943
15314
  } else if (identity$32.isPair(node)) {
14944
- path$2 = Object.freeze(path$2.concat(node));
14945
- const ck = visit_("key", node.key, visitor, path$2);
15315
+ path$1 = Object.freeze(path$1.concat(node));
15316
+ const ck = visit_("key", node.key, visitor, path$1);
14946
15317
  if (ck === BREAK$1) return BREAK$1;
14947
15318
  else if (ck === REMOVE$1) node.key = null;
14948
- const cv = visit_("value", node.value, visitor, path$2);
15319
+ const cv = visit_("value", node.value, visitor, path$1);
14949
15320
  if (cv === BREAK$1) return BREAK$1;
14950
15321
  else if (cv === REMOVE$1) node.value = null;
14951
15322
  }
@@ -14995,17 +15366,17 @@ var require_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/yam
14995
15366
  visitAsync.SKIP = SKIP$1;
14996
15367
  /** Remove the current node */
14997
15368
  visitAsync.REMOVE = REMOVE$1;
14998
- async function visitAsync_(key, node, visitor, path$2) {
14999
- const ctrl = await callVisitor(key, node, visitor, path$2);
15369
+ async function visitAsync_(key, node, visitor, path$1) {
15370
+ const ctrl = await callVisitor(key, node, visitor, path$1);
15000
15371
  if (identity$32.isNode(ctrl) || identity$32.isPair(ctrl)) {
15001
- replaceNode(key, path$2, ctrl);
15002
- return visitAsync_(key, ctrl, visitor, path$2);
15372
+ replaceNode(key, path$1, ctrl);
15373
+ return visitAsync_(key, ctrl, visitor, path$1);
15003
15374
  }
15004
15375
  if (typeof ctrl !== "symbol") {
15005
15376
  if (identity$32.isCollection(node)) {
15006
- path$2 = Object.freeze(path$2.concat(node));
15377
+ path$1 = Object.freeze(path$1.concat(node));
15007
15378
  for (let i = 0; i < node.items.length; ++i) {
15008
- const ci = await visitAsync_(i, node.items[i], visitor, path$2);
15379
+ const ci = await visitAsync_(i, node.items[i], visitor, path$1);
15009
15380
  if (typeof ci === "number") i = ci - 1;
15010
15381
  else if (ci === BREAK$1) return BREAK$1;
15011
15382
  else if (ci === REMOVE$1) {
@@ -15014,11 +15385,11 @@ var require_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/yam
15014
15385
  }
15015
15386
  }
15016
15387
  } else if (identity$32.isPair(node)) {
15017
- path$2 = Object.freeze(path$2.concat(node));
15018
- const ck = await visitAsync_("key", node.key, visitor, path$2);
15388
+ path$1 = Object.freeze(path$1.concat(node));
15389
+ const ck = await visitAsync_("key", node.key, visitor, path$1);
15019
15390
  if (ck === BREAK$1) return BREAK$1;
15020
15391
  else if (ck === REMOVE$1) node.key = null;
15021
- const cv = await visitAsync_("value", node.value, visitor, path$2);
15392
+ const cv = await visitAsync_("value", node.value, visitor, path$1);
15022
15393
  if (cv === BREAK$1) return BREAK$1;
15023
15394
  else if (cv === REMOVE$1) node.value = null;
15024
15395
  }
@@ -15041,16 +15412,16 @@ var require_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/yam
15041
15412
  }, visitor);
15042
15413
  return visitor;
15043
15414
  }
15044
- function callVisitor(key, node, visitor, path$2) {
15045
- if (typeof visitor === "function") return visitor(key, node, path$2);
15046
- if (identity$32.isMap(node)) return visitor.Map?.(key, node, path$2);
15047
- if (identity$32.isSeq(node)) return visitor.Seq?.(key, node, path$2);
15048
- if (identity$32.isPair(node)) return visitor.Pair?.(key, node, path$2);
15049
- if (identity$32.isScalar(node)) return visitor.Scalar?.(key, node, path$2);
15050
- if (identity$32.isAlias(node)) return visitor.Alias?.(key, node, path$2);
15415
+ function callVisitor(key, node, visitor, path$1) {
15416
+ if (typeof visitor === "function") return visitor(key, node, path$1);
15417
+ if (identity$32.isMap(node)) return visitor.Map?.(key, node, path$1);
15418
+ if (identity$32.isSeq(node)) return visitor.Seq?.(key, node, path$1);
15419
+ if (identity$32.isPair(node)) return visitor.Pair?.(key, node, path$1);
15420
+ if (identity$32.isScalar(node)) return visitor.Scalar?.(key, node, path$1);
15421
+ if (identity$32.isAlias(node)) return visitor.Alias?.(key, node, path$1);
15051
15422
  }
15052
- function replaceNode(key, path$2, node) {
15053
- const parent = path$2[path$2.length - 1];
15423
+ function replaceNode(key, path$1, node) {
15424
+ const parent = path$1[path$1.length - 1];
15054
15425
  if (identity$32.isCollection(parent)) parent.items[key] = node;
15055
15426
  else if (identity$32.isPair(parent)) if (key === "key") parent.key = node;
15056
15427
  else parent.value = node;
@@ -15599,10 +15970,10 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15599
15970
  var createNode$3 = require_createNode();
15600
15971
  var identity$24 = require_identity();
15601
15972
  var Node = require_Node();
15602
- function collectionFromPath(schema$6, path$2, value) {
15973
+ function collectionFromPath(schema$6, path$1, value) {
15603
15974
  let v = value;
15604
- for (let i = path$2.length - 1; i >= 0; --i) {
15605
- const k = path$2[i];
15975
+ for (let i = path$1.length - 1; i >= 0; --i) {
15976
+ const k = path$1[i];
15606
15977
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
15607
15978
  const a = [];
15608
15979
  a[k] = v;
@@ -15619,7 +15990,7 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15619
15990
  sourceObjects: /* @__PURE__ */ new Map()
15620
15991
  });
15621
15992
  }
15622
- const isEmptyPath = (path$2) => path$2 == null || typeof path$2 === "object" && !!path$2[Symbol.iterator]().next().done;
15993
+ const isEmptyPath = (path$1) => path$1 == null || typeof path$1 === "object" && !!path$1[Symbol.iterator]().next().done;
15623
15994
  var Collection$3 = class extends Node.NodeBase {
15624
15995
  constructor(type, schema$6) {
15625
15996
  super(type);
@@ -15647,10 +16018,10 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15647
16018
  * be a Pair instance or a `{ key, value }` object, which may not have a key
15648
16019
  * that already exists in the map.
15649
16020
  */
15650
- addIn(path$2, value) {
15651
- if (isEmptyPath(path$2)) this.add(value);
16021
+ addIn(path$1, value) {
16022
+ if (isEmptyPath(path$1)) this.add(value);
15652
16023
  else {
15653
- const [key, ...rest] = path$2;
16024
+ const [key, ...rest] = path$1;
15654
16025
  const node = this.get(key, true);
15655
16026
  if (identity$24.isCollection(node)) node.addIn(rest, value);
15656
16027
  else if (node === void 0 && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));
@@ -15661,8 +16032,8 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15661
16032
  * Removes a value from the collection.
15662
16033
  * @returns `true` if the item was found and removed.
15663
16034
  */
15664
- deleteIn(path$2) {
15665
- const [key, ...rest] = path$2;
16035
+ deleteIn(path$1) {
16036
+ const [key, ...rest] = path$1;
15666
16037
  if (rest.length === 0) return this.delete(key);
15667
16038
  const node = this.get(key, true);
15668
16039
  if (identity$24.isCollection(node)) return node.deleteIn(rest);
@@ -15673,8 +16044,8 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15673
16044
  * scalar values from their surrounding node; to disable set `keepScalar` to
15674
16045
  * `true` (collections are always returned intact).
15675
16046
  */
15676
- getIn(path$2, keepScalar) {
15677
- const [key, ...rest] = path$2;
16047
+ getIn(path$1, keepScalar) {
16048
+ const [key, ...rest] = path$1;
15678
16049
  const node = this.get(key, true);
15679
16050
  if (rest.length === 0) return !keepScalar && identity$24.isScalar(node) ? node.value : node;
15680
16051
  else return identity$24.isCollection(node) ? node.getIn(rest, keepScalar) : void 0;
@@ -15689,8 +16060,8 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15689
16060
  /**
15690
16061
  * Checks if the collection includes a value with the key `key`.
15691
16062
  */
15692
- hasIn(path$2) {
15693
- const [key, ...rest] = path$2;
16063
+ hasIn(path$1) {
16064
+ const [key, ...rest] = path$1;
15694
16065
  if (rest.length === 0) return this.has(key);
15695
16066
  const node = this.get(key, true);
15696
16067
  return identity$24.isCollection(node) ? node.hasIn(rest) : false;
@@ -15699,8 +16070,8 @@ var require_Collection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
15699
16070
  * Sets a value in this collection. For `!!set`, `value` needs to be a
15700
16071
  * boolean to add/remove the item from the set.
15701
16072
  */
15702
- setIn(path$2, value) {
15703
- const [key, ...rest] = path$2;
16073
+ setIn(path$1, value) {
16074
+ const [key, ...rest] = path$1;
15704
16075
  if (rest.length === 0) this.set(key, value);
15705
16076
  else {
15706
16077
  const node = this.get(key, true);
@@ -17816,8 +18187,8 @@ var require_Document = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
17816
18187
  if (assertCollection(this.contents)) this.contents.add(value);
17817
18188
  }
17818
18189
  /** Adds a value to the document. */
17819
- addIn(path$2, value) {
17820
- if (assertCollection(this.contents)) this.contents.addIn(path$2, value);
18190
+ addIn(path$1, value) {
18191
+ if (assertCollection(this.contents)) this.contents.addIn(path$1, value);
17821
18192
  }
17822
18193
  /**
17823
18194
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -17885,13 +18256,13 @@ var require_Document = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
17885
18256
  * Removes a value from the document.
17886
18257
  * @returns `true` if the item was found and removed.
17887
18258
  */
17888
- deleteIn(path$2) {
17889
- if (Collection.isEmptyPath(path$2)) {
18259
+ deleteIn(path$1) {
18260
+ if (Collection.isEmptyPath(path$1)) {
17890
18261
  if (this.contents == null) return false;
17891
18262
  this.contents = null;
17892
18263
  return true;
17893
18264
  }
17894
- return assertCollection(this.contents) ? this.contents.deleteIn(path$2) : false;
18265
+ return assertCollection(this.contents) ? this.contents.deleteIn(path$1) : false;
17895
18266
  }
17896
18267
  /**
17897
18268
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -17906,9 +18277,9 @@ var require_Document = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
17906
18277
  * scalar values from their surrounding node; to disable set `keepScalar` to
17907
18278
  * `true` (collections are always returned intact).
17908
18279
  */
17909
- getIn(path$2, keepScalar) {
17910
- if (Collection.isEmptyPath(path$2)) return !keepScalar && identity$8.isScalar(this.contents) ? this.contents.value : this.contents;
17911
- return identity$8.isCollection(this.contents) ? this.contents.getIn(path$2, keepScalar) : void 0;
18280
+ getIn(path$1, keepScalar) {
18281
+ if (Collection.isEmptyPath(path$1)) return !keepScalar && identity$8.isScalar(this.contents) ? this.contents.value : this.contents;
18282
+ return identity$8.isCollection(this.contents) ? this.contents.getIn(path$1, keepScalar) : void 0;
17912
18283
  }
17913
18284
  /**
17914
18285
  * Checks if the document includes a value with the key `key`.
@@ -17919,9 +18290,9 @@ var require_Document = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
17919
18290
  /**
17920
18291
  * Checks if the document includes a value at `path`.
17921
18292
  */
17922
- hasIn(path$2) {
17923
- if (Collection.isEmptyPath(path$2)) return this.contents !== void 0;
17924
- return identity$8.isCollection(this.contents) ? this.contents.hasIn(path$2) : false;
18293
+ hasIn(path$1) {
18294
+ if (Collection.isEmptyPath(path$1)) return this.contents !== void 0;
18295
+ return identity$8.isCollection(this.contents) ? this.contents.hasIn(path$1) : false;
17925
18296
  }
17926
18297
  /**
17927
18298
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -17935,10 +18306,10 @@ var require_Document = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
17935
18306
  * Sets a value in this document. For `!!set`, `value` needs to be a
17936
18307
  * boolean to add/remove the item from the set.
17937
18308
  */
17938
- setIn(path$2, value) {
17939
- if (Collection.isEmptyPath(path$2)) this.contents = value;
17940
- else if (this.contents == null) this.contents = Collection.collectionFromPath(this.schema, Array.from(path$2), value);
17941
- else if (assertCollection(this.contents)) this.contents.setIn(path$2, value);
18309
+ setIn(path$1, value) {
18310
+ if (Collection.isEmptyPath(path$1)) this.contents = value;
18311
+ else if (this.contents == null) this.contents = Collection.collectionFromPath(this.schema, Array.from(path$1), value);
18312
+ else if (assertCollection(this.contents)) this.contents.setIn(path$1, value);
17942
18313
  }
17943
18314
  /**
17944
18315
  * Change the YAML version and schema used by the document.
@@ -19786,9 +20157,9 @@ var require_cst_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
19786
20157
  /** Remove the current item */
19787
20158
  visit$1.REMOVE = REMOVE;
19788
20159
  /** Find the item at `path` from `cst` as the root */
19789
- visit$1.itemAtPath = (cst$3, path$2) => {
20160
+ visit$1.itemAtPath = (cst$3, path$1) => {
19790
20161
  let item = cst$3;
19791
- for (const [field, index] of path$2) {
20162
+ for (const [field, index] of path$1) {
19792
20163
  const tok = item?.[field];
19793
20164
  if (tok && "items" in tok) item = tok.items[index];
19794
20165
  else return void 0;
@@ -19800,21 +20171,21 @@ var require_cst_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
19800
20171
  *
19801
20172
  * Throws an error if the collection is not found, which should never happen if the item itself exists.
19802
20173
  */
19803
- visit$1.parentCollection = (cst$3, path$2) => {
19804
- const parent = visit$1.itemAtPath(cst$3, path$2.slice(0, -1));
19805
- const field = path$2[path$2.length - 1][0];
20174
+ visit$1.parentCollection = (cst$3, path$1) => {
20175
+ const parent = visit$1.itemAtPath(cst$3, path$1.slice(0, -1));
20176
+ const field = path$1[path$1.length - 1][0];
19806
20177
  const coll = parent?.[field];
19807
20178
  if (coll && "items" in coll) return coll;
19808
20179
  throw new Error("Parent collection not found");
19809
20180
  };
19810
- function _visit(path$2, item, visitor) {
19811
- let ctrl = visitor(item, path$2);
20181
+ function _visit(path$1, item, visitor) {
20182
+ let ctrl = visitor(item, path$1);
19812
20183
  if (typeof ctrl === "symbol") return ctrl;
19813
20184
  for (const field of ["key", "value"]) {
19814
20185
  const token = item[field];
19815
20186
  if (token && "items" in token) {
19816
20187
  for (let i = 0; i < token.items.length; ++i) {
19817
- const ci = _visit(Object.freeze(path$2.concat([[field, i]])), token.items[i], visitor);
20188
+ const ci = _visit(Object.freeze(path$1.concat([[field, i]])), token.items[i], visitor);
19818
20189
  if (typeof ci === "number") i = ci - 1;
19819
20190
  else if (ci === BREAK) return BREAK;
19820
20191
  else if (ci === REMOVE) {
@@ -19822,10 +20193,10 @@ var require_cst_visit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
19822
20193
  i -= 1;
19823
20194
  }
19824
20195
  }
19825
- if (typeof ctrl === "function" && field === "key") ctrl = ctrl(item, path$2);
20196
+ if (typeof ctrl === "function" && field === "key") ctrl = ctrl(item, path$1);
19826
20197
  }
19827
20198
  }
19828
- return typeof ctrl === "function" ? ctrl(item, path$2) : ctrl;
20199
+ return typeof ctrl === "function" ? ctrl(item, path$1) : ctrl;
19829
20200
  }
19830
20201
  exports.visit = visit$1;
19831
20202
  }) });
@@ -21049,18 +21420,18 @@ var require_parser = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ya
21049
21420
  case "scalar":
21050
21421
  case "single-quoted-scalar":
21051
21422
  case "double-quoted-scalar": {
21052
- const fs$3 = this.flowScalar(this.type);
21423
+ const fs$2 = this.flowScalar(this.type);
21053
21424
  if (atNextItem || it.value) {
21054
21425
  map$6.items.push({
21055
21426
  start,
21056
- key: fs$3,
21427
+ key: fs$2,
21057
21428
  sep: []
21058
21429
  });
21059
21430
  this.onKeyLine = true;
21060
- } else if (it.sep) this.stack.push(fs$3);
21431
+ } else if (it.sep) this.stack.push(fs$2);
21061
21432
  else {
21062
21433
  Object.assign(it, {
21063
- key: fs$3,
21434
+ key: fs$2,
21064
21435
  sep: []
21065
21436
  });
21066
21437
  this.onKeyLine = true;
@@ -21177,15 +21548,15 @@ var require_parser = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ya
21177
21548
  case "scalar":
21178
21549
  case "single-quoted-scalar":
21179
21550
  case "double-quoted-scalar": {
21180
- const fs$3 = this.flowScalar(this.type);
21551
+ const fs$2 = this.flowScalar(this.type);
21181
21552
  if (!it || it.value) fc.items.push({
21182
21553
  start: [],
21183
- key: fs$3,
21554
+ key: fs$2,
21184
21555
  sep: []
21185
21556
  });
21186
- else if (it.sep) this.stack.push(fs$3);
21557
+ else if (it.sep) this.stack.push(fs$2);
21187
21558
  else Object.assign(it, {
21188
- key: fs$3,
21559
+ key: fs$2,
21189
21560
  sep: []
21190
21561
  });
21191
21562
  return;
@@ -21476,7 +21847,7 @@ var require_dist = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/yaml
21476
21847
 
21477
21848
  //#endregion
21478
21849
  //#region ../core/src/opsx-kernel.ts
21479
- var import_dist$2 = require_dist();
21850
+ var import_dist$1 = require_dist();
21480
21851
  function parseCliJson$1(raw$1, schema$6, label) {
21481
21852
  const trimmed = raw$1.trim();
21482
21853
  if (!trimmed) throw new Error(`${label} returned empty output`);
@@ -22026,7 +22397,7 @@ const SchemaYamlSchema$1 = objectType({
22026
22397
  }).optional()
22027
22398
  });
22028
22399
  function parseSchemaYamlInline(content) {
22029
- const raw$1 = (0, import_dist$2.parse)(content);
22400
+ const raw$1 = (0, import_dist$1.parse)(content);
22030
22401
  const parsed = SchemaYamlSchema$1.safeParse(raw$1);
22031
22402
  if (!parsed.success) throw new Error(`Invalid schema.yaml: ${parsed.error.message}`);
22032
22403
  const { artifacts, apply, name, description, version } = parsed.data;
@@ -22158,92 +22529,34 @@ const PtyServerMessageSchema = discriminatedUnionType("type", [
22158
22529
  ]);
22159
22530
 
22160
22531
  //#endregion
22161
- //#region ../server/src/reactive-subscription.ts
22532
+ //#region ../server/src/cli-stream-observable.ts
22162
22533
  /**
22163
- * 创建响应式订阅
22164
- *
22165
- * 自动追踪 task 中的文件依赖,当依赖变更时自动重新执行并推送新数据。
22534
+ * 创建安全的 CLI 流式 observable
22166
22535
  *
22167
- * @param task 要执行的异步任务,内部的文件读取会被自动追踪
22168
- * @returns tRPC observable
22536
+ * 解决的问题:
22537
+ * 1. 防止在 emit.complete() 之后调用 emit.next()(会导致 "Controller is already closed" 错误)
22538
+ * 2. 统一的错误处理,防止未捕获的异常导致服务器崩溃
22539
+ * 3. 确保取消时正确清理资源
22169
22540
  *
22170
- * @example
22171
- * ```typescript
22172
- * // 在 router 中使用
22173
- * subscribe: publicProcedure.subscription(({ ctx }) => {
22174
- * return createReactiveSubscription(() => ctx.adapter.listSpecsWithMeta())
22175
- * })
22176
- * ```
22541
+ * @param startStream 启动流的函数,接收 onEvent 回调,返回取消函数的 Promise
22177
22542
  */
22178
- function createReactiveSubscription(task) {
22543
+ function createCliStreamObservable(startStream) {
22179
22544
  return observable((emit) => {
22180
- const context = new ReactiveContext();
22181
- const controller = new AbortController();
22182
- (async () => {
22545
+ let cancel;
22546
+ let completed = false;
22547
+ /**
22548
+ * 安全的事件处理器
22549
+ * - 检查是否已完成,防止重复调用
22550
+ * - 使用 try-catch 防止异常导致服务器崩溃
22551
+ */
22552
+ const safeEventHandler = (event) => {
22553
+ if (completed) return;
22183
22554
  try {
22184
- for await (const data of context.stream(task, controller.signal)) emit.next(data);
22185
- } catch (err) {
22186
- if (!controller.signal.aborted) emit.error(err);
22187
- }
22188
- })();
22189
- return () => {
22190
- controller.abort();
22191
- };
22192
- });
22193
- }
22194
- /**
22195
- * 创建带输入参数的响应式订阅
22196
- *
22197
- * @param task 接收输入参数的异步任务
22198
- * @returns 返回一个函数,接收输入参数并返回 tRPC observable
22199
- *
22200
- * @example
22201
- * ```typescript
22202
- * // 在 router 中使用
22203
- * subscribeOne: publicProcedure
22204
- * .input(z.object({ id: z.string() }))
22205
- * .subscription(({ ctx, input }) => {
22206
- * return createReactiveSubscriptionWithInput(
22207
- * (id: string) => ctx.adapter.readSpec(id)
22208
- * )(input.id)
22209
- * })
22210
- * ```
22211
- */
22212
- function createReactiveSubscriptionWithInput(task) {
22213
- return (input) => {
22214
- return createReactiveSubscription(() => task(input));
22215
- };
22216
- }
22217
-
22218
- //#endregion
22219
- //#region ../server/src/cli-stream-observable.ts
22220
- /**
22221
- * 创建安全的 CLI 流式 observable
22222
- *
22223
- * 解决的问题:
22224
- * 1. 防止在 emit.complete() 之后调用 emit.next()(会导致 "Controller is already closed" 错误)
22225
- * 2. 统一的错误处理,防止未捕获的异常导致服务器崩溃
22226
- * 3. 确保取消时正确清理资源
22227
- *
22228
- * @param startStream 启动流的函数,接收 onEvent 回调,返回取消函数的 Promise
22229
- */
22230
- function createCliStreamObservable(startStream) {
22231
- return observable((emit) => {
22232
- let cancel;
22233
- let completed = false;
22234
- /**
22235
- * 安全的事件处理器
22236
- * - 检查是否已完成,防止重复调用
22237
- * - 使用 try-catch 防止异常导致服务器崩溃
22238
- */
22239
- const safeEventHandler = (event) => {
22240
- if (completed) return;
22241
- try {
22242
- emit.next(event);
22243
- if (event.type === "exit") {
22244
- completed = true;
22245
- emit.complete();
22246
- }
22555
+ emit.next(event);
22556
+ if (event.type === "exit") {
22557
+ completed = true;
22558
+ emit.complete();
22559
+ }
22247
22560
  } catch (err) {
22248
22561
  console.error("[CLI Stream] Error emitting event:", err);
22249
22562
  if (!completed) {
@@ -22274,7 +22587,7 @@ function createCliStreamObservable(startStream) {
22274
22587
 
22275
22588
  //#endregion
22276
22589
  //#region ../server/src/opsx-schema.ts
22277
- var import_dist$1 = require_dist();
22590
+ var import_dist = require_dist();
22278
22591
  const SchemaYamlArtifactSchema = objectType({
22279
22592
  id: stringType(),
22280
22593
  generates: stringType(),
@@ -22295,7 +22608,7 @@ const SchemaYamlSchema = objectType({
22295
22608
  }).optional()
22296
22609
  });
22297
22610
  function parseSchemaYaml(content) {
22298
- const raw$1 = (0, import_dist$1.parse)(content);
22611
+ const raw$1 = (0, import_dist.parse)(content);
22299
22612
  const parsed = SchemaYamlSchema.safeParse(raw$1);
22300
22613
  if (!parsed.success) throw new Error(`Invalid schema.yaml: ${parsed.error.message}`);
22301
22614
  const { artifacts, apply, name, description, version } = parsed.data;
@@ -22377,9 +22690,66 @@ var ReactiveKV = class {
22377
22690
  /** Singleton instance shared across the server lifetime */
22378
22691
  const reactiveKV = new ReactiveKV();
22379
22692
 
22693
+ //#endregion
22694
+ //#region ../server/src/reactive-subscription.ts
22695
+ /**
22696
+ * 创建响应式订阅
22697
+ *
22698
+ * 自动追踪 task 中的文件依赖,当依赖变更时自动重新执行并推送新数据。
22699
+ *
22700
+ * @param task 要执行的异步任务,内部的文件读取会被自动追踪
22701
+ * @returns tRPC observable
22702
+ *
22703
+ * @example
22704
+ * ```typescript
22705
+ * // 在 router 中使用
22706
+ * subscribe: publicProcedure.subscription(({ ctx }) => {
22707
+ * return createReactiveSubscription(() => ctx.adapter.listSpecsWithMeta())
22708
+ * })
22709
+ * ```
22710
+ */
22711
+ function createReactiveSubscription(task) {
22712
+ return observable((emit) => {
22713
+ const context = new ReactiveContext();
22714
+ const controller = new AbortController();
22715
+ (async () => {
22716
+ try {
22717
+ for await (const data of context.stream(task, controller.signal)) emit.next(data);
22718
+ } catch (err) {
22719
+ if (!controller.signal.aborted) emit.error(err);
22720
+ }
22721
+ })();
22722
+ return () => {
22723
+ controller.abort();
22724
+ };
22725
+ });
22726
+ }
22727
+ /**
22728
+ * 创建带输入参数的响应式订阅
22729
+ *
22730
+ * @param task 接收输入参数的异步任务
22731
+ * @returns 返回一个函数,接收输入参数并返回 tRPC observable
22732
+ *
22733
+ * @example
22734
+ * ```typescript
22735
+ * // 在 router 中使用
22736
+ * subscribeOne: publicProcedure
22737
+ * .input(z.object({ id: z.string() }))
22738
+ * .subscription(({ ctx, input }) => {
22739
+ * return createReactiveSubscriptionWithInput(
22740
+ * (id: string) => ctx.adapter.readSpec(id)
22741
+ * )(input.id)
22742
+ * })
22743
+ * ```
22744
+ */
22745
+ function createReactiveSubscriptionWithInput(task) {
22746
+ return (input) => {
22747
+ return createReactiveSubscription(() => task(input));
22748
+ };
22749
+ }
22750
+
22380
22751
  //#endregion
22381
22752
  //#region ../server/src/router.ts
22382
- var import_dist = /* @__PURE__ */ __toESM$1(require_dist(), 1);
22383
22753
  const t = initTRPC.context().create();
22384
22754
  const router = t.router;
22385
22755
  const publicProcedure = t.procedure;
@@ -22757,20 +23127,40 @@ const configRouter = router({
22757
23127
  return getDefaultCliCommandString();
22758
23128
  }),
22759
23129
  update: publicProcedure.input(objectType({
22760
- cli: objectType({ command: stringType() }).optional(),
22761
- ui: objectType({ theme: enumType([
23130
+ cli: objectType({
23131
+ command: stringType().nullable().optional(),
23132
+ args: arrayType(stringType()).nullable().optional()
23133
+ }).optional(),
23134
+ theme: enumType([
22762
23135
  "light",
22763
23136
  "dark",
22764
23137
  "system"
22765
- ]) }).optional()
23138
+ ]).optional(),
23139
+ terminal: objectType({
23140
+ fontSize: numberType().min(8).max(32).optional(),
23141
+ fontFamily: stringType().optional(),
23142
+ cursorBlink: booleanType().optional(),
23143
+ cursorStyle: enumType([
23144
+ "block",
23145
+ "underline",
23146
+ "bar"
23147
+ ]).optional(),
23148
+ scrollback: numberType().min(0).max(1e5).optional()
23149
+ }).optional()
22766
23150
  })).mutation(async ({ ctx, input }) => {
23151
+ const hasCliCommand = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "command");
23152
+ const hasCliArgs = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "args");
23153
+ if (hasCliCommand && !hasCliArgs) {
23154
+ await ctx.configManager.setCliCommand(input.cli?.command ?? "");
23155
+ if (input.theme !== void 0 || input.terminal !== void 0) await ctx.configManager.writeConfig({
23156
+ theme: input.theme,
23157
+ terminal: input.terminal
23158
+ });
23159
+ return { success: true };
23160
+ }
22767
23161
  await ctx.configManager.writeConfig(input);
22768
23162
  return { success: true };
22769
23163
  }),
22770
- setCliCommand: publicProcedure.input(objectType({ command: stringType() })).mutation(async ({ ctx, input }) => {
22771
- await ctx.configManager.setCliCommand(input.command);
22772
- return { success: true };
22773
- }),
22774
23164
  subscribe: publicProcedure.subscription(({ ctx }) => {
22775
23165
  return createReactiveSubscription(() => ctx.configManager.readConfig());
22776
23166
  })
@@ -23116,32 +23506,6 @@ const opsxRouter = router({
23116
23506
  await writeFile$1(join$1(openspecDir, "config.yaml"), input.content, "utf-8");
23117
23507
  return { success: true };
23118
23508
  }),
23119
- updateProjectConfigUi: publicProcedure.input(objectType({
23120
- "font-size": numberType().min(8).max(32).optional(),
23121
- "font-families": arrayType(stringType()).optional(),
23122
- "cursor-blink": booleanType().optional(),
23123
- "cursor-style": enumType([
23124
- "block",
23125
- "underline",
23126
- "bar"
23127
- ]).optional(),
23128
- scrollback: numberType().min(0).max(1e5).optional()
23129
- })).mutation(async ({ ctx, input }) => {
23130
- const configPath = join$1(ctx.projectDir, "openspec", "config.yaml");
23131
- let doc;
23132
- try {
23133
- const content = await readFile$1(configPath, "utf-8");
23134
- doc = import_dist.parseDocument(content);
23135
- } catch {
23136
- doc = new import_dist.Document({});
23137
- }
23138
- if (!doc.has("ui")) doc.set("ui", doc.createNode({}));
23139
- const uiNode = doc.get("ui", true);
23140
- for (const [key, value] of Object.entries(input)) if (value !== void 0) uiNode.set(key, value);
23141
- await mkdir$1(join$1(ctx.projectDir, "openspec"), { recursive: true });
23142
- await writeFile$1(configPath, doc.toString(), "utf-8");
23143
- return { success: true };
23144
- }),
23145
23509
  listChanges: publicProcedure.query(async ({ ctx }) => {
23146
23510
  return reactiveReadDir(join$1(ctx.projectDir, "openspec", "changes"), {
23147
23511
  directoriesOnly: true,
@@ -23285,1174 +23649,8 @@ async function findAvailablePort(startPort, maxAttempts = 10) {
23285
23649
  throw new Error(`No available port found in range ${startPort}-${startPort + maxAttempts - 1}`);
23286
23650
  }
23287
23651
 
23288
- //#endregion
23289
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/eventEmitter2.js
23290
- var require_eventEmitter2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/eventEmitter2.js": ((exports) => {
23291
- /**
23292
- * Copyright (c) 2019, Microsoft Corporation (MIT License).
23293
- */
23294
- Object.defineProperty(exports, "__esModule", { value: true });
23295
- var EventEmitter2 = function() {
23296
- function EventEmitter2$1() {
23297
- this._listeners = [];
23298
- }
23299
- Object.defineProperty(EventEmitter2$1.prototype, "event", {
23300
- get: function() {
23301
- var _this = this;
23302
- if (!this._event) this._event = function(listener) {
23303
- _this._listeners.push(listener);
23304
- return { dispose: function() {
23305
- for (var i = 0; i < _this._listeners.length; i++) if (_this._listeners[i] === listener) {
23306
- _this._listeners.splice(i, 1);
23307
- return;
23308
- }
23309
- } };
23310
- };
23311
- return this._event;
23312
- },
23313
- enumerable: true,
23314
- configurable: true
23315
- });
23316
- EventEmitter2$1.prototype.fire = function(data) {
23317
- var queue = [];
23318
- for (var i = 0; i < this._listeners.length; i++) queue.push(this._listeners[i]);
23319
- for (var i = 0; i < queue.length; i++) queue[i].call(void 0, data);
23320
- };
23321
- return EventEmitter2$1;
23322
- }();
23323
- exports.EventEmitter2 = EventEmitter2;
23324
- }) });
23325
-
23326
- //#endregion
23327
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/terminal.js
23328
- var require_terminal = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/terminal.js": ((exports) => {
23329
- /**
23330
- * Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
23331
- * Copyright (c) 2016, Daniel Imms (MIT License).
23332
- * Copyright (c) 2018, Microsoft Corporation (MIT License).
23333
- */
23334
- Object.defineProperty(exports, "__esModule", { value: true });
23335
- var events_1 = __require("events");
23336
- var eventEmitter2_1$1 = require_eventEmitter2();
23337
- exports.DEFAULT_COLS = 80;
23338
- exports.DEFAULT_ROWS = 24;
23339
- /**
23340
- * Default messages to indicate PAUSE/RESUME for automatic flow control.
23341
- * To avoid conflicts with rebound XON/XOFF control codes (such as on-my-zsh),
23342
- * the sequences can be customized in `IPtyForkOptions`.
23343
- */
23344
- var FLOW_CONTROL_PAUSE = "";
23345
- var FLOW_CONTROL_RESUME = "";
23346
- var Terminal = function() {
23347
- function Terminal$1(opt) {
23348
- this._pid = 0;
23349
- this._fd = 0;
23350
- this._cols = 0;
23351
- this._rows = 0;
23352
- this._readable = false;
23353
- this._writable = false;
23354
- this._onData = new eventEmitter2_1$1.EventEmitter2();
23355
- this._onExit = new eventEmitter2_1$1.EventEmitter2();
23356
- this._internalee = new events_1.EventEmitter();
23357
- this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
23358
- this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
23359
- this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
23360
- if (!opt) return;
23361
- this._checkType("name", opt.name ? opt.name : void 0, "string");
23362
- this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
23363
- this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
23364
- this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
23365
- this._checkType("env", opt.env ? opt.env : void 0, "object");
23366
- this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
23367
- this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
23368
- this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
23369
- }
23370
- Object.defineProperty(Terminal$1.prototype, "onData", {
23371
- get: function() {
23372
- return this._onData.event;
23373
- },
23374
- enumerable: true,
23375
- configurable: true
23376
- });
23377
- Object.defineProperty(Terminal$1.prototype, "onExit", {
23378
- get: function() {
23379
- return this._onExit.event;
23380
- },
23381
- enumerable: true,
23382
- configurable: true
23383
- });
23384
- Object.defineProperty(Terminal$1.prototype, "pid", {
23385
- get: function() {
23386
- return this._pid;
23387
- },
23388
- enumerable: true,
23389
- configurable: true
23390
- });
23391
- Object.defineProperty(Terminal$1.prototype, "cols", {
23392
- get: function() {
23393
- return this._cols;
23394
- },
23395
- enumerable: true,
23396
- configurable: true
23397
- });
23398
- Object.defineProperty(Terminal$1.prototype, "rows", {
23399
- get: function() {
23400
- return this._rows;
23401
- },
23402
- enumerable: true,
23403
- configurable: true
23404
- });
23405
- Terminal$1.prototype.write = function(data) {
23406
- if (this.handleFlowControl) {
23407
- if (data === this._flowControlPause) {
23408
- this.pause();
23409
- return;
23410
- }
23411
- if (data === this._flowControlResume) {
23412
- this.resume();
23413
- return;
23414
- }
23415
- }
23416
- this._write(data);
23417
- };
23418
- Terminal$1.prototype._forwardEvents = function() {
23419
- var _this = this;
23420
- this.on("data", function(e) {
23421
- return _this._onData.fire(e);
23422
- });
23423
- this.on("exit", function(exitCode, signal) {
23424
- return _this._onExit.fire({
23425
- exitCode,
23426
- signal
23427
- });
23428
- });
23429
- };
23430
- Terminal$1.prototype._checkType = function(name, value, type, allowArray) {
23431
- if (allowArray === void 0) allowArray = false;
23432
- if (value === void 0) return;
23433
- if (allowArray) {
23434
- if (Array.isArray(value)) {
23435
- value.forEach(function(v, i) {
23436
- if (typeof v !== type) throw new Error(name + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
23437
- });
23438
- return;
23439
- }
23440
- }
23441
- if (typeof value !== type) throw new Error(name + " must be a " + type + " (not a " + typeof value + ")");
23442
- };
23443
- /** See net.Socket.end */
23444
- Terminal$1.prototype.end = function(data) {
23445
- this._socket.end(data);
23446
- };
23447
- /** See stream.Readable.pipe */
23448
- Terminal$1.prototype.pipe = function(dest, options) {
23449
- return this._socket.pipe(dest, options);
23450
- };
23451
- /** See net.Socket.pause */
23452
- Terminal$1.prototype.pause = function() {
23453
- return this._socket.pause();
23454
- };
23455
- /** See net.Socket.resume */
23456
- Terminal$1.prototype.resume = function() {
23457
- return this._socket.resume();
23458
- };
23459
- /** See net.Socket.setEncoding */
23460
- Terminal$1.prototype.setEncoding = function(encoding) {
23461
- if (this._socket._decoder) delete this._socket._decoder;
23462
- if (encoding) this._socket.setEncoding(encoding);
23463
- };
23464
- Terminal$1.prototype.addListener = function(eventName, listener) {
23465
- this.on(eventName, listener);
23466
- };
23467
- Terminal$1.prototype.on = function(eventName, listener) {
23468
- if (eventName === "close") {
23469
- this._internalee.on("close", listener);
23470
- return;
23471
- }
23472
- this._socket.on(eventName, listener);
23473
- };
23474
- Terminal$1.prototype.emit = function(eventName) {
23475
- var args = [];
23476
- for (var _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i];
23477
- if (eventName === "close") return this._internalee.emit.apply(this._internalee, arguments);
23478
- return this._socket.emit.apply(this._socket, arguments);
23479
- };
23480
- Terminal$1.prototype.listeners = function(eventName) {
23481
- return this._socket.listeners(eventName);
23482
- };
23483
- Terminal$1.prototype.removeListener = function(eventName, listener) {
23484
- this._socket.removeListener(eventName, listener);
23485
- };
23486
- Terminal$1.prototype.removeAllListeners = function(eventName) {
23487
- this._socket.removeAllListeners(eventName);
23488
- };
23489
- Terminal$1.prototype.once = function(eventName, listener) {
23490
- this._socket.once(eventName, listener);
23491
- };
23492
- Terminal$1.prototype._close = function() {
23493
- this._socket.readable = false;
23494
- this.write = function() {};
23495
- this.end = function() {};
23496
- this._writable = false;
23497
- this._readable = false;
23498
- };
23499
- Terminal$1.prototype._parseEnv = function(env) {
23500
- var keys = Object.keys(env || {});
23501
- var pairs$4 = [];
23502
- for (var i = 0; i < keys.length; i++) {
23503
- if (keys[i] === void 0) continue;
23504
- pairs$4.push(keys[i] + "=" + env[keys[i]]);
23505
- }
23506
- return pairs$4;
23507
- };
23508
- return Terminal$1;
23509
- }();
23510
- exports.Terminal = Terminal;
23511
- }) });
23512
-
23513
- //#endregion
23514
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/shared/conout.js
23515
- var require_conout = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/shared/conout.js": ((exports) => {
23516
- /**
23517
- * Copyright (c) 2020, Microsoft Corporation (MIT License).
23518
- */
23519
- Object.defineProperty(exports, "__esModule", { value: true });
23520
- function getWorkerPipeName(conoutPipeName) {
23521
- return conoutPipeName + "-worker";
23522
- }
23523
- exports.getWorkerPipeName = getWorkerPipeName;
23524
- }) });
23525
-
23526
- //#endregion
23527
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/windowsConoutConnection.js
23528
- var require_windowsConoutConnection = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/windowsConoutConnection.js": ((exports) => {
23529
- /**
23530
- * Copyright (c) 2020, Microsoft Corporation (MIT License).
23531
- */
23532
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
23533
- function adopt(value) {
23534
- return value instanceof P ? value : new P(function(resolve$2) {
23535
- resolve$2(value);
23536
- });
23537
- }
23538
- return new (P || (P = Promise))(function(resolve$2, reject) {
23539
- function fulfilled(value) {
23540
- try {
23541
- step(generator.next(value));
23542
- } catch (e) {
23543
- reject(e);
23544
- }
23545
- }
23546
- function rejected(value) {
23547
- try {
23548
- step(generator["throw"](value));
23549
- } catch (e) {
23550
- reject(e);
23551
- }
23552
- }
23553
- function step(result) {
23554
- result.done ? resolve$2(result.value) : adopt(result.value).then(fulfilled, rejected);
23555
- }
23556
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23557
- });
23558
- };
23559
- var __generator = exports && exports.__generator || function(thisArg, body) {
23560
- var _ = {
23561
- label: 0,
23562
- sent: function() {
23563
- if (t$1[0] & 1) throw t$1[1];
23564
- return t$1[1];
23565
- },
23566
- trys: [],
23567
- ops: []
23568
- }, f, y, t$1, g;
23569
- return g = {
23570
- next: verb(0),
23571
- "throw": verb(1),
23572
- "return": verb(2)
23573
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
23574
- return this;
23575
- }), g;
23576
- function verb(n) {
23577
- return function(v) {
23578
- return step([n, v]);
23579
- };
23580
- }
23581
- function step(op) {
23582
- if (f) throw new TypeError("Generator is already executing.");
23583
- while (_) try {
23584
- if (f = 1, y && (t$1 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t$1 = y["return"]) && t$1.call(y), 0) : y.next) && !(t$1 = t$1.call(y, op[1])).done) return t$1;
23585
- if (y = 0, t$1) op = [op[0] & 2, t$1.value];
23586
- switch (op[0]) {
23587
- case 0:
23588
- case 1:
23589
- t$1 = op;
23590
- break;
23591
- case 4:
23592
- _.label++;
23593
- return {
23594
- value: op[1],
23595
- done: false
23596
- };
23597
- case 5:
23598
- _.label++;
23599
- y = op[1];
23600
- op = [0];
23601
- continue;
23602
- case 7:
23603
- op = _.ops.pop();
23604
- _.trys.pop();
23605
- continue;
23606
- default:
23607
- if (!(t$1 = _.trys, t$1 = t$1.length > 0 && t$1[t$1.length - 1]) && (op[0] === 6 || op[0] === 2)) {
23608
- _ = 0;
23609
- continue;
23610
- }
23611
- if (op[0] === 3 && (!t$1 || op[1] > t$1[0] && op[1] < t$1[3])) {
23612
- _.label = op[1];
23613
- break;
23614
- }
23615
- if (op[0] === 6 && _.label < t$1[1]) {
23616
- _.label = t$1[1];
23617
- t$1 = op;
23618
- break;
23619
- }
23620
- if (t$1 && _.label < t$1[2]) {
23621
- _.label = t$1[2];
23622
- _.ops.push(op);
23623
- break;
23624
- }
23625
- if (t$1[2]) _.ops.pop();
23626
- _.trys.pop();
23627
- continue;
23628
- }
23629
- op = body.call(thisArg, _);
23630
- } catch (e) {
23631
- op = [6, e];
23632
- y = 0;
23633
- } finally {
23634
- f = t$1 = 0;
23635
- }
23636
- if (op[0] & 5) throw op[1];
23637
- return {
23638
- value: op[0] ? op[1] : void 0,
23639
- done: true
23640
- };
23641
- }
23642
- };
23643
- Object.defineProperty(exports, "__esModule", { value: true });
23644
- var worker_threads_1 = __require("worker_threads");
23645
- var conout_1 = require_conout();
23646
- var path_1 = __require("path");
23647
- var eventEmitter2_1 = require_eventEmitter2();
23648
- /**
23649
- * The amount of time to wait for additional data after the conpty shell process has exited before
23650
- * shutting down the worker and sockets. The timer will be reset if a new data event comes in after
23651
- * the timer has started.
23652
- */
23653
- var FLUSH_DATA_INTERVAL$1 = 1e3;
23654
- /**
23655
- * Connects to and manages the lifecycle of the conout socket. This socket must be drained on
23656
- * another thread in order to avoid deadlocks where Conpty waits for the out socket to drain
23657
- * when `ClosePseudoConsole` is called. This happens when data is being written to the terminal when
23658
- * the pty is closed.
23659
- *
23660
- * See also:
23661
- * - https://github.com/microsoft/node-pty/issues/375
23662
- * - https://github.com/microsoft/vscode/issues/76548
23663
- * - https://github.com/microsoft/terminal/issues/1810
23664
- * - https://docs.microsoft.com/en-us/windows/console/closepseudoconsole
23665
- */
23666
- var ConoutConnection = function() {
23667
- function ConoutConnection$1(_conoutPipeName) {
23668
- var _this = this;
23669
- this._conoutPipeName = _conoutPipeName;
23670
- this._isDisposed = false;
23671
- this._onReady = new eventEmitter2_1.EventEmitter2();
23672
- var workerData = { conoutPipeName: _conoutPipeName };
23673
- var scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
23674
- this._worker = new worker_threads_1.Worker(path_1.join(scriptPath, "worker/conoutSocketWorker.js"), { workerData });
23675
- this._worker.on("message", function(message) {
23676
- switch (message) {
23677
- case 1:
23678
- _this._onReady.fire();
23679
- return;
23680
- default: console.warn("Unexpected ConoutWorkerMessage", message);
23681
- }
23682
- });
23683
- }
23684
- Object.defineProperty(ConoutConnection$1.prototype, "onReady", {
23685
- get: function() {
23686
- return this._onReady.event;
23687
- },
23688
- enumerable: true,
23689
- configurable: true
23690
- });
23691
- ConoutConnection$1.prototype.dispose = function() {
23692
- if (this._isDisposed) return;
23693
- this._isDisposed = true;
23694
- this._drainDataAndClose();
23695
- };
23696
- ConoutConnection$1.prototype.connectSocket = function(socket) {
23697
- socket.connect(conout_1.getWorkerPipeName(this._conoutPipeName));
23698
- };
23699
- ConoutConnection$1.prototype._drainDataAndClose = function() {
23700
- var _this = this;
23701
- if (this._drainTimeout) clearTimeout(this._drainTimeout);
23702
- this._drainTimeout = setTimeout(function() {
23703
- return _this._destroySocket();
23704
- }, FLUSH_DATA_INTERVAL$1);
23705
- };
23706
- ConoutConnection$1.prototype._destroySocket = function() {
23707
- return __awaiter(this, void 0, void 0, function() {
23708
- return __generator(this, function(_a) {
23709
- switch (_a.label) {
23710
- case 0: return [4, this._worker.terminate()];
23711
- case 1:
23712
- _a.sent();
23713
- return [2];
23714
- }
23715
- });
23716
- });
23717
- };
23718
- return ConoutConnection$1;
23719
- }();
23720
- exports.ConoutConnection = ConoutConnection;
23721
- }) });
23722
-
23723
- //#endregion
23724
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/package.json
23725
- var require_package = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/package.json": ((exports, module) => {
23726
- module.exports = {
23727
- "name": "@lydell/node-pty",
23728
- "description": "node-pty with prebuilt binaries",
23729
- "author": "Simon Lydell",
23730
- "version": "1.1.0",
23731
- "license": "MIT",
23732
- "main": "./index.js",
23733
- "types": "./node-pty.d.ts",
23734
- "repository": {
23735
- "type": "git",
23736
- "url": "git://github.com/lydell/node-pty.git"
23737
- },
23738
- "keywords": [
23739
- "pty",
23740
- "tty",
23741
- "terminal",
23742
- "pseudoterminal",
23743
- "forkpty",
23744
- "openpty",
23745
- "prebuild",
23746
- "prebuilt"
23747
- ],
23748
- "optionalDependencies": {
23749
- "@lydell/node-pty-darwin-x64": "1.1.0",
23750
- "@lydell/node-pty-darwin-arm64": "1.1.0",
23751
- "@lydell/node-pty-linux-x64": "1.1.0",
23752
- "@lydell/node-pty-linux-arm64": "1.1.0",
23753
- "@lydell/node-pty-win32-x64": "1.1.0",
23754
- "@lydell/node-pty-win32-arm64": "1.1.0"
23755
- }
23756
- };
23757
- }) });
23758
-
23759
- //#endregion
23760
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/requireBinary.js
23761
- var require_requireBinary = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/requireBinary.js": ((exports) => {
23762
- Object.defineProperty(exports, "__esModule", { value: true });
23763
- var PACKAGE_NAME = "@lydell/node-pty-" + process.platform + "-" + process.arch;
23764
- var help = "\nThis can happen if you use the \"--omit=optional\" (or \"--no-optional\") npm flag.\nThe \"optionalDependencies\" package.json feature is used to install the correct\nbinary executable for your current platform. Remove that flag to use @lydell/node-pty.\n\nThis can also happen if the \"node_modules\" folder was copied between two operating systems\nthat need different binaries - including \"virtual\" operating systems like Docker and WSL.\nIf so, try installing with npm rather than copying \"node_modules\".\n".trim();
23765
- function requireBinary(file) {
23766
- try {
23767
- return __require(PACKAGE_NAME + "/" + file);
23768
- } catch (error) {
23769
- if (error && error.code === "MODULE_NOT_FOUND") {
23770
- var optionalDependencies = getOptionalDependencies();
23771
- throw new Error(optionalDependencies === void 0 ? "The @lydell/node-pty package could not find the binary package: " + PACKAGE_NAME + "/" + file + "\n\n" + help + "\n\nYour platform (" + process.platform + "-" + process.arch + ") might not be supported." : PACKAGE_NAME in optionalDependencies ? "The @lydell/node-pty package supports your platform (" + process.platform + "-" + process.arch + "), but it could not find the binary package for it: " + PACKAGE_NAME + "/" + file + "\n\n" + help : "The @lydell/node-pty package currently does not support your platform: " + process.platform + "-" + process.arch, { cause: error });
23772
- } else throw error;
23773
- }
23774
- }
23775
- exports.requireBinary = requireBinary;
23776
- function getOptionalDependencies() {
23777
- try {
23778
- return require_package().optionalDependencies;
23779
- } catch (_error) {
23780
- return;
23781
- }
23782
- }
23783
- }) });
23784
-
23785
- //#endregion
23786
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/windowsPtyAgent.js
23787
- var require_windowsPtyAgent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/windowsPtyAgent.js": ((exports) => {
23788
- /**
23789
- * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
23790
- * Copyright (c) 2016, Daniel Imms (MIT License).
23791
- * Copyright (c) 2018, Microsoft Corporation (MIT License).
23792
- */
23793
- Object.defineProperty(exports, "__esModule", { value: true });
23794
- var fs$2 = __require("fs");
23795
- var path$1 = __require("path");
23796
- var net_1 = __require("net");
23797
- var child_process_1 = __require("child_process");
23798
- var windowsConoutConnection_1 = require_windowsConoutConnection();
23799
- var requireBinary_1 = require_requireBinary();
23800
- var conptyNative;
23801
- /**
23802
- * The amount of time to wait for additional data after the conpty shell process has exited before
23803
- * shutting down the socket. The timer will be reset if a new data event comes in after the timer
23804
- * has started.
23805
- */
23806
- var FLUSH_DATA_INTERVAL = 1e3;
23807
- /**
23808
- * This agent sits between the WindowsTerminal class and provides an interface for both conpty.
23809
- */
23810
- var WindowsPtyAgent = function() {
23811
- function WindowsPtyAgent$1(file, args, env, cwd, cols, rows, debug$1, conptyInheritCursor) {
23812
- var _this = this;
23813
- if (conptyInheritCursor === void 0) conptyInheritCursor = false;
23814
- this._pid = 0;
23815
- this._innerPid = 0;
23816
- if (!conptyNative) conptyNative = requireBinary_1.requireBinary("conpty.node");
23817
- this._ptyNative = conptyNative;
23818
- cwd = path$1.resolve(cwd);
23819
- var commandLine = argsToCommandLine(file, args);
23820
- var term = this._ptyNative.startProcess(file, cols, rows, debug$1, this._generatePipeName(), conptyInheritCursor);
23821
- this._fd = term.fd;
23822
- this._pty = term.pty;
23823
- this._outSocket = new net_1.Socket();
23824
- this._outSocket.setEncoding("utf8");
23825
- this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout);
23826
- this._conoutSocketWorker.onReady(function() {
23827
- _this._conoutSocketWorker.connectSocket(_this._outSocket);
23828
- });
23829
- this._outSocket.on("connect", function() {
23830
- _this._outSocket.emit("ready_datapipe");
23831
- });
23832
- var inSocketFD = fs$2.openSync(term.conin, "w");
23833
- this._inSocket = new net_1.Socket({
23834
- fd: inSocketFD,
23835
- readable: false,
23836
- writable: true
23837
- });
23838
- this._inSocket.setEncoding("utf8");
23839
- this._innerPid = this._ptyNative.connect(this._pty, commandLine, cwd, env, function(c) {
23840
- return _this._$onProcessExit(c);
23841
- }).pid;
23842
- }
23843
- Object.defineProperty(WindowsPtyAgent$1.prototype, "inSocket", {
23844
- get: function() {
23845
- return this._inSocket;
23846
- },
23847
- enumerable: true,
23848
- configurable: true
23849
- });
23850
- Object.defineProperty(WindowsPtyAgent$1.prototype, "outSocket", {
23851
- get: function() {
23852
- return this._outSocket;
23853
- },
23854
- enumerable: true,
23855
- configurable: true
23856
- });
23857
- Object.defineProperty(WindowsPtyAgent$1.prototype, "fd", {
23858
- get: function() {
23859
- return this._fd;
23860
- },
23861
- enumerable: true,
23862
- configurable: true
23863
- });
23864
- Object.defineProperty(WindowsPtyAgent$1.prototype, "innerPid", {
23865
- get: function() {
23866
- return this._innerPid;
23867
- },
23868
- enumerable: true,
23869
- configurable: true
23870
- });
23871
- Object.defineProperty(WindowsPtyAgent$1.prototype, "pty", {
23872
- get: function() {
23873
- return this._pty;
23874
- },
23875
- enumerable: true,
23876
- configurable: true
23877
- });
23878
- WindowsPtyAgent$1.prototype.resize = function(cols, rows) {
23879
- if (this._exitCode !== void 0) throw new Error("Cannot resize a pty that has already exited");
23880
- this._ptyNative.resize(this._pty, cols, rows);
23881
- };
23882
- WindowsPtyAgent$1.prototype.clear = function() {
23883
- this._ptyNative.clear(this._pty);
23884
- };
23885
- WindowsPtyAgent$1.prototype.kill = function() {
23886
- var _this = this;
23887
- this._inSocket.readable = false;
23888
- this._outSocket.readable = false;
23889
- this._getConsoleProcessList().then(function(consoleProcessList) {
23890
- consoleProcessList.forEach(function(pid) {
23891
- try {
23892
- process.kill(pid);
23893
- } catch (e) {}
23894
- });
23895
- _this._ptyNative.kill(_this._pty);
23896
- });
23897
- this._conoutSocketWorker.dispose();
23898
- };
23899
- WindowsPtyAgent$1.prototype._getConsoleProcessList = function() {
23900
- var _this = this;
23901
- return new Promise(function(resolve$2) {
23902
- var agent = child_process_1.fork(path$1.join(__dirname, "conpty_console_list_agent"), [_this._innerPid.toString()]);
23903
- agent.on("message", function(message) {
23904
- clearTimeout(timeout);
23905
- resolve$2(message.consoleProcessList);
23906
- });
23907
- var timeout = setTimeout(function() {
23908
- agent.kill();
23909
- resolve$2([_this._innerPid]);
23910
- }, 5e3);
23911
- });
23912
- };
23913
- Object.defineProperty(WindowsPtyAgent$1.prototype, "exitCode", {
23914
- get: function() {
23915
- return this._exitCode;
23916
- },
23917
- enumerable: true,
23918
- configurable: true
23919
- });
23920
- WindowsPtyAgent$1.prototype._generatePipeName = function() {
23921
- return "conpty-" + Math.random() * 1e7;
23922
- };
23923
- /**
23924
- * Triggered from the native side when a contpy process exits.
23925
- */
23926
- WindowsPtyAgent$1.prototype._$onProcessExit = function(exitCode) {
23927
- var _this = this;
23928
- this._exitCode = exitCode;
23929
- this._flushDataAndCleanUp();
23930
- this._outSocket.on("data", function() {
23931
- return _this._flushDataAndCleanUp();
23932
- });
23933
- };
23934
- WindowsPtyAgent$1.prototype._flushDataAndCleanUp = function() {
23935
- var _this = this;
23936
- if (this._closeTimeout) clearTimeout(this._closeTimeout);
23937
- this._closeTimeout = setTimeout(function() {
23938
- return _this._cleanUpProcess();
23939
- }, FLUSH_DATA_INTERVAL);
23940
- };
23941
- WindowsPtyAgent$1.prototype._cleanUpProcess = function() {
23942
- this._inSocket.readable = false;
23943
- this._outSocket.readable = false;
23944
- this._outSocket.destroy();
23945
- };
23946
- return WindowsPtyAgent$1;
23947
- }();
23948
- exports.WindowsPtyAgent = WindowsPtyAgent;
23949
- function argsToCommandLine(file, args) {
23950
- if (isCommandLine(args)) {
23951
- if (args.length === 0) return file;
23952
- return argsToCommandLine(file, []) + " " + args;
23953
- }
23954
- var argv = [file];
23955
- Array.prototype.push.apply(argv, args);
23956
- var result = "";
23957
- for (var argIndex = 0; argIndex < argv.length; argIndex++) {
23958
- if (argIndex > 0) result += " ";
23959
- var arg = argv[argIndex];
23960
- var hasLopsidedEnclosingQuote = xOr(arg[0] !== "\"", arg[arg.length - 1] !== "\"");
23961
- var hasNoEnclosingQuotes = arg[0] !== "\"" && arg[arg.length - 1] !== "\"";
23962
- var quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes);
23963
- if (quote) result += "\"";
23964
- var bsCount = 0;
23965
- for (var i = 0; i < arg.length; i++) {
23966
- var p = arg[i];
23967
- if (p === "\\") bsCount++;
23968
- else if (p === "\"") {
23969
- result += repeatText("\\", bsCount * 2 + 1);
23970
- result += "\"";
23971
- bsCount = 0;
23972
- } else {
23973
- result += repeatText("\\", bsCount);
23974
- bsCount = 0;
23975
- result += p;
23976
- }
23977
- }
23978
- if (quote) {
23979
- result += repeatText("\\", bsCount * 2);
23980
- result += "\"";
23981
- } else result += repeatText("\\", bsCount);
23982
- }
23983
- return result;
23984
- }
23985
- exports.argsToCommandLine = argsToCommandLine;
23986
- function isCommandLine(args) {
23987
- return typeof args === "string";
23988
- }
23989
- function repeatText(text, count) {
23990
- var result = "";
23991
- for (var i = 0; i < count; i++) result += text;
23992
- return result;
23993
- }
23994
- function xOr(arg1, arg2) {
23995
- return arg1 && !arg2 || !arg1 && arg2;
23996
- }
23997
- }) });
23998
-
23999
- //#endregion
24000
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/utils.js
24001
- var require_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/utils.js": ((exports) => {
24002
- /**
24003
- * Copyright (c) 2017, Daniel Imms (MIT License).
24004
- * Copyright (c) 2018, Microsoft Corporation (MIT License).
24005
- */
24006
- Object.defineProperty(exports, "__esModule", { value: true });
24007
- function assign(target) {
24008
- var sources = [];
24009
- for (var _i = 1; _i < arguments.length; _i++) sources[_i - 1] = arguments[_i];
24010
- sources.forEach(function(source) {
24011
- return Object.keys(source).forEach(function(key) {
24012
- return target[key] = source[key];
24013
- });
24014
- });
24015
- return target;
24016
- }
24017
- exports.assign = assign;
24018
- }) });
24019
-
24020
- //#endregion
24021
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/windowsTerminal.js
24022
- var require_windowsTerminal = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/windowsTerminal.js": ((exports) => {
24023
- /**
24024
- * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
24025
- * Copyright (c) 2016, Daniel Imms (MIT License).
24026
- * Copyright (c) 2018, Microsoft Corporation (MIT License).
24027
- */
24028
- var __extends$1 = exports && exports.__extends || (function() {
24029
- var extendStatics = function(d, b) {
24030
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d$1, b$1) {
24031
- d$1.__proto__ = b$1;
24032
- } || function(d$1, b$1) {
24033
- for (var p in b$1) if (b$1.hasOwnProperty(p)) d$1[p] = b$1[p];
24034
- };
24035
- return extendStatics(d, b);
24036
- };
24037
- return function(d, b) {
24038
- extendStatics(d, b);
24039
- function __() {
24040
- this.constructor = d;
24041
- }
24042
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24043
- };
24044
- })();
24045
- Object.defineProperty(exports, "__esModule", { value: true });
24046
- var terminal_1$1 = require_terminal();
24047
- var windowsPtyAgent_1 = require_windowsPtyAgent();
24048
- var utils_1$1 = require_utils();
24049
- var DEFAULT_FILE$1 = "cmd.exe";
24050
- var DEFAULT_NAME$1 = "Windows Shell";
24051
- var WindowsTerminal = function(_super) {
24052
- __extends$1(WindowsTerminal$1, _super);
24053
- function WindowsTerminal$1(file, args, opt) {
24054
- var _this = _super.call(this, opt) || this;
24055
- _this._checkType("args", args, "string", true);
24056
- args = args || [];
24057
- file = file || DEFAULT_FILE$1;
24058
- opt = opt || {};
24059
- opt.env = opt.env || process.env;
24060
- if (opt.encoding) console.warn("Setting encoding on Windows is not supported");
24061
- var env = utils_1$1.assign({}, opt.env);
24062
- _this._cols = opt.cols || terminal_1$1.DEFAULT_COLS;
24063
- _this._rows = opt.rows || terminal_1$1.DEFAULT_ROWS;
24064
- var cwd = opt.cwd || process.cwd();
24065
- var name = opt.name || env.TERM || DEFAULT_NAME$1;
24066
- var parsedEnv = _this._parseEnv(env);
24067
- _this._isReady = false;
24068
- _this._deferreds = [];
24069
- _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.conptyInheritCursor);
24070
- _this._socket = _this._agent.outSocket;
24071
- _this._pid = _this._agent.innerPid;
24072
- _this._fd = _this._agent.fd;
24073
- _this._pty = _this._agent.pty;
24074
- _this._socket.on("ready_datapipe", function() {
24075
- [
24076
- "connect",
24077
- "data",
24078
- "end",
24079
- "timeout",
24080
- "drain"
24081
- ].forEach(function(event) {
24082
- _this._socket.on(event, function() {
24083
- if (!_this._isReady && event === "data") {
24084
- _this._isReady = true;
24085
- _this._deferreds.forEach(function(fn) {
24086
- fn.run();
24087
- });
24088
- _this._deferreds = [];
24089
- }
24090
- });
24091
- });
24092
- _this._socket.on("error", function(err) {
24093
- _this._close();
24094
- if (err.code) {
24095
- if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) return;
24096
- }
24097
- if (_this.listeners("error").length < 2) throw err;
24098
- });
24099
- _this._socket.on("close", function() {
24100
- _this.emit("exit", _this._agent.exitCode);
24101
- _this._close();
24102
- });
24103
- });
24104
- _this._file = file;
24105
- _this._name = name;
24106
- _this._readable = true;
24107
- _this._writable = true;
24108
- _this._forwardEvents();
24109
- return _this;
24110
- }
24111
- WindowsTerminal$1.prototype._write = function(data) {
24112
- this._defer(this._doWrite, data);
24113
- };
24114
- WindowsTerminal$1.prototype._doWrite = function(data) {
24115
- this._agent.inSocket.write(data);
24116
- };
24117
- /**
24118
- * openpty
24119
- */
24120
- WindowsTerminal$1.open = function(options) {
24121
- throw new Error("open() not supported on windows, use Fork() instead.");
24122
- };
24123
- /**
24124
- * TTY
24125
- */
24126
- WindowsTerminal$1.prototype.resize = function(cols, rows) {
24127
- var _this = this;
24128
- if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) throw new Error("resizing must be done using positive cols and rows");
24129
- this._deferNoArgs(function() {
24130
- _this._agent.resize(cols, rows);
24131
- _this._cols = cols;
24132
- _this._rows = rows;
24133
- });
24134
- };
24135
- WindowsTerminal$1.prototype.clear = function() {
24136
- var _this = this;
24137
- this._deferNoArgs(function() {
24138
- _this._agent.clear();
24139
- });
24140
- };
24141
- WindowsTerminal$1.prototype.destroy = function() {
24142
- var _this = this;
24143
- this._deferNoArgs(function() {
24144
- _this.kill();
24145
- });
24146
- };
24147
- WindowsTerminal$1.prototype.kill = function(signal) {
24148
- var _this = this;
24149
- this._deferNoArgs(function() {
24150
- if (signal) throw new Error("Signals not supported on windows.");
24151
- _this._close();
24152
- _this._agent.kill();
24153
- });
24154
- };
24155
- WindowsTerminal$1.prototype._deferNoArgs = function(deferredFn) {
24156
- var _this = this;
24157
- if (this._isReady) {
24158
- deferredFn.call(this);
24159
- return;
24160
- }
24161
- this._deferreds.push({ run: function() {
24162
- return deferredFn.call(_this);
24163
- } });
24164
- };
24165
- WindowsTerminal$1.prototype._defer = function(deferredFn, arg) {
24166
- var _this = this;
24167
- if (this._isReady) {
24168
- deferredFn.call(this, arg);
24169
- return;
24170
- }
24171
- this._deferreds.push({ run: function() {
24172
- return deferredFn.call(_this, arg);
24173
- } });
24174
- };
24175
- Object.defineProperty(WindowsTerminal$1.prototype, "process", {
24176
- get: function() {
24177
- return this._name;
24178
- },
24179
- enumerable: true,
24180
- configurable: true
24181
- });
24182
- Object.defineProperty(WindowsTerminal$1.prototype, "master", {
24183
- get: function() {
24184
- throw new Error("master is not supported on Windows");
24185
- },
24186
- enumerable: true,
24187
- configurable: true
24188
- });
24189
- Object.defineProperty(WindowsTerminal$1.prototype, "slave", {
24190
- get: function() {
24191
- throw new Error("slave is not supported on Windows");
24192
- },
24193
- enumerable: true,
24194
- configurable: true
24195
- });
24196
- return WindowsTerminal$1;
24197
- }(terminal_1$1.Terminal);
24198
- exports.WindowsTerminal = WindowsTerminal;
24199
- }) });
24200
-
24201
- //#endregion
24202
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/unixTerminal.js
24203
- var require_unixTerminal = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/unixTerminal.js": ((exports) => {
24204
- var __extends = exports && exports.__extends || (function() {
24205
- var extendStatics = function(d, b) {
24206
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d$1, b$1) {
24207
- d$1.__proto__ = b$1;
24208
- } || function(d$1, b$1) {
24209
- for (var p in b$1) if (b$1.hasOwnProperty(p)) d$1[p] = b$1[p];
24210
- };
24211
- return extendStatics(d, b);
24212
- };
24213
- return function(d, b) {
24214
- extendStatics(d, b);
24215
- function __() {
24216
- this.constructor = d;
24217
- }
24218
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24219
- };
24220
- })();
24221
- Object.defineProperty(exports, "__esModule", { value: true });
24222
- var tty = __require("tty");
24223
- var terminal_1 = require_terminal();
24224
- var utils_1 = require_utils();
24225
- var pty = require_requireBinary().requireBinary("pty.node");
24226
- var helperPath = "@lydell/node-pty-" + process.platform + "-" + process.arch + "/spawn-helper";
24227
- helperPath = process.platform === "darwin" ? __require.resolve(helperPath) : "spawn-helper-unused";
24228
- helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
24229
- helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
24230
- var DEFAULT_FILE = "sh";
24231
- var DEFAULT_NAME = "xterm";
24232
- var DESTROY_SOCKET_TIMEOUT_MS = 200;
24233
- var UnixTerminal = function(_super) {
24234
- __extends(UnixTerminal$1, _super);
24235
- function UnixTerminal$1(file, args, opt) {
24236
- var _a, _b;
24237
- var _this = _super.call(this, opt) || this;
24238
- _this._boundClose = false;
24239
- _this._emittedClose = false;
24240
- if (typeof args === "string") throw new Error("args as a string is not supported on unix.");
24241
- args = args || [];
24242
- file = file || DEFAULT_FILE;
24243
- opt = opt || {};
24244
- opt.env = opt.env || process.env;
24245
- _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
24246
- _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
24247
- var uid = (_a = opt.uid) !== null && _a !== void 0 ? _a : -1;
24248
- var gid = (_b = opt.gid) !== null && _b !== void 0 ? _b : -1;
24249
- var env = utils_1.assign({}, opt.env);
24250
- if (opt.env === process.env) _this._sanitizeEnv(env);
24251
- var cwd = opt.cwd || process.cwd();
24252
- env.PWD = cwd;
24253
- var name = opt.name || env.TERM || DEFAULT_NAME;
24254
- env.TERM = name;
24255
- var parsedEnv = _this._parseEnv(env);
24256
- var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
24257
- var onexit = function(code, signal) {
24258
- if (!_this._emittedClose) {
24259
- if (_this._boundClose) return;
24260
- _this._boundClose = true;
24261
- var timeout_1 = setTimeout(function() {
24262
- timeout_1 = null;
24263
- _this._socket.destroy();
24264
- }, DESTROY_SOCKET_TIMEOUT_MS);
24265
- _this.once("close", function() {
24266
- if (timeout_1 !== null) clearTimeout(timeout_1);
24267
- _this.emit("exit", code, signal);
24268
- });
24269
- return;
24270
- }
24271
- _this.emit("exit", code, signal);
24272
- };
24273
- var term = pty.fork(file, args, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
24274
- _this._socket = new tty.ReadStream(term.fd);
24275
- if (encoding !== null) _this._socket.setEncoding(encoding);
24276
- _this._socket.on("error", function(err) {
24277
- if (err.code) {
24278
- if (~err.code.indexOf("EAGAIN")) return;
24279
- }
24280
- _this._close();
24281
- if (!_this._emittedClose) {
24282
- _this._emittedClose = true;
24283
- _this.emit("close");
24284
- }
24285
- if (err.code) {
24286
- if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) return;
24287
- }
24288
- if (_this.listeners("error").length < 2) throw err;
24289
- });
24290
- _this._pid = term.pid;
24291
- _this._fd = term.fd;
24292
- _this._pty = term.pty;
24293
- _this._file = file;
24294
- _this._name = name;
24295
- _this._readable = true;
24296
- _this._writable = true;
24297
- _this._socket.on("close", function() {
24298
- if (_this._emittedClose) return;
24299
- _this._emittedClose = true;
24300
- _this._close();
24301
- _this.emit("close");
24302
- });
24303
- _this._forwardEvents();
24304
- return _this;
24305
- }
24306
- Object.defineProperty(UnixTerminal$1.prototype, "master", {
24307
- get: function() {
24308
- return this._master;
24309
- },
24310
- enumerable: true,
24311
- configurable: true
24312
- });
24313
- Object.defineProperty(UnixTerminal$1.prototype, "slave", {
24314
- get: function() {
24315
- return this._slave;
24316
- },
24317
- enumerable: true,
24318
- configurable: true
24319
- });
24320
- UnixTerminal$1.prototype._write = function(data) {
24321
- this._socket.write(data);
24322
- };
24323
- Object.defineProperty(UnixTerminal$1.prototype, "fd", {
24324
- get: function() {
24325
- return this._fd;
24326
- },
24327
- enumerable: true,
24328
- configurable: true
24329
- });
24330
- Object.defineProperty(UnixTerminal$1.prototype, "ptsName", {
24331
- get: function() {
24332
- return this._pty;
24333
- },
24334
- enumerable: true,
24335
- configurable: true
24336
- });
24337
- /**
24338
- * openpty
24339
- */
24340
- UnixTerminal$1.open = function(opt) {
24341
- var self = Object.create(UnixTerminal$1.prototype);
24342
- opt = opt || {};
24343
- if (arguments.length > 1) opt = {
24344
- cols: arguments[1],
24345
- rows: arguments[2]
24346
- };
24347
- var cols = opt.cols || terminal_1.DEFAULT_COLS;
24348
- var rows = opt.rows || terminal_1.DEFAULT_ROWS;
24349
- var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
24350
- var term = pty.open(cols, rows);
24351
- self._master = new tty.ReadStream(term.master);
24352
- if (encoding !== null) self._master.setEncoding(encoding);
24353
- self._master.resume();
24354
- self._slave = new tty.ReadStream(term.slave);
24355
- if (encoding !== null) self._slave.setEncoding(encoding);
24356
- self._slave.resume();
24357
- self._socket = self._master;
24358
- self._pid = -1;
24359
- self._fd = term.master;
24360
- self._pty = term.pty;
24361
- self._file = process.argv[0] || "node";
24362
- self._name = process.env.TERM || "";
24363
- self._readable = true;
24364
- self._writable = true;
24365
- self._socket.on("error", function(err) {
24366
- self._close();
24367
- if (self.listeners("error").length < 2) throw err;
24368
- });
24369
- self._socket.on("close", function() {
24370
- self._close();
24371
- });
24372
- return self;
24373
- };
24374
- UnixTerminal$1.prototype.destroy = function() {
24375
- var _this = this;
24376
- this._close();
24377
- this._socket.once("close", function() {
24378
- _this.kill("SIGHUP");
24379
- });
24380
- this._socket.destroy();
24381
- };
24382
- UnixTerminal$1.prototype.kill = function(signal) {
24383
- try {
24384
- process.kill(this.pid, signal || "SIGHUP");
24385
- } catch (e) {}
24386
- };
24387
- Object.defineProperty(UnixTerminal$1.prototype, "process", {
24388
- get: function() {
24389
- if (process.platform === "darwin") {
24390
- var title = pty.process(this._fd);
24391
- return title !== "kernel_task" ? title : this._file;
24392
- }
24393
- return pty.process(this._fd, this._pty) || this._file;
24394
- },
24395
- enumerable: true,
24396
- configurable: true
24397
- });
24398
- /**
24399
- * TTY
24400
- */
24401
- UnixTerminal$1.prototype.resize = function(cols, rows) {
24402
- if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) throw new Error("resizing must be done using positive cols and rows");
24403
- pty.resize(this._fd, cols, rows);
24404
- this._cols = cols;
24405
- this._rows = rows;
24406
- };
24407
- UnixTerminal$1.prototype.clear = function() {};
24408
- UnixTerminal$1.prototype._sanitizeEnv = function(env) {
24409
- delete env["TMUX"];
24410
- delete env["TMUX_PANE"];
24411
- delete env["STY"];
24412
- delete env["WINDOW"];
24413
- delete env["WINDOWID"];
24414
- delete env["TERMCAP"];
24415
- delete env["COLUMNS"];
24416
- delete env["LINES"];
24417
- };
24418
- return UnixTerminal$1;
24419
- }(terminal_1.Terminal);
24420
- exports.UnixTerminal = UnixTerminal;
24421
- }) });
24422
-
24423
- //#endregion
24424
- //#region ../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/index.js
24425
- var require_node_pty = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/@lydell+node-pty@1.1.0/node_modules/@lydell/node-pty/index.js": ((exports) => {
24426
- /**
24427
- * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
24428
- * Copyright (c) 2016, Daniel Imms (MIT License).
24429
- * Copyright (c) 2018, Microsoft Corporation (MIT License).
24430
- */
24431
- Object.defineProperty(exports, "__esModule", { value: true });
24432
- var terminalCtor;
24433
- if (process.platform === "win32") terminalCtor = require_windowsTerminal().WindowsTerminal;
24434
- else terminalCtor = require_unixTerminal().UnixTerminal;
24435
- /**
24436
- * Forks a process as a pseudoterminal.
24437
- * @param file The file to launch.
24438
- * @param args The file's arguments as argv (string[]) or in a pre-escaped
24439
- * CommandLine format (string). Note that the CommandLine option is only
24440
- * available on Windows and is expected to be escaped properly.
24441
- * @param options The options of the terminal.
24442
- * @throws When the file passed to spawn with does not exists.
24443
- * @see CommandLineToArgvW https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx
24444
- * @see Parsing C++ Comamnd-Line Arguments https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
24445
- * @see GetCommandLine https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx
24446
- */
24447
- function spawn$1(file, args, opt) {
24448
- return new terminalCtor(file, args, opt);
24449
- }
24450
- exports.spawn = spawn$1;
24451
- }) });
24452
-
24453
23652
  //#endregion
24454
23653
  //#region ../server/src/pty-manager.ts
24455
- var import_node_pty = /* @__PURE__ */ __toESM$1(require_node_pty(), 1);
24456
23654
  const DEFAULT_SCROLLBACK = 1e3;
24457
23655
  const DEFAULT_MAX_BUFFER_BYTES = 2 * 1024 * 1024;
24458
23656
  function detectPtyPlatform() {
@@ -24486,7 +23684,7 @@ var PtySession = class extends EventEmitter {
24486
23684
  this.platform = opts.platform;
24487
23685
  this.maxBufferLines = opts.scrollback ?? DEFAULT_SCROLLBACK;
24488
23686
  this.maxBufferBytes = opts.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;
24489
- this.process = import_node_pty.spawn(shell, args, {
23687
+ this.process = pty.spawn(shell, args, {
24490
23688
  name: "xterm-256color",
24491
23689
  cols: opts.cols ?? 80,
24492
23690
  rows: opts.rows ?? 24,
@@ -24937,13 +24135,13 @@ async function startServer(config, setupApp) {
24937
24135
 
24938
24136
  //#endregion
24939
24137
  //#region src/index.ts
24940
- const __dirname$1 = dirname$1(fileURLToPath(import.meta.url));
24138
+ const __dirname = dirname$1(fileURLToPath(import.meta.url));
24941
24139
  /**
24942
24140
  * Get the path to the web assets directory
24943
24141
  */
24944
24142
  function getWebAssetsDir() {
24945
- const devPath = join$1(__dirname$1, "..", "..", "web", "dist");
24946
- const prodPath = join$1(__dirname$1, "..", "web");
24143
+ const devPath = join$1(__dirname, "..", "..", "web", "dist");
24144
+ const prodPath = join$1(__dirname, "..", "web");
24947
24145
  if (existsSync(prodPath)) return prodPath;
24948
24146
  if (existsSync(devPath)) return devPath;
24949
24147
  throw new Error("Web assets not found. Make sure to build the web package first.");
@@ -24969,15 +24167,15 @@ function setupStaticFiles(app) {
24969
24167
  ttf: "font/ttf"
24970
24168
  };
24971
24169
  app.use("/*", async (c, next) => {
24972
- const path$2 = c.req.path === "/" ? "/index.html" : c.req.path;
24973
- if (path$2.startsWith("/trpc")) return next();
24974
- const filePath = join$1(webDir, path$2);
24170
+ const path$1 = c.req.path === "/" ? "/index.html" : c.req.path;
24171
+ if (path$1.startsWith("/trpc")) return next();
24172
+ const filePath = join$1(webDir, path$1);
24975
24173
  if (existsSync(filePath) && statSync(filePath).isFile()) {
24976
24174
  const content = readFileSync(filePath);
24977
- const contentType = mimeTypes[path$2.split(".").pop() || ""] || "application/octet-stream";
24175
+ const contentType = mimeTypes[path$1.split(".").pop() || ""] || "application/octet-stream";
24978
24176
  return c.body(content, 200, { "Content-Type": contentType });
24979
24177
  }
24980
- if (!path$2.includes(".")) {
24178
+ if (!path$1.includes(".")) {
24981
24179
  const indexPath = join$1(webDir, "index.html");
24982
24180
  if (existsSync(indexPath)) {
24983
24181
  const content = readFileSync(indexPath, "utf-8");