@pmate/cli 0.24.8 → 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,9 +19927,11 @@ 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);
19855
- ui.success(`Bot key saved to ${outPath}`);
19930
+ (0, import_node_fs20.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
19931
+ (0, import_node_fs20.chmodSync)(outPath, 384);
19932
+ if (!args.json) {
19933
+ ui.success(`Bot key saved to ${outPath}`);
19934
+ }
19856
19935
  }
19857
19936
  if (args.json || !args.out) {
19858
19937
  ui.plain(JSON.stringify(keyFile, null, 2));
@@ -20028,7 +20107,9 @@ var AccountCommandHandler = class {
20028
20107
  algorithm: "ed25519"
20029
20108
  }
20030
20109
  );
20031
- ui.success(`Created bot ${bot.credential.app}/${bot.credential.name}`);
20110
+ if (!args.json) {
20111
+ ui.success(`Created bot ${bot.credential.app}/${bot.credential.name}`);
20112
+ }
20032
20113
  this.renderJson(bot, args.json);
20033
20114
  return;
20034
20115
  }
@@ -20089,7 +20170,9 @@ var AccountCommandHandler = class {
20089
20170
  }
20090
20171
  );
20091
20172
  const saved = saveLoginSession(login, args.app);
20092
- ui.success(`Logged in bot ${args.name} to ${saved.app}`);
20173
+ if (!args.json) {
20174
+ ui.success(`Logged in bot ${args.name} to ${saved.app}`);
20175
+ }
20093
20176
  this.renderJson(login, args.json);
20094
20177
  return;
20095
20178
  }
@@ -20108,7 +20191,9 @@ var AccountCommandHandler = class {
20108
20191
  role: args.role
20109
20192
  }
20110
20193
  );
20111
- ui.success(`Created profile ${profile.id} for bot ${args.name}`);
20194
+ if (!args.json) {
20195
+ ui.success(`Created profile ${profile.id} for bot ${args.name}`);
20196
+ }
20112
20197
  this.renderJson(profile, args.json);
20113
20198
  return;
20114
20199
  }
@@ -20288,10 +20373,10 @@ var AccountCommandHandler = class {
20288
20373
  throw new Error("Missing visible apps input");
20289
20374
  }
20290
20375
  const absolutePath = this.resolveFilePath(args.filePath);
20291
- if (!(0, import_node_fs19.existsSync)(absolutePath)) {
20376
+ if (!(0, import_node_fs20.existsSync)(absolutePath)) {
20292
20377
  throw new Error(`JSON file not found: ${absolutePath}`);
20293
20378
  }
20294
- const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
20379
+ const raw = (0, import_node_fs20.readFileSync)(absolutePath, "utf8");
20295
20380
  let parsed;
20296
20381
  try {
20297
20382
  parsed = JSON.parse(raw);
@@ -20325,10 +20410,10 @@ var AccountCommandHandler = class {
20325
20410
  throw new Error("Missing bot key file");
20326
20411
  }
20327
20412
  const absolutePath = this.resolveFilePath(filePath);
20328
- if (!(0, import_node_fs19.existsSync)(absolutePath)) {
20413
+ if (!(0, import_node_fs20.existsSync)(absolutePath)) {
20329
20414
  throw new Error(`Bot key file not found: ${absolutePath}`);
20330
20415
  }
20331
- const parsed = JSON.parse((0, import_node_fs19.readFileSync)(absolutePath, "utf8"));
20416
+ const parsed = JSON.parse((0, import_node_fs20.readFileSync)(absolutePath, "utf8"));
20332
20417
  if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
20333
20418
  throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
20334
20419
  }
@@ -20380,7 +20465,7 @@ function encodePathSegment(value) {
20380
20465
  }
20381
20466
 
20382
20467
  // src/commands/OrgCommandHandler.ts
20383
- var import_node_fs20 = require("fs");
20468
+ var import_node_fs21 = require("fs");
20384
20469
  var import_node_path25 = __toESM(require("path"));
20385
20470
  init_sessionStore();
20386
20471
  var OrgCommandHandler = class {
@@ -20553,10 +20638,10 @@ var OrgCommandHandler = class {
20553
20638
  throw new Error(`Missing ${itemLabel} input`);
20554
20639
  }
20555
20640
  const absolutePath = import_node_path25.default.resolve(process.cwd(), filePath);
20556
- if (!(0, import_node_fs20.existsSync)(absolutePath)) {
20641
+ if (!(0, import_node_fs21.existsSync)(absolutePath)) {
20557
20642
  throw new Error(`JSON file not found: ${absolutePath}`);
20558
20643
  }
20559
- const raw = (0, import_node_fs20.readFileSync)(absolutePath, "utf8");
20644
+ const raw = (0, import_node_fs21.readFileSync)(absolutePath, "utf8");
20560
20645
  let parsed;
20561
20646
  try {
20562
20647
  parsed = JSON.parse(raw);
@@ -23244,6 +23329,135 @@ function requireValue10(tokens, optionName) {
23244
23329
  return value;
23245
23330
  }
23246
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
+
23247
23461
  // src/prepareDevCommandParser.ts
23248
23462
  function parsePrepareDevArgs(tokens) {
23249
23463
  const rest = [...tokens];
@@ -23271,7 +23485,7 @@ function parsePrepareDevArgs(tokens) {
23271
23485
  close = true;
23272
23486
  break;
23273
23487
  case "--env": {
23274
- const rawValue = requireValue11(rest, token);
23488
+ const rawValue = requireValue12(rest, token);
23275
23489
  const parsed = Number.parseInt(rawValue, 10);
23276
23490
  if (!Number.isInteger(parsed) || parsed < 0) {
23277
23491
  throw new Error(`Invalid --env value: ${rawValue}`);
@@ -23280,13 +23494,13 @@ function parsePrepareDevArgs(tokens) {
23280
23494
  break;
23281
23495
  }
23282
23496
  case "--env-root":
23283
- envRoot = requireValue11(rest, token);
23497
+ envRoot = requireValue12(rest, token);
23284
23498
  break;
23285
23499
  case "--base-root":
23286
- baseRoot = requireValue11(rest, token);
23500
+ baseRoot = requireValue12(rest, token);
23287
23501
  break;
23288
23502
  case "--note":
23289
- note = requireValue11(rest, token);
23503
+ note = requireValue12(rest, token);
23290
23504
  break;
23291
23505
  case "--json":
23292
23506
  json = true;
@@ -23322,7 +23536,7 @@ function parsePrepareDevArgs(tokens) {
23322
23536
  json
23323
23537
  };
23324
23538
  }
23325
- function requireValue11(tokens, option) {
23539
+ function requireValue12(tokens, option) {
23326
23540
  const value = tokens.shift();
23327
23541
  if (!value || value.startsWith("-")) {
23328
23542
  throw new Error(`Missing value for ${option}`);
@@ -23332,7 +23546,7 @@ function requireValue11(tokens, option) {
23332
23546
 
23333
23547
  // src/index.ts
23334
23548
  var pkg = JSON.parse(
23335
- (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")
23336
23550
  );
23337
23551
  var HELP_TEXT = [
23338
23552
  import_chalk4.default.bold(`pmate v${pkg.version}`),
@@ -23415,6 +23629,8 @@ var HELP_TEXT = [
23415
23629
  ` ${import_chalk4.default.gray(" --easy [--words <n>] [--digits <n>] [--separator <s>] [--count <n>]")}`,
23416
23630
  ` ${import_chalk4.default.cyan("collect")} Collect threads/messages from Electron chat app via CDP`,
23417
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>")}`,
23418
23634
  ` ${import_chalk4.default.cyan("agent")} Manage agent registry entries and call agents for debugging`,
23419
23635
  ` ${import_chalk4.default.gray(" namespaces [--base-url <url>] [--json]")}`,
23420
23636
  ` ${import_chalk4.default.gray(" list [--namespace <ns>] [--base-url <url>] [--json]")}`,
@@ -23570,7 +23786,7 @@ function parseCommandArgs(args) {
23570
23786
  const token = rest.shift();
23571
23787
  switch (token) {
23572
23788
  case "--app":
23573
- app = requireValue12(rest, token);
23789
+ app = requireValue13(rest, token);
23574
23790
  break;
23575
23791
  default:
23576
23792
  throw new Error(`Unknown login option: ${token}`);
@@ -23632,6 +23848,9 @@ function parseCommandArgs(args) {
23632
23848
  if (args.rest[0] === "collect") {
23633
23849
  return parseCollectArgs(args.rest.slice(1));
23634
23850
  }
23851
+ if (args.rest[0] === "chat-room") {
23852
+ return parseChatRoomArgs(args.rest.slice(1));
23853
+ }
23635
23854
  if (args.rest[0] === "agent") {
23636
23855
  return parseAgentArgs(args.rest.slice(1));
23637
23856
  }
@@ -23676,7 +23895,7 @@ function parseVercelArgs(tokens) {
23676
23895
  const token = rest.shift();
23677
23896
  switch (token) {
23678
23897
  case "--scope":
23679
- scope = requireValue12(rest, token);
23898
+ scope = requireValue13(rest, token);
23680
23899
  break;
23681
23900
  default:
23682
23901
  throw new Error(`Unknown vercel option: ${token}`);
@@ -23696,10 +23915,10 @@ function parseVercelArgs(tokens) {
23696
23915
  const token = rest.shift();
23697
23916
  switch (token) {
23698
23917
  case "--scope":
23699
- scope = requireValue12(rest, token);
23918
+ scope = requireValue13(rest, token);
23700
23919
  break;
23701
23920
  case "--project":
23702
- project = requireValue12(rest, token);
23921
+ project = requireValue13(rest, token);
23703
23922
  break;
23704
23923
  case "--last-week":
23705
23924
  lastWeek = true;
@@ -23730,16 +23949,16 @@ function parseAddDnsArgs(tokens) {
23730
23949
  const token = rest.shift();
23731
23950
  switch (token) {
23732
23951
  case "--type":
23733
- options.dnsType = requireValue12(rest, token);
23952
+ options.dnsType = requireValue13(rest, token);
23734
23953
  break;
23735
23954
  case "--value":
23736
- options.dnsValue = requireValue12(rest, token);
23955
+ options.dnsValue = requireValue13(rest, token);
23737
23956
  break;
23738
23957
  case "--rr":
23739
- options.dnsRr = requireValue12(rest, token);
23958
+ options.dnsRr = requireValue13(rest, token);
23740
23959
  break;
23741
23960
  case "--ttl": {
23742
- const ttlValue = requireValue12(rest, token);
23961
+ const ttlValue = requireValue13(rest, token);
23743
23962
  const ttl = Number.parseInt(ttlValue, 10);
23744
23963
  if (!Number.isFinite(ttl) || ttl <= 0) {
23745
23964
  throw new Error(`Invalid --ttl value: ${ttlValue}`);
@@ -23748,7 +23967,7 @@ function parseAddDnsArgs(tokens) {
23748
23967
  break;
23749
23968
  }
23750
23969
  case "--domain":
23751
- options.dnsDomain = requireValue12(rest, token);
23970
+ options.dnsDomain = requireValue13(rest, token);
23752
23971
  break;
23753
23972
  default:
23754
23973
  throw new Error(`Unknown add-dns option: ${token}`);
@@ -23781,13 +24000,13 @@ function parseBucketArgs(tokens) {
23781
24000
  options.bucketCreate = true;
23782
24001
  break;
23783
24002
  case "--name":
23784
- options.bucketName = requireValue12(rest, token);
24003
+ options.bucketName = requireValue13(rest, token);
23785
24004
  break;
23786
24005
  case "--subdomain":
23787
- options.bucketSubdomain = requireValue12(rest, token);
24006
+ options.bucketSubdomain = requireValue13(rest, token);
23788
24007
  break;
23789
24008
  case "--domain":
23790
- options.bucketDomain = requireValue12(rest, token);
24009
+ options.bucketDomain = requireValue13(rest, token);
23791
24010
  break;
23792
24011
  default:
23793
24012
  throw new Error(`Unknown bucket option: ${token}`);
@@ -23819,7 +24038,7 @@ function parseDevArgs(tokens) {
23819
24038
  const token = rest.shift();
23820
24039
  switch (token) {
23821
24040
  case "--cwd":
23822
- options.devCwd = requireValue12(rest, token);
24041
+ options.devCwd = requireValue13(rest, token);
23823
24042
  break;
23824
24043
  default:
23825
24044
  throw new Error(`Unknown dev option: ${token}`);
@@ -23839,7 +24058,7 @@ function parseDeleteArgs(tokens) {
23839
24058
  const token = rest.shift();
23840
24059
  switch (token) {
23841
24060
  case "--cwd":
23842
- deleteCwd = requireValue12(rest, token);
24061
+ deleteCwd = requireValue13(rest, token);
23843
24062
  break;
23844
24063
  default:
23845
24064
  throw new Error(`Unknown delete option: ${token}`);
@@ -23873,13 +24092,13 @@ function parseOssArgs(tokens) {
23873
24092
  const token = rest.shift();
23874
24093
  switch (token) {
23875
24094
  case "--bucket":
23876
- bucket = requireValue12(rest, token);
24095
+ bucket = requireValue13(rest, token);
23877
24096
  break;
23878
24097
  case "--file":
23879
- filePath = requireValue12(rest, token);
24098
+ filePath = requireValue13(rest, token);
23880
24099
  break;
23881
24100
  case "--key":
23882
- objectKey = requireValue12(rest, token);
24101
+ objectKey = requireValue13(rest, token);
23883
24102
  break;
23884
24103
  default:
23885
24104
  throw new Error(`Unknown oss option: ${token}`);
@@ -23912,7 +24131,7 @@ function parseEnvArgs(tokens) {
23912
24131
  throw new Error("Only one env action is allowed.");
23913
24132
  }
23914
24133
  action = "set";
23915
- key = requireValue12(rest, token);
24134
+ key = requireValue13(rest, token);
23916
24135
  break;
23917
24136
  case "--list":
23918
24137
  if (action) {
@@ -23925,17 +24144,17 @@ function parseEnvArgs(tokens) {
23925
24144
  throw new Error("Only one env action is allowed.");
23926
24145
  }
23927
24146
  action = "delete";
23928
- key = requireValue12(rest, token);
24147
+ key = requireValue13(rest, token);
23929
24148
  break;
23930
24149
  case "--value":
23931
- value = requireValue12(rest, token);
24150
+ value = requireValue13(rest, token);
23932
24151
  break;
23933
24152
  case "--verbose":
23934
24153
  case "-v":
23935
24154
  verbose = true;
23936
24155
  break;
23937
24156
  case "--cwd":
23938
- cwd = requireValue12(rest, token);
24157
+ cwd = requireValue13(rest, token);
23939
24158
  break;
23940
24159
  default:
23941
24160
  throw new Error(`Unknown env option: ${token}`);
@@ -23993,7 +24212,7 @@ function parseCommitArgs(tokens) {
23993
24212
  push = true;
23994
24213
  break;
23995
24214
  case "--cwd":
23996
- cwd = requireValue12(rest, token);
24215
+ cwd = requireValue13(rest, token);
23997
24216
  break;
23998
24217
  default:
23999
24218
  throw new Error(`Unknown commit option: ${token}`);
@@ -24009,10 +24228,10 @@ function parseSummaryArgs(tokens) {
24009
24228
  const token = rest.shift();
24010
24229
  switch (token) {
24011
24230
  case "--pr":
24012
- prRef = requireValue12(rest, token);
24231
+ prRef = requireValue13(rest, token);
24013
24232
  break;
24014
24233
  case "--cwd":
24015
- cwd = requireValue12(rest, token);
24234
+ cwd = requireValue13(rest, token);
24016
24235
  break;
24017
24236
  default:
24018
24237
  throw new Error(`Unknown summary option: ${token}`);
@@ -24037,13 +24256,13 @@ function parseQuizArgs(tokens) {
24037
24256
  const token = rest.shift();
24038
24257
  switch (token) {
24039
24258
  case "--paper-id":
24040
- paperId = requireValue12(rest, token);
24259
+ paperId = requireValue13(rest, token);
24041
24260
  break;
24042
24261
  case "--base-url":
24043
- apiBaseUrl = requireValue12(rest, token);
24262
+ apiBaseUrl = requireValue13(rest, token);
24044
24263
  break;
24045
24264
  case "--link-base":
24046
- linkBaseUrl = requireValue12(rest, token);
24265
+ linkBaseUrl = requireValue13(rest, token);
24047
24266
  break;
24048
24267
  default:
24049
24268
  throw new Error(`Unknown quiz create-draft option: ${token}`);
@@ -24069,16 +24288,16 @@ function parseQuizArgs(tokens) {
24069
24288
  const token = rest.shift();
24070
24289
  switch (token) {
24071
24290
  case "--paper-id":
24072
- paperId = requireValue12(rest, token);
24291
+ paperId = requireValue13(rest, token);
24073
24292
  break;
24074
24293
  case "--file":
24075
- filePath = requireValue12(rest, token);
24294
+ filePath = requireValue13(rest, token);
24076
24295
  break;
24077
24296
  case "--base-url":
24078
- apiBaseUrl = requireValue12(rest, token);
24297
+ apiBaseUrl = requireValue13(rest, token);
24079
24298
  break;
24080
24299
  case "--link-base":
24081
- linkBaseUrl = requireValue12(rest, token);
24300
+ linkBaseUrl = requireValue13(rest, token);
24082
24301
  break;
24083
24302
  default:
24084
24303
  throw new Error(`Unknown quiz update-meta option: ${token}`);
@@ -24108,16 +24327,16 @@ function parseQuizArgs(tokens) {
24108
24327
  const token = rest.shift();
24109
24328
  switch (token) {
24110
24329
  case "--paper-id":
24111
- paperId = requireValue12(rest, token);
24330
+ paperId = requireValue13(rest, token);
24112
24331
  break;
24113
24332
  case "--file":
24114
- filePath = requireValue12(rest, token);
24333
+ filePath = requireValue13(rest, token);
24115
24334
  break;
24116
24335
  case "--base-url":
24117
- apiBaseUrl = requireValue12(rest, token);
24336
+ apiBaseUrl = requireValue13(rest, token);
24118
24337
  break;
24119
24338
  case "--link-base":
24120
- linkBaseUrl = requireValue12(rest, token);
24339
+ linkBaseUrl = requireValue13(rest, token);
24121
24340
  break;
24122
24341
  default:
24123
24342
  throw new Error(`Unknown quiz append-step option: ${token}`);
@@ -24148,19 +24367,19 @@ function parseQuizArgs(tokens) {
24148
24367
  const token = rest.shift();
24149
24368
  switch (token) {
24150
24369
  case "--paper-id":
24151
- paperId = requireValue12(rest, token);
24370
+ paperId = requireValue13(rest, token);
24152
24371
  break;
24153
24372
  case "--step-id":
24154
- stepId = requireValue12(rest, token);
24373
+ stepId = requireValue13(rest, token);
24155
24374
  break;
24156
24375
  case "--file":
24157
- filePath = requireValue12(rest, token);
24376
+ filePath = requireValue13(rest, token);
24158
24377
  break;
24159
24378
  case "--base-url":
24160
- apiBaseUrl = requireValue12(rest, token);
24379
+ apiBaseUrl = requireValue13(rest, token);
24161
24380
  break;
24162
24381
  case "--link-base":
24163
- linkBaseUrl = requireValue12(rest, token);
24382
+ linkBaseUrl = requireValue13(rest, token);
24164
24383
  break;
24165
24384
  default:
24166
24385
  throw new Error(`Unknown quiz update-step option: ${token}`);
@@ -24194,16 +24413,16 @@ function parseQuizArgs(tokens) {
24194
24413
  const token = rest.shift();
24195
24414
  switch (token) {
24196
24415
  case "--paper-id":
24197
- paperId = requireValue12(rest, token);
24416
+ paperId = requireValue13(rest, token);
24198
24417
  break;
24199
24418
  case "--step-ids":
24200
- stepIdsRaw = requireValue12(rest, token);
24419
+ stepIdsRaw = requireValue13(rest, token);
24201
24420
  break;
24202
24421
  case "--base-url":
24203
- apiBaseUrl = requireValue12(rest, token);
24422
+ apiBaseUrl = requireValue13(rest, token);
24204
24423
  break;
24205
24424
  case "--link-base":
24206
- linkBaseUrl = requireValue12(rest, token);
24425
+ linkBaseUrl = requireValue13(rest, token);
24207
24426
  break;
24208
24427
  default:
24209
24428
  throw new Error(`Unknown quiz reorder option: ${token}`);
@@ -24236,13 +24455,13 @@ function parseQuizArgs(tokens) {
24236
24455
  const token = rest.shift();
24237
24456
  switch (token) {
24238
24457
  case "--paper-id":
24239
- paperId = requireValue12(rest, token);
24458
+ paperId = requireValue13(rest, token);
24240
24459
  break;
24241
24460
  case "--base-url":
24242
- apiBaseUrl = requireValue12(rest, token);
24461
+ apiBaseUrl = requireValue13(rest, token);
24243
24462
  break;
24244
24463
  case "--link-base":
24245
- linkBaseUrl = requireValue12(rest, token);
24464
+ linkBaseUrl = requireValue13(rest, token);
24246
24465
  break;
24247
24466
  default:
24248
24467
  throw new Error(`Unknown quiz activate option: ${token}`);
@@ -24267,13 +24486,13 @@ function parseQuizArgs(tokens) {
24267
24486
  const token = rest.shift();
24268
24487
  switch (token) {
24269
24488
  case "--paper-id":
24270
- paperId = requireValue12(rest, token);
24489
+ paperId = requireValue13(rest, token);
24271
24490
  break;
24272
24491
  case "--base-url":
24273
- apiBaseUrl = requireValue12(rest, token);
24492
+ apiBaseUrl = requireValue13(rest, token);
24274
24493
  break;
24275
24494
  case "--link-base":
24276
- linkBaseUrl = requireValue12(rest, token);
24495
+ linkBaseUrl = requireValue13(rest, token);
24277
24496
  break;
24278
24497
  default:
24279
24498
  throw new Error(`Unknown quiz view option: ${token}`);
@@ -24302,22 +24521,22 @@ function parseQuizArgs(tokens) {
24302
24521
  const token = rest.shift();
24303
24522
  switch (token) {
24304
24523
  case "--paper-id":
24305
- paperId = requireValue12(rest, token);
24524
+ paperId = requireValue13(rest, token);
24306
24525
  break;
24307
24526
  case "--step-id":
24308
- stepId = requireValue12(rest, token);
24527
+ stepId = requireValue13(rest, token);
24309
24528
  break;
24310
24529
  case "--file":
24311
- filePath = requireValue12(rest, token);
24530
+ filePath = requireValue13(rest, token);
24312
24531
  break;
24313
24532
  case "--new-paper-id":
24314
- newPaperId = requireValue12(rest, token);
24533
+ newPaperId = requireValue13(rest, token);
24315
24534
  break;
24316
24535
  case "--base-url":
24317
- apiBaseUrl = requireValue12(rest, token);
24536
+ apiBaseUrl = requireValue13(rest, token);
24318
24537
  break;
24319
24538
  case "--link-base":
24320
- linkBaseUrl = requireValue12(rest, token);
24539
+ linkBaseUrl = requireValue13(rest, token);
24321
24540
  break;
24322
24541
  case "--activate":
24323
24542
  activate = true;
@@ -24407,10 +24626,10 @@ function parseLinearPrArgs(tokens) {
24407
24626
  const token = rest.shift();
24408
24627
  switch (token) {
24409
24628
  case "--account":
24410
- account = requireValue12(rest, token);
24629
+ account = requireValue13(rest, token);
24411
24630
  break;
24412
24631
  case "--cwd":
24413
- cwd = requireValue12(rest, token);
24632
+ cwd = requireValue13(rest, token);
24414
24633
  break;
24415
24634
  default:
24416
24635
  throw new Error(`Unknown linear option: ${token}`);
@@ -24439,35 +24658,35 @@ function parseLinearCreateArgs(tokens) {
24439
24658
  const token = rest.shift();
24440
24659
  switch (token) {
24441
24660
  case "--account":
24442
- account = requireValue12(rest, token);
24661
+ account = requireValue13(rest, token);
24443
24662
  break;
24444
24663
  case "--repl":
24445
24664
  useRepl = true;
24446
24665
  break;
24447
24666
  case "--title":
24448
- title = requireValue12(rest, token);
24667
+ title = requireValue13(rest, token);
24449
24668
  break;
24450
24669
  case "--desc":
24451
24670
  case "--description":
24452
- description = decodeEscapedNewlines(requireValue12(rest, token));
24671
+ description = decodeEscapedNewlines(requireValue13(rest, token));
24453
24672
  break;
24454
24673
  case "--team-id":
24455
- teamId = requireValue12(rest, token);
24674
+ teamId = requireValue13(rest, token);
24456
24675
  break;
24457
24676
  case "--team-key":
24458
- teamKey = requireValue12(rest, token);
24677
+ teamKey = requireValue13(rest, token);
24459
24678
  break;
24460
24679
  case "--priority":
24461
- priority = parseLinearPriority(requireValue12(rest, token));
24680
+ priority = parseLinearPriority(requireValue13(rest, token));
24462
24681
  break;
24463
24682
  case "--parent-id":
24464
- parentId = requireValue12(rest, token);
24683
+ parentId = requireValue13(rest, token);
24465
24684
  break;
24466
24685
  case "--state-id":
24467
- stateId = requireValue12(rest, token);
24686
+ stateId = requireValue13(rest, token);
24468
24687
  break;
24469
24688
  case "--cwd":
24470
- cwd = requireValue12(rest, token);
24689
+ cwd = requireValue13(rest, token);
24471
24690
  break;
24472
24691
  default:
24473
24692
  throw new Error(`Unknown linear option: ${token}`);
@@ -24502,10 +24721,10 @@ function parseLinearWhoamiArgs(tokens) {
24502
24721
  const token = rest.shift();
24503
24722
  switch (token) {
24504
24723
  case "--account":
24505
- account = requireValue12(rest, token);
24724
+ account = requireValue13(rest, token);
24506
24725
  break;
24507
24726
  case "--cwd":
24508
- cwd = requireValue12(rest, token);
24727
+ cwd = requireValue13(rest, token);
24509
24728
  break;
24510
24729
  default:
24511
24730
  throw new Error(`Unknown linear option: ${token}`);
@@ -24530,10 +24749,10 @@ function parseLinearViewArgs(tokens) {
24530
24749
  const token = rest.shift();
24531
24750
  switch (token) {
24532
24751
  case "--account":
24533
- account = requireValue12(rest, token);
24752
+ account = requireValue13(rest, token);
24534
24753
  break;
24535
24754
  case "--cwd":
24536
- cwd = requireValue12(rest, token);
24755
+ cwd = requireValue13(rest, token);
24537
24756
  break;
24538
24757
  default:
24539
24758
  throw new Error(`Unknown linear option: ${token}`);
@@ -24568,32 +24787,32 @@ function parseLinearUpdateArgs(tokens) {
24568
24787
  const token = rest.shift();
24569
24788
  switch (token) {
24570
24789
  case "--account":
24571
- account = requireValue12(rest, token);
24790
+ account = requireValue13(rest, token);
24572
24791
  break;
24573
24792
  case "--title":
24574
- title = requireValue12(rest, token);
24793
+ title = requireValue13(rest, token);
24575
24794
  break;
24576
24795
  case "--desc":
24577
24796
  case "--description":
24578
- description = decodeEscapedNewlines(requireValue12(rest, token));
24797
+ description = decodeEscapedNewlines(requireValue13(rest, token));
24579
24798
  break;
24580
24799
  case "--team-id":
24581
- teamId = requireValue12(rest, token);
24800
+ teamId = requireValue13(rest, token);
24582
24801
  break;
24583
24802
  case "--team-key":
24584
- teamKey = requireValue12(rest, token);
24803
+ teamKey = requireValue13(rest, token);
24585
24804
  break;
24586
24805
  case "--priority":
24587
- priority = parseLinearPriority(requireValue12(rest, token));
24806
+ priority = parseLinearPriority(requireValue13(rest, token));
24588
24807
  break;
24589
24808
  case "--parent-id":
24590
- parentId = requireValue12(rest, token);
24809
+ parentId = requireValue13(rest, token);
24591
24810
  break;
24592
24811
  case "--state-id":
24593
- stateId = requireValue12(rest, token);
24812
+ stateId = requireValue13(rest, token);
24594
24813
  break;
24595
24814
  case "--cwd":
24596
- cwd = requireValue12(rest, token);
24815
+ cwd = requireValue13(rest, token);
24597
24816
  break;
24598
24817
  default:
24599
24818
  throw new Error(`Unknown linear option: ${token}`);
@@ -24631,10 +24850,10 @@ function parseLinearSubIssuesArgs(tokens) {
24631
24850
  const token = rest.shift();
24632
24851
  switch (token) {
24633
24852
  case "--account":
24634
- account = requireValue12(rest, token);
24853
+ account = requireValue13(rest, token);
24635
24854
  break;
24636
24855
  case "--cwd":
24637
- cwd = requireValue12(rest, token);
24856
+ cwd = requireValue13(rest, token);
24638
24857
  break;
24639
24858
  default:
24640
24859
  throw new Error(`Unknown linear option: ${token}`);
@@ -24661,15 +24880,15 @@ function parseLinearCommentArgs(tokens) {
24661
24880
  const token = rest.shift();
24662
24881
  switch (token) {
24663
24882
  case "--account":
24664
- account = requireValue12(rest, token);
24883
+ account = requireValue13(rest, token);
24665
24884
  break;
24666
24885
  case "--body":
24667
24886
  case "--desc":
24668
24887
  case "--description":
24669
- body = decodeEscapedNewlines(requireValue12(rest, token));
24888
+ body = decodeEscapedNewlines(requireValue13(rest, token));
24670
24889
  break;
24671
24890
  case "--cwd":
24672
- cwd = requireValue12(rest, token);
24891
+ cwd = requireValue13(rest, token);
24673
24892
  break;
24674
24893
  default:
24675
24894
  throw new Error(`Unknown linear option: ${token}`);
@@ -24699,10 +24918,10 @@ function parseLinearCommentsArgs(tokens) {
24699
24918
  const token = rest.shift();
24700
24919
  switch (token) {
24701
24920
  case "--account":
24702
- account = requireValue12(rest, token);
24921
+ account = requireValue13(rest, token);
24703
24922
  break;
24704
24923
  case "--cwd":
24705
- cwd = requireValue12(rest, token);
24924
+ cwd = requireValue13(rest, token);
24706
24925
  break;
24707
24926
  default:
24708
24927
  throw new Error(`Unknown linear option: ${token}`);
@@ -24726,16 +24945,16 @@ function parseLinearCycleArgs(tokens) {
24726
24945
  const token = rest.shift();
24727
24946
  switch (token) {
24728
24947
  case "--account":
24729
- account = requireValue12(rest, token);
24948
+ account = requireValue13(rest, token);
24730
24949
  break;
24731
24950
  case "--team-id":
24732
- teamId = requireValue12(rest, token);
24951
+ teamId = requireValue13(rest, token);
24733
24952
  break;
24734
24953
  case "--team-key":
24735
- teamKey = requireValue12(rest, token);
24954
+ teamKey = requireValue13(rest, token);
24736
24955
  break;
24737
24956
  case "--cwd":
24738
- cwd = requireValue12(rest, token);
24957
+ cwd = requireValue13(rest, token);
24739
24958
  break;
24740
24959
  default:
24741
24960
  throw new Error(`Unknown linear option: ${token}`);
@@ -24758,10 +24977,10 @@ function parseLinearTeamsArgs(tokens) {
24758
24977
  const token = rest.shift();
24759
24978
  switch (token) {
24760
24979
  case "--account":
24761
- account = requireValue12(rest, token);
24980
+ account = requireValue13(rest, token);
24762
24981
  break;
24763
24982
  case "--cwd":
24764
- cwd = requireValue12(rest, token);
24983
+ cwd = requireValue13(rest, token);
24765
24984
  break;
24766
24985
  default:
24767
24986
  throw new Error(`Unknown linear option: ${token}`);
@@ -24788,16 +25007,16 @@ function parseLinearUserIssuesArgs(tokens) {
24788
25007
  const token = rest.shift();
24789
25008
  switch (token) {
24790
25009
  case "--account":
24791
- account = requireValue12(rest, token);
25010
+ account = requireValue13(rest, token);
24792
25011
  break;
24793
25012
  case "--cycle":
24794
- cycle = parseLinearCycle(requireValue12(rest, token));
25013
+ cycle = parseLinearCycle(requireValue13(rest, token));
24795
25014
  break;
24796
25015
  case "--status":
24797
- status = parseLinearStatus(requireValue12(rest, token));
25016
+ status = parseLinearStatus(requireValue13(rest, token));
24798
25017
  break;
24799
25018
  case "--cwd":
24800
- cwd = requireValue12(rest, token);
25019
+ cwd = requireValue13(rest, token);
24801
25020
  break;
24802
25021
  default:
24803
25022
  throw new Error(`Unknown linear option: ${token}`);
@@ -24831,28 +25050,28 @@ function parseLinearIssuesArgs(tokens) {
24831
25050
  const token = rest.shift();
24832
25051
  switch (token) {
24833
25052
  case "--account":
24834
- account = requireValue12(rest, token);
25053
+ account = requireValue13(rest, token);
24835
25054
  break;
24836
25055
  case "--team-id":
24837
- teamId = requireValue12(rest, token);
25056
+ teamId = requireValue13(rest, token);
24838
25057
  break;
24839
25058
  case "--team-key":
24840
- teamKey = requireValue12(rest, token);
25059
+ teamKey = requireValue13(rest, token);
24841
25060
  break;
24842
25061
  case "--user":
24843
- user = requireValue12(rest, token);
25062
+ user = requireValue13(rest, token);
24844
25063
  break;
24845
25064
  case "--cycle":
24846
- cycle = parseLinearCycle(requireValue12(rest, token));
25065
+ cycle = parseLinearCycle(requireValue13(rest, token));
24847
25066
  break;
24848
25067
  case "--status":
24849
- status = parseLinearStatus(requireValue12(rest, token));
25068
+ status = parseLinearStatus(requireValue13(rest, token));
24850
25069
  break;
24851
25070
  case "--query":
24852
- query = requireValue12(rest, token).trim();
25071
+ query = requireValue13(rest, token).trim();
24853
25072
  break;
24854
25073
  case "--limit": {
24855
- const value = Number.parseInt(requireValue12(rest, token), 10);
25074
+ const value = Number.parseInt(requireValue13(rest, token), 10);
24856
25075
  if (!Number.isInteger(value) || value < 1 || value > 250) {
24857
25076
  throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
24858
25077
  }
@@ -24860,7 +25079,7 @@ function parseLinearIssuesArgs(tokens) {
24860
25079
  break;
24861
25080
  }
24862
25081
  case "--cwd":
24863
- cwd = requireValue12(rest, token);
25082
+ cwd = requireValue13(rest, token);
24864
25083
  break;
24865
25084
  default:
24866
25085
  throw new Error(`Unknown linear option: ${token}`);
@@ -24901,10 +25120,10 @@ function parseLinearLegacyArgs(tokens) {
24901
25120
  useScreenshot = true;
24902
25121
  break;
24903
25122
  case "--account":
24904
- account = requireValue12(rest, token);
25123
+ account = requireValue13(rest, token);
24905
25124
  break;
24906
25125
  case "--cwd":
24907
- cwd = requireValue12(rest, token);
25126
+ cwd = requireValue13(rest, token);
24908
25127
  break;
24909
25128
  default:
24910
25129
  throw new Error(`Unknown linear option: ${token}`);
@@ -24998,19 +25217,19 @@ function parseNotionArgs(tokens) {
24998
25217
  const token = rest.shift();
24999
25218
  switch (token) {
25000
25219
  case "--parent":
25001
- parentPageId = requireValue12(rest, token);
25220
+ parentPageId = requireValue13(rest, token);
25002
25221
  break;
25003
25222
  case "--title":
25004
- title = requireValue12(rest, token);
25223
+ title = requireValue13(rest, token);
25005
25224
  break;
25006
25225
  case "--private":
25007
25226
  isPrivate = true;
25008
25227
  break;
25009
25228
  case "--content":
25010
- content2 = requireValue12(rest, token);
25229
+ content2 = requireValue13(rest, token);
25011
25230
  break;
25012
25231
  case "--file":
25013
- filePath2 = requireValue12(rest, token);
25232
+ filePath2 = requireValue13(rest, token);
25014
25233
  break;
25015
25234
  default:
25016
25235
  throw new Error(`Unknown notion option: ${token}`);
@@ -25054,10 +25273,10 @@ function parseNotionArgs(tokens) {
25054
25273
  const token = rest.shift();
25055
25274
  switch (token) {
25056
25275
  case "--content":
25057
- content = requireValue12(rest, token);
25276
+ content = requireValue13(rest, token);
25058
25277
  break;
25059
25278
  case "--file":
25060
- filePath = requireValue12(rest, token);
25279
+ filePath = requireValue13(rest, token);
25061
25280
  break;
25062
25281
  case "--append":
25063
25282
  append = true;
@@ -25102,11 +25321,11 @@ function parseRandomArgs(tokens) {
25102
25321
  mode = "easy";
25103
25322
  break;
25104
25323
  case "--length":
25105
- length = parsePositiveInt2(requireValue12(rest, token), token);
25324
+ length = parsePositiveInt2(requireValue13(rest, token), token);
25106
25325
  seenLength = true;
25107
25326
  break;
25108
25327
  case "--charset": {
25109
- const value = requireValue12(rest, token);
25328
+ const value = requireValue13(rest, token);
25110
25329
  if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
25111
25330
  throw new Error(
25112
25331
  `Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
@@ -25117,18 +25336,18 @@ function parseRandomArgs(tokens) {
25117
25336
  break;
25118
25337
  }
25119
25338
  case "--count":
25120
- count = parsePositiveInt2(requireValue12(rest, token), token);
25339
+ count = parsePositiveInt2(requireValue13(rest, token), token);
25121
25340
  break;
25122
25341
  case "--words":
25123
- words = parsePositiveInt2(requireValue12(rest, token), token);
25342
+ words = parsePositiveInt2(requireValue13(rest, token), token);
25124
25343
  seenWords = true;
25125
25344
  break;
25126
25345
  case "--digits":
25127
- digits = parseNonNegativeInt(requireValue12(rest, token), token);
25346
+ digits = parseNonNegativeInt(requireValue13(rest, token), token);
25128
25347
  seenDigits = true;
25129
25348
  break;
25130
25349
  case "--separator":
25131
- separator = requireValue12(rest, token);
25350
+ separator = requireValue13(rest, token);
25132
25351
  seenSeparator = true;
25133
25352
  break;
25134
25353
  default:
@@ -25159,7 +25378,7 @@ function parseRandomArgs(tokens) {
25159
25378
  count
25160
25379
  };
25161
25380
  }
25162
- function requireValue12(tokens, optionName) {
25381
+ function requireValue13(tokens, optionName) {
25163
25382
  const value = tokens.shift();
25164
25383
  if (!value) {
25165
25384
  throw new Error(`Missing value for ${optionName}`);
@@ -25290,6 +25509,11 @@ async function main() {
25290
25509
  await handler.handle(commandArgs);
25291
25510
  return;
25292
25511
  }
25512
+ case "chat-room" /* ChatRoom */: {
25513
+ const handler = new ChatRoomCommandHandler();
25514
+ await handler.handle(commandArgs);
25515
+ return;
25516
+ }
25293
25517
  case "oss" /* Oss */: {
25294
25518
  const handler = new OssCommandHandler();
25295
25519
  await handler.handle(commandArgs);