@vosjs/cli 0.85.0 → 0.87.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/README.md +7 -6
- package/dist/{assetManifest-32VI7OK7.js → assetManifest-UUKFWTLO.js} +3 -3
- package/dist/{chunk-M5ZBQFPG.js → chunk-2UFNOKVY.js} +2 -2
- package/dist/{chunk-PF2NEZYU.js → chunk-7A3PZARL.js} +10 -3
- package/dist/{chunk-PF2NEZYU.js.map → chunk-7A3PZARL.js.map} +1 -1
- package/dist/{chunk-NJBUBXFE.js → chunk-ACWV3Y6Y.js} +349 -84
- package/dist/chunk-ACWV3Y6Y.js.map +1 -0
- package/dist/{chunk-Q47FUCYN.js → chunk-EXDMMAPT.js} +2 -2
- package/dist/{chunk-EPSYIF2S.js → chunk-PEW5GIZF.js} +361 -58
- package/dist/chunk-PEW5GIZF.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/index.d.ts +42 -6
- package/dist/index.js +5 -5
- package/dist/manifest-OLVFUZTW.js +8 -0
- package/dist/{run-XFKADM6I.js → run-OT54QJ4T.js} +5 -5
- package/package.json +2 -2
- package/skills/VERSION +1 -1
- package/skills/launch-kit/SKILL.md +6 -2
- package/skills/product-video/SKILL.md +13 -3
- package/skills/vos-cut/SKILL.md +6 -2
- package/skills/vos-score/SKILL.md +15 -5
- package/dist/chunk-EPSYIF2S.js.map +0 -1
- package/dist/chunk-NJBUBXFE.js.map +0 -1
- package/dist/manifest-GPE4CVDR.js +0 -8
- /package/dist/{assetManifest-32VI7OK7.js.map → assetManifest-UUKFWTLO.js.map} +0 -0
- /package/dist/{chunk-M5ZBQFPG.js.map → chunk-2UFNOKVY.js.map} +0 -0
- /package/dist/{chunk-Q47FUCYN.js.map → chunk-EXDMMAPT.js.map} +0 -0
- /package/dist/{manifest-GPE4CVDR.js.map → manifest-OLVFUZTW.js.map} +0 -0
- /package/dist/{run-XFKADM6I.js.map → run-OT54QJ4T.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ASSET_ROUTE,
|
|
4
4
|
UsageError,
|
|
5
5
|
serveFile
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PEW5GIZF.js";
|
|
7
7
|
|
|
8
8
|
// src/loadConfig.ts
|
|
9
9
|
import { readFile } from "fs/promises";
|
|
@@ -573,4 +573,4 @@ export {
|
|
|
573
573
|
setFlags,
|
|
574
574
|
applyDataSets
|
|
575
575
|
};
|
|
576
|
-
//# sourceMappingURL=chunk-
|
|
576
|
+
//# sourceMappingURL=chunk-EXDMMAPT.js.map
|
|
@@ -341,9 +341,8 @@ function hasFlag(flags, name) {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
// src/plugin/platform.ts
|
|
344
|
-
import {
|
|
345
|
-
import {
|
|
346
|
-
import { dirname as dirname2, join } from "path";
|
|
344
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
345
|
+
import { join as join2 } from "path";
|
|
347
346
|
|
|
348
347
|
// src/plugin/hostAgent.ts
|
|
349
348
|
import { existsSync } from "fs";
|
|
@@ -389,6 +388,204 @@ function detectHostAgent(env = process.env, exists = existsSync) {
|
|
|
389
388
|
return null;
|
|
390
389
|
}
|
|
391
390
|
|
|
391
|
+
// src/plugin/accounts.ts
|
|
392
|
+
import {
|
|
393
|
+
existsSync as existsSync2,
|
|
394
|
+
mkdirSync as mkdirSync2,
|
|
395
|
+
readFileSync,
|
|
396
|
+
readdirSync,
|
|
397
|
+
rmSync,
|
|
398
|
+
writeFileSync as writeFileSync2
|
|
399
|
+
} from "fs";
|
|
400
|
+
import { homedir } from "os";
|
|
401
|
+
import { dirname as dirname2, join } from "path";
|
|
402
|
+
var CREDENTIALS_PATH = join(homedir(), ".config", "vos", "credentials");
|
|
403
|
+
var ACCOUNTS_DIR = join(homedir(), ".config", "vos", "accounts");
|
|
404
|
+
var DEFAULT_ORIGIN = "https://vos.so";
|
|
405
|
+
var ACCOUNT_ENV = "VOS_ACCOUNT";
|
|
406
|
+
var DEFAULT_STORE = {
|
|
407
|
+
credentialsPath: CREDENTIALS_PATH,
|
|
408
|
+
accountsDir: ACCOUNTS_DIR
|
|
409
|
+
};
|
|
410
|
+
function originOf(url) {
|
|
411
|
+
try {
|
|
412
|
+
return new URL(url).origin;
|
|
413
|
+
} catch {
|
|
414
|
+
return url.replace(/\/+$/, "");
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function accountFrom(value) {
|
|
418
|
+
if (!value || typeof value !== "object") return null;
|
|
419
|
+
const u = value;
|
|
420
|
+
if (typeof u.id !== "string" || !u.id) return null;
|
|
421
|
+
return {
|
|
422
|
+
id: u.id,
|
|
423
|
+
kind: u.kind === "org" ? "org" : "person",
|
|
424
|
+
handle: typeof u.username === "string" && u.username ? u.username : null
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function formatCredential(c) {
|
|
428
|
+
const account = c.account ? `account=${c.account.id} ${c.account.kind}${c.account.handle ? ` ${c.account.handle}` : ""}
|
|
429
|
+
` : "";
|
|
430
|
+
return `${c.key.trim()}
|
|
431
|
+
origin=${originOf(c.origin)}
|
|
432
|
+
${account}`;
|
|
433
|
+
}
|
|
434
|
+
function parseCredential(text) {
|
|
435
|
+
const [first, ...rest] = text.split("\n");
|
|
436
|
+
const key = first.trim();
|
|
437
|
+
if (!key) return null;
|
|
438
|
+
let origin = "";
|
|
439
|
+
let account = null;
|
|
440
|
+
for (const raw of rest) {
|
|
441
|
+
const line = raw.trim();
|
|
442
|
+
if (line.startsWith("origin=")) origin = originOf(line.slice(7).trim());
|
|
443
|
+
else if (line.startsWith("account=")) {
|
|
444
|
+
const [id, kind, handle] = line.slice(8).trim().split(/\s+/);
|
|
445
|
+
if (id)
|
|
446
|
+
account = {
|
|
447
|
+
id,
|
|
448
|
+
kind: kind === "org" ? "org" : "person",
|
|
449
|
+
handle: handle || null
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return { key, origin: origin || DEFAULT_ORIGIN, account };
|
|
454
|
+
}
|
|
455
|
+
function readFile(path) {
|
|
456
|
+
try {
|
|
457
|
+
return parseCredential(readFileSync(path, "utf8"));
|
|
458
|
+
} catch {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function writeFile2(path, c) {
|
|
463
|
+
mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
|
|
464
|
+
writeFileSync2(path, formatCredential(c), { mode: 384 });
|
|
465
|
+
}
|
|
466
|
+
function hostDir(origin) {
|
|
467
|
+
let host;
|
|
468
|
+
try {
|
|
469
|
+
host = new URL(origin).host;
|
|
470
|
+
} catch {
|
|
471
|
+
host = origin.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
|
|
472
|
+
}
|
|
473
|
+
return host.replace(/[^A-Za-z0-9.-]/g, "_") || "unknown";
|
|
474
|
+
}
|
|
475
|
+
function accountPath(store, origin, accountId) {
|
|
476
|
+
return join(store.accountsDir, hostDir(origin), accountId);
|
|
477
|
+
}
|
|
478
|
+
function readActive(store = DEFAULT_STORE) {
|
|
479
|
+
return readFile(store.credentialsPath);
|
|
480
|
+
}
|
|
481
|
+
function listStored(store = DEFAULT_STORE, origin) {
|
|
482
|
+
const active = readActive(store);
|
|
483
|
+
const want = origin ? originOf(origin) : null;
|
|
484
|
+
const out = [];
|
|
485
|
+
const seen = /* @__PURE__ */ new Set();
|
|
486
|
+
const push = (c) => {
|
|
487
|
+
if (!c || want && c.origin !== want || seen.has(c.key)) return;
|
|
488
|
+
seen.add(c.key);
|
|
489
|
+
out.push(c);
|
|
490
|
+
};
|
|
491
|
+
push(active);
|
|
492
|
+
let hosts = [];
|
|
493
|
+
try {
|
|
494
|
+
hosts = readdirSync(store.accountsDir);
|
|
495
|
+
} catch {
|
|
496
|
+
return out;
|
|
497
|
+
}
|
|
498
|
+
for (const host of hosts.sort()) {
|
|
499
|
+
let files = [];
|
|
500
|
+
try {
|
|
501
|
+
files = readdirSync(join(store.accountsDir, host));
|
|
502
|
+
} catch {
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
for (const file of files.sort()) {
|
|
506
|
+
push(readFile(join(store.accountsDir, host, file)));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return out;
|
|
510
|
+
}
|
|
511
|
+
function isActive(c, store = DEFAULT_STORE) {
|
|
512
|
+
return readActive(store)?.key === c.key;
|
|
513
|
+
}
|
|
514
|
+
function accountLabel(a) {
|
|
515
|
+
if (!a) return "an unnamed account";
|
|
516
|
+
return a.handle ? `@${a.handle}` : a.id;
|
|
517
|
+
}
|
|
518
|
+
function matchesAccount(a, ref) {
|
|
519
|
+
if (!a) return false;
|
|
520
|
+
const want = ref.trim().replace(/^@/, "");
|
|
521
|
+
if (!want) return false;
|
|
522
|
+
if (a.id === want) return true;
|
|
523
|
+
return !!a.handle && a.handle.toLowerCase() === want.toLowerCase();
|
|
524
|
+
}
|
|
525
|
+
function findStored(store, origin, ref) {
|
|
526
|
+
return listStored(store, origin).find((c) => matchesAccount(c.account, ref)) ?? null;
|
|
527
|
+
}
|
|
528
|
+
function activate(store, c) {
|
|
529
|
+
writeFile2(store.credentialsPath, c);
|
|
530
|
+
return store.credentialsPath;
|
|
531
|
+
}
|
|
532
|
+
function storeCredential(store, c) {
|
|
533
|
+
const previous = readActive(store);
|
|
534
|
+
let setAside = null;
|
|
535
|
+
if (previous && previous.key !== c.key) {
|
|
536
|
+
if (previous.account) {
|
|
537
|
+
writeFile2(
|
|
538
|
+
accountPath(store, previous.origin, previous.account.id),
|
|
539
|
+
previous
|
|
540
|
+
);
|
|
541
|
+
setAside = previous;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (c.account) writeFile2(accountPath(store, c.origin, c.account.id), c);
|
|
545
|
+
return { path: activate(store, c), setAside };
|
|
546
|
+
}
|
|
547
|
+
function removeStored(store, c) {
|
|
548
|
+
const wasActive = isActive(c, store);
|
|
549
|
+
if (c.account) {
|
|
550
|
+
rmSync(accountPath(store, c.origin, c.account.id), { force: true });
|
|
551
|
+
}
|
|
552
|
+
if (wasActive) rmSync(store.credentialsPath, { force: true });
|
|
553
|
+
return { wasActive };
|
|
554
|
+
}
|
|
555
|
+
function removeAll(store) {
|
|
556
|
+
const had = existsSync2(store.credentialsPath) || existsSync2(store.accountsDir);
|
|
557
|
+
rmSync(store.credentialsPath, { force: true });
|
|
558
|
+
rmSync(store.accountsDir, { recursive: true, force: true });
|
|
559
|
+
return { had };
|
|
560
|
+
}
|
|
561
|
+
function switchTarget(stored, activeKey, ref, origin) {
|
|
562
|
+
if (ref) {
|
|
563
|
+
const to = stored.find((c) => matchesAccount(c.account, ref));
|
|
564
|
+
if (!to)
|
|
565
|
+
return {
|
|
566
|
+
ok: false,
|
|
567
|
+
error: `no credential stored for ${ref.startsWith("@") ? ref : `@${ref.replace(/^@/, "")}`} on ${origin}; run vos login and approve as it${stored.length ? `, or vos switch ${stored.map((c) => accountLabel(c.account)).join(" | ")}` : ""}`
|
|
568
|
+
};
|
|
569
|
+
return { ok: true, to };
|
|
570
|
+
}
|
|
571
|
+
const others = stored.filter((c) => c.key !== activeKey);
|
|
572
|
+
if (stored.length === 0)
|
|
573
|
+
return {
|
|
574
|
+
ok: false,
|
|
575
|
+
error: `nothing is stored for ${origin}; run vos login`
|
|
576
|
+
};
|
|
577
|
+
if (stored.length === 1)
|
|
578
|
+
return {
|
|
579
|
+
ok: false,
|
|
580
|
+
error: `only ${accountLabel(stored[0].account)} is stored for ${origin}; run vos login and approve as another account to add one`
|
|
581
|
+
};
|
|
582
|
+
if (others.length === 1) return { ok: true, to: others[0] };
|
|
583
|
+
return {
|
|
584
|
+
ok: false,
|
|
585
|
+
error: `say which: vos switch ${stored.map((c) => accountLabel(c.account)).join(" | ")}`
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
392
589
|
// src/plugin/platform.ts
|
|
393
590
|
function platformOrigin(flags = {}) {
|
|
394
591
|
const legacyEnv = process.env.VOS_API_BASE?.trim();
|
|
@@ -422,40 +619,116 @@ function parseVosId(input) {
|
|
|
422
619
|
function deriveSlug(title) {
|
|
423
620
|
return title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 50).replace(/-+$/, "") || "remix";
|
|
424
621
|
}
|
|
425
|
-
var
|
|
426
|
-
var
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
} catch {
|
|
431
|
-
return url.replace(/\/+$/, "");
|
|
432
|
-
}
|
|
622
|
+
var storedFor = /* @__PURE__ */ new Map();
|
|
623
|
+
var warned = /* @__PURE__ */ new Set();
|
|
624
|
+
var lastResolved = null;
|
|
625
|
+
function lastCredential() {
|
|
626
|
+
return lastResolved;
|
|
433
627
|
}
|
|
434
|
-
function
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
628
|
+
function directoryVerdict(state, origin, stored, dir) {
|
|
629
|
+
if (!state?.account) return { kind: "none" };
|
|
630
|
+
if (state.origin && originOf(state.origin) !== originOf(origin)) {
|
|
631
|
+
return {
|
|
632
|
+
kind: "other-origin",
|
|
633
|
+
note: `note: ${dir} was last pushed to ${state.origin}, and this command goes to ${originOf(origin)}`
|
|
634
|
+
};
|
|
440
635
|
}
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
636
|
+
if (stored) return { kind: "use", credential: stored };
|
|
637
|
+
const name = state.account.handle ? `@${state.account.handle}` : state.account.id;
|
|
638
|
+
const ref = state.account.handle ?? state.account.id;
|
|
639
|
+
return {
|
|
640
|
+
kind: "missing",
|
|
641
|
+
error: `${dir} belongs to ${name}, and no credential for it is stored for ${originOf(origin)}. Run vos login and approve as ${name}, or vos switch ${ref} if it is stored under another name, or pass --account or --key.`
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function credentialFlags(flags) {
|
|
645
|
+
const str = (name) => typeof flags[name] === "string" ? flags[name] : void 0;
|
|
646
|
+
return {
|
|
647
|
+
key: str("key"),
|
|
648
|
+
account: str("account"),
|
|
649
|
+
origin: platformOrigin({ origin: str("origin"), api: str("api") })
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function fromStore(c, via) {
|
|
653
|
+
if (!c) return null;
|
|
654
|
+
storedFor.set(c.key, c.origin);
|
|
655
|
+
lastResolved = { key: c.key, via, account: c.account, origin: c.origin };
|
|
656
|
+
return c.key;
|
|
447
657
|
}
|
|
448
|
-
var storedFor = /* @__PURE__ */ new Map();
|
|
449
|
-
var warned = /* @__PURE__ */ new Set();
|
|
450
658
|
function resolveCredential(explicit, path = CREDENTIALS_PATH) {
|
|
451
|
-
const
|
|
452
|
-
|
|
659
|
+
const ask = typeof explicit === "string" || explicit === void 0 ? { key: explicit } : explicit;
|
|
660
|
+
const store = ask.store ?? {
|
|
661
|
+
...DEFAULT_STORE,
|
|
662
|
+
...path !== CREDENTIALS_PATH ? { credentialsPath: path } : {}
|
|
663
|
+
};
|
|
664
|
+
const origin = ask.origin ?? platformOrigin();
|
|
665
|
+
const flag = ask.key?.trim();
|
|
666
|
+
if (flag) {
|
|
667
|
+
lastResolved = { key: flag, via: "flag", account: null, origin: null };
|
|
668
|
+
return flag;
|
|
669
|
+
}
|
|
670
|
+
const named = ask.account?.trim();
|
|
671
|
+
if (named) {
|
|
672
|
+
const found = findStored(store, origin, named);
|
|
673
|
+
if (!found)
|
|
674
|
+
throw new Error(noSuchAccount(store, origin, named, "--account"));
|
|
675
|
+
return fromStore(found, "account-flag");
|
|
676
|
+
}
|
|
453
677
|
const env = process.env.VOS_API_KEY?.trim();
|
|
454
|
-
if (env)
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
678
|
+
if (env) {
|
|
679
|
+
lastResolved = { key: env, via: "env", account: null, origin: null };
|
|
680
|
+
return env;
|
|
681
|
+
}
|
|
682
|
+
const envName = process.env[ACCOUNT_ENV]?.trim();
|
|
683
|
+
if (envName) {
|
|
684
|
+
const found = findStored(store, origin, envName);
|
|
685
|
+
if (!found)
|
|
686
|
+
throw new Error(noSuchAccount(store, origin, envName, ACCOUNT_ENV));
|
|
687
|
+
return fromStore(found, "account-env");
|
|
688
|
+
}
|
|
689
|
+
if (ask.dir) {
|
|
690
|
+
const state = readSyncState(ask.dir);
|
|
691
|
+
const verdict = directoryVerdict(
|
|
692
|
+
state,
|
|
693
|
+
origin,
|
|
694
|
+
state?.account ? findStored(store, origin, state.account.id) : null,
|
|
695
|
+
ask.dir
|
|
696
|
+
);
|
|
697
|
+
if (verdict.kind === "use")
|
|
698
|
+
return fromStore(verdict.credential, "directory");
|
|
699
|
+
if (verdict.kind === "missing") throw new Error(verdict.error);
|
|
700
|
+
if (verdict.kind === "other-origin" && !warned.has(verdict.note)) {
|
|
701
|
+
warned.add(verdict.note);
|
|
702
|
+
process.stderr.write(`${verdict.note}
|
|
703
|
+
`);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return fromStore(readActive(store), "stored");
|
|
707
|
+
}
|
|
708
|
+
var accountOfKey = /* @__PURE__ */ new Map();
|
|
709
|
+
function credentialAccount(origin, key) {
|
|
710
|
+
const last = lastResolved;
|
|
711
|
+
if (last && last.key === key && last.account)
|
|
712
|
+
return Promise.resolve(last.account);
|
|
713
|
+
const id = `${originOf(origin)} ${key}`;
|
|
714
|
+
let pending = accountOfKey.get(id);
|
|
715
|
+
if (!pending) {
|
|
716
|
+
pending = apiJson(origin, "/api/user/whoami", { key }).then((res) => res.status === 200 ? accountFrom(res.body.user) : null).catch(() => null);
|
|
717
|
+
accountOfKey.set(id, pending);
|
|
718
|
+
}
|
|
719
|
+
return pending;
|
|
720
|
+
}
|
|
721
|
+
async function syncIdentity(origin, key) {
|
|
722
|
+
const account = key ? await credentialAccount(origin, key) : null;
|
|
723
|
+
return {
|
|
724
|
+
origin: originOf(origin),
|
|
725
|
+
...account ? { account: { id: account.id, handle: account.handle } } : {}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
function noSuchAccount(store, origin, ref, how) {
|
|
729
|
+
const have = listStored(store, origin).map((c) => accountLabel(c.account));
|
|
730
|
+
const name = ref.startsWith("@") ? ref : `@${ref}`;
|
|
731
|
+
return `${how} names ${name}, and no credential for it is stored for ${origin}: run vos login and approve as ${name}` + (have.length ? ` (stored: ${have.join(", ")})` : "");
|
|
459
732
|
}
|
|
460
733
|
function bearerFor(key, url) {
|
|
461
734
|
if (!key) return {};
|
|
@@ -477,20 +750,25 @@ var mintAt = (origin = DEFAULT_ORIGIN) => `${originOf(origin)}/app/api`;
|
|
|
477
750
|
function requireCredential(explicit, origin) {
|
|
478
751
|
const key = resolveCredential(explicit);
|
|
479
752
|
if (!key) {
|
|
753
|
+
const at = origin ?? (typeof explicit === "object" ? explicit.origin : void 0) ?? platformOrigin();
|
|
480
754
|
throw new Error(
|
|
481
|
-
`no credential found \u2014 pass --key, set VOS_API_KEY, or run \`vos login\` (mint a content key at ${mintAt(
|
|
755
|
+
`no credential found \u2014 pass --key, set VOS_API_KEY, or run \`vos login\` (mint a content key at ${mintAt(at)}; a vos_rg_ remix grant works too)`
|
|
482
756
|
);
|
|
483
757
|
}
|
|
484
758
|
return key;
|
|
485
759
|
}
|
|
486
|
-
function writeCredential(key, origin = DEFAULT_ORIGIN, path = CREDENTIALS_PATH) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
760
|
+
function writeCredential(key, origin = DEFAULT_ORIGIN, path = CREDENTIALS_PATH, account = null) {
|
|
761
|
+
return storeLogin(key, origin, account, {
|
|
762
|
+
...DEFAULT_STORE,
|
|
763
|
+
...path !== CREDENTIALS_PATH ? { credentialsPath: path } : {}
|
|
764
|
+
}).path;
|
|
765
|
+
}
|
|
766
|
+
function storeLogin(key, origin, account, store = DEFAULT_STORE) {
|
|
767
|
+
return storeCredential(store, {
|
|
768
|
+
key: key.trim(),
|
|
769
|
+
origin: originOf(origin),
|
|
770
|
+
account
|
|
492
771
|
});
|
|
493
|
-
return path;
|
|
494
772
|
}
|
|
495
773
|
function clientId(env = process.env, exists) {
|
|
496
774
|
const explicit = env.VOS_CLIENT?.trim();
|
|
@@ -548,6 +826,12 @@ function promptHint(target, vosId) {
|
|
|
548
826
|
return `vos push ${target} --vos ${vosId} --prompt "<the person's prompt, as they wrote it>"`;
|
|
549
827
|
}
|
|
550
828
|
var SYNC_STATE_NAME = "vos.json";
|
|
829
|
+
function syncAccountOf(value) {
|
|
830
|
+
if (!value || typeof value !== "object") return void 0;
|
|
831
|
+
const a = value;
|
|
832
|
+
if (typeof a.id !== "string" || !a.id) return void 0;
|
|
833
|
+
return { id: a.id, handle: typeof a.handle === "string" ? a.handle : null };
|
|
834
|
+
}
|
|
551
835
|
function hostedMediaOf(value) {
|
|
552
836
|
if (!value || typeof value !== "object") return void 0;
|
|
553
837
|
const out = {};
|
|
@@ -560,13 +844,13 @@ function hostedMediaOf(value) {
|
|
|
560
844
|
}
|
|
561
845
|
function readJsonFile(file) {
|
|
562
846
|
try {
|
|
563
|
-
return JSON.parse(
|
|
847
|
+
return JSON.parse(readFileSync2(file, "utf8"));
|
|
564
848
|
} catch {
|
|
565
849
|
return null;
|
|
566
850
|
}
|
|
567
851
|
}
|
|
568
852
|
function readSyncState(dir) {
|
|
569
|
-
const own = readJsonFile(
|
|
853
|
+
const own = readJsonFile(join2(dir, SYNC_STATE_NAME));
|
|
570
854
|
if (own && typeof own.vosId === "string") {
|
|
571
855
|
return {
|
|
572
856
|
vosId: own.vosId,
|
|
@@ -575,10 +859,12 @@ function readSyncState(dir) {
|
|
|
575
859
|
...typeof own.title === "string" ? { title: own.title } : {},
|
|
576
860
|
...typeof own.slug === "string" ? { slug: own.slug } : {},
|
|
577
861
|
...typeof own.remixOfId === "string" ? { remixOfId: own.remixOfId } : {},
|
|
578
|
-
...hostedMediaOf(own.hostedMedia) ? { hostedMedia: hostedMediaOf(own.hostedMedia) } : {}
|
|
862
|
+
...hostedMediaOf(own.hostedMedia) ? { hostedMedia: hostedMediaOf(own.hostedMedia) } : {},
|
|
863
|
+
...typeof own.origin === "string" && own.origin ? { origin: originOf(own.origin) } : {},
|
|
864
|
+
...syncAccountOf(own.account) ? { account: syncAccountOf(own.account) } : {}
|
|
579
865
|
};
|
|
580
866
|
}
|
|
581
|
-
const push = readJsonFile(
|
|
867
|
+
const push = readJsonFile(join2(dir, "push.json"));
|
|
582
868
|
if (push && typeof push.vosId === "string") {
|
|
583
869
|
return {
|
|
584
870
|
vosId: push.vosId,
|
|
@@ -586,7 +872,7 @@ function readSyncState(dir) {
|
|
|
586
872
|
...typeof push.pushedAt === "string" ? { pushedAt: push.pushedAt } : {}
|
|
587
873
|
};
|
|
588
874
|
}
|
|
589
|
-
const meta = readJsonFile(
|
|
875
|
+
const meta = readJsonFile(join2(dir, "meta.json"));
|
|
590
876
|
if (meta && typeof meta.id === "string") {
|
|
591
877
|
return {
|
|
592
878
|
vosId: meta.id,
|
|
@@ -604,7 +890,7 @@ function writeSyncState(dir, patch) {
|
|
|
604
890
|
...patch
|
|
605
891
|
};
|
|
606
892
|
writeFileSafeSync(
|
|
607
|
-
|
|
893
|
+
join2(dir, SYNC_STATE_NAME),
|
|
608
894
|
`${JSON.stringify(merged, null, 2)}
|
|
609
895
|
`
|
|
610
896
|
);
|
|
@@ -631,19 +917,19 @@ function serverWarnings(body, log) {
|
|
|
631
917
|
import { createHash } from "crypto";
|
|
632
918
|
import {
|
|
633
919
|
closeSync,
|
|
634
|
-
existsSync as
|
|
920
|
+
existsSync as existsSync3,
|
|
635
921
|
mkdirSync as mkdirSync3,
|
|
636
922
|
openSync,
|
|
637
923
|
readSync,
|
|
638
|
-
readdirSync,
|
|
924
|
+
readdirSync as readdirSync2,
|
|
639
925
|
realpathSync,
|
|
640
926
|
renameSync,
|
|
641
|
-
rmSync,
|
|
927
|
+
rmSync as rmSync2,
|
|
642
928
|
statSync,
|
|
643
929
|
writeFileSync as writeFileSync3
|
|
644
930
|
} from "fs";
|
|
645
931
|
import { homedir as homedir2 } from "os";
|
|
646
|
-
import { extname, join as
|
|
932
|
+
import { extname, join as join3, resolve, sep } from "path";
|
|
647
933
|
var ASSET_ROUTE = "/__assets/";
|
|
648
934
|
var UUID = "[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}";
|
|
649
935
|
var HOSTED_URI = new RegExp(`^asset:(${UUID})$`);
|
|
@@ -729,7 +1015,7 @@ function localFile(ref, baseDir) {
|
|
|
729
1015
|
};
|
|
730
1016
|
}
|
|
731
1017
|
const file = resolve(baseDir, ref);
|
|
732
|
-
if (!
|
|
1018
|
+
if (!existsSync3(file) || !statSync(file).isFile()) {
|
|
733
1019
|
return { refused: "which is not a file beside the config" };
|
|
734
1020
|
}
|
|
735
1021
|
const root = realpathSync(baseDir);
|
|
@@ -765,11 +1051,11 @@ function manifestRefs(config) {
|
|
|
765
1051
|
return out;
|
|
766
1052
|
}
|
|
767
1053
|
async function fetchHosted(id, opts) {
|
|
768
|
-
const dir = opts.cacheDir ??
|
|
769
|
-
const cached =
|
|
1054
|
+
const dir = opts.cacheDir ?? join3(homedir2(), ".cache", "vos", "assets");
|
|
1055
|
+
const cached = existsSync3(dir) ? readdirSync2(dir).find(
|
|
770
1056
|
(f) => (f === id || f.startsWith(`${id}.`)) && !f.endsWith(".part")
|
|
771
1057
|
) : void 0;
|
|
772
|
-
if (cached) return
|
|
1058
|
+
if (cached) return join3(dir, cached);
|
|
773
1059
|
if (!opts.origin || !opts.key) {
|
|
774
1060
|
opts.log(
|
|
775
1061
|
`note: asset ${id} is hosted and no credential is set, so the render cannot load it (vos login, or keep the file beside the config and name its path)`
|
|
@@ -787,7 +1073,7 @@ async function fetchHosted(id, opts) {
|
|
|
787
1073
|
}
|
|
788
1074
|
mkdirSync3(dir, { recursive: true, mode: 448 });
|
|
789
1075
|
const type = (res.headers.get("content-type") ?? "").split(";")[0].trim();
|
|
790
|
-
const file =
|
|
1076
|
+
const file = join3(dir, `${id}${extensionFor(type)}`);
|
|
791
1077
|
const partial = `${file}.part`;
|
|
792
1078
|
try {
|
|
793
1079
|
writeFileSync3(partial, new Uint8Array(await res.arrayBuffer()), {
|
|
@@ -795,7 +1081,7 @@ async function fetchHosted(id, opts) {
|
|
|
795
1081
|
});
|
|
796
1082
|
renameSync(partial, file);
|
|
797
1083
|
} finally {
|
|
798
|
-
|
|
1084
|
+
rmSync2(partial, { force: true });
|
|
799
1085
|
}
|
|
800
1086
|
return file;
|
|
801
1087
|
}
|
|
@@ -920,11 +1206,28 @@ export {
|
|
|
920
1206
|
numFlag2,
|
|
921
1207
|
strFlag,
|
|
922
1208
|
hasFlag,
|
|
1209
|
+
CREDENTIALS_PATH,
|
|
1210
|
+
ACCOUNT_ENV,
|
|
1211
|
+
DEFAULT_STORE,
|
|
1212
|
+
originOf,
|
|
1213
|
+
accountFrom,
|
|
1214
|
+
readActive,
|
|
1215
|
+
listStored,
|
|
1216
|
+
isActive,
|
|
1217
|
+
accountLabel,
|
|
1218
|
+
findStored,
|
|
1219
|
+
activate,
|
|
1220
|
+
removeStored,
|
|
1221
|
+
removeAll,
|
|
1222
|
+
switchTarget,
|
|
923
1223
|
platformOrigin,
|
|
924
1224
|
parseVosId,
|
|
925
1225
|
deriveSlug,
|
|
926
|
-
|
|
1226
|
+
lastCredential,
|
|
1227
|
+
credentialFlags,
|
|
927
1228
|
resolveCredential,
|
|
1229
|
+
credentialAccount,
|
|
1230
|
+
syncIdentity,
|
|
928
1231
|
bearerFor,
|
|
929
1232
|
mintAt,
|
|
930
1233
|
requireCredential,
|
|
@@ -947,4 +1250,4 @@ export {
|
|
|
947
1250
|
programAssets,
|
|
948
1251
|
missingManifestFiles
|
|
949
1252
|
};
|
|
950
|
-
//# sourceMappingURL=chunk-
|
|
1253
|
+
//# sourceMappingURL=chunk-PEW5GIZF.js.map
|