@pmate/cli 0.24.33 → 0.24.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +843 -1017
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -293,150 +293,160 @@ var init_sessionStore = __esm({
293
293
  }
294
294
  });
295
295
 
296
- // node_modules/@pmate/meta/src/types/account.types.ts
296
+ // node_modules/.pnpm/@pmate+meta@1.1.15/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.15/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.15/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.15/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.15/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.15/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.15/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.15/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.15/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.15/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/blockchain.types.ts
331
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/runner-registry.types.ts
332
+ var init_runner_registry_types = __esm({
333
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
334
+ "use strict";
335
+ }
336
+ });
337
+
338
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/blockchain.types.ts
332
339
  var init_blockchain_types = __esm({
333
- "node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
340
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
334
341
  "use strict";
335
342
  }
336
343
  });
337
344
 
338
- // node_modules/@pmate/meta/src/types/breakdown.types.ts
345
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/breakdown.types.ts
339
346
  var init_breakdown_types = __esm({
340
- "node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
347
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
341
348
  "use strict";
342
349
  }
343
350
  });
344
351
 
345
- // node_modules/@pmate/meta/src/types/chat.types.ts
352
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/chat.types.ts
346
353
  var init_chat_types = __esm({
347
- "node_modules/@pmate/meta/src/types/chat.types.ts"() {
354
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/chat.types.ts"() {
348
355
  "use strict";
349
356
  }
350
357
  });
351
358
 
352
- // node_modules/@pmate/meta/src/types/companion.types.ts
359
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/companion.types.ts
353
360
  var init_companion_types = __esm({
354
- "node_modules/@pmate/meta/src/types/companion.types.ts"() {
361
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/companion.types.ts"() {
355
362
  "use strict";
356
363
  }
357
364
  });
358
365
 
359
- // node_modules/@pmate/meta/src/types/enums.ts
366
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/enums.ts
360
367
  var init_enums = __esm({
361
- "node_modules/@pmate/meta/src/types/enums.ts"() {
368
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/enums.ts"() {
362
369
  "use strict";
363
370
  }
364
371
  });
365
372
 
366
- // node_modules/@pmate/meta/src/types/lang.types.ts
373
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/lang.types.ts
367
374
  var init_lang_types = __esm({
368
- "node_modules/@pmate/meta/src/types/lang.types.ts"() {
375
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/lang.types.ts"() {
369
376
  "use strict";
370
377
  }
371
378
  });
372
379
 
373
- // node_modules/@pmate/meta/src/types/logs.types.ts
380
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/logs.types.ts
374
381
  var init_logs_types = __esm({
375
- "node_modules/@pmate/meta/src/types/logs.types.ts"() {
382
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/logs.types.ts"() {
376
383
  "use strict";
377
384
  }
378
385
  });
379
386
 
380
- // node_modules/@pmate/meta/src/types/message.types.ts
387
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/message.types.ts
388
+ var PING, PONG;
381
389
  var init_message_types = __esm({
382
- "node_modules/@pmate/meta/src/types/message.types.ts"() {
390
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/message.types.ts"() {
383
391
  "use strict";
392
+ PING = 1;
393
+ PONG = 2;
384
394
  }
385
395
  });
386
396
 
387
- // node_modules/@pmate/meta/src/types/newLog.types.ts
397
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/newLog.types.ts
388
398
  var init_newLog_types = __esm({
389
- "node_modules/@pmate/meta/src/types/newLog.types.ts"() {
399
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
390
400
  "use strict";
391
401
  }
392
402
  });
393
403
 
394
- // node_modules/@pmate/meta/src/types/novel.types.ts
404
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/novel.types.ts
395
405
  var init_novel_types = __esm({
396
- "node_modules/@pmate/meta/src/types/novel.types.ts"() {
406
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/novel.types.ts"() {
397
407
  "use strict";
398
408
  }
399
409
  });
400
410
 
401
- // node_modules/@pmate/meta/src/types/offline.types.ts
411
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/offline.types.ts
402
412
  var init_offline_types = __esm({
403
- "node_modules/@pmate/meta/src/types/offline.types.ts"() {
413
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/offline.types.ts"() {
404
414
  "use strict";
405
415
  }
406
416
  });
407
417
 
408
- // node_modules/@pmate/meta/src/types/prompt.types.ts
418
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/prompt.types.ts
409
419
  var init_prompt_types = __esm({
410
- "node_modules/@pmate/meta/src/types/prompt.types.ts"() {
420
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
411
421
  "use strict";
412
422
  }
413
423
  });
414
424
 
415
- // node_modules/@pmate/meta/src/types/reading.types.ts
425
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/reading.types.ts
416
426
  var init_reading_types = __esm({
417
- "node_modules/@pmate/meta/src/types/reading.types.ts"() {
427
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/reading.types.ts"() {
418
428
  "use strict";
419
429
  }
420
430
  });
421
431
 
422
- // node_modules/@pmate/meta/src/types/settings.types.ts
432
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/settings.types.ts
423
433
  var init_settings_types = __esm({
424
- "node_modules/@pmate/meta/src/types/settings.types.ts"() {
434
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/settings.types.ts"() {
425
435
  "use strict";
426
436
  }
427
437
  });
428
438
 
429
- // node_modules/@pmate/meta/src/types/subscription.types.ts
439
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/subscription.types.ts
430
440
  var init_subscription_types = __esm({
431
- "node_modules/@pmate/meta/src/types/subscription.types.ts"() {
441
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
432
442
  "use strict";
433
443
  }
434
444
  });
435
445
 
436
- // node_modules/@pmate/meta/src/types/types.ts
446
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/types.ts
437
447
  var buildVoiceKey, createVoice;
438
448
  var init_types = __esm({
439
- "node_modules/@pmate/meta/src/types/types.ts"() {
449
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/types.ts"() {
440
450
  "use strict";
441
451
  buildVoiceKey = (provider, name) => {
442
452
  return `${provider}:${name}`;
@@ -458,50 +468,51 @@ var init_types = __esm({
458
468
  }
459
469
  });
460
470
 
461
- // node_modules/@pmate/meta/src/types/wordv5.def.ts
471
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/wordv5.def.ts
462
472
  var init_wordv5_def = __esm({
463
- "node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
473
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
464
474
  "use strict";
465
475
  }
466
476
  });
467
477
 
468
- // node_modules/@pmate/meta/src/types/auth.types.ts
478
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/auth.types.ts
469
479
  var init_auth_types = __esm({
470
- "node_modules/@pmate/meta/src/types/auth.types.ts"() {
480
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/auth.types.ts"() {
471
481
  "use strict";
472
482
  }
473
483
  });
474
484
 
475
- // node_modules/@pmate/meta/src/types/apps.types.ts
485
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/apps.types.ts
476
486
  var init_apps_types = __esm({
477
- "node_modules/@pmate/meta/src/types/apps.types.ts"() {
487
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/apps.types.ts"() {
478
488
  "use strict";
479
489
  }
480
490
  });
481
491
 
482
- // node_modules/@pmate/meta/src/types/response.types.ts
492
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/response.types.ts
483
493
  var init_response_types = __esm({
484
- "node_modules/@pmate/meta/src/types/response.types.ts"() {
494
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/response.types.ts"() {
485
495
  "use strict";
486
496
  }
487
497
  });
488
498
 
489
- // node_modules/@pmate/meta/src/types/role.types.ts
499
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/role.types.ts
490
500
  var init_role_types = __esm({
491
- "node_modules/@pmate/meta/src/types/role.types.ts"() {
501
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/role.types.ts"() {
492
502
  "use strict";
493
503
  }
494
504
  });
495
505
 
496
- // node_modules/@pmate/meta/src/types/index.ts
506
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/index.ts
497
507
  var init_types2 = __esm({
498
- "node_modules/@pmate/meta/src/types/index.ts"() {
508
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/index.ts"() {
499
509
  "use strict";
500
510
  init_account_types();
501
511
  init_achievements_types();
502
512
  init_aigen_types();
503
513
  init_agent_types();
504
514
  init_agent_registry_types();
515
+ init_runner_registry_types();
505
516
  init_blockchain_types();
506
517
  init_breakdown_types();
507
518
  init_chat_types();
@@ -526,24 +537,24 @@ var init_types2 = __esm({
526
537
  }
527
538
  });
528
539
 
529
- // node_modules/@pmate/meta/src/config/BizErrorCode.ts
540
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/BizErrorCode.ts
530
541
  var init_BizErrorCode = __esm({
531
- "node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
542
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
532
543
  "use strict";
533
544
  }
534
545
  });
535
546
 
536
- // node_modules/@pmate/meta/src/config/consts.ts
547
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/consts.ts
537
548
  var init_consts = __esm({
538
- "node_modules/@pmate/meta/src/config/consts.ts"() {
549
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/consts.ts"() {
539
550
  "use strict";
540
551
  }
541
552
  });
542
553
 
543
- // node_modules/@pmate/meta/src/config/TopicNames.ts
554
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/TopicNames.ts
544
555
  var TopicNames, topicKindMatchers;
545
556
  var init_TopicNames = __esm({
546
- "node_modules/@pmate/meta/src/config/TopicNames.ts"() {
557
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
547
558
  "use strict";
548
559
  init_types2();
549
560
  TopicNames = class _TopicNames {
@@ -629,18 +640,18 @@ var init_TopicNames = __esm({
629
640
  }
630
641
  });
631
642
 
632
- // node_modules/@pmate/meta/src/config/OSSKeys.ts
643
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/OSSKeys.ts
633
644
  var init_OSSKeys = __esm({
634
- "node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
645
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
635
646
  "use strict";
636
647
  init_consts();
637
648
  }
638
649
  });
639
650
 
640
- // node_modules/@pmate/meta/src/config/CompanionProfiles.ts
651
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
641
652
  var openAICoral, openAIAsh, openAIBallad, openAINova, openAIVerse;
642
653
  var init_CompanionProfiles = __esm({
643
- "node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
654
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
644
655
  "use strict";
645
656
  init_types2();
646
657
  openAICoral = createVoice({
@@ -675,9 +686,9 @@ var init_CompanionProfiles = __esm({
675
686
  }
676
687
  });
677
688
 
678
- // node_modules/@pmate/meta/src/config/index.ts
689
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/index.ts
679
690
  var init_config = __esm({
680
- "node_modules/@pmate/meta/src/config/index.ts"() {
691
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/index.ts"() {
681
692
  "use strict";
682
693
  init_BizErrorCode();
683
694
  init_consts();
@@ -687,83 +698,83 @@ var init_config = __esm({
687
698
  }
688
699
  });
689
700
 
690
- // node_modules/@pmate/meta/src/index.ts
701
+ // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/index.ts
691
702
  var init_src = __esm({
692
- "node_modules/@pmate/meta/src/index.ts"() {
703
+ "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/index.ts"() {
693
704
  "use strict";
694
705
  init_types2();
695
706
  init_config();
696
707
  }
697
708
  });
698
709
 
699
- // node_modules/@pmate/utils/src/base64.ts
710
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/base64.ts
700
711
  var init_base64 = __esm({
701
- "node_modules/@pmate/utils/src/base64.ts"() {
712
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/base64.ts"() {
702
713
  "use strict";
703
714
  }
704
715
  });
705
716
 
706
- // node_modules/@pmate/utils/src/Cache.ts
717
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Cache.ts
707
718
  var init_Cache = __esm({
708
- "node_modules/@pmate/utils/src/Cache.ts"() {
719
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Cache.ts"() {
709
720
  "use strict";
710
721
  }
711
722
  });
712
723
 
713
- // node_modules/@pmate/utils/src/batchResolve.ts
724
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/batchResolve.ts
714
725
  var init_batchResolve = __esm({
715
- "node_modules/@pmate/utils/src/batchResolve.ts"() {
726
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/batchResolve.ts"() {
716
727
  "use strict";
717
728
  init_Cache();
718
729
  }
719
730
  });
720
731
 
721
- // 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
722
733
  var init_sentenceSpliter = __esm({
723
- "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"() {
724
735
  "use strict";
725
736
  }
726
737
  });
727
738
 
728
- // 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
729
740
  var init_sentenceTrim = __esm({
730
- "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"() {
731
742
  "use strict";
732
743
  }
733
744
  });
734
745
 
735
- // 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
736
747
  var init_wordSpliter = __esm({
737
- "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"() {
738
749
  "use strict";
739
750
  }
740
751
  });
741
752
 
742
- // 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
743
754
  var init_regex = __esm({
744
- "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"() {
745
756
  "use strict";
746
757
  }
747
758
  });
748
759
 
749
- // 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
750
761
  var init_sentenceSpliter2 = __esm({
751
- "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"() {
752
763
  "use strict";
753
764
  }
754
765
  });
755
766
 
756
- // 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
757
768
  var init_sentenceTrim2 = __esm({
758
- "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"() {
759
770
  "use strict";
760
771
  }
761
772
  });
762
773
 
763
- // 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
764
775
  var regex;
765
776
  var init_wordSpliter2 = __esm({
766
- "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"() {
767
778
  "use strict";
768
779
  regex = new RegExp(
769
780
  [
@@ -799,23 +810,23 @@ var init_wordSpliter2 = __esm({
799
810
  }
800
811
  });
801
812
 
802
- // 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
803
814
  var init_sentenceSpliter3 = __esm({
804
- "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"() {
805
816
  "use strict";
806
817
  }
807
818
  });
808
819
 
809
- // 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
810
821
  var init_wordSpliter3 = __esm({
811
- "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"() {
812
823
  "use strict";
813
824
  }
814
825
  });
815
826
 
816
- // node_modules/@pmate/lang/src/readingSettings.ts
827
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/readingSettings.ts
817
828
  var init_readingSettings = __esm({
818
- "node_modules/@pmate/lang/src/readingSettings.ts"() {
829
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/readingSettings.ts"() {
819
830
  "use strict";
820
831
  init_sentenceSpliter();
821
832
  init_wordSpliter();
@@ -826,17 +837,17 @@ var init_readingSettings = __esm({
826
837
  }
827
838
  });
828
839
 
829
- // node_modules/@pmate/lang/src/utils.ts
840
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/utils.ts
830
841
  var init_utils = __esm({
831
- "node_modules/@pmate/lang/src/utils.ts"() {
842
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/utils.ts"() {
832
843
  "use strict";
833
844
  init_src();
834
845
  }
835
846
  });
836
847
 
837
- // node_modules/@pmate/lang/src/index.ts
848
+ // node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/index.ts
838
849
  var init_src2 = __esm({
839
- "node_modules/@pmate/lang/src/index.ts"() {
850
+ "node_modules/.pnpm/@pmate+lang@1.0.4/node_modules/@pmate/lang/src/index.ts"() {
840
851
  "use strict";
841
852
  init_sentenceSpliter();
842
853
  init_sentenceTrim();
@@ -852,32 +863,32 @@ var init_src2 = __esm({
852
863
  }
853
864
  });
854
865
 
855
- // node_modules/@pmate/utils/src/bookStats.ts
866
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/bookStats.ts
856
867
  var init_bookStats = __esm({
857
- "node_modules/@pmate/utils/src/bookStats.ts"() {
868
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/bookStats.ts"() {
858
869
  "use strict";
859
870
  init_src2();
860
871
  }
861
872
  });
862
873
 
863
- // node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts
874
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts
864
875
  var init_BoundedConcurrentQueue = __esm({
865
- "node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts"() {
876
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/BoundedConcurrentQueue.ts"() {
866
877
  "use strict";
867
878
  }
868
879
  });
869
880
 
870
- // node_modules/@pmate/utils/src/lru.ts
881
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/lru.ts
871
882
  var init_lru = __esm({
872
- "node_modules/@pmate/utils/src/lru.ts"() {
883
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/lru.ts"() {
873
884
  "use strict";
874
885
  init_Cache();
875
886
  }
876
887
  });
877
888
 
878
- // node_modules/js-sha3/src/sha3.js
889
+ // node_modules/.pnpm/js-sha3@0.9.3/node_modules/js-sha3/src/sha3.js
879
890
  var require_sha3 = __commonJS({
880
- "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) {
881
892
  "use strict";
882
893
  (function() {
883
894
  "use strict";
@@ -1522,24 +1533,24 @@ var require_sha3 = __commonJS({
1522
1533
  }
1523
1534
  });
1524
1535
 
1525
- // node_modules/@pmate/utils/src/Maybe.ts
1536
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Maybe.ts
1526
1537
  var init_Maybe = __esm({
1527
- "node_modules/@pmate/utils/src/Maybe.ts"() {
1538
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Maybe.ts"() {
1528
1539
  "use strict";
1529
1540
  }
1530
1541
  });
1531
1542
 
1532
- // node_modules/@pmate/utils/src/cacheMethodInMem.ts
1543
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/cacheMethodInMem.ts
1533
1544
  var import_js_sha3;
1534
1545
  var init_cacheMethodInMem = __esm({
1535
- "node_modules/@pmate/utils/src/cacheMethodInMem.ts"() {
1546
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/cacheMethodInMem.ts"() {
1536
1547
  "use strict";
1537
1548
  import_js_sha3 = __toESM(require_sha3(), 1);
1538
1549
  init_Maybe();
1539
1550
  }
1540
1551
  });
1541
1552
 
1542
- // node_modules/pako/dist/pako.esm.mjs
1553
+ // node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs
1543
1554
  function zero$1(buf) {
1544
1555
  let len = buf.length;
1545
1556
  while (--len >= 0) {
@@ -1827,7 +1838,7 @@ function inflateRaw$1(input, options) {
1827
1838
  }
1828
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;
1829
1840
  var init_pako_esm = __esm({
1830
- "node_modules/pako/dist/pako.esm.mjs"() {
1841
+ "node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs"() {
1831
1842
  "use strict";
1832
1843
  Z_FIXED$1 = 4;
1833
1844
  Z_BINARY = 0;
@@ -5708,7 +5719,7 @@ var init_pako_esm = __esm({
5708
5719
  }
5709
5720
  });
5710
5721
 
5711
- // node_modules/@pmate/utils/src/compress.ts
5722
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/compress.ts
5712
5723
  async function gzipEncodeBlob(input) {
5713
5724
  const array = await toUint8Array(input);
5714
5725
  return gzip_1(array);
@@ -5734,16 +5745,16 @@ async function toUint8Array(input) {
5734
5745
  throw new TypeError("Unsupported input type for gzipEncodeBlob");
5735
5746
  }
5736
5747
  var init_compress = __esm({
5737
- "node_modules/@pmate/utils/src/compress.ts"() {
5748
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/compress.ts"() {
5738
5749
  "use strict";
5739
5750
  init_pako_esm();
5740
5751
  }
5741
5752
  });
5742
5753
 
5743
- // node_modules/@pmate/utils/src/AsyncStream.ts
5754
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/AsyncStream.ts
5744
5755
  var AsyncStream;
5745
5756
  var init_AsyncStream = __esm({
5746
- "node_modules/@pmate/utils/src/AsyncStream.ts"() {
5757
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/AsyncStream.ts"() {
5747
5758
  "use strict";
5748
5759
  AsyncStream = class _AsyncStream {
5749
5760
  constructor() {
@@ -5931,709 +5942,303 @@ var init_AsyncStream = __esm({
5931
5942
  }
5932
5943
  });
5933
5944
 
5934
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/account.types.ts
5935
- var init_account_types2 = __esm({
5936
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/account.types.ts"() {
5937
- "use strict";
5938
- }
5939
- });
5940
-
5941
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/achievements.types.ts
5942
- var init_achievements_types2 = __esm({
5943
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
5944
- "use strict";
5945
- }
5946
- });
5947
-
5948
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/aigen.types.ts
5949
- var init_aigen_types2 = __esm({
5950
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
5951
- "use strict";
5952
- }
5953
- });
5954
-
5955
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent.types.ts
5956
- var init_agent_types2 = __esm({
5957
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent.types.ts"() {
5945
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/uniqHash.ts
5946
+ var import_js_sha32, sortKeys, uniqHash;
5947
+ var init_uniqHash = __esm({
5948
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/uniqHash.ts"() {
5958
5949
  "use strict";
5950
+ init_src();
5951
+ import_js_sha32 = __toESM(require_sha3(), 1);
5952
+ sortKeys = (obj) => {
5953
+ if (Array.isArray(obj)) {
5954
+ return obj.map(sortKeys);
5955
+ }
5956
+ if (obj && typeof obj === "object") {
5957
+ return Object.keys(obj).sort().reduce((sortedObj, key) => {
5958
+ sortedObj[key] = sortKeys(obj[key]);
5959
+ return sortedObj;
5960
+ }, {});
5961
+ }
5962
+ return obj;
5963
+ };
5964
+ uniqHash = (input, type) => {
5965
+ let str;
5966
+ if (typeof input === "object") {
5967
+ const sortedObject = sortKeys(input);
5968
+ str = JSON.stringify(sortedObject);
5969
+ } else {
5970
+ str = input;
5971
+ }
5972
+ str = str.replace(/\s+/g, "").replace(/[\n\r\t]+/g, "").toLowerCase();
5973
+ return (0, import_js_sha32.keccak256)(str + "@" + type);
5974
+ };
5959
5975
  }
5960
5976
  });
5961
5977
 
5962
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent-registry.types.ts
5963
- var init_agent_registry_types2 = __esm({
5964
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
5978
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/createMsg.ts
5979
+ var init_createMsg = __esm({
5980
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/createMsg.ts"() {
5965
5981
  "use strict";
5982
+ init_src();
5983
+ init_uniqHash();
5966
5984
  }
5967
5985
  });
5968
5986
 
5969
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/blockchain.types.ts
5970
- var init_blockchain_types2 = __esm({
5971
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
5987
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/detectText.ts
5988
+ var init_detectText = __esm({
5989
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/detectText.ts"() {
5972
5990
  "use strict";
5973
5991
  }
5974
5992
  });
5975
5993
 
5976
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/breakdown.types.ts
5977
- var init_breakdown_types2 = __esm({
5978
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
5994
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Emitter.ts
5995
+ var init_Emitter = __esm({
5996
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Emitter.ts"() {
5979
5997
  "use strict";
5980
5998
  }
5981
5999
  });
5982
6000
 
5983
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/chat.types.ts
5984
- var init_chat_types2 = __esm({
5985
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/chat.types.ts"() {
6001
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/EmitterV2.ts
6002
+ var EmitterV2;
6003
+ var init_EmitterV2 = __esm({
6004
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/EmitterV2.ts"() {
5986
6005
  "use strict";
6006
+ EmitterV2 = class {
6007
+ constructor() {
6008
+ this.topics = /* @__PURE__ */ new Map();
6009
+ this.allHandlers = [];
6010
+ }
6011
+ getTopic(topic) {
6012
+ if (!this.topics.get(topic)) {
6013
+ this.topics.set(topic, []);
6014
+ }
6015
+ return this.topics.get(topic);
6016
+ }
6017
+ on(topic, handler) {
6018
+ const handlers = this.getTopic(topic);
6019
+ handlers.push(handler);
6020
+ return () => {
6021
+ this.topics.set(
6022
+ topic,
6023
+ this.getTopic(topic).filter((x) => x !== handler)
6024
+ );
6025
+ };
6026
+ }
6027
+ onAll(handler) {
6028
+ this.allHandlers.push(handler);
6029
+ return () => {
6030
+ this.allHandlers = this.allHandlers.filter((x) => x !== handler);
6031
+ };
6032
+ }
6033
+ emit(topic, ...args) {
6034
+ const hasBody = args.length > 0;
6035
+ const body = args[0];
6036
+ this.getTopic(topic).forEach((h) => {
6037
+ if (hasBody) {
6038
+ h(body);
6039
+ return;
6040
+ }
6041
+ h();
6042
+ });
6043
+ const msg = hasBody ? { topic, body } : { topic };
6044
+ this.allHandlers.forEach((h) => {
6045
+ h(msg);
6046
+ });
6047
+ }
6048
+ clearListeners(topic) {
6049
+ if (typeof topic !== "undefined") {
6050
+ this.topics.delete(topic);
6051
+ return;
6052
+ }
6053
+ this.topics.clear();
6054
+ this.allHandlers = [];
6055
+ }
6056
+ };
5987
6057
  }
5988
6058
  });
5989
6059
 
5990
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/companion.types.ts
5991
- var init_companion_types2 = __esm({
5992
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/companion.types.ts"() {
6060
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/formatTime.ts
6061
+ var init_formatTime = __esm({
6062
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/formatTime.ts"() {
5993
6063
  "use strict";
5994
6064
  }
5995
6065
  });
5996
6066
 
5997
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/enums.ts
5998
- var init_enums2 = __esm({
5999
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/enums.ts"() {
6067
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/index.ts
6068
+ var init_format = __esm({
6069
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/format/index.ts"() {
6000
6070
  "use strict";
6071
+ init_formatTime();
6001
6072
  }
6002
6073
  });
6003
6074
 
6004
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/lang.types.ts
6005
- var init_lang_types2 = __esm({
6006
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/lang.types.ts"() {
6075
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/isVolcabulary.ts
6076
+ var init_isVolcabulary = __esm({
6077
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/isVolcabulary.ts"() {
6007
6078
  "use strict";
6008
6079
  }
6009
6080
  });
6010
6081
 
6011
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/logs.types.ts
6012
- var init_logs_types2 = __esm({
6013
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/logs.types.ts"() {
6082
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Loadable.ts
6083
+ var init_Loadable = __esm({
6084
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Loadable.ts"() {
6014
6085
  "use strict";
6015
6086
  }
6016
6087
  });
6017
6088
 
6018
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/message.types.ts
6019
- var PING, PONG;
6020
- var init_message_types2 = __esm({
6021
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/message.types.ts"() {
6089
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Logger.ts
6090
+ var Logger;
6091
+ var init_Logger = __esm({
6092
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Logger.ts"() {
6022
6093
  "use strict";
6023
- PING = 1;
6024
- PONG = 2;
6094
+ Logger = class _Logger {
6095
+ constructor(name) {
6096
+ this.name = name;
6097
+ }
6098
+ log(...args) {
6099
+ const color = "blue";
6100
+ const css = `color: ${color}; font-weight: bold;`;
6101
+ const header = `%c[${this.name}]`;
6102
+ console.debug(header, css, ...args);
6103
+ }
6104
+ error(...args) {
6105
+ const color = "red";
6106
+ const css = `color: ${color}; font-weight: bold;`;
6107
+ const header = `%c[${this.name}]`;
6108
+ console.error(header, css, ...args);
6109
+ }
6110
+ static getDebugger(name) {
6111
+ return new _Logger(name);
6112
+ }
6113
+ };
6025
6114
  }
6026
6115
  });
6027
6116
 
6028
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/newLog.types.ts
6029
- var init_newLog_types2 = __esm({
6030
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
6117
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/mapToReadingBook.ts
6118
+ var init_mapToReadingBook = __esm({
6119
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/mapToReadingBook.ts"() {
6031
6120
  "use strict";
6032
6121
  }
6033
6122
  });
6034
6123
 
6035
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/novel.types.ts
6036
- var init_novel_types2 = __esm({
6037
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/novel.types.ts"() {
6124
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/memoize.ts
6125
+ var init_memoize = __esm({
6126
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/memoize.ts"() {
6038
6127
  "use strict";
6039
6128
  }
6040
6129
  });
6041
6130
 
6042
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/offline.types.ts
6043
- var init_offline_types2 = __esm({
6044
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/offline.types.ts"() {
6045
- "use strict";
6131
+ // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
6132
+ function utf8Count(str) {
6133
+ const strLength = str.length;
6134
+ let byteLength = 0;
6135
+ let pos = 0;
6136
+ while (pos < strLength) {
6137
+ let value = str.charCodeAt(pos++);
6138
+ if ((value & 4294967168) === 0) {
6139
+ byteLength++;
6140
+ continue;
6141
+ } else if ((value & 4294965248) === 0) {
6142
+ byteLength += 2;
6143
+ } else {
6144
+ if (value >= 55296 && value <= 56319) {
6145
+ if (pos < strLength) {
6146
+ const extra = str.charCodeAt(pos);
6147
+ if ((extra & 64512) === 56320) {
6148
+ ++pos;
6149
+ value = ((value & 1023) << 10) + (extra & 1023) + 65536;
6150
+ }
6151
+ }
6152
+ }
6153
+ if ((value & 4294901760) === 0) {
6154
+ byteLength += 3;
6155
+ } else {
6156
+ byteLength += 4;
6157
+ }
6158
+ }
6046
6159
  }
6047
- });
6048
-
6049
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/prompt.types.ts
6050
- var init_prompt_types2 = __esm({
6051
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
6052
- "use strict";
6160
+ return byteLength;
6161
+ }
6162
+ function utf8EncodeJs(str, output, outputOffset) {
6163
+ const strLength = str.length;
6164
+ let offset = outputOffset;
6165
+ let pos = 0;
6166
+ while (pos < strLength) {
6167
+ let value = str.charCodeAt(pos++);
6168
+ if ((value & 4294967168) === 0) {
6169
+ output[offset++] = value;
6170
+ continue;
6171
+ } else if ((value & 4294965248) === 0) {
6172
+ output[offset++] = value >> 6 & 31 | 192;
6173
+ } else {
6174
+ if (value >= 55296 && value <= 56319) {
6175
+ if (pos < strLength) {
6176
+ const extra = str.charCodeAt(pos);
6177
+ if ((extra & 64512) === 56320) {
6178
+ ++pos;
6179
+ value = ((value & 1023) << 10) + (extra & 1023) + 65536;
6180
+ }
6181
+ }
6182
+ }
6183
+ if ((value & 4294901760) === 0) {
6184
+ output[offset++] = value >> 12 & 15 | 224;
6185
+ output[offset++] = value >> 6 & 63 | 128;
6186
+ } else {
6187
+ output[offset++] = value >> 18 & 7 | 240;
6188
+ output[offset++] = value >> 12 & 63 | 128;
6189
+ output[offset++] = value >> 6 & 63 | 128;
6190
+ }
6191
+ }
6192
+ output[offset++] = value & 63 | 128;
6053
6193
  }
6054
- });
6055
-
6056
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/reading.types.ts
6057
- var init_reading_types2 = __esm({
6058
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/reading.types.ts"() {
6059
- "use strict";
6194
+ }
6195
+ function utf8EncodeTE(str, output, outputOffset) {
6196
+ sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
6197
+ }
6198
+ function utf8Encode(str, output, outputOffset) {
6199
+ if (str.length > TEXT_ENCODER_THRESHOLD) {
6200
+ utf8EncodeTE(str, output, outputOffset);
6201
+ } else {
6202
+ utf8EncodeJs(str, output, outputOffset);
6060
6203
  }
6061
- });
6062
-
6063
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/settings.types.ts
6064
- var init_settings_types2 = __esm({
6065
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/settings.types.ts"() {
6066
- "use strict";
6204
+ }
6205
+ function utf8DecodeJs(bytes, inputOffset, byteLength) {
6206
+ let offset = inputOffset;
6207
+ const end = offset + byteLength;
6208
+ const units = [];
6209
+ let result = "";
6210
+ while (offset < end) {
6211
+ const byte1 = bytes[offset++];
6212
+ if ((byte1 & 128) === 0) {
6213
+ units.push(byte1);
6214
+ } else if ((byte1 & 224) === 192) {
6215
+ const byte2 = bytes[offset++] & 63;
6216
+ units.push((byte1 & 31) << 6 | byte2);
6217
+ } else if ((byte1 & 240) === 224) {
6218
+ const byte2 = bytes[offset++] & 63;
6219
+ const byte3 = bytes[offset++] & 63;
6220
+ units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
6221
+ } else if ((byte1 & 248) === 240) {
6222
+ const byte2 = bytes[offset++] & 63;
6223
+ const byte3 = bytes[offset++] & 63;
6224
+ const byte4 = bytes[offset++] & 63;
6225
+ let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
6226
+ if (unit > 65535) {
6227
+ unit -= 65536;
6228
+ units.push(unit >>> 10 & 1023 | 55296);
6229
+ unit = 56320 | unit & 1023;
6230
+ }
6231
+ units.push(unit);
6232
+ } else {
6233
+ units.push(byte1);
6234
+ }
6235
+ if (units.length >= CHUNK_SIZE) {
6236
+ result += String.fromCharCode(...units);
6237
+ units.length = 0;
6238
+ }
6067
6239
  }
6068
- });
6069
-
6070
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/subscription.types.ts
6071
- var init_subscription_types2 = __esm({
6072
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
6073
- "use strict";
6074
- }
6075
- });
6076
-
6077
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/types.ts
6078
- var buildVoiceKey2, createVoice2;
6079
- var init_types3 = __esm({
6080
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/types.ts"() {
6081
- "use strict";
6082
- buildVoiceKey2 = (provider, name) => {
6083
- return `${provider}:${name}`;
6084
- };
6085
- createVoice2 = ({
6086
- name,
6087
- provider,
6088
- gender,
6089
- instructions
6090
- }) => {
6091
- return {
6092
- name,
6093
- provider,
6094
- gender,
6095
- instructions,
6096
- key: buildVoiceKey2(provider, name)
6097
- };
6098
- };
6099
- }
6100
- });
6101
-
6102
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/wordv5.def.ts
6103
- var init_wordv5_def2 = __esm({
6104
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
6105
- "use strict";
6106
- }
6107
- });
6108
-
6109
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/auth.types.ts
6110
- var init_auth_types2 = __esm({
6111
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/auth.types.ts"() {
6112
- "use strict";
6113
- }
6114
- });
6115
-
6116
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/apps.types.ts
6117
- var init_apps_types2 = __esm({
6118
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/apps.types.ts"() {
6119
- "use strict";
6120
- }
6121
- });
6122
-
6123
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/response.types.ts
6124
- var init_response_types2 = __esm({
6125
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/response.types.ts"() {
6126
- "use strict";
6127
- }
6128
- });
6129
-
6130
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/role.types.ts
6131
- var init_role_types2 = __esm({
6132
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/role.types.ts"() {
6133
- "use strict";
6134
- }
6135
- });
6136
-
6137
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/index.ts
6138
- var init_types4 = __esm({
6139
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/index.ts"() {
6140
- "use strict";
6141
- init_account_types2();
6142
- init_achievements_types2();
6143
- init_aigen_types2();
6144
- init_agent_types2();
6145
- init_agent_registry_types2();
6146
- init_blockchain_types2();
6147
- init_breakdown_types2();
6148
- init_chat_types2();
6149
- init_companion_types2();
6150
- init_enums2();
6151
- init_lang_types2();
6152
- init_logs_types2();
6153
- init_message_types2();
6154
- init_newLog_types2();
6155
- init_novel_types2();
6156
- init_offline_types2();
6157
- init_prompt_types2();
6158
- init_reading_types2();
6159
- init_settings_types2();
6160
- init_subscription_types2();
6161
- init_types3();
6162
- init_wordv5_def2();
6163
- init_auth_types2();
6164
- init_apps_types2();
6165
- init_response_types2();
6166
- init_role_types2();
6167
- }
6168
- });
6169
-
6170
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/BizErrorCode.ts
6171
- var init_BizErrorCode2 = __esm({
6172
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
6173
- "use strict";
6174
- }
6175
- });
6176
-
6177
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/consts.ts
6178
- var init_consts2 = __esm({
6179
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/consts.ts"() {
6180
- "use strict";
6181
- }
6182
- });
6183
-
6184
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/TopicNames.ts
6185
- var TopicNames2, topicKindMatchers2;
6186
- var init_TopicNames2 = __esm({
6187
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
6188
- "use strict";
6189
- init_types4();
6190
- TopicNames2 = class _TopicNames {
6191
- static rooms() {
6192
- return "@pmate/rooms";
6193
- }
6194
- static userThreads(user) {
6195
- return `@pmate/user_threads:${user}`;
6196
- }
6197
- static userLogs(user) {
6198
- return `@pmate/user_logs:${user}`;
6199
- }
6200
- static legacyUserLogs(user) {
6201
- return _TopicNames.userLogs(user);
6202
- }
6203
- static userContacts(profileId) {
6204
- return `@pmate/user_contacts:${profileId}`;
6205
- }
6206
- static usersMessage(userId) {
6207
- return `@pmate/user_messages:${userId}`;
6208
- }
6209
- static userMapping() {
6210
- return "@pmate/username_mapping";
6211
- }
6212
- static userMobileMapping() {
6213
- return "@pmate/mobile_account";
6214
- }
6215
- static mapping() {
6216
- return "@pmate/mapping";
6217
- }
6218
- static profiles() {
6219
- return "@pmate/profiles";
6220
- }
6221
- static groups() {
6222
- return "@pmate/groups";
6223
- }
6224
- static relationships() {
6225
- return "@pmate/relationships";
6226
- }
6227
- };
6228
- topicKindMatchers2 = [
6229
- {
6230
- kind: 1e3 /* UserLogs */,
6231
- match: (topic) => topic.startsWith("@pmate/user_logs:")
6232
- },
6233
- {
6234
- kind: 2e3 /* UserMessages */,
6235
- match: (topic) => topic.startsWith("@pmate/user_messages:")
6236
- },
6237
- {
6238
- kind: 3e3 /* Relationships */,
6239
- match: (topic) => topic === TopicNames2.relationships()
6240
- },
6241
- {
6242
- kind: 4e3 /* Rooms */,
6243
- match: (topic) => topic === TopicNames2.rooms()
6244
- },
6245
- {
6246
- kind: 5e3 /* UserContacts */,
6247
- match: (topic) => topic.startsWith("@pmate/user_contacts:")
6248
- },
6249
- {
6250
- kind: 8002 /* Entity_GROUP */,
6251
- match: (topic) => topic === TopicNames2.groups()
6252
- },
6253
- {
6254
- kind: 6e3 /* UserMapping */,
6255
- match: (topic) => topic === TopicNames2.userMapping()
6256
- },
6257
- {
6258
- kind: 7e3 /* UserMobileMapping */,
6259
- match: (topic) => topic === TopicNames2.userMobileMapping()
6260
- },
6261
- {
6262
- kind: 6003 /* Mapping */,
6263
- match: (topic) => topic === TopicNames2.mapping()
6264
- },
6265
- {
6266
- kind: 9e3 /* UserThreads */,
6267
- match: (topic) => topic.startsWith("@pmate/user_threads:")
6268
- }
6269
- ];
6270
- }
6271
- });
6272
-
6273
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/OSSKeys.ts
6274
- var init_OSSKeys2 = __esm({
6275
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
6276
- "use strict";
6277
- init_consts2();
6278
- }
6279
- });
6280
-
6281
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
6282
- var openAICoral2, openAIAsh2, openAIBallad2, openAINova2, openAIVerse2;
6283
- var init_CompanionProfiles2 = __esm({
6284
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
6285
- "use strict";
6286
- init_types4();
6287
- openAICoral2 = createVoice2({
6288
- name: "coral",
6289
- provider: "openai",
6290
- gender: "F",
6291
- instructions: "sweet, cute,naive voice"
6292
- });
6293
- openAIAsh2 = createVoice2({
6294
- name: "ash",
6295
- provider: "openai",
6296
- gender: "M"
6297
- });
6298
- openAIBallad2 = createVoice2({
6299
- name: "ballad",
6300
- provider: "openai",
6301
- gender: "M",
6302
- instructions: "bright, young man voice"
6303
- });
6304
- openAINova2 = createVoice2({
6305
- name: "nova",
6306
- provider: "openai",
6307
- gender: "F",
6308
- instructions: "mature, smooth, elegant, warm voice"
6309
- });
6310
- openAIVerse2 = createVoice2({
6311
- name: "verse",
6312
- provider: "openai",
6313
- gender: "M",
6314
- instructions: "elderly,mysterious wizzard voice"
6315
- });
6316
- }
6317
- });
6318
-
6319
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/index.ts
6320
- var init_config2 = __esm({
6321
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/index.ts"() {
6322
- "use strict";
6323
- init_BizErrorCode2();
6324
- init_consts2();
6325
- init_TopicNames2();
6326
- init_OSSKeys2();
6327
- init_CompanionProfiles2();
6328
- }
6329
- });
6330
-
6331
- // node_modules/@pmate/utils/node_modules/@pmate/meta/src/index.ts
6332
- var init_src3 = __esm({
6333
- "node_modules/@pmate/utils/node_modules/@pmate/meta/src/index.ts"() {
6334
- "use strict";
6335
- init_types4();
6336
- init_config2();
6337
- }
6338
- });
6339
-
6340
- // node_modules/@pmate/utils/src/uniqHash.ts
6341
- var import_js_sha32, sortKeys, uniqHash;
6342
- var init_uniqHash = __esm({
6343
- "node_modules/@pmate/utils/src/uniqHash.ts"() {
6344
- "use strict";
6345
- init_src3();
6346
- import_js_sha32 = __toESM(require_sha3(), 1);
6347
- sortKeys = (obj) => {
6348
- if (Array.isArray(obj)) {
6349
- return obj.map(sortKeys);
6350
- }
6351
- if (obj && typeof obj === "object") {
6352
- return Object.keys(obj).sort().reduce((sortedObj, key) => {
6353
- sortedObj[key] = sortKeys(obj[key]);
6354
- return sortedObj;
6355
- }, {});
6356
- }
6357
- return obj;
6358
- };
6359
- uniqHash = (input, type) => {
6360
- let str;
6361
- if (typeof input === "object") {
6362
- const sortedObject = sortKeys(input);
6363
- str = JSON.stringify(sortedObject);
6364
- } else {
6365
- str = input;
6366
- }
6367
- str = str.replace(/\s+/g, "").replace(/[\n\r\t]+/g, "").toLowerCase();
6368
- return (0, import_js_sha32.keccak256)(str + "@" + type);
6369
- };
6370
- }
6371
- });
6372
-
6373
- // node_modules/@pmate/utils/src/createMsg.ts
6374
- var init_createMsg = __esm({
6375
- "node_modules/@pmate/utils/src/createMsg.ts"() {
6376
- "use strict";
6377
- init_src3();
6378
- init_uniqHash();
6379
- }
6380
- });
6381
-
6382
- // node_modules/@pmate/utils/src/detectText.ts
6383
- var init_detectText = __esm({
6384
- "node_modules/@pmate/utils/src/detectText.ts"() {
6385
- "use strict";
6386
- }
6387
- });
6388
-
6389
- // node_modules/@pmate/utils/src/Emitter.ts
6390
- var init_Emitter = __esm({
6391
- "node_modules/@pmate/utils/src/Emitter.ts"() {
6392
- "use strict";
6393
- }
6394
- });
6395
-
6396
- // node_modules/@pmate/utils/src/EmitterV2.ts
6397
- var EmitterV2;
6398
- var init_EmitterV2 = __esm({
6399
- "node_modules/@pmate/utils/src/EmitterV2.ts"() {
6400
- "use strict";
6401
- EmitterV2 = class {
6402
- constructor() {
6403
- this.topics = /* @__PURE__ */ new Map();
6404
- this.allHandlers = [];
6405
- }
6406
- getTopic(topic) {
6407
- if (!this.topics.get(topic)) {
6408
- this.topics.set(topic, []);
6409
- }
6410
- return this.topics.get(topic);
6411
- }
6412
- on(topic, handler) {
6413
- const handlers = this.getTopic(topic);
6414
- handlers.push(handler);
6415
- return () => {
6416
- this.topics.set(
6417
- topic,
6418
- this.getTopic(topic).filter((x) => x !== handler)
6419
- );
6420
- };
6421
- }
6422
- onAll(handler) {
6423
- this.allHandlers.push(handler);
6424
- return () => {
6425
- this.allHandlers = this.allHandlers.filter((x) => x !== handler);
6426
- };
6427
- }
6428
- emit(topic, ...args) {
6429
- const hasBody = args.length > 0;
6430
- const body = args[0];
6431
- this.getTopic(topic).forEach((h) => {
6432
- if (hasBody) {
6433
- h(body);
6434
- return;
6435
- }
6436
- h();
6437
- });
6438
- const msg = hasBody ? { topic, body } : { topic };
6439
- this.allHandlers.forEach((h) => {
6440
- h(msg);
6441
- });
6442
- }
6443
- clearListeners(topic) {
6444
- if (typeof topic !== "undefined") {
6445
- this.topics.delete(topic);
6446
- return;
6447
- }
6448
- this.topics.clear();
6449
- this.allHandlers = [];
6450
- }
6451
- };
6452
- }
6453
- });
6454
-
6455
- // node_modules/@pmate/utils/src/format/formatTime.ts
6456
- var init_formatTime = __esm({
6457
- "node_modules/@pmate/utils/src/format/formatTime.ts"() {
6458
- "use strict";
6459
- }
6460
- });
6461
-
6462
- // node_modules/@pmate/utils/src/format/index.ts
6463
- var init_format = __esm({
6464
- "node_modules/@pmate/utils/src/format/index.ts"() {
6465
- "use strict";
6466
- init_formatTime();
6467
- }
6468
- });
6469
-
6470
- // node_modules/@pmate/utils/src/isVolcabulary.ts
6471
- var init_isVolcabulary = __esm({
6472
- "node_modules/@pmate/utils/src/isVolcabulary.ts"() {
6473
- "use strict";
6474
- }
6475
- });
6476
-
6477
- // node_modules/@pmate/utils/src/Loadable.ts
6478
- var init_Loadable = __esm({
6479
- "node_modules/@pmate/utils/src/Loadable.ts"() {
6480
- "use strict";
6481
- }
6482
- });
6483
-
6484
- // node_modules/@pmate/utils/src/Logger.ts
6485
- var Logger;
6486
- var init_Logger = __esm({
6487
- "node_modules/@pmate/utils/src/Logger.ts"() {
6488
- "use strict";
6489
- Logger = class _Logger {
6490
- constructor(name) {
6491
- this.name = name;
6492
- }
6493
- log(...args) {
6494
- const color = "blue";
6495
- const css = `color: ${color}; font-weight: bold;`;
6496
- const header = `%c[${this.name}]`;
6497
- console.debug(header, css, ...args);
6498
- }
6499
- error(...args) {
6500
- const color = "red";
6501
- const css = `color: ${color}; font-weight: bold;`;
6502
- const header = `%c[${this.name}]`;
6503
- console.error(header, css, ...args);
6504
- }
6505
- static getDebugger(name) {
6506
- return new _Logger(name);
6507
- }
6508
- };
6509
- }
6510
- });
6511
-
6512
- // node_modules/@pmate/utils/src/mapToReadingBook.ts
6513
- var init_mapToReadingBook = __esm({
6514
- "node_modules/@pmate/utils/src/mapToReadingBook.ts"() {
6515
- "use strict";
6516
- }
6517
- });
6518
-
6519
- // node_modules/@pmate/utils/src/memoize.ts
6520
- var init_memoize = __esm({
6521
- "node_modules/@pmate/utils/src/memoize.ts"() {
6522
- "use strict";
6523
- }
6524
- });
6525
-
6526
- // node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
6527
- function utf8Count(str) {
6528
- const strLength = str.length;
6529
- let byteLength = 0;
6530
- let pos = 0;
6531
- while (pos < strLength) {
6532
- let value = str.charCodeAt(pos++);
6533
- if ((value & 4294967168) === 0) {
6534
- byteLength++;
6535
- continue;
6536
- } else if ((value & 4294965248) === 0) {
6537
- byteLength += 2;
6538
- } else {
6539
- if (value >= 55296 && value <= 56319) {
6540
- if (pos < strLength) {
6541
- const extra = str.charCodeAt(pos);
6542
- if ((extra & 64512) === 56320) {
6543
- ++pos;
6544
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
6545
- }
6546
- }
6547
- }
6548
- if ((value & 4294901760) === 0) {
6549
- byteLength += 3;
6550
- } else {
6551
- byteLength += 4;
6552
- }
6553
- }
6554
- }
6555
- return byteLength;
6556
- }
6557
- function utf8EncodeJs(str, output, outputOffset) {
6558
- const strLength = str.length;
6559
- let offset = outputOffset;
6560
- let pos = 0;
6561
- while (pos < strLength) {
6562
- let value = str.charCodeAt(pos++);
6563
- if ((value & 4294967168) === 0) {
6564
- output[offset++] = value;
6565
- continue;
6566
- } else if ((value & 4294965248) === 0) {
6567
- output[offset++] = value >> 6 & 31 | 192;
6568
- } else {
6569
- if (value >= 55296 && value <= 56319) {
6570
- if (pos < strLength) {
6571
- const extra = str.charCodeAt(pos);
6572
- if ((extra & 64512) === 56320) {
6573
- ++pos;
6574
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
6575
- }
6576
- }
6577
- }
6578
- if ((value & 4294901760) === 0) {
6579
- output[offset++] = value >> 12 & 15 | 224;
6580
- output[offset++] = value >> 6 & 63 | 128;
6581
- } else {
6582
- output[offset++] = value >> 18 & 7 | 240;
6583
- output[offset++] = value >> 12 & 63 | 128;
6584
- output[offset++] = value >> 6 & 63 | 128;
6585
- }
6586
- }
6587
- output[offset++] = value & 63 | 128;
6588
- }
6589
- }
6590
- function utf8EncodeTE(str, output, outputOffset) {
6591
- sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
6592
- }
6593
- function utf8Encode(str, output, outputOffset) {
6594
- if (str.length > TEXT_ENCODER_THRESHOLD) {
6595
- utf8EncodeTE(str, output, outputOffset);
6596
- } else {
6597
- utf8EncodeJs(str, output, outputOffset);
6598
- }
6599
- }
6600
- function utf8DecodeJs(bytes, inputOffset, byteLength) {
6601
- let offset = inputOffset;
6602
- const end = offset + byteLength;
6603
- const units = [];
6604
- let result = "";
6605
- while (offset < end) {
6606
- const byte1 = bytes[offset++];
6607
- if ((byte1 & 128) === 0) {
6608
- units.push(byte1);
6609
- } else if ((byte1 & 224) === 192) {
6610
- const byte2 = bytes[offset++] & 63;
6611
- units.push((byte1 & 31) << 6 | byte2);
6612
- } else if ((byte1 & 240) === 224) {
6613
- const byte2 = bytes[offset++] & 63;
6614
- const byte3 = bytes[offset++] & 63;
6615
- units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
6616
- } else if ((byte1 & 248) === 240) {
6617
- const byte2 = bytes[offset++] & 63;
6618
- const byte3 = bytes[offset++] & 63;
6619
- const byte4 = bytes[offset++] & 63;
6620
- let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
6621
- if (unit > 65535) {
6622
- unit -= 65536;
6623
- units.push(unit >>> 10 & 1023 | 55296);
6624
- unit = 56320 | unit & 1023;
6625
- }
6626
- units.push(unit);
6627
- } else {
6628
- units.push(byte1);
6629
- }
6630
- if (units.length >= CHUNK_SIZE) {
6631
- result += String.fromCharCode(...units);
6632
- units.length = 0;
6633
- }
6634
- }
6635
- if (units.length > 0) {
6636
- result += String.fromCharCode(...units);
6240
+ if (units.length > 0) {
6241
+ result += String.fromCharCode(...units);
6637
6242
  }
6638
6243
  return result;
6639
6244
  }
@@ -6650,7 +6255,7 @@ function utf8Decode(bytes, inputOffset, byteLength) {
6650
6255
  }
6651
6256
  var sharedTextEncoder, TEXT_ENCODER_THRESHOLD, CHUNK_SIZE, sharedTextDecoder, TEXT_DECODER_THRESHOLD;
6652
6257
  var init_utf8 = __esm({
6653
- "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"() {
6654
6259
  "use strict";
6655
6260
  sharedTextEncoder = new TextEncoder();
6656
6261
  TEXT_ENCODER_THRESHOLD = 50;
@@ -6660,10 +6265,10 @@ var init_utf8 = __esm({
6660
6265
  }
6661
6266
  });
6662
6267
 
6663
- // 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
6664
6269
  var ExtData;
6665
6270
  var init_ExtData = __esm({
6666
- "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"() {
6667
6272
  "use strict";
6668
6273
  ExtData = class {
6669
6274
  type;
@@ -6676,10 +6281,10 @@ var init_ExtData = __esm({
6676
6281
  }
6677
6282
  });
6678
6283
 
6679
- // 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
6680
6285
  var DecodeError;
6681
6286
  var init_DecodeError = __esm({
6682
- "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"() {
6683
6288
  "use strict";
6684
6289
  DecodeError = class _DecodeError extends Error {
6685
6290
  constructor(message) {
@@ -6696,7 +6301,7 @@ var init_DecodeError = __esm({
6696
6301
  }
6697
6302
  });
6698
6303
 
6699
- // 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
6700
6305
  function setUint64(view, offset, value) {
6701
6306
  const high = value / 4294967296;
6702
6307
  const low = value;
@@ -6721,13 +6326,13 @@ function getUint64(view, offset) {
6721
6326
  }
6722
6327
  var UINT32_MAX;
6723
6328
  var init_int = __esm({
6724
- "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"() {
6725
6330
  "use strict";
6726
6331
  UINT32_MAX = 4294967295;
6727
6332
  }
6728
6333
  });
6729
6334
 
6730
- // 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
6731
6336
  function encodeTimeSpecToTimestamp({ sec, nsec }) {
6732
6337
  if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
6733
6338
  if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
@@ -6800,7 +6405,7 @@ function decodeTimestampExtension(data) {
6800
6405
  }
6801
6406
  var EXT_TIMESTAMP, TIMESTAMP32_MAX_SEC, TIMESTAMP64_MAX_SEC, timestampExtension;
6802
6407
  var init_timestamp = __esm({
6803
- "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"() {
6804
6409
  "use strict";
6805
6410
  init_DecodeError();
6806
6411
  init_int();
@@ -6815,10 +6420,10 @@ var init_timestamp = __esm({
6815
6420
  }
6816
6421
  });
6817
6422
 
6818
- // 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
6819
6424
  var ExtensionCodec;
6820
6425
  var init_ExtensionCodec = __esm({
6821
- "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"() {
6822
6427
  "use strict";
6823
6428
  init_ExtData();
6824
6429
  init_timestamp();
@@ -6885,7 +6490,7 @@ var init_ExtensionCodec = __esm({
6885
6490
  }
6886
6491
  });
6887
6492
 
6888
- // 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
6889
6494
  function isArrayBufferLike(buffer) {
6890
6495
  return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
6891
6496
  }
@@ -6901,15 +6506,15 @@ function ensureUint8Array(buffer) {
6901
6506
  }
6902
6507
  }
6903
6508
  var init_typedArrays = __esm({
6904
- "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"() {
6905
6510
  "use strict";
6906
6511
  }
6907
6512
  });
6908
6513
 
6909
- // 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
6910
6515
  var DEFAULT_MAX_DEPTH, DEFAULT_INITIAL_BUFFER_SIZE, Encoder;
6911
6516
  var init_Encoder = __esm({
6912
- "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"() {
6913
6518
  "use strict";
6914
6519
  init_utf8();
6915
6520
  init_ExtensionCodec();
@@ -7319,32 +6924,32 @@ var init_Encoder = __esm({
7319
6924
  }
7320
6925
  });
7321
6926
 
7322
- // 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
7323
6928
  function encode(value, options) {
7324
6929
  const encoder2 = new Encoder(options);
7325
6930
  return encoder2.encodeSharedRef(value);
7326
6931
  }
7327
6932
  var init_encode = __esm({
7328
- "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"() {
7329
6934
  "use strict";
7330
6935
  init_Encoder();
7331
6936
  }
7332
6937
  });
7333
6938
 
7334
- // 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
7335
6940
  function prettyByte(byte) {
7336
6941
  return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
7337
6942
  }
7338
6943
  var init_prettyByte = __esm({
7339
- "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"() {
7340
6945
  "use strict";
7341
6946
  }
7342
6947
  });
7343
6948
 
7344
- // 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
7345
6950
  var DEFAULT_MAX_KEY_LENGTH, DEFAULT_MAX_LENGTH_PER_KEY, CachedKeyDecoder;
7346
6951
  var init_CachedKeyDecoder = __esm({
7347
- "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"() {
7348
6953
  "use strict";
7349
6954
  init_utf8();
7350
6955
  DEFAULT_MAX_KEY_LENGTH = 16;
@@ -7404,10 +7009,10 @@ var init_CachedKeyDecoder = __esm({
7404
7009
  }
7405
7010
  });
7406
7011
 
7407
- // 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
7408
7013
  var STATE_ARRAY, STATE_MAP_KEY, STATE_MAP_VALUE, mapKeyConverter, StackPool, HEAD_BYTE_REQUIRED, EMPTY_VIEW, EMPTY_BYTES, MORE_DATA, sharedCachedKeyDecoder, Decoder;
7409
7014
  var init_Decoder = __esm({
7410
- "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"() {
7411
7016
  "use strict";
7412
7017
  init_prettyByte();
7413
7018
  init_ExtensionCodec();
@@ -8045,34 +7650,34 @@ var init_Decoder = __esm({
8045
7650
  }
8046
7651
  });
8047
7652
 
8048
- // 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
8049
7654
  function decode(buffer, options) {
8050
7655
  const decoder = new Decoder(options);
8051
7656
  return decoder.decode(buffer);
8052
7657
  }
8053
7658
  var init_decode = __esm({
8054
- "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"() {
8055
7660
  "use strict";
8056
7661
  init_Decoder();
8057
7662
  }
8058
7663
  });
8059
7664
 
8060
- // 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
8061
7666
  var init_dist = __esm({
8062
- "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"() {
8063
7668
  "use strict";
8064
7669
  init_encode();
8065
7670
  init_decode();
8066
7671
  }
8067
7672
  });
8068
7673
 
8069
- // node_modules/@pmate/utils/src/Msg.ts
7674
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Msg.ts
8070
7675
  var encoder, Msg;
8071
7676
  var init_Msg = __esm({
8072
- "node_modules/@pmate/utils/src/Msg.ts"() {
7677
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/Msg.ts"() {
8073
7678
  "use strict";
8074
7679
  init_dist();
8075
- init_src3();
7680
+ init_src();
8076
7681
  init_compress();
8077
7682
  init_uniqHash();
8078
7683
  encoder = new TextEncoder();
@@ -8146,17 +7751,21 @@ var init_Msg = __esm({
8146
7751
  if (!body || typeof body !== "object") {
8147
7752
  return msg;
8148
7753
  }
8149
- if ("payload" in body && "type" in body) {
8150
- const payload = body.payload;
8151
- const isBinaryPayload = typeof Blob !== "undefined" && (payload instanceof Blob || payload instanceof ArrayBuffer || payload instanceof Uint8Array);
8152
- if (isBinaryPayload) {
8153
- const gz = await gzipEncodeBlob(payload);
7754
+ const normalizedBody = await _Msg.normalizePayloadBody(body);
7755
+ if (normalizedBody !== body) {
7756
+ return {
7757
+ ...msg,
7758
+ body: normalizedBody
7759
+ };
7760
+ }
7761
+ if ((body.kind === "request" || body.kind === "response") && body.payload && typeof body.payload === "object") {
7762
+ const normalizedPayload = await _Msg.normalizePayloadBody(body.payload);
7763
+ if (normalizedPayload !== body.payload) {
8154
7764
  return {
8155
7765
  ...msg,
8156
7766
  body: {
8157
7767
  ...body,
8158
- payload: gz,
8159
- contentEncoding: "gzip"
7768
+ payload: normalizedPayload
8160
7769
  }
8161
7770
  };
8162
7771
  }
@@ -8171,114 +7780,130 @@ var init_Msg = __esm({
8171
7780
  }
8172
7781
  };
8173
7782
  }
8174
- return msg;
7783
+ return msg;
7784
+ }
7785
+ static async normalizePayloadBody(body) {
7786
+ if (!("payload" in body) || !("type" in body)) {
7787
+ return body;
7788
+ }
7789
+ const payload = body.payload;
7790
+ const isBinaryPayload = typeof Blob !== "undefined" && (payload instanceof Blob || payload instanceof ArrayBuffer || payload instanceof Uint8Array);
7791
+ if (!isBinaryPayload) {
7792
+ return body;
7793
+ }
7794
+ const gz = await gzipEncodeBlob(payload);
7795
+ return {
7796
+ ...body,
7797
+ payload: gz,
7798
+ contentEncoding: "gzip"
7799
+ };
8175
7800
  }
8176
7801
  };
8177
7802
  }
8178
7803
  });
8179
7804
 
8180
- // node_modules/@pmate/utils/src/normalize.ts
7805
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/normalize.ts
8181
7806
  var init_normalize = __esm({
8182
- "node_modules/@pmate/utils/src/normalize.ts"() {
7807
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/normalize.ts"() {
8183
7808
  "use strict";
8184
7809
  }
8185
7810
  });
8186
7811
 
8187
- // node_modules/@pmate/utils/src/pageURL.ts
7812
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/pageURL.ts
8188
7813
  var init_pageURL = __esm({
8189
- "node_modules/@pmate/utils/src/pageURL.ts"() {
7814
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/pageURL.ts"() {
8190
7815
  "use strict";
8191
7816
  }
8192
7817
  });
8193
7818
 
8194
- // node_modules/@pmate/utils/src/PromiseQueue.ts
7819
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/PromiseQueue.ts
8195
7820
  var init_PromiseQueue = __esm({
8196
- "node_modules/@pmate/utils/src/PromiseQueue.ts"() {
7821
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/PromiseQueue.ts"() {
8197
7822
  "use strict";
8198
7823
  }
8199
7824
  });
8200
7825
 
8201
- // node_modules/@pmate/utils/src/resourceKey.ts
7826
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/resourceKey.ts
8202
7827
  var import_js_sha33;
8203
7828
  var init_resourceKey = __esm({
8204
- "node_modules/@pmate/utils/src/resourceKey.ts"() {
7829
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/resourceKey.ts"() {
8205
7830
  "use strict";
8206
7831
  import_js_sha33 = __toESM(require_sha3(), 1);
8207
7832
  }
8208
7833
  });
8209
7834
 
8210
- // node_modules/@pmate/utils/src/SelectionHelper.ts
7835
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/SelectionHelper.ts
8211
7836
  var init_SelectionHelper = __esm({
8212
- "node_modules/@pmate/utils/src/SelectionHelper.ts"() {
7837
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/SelectionHelper.ts"() {
8213
7838
  "use strict";
8214
7839
  }
8215
7840
  });
8216
7841
 
8217
- // node_modules/@pmate/utils/src/setMinus.ts
7842
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/setMinus.ts
8218
7843
  var init_setMinus = __esm({
8219
- "node_modules/@pmate/utils/src/setMinus.ts"() {
7844
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/setMinus.ts"() {
8220
7845
  "use strict";
8221
7846
  }
8222
7847
  });
8223
7848
 
8224
- // node_modules/@pmate/utils/src/sha1Hash.ts
7849
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/sha1Hash.ts
8225
7850
  var init_sha1Hash = __esm({
8226
- "node_modules/@pmate/utils/src/sha1Hash.ts"() {
7851
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/sha1Hash.ts"() {
8227
7852
  "use strict";
8228
7853
  }
8229
7854
  });
8230
7855
 
8231
- // node_modules/@pmate/utils/src/TaskWaiter.ts
7856
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/TaskWaiter.ts
8232
7857
  var init_TaskWaiter = __esm({
8233
- "node_modules/@pmate/utils/src/TaskWaiter.ts"() {
7858
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/TaskWaiter.ts"() {
8234
7859
  "use strict";
8235
- init_src4();
7860
+ init_src3();
8236
7861
  }
8237
7862
  });
8238
7863
 
8239
- // node_modules/@pmate/utils/src/toSentenceAnalyze.ts
7864
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/toSentenceAnalyze.ts
8240
7865
  var init_toSentenceAnalyze = __esm({
8241
- "node_modules/@pmate/utils/src/toSentenceAnalyze.ts"() {
7866
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/toSentenceAnalyze.ts"() {
8242
7867
  "use strict";
8243
7868
  }
8244
7869
  });
8245
7870
 
8246
- // node_modules/@pmate/utils/src/txtBookToJson.ts
7871
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/txtBookToJson.ts
8247
7872
  var init_txtBookToJson = __esm({
8248
- "node_modules/@pmate/utils/src/txtBookToJson.ts"() {
7873
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/txtBookToJson.ts"() {
8249
7874
  "use strict";
8250
7875
  init_src2();
8251
7876
  }
8252
7877
  });
8253
7878
 
8254
- // node_modules/@pmate/utils/src/VocabularyMap.ts
7879
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/VocabularyMap.ts
8255
7880
  var init_VocabularyMap = __esm({
8256
- "node_modules/@pmate/utils/src/VocabularyMap.ts"() {
7881
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/VocabularyMap.ts"() {
8257
7882
  "use strict";
8258
7883
  init_Emitter();
8259
7884
  }
8260
7885
  });
8261
7886
 
8262
- // node_modules/@pmate/utils/src/wait.ts
7887
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wait.ts
8263
7888
  var init_wait = __esm({
8264
- "node_modules/@pmate/utils/src/wait.ts"() {
7889
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wait.ts"() {
8265
7890
  "use strict";
8266
7891
  }
8267
7892
  });
8268
7893
 
8269
- // node_modules/@pmate/utils/src/wordCount.ts
7894
+ // node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wordCount.ts
8270
7895
  var init_wordCount = __esm({
8271
- "node_modules/@pmate/utils/src/wordCount.ts"() {
7896
+ "node_modules/.pnpm/@pmate+utils@1.1.4/node_modules/@pmate/utils/src/wordCount.ts"() {
8272
7897
  "use strict";
8273
7898
  }
8274
7899
  });
8275
7900
 
8276
- // 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
8277
7902
  var logger, WebsocketHeartbeat;
8278
7903
  var init_WebsocketHeartbeat = __esm({
8279
- "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"() {
8280
7905
  "use strict";
8281
- init_src3();
7906
+ init_src();
8282
7907
  init_Logger();
8283
7908
  logger = Logger.getDebugger("heartbeat");
8284
7909
  WebsocketHeartbeat = class {
@@ -8311,19 +7936,18 @@ var init_WebsocketHeartbeat = __esm({
8311
7936
  }
8312
7937
  handlePong() {
8313
7938
  this.lastPong = Date.now();
8314
- logger.log("Pong received");
8315
7939
  return true;
8316
7940
  }
8317
7941
  };
8318
7942
  }
8319
7943
  });
8320
7944
 
8321
- // 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
8322
7946
  var logger2;
8323
7947
  var init_WebsocketClient = __esm({
8324
- "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"() {
8325
7949
  "use strict";
8326
- init_src3();
7950
+ init_src();
8327
7951
  init_Emitter();
8328
7952
  init_Logger();
8329
7953
  init_Msg();
@@ -8332,7 +7956,7 @@ var init_WebsocketClient = __esm({
8332
7956
  }
8333
7957
  });
8334
7958
 
8335
- // 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
8336
7960
  function isEventLike(value) {
8337
7961
  return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
8338
7962
  }
@@ -8341,9 +7965,9 @@ function isCloseEvent(value) {
8341
7965
  }
8342
7966
  var logger3, WebsocketClientV2;
8343
7967
  var init_WebsocketClientV2 = __esm({
8344
- "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"() {
8345
7969
  "use strict";
8346
- init_src3();
7970
+ init_src();
8347
7971
  init_AsyncStream();
8348
7972
  init_Logger();
8349
7973
  init_Msg();
@@ -8588,10 +8212,10 @@ var init_WebsocketClientV2 = __esm({
8588
8212
  }
8589
8213
  });
8590
8214
 
8591
- // 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
8592
8216
  var logger4;
8593
8217
  var init_H3Client = __esm({
8594
- "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"() {
8595
8219
  "use strict";
8596
8220
  init_Emitter();
8597
8221
  init_Logger();
@@ -8601,9 +8225,9 @@ var init_H3Client = __esm({
8601
8225
  }
8602
8226
  });
8603
8227
 
8604
- // 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
8605
8229
  var init_websocket = __esm({
8606
- "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"() {
8607
8231
  "use strict";
8608
8232
  init_WebsocketClient();
8609
8233
  init_WebsocketClientV2();
@@ -8611,9 +8235,9 @@ var init_websocket = __esm({
8611
8235
  }
8612
8236
  });
8613
8237
 
8614
- // node_modules/@pmate/utils/src/index.ts
8615
- var init_src4 = __esm({
8616
- "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"() {
8617
8241
  "use strict";
8618
8242
  init_base64();
8619
8243
  init_batchResolve();
@@ -8653,7 +8277,7 @@ var init_src4 = __esm({
8653
8277
  }
8654
8278
  });
8655
8279
 
8656
- // node_modules/@pmate/agent-sdk/dist/debug.js
8280
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/debug.js
8657
8281
  function isDebugEnabled() {
8658
8282
  return process.env.DEBUG === "1";
8659
8283
  }
@@ -8668,17 +8292,296 @@ function debugLog(message, data) {
8668
8292
  console.log(message, data);
8669
8293
  }
8670
8294
  var init_debug = __esm({
8671
- "node_modules/@pmate/agent-sdk/dist/debug.js"() {
8295
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/debug.js"() {
8296
+ "use strict";
8297
+ }
8298
+ });
8299
+
8300
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentConnectionPool.js
8301
+ function ensureProtocol(value, protocol) {
8302
+ if (!value) {
8303
+ return "";
8304
+ }
8305
+ if (/^[a-z]+:\/\//i.test(value)) {
8306
+ try {
8307
+ const url = new URL(value);
8308
+ url.protocol = `${protocol}:`;
8309
+ return url.toString();
8310
+ } catch {
8311
+ return value;
8312
+ }
8313
+ }
8314
+ if (value.startsWith("//")) {
8315
+ return `${protocol}:${value}`;
8316
+ }
8317
+ return `${protocol}://${value}`;
8318
+ }
8319
+ function createPoolKey(wsUrl, profileId, token) {
8320
+ return `${wsUrl}|${profileId}|${hashToken(token)}`;
8321
+ }
8322
+ function hashToken(token) {
8323
+ let hash = 2166136261;
8324
+ for (let i = 0; i < token.length; i += 1) {
8325
+ hash ^= token.charCodeAt(i);
8326
+ hash = Math.imul(hash, 16777619);
8327
+ }
8328
+ return (hash >>> 0).toString(16).padStart(8, "0");
8329
+ }
8330
+ var IDLE_CLOSE_MS, pool, AgentConnectionPool, AgentPooledConnection;
8331
+ var init_AgentConnectionPool = __esm({
8332
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentConnectionPool.js"() {
8672
8333
  "use strict";
8334
+ init_src();
8335
+ init_src3();
8336
+ init_debug();
8337
+ IDLE_CLOSE_MS = 5e3;
8338
+ pool = /* @__PURE__ */ new Map();
8339
+ AgentConnectionPool = class {
8340
+ static acquire(options) {
8341
+ const wsUrl = ensureProtocol(options.baseUrl, "wss");
8342
+ const key = createPoolKey(wsUrl, options.profileId, options.token);
8343
+ let entry = pool.get(key);
8344
+ if (!entry) {
8345
+ entry = {
8346
+ connection: new AgentPooledConnection(wsUrl, options.profileId, options.token),
8347
+ refCount: 0,
8348
+ idleTimer: null
8349
+ };
8350
+ pool.set(key, entry);
8351
+ }
8352
+ if (entry.idleTimer) {
8353
+ clearTimeout(entry.idleTimer);
8354
+ entry.idleTimer = null;
8355
+ }
8356
+ entry.refCount += 1;
8357
+ return {
8358
+ key,
8359
+ connection: entry.connection
8360
+ };
8361
+ }
8362
+ static release(lease) {
8363
+ const entry = pool.get(lease.key);
8364
+ if (!entry) {
8365
+ return;
8366
+ }
8367
+ entry.refCount = Math.max(0, entry.refCount - 1);
8368
+ if (entry.refCount > 0 || entry.idleTimer) {
8369
+ return;
8370
+ }
8371
+ entry.idleTimer = setTimeout(() => {
8372
+ const current = pool.get(lease.key);
8373
+ if (!current || current.refCount > 0) {
8374
+ return;
8375
+ }
8376
+ current.connection.close();
8377
+ pool.delete(lease.key);
8378
+ }, IDLE_CLOSE_MS);
8379
+ }
8380
+ static clearForTests() {
8381
+ for (const [key, entry] of pool.entries()) {
8382
+ if (entry.idleTimer) {
8383
+ clearTimeout(entry.idleTimer);
8384
+ }
8385
+ entry.connection.close();
8386
+ pool.delete(key);
8387
+ }
8388
+ }
8389
+ };
8390
+ AgentPooledConnection = class {
8391
+ constructor(wsUrl, profileId, token) {
8392
+ this.profileId = profileId;
8393
+ this.token = token;
8394
+ this.listeners = /* @__PURE__ */ new Set();
8395
+ this.authPromise = null;
8396
+ this.authResolve = null;
8397
+ this.authReject = null;
8398
+ this.authTimer = null;
8399
+ this.authenticated = false;
8400
+ this.authStarted = false;
8401
+ this.ws = new WebsocketClientV2(wsUrl);
8402
+ this.startWsStream();
8403
+ }
8404
+ addListener(listener) {
8405
+ this.listeners.add(listener);
8406
+ }
8407
+ removeListener(listener) {
8408
+ this.listeners.delete(listener);
8409
+ }
8410
+ isConnected() {
8411
+ return this.ws.isConnected();
8412
+ }
8413
+ async authenticate(timeoutMs) {
8414
+ await this.waitForConnection(timeoutMs);
8415
+ if (this.authenticated) {
8416
+ debugLog("[agent-connection-pool] auth reused", {
8417
+ profileId: this.profileId
8418
+ });
8419
+ return;
8420
+ }
8421
+ const waiter = this.waitForAuthAck(timeoutMs);
8422
+ if (!this.authStarted) {
8423
+ this.authStarted = true;
8424
+ const msg = Msg.create(this.profileId, "@hub", 4 /* AUTH */, {
8425
+ token: this.token,
8426
+ as: "user",
8427
+ profileId: this.profileId
8428
+ });
8429
+ debugLog("[agent-connection-pool] auth sent", {
8430
+ profileId: this.profileId
8431
+ });
8432
+ await this.ws.sendMsg(msg);
8433
+ }
8434
+ await waiter;
8435
+ }
8436
+ sendMsg(msg) {
8437
+ return this.ws.sendMsg(msg);
8438
+ }
8439
+ close() {
8440
+ this.ws.close();
8441
+ this.rejectAuth(new Error("Agent websocket closed before auth ack"));
8442
+ this.listeners.clear();
8443
+ }
8444
+ async startWsStream() {
8445
+ const stream = this.ws.getStream();
8446
+ try {
8447
+ for await (const event of stream) {
8448
+ this.handleWsEvent(event);
8449
+ }
8450
+ } catch {
8451
+ }
8452
+ }
8453
+ handleWsEvent(event) {
8454
+ if (event.type === "message") {
8455
+ this.handleIncomingMessage(event.data);
8456
+ return;
8457
+ }
8458
+ if (event.type === "connected" && !event.data) {
8459
+ this.authenticated = false;
8460
+ this.rejectAuth(new Error("Agent websocket disconnected before auth ack"));
8461
+ }
8462
+ if (event.type === "error") {
8463
+ this.rejectAuth(new Error("Agent websocket error before auth ack"));
8464
+ }
8465
+ this.broadcast(event);
8466
+ }
8467
+ handleIncomingMessage(message) {
8468
+ if (!message || typeof message !== "object") {
8469
+ return;
8470
+ }
8471
+ if (message.opcode === 3 /* ACK */) {
8472
+ const ack = message.body;
8473
+ const success = ack?.status === "ok";
8474
+ debugLog("[agent-connection-pool] ack received", {
8475
+ profileId: this.profileId,
8476
+ success
8477
+ });
8478
+ if (!success) {
8479
+ this.rejectAuth(new Error(ack?.message ?? ack?.code ?? "Auth failed"));
8480
+ return;
8481
+ }
8482
+ this.authenticated = true;
8483
+ this.resolveAuth();
8484
+ return;
8485
+ }
8486
+ debugLog("[agent-connection-pool] message broadcast", {
8487
+ opcode: message.opcode,
8488
+ from: message.from,
8489
+ to: message.to
8490
+ });
8491
+ this.broadcast({ type: "message", data: message });
8492
+ }
8493
+ broadcast(event) {
8494
+ for (const listener of this.listeners) {
8495
+ listener.onConnectionEvent(event);
8496
+ }
8497
+ }
8498
+ waitForConnection(timeoutMs) {
8499
+ if (this.ws.isConnected()) {
8500
+ return Promise.resolve();
8501
+ }
8502
+ return new Promise((resolve, reject) => {
8503
+ const timer = setTimeout(() => {
8504
+ off();
8505
+ reject(new Error("Websocket connect timeout"));
8506
+ }, timeoutMs);
8507
+ const off = this.createOneShotListener("connected" /* Connected */, (connected) => {
8508
+ if (connected) {
8509
+ clearTimeout(timer);
8510
+ off();
8511
+ resolve();
8512
+ }
8513
+ });
8514
+ });
8515
+ }
8516
+ waitForAuthAck(timeoutMs) {
8517
+ if (this.authenticated) {
8518
+ return Promise.resolve();
8519
+ }
8520
+ if (this.authPromise) {
8521
+ return this.authPromise;
8522
+ }
8523
+ this.authPromise = new Promise((resolve, reject) => {
8524
+ this.authResolve = resolve;
8525
+ this.authReject = reject;
8526
+ this.authTimer = setTimeout(() => {
8527
+ this.clearAuthWaiter();
8528
+ this.authStarted = false;
8529
+ reject(new Error("Auth timeout"));
8530
+ }, timeoutMs);
8531
+ });
8532
+ return this.authPromise;
8533
+ }
8534
+ resolveAuth() {
8535
+ if (!this.authResolve) {
8536
+ return;
8537
+ }
8538
+ const resolve = this.authResolve;
8539
+ this.clearAuthWaiter();
8540
+ this.authStarted = false;
8541
+ resolve();
8542
+ }
8543
+ rejectAuth(error) {
8544
+ if (!this.authReject) {
8545
+ return;
8546
+ }
8547
+ const reject = this.authReject;
8548
+ this.clearAuthWaiter();
8549
+ this.authStarted = false;
8550
+ reject(error);
8551
+ }
8552
+ clearAuthWaiter() {
8553
+ if (this.authTimer) {
8554
+ clearTimeout(this.authTimer);
8555
+ this.authTimer = null;
8556
+ }
8557
+ this.authPromise = null;
8558
+ this.authResolve = null;
8559
+ this.authReject = null;
8560
+ }
8561
+ createOneShotListener(eventName, handler) {
8562
+ const listener = {
8563
+ onConnectionEvent: (event) => {
8564
+ if (eventName === "connected" /* Connected */ && event.type === "connected") {
8565
+ ;
8566
+ handler(event.data);
8567
+ }
8568
+ }
8569
+ };
8570
+ this.addListener(listener);
8571
+ return () => {
8572
+ this.removeListener(listener);
8573
+ };
8574
+ }
8575
+ };
8673
8576
  }
8674
8577
  });
8675
8578
 
8676
- // node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js
8579
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js
8677
8580
  var AgentTaskManager;
8678
8581
  var init_AgentTaskManager = __esm({
8679
- "node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js"() {
8582
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js"() {
8680
8583
  "use strict";
8681
- init_src4();
8584
+ init_src3();
8682
8585
  init_debug();
8683
8586
  AgentTaskManager = class {
8684
8587
  constructor() {
@@ -8845,13 +8748,20 @@ var init_AgentTaskManager = __esm({
8845
8748
  }
8846
8749
  });
8847
8750
 
8848
- // node_modules/@pmate/agent-sdk/dist/AgentClient.js
8751
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentClient.js
8752
+ function createAgentRequestBody(payload) {
8753
+ return {
8754
+ kind: "request",
8755
+ payload
8756
+ };
8757
+ }
8849
8758
  var logger5, DEFAULT_TIMEOUT_MS, DEFAULT_STREAM_TIMEOUT_MS, DEFAULT_MIN_CHUNK_SIZE_BYTES, AgentClient;
8850
8759
  var init_AgentClient = __esm({
8851
- "node_modules/@pmate/agent-sdk/dist/AgentClient.js"() {
8760
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentClient.js"() {
8852
8761
  "use strict";
8853
8762
  init_src();
8854
- init_src4();
8763
+ init_src3();
8764
+ init_AgentConnectionPool();
8855
8765
  init_AgentTaskManager();
8856
8766
  init_debug();
8857
8767
  logger5 = Logger.getDebugger("AgentClient");
@@ -8862,11 +8772,6 @@ var init_AgentClient = __esm({
8862
8772
  constructor(options) {
8863
8773
  super();
8864
8774
  this.tasks = new AgentTaskManager();
8865
- this.authPromise = null;
8866
- this.authResolve = null;
8867
- this.authReject = null;
8868
- this.authTimer = null;
8869
- this.wsGeneration = 0;
8870
8775
  this.defaultRequestType = "application/json";
8871
8776
  this.defaultBinaryType = "application/octet-stream";
8872
8777
  this.baseUrl = options.baseUrl;
@@ -8874,24 +8779,33 @@ var init_AgentClient = __esm({
8874
8779
  this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
8875
8780
  this.streamTimeoutMs = options.streamTimeoutMs ?? DEFAULT_STREAM_TIMEOUT_MS;
8876
8781
  this.minChunkSizeBytes = options.minChunkSizeBytes ?? DEFAULT_MIN_CHUNK_SIZE_BYTES;
8877
- this.resetWebsocket(this.baseUrl);
8878
8782
  }
8879
8783
  isConnected() {
8880
- return this.ws?.isConnected() ?? false;
8784
+ return this.lease?.connection.isConnected() ?? false;
8881
8785
  }
8882
8786
  close() {
8883
- this.ws?.close();
8787
+ this.releaseConnection();
8884
8788
  }
8885
- async login(from, options) {
8886
- this.from = from;
8887
- const baseUrl = options?.baseUrl ?? this.baseUrl;
8888
- if (baseUrl !== this.baseUrl) {
8889
- this.resetWebsocket(baseUrl);
8789
+ async login(options) {
8790
+ const profileId = options?.profileId;
8791
+ if (!profileId) {
8792
+ throw new Error("AgentClient user auth requires profileId");
8890
8793
  }
8794
+ this.from = profileId;
8795
+ const baseUrl = options?.baseUrl ?? this.baseUrl;
8891
8796
  const timeoutMs = options?.timeoutMs ?? this.timeoutMs;
8892
- await this.waitForConnection(timeoutMs);
8893
8797
  const token = options?.token ?? "";
8894
- await this.sendAuth(token, timeoutMs);
8798
+ this.auth = { token, profileId };
8799
+ const lease = AgentConnectionPool.acquire({ baseUrl, token, profileId });
8800
+ if (this.lease?.key !== lease.key) {
8801
+ this.releaseConnection();
8802
+ this.lease = lease;
8803
+ this.lease.connection.addListener(this);
8804
+ } else {
8805
+ AgentConnectionPool.release(lease);
8806
+ }
8807
+ this.baseUrl = baseUrl;
8808
+ await this.lease.connection.authenticate(timeoutMs);
8895
8809
  return true;
8896
8810
  }
8897
8811
  async prompt(request) {
@@ -8928,11 +8842,18 @@ var init_AgentClient = __esm({
8928
8842
  taskId,
8929
8843
  agentId: request.agentId,
8930
8844
  op: 0 /* Start */,
8845
+ auth: this.auth,
8931
8846
  type: this.defaultRequestType,
8932
8847
  ...request.payload ? { payload: request.payload } : {}
8933
8848
  };
8934
- const msg = Msg.create(this.from, hubTo, 1002 /* AGENT_REQUEST */, startPayload, 0 /* PIPELINE */);
8935
- await this.ws.sendMsg(msg);
8849
+ const msg = Msg.create(this.from, hubTo, 2 /* AGENT */, createAgentRequestBody(startPayload), 0 /* PIPELINE */);
8850
+ debugLog("[agent-client] sending agent request", {
8851
+ taskId,
8852
+ agentId: request.agentId,
8853
+ from: this.from,
8854
+ to: hubTo
8855
+ });
8856
+ await this.lease.connection.sendMsg(msg);
8936
8857
  return await waiter;
8937
8858
  }
8938
8859
  stream(request) {
@@ -8944,7 +8865,7 @@ var init_AgentClient = __esm({
8944
8865
  timeoutMode: "reject"
8945
8866
  });
8946
8867
  const from = this.from;
8947
- const ws = this.ws;
8868
+ const connection = this.lease.connection;
8948
8869
  const minChunkSizeBytes = request.minChunkSizeBytes ?? this.minChunkSizeBytes;
8949
8870
  const inputStream = minChunkSizeBytes > 0 ? AsyncStream.chunkBlob(request.stream, {
8950
8871
  minBytes: minChunkSizeBytes
@@ -8982,33 +8903,36 @@ var init_AgentClient = __esm({
8982
8903
  const startDataStream = async () => {
8983
8904
  const agent = await this.agentService.getAgentById(request.agentId);
8984
8905
  const hubTo = `@hub/${agent.type}`;
8985
- const startMsg = Msg.create(from, hubTo, 1002 /* AGENT_REQUEST */, {
8906
+ const startMsg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody({
8986
8907
  taskId,
8987
8908
  agentId: request.agentId,
8988
8909
  op: 0 /* Start */,
8910
+ auth: this.auth,
8989
8911
  type: this.defaultRequestType,
8990
8912
  ...request.params ? { payload: request.params } : {}
8991
- }, 0 /* PIPELINE */);
8992
- await ws.sendMsg(startMsg);
8913
+ }), 0 /* PIPELINE */);
8914
+ await connection.sendMsg(startMsg);
8993
8915
  for await (const payload of inputStream) {
8994
8916
  const dataType = payload instanceof Blob ? payload.type || this.defaultBinaryType : payload instanceof Uint8Array || payload instanceof ArrayBuffer ? this.defaultBinaryType : typeof payload === "string" ? "text" : this.defaultRequestType;
8995
8917
  const body = {
8996
8918
  taskId,
8997
8919
  agentId: request.agentId,
8998
8920
  op: 1 /* Data */,
8921
+ auth: this.auth,
8999
8922
  type: dataType,
9000
8923
  payload
9001
8924
  };
9002
- const msg = Msg.create(from, hubTo, 1002 /* AGENT_REQUEST */, body, 0 /* PIPELINE */);
9003
- await ws.sendMsg(msg);
8925
+ const msg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody(body), 0 /* PIPELINE */);
8926
+ await connection.sendMsg(msg);
9004
8927
  }
9005
- const endMsg = Msg.create(from, hubTo, 1002 /* AGENT_REQUEST */, {
8928
+ const endMsg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody({
9006
8929
  taskId,
9007
8930
  agentId: request.agentId,
9008
8931
  op: 2 /* End */,
8932
+ auth: this.auth,
9009
8933
  type: this.defaultRequestType
9010
- }, 0 /* PIPELINE */);
9011
- await ws.sendMsg(endMsg);
8934
+ }), 0 /* PIPELINE */);
8935
+ await connection.sendMsg(endMsg);
9012
8936
  };
9013
8937
  void startDataStream();
9014
8938
  const agentStream = outputStream;
@@ -9059,7 +8983,7 @@ var init_AgentClient = __esm({
9059
8983
  return agentStream;
9060
8984
  }
9061
8985
  ensureReady() {
9062
- if (!this.ws || !this.from) {
8986
+ if (!this.lease || !this.from || !this.auth) {
9063
8987
  throw new Error("AgentClient not logged in");
9064
8988
  }
9065
8989
  }
@@ -9067,31 +8991,7 @@ var init_AgentClient = __esm({
9067
8991
  const rnd = Math.floor(Math.random() * 1e12);
9068
8992
  return uniqHash(`${agentId}-${Date.now()}-${rnd}`, "task-v1" /* Task */);
9069
8993
  }
9070
- createWebsocketClient(baseUrl) {
9071
- return new WebsocketClientV2(this.ensureProtocol(baseUrl, "wss"));
9072
- }
9073
- resetWebsocket(baseUrl) {
9074
- this.baseUrl = baseUrl;
9075
- if (this.ws) {
9076
- this.ws.close();
9077
- }
9078
- this.ws = this.createWebsocketClient(this.baseUrl);
9079
- this.wsGeneration += 1;
9080
- this.startWsStream(this.ws, this.wsGeneration);
9081
- }
9082
- async startWsStream(ws, generation) {
9083
- const stream = ws.getStream();
9084
- try {
9085
- for await (const event of stream) {
9086
- if (generation !== this.wsGeneration) {
9087
- break;
9088
- }
9089
- this.handleWsEvent(event);
9090
- }
9091
- } catch {
9092
- }
9093
- }
9094
- handleWsEvent(event) {
8994
+ onConnectionEvent(event) {
9095
8995
  if (event.type === "message") {
9096
8996
  this.handleIncomingMessage(event.data);
9097
8997
  return;
@@ -9112,14 +9012,13 @@ var init_AgentClient = __esm({
9112
9012
  if (!message || typeof message !== "object") {
9113
9013
  return;
9114
9014
  }
9115
- if (message.opcode === 1001 /* AUTH_ACK */) {
9116
- const success = Boolean(message.body?.success);
9117
- this.resolveAuth(success);
9118
- return;
9119
- }
9120
- if (message.opcode === 1003 /* AGENT_RESPONSE */) {
9121
- const body = message.body;
9122
- debugLog("[agent-client] incoming AGENT_RESPONSE", {
9015
+ if (message.opcode === 2 /* AGENT */) {
9016
+ const agentBody = message.body;
9017
+ if (agentBody?.kind !== "response") {
9018
+ return;
9019
+ }
9020
+ const body = agentBody.payload;
9021
+ debugLog("[agent-client] incoming AgentBody.response", {
9123
9022
  taskId: body?.taskId,
9124
9023
  isFinal: body?.isFinal,
9125
9024
  success: body?.success,
@@ -9127,151 +9026,78 @@ var init_AgentClient = __esm({
9127
9026
  contentEncoding: body?.contentEncoding,
9128
9027
  payloadKind: body?.payload == null ? "null" : body.payload instanceof Uint8Array ? `uint8array:${body.payload.length}` : Array.isArray(body.payload) ? `array:${body.payload.length}` : typeof body.payload
9129
9028
  });
9130
- this.tasks.handleResponse(message.body);
9131
- }
9132
- }
9133
- ensureProtocol(value, protocol) {
9134
- if (!value) {
9135
- return "";
9136
- }
9137
- if (/^[a-z]+:\/\//i.test(value)) {
9138
- try {
9139
- const url = new URL(value);
9140
- url.protocol = `${protocol}:`;
9141
- return url.toString();
9142
- } catch {
9143
- return value;
9144
- }
9145
- }
9146
- if (value.startsWith("//")) {
9147
- return `${protocol}:${value}`;
9148
- }
9149
- return `${protocol}://${value}`;
9150
- }
9151
- waitForConnection(timeoutMs) {
9152
- if (!this.ws) {
9153
- return Promise.reject(new Error("Websocket client not initialized"));
9154
- }
9155
- if (this.ws.isConnected()) {
9156
- return Promise.resolve();
9157
- }
9158
- return new Promise((resolve, reject) => {
9159
- const timer = setTimeout(() => {
9160
- off();
9161
- reject(new Error("Websocket connect timeout"));
9162
- }, timeoutMs);
9163
- const off = this.on("connected" /* Connected */, (connected) => {
9164
- if (connected) {
9165
- clearTimeout(timer);
9166
- off();
9167
- resolve();
9168
- }
9169
- });
9170
- });
9171
- }
9172
- async sendAuth(token, timeoutMs) {
9173
- if (!this.ws || !this.from) {
9174
- throw new Error("AgentClient not initialized");
9029
+ this.tasks.handleResponse(body);
9175
9030
  }
9176
- const msg = Msg.create(this.from, "@hub", 1e3 /* AUTH */, { token, as: "user" });
9177
- const waiter = this.waitForAuthAck(timeoutMs);
9178
- await this.ws.sendMsg(msg);
9179
- const success = await waiter;
9180
- if (!success) {
9181
- throw new Error("Auth failed");
9182
- }
9183
- }
9184
- waitForAuthAck(timeoutMs) {
9185
- if (this.authPromise) {
9186
- return this.authPromise;
9187
- }
9188
- this.authPromise = new Promise((resolve, reject) => {
9189
- this.authResolve = resolve;
9190
- this.authReject = reject;
9191
- this.authTimer = setTimeout(() => {
9192
- this.clearAuthWaiter();
9193
- reject(new Error("Auth timeout"));
9194
- }, timeoutMs);
9195
- });
9196
- return this.authPromise;
9197
9031
  }
9198
- resolveAuth(success) {
9199
- if (!this.authResolve) {
9032
+ releaseConnection() {
9033
+ if (!this.lease) {
9200
9034
  return;
9201
9035
  }
9202
- const resolve = this.authResolve;
9203
- this.clearAuthWaiter();
9204
- resolve(success);
9205
- }
9206
- clearAuthWaiter() {
9207
- if (this.authTimer) {
9208
- clearTimeout(this.authTimer);
9209
- this.authTimer = null;
9210
- }
9211
- this.authPromise = null;
9212
- this.authResolve = null;
9213
- this.authReject = null;
9036
+ this.lease.connection.removeListener(this);
9037
+ AgentConnectionPool.release(this.lease);
9038
+ this.lease = void 0;
9039
+ this.auth = void 0;
9214
9040
  }
9215
9041
  };
9216
9042
  }
9217
9043
  });
9218
9044
 
9219
- // node_modules/@pmate/agent-sdk/dist/AgentRuntime.js
9045
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentRuntime.js
9220
9046
  var init_AgentRuntime = __esm({
9221
- "node_modules/@pmate/agent-sdk/dist/AgentRuntime.js"() {
9047
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentRuntime.js"() {
9222
9048
  "use strict";
9223
9049
  init_src();
9224
- init_src4();
9050
+ init_src3();
9225
9051
  }
9226
9052
  });
9227
9053
 
9228
- // node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js
9054
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js
9229
9055
  var init_PromptTaskContext = __esm({
9230
- "node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js"() {
9056
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js"() {
9231
9057
  "use strict";
9232
9058
  }
9233
9059
  });
9234
9060
 
9235
- // node_modules/@pmate/agent-sdk/dist/PromptAgent.js
9061
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/PromptAgent.js
9236
9062
  var init_PromptAgent = __esm({
9237
- "node_modules/@pmate/agent-sdk/dist/PromptAgent.js"() {
9063
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/PromptAgent.js"() {
9238
9064
  "use strict";
9239
9065
  init_src();
9240
- init_src4();
9066
+ init_src3();
9241
9067
  init_debug();
9242
9068
  init_AgentRuntime();
9243
9069
  init_PromptTaskContext();
9244
9070
  }
9245
9071
  });
9246
9072
 
9247
- // node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js
9073
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js
9248
9074
  var init_StreamTaskContext = __esm({
9249
- "node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js"() {
9075
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js"() {
9250
9076
  "use strict";
9251
9077
  }
9252
9078
  });
9253
9079
 
9254
- // node_modules/@pmate/agent-sdk/dist/StreamAgent.js
9080
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/StreamAgent.js
9255
9081
  var init_StreamAgent = __esm({
9256
- "node_modules/@pmate/agent-sdk/dist/StreamAgent.js"() {
9082
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/StreamAgent.js"() {
9257
9083
  "use strict";
9258
9084
  init_src();
9259
- init_src4();
9085
+ init_src3();
9260
9086
  init_AgentRuntime();
9261
9087
  init_StreamTaskContext();
9262
9088
  }
9263
9089
  });
9264
9090
 
9265
- // node_modules/@pmate/agent-sdk/dist/AgentFactory.js
9091
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentFactory.js
9266
9092
  var init_AgentFactory = __esm({
9267
- "node_modules/@pmate/agent-sdk/dist/AgentFactory.js"() {
9093
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentFactory.js"() {
9268
9094
  "use strict";
9269
9095
  init_PromptAgent();
9270
9096
  init_StreamAgent();
9271
9097
  }
9272
9098
  });
9273
9099
 
9274
- // node_modules/@pmate/agent-sdk/dist/AgentService.js
9100
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentService.js
9275
9101
  function parseAgentId(agentId) {
9276
9102
  const separatorIndex = agentId.indexOf(":");
9277
9103
  if (separatorIndex <= 0 || separatorIndex === agentId.length - 1) {
@@ -9301,7 +9127,7 @@ function trimTrailingSlash(value) {
9301
9127
  }
9302
9128
  var AgentService;
9303
9129
  var init_AgentService = __esm({
9304
- "node_modules/@pmate/agent-sdk/dist/AgentService.js"() {
9130
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentService.js"() {
9305
9131
  "use strict";
9306
9132
  AgentService = class {
9307
9133
  constructor(options) {
@@ -9342,9 +9168,9 @@ var init_AgentService = __esm({
9342
9168
  }
9343
9169
  });
9344
9170
 
9345
- // node_modules/@pmate/agent-sdk/dist/index.js
9171
+ // node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/index.js
9346
9172
  var init_dist2 = __esm({
9347
- "node_modules/@pmate/agent-sdk/dist/index.js"() {
9173
+ "node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/index.js"() {
9348
9174
  "use strict";
9349
9175
  init_AgentClient();
9350
9176
  init_AgentFactory();
@@ -9354,7 +9180,7 @@ var init_dist2 = __esm({
9354
9180
  init_AgentTaskManager();
9355
9181
  init_AgentService();
9356
9182
  init_debug();
9357
- init_src4();
9183
+ init_src3();
9358
9184
  }
9359
9185
  });
9360
9186