@pmate/cli 0.24.9 → 0.24.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9071,7 +9071,7 @@ __export(index_exports, {
9071
9071
  parseCommandArgs: () => parseCommandArgs
9072
9072
  });
9073
9073
  module.exports = __toCommonJS(index_exports);
9074
- var import_node_fs21 = require("fs");
9074
+ var import_node_fs22 = require("fs");
9075
9075
  var import_node_path26 = __toESM(require("path"));
9076
9076
  var import_chalk4 = __toESM(require("chalk"));
9077
9077
 
@@ -16052,8 +16052,85 @@ function pad2(value) {
16052
16052
  return String(value).padStart(2, "0");
16053
16053
  }
16054
16054
 
16055
- // src/commands/AgentCommandHandler.ts
16055
+ // src/commands/ChatRoomCommandHandler.ts
16056
16056
  var import_node_fs12 = require("fs");
16057
+ var ChatRoomCommandHandler = class {
16058
+ async handle(args) {
16059
+ const sdk = await loadChatSdk();
16060
+ if (args.action === "smoke") {
16061
+ await this.smoke(sdk, args);
16062
+ return;
16063
+ }
16064
+ const client = await this.connect(sdk, args.bot, args.app, args.hubUrl, args.authBaseUrl);
16065
+ try {
16066
+ switch (args.action) {
16067
+ case "join":
16068
+ client.watchMessages((message) => ui.plain(JSON.stringify(message)));
16069
+ ui.success("chat-room joined");
16070
+ return;
16071
+ case "request-friend":
16072
+ await client.requestFriend({ to: args.to, message: args.message });
16073
+ ui.success("friend request sent");
16074
+ return;
16075
+ case "accept-friend":
16076
+ await client.acceptFriend({ to: args.to, requestId: args.requestId, message: args.message });
16077
+ ui.success("friend request accepted");
16078
+ return;
16079
+ case "send":
16080
+ await client.sendDm({ to: args.to, text: args.text });
16081
+ ui.success("message sent");
16082
+ return;
16083
+ case "group-create":
16084
+ await client.createGroup({ groupId: args.groupId, members: args.members, title: args.title });
16085
+ ui.success("group created");
16086
+ return;
16087
+ case "group-send":
16088
+ await client.sendGroup({ groupId: args.groupId, text: args.text, recipients: args.recipients });
16089
+ ui.success("group message sent");
16090
+ return;
16091
+ }
16092
+ } finally {
16093
+ if (args.action !== "join") {
16094
+ client.close();
16095
+ }
16096
+ }
16097
+ }
16098
+ async smoke(sdk, args) {
16099
+ const a = await this.connect(sdk, args.botA, args.app, args.hubUrl, args.authBaseUrl);
16100
+ const b = await this.connect(sdk, args.botB, args.app, args.hubUrl, args.authBaseUrl);
16101
+ try {
16102
+ const botA = sdk.parsePmateBotKeyJson((0, import_node_fs12.readFileSync)(args.botA, "utf8"));
16103
+ const botB = sdk.parsePmateBotKeyJson((0, import_node_fs12.readFileSync)(args.botB, "utf8"));
16104
+ await a.requestFriend({ to: botB.name, message: "smoke friend request" });
16105
+ await b.acceptFriend({ to: botA.name, message: "smoke friend accept" });
16106
+ await a.sendDm({ to: botB.name, text: "smoke dm from a" });
16107
+ await b.sendDm({ to: botA.name, text: "smoke dm from b" });
16108
+ const groupId = `smoke-${Date.now()}`;
16109
+ await a.createGroup({ groupId, members: [botB.name], title: "Smoke Group" });
16110
+ await a.sendGroup({ groupId, text: "smoke group message", recipients: [botB.name] });
16111
+ ui.success("chat-room smoke passed");
16112
+ } finally {
16113
+ a.close();
16114
+ b.close();
16115
+ }
16116
+ }
16117
+ async connect(sdk, botPath, appId, hubUrl, authBaseUrl) {
16118
+ if (!botPath) {
16119
+ throw new Error("Missing required option: --bot");
16120
+ }
16121
+ const botKey = sdk.parsePmateBotKeyJson((0, import_node_fs12.readFileSync)(botPath, "utf8"));
16122
+ const client = sdk.createChatClient({ appId, botKey, hubUrl, authBaseUrl });
16123
+ await client.connect();
16124
+ return client;
16125
+ }
16126
+ };
16127
+ async function loadChatSdk() {
16128
+ const dynamicImport = new Function("specifier", "return import(specifier)");
16129
+ return await dynamicImport("@pmate/chat-sdk/runtime");
16130
+ }
16131
+
16132
+ // src/commands/AgentCommandHandler.ts
16133
+ var import_node_fs13 = require("fs");
16057
16134
  var import_node_path17 = __toESM(require("path"));
16058
16135
  init_AgentLlmClient();
16059
16136
  init_sessionStore();
@@ -16521,10 +16598,10 @@ var AgentCommandHandler = class {
16521
16598
  }
16522
16599
  readJsonFile(filePath) {
16523
16600
  const absolutePath = import_node_path17.default.resolve(process.cwd(), filePath);
16524
- if (!(0, import_node_fs12.existsSync)(absolutePath)) {
16601
+ if (!(0, import_node_fs13.existsSync)(absolutePath)) {
16525
16602
  throw new Error(`JSON file not found: ${absolutePath}`);
16526
16603
  }
16527
- const raw = (0, import_node_fs12.readFileSync)(absolutePath, "utf8");
16604
+ const raw = (0, import_node_fs13.readFileSync)(absolutePath, "utf8");
16528
16605
  try {
16529
16606
  return JSON.parse(raw);
16530
16607
  } catch (error) {
@@ -16619,7 +16696,7 @@ var AgentCommandHandler = class {
16619
16696
  };
16620
16697
 
16621
16698
  // src/commands/RunnerCommandHandler.ts
16622
- var import_node_fs13 = require("fs");
16699
+ var import_node_fs14 = require("fs");
16623
16700
  var import_node_path18 = __toESM(require("path"));
16624
16701
  init_sessionStore();
16625
16702
  init_namespacedRef();
@@ -16716,10 +16793,10 @@ var RunnerCommandHandler = class {
16716
16793
  }
16717
16794
  readJsonFile(filePath) {
16718
16795
  const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
16719
- if (!(0, import_node_fs13.existsSync)(absolutePath)) {
16796
+ if (!(0, import_node_fs14.existsSync)(absolutePath)) {
16720
16797
  throw new Error(`JSON file not found: ${absolutePath}`);
16721
16798
  }
16722
- const raw = (0, import_node_fs13.readFileSync)(absolutePath, "utf8");
16799
+ const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
16723
16800
  try {
16724
16801
  return JSON.parse(raw);
16725
16802
  } catch (error) {
@@ -16838,7 +16915,7 @@ var NsCommandHandler = class {
16838
16915
  };
16839
16916
 
16840
16917
  // src/commands/StoreCommandHandler.ts
16841
- var import_node_fs14 = require("fs");
16918
+ var import_node_fs15 = require("fs");
16842
16919
  var import_node_path19 = __toESM(require("path"));
16843
16920
  var StoreCommandHandler = class {
16844
16921
  async handle(args) {
@@ -16982,10 +17059,10 @@ var StoreCommandHandler = class {
16982
17059
  }
16983
17060
  readJsonFile(filePath) {
16984
17061
  const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
16985
- if (!(0, import_node_fs14.existsSync)(absolutePath)) {
17062
+ if (!(0, import_node_fs15.existsSync)(absolutePath)) {
16986
17063
  throw new Error(`JSON file not found: ${absolutePath}`);
16987
17064
  }
16988
- const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
17065
+ const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
16989
17066
  try {
16990
17067
  return JSON.parse(raw);
16991
17068
  } catch (error) {
@@ -17037,12 +17114,12 @@ var StoreCommandHandler = class {
17037
17114
  };
17038
17115
 
17039
17116
  // src/commands/AppCommandHandler.ts
17040
- var import_node_fs16 = require("fs");
17117
+ var import_node_fs17 = require("fs");
17041
17118
  var import_node_path21 = __toESM(require("path"));
17042
17119
  init_sessionStore();
17043
17120
 
17044
17121
  // src/appIcon.ts
17045
- var import_node_fs15 = require("fs");
17122
+ var import_node_fs16 = require("fs");
17046
17123
  var import_node_os7 = __toESM(require("os"));
17047
17124
  var import_node_path20 = __toESM(require("path"));
17048
17125
  var import_sharp = __toESM(require("sharp"));
@@ -17150,7 +17227,7 @@ function createAppIconExportPlans(input) {
17150
17227
  throw new Error("App icon preset export requires --out-dir.");
17151
17228
  }
17152
17229
  const outDir = import_node_path20.default.resolve(input.cwd, input.outDir);
17153
- (0, import_node_fs15.mkdirSync)(outDir, { recursive: true });
17230
+ (0, import_node_fs16.mkdirSync)(outDir, { recursive: true });
17154
17231
  return specs.map((spec) => ({
17155
17232
  width: spec.width,
17156
17233
  height: spec.height,
@@ -17169,7 +17246,7 @@ function createAppIconExportPlans(input) {
17169
17246
  throw new Error("Single-size app icon export requires --output.");
17170
17247
  }
17171
17248
  const resolvedOutput = import_node_path20.default.resolve(input.cwd, input.output);
17172
- (0, import_node_fs15.mkdirSync)(import_node_path20.default.dirname(resolvedOutput), { recursive: true });
17249
+ (0, import_node_fs16.mkdirSync)(import_node_path20.default.dirname(resolvedOutput), { recursive: true });
17173
17250
  return [
17174
17251
  {
17175
17252
  width: input.width,
@@ -17183,7 +17260,7 @@ async function exportAppIcon(icon, plans) {
17183
17260
  const svg = await resolveAppIconSvg(icon);
17184
17261
  for (const plan of plans) {
17185
17262
  const bytes = await renderAppIcon(svg, plan.width, plan.height, plan.format);
17186
- (0, import_node_fs15.writeFileSync)(plan.outputPath, bytes);
17263
+ (0, import_node_fs16.writeFileSync)(plan.outputPath, bytes);
17187
17264
  }
17188
17265
  }
17189
17266
  async function renderAppIconVariant(input) {
@@ -17192,8 +17269,8 @@ async function renderAppIconVariant(input) {
17192
17269
  let outputPath;
17193
17270
  if (input.output) {
17194
17271
  outputPath = import_node_path20.default.resolve(input.cwd, input.output);
17195
- (0, import_node_fs15.mkdirSync)(import_node_path20.default.dirname(outputPath), { recursive: true });
17196
- (0, import_node_fs15.writeFileSync)(outputPath, bytes);
17272
+ (0, import_node_fs16.mkdirSync)(import_node_path20.default.dirname(outputPath), { recursive: true });
17273
+ (0, import_node_fs16.writeFileSync)(outputPath, bytes);
17197
17274
  }
17198
17275
  if (input.name) {
17199
17276
  return {
@@ -17223,7 +17300,7 @@ async function loadAppIconVariantFile(input) {
17223
17300
  name: input.name,
17224
17301
  format,
17225
17302
  sourcePath: absolutePath
17226
- }) : createImageDataUrl((0, import_node_fs15.readFileSync)(absolutePath), format),
17303
+ }) : createImageDataUrl((0, import_node_fs16.readFileSync)(absolutePath), format),
17227
17304
  format,
17228
17305
  absolutePath
17229
17306
  };
@@ -17353,7 +17430,7 @@ async function uploadAppIconVariantAsset(input) {
17353
17430
  await AliyunService.uploadFile(sourcePath, DEFAULT_APP_ICON_VARIANT_BUCKET, objectKey);
17354
17431
  } finally {
17355
17432
  if (shouldCleanup) {
17356
- (0, import_node_fs15.rmSync)(import_node_path20.default.dirname(sourcePath), { recursive: true, force: true });
17433
+ (0, import_node_fs16.rmSync)(import_node_path20.default.dirname(sourcePath), { recursive: true, force: true });
17357
17434
  }
17358
17435
  }
17359
17436
  return `${DEFAULT_APP_ICON_VARIANT_PUBLIC_BASE_URL}/${objectKey}`;
@@ -17398,9 +17475,9 @@ function writeTempAppIconVariantFile(objectKey, format, bytes) {
17398
17475
  if (!bytes) {
17399
17476
  throw new Error("App icon variant upload requires bytes or a source file.");
17400
17477
  }
17401
- const tempDir = (0, import_node_fs15.mkdtempSync)(import_node_path20.default.join(import_node_os7.default.tmpdir(), "pmate-app-icon-"));
17478
+ const tempDir = (0, import_node_fs16.mkdtempSync)(import_node_path20.default.join(import_node_os7.default.tmpdir(), "pmate-app-icon-"));
17402
17479
  const tempPath = import_node_path20.default.join(tempDir, import_node_path20.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
17403
- (0, import_node_fs15.writeFileSync)(tempPath, bytes);
17480
+ (0, import_node_fs16.writeFileSync)(tempPath, bytes);
17404
17481
  return tempPath;
17405
17482
  }
17406
17483
 
@@ -17609,10 +17686,10 @@ var AppCommandHandler = class {
17609
17686
  }
17610
17687
  readJsonFile(filePath) {
17611
17688
  const absolutePath = this.resolveFilePath(filePath);
17612
- if (!(0, import_node_fs16.existsSync)(absolutePath)) {
17689
+ if (!(0, import_node_fs17.existsSync)(absolutePath)) {
17613
17690
  throw new Error(`JSON file not found: ${absolutePath}`);
17614
17691
  }
17615
- const raw = (0, import_node_fs16.readFileSync)(absolutePath, "utf8");
17692
+ const raw = (0, import_node_fs17.readFileSync)(absolutePath, "utf8");
17616
17693
  try {
17617
17694
  return JSON.parse(raw);
17618
17695
  } catch (error) {
@@ -17742,13 +17819,13 @@ function readNamespaceFromPayload(payload) {
17742
17819
  }
17743
17820
 
17744
17821
  // src/commands/ServiceCommandHandler.ts
17745
- var import_node_fs18 = require("fs");
17822
+ var import_node_fs19 = require("fs");
17746
17823
  var import_promises5 = require("fs/promises");
17747
17824
  var import_node_path23 = __toESM(require("path"));
17748
17825
  var import_promises6 = require("readline/promises");
17749
17826
 
17750
17827
  // src/services/ServiceRuntimeRunner.ts
17751
- var import_node_fs17 = require("fs");
17828
+ var import_node_fs18 = require("fs");
17752
17829
  var import_node_os8 = __toESM(require("os"));
17753
17830
  var import_node_path22 = __toESM(require("path"));
17754
17831
  var import_node_child_process10 = require("child_process");
@@ -18137,7 +18214,7 @@ var ServiceRuntimeRunner = class {
18137
18214
  import_node_path22.default.join(import_node_os8.default.homedir(), "dev", "pmate-envs", repoName)
18138
18215
  ];
18139
18216
  for (const candidate of candidates) {
18140
- if ((0, import_node_fs17.existsSync)(candidate)) {
18217
+ if ((0, import_node_fs18.existsSync)(candidate)) {
18141
18218
  return candidate;
18142
18219
  }
18143
18220
  }
@@ -18156,7 +18233,7 @@ var ServiceRuntimeRunner = class {
18156
18233
  async deployVite(service, options) {
18157
18234
  const appDir = this.resolveLocalDir(service, options.cwd);
18158
18235
  const packageJsonPath = import_node_path22.default.join(appDir, "package.json");
18159
- if (!(0, import_node_fs17.existsSync)(packageJsonPath)) {
18236
+ if (!(0, import_node_fs18.existsSync)(packageJsonPath)) {
18160
18237
  throw new Error(`No package.json found at ${packageJsonPath}`);
18161
18238
  }
18162
18239
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -18166,7 +18243,7 @@ var ServiceRuntimeRunner = class {
18166
18243
  }
18167
18244
  await this.runCommand("pnpm", ["--filter", pkgName, "build"], this.resolveRepoRoot(service, options.cwd));
18168
18245
  const distDir = import_node_path22.default.join(appDir, "dist");
18169
- if (!(0, import_node_fs17.existsSync)(distDir)) {
18246
+ if (!(0, import_node_fs18.existsSync)(distDir)) {
18170
18247
  throw new Error(`No dist directory found at ${distDir}`);
18171
18248
  }
18172
18249
  const site = this.getSite(service);
@@ -18179,7 +18256,7 @@ var ServiceRuntimeRunner = class {
18179
18256
  async deployStatic(service, options) {
18180
18257
  const appDir = this.resolveLocalDir(service, options.cwd);
18181
18258
  const srcDir = import_node_path22.default.join(appDir, "src");
18182
- if (!(0, import_node_fs17.existsSync)(srcDir)) {
18259
+ if (!(0, import_node_fs18.existsSync)(srcDir)) {
18183
18260
  throw new Error(`No src directory found at ${srcDir}`);
18184
18261
  }
18185
18262
  const site = this.getSite(service);
@@ -18195,7 +18272,7 @@ var ServiceRuntimeRunner = class {
18195
18272
  const repoRoot = this.resolveRepoRoot(service);
18196
18273
  const appDir = this.resolveLocalDir(service);
18197
18274
  const packageJsonPath = import_node_path22.default.join(appDir, "package.json");
18198
- if (!(0, import_node_fs17.existsSync)(packageJsonPath)) {
18275
+ if (!(0, import_node_fs18.existsSync)(packageJsonPath)) {
18199
18276
  throw new Error(`No package.json found at ${packageJsonPath}`);
18200
18277
  }
18201
18278
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -18249,14 +18326,14 @@ var ServiceRuntimeRunner = class {
18249
18326
  const appDir = this.resolveLocalDir(service, options.cwd);
18250
18327
  await this.ensurePnpmWorkspaceRoot(repoRoot);
18251
18328
  const configPath = import_node_path22.default.join(appDir, fc.configFile ?? "s.yaml");
18252
- if (!(0, import_node_fs17.existsSync)(configPath)) {
18329
+ if (!(0, import_node_fs18.existsSync)(configPath)) {
18253
18330
  throw new Error(`Missing FC config file at ${configPath}`);
18254
18331
  }
18255
18332
  const packageJsonPath = import_node_path22.default.join(appDir, "package.json");
18256
- if (!(0, import_node_fs17.existsSync)(packageJsonPath)) {
18333
+ if (!(0, import_node_fs18.existsSync)(packageJsonPath)) {
18257
18334
  throw new Error(`No package.json found at ${packageJsonPath}`);
18258
18335
  }
18259
- const rawConfig = (0, import_node_fs17.readFileSync)(configPath, "utf8");
18336
+ const rawConfig = (0, import_node_fs18.readFileSync)(configPath, "utf8");
18260
18337
  if (!rawConfig.includes(fc.functionName)) {
18261
18338
  throw new Error(`FC config ${configPath} does not mention functionName ${fc.functionName}`);
18262
18339
  }
@@ -18444,7 +18521,7 @@ var ServiceRuntimeRunner = class {
18444
18521
  const serverAddress = await resolveServerAddress(server);
18445
18522
  const templateName = exposeType === "websocket" ? "nginx.ws.template" : "nginx.rest.template";
18446
18523
  const templatePath = this.resolveTemplatePath(templateName);
18447
- const template = (0, import_node_fs17.readFileSync)(templatePath, "utf8");
18524
+ const template = (0, import_node_fs18.readFileSync)(templatePath, "utf8");
18448
18525
  const host = `${subdomain}.${("domain" in network ? network.domain?.trim() : void 0) || "pmate.chat"}`;
18449
18526
  const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
18450
18527
  const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
@@ -18477,10 +18554,10 @@ var ServiceRuntimeRunner = class {
18477
18554
  if (config.ensurePackageJson) {
18478
18555
  const appDir = this.resolveLocalDir(service, options.cwd);
18479
18556
  const packageJsonPath = import_node_path22.default.join(appDir, "package.json");
18480
- if (!(0, import_node_fs17.existsSync)(packageJsonPath)) {
18557
+ if (!(0, import_node_fs18.existsSync)(packageJsonPath)) {
18481
18558
  throw new Error(`Missing package.json at ${packageJsonPath}`);
18482
18559
  }
18483
- const pkgStat = (0, import_node_fs17.statSync)(packageJsonPath);
18560
+ const pkgStat = (0, import_node_fs18.statSync)(packageJsonPath);
18484
18561
  if (!pkgStat.isFile()) {
18485
18562
  throw new Error(`package.json is not a file at ${packageJsonPath}`);
18486
18563
  }
@@ -18954,7 +19031,7 @@ var ServiceRuntimeRunner = class {
18954
19031
  import_node_path22.default.join(__dirname, "templates", templateName)
18955
19032
  ];
18956
19033
  for (const candidate of candidates) {
18957
- if ((0, import_node_fs17.existsSync)(candidate)) {
19034
+ if ((0, import_node_fs18.existsSync)(candidate)) {
18958
19035
  return candidate;
18959
19036
  }
18960
19037
  }
@@ -18986,7 +19063,7 @@ var ServiceRuntimeRunner = class {
18986
19063
  });
18987
19064
  }
18988
19065
  loadPackageJson(packageJsonPath) {
18989
- const raw = (0, import_node_fs17.readFileSync)(packageJsonPath, "utf8");
19066
+ const raw = (0, import_node_fs18.readFileSync)(packageJsonPath, "utf8");
18990
19067
  const parsed = JSON.parse(raw);
18991
19068
  if (!parsed || typeof parsed !== "object") {
18992
19069
  throw new Error(`Invalid package.json at ${packageJsonPath}`);
@@ -18995,7 +19072,7 @@ var ServiceRuntimeRunner = class {
18995
19072
  }
18996
19073
  writePackageJson(packageJsonPath, data) {
18997
19074
  const serialized = JSON.stringify(data, null, 2);
18998
- (0, import_node_fs17.writeFileSync)(packageJsonPath, `${serialized}
19075
+ (0, import_node_fs18.writeFileSync)(packageJsonPath, `${serialized}
18999
19076
  `, "utf8");
19000
19077
  }
19001
19078
  validateFcConfig(service, fc) {
@@ -19023,7 +19100,7 @@ var ServiceRuntimeRunner = class {
19023
19100
  }
19024
19101
  async ensurePnpmWorkspaceRoot(repoRoot) {
19025
19102
  const workspacePath = import_node_path22.default.join(repoRoot, "pnpm-workspace.yaml");
19026
- if (!(0, import_node_fs17.existsSync)(workspacePath)) {
19103
+ if (!(0, import_node_fs18.existsSync)(workspacePath)) {
19027
19104
  throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
19028
19105
  }
19029
19106
  }
@@ -19092,16 +19169,16 @@ var ServiceRuntimeRunner = class {
19092
19169
  if (!privateKeyPath) {
19093
19170
  throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
19094
19171
  }
19095
- if (!(0, import_node_fs17.existsSync)(certificatePath)) {
19172
+ if (!(0, import_node_fs18.existsSync)(certificatePath)) {
19096
19173
  throw new Error(`SSL certificate file not found: ${certificatePath}`);
19097
19174
  }
19098
- if (!(0, import_node_fs17.existsSync)(privateKeyPath)) {
19175
+ if (!(0, import_node_fs18.existsSync)(privateKeyPath)) {
19099
19176
  throw new Error(`SSL private key file not found: ${privateKeyPath}`);
19100
19177
  }
19101
19178
  return {
19102
19179
  certName: host,
19103
- certificate: (0, import_node_fs17.readFileSync)(certificatePath, "utf8"),
19104
- privateKey: (0, import_node_fs17.readFileSync)(privateKeyPath, "utf8")
19180
+ certificate: (0, import_node_fs18.readFileSync)(certificatePath, "utf8"),
19181
+ privateKey: (0, import_node_fs18.readFileSync)(privateKeyPath, "utf8")
19105
19182
  };
19106
19183
  }
19107
19184
  resolveFcProtocol(fc, certConfig) {
@@ -19454,10 +19531,10 @@ var ServiceCommandHandler = class {
19454
19531
  }
19455
19532
  readJsonFile(filePath) {
19456
19533
  const absolutePath = import_node_path23.default.resolve(process.cwd(), filePath);
19457
- if (!(0, import_node_fs18.existsSync)(absolutePath)) {
19534
+ if (!(0, import_node_fs19.existsSync)(absolutePath)) {
19458
19535
  throw new Error(`JSON file not found: ${absolutePath}`);
19459
19536
  }
19460
- const raw = (0, import_node_fs18.readFileSync)(absolutePath, "utf8");
19537
+ const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
19461
19538
  try {
19462
19539
  return JSON.parse(raw);
19463
19540
  } catch (error) {
@@ -19839,7 +19916,7 @@ var RoleCommandHandler = class {
19839
19916
  };
19840
19917
 
19841
19918
  // src/commands/AccountCommandHandler.ts
19842
- var import_node_fs19 = require("fs");
19919
+ var import_node_fs20 = require("fs");
19843
19920
  var import_node_crypto4 = require("crypto");
19844
19921
  var import_node_path24 = __toESM(require("path"));
19845
19922
  init_sessionStore();
@@ -19850,8 +19927,8 @@ var AccountCommandHandler = class {
19850
19927
  const keyFile = this.generateBotKeyFile(args.app, args.name);
19851
19928
  if (args.out) {
19852
19929
  const outPath = this.resolveFilePath(args.out);
19853
- (0, import_node_fs19.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
19854
- (0, import_node_fs19.chmodSync)(outPath, 384);
19930
+ (0, import_node_fs20.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
19931
+ (0, import_node_fs20.chmodSync)(outPath, 384);
19855
19932
  if (!args.json) {
19856
19933
  ui.success(`Bot key saved to ${outPath}`);
19857
19934
  }
@@ -20296,10 +20373,10 @@ var AccountCommandHandler = class {
20296
20373
  throw new Error("Missing visible apps input");
20297
20374
  }
20298
20375
  const absolutePath = this.resolveFilePath(args.filePath);
20299
- if (!(0, import_node_fs19.existsSync)(absolutePath)) {
20376
+ if (!(0, import_node_fs20.existsSync)(absolutePath)) {
20300
20377
  throw new Error(`JSON file not found: ${absolutePath}`);
20301
20378
  }
20302
- const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
20379
+ const raw = (0, import_node_fs20.readFileSync)(absolutePath, "utf8");
20303
20380
  let parsed;
20304
20381
  try {
20305
20382
  parsed = JSON.parse(raw);
@@ -20333,10 +20410,10 @@ var AccountCommandHandler = class {
20333
20410
  throw new Error("Missing bot key file");
20334
20411
  }
20335
20412
  const absolutePath = this.resolveFilePath(filePath);
20336
- if (!(0, import_node_fs19.existsSync)(absolutePath)) {
20413
+ if (!(0, import_node_fs20.existsSync)(absolutePath)) {
20337
20414
  throw new Error(`Bot key file not found: ${absolutePath}`);
20338
20415
  }
20339
- const parsed = JSON.parse((0, import_node_fs19.readFileSync)(absolutePath, "utf8"));
20416
+ const parsed = JSON.parse((0, import_node_fs20.readFileSync)(absolutePath, "utf8"));
20340
20417
  if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
20341
20418
  throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
20342
20419
  }
@@ -20388,7 +20465,7 @@ function encodePathSegment(value) {
20388
20465
  }
20389
20466
 
20390
20467
  // src/commands/OrgCommandHandler.ts
20391
- var import_node_fs20 = require("fs");
20468
+ var import_node_fs21 = require("fs");
20392
20469
  var import_node_path25 = __toESM(require("path"));
20393
20470
  init_sessionStore();
20394
20471
  var OrgCommandHandler = class {
@@ -20561,10 +20638,10 @@ var OrgCommandHandler = class {
20561
20638
  throw new Error(`Missing ${itemLabel} input`);
20562
20639
  }
20563
20640
  const absolutePath = import_node_path25.default.resolve(process.cwd(), filePath);
20564
- if (!(0, import_node_fs20.existsSync)(absolutePath)) {
20641
+ if (!(0, import_node_fs21.existsSync)(absolutePath)) {
20565
20642
  throw new Error(`JSON file not found: ${absolutePath}`);
20566
20643
  }
20567
- const raw = (0, import_node_fs20.readFileSync)(absolutePath, "utf8");
20644
+ const raw = (0, import_node_fs21.readFileSync)(absolutePath, "utf8");
20568
20645
  let parsed;
20569
20646
  try {
20570
20647
  parsed = JSON.parse(raw);
@@ -23252,6 +23329,135 @@ function requireValue10(tokens, optionName) {
23252
23329
  return value;
23253
23330
  }
23254
23331
 
23332
+ // src/chatRoomCommandParser.ts
23333
+ function parseChatRoomArgs(tokens) {
23334
+ const rest = [...tokens];
23335
+ const action = rest.shift();
23336
+ if (!action) {
23337
+ throw new Error("Usage: chat-room <join|request-friend|accept-friend|send|group-create|group-send|smoke>");
23338
+ }
23339
+ const parsed = parseShared(rest);
23340
+ const { options, multiOptions, ...shared } = parsed;
23341
+ switch (action) {
23342
+ case "smoke":
23343
+ return {
23344
+ type: "chat-room" /* ChatRoom */,
23345
+ action,
23346
+ botA: requiredOption(options, "--bot-a"),
23347
+ botB: requiredOption(options, "--bot-b"),
23348
+ app: shared.app,
23349
+ hubUrl: shared.hubUrl,
23350
+ authBaseUrl: shared.authBaseUrl
23351
+ };
23352
+ case "join":
23353
+ return { type: "chat-room" /* ChatRoom */, action, ...withBot(shared, options) };
23354
+ case "request-friend":
23355
+ return {
23356
+ type: "chat-room" /* ChatRoom */,
23357
+ action,
23358
+ ...withBot(shared, options),
23359
+ to: requiredOption(options, "--to"),
23360
+ message: options.get("--message")
23361
+ };
23362
+ case "accept-friend":
23363
+ return {
23364
+ type: "chat-room" /* ChatRoom */,
23365
+ action,
23366
+ ...withBot(shared, options),
23367
+ to: requiredOption(options, "--to"),
23368
+ requestId: options.get("--request-id"),
23369
+ message: options.get("--message")
23370
+ };
23371
+ case "send":
23372
+ return {
23373
+ type: "chat-room" /* ChatRoom */,
23374
+ action,
23375
+ ...withBot(shared, options),
23376
+ to: requiredOption(options, "--to"),
23377
+ text: requiredOption(options, "--text")
23378
+ };
23379
+ case "group-create":
23380
+ return {
23381
+ type: "chat-room" /* ChatRoom */,
23382
+ action,
23383
+ ...withBot(shared, options),
23384
+ groupId: requiredOption(options, "--group"),
23385
+ members: multiOptions.get("--member") ?? [],
23386
+ title: options.get("--title")
23387
+ };
23388
+ case "group-send":
23389
+ return {
23390
+ type: "chat-room" /* ChatRoom */,
23391
+ action,
23392
+ ...withBot(shared, options),
23393
+ groupId: requiredOption(options, "--group"),
23394
+ text: requiredOption(options, "--text"),
23395
+ recipients: multiOptions.get("--recipient")
23396
+ };
23397
+ default:
23398
+ throw new Error(`Unknown chat-room action: ${action}`);
23399
+ }
23400
+ }
23401
+ function withBot(shared, options) {
23402
+ return { ...shared, bot: requiredOption(options, "--bot") };
23403
+ }
23404
+ function parseShared(tokens) {
23405
+ const options = /* @__PURE__ */ new Map();
23406
+ const multiOptions = /* @__PURE__ */ new Map();
23407
+ while (tokens.length > 0) {
23408
+ const token = tokens.shift();
23409
+ switch (token) {
23410
+ case "--bot":
23411
+ case "--app":
23412
+ case "--hub-url":
23413
+ case "--auth-base-url":
23414
+ case "--to":
23415
+ case "--message":
23416
+ case "--request-id":
23417
+ case "--text":
23418
+ case "--group":
23419
+ case "--title":
23420
+ case "--bot-a":
23421
+ case "--bot-b":
23422
+ options.set(token, requireValue11(tokens, token));
23423
+ break;
23424
+ case "--member":
23425
+ case "--recipient": {
23426
+ const values = multiOptions.get(token) ?? [];
23427
+ values.push(requireValue11(tokens, token));
23428
+ multiOptions.set(token, values);
23429
+ break;
23430
+ }
23431
+ default:
23432
+ throw new Error(`Unknown chat-room option: ${token}`);
23433
+ }
23434
+ }
23435
+ const app = requiredOption(options, "--app");
23436
+ const bot = options.get("--bot");
23437
+ return {
23438
+ bot,
23439
+ app,
23440
+ hubUrl: options.get("--hub-url"),
23441
+ authBaseUrl: options.get("--auth-base-url"),
23442
+ options,
23443
+ multiOptions
23444
+ };
23445
+ }
23446
+ function requiredOption(options, option) {
23447
+ const value = options.get(option);
23448
+ if (!value) {
23449
+ throw new Error(`Missing required option: ${option}`);
23450
+ }
23451
+ return value;
23452
+ }
23453
+ function requireValue11(tokens, option) {
23454
+ const value = tokens.shift();
23455
+ if (!value || value.startsWith("--")) {
23456
+ throw new Error(`Missing value for ${option}`);
23457
+ }
23458
+ return value;
23459
+ }
23460
+
23255
23461
  // src/prepareDevCommandParser.ts
23256
23462
  function parsePrepareDevArgs(tokens) {
23257
23463
  const rest = [...tokens];
@@ -23279,7 +23485,7 @@ function parsePrepareDevArgs(tokens) {
23279
23485
  close = true;
23280
23486
  break;
23281
23487
  case "--env": {
23282
- const rawValue = requireValue11(rest, token);
23488
+ const rawValue = requireValue12(rest, token);
23283
23489
  const parsed = Number.parseInt(rawValue, 10);
23284
23490
  if (!Number.isInteger(parsed) || parsed < 0) {
23285
23491
  throw new Error(`Invalid --env value: ${rawValue}`);
@@ -23288,13 +23494,13 @@ function parsePrepareDevArgs(tokens) {
23288
23494
  break;
23289
23495
  }
23290
23496
  case "--env-root":
23291
- envRoot = requireValue11(rest, token);
23497
+ envRoot = requireValue12(rest, token);
23292
23498
  break;
23293
23499
  case "--base-root":
23294
- baseRoot = requireValue11(rest, token);
23500
+ baseRoot = requireValue12(rest, token);
23295
23501
  break;
23296
23502
  case "--note":
23297
- note = requireValue11(rest, token);
23503
+ note = requireValue12(rest, token);
23298
23504
  break;
23299
23505
  case "--json":
23300
23506
  json = true;
@@ -23330,7 +23536,7 @@ function parsePrepareDevArgs(tokens) {
23330
23536
  json
23331
23537
  };
23332
23538
  }
23333
- function requireValue11(tokens, option) {
23539
+ function requireValue12(tokens, option) {
23334
23540
  const value = tokens.shift();
23335
23541
  if (!value || value.startsWith("-")) {
23336
23542
  throw new Error(`Missing value for ${option}`);
@@ -23340,7 +23546,7 @@ function requireValue11(tokens, option) {
23340
23546
 
23341
23547
  // src/index.ts
23342
23548
  var pkg = JSON.parse(
23343
- (0, import_node_fs21.readFileSync)(import_node_path26.default.resolve(__dirname, "..", "package.json"), "utf8")
23549
+ (0, import_node_fs22.readFileSync)(import_node_path26.default.resolve(__dirname, "..", "package.json"), "utf8")
23344
23550
  );
23345
23551
  var HELP_TEXT = [
23346
23552
  import_chalk4.default.bold(`pmate v${pkg.version}`),
@@ -23423,6 +23629,8 @@ var HELP_TEXT = [
23423
23629
  ` ${import_chalk4.default.gray(" --easy [--words <n>] [--digits <n>] [--separator <s>] [--count <n>]")}`,
23424
23630
  ` ${import_chalk4.default.cyan("collect")} Collect threads/messages from Electron chat app via CDP`,
23425
23631
  ` ${import_chalk4.default.gray(" sync (--source <cc|yelling> | --endpoint <url>)")}`,
23632
+ ` ${import_chalk4.default.cyan("chat-room")} Run social chat regression commands with PMate bot key JSON`,
23633
+ ` ${import_chalk4.default.gray(" join|request-friend|accept-friend|send|group-create|group-send|smoke --app <ns:app> --bot <file>")}`,
23426
23634
  ` ${import_chalk4.default.cyan("agent")} Manage agent registry entries and call agents for debugging`,
23427
23635
  ` ${import_chalk4.default.gray(" namespaces [--base-url <url>] [--json]")}`,
23428
23636
  ` ${import_chalk4.default.gray(" list [--namespace <ns>] [--base-url <url>] [--json]")}`,
@@ -23578,7 +23786,7 @@ function parseCommandArgs(args) {
23578
23786
  const token = rest.shift();
23579
23787
  switch (token) {
23580
23788
  case "--app":
23581
- app = requireValue12(rest, token);
23789
+ app = requireValue13(rest, token);
23582
23790
  break;
23583
23791
  default:
23584
23792
  throw new Error(`Unknown login option: ${token}`);
@@ -23640,6 +23848,9 @@ function parseCommandArgs(args) {
23640
23848
  if (args.rest[0] === "collect") {
23641
23849
  return parseCollectArgs(args.rest.slice(1));
23642
23850
  }
23851
+ if (args.rest[0] === "chat-room") {
23852
+ return parseChatRoomArgs(args.rest.slice(1));
23853
+ }
23643
23854
  if (args.rest[0] === "agent") {
23644
23855
  return parseAgentArgs(args.rest.slice(1));
23645
23856
  }
@@ -23684,7 +23895,7 @@ function parseVercelArgs(tokens) {
23684
23895
  const token = rest.shift();
23685
23896
  switch (token) {
23686
23897
  case "--scope":
23687
- scope = requireValue12(rest, token);
23898
+ scope = requireValue13(rest, token);
23688
23899
  break;
23689
23900
  default:
23690
23901
  throw new Error(`Unknown vercel option: ${token}`);
@@ -23704,10 +23915,10 @@ function parseVercelArgs(tokens) {
23704
23915
  const token = rest.shift();
23705
23916
  switch (token) {
23706
23917
  case "--scope":
23707
- scope = requireValue12(rest, token);
23918
+ scope = requireValue13(rest, token);
23708
23919
  break;
23709
23920
  case "--project":
23710
- project = requireValue12(rest, token);
23921
+ project = requireValue13(rest, token);
23711
23922
  break;
23712
23923
  case "--last-week":
23713
23924
  lastWeek = true;
@@ -23738,16 +23949,16 @@ function parseAddDnsArgs(tokens) {
23738
23949
  const token = rest.shift();
23739
23950
  switch (token) {
23740
23951
  case "--type":
23741
- options.dnsType = requireValue12(rest, token);
23952
+ options.dnsType = requireValue13(rest, token);
23742
23953
  break;
23743
23954
  case "--value":
23744
- options.dnsValue = requireValue12(rest, token);
23955
+ options.dnsValue = requireValue13(rest, token);
23745
23956
  break;
23746
23957
  case "--rr":
23747
- options.dnsRr = requireValue12(rest, token);
23958
+ options.dnsRr = requireValue13(rest, token);
23748
23959
  break;
23749
23960
  case "--ttl": {
23750
- const ttlValue = requireValue12(rest, token);
23961
+ const ttlValue = requireValue13(rest, token);
23751
23962
  const ttl = Number.parseInt(ttlValue, 10);
23752
23963
  if (!Number.isFinite(ttl) || ttl <= 0) {
23753
23964
  throw new Error(`Invalid --ttl value: ${ttlValue}`);
@@ -23756,7 +23967,7 @@ function parseAddDnsArgs(tokens) {
23756
23967
  break;
23757
23968
  }
23758
23969
  case "--domain":
23759
- options.dnsDomain = requireValue12(rest, token);
23970
+ options.dnsDomain = requireValue13(rest, token);
23760
23971
  break;
23761
23972
  default:
23762
23973
  throw new Error(`Unknown add-dns option: ${token}`);
@@ -23789,13 +24000,13 @@ function parseBucketArgs(tokens) {
23789
24000
  options.bucketCreate = true;
23790
24001
  break;
23791
24002
  case "--name":
23792
- options.bucketName = requireValue12(rest, token);
24003
+ options.bucketName = requireValue13(rest, token);
23793
24004
  break;
23794
24005
  case "--subdomain":
23795
- options.bucketSubdomain = requireValue12(rest, token);
24006
+ options.bucketSubdomain = requireValue13(rest, token);
23796
24007
  break;
23797
24008
  case "--domain":
23798
- options.bucketDomain = requireValue12(rest, token);
24009
+ options.bucketDomain = requireValue13(rest, token);
23799
24010
  break;
23800
24011
  default:
23801
24012
  throw new Error(`Unknown bucket option: ${token}`);
@@ -23827,7 +24038,7 @@ function parseDevArgs(tokens) {
23827
24038
  const token = rest.shift();
23828
24039
  switch (token) {
23829
24040
  case "--cwd":
23830
- options.devCwd = requireValue12(rest, token);
24041
+ options.devCwd = requireValue13(rest, token);
23831
24042
  break;
23832
24043
  default:
23833
24044
  throw new Error(`Unknown dev option: ${token}`);
@@ -23847,7 +24058,7 @@ function parseDeleteArgs(tokens) {
23847
24058
  const token = rest.shift();
23848
24059
  switch (token) {
23849
24060
  case "--cwd":
23850
- deleteCwd = requireValue12(rest, token);
24061
+ deleteCwd = requireValue13(rest, token);
23851
24062
  break;
23852
24063
  default:
23853
24064
  throw new Error(`Unknown delete option: ${token}`);
@@ -23881,13 +24092,13 @@ function parseOssArgs(tokens) {
23881
24092
  const token = rest.shift();
23882
24093
  switch (token) {
23883
24094
  case "--bucket":
23884
- bucket = requireValue12(rest, token);
24095
+ bucket = requireValue13(rest, token);
23885
24096
  break;
23886
24097
  case "--file":
23887
- filePath = requireValue12(rest, token);
24098
+ filePath = requireValue13(rest, token);
23888
24099
  break;
23889
24100
  case "--key":
23890
- objectKey = requireValue12(rest, token);
24101
+ objectKey = requireValue13(rest, token);
23891
24102
  break;
23892
24103
  default:
23893
24104
  throw new Error(`Unknown oss option: ${token}`);
@@ -23920,7 +24131,7 @@ function parseEnvArgs(tokens) {
23920
24131
  throw new Error("Only one env action is allowed.");
23921
24132
  }
23922
24133
  action = "set";
23923
- key = requireValue12(rest, token);
24134
+ key = requireValue13(rest, token);
23924
24135
  break;
23925
24136
  case "--list":
23926
24137
  if (action) {
@@ -23933,17 +24144,17 @@ function parseEnvArgs(tokens) {
23933
24144
  throw new Error("Only one env action is allowed.");
23934
24145
  }
23935
24146
  action = "delete";
23936
- key = requireValue12(rest, token);
24147
+ key = requireValue13(rest, token);
23937
24148
  break;
23938
24149
  case "--value":
23939
- value = requireValue12(rest, token);
24150
+ value = requireValue13(rest, token);
23940
24151
  break;
23941
24152
  case "--verbose":
23942
24153
  case "-v":
23943
24154
  verbose = true;
23944
24155
  break;
23945
24156
  case "--cwd":
23946
- cwd = requireValue12(rest, token);
24157
+ cwd = requireValue13(rest, token);
23947
24158
  break;
23948
24159
  default:
23949
24160
  throw new Error(`Unknown env option: ${token}`);
@@ -24001,7 +24212,7 @@ function parseCommitArgs(tokens) {
24001
24212
  push = true;
24002
24213
  break;
24003
24214
  case "--cwd":
24004
- cwd = requireValue12(rest, token);
24215
+ cwd = requireValue13(rest, token);
24005
24216
  break;
24006
24217
  default:
24007
24218
  throw new Error(`Unknown commit option: ${token}`);
@@ -24017,10 +24228,10 @@ function parseSummaryArgs(tokens) {
24017
24228
  const token = rest.shift();
24018
24229
  switch (token) {
24019
24230
  case "--pr":
24020
- prRef = requireValue12(rest, token);
24231
+ prRef = requireValue13(rest, token);
24021
24232
  break;
24022
24233
  case "--cwd":
24023
- cwd = requireValue12(rest, token);
24234
+ cwd = requireValue13(rest, token);
24024
24235
  break;
24025
24236
  default:
24026
24237
  throw new Error(`Unknown summary option: ${token}`);
@@ -24045,13 +24256,13 @@ function parseQuizArgs(tokens) {
24045
24256
  const token = rest.shift();
24046
24257
  switch (token) {
24047
24258
  case "--paper-id":
24048
- paperId = requireValue12(rest, token);
24259
+ paperId = requireValue13(rest, token);
24049
24260
  break;
24050
24261
  case "--base-url":
24051
- apiBaseUrl = requireValue12(rest, token);
24262
+ apiBaseUrl = requireValue13(rest, token);
24052
24263
  break;
24053
24264
  case "--link-base":
24054
- linkBaseUrl = requireValue12(rest, token);
24265
+ linkBaseUrl = requireValue13(rest, token);
24055
24266
  break;
24056
24267
  default:
24057
24268
  throw new Error(`Unknown quiz create-draft option: ${token}`);
@@ -24077,16 +24288,16 @@ function parseQuizArgs(tokens) {
24077
24288
  const token = rest.shift();
24078
24289
  switch (token) {
24079
24290
  case "--paper-id":
24080
- paperId = requireValue12(rest, token);
24291
+ paperId = requireValue13(rest, token);
24081
24292
  break;
24082
24293
  case "--file":
24083
- filePath = requireValue12(rest, token);
24294
+ filePath = requireValue13(rest, token);
24084
24295
  break;
24085
24296
  case "--base-url":
24086
- apiBaseUrl = requireValue12(rest, token);
24297
+ apiBaseUrl = requireValue13(rest, token);
24087
24298
  break;
24088
24299
  case "--link-base":
24089
- linkBaseUrl = requireValue12(rest, token);
24300
+ linkBaseUrl = requireValue13(rest, token);
24090
24301
  break;
24091
24302
  default:
24092
24303
  throw new Error(`Unknown quiz update-meta option: ${token}`);
@@ -24116,16 +24327,16 @@ function parseQuizArgs(tokens) {
24116
24327
  const token = rest.shift();
24117
24328
  switch (token) {
24118
24329
  case "--paper-id":
24119
- paperId = requireValue12(rest, token);
24330
+ paperId = requireValue13(rest, token);
24120
24331
  break;
24121
24332
  case "--file":
24122
- filePath = requireValue12(rest, token);
24333
+ filePath = requireValue13(rest, token);
24123
24334
  break;
24124
24335
  case "--base-url":
24125
- apiBaseUrl = requireValue12(rest, token);
24336
+ apiBaseUrl = requireValue13(rest, token);
24126
24337
  break;
24127
24338
  case "--link-base":
24128
- linkBaseUrl = requireValue12(rest, token);
24339
+ linkBaseUrl = requireValue13(rest, token);
24129
24340
  break;
24130
24341
  default:
24131
24342
  throw new Error(`Unknown quiz append-step option: ${token}`);
@@ -24156,19 +24367,19 @@ function parseQuizArgs(tokens) {
24156
24367
  const token = rest.shift();
24157
24368
  switch (token) {
24158
24369
  case "--paper-id":
24159
- paperId = requireValue12(rest, token);
24370
+ paperId = requireValue13(rest, token);
24160
24371
  break;
24161
24372
  case "--step-id":
24162
- stepId = requireValue12(rest, token);
24373
+ stepId = requireValue13(rest, token);
24163
24374
  break;
24164
24375
  case "--file":
24165
- filePath = requireValue12(rest, token);
24376
+ filePath = requireValue13(rest, token);
24166
24377
  break;
24167
24378
  case "--base-url":
24168
- apiBaseUrl = requireValue12(rest, token);
24379
+ apiBaseUrl = requireValue13(rest, token);
24169
24380
  break;
24170
24381
  case "--link-base":
24171
- linkBaseUrl = requireValue12(rest, token);
24382
+ linkBaseUrl = requireValue13(rest, token);
24172
24383
  break;
24173
24384
  default:
24174
24385
  throw new Error(`Unknown quiz update-step option: ${token}`);
@@ -24202,16 +24413,16 @@ function parseQuizArgs(tokens) {
24202
24413
  const token = rest.shift();
24203
24414
  switch (token) {
24204
24415
  case "--paper-id":
24205
- paperId = requireValue12(rest, token);
24416
+ paperId = requireValue13(rest, token);
24206
24417
  break;
24207
24418
  case "--step-ids":
24208
- stepIdsRaw = requireValue12(rest, token);
24419
+ stepIdsRaw = requireValue13(rest, token);
24209
24420
  break;
24210
24421
  case "--base-url":
24211
- apiBaseUrl = requireValue12(rest, token);
24422
+ apiBaseUrl = requireValue13(rest, token);
24212
24423
  break;
24213
24424
  case "--link-base":
24214
- linkBaseUrl = requireValue12(rest, token);
24425
+ linkBaseUrl = requireValue13(rest, token);
24215
24426
  break;
24216
24427
  default:
24217
24428
  throw new Error(`Unknown quiz reorder option: ${token}`);
@@ -24244,13 +24455,13 @@ function parseQuizArgs(tokens) {
24244
24455
  const token = rest.shift();
24245
24456
  switch (token) {
24246
24457
  case "--paper-id":
24247
- paperId = requireValue12(rest, token);
24458
+ paperId = requireValue13(rest, token);
24248
24459
  break;
24249
24460
  case "--base-url":
24250
- apiBaseUrl = requireValue12(rest, token);
24461
+ apiBaseUrl = requireValue13(rest, token);
24251
24462
  break;
24252
24463
  case "--link-base":
24253
- linkBaseUrl = requireValue12(rest, token);
24464
+ linkBaseUrl = requireValue13(rest, token);
24254
24465
  break;
24255
24466
  default:
24256
24467
  throw new Error(`Unknown quiz activate option: ${token}`);
@@ -24275,13 +24486,13 @@ function parseQuizArgs(tokens) {
24275
24486
  const token = rest.shift();
24276
24487
  switch (token) {
24277
24488
  case "--paper-id":
24278
- paperId = requireValue12(rest, token);
24489
+ paperId = requireValue13(rest, token);
24279
24490
  break;
24280
24491
  case "--base-url":
24281
- apiBaseUrl = requireValue12(rest, token);
24492
+ apiBaseUrl = requireValue13(rest, token);
24282
24493
  break;
24283
24494
  case "--link-base":
24284
- linkBaseUrl = requireValue12(rest, token);
24495
+ linkBaseUrl = requireValue13(rest, token);
24285
24496
  break;
24286
24497
  default:
24287
24498
  throw new Error(`Unknown quiz view option: ${token}`);
@@ -24310,22 +24521,22 @@ function parseQuizArgs(tokens) {
24310
24521
  const token = rest.shift();
24311
24522
  switch (token) {
24312
24523
  case "--paper-id":
24313
- paperId = requireValue12(rest, token);
24524
+ paperId = requireValue13(rest, token);
24314
24525
  break;
24315
24526
  case "--step-id":
24316
- stepId = requireValue12(rest, token);
24527
+ stepId = requireValue13(rest, token);
24317
24528
  break;
24318
24529
  case "--file":
24319
- filePath = requireValue12(rest, token);
24530
+ filePath = requireValue13(rest, token);
24320
24531
  break;
24321
24532
  case "--new-paper-id":
24322
- newPaperId = requireValue12(rest, token);
24533
+ newPaperId = requireValue13(rest, token);
24323
24534
  break;
24324
24535
  case "--base-url":
24325
- apiBaseUrl = requireValue12(rest, token);
24536
+ apiBaseUrl = requireValue13(rest, token);
24326
24537
  break;
24327
24538
  case "--link-base":
24328
- linkBaseUrl = requireValue12(rest, token);
24539
+ linkBaseUrl = requireValue13(rest, token);
24329
24540
  break;
24330
24541
  case "--activate":
24331
24542
  activate = true;
@@ -24415,10 +24626,10 @@ function parseLinearPrArgs(tokens) {
24415
24626
  const token = rest.shift();
24416
24627
  switch (token) {
24417
24628
  case "--account":
24418
- account = requireValue12(rest, token);
24629
+ account = requireValue13(rest, token);
24419
24630
  break;
24420
24631
  case "--cwd":
24421
- cwd = requireValue12(rest, token);
24632
+ cwd = requireValue13(rest, token);
24422
24633
  break;
24423
24634
  default:
24424
24635
  throw new Error(`Unknown linear option: ${token}`);
@@ -24447,35 +24658,35 @@ function parseLinearCreateArgs(tokens) {
24447
24658
  const token = rest.shift();
24448
24659
  switch (token) {
24449
24660
  case "--account":
24450
- account = requireValue12(rest, token);
24661
+ account = requireValue13(rest, token);
24451
24662
  break;
24452
24663
  case "--repl":
24453
24664
  useRepl = true;
24454
24665
  break;
24455
24666
  case "--title":
24456
- title = requireValue12(rest, token);
24667
+ title = requireValue13(rest, token);
24457
24668
  break;
24458
24669
  case "--desc":
24459
24670
  case "--description":
24460
- description = decodeEscapedNewlines(requireValue12(rest, token));
24671
+ description = decodeEscapedNewlines(requireValue13(rest, token));
24461
24672
  break;
24462
24673
  case "--team-id":
24463
- teamId = requireValue12(rest, token);
24674
+ teamId = requireValue13(rest, token);
24464
24675
  break;
24465
24676
  case "--team-key":
24466
- teamKey = requireValue12(rest, token);
24677
+ teamKey = requireValue13(rest, token);
24467
24678
  break;
24468
24679
  case "--priority":
24469
- priority = parseLinearPriority(requireValue12(rest, token));
24680
+ priority = parseLinearPriority(requireValue13(rest, token));
24470
24681
  break;
24471
24682
  case "--parent-id":
24472
- parentId = requireValue12(rest, token);
24683
+ parentId = requireValue13(rest, token);
24473
24684
  break;
24474
24685
  case "--state-id":
24475
- stateId = requireValue12(rest, token);
24686
+ stateId = requireValue13(rest, token);
24476
24687
  break;
24477
24688
  case "--cwd":
24478
- cwd = requireValue12(rest, token);
24689
+ cwd = requireValue13(rest, token);
24479
24690
  break;
24480
24691
  default:
24481
24692
  throw new Error(`Unknown linear option: ${token}`);
@@ -24510,10 +24721,10 @@ function parseLinearWhoamiArgs(tokens) {
24510
24721
  const token = rest.shift();
24511
24722
  switch (token) {
24512
24723
  case "--account":
24513
- account = requireValue12(rest, token);
24724
+ account = requireValue13(rest, token);
24514
24725
  break;
24515
24726
  case "--cwd":
24516
- cwd = requireValue12(rest, token);
24727
+ cwd = requireValue13(rest, token);
24517
24728
  break;
24518
24729
  default:
24519
24730
  throw new Error(`Unknown linear option: ${token}`);
@@ -24538,10 +24749,10 @@ function parseLinearViewArgs(tokens) {
24538
24749
  const token = rest.shift();
24539
24750
  switch (token) {
24540
24751
  case "--account":
24541
- account = requireValue12(rest, token);
24752
+ account = requireValue13(rest, token);
24542
24753
  break;
24543
24754
  case "--cwd":
24544
- cwd = requireValue12(rest, token);
24755
+ cwd = requireValue13(rest, token);
24545
24756
  break;
24546
24757
  default:
24547
24758
  throw new Error(`Unknown linear option: ${token}`);
@@ -24576,32 +24787,32 @@ function parseLinearUpdateArgs(tokens) {
24576
24787
  const token = rest.shift();
24577
24788
  switch (token) {
24578
24789
  case "--account":
24579
- account = requireValue12(rest, token);
24790
+ account = requireValue13(rest, token);
24580
24791
  break;
24581
24792
  case "--title":
24582
- title = requireValue12(rest, token);
24793
+ title = requireValue13(rest, token);
24583
24794
  break;
24584
24795
  case "--desc":
24585
24796
  case "--description":
24586
- description = decodeEscapedNewlines(requireValue12(rest, token));
24797
+ description = decodeEscapedNewlines(requireValue13(rest, token));
24587
24798
  break;
24588
24799
  case "--team-id":
24589
- teamId = requireValue12(rest, token);
24800
+ teamId = requireValue13(rest, token);
24590
24801
  break;
24591
24802
  case "--team-key":
24592
- teamKey = requireValue12(rest, token);
24803
+ teamKey = requireValue13(rest, token);
24593
24804
  break;
24594
24805
  case "--priority":
24595
- priority = parseLinearPriority(requireValue12(rest, token));
24806
+ priority = parseLinearPriority(requireValue13(rest, token));
24596
24807
  break;
24597
24808
  case "--parent-id":
24598
- parentId = requireValue12(rest, token);
24809
+ parentId = requireValue13(rest, token);
24599
24810
  break;
24600
24811
  case "--state-id":
24601
- stateId = requireValue12(rest, token);
24812
+ stateId = requireValue13(rest, token);
24602
24813
  break;
24603
24814
  case "--cwd":
24604
- cwd = requireValue12(rest, token);
24815
+ cwd = requireValue13(rest, token);
24605
24816
  break;
24606
24817
  default:
24607
24818
  throw new Error(`Unknown linear option: ${token}`);
@@ -24639,10 +24850,10 @@ function parseLinearSubIssuesArgs(tokens) {
24639
24850
  const token = rest.shift();
24640
24851
  switch (token) {
24641
24852
  case "--account":
24642
- account = requireValue12(rest, token);
24853
+ account = requireValue13(rest, token);
24643
24854
  break;
24644
24855
  case "--cwd":
24645
- cwd = requireValue12(rest, token);
24856
+ cwd = requireValue13(rest, token);
24646
24857
  break;
24647
24858
  default:
24648
24859
  throw new Error(`Unknown linear option: ${token}`);
@@ -24669,15 +24880,15 @@ function parseLinearCommentArgs(tokens) {
24669
24880
  const token = rest.shift();
24670
24881
  switch (token) {
24671
24882
  case "--account":
24672
- account = requireValue12(rest, token);
24883
+ account = requireValue13(rest, token);
24673
24884
  break;
24674
24885
  case "--body":
24675
24886
  case "--desc":
24676
24887
  case "--description":
24677
- body = decodeEscapedNewlines(requireValue12(rest, token));
24888
+ body = decodeEscapedNewlines(requireValue13(rest, token));
24678
24889
  break;
24679
24890
  case "--cwd":
24680
- cwd = requireValue12(rest, token);
24891
+ cwd = requireValue13(rest, token);
24681
24892
  break;
24682
24893
  default:
24683
24894
  throw new Error(`Unknown linear option: ${token}`);
@@ -24707,10 +24918,10 @@ function parseLinearCommentsArgs(tokens) {
24707
24918
  const token = rest.shift();
24708
24919
  switch (token) {
24709
24920
  case "--account":
24710
- account = requireValue12(rest, token);
24921
+ account = requireValue13(rest, token);
24711
24922
  break;
24712
24923
  case "--cwd":
24713
- cwd = requireValue12(rest, token);
24924
+ cwd = requireValue13(rest, token);
24714
24925
  break;
24715
24926
  default:
24716
24927
  throw new Error(`Unknown linear option: ${token}`);
@@ -24734,16 +24945,16 @@ function parseLinearCycleArgs(tokens) {
24734
24945
  const token = rest.shift();
24735
24946
  switch (token) {
24736
24947
  case "--account":
24737
- account = requireValue12(rest, token);
24948
+ account = requireValue13(rest, token);
24738
24949
  break;
24739
24950
  case "--team-id":
24740
- teamId = requireValue12(rest, token);
24951
+ teamId = requireValue13(rest, token);
24741
24952
  break;
24742
24953
  case "--team-key":
24743
- teamKey = requireValue12(rest, token);
24954
+ teamKey = requireValue13(rest, token);
24744
24955
  break;
24745
24956
  case "--cwd":
24746
- cwd = requireValue12(rest, token);
24957
+ cwd = requireValue13(rest, token);
24747
24958
  break;
24748
24959
  default:
24749
24960
  throw new Error(`Unknown linear option: ${token}`);
@@ -24766,10 +24977,10 @@ function parseLinearTeamsArgs(tokens) {
24766
24977
  const token = rest.shift();
24767
24978
  switch (token) {
24768
24979
  case "--account":
24769
- account = requireValue12(rest, token);
24980
+ account = requireValue13(rest, token);
24770
24981
  break;
24771
24982
  case "--cwd":
24772
- cwd = requireValue12(rest, token);
24983
+ cwd = requireValue13(rest, token);
24773
24984
  break;
24774
24985
  default:
24775
24986
  throw new Error(`Unknown linear option: ${token}`);
@@ -24796,16 +25007,16 @@ function parseLinearUserIssuesArgs(tokens) {
24796
25007
  const token = rest.shift();
24797
25008
  switch (token) {
24798
25009
  case "--account":
24799
- account = requireValue12(rest, token);
25010
+ account = requireValue13(rest, token);
24800
25011
  break;
24801
25012
  case "--cycle":
24802
- cycle = parseLinearCycle(requireValue12(rest, token));
25013
+ cycle = parseLinearCycle(requireValue13(rest, token));
24803
25014
  break;
24804
25015
  case "--status":
24805
- status = parseLinearStatus(requireValue12(rest, token));
25016
+ status = parseLinearStatus(requireValue13(rest, token));
24806
25017
  break;
24807
25018
  case "--cwd":
24808
- cwd = requireValue12(rest, token);
25019
+ cwd = requireValue13(rest, token);
24809
25020
  break;
24810
25021
  default:
24811
25022
  throw new Error(`Unknown linear option: ${token}`);
@@ -24839,28 +25050,28 @@ function parseLinearIssuesArgs(tokens) {
24839
25050
  const token = rest.shift();
24840
25051
  switch (token) {
24841
25052
  case "--account":
24842
- account = requireValue12(rest, token);
25053
+ account = requireValue13(rest, token);
24843
25054
  break;
24844
25055
  case "--team-id":
24845
- teamId = requireValue12(rest, token);
25056
+ teamId = requireValue13(rest, token);
24846
25057
  break;
24847
25058
  case "--team-key":
24848
- teamKey = requireValue12(rest, token);
25059
+ teamKey = requireValue13(rest, token);
24849
25060
  break;
24850
25061
  case "--user":
24851
- user = requireValue12(rest, token);
25062
+ user = requireValue13(rest, token);
24852
25063
  break;
24853
25064
  case "--cycle":
24854
- cycle = parseLinearCycle(requireValue12(rest, token));
25065
+ cycle = parseLinearCycle(requireValue13(rest, token));
24855
25066
  break;
24856
25067
  case "--status":
24857
- status = parseLinearStatus(requireValue12(rest, token));
25068
+ status = parseLinearStatus(requireValue13(rest, token));
24858
25069
  break;
24859
25070
  case "--query":
24860
- query = requireValue12(rest, token).trim();
25071
+ query = requireValue13(rest, token).trim();
24861
25072
  break;
24862
25073
  case "--limit": {
24863
- const value = Number.parseInt(requireValue12(rest, token), 10);
25074
+ const value = Number.parseInt(requireValue13(rest, token), 10);
24864
25075
  if (!Number.isInteger(value) || value < 1 || value > 250) {
24865
25076
  throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
24866
25077
  }
@@ -24868,7 +25079,7 @@ function parseLinearIssuesArgs(tokens) {
24868
25079
  break;
24869
25080
  }
24870
25081
  case "--cwd":
24871
- cwd = requireValue12(rest, token);
25082
+ cwd = requireValue13(rest, token);
24872
25083
  break;
24873
25084
  default:
24874
25085
  throw new Error(`Unknown linear option: ${token}`);
@@ -24909,10 +25120,10 @@ function parseLinearLegacyArgs(tokens) {
24909
25120
  useScreenshot = true;
24910
25121
  break;
24911
25122
  case "--account":
24912
- account = requireValue12(rest, token);
25123
+ account = requireValue13(rest, token);
24913
25124
  break;
24914
25125
  case "--cwd":
24915
- cwd = requireValue12(rest, token);
25126
+ cwd = requireValue13(rest, token);
24916
25127
  break;
24917
25128
  default:
24918
25129
  throw new Error(`Unknown linear option: ${token}`);
@@ -25006,19 +25217,19 @@ function parseNotionArgs(tokens) {
25006
25217
  const token = rest.shift();
25007
25218
  switch (token) {
25008
25219
  case "--parent":
25009
- parentPageId = requireValue12(rest, token);
25220
+ parentPageId = requireValue13(rest, token);
25010
25221
  break;
25011
25222
  case "--title":
25012
- title = requireValue12(rest, token);
25223
+ title = requireValue13(rest, token);
25013
25224
  break;
25014
25225
  case "--private":
25015
25226
  isPrivate = true;
25016
25227
  break;
25017
25228
  case "--content":
25018
- content2 = requireValue12(rest, token);
25229
+ content2 = requireValue13(rest, token);
25019
25230
  break;
25020
25231
  case "--file":
25021
- filePath2 = requireValue12(rest, token);
25232
+ filePath2 = requireValue13(rest, token);
25022
25233
  break;
25023
25234
  default:
25024
25235
  throw new Error(`Unknown notion option: ${token}`);
@@ -25062,10 +25273,10 @@ function parseNotionArgs(tokens) {
25062
25273
  const token = rest.shift();
25063
25274
  switch (token) {
25064
25275
  case "--content":
25065
- content = requireValue12(rest, token);
25276
+ content = requireValue13(rest, token);
25066
25277
  break;
25067
25278
  case "--file":
25068
- filePath = requireValue12(rest, token);
25279
+ filePath = requireValue13(rest, token);
25069
25280
  break;
25070
25281
  case "--append":
25071
25282
  append = true;
@@ -25110,11 +25321,11 @@ function parseRandomArgs(tokens) {
25110
25321
  mode = "easy";
25111
25322
  break;
25112
25323
  case "--length":
25113
- length = parsePositiveInt2(requireValue12(rest, token), token);
25324
+ length = parsePositiveInt2(requireValue13(rest, token), token);
25114
25325
  seenLength = true;
25115
25326
  break;
25116
25327
  case "--charset": {
25117
- const value = requireValue12(rest, token);
25328
+ const value = requireValue13(rest, token);
25118
25329
  if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
25119
25330
  throw new Error(
25120
25331
  `Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
@@ -25125,18 +25336,18 @@ function parseRandomArgs(tokens) {
25125
25336
  break;
25126
25337
  }
25127
25338
  case "--count":
25128
- count = parsePositiveInt2(requireValue12(rest, token), token);
25339
+ count = parsePositiveInt2(requireValue13(rest, token), token);
25129
25340
  break;
25130
25341
  case "--words":
25131
- words = parsePositiveInt2(requireValue12(rest, token), token);
25342
+ words = parsePositiveInt2(requireValue13(rest, token), token);
25132
25343
  seenWords = true;
25133
25344
  break;
25134
25345
  case "--digits":
25135
- digits = parseNonNegativeInt(requireValue12(rest, token), token);
25346
+ digits = parseNonNegativeInt(requireValue13(rest, token), token);
25136
25347
  seenDigits = true;
25137
25348
  break;
25138
25349
  case "--separator":
25139
- separator = requireValue12(rest, token);
25350
+ separator = requireValue13(rest, token);
25140
25351
  seenSeparator = true;
25141
25352
  break;
25142
25353
  default:
@@ -25167,7 +25378,7 @@ function parseRandomArgs(tokens) {
25167
25378
  count
25168
25379
  };
25169
25380
  }
25170
- function requireValue12(tokens, optionName) {
25381
+ function requireValue13(tokens, optionName) {
25171
25382
  const value = tokens.shift();
25172
25383
  if (!value) {
25173
25384
  throw new Error(`Missing value for ${optionName}`);
@@ -25298,6 +25509,11 @@ async function main() {
25298
25509
  await handler.handle(commandArgs);
25299
25510
  return;
25300
25511
  }
25512
+ case "chat-room" /* ChatRoom */: {
25513
+ const handler = new ChatRoomCommandHandler();
25514
+ await handler.handle(commandArgs);
25515
+ return;
25516
+ }
25301
25517
  case "oss" /* Oss */: {
25302
25518
  const handler = new OssCommandHandler();
25303
25519
  await handler.handle(commandArgs);