@pmate/cli 0.28.8 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -293,160 +293,181 @@ var init_sessionStore = __esm({
293
293
  }
294
294
  });
295
295
 
296
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/account.types.ts
296
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/account.types.ts
297
297
  var init_account_types = __esm({
298
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/account.types.ts"() {
298
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/account.types.ts"() {
299
299
  "use strict";
300
300
  }
301
301
  });
302
302
 
303
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/achievements.types.ts
303
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/achievements.types.ts
304
304
  var init_achievements_types = __esm({
305
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
305
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
306
306
  "use strict";
307
307
  }
308
308
  });
309
309
 
310
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/aigen.types.ts
310
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/aigen.types.ts
311
311
  var init_aigen_types = __esm({
312
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
312
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
313
313
  "use strict";
314
314
  }
315
315
  });
316
316
 
317
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/agent.types.ts
317
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/agent.types.ts
318
318
  var init_agent_types = __esm({
319
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/agent.types.ts"() {
319
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/agent.types.ts"() {
320
320
  "use strict";
321
321
  }
322
322
  });
323
323
 
324
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/agent-registry.types.ts
324
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/agent-registry.types.ts
325
325
  var init_agent_registry_types = __esm({
326
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
326
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
327
327
  "use strict";
328
328
  }
329
329
  });
330
330
 
331
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/runner-registry.types.ts
331
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/runner-registry.types.ts
332
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"() {
333
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
334
334
  "use strict";
335
335
  }
336
336
  });
337
337
 
338
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/blockchain.types.ts
338
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/function-registry.types.ts
339
+ var init_function_registry_types = __esm({
340
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/function-registry.types.ts"() {
341
+ "use strict";
342
+ }
343
+ });
344
+
345
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/worker-registry.types.ts
346
+ var init_worker_registry_types = __esm({
347
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/worker-registry.types.ts"() {
348
+ "use strict";
349
+ }
350
+ });
351
+
352
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/call.types.ts
353
+ var init_call_types = __esm({
354
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/call.types.ts"() {
355
+ "use strict";
356
+ }
357
+ });
358
+
359
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/blockchain.types.ts
339
360
  var init_blockchain_types = __esm({
340
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
361
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
341
362
  "use strict";
342
363
  }
343
364
  });
344
365
 
345
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/breakdown.types.ts
366
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/breakdown.types.ts
346
367
  var init_breakdown_types = __esm({
347
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
368
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
348
369
  "use strict";
349
370
  }
350
371
  });
351
372
 
352
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/chat.types.ts
373
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/chat.types.ts
353
374
  var init_chat_types = __esm({
354
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/chat.types.ts"() {
375
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/chat.types.ts"() {
355
376
  "use strict";
356
377
  }
357
378
  });
358
379
 
359
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/companion.types.ts
380
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/companion.types.ts
360
381
  var init_companion_types = __esm({
361
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/companion.types.ts"() {
382
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/companion.types.ts"() {
362
383
  "use strict";
363
384
  }
364
385
  });
365
386
 
366
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/enums.ts
387
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/enums.ts
367
388
  var init_enums = __esm({
368
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/enums.ts"() {
389
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/enums.ts"() {
369
390
  "use strict";
370
391
  }
371
392
  });
372
393
 
373
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/lang.types.ts
394
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/lang.types.ts
374
395
  var init_lang_types = __esm({
375
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/lang.types.ts"() {
396
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/lang.types.ts"() {
376
397
  "use strict";
377
398
  }
378
399
  });
379
400
 
380
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/logs.types.ts
401
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/logs.types.ts
381
402
  var init_logs_types = __esm({
382
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/logs.types.ts"() {
403
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/logs.types.ts"() {
383
404
  "use strict";
384
405
  }
385
406
  });
386
407
 
387
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/message.types.ts
408
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/message.types.ts
388
409
  var PING, PONG;
389
410
  var init_message_types = __esm({
390
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/message.types.ts"() {
411
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/message.types.ts"() {
391
412
  "use strict";
392
413
  PING = 1;
393
414
  PONG = 2;
394
415
  }
395
416
  });
396
417
 
397
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/newLog.types.ts
418
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/newLog.types.ts
398
419
  var init_newLog_types = __esm({
399
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
420
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
400
421
  "use strict";
401
422
  }
402
423
  });
403
424
 
404
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/novel.types.ts
425
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/novel.types.ts
405
426
  var init_novel_types = __esm({
406
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/novel.types.ts"() {
427
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/novel.types.ts"() {
407
428
  "use strict";
408
429
  }
409
430
  });
410
431
 
411
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/offline.types.ts
432
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/offline.types.ts
412
433
  var init_offline_types = __esm({
413
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/offline.types.ts"() {
434
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/offline.types.ts"() {
414
435
  "use strict";
415
436
  }
416
437
  });
417
438
 
418
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/prompt.types.ts
439
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/prompt.types.ts
419
440
  var init_prompt_types = __esm({
420
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
441
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
421
442
  "use strict";
422
443
  }
423
444
  });
424
445
 
425
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/reading.types.ts
446
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/reading.types.ts
426
447
  var init_reading_types = __esm({
427
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/reading.types.ts"() {
448
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/reading.types.ts"() {
428
449
  "use strict";
429
450
  }
430
451
  });
431
452
 
432
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/settings.types.ts
453
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/settings.types.ts
433
454
  var init_settings_types = __esm({
434
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/settings.types.ts"() {
455
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/settings.types.ts"() {
435
456
  "use strict";
436
457
  }
437
458
  });
438
459
 
439
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/subscription.types.ts
460
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/subscription.types.ts
440
461
  var init_subscription_types = __esm({
441
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
462
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
442
463
  "use strict";
443
464
  }
444
465
  });
445
466
 
446
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/types.ts
467
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/types.ts
447
468
  var buildVoiceKey, createVoice;
448
469
  var init_types = __esm({
449
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/types.ts"() {
470
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/types.ts"() {
450
471
  "use strict";
451
472
  buildVoiceKey = (provider, name) => {
452
473
  return `${provider}:${name}`;
@@ -468,44 +489,44 @@ var init_types = __esm({
468
489
  }
469
490
  });
470
491
 
471
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/wordv5.def.ts
492
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/wordv5.def.ts
472
493
  var init_wordv5_def = __esm({
473
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
494
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
474
495
  "use strict";
475
496
  }
476
497
  });
477
498
 
478
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/auth.types.ts
499
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/auth.types.ts
479
500
  var init_auth_types = __esm({
480
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/auth.types.ts"() {
501
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/auth.types.ts"() {
481
502
  "use strict";
482
503
  }
483
504
  });
484
505
 
485
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/apps.types.ts
506
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/apps.types.ts
486
507
  var init_apps_types = __esm({
487
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/apps.types.ts"() {
508
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/apps.types.ts"() {
488
509
  "use strict";
489
510
  }
490
511
  });
491
512
 
492
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/response.types.ts
513
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/response.types.ts
493
514
  var init_response_types = __esm({
494
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/response.types.ts"() {
515
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/response.types.ts"() {
495
516
  "use strict";
496
517
  }
497
518
  });
498
519
 
499
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/role.types.ts
520
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/role.types.ts
500
521
  var init_role_types = __esm({
501
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/role.types.ts"() {
522
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/role.types.ts"() {
502
523
  "use strict";
503
524
  }
504
525
  });
505
526
 
506
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/index.ts
527
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/index.ts
507
528
  var init_types2 = __esm({
508
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/types/index.ts"() {
529
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/types/index.ts"() {
509
530
  "use strict";
510
531
  init_account_types();
511
532
  init_achievements_types();
@@ -513,6 +534,9 @@ var init_types2 = __esm({
513
534
  init_agent_types();
514
535
  init_agent_registry_types();
515
536
  init_runner_registry_types();
537
+ init_function_registry_types();
538
+ init_worker_registry_types();
539
+ init_call_types();
516
540
  init_blockchain_types();
517
541
  init_breakdown_types();
518
542
  init_chat_types();
@@ -537,24 +561,24 @@ var init_types2 = __esm({
537
561
  }
538
562
  });
539
563
 
540
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/BizErrorCode.ts
564
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/BizErrorCode.ts
541
565
  var init_BizErrorCode = __esm({
542
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
566
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
543
567
  "use strict";
544
568
  }
545
569
  });
546
570
 
547
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/consts.ts
571
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/consts.ts
548
572
  var init_consts = __esm({
549
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/consts.ts"() {
573
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/consts.ts"() {
550
574
  "use strict";
551
575
  }
552
576
  });
553
577
 
554
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/TopicNames.ts
578
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/TopicNames.ts
555
579
  var TopicNames, topicKindMatchers;
556
580
  var init_TopicNames = __esm({
557
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
581
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
558
582
  "use strict";
559
583
  init_types2();
560
584
  TopicNames = class _TopicNames {
@@ -640,18 +664,18 @@ var init_TopicNames = __esm({
640
664
  }
641
665
  });
642
666
 
643
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/OSSKeys.ts
667
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/OSSKeys.ts
644
668
  var init_OSSKeys = __esm({
645
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
669
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
646
670
  "use strict";
647
671
  init_consts();
648
672
  }
649
673
  });
650
674
 
651
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
675
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
652
676
  var openAICoral, openAIAsh, openAIBallad, openAINova, openAIVerse;
653
677
  var init_CompanionProfiles = __esm({
654
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
678
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
655
679
  "use strict";
656
680
  init_types2();
657
681
  openAICoral = createVoice({
@@ -686,9 +710,9 @@ var init_CompanionProfiles = __esm({
686
710
  }
687
711
  });
688
712
 
689
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/index.ts
713
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/index.ts
690
714
  var init_config = __esm({
691
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/config/index.ts"() {
715
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/config/index.ts"() {
692
716
  "use strict";
693
717
  init_BizErrorCode();
694
718
  init_consts();
@@ -698,9 +722,9 @@ var init_config = __esm({
698
722
  }
699
723
  });
700
724
 
701
- // node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/index.ts
725
+ // node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/index.ts
702
726
  var init_src = __esm({
703
- "node_modules/.pnpm/@pmate+meta@1.1.15/node_modules/@pmate/meta/src/index.ts"() {
727
+ "node_modules/.pnpm/@pmate+meta@1.3.0/node_modules/@pmate/meta/src/index.ts"() {
704
728
  "use strict";
705
729
  init_types2();
706
730
  init_config();
@@ -8858,52 +8882,52 @@ var init_AgentClient = __esm({
8858
8882
  await this.lease.connection.authenticate(timeoutMs);
8859
8883
  return true;
8860
8884
  }
8861
- async prompt(request) {
8885
+ async prompt(request2) {
8862
8886
  return this.runInternal({
8863
- agentId: request.agentId,
8864
- payload: request.payload
8887
+ agentId: request2.agentId,
8888
+ payload: request2.payload
8865
8889
  });
8866
8890
  }
8867
- async promptMany(request) {
8868
- return mapWithConcurrency(request.requests, request.concurrency ?? 10, (item) => this.prompt(item));
8891
+ async promptMany(request2) {
8892
+ return mapWithConcurrency(request2.requests, request2.concurrency ?? 10, (item) => this.prompt(item));
8869
8893
  }
8870
- async submitPromptBatch(request) {
8894
+ async submitPromptBatch(request2) {
8871
8895
  return requireBatchResponse(await this.runInternal({
8872
- agentId: request.agentId,
8896
+ agentId: request2.agentId,
8873
8897
  payload: {
8874
8898
  __pmateLlmBatch: {
8875
8899
  operation: "submit",
8876
- items: request.items,
8877
- metadata: request.metadata
8900
+ items: request2.items,
8901
+ metadata: request2.metadata
8878
8902
  }
8879
8903
  }
8880
8904
  }));
8881
8905
  }
8882
- async getPromptBatch(request) {
8906
+ async getPromptBatch(request2) {
8883
8907
  return requireBatchResponse(await this.runInternal({
8884
- agentId: request.agentId,
8908
+ agentId: request2.agentId,
8885
8909
  payload: {
8886
8910
  __pmateLlmBatch: {
8887
8911
  operation: "get",
8888
- batchId: request.batchId
8912
+ batchId: request2.batchId
8889
8913
  }
8890
8914
  }
8891
8915
  }));
8892
8916
  }
8893
- async getPromptBatchResults(request) {
8917
+ async getPromptBatchResults(request2) {
8894
8918
  return requireBatchResponse(await this.runInternal({
8895
- agentId: request.agentId,
8919
+ agentId: request2.agentId,
8896
8920
  payload: {
8897
8921
  __pmateLlmBatch: {
8898
8922
  operation: "results",
8899
- batchId: request.batchId
8923
+ batchId: request2.batchId
8900
8924
  }
8901
8925
  }
8902
8926
  }));
8903
8927
  }
8904
- async waitPromptBatch(request) {
8905
- const pollIntervalMs = request.pollIntervalMs ?? 1e4;
8906
- const timeoutMs = request.timeoutMs ?? 24 * 60 * 60 * 1e3;
8928
+ async waitPromptBatch(request2) {
8929
+ const pollIntervalMs = request2.pollIntervalMs ?? 1e4;
8930
+ const timeoutMs = request2.timeoutMs ?? 24 * 60 * 60 * 1e3;
8907
8931
  if (!Number.isFinite(pollIntervalMs) || pollIntervalMs < 1) {
8908
8932
  throw new Error("pollIntervalMs must be a positive number");
8909
8933
  }
@@ -8912,89 +8936,89 @@ var init_AgentClient = __esm({
8912
8936
  }
8913
8937
  const deadline = Date.now() + timeoutMs;
8914
8938
  while (true) {
8915
- const batch = await this.getPromptBatch(request);
8939
+ const batch = await this.getPromptBatch(request2);
8916
8940
  if (isPromptBatchTerminal(batch.status)) {
8917
8941
  return batch;
8918
8942
  }
8919
8943
  const remainingMs = deadline - Date.now();
8920
8944
  if (remainingMs <= 0) {
8921
- throw new Error(`Timed out waiting for prompt batch "${request.batchId}"; the server-side batch was not cancelled`);
8945
+ throw new Error(`Timed out waiting for prompt batch "${request2.batchId}"; the server-side batch was not cancelled`);
8922
8946
  }
8923
8947
  await delay(Math.min(pollIntervalMs, remainingMs));
8924
8948
  }
8925
8949
  }
8926
- async promptBatch(request) {
8927
- const submitted = await this.submitPromptBatch(request);
8950
+ async promptBatch(request2) {
8951
+ const submitted = await this.submitPromptBatch(request2);
8928
8952
  const completed = await this.waitPromptBatch({
8929
- agentId: request.agentId,
8953
+ agentId: request2.agentId,
8930
8954
  batchId: submitted.id,
8931
- pollIntervalMs: request.pollIntervalMs,
8932
- timeoutMs: request.timeoutMs
8955
+ pollIntervalMs: request2.pollIntervalMs,
8956
+ timeoutMs: request2.timeoutMs
8933
8957
  });
8934
8958
  if (completed.status === "failed" || completed.status === "cancelled") {
8935
8959
  throw new Error(`Prompt batch "${completed.id}" ended with status "${completed.status}"`);
8936
8960
  }
8937
8961
  return this.getPromptBatchResults({
8938
- agentId: request.agentId,
8962
+ agentId: request2.agentId,
8939
8963
  batchId: completed.id
8940
8964
  });
8941
8965
  }
8942
- async cancelPromptBatch(request) {
8966
+ async cancelPromptBatch(request2) {
8943
8967
  return requireBatchResponse(await this.runInternal({
8944
- agentId: request.agentId,
8968
+ agentId: request2.agentId,
8945
8969
  payload: {
8946
8970
  __pmateLlmBatch: {
8947
8971
  operation: "cancel",
8948
- batchId: request.batchId
8972
+ batchId: request2.batchId
8949
8973
  }
8950
8974
  }
8951
8975
  }));
8952
8976
  }
8953
- async generateImage(request) {
8977
+ async generateImage(request2) {
8954
8978
  return this.runInternal({
8955
- agentId: request.agentId,
8956
- payload: request.payload
8979
+ agentId: request2.agentId,
8980
+ payload: request2.payload
8957
8981
  });
8958
8982
  }
8959
- async echo(request) {
8983
+ async echo(request2) {
8960
8984
  return this.runInternal({
8961
- agentId: request.agentId,
8962
- payload: request.payload
8985
+ agentId: request2.agentId,
8986
+ payload: request2.payload
8963
8987
  });
8964
8988
  }
8965
- async runInternal(request) {
8989
+ async runInternal(request2) {
8966
8990
  this.ensureReady();
8967
- const taskId = this.createTaskId(request.agentId);
8968
- const agent = await this.agentService.getAgentById(request.agentId);
8991
+ const taskId = this.createTaskId(request2.agentId);
8992
+ const agent = await this.agentService.getAgentById(request2.agentId);
8969
8993
  const hubTo = `@hub/${agent.type}`;
8970
8994
  const { waiter } = this.tasks.createTask(taskId, {
8971
8995
  timeoutMs: this.timeoutMs,
8972
8996
  failMode: "reject",
8973
8997
  onFail: (message) => {
8974
- logger5.error("Agent task failed", request.agentId, message);
8998
+ logger5.error("Agent task failed", request2.agentId, message);
8975
8999
  }
8976
9000
  });
8977
9001
  const startPayload = {
8978
9002
  taskId,
8979
- agentId: request.agentId,
9003
+ agentId: request2.agentId,
8980
9004
  op: 0 /* Start */,
8981
9005
  auth: this.auth,
8982
9006
  type: this.defaultRequestType,
8983
- ...request.payload ? { payload: request.payload } : {}
9007
+ ...request2.payload ? { payload: request2.payload } : {}
8984
9008
  };
8985
9009
  const msg = Msg.create(this.from, hubTo, 2 /* AGENT */, createAgentRequestBody(startPayload), 0 /* PIPELINE */);
8986
9010
  debugLog("[agent-client] sending agent request", {
8987
9011
  taskId,
8988
- agentId: request.agentId,
9012
+ agentId: request2.agentId,
8989
9013
  from: this.from,
8990
9014
  to: hubTo
8991
9015
  });
8992
9016
  await this.lease.connection.sendMsg(msg);
8993
9017
  return await waiter;
8994
9018
  }
8995
- stream(request) {
9019
+ stream(request2) {
8996
9020
  this.ensureReady();
8997
- const taskId = this.createTaskId(request.agentId);
9021
+ const taskId = this.createTaskId(request2.agentId);
8998
9022
  const { waiter, onProgress } = this.tasks.createTask(taskId, {
8999
9023
  timeoutMs: this.streamTimeoutMs,
9000
9024
  failMode: "reject",
@@ -9002,10 +9026,10 @@ var init_AgentClient = __esm({
9002
9026
  });
9003
9027
  const from = this.from;
9004
9028
  const connection = this.lease.connection;
9005
- const minChunkSizeBytes = request.minChunkSizeBytes ?? this.minChunkSizeBytes;
9006
- const inputStream = minChunkSizeBytes > 0 ? AsyncStream.chunkBlob(request.stream, {
9029
+ const minChunkSizeBytes = request2.minChunkSizeBytes ?? this.minChunkSizeBytes;
9030
+ const inputStream = minChunkSizeBytes > 0 ? AsyncStream.chunkBlob(request2.stream, {
9007
9031
  minBytes: minChunkSizeBytes
9008
- }) : request.stream;
9032
+ }) : request2.stream;
9009
9033
  const outputStream = new AsyncStream();
9010
9034
  onProgress((data) => {
9011
9035
  outputStream.push({ type: "progress", data });
@@ -9037,22 +9061,22 @@ var init_AgentClient = __esm({
9037
9061
  outputStream.error(err2);
9038
9062
  });
9039
9063
  const startDataStream = async () => {
9040
- const agent = await this.agentService.getAgentById(request.agentId);
9064
+ const agent = await this.agentService.getAgentById(request2.agentId);
9041
9065
  const hubTo = `@hub/${agent.type}`;
9042
9066
  const startMsg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody({
9043
9067
  taskId,
9044
- agentId: request.agentId,
9068
+ agentId: request2.agentId,
9045
9069
  op: 0 /* Start */,
9046
9070
  auth: this.auth,
9047
9071
  type: this.defaultRequestType,
9048
- ...request.params ? { payload: request.params } : {}
9072
+ ...request2.params ? { payload: request2.params } : {}
9049
9073
  }), 0 /* PIPELINE */);
9050
9074
  await connection.sendMsg(startMsg);
9051
9075
  for await (const payload of inputStream) {
9052
9076
  const dataType = payload instanceof Blob ? payload.type || this.defaultBinaryType : payload instanceof Uint8Array || payload instanceof ArrayBuffer ? this.defaultBinaryType : typeof payload === "string" ? "text" : this.defaultRequestType;
9053
9077
  const body = {
9054
9078
  taskId,
9055
- agentId: request.agentId,
9079
+ agentId: request2.agentId,
9056
9080
  op: 1 /* Data */,
9057
9081
  auth: this.auth,
9058
9082
  type: dataType,
@@ -9063,7 +9087,7 @@ var init_AgentClient = __esm({
9063
9087
  }
9064
9088
  const endMsg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody({
9065
9089
  taskId,
9066
- agentId: request.agentId,
9090
+ agentId: request2.agentId,
9067
9091
  op: 2 /* End */,
9068
9092
  auth: this.auth,
9069
9093
  type: this.defaultRequestType
@@ -9466,8 +9490,8 @@ __export(index_exports, {
9466
9490
  parseCommandArgs: () => parseCommandArgs
9467
9491
  });
9468
9492
  module.exports = __toCommonJS(index_exports);
9469
- var import_node_fs26 = require("fs");
9470
- var import_node_path31 = __toESM(require("path"));
9493
+ var import_node_fs28 = require("fs");
9494
+ var import_node_path33 = __toESM(require("path"));
9471
9495
  var import_chalk4 = __toESM(require("chalk"));
9472
9496
 
9473
9497
  // src/cli.ts
@@ -10257,8 +10281,8 @@ var LoginCommandHandler = class {
10257
10281
  rejectToken = reject;
10258
10282
  });
10259
10283
  const openSockets = /* @__PURE__ */ new Set();
10260
- const server = (0, import_node_http.createServer)((request, response) => {
10261
- this.handleCallbackRequest(request, response, resolveToken, rejectToken);
10284
+ const server = (0, import_node_http.createServer)((request2, response) => {
10285
+ this.handleCallbackRequest(request2, response, resolveToken, rejectToken);
10262
10286
  });
10263
10287
  server.on("connection", (socket) => {
10264
10288
  openSockets.add(socket);
@@ -10301,8 +10325,8 @@ var LoginCommandHandler = class {
10301
10325
  close
10302
10326
  };
10303
10327
  }
10304
- handleCallbackRequest(request, response, resolveToken, rejectToken) {
10305
- const url = new URL(request.url || "/", "http://127.0.0.1");
10328
+ handleCallbackRequest(request2, response, resolveToken, rejectToken) {
10329
+ const url = new URL(request2.url || "/", "http://127.0.0.1");
10306
10330
  if (url.pathname !== CALLBACK_PATH) {
10307
10331
  response.statusCode = 404;
10308
10332
  response.end("Not found");
@@ -10581,14 +10605,14 @@ var AliyunService = class {
10581
10605
  regionId: userConfig.aliyun?.region?.trim() || "cn-hangzhou"
10582
10606
  });
10583
10607
  const client = new import_alidns20150109.default(sdkConfig);
10584
- const request = new import_alidns20150109.AddDomainRecordRequest({
10608
+ const request2 = new import_alidns20150109.AddDomainRecordRequest({
10585
10609
  domainName: input.domainName,
10586
10610
  RR: input.rr,
10587
10611
  type: input.type,
10588
10612
  value: input.value,
10589
10613
  TTL: input.ttl ?? 600
10590
10614
  });
10591
- await client.addDomainRecord(request);
10615
+ await client.addDomainRecord(request2);
10592
10616
  }
10593
10617
  /** Get existing CNAME record value for an RR, if any. */
10594
10618
  static async getCnameRecordValue(domainName, rr) {
@@ -10603,14 +10627,14 @@ var AliyunService = class {
10603
10627
  regionId: userConfig.aliyun?.region?.trim() || "cn-hangzhou"
10604
10628
  });
10605
10629
  const client = new import_alidns20150109.default(sdkConfig);
10606
- const request = new import_alidns20150109.DescribeDomainRecordsRequest({
10630
+ const request2 = new import_alidns20150109.DescribeDomainRecordsRequest({
10607
10631
  domainName,
10608
10632
  RRKeyWord: rr,
10609
10633
  type: "CNAME",
10610
10634
  searchMode: "ADVANCED",
10611
10635
  pageSize: 500
10612
10636
  });
10613
- const response = await client.describeDomainRecords(request);
10637
+ const response = await client.describeDomainRecords(request2);
10614
10638
  const records = response.body?.domainRecords?.record ?? [];
10615
10639
  const normalizedRr = rr.toLowerCase();
10616
10640
  const match = records.find(
@@ -10631,14 +10655,14 @@ var AliyunService = class {
10631
10655
  regionId: userConfig.aliyun?.region?.trim() || "cn-hangzhou"
10632
10656
  });
10633
10657
  const client = new import_alidns20150109.default(sdkConfig);
10634
- const request = new import_alidns20150109.DescribeDomainRecordsRequest({
10658
+ const request2 = new import_alidns20150109.DescribeDomainRecordsRequest({
10635
10659
  domainName,
10636
10660
  RRKeyWord: rr,
10637
10661
  type: "A",
10638
10662
  searchMode: "ADVANCED",
10639
10663
  pageSize: 500
10640
10664
  });
10641
- const response = await client.describeDomainRecords(request);
10665
+ const response = await client.describeDomainRecords(request2);
10642
10666
  const records = response.body?.domainRecords?.record ?? [];
10643
10667
  const normalizedRr = rr.toLowerCase();
10644
10668
  const match = records.find(
@@ -10659,14 +10683,14 @@ var AliyunService = class {
10659
10683
  regionId: userConfig.aliyun?.region?.trim() || "cn-hangzhou"
10660
10684
  });
10661
10685
  const client = new import_alidns20150109.default(sdkConfig);
10662
- const request = new import_alidns20150109.DescribeDomainRecordsRequest({
10686
+ const request2 = new import_alidns20150109.DescribeDomainRecordsRequest({
10663
10687
  domainName: input.domainName,
10664
10688
  RRKeyWord: input.rr,
10665
10689
  type: input.type,
10666
10690
  searchMode: "ADVANCED",
10667
10691
  pageSize: 500
10668
10692
  });
10669
- const response = await client.describeDomainRecords(request);
10693
+ const response = await client.describeDomainRecords(request2);
10670
10694
  const records = response.body?.domainRecords?.record ?? [];
10671
10695
  const normalizedRr = input.rr.toLowerCase();
10672
10696
  const normalizedType = input.type.toUpperCase();
@@ -10893,19 +10917,19 @@ var AliyunService = class {
10893
10917
  weight: "10"
10894
10918
  }
10895
10919
  ]);
10896
- const request = new import_cdn20180510.AddCdnDomainRequest({
10920
+ const request2 = new import_cdn20180510.AddCdnDomainRequest({
10897
10921
  domainName,
10898
10922
  cdnType: "web",
10899
10923
  sources
10900
10924
  });
10901
- await client.addCdnDomain(request);
10925
+ await client.addCdnDomain(request2);
10902
10926
  ui.success(`CDN domain created: ${domainName}`);
10903
10927
  }
10904
10928
  /** Fetch the CDN CNAME for a domain. */
10905
10929
  static async getCdnCname(domainName) {
10906
10930
  const client = this.createCdnClient();
10907
- const request = new import_cdn20180510.DescribeDomainCnameRequest({ domainName });
10908
- const response = await client.describeDomainCname(request);
10931
+ const request2 = new import_cdn20180510.DescribeDomainCnameRequest({ domainName });
10932
+ const response = await client.describeDomainCname(request2);
10909
10933
  const data = response.body?.cnameDatas?.data ?? [];
10910
10934
  const match = data.find((item) => item?.domain === domainName) ?? data[0];
10911
10935
  return match?.cname;
@@ -10936,7 +10960,7 @@ var AliyunService = class {
10936
10960
  static async refreshCdnSslCertificate(domainName, certKey = DEFAULT_SSL_CERT_KEY) {
10937
10961
  const client = this.createCdnClient();
10938
10962
  const cert = resolveSslCert(certKey);
10939
- const request = new import_cdn20180510.SetCdnDomainSSLCertificateRequest({
10963
+ const request2 = new import_cdn20180510.SetCdnDomainSSLCertificateRequest({
10940
10964
  domainName,
10941
10965
  certType: "cas",
10942
10966
  certName: cert.certName,
@@ -10944,7 +10968,7 @@ var AliyunService = class {
10944
10968
  certRegion: cert.certRegion,
10945
10969
  SSLProtocol: "on"
10946
10970
  });
10947
- await client.setCdnDomainSSLCertificate(request);
10971
+ await client.setCdnDomainSSLCertificate(request2);
10948
10972
  }
10949
10973
  /** Configure a CDN 403 error page for SPA fallback. */
10950
10974
  static async enableSpa404Fallback(domainName) {
@@ -10961,11 +10985,11 @@ var AliyunService = class {
10961
10985
  ]
10962
10986
  }
10963
10987
  ]);
10964
- const request = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
10988
+ const request2 = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
10965
10989
  domainNames: domainName,
10966
10990
  functions
10967
10991
  });
10968
- await client.batchSetCdnDomainConfig(request);
10992
+ await client.batchSetCdnDomainConfig(request2);
10969
10993
  }
10970
10994
  /** Enable SPA rewrite rule for CDN. */
10971
10995
  static async enableSpaRewriteRule(domainName) {
@@ -10983,11 +11007,11 @@ var AliyunService = class {
10983
11007
  ]
10984
11008
  }
10985
11009
  ]);
10986
- const request = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11010
+ const request2 = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
10987
11011
  domainNames: domainName,
10988
11012
  functions
10989
11013
  });
10990
- await client.batchSetCdnDomainConfig(request);
11014
+ await client.batchSetCdnDomainConfig(request2);
10991
11015
  }
10992
11016
  /** Enable SSG rewrite rule for CDN. */
10993
11017
  static async enableSsgRewriteRule(domainName) {
@@ -11005,11 +11029,11 @@ var AliyunService = class {
11005
11029
  ]
11006
11030
  }
11007
11031
  ]);
11008
- const request = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11032
+ const request2 = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11009
11033
  domainNames: domainName,
11010
11034
  functions
11011
11035
  });
11012
- await client.batchSetCdnDomainConfig(request);
11036
+ await client.batchSetCdnDomainConfig(request2);
11013
11037
  }
11014
11038
  /** Enable OSS private bucket origin auth for CDN. */
11015
11039
  static async enableOssPrivateBucketOrigin(domainName) {
@@ -11020,11 +11044,11 @@ var AliyunService = class {
11020
11044
  functionArgs: [{ argName: "private_oss_auth", argValue: "on" }]
11021
11045
  }
11022
11046
  ]);
11023
- const request = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11047
+ const request2 = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11024
11048
  domainNames: domainName,
11025
11049
  functions
11026
11050
  });
11027
- await client.batchSetCdnDomainConfig(request);
11051
+ await client.batchSetCdnDomainConfig(request2);
11028
11052
  }
11029
11053
  /** Configure default cache rules for CDN. */
11030
11054
  static async setDefaultCacheRules(domainName) {
@@ -11071,11 +11095,11 @@ var AliyunService = class {
11071
11095
  ]
11072
11096
  }
11073
11097
  ]);
11074
- const request = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11098
+ const request2 = new import_cdn20180510.BatchSetCdnDomainConfigRequest({
11075
11099
  domainNames: domainName,
11076
11100
  functions
11077
11101
  });
11078
- await client.batchSetCdnDomainConfig(request);
11102
+ await client.batchSetCdnDomainConfig(request2);
11079
11103
  }
11080
11104
  /** Check if an OSS bucket exists. */
11081
11105
  static async bucketExists(client, bucketName) {
@@ -11103,8 +11127,8 @@ var AliyunService = class {
11103
11127
  }
11104
11128
  /** Check CDN domain status. */
11105
11129
  static async getCdnDomainStatus(client, domainName) {
11106
- const request = new import_cdn20180510.CheckCdnDomainExistRequest({ domainName });
11107
- const response = await client.checkCdnDomainExist(request);
11130
+ const request2 = new import_cdn20180510.CheckCdnDomainExistRequest({ domainName });
11131
+ const response = await client.checkCdnDomainExist(request2);
11108
11132
  return response.body?.status;
11109
11133
  }
11110
11134
  /** Build the OSS regional domain for a bucket. */
@@ -14896,9 +14920,9 @@ ${indent}\`\`\``;
14896
14920
  static richTextToPlain(richText) {
14897
14921
  return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
14898
14922
  }
14899
- static async requestJson(path32, init) {
14923
+ static async requestJson(path34, init) {
14900
14924
  const token = this.getToken();
14901
- const response = await fetch(`${this.baseUrl}${path32}`, {
14925
+ const response = await fetch(`${this.baseUrl}${path34}`, {
14902
14926
  method: init.method,
14903
14927
  headers: {
14904
14928
  Authorization: `Bearer ${token}`,
@@ -17494,8 +17518,8 @@ function descriptorPathSegments(descriptor) {
17494
17518
  return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
17495
17519
  }
17496
17520
  function buildPathUrl(baseUrl, pathSegments, query) {
17497
- const path32 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
17498
- const url = new URL(path32, baseUrl);
17521
+ const path34 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
17522
+ const url = new URL(path34, baseUrl);
17499
17523
  if (query) {
17500
17524
  for (const [key, value] of Object.entries(query)) {
17501
17525
  url.searchParams.set(key, String(value));
@@ -18237,6 +18261,284 @@ var RunnerCommandHandler = class {
18237
18261
  }
18238
18262
  };
18239
18263
 
18264
+ // src/commands/RegistryResourceCommandHandler.ts
18265
+ var import_node_fs17 = require("fs");
18266
+ var import_node_path22 = __toESM(require("path"));
18267
+ init_sessionStore();
18268
+ var RegistryResourceCommandHandler = class {
18269
+ async handle(args) {
18270
+ const resource = args.type === "function" ? "functions" : "workers";
18271
+ const singular = args.type === "function" ? "Function" : "Worker";
18272
+ const baseUrl = (args.baseUrl || process.env.PMATE_AGENT_API_BASE_URL || "https://agent-api.pmate.chat").replace(/\/+$/, "");
18273
+ const token = readRequiredSession({ preferredApp: DEFAULT_APP_ID }).token;
18274
+ if (args.action === "list") {
18275
+ const query = args.namespace ? `?namespace=${encodeURIComponent(args.namespace)}` : "";
18276
+ const { items } = await request(baseUrl, token, "GET", `/v1/${resource}${query}`);
18277
+ if (args.json) ui.plain(JSON.stringify(items, null, 2));
18278
+ else if (!items.length) ui.warn(`No ${resource} found.`);
18279
+ else for (const item of items) ui.info(item.id, { status: item.status, ...item.payload });
18280
+ return;
18281
+ }
18282
+ const resourcePath = `/v1/${resource}/${encodeURIComponent(args.namespace)}${args.action === "create" ? "" : `/${encodeURIComponent(args.name)}`}`;
18283
+ if (args.action === "get" || args.action === "view") {
18284
+ const record2 = await request(baseUrl, token, "GET", resourcePath);
18285
+ ui.plain(JSON.stringify(record2, null, 2));
18286
+ return;
18287
+ }
18288
+ if (args.action === "create" || args.action === "update") {
18289
+ const payload = readJson(args.filePath);
18290
+ const record2 = await request(baseUrl, token, args.action === "create" ? "POST" : "PUT", resourcePath, payload);
18291
+ ui.success(`${args.action === "create" ? "Created" : "Updated"} ${singular.toLowerCase()} ${record2.id}`);
18292
+ if (args.json) ui.plain(JSON.stringify(record2, null, 2));
18293
+ return;
18294
+ }
18295
+ const record = await request(baseUrl, token, "DELETE", resourcePath);
18296
+ ui.success(`Disabled ${singular.toLowerCase()} ${record.id}`);
18297
+ if (args.json) ui.plain(JSON.stringify(record, null, 2));
18298
+ }
18299
+ };
18300
+ function readJson(filePath) {
18301
+ const absolutePath = import_node_path22.default.resolve(process.cwd(), filePath);
18302
+ if (!(0, import_node_fs17.existsSync)(absolutePath)) throw new Error(`JSON file not found: ${absolutePath}`);
18303
+ return JSON.parse((0, import_node_fs17.readFileSync)(absolutePath, "utf8"));
18304
+ }
18305
+ async function request(baseUrl, token, method, pathname, body) {
18306
+ const response = await fetch(`${baseUrl}${pathname}`, {
18307
+ method,
18308
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
18309
+ ...body === void 0 ? {} : { body: JSON.stringify(body) }
18310
+ });
18311
+ const payload = await response.json();
18312
+ if (!response.ok || !payload.success) throw new Error(payload.message || `Request failed with status ${response.status}`);
18313
+ return payload.data;
18314
+ }
18315
+
18316
+ // src/commands/CallCommandHandler.ts
18317
+ var import_node_fs18 = require("fs");
18318
+ var import_node_path23 = __toESM(require("path"));
18319
+
18320
+ // node_modules/.pnpm/@pmate+hub-sdk@0.2.1/node_modules/@pmate/hub-sdk/dist/HubClient.js
18321
+ init_src();
18322
+ init_src3();
18323
+ var DEFAULT_TIMEOUT_MS2 = 4e4;
18324
+ var HubClient = class {
18325
+ options;
18326
+ ws;
18327
+ profileId;
18328
+ token;
18329
+ authenticated = false;
18330
+ calls = /* @__PURE__ */ new Map();
18331
+ timeoutMs;
18332
+ connectWaiter;
18333
+ authWaiter;
18334
+ constructor(options) {
18335
+ this.options = options;
18336
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
18337
+ }
18338
+ async login(options) {
18339
+ this.close();
18340
+ this.profileId = options.profileId;
18341
+ this.token = options.token;
18342
+ this.connectWaiter = deferred();
18343
+ this.authWaiter = deferred();
18344
+ const ws = new WebsocketClientV2(ensureWsProtocol(this.options.baseUrl));
18345
+ this.ws = ws;
18346
+ const stream = ws.getStream();
18347
+ void this.consume(stream);
18348
+ const timeoutMs = options.timeoutMs ?? this.timeoutMs;
18349
+ await withTimeout(this.connectWaiter.promise, timeoutMs, "Hub connection timed out");
18350
+ await ws.sendMsg(Msg.create(options.profileId, "@hub", 4 /* AUTH */, {
18351
+ token: options.token,
18352
+ as: "user",
18353
+ profileId: options.profileId
18354
+ }, 0 /* PIPELINE */));
18355
+ await withTimeout(this.authWaiter.promise, timeoutMs, "Hub authentication timed out");
18356
+ this.authenticated = true;
18357
+ }
18358
+ async call(request2) {
18359
+ if (!this.ws || !this.profileId || !this.token || !this.authenticated) {
18360
+ throw new Error("HubClient is not logged in");
18361
+ }
18362
+ const callId = createCallId(request2.functionId);
18363
+ const timeoutMs = request2.timeoutMs ?? this.timeoutMs;
18364
+ const result = new Promise((resolve, reject) => {
18365
+ const timer = setTimeout(() => {
18366
+ this.calls.delete(callId);
18367
+ reject(new Error(`Function call timed out: ${request2.functionId}`));
18368
+ }, timeoutMs);
18369
+ this.calls.set(callId, {
18370
+ resolve,
18371
+ reject,
18372
+ timer
18373
+ });
18374
+ });
18375
+ const body = {
18376
+ kind: "request",
18377
+ callId,
18378
+ functionId: request2.functionId,
18379
+ input: request2.input,
18380
+ auth: { token: this.token, profileId: this.profileId },
18381
+ idempotencyKey: request2.idempotencyKey,
18382
+ timeoutMs
18383
+ };
18384
+ try {
18385
+ await this.ws.sendMsg(Msg.create(this.profileId, "@hub", 6 /* CALL */, body, 0 /* PIPELINE */));
18386
+ } catch (error) {
18387
+ this.rejectCall(callId, error instanceof Error ? error : new Error(String(error)));
18388
+ }
18389
+ return result;
18390
+ }
18391
+ close() {
18392
+ this.ws?.close();
18393
+ this.ws = void 0;
18394
+ this.authenticated = false;
18395
+ this.token = void 0;
18396
+ this.connectWaiter?.reject(new Error("HubClient closed before connection completed"));
18397
+ this.authWaiter?.reject(new Error("HubClient closed before authentication completed"));
18398
+ this.connectWaiter = void 0;
18399
+ this.authWaiter = void 0;
18400
+ for (const callId of this.calls.keys()) {
18401
+ this.rejectCall(callId, new Error("HubClient closed before call completed"));
18402
+ }
18403
+ }
18404
+ async consume(stream) {
18405
+ try {
18406
+ for await (const event of stream) {
18407
+ this.handleEvent(event);
18408
+ }
18409
+ } catch (error) {
18410
+ const failure = error instanceof Error ? error : new Error(String(error));
18411
+ this.connectWaiter?.reject(failure);
18412
+ this.authWaiter?.reject(failure);
18413
+ for (const callId of this.calls.keys()) {
18414
+ this.rejectCall(callId, failure);
18415
+ }
18416
+ }
18417
+ }
18418
+ handleEvent(event) {
18419
+ if (event.type === "connected") {
18420
+ if (event.data)
18421
+ this.connectWaiter?.resolve();
18422
+ else
18423
+ this.authenticated = false;
18424
+ return;
18425
+ }
18426
+ if (event.type === "error") {
18427
+ const failure = new Error("Hub websocket connection failed");
18428
+ this.connectWaiter?.reject(failure);
18429
+ this.authWaiter?.reject(failure);
18430
+ return;
18431
+ }
18432
+ if (event.type === "message")
18433
+ this.handleMessage(event.data);
18434
+ }
18435
+ handleMessage(message) {
18436
+ if (message.opcode === 3 /* ACK */) {
18437
+ const ack = message.body;
18438
+ if (ack.status === "ok")
18439
+ this.authWaiter?.resolve();
18440
+ else
18441
+ this.authWaiter?.reject(new Error(ack.message ?? ack.code ?? "Hub authentication failed"));
18442
+ return;
18443
+ }
18444
+ if (message.opcode !== 6 /* CALL */)
18445
+ return;
18446
+ const body = message.body;
18447
+ if (body?.kind !== "response")
18448
+ return;
18449
+ this.handleResponse(body);
18450
+ }
18451
+ handleResponse(body) {
18452
+ if (body.status === "pending" || body.status === "running")
18453
+ return;
18454
+ const call = this.calls.get(body.callId);
18455
+ if (!call)
18456
+ return;
18457
+ clearTimeout(call.timer);
18458
+ this.calls.delete(body.callId);
18459
+ if (body.status === "completed") {
18460
+ call.resolve(body.output);
18461
+ return;
18462
+ }
18463
+ call.reject(new Error(body.error?.message ?? `Function call ${body.status}`));
18464
+ }
18465
+ rejectCall(callId, error) {
18466
+ const call = this.calls.get(callId);
18467
+ if (!call)
18468
+ return;
18469
+ clearTimeout(call.timer);
18470
+ this.calls.delete(callId);
18471
+ call.reject(error);
18472
+ }
18473
+ };
18474
+ function createCallId(functionId) {
18475
+ return uniqHash(`${functionId}-${Date.now()}-${Math.random()}`, "task-v1" /* Task */);
18476
+ }
18477
+ function ensureWsProtocol(baseUrl) {
18478
+ if (/^wss?:\/\//i.test(baseUrl))
18479
+ return baseUrl;
18480
+ if (/^https:\/\//i.test(baseUrl))
18481
+ return baseUrl.replace(/^https:/i, "wss:");
18482
+ if (/^http:\/\//i.test(baseUrl))
18483
+ return baseUrl.replace(/^http:/i, "ws:");
18484
+ return `wss://${baseUrl}`;
18485
+ }
18486
+ function deferred() {
18487
+ let resolve;
18488
+ let reject;
18489
+ const promise = new Promise((resolvePromise, rejectPromise) => {
18490
+ resolve = resolvePromise;
18491
+ reject = rejectPromise;
18492
+ });
18493
+ return { promise, resolve, reject };
18494
+ }
18495
+ function withTimeout(promise, timeoutMs, message) {
18496
+ return new Promise((resolve, reject) => {
18497
+ const timer = setTimeout(() => reject(new Error(message)), timeoutMs);
18498
+ promise.then((value) => {
18499
+ clearTimeout(timer);
18500
+ resolve(value);
18501
+ }, (error) => {
18502
+ clearTimeout(timer);
18503
+ reject(error);
18504
+ });
18505
+ });
18506
+ }
18507
+
18508
+ // src/commands/CallCommandHandler.ts
18509
+ init_sessionStore();
18510
+ var CallCommandHandler = class {
18511
+ async handle(args) {
18512
+ const session = readRequiredSession({ preferredApp: DEFAULT_APP_ID });
18513
+ const hub = new HubClient({
18514
+ baseUrl: args.hubBaseUrl || process.env.PMATE_HUB_BASE_URL || "https://hub.pmate.chat",
18515
+ timeoutMs: args.timeoutMs
18516
+ });
18517
+ const input = args.filePath ? readJson2(args.filePath) : args.payload;
18518
+ try {
18519
+ await hub.login({ token: session.token, profileId: session.profileId, timeoutMs: args.timeoutMs });
18520
+ const output = await hub.call({
18521
+ functionId: `${args.namespace}:${args.name}`,
18522
+ input,
18523
+ timeoutMs: args.timeoutMs
18524
+ });
18525
+ if (args.json || typeof output !== "string") ui.plain(JSON.stringify(output ?? null, null, 2));
18526
+ else ui.plain(output);
18527
+ } finally {
18528
+ hub.close();
18529
+ }
18530
+ }
18531
+ };
18532
+ function readJson2(filePath) {
18533
+ const absolutePath = import_node_path23.default.resolve(process.cwd(), filePath);
18534
+ if (!(0, import_node_fs18.existsSync)(absolutePath)) throw new Error(`JSON file not found: ${absolutePath}`);
18535
+ const decoded = JSON.parse((0, import_node_fs18.readFileSync)(absolutePath, "utf8"));
18536
+ if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) {
18537
+ throw new Error("Call input file must contain a JSON object");
18538
+ }
18539
+ return decoded;
18540
+ }
18541
+
18240
18542
  // src/commands/NsCommandHandler.ts
18241
18543
  init_sessionStore();
18242
18544
  var NsCommandHandler = class {
@@ -18303,8 +18605,8 @@ var NsCommandHandler = class {
18303
18605
  };
18304
18606
 
18305
18607
  // src/commands/StoreCommandHandler.ts
18306
- var import_node_fs17 = require("fs");
18307
- var import_node_path22 = __toESM(require("path"));
18608
+ var import_node_fs19 = require("fs");
18609
+ var import_node_path24 = __toESM(require("path"));
18308
18610
  init_sessionStore();
18309
18611
  var StoreCommandHandler = class {
18310
18612
  async handle(args) {
@@ -18458,11 +18760,11 @@ var StoreCommandHandler = class {
18458
18760
  return payload.data ?? [];
18459
18761
  }
18460
18762
  readJsonFile(filePath) {
18461
- const absolutePath = import_node_path22.default.resolve(process.cwd(), filePath);
18462
- if (!(0, import_node_fs17.existsSync)(absolutePath)) {
18763
+ const absolutePath = import_node_path24.default.resolve(process.cwd(), filePath);
18764
+ if (!(0, import_node_fs19.existsSync)(absolutePath)) {
18463
18765
  throw new Error(`JSON file not found: ${absolutePath}`);
18464
18766
  }
18465
- const raw = (0, import_node_fs17.readFileSync)(absolutePath, "utf8");
18767
+ const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
18466
18768
  try {
18467
18769
  return JSON.parse(raw);
18468
18770
  } catch (error) {
@@ -18514,14 +18816,14 @@ var StoreCommandHandler = class {
18514
18816
  };
18515
18817
 
18516
18818
  // src/commands/AppCommandHandler.ts
18517
- var import_node_fs19 = require("fs");
18518
- var import_node_path24 = __toESM(require("path"));
18819
+ var import_node_fs21 = require("fs");
18820
+ var import_node_path26 = __toESM(require("path"));
18519
18821
  init_sessionStore();
18520
18822
 
18521
18823
  // src/appIcon.ts
18522
- var import_node_fs18 = require("fs");
18824
+ var import_node_fs20 = require("fs");
18523
18825
  var import_node_os8 = __toESM(require("os"));
18524
- var import_node_path23 = __toESM(require("path"));
18826
+ var import_node_path25 = __toESM(require("path"));
18525
18827
  var import_sharp = __toESM(require("sharp"));
18526
18828
  init_namespacedRef();
18527
18829
  var ANDROID_ICON_SPECS = [
@@ -18626,13 +18928,13 @@ function createAppIconExportPlans(input) {
18626
18928
  if (!input.outDir) {
18627
18929
  throw new Error("App icon preset export requires --out-dir.");
18628
18930
  }
18629
- const outDir = import_node_path23.default.resolve(input.cwd, input.outDir);
18630
- (0, import_node_fs18.mkdirSync)(outDir, { recursive: true });
18931
+ const outDir = import_node_path25.default.resolve(input.cwd, input.outDir);
18932
+ (0, import_node_fs20.mkdirSync)(outDir, { recursive: true });
18631
18933
  return specs.map((spec) => ({
18632
18934
  width: spec.width,
18633
18935
  height: spec.height,
18634
18936
  format: "png",
18635
- outputPath: import_node_path23.default.join(
18937
+ outputPath: import_node_path25.default.join(
18636
18938
  outDir,
18637
18939
  `${namespace}-${objectId}-${spec.name}-${spec.width}x${spec.height}.png`
18638
18940
  )
@@ -18645,8 +18947,8 @@ function createAppIconExportPlans(input) {
18645
18947
  if (!input.output) {
18646
18948
  throw new Error("Single-size app icon export requires --output.");
18647
18949
  }
18648
- const resolvedOutput = import_node_path23.default.resolve(input.cwd, input.output);
18649
- (0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(resolvedOutput), { recursive: true });
18950
+ const resolvedOutput = import_node_path25.default.resolve(input.cwd, input.output);
18951
+ (0, import_node_fs20.mkdirSync)(import_node_path25.default.dirname(resolvedOutput), { recursive: true });
18650
18952
  return [
18651
18953
  {
18652
18954
  width: input.width,
@@ -18660,7 +18962,7 @@ async function exportAppIcon(icon, plans) {
18660
18962
  const svg = await resolveAppIconSvg(icon);
18661
18963
  for (const plan of plans) {
18662
18964
  const bytes = await renderAppIcon(svg, plan.width, plan.height, plan.format);
18663
- (0, import_node_fs18.writeFileSync)(plan.outputPath, bytes);
18965
+ (0, import_node_fs20.writeFileSync)(plan.outputPath, bytes);
18664
18966
  }
18665
18967
  }
18666
18968
  async function renderAppIconVariant(input) {
@@ -18668,9 +18970,9 @@ async function renderAppIconVariant(input) {
18668
18970
  const bytes = await renderAppIcon(svg, input.width, input.height, input.format);
18669
18971
  let outputPath;
18670
18972
  if (input.output) {
18671
- outputPath = import_node_path23.default.resolve(input.cwd, input.output);
18672
- (0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(outputPath), { recursive: true });
18673
- (0, import_node_fs18.writeFileSync)(outputPath, bytes);
18973
+ outputPath = import_node_path25.default.resolve(input.cwd, input.output);
18974
+ (0, import_node_fs20.mkdirSync)(import_node_path25.default.dirname(outputPath), { recursive: true });
18975
+ (0, import_node_fs20.writeFileSync)(outputPath, bytes);
18674
18976
  }
18675
18977
  if (input.name) {
18676
18978
  return {
@@ -18691,7 +18993,7 @@ async function renderAppIconVariant(input) {
18691
18993
  };
18692
18994
  }
18693
18995
  async function loadAppIconVariantFile(input) {
18694
- const absolutePath = import_node_path23.default.resolve(input.cwd, input.filePath);
18996
+ const absolutePath = import_node_path25.default.resolve(input.cwd, input.filePath);
18695
18997
  const format = inferVariantFormatFromPath(absolutePath);
18696
18998
  return {
18697
18999
  value: input.name ? await uploadAppIconVariantAsset({
@@ -18700,7 +19002,7 @@ async function loadAppIconVariantFile(input) {
18700
19002
  name: input.name,
18701
19003
  format,
18702
19004
  sourcePath: absolutePath
18703
- }) : createImageDataUrl((0, import_node_fs18.readFileSync)(absolutePath), format),
19005
+ }) : createImageDataUrl((0, import_node_fs20.readFileSync)(absolutePath), format),
18704
19006
  format,
18705
19007
  absolutePath
18706
19008
  };
@@ -18759,7 +19061,7 @@ function shouldAutoGenerateDefaultVariant(icon) {
18759
19061
  return looksLikeSvgMarkup(icon) || looksLikeSvgUrl(icon);
18760
19062
  }
18761
19063
  function inferVariantFormatFromPath(filePath) {
18762
- const ext = import_node_path23.default.extname(filePath).toLowerCase();
19064
+ const ext = import_node_path25.default.extname(filePath).toLowerCase();
18763
19065
  switch (ext) {
18764
19066
  case ".png":
18765
19067
  return "png";
@@ -18830,13 +19132,13 @@ async function uploadAppIconVariantAsset(input) {
18830
19132
  await AliyunService.uploadFile(sourcePath, DEFAULT_APP_ICON_VARIANT_BUCKET, objectKey);
18831
19133
  } finally {
18832
19134
  if (shouldCleanup) {
18833
- (0, import_node_fs18.rmSync)(import_node_path23.default.dirname(sourcePath), { recursive: true, force: true });
19135
+ (0, import_node_fs20.rmSync)(import_node_path25.default.dirname(sourcePath), { recursive: true, force: true });
18834
19136
  }
18835
19137
  }
18836
19138
  return `${DEFAULT_APP_ICON_VARIANT_PUBLIC_BASE_URL}/${objectKey}`;
18837
19139
  }
18838
19140
  function buildAppIconVariantObjectKey(input) {
18839
- return import_node_path23.default.posix.join(
19141
+ return import_node_path25.default.posix.join(
18840
19142
  "apps",
18841
19143
  `${resolveAppIconAssetStem(input.icon, input.appRef)}-${input.name}.${extensionForIconFormat(input.format)}`
18842
19144
  );
@@ -18845,8 +19147,8 @@ function resolveAppIconAssetStem(icon, appRef) {
18845
19147
  if (icon) {
18846
19148
  try {
18847
19149
  const url = new URL(icon);
18848
- const ext = import_node_path23.default.posix.extname(url.pathname);
18849
- const basename = import_node_path23.default.posix.basename(url.pathname, ext);
19150
+ const ext = import_node_path25.default.posix.extname(url.pathname);
19151
+ const basename = import_node_path25.default.posix.basename(url.pathname, ext);
18850
19152
  const normalized = sanitizeAppIconAssetStem(basename);
18851
19153
  if (normalized) {
18852
19154
  return normalized;
@@ -18875,9 +19177,9 @@ function writeTempAppIconVariantFile(objectKey, format, bytes) {
18875
19177
  if (!bytes) {
18876
19178
  throw new Error("App icon variant upload requires bytes or a source file.");
18877
19179
  }
18878
- const tempDir = (0, import_node_fs18.mkdtempSync)(import_node_path23.default.join(import_node_os8.default.tmpdir(), "pmate-app-icon-"));
18879
- const tempPath = import_node_path23.default.join(tempDir, import_node_path23.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
18880
- (0, import_node_fs18.writeFileSync)(tempPath, bytes);
19180
+ const tempDir = (0, import_node_fs20.mkdtempSync)(import_node_path25.default.join(import_node_os8.default.tmpdir(), "pmate-app-icon-"));
19181
+ const tempPath = import_node_path25.default.join(tempDir, import_node_path25.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
19182
+ (0, import_node_fs20.writeFileSync)(tempPath, bytes);
18881
19183
  return tempPath;
18882
19184
  }
18883
19185
 
@@ -19086,10 +19388,10 @@ var AppCommandHandler = class {
19086
19388
  }
19087
19389
  readJsonFile(filePath) {
19088
19390
  const absolutePath = this.resolveFilePath(filePath);
19089
- if (!(0, import_node_fs19.existsSync)(absolutePath)) {
19391
+ if (!(0, import_node_fs21.existsSync)(absolutePath)) {
19090
19392
  throw new Error(`JSON file not found: ${absolutePath}`);
19091
19393
  }
19092
- const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
19394
+ const raw = (0, import_node_fs21.readFileSync)(absolutePath, "utf8");
19093
19395
  try {
19094
19396
  return JSON.parse(raw);
19095
19397
  } catch (error) {
@@ -19099,10 +19401,10 @@ var AppCommandHandler = class {
19099
19401
  }
19100
19402
  async preparePayload(filePath, appRef) {
19101
19403
  const absolutePath = this.resolveFilePath(filePath);
19102
- return prepareAppPayload(this.readJsonFile(filePath), import_node_path24.default.dirname(absolutePath), { appRef });
19404
+ return prepareAppPayload(this.readJsonFile(filePath), import_node_path26.default.dirname(absolutePath), { appRef });
19103
19405
  }
19104
19406
  resolveFilePath(filePath) {
19105
- return import_node_path24.default.resolve(process.cwd(), filePath);
19407
+ return import_node_path26.default.resolve(process.cwd(), filePath);
19106
19408
  }
19107
19409
  async request(baseUrl, token, method, pathname, body) {
19108
19410
  const response = await fetch(`${baseUrl}${pathname}`, {
@@ -19222,18 +19524,18 @@ function readNamespaceFromPayload(payload) {
19222
19524
  }
19223
19525
 
19224
19526
  // src/commands/ServiceCommandHandler.ts
19225
- var import_node_fs22 = require("fs");
19527
+ var import_node_fs24 = require("fs");
19226
19528
  var import_promises5 = require("fs/promises");
19227
- var import_node_path27 = __toESM(require("path"));
19529
+ var import_node_path29 = __toESM(require("path"));
19228
19530
  var import_node_child_process11 = require("child_process");
19229
19531
  var import_promises6 = require("readline/promises");
19230
19532
 
19231
19533
  // src/services/AndroidApkReleaseService.ts
19232
19534
  var import_node_child_process9 = require("child_process");
19233
19535
  var import_node_crypto4 = require("crypto");
19234
- var import_node_fs20 = require("fs");
19536
+ var import_node_fs22 = require("fs");
19235
19537
  var import_node_os9 = __toESM(require("os"));
19236
- var import_node_path25 = __toESM(require("path"));
19538
+ var import_node_path27 = __toESM(require("path"));
19237
19539
  var ANDROID_APK_BUCKET = "parrot-static";
19238
19540
  var ANDROID_APK_PUBLIC_BASE_URL = "https://parrot-static.pmate.chat";
19239
19541
  var AndroidApkReleaseService = class {
@@ -19267,7 +19569,7 @@ var AndroidApkReleaseService = class {
19267
19569
  }
19268
19570
  await AliyunService.uploadFile(apkPath, ANDROID_APK_BUCKET, objectKey);
19269
19571
  const sha256 = await sha256File(apkPath);
19270
- const size = (0, import_node_fs20.statSync)(apkPath).size;
19572
+ const size = (0, import_node_fs22.statSync)(apkPath).size;
19271
19573
  const artifact = {
19272
19574
  serviceId: service.id,
19273
19575
  env: options.env,
@@ -19301,15 +19603,15 @@ var AndroidApkReleaseService = class {
19301
19603
  minimumVersionCode: options.minimumVersionCode
19302
19604
  });
19303
19605
  const objectKey = buildAndroidLatestManifestObjectKey(service.namespace, service.name);
19304
- const tempDir = (0, import_node_fs20.mkdtempSync)(import_node_path25.default.join(import_node_os9.default.tmpdir(), "pmate-apk-latest-"));
19305
- const manifestPath = import_node_path25.default.join(tempDir, "latest.json");
19606
+ const tempDir = (0, import_node_fs22.mkdtempSync)(import_node_path27.default.join(import_node_os9.default.tmpdir(), "pmate-apk-latest-"));
19607
+ const manifestPath = import_node_path27.default.join(tempDir, "latest.json");
19306
19608
  try {
19307
- (0, import_node_fs20.writeFileSync)(manifestPath, `${JSON.stringify(manifest, null, 2)}
19609
+ (0, import_node_fs22.writeFileSync)(manifestPath, `${JSON.stringify(manifest, null, 2)}
19308
19610
  `);
19309
19611
  await AliyunService.uploadFile(manifestPath, ANDROID_APK_BUCKET, objectKey);
19310
19612
  ui.success(`Published Android update manifest ${ANDROID_APK_PUBLIC_BASE_URL}/${objectKey}`);
19311
19613
  } finally {
19312
- (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
19614
+ (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
19313
19615
  }
19314
19616
  }
19315
19617
  async list(service, options) {
@@ -19325,7 +19627,7 @@ var AndroidApkReleaseService = class {
19325
19627
  const prefix = `apks/${service.namespace}/${service.name}`;
19326
19628
  const objects = await AliyunService.listObjects(ANDROID_APK_BUCKET, prefix);
19327
19629
  return objects.filter((item) => item.name.endsWith(".apk")).map((item) => {
19328
- const versionName = import_node_path25.default.basename(item.name, ".apk");
19630
+ const versionName = import_node_path27.default.basename(item.name, ".apk");
19329
19631
  return {
19330
19632
  serviceId,
19331
19633
  env: options.env ?? "unknown",
@@ -19348,7 +19650,7 @@ var AndroidApkReleaseService = class {
19348
19650
  }
19349
19651
  }
19350
19652
  resolveRepoRoot(service, cwd) {
19351
- if (cwd) return import_node_path25.default.resolve(process.cwd(), cwd);
19653
+ if (cwd) return import_node_path27.default.resolve(process.cwd(), cwd);
19352
19654
  const repository = this.getRepository(service);
19353
19655
  if (repository) {
19354
19656
  return resolveRepositoryLocalRoot(repository);
@@ -19360,8 +19662,8 @@ var AndroidApkReleaseService = class {
19360
19662
  if (!dir) {
19361
19663
  throw new Error(`Missing dir for android service ${service.id}`);
19362
19664
  }
19363
- const appDir = import_node_path25.default.resolve(repoRoot, dir);
19364
- if (!(0, import_node_fs20.existsSync)(appDir)) {
19665
+ const appDir = import_node_path27.default.resolve(repoRoot, dir);
19666
+ if (!(0, import_node_fs22.existsSync)(appDir)) {
19365
19667
  throw new Error(`Android app dir not found: ${appDir}`);
19366
19668
  }
19367
19669
  return appDir;
@@ -19377,11 +19679,11 @@ var AndroidApkReleaseService = class {
19377
19679
  return void 0;
19378
19680
  }
19379
19681
  async runGradleAssembleAndFindApk(repoRoot, appDir, variant) {
19380
- const gradlew = [import_node_path25.default.join(appDir, "gradlew"), import_node_path25.default.join(repoRoot, "gradlew")].find((candidate) => (0, import_node_fs20.existsSync)(candidate));
19682
+ const gradlew = [import_node_path27.default.join(appDir, "gradlew"), import_node_path27.default.join(repoRoot, "gradlew")].find((candidate) => (0, import_node_fs22.existsSync)(candidate));
19381
19683
  if (!gradlew) {
19382
19684
  throw new Error(`Gradle wrapper not found in ${appDir} or ${repoRoot}`);
19383
19685
  }
19384
- const gradleCwd = import_node_path25.default.dirname(gradlew);
19686
+ const gradleCwd = import_node_path27.default.dirname(gradlew);
19385
19687
  const normalizedVariant = variant.toLowerCase();
19386
19688
  const taskSuffix = `assemble${capitalize(normalizedVariant)}`;
19387
19689
  const tasks = [`:app:${taskSuffix}`, taskSuffix];
@@ -19469,7 +19771,7 @@ function resolveRepositoryLocalRoot(repository) {
19469
19771
  if (!repoName) {
19470
19772
  throw new Error(`Invalid repository: ${repository}`);
19471
19773
  }
19472
- return import_node_path25.default.join(import_node_os9.default.homedir(), "dev", "pmate", repoName);
19774
+ return import_node_path27.default.join(import_node_os9.default.homedir(), "dev", "pmate", repoName);
19473
19775
  }
19474
19776
  function bumpAndroidGradleVersionText(source, bump) {
19475
19777
  const versionNameMatch = source.match(/(^\s*versionName\s+["'])([^"']+)(["']\s*$)/m) ?? source.match(/(^\s*versionName\s*=\s*["'])([^"']+)(["']\s*$)/m);
@@ -19525,42 +19827,42 @@ function parseGradleOutputMetadata(source, apkFileName) {
19525
19827
  }
19526
19828
  function bumpAndroidProjectVersion(appDir, bump) {
19527
19829
  const candidates = [
19528
- import_node_path25.default.join(appDir, "app", "build.gradle.kts"),
19529
- import_node_path25.default.join(appDir, "app", "build.gradle"),
19530
- import_node_path25.default.join(appDir, "build.gradle.kts"),
19531
- import_node_path25.default.join(appDir, "build.gradle")
19830
+ import_node_path27.default.join(appDir, "app", "build.gradle.kts"),
19831
+ import_node_path27.default.join(appDir, "app", "build.gradle"),
19832
+ import_node_path27.default.join(appDir, "build.gradle.kts"),
19833
+ import_node_path27.default.join(appDir, "build.gradle")
19532
19834
  ];
19533
19835
  for (const candidate of candidates) {
19534
- if (!(0, import_node_fs20.existsSync)(candidate)) continue;
19535
- const result = bumpAndroidGradleVersionText((0, import_node_fs20.readFileSync)(candidate, "utf8"), bump);
19536
- (0, import_node_fs20.writeFileSync)(candidate, result.source);
19836
+ if (!(0, import_node_fs22.existsSync)(candidate)) continue;
19837
+ const result = bumpAndroidGradleVersionText((0, import_node_fs22.readFileSync)(candidate, "utf8"), bump);
19838
+ (0, import_node_fs22.writeFileSync)(candidate, result.source);
19537
19839
  return { filePath: candidate, ...result };
19538
19840
  }
19539
19841
  throw new Error(`No Android Gradle version file found under ${appDir}`);
19540
19842
  }
19541
19843
  function findLatestApk(repoRoot, appDir, variant) {
19542
19844
  const dirs = [
19543
- import_node_path25.default.join(appDir, "app", "build", "outputs", "apk", variant),
19544
- import_node_path25.default.join(appDir, "build", "outputs", "apk", variant),
19545
- import_node_path25.default.join(repoRoot, "app", "build", "outputs", "apk", variant)
19845
+ import_node_path27.default.join(appDir, "app", "build", "outputs", "apk", variant),
19846
+ import_node_path27.default.join(appDir, "build", "outputs", "apk", variant),
19847
+ import_node_path27.default.join(repoRoot, "app", "build", "outputs", "apk", variant)
19546
19848
  ];
19547
19849
  const files = dirs.flatMap((dir) => listApks(dir));
19548
19850
  if (files.length === 0) {
19549
19851
  throw new Error(`Cannot find APK output for variant ${variant}`);
19550
19852
  }
19551
- files.sort((a, b) => (0, import_node_fs20.statSync)(b).mtimeMs - (0, import_node_fs20.statSync)(a).mtimeMs);
19853
+ files.sort((a, b) => (0, import_node_fs22.statSync)(b).mtimeMs - (0, import_node_fs22.statSync)(a).mtimeMs);
19552
19854
  return files[0];
19553
19855
  }
19554
19856
  function readGradleOutputMetadata(apkPath) {
19555
- const metadataPath = import_node_path25.default.join(import_node_path25.default.dirname(apkPath), "output-metadata.json");
19556
- if (!(0, import_node_fs20.existsSync)(metadataPath)) {
19857
+ const metadataPath = import_node_path27.default.join(import_node_path27.default.dirname(apkPath), "output-metadata.json");
19858
+ if (!(0, import_node_fs22.existsSync)(metadataPath)) {
19557
19859
  throw new Error(`Gradle output metadata not found: ${metadataPath}`);
19558
19860
  }
19559
- return parseGradleOutputMetadata((0, import_node_fs20.readFileSync)(metadataPath, "utf8"), import_node_path25.default.basename(apkPath));
19861
+ return parseGradleOutputMetadata((0, import_node_fs22.readFileSync)(metadataPath, "utf8"), import_node_path27.default.basename(apkPath));
19560
19862
  }
19561
19863
  function listApks(dir) {
19562
- if (!(0, import_node_fs20.existsSync)(dir)) return [];
19563
- return (0, import_node_fs20.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) => import_node_path25.default.join(dir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isFile());
19864
+ if (!(0, import_node_fs22.existsSync)(dir)) return [];
19865
+ return (0, import_node_fs22.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) => import_node_path27.default.join(dir, entry)).filter((entry) => (0, import_node_fs22.statSync)(entry).isFile());
19564
19866
  }
19565
19867
  function runCommand(command, args, cwd) {
19566
19868
  return new Promise((resolve, reject) => {
@@ -19594,26 +19896,26 @@ async function runAndroidSdkToolCapture(toolName, args) {
19594
19896
  return runCommandCapture(toolPath, args);
19595
19897
  }
19596
19898
  function findAndroidSdkTool(toolName) {
19597
- const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) => import_node_path25.default.resolve(item));
19899
+ const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) => import_node_path27.default.resolve(item));
19598
19900
  for (const sdkRoot of sdkRoots) {
19599
- const candidates = toolName === "aapt" ? listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "build-tools"), toolName) : [
19600
- import_node_path25.default.join(sdkRoot, "cmdline-tools", "latest", "bin", toolName),
19601
- ...listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "cmdline-tools"), import_node_path25.default.join("bin", toolName)),
19602
- import_node_path25.default.join(sdkRoot, "tools", "bin", toolName)
19901
+ const candidates = toolName === "aapt" ? listVersionedToolCandidates(import_node_path27.default.join(sdkRoot, "build-tools"), toolName) : [
19902
+ import_node_path27.default.join(sdkRoot, "cmdline-tools", "latest", "bin", toolName),
19903
+ ...listVersionedToolCandidates(import_node_path27.default.join(sdkRoot, "cmdline-tools"), import_node_path27.default.join("bin", toolName)),
19904
+ import_node_path27.default.join(sdkRoot, "tools", "bin", toolName)
19603
19905
  ];
19604
- const match = candidates.find((candidate) => (0, import_node_fs20.existsSync)(candidate));
19906
+ const match = candidates.find((candidate) => (0, import_node_fs22.existsSync)(candidate));
19605
19907
  if (match) return match;
19606
19908
  }
19607
19909
  return void 0;
19608
19910
  }
19609
19911
  function listVersionedToolCandidates(parentDir, relativeToolPath) {
19610
- if (!(0, import_node_fs20.existsSync)(parentDir)) return [];
19611
- return (0, import_node_fs20.readdirSync)(parentDir).map((entry) => import_node_path25.default.join(parentDir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isDirectory()).sort((a, b) => import_node_path25.default.basename(b).localeCompare(import_node_path25.default.basename(a), void 0, { numeric: true })).map((entry) => import_node_path25.default.join(entry, relativeToolPath));
19912
+ if (!(0, import_node_fs22.existsSync)(parentDir)) return [];
19913
+ return (0, import_node_fs22.readdirSync)(parentDir).map((entry) => import_node_path27.default.join(parentDir, entry)).filter((entry) => (0, import_node_fs22.statSync)(entry).isDirectory()).sort((a, b) => import_node_path27.default.basename(b).localeCompare(import_node_path27.default.basename(a), void 0, { numeric: true })).map((entry) => import_node_path27.default.join(entry, relativeToolPath));
19612
19914
  }
19613
19915
  function sha256File(filePath) {
19614
19916
  return new Promise((resolve, reject) => {
19615
19917
  const hash = (0, import_node_crypto4.createHash)("sha256");
19616
- const stream = (0, import_node_fs20.createReadStream)(filePath);
19918
+ const stream = (0, import_node_fs22.createReadStream)(filePath);
19617
19919
  stream.on("data", (chunk) => hash.update(chunk));
19618
19920
  stream.on("error", reject);
19619
19921
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -19630,9 +19932,9 @@ function capitalize(value) {
19630
19932
  }
19631
19933
 
19632
19934
  // src/services/ServiceRuntimeRunner.ts
19633
- var import_node_fs21 = require("fs");
19935
+ var import_node_fs23 = require("fs");
19634
19936
  var import_node_os10 = __toESM(require("os"));
19635
- var import_node_path26 = __toESM(require("path"));
19937
+ var import_node_path28 = __toESM(require("path"));
19636
19938
  var import_node_child_process10 = require("child_process");
19637
19939
  var import_node_readline = require("readline");
19638
19940
  var import_chalk3 = __toESM(require("chalk"));
@@ -20122,14 +20424,14 @@ var ServiceRuntimeRunner = class {
20122
20424
  }
20123
20425
  resolveRepoRoot(service, cwd) {
20124
20426
  if (cwd) {
20125
- return import_node_path26.default.resolve(process.cwd(), cwd);
20427
+ return import_node_path28.default.resolve(process.cwd(), cwd);
20126
20428
  }
20127
20429
  const repository = this.getType(service) === "vite" || this.getType(service) === "static" ? this.getRepoStaticSite(service).repository.trim() : this.getType(service) === "fc" ? this.getFc(service).repository?.trim() : this.getType(service) === "ios" || this.getType(service) === "android" ? void 0 : this.getNetwork(service).repository?.trim();
20128
20430
  if (repository) {
20129
20431
  const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
20130
20432
  if (repoName) {
20131
- const candidate = import_node_path26.default.join(import_node_os10.default.homedir(), "dev", "pmate", repoName);
20132
- if ((0, import_node_fs21.existsSync)(candidate)) {
20433
+ const candidate = import_node_path28.default.join(import_node_os10.default.homedir(), "dev", "pmate", repoName);
20434
+ if ((0, import_node_fs23.existsSync)(candidate)) {
20133
20435
  return candidate;
20134
20436
  }
20135
20437
  }
@@ -20142,13 +20444,13 @@ var ServiceRuntimeRunner = class {
20142
20444
  if (!dir) {
20143
20445
  throw new Error(`Missing service dir for ${service.id}`);
20144
20446
  }
20145
- return import_node_path26.default.resolve(repoRoot, dir);
20447
+ return import_node_path28.default.resolve(repoRoot, dir);
20146
20448
  }
20147
20449
  async deployVite(service, options) {
20148
20450
  this.assertDeployableStaticSite(service);
20149
20451
  const appDir = this.resolveLocalDir(service, options.cwd);
20150
- const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
20151
- if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20452
+ const packageJsonPath = import_node_path28.default.join(appDir, "package.json");
20453
+ if (!(0, import_node_fs23.existsSync)(packageJsonPath)) {
20152
20454
  throw new Error(`No package.json found at ${packageJsonPath}`);
20153
20455
  }
20154
20456
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -20163,8 +20465,8 @@ var ServiceRuntimeRunner = class {
20163
20465
  this.resolveRepoRoot(service, options.cwd),
20164
20466
  buildEnv
20165
20467
  );
20166
- const distDir = import_node_path26.default.join(appDir, "dist");
20167
- if (!(0, import_node_fs21.existsSync)(distDir)) {
20468
+ const distDir = import_node_path28.default.join(appDir, "dist");
20469
+ if (!(0, import_node_fs23.existsSync)(distDir)) {
20168
20470
  throw new Error(`No dist directory found at ${distDir}`);
20169
20471
  }
20170
20472
  const site = this.getSite(service);
@@ -20177,8 +20479,8 @@ var ServiceRuntimeRunner = class {
20177
20479
  async deployStatic(service, options) {
20178
20480
  this.assertDeployableStaticSite(service);
20179
20481
  const appDir = this.resolveLocalDir(service, options.cwd);
20180
- const srcDir = import_node_path26.default.join(appDir, "src");
20181
- if (!(0, import_node_fs21.existsSync)(srcDir)) {
20482
+ const srcDir = import_node_path28.default.join(appDir, "src");
20483
+ if (!(0, import_node_fs23.existsSync)(srcDir)) {
20182
20484
  throw new Error(`No src directory found at ${srcDir}`);
20183
20485
  }
20184
20486
  const site = this.getSite(service);
@@ -20212,8 +20514,8 @@ var ServiceRuntimeRunner = class {
20212
20514
  this.validateFcConfig(service, fc);
20213
20515
  const repoRoot = this.resolveRepoRoot(service);
20214
20516
  const appDir = this.resolveLocalDir(service);
20215
- const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
20216
- if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20517
+ const packageJsonPath = import_node_path28.default.join(appDir, "package.json");
20518
+ if (!(0, import_node_fs23.existsSync)(packageJsonPath)) {
20217
20519
  throw new Error(`No package.json found at ${packageJsonPath}`);
20218
20520
  }
20219
20521
  const pkg2 = this.loadPackageJson(packageJsonPath);
@@ -20266,15 +20568,15 @@ var ServiceRuntimeRunner = class {
20266
20568
  const repoRoot = this.resolveRepoRoot(service, options.cwd);
20267
20569
  const appDir = this.resolveLocalDir(service, options.cwd);
20268
20570
  await this.ensurePnpmWorkspaceRoot(repoRoot);
20269
- const configPath = import_node_path26.default.join(appDir, fc.configFile ?? "s.yaml");
20270
- if (!(0, import_node_fs21.existsSync)(configPath)) {
20571
+ const configPath = import_node_path28.default.join(appDir, fc.configFile ?? "s.yaml");
20572
+ if (!(0, import_node_fs23.existsSync)(configPath)) {
20271
20573
  throw new Error(`Missing FC config file at ${configPath}`);
20272
20574
  }
20273
- const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
20274
- if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20575
+ const packageJsonPath = import_node_path28.default.join(appDir, "package.json");
20576
+ if (!(0, import_node_fs23.existsSync)(packageJsonPath)) {
20275
20577
  throw new Error(`No package.json found at ${packageJsonPath}`);
20276
20578
  }
20277
- const rawConfig = (0, import_node_fs21.readFileSync)(configPath, "utf8");
20579
+ const rawConfig = (0, import_node_fs23.readFileSync)(configPath, "utf8");
20278
20580
  if (!rawConfig.includes(fc.functionName)) {
20279
20581
  throw new Error(`FC config ${configPath} does not mention functionName ${fc.functionName}`);
20280
20582
  }
@@ -20552,7 +20854,7 @@ var ServiceRuntimeRunner = class {
20552
20854
  const serverAddress = await resolveServerAddress(server);
20553
20855
  const templateName = exposeType === "websocket" ? "nginx.ws.template" : "nginx.rest.template";
20554
20856
  const templatePath = this.resolveTemplatePath(templateName);
20555
- const template = (0, import_node_fs21.readFileSync)(templatePath, "utf8");
20857
+ const template = (0, import_node_fs23.readFileSync)(templatePath, "utf8");
20556
20858
  const host = `${subdomain}.${("domain" in network ? network.domain?.trim() : void 0) || "pmate.chat"}`;
20557
20859
  const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
20558
20860
  const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
@@ -20584,11 +20886,11 @@ var ServiceRuntimeRunner = class {
20584
20886
  }
20585
20887
  if (config.ensurePackageJson) {
20586
20888
  const appDir = this.resolveLocalDir(service, options.cwd);
20587
- const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
20588
- if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
20889
+ const packageJsonPath = import_node_path28.default.join(appDir, "package.json");
20890
+ if (!(0, import_node_fs23.existsSync)(packageJsonPath)) {
20589
20891
  throw new Error(`Missing package.json at ${packageJsonPath}`);
20590
20892
  }
20591
- const pkgStat = (0, import_node_fs21.statSync)(packageJsonPath);
20893
+ const pkgStat = (0, import_node_fs23.statSync)(packageJsonPath);
20592
20894
  if (!pkgStat.isFile()) {
20593
20895
  throw new Error(`package.json is not a file at ${packageJsonPath}`);
20594
20896
  }
@@ -21017,9 +21319,9 @@ var ServiceRuntimeRunner = class {
21017
21319
  return tokens;
21018
21320
  }
21019
21321
  readPathValue(source, pathExpr) {
21020
- const path32 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
21322
+ const path34 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
21021
21323
  let cursor = source;
21022
- for (const segment of path32) {
21324
+ for (const segment of path34) {
21023
21325
  if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
21024
21326
  return void 0;
21025
21327
  }
@@ -21062,12 +21364,12 @@ var ServiceRuntimeRunner = class {
21062
21364
  }
21063
21365
  resolveTemplatePath(templateName) {
21064
21366
  const candidates = [
21065
- import_node_path26.default.join(__dirname, "..", "templates", templateName),
21066
- import_node_path26.default.join(__dirname, "..", "src", "templates", templateName),
21067
- import_node_path26.default.join(__dirname, "templates", templateName)
21367
+ import_node_path28.default.join(__dirname, "..", "templates", templateName),
21368
+ import_node_path28.default.join(__dirname, "..", "src", "templates", templateName),
21369
+ import_node_path28.default.join(__dirname, "templates", templateName)
21068
21370
  ];
21069
21371
  for (const candidate of candidates) {
21070
- if ((0, import_node_fs21.existsSync)(candidate)) {
21372
+ if ((0, import_node_fs23.existsSync)(candidate)) {
21071
21373
  return candidate;
21072
21374
  }
21073
21375
  }
@@ -21099,7 +21401,7 @@ var ServiceRuntimeRunner = class {
21099
21401
  });
21100
21402
  }
21101
21403
  loadPackageJson(packageJsonPath) {
21102
- const raw = (0, import_node_fs21.readFileSync)(packageJsonPath, "utf8");
21404
+ const raw = (0, import_node_fs23.readFileSync)(packageJsonPath, "utf8");
21103
21405
  const parsed = JSON.parse(raw);
21104
21406
  if (!parsed || typeof parsed !== "object") {
21105
21407
  throw new Error(`Invalid package.json at ${packageJsonPath}`);
@@ -21108,7 +21410,7 @@ var ServiceRuntimeRunner = class {
21108
21410
  }
21109
21411
  writePackageJson(packageJsonPath, data) {
21110
21412
  const serialized = JSON.stringify(data, null, 2);
21111
- (0, import_node_fs21.writeFileSync)(packageJsonPath, `${serialized}
21413
+ (0, import_node_fs23.writeFileSync)(packageJsonPath, `${serialized}
21112
21414
  `, "utf8");
21113
21415
  }
21114
21416
  validateFcConfig(service, fc) {
@@ -21135,8 +21437,8 @@ var ServiceRuntimeRunner = class {
21135
21437
  }
21136
21438
  }
21137
21439
  async ensurePnpmWorkspaceRoot(repoRoot) {
21138
- const workspacePath = import_node_path26.default.join(repoRoot, "pnpm-workspace.yaml");
21139
- if (!(0, import_node_fs21.existsSync)(workspacePath)) {
21440
+ const workspacePath = import_node_path28.default.join(repoRoot, "pnpm-workspace.yaml");
21441
+ if (!(0, import_node_fs23.existsSync)(workspacePath)) {
21140
21442
  throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
21141
21443
  }
21142
21444
  }
@@ -21210,16 +21512,16 @@ var ServiceRuntimeRunner = class {
21210
21512
  if (!privateKeyPath) {
21211
21513
  throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
21212
21514
  }
21213
- if (!(0, import_node_fs21.existsSync)(certificatePath)) {
21515
+ if (!(0, import_node_fs23.existsSync)(certificatePath)) {
21214
21516
  throw new Error(`SSL certificate file not found: ${certificatePath}`);
21215
21517
  }
21216
- if (!(0, import_node_fs21.existsSync)(privateKeyPath)) {
21518
+ if (!(0, import_node_fs23.existsSync)(privateKeyPath)) {
21217
21519
  throw new Error(`SSL private key file not found: ${privateKeyPath}`);
21218
21520
  }
21219
21521
  return {
21220
21522
  certName: host,
21221
- certificate: (0, import_node_fs21.readFileSync)(certificatePath, "utf8"),
21222
- privateKey: (0, import_node_fs21.readFileSync)(privateKeyPath, "utf8")
21523
+ certificate: (0, import_node_fs23.readFileSync)(certificatePath, "utf8"),
21524
+ privateKey: (0, import_node_fs23.readFileSync)(privateKeyPath, "utf8")
21223
21525
  };
21224
21526
  }
21225
21527
  resolveFcProtocol(fc, certConfig) {
@@ -21678,7 +21980,7 @@ var ServiceCommandHandler = class {
21678
21980
  format: "dotenv"
21679
21981
  }
21680
21982
  );
21681
- const outputPath = import_node_path27.default.resolve(process.cwd(), args.output);
21983
+ const outputPath = import_node_path29.default.resolve(process.cwd(), args.output);
21682
21984
  await (0, import_promises5.writeFile)(outputPath, payload.content, "utf8");
21683
21985
  ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
21684
21986
  this.renderJson({ ...payload, output: outputPath }, args.json);
@@ -21904,11 +22206,11 @@ var ServiceCommandHandler = class {
21904
22206
  return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
21905
22207
  }
21906
22208
  readJsonFile(filePath) {
21907
- const absolutePath = import_node_path27.default.resolve(process.cwd(), filePath);
21908
- if (!(0, import_node_fs22.existsSync)(absolutePath)) {
22209
+ const absolutePath = import_node_path29.default.resolve(process.cwd(), filePath);
22210
+ if (!(0, import_node_fs24.existsSync)(absolutePath)) {
21909
22211
  throw new Error(`JSON file not found: ${absolutePath}`);
21910
22212
  }
21911
- const raw = (0, import_node_fs22.readFileSync)(absolutePath, "utf8");
22213
+ const raw = (0, import_node_fs24.readFileSync)(absolutePath, "utf8");
21912
22214
  try {
21913
22215
  return JSON.parse(raw);
21914
22216
  } catch (error) {
@@ -22716,9 +23018,9 @@ var RoleCommandHandler = class {
22716
23018
  };
22717
23019
 
22718
23020
  // src/commands/AccountCommandHandler.ts
22719
- var import_node_fs23 = require("fs");
23021
+ var import_node_fs25 = require("fs");
22720
23022
  var import_node_crypto5 = require("crypto");
22721
- var import_node_path28 = __toESM(require("path"));
23023
+ var import_node_path30 = __toESM(require("path"));
22722
23024
  init_sessionStore();
22723
23025
  var AccountCommandHandler = class {
22724
23026
  async handle(args) {
@@ -22726,9 +23028,9 @@ var AccountCommandHandler = class {
22726
23028
  case "bot-keygen": {
22727
23029
  const keyFile = this.generateBotKeyFile(args.app, args.name);
22728
23030
  const outPath = args.out ? this.resolveFilePath(args.out) : this.resolveDefaultBotKeyPath(args.app, args.name);
22729
- (0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
22730
- (0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
22731
- (0, import_node_fs23.chmodSync)(outPath, 384);
23031
+ (0, import_node_fs25.mkdirSync)(import_node_path30.default.dirname(outPath), { recursive: true });
23032
+ (0, import_node_fs25.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
23033
+ (0, import_node_fs25.chmodSync)(outPath, 384);
22732
23034
  if (!args.json) {
22733
23035
  ui.success(`Bot key saved to ${outPath}`);
22734
23036
  }
@@ -23264,10 +23566,10 @@ var AccountCommandHandler = class {
23264
23566
  throw new Error("Missing visible apps input");
23265
23567
  }
23266
23568
  const absolutePath = this.resolveFilePath(args.filePath);
23267
- if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23569
+ if (!(0, import_node_fs25.existsSync)(absolutePath)) {
23268
23570
  throw new Error(`JSON file not found: ${absolutePath}`);
23269
23571
  }
23270
- const raw = (0, import_node_fs23.readFileSync)(absolutePath, "utf8");
23572
+ const raw = (0, import_node_fs25.readFileSync)(absolutePath, "utf8");
23271
23573
  let parsed;
23272
23574
  try {
23273
23575
  parsed = JSON.parse(raw);
@@ -23281,13 +23583,13 @@ var AccountCommandHandler = class {
23281
23583
  return parsed;
23282
23584
  }
23283
23585
  resolveFilePath(filePath) {
23284
- return import_node_path28.default.resolve(process.cwd(), filePath);
23586
+ return import_node_path30.default.resolve(process.cwd(), filePath);
23285
23587
  }
23286
23588
  resolveDefaultBotKeyPath(app, name) {
23287
- return import_node_path28.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
23589
+ return import_node_path30.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
23288
23590
  }
23289
23591
  resolveDefaultAccessKeyPath(app, name) {
23290
- return import_node_path28.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
23592
+ return import_node_path30.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
23291
23593
  }
23292
23594
  homeDir() {
23293
23595
  return process.env.HOME || process.env.USERPROFILE || process.cwd();
@@ -23310,10 +23612,10 @@ var AccountCommandHandler = class {
23310
23612
  throw new Error("Missing bot key file");
23311
23613
  }
23312
23614
  const absolutePath = this.resolveFilePath(filePath);
23313
- if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23615
+ if (!(0, import_node_fs25.existsSync)(absolutePath)) {
23314
23616
  throw new Error(`Bot key file not found: ${absolutePath}`);
23315
23617
  }
23316
- const parsed = JSON.parse((0, import_node_fs23.readFileSync)(absolutePath, "utf8"));
23618
+ const parsed = JSON.parse((0, import_node_fs25.readFileSync)(absolutePath, "utf8"));
23317
23619
  if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
23318
23620
  throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
23319
23621
  }
@@ -23330,10 +23632,10 @@ var AccountCommandHandler = class {
23330
23632
  throw new Error("Missing access key file");
23331
23633
  }
23332
23634
  const absolutePath = this.resolveFilePath(filePath);
23333
- if (!(0, import_node_fs23.existsSync)(absolutePath)) {
23635
+ if (!(0, import_node_fs25.existsSync)(absolutePath)) {
23334
23636
  throw new Error(`Access key file not found: ${absolutePath}`);
23335
23637
  }
23336
- const parsed = JSON.parse((0, import_node_fs23.readFileSync)(absolutePath, "utf8"));
23638
+ const parsed = JSON.parse((0, import_node_fs25.readFileSync)(absolutePath, "utf8"));
23337
23639
  if (parsed.type !== "pmate-access-key" || parsed.version !== 1 || !parsed.id || !parsed.app || !parsed.secret || !parsed.expiresAt) {
23338
23640
  throw new Error(`Invalid PMate access key file: ${absolutePath}`);
23339
23641
  }
@@ -23355,9 +23657,9 @@ var AccountCommandHandler = class {
23355
23657
  createdAt: result.key.createdAt
23356
23658
  };
23357
23659
  const outPath = out ? this.resolveFilePath(out) : this.resolveDefaultAccessKeyPath(result.key.app, result.key.name);
23358
- (0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
23359
- (0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
23360
- (0, import_node_fs23.chmodSync)(outPath, 384);
23660
+ (0, import_node_fs25.mkdirSync)(import_node_path30.default.dirname(outPath), { recursive: true });
23661
+ (0, import_node_fs25.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
23662
+ (0, import_node_fs25.chmodSync)(outPath, 384);
23361
23663
  }
23362
23664
  renderAccessKeyCreateResult(result, asJson, out) {
23363
23665
  if (asJson) {
@@ -23442,8 +23744,8 @@ function encodePathSegment2(value) {
23442
23744
  }
23443
23745
 
23444
23746
  // src/commands/OrgCommandHandler.ts
23445
- var import_node_fs24 = require("fs");
23446
- var import_node_path29 = __toESM(require("path"));
23747
+ var import_node_fs26 = require("fs");
23748
+ var import_node_path31 = __toESM(require("path"));
23447
23749
  init_sessionStore();
23448
23750
  var OrgCommandHandler = class {
23449
23751
  async handle(args) {
@@ -23613,11 +23915,11 @@ var OrgCommandHandler = class {
23613
23915
  if (!filePath) {
23614
23916
  throw new Error(`Missing ${itemLabel} input`);
23615
23917
  }
23616
- const absolutePath = import_node_path29.default.resolve(process.cwd(), filePath);
23617
- if (!(0, import_node_fs24.existsSync)(absolutePath)) {
23918
+ const absolutePath = import_node_path31.default.resolve(process.cwd(), filePath);
23919
+ if (!(0, import_node_fs26.existsSync)(absolutePath)) {
23618
23920
  throw new Error(`JSON file not found: ${absolutePath}`);
23619
23921
  }
23620
- const raw = (0, import_node_fs24.readFileSync)(absolutePath, "utf8");
23922
+ const raw = (0, import_node_fs26.readFileSync)(absolutePath, "utf8");
23621
23923
  let parsed;
23622
23924
  try {
23623
23925
  parsed = JSON.parse(raw);
@@ -23688,9 +23990,9 @@ function encodePathSegment3(value) {
23688
23990
  }
23689
23991
 
23690
23992
  // src/commands/HostCommandHandler.ts
23691
- var import_node_fs25 = require("fs");
23993
+ var import_node_fs27 = require("fs");
23692
23994
  var import_node_os11 = require("os");
23693
- var import_node_path30 = __toESM(require("path"));
23995
+ var import_node_path32 = __toESM(require("path"));
23694
23996
  var import_node_child_process13 = require("child_process");
23695
23997
  var BLOCK_START = "# >>> pmate host env >>>";
23696
23998
  var BLOCK_END = "# <<< pmate host env <<<";
@@ -24322,6 +24624,101 @@ function requireValue2(tokens, optionName) {
24322
24624
  return value;
24323
24625
  }
24324
24626
 
24627
+ // src/registryResourceCommandParser.ts
24628
+ init_namespacedRef();
24629
+ function parseFunctionArgs(tokens) {
24630
+ return parseRegistryArgs(tokens, "function" /* Function */, "function");
24631
+ }
24632
+ function parseWorkerArgs(tokens) {
24633
+ return parseRegistryArgs(tokens, "worker" /* Worker */, "worker");
24634
+ }
24635
+ function parseRegistryArgs(tokens, type, label) {
24636
+ const rest = [...tokens];
24637
+ const action = rest.shift();
24638
+ if (!action || !["list", "get", "view", "create", "update", "delete"].includes(action)) {
24639
+ throw new Error(`Use: ${label} list|get|view|create|update|delete`);
24640
+ }
24641
+ let baseUrl;
24642
+ let json = false;
24643
+ let namespace;
24644
+ let name;
24645
+ let filePath;
24646
+ if (["get", "view", "update", "delete"].includes(action)) {
24647
+ const ref = rest.shift();
24648
+ if (!ref) throw new Error(`Missing ${label} ref`);
24649
+ const parsed = parseNamespacedRef(ref, { entityLabel: `${label} ref` });
24650
+ namespace = parsed.namespace;
24651
+ name = parsed.objectId;
24652
+ } else if (action === "create" && rest[0] && !rest[0].startsWith("-")) {
24653
+ namespace = rest.shift();
24654
+ }
24655
+ namespace ??= "pmate";
24656
+ while (rest.length) {
24657
+ const option = rest.shift();
24658
+ const value = () => {
24659
+ const next = rest.shift();
24660
+ if (!next || next.startsWith("-")) throw new Error(`Missing value for ${option}`);
24661
+ return next;
24662
+ };
24663
+ if (option === "--namespace" || option === "--ns") namespace = value();
24664
+ else if (option === "--base-url") baseUrl = value();
24665
+ else if (option === "--file") filePath = value();
24666
+ else if (option === "--json") json = true;
24667
+ else throw new Error(`Unknown ${label} option: ${option}`);
24668
+ }
24669
+ if ((action === "create" || action === "update") && !filePath) {
24670
+ throw new Error(`Missing required option --file for ${label} ${action}`);
24671
+ }
24672
+ return { type, action, namespace, name, filePath, baseUrl, json };
24673
+ }
24674
+
24675
+ // src/callCommandParser.ts
24676
+ init_namespacedRef();
24677
+ function parseCallArgs(tokens) {
24678
+ const rest = [...tokens];
24679
+ const ref = rest.shift();
24680
+ if (!ref) throw new Error("Usage: call <namespace:functionId> [--payload <json>|--file <path>]");
24681
+ const parsed = parseNamespacedRef(ref, { entityLabel: "function ref" });
24682
+ let payload;
24683
+ let filePath;
24684
+ let hubBaseUrl;
24685
+ let timeoutMs;
24686
+ let json = false;
24687
+ while (rest.length) {
24688
+ const option = rest.shift();
24689
+ const value = () => {
24690
+ const next = rest.shift();
24691
+ if (!next || next.startsWith("-")) throw new Error(`Missing value for ${option}`);
24692
+ return next;
24693
+ };
24694
+ if (option === "--payload") {
24695
+ const decoded = JSON.parse(value());
24696
+ if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) {
24697
+ throw new Error("--payload must be a JSON object");
24698
+ }
24699
+ payload = decoded;
24700
+ } else if (option === "--file") filePath = value();
24701
+ else if (option === "--hub-base-url") hubBaseUrl = value();
24702
+ else if (option === "--timeout-ms") timeoutMs = Number.parseInt(value(), 10);
24703
+ else if (option === "--json") json = true;
24704
+ else throw new Error(`Unknown call option: ${option}`);
24705
+ }
24706
+ if (payload && filePath) throw new Error("Provide only one of --payload or --file");
24707
+ if (timeoutMs !== void 0 && (!Number.isInteger(timeoutMs) || timeoutMs < 1)) {
24708
+ throw new Error("--timeout-ms must be a positive integer");
24709
+ }
24710
+ return {
24711
+ type: "call" /* Call */,
24712
+ namespace: parsed.namespace,
24713
+ name: parsed.objectId,
24714
+ payload,
24715
+ filePath,
24716
+ hubBaseUrl,
24717
+ timeoutMs,
24718
+ json
24719
+ };
24720
+ }
24721
+
24325
24722
  // src/nsCommandParser.ts
24326
24723
  var DEFAULT_CHAIN = "pmate";
24327
24724
  function parseNsArgs(tokens) {
@@ -27286,7 +27683,7 @@ function requireValue13(tokens, option) {
27286
27683
 
27287
27684
  // src/index.ts
27288
27685
  var pkg = JSON.parse(
27289
- (0, import_node_fs26.readFileSync)(import_node_path31.default.resolve(__dirname, "..", "package.json"), "utf8")
27686
+ (0, import_node_fs28.readFileSync)(import_node_path33.default.resolve(__dirname, "..", "package.json"), "utf8")
27290
27687
  );
27291
27688
  var HELP_TEXT = [
27292
27689
  import_chalk4.default.bold(`pmate v${pkg.version}`),
@@ -27398,6 +27795,12 @@ var HELP_TEXT = [
27398
27795
  ` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
27399
27796
  ` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
27400
27797
  ` ${import_chalk4.default.gray(" list defaults to all namespaces; create defaults to namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
27798
+ ` ${import_chalk4.default.cyan("function")} Manage Function Registry entries`,
27799
+ ` ${import_chalk4.default.gray(" list|get|view|create|update|delete [--base-url <url>] [--json]")}`,
27800
+ ` ${import_chalk4.default.cyan("worker")} Manage Worker Registry entries`,
27801
+ ` ${import_chalk4.default.gray(" list|get|view|create|update|delete [--base-url <url>] [--json]")}`,
27802
+ ` ${import_chalk4.default.cyan("call")} Call a Function through Hub`,
27803
+ ` ${import_chalk4.default.gray(" <namespace:functionId> [--payload <json>|--file <path>] [--timeout-ms <n>] [--json]")}`,
27401
27804
  ` ${import_chalk4.default.cyan("ns")} Manage registered namespaces`,
27402
27805
  ` ${import_chalk4.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
27403
27806
  ` ${import_chalk4.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
@@ -27644,6 +28047,15 @@ function parseCommandArgs(args) {
27644
28047
  if (args.rest[0] === "runner") {
27645
28048
  return parseRunnerArgs(args.rest.slice(1));
27646
28049
  }
28050
+ if (args.rest[0] === "function") {
28051
+ return parseFunctionArgs(args.rest.slice(1));
28052
+ }
28053
+ if (args.rest[0] === "worker") {
28054
+ return parseWorkerArgs(args.rest.slice(1));
28055
+ }
28056
+ if (args.rest[0] === "call") {
28057
+ return parseCallArgs(args.rest.slice(1));
28058
+ }
27647
28059
  if (args.rest[0] === "ns" || args.rest[0] === "namespace") {
27648
28060
  return parseNsArgs(args.rest.slice(1));
27649
28061
  }
@@ -29353,6 +29765,17 @@ async function main() {
29353
29765
  await handler.handle(commandArgs);
29354
29766
  return;
29355
29767
  }
29768
+ case "function" /* Function */:
29769
+ case "worker" /* Worker */: {
29770
+ const handler = new RegistryResourceCommandHandler();
29771
+ await handler.handle(commandArgs);
29772
+ return;
29773
+ }
29774
+ case "call" /* Call */: {
29775
+ const handler = new CallCommandHandler();
29776
+ await handler.handle(commandArgs);
29777
+ return;
29778
+ }
29356
29779
  case "ns" /* Ns */: {
29357
29780
  const handler = new NsCommandHandler();
29358
29781
  await handler.handle(commandArgs);