@pmate/cli 0.25.11 → 0.26.0

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
@@ -88,7 +88,7 @@ var init_namespacedRef = __esm({
88
88
 
89
89
  // src/sessionStore.ts
90
90
  function buildSessionStorePath() {
91
- return import_node_path3.default.join(import_node_os2.default.homedir(), ".pmate", "session.json");
91
+ return import_node_path4.default.join(import_node_os3.default.homedir(), ".pmate", "session.json");
92
92
  }
93
93
  function assertValidAppRef(appRef) {
94
94
  return parseNamespacedRef(appRef, { entityLabel: "app ref" }).fullId;
@@ -153,7 +153,7 @@ function loadSessionStore() {
153
153
  }
154
154
  function loadExistingSessionStoreOrEmpty() {
155
155
  const sessionPath = buildSessionStorePath();
156
- if (!(0, import_node_fs2.existsSync)(sessionPath)) {
156
+ if (!(0, import_node_fs3.existsSync)(sessionPath)) {
157
157
  return {
158
158
  version: SESSION_STORE_VERSION,
159
159
  activeAppRef: DEFAULT_APP_ID,
@@ -172,10 +172,10 @@ function loadExistingSessionStoreOrEmpty() {
172
172
  }
173
173
  function loadSessionStoreWithPath() {
174
174
  const sessionPath = buildSessionStorePath();
175
- if (!(0, import_node_fs2.existsSync)(sessionPath)) {
175
+ if (!(0, import_node_fs3.existsSync)(sessionPath)) {
176
176
  throw new Error(`Missing session file at ${sessionPath}. Run "pmate login" first.`);
177
177
  }
178
- const raw = (0, import_node_fs2.readFileSync)(sessionPath, "utf8");
178
+ const raw = (0, import_node_fs3.readFileSync)(sessionPath, "utf8");
179
179
  const parsed = JSON.parse(raw);
180
180
  const store = normalizeStore(parsed);
181
181
  return { sessionPath, store };
@@ -265,12 +265,12 @@ function resolveReadApp(store, options) {
265
265
  }
266
266
  function writeSessionStore(store) {
267
267
  const sessionPath = buildSessionStorePath();
268
- (0, import_node_fs2.mkdirSync)(import_node_path3.default.dirname(sessionPath), { recursive: true });
269
- (0, import_node_fs2.writeFileSync)(sessionPath, JSON.stringify(store, null, 2), {
268
+ (0, import_node_fs3.mkdirSync)(import_node_path4.default.dirname(sessionPath), { recursive: true });
269
+ (0, import_node_fs3.writeFileSync)(sessionPath, JSON.stringify(store, null, 2), {
270
270
  mode: 384
271
271
  });
272
272
  try {
273
- (0, import_node_fs2.chmodSync)(sessionPath, 384);
273
+ (0, import_node_fs3.chmodSync)(sessionPath, 384);
274
274
  } catch {
275
275
  }
276
276
  }
@@ -280,170 +280,173 @@ function buildMissingSessionMessage(sessionPath, app) {
280
280
  }
281
281
  return `Missing session for app ${app} in ${sessionPath}. Run "pmate login --app ${app}" first.`;
282
282
  }
283
- var import_node_fs2, import_node_os2, import_node_path3, DEFAULT_APP_ID, SESSION_STORE_VERSION;
283
+ var import_node_fs3, import_node_os3, import_node_path4, DEFAULT_APP_ID, SESSION_STORE_VERSION;
284
284
  var init_sessionStore = __esm({
285
285
  "src/sessionStore.ts"() {
286
286
  "use strict";
287
- import_node_fs2 = require("fs");
288
- import_node_os2 = __toESM(require("os"));
289
- import_node_path3 = __toESM(require("path"));
287
+ import_node_fs3 = require("fs");
288
+ import_node_os3 = __toESM(require("os"));
289
+ import_node_path4 = __toESM(require("path"));
290
290
  init_namespacedRef();
291
291
  DEFAULT_APP_ID = "pmate:factory";
292
292
  SESSION_STORE_VERSION = 4;
293
293
  }
294
294
  });
295
295
 
296
- // node_modules/@pmate/meta/src/types/account.types.ts
296
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/account.types.ts
297
297
  var init_account_types = __esm({
298
- "node_modules/@pmate/meta/src/types/account.types.ts"() {
298
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/account.types.ts"() {
299
299
  "use strict";
300
300
  }
301
301
  });
302
302
 
303
- // node_modules/@pmate/meta/src/types/achievements.types.ts
303
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/achievements.types.ts
304
304
  var init_achievements_types = __esm({
305
- "node_modules/@pmate/meta/src/types/achievements.types.ts"() {
305
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
306
306
  "use strict";
307
307
  }
308
308
  });
309
309
 
310
- // node_modules/@pmate/meta/src/types/aigen.types.ts
310
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/aigen.types.ts
311
311
  var init_aigen_types = __esm({
312
- "node_modules/@pmate/meta/src/types/aigen.types.ts"() {
312
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
313
313
  "use strict";
314
314
  }
315
315
  });
316
316
 
317
- // node_modules/@pmate/meta/src/types/agent.types.ts
317
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent.types.ts
318
318
  var init_agent_types = __esm({
319
- "node_modules/@pmate/meta/src/types/agent.types.ts"() {
319
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent.types.ts"() {
320
320
  "use strict";
321
321
  }
322
322
  });
323
323
 
324
- // node_modules/@pmate/meta/src/types/agent-registry.types.ts
324
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent-registry.types.ts
325
325
  var init_agent_registry_types = __esm({
326
- "node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
326
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
327
327
  "use strict";
328
328
  }
329
329
  });
330
330
 
331
- // node_modules/@pmate/meta/src/types/runner-registry.types.ts
331
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/runner-registry.types.ts
332
332
  var init_runner_registry_types = __esm({
333
- "node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
333
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
334
334
  "use strict";
335
335
  }
336
336
  });
337
337
 
338
- // node_modules/@pmate/meta/src/types/blockchain.types.ts
338
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/blockchain.types.ts
339
339
  var init_blockchain_types = __esm({
340
- "node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
340
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
341
341
  "use strict";
342
342
  }
343
343
  });
344
344
 
345
- // node_modules/@pmate/meta/src/types/breakdown.types.ts
345
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/breakdown.types.ts
346
346
  var init_breakdown_types = __esm({
347
- "node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
347
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
348
348
  "use strict";
349
349
  }
350
350
  });
351
351
 
352
- // node_modules/@pmate/meta/src/types/chat.types.ts
352
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/chat.types.ts
353
353
  var init_chat_types = __esm({
354
- "node_modules/@pmate/meta/src/types/chat.types.ts"() {
354
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/chat.types.ts"() {
355
355
  "use strict";
356
356
  }
357
357
  });
358
358
 
359
- // node_modules/@pmate/meta/src/types/companion.types.ts
359
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/companion.types.ts
360
360
  var init_companion_types = __esm({
361
- "node_modules/@pmate/meta/src/types/companion.types.ts"() {
361
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/companion.types.ts"() {
362
362
  "use strict";
363
363
  }
364
364
  });
365
365
 
366
- // node_modules/@pmate/meta/src/types/enums.ts
366
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/enums.ts
367
367
  var init_enums = __esm({
368
- "node_modules/@pmate/meta/src/types/enums.ts"() {
368
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/enums.ts"() {
369
369
  "use strict";
370
370
  }
371
371
  });
372
372
 
373
- // node_modules/@pmate/meta/src/types/lang.types.ts
373
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/lang.types.ts
374
374
  var init_lang_types = __esm({
375
- "node_modules/@pmate/meta/src/types/lang.types.ts"() {
375
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/lang.types.ts"() {
376
376
  "use strict";
377
377
  }
378
378
  });
379
379
 
380
- // node_modules/@pmate/meta/src/types/logs.types.ts
380
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/logs.types.ts
381
381
  var init_logs_types = __esm({
382
- "node_modules/@pmate/meta/src/types/logs.types.ts"() {
382
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/logs.types.ts"() {
383
383
  "use strict";
384
384
  }
385
385
  });
386
386
 
387
- // node_modules/@pmate/meta/src/types/message.types.ts
387
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/message.types.ts
388
+ var PING, PONG;
388
389
  var init_message_types = __esm({
389
- "node_modules/@pmate/meta/src/types/message.types.ts"() {
390
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/message.types.ts"() {
390
391
  "use strict";
392
+ PING = 1;
393
+ PONG = 2;
391
394
  }
392
395
  });
393
396
 
394
- // node_modules/@pmate/meta/src/types/newLog.types.ts
397
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/newLog.types.ts
395
398
  var init_newLog_types = __esm({
396
- "node_modules/@pmate/meta/src/types/newLog.types.ts"() {
399
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
397
400
  "use strict";
398
401
  }
399
402
  });
400
403
 
401
- // node_modules/@pmate/meta/src/types/novel.types.ts
404
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/novel.types.ts
402
405
  var init_novel_types = __esm({
403
- "node_modules/@pmate/meta/src/types/novel.types.ts"() {
406
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/novel.types.ts"() {
404
407
  "use strict";
405
408
  }
406
409
  });
407
410
 
408
- // node_modules/@pmate/meta/src/types/offline.types.ts
411
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/offline.types.ts
409
412
  var init_offline_types = __esm({
410
- "node_modules/@pmate/meta/src/types/offline.types.ts"() {
413
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/offline.types.ts"() {
411
414
  "use strict";
412
415
  }
413
416
  });
414
417
 
415
- // node_modules/@pmate/meta/src/types/prompt.types.ts
418
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/prompt.types.ts
416
419
  var init_prompt_types = __esm({
417
- "node_modules/@pmate/meta/src/types/prompt.types.ts"() {
420
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
418
421
  "use strict";
419
422
  }
420
423
  });
421
424
 
422
- // node_modules/@pmate/meta/src/types/reading.types.ts
425
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/reading.types.ts
423
426
  var init_reading_types = __esm({
424
- "node_modules/@pmate/meta/src/types/reading.types.ts"() {
427
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/reading.types.ts"() {
425
428
  "use strict";
426
429
  }
427
430
  });
428
431
 
429
- // node_modules/@pmate/meta/src/types/settings.types.ts
432
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/settings.types.ts
430
433
  var init_settings_types = __esm({
431
- "node_modules/@pmate/meta/src/types/settings.types.ts"() {
434
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/settings.types.ts"() {
432
435
  "use strict";
433
436
  }
434
437
  });
435
438
 
436
- // node_modules/@pmate/meta/src/types/subscription.types.ts
439
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/subscription.types.ts
437
440
  var init_subscription_types = __esm({
438
- "node_modules/@pmate/meta/src/types/subscription.types.ts"() {
441
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
439
442
  "use strict";
440
443
  }
441
444
  });
442
445
 
443
- // node_modules/@pmate/meta/src/types/types.ts
446
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/types.ts
444
447
  var buildVoiceKey, createVoice;
445
448
  var init_types = __esm({
446
- "node_modules/@pmate/meta/src/types/types.ts"() {
449
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/types.ts"() {
447
450
  "use strict";
448
451
  buildVoiceKey = (provider, name) => {
449
452
  return `${provider}:${name}`;
@@ -465,44 +468,44 @@ var init_types = __esm({
465
468
  }
466
469
  });
467
470
 
468
- // node_modules/@pmate/meta/src/types/wordv5.def.ts
471
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/wordv5.def.ts
469
472
  var init_wordv5_def = __esm({
470
- "node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
473
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
471
474
  "use strict";
472
475
  }
473
476
  });
474
477
 
475
- // node_modules/@pmate/meta/src/types/auth.types.ts
478
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/auth.types.ts
476
479
  var init_auth_types = __esm({
477
- "node_modules/@pmate/meta/src/types/auth.types.ts"() {
480
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/auth.types.ts"() {
478
481
  "use strict";
479
482
  }
480
483
  });
481
484
 
482
- // node_modules/@pmate/meta/src/types/apps.types.ts
485
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/apps.types.ts
483
486
  var init_apps_types = __esm({
484
- "node_modules/@pmate/meta/src/types/apps.types.ts"() {
487
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/apps.types.ts"() {
485
488
  "use strict";
486
489
  }
487
490
  });
488
491
 
489
- // node_modules/@pmate/meta/src/types/response.types.ts
492
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/response.types.ts
490
493
  var init_response_types = __esm({
491
- "node_modules/@pmate/meta/src/types/response.types.ts"() {
494
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/response.types.ts"() {
492
495
  "use strict";
493
496
  }
494
497
  });
495
498
 
496
- // node_modules/@pmate/meta/src/types/role.types.ts
499
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/role.types.ts
497
500
  var init_role_types = __esm({
498
- "node_modules/@pmate/meta/src/types/role.types.ts"() {
501
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/role.types.ts"() {
499
502
  "use strict";
500
503
  }
501
504
  });
502
505
 
503
- // node_modules/@pmate/meta/src/types/index.ts
506
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/index.ts
504
507
  var init_types2 = __esm({
505
- "node_modules/@pmate/meta/src/types/index.ts"() {
508
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/index.ts"() {
506
509
  "use strict";
507
510
  init_account_types();
508
511
  init_achievements_types();
@@ -534,24 +537,24 @@ var init_types2 = __esm({
534
537
  }
535
538
  });
536
539
 
537
- // node_modules/@pmate/meta/src/config/BizErrorCode.ts
540
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/BizErrorCode.ts
538
541
  var init_BizErrorCode = __esm({
539
- "node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
542
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
540
543
  "use strict";
541
544
  }
542
545
  });
543
546
 
544
- // node_modules/@pmate/meta/src/config/consts.ts
547
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/consts.ts
545
548
  var init_consts = __esm({
546
- "node_modules/@pmate/meta/src/config/consts.ts"() {
549
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/consts.ts"() {
547
550
  "use strict";
548
551
  }
549
552
  });
550
553
 
551
- // node_modules/@pmate/meta/src/config/TopicNames.ts
554
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/TopicNames.ts
552
555
  var TopicNames, topicKindMatchers;
553
556
  var init_TopicNames = __esm({
554
- "node_modules/@pmate/meta/src/config/TopicNames.ts"() {
557
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
555
558
  "use strict";
556
559
  init_types2();
557
560
  TopicNames = class _TopicNames {
@@ -637,18 +640,18 @@ var init_TopicNames = __esm({
637
640
  }
638
641
  });
639
642
 
640
- // node_modules/@pmate/meta/src/config/OSSKeys.ts
643
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/OSSKeys.ts
641
644
  var init_OSSKeys = __esm({
642
- "node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
645
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
643
646
  "use strict";
644
647
  init_consts();
645
648
  }
646
649
  });
647
650
 
648
- // node_modules/@pmate/meta/src/config/CompanionProfiles.ts
651
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
649
652
  var openAICoral, openAIAsh, openAIBallad, openAINova, openAIVerse;
650
653
  var init_CompanionProfiles = __esm({
651
- "node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
654
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
652
655
  "use strict";
653
656
  init_types2();
654
657
  openAICoral = createVoice({
@@ -683,9 +686,9 @@ var init_CompanionProfiles = __esm({
683
686
  }
684
687
  });
685
688
 
686
- // node_modules/@pmate/meta/src/config/index.ts
689
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/index.ts
687
690
  var init_config = __esm({
688
- "node_modules/@pmate/meta/src/config/index.ts"() {
691
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/index.ts"() {
689
692
  "use strict";
690
693
  init_BizErrorCode();
691
694
  init_consts();
@@ -695,83 +698,83 @@ var init_config = __esm({
695
698
  }
696
699
  });
697
700
 
698
- // node_modules/@pmate/meta/src/index.ts
701
+ // node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/index.ts
699
702
  var init_src = __esm({
700
- "node_modules/@pmate/meta/src/index.ts"() {
703
+ "node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/index.ts"() {
701
704
  "use strict";
702
705
  init_types2();
703
706
  init_config();
704
707
  }
705
708
  });
706
709
 
707
- // node_modules/@pmate/utils/src/base64.ts
710
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/base64.ts
708
711
  var init_base64 = __esm({
709
- "node_modules/@pmate/utils/src/base64.ts"() {
712
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/base64.ts"() {
710
713
  "use strict";
711
714
  }
712
715
  });
713
716
 
714
- // node_modules/@pmate/utils/src/Cache.ts
717
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Cache.ts
715
718
  var init_Cache = __esm({
716
- "node_modules/@pmate/utils/src/Cache.ts"() {
719
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Cache.ts"() {
717
720
  "use strict";
718
721
  }
719
722
  });
720
723
 
721
- // node_modules/@pmate/utils/src/batchResolve.ts
724
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/batchResolve.ts
722
725
  var init_batchResolve = __esm({
723
- "node_modules/@pmate/utils/src/batchResolve.ts"() {
726
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/batchResolve.ts"() {
724
727
  "use strict";
725
728
  init_Cache();
726
729
  }
727
730
  });
728
731
 
729
- // node_modules/@pmate/lang/src/cn/sentenceSpliter.ts
732
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/cn/sentenceSpliter.ts
730
733
  var init_sentenceSpliter = __esm({
731
- "node_modules/@pmate/lang/src/cn/sentenceSpliter.ts"() {
734
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/cn/sentenceSpliter.ts"() {
732
735
  "use strict";
733
736
  }
734
737
  });
735
738
 
736
- // node_modules/@pmate/lang/src/cn/sentenceTrim.ts
739
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/cn/sentenceTrim.ts
737
740
  var init_sentenceTrim = __esm({
738
- "node_modules/@pmate/lang/src/cn/sentenceTrim.ts"() {
741
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/cn/sentenceTrim.ts"() {
739
742
  "use strict";
740
743
  }
741
744
  });
742
745
 
743
- // node_modules/@pmate/lang/src/cn/wordSpliter.ts
746
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/cn/wordSpliter.ts
744
747
  var init_wordSpliter = __esm({
745
- "node_modules/@pmate/lang/src/cn/wordSpliter.ts"() {
748
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/cn/wordSpliter.ts"() {
746
749
  "use strict";
747
750
  }
748
751
  });
749
752
 
750
- // node_modules/@pmate/lang/src/en/regex.ts
753
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/regex.ts
751
754
  var init_regex = __esm({
752
- "node_modules/@pmate/lang/src/en/regex.ts"() {
755
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/regex.ts"() {
753
756
  "use strict";
754
757
  }
755
758
  });
756
759
 
757
- // node_modules/@pmate/lang/src/en/sentenceSpliter.ts
760
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/sentenceSpliter.ts
758
761
  var init_sentenceSpliter2 = __esm({
759
- "node_modules/@pmate/lang/src/en/sentenceSpliter.ts"() {
762
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/sentenceSpliter.ts"() {
760
763
  "use strict";
761
764
  }
762
765
  });
763
766
 
764
- // node_modules/@pmate/lang/src/en/sentenceTrim.ts
767
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/sentenceTrim.ts
765
768
  var init_sentenceTrim2 = __esm({
766
- "node_modules/@pmate/lang/src/en/sentenceTrim.ts"() {
769
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/sentenceTrim.ts"() {
767
770
  "use strict";
768
771
  }
769
772
  });
770
773
 
771
- // node_modules/@pmate/lang/src/en/wordSpliter.ts
774
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/wordSpliter.ts
772
775
  var regex;
773
776
  var init_wordSpliter2 = __esm({
774
- "node_modules/@pmate/lang/src/en/wordSpliter.ts"() {
777
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/en/wordSpliter.ts"() {
775
778
  "use strict";
776
779
  regex = new RegExp(
777
780
  [
@@ -807,23 +810,23 @@ var init_wordSpliter2 = __esm({
807
810
  }
808
811
  });
809
812
 
810
- // node_modules/@pmate/lang/src/kr/sentenceSpliter.ts
813
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/kr/sentenceSpliter.ts
811
814
  var init_sentenceSpliter3 = __esm({
812
- "node_modules/@pmate/lang/src/kr/sentenceSpliter.ts"() {
815
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/kr/sentenceSpliter.ts"() {
813
816
  "use strict";
814
817
  }
815
818
  });
816
819
 
817
- // node_modules/@pmate/lang/src/kr/wordSpliter.ts
820
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/kr/wordSpliter.ts
818
821
  var init_wordSpliter3 = __esm({
819
- "node_modules/@pmate/lang/src/kr/wordSpliter.ts"() {
822
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/kr/wordSpliter.ts"() {
820
823
  "use strict";
821
824
  }
822
825
  });
823
826
 
824
- // node_modules/@pmate/lang/src/readingSettings.ts
827
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/readingSettings.ts
825
828
  var init_readingSettings = __esm({
826
- "node_modules/@pmate/lang/src/readingSettings.ts"() {
829
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/readingSettings.ts"() {
827
830
  "use strict";
828
831
  init_sentenceSpliter();
829
832
  init_wordSpliter();
@@ -834,428 +837,17 @@ var init_readingSettings = __esm({
834
837
  }
835
838
  });
836
839
 
837
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/account.types.ts
838
- var init_account_types2 = __esm({
839
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/account.types.ts"() {
840
- "use strict";
841
- }
842
- });
843
-
844
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/achievements.types.ts
845
- var init_achievements_types2 = __esm({
846
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
847
- "use strict";
848
- }
849
- });
850
-
851
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/aigen.types.ts
852
- var init_aigen_types2 = __esm({
853
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
854
- "use strict";
855
- }
856
- });
857
-
858
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/agent.types.ts
859
- var init_agent_types2 = __esm({
860
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/agent.types.ts"() {
861
- "use strict";
862
- }
863
- });
864
-
865
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/agent-registry.types.ts
866
- var init_agent_registry_types2 = __esm({
867
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
868
- "use strict";
869
- }
870
- });
871
-
872
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/runner-registry.types.ts
873
- var init_runner_registry_types2 = __esm({
874
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
875
- "use strict";
876
- }
877
- });
878
-
879
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/blockchain.types.ts
880
- var init_blockchain_types2 = __esm({
881
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
882
- "use strict";
883
- }
884
- });
885
-
886
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/breakdown.types.ts
887
- var init_breakdown_types2 = __esm({
888
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
889
- "use strict";
890
- }
891
- });
892
-
893
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/chat.types.ts
894
- var init_chat_types2 = __esm({
895
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/chat.types.ts"() {
896
- "use strict";
897
- }
898
- });
899
-
900
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/companion.types.ts
901
- var init_companion_types2 = __esm({
902
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/companion.types.ts"() {
903
- "use strict";
904
- }
905
- });
906
-
907
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/enums.ts
908
- var init_enums2 = __esm({
909
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/enums.ts"() {
910
- "use strict";
911
- }
912
- });
913
-
914
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/lang.types.ts
915
- var init_lang_types2 = __esm({
916
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/lang.types.ts"() {
917
- "use strict";
918
- }
919
- });
920
-
921
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/logs.types.ts
922
- var init_logs_types2 = __esm({
923
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/logs.types.ts"() {
924
- "use strict";
925
- }
926
- });
927
-
928
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/message.types.ts
929
- var init_message_types2 = __esm({
930
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/message.types.ts"() {
931
- "use strict";
932
- }
933
- });
934
-
935
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/newLog.types.ts
936
- var init_newLog_types2 = __esm({
937
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
938
- "use strict";
939
- }
940
- });
941
-
942
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/novel.types.ts
943
- var init_novel_types2 = __esm({
944
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/novel.types.ts"() {
945
- "use strict";
946
- }
947
- });
948
-
949
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/offline.types.ts
950
- var init_offline_types2 = __esm({
951
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/offline.types.ts"() {
952
- "use strict";
953
- }
954
- });
955
-
956
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/prompt.types.ts
957
- var init_prompt_types2 = __esm({
958
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
959
- "use strict";
960
- }
961
- });
962
-
963
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/reading.types.ts
964
- var init_reading_types2 = __esm({
965
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/reading.types.ts"() {
966
- "use strict";
967
- }
968
- });
969
-
970
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/settings.types.ts
971
- var init_settings_types2 = __esm({
972
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/settings.types.ts"() {
973
- "use strict";
974
- }
975
- });
976
-
977
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/subscription.types.ts
978
- var init_subscription_types2 = __esm({
979
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
980
- "use strict";
981
- }
982
- });
983
-
984
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/types.ts
985
- var buildVoiceKey2, createVoice2;
986
- var init_types3 = __esm({
987
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/types.ts"() {
988
- "use strict";
989
- buildVoiceKey2 = (provider, name) => {
990
- return `${provider}:${name}`;
991
- };
992
- createVoice2 = ({
993
- name,
994
- provider,
995
- gender,
996
- instructions
997
- }) => {
998
- return {
999
- name,
1000
- provider,
1001
- gender,
1002
- instructions,
1003
- key: buildVoiceKey2(provider, name)
1004
- };
1005
- };
1006
- }
1007
- });
1008
-
1009
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/wordv5.def.ts
1010
- var init_wordv5_def2 = __esm({
1011
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
1012
- "use strict";
1013
- }
1014
- });
1015
-
1016
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/auth.types.ts
1017
- var init_auth_types2 = __esm({
1018
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/auth.types.ts"() {
1019
- "use strict";
1020
- }
1021
- });
1022
-
1023
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/apps.types.ts
1024
- var init_apps_types2 = __esm({
1025
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/apps.types.ts"() {
1026
- "use strict";
1027
- }
1028
- });
1029
-
1030
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/response.types.ts
1031
- var init_response_types2 = __esm({
1032
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/response.types.ts"() {
1033
- "use strict";
1034
- }
1035
- });
1036
-
1037
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/role.types.ts
1038
- var init_role_types2 = __esm({
1039
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/role.types.ts"() {
1040
- "use strict";
1041
- }
1042
- });
1043
-
1044
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/index.ts
1045
- var init_types4 = __esm({
1046
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/types/index.ts"() {
1047
- "use strict";
1048
- init_account_types2();
1049
- init_achievements_types2();
1050
- init_aigen_types2();
1051
- init_agent_types2();
1052
- init_agent_registry_types2();
1053
- init_runner_registry_types2();
1054
- init_blockchain_types2();
1055
- init_breakdown_types2();
1056
- init_chat_types2();
1057
- init_companion_types2();
1058
- init_enums2();
1059
- init_lang_types2();
1060
- init_logs_types2();
1061
- init_message_types2();
1062
- init_newLog_types2();
1063
- init_novel_types2();
1064
- init_offline_types2();
1065
- init_prompt_types2();
1066
- init_reading_types2();
1067
- init_settings_types2();
1068
- init_subscription_types2();
1069
- init_types3();
1070
- init_wordv5_def2();
1071
- init_auth_types2();
1072
- init_apps_types2();
1073
- init_response_types2();
1074
- init_role_types2();
1075
- }
1076
- });
1077
-
1078
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/BizErrorCode.ts
1079
- var init_BizErrorCode2 = __esm({
1080
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
1081
- "use strict";
1082
- }
1083
- });
1084
-
1085
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/consts.ts
1086
- var init_consts2 = __esm({
1087
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/consts.ts"() {
1088
- "use strict";
1089
- }
1090
- });
1091
-
1092
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/TopicNames.ts
1093
- var TopicNames2, topicKindMatchers2;
1094
- var init_TopicNames2 = __esm({
1095
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
1096
- "use strict";
1097
- init_types4();
1098
- TopicNames2 = class _TopicNames {
1099
- static rooms() {
1100
- return "@pmate/rooms";
1101
- }
1102
- static userThreads(user) {
1103
- return `@pmate/user_threads:${user}`;
1104
- }
1105
- static userLogs(user) {
1106
- return `@pmate/user_logs:${user}`;
1107
- }
1108
- static legacyUserLogs(user) {
1109
- return _TopicNames.userLogs(user);
1110
- }
1111
- static userContacts(profileId) {
1112
- return `@pmate/user_contacts:${profileId}`;
1113
- }
1114
- static usersMessage(userId) {
1115
- return `@pmate/user_messages:${userId}`;
1116
- }
1117
- static userMapping() {
1118
- return "@pmate/username_mapping";
1119
- }
1120
- static userMobileMapping() {
1121
- return "@pmate/mobile_account";
1122
- }
1123
- static mapping() {
1124
- return "@pmate/mapping";
1125
- }
1126
- static profiles() {
1127
- return "@pmate/profiles";
1128
- }
1129
- static groups() {
1130
- return "@pmate/groups";
1131
- }
1132
- static relationships() {
1133
- return "@pmate/relationships";
1134
- }
1135
- };
1136
- topicKindMatchers2 = [
1137
- {
1138
- kind: 1e3 /* UserLogs */,
1139
- match: (topic) => topic.startsWith("@pmate/user_logs:")
1140
- },
1141
- {
1142
- kind: 2e3 /* UserMessages */,
1143
- match: (topic) => topic.startsWith("@pmate/user_messages:")
1144
- },
1145
- {
1146
- kind: 3e3 /* Relationships */,
1147
- match: (topic) => topic === TopicNames2.relationships()
1148
- },
1149
- {
1150
- kind: 4e3 /* Rooms */,
1151
- match: (topic) => topic === TopicNames2.rooms()
1152
- },
1153
- {
1154
- kind: 5e3 /* UserContacts */,
1155
- match: (topic) => topic.startsWith("@pmate/user_contacts:")
1156
- },
1157
- {
1158
- kind: 8002 /* Entity_GROUP */,
1159
- match: (topic) => topic === TopicNames2.groups()
1160
- },
1161
- {
1162
- kind: 6e3 /* UserMapping */,
1163
- match: (topic) => topic === TopicNames2.userMapping()
1164
- },
1165
- {
1166
- kind: 7e3 /* UserMobileMapping */,
1167
- match: (topic) => topic === TopicNames2.userMobileMapping()
1168
- },
1169
- {
1170
- kind: 6003 /* Mapping */,
1171
- match: (topic) => topic === TopicNames2.mapping()
1172
- },
1173
- {
1174
- kind: 9e3 /* UserThreads */,
1175
- match: (topic) => topic.startsWith("@pmate/user_threads:")
1176
- }
1177
- ];
1178
- }
1179
- });
1180
-
1181
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/OSSKeys.ts
1182
- var init_OSSKeys2 = __esm({
1183
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
1184
- "use strict";
1185
- init_consts2();
1186
- }
1187
- });
1188
-
1189
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
1190
- var openAICoral2, openAIAsh2, openAIBallad2, openAINova2, openAIVerse2;
1191
- var init_CompanionProfiles2 = __esm({
1192
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
1193
- "use strict";
1194
- init_types4();
1195
- openAICoral2 = createVoice2({
1196
- name: "coral",
1197
- provider: "openai",
1198
- gender: "F",
1199
- instructions: "sweet, cute,naive voice"
1200
- });
1201
- openAIAsh2 = createVoice2({
1202
- name: "ash",
1203
- provider: "openai",
1204
- gender: "M"
1205
- });
1206
- openAIBallad2 = createVoice2({
1207
- name: "ballad",
1208
- provider: "openai",
1209
- gender: "M",
1210
- instructions: "bright, young man voice"
1211
- });
1212
- openAINova2 = createVoice2({
1213
- name: "nova",
1214
- provider: "openai",
1215
- gender: "F",
1216
- instructions: "mature, smooth, elegant, warm voice"
1217
- });
1218
- openAIVerse2 = createVoice2({
1219
- name: "verse",
1220
- provider: "openai",
1221
- gender: "M",
1222
- instructions: "elderly,mysterious wizzard voice"
1223
- });
1224
- }
1225
- });
1226
-
1227
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/index.ts
1228
- var init_config2 = __esm({
1229
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/config/index.ts"() {
1230
- "use strict";
1231
- init_BizErrorCode2();
1232
- init_consts2();
1233
- init_TopicNames2();
1234
- init_OSSKeys2();
1235
- init_CompanionProfiles2();
1236
- }
1237
- });
1238
-
1239
- // node_modules/@pmate/lang/node_modules/@pmate/meta/src/index.ts
1240
- var init_src2 = __esm({
1241
- "node_modules/@pmate/lang/node_modules/@pmate/meta/src/index.ts"() {
1242
- "use strict";
1243
- init_types4();
1244
- init_config2();
1245
- }
1246
- });
1247
-
1248
- // node_modules/@pmate/lang/src/utils.ts
840
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/utils.ts
1249
841
  var init_utils = __esm({
1250
- "node_modules/@pmate/lang/src/utils.ts"() {
842
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/utils.ts"() {
1251
843
  "use strict";
1252
- init_src2();
844
+ init_src();
1253
845
  }
1254
846
  });
1255
847
 
1256
- // node_modules/@pmate/lang/src/index.ts
1257
- var init_src3 = __esm({
1258
- "node_modules/@pmate/lang/src/index.ts"() {
848
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/index.ts
849
+ var init_src2 = __esm({
850
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/index.ts"() {
1259
851
  "use strict";
1260
852
  init_sentenceSpliter();
1261
853
  init_sentenceTrim();
@@ -1271,32 +863,32 @@ var init_src3 = __esm({
1271
863
  }
1272
864
  });
1273
865
 
1274
- // node_modules/@pmate/utils/src/bookStats.ts
866
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/bookStats.ts
1275
867
  var init_bookStats = __esm({
1276
- "node_modules/@pmate/utils/src/bookStats.ts"() {
868
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/bookStats.ts"() {
1277
869
  "use strict";
1278
- init_src3();
870
+ init_src2();
1279
871
  }
1280
872
  });
1281
873
 
1282
- // node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts
874
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts
1283
875
  var init_BoundedConcurrentQueue = __esm({
1284
- "node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts"() {
876
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts"() {
1285
877
  "use strict";
1286
878
  }
1287
879
  });
1288
880
 
1289
- // node_modules/@pmate/utils/src/lru.ts
881
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/lru.ts
1290
882
  var init_lru = __esm({
1291
- "node_modules/@pmate/utils/src/lru.ts"() {
883
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/lru.ts"() {
1292
884
  "use strict";
1293
885
  init_Cache();
1294
886
  }
1295
887
  });
1296
888
 
1297
- // node_modules/js-sha3/src/sha3.js
889
+ // node_modules/.pnpm/js-sha3@0.9.3/node_modules/js-sha3/src/sha3.js
1298
890
  var require_sha3 = __commonJS({
1299
- "node_modules/js-sha3/src/sha3.js"(exports2, module2) {
891
+ "node_modules/.pnpm/js-sha3@0.9.3/node_modules/js-sha3/src/sha3.js"(exports2, module2) {
1300
892
  "use strict";
1301
893
  (function() {
1302
894
  "use strict";
@@ -1941,24 +1533,24 @@ var require_sha3 = __commonJS({
1941
1533
  }
1942
1534
  });
1943
1535
 
1944
- // node_modules/@pmate/utils/src/Maybe.ts
1536
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Maybe.ts
1945
1537
  var init_Maybe = __esm({
1946
- "node_modules/@pmate/utils/src/Maybe.ts"() {
1538
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Maybe.ts"() {
1947
1539
  "use strict";
1948
1540
  }
1949
1541
  });
1950
1542
 
1951
- // node_modules/@pmate/utils/src/cacheMethodInMem.ts
1543
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/cacheMethodInMem.ts
1952
1544
  var import_js_sha3;
1953
1545
  var init_cacheMethodInMem = __esm({
1954
- "node_modules/@pmate/utils/src/cacheMethodInMem.ts"() {
1546
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/cacheMethodInMem.ts"() {
1955
1547
  "use strict";
1956
1548
  import_js_sha3 = __toESM(require_sha3(), 1);
1957
1549
  init_Maybe();
1958
1550
  }
1959
1551
  });
1960
1552
 
1961
- // node_modules/pako/dist/pako.esm.mjs
1553
+ // node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs
1962
1554
  function zero$1(buf) {
1963
1555
  let len = buf.length;
1964
1556
  while (--len >= 0) {
@@ -2246,7 +1838,7 @@ function inflateRaw$1(input, options) {
2246
1838
  }
2247
1839
  var Z_FIXED$1, Z_BINARY, Z_TEXT, Z_UNKNOWN$1, STORED_BLOCK, STATIC_TREES, DYN_TREES, MIN_MATCH$1, MAX_MATCH$1, LENGTH_CODES$1, LITERALS$1, L_CODES$1, D_CODES$1, BL_CODES$1, HEAP_SIZE$1, MAX_BITS$1, Buf_size, MAX_BL_BITS, END_BLOCK, REP_3_6, REPZ_3_10, REPZ_11_138, extra_lbits, extra_dbits, extra_blbits, bl_order, DIST_CODE_LEN, static_ltree, static_dtree, _dist_code, _length_code, base_length, base_dist, static_l_desc, static_d_desc, static_bl_desc, d_code, put_short, send_bits, send_code, bi_reverse, bi_flush, gen_bitlen, gen_codes, tr_static_init, init_block, bi_windup, smaller, pqdownheap, compress_block, build_tree, scan_tree, send_tree, build_bl_tree, send_all_trees, detect_data_type, static_init_done, _tr_init$1, _tr_stored_block$1, _tr_align$1, _tr_flush_block$1, _tr_tally$1, _tr_init_1, _tr_stored_block_1, _tr_flush_block_1, _tr_tally_1, _tr_align_1, trees, adler32, adler32_1, makeTable, crcTable, crc32, crc32_1, messages, constants$2, _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align, Z_NO_FLUSH$2, Z_PARTIAL_FLUSH, Z_FULL_FLUSH$1, Z_FINISH$3, Z_BLOCK$1, Z_OK$3, Z_STREAM_END$3, Z_STREAM_ERROR$2, Z_DATA_ERROR$2, Z_BUF_ERROR$1, Z_DEFAULT_COMPRESSION$1, Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY$1, Z_UNKNOWN, Z_DEFLATED$2, MAX_MEM_LEVEL, MAX_WBITS$1, DEF_MEM_LEVEL, LENGTH_CODES, LITERALS, L_CODES, D_CODES, BL_CODES, HEAP_SIZE, MAX_BITS, MIN_MATCH, MAX_MATCH, MIN_LOOKAHEAD, PRESET_DICT, INIT_STATE, GZIP_STATE, EXTRA_STATE, NAME_STATE, COMMENT_STATE, HCRC_STATE, BUSY_STATE, FINISH_STATE, BS_NEED_MORE, BS_BLOCK_DONE, BS_FINISH_STARTED, BS_FINISH_DONE, OS_CODE, err, rank, zero, slide_hash, HASH_ZLIB, HASH, flush_pending, flush_block_only, put_byte, putShortMSB, read_buf, longest_match, fill_window, deflate_stored, deflate_fast, deflate_slow, deflate_rle, deflate_huff, configuration_table, lm_init, deflateStateCheck, deflateResetKeep, deflateReset, deflateSetHeader, deflateInit2, deflateInit, deflate$2, deflateEnd, deflateSetDictionary, deflateInit_1, deflateInit2_1, deflateReset_1, deflateResetKeep_1, deflateSetHeader_1, deflate_2$1, deflateEnd_1, deflateSetDictionary_1, deflateInfo, deflate_1$2, _has, assign, flattenChunks, common, STR_APPLY_UIA_OK, _utf8len, string2buf, buf2binstring, buf2string, utf8border, strings, zstream, toString$1, Z_NO_FLUSH$1, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH$2, Z_OK$2, Z_STREAM_END$2, Z_DEFAULT_COMPRESSION, Z_DEFAULT_STRATEGY, Z_DEFLATED$1, Deflate_1$1, deflate_2, deflateRaw_1$1, gzip_1$1, constants$1, deflate_1$1, BAD$1, TYPE$1, inffast, MAXBITS, ENOUGH_LENS$1, ENOUGH_DISTS$1, CODES$1, LENS$1, DISTS$1, lbase, lext, dbase, dext, inflate_table, inftrees, CODES, LENS, DISTS, Z_FINISH$1, Z_BLOCK, Z_TREES, Z_OK$1, Z_STREAM_END$1, Z_NEED_DICT$1, Z_STREAM_ERROR$1, Z_DATA_ERROR$1, Z_MEM_ERROR$1, Z_BUF_ERROR, Z_DEFLATED, HEAD, FLAGS, TIME, OS, EXLEN, EXTRA, NAME, COMMENT, HCRC, DICTID, DICT, TYPE, TYPEDO, STORED, COPY_, COPY, TABLE, LENLENS, CODELENS, LEN_, LEN, LENEXT, DIST, DISTEXT, MATCH, LIT, CHECK, LENGTH, DONE, BAD, MEM, SYNC, ENOUGH_LENS, ENOUGH_DISTS, MAX_WBITS, DEF_WBITS, zswap32, inflateStateCheck, inflateResetKeep, inflateReset, inflateReset2, inflateInit2, inflateInit, virgin, lenfix, distfix, fixedtables, updatewindow, inflate$2, inflateEnd, inflateGetHeader, inflateSetDictionary, inflateReset_1, inflateReset2_1, inflateResetKeep_1, inflateInit_1, inflateInit2_1, inflate_2$1, inflateEnd_1, inflateGetHeader_1, inflateSetDictionary_1, inflateInfo, inflate_1$2, gzheader, toString, Z_NO_FLUSH, Z_FINISH, Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR, Inflate_1$1, inflate_2, inflateRaw_1$1, ungzip$1, constants, inflate_1$1, Deflate, deflate, deflateRaw, gzip, Inflate, inflate, inflateRaw, ungzip, gzip_1;
2248
1840
  var init_pako_esm = __esm({
2249
- "node_modules/pako/dist/pako.esm.mjs"() {
1841
+ "node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs"() {
2250
1842
  "use strict";
2251
1843
  Z_FIXED$1 = 4;
2252
1844
  Z_BINARY = 0;
@@ -6127,7 +5719,7 @@ var init_pako_esm = __esm({
6127
5719
  }
6128
5720
  });
6129
5721
 
6130
- // node_modules/@pmate/utils/src/compress.ts
5722
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/compress.ts
6131
5723
  async function gzipEncodeBlob(input) {
6132
5724
  const array = await toUint8Array(input);
6133
5725
  return gzip_1(array);
@@ -6153,16 +5745,16 @@ async function toUint8Array(input) {
6153
5745
  throw new TypeError("Unsupported input type for gzipEncodeBlob");
6154
5746
  }
6155
5747
  var init_compress = __esm({
6156
- "node_modules/@pmate/utils/src/compress.ts"() {
5748
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/compress.ts"() {
6157
5749
  "use strict";
6158
5750
  init_pako_esm();
6159
5751
  }
6160
5752
  });
6161
5753
 
6162
- // node_modules/@pmate/utils/src/AsyncStream.ts
5754
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/AsyncStream.ts
6163
5755
  var AsyncStream;
6164
5756
  var init_AsyncStream = __esm({
6165
- "node_modules/@pmate/utils/src/AsyncStream.ts"() {
5757
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/AsyncStream.ts"() {
6166
5758
  "use strict";
6167
5759
  AsyncStream = class _AsyncStream {
6168
5760
  constructor() {
@@ -6350,426 +5942,12 @@ var init_AsyncStream = __esm({
6350
5942
  }
6351
5943
  });
6352
5944
 
6353
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/account.types.ts
6354
- var init_account_types3 = __esm({
6355
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/account.types.ts"() {
6356
- "use strict";
6357
- }
6358
- });
6359
-
6360
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/achievements.types.ts
6361
- var init_achievements_types3 = __esm({
6362
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
6363
- "use strict";
6364
- }
6365
- });
6366
-
6367
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/aigen.types.ts
6368
- var init_aigen_types3 = __esm({
6369
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
6370
- "use strict";
6371
- }
6372
- });
6373
-
6374
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent.types.ts
6375
- var init_agent_types3 = __esm({
6376
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent.types.ts"() {
6377
- "use strict";
6378
- }
6379
- });
6380
-
6381
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent-registry.types.ts
6382
- var init_agent_registry_types3 = __esm({
6383
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
6384
- "use strict";
6385
- }
6386
- });
6387
-
6388
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/runner-registry.types.ts
6389
- var init_runner_registry_types3 = __esm({
6390
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
6391
- "use strict";
6392
- }
6393
- });
6394
-
6395
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/blockchain.types.ts
6396
- var init_blockchain_types3 = __esm({
6397
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
6398
- "use strict";
6399
- }
6400
- });
6401
-
6402
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/breakdown.types.ts
6403
- var init_breakdown_types3 = __esm({
6404
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
6405
- "use strict";
6406
- }
6407
- });
6408
-
6409
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/chat.types.ts
6410
- var init_chat_types3 = __esm({
6411
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/chat.types.ts"() {
6412
- "use strict";
6413
- }
6414
- });
6415
-
6416
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/companion.types.ts
6417
- var init_companion_types3 = __esm({
6418
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/companion.types.ts"() {
6419
- "use strict";
6420
- }
6421
- });
6422
-
6423
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/enums.ts
6424
- var init_enums3 = __esm({
6425
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/enums.ts"() {
6426
- "use strict";
6427
- }
6428
- });
6429
-
6430
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/lang.types.ts
6431
- var init_lang_types3 = __esm({
6432
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/lang.types.ts"() {
6433
- "use strict";
6434
- }
6435
- });
6436
-
6437
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/logs.types.ts
6438
- var init_logs_types3 = __esm({
6439
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/logs.types.ts"() {
6440
- "use strict";
6441
- }
6442
- });
6443
-
6444
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/message.types.ts
6445
- var PING, PONG;
6446
- var init_message_types3 = __esm({
6447
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/message.types.ts"() {
6448
- "use strict";
6449
- PING = 1;
6450
- PONG = 2;
6451
- }
6452
- });
6453
-
6454
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/newLog.types.ts
6455
- var init_newLog_types3 = __esm({
6456
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
6457
- "use strict";
6458
- }
6459
- });
6460
-
6461
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/novel.types.ts
6462
- var init_novel_types3 = __esm({
6463
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/novel.types.ts"() {
6464
- "use strict";
6465
- }
6466
- });
6467
-
6468
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/offline.types.ts
6469
- var init_offline_types3 = __esm({
6470
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/offline.types.ts"() {
6471
- "use strict";
6472
- }
6473
- });
6474
-
6475
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/prompt.types.ts
6476
- var init_prompt_types3 = __esm({
6477
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
6478
- "use strict";
6479
- }
6480
- });
6481
-
6482
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/reading.types.ts
6483
- var init_reading_types3 = __esm({
6484
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/reading.types.ts"() {
6485
- "use strict";
6486
- }
6487
- });
6488
-
6489
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/settings.types.ts
6490
- var init_settings_types3 = __esm({
6491
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/settings.types.ts"() {
6492
- "use strict";
6493
- }
6494
- });
6495
-
6496
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/subscription.types.ts
6497
- var init_subscription_types3 = __esm({
6498
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
6499
- "use strict";
6500
- }
6501
- });
6502
-
6503
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/types.ts
6504
- var buildVoiceKey3, createVoice3;
6505
- var init_types5 = __esm({
6506
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/types.ts"() {
6507
- "use strict";
6508
- buildVoiceKey3 = (provider, name) => {
6509
- return `${provider}:${name}`;
6510
- };
6511
- createVoice3 = ({
6512
- name,
6513
- provider,
6514
- gender,
6515
- instructions
6516
- }) => {
6517
- return {
6518
- name,
6519
- provider,
6520
- gender,
6521
- instructions,
6522
- key: buildVoiceKey3(provider, name)
6523
- };
6524
- };
6525
- }
6526
- });
6527
-
6528
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/wordv5.def.ts
6529
- var init_wordv5_def3 = __esm({
6530
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
6531
- "use strict";
6532
- }
6533
- });
6534
-
6535
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/auth.types.ts
6536
- var init_auth_types3 = __esm({
6537
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/auth.types.ts"() {
6538
- "use strict";
6539
- }
6540
- });
6541
-
6542
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/apps.types.ts
6543
- var init_apps_types3 = __esm({
6544
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/apps.types.ts"() {
6545
- "use strict";
6546
- }
6547
- });
6548
-
6549
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/response.types.ts
6550
- var init_response_types3 = __esm({
6551
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/response.types.ts"() {
6552
- "use strict";
6553
- }
6554
- });
6555
-
6556
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/role.types.ts
6557
- var init_role_types3 = __esm({
6558
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/role.types.ts"() {
6559
- "use strict";
6560
- }
6561
- });
6562
-
6563
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/index.ts
6564
- var init_types6 = __esm({
6565
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/index.ts"() {
6566
- "use strict";
6567
- init_account_types3();
6568
- init_achievements_types3();
6569
- init_aigen_types3();
6570
- init_agent_types3();
6571
- init_agent_registry_types3();
6572
- init_runner_registry_types3();
6573
- init_blockchain_types3();
6574
- init_breakdown_types3();
6575
- init_chat_types3();
6576
- init_companion_types3();
6577
- init_enums3();
6578
- init_lang_types3();
6579
- init_logs_types3();
6580
- init_message_types3();
6581
- init_newLog_types3();
6582
- init_novel_types3();
6583
- init_offline_types3();
6584
- init_prompt_types3();
6585
- init_reading_types3();
6586
- init_settings_types3();
6587
- init_subscription_types3();
6588
- init_types5();
6589
- init_wordv5_def3();
6590
- init_auth_types3();
6591
- init_apps_types3();
6592
- init_response_types3();
6593
- init_role_types3();
6594
- }
6595
- });
6596
-
6597
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/BizErrorCode.ts
6598
- var init_BizErrorCode3 = __esm({
6599
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
6600
- "use strict";
6601
- }
6602
- });
6603
-
6604
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/consts.ts
6605
- var init_consts3 = __esm({
6606
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/consts.ts"() {
6607
- "use strict";
6608
- }
6609
- });
6610
-
6611
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/TopicNames.ts
6612
- var TopicNames3, topicKindMatchers3;
6613
- var init_TopicNames3 = __esm({
6614
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
6615
- "use strict";
6616
- init_types6();
6617
- TopicNames3 = class _TopicNames {
6618
- static rooms() {
6619
- return "@pmate/rooms";
6620
- }
6621
- static userThreads(user) {
6622
- return `@pmate/user_threads:${user}`;
6623
- }
6624
- static userLogs(user) {
6625
- return `@pmate/user_logs:${user}`;
6626
- }
6627
- static legacyUserLogs(user) {
6628
- return _TopicNames.userLogs(user);
6629
- }
6630
- static userContacts(profileId) {
6631
- return `@pmate/user_contacts:${profileId}`;
6632
- }
6633
- static usersMessage(userId) {
6634
- return `@pmate/user_messages:${userId}`;
6635
- }
6636
- static userMapping() {
6637
- return "@pmate/username_mapping";
6638
- }
6639
- static userMobileMapping() {
6640
- return "@pmate/mobile_account";
6641
- }
6642
- static mapping() {
6643
- return "@pmate/mapping";
6644
- }
6645
- static profiles() {
6646
- return "@pmate/profiles";
6647
- }
6648
- static groups() {
6649
- return "@pmate/groups";
6650
- }
6651
- static relationships() {
6652
- return "@pmate/relationships";
6653
- }
6654
- };
6655
- topicKindMatchers3 = [
6656
- {
6657
- kind: 1e3 /* UserLogs */,
6658
- match: (topic) => topic.startsWith("@pmate/user_logs:")
6659
- },
6660
- {
6661
- kind: 2e3 /* UserMessages */,
6662
- match: (topic) => topic.startsWith("@pmate/user_messages:")
6663
- },
6664
- {
6665
- kind: 3e3 /* Relationships */,
6666
- match: (topic) => topic === TopicNames3.relationships()
6667
- },
6668
- {
6669
- kind: 4e3 /* Rooms */,
6670
- match: (topic) => topic === TopicNames3.rooms()
6671
- },
6672
- {
6673
- kind: 5e3 /* UserContacts */,
6674
- match: (topic) => topic.startsWith("@pmate/user_contacts:")
6675
- },
6676
- {
6677
- kind: 8002 /* Entity_GROUP */,
6678
- match: (topic) => topic === TopicNames3.groups()
6679
- },
6680
- {
6681
- kind: 6e3 /* UserMapping */,
6682
- match: (topic) => topic === TopicNames3.userMapping()
6683
- },
6684
- {
6685
- kind: 7e3 /* UserMobileMapping */,
6686
- match: (topic) => topic === TopicNames3.userMobileMapping()
6687
- },
6688
- {
6689
- kind: 6003 /* Mapping */,
6690
- match: (topic) => topic === TopicNames3.mapping()
6691
- },
6692
- {
6693
- kind: 9e3 /* UserThreads */,
6694
- match: (topic) => topic.startsWith("@pmate/user_threads:")
6695
- }
6696
- ];
6697
- }
6698
- });
6699
-
6700
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/OSSKeys.ts
6701
- var init_OSSKeys3 = __esm({
6702
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
6703
- "use strict";
6704
- init_consts3();
6705
- }
6706
- });
6707
-
6708
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
6709
- var openAICoral3, openAIAsh3, openAIBallad3, openAINova3, openAIVerse3;
6710
- var init_CompanionProfiles3 = __esm({
6711
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
6712
- "use strict";
6713
- init_types6();
6714
- openAICoral3 = createVoice3({
6715
- name: "coral",
6716
- provider: "openai",
6717
- gender: "F",
6718
- instructions: "sweet, cute,naive voice"
6719
- });
6720
- openAIAsh3 = createVoice3({
6721
- name: "ash",
6722
- provider: "openai",
6723
- gender: "M"
6724
- });
6725
- openAIBallad3 = createVoice3({
6726
- name: "ballad",
6727
- provider: "openai",
6728
- gender: "M",
6729
- instructions: "bright, young man voice"
6730
- });
6731
- openAINova3 = createVoice3({
6732
- name: "nova",
6733
- provider: "openai",
6734
- gender: "F",
6735
- instructions: "mature, smooth, elegant, warm voice"
6736
- });
6737
- openAIVerse3 = createVoice3({
6738
- name: "verse",
6739
- provider: "openai",
6740
- gender: "M",
6741
- instructions: "elderly,mysterious wizzard voice"
6742
- });
6743
- }
6744
- });
6745
-
6746
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/index.ts
6747
- var init_config3 = __esm({
6748
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/index.ts"() {
6749
- "use strict";
6750
- init_BizErrorCode3();
6751
- init_consts3();
6752
- init_TopicNames3();
6753
- init_OSSKeys3();
6754
- init_CompanionProfiles3();
6755
- }
6756
- });
6757
-
6758
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/index.ts
6759
- var init_src4 = __esm({
6760
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/index.ts"() {
6761
- "use strict";
6762
- init_types6();
6763
- init_config3();
6764
- }
6765
- });
6766
-
6767
- // node_modules/@pmate/utils/src/uniqHash.ts
5945
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/uniqHash.ts
6768
5946
  var import_js_sha32, sortKeys, uniqHash;
6769
5947
  var init_uniqHash = __esm({
6770
- "node_modules/@pmate/utils/src/uniqHash.ts"() {
5948
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/uniqHash.ts"() {
6771
5949
  "use strict";
6772
- init_src4();
5950
+ init_src();
6773
5951
  import_js_sha32 = __toESM(require_sha3(), 1);
6774
5952
  sortKeys = (obj) => {
6775
5953
  if (Array.isArray(obj)) {
@@ -6797,33 +5975,33 @@ var init_uniqHash = __esm({
6797
5975
  }
6798
5976
  });
6799
5977
 
6800
- // node_modules/@pmate/utils/src/createMsg.ts
5978
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/createMsg.ts
6801
5979
  var init_createMsg = __esm({
6802
- "node_modules/@pmate/utils/src/createMsg.ts"() {
5980
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/createMsg.ts"() {
6803
5981
  "use strict";
6804
- init_src4();
5982
+ init_src();
6805
5983
  init_uniqHash();
6806
5984
  }
6807
5985
  });
6808
5986
 
6809
- // node_modules/@pmate/utils/src/detectText.ts
5987
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/detectText.ts
6810
5988
  var init_detectText = __esm({
6811
- "node_modules/@pmate/utils/src/detectText.ts"() {
5989
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/detectText.ts"() {
6812
5990
  "use strict";
6813
5991
  }
6814
5992
  });
6815
5993
 
6816
- // node_modules/@pmate/utils/src/Emitter.ts
5994
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Emitter.ts
6817
5995
  var init_Emitter = __esm({
6818
- "node_modules/@pmate/utils/src/Emitter.ts"() {
5996
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Emitter.ts"() {
6819
5997
  "use strict";
6820
5998
  }
6821
5999
  });
6822
6000
 
6823
- // node_modules/@pmate/utils/src/EmitterV2.ts
6001
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/EmitterV2.ts
6824
6002
  var EmitterV2;
6825
6003
  var init_EmitterV2 = __esm({
6826
- "node_modules/@pmate/utils/src/EmitterV2.ts"() {
6004
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/EmitterV2.ts"() {
6827
6005
  "use strict";
6828
6006
  EmitterV2 = class {
6829
6007
  constructor() {
@@ -6879,39 +6057,39 @@ var init_EmitterV2 = __esm({
6879
6057
  }
6880
6058
  });
6881
6059
 
6882
- // node_modules/@pmate/utils/src/format/formatTime.ts
6060
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/formatTime.ts
6883
6061
  var init_formatTime = __esm({
6884
- "node_modules/@pmate/utils/src/format/formatTime.ts"() {
6062
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/formatTime.ts"() {
6885
6063
  "use strict";
6886
6064
  }
6887
6065
  });
6888
6066
 
6889
- // node_modules/@pmate/utils/src/format/index.ts
6067
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/index.ts
6890
6068
  var init_format = __esm({
6891
- "node_modules/@pmate/utils/src/format/index.ts"() {
6069
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/index.ts"() {
6892
6070
  "use strict";
6893
6071
  init_formatTime();
6894
6072
  }
6895
6073
  });
6896
6074
 
6897
- // node_modules/@pmate/utils/src/isVolcabulary.ts
6075
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/isVolcabulary.ts
6898
6076
  var init_isVolcabulary = __esm({
6899
- "node_modules/@pmate/utils/src/isVolcabulary.ts"() {
6077
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/isVolcabulary.ts"() {
6900
6078
  "use strict";
6901
6079
  }
6902
6080
  });
6903
6081
 
6904
- // node_modules/@pmate/utils/src/Loadable.ts
6082
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Loadable.ts
6905
6083
  var init_Loadable = __esm({
6906
- "node_modules/@pmate/utils/src/Loadable.ts"() {
6084
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Loadable.ts"() {
6907
6085
  "use strict";
6908
6086
  }
6909
6087
  });
6910
6088
 
6911
- // node_modules/@pmate/utils/src/Logger.ts
6089
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Logger.ts
6912
6090
  var Logger;
6913
6091
  var init_Logger = __esm({
6914
- "node_modules/@pmate/utils/src/Logger.ts"() {
6092
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Logger.ts"() {
6915
6093
  "use strict";
6916
6094
  Logger = class _Logger {
6917
6095
  constructor(name) {
@@ -6936,21 +6114,21 @@ var init_Logger = __esm({
6936
6114
  }
6937
6115
  });
6938
6116
 
6939
- // node_modules/@pmate/utils/src/mapToReadingBook.ts
6117
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/mapToReadingBook.ts
6940
6118
  var init_mapToReadingBook = __esm({
6941
- "node_modules/@pmate/utils/src/mapToReadingBook.ts"() {
6119
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/mapToReadingBook.ts"() {
6942
6120
  "use strict";
6943
6121
  }
6944
6122
  });
6945
6123
 
6946
- // node_modules/@pmate/utils/src/memoize.ts
6124
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/memoize.ts
6947
6125
  var init_memoize = __esm({
6948
- "node_modules/@pmate/utils/src/memoize.ts"() {
6126
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/memoize.ts"() {
6949
6127
  "use strict";
6950
6128
  }
6951
6129
  });
6952
6130
 
6953
- // node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
6131
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
6954
6132
  function utf8Count(str) {
6955
6133
  const strLength = str.length;
6956
6134
  let byteLength = 0;
@@ -7077,7 +6255,7 @@ function utf8Decode(bytes, inputOffset, byteLength) {
7077
6255
  }
7078
6256
  var sharedTextEncoder, TEXT_ENCODER_THRESHOLD, CHUNK_SIZE, sharedTextDecoder, TEXT_DECODER_THRESHOLD;
7079
6257
  var init_utf8 = __esm({
7080
- "node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs"() {
6258
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs"() {
7081
6259
  "use strict";
7082
6260
  sharedTextEncoder = new TextEncoder();
7083
6261
  TEXT_ENCODER_THRESHOLD = 50;
@@ -7087,10 +6265,10 @@ var init_utf8 = __esm({
7087
6265
  }
7088
6266
  });
7089
6267
 
7090
- // node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs
6268
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs
7091
6269
  var ExtData;
7092
6270
  var init_ExtData = __esm({
7093
- "node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs"() {
6271
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs"() {
7094
6272
  "use strict";
7095
6273
  ExtData = class {
7096
6274
  type;
@@ -7103,10 +6281,10 @@ var init_ExtData = __esm({
7103
6281
  }
7104
6282
  });
7105
6283
 
7106
- // node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs
6284
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs
7107
6285
  var DecodeError;
7108
6286
  var init_DecodeError = __esm({
7109
- "node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs"() {
6287
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs"() {
7110
6288
  "use strict";
7111
6289
  DecodeError = class _DecodeError extends Error {
7112
6290
  constructor(message) {
@@ -7123,7 +6301,7 @@ var init_DecodeError = __esm({
7123
6301
  }
7124
6302
  });
7125
6303
 
7126
- // node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs
6304
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs
7127
6305
  function setUint64(view, offset, value) {
7128
6306
  const high = value / 4294967296;
7129
6307
  const low = value;
@@ -7148,13 +6326,13 @@ function getUint64(view, offset) {
7148
6326
  }
7149
6327
  var UINT32_MAX;
7150
6328
  var init_int = __esm({
7151
- "node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs"() {
6329
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs"() {
7152
6330
  "use strict";
7153
6331
  UINT32_MAX = 4294967295;
7154
6332
  }
7155
6333
  });
7156
6334
 
7157
- // node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs
6335
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs
7158
6336
  function encodeTimeSpecToTimestamp({ sec, nsec }) {
7159
6337
  if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
7160
6338
  if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
@@ -7227,7 +6405,7 @@ function decodeTimestampExtension(data) {
7227
6405
  }
7228
6406
  var EXT_TIMESTAMP, TIMESTAMP32_MAX_SEC, TIMESTAMP64_MAX_SEC, timestampExtension;
7229
6407
  var init_timestamp = __esm({
7230
- "node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs"() {
6408
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs"() {
7231
6409
  "use strict";
7232
6410
  init_DecodeError();
7233
6411
  init_int();
@@ -7242,10 +6420,10 @@ var init_timestamp = __esm({
7242
6420
  }
7243
6421
  });
7244
6422
 
7245
- // node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs
6423
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs
7246
6424
  var ExtensionCodec;
7247
6425
  var init_ExtensionCodec = __esm({
7248
- "node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs"() {
6426
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs"() {
7249
6427
  "use strict";
7250
6428
  init_ExtData();
7251
6429
  init_timestamp();
@@ -7312,7 +6490,7 @@ var init_ExtensionCodec = __esm({
7312
6490
  }
7313
6491
  });
7314
6492
 
7315
- // node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs
6493
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs
7316
6494
  function isArrayBufferLike(buffer) {
7317
6495
  return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
7318
6496
  }
@@ -7328,15 +6506,15 @@ function ensureUint8Array(buffer) {
7328
6506
  }
7329
6507
  }
7330
6508
  var init_typedArrays = __esm({
7331
- "node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs"() {
6509
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs"() {
7332
6510
  "use strict";
7333
6511
  }
7334
6512
  });
7335
6513
 
7336
- // node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs
6514
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs
7337
6515
  var DEFAULT_MAX_DEPTH, DEFAULT_INITIAL_BUFFER_SIZE, Encoder;
7338
6516
  var init_Encoder = __esm({
7339
- "node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs"() {
6517
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs"() {
7340
6518
  "use strict";
7341
6519
  init_utf8();
7342
6520
  init_ExtensionCodec();
@@ -7746,32 +6924,32 @@ var init_Encoder = __esm({
7746
6924
  }
7747
6925
  });
7748
6926
 
7749
- // node_modules/@msgpack/msgpack/dist.esm/encode.mjs
6927
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/encode.mjs
7750
6928
  function encode(value, options) {
7751
6929
  const encoder2 = new Encoder(options);
7752
6930
  return encoder2.encodeSharedRef(value);
7753
6931
  }
7754
6932
  var init_encode = __esm({
7755
- "node_modules/@msgpack/msgpack/dist.esm/encode.mjs"() {
6933
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/encode.mjs"() {
7756
6934
  "use strict";
7757
6935
  init_Encoder();
7758
6936
  }
7759
6937
  });
7760
6938
 
7761
- // node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs
6939
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs
7762
6940
  function prettyByte(byte) {
7763
6941
  return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
7764
6942
  }
7765
6943
  var init_prettyByte = __esm({
7766
- "node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs"() {
6944
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs"() {
7767
6945
  "use strict";
7768
6946
  }
7769
6947
  });
7770
6948
 
7771
- // node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs
6949
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs
7772
6950
  var DEFAULT_MAX_KEY_LENGTH, DEFAULT_MAX_LENGTH_PER_KEY, CachedKeyDecoder;
7773
6951
  var init_CachedKeyDecoder = __esm({
7774
- "node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs"() {
6952
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs"() {
7775
6953
  "use strict";
7776
6954
  init_utf8();
7777
6955
  DEFAULT_MAX_KEY_LENGTH = 16;
@@ -7831,10 +7009,10 @@ var init_CachedKeyDecoder = __esm({
7831
7009
  }
7832
7010
  });
7833
7011
 
7834
- // node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs
7012
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs
7835
7013
  var STATE_ARRAY, STATE_MAP_KEY, STATE_MAP_VALUE, mapKeyConverter, StackPool, HEAD_BYTE_REQUIRED, EMPTY_VIEW, EMPTY_BYTES, MORE_DATA, sharedCachedKeyDecoder, Decoder;
7836
7014
  var init_Decoder = __esm({
7837
- "node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs"() {
7015
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs"() {
7838
7016
  "use strict";
7839
7017
  init_prettyByte();
7840
7018
  init_ExtensionCodec();
@@ -8472,34 +7650,34 @@ var init_Decoder = __esm({
8472
7650
  }
8473
7651
  });
8474
7652
 
8475
- // node_modules/@msgpack/msgpack/dist.esm/decode.mjs
7653
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/decode.mjs
8476
7654
  function decode(buffer, options) {
8477
7655
  const decoder = new Decoder(options);
8478
7656
  return decoder.decode(buffer);
8479
7657
  }
8480
7658
  var init_decode = __esm({
8481
- "node_modules/@msgpack/msgpack/dist.esm/decode.mjs"() {
7659
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/decode.mjs"() {
8482
7660
  "use strict";
8483
7661
  init_Decoder();
8484
7662
  }
8485
7663
  });
8486
7664
 
8487
- // node_modules/@msgpack/msgpack/dist.esm/index.mjs
7665
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/index.mjs
8488
7666
  var init_dist = __esm({
8489
- "node_modules/@msgpack/msgpack/dist.esm/index.mjs"() {
7667
+ "node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/index.mjs"() {
8490
7668
  "use strict";
8491
7669
  init_encode();
8492
7670
  init_decode();
8493
7671
  }
8494
7672
  });
8495
7673
 
8496
- // node_modules/@pmate/utils/src/Msg.ts
7674
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Msg.ts
8497
7675
  var encoder, Msg;
8498
7676
  var init_Msg = __esm({
8499
- "node_modules/@pmate/utils/src/Msg.ts"() {
7677
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Msg.ts"() {
8500
7678
  "use strict";
8501
7679
  init_dist();
8502
- init_src4();
7680
+ init_src();
8503
7681
  init_compress();
8504
7682
  init_uniqHash();
8505
7683
  encoder = new TextEncoder();
@@ -8624,108 +7802,108 @@ var init_Msg = __esm({
8624
7802
  }
8625
7803
  });
8626
7804
 
8627
- // node_modules/@pmate/utils/src/normalize.ts
7805
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/normalize.ts
8628
7806
  var init_normalize = __esm({
8629
- "node_modules/@pmate/utils/src/normalize.ts"() {
7807
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/normalize.ts"() {
8630
7808
  "use strict";
8631
7809
  }
8632
7810
  });
8633
7811
 
8634
- // node_modules/@pmate/utils/src/pageURL.ts
7812
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/pageURL.ts
8635
7813
  var init_pageURL = __esm({
8636
- "node_modules/@pmate/utils/src/pageURL.ts"() {
7814
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/pageURL.ts"() {
8637
7815
  "use strict";
8638
7816
  }
8639
7817
  });
8640
7818
 
8641
- // node_modules/@pmate/utils/src/PromiseQueue.ts
7819
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/PromiseQueue.ts
8642
7820
  var init_PromiseQueue = __esm({
8643
- "node_modules/@pmate/utils/src/PromiseQueue.ts"() {
7821
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/PromiseQueue.ts"() {
8644
7822
  "use strict";
8645
7823
  }
8646
7824
  });
8647
7825
 
8648
- // node_modules/@pmate/utils/src/resourceKey.ts
7826
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/resourceKey.ts
8649
7827
  var import_js_sha33;
8650
7828
  var init_resourceKey = __esm({
8651
- "node_modules/@pmate/utils/src/resourceKey.ts"() {
7829
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/resourceKey.ts"() {
8652
7830
  "use strict";
8653
7831
  import_js_sha33 = __toESM(require_sha3(), 1);
8654
7832
  }
8655
7833
  });
8656
7834
 
8657
- // node_modules/@pmate/utils/src/SelectionHelper.ts
7835
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/SelectionHelper.ts
8658
7836
  var init_SelectionHelper = __esm({
8659
- "node_modules/@pmate/utils/src/SelectionHelper.ts"() {
7837
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/SelectionHelper.ts"() {
8660
7838
  "use strict";
8661
7839
  }
8662
7840
  });
8663
7841
 
8664
- // node_modules/@pmate/utils/src/setMinus.ts
7842
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/setMinus.ts
8665
7843
  var init_setMinus = __esm({
8666
- "node_modules/@pmate/utils/src/setMinus.ts"() {
7844
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/setMinus.ts"() {
8667
7845
  "use strict";
8668
7846
  }
8669
7847
  });
8670
7848
 
8671
- // node_modules/@pmate/utils/src/sha1Hash.ts
7849
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/sha1Hash.ts
8672
7850
  var init_sha1Hash = __esm({
8673
- "node_modules/@pmate/utils/src/sha1Hash.ts"() {
7851
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/sha1Hash.ts"() {
8674
7852
  "use strict";
8675
7853
  }
8676
7854
  });
8677
7855
 
8678
- // node_modules/@pmate/utils/src/TaskWaiter.ts
7856
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/TaskWaiter.ts
8679
7857
  var init_TaskWaiter = __esm({
8680
- "node_modules/@pmate/utils/src/TaskWaiter.ts"() {
7858
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/TaskWaiter.ts"() {
8681
7859
  "use strict";
8682
- init_src5();
7860
+ init_src3();
8683
7861
  }
8684
7862
  });
8685
7863
 
8686
- // node_modules/@pmate/utils/src/toSentenceAnalyze.ts
7864
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/toSentenceAnalyze.ts
8687
7865
  var init_toSentenceAnalyze = __esm({
8688
- "node_modules/@pmate/utils/src/toSentenceAnalyze.ts"() {
7866
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/toSentenceAnalyze.ts"() {
8689
7867
  "use strict";
8690
7868
  }
8691
7869
  });
8692
7870
 
8693
- // node_modules/@pmate/utils/src/txtBookToJson.ts
7871
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/txtBookToJson.ts
8694
7872
  var init_txtBookToJson = __esm({
8695
- "node_modules/@pmate/utils/src/txtBookToJson.ts"() {
7873
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/txtBookToJson.ts"() {
8696
7874
  "use strict";
8697
- init_src3();
7875
+ init_src2();
8698
7876
  }
8699
7877
  });
8700
7878
 
8701
- // node_modules/@pmate/utils/src/VocabularyMap.ts
7879
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/VocabularyMap.ts
8702
7880
  var init_VocabularyMap = __esm({
8703
- "node_modules/@pmate/utils/src/VocabularyMap.ts"() {
7881
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/VocabularyMap.ts"() {
8704
7882
  "use strict";
8705
7883
  init_Emitter();
8706
7884
  }
8707
7885
  });
8708
7886
 
8709
- // node_modules/@pmate/utils/src/wait.ts
7887
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wait.ts
8710
7888
  var init_wait = __esm({
8711
- "node_modules/@pmate/utils/src/wait.ts"() {
7889
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wait.ts"() {
8712
7890
  "use strict";
8713
7891
  }
8714
7892
  });
8715
7893
 
8716
- // node_modules/@pmate/utils/src/wordCount.ts
7894
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wordCount.ts
8717
7895
  var init_wordCount = __esm({
8718
- "node_modules/@pmate/utils/src/wordCount.ts"() {
7896
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wordCount.ts"() {
8719
7897
  "use strict";
8720
7898
  }
8721
7899
  });
8722
7900
 
8723
- // node_modules/@pmate/utils/src/websocket/WebsocketHeartbeat.ts
7901
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/WebsocketHeartbeat.ts
8724
7902
  var logger, WebsocketHeartbeat;
8725
7903
  var init_WebsocketHeartbeat = __esm({
8726
- "node_modules/@pmate/utils/src/websocket/WebsocketHeartbeat.ts"() {
7904
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/WebsocketHeartbeat.ts"() {
8727
7905
  "use strict";
8728
- init_src4();
7906
+ init_src();
8729
7907
  init_Logger();
8730
7908
  logger = Logger.getDebugger("heartbeat");
8731
7909
  WebsocketHeartbeat = class {
@@ -8764,12 +7942,12 @@ var init_WebsocketHeartbeat = __esm({
8764
7942
  }
8765
7943
  });
8766
7944
 
8767
- // node_modules/@pmate/utils/src/websocket/WebsocketClient.ts
7945
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/WebsocketClient.ts
8768
7946
  var logger2;
8769
7947
  var init_WebsocketClient = __esm({
8770
- "node_modules/@pmate/utils/src/websocket/WebsocketClient.ts"() {
7948
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/WebsocketClient.ts"() {
8771
7949
  "use strict";
8772
- init_src4();
7950
+ init_src();
8773
7951
  init_Emitter();
8774
7952
  init_Logger();
8775
7953
  init_Msg();
@@ -8778,7 +7956,7 @@ var init_WebsocketClient = __esm({
8778
7956
  }
8779
7957
  });
8780
7958
 
8781
- // node_modules/@pmate/utils/src/websocket/WebsocketClientV2.ts
7959
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/WebsocketClientV2.ts
8782
7960
  function isEventLike(value) {
8783
7961
  return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
8784
7962
  }
@@ -8787,9 +7965,9 @@ function isCloseEvent(value) {
8787
7965
  }
8788
7966
  var logger3, WebsocketClientV2;
8789
7967
  var init_WebsocketClientV2 = __esm({
8790
- "node_modules/@pmate/utils/src/websocket/WebsocketClientV2.ts"() {
7968
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/WebsocketClientV2.ts"() {
8791
7969
  "use strict";
8792
- init_src4();
7970
+ init_src();
8793
7971
  init_AsyncStream();
8794
7972
  init_Logger();
8795
7973
  init_Msg();
@@ -9034,10 +8212,10 @@ var init_WebsocketClientV2 = __esm({
9034
8212
  }
9035
8213
  });
9036
8214
 
9037
- // node_modules/@pmate/utils/src/websocket/H3Client.ts
8215
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/H3Client.ts
9038
8216
  var logger4;
9039
8217
  var init_H3Client = __esm({
9040
- "node_modules/@pmate/utils/src/websocket/H3Client.ts"() {
8218
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/H3Client.ts"() {
9041
8219
  "use strict";
9042
8220
  init_Emitter();
9043
8221
  init_Logger();
@@ -9047,9 +8225,9 @@ var init_H3Client = __esm({
9047
8225
  }
9048
8226
  });
9049
8227
 
9050
- // node_modules/@pmate/utils/src/websocket/index.ts
8228
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/index.ts
9051
8229
  var init_websocket = __esm({
9052
- "node_modules/@pmate/utils/src/websocket/index.ts"() {
8230
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/websocket/index.ts"() {
9053
8231
  "use strict";
9054
8232
  init_WebsocketClient();
9055
8233
  init_WebsocketClientV2();
@@ -9057,9 +8235,9 @@ var init_websocket = __esm({
9057
8235
  }
9058
8236
  });
9059
8237
 
9060
- // node_modules/@pmate/utils/src/index.ts
9061
- var init_src5 = __esm({
9062
- "node_modules/@pmate/utils/src/index.ts"() {
8238
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/index.ts
8239
+ var init_src3 = __esm({
8240
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/index.ts"() {
9063
8241
  "use strict";
9064
8242
  init_base64();
9065
8243
  init_batchResolve();
@@ -9099,7 +8277,7 @@ var init_src5 = __esm({
9099
8277
  }
9100
8278
  });
9101
8279
 
9102
- // node_modules/@pmate/agent-sdk/dist/debug.js
8280
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/debug.js
9103
8281
  function isDebugEnabled() {
9104
8282
  return process.env.DEBUG === "1";
9105
8283
  }
@@ -9114,296 +8292,17 @@ function debugLog(message, data) {
9114
8292
  console.log(message, data);
9115
8293
  }
9116
8294
  var init_debug = __esm({
9117
- "node_modules/@pmate/agent-sdk/dist/debug.js"() {
9118
- "use strict";
9119
- }
9120
- });
9121
-
9122
- // node_modules/@pmate/agent-sdk/dist/AgentConnectionPool.js
9123
- function ensureProtocol(value, protocol) {
9124
- if (!value) {
9125
- return "";
9126
- }
9127
- if (/^[a-z]+:\/\//i.test(value)) {
9128
- try {
9129
- const url = new URL(value);
9130
- url.protocol = `${protocol}:`;
9131
- return url.toString();
9132
- } catch {
9133
- return value;
9134
- }
9135
- }
9136
- if (value.startsWith("//")) {
9137
- return `${protocol}:${value}`;
9138
- }
9139
- return `${protocol}://${value}`;
9140
- }
9141
- function createPoolKey(wsUrl, profileId, token) {
9142
- return `${wsUrl}|${profileId}|${hashToken(token)}`;
9143
- }
9144
- function hashToken(token) {
9145
- let hash = 2166136261;
9146
- for (let i = 0; i < token.length; i += 1) {
9147
- hash ^= token.charCodeAt(i);
9148
- hash = Math.imul(hash, 16777619);
9149
- }
9150
- return (hash >>> 0).toString(16).padStart(8, "0");
9151
- }
9152
- var IDLE_CLOSE_MS, pool, AgentConnectionPool, AgentPooledConnection;
9153
- var init_AgentConnectionPool = __esm({
9154
- "node_modules/@pmate/agent-sdk/dist/AgentConnectionPool.js"() {
8295
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/debug.js"() {
9155
8296
  "use strict";
9156
- init_src();
9157
- init_src5();
9158
- init_debug();
9159
- IDLE_CLOSE_MS = 5e3;
9160
- pool = /* @__PURE__ */ new Map();
9161
- AgentConnectionPool = class {
9162
- static acquire(options) {
9163
- const wsUrl = ensureProtocol(options.baseUrl, "wss");
9164
- const key = createPoolKey(wsUrl, options.profileId, options.token);
9165
- let entry = pool.get(key);
9166
- if (!entry) {
9167
- entry = {
9168
- connection: new AgentPooledConnection(wsUrl, options.profileId, options.token),
9169
- refCount: 0,
9170
- idleTimer: null
9171
- };
9172
- pool.set(key, entry);
9173
- }
9174
- if (entry.idleTimer) {
9175
- clearTimeout(entry.idleTimer);
9176
- entry.idleTimer = null;
9177
- }
9178
- entry.refCount += 1;
9179
- return {
9180
- key,
9181
- connection: entry.connection
9182
- };
9183
- }
9184
- static release(lease) {
9185
- const entry = pool.get(lease.key);
9186
- if (!entry) {
9187
- return;
9188
- }
9189
- entry.refCount = Math.max(0, entry.refCount - 1);
9190
- if (entry.refCount > 0 || entry.idleTimer) {
9191
- return;
9192
- }
9193
- entry.idleTimer = setTimeout(() => {
9194
- const current = pool.get(lease.key);
9195
- if (!current || current.refCount > 0) {
9196
- return;
9197
- }
9198
- current.connection.close();
9199
- pool.delete(lease.key);
9200
- }, IDLE_CLOSE_MS);
9201
- }
9202
- static clearForTests() {
9203
- for (const [key, entry] of pool.entries()) {
9204
- if (entry.idleTimer) {
9205
- clearTimeout(entry.idleTimer);
9206
- }
9207
- entry.connection.close();
9208
- pool.delete(key);
9209
- }
9210
- }
9211
- };
9212
- AgentPooledConnection = class {
9213
- constructor(wsUrl, profileId, token) {
9214
- this.profileId = profileId;
9215
- this.token = token;
9216
- this.listeners = /* @__PURE__ */ new Set();
9217
- this.authPromise = null;
9218
- this.authResolve = null;
9219
- this.authReject = null;
9220
- this.authTimer = null;
9221
- this.authenticated = false;
9222
- this.authStarted = false;
9223
- this.ws = new WebsocketClientV2(wsUrl);
9224
- this.startWsStream();
9225
- }
9226
- addListener(listener) {
9227
- this.listeners.add(listener);
9228
- }
9229
- removeListener(listener) {
9230
- this.listeners.delete(listener);
9231
- }
9232
- isConnected() {
9233
- return this.ws.isConnected();
9234
- }
9235
- async authenticate(timeoutMs) {
9236
- await this.waitForConnection(timeoutMs);
9237
- if (this.authenticated) {
9238
- debugLog("[agent-connection-pool] auth reused", {
9239
- profileId: this.profileId
9240
- });
9241
- return;
9242
- }
9243
- const waiter = this.waitForAuthAck(timeoutMs);
9244
- if (!this.authStarted) {
9245
- this.authStarted = true;
9246
- const msg = Msg.create(this.profileId, "@hub", 4 /* AUTH */, {
9247
- token: this.token,
9248
- as: "user",
9249
- profileId: this.profileId
9250
- });
9251
- debugLog("[agent-connection-pool] auth sent", {
9252
- profileId: this.profileId
9253
- });
9254
- await this.ws.sendMsg(msg);
9255
- }
9256
- await waiter;
9257
- }
9258
- sendMsg(msg) {
9259
- return this.ws.sendMsg(msg);
9260
- }
9261
- close() {
9262
- this.ws.close();
9263
- this.rejectAuth(new Error("Agent websocket closed before auth ack"));
9264
- this.listeners.clear();
9265
- }
9266
- async startWsStream() {
9267
- const stream = this.ws.getStream();
9268
- try {
9269
- for await (const event of stream) {
9270
- this.handleWsEvent(event);
9271
- }
9272
- } catch {
9273
- }
9274
- }
9275
- handleWsEvent(event) {
9276
- if (event.type === "message") {
9277
- this.handleIncomingMessage(event.data);
9278
- return;
9279
- }
9280
- if (event.type === "connected" && !event.data) {
9281
- this.authenticated = false;
9282
- this.rejectAuth(new Error("Agent websocket disconnected before auth ack"));
9283
- }
9284
- if (event.type === "error") {
9285
- this.rejectAuth(new Error("Agent websocket error before auth ack"));
9286
- }
9287
- this.broadcast(event);
9288
- }
9289
- handleIncomingMessage(message) {
9290
- if (!message || typeof message !== "object") {
9291
- return;
9292
- }
9293
- if (message.opcode === 3 /* ACK */) {
9294
- const ack = message.body;
9295
- const success = ack?.status === "ok";
9296
- debugLog("[agent-connection-pool] ack received", {
9297
- profileId: this.profileId,
9298
- success
9299
- });
9300
- if (!success) {
9301
- this.rejectAuth(new Error(ack?.message ?? ack?.code ?? "Auth failed"));
9302
- return;
9303
- }
9304
- this.authenticated = true;
9305
- this.resolveAuth();
9306
- return;
9307
- }
9308
- debugLog("[agent-connection-pool] message broadcast", {
9309
- opcode: message.opcode,
9310
- from: message.from,
9311
- to: message.to
9312
- });
9313
- this.broadcast({ type: "message", data: message });
9314
- }
9315
- broadcast(event) {
9316
- for (const listener of this.listeners) {
9317
- listener.onConnectionEvent(event);
9318
- }
9319
- }
9320
- waitForConnection(timeoutMs) {
9321
- if (this.ws.isConnected()) {
9322
- return Promise.resolve();
9323
- }
9324
- return new Promise((resolve, reject) => {
9325
- const timer = setTimeout(() => {
9326
- off();
9327
- reject(new Error("Websocket connect timeout"));
9328
- }, timeoutMs);
9329
- const off = this.createOneShotListener("connected" /* Connected */, (connected) => {
9330
- if (connected) {
9331
- clearTimeout(timer);
9332
- off();
9333
- resolve();
9334
- }
9335
- });
9336
- });
9337
- }
9338
- waitForAuthAck(timeoutMs) {
9339
- if (this.authenticated) {
9340
- return Promise.resolve();
9341
- }
9342
- if (this.authPromise) {
9343
- return this.authPromise;
9344
- }
9345
- this.authPromise = new Promise((resolve, reject) => {
9346
- this.authResolve = resolve;
9347
- this.authReject = reject;
9348
- this.authTimer = setTimeout(() => {
9349
- this.clearAuthWaiter();
9350
- this.authStarted = false;
9351
- reject(new Error("Auth timeout"));
9352
- }, timeoutMs);
9353
- });
9354
- return this.authPromise;
9355
- }
9356
- resolveAuth() {
9357
- if (!this.authResolve) {
9358
- return;
9359
- }
9360
- const resolve = this.authResolve;
9361
- this.clearAuthWaiter();
9362
- this.authStarted = false;
9363
- resolve();
9364
- }
9365
- rejectAuth(error) {
9366
- if (!this.authReject) {
9367
- return;
9368
- }
9369
- const reject = this.authReject;
9370
- this.clearAuthWaiter();
9371
- this.authStarted = false;
9372
- reject(error);
9373
- }
9374
- clearAuthWaiter() {
9375
- if (this.authTimer) {
9376
- clearTimeout(this.authTimer);
9377
- this.authTimer = null;
9378
- }
9379
- this.authPromise = null;
9380
- this.authResolve = null;
9381
- this.authReject = null;
9382
- }
9383
- createOneShotListener(eventName, handler) {
9384
- const listener = {
9385
- onConnectionEvent: (event) => {
9386
- if (eventName === "connected" /* Connected */ && event.type === "connected") {
9387
- ;
9388
- handler(event.data);
9389
- }
9390
- }
9391
- };
9392
- this.addListener(listener);
9393
- return () => {
9394
- this.removeListener(listener);
9395
- };
9396
- }
9397
- };
9398
8297
  }
9399
8298
  });
9400
8299
 
9401
- // node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js
8300
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js
9402
8301
  var AgentTaskManager;
9403
8302
  var init_AgentTaskManager = __esm({
9404
- "node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js"() {
8303
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js"() {
9405
8304
  "use strict";
9406
- init_src5();
8305
+ init_src3();
9407
8306
  init_debug();
9408
8307
  AgentTaskManager = class {
9409
8308
  constructor() {
@@ -9570,7 +8469,7 @@ var init_AgentTaskManager = __esm({
9570
8469
  }
9571
8470
  });
9572
8471
 
9573
- // node_modules/@pmate/agent-sdk/dist/AgentClient.js
8472
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentClient.js
9574
8473
  function createAgentRequestBody(payload) {
9575
8474
  return {
9576
8475
  kind: "request",
@@ -9579,11 +8478,10 @@ function createAgentRequestBody(payload) {
9579
8478
  }
9580
8479
  var logger5, DEFAULT_TIMEOUT_MS, DEFAULT_STREAM_TIMEOUT_MS, DEFAULT_MIN_CHUNK_SIZE_BYTES, AgentClient;
9581
8480
  var init_AgentClient = __esm({
9582
- "node_modules/@pmate/agent-sdk/dist/AgentClient.js"() {
8481
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentClient.js"() {
9583
8482
  "use strict";
9584
8483
  init_src();
9585
- init_src5();
9586
- init_AgentConnectionPool();
8484
+ init_src3();
9587
8485
  init_AgentTaskManager();
9588
8486
  init_debug();
9589
8487
  logger5 = Logger.getDebugger("AgentClient");
@@ -9594,6 +8492,11 @@ var init_AgentClient = __esm({
9594
8492
  constructor(options) {
9595
8493
  super();
9596
8494
  this.tasks = new AgentTaskManager();
8495
+ this.authPromise = null;
8496
+ this.authResolve = null;
8497
+ this.authReject = null;
8498
+ this.authTimer = null;
8499
+ this.wsGeneration = 0;
9597
8500
  this.defaultRequestType = "application/json";
9598
8501
  this.defaultBinaryType = "application/octet-stream";
9599
8502
  this.baseUrl = options.baseUrl;
@@ -9601,12 +8504,13 @@ var init_AgentClient = __esm({
9601
8504
  this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
9602
8505
  this.streamTimeoutMs = options.streamTimeoutMs ?? DEFAULT_STREAM_TIMEOUT_MS;
9603
8506
  this.minChunkSizeBytes = options.minChunkSizeBytes ?? DEFAULT_MIN_CHUNK_SIZE_BYTES;
8507
+ this.resetWebsocket(this.baseUrl);
9604
8508
  }
9605
8509
  isConnected() {
9606
- return this.lease?.connection.isConnected() ?? false;
8510
+ return this.ws?.isConnected() ?? false;
9607
8511
  }
9608
8512
  close() {
9609
- this.releaseConnection();
8513
+ this.ws?.close();
9610
8514
  }
9611
8515
  async login(options) {
9612
8516
  const profileId = options?.profileId;
@@ -9615,19 +8519,13 @@ var init_AgentClient = __esm({
9615
8519
  }
9616
8520
  this.from = profileId;
9617
8521
  const baseUrl = options?.baseUrl ?? this.baseUrl;
8522
+ if (baseUrl !== this.baseUrl) {
8523
+ this.resetWebsocket(baseUrl);
8524
+ }
9618
8525
  const timeoutMs = options?.timeoutMs ?? this.timeoutMs;
8526
+ await this.waitForConnection(timeoutMs);
9619
8527
  const token = options?.token ?? "";
9620
- this.auth = { token, profileId };
9621
- const lease = AgentConnectionPool.acquire({ baseUrl, token, profileId });
9622
- if (this.lease?.key !== lease.key) {
9623
- this.releaseConnection();
9624
- this.lease = lease;
9625
- this.lease.connection.addListener(this);
9626
- } else {
9627
- AgentConnectionPool.release(lease);
9628
- }
9629
- this.baseUrl = baseUrl;
9630
- await this.lease.connection.authenticate(timeoutMs);
8528
+ await this.sendAuth(token, timeoutMs, profileId);
9631
8529
  return true;
9632
8530
  }
9633
8531
  async prompt(request) {
@@ -9664,18 +8562,11 @@ var init_AgentClient = __esm({
9664
8562
  taskId,
9665
8563
  agentId: request.agentId,
9666
8564
  op: 0 /* Start */,
9667
- auth: this.auth,
9668
8565
  type: this.defaultRequestType,
9669
8566
  ...request.payload ? { payload: request.payload } : {}
9670
8567
  };
9671
8568
  const msg = Msg.create(this.from, hubTo, 2 /* AGENT */, createAgentRequestBody(startPayload), 0 /* PIPELINE */);
9672
- debugLog("[agent-client] sending agent request", {
9673
- taskId,
9674
- agentId: request.agentId,
9675
- from: this.from,
9676
- to: hubTo
9677
- });
9678
- await this.lease.connection.sendMsg(msg);
8569
+ await this.ws.sendMsg(msg);
9679
8570
  return await waiter;
9680
8571
  }
9681
8572
  stream(request) {
@@ -9687,7 +8578,7 @@ var init_AgentClient = __esm({
9687
8578
  timeoutMode: "reject"
9688
8579
  });
9689
8580
  const from = this.from;
9690
- const connection = this.lease.connection;
8581
+ const ws = this.ws;
9691
8582
  const minChunkSizeBytes = request.minChunkSizeBytes ?? this.minChunkSizeBytes;
9692
8583
  const inputStream = minChunkSizeBytes > 0 ? AsyncStream.chunkBlob(request.stream, {
9693
8584
  minBytes: minChunkSizeBytes
@@ -9729,32 +8620,29 @@ var init_AgentClient = __esm({
9729
8620
  taskId,
9730
8621
  agentId: request.agentId,
9731
8622
  op: 0 /* Start */,
9732
- auth: this.auth,
9733
8623
  type: this.defaultRequestType,
9734
8624
  ...request.params ? { payload: request.params } : {}
9735
8625
  }), 0 /* PIPELINE */);
9736
- await connection.sendMsg(startMsg);
8626
+ await ws.sendMsg(startMsg);
9737
8627
  for await (const payload of inputStream) {
9738
8628
  const dataType = payload instanceof Blob ? payload.type || this.defaultBinaryType : payload instanceof Uint8Array || payload instanceof ArrayBuffer ? this.defaultBinaryType : typeof payload === "string" ? "text" : this.defaultRequestType;
9739
8629
  const body = {
9740
8630
  taskId,
9741
8631
  agentId: request.agentId,
9742
8632
  op: 1 /* Data */,
9743
- auth: this.auth,
9744
8633
  type: dataType,
9745
8634
  payload
9746
8635
  };
9747
8636
  const msg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody(body), 0 /* PIPELINE */);
9748
- await connection.sendMsg(msg);
8637
+ await ws.sendMsg(msg);
9749
8638
  }
9750
8639
  const endMsg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody({
9751
8640
  taskId,
9752
8641
  agentId: request.agentId,
9753
8642
  op: 2 /* End */,
9754
- auth: this.auth,
9755
8643
  type: this.defaultRequestType
9756
8644
  }), 0 /* PIPELINE */);
9757
- await connection.sendMsg(endMsg);
8645
+ await ws.sendMsg(endMsg);
9758
8646
  };
9759
8647
  void startDataStream();
9760
8648
  const agentStream = outputStream;
@@ -9805,7 +8693,7 @@ var init_AgentClient = __esm({
9805
8693
  return agentStream;
9806
8694
  }
9807
8695
  ensureReady() {
9808
- if (!this.lease || !this.from || !this.auth) {
8696
+ if (!this.ws || !this.from) {
9809
8697
  throw new Error("AgentClient not logged in");
9810
8698
  }
9811
8699
  }
@@ -9813,7 +8701,31 @@ var init_AgentClient = __esm({
9813
8701
  const rnd = Math.floor(Math.random() * 1e12);
9814
8702
  return uniqHash(`${agentId}-${Date.now()}-${rnd}`, "task-v1" /* Task */);
9815
8703
  }
9816
- onConnectionEvent(event) {
8704
+ createWebsocketClient(baseUrl) {
8705
+ return new WebsocketClientV2(this.ensureProtocol(baseUrl, "wss"));
8706
+ }
8707
+ resetWebsocket(baseUrl) {
8708
+ this.baseUrl = baseUrl;
8709
+ if (this.ws) {
8710
+ this.ws.close();
8711
+ }
8712
+ this.ws = this.createWebsocketClient(this.baseUrl);
8713
+ this.wsGeneration += 1;
8714
+ this.startWsStream(this.ws, this.wsGeneration);
8715
+ }
8716
+ async startWsStream(ws, generation) {
8717
+ const stream = ws.getStream();
8718
+ try {
8719
+ for await (const event of stream) {
8720
+ if (generation !== this.wsGeneration) {
8721
+ break;
8722
+ }
8723
+ this.handleWsEvent(event);
8724
+ }
8725
+ } catch {
8726
+ }
8727
+ }
8728
+ handleWsEvent(event) {
9817
8729
  if (event.type === "message") {
9818
8730
  this.handleIncomingMessage(event.data);
9819
8731
  return;
@@ -9824,16 +8736,30 @@ var init_AgentClient = __esm({
9824
8736
  }
9825
8737
  if (event.type === "connected") {
9826
8738
  this.emit("connected" /* Connected */, event.data);
8739
+ if (!event.data) {
8740
+ this.rejectAuth(new Error("Agent websocket disconnected before auth ack"));
8741
+ }
9827
8742
  return;
9828
8743
  }
9829
8744
  if (event.type === "error") {
9830
8745
  this.emit("error" /* Error */, event.data);
8746
+ this.rejectAuth(new Error("Agent websocket error before auth ack"));
9831
8747
  }
9832
8748
  }
9833
8749
  handleIncomingMessage(message) {
9834
8750
  if (!message || typeof message !== "object") {
9835
8751
  return;
9836
8752
  }
8753
+ if (message.opcode === 3 /* ACK */) {
8754
+ const ack = message.body;
8755
+ const success = ack?.status === "ok";
8756
+ if (!success) {
8757
+ this.rejectAuth(new Error(ack?.message ?? ack?.code ?? "Auth failed"));
8758
+ return;
8759
+ }
8760
+ this.resolveAuth();
8761
+ return;
8762
+ }
9837
8763
  if (message.opcode === 2 /* AGENT */) {
9838
8764
  const agentBody = message.body;
9839
8765
  if (agentBody?.kind !== "response") {
@@ -9851,75 +8777,158 @@ var init_AgentClient = __esm({
9851
8777
  this.tasks.handleResponse(body);
9852
8778
  }
9853
8779
  }
9854
- releaseConnection() {
9855
- if (!this.lease) {
8780
+ ensureProtocol(value, protocol) {
8781
+ if (!value) {
8782
+ return "";
8783
+ }
8784
+ if (/^[a-z]+:\/\//i.test(value)) {
8785
+ try {
8786
+ const url = new URL(value);
8787
+ url.protocol = `${protocol}:`;
8788
+ return url.toString();
8789
+ } catch {
8790
+ return value;
8791
+ }
8792
+ }
8793
+ if (value.startsWith("//")) {
8794
+ return `${protocol}:${value}`;
8795
+ }
8796
+ return `${protocol}://${value}`;
8797
+ }
8798
+ waitForConnection(timeoutMs) {
8799
+ if (!this.ws) {
8800
+ return Promise.reject(new Error("Websocket client not initialized"));
8801
+ }
8802
+ if (this.ws.isConnected()) {
8803
+ return Promise.resolve();
8804
+ }
8805
+ return new Promise((resolve, reject) => {
8806
+ const timer = setTimeout(() => {
8807
+ off();
8808
+ reject(new Error("Websocket connect timeout"));
8809
+ }, timeoutMs);
8810
+ const off = this.on("connected" /* Connected */, (connected) => {
8811
+ if (connected) {
8812
+ clearTimeout(timer);
8813
+ off();
8814
+ resolve();
8815
+ }
8816
+ });
8817
+ });
8818
+ }
8819
+ async sendAuth(token, timeoutMs, profileId) {
8820
+ if (!this.ws || !this.from) {
8821
+ throw new Error("AgentClient not initialized");
8822
+ }
8823
+ const body = {
8824
+ token,
8825
+ as: "user",
8826
+ profileId
8827
+ };
8828
+ const msg = Msg.create(this.from, "@hub", 4 /* AUTH */, body);
8829
+ const waiter = this.waitForAuthAck(timeoutMs);
8830
+ await this.ws.sendMsg(msg);
8831
+ await waiter;
8832
+ }
8833
+ waitForAuthAck(timeoutMs) {
8834
+ if (this.authPromise) {
8835
+ return this.authPromise;
8836
+ }
8837
+ this.authPromise = new Promise((resolve, reject) => {
8838
+ this.authResolve = resolve;
8839
+ this.authReject = reject;
8840
+ this.authTimer = setTimeout(() => {
8841
+ this.clearAuthWaiter();
8842
+ reject(new Error("Auth timeout"));
8843
+ }, timeoutMs);
8844
+ });
8845
+ return this.authPromise;
8846
+ }
8847
+ resolveAuth() {
8848
+ if (!this.authResolve) {
8849
+ return;
8850
+ }
8851
+ const resolve = this.authResolve;
8852
+ this.clearAuthWaiter();
8853
+ resolve();
8854
+ }
8855
+ rejectAuth(error) {
8856
+ if (!this.authReject) {
9856
8857
  return;
9857
8858
  }
9858
- this.lease.connection.removeListener(this);
9859
- AgentConnectionPool.release(this.lease);
9860
- this.lease = void 0;
9861
- this.auth = void 0;
8859
+ const reject = this.authReject;
8860
+ this.clearAuthWaiter();
8861
+ reject(error);
8862
+ }
8863
+ clearAuthWaiter() {
8864
+ if (this.authTimer) {
8865
+ clearTimeout(this.authTimer);
8866
+ this.authTimer = null;
8867
+ }
8868
+ this.authPromise = null;
8869
+ this.authResolve = null;
8870
+ this.authReject = null;
9862
8871
  }
9863
8872
  };
9864
8873
  }
9865
8874
  });
9866
8875
 
9867
- // node_modules/@pmate/agent-sdk/dist/AgentRuntime.js
8876
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentRuntime.js
9868
8877
  var init_AgentRuntime = __esm({
9869
- "node_modules/@pmate/agent-sdk/dist/AgentRuntime.js"() {
8878
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentRuntime.js"() {
9870
8879
  "use strict";
9871
8880
  init_src();
9872
- init_src5();
8881
+ init_src3();
9873
8882
  }
9874
8883
  });
9875
8884
 
9876
- // node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js
8885
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js
9877
8886
  var init_PromptTaskContext = __esm({
9878
- "node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js"() {
8887
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js"() {
9879
8888
  "use strict";
9880
8889
  }
9881
8890
  });
9882
8891
 
9883
- // node_modules/@pmate/agent-sdk/dist/PromptAgent.js
8892
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptAgent.js
9884
8893
  var init_PromptAgent = __esm({
9885
- "node_modules/@pmate/agent-sdk/dist/PromptAgent.js"() {
8894
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptAgent.js"() {
9886
8895
  "use strict";
9887
8896
  init_src();
9888
- init_src5();
8897
+ init_src3();
9889
8898
  init_debug();
9890
8899
  init_AgentRuntime();
9891
8900
  init_PromptTaskContext();
9892
8901
  }
9893
8902
  });
9894
8903
 
9895
- // node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js
8904
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js
9896
8905
  var init_StreamTaskContext = __esm({
9897
- "node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js"() {
8906
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js"() {
9898
8907
  "use strict";
9899
8908
  }
9900
8909
  });
9901
8910
 
9902
- // node_modules/@pmate/agent-sdk/dist/StreamAgent.js
8911
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamAgent.js
9903
8912
  var init_StreamAgent = __esm({
9904
- "node_modules/@pmate/agent-sdk/dist/StreamAgent.js"() {
8913
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamAgent.js"() {
9905
8914
  "use strict";
9906
8915
  init_src();
9907
- init_src5();
8916
+ init_src3();
9908
8917
  init_AgentRuntime();
9909
8918
  init_StreamTaskContext();
9910
8919
  }
9911
8920
  });
9912
8921
 
9913
- // node_modules/@pmate/agent-sdk/dist/AgentFactory.js
8922
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentFactory.js
9914
8923
  var init_AgentFactory = __esm({
9915
- "node_modules/@pmate/agent-sdk/dist/AgentFactory.js"() {
8924
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentFactory.js"() {
9916
8925
  "use strict";
9917
8926
  init_PromptAgent();
9918
8927
  init_StreamAgent();
9919
8928
  }
9920
8929
  });
9921
8930
 
9922
- // node_modules/@pmate/agent-sdk/dist/AgentService.js
8931
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentService.js
9923
8932
  function parseAgentId(agentId) {
9924
8933
  const separatorIndex = agentId.indexOf(":");
9925
8934
  if (separatorIndex <= 0 || separatorIndex === agentId.length - 1) {
@@ -9949,7 +8958,7 @@ function trimTrailingSlash(value) {
9949
8958
  }
9950
8959
  var AgentService;
9951
8960
  var init_AgentService = __esm({
9952
- "node_modules/@pmate/agent-sdk/dist/AgentService.js"() {
8961
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentService.js"() {
9953
8962
  "use strict";
9954
8963
  AgentService = class {
9955
8964
  constructor(options) {
@@ -9990,9 +8999,9 @@ var init_AgentService = __esm({
9990
8999
  }
9991
9000
  });
9992
9001
 
9993
- // node_modules/@pmate/agent-sdk/dist/index.js
9002
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/index.js
9994
9003
  var init_dist2 = __esm({
9995
- "node_modules/@pmate/agent-sdk/dist/index.js"() {
9004
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/index.js"() {
9996
9005
  "use strict";
9997
9006
  init_AgentClient();
9998
9007
  init_AgentFactory();
@@ -10002,7 +9011,7 @@ var init_dist2 = __esm({
10002
9011
  init_AgentTaskManager();
10003
9012
  init_AgentService();
10004
9013
  init_debug();
10005
- init_src5();
9014
+ init_src3();
10006
9015
  }
10007
9016
  });
10008
9017
 
@@ -10034,7 +9043,7 @@ function unwrapAgentResult(agentId, value) {
10034
9043
  return value;
10035
9044
  }
10036
9045
  function resolveMimeType(filePath) {
10037
- const ext = import_node_path10.default.extname(filePath).toLowerCase();
9046
+ const ext = import_node_path12.default.extname(filePath).toLowerCase();
10038
9047
  switch (ext) {
10039
9048
  case ".wav":
10040
9049
  return "audio/wav";
@@ -10054,12 +9063,12 @@ function resolveMimeType(filePath) {
10054
9063
  return "application/octet-stream";
10055
9064
  }
10056
9065
  }
10057
- var import_node_fs6, import_node_path10, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE, DEFAULT_AGENT_PROMPT_TIMEOUT_MS, AgentLlmClient;
9066
+ var import_node_fs7, import_node_path12, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE, DEFAULT_AGENT_PROMPT_TIMEOUT_MS, AgentLlmClient;
10058
9067
  var init_AgentLlmClient = __esm({
10059
9068
  "src/llm/AgentLlmClient.ts"() {
10060
9069
  "use strict";
10061
- import_node_fs6 = require("fs");
10062
- import_node_path10 = __toESM(require("path"));
9070
+ import_node_fs7 = require("fs");
9071
+ import_node_path12 = __toESM(require("path"));
10063
9072
  init_dist2();
10064
9073
  init_sessionStore();
10065
9074
  DEFAULT_AGENT_API_BASE_URL = "https://agent-api.pmate.chat";
@@ -10126,7 +9135,7 @@ var init_AgentLlmClient = __esm({
10126
9135
  params,
10127
9136
  minChunkSizeBytes: 0
10128
9137
  });
10129
- const file = (0, import_node_fs6.readFileSync)(filePath);
9138
+ const file = (0, import_node_fs7.readFileSync)(filePath);
10130
9139
  input.push(new Blob([file], { type: resolveMimeType(filePath) }));
10131
9140
  input.end();
10132
9141
  return await stream.finish();
@@ -10151,8 +9160,8 @@ __export(index_exports, {
10151
9160
  parseCommandArgs: () => parseCommandArgs
10152
9161
  });
10153
9162
  module.exports = __toCommonJS(index_exports);
10154
- var import_node_fs24 = require("fs");
10155
- var import_node_path28 = __toESM(require("path"));
9163
+ var import_node_fs25 = require("fs");
9164
+ var import_node_path30 = __toESM(require("path"));
10156
9165
  var import_chalk4 = __toESM(require("chalk"));
10157
9166
 
10158
9167
  // src/cli.ts
@@ -10584,8 +9593,67 @@ var ListCommandHandler = class {
10584
9593
 
10585
9594
  // src/commands/LoginCommandHandler.ts
10586
9595
  var import_node_child_process = require("child_process");
9596
+ var import_node_path5 = __toESM(require("path"));
10587
9597
  var import_node_http = require("http");
10588
9598
  var import_promises = require("readline/promises");
9599
+
9600
+ // src/accessKeyFile.ts
9601
+ var import_node_fs2 = require("fs");
9602
+ var import_node_os2 = __toESM(require("os"));
9603
+ var import_node_path3 = __toESM(require("path"));
9604
+ function readAccessKeyFile(filePath, options = {}) {
9605
+ const absolutePath = resolveFilePath(filePath, options.cwd);
9606
+ if (!(0, import_node_fs2.existsSync)(absolutePath)) {
9607
+ throw new Error(`Access key file not found: ${absolutePath}`);
9608
+ }
9609
+ let parsed;
9610
+ try {
9611
+ parsed = JSON.parse((0, import_node_fs2.readFileSync)(absolutePath, "utf8"));
9612
+ } catch (error) {
9613
+ const message = error instanceof Error ? error.message : String(error);
9614
+ throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
9615
+ }
9616
+ if (!isAccessKeyFile(parsed)) {
9617
+ throw new Error(`Invalid PMate access key file: ${absolutePath}`);
9618
+ }
9619
+ if (options.expectedApp && parsed.app !== options.expectedApp) {
9620
+ throw new Error(
9621
+ `Access key app mismatch. expected=${options.expectedApp}, received=${parsed.app}`
9622
+ );
9623
+ }
9624
+ return parsed;
9625
+ }
9626
+ function scanAccessKeyFiles(app) {
9627
+ const dir = resolveAccessKeyDir(app);
9628
+ if (!(0, import_node_fs2.existsSync)(dir)) {
9629
+ return [];
9630
+ }
9631
+ return (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".access-key.json")).map((entry) => import_node_path3.default.join(dir, entry.name)).flatMap((filePath) => {
9632
+ try {
9633
+ return [{ filePath, key: readAccessKeyFile(filePath, { expectedApp: app }) }];
9634
+ } catch {
9635
+ return [];
9636
+ }
9637
+ }).sort((a, b) => a.key.name.localeCompare(b.key.name) || a.filePath.localeCompare(b.filePath));
9638
+ }
9639
+ function resolveAccessKeyDir(app) {
9640
+ return import_node_path3.default.join(homeDir(), ".pmate", "access-keys", app);
9641
+ }
9642
+ function resolveFilePath(filePath, cwd = process.cwd()) {
9643
+ return import_node_path3.default.isAbsolute(filePath) ? filePath : import_node_path3.default.resolve(cwd, filePath);
9644
+ }
9645
+ function homeDir() {
9646
+ return process.env.HOME || process.env.USERPROFILE || import_node_os2.default.homedir() || process.cwd();
9647
+ }
9648
+ function isAccessKeyFile(value) {
9649
+ if (!value || typeof value !== "object") {
9650
+ return false;
9651
+ }
9652
+ const candidate = value;
9653
+ return candidate.type === "pmate-access-key" && candidate.version === 1 && typeof candidate.id === "string" && !!candidate.id.trim() && typeof candidate.app === "string" && !!candidate.app.trim() && typeof candidate.name === "string" && !!candidate.name.trim() && typeof candidate.secret === "string" && !!candidate.secret.trim() && typeof candidate.expiresAt === "string" && !!candidate.expiresAt.trim() && typeof candidate.createdAt === "string" && !!candidate.createdAt.trim();
9654
+ }
9655
+
9656
+ // src/commands/LoginCommandHandler.ts
10589
9657
  init_sessionStore();
10590
9658
 
10591
9659
  // src/profileClient.ts
@@ -10632,7 +9700,6 @@ function resolveAuthApiBaseUrl(value) {
10632
9700
 
10633
9701
  // src/commands/LoginCommandHandler.ts
10634
9702
  var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
10635
- var AUTH_API_BASE_URL = DEFAULT_AUTH_API_BASE_URL;
10636
9703
  var CALLBACK_PATH = "/pmate-login-callback";
10637
9704
  var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
10638
9705
  function buildHostedLoginUrl(redirectUrl, appId = DEFAULT_APP_ID) {
@@ -10644,6 +9711,13 @@ function buildHostedLoginUrl(redirectUrl, appId = DEFAULT_APP_ID) {
10644
9711
  }
10645
9712
  var LoginCommandHandler = class {
10646
9713
  async handle(args) {
9714
+ if (args.accessKey || args.accessKeyFile || args.accessKeyScan) {
9715
+ await this.handleAccessKeyLogin(args);
9716
+ return;
9717
+ }
9718
+ await this.handleHostedLogin(args);
9719
+ }
9720
+ async handleHostedLogin(args) {
10647
9721
  const callback = await this.startCallbackServer();
10648
9722
  const appId = assertValidAppRef(args.app?.trim() || DEFAULT_APP_ID);
10649
9723
  const loginUrl = buildHostedLoginUrl(callback.redirectUrl, appId);
@@ -10671,6 +9745,7 @@ var LoginCommandHandler = class {
10671
9745
  const profileId = await this.resolveProfileId({
10672
9746
  appId,
10673
9747
  requestedProfileId: args.profileId,
9748
+ selectProfile: args.selectProfile,
10674
9749
  profiles
10675
9750
  });
10676
9751
  savedSession = saveLoginSession({ ...loginResponse, profileId }, appId);
@@ -10683,8 +9758,28 @@ var LoginCommandHandler = class {
10683
9758
  );
10684
9759
  }
10685
9760
  }
9761
+ async handleAccessKeyLogin(args) {
9762
+ const resolved = await this.resolveAccessKeyInput(args);
9763
+ const appId = assertValidAppRef(resolved.app);
9764
+ const loginResponse = await this.exchangeAccessKeySession(resolved.secret, appId);
9765
+ const profiles = await fetchProfiles({
9766
+ token: loginResponse.token,
9767
+ app: appId,
9768
+ accountId: loginResponse.session.identity.accountId
9769
+ });
9770
+ const profileId = await this.resolveProfileId({
9771
+ appId,
9772
+ requestedProfileId: args.profileId,
9773
+ selectProfile: args.selectProfile,
9774
+ profiles
9775
+ });
9776
+ const savedSession = saveLoginSession({ ...loginResponse, profileId }, appId);
9777
+ ui.success(
9778
+ `Logged in to ${savedSession.app}. Session saved to ${savedSession.sessionPath}`
9779
+ );
9780
+ }
10686
9781
  async exchangeSession(token, appId) {
10687
- const response = await fetch(`${AUTH_API_BASE_URL}/session/exchange`, {
9782
+ const response = await fetch(`${resolveAuthApiBaseUrl()}/session/exchange`, {
10688
9783
  method: "POST",
10689
9784
  headers: {
10690
9785
  "Content-Type": "application/json",
@@ -10705,6 +9800,88 @@ var LoginCommandHandler = class {
10705
9800
  }
10706
9801
  return resp.data;
10707
9802
  }
9803
+ async exchangeAccessKeySession(secret, appId) {
9804
+ const response = await fetch(`${resolveAuthApiBaseUrl()}/access-keys/session`, {
9805
+ method: "POST",
9806
+ headers: {
9807
+ "Content-Type": "application/json",
9808
+ Authorization: `Bearer ${secret}`
9809
+ },
9810
+ body: JSON.stringify({ app: appId })
9811
+ });
9812
+ if (!response.ok) {
9813
+ const detail = await response.text();
9814
+ throw new Error(
9815
+ `Failed to exchange access key session (${response.status}): ${detail || response.statusText}`
9816
+ );
9817
+ }
9818
+ const resp = await response.json();
9819
+ const returnedApp = resp?.data?.session?.identity?.app?.trim();
9820
+ if (!returnedApp || returnedApp !== appId) {
9821
+ throw new Error("Invalid access key session response: app-scoped session mismatch.");
9822
+ }
9823
+ return resp.data;
9824
+ }
9825
+ async resolveAccessKeyInput(args) {
9826
+ if (args.accessKey) {
9827
+ return {
9828
+ app: args.app?.trim() || DEFAULT_APP_ID,
9829
+ secret: args.accessKey.trim()
9830
+ };
9831
+ }
9832
+ if (args.accessKeyFile) {
9833
+ const key = readAccessKeyFile(args.accessKeyFile, {
9834
+ expectedApp: args.app?.trim()
9835
+ });
9836
+ return {
9837
+ app: args.app?.trim() || key.app,
9838
+ secret: key.secret
9839
+ };
9840
+ }
9841
+ const app = assertValidAppRef(args.app?.trim() || DEFAULT_APP_ID);
9842
+ const candidate = await this.selectScannedAccessKey(app);
9843
+ return {
9844
+ app,
9845
+ secret: candidate.key.secret
9846
+ };
9847
+ }
9848
+ async selectScannedAccessKey(app) {
9849
+ const candidates = scanAccessKeyFiles(app);
9850
+ if (candidates.length === 0) {
9851
+ throw new Error(
9852
+ `No access key found for app ${app}. Run "pmate account access-key create --app ${app} ..." or "pmate login --access-key-file <path>".`
9853
+ );
9854
+ }
9855
+ if (candidates.length === 1) {
9856
+ return candidates[0];
9857
+ }
9858
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
9859
+ const files = candidates.map((candidate) => candidate.filePath).join(", ");
9860
+ throw new Error(
9861
+ `Multiple access keys found for app ${app}. Run "pmate login --access-key-file <path>" with one of: ${files}`
9862
+ );
9863
+ }
9864
+ ui.info(`Multiple access keys found for ${app}. Select one:`);
9865
+ candidates.forEach((candidate, index) => {
9866
+ ui.plain(`${index + 1}. ${this.formatAccessKeyLabel(candidate)}`);
9867
+ });
9868
+ const rl = (0, import_promises.createInterface)({
9869
+ input: process.stdin,
9870
+ output: process.stdout
9871
+ });
9872
+ try {
9873
+ while (true) {
9874
+ const answer = (await rl.question("Access key number: ")).trim();
9875
+ const index = Number.parseInt(answer, 10);
9876
+ if (Number.isInteger(index) && index >= 1 && index <= candidates.length) {
9877
+ return candidates[index - 1];
9878
+ }
9879
+ ui.warn(`Enter a number from 1 to ${candidates.length}.`);
9880
+ }
9881
+ } finally {
9882
+ rl.close();
9883
+ }
9884
+ }
10708
9885
  async resolveProfileId(input) {
10709
9886
  const requestedProfileId = input.requestedProfileId?.trim();
10710
9887
  if (requestedProfileId) {
@@ -10717,7 +9894,7 @@ var LoginCommandHandler = class {
10717
9894
  if (input.profiles.length === 0) {
10718
9895
  throw new Error(`No profile found for app ${input.appId}.`);
10719
9896
  }
10720
- if (input.profiles.length === 1) {
9897
+ if (input.profiles.length === 1 || !input.selectProfile) {
10721
9898
  return input.profiles[0].id;
10722
9899
  }
10723
9900
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
@@ -10747,6 +9924,17 @@ var LoginCommandHandler = class {
10747
9924
  rl.close();
10748
9925
  }
10749
9926
  }
9927
+ formatAccessKeyLabel(candidate) {
9928
+ const key = candidate.key;
9929
+ const parts = [
9930
+ key.name?.trim(),
9931
+ key.id?.trim(),
9932
+ key.namespace?.trim(),
9933
+ `expires ${key.expiresAt}`,
9934
+ import_node_path5.default.relative(process.cwd(), candidate.filePath)
9935
+ ].filter(Boolean);
9936
+ return parts.join(" / ");
9937
+ }
10750
9938
  formatProfileLabel(profile) {
10751
9939
  const parts = [
10752
9940
  profile.nickName?.trim(),
@@ -10962,8 +10150,8 @@ var import_openapi_client = require("@alicloud/openapi-client");
10962
10150
  var import_sts20150401 = __toESM(require("@alicloud/sts20150401"));
10963
10151
  var import_ali_oss = __toESM(require("ali-oss"));
10964
10152
  var import_node_crypto = require("crypto");
10965
- var import_node_fs3 = require("fs");
10966
- var import_node_path4 = __toESM(require("path"));
10153
+ var import_node_fs4 = require("fs");
10154
+ var import_node_path6 = __toESM(require("path"));
10967
10155
 
10968
10156
  // src/certs.ts
10969
10157
  var DEFAULT_SSL_CERT_KEY = "pmate-01";
@@ -11256,7 +10444,7 @@ var AliyunService = class {
11256
10444
  ])
11257
10445
  );
11258
10446
  for (const filePath of files) {
11259
- const relativePath = import_node_path4.default.relative(localDir, filePath);
10447
+ const relativePath = import_node_path6.default.relative(localDir, filePath);
11260
10448
  const objectKey = this.toObjectKey(normalizedPrefix, relativePath);
11261
10449
  const contentType = this.getContentType(filePath);
11262
10450
  const cacheControl = this.getStaticAssetCacheControl(relativePath);
@@ -11266,7 +10454,7 @@ var AliyunService = class {
11266
10454
  const options = Object.keys(headers).length > 0 ? { headers } : void 0;
11267
10455
  const existing = existingMap.get(objectKey);
11268
10456
  if (existing && typeof existing.size === "number" && !cacheControl) {
11269
- const stat = await import_node_fs3.promises.stat(filePath);
10457
+ const stat = await import_node_fs4.promises.stat(filePath);
11270
10458
  if (stat.size === existing.size) {
11271
10459
  const etag = this.normalizeEtag(existing.etag);
11272
10460
  if (etag && !etag.includes("-")) {
@@ -11291,7 +10479,7 @@ var AliyunService = class {
11291
10479
  if (!region) throw new Error("Missing oss.public.region in ~/.pmate/config.yaml.");
11292
10480
  if (!accessKeyId) throw new Error("Missing aliyun.ak in ~/.pmate/config.yaml.");
11293
10481
  if (!accessKeySecret) throw new Error("Missing aliyun.sk in ~/.pmate/config.yaml.");
11294
- if (!(0, import_node_fs3.existsSync)(localFile)) {
10482
+ if (!(0, import_node_fs4.existsSync)(localFile)) {
11295
10483
  throw new Error(`File not found: ${localFile}`);
11296
10484
  }
11297
10485
  const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
@@ -11638,10 +10826,10 @@ var AliyunService = class {
11638
10826
  }
11639
10827
  /** Recursively collect file paths under a directory. */
11640
10828
  static async collectFiles(dir) {
11641
- const entries = await import_node_fs3.promises.readdir(dir, { withFileTypes: true });
10829
+ const entries = await import_node_fs4.promises.readdir(dir, { withFileTypes: true });
11642
10830
  const files = [];
11643
10831
  for (const entry of entries) {
11644
- const fullPath = import_node_path4.default.join(dir, entry.name);
10832
+ const fullPath = import_node_path6.default.join(dir, entry.name);
11645
10833
  if (entry.isDirectory()) {
11646
10834
  files.push(...await this.collectFiles(fullPath));
11647
10835
  } else if (entry.isFile()) {
@@ -11690,7 +10878,7 @@ var AliyunService = class {
11690
10878
  static getFileMd5(filePath) {
11691
10879
  return new Promise((resolve, reject) => {
11692
10880
  const hash = (0, import_node_crypto.createHash)("md5");
11693
- const stream = (0, import_node_fs3.createReadStream)(filePath);
10881
+ const stream = (0, import_node_fs4.createReadStream)(filePath);
11694
10882
  stream.on("data", (chunk) => {
11695
10883
  hash.update(chunk);
11696
10884
  });
@@ -11703,17 +10891,17 @@ var AliyunService = class {
11703
10891
  });
11704
10892
  }
11705
10893
  static toObjectKey(prefix, relativePath) {
11706
- const normalizedPath = relativePath.split(import_node_path4.default.sep).join("/");
10894
+ const normalizedPath = relativePath.split(import_node_path6.default.sep).join("/");
11707
10895
  if (!prefix) {
11708
10896
  return normalizedPath;
11709
10897
  }
11710
10898
  return `${prefix}/${normalizedPath}`;
11711
10899
  }
11712
10900
  static getContentType(filePath) {
11713
- if (import_node_path4.default.basename(filePath).toLowerCase() === "apple-app-site-association") {
10901
+ if (import_node_path6.default.basename(filePath).toLowerCase() === "apple-app-site-association") {
11714
10902
  return "application/json";
11715
10903
  }
11716
- const ext = import_node_path4.default.extname(filePath).toLowerCase();
10904
+ const ext = import_node_path6.default.extname(filePath).toLowerCase();
11717
10905
  switch (ext) {
11718
10906
  case ".html":
11719
10907
  return "text/html";
@@ -11756,7 +10944,7 @@ var AliyunService = class {
11756
10944
  }
11757
10945
  static getStaticAssetCacheControl(filePath) {
11758
10946
  const normalized = filePath.replace(/\\/g, "/");
11759
- const base = import_node_path4.default.posix.basename(normalized).toLowerCase();
10947
+ const base = import_node_path6.default.posix.basename(normalized).toLowerCase();
11760
10948
  if (base === "index.html" || base === "200.html" || base === "404.html" || base === "apple-app-site-association") {
11761
10949
  return "no-cache, no-store, must-revalidate";
11762
10950
  }
@@ -11973,7 +11161,7 @@ var BucketCommandHandler = class {
11973
11161
  };
11974
11162
 
11975
11163
  // src/commands/DeleteCommandHandler.ts
11976
- var import_node_path5 = __toESM(require("path"));
11164
+ var import_node_path7 = __toESM(require("path"));
11977
11165
  var import_node_child_process2 = require("child_process");
11978
11166
 
11979
11167
  // src/serverAddress.ts
@@ -12131,17 +11319,17 @@ var DeleteCommandHandler = class {
12131
11319
  });
12132
11320
  }
12133
11321
  resolveCwd(target) {
12134
- return target ? import_node_path5.default.resolve(process.cwd(), target) : process.cwd();
11322
+ return target ? import_node_path7.default.resolve(process.cwd(), target) : process.cwd();
12135
11323
  }
12136
11324
  };
12137
11325
 
12138
11326
  // src/commands/DevCommandHandler.ts
12139
- var import_node_fs4 = require("fs");
12140
- var import_node_path7 = __toESM(require("path"));
11327
+ var import_node_fs5 = require("fs");
11328
+ var import_node_path9 = __toESM(require("path"));
12141
11329
  var import_node_child_process3 = require("child_process");
12142
11330
 
12143
11331
  // src/appDir.ts
12144
- var import_node_path6 = __toESM(require("path"));
11332
+ var import_node_path8 = __toESM(require("path"));
12145
11333
  function normalizeRelativeDir(input, appName) {
12146
11334
  if (typeof input !== "string") {
12147
11335
  throw new Error(`Missing dir for ${appName} in .pmate.yaml`);
@@ -12154,7 +11342,7 @@ function normalizeRelativeDir(input, appName) {
12154
11342
  if (unixLike.startsWith("/")) {
12155
11343
  throw new Error(`Invalid dir for ${appName} in .pmate.yaml: must be relative`);
12156
11344
  }
12157
- const normalized = import_node_path6.default.posix.normalize(unixLike);
11345
+ const normalized = import_node_path8.default.posix.normalize(unixLike);
12158
11346
  if (normalized.startsWith("../") || normalized === "..") {
12159
11347
  throw new Error(
12160
11348
  `Invalid dir for ${appName} in .pmate.yaml: must stay within repo`
@@ -12164,7 +11352,7 @@ function normalizeRelativeDir(input, appName) {
12164
11352
  }
12165
11353
  function resolveLocalAppDir(repoRoot, appName, dir) {
12166
11354
  const relative = normalizeRelativeDir(dir, appName);
12167
- return import_node_path6.default.resolve(repoRoot, relative);
11355
+ return import_node_path8.default.resolve(repoRoot, relative);
12168
11356
  }
12169
11357
  function resolveRemoteAppDir(appName, dir) {
12170
11358
  return normalizeRelativeDir(dir, appName);
@@ -12187,8 +11375,8 @@ var DevCommandHandler = class {
12187
11375
  );
12188
11376
  }
12189
11377
  const appDir = resolveLocalAppDir(cwd, appName, appConfig.dir);
12190
- const packageJsonPath = import_node_path7.default.join(appDir, "package.json");
12191
- if (!(0, import_node_fs4.existsSync)(packageJsonPath)) {
11378
+ const packageJsonPath = import_node_path9.default.join(appDir, "package.json");
11379
+ if (!(0, import_node_fs5.existsSync)(packageJsonPath)) {
12192
11380
  throw new Error(`No package.json found at ${packageJsonPath}`);
12193
11381
  }
12194
11382
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -12202,13 +11390,13 @@ var DevCommandHandler = class {
12202
11390
  await this.runCommand("pnpm", ["--filter", pkgName, "run", "dev"], cwd);
12203
11391
  }
12204
11392
  resolveCwd(target) {
12205
- return target ? import_node_path7.default.resolve(process.cwd(), target) : process.cwd();
11393
+ return target ? import_node_path9.default.resolve(process.cwd(), target) : process.cwd();
12206
11394
  }
12207
11395
  loadConfig(cwd) {
12208
11396
  return loadAppConfig(cwd);
12209
11397
  }
12210
11398
  loadPackageJson(packageJsonPath) {
12211
- const raw = (0, import_node_fs4.readFileSync)(packageJsonPath, "utf8");
11399
+ const raw = (0, import_node_fs5.readFileSync)(packageJsonPath, "utf8");
12212
11400
  const parsed = JSON.parse(raw);
12213
11401
  if (!parsed || typeof parsed !== "object") {
12214
11402
  throw new Error(`Invalid package.json at ${packageJsonPath}`);
@@ -12236,8 +11424,8 @@ var DevCommandHandler = class {
12236
11424
  };
12237
11425
 
12238
11426
  // src/commands/OssCommandHandler.ts
12239
- var import_node_fs5 = require("fs");
12240
- var import_node_path8 = __toESM(require("path"));
11427
+ var import_node_fs6 = require("fs");
11428
+ var import_node_path10 = __toESM(require("path"));
12241
11429
  var OssCommandHandler = class _OssCommandHandler {
12242
11430
  static {
12243
11431
  this.DEFAULT_BUCKET = "parrot-static";
@@ -12254,17 +11442,17 @@ var OssCommandHandler = class _OssCommandHandler {
12254
11442
  }
12255
11443
  return;
12256
11444
  }
12257
- const resolvedFile = import_node_path8.default.resolve(process.cwd(), args.filePath);
11445
+ const resolvedFile = import_node_path10.default.resolve(process.cwd(), args.filePath);
12258
11446
  this.assertFile(resolvedFile);
12259
11447
  const objectKey = this.normalizeObjectKey(args.objectKey);
12260
11448
  const bucket = this.resolveBucket(args.bucket);
12261
11449
  await AliyunService.uploadFile(resolvedFile, bucket, objectKey);
12262
11450
  }
12263
11451
  assertFile(filePath) {
12264
- if (!(0, import_node_fs5.existsSync)(filePath)) {
11452
+ if (!(0, import_node_fs6.existsSync)(filePath)) {
12265
11453
  throw new Error(`File not found: ${filePath}`);
12266
11454
  }
12267
- const stat = (0, import_node_fs5.statSync)(filePath);
11455
+ const stat = (0, import_node_fs6.statSync)(filePath);
12268
11456
  if (!stat.isFile()) {
12269
11457
  throw new Error(`Not a file: ${filePath}`);
12270
11458
  }
@@ -12286,7 +11474,7 @@ var OssCommandHandler = class _OssCommandHandler {
12286
11474
  };
12287
11475
 
12288
11476
  // src/commands/EnvCommandHandler.ts
12289
- var import_node_path9 = __toESM(require("path"));
11477
+ var import_node_path11 = __toESM(require("path"));
12290
11478
  var import_node_child_process4 = require("child_process");
12291
11479
 
12292
11480
  // src/shell.ts
@@ -12370,8 +11558,8 @@ var EnvCommandHandler = class {
12370
11558
  ui.success(`Set ${envKey} in .env.local`, appName);
12371
11559
  }
12372
11560
  async listEnvKeys(server, repoDir, appDir, verbose) {
12373
- const envLocalPath = import_node_path9.default.posix.join(appDir, ".env.local");
12374
- const envPath = import_node_path9.default.posix.join(appDir, ".env");
11561
+ const envLocalPath = import_node_path11.default.posix.join(appDir, ".env.local");
11562
+ const envPath = import_node_path11.default.posix.join(appDir, ".env");
12375
11563
  if (verbose) {
12376
11564
  const repoPath = `$HOME/${repoDir}`;
12377
11565
  ui.info("Env list target", {
@@ -12464,8 +11652,8 @@ var EnvCommandHandler = class {
12464
11652
  }
12465
11653
  }
12466
11654
  async appendEnvLine(server, repoDir, appDir, envKey, envLine, verbose) {
12467
- const envLocalPath = import_node_path9.default.posix.join(appDir, ".env.local");
12468
- const envPath = import_node_path9.default.posix.join(appDir, ".env");
11655
+ const envLocalPath = import_node_path11.default.posix.join(appDir, ".env.local");
11656
+ const envPath = import_node_path11.default.posix.join(appDir, ".env");
12469
11657
  if (verbose) {
12470
11658
  const repoPath = `$HOME/${repoDir}`;
12471
11659
  ui.info("Env add target", {
@@ -12513,8 +11701,8 @@ var EnvCommandHandler = class {
12513
11701
  await this.runRemoteCommand(server, command);
12514
11702
  }
12515
11703
  async deleteEnvKey(server, repoDir, appDir, envKey, verbose) {
12516
- const envLocalPath = import_node_path9.default.posix.join(appDir, ".env.local");
12517
- const envPath = import_node_path9.default.posix.join(appDir, ".env");
11704
+ const envLocalPath = import_node_path11.default.posix.join(appDir, ".env.local");
11705
+ const envPath = import_node_path11.default.posix.join(appDir, ".env");
12518
11706
  if (verbose) {
12519
11707
  const repoPath = `$HOME/${repoDir}`;
12520
11708
  ui.info("Env delete target", {
@@ -13330,7 +12518,7 @@ var CommitCommandHandler = class {
13330
12518
 
13331
12519
  // src/commands/SummaryCommandHandler.ts
13332
12520
  var import_node_child_process6 = require("child_process");
13333
- var import_node_path11 = __toESM(require("path"));
12521
+ var import_node_path13 = __toESM(require("path"));
13334
12522
  var SummaryCommandHandler = class {
13335
12523
  async handle(args) {
13336
12524
  const cwd = this.resolveCwd(args.cwd);
@@ -13515,7 +12703,7 @@ var SummaryCommandHandler = class {
13515
12703
  return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
13516
12704
  }
13517
12705
  resolveCwd(value) {
13518
- return value ? import_node_path11.default.resolve(process.cwd(), value) : process.cwd();
12706
+ return value ? import_node_path13.default.resolve(process.cwd(), value) : process.cwd();
13519
12707
  }
13520
12708
  };
13521
12709
  function truncate2(value, limit) {
@@ -13528,9 +12716,9 @@ function truncate2(value, limit) {
13528
12716
 
13529
12717
  // src/commands/LinearCommandHandler.ts
13530
12718
  var import_node_child_process7 = require("child_process");
13531
- var import_node_fs7 = require("fs");
13532
- var import_node_os3 = __toESM(require("os"));
13533
- var import_node_path12 = __toESM(require("path"));
12719
+ var import_node_fs8 = require("fs");
12720
+ var import_node_os4 = __toESM(require("os"));
12721
+ var import_node_path14 = __toESM(require("path"));
13534
12722
  var import_promises3 = require("readline/promises");
13535
12723
  var import_openai = __toESM(require("openai"));
13536
12724
  var import_sdk = require("@linear/sdk");
@@ -14414,15 +13602,15 @@ var LinearCommandHandler = class {
14414
13602
  }
14415
13603
  }
14416
13604
  getLinearSelectionPath() {
14417
- return import_node_path12.default.join(import_node_os3.default.homedir(), ".pmate", "linear-selection.json");
13605
+ return import_node_path14.default.join(import_node_os4.default.homedir(), ".pmate", "linear-selection.json");
14418
13606
  }
14419
13607
  readCachedLinearSelection(cwd) {
14420
13608
  const selectionPath = this.getLinearSelectionPath();
14421
- if (!(0, import_node_fs7.existsSync)(selectionPath)) {
13609
+ if (!(0, import_node_fs8.existsSync)(selectionPath)) {
14422
13610
  return void 0;
14423
13611
  }
14424
13612
  try {
14425
- const raw = (0, import_node_fs7.readFileSync)(selectionPath, "utf8").trim();
13613
+ const raw = (0, import_node_fs8.readFileSync)(selectionPath, "utf8").trim();
14426
13614
  if (!raw) return void 0;
14427
13615
  const parsed = JSON.parse(raw);
14428
13616
  const value = parsed[cwd];
@@ -14433,12 +13621,12 @@ var LinearCommandHandler = class {
14433
13621
  }
14434
13622
  writeCachedLinearSelection(cwd, title) {
14435
13623
  const selectionPath = this.getLinearSelectionPath();
14436
- const dir = import_node_path12.default.dirname(selectionPath);
14437
- (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
13624
+ const dir = import_node_path14.default.dirname(selectionPath);
13625
+ (0, import_node_fs8.mkdirSync)(dir, { recursive: true });
14438
13626
  let data = {};
14439
- if ((0, import_node_fs7.existsSync)(selectionPath)) {
13627
+ if ((0, import_node_fs8.existsSync)(selectionPath)) {
14440
13628
  try {
14441
- const raw = (0, import_node_fs7.readFileSync)(selectionPath, "utf8").trim();
13629
+ const raw = (0, import_node_fs8.readFileSync)(selectionPath, "utf8").trim();
14442
13630
  if (raw) {
14443
13631
  data = JSON.parse(raw);
14444
13632
  }
@@ -14447,7 +13635,7 @@ var LinearCommandHandler = class {
14447
13635
  }
14448
13636
  }
14449
13637
  data[cwd] = title;
14450
- (0, import_node_fs7.writeFileSync)(selectionPath, `${JSON.stringify(data, null, 2)}
13638
+ (0, import_node_fs8.writeFileSync)(selectionPath, `${JSON.stringify(data, null, 2)}
14451
13639
  `, "utf8");
14452
13640
  }
14453
13641
  async lookupIssue(client, issueRef) {
@@ -14624,14 +13812,14 @@ var LinearCommandHandler = class {
14624
13812
  if (process.platform !== "darwin") {
14625
13813
  throw new Error("Screenshot capture only supports macOS.");
14626
13814
  }
14627
- const dir = await import_node_fs7.promises.mkdtemp(import_node_path12.default.join(import_node_os3.default.tmpdir(), "pmate-screenshot-"));
14628
- const filePath = import_node_path12.default.join(dir, `screenshot-${index}.png`);
13815
+ const dir = await import_node_fs8.promises.mkdtemp(import_node_path14.default.join(import_node_os4.default.tmpdir(), "pmate-screenshot-"));
13816
+ const filePath = import_node_path14.default.join(dir, `screenshot-${index}.png`);
14629
13817
  try {
14630
13818
  const code = await this.run("screencapture", ["-i", "-x", filePath], true);
14631
13819
  if (code !== 0) {
14632
13820
  throw new Error("Screenshot capture canceled or failed.");
14633
13821
  }
14634
- const buffer = await import_node_fs7.promises.readFile(filePath);
13822
+ const buffer = await import_node_fs8.promises.readFile(filePath);
14635
13823
  if (buffer.length === 0) {
14636
13824
  throw new Error("Screenshot capture produced an empty file.");
14637
13825
  }
@@ -14643,7 +13831,7 @@ var LinearCommandHandler = class {
14643
13831
  return { buffer, mime, filename: `screenshot-${index}.${extension}` };
14644
13832
  } finally {
14645
13833
  try {
14646
- await import_node_fs7.promises.rm(dir, { recursive: true, force: true });
13834
+ await import_node_fs8.promises.rm(dir, { recursive: true, force: true });
14647
13835
  } catch {
14648
13836
  }
14649
13837
  }
@@ -14787,17 +13975,17 @@ var LinearCommandHandler = class {
14787
13975
  return compact.length > limit ? `${compact.slice(0, limit)}...` : compact;
14788
13976
  }
14789
13977
  async convertToPng(buffer, ext) {
14790
- const dir = await import_node_fs7.promises.mkdtemp(import_node_path12.default.join(import_node_os3.default.tmpdir(), "pmate-"));
14791
- const inputPath = import_node_path12.default.join(dir, `clipboard.${ext}`);
14792
- const outputPath = import_node_path12.default.join(dir, "clipboard.png");
13978
+ const dir = await import_node_fs8.promises.mkdtemp(import_node_path14.default.join(import_node_os4.default.tmpdir(), "pmate-"));
13979
+ const inputPath = import_node_path14.default.join(dir, `clipboard.${ext}`);
13980
+ const outputPath = import_node_path14.default.join(dir, "clipboard.png");
14793
13981
  try {
14794
- await import_node_fs7.promises.writeFile(inputPath, buffer);
13982
+ await import_node_fs8.promises.writeFile(inputPath, buffer);
14795
13983
  const stderr = await this.runCapture(
14796
13984
  "sips",
14797
13985
  ["-s", "format", "png", inputPath, "--out", outputPath],
14798
13986
  true
14799
13987
  );
14800
- const out = await import_node_fs7.promises.readFile(outputPath);
13988
+ const out = await import_node_fs8.promises.readFile(outputPath);
14801
13989
  if (this.detectImageMime(out) !== "image/png") {
14802
13990
  throw new Error(
14803
13991
  stderr?.trim() ? `Failed to convert clipboard ${ext} to PNG: ${stderr.trim()}` : `Failed to convert clipboard ${ext} to PNG.`
@@ -14806,7 +13994,7 @@ var LinearCommandHandler = class {
14806
13994
  return out;
14807
13995
  } finally {
14808
13996
  try {
14809
- await import_node_fs7.promises.rm(dir, { recursive: true, force: true });
13997
+ await import_node_fs8.promises.rm(dir, { recursive: true, force: true });
14810
13998
  } catch {
14811
13999
  }
14812
14000
  }
@@ -15100,7 +14288,7 @@ var LinearCommandHandler = class {
15100
14288
  return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
15101
14289
  }
15102
14290
  resolveCwd(value) {
15103
- return value ? import_node_path12.default.resolve(process.cwd(), value) : process.cwd();
14291
+ return value ? import_node_path14.default.resolve(process.cwd(), value) : process.cwd();
15104
14292
  }
15105
14293
  createOpenAiClient() {
15106
14294
  const config = loadPmateConfig();
@@ -15152,8 +14340,8 @@ function sleep2(ms) {
15152
14340
  }
15153
14341
 
15154
14342
  // src/commands/NotionCommandHandler.ts
15155
- var import_node_fs8 = require("fs");
15156
- var import_node_path13 = __toESM(require("path"));
14343
+ var import_node_fs9 = require("fs");
14344
+ var import_node_path15 = __toESM(require("path"));
15157
14345
 
15158
14346
  // src/services/NotionService.ts
15159
14347
  var NotionService = class {
@@ -15392,9 +14580,9 @@ ${indent}\`\`\``;
15392
14580
  static richTextToPlain(richText) {
15393
14581
  return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
15394
14582
  }
15395
- static async requestJson(path29, init) {
14583
+ static async requestJson(path31, init) {
15396
14584
  const token = this.getToken();
15397
- const response = await fetch(`${this.baseUrl}${path29}`, {
14585
+ const response = await fetch(`${this.baseUrl}${path31}`, {
15398
14586
  method: init.method,
15399
14587
  headers: {
15400
14588
  Authorization: `Bearer ${token}`,
@@ -15492,16 +14680,16 @@ var NotionCommandHandler = class {
15492
14680
  if (!args.filePath) {
15493
14681
  return "";
15494
14682
  }
15495
- const resolved = import_node_path13.default.resolve(process.cwd(), args.filePath);
15496
- return (0, import_node_fs8.readFileSync)(resolved, "utf8");
14683
+ const resolved = import_node_path15.default.resolve(process.cwd(), args.filePath);
14684
+ return (0, import_node_fs9.readFileSync)(resolved, "utf8");
15497
14685
  }
15498
14686
  };
15499
14687
 
15500
14688
  // src/commands/QrcodeCommandHandler.ts
15501
14689
  var import_node_child_process8 = require("child_process");
15502
- var import_node_fs9 = require("fs");
15503
- var import_node_os4 = __toESM(require("os"));
15504
- var import_node_path14 = __toESM(require("path"));
14690
+ var import_node_fs10 = require("fs");
14691
+ var import_node_os5 = __toESM(require("os"));
14692
+ var import_node_path16 = __toESM(require("path"));
15505
14693
  var import_promises4 = require("readline/promises");
15506
14694
  var import_jsqr = __toESM(require("jsqr"));
15507
14695
  var import_pngjs = require("pngjs");
@@ -15527,7 +14715,7 @@ var QrcodeCommandHandler = class {
15527
14715
  ui.success("QR code value:", value);
15528
14716
  } finally {
15529
14717
  try {
15530
- await import_node_fs9.promises.rm(dir, { recursive: true, force: true });
14718
+ await import_node_fs10.promises.rm(dir, { recursive: true, force: true });
15531
14719
  } catch {
15532
14720
  }
15533
14721
  }
@@ -15543,13 +14731,13 @@ var QrcodeCommandHandler = class {
15543
14731
  } finally {
15544
14732
  rl.close();
15545
14733
  }
15546
- const dir = await import_node_fs9.promises.mkdtemp(import_node_path14.default.join(import_node_os4.default.tmpdir(), "pmate-qrcode-"));
15547
- const filePath = import_node_path14.default.join(dir, "qrcode.png");
14734
+ const dir = await import_node_fs10.promises.mkdtemp(import_node_path16.default.join(import_node_os5.default.tmpdir(), "pmate-qrcode-"));
14735
+ const filePath = import_node_path16.default.join(dir, "qrcode.png");
15548
14736
  const code = await this.run("screencapture", ["-i", "-x", filePath], true);
15549
14737
  if (code !== 0) {
15550
14738
  throw new Error("Screenshot capture canceled or failed.");
15551
14739
  }
15552
- const buffer = await import_node_fs9.promises.readFile(filePath);
14740
+ const buffer = await import_node_fs10.promises.readFile(filePath);
15553
14741
  if (buffer.length === 0) {
15554
14742
  throw new Error("Screenshot capture produced an empty file.");
15555
14743
  }
@@ -15565,7 +14753,7 @@ var QrcodeCommandHandler = class {
15565
14753
  async decodeQr(filePath) {
15566
14754
  let buffer;
15567
14755
  try {
15568
- buffer = await import_node_fs9.promises.readFile(filePath);
14756
+ buffer = await import_node_fs10.promises.readFile(filePath);
15569
14757
  } catch {
15570
14758
  return null;
15571
14759
  }
@@ -15823,8 +15011,8 @@ function clampNumber(value, min, max, fallback) {
15823
15011
  }
15824
15012
 
15825
15013
  // src/commands/QuizCommandHandler.ts
15826
- var import_node_fs10 = require("fs");
15827
- var import_node_path15 = __toESM(require("path"));
15014
+ var import_node_fs11 = require("fs");
15015
+ var import_node_path17 = __toESM(require("path"));
15828
15016
  init_sessionStore();
15829
15017
 
15830
15018
  // src/services/QuizService.ts
@@ -16369,8 +15557,8 @@ var QuizCommandHandler = class {
16369
15557
  return;
16370
15558
  }
16371
15559
  if (args.action === "update-meta") {
16372
- const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
16373
- const metadata = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
15560
+ const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
15561
+ const metadata = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
16374
15562
  const result = await updateQuizPaperMetadata({
16375
15563
  apiBaseUrl,
16376
15564
  linkBaseUrl,
@@ -16382,8 +15570,8 @@ var QuizCommandHandler = class {
16382
15570
  return;
16383
15571
  }
16384
15572
  if (args.action === "append-step") {
16385
- const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
16386
- const step = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
15573
+ const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
15574
+ const step = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
16387
15575
  const result = await appendQuizPaperStep({
16388
15576
  apiBaseUrl,
16389
15577
  linkBaseUrl,
@@ -16396,8 +15584,8 @@ var QuizCommandHandler = class {
16396
15584
  return;
16397
15585
  }
16398
15586
  if (args.action === "update-step") {
16399
- const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
16400
- const step = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
15587
+ const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
15588
+ const step = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
16401
15589
  step.stepId = args.stepId;
16402
15590
  const result = await updateQuizPaperStep({
16403
15591
  apiBaseUrl,
@@ -16460,8 +15648,8 @@ var QuizCommandHandler = class {
16460
15648
  if (targetIndex < 0) {
16461
15649
  throw new Error(`\u672A\u627E\u5230 stepId=${args.stepId}\uFF0C\u65E0\u6CD5\u66F4\u65B0\u8BE5\u9898\u76EE\u3002`);
16462
15650
  }
16463
- const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
16464
- const nextStep = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
15651
+ const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
15652
+ const nextStep = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
16465
15653
  nextStep.stepId = args.stepId;
16466
15654
  const nextSteps = [...basePaper.steps];
16467
15655
  nextSteps[targetIndex] = nextStep;
@@ -16511,9 +15699,9 @@ var QuizCommandHandler = class {
16511
15699
  };
16512
15700
 
16513
15701
  // src/commands/CollectCommandHandler.ts
16514
- var import_node_fs12 = require("fs");
16515
- var import_node_os6 = __toESM(require("os"));
16516
- var import_node_path17 = __toESM(require("path"));
15702
+ var import_node_fs13 = require("fs");
15703
+ var import_node_os7 = __toESM(require("os"));
15704
+ var import_node_path19 = __toESM(require("path"));
16517
15705
  var import_playwright = require("playwright");
16518
15706
 
16519
15707
  // src/im1BotClient.ts
@@ -16579,13 +15767,13 @@ var Im1BotClient = class {
16579
15767
 
16580
15768
  // src/collectStore.ts
16581
15769
  var import_node_crypto3 = require("crypto");
16582
- var import_node_fs11 = require("fs");
16583
- var import_node_os5 = __toESM(require("os"));
16584
- var import_node_path16 = __toESM(require("path"));
15770
+ var import_node_fs12 = require("fs");
15771
+ var import_node_os6 = __toESM(require("os"));
15772
+ var import_node_path18 = __toESM(require("path"));
16585
15773
  function resolveCollectTarget(input) {
16586
15774
  const endpoint = input.endpoint ?? (input.source === "cc" ? "http://localhost:9223" : "http://localhost:9222");
16587
15775
  const sourceKey = input.source ?? `endpoint-${(0, import_node_crypto3.createHash)("sha1").update(endpoint).digest("hex").slice(0, 8)}`;
16588
- const rootDir = import_node_path16.default.join(import_node_os5.default.homedir(), ".pmate", "collect", sourceKey);
15776
+ const rootDir = import_node_path18.default.join(import_node_os6.default.homedir(), ".pmate", "collect", sourceKey);
16589
15777
  return { sourceKey, endpoint, rootDir };
16590
15778
  }
16591
15779
  function toThreadKey(name) {
@@ -16597,7 +15785,7 @@ function toThreadKey(name) {
16597
15785
  async function readStoredThread(rootDir, threadKey) {
16598
15786
  const filePath = getThreadMetaFilePath(rootDir, threadKey);
16599
15787
  try {
16600
- const raw = await import_node_fs11.promises.readFile(filePath, "utf8");
15788
+ const raw = await import_node_fs12.promises.readFile(filePath, "utf8");
16601
15789
  const parsed = JSON.parse(raw);
16602
15790
  if ("messages" in parsed && Array.isArray(parsed.messages)) {
16603
15791
  return parsed;
@@ -16615,15 +15803,15 @@ async function writeStoredThread(rootDir, thread) {
16615
15803
  const metaPath = getThreadMetaFilePath(rootDir, thread.threadKey);
16616
15804
  const messagePath = getThreadMessagesFilePath(rootDir, thread.threadKey);
16617
15805
  const { messages: messages2, ...meta } = thread;
16618
- await import_node_fs11.promises.mkdir(import_node_path16.default.dirname(metaPath), { recursive: true });
16619
- await import_node_fs11.promises.writeFile(metaPath, JSON.stringify(meta, null, 2) + "\n", "utf8");
15806
+ await import_node_fs12.promises.mkdir(import_node_path18.default.dirname(metaPath), { recursive: true });
15807
+ await import_node_fs12.promises.writeFile(metaPath, JSON.stringify(meta, null, 2) + "\n", "utf8");
16620
15808
  const body = messages2.map((message) => JSON.stringify(message)).join("\n");
16621
- await import_node_fs11.promises.writeFile(messagePath, `${body}${body ? "\n" : ""}`, "utf8");
15809
+ await import_node_fs12.promises.writeFile(messagePath, `${body}${body ? "\n" : ""}`, "utf8");
16622
15810
  }
16623
15811
  async function writeStoredIndex(rootDir, index) {
16624
- await import_node_fs11.promises.mkdir(rootDir, { recursive: true });
16625
- const filePath = import_node_path16.default.join(rootDir, "index.json");
16626
- await import_node_fs11.promises.writeFile(filePath, JSON.stringify(index, null, 2) + "\n", "utf8");
15812
+ await import_node_fs12.promises.mkdir(rootDir, { recursive: true });
15813
+ const filePath = import_node_path18.default.join(rootDir, "index.json");
15814
+ await import_node_fs12.promises.writeFile(filePath, JSON.stringify(index, null, 2) + "\n", "utf8");
16627
15815
  }
16628
15816
  function diffMessages(existing, incoming) {
16629
15817
  const seenMessageIds = new Set(
@@ -16697,7 +15885,7 @@ function joinNormalized(values) {
16697
15885
  async function readStoredMessages(rootDir, threadKey) {
16698
15886
  const filePath = getThreadMessagesFilePath(rootDir, threadKey);
16699
15887
  try {
16700
- const raw = await import_node_fs11.promises.readFile(filePath, "utf8");
15888
+ const raw = await import_node_fs12.promises.readFile(filePath, "utf8");
16701
15889
  return raw.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => normalizeStoredMessage(JSON.parse(line)));
16702
15890
  } catch {
16703
15891
  return [];
@@ -16706,20 +15894,20 @@ async function readStoredMessages(rootDir, threadKey) {
16706
15894
  async function readLegacyStoredThread(rootDir, threadKey) {
16707
15895
  const filePath = getLegacyThreadFilePath(rootDir, threadKey);
16708
15896
  try {
16709
- const raw = await import_node_fs11.promises.readFile(filePath, "utf8");
15897
+ const raw = await import_node_fs12.promises.readFile(filePath, "utf8");
16710
15898
  return JSON.parse(raw);
16711
15899
  } catch {
16712
15900
  return null;
16713
15901
  }
16714
15902
  }
16715
15903
  function getThreadMetaFilePath(rootDir, threadKey) {
16716
- return import_node_path16.default.join(rootDir, "threads", `${threadKey}.json`);
15904
+ return import_node_path18.default.join(rootDir, "threads", `${threadKey}.json`);
16717
15905
  }
16718
15906
  function getThreadMessagesFilePath(rootDir, threadKey) {
16719
- return import_node_path16.default.join(rootDir, "threads", `${threadKey}.jsonl`);
15907
+ return import_node_path18.default.join(rootDir, "threads", `${threadKey}.jsonl`);
16720
15908
  }
16721
15909
  function getLegacyThreadFilePath(rootDir, threadKey) {
16722
- return import_node_path16.default.join(rootDir, "threads", `${threadKey}.json`);
15910
+ return import_node_path18.default.join(rootDir, "threads", `${threadKey}.json`);
16723
15911
  }
16724
15912
  function normalizeStoredMessage(message) {
16725
15913
  return {
@@ -16958,7 +16146,7 @@ var CollectCommandHandler = class {
16958
16146
  }
16959
16147
  async writeSyncReport(rootDir, target, results, failures, syncedAt) {
16960
16148
  const syncId = toSyncId(syncedAt);
16961
- const reportPath = import_node_path17.default.join(rootDir, "syncs", `${syncId}.json`);
16149
+ const reportPath = import_node_path19.default.join(rootDir, "syncs", `${syncId}.json`);
16962
16150
  const threadReports = results.map((result) => ({
16963
16151
  threadKey: result.thread.threadKey,
16964
16152
  threadName: result.thread.threadName,
@@ -16967,8 +16155,8 @@ var CollectCommandHandler = class {
16967
16155
  addedMessages: result.diff.added,
16968
16156
  upgradedMessages: result.diff.upgraded
16969
16157
  })).filter((thread) => thread.addedCount > 0 || thread.upgradedCount > 0);
16970
- await import_node_fs12.promises.mkdir(import_node_path17.default.dirname(reportPath), { recursive: true });
16971
- await import_node_fs12.promises.writeFile(
16158
+ await import_node_fs13.promises.mkdir(import_node_path19.default.dirname(reportPath), { recursive: true });
16159
+ await import_node_fs13.promises.writeFile(
16972
16160
  reportPath,
16973
16161
  JSON.stringify(
16974
16162
  {
@@ -17146,19 +16334,19 @@ async function archiveMessageImage(rootDir, attachmentRoot, threadKey, imagePath
17146
16334
  if (!imagePath || isExternalImageRef(imagePath)) {
17147
16335
  return imagePath;
17148
16336
  }
17149
- const normalized = import_node_path17.default.posix.normalize(imagePath.replace(/\\/g, "/"));
16337
+ const normalized = import_node_path19.default.posix.normalize(imagePath.replace(/\\/g, "/"));
17150
16338
  if (normalized.startsWith("attachments/")) {
17151
- return import_node_path17.default.join(rootDir, ...normalized.split("/"));
16339
+ return import_node_path19.default.join(rootDir, ...normalized.split("/"));
17152
16340
  }
17153
- if (normalized.startsWith("../") || import_node_path17.default.posix.isAbsolute(normalized)) {
16341
+ if (normalized.startsWith("../") || import_node_path19.default.posix.isAbsolute(normalized)) {
17154
16342
  return imagePath;
17155
16343
  }
17156
- const sourcePath = import_node_path17.default.join(attachmentRoot, ...normalized.split("/"));
17157
- const destinationRelativePath = import_node_path17.default.posix.join("attachments", threadKey, normalized);
17158
- const destinationPath = import_node_path17.default.join(rootDir, ...destinationRelativePath.split("/"));
16344
+ const sourcePath = import_node_path19.default.join(attachmentRoot, ...normalized.split("/"));
16345
+ const destinationRelativePath = import_node_path19.default.posix.join("attachments", threadKey, normalized);
16346
+ const destinationPath = import_node_path19.default.join(rootDir, ...destinationRelativePath.split("/"));
17159
16347
  try {
17160
- await import_node_fs12.promises.mkdir(import_node_path17.default.dirname(destinationPath), { recursive: true });
17161
- await import_node_fs12.promises.copyFile(sourcePath, destinationPath);
16348
+ await import_node_fs13.promises.mkdir(import_node_path19.default.dirname(destinationPath), { recursive: true });
16349
+ await import_node_fs13.promises.copyFile(sourcePath, destinationPath);
17162
16350
  return destinationPath;
17163
16351
  } catch {
17164
16352
  return imagePath;
@@ -17168,7 +16356,7 @@ function resolveLocalAttachmentRoot(sourceKey) {
17168
16356
  if (sourceKey !== "cc" && sourceKey !== "yelling") {
17169
16357
  return null;
17170
16358
  }
17171
- return import_node_path17.default.join(import_node_os6.default.homedir(), "Library", "Application Support", sourceKey, "attachments.noindex");
16359
+ return import_node_path19.default.join(import_node_os7.default.homedir(), "Library", "Application Support", sourceKey, "attachments.noindex");
17172
16360
  }
17173
16361
  function isExternalImageRef(imagePath) {
17174
16362
  return /^[a-z][a-z0-9+.-]*:/i.test(imagePath);
@@ -17780,7 +16968,7 @@ function pad2(value) {
17780
16968
  }
17781
16969
 
17782
16970
  // src/commands/ChatRoomCommandHandler.ts
17783
- var import_node_fs13 = require("fs");
16971
+ var import_node_fs14 = require("fs");
17784
16972
  var ChatRoomCommandHandler = class {
17785
16973
  async handle(args) {
17786
16974
  const sdk = await loadChatSdk();
@@ -17830,8 +17018,8 @@ var ChatRoomCommandHandler = class {
17830
17018
  const a = await this.connect(sdk, args.botA, args.app, args.hubUrl, args.authBaseUrl);
17831
17019
  const b = await this.connect(sdk, args.botB, args.app, args.hubUrl, args.authBaseUrl);
17832
17020
  try {
17833
- const botA = sdk.parsePmateBotKeyJson((0, import_node_fs13.readFileSync)(args.botA, "utf8"));
17834
- const botB = sdk.parsePmateBotKeyJson((0, import_node_fs13.readFileSync)(args.botB, "utf8"));
17021
+ const botA = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(args.botA, "utf8"));
17022
+ const botB = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(args.botB, "utf8"));
17835
17023
  await a.requestFriend({ to: botB.name, message: "smoke friend request" });
17836
17024
  await b.acceptFriend({ to: botA.name, message: "smoke friend accept" });
17837
17025
  await a.sendDm({ to: botB.name, text: "smoke dm from a" });
@@ -17850,7 +17038,7 @@ var ChatRoomCommandHandler = class {
17850
17038
  if (!botPath) {
17851
17039
  throw new Error("Missing required option: --bot");
17852
17040
  }
17853
- const botKey = sdk.parsePmateBotKeyJson((0, import_node_fs13.readFileSync)(botPath, "utf8"));
17041
+ const botKey = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(botPath, "utf8"));
17854
17042
  const client = sdk.createChatClient({ appId, botKey, hubUrl, authBaseUrl });
17855
17043
  await client.connect();
17856
17044
  return client;
@@ -17862,8 +17050,8 @@ async function loadChatSdk() {
17862
17050
  }
17863
17051
 
17864
17052
  // src/commands/AgentCommandHandler.ts
17865
- var import_node_fs14 = require("fs");
17866
- var import_node_path18 = __toESM(require("path"));
17053
+ var import_node_fs15 = require("fs");
17054
+ var import_node_path20 = __toESM(require("path"));
17867
17055
  init_AgentLlmClient();
17868
17056
  init_sessionStore();
17869
17057
 
@@ -17896,8 +17084,8 @@ function descriptorPathSegments(descriptor) {
17896
17084
  return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
17897
17085
  }
17898
17086
  function buildPathUrl(baseUrl, pathSegments, query) {
17899
- const path29 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
17900
- const url = new URL(path29, baseUrl);
17087
+ const path31 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
17088
+ const url = new URL(path31, baseUrl);
17901
17089
  if (query) {
17902
17090
  for (const [key, value] of Object.entries(query)) {
17903
17091
  url.searchParams.set(key, String(value));
@@ -18354,11 +17542,11 @@ var AgentCommandHandler = class {
18354
17542
  }).token;
18355
17543
  }
18356
17544
  readJsonFile(filePath) {
18357
- const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
18358
- if (!(0, import_node_fs14.existsSync)(absolutePath)) {
17545
+ const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
17546
+ if (!(0, import_node_fs15.existsSync)(absolutePath)) {
18359
17547
  throw new Error(`JSON file not found: ${absolutePath}`);
18360
17548
  }
18361
- const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
17549
+ const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
18362
17550
  try {
18363
17551
  return JSON.parse(raw);
18364
17552
  } catch (error) {
@@ -18369,14 +17557,14 @@ var AgentCommandHandler = class {
18369
17557
  readJsonObjectFile(filePath) {
18370
17558
  const parsed = this.readJsonFile(filePath);
18371
17559
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
18372
- const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
17560
+ const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
18373
17561
  throw new Error(`Invalid JSON in ${absolutePath}: expected an object`);
18374
17562
  }
18375
17563
  return parsed;
18376
17564
  }
18377
17565
  tryReadJsonObjectFile(filePath) {
18378
17566
  const absolutePath = this.resolveExistingFile(filePath);
18379
- const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
17567
+ const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
18380
17568
  try {
18381
17569
  const parsed = JSON.parse(raw);
18382
17570
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
@@ -18388,8 +17576,8 @@ var AgentCommandHandler = class {
18388
17576
  }
18389
17577
  }
18390
17578
  resolveExistingFile(filePath) {
18391
- const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
18392
- if (!(0, import_node_fs14.existsSync)(absolutePath)) {
17579
+ const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
17580
+ if (!(0, import_node_fs15.existsSync)(absolutePath)) {
18393
17581
  throw new Error(`File not found: ${absolutePath}`);
18394
17582
  }
18395
17583
  return absolutePath;
@@ -18473,8 +17661,8 @@ var AgentCommandHandler = class {
18473
17661
  };
18474
17662
 
18475
17663
  // src/commands/RunnerCommandHandler.ts
18476
- var import_node_fs15 = require("fs");
18477
- var import_node_path19 = __toESM(require("path"));
17664
+ var import_node_fs16 = require("fs");
17665
+ var import_node_path21 = __toESM(require("path"));
18478
17666
  init_sessionStore();
18479
17667
  init_namespacedRef();
18480
17668
  var RunnerCommandHandler = class {
@@ -18569,11 +17757,11 @@ var RunnerCommandHandler = class {
18569
17757
  }).token;
18570
17758
  }
18571
17759
  readJsonFile(filePath) {
18572
- const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
18573
- if (!(0, import_node_fs15.existsSync)(absolutePath)) {
17760
+ const absolutePath = import_node_path21.default.resolve(process.cwd(), filePath);
17761
+ if (!(0, import_node_fs16.existsSync)(absolutePath)) {
18574
17762
  throw new Error(`JSON file not found: ${absolutePath}`);
18575
17763
  }
18576
- const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
17764
+ const raw = (0, import_node_fs16.readFileSync)(absolutePath, "utf8");
18577
17765
  try {
18578
17766
  return JSON.parse(raw);
18579
17767
  } catch (error) {
@@ -18692,8 +17880,8 @@ var NsCommandHandler = class {
18692
17880
  };
18693
17881
 
18694
17882
  // src/commands/StoreCommandHandler.ts
18695
- var import_node_fs16 = require("fs");
18696
- var import_node_path20 = __toESM(require("path"));
17883
+ var import_node_fs17 = require("fs");
17884
+ var import_node_path22 = __toESM(require("path"));
18697
17885
  var StoreCommandHandler = class {
18698
17886
  async handle(args) {
18699
17887
  if (args.scope === "namespace") {
@@ -18835,11 +18023,11 @@ var StoreCommandHandler = class {
18835
18023
  return payload.data ?? [];
18836
18024
  }
18837
18025
  readJsonFile(filePath) {
18838
- const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
18839
- if (!(0, import_node_fs16.existsSync)(absolutePath)) {
18026
+ const absolutePath = import_node_path22.default.resolve(process.cwd(), filePath);
18027
+ if (!(0, import_node_fs17.existsSync)(absolutePath)) {
18840
18028
  throw new Error(`JSON file not found: ${absolutePath}`);
18841
18029
  }
18842
- const raw = (0, import_node_fs16.readFileSync)(absolutePath, "utf8");
18030
+ const raw = (0, import_node_fs17.readFileSync)(absolutePath, "utf8");
18843
18031
  try {
18844
18032
  return JSON.parse(raw);
18845
18033
  } catch (error) {
@@ -18891,14 +18079,14 @@ var StoreCommandHandler = class {
18891
18079
  };
18892
18080
 
18893
18081
  // src/commands/AppCommandHandler.ts
18894
- var import_node_fs18 = require("fs");
18895
- var import_node_path22 = __toESM(require("path"));
18082
+ var import_node_fs19 = require("fs");
18083
+ var import_node_path24 = __toESM(require("path"));
18896
18084
  init_sessionStore();
18897
18085
 
18898
18086
  // src/appIcon.ts
18899
- var import_node_fs17 = require("fs");
18900
- var import_node_os7 = __toESM(require("os"));
18901
- var import_node_path21 = __toESM(require("path"));
18087
+ var import_node_fs18 = require("fs");
18088
+ var import_node_os8 = __toESM(require("os"));
18089
+ var import_node_path23 = __toESM(require("path"));
18902
18090
  var import_sharp = __toESM(require("sharp"));
18903
18091
  init_namespacedRef();
18904
18092
  var ANDROID_ICON_SPECS = [
@@ -19003,13 +18191,13 @@ function createAppIconExportPlans(input) {
19003
18191
  if (!input.outDir) {
19004
18192
  throw new Error("App icon preset export requires --out-dir.");
19005
18193
  }
19006
- const outDir = import_node_path21.default.resolve(input.cwd, input.outDir);
19007
- (0, import_node_fs17.mkdirSync)(outDir, { recursive: true });
18194
+ const outDir = import_node_path23.default.resolve(input.cwd, input.outDir);
18195
+ (0, import_node_fs18.mkdirSync)(outDir, { recursive: true });
19008
18196
  return specs.map((spec) => ({
19009
18197
  width: spec.width,
19010
18198
  height: spec.height,
19011
18199
  format: "png",
19012
- outputPath: import_node_path21.default.join(
18200
+ outputPath: import_node_path23.default.join(
19013
18201
  outDir,
19014
18202
  `${namespace}-${objectId}-${spec.name}-${spec.width}x${spec.height}.png`
19015
18203
  )
@@ -19022,8 +18210,8 @@ function createAppIconExportPlans(input) {
19022
18210
  if (!input.output) {
19023
18211
  throw new Error("Single-size app icon export requires --output.");
19024
18212
  }
19025
- const resolvedOutput = import_node_path21.default.resolve(input.cwd, input.output);
19026
- (0, import_node_fs17.mkdirSync)(import_node_path21.default.dirname(resolvedOutput), { recursive: true });
18213
+ const resolvedOutput = import_node_path23.default.resolve(input.cwd, input.output);
18214
+ (0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(resolvedOutput), { recursive: true });
19027
18215
  return [
19028
18216
  {
19029
18217
  width: input.width,
@@ -19037,7 +18225,7 @@ async function exportAppIcon(icon, plans) {
19037
18225
  const svg = await resolveAppIconSvg(icon);
19038
18226
  for (const plan of plans) {
19039
18227
  const bytes = await renderAppIcon(svg, plan.width, plan.height, plan.format);
19040
- (0, import_node_fs17.writeFileSync)(plan.outputPath, bytes);
18228
+ (0, import_node_fs18.writeFileSync)(plan.outputPath, bytes);
19041
18229
  }
19042
18230
  }
19043
18231
  async function renderAppIconVariant(input) {
@@ -19045,9 +18233,9 @@ async function renderAppIconVariant(input) {
19045
18233
  const bytes = await renderAppIcon(svg, input.width, input.height, input.format);
19046
18234
  let outputPath;
19047
18235
  if (input.output) {
19048
- outputPath = import_node_path21.default.resolve(input.cwd, input.output);
19049
- (0, import_node_fs17.mkdirSync)(import_node_path21.default.dirname(outputPath), { recursive: true });
19050
- (0, import_node_fs17.writeFileSync)(outputPath, bytes);
18236
+ outputPath = import_node_path23.default.resolve(input.cwd, input.output);
18237
+ (0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(outputPath), { recursive: true });
18238
+ (0, import_node_fs18.writeFileSync)(outputPath, bytes);
19051
18239
  }
19052
18240
  if (input.name) {
19053
18241
  return {
@@ -19068,7 +18256,7 @@ async function renderAppIconVariant(input) {
19068
18256
  };
19069
18257
  }
19070
18258
  async function loadAppIconVariantFile(input) {
19071
- const absolutePath = import_node_path21.default.resolve(input.cwd, input.filePath);
18259
+ const absolutePath = import_node_path23.default.resolve(input.cwd, input.filePath);
19072
18260
  const format = inferVariantFormatFromPath(absolutePath);
19073
18261
  return {
19074
18262
  value: input.name ? await uploadAppIconVariantAsset({
@@ -19077,7 +18265,7 @@ async function loadAppIconVariantFile(input) {
19077
18265
  name: input.name,
19078
18266
  format,
19079
18267
  sourcePath: absolutePath
19080
- }) : createImageDataUrl((0, import_node_fs17.readFileSync)(absolutePath), format),
18268
+ }) : createImageDataUrl((0, import_node_fs18.readFileSync)(absolutePath), format),
19081
18269
  format,
19082
18270
  absolutePath
19083
18271
  };
@@ -19136,7 +18324,7 @@ function shouldAutoGenerateDefaultVariant(icon) {
19136
18324
  return looksLikeSvgMarkup(icon) || looksLikeSvgUrl(icon);
19137
18325
  }
19138
18326
  function inferVariantFormatFromPath(filePath) {
19139
- const ext = import_node_path21.default.extname(filePath).toLowerCase();
18327
+ const ext = import_node_path23.default.extname(filePath).toLowerCase();
19140
18328
  switch (ext) {
19141
18329
  case ".png":
19142
18330
  return "png";
@@ -19207,13 +18395,13 @@ async function uploadAppIconVariantAsset(input) {
19207
18395
  await AliyunService.uploadFile(sourcePath, DEFAULT_APP_ICON_VARIANT_BUCKET, objectKey);
19208
18396
  } finally {
19209
18397
  if (shouldCleanup) {
19210
- (0, import_node_fs17.rmSync)(import_node_path21.default.dirname(sourcePath), { recursive: true, force: true });
18398
+ (0, import_node_fs18.rmSync)(import_node_path23.default.dirname(sourcePath), { recursive: true, force: true });
19211
18399
  }
19212
18400
  }
19213
18401
  return `${DEFAULT_APP_ICON_VARIANT_PUBLIC_BASE_URL}/${objectKey}`;
19214
18402
  }
19215
18403
  function buildAppIconVariantObjectKey(input) {
19216
- return import_node_path21.default.posix.join(
18404
+ return import_node_path23.default.posix.join(
19217
18405
  "apps",
19218
18406
  `${resolveAppIconAssetStem(input.icon, input.appRef)}-${input.name}.${extensionForIconFormat(input.format)}`
19219
18407
  );
@@ -19222,8 +18410,8 @@ function resolveAppIconAssetStem(icon, appRef) {
19222
18410
  if (icon) {
19223
18411
  try {
19224
18412
  const url = new URL(icon);
19225
- const ext = import_node_path21.default.posix.extname(url.pathname);
19226
- const basename = import_node_path21.default.posix.basename(url.pathname, ext);
18413
+ const ext = import_node_path23.default.posix.extname(url.pathname);
18414
+ const basename = import_node_path23.default.posix.basename(url.pathname, ext);
19227
18415
  const normalized = sanitizeAppIconAssetStem(basename);
19228
18416
  if (normalized) {
19229
18417
  return normalized;
@@ -19252,9 +18440,9 @@ function writeTempAppIconVariantFile(objectKey, format, bytes) {
19252
18440
  if (!bytes) {
19253
18441
  throw new Error("App icon variant upload requires bytes or a source file.");
19254
18442
  }
19255
- const tempDir = (0, import_node_fs17.mkdtempSync)(import_node_path21.default.join(import_node_os7.default.tmpdir(), "pmate-app-icon-"));
19256
- const tempPath = import_node_path21.default.join(tempDir, import_node_path21.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
19257
- (0, import_node_fs17.writeFileSync)(tempPath, bytes);
18443
+ const tempDir = (0, import_node_fs18.mkdtempSync)(import_node_path23.default.join(import_node_os8.default.tmpdir(), "pmate-app-icon-"));
18444
+ const tempPath = import_node_path23.default.join(tempDir, import_node_path23.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
18445
+ (0, import_node_fs18.writeFileSync)(tempPath, bytes);
19258
18446
  return tempPath;
19259
18447
  }
19260
18448
 
@@ -19463,10 +18651,10 @@ var AppCommandHandler = class {
19463
18651
  }
19464
18652
  readJsonFile(filePath) {
19465
18653
  const absolutePath = this.resolveFilePath(filePath);
19466
- if (!(0, import_node_fs18.existsSync)(absolutePath)) {
18654
+ if (!(0, import_node_fs19.existsSync)(absolutePath)) {
19467
18655
  throw new Error(`JSON file not found: ${absolutePath}`);
19468
18656
  }
19469
- const raw = (0, import_node_fs18.readFileSync)(absolutePath, "utf8");
18657
+ const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
19470
18658
  try {
19471
18659
  return JSON.parse(raw);
19472
18660
  } catch (error) {
@@ -19476,10 +18664,10 @@ var AppCommandHandler = class {
19476
18664
  }
19477
18665
  async preparePayload(filePath, appRef) {
19478
18666
  const absolutePath = this.resolveFilePath(filePath);
19479
- return prepareAppPayload(this.readJsonFile(filePath), import_node_path22.default.dirname(absolutePath), { appRef });
18667
+ return prepareAppPayload(this.readJsonFile(filePath), import_node_path24.default.dirname(absolutePath), { appRef });
19480
18668
  }
19481
18669
  resolveFilePath(filePath) {
19482
- return import_node_path22.default.resolve(process.cwd(), filePath);
18670
+ return import_node_path24.default.resolve(process.cwd(), filePath);
19483
18671
  }
19484
18672
  async request(baseUrl, token, method, pathname, body) {
19485
18673
  const response = await fetch(`${baseUrl}${pathname}`, {
@@ -19599,18 +18787,18 @@ function readNamespaceFromPayload(payload) {
19599
18787
  }
19600
18788
 
19601
18789
  // src/commands/ServiceCommandHandler.ts
19602
- var import_node_fs21 = require("fs");
18790
+ var import_node_fs22 = require("fs");
19603
18791
  var import_promises5 = require("fs/promises");
19604
- var import_node_path25 = __toESM(require("path"));
18792
+ var import_node_path27 = __toESM(require("path"));
19605
18793
  var import_node_child_process11 = require("child_process");
19606
18794
  var import_promises6 = require("readline/promises");
19607
18795
 
19608
18796
  // src/services/AndroidApkReleaseService.ts
19609
18797
  var import_node_child_process9 = require("child_process");
19610
18798
  var import_node_crypto4 = require("crypto");
19611
- var import_node_fs19 = require("fs");
19612
- var import_node_os8 = __toESM(require("os"));
19613
- var import_node_path23 = __toESM(require("path"));
18799
+ var import_node_fs20 = require("fs");
18800
+ var import_node_os9 = __toESM(require("os"));
18801
+ var import_node_path25 = __toESM(require("path"));
19614
18802
  var ANDROID_APK_BUCKET = "parrot-static";
19615
18803
  var ANDROID_APK_PUBLIC_BASE_URL = "https://parrot-static.pmate.chat";
19616
18804
  var AndroidApkReleaseService = class {
@@ -19644,7 +18832,7 @@ var AndroidApkReleaseService = class {
19644
18832
  }
19645
18833
  await AliyunService.uploadFile(apkPath, ANDROID_APK_BUCKET, objectKey);
19646
18834
  const sha256 = await sha256File(apkPath);
19647
- const size = (0, import_node_fs19.statSync)(apkPath).size;
18835
+ const size = (0, import_node_fs20.statSync)(apkPath).size;
19648
18836
  const artifact = {
19649
18837
  serviceId: service.id,
19650
18838
  env: options.env,
@@ -19682,7 +18870,7 @@ var AndroidApkReleaseService = class {
19682
18870
  const prefix = `apks/${service.namespace}/${service.name}`;
19683
18871
  const objects = await AliyunService.listObjects(ANDROID_APK_BUCKET, prefix);
19684
18872
  return objects.filter((item) => item.name.endsWith(".apk")).map((item) => {
19685
- const versionName = import_node_path23.default.basename(item.name, ".apk");
18873
+ const versionName = import_node_path25.default.basename(item.name, ".apk");
19686
18874
  return {
19687
18875
  serviceId,
19688
18876
  env: options.env ?? "unknown",
@@ -19705,7 +18893,7 @@ var AndroidApkReleaseService = class {
19705
18893
  }
19706
18894
  }
19707
18895
  resolveRepoRoot(service, cwd) {
19708
- if (cwd) return import_node_path23.default.resolve(process.cwd(), cwd);
18896
+ if (cwd) return import_node_path25.default.resolve(process.cwd(), cwd);
19709
18897
  const repository = this.getRepository(service);
19710
18898
  if (repository) {
19711
18899
  return resolveRepositoryLocalRoot(repository);
@@ -19717,8 +18905,8 @@ var AndroidApkReleaseService = class {
19717
18905
  if (!dir) {
19718
18906
  throw new Error(`Missing dir for android service ${service.id}`);
19719
18907
  }
19720
- const appDir = import_node_path23.default.resolve(repoRoot, dir);
19721
- if (!(0, import_node_fs19.existsSync)(appDir)) {
18908
+ const appDir = import_node_path25.default.resolve(repoRoot, dir);
18909
+ if (!(0, import_node_fs20.existsSync)(appDir)) {
19722
18910
  throw new Error(`Android app dir not found: ${appDir}`);
19723
18911
  }
19724
18912
  return appDir;
@@ -19734,11 +18922,11 @@ var AndroidApkReleaseService = class {
19734
18922
  return void 0;
19735
18923
  }
19736
18924
  async runGradleAssembleAndFindApk(repoRoot, appDir, variant) {
19737
- const gradlew = [import_node_path23.default.join(appDir, "gradlew"), import_node_path23.default.join(repoRoot, "gradlew")].find((candidate) => (0, import_node_fs19.existsSync)(candidate));
18925
+ const gradlew = [import_node_path25.default.join(appDir, "gradlew"), import_node_path25.default.join(repoRoot, "gradlew")].find((candidate) => (0, import_node_fs20.existsSync)(candidate));
19738
18926
  if (!gradlew) {
19739
18927
  throw new Error(`Gradle wrapper not found in ${appDir} or ${repoRoot}`);
19740
18928
  }
19741
- const gradleCwd = import_node_path23.default.dirname(gradlew);
18929
+ const gradleCwd = import_node_path25.default.dirname(gradlew);
19742
18930
  const normalizedVariant = variant.toLowerCase();
19743
18931
  const taskSuffix = `assemble${capitalize(normalizedVariant)}`;
19744
18932
  const tasks = [`:app:${taskSuffix}`, taskSuffix];
@@ -19806,7 +18994,7 @@ function resolveRepositoryLocalRoot(repository) {
19806
18994
  if (!repoName) {
19807
18995
  throw new Error(`Invalid repository: ${repository}`);
19808
18996
  }
19809
- return import_node_path23.default.join(import_node_os8.default.homedir(), "dev", "pmate", repoName);
18997
+ return import_node_path25.default.join(import_node_os9.default.homedir(), "dev", "pmate", repoName);
19810
18998
  }
19811
18999
  function bumpAndroidGradleVersionText(source, bump) {
19812
19000
  const versionNameMatch = source.match(/(^\s*versionName\s+["'])([^"']+)(["']\s*$)/m) ?? source.match(/(^\s*versionName\s*=\s*["'])([^"']+)(["']\s*$)/m);
@@ -19862,42 +19050,42 @@ function parseGradleOutputMetadata(source, apkFileName) {
19862
19050
  }
19863
19051
  function bumpAndroidProjectVersion(appDir, bump) {
19864
19052
  const candidates = [
19865
- import_node_path23.default.join(appDir, "app", "build.gradle.kts"),
19866
- import_node_path23.default.join(appDir, "app", "build.gradle"),
19867
- import_node_path23.default.join(appDir, "build.gradle.kts"),
19868
- import_node_path23.default.join(appDir, "build.gradle")
19053
+ import_node_path25.default.join(appDir, "app", "build.gradle.kts"),
19054
+ import_node_path25.default.join(appDir, "app", "build.gradle"),
19055
+ import_node_path25.default.join(appDir, "build.gradle.kts"),
19056
+ import_node_path25.default.join(appDir, "build.gradle")
19869
19057
  ];
19870
19058
  for (const candidate of candidates) {
19871
- if (!(0, import_node_fs19.existsSync)(candidate)) continue;
19872
- const result = bumpAndroidGradleVersionText((0, import_node_fs19.readFileSync)(candidate, "utf8"), bump);
19873
- (0, import_node_fs19.writeFileSync)(candidate, result.source);
19059
+ if (!(0, import_node_fs20.existsSync)(candidate)) continue;
19060
+ const result = bumpAndroidGradleVersionText((0, import_node_fs20.readFileSync)(candidate, "utf8"), bump);
19061
+ (0, import_node_fs20.writeFileSync)(candidate, result.source);
19874
19062
  return { filePath: candidate, ...result };
19875
19063
  }
19876
19064
  throw new Error(`No Android Gradle version file found under ${appDir}`);
19877
19065
  }
19878
19066
  function findLatestApk(repoRoot, appDir, variant) {
19879
19067
  const dirs = [
19880
- import_node_path23.default.join(appDir, "app", "build", "outputs", "apk", variant),
19881
- import_node_path23.default.join(appDir, "build", "outputs", "apk", variant),
19882
- import_node_path23.default.join(repoRoot, "app", "build", "outputs", "apk", variant)
19068
+ import_node_path25.default.join(appDir, "app", "build", "outputs", "apk", variant),
19069
+ import_node_path25.default.join(appDir, "build", "outputs", "apk", variant),
19070
+ import_node_path25.default.join(repoRoot, "app", "build", "outputs", "apk", variant)
19883
19071
  ];
19884
19072
  const files = dirs.flatMap((dir) => listApks(dir));
19885
19073
  if (files.length === 0) {
19886
19074
  throw new Error(`Cannot find APK output for variant ${variant}`);
19887
19075
  }
19888
- files.sort((a, b) => (0, import_node_fs19.statSync)(b).mtimeMs - (0, import_node_fs19.statSync)(a).mtimeMs);
19076
+ files.sort((a, b) => (0, import_node_fs20.statSync)(b).mtimeMs - (0, import_node_fs20.statSync)(a).mtimeMs);
19889
19077
  return files[0];
19890
19078
  }
19891
19079
  function readGradleOutputMetadata(apkPath) {
19892
- const metadataPath = import_node_path23.default.join(import_node_path23.default.dirname(apkPath), "output-metadata.json");
19893
- if (!(0, import_node_fs19.existsSync)(metadataPath)) {
19080
+ const metadataPath = import_node_path25.default.join(import_node_path25.default.dirname(apkPath), "output-metadata.json");
19081
+ if (!(0, import_node_fs20.existsSync)(metadataPath)) {
19894
19082
  throw new Error(`Gradle output metadata not found: ${metadataPath}`);
19895
19083
  }
19896
- return parseGradleOutputMetadata((0, import_node_fs19.readFileSync)(metadataPath, "utf8"), import_node_path23.default.basename(apkPath));
19084
+ return parseGradleOutputMetadata((0, import_node_fs20.readFileSync)(metadataPath, "utf8"), import_node_path25.default.basename(apkPath));
19897
19085
  }
19898
19086
  function listApks(dir) {
19899
- if (!(0, import_node_fs19.existsSync)(dir)) return [];
19900
- return (0, import_node_fs19.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) => import_node_path23.default.join(dir, entry)).filter((entry) => (0, import_node_fs19.statSync)(entry).isFile());
19087
+ if (!(0, import_node_fs20.existsSync)(dir)) return [];
19088
+ return (0, import_node_fs20.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) => import_node_path25.default.join(dir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isFile());
19901
19089
  }
19902
19090
  function runCommand(command, args, cwd) {
19903
19091
  return new Promise((resolve, reject) => {
@@ -19931,26 +19119,26 @@ async function runAndroidSdkToolCapture(toolName, args) {
19931
19119
  return runCommandCapture(toolPath, args);
19932
19120
  }
19933
19121
  function findAndroidSdkTool(toolName) {
19934
- const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) => import_node_path23.default.resolve(item));
19122
+ const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) => import_node_path25.default.resolve(item));
19935
19123
  for (const sdkRoot of sdkRoots) {
19936
- const candidates = toolName === "aapt" ? listVersionedToolCandidates(import_node_path23.default.join(sdkRoot, "build-tools"), toolName) : [
19937
- import_node_path23.default.join(sdkRoot, "cmdline-tools", "latest", "bin", toolName),
19938
- ...listVersionedToolCandidates(import_node_path23.default.join(sdkRoot, "cmdline-tools"), import_node_path23.default.join("bin", toolName)),
19939
- import_node_path23.default.join(sdkRoot, "tools", "bin", toolName)
19124
+ const candidates = toolName === "aapt" ? listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "build-tools"), toolName) : [
19125
+ import_node_path25.default.join(sdkRoot, "cmdline-tools", "latest", "bin", toolName),
19126
+ ...listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "cmdline-tools"), import_node_path25.default.join("bin", toolName)),
19127
+ import_node_path25.default.join(sdkRoot, "tools", "bin", toolName)
19940
19128
  ];
19941
- const match = candidates.find((candidate) => (0, import_node_fs19.existsSync)(candidate));
19129
+ const match = candidates.find((candidate) => (0, import_node_fs20.existsSync)(candidate));
19942
19130
  if (match) return match;
19943
19131
  }
19944
19132
  return void 0;
19945
19133
  }
19946
19134
  function listVersionedToolCandidates(parentDir, relativeToolPath) {
19947
- if (!(0, import_node_fs19.existsSync)(parentDir)) return [];
19948
- return (0, import_node_fs19.readdirSync)(parentDir).map((entry) => import_node_path23.default.join(parentDir, entry)).filter((entry) => (0, import_node_fs19.statSync)(entry).isDirectory()).sort((a, b) => import_node_path23.default.basename(b).localeCompare(import_node_path23.default.basename(a), void 0, { numeric: true })).map((entry) => import_node_path23.default.join(entry, relativeToolPath));
19135
+ if (!(0, import_node_fs20.existsSync)(parentDir)) return [];
19136
+ return (0, import_node_fs20.readdirSync)(parentDir).map((entry) => import_node_path25.default.join(parentDir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isDirectory()).sort((a, b) => import_node_path25.default.basename(b).localeCompare(import_node_path25.default.basename(a), void 0, { numeric: true })).map((entry) => import_node_path25.default.join(entry, relativeToolPath));
19949
19137
  }
19950
19138
  function sha256File(filePath) {
19951
19139
  return new Promise((resolve, reject) => {
19952
19140
  const hash = (0, import_node_crypto4.createHash)("sha256");
19953
- const stream = (0, import_node_fs19.createReadStream)(filePath);
19141
+ const stream = (0, import_node_fs20.createReadStream)(filePath);
19954
19142
  stream.on("data", (chunk) => hash.update(chunk));
19955
19143
  stream.on("error", reject);
19956
19144
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -19967,9 +19155,9 @@ function capitalize(value) {
19967
19155
  }
19968
19156
 
19969
19157
  // src/services/ServiceRuntimeRunner.ts
19970
- var import_node_fs20 = require("fs");
19971
- var import_node_os9 = __toESM(require("os"));
19972
- var import_node_path24 = __toESM(require("path"));
19158
+ var import_node_fs21 = require("fs");
19159
+ var import_node_os10 = __toESM(require("os"));
19160
+ var import_node_path26 = __toESM(require("path"));
19973
19161
  var import_node_child_process10 = require("child_process");
19974
19162
  var import_node_readline = require("readline");
19975
19163
  var import_chalk3 = __toESM(require("chalk"));
@@ -20142,8 +19330,7 @@ var ServiceRegistryClient = class {
20142
19330
  }
20143
19331
  readToken() {
20144
19332
  return readRequiredSession({
20145
- preferredApp: DEFAULT_APP_ID,
20146
- fallbackToActiveApp: true
19333
+ preferredApp: DEFAULT_APP_ID
20147
19334
  }).token;
20148
19335
  }
20149
19336
  async request(method, pathname) {
@@ -20433,14 +19620,14 @@ var ServiceRuntimeRunner = class {
20433
19620
  }
20434
19621
  resolveRepoRoot(service, cwd) {
20435
19622
  if (cwd) {
20436
- return import_node_path24.default.resolve(process.cwd(), cwd);
19623
+ return import_node_path26.default.resolve(process.cwd(), cwd);
20437
19624
  }
20438
19625
  const repository = this.getType(service) === "vite" || this.getType(service) === "static" ? this.getRepoStaticSite(service).repository.trim() : this.getType(service) === "fc" ? this.getFc(service).repository?.trim() : this.getType(service) === "ios" || this.getType(service) === "android" ? void 0 : this.getNetwork(service).repository?.trim();
20439
19626
  if (repository) {
20440
19627
  const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
20441
19628
  if (repoName) {
20442
- const candidate = import_node_path24.default.join(import_node_os9.default.homedir(), "dev", "pmate", repoName);
20443
- if ((0, import_node_fs20.existsSync)(candidate)) {
19629
+ const candidate = import_node_path26.default.join(import_node_os10.default.homedir(), "dev", "pmate", repoName);
19630
+ if ((0, import_node_fs21.existsSync)(candidate)) {
20444
19631
  return candidate;
20445
19632
  }
20446
19633
  }
@@ -20453,13 +19640,13 @@ var ServiceRuntimeRunner = class {
20453
19640
  if (!dir) {
20454
19641
  throw new Error(`Missing service dir for ${service.id}`);
20455
19642
  }
20456
- return import_node_path24.default.resolve(repoRoot, dir);
19643
+ return import_node_path26.default.resolve(repoRoot, dir);
20457
19644
  }
20458
19645
  async deployVite(service, options) {
20459
19646
  this.assertDeployableStaticSite(service);
20460
19647
  const appDir = this.resolveLocalDir(service, options.cwd);
20461
- const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
20462
- if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
19648
+ const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
19649
+ if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20463
19650
  throw new Error(`No package.json found at ${packageJsonPath}`);
20464
19651
  }
20465
19652
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -20474,8 +19661,8 @@ var ServiceRuntimeRunner = class {
20474
19661
  this.resolveRepoRoot(service, options.cwd),
20475
19662
  buildEnv
20476
19663
  );
20477
- const distDir = import_node_path24.default.join(appDir, "dist");
20478
- if (!(0, import_node_fs20.existsSync)(distDir)) {
19664
+ const distDir = import_node_path26.default.join(appDir, "dist");
19665
+ if (!(0, import_node_fs21.existsSync)(distDir)) {
20479
19666
  throw new Error(`No dist directory found at ${distDir}`);
20480
19667
  }
20481
19668
  const site = this.getSite(service);
@@ -20488,8 +19675,8 @@ var ServiceRuntimeRunner = class {
20488
19675
  async deployStatic(service, options) {
20489
19676
  this.assertDeployableStaticSite(service);
20490
19677
  const appDir = this.resolveLocalDir(service, options.cwd);
20491
- const srcDir = import_node_path24.default.join(appDir, "src");
20492
- if (!(0, import_node_fs20.existsSync)(srcDir)) {
19678
+ const srcDir = import_node_path26.default.join(appDir, "src");
19679
+ if (!(0, import_node_fs21.existsSync)(srcDir)) {
20493
19680
  throw new Error(`No src directory found at ${srcDir}`);
20494
19681
  }
20495
19682
  const site = this.getSite(service);
@@ -20523,8 +19710,8 @@ var ServiceRuntimeRunner = class {
20523
19710
  this.validateFcConfig(service, fc);
20524
19711
  const repoRoot = this.resolveRepoRoot(service);
20525
19712
  const appDir = this.resolveLocalDir(service);
20526
- const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
20527
- if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
19713
+ const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
19714
+ if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20528
19715
  throw new Error(`No package.json found at ${packageJsonPath}`);
20529
19716
  }
20530
19717
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -20577,15 +19764,15 @@ var ServiceRuntimeRunner = class {
20577
19764
  const repoRoot = this.resolveRepoRoot(service, options.cwd);
20578
19765
  const appDir = this.resolveLocalDir(service, options.cwd);
20579
19766
  await this.ensurePnpmWorkspaceRoot(repoRoot);
20580
- const configPath = import_node_path24.default.join(appDir, fc.configFile ?? "s.yaml");
20581
- if (!(0, import_node_fs20.existsSync)(configPath)) {
19767
+ const configPath = import_node_path26.default.join(appDir, fc.configFile ?? "s.yaml");
19768
+ if (!(0, import_node_fs21.existsSync)(configPath)) {
20582
19769
  throw new Error(`Missing FC config file at ${configPath}`);
20583
19770
  }
20584
- const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
20585
- if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
19771
+ const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
19772
+ if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20586
19773
  throw new Error(`No package.json found at ${packageJsonPath}`);
20587
19774
  }
20588
- const rawConfig = (0, import_node_fs20.readFileSync)(configPath, "utf8");
19775
+ const rawConfig = (0, import_node_fs21.readFileSync)(configPath, "utf8");
20589
19776
  if (!rawConfig.includes(fc.functionName)) {
20590
19777
  throw new Error(`FC config ${configPath} does not mention functionName ${fc.functionName}`);
20591
19778
  }
@@ -20863,7 +20050,7 @@ var ServiceRuntimeRunner = class {
20863
20050
  const serverAddress = await resolveServerAddress(server);
20864
20051
  const templateName = exposeType === "websocket" ? "nginx.ws.template" : "nginx.rest.template";
20865
20052
  const templatePath = this.resolveTemplatePath(templateName);
20866
- const template = (0, import_node_fs20.readFileSync)(templatePath, "utf8");
20053
+ const template = (0, import_node_fs21.readFileSync)(templatePath, "utf8");
20867
20054
  const host = `${subdomain}.${("domain" in network ? network.domain?.trim() : void 0) || "pmate.chat"}`;
20868
20055
  const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
20869
20056
  const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
@@ -20895,11 +20082,11 @@ var ServiceRuntimeRunner = class {
20895
20082
  }
20896
20083
  if (config.ensurePackageJson) {
20897
20084
  const appDir = this.resolveLocalDir(service, options.cwd);
20898
- const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
20899
- if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
20085
+ const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
20086
+ if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20900
20087
  throw new Error(`Missing package.json at ${packageJsonPath}`);
20901
20088
  }
20902
- const pkgStat = (0, import_node_fs20.statSync)(packageJsonPath);
20089
+ const pkgStat = (0, import_node_fs21.statSync)(packageJsonPath);
20903
20090
  if (!pkgStat.isFile()) {
20904
20091
  throw new Error(`package.json is not a file at ${packageJsonPath}`);
20905
20092
  }
@@ -21328,9 +20515,9 @@ var ServiceRuntimeRunner = class {
21328
20515
  return tokens;
21329
20516
  }
21330
20517
  readPathValue(source, pathExpr) {
21331
- const path29 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
20518
+ const path31 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
21332
20519
  let cursor = source;
21333
- for (const segment of path29) {
20520
+ for (const segment of path31) {
21334
20521
  if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
21335
20522
  return void 0;
21336
20523
  }
@@ -21373,12 +20560,12 @@ var ServiceRuntimeRunner = class {
21373
20560
  }
21374
20561
  resolveTemplatePath(templateName) {
21375
20562
  const candidates = [
21376
- import_node_path24.default.join(__dirname, "..", "templates", templateName),
21377
- import_node_path24.default.join(__dirname, "..", "src", "templates", templateName),
21378
- import_node_path24.default.join(__dirname, "templates", templateName)
20563
+ import_node_path26.default.join(__dirname, "..", "templates", templateName),
20564
+ import_node_path26.default.join(__dirname, "..", "src", "templates", templateName),
20565
+ import_node_path26.default.join(__dirname, "templates", templateName)
21379
20566
  ];
21380
20567
  for (const candidate of candidates) {
21381
- if ((0, import_node_fs20.existsSync)(candidate)) {
20568
+ if ((0, import_node_fs21.existsSync)(candidate)) {
21382
20569
  return candidate;
21383
20570
  }
21384
20571
  }
@@ -21410,7 +20597,7 @@ var ServiceRuntimeRunner = class {
21410
20597
  });
21411
20598
  }
21412
20599
  loadPackageJson(packageJsonPath) {
21413
- const raw = (0, import_node_fs20.readFileSync)(packageJsonPath, "utf8");
20600
+ const raw = (0, import_node_fs21.readFileSync)(packageJsonPath, "utf8");
21414
20601
  const parsed = JSON.parse(raw);
21415
20602
  if (!parsed || typeof parsed !== "object") {
21416
20603
  throw new Error(`Invalid package.json at ${packageJsonPath}`);
@@ -21419,7 +20606,7 @@ var ServiceRuntimeRunner = class {
21419
20606
  }
21420
20607
  writePackageJson(packageJsonPath, data) {
21421
20608
  const serialized = JSON.stringify(data, null, 2);
21422
- (0, import_node_fs20.writeFileSync)(packageJsonPath, `${serialized}
20609
+ (0, import_node_fs21.writeFileSync)(packageJsonPath, `${serialized}
21423
20610
  `, "utf8");
21424
20611
  }
21425
20612
  validateFcConfig(service, fc) {
@@ -21446,8 +20633,8 @@ var ServiceRuntimeRunner = class {
21446
20633
  }
21447
20634
  }
21448
20635
  async ensurePnpmWorkspaceRoot(repoRoot) {
21449
- const workspacePath = import_node_path24.default.join(repoRoot, "pnpm-workspace.yaml");
21450
- if (!(0, import_node_fs20.existsSync)(workspacePath)) {
20636
+ const workspacePath = import_node_path26.default.join(repoRoot, "pnpm-workspace.yaml");
20637
+ if (!(0, import_node_fs21.existsSync)(workspacePath)) {
21451
20638
  throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
21452
20639
  }
21453
20640
  }
@@ -21521,16 +20708,16 @@ var ServiceRuntimeRunner = class {
21521
20708
  if (!privateKeyPath) {
21522
20709
  throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
21523
20710
  }
21524
- if (!(0, import_node_fs20.existsSync)(certificatePath)) {
20711
+ if (!(0, import_node_fs21.existsSync)(certificatePath)) {
21525
20712
  throw new Error(`SSL certificate file not found: ${certificatePath}`);
21526
20713
  }
21527
- if (!(0, import_node_fs20.existsSync)(privateKeyPath)) {
20714
+ if (!(0, import_node_fs21.existsSync)(privateKeyPath)) {
21528
20715
  throw new Error(`SSL private key file not found: ${privateKeyPath}`);
21529
20716
  }
21530
20717
  return {
21531
20718
  certName: host,
21532
- certificate: (0, import_node_fs20.readFileSync)(certificatePath, "utf8"),
21533
- privateKey: (0, import_node_fs20.readFileSync)(privateKeyPath, "utf8")
20719
+ certificate: (0, import_node_fs21.readFileSync)(certificatePath, "utf8"),
20720
+ privateKey: (0, import_node_fs21.readFileSync)(privateKeyPath, "utf8")
21534
20721
  };
21535
20722
  }
21536
20723
  resolveFcProtocol(fc, certConfig) {
@@ -21987,7 +21174,7 @@ var ServiceCommandHandler = class {
21987
21174
  format: "dotenv"
21988
21175
  }
21989
21176
  );
21990
- const outputPath = import_node_path25.default.resolve(process.cwd(), args.output);
21177
+ const outputPath = import_node_path27.default.resolve(process.cwd(), args.output);
21991
21178
  await (0, import_promises5.writeFile)(outputPath, payload.content, "utf8");
21992
21179
  ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
21993
21180
  this.renderJson({ ...payload, output: outputPath }, args.json);
@@ -22213,11 +21400,11 @@ var ServiceCommandHandler = class {
22213
21400
  return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
22214
21401
  }
22215
21402
  readJsonFile(filePath) {
22216
- const absolutePath = import_node_path25.default.resolve(process.cwd(), filePath);
22217
- if (!(0, import_node_fs21.existsSync)(absolutePath)) {
21403
+ const absolutePath = import_node_path27.default.resolve(process.cwd(), filePath);
21404
+ if (!(0, import_node_fs22.existsSync)(absolutePath)) {
22218
21405
  throw new Error(`JSON file not found: ${absolutePath}`);
22219
21406
  }
22220
- const raw = (0, import_node_fs21.readFileSync)(absolutePath, "utf8");
21407
+ const raw = (0, import_node_fs22.readFileSync)(absolutePath, "utf8");
22221
21408
  try {
22222
21409
  return JSON.parse(raw);
22223
21410
  } catch (error) {
@@ -22977,8 +22164,7 @@ var RoleCommandHandler = class {
22977
22164
  }
22978
22165
  readToken() {
22979
22166
  return readRequiredSession({
22980
- preferredApp: DEFAULT_APP_ID,
22981
- fallbackToActiveApp: true
22167
+ preferredApp: DEFAULT_APP_ID
22982
22168
  }).token;
22983
22169
  }
22984
22170
  async request(baseUrl, token, method, pathname, body) {
@@ -23026,9 +22212,9 @@ var RoleCommandHandler = class {
23026
22212
  };
23027
22213
 
23028
22214
  // src/commands/AccountCommandHandler.ts
23029
- var import_node_fs22 = require("fs");
22215
+ var import_node_fs23 = require("fs");
23030
22216
  var import_node_crypto5 = require("crypto");
23031
- var import_node_path26 = __toESM(require("path"));
22217
+ var import_node_path28 = __toESM(require("path"));
23032
22218
  init_sessionStore();
23033
22219
  var AccountCommandHandler = class {
23034
22220
  async handle(args) {
@@ -23036,9 +22222,9 @@ var AccountCommandHandler = class {
23036
22222
  case "bot-keygen": {
23037
22223
  const keyFile = this.generateBotKeyFile(args.app, args.name);
23038
22224
  const outPath = args.out ? this.resolveFilePath(args.out) : this.resolveDefaultBotKeyPath(args.app, args.name);
23039
- (0, import_node_fs22.mkdirSync)(import_node_path26.default.dirname(outPath), { recursive: true });
23040
- (0, import_node_fs22.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
23041
- (0, import_node_fs22.chmodSync)(outPath, 384);
22225
+ (0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
22226
+ (0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
22227
+ (0, import_node_fs23.chmodSync)(outPath, 384);
23042
22228
  if (!args.json) {
23043
22229
  ui.success(`Bot key saved to ${outPath}`);
23044
22230
  }
@@ -23404,8 +22590,7 @@ var AccountCommandHandler = class {
23404
22590
  }
23405
22591
  readToken() {
23406
22592
  return readRequiredSession({
23407
- preferredApp: DEFAULT_APP_ID,
23408
- fallbackToActiveApp: true
22593
+ preferredApp: DEFAULT_APP_ID
23409
22594
  }).token;
23410
22595
  }
23411
22596
  buildAccountViewQuery(args) {
@@ -23576,10 +22761,10 @@ var AccountCommandHandler = class {
23576
22761
  throw new Error("Missing visible apps input");
23577
22762
  }
23578
22763
  const absolutePath = this.resolveFilePath(args.filePath);
23579
- if (!(0, import_node_fs22.existsSync)(absolutePath)) {
22764
+ if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23580
22765
  throw new Error(`JSON file not found: ${absolutePath}`);
23581
22766
  }
23582
- const raw = (0, import_node_fs22.readFileSync)(absolutePath, "utf8");
22767
+ const raw = (0, import_node_fs23.readFileSync)(absolutePath, "utf8");
23583
22768
  let parsed;
23584
22769
  try {
23585
22770
  parsed = JSON.parse(raw);
@@ -23593,13 +22778,13 @@ var AccountCommandHandler = class {
23593
22778
  return parsed;
23594
22779
  }
23595
22780
  resolveFilePath(filePath) {
23596
- return import_node_path26.default.resolve(process.cwd(), filePath);
22781
+ return import_node_path28.default.resolve(process.cwd(), filePath);
23597
22782
  }
23598
22783
  resolveDefaultBotKeyPath(app, name) {
23599
- return import_node_path26.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
22784
+ return import_node_path28.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
23600
22785
  }
23601
22786
  resolveDefaultAccessKeyPath(app, name) {
23602
- return import_node_path26.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
22787
+ return import_node_path28.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
23603
22788
  }
23604
22789
  homeDir() {
23605
22790
  return process.env.HOME || process.env.USERPROFILE || process.cwd();
@@ -23622,10 +22807,10 @@ var AccountCommandHandler = class {
23622
22807
  throw new Error("Missing bot key file");
23623
22808
  }
23624
22809
  const absolutePath = this.resolveFilePath(filePath);
23625
- if (!(0, import_node_fs22.existsSync)(absolutePath)) {
22810
+ if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23626
22811
  throw new Error(`Bot key file not found: ${absolutePath}`);
23627
22812
  }
23628
- const parsed = JSON.parse((0, import_node_fs22.readFileSync)(absolutePath, "utf8"));
22813
+ const parsed = JSON.parse((0, import_node_fs23.readFileSync)(absolutePath, "utf8"));
23629
22814
  if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
23630
22815
  throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
23631
22816
  }
@@ -23642,10 +22827,10 @@ var AccountCommandHandler = class {
23642
22827
  throw new Error("Missing access key file");
23643
22828
  }
23644
22829
  const absolutePath = this.resolveFilePath(filePath);
23645
- if (!(0, import_node_fs22.existsSync)(absolutePath)) {
22830
+ if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23646
22831
  throw new Error(`Access key file not found: ${absolutePath}`);
23647
22832
  }
23648
- const parsed = JSON.parse((0, import_node_fs22.readFileSync)(absolutePath, "utf8"));
22833
+ const parsed = JSON.parse((0, import_node_fs23.readFileSync)(absolutePath, "utf8"));
23649
22834
  if (parsed.type !== "pmate-access-key" || parsed.version !== 1 || !parsed.id || !parsed.app || !parsed.secret || !parsed.expiresAt) {
23650
22835
  throw new Error(`Invalid PMate access key file: ${absolutePath}`);
23651
22836
  }
@@ -23667,9 +22852,9 @@ var AccountCommandHandler = class {
23667
22852
  createdAt: result.key.createdAt
23668
22853
  };
23669
22854
  const outPath = out ? this.resolveFilePath(out) : this.resolveDefaultAccessKeyPath(result.key.app, result.key.name);
23670
- (0, import_node_fs22.mkdirSync)(import_node_path26.default.dirname(outPath), { recursive: true });
23671
- (0, import_node_fs22.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
23672
- (0, import_node_fs22.chmodSync)(outPath, 384);
22855
+ (0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
22856
+ (0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
22857
+ (0, import_node_fs23.chmodSync)(outPath, 384);
23673
22858
  }
23674
22859
  renderAccessKeyCreateResult(result, asJson, out) {
23675
22860
  if (asJson) {
@@ -23709,16 +22894,12 @@ var AccountCommandHandler = class {
23709
22894
  }
23710
22895
  }
23711
22896
  async resolveLoginProfileId(login, app, authApiBaseUrl) {
23712
- try {
23713
- return await fetchDefaultProfileId({
23714
- token: login.token,
23715
- app,
23716
- accountId: login.session.identity.accountId,
23717
- authApiBaseUrl
23718
- });
23719
- } catch {
23720
- return login.session.identity.accessKeyId ?? login.session.identity.accountId;
23721
- }
22897
+ return await fetchDefaultProfileId({
22898
+ token: login.token,
22899
+ app,
22900
+ accountId: login.session.identity.accountId,
22901
+ authApiBaseUrl
22902
+ });
23722
22903
  }
23723
22904
  signBotChallenge(challenge, privateKey) {
23724
22905
  const key = (0, import_node_crypto5.createPrivateKey)({
@@ -23760,8 +22941,8 @@ function encodePathSegment2(value) {
23760
22941
  }
23761
22942
 
23762
22943
  // src/commands/OrgCommandHandler.ts
23763
- var import_node_fs23 = require("fs");
23764
- var import_node_path27 = __toESM(require("path"));
22944
+ var import_node_fs24 = require("fs");
22945
+ var import_node_path29 = __toESM(require("path"));
23765
22946
  init_sessionStore();
23766
22947
  var OrgCommandHandler = class {
23767
22948
  async handle(args) {
@@ -23921,8 +23102,7 @@ var OrgCommandHandler = class {
23921
23102
  }
23922
23103
  readToken() {
23923
23104
  return readRequiredSession({
23924
- preferredApp: DEFAULT_APP_ID,
23925
- fallbackToActiveApp: true
23105
+ preferredApp: DEFAULT_APP_ID
23926
23106
  }).token;
23927
23107
  }
23928
23108
  resolveStringArrayInput(values, filePath, itemLabel) {
@@ -23932,11 +23112,11 @@ var OrgCommandHandler = class {
23932
23112
  if (!filePath) {
23933
23113
  throw new Error(`Missing ${itemLabel} input`);
23934
23114
  }
23935
- const absolutePath = import_node_path27.default.resolve(process.cwd(), filePath);
23936
- if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23115
+ const absolutePath = import_node_path29.default.resolve(process.cwd(), filePath);
23116
+ if (!(0, import_node_fs24.existsSync)(absolutePath)) {
23937
23117
  throw new Error(`JSON file not found: ${absolutePath}`);
23938
23118
  }
23939
- const raw = (0, import_node_fs23.readFileSync)(absolutePath, "utf8");
23119
+ const raw = (0, import_node_fs24.readFileSync)(absolutePath, "utf8");
23940
23120
  let parsed;
23941
23121
  try {
23942
23122
  parsed = JSON.parse(raw);
@@ -27332,7 +26512,7 @@ function requireValue12(tokens, option) {
27332
26512
 
27333
26513
  // src/index.ts
27334
26514
  var pkg = JSON.parse(
27335
- (0, import_node_fs24.readFileSync)(import_node_path28.default.resolve(__dirname, "..", "package.json"), "utf8")
26515
+ (0, import_node_fs25.readFileSync)(import_node_path30.default.resolve(__dirname, "..", "package.json"), "utf8")
27336
26516
  );
27337
26517
  var HELP_TEXT = [
27338
26518
  import_chalk4.default.bold(`pmate v${pkg.version}`),
@@ -27348,7 +26528,8 @@ var HELP_TEXT = [
27348
26528
  import_chalk4.default.bold("Commands:"),
27349
26529
  ` ${import_chalk4.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
27350
26530
  ` ${import_chalk4.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
27351
- ` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>]")}`,
26531
+ ` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>] [--select-profile]")}`,
26532
+ ` ${import_chalk4.default.gray(" [--access-key [secret] | --access-key-file <path>]")}`,
27352
26533
  ` ${import_chalk4.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
27353
26534
  ` ${import_chalk4.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
27354
26535
  ` ${import_chalk4.default.cyan("sts")} Request an OSS STS token from the CI server`,
@@ -27581,6 +26762,10 @@ function parseCommandArgs(args) {
27581
26762
  const rest = args.rest.slice(1);
27582
26763
  let app;
27583
26764
  let profileId;
26765
+ let accessKey;
26766
+ let accessKeyFile;
26767
+ let accessKeyScan = false;
26768
+ let selectProfile = false;
27584
26769
  while (rest.length > 0) {
27585
26770
  const token = rest.shift();
27586
26771
  switch (token) {
@@ -27590,11 +26775,30 @@ function parseCommandArgs(args) {
27590
26775
  case "--profile-id":
27591
26776
  profileId = requireValue13(rest, token);
27592
26777
  break;
26778
+ case "--access-key":
26779
+ if (rest[0] && !rest[0].startsWith("--")) {
26780
+ accessKey = rest.shift();
26781
+ } else {
26782
+ accessKeyScan = true;
26783
+ }
26784
+ break;
26785
+ case "--access-key-file":
26786
+ accessKeyFile = requireValue13(rest, token);
26787
+ break;
26788
+ case "--select-profile":
26789
+ selectProfile = true;
26790
+ break;
27593
26791
  default:
27594
26792
  throw new Error(`Unknown login option: ${token}`);
27595
26793
  }
27596
26794
  }
27597
- return { type: "login" /* Login */, app, profileId };
26795
+ if (accessKey && accessKeyFile) {
26796
+ throw new Error("--access-key and --access-key-file are mutually exclusive");
26797
+ }
26798
+ if (accessKeyScan && accessKeyFile) {
26799
+ throw new Error("--access-key and --access-key-file are mutually exclusive");
26800
+ }
26801
+ return { type: "login" /* Login */, app, profileId, accessKey, accessKeyFile, accessKeyScan, selectProfile };
27598
26802
  }
27599
26803
  if (args.rest[0] === "add-dns") {
27600
26804
  return parseAddDnsArgs(args.rest.slice(1));