@pmate/cli 0.25.10 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.js +756 -721
- package/package.json +17 -10
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var init_namespacedRef = __esm({
|
|
|
88
88
|
|
|
89
89
|
// src/sessionStore.ts
|
|
90
90
|
function buildSessionStorePath() {
|
|
91
|
-
return
|
|
91
|
+
return import_node_path4.default.join(import_node_os3.default.homedir(), ".pmate", "session.json");
|
|
92
92
|
}
|
|
93
93
|
function assertValidAppRef(appRef) {
|
|
94
94
|
return parseNamespacedRef(appRef, { entityLabel: "app ref" }).fullId;
|
|
@@ -153,7 +153,7 @@ function loadSessionStore() {
|
|
|
153
153
|
}
|
|
154
154
|
function loadExistingSessionStoreOrEmpty() {
|
|
155
155
|
const sessionPath = buildSessionStorePath();
|
|
156
|
-
if (!(0,
|
|
156
|
+
if (!(0, import_node_fs3.existsSync)(sessionPath)) {
|
|
157
157
|
return {
|
|
158
158
|
version: SESSION_STORE_VERSION,
|
|
159
159
|
activeAppRef: DEFAULT_APP_ID,
|
|
@@ -172,10 +172,10 @@ function loadExistingSessionStoreOrEmpty() {
|
|
|
172
172
|
}
|
|
173
173
|
function loadSessionStoreWithPath() {
|
|
174
174
|
const sessionPath = buildSessionStorePath();
|
|
175
|
-
if (!(0,
|
|
175
|
+
if (!(0, import_node_fs3.existsSync)(sessionPath)) {
|
|
176
176
|
throw new Error(`Missing session file at ${sessionPath}. Run "pmate login" first.`);
|
|
177
177
|
}
|
|
178
|
-
const raw = (0,
|
|
178
|
+
const raw = (0, import_node_fs3.readFileSync)(sessionPath, "utf8");
|
|
179
179
|
const parsed = JSON.parse(raw);
|
|
180
180
|
const store = normalizeStore(parsed);
|
|
181
181
|
return { sessionPath, store };
|
|
@@ -265,12 +265,12 @@ function resolveReadApp(store, options) {
|
|
|
265
265
|
}
|
|
266
266
|
function writeSessionStore(store) {
|
|
267
267
|
const sessionPath = buildSessionStorePath();
|
|
268
|
-
(0,
|
|
269
|
-
(0,
|
|
268
|
+
(0, import_node_fs3.mkdirSync)(import_node_path4.default.dirname(sessionPath), { recursive: true });
|
|
269
|
+
(0, import_node_fs3.writeFileSync)(sessionPath, JSON.stringify(store, null, 2), {
|
|
270
270
|
mode: 384
|
|
271
271
|
});
|
|
272
272
|
try {
|
|
273
|
-
(0,
|
|
273
|
+
(0, import_node_fs3.chmodSync)(sessionPath, 384);
|
|
274
274
|
} catch {
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -280,173 +280,173 @@ function buildMissingSessionMessage(sessionPath, app) {
|
|
|
280
280
|
}
|
|
281
281
|
return `Missing session for app ${app} in ${sessionPath}. Run "pmate login --app ${app}" first.`;
|
|
282
282
|
}
|
|
283
|
-
var
|
|
283
|
+
var import_node_fs3, import_node_os3, import_node_path4, DEFAULT_APP_ID, SESSION_STORE_VERSION;
|
|
284
284
|
var init_sessionStore = __esm({
|
|
285
285
|
"src/sessionStore.ts"() {
|
|
286
286
|
"use strict";
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
import_node_fs3 = require("fs");
|
|
288
|
+
import_node_os3 = __toESM(require("os"));
|
|
289
|
+
import_node_path4 = __toESM(require("path"));
|
|
290
290
|
init_namespacedRef();
|
|
291
291
|
DEFAULT_APP_ID = "pmate:factory";
|
|
292
292
|
SESSION_STORE_VERSION = 4;
|
|
293
293
|
}
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
-
// node_modules/.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();
|
|
@@ -9212,7 +9043,7 @@ function unwrapAgentResult(agentId, value) {
|
|
|
9212
9043
|
return value;
|
|
9213
9044
|
}
|
|
9214
9045
|
function resolveMimeType(filePath) {
|
|
9215
|
-
const ext =
|
|
9046
|
+
const ext = import_node_path12.default.extname(filePath).toLowerCase();
|
|
9216
9047
|
switch (ext) {
|
|
9217
9048
|
case ".wav":
|
|
9218
9049
|
return "audio/wav";
|
|
@@ -9232,12 +9063,12 @@ function resolveMimeType(filePath) {
|
|
|
9232
9063
|
return "application/octet-stream";
|
|
9233
9064
|
}
|
|
9234
9065
|
}
|
|
9235
|
-
var
|
|
9066
|
+
var import_node_fs7, import_node_path12, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE, DEFAULT_AGENT_PROMPT_TIMEOUT_MS, AgentLlmClient;
|
|
9236
9067
|
var init_AgentLlmClient = __esm({
|
|
9237
9068
|
"src/llm/AgentLlmClient.ts"() {
|
|
9238
9069
|
"use strict";
|
|
9239
|
-
|
|
9240
|
-
|
|
9070
|
+
import_node_fs7 = require("fs");
|
|
9071
|
+
import_node_path12 = __toESM(require("path"));
|
|
9241
9072
|
init_dist2();
|
|
9242
9073
|
init_sessionStore();
|
|
9243
9074
|
DEFAULT_AGENT_API_BASE_URL = "https://agent-api.pmate.chat";
|
|
@@ -9304,7 +9135,7 @@ var init_AgentLlmClient = __esm({
|
|
|
9304
9135
|
params,
|
|
9305
9136
|
minChunkSizeBytes: 0
|
|
9306
9137
|
});
|
|
9307
|
-
const file = (0,
|
|
9138
|
+
const file = (0, import_node_fs7.readFileSync)(filePath);
|
|
9308
9139
|
input.push(new Blob([file], { type: resolveMimeType(filePath) }));
|
|
9309
9140
|
input.end();
|
|
9310
9141
|
return await stream.finish();
|
|
@@ -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_fs25 = require("fs");
|
|
9164
|
+
var import_node_path30 = __toESM(require("path"));
|
|
9334
9165
|
var import_chalk4 = __toESM(require("chalk"));
|
|
9335
9166
|
|
|
9336
9167
|
// src/cli.ts
|
|
@@ -9762,8 +9593,67 @@ var ListCommandHandler = class {
|
|
|
9762
9593
|
|
|
9763
9594
|
// src/commands/LoginCommandHandler.ts
|
|
9764
9595
|
var import_node_child_process = require("child_process");
|
|
9596
|
+
var import_node_path5 = __toESM(require("path"));
|
|
9765
9597
|
var import_node_http = require("http");
|
|
9766
9598
|
var import_promises = require("readline/promises");
|
|
9599
|
+
|
|
9600
|
+
// src/accessKeyFile.ts
|
|
9601
|
+
var import_node_fs2 = require("fs");
|
|
9602
|
+
var import_node_os2 = __toESM(require("os"));
|
|
9603
|
+
var import_node_path3 = __toESM(require("path"));
|
|
9604
|
+
function readAccessKeyFile(filePath, options = {}) {
|
|
9605
|
+
const absolutePath = resolveFilePath(filePath, options.cwd);
|
|
9606
|
+
if (!(0, import_node_fs2.existsSync)(absolutePath)) {
|
|
9607
|
+
throw new Error(`Access key file not found: ${absolutePath}`);
|
|
9608
|
+
}
|
|
9609
|
+
let parsed;
|
|
9610
|
+
try {
|
|
9611
|
+
parsed = JSON.parse((0, import_node_fs2.readFileSync)(absolutePath, "utf8"));
|
|
9612
|
+
} catch (error) {
|
|
9613
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9614
|
+
throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
|
|
9615
|
+
}
|
|
9616
|
+
if (!isAccessKeyFile(parsed)) {
|
|
9617
|
+
throw new Error(`Invalid PMate access key file: ${absolutePath}`);
|
|
9618
|
+
}
|
|
9619
|
+
if (options.expectedApp && parsed.app !== options.expectedApp) {
|
|
9620
|
+
throw new Error(
|
|
9621
|
+
`Access key app mismatch. expected=${options.expectedApp}, received=${parsed.app}`
|
|
9622
|
+
);
|
|
9623
|
+
}
|
|
9624
|
+
return parsed;
|
|
9625
|
+
}
|
|
9626
|
+
function scanAccessKeyFiles(app) {
|
|
9627
|
+
const dir = resolveAccessKeyDir(app);
|
|
9628
|
+
if (!(0, import_node_fs2.existsSync)(dir)) {
|
|
9629
|
+
return [];
|
|
9630
|
+
}
|
|
9631
|
+
return (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".access-key.json")).map((entry) => import_node_path3.default.join(dir, entry.name)).flatMap((filePath) => {
|
|
9632
|
+
try {
|
|
9633
|
+
return [{ filePath, key: readAccessKeyFile(filePath, { expectedApp: app }) }];
|
|
9634
|
+
} catch {
|
|
9635
|
+
return [];
|
|
9636
|
+
}
|
|
9637
|
+
}).sort((a, b) => a.key.name.localeCompare(b.key.name) || a.filePath.localeCompare(b.filePath));
|
|
9638
|
+
}
|
|
9639
|
+
function resolveAccessKeyDir(app) {
|
|
9640
|
+
return import_node_path3.default.join(homeDir(), ".pmate", "access-keys", app);
|
|
9641
|
+
}
|
|
9642
|
+
function resolveFilePath(filePath, cwd = process.cwd()) {
|
|
9643
|
+
return import_node_path3.default.isAbsolute(filePath) ? filePath : import_node_path3.default.resolve(cwd, filePath);
|
|
9644
|
+
}
|
|
9645
|
+
function homeDir() {
|
|
9646
|
+
return process.env.HOME || process.env.USERPROFILE || import_node_os2.default.homedir() || process.cwd();
|
|
9647
|
+
}
|
|
9648
|
+
function isAccessKeyFile(value) {
|
|
9649
|
+
if (!value || typeof value !== "object") {
|
|
9650
|
+
return false;
|
|
9651
|
+
}
|
|
9652
|
+
const candidate = value;
|
|
9653
|
+
return candidate.type === "pmate-access-key" && candidate.version === 1 && typeof candidate.id === "string" && !!candidate.id.trim() && typeof candidate.app === "string" && !!candidate.app.trim() && typeof candidate.name === "string" && !!candidate.name.trim() && typeof candidate.secret === "string" && !!candidate.secret.trim() && typeof candidate.expiresAt === "string" && !!candidate.expiresAt.trim() && typeof candidate.createdAt === "string" && !!candidate.createdAt.trim();
|
|
9654
|
+
}
|
|
9655
|
+
|
|
9656
|
+
// src/commands/LoginCommandHandler.ts
|
|
9767
9657
|
init_sessionStore();
|
|
9768
9658
|
|
|
9769
9659
|
// src/profileClient.ts
|
|
@@ -9810,7 +9700,6 @@ function resolveAuthApiBaseUrl(value) {
|
|
|
9810
9700
|
|
|
9811
9701
|
// src/commands/LoginCommandHandler.ts
|
|
9812
9702
|
var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
|
|
9813
|
-
var AUTH_API_BASE_URL = DEFAULT_AUTH_API_BASE_URL;
|
|
9814
9703
|
var CALLBACK_PATH = "/pmate-login-callback";
|
|
9815
9704
|
var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
9816
9705
|
function buildHostedLoginUrl(redirectUrl, appId = DEFAULT_APP_ID) {
|
|
@@ -9822,6 +9711,13 @@ function buildHostedLoginUrl(redirectUrl, appId = DEFAULT_APP_ID) {
|
|
|
9822
9711
|
}
|
|
9823
9712
|
var LoginCommandHandler = class {
|
|
9824
9713
|
async handle(args) {
|
|
9714
|
+
if (args.accessKey || args.accessKeyFile || args.accessKeyScan) {
|
|
9715
|
+
await this.handleAccessKeyLogin(args);
|
|
9716
|
+
return;
|
|
9717
|
+
}
|
|
9718
|
+
await this.handleHostedLogin(args);
|
|
9719
|
+
}
|
|
9720
|
+
async handleHostedLogin(args) {
|
|
9825
9721
|
const callback = await this.startCallbackServer();
|
|
9826
9722
|
const appId = assertValidAppRef(args.app?.trim() || DEFAULT_APP_ID);
|
|
9827
9723
|
const loginUrl = buildHostedLoginUrl(callback.redirectUrl, appId);
|
|
@@ -9849,6 +9745,7 @@ var LoginCommandHandler = class {
|
|
|
9849
9745
|
const profileId = await this.resolveProfileId({
|
|
9850
9746
|
appId,
|
|
9851
9747
|
requestedProfileId: args.profileId,
|
|
9748
|
+
selectProfile: args.selectProfile,
|
|
9852
9749
|
profiles
|
|
9853
9750
|
});
|
|
9854
9751
|
savedSession = saveLoginSession({ ...loginResponse, profileId }, appId);
|
|
@@ -9861,8 +9758,28 @@ var LoginCommandHandler = class {
|
|
|
9861
9758
|
);
|
|
9862
9759
|
}
|
|
9863
9760
|
}
|
|
9761
|
+
async handleAccessKeyLogin(args) {
|
|
9762
|
+
const resolved = await this.resolveAccessKeyInput(args);
|
|
9763
|
+
const appId = assertValidAppRef(resolved.app);
|
|
9764
|
+
const loginResponse = await this.exchangeAccessKeySession(resolved.secret, appId);
|
|
9765
|
+
const profiles = await fetchProfiles({
|
|
9766
|
+
token: loginResponse.token,
|
|
9767
|
+
app: appId,
|
|
9768
|
+
accountId: loginResponse.session.identity.accountId
|
|
9769
|
+
});
|
|
9770
|
+
const profileId = await this.resolveProfileId({
|
|
9771
|
+
appId,
|
|
9772
|
+
requestedProfileId: args.profileId,
|
|
9773
|
+
selectProfile: args.selectProfile,
|
|
9774
|
+
profiles
|
|
9775
|
+
});
|
|
9776
|
+
const savedSession = saveLoginSession({ ...loginResponse, profileId }, appId);
|
|
9777
|
+
ui.success(
|
|
9778
|
+
`Logged in to ${savedSession.app}. Session saved to ${savedSession.sessionPath}`
|
|
9779
|
+
);
|
|
9780
|
+
}
|
|
9864
9781
|
async exchangeSession(token, appId) {
|
|
9865
|
-
const response = await fetch(`${
|
|
9782
|
+
const response = await fetch(`${resolveAuthApiBaseUrl()}/session/exchange`, {
|
|
9866
9783
|
method: "POST",
|
|
9867
9784
|
headers: {
|
|
9868
9785
|
"Content-Type": "application/json",
|
|
@@ -9883,6 +9800,88 @@ var LoginCommandHandler = class {
|
|
|
9883
9800
|
}
|
|
9884
9801
|
return resp.data;
|
|
9885
9802
|
}
|
|
9803
|
+
async exchangeAccessKeySession(secret, appId) {
|
|
9804
|
+
const response = await fetch(`${resolveAuthApiBaseUrl()}/access-keys/session`, {
|
|
9805
|
+
method: "POST",
|
|
9806
|
+
headers: {
|
|
9807
|
+
"Content-Type": "application/json",
|
|
9808
|
+
Authorization: `Bearer ${secret}`
|
|
9809
|
+
},
|
|
9810
|
+
body: JSON.stringify({ app: appId })
|
|
9811
|
+
});
|
|
9812
|
+
if (!response.ok) {
|
|
9813
|
+
const detail = await response.text();
|
|
9814
|
+
throw new Error(
|
|
9815
|
+
`Failed to exchange access key session (${response.status}): ${detail || response.statusText}`
|
|
9816
|
+
);
|
|
9817
|
+
}
|
|
9818
|
+
const resp = await response.json();
|
|
9819
|
+
const returnedApp = resp?.data?.session?.identity?.app?.trim();
|
|
9820
|
+
if (!returnedApp || returnedApp !== appId) {
|
|
9821
|
+
throw new Error("Invalid access key session response: app-scoped session mismatch.");
|
|
9822
|
+
}
|
|
9823
|
+
return resp.data;
|
|
9824
|
+
}
|
|
9825
|
+
async resolveAccessKeyInput(args) {
|
|
9826
|
+
if (args.accessKey) {
|
|
9827
|
+
return {
|
|
9828
|
+
app: args.app?.trim() || DEFAULT_APP_ID,
|
|
9829
|
+
secret: args.accessKey.trim()
|
|
9830
|
+
};
|
|
9831
|
+
}
|
|
9832
|
+
if (args.accessKeyFile) {
|
|
9833
|
+
const key = readAccessKeyFile(args.accessKeyFile, {
|
|
9834
|
+
expectedApp: args.app?.trim()
|
|
9835
|
+
});
|
|
9836
|
+
return {
|
|
9837
|
+
app: args.app?.trim() || key.app,
|
|
9838
|
+
secret: key.secret
|
|
9839
|
+
};
|
|
9840
|
+
}
|
|
9841
|
+
const app = assertValidAppRef(args.app?.trim() || DEFAULT_APP_ID);
|
|
9842
|
+
const candidate = await this.selectScannedAccessKey(app);
|
|
9843
|
+
return {
|
|
9844
|
+
app,
|
|
9845
|
+
secret: candidate.key.secret
|
|
9846
|
+
};
|
|
9847
|
+
}
|
|
9848
|
+
async selectScannedAccessKey(app) {
|
|
9849
|
+
const candidates = scanAccessKeyFiles(app);
|
|
9850
|
+
if (candidates.length === 0) {
|
|
9851
|
+
throw new Error(
|
|
9852
|
+
`No access key found for app ${app}. Run "pmate account access-key create --app ${app} ..." or "pmate login --access-key-file <path>".`
|
|
9853
|
+
);
|
|
9854
|
+
}
|
|
9855
|
+
if (candidates.length === 1) {
|
|
9856
|
+
return candidates[0];
|
|
9857
|
+
}
|
|
9858
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
9859
|
+
const files = candidates.map((candidate) => candidate.filePath).join(", ");
|
|
9860
|
+
throw new Error(
|
|
9861
|
+
`Multiple access keys found for app ${app}. Run "pmate login --access-key-file <path>" with one of: ${files}`
|
|
9862
|
+
);
|
|
9863
|
+
}
|
|
9864
|
+
ui.info(`Multiple access keys found for ${app}. Select one:`);
|
|
9865
|
+
candidates.forEach((candidate, index) => {
|
|
9866
|
+
ui.plain(`${index + 1}. ${this.formatAccessKeyLabel(candidate)}`);
|
|
9867
|
+
});
|
|
9868
|
+
const rl = (0, import_promises.createInterface)({
|
|
9869
|
+
input: process.stdin,
|
|
9870
|
+
output: process.stdout
|
|
9871
|
+
});
|
|
9872
|
+
try {
|
|
9873
|
+
while (true) {
|
|
9874
|
+
const answer = (await rl.question("Access key number: ")).trim();
|
|
9875
|
+
const index = Number.parseInt(answer, 10);
|
|
9876
|
+
if (Number.isInteger(index) && index >= 1 && index <= candidates.length) {
|
|
9877
|
+
return candidates[index - 1];
|
|
9878
|
+
}
|
|
9879
|
+
ui.warn(`Enter a number from 1 to ${candidates.length}.`);
|
|
9880
|
+
}
|
|
9881
|
+
} finally {
|
|
9882
|
+
rl.close();
|
|
9883
|
+
}
|
|
9884
|
+
}
|
|
9886
9885
|
async resolveProfileId(input) {
|
|
9887
9886
|
const requestedProfileId = input.requestedProfileId?.trim();
|
|
9888
9887
|
if (requestedProfileId) {
|
|
@@ -9895,7 +9894,7 @@ var LoginCommandHandler = class {
|
|
|
9895
9894
|
if (input.profiles.length === 0) {
|
|
9896
9895
|
throw new Error(`No profile found for app ${input.appId}.`);
|
|
9897
9896
|
}
|
|
9898
|
-
if (input.profiles.length === 1) {
|
|
9897
|
+
if (input.profiles.length === 1 || !input.selectProfile) {
|
|
9899
9898
|
return input.profiles[0].id;
|
|
9900
9899
|
}
|
|
9901
9900
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
@@ -9925,6 +9924,17 @@ var LoginCommandHandler = class {
|
|
|
9925
9924
|
rl.close();
|
|
9926
9925
|
}
|
|
9927
9926
|
}
|
|
9927
|
+
formatAccessKeyLabel(candidate) {
|
|
9928
|
+
const key = candidate.key;
|
|
9929
|
+
const parts = [
|
|
9930
|
+
key.name?.trim(),
|
|
9931
|
+
key.id?.trim(),
|
|
9932
|
+
key.namespace?.trim(),
|
|
9933
|
+
`expires ${key.expiresAt}`,
|
|
9934
|
+
import_node_path5.default.relative(process.cwd(), candidate.filePath)
|
|
9935
|
+
].filter(Boolean);
|
|
9936
|
+
return parts.join(" / ");
|
|
9937
|
+
}
|
|
9928
9938
|
formatProfileLabel(profile) {
|
|
9929
9939
|
const parts = [
|
|
9930
9940
|
profile.nickName?.trim(),
|
|
@@ -10140,8 +10150,8 @@ var import_openapi_client = require("@alicloud/openapi-client");
|
|
|
10140
10150
|
var import_sts20150401 = __toESM(require("@alicloud/sts20150401"));
|
|
10141
10151
|
var import_ali_oss = __toESM(require("ali-oss"));
|
|
10142
10152
|
var import_node_crypto = require("crypto");
|
|
10143
|
-
var
|
|
10144
|
-
var
|
|
10153
|
+
var import_node_fs4 = require("fs");
|
|
10154
|
+
var import_node_path6 = __toESM(require("path"));
|
|
10145
10155
|
|
|
10146
10156
|
// src/certs.ts
|
|
10147
10157
|
var DEFAULT_SSL_CERT_KEY = "pmate-01";
|
|
@@ -10434,7 +10444,7 @@ var AliyunService = class {
|
|
|
10434
10444
|
])
|
|
10435
10445
|
);
|
|
10436
10446
|
for (const filePath of files) {
|
|
10437
|
-
const relativePath =
|
|
10447
|
+
const relativePath = import_node_path6.default.relative(localDir, filePath);
|
|
10438
10448
|
const objectKey = this.toObjectKey(normalizedPrefix, relativePath);
|
|
10439
10449
|
const contentType = this.getContentType(filePath);
|
|
10440
10450
|
const cacheControl = this.getStaticAssetCacheControl(relativePath);
|
|
@@ -10444,7 +10454,7 @@ var AliyunService = class {
|
|
|
10444
10454
|
const options = Object.keys(headers).length > 0 ? { headers } : void 0;
|
|
10445
10455
|
const existing = existingMap.get(objectKey);
|
|
10446
10456
|
if (existing && typeof existing.size === "number" && !cacheControl) {
|
|
10447
|
-
const stat = await
|
|
10457
|
+
const stat = await import_node_fs4.promises.stat(filePath);
|
|
10448
10458
|
if (stat.size === existing.size) {
|
|
10449
10459
|
const etag = this.normalizeEtag(existing.etag);
|
|
10450
10460
|
if (etag && !etag.includes("-")) {
|
|
@@ -10469,7 +10479,7 @@ var AliyunService = class {
|
|
|
10469
10479
|
if (!region) throw new Error("Missing oss.public.region in ~/.pmate/config.yaml.");
|
|
10470
10480
|
if (!accessKeyId) throw new Error("Missing aliyun.ak in ~/.pmate/config.yaml.");
|
|
10471
10481
|
if (!accessKeySecret) throw new Error("Missing aliyun.sk in ~/.pmate/config.yaml.");
|
|
10472
|
-
if (!(0,
|
|
10482
|
+
if (!(0, import_node_fs4.existsSync)(localFile)) {
|
|
10473
10483
|
throw new Error(`File not found: ${localFile}`);
|
|
10474
10484
|
}
|
|
10475
10485
|
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
@@ -10658,7 +10668,10 @@ var AliyunService = class {
|
|
|
10658
10668
|
{
|
|
10659
10669
|
functionName: "host_redirect",
|
|
10660
10670
|
functionArgs: [
|
|
10661
|
-
{
|
|
10671
|
+
{
|
|
10672
|
+
argName: "regex",
|
|
10673
|
+
argValue: "^/(?!\\.well-known(?:/|$))(?!.*\\.[^/]+$).*"
|
|
10674
|
+
},
|
|
10662
10675
|
{ argName: "replacement", argValue: "/index.html" },
|
|
10663
10676
|
{ argName: "flag", argValue: "break" }
|
|
10664
10677
|
]
|
|
@@ -10677,7 +10690,10 @@ var AliyunService = class {
|
|
|
10677
10690
|
{
|
|
10678
10691
|
functionName: "host_redirect",
|
|
10679
10692
|
functionArgs: [
|
|
10680
|
-
{
|
|
10693
|
+
{
|
|
10694
|
+
argName: "regex",
|
|
10695
|
+
argValue: "^/(?!\\.well-known(?:/|$))(?!.*\\.[^/]+$)(.*?)(?:/)?$"
|
|
10696
|
+
},
|
|
10681
10697
|
{ argName: "replacement", argValue: "/$1/index.html" },
|
|
10682
10698
|
{ argName: "flag", argValue: "break" }
|
|
10683
10699
|
]
|
|
@@ -10810,10 +10826,10 @@ var AliyunService = class {
|
|
|
10810
10826
|
}
|
|
10811
10827
|
/** Recursively collect file paths under a directory. */
|
|
10812
10828
|
static async collectFiles(dir) {
|
|
10813
|
-
const entries = await
|
|
10829
|
+
const entries = await import_node_fs4.promises.readdir(dir, { withFileTypes: true });
|
|
10814
10830
|
const files = [];
|
|
10815
10831
|
for (const entry of entries) {
|
|
10816
|
-
const fullPath =
|
|
10832
|
+
const fullPath = import_node_path6.default.join(dir, entry.name);
|
|
10817
10833
|
if (entry.isDirectory()) {
|
|
10818
10834
|
files.push(...await this.collectFiles(fullPath));
|
|
10819
10835
|
} else if (entry.isFile()) {
|
|
@@ -10862,7 +10878,7 @@ var AliyunService = class {
|
|
|
10862
10878
|
static getFileMd5(filePath) {
|
|
10863
10879
|
return new Promise((resolve, reject) => {
|
|
10864
10880
|
const hash = (0, import_node_crypto.createHash)("md5");
|
|
10865
|
-
const stream = (0,
|
|
10881
|
+
const stream = (0, import_node_fs4.createReadStream)(filePath);
|
|
10866
10882
|
stream.on("data", (chunk) => {
|
|
10867
10883
|
hash.update(chunk);
|
|
10868
10884
|
});
|
|
@@ -10875,14 +10891,17 @@ var AliyunService = class {
|
|
|
10875
10891
|
});
|
|
10876
10892
|
}
|
|
10877
10893
|
static toObjectKey(prefix, relativePath) {
|
|
10878
|
-
const normalizedPath = relativePath.split(
|
|
10894
|
+
const normalizedPath = relativePath.split(import_node_path6.default.sep).join("/");
|
|
10879
10895
|
if (!prefix) {
|
|
10880
10896
|
return normalizedPath;
|
|
10881
10897
|
}
|
|
10882
10898
|
return `${prefix}/${normalizedPath}`;
|
|
10883
10899
|
}
|
|
10884
10900
|
static getContentType(filePath) {
|
|
10885
|
-
|
|
10901
|
+
if (import_node_path6.default.basename(filePath).toLowerCase() === "apple-app-site-association") {
|
|
10902
|
+
return "application/json";
|
|
10903
|
+
}
|
|
10904
|
+
const ext = import_node_path6.default.extname(filePath).toLowerCase();
|
|
10886
10905
|
switch (ext) {
|
|
10887
10906
|
case ".html":
|
|
10888
10907
|
return "text/html";
|
|
@@ -10925,8 +10944,8 @@ var AliyunService = class {
|
|
|
10925
10944
|
}
|
|
10926
10945
|
static getStaticAssetCacheControl(filePath) {
|
|
10927
10946
|
const normalized = filePath.replace(/\\/g, "/");
|
|
10928
|
-
const base =
|
|
10929
|
-
if (base === "index.html" || base === "200.html" || base === "404.html") {
|
|
10947
|
+
const base = import_node_path6.default.posix.basename(normalized).toLowerCase();
|
|
10948
|
+
if (base === "index.html" || base === "200.html" || base === "404.html" || base === "apple-app-site-association") {
|
|
10930
10949
|
return "no-cache, no-store, must-revalidate";
|
|
10931
10950
|
}
|
|
10932
10951
|
if (/[.-][a-z0-9_-]{8,}\./i.test(base)) {
|
|
@@ -11142,7 +11161,7 @@ var BucketCommandHandler = class {
|
|
|
11142
11161
|
};
|
|
11143
11162
|
|
|
11144
11163
|
// src/commands/DeleteCommandHandler.ts
|
|
11145
|
-
var
|
|
11164
|
+
var import_node_path7 = __toESM(require("path"));
|
|
11146
11165
|
var import_node_child_process2 = require("child_process");
|
|
11147
11166
|
|
|
11148
11167
|
// src/serverAddress.ts
|
|
@@ -11300,17 +11319,17 @@ var DeleteCommandHandler = class {
|
|
|
11300
11319
|
});
|
|
11301
11320
|
}
|
|
11302
11321
|
resolveCwd(target) {
|
|
11303
|
-
return target ?
|
|
11322
|
+
return target ? import_node_path7.default.resolve(process.cwd(), target) : process.cwd();
|
|
11304
11323
|
}
|
|
11305
11324
|
};
|
|
11306
11325
|
|
|
11307
11326
|
// src/commands/DevCommandHandler.ts
|
|
11308
|
-
var
|
|
11309
|
-
var
|
|
11327
|
+
var import_node_fs5 = require("fs");
|
|
11328
|
+
var import_node_path9 = __toESM(require("path"));
|
|
11310
11329
|
var import_node_child_process3 = require("child_process");
|
|
11311
11330
|
|
|
11312
11331
|
// src/appDir.ts
|
|
11313
|
-
var
|
|
11332
|
+
var import_node_path8 = __toESM(require("path"));
|
|
11314
11333
|
function normalizeRelativeDir(input, appName) {
|
|
11315
11334
|
if (typeof input !== "string") {
|
|
11316
11335
|
throw new Error(`Missing dir for ${appName} in .pmate.yaml`);
|
|
@@ -11323,7 +11342,7 @@ function normalizeRelativeDir(input, appName) {
|
|
|
11323
11342
|
if (unixLike.startsWith("/")) {
|
|
11324
11343
|
throw new Error(`Invalid dir for ${appName} in .pmate.yaml: must be relative`);
|
|
11325
11344
|
}
|
|
11326
|
-
const normalized =
|
|
11345
|
+
const normalized = import_node_path8.default.posix.normalize(unixLike);
|
|
11327
11346
|
if (normalized.startsWith("../") || normalized === "..") {
|
|
11328
11347
|
throw new Error(
|
|
11329
11348
|
`Invalid dir for ${appName} in .pmate.yaml: must stay within repo`
|
|
@@ -11333,7 +11352,7 @@ function normalizeRelativeDir(input, appName) {
|
|
|
11333
11352
|
}
|
|
11334
11353
|
function resolveLocalAppDir(repoRoot, appName, dir) {
|
|
11335
11354
|
const relative = normalizeRelativeDir(dir, appName);
|
|
11336
|
-
return
|
|
11355
|
+
return import_node_path8.default.resolve(repoRoot, relative);
|
|
11337
11356
|
}
|
|
11338
11357
|
function resolveRemoteAppDir(appName, dir) {
|
|
11339
11358
|
return normalizeRelativeDir(dir, appName);
|
|
@@ -11356,8 +11375,8 @@ var DevCommandHandler = class {
|
|
|
11356
11375
|
);
|
|
11357
11376
|
}
|
|
11358
11377
|
const appDir = resolveLocalAppDir(cwd, appName, appConfig.dir);
|
|
11359
|
-
const packageJsonPath =
|
|
11360
|
-
if (!(0,
|
|
11378
|
+
const packageJsonPath = import_node_path9.default.join(appDir, "package.json");
|
|
11379
|
+
if (!(0, import_node_fs5.existsSync)(packageJsonPath)) {
|
|
11361
11380
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
11362
11381
|
}
|
|
11363
11382
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -11371,13 +11390,13 @@ var DevCommandHandler = class {
|
|
|
11371
11390
|
await this.runCommand("pnpm", ["--filter", pkgName, "run", "dev"], cwd);
|
|
11372
11391
|
}
|
|
11373
11392
|
resolveCwd(target) {
|
|
11374
|
-
return target ?
|
|
11393
|
+
return target ? import_node_path9.default.resolve(process.cwd(), target) : process.cwd();
|
|
11375
11394
|
}
|
|
11376
11395
|
loadConfig(cwd) {
|
|
11377
11396
|
return loadAppConfig(cwd);
|
|
11378
11397
|
}
|
|
11379
11398
|
loadPackageJson(packageJsonPath) {
|
|
11380
|
-
const raw = (0,
|
|
11399
|
+
const raw = (0, import_node_fs5.readFileSync)(packageJsonPath, "utf8");
|
|
11381
11400
|
const parsed = JSON.parse(raw);
|
|
11382
11401
|
if (!parsed || typeof parsed !== "object") {
|
|
11383
11402
|
throw new Error(`Invalid package.json at ${packageJsonPath}`);
|
|
@@ -11405,8 +11424,8 @@ var DevCommandHandler = class {
|
|
|
11405
11424
|
};
|
|
11406
11425
|
|
|
11407
11426
|
// src/commands/OssCommandHandler.ts
|
|
11408
|
-
var
|
|
11409
|
-
var
|
|
11427
|
+
var import_node_fs6 = require("fs");
|
|
11428
|
+
var import_node_path10 = __toESM(require("path"));
|
|
11410
11429
|
var OssCommandHandler = class _OssCommandHandler {
|
|
11411
11430
|
static {
|
|
11412
11431
|
this.DEFAULT_BUCKET = "parrot-static";
|
|
@@ -11423,17 +11442,17 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
11423
11442
|
}
|
|
11424
11443
|
return;
|
|
11425
11444
|
}
|
|
11426
|
-
const resolvedFile =
|
|
11445
|
+
const resolvedFile = import_node_path10.default.resolve(process.cwd(), args.filePath);
|
|
11427
11446
|
this.assertFile(resolvedFile);
|
|
11428
11447
|
const objectKey = this.normalizeObjectKey(args.objectKey);
|
|
11429
11448
|
const bucket = this.resolveBucket(args.bucket);
|
|
11430
11449
|
await AliyunService.uploadFile(resolvedFile, bucket, objectKey);
|
|
11431
11450
|
}
|
|
11432
11451
|
assertFile(filePath) {
|
|
11433
|
-
if (!(0,
|
|
11452
|
+
if (!(0, import_node_fs6.existsSync)(filePath)) {
|
|
11434
11453
|
throw new Error(`File not found: ${filePath}`);
|
|
11435
11454
|
}
|
|
11436
|
-
const stat = (0,
|
|
11455
|
+
const stat = (0, import_node_fs6.statSync)(filePath);
|
|
11437
11456
|
if (!stat.isFile()) {
|
|
11438
11457
|
throw new Error(`Not a file: ${filePath}`);
|
|
11439
11458
|
}
|
|
@@ -11455,7 +11474,7 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
11455
11474
|
};
|
|
11456
11475
|
|
|
11457
11476
|
// src/commands/EnvCommandHandler.ts
|
|
11458
|
-
var
|
|
11477
|
+
var import_node_path11 = __toESM(require("path"));
|
|
11459
11478
|
var import_node_child_process4 = require("child_process");
|
|
11460
11479
|
|
|
11461
11480
|
// src/shell.ts
|
|
@@ -11539,8 +11558,8 @@ var EnvCommandHandler = class {
|
|
|
11539
11558
|
ui.success(`Set ${envKey} in .env.local`, appName);
|
|
11540
11559
|
}
|
|
11541
11560
|
async listEnvKeys(server, repoDir, appDir, verbose) {
|
|
11542
|
-
const envLocalPath =
|
|
11543
|
-
const envPath =
|
|
11561
|
+
const envLocalPath = import_node_path11.default.posix.join(appDir, ".env.local");
|
|
11562
|
+
const envPath = import_node_path11.default.posix.join(appDir, ".env");
|
|
11544
11563
|
if (verbose) {
|
|
11545
11564
|
const repoPath = `$HOME/${repoDir}`;
|
|
11546
11565
|
ui.info("Env list target", {
|
|
@@ -11633,8 +11652,8 @@ var EnvCommandHandler = class {
|
|
|
11633
11652
|
}
|
|
11634
11653
|
}
|
|
11635
11654
|
async appendEnvLine(server, repoDir, appDir, envKey, envLine, verbose) {
|
|
11636
|
-
const envLocalPath =
|
|
11637
|
-
const envPath =
|
|
11655
|
+
const envLocalPath = import_node_path11.default.posix.join(appDir, ".env.local");
|
|
11656
|
+
const envPath = import_node_path11.default.posix.join(appDir, ".env");
|
|
11638
11657
|
if (verbose) {
|
|
11639
11658
|
const repoPath = `$HOME/${repoDir}`;
|
|
11640
11659
|
ui.info("Env add target", {
|
|
@@ -11682,8 +11701,8 @@ var EnvCommandHandler = class {
|
|
|
11682
11701
|
await this.runRemoteCommand(server, command);
|
|
11683
11702
|
}
|
|
11684
11703
|
async deleteEnvKey(server, repoDir, appDir, envKey, verbose) {
|
|
11685
|
-
const envLocalPath =
|
|
11686
|
-
const envPath =
|
|
11704
|
+
const envLocalPath = import_node_path11.default.posix.join(appDir, ".env.local");
|
|
11705
|
+
const envPath = import_node_path11.default.posix.join(appDir, ".env");
|
|
11687
11706
|
if (verbose) {
|
|
11688
11707
|
const repoPath = `$HOME/${repoDir}`;
|
|
11689
11708
|
ui.info("Env delete target", {
|
|
@@ -12499,7 +12518,7 @@ var CommitCommandHandler = class {
|
|
|
12499
12518
|
|
|
12500
12519
|
// src/commands/SummaryCommandHandler.ts
|
|
12501
12520
|
var import_node_child_process6 = require("child_process");
|
|
12502
|
-
var
|
|
12521
|
+
var import_node_path13 = __toESM(require("path"));
|
|
12503
12522
|
var SummaryCommandHandler = class {
|
|
12504
12523
|
async handle(args) {
|
|
12505
12524
|
const cwd = this.resolveCwd(args.cwd);
|
|
@@ -12684,7 +12703,7 @@ var SummaryCommandHandler = class {
|
|
|
12684
12703
|
return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
|
|
12685
12704
|
}
|
|
12686
12705
|
resolveCwd(value) {
|
|
12687
|
-
return value ?
|
|
12706
|
+
return value ? import_node_path13.default.resolve(process.cwd(), value) : process.cwd();
|
|
12688
12707
|
}
|
|
12689
12708
|
};
|
|
12690
12709
|
function truncate2(value, limit) {
|
|
@@ -12697,9 +12716,9 @@ function truncate2(value, limit) {
|
|
|
12697
12716
|
|
|
12698
12717
|
// src/commands/LinearCommandHandler.ts
|
|
12699
12718
|
var import_node_child_process7 = require("child_process");
|
|
12700
|
-
var
|
|
12701
|
-
var
|
|
12702
|
-
var
|
|
12719
|
+
var import_node_fs8 = require("fs");
|
|
12720
|
+
var import_node_os4 = __toESM(require("os"));
|
|
12721
|
+
var import_node_path14 = __toESM(require("path"));
|
|
12703
12722
|
var import_promises3 = require("readline/promises");
|
|
12704
12723
|
var import_openai = __toESM(require("openai"));
|
|
12705
12724
|
var import_sdk = require("@linear/sdk");
|
|
@@ -13583,15 +13602,15 @@ var LinearCommandHandler = class {
|
|
|
13583
13602
|
}
|
|
13584
13603
|
}
|
|
13585
13604
|
getLinearSelectionPath() {
|
|
13586
|
-
return
|
|
13605
|
+
return import_node_path14.default.join(import_node_os4.default.homedir(), ".pmate", "linear-selection.json");
|
|
13587
13606
|
}
|
|
13588
13607
|
readCachedLinearSelection(cwd) {
|
|
13589
13608
|
const selectionPath = this.getLinearSelectionPath();
|
|
13590
|
-
if (!(0,
|
|
13609
|
+
if (!(0, import_node_fs8.existsSync)(selectionPath)) {
|
|
13591
13610
|
return void 0;
|
|
13592
13611
|
}
|
|
13593
13612
|
try {
|
|
13594
|
-
const raw = (0,
|
|
13613
|
+
const raw = (0, import_node_fs8.readFileSync)(selectionPath, "utf8").trim();
|
|
13595
13614
|
if (!raw) return void 0;
|
|
13596
13615
|
const parsed = JSON.parse(raw);
|
|
13597
13616
|
const value = parsed[cwd];
|
|
@@ -13602,12 +13621,12 @@ var LinearCommandHandler = class {
|
|
|
13602
13621
|
}
|
|
13603
13622
|
writeCachedLinearSelection(cwd, title) {
|
|
13604
13623
|
const selectionPath = this.getLinearSelectionPath();
|
|
13605
|
-
const dir =
|
|
13606
|
-
(0,
|
|
13624
|
+
const dir = import_node_path14.default.dirname(selectionPath);
|
|
13625
|
+
(0, import_node_fs8.mkdirSync)(dir, { recursive: true });
|
|
13607
13626
|
let data = {};
|
|
13608
|
-
if ((0,
|
|
13627
|
+
if ((0, import_node_fs8.existsSync)(selectionPath)) {
|
|
13609
13628
|
try {
|
|
13610
|
-
const raw = (0,
|
|
13629
|
+
const raw = (0, import_node_fs8.readFileSync)(selectionPath, "utf8").trim();
|
|
13611
13630
|
if (raw) {
|
|
13612
13631
|
data = JSON.parse(raw);
|
|
13613
13632
|
}
|
|
@@ -13616,7 +13635,7 @@ var LinearCommandHandler = class {
|
|
|
13616
13635
|
}
|
|
13617
13636
|
}
|
|
13618
13637
|
data[cwd] = title;
|
|
13619
|
-
(0,
|
|
13638
|
+
(0, import_node_fs8.writeFileSync)(selectionPath, `${JSON.stringify(data, null, 2)}
|
|
13620
13639
|
`, "utf8");
|
|
13621
13640
|
}
|
|
13622
13641
|
async lookupIssue(client, issueRef) {
|
|
@@ -13793,14 +13812,14 @@ var LinearCommandHandler = class {
|
|
|
13793
13812
|
if (process.platform !== "darwin") {
|
|
13794
13813
|
throw new Error("Screenshot capture only supports macOS.");
|
|
13795
13814
|
}
|
|
13796
|
-
const dir = await
|
|
13797
|
-
const filePath =
|
|
13815
|
+
const dir = await import_node_fs8.promises.mkdtemp(import_node_path14.default.join(import_node_os4.default.tmpdir(), "pmate-screenshot-"));
|
|
13816
|
+
const filePath = import_node_path14.default.join(dir, `screenshot-${index}.png`);
|
|
13798
13817
|
try {
|
|
13799
13818
|
const code = await this.run("screencapture", ["-i", "-x", filePath], true);
|
|
13800
13819
|
if (code !== 0) {
|
|
13801
13820
|
throw new Error("Screenshot capture canceled or failed.");
|
|
13802
13821
|
}
|
|
13803
|
-
const buffer = await
|
|
13822
|
+
const buffer = await import_node_fs8.promises.readFile(filePath);
|
|
13804
13823
|
if (buffer.length === 0) {
|
|
13805
13824
|
throw new Error("Screenshot capture produced an empty file.");
|
|
13806
13825
|
}
|
|
@@ -13812,7 +13831,7 @@ var LinearCommandHandler = class {
|
|
|
13812
13831
|
return { buffer, mime, filename: `screenshot-${index}.${extension}` };
|
|
13813
13832
|
} finally {
|
|
13814
13833
|
try {
|
|
13815
|
-
await
|
|
13834
|
+
await import_node_fs8.promises.rm(dir, { recursive: true, force: true });
|
|
13816
13835
|
} catch {
|
|
13817
13836
|
}
|
|
13818
13837
|
}
|
|
@@ -13956,17 +13975,17 @@ var LinearCommandHandler = class {
|
|
|
13956
13975
|
return compact.length > limit ? `${compact.slice(0, limit)}...` : compact;
|
|
13957
13976
|
}
|
|
13958
13977
|
async convertToPng(buffer, ext) {
|
|
13959
|
-
const dir = await
|
|
13960
|
-
const inputPath =
|
|
13961
|
-
const outputPath =
|
|
13978
|
+
const dir = await import_node_fs8.promises.mkdtemp(import_node_path14.default.join(import_node_os4.default.tmpdir(), "pmate-"));
|
|
13979
|
+
const inputPath = import_node_path14.default.join(dir, `clipboard.${ext}`);
|
|
13980
|
+
const outputPath = import_node_path14.default.join(dir, "clipboard.png");
|
|
13962
13981
|
try {
|
|
13963
|
-
await
|
|
13982
|
+
await import_node_fs8.promises.writeFile(inputPath, buffer);
|
|
13964
13983
|
const stderr = await this.runCapture(
|
|
13965
13984
|
"sips",
|
|
13966
13985
|
["-s", "format", "png", inputPath, "--out", outputPath],
|
|
13967
13986
|
true
|
|
13968
13987
|
);
|
|
13969
|
-
const out = await
|
|
13988
|
+
const out = await import_node_fs8.promises.readFile(outputPath);
|
|
13970
13989
|
if (this.detectImageMime(out) !== "image/png") {
|
|
13971
13990
|
throw new Error(
|
|
13972
13991
|
stderr?.trim() ? `Failed to convert clipboard ${ext} to PNG: ${stderr.trim()}` : `Failed to convert clipboard ${ext} to PNG.`
|
|
@@ -13975,7 +13994,7 @@ var LinearCommandHandler = class {
|
|
|
13975
13994
|
return out;
|
|
13976
13995
|
} finally {
|
|
13977
13996
|
try {
|
|
13978
|
-
await
|
|
13997
|
+
await import_node_fs8.promises.rm(dir, { recursive: true, force: true });
|
|
13979
13998
|
} catch {
|
|
13980
13999
|
}
|
|
13981
14000
|
}
|
|
@@ -14269,7 +14288,7 @@ var LinearCommandHandler = class {
|
|
|
14269
14288
|
return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
|
|
14270
14289
|
}
|
|
14271
14290
|
resolveCwd(value) {
|
|
14272
|
-
return value ?
|
|
14291
|
+
return value ? import_node_path14.default.resolve(process.cwd(), value) : process.cwd();
|
|
14273
14292
|
}
|
|
14274
14293
|
createOpenAiClient() {
|
|
14275
14294
|
const config = loadPmateConfig();
|
|
@@ -14321,8 +14340,8 @@ function sleep2(ms) {
|
|
|
14321
14340
|
}
|
|
14322
14341
|
|
|
14323
14342
|
// src/commands/NotionCommandHandler.ts
|
|
14324
|
-
var
|
|
14325
|
-
var
|
|
14343
|
+
var import_node_fs9 = require("fs");
|
|
14344
|
+
var import_node_path15 = __toESM(require("path"));
|
|
14326
14345
|
|
|
14327
14346
|
// src/services/NotionService.ts
|
|
14328
14347
|
var NotionService = class {
|
|
@@ -14561,9 +14580,9 @@ ${indent}\`\`\``;
|
|
|
14561
14580
|
static richTextToPlain(richText) {
|
|
14562
14581
|
return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
|
|
14563
14582
|
}
|
|
14564
|
-
static async requestJson(
|
|
14583
|
+
static async requestJson(path31, init) {
|
|
14565
14584
|
const token = this.getToken();
|
|
14566
|
-
const response = await fetch(`${this.baseUrl}${
|
|
14585
|
+
const response = await fetch(`${this.baseUrl}${path31}`, {
|
|
14567
14586
|
method: init.method,
|
|
14568
14587
|
headers: {
|
|
14569
14588
|
Authorization: `Bearer ${token}`,
|
|
@@ -14661,16 +14680,16 @@ var NotionCommandHandler = class {
|
|
|
14661
14680
|
if (!args.filePath) {
|
|
14662
14681
|
return "";
|
|
14663
14682
|
}
|
|
14664
|
-
const resolved =
|
|
14665
|
-
return (0,
|
|
14683
|
+
const resolved = import_node_path15.default.resolve(process.cwd(), args.filePath);
|
|
14684
|
+
return (0, import_node_fs9.readFileSync)(resolved, "utf8");
|
|
14666
14685
|
}
|
|
14667
14686
|
};
|
|
14668
14687
|
|
|
14669
14688
|
// src/commands/QrcodeCommandHandler.ts
|
|
14670
14689
|
var import_node_child_process8 = require("child_process");
|
|
14671
|
-
var
|
|
14672
|
-
var
|
|
14673
|
-
var
|
|
14690
|
+
var import_node_fs10 = require("fs");
|
|
14691
|
+
var import_node_os5 = __toESM(require("os"));
|
|
14692
|
+
var import_node_path16 = __toESM(require("path"));
|
|
14674
14693
|
var import_promises4 = require("readline/promises");
|
|
14675
14694
|
var import_jsqr = __toESM(require("jsqr"));
|
|
14676
14695
|
var import_pngjs = require("pngjs");
|
|
@@ -14696,7 +14715,7 @@ var QrcodeCommandHandler = class {
|
|
|
14696
14715
|
ui.success("QR code value:", value);
|
|
14697
14716
|
} finally {
|
|
14698
14717
|
try {
|
|
14699
|
-
await
|
|
14718
|
+
await import_node_fs10.promises.rm(dir, { recursive: true, force: true });
|
|
14700
14719
|
} catch {
|
|
14701
14720
|
}
|
|
14702
14721
|
}
|
|
@@ -14712,13 +14731,13 @@ var QrcodeCommandHandler = class {
|
|
|
14712
14731
|
} finally {
|
|
14713
14732
|
rl.close();
|
|
14714
14733
|
}
|
|
14715
|
-
const dir = await
|
|
14716
|
-
const filePath =
|
|
14734
|
+
const dir = await import_node_fs10.promises.mkdtemp(import_node_path16.default.join(import_node_os5.default.tmpdir(), "pmate-qrcode-"));
|
|
14735
|
+
const filePath = import_node_path16.default.join(dir, "qrcode.png");
|
|
14717
14736
|
const code = await this.run("screencapture", ["-i", "-x", filePath], true);
|
|
14718
14737
|
if (code !== 0) {
|
|
14719
14738
|
throw new Error("Screenshot capture canceled or failed.");
|
|
14720
14739
|
}
|
|
14721
|
-
const buffer = await
|
|
14740
|
+
const buffer = await import_node_fs10.promises.readFile(filePath);
|
|
14722
14741
|
if (buffer.length === 0) {
|
|
14723
14742
|
throw new Error("Screenshot capture produced an empty file.");
|
|
14724
14743
|
}
|
|
@@ -14734,7 +14753,7 @@ var QrcodeCommandHandler = class {
|
|
|
14734
14753
|
async decodeQr(filePath) {
|
|
14735
14754
|
let buffer;
|
|
14736
14755
|
try {
|
|
14737
|
-
buffer = await
|
|
14756
|
+
buffer = await import_node_fs10.promises.readFile(filePath);
|
|
14738
14757
|
} catch {
|
|
14739
14758
|
return null;
|
|
14740
14759
|
}
|
|
@@ -14992,8 +15011,8 @@ function clampNumber(value, min, max, fallback) {
|
|
|
14992
15011
|
}
|
|
14993
15012
|
|
|
14994
15013
|
// src/commands/QuizCommandHandler.ts
|
|
14995
|
-
var
|
|
14996
|
-
var
|
|
15014
|
+
var import_node_fs11 = require("fs");
|
|
15015
|
+
var import_node_path17 = __toESM(require("path"));
|
|
14997
15016
|
init_sessionStore();
|
|
14998
15017
|
|
|
14999
15018
|
// src/services/QuizService.ts
|
|
@@ -15538,8 +15557,8 @@ var QuizCommandHandler = class {
|
|
|
15538
15557
|
return;
|
|
15539
15558
|
}
|
|
15540
15559
|
if (args.action === "update-meta") {
|
|
15541
|
-
const resolvedFilePath =
|
|
15542
|
-
const metadata = JSON.parse((0,
|
|
15560
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15561
|
+
const metadata = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15543
15562
|
const result = await updateQuizPaperMetadata({
|
|
15544
15563
|
apiBaseUrl,
|
|
15545
15564
|
linkBaseUrl,
|
|
@@ -15551,8 +15570,8 @@ var QuizCommandHandler = class {
|
|
|
15551
15570
|
return;
|
|
15552
15571
|
}
|
|
15553
15572
|
if (args.action === "append-step") {
|
|
15554
|
-
const resolvedFilePath =
|
|
15555
|
-
const step = JSON.parse((0,
|
|
15573
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15574
|
+
const step = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15556
15575
|
const result = await appendQuizPaperStep({
|
|
15557
15576
|
apiBaseUrl,
|
|
15558
15577
|
linkBaseUrl,
|
|
@@ -15565,8 +15584,8 @@ var QuizCommandHandler = class {
|
|
|
15565
15584
|
return;
|
|
15566
15585
|
}
|
|
15567
15586
|
if (args.action === "update-step") {
|
|
15568
|
-
const resolvedFilePath =
|
|
15569
|
-
const step = JSON.parse((0,
|
|
15587
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15588
|
+
const step = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15570
15589
|
step.stepId = args.stepId;
|
|
15571
15590
|
const result = await updateQuizPaperStep({
|
|
15572
15591
|
apiBaseUrl,
|
|
@@ -15629,8 +15648,8 @@ var QuizCommandHandler = class {
|
|
|
15629
15648
|
if (targetIndex < 0) {
|
|
15630
15649
|
throw new Error(`\u672A\u627E\u5230 stepId=${args.stepId}\uFF0C\u65E0\u6CD5\u66F4\u65B0\u8BE5\u9898\u76EE\u3002`);
|
|
15631
15650
|
}
|
|
15632
|
-
const resolvedFilePath =
|
|
15633
|
-
const nextStep = JSON.parse((0,
|
|
15651
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15652
|
+
const nextStep = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15634
15653
|
nextStep.stepId = args.stepId;
|
|
15635
15654
|
const nextSteps = [...basePaper.steps];
|
|
15636
15655
|
nextSteps[targetIndex] = nextStep;
|
|
@@ -15680,9 +15699,9 @@ var QuizCommandHandler = class {
|
|
|
15680
15699
|
};
|
|
15681
15700
|
|
|
15682
15701
|
// src/commands/CollectCommandHandler.ts
|
|
15683
|
-
var
|
|
15684
|
-
var
|
|
15685
|
-
var
|
|
15702
|
+
var import_node_fs13 = require("fs");
|
|
15703
|
+
var import_node_os7 = __toESM(require("os"));
|
|
15704
|
+
var import_node_path19 = __toESM(require("path"));
|
|
15686
15705
|
var import_playwright = require("playwright");
|
|
15687
15706
|
|
|
15688
15707
|
// src/im1BotClient.ts
|
|
@@ -15748,13 +15767,13 @@ var Im1BotClient = class {
|
|
|
15748
15767
|
|
|
15749
15768
|
// src/collectStore.ts
|
|
15750
15769
|
var import_node_crypto3 = require("crypto");
|
|
15751
|
-
var
|
|
15752
|
-
var
|
|
15753
|
-
var
|
|
15770
|
+
var import_node_fs12 = require("fs");
|
|
15771
|
+
var import_node_os6 = __toESM(require("os"));
|
|
15772
|
+
var import_node_path18 = __toESM(require("path"));
|
|
15754
15773
|
function resolveCollectTarget(input) {
|
|
15755
15774
|
const endpoint = input.endpoint ?? (input.source === "cc" ? "http://localhost:9223" : "http://localhost:9222");
|
|
15756
15775
|
const sourceKey = input.source ?? `endpoint-${(0, import_node_crypto3.createHash)("sha1").update(endpoint).digest("hex").slice(0, 8)}`;
|
|
15757
|
-
const rootDir =
|
|
15776
|
+
const rootDir = import_node_path18.default.join(import_node_os6.default.homedir(), ".pmate", "collect", sourceKey);
|
|
15758
15777
|
return { sourceKey, endpoint, rootDir };
|
|
15759
15778
|
}
|
|
15760
15779
|
function toThreadKey(name) {
|
|
@@ -15766,7 +15785,7 @@ function toThreadKey(name) {
|
|
|
15766
15785
|
async function readStoredThread(rootDir, threadKey) {
|
|
15767
15786
|
const filePath = getThreadMetaFilePath(rootDir, threadKey);
|
|
15768
15787
|
try {
|
|
15769
|
-
const raw = await
|
|
15788
|
+
const raw = await import_node_fs12.promises.readFile(filePath, "utf8");
|
|
15770
15789
|
const parsed = JSON.parse(raw);
|
|
15771
15790
|
if ("messages" in parsed && Array.isArray(parsed.messages)) {
|
|
15772
15791
|
return parsed;
|
|
@@ -15784,15 +15803,15 @@ async function writeStoredThread(rootDir, thread) {
|
|
|
15784
15803
|
const metaPath = getThreadMetaFilePath(rootDir, thread.threadKey);
|
|
15785
15804
|
const messagePath = getThreadMessagesFilePath(rootDir, thread.threadKey);
|
|
15786
15805
|
const { messages: messages2, ...meta } = thread;
|
|
15787
|
-
await
|
|
15788
|
-
await
|
|
15806
|
+
await import_node_fs12.promises.mkdir(import_node_path18.default.dirname(metaPath), { recursive: true });
|
|
15807
|
+
await import_node_fs12.promises.writeFile(metaPath, JSON.stringify(meta, null, 2) + "\n", "utf8");
|
|
15789
15808
|
const body = messages2.map((message) => JSON.stringify(message)).join("\n");
|
|
15790
|
-
await
|
|
15809
|
+
await import_node_fs12.promises.writeFile(messagePath, `${body}${body ? "\n" : ""}`, "utf8");
|
|
15791
15810
|
}
|
|
15792
15811
|
async function writeStoredIndex(rootDir, index) {
|
|
15793
|
-
await
|
|
15794
|
-
const filePath =
|
|
15795
|
-
await
|
|
15812
|
+
await import_node_fs12.promises.mkdir(rootDir, { recursive: true });
|
|
15813
|
+
const filePath = import_node_path18.default.join(rootDir, "index.json");
|
|
15814
|
+
await import_node_fs12.promises.writeFile(filePath, JSON.stringify(index, null, 2) + "\n", "utf8");
|
|
15796
15815
|
}
|
|
15797
15816
|
function diffMessages(existing, incoming) {
|
|
15798
15817
|
const seenMessageIds = new Set(
|
|
@@ -15866,7 +15885,7 @@ function joinNormalized(values) {
|
|
|
15866
15885
|
async function readStoredMessages(rootDir, threadKey) {
|
|
15867
15886
|
const filePath = getThreadMessagesFilePath(rootDir, threadKey);
|
|
15868
15887
|
try {
|
|
15869
|
-
const raw = await
|
|
15888
|
+
const raw = await import_node_fs12.promises.readFile(filePath, "utf8");
|
|
15870
15889
|
return raw.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => normalizeStoredMessage(JSON.parse(line)));
|
|
15871
15890
|
} catch {
|
|
15872
15891
|
return [];
|
|
@@ -15875,20 +15894,20 @@ async function readStoredMessages(rootDir, threadKey) {
|
|
|
15875
15894
|
async function readLegacyStoredThread(rootDir, threadKey) {
|
|
15876
15895
|
const filePath = getLegacyThreadFilePath(rootDir, threadKey);
|
|
15877
15896
|
try {
|
|
15878
|
-
const raw = await
|
|
15897
|
+
const raw = await import_node_fs12.promises.readFile(filePath, "utf8");
|
|
15879
15898
|
return JSON.parse(raw);
|
|
15880
15899
|
} catch {
|
|
15881
15900
|
return null;
|
|
15882
15901
|
}
|
|
15883
15902
|
}
|
|
15884
15903
|
function getThreadMetaFilePath(rootDir, threadKey) {
|
|
15885
|
-
return
|
|
15904
|
+
return import_node_path18.default.join(rootDir, "threads", `${threadKey}.json`);
|
|
15886
15905
|
}
|
|
15887
15906
|
function getThreadMessagesFilePath(rootDir, threadKey) {
|
|
15888
|
-
return
|
|
15907
|
+
return import_node_path18.default.join(rootDir, "threads", `${threadKey}.jsonl`);
|
|
15889
15908
|
}
|
|
15890
15909
|
function getLegacyThreadFilePath(rootDir, threadKey) {
|
|
15891
|
-
return
|
|
15910
|
+
return import_node_path18.default.join(rootDir, "threads", `${threadKey}.json`);
|
|
15892
15911
|
}
|
|
15893
15912
|
function normalizeStoredMessage(message) {
|
|
15894
15913
|
return {
|
|
@@ -16127,7 +16146,7 @@ var CollectCommandHandler = class {
|
|
|
16127
16146
|
}
|
|
16128
16147
|
async writeSyncReport(rootDir, target, results, failures, syncedAt) {
|
|
16129
16148
|
const syncId = toSyncId(syncedAt);
|
|
16130
|
-
const reportPath =
|
|
16149
|
+
const reportPath = import_node_path19.default.join(rootDir, "syncs", `${syncId}.json`);
|
|
16131
16150
|
const threadReports = results.map((result) => ({
|
|
16132
16151
|
threadKey: result.thread.threadKey,
|
|
16133
16152
|
threadName: result.thread.threadName,
|
|
@@ -16136,8 +16155,8 @@ var CollectCommandHandler = class {
|
|
|
16136
16155
|
addedMessages: result.diff.added,
|
|
16137
16156
|
upgradedMessages: result.diff.upgraded
|
|
16138
16157
|
})).filter((thread) => thread.addedCount > 0 || thread.upgradedCount > 0);
|
|
16139
|
-
await
|
|
16140
|
-
await
|
|
16158
|
+
await import_node_fs13.promises.mkdir(import_node_path19.default.dirname(reportPath), { recursive: true });
|
|
16159
|
+
await import_node_fs13.promises.writeFile(
|
|
16141
16160
|
reportPath,
|
|
16142
16161
|
JSON.stringify(
|
|
16143
16162
|
{
|
|
@@ -16315,19 +16334,19 @@ async function archiveMessageImage(rootDir, attachmentRoot, threadKey, imagePath
|
|
|
16315
16334
|
if (!imagePath || isExternalImageRef(imagePath)) {
|
|
16316
16335
|
return imagePath;
|
|
16317
16336
|
}
|
|
16318
|
-
const normalized =
|
|
16337
|
+
const normalized = import_node_path19.default.posix.normalize(imagePath.replace(/\\/g, "/"));
|
|
16319
16338
|
if (normalized.startsWith("attachments/")) {
|
|
16320
|
-
return
|
|
16339
|
+
return import_node_path19.default.join(rootDir, ...normalized.split("/"));
|
|
16321
16340
|
}
|
|
16322
|
-
if (normalized.startsWith("../") ||
|
|
16341
|
+
if (normalized.startsWith("../") || import_node_path19.default.posix.isAbsolute(normalized)) {
|
|
16323
16342
|
return imagePath;
|
|
16324
16343
|
}
|
|
16325
|
-
const sourcePath =
|
|
16326
|
-
const destinationRelativePath =
|
|
16327
|
-
const destinationPath =
|
|
16344
|
+
const sourcePath = import_node_path19.default.join(attachmentRoot, ...normalized.split("/"));
|
|
16345
|
+
const destinationRelativePath = import_node_path19.default.posix.join("attachments", threadKey, normalized);
|
|
16346
|
+
const destinationPath = import_node_path19.default.join(rootDir, ...destinationRelativePath.split("/"));
|
|
16328
16347
|
try {
|
|
16329
|
-
await
|
|
16330
|
-
await
|
|
16348
|
+
await import_node_fs13.promises.mkdir(import_node_path19.default.dirname(destinationPath), { recursive: true });
|
|
16349
|
+
await import_node_fs13.promises.copyFile(sourcePath, destinationPath);
|
|
16331
16350
|
return destinationPath;
|
|
16332
16351
|
} catch {
|
|
16333
16352
|
return imagePath;
|
|
@@ -16337,7 +16356,7 @@ function resolveLocalAttachmentRoot(sourceKey) {
|
|
|
16337
16356
|
if (sourceKey !== "cc" && sourceKey !== "yelling") {
|
|
16338
16357
|
return null;
|
|
16339
16358
|
}
|
|
16340
|
-
return
|
|
16359
|
+
return import_node_path19.default.join(import_node_os7.default.homedir(), "Library", "Application Support", sourceKey, "attachments.noindex");
|
|
16341
16360
|
}
|
|
16342
16361
|
function isExternalImageRef(imagePath) {
|
|
16343
16362
|
return /^[a-z][a-z0-9+.-]*:/i.test(imagePath);
|
|
@@ -16949,7 +16968,7 @@ function pad2(value) {
|
|
|
16949
16968
|
}
|
|
16950
16969
|
|
|
16951
16970
|
// src/commands/ChatRoomCommandHandler.ts
|
|
16952
|
-
var
|
|
16971
|
+
var import_node_fs14 = require("fs");
|
|
16953
16972
|
var ChatRoomCommandHandler = class {
|
|
16954
16973
|
async handle(args) {
|
|
16955
16974
|
const sdk = await loadChatSdk();
|
|
@@ -16999,8 +17018,8 @@ var ChatRoomCommandHandler = class {
|
|
|
16999
17018
|
const a = await this.connect(sdk, args.botA, args.app, args.hubUrl, args.authBaseUrl);
|
|
17000
17019
|
const b = await this.connect(sdk, args.botB, args.app, args.hubUrl, args.authBaseUrl);
|
|
17001
17020
|
try {
|
|
17002
|
-
const botA = sdk.parsePmateBotKeyJson((0,
|
|
17003
|
-
const botB = sdk.parsePmateBotKeyJson((0,
|
|
17021
|
+
const botA = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(args.botA, "utf8"));
|
|
17022
|
+
const botB = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(args.botB, "utf8"));
|
|
17004
17023
|
await a.requestFriend({ to: botB.name, message: "smoke friend request" });
|
|
17005
17024
|
await b.acceptFriend({ to: botA.name, message: "smoke friend accept" });
|
|
17006
17025
|
await a.sendDm({ to: botB.name, text: "smoke dm from a" });
|
|
@@ -17019,7 +17038,7 @@ var ChatRoomCommandHandler = class {
|
|
|
17019
17038
|
if (!botPath) {
|
|
17020
17039
|
throw new Error("Missing required option: --bot");
|
|
17021
17040
|
}
|
|
17022
|
-
const botKey = sdk.parsePmateBotKeyJson((0,
|
|
17041
|
+
const botKey = sdk.parsePmateBotKeyJson((0, import_node_fs14.readFileSync)(botPath, "utf8"));
|
|
17023
17042
|
const client = sdk.createChatClient({ appId, botKey, hubUrl, authBaseUrl });
|
|
17024
17043
|
await client.connect();
|
|
17025
17044
|
return client;
|
|
@@ -17031,8 +17050,8 @@ async function loadChatSdk() {
|
|
|
17031
17050
|
}
|
|
17032
17051
|
|
|
17033
17052
|
// src/commands/AgentCommandHandler.ts
|
|
17034
|
-
var
|
|
17035
|
-
var
|
|
17053
|
+
var import_node_fs15 = require("fs");
|
|
17054
|
+
var import_node_path20 = __toESM(require("path"));
|
|
17036
17055
|
init_AgentLlmClient();
|
|
17037
17056
|
init_sessionStore();
|
|
17038
17057
|
|
|
@@ -17065,8 +17084,8 @@ function descriptorPathSegments(descriptor) {
|
|
|
17065
17084
|
return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
|
|
17066
17085
|
}
|
|
17067
17086
|
function buildPathUrl(baseUrl, pathSegments, query) {
|
|
17068
|
-
const
|
|
17069
|
-
const url = new URL(
|
|
17087
|
+
const path31 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
17088
|
+
const url = new URL(path31, baseUrl);
|
|
17070
17089
|
if (query) {
|
|
17071
17090
|
for (const [key, value] of Object.entries(query)) {
|
|
17072
17091
|
url.searchParams.set(key, String(value));
|
|
@@ -17523,11 +17542,11 @@ var AgentCommandHandler = class {
|
|
|
17523
17542
|
}).token;
|
|
17524
17543
|
}
|
|
17525
17544
|
readJsonFile(filePath) {
|
|
17526
|
-
const absolutePath =
|
|
17527
|
-
if (!(0,
|
|
17545
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
17546
|
+
if (!(0, import_node_fs15.existsSync)(absolutePath)) {
|
|
17528
17547
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17529
17548
|
}
|
|
17530
|
-
const raw = (0,
|
|
17549
|
+
const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
|
|
17531
17550
|
try {
|
|
17532
17551
|
return JSON.parse(raw);
|
|
17533
17552
|
} catch (error) {
|
|
@@ -17538,14 +17557,14 @@ var AgentCommandHandler = class {
|
|
|
17538
17557
|
readJsonObjectFile(filePath) {
|
|
17539
17558
|
const parsed = this.readJsonFile(filePath);
|
|
17540
17559
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
17541
|
-
const absolutePath =
|
|
17560
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
17542
17561
|
throw new Error(`Invalid JSON in ${absolutePath}: expected an object`);
|
|
17543
17562
|
}
|
|
17544
17563
|
return parsed;
|
|
17545
17564
|
}
|
|
17546
17565
|
tryReadJsonObjectFile(filePath) {
|
|
17547
17566
|
const absolutePath = this.resolveExistingFile(filePath);
|
|
17548
|
-
const raw = (0,
|
|
17567
|
+
const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
|
|
17549
17568
|
try {
|
|
17550
17569
|
const parsed = JSON.parse(raw);
|
|
17551
17570
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -17557,8 +17576,8 @@ var AgentCommandHandler = class {
|
|
|
17557
17576
|
}
|
|
17558
17577
|
}
|
|
17559
17578
|
resolveExistingFile(filePath) {
|
|
17560
|
-
const absolutePath =
|
|
17561
|
-
if (!(0,
|
|
17579
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
17580
|
+
if (!(0, import_node_fs15.existsSync)(absolutePath)) {
|
|
17562
17581
|
throw new Error(`File not found: ${absolutePath}`);
|
|
17563
17582
|
}
|
|
17564
17583
|
return absolutePath;
|
|
@@ -17642,8 +17661,8 @@ var AgentCommandHandler = class {
|
|
|
17642
17661
|
};
|
|
17643
17662
|
|
|
17644
17663
|
// src/commands/RunnerCommandHandler.ts
|
|
17645
|
-
var
|
|
17646
|
-
var
|
|
17664
|
+
var import_node_fs16 = require("fs");
|
|
17665
|
+
var import_node_path21 = __toESM(require("path"));
|
|
17647
17666
|
init_sessionStore();
|
|
17648
17667
|
init_namespacedRef();
|
|
17649
17668
|
var RunnerCommandHandler = class {
|
|
@@ -17738,11 +17757,11 @@ var RunnerCommandHandler = class {
|
|
|
17738
17757
|
}).token;
|
|
17739
17758
|
}
|
|
17740
17759
|
readJsonFile(filePath) {
|
|
17741
|
-
const absolutePath =
|
|
17742
|
-
if (!(0,
|
|
17760
|
+
const absolutePath = import_node_path21.default.resolve(process.cwd(), filePath);
|
|
17761
|
+
if (!(0, import_node_fs16.existsSync)(absolutePath)) {
|
|
17743
17762
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17744
17763
|
}
|
|
17745
|
-
const raw = (0,
|
|
17764
|
+
const raw = (0, import_node_fs16.readFileSync)(absolutePath, "utf8");
|
|
17746
17765
|
try {
|
|
17747
17766
|
return JSON.parse(raw);
|
|
17748
17767
|
} catch (error) {
|
|
@@ -17861,8 +17880,8 @@ var NsCommandHandler = class {
|
|
|
17861
17880
|
};
|
|
17862
17881
|
|
|
17863
17882
|
// src/commands/StoreCommandHandler.ts
|
|
17864
|
-
var
|
|
17865
|
-
var
|
|
17883
|
+
var import_node_fs17 = require("fs");
|
|
17884
|
+
var import_node_path22 = __toESM(require("path"));
|
|
17866
17885
|
var StoreCommandHandler = class {
|
|
17867
17886
|
async handle(args) {
|
|
17868
17887
|
if (args.scope === "namespace") {
|
|
@@ -18004,11 +18023,11 @@ var StoreCommandHandler = class {
|
|
|
18004
18023
|
return payload.data ?? [];
|
|
18005
18024
|
}
|
|
18006
18025
|
readJsonFile(filePath) {
|
|
18007
|
-
const absolutePath =
|
|
18008
|
-
if (!(0,
|
|
18026
|
+
const absolutePath = import_node_path22.default.resolve(process.cwd(), filePath);
|
|
18027
|
+
if (!(0, import_node_fs17.existsSync)(absolutePath)) {
|
|
18009
18028
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
18010
18029
|
}
|
|
18011
|
-
const raw = (0,
|
|
18030
|
+
const raw = (0, import_node_fs17.readFileSync)(absolutePath, "utf8");
|
|
18012
18031
|
try {
|
|
18013
18032
|
return JSON.parse(raw);
|
|
18014
18033
|
} catch (error) {
|
|
@@ -18060,14 +18079,14 @@ var StoreCommandHandler = class {
|
|
|
18060
18079
|
};
|
|
18061
18080
|
|
|
18062
18081
|
// src/commands/AppCommandHandler.ts
|
|
18063
|
-
var
|
|
18064
|
-
var
|
|
18082
|
+
var import_node_fs19 = require("fs");
|
|
18083
|
+
var import_node_path24 = __toESM(require("path"));
|
|
18065
18084
|
init_sessionStore();
|
|
18066
18085
|
|
|
18067
18086
|
// src/appIcon.ts
|
|
18068
|
-
var
|
|
18069
|
-
var
|
|
18070
|
-
var
|
|
18087
|
+
var import_node_fs18 = require("fs");
|
|
18088
|
+
var import_node_os8 = __toESM(require("os"));
|
|
18089
|
+
var import_node_path23 = __toESM(require("path"));
|
|
18071
18090
|
var import_sharp = __toESM(require("sharp"));
|
|
18072
18091
|
init_namespacedRef();
|
|
18073
18092
|
var ANDROID_ICON_SPECS = [
|
|
@@ -18172,13 +18191,13 @@ function createAppIconExportPlans(input) {
|
|
|
18172
18191
|
if (!input.outDir) {
|
|
18173
18192
|
throw new Error("App icon preset export requires --out-dir.");
|
|
18174
18193
|
}
|
|
18175
|
-
const outDir =
|
|
18176
|
-
(0,
|
|
18194
|
+
const outDir = import_node_path23.default.resolve(input.cwd, input.outDir);
|
|
18195
|
+
(0, import_node_fs18.mkdirSync)(outDir, { recursive: true });
|
|
18177
18196
|
return specs.map((spec) => ({
|
|
18178
18197
|
width: spec.width,
|
|
18179
18198
|
height: spec.height,
|
|
18180
18199
|
format: "png",
|
|
18181
|
-
outputPath:
|
|
18200
|
+
outputPath: import_node_path23.default.join(
|
|
18182
18201
|
outDir,
|
|
18183
18202
|
`${namespace}-${objectId}-${spec.name}-${spec.width}x${spec.height}.png`
|
|
18184
18203
|
)
|
|
@@ -18191,8 +18210,8 @@ function createAppIconExportPlans(input) {
|
|
|
18191
18210
|
if (!input.output) {
|
|
18192
18211
|
throw new Error("Single-size app icon export requires --output.");
|
|
18193
18212
|
}
|
|
18194
|
-
const resolvedOutput =
|
|
18195
|
-
(0,
|
|
18213
|
+
const resolvedOutput = import_node_path23.default.resolve(input.cwd, input.output);
|
|
18214
|
+
(0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(resolvedOutput), { recursive: true });
|
|
18196
18215
|
return [
|
|
18197
18216
|
{
|
|
18198
18217
|
width: input.width,
|
|
@@ -18206,7 +18225,7 @@ async function exportAppIcon(icon, plans) {
|
|
|
18206
18225
|
const svg = await resolveAppIconSvg(icon);
|
|
18207
18226
|
for (const plan of plans) {
|
|
18208
18227
|
const bytes = await renderAppIcon(svg, plan.width, plan.height, plan.format);
|
|
18209
|
-
(0,
|
|
18228
|
+
(0, import_node_fs18.writeFileSync)(plan.outputPath, bytes);
|
|
18210
18229
|
}
|
|
18211
18230
|
}
|
|
18212
18231
|
async function renderAppIconVariant(input) {
|
|
@@ -18214,9 +18233,9 @@ async function renderAppIconVariant(input) {
|
|
|
18214
18233
|
const bytes = await renderAppIcon(svg, input.width, input.height, input.format);
|
|
18215
18234
|
let outputPath;
|
|
18216
18235
|
if (input.output) {
|
|
18217
|
-
outputPath =
|
|
18218
|
-
(0,
|
|
18219
|
-
(0,
|
|
18236
|
+
outputPath = import_node_path23.default.resolve(input.cwd, input.output);
|
|
18237
|
+
(0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(outputPath), { recursive: true });
|
|
18238
|
+
(0, import_node_fs18.writeFileSync)(outputPath, bytes);
|
|
18220
18239
|
}
|
|
18221
18240
|
if (input.name) {
|
|
18222
18241
|
return {
|
|
@@ -18237,7 +18256,7 @@ async function renderAppIconVariant(input) {
|
|
|
18237
18256
|
};
|
|
18238
18257
|
}
|
|
18239
18258
|
async function loadAppIconVariantFile(input) {
|
|
18240
|
-
const absolutePath =
|
|
18259
|
+
const absolutePath = import_node_path23.default.resolve(input.cwd, input.filePath);
|
|
18241
18260
|
const format = inferVariantFormatFromPath(absolutePath);
|
|
18242
18261
|
return {
|
|
18243
18262
|
value: input.name ? await uploadAppIconVariantAsset({
|
|
@@ -18246,7 +18265,7 @@ async function loadAppIconVariantFile(input) {
|
|
|
18246
18265
|
name: input.name,
|
|
18247
18266
|
format,
|
|
18248
18267
|
sourcePath: absolutePath
|
|
18249
|
-
}) : createImageDataUrl((0,
|
|
18268
|
+
}) : createImageDataUrl((0, import_node_fs18.readFileSync)(absolutePath), format),
|
|
18250
18269
|
format,
|
|
18251
18270
|
absolutePath
|
|
18252
18271
|
};
|
|
@@ -18305,7 +18324,7 @@ function shouldAutoGenerateDefaultVariant(icon) {
|
|
|
18305
18324
|
return looksLikeSvgMarkup(icon) || looksLikeSvgUrl(icon);
|
|
18306
18325
|
}
|
|
18307
18326
|
function inferVariantFormatFromPath(filePath) {
|
|
18308
|
-
const ext =
|
|
18327
|
+
const ext = import_node_path23.default.extname(filePath).toLowerCase();
|
|
18309
18328
|
switch (ext) {
|
|
18310
18329
|
case ".png":
|
|
18311
18330
|
return "png";
|
|
@@ -18376,13 +18395,13 @@ async function uploadAppIconVariantAsset(input) {
|
|
|
18376
18395
|
await AliyunService.uploadFile(sourcePath, DEFAULT_APP_ICON_VARIANT_BUCKET, objectKey);
|
|
18377
18396
|
} finally {
|
|
18378
18397
|
if (shouldCleanup) {
|
|
18379
|
-
(0,
|
|
18398
|
+
(0, import_node_fs18.rmSync)(import_node_path23.default.dirname(sourcePath), { recursive: true, force: true });
|
|
18380
18399
|
}
|
|
18381
18400
|
}
|
|
18382
18401
|
return `${DEFAULT_APP_ICON_VARIANT_PUBLIC_BASE_URL}/${objectKey}`;
|
|
18383
18402
|
}
|
|
18384
18403
|
function buildAppIconVariantObjectKey(input) {
|
|
18385
|
-
return
|
|
18404
|
+
return import_node_path23.default.posix.join(
|
|
18386
18405
|
"apps",
|
|
18387
18406
|
`${resolveAppIconAssetStem(input.icon, input.appRef)}-${input.name}.${extensionForIconFormat(input.format)}`
|
|
18388
18407
|
);
|
|
@@ -18391,8 +18410,8 @@ function resolveAppIconAssetStem(icon, appRef) {
|
|
|
18391
18410
|
if (icon) {
|
|
18392
18411
|
try {
|
|
18393
18412
|
const url = new URL(icon);
|
|
18394
|
-
const ext =
|
|
18395
|
-
const basename =
|
|
18413
|
+
const ext = import_node_path23.default.posix.extname(url.pathname);
|
|
18414
|
+
const basename = import_node_path23.default.posix.basename(url.pathname, ext);
|
|
18396
18415
|
const normalized = sanitizeAppIconAssetStem(basename);
|
|
18397
18416
|
if (normalized) {
|
|
18398
18417
|
return normalized;
|
|
@@ -18421,9 +18440,9 @@ function writeTempAppIconVariantFile(objectKey, format, bytes) {
|
|
|
18421
18440
|
if (!bytes) {
|
|
18422
18441
|
throw new Error("App icon variant upload requires bytes or a source file.");
|
|
18423
18442
|
}
|
|
18424
|
-
const tempDir = (0,
|
|
18425
|
-
const tempPath =
|
|
18426
|
-
(0,
|
|
18443
|
+
const tempDir = (0, import_node_fs18.mkdtempSync)(import_node_path23.default.join(import_node_os8.default.tmpdir(), "pmate-app-icon-"));
|
|
18444
|
+
const tempPath = import_node_path23.default.join(tempDir, import_node_path23.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
|
|
18445
|
+
(0, import_node_fs18.writeFileSync)(tempPath, bytes);
|
|
18427
18446
|
return tempPath;
|
|
18428
18447
|
}
|
|
18429
18448
|
|
|
@@ -18632,10 +18651,10 @@ var AppCommandHandler = class {
|
|
|
18632
18651
|
}
|
|
18633
18652
|
readJsonFile(filePath) {
|
|
18634
18653
|
const absolutePath = this.resolveFilePath(filePath);
|
|
18635
|
-
if (!(0,
|
|
18654
|
+
if (!(0, import_node_fs19.existsSync)(absolutePath)) {
|
|
18636
18655
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
18637
18656
|
}
|
|
18638
|
-
const raw = (0,
|
|
18657
|
+
const raw = (0, import_node_fs19.readFileSync)(absolutePath, "utf8");
|
|
18639
18658
|
try {
|
|
18640
18659
|
return JSON.parse(raw);
|
|
18641
18660
|
} catch (error) {
|
|
@@ -18645,10 +18664,10 @@ var AppCommandHandler = class {
|
|
|
18645
18664
|
}
|
|
18646
18665
|
async preparePayload(filePath, appRef) {
|
|
18647
18666
|
const absolutePath = this.resolveFilePath(filePath);
|
|
18648
|
-
return prepareAppPayload(this.readJsonFile(filePath),
|
|
18667
|
+
return prepareAppPayload(this.readJsonFile(filePath), import_node_path24.default.dirname(absolutePath), { appRef });
|
|
18649
18668
|
}
|
|
18650
18669
|
resolveFilePath(filePath) {
|
|
18651
|
-
return
|
|
18670
|
+
return import_node_path24.default.resolve(process.cwd(), filePath);
|
|
18652
18671
|
}
|
|
18653
18672
|
async request(baseUrl, token, method, pathname, body) {
|
|
18654
18673
|
const response = await fetch(`${baseUrl}${pathname}`, {
|
|
@@ -18768,18 +18787,18 @@ function readNamespaceFromPayload(payload) {
|
|
|
18768
18787
|
}
|
|
18769
18788
|
|
|
18770
18789
|
// src/commands/ServiceCommandHandler.ts
|
|
18771
|
-
var
|
|
18790
|
+
var import_node_fs22 = require("fs");
|
|
18772
18791
|
var import_promises5 = require("fs/promises");
|
|
18773
|
-
var
|
|
18792
|
+
var import_node_path27 = __toESM(require("path"));
|
|
18774
18793
|
var import_node_child_process11 = require("child_process");
|
|
18775
18794
|
var import_promises6 = require("readline/promises");
|
|
18776
18795
|
|
|
18777
18796
|
// src/services/AndroidApkReleaseService.ts
|
|
18778
18797
|
var import_node_child_process9 = require("child_process");
|
|
18779
18798
|
var import_node_crypto4 = require("crypto");
|
|
18780
|
-
var
|
|
18781
|
-
var
|
|
18782
|
-
var
|
|
18799
|
+
var import_node_fs20 = require("fs");
|
|
18800
|
+
var import_node_os9 = __toESM(require("os"));
|
|
18801
|
+
var import_node_path25 = __toESM(require("path"));
|
|
18783
18802
|
var ANDROID_APK_BUCKET = "parrot-static";
|
|
18784
18803
|
var ANDROID_APK_PUBLIC_BASE_URL = "https://parrot-static.pmate.chat";
|
|
18785
18804
|
var AndroidApkReleaseService = class {
|
|
@@ -18813,7 +18832,7 @@ var AndroidApkReleaseService = class {
|
|
|
18813
18832
|
}
|
|
18814
18833
|
await AliyunService.uploadFile(apkPath, ANDROID_APK_BUCKET, objectKey);
|
|
18815
18834
|
const sha256 = await sha256File(apkPath);
|
|
18816
|
-
const size = (0,
|
|
18835
|
+
const size = (0, import_node_fs20.statSync)(apkPath).size;
|
|
18817
18836
|
const artifact = {
|
|
18818
18837
|
serviceId: service.id,
|
|
18819
18838
|
env: options.env,
|
|
@@ -18851,7 +18870,7 @@ var AndroidApkReleaseService = class {
|
|
|
18851
18870
|
const prefix = `apks/${service.namespace}/${service.name}`;
|
|
18852
18871
|
const objects = await AliyunService.listObjects(ANDROID_APK_BUCKET, prefix);
|
|
18853
18872
|
return objects.filter((item) => item.name.endsWith(".apk")).map((item) => {
|
|
18854
|
-
const versionName =
|
|
18873
|
+
const versionName = import_node_path25.default.basename(item.name, ".apk");
|
|
18855
18874
|
return {
|
|
18856
18875
|
serviceId,
|
|
18857
18876
|
env: options.env ?? "unknown",
|
|
@@ -18874,7 +18893,7 @@ var AndroidApkReleaseService = class {
|
|
|
18874
18893
|
}
|
|
18875
18894
|
}
|
|
18876
18895
|
resolveRepoRoot(service, cwd) {
|
|
18877
|
-
if (cwd) return
|
|
18896
|
+
if (cwd) return import_node_path25.default.resolve(process.cwd(), cwd);
|
|
18878
18897
|
const repository = this.getRepository(service);
|
|
18879
18898
|
if (repository) {
|
|
18880
18899
|
return resolveRepositoryLocalRoot(repository);
|
|
@@ -18886,8 +18905,8 @@ var AndroidApkReleaseService = class {
|
|
|
18886
18905
|
if (!dir) {
|
|
18887
18906
|
throw new Error(`Missing dir for android service ${service.id}`);
|
|
18888
18907
|
}
|
|
18889
|
-
const appDir =
|
|
18890
|
-
if (!(0,
|
|
18908
|
+
const appDir = import_node_path25.default.resolve(repoRoot, dir);
|
|
18909
|
+
if (!(0, import_node_fs20.existsSync)(appDir)) {
|
|
18891
18910
|
throw new Error(`Android app dir not found: ${appDir}`);
|
|
18892
18911
|
}
|
|
18893
18912
|
return appDir;
|
|
@@ -18903,11 +18922,11 @@ var AndroidApkReleaseService = class {
|
|
|
18903
18922
|
return void 0;
|
|
18904
18923
|
}
|
|
18905
18924
|
async runGradleAssembleAndFindApk(repoRoot, appDir, variant) {
|
|
18906
|
-
const gradlew = [
|
|
18925
|
+
const gradlew = [import_node_path25.default.join(appDir, "gradlew"), import_node_path25.default.join(repoRoot, "gradlew")].find((candidate) => (0, import_node_fs20.existsSync)(candidate));
|
|
18907
18926
|
if (!gradlew) {
|
|
18908
18927
|
throw new Error(`Gradle wrapper not found in ${appDir} or ${repoRoot}`);
|
|
18909
18928
|
}
|
|
18910
|
-
const gradleCwd =
|
|
18929
|
+
const gradleCwd = import_node_path25.default.dirname(gradlew);
|
|
18911
18930
|
const normalizedVariant = variant.toLowerCase();
|
|
18912
18931
|
const taskSuffix = `assemble${capitalize(normalizedVariant)}`;
|
|
18913
18932
|
const tasks = [`:app:${taskSuffix}`, taskSuffix];
|
|
@@ -18975,7 +18994,7 @@ function resolveRepositoryLocalRoot(repository) {
|
|
|
18975
18994
|
if (!repoName) {
|
|
18976
18995
|
throw new Error(`Invalid repository: ${repository}`);
|
|
18977
18996
|
}
|
|
18978
|
-
return
|
|
18997
|
+
return import_node_path25.default.join(import_node_os9.default.homedir(), "dev", "pmate", repoName);
|
|
18979
18998
|
}
|
|
18980
18999
|
function bumpAndroidGradleVersionText(source, bump) {
|
|
18981
19000
|
const versionNameMatch = source.match(/(^\s*versionName\s+["'])([^"']+)(["']\s*$)/m) ?? source.match(/(^\s*versionName\s*=\s*["'])([^"']+)(["']\s*$)/m);
|
|
@@ -19031,42 +19050,42 @@ function parseGradleOutputMetadata(source, apkFileName) {
|
|
|
19031
19050
|
}
|
|
19032
19051
|
function bumpAndroidProjectVersion(appDir, bump) {
|
|
19033
19052
|
const candidates = [
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19053
|
+
import_node_path25.default.join(appDir, "app", "build.gradle.kts"),
|
|
19054
|
+
import_node_path25.default.join(appDir, "app", "build.gradle"),
|
|
19055
|
+
import_node_path25.default.join(appDir, "build.gradle.kts"),
|
|
19056
|
+
import_node_path25.default.join(appDir, "build.gradle")
|
|
19038
19057
|
];
|
|
19039
19058
|
for (const candidate of candidates) {
|
|
19040
|
-
if (!(0,
|
|
19041
|
-
const result = bumpAndroidGradleVersionText((0,
|
|
19042
|
-
(0,
|
|
19059
|
+
if (!(0, import_node_fs20.existsSync)(candidate)) continue;
|
|
19060
|
+
const result = bumpAndroidGradleVersionText((0, import_node_fs20.readFileSync)(candidate, "utf8"), bump);
|
|
19061
|
+
(0, import_node_fs20.writeFileSync)(candidate, result.source);
|
|
19043
19062
|
return { filePath: candidate, ...result };
|
|
19044
19063
|
}
|
|
19045
19064
|
throw new Error(`No Android Gradle version file found under ${appDir}`);
|
|
19046
19065
|
}
|
|
19047
19066
|
function findLatestApk(repoRoot, appDir, variant) {
|
|
19048
19067
|
const dirs = [
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19068
|
+
import_node_path25.default.join(appDir, "app", "build", "outputs", "apk", variant),
|
|
19069
|
+
import_node_path25.default.join(appDir, "build", "outputs", "apk", variant),
|
|
19070
|
+
import_node_path25.default.join(repoRoot, "app", "build", "outputs", "apk", variant)
|
|
19052
19071
|
];
|
|
19053
19072
|
const files = dirs.flatMap((dir) => listApks(dir));
|
|
19054
19073
|
if (files.length === 0) {
|
|
19055
19074
|
throw new Error(`Cannot find APK output for variant ${variant}`);
|
|
19056
19075
|
}
|
|
19057
|
-
files.sort((a, b) => (0,
|
|
19076
|
+
files.sort((a, b) => (0, import_node_fs20.statSync)(b).mtimeMs - (0, import_node_fs20.statSync)(a).mtimeMs);
|
|
19058
19077
|
return files[0];
|
|
19059
19078
|
}
|
|
19060
19079
|
function readGradleOutputMetadata(apkPath) {
|
|
19061
|
-
const metadataPath =
|
|
19062
|
-
if (!(0,
|
|
19080
|
+
const metadataPath = import_node_path25.default.join(import_node_path25.default.dirname(apkPath), "output-metadata.json");
|
|
19081
|
+
if (!(0, import_node_fs20.existsSync)(metadataPath)) {
|
|
19063
19082
|
throw new Error(`Gradle output metadata not found: ${metadataPath}`);
|
|
19064
19083
|
}
|
|
19065
|
-
return parseGradleOutputMetadata((0,
|
|
19084
|
+
return parseGradleOutputMetadata((0, import_node_fs20.readFileSync)(metadataPath, "utf8"), import_node_path25.default.basename(apkPath));
|
|
19066
19085
|
}
|
|
19067
19086
|
function listApks(dir) {
|
|
19068
|
-
if (!(0,
|
|
19069
|
-
return (0,
|
|
19087
|
+
if (!(0, import_node_fs20.existsSync)(dir)) return [];
|
|
19088
|
+
return (0, import_node_fs20.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) => import_node_path25.default.join(dir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isFile());
|
|
19070
19089
|
}
|
|
19071
19090
|
function runCommand(command, args, cwd) {
|
|
19072
19091
|
return new Promise((resolve, reject) => {
|
|
@@ -19100,26 +19119,26 @@ async function runAndroidSdkToolCapture(toolName, args) {
|
|
|
19100
19119
|
return runCommandCapture(toolPath, args);
|
|
19101
19120
|
}
|
|
19102
19121
|
function findAndroidSdkTool(toolName) {
|
|
19103
|
-
const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) =>
|
|
19122
|
+
const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) => import_node_path25.default.resolve(item));
|
|
19104
19123
|
for (const sdkRoot of sdkRoots) {
|
|
19105
|
-
const candidates = toolName === "aapt" ? listVersionedToolCandidates(
|
|
19106
|
-
|
|
19107
|
-
...listVersionedToolCandidates(
|
|
19108
|
-
|
|
19124
|
+
const candidates = toolName === "aapt" ? listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "build-tools"), toolName) : [
|
|
19125
|
+
import_node_path25.default.join(sdkRoot, "cmdline-tools", "latest", "bin", toolName),
|
|
19126
|
+
...listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "cmdline-tools"), import_node_path25.default.join("bin", toolName)),
|
|
19127
|
+
import_node_path25.default.join(sdkRoot, "tools", "bin", toolName)
|
|
19109
19128
|
];
|
|
19110
|
-
const match = candidates.find((candidate) => (0,
|
|
19129
|
+
const match = candidates.find((candidate) => (0, import_node_fs20.existsSync)(candidate));
|
|
19111
19130
|
if (match) return match;
|
|
19112
19131
|
}
|
|
19113
19132
|
return void 0;
|
|
19114
19133
|
}
|
|
19115
19134
|
function listVersionedToolCandidates(parentDir, relativeToolPath) {
|
|
19116
|
-
if (!(0,
|
|
19117
|
-
return (0,
|
|
19135
|
+
if (!(0, import_node_fs20.existsSync)(parentDir)) return [];
|
|
19136
|
+
return (0, import_node_fs20.readdirSync)(parentDir).map((entry) => import_node_path25.default.join(parentDir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isDirectory()).sort((a, b) => import_node_path25.default.basename(b).localeCompare(import_node_path25.default.basename(a), void 0, { numeric: true })).map((entry) => import_node_path25.default.join(entry, relativeToolPath));
|
|
19118
19137
|
}
|
|
19119
19138
|
function sha256File(filePath) {
|
|
19120
19139
|
return new Promise((resolve, reject) => {
|
|
19121
19140
|
const hash = (0, import_node_crypto4.createHash)("sha256");
|
|
19122
|
-
const stream = (0,
|
|
19141
|
+
const stream = (0, import_node_fs20.createReadStream)(filePath);
|
|
19123
19142
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
19124
19143
|
stream.on("error", reject);
|
|
19125
19144
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
@@ -19136,9 +19155,9 @@ function capitalize(value) {
|
|
|
19136
19155
|
}
|
|
19137
19156
|
|
|
19138
19157
|
// src/services/ServiceRuntimeRunner.ts
|
|
19139
|
-
var
|
|
19140
|
-
var
|
|
19141
|
-
var
|
|
19158
|
+
var import_node_fs21 = require("fs");
|
|
19159
|
+
var import_node_os10 = __toESM(require("os"));
|
|
19160
|
+
var import_node_path26 = __toESM(require("path"));
|
|
19142
19161
|
var import_node_child_process10 = require("child_process");
|
|
19143
19162
|
var import_node_readline = require("readline");
|
|
19144
19163
|
var import_chalk3 = __toESM(require("chalk"));
|
|
@@ -19311,8 +19330,7 @@ var ServiceRegistryClient = class {
|
|
|
19311
19330
|
}
|
|
19312
19331
|
readToken() {
|
|
19313
19332
|
return readRequiredSession({
|
|
19314
|
-
preferredApp: DEFAULT_APP_ID
|
|
19315
|
-
fallbackToActiveApp: true
|
|
19333
|
+
preferredApp: DEFAULT_APP_ID
|
|
19316
19334
|
}).token;
|
|
19317
19335
|
}
|
|
19318
19336
|
async request(method, pathname) {
|
|
@@ -19602,14 +19620,14 @@ var ServiceRuntimeRunner = class {
|
|
|
19602
19620
|
}
|
|
19603
19621
|
resolveRepoRoot(service, cwd) {
|
|
19604
19622
|
if (cwd) {
|
|
19605
|
-
return
|
|
19623
|
+
return import_node_path26.default.resolve(process.cwd(), cwd);
|
|
19606
19624
|
}
|
|
19607
19625
|
const repository = this.getType(service) === "vite" || this.getType(service) === "static" ? this.getRepoStaticSite(service).repository.trim() : this.getType(service) === "fc" ? this.getFc(service).repository?.trim() : this.getType(service) === "ios" || this.getType(service) === "android" ? void 0 : this.getNetwork(service).repository?.trim();
|
|
19608
19626
|
if (repository) {
|
|
19609
19627
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
19610
19628
|
if (repoName) {
|
|
19611
|
-
const candidate =
|
|
19612
|
-
if ((0,
|
|
19629
|
+
const candidate = import_node_path26.default.join(import_node_os10.default.homedir(), "dev", "pmate", repoName);
|
|
19630
|
+
if ((0, import_node_fs21.existsSync)(candidate)) {
|
|
19613
19631
|
return candidate;
|
|
19614
19632
|
}
|
|
19615
19633
|
}
|
|
@@ -19622,13 +19640,13 @@ var ServiceRuntimeRunner = class {
|
|
|
19622
19640
|
if (!dir) {
|
|
19623
19641
|
throw new Error(`Missing service dir for ${service.id}`);
|
|
19624
19642
|
}
|
|
19625
|
-
return
|
|
19643
|
+
return import_node_path26.default.resolve(repoRoot, dir);
|
|
19626
19644
|
}
|
|
19627
19645
|
async deployVite(service, options) {
|
|
19628
19646
|
this.assertDeployableStaticSite(service);
|
|
19629
19647
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19630
|
-
const packageJsonPath =
|
|
19631
|
-
if (!(0,
|
|
19648
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19649
|
+
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19632
19650
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19633
19651
|
}
|
|
19634
19652
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -19643,8 +19661,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19643
19661
|
this.resolveRepoRoot(service, options.cwd),
|
|
19644
19662
|
buildEnv
|
|
19645
19663
|
);
|
|
19646
|
-
const distDir =
|
|
19647
|
-
if (!(0,
|
|
19664
|
+
const distDir = import_node_path26.default.join(appDir, "dist");
|
|
19665
|
+
if (!(0, import_node_fs21.existsSync)(distDir)) {
|
|
19648
19666
|
throw new Error(`No dist directory found at ${distDir}`);
|
|
19649
19667
|
}
|
|
19650
19668
|
const site = this.getSite(service);
|
|
@@ -19657,8 +19675,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19657
19675
|
async deployStatic(service, options) {
|
|
19658
19676
|
this.assertDeployableStaticSite(service);
|
|
19659
19677
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19660
|
-
const srcDir =
|
|
19661
|
-
if (!(0,
|
|
19678
|
+
const srcDir = import_node_path26.default.join(appDir, "src");
|
|
19679
|
+
if (!(0, import_node_fs21.existsSync)(srcDir)) {
|
|
19662
19680
|
throw new Error(`No src directory found at ${srcDir}`);
|
|
19663
19681
|
}
|
|
19664
19682
|
const site = this.getSite(service);
|
|
@@ -19692,8 +19710,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19692
19710
|
this.validateFcConfig(service, fc);
|
|
19693
19711
|
const repoRoot = this.resolveRepoRoot(service);
|
|
19694
19712
|
const appDir = this.resolveLocalDir(service);
|
|
19695
|
-
const packageJsonPath =
|
|
19696
|
-
if (!(0,
|
|
19713
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19714
|
+
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19697
19715
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19698
19716
|
}
|
|
19699
19717
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -19746,15 +19764,15 @@ var ServiceRuntimeRunner = class {
|
|
|
19746
19764
|
const repoRoot = this.resolveRepoRoot(service, options.cwd);
|
|
19747
19765
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19748
19766
|
await this.ensurePnpmWorkspaceRoot(repoRoot);
|
|
19749
|
-
const configPath =
|
|
19750
|
-
if (!(0,
|
|
19767
|
+
const configPath = import_node_path26.default.join(appDir, fc.configFile ?? "s.yaml");
|
|
19768
|
+
if (!(0, import_node_fs21.existsSync)(configPath)) {
|
|
19751
19769
|
throw new Error(`Missing FC config file at ${configPath}`);
|
|
19752
19770
|
}
|
|
19753
|
-
const packageJsonPath =
|
|
19754
|
-
if (!(0,
|
|
19771
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19772
|
+
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19755
19773
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19756
19774
|
}
|
|
19757
|
-
const rawConfig = (0,
|
|
19775
|
+
const rawConfig = (0, import_node_fs21.readFileSync)(configPath, "utf8");
|
|
19758
19776
|
if (!rawConfig.includes(fc.functionName)) {
|
|
19759
19777
|
throw new Error(`FC config ${configPath} does not mention functionName ${fc.functionName}`);
|
|
19760
19778
|
}
|
|
@@ -20032,7 +20050,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20032
20050
|
const serverAddress = await resolveServerAddress(server);
|
|
20033
20051
|
const templateName = exposeType === "websocket" ? "nginx.ws.template" : "nginx.rest.template";
|
|
20034
20052
|
const templatePath = this.resolveTemplatePath(templateName);
|
|
20035
|
-
const template = (0,
|
|
20053
|
+
const template = (0, import_node_fs21.readFileSync)(templatePath, "utf8");
|
|
20036
20054
|
const host = `${subdomain}.${("domain" in network ? network.domain?.trim() : void 0) || "pmate.chat"}`;
|
|
20037
20055
|
const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
|
|
20038
20056
|
const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
|
|
@@ -20064,11 +20082,11 @@ var ServiceRuntimeRunner = class {
|
|
|
20064
20082
|
}
|
|
20065
20083
|
if (config.ensurePackageJson) {
|
|
20066
20084
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
20067
|
-
const packageJsonPath =
|
|
20068
|
-
if (!(0,
|
|
20085
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
20086
|
+
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
20069
20087
|
throw new Error(`Missing package.json at ${packageJsonPath}`);
|
|
20070
20088
|
}
|
|
20071
|
-
const pkgStat = (0,
|
|
20089
|
+
const pkgStat = (0, import_node_fs21.statSync)(packageJsonPath);
|
|
20072
20090
|
if (!pkgStat.isFile()) {
|
|
20073
20091
|
throw new Error(`package.json is not a file at ${packageJsonPath}`);
|
|
20074
20092
|
}
|
|
@@ -20497,9 +20515,9 @@ var ServiceRuntimeRunner = class {
|
|
|
20497
20515
|
return tokens;
|
|
20498
20516
|
}
|
|
20499
20517
|
readPathValue(source, pathExpr) {
|
|
20500
|
-
const
|
|
20518
|
+
const path31 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
20501
20519
|
let cursor = source;
|
|
20502
|
-
for (const segment of
|
|
20520
|
+
for (const segment of path31) {
|
|
20503
20521
|
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
|
|
20504
20522
|
return void 0;
|
|
20505
20523
|
}
|
|
@@ -20542,12 +20560,12 @@ var ServiceRuntimeRunner = class {
|
|
|
20542
20560
|
}
|
|
20543
20561
|
resolveTemplatePath(templateName) {
|
|
20544
20562
|
const candidates = [
|
|
20545
|
-
|
|
20546
|
-
|
|
20547
|
-
|
|
20563
|
+
import_node_path26.default.join(__dirname, "..", "templates", templateName),
|
|
20564
|
+
import_node_path26.default.join(__dirname, "..", "src", "templates", templateName),
|
|
20565
|
+
import_node_path26.default.join(__dirname, "templates", templateName)
|
|
20548
20566
|
];
|
|
20549
20567
|
for (const candidate of candidates) {
|
|
20550
|
-
if ((0,
|
|
20568
|
+
if ((0, import_node_fs21.existsSync)(candidate)) {
|
|
20551
20569
|
return candidate;
|
|
20552
20570
|
}
|
|
20553
20571
|
}
|
|
@@ -20579,7 +20597,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20579
20597
|
});
|
|
20580
20598
|
}
|
|
20581
20599
|
loadPackageJson(packageJsonPath) {
|
|
20582
|
-
const raw = (0,
|
|
20600
|
+
const raw = (0, import_node_fs21.readFileSync)(packageJsonPath, "utf8");
|
|
20583
20601
|
const parsed = JSON.parse(raw);
|
|
20584
20602
|
if (!parsed || typeof parsed !== "object") {
|
|
20585
20603
|
throw new Error(`Invalid package.json at ${packageJsonPath}`);
|
|
@@ -20588,7 +20606,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20588
20606
|
}
|
|
20589
20607
|
writePackageJson(packageJsonPath, data) {
|
|
20590
20608
|
const serialized = JSON.stringify(data, null, 2);
|
|
20591
|
-
(0,
|
|
20609
|
+
(0, import_node_fs21.writeFileSync)(packageJsonPath, `${serialized}
|
|
20592
20610
|
`, "utf8");
|
|
20593
20611
|
}
|
|
20594
20612
|
validateFcConfig(service, fc) {
|
|
@@ -20615,8 +20633,8 @@ var ServiceRuntimeRunner = class {
|
|
|
20615
20633
|
}
|
|
20616
20634
|
}
|
|
20617
20635
|
async ensurePnpmWorkspaceRoot(repoRoot) {
|
|
20618
|
-
const workspacePath =
|
|
20619
|
-
if (!(0,
|
|
20636
|
+
const workspacePath = import_node_path26.default.join(repoRoot, "pnpm-workspace.yaml");
|
|
20637
|
+
if (!(0, import_node_fs21.existsSync)(workspacePath)) {
|
|
20620
20638
|
throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
|
|
20621
20639
|
}
|
|
20622
20640
|
}
|
|
@@ -20690,16 +20708,16 @@ var ServiceRuntimeRunner = class {
|
|
|
20690
20708
|
if (!privateKeyPath) {
|
|
20691
20709
|
throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
|
|
20692
20710
|
}
|
|
20693
|
-
if (!(0,
|
|
20711
|
+
if (!(0, import_node_fs21.existsSync)(certificatePath)) {
|
|
20694
20712
|
throw new Error(`SSL certificate file not found: ${certificatePath}`);
|
|
20695
20713
|
}
|
|
20696
|
-
if (!(0,
|
|
20714
|
+
if (!(0, import_node_fs21.existsSync)(privateKeyPath)) {
|
|
20697
20715
|
throw new Error(`SSL private key file not found: ${privateKeyPath}`);
|
|
20698
20716
|
}
|
|
20699
20717
|
return {
|
|
20700
20718
|
certName: host,
|
|
20701
|
-
certificate: (0,
|
|
20702
|
-
privateKey: (0,
|
|
20719
|
+
certificate: (0, import_node_fs21.readFileSync)(certificatePath, "utf8"),
|
|
20720
|
+
privateKey: (0, import_node_fs21.readFileSync)(privateKeyPath, "utf8")
|
|
20703
20721
|
};
|
|
20704
20722
|
}
|
|
20705
20723
|
resolveFcProtocol(fc, certConfig) {
|
|
@@ -21156,7 +21174,7 @@ var ServiceCommandHandler = class {
|
|
|
21156
21174
|
format: "dotenv"
|
|
21157
21175
|
}
|
|
21158
21176
|
);
|
|
21159
|
-
const outputPath =
|
|
21177
|
+
const outputPath = import_node_path27.default.resolve(process.cwd(), args.output);
|
|
21160
21178
|
await (0, import_promises5.writeFile)(outputPath, payload.content, "utf8");
|
|
21161
21179
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
21162
21180
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
@@ -21382,11 +21400,11 @@ var ServiceCommandHandler = class {
|
|
|
21382
21400
|
return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
21383
21401
|
}
|
|
21384
21402
|
readJsonFile(filePath) {
|
|
21385
|
-
const absolutePath =
|
|
21386
|
-
if (!(0,
|
|
21403
|
+
const absolutePath = import_node_path27.default.resolve(process.cwd(), filePath);
|
|
21404
|
+
if (!(0, import_node_fs22.existsSync)(absolutePath)) {
|
|
21387
21405
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
21388
21406
|
}
|
|
21389
|
-
const raw = (0,
|
|
21407
|
+
const raw = (0, import_node_fs22.readFileSync)(absolutePath, "utf8");
|
|
21390
21408
|
try {
|
|
21391
21409
|
return JSON.parse(raw);
|
|
21392
21410
|
} catch (error) {
|
|
@@ -22146,8 +22164,7 @@ var RoleCommandHandler = class {
|
|
|
22146
22164
|
}
|
|
22147
22165
|
readToken() {
|
|
22148
22166
|
return readRequiredSession({
|
|
22149
|
-
preferredApp: DEFAULT_APP_ID
|
|
22150
|
-
fallbackToActiveApp: true
|
|
22167
|
+
preferredApp: DEFAULT_APP_ID
|
|
22151
22168
|
}).token;
|
|
22152
22169
|
}
|
|
22153
22170
|
async request(baseUrl, token, method, pathname, body) {
|
|
@@ -22195,9 +22212,9 @@ var RoleCommandHandler = class {
|
|
|
22195
22212
|
};
|
|
22196
22213
|
|
|
22197
22214
|
// src/commands/AccountCommandHandler.ts
|
|
22198
|
-
var
|
|
22215
|
+
var import_node_fs23 = require("fs");
|
|
22199
22216
|
var import_node_crypto5 = require("crypto");
|
|
22200
|
-
var
|
|
22217
|
+
var import_node_path28 = __toESM(require("path"));
|
|
22201
22218
|
init_sessionStore();
|
|
22202
22219
|
var AccountCommandHandler = class {
|
|
22203
22220
|
async handle(args) {
|
|
@@ -22205,9 +22222,9 @@ var AccountCommandHandler = class {
|
|
|
22205
22222
|
case "bot-keygen": {
|
|
22206
22223
|
const keyFile = this.generateBotKeyFile(args.app, args.name);
|
|
22207
22224
|
const outPath = args.out ? this.resolveFilePath(args.out) : this.resolveDefaultBotKeyPath(args.app, args.name);
|
|
22208
|
-
(0,
|
|
22209
|
-
(0,
|
|
22210
|
-
(0,
|
|
22225
|
+
(0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
|
|
22226
|
+
(0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
22227
|
+
(0, import_node_fs23.chmodSync)(outPath, 384);
|
|
22211
22228
|
if (!args.json) {
|
|
22212
22229
|
ui.success(`Bot key saved to ${outPath}`);
|
|
22213
22230
|
}
|
|
@@ -22573,8 +22590,7 @@ var AccountCommandHandler = class {
|
|
|
22573
22590
|
}
|
|
22574
22591
|
readToken() {
|
|
22575
22592
|
return readRequiredSession({
|
|
22576
|
-
preferredApp: DEFAULT_APP_ID
|
|
22577
|
-
fallbackToActiveApp: true
|
|
22593
|
+
preferredApp: DEFAULT_APP_ID
|
|
22578
22594
|
}).token;
|
|
22579
22595
|
}
|
|
22580
22596
|
buildAccountViewQuery(args) {
|
|
@@ -22745,10 +22761,10 @@ var AccountCommandHandler = class {
|
|
|
22745
22761
|
throw new Error("Missing visible apps input");
|
|
22746
22762
|
}
|
|
22747
22763
|
const absolutePath = this.resolveFilePath(args.filePath);
|
|
22748
|
-
if (!(0,
|
|
22764
|
+
if (!(0, import_node_fs23.existsSync)(absolutePath)) {
|
|
22749
22765
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
22750
22766
|
}
|
|
22751
|
-
const raw = (0,
|
|
22767
|
+
const raw = (0, import_node_fs23.readFileSync)(absolutePath, "utf8");
|
|
22752
22768
|
let parsed;
|
|
22753
22769
|
try {
|
|
22754
22770
|
parsed = JSON.parse(raw);
|
|
@@ -22762,13 +22778,13 @@ var AccountCommandHandler = class {
|
|
|
22762
22778
|
return parsed;
|
|
22763
22779
|
}
|
|
22764
22780
|
resolveFilePath(filePath) {
|
|
22765
|
-
return
|
|
22781
|
+
return import_node_path28.default.resolve(process.cwd(), filePath);
|
|
22766
22782
|
}
|
|
22767
22783
|
resolveDefaultBotKeyPath(app, name) {
|
|
22768
|
-
return
|
|
22784
|
+
return import_node_path28.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
|
|
22769
22785
|
}
|
|
22770
22786
|
resolveDefaultAccessKeyPath(app, name) {
|
|
22771
|
-
return
|
|
22787
|
+
return import_node_path28.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
|
|
22772
22788
|
}
|
|
22773
22789
|
homeDir() {
|
|
22774
22790
|
return process.env.HOME || process.env.USERPROFILE || process.cwd();
|
|
@@ -22791,10 +22807,10 @@ var AccountCommandHandler = class {
|
|
|
22791
22807
|
throw new Error("Missing bot key file");
|
|
22792
22808
|
}
|
|
22793
22809
|
const absolutePath = this.resolveFilePath(filePath);
|
|
22794
|
-
if (!(0,
|
|
22810
|
+
if (!(0, import_node_fs23.existsSync)(absolutePath)) {
|
|
22795
22811
|
throw new Error(`Bot key file not found: ${absolutePath}`);
|
|
22796
22812
|
}
|
|
22797
|
-
const parsed = JSON.parse((0,
|
|
22813
|
+
const parsed = JSON.parse((0, import_node_fs23.readFileSync)(absolutePath, "utf8"));
|
|
22798
22814
|
if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
|
|
22799
22815
|
throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
|
|
22800
22816
|
}
|
|
@@ -22811,10 +22827,10 @@ var AccountCommandHandler = class {
|
|
|
22811
22827
|
throw new Error("Missing access key file");
|
|
22812
22828
|
}
|
|
22813
22829
|
const absolutePath = this.resolveFilePath(filePath);
|
|
22814
|
-
if (!(0,
|
|
22830
|
+
if (!(0, import_node_fs23.existsSync)(absolutePath)) {
|
|
22815
22831
|
throw new Error(`Access key file not found: ${absolutePath}`);
|
|
22816
22832
|
}
|
|
22817
|
-
const parsed = JSON.parse((0,
|
|
22833
|
+
const parsed = JSON.parse((0, import_node_fs23.readFileSync)(absolutePath, "utf8"));
|
|
22818
22834
|
if (parsed.type !== "pmate-access-key" || parsed.version !== 1 || !parsed.id || !parsed.app || !parsed.secret || !parsed.expiresAt) {
|
|
22819
22835
|
throw new Error(`Invalid PMate access key file: ${absolutePath}`);
|
|
22820
22836
|
}
|
|
@@ -22836,9 +22852,9 @@ var AccountCommandHandler = class {
|
|
|
22836
22852
|
createdAt: result.key.createdAt
|
|
22837
22853
|
};
|
|
22838
22854
|
const outPath = out ? this.resolveFilePath(out) : this.resolveDefaultAccessKeyPath(result.key.app, result.key.name);
|
|
22839
|
-
(0,
|
|
22840
|
-
(0,
|
|
22841
|
-
(0,
|
|
22855
|
+
(0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
|
|
22856
|
+
(0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
22857
|
+
(0, import_node_fs23.chmodSync)(outPath, 384);
|
|
22842
22858
|
}
|
|
22843
22859
|
renderAccessKeyCreateResult(result, asJson, out) {
|
|
22844
22860
|
if (asJson) {
|
|
@@ -22878,16 +22894,12 @@ var AccountCommandHandler = class {
|
|
|
22878
22894
|
}
|
|
22879
22895
|
}
|
|
22880
22896
|
async resolveLoginProfileId(login, app, authApiBaseUrl) {
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
});
|
|
22888
|
-
} catch {
|
|
22889
|
-
return login.session.identity.accessKeyId ?? login.session.identity.accountId;
|
|
22890
|
-
}
|
|
22897
|
+
return await fetchDefaultProfileId({
|
|
22898
|
+
token: login.token,
|
|
22899
|
+
app,
|
|
22900
|
+
accountId: login.session.identity.accountId,
|
|
22901
|
+
authApiBaseUrl
|
|
22902
|
+
});
|
|
22891
22903
|
}
|
|
22892
22904
|
signBotChallenge(challenge, privateKey) {
|
|
22893
22905
|
const key = (0, import_node_crypto5.createPrivateKey)({
|
|
@@ -22929,8 +22941,8 @@ function encodePathSegment2(value) {
|
|
|
22929
22941
|
}
|
|
22930
22942
|
|
|
22931
22943
|
// src/commands/OrgCommandHandler.ts
|
|
22932
|
-
var
|
|
22933
|
-
var
|
|
22944
|
+
var import_node_fs24 = require("fs");
|
|
22945
|
+
var import_node_path29 = __toESM(require("path"));
|
|
22934
22946
|
init_sessionStore();
|
|
22935
22947
|
var OrgCommandHandler = class {
|
|
22936
22948
|
async handle(args) {
|
|
@@ -23090,8 +23102,7 @@ var OrgCommandHandler = class {
|
|
|
23090
23102
|
}
|
|
23091
23103
|
readToken() {
|
|
23092
23104
|
return readRequiredSession({
|
|
23093
|
-
preferredApp: DEFAULT_APP_ID
|
|
23094
|
-
fallbackToActiveApp: true
|
|
23105
|
+
preferredApp: DEFAULT_APP_ID
|
|
23095
23106
|
}).token;
|
|
23096
23107
|
}
|
|
23097
23108
|
resolveStringArrayInput(values, filePath, itemLabel) {
|
|
@@ -23101,11 +23112,11 @@ var OrgCommandHandler = class {
|
|
|
23101
23112
|
if (!filePath) {
|
|
23102
23113
|
throw new Error(`Missing ${itemLabel} input`);
|
|
23103
23114
|
}
|
|
23104
|
-
const absolutePath =
|
|
23105
|
-
if (!(0,
|
|
23115
|
+
const absolutePath = import_node_path29.default.resolve(process.cwd(), filePath);
|
|
23116
|
+
if (!(0, import_node_fs24.existsSync)(absolutePath)) {
|
|
23106
23117
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
23107
23118
|
}
|
|
23108
|
-
const raw = (0,
|
|
23119
|
+
const raw = (0, import_node_fs24.readFileSync)(absolutePath, "utf8");
|
|
23109
23120
|
let parsed;
|
|
23110
23121
|
try {
|
|
23111
23122
|
parsed = JSON.parse(raw);
|
|
@@ -26501,7 +26512,7 @@ function requireValue12(tokens, option) {
|
|
|
26501
26512
|
|
|
26502
26513
|
// src/index.ts
|
|
26503
26514
|
var pkg = JSON.parse(
|
|
26504
|
-
(0,
|
|
26515
|
+
(0, import_node_fs25.readFileSync)(import_node_path30.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
26505
26516
|
);
|
|
26506
26517
|
var HELP_TEXT = [
|
|
26507
26518
|
import_chalk4.default.bold(`pmate v${pkg.version}`),
|
|
@@ -26517,7 +26528,8 @@ var HELP_TEXT = [
|
|
|
26517
26528
|
import_chalk4.default.bold("Commands:"),
|
|
26518
26529
|
` ${import_chalk4.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
|
|
26519
26530
|
` ${import_chalk4.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
|
|
26520
|
-
` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>]")}`,
|
|
26531
|
+
` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>] [--select-profile]")}`,
|
|
26532
|
+
` ${import_chalk4.default.gray(" [--access-key [secret] | --access-key-file <path>]")}`,
|
|
26521
26533
|
` ${import_chalk4.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
|
|
26522
26534
|
` ${import_chalk4.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
|
|
26523
26535
|
` ${import_chalk4.default.cyan("sts")} Request an OSS STS token from the CI server`,
|
|
@@ -26750,6 +26762,10 @@ function parseCommandArgs(args) {
|
|
|
26750
26762
|
const rest = args.rest.slice(1);
|
|
26751
26763
|
let app;
|
|
26752
26764
|
let profileId;
|
|
26765
|
+
let accessKey;
|
|
26766
|
+
let accessKeyFile;
|
|
26767
|
+
let accessKeyScan = false;
|
|
26768
|
+
let selectProfile = false;
|
|
26753
26769
|
while (rest.length > 0) {
|
|
26754
26770
|
const token = rest.shift();
|
|
26755
26771
|
switch (token) {
|
|
@@ -26759,11 +26775,30 @@ function parseCommandArgs(args) {
|
|
|
26759
26775
|
case "--profile-id":
|
|
26760
26776
|
profileId = requireValue13(rest, token);
|
|
26761
26777
|
break;
|
|
26778
|
+
case "--access-key":
|
|
26779
|
+
if (rest[0] && !rest[0].startsWith("--")) {
|
|
26780
|
+
accessKey = rest.shift();
|
|
26781
|
+
} else {
|
|
26782
|
+
accessKeyScan = true;
|
|
26783
|
+
}
|
|
26784
|
+
break;
|
|
26785
|
+
case "--access-key-file":
|
|
26786
|
+
accessKeyFile = requireValue13(rest, token);
|
|
26787
|
+
break;
|
|
26788
|
+
case "--select-profile":
|
|
26789
|
+
selectProfile = true;
|
|
26790
|
+
break;
|
|
26762
26791
|
default:
|
|
26763
26792
|
throw new Error(`Unknown login option: ${token}`);
|
|
26764
26793
|
}
|
|
26765
26794
|
}
|
|
26766
|
-
|
|
26795
|
+
if (accessKey && accessKeyFile) {
|
|
26796
|
+
throw new Error("--access-key and --access-key-file are mutually exclusive");
|
|
26797
|
+
}
|
|
26798
|
+
if (accessKeyScan && accessKeyFile) {
|
|
26799
|
+
throw new Error("--access-key and --access-key-file are mutually exclusive");
|
|
26800
|
+
}
|
|
26801
|
+
return { type: "login" /* Login */, app, profileId, accessKey, accessKeyFile, accessKeyScan, selectProfile };
|
|
26767
26802
|
}
|
|
26768
26803
|
if (args.rest[0] === "add-dns") {
|
|
26769
26804
|
return parseAddDnsArgs(args.rest.slice(1));
|