@pmate/cli 0.24.34 → 0.24.36
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 +435 -532
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -293,160 +293,160 @@ var init_sessionStore = __esm({
|
|
|
293
293
|
}
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
296
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/account.types.ts
|
|
297
297
|
var init_account_types = __esm({
|
|
298
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
298
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/account.types.ts"() {
|
|
299
299
|
"use strict";
|
|
300
300
|
}
|
|
301
301
|
});
|
|
302
302
|
|
|
303
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
303
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/achievements.types.ts
|
|
304
304
|
var init_achievements_types = __esm({
|
|
305
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
305
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
|
|
306
306
|
"use strict";
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
310
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/aigen.types.ts
|
|
311
311
|
var init_aigen_types = __esm({
|
|
312
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
312
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
|
|
313
313
|
"use strict";
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
317
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent.types.ts
|
|
318
318
|
var init_agent_types = __esm({
|
|
319
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
319
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent.types.ts"() {
|
|
320
320
|
"use strict";
|
|
321
321
|
}
|
|
322
322
|
});
|
|
323
323
|
|
|
324
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
324
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent-registry.types.ts
|
|
325
325
|
var init_agent_registry_types = __esm({
|
|
326
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
326
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
|
|
327
327
|
"use strict";
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
|
|
331
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
331
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/runner-registry.types.ts
|
|
332
332
|
var init_runner_registry_types = __esm({
|
|
333
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
333
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
|
|
334
334
|
"use strict";
|
|
335
335
|
}
|
|
336
336
|
});
|
|
337
337
|
|
|
338
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
338
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/blockchain.types.ts
|
|
339
339
|
var init_blockchain_types = __esm({
|
|
340
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
340
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
|
|
341
341
|
"use strict";
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
|
|
345
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
345
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/breakdown.types.ts
|
|
346
346
|
var init_breakdown_types = __esm({
|
|
347
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
347
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
|
|
348
348
|
"use strict";
|
|
349
349
|
}
|
|
350
350
|
});
|
|
351
351
|
|
|
352
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
352
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/chat.types.ts
|
|
353
353
|
var init_chat_types = __esm({
|
|
354
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
354
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/chat.types.ts"() {
|
|
355
355
|
"use strict";
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
358
|
|
|
359
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
359
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/companion.types.ts
|
|
360
360
|
var init_companion_types = __esm({
|
|
361
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
361
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/companion.types.ts"() {
|
|
362
362
|
"use strict";
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
365
|
|
|
366
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
366
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/enums.ts
|
|
367
367
|
var init_enums = __esm({
|
|
368
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
368
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/enums.ts"() {
|
|
369
369
|
"use strict";
|
|
370
370
|
}
|
|
371
371
|
});
|
|
372
372
|
|
|
373
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
373
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/lang.types.ts
|
|
374
374
|
var init_lang_types = __esm({
|
|
375
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
375
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/lang.types.ts"() {
|
|
376
376
|
"use strict";
|
|
377
377
|
}
|
|
378
378
|
});
|
|
379
379
|
|
|
380
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
380
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/logs.types.ts
|
|
381
381
|
var init_logs_types = __esm({
|
|
382
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
382
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/logs.types.ts"() {
|
|
383
383
|
"use strict";
|
|
384
384
|
}
|
|
385
385
|
});
|
|
386
386
|
|
|
387
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
387
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/message.types.ts
|
|
388
388
|
var PING, PONG;
|
|
389
389
|
var init_message_types = __esm({
|
|
390
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
390
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/message.types.ts"() {
|
|
391
391
|
"use strict";
|
|
392
392
|
PING = 1;
|
|
393
393
|
PONG = 2;
|
|
394
394
|
}
|
|
395
395
|
});
|
|
396
396
|
|
|
397
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
397
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/newLog.types.ts
|
|
398
398
|
var init_newLog_types = __esm({
|
|
399
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
399
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
|
|
400
400
|
"use strict";
|
|
401
401
|
}
|
|
402
402
|
});
|
|
403
403
|
|
|
404
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
404
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/novel.types.ts
|
|
405
405
|
var init_novel_types = __esm({
|
|
406
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
406
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/novel.types.ts"() {
|
|
407
407
|
"use strict";
|
|
408
408
|
}
|
|
409
409
|
});
|
|
410
410
|
|
|
411
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
411
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/offline.types.ts
|
|
412
412
|
var init_offline_types = __esm({
|
|
413
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
413
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/offline.types.ts"() {
|
|
414
414
|
"use strict";
|
|
415
415
|
}
|
|
416
416
|
});
|
|
417
417
|
|
|
418
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
418
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/prompt.types.ts
|
|
419
419
|
var init_prompt_types = __esm({
|
|
420
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
420
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
|
|
421
421
|
"use strict";
|
|
422
422
|
}
|
|
423
423
|
});
|
|
424
424
|
|
|
425
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
425
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/reading.types.ts
|
|
426
426
|
var init_reading_types = __esm({
|
|
427
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
427
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/reading.types.ts"() {
|
|
428
428
|
"use strict";
|
|
429
429
|
}
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
432
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/settings.types.ts
|
|
433
433
|
var init_settings_types = __esm({
|
|
434
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
434
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/settings.types.ts"() {
|
|
435
435
|
"use strict";
|
|
436
436
|
}
|
|
437
437
|
});
|
|
438
438
|
|
|
439
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
439
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/subscription.types.ts
|
|
440
440
|
var init_subscription_types = __esm({
|
|
441
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
441
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
|
|
442
442
|
"use strict";
|
|
443
443
|
}
|
|
444
444
|
});
|
|
445
445
|
|
|
446
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
446
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/types.ts
|
|
447
447
|
var buildVoiceKey, createVoice;
|
|
448
448
|
var init_types = __esm({
|
|
449
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
449
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/types.ts"() {
|
|
450
450
|
"use strict";
|
|
451
451
|
buildVoiceKey = (provider, name) => {
|
|
452
452
|
return `${provider}:${name}`;
|
|
@@ -468,44 +468,44 @@ var init_types = __esm({
|
|
|
468
468
|
}
|
|
469
469
|
});
|
|
470
470
|
|
|
471
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
471
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/wordv5.def.ts
|
|
472
472
|
var init_wordv5_def = __esm({
|
|
473
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
473
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
|
|
474
474
|
"use strict";
|
|
475
475
|
}
|
|
476
476
|
});
|
|
477
477
|
|
|
478
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
478
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/auth.types.ts
|
|
479
479
|
var init_auth_types = __esm({
|
|
480
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
480
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/auth.types.ts"() {
|
|
481
481
|
"use strict";
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
484
|
|
|
485
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
485
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/apps.types.ts
|
|
486
486
|
var init_apps_types = __esm({
|
|
487
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
487
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/apps.types.ts"() {
|
|
488
488
|
"use strict";
|
|
489
489
|
}
|
|
490
490
|
});
|
|
491
491
|
|
|
492
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
492
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/response.types.ts
|
|
493
493
|
var init_response_types = __esm({
|
|
494
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
494
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/response.types.ts"() {
|
|
495
495
|
"use strict";
|
|
496
496
|
}
|
|
497
497
|
});
|
|
498
498
|
|
|
499
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
499
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/role.types.ts
|
|
500
500
|
var init_role_types = __esm({
|
|
501
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
501
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/role.types.ts"() {
|
|
502
502
|
"use strict";
|
|
503
503
|
}
|
|
504
504
|
});
|
|
505
505
|
|
|
506
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
506
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/index.ts
|
|
507
507
|
var init_types2 = __esm({
|
|
508
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
508
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/types/index.ts"() {
|
|
509
509
|
"use strict";
|
|
510
510
|
init_account_types();
|
|
511
511
|
init_achievements_types();
|
|
@@ -537,24 +537,24 @@ var init_types2 = __esm({
|
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
|
|
540
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
540
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/BizErrorCode.ts
|
|
541
541
|
var init_BizErrorCode = __esm({
|
|
542
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
542
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
|
|
543
543
|
"use strict";
|
|
544
544
|
}
|
|
545
545
|
});
|
|
546
546
|
|
|
547
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
547
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/consts.ts
|
|
548
548
|
var init_consts = __esm({
|
|
549
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
549
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/consts.ts"() {
|
|
550
550
|
"use strict";
|
|
551
551
|
}
|
|
552
552
|
});
|
|
553
553
|
|
|
554
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
554
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/TopicNames.ts
|
|
555
555
|
var TopicNames, topicKindMatchers;
|
|
556
556
|
var init_TopicNames = __esm({
|
|
557
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
557
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
|
|
558
558
|
"use strict";
|
|
559
559
|
init_types2();
|
|
560
560
|
TopicNames = class _TopicNames {
|
|
@@ -640,18 +640,18 @@ var init_TopicNames = __esm({
|
|
|
640
640
|
}
|
|
641
641
|
});
|
|
642
642
|
|
|
643
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
643
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/OSSKeys.ts
|
|
644
644
|
var init_OSSKeys = __esm({
|
|
645
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
645
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
|
|
646
646
|
"use strict";
|
|
647
647
|
init_consts();
|
|
648
648
|
}
|
|
649
649
|
});
|
|
650
650
|
|
|
651
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
651
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
|
|
652
652
|
var openAICoral, openAIAsh, openAIBallad, openAINova, openAIVerse;
|
|
653
653
|
var init_CompanionProfiles = __esm({
|
|
654
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
654
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
|
|
655
655
|
"use strict";
|
|
656
656
|
init_types2();
|
|
657
657
|
openAICoral = createVoice({
|
|
@@ -686,9 +686,9 @@ var init_CompanionProfiles = __esm({
|
|
|
686
686
|
}
|
|
687
687
|
});
|
|
688
688
|
|
|
689
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
689
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/index.ts
|
|
690
690
|
var init_config = __esm({
|
|
691
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
691
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/config/index.ts"() {
|
|
692
692
|
"use strict";
|
|
693
693
|
init_BizErrorCode();
|
|
694
694
|
init_consts();
|
|
@@ -698,9 +698,9 @@ var init_config = __esm({
|
|
|
698
698
|
}
|
|
699
699
|
});
|
|
700
700
|
|
|
701
|
-
// node_modules/.pnpm/@pmate+meta@1.1.
|
|
701
|
+
// node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/index.ts
|
|
702
702
|
var init_src = __esm({
|
|
703
|
-
"node_modules/.pnpm/@pmate+meta@1.1.
|
|
703
|
+
"node_modules/.pnpm/@pmate+meta@1.1.13/node_modules/@pmate/meta/src/index.ts"() {
|
|
704
704
|
"use strict";
|
|
705
705
|
init_types2();
|
|
706
706
|
init_config();
|
|
@@ -8277,7 +8277,7 @@ var init_src3 = __esm({
|
|
|
8277
8277
|
}
|
|
8278
8278
|
});
|
|
8279
8279
|
|
|
8280
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8280
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/debug.js
|
|
8281
8281
|
function isDebugEnabled() {
|
|
8282
8282
|
return process.env.DEBUG === "1";
|
|
8283
8283
|
}
|
|
@@ -8292,294 +8292,15 @@ function debugLog(message, data) {
|
|
|
8292
8292
|
console.log(message, data);
|
|
8293
8293
|
}
|
|
8294
8294
|
var init_debug = __esm({
|
|
8295
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8295
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/debug.js"() {
|
|
8296
8296
|
"use strict";
|
|
8297
8297
|
}
|
|
8298
8298
|
});
|
|
8299
8299
|
|
|
8300
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8301
|
-
function ensureProtocol(value, protocol) {
|
|
8302
|
-
if (!value) {
|
|
8303
|
-
return "";
|
|
8304
|
-
}
|
|
8305
|
-
if (/^[a-z]+:\/\//i.test(value)) {
|
|
8306
|
-
try {
|
|
8307
|
-
const url = new URL(value);
|
|
8308
|
-
url.protocol = `${protocol}:`;
|
|
8309
|
-
return url.toString();
|
|
8310
|
-
} catch {
|
|
8311
|
-
return value;
|
|
8312
|
-
}
|
|
8313
|
-
}
|
|
8314
|
-
if (value.startsWith("//")) {
|
|
8315
|
-
return `${protocol}:${value}`;
|
|
8316
|
-
}
|
|
8317
|
-
return `${protocol}://${value}`;
|
|
8318
|
-
}
|
|
8319
|
-
function createPoolKey(wsUrl, profileId, token) {
|
|
8320
|
-
return `${wsUrl}|${profileId}|${hashToken(token)}`;
|
|
8321
|
-
}
|
|
8322
|
-
function hashToken(token) {
|
|
8323
|
-
let hash = 2166136261;
|
|
8324
|
-
for (let i = 0; i < token.length; i += 1) {
|
|
8325
|
-
hash ^= token.charCodeAt(i);
|
|
8326
|
-
hash = Math.imul(hash, 16777619);
|
|
8327
|
-
}
|
|
8328
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
8329
|
-
}
|
|
8330
|
-
var IDLE_CLOSE_MS, pool, AgentConnectionPool, AgentPooledConnection;
|
|
8331
|
-
var init_AgentConnectionPool = __esm({
|
|
8332
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentConnectionPool.js"() {
|
|
8333
|
-
"use strict";
|
|
8334
|
-
init_src();
|
|
8335
|
-
init_src3();
|
|
8336
|
-
init_debug();
|
|
8337
|
-
IDLE_CLOSE_MS = 5e3;
|
|
8338
|
-
pool = /* @__PURE__ */ new Map();
|
|
8339
|
-
AgentConnectionPool = class {
|
|
8340
|
-
static acquire(options) {
|
|
8341
|
-
const wsUrl = ensureProtocol(options.baseUrl, "wss");
|
|
8342
|
-
const key = createPoolKey(wsUrl, options.profileId, options.token);
|
|
8343
|
-
let entry = pool.get(key);
|
|
8344
|
-
if (!entry) {
|
|
8345
|
-
entry = {
|
|
8346
|
-
connection: new AgentPooledConnection(wsUrl, options.profileId, options.token),
|
|
8347
|
-
refCount: 0,
|
|
8348
|
-
idleTimer: null
|
|
8349
|
-
};
|
|
8350
|
-
pool.set(key, entry);
|
|
8351
|
-
}
|
|
8352
|
-
if (entry.idleTimer) {
|
|
8353
|
-
clearTimeout(entry.idleTimer);
|
|
8354
|
-
entry.idleTimer = null;
|
|
8355
|
-
}
|
|
8356
|
-
entry.refCount += 1;
|
|
8357
|
-
return {
|
|
8358
|
-
key,
|
|
8359
|
-
connection: entry.connection
|
|
8360
|
-
};
|
|
8361
|
-
}
|
|
8362
|
-
static release(lease) {
|
|
8363
|
-
const entry = pool.get(lease.key);
|
|
8364
|
-
if (!entry) {
|
|
8365
|
-
return;
|
|
8366
|
-
}
|
|
8367
|
-
entry.refCount = Math.max(0, entry.refCount - 1);
|
|
8368
|
-
if (entry.refCount > 0 || entry.idleTimer) {
|
|
8369
|
-
return;
|
|
8370
|
-
}
|
|
8371
|
-
entry.idleTimer = setTimeout(() => {
|
|
8372
|
-
const current = pool.get(lease.key);
|
|
8373
|
-
if (!current || current.refCount > 0) {
|
|
8374
|
-
return;
|
|
8375
|
-
}
|
|
8376
|
-
current.connection.close();
|
|
8377
|
-
pool.delete(lease.key);
|
|
8378
|
-
}, IDLE_CLOSE_MS);
|
|
8379
|
-
}
|
|
8380
|
-
static clearForTests() {
|
|
8381
|
-
for (const [key, entry] of pool.entries()) {
|
|
8382
|
-
if (entry.idleTimer) {
|
|
8383
|
-
clearTimeout(entry.idleTimer);
|
|
8384
|
-
}
|
|
8385
|
-
entry.connection.close();
|
|
8386
|
-
pool.delete(key);
|
|
8387
|
-
}
|
|
8388
|
-
}
|
|
8389
|
-
};
|
|
8390
|
-
AgentPooledConnection = class {
|
|
8391
|
-
constructor(wsUrl, profileId, token) {
|
|
8392
|
-
this.profileId = profileId;
|
|
8393
|
-
this.token = token;
|
|
8394
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
8395
|
-
this.authPromise = null;
|
|
8396
|
-
this.authResolve = null;
|
|
8397
|
-
this.authReject = null;
|
|
8398
|
-
this.authTimer = null;
|
|
8399
|
-
this.authenticated = false;
|
|
8400
|
-
this.authStarted = false;
|
|
8401
|
-
this.ws = new WebsocketClientV2(wsUrl);
|
|
8402
|
-
this.startWsStream();
|
|
8403
|
-
}
|
|
8404
|
-
addListener(listener) {
|
|
8405
|
-
this.listeners.add(listener);
|
|
8406
|
-
}
|
|
8407
|
-
removeListener(listener) {
|
|
8408
|
-
this.listeners.delete(listener);
|
|
8409
|
-
}
|
|
8410
|
-
isConnected() {
|
|
8411
|
-
return this.ws.isConnected();
|
|
8412
|
-
}
|
|
8413
|
-
async authenticate(timeoutMs) {
|
|
8414
|
-
await this.waitForConnection(timeoutMs);
|
|
8415
|
-
if (this.authenticated) {
|
|
8416
|
-
debugLog("[agent-connection-pool] auth reused", {
|
|
8417
|
-
profileId: this.profileId
|
|
8418
|
-
});
|
|
8419
|
-
return;
|
|
8420
|
-
}
|
|
8421
|
-
const waiter = this.waitForAuthAck(timeoutMs);
|
|
8422
|
-
if (!this.authStarted) {
|
|
8423
|
-
this.authStarted = true;
|
|
8424
|
-
const msg = Msg.create(this.profileId, "@hub", 4 /* AUTH */, {
|
|
8425
|
-
token: this.token,
|
|
8426
|
-
as: "user",
|
|
8427
|
-
profileId: this.profileId
|
|
8428
|
-
});
|
|
8429
|
-
debugLog("[agent-connection-pool] auth sent", {
|
|
8430
|
-
profileId: this.profileId
|
|
8431
|
-
});
|
|
8432
|
-
await this.ws.sendMsg(msg);
|
|
8433
|
-
}
|
|
8434
|
-
await waiter;
|
|
8435
|
-
}
|
|
8436
|
-
sendMsg(msg) {
|
|
8437
|
-
return this.ws.sendMsg(msg);
|
|
8438
|
-
}
|
|
8439
|
-
close() {
|
|
8440
|
-
this.ws.close();
|
|
8441
|
-
this.rejectAuth(new Error("Agent websocket closed before auth ack"));
|
|
8442
|
-
this.listeners.clear();
|
|
8443
|
-
}
|
|
8444
|
-
async startWsStream() {
|
|
8445
|
-
const stream = this.ws.getStream();
|
|
8446
|
-
try {
|
|
8447
|
-
for await (const event of stream) {
|
|
8448
|
-
this.handleWsEvent(event);
|
|
8449
|
-
}
|
|
8450
|
-
} catch {
|
|
8451
|
-
}
|
|
8452
|
-
}
|
|
8453
|
-
handleWsEvent(event) {
|
|
8454
|
-
if (event.type === "message") {
|
|
8455
|
-
this.handleIncomingMessage(event.data);
|
|
8456
|
-
return;
|
|
8457
|
-
}
|
|
8458
|
-
if (event.type === "connected" && !event.data) {
|
|
8459
|
-
this.authenticated = false;
|
|
8460
|
-
this.rejectAuth(new Error("Agent websocket disconnected before auth ack"));
|
|
8461
|
-
}
|
|
8462
|
-
if (event.type === "error") {
|
|
8463
|
-
this.rejectAuth(new Error("Agent websocket error before auth ack"));
|
|
8464
|
-
}
|
|
8465
|
-
this.broadcast(event);
|
|
8466
|
-
}
|
|
8467
|
-
handleIncomingMessage(message) {
|
|
8468
|
-
if (!message || typeof message !== "object") {
|
|
8469
|
-
return;
|
|
8470
|
-
}
|
|
8471
|
-
if (message.opcode === 3 /* ACK */) {
|
|
8472
|
-
const ack = message.body;
|
|
8473
|
-
const success = ack?.status === "ok";
|
|
8474
|
-
debugLog("[agent-connection-pool] ack received", {
|
|
8475
|
-
profileId: this.profileId,
|
|
8476
|
-
success
|
|
8477
|
-
});
|
|
8478
|
-
if (!success) {
|
|
8479
|
-
this.rejectAuth(new Error(ack?.message ?? ack?.code ?? "Auth failed"));
|
|
8480
|
-
return;
|
|
8481
|
-
}
|
|
8482
|
-
this.authenticated = true;
|
|
8483
|
-
this.resolveAuth();
|
|
8484
|
-
return;
|
|
8485
|
-
}
|
|
8486
|
-
debugLog("[agent-connection-pool] message broadcast", {
|
|
8487
|
-
opcode: message.opcode,
|
|
8488
|
-
from: message.from,
|
|
8489
|
-
to: message.to
|
|
8490
|
-
});
|
|
8491
|
-
this.broadcast({ type: "message", data: message });
|
|
8492
|
-
}
|
|
8493
|
-
broadcast(event) {
|
|
8494
|
-
for (const listener of this.listeners) {
|
|
8495
|
-
listener.onConnectionEvent(event);
|
|
8496
|
-
}
|
|
8497
|
-
}
|
|
8498
|
-
waitForConnection(timeoutMs) {
|
|
8499
|
-
if (this.ws.isConnected()) {
|
|
8500
|
-
return Promise.resolve();
|
|
8501
|
-
}
|
|
8502
|
-
return new Promise((resolve, reject) => {
|
|
8503
|
-
const timer = setTimeout(() => {
|
|
8504
|
-
off();
|
|
8505
|
-
reject(new Error("Websocket connect timeout"));
|
|
8506
|
-
}, timeoutMs);
|
|
8507
|
-
const off = this.createOneShotListener("connected" /* Connected */, (connected) => {
|
|
8508
|
-
if (connected) {
|
|
8509
|
-
clearTimeout(timer);
|
|
8510
|
-
off();
|
|
8511
|
-
resolve();
|
|
8512
|
-
}
|
|
8513
|
-
});
|
|
8514
|
-
});
|
|
8515
|
-
}
|
|
8516
|
-
waitForAuthAck(timeoutMs) {
|
|
8517
|
-
if (this.authenticated) {
|
|
8518
|
-
return Promise.resolve();
|
|
8519
|
-
}
|
|
8520
|
-
if (this.authPromise) {
|
|
8521
|
-
return this.authPromise;
|
|
8522
|
-
}
|
|
8523
|
-
this.authPromise = new Promise((resolve, reject) => {
|
|
8524
|
-
this.authResolve = resolve;
|
|
8525
|
-
this.authReject = reject;
|
|
8526
|
-
this.authTimer = setTimeout(() => {
|
|
8527
|
-
this.clearAuthWaiter();
|
|
8528
|
-
this.authStarted = false;
|
|
8529
|
-
reject(new Error("Auth timeout"));
|
|
8530
|
-
}, timeoutMs);
|
|
8531
|
-
});
|
|
8532
|
-
return this.authPromise;
|
|
8533
|
-
}
|
|
8534
|
-
resolveAuth() {
|
|
8535
|
-
if (!this.authResolve) {
|
|
8536
|
-
return;
|
|
8537
|
-
}
|
|
8538
|
-
const resolve = this.authResolve;
|
|
8539
|
-
this.clearAuthWaiter();
|
|
8540
|
-
this.authStarted = false;
|
|
8541
|
-
resolve();
|
|
8542
|
-
}
|
|
8543
|
-
rejectAuth(error) {
|
|
8544
|
-
if (!this.authReject) {
|
|
8545
|
-
return;
|
|
8546
|
-
}
|
|
8547
|
-
const reject = this.authReject;
|
|
8548
|
-
this.clearAuthWaiter();
|
|
8549
|
-
this.authStarted = false;
|
|
8550
|
-
reject(error);
|
|
8551
|
-
}
|
|
8552
|
-
clearAuthWaiter() {
|
|
8553
|
-
if (this.authTimer) {
|
|
8554
|
-
clearTimeout(this.authTimer);
|
|
8555
|
-
this.authTimer = null;
|
|
8556
|
-
}
|
|
8557
|
-
this.authPromise = null;
|
|
8558
|
-
this.authResolve = null;
|
|
8559
|
-
this.authReject = null;
|
|
8560
|
-
}
|
|
8561
|
-
createOneShotListener(eventName, handler) {
|
|
8562
|
-
const listener = {
|
|
8563
|
-
onConnectionEvent: (event) => {
|
|
8564
|
-
if (eventName === "connected" /* Connected */ && event.type === "connected") {
|
|
8565
|
-
;
|
|
8566
|
-
handler(event.data);
|
|
8567
|
-
}
|
|
8568
|
-
}
|
|
8569
|
-
};
|
|
8570
|
-
this.addListener(listener);
|
|
8571
|
-
return () => {
|
|
8572
|
-
this.removeListener(listener);
|
|
8573
|
-
};
|
|
8574
|
-
}
|
|
8575
|
-
};
|
|
8576
|
-
}
|
|
8577
|
-
});
|
|
8578
|
-
|
|
8579
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.16/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js
|
|
8300
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js
|
|
8580
8301
|
var AgentTaskManager;
|
|
8581
8302
|
var init_AgentTaskManager = __esm({
|
|
8582
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8303
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js"() {
|
|
8583
8304
|
"use strict";
|
|
8584
8305
|
init_src3();
|
|
8585
8306
|
init_debug();
|
|
@@ -8748,7 +8469,7 @@ var init_AgentTaskManager = __esm({
|
|
|
8748
8469
|
}
|
|
8749
8470
|
});
|
|
8750
8471
|
|
|
8751
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8472
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentClient.js
|
|
8752
8473
|
function createAgentRequestBody(payload) {
|
|
8753
8474
|
return {
|
|
8754
8475
|
kind: "request",
|
|
@@ -8757,11 +8478,10 @@ function createAgentRequestBody(payload) {
|
|
|
8757
8478
|
}
|
|
8758
8479
|
var logger5, DEFAULT_TIMEOUT_MS, DEFAULT_STREAM_TIMEOUT_MS, DEFAULT_MIN_CHUNK_SIZE_BYTES, AgentClient;
|
|
8759
8480
|
var init_AgentClient = __esm({
|
|
8760
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8481
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentClient.js"() {
|
|
8761
8482
|
"use strict";
|
|
8762
8483
|
init_src();
|
|
8763
8484
|
init_src3();
|
|
8764
|
-
init_AgentConnectionPool();
|
|
8765
8485
|
init_AgentTaskManager();
|
|
8766
8486
|
init_debug();
|
|
8767
8487
|
logger5 = Logger.getDebugger("AgentClient");
|
|
@@ -8772,6 +8492,11 @@ var init_AgentClient = __esm({
|
|
|
8772
8492
|
constructor(options) {
|
|
8773
8493
|
super();
|
|
8774
8494
|
this.tasks = new AgentTaskManager();
|
|
8495
|
+
this.authPromise = null;
|
|
8496
|
+
this.authResolve = null;
|
|
8497
|
+
this.authReject = null;
|
|
8498
|
+
this.authTimer = null;
|
|
8499
|
+
this.wsGeneration = 0;
|
|
8775
8500
|
this.defaultRequestType = "application/json";
|
|
8776
8501
|
this.defaultBinaryType = "application/octet-stream";
|
|
8777
8502
|
this.baseUrl = options.baseUrl;
|
|
@@ -8779,12 +8504,13 @@ var init_AgentClient = __esm({
|
|
|
8779
8504
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
8780
8505
|
this.streamTimeoutMs = options.streamTimeoutMs ?? DEFAULT_STREAM_TIMEOUT_MS;
|
|
8781
8506
|
this.minChunkSizeBytes = options.minChunkSizeBytes ?? DEFAULT_MIN_CHUNK_SIZE_BYTES;
|
|
8507
|
+
this.resetWebsocket(this.baseUrl);
|
|
8782
8508
|
}
|
|
8783
8509
|
isConnected() {
|
|
8784
|
-
return this.
|
|
8510
|
+
return this.ws?.isConnected() ?? false;
|
|
8785
8511
|
}
|
|
8786
8512
|
close() {
|
|
8787
|
-
this.
|
|
8513
|
+
this.ws?.close();
|
|
8788
8514
|
}
|
|
8789
8515
|
async login(options) {
|
|
8790
8516
|
const profileId = options?.profileId;
|
|
@@ -8793,19 +8519,13 @@ var init_AgentClient = __esm({
|
|
|
8793
8519
|
}
|
|
8794
8520
|
this.from = profileId;
|
|
8795
8521
|
const baseUrl = options?.baseUrl ?? this.baseUrl;
|
|
8522
|
+
if (baseUrl !== this.baseUrl) {
|
|
8523
|
+
this.resetWebsocket(baseUrl);
|
|
8524
|
+
}
|
|
8796
8525
|
const timeoutMs = options?.timeoutMs ?? this.timeoutMs;
|
|
8526
|
+
await this.waitForConnection(timeoutMs);
|
|
8797
8527
|
const token = options?.token ?? "";
|
|
8798
|
-
this.
|
|
8799
|
-
const lease = AgentConnectionPool.acquire({ baseUrl, token, profileId });
|
|
8800
|
-
if (this.lease?.key !== lease.key) {
|
|
8801
|
-
this.releaseConnection();
|
|
8802
|
-
this.lease = lease;
|
|
8803
|
-
this.lease.connection.addListener(this);
|
|
8804
|
-
} else {
|
|
8805
|
-
AgentConnectionPool.release(lease);
|
|
8806
|
-
}
|
|
8807
|
-
this.baseUrl = baseUrl;
|
|
8808
|
-
await this.lease.connection.authenticate(timeoutMs);
|
|
8528
|
+
await this.sendAuth(token, timeoutMs, profileId);
|
|
8809
8529
|
return true;
|
|
8810
8530
|
}
|
|
8811
8531
|
async prompt(request) {
|
|
@@ -8842,18 +8562,11 @@ var init_AgentClient = __esm({
|
|
|
8842
8562
|
taskId,
|
|
8843
8563
|
agentId: request.agentId,
|
|
8844
8564
|
op: 0 /* Start */,
|
|
8845
|
-
auth: this.auth,
|
|
8846
8565
|
type: this.defaultRequestType,
|
|
8847
8566
|
...request.payload ? { payload: request.payload } : {}
|
|
8848
8567
|
};
|
|
8849
8568
|
const msg = Msg.create(this.from, hubTo, 2 /* AGENT */, createAgentRequestBody(startPayload), 0 /* PIPELINE */);
|
|
8850
|
-
|
|
8851
|
-
taskId,
|
|
8852
|
-
agentId: request.agentId,
|
|
8853
|
-
from: this.from,
|
|
8854
|
-
to: hubTo
|
|
8855
|
-
});
|
|
8856
|
-
await this.lease.connection.sendMsg(msg);
|
|
8569
|
+
await this.ws.sendMsg(msg);
|
|
8857
8570
|
return await waiter;
|
|
8858
8571
|
}
|
|
8859
8572
|
stream(request) {
|
|
@@ -8865,7 +8578,7 @@ var init_AgentClient = __esm({
|
|
|
8865
8578
|
timeoutMode: "reject"
|
|
8866
8579
|
});
|
|
8867
8580
|
const from = this.from;
|
|
8868
|
-
const
|
|
8581
|
+
const ws = this.ws;
|
|
8869
8582
|
const minChunkSizeBytes = request.minChunkSizeBytes ?? this.minChunkSizeBytes;
|
|
8870
8583
|
const inputStream = minChunkSizeBytes > 0 ? AsyncStream.chunkBlob(request.stream, {
|
|
8871
8584
|
minBytes: minChunkSizeBytes
|
|
@@ -8907,32 +8620,29 @@ var init_AgentClient = __esm({
|
|
|
8907
8620
|
taskId,
|
|
8908
8621
|
agentId: request.agentId,
|
|
8909
8622
|
op: 0 /* Start */,
|
|
8910
|
-
auth: this.auth,
|
|
8911
8623
|
type: this.defaultRequestType,
|
|
8912
8624
|
...request.params ? { payload: request.params } : {}
|
|
8913
8625
|
}), 0 /* PIPELINE */);
|
|
8914
|
-
await
|
|
8626
|
+
await ws.sendMsg(startMsg);
|
|
8915
8627
|
for await (const payload of inputStream) {
|
|
8916
8628
|
const dataType = payload instanceof Blob ? payload.type || this.defaultBinaryType : payload instanceof Uint8Array || payload instanceof ArrayBuffer ? this.defaultBinaryType : typeof payload === "string" ? "text" : this.defaultRequestType;
|
|
8917
8629
|
const body = {
|
|
8918
8630
|
taskId,
|
|
8919
8631
|
agentId: request.agentId,
|
|
8920
8632
|
op: 1 /* Data */,
|
|
8921
|
-
auth: this.auth,
|
|
8922
8633
|
type: dataType,
|
|
8923
8634
|
payload
|
|
8924
8635
|
};
|
|
8925
8636
|
const msg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody(body), 0 /* PIPELINE */);
|
|
8926
|
-
await
|
|
8637
|
+
await ws.sendMsg(msg);
|
|
8927
8638
|
}
|
|
8928
8639
|
const endMsg = Msg.create(from, hubTo, 2 /* AGENT */, createAgentRequestBody({
|
|
8929
8640
|
taskId,
|
|
8930
8641
|
agentId: request.agentId,
|
|
8931
8642
|
op: 2 /* End */,
|
|
8932
|
-
auth: this.auth,
|
|
8933
8643
|
type: this.defaultRequestType
|
|
8934
8644
|
}), 0 /* PIPELINE */);
|
|
8935
|
-
await
|
|
8645
|
+
await ws.sendMsg(endMsg);
|
|
8936
8646
|
};
|
|
8937
8647
|
void startDataStream();
|
|
8938
8648
|
const agentStream = outputStream;
|
|
@@ -8983,7 +8693,7 @@ var init_AgentClient = __esm({
|
|
|
8983
8693
|
return agentStream;
|
|
8984
8694
|
}
|
|
8985
8695
|
ensureReady() {
|
|
8986
|
-
if (!this.
|
|
8696
|
+
if (!this.ws || !this.from) {
|
|
8987
8697
|
throw new Error("AgentClient not logged in");
|
|
8988
8698
|
}
|
|
8989
8699
|
}
|
|
@@ -8991,7 +8701,31 @@ var init_AgentClient = __esm({
|
|
|
8991
8701
|
const rnd = Math.floor(Math.random() * 1e12);
|
|
8992
8702
|
return uniqHash(`${agentId}-${Date.now()}-${rnd}`, "task-v1" /* Task */);
|
|
8993
8703
|
}
|
|
8994
|
-
|
|
8704
|
+
createWebsocketClient(baseUrl) {
|
|
8705
|
+
return new WebsocketClientV2(this.ensureProtocol(baseUrl, "wss"));
|
|
8706
|
+
}
|
|
8707
|
+
resetWebsocket(baseUrl) {
|
|
8708
|
+
this.baseUrl = baseUrl;
|
|
8709
|
+
if (this.ws) {
|
|
8710
|
+
this.ws.close();
|
|
8711
|
+
}
|
|
8712
|
+
this.ws = this.createWebsocketClient(this.baseUrl);
|
|
8713
|
+
this.wsGeneration += 1;
|
|
8714
|
+
this.startWsStream(this.ws, this.wsGeneration);
|
|
8715
|
+
}
|
|
8716
|
+
async startWsStream(ws, generation) {
|
|
8717
|
+
const stream = ws.getStream();
|
|
8718
|
+
try {
|
|
8719
|
+
for await (const event of stream) {
|
|
8720
|
+
if (generation !== this.wsGeneration) {
|
|
8721
|
+
break;
|
|
8722
|
+
}
|
|
8723
|
+
this.handleWsEvent(event);
|
|
8724
|
+
}
|
|
8725
|
+
} catch {
|
|
8726
|
+
}
|
|
8727
|
+
}
|
|
8728
|
+
handleWsEvent(event) {
|
|
8995
8729
|
if (event.type === "message") {
|
|
8996
8730
|
this.handleIncomingMessage(event.data);
|
|
8997
8731
|
return;
|
|
@@ -9002,16 +8736,30 @@ var init_AgentClient = __esm({
|
|
|
9002
8736
|
}
|
|
9003
8737
|
if (event.type === "connected") {
|
|
9004
8738
|
this.emit("connected" /* Connected */, event.data);
|
|
8739
|
+
if (!event.data) {
|
|
8740
|
+
this.rejectAuth(new Error("Agent websocket disconnected before auth ack"));
|
|
8741
|
+
}
|
|
9005
8742
|
return;
|
|
9006
8743
|
}
|
|
9007
8744
|
if (event.type === "error") {
|
|
9008
8745
|
this.emit("error" /* Error */, event.data);
|
|
8746
|
+
this.rejectAuth(new Error("Agent websocket error before auth ack"));
|
|
9009
8747
|
}
|
|
9010
8748
|
}
|
|
9011
8749
|
handleIncomingMessage(message) {
|
|
9012
8750
|
if (!message || typeof message !== "object") {
|
|
9013
8751
|
return;
|
|
9014
8752
|
}
|
|
8753
|
+
if (message.opcode === 3 /* ACK */) {
|
|
8754
|
+
const ack = message.body;
|
|
8755
|
+
const success = ack?.status === "ok";
|
|
8756
|
+
if (!success) {
|
|
8757
|
+
this.rejectAuth(new Error(ack?.message ?? ack?.code ?? "Auth failed"));
|
|
8758
|
+
return;
|
|
8759
|
+
}
|
|
8760
|
+
this.resolveAuth();
|
|
8761
|
+
return;
|
|
8762
|
+
}
|
|
9015
8763
|
if (message.opcode === 2 /* AGENT */) {
|
|
9016
8764
|
const agentBody = message.body;
|
|
9017
8765
|
if (agentBody?.kind !== "response") {
|
|
@@ -9029,38 +8777,121 @@ var init_AgentClient = __esm({
|
|
|
9029
8777
|
this.tasks.handleResponse(body);
|
|
9030
8778
|
}
|
|
9031
8779
|
}
|
|
9032
|
-
|
|
9033
|
-
if (!
|
|
8780
|
+
ensureProtocol(value, protocol) {
|
|
8781
|
+
if (!value) {
|
|
8782
|
+
return "";
|
|
8783
|
+
}
|
|
8784
|
+
if (/^[a-z]+:\/\//i.test(value)) {
|
|
8785
|
+
try {
|
|
8786
|
+
const url = new URL(value);
|
|
8787
|
+
url.protocol = `${protocol}:`;
|
|
8788
|
+
return url.toString();
|
|
8789
|
+
} catch {
|
|
8790
|
+
return value;
|
|
8791
|
+
}
|
|
8792
|
+
}
|
|
8793
|
+
if (value.startsWith("//")) {
|
|
8794
|
+
return `${protocol}:${value}`;
|
|
8795
|
+
}
|
|
8796
|
+
return `${protocol}://${value}`;
|
|
8797
|
+
}
|
|
8798
|
+
waitForConnection(timeoutMs) {
|
|
8799
|
+
if (!this.ws) {
|
|
8800
|
+
return Promise.reject(new Error("Websocket client not initialized"));
|
|
8801
|
+
}
|
|
8802
|
+
if (this.ws.isConnected()) {
|
|
8803
|
+
return Promise.resolve();
|
|
8804
|
+
}
|
|
8805
|
+
return new Promise((resolve, reject) => {
|
|
8806
|
+
const timer = setTimeout(() => {
|
|
8807
|
+
off();
|
|
8808
|
+
reject(new Error("Websocket connect timeout"));
|
|
8809
|
+
}, timeoutMs);
|
|
8810
|
+
const off = this.on("connected" /* Connected */, (connected) => {
|
|
8811
|
+
if (connected) {
|
|
8812
|
+
clearTimeout(timer);
|
|
8813
|
+
off();
|
|
8814
|
+
resolve();
|
|
8815
|
+
}
|
|
8816
|
+
});
|
|
8817
|
+
});
|
|
8818
|
+
}
|
|
8819
|
+
async sendAuth(token, timeoutMs, profileId) {
|
|
8820
|
+
if (!this.ws || !this.from) {
|
|
8821
|
+
throw new Error("AgentClient not initialized");
|
|
8822
|
+
}
|
|
8823
|
+
const body = {
|
|
8824
|
+
token,
|
|
8825
|
+
as: "user",
|
|
8826
|
+
profileId
|
|
8827
|
+
};
|
|
8828
|
+
const msg = Msg.create(this.from, "@hub", 4 /* AUTH */, body);
|
|
8829
|
+
const waiter = this.waitForAuthAck(timeoutMs);
|
|
8830
|
+
await this.ws.sendMsg(msg);
|
|
8831
|
+
await waiter;
|
|
8832
|
+
}
|
|
8833
|
+
waitForAuthAck(timeoutMs) {
|
|
8834
|
+
if (this.authPromise) {
|
|
8835
|
+
return this.authPromise;
|
|
8836
|
+
}
|
|
8837
|
+
this.authPromise = new Promise((resolve, reject) => {
|
|
8838
|
+
this.authResolve = resolve;
|
|
8839
|
+
this.authReject = reject;
|
|
8840
|
+
this.authTimer = setTimeout(() => {
|
|
8841
|
+
this.clearAuthWaiter();
|
|
8842
|
+
reject(new Error("Auth timeout"));
|
|
8843
|
+
}, timeoutMs);
|
|
8844
|
+
});
|
|
8845
|
+
return this.authPromise;
|
|
8846
|
+
}
|
|
8847
|
+
resolveAuth() {
|
|
8848
|
+
if (!this.authResolve) {
|
|
9034
8849
|
return;
|
|
9035
8850
|
}
|
|
9036
|
-
this.
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
8851
|
+
const resolve = this.authResolve;
|
|
8852
|
+
this.clearAuthWaiter();
|
|
8853
|
+
resolve();
|
|
8854
|
+
}
|
|
8855
|
+
rejectAuth(error) {
|
|
8856
|
+
if (!this.authReject) {
|
|
8857
|
+
return;
|
|
8858
|
+
}
|
|
8859
|
+
const reject = this.authReject;
|
|
8860
|
+
this.clearAuthWaiter();
|
|
8861
|
+
reject(error);
|
|
8862
|
+
}
|
|
8863
|
+
clearAuthWaiter() {
|
|
8864
|
+
if (this.authTimer) {
|
|
8865
|
+
clearTimeout(this.authTimer);
|
|
8866
|
+
this.authTimer = null;
|
|
8867
|
+
}
|
|
8868
|
+
this.authPromise = null;
|
|
8869
|
+
this.authResolve = null;
|
|
8870
|
+
this.authReject = null;
|
|
9040
8871
|
}
|
|
9041
8872
|
};
|
|
9042
8873
|
}
|
|
9043
8874
|
});
|
|
9044
8875
|
|
|
9045
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8876
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentRuntime.js
|
|
9046
8877
|
var init_AgentRuntime = __esm({
|
|
9047
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8878
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentRuntime.js"() {
|
|
9048
8879
|
"use strict";
|
|
9049
8880
|
init_src();
|
|
9050
8881
|
init_src3();
|
|
9051
8882
|
}
|
|
9052
8883
|
});
|
|
9053
8884
|
|
|
9054
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8885
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js
|
|
9055
8886
|
var init_PromptTaskContext = __esm({
|
|
9056
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8887
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptTaskContext.js"() {
|
|
9057
8888
|
"use strict";
|
|
9058
8889
|
}
|
|
9059
8890
|
});
|
|
9060
8891
|
|
|
9061
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8892
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptAgent.js
|
|
9062
8893
|
var init_PromptAgent = __esm({
|
|
9063
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8894
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/PromptAgent.js"() {
|
|
9064
8895
|
"use strict";
|
|
9065
8896
|
init_src();
|
|
9066
8897
|
init_src3();
|
|
@@ -9070,16 +8901,16 @@ var init_PromptAgent = __esm({
|
|
|
9070
8901
|
}
|
|
9071
8902
|
});
|
|
9072
8903
|
|
|
9073
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8904
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js
|
|
9074
8905
|
var init_StreamTaskContext = __esm({
|
|
9075
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8906
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamTaskContext.js"() {
|
|
9076
8907
|
"use strict";
|
|
9077
8908
|
}
|
|
9078
8909
|
});
|
|
9079
8910
|
|
|
9080
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8911
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamAgent.js
|
|
9081
8912
|
var init_StreamAgent = __esm({
|
|
9082
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8913
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/StreamAgent.js"() {
|
|
9083
8914
|
"use strict";
|
|
9084
8915
|
init_src();
|
|
9085
8916
|
init_src3();
|
|
@@ -9088,16 +8919,16 @@ var init_StreamAgent = __esm({
|
|
|
9088
8919
|
}
|
|
9089
8920
|
});
|
|
9090
8921
|
|
|
9091
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8922
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentFactory.js
|
|
9092
8923
|
var init_AgentFactory = __esm({
|
|
9093
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8924
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentFactory.js"() {
|
|
9094
8925
|
"use strict";
|
|
9095
8926
|
init_PromptAgent();
|
|
9096
8927
|
init_StreamAgent();
|
|
9097
8928
|
}
|
|
9098
8929
|
});
|
|
9099
8930
|
|
|
9100
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8931
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentService.js
|
|
9101
8932
|
function parseAgentId(agentId) {
|
|
9102
8933
|
const separatorIndex = agentId.indexOf(":");
|
|
9103
8934
|
if (separatorIndex <= 0 || separatorIndex === agentId.length - 1) {
|
|
@@ -9127,7 +8958,7 @@ function trimTrailingSlash(value) {
|
|
|
9127
8958
|
}
|
|
9128
8959
|
var AgentService;
|
|
9129
8960
|
var init_AgentService = __esm({
|
|
9130
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
8961
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/AgentService.js"() {
|
|
9131
8962
|
"use strict";
|
|
9132
8963
|
AgentService = class {
|
|
9133
8964
|
constructor(options) {
|
|
@@ -9168,9 +8999,9 @@ var init_AgentService = __esm({
|
|
|
9168
8999
|
}
|
|
9169
9000
|
});
|
|
9170
9001
|
|
|
9171
|
-
// node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
9002
|
+
// node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/index.js
|
|
9172
9003
|
var init_dist2 = __esm({
|
|
9173
|
-
"node_modules/.pnpm/@pmate+agent-sdk@1.1.
|
|
9004
|
+
"node_modules/.pnpm/@pmate+agent-sdk@1.1.14/node_modules/@pmate/agent-sdk/dist/index.js"() {
|
|
9174
9005
|
"use strict";
|
|
9175
9006
|
init_AgentClient();
|
|
9176
9007
|
init_AgentFactory();
|
|
@@ -9329,8 +9160,8 @@ __export(index_exports, {
|
|
|
9329
9160
|
parseCommandArgs: () => parseCommandArgs
|
|
9330
9161
|
});
|
|
9331
9162
|
module.exports = __toCommonJS(index_exports);
|
|
9332
|
-
var
|
|
9333
|
-
var
|
|
9163
|
+
var import_node_fs24 = require("fs");
|
|
9164
|
+
var import_node_path28 = __toESM(require("path"));
|
|
9334
9165
|
var import_chalk4 = __toESM(require("chalk"));
|
|
9335
9166
|
|
|
9336
9167
|
// src/cli.ts
|
|
@@ -10417,9 +10248,13 @@ var AliyunService = class {
|
|
|
10417
10248
|
const relativePath = import_node_path4.default.relative(localDir, filePath);
|
|
10418
10249
|
const objectKey = this.toObjectKey(normalizedPrefix, relativePath);
|
|
10419
10250
|
const contentType = this.getContentType(filePath);
|
|
10420
|
-
const
|
|
10251
|
+
const cacheControl = this.getStaticAssetCacheControl(relativePath);
|
|
10252
|
+
const headers = {};
|
|
10253
|
+
if (contentType) headers["Content-Type"] = contentType;
|
|
10254
|
+
if (cacheControl) headers["Cache-Control"] = cacheControl;
|
|
10255
|
+
const options = Object.keys(headers).length > 0 ? { headers } : void 0;
|
|
10421
10256
|
const existing = existingMap.get(objectKey);
|
|
10422
|
-
if (existing && typeof existing.size === "number") {
|
|
10257
|
+
if (existing && typeof existing.size === "number" && !cacheControl) {
|
|
10423
10258
|
const stat = await import_node_fs3.promises.stat(filePath);
|
|
10424
10259
|
if (stat.size === existing.size) {
|
|
10425
10260
|
const etag = this.normalizeEtag(existing.etag);
|
|
@@ -10450,7 +10285,11 @@ var AliyunService = class {
|
|
|
10450
10285
|
}
|
|
10451
10286
|
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
10452
10287
|
const contentType = this.getContentType(localFile);
|
|
10453
|
-
const
|
|
10288
|
+
const cacheControl = this.getStaticAssetCacheControl(objectKey);
|
|
10289
|
+
const headers = {};
|
|
10290
|
+
if (contentType) headers["Content-Type"] = contentType;
|
|
10291
|
+
if (cacheControl) headers["Cache-Control"] = cacheControl;
|
|
10292
|
+
const options = Object.keys(headers).length > 0 ? { headers } : void 0;
|
|
10454
10293
|
await client.put(objectKey, localFile, options);
|
|
10455
10294
|
ui.success(`Uploaded ${objectKey}`);
|
|
10456
10295
|
}
|
|
@@ -10887,6 +10726,17 @@ var AliyunService = class {
|
|
|
10887
10726
|
return void 0;
|
|
10888
10727
|
}
|
|
10889
10728
|
}
|
|
10729
|
+
static getStaticAssetCacheControl(filePath) {
|
|
10730
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
10731
|
+
const base = import_node_path4.default.posix.basename(normalized).toLowerCase();
|
|
10732
|
+
if (base === "index.html" || base === "200.html" || base === "404.html") {
|
|
10733
|
+
return "no-cache, no-store, must-revalidate";
|
|
10734
|
+
}
|
|
10735
|
+
if (/[.-][a-z0-9_-]{8,}\./i.test(base)) {
|
|
10736
|
+
return "public, max-age=31536000, immutable";
|
|
10737
|
+
}
|
|
10738
|
+
return void 0;
|
|
10739
|
+
}
|
|
10890
10740
|
static buildFcPathConfig(input) {
|
|
10891
10741
|
return new import_fc20230330.PathConfig({
|
|
10892
10742
|
path: input.routePath ?? "/*",
|
|
@@ -14764,9 +14614,9 @@ ${indent}\`\`\``;
|
|
|
14764
14614
|
static richTextToPlain(richText) {
|
|
14765
14615
|
return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
|
|
14766
14616
|
}
|
|
14767
|
-
static async requestJson(
|
|
14617
|
+
static async requestJson(path29, init) {
|
|
14768
14618
|
const token = this.getToken();
|
|
14769
|
-
const response = await fetch(`${this.baseUrl}${
|
|
14619
|
+
const response = await fetch(`${this.baseUrl}${path29}`, {
|
|
14770
14620
|
method: init.method,
|
|
14771
14621
|
headers: {
|
|
14772
14622
|
Authorization: `Bearer ${token}`,
|
|
@@ -15883,6 +15733,9 @@ var QuizCommandHandler = class {
|
|
|
15883
15733
|
};
|
|
15884
15734
|
|
|
15885
15735
|
// src/commands/CollectCommandHandler.ts
|
|
15736
|
+
var import_node_fs13 = require("fs");
|
|
15737
|
+
var import_node_os7 = __toESM(require("os"));
|
|
15738
|
+
var import_node_path18 = __toESM(require("path"));
|
|
15886
15739
|
var import_playwright = require("playwright");
|
|
15887
15740
|
|
|
15888
15741
|
// src/collectStore.ts
|
|
@@ -16085,6 +15938,12 @@ var CollectCommandHandler = class {
|
|
|
16085
15938
|
collectedAt: syncedAt
|
|
16086
15939
|
}));
|
|
16087
15940
|
const merged = mergeMessages(existing?.messages ?? [], incoming);
|
|
15941
|
+
const messagesWithArchivedImages = await archiveMessageImages(
|
|
15942
|
+
rootDir,
|
|
15943
|
+
target.sourceKey,
|
|
15944
|
+
threadKey,
|
|
15945
|
+
merged.messages
|
|
15946
|
+
);
|
|
16088
15947
|
const stored = {
|
|
16089
15948
|
source: target.sourceKey,
|
|
16090
15949
|
endpoint: target.endpoint,
|
|
@@ -16094,8 +15953,8 @@ var CollectCommandHandler = class {
|
|
|
16094
15953
|
unread: thread.unread,
|
|
16095
15954
|
lastMessageAt: thread.time,
|
|
16096
15955
|
lastSyncedAt: syncedAt,
|
|
16097
|
-
messageCount:
|
|
16098
|
-
messages:
|
|
15956
|
+
messageCount: messagesWithArchivedImages.length,
|
|
15957
|
+
messages: messagesWithArchivedImages
|
|
16099
15958
|
};
|
|
16100
15959
|
await writeStoredThread(rootDir, stored);
|
|
16101
15960
|
return {
|
|
@@ -16246,6 +16105,50 @@ var CollectCommandHandler = class {
|
|
|
16246
16105
|
}
|
|
16247
16106
|
}
|
|
16248
16107
|
};
|
|
16108
|
+
async function archiveMessageImages(rootDir, sourceKey, threadKey, messages2) {
|
|
16109
|
+
const attachmentRoot = resolveLocalAttachmentRoot(sourceKey);
|
|
16110
|
+
if (!attachmentRoot) {
|
|
16111
|
+
return messages2;
|
|
16112
|
+
}
|
|
16113
|
+
return Promise.all(
|
|
16114
|
+
messages2.map(async (message) => ({
|
|
16115
|
+
...message,
|
|
16116
|
+
images: await Promise.all(
|
|
16117
|
+
message.images.map(
|
|
16118
|
+
(imagePath) => archiveMessageImage(rootDir, attachmentRoot, threadKey, imagePath)
|
|
16119
|
+
)
|
|
16120
|
+
)
|
|
16121
|
+
}))
|
|
16122
|
+
);
|
|
16123
|
+
}
|
|
16124
|
+
async function archiveMessageImage(rootDir, attachmentRoot, threadKey, imagePath) {
|
|
16125
|
+
if (!imagePath || isExternalImageRef(imagePath) || imagePath.startsWith("attachments/")) {
|
|
16126
|
+
return imagePath;
|
|
16127
|
+
}
|
|
16128
|
+
const normalized = import_node_path18.default.posix.normalize(imagePath.replace(/\\/g, "/"));
|
|
16129
|
+
if (normalized.startsWith("../") || import_node_path18.default.posix.isAbsolute(normalized)) {
|
|
16130
|
+
return imagePath;
|
|
16131
|
+
}
|
|
16132
|
+
const sourcePath = import_node_path18.default.join(attachmentRoot, ...normalized.split("/"));
|
|
16133
|
+
const destinationRelativePath = import_node_path18.default.posix.join("attachments", threadKey, normalized);
|
|
16134
|
+
const destinationPath = import_node_path18.default.join(rootDir, ...destinationRelativePath.split("/"));
|
|
16135
|
+
try {
|
|
16136
|
+
await import_node_fs13.promises.mkdir(import_node_path18.default.dirname(destinationPath), { recursive: true });
|
|
16137
|
+
await import_node_fs13.promises.copyFile(sourcePath, destinationPath);
|
|
16138
|
+
return destinationRelativePath;
|
|
16139
|
+
} catch {
|
|
16140
|
+
return imagePath;
|
|
16141
|
+
}
|
|
16142
|
+
}
|
|
16143
|
+
function resolveLocalAttachmentRoot(sourceKey) {
|
|
16144
|
+
if (sourceKey !== "cc" && sourceKey !== "yelling") {
|
|
16145
|
+
return null;
|
|
16146
|
+
}
|
|
16147
|
+
return import_node_path18.default.join(import_node_os7.default.homedir(), "Library", "Application Support", sourceKey, "attachments.noindex");
|
|
16148
|
+
}
|
|
16149
|
+
function isExternalImageRef(imagePath) {
|
|
16150
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(imagePath);
|
|
16151
|
+
}
|
|
16249
16152
|
function normalizeText(value) {
|
|
16250
16153
|
return value.replace(/\s+/g, " ").replace(/\u200B/g, "").trim();
|
|
16251
16154
|
}
|
|
@@ -16470,7 +16373,7 @@ function pad2(value) {
|
|
|
16470
16373
|
}
|
|
16471
16374
|
|
|
16472
16375
|
// src/commands/ChatRoomCommandHandler.ts
|
|
16473
|
-
var
|
|
16376
|
+
var import_node_fs14 = require("fs");
|
|
16474
16377
|
var ChatRoomCommandHandler = class {
|
|
16475
16378
|
async handle(args) {
|
|
16476
16379
|
const sdk = await loadChatSdk();
|
|
@@ -16520,8 +16423,8 @@ var ChatRoomCommandHandler = class {
|
|
|
16520
16423
|
const a = await this.connect(sdk, args.botA, args.app, args.hubUrl, args.authBaseUrl);
|
|
16521
16424
|
const b = await this.connect(sdk, args.botB, args.app, args.hubUrl, args.authBaseUrl);
|
|
16522
16425
|
try {
|
|
16523
|
-
const botA = sdk.parsePmateBotKeyJson((0,
|
|
16524
|
-
const botB = sdk.parsePmateBotKeyJson((0,
|
|
16426
|
+
const botA = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(args.botA, "utf8"));
|
|
16427
|
+
const botB = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(args.botB, "utf8"));
|
|
16525
16428
|
await a.requestFriend({ to: botB.name, message: "smoke friend request" });
|
|
16526
16429
|
await b.acceptFriend({ to: botA.name, message: "smoke friend accept" });
|
|
16527
16430
|
await a.sendDm({ to: botB.name, text: "smoke dm from a" });
|
|
@@ -16540,7 +16443,7 @@ var ChatRoomCommandHandler = class {
|
|
|
16540
16443
|
if (!botPath) {
|
|
16541
16444
|
throw new Error("Missing required option: --bot");
|
|
16542
16445
|
}
|
|
16543
|
-
const botKey = sdk.parsePmateBotKeyJson((0,
|
|
16446
|
+
const botKey = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(botPath, "utf8"));
|
|
16544
16447
|
const client = sdk.createChatClient({ appId, botKey, hubUrl, authBaseUrl });
|
|
16545
16448
|
await client.connect();
|
|
16546
16449
|
return client;
|
|
@@ -16552,8 +16455,8 @@ async function loadChatSdk() {
|
|
|
16552
16455
|
}
|
|
16553
16456
|
|
|
16554
16457
|
// src/commands/AgentCommandHandler.ts
|
|
16555
|
-
var
|
|
16556
|
-
var
|
|
16458
|
+
var import_node_fs15 = require("fs");
|
|
16459
|
+
var import_node_path19 = __toESM(require("path"));
|
|
16557
16460
|
init_AgentLlmClient();
|
|
16558
16461
|
init_sessionStore();
|
|
16559
16462
|
|
|
@@ -16586,8 +16489,8 @@ function descriptorPathSegments(descriptor) {
|
|
|
16586
16489
|
return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
|
|
16587
16490
|
}
|
|
16588
16491
|
function buildPathUrl(baseUrl, pathSegments, query) {
|
|
16589
|
-
const
|
|
16590
|
-
const url = new URL(
|
|
16492
|
+
const path29 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
16493
|
+
const url = new URL(path29, baseUrl);
|
|
16591
16494
|
if (query) {
|
|
16592
16495
|
for (const [key, value] of Object.entries(query)) {
|
|
16593
16496
|
url.searchParams.set(key, String(value));
|
|
@@ -17044,11 +16947,11 @@ var AgentCommandHandler = class {
|
|
|
17044
16947
|
}).token;
|
|
17045
16948
|
}
|
|
17046
16949
|
readJsonFile(filePath) {
|
|
17047
|
-
const absolutePath =
|
|
17048
|
-
if (!(0,
|
|
16950
|
+
const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
|
|
16951
|
+
if (!(0, import_node_fs15.existsSync)(absolutePath)) {
|
|
17049
16952
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17050
16953
|
}
|
|
17051
|
-
const raw = (0,
|
|
16954
|
+
const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
|
|
17052
16955
|
try {
|
|
17053
16956
|
return JSON.parse(raw);
|
|
17054
16957
|
} catch (error) {
|
|
@@ -17059,14 +16962,14 @@ var AgentCommandHandler = class {
|
|
|
17059
16962
|
readJsonObjectFile(filePath) {
|
|
17060
16963
|
const parsed = this.readJsonFile(filePath);
|
|
17061
16964
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
17062
|
-
const absolutePath =
|
|
16965
|
+
const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
|
|
17063
16966
|
throw new Error(`Invalid JSON in ${absolutePath}: expected an object`);
|
|
17064
16967
|
}
|
|
17065
16968
|
return parsed;
|
|
17066
16969
|
}
|
|
17067
16970
|
tryReadJsonObjectFile(filePath) {
|
|
17068
16971
|
const absolutePath = this.resolveExistingFile(filePath);
|
|
17069
|
-
const raw = (0,
|
|
16972
|
+
const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
|
|
17070
16973
|
try {
|
|
17071
16974
|
const parsed = JSON.parse(raw);
|
|
17072
16975
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -17078,8 +16981,8 @@ var AgentCommandHandler = class {
|
|
|
17078
16981
|
}
|
|
17079
16982
|
}
|
|
17080
16983
|
resolveExistingFile(filePath) {
|
|
17081
|
-
const absolutePath =
|
|
17082
|
-
if (!(0,
|
|
16984
|
+
const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
|
|
16985
|
+
if (!(0, import_node_fs15.existsSync)(absolutePath)) {
|
|
17083
16986
|
throw new Error(`File not found: ${absolutePath}`);
|
|
17084
16987
|
}
|
|
17085
16988
|
return absolutePath;
|
|
@@ -17163,8 +17066,8 @@ var AgentCommandHandler = class {
|
|
|
17163
17066
|
};
|
|
17164
17067
|
|
|
17165
17068
|
// src/commands/RunnerCommandHandler.ts
|
|
17166
|
-
var
|
|
17167
|
-
var
|
|
17069
|
+
var import_node_fs16 = require("fs");
|
|
17070
|
+
var import_node_path20 = __toESM(require("path"));
|
|
17168
17071
|
init_sessionStore();
|
|
17169
17072
|
init_namespacedRef();
|
|
17170
17073
|
var RunnerCommandHandler = class {
|
|
@@ -17259,11 +17162,11 @@ var RunnerCommandHandler = class {
|
|
|
17259
17162
|
}).token;
|
|
17260
17163
|
}
|
|
17261
17164
|
readJsonFile(filePath) {
|
|
17262
|
-
const absolutePath =
|
|
17263
|
-
if (!(0,
|
|
17165
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
17166
|
+
if (!(0, import_node_fs16.existsSync)(absolutePath)) {
|
|
17264
17167
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17265
17168
|
}
|
|
17266
|
-
const raw = (0,
|
|
17169
|
+
const raw = (0, import_node_fs16.readFileSync)(absolutePath, "utf8");
|
|
17267
17170
|
try {
|
|
17268
17171
|
return JSON.parse(raw);
|
|
17269
17172
|
} catch (error) {
|
|
@@ -17382,8 +17285,8 @@ var NsCommandHandler = class {
|
|
|
17382
17285
|
};
|
|
17383
17286
|
|
|
17384
17287
|
// src/commands/StoreCommandHandler.ts
|
|
17385
|
-
var
|
|
17386
|
-
var
|
|
17288
|
+
var import_node_fs17 = require("fs");
|
|
17289
|
+
var import_node_path21 = __toESM(require("path"));
|
|
17387
17290
|
var StoreCommandHandler = class {
|
|
17388
17291
|
async handle(args) {
|
|
17389
17292
|
if (args.scope === "namespace") {
|
|
@@ -17525,11 +17428,11 @@ var StoreCommandHandler = class {
|
|
|
17525
17428
|
return payload.data ?? [];
|
|
17526
17429
|
}
|
|
17527
17430
|
readJsonFile(filePath) {
|
|
17528
|
-
const absolutePath =
|
|
17529
|
-
if (!(0,
|
|
17431
|
+
const absolutePath = import_node_path21.default.resolve(process.cwd(), filePath);
|
|
17432
|
+
if (!(0, import_node_fs17.existsSync)(absolutePath)) {
|
|
17530
17433
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17531
17434
|
}
|
|
17532
|
-
const raw = (0,
|
|
17435
|
+
const raw = (0, import_node_fs17.readFileSync)(absolutePath, "utf8");
|
|
17533
17436
|
try {
|
|
17534
17437
|
return JSON.parse(raw);
|
|
17535
17438
|
} catch (error) {
|
|
@@ -17581,14 +17484,14 @@ var StoreCommandHandler = class {
|
|
|
17581
17484
|
};
|
|
17582
17485
|
|
|
17583
17486
|
// src/commands/AppCommandHandler.ts
|
|
17584
|
-
var
|
|
17585
|
-
var
|
|
17487
|
+
var import_node_fs19 = require("fs");
|
|
17488
|
+
var import_node_path23 = __toESM(require("path"));
|
|
17586
17489
|
init_sessionStore();
|
|
17587
17490
|
|
|
17588
17491
|
// src/appIcon.ts
|
|
17589
|
-
var
|
|
17590
|
-
var
|
|
17591
|
-
var
|
|
17492
|
+
var import_node_fs18 = require("fs");
|
|
17493
|
+
var import_node_os8 = __toESM(require("os"));
|
|
17494
|
+
var import_node_path22 = __toESM(require("path"));
|
|
17592
17495
|
var import_sharp = __toESM(require("sharp"));
|
|
17593
17496
|
init_namespacedRef();
|
|
17594
17497
|
var ANDROID_ICON_SPECS = [
|
|
@@ -17693,13 +17596,13 @@ function createAppIconExportPlans(input) {
|
|
|
17693
17596
|
if (!input.outDir) {
|
|
17694
17597
|
throw new Error("App icon preset export requires --out-dir.");
|
|
17695
17598
|
}
|
|
17696
|
-
const outDir =
|
|
17697
|
-
(0,
|
|
17599
|
+
const outDir = import_node_path22.default.resolve(input.cwd, input.outDir);
|
|
17600
|
+
(0, import_node_fs18.mkdirSync)(outDir, { recursive: true });
|
|
17698
17601
|
return specs.map((spec) => ({
|
|
17699
17602
|
width: spec.width,
|
|
17700
17603
|
height: spec.height,
|
|
17701
17604
|
format: "png",
|
|
17702
|
-
outputPath:
|
|
17605
|
+
outputPath: import_node_path22.default.join(
|
|
17703
17606
|
outDir,
|
|
17704
17607
|
`${namespace}-${objectId}-${spec.name}-${spec.width}x${spec.height}.png`
|
|
17705
17608
|
)
|
|
@@ -17712,8 +17615,8 @@ function createAppIconExportPlans(input) {
|
|
|
17712
17615
|
if (!input.output) {
|
|
17713
17616
|
throw new Error("Single-size app icon export requires --output.");
|
|
17714
17617
|
}
|
|
17715
|
-
const resolvedOutput =
|
|
17716
|
-
(0,
|
|
17618
|
+
const resolvedOutput = import_node_path22.default.resolve(input.cwd, input.output);
|
|
17619
|
+
(0, import_node_fs18.mkdirSync)(import_node_path22.default.dirname(resolvedOutput), { recursive: true });
|
|
17717
17620
|
return [
|
|
17718
17621
|
{
|
|
17719
17622
|
width: input.width,
|
|
@@ -17727,7 +17630,7 @@ async function exportAppIcon(icon, plans) {
|
|
|
17727
17630
|
const svg = await resolveAppIconSvg(icon);
|
|
17728
17631
|
for (const plan of plans) {
|
|
17729
17632
|
const bytes = await renderAppIcon(svg, plan.width, plan.height, plan.format);
|
|
17730
|
-
(0,
|
|
17633
|
+
(0, import_node_fs18.writeFileSync)(plan.outputPath, bytes);
|
|
17731
17634
|
}
|
|
17732
17635
|
}
|
|
17733
17636
|
async function renderAppIconVariant(input) {
|
|
@@ -17735,9 +17638,9 @@ async function renderAppIconVariant(input) {
|
|
|
17735
17638
|
const bytes = await renderAppIcon(svg, input.width, input.height, input.format);
|
|
17736
17639
|
let outputPath;
|
|
17737
17640
|
if (input.output) {
|
|
17738
|
-
outputPath =
|
|
17739
|
-
(0,
|
|
17740
|
-
(0,
|
|
17641
|
+
outputPath = import_node_path22.default.resolve(input.cwd, input.output);
|
|
17642
|
+
(0, import_node_fs18.mkdirSync)(import_node_path22.default.dirname(outputPath), { recursive: true });
|
|
17643
|
+
(0, import_node_fs18.writeFileSync)(outputPath, bytes);
|
|
17741
17644
|
}
|
|
17742
17645
|
if (input.name) {
|
|
17743
17646
|
return {
|
|
@@ -17758,7 +17661,7 @@ async function renderAppIconVariant(input) {
|
|
|
17758
17661
|
};
|
|
17759
17662
|
}
|
|
17760
17663
|
async function loadAppIconVariantFile(input) {
|
|
17761
|
-
const absolutePath =
|
|
17664
|
+
const absolutePath = import_node_path22.default.resolve(input.cwd, input.filePath);
|
|
17762
17665
|
const format = inferVariantFormatFromPath(absolutePath);
|
|
17763
17666
|
return {
|
|
17764
17667
|
value: input.name ? await uploadAppIconVariantAsset({
|
|
@@ -17767,7 +17670,7 @@ async function loadAppIconVariantFile(input) {
|
|
|
17767
17670
|
name: input.name,
|
|
17768
17671
|
format,
|
|
17769
17672
|
sourcePath: absolutePath
|
|
17770
|
-
}) : createImageDataUrl((0,
|
|
17673
|
+
}) : createImageDataUrl((0, import_node_fs18.readFileSync)(absolutePath), format),
|
|
17771
17674
|
format,
|
|
17772
17675
|
absolutePath
|
|
17773
17676
|
};
|
|
@@ -17826,7 +17729,7 @@ function shouldAutoGenerateDefaultVariant(icon) {
|
|
|
17826
17729
|
return looksLikeSvgMarkup(icon) || looksLikeSvgUrl(icon);
|
|
17827
17730
|
}
|
|
17828
17731
|
function inferVariantFormatFromPath(filePath) {
|
|
17829
|
-
const ext =
|
|
17732
|
+
const ext = import_node_path22.default.extname(filePath).toLowerCase();
|
|
17830
17733
|
switch (ext) {
|
|
17831
17734
|
case ".png":
|
|
17832
17735
|
return "png";
|
|
@@ -17897,13 +17800,13 @@ async function uploadAppIconVariantAsset(input) {
|
|
|
17897
17800
|
await AliyunService.uploadFile(sourcePath, DEFAULT_APP_ICON_VARIANT_BUCKET, objectKey);
|
|
17898
17801
|
} finally {
|
|
17899
17802
|
if (shouldCleanup) {
|
|
17900
|
-
(0,
|
|
17803
|
+
(0, import_node_fs18.rmSync)(import_node_path22.default.dirname(sourcePath), { recursive: true, force: true });
|
|
17901
17804
|
}
|
|
17902
17805
|
}
|
|
17903
17806
|
return `${DEFAULT_APP_ICON_VARIANT_PUBLIC_BASE_URL}/${objectKey}`;
|
|
17904
17807
|
}
|
|
17905
17808
|
function buildAppIconVariantObjectKey(input) {
|
|
17906
|
-
return
|
|
17809
|
+
return import_node_path22.default.posix.join(
|
|
17907
17810
|
"apps",
|
|
17908
17811
|
`${resolveAppIconAssetStem(input.icon, input.appRef)}-${input.name}.${extensionForIconFormat(input.format)}`
|
|
17909
17812
|
);
|
|
@@ -17912,8 +17815,8 @@ function resolveAppIconAssetStem(icon, appRef) {
|
|
|
17912
17815
|
if (icon) {
|
|
17913
17816
|
try {
|
|
17914
17817
|
const url = new URL(icon);
|
|
17915
|
-
const ext =
|
|
17916
|
-
const basename =
|
|
17818
|
+
const ext = import_node_path22.default.posix.extname(url.pathname);
|
|
17819
|
+
const basename = import_node_path22.default.posix.basename(url.pathname, ext);
|
|
17917
17820
|
const normalized = sanitizeAppIconAssetStem(basename);
|
|
17918
17821
|
if (normalized) {
|
|
17919
17822
|
return normalized;
|
|
@@ -17942,9 +17845,9 @@ function writeTempAppIconVariantFile(objectKey, format, bytes) {
|
|
|
17942
17845
|
if (!bytes) {
|
|
17943
17846
|
throw new Error("App icon variant upload requires bytes or a source file.");
|
|
17944
17847
|
}
|
|
17945
|
-
const tempDir = (0,
|
|
17946
|
-
const tempPath =
|
|
17947
|
-
(0,
|
|
17848
|
+
const tempDir = (0, import_node_fs18.mkdtempSync)(import_node_path22.default.join(import_node_os8.default.tmpdir(), "pmate-app-icon-"));
|
|
17849
|
+
const tempPath = import_node_path22.default.join(tempDir, import_node_path22.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
|
|
17850
|
+
(0, import_node_fs18.writeFileSync)(tempPath, bytes);
|
|
17948
17851
|
return tempPath;
|
|
17949
17852
|
}
|
|
17950
17853
|
|
|
@@ -18153,10 +18056,10 @@ var AppCommandHandler = class {
|
|
|
18153
18056
|
}
|
|
18154
18057
|
readJsonFile(filePath) {
|
|
18155
18058
|
const absolutePath = this.resolveFilePath(filePath);
|
|
18156
|
-
if (!(0,
|
|
18059
|
+
if (!(0, import_node_fs19.existsSync)(absolutePath)) {
|
|
18157
18060
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
18158
18061
|
}
|
|
18159
|
-
const raw = (0,
|
|
18062
|
+
const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
|
|
18160
18063
|
try {
|
|
18161
18064
|
return JSON.parse(raw);
|
|
18162
18065
|
} catch (error) {
|
|
@@ -18166,10 +18069,10 @@ var AppCommandHandler = class {
|
|
|
18166
18069
|
}
|
|
18167
18070
|
async preparePayload(filePath, appRef) {
|
|
18168
18071
|
const absolutePath = this.resolveFilePath(filePath);
|
|
18169
|
-
return prepareAppPayload(this.readJsonFile(filePath),
|
|
18072
|
+
return prepareAppPayload(this.readJsonFile(filePath), import_node_path23.default.dirname(absolutePath), { appRef });
|
|
18170
18073
|
}
|
|
18171
18074
|
resolveFilePath(filePath) {
|
|
18172
|
-
return
|
|
18075
|
+
return import_node_path23.default.resolve(process.cwd(), filePath);
|
|
18173
18076
|
}
|
|
18174
18077
|
async request(baseUrl, token, method, pathname, body) {
|
|
18175
18078
|
const response = await fetch(`${baseUrl}${pathname}`, {
|
|
@@ -18289,16 +18192,16 @@ function readNamespaceFromPayload(payload) {
|
|
|
18289
18192
|
}
|
|
18290
18193
|
|
|
18291
18194
|
// src/commands/ServiceCommandHandler.ts
|
|
18292
|
-
var
|
|
18195
|
+
var import_node_fs21 = require("fs");
|
|
18293
18196
|
var import_promises6 = require("fs/promises");
|
|
18294
|
-
var
|
|
18197
|
+
var import_node_path25 = __toESM(require("path"));
|
|
18295
18198
|
var import_node_child_process11 = require("child_process");
|
|
18296
18199
|
var import_promises7 = require("readline/promises");
|
|
18297
18200
|
|
|
18298
18201
|
// src/services/ServiceRuntimeRunner.ts
|
|
18299
|
-
var
|
|
18300
|
-
var
|
|
18301
|
-
var
|
|
18202
|
+
var import_node_fs20 = require("fs");
|
|
18203
|
+
var import_node_os9 = __toESM(require("os"));
|
|
18204
|
+
var import_node_path24 = __toESM(require("path"));
|
|
18302
18205
|
var import_node_child_process10 = require("child_process");
|
|
18303
18206
|
var import_node_readline = require("readline");
|
|
18304
18207
|
var import_chalk3 = __toESM(require("chalk"));
|
|
@@ -18744,18 +18647,18 @@ var ServiceRuntimeRunner = class {
|
|
|
18744
18647
|
}
|
|
18745
18648
|
resolveRepoRoot(service, cwd) {
|
|
18746
18649
|
if (cwd) {
|
|
18747
|
-
return
|
|
18650
|
+
return import_node_path24.default.resolve(process.cwd(), cwd);
|
|
18748
18651
|
}
|
|
18749
18652
|
const repository = this.getType(service) === "vite" || this.getType(service) === "static" ? this.getSite(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();
|
|
18750
18653
|
if (repository) {
|
|
18751
18654
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
18752
18655
|
if (repoName) {
|
|
18753
18656
|
const candidates = [
|
|
18754
|
-
|
|
18755
|
-
|
|
18657
|
+
import_node_path24.default.join(import_node_os9.default.homedir(), "dev", "pmate", repoName),
|
|
18658
|
+
import_node_path24.default.join(import_node_os9.default.homedir(), "dev", "pmate-envs", repoName)
|
|
18756
18659
|
];
|
|
18757
18660
|
for (const candidate of candidates) {
|
|
18758
|
-
if ((0,
|
|
18661
|
+
if ((0, import_node_fs20.existsSync)(candidate)) {
|
|
18759
18662
|
return candidate;
|
|
18760
18663
|
}
|
|
18761
18664
|
}
|
|
@@ -18769,12 +18672,12 @@ var ServiceRuntimeRunner = class {
|
|
|
18769
18672
|
if (!dir) {
|
|
18770
18673
|
throw new Error(`Missing service dir for ${service.id}`);
|
|
18771
18674
|
}
|
|
18772
|
-
return
|
|
18675
|
+
return import_node_path24.default.resolve(repoRoot, dir);
|
|
18773
18676
|
}
|
|
18774
18677
|
async deployVite(service, options) {
|
|
18775
18678
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
18776
|
-
const packageJsonPath =
|
|
18777
|
-
if (!(0,
|
|
18679
|
+
const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
|
|
18680
|
+
if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
|
|
18778
18681
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
18779
18682
|
}
|
|
18780
18683
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -18783,8 +18686,8 @@ var ServiceRuntimeRunner = class {
|
|
|
18783
18686
|
throw new Error(`Missing package name in ${packageJsonPath}`);
|
|
18784
18687
|
}
|
|
18785
18688
|
await this.runCommand("pnpm", ["--filter", pkgName, "build"], this.resolveRepoRoot(service, options.cwd));
|
|
18786
|
-
const distDir =
|
|
18787
|
-
if (!(0,
|
|
18689
|
+
const distDir = import_node_path24.default.join(appDir, "dist");
|
|
18690
|
+
if (!(0, import_node_fs20.existsSync)(distDir)) {
|
|
18788
18691
|
throw new Error(`No dist directory found at ${distDir}`);
|
|
18789
18692
|
}
|
|
18790
18693
|
const site = this.getSite(service);
|
|
@@ -18796,8 +18699,8 @@ var ServiceRuntimeRunner = class {
|
|
|
18796
18699
|
}
|
|
18797
18700
|
async deployStatic(service, options) {
|
|
18798
18701
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
18799
|
-
const srcDir =
|
|
18800
|
-
if (!(0,
|
|
18702
|
+
const srcDir = import_node_path24.default.join(appDir, "src");
|
|
18703
|
+
if (!(0, import_node_fs20.existsSync)(srcDir)) {
|
|
18801
18704
|
throw new Error(`No src directory found at ${srcDir}`);
|
|
18802
18705
|
}
|
|
18803
18706
|
const site = this.getSite(service);
|
|
@@ -18812,8 +18715,8 @@ var ServiceRuntimeRunner = class {
|
|
|
18812
18715
|
this.validateFcConfig(service, fc);
|
|
18813
18716
|
const repoRoot = this.resolveRepoRoot(service);
|
|
18814
18717
|
const appDir = this.resolveLocalDir(service);
|
|
18815
|
-
const packageJsonPath =
|
|
18816
|
-
if (!(0,
|
|
18718
|
+
const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
|
|
18719
|
+
if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
|
|
18817
18720
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
18818
18721
|
}
|
|
18819
18722
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -18866,15 +18769,15 @@ var ServiceRuntimeRunner = class {
|
|
|
18866
18769
|
const repoRoot = this.resolveRepoRoot(service, options.cwd);
|
|
18867
18770
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
18868
18771
|
await this.ensurePnpmWorkspaceRoot(repoRoot);
|
|
18869
|
-
const configPath =
|
|
18870
|
-
if (!(0,
|
|
18772
|
+
const configPath = import_node_path24.default.join(appDir, fc.configFile ?? "s.yaml");
|
|
18773
|
+
if (!(0, import_node_fs20.existsSync)(configPath)) {
|
|
18871
18774
|
throw new Error(`Missing FC config file at ${configPath}`);
|
|
18872
18775
|
}
|
|
18873
|
-
const packageJsonPath =
|
|
18874
|
-
if (!(0,
|
|
18776
|
+
const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
|
|
18777
|
+
if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
|
|
18875
18778
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
18876
18779
|
}
|
|
18877
|
-
const rawConfig = (0,
|
|
18780
|
+
const rawConfig = (0, import_node_fs20.readFileSync)(configPath, "utf8");
|
|
18878
18781
|
if (!rawConfig.includes(fc.functionName)) {
|
|
18879
18782
|
throw new Error(`FC config ${configPath} does not mention functionName ${fc.functionName}`);
|
|
18880
18783
|
}
|
|
@@ -19135,7 +19038,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19135
19038
|
const serverAddress = await resolveServerAddress(server);
|
|
19136
19039
|
const templateName = exposeType === "websocket" ? "nginx.ws.template" : "nginx.rest.template";
|
|
19137
19040
|
const templatePath = this.resolveTemplatePath(templateName);
|
|
19138
|
-
const template = (0,
|
|
19041
|
+
const template = (0, import_node_fs20.readFileSync)(templatePath, "utf8");
|
|
19139
19042
|
const host = `${subdomain}.${("domain" in network ? network.domain?.trim() : void 0) || "pmate.chat"}`;
|
|
19140
19043
|
const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
|
|
19141
19044
|
const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
|
|
@@ -19167,11 +19070,11 @@ var ServiceRuntimeRunner = class {
|
|
|
19167
19070
|
}
|
|
19168
19071
|
if (config.ensurePackageJson) {
|
|
19169
19072
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19170
|
-
const packageJsonPath =
|
|
19171
|
-
if (!(0,
|
|
19073
|
+
const packageJsonPath = import_node_path24.default.join(appDir, "package.json");
|
|
19074
|
+
if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
|
|
19172
19075
|
throw new Error(`Missing package.json at ${packageJsonPath}`);
|
|
19173
19076
|
}
|
|
19174
|
-
const pkgStat = (0,
|
|
19077
|
+
const pkgStat = (0, import_node_fs20.statSync)(packageJsonPath);
|
|
19175
19078
|
if (!pkgStat.isFile()) {
|
|
19176
19079
|
throw new Error(`package.json is not a file at ${packageJsonPath}`);
|
|
19177
19080
|
}
|
|
@@ -19601,9 +19504,9 @@ var ServiceRuntimeRunner = class {
|
|
|
19601
19504
|
return tokens;
|
|
19602
19505
|
}
|
|
19603
19506
|
readPathValue(source, pathExpr) {
|
|
19604
|
-
const
|
|
19507
|
+
const path29 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
19605
19508
|
let cursor = source;
|
|
19606
|
-
for (const segment of
|
|
19509
|
+
for (const segment of path29) {
|
|
19607
19510
|
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
|
|
19608
19511
|
return void 0;
|
|
19609
19512
|
}
|
|
@@ -19646,12 +19549,12 @@ var ServiceRuntimeRunner = class {
|
|
|
19646
19549
|
}
|
|
19647
19550
|
resolveTemplatePath(templateName) {
|
|
19648
19551
|
const candidates = [
|
|
19649
|
-
|
|
19650
|
-
|
|
19651
|
-
|
|
19552
|
+
import_node_path24.default.join(__dirname, "..", "templates", templateName),
|
|
19553
|
+
import_node_path24.default.join(__dirname, "..", "src", "templates", templateName),
|
|
19554
|
+
import_node_path24.default.join(__dirname, "templates", templateName)
|
|
19652
19555
|
];
|
|
19653
19556
|
for (const candidate of candidates) {
|
|
19654
|
-
if ((0,
|
|
19557
|
+
if ((0, import_node_fs20.existsSync)(candidate)) {
|
|
19655
19558
|
return candidate;
|
|
19656
19559
|
}
|
|
19657
19560
|
}
|
|
@@ -19683,7 +19586,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19683
19586
|
});
|
|
19684
19587
|
}
|
|
19685
19588
|
loadPackageJson(packageJsonPath) {
|
|
19686
|
-
const raw = (0,
|
|
19589
|
+
const raw = (0, import_node_fs20.readFileSync)(packageJsonPath, "utf8");
|
|
19687
19590
|
const parsed = JSON.parse(raw);
|
|
19688
19591
|
if (!parsed || typeof parsed !== "object") {
|
|
19689
19592
|
throw new Error(`Invalid package.json at ${packageJsonPath}`);
|
|
@@ -19692,7 +19595,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19692
19595
|
}
|
|
19693
19596
|
writePackageJson(packageJsonPath, data) {
|
|
19694
19597
|
const serialized = JSON.stringify(data, null, 2);
|
|
19695
|
-
(0,
|
|
19598
|
+
(0, import_node_fs20.writeFileSync)(packageJsonPath, `${serialized}
|
|
19696
19599
|
`, "utf8");
|
|
19697
19600
|
}
|
|
19698
19601
|
validateFcConfig(service, fc) {
|
|
@@ -19719,8 +19622,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19719
19622
|
}
|
|
19720
19623
|
}
|
|
19721
19624
|
async ensurePnpmWorkspaceRoot(repoRoot) {
|
|
19722
|
-
const workspacePath =
|
|
19723
|
-
if (!(0,
|
|
19625
|
+
const workspacePath = import_node_path24.default.join(repoRoot, "pnpm-workspace.yaml");
|
|
19626
|
+
if (!(0, import_node_fs20.existsSync)(workspacePath)) {
|
|
19724
19627
|
throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
|
|
19725
19628
|
}
|
|
19726
19629
|
}
|
|
@@ -19794,16 +19697,16 @@ var ServiceRuntimeRunner = class {
|
|
|
19794
19697
|
if (!privateKeyPath) {
|
|
19795
19698
|
throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
|
|
19796
19699
|
}
|
|
19797
|
-
if (!(0,
|
|
19700
|
+
if (!(0, import_node_fs20.existsSync)(certificatePath)) {
|
|
19798
19701
|
throw new Error(`SSL certificate file not found: ${certificatePath}`);
|
|
19799
19702
|
}
|
|
19800
|
-
if (!(0,
|
|
19703
|
+
if (!(0, import_node_fs20.existsSync)(privateKeyPath)) {
|
|
19801
19704
|
throw new Error(`SSL private key file not found: ${privateKeyPath}`);
|
|
19802
19705
|
}
|
|
19803
19706
|
return {
|
|
19804
19707
|
certName: host,
|
|
19805
|
-
certificate: (0,
|
|
19806
|
-
privateKey: (0,
|
|
19708
|
+
certificate: (0, import_node_fs20.readFileSync)(certificatePath, "utf8"),
|
|
19709
|
+
privateKey: (0, import_node_fs20.readFileSync)(privateKeyPath, "utf8")
|
|
19807
19710
|
};
|
|
19808
19711
|
}
|
|
19809
19712
|
resolveFcProtocol(fc, certConfig) {
|
|
@@ -20197,7 +20100,7 @@ var ServiceCommandHandler = class {
|
|
|
20197
20100
|
format: "dotenv"
|
|
20198
20101
|
}
|
|
20199
20102
|
);
|
|
20200
|
-
const outputPath =
|
|
20103
|
+
const outputPath = import_node_path25.default.resolve(process.cwd(), args.output);
|
|
20201
20104
|
await (0, import_promises6.writeFile)(outputPath, payload.content, "utf8");
|
|
20202
20105
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
20203
20106
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
@@ -20419,11 +20322,11 @@ var ServiceCommandHandler = class {
|
|
|
20419
20322
|
return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
20420
20323
|
}
|
|
20421
20324
|
readJsonFile(filePath) {
|
|
20422
|
-
const absolutePath =
|
|
20423
|
-
if (!(0,
|
|
20325
|
+
const absolutePath = import_node_path25.default.resolve(process.cwd(), filePath);
|
|
20326
|
+
if (!(0, import_node_fs21.existsSync)(absolutePath)) {
|
|
20424
20327
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
20425
20328
|
}
|
|
20426
|
-
const raw = (0,
|
|
20329
|
+
const raw = (0, import_node_fs21.readFileSync)(absolutePath, "utf8");
|
|
20427
20330
|
try {
|
|
20428
20331
|
return JSON.parse(raw);
|
|
20429
20332
|
} catch (error) {
|
|
@@ -21148,9 +21051,9 @@ var RoleCommandHandler = class {
|
|
|
21148
21051
|
};
|
|
21149
21052
|
|
|
21150
21053
|
// src/commands/AccountCommandHandler.ts
|
|
21151
|
-
var
|
|
21054
|
+
var import_node_fs22 = require("fs");
|
|
21152
21055
|
var import_node_crypto4 = require("crypto");
|
|
21153
|
-
var
|
|
21056
|
+
var import_node_path26 = __toESM(require("path"));
|
|
21154
21057
|
init_sessionStore();
|
|
21155
21058
|
var AccountCommandHandler = class {
|
|
21156
21059
|
async handle(args) {
|
|
@@ -21158,9 +21061,9 @@ var AccountCommandHandler = class {
|
|
|
21158
21061
|
case "bot-keygen": {
|
|
21159
21062
|
const keyFile = this.generateBotKeyFile(args.app, args.name);
|
|
21160
21063
|
const outPath = args.out ? this.resolveFilePath(args.out) : this.resolveDefaultBotKeyPath(args.app, args.name);
|
|
21161
|
-
(0,
|
|
21162
|
-
(0,
|
|
21163
|
-
(0,
|
|
21064
|
+
(0, import_node_fs22.mkdirSync)(import_node_path26.default.dirname(outPath), { recursive: true });
|
|
21065
|
+
(0, import_node_fs22.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
21066
|
+
(0, import_node_fs22.chmodSync)(outPath, 384);
|
|
21164
21067
|
if (!args.json) {
|
|
21165
21068
|
ui.success(`Bot key saved to ${outPath}`);
|
|
21166
21069
|
}
|
|
@@ -21610,10 +21513,10 @@ var AccountCommandHandler = class {
|
|
|
21610
21513
|
throw new Error("Missing visible apps input");
|
|
21611
21514
|
}
|
|
21612
21515
|
const absolutePath = this.resolveFilePath(args.filePath);
|
|
21613
|
-
if (!(0,
|
|
21516
|
+
if (!(0, import_node_fs22.existsSync)(absolutePath)) {
|
|
21614
21517
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
21615
21518
|
}
|
|
21616
|
-
const raw = (0,
|
|
21519
|
+
const raw = (0, import_node_fs22.readFileSync)(absolutePath, "utf8");
|
|
21617
21520
|
let parsed;
|
|
21618
21521
|
try {
|
|
21619
21522
|
parsed = JSON.parse(raw);
|
|
@@ -21627,10 +21530,10 @@ var AccountCommandHandler = class {
|
|
|
21627
21530
|
return parsed;
|
|
21628
21531
|
}
|
|
21629
21532
|
resolveFilePath(filePath) {
|
|
21630
|
-
return
|
|
21533
|
+
return import_node_path26.default.resolve(process.cwd(), filePath);
|
|
21631
21534
|
}
|
|
21632
21535
|
resolveDefaultBotKeyPath(app, name) {
|
|
21633
|
-
return
|
|
21536
|
+
return import_node_path26.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
|
|
21634
21537
|
}
|
|
21635
21538
|
homeDir() {
|
|
21636
21539
|
return process.env.HOME || process.env.USERPROFILE || process.cwd();
|
|
@@ -21653,10 +21556,10 @@ var AccountCommandHandler = class {
|
|
|
21653
21556
|
throw new Error("Missing bot key file");
|
|
21654
21557
|
}
|
|
21655
21558
|
const absolutePath = this.resolveFilePath(filePath);
|
|
21656
|
-
if (!(0,
|
|
21559
|
+
if (!(0, import_node_fs22.existsSync)(absolutePath)) {
|
|
21657
21560
|
throw new Error(`Bot key file not found: ${absolutePath}`);
|
|
21658
21561
|
}
|
|
21659
|
-
const parsed = JSON.parse((0,
|
|
21562
|
+
const parsed = JSON.parse((0, import_node_fs22.readFileSync)(absolutePath, "utf8"));
|
|
21660
21563
|
if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
|
|
21661
21564
|
throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
|
|
21662
21565
|
}
|
|
@@ -21708,8 +21611,8 @@ function encodePathSegment(value) {
|
|
|
21708
21611
|
}
|
|
21709
21612
|
|
|
21710
21613
|
// src/commands/OrgCommandHandler.ts
|
|
21711
|
-
var
|
|
21712
|
-
var
|
|
21614
|
+
var import_node_fs23 = require("fs");
|
|
21615
|
+
var import_node_path27 = __toESM(require("path"));
|
|
21713
21616
|
init_sessionStore();
|
|
21714
21617
|
var OrgCommandHandler = class {
|
|
21715
21618
|
async handle(args) {
|
|
@@ -21880,11 +21783,11 @@ var OrgCommandHandler = class {
|
|
|
21880
21783
|
if (!filePath) {
|
|
21881
21784
|
throw new Error(`Missing ${itemLabel} input`);
|
|
21882
21785
|
}
|
|
21883
|
-
const absolutePath =
|
|
21884
|
-
if (!(0,
|
|
21786
|
+
const absolutePath = import_node_path27.default.resolve(process.cwd(), filePath);
|
|
21787
|
+
if (!(0, import_node_fs23.existsSync)(absolutePath)) {
|
|
21885
21788
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
21886
21789
|
}
|
|
21887
|
-
const raw = (0,
|
|
21790
|
+
const raw = (0, import_node_fs23.readFileSync)(absolutePath, "utf8");
|
|
21888
21791
|
let parsed;
|
|
21889
21792
|
try {
|
|
21890
21793
|
parsed = JSON.parse(raw);
|
|
@@ -24960,7 +24863,7 @@ function requireValue12(tokens, option) {
|
|
|
24960
24863
|
|
|
24961
24864
|
// src/index.ts
|
|
24962
24865
|
var pkg = JSON.parse(
|
|
24963
|
-
(0,
|
|
24866
|
+
(0, import_node_fs24.readFileSync)(import_node_path28.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
24964
24867
|
);
|
|
24965
24868
|
var HELP_TEXT = [
|
|
24966
24869
|
import_chalk4.default.bold(`pmate v${pkg.version}`),
|